class WebAuthn::AttestationObject

Attributes

att_stmt[RW]
attestation_statement[RW]
auth_data[RW]
authenticator_data[RW]
fmt[RW]
format[RW]

Public Class Methods

decode(encoded_attestation_object) click to toggle source
# File lib/web_authn/attestation_object.rb, line 36
def decode(encoded_attestation_object)
  cbor = CBOR.decode(
    Base64.urlsafe_decode64 encoded_attestation_object
  ).with_indifferent_access
  new(
    fmt: cbor[:fmt],
    att_stmt: cbor[:attStmt],
    auth_data: cbor[:authData]
  )
end
new(fmt:, att_stmt:, auth_data:) click to toggle source
# File lib/web_authn/attestation_object.rb, line 12
def initialize(fmt:, att_stmt:, auth_data:)
  self.format = fmt
  self.attestation_statement = case format
  when 'none'
    nil
  when 'android-safetynet'
    AttestationStatement::AndroidSafetynet.decode att_stmt
  when 'packed'
    AttestationStatement::Packed.decode att_stmt
  when 'apple'
    AttestationStatement::Apple.decode att_stmt
  when 'tpm', 'android-key', 'fido-u2f'
    raise NotImplementedError, "Unsupported Attestation Format: #{format}"
  else
    raise InvalidContext, 'Unknown Attestation Format'
  end
  self.authenticator_data = AuthenticatorData.decode auth_data
end

Public Instance Methods

verify_signature!(client_data_json) click to toggle source
# File lib/web_authn/attestation_object.rb, line 31
def verify_signature!(client_data_json)
  attestation_statement.try(:verify!, authenticator_data, client_data_json)
end