@zerohash-sdk/crypto-deposits-react 0.1.1 → 0.3.0

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` (`PROCESSED` = 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. */
@@ -47,6 +69,35 @@ declare interface CryptoDepositsProps {
47
69
  onEvent?: (event: CryptoDepositsEvent) => void;
48
70
  }
49
71
 
72
+ /**
73
+ * Deposit completed payload — emitted by SDKs that drive a deposit through
74
+ * the integrations flow. Lives on `CommonCallbacks` because both Auth and
75
+ * any SDK embedding `@zerohash/integrations-flow` (e.g. fund with `useAuth`)
76
+ * resolve through the same deposit-status hook.
77
+ */
78
+ declare type DepositCompletedPayload = {
79
+ data: {
80
+ depositId: string;
81
+ status: DepositStatus;
82
+ assetId: string;
83
+ networkId: string;
84
+ amount?: string;
85
+ accountMatchingValidation?: {
86
+ status: 'PENDING' | 'VALID' | 'INVALID' | 'ERROR';
87
+ reason?: string;
88
+ };
89
+ };
90
+ };
91
+
92
+ /**
93
+ * Deposit status object — shared across SDKs that surface deposit completion.
94
+ */
95
+ declare type DepositStatus = {
96
+ value: string;
97
+ details: string;
98
+ occurredAt: string;
99
+ };
100
+
50
101
  /**
51
102
  * Available environments for the Connect Crypto Deposits service.
52
103
  *
package/dist/index.js CHANGED
@@ -91,28 +91,28 @@ 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: f = 15e3, onLoad: _, onError: g } = 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
- const h = `${t}-script-${n}`;
98
- if (customElements.get(t) || document.getElementById(h))
97
+ const p = `${t}-script-${n}`;
98
+ if (customElements.get(t) || document.getElementById(p))
99
99
  return O;
100
- const S = P(c), k = e.report ?? ((p) => K(s && H(s, n, c), p, 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 = (p, y, 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
111
  scriptUrl: y,
112
- reason: p,
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);
@@ -120,20 +120,20 @@ const $ = {
120
120
  N(x, !0);
121
121
  return;
122
122
  }
123
- m = !0, R(), document.getElementById(h)?.remove(), g?.(E);
124
- }, N = (p, y) => {
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
- l.id = h, l.src = p, l.type = "module", l.async = !0, l.onload = () => {
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(), _?.()) : C("not-defined", p, y));
129
+ g || (customElements.get(t) ? (g = !0, S(), _?.()) : C("not-defined", u, y));
130
130
  }, 0);
131
- }, l.onerror = () => C("network", p, y), v = setTimeout(() => C("timeout", p, y), f), document.getElementById(h)?.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
- }, u = {
136
+ }, f = {
137
137
  local: "http://localhost:5173",
138
138
  dev: "https://sdk-cdn.dev.0hash.com",
139
139
  cert: "https://sdk-cdn.cert.zerohash.com",
@@ -141,14 +141,14 @@ const $ = {
141
141
  "eu-cert": "https://sdk-cdn.cert.zerohash.eu",
142
142
  "eu-prod": "https://sdk-cdn.zerohash.eu"
143
143
  }, q = "https://sdk-cdn.gating.0hash.com", Q = (e, t, o = {}) => {
144
- const { eu: r = !1, legacyAliases: a = !1, local: i = u.local } = o, s = (c) => `${c}/${e}/${t}`, n = {
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
- dev: s(u.dev),
146
+ dev: s(f.dev),
147
147
  gating: s(q),
148
- cert: s(u.cert),
149
- prod: s(u.prod)
148
+ cert: s(f.cert),
149
+ prod: s(f.prod)
150
150
  };
151
- return a && (n.sandbox = s(u.cert), n.production = s(u.prod)), r && (n["eu-cert"] = s(u["eu-cert"]), n["eu-prod"] = s(u["eu-prod"])), n;
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
153
  var F;
154
154
  (function(e) {
@@ -204,8 +204,8 @@ const b = {
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: f } = e, [_, g] = L(!1), [h, S] = L(0);
208
- A(() => (g(!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 b = {
214
214
  collectorUrls: s ?? $,
215
215
  env: n,
216
216
  jwt: c,
217
- timeoutMs: f,
218
- onError: () => g(!0)
217
+ timeoutMs: h,
218
+ onError: () => m(!0)
219
219
  })), [
220
220
  t,
221
221
  o,
@@ -225,36 +225,38 @@ const b = {
225
225
  s,
226
226
  n,
227
227
  c,
228
- f,
229
- h
228
+ h,
229
+ p
230
230
  ]);
231
- const k = M(() => S((m) => m + 1), []);
231
+ const k = M(() => R((g) => g + 1), []);
232
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
- ...c
238
+ onFailed: a,
239
+ onDeposit: i,
240
+ onError: s,
241
+ onClose: n,
242
+ onLoaded: c,
243
+ onEvent: h,
244
+ ..._
243
245
  }) => {
244
- const f = j(null);
245
- Y(f, { theme: o, onCompleted: r, onError: a, onClose: i, onLoaded: s, onEvent: n });
246
- const { loadFailed: _, retry: g } = 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({
247
249
  webComponentTag: B,
248
250
  scriptUrls: te,
249
251
  env: t,
250
252
  jwt: e
251
253
  });
252
- return _ ? /* @__PURE__ */ d(X, { onRetry: g }) : D.createElement(B, {
253
- ref: f,
254
+ return p ? /* @__PURE__ */ d(X, { onRetry: R }) : D.createElement(B, {
255
+ ref: m,
254
256
  jwt: e,
255
257
  env: t,
256
258
  theme: o,
257
- ...c
259
+ ..._
258
260
  });
259
261
  };
260
262
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zerohash-sdk/crypto-deposits-react",
3
- "version": "0.1.1",
3
+ "version": "0.3.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",