smile-identity-core 2.2.5 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f2afcbbd6545c88d03ff0b594301cecbadde5254f80596f1ea0eb0618b503675
4
- data.tar.gz: f61285ea5a4a1bd2100c9a7595df42f99e6d45a83bb937669fdb7850b08c2742
3
+ metadata.gz: abb8ad5e4e436c109342eab8da6d4d24f497f5b3f7dca2ab368683b31a628624
4
+ data.tar.gz: 0d2c119d4d28d2ea8ef1b8e7ad96cf4293b64ae8fc6bb0399b0a7f198926a577
5
5
  SHA512:
6
- metadata.gz: 5c907e4c87b263502515cdf0481a74efa8610017d3205b3e5fcd026521ad511c2b6831b23d24485aa6fad62388cd5a207fe77b9530c77ecc0f8d75b33160e5bb
7
- data.tar.gz: 696a8eb8bb44d8cb2aec5f97b4f5ecf51789f1310d85e62bdb0f99542d3242fd78980b21740871af592bf7e8616aeafa0c3f6daa40550607f22404a16342de23
6
+ metadata.gz: d6356d1c4f5b32060274bb87ab75959cc34b7bddb4446143ccecee1c62ef364c9825413ad8afb5725b23ade388b7861d0b0bdfc4c4499ca193bec2148d4ed846
7
+ data.tar.gz: 83be55109d9f4aa6bfb74278fd2c50dc4efe687aae53ef52fe85579dbde2d750ffd1765f6b73049f28b87e407b700a524129c671f771311f6f9a05278dfbd482
data/CHANGELOG.md CHANGED
@@ -5,6 +5,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
5
5
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
7
  ## [Unreleased]
8
+ ## [2.3.0] - 2024-12-10
9
+ ### Added
10
+ - Support for Address verification
11
+
8
12
  ## [2.2.5] - 2024-06-11
9
13
  ### Fixed
10
14
  - No changes, fixed deployment issue
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- smile-identity-core (2.2.5)
4
+ smile-identity-core (2.3.0)
5
5
  rubyzip (~> 1.2, >= 1.2.3)
6
6
  typhoeus (~> 1.0, >= 1.0.1)
7
7
 
@@ -21,8 +21,7 @@ GEM
21
21
  rainbow (3.1.1)
22
22
  rake (12.3.3)
23
23
  regexp_parser (2.6.0)
24
- rexml (3.2.8)
25
- strscan (>= 3.0.9)
24
+ rexml (3.3.9)
26
25
  rspec (3.8.0)
27
26
  rspec-core (~> 3.8.0)
28
27
  rspec-expectations (~> 3.8.0)
@@ -60,7 +59,6 @@ GEM
60
59
  simplecov_json_formatter (~> 0.1)
61
60
  simplecov-html (0.12.3)
62
61
  simplecov_json_formatter (0.1.4)
63
- strscan (3.1.0)
64
62
  typhoeus (1.4.0)
65
63
  ethon (>= 0.9.0)
66
64
  unicode-display_width (2.3.0)
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'smile-identity-core'
4
+ # See https://docs.usesmileid.com/products/for-individuals-kyc/address-verification for
5
+ # more information on address verification
6
+
7
+ # Initialize
8
+ partner_id = '' # login to the Smile Identity portal to view your partner id
9
+ api_key = '' # copy your API key from the Smile Identity portal
10
+ sid_server = '0' # Use 0 for the sandbox server, use 1 for production server
11
+
12
+ # Array of example cases for different countries
13
+ example_cases = [
14
+ {
15
+ description: 'Example for South Africa (ZA)',
16
+ request_params: {
17
+ country: 'ZA', # (Required) Must be 'NG' or 'ZA'.
18
+ address: 'Cape Town', # (Required) A valid and complete address.
19
+ id_number: '1234567891234', # (Required for ZA) The 13-digit national ID number.
20
+ full_name: 'Doe Joe Leo', # (Optional) Full name for additional verification.
21
+ callback_url: 'https://webhook.site', # (Required) Callback URL for the response.
22
+ },
23
+ },
24
+ {
25
+ description: 'Example for Nigeria (NG)',
26
+ request_params: {
27
+ country: 'NG', # (Required) Must be 'NG' or 'ZA'.
28
+ address: 'Lagos', # (Required) A valid and complete address.
29
+ utility_number: '12345678911', # (Required for NG) Utility account number.
30
+ utility_provider: 'IkejaElectric', # (Required for NG) Utility provider name.
31
+ full_name: 'John Doe', # (Optional) Full name for additional verification.
32
+ callback_url: 'https://webhook.site', # (Required) Callback URL for the response.
33
+ },
34
+ },
35
+ ]
36
+
37
+ # Create a connection object
38
+ connection = SmileIdentityCore::AddressVerification.new(partner_id, api_key, sid_server)
39
+
40
+ # Loop through the example cases and make requests
41
+ example_cases.each do |example|
42
+ puts example[:description]
43
+ response = connection.submit_job(example[:request_params])
44
+ pp response
45
+ end
@@ -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
@@ -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
@@ -12,6 +12,25 @@ 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
+ 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)
20
+ end
21
+
22
+ # Confirms the signature against a newly generated signature based on the same timestamp
23
+ #
24
+ # @param [String] timestamp the timestamp to generate the signature from
25
+ # @param [String] msg_signature a previously generated signature, to be confirmed
26
+ # @return [Boolean] TRUE or FALSE
27
+ def confirm_signature(timestamp, msg_signature)
28
+ get_signature(timestamp)[:signature] == msg_signature
29
+ end
30
+
31
+ private
32
+
33
+ def get_signature(timestamp)
15
34
  hmac = OpenSSL::HMAC.new(@api_key, 'sha256')
