Module: SelfSDK::Messages
- Defined in:
- lib/messages/base.rb,
lib/messages/fact.rb,
lib/messages/message.rb,
lib/messages/attestation.rb,
lib/messages/fact_request.rb,
lib/messages/fact_response.rb,
lib/messages/authentication_req.rb,
lib/messages/authentication_resp.rb,
lib/messages/authentication_message.rb more...
Defined Under Namespace
Classes: Attestation, AuthenticationMessage, AuthenticationReq, AuthenticationResp, Base, Fact, FactRequest, FactResponse
Class Method Summary collapse
Class Method Details
permalink .parse(input, messaging, original = nil) ⇒ Object
[View source]
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/messages/message.rb', line 10 def self.parse(input, messaging, original=nil) body = if input.is_a? String input else issuer = input.recipient.split(":") messaging.encryption_client.decrypt(input.ciphertext, issuer.first, issuer.last) end jwt = JSON.parse(body, symbolize_names: true) payload = JSON.parse(messaging.jwt.decode(jwt[:payload]), symbolize_names: true) case payload[:typ] when "identities.facts.query.req" m = FactRequest.new(messaging) m.parse(body) when "identities.facts.query.resp" m = FactResponse.new(messaging) m.parse(body) when "identities.authenticate.resp" m = AuthenticationResp.new(messaging) m.parse(body) when "identities.authenticate.req" m = AuthenticationReq.new(messaging) m.parse(body) else raise StandardError.new("Invalid message type.") end return m end |