selfsdk 0.0.186 → 0.0.187

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: 537d89a4c6f35651b5c5935b12861a3b76966a34858fc8c0cce2e6a0c079a574
4
- data.tar.gz: a1e8991eff4ccaf30dd7ee633a17009f43e68e383b28cedb29cd61977135b575
3
+ metadata.gz: b2efe13e1c9449fe24bbfbe5754377fe0ef1dc3bd8a5815b6ccc77f854ab8339
4
+ data.tar.gz: 07c371286f2aa7fd97ac2a4423daeb2ac3b767be2bb54c0233a7d5db8d1bde91
5
5
  SHA512:
6
- metadata.gz: f2c2a074476b655870575194c68781a905b5a6186823c732c70a612d61baa530f2e10cc501b80013571119befcc9d0decd18dc55c15e999751eb908d7576e9d8
7
- data.tar.gz: 7587e69db01c25ccaa558da3ef9f70d9a668c16d6b93c12b178f86ca8956f5a90b966e8107b9157a7211e6a2cb78ef801644792c1886ee0ea129c8d22363c5cc
6
+ metadata.gz: '0748ed14d36949e1a96b8299d325189ea0a8f554e2b31d95d0831763051c74f0440f6f319e1808372bc1f09a43c3da7035bf1554843df9adda6d1eecaa51eae6'
7
+ data.tar.gz: 73f72a6b7357359af3d07bb5067b718147a32395fdee1a24fca29a82adeaafe7956483860ab7e8b74864d9e2dbb4fef11e9193651dd79c41e56f1a21f9c65984
data/lib/crypto.rb CHANGED
@@ -141,12 +141,17 @@ module SelfSDK
141
141
  if File.exist?(session_file_name)
142
142
  # 7a) if carol's session file exists load the pickle from the file
143
143
  session_with_bob = SelfCrypto::Session.from_pickle(File.read(session_file_name), @storage_key)
144
- else
145
- # 7b-i) if you have not previously sent or received a message to/from bob,
146
- # you should extract the initial message from the group message intended
147
- # for your account id.
148
- m = SelfCrypto::GroupMessage.new(message.to_s).get_message("#{@client.jwt.id}:#{@device}")
144
+ end
145
+
146
+ # 7b-i) if you have not previously sent or received a message to/from bob,
147
+ # you should extract the initial message from the group message intended
148
+ # for your account id.
149
+ m = SelfCrypto::GroupMessage.new(message.to_s).get_message("#{@client.jwt.id}:#{@device}")
149
150
 
151
+ # if there is no session, create one
152
+ # if there is an existing session and we are sent a one time key message, check
153
+ # if it belongs to this current session and create a new inbound session if it doesn't
154
+ if session_with_bob.nil? || m.instance_of?(SelfCrypto::PreKeyMessage) and !session_with_bob.will_receive?(m)
150
155
  # 7b-ii) use the initial message to create a session for bob or carol
151
156
  session_with_bob = @account.inbound_session(m)
152
157
 
@@ -37,7 +37,7 @@ module SelfSDK
37
37
  end
38
38
 
39
39
  def validate!(original)
40
- raise ::StandardError.new("invalid origin") if @to != original.to
40
+ raise ::StandardError.new("invalid origin") if @to.split(":").first != original.to
41
41
  end
42
42
 
43
43
  def signed
@@ -152,7 +152,13 @@ module SelfSDK
152
152
  raise 'provided fact does not specify a name' if f[:fact].empty?
153
153
  return unless f.has_key? :sources
154
154
 
155
- valid_sources = [SOURCE_USER_SPECIFIED, SOURCE_PASSPORT, SOURCE_DRIVING_LICENSE, SOURCE_IDENTITY_CARD]
155
+ valid_sources = [ SOURCE_USER_SPECIFIED,
156
+ SOURCE_PASSPORT,
157
+ SOURCE_DRIVING_LICENSE,
158
+ SOURCE_IDENTITY_CARD,
159
+ SOURCE_TWITTER,
160
+ SOURCE_LINKEDIN,
161
+ SOURCE_FACEBOK ]
156
162
  factsForPassport = [ FACT_DOCUMENT_NUMBER,
157
163
  FACT_SURNAME,
158
164
  FACT_GIVEN_NAMES,
@@ -177,7 +183,11 @@ module SelfSDK
177
183
  FACT_DISPLAY_NAME,
178
184
  FACT_EMAIL,
179
185
  FACT_PHONE ]
