@connect-xyz/auth-react 0.84.16 → 0.84.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.
Files changed (2) hide show
  1. package/dist/index.js +92 -78
  2. 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, useRef as a, useState as o } from "react";
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 s = {
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
- }, c = (e) => typeof e == "object" && !!e && !Array.isArray(e), l = (e) => {
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 = c(i) ? i.payload : void 0, o = c(a) ? a.region : void 0;
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
- }, u = (e, t) => l(t) === "eu" ? e === "cert" ? "eu-cert" : e === "prod" ? "eu-prod" : e : e, d = (e) => {
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 (!c(i)) return {};
31
- let a = c(i.payload) ? i.payload : {}, o = (e) => typeof e == "string" && e.length > 0 ? e : void 0;
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
- }, 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 = () => {
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
- }, g = (e, t) => {
45
- let n = h(), r = Reflect.get(globalThis, "__ZH_WEB_SDK_VERSION__"), i = typeof r == "string" ? r : void 0, a = {};
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
- }, _ = (e, t, n) => {
76
+ }, v = (e, t, n) => {
77
77
  if (!e || typeof fetch > "u") return;
78
- let { sessionId: r, payload: i } = g(t, n);
79
- try {
80
- fetch(e, {
81
- method: "POST",
82
- headers: {
83
- "Content-Type": "application/json",
84
- "x-faro-session-id": r
85
- },
86
- body: JSON.stringify(i),
87
- keepalive: !0
88
- }).catch(() => void 0);
89
- } catch {}
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;
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 m;
95
- let v = d(c), y = e.report ?? ((e) => _(o && p(o, s, c), e, r)), b = !1, x = 0, S, C = () => {
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: v
109
+ claims: _
108
110
  };
109
111
  y(l);
110
- let u = i ? void 0 : f(a ?? {}, s, c);
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(), h?.(l);
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,13 +123,13 @@ 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 = f(i, s, c);
126
+ }, E = p(i, s, c);
125
127
  return E ? (T(E, !1), () => {
126
128
  b = !0, C();
127
- }) : m;
128
- }, y = () => {
129
+ }) : h;
130
+ }, b = () => {
129
131
  if (typeof __ZH_SDK_PACKAGE_VERSION__ == "string" && __ZH_SDK_PACKAGE_VERSION__) return __ZH_SDK_PACKAGE_VERSION__;
130
- }, b = {
132
+ }, x = {
131
133
  local: {
132
134
  BASE_URL: "/",
133
135
  DEV: !1,
@@ -147,7 +149,8 @@ var s = {
147
149
  VITE_REDIRECT_HANDLER_URL: "http://localhost:4202/redirect-handler/index.html",
148
150
  VITE_SCRAPER_EXTENSION_ID_CHROMIUM: "kofibejdfkmnbobmbogndbiimkflcllf",
149
151
  VITE_TRADE_API_BASE_URL: "/trade",
150
- VITE_UNLEASH_APIKEY: "zerohash-sdk:dev.b0d8aa594e9b94564f885167881bcb9dc69332f935fcb253e656ff34"
152
+ VITE_UNLEASH_APIKEY: "zerohash-sdk:dev.b0d8aa594e9b94564f885167881bcb9dc69332f935fcb253e656ff34",
153
+ VITE_WALLET_DEPOSIT_DEBUG_PLATFORMS: "UW6VWU"
151
154
  }.VITE_LOCAL_CDN_HOST || "http://localhost:5173",
152
155
  dev: "https://sdk-cdn.dev.0hash.com",
153
156
  cert: "https://sdk-cdn.cert.zerohash.com",
@@ -155,24 +158,24 @@ var s = {
155
158
  "eu-cert": "https://sdk-cdn.cert.zerohash.eu",
156
159
  "eu-prod": "https://sdk-cdn.zerohash.eu"
157
160
  };
158
- [...Object.entries(b).filter(([e]) => e !== "local").map(([, e]) => e)], {
161
+ [...Object.entries(x).filter(([e]) => e !== "local").map(([, e]) => e)], {
159
162
  LOADED: "travel_rule_loaded",
160
163
  COMPLETED: "travel_rule_completed"
161
164
  }.LOADED;
162
165
  //#endregion
163
166
  //#region ../../../common/callbacks/dist/shared/models.js
164
- var x;
167
+ var S;
165
168
  (function(e) {
166
169
  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";
167
- })(x ||= {});
170
+ })(S ||= {});
168
171
  //#endregion
169
172
  //#region ../../../common/react-sdk-base/dist/script-load-fallback.js
170
- var S = {
173
+ var C = {
171
174
  evergreen: "#00381D",
172
175
  green: "#CCFFD0",
173
176
  offBlack: "#1C1B1C",
174
177
  grayLight: "#EBEBE9"
175
- }, C = ({ onRetry: n, onClose: r }) => t("div", {
178
+ }, w = ({ onRetry: n, onClose: r }) => t("div", {
176
179
  role: "alert",
177
180
  style: {
178
181
  position: "relative",
@@ -185,9 +188,9 @@ var S = {
185
188
  padding: "32px 24px",
186
189
  textAlign: "center",
187
190
  fontFamily: "inherit",
188
- color: S.offBlack,
191
+ color: C.offBlack,
189
192
  background: "#FFFFFF",
190
- border: `1px solid ${S.grayLight}`,
193
+ border: `1px solid ${C.grayLight}`,
191
194
  borderRadius: "12px"
192
195
  },
193
196
  children: [
@@ -201,7 +204,7 @@ var S = {
201
204
  right: "12px",
202
205
  display: "flex",
203
206
  padding: "4px",
204
- color: S.offBlack,
207
+ color: C.offBlack,
205
208
  background: "none",
206
209
  border: "none",
207
210
  cursor: "pointer",
@@ -230,7 +233,7 @@ var S = {
230
233
  "aria-hidden": "true",
231
234
  children: e("path", {
232
235
  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",
233
- stroke: S.evergreen,
236
+ stroke: C.evergreen,
234
237
  strokeWidth: "1.5",
235
238
  strokeLinecap: "round",
236
239
  strokeLinejoin: "round"
@@ -261,8 +264,8 @@ var S = {
261
264
  fontSize: "14px",
262
265
  fontWeight: 600,
263
266
  fontFamily: "inherit",
264
- color: S.green,
265
- background: S.evergreen,
267
+ color: C.green,
268
+ background: C.evergreen,
266
269
  border: "none",
267
270
  borderRadius: "8px",
268
271
  cursor: "pointer"
@@ -270,69 +273,80 @@ var S = {
270
273
  children: "Try again"
271
274
  })
272
275
  ]
273
- }), w = (e, t) => {
276
+ }), T = (e, t) => {
274
277
  i(() => {
275
278
  let n = e.current;
276
279
  if (n) for (let [e, r] of Object.entries(t)) r !== void 0 && Reflect.set(n, e, r);
277
280
  });
278
- }, T = (e) => {
279
- 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);
280
- return i(() => (h(!1), v({
281
+ }, E = (e) => {
282
+ 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(() => ({
281
283
  webComponentTag: t,
282
284
  appName: n ?? t,
283
- appVersion: a,
284
- scriptUrls: c,
285
- fallbackScriptUrls: l,
286
- collectorUrls: u ?? s,
287
- env: d,
288
- jwt: f,
289
- timeoutMs: p,
290
- onError: () => h(!0)
291
- })), [
285
+ appVersion: o,
286
+ scriptUrls: l,
287
+ fallbackScriptUrls: u,
288
+ collectorUrls: d ?? c,
289
+ env: f,
290
+ jwt: p,
291
+ timeoutMs: m,
292
+ retryNonce: h
293
+ }), [
292
294
  t,
293
295
  n,
294
- a,
295
- c,
296
+ o,
296
297
  l,
297
298
  u,
298
299
  d,
299
300
  f,
300
301
  p,
301
- g
302
- ]), {
303
- loadFailed: m,
304
- retry: r(() => _((e) => e + 1), [])
302
+ m,
303
+ h
304
+ ]), [v, b] = s(null), x = v === _;
305
+ return i(() => y({
306
+ webComponentTag: _.webComponentTag,
307
+ appName: _.appName,
308
+ appVersion: _.appVersion,
309
+ scriptUrls: _.scriptUrls,
310
+ fallbackScriptUrls: _.fallbackScriptUrls,
311
+ collectorUrls: _.collectorUrls,
312
+ env: _.env,
313
+ jwt: _.jwt,
314
+ timeoutMs: _.timeoutMs,
315
+ onError: () => b(_)
316
+ }), [_]), {
317
+ loadFailed: x,
318
+ retry: r(() => g((e) => e + 1), [])
305
319
  };
306
- }, E = {
320
+ }, D = {
307
321
  sandbox: "https://sdk.sandbox.connect.xyz/auth-web/index.js",
308
322
  production: "https://sdk.connect.xyz/auth-web/index.js"
309
- }, D = "connect-auth", O = E, k = ({ jwt: t, env: r = "production", theme: i, onError: o, onClose: s, onDeposit: c, onEvent: l, onLoaded: u, ...d }) => {
310
- let f = a(null);
311
- w(f, {
323
+ }, O = "connect-auth", k = D, A = ({ jwt: t, env: r = "production", theme: i, onError: a, onClose: s, onDeposit: c, onEvent: l, onLoaded: u, ...d }) => {
324
+ let f = o(null);
325
+ T(f, {
312
326
  theme: i,
313
- onError: o,
327
+ onError: a,
314
328
  onClose: s,
315
329
  onDeposit: c,
316
330
  onEvent: l,
317
331
  onLoaded: u
318
332
  });
319
- let { loadFailed: p, retry: m } = T({
320
- webComponentTag: D,
321
- scriptUrls: O,
333
+ let { loadFailed: p, retry: m } = E({
334
+ webComponentTag: O,
335
+ scriptUrls: k,
322
336
  env: r,
323
337
  jwt: t
324
338
  });
325
- return p ? /* @__PURE__ */ e(C, {
339
+ return p ? /* @__PURE__ */ e(w, {
326
340
  onRetry: m,
327
341
  onClose: s
328
- }) : n.createElement(D, {
342
+ }) : n.createElement(O, {
329
343
  ref: f,
330
344
  jwt: t,
331
345
  env: r,
332
- sdkversion: y(),
346
+ sdkversion: b(),
333
347
  theme: i,
334
348
  ...d
335
349
  });
336
350
  };
337
351
  //#endregion
338
- export { k as Auth };
352
+ export { A as Auth };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@connect-xyz/auth-react",
3
- "version": "0.84.16",
3
+ "version": "0.84.18",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",