Class: WebAuthn::ClientDataJSON
- Inherits:
-
Object
- Object
- WebAuthn::ClientDataJSON
- Defined in:
- lib/web_authn/client_data_json.rb
Instance Attribute Summary collapse
-
#challenge ⇒ Object
Returns the value of attribute challenge.
-
#origin ⇒ Object
Returns the value of attribute origin.
-
#raw ⇒ Object
Returns the value of attribute raw.
-
#type ⇒ Object
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(type:, origin:, challenge:, raw: nil) ⇒ ClientDataJSON
constructor
A new instance of ClientDataJSON.
Constructor Details
#initialize(type:, origin:, challenge:, raw: nil) ⇒ ClientDataJSON
Returns a new instance of ClientDataJSON.
5 6 7 8 9 10 |
# File 'lib/web_authn/client_data_json.rb', line 5 def initialize(type:, origin:, challenge:, raw: nil) self.type = type self.origin = origin self.challenge = challenge self.raw = raw end |
Instance Attribute Details
#challenge ⇒ Object
Returns the value of attribute challenge.
3 4 5 |
# File 'lib/web_authn/client_data_json.rb', line 3 def challenge @challenge end |
#origin ⇒ Object
Returns the value of attribute origin.
3 4 5 |
# File 'lib/web_authn/client_data_json.rb', line 3 def origin @origin end |
#raw ⇒ Object
Returns the value of attribute raw.
3 4 5 |
# File 'lib/web_authn/client_data_json.rb', line 3 def raw @raw end |
#type ⇒ Object
Returns the value of attribute type.
3 4 5 |
# File 'lib/web_authn/client_data_json.rb', line 3 def type @type end |
Class Method Details
.decode(encoded_client_data_json) ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/web_authn/client_data_json.rb', line 13 def decode(encoded_client_data_json) raw = Base64.urlsafe_decode64 encoded_client_data_json json = JSON.parse(raw).with_indifferent_access new( type: json[:type], origin: json[:origin], challenge: Base64.urlsafe_decode64(json[:challenge]), raw: raw ) end |