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.



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

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.



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

def attestation_statement
  @attestation_statement
end

#authenticator_dataObject (readonly)

Returns the value of attribute authenticator_data.



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

def authenticator_data
  @authenticator_data
end

#relying_partyObject (readonly)

Returns the value of attribute relying_party.



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

def relying_party
  @relying_party
end

Class Method Details

.deserialize(attestation_object, relying_party) ⇒ Object



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

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

.from_map(map, relying_party) ⇒ Object



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

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

Instance Method Details

#valid_attestation_statement?(client_data_hash) ⇒ Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/webauthn/attestation_object.rb', line 40

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

#valid_attested_credential?Boolean

Returns:

  • (Boolean)


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

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