Class: WebAuthn::ClientData
- Inherits:
-
Object
- Object
- WebAuthn::ClientData
- Defined in:
- lib/webauthn/client_data.rb
Constant Summary collapse
- VALID_TOKEN_BINDING_STATUSES =
["present", "supported", "not-supported"].freeze
Instance Method Summary collapse
- #challenge ⇒ Object
- #hash ⇒ Object
-
#initialize(client_data_json) ⇒ ClientData
constructor
A new instance of ClientData.
- #origin ⇒ Object
- #token_binding ⇒ Object
- #type ⇒ Object
- #valid_token_binding_format? ⇒ Boolean
Constructor Details
#initialize(client_data_json) ⇒ ClientData
Returns a new instance of ClientData.
14 15 16 |
# File 'lib/webauthn/client_data.rb', line 14 def initialize(client_data_json) @client_data_json = client_data_json end |
Instance Method Details
#challenge ⇒ Object
22 23 24 |
# File 'lib/webauthn/client_data.rb', line 22 def challenge WebAuthn.standard_encoder.decode(data["challenge"]) end |
#hash ⇒ Object
42 43 44 |
# File 'lib/webauthn/client_data.rb', line 42 def hash OpenSSL::Digest::SHA256.digest(client_data_json) end |
#origin ⇒ Object
26 27 28 |
# File 'lib/webauthn/client_data.rb', line 26 def origin data["origin"] end |
#token_binding ⇒ Object
30 31 32 |
# File 'lib/webauthn/client_data.rb', line 30 def token_binding data["tokenBinding"] end |
#type ⇒ Object
18 19 20 |
# File 'lib/webauthn/client_data.rb', line 18 def type data["type"] end |
#valid_token_binding_format? ⇒ Boolean
34 35 36 37 38 39 40 |
# File 'lib/webauthn/client_data.rb', line 34 def valid_token_binding_format? if token_binding token_binding.is_a?(Hash) && VALID_TOKEN_BINDING_STATUSES.include?(token_binding["status"]) else true end end |