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:, **options) ⇒ AuthenticatorAttestationResponse

Returns a new instance of AuthenticatorAttestationResponse.


32
33
34
35
36
# File 'lib/webauthn/authenticator_attestation_response.rb', line 32

def initialize(attestation_object:, **options)
  super(**options)

  @attestation_object_bytes = attestation_object
end

Instance Attribute Details

#attestation_trust_pathObject (readonly)

Returns the value of attribute attestation_trust_path


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

def attestation_trust_path
  @attestation_trust_path
end

#attestation_typeObject (readonly)

Returns the value of attribute attestation_type


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

def attestation_type
  @attestation_type
end

Class Method Details

.from_client(response) ⇒ Object


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

def self.from_client(response)
  encoder = WebAuthn.configuration.encoder

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

Instance Method Details

#attestation_objectObject


49
50
51
# File 'lib/webauthn/authenticator_attestation_response.rb', line 49

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

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


38
39
40
41
42
43
44
45
46
47
# File 'lib/webauthn/authenticator_attestation_response.rb', line 38

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

  verify_item(:attested_credential)
  if WebAuthn.configuration.verify_attestation_statement
    verify_item(:attestation_statement)
  end

  true
end