usesmileid 13.0.0 → 13.2.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: f64d6fd177105edbffe5bceac374c675140d49a0da20d8e56041ae156429dda3
4
- data.tar.gz: 810132bb74281566a6957f2ae76dd647d0e685f1423a71db26780dbf9351076f
3
+ metadata.gz: 2759896be24ef979f47a9794d279fc97cf05390a43ae97b33af18b787b413a3d
4
+ data.tar.gz: 9ae56e3aea45fc59a10ef8a3f5ddd6e04e97694251eb07ad71dae49cc293527d
5
5
  SHA512:
6
- metadata.gz: 856a7d6b04e054b1084d21dd35822274c2f0fcced663944ad01b6c6446df160e1f58237a5686c9f0824bd64e6cdf9de32b9b131fd1db68d4f34287998a9da0f4
7
- data.tar.gz: 306285d436a657d8bbafe633b101cebb9f5e6e955b2fe60029d6ff08e3cc0c5665fb58edfa78037323f7f23563897012e4fff02fd7b2d6810cb01c5b2f6bb427
6
+ metadata.gz: 3fdcfad5606923a87f00e7ff43a0adc5bb970d0344bac3b0ef66f6220d4a9816acce9b4ce9343c396c24589bcaf9476ddc727dbdecc5c1435cf9a329711a337f
7
+ data.tar.gz: 9926babc0a54d80f5a68ec95c2e871f837a98d11c0cbbda153a031572eb93ef44e111be484c00d0d885b0b79428445255d7be17e9e19c4dc55eefd7e7ced95a2
data/CHANGELOG.md CHANGED
@@ -7,6 +7,27 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [13.2.0] - 2026-11-24
11
+
12
+ ### Added
13
+
14
+ - Basic KYC: `basic_kyc.verify` (async, result on the callback URL) and `basic_kyc.verify_sync` (result returned inline). The inline result is a `BasicKycResult` with a verdict per field in `match_results`, and it carries the `SmileID-Job-ID`, `User-ID`, `Response-Signature` and `Response-Timestamp` response headers. Both operations mint their token with the `basic_kyc` product claim.
15
+ - Enhanced KYC: `enhanced_kyc.verify_sync`, which runs the same verification as `enhanced_kyc.verify` and returns the result inline. It takes the same arguments, sends no default callback URL, and does not retry a 408, 424 or 500. The result is an `EnhancedKycResult` with the full callback payload in `raw`. Its `job_id` and `user_id` come from the `SmileID-Job-ID` and `User-ID` response headers, or from the body when a header is absent, and `response_signature` and `response_timestamp` from the `Response-Signature` and `Response-Timestamp` headers, for your own webhook verification code. Its token is minted with the `enhanced_kyc` product claim.
16
+ - `SmileIDError#job_id`: the job id from the `SmileID-Job-ID` response header, or `nil` when the response had none. It is set on every error raised from an HTTP response. When `basic_kyc.verify_sync` or `enhanced_kyc.verify_sync` fails with a 408 or 424, or a 500 with a `job_id`, read the outcome with `verifications.retrieve(error.job_id)` instead of resubmitting. When `aml.submit_sync` fails with a 408, resubmit; a 500 with a `job_id` can be read the same way.
17
+ - `SmileID::Errors.job_id_from` and `SmileID::Errors.header_value`, which read a response header by name, ignoring case. `BasicKycResult`, `EnhancedKycResult` and `OneTimeAmlResult` read their response headers this way, so `.from` also accepts a plain hash of headers in any casing.
18
+
19
+ ## [13.1.0] - 2026-11-19
20
+
21
+ ### Added
22
+
23
+ - One-Time AML: `aml.submit` (async, result on the callback URL) and `aml.submit_sync` (result returned inline, with an optional `idempotency_key:`). The inline result is a `OneTimeAmlResult` that also carries the `SmileID-Job-ID`, `Response-Signature` and `Response-Timestamp` response headers.
24
+ - AML Monitoring: `aml_monitoring.submit` and `aml_monitoring.news`, which reads the news articles for one person in a monitoring result.
25
+ - `countries` and `aliases` are sent as JSON multipart parts, as the AML endpoints require.
26
+
27
+ ### Fixed
28
+
29
+ - `aml_monitoring.news` now mints its token with the `aml` product claim, as the spec's `x-smile-token-product` requires. Each operation's product now comes from the generated operations table (`Operation#product`), and `Client::PRODUCT_BY_PATH` is derived from it.
30
+
10
31
  ## [13.0.0] - 2026-11-09
11
32
 
12
33
  Version 12.2.0 was never published. Its changes are in this release, which is a major version because it breaks the 12.1.0 API.
@@ -65,7 +86,9 @@ First public release.
65
86
  - Typed errors under `SmileID::Errors`, keyed on HTTP status.
66
87
  - Bank codes, supported ID types and supported documents lookups.
67
88
 
68
- [Unreleased]: https://github.com/smileidentity/smileid-sdk-ruby/compare/v13.0.0...HEAD
89
+ [Unreleased]: https://github.com/smileidentity/smileid-sdk-ruby/compare/v13.2.0...HEAD
90
+ [13.2.0]: https://github.com/smileidentity/smileid-sdk-ruby/compare/v13.1.0...v13.2.0
91
+ [13.1.0]: https://github.com/smileidentity/smileid-sdk-ruby/compare/v13.0.0...v13.1.0
69
92
  [13.0.0]: https://github.com/smileidentity/smileid-sdk-ruby/compare/v12.1.0...v13.0.0
70
93
  [12.1.0]: https://github.com/smileidentity/smileid-sdk-ruby/compare/v12.0.0...v12.1.0
71
94
  [12.0.0]: https://github.com/smileidentity/smileid-sdk-ruby/releases/tag/v12.0.0
data/README.md CHANGED
@@ -110,6 +110,103 @@ accepted.job_id # => "job_..."
110
110
  accepted.accepted? # => true
