@zerohash-sdk/crypto-account-link-react 1.14.18 → 1.14.19
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 +95 -82
- 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.14.19", x = {
|
|
129
131
|
local: {
|
|
130
132
|
BASE_URL: "/",
|
|
131
133
|
DEV: !1,
|
|
@@ -153,34 +155,34 @@ var s = {
|
|
|
153
155
|
prod: "https://sdk-cdn.zerohash.com",
|
|
154
156
|
"eu-cert": "https://sdk-cdn.cert.zerohash.eu",
|
|
155
157
|
"eu-prod": "https://sdk-cdn.zerohash.eu"
|
|
156
|
-
},
|
|
157
|
-
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 = {
|
|
158
160
|
local: o(a),
|
|
159
|
-
dev: o(
|
|
160
|
-
gating: o(
|
|
161
|
-
cert: o(
|
|
162
|
-
prod: o(
|
|
161
|
+
dev: o(x.dev),
|
|
162
|
+
gating: o(S),
|
|
163
|
+
cert: o(x.cert),
|
|
164
|
+
prod: o(x.prod)
|
|
163
165
|
};
|
|
164
|
-
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;
|
|
165
167
|
};
|
|
166
|
-
[...Object.entries(
|
|
168
|
+
[...Object.entries(x).filter(([e]) => e !== "local").map(([, e]) => e)], {
|
|
167
169
|
LOADED: "travel_rule_loaded",
|
|
168
170
|
COMPLETED: "travel_rule_completed"
|
|
169
171
|
}.LOADED;
|
|
170
172
|
//#endregion
|
|
171
173
|
//#region ../../../common/callbacks/dist/shared/models.js
|
|
172
|
-
var
|
|
174
|
+
var w;
|
|
173
175
|
(function(e) {
|
|
174
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";
|
|
175
|
-
})(
|
|
177
|
+
})(w ||= {});
|
|
176
178
|
//#endregion
|
|
177
179
|
//#region ../../../common/react-sdk-base/dist/script-load-fallback.js
|
|
178
|
-
var
|
|
180
|
+
var T = {
|
|
179
181
|
evergreen: "#00381D",
|
|
180
182
|
green: "#CCFFD0",
|
|
181
183
|
offBlack: "#1C1B1C",
|
|
182
184
|
grayLight: "#EBEBE9"
|
|
183
|
-
},
|
|
185
|
+
}, E = ({ onRetry: n, onClose: r }) => t("div", {
|
|
184
186
|
role: "alert",
|
|
185
187
|
style: {
|
|
186
188
|
position: "relative",
|
|
@@ -193,9 +195,9 @@ var w = {
|
|
|
193
195
|
padding: "32px 24px",
|
|
194
196
|
textAlign: "center",
|
|
195
197
|
fontFamily: "inherit",
|
|
196
|
-
color:
|
|
198
|
+
color: T.offBlack,
|
|
197
199
|
background: "#FFFFFF",
|
|
198
|
-
border: `1px solid ${
|
|
200
|
+
border: `1px solid ${T.grayLight}`,
|
|
199
201
|
borderRadius: "12px"
|
|
200
202
|
},
|
|
201
203
|
children: [
|
|
@@ -209,7 +211,7 @@ var w = {
|
|
|
209
211
|
right: "12px",
|
|
210
212
|
display: "flex",
|
|
211
213
|
padding: "4px",
|
|
212
|
-
color:
|
|
214
|
+
color: T.offBlack,
|
|
213
215
|
background: "none",
|
|
214
216
|
border: "none",
|
|
215
217
|
cursor: "pointer",
|
|
@@ -238,7 +240,7 @@ var w = {
|
|
|
238
240
|
"aria-hidden": "true",
|
|
239
241
|
children: e("path", {
|
|
240
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",
|
|
241
|
-
stroke:
|
|
243
|
+
stroke: T.evergreen,
|
|
242
244
|
strokeWidth: "1.5",
|
|
243
245
|
strokeLinecap: "round",
|
|
244
246
|
strokeLinejoin: "round"
|
|
@@ -269,8 +271,8 @@ var w = {
|
|
|
269
271
|
fontSize: "14px",
|
|
270
272
|
fontWeight: 600,
|
|
271
273
|
fontFamily: "inherit",
|
|
272
|
-
color:
|
|
273
|
-
background:
|
|
274
|
+
color: T.green,
|
|
275
|
+
background: T.evergreen,
|
|
274
276
|
border: "none",
|
|
275
277
|
borderRadius: "8px",
|
|
276
278
|
cursor: "pointer"
|
|
@@ -278,42 +280,53 @@ var w = {
|
|
|
278
280
|
children: "Try again"
|
|
279
281
|
})
|
|
280
282
|
]
|
|
281
|
-
}),
|
|
283
|
+
}), D = (e, t) => {
|
|
282
284
|
i(() => {
|
|
283
285
|
let n = e.current;
|
|
284
286
|
if (n) for (let [e, r] of Object.entries(t)) r !== void 0 && Reflect.set(n, e, r);
|
|
285
287
|
});
|
|
286
|
-
},
|
|
287
|
-
let { webComponentTag: t, appName: n, appVersion:
|
|
288
|
-
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(() => ({
|
|
289
290
|
webComponentTag: t,
|
|
290
291
|
appName: n ?? t,
|
|
291
|
-
appVersion:
|
|
292
|
-
scriptUrls:
|
|
293
|
-
fallbackScriptUrls:
|
|
294
|
-
collectorUrls:
|
|
295
|
-
env:
|
|
296
|
-
jwt:
|
|
297
|
-
timeoutMs:
|
|
298
|
-
|
|
299
|
-
})
|
|
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
|
+
}), [
|
|
300
301
|
t,
|
|
301
302
|
n,
|
|
302
|
-
|
|
303
|
-
c,
|
|
303
|
+
o,
|
|
304
304
|
l,
|
|
305
305
|
u,
|
|
306
306
|
d,
|
|
307
307
|
f,
|
|
308
308
|
p,
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
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), [])
|
|
313
326
|
};
|
|
314
|
-
},
|
|
315
|
-
let m =
|
|
316
|
-
|
|
327
|
+
}, k = C("crypto-account-link-web", "index.js", { eu: !0 }), A = "zerohash-crypto-account-link", j = ({ jwt: t, env: r = "prod", theme: i, isPayouts: a = !1, onCompleted: s, onError: c, onClose: l, onLoaded: u, onExternalAccountCreated: d, onEvent: f, ...p }) => {
|
|
328
|
+
let m = o(null);
|
|
329
|
+
D(m, {
|
|
317
330
|
theme: i,
|
|
318
331
|
onCompleted: s,
|
|
319
332
|
onError: c,
|
|
@@ -322,24 +335,24 @@ var w = {
|
|
|
322
335
|
onExternalAccountCreated: d,
|
|
323
336
|
onEvent: f
|
|
324
337
|
});
|
|
325
|
-
let { loadFailed: h, retry: g } =
|
|
326
|
-
webComponentTag:
|
|
327
|
-
scriptUrls:
|
|
338
|
+
let { loadFailed: h, retry: g } = O({
|
|
339
|
+
webComponentTag: A,
|
|
340
|
+
scriptUrls: k,
|
|
328
341
|
env: r,
|
|
329
342
|
jwt: t
|
|
330
343
|
});
|
|
331
|
-
return h ? /* @__PURE__ */ e(
|
|
344
|
+
return h ? /* @__PURE__ */ e(E, {
|
|
332
345
|
onRetry: g,
|
|
333
346
|
onClose: l
|
|
334
|
-
}) : n.createElement(
|
|
347
|
+
}) : n.createElement(A, {
|
|
335
348
|
ref: m,
|
|
336
349
|
jwt: t,
|
|
337
350
|
env: r,
|
|
338
|
-
sdkversion:
|
|
351
|
+
sdkversion: b(),
|
|
339
352
|
theme: i,
|
|
340
|
-
"is-payouts":
|
|
353
|
+
"is-payouts": a,
|
|
341
354
|
...p
|
|
342
355
|
});
|
|
343
356
|
};
|
|
344
357
|
//#endregion
|
|
345
|
-
export {
|
|
358
|
+
export { j as CryptoAccountLink };
|