vult-security-kyc 0.0.1 → 0.0.3

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.
Files changed (2) hide show
  1. package/README.md +160 -49
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -9,77 +9,188 @@ The client side construction for the KYC Widget
9
9
  * [Typescript](https://www.typescriptlang.org/)
10
10
  * [Yarn](https://yarnpkg.com//)
11
11
 
12
+ ## Installation
13
+
14
+ Install the package using npm or yarn:
15
+
16
+ ```bash
17
+ npm install vult-security-kyc
18
+ # or
19
+ yarn add vult-security-kyc
20
+ ```
21
+
12
22
  ## Usage
13
23
 
24
+ The package provides two ways to use the KYC Widget:
25
+ 1. **Generic Class Usage** - Use the `KYCWidget` class directly for maximum flexibility
26
+ 2. **React Components** - Use the pre-built React components (`VULTIda` and `VULTIdv`)
27
+
28
+ ### Generic Class Usage
29
+
30
+ The `KYCWidget` class can be used in any JavaScript/TypeScript application (not just React). This gives you full control over when and how the widget is initialized and started.
31
+
14
32
  ```typescript
15
- window.addEventListener("load", () => {
16
- // Code to run once the entire page (including images) is fully loaded
17
- idv = new VultKYC.KYCWidget({
18
- onComplete: function () {
19
- console.log("The Kyc is completed.")
20
- },
21
- onDismiss:function(){
22
- // callback when dismissing modal by pressing/clicking on backdrop
23
- },
24
- Session_Type: VultKYC.IDV,
25
- })
26
- ida = new VultKYC.KYCWidget({
27
- onComplete: function () {
28
- console.log("The Kyc is completed.")
29
- },
30
- onDismiss:function(){
31
- // callback when dismissing modal by pressing/clicking on backdrop
32
- },
33
- Session_Type: VultKYC.IDA,
34
- })
33
+ import { KYCWidget, IDV, IDA } from 'vult-security-kyc';
34
+
35
+ // Initialize ID Verification widget
36
+ const idvWidget = new KYCWidget({
37
+ Session_Type: IDV, // or "IDVerification"
38
+ env: "dev", // Options: "dev" | "development" | "stage" | "demo" | "prod" | "production"
39
+ onComplete: (response) => {
40
+ console.log("ID Verification completed", response);
41
+ // Handle completion logic here
42
+ },
43
+ onDismiss: () => {
44
+ console.log("Widget dismissed");
45
+ // Handle dismissal logic here
46
+ }
47
+ });
48
+
49
+ // Start ID Verification with a session ID
50
+ function startVerification(sessionId: string) {
51
+ idvWidget.startIDVerify(sessionId);
52
+ }
53
+
54
+ // Initialize ID Authentication widget
55
+ const idaWidget = new KYCWidget({
56
+ Session_Type: IDA, // or "IDAuthentication"
57
+ env: "prod",
58
+ onComplete: (response) => {
59
+ console.log("ID Authentication completed", response);
60
+ },
61
+ onDismiss: () => {
62
+ console.log("Widget dismissed");
63
+ }
35
64
  });
36
65
 
37
- function onPressIDV() {
38
- idv.startIDVerify("e595a489-3706-4942-969d-17259db47b51")
66
+ // Start ID Authentication with a session ID
67
+ function startAuthentication(sessionId: string) {
68
+ idaWidget.startIDAuthenticate(sessionId);
39
69
  }
40
- function onPressIDA() {
41
- ida.startIDAuthenticate("beba906a-76aa-4231-a610-763f6fef8855")
70
+
71
+ // Close the widget programmatically
72
+ function closeWidget() {
73
+ idvWidget.close(); // or idaWidget.close()
42
74
  }
43
75
  ```
44
76
 
45
- The object needed to instantiate KYC widget.
77
+ **Configuration Interface:**
46
78
 
47
79
  ```typescript
48
- interface IKYCWidget {
49
- Session_Type: "IDVerification" | "IDAuthentication",
50
- onComplete?: () => void
51
- onDismiss?: () => void
80
+ interface KYCWidgetConfig {
81
+ Session_Type: "IDVerification" | "IDAuthentication";
82
+ env: "dev" | "development" | "stage" | "demo" | "prod" | "production";
83
+ onComplete?: (response?: any) => void;
84
+ onDismiss?: () => void;
52
85
  }
53
86
  ```
54
- ## Development
55
87
 
56
- ### Installing the Package Locally
88
+ ### IDA Component (ID Authentication)
57
89
 
58
- ```bash
59
- # Step 1: Clear yarn cache for the specific package
60
- yarn cache clean kyc-widget
90
+ For React applications, you can use the `VULTIda` component for ID Authentication. This component handles the widget lifecycle automatically.
61
91
 
62
- # Step 2: Verify it's cleared (should return nothing)
63
- yarn cache list | grep kyc-widget
92
+ ```typescript
93
+ import { useState } from 'react';
94
+ import { VULTIda } from 'vult-security-kyc/components';
95
+ import type { VULTProps } from 'vult-security-kyc/components';
96
+
97
+ function MyComponent() {
98
+ const [sessionId, setSessionId] = useState<string>('');
99
+
100
+ const handleComplete = () => {
101
+ console.log('ID Authentication completed');
102
+ // Handle completion logic
103
+ };
104
+
105
+ const handleDismiss = () => {
106
+ console.log('Widget dismissed');
107
+ // Handle dismissal logic
108
+ };
109
+
110
+ return (
111
+ <div>
112
+ <button onClick={() => setSessionId('your-session-id-here')}>
113
+ Start ID Authentication
114
+ </button>
115
+
116
+ {sessionId && (
117
+ <VULTIda
118
+ sessionId={sessionId}
119
+ environment="prod"
120
+ autoClose={true}
121
+ onComplete={handleComplete}
122
+ onDismiss={handleDismiss}
123
+ />
124
+ )}
125
+ </div>
126
+ );
127
+ }
128
+ ```
64
129
 
65
- # Step 3: Remove the package from node_modules (you already did this)
66
- rm -rf node_modules/kyc-widget
130
+ **VULTIda Props:**
67
131
 
68
- # Step 4: Remove yarn.lock entry if it exists (optional but recommended)
69
- # Manually edit yarn.lock to remove kyc-widget entries, or:
132
+ ```typescript
133
+ interface VULTProps {
134
+ sessionId: string; // Required: The session ID for authentication
135
+ environment: "dev" | "development" | "stage" | "demo" | "prod" | "production"; // Required
136
+ autoClose?: boolean; // Optional: Automatically close widget on completion (default: true)
137
+ onComplete?: () => void; // Optional: Callback when authentication completes
138
+ onDismiss?: () => void; // Optional: Callback when widget is dismissed
139
+ }
140
+ ```
70
141
 
71
- # Step 5: Clear yarn's entire cache (nuclear option if step 1 doesn't work)
72
- yarn cache clean
142
+ ### IDV Component (ID Verification)
73
143
 
74
- # Step 6: Remove node_modules and yarn.lock (if you want completely fresh install)
75
- rm -rf node_modules
76
- rm yarn.lock
144
+ For React applications, you can use the `VULTIdv` component for ID Verification. This component handles the widget lifecycle automatically.
77
145
 
78
- # Step 7: Reinstall everything
79
- yarn install
146
+ ```typescript
147
+ import { useState } from 'react';
148
+ import { VULTIdv } from 'vult-security-kyc/components';
149
+ import type { VULTProps } from 'vult-security-kyc/components';
150
+
151
+ function MyComponent() {
152
+ const [sessionId, setSessionId] = useState<string>('');
153
+
154
+ const handleComplete = () => {
155
+ console.log('ID Verification completed');
156
+ // Handle completion logic
157
+ };
158
+
159
+ const handleDismiss = () => {
160
+ console.log('Widget dismissed');
161
+ // Handle dismissal logic
162
+ };
163
+
164
+ return (
165
+ <div>
166
+ <button onClick={() => setSessionId('your-session-id-here')}>
167
+ Start ID Verification
168
+ </button>
169
+
170
+ {sessionId && (
171
+ <VULTIdv
172
+ sessionId={sessionId}
173
+ environment="dev"
174
+ autoClose={true}
175
+ onComplete={handleComplete}
176
+ onDismiss={handleDismiss}
177
+ />
178
+ )}
179
+ </div>
180
+ );
181
+ }
182
+ ```
80
183
 
81
- # Step 8: Then add your local package
82
- yarn add ./path/to/kyc-widget-2.0.0.tgz
184
+ **VULTIdv Props:**
185
+
186
+ ```typescript
187
+ interface VULTProps {
188
+ sessionId: string; // Required: The session ID for verification
189
+ environment: "dev" | "development" | "stage" | "demo" | "prod" | "production"; // Required
190
+ autoClose?: boolean; // Optional: Automatically close widget on completion (default: true)
191
+ onComplete?: () => void; // Optional: Callback when verification completes
192
+ onDismiss?: () => void; // Optional: Callback when widget is dismissed
193
+ }
83
194
  ```
84
195
 
85
196
  ## Licensing
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vult-security-kyc",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "description": "typescript widget",
5
5
  "author": "Nexrage",
6
6
  "license": "ISC",
@@ -50,7 +50,7 @@
50
50
  "preview": "vite preview"
51
51
  },
52
52
  "dependencies": {
53
- "isomorphic-dompurify": "^2.15.0"
53
+ "isomorphic-dompurify": "2.30.0"
54
54
  },
55
55
  "peerDependencies": {
56
56
  "react": ">=16.8.0",