@coinbase/cdp-react 0.0.85 → 0.0.87

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 (107) hide show
  1. package/dist/assets/CDPReactProvider.css +1 -1
  2. package/dist/assets/EnrollMfaFlow.css +1 -1
  3. package/dist/assets/VerifyMfaFlow.css +1 -1
  4. package/dist/assets/VerifyMfaFlowBackButton.css +1 -0
  5. package/dist/assets/VerifyMfaInline.css +1 -1
  6. package/dist/assets/VerifyMfaItem.css +1 -0
  7. package/dist/assets/VerifyMfaItems.css +1 -0
  8. package/dist/assets/sms.css +1 -0
  9. package/dist/chunks/CDPReactProvider.C38bKQ2x.js +337 -0
  10. package/dist/chunks/{LinkAuthFlow.BaUSMzGH.js → LinkAuthFlow.CLubKoY0.js} +13 -13
  11. package/dist/chunks/{index.C_DV0Ud7.js → index.BN39qScu.js} +1 -1
  12. package/dist/chunks/index.BX4k-ruQ.js +12 -0
  13. package/dist/chunks/index.Bgx0-QLY.js +12 -0
  14. package/dist/components/CDPReactProvider/index.js +1 -1
  15. package/dist/components/EnrollMfa/EnrollMfaDescription.js +4 -3
  16. package/dist/components/EnrollMfa/EnrollMfaFlow.js +27 -26
  17. package/dist/components/EnrollMfa/EnrollMfaFlowBackButton.js +7 -6
  18. package/dist/components/EnrollMfa/EnrollMfaFlowProvider.d.ts +1 -1
  19. package/dist/components/EnrollMfa/EnrollMfaFlowProvider.js +5 -4
  20. package/dist/components/EnrollMfa/EnrollMfaImage.js +7 -6
  21. package/dist/components/EnrollMfa/EnrollMfaItem.js +7 -6
  22. package/dist/components/EnrollMfa/EnrollMfaItems.js +28 -25
  23. package/dist/components/EnrollMfa/EnrollMfaProvider.js +22 -17
  24. package/dist/components/EnrollMfa/EnrollMfaTitle.js +8 -7
  25. package/dist/components/EnrollMfa/index.js +138 -123
  26. package/dist/components/EnrollMfa/methods/sms.d.ts +6 -0
  27. package/dist/components/EnrollMfa/methods/sms.js +148 -0
  28. package/dist/components/EnrollMfa/methods/totp.js +24 -19
  29. package/dist/components/EnrollMfa/types.d.ts +17 -5
  30. package/dist/components/EnrollMfa/types.js +1 -0
  31. package/dist/components/EnrollMfa/useEnrollMfaReducer.js +51 -38
  32. package/dist/components/EnrollMfaModal/index.js +1 -1
  33. package/dist/components/ExportWallet/index.js +109 -101
  34. package/dist/components/ExportWalletModal/index.js +1 -1
  35. package/dist/components/Fund/index.js +1 -1
  36. package/dist/components/FundModal/index.js +1 -1
  37. package/dist/components/LinkAuth/LinkAuthFlow.js +2 -2
  38. package/dist/components/LinkAuth/LinkAuthFlowBackButton.js +2 -2
  39. package/dist/components/LinkAuth/LinkAuthFlowProvider.js +2 -2
  40. package/dist/components/LinkAuth/LinkAuthItem.js +1 -1
  41. package/dist/components/LinkAuth/LinkAuthItems.js +1 -1
  42. package/dist/components/LinkAuth/LinkAuthProvider.js +1 -1
  43. package/dist/components/LinkAuth/index.js +59 -60
  44. package/dist/components/LinkAuth/types.js +1 -1
  45. package/dist/components/LinkAuth/utils.js +1 -1
  46. package/dist/components/LinkAuthModal/index.js +2 -2
  47. package/dist/components/OAuthStatusModal/index.js +1 -1
  48. package/dist/components/SignIn/SignInAuthMethodButtons.js +1 -1
  49. package/dist/components/SignIn/SignInBackButton.js +12 -12
  50. package/dist/components/SignIn/SignInDescription.js +2 -2
  51. package/dist/components/SignIn/SignInForm.js +2 -2
  52. package/dist/components/SignIn/SignInImage.js +1 -1
  53. package/dist/components/SignIn/SignInProvider.js +1 -1
  54. package/dist/components/SignIn/SignInTitle.js +2 -2
  55. package/dist/components/SignIn/flows/SignInWithEmail.js +1 -1
  56. package/dist/components/SignIn/flows/SignInWithOAuth.js +1 -1
  57. package/dist/components/SignIn/flows/SignInWithSms.js +74 -84
  58. package/dist/components/SignIn/index.js +1 -1
  59. package/dist/components/SignIn/types.d.ts +2 -0
  60. package/dist/components/SignIn/types.js +1 -1
  61. package/dist/components/SignIn/useSignInReducer.js +20 -6
  62. package/dist/components/SignInModal/index.js +1 -1
  63. package/dist/components/VerifyMfa/VerifyMfaDescription.d.ts +1 -1
  64. package/dist/components/VerifyMfa/VerifyMfaDescription.js +24 -14
  65. package/dist/components/VerifyMfa/VerifyMfaFlow.d.ts +5 -4
  66. package/dist/components/VerifyMfa/VerifyMfaFlow.js +52 -13
  67. package/dist/components/VerifyMfa/VerifyMfaFlowBackButton.d.ts +9 -0
  68. package/dist/components/VerifyMfa/VerifyMfaFlowBackButton.js +40 -0
  69. package/dist/components/VerifyMfa/VerifyMfaFlowProvider.d.ts +23 -0
  70. package/dist/components/VerifyMfa/VerifyMfaFlowProvider.js +37 -0
  71. package/dist/components/VerifyMfa/VerifyMfaImage.d.ts +1 -1
  72. package/dist/components/VerifyMfa/VerifyMfaImage.js +25 -13
  73. package/dist/components/VerifyMfa/VerifyMfaItem.d.ts +10 -0
  74. package/dist/components/VerifyMfa/VerifyMfaItem.js +27 -0
  75. package/dist/components/VerifyMfa/VerifyMfaItems.d.ts +9 -0
  76. package/dist/components/VerifyMfa/VerifyMfaItems.js +31 -0
  77. package/dist/components/VerifyMfa/VerifyMfaProvider.js +27 -14
  78. package/dist/components/VerifyMfa/VerifyMfaTitle.d.ts +1 -1
  79. package/dist/components/VerifyMfa/VerifyMfaTitle.js +23 -13
  80. package/dist/components/VerifyMfa/index.d.ts +6 -2
  81. package/dist/components/VerifyMfa/index.js +23 -14
  82. package/dist/components/VerifyMfa/methods/sms.d.ts +6 -0
  83. package/dist/components/VerifyMfa/methods/sms.js +90 -0
  84. package/dist/components/VerifyMfa/methods/totp.js +40 -39
  85. package/dist/components/VerifyMfa/types.d.ts +21 -2
  86. package/dist/components/VerifyMfa/types.js +1 -0
  87. package/dist/components/VerifyMfa/useVerifyMfaReducer.d.ts +2 -1
  88. package/dist/components/VerifyMfa/useVerifyMfaReducer.js +29 -4
  89. package/dist/components/VerifyMfaInline/index.d.ts +1 -1
  90. package/dist/components/VerifyMfaInline/index.js +133 -116
  91. package/dist/components/VerifyMfaModal/index.js +7 -5
  92. package/dist/components/ui/SwitchTransition/index.js +3 -3
  93. package/dist/hooks/usePhoneNumberState.d.ts +15 -0
  94. package/dist/hooks/usePhoneNumberState.js +39 -0
  95. package/dist/hooks/useTimeout.d.ts +4 -0
  96. package/dist/hooks/useTimeout.js +16 -0
  97. package/dist/hooks/useTransitionMap.js +58 -50
  98. package/dist/hooks/useVerifyMfaModal.js +1 -1
  99. package/dist/index.js +59 -51
  100. package/dist/utils/transition.d.ts +3 -3
  101. package/dist/utils/transition.js +21 -20
  102. package/dist/version.d.ts +1 -1
  103. package/dist/version.js +1 -1
  104. package/package.json +6 -6
  105. package/dist/chunks/CDPReactProvider.CIQm4C4z.js +0 -299
  106. package/dist/chunks/index.CKQKBoX2.js +0 -9
  107. package/dist/chunks/index.Dp-lIxM1.js +0 -9
