selfsdk 0.0.185 → 0.0.188

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: 46b877bce1cf941473947fe1980fcc28dd2998a4bf19781a8eb7563b50e5576d
4
- data.tar.gz: bcaa5355a79c64e88e846fed291f83f23034258817611e3bf23810fd9e6f57e6
3
+ metadata.gz: 585d5ba75fa375a31bcb5b48716d3b6c90ac040c75e5eec77dde03e7a3d4149d
4
+ data.tar.gz: 553e3b48e37449298f2ba166e9d56d5c9804f9dcbbc9848aa1e62aa4947c0a69
5
5
  SHA512:
6
- metadata.gz: 6365053015bbf9aff47e00eb1d40fd9a2609e1353404abab7389ce37747a3792de36c5d30e1dc3e85f3d57a2c2fe1f5de2219bf549b8008e94908974fd8f0dee
7
- data.tar.gz: ff241c95f89d25f006d1ed74cf890b7cb9c6db7580fb1e9695b082fca8200f14282b2023b7aa3b0388201c190f905e8f9e5cfa4c4ba251d693f26e1e92df3372
6
+ metadata.gz: da714cbed5d4df337a13ab3ee6fc15d364ca097bee186d0885d9d543fef195df911309d01f371a2aaf99ca2b97faf0913e754668e750eacdc7a3df7b3fe9ad64
7
+ data.tar.gz: e6228891c0026d831dc306237f3a977585d4279086d040d13e7491ad7f6e601c9459efb9cdc5a84b6e60fe001cbbf8e56593584e8bb6ac1752eba0ba4ac64c55
@@ -75,7 +75,7 @@ module SelfSDK
75
75
  def upload(ciphertext)
76
76
  uri = URI.parse("#{@url}/v1/objects")
77
77
  https = Net::HTTP.new(uri.host, uri.port)
78
- https.use_ssl = true
78
+ https.use_ssl = true if uri.scheme == "https"
79
79
  req = Net::HTTP::Post.new(uri.path)
80
80
  req["Authorization"] = "Bearer #{@token}"
81
81
  req.body = ciphertext.force_encoding("UTF-8")
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
@@ -35,6 +35,7 @@ module SelfSDK
35
35
  @description = opts.include?(:description) ? opts[:description] : nil
36
36
  @exp_timeout = opts.fetch(:exp_timeout, DEFAULT_EXP_TIMEOUT)
37
37
  @allowed_for = opts.fetch(:allowed_for, nil)
38
+ @auth = opts.fetch(:auth, false)
38
39
 
39
40
  @intermediary = if opts.include?(:intermediary)
40
41
  opts[:intermediary]
@@ -91,6 +92,7 @@ module SelfSDK
91
92
  b[:options] = @options unless (@options.nil? || @options == false)
92
93
  b[:description] = @description unless (@description.nil? || @description.empty?)
93
94
  b[:allowed_until] = (SelfSDK::Time.now + @allowed_for).strftime('%FT%TZ') unless @allowed_for.nil?
95
+ b[:auth] = @auth unless @auth.nil?
94
96
  b
95
97
  end
96
98
 
@@ -11,7 +11,7 @@ module SelfSDK
11
11
  class FactResponse < Base
12
12
  MSG_TYPE = "identities.facts.query.resp"
13
13
 
14
- attr_accessor :facts, :audience
14
+ attr_accessor :facts, :audience, :auth
15
15
 
16
16
  def parse(input, envelope=nil)
17
17
  @input = input
@@ -24,6 +24,7 @@ module SelfSDK
24
24
  @issued = ::Time.parse(payload[:iat])
25
25
  @audience = payload[:aud]
26
26
  @status = payload[:status]
27
+ @auth = payload[:auth]
27
28
  @facts = []
28
29
  payload[:facts] = [] if payload[:facts].nil?
29
30
  payload[:facts].each do |f|
@@ -69,7 +70,7 @@ module SelfSDK
69
70
  @facts.each do |fact|
70
71
  encoded_facts.push(fact.to_hash)
71
72
  end
72
-
73
+
73
74
  { typ: MSG_TYPE,
74
75
  iss: @jwt.id,
75
76
  sub: @sub || @to,
@@ -79,7 +80,8 @@ module SelfSDK
79
80
  cid: @id,
80
81
  jti: SecureRandom.uuid,
81
82
  status: @status,
82
- facts: encoded_facts }
83
+ facts: encoded_facts,
84
+ auth: @auth }
83
85
  end
84
86
 
85
87
  protected