180
-
186
+
187
+ factsForTwitter = [ FACT_ACCOUNT_ID, FACT_NICKNAME ]
188
+ factsForLinkedin = [ FACT_ACCOUNT_ID, FACT_NICKNAME ]
189
+ factsForFacebook = [ FACT_ACCOUNT_ID, FACT_NICKNAME ]
190
+
181
191
  f[:sources].each do |s|
182
192
  raise errInvalidSource unless valid_sources.include? s.to_s
183
193
 
@@ -192,6 +202,18 @@ module SelfSDK
192
202
  if s.to_s == SOURCE_USER_SPECIFIED
193
203
  raise errInvalidFactToSource unless factsForUser.include? f[:fact].to_s
194
204
  end
205
+
206
+ if s.to_s == SOURCE_TWITTER
207
+ raise errInvalidFactToSource unless factsForTwitter.include? f[:fact].to_s
208
+ end
209
+
210
+ if s.to_s == SOURCE_LINKEDIN
211
+ raise errInvalidFactToSource unless factsForLinkedin.include? f[:fact].to_s
212
+ end
213
+
214
+ if s.to_s == SOURCE_FACEBOOK
215
+ raise errInvalidFactToSource unless factsForFacebok.include? f[:fact].to_s
216
+ end
195
217
  end
196
218
  end
197
219
  end
data/lib/sources.rb CHANGED
@@ -22,11 +22,16 @@ module SelfSDK
22
22
  FACT_CATEGORIES = "categories"
23
23
  FACT_SORT_CODE = "sort_code"
24
24
  FACT_COUNTRY_OF_ISSUANCE = "country_of_issuance"
25
+ FACT_ACCOUNT_ID = "account_id"
26
+ FACT_NICKNAME = "nickname"
25
27
 
26
28
  SOURCE_USER_SPECIFIED = "user_specified"
27
29
  SOURCE_PASSPORT = "passport"
28
30
  SOURCE_DRIVING_LICENSE = "driving_license"
29
31
  SOURCE_IDENTITY_CARD = "identity_card"
32
+ SOURCE_TWITTER = "twitter"
33
+ SOURCE_LINKEDIN = "linkedin"
34
+ SOURCE_FACEBOOK = "facebook"
30
35
 
31
36
  class << self
32
37
  def message_type(s)
@@ -75,7 +80,9 @@ module SelfSDK
75
80
  valid_to: FACT_VALID_TO,
76
81
  categories: FACT_CATEGORIES,
77
82
  sort_code: FACT_SORT_CODE,
78
- country_of_issuance: FACT_COUNTRY_OF_ISSUANCE }
83
+ country_of_issuance: FACT_COUNTRY_OF_ISSUANCE,
84
+ account_id: FACT_ACCOUNT_ID,
85
+ nickname: FACT_NICKNAME }
79
86
  get(facts, input, "fact")
80
87
  end
81
88
 
@@ -83,7 +90,10 @@ module SelfSDK
83
90
  sources = { user_specified: SOURCE_USER_SPECIFIED,
84
91
  passport: SOURCE_PASSPORT,
85
92
  driving_license: SOURCE_DRIVING_LICENSE,
86
- identity_card: SOURCE_IDENTITY_CARD }
93
+ identity_card: SOURCE_IDENTITY_CARD,
94
+ twitter: SOURCE_TWITTER,
95
+ linkedin: SOURCE_LINKEDIN,
96
+ facebook: SOURCE_FACEBOOK }
87
97
  get(sources, input, "source")
88
98
  end
89
99
 
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.186
4
+ version: 0.0.187
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aldgate Ventures