smile-identity-core 2.2.1 → 2.2.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5436921cd5f8d337cec031b4b193f73a11d15389481ac860195e6c28164296a5
4
- data.tar.gz: da6562fc3a5647137338336e5f9f710e042cba36451339e485a0f818532805a2
3
+ metadata.gz: 1b08d29788e9df7942697da8ef9391fdc7200e5d31ac8b0e6520649d9051fbc0
4
+ data.tar.gz: 4e27841299e6c26392883a14d38a72ae104195df8cc06492bb27457198a96e89
5
5
  SHA512:
6
- metadata.gz: 28f93dbeab2f0aeb9a80145e245b583c0479dd6b17b0a96fdd0ef471623c401bcdd8112a407e90265716aa1bc4a51a84c7dade6b866a929001d9189c4c89e371
7
- data.tar.gz: c910e027a0420cc594862676a42f4022b9ad1b45e657d63c5977a3f6b38db2f0280e079e74df233a63f5ba3c26fb4637eda6c30cb8bc7cde102ecb91878d2ae9
6
+ metadata.gz: b08f43d9d9849048f18adb39ef3553c442cdf5aa2ccb4e77a97048df1b2b1a0b72a36fa2d8c0750e13177d9b7a2db987d7f3746c5218f771402da047721cc73b
7
+ data.tar.gz: febc9a1df0e0535fc93f3fc4d7562ee118f0f87031445da6ddc2ec2c91e5a9c52df27c05e8bc0e4db4377b81924e9f26e8b87b1594583e8554495923e898be54
@@ -14,23 +14,21 @@ jobs:
14
14
  matrix:
15
15
  # Due to https://github.com/actions/runner/issues/849, we have to use quotes for '3.0'
16
16
  # See https://www.ruby-lang.org/en/downloads/ for latest stable releases.
17
- ruby: ['2.6', '2.7', '3.0', '3.1']
17
+ ruby: ['2.6', '2.7', '3.0', '3.1', '3.2']
18
18
  steps:
19
- - uses: actions/checkout@v3
19
+ - uses: actions/checkout@v4
20
20
  - uses: ruby/setup-ruby@v1
21
21
  with:
22
22
  ruby-version: ${{ matrix.ruby }}
23
- bundler-cache: true # runs 'bundle install' and caches installed gems automatically
23
+ bundler-cache: true
24
24
  - run: bundle exec rake
25
25
  lint:
26
26
  runs-on: ubuntu-latest
27
27
  steps:
28
- - uses: actions/checkout@v3
29
- - name: Set up Ruby 3.1
30
- uses: ruby/setup-ruby@v1
28
+ - uses: actions/checkout@v4
29
+ - uses: ruby/setup-ruby@v1
31
30
  with:
32
- ruby-version: 3.1
33
- bundler-cache: true # runs 'bundle install' and caches installed gems automatically
34
- # NOTE: || true should be removed as soon as all offenses are fixed.
31
+ ruby-version: 3.2
32
+ bundler-cache: true
35
33
  - name: Run RuboCop
36
- run: bundle exec rubocop --parallel || true
34
+ run: bundle exec rubocop --parallel
data/.rubocop.yml CHANGED
@@ -3,4 +3,43 @@ require:
3
3
  - rubocop-rspec
4
4
 
5
5
  AllCops:
6
- TargetRubyVersion: 2.5
6
+ TargetRubyVersion: 2.5
7
+
8
+ Metrics/AbcSize:
9
+ Max: 30
10
+
11
+ Metrics/ClassLength:
12
+ Max: 500
13
+
14
+ Metrics/CyclomaticComplexity:
15
+ Max: 15
16
+
17
+ Metrics/MethodLength:
18
+ Max: 50
19
+
20
+ Metrics/PerceivedComplexity:
21
+ Max: 15
22
+
23
+ Naming/FileName:
24
+ Enabled: false
25
+
26
+ RSpec/ExampleLength:
27
+ Enabled: false
28
+
29
+ RSpec/FilePath:
30
+ Enabled: false
31
+
32
+ RSpec/InstanceVariable:
33
+ Enabled: false
34
+
35
+ RSpec/MultipleExpectations:
36
+ Enabled: false
37
+
38
+ RSpec/MultipleMemoizedHelpers:
39
+ Enabled: false
40
+
41
+ RSpec/NestedGroups:
42
+ Enabled: false
43
+
44
+ RSpec/RepeatedExampleGroupDescription:
45
+ Enabled: false
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 3.1.2
1
+ 3.2.2
data/CHANGELOG.md CHANGED
@@ -4,8 +4,19 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
5
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## [2.2.3] - 2023-10-20
8
+ ## Added
9
+ - Adds support for Enhanced Document Verification
10
+
7
11
  ## [Unreleased]