data/lib/services/auth.rb CHANGED
@@ -89,11 +89,11 @@ module SelfSDK
89
89
  body = @client.jwt.encode(request(selfid, opts))
90
90
 
91
91
  if @client.env.empty?
92
- return "https://joinself.page.link/?link=#{callback}%3Fqr=#{body}&apn=com.joinself.app"
92
+ return "https://links.joinself.com/?link=#{callback}%3Fqr=#{body}&apn=com.joinself.app"
93
93
  elsif @client.env == 'development'
94
- return "https://joinself.page.link/?link=#{callback}%3Fqr=#{body}&apn=com.joinself.app.dev"
94
+ return "https://links.joinself.com/?link=#{callback}%3Fqr=#{body}&apn=com.joinself.app.dev"
95
95
  end
96
- "https://joinself.page.link/?link=#{callback}%3Fqr=#{body}&apn=com.joinself.app.#{@client.env}"
96
+ "https://#{@client.env}.links.joinself.com/?link=#{callback}%3Fqr=#{body}&apn=com.joinself.app.#{@client.env}"
97
97
  end
98
98
 
99
99
  # Adds an observer for an authentication response
@@ -41,6 +41,7 @@ module SelfSDK
41
41
  # @option opts [String] :cid The unique identifier of the authentication request.
42
42
  # @option opts [Integer] :exp_timeout timeout in seconds to expire the request.
43
43
  # @option opts [Integer] :allowed_for number of seconds for enabling recurrent requests.
44
+ # @option opts [Boolean] :auth allows displaying the request as anuthentication request with facts.
44
45
  # @return [Object] SelfSDK:::Messages::FactRequest
45
46
  def request(selfid, facts, opts = {}, &block)
46
47
  SelfSDK.logger.info "authenticating #{selfid}"
@@ -116,11 +117,11 @@ module SelfSDK
116
117
  body = @client.jwt.encode(request(selfid, facts, opts))
117
118
 
118
119
  if @client.env.empty?
119
- return "https://joinself.page.link/?link=#{callback}%3Fqr=#{body}&apn=com.joinself.app"
120
+ return "https://links.joinself.com/?link=#{callback}%3Fqr=#{body}&apn=com.joinself.app"
120
121
  elsif @client.env == 'development'
121
- return "https://joinself.page.link/?link=#{callback}%3Fqr=#{body}&apn=com.joinself.app.dev"
122
+ return "https://links.joinself.com/?link=#{callback}%3Fqr=#{body}&apn=com.joinself.app.dev"
122
123
  end
123
- "https://joinself.page.link/?link=#{callback}%3Fqr=#{body}&apn=com.joinself.app.#{@client.env}"
124
+ "https://#{@client.env}.links.joinself.com/?link=#{callback}%3Fqr=#{body}&apn=com.joinself.app.#{@client.env}"
124
125
  end
125
126
 
126
127
  private
@@ -151,7 +152,13 @@ module SelfSDK
151
152
  raise 'provided fact does not specify a name' if f[:fact].empty?
152
153
  return unless f.has_key? :sources
153
154
 
154
- 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 ]
155
162
  factsForPassport = [ FACT_DOCUMENT_NUMBER,
156
163
  FACT_SURNAME,
157
164
  FACT_GIVEN_NAMES,
@@ -176,7 +183,11 @@ module SelfSDK
176
183
  FACT_DISPLAY_NAME,
177
184
  FACT_EMAIL,
178
185
  FACT_PHONE ]
179
-
186
+
187
+ factsForTwitter = [ FACT_ACCOUNT_ID, FACT_NICKNAME ]
188
+ factsForLinkedin = [ FACT_ACCOUNT_ID, FACT_NICKNAME ]
189
+ factsForFacebook = [ FACT_ACCOUNT_ID, FACT_NICKNAME ]
190
+
180
191
  f[:sources].each do |s|
181
192
  raise errInvalidSource unless valid_sources.include? s.to_s
182
193
 
@@ -191,6 +202,18 @@ module SelfSDK
191
202
  if s.to_s == SOURCE_USER_SPECIFIED
192
203
  raise errInvalidFactToSource unless factsForUser.include? f[:fact].to_s
193
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
194
217
  end
195
218
  end
196
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.185
4
+ version: 0.0.188
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aldgate Ventures
@@ -98,16 +98,16 @@ dependencies:
98
98
  name: google-protobuf
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ">="
101
+ - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '0'
103
+ version: '3.19'
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ">="
108
+ - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: '0'
110
+ version: '3.19'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: httparty
113
113
  requirement: !ruby/object:Gem::Requirement