Class: Fido2Credential

Inherits:
Dry::Struct
  • Object
show all
Defined in:
lib/schemas.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_dynamic!(d) ⇒ Object



2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
# File 'lib/schemas.rb', line 2914

def self.from_dynamic!(d)
  d = Types::Hash[d]
  new(
    counter:           d.fetch("counter"),
    creation_date:     d.fetch("creationDate"),
    credential_id:     d.fetch("credentialId"),
    discoverable:      d.fetch("discoverable"),
    key_algorithm:     d.fetch("keyAlgorithm"),
    key_curve:         d.fetch("keyCurve"),
    key_type:          d.fetch("keyType"),
    key_value:         d.fetch("keyValue"),
    rp_id:             d.fetch("rpId"),
    rp_name:           d["rpName"],
    user_display_name: d["userDisplayName"],
    user_handle:       d["userHandle"],
    user_name:         d["userName"],
  )
end

.from_json!(json) ⇒ Object



2933
2934
2935
# File 'lib/schemas.rb', line 2933

def self.from_json!(json)
  from_dynamic!(JSON.parse(json))
end

Instance Method Details

#to_dynamicObject



2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
# File 'lib/schemas.rb', line 2937

def to_dynamic
  {
    "counter"         => counter,
    "creationDate"    => creation_date,
    "credentialId"    => credential_id,
    "discoverable"    => discoverable,
    "keyAlgorithm"    => key_algorithm,
    "keyCurve"        => key_curve,
    "keyType"         => key_type,
    "keyValue"        => key_value,
    "rpId"            => rp_id,
    "rpName"          => rp_name,
    "userDisplayName" => user_display_name,
    "userHandle"      => user_handle,
    "userName"        => user_name,
  }
end

#to_json(options = nil) ⇒ Object



2955
2956
2957
# File 'lib/schemas.rb', line 2955

def to_json(options = nil)
  JSON.generate(to_dynamic, options)
end