@zerohash-sdk/csp-crypto-sell-react 1.6.0 → 1.6.2

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 +49 -47
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,11 +1,11 @@
1
- import { jsxs as W, jsx as h } from "react/jsx-runtime";
2
- import A, { useEffect as B, useState as T, useCallback as j, useRef as M } from "react";
1
+ import { jsxs as U, jsx as h } from "react/jsx-runtime";
2
+ import W, { useEffect as B, useState as T, useCallback as A, useRef as M } from "react";
3
3
  const b = {
4
4
  evergreen: "#00381D",
5
5
  green: "#CCFFD0",
6
6
  offBlack: "#1C1B1C",
7
7
  grayLight: "#EBEBE9"
8
- }, D = ({ onRetry: e }) => W("div", { role: "alert", style: {
8
+ }, D = ({ onRetry: e }) => U("div", { role: "alert", style: {
9
9
  display: "flex",
10
10
  flexDirection: "column",
11
11
  alignItems: "center",
@@ -52,11 +52,11 @@ const b = {
52
52
  if (t.length < 2)
53
53
  return null;
54
54
  try {
55
- const o = t[1].replace(/-/g, "+").replace(/_/g, "/"), r = o + "===".slice(0, (4 - o.length % 4) % 4), n = typeof atob < "u" ? atob(r) : Buffer.from(r, "base64").toString("utf-8"), c = JSON.parse(n)?.payload?.region;
56
- if (typeof c != "string")
55
+ const o = t[1].replace(/-/g, "+").replace(/_/g, "/"), r = o + "===".slice(0, (4 - o.length % 4) % 4), n = typeof atob < "u" ? atob(r) : Buffer.from(r, "base64").toString("utf-8"), s = JSON.parse(n)?.payload?.region;
56
+ if (typeof s != "string")
57
57
  return null;
58
- const a = c.toLowerCase();
59
- return a === "us" || a === "eu" ? a : null;
58
+ const c = s.toLowerCase();
59
+ return c === "us" || c === "eu" ? c : null;
60
60
  } catch {
61
61
  return null;
62
62
  }
@@ -67,17 +67,17 @@ const b = {
67
67
  if (t.length < 2)
68
68
  return {};
69
69
  try {
70
- const o = t[1].replace(/-/g, "+").replace(/_/g, "/"), r = o + "===".slice(0, (4 - o.length % 4) % 4), n = typeof atob < "u" ? atob(r) : Buffer.from(r, "base64").toString("utf-8"), i = JSON.parse(n), c = i?.payload ?? {}, a = (s) => typeof s == "string" && s.length > 0 ? s : void 0;
70
+ const o = t[1].replace(/-/g, "+").replace(/_/g, "/"), r = o + "===".slice(0, (4 - o.length % 4) % 4), n = typeof atob < "u" ? atob(r) : Buffer.from(r, "base64").toString("utf-8"), i = JSON.parse(n), s = i?.payload ?? {}, c = (a) => typeof a == "string" && a.length > 0 ? a : void 0;
71
71
  return {
72
- participantCode: a(c.participant_code),
73
- platformName: a(c.platform_name),
74
- platformCode: a(i.platform_code),
75
- region: a(c.region)
72
+ participantCode: c(s.participant_code),
73
+ platformName: c(s.platform_name),
74
+ platformCode: c(i.platform_code),
75
+ region: c(s.region)
76
76
  };
77
77
  } catch {
78
78
  return {};
79
79
  }
80
- }, L = (e, t, o) => {
80
+ }, z = (e, t, o) => {
81
81
  const r = I(t, o);
82
82
  return e[r] ?? e[t] ?? e.prod;
83
83
  }, K = (e, t, o) => {
@@ -128,64 +128,64 @@ const b = {
128
128
  } catch {
129
129
  }
130
130
  }, q = (e) => {
131
- const { webComponentTag: t, appName: o, appVersion: r, scriptUrls: n, fallbackScriptUrls: i, collectorUrls: c, env: a, jwt: s, timeoutMs: p = 15e3, onLoad: y, onError: f } = e;
131
+ const { webComponentTag: t, appName: o, appVersion: r, scriptUrls: n, fallbackScriptUrls: i, collectorUrls: s, env: c, jwt: a, timeoutMs: p = 15e3, onLoad: y, onError: f } = e;
132
132
  if (typeof document > "u")
133
133
  return C;
134
- const m = `${t}-script-${a}`;
134
+ const m = `${t}-script-${c}`;
135
135
  if (customElements.get(t) || document.getElementById(m))
136
136
  return C;
137
- const R = $(s), S = e.report ?? ((d) => Z(c && K(c, a, s), d, r));
138
- let u = !1, O = 0, x;
137
+ const R = $(a), S = e.report ?? ((d) => Z(s && K(s, c, a), d, r));
138
+ let u = !1, k = 0, x;
139
139
  const _ = () => {
140
140
  x !== void 0 && clearTimeout(x);
141
- }, v = (d, g, l) => {
141
+ }, w = (d, g, l) => {
142
142
  if (u)
143
143
  return;
144
- const U = Math.round(performance.now() - O), N = {
144
+ const j = Math.round(performance.now() - k), N = {
145
145
  webComponentTag: t,
146
146
  appName: o,
147
- env: a,
147
+ env: c,
148
148
  scriptUrl: g,
149
149
  reason: d,
150
150
  triedFallback: l,
151
- elapsedMs: U,
151
+ elapsedMs: j,
152
152
  claims: R
153
153
  };
154
154
  S(N);
155
- const w = l ? void 0 : L(i ?? {}, a, s);
156
- if (w && w !== g) {
157
- k(w, !0);
155
+ const v = l ? void 0 : z(i ?? {}, c, a);
156
+ if (v && v !== g) {
157
+ O(v, !0);
158
158
  return;
159
159
  }
160
160
  u = !0, _(), document.getElementById(m)?.remove(), f?.(N);
161
- }, k = (d, g) => {
162
- _(), O = performance.now();
161
+ }, O = (d, g) => {
162
+ _(), k = performance.now();
163
163
  const l = document.createElement("script");
164
164
  l.id = m, l.src = d, l.type = "module", l.async = !0, l.onload = () => {
165
165
  setTimeout(() => {
166
- u || (customElements.get(t) ? (u = !0, _(), y?.()) : v("not-defined", d, g));
166
+ u || (customElements.get(t) ? (u = !0, _(), y?.()) : w("not-defined", d, g));
167
167
  }, 0);
168
- }, l.onerror = () => v("network", d, g), x = setTimeout(() => v("timeout", d, g), p), document.getElementById(m)?.remove(), document.head.appendChild(l);
169
- }, E = L(n, a, s);
170
- return E ? (k(E, !1), () => {
168
+ }, l.onerror = () => w("network", d, g), x = setTimeout(() => w("timeout", d, g), p), document.getElementById(m)?.remove(), document.head.appendChild(l);
169
+ }, E = z(n, c, a);
170
+ return E ? (O(E, !1), () => {
171
171
  u = !0, _();
172
172
  }) : C;
173
173
  };
174
- var F;
174
+ var L;
175
175
  (function(e) {
176
176
  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";
177
- })(F || (F = {}));
177
+ })(L || (L = {}));
178
178
  const Q = (e) => {
179
- const { webComponentTag: t, appName: o, appVersion: r, scriptUrls: n, fallbackScriptUrls: i, collectorUrls: c, env: a, jwt: s, timeoutMs: p } = e, [y, f] = T(!1), [m, R] = T(0);
179
+ const { webComponentTag: t, appName: o, appVersion: r, scriptUrls: n, fallbackScriptUrls: i, collectorUrls: s, env: c, jwt: a, timeoutMs: p } = e, [y, f] = T(!1), [m, R] = T(0);
180
180
  B(() => (f(!1), q({
181
181
  webComponentTag: t,
182
182
  appName: o ?? t,
183
183
  appVersion: r,
184
184
  scriptUrls: n,
185
185
  fallbackScriptUrls: i,
186
- collectorUrls: c ?? P,
187
- env: a,
188
- jwt: s,
186
+ collectorUrls: s ?? P,
187
+ env: c,
188
+ jwt: a,
189
189
  timeoutMs: p,
190
190
  onError: () => f(!0)
191
191
  })), [
@@ -194,44 +194,46 @@ const Q = (e) => {
194
194
  r,
195
195
  n,
196
196
  i,
197
+ s,
197
198
  c,
198
199
  a,
199
- s,
200
200
  p,
201
201
  m
202
202
  ]);
203
- const S = j(() => R((u) => u + 1), []);
203
+ const S = A(() => R((u) => u + 1), []);
204
204
  return { loadFailed: y, retry: S };
205
205
  }, X = {
206
206
  local: "http://localhost:5173/csp-crypto-sell-web/index.js",
207
207
  dev: "https://connect-sdk.dev.0hash.com/csp-crypto-sell-web/index.js",
208
208
  cert: "https://sdk.sandbox.connect.xyz/csp-crypto-sell-web/index.js",
209
- prod: "https://sdk.connect.xyz/csp-crypto-sell-web/index.js"
210
- }, z = "zerohash-csp-crypto-sell", te = ({
209
+ prod: "https://sdk.connect.xyz/csp-crypto-sell-web/index.js",
210
+ "eu-cert": "https://sdk-cdn.cert.zerohash.eu/csp-crypto-sell-web/index.js",
211
+ "eu-prod": "https://sdk-cdn.zerohash.eu/csp-crypto-sell-web/index.js"
212
+ }, F = "zerohash-csp-crypto-sell", te = ({
211
213
  jwt: e,
212
214
  env: t = "prod",
213
215
  theme: o,
214
216
  onCompleted: r,
215
217
  onError: n,
216
218
  onClose: i,
217
- onLoaded: c,
218
- onEvent: a,
219
- ...s
219
+ onLoaded: s,
220
+ onEvent: c,
221
+ ...a
220
222
  }) => {
221
223
  const p = M(null);
222
- V(p, { theme: o, onCompleted: r, onError: n, onClose: i, onLoaded: c, onEvent: a });
224
+ V(p, { theme: o, onCompleted: r, onError: n, onClose: i, onLoaded: s, onEvent: c });
223
225
  const { loadFailed: y, retry: f } = Q({
224
- webComponentTag: z,
226
+ webComponentTag: F,
225
227
  scriptUrls: X,
226
228
  env: t,
227
229
  jwt: e
228
230
  });
229
- return y ? /* @__PURE__ */ h(D, { onRetry: f }) : A.createElement(z, {
231
+ return y ? /* @__PURE__ */ h(D, { onRetry: f }) : W.createElement(F, {
230
232
  ref: p,
231
233
  jwt: e,
232
234
  env: t,
233
235
  theme: o,
234
- ...s
236
+ ...a
235
237
  });
236
238
  };
237
239
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zerohash-sdk/csp-crypto-sell-react",
3
- "version": "1.6.0",
3
+ "version": "1.6.2",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",