@soyio/soyio-rn-sdk 2.3.1 → 3.1.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.
Files changed (137) hide show
  1. package/README.md +287 -132
  2. package/android/build.gradle +56 -0
  3. package/android/libs/facetec-sdk-9.7.96.aar +0 -0
  4. package/android/src/main/AndroidManifest.xml +8 -0
  5. package/android/src/main/java/com/soyio/soyiorndk/AndroidFacetecSdkModule.kt +224 -0
  6. package/android/src/main/java/com/soyio/soyiorndk/AndroidFacetecSdkPackage.kt +16 -0
  7. package/android/src/main/java/com/soyio/soyiorndk/ApiDate.kt +5 -0
  8. package/android/src/main/java/com/soyio/soyiorndk/BaseFaceTecProcessor.kt +44 -0
  9. package/android/src/main/java/com/soyio/soyiorndk/FaceTecRequestService.kt +115 -0
  10. package/android/src/main/java/com/soyio/soyiorndk/FacetecConfig.kt +308 -0
  11. package/android/src/main/java/com/soyio/soyiorndk/SoyioIdOnlyProcessor.kt +81 -0
  12. package/android/src/main/java/com/soyio/soyiorndk/SoyioValidationProcessor.kt +134 -0
  13. package/android/src/main/res/values/strings.xml +134 -0
  14. package/assets/adaptive-icon.png +0 -0
  15. package/assets/favicon.png +0 -0
  16. package/assets/fonts/RobotoFlex.ttf +0 -0
  17. package/assets/icon.png +0 -0
  18. package/assets/images/SoyioRnSdk.xcassets/facetec-close.imageset/Contents.json +23 -0
  19. package/assets/images/SoyioRnSdk.xcassets/facetec-close.imageset/facetec-close@1x.png +0 -0
  20. package/assets/images/SoyioRnSdk.xcassets/facetec-close.imageset/facetec-close@2x.png +0 -0
  21. package/assets/images/SoyioRnSdk.xcassets/facetec-close.imageset/facetec-close@3x.png +0 -0
  22. package/assets/images/SoyioRnSdk.xcassets/facetec-id-front.imageset/Contents.json +23 -0
  23. package/assets/images/SoyioRnSdk.xcassets/facetec-id-front.imageset/facetec-id-front@1x.png +0 -0
  24. package/assets/images/SoyioRnSdk.xcassets/facetec-id-front.imageset/facetec-id-front@2x.png +0 -0
  25. package/assets/images/SoyioRnSdk.xcassets/facetec-id-front.imageset/facetec-id-front@3x.png +0 -0
  26. package/assets/splash.png +0 -0
  27. package/index.ts +14 -3
  28. package/ios/ApiDate.swift +5 -0
  29. package/ios/FacetecConfig.swift +217 -0
  30. package/ios/FacetecStrings.swift +139 -0
  31. package/ios/Frameworks/FaceTecSDK.framework/Assets.car +0 -0
  32. package/ios/Frameworks/FaceTecSDK.framework/FaceTecSDK +0 -0
  33. package/ios/Frameworks/FaceTecSDK.framework/GenericGuidanceContentLayout.nib +0 -0
  34. package/ios/Frameworks/FaceTecSDK.framework/Headers/FaceTecPublicApi.h +1935 -0
  35. package/ios/Frameworks/FaceTecSDK.framework/Headers/FaceTecPublicStringKeys.h +109 -0
  36. package/ios/Frameworks/FaceTecSDK.framework/Headers/FaceTecSDK.h +16 -0
  37. package/ios/Frameworks/FaceTecSDK.framework/Info.plist +0 -0
  38. package/ios/Frameworks/FaceTecSDK.framework/Modules/module.modulemap +6 -0
  39. package/ios/Frameworks/FaceTecSDK.framework/PrivacyInfo.xcprivacy +29 -0
  40. package/ios/Frameworks/FaceTecSDK.framework/ReadyScreenGuidanceContentLayout.nib +0 -0
  41. package/ios/Frameworks/FaceTecSDK.framework/RetryScreenGuidanceContentLayout.nib +0 -0
  42. package/ios/Frameworks/FaceTecSDK.framework/SharedGuidanceLayout.nib +0 -0
  43. package/ios/Frameworks/FaceTecSDK.framework/Storyboard.storyboardc/9Uo-4b-JiE-view-Ae0-rb-UqS.nib +0 -0
  44. package/ios/Frameworks/FaceTecSDK.framework/Storyboard.storyboardc/CJ6-MX-bJp-view-8JL-Rc-0g1.nib +0 -0
  45. package/ios/Frameworks/FaceTecSDK.framework/Storyboard.storyboardc/FaceScanViewController.nib +0 -0
  46. package/ios/Frameworks/FaceTecSDK.framework/Storyboard.storyboardc/FaceTecAdditionalReviewViewController.nib +0 -0
  47. package/ios/Frameworks/FaceTecSDK.framework/Storyboard.storyboardc/FaceTecIDFeedbackViewController.nib +0 -0
  48. package/ios/Frameworks/FaceTecSDK.framework/Storyboard.storyboardc/FaceTecOCRConfirmationViewController.nib +0 -0
  49. package/ios/Frameworks/FaceTecSDK.framework/Storyboard.storyboardc/IDCaptureViewController.nib +0 -0
  50. package/ios/Frameworks/FaceTecSDK.framework/Storyboard.storyboardc/IDSelectionViewController.nib +0 -0
  51. package/ios/Frameworks/FaceTecSDK.framework/Storyboard.storyboardc/Info.plist +0 -0
  52. package/ios/Frameworks/FaceTecSDK.framework/Storyboard.storyboardc/Pyw-6G-JSY-view-Zue-Eo-Q2U.nib +0 -0
  53. package/ios/Frameworks/FaceTecSDK.framework/Storyboard.storyboardc/QWA-8Y-vUM-view-wJB-Z5-eD2.nib +0 -0
  54. package/ios/Frameworks/FaceTecSDK.framework/Storyboard.storyboardc/alz-Ia-X3d-view-IKu-EI-Hug.nib +0 -0
  55. package/ios/Frameworks/FaceTecSDK.framework/Storyboard.storyboardc/l2Q-cc-kD8-view-UUy-6c-meu.nib +0 -0
  56. package/ios/Frameworks/FaceTecSDK.framework/attributions.txt +462 -0
  57. package/ios/Frameworks/FaceTecSDK.framework/cache_uyertuazlkxcjrlwkejr/39bb748b334003e3fa/1f5b84f51ce0fcfbb76e904b7bcaa7560f601e1394a0b29367a09385312287eb +0 -0
  58. package/ios/Frameworks/FaceTecSDK.framework/cache_uyertuazlkxcjrlwkejr/39bb748b334003e3fa/2b075ac1a6132b5b8a4c9ef0ba6b0cd84db7838aca9a000e50d907f40770a4ab +0 -0
  59. package/ios/Frameworks/FaceTecSDK.framework/cache_uyertuazlkxcjrlwkejr/39bb748b334003e3fa/59cc2a9af81aaca2376702c2490650f4da2775fa673274db98aad41b7ef101c0 +0 -0
  60. package/ios/Frameworks/FaceTecSDK.framework/cache_uyertuazlkxcjrlwkejr/39bb748b334003e3fa/5b63e98b991aedabb60665503384f30bffd939decf9433883b30b78011ee501a +0 -0
  61. package/ios/Frameworks/FaceTecSDK.framework/cache_uyertuazlkxcjrlwkejr/39bb748b334003e3fa/66388dc76dc16bc6b76b682edd218a575bf45b9b +0 -0
  62. package/ios/Frameworks/FaceTecSDK.framework/cache_uyertuazlkxcjrlwkejr/39bb748b334003e3fa/6b3133f0f39ff89a2a169d61176ee17cafacc5e288f334e2b64ee82892d11ccd +0 -0
  63. package/ios/Frameworks/FaceTecSDK.framework/cache_uyertuazlkxcjrlwkejr/39bb748b334003e3fa/9077d16225f9314163ef1e7db6fc7d4088bb903d134bd95f23d5591ca4dfbfca +0 -0
  64. package/ios/Frameworks/FaceTecSDK.framework/cache_uyertuazlkxcjrlwkejr/39bb748b334003e3fa/a74f2afb9d20f2375ccbd14e67c094b85c89ceb608f7cf8ae04f3f646a6c5672 +0 -0
  65. package/ios/Frameworks/FaceTecSDK.framework/cache_uyertuazlkxcjrlwkejr/39bb748b334003e3fa/b501893e75f62ee1707643e35b21109927b07ed5b202321c961b424cbc2e4695 +0 -0
  66. package/ios/Frameworks/FaceTecSDK.framework/cache_uyertuazlkxcjrlwkejr/39bb748b334003e3fa/dbd7a353f0130bb983d6ba05917e9be991d70e8f028df4b74e30bc6497ef7f71 +0 -0
  67. package/ios/Frameworks/FaceTecSDK.framework/cache_uyertuazlkxcjrlwkejr/39bb748b334003e3fa/f2.xml +0 -0
  68. package/ios/Frameworks/FaceTecSDK.framework/cache_uyertuazlkxcjrlwkejr/39bb748b334003e3fa/fd6d368a5658496536e2bfae170d1b823a3629b242cafc09784bfba4e56d8c80 +0 -0
  69. package/ios/Frameworks/FaceTecSDK.framework/cache_uyertuazlkxcjrlwkejr/39bb748b334003e3fa/marker +0 -0
  70. package/ios/Frameworks/FaceTecSDK.framework/cache_uyertuazlkxcjrlwkejr/39bb748b334003e3fa/vu0ilin6we3lrzo5f83f7qs2jul4aq7v4aoynrmch8zfvpi8ezrfyafa4t0fx87l +0 -0
  71. package/ios/Frameworks/FaceTecSDK.framework/strip-unused-architectures-from-target.sh +62 -0
  72. package/ios/IOSFacetecSdk.m +22 -0
  73. package/ios/IOSFacetecSdk.swift +219 -0
  74. package/ios/ProcessorProtocol.swift +6 -0
  75. package/ios/SoyioIDOnlyProcessor.swift +168 -0
  76. package/ios/SoyioPhotoIDMatchProcessor.swift +262 -0
  77. package/package/index.d.ts +4 -2
  78. package/package/index.js +6 -3
  79. package/package/index.js.map +1 -0
  80. package/package/src/api/facetec.d.ts +3 -0
  81. package/package/src/api/facetec.js +109 -0
  82. package/package/src/api/facetec.js.map +1 -0
  83. package/package/src/bridges/facetec.d.ts +2 -0
  84. package/package/src/bridges/facetec.js +105 -0
  85. package/package/src/bridges/facetec.js.map +1 -0
  86. package/package/src/bridges/passkey.d.ts +17 -0
  87. package/package/src/bridges/passkey.js +103 -0
  88. package/package/src/bridges/passkey.js.map +1 -0
  89. package/package/src/constants.d.ts +3 -2
  90. package/package/src/constants.js +4 -3
  91. package/package/src/constants.js.map +1 -0
  92. package/package/src/core.d.ts +3 -5
  93. package/package/src/core.jsx +42 -111
  94. package/package/src/core.jsx.map +1 -0
  95. package/package/src/facetec-bridge.d.ts +10 -0
  96. package/package/src/facetec-bridge.js +125 -0
  97. package/package/src/facetec-bridge.js.map +1 -0
  98. package/package/src/inapp-browser.d.ts +21 -0
  99. package/package/src/inapp-browser.js +104 -0
  100. package/package/src/inapp-browser.js.map +1 -0
  101. package/package/src/passkey-bridge.d.ts +17 -0
  102. package/package/src/passkey-bridge.js +103 -0
  103. package/package/src/passkey-bridge.js.map +1 -0
  104. package/package/src/types.d.ts +27 -13
  105. package/package/src/types.js.map +1 -0
  106. package/package/src/utils/apiDate.d.ts +1 -0
  107. package/package/src/utils/apiDate.js +5 -0
  108. package/package/src/utils/apiDate.js.map +1 -0
  109. package/package/src/utils/color.d.ts +5 -0
  110. package/package/src/utils/color.js +35 -0
  111. package/package/src/utils/color.js.map +1 -0
  112. package/package/src/utils/date.d.ts +1 -0
  113. package/package/src/utils/date.js +6 -0
  114. package/package/src/utils/date.js.map +1 -0
  115. package/package/src/utils/index.d.ts +4 -0
  116. package/package/src/utils/index.js +12 -0
  117. package/package/src/utils/index.js.map +1 -0
  118. package/package/src/utils/message-handler.d.ts +3 -0
  119. package/package/src/utils/message-handler.js +76 -0
  120. package/package/src/utils/message-handler.js.map +1 -0
  121. package/package/src/utils/platform.d.ts +1 -0
  122. package/package/src/utils/platform.js +9 -0
  123. package/package/src/utils/platform.js.map +1 -0
  124. package/package/src/utils/type-guards.d.ts +4 -0
  125. package/package/src/utils/type-guards.js +15 -0
  126. package/package/src/utils/type-guards.js.map +1 -0
  127. package/package/src/utils/url-builder.d.ts +2 -0
  128. package/package/src/utils/url-builder.js +70 -0
  129. package/package/src/utils/url-builder.js.map +1 -0
  130. package/package/src/webview.d.ts +3 -0
  131. package/package/src/webview.jsx +65 -0
  132. package/package/src/webview.jsx.map +1 -0
  133. package/package.json +14 -12
  134. package/react-native.config.js +14 -0
  135. package/soyio_rn_sdk.podspec +49 -0
  136. package/package/src/utils.d.ts +0 -17
  137. package/package/src/utils.js +0 -157