111
111
  ```
112
112
 
113
+ `enhanced_kyc.verify_sync` takes the same arguments but returns the result in the response. The API ignores `callback_url` on this call, so the client's `default_callback_url` isn't sent. The result carries the `Response-Signature` and `Response-Timestamp` headers as `response_signature` and `response_timestamp`, so you can check them with your own webhook signature verification code. The SDK doesn't verify them. If the verification can't be completed, it raises `SmileID::Errors::SmileIDError` with `status_code` 424, 408 or 500. The job may still have run, and resubmitting runs and bills a second lookup, so don't resubmit automatically. On a 408 or 424 the job is recorded: read its outcome with `verifications.retrieve(error.job_id)`. Do the same for a 500 that has a `job_id`. A 500 with no `job_id` means the job wasn't created.
114
+
115
+ ```ruby
116
+ result = smile.enhanced_kyc.verify_sync(
117
+ country: "NG", id_type: "NIN", id_number: "12345678901",
118
+ user_details: user_details, consent: consent
119
+ )
120
+ result.status # => "clear", "block", "attention" or "error"
121
+ result.raw # the full callback payload, including the ID authority's record
122
+ result.job_id # from the SmileID-Job-ID header, else the body's job_id
123
+ ```
124
+
125
+ ```ruby
126
+ begin
127
+ result = smile.enhanced_kyc.verify_sync(...)
128
+ rescue SmileID::Errors::SmileIDError => e
129
+ # Only a 408, 424 or 500 that names a job has an outcome to read.
130
+ raise unless [408, 424, 500].include?(e.status_code) && e.job_id
131
+
132
+ status = smile.verifications.retrieve(e.job_id) # don't resubmit
133
+ end
134
+ ```
135
+
136
+ ### Basic KYC
137
+
138
+ Basic KYC checks the details you submit against the ID authority's record and reports a match verdict per field. It never returns the record itself. `basic_kyc.verify` takes the same arguments as Enhanced KYC, apart from `user_id`, and sends the result to your callback URL:
139
+
140
+ ```ruby
141
+ accepted = smile.basic_kyc.verify(
142
+ country: "NG",
143
+ id_type: "NIN",
144
+ id_number: "12345678901",
145
+ user_details: user_details,
146
+ consent: consent,
147
+ callback_url: "https://example.com/callback" # optional if a default is configured
148
+ )
149
+ ```
150
+
151
+ `basic_kyc.verify_sync` returns the result in the response. The API ignores `callback_url` on this call, so the client's `default_callback_url` isn't sent. If the verification can't be completed, it raises `SmileID::Errors::SmileIDError` with `status_code` 424, 408 or 500. The job may still have run, and resubmitting runs and bills a second lookup, so don't resubmit automatically. On a 408 or 424 the job is recorded: read its outcome with `verifications.retrieve(error.job_id)`. Do the same for a 500 that has a `job_id`. A 500 with no `job_id` means the job wasn't created.
152
+
153
+ ```ruby
154
+ result = smile.basic_kyc.verify_sync(
155
+ country: "NG", id_type: "NIN", id_number: "12345678901",
156
+ user_details: user_details, consent: consent
157
+ )
158
+ result.status # => "clear", "block", "attention" or "error"
159
+ result.match_results["overall"] # => "exact_match", "partial_match", "transposed", "no_match" or "not_provided"
160
+ result.job_id # from the SmileID-Job-ID header
161
+ ```
162
+
163
+ ```ruby
164
+ begin
165
+ result = smile.basic_kyc.verify_sync(...)
166
+ rescue SmileID::Errors::SmileIDError => e
167
+ # Only a 408, 424 or 500 that names a job has an outcome to read.
168
+ raise unless [408, 424, 500].include?(e.status_code) && e.job_id
169
+
170
+ status = smile.verifications.retrieve(e.job_id) # don't resubmit
171
+ end
172
+ ```
173
+
174
+ ### AML screening
175
+
176
+ One-Time AML screens a name against sanctions, PEP and adverse-media lists. `aml.submit` queues the screening and the result goes to your callback URL:
177
+
178
+ ```ruby
179
+ accepted = smile.aml.submit(
180
+ countries: ["NG", "KE"],
181
+ full_name: "John Doe",
182
+ user_details: user_details,
183
+ consent: consent,
184
+ callback_url: "https://example.com/callback" # optional if a default is configured
185
+ )
186
+ ```
187
+
188
+ `aml.submit_sync` takes the same arguments but returns the result in the response, so `callback_url` is optional. Pass an `idempotency_key:` (16 to 128 characters of `A-Z a-z 0-9 - _`) so a retry returns the original result instead of a second billed screening. A provider timeout raises `SmileID::Errors::SmileIDError` with `status_code` 408. Nothing is billed and the job is final in `error`, so resubmit rather than reading its status, with the same `idempotency_key:` to make the resubmission safe to repeat. A 500 that has a `job_id` means the job exists: read its outcome with `verifications.retrieve(error.job_id)`.
189
+
190
+ ```ruby
191
+ result = smile.aml.submit_sync(
192
+ countries: ["NG"], full_name: "John Doe",
193
+ user_details: user_details, consent: consent,
194
+ idempotency_key: "onboarding-8f14e45fceea167a"
195
+ )
196
+ result.status # => "clear", "block", "attention" or "error"
197
+ result.no_of_persons_found # => 0
198
+ result.job_id # from the SmileID-Job-ID header
199
+ ```
200
+
201
+ AML Monitoring enrols the person for ongoing screening. `aml_monitoring.submit` takes the same arguments (`full_name:` is optional with `search_existing_user: true` and a `user_id:`). `aml_monitoring.news` reads the news articles behind a person reference in a result:
202
+
203
+ ```ruby
204
+ smile.aml_monitoring.submit(countries: ["NG"], full_name: "Jane Doe",
205
+ user_details: user_details, consent: consent)
206
+ news = smile.aml_monitoring.news("a1b2c3d4e5", "ref_001", news_category: "financial_crime", page: 1, limit: 25)
207
+ news.news.first.title
208
+ ```
209
+
113
210
  ### Document verification
114
211
 
115
212
  ```ruby
