Class: SelfSDK::Messages::ConnectionRequest
- Defined in:
- lib/messages/connection_request.rb
Constant Summary collapse
- MSG_TYPE =
"identities.connections.req"
- DEFAULT_EXP_TIMEOUT =
9000
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
- #body ⇒ Object
-
#initialize(messaging) ⇒ ConnectionRequest
constructor
A new instance of ConnectionRequest.
- #parse(input, envelope = nil) ⇒ Object
- #populate(selfid, opts) ⇒ Object
Methods inherited from Base
#accepted?, #encrypt_message, #errored?, #rejected?, #request, #send_message, #unauthorized?, #validate!
Constructor Details
#initialize(messaging) ⇒ ConnectionRequest
Returns a new instance of ConnectionRequest.
17 18 19 20 |
# File 'lib/messages/connection_request.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_request.rb', line 15 def auth @auth end |
#facts ⇒ Object
Returns the value of attribute facts.
15 16 17 |
# File 'lib/messages/connection_request.rb', line 15 def facts @facts end |
#options ⇒ Object
Returns the value of attribute options.
15 16 17 |
# File 'lib/messages/connection_request.rb', line 15 def @options end |
Instance Method Details
#body ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/messages/connection_request.rb', line 35 def body { typ: MSG_TYPE, iss: @jwt.id, aud: @to, sub: @to, iat: SelfSDK::Time.now.strftime('%FT%TZ'), exp: (SelfSDK::Time.now + @exp_timeout).strftime('%FT%TZ'), jti: SecureRandom.uuid, require_confirmation: true, } end |
#parse(input, envelope = nil) ⇒ Object
29 30 31 32 33 |
# File 'lib/messages/connection_request.rb', line 29 def parse(input, envelope=nil) super @typ = MSG_TYPE @body = @payload[:msg] end |
#populate(selfid, opts) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/messages/connection_request.rb', line 22 def populate(selfid, opts) @id = SecureRandom.uuid @from = @client.jwt.id @to = selfid @exp_timeout = opts.fetch(:exp_timeout, DEFAULT_EXP_TIMEOUT) end |