smile-identity-core 2.2.3 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +12 -0
- data/.github/workflows/release.yml +1 -1
- data/.rubocop.yml +181 -8
- data/CHANGELOG.md +76 -56
- data/Gemfile.lock +2 -2
- data/README.md +7 -7
- data/examples/address_verification.rb +45 -0
- data/examples/aml_check.rb +3 -2
- data/examples/biometric_kyc.rb +7 -7
- data/examples/business_verification.rb +3 -3
- data/examples/document_verification.rb +9 -9
- data/examples/enhanced_document_verification.rb +9 -9
- data/examples/enhanced_kyc.rb +4 -4
- data/examples/example-project/README.md +1 -1
- data/examples/example-project/smart_bank.rb +26 -25
- data/examples/get_web_token.rb +2 -2
- data/examples/smart_selfie_authentication.rb +6 -6
- data/lib/smile-identity-core/address_verification.rb +79 -0
- data/lib/smile-identity-core/aml_check.rb +5 -3
- data/lib/smile-identity-core/business_verification.rb +2 -2
- data/lib/smile-identity-core/constants/env.rb +4 -4
- data/lib/smile-identity-core/constants/job_type.rb +4 -0
- data/lib/smile-identity-core/id_api.rb +11 -11
- data/lib/smile-identity-core/signature.rb +20 -10
- data/lib/smile-identity-core/utilities.rb +4 -6
- data/lib/smile-identity-core/validations.rb +2 -2
- data/lib/smile-identity-core/version.rb +1 -1
- data/lib/smile-identity-core/web_api.rb +45 -45
- data/lib/smile-identity-core.rb +1 -0
- data/smile-identity-core.gemspec +12 -11
- metadata +12 -11
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'smile-identity-core'
|
4
4
|
|
5
|
-
# See https://docs.
|
5
|
+
# See https://docs.usesmileid.com/server-to-server/ruby/products/document-verification for
|
6
6
|
# how to setup and retrieve configuation values for the WebApi class.
|
7
7
|
|
8
8
|
# Initialize
|
@@ -17,7 +17,7 @@ connection = SmileIdentityCore::WebApi.new(partner_id, default_callback, api_key
|
|
17
17
|
partner_params = {
|
18
18
|
user_id: '<put your unique ID for the user here>',
|
19
19
|
job_id: '<put your unique job ID here>',
|
20
|
-
job_type: 6
|
20
|
+
job_type: 6,
|
21
21
|
}
|
22
22
|
|
23
23
|
# Create image list
|
@@ -33,27 +33,27 @@ partner_params = {
|
|
33
33
|
image_details = [
|
34
34
|
{
|
35
35
|
image_type_id: '<0 | 2>',
|
36
|
-
image: '<full path to selfie image or base64image string>'
|
36
|
+
image: '<full path to selfie image or base64image string>',
|
37
37
|
},
|
38
38
|
{ # Not required if you don't require proof of life (note photo of photo check
|
39
39
|
# will still be performed on the uploaded selfie)
|
40
40
|
image_type_id: '<4 | 6>',
|
41
|
-
image: '<full path to liveness image or base64 image string>'
|
41
|
+
image: '<full path to liveness image or base64 image string>',
|
42
42
|
},
|
43
43
|
{
|
44
44
|
image_type_id: '<1 | 3>',
|
45
|
-
image: '<full path to front of id document image or base64image string>'
|
45
|
+
image: '<full path to front of id document image or base64image string>',
|
46
46
|
},
|
47
47
|
{ # Optional, only use if you're uploading the back of the id document image
|
48
48
|
image_type_id: '<5 | 7>',
|
49
|
-
image: '<full path to back of id document image or base64image string>'
|
50
|
-
}
|
49
|
+
image: '<full path to back of id document image or base64image string>',
|
50
|
+
},
|
51
51
|
]
|
52
52
|
|
53
53
|
# The ID Document Information
|
54
54
|
id_info = {
|
55
55
|
country: '<2-letter country code>', # The country where ID document was issued
|
56
|
-
id_type: '<id type>' # The ID document type
|
56
|
+
id_type: '<id type>', # The ID document type
|
57
57
|
}
|
58
58
|
|
59
59
|
# Set options for the job
|
@@ -67,7 +67,7 @@ options = {
|
|
67
67
|
# Set to true to receive links to the selfie and the photo it was compared to.
|
68
68
|
# You must set return_job_status to true to use this flag.
|
69
69
|
return_image_links: '<true |false>',
|
70
|
-
signature: true
|
70
|
+
signature: true,
|
71
71
|
}
|
72
72
|
|
73
73
|
# Submit the job
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'smile-identity-core'
|
4
4
|
|
5
|
-
# See https://docs.
|
5
|
+
# See https://docs.usesmileid.com/server-to-server/ruby/products/enhanced_document-verification for
|
6
6
|
# how to setup and retrieve configuation values for the WebApi class.
|
7
7
|
|
8
8
|
# Initialize
|
@@ -17,7 +17,7 @@ connection = SmileIdentityCore::WebApi.new(partner_id, default_callback, api_key
|
|
17
17
|
partner_params = {
|
18
18
|
user_id: '<put your unique ID for the user here>',
|
19
19
|
job_id: '<put your unique job ID here>',
|
20
|
-
job_type: 11
|
20
|
+
job_type: 11,
|
21
21
|
}
|
22
22
|
|
23
23
|
# Create image list
|
@@ -33,27 +33,27 @@ partner_params = {
|
|
33
33
|
image_details = [
|
34
34
|
{
|
35
35
|
image_type_id: '<0 | 2>',
|
36
|
-
image: '<full path to selfie image or base64image string>'
|
36
|
+
image: '<full path to selfie image or base64image string>',
|
37
37
|
},
|
38
38
|
{ # Not required if you don't require proof of life (note photo of photo check
|
39
39
|
# will still be performed on the uploaded selfie)
|
40
40
|
image_type_id: '<4 | 6>',
|
41
|
-
image: '<full path to liveness image or base64 image string>'
|
41
|
+
image: '<full path to liveness image or base64 image string>',
|
42
42
|
},
|
43
43
|
{
|
44
44
|
image_type_id: '<1 | 3>',
|
45
|
-
image: '<full path to front of id document image or base64image string>'
|
45
|
+
image: '<full path to front of id document image or base64image string>',
|
46
46
|
},
|
47
47
|
{ # Optional, only use if you're uploading the back of the id document image
|
48
48
|
image_type_id: '<5 | 7>',
|
49
|
-
image: '<full path to back of id document image or base64image string>'
|
50
|
-
}
|
49
|
+
image: '<full path to back of id document image or base64image string>',
|
50
|
+
},
|
51
51
|
]
|
52
52
|
|
53
53
|
# The ID Document Information
|
54
54
|
id_info = {
|
55
55
|
country: '<2-letter country code>', # The country where ID document was issued
|
56
|
-
id_type: '<id type>' # The ID document type
|
56
|
+
id_type: '<id type>', # The ID document type
|
57
57
|
}
|
58
58
|
|
59
59
|
# Set options for the job
|
@@ -67,7 +67,7 @@ options = {
|
|
67
67
|
# Set to true to receive links to the selfie and the photo it was compared to.
|
68
68
|
# You must set return_job_status to true to use this flag.
|
69
69
|
return_image_links: '<true |false>',
|
70
|
-
signature: true
|
70
|
+
signature: true,
|
71
71
|
}
|
72
72
|
|
73
73
|
# Submit the job
|
data/examples/enhanced_kyc.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'smile-identity-core'
|
4
4
|
|
5
|
-
# See https://docs.
|
5
|
+
# See https://docs.usesmileid.com/server-to-server/ruby/products/enhanced-kyc for
|
6
6
|
# how to setup and retrieve configuation values for the IDApi class.
|
7
7
|
|
8
8
|
# Initialize
|
@@ -16,7 +16,7 @@ connection = SmileIdentityCore::IDApi.new(partner_id, api_key, sid_server)
|
|
16
16
|
partner_params = {
|
17
17
|
job_id: '<put your unique job ID here>',
|
18
18
|
user_id: '<put your unique ID for the user here>',
|
19
|
-
job_type: 5
|
19
|
+
job_type: 5,
|
20
20
|
}
|
21
21
|
|
22
22
|
# Create ID info
|
@@ -27,12 +27,12 @@ id_info = {
|
|
27
27
|
id_type: '<id type>',
|
28
28
|
id_number: '<valid id number>',
|
29
29
|
dob: '<date of birth>', # yyyy-mm-dd
|
30
|
-
phone_number: '<phone number>'
|
30
|
+
phone_number: '<phone number>',
|
31
31
|
}
|
32
32
|
|
33
33
|
# Set the options for the job
|
34
34
|
options = {
|
35
|
-
signature: true
|
35
|
+
signature: true,
|
36
36
|
}
|
37
37
|
|
38
38
|
# Submit the job
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# Example Project
|
2
2
|
|
3
|
-
This project is an example implementation of the Smile Identity Ruby SDK on the server side. The example implements [Enhanced KYC](https://docs.
|
3
|
+
This project is an example implementation of the Smile Identity Ruby SDK on the server side. The example implements [Enhanced KYC](https://docs.usesmileid.com/products/identity-lookup), [Biometric KYC](https://docs.usesmileid.com/products/biometric-kyc), [Document Verification](https://docs.usesmileid.com/products/document-verification) and [SmartSelfieTM Authentication](https://docs.usesmileid.com/products/biometric-authentication) job types.
|
4
4
|
|
5
5
|
## Setup
|
6
6
|
|
@@ -11,11 +11,12 @@ class SmartBank
|
|
11
11
|
|
12
12
|
def initialize
|
13
13
|
# login to the Smile Identity portal to view your partner id
|
14
|
-
@partner_id = ENV
|
15
|
-
# See https://docs.
|
16
|
-
@default_callback = ENV
|
17
|
-
@api_key = ENV
|
18
|
-
|
14
|
+
@partner_id = ENV.fetch('SMILE_PARTNER_ID', nil)
|
15
|
+
# See https://docs.usesmileid.com/server-to-server/ruby/products/biometric-kyc#create-a-callback-endpoint
|
16
|
+
@default_callback = ENV.fetch('SMILE_JOB_CALLBACK_URL', nil)
|
17
|
+
@api_key = ENV.fetch('SMILE_API_KEY', nil) # copy your API key from the Smile Identity portal
|
18
|
+
# Use '0' for the sandbox server, use '1' for production server
|
19
|
+
@sid_server = ENV.fetch('SMILE_SERVER_ENVIRONMENT', nil)
|
19
20
|
@user_id = SecureRandom.uuid # your unique ID for the user
|
20
21
|
@job_id = SecureRandom.uuid # your unique job ID
|
21
22
|
end
|
@@ -35,12 +36,12 @@ class SmartBank
|
|
35
36
|
id_type: 'PASSPORT',
|
36
37
|
id_number: 'G0000000',
|
37
38
|
dob: '1992-12-07', # yyyy-mm-dd
|
38
|
-
phone_number: '00000000000'
|
39
|
+
phone_number: '00000000000',
|
39
40
|
}
|
40
41
|
|
41
42
|
# Set the options for the job
|
42
43
|
options = {
|
43
|
-
signature: true
|
44
|
+
signature: true,
|
44
45
|
}
|
45
46
|
|
46
47
|
# Submit the job
|
@@ -57,13 +58,13 @@ class SmartBank
|
|
57
58
|
image_details = [
|
58
59
|
{
|
59
60
|
image_type_id: SmileIdentityCore::ImageType::SELFIE_IMAGE_FILE,
|
60
|
-
image: '/path/to/selfie_image.jpeg'
|
61
|
+
image: '/path/to/selfie_image.jpeg',
|
61
62
|
},
|
62
63
|
{ # Not required if you don't require proof of life (note photo of photo check will
|
63
64
|
# still be performed on the uploaded selfie)
|
64
65
|
image_type_id: SmileIdentityCore::ImageType::LIVENESS_IMAGE_FILE,
|
65
|
-
image: '/path/to/liveness_image.jpeg'
|
66
|
-
}
|
66
|
+
image: '/path/to/liveness_image.jpeg',
|
67
|
+
},
|
67
68
|
]
|
68
69
|
|
69
70
|
# Create ID number info
|
@@ -74,7 +75,7 @@ class SmartBank
|
|
74
75
|
id_type: 'PASSPORT',
|
75
76
|
id_number: 'G0000000',
|
76
77
|
dob: '1992-12-07', # yyyy-mm-dd
|
77
|
-
entered: 'true' # must be a string
|
78
|
+
entered: 'true', # must be a string
|
78
79
|
}
|
79
80
|
|
80
81
|
# Submit the job
|
@@ -91,27 +92,27 @@ class SmartBank
|
|
91
92
|
image_details = [
|
92
93
|
{
|
93
94
|
image_type_id: SmileIdentityCore::ImageType::SELFIE_IMAGE_FILE,
|
94
|
-
image: '/path/to/selfie_image.jpeg'
|
95
|
+
image: '/path/to/selfie_image.jpeg',
|
95
96
|
},
|
96
97
|
{ # Not required if you don't require proof of life (note photo of photo
|
97
98
|
# check will still be performed on the uploaded selfie)
|
98
99
|
image_type_id: SmileIdentityCore::ImageType::LIVENESS_IMAGE_FILE,
|
99
|
-
image: '/path/to/liveness_image.jpeg'
|
100
|
+
image: '/path/to/liveness_image.jpeg',
|
100
101
|
},
|
101
102
|
{
|
102
103
|
image_type_id: SmileIdentityCore::ImageType::ID_CARD_IMAGE_FILE,
|
103
|
-
image: '/path/to/front_document_image.jpeg'
|
104
|
+
image: '/path/to/front_document_image.jpeg',
|
104
105
|
},
|
105
106
|
{ # Optional, only use if you're uploading the back of the id document image
|
106
107
|
image_type_id: SmileIdentityCore::ImageType::ID_CARD_BACK_IMAGE_FILE,
|
107
|
-
image: '/path/to/back_document_image.jpeg'
|
108
|
-
}
|
108
|
+
image: '/path/to/back_document_image.jpeg',
|
109
|
+
},
|
109
110
|
]
|
110
111
|
|
111
112
|
# The ID Document Information
|
112
113
|
id_info = {
|
113
114
|
country: 'GH', # The country where ID document was issued
|
114
|
-
id_type: 'PASSPORT' # The ID document type
|
115
|
+
id_type: 'PASSPORT', # The ID document type
|
115
116
|
}
|
116
117
|
|
117
118
|
# Submit the job
|
@@ -128,20 +129,20 @@ class SmartBank
|
|
128
129
|
partner_params = {
|
129
130
|
user_id: '512c9c37-a689-4959-a620-bed75fb41344', # previously registered user's user_id
|
130
131
|
job_id: SecureRandom.uuid, # new unique job ID
|
131
|
-
job_type: SmileIdentityCore::JobType::SMART_SELFIE_REGISTRATION
|
132
|
+
job_type: SmileIdentityCore::JobType::SMART_SELFIE_REGISTRATION,
|
132
133
|
}
|
133
134
|
|
134
135
|
# Create image list
|
135
136
|
image_details = [
|
136
137
|
{
|
137
138
|
image_type_id: SmileIdentityCore::ImageType::SELFIE_IMAGE_FILE,
|
138
|
-
image: '/path/to/selfie_image.jpeg'
|
139
|
+
image: '/path/to/selfie_image.jpeg',
|
139
140
|
},
|
140
141
|
{ # Not required if you don't require proof of life
|
141
142
|
# (note photo of photo check will still be performed on the uploaded selfie)
|
142
143
|
image_type_id: SmileIdentityCore::ImageType::LIVENESS_IMAGE_FILE,
|
143
|
-
image: '/path/to/liveness_image.jpeg'
|
144
|
-
}
|
144
|
+
image: '/path/to/liveness_image.jpeg',
|
145
|
+
},
|
145
146
|
]
|
146
147
|
|
147
148
|
# Submit the job
|
@@ -154,7 +155,7 @@ class SmartBank
|
|
154
155
|
{
|
155
156
|
user_id: user_id,
|
156
157
|
job_id: job_id,
|
157
|
-
job_type: job_type
|
158
|
+
job_type: job_type,
|
158
159
|
}
|
159
160
|
end
|
160
161
|
|
@@ -175,7 +176,7 @@ class SmartBank
|
|
175
176
|
# Set to true to receive links to the selfie and the photo it was compared to.
|
176
177
|
# You must set return_job_status to true to use this flag.
|
177
178
|
return_image_links: true,
|
178
|
-
signature: true
|
179
|
+
signature: true,
|
179
180
|
}
|
180
181
|
end
|
181
182
|
end
|
@@ -187,7 +188,7 @@ enhanced_kyc_response['success'] # => true
|
|
187
188
|
enhanced_kyc_response['result']['PartnerParams']['job_id'] # job_id
|
188
189
|
enhanced_kyc_response['result']['PartnerParams']['user_id'] # user_id
|
189
190
|
enhanced_kyc_response['result']['PartnerParams']['job_type'] # => 5
|
190
|
-
# See https://docs.
|
191
|
+
# See https://docs.usesmileid.com/products/for-individuals-kyc/identity-lookup#return-values
|
191
192
|
# for the full JSON response interpretation
|
192
193
|
|
193
194
|
# Biometric KYC
|
@@ -212,5 +213,5 @@ smart_selfie_auth_response['result']['PartnerParams']['user_id'] # user_id
|
|
212
213
|
smart_selfie_auth_response['result']['PartnerParams']['job_type'] # => 2
|
213
214
|
|
214
215
|
# All jobs submitted with a selfie has the same return values, result codes and texts. For example
|
215
|
-
# see https://docs.
|
216
|
+
# see https://docs.usesmileid.com/products/for-individuals-kyc/biometric-kyc#return-values.
|
216
217
|
# Save the returned user_id and job_id in your DB as you would need them later when you call other services.
|
data/examples/get_web_token.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
require 'smile-identity-core'
|
4
4
|
require 'random/formatter'
|
5
5
|
|
6
|
-
# See https://docs.
|
6
|
+
# See https://docs.usesmileid.com/server-to-server/ruby/products/biometric-kyc for
|
7
7
|
# how to setup and retrieve configuation values for the WebApi class.
|
8
8
|
|
9
9
|
# Initialize
|
@@ -19,7 +19,7 @@ request_params = {
|
|
19
19
|
user_id: '<your unique user id>',
|
20
20
|
job_id: '<your unique job id>',
|
21
21
|
product: '<smile identity product type>',
|
22
|
-
callback_url: '<your callback url>'
|
22
|
+
callback_url: '<your callback url>',
|
23
23
|
}
|
24
24
|
|
25
25
|
# Get web token
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'smile-identity-core'
|
4
4
|
|
5
|
-
# See https://docs.
|
5
|
+
# See https://docs.usesmileid.com/server-to-server/ruby/products/smartselfie-tm-authentication for
|
6
6
|
# how to setup and retrieve configuation values for the WebApi class.
|
7
7
|
|
8
8
|
# Initialize
|
@@ -17,7 +17,7 @@ connection = SmileIdentityCore::WebApi.new(partner_id, default_callback, api_key
|
|
17
17
|
partner_params = {
|
18
18
|
user_id: '<put previously registered user"s user_id here>',
|
19
19
|
job_id: '<put your unique job ID here>',
|
20
|
-
job_type: 2
|
20
|
+
job_type: 2,
|
21
21
|
}
|
22
22
|
|
23
23
|
# Create image list
|
@@ -29,13 +29,13 @@ partner_params = {
|
|
29
29
|
image_details = [
|
30
30
|
{
|
31
31
|
image_type_id: '<0 | 2>',
|
32
|
-
image: '<full path to selfie image or base64image string>'
|
32
|
+
image: '<full path to selfie image or base64image string>',
|
33
33
|
},
|
34
34
|
{ # Not required if you don't require proof of life (note photo of photo check will
|
35
35
|
# still be performed on the uploaded selfie)
|
36
36
|
image_type_id: '<4 | 6>',
|
37
|
-
image: '<full path to liveness image or base64 image string>'
|
38
|
-
}
|
37
|
+
image: '<full path to liveness image or base64 image string>',
|
38
|
+
},
|
39
39
|
]
|
40
40
|
|
41
41
|
# Set options for the job
|
@@ -49,7 +49,7 @@ options = {
|
|
49
49
|
# Set to true to receive links to the selfie and the photo it was
|
50
50
|
# compared to. You must set return_job_status to true to use this flag.
|
51
51
|
return_image_links: '<true | false>',
|
52
|
-
signature: true
|
52
|
+
signature: true,
|
53
53
|
}
|
54
54
|
|
55
55
|
# Submit the job
|
@@ -0,0 +1,79 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'json'
|
4
|
+
require 'typhoeus'
|
5
|
+
require_relative 'validations'
|
6
|
+
|
7
|
+
module SmileIdentityCore
|
8
|
+
##
|
9
|
+
# The Address Verification Service allows you to verify address details provided by a user,
|
10
|
+
# by comparing the address details provided by the user to the address details on file with the authorities database.
|
11
|
+
# For more info visit https://docs.usesmileid.com/
|
12
|
+
class AddressVerification
|
13
|
+
include Validations
|
14
|
+
|
15
|
+
###
|
16
|
+
# Initialize Address Verification
|
17
|
+
# @param [String] :partner_id A unique number assigned by Smile ID to your account. Can be found in the portal
|
18
|
+
# @param [String] :api_key Your API key from the Smile Identity portal
|
19
|
+
# @param [String] :sid_server Use 0 for the sandbox server, use 1 for production server
|
20
|
+
def initialize(partner_id, api_key, sid_server)
|
21
|
+
@api_key = api_key
|
22
|
+
@partner_id = partner_id.to_s
|
23
|
+
@sid_server = sid_server
|
24
|
+
@url = SmileIdentityCore::ENV.determine_url(sid_server)
|
25
|
+
end
|
26
|
+
|
27
|
+
###
|
28
|
+
# Submit Address Verification
|
29
|
+
# @param [Hash] params the options to create a job with.
|
30
|
+
# @option params [String] :country (required) The user's country (e.g., NG or ZA).
|
31
|
+
# @option params [String] :address (required) The user's address.
|
32
|
+
# @option params [String] :utility_number (required for NG) The utility account number.
|
33
|
+
# @option params [String] :utility_provider (required for NG) The utility provider.
|
34
|
+
# @option params [String] :id_number (required for ZA) The national ID number.
|
35
|
+
# @option params [String] :full_name (optional) The user's full name.
|
36
|
+
# @option params [String] :callback_url (required) The callback URL.
|
37
|
+
def submit_job(params)
|
38
|
+
@params = symbolize_keys(params)
|
39
|
+
submit_requests
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def symbolize_keys(params)
|
45
|
+
params.is_a?(Hash) ? params.transform_keys(&:to_sym) : params
|
46
|
+
end
|
47
|
+
|
48
|
+
def construct_and_validate_headers
|
49
|
+
signature = SmileIdentityCore::Signature.new(@partner_id, @api_key).generate_iso_timestamp_signature
|
50
|
+
{
|
51
|
+
'smileid-source-sdk' => SmileIdentityCore::SOURCE_SDK,
|
52
|
+
'smileid-source-sdk-version' => SmileIdentityCore::VERSION,
|
53
|
+
'smileid-request-signature' => signature[:signature],
|
54
|
+
'smileid-timestamp' => signature[:timestamp],
|
55
|
+
'smileid-partner-id' => @partner_id,
|
56
|
+
}
|
57
|
+
end
|
58
|
+
|
59
|
+
def submit_requests
|
60
|
+
# Construct headers and body
|
61
|
+
headers = construct_and_validate_headers
|
62
|
+
body = @params.to_json
|
63
|
+
|
64
|
+
# Create and run the request
|
65
|
+
request = Typhoeus::Request.new("#{@url}/async-verify-address", method: 'POST',
|
66
|
+
headers: headers,
|
67
|
+
body: body)
|
68
|
+
|
69
|
+
# Handle the response
|
70
|
+
request.on_complete do |response|
|
71
|
+
raise " #{response.code}: #{response.body}" unless response.success?
|
72
|
+
|
73
|
+
return { success: true }.to_json
|
74
|
+
end
|
75
|
+
|
76
|
+
request.run
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -8,7 +8,7 @@ module SmileIdentityCore
|
|
8
8
|
##
|
9
9
|
# The AML Check product allows you to perform due diligence on your customers by screening them against
|
10
10
|
# global watchlists, politically exposed persons lists, and adverse media publications.
|
11
|
-
# For more info visit https://docs.
|
11
|
+
# For more info visit https://docs.usesmileid.com/products/for-individuals-kyc/aml-check
|
12
12
|
class AmlCheck
|
13
13
|
include Validations
|
14
14
|
|
@@ -33,6 +33,7 @@ module SmileIdentityCore
|
|
33
33
|
# @option opts [Array] :countries An array that takes the customer’s known nationalities in 2-character
|
34
34
|
# (ISO 3166-1 alpha-2) format e.g. Nigeria is NG, Kenya is KE, etc
|
35
35
|
# @option opts [boolean] :search_existing_user If you intend to re-use the name and year of birth
|
36
|
+
# @option opts [boolean] :strict_match If you want to perform a strict match on the serach criteria.
|
36
37
|
# of a user’s previous KYC job
|
37
38
|
# @option opts [Hash] :optional_info Any optional data, this will be returned
|
38
39
|
# in partner_params.
|
@@ -51,6 +52,7 @@ module SmileIdentityCore
|
|
51
52
|
def build_payload
|
52
53
|
@payload = generate_signature
|
53
54
|
@payload.merge!(@params)
|
55
|
+
@payload[:strict_match] = true unless @params.key?(:strict_match)
|
54
56
|
add_partner_info
|
55
57
|
add_sdk_info
|
56
58
|
@payload
|
@@ -73,8 +75,8 @@ module SmileIdentityCore
|
|
73
75
|
|
74
76
|
def submit_requests
|
75
77
|
request = Typhoeus::Request.new("#{@url}/aml", method: 'POST',
|
76
|
-
|
77
|
-
|
78
|
+
headers: { 'Content-Type' => 'application/json' },
|
79
|
+
body: build_payload.to_json)
|
78
80
|
|
79
81
|
request.on_complete do |response|
|
80
82
|
return response.body if response.success?
|
@@ -8,7 +8,7 @@ module SmileIdentityCore
|
|
8
8
|
##
|
9
9
|
# The business verification product lets you search the business registration or
|
10
10
|
# tax information (available in Nigeria only) of a business from one of our supported countries.
|
11
|
-
# For more info visit https://docs.
|
11
|
+
# For more info visit https://docs.usesmileid.com/products/for-businesses-kyb/business-verification
|
12
12
|
class BusinessVerification
|
13
13
|
include Validations
|
14
14
|
|
@@ -85,7 +85,7 @@ module SmileIdentityCore
|
|
85
85
|
"#{@url}/business_verification",
|
86
86
|
method: 'POST',
|
87
87
|
headers: { 'Content-Type' => 'application/json' },
|
88
|
-
body: build_payload.to_json
|
88
|
+
body: build_payload.to_json,
|
89
89
|
)
|
90
90
|
|
91
91
|
request.on_complete do |response|
|
@@ -6,7 +6,7 @@ module SmileIdentityCore
|
|
6
6
|
module ENV
|
7
7
|
SID_SERVER_MAPPING = {
|
8
8
|
'0' => 'https://testapi.smileidentity.com/v1',
|
9
|
-
'1' => 'https://api.smileidentity.com/v1'
|
9
|
+
'1' => 'https://api.smileidentity.com/v1',
|
10
10
|
}.freeze
|
11
11
|
|
12
12
|
TEST = '0'
|
@@ -15,10 +15,10 @@ module SmileIdentityCore
|
|
15
15
|
module_function
|
16
16
|
|
17
17
|
def determine_url(sid_server)
|
18
|
-
if sid_server.to_s
|
19
|
-
SID_SERVER_MAPPING[sid_server.to_s] || sid_server
|
20
|
-
else
|
18
|
+
if sid_server.to_s =~ URI::DEFAULT_PARSER.make_regexp
|
21
19
|
sid_server
|
20
|
+
else
|
21
|
+
SID_SERVER_MAPPING[sid_server.to_s] || sid_server
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
@@ -29,5 +29,9 @@ module SmileIdentityCore
|
|
29
29
|
# with an ID authority, and uses biometric checks to confirm they
|
30
30
|
# belong to the user.
|
31
31
|
ENHANCED_DOCUMENT_VERIFICATION = 11
|
32
|
+
# Verifies the authenticity of National IDs or Utility Numbers and confirms
|
33
|
+
# their validity with an ID authority, and retrieves user address information
|
34
|
+
# from the ID authority.
|
35
|
+
ADDRESS_VERIFICATION = 12
|
32
36
|
end
|
33
37
|
end
|
@@ -25,8 +25,8 @@ module SmileIdentityCore
|
|
25
25
|
|
26
26
|
if partner_params[:job_type] == JobType::BUSINESS_VERIFICATION
|
27
27
|
return SmileIdentityCore::BusinessVerification
|
28
|
-
|
29
|
-
|
28
|
+
.new(@partner_id, @api_key, @url)
|
29
|
+
.submit_job(partner_params, id_info)
|
30
30
|
end
|
31
31
|
|
32
32
|
options = symbolize_keys(options || {})
|
@@ -46,7 +46,7 @@ module SmileIdentityCore
|
|
46
46
|
"#{@url}/#{endpoint}",
|
47
47
|
method: 'POST',
|
48
48
|
headers: { 'Content-Type' => 'application/json' },
|
49
|
-
body: configure_json
|
49
|
+
body: configure_json,
|
50
50
|
)
|
51
51
|
|
52
52
|
request.on_complete do |response|
|
@@ -63,14 +63,14 @@ module SmileIdentityCore
|
|
63
63
|
|
64
64
|
def configure_json
|
65
65
|
signature_generator.generate_signature(Time.now.to_s)
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
66
|
+
.merge(@id_info)
|
67
|
+
.merge(
|
68
|
+
partner_id: @partner_id,
|
69
|
+
partner_params: @partner_params,
|
70
|
+
source_sdk: SmileIdentityCore::SOURCE_SDK,
|
71
|
+
source_sdk_version: SmileIdentityCore::VERSION,
|
72
|
+
)
|
73
|
+
.to_json
|
74
74
|
end
|
75
75
|
|
76
76
|
def signature_generator
|
@@ -12,15 +12,11 @@ module SmileIdentityCore
|
|
12
12
|
#
|
13
13
|
# @return [Hash] containing both the signature and related timestamp
|
14
14
|
def generate_signature(timestamp = Time.now.to_s)
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
{
|
21
|
-
signature: @signature,
|
22
|
-
timestamp: timestamp.to_s
|
23
|
-
}
|
15
|
+
get_signature(timestamp)
|
16
|
+
end
|
17
|
+
|
18
|
+
def generate_iso_timestamp_signature(timestamp = Time.now.utc.strftime('%Y-%m-%dT%H:%M:%S.%LZ'))
|
19
|
+
get_signature(timestamp)
|
24
20
|
end
|
25
21
|
|
26
22
|
# Confirms the signature against a newly generated signature based on the same timestamp
|
@@ -29,7 +25,21 @@ module SmileIdentityCore
|
|
29
25
|
# @param [String] msg_signature a previously generated signature, to be confirmed
|
30
26
|
# @return [Boolean] TRUE or FALSE
|
31
27
|
def confirm_signature(timestamp, msg_signature)
|
32
|
-
|
28
|
+
get_signature(timestamp)[:signature] == msg_signature
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def get_signature(timestamp)
|
34
|
+
hmac = OpenSSL::HMAC.new(@api_key, 'sha256')
|
35
|
+
hmac.update(timestamp.to_s)
|
36
|
+
hmac.update(@partner_id)
|
37
|
+
hmac.update('sid_request')
|
38
|
+
@signature = Base64.strict_encode64(hmac.digest)
|
39
|
+
{
|
40
|
+
signature: @signature,
|
41
|
+
timestamp: timestamp.to_s,
|
42
|
+
}
|
33
43
|
end
|
34
44
|
end
|
35
45
|
end
|
@@ -17,7 +17,7 @@ module SmileIdentityCore
|
|
17
17
|
options[:return_image_links] ||= false
|
18
18
|
|
19
19
|
query_job_status(configure_job_query(user_id, job_id,
|
20
|
-
|
20
|
+
options).merge(@signature_connection.generate_signature(Time.now.to_s)))
|
21
21
|
end
|
22
22
|
|
23
23
|
private
|
@@ -29,9 +29,9 @@ module SmileIdentityCore
|
|
29
29
|
def query_job_status(request_json_data)
|
30
30
|
request = Typhoeus::Request.new(
|
31
31
|
"#{@url}/job_status",
|
32
|
-
headers: { 'Content-Type': 'application/json',
|
32
|
+
headers: { 'Content-Type': 'application/json', Accept: 'application/json' },
|
33
33
|
method: :post,
|
34
|
-
body: request_json_data.to_json
|
34
|
+
body: request_json_data.to_json,
|
35
35
|
)
|
36
36
|
|
37
37
|
request.on_complete do |response|
|
@@ -47,8 +47,6 @@ module SmileIdentityCore
|
|
47
47
|
raise 'Unable to confirm validity of the job_status response' unless valid
|
48
48
|
|
49
49
|
return body
|
50
|
-
rescue StandardError => e
|
51
|
-
raise e
|
52
50
|
end
|
53
51
|
|
54
52
|
request.run
|
@@ -62,7 +60,7 @@ module SmileIdentityCore
|
|
62
60
|
image_links: options[:return_image_links],
|
63
61
|
history: options[:return_history],
|
64
62
|
source_sdk: SmileIdentityCore::SOURCE_SDK,
|
65
|
-
source_sdk_version: SmileIdentityCore::VERSION
|
63
|
+
source_sdk_version: SmileIdentityCore::VERSION,
|
66
64
|
}
|
67
65
|
end
|
68
66
|
end
|