@zerohash-sdk/crypto-deposits-react 0.2.0 → 0.3.1

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.d.ts CHANGED
@@ -37,6 +37,28 @@ declare interface CryptoDepositsProps {
37
37
  theme?: Theme;
38
38
  /** Callback invoked when the crypto deposit flow is successfully completed. */
39
39
  onCompleted?: (data: CryptoDepositsCompletedData) => void;
40
+ /**
41
+ * Callback invoked when a deposit transaction reaches a terminal **failed**
42
+ * state (the "Transaction failed" page). Distinct from `onError` — this
43
+ * carries the failed transaction's details, not an SDK/request error.
44
+ *
45
+ * @param data - Details about the failed transaction (depositId, assetSymbol, network, amount)
46
+ */
47
+ onFailed?: (data: CryptoDepositsCompletedData) => void;
48
+ /**
49
+ * Callback invoked when a deposit made from an external funding source
50
+ * changes status. This is the "auth as a feature" path; the manual-deposit
51
+ * path reports through `onCompleted`/`onFailed` instead.
52
+ *
53
+ * A status notification, not a single terminal event: it can fire more than
54
+ * once for one deposit, including while account matching is still verifying.
55
+ * Read `deposit.data.status.value` (`CONFIRMED` = funded, `FAILED` = not) and
56
+ * `deposit.data.accountMatchingValidation?.status` (`PENDING` = not finished
57
+ * yet) rather than assuming any call is the last one.
58
+ *
59
+ * @param deposit - The deposit and its current status
60
+ */
61
+ onDeposit?: (deposit: DepositCompletedPayload) => void;
40
62
  /** Callback invoked when an error occurs during the crypto deposit flow. */
41
63
  onError?: (error: ErrorPayload) => void;
42
64
  /** Callback invoked when the user closes the crypto deposits widget. */
@@ -45,12 +67,6 @@ declare interface CryptoDepositsProps {
45
67
  onLoaded?: () => void;
46
68
  /** Callback invoked for general application events during the crypto deposit flow. */
47
69
  onEvent?: (event: CryptoDepositsEvent) => void;
48
- /**
49
- * Callback invoked with the status of a deposit funded from a connected
50
- * external account. Non-terminal: it can fire more than once per deposit, and
51
- * the outcome is read off `status`.
52
- */
53
- onDeposit?: (deposit: DepositCompletedPayload) => void;
54
70
  }
55
71
 
56
72
  /**
package/dist/index.js CHANGED
@@ -91,47 +91,47 @@ 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: g = 15e3, onLoad: h, onError: y } = 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;
95
95
  if (typeof document > "u")
96
96
  return O;
97
97
  const p = `${t}-script-${n}`;
98
98
  if (customElements.get(t) || document.getElementById(p))
99
99
  return O;
100
- const S = P(c), k = e.report ?? ((u) => K(s && H(s, n, c), u, r));
101
- let m = !1, w = 0, v;
102
- const R = () => {
100
+ const R = P(c), k = e.report ?? ((u) => K(s && H(s, n, c), u, r));
101
+ let g = !1, w = 0, v;
102
+ const S = () => {
103
103
  v !== void 0 && clearTimeout(v);
104
- }, C = (u, b, l) => {
105
- if (m)
104
+ }, C = (u, y, l) => {
105
+ if (g)
106
106
  return;
107
107
  const U = Math.round(performance.now() - w), E = {
108
108
  webComponentTag: t,
109
109
  appName: o,
110
110
  env: n,
111
- scriptUrl: b,
111
+ scriptUrl: y,
112
112
  reason: u,
113
113
  triedFallback: l,
114
114
  elapsedMs: U,
115
- claims: S
115
+ claims: R
116
116
  };
117
117
  k(E);
118
118
  const x = l ? void 0 : z(i ?? {}, n, c);
119
- if (x && x !== b) {
119
+ if (x && x !== y) {
120
120
  N(x, !0);
121
121
  return;
122
122
  }
123
- m = !0, R(), document.getElementById(p)?.remove(), y?.(E);
124
- }, N = (u, b) => {
125
- R(), w = performance.now();
123
+ g = !0, S(), document.getElementById(p)?.remove(), m?.(E);
124
+ }, N = (u, y) => {
125
+ S(), w = 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
- m || (customElements.get(t) ? (m = !0, R(), h?.()) : C("not-defined", u, b));
129
+ g || (customElements.get(t) ? (g = !0, S(), _?.()) : C("not-defined", u, y));
130
130
  }, 0);
131
- }, l.onerror = () => C("network", u, b), v = setTimeout(() => C("timeout", u, b), g), document.getElementById(p)?.remove(), document.head.appendChild(l);
131
+ }, l.onerror = () => C("network", u, y), v = setTimeout(() => C("timeout", u, y), h), document.getElementById(p)?.remove(), document.head.appendChild(l);
132
132
  }, T = z(a, n, c);
133
133
  return T ? (N(T, !1), () => {
134
- m = !0, R();
134
+ g = !0, S();
135
135
  }) : O;
136
136
  }, f = {
137
137
  local: "http://localhost:5173",
@@ -154,7 +154,7 @@ var F;
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
  })(F || (F = {}));
157
- const _ = {
157
+ const b = {
158
158
  evergreen: "#00381D",
159
159
  green: "#CCFFD0",
160
160
  offBlack: "#1C1B1C",
@@ -170,9 +170,9 @@ const _ = {
170
170
  padding: "32px 24px",
171
171
  textAlign: "center",
172
172
  fontFamily: "inherit",
173
- color: _.offBlack,
173
+ color: b.offBlack,
174
174
  background: "#FFFFFF",
175
- border: `1px solid ${_.grayLight}`,
175
+ border: `1px solid ${b.grayLight}`,
176
176
  borderRadius: "12px"
177
177
  }, children: [t && d("button", { type: "button", onClick: t, "aria-label": "Close", style: {
178
178
  position: "absolute",
@@ -180,19 +180,19 @@ const _ = {
180
180
  right: "12px",
181
181
  display: "flex",
182
182
  padding: "4px",
183
- color: _.offBlack,
183
+ color: b.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: _.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: 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: {
189
189
  marginTop: "8px",
190
190
  padding: "8px 20px",
191
191
  fontSize: "14px",
192
192
  fontWeight: 600,
193
193
  fontFamily: "inherit",
194
- color: _.green,
195
- background: _.evergreen,
194
+ color: b.green,
195
+ background: b.evergreen,
196
196
  border: "none",
197
197
  borderRadius: "8px",
198
198
  cursor: "pointer"
@@ -204,8 +204,8 @@ const _ = {
204
204
  a !== void 0 && (o[r] = a);
205
205
  });
206
206
  }, ee = (e) => {
207
- const { webComponentTag: t, appName: o, appVersion: r, scriptUrls: a, fallbackScriptUrls: i, collectorUrls: s, env: n, jwt: c, timeoutMs: g } = e, [h, y] = L(!1), [p, S] = L(0);
208
- A(() => (y(!1), Z({
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({
209
209
  webComponentTag: t,
210
210
  appName: o ?? t,
211
211
  appVersion: r,
@@ -214,8 +214,8 @@ const _ = {
214
214
  collectorUrls: s ?? $,
215
215
  env: n,
216
216
  jwt: c,
217
- timeoutMs: g,
218
- onError: () => y(!0)
217
+ timeoutMs: h,
218
+ onError: () => m(!0)
219
219
  })), [
220
220
  t,
221
221
  o,
@@ -225,37 +225,38 @@ const _ = {
225
225
  s,
226
226
  n,
227
227
  c,
228
- g,
228
+ h,
229
229
  p
230
230
  ]);
231
- const k = M(() => S((m) => m + 1), []);
232
- return { loadFailed: h, retry: k };
231
+ const k = M(() => R((g) => g + 1), []);
232
+ return { loadFailed: _, retry: k };
233
233
  }, te = Q("crypto-deposits-web", "index.js", { eu: !0 }), B = "zerohash-crypto-deposits", ne = ({
234
234
  jwt: e,
235
235
  env: t = "prod",
236
236
  theme: o,
237
237
  onCompleted: r,
238
- onError: a,
239
- onClose: i,
240
- onLoaded: s,
241
- onEvent: n,
242
- onDeposit: c,
243
- ...g
238
+ onFailed: a,
239
+ onDeposit: i,
240
+ onError: s,
241
+ onClose: n,
242
+ onLoaded: c,
243
+ onEvent: h,
244
+ ..._
244
245
  }) => {
245
- const h = j(null);
246
- Y(h, { theme: o, onCompleted: r, onError: a, onClose: i, onLoaded: s, onEvent: n, onDeposit: c });
247
- const { loadFailed: y, retry: p } = ee({
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({
248
249
  webComponentTag: B,
249
250
  scriptUrls: te,
250
251
  env: t,
251
252
  jwt: e
252
253
  });
253
- return y ? /* @__PURE__ */ d(X, { onRetry: p }) : D.createElement(B, {
254
- ref: h,
254
+ return p ? /* @__PURE__ */ d(X, { onRetry: R }) : D.createElement(B, {
255
+ ref: m,
255
256
  jwt: e,
256
257
  env: t,
257
258
  theme: o,
258
- ...g
259
+ ..._
259
260
  });
260
261
  };
261
262
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zerohash-sdk/crypto-deposits-react",
3
- "version": "0.2.0",
3
+ "version": "0.3.1",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",