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



2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
# File 'lib/schemas.rb', line 2665

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



2684
2685
2686
# File 'lib/schemas.rb', line 2684

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

Instance Method Details

#to_dynamicObject



2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
# File 'lib/schemas.rb', line 2688

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



2706
2707
2708
# File 'lib/schemas.rb', line 2706

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