@zerohash-sdk/crypto-deposits-react 0.5.14 → 0.5.15
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/dist/index.js +61 -59
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -9,24 +9,26 @@ var s = {
|
|
|
9
9
|
"eu-prod": "https://grafana-faro-collector.zerohash.eu/collect",
|
|
10
10
|
sandbox: "https://grafana-faro-collector.cert.zerohash.com/collect",
|
|
11
11
|
production: "https://grafana-faro-collector.zerohash.com/collect"
|
|
12
|
-
}, c = (e) => {
|
|
12
|
+
}, c = (e) => typeof e == "object" && !!e && !Array.isArray(e), l = (e) => {
|
|
13
13
|
if (!e || typeof e != "string") return null;
|
|
14
14
|
let t = e.split(".");
|
|
15
15
|
if (t.length < 2) return null;
|
|
16
16
|
try {
|
|
17
|
-
let e = t[1].replace(/-/g, "+").replace(/_/g, "/"), n = e + "===".slice(0, (4 - e.length % 4) % 4), r = typeof atob < "u" ? atob(n) : Buffer.from(n, "base64").toString("utf-8"), i = JSON.parse(r)
|
|
18
|
-
if (typeof
|
|
19
|
-
let
|
|
20
|
-
return
|
|
17
|
+
let e = t[1].replace(/-/g, "+").replace(/_/g, "/"), n = e + "===".slice(0, (4 - e.length % 4) % 4), r = typeof atob < "u" ? atob(n) : Buffer.from(n, "base64").toString("utf-8"), i = JSON.parse(r), a = c(i) ? i.payload : void 0, o = c(a) ? a.region : void 0;
|
|
18
|
+
if (typeof o != "string") return null;
|
|
19
|
+
let s = o.toLowerCase();
|
|
20
|
+
return s === "us" || s === "eu" ? s : null;
|
|
21
21
|
} catch {
|
|
22
22
|
return null;
|
|
23
23
|
}
|
|
24
|
-
},
|
|
24
|
+
}, u = (e, t) => l(t) === "eu" ? e === "cert" ? "eu-cert" : e === "prod" ? "eu-prod" : e : e, d = (e) => {
|
|
25
25
|
if (!e || typeof e != "string") return {};
|
|
26
26
|
let t = e.split(".");
|
|
27
27
|
if (t.length < 2) return {};
|
|
28
28
|
try {
|
|
29
|
-
let e = t[1].replace(/-/g, "+").replace(/_/g, "/"), n = e + "===".slice(0, (4 - e.length % 4) % 4), r = typeof atob < "u" ? atob(n) : Buffer.from(n, "base64").toString("utf-8"), i = JSON.parse(r)
|
|
29
|
+
let e = t[1].replace(/-/g, "+").replace(/_/g, "/"), n = e + "===".slice(0, (4 - e.length % 4) % 4), r = typeof atob < "u" ? atob(n) : Buffer.from(n, "base64").toString("utf-8"), i = JSON.parse(r);
|
|
30
|
+
if (!c(i)) return {};
|
|
31
|
+
let a = c(i.payload) ? i.payload : {}, o = (e) => typeof e == "string" && e.length > 0 ? e : void 0;
|
|
30
32
|
return {
|
|
31
33
|
participantCode: o(a.participant_code),
|
|
32
34
|
platformName: o(a.platform_name),
|
|
@@ -36,12 +38,12 @@ var s = {
|
|
|
36
38
|
} catch {
|
|
37
39
|
return {};
|
|
38
40
|
}
|
|
39
|
-
},
|
|
41
|
+
}, f = (e, t, n) => e[u(t, n)] ?? e[t] ?? e.prod, p = (e, t, n) => e[u(t, n)] ?? e[t], m = () => void 0, h = () => {
|
|
40
42
|
let e = /* @__PURE__ */ new Uint8Array(8);
|
|
41
43
|
return globalThis.crypto.getRandomValues(e), Array.from(e, (e) => e.toString(16).padStart(2, "0")).join("");
|
|
42
|
-
},
|
|
43
|
-
let n =
|
|
44
|
-
return e.claims.participantCode && (
|
|
44
|
+
}, g = (e, t) => {
|
|
45
|
+
let n = h(), r = Reflect.get(globalThis, "__ZH_WEB_SDK_VERSION__"), i = typeof r == "string" ? r : void 0, a = {};
|
|
46
|
+
return e.claims.participantCode && (a.participant_code = e.claims.participantCode), e.claims.platformName && (a.platform_name = e.claims.platformName), e.claims.platformCode && (a.platform_code = e.claims.platformCode), e.claims.region && (a.region = e.claims.region), i && (a.zh_web_sdk_version = i), {
|
|
45
47
|
sessionId: n,
|
|
46
48
|
payload: {
|
|
47
49
|
meta: {
|
|
@@ -52,7 +54,7 @@ var s = {
|
|
|
52
54
|
},
|
|
53
55
|
session: {
|
|
54
56
|
id: n,
|
|
55
|
-
attributes:
|
|
57
|
+
attributes: a
|
|
56
58
|
},
|
|
57
59
|
browser: typeof navigator < "u" ? { userAgent: navigator.userAgent } : void 0,
|
|
58
60
|
page: typeof window < "u" ? { url: window.location.origin } : void 0
|
|
@@ -71,9 +73,9 @@ var s = {
|
|
|
71
73
|
}]
|
|
72
74
|
}
|
|
73
75
|
};
|
|
74
|
-
},
|
|
76
|
+
}, _ = (e, t, n) => {
|
|
75
77
|
if (!e || typeof fetch > "u") return;
|
|
76
|
-
let { sessionId: r, payload: i } =
|
|
78
|
+
let { sessionId: r, payload: i } = g(t, n);
|
|
77
79
|
try {
|
|
78
80
|
fetch(e, {
|
|
79
81
|
method: "POST",
|
|
@@ -85,12 +87,12 @@ var s = {
|
|
|
85
87
|
keepalive: !0
|
|
86
88
|
}).catch(() => void 0);
|
|
87
89
|
} catch {}
|
|
88
|
-
},
|
|
89
|
-
let { webComponentTag: t, appName: n, appVersion: r, scriptUrls: i, fallbackScriptUrls: a, collectorUrls: o, env: s, jwt: c, timeoutMs: l = 15e3, onLoad:
|
|
90
|
-
if (typeof document > "u") return
|
|
91
|
-
let
|
|
92
|
-
if (customElements.get(t) || document.getElementById(
|
|
93
|
-
let v =
|
|
90
|
+
}, v = (e) => {
|
|
91
|
+
let { webComponentTag: t, appName: n, appVersion: r, scriptUrls: i, fallbackScriptUrls: a, collectorUrls: o, env: s, jwt: c, timeoutMs: l = 15e3, onLoad: u, onError: h } = e;
|
|
92
|
+
if (typeof document > "u") return m;
|
|
93
|
+
let g = `${t}-script-${s}`;
|
|
94
|
+
if (customElements.get(t) || document.getElementById(g)) return m;
|
|
95
|
+
let v = d(c), y = e.report ?? ((e) => _(o && p(o, s, c), e, r)), b = !1, x = 0, S, C = () => {
|
|
94
96
|
S !== void 0 && clearTimeout(S);
|
|
95
97
|
}, w = (e, r, i) => {
|
|
96
98
|
if (b) return;
|
|
@@ -105,25 +107,25 @@ var s = {
|
|
|
105
107
|
claims: v
|
|
106
108
|
};
|
|
107
109
|
y(l);
|
|
108
|
-
let u = i ? void 0 :
|
|
110
|
+
let u = i ? void 0 : f(a ?? {}, s, c);
|
|
109
111
|
if (u && u !== r) {
|
|
110
112
|
T(u, !0);
|
|
111
113
|
return;
|
|
112
114
|
}
|
|
113
|
-
b = !0, C(), document.getElementById(
|
|
115
|
+
b = !0, C(), document.getElementById(g)?.remove(), h?.(l);
|
|
114
116
|
}, T = (e, n) => {
|
|
115
117
|
C(), x = performance.now();
|
|
116
118
|
let r = document.createElement("script");
|
|
117
|
-
r.id =
|
|
119
|
+
r.id = g, r.src = e, r.type = "module", r.async = !0, r.addEventListener("load", () => {
|
|
118
120
|
setTimeout(() => {
|
|
119
|
-
b || (customElements.get(t) ? (b = !0, C(),
|
|
121
|
+
b || (customElements.get(t) ? (b = !0, C(), u?.()) : w("not-defined", e, n));
|
|
120
122
|
}, 0);
|
|
121
|
-
}, r.
|
|
122
|
-
}, E =
|
|
123
|
+
}), r.addEventListener("error", () => w("network", e, n)), S = setTimeout(() => w("timeout", e, n), l), document.getElementById(g)?.remove(), document.head.appendChild(r);
|
|
124
|
+
}, E = f(i, s, c);
|
|
123
125
|
return E ? (T(E, !1), () => {
|
|
124
126
|
b = !0, C();
|
|
125
|
-
}) :
|
|
126
|
-
},
|
|
127
|
+
}) : m;
|
|
128
|
+
}, y = {
|
|
127
129
|
local: {
|
|
128
130
|
BASE_URL: "/",
|
|
129
131
|
DEV: !1,
|
|
@@ -150,34 +152,34 @@ var s = {
|
|
|
150
152
|
prod: "https://sdk-cdn.zerohash.com",
|
|
151
153
|
"eu-cert": "https://sdk-cdn.cert.zerohash.eu",
|
|
152
154
|
"eu-prod": "https://sdk-cdn.zerohash.eu"
|
|
153
|
-
},
|
|
154
|
-
let { eu: r = !1, legacyAliases: i = !1, local: a =
|
|
155
|
+
}, b = "https://sdk-cdn.gating.0hash.com", x = (e, t, n = {}) => {
|
|
156
|
+
let { eu: r = !1, legacyAliases: i = !1, local: a = y.local } = n, o = (n) => `${n}/${e}/${t}`, s = {
|
|
155
157
|
local: o(a),
|
|
156
|
-
dev: o(
|
|
157
|
-
gating: o(
|
|
158
|
-
cert: o(
|
|
159
|
-
prod: o(
|
|
158
|
+
dev: o(y.dev),
|
|
159
|
+
gating: o(b),
|
|
160
|
+
cert: o(y.cert),
|
|
161
|
+
prod: o(y.prod)
|
|
160
162
|
};
|
|
161
|
-
return i && (s.sandbox = o(
|
|
163
|
+
return i && (s.sandbox = o(y.cert), s.production = o(y.prod)), r && (s["eu-cert"] = o(y["eu-cert"]), s["eu-prod"] = o(y["eu-prod"])), s;
|
|
162
164
|
};
|
|
163
|
-
[...Object.entries(
|
|
165
|
+
[...Object.entries(y).filter(([e]) => e !== "local").map(([, e]) => e)], {
|
|
164
166
|
LOADED: "travel_rule_loaded",
|
|
165
167
|
COMPLETED: "travel_rule_completed"
|
|
166
168
|
}.LOADED;
|
|
167
169
|
//#endregion
|
|
168
170
|
//#region ../../../common/callbacks/dist/shared/models.js
|
|
169
|
-
var
|
|
171
|
+
var S;
|
|
170
172
|
(function(e) {
|
|
171
173
|
e.NETWORK_ERROR = "network_error", e.AUTH_ERROR = "auth_error", e.NOT_FOUND_ERROR = "not_found_error", e.VALIDATION_ERROR = "validation_error", e.SERVER_ERROR = "server_error", e.CLIENT_ERROR = "client_error", e.UNKNOWN_ERROR = "unknown_error";
|
|
172
|
-
})(
|
|
174
|
+
})(S ||= {});
|
|
173
175
|
//#endregion
|
|
174
176
|
//#region ../../../common/react-sdk-base/dist/script-load-fallback.js
|
|
175
|
-
var
|
|
177
|
+
var C = {
|
|
176
178
|
evergreen: "#00381D",
|
|
177
179
|
green: "#CCFFD0",
|
|
178
180
|
offBlack: "#1C1B1C",
|
|
179
181
|
grayLight: "#EBEBE9"
|
|
180
|
-
},
|
|
182
|
+
}, w = ({ onRetry: n, onClose: r }) => t("div", {
|
|
181
183
|
role: "alert",
|
|
182
184
|
style: {
|
|
183
185
|
position: "relative",
|
|
@@ -190,9 +192,9 @@ var S = {
|
|
|
190
192
|
padding: "32px 24px",
|
|
191
193
|
textAlign: "center",
|
|
192
194
|
fontFamily: "inherit",
|
|
193
|
-
color:
|
|
195
|
+
color: C.offBlack,
|
|
194
196
|
background: "#FFFFFF",
|
|
195
|
-
border: `1px solid ${
|
|
197
|
+
border: `1px solid ${C.grayLight}`,
|
|
196
198
|
borderRadius: "12px"
|
|
197
199
|
},
|
|
198
200
|
children: [
|
|
@@ -206,7 +208,7 @@ var S = {
|
|
|
206
208
|
right: "12px",
|
|
207
209
|
display: "flex",
|
|
208
210
|
padding: "4px",
|
|
209
|
-
color:
|
|
211
|
+
color: C.offBlack,
|
|
210
212
|
background: "none",
|
|
211
213
|
border: "none",
|
|
212
214
|
cursor: "pointer",
|
|
@@ -235,7 +237,7 @@ var S = {
|
|
|
235
237
|
"aria-hidden": "true",
|
|
236
238
|
children: e("path", {
|
|
237
239
|
d: "M12 9v4m0 4h.01M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z",
|
|
238
|
-
stroke:
|
|
240
|
+
stroke: C.evergreen,
|
|
239
241
|
strokeWidth: "1.5",
|
|
240
242
|
strokeLinecap: "round",
|
|
241
243
|
strokeLinejoin: "round"
|
|
@@ -266,8 +268,8 @@ var S = {
|
|
|
266
268
|
fontSize: "14px",
|
|
267
269
|
fontWeight: 600,
|
|
268
270
|
fontFamily: "inherit",
|
|
269
|
-
color:
|
|
270
|
-
background:
|
|
271
|
+
color: C.green,
|
|
272
|
+
background: C.evergreen,
|
|
271
273
|
border: "none",
|
|
272
274
|
borderRadius: "8px",
|
|
273
275
|
cursor: "pointer"
|
|
@@ -275,14 +277,14 @@ var S = {
|
|
|
275
277
|
children: "Try again"
|
|
276
278
|
})
|
|
277
279
|
]
|
|
278
|
-
}),
|
|
280
|
+
}), T = (e, t) => {
|
|
279
281
|
i(() => {
|
|
280
282
|
let n = e.current;
|
|
281
|
-
if (n) for (let [e, r] of Object.entries(t)) r !== void 0 && (n
|
|
283
|
+
if (n) for (let [e, r] of Object.entries(t)) r !== void 0 && Reflect.set(n, e, r);
|
|
282
284
|
});
|
|
283
|
-
},
|
|
284
|
-
let { webComponentTag: t, appName: n, appVersion: a, scriptUrls: c, fallbackScriptUrls: l, collectorUrls: u, env: d, jwt: f, timeoutMs: p } = e, [m, h] = o(!1), [g,
|
|
285
|
-
return i(() => (h(!1),
|
|
285
|
+
}, E = (e) => {
|
|
286
|
+
let { webComponentTag: t, appName: n, appVersion: a, scriptUrls: c, fallbackScriptUrls: l, collectorUrls: u, env: d, jwt: f, timeoutMs: p } = e, [m, h] = o(!1), [g, _] = o(0);
|
|
287
|
+
return i(() => (h(!1), v({
|
|
286
288
|
webComponentTag: t,
|
|
287
289
|
appName: n ?? t,
|
|
288
290
|
appVersion: a,
|
|
@@ -306,11 +308,11 @@ var S = {
|
|
|
306
308
|
g
|
|
307
309
|
]), {
|
|
308
310
|
loadFailed: m,
|
|
309
|
-
retry: r(() =>
|
|
311
|
+
retry: r(() => _((e) => e + 1), [])
|
|
310
312
|
};
|
|
311
|
-
},
|
|
313
|
+
}, D = x("crypto-deposits-web", "index.js", { eu: !0 }), O = "zerohash-crypto-deposits", k = ({ jwt: t, env: r = "prod", theme: i, appRedirectUrl: o, onCompleted: s, onFailed: c, onDeposit: l, onError: u, onClose: d, onLoaded: f, onEvent: p, ...m }) => {
|
|
312
314
|
let h = a(null);
|
|
313
|
-
|
|
315
|
+
T(h, {
|
|
314
316
|
theme: i,
|
|
315
317
|
onCompleted: s,
|
|
316
318
|
onFailed: c,
|
|
@@ -320,13 +322,13 @@ var S = {
|
|
|
320
322
|
onLoaded: f,
|
|
321
323
|
onEvent: p
|
|
322
324
|
});
|
|
323
|
-
let { loadFailed: g, retry: _ } =
|
|
324
|
-
webComponentTag:
|
|
325
|
-
scriptUrls:
|
|
325
|
+
let { loadFailed: g, retry: _ } = E({
|
|
326
|
+
webComponentTag: O,
|
|
327
|
+
scriptUrls: D,
|
|
326
328
|
env: r,
|
|
327
329
|
jwt: t
|
|
328
330
|
});
|
|
329
|
-
return g ? /* @__PURE__ */ e(
|
|
331
|
+
return g ? /* @__PURE__ */ e(w, { onRetry: _ }) : n.createElement(O, {
|
|
330
332
|
ref: h,
|
|
331
333
|
jwt: t,
|
|
332
334
|
env: r,
|
|
@@ -336,4 +338,4 @@ var S = {
|
|
|
336
338
|
});
|
|
337
339
|
};
|
|
338
340
|
//#endregion
|
|
339
|
-
export {
|
|
341
|
+
export { k as CryptoDeposits };
|