@coinbase/cdp-react 0.0.67 → 0.0.69

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.
@@ -1,20 +1,20 @@
1
- import { u as F, A as B } from "../../chunks/useSendComponentCallOnce.BHZMuo6E.js";
2
- import { createContext as M, useMemo as x, useContext as v } from "react";
3
- import { VERSION as I } from "../../version.js";
1
+ import { u as S, A as Y } from "../../chunks/useSendComponentCallOnce.BHZMuo6E.js";
2
+ import { createContext as N, useMemo as x, useState as z, useCallback as D, useContext as A } from "react";
3
+ import { VERSION as O } from "../../version.js";
4
4
  import "../AuthButton/index.js";
5
5
  import { useAppConfig as g } from "../CDPReactProvider/index.js";
6
- import { CopyAddress as K } from "../CopyAddress/index.js";
7
- import { CopyEvmKeyButton as V } from "../CopyEvmKeyButton/index.js";
8
- import { CopySolanaKeyButton as z } from "../CopySolanaKeyButton/index.js";
9
- import { jsx as o, jsxs as m, Fragment as E } from "react/jsx-runtime";
10
- import { useCurrentUser as D } from "@coinbase/cdp-hooks";
11
- import { c as f } from "../../chunks/lite.1fxw3LjI.js";
12
- import { Banner as h } from "../ui/Banner/index.js";
13
- import { CoinbaseFooter as O } from "../ui/CoinbaseFooter/index.js";
14
- import { Button as b } from "../ui/Button/index.js";
15
- import { Modal as j, ModalClose as U, ModalContent as X, ModalTitle as Y, ModalTrigger as Z } from "../ui/Modal/index.js";
16
- import { IconXMark as $ } from "../../icons/IconXMark.js";
17
- import { childrenHasComponent as W } from "../../utils/childrenHasComponent.js";
6
+ import { CopyAddress as j } from "../CopyAddress/index.js";
7
+ import { CopyEvmKeyButton as U } from "../CopyEvmKeyButton/index.js";
8
+ import { CopySolanaKeyButton as X } from "../CopySolanaKeyButton/index.js";
9
+ import { jsx as o, jsxs as d, Fragment as E } from "react/jsx-runtime";
10
+ import { useCurrentUser as Z } from "@coinbase/cdp-hooks";
11
+ import { c as h } from "../../chunks/lite.1fxw3LjI.js";
12
+ import { Banner as _ } from "../ui/Banner/index.js";
13
+ import { CoinbaseFooter as $ } from "../ui/CoinbaseFooter/index.js";
14
+ import { Button as T } from "../ui/Button/index.js";
15
+ import { Modal as q, ModalClose as H, ModalContent as L, ModalTitle as G, ModalTrigger as J } from "../ui/Modal/index.js";
16
+ import { IconXMark as Q } from "../../icons/IconXMark.js";
17
+ import { childrenHasComponent as M } from "../../utils/childrenHasComponent.js";
18
18
  import "../Fund/index.js";
19
19
  import "../FundModal/index.js";
20
20
  import "../LinkAuth/index.js";
@@ -51,7 +51,7 @@ import "../../utils/isApiError.js";
51
51
  import "../../utils/isEmailInvalid.js";
52
52
  import "../../utils/parseValuesFromPhoneNumber.js";
53
53
  import "../../utils/sendIframeMessage.js";
54
- import "@coinbase/cdp-core";
54
+ import "../../types/secureIframe.js";
55
55
  import "../Fund/FundForm.js";
56
56
  import "../Fund/FundTitle.js";
57
57
  import "../Fund/FundProvider.js";
@@ -69,213 +69,243 @@ import "../SignIn/SignInForm.js";
69
69
  import "../SignIn/SignInImage.js";
70
70
  import "../SignIn/SignInTitle.js";
71
71
  import "../SignIn/SignInProvider.js";
