Class: WebAuthn::AttestationObject

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/webauthn/attestation_object.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(authenticator_data:, attestation_statement:) ⇒ AttestationObject

Returns a new instance of AttestationObject.


26
27
28
29
# File 'lib/webauthn/attestation_object.rb', line 26

def initialize(authenticator_data:, attestation_statement:)
  @authenticator_data = authenticator_data
  @attestation_statement = attestation_statement
end

Instance Attribute Details

#attestation_statementObject (readonly)

Returns the value of attribute attestation_statement


24
25
26
# File 'lib/webauthn/attestation_object.rb', line 24

def attestation_statement
  @attestation_statement
end

#authenticator_dataObject (readonly)

Returns the value of attribute authenticator_data


24
25
26
# File 'lib/webauthn/attestation_object.rb', line 24

def authenticator_data
  @authenticator_data
end

Class Method Details

.deserialize(attestation_object) ⇒ Object


13
14
15
# File 'lib/webauthn/attestation_object.rb', line 13

def self.deserialize(attestation_object)
  from_map(CBOR.decode(attestation_object))
end

.from_map(map) ⇒ Object


17
18
19
20
21
22
# File 'lib/webauthn/attestation_object.rb', line 17

def self.from_map(map)
  new(
    authenticator_data: WebAuthn::AuthenticatorData.deserialize(map["authData"]),
    attestation_statement: WebAuthn::AttestationStatement.from(map["fmt"], map["attStmt"])
  )
end

Instance Method Details

#valid_attestation_statement?(client_data_hash) ⇒ Boolean

Returns:

  • (Boolean)

36
37
38
# File 'lib/webauthn/attestation_object.rb', line 36

def valid_attestation_statement?(client_data_hash)
  attestation_statement.valid?(authenticator_data, client_data_hash)
end

#valid_attested_credential?Boolean

Returns:

  • (Boolean)

31
32
33
34
# File 'lib/webauthn/attestation_object.rb', line 31

def valid_attested_credential?
  authenticator_data.attested_credential_data_included? &&
    authenticator_data.attested_credential_data.valid?
end