Class: IcAgent::DelegateIdentity
- Inherits:
-
Object
- Object
- IcAgent::DelegateIdentity
- Defined in:
- lib/ic_agent/identity.rb
Instance Attribute Summary collapse
-
#delegations ⇒ Object
readonly
Returns the value of attribute delegations.
-
#der_pubkey ⇒ Object
readonly
Returns the value of attribute der_pubkey.
-
#identity ⇒ Object
readonly
Returns the value of attribute identity.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(identity, delegation) ⇒ DelegateIdentity
constructor
A new instance of DelegateIdentity.
- #sender ⇒ Object
- #sign(msg) ⇒ Object
- #to_s ⇒ Object (also: #inspect)
Constructor Details
#initialize(identity, delegation) ⇒ DelegateIdentity
Returns a new instance of DelegateIdentity.
95 96 97 98 99 |
# File 'lib/ic_agent/identity.rb', line 95 def initialize(identity, delegation) @identity = identity @delegations = delegation['delegations'].map { |d| d } @der_pubkey = [delegation['publicKey']].pack('H*') end |
Instance Attribute Details
#delegations ⇒ Object (readonly)
Returns the value of attribute delegations.
93 94 95 |
# File 'lib/ic_agent/identity.rb', line 93 def delegations @delegations end |
#der_pubkey ⇒ Object (readonly)
Returns the value of attribute der_pubkey.
93 94 95 |
# File 'lib/ic_agent/identity.rb', line 93 def der_pubkey @der_pubkey end |
#identity ⇒ Object (readonly)
Returns the value of attribute identity.
93 94 95 |
# File 'lib/ic_agent/identity.rb', line 93 def identity @identity end |
Class Method Details
.from_json(ic_identity, ic_delegation) ⇒ Object
109 110 111 112 113 114 115 116 117 |
# File 'lib/ic_agent/identity.rb', line 109 def self.from_json(ic_identity, ic_delegation) parsed_ic_identity = JSON.parse(ic_identity) parsed_ic_delegation = JSON.parse(ic_delegation) DelegateIdentity.new( Identity.new(parsed_ic_identity[1][0...64]), parsed_ic_delegation ) end |
Instance Method Details
#sender ⇒ Object
105 106 107 |
# File 'lib/ic_agent/identity.rb', line 105 def sender Principal.self_authenticating(@der_pubkey) end |
#sign(msg) ⇒ Object
101 102 103 |
# File 'lib/ic_agent/identity.rb', line 101 def sign(msg) @identity.sign(msg) end |
#to_s ⇒ Object Also known as: inspect
119 120 121 |
# File 'lib/ic_agent/identity.rb', line 119 def to_s "(#{@identity.to_s},\n#{@delegations.to_s})" end |