package/README.md CHANGED
@@ -14,7 +14,7 @@
14
14
 
15
15
  ## Installation
16
16
 
17
- - Install using npm! (or your favorite package manager)
17
+ - Install using npm (or your favorite package manager)
18
18
 
19
19
  ```sh
20
20
  # Using npm
@@ -24,22 +24,147 @@ npm install @soyio/soyio-rn-sdk
24
24
  yarn add @soyio/soyio-rn-sdk
25
25
  ```
26
26
 
27
- - Add custom uri scheme to your project:
27
+ - You'll also need to install the required peer dependencies:
28
28
 
29
- ```bash
30
- npx uri-scheme add custom-uri-scheme
29
+ ```sh
30
+ # Using npm
31
+ npm install react-native-webview react-native-inappbrowser-reborn
32
+
33
+ # Using yarn
34
+ yarn add react-native-webview react-native-inappbrowser-reborn
35
+ ```
36
+
37
+ **iOS Setup:** Run `cd ios && pod install` to install native dependencies.
38
+
39
+ **Android Setup:** For React Native 0.60+, auto-linking should handle Android setup automatically. For older versions, follow the [manual linking guide](https://github.com/react-native-webview/react-native-webview/blob/master/docs/Getting-Started.md).
40
+
41
+ ## Android setup (repositories, permissions, deep links)
42
+
43
+ Add these to your app so bundled native dependencies and deep linking work when consuming the SDK from npm.
44
+
45
+ 1) Repositories (`android/settings.gradle`) - **Only required if you want to use NFC validation**
46
+
47
+ ```gradle
48
+ dependencyResolutionManagement {
49
+ repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)
50
+ repositories {
51
+ // Keep your normal repositories here (e.g., google(), mavenCentral()) as appropriate for your project/architecture.
52
+ // Add this flatDir so bundled native dependencies are resolvable:
53
+ flatDir {
54
+ dirs(
55
+ "$rootDir/../node_modules/@soyio/soyio-rn-sdk/android/libs",
56
+ )
57
+ }
58
+ }
59
+ }
60
+ ```
61
+
62
+ 2) Manifest entries (`android/app/src/main/AndroidManifest.xml` inside `<manifest>`)
63
+
64
+ ```xml
65
+ <uses-permission android:name="android.permission.INTERNET" />
66
+ <uses-permission android:name="android.permission.CAMERA" />
67
+ <uses-feature android:name="android.hardware.camera" android:required="true" />
68
+ ```
69
+
70
+ If you want to enable NFC validation with the `SoyioWidget`, also add:
71
+
72
+ ```xml
73
+ <uses-permission android:name="android.permission.NFC" />
74
+ <uses-feature android:name="android.hardware.nfc" android:required="false" />
75
+ ```
76
+
77
+ 3) Deep link for returning from the in-app browser: add an intent filter in your main `<activity>` with your chosen scheme (must match `uriScheme` passed to the SDK)
78
+
79
+ ```xml
80
+ <intent-filter>
81
+ <action android:name="android.intent.action.VIEW" />
82
+ <category android:name="android.intent.category.DEFAULT" />
83
+ <category android:name="android.intent.category.BROWSABLE" />
84
+ <data android:scheme="your-app-scheme" />
85
+ </intent-filter>
86
+ ```
87
+
88
+ After changes, rebuild the Android app (`cd android && ./gradlew :app:assembleDebug` or `yarn android`).
89
+
90
+ ## iOS Setup (permissions, NFC, deep links)
91
+
92
+ Add these to your app so native dependencies, NFC scanning, and deep linking work when consuming the SDK from npm.
93
+
94
+ ### 1. Native Dependencies
95
+
96
+ After installing the package and peer dependencies, run:
97
+
98
+ ```sh
99
+ cd ios && pod install
100
+ ```
101
+
102
+ ### 2. Permissions
103
+
104
+ Add the following permissions to your `ios/YourApp/Info.plist` file:
105
+
106
+ ```xml
107
+ <key>NSCameraUsageDescription</key>
108
+ <string>This app needs access to camera for document verification</string>
31
109
  ```
32
110
 
33
- Here, `custom-uri-scheme` is a unique scheme used for redirecting within Android applications, ensuring links open in the correct app without prompting the user to choose. It should be structured uniquely for your application. For example, for a company with name `Test`, a custom uri scheme could be `soyio-test` or simply `test`.
111
+ If you want to enable NFC validation with the `SoyioWidget`, also add:
34
112
 
35
- **IMPORTANT:**
36
- For developers integrating with a **bare React Native** application, it's crucial to prepare your project for Expo modules:
113
+ ```xml
114
+ <key>NFCReaderUsageDescription</key>
115
+ <string>This app needs access to NFC for identity document verification</string>
37
116
 
