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(attrs = {}) ⇒ ClientDataJSON
constructor
A new instance of ClientDataJSON.
Constructor Details
#initialize(attrs = {}) ⇒ 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(attrs = {}) self.type = attrs[:type] self.origin = attrs[:origin] self.challenge = attrs[:challenge] self.raw = attrs[: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_client_data_json = Base64.urlsafe_decode64 encoded_client_data_json attrs = JSON.parse( raw_client_data_json ).merge( raw: raw_client_data_json ).with_indifferent_access attrs[:challenge] = Base64.urlsafe_decode64 attrs[:challenge] new attrs end |