@zerohash-sdk/fiat-account-link-react 1.15.16 → 1.15.18
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 +97 -83
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as e, jsxs as t } from "react/jsx-runtime";
|
|
2
|
-
import n, { useCallback as r, useEffect as i,
|
|
2
|
+
import n, { useCallback as r, useEffect as i, useMemo as a, useRef as o, useState as s } from "react";
|
|
3
3
|
//#region ../../../common/js-sdk-base/dist/constants.js
|
|
4
|
-
var
|
|
4
|
+
var c = {
|
|
5
5
|
dev: "https://grafana-faro-collector.dev.0hash.com/collect",
|
|
6
6
|
cert: "https://grafana-faro-collector.cert.zerohash.com/collect",
|
|
7
7
|
prod: "https://grafana-faro-collector.zerohash.com/collect",
|
|
@@ -9,26 +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
|
-
},
|
|
12
|
+
}, l = (e) => typeof e == "object" && !!e && !Array.isArray(e), u = (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), a =
|
|
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 = l(i) ? i.payload : void 0, o = l(a) ? a.region : void 0;
|
|
18
18
|
if (typeof o != "string") return null;
|
|
19
19
|
let s = o.toLowerCase();
|
|
20
20
|
return s === "us" || s === "eu" ? s : null;
|
|
21
21
|
} catch {
|
|
22
22
|
return null;
|
|
23
23
|
}
|
|
24
|
-
},
|
|
24
|
+
}, d = (e, t) => u(t) === "eu" ? e === "cert" ? "eu-cert" : e === "prod" ? "eu-prod" : e : e, f = (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
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 (!
|
|
31
|
-
let a =
|
|
30
|
+
if (!l(i)) return {};
|
|
31
|
+
let a = l(i.payload) ? i.payload : {}, o = (e) => typeof e == "string" && e.length > 0 ? e : void 0;
|
|
32
32
|
return {
|
|
33
33
|
participantCode: o(a.participant_code),
|
|
34
34
|
platformName: o(a.platform_name),
|
|
@@ -38,11 +38,11 @@ var s = {
|
|
|
38
38
|
} catch {
|
|
39
39
|
return {};
|
|
40
40
|
}
|
|
41
|
-
},
|
|
41
|
+
}, p = (e, t, n) => e[d(t, n)] ?? e[t] ?? e.prod, m = (e, t, n) => e[d(t, n)] ?? e[t], h = () => void 0, g = () => {
|
|
42
42
|
let e = /* @__PURE__ */ new Uint8Array(8);
|
|
43
43
|
return globalThis.crypto.getRandomValues(e), Array.from(e, (e) => e.toString(16).padStart(2, "0")).join("");
|
|
44
|
-
},
|
|
45
|
-
let n =
|
|
44
|
+
}, _ = (e, t) => {
|
|
45
|
+
let n = g(), r = Reflect.get(globalThis, "__ZH_WEB_SDK_VERSION__"), i = typeof r == "string" ? r : void 0, a = {};
|
|
46
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), {
|
|
47
47
|
sessionId: n,
|
|
48
48
|
payload: {
|
|
@@ -73,26 +73,28 @@ var s = {
|
|
|
73
73
|
}]
|
|
74
74
|
}
|
|
75
75
|
};
|
|
76
|
-
},
|
|
76
|
+
}, v = (e, t, n) => {
|
|
77
77
|
if (!e || typeof fetch > "u") return;
|
|
78
|
-
let { sessionId: r, payload: i } =
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
|
|
78
|
+
let { sessionId: r, payload: i } = _(t, n);
|
|
79
|
+
(async () => {
|
|
80
|
+
try {
|
|
81
|
+
await fetch(e, {
|
|
82
|
+
method: "POST",
|
|
83
|
+
headers: {
|
|
84
|
+
"Content-Type": "application/json",
|
|
85
|
+
"x-faro-session-id": r
|
|
86
|
+
},
|
|
87
|
+
body: JSON.stringify(i),
|
|
88
|
+
keepalive: !0
|
|
89
|
+
});
|
|
90
|
+
} catch {}
|
|
91
|
+
})();
|
|
92
|
+
}, y = (e) => {
|
|
93
|
+
let { webComponentTag: t, appName: n, appVersion: r, scriptUrls: i, fallbackScriptUrls: a, collectorUrls: o, env: s, jwt: c, timeoutMs: l = 15e3, onLoad: u, onError: d } = e;
|
|
94
|
+
if (typeof document > "u") return h;
|
|
93
95
|
let g = `${t}-script-${s}`;
|
|
94
|
-
if (customElements.get(t) || document.getElementById(g)) return
|
|
95
|
-
let
|
|
96
|
+
if (customElements.get(t) || document.getElementById(g)) return h;
|
|
97
|
+
let _ = f(c), y = e.report ?? ((e) => v(o && m(o, s, c), e, r)), b = !1, x = 0, S, C = () => {
|
|
96
98
|
S !== void 0 && clearTimeout(S);
|
|
97
99
|
}, w = (e, r, i) => {
|
|
98
100
|
if (b) return;
|
|
@@ -104,15 +106,15 @@ var s = {
|
|
|
104
106
|
reason: e,
|
|
105
107
|
triedFallback: i,
|
|
106
108
|
elapsedMs: o,
|
|
107
|
-
claims:
|
|
109
|
+
claims: _
|
|
108
110
|
};
|
|
109
111
|
y(l);
|
|
110
|
-
let u = i ? void 0 :
|
|
112
|
+
let u = i ? void 0 : p(a ?? {}, s, c);
|
|
111
113
|
if (u && u !== r) {
|
|
112
114
|
T(u, !0);
|
|
113
115
|
return;
|
|
114
116
|
}
|
|
115
|
-
b = !0, C(), document.getElementById(g)?.remove(),
|
|
117
|
+
b = !0, C(), document.getElementById(g)?.remove(), d?.(l);
|
|
116
118
|
}, T = (e, n) => {
|
|
117
119
|
C(), x = performance.now();
|
|
118
120
|
let r = document.createElement("script");
|
|
@@ -121,11 +123,11 @@ var s = {
|
|
|
121
123
|
b || (customElements.get(t) ? (b = !0, C(), u?.()) : w("not-defined", e, n));
|
|
122
124
|
}, 0);
|
|
123
125
|
}), r.addEventListener("error", () => w("network", e, n)), S = setTimeout(() => w("timeout", e, n), l), document.getElementById(g)?.remove(), document.head.appendChild(r);
|
|
124
|
-
}, E =
|
|
126
|
+
}, E = p(i, s, c);
|
|
125
127
|
return E ? (T(E, !1), () => {
|
|
126
128
|
b = !0, C();
|
|
127
|
-
}) :
|
|
128
|
-
},
|
|
129
|
+
}) : h;
|
|
130
|
+
}, b = () => "1.15.18", x = {
|
|
129
131
|
local: {
|
|
130
132
|
BASE_URL: "/",
|
|
131
133
|
DEV: !1,
|
|
@@ -145,41 +147,42 @@ var s = {
|
|
|
145
147
|
VITE_REDIRECT_HANDLER_URL: "http://localhost:4202/redirect-handler/index.html",
|
|
146
148
|
VITE_SCRAPER_EXTENSION_ID_CHROMIUM: "kofibejdfkmnbobmbogndbiimkflcllf",
|
|
147
149
|
VITE_TRADE_API_BASE_URL: "/trade",
|
|
148
|
-
VITE_UNLEASH_APIKEY: "zerohash-sdk:dev.b0d8aa594e9b94564f885167881bcb9dc69332f935fcb253e656ff34"
|
|
150
|
+
VITE_UNLEASH_APIKEY: "zerohash-sdk:dev.b0d8aa594e9b94564f885167881bcb9dc69332f935fcb253e656ff34",
|
|
151
|
+
VITE_WALLET_DEPOSIT_DEBUG_PLATFORMS: "UW6VWU"
|
|
149
152
|
}.VITE_LOCAL_CDN_HOST || "http://localhost:5173",
|
|
150
153
|
dev: "https://sdk-cdn.dev.0hash.com",
|
|
151
154
|
cert: "https://sdk-cdn.cert.zerohash.com",
|
|
152
155
|
prod: "https://sdk-cdn.zerohash.com",
|
|
153
156
|
"eu-cert": "https://sdk-cdn.cert.zerohash.eu",
|
|
154
157
|
"eu-prod": "https://sdk-cdn.zerohash.eu"
|
|
155
|
-
},
|
|
156
|
-
let { eu: r = !1, legacyAliases: i = !1, local: a =
|
|
158
|
+
}, S = "https://sdk-cdn.gating.0hash.com", C = (e, t, n = {}) => {
|
|
159
|
+
let { eu: r = !1, legacyAliases: i = !1, local: a = x.local } = n, o = (n) => `${n}/${e}/${t}`, s = {
|
|
157
160
|
local: o(a),
|
|
158
|
-
dev: o(
|
|
159
|
-
gating: o(
|
|
160
|
-
cert: o(
|
|
161
|
-
prod: o(
|
|
161
|
+
dev: o(x.dev),
|
|
162
|
+
gating: o(S),
|
|
163
|
+
cert: o(x.cert),
|
|
164
|
+
prod: o(x.prod)
|
|
162
165
|
};
|
|
163
|
-
return i && (s.sandbox = o(
|
|
166
|
+
return i && (s.sandbox = o(x.cert), s.production = o(x.prod)), r && (s["eu-cert"] = o(x["eu-cert"]), s["eu-prod"] = o(x["eu-prod"])), s;
|
|
164
167
|
};
|
|
165
|
-
[...Object.entries(
|
|
168
|
+
[...Object.entries(x).filter(([e]) => e !== "local").map(([, e]) => e)], {
|
|
166
169
|
LOADED: "travel_rule_loaded",
|
|
167
170
|
COMPLETED: "travel_rule_completed"
|
|
168
171
|
}.LOADED;
|
|
169
172
|
//#endregion
|
|
170
173
|
//#region ../../../common/callbacks/dist/shared/models.js
|
|
171
|
-
var
|
|
174
|
+
var w;
|
|
172
175
|
(function(e) {
|
|
173
176
|
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";
|
|
174
|
-
})(
|
|
177
|
+
})(w ||= {});
|
|
175
178
|
//#endregion
|
|
176
179
|
//#region ../../../common/react-sdk-base/dist/script-load-fallback.js
|
|
177
|
-
var
|
|
180
|
+
var T = {
|
|
178
181
|
evergreen: "#00381D",
|
|
179
182
|
green: "#CCFFD0",
|
|
180
183
|
offBlack: "#1C1B1C",
|
|
181
184
|
grayLight: "#EBEBE9"
|
|
182
|
-
},
|
|
185
|
+
}, E = ({ onRetry: n, onClose: r }) => t("div", {
|
|
183
186
|
role: "alert",
|
|
184
187
|
style: {
|
|
185
188
|
position: "relative",
|
|
@@ -192,9 +195,9 @@ var w = {
|
|
|
192
195
|
padding: "32px 24px",
|
|
193
196
|
textAlign: "center",
|
|
194
197
|
fontFamily: "inherit",
|
|
195
|
-
color:
|
|
198
|
+
color: T.offBlack,
|
|
196
199
|
background: "#FFFFFF",
|
|
197
|
-
border: `1px solid ${
|
|
200
|
+
border: `1px solid ${T.grayLight}`,
|
|
198
201
|
borderRadius: "12px"
|
|
199
202
|
},
|
|
200
203
|
children: [
|
|
@@ -208,7 +211,7 @@ var w = {
|
|
|
208
211
|
right: "12px",
|
|
209
212
|
display: "flex",
|
|
210
213
|
padding: "4px",
|
|
211
|
-
color:
|
|
214
|
+
color: T.offBlack,
|
|
212
215
|
background: "none",
|
|
213
216
|
border: "none",
|
|
214
217
|
cursor: "pointer",
|
|
@@ -237,7 +240,7 @@ var w = {
|
|
|
237
240
|
"aria-hidden": "true",
|
|
238
241
|
children: e("path", {
|
|
239
242
|
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",
|
|
240
|
-
stroke:
|
|
243
|
+
stroke: T.evergreen,
|
|
241
244
|
strokeWidth: "1.5",
|
|
242
245
|
strokeLinecap: "round",
|
|
243
246
|
strokeLinejoin: "round"
|
|
@@ -268,8 +271,8 @@ var w = {
|
|
|
268
271
|
fontSize: "14px",
|
|
269
272
|
fontWeight: 600,
|
|
270
273
|
fontFamily: "inherit",
|
|
271
|
-
color:
|
|
272
|
-
background:
|
|
274
|
+
color: T.green,
|
|
275
|
+
background: T.evergreen,
|
|
273
276
|
border: "none",
|
|
274
277
|
borderRadius: "8px",
|
|
275
278
|
cursor: "pointer"
|
|
@@ -277,66 +280,77 @@ var w = {
|
|
|
277
280
|
children: "Try again"
|
|
278
281
|
})
|
|
279
282
|
]
|
|
280
|
-
}),
|
|
283
|
+
}), D = (e, t) => {
|
|
281
284
|
i(() => {
|
|
282
285
|
let n = e.current;
|
|
283
286
|
if (n) for (let [e, r] of Object.entries(t)) r !== void 0 && Reflect.set(n, e, r);
|
|
284
287
|
});
|
|
285
|
-
},
|
|
286
|
-
let { webComponentTag: t, appName: n, appVersion:
|
|
287
|
-
return i(() => (h(!1), v({
|
|
288
|
+
}, O = (e) => {
|
|
289
|
+
let { webComponentTag: t, appName: n, appVersion: o, scriptUrls: l, fallbackScriptUrls: u, collectorUrls: d, env: f, jwt: p, timeoutMs: m } = e, [h, g] = s(0), _ = a(() => ({
|
|
288
290
|
webComponentTag: t,
|
|
289
291
|
appName: n ?? t,
|
|
290
|
-
appVersion:
|
|
291
|
-
scriptUrls:
|
|
292
|
-
fallbackScriptUrls:
|
|
293
|
-
collectorUrls:
|
|
294
|
-
env:
|
|
295
|
-
jwt:
|
|
296
|
-
timeoutMs:
|
|
297
|
-
|
|
298
|
-
})
|
|
292
|
+
appVersion: o,
|
|
293
|
+
scriptUrls: l,
|
|
294
|
+
fallbackScriptUrls: u,
|
|
295
|
+
collectorUrls: d ?? c,
|
|
296
|
+
env: f,
|
|
297
|
+
jwt: p,
|
|
298
|
+
timeoutMs: m,
|
|
299
|
+
retryNonce: h
|
|
300
|
+
}), [
|
|
299
301
|
t,
|
|
300
302
|
n,
|
|
301
|
-
|
|
302
|
-
c,
|
|
303
|
+
o,
|
|
303
304
|
l,
|
|
304
305
|
u,
|
|
305
306
|
d,
|
|
306
307
|
f,
|
|
307
308
|
p,
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
309
|
+
m,
|
|
310
|
+
h
|
|
311
|
+
]), [v, b] = s(null), x = v === _;
|
|
312
|
+
return i(() => y({
|
|
313
|
+
webComponentTag: _.webComponentTag,
|
|
314
|
+
appName: _.appName,
|
|
315
|
+
appVersion: _.appVersion,
|
|
316
|
+
scriptUrls: _.scriptUrls,
|
|
317
|
+
fallbackScriptUrls: _.fallbackScriptUrls,
|
|
318
|
+
collectorUrls: _.collectorUrls,
|
|
319
|
+
env: _.env,
|
|
320
|
+
jwt: _.jwt,
|
|
321
|
+
timeoutMs: _.timeoutMs,
|
|
322
|
+
onError: () => b(_)
|
|
323
|
+
}), [_]), {
|
|
324
|
+
loadFailed: x,
|
|
325
|
+
retry: r(() => g((e) => e + 1), [])
|
|
312
326
|
};
|
|
313
|
-
},
|
|
314
|
-
let f =
|
|
315
|
-
|
|
327
|
+
}, k = C("fiat-account-link-web", "index.js", { eu: !0 }), A = "zerohash-fiat-account-link", j = ({ jwt: t, env: r = "prod", theme: i, onCompleted: a, onError: s, onClose: c, onLoaded: l, onEvent: u, ...d }) => {
|
|
328
|
+
let f = o(null);
|
|
329
|
+
D(f, {
|
|
316
330
|
theme: i,
|
|
317
|
-
onCompleted:
|
|
331
|
+
onCompleted: a,
|
|
318
332
|
onError: s,
|
|
319
333
|
onClose: c,
|
|
320
334
|
onLoaded: l,
|
|
321
335
|
onEvent: u
|
|
322
336
|
});
|
|
323
|
-
let { loadFailed: p, retry: m } =
|
|
324
|
-
webComponentTag:
|
|
325
|
-
scriptUrls:
|
|
337
|
+
let { loadFailed: p, retry: m } = O({
|
|
338
|
+
webComponentTag: A,
|
|
339
|
+
scriptUrls: k,
|
|
326
340
|
env: r,
|
|
327
341
|
jwt: t
|
|
328
342
|
});
|
|
329
|
-
return p ? /* @__PURE__ */ e(
|
|
343
|
+
return p ? /* @__PURE__ */ e(E, {
|
|
330
344
|
onRetry: m,
|
|
331
345
|
onClose: c
|
|
332
|
-
}) : n.createElement(
|
|
346
|
+
}) : n.createElement(A, {
|
|
333
347
|
ref: f,
|
|
334
348
|
jwt: t,
|
|
335
349
|
env: r,
|
|
336
|
-
sdkversion:
|
|
350
|
+
sdkversion: b(),
|
|
337
351
|
theme: i,
|
|
338
352
|
...d
|
|
339
353
|
});
|
|
340
354
|
};
|
|
341
355
|
//#endregion
|
|
342
|
-
export {
|
|
356
|
+
export { j as FiatAccountLink };
|