@zerohash-sdk/crypto-account-link-react 1.14.4 → 1.14.5

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.d.ts CHANGED
@@ -275,3 +275,32 @@ declare type ErrorPayload = {
275
275
  declare type Theme = 'auto' | 'light' | 'dark';
276
276
 
277
277
  export { }
278
+
279
+
280
+ declare global {
281
+ namespace JSX {
282
+ interface IntrinsicElements {
283
+ /**
284
+ * Connect Crypto Account Link web component element
285
+ */
286
+ [WEB_COMPONENT_TAG]: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> & {
287
+ /**
288
+ * JWT token for authentication
289
+ */
290
+ jwt: string;
291
+ /**
292
+ * Target environment ("local" | "dev" | "cert" | "prod")
293
+ */
294
+ env?: Environment;
295
+ /**
296
+ * Theme mode ("auto" | "light" | "dark")
297
+ */
298
+ theme?: Theme;
299
+ /**
300
+ * Whether this is for payouts (withdrawals) or deposits
301
+ */
302
+ 'is-payouts'?: boolean;
303
+ };
304
+ }
305
+ }
306
+ }
package/dist/index.js CHANGED
@@ -1,271 +1,341 @@
1
- import { jsxs as W, jsx as d } from "react/jsx-runtime";
2
- import D, { useEffect as B, useState as L, useCallback as M, useRef as j } from "react";
3
- const V = {
4
- dev: "https://grafana-faro-collector.dev.0hash.com/collect",
5
- cert: "https://grafana-faro-collector.cert.zerohash.com/collect",
6
- prod: "https://grafana-faro-collector.zerohash.com/collect",
7
- "eu-cert": "https://grafana-faro-collector.cert.zerohash.eu/collect",
8
- "eu-prod": "https://grafana-faro-collector.zerohash.eu/collect",
9
- sandbox: "https://grafana-faro-collector.cert.zerohash.com/collect",
10
- production: "https://grafana-faro-collector.zerohash.com/collect"
11
- }, $ = (e) => {
12
- if (!e || typeof e != "string")
13
- return null;
14
- const t = e.split(".");
15
- if (t.length < 2)
16
- return null;
17
- try {
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"), n = JSON.parse(c)?.payload?.region;
19
- if (typeof n != "string")
20
- return null;
21
- const a = n.toLowerCase();
22
- return a === "us" || a === "eu" ? a : null;
23
- } catch {
24
- return null;
25
- }
26
- }, I = (e, t) => $(t) !== "eu" ? e : e === "cert" ? "eu-cert" : e === "prod" ? "eu-prod" : e, H = (e) => {
27
- if (!e || typeof e != "string")
28
- return {};
29
- const t = e.split(".");
30
- if (t.length < 2)
31
- return {};
32
- try {
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), n = i?.payload ?? {}, a = (s) => typeof s == "string" && s.length > 0 ? s : void 0;
34
- return {
35
- participantCode: a(n.participant_code),
36
- platformName: a(n.platform_name),
37
- platformCode: a(i.platform_code),
38
- region: a(n.region)
39
- };
40
- } catch {
41
- return {};
42
- }
43
- }, z = (e, t, o) => {
44
- const r = I(t, o);
45
- return e[r] ?? e[t] ?? e.prod;
46
- }, P = (e, t, o) => {
47
- const r = I(t, o);
48
- return e[r] ?? e[t];
49
- }, x = () => {
50
- }, J = () => {
51
- const e = new Uint8Array(8);
52
- return globalThis.crypto.getRandomValues(e), Array.from(e, (t) => t.toString(16).padStart(2, "0")).join("");
53
- }, G = (e, t) => {
54
- const o = J(), 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);
56
- const i = {
57
- meta: {
58
- app: { name: e.appName, version: t ?? "unknown", environment: e.env },
59
- session: { id: o, attributes: c },
60
- browser: typeof navigator < "u" ? { userAgent: navigator.userAgent } : void 0,
61
- page: typeof window < "u" ? { url: window.location.origin } : void 0
62
- },
63
- logs: [
64
- {
65
- message: `Failed to load the script for ${e.webComponentTag} from ${e.env} environment.`,
66
- level: "error",
67
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
68
- context: {
69
- web_component: e.webComponentTag,
70
- script_url: e.scriptUrl,
71
- reason: e.reason,
72
- tried_fallback: String(e.triedFallback),
73
- elapsed_ms: String(e.elapsedMs)
74
- }
75
- }
76
- ]
77
- };
78
- return { sessionId: o, payload: i };
79
- }, K = (e, t, o) => {
80
- if (!e || typeof fetch > "u")
81
- return;
82
- const { sessionId: r, payload: c } = G(t, o);
83
- try {
84
- fetch(e, {
85
- method: "POST",
86
- headers: { "Content-Type": "application/json", "x-faro-session-id": r },
87
- body: JSON.stringify(c),
88
- keepalive: !0
89
- }).catch(() => {
90
- });
91
- } catch {
92
- }
93
- }, Z = (e) => {
94
- const { webComponentTag: t, appName: o, appVersion: r, scriptUrls: c, fallbackScriptUrls: i, collectorUrls: n, env: a, jwt: s, timeoutMs: h = 15e3, onLoad: b, onError: m } = e;
95
- if (typeof document > "u")
96
- return x;
97
- const p = `${t}-script-${a}`;
98
- if (customElements.get(t) || document.getElementById(p))
99
- return x;
100
- const R = H(s), S = e.report ?? ((u) => K(n && P(n, a, s), u, r));
101
- let g = !1, T = 0, v;
102
- const k = () => {
103
- v !== void 0 && clearTimeout(v);
104
- }, C = (u, y, l) => {
105
- if (g)
106
- return;
107
- const U = Math.round(performance.now() - T), E = {
108
- webComponentTag: t,
109
- appName: o,
110
- env: a,
111
- scriptUrl: y,
112
- reason: u,
113
- triedFallback: l,
114
- elapsedMs: U,
115
- claims: R
116
- };
117
- S(E);
118
- const O = l ? void 0 : z(i ?? {}, a, s);
119
- if (O && O !== y) {
120
- N(O, !0);
121
- return;
122
- }
123
- g = !0, k(), document.getElementById(p)?.remove(), m?.(E);
124
- }, N = (u, y) => {
125
- k(), T = performance.now();
126
- const l = document.createElement("script");
127
- l.id = p, l.src = u, l.type = "module", l.async = !0, l.onload = () => {
128
- setTimeout(() => {
129
- g || (customElements.get(t) ? (g = !0, k(), b?.()) : C("not-defined", u, y));
130
- }, 0);
131
- }, l.onerror = () => C("network", u, y), v = setTimeout(() => C("timeout", u, y), h), document.getElementById(p)?.remove(), document.head.appendChild(l);
132
- }, w = z(c, a, s);
133
- return w ? (N(w, !1), () => {
134
- g = !0, k();
135
- }) : x;
136
- }, q = {}, Q = typeof import.meta < "u" && q?.VITE_LOCAL_CDN_HOST || "http://localhost:5173", f = {
137
- local: Q,
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
- }, X = "https://sdk-cdn.gating.0hash.com", Y = (e, t, o = {}) => {
144
- const { eu: r = !1, legacyAliases: c = !1, local: i = f.local } = o, n = (s) => `${s}/${e}/${t}`, a = {
145
- local: n(i),
146
- dev: n(f.dev),
147
- gating: n(X),
148
- cert: n(f.cert),
149
- prod: n(f.prod)
150
- };
151
- return c && (a.sandbox = n(f.cert), a.production = n(f.prod)), r && (a["eu-cert"] = n(f["eu-cert"]), a["eu-prod"] = n(f["eu-prod"])), a;
1
+ import { jsx as e, jsxs as t } from "react/jsx-runtime";
2
+ import n, { useCallback as r, useEffect as i, useRef as a, useState as o } from "react";
3
+ //#region ../../../common/js-sdk-base/dist/constants.js
4
+ var s = {
5
+ dev: "https://grafana-faro-collector.dev.0hash.com/collect",
6
+ cert: "https://grafana-faro-collector.cert.zerohash.com/collect",
7
+ prod: "https://grafana-faro-collector.zerohash.com/collect",
8
+ "eu-cert": "https://grafana-faro-collector.cert.zerohash.eu/collect",
9
+ "eu-prod": "https://grafana-faro-collector.zerohash.eu/collect",
10
+ sandbox: "https://grafana-faro-collector.cert.zerohash.com/collect",
11
+ production: "https://grafana-faro-collector.zerohash.com/collect"
12
+ }, c = (e) => {
13
+ if (!e || typeof e != "string") return null;
14
+ let t = e.split(".");
15
+ if (t.length < 2) return null;
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)?.payload?.region;
18
+ if (typeof i != "string") return null;
19
+ let a = i.toLowerCase();
20
+ return a === "us" || a === "eu" ? a : null;
21
+ } catch {
22
+ return null;
23
+ }
24
+ }, l = (e, t) => c(t) === "eu" ? e === "cert" ? "eu-cert" : e === "prod" ? "eu-prod" : e : e, u = (e) => {
25
+ if (!e || typeof e != "string") return {};
26
+ let t = e.split(".");
27
+ if (t.length < 2) return {};
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), a = i?.payload ?? {}, o = (e) => typeof e == "string" && e.length > 0 ? e : void 0;
30
+ return {
31
+ participantCode: o(a.participant_code),
32
+ platformName: o(a.platform_name),
33
+ platformCode: o(i.platform_code),
34
+ region: o(a.region)
35
+ };
36
+ } catch {
37
+ return {};
38
+ }
39
+ }, d = (e, t, n) => e[l(t, n)] ?? e[t] ?? e.prod, f = (e, t, n) => e[l(t, n)] ?? e[t], p = () => void 0, m = () => {
40
+ let e = /* @__PURE__ */ new Uint8Array(8);
41
+ return globalThis.crypto.getRandomValues(e), Array.from(e, (e) => e.toString(16).padStart(2, "0")).join("");
42
+ }, h = (e, t) => {
43
+ let n = m(), r = globalThis.__ZH_WEB_SDK_VERSION__, i = {};
44
+ return e.claims.participantCode && (i.participant_code = e.claims.participantCode), e.claims.platformName && (i.platform_name = e.claims.platformName), e.claims.platformCode && (i.platform_code = e.claims.platformCode), e.claims.region && (i.region = e.claims.region), r && (i.zh_web_sdk_version = r), {
45
+ sessionId: n,
46
+ payload: {
47
+ meta: {
48
+ app: {
49
+ name: e.appName,
50
+ version: t ?? "unknown",
51
+ environment: e.env
52
+ },
53
+ session: {
54
+ id: n,
55
+ attributes: i
56
+ },
57
+ browser: typeof navigator < "u" ? { userAgent: navigator.userAgent } : void 0,
58
+ page: typeof window < "u" ? { url: window.location.origin } : void 0
59
+ },
60
+ logs: [{
61
+ message: `Failed to load the script for ${e.webComponentTag} from ${e.env} environment.`,
62
+ level: "error",
63
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
64
+ context: {
65
+ web_component: e.webComponentTag,
66
+ script_url: e.scriptUrl,
67
+ reason: e.reason,
68
+ tried_fallback: String(e.triedFallback),
69
+ elapsed_ms: String(e.elapsedMs)
70
+ }
71
+ }]
72
+ }
73
+ };
74
+ }, g = (e, t, n) => {
75
+ if (!e || typeof fetch > "u") return;
76
+ let { sessionId: r, payload: i } = h(t, n);
77
+ try {
78
+ fetch(e, {
79
+ method: "POST",
80
+ headers: {
81
+ "Content-Type": "application/json",
82
+ "x-faro-session-id": r
83
+ },
84
+ body: JSON.stringify(i),
85
+ keepalive: !0
86
+ }).catch(() => void 0);
87
+ } catch {}
88
+ }, _ = (e) => {
89
+ let { webComponentTag: t, appName: n, appVersion: r, scriptUrls: i, fallbackScriptUrls: a, collectorUrls: o, env: s, jwt: c, timeoutMs: l = 15e3, onLoad: m, onError: h } = e;
90
+ if (typeof document > "u") return p;
91
+ let _ = `${t}-script-${s}`;
92
+ if (customElements.get(t) || document.getElementById(_)) return p;
93
+ let v = u(c), y = e.report ?? ((e) => g(o && f(o, s, c), e, r)), b = !1, x = 0, S, C = () => {
94
+ S !== void 0 && clearTimeout(S);
95
+ }, w = (e, r, i) => {
96
+ if (b) return;
97
+ let o = Math.round(performance.now() - x), l = {
98
+ webComponentTag: t,
99
+ appName: n,
100
+ env: s,
101
+ scriptUrl: r,
102
+ reason: e,
103
+ triedFallback: i,
104
+ elapsedMs: o,
105
+ claims: v
106
+ };
107
+ y(l);
108
+ let u = i ? void 0 : d(a ?? {}, s, c);
109
+ if (u && u !== r) {
110
+ T(u, !0);
111
+ return;
112
+ }
113
+ b = !0, C(), document.getElementById(_)?.remove(), h?.(l);
114
+ }, T = (e, n) => {
115
+ C(), x = performance.now();
116
+ let r = document.createElement("script");
117
+ r.id = _, r.src = e, r.type = "module", r.async = !0, r.onload = () => {
118
+ setTimeout(() => {
119
+ b || (customElements.get(t) ? (b = !0, C(), m?.()) : w("not-defined", e, n));
120
+ }, 0);
121
+ }, r.onerror = () => w("network", e, n), S = setTimeout(() => w("timeout", e, n), l), document.getElementById(_)?.remove(), document.head.appendChild(r);
122
+ }, E = d(i, s, c);
123
+ return E ? (T(E, !1), () => {
124
+ b = !0, C();
125
+ }) : p;
126
+ }, v = {
127
+ local: {
128
+ BASE_URL: "/",
129
+ DEV: !1,
130
+ MODE: "production",
131
+ PROD: !0,
132
+ SSR: !1,
133
+ VITE_ASSETS_SERVICE_URL: "http://localhost:5173/assets",
134
+ VITE_CONNECT_API_BASE_URL: "/api/v1",
135
+ VITE_CONNECT_ENV: "local",
136
+ VITE_CONNECT_SDK_API_BASE_URL: "/sdk/v1",
137
+ VITE_DYNAMIC_ENVIRONMENT_ID: "38ce0330-c85e-414a-80b4-6129c548018f",
138
+ VITE_FARO_COLLECTOR_URL: "https://grafana-faro-collector.dev.0hash.com/collect",
139
+ VITE_FEATURE_SERVER_PROXY_URL: "https://ff-edge.dev.0hash.com/api/frontend",
140
+ VITE_INTERNAL_BUILD: "true",
141
+ VITE_ONBOARDING_API_BASE_URL: "/onboarding",
142
+ VITE_POST_MESSAGE_COMMUNICATION_PLATFORMS: "UW6VWU",
143
+ VITE_REDIRECT_HANDLER_URL: "http://localhost:4202/redirect-handler/index.html",
144
+ VITE_SCRAPER_EXTENSION_ID_CHROMIUM: "kofibejdfkmnbobmbogndbiimkflcllf",
145
+ VITE_TRADE_API_BASE_URL: "/trade",
146
+ VITE_UNLEASH_APIKEY: "zerohash-sdk:dev.b0d8aa594e9b94564f885167881bcb9dc69332f935fcb253e656ff34"
147
+ }.VITE_LOCAL_CDN_HOST || "http://localhost:5173",
148
+ dev: "https://sdk-cdn.dev.0hash.com",
149
+ cert: "https://sdk-cdn.cert.zerohash.com",
150
+ prod: "https://sdk-cdn.zerohash.com",
151
+ "eu-cert": "https://sdk-cdn.cert.zerohash.eu",
152
+ "eu-prod": "https://sdk-cdn.zerohash.eu"
153
+ }, y = "https://sdk-cdn.gating.0hash.com", b = (e, t, n = {}) => {
154
+ let { eu: r = !1, legacyAliases: i = !1, local: a = v.local } = n, o = (n) => `${n}/${e}/${t}`, s = {
155
+ local: o(a),
156
+ dev: o(v.dev),
157
+ gating: o(y),
158
+ cert: o(v.cert),
159
+ prod: o(v.prod)
160
+ };
161
+ return i && (s.sandbox = o(v.cert), s.production = o(v.prod)), r && (s["eu-cert"] = o(v["eu-cert"]), s["eu-prod"] = o(v["eu-prod"])), s;
152
162
  };
