@zkyc/evg 1.5.0 → 1.5.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.
- package/index.d.ts +13 -0
- package/index.js +16 -10
- package/package.json +9 -5
package/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface ZKYCConfig {
|
|
2
|
+
apiKey: string;
|
|
3
|
+
userId: string;
|
|
4
|
+
callbackUrl: string;
|
|
5
|
+
platformApiUrl?: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Generates a secure token and opens the zKYC popup
|
|
10
|
+
*/
|
|
11
|
+
export function ZKYCProcess(config: ZKYCConfig): Promise<void>;
|
|
12
|
+
|
|
13
|
+
export default ZKYCProcess;
|
package/index.js
CHANGED
|
@@ -28,9 +28,9 @@ async function ZKYCProcess(config) {
|
|
|
28
28
|
|
|
29
29
|
// Default to production platform API URL if not provided
|
|
30
30
|
// Users should set this to their platform URL (e.g., https://api.zkyc.tech)
|
|
31
|
-
const platformUrl = "https://
|
|
32
|
-
const tokenEndpoint = `${platformUrl}/api/
|
|
33
|
-
|
|
31
|
+
const platformUrl = "https://api.zkyc.tech";
|
|
32
|
+
const tokenEndpoint = `${platformUrl}/api/kyc/generate-token`;
|
|
33
|
+
console.log(tokenEndpoint)
|
|
34
34
|
try {
|
|
35
35
|
// Generate token from API key (server-side call)
|
|
36
36
|
const response = await fetch(tokenEndpoint, {
|
|
@@ -41,22 +41,28 @@ async function ZKYCProcess(config) {
|
|
|
41
41
|
body: JSON.stringify({ apikey: apiKey }),
|
|
42
42
|
});
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
44
|
+
if (!response.ok) {
|
|
45
|
+
const errorData = await response.json().catch(() => ({ error: "Unknown error" }));
|
|
46
|
+
throw new Error(`Token generation failed: ${errorData.error || response.statusText}`);
|
|
47
|
+
}
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
const result = await response.json();
|
|
50
50
|
|
|
51
|
+
if (!result.success) {
|
|
52
|
+
throw new Error("Token generation failed");
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const { token, expiresIn, expiresAt } = result.data;
|
|
51
56
|
if (!token) {
|
|
52
57
|
throw new Error("Token generation failed: No token received");
|
|
53
58
|
}
|
|
54
|
-
|
|
55
59
|
// Build SDK URL with token
|
|
56
|
-
const sdkUrl = new URL("https://
|
|
60
|
+
const sdkUrl = new URL("https://sdk.zkyc.tech/");
|
|
57
61
|
sdkUrl.searchParams.set("apiKey", token); // SDK will detect it's a token
|
|
58
62
|
sdkUrl.searchParams.set("userId", userId);
|
|
59
63
|
sdkUrl.searchParams.set("callbackUrl", callbackUrl);
|
|
64
|
+
sdkUrl.searchParams.set("platForm", "EVG");
|
|
65
|
+
|
|
60
66
|
|
|
61
67
|
// Redirect to SDK
|
|
62
68
|
if (typeof window !== "undefined") {
|
package/package.json
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zkyc/evg",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.3",
|
|
4
4
|
"description": "zKYC SDK wrapper to generate tokens and redirect to KYC",
|
|
5
5
|
"main": "index.js",
|
|
6
|
-
"
|
|
6
|
+
"types": "index.d.ts",
|
|
7
7
|
"type": "module",
|
|
8
|
-
"
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./index.js",
|
|
11
|
+
"types": "./index.d.ts"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
9
14
|
"keywords": [
|
|
10
15
|
"zkc",
|
|
11
16
|
"kyc",
|
|
@@ -13,6 +18,5 @@
|
|
|
13
18
|
"token"
|
|
14
19
|
],
|
|
15
20
|
"author": "Your Name",
|
|
16
|
-
"license": "MIT"
|
|
17
|
-
"dependencies": {}
|
|
21
|
+
"license": "MIT"
|
|
18
22
|
}
|