selfsdk 0.0.195 → 0.0.198
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/authenticated.rb +1 -0
- data/lib/chat/file_object.rb +1 -2
- data/lib/messages/attestation.rb +10 -1
- data/lib/messages/{authentication_req.rb → connection_request.rb} +23 -14
- data/lib/messages/connection_response.rb +52 -0
- data/lib/messages/fact.rb +7 -2
- data/lib/messages/fact_issue.rb +94 -0
- data/lib/messages/fact_request.rb +7 -1
- data/lib/messages/fact_response.rb +10 -1
- data/lib/messages/message.rb +6 -10
- data/lib/messaging.rb +1 -2
- data/lib/selfsdk.rb +7 -2
- data/lib/services/auth.rb +24 -68
- data/lib/services/chat.rb +46 -4
- data/lib/services/facts.rb +62 -143
- data/lib/services/messaging.rb +1 -1
- data/lib/services/requester.rb +184 -0
- data/lib/source_definition.rb +61 -0
- data/lib/sources.rb +13 -64
- metadata +6 -4
- data/lib/messages/authentication_message.rb +0 -31
- data/lib/messages/authentication_resp.rb +0 -25
data/lib/services/facts.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
# Copyright 2020 Self Group Ltd. All Rights Reserved.
|
2
2
|
|
3
3
|
# frozen_string_literal: true
|
4
|
+
require_relative '../messages/fact_issue.rb'
|
4
5
|
|
5
6
|
# Namespace for classes and modules that handle SelfSDK gem
|
6
7
|
module SelfSDK
|
7
8
|
# Namespace for classes and modules that handle selfsdk-gem public ui
|
8
9
|
module Services
|
9
10
|
# Self provides this self-hosted verified intermediary.
|
10
|
-
DEFAULT_INTERMEDIARY = "self_intermediary"
|
11
11
|
# Input class to handle fact requests on self network.
|
12
12
|
class Facts
|
13
13
|
# Creates a new facts service.
|
@@ -18,10 +18,8 @@ module SelfSDK
|
|
18
18
|
# @param client [SelfSDK::Client] http client object.
|
19
19
|
#
|
20
20
|
# @return [SelfSDK::Services::Facts] facts service.
|
21
|
-
def initialize(
|
22
|
-
@
|
23
|
-
@messaging_service = messaging
|
24
|
-
@client = client
|
21
|
+
def initialize(requester)
|
22
|
+
@requester = requester
|
25
23
|
end
|
26
24
|
|
27
25
|
# Sends a fact request to the specified selfid.
|
@@ -29,45 +27,24 @@ module SelfSDK
|
|
29
27
|
# permission.
|
30
28
|
#
|
31
29
|
# @overload request(selfid, facts, opts = {}, &block)
|
32
|
-
# @param selfid [string] the receiver of the
|
33
|
-
# @param [
|
34
|
-
# @
|
30
|
+
# @param selfid [string] the receiver of the fact request.
|
31
|
+
# @param facts [Array] array of facts to be requested
|
32
|
+
# @param [Hash] opts the options to process the request.
|
33
|
+
# @option opts [String] :cid The unique identifier of the fact request.
|
35
34
|
# @yield [request] Invokes the given block when a response is received.
|
36
35
|
# @return [Object] SelfSDK:::Messages::FactRequest
|
37
36
|
#
|
38
37
|
# @overload request(selfid, facts, opts = {})
|
39
|
-
# @param selfid [string] the receiver of the
|
40
|
-
# @param [
|
41
|
-
# @
|
38
|
+
# @param selfid [string] the receiver of the fact request.
|
39
|
+
# @param facts [Array] array of facts to be requested
|
40
|
+
# @param [Hash] opts the options to request.
|
41
|
+
# @option opts [String] :cid The unique identifier of the fact 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.
|
45
44
|
# @return [Object] SelfSDK:::Messages::FactRequest
|
46
45
|
def request(selfid, facts, opts = {}, &block)
|
47
|
-
|
48
|
-
|
49
|
-
if rq
|
50
|
-
raise "You're not permitting connections from #{selfid}" unless @messaging_service.is_permitted?(selfid)
|
51
|
-
end
|
52
|
-
|
53
|
-
req = SelfSDK::Messages::FactRequest.new(@messaging)
|
54
|
-
req.populate(selfid, prepare_facts(facts), opts)
|
55
|
-
|
56
|
-
body = @client.jwt.prepare(req.body)
|
57
|
-
return body unless rq
|
58
|
-
|
59
|
-
# when a block is given the request will always be asynchronous.
|
60
|
-
if block_given?
|
61
|
-
@messaging.set_observer(req, timeout: req.exp_timeout, &block)
|
62
|
-
return req.send_message
|
63
|
-
end
|
64
|
-
|
65
|
-
if opts[:async] == true
|
66
|
-
return req.send_message
|
67
|
-
end
|
68
|
-
|
69
|
-
# Otherwise the request is synchronous
|
70
|
-
req.request
|
46
|
+
opts[:auth] = false # force auth to false as you have auth service to make auth requests
|
47
|
+
@requester.request(selfid, facts, opts, &block)
|
71
48
|
end
|
72
49
|
|
73
50
|
# Sends a request through an intermediary.
|
@@ -81,8 +58,7 @@ module SelfSDK
|
|
81
58
|
# @option opts [String] intermediary an intermediary identity to be used.
|
82
59
|
# @return [Object] SelfSDK:::Messages::FactRequest
|
83
60
|
def request_via_intermediary(selfid, facts, opts = {}, &block)
|
84
|
-
|
85
|
-
request(selfid, facts, opts, &block)
|
61
|
+
@requester.request_via_intermediary(selfid, facts, opts, &block)
|
86
62
|
end
|
87
63
|
|
88
64
|
# Adds an observer for a fact response
|
@@ -90,7 +66,7 @@ module SelfSDK
|
|
90
66
|
#
|
91
67
|
# @yield [request] Invokes the block with a fact response message.
|
92
68
|
def subscribe(&block)
|
93
|
-
@
|
69
|
+
@requester.subscribe(false, &block)
|
94
70
|
end
|
95
71
|
|
96
72
|
# Generates a QR code so users can send facts to your app.
|
@@ -101,10 +77,8 @@ module SelfSDK
|
|
101
77
|
#
|
102
78
|
# @return [String, String] conversation id or encoded body.
|
103
79
|
def generate_qr(facts, opts = {})
|
104
|
-
opts[:
|
105
|
-
|
106
|
-
req = request(selfid, facts, opts)
|
107
|
-
::RQRCode::QRCode.new(req, level: 'l')
|
80
|
+
opts[:auth] = false
|
81
|
+
@requester.generate_qr(facts, opts)
|
108
82
|
end
|
109
83
|
|
110
84
|
# Generates a deep link to authenticate with self app.
|
@@ -116,113 +90,58 @@ module SelfSDK
|
|
116
90
|
#
|
117
91
|
# @return [String, String] conversation id or encoded body.
|
118
92
|
def generate_deep_link(facts, callback, opts = {})
|
119
|
-
opts[:
|
120
|
-
|
121
|
-
body = @client.jwt.encode(request(selfid, facts, opts))
|
122
|
-
|
123
|
-
if @client.env.empty?
|
124
|
-
return "https://links.joinself.com/?link=#{callback}%3Fqr=#{body}&apn=com.joinself.app"
|
125
|
-
elsif @client.env == 'development'
|
126
|
-
return "https://links.joinself.com/?link=#{callback}%3Fqr=#{body}&apn=com.joinself.app.dev"
|
127
|
-
end
|
128
|
-
"https://#{@client.env}.links.joinself.com/?link=#{callback}%3Fqr=#{body}&apn=com.joinself.app.#{@client.env}"
|
93
|
+
opts[:auth] = false
|
94
|
+
@requester.generate_deep_link(facts, callback, opts)
|
129
95
|
end
|
130
96
|
|
131
|
-
|
132
|
-
|
133
|
-
# As request facts can accept an array of strings this populates with necessary
|
134
|
-
# structure this short fact definitions.
|
97
|
+
# Issues a custom fact and sends it to the user.
|
135
98
|
#
|
136
|
-
# @param
|
137
|
-
# @
|
138
|
-
|
139
|
-
|
99
|
+
# @param selfid [String] self identifier for the message recipient.
|
100
|
+
# @param facts [Array<Fact>] facts to be sent to the user
|
101
|
+
# @option opts [String] :viewers list of self identifiers for the user that will have access to this facts.
|
102
|
+
def issue(selfid, facts, opts = {})
|
103
|
+
hased_facts = []
|
140
104
|
facts.each do |f|
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
105
|
+
hased_facts << f.to_hash
|
106
|
+
end
|
107
|
+
|
108
|
+
SelfSDK.logger.info "issuing facts for #{selfid}"
|
109
|
+
msg = SelfSDK::Messages::FactIssue.new(@requester.messaging)
|
110
|
+
msg.populate(selfid, hased_facts, opts)
|
111
|
+
|
112
|
+
msg.send_message
|
113
|
+
end
|
114
|
+
|
115
|
+
# Facts to be issued
|
116
|
+
class Fact
|
117
|
+
attr_accessor :key, :value, :group
|
118
|
+
|
119
|
+
def initialize(key, value, source, group = nil)
|
120
|
+
@key = key
|
121
|
+
@value = value
|
122
|
+
@source = source
|
123
|
+
@group = group
|
124
|
+
end
|
125
|
+
|
126
|
+
def to_hash
|
127
|
+
b = { key: @key, value: @value, source: @source }
|
128
|
+
b[:group] = @group.to_hash unless @group.nil?
|
129
|
+
b
|
148
130
|
end
|
149
|
-
fs
|
150
131
|
end
|
151
132
|
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
SOURCE_LINKEDIN,
|
165
|
-
SOURCE_FACEBOK]
|
166
|
-
fact_for_passport = [FACT_DOCUMENT_NUMBER,
|
167
|
-
FACT_SURNAME,
|
168
|
-
FACT_GIVEN_NAMES,
|
169
|
-
FACT_DATE_OF_BIRTH,
|
170
|
-
FACT_DATE_OF_EXPIRATION,
|
171
|
-
FACT_SEX,
|
172
|
-
FACT_NATIONALITY,
|
173
|
-
FACT_COUNTRY_OF_ISSUANCE]
|
174
|
-
|
175
|
-
facts_for_dl = [FACT_DOCUMENT_NUMBER,
|
176
|
-
FACT_SURNAME,
|
177
|
-
FACT_GIVEN_NAMES,
|
178
|
-
FACT_DATE_OF_BIRTH,
|
179
|
-
FACT_DATE_OF_ISSUANCE,
|
180
|
-
FACT_DATE_OF_EXPIRATION,
|
181
|
-
FACT_ADDRESS,
|
182
|
-
FACT_ISSUING_AUTHORITY,
|
183
|
-
FACT_PLACE_OF_BIRTH,
|
184
|
-
FACT_COUNTRY_OF_ISSUANCE]
|
185
|
-
|
186
|
-
facts_for_user = [FACT_DOCUMENT_NUMBER,
|
187
|
-
FACT_DISPLAY_NAME,
|
188
|
-
FACT_EMAIL,
|
189
|
-
FACT_PHONE]
|
190
|
-
|
191
|
-
facts_for_twitter = [FACT_ACCOUNT_ID, FACT_NICKNAME]
|
192
|
-
facts_for_linkedin = [FACT_ACCOUNT_ID, FACT_NICKNAME]
|
193
|
-
facts_for_facebook = [FACT_ACCOUNT_ID, FACT_NICKNAME]
|
194
|
-
facts_for_live = [FACT_SELFIE]
|
195
|
-
|
196
|
-
f[:sources].each do |s|
|
197
|
-
raise errInvalidSource unless valid_sources.include? s.to_s
|
198
|
-
|
199
|
-
if s.to_s == SOURCE_PASSPORT || s.to_s == SOURCE_IDENTITY_CARD
|
200
|
-
raise errInvalidFactToSource unless fact_for_passport.include? f[:fact]
|
201
|
-
end
|
202
|
-
|
203
|
-
if s.to_s == SOURCE_DRIVING_LICENSE
|
204
|
-
raise errInvalidFactToSource unless facts_for_dl.include? f[:fact]
|
205
|
-
end
|
206
|
-
|
207
|
-
if s.to_s == SOURCE_USER_SPECIFIED
|
208
|
-
raise errInvalidFactToSource unless facts_for_user.include? f[:fact].to_s
|
209
|
-
end
|
210
|
-
|
211
|
-
if s.to_s == SOURCE_TWITTER
|
212
|
-
raise errInvalidFactToSource unless facts_for_twitter.include? f[:fact].to_s
|
213
|
-
end
|
214
|
-
|
215
|
-
if s.to_s == SOURCE_LINKEDIN
|
216
|
-
raise errInvalidFactToSource unless facts_for_linkedin.include? f[:fact].to_s
|
217
|
-
end
|
218
|
-
|
219
|
-
if s.to_s == SOURCE_FACEBOOK
|
220
|
-
raise errInvalidFactToSource unless facts_for_facebook.include? f[:fact].to_s
|
221
|
-
end
|
222
|
-
|
223
|
-
if s.to_s == SOURCE_LIVE
|
224
|
-
raise errInvalidFactToSource unless facts_for_live.include? f[:fact].to_s
|
225
|
-
end
|
133
|
+
class Group
|
134
|
+
attr_accessor :name, :icon
|
135
|
+
|
136
|
+
def initialize(name, icon = "")
|
137
|
+
@name = name
|
138
|
+
@icon = icon
|
139
|
+
end
|
140
|
+
|
141
|
+
def to_hash
|
142
|
+
b = { name: @name }
|
143
|
+
b[:icon] = @icon unless @icon.empty?
|
144
|
+
b
|
226
145
|
end
|
227
146
|
end
|
228
147
|
end
|
data/lib/services/messaging.rb
CHANGED
@@ -26,7 +26,7 @@ module SelfSDK
|
|
26
26
|
# Subscribes to a specific message type and attaches the given observer
|
27
27
|
# which will be executed when a meeting criteria message is received.
|
28
28
|
#
|
29
|
-
# @param [String] type message type (ex: SelfSDK::Messages::
|
29
|
+
# @param [String] type message type (ex: SelfSDK::Messages::FactRequest.MSG_TYPE
|
30
30
|
# @yield [SelfSDK::Messages::Message] receives incoming message.
|
31
31
|
def subscribe(type, &block)
|
32
32
|
@client.subscribe(type, &block)
|
@@ -0,0 +1,184 @@
|
|
1
|
+
# Copyright 2020 Self Group Ltd. All Rights Reserved.
|
2
|
+
|
3
|
+
# frozen_string_literal: true
|
4
|
+
|
5
|
+
# Namespace for classes and modules that handle SelfSDK gem
|
6
|
+
module SelfSDK
|
7
|
+
# Namespace for classes and modules that handle selfsdk-gem public ui
|
8
|
+
module Services
|
9
|
+
# Self provides this self-hosted verified intermediary.
|
10
|
+
DEFAULT_INTERMEDIARY = "self_intermediary"
|
11
|
+
# Input class to handle fact requests on self network.
|
12
|
+
class Requester
|
13
|
+
attr_reader :messaging
|
14
|
+
|
15
|
+
# Creates a new facts service.
|
16
|
+
# Facts service mainly manages fact requests against self users wanting
|
17
|
+
# to share their verified facts with your app.
|
18
|
+
#
|
19
|
+
# @param messaging [SelfSDK::Messaging] messaging object.
|
20
|
+
# @param client [SelfSDK::Client] http client object.
|
21
|
+
#
|
22
|
+
# @return [SelfSDK::Services::Facts] facts service.
|
23
|
+
def initialize(messaging, client)
|
24
|
+
@messaging = messaging.client
|
25
|
+
@messaging_service = messaging
|
26
|
+
@client = client
|
27
|
+
end
|
28
|
+
|
29
|
+
# Sends a fact request to the specified selfid.
|
30
|
+
# An fact request allows your app to access trusted facts of your user with its
|
31
|
+
# permission.
|
32
|
+
#
|
33
|
+
# @overload request(selfid, facts, opts = {}, &block)
|
34
|
+
# @param selfid [string] the receiver of the authentication request.
|
35
|
+
# @param [Hash] opts the options to authenticate.
|
36
|
+
# @option opts [String] :cid The unique identifier of the authentication request.
|
37
|
+
# @yield [request] Invokes the given block when a response is received.
|
38
|
+
# @return [Object] SelfSDK:::Messages::FactRequest
|
39
|
+
#
|
40
|
+
# @overload request(selfid, facts, opts = {})
|
41
|
+
# @param selfid [string] the receiver of the authentication request.
|
42
|
+
# @param [Hash] opts the options to authenticate.
|
43
|
+
# @option opts [String] :cid The unique identifier of the authentication request.
|
44
|
+
# @option opts [Integer] :exp_timeout timeout in seconds to expire the request.
|
45
|
+
# @option opts [Integer] :allowed_for number of seconds for enabling recurrent requests.
|
46
|
+
# @option opts [Boolean] :auth allows displaying the request as anuthentication request with facts.
|
47
|
+
# @return [Object] SelfSDK:::Messages::FactRequest
|
48
|
+
def request(selfid, facts, opts = {}, &block)
|
49
|
+
SelfSDK.logger.info "authenticating #{selfid}"
|
50
|
+
rq = opts.fetch(:request, true)
|
51
|
+
if rq
|
52
|
+
raise "You're not permitting connections from #{selfid}" unless @messaging_service.is_permitted?(selfid)
|
53
|
+
end
|
54
|
+
|
55
|
+
req = SelfSDK::Messages::FactRequest.new(@messaging)
|
56
|
+
req.populate(selfid, prepare_facts(facts), opts)
|
57
|
+
|
58
|
+
body = @client.jwt.prepare(req.body)
|
59
|
+
return body unless rq
|
60
|
+
|
61
|
+
# when a block is given the request will always be asynchronous.
|
62
|
+
if block_given?
|
63
|
+
@messaging.set_observer(req, timeout: req.exp_timeout, &block)
|
64
|
+
return req.send_message
|
65
|
+
end
|
66
|
+
|
67
|
+
if opts[:async] == true
|
68
|
+
return req.send_message
|
69
|
+
end
|
70
|
+
|
71
|
+
# Otherwise the request is synchronous
|
72
|
+
req.request
|
73
|
+
end
|
74
|
+
|
75
|
+
# Sends a request through an intermediary.
|
76
|
+
# An intermediary is an entity trusted by the user and acting as a proxy between you
|
77
|
+
# and the recipient of your fact request.
|
78
|
+
# Intermediaries usually do not provide the original user facts, but they create its
|
79
|
+
# own assertions based on your request and the user's facts.
|
80
|
+
#
|
81
|
+
# @param selfid [string] the receiver of the authentication request.
|
82
|
+
# @param [Hash] opts the options to authenticate.
|
83
|
+
# @option opts [String] intermediary an intermediary identity to be used.
|
84
|
+
# @return [Object] SelfSDK:::Messages::FactRequest
|
85
|
+
def request_via_intermediary(selfid, facts, opts = {}, &block)
|
86
|
+
opts[:intermediary] = opts.fetch(:intermediary, DEFAULT_INTERMEDIARY)
|
87
|
+
request(selfid, facts, opts, &block)
|
88
|
+
end
|
89
|
+
|
90
|
+
# Adds an observer for a fact response
|
91
|
+
# Whenever you receive a fact response registered observers will receive a notification.
|
92
|
+
#
|
93
|
+
# @yield [request] Invokes the block with a fact response message.
|
94
|
+
def subscribe(auth, &block)
|
95
|
+
if auth == true
|
96
|
+
@auth_subscription = block
|
97
|
+
else
|
98
|
+
@fact_subscription = block
|
99
|
+
end
|
100
|
+
|
101
|
+
@messaging.subscribe :fact_response do |res|
|
102
|
+
if res.auth_response?
|
103
|
+
@auth_subscription&.call(res)
|
104
|
+
else
|
105
|
+
@fact_subscription&.call(res)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
# Generates a QR code so users can send facts to your app.
|
111
|
+
#
|
112
|
+
# @param facts [Array] a list of facts to be requested.
|
113
|
+
# @option opts [String] :cid The unique identifier of the authentication request.
|
114
|
+
# @option opts [String] :options Options you want to share with the identity.
|
115
|
+
#
|
116
|
+
# @return [String, String] conversation id or encoded body.
|
117
|
+
def generate_qr(facts, opts = {})
|
118
|
+
opts[:request] = false
|
119
|
+
selfid = opts.fetch(:selfid, "-")
|
120
|
+
req = request(selfid, facts, opts)
|
121
|
+
::RQRCode::QRCode.new(req, level: 'l')
|
122
|
+
end
|
123
|
+
|
124
|
+
# Generates a deep link to authenticate with self app.
|
125
|
+
#
|
126
|
+
# @param facts [Array] a list of facts to be requested.
|
127
|
+
# @param callback [String] the url you'll be redirected if the app is not installed.
|
128
|
+
# @option opts [String] :selfid the user selfid you want to authenticate.
|
129
|
+
# @option opts [String] :cid The unique identifier of the authentication request.
|
130
|
+
#
|
131
|
+
# @return [String, String] conversation id or encoded body.
|
132
|
+
def generate_deep_link(facts, callback, opts = {})
|
133
|
+
opts[:request] = false
|
134
|
+
selfid = opts.fetch(:selfid, "-")
|
135
|
+
body = @client.jwt.encode(request(selfid, facts, opts))
|
136
|
+
|
137
|
+
if @client.env.empty?
|
138
|
+
return "https://links.joinself.com/?link=#{callback}%3Fqr=#{body}&apn=com.joinself.app"
|
139
|
+
elsif @client.env == 'development'
|
140
|
+
return "https://links.joinself.com/?link=#{callback}%3Fqr=#{body}&apn=com.joinself.app.dev"
|
141
|
+
end
|
142
|
+
"https://#{@client.env}.links.joinself.com/?link=#{callback}%3Fqr=#{body}&apn=com.joinself.app.#{@client.env}"
|
143
|
+
end
|
144
|
+
|
145
|
+
private
|
146
|
+
|
147
|
+
# As request facts can accept an array of strings this populates with necessary
|
148
|
+
# structure this short fact definitions.
|
149
|
+
#
|
150
|
+
# @param facts [Array] an array of strings or hashes.
|
151
|
+
# @return [Array] a list of hashed facts.
|
152
|
+
def prepare_facts(facts)
|
153
|
+
fs = []
|
154
|
+
facts.each do |f|
|
155
|
+
fact = if f.is_a?(Hash)
|
156
|
+
f
|
157
|
+
else
|
158
|
+
{ fact: f }
|
159
|
+
end
|
160
|
+
validate_fact!(fact) unless fact.key?('issuers')
|
161
|
+
fs << fact
|
162
|
+
end
|
163
|
+
fs
|
164
|
+
end
|
165
|
+
|
166
|
+
def validate_fact!(f)
|
167
|
+
errInvalidFactToSource = 'provided source does not support given fact'
|
168
|
+
errInvalidSource = 'provided fact does not specify a valid source'
|
169
|
+
|
170
|
+
raise 'provided fact does not specify a name' if f[:fact].empty?
|
171
|
+
return unless f.has_key? :sources
|
172
|
+
return if f.has_key? :issuers # skip the validation if is a custom fact
|
173
|
+
|
174
|
+
raise "invalid fact '#{f[:fact]}'" unless @messaging.facts.include?(f[:fact])
|
175
|
+
|
176
|
+
spec = @messaging.sources
|
177
|
+
f[:sources].each do |s|
|
178
|
+
raise errInvalidSource unless spec.key?(s)
|
179
|
+
raise errInvalidFactToSource unless spec[s].include? f[:fact]
|
180
|
+
end
|
181
|
+
end
|
182
|
+
end
|
183
|
+
end
|
184
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Do not edit this file, autogenerate it with "rake sources:generate" instead
|
4
|
+
module SelfSDK
|
5
|
+
SOURCE_DATA = {
|
6
|
+
"sources" => {
|
7
|
+
"user_specified" => [
|
8
|
+
"document_number",
|
9
|
+
"display_name",
|
10
|
+
"email_address",
|
11
|
+
"phone_number"
|
12
|
+
],
|
13
|
+
"passport" => [
|
14
|
+
"document_number",
|
15
|
+
"surname",
|
16
|
+
"given_names",
|
17
|
+
"date_of_birth",
|
18
|
+
"date_of_expiration",
|
19
|
+
"sex",
|
20
|
+
"nationality",
|
21
|
+
"country_of_issuance"
|
22
|
+
],
|
23
|
+
"driving_license" => [
|
24
|
+
"document_number",
|
25
|
+
"surname",
|
26
|
+
"given_names",
|
27
|
+
"date_of_birth",
|
28
|
+
"date_of_issuance",
|
29
|
+
"date_of_expiration",
|
30
|
+
"address",
|
31
|
+
"issuing_authority",
|
32
|
+
"place_of_birth"
|
33
|
+
],
|
34
|
+
"identity_card" => [
|
35
|
+
"document_number",
|
36
|
+
"surname",
|
37
|
+
"given_names",
|
38
|
+
"date_of_birth",
|
39
|
+
"date_of_expiration",
|
40
|
+
"sex",
|
41
|
+
"nationality",
|
42
|
+
"country_of_issuance"
|
43
|
+
],
|
44
|
+
"twitter" => [
|
45
|
+
"account_id",
|
46
|
+
"nickname"
|
47
|
+
],
|
48
|
+
"linkedin" => [
|
49
|
+
"account_id",
|
50
|
+
"nickname"
|
51
|
+
],
|
52
|
+
"facebook" => [
|
53
|
+
"account_id",
|
54
|
+
"nickname"
|
55
|
+
],
|
56
|
+
"live" => [
|
57
|
+
"selfie_verification"
|
58
|
+
]
|
59
|
+
}
|
60
|
+
}
|
61
|
+
end
|
data/lib/sources.rb
CHANGED
@@ -3,76 +3,25 @@
|
|
3
3
|
# frozen_string_literal: true
|
4
4
|
|
5
5
|
require "json"
|
6
|
+
require_relative "source_definition.rb"
|
7
|
+
|
6
8
|
module SelfSDK
|
9
|
+
attr_reader :sources, :facts
|
7
10
|
class Sources
|
8
11
|
def initialize(sources_file)
|
9
|
-
|
10
|
-
"sources": {
|
11
|
-
"user_specified": [
|
12
|
-
"document_number",
|
13
|
-
"display_name",
|
14
|
-
"email_address",
|
15
|
-
"phone_number"
|
16
|
-
],
|
17
|
-
"passport": [
|
18
|
-
"document_number",
|
19
|
-
"surname",
|
20
|
-
"given_names",
|
21
|
-
"date_of_birth",
|
22
|
-
"date_of_expiration",
|
23
|
-
"sex",
|
24
|
-
"nationality",
|
25
|
-
"country_of_issuance"
|
26
|
-
],
|
27
|
-
"driving_license": [
|
28
|
-
"document_number",
|
29
|
-
"surname",
|
30
|
-
"given_names",
|
31
|
-
"date_of_birth",
|
32
|
-
"date_of_issuance",
|
33
|
-
"date_of_expiration",
|
34
|
-
"address",
|
35
|
-
"issuing_authority",
|
36
|
-
"place_of_birth"
|
37
|
-
],
|
38
|
-
"identity_card": [
|
39
|
-
"document_number",
|
40
|
-
"surname",
|
41
|
-
"given_names",
|
42
|
-
"date_of_birth",
|
43
|
-
"date_of_expiration",
|
44
|
-
"sex",
|
45
|
-
"nationality",
|
46
|
-
"country_of_issuance"
|
47
|
-
],
|
48
|
-
"twitter": [
|
49
|
-
"account_id",
|
50
|
-
"nickname"
|
51
|
-
],
|
52
|
-
"linkedin": [
|
53
|
-
"account_id",
|
54
|
-
"nickname"
|
55
|
-
],
|
56
|
-
"facebook": [
|
57
|
-
"account_id",
|
58
|
-
"nickname"
|
59
|
-
],
|
60
|
-
"live": [
|
61
|
-
"selfie_verification"
|
62
|
-
]
|
63
|
-
}
|
64
|
-
}')
|
65
|
-
@sources = data["sources"]
|
12
|
+
@sources = SOURCE_DATA["sources"]
|
66
13
|
@facts = []
|
67
14
|
@sources.each do |source, facts|
|
68
15
|
@facts.push(*facts)
|
69
16
|
end
|
70
17
|
end
|
71
18
|
|
72
|
-
def normalize_fact_name
|
73
|
-
fact
|
74
|
-
|
75
|
-
|
19
|
+
def normalize_fact_name(fact)
|
20
|
+
fact.to_s
|
21
|
+
end
|
22
|
+
|
23
|
+
def normalize_source(source)
|
24
|
+
source.to_s
|
76
25
|
end
|
77
26
|
|
78
27
|
def validate_source!(source)
|
@@ -92,9 +41,7 @@ module SelfSDK
|
|
92
41
|
end
|
93
42
|
|
94
43
|
def message_type(s)
|
95
|
-
types = {
|
96
|
-
authentication_response: SelfSDK::Messages::AuthenticationResp::MSG_TYPE,
|
97
|
-
fact_request: SelfSDK::Messages::FactRequest::MSG_TYPE,
|
44
|
+
types = { fact_request: SelfSDK::Messages::FactRequest::MSG_TYPE,
|
98
45
|
fact_response: SelfSDK::Messages::FactResponse::MSG_TYPE,
|
99
46
|
chat_message: SelfSDK::Messages::ChatMessage::MSG_TYPE,
|
100
47
|
chat_message_deivered: SelfSDK::Messages::ChatMessageDelivered::MSG_TYPE,
|
@@ -103,11 +50,13 @@ module SelfSDK
|
|
103
50
|
chat_join: SelfSDK::Messages::ChatJoin::MSG_TYPE,
|
104
51
|
chat_remove: SelfSDK::Messages::ChatRemove::MSG_TYPE,
|
105
52
|
document_sign_response: SelfSDK::Messages::DocumentSignResponse::MSG_TYPE,
|
53
|
+
connection_response: SelfSDK::Messages::ConnectionResponse::MSG_TYPE,
|
106
54
|
}
|
107
55
|
raise "invalid message type '#{s}'" unless types.key? s
|
108
56
|
return types[s]
|
109
57
|
end
|
110
58
|
|
59
|
+
|
111
60
|
private
|
112
61
|
|
113
62
|
def get(options, input, option_type)
|
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.
|
4
|
+
version: 0.0.198
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aldgate Ventures
|
@@ -334,9 +334,6 @@ files:
|
|
334
334
|
- lib/jwt_service.rb
|
335
335
|
- lib/log.rb
|
336
336
|
- lib/messages/attestation.rb
|
337
|
-
- lib/messages/authentication_message.rb
|
338
|
-
- lib/messages/authentication_req.rb
|
339
|
-
- lib/messages/authentication_resp.rb
|
340
337
|
- lib/messages/base.rb
|
341
338
|
- lib/messages/chat.rb
|
342
339
|
- lib/messages/chat_invite.rb
|
@@ -345,8 +342,11 @@ files:
|
|
345
342
|
- lib/messages/chat_message_delivered.rb
|
346
343
|
- lib/messages/chat_message_read.rb
|
347
344
|
- lib/messages/chat_remove.rb
|
345
|
+
- lib/messages/connection_request.rb
|
346
|
+
- lib/messages/connection_response.rb
|
348
347
|
- lib/messages/document_sign_resp.rb
|
349
348
|
- lib/messages/fact.rb
|
349
|
+
- lib/messages/fact_issue.rb
|
350
350
|
- lib/messages/fact_request.rb
|
351
351
|
- lib/messages/fact_response.rb
|
352
352
|
- lib/messages/message.rb
|
@@ -359,7 +359,9 @@ files:
|
|
359
359
|
- lib/services/facts.rb
|
360
360
|
- lib/services/identity.rb
|
361
361
|
- lib/services/messaging.rb
|
362
|
+
- lib/services/requester.rb
|
362
363
|
- lib/signature_graph.rb
|
364
|
+
- lib/source_definition.rb
|
363
365
|
- lib/sources.rb
|
364
366
|
homepage: https://www.joinself.com/
|
365
367
|
licenses:
|