Class: WebAuthn::PublicKeyCredential
- Inherits:
-
Object
- Object
- WebAuthn::PublicKeyCredential
- 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
Direct Known Subclasses
PublicKeyCredentialWithAssertion, PublicKeyCredentialWithAttestation
Defined Under Namespace
Classes: CreationOptions, Entity, InvalidChallengeError, Options, RPEntity, RequestOptions, UserEntity
Instance Attribute Summary collapse
-
#authenticator_attachment ⇒ Object
readonly
Returns the value of attribute authenticator_attachment.
-
#client_extension_outputs ⇒ Object
readonly
Returns the value of attribute client_extension_outputs.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#raw_id ⇒ Object
readonly
Returns the value of attribute raw_id.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
- #authenticator_extension_outputs ⇒ Object
- #backed_up? ⇒ Boolean
- #backup_eligible? ⇒ Boolean
-
#initialize(type:, id:, raw_id:, response:, authenticator_attachment: nil, client_extension_outputs: {}, relying_party: WebAuthn.configuration.relying_party) ⇒ PublicKeyCredential
constructor
A new instance of PublicKeyCredential.
- #sign_count ⇒ Object
- #verify(challenge, *_args) ⇒ Object
Constructor Details
#initialize(type:, id:, raw_id:, response:, authenticator_attachment: nil, client_extension_outputs: {}, relying_party: WebAuthn.configuration.relying_party) ⇒ PublicKeyCredential
Returns a new instance of PublicKeyCredential.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/webauthn/public_key_credential.rb', line 23 def initialize( type:, id:, raw_id:, response:, authenticator_attachment: nil, client_extension_outputs: {}, relying_party: WebAuthn.configuration. ) @type = type @id = id @raw_id = raw_id @client_extension_outputs = client_extension_outputs @authenticator_attachment = @response = response @relying_party = end |
Instance Attribute Details
#authenticator_attachment ⇒ Object (readonly)
Returns the value of attribute authenticator_attachment.
9 10 11 |
# File 'lib/webauthn/public_key_credential.rb', line 9 def @authenticator_attachment end |
#client_extension_outputs ⇒ Object (readonly)
Returns the value of attribute client_extension_outputs.
9 10 11 |
# File 'lib/webauthn/public_key_credential.rb', line 9 def client_extension_outputs @client_extension_outputs end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
9 10 11 |
# File 'lib/webauthn/public_key_credential.rb', line 9 def id @id end |
#raw_id ⇒ Object (readonly)
Returns the value of attribute raw_id.
9 10 11 |
# File 'lib/webauthn/public_key_credential.rb', line 9 def raw_id @raw_id end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
9 10 11 |
# File 'lib/webauthn/public_key_credential.rb', line 9 def response @response end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
9 10 11 |
# File 'lib/webauthn/public_key_credential.rb', line 9 def type @type end |
Class Method Details
.from_client(credential, relying_party: WebAuthn.configuration.relying_party) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/webauthn/public_key_credential.rb', line 11 def self.from_client(credential, relying_party: WebAuthn.configuration.) new( type: credential["type"], id: credential["id"], raw_id: .encoder.decode(credential["rawId"]), client_extension_outputs: credential["clientExtensionResults"], authenticator_attachment: credential["authenticatorAttachment"], response: response_class.from_client(credential["response"], relying_party: ), relying_party: ) end |
Instance Method Details
#authenticator_extension_outputs ⇒ Object
58 59 60 |
# File 'lib/webauthn/public_key_credential.rb', line 58 def authenticator_extension_outputs authenticator_data.extension_data if authenticator_data&.extension_data_included? end |
#backed_up? ⇒ Boolean
66 67 68 |
# File 'lib/webauthn/public_key_credential.rb', line 66 def backed_up? authenticator_data&.credential_backed_up? end |
#backup_eligible? ⇒ Boolean
62 63 64 |
# File 'lib/webauthn/public_key_credential.rb', line 62 def backup_eligible? authenticator_data&.credential_backup_eligible? end |
#sign_count ⇒ Object
54 55 56 |
# File 'lib/webauthn/public_key_credential.rb', line 54 def sign_count authenticator_data&.sign_count end |
#verify(challenge, *_args) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/webauthn/public_key_credential.rb', line 41 def verify(challenge, *_args) unless valid_class?(challenge) msg = "challenge must be a String. input challenge class: #{challenge.class}" raise(InvalidChallengeError, msg) end valid_type? || raise("invalid type") valid_id? || raise("invalid id") true end |