Class: WebAuthn::AuthenticatorAttestationResponse

Inherits:
AuthenticatorResponse show all
Extended by:
Forwardable
Defined in:
lib/webauthn/authenticator_attestation_response.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from AuthenticatorResponse

#client_data, #valid?

Constructor Details

#initialize(attestation_object:, transports: [], **options) ⇒ AuthenticatorAttestationResponse

Returns a new instance of AuthenticatorAttestationResponse.



33
34
35
36
37
38
39
# File 'lib/webauthn/authenticator_attestation_response.rb', line 33

def initialize(attestation_object:, transports: [], **options)
  super(**options)

  @attestation_object_bytes = attestation_object
  @transports = transports
  @relying_party = relying_party
end

Instance Attribute Details

#attestation_trust_pathObject (readonly)

Returns the value of attribute attestation_trust_path.



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

def attestation_trust_path
  @attestation_trust_path
end

#attestation_typeObject (readonly)

Returns the value of attribute attestation_type.



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

def attestation_type
  @attestation_type
end

#transportsObject (readonly)

Returns the value of attribute transports.



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

def transports
  @transports
end

Class Method Details

.from_client(response, relying_party: WebAuthn.configuration.relying_party) ⇒ Object



20
21
22
23
24
25
26
27
28
29
# File 'lib/webauthn/authenticator_attestation_response.rb', line 20

def self.from_client(response, relying_party: WebAuthn.configuration.relying_party)
  encoder = relying_party.encoder

  new(
    attestation_object: encoder.decode(response["attestationObject"]),
    transports: response["transports"],
    client_data_json: encoder.decode(response["clientDataJSON"]),
    relying_party: relying_party
  )
end

Instance Method Details

#attestation_objectObject



52
53
54
# File 'lib/webauthn/authenticator_attestation_response.rb', line 52

def attestation_object
  @attestation_object ||= WebAuthn::AttestationObject.deserialize(attestation_object_bytes, relying_party)
end

#verify(expected_challenge, expected_origin = nil, user_presence: nil, user_verification: nil, rp_id: nil) ⇒ Object



41
42
43
44
45
46
47
48
49
50
# File 'lib/webauthn/authenticator_attestation_response.rb', line 41

def verify(expected_challenge, expected_origin = nil, user_presence: nil, user_verification: nil, rp_id: nil)
  super

  verify_item(:attested_credential)
  if relying_party.verify_attestation_statement
    verify_item(:attestation_statement)
  end

  true
end