@connect-xyz/auth-react 0.84.13 → 0.84.15

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 +170 -165
  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 && (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,24 +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) => {
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)?.payload?.region;
126
- if (typeof i != "string") return null;
127
- let a = i.toLowerCase();
128
- return a === "us" || a === "eu" ? a : null;
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;
18
+ if (typeof o != "string") return null;
19
+ let s = o.toLowerCase();
20
+ return s === "us" || s === "eu" ? s : null;
129
21
  } catch {
130
22
  return null;
131
23
  }
132
- }, f = (e, t) => d(t) === "eu" ? e === "cert" ? "eu-cert" : e === "prod" ? "eu-prod" : e : e, p = (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
- 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;
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;
138
32
  return {
139
33
  participantCode: o(a.participant_code),
140
34
  platformName: o(a.platform_name),
@@ -144,12 +38,12 @@ var s = {
144
38
  } catch {
145
39
  return {};
146
40
  }
147
- }, m = (e, t, n) => e[f(t, n)] ?? e[t] ?? e.prod, h = (e, t, n) => e[f(t, n)] ?? e[t], g = () => void 0, _ = () => {
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 = () => {
148
42
  let e = /* @__PURE__ */ new Uint8Array(8);
149
43
  return globalThis.crypto.getRandomValues(e), Array.from(e, (e) => e.toString(16).padStart(2, "0")).join("");
150
- }, v = (e, t) => {
151
- let n = _(), r = globalThis.__ZH_WEB_SDK_VERSION__, i = {};
152
- 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), {
44
+ }, g = (e, t) => {
45
+ let n = h(), r = Reflect.get(globalThis, "__ZH_WEB_SDK_VERSION__"), i = typeof r == "string" ? r : void 0, a = {};
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), {
153
47
  sessionId: n,
154
48
  payload: {
155
49
  meta: {
@@ -160,7 +54,7 @@ var s = {
160
54
  },
161
55
  session: {
162
56
  id: n,
163
- attributes: i
57
+ attributes: a
164
58
  },
165
59
  browser: typeof navigator < "u" ? { userAgent: navigator.userAgent } : void 0,
166
60
  page: typeof window < "u" ? { url: window.location.origin } : void 0
@@ -179,9 +73,9 @@ var s = {
179
73
  }]
180
74
  }
181
75
  };
182
- }, y = (e, t, n) => {
76
+ }, _ = (e, t, n) => {
183
77
  if (!e || typeof fetch > "u") return;
184
- let { sessionId: r, payload: i } = v(t, n);
78
+ let { sessionId: r, payload: i } = g(t, n);
185
79
  try {
186
80
  fetch(e, {
187
81
  method: "POST",
@@ -193,12 +87,12 @@ var s = {
193
87
  keepalive: !0
194
88
  }).catch(() => void 0);
195
89
  } catch {}
196
- }, b = (e) => {
197
- 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;
198
- if (typeof document > "u") return g;
199
- let f = `${t}-script-${s}`;
200
- if (customElements.get(t) || document.getElementById(f)) return g;
201
- let _ = p(c), v = e.report ?? ((e) => y(o && h(o, s, c), e, r)), b = !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 = () => {
202
96
  S !== void 0 && clearTimeout(S);
203
97
  }, w = (e, r, i) => {
204
98
  if (b) return;
@@ -210,28 +104,30 @@ var s = {
210
104
  reason: e,
211
105
  triedFallback: i,
212
106
  elapsedMs: o,
213
- claims: _
107
+ claims: v
214
108
  };
215
- v(l);
216
- let u = i ? void 0 : m(a ?? {}, s, c);
109
+ y(l);
110
+ let u = i ? void 0 : f(a ?? {}, s, c);
217
111
  if (u && u !== r) {
218
112
  T(u, !0);
219
113
  return;
220
114
  }
221
- b = !0, C(), document.getElementById(f)?.remove(), d?.(l);
115
+ b = !0, C(), document.getElementById(g)?.remove(), h?.(l);
222
116
  }, T = (e, n) => {
223
117
  C(), x = performance.now();
224
118
  let r = document.createElement("script");
225
- r.id = f, r.src = e, r.type = "module", r.async = !0, r.onload = () => {
119
+ r.id = g, r.src = e, r.type = "module", r.async = !0, r.addEventListener("load", () => {
226
120
  setTimeout(() => {
227
121
  b || (customElements.get(t) ? (b = !0, C(), u?.()) : w("not-defined", e, n));
228
122
  }, 0);
229
- }, r.onerror = () => w("network", e, n), S = setTimeout(() => w("timeout", e, n), l), document.getElementById(f)?.remove(), document.head.appendChild(r);
230
- }, E = m(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);
231
125
  return E ? (T(E, !1), () => {
232
126
  b = !0, C();
233
- }) : g;
234
- }, x = {
127
+ }) : m;
128
+ }, y = () => {
129
+ if (typeof __ZH_SDK_PACKAGE_VERSION__ == "string" && __ZH_SDK_PACKAGE_VERSION__) return __ZH_SDK_PACKAGE_VERSION__;
130
+ }, b = {
235
131
  local: {
236
132
  BASE_URL: "/",
237
133
  DEV: !1,
@@ -259,27 +155,135 @@ var s = {
259
155
  "eu-cert": "https://sdk-cdn.cert.zerohash.eu",
260
156
  "eu-prod": "https://sdk-cdn.zerohash.eu"
261
157
  };
262
- [...Object.entries(x).filter(([e]) => e !== "local").map(([, e]) => e)], {
158
+ [...Object.entries(b).filter(([e]) => e !== "local").map(([, e]) => e)], {
263
159
  LOADED: "travel_rule_loaded",
264
160
  COMPLETED: "travel_rule_completed"
265
161
  }.LOADED;
266
162
  //#endregion
267
163
  //#region ../../../common/callbacks/dist/shared/models.js
268
- var S;
164
+ var x;
269
165
  (function(e) {
270
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";
271
- })(S ||= {});
167
+ })(x ||= {});
272
168
  //#endregion
273
- //#region ../../../common/react-sdk-base/dist/use-web-component-script.js
274
- var C = (e) => {
275
- 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);
276
- return i(() => (h(!1), b({
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({
277
281
  webComponentTag: t,
278
282
  appName: n ?? t,
279
283
  appVersion: a,
280
- scriptUrls: s,
281
- fallbackScriptUrls: c,
282
- collectorUrls: l ?? u,
284
+ scriptUrls: c,
285
+ fallbackScriptUrls: l,
286
+ collectorUrls: u ?? s,
283
287
  env: d,
284
288
  jwt: f,
285
289
  timeoutMs: p,
@@ -288,9 +292,9 @@ var C = (e) => {
288
292
  t,
289
293
  n,
290
294
  a,
291
- s,
292
295
  c,
293
296
  l,
297
+ u,
294
298
  d,
295
299
  f,
296
300
  p,
@@ -299,35 +303,36 @@ var C = (e) => {
299
303
  loadFailed: m,
300
304
  retry: r(() => _((e) => e + 1), [])
301
305
  };
302
- }, w = {
306
+ }, E = {
303
307
  sandbox: "https://sdk.sandbox.connect.xyz/auth-web/index.js",
304
308
  production: "https://sdk.connect.xyz/auth-web/index.js"
305
- }, T = "connect-auth", E = w, D = ({ jwt: t, env: r = "production", theme: i, onError: o, onClose: s, onDeposit: u, onEvent: d, onLoaded: f, ...p }) => {
306
- let m = a(null);
307
- 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, {
308
312
  theme: i,
309
313
  onError: o,
310
314
  onClose: s,
311
- onDeposit: u,
312
- onEvent: d,
313
- onLoaded: f
315
+ onDeposit: c,
316
+ onEvent: l,
317
+ onLoaded: u
314
318
  });
315
- let { loadFailed: h, retry: g } = C({
316
- webComponentTag: T,
317
- scriptUrls: E,
319
+ let { loadFailed: p, retry: m } = T({
320
+ webComponentTag: D,
321
+ scriptUrls: O,
318
322
  env: r,
319
323
  jwt: t
320
324
  });
321
- return h ? /* @__PURE__ */ e(c, {
322
- onRetry: g,
325
+ return p ? /* @__PURE__ */ e(C, {
326
+ onRetry: m,
323
327
  onClose: s
324
- }) : n.createElement(T, {
325
- ref: m,
328
+ }) : n.createElement(D, {
329
+ ref: f,
326
330
  jwt: t,
327
331
  env: r,
332
+ sdkversion: y(),
328
333
  theme: i,
329
- ...p
334
+ ...d
330
335
  });
331
336
  };
332
337
  //#endregion
333
- export { D 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.13",
3
+ "version": "0.84.15",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",