@zerohash-sdk/crypto-account-link-react 1.5.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/dist/index.js
CHANGED
|
@@ -1,43 +1,6 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import
|
|
3
|
-
const
|
|
4
|
-
evergreen: "#00381D",
|
|
5
|
-
green: "#CCFFD0",
|
|
6
|
-
offBlack: "#1C1B1C",
|
|
7
|
-
grayLight: "#EBEBE9"
|
|
8
|
-
}, D = ({ onRetry: e }) => A("div", { role: "alert", style: {
|
|
9
|
-
display: "flex",
|
|
10
|
-
flexDirection: "column",
|
|
11
|
-
alignItems: "center",
|
|
12
|
-
gap: "8px",
|
|
13
|
-
maxWidth: "360px",
|
|
14
|
-
margin: "0 auto",
|
|
15
|
-
padding: "32px 24px",
|
|
16
|
-
textAlign: "center",
|
|
17
|
-
fontFamily: "inherit",
|
|
18
|
-
color: _.offBlack,
|
|
19
|
-
background: "#FFFFFF",
|
|
20
|
-
border: `1px solid ${_.grayLight}`,
|
|
21
|
-
borderRadius: "12px"
|
|
22
|
-
}, children: [h("svg", { width: "32", height: "32", viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", children: h("path", { 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", stroke: _.evergreen, strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) }), h("p", { style: { margin: 0, fontSize: "16px", fontWeight: 600 }, children: "Something went wrong" }), h("p", { style: { margin: 0, fontSize: "14px", opacity: 0.75 }, children: "We couldn't load this content. Please check your internet connection and try again." }), h("button", { type: "button", onClick: e, style: {
|
|
23
|
-
marginTop: "8px",
|
|
24
|
-
padding: "8px 20px",
|
|
25
|
-
fontSize: "14px",
|
|
26
|
-
fontWeight: 600,
|
|
27
|
-
fontFamily: "inherit",
|
|
28
|
-
color: _.green,
|
|
29
|
-
background: _.evergreen,
|
|
30
|
-
border: "none",
|
|
31
|
-
borderRadius: "8px",
|
|
32
|
-
cursor: "pointer"
|
|
33
|
-
}, children: "Try again" })] }), V = (e, t) => {
|
|
34
|
-
B(() => {
|
|
35
|
-
const o = e.current;
|
|
36
|
-
if (o)
|
|
37
|
-
for (const [n, r] of Object.entries(t))
|
|
38
|
-
r !== void 0 && (o[n] = r);
|
|
39
|
-
});
|
|
40
|
-
}, P = {
|
|
1
|
+
import { jsxs as W, jsx as y } from "react/jsx-runtime";
|
|
2
|
+
import j, { useEffect as B, useState as L, useCallback as D, useRef as M } from "react";
|
|
3
|
+
const $ = {
|
|
41
4
|
dev: "https://grafana-faro-collector.dev.0hash.com/collect",
|
|
42
5
|
cert: "https://grafana-faro-collector.cert.zerohash.com/collect",
|
|
43
6
|
prod: "https://grafana-faro-collector.zerohash.com/collect",
|
|
@@ -45,55 +8,55 @@ const _ = {
|
|
|
45
8
|
"eu-prod": "https://grafana-faro-collector.zerohash.eu/collect",
|
|
46
9
|
sandbox: "https://grafana-faro-collector.cert.zerohash.com/collect",
|
|
47
10
|
production: "https://grafana-faro-collector.zerohash.com/collect"
|
|
48
|
-
},
|
|
11
|
+
}, V = (e) => {
|
|
49
12
|
if (!e || typeof e != "string")
|
|
50
13
|
return null;
|
|
51
14
|
const t = e.split(".");
|
|
52
15
|
if (t.length < 2)
|
|
53
16
|
return null;
|
|
54
17
|
try {
|
|
55
|
-
const o = t[1].replace(/-/g, "+").replace(/_/g, "/"),
|
|
18
|
+
const o = t[1].replace(/-/g, "+").replace(/_/g, "/"), r = o + "===".slice(0, (4 - o.length % 4) % 4), c = typeof atob < "u" ? atob(r) : Buffer.from(r, "base64").toString("utf-8"), a = JSON.parse(c)?.payload?.region;
|
|
56
19
|
if (typeof a != "string")
|
|
57
20
|
return null;
|
|
58
|
-
const
|
|
59
|
-
return
|
|
21
|
+
const n = a.toLowerCase();
|
|
22
|
+
return n === "us" || n === "eu" ? n : null;
|
|
60
23
|
} catch {
|
|
61
24
|
return null;
|
|
62
25
|
}
|
|
63
|
-
}, I = (e, t) =>
|
|
26
|
+
}, I = (e, t) => V(t) !== "eu" ? e : e === "cert" ? "eu-cert" : e === "prod" ? "eu-prod" : e, P = (e) => {
|
|
64
27
|
if (!e || typeof e != "string")
|
|
65
28
|
return {};
|
|
66
29
|
const t = e.split(".");
|
|
67
30
|
if (t.length < 2)
|
|
68
31
|
return {};
|
|
69
32
|
try {
|
|
70
|
-
const o = t[1].replace(/-/g, "+").replace(/_/g, "/"),
|
|
33
|
+
const o = t[1].replace(/-/g, "+").replace(/_/g, "/"), r = o + "===".slice(0, (4 - o.length % 4) % 4), c = typeof atob < "u" ? atob(r) : Buffer.from(r, "base64").toString("utf-8"), i = JSON.parse(c), a = i?.payload ?? {}, n = (s) => typeof s == "string" && s.length > 0 ? s : void 0;
|
|
71
34
|
return {
|
|
72
|
-
participantCode:
|
|
73
|
-
platformName:
|
|
74
|
-
platformCode:
|
|
75
|
-
region:
|
|
35
|
+
participantCode: n(a.participant_code),
|
|
36
|
+
platformName: n(a.platform_name),
|
|
37
|
+
platformCode: n(i.platform_code),
|
|
38
|
+
region: n(a.region)
|
|
76
39
|
};
|
|
77
40
|
} catch {
|
|
78
41
|
return {};
|
|
79
42
|
}
|
|
80
|
-
},
|
|
81
|
-
const
|
|
82
|
-
return e[
|
|
83
|
-
},
|
|
84
|
-
const
|
|
85
|
-
return e[
|
|
86
|
-
},
|
|
43
|
+
}, z = (e, t, o) => {
|
|
44
|
+
const r = I(t, o);
|
|
45
|
+
return e[r] ?? e[t] ?? e.prod;
|
|
46
|
+
}, J = (e, t, o) => {
|
|
47
|
+
const r = I(t, o);
|
|
48
|
+
return e[r] ?? e[t];
|
|
49
|
+
}, x = () => {
|
|
87
50
|
}, H = () => {
|
|
88
51
|
const e = new Uint8Array(8);
|
|
89
52
|
return globalThis.crypto.getRandomValues(e), Array.from(e, (t) => t.toString(16).padStart(2, "0")).join("");
|
|
90
|
-
},
|
|
91
|
-
const o = H(),
|
|
92
|
-
e.claims.participantCode && (
|
|
53
|
+
}, K = (e, t) => {
|
|
54
|
+
const o = H(), r = globalThis.__ZH_WEB_SDK_VERSION__, c = {};
|
|
55
|
+
e.claims.participantCode && (c.participant_code = e.claims.participantCode), e.claims.platformName && (c.platform_name = e.claims.platformName), e.claims.platformCode && (c.platform_code = e.claims.platformCode), e.claims.region && (c.region = e.claims.region), r && (c.zh_web_sdk_version = r);
|
|
93
56
|
const i = {
|
|
94
57
|
meta: {
|
|
95
58
|
app: { name: e.appName, version: t ?? "unknown", environment: e.env },
|
|
96
|
-
session: { id: o, attributes:
|
|
59
|
+
session: { id: o, attributes: c },
|
|
97
60
|
browser: typeof navigator < "u" ? { userAgent: navigator.userAgent } : void 0,
|
|
98
61
|
page: typeof window < "u" ? { url: window.location.origin } : void 0
|
|
99
62
|
},
|
|
@@ -113,132 +76,177 @@ const _ = {
|
|
|
113
76
|
]
|
|
114
77
|
};
|
|
115
78
|
return { sessionId: o, payload: i };
|
|
116
|
-
},
|
|
79
|
+
}, G = (e, t, o) => {
|
|
117
80
|
if (!e || typeof fetch > "u")
|
|
118
81
|
return;
|
|
119
|
-
const { sessionId:
|
|
82
|
+
const { sessionId: r, payload: c } = K(t, o);
|
|
120
83
|
try {
|
|
121
84
|
fetch(e, {
|
|
122
85
|
method: "POST",
|
|
123
|
-
headers: { "Content-Type": "application/json", "x-faro-session-id":
|
|
124
|
-
body: JSON.stringify(
|
|
86
|
+
headers: { "Content-Type": "application/json", "x-faro-session-id": r },
|
|
87
|
+
body: JSON.stringify(c),
|
|
125
88
|
keepalive: !0
|
|
126
89
|
}).catch(() => {
|
|
127
90
|
});
|
|
128
91
|
} catch {
|
|
129
92
|
}
|
|
130
|
-
},
|
|
131
|
-
const { webComponentTag: t, appName: o, appVersion:
|
|
93
|
+
}, Z = (e) => {
|
|
94
|
+
const { webComponentTag: t, appName: o, appVersion: r, scriptUrls: c, fallbackScriptUrls: i, collectorUrls: a, env: n, jwt: s, timeoutMs: g = 15e3, onLoad: _, onError: f } = e;
|
|
132
95
|
if (typeof document > "u")
|
|
133
|
-
return
|
|
134
|
-
const d = `${t}-script-${
|
|
96
|
+
return x;
|
|
97
|
+
const d = `${t}-script-${n}`;
|
|
135
98
|
if (customElements.get(t) || document.getElementById(d))
|
|
136
|
-
return
|
|
137
|
-
const b =
|
|
138
|
-
let
|
|
139
|
-
const
|
|
140
|
-
|
|
141
|
-
},
|
|
142
|
-
if (
|
|
99
|
+
return x;
|
|
100
|
+
const b = P(s), k = e.report ?? ((p) => G(a && J(a, n, s), p, r));
|
|
101
|
+
let m = !1, w = 0, v;
|
|
102
|
+
const S = () => {
|
|
103
|
+
v !== void 0 && clearTimeout(v);
|
|
104
|
+
}, C = (p, h, l) => {
|
|
105
|
+
if (m)
|
|
143
106
|
return;
|
|
144
|
-
const
|
|
107
|
+
const U = Math.round(performance.now() - w), T = {
|
|
145
108
|
webComponentTag: t,
|
|
146
109
|
appName: o,
|
|
147
|
-
env:
|
|
148
|
-
scriptUrl:
|
|
110
|
+
env: n,
|
|
111
|
+
scriptUrl: h,
|
|
149
112
|
reason: p,
|
|
150
113
|
triedFallback: l,
|
|
151
|
-
elapsedMs:
|
|
114
|
+
elapsedMs: U,
|
|
152
115
|
claims: b
|
|
153
116
|
};
|
|
154
|
-
k(
|
|
155
|
-
const
|
|
156
|
-
if (
|
|
157
|
-
O
|
|
117
|
+
k(T);
|
|
118
|
+
const O = l ? void 0 : z(i ?? {}, n, s);
|
|
119
|
+
if (O && O !== h) {
|
|
120
|
+
E(O, !0);
|
|
158
121
|
return;
|
|
159
122
|
}
|
|
160
|
-
|
|
161
|
-
},
|
|
162
|
-
|
|
123
|
+
m = !0, S(), document.getElementById(d)?.remove(), f?.(T);
|
|
124
|
+
}, E = (p, h) => {
|
|
125
|
+
S(), w = performance.now();
|
|
163
126
|
const l = document.createElement("script");
|
|
164
127
|
l.id = d, l.src = p, l.type = "module", l.async = !0, l.onload = () => {
|
|
165
128
|
setTimeout(() => {
|
|
166
|
-
|
|
129
|
+
m || (customElements.get(t) ? (m = !0, S(), _?.()) : C("not-defined", p, h));
|
|
167
130
|
}, 0);
|
|
168
|
-
}, l.onerror = () =>
|
|
169
|
-
},
|
|
170
|
-
return
|
|
171
|
-
|
|
172
|
-
}) :
|
|
131
|
+
}, l.onerror = () => C("network", p, h), v = setTimeout(() => C("timeout", p, h), g), document.getElementById(d)?.remove(), document.head.appendChild(l);
|
|
132
|
+
}, N = z(c, n, s);
|
|
133
|
+
return N ? (E(N, !1), () => {
|
|
134
|
+
m = !0, S();
|
|
135
|
+
}) : x;
|
|
136
|
+
}, u = {
|
|
137
|
+
local: "http://localhost:5173",
|
|
138
|
+
dev: "https://sdk-cdn.dev.0hash.com",
|
|
139
|
+
cert: "https://sdk-cdn.cert.zerohash.com",
|
|
140
|
+
prod: "https://sdk-cdn.zerohash.com",
|
|
141
|
+
"eu-cert": "https://sdk-cdn.cert.zerohash.eu",
|
|
142
|
+
"eu-prod": "https://sdk-cdn.zerohash.eu"
|
|
143
|
+
}, q = (e, t, o = {}) => {
|
|
144
|
+
const { eu: r = !1, legacyAliases: c = !1, local: i = u.local } = o, a = (s) => `${s}/${e}/${t}`, n = {
|
|
145
|
+
local: a(i),
|
|
146
|
+
dev: a(u.dev),
|
|
147
|
+
cert: a(u.cert),
|
|
148
|
+
prod: a(u.prod)
|
|
149
|
+
};
|
|
150
|
+
return c && (n.sandbox = a(u.cert), n.production = a(u.prod)), r && (n["eu-cert"] = a(u["eu-cert"]), n["eu-prod"] = a(u["eu-prod"])), n;
|
|
173
151
|
};
|
|
174
|
-
var
|
|
152
|
+
var F;
|
|
175
153
|
(function(e) {
|
|
176
154
|
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";
|
|
177
|
-
})(
|
|
178
|
-
const
|
|
179
|
-
|
|
180
|
-
|
|
155
|
+
})(F || (F = {}));
|
|
156
|
+
const R = {
|
|
157
|
+
evergreen: "#00381D",
|
|
158
|
+
green: "#CCFFD0",
|
|
159
|
+
offBlack: "#1C1B1C",
|
|
160
|
+
grayLight: "#EBEBE9"
|
|
161
|
+
}, Q = ({ onRetry: e }) => W("div", { role: "alert", style: {
|
|
162
|
+
display: "flex",
|
|
163
|
+
flexDirection: "column",
|
|
164
|
+
alignItems: "center",
|
|
165
|
+
gap: "8px",
|
|
166
|
+
maxWidth: "360px",
|
|
167
|
+
margin: "0 auto",
|
|
168
|
+
padding: "32px 24px",
|
|
169
|
+
textAlign: "center",
|
|
170
|
+
fontFamily: "inherit",
|
|
171
|
+
color: R.offBlack,
|
|
172
|
+
background: "#FFFFFF",
|
|
173
|
+
border: `1px solid ${R.grayLight}`,
|
|
174
|
+
borderRadius: "12px"
|
|
175
|
+
}, children: [y("svg", { width: "32", height: "32", viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", children: y("path", { 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", stroke: R.evergreen, strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) }), y("p", { style: { margin: 0, fontSize: "16px", fontWeight: 600 }, children: "Something went wrong" }), y("p", { style: { margin: 0, fontSize: "14px", opacity: 0.75 }, children: "We couldn't load this content. Please check your internet connection and try again." }), y("button", { type: "button", onClick: e, style: {
|
|
176
|
+
marginTop: "8px",
|
|
177
|
+
padding: "8px 20px",
|
|
178
|
+
fontSize: "14px",
|
|
179
|
+
fontWeight: 600,
|
|
180
|
+
fontFamily: "inherit",
|
|
181
|
+
color: R.green,
|
|
182
|
+
background: R.evergreen,
|
|
183
|
+
border: "none",
|
|
184
|
+
borderRadius: "8px",
|
|
185
|
+
cursor: "pointer"
|
|
186
|
+
}, children: "Try again" })] }), X = (e, t) => {
|
|
187
|
+
B(() => {
|
|
188
|
+
const o = e.current;
|
|
189
|
+
if (o)
|
|
190
|
+
for (const [r, c] of Object.entries(t))
|
|
191
|
+
c !== void 0 && (o[r] = c);
|
|
192
|
+
});
|
|
193
|
+
}, Y = (e) => {
|
|
194
|
+
const { webComponentTag: t, appName: o, appVersion: r, scriptUrls: c, fallbackScriptUrls: i, collectorUrls: a, env: n, jwt: s, timeoutMs: g } = e, [_, f] = L(!1), [d, b] = L(0);
|
|
195
|
+
B(() => (f(!1), Z({
|
|
181
196
|
webComponentTag: t,
|
|
182
197
|
appName: o ?? t,
|
|
183
|
-
appVersion:
|
|
184
|
-
scriptUrls:
|
|
198
|
+
appVersion: r,
|
|
199
|
+
scriptUrls: c,
|
|
185
200
|
fallbackScriptUrls: i,
|
|
186
|
-
collectorUrls: a ??
|
|
187
|
-
env:
|
|
201
|
+
collectorUrls: a ?? $,
|
|
202
|
+
env: n,
|
|
188
203
|
jwt: s,
|
|
189
|
-
timeoutMs:
|
|
190
|
-
onError: () =>
|
|
204
|
+
timeoutMs: g,
|
|
205
|
+
onError: () => f(!0)
|
|
191
206
|
})), [
|
|
192
207
|
t,
|
|
193
208
|
o,
|
|
194
|
-
n,
|
|
195
209
|
r,
|
|
210
|
+
c,
|
|
196
211
|
i,
|
|
197
212
|
a,
|
|
198
|
-
|
|
213
|
+
n,
|
|
199
214
|
s,
|
|
200
|
-
|
|
215
|
+
g,
|
|
201
216
|
d
|
|
202
217
|
]);
|
|
203
|
-
const k =
|
|
204
|
-
return { loadFailed:
|
|
205
|
-
},
|
|
206
|
-
local: "http://localhost:5173/crypto-account-link-web/index.js",
|
|
207
|
-
dev: "https://connect-sdk.dev.0hash.com/crypto-account-link-web/index.js",
|
|
208
|
-
cert: "https://sdk.sandbox.connect.xyz/crypto-account-link-web/index.js",
|
|
209
|
-
prod: "https://sdk.connect.xyz/crypto-account-link-web/index.js",
|
|
210
|
-
"eu-cert": "https://sdk-cdn.cert.zerohash.eu/crypto-account-link-web/index.js",
|
|
211
|
-
"eu-prod": "https://sdk-cdn.zerohash.eu/crypto-account-link-web/index.js"
|
|
212
|
-
}, F = "zerohash-crypto-account-link", te = ({
|
|
218
|
+
const k = D(() => b((m) => m + 1), []);
|
|
219
|
+
return { loadFailed: _, retry: k };
|
|
220
|
+
}, ee = q("crypto-account-link-web", "index.js", { eu: !0 }), A = "zerohash-crypto-account-link", re = ({
|
|
213
221
|
jwt: e,
|
|
214
222
|
env: t = "prod",
|
|
215
223
|
theme: o,
|
|
216
|
-
isPayouts:
|
|
217
|
-
onCompleted:
|
|
224
|
+
isPayouts: r = !1,
|
|
225
|
+
onCompleted: c,
|
|
218
226
|
onError: i,
|
|
219
227
|
onClose: a,
|
|
220
|
-
onLoaded:
|
|
228
|
+
onLoaded: n,
|
|
221
229
|
onExternalAccountCreated: s,
|
|
222
|
-
onEvent:
|
|
223
|
-
...
|
|
230
|
+
onEvent: g,
|
|
231
|
+
..._
|
|
224
232
|
}) => {
|
|
225
|
-
const
|
|
226
|
-
|
|
227
|
-
const { loadFailed: d, retry: b } =
|
|
228
|
-
webComponentTag:
|
|
229
|
-
scriptUrls:
|
|
233
|
+
const f = M(null);
|
|
234
|
+
X(f, { theme: o, onCompleted: c, onError: i, onClose: a, onLoaded: n, onExternalAccountCreated: s, onEvent: g });
|
|
235
|
+
const { loadFailed: d, retry: b } = Y({
|
|
236
|
+
webComponentTag: A,
|
|
237
|
+
scriptUrls: ee,
|
|
230
238
|
env: t,
|
|
231
239
|
jwt: e
|
|
232
240
|
});
|
|
233
|
-
return d ? /* @__PURE__ */
|
|
234
|
-
ref:
|
|
241
|
+
return d ? /* @__PURE__ */ y(Q, { onRetry: b }) : j.createElement(A, {
|
|
242
|
+
ref: f,
|
|
235
243
|
jwt: e,
|
|
236
244
|
env: t,
|
|
237
245
|
theme: o,
|
|
238
|
-
"is-payouts":
|
|
239
|
-
...
|
|
246
|
+
"is-payouts": r,
|
|
247
|
+
..._
|
|
240
248
|
});
|
|
241
249
|
};
|
|
242
250
|
export {
|
|
243
|
-
|
|
251
|
+
re as CryptoAccountLink
|
|
244
252
|
};
|
package/package.json
CHANGED
|
@@ -28,7 +28,7 @@ describe('CryptoAccountLink', () => {
|
|
|
28
28
|
/>
|
|
29
29
|
);
|
|
30
30
|
const script = document.head.querySelector('script');
|
|
31
|
-
expect(script?.src).toBe('https://
|
|
31
|
+
expect(script?.src).toBe('https://sdk-cdn.dev.0hash.com/crypto-account-link-web/index.js');
|
|
32
32
|
});
|
|
33
33
|
|
|
34
34
|
it('loads the cert CDN script for cert env', () => {
|
|
@@ -39,13 +39,13 @@ describe('CryptoAccountLink', () => {
|
|
|
39
39
|
/>
|
|
40
40
|
);
|
|
41
41
|
const script = document.head.querySelector('script');
|
|
42
|
-
expect(script?.src).toBe('https://sdk.
|
|
42
|
+
expect(script?.src).toBe('https://sdk-cdn.cert.zerohash.com/crypto-account-link-web/index.js');
|
|
43
43
|
});
|
|
44
44
|
|
|
45
45
|
it('loads the production CDN script for prod env', () => {
|
|
46
46
|
render(<CryptoAccountLink jwt="test-jwt" />);
|
|
47
47
|
const script = document.head.querySelector('script');
|
|
48
|
-
expect(script?.src).toBe('https://sdk.
|
|
48
|
+
expect(script?.src).toBe('https://sdk-cdn.zerohash.com/crypto-account-link-web/index.js');
|
|
49
49
|
});
|
|
50
50
|
|
|
51
51
|
it('loads the EU cert CDN script when JWT region is "eu" and env is "cert"', () => {
|
|
@@ -73,7 +73,7 @@ describe('CryptoAccountLink', () => {
|
|
|
73
73
|
/>
|
|
74
74
|
);
|
|
75
75
|
const script = document.head.querySelector('script');
|
|
76
|
-
expect(script?.src).toBe('https://sdk.
|
|
76
|
+
expect(script?.src).toBe('https://sdk-cdn.cert.zerohash.com/crypto-account-link-web/index.js');
|
|
77
77
|
});
|
|
78
78
|
|
|
79
79
|
it('falls back to the US host when the JWT has no region claim', () => {
|
|
@@ -84,7 +84,7 @@ describe('CryptoAccountLink', () => {
|
|
|
84
84
|
/>
|
|
85
85
|
);
|
|
86
86
|
const script = document.head.querySelector('script');
|
|
87
|
-
expect(script?.src).toBe('https://sdk.
|
|
87
|
+
expect(script?.src).toBe('https://sdk-cdn.cert.zerohash.com/crypto-account-link-web/index.js');
|
|
88
88
|
});
|
|
89
89
|
|
|
90
90
|
it('falls back to the US host when the JWT is malformed', () => {
|
|
@@ -95,7 +95,7 @@ describe('CryptoAccountLink', () => {
|
|
|
95
95
|
/>
|
|
96
96
|
);
|
|
97
97
|
const script = document.head.querySelector('script');
|
|
98
|
-
expect(script?.src).toBe('https://sdk.
|
|
98
|
+
expect(script?.src).toBe('https://sdk-cdn.cert.zerohash.com/crypto-account-link-web/index.js');
|
|
99
99
|
});
|
|
100
100
|
|
|
101
101
|
it('falls back to the prod connect.xyz host when env is an unknown string', () => {
|
|
@@ -106,7 +106,7 @@ describe('CryptoAccountLink', () => {
|
|
|
106
106
|
/>
|
|
107
107
|
);
|
|
108
108
|
const script = document.head.querySelector('script');
|
|
109
|
-
expect(script?.src).toBe('https://sdk.
|
|
109
|
+
expect(script?.src).toBe('https://sdk-cdn.zerohash.com/crypto-account-link-web/index.js');
|
|
110
110
|
});
|
|
111
111
|
});
|
|
112
112
|
});
|
|
@@ -3,22 +3,11 @@
|
|
|
3
3
|
CryptoAccountLinkEvent,
|
|
4
4
|
ErrorPayload,
|
|
5
5
|
} from '@zerohash/callbacks';
|
|
6
|
+
import { buildCdnAssetUrls } from '@zerohash/js-sdk-base';
|
|
6
7
|
import { ScriptLoadFallback, useSyncWebComponentProps, useWebComponentScript } from '@zerohash/react-sdk-base';
|
|
7
8
|
import React, { useRef } from 'react';
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
// connect.xyz CDN — that host has no Cloudflare Rocket Loader, which was the
|
|
11
|
-
// root cause of the SRE-18031 blank-screen incident. EU partners
|
|
12
|
-
// (`region: 'eu'` in the JWT payload) are routed to the EU CDN. The two will
|
|
13
|
-
// be unified once Rocket Loader is dropped on the .com host.
|
|
14
|
-
const SCRIPT_URLS = {
|
|
15
|
-
local: 'http://localhost:5173/crypto-account-link-web/index.js',
|
|
16
|
-
dev: 'https://connect-sdk.dev.0hash.com/crypto-account-link-web/index.js',
|
|
17
|
-
cert: 'https://sdk.sandbox.connect.xyz/crypto-account-link-web/index.js',
|
|
18
|
-
prod: 'https://sdk.connect.xyz/crypto-account-link-web/index.js',
|
|
19
|
-
'eu-cert': 'https://sdk-cdn.cert.zerohash.eu/crypto-account-link-web/index.js',
|
|
20
|
-
'eu-prod': 'https://sdk-cdn.zerohash.eu/crypto-account-link-web/index.js',
|
|
21
|
-
} as const;
|
|
10
|
+
const SCRIPT_URLS = buildCdnAssetUrls('crypto-account-link-web', 'index.js', { eu: true });
|
|
22
11
|
|
|
23
12
|
const WEB_COMPONENT_TAG = 'zerohash-crypto-account-link';
|
|
24
13
|
|