@connect-xyz/auth-react 0.84.12 → 0.84.14
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 +44 -42
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -107,7 +107,7 @@ var s = {
|
|
|
107
107
|
}), l = (e, t) => {
|
|
108
108
|
i(() => {
|
|
109
109
|
let n = e.current;
|
|
110
|
-
if (n) for (let [e, r] of Object.entries(t)) r !== void 0 && (n
|
|
110
|
+
if (n) for (let [e, r] of Object.entries(t)) r !== void 0 && Reflect.set(n, e, r);
|
|
111
111
|
});
|
|
112
112
|
}, u = {
|
|
113
113
|
dev: "https://grafana-faro-collector.dev.0hash.com/collect",
|
|
@@ -117,24 +117,26 @@ var s = {
|
|
|
117
117
|
"eu-prod": "https://grafana-faro-collector.zerohash.eu/collect",
|
|
118
118
|
sandbox: "https://grafana-faro-collector.cert.zerohash.com/collect",
|
|
119
119
|
production: "https://grafana-faro-collector.zerohash.com/collect"
|
|
120
|
-
}, d = (e) => {
|
|
120
|
+
}, d = (e) => typeof e == "object" && !!e && !Array.isArray(e), f = (e) => {
|
|
121
121
|
if (!e || typeof e != "string") return null;
|
|
122
122
|
let t = e.split(".");
|
|
123
123
|
if (t.length < 2) return null;
|
|
124
124
|
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)
|
|
126
|
-
if (typeof
|
|
127
|
-
let
|
|
128
|
-
return
|
|
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;
|
|
126
|
+
if (typeof o != "string") return null;
|
|
127
|
+
let s = o.toLowerCase();
|
|
128
|
+
return s === "us" || s === "eu" ? s : null;
|
|
129
129
|
} catch {
|
|
130
130
|
return null;
|
|
131
131
|
}
|
|
132
|
-
},
|
|
132
|
+
}, p = (e, t) => f(t) === "eu" ? e === "cert" ? "eu-cert" : e === "prod" ? "eu-prod" : e : e, m = (e) => {
|
|
133
133
|
if (!e || typeof e != "string") return {};
|
|
134
134
|
let t = e.split(".");
|
|
135
135
|
if (t.length < 2) return {};
|
|
136
136
|
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)
|
|
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);
|
|
138
|
+
if (!d(i)) return {};
|
|
139
|
+
let a = d(i.payload) ? i.payload : {}, o = (e) => typeof e == "string" && e.length > 0 ? e : void 0;
|
|
138
140
|
return {
|
|
139
141
|
participantCode: o(a.participant_code),
|
|
140
142
|
platformName: o(a.platform_name),
|
|
@@ -144,12 +146,12 @@ var s = {
|
|
|
144
146
|
} catch {
|
|
145
147
|
return {};
|
|
146
148
|
}
|
|
147
|
-
},
|
|
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 = () => {
|
|
148
150
|
let e = /* @__PURE__ */ new Uint8Array(8);
|
|
149
151
|
return globalThis.crypto.getRandomValues(e), Array.from(e, (e) => e.toString(16).padStart(2, "0")).join("");
|
|
150
|
-
},
|
|
151
|
-
let n =
|
|
152
|
-
return e.claims.participantCode && (
|
|
152
|
+
}, y = (e, t) => {
|
|
153
|
+
let n = v(), r = Reflect.get(globalThis, "__ZH_WEB_SDK_VERSION__"), i = typeof r == "string" ? r : void 0, a = {};
|
|
154
|
+
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
155
|
sessionId: n,
|
|
154
156
|
payload: {
|
|
155
157
|
meta: {
|
|
@@ -160,7 +162,7 @@ var s = {
|
|
|
160
162
|
},
|
|
161
163
|
session: {
|
|
162
164
|
id: n,
|
|
163
|
-
attributes:
|
|
165
|
+
attributes: a
|
|
164
166
|
},
|
|
165
167
|
browser: typeof navigator < "u" ? { userAgent: navigator.userAgent } : void 0,
|
|
166
168
|
page: typeof window < "u" ? { url: window.location.origin } : void 0
|
|
@@ -179,9 +181,9 @@ var s = {
|
|
|
179
181
|
}]
|
|
180
182
|
}
|
|
181
183
|
};
|
|
182
|
-
},
|
|
184
|
+
}, b = (e, t, n) => {
|
|
183
185
|
if (!e || typeof fetch > "u") return;
|
|
184
|
-
let { sessionId: r, payload: i } =
|
|
186
|
+
let { sessionId: r, payload: i } = y(t, n);
|
|
185
187
|
try {
|
|
186
188
|
fetch(e, {
|
|
187
189
|
method: "POST",
|
|
@@ -193,15 +195,15 @@ var s = {
|
|
|
193
195
|
keepalive: !0
|
|
194
196
|
}).catch(() => void 0);
|
|
195
197
|
} catch {}
|
|
196
|
-
},
|
|
198
|
+
}, x = (e) => {
|
|
197
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;
|
|
198
|
-
if (typeof document > "u") return
|
|
200
|
+
if (typeof document > "u") return _;
|
|
199
201
|
let f = `${t}-script-${s}`;
|
|
200
|
-
if (customElements.get(t) || document.getElementById(f)) return
|
|
201
|
-
let
|
|
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 = () => {
|
|
202
204
|
S !== void 0 && clearTimeout(S);
|
|
203
205
|
}, w = (e, r, i) => {
|
|
204
|
-
if (
|
|
206
|
+
if (y) return;
|
|
205
207
|
let o = Math.round(performance.now() - x), l = {
|
|
206
208
|
webComponentTag: t,
|
|
207
209
|
appName: n,
|
|
@@ -210,28 +212,28 @@ var s = {
|
|
|
210
212
|
reason: e,
|
|
211
213
|
triedFallback: i,
|
|
212
214
|
elapsedMs: o,
|
|
213
|
-
claims:
|
|
215
|
+
claims: p
|
|
214
216
|
};
|
|
215
217
|
v(l);
|
|
216
|
-
let u = i ? void 0 :
|
|
218
|
+
let u = i ? void 0 : h(a ?? {}, s, c);
|
|
217
219
|
if (u && u !== r) {
|
|
218
220
|
T(u, !0);
|
|
219
221
|
return;
|
|
220
222
|
}
|
|
221
|
-
|
|
223
|
+
y = !0, C(), document.getElementById(f)?.remove(), d?.(l);
|
|
222
224
|
}, T = (e, n) => {
|
|
223
225
|
C(), x = performance.now();
|
|
224
226
|
let r = document.createElement("script");
|
|
225
|
-
r.id = f, r.src = e, r.type = "module", r.async = !0, r.
|
|
227
|
+
r.id = f, r.src = e, r.type = "module", r.async = !0, r.addEventListener("load", () => {
|
|
226
228
|
setTimeout(() => {
|
|
227
|
-
|
|
229
|
+
y || (customElements.get(t) ? (y = !0, C(), u?.()) : w("not-defined", e, n));
|
|
228
230
|
}, 0);
|
|
229
|
-
}, r.
|
|
230
|
-
}, E =
|
|
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);
|
|
231
233
|
return E ? (T(E, !1), () => {
|
|
232
|
-
|
|
233
|
-
}) :
|
|
234
|
-
},
|
|
234
|
+
y = !0, C();
|
|
235
|
+
}) : _;
|
|
236
|
+
}, S = {
|
|
235
237
|
local: {
|
|
236
238
|
BASE_URL: "/",
|
|
237
239
|
DEV: !1,
|
|
@@ -259,21 +261,21 @@ var s = {
|
|
|
259
261
|
"eu-cert": "https://sdk-cdn.cert.zerohash.eu",
|
|
260
262
|
"eu-prod": "https://sdk-cdn.zerohash.eu"
|
|
261
263
|
};
|
|
262
|
-
[...Object.entries(
|
|
264
|
+
[...Object.entries(S).filter(([e]) => e !== "local").map(([, e]) => e)], {
|
|
263
265
|
LOADED: "travel_rule_loaded",
|
|
264
266
|
COMPLETED: "travel_rule_completed"
|
|
265
267
|
}.LOADED;
|
|
266
268
|
//#endregion
|
|
267
269
|
//#region ../../../common/callbacks/dist/shared/models.js
|
|
268
|
-
var
|
|
270
|
+
var C;
|
|
269
271
|
(function(e) {
|
|
270
272
|
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
|
-
})(
|
|
273
|
+
})(C ||= {});
|
|
272
274
|
//#endregion
|
|
273
275
|
//#region ../../../common/react-sdk-base/dist/use-web-component-script.js
|
|
274
|
-
var
|
|
276
|
+
var w = (e) => {
|
|
275
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);
|
|
276
|
-
return i(() => (h(!1),
|
|
278
|
+
return i(() => (h(!1), x({
|
|
277
279
|
webComponentTag: t,
|
|
278
280
|
appName: n ?? t,
|
|
279
281
|
appVersion: a,
|
|
@@ -299,10 +301,10 @@ var C = (e) => {
|
|
|
299
301
|
loadFailed: m,
|
|
300
302
|
retry: r(() => _((e) => e + 1), [])
|
|
301
303
|
};
|
|
302
|
-
},
|
|
304
|
+
}, T = {
|
|
303
305
|
sandbox: "https://sdk.sandbox.connect.xyz/auth-web/index.js",
|
|
304
306
|
production: "https://sdk.connect.xyz/auth-web/index.js"
|
|
305
|
-
},
|
|
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 }) => {
|
|
306
308
|
let m = a(null);
|
|
307
309
|
l(m, {
|
|
308
310
|
theme: i,
|
|
@@ -312,16 +314,16 @@ var C = (e) => {
|
|
|
312
314
|
onEvent: d,
|
|
313
315
|
onLoaded: f
|
|
314
316
|
});
|
|
315
|
-
let { loadFailed: h, retry: g } =
|
|
316
|
-
webComponentTag:
|
|
317
|
-
scriptUrls:
|
|
317
|
+
let { loadFailed: h, retry: g } = w({
|
|
318
|
+
webComponentTag: E,
|
|
319
|
+
scriptUrls: D,
|
|
318
320
|
env: r,
|
|
319
321
|
jwt: t
|
|
320
322
|
});
|
|
321
323
|
return h ? /* @__PURE__ */ e(c, {
|
|
322
324
|
onRetry: g,
|
|
323
325
|
onClose: s
|
|
324
|
-
}) : n.createElement(
|
|
326
|
+
}) : n.createElement(E, {
|
|
325
327
|
ref: m,
|
|
326
328
|
jwt: t,
|
|
327
329
|
env: r,
|
|
@@ -330,4 +332,4 @@ var C = (e) => {
|
|
|
330
332
|
});
|
|
331
333
|
};
|
|
332
334
|
//#endregion
|
|
333
|
-
export {
|
|
335
|
+
export { O as Auth };
|