16
35
  hmac.update(timestamp.to_s)
17
36
  hmac.update(@partner_id)
@@ -22,14 +41,5 @@ module SmileIdentityCore
22
41
  timestamp: timestamp.to_s,
23
42
  }
24
43
  end
25
-
26
- # Confirms the signature against a newly generated signature based on the same timestamp
27
- #
28
- # @param [String] timestamp the timestamp to generate the signature from
29
- # @param [String] msg_signature a previously generated signature, to be confirmed
30
- # @return [Boolean] TRUE or FALSE
31
- def confirm_signature(timestamp, msg_signature)
32
- generate_signature(timestamp)[:signature] == msg_signature
33
- end
34
44
  end
35
45
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SmileIdentityCore
4
- VERSION = '2.2.5'
4
+ VERSION = '2.3.0'
5
5
  SOURCE_SDK = 'Ruby'
6
6
  end
@@ -7,6 +7,7 @@ require_relative 'smile-identity-core/aml_check'
7
7
  require_relative 'smile-identity-core/signature'
8
8
  require_relative 'smile-identity-core/utilities'
9
9
  require_relative 'smile-identity-core/business_verification'
10
+ require_relative 'smile-identity-core/address_verification'
10
11
  require_relative 'smile-identity-core/constants/env'
11
12
  require_relative 'smile-identity-core/constants/image_type'
12
13
  require_relative 'smile-identity-core/constants/job_type'
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smile-identity-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.5
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Smile Identity
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2024-06-12 00:00:00.000000000 Z
10
+ date: 2025-01-09 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: bundler
@@ -169,6 +168,7 @@ files:
169
168
  - Rakefile
170
169
  - bin/console
171
170
  - bin/setup
171
+ - examples/address_verification.rb
172
172
  - examples/aml_check.rb
173
173
  - examples/biometric_kyc.rb
174
174
  - examples/business_verification.rb
@@ -183,6 +183,7 @@ files:
183
183
  - examples/get_web_token.rb
184
184
  - examples/smart_selfie_authentication.rb
185
185
  - lib/smile-identity-core.rb
186
+ - lib/smile-identity-core/address_verification.rb
186
187
  - lib/smile-identity-core/aml_check.rb
187
188
  - lib/smile-identity-core/business_verification.rb
188
189
  - lib/smile-identity-core/constants/env.rb
@@ -204,7 +205,6 @@ metadata:
204
205
  documentation_uri: https://docs.usesmileid.com
205
206
  changelog_uri: https://github.com/smileidentity/smile-identity-core-ruby/blob/master/CHANGELOG.md
206
207
  rubygems_mfa_required: 'true'
207
- post_install_message:
208
208
  rdoc_options: []
209
209
  require_paths:
210
210
  - lib
@@ -219,8 +219,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
219
219
  - !ruby/object:Gem::Version
220
220
  version: '0'
221
221
  requirements: []
222
- rubygems_version: 3.5.9
223
- signing_key:
222
+ rubygems_version: 3.6.2
224
223
  specification_version: 4
225
224
  summary: The Smile Identity Web API allows the user to access\ most of the features
226
225
  of the Smile Identity system through direct server to server queries.