72
- import '../../assets/ExportWallet.css';const q = "ExportWallet-module__footer___NvrFY", _ = {
72
+ import '../../assets/ExportWallet.css';const tt = "ExportWallet-module__footer___NvrFY", f = {
73
73
  "export-wallet": "ExportWallet-module__export-wallet___EyZys",
74
74
  "no-footer": "ExportWallet-module__no-footer___fzl3R",
75
75
  "export-wallet-title": "ExportWallet-module__export-wallet-title___MuI09",
76
- footer: q
77
- }, N = M({
76
+ footer: tt
77
+ }, k = N({
78
78
  address: "",
79
+ isSessionExpired: !1,
79
80
  type: "evm-eoa"
80
81
  }), C = () => {
81
- const t = v(N);
82
+ const t = A(k);
82
83
  if (!t)
83
84
  throw new Error("useExportWalletContext must be used within a ExportWalletProvider");
84
85
  return t;
85
- }, H = ({
86
+ }, ot = ({
86
87
  address: t,
87
- children: r,
88
- onIframeError: e,
89
- onIframeReady: l,
90
- onCopySuccess: n
88
+ children: e,
89
+ onIframeError: r,
90
+ onIframeReady: a,
91
+ onIframeSessionExpired: l,
92
+ onCopySuccess: i
91
93
  }) => {
92
- const { currentUser: a } = D(), i = x(
93
- () => !!a?.solanaAccounts?.find((c) => c === t),
94
- [a?.solanaAccounts, t]
95
- ), s = x(
96
- () => !!a?.evmSmartAccounts?.find((c) => c === t),
97
- [a?.evmSmartAccounts, t]
98
- ), d = i ? "solana" : s ? "evm-smart" : "evm-eoa", u = x(
99
- () => ({ address: t, type: d, onIframeError: e, onIframeReady: l, onCopySuccess: n }),
100
- [t, d, e, l, n]
94
+ const { currentUser: n } = Z(), s = x(
95
+ () => !!n?.solanaAccounts?.find((w) => w === t),
96
+ [n?.solanaAccounts, t]
97
+ ), m = x(
98
+ () => !!n?.evmSmartAccounts?.find((w) => w === t),
99
+ [n?.evmSmartAccounts, t]
100
+ ), c = s ? "solana" : m ? "evm-smart" : "evm-eoa", [u, y] = z(!1), v = D(() => {
101
+ y(!0), l?.();
102
+ }, [l]), V = x(
103
+ () => ({
104
+ address: t,
105
+ isSessionExpired: u,
106
+ type: c,
107
+ onIframeError: r,
108
+ onIframeReady: a,
109
+ onIframeSessionExpired: v,
110
+ onCopySuccess: i
111
+ }),
112
+ [
113
+ t,
114
+ u,
115
+ c,
116
+ v,
117
+ r,
118
+ a,
119
+ i
120
+ ]
101
121
  );
102
- return /* @__PURE__ */ o(N.Provider, { value: u, children: r });
103
- }, A = ({
122
+ return /* @__PURE__ */ o(k.Provider, { value: V, children: e });
123
+ }, P = ({
104
124
  children: t,
105
- className: r = "",
106
- as: e = "h2",
107
- ...l
125
+ className: e = "",
126
+ as: r = "h2",
127
+ ...a
108
128
  }) => /* @__PURE__ */ o(
109
- e,
129
+ r,
110
130
  {
111
131
  "data-part": "title",
112
- className: f(_["export-wallet-title"], r),
113
- ...l,
132
+ className: h(f["export-wallet-title"], e),
133
+ ...a,
114
134
  children: t || "Export your wallet"
115
135
  }
116
- ), S = (t) => {
117
- const { type: r } = C();
118
- return r === "evm-smart" ? /* @__PURE__ */ o(h, { "data-part": "warning", variant: "warning", ...t, children: "Cannot export a smart account's private key; only the owner's private key can be exported." }) : /* @__PURE__ */ o(h, { "data-part": "warning", variant: "warning", ...t, children: "Do not share your private key with anyone" });
119
- }, T = ({
136
+ ), F = (t) => {
137
+ const { isSessionExpired: e, type: r } = C();
138
+ return e ? /* @__PURE__ */ o(_, { "data-part": "warning", variant: "warning", ...t, children: "Your export session has expired." }) : r === "evm-smart" ? /* @__PURE__ */ o(_, { "data-part": "warning", variant: "warning", ...t, children: "Cannot export a smart account's private key; only the owner's private key can be exported." }) : /* @__PURE__ */ o(_, { "data-part": "warning", variant: "warning", ...t, children: "Do not share your private key with anyone" });
139
+ }, I = ({
120
140
  label: t = "Your wallet address",
121
- ...r
141
+ ...e
122
142
  }) => {
123
- const { address: e } = C();
124
- return /* @__PURE__ */ o(K, { "data-part": "copy-address", address: e, label: t, ...r });
125
- }, k = ({
143
+ const { address: r } = C();
144
+ return /* @__PURE__ */ o(j, { "data-part": "copy-address", address: r, label: t, ...e });
145
+ }, R = ({
126
146
  fullWidth: t = !0,
127
- ...r
147
+ ...e
128
148
  }) => {
129
- const { address: e, type: l, onIframeError: n, onIframeReady: a, onCopySuccess: i } = C();
130
- return l === "solana" ? /* @__PURE__ */ o(
131
- z,
149
+ const { address: r, type: a, onIframeError: l, onIframeReady: i, onIframeSessionExpired: n, onCopySuccess: s } = C();
150
+ return a === "solana" ? /* @__PURE__ */ o(
151
+ X,
132
152
  {
133
153
  fullWidth: t,
134
- address: e,
135
- onError: n,
136
- onReady: a,
137
- onSuccess: i,
138
- ...r
154
+ address: r,
155
+ onError: l,
156
+ onReady: i,
157
+ onSessionExpired: n,
158
+ onSuccess: s,
159
+ ...e
139
160
  }
140
- ) : l === "evm-eoa" ? /* @__PURE__ */ o(
141
- V,
161
+ ) : a === "evm-eoa" ? /* @__PURE__ */ o(
162
+ U,
142
163
  {
143
164
  fullWidth: t,
144
- address: e,
145
- onError: n,
146
- onReady: a,
147
- onSuccess: i,
148
- ...r
165
+ address: r,
166
+ onError: l,
167
+ onReady: i,
168
+ onSessionExpired: n,
169
+ onSuccess: s,
170
+ ...e
149
171
  }
150
172
  ) : null;
151
- }, P = (t) => /* @__PURE__ */ o(O, { "data-part": "coinbase-footer", ...t }), L = ({
173
+ }, B = (t) => /* @__PURE__ */ o($, { "data-part": "coinbase-footer", ...t }), et = ({ children: t }) => {
174
+ const { showCoinbaseFooter: e } = g(), { type: r, isSessionExpired: a } = C();
175
+ return t && typeof t == "function" ? t({ type: r, isSessionExpired: a }) : t || /* @__PURE__ */ d(E, { children: [
176
+ /* @__PURE__ */ o(P, {}),
177
+ /* @__PURE__ */ o(F, {}),
178
+ /* @__PURE__ */ o(I, {}),
179
+ /* @__PURE__ */ o(R, {}),
180
+ e && /* @__PURE__ */ o(B, { className: f.footer })
181
+ ] });
182
+ }, rt = ({
152
183
  address: t,
153
- children: r,
154
- className: e = "",
155
- onIframeError: l,
156
- onIframeReady: n,
157
- onCopySuccess: a,
158
- ...i
184
+ children: e,
185
+ className: r = "",
186
+ onIframeError: a,
187
+ onIframeReady: l,
188
+ onIframeSessionExpired: i,
189
+ onCopySuccess: n,
190
+ ...s
159
191
  }) => {
160
- const { showCoinbaseFooter: s } = g();
192
+ S("export_wallet");
193
+ const { showCoinbaseFooter: m } = g();
161
194
  return /* @__PURE__ */ o(
162
195
  "div",
163
196
  {
164
- className: f(
165
- _["export-wallet"],
166
- !s && _["no-footer"],
167
- e
197
+ className: h(
198
+ f["export-wallet"],
199
+ !m && f["no-footer"],
200
+ r
168
201
  ),
169
- ...i,
202
+ ...s,
170
203
  children: /* @__PURE__ */ o(
171
- H,
204
+ ot,
172
205
  {
173
206
  address: t,
174
- onIframeReady: n,
175
- onCopySuccess: a,
176
- onIframeError: l,
177
- children: r || /* @__PURE__ */ m(E, { children: [
178
- /* @__PURE__ */ o(A, {}),
179
- /* @__PURE__ */ o(S, {}),
180
- /* @__PURE__ */ o(T, {}),
181
- /* @__PURE__ */ o(k, {}),
182
- s && /* @__PURE__ */ o(P, { className: _.footer })
183
- ] })
207
+ onIframeReady: l,
208
+ onCopySuccess: n,
209
+ onIframeError: a,
210
+ onIframeSessionExpired: i,
211
+ children: /* @__PURE__ */ o(et, { children: e })
184
212
  }
185
213
  )
186
214
  }
187
215
  );
188
- }, G = "ExportWalletModal-module__trigger___zMk8N", J = "ExportWalletModal-module__content___KzNol", Q = "ExportWalletModal-module__footer___byg1T", tt = "ExportWalletModal-module__modal___pX1AP", p = {
216
+ }, at = "ExportWalletModal-module__trigger___zMk8N", nt = "ExportWalletModal-module__content___KzNol", lt = "ExportWalletModal-module__footer___byg1T", it = "ExportWalletModal-module__modal___pX1AP", p = {
189
217
  "export-wallet": "ExportWalletModal-module__export-wallet___--L56",
190
- trigger: G,
218
+ trigger: at,
191
219
  "title-bar": "ExportWalletModal-module__title-bar___RTPZq",
192
- content: J,
220
+ content: nt,
193
221
  "close-button": "ExportWalletModal-module__close-button___ImsDR",
194
222
  "close-icon": "ExportWalletModal-module__close-icon___iAfyT",
195
- footer: Q,
196
- modal: tt
197
- }, R = M(null), ot = () => {
198
- const t = v(R);
223
+ footer: lt,
224
+ modal: it
225
+ }, K = N(null), st = () => {
226
+ const t = A(K);
199
227
  if (!t)
200
228
  throw new Error("useExportWalletModalContext must be used within a ExportWalletModal");
201
229
  return t;
202
- }, w = ({
230
+ }, b = ({
203
231
  children: t,
204
- className: r = "",
205
- label: e,
206
- ...l
207
- }) => /* @__PURE__ */ o(Z, { asChild: !0, children: t || /* @__PURE__ */ o(b, { className: f(p.trigger, r), ...l, children: e || "Export wallet" }) }), rt = ({
232
+ className: e = "",
233
+ label: r,
234
+ ...a
235
+ }) => /* @__PURE__ */ o(J, { asChild: !0, children: t || /* @__PURE__ */ o(T, { className: h(p.trigger, e), ...a, children: r || "Export wallet" }) }), pt = ({
208
236
  children: t = "Copy private key to export wallet",
209
- ...r
210
- }) => /* @__PURE__ */ o(Y, { asChild: !0, children: /* @__PURE__ */ o(A, { ...r, children: t }) }), et = ({ children: t }) => /* @__PURE__ */ o(U, { asChild: !0, children: t || /* @__PURE__ */ o(
211
- b,
237
+ ...e
238
+ }) => /* @__PURE__ */ o(G, { asChild: !0, children: /* @__PURE__ */ o(P, { ...e, children: t }) }), mt = ({ children: t }) => /* @__PURE__ */ o(H, { asChild: !0, children: t || /* @__PURE__ */ o(
239
+ T,
212
240
  {
213
241
  "aria-label": "Close",
214
242
  className: p["close-button"],
215
243
  variant: "transparentSecondary",
216
- children: /* @__PURE__ */ o($, { className: p["close-icon"] })
244
+ children: /* @__PURE__ */ o(Q, { className: p["close-icon"] })
217
245
  }
218
- ) }), y = ({
246
+ ) }), W = ({
219
247
  children: t,
220
- className: r = "",
221
- ...e
248
+ className: e = "",
249
+ ...r
222
250
  }) => {
223
- const { showCoinbaseFooter: l } = g(), { address: n, onIframeReady: a, onCopySuccess: i, onIframeError: s } = ot();
224
- return /* @__PURE__ */ o(X, { "aria-describedby": void 0, className: f(p.modal, r), ...e, children: /* @__PURE__ */ o(
225
- L,
251
+ const { showCoinbaseFooter: a } = g(), { address: l, onIframeReady: i, onCopySuccess: n, onIframeError: s, onIframeSessionExpired: m } = st();
252
+ return /* @__PURE__ */ o(L, { "aria-describedby": void 0, className: h(p.modal, e), ...r, children: /* @__PURE__ */ o(
253
+ rt,
226
254
  {
227
- address: n,
228
- onIframeReady: a,
229
- onCopySuccess: i,
255
+ address: l,
256
+ onIframeReady: i,
257
+ onCopySuccess: n,
230
258
  onIframeError: s,
259
+ onIframeSessionExpired: m,
231
260
  className: p["export-wallet"],
232
- children: t || /* @__PURE__ */ m(E, { children: [
233
- /* @__PURE__ */ m("div", { className: p["title-bar"], children: [
234
- /* @__PURE__ */ o(rt, {}),
235
- /* @__PURE__ */ o(et, {})
261
+ children: t || (({ isSessionExpired: c }) => /* @__PURE__ */ d(E, { children: [
262
+ /* @__PURE__ */ d("div", { className: p["title-bar"], children: [
263
+ /* @__PURE__ */ o(pt, {}),
264
+ /* @__PURE__ */ o(mt, {})
236
265
  ] }),
237
- /* @__PURE__ */ m("div", { className: p.content, children: [
238
- /* @__PURE__ */ o(S, {}),
239
- /* @__PURE__ */ o(T, {}),
240
- /* @__PURE__ */ o(k, {}),
241
- l && /* @__PURE__ */ o(P, { className: p.footer })
266
+ /* @__PURE__ */ d("div", { className: p.content, children: [
267
+ c ? /* @__PURE__ */ o(_, { role: "alert", "data-part": "warning", variant: "warning", children: "Your export session has expired. Please close and reopen the modal to export again." }) : /* @__PURE__ */ o(F, {}),
268
+ /* @__PURE__ */ o(I, {}),
269
+ /* @__PURE__ */ o(R, {}),
270
+ a && /* @__PURE__ */ o(B, { className: p.footer })
242
271
  ] })
243
- ] })
272
+ ] }))
244
273
  }
245
274
  ) });
246
- }, wo = ({
275
+ }, Ao = ({
247
276
  address: t,
248
- children: r,
249
- onIframeReady: e,
250
- onCopySuccess: l,
251
- onIframeError: n,
252
- open: a,
253
- setIsOpen: i
277
+ children: e,
278
+ onIframeReady: r,
279
+ onCopySuccess: a,
280
+ onIframeError: l,
281
+ onIframeSessionExpired: i,
282
+ open: n,
283
+ setIsOpen: s
254
284
  }) => {
255
- F("export_wallet_modal");
256
- const s = x(
257
- () => ({ address: t, onIframeReady: e, onCopySuccess: l, onIframeError: n }),
258
- [t, e, l, n]
259
- ), d = r ? W(r, w) : !1, u = r ? W(r, y) : !1, c = !d && !u;
260
- return /* @__PURE__ */ o(R.Provider, { value: s, children: /* @__PURE__ */ o(j, { open: a, onOpenChange: i, children: c ? /* @__PURE__ */ m(E, { children: [
261
- /* @__PURE__ */ o(w, { children: r }),
262
- /* @__PURE__ */ o(y, {})
263
- ] }) : /* @__PURE__ */ m(E, { children: [
264
- r,
265
- !u && /* @__PURE__ */ o(y, {})
285
+ S("export_wallet_modal");
286
+ const m = x(
287
+ () => ({ address: t, onIframeReady: r, onCopySuccess: a, onIframeError: l, onIframeSessionExpired: i }),
288
+ [t, r, a, l, i]
289
+ ), c = e ? M(e, b) : !1, u = e ? M(e, W) : !1, y = !c && !u;
290
+ return /* @__PURE__ */ o(K.Provider, { value: m, children: /* @__PURE__ */ o(q, { open: n, onOpenChange: s, children: y ? /* @__PURE__ */ d(E, { children: [
291
+ /* @__PURE__ */ o(b, { children: e }),
292
+ /* @__PURE__ */ o(W, {})
293
+ ] }) : /* @__PURE__ */ d(E, { children: [
294
+ e,
295
+ !u && /* @__PURE__ */ o(W, {})
266
296
  ] }) }) });
267
297
  };
268
- B.registerPackageVersion("react", I);
298
+ Y.registerPackageVersion("react", O);
269
299
  export {
270
- wo as E,
271
- L as ExportWallet,
272
- T as ExportWalletCopyAddress,
273
- k as ExportWalletCopyKeyButton,
274
- P as ExportWalletFooter,
275
- A as ExportWalletTitle,
276
- S as ExportWalletWarning,
277
- et as a,
278
- y as b,
279
- rt as c,
280
- w as d
300
+ Ao as E,
301
+ rt as ExportWallet,
302
+ I as ExportWalletCopyAddress,
303
+ R as ExportWalletCopyKeyButton,
304
+ B as ExportWalletFooter,
305
+ P as ExportWalletTitle,
306
+ F as ExportWalletWarning,
307
+ mt as a,
308
+ W as b,
309
+ pt as c,
310
+ b as d
281
311
  };
@@ -6,12 +6,12 @@ interface ExportWalletModalTriggerProps extends Partial<Pick<ButtonProps, "class
6
6
  children?: ReactNode;
7
7
  label?: ReactNode;
8
8
  }
9
- type ExportWalletModalContentProps = ModalContentProps;
9
+ type ExportWalletModalContentProps = Omit<ModalContentProps, "children"> & Pick<ExportWalletProps, "children">;
10
10
  type ExportWalletModalTitleProps = ExportWalletTitleProps;
11
11
  interface ExportWalletModalCloseProps {
12
12
  children?: ReactNode;
13
13
  }
14
- interface ExportWalletModalProps extends Pick<ExportWalletProps, "address" | "onIframeReady" | "onCopySuccess" | "onIframeError"> {
14
+ interface ExportWalletModalProps extends Pick<ExportWalletProps, "address" | "onIframeReady" | "onCopySuccess" | "onIframeError" | "onIframeSessionExpired"> {
15
15
  children?: ReactNode;
16
16
  open?: boolean;
17
17
  setIsOpen?: (value: boolean) => void;
@@ -20,5 +20,5 @@ declare const ExportWalletModalTrigger: ({ children, className, label, ...props
20
20
  declare const ExportWalletModalTitle: ({ children, ...props }: ExportWalletModalTitleProps) => import("react/jsx-runtime").JSX.Element;
21
21
  declare const ExportWalletModalClose: ({ children }: ExportWalletModalCloseProps) => import("react/jsx-runtime").JSX.Element;
22
22
  declare const ExportWalletModalContent: ({ children, className, ...props }: ExportWalletModalContentProps) => import("react/jsx-runtime").JSX.Element;
23
- declare const ExportWalletModal: ({ address, children, onIframeReady, onCopySuccess, onIframeError, open, setIsOpen, }: ExportWalletModalProps) => import("react/jsx-runtime").JSX.Element;
23
+ declare const ExportWalletModal: ({ address, children, onIframeReady, onCopySuccess, onIframeError, onIframeSessionExpired, open, setIsOpen, }: ExportWalletModalProps) => import("react/jsx-runtime").JSX.Element;
24
24
  export { ExportWalletModal, ExportWalletModalClose, ExportWalletModalContent, ExportWalletModalTitle, ExportWalletModalTrigger, type ExportWalletModalProps, type ExportWalletModalCloseProps, type ExportWalletModalContentProps, type ExportWalletModalTitleProps, type ExportWalletModalTriggerProps, };
@@ -3,15 +3,16 @@ import "../../chunks/useSendComponentCallOnce.BHZMuo6E.js";
3
3
  import "react";
4
4
  import "../../chunks/lite.1fxw3LjI.js";
5
5
  import "../CDPReactProvider/index.js";
6
- import { E as x, a as E, b as M, c as W, d as g } from "../ExportWallet/index.js";
6
+ import { E, a as M, b as W, c as g, d as n } from "../ExportWallet/index.js";
7
+ import "../ui/Banner/index.js";
7
8
  import "../ui/Button/index.js";
8
9
  import "../ui/Modal/index.js";
9
10
  import "../../icons/IconXMark.js";
10
11
  import "../../utils/childrenHasComponent.js";
11
12
  export {
12
- x as ExportWalletModal,
13
- E as ExportWalletModalClose,
14
- M as ExportWalletModalContent,
15
- W as ExportWalletModalTitle,
16
- g as ExportWalletModalTrigger
13
+ E as ExportWalletModal,
14
+ M as ExportWalletModalClose,
15
+ W as ExportWalletModalContent,
16
+ g as ExportWalletModalTitle,
17
+ n as ExportWalletModalTrigger
17
18
  };
@@ -1,9 +1,8 @@
1
1
  import { EventMetadata, OnrampError, OnrampSuccessEventData } from '../types';
2
2
  type SetupOnrampEventListenersParams = {
3
- host?: string;
4
3
  onEvent?: (event: EventMetadata) => void;
5
4
  onExit?: (error?: OnrampError) => void;
6
5
  onSuccess?: (data?: OnrampSuccessEventData) => void;
7
6
  };
8
- export declare function setupOnrampEventListeners({ host, onEvent, onExit, onSuccess, }: SetupOnrampEventListenersParams): () => void;
7
+ export declare function setupOnrampEventListeners({ onEvent, onExit, onSuccess, }: SetupOnrampEventListenersParams): () => void;
9
8
  export {};
@@ -1,19 +1,17 @@
1
1
  import "react";
2
- import { subscribeToWindowMessage as o, DEFAULT_ONRAMP_URL as a } from "./subscribeToWindowMessage.js";
3
- function b({
4
- host: s = a,
5
- onEvent: t,
6
- onExit: n,
7
- onSuccess: r
2
+ import { subscribeToWindowMessage as i } from "./subscribeToWindowMessage.js";
3
+ function c({
4
+ onEvent: s,
5
+ onExit: t,
6
+ onSuccess: n
8
7
  }) {
9
- return o({
10
- allowedOrigin: s,
11
- onMessage: (i) => {
12
- const e = i;
13
- e.eventName === "success" && r?.(e.data), e.eventName === "exit" && n?.(e.error), t?.(e);
8
+ return i({
9
+ onMessage: (r) => {
10
+ const e = r;
11
+ e.eventName === "success" && n?.(e.data), e.eventName === "exit" && t?.(e.error), s?.(e);
14
12
  }
15
13
  });
16
14
  }
17
15
  export {
18
- b as setupOnrampEventListeners
16
+ c as setupOnrampEventListeners
19
17
  };
@@ -4,11 +4,11 @@ export type JsonObject = {
4
4
  export type JsonArray = JsonValue[];
5
5
  export type JsonPrimitive = string | number | boolean | null;
6
6
  export type JsonValue = JsonPrimitive | JsonObject | JsonArray;
7
- export declare const DEFAULT_ONRAMP_URL = "https://pay.coinbase.com";
7
+ export declare const DEFAULT_ONRAMP_URL: string[];
8
8
  type MessageData = JsonObject;
9
9
  export declare function subscribeToWindowMessage({ onMessage, allowedOrigin, onValidateOrigin, }: {
10
10
  onMessage: (data?: MessageData) => void;
11
- allowedOrigin: string;
11
+ allowedOrigin?: string | string[];
12
12
  onValidateOrigin?: (origin: string) => Promise<boolean>;
13
13
  }): () => void;
14
14
  export {};
@@ -1,23 +1,23 @@
1
- const a = "https://pay.coinbase.com";
1
+ const a = ["https://pay.coinbase.com", "https://pay-sandbox.coinbase.com"];
2
2
  function d({
3
- onMessage: s,
4
- allowedOrigin: e = a,
5
- onValidateOrigin: n = () => Promise.resolve(!0)
3
+ onMessage: e,
4
+ allowedOrigin: s = a,
5
+ onValidateOrigin: i = () => Promise.resolve(!0)
6
6
  }) {
7
- const o = (i) => {
8
- if (!c({ event: i, allowedOrigin: e }))
7
+ const o = (n) => {
8
+ if (!c({ event: n, allowedOrigin: s }))
9
9
  return;
10
- const { eventName: t, data: r } = JSON.parse(i.data);
11
- t === "event" && (async () => await n(i.origin) && s(r))();
10
+ const { eventName: t, data: r } = JSON.parse(n.data);
11
+ t === "event" && (async () => await i(n.origin) && e(r))();
12
12
  };
13
13
  return window.addEventListener("message", o), () => {
14
14
  window.removeEventListener("message", o);
15
15
  };
16
16
  }
17
17
  const c = ({
18
- event: s,
19
- allowedOrigin: e
20
- }) => !e || s.origin === e;
18
+ event: e,
19
+ allowedOrigin: s
20
+ }) => !s || (typeof s == "string" ? e.origin === s : s.includes(e.origin));
21
21
  export {
22
22
  a as DEFAULT_ONRAMP_URL,
23
23
  d as subscribeToWindowMessage