@soyio/soyio-widget 1.0.7 → 1.0.9

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 CHANGED
@@ -26,22 +26,88 @@ 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., <flow>, <company id>) with actual values relevant to your implementation.
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: "<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
+
61
+ - `userReference`
62
+ - `userEmail`
63
+ - `forceError`
64
+ - `customColor`.
65
+
66
+ ### 2. Auth attempt
67
+
68
+ ```html
69
+ <script>
70
+ import { SoyioWidget } from "@soyio/soyio-widget";
71
+
72
+ // Widget configuration
73
+ const widgetConfig = {
74
+ flow: "authenticate",
75
+ configProps: {
76
+ companyId: "<company id>",
77
+ userReference: "<user identifier of company>",
43
78
  identityId: "<identity id>",
44
79
  forceError: "<error type>",
80
+ customColor: "<custom color>",
81
+ },
82
+ onEvent: (data) => console.log(data),
83
+ isSandbox: true,
84
+ };
85
+
86
+ // Create widget when needed. In this example, widget is created when page is loaded.
87
+ document.addEventListener("DOMContentLoaded", function () {
88
+ new SoyioWidget(widgetConfig);
89
+ });
90
+ </script>
91
+ ```
92
+
93
+ Optional props:
94
+
95
+ - `userReference`
96
+ - `forceError`
97
+ - `customColor`.
98
+
99
+ ### 3. Signature attempt (_coming soon..._)
100
+
101
+ ```html
102
+ <script>
103
+ import { SoyioWidget } from "@soyio/soyio-widget";
104
+
105
+ // Widget configuration
106
+ const widgetConfig = {
107
+ flow: "signature",
108
+ configProps: {
109
+ signatureAttemptId: "<signature attempt id>",
110
+ forceError: "<error type>",
45
111
  customColor: "<custom color>"
46
112
  },
47
113
  onEvent: (data) => console.log(data),
@@ -55,35 +121,46 @@ Integrate the widget into your frontend framework using the script below. Ensure
55
121
  </script>
56
122
  ```
57
123
 
58
- #### Attribute Descriptions
124
+ Optional props:
125
+
126
+ - `forceError`
127
+ - `customColor`.
128
+
129
+ ### Attribute Descriptions
59
130
 
60
- - **`flow`**: A string that can only take the values `'register'` or `'authenticate'`. Specifies the workflow of the widget.
61
131
  - **`companyId`**: The unique identifier for the company, must start with `'com_'`.
62
- - **`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.
63
- - **`userEmail`**: The user's email address. This field is optional when the flow is `'register'`, where if not provided, Soyio will prompt the user to enter their email. However, for the `'authenticate'` flow, this field should not be provided.
64
- - **`flowTemplateId`**: Required only in the `'register'` flow, this identifier specifies the order and quantity of documents requested from the user. It must start with `'vt_'`.
65
- - **`identityId`**: Necessary only in the `'authenticate'` flow, this identifier must start with `'id_'` and signifies the user's identity.
66
- - **`forceError`**: (Optional) Triggers specific errors for testing or debugging. Used to simulate failure scenarios.
132
+ - **`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.
133
+ - **`userEmail`**: The user's email address. If not provided, Soyio will prompt the user to enter their email.
134
+ - **`flowTemplateId`**: Identifier of template. Specifies the order and quantity of documents requested from the user. It must start with `'vt_'`.
135
+ - **`signatureAttemptId`**: Identifier of signature attempt obtained when creating the `SignatureAttempt`. It must start with `'sa_'`.
136
+ - **`identityId`**: This identifier must start with `'id_'` and signifies the user's identity.
137
+ - **`isSandbox`**: Indicates if the widget should operate in sandbox mode, defaulting to `false`.
138
+ - **`forceError`**: Triggers specific errors for testing or debugging. Used to simulate failure scenarios. Only works in `sandbox` mode.
67
139
  - **`onEvent`**: A callback function triggered upon event occurrences, used for capturing and logging event-related data.
68
- - **`customColor`**: (Optional) A hex code string that specifies the base color of the interface during either the authentication or registration flow.
69
- - **`isSandbox`**: (Optional) Indicates if the widget should operate in sandbox mode, defaulting to `false`.
140
+ - **`customColor`**: A hex code string that specifies the base color of the interface during either the authentication or registration flow.
70
141
 
71
- #### Events
142
+ ### Events
72
143
 
73
144
  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
145
 
75
- - **`IDENTITY_REGISTERED`**: This event is dispatched when a user successfully completes the registration flow. The event object contains:
146
+ - **`IDENTITY_REGISTERED`**: This event is dispatched when a user successfully completes the validation attempt. The event object contains:
76
147
 
77
148
  - `eventName`: The name of the event, in this case, `'IDENTITY_REGISTERED'`.
78
149
  - `identityId`: The unique identifier for the newly registered identity.