8
12
 
13
+ ## [2.2.2] - 2023-10-05
14
+ ### Changed
15
+ - Lint project. Enforce rubocop rules via github action
16
+
17
+ ## Added
18
+ Support Ruby 3.2
19
+
9
20
  ## [2.2.1] - 2023-08-31
10
21
  ### Changed
11
22
  - Don't validate the presence of `id_type` and `id_number` for Document Verification jobs
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- smile-identity-core (2.2.1)
4
+ smile-identity-core (2.2.3)
5
5
  rubyzip (~> 1.2, >= 1.2.3)
6
6
  typhoeus (~> 1.0, >= 1.0.1)
7
7
 
@@ -10,10 +10,10 @@ GEM
10
10
  specs:
11
11
  ast (2.4.2)
12
12
  diff-lcs (1.3)
13
- docile (1.1.5)
13
+ docile (1.4.0)
14
14
  ethon (0.16.0)
15
15
  ffi (>= 1.15.0)
16
- ffi (1.15.5)
16
+ ffi (1.16.3)
17
17
  json (2.5.1)
18
18
  parallel (1.22.1)
19
19
  parser (3.1.2.1)
@@ -53,11 +53,12 @@ GEM
53
53
  rubocop (~> 1.33)
54
54
  ruby-progressbar (1.11.0)
55
55
  rubyzip (1.3.0)
56
- simplecov (0.12.0)
57
- docile (~> 1.1.0)
58
- json (>= 1.8, < 3)
59
- simplecov-html (~> 0.10.0)
60
- simplecov-html (0.10.2)
56
+ simplecov (0.22.0)
57
+ docile (~> 1.1)
58
+ simplecov-html (~> 0.11)
59
+ simplecov_json_formatter (~> 0.1)
60
+ simplecov-html (0.12.3)
61
+ simplecov_json_formatter (0.1.4)
61
62
  typhoeus (1.4.0)
62
63
  ethon (>= 0.9.0)
63
64
  unicode-display_width (2.3.0)
@@ -72,7 +73,7 @@ DEPENDENCIES
72
73
  rubocop (~> 1.37.1)
73
74
  rubocop-rake (~> 0.6.0)
74
75
  rubocop-rspec (~> 2.14.1)
75
- simplecov (~> 0.12.0)
76
+ simplecov (~> 0.18)
76
77
  smile-identity-core!
77
78
 
78
79
  BUNDLED WITH
