Class: WebAuthn::PublicKeyCredential

Inherits:
Object
  • Object
show all
Defined in:
lib/webauthn/public_key_credential.rb,
lib/webauthn/public_key_credential/entity.rb,
lib/webauthn/public_key_credential/options.rb,
lib/webauthn/public_key_credential/rp_entity.rb,
lib/webauthn/public_key_credential/user_entity.rb,
lib/webauthn/public_key_credential/request_options.rb,
lib/webauthn/public_key_credential/creation_options.rb

Defined Under Namespace

Classes: CreationOptions, Entity, Options, RPEntity, RequestOptions, UserEntity

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type:, id:, raw_id:, client_extension_outputs: {}, response:) ⇒ PublicKeyCredential

Returns a new instance of PublicKeyCredential.


19
20
21
22
23
24
25
# File 'lib/webauthn/public_key_credential.rb', line 19

def initialize(type:, id:, raw_id:, client_extension_outputs: {}, response:)
  @type = type
  @id = id
  @raw_id = raw_id
  @client_extension_outputs = client_extension_outputs
  @response = response
end

Instance Attribute Details

#client_extension_outputsObject (readonly)

Returns the value of attribute client_extension_outputs


7
8
9
# File 'lib/webauthn/public_key_credential.rb', line 7

def client_extension_outputs
  @client_extension_outputs
end

#idObject (readonly)

Returns the value of attribute id


7
8
9
# File 'lib/webauthn/public_key_credential.rb', line 7

def id
  @id
end

#raw_idObject (readonly)

Returns the value of attribute raw_id


7
8
9
# File 'lib/webauthn/public_key_credential.rb', line 7

def raw_id
  @raw_id
end

#responseObject (readonly)

Returns the value of attribute response


7
8
9
# File 'lib/webauthn/public_key_credential.rb', line 7

def response
  @response
end

#typeObject (readonly)

Returns the value of attribute type


7
8
9
# File 'lib/webauthn/public_key_credential.rb', line 7

def type
  @type
end

Class Method Details

.from_client(credential) ⇒ Object


9
10
11
12
13
14
15
16
17
# File 'lib/webauthn/public_key_credential.rb', line 9

def self.from_client(credential)
  new(
    type: credential["type"],
    id: credential["id"],
    raw_id: WebAuthn.configuration.encoder.decode(credential["rawId"]),
    client_extension_outputs: credential["clientExtensionResults"],
    response: response_class.from_client(credential["response"])
  )
end

Instance Method Details

#authenticator_extension_outputsObject


38
39
40
# File 'lib/webauthn/public_key_credential.rb', line 38

def authenticator_extension_outputs
  authenticator_data.extension_data if authenticator_data&.extension_data_included?
end

#sign_countObject


34
35
36
# File 'lib/webauthn/public_key_credential.rb', line 34

def sign_count
  authenticator_data&.sign_count
end

#verify(*_args) ⇒ Object


27
28
29
30
31
32
# File 'lib/webauthn/public_key_credential.rb', line 27

def verify(*_args)
  valid_type? || raise("invalid type")
  valid_id? || raise("invalid id")

  true
end