79
150
  - `userReference`: The reference identifier for the user, facilitating the association of the event with the user within the company's context.
80
151
 
81
- - **`IDENTITY_AUTHENTICATED`**: This event occurs when a user successfully completes the authentication flow. The event object includes:
152
+ - **`IDENTITY_AUTHENTICATED`**: This event occurs when a user successfully completes an authentication attempt. The event object includes:
82
153
 
83
154
  - `eventName`: The name of the event, in this case, `'IDENTITY_AUTHENTICATED'`.
84
155
  - `identityId`: The unique identifier for the authenticated identity.
85
156
  - `userReference`: The reference identifier for the user, facilitating the association of the event with the user within the company's context.
86
157
 
158
+ - **`IDENTITY_SIGNATURE`**: This event occurs when a user successfully completes a signature attempt. The event object includes:
159
+
160
+ - `eventName`: The name of the event, in this case, `'IDENTITY_SIGNATURE'`.
161
+ - `identityId`: The unique identifier for the authenticated identity.
162
+ - `userReference`: The reference identifier for the user, facilitating the association of the event with the user within the company's context.
163
+
87
164
  - **`DENIED_CAMERA_PERMISSION`**: Event triggered when user denies camera permissions. It closes the widget.
88
165
 
89
166
  - **`WIDGET_CLOSED`**: This event occurs when the user closes the `Soyio` pop up. The event object is as follows:
@@ -93,13 +170,22 @@ The `onEvent` callback is designed to handle various events that occur during wi
93
170
  - **`WIDGET_OPENED`**: This event occurs when the user closes the `Soyio` pop up. The event object is as follows:
94
171
  - `{ eventName: 'WIDGET_CLOSED' }`.
95
172
 
96
- #### Error types
173
+ #### Force error types
97
174
 
98
175
  The `forceError` parameter can simulate the following error conditions:
99
176
 
100
-
101
177
  - `'facial_validation_error'`: Simulates a failure in the facial video liveness test, indicating the system could not verify the user's live presence.
102
178
  - `'document_validation_error'`: Indicates an issue with validating the photos of the documents provided by the user.
103
179
  - `'unknown_error'`: Generates a generic error, representing an unspecified problem.
104
180
  - `'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
181
  - `'camera_permission_error'`: Happens when the user does not grant the necessary permissions to access the camera, preventing the completion of the validation flow.
182
+
183
+ #### Typescript
184
+
185
+ 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.
186
+
187
+ To use the `SoyioTypes` in your project, import it directly from the `@soyio/soyio-widget` package:
188
+
189
+ ```javascript
190
+ import type { SoyioTypes } from "@soyio/soyio-widget";
191
+ ```
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,69 @@ 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
+ signatureAttemptId: string;
39
+ forceError?: ForceErrors;
40
+ customColor?: string;
41
+ };
42
+
21
43
  declare namespace SoyioTypes {
22
44
  export {
23
45
  ForceErrors,
24
46
  Flow,
25
47
  AuthAttemptProps,
26
48
  ValidationAttemptProps,
27
- ConfigProps,
49
+ SignatureAttemptProps,
28
50
  EventData,
29
- WidgetConfig
51
+ ValidationAttemptConfig,
52
+ AuthAttemptConfig,
53
+ SignatureAttemptConfig,
54
+ AttemptConfig
30
55
  }
31
56
  }
32
57
  export { SoyioTypes }
33
58
 
34
- declare type ValidationAttemptProps = {
35
- companyId: string;
36
- flowTemplateId: string;
37
- userReference?: string;
38
- userEmail?: string;
39
- forceError?: ForceErrors;
40
- customColor?: string;
41
- };
42
-
43
- declare class Widget {
59
+ declare class SoyioWidget {
44
60
  #private;
45
- private flow;
46
- private configProps;
47
61
  private onEvent;
48
- private isSandbox;
49
- constructor(options: SoyioTypes.WidgetConfig);
50
- validateProps(): void;
62
+ constructor(options: SoyioTypes.AttemptConfig);
51
63
  }
52
- export default Widget;
64
+ export { SoyioWidget }
65
+ export default SoyioWidget;
53
66
 
54
- declare type WidgetConfig = {
55
- flow: Flow;
56
- configProps: ConfigProps;
67
+ declare type ValidationAttemptConfig = {
68
+ flow: 'register';
69
+ configProps: ValidationAttemptProps;
57
70
  onEvent: (data: EventData) => void;
58
71
  isSandbox?: boolean;
59
72
  developmentUrl?: string;
60
73
  };
61
74
 
75
+ declare type ValidationAttemptProps = {
76
+ companyId: string;
77
+ flowTemplateId: string;
78
+ userReference?: string;
79
+ userEmail?: string;
80
+ forceError?: ForceErrors;
81
+ customColor?: string;
82
+ };
83
+
62
84
  export { }