@@ -1,299 +0,0 @@
1
- import { jsx as o, jsxs as p, Fragment as N } from "react/jsx-runtime";
2
- import { OAuth2ProviderType as Q, CDPContext as ee, CDPHooksProvider as oe } from "@coinbase/cdp-hooks";
3
- import { useRef as A, useEffect as S, createContext as D, useState as $, useCallback as m, useMemo as E, useContext as P, useId as j, lazy as te } from "react";
4
- import { registerMfaListener as re, cancelMfaVerification as ne } from "@coinbase/cdp-core";
5
- import { A as se, u as J } from "./useSendComponentCallOnce.BHZMuo6E.js";
6
- import { ThemeProvider as ae } from "../components/ThemeProvider/index.js";
7
- import { c as ie } from "./lite.1fxw3LjI.js";
8
- import { Button as Y } from "../components/ui/Button/index.js";
9
- import { Modal as ce, ModalContent as fe, ModalClose as le, ModalTitle as de, ModalDescription as ue, ModalTrigger as me } from "../components/ui/Modal/index.js";
10
- import { VerifyMfaDescription as q } from "../components/VerifyMfa/VerifyMfaDescription.js";
11
- import { VerifyMfaFlow as z } from "../components/VerifyMfa/VerifyMfaFlow.js";
12
- import { VerifyMfaFooter as B } from "../components/VerifyMfa/VerifyMfaFooter.js";
13
- import { VerifyMfaImage as G } from "../components/VerifyMfa/VerifyMfaImage.js";
14
- import { VerifyMfaProvider as pe, useVerifyMfaContext as he } from "../components/VerifyMfa/VerifyMfaProvider.js";
15
- import { VerifyMfaTitle as X } from "../components/VerifyMfa/VerifyMfaTitle.js";
16
- import { IconXMark as Me } from "../icons/IconXMark.js";
17
- import { childrenHasComponent as I } from "../utils/childrenHasComponent.js";
18
- import '../assets/CDPReactProvider.css';function _e(e) {
19
- const t = A(!1);
20
- S(() => {
21
- t.current || (se.sendHookCallEvent({ name: e }), t.current = !0);
22
- }, [e]);
23
- }
24
- const ve = "VerifyMfa-module__footer___3bANn", b = {
25
- "mfa-verification": "VerifyMfa-module__mfa-verification___txLpd",
26
- "mfa-verification-content": "VerifyMfa-module__mfa-verification-content___-ksMh",
27
- "mfa-verification-form": "VerifyMfa-module__mfa-verification-form___7b69Y",
28
- footer: ve
29
- }, ye = ({
30
- className: e = "",
31
- children: t,
32
- ...r
33
- }) => {
34
- const { state: n } = he(), { showCoinbaseFooter: s } = R(), a = typeof t == "function" ? t(n) : t;
35
- return /* @__PURE__ */ p("div", { className: `${b["mfa-verification"]} ${e}`, ...r, children: [
36
- a,
37
- !a && /* @__PURE__ */ p("div", { className: b["mfa-verification-content"], children: [
38
- /* @__PURE__ */ o(G, {}),
39
- /* @__PURE__ */ p("div", { children: [
40
- /* @__PURE__ */ o(X, {}),
41
- /* @__PURE__ */ o(q, {})
42
- ] }),
43
- /* @__PURE__ */ o(z, { className: b["mfa-verification-form"] }),
44
- s && /* @__PURE__ */ o(B, { className: b.footer })
45
- ] })
46
- ] });
47
- }, Ce = ({ onSuccess: e, onError: t, ...r }) => (J("verify_mfa"), /* @__PURE__ */ o(pe, { onError: t, onSuccess: e, children: /* @__PURE__ */ o(ye, { ...r }) })), ge = "VerifyMfaModal-module__verify___GZ6dw", Ve = "VerifyMfaModal-module__content___BSj0G", Ae = "VerifyMfaModal-module__header___2plY9", Pe = "VerifyMfaModal-module__trigger___YXiwC", we = "VerifyMfaModal-module__flow___HE2Lf", V = {
48
- verify: ge,
49
- content: Ve,
50
- header: Ae,
51
- "close-icon": "VerifyMfaModal-module__close-icon___pyobJ",
52
- "close-button": "VerifyMfaModal-module__close-button___h9yrq",
53
- trigger: Pe,
54
- flow: we
55
- }, K = D(null), xe = () => {
56
- const e = P(K);
57
- if (!e)
58
- throw new Error("useVerifyMfaModalContext must be used within a VerifyMfaModal");
59
- return e;
60
- }, U = ({
61
- children: e,
62
- className: t = "",
63
- label: r,
64
- ...n
65
- }) => /* @__PURE__ */ o(me, { asChild: !0, children: e || /* @__PURE__ */ o(Y, { className: ie(V.trigger, t), ...n, children: r || "Verify" }) }), O = ({ children: e, ...t }) => {
66
- const { onSuccess: r, onError: n } = xe(), { showCoinbaseFooter: s } = R();
67
- return /* @__PURE__ */ o(fe, { ...t, children: /* @__PURE__ */ o(Ce, { className: V.verify, onSuccess: r, onError: n, children: (a) => /* @__PURE__ */ p(N, { children: [
68
- e ? typeof e == "function" ? e(a) : e : null,
69
- !e && /* @__PURE__ */ p(N, { children: [
70
- /* @__PURE__ */ p("div", { className: V.header, children: [
71
- /* @__PURE__ */ o("span", {}),
72
- /* @__PURE__ */ o(le, { asChild: !0, children: /* @__PURE__ */ o(
73
- Y,
74
- {
75
- className: V["close-button"],
76
- "aria-label": "Close",
77
- size: "md",
78
- variant: "transparentSecondary",
79
- children: /* @__PURE__ */ o(Me, { className: V["close-icon"] })
80
- }
81
- ) })
82
- ] }),
83
- /* @__PURE__ */ p("div", { className: V.content, children: [
84
- /* @__PURE__ */ o(G, {}),
85
- /* @__PURE__ */ p("div", { children: [
86
- /* @__PURE__ */ o(de, { asChild: !0, children: /* @__PURE__ */ o(X, {}) }),
87
- /* @__PURE__ */ o(ue, { asChild: !0, children: /* @__PURE__ */ o(q, {}) })
88
- ] }),
89
- /* @__PURE__ */ o("div", { className: V.flow, children: /* @__PURE__ */ o(z, {}) })
90
- ] }),
91
- s && /* @__PURE__ */ o(B, {})
92
- ] })
93
- ] }) }) });
94
- }, be = ({
95
- children: e,
96
- open: t,
97
- setIsOpen: r,
98
- onCancel: n,
99
- onError: s,
100
- onSuccess: a
101
- }) => {
102
- J("verify_mfa_modal");
103
- const f = t !== void 0 && r !== void 0, [i, u] = $(!1), M = f ? t : i, l = A(!1), _ = m(
104
- (v) => {
105
- l.current = !0, a?.(v);
106
- },
107
- [a]
108
- ), y = m(
109
- (v) => {
110
- f ? r?.(v) : u(v), v || (l.current || n?.(), l.current = !1);
111
- },
112
- [f, r, u, n]
113
- ), h = e ? I(e, U) : !1, d = e ? I(e, O) : !1, w = !h && !d, x = E(
114
- () => ({ onCancel: n, onError: s, onSuccess: _ }),
115
- [n, s, _]
116
- );
117
- return /* @__PURE__ */ o(K.Provider, { value: x, children: /* @__PURE__ */ o(ce, { open: M, onOpenChange: y, children: w ? /* @__PURE__ */ p(N, { children: [
118
- /* @__PURE__ */ o(U, { children: e }),
119
- /* @__PURE__ */ o(O, {})
120
- ] }) : /* @__PURE__ */ p(N, { children: [
121
- e,
122
- !d && /* @__PURE__ */ o(O, {})
123
- ] }) }) });
124
- }, Oe = (e) => e?.closest("[data-cdp-provider]")?.getAttribute?.("data-cdp-provider") ?? null, F = D(void 0), Ne = "__core_mfa_handler__", Se = ({ children: e }) => {
125
- const { mfa: t } = R(), r = He(), { disableAutoPrompt: n } = t, [s, a] = $(null), f = A(/* @__PURE__ */ new Map()), i = A(!1), u = m((c, C) => {
126
- f.current.set(c, C);
127
- }, []), M = m((c) => {
128
- f.current.delete(c);
129
- }, []), l = A(s);
130
- l.current = s;
131
- const _ = A(null), y = m((c) => l.current !== null ? !1 : (_.current = document.activeElement, a(c), !0), []), h = m(() => {
132
- a(null);
133
- const c = _.current;
134
- _.current = null, c && requestAnimationFrame(() => {
135
- c.focus();
136
- });
137
- }, []);
138
- S(() => n ? void 0 : re(() => {
139
- const C = document.activeElement, k = Oe(C);
140
- k !== null && k !== r || (i.current = !0, y(Ne));
141
- }), [n, y, r]);
142
- const d = s ? f.current.get(s)?.current : void 0, w = s !== null, x = m(
143
- (c) => {
144
- c || h();
145
- },
146
- [h]
147
- ), v = m(
148
- (c) => {
149
- i.current && (i.current = !1), d?.onSuccess?.(c);
150
- const C = d?.closeOnSuccessDelay === void 0 ? 500 : d?.closeOnSuccessDelay;
151
- C !== null && (C === 0 ? h() : setTimeout(() => h(), C));
152
- },
153
- [d, h]
154
- ), L = m(
155
- (c) => {
156
- d?.onError?.(c);
157
- },
158
- [d]
159
- ), T = m(() => {
160
- i.current && (ne(), i.current = !1), d?.onCancel?.();
161
- }, [d]), Z = E(
162
- () => ({
163
- register: u,
164
- unregister: M,
165
- open: y,
166
- close: h
167
- }),
168
- [u, M, y, h]
169
- );
170
- return /* @__PURE__ */ p(F.Provider, { value: Z, children: [
171
- e,
172
- /* @__PURE__ */ o(
173
- be,
174
- {
175
- open: w,
176
- setIsOpen: x,
177
- onSuccess: v,
178
- onError: L,
179
- onCancel: T,
180
- children: /* @__PURE__ */ o(O, {})
181
- }
182
- )
183
- ] });
184
- }, Qe = (e = {}) => {
185
- const t = P(F);
186
- if (!t)
187
- throw new Error(
188
- "useVerifyMfaModal must be used within a MfaVerificationProvider or CDPReactProvider"
189
- );
190
- _e("use_verify_mfa_modal");
191
- const r = j(), n = A(e);
192
- S(() => {
193
- n.current = e;
194
- }, [e]);
195
- const { register: s, unregister: a, open: f, close: i } = t;
196
- S(() => (s(r, n), () => a(r)), [s, a, r]);
197
- const u = m(() => f(r), [f, r]), M = m(() => {
198
- i();
199
- }, [i]);
200
- return { open: u, close: M };
201
- }, eo = () => P(F) ?? {
202
- register: () => {
203
- },
204
- unregister: () => {
205
- },
206
- open: () => !1,
207
- close: () => {
208
- }
209
- }, Ee = te(() => import("../components/OAuthStatusModal/index.js")), W = (e) => {
210
- try {
211
- return JSON.stringify(e);
212
- } catch {
213
- }
214
- return "";
215
- }, Te = Object.keys(Q).map((e) => `oauth:${e}`), De = [
216
- /** Email OTP method */
217
- "email",
218
- /** SMS OTP method */
219
- "sms"
220
- ], oo = [...De, ...Te], to = ({
221
- children: e,
222
- className: t = "",
223
- config: r,
224
- name: n,
225
- style: s,
226
- theme: a
227
- }) => {
228
- const f = j(), i = n ?? f, { appName: u, appLogoUrl: M, showCoinbaseFooter: l, authMethods: _, ...y } = r, h = W(y), d = E(() => y, [h]), w = { appName: u, appLogoUrl: M, showCoinbaseFooter: l, authMethods: _ }, x = _?.some((T) => T.startsWith("oauth:")), v = /* @__PURE__ */ o(Fe, { name: i, config: w, children: /* @__PURE__ */ o(ae, { className: t, style: s, theme: a, "data-cdp-provider": i, children: /* @__PURE__ */ p(Se, { children: [
229
- e,
230
- x && /* @__PURE__ */ o(Ee, {})
231
- ] }) }) });
232
- return P(ee) ? v : /* @__PURE__ */ o(oe, { config: d, children: v });
233
- }, H = D(
234
- void 0
235
- ), g = {
236
- appName: "",
237
- appLogoUrl: "",
238
- showCoinbaseFooter: !0,
239
- authMethods: ["email"],
240
- mfa: {
241
- disableAutoPrompt: !1
242
- }
243
- }, Fe = ({
244
- children: e,
245
- config: t,
246
- name: r
247
- }) => {
248
- const {
249
- appName: n = g.appName,
250
- appLogoUrl: s = g.appLogoUrl,
251
- showCoinbaseFooter: a = g.showCoinbaseFooter,
252
- authMethods: f = g.authMethods,
253
- mfa: { disableAutoPrompt: i = g.mfa.disableAutoPrompt } = g.mfa
254
- } = t ?? {}, u = W(f), M = E(() => {
255
- let l = ["email"];
256
- try {
257
- l = JSON.parse(u);
258
- } catch {
259
- }
260
- return {
261
- app: {
262
- appName: n,
263
- appLogoUrl: s,
264
- showCoinbaseFooter: a,
265
- authMethods: Array.isArray(l) && l?.length ? l : g.authMethods,
266
- mfa: {
267
- disableAutoPrompt: i
268
- }
269
- },
270
- name: r
271
- };
272
- }, [n, s, a, u, r, i]);
273
- return /* @__PURE__ */ o(H.Provider, { value: M, children: e });
274
- }, R = () => {
275
- const e = P(H);
276
- if (!e)
277
- throw new Error("useAppConfig must be used within an AppConfigProvider");
278
- return e.app;
279
- }, He = () => {
280
- const e = P(H);
281
- if (!e)
282
- throw new Error("useProviderName must be used within an AppConfigProvider");
283
- return e.name ?? "";
284
- };
285
- export {
286
- De as A,
287
- to as C,
288
- Te as O,
289
- Ce as V,
290
- He as a,
291
- Qe as b,
292
- oo as c,
293
- be as d,
294
- O as e,
295
- U as f,
296
- Se as g,
297
- eo as h,
298
- R as u
299
- };
@@ -1,9 +0,0 @@
1
- import "@coinbase/cdp-hooks";
2
- import "react";
3
- import { totpMethodConfig as t } from "../components/EnrollMfa/methods/totp.js";
4
- const p = {
5
- totp: t
6
- };
7
- export {
8
- p as m
9
- };
@@ -1,9 +0,0 @@
1
- import "@coinbase/cdp-hooks";
2
- import "react";
3
- import { totpMethodConfig as t } from "../components/VerifyMfa/methods/totp.js";
4
- const r = {
5
- totp: t
6
- };
7
- export {
8
- r as m
9
- };