Class: SelfSDK::Key
- Inherits:
-
Object
- Object
- SelfSDK::Key
- Defined in:
- lib/signature_graph.rb
Instance Attribute Summary collapse
-
#created ⇒ Object
readonly
Returns the value of attribute created.
-
#did ⇒ Object
readonly
Returns the value of attribute did.
-
#incoming ⇒ Object
readonly
Returns the value of attribute incoming.
-
#kid ⇒ Object
readonly
Returns the value of attribute kid.
-
#outgoing ⇒ Object
readonly
Returns the value of attribute outgoing.
-
#public_key ⇒ Object
readonly
Returns the value of attribute public_key.
-
#raw_public_key ⇒ Object
readonly
Returns the value of attribute raw_public_key.
-
#revoked ⇒ Object
readonly
Returns the value of attribute revoked.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #child_keys ⇒ Object
-
#initialize(action) ⇒ Key
constructor
A new instance of Key.
- #revoke(at) ⇒ Object
- #revoked? ⇒ Boolean
- #valid_at(at) ⇒ Object
Constructor Details
#initialize(action) ⇒ Key
Returns a new instance of Key.
62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/signature_graph.rb', line 62 def initialize(action) @kid = action[:kid] @did = action[:did] @type = action[:type] @created = action[:from] @revoked = 0 @raw_public_key = action[:key] @public_key = Ed25519::VerifyKey.new(Base64.urlsafe_decode64(@raw_public_key)) @incoming = Array.new @outgoing = Array.new end |
Instance Attribute Details
#created ⇒ Object (readonly)
Returns the value of attribute created.
60 61 62 |
# File 'lib/signature_graph.rb', line 60 def created @created end |
#did ⇒ Object (readonly)
Returns the value of attribute did.
60 61 62 |
# File 'lib/signature_graph.rb', line 60 def did @did end |
#incoming ⇒ Object (readonly)
Returns the value of attribute incoming.
60 61 62 |
# File 'lib/signature_graph.rb', line 60 def incoming @incoming end |
#kid ⇒ Object (readonly)
Returns the value of attribute kid.
60 61 62 |
# File 'lib/signature_graph.rb', line 60 def kid @kid end |
#outgoing ⇒ Object (readonly)
Returns the value of attribute outgoing.
60 61 62 |
# File 'lib/signature_graph.rb', line 60 def outgoing @outgoing end |
#public_key ⇒ Object (readonly)
Returns the value of attribute public_key.
60 61 62 |
# File 'lib/signature_graph.rb', line 60 def public_key @public_key end |
#raw_public_key ⇒ Object (readonly)
Returns the value of attribute raw_public_key.
60 61 62 |
# File 'lib/signature_graph.rb', line 60 def raw_public_key @raw_public_key end |
#revoked ⇒ Object (readonly)
Returns the value of attribute revoked.
60 61 62 |
# File 'lib/signature_graph.rb', line 60 def revoked @revoked end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
60 61 62 |
# File 'lib/signature_graph.rb', line 60 def type @type end |
Instance Method Details
#child_keys ⇒ Object
88 89 90 91 92 93 94 95 96 |
# File 'lib/signature_graph.rb', line 88 def child_keys keys = @outgoing.dup @outgoing.each do |k| keys.concat k.child_keys end keys end |
#revoke(at) ⇒ Object
80 81 82 |
# File 'lib/signature_graph.rb', line 80 def revoke(at) @revoked = at end |
#revoked? ⇒ Boolean
84 85 86 |
# File 'lib/signature_graph.rb', line 84 def revoked? @revoked > 0 end |
#valid_at(at) ⇒ Object
76 77 78 |
# File 'lib/signature_graph.rb', line 76 def valid_at(at) created <= at && revoked == 0 || created <= at && revoked > at end |