153
- var A;
163
+ ({
164
+ LOADED: "travel_rule_loaded",
165
+ COMPLETED: "travel_rule_completed"
166
+ }).LOADED;
167
+ //#endregion
168
+ //#region ../../../common/callbacks/dist/shared/models.js
169
+ var x;
154
170
  (function(e) {
155
- 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";
156
- })(A || (A = {}));
157
- const _ = {
158
- evergreen: "#00381D",
159
- green: "#CCFFD0",
160
- offBlack: "#1C1B1C",
161
- grayLight: "#EBEBE9"
162
- }, ee = ({ onRetry: e, onClose: t }) => W("div", { role: "alert", style: {
163
- position: "relative",
164
- display: "flex",
165
- flexDirection: "column",
166
- alignItems: "center",
167
- gap: "8px",
168
- maxWidth: "360px",
169
- margin: "0 auto",
170
- padding: "32px 24px",
171
- textAlign: "center",
172
- fontFamily: "inherit",
173
- color: _.offBlack,
174
- background: "#FFFFFF",
175
- border: `1px solid ${_.grayLight}`,
176
- borderRadius: "12px"
177
- }, children: [t && d("button", { type: "button", onClick: t, "aria-label": "Close", style: {
178
- position: "absolute",
179
- top: "12px",
180
- right: "12px",
181
- display: "flex",
182
- padding: "4px",
183
- color: _.offBlack,
184
- background: "none",
185
- border: "none",
186
- cursor: "pointer",
187
- lineHeight: 0
188
- }, children: d("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", children: d("path", { d: "M18 6L6 18M6 6l12 12", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) }) }), d("svg", { width: "32", height: "32", viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", children: d("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" }) }), d("p", { style: { margin: 0, fontSize: "16px", fontWeight: 600 }, children: "Something went wrong" }), d("p", { style: { margin: 0, fontSize: "14px", opacity: 0.75 }, children: "We couldn't load this content. Please check your internet connection and try again." }), d("button", { type: "button", onClick: e, style: {
189
- marginTop: "8px",
190
- padding: "8px 20px",
191
- fontSize: "14px",
192
- fontWeight: 600,
193
- fontFamily: "inherit",
194
- color: _.green,
195
- background: _.evergreen,
196
- border: "none",
197
- borderRadius: "8px",
198
- cursor: "pointer"
199
- }, children: "Try again" })] }), te = (e, t) => {
200
- B(() => {
201
- const o = e.current;
202
- if (o)
203
- for (const [r, c] of Object.entries(t))
204
- c !== void 0 && (o[r] = c);
205
- });
206
- }, oe = (e) => {
207
- const { webComponentTag: t, appName: o, appVersion: r, scriptUrls: c, fallbackScriptUrls: i, collectorUrls: n, env: a, jwt: s, timeoutMs: h } = e, [b, m] = L(!1), [p, R] = L(0);
208
- B(() => (m(!1), Z({
209
- webComponentTag: t,
210
- appName: o ?? t,
211
- appVersion: r,
212
- scriptUrls: c,
213
- fallbackScriptUrls: i,
214
- collectorUrls: n ?? V,
215
- env: a,
216
- jwt: s,
217
- timeoutMs: h,
218
- onError: () => m(!0)
219
- })), [
220
- t,
221
- o,
222
- r,
223
- c,
224
- i,
225
- n,
226
- a,
227
- s,
228
- h,
229
- p
230
- ]);
231
- const S = M(() => R((g) => g + 1), []);
232
- return { loadFailed: b, retry: S };
233
- }, re = Y("crypto-account-link-web", "index.js", { eu: !0 }), F = "zerohash-crypto-account-link", ce = ({
234
- jwt: e,
235
- env: t = "prod",
236
- theme: o,
237
- isPayouts: r = !1,
238
- onCompleted: c,
239
- onError: i,
240
- onClose: n,
241
- onLoaded: a,
242
- onExternalAccountCreated: s,
243
- onEvent: h,
244
- ...b
245
- }) => {
246
- const m = j(null);
247
- te(m, { theme: o, onCompleted: c, onError: i, onClose: n, onLoaded: a, onExternalAccountCreated: s, onEvent: h });
248
- const { loadFailed: p, retry: R } = oe({
249
- webComponentTag: F,
250
- scriptUrls: re,
251
- env: t,
252
- jwt: e
253
- });
254
- return p ? /* @__PURE__ */ d(
255
- ee,
256
- {
257
- onRetry: R,
258
- onClose: n
259
- }
260
- ) : D.createElement(F, {
261
- ref: m,
262
- jwt: e,
263
- env: t,
264
- theme: o,
265
- "is-payouts": r,
266
- ...b
267
- });
268
- };
269
- export {
270
- ce as CryptoAccountLink
171
+ 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
+ })(x ||= {});
173
+ //#endregion
174
+ //#region ../../../common/react-sdk-base/dist/script-load-fallback.js
175
+ var S = {
176
+ evergreen: "#00381D",
177
+ green: "#CCFFD0",
178
+ offBlack: "#1C1B1C",
179
+ grayLight: "#EBEBE9"
180
+ }, C = ({ onRetry: n, onClose: r }) => t("div", {
181
+ role: "alert",
182
+ style: {
183
+ position: "relative",
184
+ display: "flex",
185
+ flexDirection: "column",
186
+ alignItems: "center",
187
+ gap: "8px",
188
+ maxWidth: "360px",
189
+ margin: "0 auto",
190
+ padding: "32px 24px",
191
+ textAlign: "center",
192
+ fontFamily: "inherit",
193
+ color: S.offBlack,
194
+ background: "#FFFFFF",
195
+ border: `1px solid ${S.grayLight}`,
196
+ borderRadius: "12px"
197
+ },
198
+ children: [
199
+ r && e("button", {
200
+ type: "button",
201
+ onClick: r,
202
+ "aria-label": "Close",
203
+ style: {
204
+ position: "absolute",
205
+ top: "12px",
206
+ right: "12px",
207
+ display: "flex",
208
+ padding: "4px",
209
+ color: S.offBlack,
210
+ background: "none",
211
+ border: "none",
212
+ cursor: "pointer",
213
+ lineHeight: 0
214
+ },
215
+ children: e("svg", {
216
+ width: "20",
217
+ height: "20",
218
+ viewBox: "0 0 24 24",
219
+ fill: "none",
220
+ "aria-hidden": "true",
221
+ children: e("path", {
222
+ d: "M18 6L6 18M6 6l12 12",
223
+ stroke: "currentColor",
224
+ strokeWidth: "1.5",
225
+ strokeLinecap: "round",
226
+ strokeLinejoin: "round"
227
+ })
228
+ })
229
+ }),
230
+ e("svg", {
231
+ width: "32",
232
+ height: "32",
233
+ viewBox: "0 0 24 24",
234
+ fill: "none",
235
+ "aria-hidden": "true",
236
+ children: e("path", {
237
+ 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: S.evergreen,
239
+ strokeWidth: "1.5",
240
+ strokeLinecap: "round",
241
+ strokeLinejoin: "round"
242
+ })
243
+ }),
244
+ e("p", {
245
+ style: {
246
+ margin: 0,
247
+ fontSize: "16px",
248
+ fontWeight: 600
249
+ },
250
+ children: "Something went wrong"
251
+ }),
252
+ e("p", {
253
+ style: {
254
+ margin: 0,
255
+ fontSize: "14px",
256
+ opacity: .75
257
+ },
258
+ children: "We couldn't load this content. Please check your internet connection and try again."
259
+ }),
260
+ e("button", {
261
+ type: "button",
262
+ onClick: n,
263
+ style: {
264
+ marginTop: "8px",
265
+ padding: "8px 20px",
266
+ fontSize: "14px",
267
+ fontWeight: 600,
268
+ fontFamily: "inherit",
269
+ color: S.green,
270
+ background: S.evergreen,
271
+ border: "none",
272
+ borderRadius: "8px",
273
+ cursor: "pointer"
274
+ },
275
+ children: "Try again"
276
+ })
277
+ ]
278
+ }), w = (e, t) => {
279
+ i(() => {
280
+ let n = e.current;
281
+ if (n) for (let [e, r] of Object.entries(t)) r !== void 0 && (n[e] = r);
282
+ });
283
+ }, T = (e) => {
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, v] = o(0);
285
+ return i(() => (h(!1), _({
286
+ webComponentTag: t,
287
+ appName: n ?? t,
288
+ appVersion: a,
289
+ scriptUrls: c,
290
+ fallbackScriptUrls: l,
291
+ collectorUrls: u ?? s,
292
+ env: d,
293
+ jwt: f,
294
+ timeoutMs: p,
295
+ onError: () => h(!0)
296
+ })), [
297
+ t,
298
+ n,
299
+ a,
300
+ c,
301
+ l,
302
+ u,
303
+ d,
304
+ f,
305
+ p,
306
+ g
307
+ ]), {
308
+ loadFailed: m,
309
+ retry: r(() => v((e) => e + 1), [])
310
+ };
311
+ }, E = b("crypto-account-link-web", "index.js", { eu: !0 }), D = "zerohash-crypto-account-link", O = ({ jwt: t, env: r = "prod", theme: i, isPayouts: o = !1, onCompleted: s, onError: c, onClose: l, onLoaded: u, onExternalAccountCreated: d, onEvent: f, ...p }) => {
312
+ let m = a(null);
313
+ w(m, {
314
+ theme: i,
315
+ onCompleted: s,
316
+ onError: c,
317
+ onClose: l,
318
+ onLoaded: u,
319
+ onExternalAccountCreated: d,
320
+ onEvent: f
321
+ });
322
+ let { loadFailed: h, retry: g } = T({
323
+ webComponentTag: D,
324
+ scriptUrls: E,
325
+ env: r,
326
+ jwt: t
327
+ });
328
+ return h ? /* @__PURE__ */ e(C, {
329
+ onRetry: g,
330
+ onClose: l
331
+ }) : n.createElement(D, {
332
+ ref: m,
333
+ jwt: t,
334
+ env: r,
335
+ theme: i,
336
+ "is-payouts": o,
337
+ ...p
338
+ });
271
339
  };
