@zkyc/evg 1.4.0 → 1.5.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/index.d.ts +13 -0
- package/index.js +31 -1
- 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
|
@@ -86,13 +86,43 @@ function openZKYCPopup(url) {
|
|
|
86
86
|
url,
|
|
87
87
|
"ZKYC_Popup",
|
|
88
88
|
`width=${width},height=${height},left=${left},top=${top},
|
|
89
|
-
resizable=yes,scrollbars=yes,toolbar=no,menubar=no,status=no
|
|
89
|
+
resizable=yes,scrollbars=yes,toolbar=no,menubar=no,status=no`,"_self"
|
|
90
90
|
);
|
|
91
91
|
|
|
92
92
|
if (!popup) {
|
|
93
93
|
throw new Error("Popup blocked. Please allow popups.");
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
+
// ✅ LISTEN FOR SDK EVENTS HERE
|
|
97
|
+
const handleMessage = (event) => {
|
|
98
|
+
console.log("🔵 MESSAGE RECEIVED", {
|
|
99
|
+
origin: event.origin,
|
|
100
|
+
data: event.data,
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
window.addEventListener("message", handleMessage);
|
|
105
|
+
// 🔒 Security check — VERY IMPORTANT
|
|
106
|
+
|
|
107
|
+
if (event.origin !== "https://evg.zkyc.tech") return;
|
|
108
|
+
|
|
109
|
+
if (event.data?.type === "KYC_SUBMITTED") {
|
|
110
|
+
popup.close();
|
|
111
|
+
window.removeEventListener("message", handleMessage);
|
|
112
|
+
|
|
113
|
+
// Optional: notify host app
|
|
114
|
+
console.log("KYC flow completed");
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (event.data?.type === "KYC_ERROR") {
|
|
118
|
+
popup.close();
|
|
119
|
+
window.removeEventListener("message", handleMessage);
|
|
120
|
+
console.error("KYC failed");
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
window.addEventListener("message", handleMessage);
|
|
125
|
+
|
|
96
126
|
popup.focus();
|
|
97
127
|
}
|
|
98
128
|
|
package/package.json
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zkyc/evg",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.2",
|
|
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
|
}
|