Class: SelfSDK::Messages::ConnectionResponse
- Defined in:
- lib/messages/connection_response.rb
Constant Summary collapse
- MSG_TYPE =
"identities.connections.resp"
- DEFAULT_EXP_TIMEOUT =
900
Instance Attribute Summary collapse
-
#auth ⇒ Object
Returns the value of attribute auth.
-
#facts ⇒ Object
Returns the value of attribute facts.
-
#options ⇒ Object
Returns the value of attribute options.
Attributes inherited from Base
#description, #exp_timeout, #expires, #fields, #from, #from_device, #id, #input, #intermediary, #payload, #status, #sub, #to, #to_device, #typ
Instance Method Summary collapse
- #get_payload(input) ⇒ Object
-
#initialize(messaging) ⇒ ConnectionResponse
constructor
A new instance of ConnectionResponse.
- #parse(input, envelope = nil) ⇒ Object
- #populate(selfid) ⇒ Object
Methods inherited from Base
#accepted?, #encrypt_message, #errored?, #rejected?, #request, #send_message, #unauthorized?, #validate!
Constructor Details
#initialize(messaging) ⇒ ConnectionResponse
Returns a new instance of ConnectionResponse.
17 18 19 20 |
# File 'lib/messages/connection_response.rb', line 17 def initialize(messaging) @typ = MSG_TYPE super end |
Instance Attribute Details
#auth ⇒ Object
Returns the value of attribute auth.
15 16 17 |
# File 'lib/messages/connection_response.rb', line 15 def auth @auth end |
#facts ⇒ Object
Returns the value of attribute facts.
15 16 17 |
# File 'lib/messages/connection_response.rb', line 15 def facts @facts end |
#options ⇒ Object
Returns the value of attribute options.
15 16 17 |
# File 'lib/messages/connection_response.rb', line 15 def @options end |
Instance Method Details
#get_payload(input) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/messages/connection_response.rb', line 35 def get_payload(input) body = if input.is_a? String input else input.ciphertext end jwt = JSON.parse(body, symbolize_names: true) payload = JSON.parse(@jwt.decode(jwt[:payload]), symbolize_names: true) header = JSON.parse(@jwt.decode(jwt[:protected]), symbolize_names: true) @from = payload[:iss] verify! jwt, header[:kid] payload end |
#parse(input, envelope = nil) ⇒ Object
28 29 30 31 32 33 |
# File 'lib/messages/connection_response.rb', line 28 def parse(input, envelope=nil) @typ = MSG_TYPE @payload = get_payload input @body = @payload[:msg] @status = @payload[:status] end |
#populate(selfid) ⇒ Object
22 23 24 25 26 |
# File 'lib/messages/connection_response.rb', line 22 def populate(selfid) @id = SecureRandom.uuid @from = @client.jwt.id @to = selfid end |