@@ -0,0 +1,74 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'smile-identity-core'
4
+
5
+ # See https://docs.smileidentity.com/server-to-server/ruby/products/enhanced_document-verification for
6
+ # how to setup and retrieve configuation values for the WebApi class.
7
+
8
+ # Initialize
9
+ partner_id = '<Put your partner ID here>'; # login to the Smile Identity portal to view your partner id
10
+ default_callback = '<Put your default callback url here>'
11
+ api_key = '<Put your API key here>'; # copy your API key from the Smile Identity portal
12
+ sid_server = '<0 | 1>'; # Use '0' for the sandbox server, use '1' for production server
13
+
14
+ connection = SmileIdentityCore::WebApi.new(partner_id, default_callback, api_key, sid_server)
15
+
16
+ # Create required tracking parameters
17
+ partner_params = {
18
+ user_id: '<put your unique ID for the user here>',
19
+ job_id: '<put your unique job ID here>',
20
+ job_type: 11
21
+ }
22
+
23
+ # Create image list
24
+ # image_type_id (Integer) - This infers to either a file or a base64 encoded image, but not both.
25
+ # 0 - Selfie image jpg or png (if you have the full path of the selfie)
26
+ # 2 - Selfie image jpg or png base64 encoded (if you have the base64image string of the selfie)
27
+ # 4 - Liveness image jpg or png (if you have the full path of the liveness image)
28
+ # 6 - Liveness image jpg or png base64 encoded (if you have the base64image string of the liveness image)
29
+ # 1 - Front of ID document image jpg or png (if you have the full path of the selfie)
30
+ # 3 - Front of ID document image jpg or png base64 encoded (if you have the base64image string of the selfie)
31
+ # 5 - Back of ID document image jpg or png (if you have the full path of the selfie)
32
+ # 7 - Back of ID document image jpg or png base64 encoded (if you have the base64image string of the selfie)
33
+ image_details = [
34
+ {
35
+ image_type_id: '<0 | 2>',
36
+ image: '<full path to selfie image or base64image string>'
37
+ },
38
+ { # Not required if you don't require proof of life (note photo of photo check
39
+ # will still be performed on the uploaded selfie)
40
+ image_type_id: '<4 | 6>',
41
+ image: '<full path to liveness image or base64 image string>'
42
+ },
43
+ {
44
+ image_type_id: '<1 | 3>',
45
+ image: '<full path to front of id document image or base64image string>'
46
+ },
47
+ { # Optional, only use if you're uploading the back of the id document image
48
+ image_type_id: '<5 | 7>',
49
+ image: '<full path to back of id document image or base64image string>'
50
+ }
51
+ ]
52
+
53
+ # The ID Document Information
54
+ id_info = {
55
+ country: '<2-letter country code>', # The country where ID document was issued
56
+ id_type: '<id type>' # The ID document type
57
+ }
58
+
59
+ # Set options for the job
60
+ options = {
61
+ # Set to true if you want to get the job result in sync (in addition to the result
62
+ # been sent to your callback). If set to false, result is sent to callback url only.
63
+ return_job_status: '<true | false>',
64
+ # Set to true to receive all of the updates you would otherwise have received in your
65
+ # callback as opposed to only the final result. You must set return_job_status to true to use this flag.
66
+ return_history: '<true | false>',
67
+ # Set to true to receive links to the selfie and the photo it was compared to.
68
+ # You must set return_job_status to true to use this flag.
69
+ return_image_links: '<true |false>',
70
+ signature: true
71
+ }
72
+
73
+ # Submit the job
74
+ connection.submit_job(partner_params, image_details, id_info, options)
@@ -18,14 +18,10 @@ module SmileIdentityCore
18
18
  # @param [String] :api_key your API key from the Smile Identity portal
19
19
  # @param [String] :sid_server Use 0 for the sandbox server, use 1 for production server
20
20
  def initialize(partner_id, api_key, sid_server)
21
- @partner_id = partner_id.to_s
22
21
  @api_key = api_key
22
+ @partner_id = partner_id.to_s
23
23
  @sid_server = sid_server
24
- @url = if sid_server !~ URI::DEFAULT_PARSER.make_regexp
25
- SmileIdentityCore::ENV::SID_SERVER_MAPPING[sid_server.to_s]
26
- else
27
- sid_server
28
- end
24
+ @url = SmileIdentityCore::ENV.determine_url(sid_server)
29
25
  end
30
26
 
31
27
  # Submit AML
@@ -24,14 +24,10 @@ module SmileIdentityCore
24
24
  # @param [String] :api_key your API key from the Smile Identity portal
25
25
  # @param [String] :sid_server Use 0 for the sandbox server, use 1 for production server
26
26
  def initialize(partner_id, api_key, sid_server)
27
- @partner_id = partner_id.to_s
28
27
  @api_key = api_key
28
+ @partner_id = partner_id.to_s
29
29
  @sid_server = sid_server
30
- @url = if sid_server !~ URI::DEFAULT_PARSER.make_regexp
31
- SmileIdentityCore::ENV::SID_SERVER_MAPPING[sid_server.to_s]
32
- else
33
- sid_server
34
- end
30
+ @url = SmileIdentityCore::ENV.determine_url(sid_server)
35
31
  end
36
32
 
37
33
  # Submit business verification
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SmileIdentityCore
4
+ # The ENV module contains constants and utility methods for mapping
5
+ # managing aliases to Smile Identity servers.
4
6
  module ENV
