@zerohash-sdk/crypto-deposits-react 0.5.3 → 0.5.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.
Files changed (2) hide show
  1. package/dist/index.js +55 -55
  2. 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 D, { useEffect as A, useState as L, useCallback as M, useRef as j } from "react";
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
- }, V = (e) => {
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) => V(t) !== "eu" ? e : e === "cert" ? "eu-cert" : e === "prod" ? "eu-prod" : e, P = (e) => {
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
- }, H = (e, t, o) => {
46
+ }, P = (e, t, o) => {
47
47
  const r = I(t, o);
48
48
  return e[r] ?? e[t];
49
- }, O = () => {
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: a, fallbackScriptUrls: i, collectorUrls: s, env: n, jwt: c, timeoutMs: h = 15e3, onLoad: _, onError: m } = e;
94
+ const { webComponentTag: t, appName: o, appVersion: r, scriptUrls: a, fallbackScriptUrls: i, collectorUrls: s, env: n, jwt: c, timeoutMs: h = 15e3, onLoad: b, onError: m } = e;
95
95
  if (typeof document > "u")
96
- return O;
96
+ return x;
97
97
  const p = `${t}-script-${n}`;
98
98
  if (customElements.get(t) || document.getElementById(p))
99
- return O;
100
- const R = P(c), k = e.report ?? ((u) => K(s && H(s, n, c), u, r));
101
- let g = !1, w = 0, v;
99
+ return x;
100
+ const R = H(c), C = e.report ?? ((u) => K(s && P(s, n, c), u, r));
101
+ let g = !1, T = 0, k;
102
102
  const S = () => {
103
- v !== void 0 && clearTimeout(v);
104
- }, C = (u, y, l) => {
103
+ k !== void 0 && clearTimeout(k);
104
+ }, v = (u, y, l) => {
105
105
  if (g)
106
106
  return;
107
- const U = Math.round(performance.now() - w), E = {
107
+ const U = Math.round(performance.now() - T), E = {
108
108
  webComponentTag: t,
109
109
  appName: o,
110
110
  env: n,
@@ -114,52 +114,52 @@ const $ = {
114
114
  elapsedMs: U,
115
115
  claims: R
116
116
  };
117
- k(E);
118
- const x = l ? void 0 : z(i ?? {}, n, c);
119
- if (x && x !== y) {
120
- N(x, !0);
117
+ C(E);
118
+ const O = l ? void 0 : z(i ?? {}, n, c);
119
+ if (O && O !== y) {
120
+ N(O, !0);
121
121
  return;
122
122
  }
123
123
  g = !0, S(), document.getElementById(p)?.remove(), m?.(E);
124
124
  }, N = (u, y) => {
125
- S(), w = performance.now();
125
+ S(), T = performance.now();
126
126
  const l = document.createElement("script");
127
127
  l.id = p, l.src = u, l.type = "module", l.async = !0, l.onload = () => {
128
128
  setTimeout(() => {
129
- g || (customElements.get(t) ? (g = !0, S(), _?.()) : C("not-defined", u, y));
129
+ g || (customElements.get(t) ? (g = !0, S(), b?.()) : v("not-defined", u, y));
130
130
  }, 0);
131
- }, l.onerror = () => C("network", u, y), v = setTimeout(() => C("timeout", u, y), h), document.getElementById(p)?.remove(), document.head.appendChild(l);
132
- }, T = z(a, n, c);
133
- return T ? (N(T, !1), () => {
131
+ }, l.onerror = () => v("network", u, y), k = setTimeout(() => v("timeout", u, y), h), document.getElementById(p)?.remove(), document.head.appendChild(l);
132
+ }, w = z(a, n, c);
133
+ return w ? (N(w, !1), () => {
134
134
  g = !0, S();
135
- }) : O;
136
- }, f = {
137
- local: "http://localhost:5173",
135
+ }) : x;
136
+ }, q = {}, Q = typeof import.meta < "u" && q?.VITE_LOCAL_CDN_HOST || "http://localhost:5173", f = {
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
- }, q = "https://sdk-cdn.gating.0hash.com", Q = (e, t, o = {}) => {
143
+ }, X = "https://sdk-cdn.gating.0hash.com", Y = (e, t, o = {}) => {
144
144
  const { eu: r = !1, legacyAliases: a = !1, local: i = f.local } = o, s = (c) => `${c}/${e}/${t}`, n = {
145
145
  local: s(i),
146
146
  dev: s(f.dev),
147
- gating: s(q),
147
+ gating: s(X),
148
148
  cert: s(f.cert),
149
149
  prod: s(f.prod)
150
150
  };
151
151
  return a && (n.sandbox = s(f.cert), n.production = s(f.prod)), r && (n["eu-cert"] = s(f["eu-cert"]), n["eu-prod"] = s(f["eu-prod"])), n;
152
152
  };
