@zkyc/evg 1.4.0 → 1.5.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/index.js +31 -1
- package/package.json +1 -1
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
|
|