38
- `npx install-expo-modules`: This command installs Expo modules in your React Native project, allowing you to use Expo's powerful library of APIs and components without needing to eject from the Expo managed workflow.
117
+ <key>com.apple.developer.nfc.readersession.iso7816.select-identifiers</key>
118
+ <array>
119
+ <string>A0000002471001</string>
120
+ <string>A0000002472001</string>
121
+ </array>
122
+ ```
123
+
124
+ ### 3. NFC Entitlements
125
+
126
+ For NFC to work, you also need to create (or update) your entitlements file at `ios/YourApp/YourApp.entitlements`:
127
+
128
+ ```xml
129
+ <?xml version="1.0" encoding="UTF-8"?>
130
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
131
+ <plist version="1.0">
132
+ <dict>
133
+ <key>com.apple.developer.nfc.readersession.formats</key>
134
+ <array>
135
+ <string>TAG</string>
136
+ </array>
137
+ </dict>
138
+ </plist>
139
+ ```
140
+
141
+ Then, in Xcode, ensure the entitlements file is linked to your target:
142
+ 1. Select your project in Xcode
143
+ 2. Go to your app target's **Signing & Capabilities** tab
144
+ 3. Add **Near Field Communication Tag Reading** capability (if not already added)
145
+ 4. Verify the entitlements file path is set in **Build Settings → Code Signing Entitlements**
146
+
147
+
148
+ ## URI Scheme Setup
149
+
150
+ You need to configure a custom URI scheme for your application to handle deep linking properly:
151
+
152
+ ```sh
153
+ npx uri-scheme add custom-uri-scheme
154
+ ```
155
+
156
+ Replace `custom-uri-scheme` with your desired scheme name. This scheme should match the `uriScheme` parameter you use in the `SoyioWidget` options.
39
157
 
40
158
  ## Usage
41
159
 
42
- `Soyio React Native` exports a single hook called `useSoyioAuth`. This is a hook that opens a `WebBrowser` using the `openAuthSessionAsync` method by [expo](https://docs.expo.dev/versions/latest/sdk/webbrowser/#webbrowseropenauthsessionasyncurl-redirecturl-options).
160
+ `Soyio React Native` provides two ways to integrate the Soyio verification flow:
161
+
162
+ 1. **Component**: A `SoyioWidget` component that renders a WebView within your app.
163
+ 2. **InAppBrowser Functions**: Direct functions that open the verification flow in an in-app browser.
164
+
165
+ > ℹ️ **NFC validation** is only available when you integrate with the `SoyioWidget` component (WebView). The InAppBrowser mode does not support NFC.
166
+
167
+ ## Component Integration
43
168
 
44
169
  ### 1. Disclosure Request
45
170
 
@@ -57,40 +182,44 @@ To instantiate this process in the code, you have two options:
57
182
  This doesn't require any previous setup. Given your company and disclosure template IDs, you can create disclosure requests freely when the user starts the widget:
58
183
 
59
184
  ```jsx