153
- var F;
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
- })(F || (F = {}));
157
- const b = {
156
+ })(A || (A = {}));
157
+ const _ = {
158
158
  evergreen: "#00381D",
159
159
  green: "#CCFFD0",
160
160
  offBlack: "#1C1B1C",
161
161
  grayLight: "#EBEBE9"
162
- }, X = ({ onRetry: e, onClose: t }) => W("div", { role: "alert", style: {
162
+ }, ee = ({ onRetry: e, onClose: t }) => W("div", { role: "alert", style: {
163
163
  position: "relative",
164
164
  display: "flex",
165
165
  flexDirection: "column",
@@ -170,9 +170,9 @@ const b = {
170
170
  padding: "32px 24px",
171
171
  textAlign: "center",
172
172
  fontFamily: "inherit",
173
- color: b.offBlack,
173
+ color: _.offBlack,
174
174
  background: "#FFFFFF",
175
- border: `1px solid ${b.grayLight}`,
175
+ border: `1px solid ${_.grayLight}`,
176
176
  borderRadius: "12px"
177
177
  }, children: [t && d("button", { type: "button", onClick: t, "aria-label": "Close", style: {
178
178
  position: "absolute",
@@ -180,38 +180,38 @@ const b = {
180
180
  right: "12px",
181
181
  display: "flex",
182
182
  padding: "4px",
183
- color: b.offBlack,
183
+ color: _.offBlack,
184
184
  background: "none",
185
185
  border: "none",
186
186
  cursor: "pointer",
187
187
  lineHeight: 0
188
- }, children: d("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", children: d("path", { d: "M18 6L6 18M6 6l12 12", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) }) }), d("svg", { width: "32", height: "32", viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", children: d("path", { 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", stroke: b.evergreen, strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) }), d("p", { style: { margin: 0, fontSize: "16px", fontWeight: 600 }, children: "Something went wrong" }), d("p", { style: { margin: 0, fontSize: "14px", opacity: 0.75 }, children: "We couldn't load this content. Please check your internet connection and try again." }), d("button", { type: "button", onClick: e, style: {
188
+ }, children: d("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", children: d("path", { d: "M18 6L6 18M6 6l12 12", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) }) }), d("svg", { width: "32", height: "32", viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", children: d("path", { 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", stroke: _.evergreen, strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) }), d("p", { style: { margin: 0, fontSize: "16px", fontWeight: 600 }, children: "Something went wrong" }), d("p", { style: { margin: 0, fontSize: "14px", opacity: 0.75 }, children: "We couldn't load this content. Please check your internet connection and try again." }), d("button", { type: "button", onClick: e, style: {
189
189
  marginTop: "8px",
190
190
  padding: "8px 20px",
191
191
  fontSize: "14px",
192
192
  fontWeight: 600,
193
193
  fontFamily: "inherit",
194
- color: b.green,
195
- background: b.evergreen,
194
+ color: _.green,
195
+ background: _.evergreen,
196
196
  border: "none",
197
197
  borderRadius: "8px",
198
198
  cursor: "pointer"
199
- }, children: "Try again" })] }), Y = (e, t) => {
200
- A(() => {
199
+ }, children: "Try again" })] }), te = (e, t) => {
200
+ B(() => {
201
201
  const o = e.current;
202
202
  if (o)
203
203
  for (const [r, a] of Object.entries(t))
204
204
  a !== void 0 && (o[r] = a);
205
205
  });
206
- }, ee = (e) => {
207
- const { webComponentTag: t, appName: o, appVersion: r, scriptUrls: a, fallbackScriptUrls: i, collectorUrls: s, env: n, jwt: c, timeoutMs: h } = e, [_, m] = L(!1), [p, R] = L(0);
208
- A(() => (m(!1), Z({
206
+ }, oe = (e) => {
207
+ const { webComponentTag: t, appName: o, appVersion: r, scriptUrls: a, fallbackScriptUrls: i, collectorUrls: s, env: n, jwt: c, timeoutMs: h } = e, [b, m] = L(!1), [p, R] = L(0);
208
+ B(() => (m(!1), Z({
209
209
  webComponentTag: t,
210
210
  appName: o ?? t,
211
211
  appVersion: r,
212
212
  scriptUrls: a,
213
213
  fallbackScriptUrls: i,
214
- collectorUrls: s ?? $,
214
+ collectorUrls: s ?? V,
215
215
  env: n,
216
216
  jwt: c,
217
217
  timeoutMs: h,
@@ -228,9 +228,9 @@ const b = {
228
228
  h,
229
229
  p
230
230
  ]);
231
- const k = M(() => R((g) => g + 1), []);
232
- return { loadFailed: _, retry: k };
233
- }, te = Q("crypto-deposits-web", "index.js", { eu: !0 }), B = "zerohash-crypto-deposits", ne = ({
231
+ const C = M(() => R((g) => g + 1), []);
232
+ return { loadFailed: b, retry: C };
233
+ }, re = Y("crypto-deposits-web", "index.js", { eu: !0 }), F = "zerohash-crypto-deposits", se = ({
234
234
  jwt: e,
235
235
  env: t = "prod",
236
236
  theme: o,
@@ -241,24 +241,24 @@ const b = {
241
241
  onClose: n,
242
242
  onLoaded: c,
243
243
  onEvent: h,
244
- ..._
244
+ ...b
245
245
  }) => {
246
246
  const m = j(null);
247
- Y(m, { theme: o, onCompleted: r, onFailed: a, onDeposit: i, onError: s, onClose: n, onLoaded: c, onEvent: h });
248
- const { loadFailed: p, retry: R } = ee({
249
- webComponentTag: B,
250
- scriptUrls: te,
247
+ te(m, { theme: o, onCompleted: r, onFailed: a, onDeposit: i, onError: s, onClose: n, onLoaded: c, onEvent: h });
248
+ const { loadFailed: p, retry: R } = oe({
249
+ webComponentTag: F,
250
+ scriptUrls: re,
251
251
  env: t,
252
252
  jwt: e
253
253
  });
254
- return p ? /* @__PURE__ */ d(X, { onRetry: R }) : D.createElement(B, {
254
+ return p ? /* @__PURE__ */ d(ee, { onRetry: R }) : D.createElement(F, {
255
255
  ref: m,
256
256
  jwt: e,
257
257
  env: t,
258
258
  theme: o,
259
- ..._
259
+ ...b
260
260
  });
261
261
  };
262
262
  export {
263
- ne as CryptoDeposits
263
+ se as CryptoDeposits
264
264
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zerohash-sdk/crypto-deposits-react",
3
- "version": "0.5.3",
3
+ "version": "0.5.4",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",