@zerohash-sdk/fund-react 1.8.1 → 1.9.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
@@ -101,6 +101,12 @@ declare type FundCompletedData = {
101
101
  assetSymbol?: string;
102
102
  /** Amount to be deposited */
103
103
  amount?: string;
104
+ /** Backend transaction id for the deposit */
105
+ transactionId?: string;
106
+ /** Fund id the deposit was credited to */
107
+ fundId?: string;
108
+ /** Notional (fiat) amount of the deposit */
109
+ notionalAmount?: string;
104
110
  };
105
111
 
106
112
  /**
@@ -196,6 +202,16 @@ declare interface FundProps {
196
202
  * ```
197
203
  */
198
204
  onCompleted?: (data: FundCompletedData) => void;
205
+ /**
206
+ * Callback invoked when a deposit transaction reaches a terminal **failed**
207
+ * state (the "Transaction failed" page). Distinct from `onError` — this
208
+ * carries the failed transaction's details, not an SDK/request error.
209
+ *
210
+ * @param data - Details about the failed transaction (transactionId, fundId, amount…)
211
+ */
212
+ onFailed?: (data: FundCompletedData) => void;
213
+ /** Invoked when the user taps "Provide info" on the travel-rule pending screen; open the Travel Rule SDK scoped to `depositId`. */
214
+ onProvideInfo?: (data: FundProvideInfoData) => void;
199
215
  /**
200
216
  * Callback invoked when an error occurs during the fund flow.
201
217
  *
@@ -252,6 +268,10 @@ declare interface FundProps {
252
268
  onEvent?: (event: FundEvent) => void;
253
269
  }
254
270
 
271
+ declare type FundProvideInfoData = {
272
+ depositId: string;
273
+ };
274
+
255
275
  /**
256
276
  * Theme mode for the Connect Fund interface.
257
277
  *
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { jsxs as W, jsx as y } from "react/jsx-runtime";
1
+ import { jsxs as W, jsx as _ } from "react/jsx-runtime";
2
2
  import j, { useEffect as B, useState as z, useCallback as D, useRef as M } from "react";
3
3
  const $ = {
4
4
  dev: "https://grafana-faro-collector.dev.0hash.com/collect",
@@ -91,49 +91,49 @@ 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: g = 15e3, onLoad: _, onError: f } = e;
94
+ const { webComponentTag: t, appName: o, appVersion: r, scriptUrls: n, fallbackScriptUrls: i, collectorUrls: c, env: a, jwt: s, timeoutMs: m = 15e3, onLoad: b, onError: g } = e;
95
95
  if (typeof document > "u")
96
96
  return x;
97
- const d = `${t}-script-${a}`;
98
- if (customElements.get(t) || document.getElementById(d))
97
+ const p = `${t}-script-${a}`;
98
+ if (customElements.get(t) || document.getElementById(p))
99
99
  return x;
100
- const b = J(s), v = e.report ?? ((p) => G(c && P(c, a, s), p, r));
101
- let m = !1, w = 0, C;
102
- const S = () => {
100
+ const h = J(s), R = e.report ?? ((u) => G(c && P(c, a, s), u, r));
101
+ let d = !1, w = 0, C;
102
+ const v = () => {
103
103
  C !== void 0 && clearTimeout(C);
104
- }, k = (p, h, l) => {
105
- if (m)
104
+ }, k = (u, y, l) => {
105
+ if (d)
106
106
  return;
107
107
  const U = Math.round(performance.now() - w), T = {
108
108
  webComponentTag: t,
109
109
  appName: o,
110
110
  env: a,
111
- scriptUrl: h,
112
- reason: p,
111
+ scriptUrl: y,
112
+ reason: u,
113
113
  triedFallback: l,
114
114
  elapsedMs: U,
115
- claims: b
115
+ claims: h
116
116
  };
117
- v(T);
117
+ R(T);
118
118
  const O = l ? void 0 : F(i ?? {}, a, s);
119
- if (O && O !== h) {
119
+ if (O && O !== y) {
120
120
  E(O, !0);
121
121
  return;
122
122
  }
123
- m = !0, S(), document.getElementById(d)?.remove(), f?.(T);
124
- }, E = (p, h) => {
125
- S(), w = performance.now();
123
+ d = !0, v(), document.getElementById(p)?.remove(), g?.(T);
124
+ }, E = (u, y) => {
125
+ v(), w = performance.now();
126
126
  const l = document.createElement("script");
127
- l.id = d, 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, S(), _?.()) : k("not-defined", p, h));
129
+ d || (customElements.get(t) ? (d = !0, v(), b?.()) : k("not-defined", u, y));
130
130
  }, 0);
131
- }, l.onerror = () => k("network", p, h), C = setTimeout(() => k("timeout", p, h), g), document.getElementById(d)?.remove(), document.head.appendChild(l);
131
+ }, l.onerror = () => k("network", u, y), C = setTimeout(() => k("timeout", u, y), m), document.getElementById(p)?.remove(), document.head.appendChild(l);
132
132
  }, N = F(n, a, s);
133
133
  return N ? (E(N, !1), () => {
134
- m = !0, S();
134
+ d = !0, v();
135
135
  }) : x;
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,19 +141,19 @@ const $ = {
141
141
  "eu-cert": "https://sdk-cdn.cert.zerohash.eu",
142
142
  "eu-prod": "https://sdk-cdn.zerohash.eu"
143
143
  }, q = (e, t, o = {}) => {
144
- const { eu: r = !1, legacyAliases: n = !1, local: i = u.local } = o, c = (s) => `${s}/${e}/${t}`, a = {
144
+ const { eu: r = !1, legacyAliases: n = !1, local: i = f.local } = o, c = (s) => `${s}/${e}/${t}`, a = {
145
145
  local: c(i),
146
- dev: c(u.dev),
147
- cert: c(u.cert),
148
- prod: c(u.prod)
146
+ dev: c(f.dev),
147
+ cert: c(f.cert),
148
+ prod: c(f.prod)
149
149
  };
150
- 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;
150
+ return n && (a.sandbox = c(f.cert), a.production = c(f.prod)), r && (a["eu-cert"] = c(f["eu-cert"]), a["eu-prod"] = c(f["eu-prod"])), a;
151
151
  };
152
152
  var L;
153
153
  (function(e) {
154
154
  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";
155
155
  })(L || (L = {}));
156
- const R = {
156
+ const S = {
157
157
  evergreen: "#00381D",
158
158
  green: "#CCFFD0",
159
159
  offBlack: "#1C1B1C",
@@ -168,18 +168,18 @@ const R = {
168
168
  padding: "32px 24px",
169
169
  textAlign: "center",
170
170
  fontFamily: "inherit",
171
- color: R.offBlack,
171
+ color: S.offBlack,
172
172
  background: "#FFFFFF",
173
- border: `1px solid ${R.grayLight}`,
173
+ border: `1px solid ${S.grayLight}`,
174
174
  borderRadius: "12px"
175
- }, children: [y("svg", { width: "32", height: "32", viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", children: y("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: R.evergreen, strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) }), y("p", { style: { margin: 0, fontSize: "16px", fontWeight: 600 }, children: "Something went wrong" }), y("p", { style: { margin: 0, fontSize: "14px", opacity: 0.75 }, children: "We couldn't load this content. Please check your internet connection and try again." }), y("button", { type: "button", onClick: e, style: {
175
+ }, children: [_("svg", { width: "32", height: "32", viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", children: _("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: S.evergreen, strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) }), _("p", { style: { margin: 0, fontSize: "16px", fontWeight: 600 }, children: "Something went wrong" }), _("p", { style: { margin: 0, fontSize: "14px", opacity: 0.75 }, children: "We couldn't load this content. Please check your internet connection and try again." }), _("button", { type: "button", onClick: e, style: {
176
176
  marginTop: "8px",
177
177
  padding: "8px 20px",
178
178
  fontSize: "14px",
179
179
  fontWeight: 600,
180
180
  fontFamily: "inherit",
181
- color: R.green,
182
- background: R.evergreen,
181
+ color: S.green,
182
+ background: S.evergreen,
183
183
  border: "none",
184
184
  borderRadius: "8px",
185
185
  cursor: "pointer"
@@ -191,8 +191,8 @@ const R = {
191
191
  n !== void 0 && (o[r] = n);
192
192
  });
193
193
  }, Y = (e) => {
194
- const { webComponentTag: t, appName: o, appVersion: r, scriptUrls: n, fallbackScriptUrls: i, collectorUrls: c, env: a, jwt: s, timeoutMs: g } = e, [_, f] = z(!1), [d, b] = z(0);
195
- B(() => (f(!1), Z({
194
+ const { webComponentTag: t, appName: o, appVersion: r, scriptUrls: n, fallbackScriptUrls: i, collectorUrls: c, env: a, jwt: s, timeoutMs: m } = e, [b, g] = z(!1), [p, h] = z(0);
195
+ B(() => (g(!1), Z({
196
196
  webComponentTag: t,
197
197
  appName: o ?? t,
198
198
  appVersion: r,
@@ -201,8 +201,8 @@ const R = {
201
201
  collectorUrls: c ?? $,
202
202
  env: a,
203
203
  jwt: s,
204
- timeoutMs: g,
205
- onError: () => f(!0)
204
+ timeoutMs: m,
205
+ onError: () => g(!0)
206
206
  })), [
207
207
  t,
208
208
  o,
@@ -212,11 +212,11 @@ const R = {
212
212
  c,
213
213
  a,
214
214
  s,
215
- g,
216
- d
215
+ m,
216
+ p
217
217
  ]);
218
- const v = D(() => b((m) => m + 1), []);
219
- return { loadFailed: _, retry: v };
218
+ const R = D(() => h((d) => d + 1), []);
219
+ return { loadFailed: b, retry: R };
220
220
  }, ee = q("fund-web", "index.js", { eu: !0 }), A = "zerohash-fund", re = ({
221
221
  jwt: e,
222
222
  env: t = "prod",
@@ -224,28 +224,41 @@ const R = {
224
224
  branding: r,
225
225
  isPay: n = !1,
226
226
  onCompleted: i,
227
- onError: c,
228
- onClose: a,
229
- onLoaded: s,
227
+ onFailed: c,
228
+ onProvideInfo: a,
229
+ onError: s,
230
+ onClose: m,
231
+ onLoaded: b,
230
232
  onEvent: g,
231
- ..._
233
+ ...p
232
234
  }) => {
233
- const f = M(null);
234
- X(f, { isPay: n, theme: o, branding: r, onCompleted: i, onError: c, onClose: a, onLoaded: s, onEvent: g });
235
- const { loadFailed: d, retry: b } = Y({
235
+ const h = M(null);
236
+ X(h, {
237
+ isPay: n,
238
+ theme: o,
239
+ branding: r,
240
+ onCompleted: i,
241
+ onFailed: c,
242
+ onProvideInfo: a,
243
+ onError: s,
244
+ onClose: m,
245
+ onLoaded: b,
246
+ onEvent: g
247
+ });
248
+ const { loadFailed: R, retry: d } = Y({
236
249
  webComponentTag: A,
237
250
  scriptUrls: ee,
238
251
  // fallbackScriptUrls: FALLBACK_SCRIPT_URLS, // enable once the host is confirmed (AUTH-3095)
239
252
  env: t,
240
253
  jwt: e
241
254
  });
242
- return d ? /* @__PURE__ */ y(Q, { onRetry: b }) : j.createElement(A, {
243
- ref: f,
255
+ return R ? /* @__PURE__ */ _(Q, { onRetry: d }) : j.createElement(A, {
256
+ ref: h,
244
257
  jwt: e,
245
258
  env: t,
246
259
  theme: o,
247
260
  ispay: n ? "true" : void 0,
248
- ..._
261
+ ...p
249
262
  });
250
263
  };
251
264
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zerohash-sdk/fund-react",
3
- "version": "1.8.1",
3
+ "version": "1.9.1",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",