60
- import { useSoyioAuth } from "@soyio/soyio-rn-sdk";
185
+ import { View, StyleSheet } from "react-native";
186
+ import { SoyioWidget } from "@soyio/soyio-rn-sdk";
61
187
 
62
188
  export default function App() {
63
189
  const options = {
64
- companyId: "<company id>", // Starts with 'com_'
65
- uriScheme: "<company custom uri scheme>"
190
+ uriScheme: "<your-app-scheme>", // Required: Your app's URI scheme
191
+ companyId: "<company id>", // Optional: Starts with 'com_'
66
192
  userReference: "<company identifier of user>", // Optional
67
- customColor: "<custom color>", // Optional
68
- isSandbox: true, // Optional
193
+ isSandbox: true, // Optional
69
194
  };
70
195
 
71
196
  // For initialize a disclosure request
72
197
  const disclosureParams = {
73
- templateId: "<template id>", // Starts with 'dtpl_'
74
- userEmail: "<user email>", // Optional
75
- forceError: '<error type>', // Optional
76
- };
77
-
78
- const onEventChange = (event) => {
79
- console.log("Event:", event);
198
+ templateId: "<template id>", // Starts with 'dtpl_'
199
+ userEmail: "<user email>", // Optional
80
200
  };
81
201
 
82
- const { disclosure } = useSoyioAuth({ options, onEventChange });
83
-
84
- const initDisclosureRequest = () => {
85
- disclosure(disclosureParams);
202
+ const handleSuccess = () => {
203
+ console.log("Verification successful!");
86
204
  };
87
205
 
88
206
  return (
89
- <View>
90
- <Button title="Disclosure request" onPress={initDisclosureRequest} />
207
+ <View style={styles.container}>
208
+ <SoyioWidget
209
+ options={options}
210
+ requestType="disclosure"
211
+ requestParams={disclosureParams}
212
+ onSuccess={handleSuccess}
213
+ />
91
214
  </View>
92
215
  );
93
216
  }
217
+
218
+ const styles = StyleSheet.create({
219
+ container: {
220
+ flex: 1,
221
+ },
222
+ });
94
223
  ```
95
224
 
96
225
  #### 1.b Created disclosure request:
@@ -102,38 +231,41 @@ For more details about the use case, please refer to [the documentation](https:/
102
231
  To use this option, simply specify the disclosure request ID along with any optional parameters:
103
232
 
104
233
  ```jsx
105
- import { useSoyioAuth } from "@soyio/soyio-rn-sdk";
234
+ import { View, StyleSheet } from "react-native";
235
+ import { SoyioWidget } from "@soyio/soyio-rn-sdk";
106
236
 
107
237
  export default function App() {
108
238
  const options = {
109
- uriScheme: "<company custom uri scheme>"
110
- customColor: "<custom color>", // Optional
111
- isSandbox: false, // Optional
239
+ uriScheme: "<your-app-scheme>", // Required: Your app's URI scheme
240
+ isSandbox: false, // Optional
112
241
  };
113
242
 
114
243
  // For initialize a disclosure request
115
244
  const disclosureParams = {
116
- disclosureRequestId: "<disclosure request id>", // Starts with 'dreq_'
117
- userEmail: "<user email>", // Optional
118
- forceError: '<error type>', // Optional
245
+ disclosureRequestId: "<disclosure request id>", // Starts with 'dreq_'
119
246
  };
120
247
 
121
- const onEventChange = (event) => {
122
- console.log("Event:", event);
123
- };
124
-
125
- const { disclosure } = useSoyioAuth({ options, onEventChange });
126
-
127
- const initDisclosureRequest = () => {
128
- disclosure(disclosureParams);
248
+ const handleSuccess = () => {
249
+ console.log("Verification successful!");
129
250
  };
130
251
 
131
252
  return (
132
- <View>
133
- <Button title="Disclosure request" onPress={initDisclosureRequest} />
253
+ <View style={styles.container}>
254
+ <SoyioWidget
255
+ options={options}
256
+ requestType="disclosure"
257
+ requestParams={disclosureParams}
258
+ onSuccess={handleSuccess}
259
+ />
134
260
  </View>
135
261
  );
136
262
  }
263
+
264
+ const styles = StyleSheet.create({
265
+ container: {
266
+ flex: 1,
267
+ },
268
+ });
137
269
  ```
138
270
 
139
271
  Note that user and template properties are not specified here because they must be specified when creating the disclosure request beforehand.
@@ -143,97 +275,147 @@ Note that user and template properties are not specified here because they must
143
275
  The **`auth_request`** is a process where, using a previously created `auth_request_id`, a request is initiated in which a user can authenticate with Soyio. This authentication can occur either through an access key or facial video.
144
276
 
145
277
  ```jsx
146
- import { useSoyioAuth } from "@soyio/soyio-rn-sdk";
278
+ import { View, StyleSheet } from "react-native";
279
+ import { SoyioWidget } from "@soyio/soyio-rn-sdk";
147
280
 
148
281
  export default function App() {
149
282
  const options = {
150
- uriScheme: "<company custom uri scheme>"
151
- customColor: "<custom color>", // Optional
152
- isSandbox: false, // Optional
283
+ uriScheme: "<your-app-scheme>", // Required: Your app's URI scheme
284
+ isSandbox: false, // Optional
153
285
  };
154
286
 
155
287
  const authRequestParams = {
156
- authRequestId: "<auth request id>" // Starts with 'authreq_'
157
- }
158
-
159
- const onEventChange = (event) => {
160
- console.log("Event:", event);
288
+ authRequestId: "<auth request id>", // Starts with 'authreq_'
161
289
  };
162
290
 
163
- const { authentication } = useSoyioAuth({ options, onEventChange });
164
-
165
- const initAuthRequest = () => {
166
- authentication(authRequestParams);
291
+ const handleSuccess = () => {
292
+ console.log("Authentication successful!");
167
293
  };
168
294
 
169
295
  return (
170
- <View>
171
- <Button title="Auth Request" onPress={initAuthRequest} />
296
+ <View style={styles.container}>
297
+ <SoyioWidget
298
+ options={options}
299
+ requestType="authentication_request"
300
+ requestParams={authRequestParams}
301
+ onSuccess={handleSuccess}
302
+ />
172
303
  </View>
173
304
  );
174
305
  }
306
+
307
+ const styles = StyleSheet.create({
308
+ container: {
309
+ flex: 1,
310
+ },
311
+ });
175
312
  ```
176
313
 
177
- The `onEventChange` function can return the following objects:
314
+ ### Event Handling
178
315
 
179
- 1. When a request is successful:
316
+ The `SoyioWidget` component supports the following event handlers:
180
317
 
181
- ```js
182
- {
183
- type: "success",
184
- request: "disclosure" | "authRequest",
185
- verificationKind: "validation" | "authentication",
186
- userReference: "<company-user-reference>",
187
- identityId: "<soyio-identity-id-of-user>",
188
- }
189
- ```
318
+ - **`onSuccess`**: Called when the verification/authentication process completes successfully
190
319
 
191
- 2. When webview is opened:
320
+ ## InAppBrowser Integration
192
321
 
193
- ```js
194
- {
195
- type: "open";
196
- }
322
+ For cases where you prefer to open the verification flow in an in-app browser instead of a WebView, you can use the direct function approach.
323
+
324
+ ### 1. Disclosure Request (InAppBrowser)
325
+
326
+ #### 1.a Disclosure request on-the-fly:
327
+
328
+ ```jsx
329
+ import { openDisclosure } from "@soyio/soyio-rn-sdk";
330
+
331
+ const handleDisclosure = async () => {
332
+ const options = {
333
+ uriScheme: "<your-app-scheme>", // Required: Your app's URI scheme
334
+ companyId: "<company id>", // Optional: Starts with 'com_'
335
+ userReference: "<company identifier of user>", // Optional
336
+ isSandbox: true, // Optional
337
+ };
338
+
339
+ const disclosureParams = {
340
+ templateId: "<template id>", // Starts with 'dtpl_'
341
+ userEmail: "<user email>", // Optional
342
+ };
343
+
344
+ await openDisclosure({
345
+ options,
346
+ requestParams: disclosureParams,
347
+ onComplete: () => console.log("Disclosure completed successfully!"),
348
+ onCancel: () => console.log("Disclosure was cancelled by user"),
349
+ });
350
+ };
197
351
  ```
198
352
 
199
- 3. When webview is closed:
353
+ #### 1.b Created disclosure request:
200
354
 
201
- ```js
202
- {
203
- type: "cancel";
204
- }
355
+ ```jsx
356
+ import { openDisclosure } from "@soyio/soyio-rn-sdk";
357
+
358
+ const handleDisclosure = async () => {
359
+ const options = {
360
+ uriScheme: "<your-app-scheme>", // Required: Your app's URI scheme
361
+ isSandbox: false, // Optional
362
+ };
363
+
364
+ const disclosureParams = {
365
+ disclosureRequestId: "<disclosure request id>", // Starts with 'dreq_'
366
+ };
367
+
368
+ await openDisclosure({
369
+ options,
370
+ requestParams: disclosureParams,
371
+ onComplete: () => console.log("Disclosure completed successfully!"),
372
+ onCancel: () => console.log("Disclosure was cancelled by user"),
373
+ });
374
+ };
205
375
  ```
206
376
 
207
- 4. When user exits because of error:
377
+ ### 2. Auth Request (InAppBrowser)
208
378
 
209
- ```js
210
- {
211
- type: "error",
212
- request: "disclosure" | "authRequest",
213
- error: "UNEXPECTED_ERROR"
214
- }
379
+ ```jsx
380
+ import { openAuthenticationRequest } from "@soyio/soyio-rn-sdk";
381
+
382
+ const handleAuthRequest = async () => {
383
+ const options = {
384
+ uriScheme: "<your-app-scheme>", // Required: Your app's URI scheme
385
+ isSandbox: false, // Optional
386
+ };
387
+
388
+ const authRequestParams = {
389
+ authRequestId: "<auth request id>", // Starts with 'authreq_'
390
+ };
391
+
392
+ await openAuthenticationRequest({
393
+ options,
394
+ requestParams: authRequestParams,
395
+ onComplete: () => console.log("Authentication completed successfully!"),
396
+ onCancel: () => console.log("Authentication was cancelled by user"),
397
+ });
398
+ };
215
399
  ```
216
400
 
217
- #### Attribute Descriptions
401
+ ### Event Handling (InAppBrowser)
218
402
 
219
- - **`companyId`**: The unique identifier for the company, must start with `'com_'`.
220
- - **`userReference`**: (Optional) A reference identifier provided by the company for the user engaging with the widget. This identifier is used in events (`onEvent` and `webhooks`) to inform the company which user the events are associated with.
221
- - **`userEmail`**: The user's email address.
222
- - **`forceError`**: (Optional) Triggers specific errors for testing or debugging. Used to simulate failure scenarios.
223
- - **`templateId`**: Identifier of template. Specifies the order and quantity of documents requested from the user, as well as the mandatory data that the user is asked to share with the company. It must start with `'datmp_'`.
224
- - **`customColor`**: (Optional) A hex code string that specifies the base color of the interface
225
- - **`isSandbox`**: (Optional) Indicates if the widget should operate in sandbox mode, defaulting to `false`.
226
- - **`uriScheme`**: The unique redirect scheme you've set with `npx uri-scheme add ...`, critical for redirect handling in your app.
227
- - **`authRequestId`**: Identifier of auth request obtained when creating the `AuthRequest`. It must start with `'authreq_'`.
403
+ The InAppBrowser functions support the following callback handlers:
228
404
 
229
- #### Error types
405
+ - **`onComplete`**: Called when the verification/authentication process completes successfully
406
+ - **`onCancel`**: Called when the user cancels the process or navigates away
230
407
 
231
- The `forceError` parameter can simulate the following error conditions:
408
+ #### Attribute Descriptions
232
409
 
233
- - `'user_exists'`: Triggers an error indicating that a user with the given credentials already exists in the system.
234
- - `'facial_validation_error'`: Simulates a failure in the facial video liveness test, indicating the system could not verify the user's live presence.
235
- - `'document_validation_error'`: Indicates an issue with validating the photos of the documents provided by the user.
236
- - `'unknown_error'`: Generates a generic error, representing an unspecified problem.
410
+ - **`uriScheme`**: (Required) The URI scheme for your application, used for deep linking and navigation.
411
+ - **`companyId`**: (Optional) The unique identifier for the company, must start with `'com_'`.
412
+ - **`userReference`**: (Optional) A reference identifier provided by the company for the user engaging with the widget. This identifier is used in events (`onEvent` and `webhooks`) to inform the company which user the events are associated with.
413
+ - **`userEmail`**: (Optional) The user's email address.
414
+ - **`templateId`**: (Required for new disclosure requests) Identifier of template. Specifies the order and quantity of documents requested from the user, as well as the mandatory data that the user is asked to share with the company. It must start with `'dtpl_'`.
415
+ - **`isSandbox`**: (Optional) Indicates if the widget should operate in sandbox mode, defaulting to `false`.
416
+ - **`developmentUrl`**: (Optional) Custom development URL for testing purposes.
417
+ - **`authRequestId`**: (Required for authentication requests) Identifier of auth request obtained when creating the `AuthRequest`. It must start with `'authreq_'`.
418
+ - **`disclosureRequestId`**: (Required for existing disclosure requests) Identifier of an existing disclosure request. It must start with `'dreq_'`.
237
419
 
238
420
  #### TypeScript support
239
421
 
@@ -241,10 +423,10 @@ This package includes TypeScript declarations.
241
423
 
242
424
  #### Developing
243
425
 
244
- To develop the package, you need to use `npm`. Install the dependencies:
426
+ To develop the package, you need to use `yarn`. Install the dependencies:
245
427
 
246
428
  ```sh
247
- npm install
429
+ yarn install
248
430
  ```
249
431
 
250
432
  To test locally, I recommend packaging the app. Remember to build the library first:
@@ -253,30 +435,3 @@ To test locally, I recommend packaging the app. Remember to build the library fi
253
435
  npm run build
254
436
  npm pack
255
437
  ```
256
-
257
- This will create a `soyio-soyio-rn-sdk-x.x.x.tgz` file (with the corresponding package version). Now, go to another directory and create a React Native app (using Expo, perhaps). After creating the new application, add the following dependency to its `package.json` file:
258
-
259
- ```json
260
- {
261
- "dependencies": {
262
- ...,
263
- "@soyio/soyio-rn-sdk": "file:./path/to/soyio-soyio-rn-sdk-x.x.x.tgz",
264
- ...
265
- }
266
- }
267
- ```
268
-
269
- Where `./path/to/soyio-soyio-rn-sdk-x.x.x.tgz` corresponds to the path to the `.tgz` file created on the `npm pack` step. After running `npm install` on the new React Native app, you should be able to use Soyio React Native to import the Soyio View.
270
-
271
- If you want to create a new _release_, you can run:
272
-
273
- ```sh
274
- git switch main
275
- npm run bump! <major|minor|patch>
276
- ```
277
-
278
- This will create a new branch with the updated version from `main`.
279
-
280
- ## Acknowledgements
281
-
282
- This implementation was written based on the input and experience of [**fintoc**](https://github.com/fintoc-com/fintoc-react-native) integrating the WebView using React Native, which served as a good starting point for the general idea of this library.
@@ -0,0 +1,56 @@
1
+ apply plugin: 'com.android.library'
2
+ apply plugin: 'kotlin-android'
3
+
4
+ def safeExtGet(prop, fallback) {
5
+ rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
6
+ }
7
+
8
+ android {
9
+ compileSdkVersion safeExtGet('compileSdkVersion', 34)
10
+ def javaVersion = safeExtGet('javaVersion', JavaVersion.VERSION_17)
11
+
12
+ defaultConfig {
13
+ minSdkVersion safeExtGet('minSdkVersion', 21)
14
+ targetSdkVersion safeExtGet('targetSdkVersion', 34)
15
+ versionCode 1
16
+ versionName "1.0"
17
+ }
18
+
19
+ buildTypes {
20
+ release {
21
+ minifyEnabled false
22
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
23
+ }
24
+ }
25
+
26
+ compileOptions {
27
+ sourceCompatibility javaVersion
28
+ targetCompatibility javaVersion
29
+ }
30
+
31
+ kotlinOptions {
32
+ jvmTarget = javaVersion.toString()
33
+ }
34
+
35
+ sourceSets {
36
+ main {
37
+ assets.srcDirs += ['../assets']
38
+ }
39
+ }
40
+ }
41
+
42
+ repositories {
43
+ flatDir {
44
+ dirs 'libs'
45
+ }
46
+ google()
47
+ mavenCentral()
48
+ }
49
+
50
+ dependencies {
51
+ def kotlinVersion = safeExtGet('kotlinVersion', '1.8.0')
52
+ implementation "com.facebook.react:react-native:+"
53
+ implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
54
+ implementation(name: "facetec-sdk-9.7.96", ext: "aar")
55
+ implementation "com.squareup.okhttp3:okhttp:3.12.13"
56
+ }
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android"
3
+ package="com.soyio.soyiorndk">
4
+
5
+ <!-- Add any permissions your module needs here -->
6
+ <!-- Example: <uses-permission android:name="android.permission.INTERNET" /> -->
7
+
8
+ </manifest>