@socure-inc/docv-react-native 5.2.7 → 5.2.8
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.
- package/README.md +259 -72
- package/android/build.gradle +9 -2
- package/android/src/main/java/com/socure/docv/reactnative/SocureDocVReactNativeModule.kt +147 -77
- package/android/src/main/java/com/socure/docv/reactnative/SocureDocVReactNativePackage.kt +21 -7
- package/android/src/oldarch/com/socure/docv/reactnative/NativeSocureDocVReactNativeSpec.kt +17 -0
- package/ios/SocureDocVReactNative-Bridging-Header.h +1 -0
- package/ios/SocureDocVReactNative.mm +68 -0
- package/ios/SocureDocVReactNative.swift +95 -61
- package/lib/commonjs/NativeSocureDocVReactNative.js +9 -0
- package/lib/commonjs/NativeSocureDocVReactNative.js.map +1 -0
- package/lib/commonjs/index.js +20 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/NativeSocureDocVReactNative.js +3 -0
- package/lib/module/NativeSocureDocVReactNative.js.map +1 -0
- package/lib/module/index.js +18 -1
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/NativeSocureDocVReactNative.d.ts +9 -0
- package/lib/typescript/index.d.ts +4 -0
- package/package.json +13 -4
- package/socure-docv-react-native.podspec +2 -3
- package/src/NativeSocureDocVReactNative.ts +16 -0
- package/src/index.ts +34 -4
- package/ios/SocureDocVReactNative.m +0 -10
package/README.md
CHANGED
|
@@ -7,15 +7,45 @@ The Predictive Document Verification (DocV) SDK for React Native is a React Nati
|
|
|
7
7
|
## Table of Contents
|
|
8
8
|
|
|
9
9
|
1. [Getting Started](#getting-started)
|
|
10
|
-
2. [
|
|
11
|
-
3. [Step
|
|
12
|
-
4. [Step
|
|
13
|
-
5. [Step
|
|
14
|
-
6. [Step
|
|
15
|
-
7. [Step
|
|
16
|
-
8. [Step
|
|
10
|
+
2. [React Native New Architecture Support](#react-native-new-architecture-support)
|
|
11
|
+
3. [Step 1: Install the React Native Wrapper](#step-1-install-the-react-native-wrapper)
|
|
12
|
+
4. [Step 2: Configure Your iOS or Android App](#step-2-configure-your-ios-or-android-app)
|
|
13
|
+
5. [Step 3: Run the App](#step-3-run-the-app)
|
|
14
|
+
6. [Step 4: Generate a Transaction Token and Configure the Capture App](#step-4-generate-a-transaction-token-and-configure-the-capture-app)
|
|
15
|
+
7. [Step 5: Import and Launch the SDK](#step-5-import-and-launch-the-sdk)
|
|
16
|
+
8. [Step 6: Handle Response Callbacks](#step-6-handle-response-callbacks)
|
|
17
|
+
9. [Step 7: Fetch the Verification Results](#step-7-fetch-the-verification-results)
|
|
17
18
|
|
|
18
19
|
|
|
20
|
+
## React Native New Architecture Support
|
|
21
|
+
|
|
22
|
+
Starting with this version 5.2.8, the wrapper fully supports the **React Native New Architecture** (TurboModules / Fabric) introduced in React Native 0.79+. Both Old Architecture and New Architecture builds are supported from the same package with no configuration changes required.
|
|
23
|
+
|
|
24
|
+
### What changed
|
|
25
|
+
|
|
26
|
+
| Area | Old Architecture | New Architecture |
|
|
27
|
+
|---|---|---|
|
|
28
|
+
| Module system | `NativeModules` bridge | TurboModule (JSI, CodeGen spec) |
|
|
29
|
+
| iOS bridge file | `.m` (ObjC extern) | `.mm` (conditional `#ifdef RCT_NEW_ARCH_ENABLED`) |
|
|
30
|
+
| Android package | `ReactPackage` | `BaseReactPackage` with `ReactModuleInfoProvider` |
|
|
31
|
+
| Peer dependencies | React ≥ 16.13.1, RN ≥ 0.66 | React ≥ 19.0.0, RN ≥ 0.79.0 |
|
|
32
|
+
|
|
33
|
+
### New Promise-based API
|
|
34
|
+
|
|
35
|
+
In addition to the existing callback-based `launchSocureDocV`, a new **Promise-based API** `launchSocureDocVWithPromise` is now available. This is the recommended API for New Architecture apps and any new integrations.
|
|
36
|
+
|
|
37
|
+
```jsx
|
|
38
|
+
import { launchSocureDocVWithPromise } from "@socure-inc/docv-react-native";
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Under the New Architecture, `launchSocureDocV` also continues to work — it internally bridges callbacks over the TurboModule promise API when the legacy callback method is not available, so **existing integrations require no code changes**.
|
|
42
|
+
|
|
43
|
+
### Enhanced error object
|
|
44
|
+
|
|
45
|
+
The `onError` callback now includes a machine-readable `code` field alongside the existing `error` message string. See the [updated error reference](#onerror-response) for all codes.
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
19
49
|
## Getting started
|
|
20
50
|
|
|
21
51
|
Before you begin, ensure you have the following:
|
|
@@ -27,6 +57,8 @@ Before you begin, ensure you have the following:
|
|
|
27
57
|
**React Native**
|
|
28
58
|
|
|
29
59
|
- React Native CLI. See the [React Native docs](https://reactnative.dev/docs/environment-setup) for instructions on how to set up your development environment.
|
|
60
|
+
- React Native **0.79.0** or later (required for New Architecture / TurboModule support)
|
|
61
|
+
- React **19.0.0** or later
|
|
30
62
|
|
|
31
63
|
**iOS**
|
|
32
64
|
|
|
@@ -36,6 +68,7 @@ Before you begin, ensure you have the following:
|
|
|
36
68
|
**Android**
|
|
37
69
|
|
|
38
70
|
- `compileSdkVersion: 36`
|
|
71
|
+
- `minSdkVersion: 23`
|
|
39
72
|
- `Java: 17`
|
|
40
73
|
|
|
41
74
|
## Step 1: Install the React Native wrapper
|
|
@@ -73,43 +106,117 @@ pod 'socure-docv-react-native', :path => '../node_modules/@socure-inc/docv-react
|
|
|
73
106
|
Once completed, your `Podfile` should look like the following example:
|
|
74
107
|
|
|
75
108
|
```swift {4,36}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
109
|
+
# Resolve react_native_pods.rb with node to allow for hoisting
|
|
110
|
+
require Pod::Executable.execute_command('node', ['-p',
|
|
111
|
+
'require.resolve(
|
|
112
|
+
"react-native/scripts/react_native_pods.rb",
|
|
113
|
+
{paths: [process.argv[1]]},
|
|
114
|
+
)', __dir__]).strip
|
|
115
|
+
|
|
116
|
+
platform :ios, min_ios_version_supported
|
|
117
|
+
prepare_react_native_project!
|
|
118
|
+
|
|
119
|
+
linkage = ENV['USE_FRAMEWORKS']
|
|
120
|
+
if linkage != nil
|
|
121
|
+
Pod::UI.puts "Configuring Pod with #{linkage}ally linked Frameworks".green
|
|
122
|
+
use_frameworks! :linkage => linkage.to_sym
|
|
123
|
+
end
|
|
83
124
|
|
|
84
|
-
target '
|
|
125
|
+
target 'DocVReactNativeSample' do
|
|
85
126
|
config = use_native_modules!
|
|
86
127
|
|
|
87
|
-
# Flags change depending on the env values.
|
|
88
|
-
flags = get_default_flags()
|
|
89
|
-
|
|
90
128
|
use_react_native!(
|
|
91
129
|
:path => config[:reactNativePath],
|
|
92
|
-
# to enable hermes on iOS, change `false` to `true` and then install pods
|
|
93
|
-
:production => production,
|
|
94
|
-
:hermes_enabled => flags[:hermes_enabled],
|
|
95
|
-
:fabric_enabled => flags[:fabric_enabled],
|
|
96
|
-
:flipper_configuration => FlipperConfiguration.enabled,
|
|
97
130
|
# An absolute path to your application root.
|
|
98
131
|
:app_path => "#{Pod::Config.instance.installation_root}/.."
|
|
99
132
|
)
|
|
100
133
|
|
|
101
|
-
target 'SocureDocVDemoTests' do
|
|
102
|
-
inherit! :complete
|
|
103
|
-
# Pods for testing
|
|
104
|
-
end
|
|
105
|
-
|
|
106
134
|
post_install do |installer|
|
|
107
|
-
|
|
108
|
-
|
|
135
|
+
# https://github.com/facebook/react-native/blob/main/packages/react-native/scripts/react_native_pods.rb#L197-L202
|
|
136
|
+
react_native_post_install(
|
|
137
|
+
installer,
|
|
138
|
+
config[:reactNativePath],
|
|
139
|
+
:mac_catalyst_enabled => false,
|
|
140
|
+
# :ccache_enabled => true
|
|
141
|
+
)
|
|
142
|
+
|
|
143
|
+
# fmt fails under Xcode 26 Clang (consteval FMT_STRING). base.h redefines
|
|
144
|
+
# FMT_USE_CONSTEVAL unconditionally, so patch it to honor an external value,
|
|
145
|
+
# then force it off below. Toolchain workaround; idempotent.
|
|
146
|
+
fmt_base = File.join(installer.sandbox.root, 'fmt', 'include', 'fmt', 'base.h')
|
|
147
|
+
if File.exist?(fmt_base)
|
|
148
|
+
src = File.read(fmt_base)
|
|
149
|
+
# Turn the chain's opening `#if` into an `#elif` behind our own branch.
|
|
150
|
+
original_open = "#if !defined(__cpp_lib_is_constant_evaluated)\n# define FMT_USE_CONSTEVAL 0\n"
|
|
151
|
+
patched_open = "#if defined(FMT_USE_CONSTEVAL)\n// honor externally-provided value\n" \
|
|
152
|
+
"#elif !defined(__cpp_lib_is_constant_evaluated)\n# define FMT_USE_CONSTEVAL 0\n"
|
|
153
|
+
if src.include?(original_open)
|
|
154
|
+
src = src.sub(original_open, patched_open)
|
|
155
|
+
File.chmod(0644, fmt_base) # pod headers are read-only
|
|
156
|
+
File.write(fmt_base, src)
|
|
157
|
+
Pod::UI.puts "[fmt] Patched base.h to honor pre-set FMT_USE_CONSTEVAL".green
|
|
158
|
+
end
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
# socure-docv-react-native (Swift + Obj-C++ static module) build fixes for
|
|
162
|
+
# Xcode 26 / new arch. Patch the copied pod sources; idempotent.
|
|
163
|
+
socure_ios = File.expand_path('../node_modules/@socure-inc/docv-react-native/ios', __dir__)
|
|
164
|
+
|
|
165
|
+
# Fix 1: drop the non-modular C++ import from the bridging header — it breaks
|
|
166
|
+
# Clang module scanning ("could not build module 'socure_docv_react_native'").
|
|
167
|
+
bridging = File.join(socure_ios, 'SocureDocVReactNative-Bridging-Header.h')
|
|
168
|
+
if File.exist?(bridging)
|
|
169
|
+
original = File.read(bridging)
|
|
170
|
+
patched = original.gsub(/^#import <ReactCommon\/RCTTurboModule\.h>\r?\n/, '')
|
|
171
|
+
if patched != original
|
|
172
|
+
File.chmod(0644, bridging)
|
|
173
|
+
File.write(bridging, patched)
|
|
174
|
+
Pod::UI.puts "[socure-docv] Removed non-modular C++ import from bridging header".green
|
|
175
|
+
end
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
# Fix 2: promote SocureDocVHelper + its @objc methods to public, else the .mm
|
|
179
|
+
# can't see them ("use of undeclared identifier 'SocureDocVHelper'").
|
|
180
|
+
swift = File.join(socure_ios, 'SocureDocVReactNative.swift')
|
|
181
|
+
if File.exist?(swift)
|
|
182
|
+
original = File.read(swift)
|
|
183
|
+
patched = original
|
|
184
|
+
.gsub(/^class SocureDocVHelper\b/, 'public class SocureDocVHelper')
|
|
185
|
+
.gsub(/^(\s*)@objc static func launch\b/, '\1@objc public static func launch')
|
|
186
|
+
if patched != original
|
|
187
|
+
File.chmod(0644, swift)
|
|
188
|
+
File.write(swift, patched)
|
|
189
|
+
Pod::UI.puts "[socure-docv] Promoted SocureDocVHelper to public for Obj-C interop".green
|
|
190
|
+
end
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
# Fix 3: provide the module-named header swiftc self-imports; CocoaPods only
|
|
194
|
+
# makes the dashed `...-umbrella.h`, so point a shim at it.
|
|
195
|
+
public_headers = File.join(installer.sandbox.root, 'Headers', 'Public', 'socure_docv_react_native')
|
|
196
|
+
if Dir.exist?(public_headers)
|
|
197
|
+
shim = File.join(public_headers, 'socure_docv_react_native.h')
|
|
198
|
+
shim_body = "#import \"socure-docv-react-native-umbrella.h\"\n"
|
|
199
|
+
if !File.exist?(shim) || File.read(shim) != shim_body
|
|
200
|
+
File.write(shim, shim_body)
|
|
201
|
+
Pod::UI.puts "[socure-docv] Added module-named umbrella shim header".green
|
|
202
|
+
end
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
installer.pods_project.targets.each do |t|
|
|
206
|
+
if ['fmt', 'glog'].include?(t.name)
|
|
207
|
+
t.build_configurations.each do |c|
|
|
208
|
+
defs = c.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] || ['$(inherited)']
|
|
209
|
+
defs = [defs] unless defs.is_a?(Array)
|
|
210
|
+
defs.delete('FMT_USE_NONTYPE_TEMPLATE_ARGS=0')
|
|
211
|
+
defs.delete('FMT_CONSTEVAL=')
|
|
212
|
+
defs << 'FMT_USE_CONSTEVAL=0' unless defs.include?('FMT_USE_CONSTEVAL=0')
|
|
213
|
+
c.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] = defs
|
|
214
|
+
end
|
|
215
|
+
end
|
|
216
|
+
end
|
|
109
217
|
end
|
|
110
218
|
|
|
111
|
-
pod 'socure-docv-react-native', :path => '../node_modules/@socure-inc/docv-react-native'
|
|
112
|
-
|
|
219
|
+
pod 'socure-docv-react-native', :path => '../node_modules/@socure-inc/docv-react-native'
|
|
113
220
|
end
|
|
114
221
|
```
|
|
115
222
|
|
|
@@ -154,7 +261,7 @@ The DocV iOS SDK requires a device's camera permission to capture identity docum
|
|
|
154
261
|
|
|
155
262
|
<br />
|
|
156
263
|
|
|
157
|
-
For the Android app, add your project dependencies by going to the module level `build.gradle` file and making sure the `minSdkVersion` is set to at least 23 and the `compileSdkVersion` is set to at least
|
|
264
|
+
For the Android app, add your project dependencies by going to the module level `build.gradle` file and making sure the `minSdkVersion` is set to at least 23 and the `compileSdkVersion` is set to at least 36.
|
|
158
265
|
|
|
159
266
|
```gradle
|
|
160
267
|
buildscript {
|
|
@@ -258,71 +365,151 @@ curl --location 'https://service.socure.com/api/5.0/documents/request' \
|
|
|
258
365
|
|
|
259
366
|
## Step 5: Import and launch the SDK
|
|
260
367
|
|
|
261
|
-
|
|
368
|
+
The wrapper exposes two APIs. Use **`launchSocureDocVWithPromise`** for new integrations and any app running React Native 0.79+. Use **`launchSocureDocV`** if your codebase already uses callbacks or you need to support older React Native versions.
|
|
369
|
+
|
|
370
|
+
### Option A: Promise-based API (recommended)
|
|
371
|
+
|
|
372
|
+
The Promise-based API is the recommended approach for New Architecture apps. It uses `async/await` and standard JavaScript error handling.
|
|
373
|
+
|
|
374
|
+
1. Import `launchSocureDocVWithPromise`:
|
|
375
|
+
|
|
376
|
+
```jsx
|
|
377
|
+
import { launchSocureDocVWithPromise } from "@socure-inc/docv-react-native";
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
2. Call `launchSocureDocVWithPromise` inside an `async` function:
|
|
381
|
+
|
|
382
|
+
```jsx
|
|
383
|
+
try {
|
|
384
|
+
const result = await launchSocureDocVWithPromise(
|
|
385
|
+
"docVTransactionToken",
|
|
386
|
+
"SOCURE_SDK_KEY",
|
|
387
|
+
false // useSocureGov
|
|
388
|
+
);
|
|
389
|
+
console.log("Success:", result.deviceSessionToken);
|
|
390
|
+
} catch (error) {
|
|
391
|
+
console.log("Error code:", error.code);
|
|
392
|
+
console.log("Error message:", error.message);
|
|
393
|
+
}
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
#### `launchSocureDocVWithPromise` Parameters
|
|
397
|
+
|
|
398
|
+
| Parameter | Type | Description |
|
|
399
|
+
|---|---|---|
|
|
400
|
+
| `docVTransactionToken` | String | The transaction token from the [`/documents/request`](https://developer.socure.com/reference#tag/Predictive-Document-Verification) API response. Required to initiate the document verification session. |
|
|
401
|
+
| `publicKey` | String | The unique SDK key from [Admin Dashboard](https://developer.socure.com/docs/admin-dashboard/developers/sdk-keys) used to authenticate the SDK. |
|
|
402
|
+
| `useSocureGov` | Boolean | Set to `true` to use the GovCloud environment. Defaults to `false`. Applicable only to customers provisioned in the SocureGov environment. |
|
|
403
|
+
|
|
404
|
+
**Returns:** `Promise<DocVResult>` — resolves with `{ deviceSessionToken: string }` on success, or rejects with an error object containing `code` and `message` on failure.
|
|
405
|
+
|
|
406
|
+
---
|
|
407
|
+
|
|
408
|
+
### Option B: Callback-based API (legacy)
|
|
409
|
+
|
|
410
|
+
The callback-based API is preserved for backward compatibility. Existing integrations do not require any code changes.
|
|
411
|
+
|
|
412
|
+
1. Import `launchSocureDocV`:
|
|
262
413
|
|
|
263
414
|
```jsx
|
|
264
|
-
import { launchSocureDocV } from "@socure-inc/docv-react-native"
|
|
415
|
+
import { launchSocureDocV } from "@socure-inc/docv-react-native";
|
|
265
416
|
```
|
|
266
417
|
|
|
267
418
|
2. Call `launchSocureDocV` to initiate the Socure DocV SDK:
|
|
268
419
|
|
|
269
420
|
```jsx
|
|
270
|
-
launchSocureDocV(
|
|
421
|
+
launchSocureDocV(
|
|
422
|
+
"docVTransactionToken",
|
|
423
|
+
"SOCURE_SDK_KEY",
|
|
424
|
+
false, // useSocureGov
|
|
425
|
+
onSuccess,
|
|
426
|
+
onError
|
|
427
|
+
);
|
|
271
428
|
```
|
|
272
429
|
|
|
273
|
-
|
|
430
|
+
#### `launchSocureDocV` Parameters
|
|
274
431
|
|
|
275
|
-
|
|
432
|
+
| Parameter | Type | Description |
|
|
433
|
+
|---|---|---|
|
|
434
|
+
| `docVTransactionToken` | String | The transaction token from the [`/documents/request`](https://developer.socure.com/reference#tag/Predictive-Document-Verification) API response. Required to initiate the document verification session. |
|
|
435
|
+
| `publicKey` | String | The unique SDK key from [Admin Dashboard](https://developer.socure.com/docs/admin-dashboard/developers/sdk-keys) used to authenticate the SDK. |
|
|
436
|
+
| `useSocureGov` | Boolean | Set to `true` to use the GovCloud environment. Defaults to `false`. Applicable only to customers provisioned in the SocureGov environment. |
|
|
437
|
+
| `onSuccess` | Function | A callback function invoked when the flow completes successfully. |
|
|
438
|
+
| `onError` | Function | A callback function invoked when the flow fails. |
|
|
276
439
|
|
|
277
|
-
|
|
278
|
-
|--------------------------|------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
279
|
-
| `SOCURE_SDK_KEY` | String | The unique SDK key obtained from [Admin Dashboard](https://developer.socure.com/docs/admin-dashboard/developers/sdk-keys) used to authenticate the SDK. |
|
|
280
|
-
| `DocV_Transaction_Token` | String | The transaction token retrieved from the API response of the [`/documents/request`](https://developer.socure.com/reference#tag/Predictive-Document-Verification) endpoint. Required to initiate the document verification session. |
|
|
281
|
-
| `useSocureGov` | Bool | A Boolean flag indicating whether to use the GovCloud environment. It defaults to `false`. This is only applicable for customers provisioned in the SocureGov environment. |
|
|
282
|
-
| `onSuccess` | Function | A callback function invoked when the flow completes successfully. |
|
|
283
|
-
| `onError` | Function | A callback function invoked when the flow fails. |
|
|
440
|
+
> **New Architecture note:** Under React Native New Architecture, `launchSocureDocV` automatically routes through the TurboModule promise API and bridges the result back to your `onSuccess` / `onError` callbacks. No code changes are required.
|
|
284
441
|
|
|
285
442
|
## Step 6: Handle response callbacks
|
|
286
443
|
|
|
287
|
-
|
|
444
|
+
### Success response
|
|
288
445
|
|
|
289
|
-
|
|
446
|
+
When the consumer successfully completes the verification flow and the captured images are uploaded to Socure's servers, the SDK returns a `DocVResult` object containing a device session token.
|
|
290
447
|
|
|
291
|
-
|
|
448
|
+
**Promise API** — the `Promise` resolves with:
|
|
292
449
|
|
|
293
|
-
```javascript
|
|
294
|
-
{
|
|
295
|
-
deviceSessionToken: 'eyJraWQiOiJmMzRiN2YiLCJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9
|
|
450
|
+
```javascript
|
|
451
|
+
{
|
|
452
|
+
deviceSessionToken: 'eyJraWQiOiJmMzRiN2YiLCJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9...'
|
|
296
453
|
}
|
|
297
454
|
```
|
|
298
455
|
|
|
456
|
+
**Callback API** — the `onSuccess` callback receives the same object:
|
|
457
|
+
|
|
458
|
+
```javascript
|
|
459
|
+
{
|
|
460
|
+
deviceSessionToken: 'eyJraWQiOiJmMzRiN2YiLCJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9...'
|
|
461
|
+
}
|
|
462
|
+
```
|
|
463
|
+
|
|
464
|
+
The `deviceSessionToken` can be used to access device risk details for the specific session.
|
|
465
|
+
|
|
299
466
|
### `onError` response
|
|
300
467
|
|
|
301
|
-
The `onError` callback is triggered when the DocV SDK encounters an error or when the consumer exits the flow without completing it.
|
|
468
|
+
The `onError` callback (and Promise rejection) is triggered when the DocV SDK encounters an error or when the consumer exits the flow without completing it.
|
|
302
469
|
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
470
|
+
**Promise API** — the `Promise` rejects with a JavaScript `Error`-like object. Access `error.code` and `error.message`:
|
|
471
|
+
|
|
472
|
+
```javascript
|
|
473
|
+
try {
|
|
474
|
+
const result = await launchSocureDocVWithPromise(token, key, false);
|
|
475
|
+
} catch (error) {
|
|
476
|
+
console.log(error.code); // e.g. "ERR_USER_CANCELED"
|
|
477
|
+
console.log(error.message); // e.g. "Scan canceled by the user"
|
|
478
|
+
}
|
|
479
|
+
```
|
|
480
|
+
|
|
481
|
+
**Callback API** — the `onError` callback receives an object with the following shape:
|
|
482
|
+
|
|
483
|
+
```javascript
|
|
484
|
+
{
|
|
485
|
+
code: 'ERR_USER_CANCELED',
|
|
486
|
+
error: 'Scan canceled by the user',
|
|
487
|
+
deviceSessionToken: 'eyJraWQiOiJmMzRiN2YiLCJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9...'
|
|
307
488
|
}
|
|
308
489
|
```
|
|
309
490
|
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
| `
|
|
317
|
-
|
|
318
|
-
| `
|
|
319
|
-
| `"
|
|
320
|
-
| `"
|
|
321
|
-
| `"
|
|
322
|
-
| `"
|
|
323
|
-
| `"
|
|
324
|
-
| `"
|
|
325
|
-
| `"
|
|
491
|
+
> **Migration note:** The `error` field (human-readable message string) is preserved from previous versions. The new `code` field (machine-readable constant) was added in this release to enable reliable programmatic error handling without string matching.
|
|
492
|
+
|
|
493
|
+
#### Error reference
|
|
494
|
+
|
|
495
|
+
The following errors may be returned by the Socure DocV SDK:
|
|
496
|
+
|
|
497
|
+
| `code` | `error` message | Description |
|
|
498
|
+
|---|---|---|
|
|
499
|
+
| `ERR_NO_INTERNET` | `"No internet connection"` | Device has no network connectivity. |
|
|
500
|
+
| `ERR_SESSION_INITIATION` | `"Failed to initiate the session"` | The SDK could not start a verification session with Socure servers. |
|
|
501
|
+
| `ERR_CAMERA_PERMISSION` | `"Permissions to open the camera declined by the user"` | The user denied camera access. |
|
|
502
|
+
| `ERR_CONSENT_DECLINED` | `"Consent declined by the user"` | The user declined the consent screen. |
|
|
503
|
+
| `ERR_UPLOAD_FAILURE` | `"Failed to upload the documents"` | Captured images could not be uploaded. |
|
|
504
|
+
| `ERR_INVALID_TOKEN` | `"Invalid transaction token"` | The `docVTransactionToken` is missing, malformed, or already used. |
|
|
505
|
+
| `ERR_INVALID_KEY` | `"Invalid or missing SDK key"` | The `publicKey` (SDK key) is invalid or was not provided. |
|
|
506
|
+
| `ERR_SESSION_EXPIRED` | `"Session expired"` | The verification session timed out before completion. |
|
|
507
|
+
| `ERR_USER_CANCELED` | `"Scan canceled by the user"` | The user dismissed the capture flow before completing it. |
|
|
508
|
+
| `ERR_NO_ACTIVITY` | `"App activity is null"` | Android only — the host `Activity` was not available when the SDK attempted to launch. |
|
|
509
|
+
| `ERR_NO_DATA` | `"No result data returned from SDK"` | Android only — the SDK activity returned without data. |
|
|
510
|
+
| `ERR_NO_VIEW_CONTROLLER` | `"Failed to get root view controller"` | iOS only — the root `UIViewController` could not be resolved. |
|
|
511
|
+
| `ERR_ALREADY_IN_PROGRESS` | `"A DocV session is already in progress"` | A previous call has not yet resolved. Wait for it to complete before launching again. |
|
|
512
|
+
| `ERR_UNKNOWN` | `"Unknown error"` | An unrecognized error occurred. |
|
|
326
513
|
|
|
327
514
|
|
|
328
515
|
|
package/android/build.gradle
CHANGED
|
@@ -15,7 +15,7 @@ buildscript {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
def isNewArchitectureEnabled() {
|
|
18
|
-
return rootProject.hasProperty("newArchEnabled") &&
|
|
18
|
+
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
apply plugin: 'com.android.library'
|
|
@@ -41,6 +41,7 @@ android {
|
|
|
41
41
|
defaultConfig {
|
|
42
42
|
minSdkVersion getExtOrIntegerDefault('minSdkVersion')
|
|
43
43
|
targetSdkVersion getExtOrIntegerDefault('targetSdkVersion')
|
|
44
|
+
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
|
|
44
45
|
}
|
|
45
46
|
buildTypes {
|
|
46
47
|
release {
|
|
@@ -57,6 +58,13 @@ android {
|
|
|
57
58
|
targetCompatibility JavaVersion.VERSION_17
|
|
58
59
|
}
|
|
59
60
|
|
|
61
|
+
sourceSets {
|
|
62
|
+
main {
|
|
63
|
+
if (!isNewArchitectureEnabled()) {
|
|
64
|
+
java.srcDirs += ['src/oldarch']
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
60
68
|
}
|
|
61
69
|
|
|
62
70
|
repositories {
|
|
@@ -147,7 +155,6 @@ dependencies {
|
|
|
147
155
|
|
|
148
156
|
def okhttp_version = "4.9.3"
|
|
149
157
|
implementation "com.squareup.okhttp3:logging-interceptor:$okhttp_version"
|
|
150
|
-
// From node_modules
|
|
151
158
|
}
|
|
152
159
|
|
|
153
160
|
if (isNewArchitectureEnabled()) {
|