340
+ //#endregion
341
+ export { O as CryptoAccountLink };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zerohash-sdk/crypto-account-link-react",
3
- "version": "1.14.4",
3
+ "version": "1.14.5",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -4,16 +4,19 @@ import * as path from 'path';
4
4
  import { defineConfig } from 'vite';
5
5
  import dts from 'vite-plugin-dts';
6
6
 
7
+ // eslint-disable-next-line @nx/enforce-module-boundaries
8
+ import { rolldownCjsInterop } from '../../../../vite-cjs-interop.config.mjs';
9
+
7
10
  export default defineConfig(() => ({
8
- root: __dirname,
11
+ root: import.meta.dirname,
9
12
  cacheDir: '../../../../node_modules/.vite/src/crypto-account-link/sdks/react',
10
13
  plugins: [
14
+ rolldownCjsInterop(),
11
15
  react(),
12
16
  dts({
13
17
  entryRoot: 'src',
14
- tsconfigPath: path.join(__dirname, 'tsconfig.lib.json'),
15
- rollupTypes: true, // Bundle all type dependencies
16
- bundledPackages: ['@zerohash/callbacks'], // Explicitly bundle callbacks types
18
+ tsconfigPath: path.join(import.meta.dirname, 'tsconfig.lib.json'),
19
+ bundleTypes: { bundledPackages: ['@zerohash/callbacks'] }, // Bundle all type dependencies
17
20
  }),
18
21
  ],
19
22
  // Uncomment this if you are using workers.
@@ -26,9 +29,6 @@ export default defineConfig(() => ({
26
29
  outDir: './dist',
27
30
  emptyOutDir: true,
28
31
  reportCompressedSize: true,
29
- commonjsOptions: {
30
- transformMixedEsModules: true,
31
- },
32
32
  lib: {
33
33
  // Could also be a dictionary or array of multiple entry points.
34
34
  entry: 'src/index.ts',
@@ -38,7 +38,7 @@ export default defineConfig(() => ({
38
38
  // Don't forget to update your package.json as well.
39
39
  formats: ['es' as const],
40
40
  },
41
- rollupOptions: {
41
+ rolldownOptions: {
42
42
  // External packages that should not be bundled into your library.
43
43
  external: ['react', 'react-dom', 'react/jsx-runtime'],
44
44
  },