5
7
  SID_SERVER_MAPPING = {
6
8
  '0' => 'https://testapi.smileidentity.com/v1',
@@ -9,5 +11,15 @@ module SmileIdentityCore
9
11
 
10
12
  TEST = '0'
11
13
  LIVE = '1'
14
+
15
+ module_function
16
+
17
+ def determine_url(sid_server)
18
+ if sid_server.to_s !~ URI::DEFAULT_PARSER.make_regexp
19
+ SID_SERVER_MAPPING[sid_server.to_s] || sid_server
20
+ else
21
+ sid_server
22
+ end
23
+ end
12
24
  end
13
25
  end
@@ -25,5 +25,9 @@ module SmileIdentityCore
25
25
  # Performs due diligence by screening against global watchlists,
26
26
  # politically exposed persons lists, and adverse media publications
27
27
  AML = 10
28
+ # Verifies the authenticity of Document IDs and confirms their validity
29
+ # with an ID authority, and uses biometric checks to confirm they
30
+ # belong to the user.
31
+ ENHANCED_DOCUMENT_VERIFICATION = 11
28
32
  end
29
33
  end
@@ -10,14 +10,9 @@ module SmileIdentityCore
10
10
  REQUIRED_ID_INFO_FIELD = %i[country id_type id_number].freeze
11
11
 
12
12
  def initialize(partner_id, api_key, sid_server)
13
- @partner_id = partner_id.to_s
14
13
  @api_key = api_key
15
-
16
- @url = if sid_server !~ URI::DEFAULT_PARSER.make_regexp
17
- SmileIdentityCore::ENV::SID_SERVER_MAPPING[sid_server.to_s]
18
- else
19
- sid_server
20
- end
14
+ @partner_id = partner_id.to_s
15
+ @url = SmileIdentityCore::ENV.determine_url(sid_server)
21
16
  end
22
17
 
23
18
  def submit_job(partner_params, id_info, options = {})
@@ -4,14 +4,9 @@ module SmileIdentityCore
4
4
  # A utility class to query job status
5
5
  class Utilities
6
6
  def initialize(partner_id, api_key, sid_server)
7
- @partner_id = partner_id.to_s
8
7
  @api_key = api_key
9
-
10
- @url = if sid_server !~ URI::DEFAULT_PARSER.make_regexp
11
- SmileIdentityCore::ENV::SID_SERVER_MAPPING[sid_server.to_s]
12
- else
13
- sid_server
14
- end
8
+ @partner_id = partner_id.to_s
9
+ @url = SmileIdentityCore::ENV.determine_url(sid_server)
15
10
 
16
11
  @signature_connection = SmileIdentityCore::Signature.new(@partner_id, @api_key)
17
12
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SmileIdentityCore
4
- VERSION = '2.2.1'
4
+ VERSION = '2.2.3'
5
5
  SOURCE_SDK = 'Ruby'
6
6
  end
@@ -12,15 +12,11 @@ module SmileIdentityCore
12
12
  # Allows Identity verifications of ids with images
13
13
  class WebApi
14
14
  def initialize(partner_id, default_callback, api_key, sid_server)
15
- @partner_id = partner_id.to_s
16
- @callback_url = default_callback
17
15
  @api_key = api_key
16
+ @callback_url = default_callback
17
+ @partner_id = partner_id.to_s
18
18
  @sid_server = sid_server
19
- @url = if sid_server !~ URI::DEFAULT_PARSER.make_regexp
20
- SmileIdentityCore::ENV::SID_SERVER_MAPPING[sid_server.to_s]
21
- else
22
- sid_server
23
- end
19
+ @url = SmileIdentityCore::ENV.determine_url(sid_server)
24
20
  end
25
21
 
26
22
  def submit_job(partner_params, images, id_info, options)
@@ -75,7 +71,7 @@ module SmileIdentityCore
75
71
  raise ArgumentError, 'Image details needs to be an array' unless images.is_a?(Array)
76
72
 
77
73
  # all job types require atleast a selfie
78
- if images.length.zero? || images.none? { |h| (h[:image_type_id]).zero? || h[:image_type_id] == 2 }
74
+ if images.empty? || images.none? { |h| (h[:image_type_id]).zero? || h[:image_type_id] == 2 }
79
75
  raise ArgumentError, 'You need to send through at least one selfie image'
80
76
  end
81
77
 
@@ -89,16 +85,18 @@ module SmileIdentityCore
89
85
  updated_id_info[:entered] = 'false' if !updated_id_info.key?(:entered) || id_info[:entered].empty?
90
86
 
91
87
  # if it's a boolean
92
- updated_id_info[:entered] = id_info[:entered].to_s if !updated_id_info[:entered].nil? == updated_id_info[:entered]
88
+ updated_id_info[:entered] = id_info[:entered].to_s
93
89
 
94
90
  is_jt6 = @partner_params[:job_type].to_i == JobType::DOCUMENT_VERIFICATION
95
- keys = if is_jt6
96
- %i[country]
97
- else
98
- %i[country id_type id_number]
99
- end
91
+ is_jt11 = @partner_params[:job_type].to_i == JobType::ENHANCED_DOCUMENT_VERIFICATION
92
+ keys = if is_jt6 || is_jt11
93
+ %i[country]
94
+ else
95
+ %i[country id_type id_number]
96
+ end
97
+ keys.push(:id_type) if is_jt11
100
98
 
101
- if updated_id_info[:entered] == 'true' || is_jt6
99
+ if updated_id_info[:entered] == 'true' || is_jt6 || is_jt11
102
100
  keys.each do |key|
103
101
  raise ArgumentError, "Please make sure that #{key} is included in the id_info" if id_info[key].to_s.empty?
104
102
  end
@@ -137,12 +135,12 @@ module SmileIdentityCore
137
135
 
138
136
  def request_web_token(request_params)
139
137
  request_params = request_params
140
- .merge(SmileIdentityCore::Signature.new(@partner_id, @api_key).generate_signature(Time.now.to_s))
141
- .merge(
142
- { partner_id: @partner_id,
143
- source_sdk: SmileIdentityCore::SOURCE_SDK,
144
- source_sdk_version: SmileIdentityCore::VERSION }
145
- )
138
+ .merge(SmileIdentityCore::Signature.new(@partner_id, @api_key).generate_signature(Time.now.to_s))
139
+ .merge(
140
+ { partner_id: @partner_id,
141
+ source_sdk: SmileIdentityCore::SOURCE_SDK,
142
+ source_sdk_version: SmileIdentityCore::VERSION }
143
+ )
146
144
  url = "#{@url}/token"
147
145
 
148
146
  response = Typhoeus.post(
@@ -161,9 +159,9 @@ module SmileIdentityCore
161
159
  end
162
160
 
163
161
  def validate_return_data
164
- if (!@callback_url || @callback_url.empty?) && !@options[:return_job_status]
165
- raise ArgumentError, 'Please choose to either get your response via the callback or job status query'
166
- end
162
+ return unless (!@callback_url || @callback_url.empty?) && !@options[:return_job_status]
163
+
164
+ raise ArgumentError, 'Please choose to either get your response via the callback or job status query'
167
165
  end
168
166
 
169
167
  def validate_enroll_with_id
@@ -37,7 +37,7 @@ Gem::Specification.new do |spec|
37
37
  spec.add_development_dependency 'rubocop', '~> 1.37.1'
38
38
  spec.add_development_dependency 'rubocop-rake', '~> 0.6.0'
39
39
  spec.add_development_dependency 'rubocop-rspec', '~> 2.14.1'
40
- spec.add_development_dependency 'simplecov', '~> 0.12.0'
40
+ spec.add_development_dependency 'simplecov', '~> 0.18'
41
41
 
42
42
  spec.add_dependency 'rubyzip', '~> 1.2', '>= 1.2.3'
43
43
  spec.add_dependency 'typhoeus', '~> 1.0', '>= 1.0.1'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smile-identity-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.1
4
+ version: 2.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Smile Identity
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-09-01 00:00:00.000000000 Z
11
+ date: 2023-10-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -100,14 +100,14 @@ dependencies:
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 0.12.0
103
+ version: '0.18'
104
104
  type: :development
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.12.0
110
+ version: '0.18'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: rubyzip
113
113
  requirement: !ruby/object:Gem::Requirement
@@ -172,6 +172,7 @@ files:
172
172
  - examples/biometric_kyc.rb
173
173
  - examples/business_verification.rb
174
174
  - examples/document_verification.rb
175
+ - examples/enhanced_document_verification.rb
175
176
  - examples/enhanced_kyc.rb
176
177
  - examples/example-project/Gemfile
177
178
  - examples/example-project/Gemfile.lock