@soyio/soyio-widget 1.0.6 → 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 CHANGED
@@ -26,20 +26,54 @@ 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 Widget 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
+ * `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>",
43
77
  identityId: "<identity id>",
44
78
  forceError: "<error type>",
45
79
  customColor: "<custom color>"
@@ -50,40 +84,84 @@ Integrate the widget into your frontend framework using the script below. Ensure
50
84
 
51
85
  // Create widget when needed. In this example, widget is created when page is loaded.
52
86
  document.addEventListener("DOMContentLoaded", function () {
53
- new Widget(widgetConfig);
87
+ new SoyioWidget(widgetConfig);
54
88
  });
55
89
  </script>
56
90
  ```
57
91
 
58
- #### Attribute Descriptions
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>",
110
+ identityId: "<identity id>",
111
+ forceError: "<error type>",
112
+ customColor: "<custom color>"
113
+ },
114
+ onEvent: (data) => console.log(data),
115
+ isSandbox: true,
116
+ };
117
+
118
+ // Create widget when needed. In this example, widget is created when page is loaded.
119
+ document.addEventListener("DOMContentLoaded", function () {
120
+ new SoyioWidget(widgetConfig);
121
+ });
122
+ </script>
123
+ ```
124
+
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`**: (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.
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`**: (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`.
141
+ - **`customColor`**: A hex code string that specifies the base color of the interface during either the authentication or registration flow.
70
142
 
71
- #### Events
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 registration flow. The event object contains:
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 the authentication flow. The event object includes:
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,11 +171,23 @@ 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
- #### Error types
174
+ #### Force error types
97
175
 
98
176
  The `forceError` parameter can simulate the following error conditions:
99
177
 
100
- - `'user_exists'`: Triggers an error indicating that a user with the given credentials already exists in the system.
178
+
101
179
  - `'facial_validation_error'`: Simulates a failure in the facial video liveness test, indicating the system could not verify the user's live presence.
102
180
  - `'document_validation_error'`: Indicates an issue with validating the photos of the documents provided by the user.
103
181
  - `'unknown_error'`: Generates a generic error, representing an unspecified problem.
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.
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,40 +1,87 @@
1
- declare type ConfigProps = {
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
+
11
+ declare type AuthAttemptProps = {
2
12
  companyId: string;
13
+ identityId: string;
3
14
  userReference?: string;
4
- flowTemplateId?: string;
5
- userEmail?: string;
6
- identityId?: string;
7
- forceError?: SoyioErrors;
15
+ forceError?: ForceErrors;
8
16
  customColor?: string;
9
17
  };
10
18
 
11
19
  declare type EventData = {
12
- eventName: 'IDENTITY_REGISTERED' | 'IDENTITY_AUTHENTICATED';
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
- declare type SoyioErrors = 'user_exists' | 'facial_validation_error' | 'document_validation_error' | 'unknown_error';
27
+ declare type ForceErrors = 'facial_validation_error' | 'document_validation_error' | 'unknown_error' | 'expiration_error' | 'camera_permission_error';
20
28
 
21
- declare class Widget {
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
+
46
+ declare namespace SoyioTypes {
47
+ export {
48
+ ForceErrors,
49
+ Flow,
50
+ AuthAttemptProps,
51
+ ValidationAttemptProps,
52
+ SignatureAttemptProps,
53
+ EventData,
54
+ ValidationAttemptConfig,
55
+ AuthAttemptConfig,
56
+ SignatureAttemptConfig,
57
+ AttemptConfig
58
+ }
59
+ }
60
+ export { SoyioTypes }
61
+
62
+ declare class SoyioWidget {
22
63
  #private;
23
- private flow;
24
- private configProps;
25
64
  private onEvent;
26
- private isSandbox;
27
- constructor(options: WidgetConfig);
28
- validateProps(): void;
65
+ constructor(options: SoyioTypes.AttemptConfig);
29
66
  }
30
- export default Widget;
67
+ export { SoyioWidget }
68
+ export default SoyioWidget;
31
69
 
32
- declare type WidgetConfig = {
33
- flow: Flow;
34
- configProps: Partial<ConfigProps>;
70
+ declare type ValidationAttemptConfig = {
71
+ flow: 'register';
72
+ configProps: ValidationAttemptProps;
35
73
  onEvent: (data: EventData) => void;
36
74
  isSandbox?: boolean;
37
75
  developmentUrl?: string;
38
76
  };
39
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
+
40
87
  export { }