@soyio/soyio-rn-sdk 2.3.0 → 3.0.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.
- package/README.md +194 -131
- package/index.ts +14 -3
- package/package/index.d.ts +4 -2
- package/package/index.js +6 -3
- package/package/src/constants.d.ts +3 -2
- package/package/src/constants.js +4 -3
- package/package/src/inapp-browser.d.ts +21 -0
- package/package/src/inapp-browser.js +104 -0
- package/package/src/passkey-bridge.d.ts +17 -0
- package/package/src/passkey-bridge.js +103 -0
- package/package/src/types.d.ts +27 -13
- package/package/src/utils/index.d.ts +4 -0
- package/package/src/utils/index.js +12 -0
- package/package/src/utils/message-handler.d.ts +3 -0
- package/package/src/utils/message-handler.js +76 -0
- package/package/src/utils/platform.d.ts +1 -0
- package/package/src/utils/platform.js +9 -0
- package/package/src/utils/type-guards.d.ts +4 -0
- package/package/src/utils/type-guards.js +15 -0
- package/package/src/utils/url-builder.d.ts +2 -0
- package/package/src/utils/url-builder.js +70 -0
- package/package/src/webview.d.ts +3 -0
- package/package/src/webview.jsx +65 -0
- package/package.json +10 -10
- package/package/src/core.d.ts +0 -5
- package/package/src/core.jsx +0 -134
- package/package/src/utils.d.ts +0 -17
- 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
|
|
17
|
+
- Install using npm (or your favorite package manager)
|
|
18
18
|
|
|
19
19
|
```sh
|
|
20
20
|
# Using npm
|
|
@@ -24,22 +24,55 @@ npm install @soyio/soyio-rn-sdk
|
|
|
24
24
|
yarn add @soyio/soyio-rn-sdk
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
-
-
|
|
27
|
+
- You'll also need to install the required peer dependencies:
|
|
28
28
|
|
|
29
|
-
```
|
|
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
|
+
### URI Scheme Setup
|
|
42
|
+
|
|
43
|
+
You need to configure a custom URI scheme for your application to handle deep linking properly:
|
|
44
|
+
|
|
45
|
+
```sh
|
|
30
46
|
npx uri-scheme add custom-uri-scheme
|
|
31
47
|
```
|
|
32
48
|
|
|
33
|
-
|
|
49
|
+
Replace `custom-uri-scheme` with your desired scheme name. This scheme should match the `uriScheme` parameter you use in the `SoyioWidget` options.
|
|
34
50
|
|
|
35
|
-
|
|
36
|
-
For developers integrating with a **bare React Native** application, it's crucial to prepare your project for Expo modules:
|
|
51
|
+
### iOS Permissions
|
|
37
52
|
|
|
38
|
-
|
|
53
|
+
Add the following permission to your `ios/YourApp/Info.plist` file to enable camera access for document verification:
|
|
54
|
+
|
|
55
|
+
```xml
|
|
56
|
+
<key>NSCameraUsageDescription</key>
|
|
57
|
+
<string>This app needs access to camera for document verification</string>
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Android Permissions
|
|
61
|
+
Add the following permission and feature declaration to your `android/app/src/main/AndroidManifest.xml` file within the `<manifest>` tag:
|
|
62
|
+
|
|
63
|
+
```xml
|
|
64
|
+
<uses-permission android:name="android.permission.CAMERA" />
|
|
65
|
+
<uses-feature android:name="android.hardware.camera" android:required="true" />
|
|
66
|
+
```
|
|
39
67
|
|
|
40
68
|
## Usage
|
|
41
69
|
|
|
42
|
-
`Soyio React Native`
|
|
70
|
+
`Soyio React Native` provides two ways to integrate the Soyio verification flow:
|
|
71
|
+
|
|
72
|
+
1. **WebView Component**: A `SoyioWidget` component that renders a WebView within your app.
|
|
73
|
+
2. **InAppBrowser Functions**: Direct functions that open the verification flow in an in-app browser.
|
|
74
|
+
|
|
75
|
+
## WebView Integration
|
|
43
76
|
|
|
44
77
|
### 1. Disclosure Request
|
|
45
78
|
|
|
@@ -57,40 +90,44 @@ To instantiate this process in the code, you have two options:
|
|
|
57
90
|
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
91
|
|
|
59
92
|
```jsx
|
|
60
|
-
import {
|
|
93
|
+
import { View, StyleSheet } from "react-native";
|
|
94
|
+
import { SoyioWidget } from "@soyio/soyio-rn-sdk";
|
|
61
95
|
|
|
62
96
|
export default function App() {
|
|
63
97
|
const options = {
|
|
64
|
-
|
|
65
|
-
|
|
98
|
+
uriScheme: "<your-app-scheme>", // Required: Your app's URI scheme
|
|
99
|
+
companyId: "<company id>", // Optional: Starts with 'com_'
|
|
66
100
|
userReference: "<company identifier of user>", // Optional
|
|
67
|
-
|
|
68
|
-
isSandbox: true, // Optional
|
|
101
|
+
isSandbox: true, // Optional
|
|
69
102
|
};
|
|
70
103
|
|
|
71
104
|
// For initialize a disclosure request
|
|
72
105
|
const disclosureParams = {
|
|
73
|
-
templateId: "<template id>",
|
|
74
|
-
userEmail: "<user email>",
|
|
75
|
-
forceError: '<error type>', // Optional
|
|
106
|
+
templateId: "<template id>", // Starts with 'dtpl_'
|
|
107
|
+
userEmail: "<user email>", // Optional
|
|
76
108
|
};
|
|
77
109
|
|
|
78
|
-
const
|
|
79
|
-
console.log("
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
const { disclosure } = useSoyioAuth({ options, onEventChange });
|
|
83
|
-
|
|
84
|
-
const initDisclosureRequest = () => {
|
|
85
|
-
disclosure(disclosureParams);
|
|
110
|
+
const handleSuccess = () => {
|
|
111
|
+
console.log("Verification successful!");
|
|
86
112
|
};
|
|
87
113
|
|
|
88
114
|
return (
|
|
89
|
-
<View>
|
|
90
|
-
<
|
|
115
|
+
<View style={styles.container}>
|
|
116
|
+
<SoyioWidget
|
|
117
|
+
options={options}
|
|
118
|
+
requestType="disclosure"
|
|
119
|
+
requestParams={disclosureParams}
|
|
120
|
+
onSuccess={handleSuccess}
|
|
121
|
+
/>
|
|
91
122
|
</View>
|
|
92
123
|
);
|
|
93
124
|
}
|
|
125
|
+
|
|
126
|
+
const styles = StyleSheet.create({
|
|
127
|
+
container: {
|
|
128
|
+
flex: 1,
|
|
129
|
+
},
|
|
130
|
+
});
|
|
94
131
|
```
|
|
95
132
|
|
|
96
133
|
#### 1.b Created disclosure request:
|
|
@@ -102,38 +139,41 @@ For more details about the use case, please refer to [the documentation](https:/
|
|
|
102
139
|
To use this option, simply specify the disclosure request ID along with any optional parameters:
|
|
103
140
|
|
|
104
141
|
```jsx
|
|
105
|
-
import {
|
|
142
|
+
import { View, StyleSheet } from "react-native";
|
|
143
|
+
import { SoyioWidget } from "@soyio/soyio-rn-sdk";
|
|
106
144
|
|
|
107
145
|
export default function App() {
|
|
108
146
|
const options = {
|
|
109
|
-
uriScheme: "<
|
|
110
|
-
|
|
111
|
-
isSandbox: false, // Optional
|
|
147
|
+
uriScheme: "<your-app-scheme>", // Required: Your app's URI scheme
|
|
148
|
+
isSandbox: false, // Optional
|
|
112
149
|
};
|
|
113
150
|
|
|
114
151
|
// For initialize a disclosure request
|
|
115
152
|
const disclosureParams = {
|
|
116
|
-
disclosureRequestId: "<disclosure request id>",
|
|
117
|
-
userEmail: "<user email>", // Optional
|
|
118
|
-
forceError: '<error type>', // Optional
|
|
153
|
+
disclosureRequestId: "<disclosure request id>", // Starts with 'dreq_'
|
|
119
154
|
};
|
|
120
155
|
|
|
121
|
-
const
|
|
122
|
-
console.log("
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
const { disclosure } = useSoyioAuth({ options, onEventChange });
|
|
126
|
-
|
|
127
|
-
const initDisclosureRequest = () => {
|
|
128
|
-
disclosure(disclosureParams);
|
|
156
|
+
const handleSuccess = () => {
|
|
157
|
+
console.log("Verification successful!");
|
|
129
158
|
};
|
|
130
159
|
|
|
131
160
|
return (
|
|
132
|
-
<View>
|
|
133
|
-
<
|
|
161
|
+
<View style={styles.container}>
|
|
162
|
+
<SoyioWidget
|
|
163
|
+
options={options}
|
|
164
|
+
requestType="disclosure"
|
|
165
|
+
requestParams={disclosureParams}
|
|
166
|
+
onSuccess={handleSuccess}
|
|
167
|
+
/>
|
|
134
168
|
</View>
|
|
135
169
|
);
|
|
136
170
|
}
|
|
171
|
+
|
|
172
|
+
const styles = StyleSheet.create({
|
|
173
|
+
container: {
|
|
174
|
+
flex: 1,
|
|
175
|
+
},
|
|
176
|
+
});
|
|
137
177
|
```
|
|
138
178
|
|
|
139
179
|
Note that user and template properties are not specified here because they must be specified when creating the disclosure request beforehand.
|
|
@@ -143,97 +183,147 @@ Note that user and template properties are not specified here because they must
|
|
|
143
183
|
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
184
|
|
|
145
185
|
```jsx
|
|
146
|
-
import {
|
|
186
|
+
import { View, StyleSheet } from "react-native";
|
|
187
|
+
import { SoyioWidget } from "@soyio/soyio-rn-sdk";
|
|
147
188
|
|
|
148
189
|
export default function App() {
|
|
149
190
|
const options = {
|
|
150
|
-
uriScheme: "<
|
|
151
|
-
|
|
152
|
-
isSandbox: false, // Optional
|
|
191
|
+
uriScheme: "<your-app-scheme>", // Required: Your app's URI scheme
|
|
192
|
+
isSandbox: false, // Optional
|
|
153
193
|
};
|
|
154
194
|
|
|
155
195
|
const authRequestParams = {
|
|
156
|
-
authRequestId: "<auth request id>" // Starts with 'authreq_'
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
const onEventChange = (event) => {
|
|
160
|
-
console.log("Event:", event);
|
|
196
|
+
authRequestId: "<auth request id>", // Starts with 'authreq_'
|
|
161
197
|
};
|
|
162
198
|
|
|
163
|
-
const
|
|
164
|
-
|
|
165
|
-
const initAuthRequest = () => {
|
|
166
|
-
authentication(authRequestParams);
|
|
199
|
+
const handleSuccess = () => {
|
|
200
|
+
console.log("Authentication successful!");
|
|
167
201
|
};
|
|
168
202
|
|
|
169
203
|
return (
|
|
170
|
-
<View>
|
|
171
|
-
<
|
|
204
|
+
<View style={styles.container}>
|
|
205
|
+
<SoyioWidget
|
|
206
|
+
options={options}
|
|
207
|
+
requestType="authentication_request"
|
|
208
|
+
requestParams={authRequestParams}
|
|
209
|
+
onSuccess={handleSuccess}
|
|
210
|
+
/>
|
|
172
211
|
</View>
|
|
173
212
|
);
|
|
174
213
|
}
|
|
214
|
+
|
|
215
|
+
const styles = StyleSheet.create({
|
|
216
|
+
container: {
|
|
217
|
+
flex: 1,
|
|
218
|
+
},
|
|
219
|
+
});
|
|
175
220
|
```
|
|
176
221
|
|
|
177
|
-
|
|
222
|
+
### Event Handling
|
|
178
223
|
|
|
179
|
-
|
|
224
|
+
The `SoyioWidget` component supports the following event handlers:
|
|
180
225
|
|
|
181
|
-
|
|
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
|
-
```
|
|
226
|
+
- **`onSuccess`**: Called when the verification/authentication process completes successfully
|
|
190
227
|
|
|
191
|
-
|
|
228
|
+
## InAppBrowser Integration
|
|
192
229
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
230
|
+
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.
|
|
231
|
+
|
|
232
|
+
### 1. Disclosure Request (InAppBrowser)
|
|
233
|
+
|
|
234
|
+
#### 1.a Disclosure request on-the-fly:
|
|
235
|
+
|
|
236
|
+
```jsx
|
|
237
|
+
import { openDisclosure } from "@soyio/soyio-rn-sdk";
|
|
238
|
+
|
|
239
|
+
const handleDisclosure = async () => {
|
|
240
|
+
const options = {
|
|
241
|
+
uriScheme: "<your-app-scheme>", // Required: Your app's URI scheme
|
|
242
|
+
companyId: "<company id>", // Optional: Starts with 'com_'
|
|
243
|
+
userReference: "<company identifier of user>", // Optional
|
|
244
|
+
isSandbox: true, // Optional
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
const disclosureParams = {
|
|
248
|
+
templateId: "<template id>", // Starts with 'dtpl_'
|
|
249
|
+
userEmail: "<user email>", // Optional
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
await openDisclosure({
|
|
253
|
+
options,
|
|
254
|
+
requestParams: disclosureParams,
|
|
255
|
+
onComplete: () => console.log("Disclosure completed successfully!"),
|
|
256
|
+
onCancel: () => console.log("Disclosure was cancelled by user"),
|
|
257
|
+
});
|
|
258
|
+
};
|
|
197
259
|
```
|
|
198
260
|
|
|
199
|
-
|
|
261
|
+
#### 1.b Created disclosure request:
|
|
200
262
|
|
|
201
|
-
```
|
|
202
|
-
{
|
|
203
|
-
|
|
204
|
-
|
|
263
|
+
```jsx
|
|
264
|
+
import { openDisclosure } from "@soyio/soyio-rn-sdk";
|
|
265
|
+
|
|
266
|
+
const handleDisclosure = async () => {
|
|
267
|
+
const options = {
|
|
268
|
+
uriScheme: "<your-app-scheme>", // Required: Your app's URI scheme
|
|
269
|
+
isSandbox: false, // Optional
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
const disclosureParams = {
|
|
273
|
+
disclosureRequestId: "<disclosure request id>", // Starts with 'dreq_'
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
await openDisclosure({
|
|
277
|
+
options,
|
|
278
|
+
requestParams: disclosureParams,
|
|
279
|
+
onComplete: () => console.log("Disclosure completed successfully!"),
|
|
280
|
+
onCancel: () => console.log("Disclosure was cancelled by user"),
|
|
281
|
+
});
|
|
282
|
+
};
|
|
205
283
|
```
|
|
206
284
|
|
|
207
|
-
|
|
285
|
+
### 2. Auth Request (InAppBrowser)
|
|
208
286
|
|
|
209
|
-
```
|
|
210
|
-
{
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
287
|
+
```jsx
|
|
288
|
+
import { openAuthenticationRequest } from "@soyio/soyio-rn-sdk";
|
|
289
|
+
|
|
290
|
+
const handleAuthRequest = async () => {
|
|
291
|
+
const options = {
|
|
292
|
+
uriScheme: "<your-app-scheme>", // Required: Your app's URI scheme
|
|
293
|
+
isSandbox: false, // Optional
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
const authRequestParams = {
|
|
297
|
+
authRequestId: "<auth request id>", // Starts with 'authreq_'
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
await openAuthenticationRequest({
|
|
301
|
+
options,
|
|
302
|
+
requestParams: authRequestParams,
|
|
303
|
+
onComplete: () => console.log("Authentication completed successfully!"),
|
|
304
|
+
onCancel: () => console.log("Authentication was cancelled by user"),
|
|
305
|
+
});
|
|
306
|
+
};
|
|
215
307
|
```
|
|
216
308
|
|
|
217
|
-
|
|
309
|
+
### Event Handling (InAppBrowser)
|
|
218
310
|
|
|
219
|
-
|
|
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_'`.
|
|
311
|
+
The InAppBrowser functions support the following callback handlers:
|
|
228
312
|
|
|
229
|
-
|
|
313
|
+
- **`onComplete`**: Called when the verification/authentication process completes successfully
|
|
314
|
+
- **`onCancel`**: Called when the user cancels the process or navigates away
|
|
230
315
|
|
|
231
|
-
|
|
316
|
+
#### Attribute Descriptions
|
|
232
317
|
|
|
233
|
-
-
|
|
234
|
-
-
|
|
235
|
-
-
|
|
236
|
-
-
|
|
318
|
+
- **`uriScheme`**: (Required) The URI scheme for your application, used for deep linking and navigation.
|
|
319
|
+
- **`companyId`**: (Optional) The unique identifier for the company, must start with `'com_'`.
|
|
320
|
+
- **`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.
|
|
321
|
+
- **`userEmail`**: (Optional) The user's email address.
|
|
322
|
+
- **`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_'`.
|
|
323
|
+
- **`isSandbox`**: (Optional) Indicates if the widget should operate in sandbox mode, defaulting to `false`.
|
|
324
|
+
- **`developmentUrl`**: (Optional) Custom development URL for testing purposes.
|
|
325
|
+
- **`authRequestId`**: (Required for authentication requests) Identifier of auth request obtained when creating the `AuthRequest`. It must start with `'authreq_'`.
|
|
326
|
+
- **`disclosureRequestId`**: (Required for existing disclosure requests) Identifier of an existing disclosure request. It must start with `'dreq_'`.
|
|
237
327
|
|
|
238
328
|
#### TypeScript support
|
|
239
329
|
|
|
@@ -241,10 +331,10 @@ This package includes TypeScript declarations.
|
|
|
241
331
|
|
|
242
332
|
#### Developing
|
|
243
333
|
|
|
244
|
-
To develop the package, you need to use `
|
|
334
|
+
To develop the package, you need to use `yarn`. Install the dependencies:
|
|
245
335
|
|
|
246
336
|
```sh
|
|
247
|
-
|
|
337
|
+
yarn install
|
|
248
338
|
```
|
|
249
339
|
|
|
250
340
|
To test locally, I recommend packaging the app. Remember to build the library first:
|
|
@@ -253,30 +343,3 @@ To test locally, I recommend packaging the app. Remember to build the library fi
|
|
|
253
343
|
npm run build
|
|
254
344
|
npm pack
|
|
255
345
|
```
|
|
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.
|
package/index.ts
CHANGED
|
@@ -1,7 +1,18 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { SoyioWidget } from './src/webview';
|
|
2
|
+
|
|
3
|
+
export {
|
|
4
|
+
openDisclosure,
|
|
5
|
+
openAuthenticationRequest,
|
|
6
|
+
} from './src/inapp-browser';
|
|
2
7
|
|
|
3
8
|
export type {
|
|
4
|
-
|
|
9
|
+
SoyioWidgetOptions,
|
|
5
10
|
DisclosureParams,
|
|
6
|
-
|
|
11
|
+
AuthRequestParams,
|
|
12
|
+
SoyioWidgetProps,
|
|
7
13
|
} from './src/types';
|
|
14
|
+
|
|
15
|
+
export type {
|
|
16
|
+
OpenDisclosureParams,
|
|
17
|
+
OpenAuthRequestParams,
|
|
18
|
+
} from './src/inapp-browser';
|
package/package/index.d.ts
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export
|
|
1
|
+
export { SoyioWidget } from './src/webview';
|
|
2
|
+
export { openDisclosure, openAuthenticationRequest, } from './src/inapp-browser';
|
|
3
|
+
export type { SoyioWidgetOptions, DisclosureParams, AuthRequestParams, SoyioWidgetProps, } from './src/types';
|
|
4
|
+
export type { OpenDisclosureParams, OpenAuthRequestParams, } from './src/inapp-browser';
|
package/package/index.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
var
|
|
5
|
-
Object.defineProperty(exports, "
|
|
3
|
+
exports.openAuthenticationRequest = exports.openDisclosure = exports.SoyioWidget = void 0;
|
|
4
|
+
var webview_1 = require("./src/webview");
|
|
5
|
+
Object.defineProperty(exports, "SoyioWidget", { enumerable: true, get: function () { return webview_1.SoyioWidget; } });
|
|
6
|
+
var inapp_browser_1 = require("./src/inapp-browser");
|
|
7
|
+
Object.defineProperty(exports, "openDisclosure", { enumerable: true, get: function () { return inapp_browser_1.openDisclosure; } });
|
|
8
|
+
Object.defineProperty(exports, "openAuthenticationRequest", { enumerable: true, get: function () { return inapp_browser_1.openAuthenticationRequest; } });
|
|
6
9
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export declare const PRODUCTION_URL = "https://app.soyio.id
|
|
2
|
-
export declare const SANDBOX_URL = "https://sandbox.soyio.id
|
|
1
|
+
export declare const PRODUCTION_URL = "https://app.soyio.id";
|
|
2
|
+
export declare const SANDBOX_URL = "https://sandbox.soyio.id";
|
|
3
|
+
export declare const SOYIO_BASE_URLS: string[];
|
package/package/src/constants.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SANDBOX_URL = exports.PRODUCTION_URL = void 0;
|
|
4
|
-
exports.PRODUCTION_URL = 'https://app.soyio.id
|
|
5
|
-
exports.SANDBOX_URL = 'https://sandbox.soyio.id
|
|
3
|
+
exports.SOYIO_BASE_URLS = exports.SANDBOX_URL = exports.PRODUCTION_URL = void 0;
|
|
4
|
+
exports.PRODUCTION_URL = 'https://app.soyio.id';
|
|
5
|
+
exports.SANDBOX_URL = 'https://sandbox.soyio.id';
|
|
6
|
+
exports.SOYIO_BASE_URLS = [exports.PRODUCTION_URL, exports.SANDBOX_URL];
|
|
6
7
|
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { AuthRequestParams, DisclosureParams, SoyioWidgetOptions } from './types';
|
|
2
|
+
export interface OpenDisclosureParams {
|
|
3
|
+
options: SoyioWidgetOptions;
|
|
4
|
+
requestParams: DisclosureParams;
|
|
5
|
+
onComplete?: () => void;
|
|
6
|
+
onCancel?: () => void;
|
|
7
|
+
}
|
|
8
|
+
export interface OpenAuthRequestParams {
|
|
9
|
+
options: SoyioWidgetOptions;
|
|
10
|
+
requestParams: AuthRequestParams;
|
|
11
|
+
onComplete?: () => void;
|
|
12
|
+
onCancel?: () => void;
|
|
13
|
+
}
|
|
14
|
+
export declare const IN_APP_BROWSER_OPTIONS: {
|
|
15
|
+
ephemeralWebSession: boolean;
|
|
16
|
+
showTitle: boolean;
|
|
17
|
+
enableUrlBarHiding: boolean;
|
|
18
|
+
enableDefaultShare: boolean;
|
|
19
|
+
};
|
|
20
|
+
export declare const openDisclosure: ({ options, requestParams, onComplete, onCancel, }: OpenDisclosureParams) => Promise<void>;
|
|
21
|
+
export declare const openAuthenticationRequest: ({ options, requestParams, onComplete, onCancel, }: OpenAuthRequestParams) => Promise<void>;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.openAuthenticationRequest = exports.openDisclosure = exports.IN_APP_BROWSER_OPTIONS = void 0;
|
|
40
|
+
var react_native_inappbrowser_reborn_1 = require("react-native-inappbrowser-reborn");
|
|
41
|
+
var url_builder_1 = require("./utils/url-builder");
|
|
42
|
+
exports.IN_APP_BROWSER_OPTIONS = {
|
|
43
|
+
// iOS Properties
|
|
44
|
+
ephemeralWebSession: false,
|
|
45
|
+
showTitle: false,
|
|
46
|
+
// Android Properties
|
|
47
|
+
enableUrlBarHiding: true,
|
|
48
|
+
enableDefaultShare: false,
|
|
49
|
+
};
|
|
50
|
+
var openInAppBrowser = function (url, uriScheme, onComplete, onCancel) { return __awaiter(void 0, void 0, void 0, function () {
|
|
51
|
+
var deepLink, result;
|
|
52
|
+
return __generator(this, function (_a) {
|
|
53
|
+
switch (_a.label) {
|
|
54
|
+
case 0:
|
|
55
|
+
deepLink = "".concat(uriScheme, "://success");
|
|
56
|
+
return [4 /*yield*/, react_native_inappbrowser_reborn_1.InAppBrowser.isAvailable()];
|
|
57
|
+
case 1:
|
|
58
|
+
if (!(_a.sent())) {
|
|
59
|
+
throw new Error('InAppBrowser is not available');
|
|
60
|
+
}
|
|
61
|
+
return [4 /*yield*/, react_native_inappbrowser_reborn_1.InAppBrowser.openAuth(url, deepLink, exports.IN_APP_BROWSER_OPTIONS)];
|
|
62
|
+
case 2:
|
|
63
|
+
result = _a.sent();
|
|
64
|
+
if (result.type === 'success') {
|
|
65
|
+
onComplete === null || onComplete === void 0 ? void 0 : onComplete();
|
|
66
|
+
}
|
|
67
|
+
else if (result.type === 'cancel') {
|
|
68
|
+
onCancel === null || onCancel === void 0 ? void 0 : onCancel();
|
|
69
|
+
}
|
|
70
|
+
return [2 /*return*/];
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
}); };
|
|
74
|
+
var openDisclosure = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
75
|
+
var url;
|
|
76
|
+
var options = _b.options, requestParams = _b.requestParams, onComplete = _b.onComplete, onCancel = _b.onCancel;
|
|
77
|
+
return __generator(this, function (_c) {
|
|
78
|
+
switch (_c.label) {
|
|
79
|
+
case 0:
|
|
80
|
+
url = (0, url_builder_1.buildUrl)(options, 'disclosure', requestParams, false);
|
|
81
|
+
return [4 /*yield*/, openInAppBrowser(url, options.uriScheme, onComplete, onCancel)];
|
|
82
|
+
case 1:
|
|
83
|
+
_c.sent();
|
|
84
|
+
return [2 /*return*/];
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
}); };
|
|
88
|
+
exports.openDisclosure = openDisclosure;
|
|
89
|
+
var openAuthenticationRequest = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
90
|
+
var url;
|
|
91
|
+
var options = _b.options, requestParams = _b.requestParams, onComplete = _b.onComplete, onCancel = _b.onCancel;
|
|
92
|
+
return __generator(this, function (_c) {
|
|
93
|
+
switch (_c.label) {
|
|
94
|
+
case 0:
|
|
95
|
+
url = (0, url_builder_1.buildUrl)(options, 'authentication_request', requestParams, false);
|
|
96
|
+
return [4 /*yield*/, openInAppBrowser(url, options.uriScheme, onComplete, onCancel)];
|
|
97
|
+
case 1:
|
|
98
|
+
_c.sent();
|
|
99
|
+
return [2 /*return*/];
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
}); };
|
|
103
|
+
exports.openAuthenticationRequest = openAuthenticationRequest;
|
|
104
|
+
//# sourceMappingURL=inapp-browser.js.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface PasskeyRequiredParams {
|
|
2
|
+
companyId: string;
|
|
3
|
+
sessionToken: string;
|
|
4
|
+
uriScheme: string;
|
|
5
|
+
isSandbox?: boolean;
|
|
6
|
+
developmentUrl?: string;
|
|
7
|
+
onComplete?: () => void;
|
|
8
|
+
}
|
|
9
|
+
export interface PasskeyAuthenticationParams {
|
|
10
|
+
authRequestId: string;
|
|
11
|
+
uriScheme: string;
|
|
12
|
+
isSandbox?: boolean;
|
|
13
|
+
developmentUrl?: string;
|
|
14
|
+
onComplete?: () => void;
|
|
15
|
+
}
|
|
16
|
+
export declare const handlePasskeyRequired: ({ companyId, sessionToken, uriScheme, isSandbox, developmentUrl, onComplete, }: PasskeyRequiredParams) => Promise<void>;
|
|
17
|
+
export declare const handlePasskeyAuthentication: ({ authRequestId, uriScheme, isSandbox, developmentUrl, onComplete, }: PasskeyAuthenticationParams) => Promise<void>;
|