selfsdk 0.0.223 → 0.0.224

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e01c4dae273f3546f383e210f31b66d75a1d8b3154805e943a4f90ce8ff51f2b
4
- data.tar.gz: f9081aaeb82f33f593c635c83a64ab00dd2ea0f1e12a1f1e0ebded73e3d690cd
3
+ metadata.gz: 603c5c25f0cfd0f1d5e4fd8d9912c15b2d279fbbe954b60eda27ee2fae116631
4
+ data.tar.gz: 1c78db36346a7a4bf10350c0d87c12b75b990c729cd22b2ae1e83d30aeade199
5
5
  SHA512:
6
- metadata.gz: 3f42df63fda36b70919f5a23db332d39dd886225bbbdb6fe28dece6f8fb6581b3ea286f7e1e8ebca194a579ffe50049bee7fe18425f21ad712ab6ffc4787fb34
7
- data.tar.gz: c6fb329eb380e739963d94fa5e244bdd03c0d8207d4551f82fbe556a79fca94d1cc36838765ca3358700bc73caa33b963448f605d5c94843d35ea9e2f4a875cb
6
+ metadata.gz: 45f2d8427c79febc037f4e918fd8e6e24b8c1e08ffdc66567b1a33f602857737dedb2ceabf457c2adb814822697a3025f3499db2bb11acefc2200cd31144f80b
7
+ data.tar.gz: ea5d5a7ea4ed98cac59f78f5ca6552e8f48236215c72203dbc22bf7df063a0f555a7143b7b3de87b0b00b22d2bc871ba08d32f46ccefd3380698881bdfdaa349
@@ -74,12 +74,14 @@ module SelfSDK
74
74
  end
75
75
 
76
76
  def to_payload
77
+ k = build_key(@key, @nonce)
77
78
  {
78
79
  name: @name,
79
80
  link: @link,
80
- key: build_key(@key, @nonce),
81
+ key: k,
81
82
  mime: @mime,
82
- expires: @expires
83
+ expires: @expires,
84
+ public: (k == "")
83
85
  }
84
86
  end
85
87
 
@@ -111,4 +113,4 @@ module SelfSDK
111
113
  end
112
114
  end
113
115
  end
114
- end
116
+ end
@@ -7,34 +7,35 @@ require_relative '../ntptime'
7
7
  module SelfSDK
8
8
  module Messages
9
9
  class Attestation
10
- attr_accessor :verified, :origin, :source, :value, :operator, :expected_value, :fact_name, :to, :audience
10
+ attr_accessor :verified, :origin, :source, :value, :operator, :expected_value, :fact_name, :to, :audience, :payload
11
11
 
12
12
  def initialize(messaging)
13
13
  @messaging = messaging
14
14
  end
15
15
 
16
16
  def parse(name, attestation)
17
- payload = JSON.parse(@messaging.jwt.decode(attestation[:payload]), symbolize_names: true)
18
- @origin = payload[:iss]
19
- @to = payload[:sub]
20
- @audience = payload[:aud]
21
- @source = payload[:source]
17
+ @payload = JSON.parse(@messaging.jwt.decode(attestation[:payload]), symbolize_names: true)
18
+ @origin = @payload[:iss]
19
+ @to = @payload[:sub]
20
+ @audience = @payload[:aud]
21
+ @source = @payload[:source]
22
22
  header = JSON.parse(@messaging.jwt.decode(attestation[:protected]), symbolize_names: true)
23
23
  @verified = valid_signature?(attestation, header[:kid])
24
- @expected_value = payload[:expected_value]
25
- @operator = payload[:operator]
24
+ @expected_value = @payload[:expected_value]
25
+ @operator = @payload[:operator]
26
26
  @fact_name = name.to_s
27
- if payload[name].nil?
28
- return if payload[:facts].nil?
29
27
 
30
- payload[:facts].each do |f|
28
+ if @payload[name].nil?
29
+ return if @payload[:facts].nil?
30
+
31
+ @payload[:facts].each do |f|
31
32
  if f[:key] == name.to_s
32
33
  @value = f[:value]
33
34
  break
34
35
  end
35
36
  end
36
37
  else
37
- @value = payload[name]
38
+ @value = @payload[name]
38
39
  end
39
40
  end
40
41
 
data/lib/messages/fact.rb CHANGED
@@ -31,7 +31,7 @@ module SelfSDK
31
31
  fact[:attestations]&.each do |a|
32
32
  attestation = SelfSDK::Messages::Attestation.new(@messaging)
33
33
  attestation.parse(fact[:fact].to_sym, a)
34
- @attestations.push(attestation)
34
+ @attestations.push(attestation) unless attestation.value.nil?
35
35
  end
36
36
  end
37
37
 
@@ -35,6 +35,9 @@ module SelfSDK
35
35
  payload[:facts].each do |f|
36
36
  begin
37
37
  fact = SelfSDK::Messages::Fact.new(@messaging)
38
+ if f[:fact] == 'photo'
39
+ f[:fact] = :image_hash
40
+ end
38
41
  fact.parse(f)
39
42
  @facts.push(fact)
40
43
  rescue StandardError => e
@@ -45,10 +48,12 @@ module SelfSDK
45
48
  issuer = envelope.sender.split(":")
46
49
  @from_device = issuer.last
47
50
  end
51
+
48
52
  end
49
53
 
50
54
  def fact(name)
51
55
  name = @messaging.source.normalize_fact_name(name)
56
+ name = "image_hash" if name == 'photo'
52
57
  @facts.select{|f| f.name == name}.first
53
58
  end
54
59
 
@@ -59,8 +64,8 @@ module SelfSDK
59
64
  end
60
65
 
61
66
  def attestation_values_for(name)
62
- a = attestations_for(name)
63
- a.map{|a| a.value}
67
+ aa = attestations_for(name)
68
+ aa.map{|a| a.value}
64
69
  end
65
70
 
66
71
  def validate!(original)
@@ -92,6 +97,16 @@ module SelfSDK
92
97
  def auth_response?
93
98
  @auth == true
94
99
  end
100
+
101
+ def object(hash)
102
+ payload[:objects].each do |o|
103
+ if o[:image_hash] == hash
104
+ return SelfSDK::Chat::FileObject.new(
105
+ @messaging.client.jwt.auth_token,
106
+ @messaging.client.self_url).build_from_object(o)
107
+ end
108
+ end
109
+ end
95
110
  end
96
111
  end
97
112
  end
@@ -43,18 +43,6 @@ module SelfSDK
43
43
  "nationality",
44
44
  "country_of_issuance"
45
45
  ],
46
- "twitter" => [
47
- "account_id",
48
- "nickname"
49
- ],
50
- "linkedin" => [
51
- "account_id",
52
- "nickname"
53
- ],
54
- "facebook" => [
55
- "account_id",
56
- "nickname"
57
- ],
58
46
  "live" => [
59
47
  "selfie_verification"
60
48
  ]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: selfsdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.223
4
+ version: 0.0.224
5
5
  platform: ruby
6
6
  authors:
7
7
  - Self Group Ltd.