selfsdk 0.0.163 → 0.0.164
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/messages/authentication_message.rb +5 -1
- data/lib/messages/base.rb +4 -2
- data/lib/messages/fact_request.rb +6 -1
- data/lib/messages/fact_response.rb +5 -1
- data/lib/messages/message.rb +9 -7
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 37a0711ed0feb251165f49fcfdce3573cb3845dea3e02263395baada7af5d0f6
|
4
|
+
data.tar.gz: dd281cf75f58dc8ff14e22a8e71e32b400aa78a7ea806038a33c9cb8d9bf61ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 81ce8dcd9ebdbccfd0991b0479ddba10d46806588d660a4c7ace4f76cc534d62c7c3ef3074060989504b11a7876c51e66bb5ec780ddce889d780750cc5724e85
|
7
|
+
data.tar.gz: 296412709b0ad51d9e4ee748d2116f07f940168aa00c7ad9494ff432fca532f81e7c996e833641c36417f94a319a82d012fa49665eb8b7f2e651b39419ba77b5
|
@@ -9,7 +9,7 @@ module SelfSDK
|
|
9
9
|
module Messages
|
10
10
|
class AuthenticationMessage < Base
|
11
11
|
|
12
|
-
def parse(input,
|
12
|
+
def parse(input, envelope=nil)
|
13
13
|
@input = input
|
14
14
|
@typ = @typ
|
15
15
|
@payload = get_payload input
|
@@ -21,6 +21,10 @@ module SelfSDK
|
|
21
21
|
@expires = ::Time.parse(payload[:exp])
|
22
22
|
@issued = ::Time.parse(payload[:iat])
|
23
23
|
@status = payload[:status]
|
24
|
+
if envelope
|
25
|
+
issuer = envelope.sender.split(":")
|
26
|
+
@from_device = issuer.last
|
27
|
+
end
|
24
28
|
end
|
25
29
|
end
|
26
30
|
end
|
data/lib/messages/base.rb
CHANGED
@@ -27,10 +27,12 @@ module SelfSDK
|
|
27
27
|
res
|
28
28
|
end
|
29
29
|
|
30
|
-
def send_message
|
30
|
+
def send_message(device_id = nil)
|
31
31
|
check_credits!
|
32
|
+
dds = devices
|
33
|
+
dds = [device_id] if device_id
|
32
34
|
res = []
|
33
|
-
|
35
|
+
dds.each do |d|
|
34
36
|
res << @messaging.send_message(proto(d))
|
35
37
|
SelfSDK.logger.info "asynchronously requested information to #{@to}:#{d}"
|
36
38
|
end
|
@@ -39,7 +39,7 @@ module SelfSDK
|
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
-
def parse(input)
|
42
|
+
def parse(input, envelope=nil)
|
43
43
|
@input = input
|
44
44
|
@typ = MSG_TYPE
|
45
45
|
@payload = get_payload input
|
@@ -51,6 +51,11 @@ module SelfSDK
|
|
51
51
|
@description = @payload.include?(:description) ? @payload[:description] : nil
|
52
52
|
@facts = @payload[:facts]
|
53
53
|
@options = @payload[:options]
|
54
|
+
|
55
|
+
if envelope
|
56
|
+
issuer = envelope.sender.split(":")
|
57
|
+
@from_device = issuer.last
|
58
|
+
end
|
54
59
|
end
|
55
60
|
|
56
61
|
def build_response
|
@@ -13,7 +13,7 @@ module SelfSDK
|
|
13
13
|
|
14
14
|
attr_accessor :facts, :audience
|
15
15
|
|
16
|
-
def parse(input)
|
16
|
+
def parse(input, envelope=nil)
|
17
17
|
@input = input
|
18
18
|
@typ = MSG_TYPE
|
19
19
|
@payload = get_payload input
|
@@ -35,6 +35,10 @@ module SelfSDK
|
|
35
35
|
SelfSDK.logger.info e.message
|
36
36
|
end
|
37
37
|
end
|
38
|
+
if envelope
|
39
|
+
issuer = envelope.sender.split(":")
|
40
|
+
@from_device = issuer.last
|
41
|
+
end
|
38
42
|
end
|
39
43
|
|
40
44
|
def fact(name)
|
data/lib/messages/message.rb
CHANGED
@@ -10,11 +10,13 @@ require_relative "authentication_req"
|
|
10
10
|
module SelfSDK
|
11
11
|
module Messages
|
12
12
|
def self.parse(input, messaging, original=nil)
|
13
|
+
envelope = nil
|
13
14
|
body = if input.is_a? String
|
14
|
-
|
15
|
+
input
|
15
16
|
else
|
16
|
-
|
17
|
-
|
17
|
+
envelope = input
|
18
|
+
issuer = input.sender.split(":")
|
19
|
+
messaging.encryption_client.decrypt(input.ciphertext, issuer.first, issuer.last)
|
18
20
|
end
|
19
21
|
|
20
22
|
jwt = JSON.parse(body, symbolize_names: true)
|
@@ -23,16 +25,16 @@ module SelfSDK
|
|
23
25
|
case payload[:typ]
|
24
26
|
when "identities.facts.query.req"
|
25
27
|
m = FactRequest.new(messaging)
|
26
|
-
m.parse(body)
|
28
|
+
m.parse(body, envelope)
|
27
29
|
when "identities.facts.query.resp"
|
28
30
|
m = FactResponse.new(messaging)
|
29
|
-
m.parse(body)
|
31
|
+
m.parse(body, envelope)
|
30
32
|
when "identities.authenticate.resp"
|
31
33
|
m = AuthenticationResp.new(messaging)
|
32
|
-
m.parse(body)
|
34
|
+
m.parse(body, envelope)
|
33
35
|
when "identities.authenticate.req"
|
34
36
|
m = AuthenticationReq.new(messaging)
|
35
|
-
m.parse(body)
|
37
|
+
m.parse(body, envelope)
|
36
38
|
else
|
37
39
|
raise StandardError.new("Invalid message type.")
|
38
40
|
end
|