@soyio/soyio-widget 1.0.0 → 1.0.2

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
@@ -39,7 +39,7 @@ Integrate the widget into your frontend framework using the script below. Ensure
39
39
  userEmail: "<user email>",
40
40
  flowTemplateId: "<flow template id>",
41
41
  identityId: "<identity id>",
42
- forceError: 'no_error'
42
+ forceError: "<error type>",
43
43
  },
44
44
  onEvent: (data) => console.log(data),
45
45
  isSandbox: true,
@@ -58,12 +58,11 @@ Integrate the widget into your frontend framework using the script below. Ensure
58
58
  - **`companyId`**: The unique identifier for the company, must start with `'com_'`.
59
59
  - **`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.
60
60
  - **`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.
61
+ - **`forceError`**: (Optional) Triggers specific errors for testing or debugging. Used to simulate failure scenarios.
61
62
  - **`flowTemplateId`**: : Required only in the `'register'` flow, this identifier specifies the order and quantity of documents requested from the user. It must start with `'vft_'`.
62
63
  - **`identityId`**: Necessary only in the `'authenticate'` flow, this identifier must start with `'id_'` and signifies the user's identity.
63
64
  - **`onEvent`**: A callback function triggered upon event occurrences, used for capturing and logging event-related data.
64
65
  - **`isSandbox`**: (Optional) Indicates if the widget should operate in sandbox mode, defaulting to `false`.
65
- - **`forceError`**: (Optional) Enum with two values (`no_error` and `validation_error`). Only valid for sandbox environment. Indicates if the flow should simulate a failed validation response.
66
-
67
66
 
68
67
  #### Events
69
68
 
@@ -87,3 +86,12 @@ The `onEvent` callback is designed to handle various events that occur during wi
87
86
 
88
87
  - **`WIDGET_OPENED`**: This event occurs when the user closes the `Soyio` pop up. The event object is as follows:
89
88
  - `{ eventName: 'WIDGET_CLOSED' }`.
89
+
90
+ #### Error types
91
+
92
+ The `forceError` parameter can simulate the following error conditions:
93
+
94
+ - `'user_exists'`: Triggers an error indicating that a user with the given credentials already exists in the system.
95
+ - `'facial_validation_error'`: Simulates a failure in the facial video liveness test, indicating the system could not verify the user's live presence.
96
+ - `'document_validation_error'`: Indicates an issue with validating the photos of the documents provided by the user.
97
+ - `'unknown_error'`: Generates a generic error, representing an unspecified problem.
package/dist/index.d.ts CHANGED
@@ -1,3 +1,39 @@
1
- export * from './src/index'
2
- import SoyioWidget from './src/index'
3
- export default SoyioWidget
1
+ declare type ConfigProps = {
2
+ companyId: string;
3
+ userReference?: string;
4
+ flowTemplateId?: string;
5
+ userEmail?: string;
6
+ identityId?: string;
7
+ forceError?: SoyioErrors;
8
+ };
9
+
10
+ declare type EventData = {
11
+ eventName: 'IDENTITY_REGISTERED' | 'IDENTITY_AUTHENTICATED';
12
+ identityId: string;
13
+ userReference?: string;
14
+ };
15
+
16
+ declare type Flow = 'authenticate' | 'register';
17
+
18
+ declare type SoyioErrors = 'user_exists' | 'facial_validation_error' | 'document_validation_error' | 'unknown_error';
19
+
20
+ declare class Widget {
21
+ #private;
22
+ private flow;
23
+ private configProps;
24
+ private onEvent;
25
+ private isSandbox;
26
+ constructor(options: WidgetConfig);
27
+ validateProps(): void;
28
+ }
29
+ export default Widget;
30
+
31
+ declare type WidgetConfig = {
32
+ flow: Flow;
33
+ configProps: Partial<ConfigProps>;
34
+ onEvent: (data: EventData) => void;
35
+ isSandbox?: boolean;
36
+ developmentUrl?: string;
37
+ };
38
+
39
+ export { }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soyio/soyio-widget",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "type": "module",
5
5
  "main": "./dist/index.umd.cjs",
6
6
  "module": "./dist/index.js",
@@ -1,6 +0,0 @@
1
- export declare const CONTAINER_ID = "soyio-widget-iframe-container";
2
- export declare const IFRAME_ID = "soyio-widget-iframe";
3
- export declare const PRODUCTION_URL = "https://app.soyio.id/widget";
4
- export declare const SANDBOX_URL = "https://sandbox.soyio.id/widget";
5
- export declare const FINISHING_EVENTS: string[];
6
- export declare const CLOSED_EVENT = "WIDGET_CLOSED";
@@ -1,3 +0,0 @@
1
- declare function setReady(iframe: HTMLIFrameElement): void;
2
- declare function setConfig(iframe: HTMLIFrameElement, config: Partial<ConfigProps>): void;
3
- export { setReady, setConfig };
@@ -1,10 +0,0 @@
1
- declare class Widget {
2
- #private;
3
- private flow;
4
- private configProps;
5
- private onEvent;
6
- private isSandbox;
7
- constructor(options: WidgetConfig);
8
- validateProps(): void;
9
- }
10
- export default Widget;
@@ -1,5 +0,0 @@
1
- type Hooks = {
2
- onEvent: (event: any) => void;
3
- };
4
- export declare function setListeners(hooks: Hooks): void;
5
- export {};
@@ -1 +0,0 @@
1
- export declare function getFullUrl(flow: Flow, configProps: Partial<ConfigProps>, isSandbox: boolean, developmentUrl: string | undefined): string;
@@ -1,3 +0,0 @@
1
- export declare function showPopUp(flow: Flow, configProps: Partial<ConfigProps>, isSandbox: boolean, developmentUrl: string | undefined): void;
2
- export declare function clearOverlayEffects(): void;
3
- export declare function removePopUp(): void;
@@ -1,2 +0,0 @@
1
- declare const _default: import("vite").UserConfig;
2
- export default _default;