@soyio/soyio-widget 1.0.7 → 1.0.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 +104 -16
- package/dist/index.d.ts +50 -25
- package/dist/index.js +943 -959
- package/dist/index.umd.cjs +10 -10
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -26,20 +26,87 @@ yarn add @soyio/soyio-widget
|
|
|
26
26
|
|
|
27
27
|
## Usage
|
|
28
28
|
|
|
29
|
-
Integrate the widget into your frontend framework using the script below. Ensure to replace placeholders (e.g.,
|
|
29
|
+
Integrate the widget into your frontend framework using the script below. Ensure to replace placeholders (e.g., \<flow>, \<company id>) with actual values relevant to your implementation.
|
|
30
|
+
|
|
31
|
+
### 1. Validation attempt
|
|
30
32
|
|
|
31
33
|
```html
|
|
32
34
|
<script>
|
|
33
|
-
import SoyioWidget from '@soyio/soyio-widget';
|
|
35
|
+
import { SoyioWidget } from '@soyio/soyio-widget';
|
|
34
36
|
|
|
35
37
|
// Widget configuration
|
|
36
38
|
const widgetConfig = {
|
|
37
|
-
flow: "
|
|
39
|
+
flow: "register",
|
|
38
40
|
configProps: {
|
|
39
41
|
companyId: "<company id>",
|
|
40
42
|
userReference: "<user identifier of company>",
|
|
41
43
|
userEmail: "<user email>",
|
|
42
44
|
flowTemplateId: "<flow template id>",
|
|
45
|
+
forceError: "<error type>",
|
|
46
|
+
customColor: "<custom color>"
|
|
47
|
+
},
|
|
48
|
+
onEvent: (data) => console.log(data),
|
|
49
|
+
isSandbox: true,
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
// Create widget when needed. In this example, widget is created when page is loaded.
|
|
53
|
+
document.addEventListener("DOMContentLoaded", function () {
|
|
54
|
+
new SoyioWidget(widgetConfig);
|
|
55
|
+
});
|
|
56
|
+
</script>
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Optional props:
|
|
60
|
+
* `userReference`
|
|
61
|
+
* `userEmail`
|
|
62
|
+
* `forceError`
|
|
63
|
+
* `customColor`.
|
|
64
|
+
|
|
65
|
+
### 2. Auth attempt
|
|
66
|
+
|
|
67
|
+
```html
|
|
68
|
+
<script>
|
|
69
|
+
import { SoyioWidget } from '@soyio/soyio-widget';
|
|
70
|
+
|
|
71
|
+
// Widget configuration
|
|
72
|
+
const widgetConfig = {
|
|
73
|
+
flow: "authenticate",
|
|
74
|
+
configProps: {
|
|
75
|
+
companyId: "<company id>",
|
|
76
|
+
userReference: "<user identifier of company>",
|
|
77
|
+
identityId: "<identity id>",
|
|
78
|
+
forceError: "<error type>",
|
|
79
|
+
customColor: "<custom color>"
|
|
80
|
+
},
|
|
81
|
+
onEvent: (data) => console.log(data),
|
|
82
|
+
isSandbox: true,
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
// Create widget when needed. In this example, widget is created when page is loaded.
|
|
86
|
+
document.addEventListener("DOMContentLoaded", function () {
|
|
87
|
+
new SoyioWidget(widgetConfig);
|
|
88
|
+
});
|
|
89
|
+
</script>
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Optional props:
|
|
93
|
+
* `userReference`
|
|
94
|
+
* `forceError`
|
|
95
|
+
* `customColor`.
|
|
96
|
+
|
|
97
|
+
### 3. Signature attempt (*coming soon...*)
|
|
98
|
+
|
|
99
|
+
```html
|
|
100
|
+
<script>
|
|
101
|
+
import { SoyioWidget } from '@soyio/soyio-widget';
|
|
102
|
+
|
|
103
|
+
// Widget configuration
|
|
104
|
+
const widgetConfig = {
|
|
105
|
+
flow: "signature",
|
|
106
|
+
configProps: {
|
|
107
|
+
companyId: "<company id>",
|
|
108
|
+
userReference: "<user identifier of company>",
|
|
109
|
+
signatureTemplateId: "<signature template id>",
|
|
43
110
|
identityId: "<identity id>",
|
|
44
111
|
forceError: "<error type>",
|
|
45
112
|
customColor: "<custom color>"
|
|
@@ -55,35 +122,46 @@ Integrate the widget into your frontend framework using the script below. Ensure
|
|
|
55
122
|
</script>
|
|
56
123
|
```
|
|
57
124
|
|
|
58
|
-
|
|
125
|
+
Optional props:
|
|
126
|
+
* `userReference`
|
|
127
|
+
* `forceError`
|
|
128
|
+
* `customColor`.
|
|
129
|
+
|
|
130
|
+
### Attribute Descriptions
|
|
59
131
|
|
|
60
|
-
- **`flow`**: A string that can only take the values `'register'` or `'authenticate'`. Specifies the workflow of the widget.
|
|
61
132
|
- **`companyId`**: The unique identifier for the company, must start with `'com_'`.
|
|
62
|
-
- **`userReference`**:
|
|
63
|
-
- **`userEmail`**: The user's email address.
|
|
64
|
-
- **`flowTemplateId`**:
|
|
65
|
-
- **`
|
|
66
|
-
- **`
|
|
133
|
+
- **`userReference`**: 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.
|
|
134
|
+
- **`userEmail`**: The user's email address. If not provided, Soyio will prompt the user to enter their email.
|
|
135
|
+
- **`flowTemplateId`**: Identifier of template. Specifies the order and quantity of documents requested from the user. It must start with `'vt_'`.
|
|
136
|
+
- **`signatureTemplateId`**: Identifier of template. Specifies the order and quantity of documents to sign. It must start with `'st_'`.
|
|
137
|
+
- **`identityId`**: This identifier must start with `'id_'` and signifies the user's identity.
|
|
138
|
+
- **`isSandbox`**: Indicates if the widget should operate in sandbox mode, defaulting to `false`.
|
|
139
|
+
- **`forceError`**: Triggers specific errors for testing or debugging. Used to simulate failure scenarios. Only works in `sandbox` mode.
|
|
67
140
|
- **`onEvent`**: A callback function triggered upon event occurrences, used for capturing and logging event-related data.
|
|
68
|
-
- **`customColor`**:
|
|
69
|
-
- **`isSandbox`**: (Optional) Indicates if the widget should operate in sandbox mode, defaulting to `false`.
|
|
141
|
+
- **`customColor`**: A hex code string that specifies the base color of the interface during either the authentication or registration flow.
|
|
70
142
|
|
|
71
|
-
|
|
143
|
+
### Events
|
|
72
144
|
|
|
73
145
|
The `onEvent` callback is designed to handle various events that occur during widget interaction. Specifically, it receives detailed information upon the successful completion of user flows. Here are the events it handles:
|
|
74
146
|
|
|
75
|
-
- **`IDENTITY_REGISTERED`**: This event is dispatched when a user successfully completes the
|
|
147
|
+
- **`IDENTITY_REGISTERED`**: This event is dispatched when a user successfully completes the validation attempt. The event object contains:
|
|
76
148
|
|
|
77
149
|
- `eventName`: The name of the event, in this case, `'IDENTITY_REGISTERED'`.
|
|
78
150
|
- `identityId`: The unique identifier for the newly registered identity.
|
|
79
151
|
- `userReference`: The reference identifier for the user, facilitating the association of the event with the user within the company's context.
|
|
80
152
|
|
|
81
|
-
- **`IDENTITY_AUTHENTICATED`**: This event occurs when a user successfully completes
|
|
153
|
+
- **`IDENTITY_AUTHENTICATED`**: This event occurs when a user successfully completes an authentication attempt. The event object includes:
|
|
82
154
|
|
|
83
155
|
- `eventName`: The name of the event, in this case, `'IDENTITY_AUTHENTICATED'`.
|
|
84
156
|
- `identityId`: The unique identifier for the authenticated identity.
|
|
85
157
|
- `userReference`: The reference identifier for the user, facilitating the association of the event with the user within the company's context.
|
|
86
158
|
|
|
159
|
+
- **`IDENTITY_SIGNATURE`**: This event occurs when a user successfully completes a signature attempt. The event object includes:
|
|
160
|
+
|
|
161
|
+
- `eventName`: The name of the event, in this case, `'IDENTITY_SIGNATURE'`.
|
|
162
|
+
- `identityId`: The unique identifier for the authenticated identity.
|
|
163
|
+
- `userReference`: The reference identifier for the user, facilitating the association of the event with the user within the company's context.
|
|
164
|
+
|
|
87
165
|
- **`DENIED_CAMERA_PERMISSION`**: Event triggered when user denies camera permissions. It closes the widget.
|
|
88
166
|
|
|
89
167
|
- **`WIDGET_CLOSED`**: This event occurs when the user closes the `Soyio` pop up. The event object is as follows:
|
|
@@ -93,7 +171,7 @@ The `onEvent` callback is designed to handle various events that occur during wi
|
|
|
93
171
|
- **`WIDGET_OPENED`**: This event occurs when the user closes the `Soyio` pop up. The event object is as follows:
|
|
94
172
|
- `{ eventName: 'WIDGET_CLOSED' }`.
|
|
95
173
|
|
|
96
|
-
####
|
|
174
|
+
#### Force error types
|
|
97
175
|
|
|
98
176
|
The `forceError` parameter can simulate the following error conditions:
|
|
99
177
|
|
|
@@ -103,3 +181,13 @@ The `forceError` parameter can simulate the following error conditions:
|
|
|
103
181
|
- `'unknown_error'`: Generates a generic error, representing an unspecified problem.
|
|
104
182
|
- `'expiration_error'`: Occurs when there is an issue with the identity provider that prevents the validation of one or both documents provided by the user, due to unspecified problems in the validation process.
|
|
105
183
|
- `'camera_permission_error'`: Happens when the user does not grant the necessary permissions to access the camera, preventing the completion of the validation flow.
|
|
184
|
+
|
|
185
|
+
#### Typescript
|
|
186
|
+
|
|
187
|
+
The `SoyioTypes` module from the `@soyio/soyio-widget` package provides TypeScript type definitions that you can use to integrate the SoyioWidget more seamlessly into your TypeScript projects.
|
|
188
|
+
|
|
189
|
+
To use the `SoyioTypes` in your project, import it directly from the `@soyio/soyio-widget` package:
|
|
190
|
+
|
|
191
|
+
```javascript
|
|
192
|
+
import { SoyioTypes } from '@soyio/soyio-widget'
|
|
193
|
+
```
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
declare type AttemptConfig = ValidationAttemptConfig | AuthAttemptConfig | SignatureAttemptConfig;
|
|
2
|
+
|
|
3
|
+
declare type AuthAttemptConfig = {
|
|
4
|
+
flow: 'authenticate';
|
|
5
|
+
configProps: AuthAttemptProps;
|
|
6
|
+
onEvent: (data: EventData) => void;
|
|
7
|
+
isSandbox?: boolean;
|
|
8
|
+
developmentUrl?: string;
|
|
9
|
+
};
|
|
10
|
+
|
|
1
11
|
declare type AuthAttemptProps = {
|
|
2
12
|
companyId: string;
|
|
3
13
|
identityId: string;
|
|
@@ -6,57 +16,72 @@ declare type AuthAttemptProps = {
|
|
|
6
16
|
customColor?: string;
|
|
7
17
|
};
|
|
8
18
|
|
|
9
|
-
declare type ConfigProps = AuthAttemptProps | ValidationAttemptProps;
|
|
10
|
-
|
|
11
19
|
declare type EventData = {
|
|
12
|
-
eventName: 'IDENTITY_REGISTERED' | 'IDENTITY_AUTHENTICATED' | 'DENIED_CAMERA_PERMISSION';
|
|
20
|
+
eventName: 'IDENTITY_REGISTERED' | 'IDENTITY_AUTHENTICATED' | 'IDENTITY_SIGNATURE' | 'DENIED_CAMERA_PERMISSION' | 'REJECTED_SIGNATURE';
|
|
13
21
|
identityId: string;
|
|
14
22
|
userReference?: string;
|
|
15
23
|
};
|
|
16
24
|
|
|
17
|
-
declare type Flow = 'authenticate' | 'register';
|
|
25
|
+
declare type Flow = 'authenticate' | 'register' | 'signature';
|
|
18
26
|
|
|
19
27
|
declare type ForceErrors = 'facial_validation_error' | 'document_validation_error' | 'unknown_error' | 'expiration_error' | 'camera_permission_error';
|
|
20
28
|
|
|
29
|
+
declare type SignatureAttemptConfig = {
|
|
30
|
+
flow: 'signature';
|
|
31
|
+
configProps: SignatureAttemptProps;
|
|
32
|
+
onEvent: (data: EventData) => void;
|
|
33
|
+
isSandbox?: boolean;
|
|
34
|
+
developmentUrl?: string;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
declare type SignatureAttemptProps = {
|
|
38
|
+
companyId: string;
|
|
39
|
+
identityId: string;
|
|
40
|
+
signatureTemplateId: string;
|
|
41
|
+
userReference?: string;
|
|
42
|
+
forceError?: ForceErrors;
|
|
43
|
+
customColor?: string;
|
|
44
|
+
};
|
|
45
|
+
|
|
21
46
|
declare namespace SoyioTypes {
|
|
22
47
|
export {
|
|
23
48
|
ForceErrors,
|
|
24
49
|
Flow,
|
|
25
50
|
AuthAttemptProps,
|
|
26
51
|
ValidationAttemptProps,
|
|
27
|
-
|
|
52
|
+
SignatureAttemptProps,
|
|
28
53
|
EventData,
|
|
29
|
-
|
|
54
|
+
ValidationAttemptConfig,
|
|
55
|
+
AuthAttemptConfig,
|
|
56
|
+
SignatureAttemptConfig,
|
|
57
|
+
AttemptConfig
|
|
30
58
|
}
|
|
31
59
|
}
|
|
32
60
|
export { SoyioTypes }
|
|
33
61
|
|
|
34
|
-
declare
|
|
35
|
-
companyId: string;
|
|
36
|
-
flowTemplateId: string;
|
|
37
|
-
userReference?: string;
|
|
38
|
-
userEmail?: string;
|
|
39
|
-
forceError?: ForceErrors;
|
|
40
|
-
customColor?: string;
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
declare class Widget {
|
|
62
|
+
declare class SoyioWidget {
|
|
44
63
|
#private;
|
|
45
|
-
private flow;
|
|
46
|
-
private configProps;
|
|
47
64
|
private onEvent;
|
|
48
|
-
|
|
49
|
-
constructor(options: SoyioTypes.WidgetConfig);
|
|
50
|
-
validateProps(): void;
|
|
65
|
+
constructor(options: SoyioTypes.AttemptConfig);
|
|
51
66
|
}
|
|
52
|
-
export
|
|
67
|
+
export { SoyioWidget }
|
|
68
|
+
export default SoyioWidget;
|
|
53
69
|
|
|
54
|
-
declare type
|
|
55
|
-
flow:
|
|
56
|
-
configProps:
|
|
70
|
+
declare type ValidationAttemptConfig = {
|
|
71
|
+
flow: 'register';
|
|
72
|
+
configProps: ValidationAttemptProps;
|
|
57
73
|
onEvent: (data: EventData) => void;
|
|
58
74
|
isSandbox?: boolean;
|
|
59
75
|
developmentUrl?: string;
|
|
60
76
|
};
|
|
61
77
|
|
|
78
|
+
declare type ValidationAttemptProps = {
|
|
79
|
+
companyId: string;
|
|
80
|
+
flowTemplateId: string;
|
|
81
|
+
userReference?: string;
|
|
82
|
+
userEmail?: string;
|
|
83
|
+
forceError?: ForceErrors;
|
|
84
|
+
customColor?: string;
|
|
85
|
+
};
|
|
86
|
+
|
|
62
87
|
export { }
|