@zerohash-sdk/profile-react 0.14.3 → 0.14.4
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 +49 -49
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsxs as W, jsx as d } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
3
|
-
const
|
|
2
|
+
import D, { useEffect as B, useState as L, useCallback as M, useRef as j } from "react";
|
|
3
|
+
const V = {
|
|
4
4
|
dev: "https://grafana-faro-collector.dev.0hash.com/collect",
|
|
5
5
|
cert: "https://grafana-faro-collector.cert.zerohash.com/collect",
|
|
6
6
|
prod: "https://grafana-faro-collector.zerohash.com/collect",
|
|
@@ -8,7 +8,7 @@ const $ = {
|
|
|
8
8
|
"eu-prod": "https://grafana-faro-collector.zerohash.eu/collect",
|
|
9
9
|
sandbox: "https://grafana-faro-collector.cert.zerohash.com/collect",
|
|
10
10
|
production: "https://grafana-faro-collector.zerohash.com/collect"
|
|
11
|
-
},
|
|
11
|
+
}, $ = (e) => {
|
|
12
12
|
if (!e || typeof e != "string")
|
|
13
13
|
return null;
|
|
14
14
|
const t = e.split(".");
|
|
@@ -23,7 +23,7 @@ const $ = {
|
|
|
23
23
|
} catch {
|
|
24
24
|
return null;
|
|
25
25
|
}
|
|
26
|
-
}, I = (e, t) =>
|
|
26
|
+
}, I = (e, t) => $(t) !== "eu" ? e : e === "cert" ? "eu-cert" : e === "prod" ? "eu-prod" : e, H = (e) => {
|
|
27
27
|
if (!e || typeof e != "string")
|
|
28
28
|
return {};
|
|
29
29
|
const t = e.split(".");
|
|
@@ -43,10 +43,10 @@ const $ = {
|
|
|
43
43
|
}, z = (e, t, o) => {
|
|
44
44
|
const r = I(t, o);
|
|
45
45
|
return e[r] ?? e[t] ?? e.prod;
|
|
46
|
-
},
|
|
46
|
+
}, P = (e, t, o) => {
|
|
47
47
|
const r = I(t, o);
|
|
48
48
|
return e[r] ?? e[t];
|
|
49
|
-
},
|
|
49
|
+
}, x = () => {
|
|
50
50
|
}, J = () => {
|
|
51
51
|
const e = new Uint8Array(8);
|
|
52
52
|
return globalThis.crypto.getRandomValues(e), Array.from(e, (t) => t.toString(16).padStart(2, "0")).join("");
|
|
@@ -91,20 +91,20 @@ const $ = {
|
|
|
91
91
|
} catch {
|
|
92
92
|
}
|
|
93
93
|
}, Z = (e) => {
|
|
94
|
-
const { webComponentTag: t, appName: o, appVersion: r, scriptUrls: n, fallbackScriptUrls: i, collectorUrls: c, env: a, jwt: s, timeoutMs: m = 15e3, onLoad:
|
|
94
|
+
const { webComponentTag: t, appName: o, appVersion: r, scriptUrls: n, fallbackScriptUrls: i, collectorUrls: c, env: a, jwt: s, timeoutMs: m = 15e3, onLoad: _, onError: b } = e;
|
|
95
95
|
if (typeof document > "u")
|
|
96
|
-
return
|
|
96
|
+
return x;
|
|
97
97
|
const g = `${t}-script-${a}`;
|
|
98
98
|
if (customElements.get(t) || document.getElementById(g))
|
|
99
|
-
return
|
|
100
|
-
const S =
|
|
101
|
-
let f = !1,
|
|
99
|
+
return x;
|
|
100
|
+
const S = H(s), k = e.report ?? ((p) => K(c && P(c, a, s), p, r));
|
|
101
|
+
let f = !1, T = 0, v;
|
|
102
102
|
const R = () => {
|
|
103
103
|
v !== void 0 && clearTimeout(v);
|
|
104
|
-
},
|
|
104
|
+
}, C = (p, h, l) => {
|
|
105
105
|
if (f)
|
|
106
106
|
return;
|
|
107
|
-
const U = Math.round(performance.now() -
|
|
107
|
+
const U = Math.round(performance.now() - T), E = {
|
|
108
108
|
webComponentTag: t,
|
|
109
109
|
appName: o,
|
|
110
110
|
env: a,
|
|
@@ -115,51 +115,51 @@ const $ = {
|
|
|
115
115
|
claims: S
|
|
116
116
|
};
|
|
117
117
|
k(E);
|
|
118
|
-
const
|
|
119
|
-
if (
|
|
120
|
-
N(
|
|
118
|
+
const O = l ? void 0 : z(i ?? {}, a, s);
|
|
119
|
+
if (O && O !== h) {
|
|
120
|
+
N(O, !0);
|
|
121
121
|
return;
|
|
122
122
|
}
|
|
123
|
-
f = !0, R(), document.getElementById(g)?.remove(),
|
|
123
|
+
f = !0, R(), document.getElementById(g)?.remove(), b?.(E);
|
|
124
124
|
}, N = (p, h) => {
|
|
125
|
-
R(),
|
|
125
|
+
R(), T = performance.now();
|
|
126
126
|
const l = document.createElement("script");
|
|
127
127
|
l.id = g, l.src = p, l.type = "module", l.async = !0, l.onload = () => {
|
|
128
128
|
setTimeout(() => {
|
|
129
|
-
f || (customElements.get(t) ? (f = !0, R(),
|
|
129
|
+
f || (customElements.get(t) ? (f = !0, R(), _?.()) : C("not-defined", p, h));
|
|
130
130
|
}, 0);
|
|
131
|
-
}, l.onerror = () =>
|
|
132
|
-
},
|
|
133
|
-
return
|
|
131
|
+
}, l.onerror = () => C("network", p, h), v = setTimeout(() => C("timeout", p, h), m), document.getElementById(g)?.remove(), document.head.appendChild(l);
|
|
132
|
+
}, w = z(n, a, s);
|
|
133
|
+
return w ? (N(w, !1), () => {
|
|
134
134
|
f = !0, R();
|
|
135
|
-
}) :
|
|
136
|
-
}, u = {
|
|
137
|
-
local:
|
|
135
|
+
}) : x;
|
|
136
|
+
}, q = {}, Q = typeof import.meta < "u" && q?.VITE_LOCAL_CDN_HOST || "http://localhost:5173", u = {
|
|
137
|
+
local: Q,
|
|
138
138
|
dev: "https://sdk-cdn.dev.0hash.com",
|
|
139
139
|
cert: "https://sdk-cdn.cert.zerohash.com",
|
|
140
140
|
prod: "https://sdk-cdn.zerohash.com",
|
|
141
141
|
"eu-cert": "https://sdk-cdn.cert.zerohash.eu",
|
|
142
142
|
"eu-prod": "https://sdk-cdn.zerohash.eu"
|
|
143
|
-
},
|
|
143
|
+
}, X = "https://sdk-cdn.gating.0hash.com", Y = (e, t, o = {}) => {
|
|
144
144
|
const { eu: r = !1, legacyAliases: n = !1, local: i = u.local } = o, c = (s) => `${s}/${e}/${t}`, a = {
|
|
145
145
|
local: c(i),
|
|
146
146
|
dev: c(u.dev),
|
|
147
|
-
gating: c(
|
|
147
|
+
gating: c(X),
|
|
148
148
|
cert: c(u.cert),
|
|
149
149
|
prod: c(u.prod)
|
|
150
150
|
};
|
|
151
151
|
return n && (a.sandbox = c(u.cert), a.production = c(u.prod)), r && (a["eu-cert"] = c(u["eu-cert"]), a["eu-prod"] = c(u["eu-prod"])), a;
|
|
152
152
|
};
|
|
153
|
-
var
|
|
153
|
+
var A;
|
|
154
154
|
(function(e) {
|
|
155
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
|
-
})(
|
|
156
|
+
})(A || (A = {}));
|
|
157
157
|
const y = {
|
|
158
158
|
evergreen: "#00381D",
|
|
159
159
|
green: "#CCFFD0",
|
|
160
160
|
offBlack: "#1C1B1C",
|
|
161
161
|
grayLight: "#EBEBE9"
|
|
162
|
-
},
|
|
162
|
+
}, ee = ({ onRetry: e, onClose: t }) => W("div", { role: "alert", style: {
|
|
163
163
|
position: "relative",
|
|
164
164
|
display: "flex",
|
|
165
165
|
flexDirection: "column",
|
|
@@ -196,26 +196,26 @@ const y = {
|
|
|
196
196
|
border: "none",
|
|
197
197
|
borderRadius: "8px",
|
|
198
198
|
cursor: "pointer"
|
|
199
|
-
}, children: "Try again" })] }),
|
|
200
|
-
|
|
199
|
+
}, children: "Try again" })] }), te = (e, t) => {
|
|
200
|
+
B(() => {
|
|
201
201
|
const o = e.current;
|
|
202
202
|
if (o)
|
|
203
203
|
for (const [r, n] of Object.entries(t))
|
|
204
204
|
n !== void 0 && (o[r] = n);
|
|
205
205
|
});
|
|
206
|
-
},
|
|
207
|
-
const { webComponentTag: t, appName: o, appVersion: r, scriptUrls: n, fallbackScriptUrls: i, collectorUrls: c, env: a, jwt: s, timeoutMs: m } = e, [
|
|
208
|
-
|
|
206
|
+
}, oe = (e) => {
|
|
207
|
+
const { webComponentTag: t, appName: o, appVersion: r, scriptUrls: n, fallbackScriptUrls: i, collectorUrls: c, env: a, jwt: s, timeoutMs: m } = e, [_, b] = L(!1), [g, S] = L(0);
|
|
208
|
+
B(() => (b(!1), Z({
|
|
209
209
|
webComponentTag: t,
|
|
210
210
|
appName: o ?? t,
|
|
211
211
|
appVersion: r,
|
|
212
212
|
scriptUrls: n,
|
|
213
213
|
fallbackScriptUrls: i,
|
|
214
|
-
collectorUrls: c ??
|
|
214
|
+
collectorUrls: c ?? V,
|
|
215
215
|
env: a,
|
|
216
216
|
jwt: s,
|
|
217
217
|
timeoutMs: m,
|
|
218
|
-
onError: () =>
|
|
218
|
+
onError: () => b(!0)
|
|
219
219
|
})), [
|
|
220
220
|
t,
|
|
221
221
|
o,
|
|
@@ -228,9 +228,9 @@ const y = {
|
|
|
228
228
|
m,
|
|
229
229
|
g
|
|
230
230
|
]);
|
|
231
|
-
const k =
|
|
232
|
-
return { loadFailed:
|
|
233
|
-
},
|
|
231
|
+
const k = M(() => S((f) => f + 1), []);
|
|
232
|
+
return { loadFailed: _, retry: k };
|
|
233
|
+
}, re = Y("profile-web", "index.js", { eu: !0 }), F = "zerohash-profile", ce = ({
|
|
234
234
|
jwt: e,
|
|
235
235
|
env: t = "prod",
|
|
236
236
|
theme: o,
|
|
@@ -240,21 +240,21 @@ const y = {
|
|
|
240
240
|
onEvent: c,
|
|
241
241
|
...a
|
|
242
242
|
}) => {
|
|
243
|
-
const s =
|
|
244
|
-
|
|
245
|
-
const { loadFailed: m, retry:
|
|
246
|
-
webComponentTag:
|
|
247
|
-
scriptUrls:
|
|
243
|
+
const s = j(null);
|
|
244
|
+
te(s, { theme: o, onError: r, onClose: n, onLoaded: i, onEvent: c });
|
|
245
|
+
const { loadFailed: m, retry: _ } = oe({
|
|
246
|
+
webComponentTag: F,
|
|
247
|
+
scriptUrls: re,
|
|
248
248
|
env: t,
|
|
249
249
|
jwt: e
|
|
250
250
|
});
|
|
251
251
|
return m ? /* @__PURE__ */ d(
|
|
252
|
-
|
|
252
|
+
ee,
|
|
253
253
|
{
|
|
254
|
-
onRetry:
|
|
254
|
+
onRetry: _,
|
|
255
255
|
onClose: n
|
|
256
256
|
}
|
|
257
|
-
) :
|
|
257
|
+
) : D.createElement(F, {
|
|
258
258
|
ref: s,
|
|
259
259
|
jwt: e,
|
|
260
260
|
env: t,
|
|
@@ -263,5 +263,5 @@ const y = {
|
|
|
263
263
|
});
|
|
264
264
|
};
|
|
265
265
|
export {
|
|
266
|
-
|
|
266
|
+
ce as Profile
|
|
267
267
|
};
|