@@ -322,7 +419,7 @@ Every API failure raises a typed error under `SmileID::Errors`, keyed on the HTT
322
419
  | `TimeoutError` | `wait_until_complete` deadline passed (no HTTP response) |
323
420
  | `UnexpectedResponseError` | a 2xx response whose body is not the expected JSON object, for example proxy interference |
324
421
 
325
- Each error exposes `status_code`, `status`, `message`, `code`, `request_id` and `raw_body`.
422
+ Each error exposes `status_code`, `status`, `message`, `code`, `request_id`, `job_id` and `raw_body`. `job_id` comes from the `SmileID-Job-ID` response header and is `nil` when the response had none.
326
423
 
327
424
  ```ruby
328
425
  begin
@@ -7,18 +7,12 @@ module SmileID
7
7
  # The Smile ID client (spec section 2.1, 4). Construct once, then call
8
8
  # resource verbs, e.g. client.enhanced_kyc.verify(...).
9
9
  class Client
10
- # Mirrors the API authorizer: a token bound to a product is accepted only on
11
- # that product's endpoint. Paths absent here mint a token with no claims.
12
- PRODUCT_BY_PATH = {
13
- '/v3/enhanced_kyc' => 'enhanced_kyc',
14
- '/v3/document_verification' => 'document_verification',
15
- '/v3/enhanced_document_verification' => 'enhanced_document_verification',
16
- '/v3/residency_document_verification' => 'residency_document_verification',
17
- '/v3/biometric_kyc' => 'biometric_kyc',
18
- '/v3/registration' => 'smart_selfie_registration',
19
- '/v3/authentication' => 'smart_selfie_authentication',
20
- '/v3/compare' => 'smart_selfie_compare'
21
- }.freeze
10
+ # Product claim by path, taken from the spec's x-smile-token-product via the
11
+ # generated operations table. Kept for compatibility; the client reads each
12
+ # operation's product directly.
13
+ PRODUCT_BY_PATH = Generated::Operations::OPS.values
14
+ .select(&:product)
15
+ .to_h { |op| [op.path, op.product] }.freeze
22
16
 
23
17
  attr_reader :config
24
18
 
@@ -37,6 +31,10 @@ module SmileID
37
31
  @enhanced_kyc ||= Resources::EnhancedKyc.new(self)
38
32
  end
39
33
 
34
+ def basic_kyc
35
+ @basic_kyc ||= Resources::BasicKyc.new(self)
36
+ end
37
+
40
38
  def documents
41
39
  @documents ||= Resources::Documents.new(self)
42
40
  end
@@ -57,6 +55,14 @@ module SmileID
57
55
  @users ||= Resources::Users.new(self)
58
56
  end
59
57
 
58
+ def aml
59
+ @aml ||= Resources::Aml.new(self)
60
+ end
61
+
62
+ def aml_monitoring
63
+ @aml_monitoring ||= Resources::AmlMonitoring.new(self)
64
+ end
65
+
60
66
  def services
61
67
  @services ||= Resources::Services.new(self)
62
68
  end
@@ -68,13 +74,13 @@ module SmileID
68
74
  #
69
75
  # @return [SmileID::Response] on a success status for the operation.
70
76
  def call(op_key, form: nil, path_params: {}, query: {}, user_id_header: nil, timeout: nil,
71
- use_enrolled_image: false)
77
+ use_enrolled_image: false, extra_headers: nil)
72
78
  op = Generated::Operations.fetch(op_key)
73
79
  url = @config.base_url + interpolate(op.path, path_params)
74
80
  content_type, body = serialize(op, form)
75
81
  token = mint_token(op, form, user_id_header, use_enrolled_image, timeout) if op.authenticated
76
82
 
77
- headers = build_headers(op, content_type, user_id_header, token)
83
+ headers = build_headers(op, content_type, user_id_header, token).merge(extra_headers || {})
78
84
  response = @transport.send_request(
79
85
  method: op.http_method, url: url, headers: headers, query: query || {},
80
86
  body: body, retryable: op.idempotent, timeout: timeout
@@ -106,7 +112,7 @@ module SmileID
106
112
  # (use_enrolled_image) authorises a captureless job for one user, so it must
107
113
  # never reach another call's token.
108
114
  def mint_token(op, form, user_id_header, use_enrolled_image, timeout)
109
- product = PRODUCT_BY_PATH[op.path]
115
+ product = op.product
110
116
  user_id = job_user_id(form, user_id_header) if product
111
117
  if use_enrolled_image && user_id.nil?
112
118
  raise Errors::ValidationError.new('user_id is required when use_enrolled_image is true')
@@ -143,7 +149,8 @@ module SmileID
143
149
  'token endpoint returned no token',
144
150
  status_code: response.status,
145
151
  request_id: Errors.request_id_from(response.headers),
146
- raw_body: response.raw_body
152
+ raw_body: response.raw_body,
153
+ job_id: Errors.job_id_from(response.headers)
147
154
  )
148
155
  end
149
156
 
@@ -181,7 +188,8 @@ module SmileID
181
188
  'expected a JSON object response body',
182
189
  status_code: response.status,
183
190
  request_id: Errors.request_id_from(response.headers),
184
- raw_body: response.raw_body
191
+ raw_body: response.raw_body,
192
+ job_id: Errors.job_id_from(response.headers)
185
193
  )
186
194
  end
187
195
 
@@ -41,24 +41,117 @@ module SmileID
41
41
  end
42
42
  end
43
43
 
44
- # POST /v3/enhanced_kyc
44
+ # POST /v3/enhanced_kyc and /v3/enhanced_kyc/sync
45
45
  class EnhancedKyc < Base
46
+ # Queues an Enhanced KYC verification. The result arrives on callback_url.
46
47
  def verify(country:, id_type:, id_number:, user_details:, consent:,
47
48
  callback_url: nil, bank_code: nil, operator: nil,
48
49
  partner_params: nil, metadata: nil, user_id: nil, timeout: nil)
49
- form = {
50
+ form = enhanced_kyc_form(
51
+ country: country, id_type: id_type, id_number: id_number,
52
+ user_details: user_details, consent: consent,
53
+ callback_url: resolve_callback(callback_url), bank_code: bank_code,
54
+ operator: operator, partner_params: partner_params, metadata: metadata
55
+ )
56
+ accepted(@client.call(:enhanced_kyc, form: form, user_id_header: user_id, timeout: timeout))
57
+ end
58
+
59
+ # Runs the same verification and returns the result in the response.
60
+ # The API ignores callback_url here, so the client's default callback
61
+ # URL is never sent; a callback_url passed on the call is checked and
62
+ # sent as given. A verification that could not be completed raises
63
+ # SmileIDError with status_code 424, 408 or 500. The job may still have
64
+ # run, and resubmitting runs and bills a second lookup, so don't
65
+ # resubmit automatically: read the outcome with
66
+ # verifications.retrieve(error.job_id). A 500 with no job_id means the
67
+ # job was not created.
68
+ def verify_sync(country:, id_type:, id_number:, user_details:, consent:,
69
+ callback_url: nil, bank_code: nil, operator: nil,
70
+ partner_params: nil, metadata: nil, user_id: nil, timeout: nil)
71
+ Config.validate_callback_url!(callback_url) if callback_url
72
+ form = enhanced_kyc_form(
73
+ country: country, id_type: id_type, id_number: id_number,
74
+ user_details: user_details, consent: consent, callback_url: callback_url,
75
+ bank_code: bank_code, operator: operator, partner_params: partner_params,
76
+ metadata: metadata
77
+ )
78
+ response = @client.call(:enhanced_kyc_sync, form: form, user_id_header: user_id, timeout: timeout)
79
+ Generated::Models::EnhancedKycResult.from(response.json, response.headers)
80
+ end
81
+
82
+ private
83
+
84
+ def enhanced_kyc_form(country:, id_type:, id_number:, user_details:, consent:, callback_url:,
85
+ bank_code:, operator:, partner_params:, metadata:)
86
+ {
50
87
  'country' => country,
51
88
  'id_type' => id_type,
52
89
  'id_number' => id_number,
53
90
  'user_details' => coerce_user_details(user_details),
54
91
  'consent' => coerce_consent(consent),
55
- 'callback_url' => resolve_callback(callback_url),
92
+ 'callback_url' => callback_url,
93
+ 'bank_code' => bank_code,
94
+ 'operator' => operator,
95
+ 'partner_params' => partner_params,
96
+ 'metadata' => metadata
97
+ }.compact
98
+ end
99
+ end
100
+
101
+ # POST /v3/basic_kyc and /v3/basic_kyc/sync
102
+ class BasicKyc < Base
103
+ # Queues a Basic KYC verification. The result arrives on callback_url.
104
+ def verify(country:, id_type:, id_number:, user_details:, consent:,
105
+ callback_url: nil, bank_code: nil, operator: nil,
106
+ partner_params: nil, metadata: nil, timeout: nil)
107
+ form = basic_kyc_form(
108
+ country: country, id_type: id_type, id_number: id_number,
109
+ user_details: user_details, consent: consent,
110
+ callback_url: resolve_callback(callback_url), bank_code: bank_code,
111
+ operator: operator, partner_params: partner_params, metadata: metadata
112
+ )
113
+ accepted(@client.call(:basic_kyc, form: form, timeout: timeout))
114
+ end
115
+
116
+ # Runs the same verification and returns the result in the response.
117
+ # The API ignores callback_url here, so the client's default callback
118
+ # URL is never sent; a callback_url passed on the call is checked and
119
+ # sent as given. A verification that could not be completed raises
120
+ # SmileIDError with status_code 424, 408 or 500. The job may still have
121
+ # run, and resubmitting runs and bills a second lookup, so don't
122
+ # resubmit automatically: read the outcome with
123
+ # verifications.retrieve(error.job_id). A 500 with no job_id means the
124
+ # job was not created.
125
+ def verify_sync(country:, id_type:, id_number:, user_details:, consent:,
126
+ callback_url: nil, bank_code: nil, operator: nil,
127
+ partner_params: nil, metadata: nil, timeout: nil)
128
+ Config.validate_callback_url!(callback_url) if callback_url
129
+ form = basic_kyc_form(
130
+ country: country, id_type: id_type, id_number: id_number,
131
+ user_details: user_details, consent: consent, callback_url: callback_url,
132
+ bank_code: bank_code, operator: operator, partner_params: partner_params,
133
+ metadata: metadata
134
+ )
135
+ response = @client.call(:basic_kyc_sync, form: form, timeout: timeout)
136
+ Generated::Models::BasicKycResult.from(response.json, response.headers)
137
+ end
138
+
139
+ private
140
+
141
+ def basic_kyc_form(country:, id_type:, id_number:, user_details:, consent:, callback_url:,
142
+ bank_code:, operator:, partner_params:, metadata:)
143
+ {
144
+ 'country' => country,
145
+ 'id_type' => id_type,
146
+ 'id_number' => id_number,
147
+ 'user_details' => coerce_user_details(user_details),
148
+ 'consent' => coerce_consent(consent),
149
+ 'callback_url' => callback_url,
56
150
  'bank_code' => bank_code,
57
151
  'operator' => operator,
58
152
  'partner_params' => partner_params,
59
153
  'metadata' => metadata
60
154
  }.compact
61
- accepted(@client.call(:enhanced_kyc, form: form, user_id_header: user_id, timeout: timeout))
62
155
  end
63
156
  end
64
157
 
@@ -236,6 +329,112 @@ module SmileID
236
329
  end
237
330
  end
238
331
 
332
+ # POST /v3/aml and /v3/aml/sync
333
+ class Aml < Base
334
+ # Queues a One-Time AML screening. The result arrives on callback_url.
335
+ def submit(countries:, full_name:, user_details:, consent:, birth_year: nil,
336
+ strict_match: nil, aliases: nil, search_existing_user: nil,
337
+ callback_url: nil, partner_params: nil, metadata: nil, user_id: nil, timeout: nil)
338
+ form = aml_form(
339
+ countries: countries, full_name: full_name, user_details: user_details,
340
+ consent: consent, birth_year: birth_year, strict_match: strict_match,
341
+ aliases: aliases, search_existing_user: search_existing_user,
342
+ callback_url: resolve_callback(callback_url), partner_params: partner_params,
343
+ metadata: metadata, user_id: user_id
344
+ )
345
+ accepted(@client.call(:one_time_aml, form: form, user_id_header: user_id, timeout: timeout))
346
+ end
347
+
348
+ # Runs the same screening and returns the terminal result in the response.
349
+ # callback_url is optional: no callback is sent, but a given one is kept
350
+ # for replay. Send the same idempotency_key on a retry to get the original
351
+ # result instead of a second, billed screening. A provider timeout raises
352
+ # SmileIDError with status_code 408; nothing is billed and the job is
353
+ # final in `error`, so resubmit rather than poll. A 500 with a job_id
354
+ # can be read with verifications.retrieve(error.job_id).
355
+ def submit_sync(countries:, full_name:, user_details:, consent:, birth_year: nil,
356
+ strict_match: nil, aliases: nil, search_existing_user: nil,
357
+ callback_url: nil, partner_params: nil, metadata: nil, user_id: nil,
358
+ idempotency_key: nil, timeout: nil)
359
+ Config.validate_callback_url!(callback_url) if callback_url
360
+ form = aml_form(
361
+ countries: countries, full_name: full_name, user_details: user_details,
362
+ consent: consent, birth_year: birth_year, strict_match: strict_match,
363
+ aliases: aliases, search_existing_user: search_existing_user,
364
+ callback_url: callback_url, partner_params: partner_params,
365
+ metadata: metadata, user_id: user_id
366
+ )
367
+ extra_headers = idempotency_key ? { 'SmileID-Idempotency-Key' => idempotency_key } : nil
368
+ response = @client.call(:one_time_aml_sync, form: form, user_id_header: user_id,
369
+ timeout: timeout, extra_headers: extra_headers)
370
+ Generated::Models::OneTimeAmlResult.from(response.json, response.headers)
371
+ end
372
+
373
+ private
374
+
375
+ def aml_form(countries:, full_name:, user_details:, consent:, birth_year:, strict_match:,
376
+ aliases:, search_existing_user:, callback_url:, partner_params:, metadata:, user_id:)
377
+ {
378
+ 'countries' => countries,
379
+ 'full_name' => full_name,
380
+ 'birth_year' => birth_year,
381
+ 'strict_match' => strict_match,
382
+ 'aliases' => aliases,
383
+ 'search_existing_user' => search_existing_user,
384
+ 'user_id' => user_id,
385
+ 'user_details' => coerce_user_details(user_details),
386
+ 'consent' => coerce_consent(consent),
387
+ 'callback_url' => callback_url,
388
+ 'partner_params' => partner_params,
389
+ 'metadata' => metadata
390
+ }.compact
391
+ end
392
+ end
393
+
394
+ # POST /v3/aml/monitoring and GET /v3/aml/monitoring/{job_id}/news/{reference}
395
+ class AmlMonitoring < Base
396
+ NEWS_CATEGORIES = %w[
397
+ arms_trafficking credit_update environmental_crime financial_crime
398
+ human_rights_violation leadership_change legal_risk location_change narcotics
399
+ other other_crime ownership_change product_change regulatory sexual_crime
400
+ technology_event terrorism violent_crime
401
+ ].freeze
402
+
403
+ # full_name is required unless search_existing_user is true, which takes
404
+ # the name from the user's earlier KYC record and needs user_id.
405
+ def submit(countries:, user_details:, consent:, full_name: nil, birth_year: nil,
406
+ strict_match: nil, aliases: nil, search_existing_user: nil,
407
+ callback_url: nil, partner_params: nil, metadata: nil, user_id: nil, timeout: nil)
408
+ form = {
409
+ 'countries' => countries,
410
+ 'full_name' => full_name,
411
+ 'birth_year' => birth_year,
412
+ 'strict_match' => strict_match,
413
+ 'aliases' => aliases,
414
+ 'search_existing_user' => search_existing_user,
415
+ 'user_id' => user_id,
416
+ 'user_details' => coerce_user_details(user_details),
417
+ 'consent' => coerce_consent(consent),
418
+ 'callback_url' => resolve_callback(callback_url),
419
+ 'partner_params' => partner_params,
420
+ 'metadata' => metadata
421
+ }.compact
422
+ accepted(@client.call(:aml_monitoring, form: form, user_id_header: user_id, timeout: timeout))
423
+ end
424
+
425
+ def news(job_id, reference, news_category:, page: nil, limit: nil, timeout: nil)
426
+ unless NEWS_CATEGORIES.include?(news_category.to_s)
427
+ raise Errors::ValidationError.new("news_category must be one of #{NEWS_CATEGORIES.join(', ')}")
428
+ end
429
+
430
+ query = { 'news_category' => news_category, 'page' => page, 'limit' => limit }.compact
431
+ response = @client.call(:aml_monitoring_news,
432
+ path_params: { 'job_id' => job_id, 'reference' => reference },
433
+ query: query, timeout: timeout)
434
+ Generated::Models::AmlMonitoringNewsResponse.from(response.json)
435
+ end
436
+ end
437
+
239
438
  # GET /v3/status, POST /v3/replay, plus the wait_until_complete poll helper.
240
439
  class Verifications < Base
241
440
  def retrieve(job_id, timeout: nil)
@@ -21,15 +21,20 @@ module SmileID
21
21
  attr_reader :request_id
22
22
  # The unparsed response body.
23
23
  attr_reader :raw_body
24
+ # The Smile job id from the SmileID-Job-ID response header, or nil when
25
+ # the response had none. On a sync call that failed with 408, 424 or 500
26
+ # it names a job whose outcome verifications.retrieve can read.
27
+ attr_reader :job_id
24
28
 
25
29
  def initialize(message = nil, status_code: nil, status: nil, code: nil,
26
- request_id: nil, raw_body: nil)
30
+ request_id: nil, raw_body: nil, job_id: nil)
27
31
  super(message)
28
32
  @status_code = status_code
29
33
  @status = status
30
34
  @code = code
31
35
  @request_id = request_id
32
36
  @raw_body = raw_body
37
+ @job_id = job_id
33
38
  end
34
39
  end
35
40
 
@@ -89,6 +94,9 @@ module SmileID
89
94
  # spec today; populate from a header if the backend ever sends one).
90
95
  REQUEST_ID_HEADERS = %w[x-request-id smileid-request-id request-id].freeze
91
96
 
97
+ # The response header that carries the Smile job id.
98
+ JOB_ID_HEADER = 'SmileID-Job-ID'
99
+
92
100
  # Select the error class for an HTTP status code.
93
101
  def self.class_for(status_code)
94
102
  return STATUS_CLASSES[status_code] if STATUS_CLASSES.key?(status_code)
@@ -108,7 +116,8 @@ module SmileID
108
116
  status: body['status'],
109
117
  code: body['code'],
110
118
  request_id: request_id_from(headers),
111
- raw_body: raw_body
119
+ raw_body: raw_body,
120
+ job_id: job_id_from(headers)
112
121
  )
113
122
  end
114
123
 
@@ -121,5 +130,21 @@ module SmileID
121
130
  end
122
131
  nil
123
132
  end
133
+
134
+ # The SmileID-Job-ID response header with surrounding whitespace removed,
135
+ # or nil when it is absent or blank.
136
+ def self.job_id_from(headers)
137
+ job_id = header_value(headers, JOB_ID_HEADER).to_s.strip
138
+ job_id.empty? ? nil : job_id
139
+ end
140
+
141
+ # Looks a response header up by name, ignoring case. Returns nil when the
142
+ # header is absent or headers is not a hash.
143
+ def self.header_value(headers, name)
144
+ return nil unless headers.respond_to?(:each_pair)
145
+
146
+ headers.each_pair { |key, value| return value if key.to_s.casecmp?(name) }
147
+ nil
148
+ end
124
149
  end
125
150
  end
@@ -107,6 +107,176 @@ module SmileID
107
107
  end
108
108
  end
109
109
 
110
+ # Result of a One-Time AML screening: the body of POST /v3/aml/sync, which
111
+ # is the payload the async callback would have delivered. `status` is
112
+ # `clear`, `block`, `attention` or `error`. The response headers are kept
113
+ # alongside the body: the job and user ids, and the signature and
114
+ # timestamp that webhook verification code can check unchanged.
115
+ class OneTimeAmlResult
116
+ attr_reader :status, :message, :reason, :created_at, :completed_at, :product,
117
+ :partner_params, :kyc_receipt, :strict_match, :no_of_persons_found,
118
+ :people, :user_provided_info, :consent, :antifraud, :device_signals,
119
+ :job_id, :user_id, :response_signature, :response_timestamp, :raw
120
+
121
+ def initialize(hash, headers = {})
122
+ @status = hash['status']
123
+ @message = hash['message']
124
+ @reason = hash['reason']
125
+ @created_at = hash['created_at']
126
+ @completed_at = hash['completed_at']
127
+ @product = hash['product']
128
+ @partner_params = hash['partner_params']
129
+ @kyc_receipt = hash['kyc_receipt']
130
+ @strict_match = hash['strict_match']
131
+ @no_of_persons_found = hash['no_of_persons_found']
132
+ @people = hash['people'] || []
133
+ @user_provided_info = hash['user_provided_info']
134
+ @consent = hash['consent']
135
+ @antifraud = hash['antifraud']
136
+ @device_signals = hash['device_signals']
137
+ @job_id = Errors.job_id_from(headers)
138
+ @user_id = Errors.header_value(headers, 'user-id')
139
+ @response_signature = Errors.header_value(headers, 'response-signature')
140
+ @response_timestamp = Errors.header_value(headers, 'response-timestamp')
141
+ @raw = hash
142
+ end
143
+
144
+ def self.from(hash, headers = {})
145
+ new(hash, headers)
146
+ end
147
+ end
148
+
149
+ # Result of a Basic KYC verification: the body of POST /v3/basic_kyc/sync,
150
+ # which is the payload the async callback would have delivered. `status`
151
+ # is `clear`, `block`, `attention` or `error`. `match_results` is a plain
152
+ # hash with string keys: one verdict per submitted field (`overall`,
153
+ # `names`, `first_name`, `last_name`, `other_names`, `date_of_birth`,
154
+ # `gender`, `phone_number`, `secondary_id_number`), each one of
155
+ # `exact_match`, `partial_match`, `transposed`, `no_match` or
156
+ # `not_provided`. It is nil when no verdict was produced. Basic KYC never
157
+ # returns the ID record itself. The response headers are kept alongside
158
+ # the body, as for OneTimeAmlResult.
159
+ class BasicKycResult
160
+ attr_reader :status, :message, :reason, :created_at, :completed_at, :product,
161
+ :partner_params, :match_results, :user_provided_info, :consent,
162
+ :antifraud, :device_signals, :kyc_receipt,
163
+ :job_id, :user_id, :response_signature, :response_timestamp, :raw
164
+
165
+ def initialize(hash, headers = {})
166
+ @status = hash['status']
167
+ @message = hash['message']
168
+ @reason = hash['reason']
169
+ @created_at = hash['created_at']
170
+ @completed_at = hash['completed_at']
171
+ @product = hash['product']
172
+ @partner_params = hash['partner_params']
173
+ @match_results = hash['match_results']
174
+ @user_provided_info = hash['user_provided_info']
175
+ @consent = hash['consent']
176
+ @antifraud = hash['antifraud']
177
+ @device_signals = hash['device_signals']
178
+ @kyc_receipt = hash['kyc_receipt']
179
+ @job_id = Errors.job_id_from(headers)
180
+ @user_id = Errors.header_value(headers, 'user-id')
181
+ @response_signature = Errors.header_value(headers, 'response-signature')
182
+ @response_timestamp = Errors.header_value(headers, 'response-timestamp')
183
+ @raw = hash
184
+ end
185
+
186
+ def self.from(hash, headers = {})
187
+ new(hash, headers)
188
+ end
189
+ end
190
+
191
+ # Result of an Enhanced KYC verification: the body of
192
+ # POST /v3/enhanced_kyc/sync, which is the payload the async callback
193
+ # would have delivered. `status` is `clear`, `block`, `attention` or
194
+ # `error`. The spec documents only the fields every callback shares, so
195
+ # those are read here; anything else the ID authority returned is in
196
+ # `raw`. `job_id` and `user_id` come from the SmileID-Job-ID and User-ID
197
+ # headers, or from the body when a header is absent or blank.
198
+ # `response_signature` and `response_timestamp` are the
199
+ # Response-Signature and Response-Timestamp headers, or nil.
200
+ class EnhancedKycResult
201
+ attr_reader :status, :message, :reason, :created_at, :completed_at, :product,
202
+ :partner_params, :user_provided_info, :consent, :antifraud,
203
+ :device_signals, :kyc_receipt,
204
+ :job_id, :user_id, :response_signature, :response_timestamp, :raw
205
+
206
+ def initialize(hash, headers = {})
207
+ @status = hash['status']
208
+ @message = hash['message']
209
+ @reason = hash['reason']
210
+ @created_at = hash['created_at']
211
+ @completed_at = hash['completed_at']
212
+ @product = hash['product']
213
+ @partner_params = hash['partner_params']
214
+ @user_provided_info = hash['user_provided_info']
215
+ @consent = hash['consent']
216
+ @antifraud = hash['antifraud']
217
+ @device_signals = hash['device_signals']
218
+ @kyc_receipt = hash['kyc_receipt']
219
+ @job_id = Errors.job_id_from(headers) || hash['job_id']
220
+ @user_id = header_text(headers, 'user-id') || hash['user_id']
221
+ @response_signature = Errors.header_value(headers, 'response-signature')
222
+ @response_timestamp = Errors.header_value(headers, 'response-timestamp')
223
+ @raw = hash
224
+ end
225
+
226
+ def self.from(hash, headers = {})
227
+ new(hash, headers)
228
+ end
229
+
230
+ private
231
+
232
+ # A response header's value with surrounding whitespace removed, or
233
+ # nil when it is absent or blank.
234
+ def header_text(headers, name)
235
+ value = Errors.header_value(headers, name).to_s.strip
236
+ value.empty? ? nil : value
237
+ end
238
+ end
239
+
240
+ # One article in an AML Monitoring news response.
241
+ class AmlMonitoringNewsItem
242
+ attr_reader :body, :published_date, :publisher, :publisher_country_code,
243
+ :title, :url, :raw
244
+
245
+ def initialize(hash)
246
+ @body = hash['body']
247
+ @published_date = hash['published_date']
248
+ @publisher = hash['publisher']
249
+ @publisher_country_code = hash['publisher_country_code']
250
+ @title = hash['title']
251
+ @url = hash['url']
252
+ @raw = hash
253
+ end
254
+
255
+ def self.from(hash)
256
+ new(hash)
257
+ end
258
+ end
259
+
260
+ # Response from GET /v3/aml/monitoring/{job_id}/news/{reference}. `meta`
261
+ # is a plain hash with string keys (`current_page`, `limit`,
262
+ # `total_count`); `news` holds AmlMonitoringNewsItem objects.
263
+ class AmlMonitoringNewsResponse
264
+ attr_reader :job_id, :product, :user_id, :meta, :news, :raw
265
+
266
+ def initialize(hash)
267
+ @job_id = hash['job_id']
268
+ @product = hash['product']
269
+ @user_id = hash['user_id']
270
+ @meta = hash['meta']
271
+ @news = (hash['news'] || []).map { |item| AmlMonitoringNewsItem.from(item) }
272
+ @raw = hash
273
+ end
274
+
275
+ def self.from(hash)
276
+ new(hash)
277
+ end
278
+ end
279
+
110
280
  # Service responses (spec section 5.2). Nested collections are exposed as
111
281
  # plain hashes with string keys, exactly as they arrive on the wire.
112
282
  class BankCodesResponse
@@ -14,6 +14,7 @@ module SmileID
14
14
  :body_kind, # :multipart / :json / nil
15
15
  :idempotent, # safe to auto-retry? (GETs + token only)
16
16
  :success_statuses, # statuses treated as success (not raised)
17
+ :product, # x-smile-token-product: the token's product claim, nil for none
17
18
  keyword_init: true
18
19
  )
19
20
 
@@ -21,42 +22,92 @@ module SmileID
21
22
  enhanced_kyc: Operation.new(
22
23
  http_method: :post, path: '/v3/enhanced_kyc', authenticated: true,
23
24
  partner_id_header: false, body_kind: :multipart, idempotent: false,
24
- success_statuses: [202]
25
+ success_statuses: [202],
26
+ product: 'enhanced_kyc'
27
+ ),
28
+ enhanced_kyc_sync: Operation.new(
29
+ http_method: :post, path: '/v3/enhanced_kyc/sync', authenticated: true,
30
+ partner_id_header: false, body_kind: :multipart, idempotent: false,
31
+ success_statuses: [200],
32
+ product: 'enhanced_kyc'
33
+ ),
34
+ basic_kyc: Operation.new(
35
+ http_method: :post, path: '/v3/basic_kyc', authenticated: true,
36
+ partner_id_header: false, body_kind: :multipart, idempotent: false,
37
+ success_statuses: [202],
38
+ product: 'basic_kyc'
39
+ ),
40
+ basic_kyc_sync: Operation.new(
41
+ http_method: :post, path: '/v3/basic_kyc/sync', authenticated: true,
42
+ partner_id_header: false, body_kind: :multipart, idempotent: false,
43
+ success_statuses: [200],
44
+ product: 'basic_kyc'
25
45
  ),
26
46
  document_verification: Operation.new(
27
47
  http_method: :post, path: '/v3/document_verification', authenticated: true,
28
48
  partner_id_header: true, body_kind: :multipart, idempotent: false,
29
- success_statuses: [202]
49
+ success_statuses: [202],
50
+ product: 'document_verification'
30
51
  ),
31
52
  enhanced_document_verification: Operation.new(
32
53
  http_method: :post, path: '/v3/enhanced_document_verification', authenticated: true,
33
54
  partner_id_header: true, body_kind: :multipart, idempotent: false,
34
- success_statuses: [202]
55
+ success_statuses: [202],
56
+ product: 'enhanced_document_verification'
35
57
  ),
36
58
  residency_document_verification: Operation.new(
37
59
  http_method: :post, path: '/v3/residency_document_verification', authenticated: true,
38
60
  partner_id_header: true, body_kind: :multipart, idempotent: false,
39
- success_statuses: [202]
61
+ success_statuses: [202],
62
+ product: 'residency_document_verification'
40
63
  ),
41
64
  biometric_kyc: Operation.new(
42
65
  http_method: :post, path: '/v3/biometric_kyc', authenticated: true,
43
66
  partner_id_header: true, body_kind: :multipart, idempotent: false,
44
- success_statuses: [202]
67
+ success_statuses: [202],
68
+ product: 'biometric_kyc'
45
69
  ),
46
70
  registration: Operation.new(
47
71
  http_method: :post, path: '/v3/registration', authenticated: true,
48
72
  partner_id_header: false, body_kind: :multipart, idempotent: false,
49
- success_statuses: [202]
73
+ success_statuses: [202],
74
+ product: 'smart_selfie_registration'
50
75
  ),
51
76
  authentication: Operation.new(
52
77
  http_method: :post, path: '/v3/authentication', authenticated: true,
53
78
  partner_id_header: false, body_kind: :multipart, idempotent: false,
54
- success_statuses: [202]
79
+ success_statuses: [202],
80
+ product: 'smart_selfie_authentication'
55
81
  ),
56
82
  compare: Operation.new(
57
83
  http_method: :post, path: '/v3/compare', authenticated: true,
58
84
  partner_id_header: false, body_kind: :multipart, idempotent: false,
59
- success_statuses: [202]
85
+ success_statuses: [202],
86
+ product: 'smart_selfie_compare'
87
+ ),
88
+ one_time_aml: Operation.new(
89
+ http_method: :post, path: '/v3/aml', authenticated: true,
90
+ partner_id_header: false, body_kind: :multipart, idempotent: false,
91
+ success_statuses: [202],
92
+ product: 'one_time_aml'
93
+ ),
94
+ one_time_aml_sync: Operation.new(
95
+ http_method: :post, path: '/v3/aml/sync', authenticated: true,
96
+ partner_id_header: false, body_kind: :multipart, idempotent: false,
97
+ success_statuses: [200],
98
+ product: 'one_time_aml'
99
+ ),
100
+ aml_monitoring: Operation.new(
101
+ http_method: :post, path: '/v3/aml/monitoring', authenticated: true,
102
+ partner_id_header: false, body_kind: :multipart, idempotent: false,
103
+ success_statuses: [202],
104
+ product: 'aml'
105
+ ),
106
+ aml_monitoring_news: Operation.new(
107
+ http_method: :get, path: '/v3/aml/monitoring/{job_id}/news/{reference}',
108
+ authenticated: true, partner_id_header: false, body_kind: nil, idempotent: true,
109
+ success_statuses: [200],
110
+ product: 'aml'
60
111
  ),
61
112
  status: Operation.new(
62
113
  http_method: :get, path: '/v3/status/{job_id}', authenticated: true,
@@ -19,7 +19,7 @@ module SmileID
19
19
  # item 4, the OpenAPI-Generator bug to avoid).
20
20
  module Multipart
21
21
  # Fields serialized as JSON parts.
22
- JSON_PART_FIELDS = %w[consent user_details partner_params metadata].freeze
22
+ JSON_PART_FIELDS = %w[consent user_details partner_params metadata countries aliases].freeze
23
23
  # Single binary fields.
24
24
  BINARY_FIELDS = %w[selfie_image document document_back visa comparison_image].freeze
25
25
  # Repeated binary fields.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SmileID
4
- VERSION = '13.0.0'
4
+ VERSION = '13.2.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: usesmileid
3
3
  version: !ruby/object:Gem::Version
4
- version: 13.0.0
4
+ version: 13.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Smile Identity
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-11-10 00:00:00.000000000 Z
11
+ date: 2026-11-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -82,7 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
82
82
  - !ruby/object:Gem::Version
83
83
  version: '0'
84
84
  requirements: []
85
- rubygems_version: 3.4.10
85
+ rubygems_version: 3.4.19
86
86
  signing_key:
87
87
  specification_version: 4
88
88
  summary: Official Smile ID server-side SDK for Ruby.