@connect-xyz/auth-react 0.84.14 → 0.84.16

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 +167 -164
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,115 +1,7 @@
1
1
  import { jsx as e, jsxs as t } from "react/jsx-runtime";
2
2
  import n, { useCallback as r, useEffect as i, useRef as a, useState as o } from "react";
3
- //#region ../../../common/react-sdk-base/dist/script-load-fallback.js
3
+ //#region ../../../common/js-sdk-base/dist/constants.js
4
4
  var s = {
5
- evergreen: "#00381D",
6
- green: "#CCFFD0",
7
- offBlack: "#1C1B1C",
8
- grayLight: "#EBEBE9"
9
- }, c = ({ onRetry: n, onClose: r }) => t("div", {
10
- role: "alert",
11
- style: {
12
- position: "relative",
13
- display: "flex",
14
- flexDirection: "column",
15
- alignItems: "center",
16
- gap: "8px",
17
- maxWidth: "360px",
18
- margin: "0 auto",
19
- padding: "32px 24px",
20
- textAlign: "center",
21
- fontFamily: "inherit",
22
- color: s.offBlack,
23
- background: "#FFFFFF",
24
- border: `1px solid ${s.grayLight}`,
25
- borderRadius: "12px"
26
- },
27
- children: [
28
- r && e("button", {
29
- type: "button",
30
- onClick: r,
31
- "aria-label": "Close",
32
- style: {
33
- position: "absolute",
34
- top: "12px",
35
- right: "12px",
36
- display: "flex",
37
- padding: "4px",
38
- color: s.offBlack,
39
- background: "none",
40
- border: "none",
41
- cursor: "pointer",
42
- lineHeight: 0
43
- },
44
- children: e("svg", {
45
- width: "20",
46
- height: "20",
47
- viewBox: "0 0 24 24",
48
- fill: "none",
49
- "aria-hidden": "true",
50
- children: e("path", {
51
- d: "M18 6L6 18M6 6l12 12",
52
- stroke: "currentColor",
53
- strokeWidth: "1.5",
54
- strokeLinecap: "round",
55
- strokeLinejoin: "round"
56
- })
57
- })
58
- }),
59
- e("svg", {
60
- width: "32",
61
- height: "32",
62
- viewBox: "0 0 24 24",
63
- fill: "none",
64
- "aria-hidden": "true",
65
- children: e("path", {
66
- 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",
67
- stroke: s.evergreen,
68
- strokeWidth: "1.5",
69
- strokeLinecap: "round",
70
- strokeLinejoin: "round"
71
- })
72
- }),
73
- e("p", {
74
- style: {
75
- margin: 0,
76
- fontSize: "16px",
77
- fontWeight: 600
78
- },
79
- children: "Something went wrong"
80
- }),
81
- e("p", {
82
- style: {
83
- margin: 0,
84
- fontSize: "14px",
85
- opacity: .75
86
- },
87
- children: "We couldn't load this content. Please check your internet connection and try again."
88
- }),
89
- e("button", {
90
- type: "button",
91
- onClick: n,
92
- style: {
93
- marginTop: "8px",
94
- padding: "8px 20px",
95
- fontSize: "14px",
96
- fontWeight: 600,
97
- fontFamily: "inherit",
98
- color: s.green,
99
- background: s.evergreen,
100
- border: "none",
101
- borderRadius: "8px",
102
- cursor: "pointer"
103
- },
104
- children: "Try again"
105
- })
106
- ]
107
- }), l = (e, t) => {
108
- i(() => {
109
- let n = e.current;
110
- if (n) for (let [e, r] of Object.entries(t)) r !== void 0 && Reflect.set(n, e, r);
111
- });
112
- }, u = {
113
5
  dev: "https://grafana-faro-collector.dev.0hash.com/collect",
114
6
  cert: "https://grafana-faro-collector.cert.zerohash.com/collect",
115
7
  prod: "https://grafana-faro-collector.zerohash.com/collect",
@@ -117,26 +9,26 @@ var s = {
117
9
  "eu-prod": "https://grafana-faro-collector.zerohash.eu/collect",
118
10
  sandbox: "https://grafana-faro-collector.cert.zerohash.com/collect",
119
11
  production: "https://grafana-faro-collector.zerohash.com/collect"
120
- }, d = (e) => typeof e == "object" && !!e && !Array.isArray(e), f = (e) => {
12
+ }, c = (e) => typeof e == "object" && !!e && !Array.isArray(e), l = (e) => {
121
13
  if (!e || typeof e != "string") return null;
122
14
  let t = e.split(".");
123
15
  if (t.length < 2) return null;
124
16
  try {
125
- 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 = d(i) ? i.payload : void 0, o = d(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 = c(i) ? i.payload : void 0, o = c(a) ? a.region : void 0;
126
18
  if (typeof o != "string") return null;
127
19
  let s = o.toLowerCase();
128
20
  return s === "us" || s === "eu" ? s : null;
129
21
  } catch {
130
22
  return null;
131
23
  }
132
- }, p = (e, t) => f(t) === "eu" ? e === "cert" ? "eu-cert" : e === "prod" ? "eu-prod" : e : e, m = (e) => {
24
+ }, u = (e, t) => l(t) === "eu" ? e === "cert" ? "eu-cert" : e === "prod" ? "eu-prod" : e : e, d = (e) => {
133
25
  if (!e || typeof e != "string") return {};
134
26
  let t = e.split(".");
135
27
  if (t.length < 2) return {};
136
28
  try {
137
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);
138
- if (!d(i)) return {};
139
- let a = d(i.payload) ? i.payload : {}, o = (e) => typeof e == "string" && e.length > 0 ? e : void 0;
30
+ if (!c(i)) return {};
31
+ let a = c(i.payload) ? i.payload : {}, o = (e) => typeof e == "string" && e.length > 0 ? e : void 0;
140
32
  return {
141
33
  participantCode: o(a.participant_code),
142
34
  platformName: o(a.platform_name),
@@ -146,11 +38,11 @@ var s = {
146
38
  } catch {
147
39
  return {};
148
40
  }
149
- }, h = (e, t, n) => e[p(t, n)] ?? e[t] ?? e.prod, g = (e, t, n) => e[p(t, n)] ?? e[t], _ = () => void 0, v = () => {
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 = () => {
150
42
  let e = /* @__PURE__ */ new Uint8Array(8);
151
43
  return globalThis.crypto.getRandomValues(e), Array.from(e, (e) => e.toString(16).padStart(2, "0")).join("");
152
- }, y = (e, t) => {
153
- let n = v(), r = Reflect.get(globalThis, "__ZH_WEB_SDK_VERSION__"), i = typeof r == "string" ? r : void 0, a = {};
44
+ }, g = (e, t) => {
45
+ let n = h(), r = Reflect.get(globalThis, "__ZH_WEB_SDK_VERSION__"), i = typeof r == "string" ? r : void 0, a = {};
154
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), {
155
47
  sessionId: n,
156
48
  payload: {
@@ -181,9 +73,9 @@ var s = {
181
73
  }]
182
74
  }
183
75
  };
184
- }, b = (e, t, n) => {
76
+ }, _ = (e, t, n) => {
185
77
  if (!e || typeof fetch > "u") return;
186
- let { sessionId: r, payload: i } = y(t, n);
78
+ let { sessionId: r, payload: i } = g(t, n);
187
79
  try {
188
80
  fetch(e, {
189
81
  method: "POST",
@@ -195,15 +87,15 @@ var s = {
195
87
  keepalive: !0
196
88
  }).catch(() => void 0);
197
89
  } catch {}
198
- }, x = (e) => {
199
- 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;
200
- if (typeof document > "u") return _;
201
- let f = `${t}-script-${s}`;
202
- if (customElements.get(t) || document.getElementById(f)) return _;
203
- let p = m(c), v = e.report ?? ((e) => b(o && g(o, s, c), e, r)), y = !1, x = 0, S, C = () => {
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;
93
+ 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 = () => {
204
96
  S !== void 0 && clearTimeout(S);
205
97
  }, w = (e, r, i) => {
206
- if (y) return;
98
+ if (b) return;
207
99
  let o = Math.round(performance.now() - x), l = {
208
100
  webComponentTag: t,
209
101
  appName: n,
@@ -212,28 +104,30 @@ var s = {
212
104
  reason: e,
213
105
  triedFallback: i,
214
106
  elapsedMs: o,
215
- claims: p
107
+ claims: v
216
108
  };
217
- v(l);
218
- let u = i ? void 0 : h(a ?? {}, s, c);
109
+ y(l);
110
+ let u = i ? void 0 : f(a ?? {}, s, c);
219
111
  if (u && u !== r) {
220
112
  T(u, !0);
221
113
  return;
222
114
  }
223
- y = !0, C(), document.getElementById(f)?.remove(), d?.(l);
115
+ b = !0, C(), document.getElementById(g)?.remove(), h?.(l);
224
116
  }, T = (e, n) => {
225
117
  C(), x = performance.now();
226
118
  let r = document.createElement("script");
227
- r.id = f, r.src = e, r.type = "module", r.async = !0, r.addEventListener("load", () => {
119
+ r.id = g, r.src = e, r.type = "module", r.async = !0, r.addEventListener("load", () => {
228
120
  setTimeout(() => {
229
- y || (customElements.get(t) ? (y = !0, C(), u?.()) : w("not-defined", e, n));
121
+ b || (customElements.get(t) ? (b = !0, C(), u?.()) : w("not-defined", e, n));
230
122
  }, 0);
231
- }), r.addEventListener("error", () => w("network", e, n)), S = setTimeout(() => w("timeout", e, n), l), document.getElementById(f)?.remove(), document.head.appendChild(r);
232
- }, E = h(i, s, c);
123
+ }), 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);
233
125
  return E ? (T(E, !1), () => {
234
- y = !0, C();
235
- }) : _;
236
- }, S = {
126
+ b = !0, C();
127
+ }) : m;
128
+ }, y = () => {
129
+ if (typeof __ZH_SDK_PACKAGE_VERSION__ == "string" && __ZH_SDK_PACKAGE_VERSION__) return __ZH_SDK_PACKAGE_VERSION__;
130
+ }, b = {
237
131
  local: {
238
132
  BASE_URL: "/",
239
133
  DEV: !1,
@@ -261,27 +155,135 @@ var s = {
261
155
  "eu-cert": "https://sdk-cdn.cert.zerohash.eu",
262
156
  "eu-prod": "https://sdk-cdn.zerohash.eu"
263
157
  };
264
- [...Object.entries(S).filter(([e]) => e !== "local").map(([, e]) => e)], {
158
+ [...Object.entries(b).filter(([e]) => e !== "local").map(([, e]) => e)], {
265
159
  LOADED: "travel_rule_loaded",
266
160
  COMPLETED: "travel_rule_completed"
267
161
  }.LOADED;
268
162
  //#endregion
269
163
  //#region ../../../common/callbacks/dist/shared/models.js
270
- var C;
164
+ var x;
271
165
  (function(e) {
272
166
  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";
273
- })(C ||= {});
167
+ })(x ||= {});
274
168
  //#endregion
275
- //#region ../../../common/react-sdk-base/dist/use-web-component-script.js
276
- var w = (e) => {
277
- let { webComponentTag: t, appName: n, appVersion: a, scriptUrls: s, fallbackScriptUrls: c, collectorUrls: l, env: d, jwt: f, timeoutMs: p } = e, [m, h] = o(!1), [g, _] = o(0);
278
- return i(() => (h(!1), x({
169
+ //#region ../../../common/react-sdk-base/dist/script-load-fallback.js
170
+ var S = {
171
+ evergreen: "#00381D",
172
+ green: "#CCFFD0",
173
+ offBlack: "#1C1B1C",
174
+ grayLight: "#EBEBE9"
175
+ }, C = ({ onRetry: n, onClose: r }) => t("div", {
176
+ role: "alert",
177
+ style: {
178
+ position: "relative",
179
+ display: "flex",
180
+ flexDirection: "column",
181
+ alignItems: "center",
182
+ gap: "8px",
183
+ maxWidth: "360px",
184
+ margin: "0 auto",
185
+ padding: "32px 24px",
186
+ textAlign: "center",
187
+ fontFamily: "inherit",
188
+ color: S.offBlack,
189
+ background: "#FFFFFF",
190
+ border: `1px solid ${S.grayLight}`,
191
+ borderRadius: "12px"
192
+ },
193
+ children: [
194
+ r && e("button", {
195
+ type: "button",
196
+ onClick: r,
197
+ "aria-label": "Close",
198
+ style: {
199
+ position: "absolute",
200
+ top: "12px",
201
+ right: "12px",
202
+ display: "flex",
203
+ padding: "4px",
204
+ color: S.offBlack,
205
+ background: "none",
206
+ border: "none",
207
+ cursor: "pointer",
208
+ lineHeight: 0
209
+ },
210
+ children: e("svg", {
211
+ width: "20",
212
+ height: "20",
213
+ viewBox: "0 0 24 24",
214
+ fill: "none",
215
+ "aria-hidden": "true",
216
+ children: e("path", {
217
+ d: "M18 6L6 18M6 6l12 12",
218
+ stroke: "currentColor",
219
+ strokeWidth: "1.5",
220
+ strokeLinecap: "round",
221
+ strokeLinejoin: "round"
222
+ })
223
+ })
224
+ }),
225
+ e("svg", {
226
+ width: "32",
227
+ height: "32",
228
+ viewBox: "0 0 24 24",
229
+ fill: "none",
230
+ "aria-hidden": "true",
231
+ children: e("path", {
232
+ 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,
234
+ strokeWidth: "1.5",
235
+ strokeLinecap: "round",
236
+ strokeLinejoin: "round"
237
+ })
238
+ }),
239
+ e("p", {
240
+ style: {
241
+ margin: 0,
242
+ fontSize: "16px",
243
+ fontWeight: 600
244
+ },
245
+ children: "Something went wrong"
246
+ }),
247
+ e("p", {
248
+ style: {
249
+ margin: 0,
250
+ fontSize: "14px",
251
+ opacity: .75
252
+ },
253
+ children: "We couldn't load this content. Please check your internet connection and try again."
254
+ }),
255
+ e("button", {
256
+ type: "button",
257
+ onClick: n,
258
+ style: {
259
+ marginTop: "8px",
260
+ padding: "8px 20px",
261
+ fontSize: "14px",
262
+ fontWeight: 600,
263
+ fontFamily: "inherit",
264
+ color: S.green,
265
+ background: S.evergreen,
266
+ border: "none",
267
+ borderRadius: "8px",
268
+ cursor: "pointer"
269
+ },
270
+ children: "Try again"
271
+ })
272
+ ]
273
+ }), w = (e, t) => {
274
+ i(() => {
275
+ let n = e.current;
276
+ if (n) for (let [e, r] of Object.entries(t)) r !== void 0 && Reflect.set(n, e, r);
277
+ });
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({
279
281
  webComponentTag: t,
280
282
  appName: n ?? t,
281
283
  appVersion: a,
282
- scriptUrls: s,
283
- fallbackScriptUrls: c,
284
- collectorUrls: l ?? u,
284
+ scriptUrls: c,
285
+ fallbackScriptUrls: l,
286
+ collectorUrls: u ?? s,
285
287
  env: d,
286
288
  jwt: f,
287
289
  timeoutMs: p,
@@ -290,9 +292,9 @@ var w = (e) => {
290
292
  t,
291
293
  n,
292
294
  a,
293
- s,
294
295
  c,
295
296
  l,
297
+ u,
296
298
  d,
297
299
  f,
298
300
  p,
@@ -301,35 +303,36 @@ var w = (e) => {
301
303
  loadFailed: m,
302
304
  retry: r(() => _((e) => e + 1), [])
303
305
  };
304
- }, T = {
306
+ }, E = {
305
307
  sandbox: "https://sdk.sandbox.connect.xyz/auth-web/index.js",
306
308
  production: "https://sdk.connect.xyz/auth-web/index.js"
307
- }, E = "connect-auth", D = T, O = ({ jwt: t, env: r = "production", theme: i, onError: o, onClose: s, onDeposit: u, onEvent: d, onLoaded: f, ...p }) => {
308
- let m = a(null);
309
- l(m, {
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, {
310
312
  theme: i,
311
313
  onError: o,
312
314
  onClose: s,
313
- onDeposit: u,
314
- onEvent: d,
315
- onLoaded: f
315
+ onDeposit: c,
316
+ onEvent: l,
317
+ onLoaded: u
316
318
  });
317
- let { loadFailed: h, retry: g } = w({
318
- webComponentTag: E,
319
- scriptUrls: D,
319
+ let { loadFailed: p, retry: m } = T({
320
+ webComponentTag: D,
321
+ scriptUrls: O,
320
322
  env: r,
321
323
  jwt: t
322
324
  });
323
- return h ? /* @__PURE__ */ e(c, {
324
- onRetry: g,
325
+ return p ? /* @__PURE__ */ e(C, {
326
+ onRetry: m,
325
327
  onClose: s
326
- }) : n.createElement(E, {
327
- ref: m,
328
+ }) : n.createElement(D, {
329
+ ref: f,
328
330
  jwt: t,
329
331
  env: r,
332
+ sdkversion: y(),
330
333
  theme: i,
331
- ...p
334
+ ...d
332
335
  });
333
336
  };
334
337
  //#endregion
335
- export { O as Auth };
338
+ export { k as Auth };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@connect-xyz/auth-react",
3
- "version": "0.84.14",
3
+ "version": "0.84.16",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",