@soyio/soyio-widget 2.1.0 → 2.2.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 CHANGED
@@ -170,6 +170,43 @@ Optional props:
170
170
  - `forceError`
171
171
  - `customColor`.
172
172
 
173
+ ### 3. Auth Request
174
+
175
+ The **`auth_request`** is a process where, using a previously created `auth_request_id`, a request is initiated in which a user can authenticate. This authentication can occur either through an access key or facial video. It's important to note that for this request, the user must have been previously verified with Soyio.
176
+
177
+ ```html
178
+ <button id="start-auth-request">Start auth request</button>
179
+
180
+ <script>
181
+ import { SoyioWidget } from "@soyio/soyio-widget";
182
+
183
+ // Widget configuration
184
+ const widgetConfig = {
185
+ request: "authentication",
186
+ configProps: {
187
+ authRequestId: "<auth request id>",
188
+ customColor: "<custom color>",
189
+ },
190
+ onEvent: (data) => console.log(data),
191
+ isSandbox: true,
192
+ };
193
+
194
+ // Function to create the widget
195
+ function initWidget() {
196
+ new SoyioWidget(widgetConfig);
197
+ }
198
+
199
+ // Add event listener to the button to create the widget on click
200
+ document
201
+ .getElementById("start-auth-request")
202
+ .addEventListener("click", initWidget);
203
+ </script>
204
+ ```
205
+
206
+ Optional props:
207
+
208
+ - `customColor`.
209
+
173
210
  ### Attribute Descriptions
174
211
 
175
212
  - **`companyId`**: The unique identifier for the company, must start with `'com_'`.
@@ -178,6 +215,7 @@ Optional props:
178
215
  - **`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 `'dtpl_'`.
179
216
  - **`disclosureRequestId`**: If created beforehand, you can target a specific disclosure request that the user must complete. It is useful if you need to match some data between the disclosure process and your database records. It must start with `'dreq_'`
180
217
  - **`signatureAttemptId`**: Identifier of signature attempt obtained when creating the `SignatureAttempt`. It must start with `'sa_'`.
218
+ - **`authRequestId`**: Identifier of auth request obtained when creating the `AuthRequest`. It must start with `'authreq_'`.
181
219
  - **`identityId`**: This identifier must start with `'id_'` and signifies the user's identity.
182
220
  - **`isSandbox`**: Indicates if the widget should operate in sandbox mode, defaulting to `false`.
183
221
  - **`forceError`**: Triggers specific errors for testing or debugging. Used to simulate failure scenarios. Only works in `sandbox` mode.
package/dist/index.d.ts CHANGED
@@ -1,4 +1,17 @@
1
- declare type AttemptConfig = DisclosureRequestConfig | SignatureAttemptConfig;
1
+ declare type AttemptConfig = DisclosureRequestConfig | SignatureAttemptConfig | AuthRequestConfig;
2
+
3
+ declare type AuthRequestConfig = {
4
+ request: 'authentication';
5
+ configProps: AuthRequestProps;
6
+ onEvent: (data: EventData) => void;
7
+ isSandbox?: boolean;
8
+ developmentUrl?: string;
9
+ };
10
+
11
+ declare type AuthRequestProps = {
12
+ authRequestId: `authreq_${string}`;
13
+ customColor?: string;
14
+ };
2
15
 
3
16
  declare type DisclosureRequestConfig = {
4
17
  request: 'disclosure';
@@ -11,15 +24,15 @@ declare type DisclosureRequestConfig = {
11
24
  declare type DisclosureRequestProps = NewDisclosureRequestProps | ExistingDisclosureRequestProps;
12
25
 
13
26
  declare type EventData = {
14
- eventName: 'IDENTITY_VALIDATED' | 'IDENTITY_AUTHENTICATED' | 'IDENTITY_SIGNATURE' | 'DENIED_CAMERA_PERMISSION' | 'REJECTED_SIGNATURE' | 'DISCLOSURE_REQUEST_SUCCESSFUL' | 'UNEXPECTED_ERROR';
15
- identityId: string;
27
+ eventName: 'IDENTITY_VALIDATED' | 'IDENTITY_AUTHENTICATED' | 'IDENTITY_SIGNATURE' | 'DENIED_CAMERA_PERMISSION' | 'REJECTED_SIGNATURE' | 'DISCLOSURE_REQUEST_SUCCESSFUL' | 'UNEXPECTED_ERROR' | 'AUTH_REQUEST_SUCCESSFUL';
28
+ identityId: `id_${string}`;
16
29
  userReference?: string;
17
30
  };
18
31
 
19
32
  declare type ExistingDisclosureRequestProps = {
20
33
  companyId?: never;
21
34
  templateId?: never;
22
- disclosureRequestId: string;
35
+ disclosureRequestId: `dreq_${string}`;
23
36
  userReference?: never;
24
37
  userEmail?: never;
25
38
  forceError?: ForceErrors;
@@ -29,8 +42,8 @@ declare type ExistingDisclosureRequestProps = {
29
42
  declare type ForceErrors = 'facial_validation_error' | 'document_validation_error' | 'unknown_error' | 'expiration_error' | 'camera_permission_error';
30
43
 
31
44
  declare type NewDisclosureRequestProps = {
32
- companyId: string;
33
- templateId: string;
45
+ companyId: `com_${string}`;
46
+ templateId: `dtpl_${string}`;
34
47
  disclosureRequestId?: never;
35
48
  userReference: string;
36
49
  userEmail?: string;
@@ -49,7 +62,7 @@ declare type SignatureAttemptConfig = {
49
62
  };
50
63
 
51
64
  declare type SignatureAttemptProps = {
52
- signatureAttemptId: string;
65
+ signatureAttemptId: `sa_${string}`;
53
66
  forceError?: ForceErrors;
54
67
  customColor?: string;
55
68
  };
@@ -62,9 +75,11 @@ declare namespace SoyioTypes {
62
75
  ExistingDisclosureRequestProps,
63
76
  DisclosureRequestProps,
64
77
  SignatureAttemptProps,
78
+ AuthRequestProps,
65
79
  EventData,
66
80
  DisclosureRequestConfig,
67
81
  SignatureAttemptConfig,
82
+ AuthRequestConfig,
68
83
  AttemptConfig
69
84
  }
70
85
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soyio/soyio-widget",
3
- "version": "2.1.0",
3
+ "version": "2.2.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.umd.cjs",
6
6
  "module": "./dist/index.js",