@coinbase/cdp-react 0.0.78 → 0.0.80

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 (164) hide show
  1. package/README.md +5 -0
  2. package/dist/assets/Badge.css +1 -0
  3. package/dist/assets/Banner.css +1 -1
  4. package/dist/assets/CDPReactProvider.css +1 -0
  5. package/dist/assets/CoinbaseFooter.css +1 -1
  6. package/dist/assets/CopyTextField.css +1 -0
  7. package/dist/assets/EnrollMfa.css +1 -0
  8. package/dist/assets/EnrollMfaDescription.css +1 -0
  9. package/dist/assets/EnrollMfaFlow.css +1 -0
  10. package/dist/assets/EnrollMfaFlowBackButton.css +1 -0
  11. package/dist/assets/EnrollMfaItems.css +1 -0
  12. package/dist/assets/EnrollMfaModal.css +1 -0
  13. package/dist/assets/EnrollMfaTitle.css +1 -0
  14. package/dist/assets/ExportWallet.css +1 -1
  15. package/dist/assets/OTPForm.css +1 -1
  16. package/dist/assets/QRCode.css +1 -0
  17. package/dist/assets/ToggleListItem.css +1 -0
  18. package/dist/assets/VerifyMfaDescription.css +1 -0
  19. package/dist/assets/VerifyMfaFlow.css +1 -0
  20. package/dist/assets/VerifyMfaImage.css +1 -0
  21. package/dist/assets/VerifyMfaInline.css +1 -0
  22. package/dist/assets/VerifyMfaTitle.css +1 -0
  23. package/dist/assets/totp.css +1 -0
  24. package/dist/chunks/CDPReactProvider.CIQm4C4z.js +299 -0
  25. package/dist/chunks/{LinkAuthFlow.3HN888DV.js → LinkAuthFlow.BaUSMzGH.js} +1 -1
  26. package/dist/chunks/index.CKQKBoX2.js +9 -0
  27. package/dist/chunks/{index.Bvudzh_y.js → index.C_DV0Ud7.js} +1 -1
  28. package/dist/chunks/index.Dp-lIxM1.js +9 -0
  29. package/dist/components/CDPReactProvider/index.d.ts +4 -1
  30. package/dist/components/CDPReactProvider/index.js +11 -79
  31. package/dist/components/CopyAddress/index.js +24 -60
  32. package/dist/components/EnrollMfa/EnrollMfaDescription.d.ts +6 -0
  33. package/dist/components/EnrollMfa/EnrollMfaDescription.js +21 -0
  34. package/dist/components/EnrollMfa/EnrollMfaFlow.d.ts +12 -0
  35. package/dist/components/EnrollMfa/EnrollMfaFlow.js +46 -0
  36. package/dist/components/EnrollMfa/EnrollMfaFlowBackButton.d.ts +9 -0
  37. package/dist/components/EnrollMfa/EnrollMfaFlowBackButton.js +39 -0
  38. package/dist/components/EnrollMfa/EnrollMfaFlowProvider.d.ts +21 -0
  39. package/dist/components/EnrollMfa/EnrollMfaFlowProvider.js +34 -0
  40. package/dist/components/EnrollMfa/EnrollMfaFooter.d.ts +2 -0
  41. package/dist/components/EnrollMfa/EnrollMfaFooter.js +7 -0
  42. package/dist/components/EnrollMfa/EnrollMfaImage.d.ts +6 -0
  43. package/dist/components/EnrollMfa/EnrollMfaImage.js +19 -0
  44. package/dist/components/EnrollMfa/EnrollMfaItem.d.ts +11 -0
  45. package/dist/components/EnrollMfa/EnrollMfaItem.js +21 -0
  46. package/dist/components/EnrollMfa/EnrollMfaItems.d.ts +9 -0
  47. package/dist/components/EnrollMfa/EnrollMfaItems.js +39 -0
  48. package/dist/components/EnrollMfa/EnrollMfaProvider.d.ts +14 -0
  49. package/dist/components/EnrollMfa/EnrollMfaProvider.js +24 -0
  50. package/dist/components/EnrollMfa/EnrollMfaTitle.d.ts +6 -0
  51. package/dist/components/EnrollMfa/EnrollMfaTitle.js +21 -0
  52. package/dist/components/EnrollMfa/index.d.ts +20 -0
  53. package/dist/components/EnrollMfa/index.js +171 -0
  54. package/dist/components/EnrollMfa/methods/totp.d.ts +6 -0
  55. package/dist/components/EnrollMfa/methods/totp.js +120 -0
  56. package/dist/components/EnrollMfa/types.d.ts +83 -0
  57. package/dist/components/EnrollMfa/types.js +2 -0
  58. package/dist/components/EnrollMfa/useEnrollMfaReducer.d.ts +3 -0
  59. package/dist/components/EnrollMfa/useEnrollMfaReducer.js +111 -0
  60. package/dist/components/EnrollMfaModal/index.d.ts +20 -0
  61. package/dist/components/EnrollMfaModal/index.js +144 -0
  62. package/dist/components/ExportWallet/index.d.ts +2 -1
  63. package/dist/components/ExportWallet/index.js +225 -165
  64. package/dist/components/ExportWalletModal/index.d.ts +7 -4
  65. package/dist/components/ExportWalletModal/index.js +9 -7
  66. package/dist/components/Fund/index.js +5 -5
  67. package/dist/components/FundModal/index.js +14 -14
  68. package/dist/components/LinkAuth/LinkAuthFlow.js +2 -2
  69. package/dist/components/LinkAuth/LinkAuthFlowBackButton.js +2 -2
  70. package/dist/components/LinkAuth/LinkAuthFlowProvider.js +2 -2
  71. package/dist/components/LinkAuth/LinkAuthItem.js +26 -45
  72. package/dist/components/LinkAuth/LinkAuthItems.js +1 -1
  73. package/dist/components/LinkAuth/LinkAuthProvider.js +1 -1
  74. package/dist/components/LinkAuth/index.js +3 -3
  75. package/dist/components/LinkAuth/types.js +1 -1
  76. package/dist/components/LinkAuth/utils.js +1 -1
  77. package/dist/components/LinkAuthModal/index.js +2 -2
  78. package/dist/components/OAuthStatusModal/index.js +1 -1
  79. package/dist/components/SignIn/SignInAuthMethodButtons.js +1 -1
  80. package/dist/components/SignIn/SignInBackButton.js +1 -1
  81. package/dist/components/SignIn/SignInDescription.js +2 -2
  82. package/dist/components/SignIn/SignInForm.js +2 -2
  83. package/dist/components/SignIn/SignInImage.js +5 -5
  84. package/dist/components/SignIn/SignInProvider.js +1 -1
  85. package/dist/components/SignIn/SignInTitle.js +2 -2
  86. package/dist/components/SignIn/flows/SignInWithEmail.js +1 -1
  87. package/dist/components/SignIn/flows/SignInWithOAuth.js +1 -1
  88. package/dist/components/SignIn/flows/SignInWithSms.js +1 -1
  89. package/dist/components/SignIn/index.js +4 -4
  90. package/dist/components/SignIn/types.js +1 -1
  91. package/dist/components/SignIn/useSignInReducer.js +1 -1
  92. package/dist/components/SignInModal/index.js +13 -13
  93. package/dist/components/ThemeProvider/index.d.ts +4 -6
  94. package/dist/components/ThemeProvider/index.js +32 -21
  95. package/dist/components/VerifyMfa/VerifyMfaDescription.d.ts +6 -0
  96. package/dist/components/VerifyMfa/VerifyMfaDescription.js +21 -0
  97. package/dist/components/VerifyMfa/VerifyMfaFlow.d.ts +11 -0
  98. package/dist/components/VerifyMfa/VerifyMfaFlow.js +19 -0
  99. package/dist/components/VerifyMfa/VerifyMfaFooter.d.ts +2 -0
  100. package/dist/components/VerifyMfa/VerifyMfaFooter.js +7 -0
  101. package/dist/components/VerifyMfa/VerifyMfaImage.d.ts +6 -0
  102. package/dist/components/VerifyMfa/VerifyMfaImage.js +21 -0
  103. package/dist/components/VerifyMfa/VerifyMfaProvider.d.ts +15 -0
  104. package/dist/components/VerifyMfa/VerifyMfaProvider.js +28 -0
  105. package/dist/components/VerifyMfa/VerifyMfaTitle.d.ts +6 -0
  106. package/dist/components/VerifyMfa/VerifyMfaTitle.js +21 -0
  107. package/dist/components/VerifyMfa/index.d.ts +16 -0
  108. package/dist/components/VerifyMfa/index.js +20 -0
  109. package/dist/components/VerifyMfa/methods/totp.d.ts +6 -0
  110. package/dist/components/VerifyMfa/methods/totp.js +69 -0
  111. package/dist/components/VerifyMfa/types.d.ts +60 -0
  112. package/dist/components/VerifyMfa/types.js +2 -0
  113. package/dist/components/VerifyMfa/useVerifyMfaReducer.d.ts +2 -0
  114. package/dist/components/VerifyMfa/useVerifyMfaReducer.js +61 -0
  115. package/dist/components/VerifyMfaInline/index.d.ts +40 -0
  116. package/dist/components/VerifyMfaInline/index.js +175 -0
  117. package/dist/components/VerifyMfaModal/index.d.ts +23 -0
  118. package/dist/components/VerifyMfaModal/index.js +19 -0
  119. package/dist/components/forms/AmountInput/index.d.ts +1 -1
  120. package/dist/components/forms/ExchangeAmountInput/index.d.ts +1 -1
  121. package/dist/components/forms/OTPForm/index.d.ts +2 -2
  122. package/dist/components/forms/OTPForm/index.js +81 -64
  123. package/dist/components/ui/Badge/index.d.ts +7 -0
  124. package/dist/components/ui/Badge/index.js +9 -0
  125. package/dist/components/ui/CopyTextField/index.d.ts +10 -0
  126. package/dist/components/ui/CopyTextField/index.js +81 -0
  127. package/dist/components/ui/Modal/index.js +4 -4
  128. package/dist/components/ui/QRCode/QRCodeSvg.d.ts +17 -0
  129. package/dist/components/ui/QRCode/QRCodeSvg.js +57 -0
  130. package/dist/components/ui/QRCode/index.d.ts +5 -0
  131. package/dist/components/ui/QRCode/index.js +31 -0
  132. package/dist/components/ui/QRCode/useCorners.d.ts +1 -0
  133. package/dist/components/ui/QRCode/useCorners.js +72 -0
  134. package/dist/components/ui/QRCode/useDotsPath.d.ts +11 -0
  135. package/dist/components/ui/QRCode/useDotsPath.js +66 -0
  136. package/dist/components/ui/QRCode/useLogo.d.ts +12 -0
  137. package/dist/components/ui/QRCode/useLogo.js +52 -0
  138. package/dist/components/ui/QRCode/useMatrix.d.ts +1 -0
  139. package/dist/components/ui/QRCode/useMatrix.js +17 -0
  140. package/dist/components/ui/ToggleListItem/index.d.ts +15 -0
  141. package/dist/components/ui/ToggleListItem/index.js +52 -0
  142. package/dist/hooks/useKeyExportPostMessage.js +67 -55
  143. package/dist/hooks/useVerifyMfaModal.d.ts +22 -0
  144. package/dist/hooks/useVerifyMfaModal.js +10 -0
  145. package/dist/icons/IconCoinbaseWordmark.js +10 -13
  146. package/dist/icons/IconPinCode.d.ts +2 -0
  147. package/dist/icons/IconPinCode.js +13 -0
  148. package/dist/icons/IconShield.d.ts +2 -0
  149. package/dist/icons/IconShield.js +7 -0
  150. package/dist/icons/IconSmartPhone.d.ts +2 -0
  151. package/dist/icons/IconSmartPhone.js +7 -0
  152. package/dist/icons/index.d.ts +5 -2
  153. package/dist/icons/index.js +22 -16
  154. package/dist/index.d.ts +6 -0
  155. package/dist/index.js +220 -165
  156. package/dist/theme/theme.d.ts +104 -0
  157. package/dist/theme/tokens.d.ts +312 -0
  158. package/dist/theme/tokens.js +70 -0
  159. package/dist/utils/transition.d.ts +2 -2
  160. package/dist/version.d.ts +1 -1
  161. package/dist/version.js +1 -1
  162. package/package.json +9 -7
  163. package/dist/assets/CopyAddress.css +0 -1
  164. package/dist/assets/LinkAuthItem.css +0 -1
@@ -0,0 +1,11 @@
1
+ import { HTMLAttributes, ReactNode } from 'react';
2
+ import { MfaMethod, VerifyMfaState } from './types';
3
+ export interface VerifyMfaFlowProps extends Omit<HTMLAttributes<HTMLElement>, "children"> {
4
+ autoFocus?: boolean;
5
+ children?: (props: {
6
+ step: VerifyMfaState["step"];
7
+ method: MfaMethod;
8
+ Form: ReactNode;
9
+ }) => ReactNode;
10
+ }
11
+ export declare const VerifyMfaFlow: ({ autoFocus, children, className, ...props }: VerifyMfaFlowProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,19 @@
1
+ import { jsx as r } from "react/jsx-runtime";
2
+ import "react";
3
+ import { m as h } from "../../chunks/index.Dp-lIxM1.js";
4
+ import "@coinbase/cdp-hooks";
5
+ import { useVerifyMfaContext as l } from "./VerifyMfaProvider.js";
6
+ import '../../assets/VerifyMfaFlow.css';const u = {
7
+ "method-wrapper": "VerifyMfaFlow-module__method-wrapper___LEPzD"
8
+ }, F = ({
9
+ autoFocus: s = !0,
10
+ children: t,
11
+ className: m = "",
12
+ ...p
13
+ }) => {
14
+ const { state: n, onSuccess: a, onError: i } = l(), { method: o, step: c } = n, f = h[o].content;
15
+ return /* @__PURE__ */ r("div", { className: `${u["method-wrapper"]} ${m}`, ...p, children: /* @__PURE__ */ r(f, { autoFocus: s, step: c, onSuccess: a, onError: i, children: ({ step: d, Content: e }) => t ? t({ step: d, method: o, Form: e }) : e }) });
16
+ };
17
+ export {
18
+ F as VerifyMfaFlow
19
+ };
@@ -0,0 +1,2 @@
1
+ import { HTMLAttributes } from 'react';
2
+ export declare const VerifyMfaFooter: (props: HTMLAttributes<HTMLDivElement>) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,7 @@
1
+ import { jsx as r } from "react/jsx-runtime";
2
+ import "react";
3
+ import { CoinbaseFooter as t } from "../ui/CoinbaseFooter/index.js";
4
+ const f = (o) => /* @__PURE__ */ r(t, { ...o });
5
+ export {
6
+ f as VerifyMfaFooter
7
+ };
@@ -0,0 +1,6 @@
1
+ import { ElementType, HTMLAttributes } from 'react';
2
+ import { VerifyMfaMethodComponentProps } from './types';
3
+ export interface VerifyMfaImageProps extends VerifyMfaMethodComponentProps, HTMLAttributes<HTMLElement> {
4
+ as?: ElementType;
5
+ }
6
+ export declare const VerifyMfaImage: ({ as: Component, children, className, method: methodFromProps, step: stepFromProps, ...props }: VerifyMfaImageProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,21 @@
1
+ import { jsx as o } from "react/jsx-runtime";
2
+ import "react";
3
+ import { m as c } from "../../chunks/index.Dp-lIxM1.js";
4
+ import "@coinbase/cdp-hooks";
5
+ import { useVerifyMfaContext as g } from "./VerifyMfaProvider.js";
6
+ import '../../assets/VerifyMfaImage.css';const d = "VerifyMfaImage-module__image___xftcN", y = {
7
+ image: d
8
+ }, u = ({
9
+ as: s = "div",
10
+ children: t,
11
+ className: a = "",
12
+ method: i,
13
+ step: r,
14
+ ...f
15
+ }) => {
16
+ const { state: e } = g(), n = r || e.step, m = i || e.method, p = c[m].image;
17
+ return /* @__PURE__ */ o(s, { className: `${y.image} ${a}`, ...f, children: t || /* @__PURE__ */ o(p, { step: n, method: m }) });
18
+ };
19
+ export {
20
+ u as VerifyMfaImage
21
+ };
@@ -0,0 +1,15 @@
1
+ import { Dispatch, ReactNode } from 'react';
2
+ import { VerifyMfaAction, VerifyMfaState } from './types';
3
+ export interface VerifyMfaContextValue {
4
+ onSuccess?: (mfaCode: string) => void;
5
+ onError?: (error: Error) => void;
6
+ state: VerifyMfaState;
7
+ dispatch: Dispatch<VerifyMfaAction>;
8
+ }
9
+ export declare const useVerifyMfaContext: () => VerifyMfaContextValue;
10
+ export interface VerifyMfaProviderProps {
11
+ children: ReactNode;
12
+ onSuccess?: (mfaCode: string) => void;
13
+ onError?: (error: Error) => void;
14
+ }
15
+ export declare const VerifyMfaProvider: ({ children, onError, onSuccess }: VerifyMfaProviderProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,28 @@
1
+ import { jsx as n } from "react/jsx-runtime";
2
+ import { createContext as a, useContext as u, useMemo as c } from "react";
3
+ import "@coinbase/cdp-hooks";
4
+ import { useVerifyMfaReducer as m } from "./useVerifyMfaReducer.js";
5
+ const d = {
6
+ method: "totp",
7
+ methods: ["totp"],
8
+ step: "verification",
9
+ mfaCode: "",
10
+ error: null,
11
+ isPending: !1,
12
+ isSuccess: !1
13
+ }, s = a(null), y = () => {
14
+ const e = u(s);
15
+ if (!e)
16
+ throw new Error("useVerifyMfaContext must be used within a VerifyMfaProvider");
17
+ return e;
18
+ }, C = ({ children: e, onError: t, onSuccess: o }) => {
19
+ const [r, i] = m({ ...d }), f = c(
20
+ () => ({ state: r, dispatch: i, onSuccess: o, onError: t }),
21
+ [r, i, o, t]
22
+ );
23
+ return /* @__PURE__ */ n(s.Provider, { value: f, children: e });
24
+ };
25
+ export {
26
+ C as VerifyMfaProvider,
27
+ y as useVerifyMfaContext
28
+ };
@@ -0,0 +1,6 @@
1
+ import { ElementType, HTMLAttributes } from 'react';
2
+ import { VerifyMfaMethodComponentProps } from './types';
3
+ export interface VerifyMfaTitleProps extends VerifyMfaMethodComponentProps, HTMLAttributes<HTMLElement> {
4
+ as?: ElementType;
5
+ }
6
+ export declare const VerifyMfaTitle: ({ as: Component, children, className, method: methodFromProps, step: stepFromProps, ...props }: VerifyMfaTitleProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,21 @@
1
+ import { jsx as s } from "react/jsx-runtime";
2
+ import "react";
3
+ import { m as d } from "../../chunks/index.Dp-lIxM1.js";
4
+ import "@coinbase/cdp-hooks";
5
+ import { useVerifyMfaContext as h } from "./VerifyMfaProvider.js";
6
+ import '../../assets/VerifyMfaTitle.css';const c = "VerifyMfaTitle-module__heading___18nul", l = {
7
+ heading: c
8
+ }, x = ({
9
+ as: i = "h2",
10
+ children: t,
11
+ className: m = "",
12
+ method: n,
13
+ step: r,
14
+ ...a
15
+ }) => {
16
+ const { state: e } = h(), f = r || e.step, o = n || e.method, p = d[o].title;
17
+ return /* @__PURE__ */ s(i, { className: `${l.heading} ${m}`, ...a, children: t || /* @__PURE__ */ s(p, { step: f, method: o }) });
18
+ };
19
+ export {
20
+ x as VerifyMfaTitle
21
+ };
@@ -0,0 +1,16 @@
1
+ import { APIError } from '@coinbase/cdp-hooks';
2
+ import { HTMLAttributes, ReactNode } from 'react';
3
+ import { VerifyMfaAction, VerifyMfaState } from './types';
4
+ import { VerifyMfaDescription, VerifyMfaDescriptionProps } from './VerifyMfaDescription';
5
+ import { VerifyMfaFlow, VerifyMfaFlowProps } from './VerifyMfaFlow';
6
+ import { VerifyMfaFooter } from './VerifyMfaFooter';
7
+ import { VerifyMfaImage, VerifyMfaImageProps } from './VerifyMfaImage';
8
+ import { useVerifyMfaContext, VerifyMfaContextValue } from './VerifyMfaProvider';
9
+ import { VerifyMfaTitle, VerifyMfaTitleProps } from './VerifyMfaTitle';
10
+ interface VerifyMfaProps extends Omit<HTMLAttributes<HTMLDivElement>, "children" | "onSubmit" | "onError"> {
11
+ children?: ReactNode | ((state: VerifyMfaState) => ReactNode);
12
+ onSuccess?: (mfaCode: string) => void;
13
+ onError?: (error: APIError | Error) => void;
14
+ }
15
+ declare const VerifyMfa: ({ onSuccess, onError, ...props }: VerifyMfaProps) => import("react/jsx-runtime").JSX.Element;
16
+ export { VerifyMfa, VerifyMfaDescription, VerifyMfaFooter, VerifyMfaFlow, VerifyMfaImage, VerifyMfaTitle, useVerifyMfaContext, type VerifyMfaProps, type VerifyMfaDescriptionProps, type VerifyMfaFlowProps, type VerifyMfaImageProps, type VerifyMfaTitleProps, type VerifyMfaAction, type VerifyMfaState, type VerifyMfaContextValue, };
@@ -0,0 +1,20 @@
1
+ import "react/jsx-runtime";
2
+ import "@coinbase/cdp-hooks";
3
+ import "../../chunks/useSendComponentCallOnce.BHZMuo6E.js";
4
+ import "react";
5
+ import { V as m } from "../../chunks/CDPReactProvider.CIQm4C4z.js";
6
+ import { VerifyMfaDescription as a } from "./VerifyMfaDescription.js";
7
+ import { VerifyMfaFlow as V } from "./VerifyMfaFlow.js";
8
+ import { VerifyMfaFooter as M } from "./VerifyMfaFooter.js";
9
+ import { VerifyMfaImage as l } from "./VerifyMfaImage.js";
10
+ import { useVerifyMfaContext as F } from "./VerifyMfaProvider.js";
11
+ import { VerifyMfaTitle as g } from "./VerifyMfaTitle.js";
12
+ export {
13
+ m as VerifyMfa,
14
+ a as VerifyMfaDescription,
15
+ V as VerifyMfaFlow,
16
+ M as VerifyMfaFooter,
17
+ l as VerifyMfaImage,
18
+ g as VerifyMfaTitle,
19
+ F as useVerifyMfaContext
20
+ };
@@ -0,0 +1,6 @@
1
+ import { MfaMethodConfig, MfaMethodContentProps, VerifyMfaMethodComponentProps } from '../types';
2
+ export declare const TotpContent: ({ autoFocus, onError, onSuccess, children, }: MfaMethodContentProps) => import("react/jsx-runtime").JSX.Element;
3
+ export declare const TotpTitle: (_props: VerifyMfaMethodComponentProps) => import("react/jsx-runtime").JSX.Element;
4
+ export declare const TotpImage: (_props: VerifyMfaMethodComponentProps) => import("react/jsx-runtime").JSX.Element;
5
+ export declare const TotpDescription: (_props: VerifyMfaMethodComponentProps) => import("react/jsx-runtime").JSX.Element;
6
+ export declare const totpMethodConfig: MfaMethodConfig;
@@ -0,0 +1,69 @@
1
+ import { jsx as o, Fragment as a } from "react/jsx-runtime";
2
+ import { useIsInitialized as g, useCurrentUser as _, useInitiateMfaVerification as E, useSubmitMfaVerification as S } from "@coinbase/cdp-hooks";
3
+ import { useRef as I, useEffect as T } from "react";
4
+ import { OTPForm as F } from "../../forms/OTPForm/index.js";
5
+ import { Badge as A } from "../../ui/Badge/index.js";
6
+ import { IconSmartPhone as U } from "../../../icons/IconSmartPhone.js";
7
+ import { useVerifyMfaContext as V } from "../VerifyMfaProvider.js";
8
+ const v = ({
9
+ autoFocus: r = !0,
10
+ onError: u,
11
+ onSuccess: C,
12
+ children: s
13
+ }) => {
14
+ const { isInitialized: c } = g(), { currentUser: M } = _(), { state: e, dispatch: i } = V(), { initiateMfaVerification: f } = E(), p = I(!1), { submitMfaVerification: l } = S();
15
+ T(() => {
16
+ if (!c || p.current) return;
17
+ requestAnimationFrame(async () => {
18
+ p.current = !0;
19
+ try {
20
+ await f({ mfaMethod: "totp" });
21
+ } catch (t) {
22
+ console.error("Failed to initiate MFA verification", t);
23
+ }
24
+ });
25
+ }, [c, f, M]);
26
+ const h = (n) => {
27
+ i({ type: "SET_MFA_CODE", payload: { mfaCode: n } });
28
+ }, y = async (n) => {
29
+ n.preventDefault(), i({ type: "SUBMIT_MFA_CODE", payload: { mfaCode: e.mfaCode } });
30
+ try {
31
+ const t = e.mfaCode;
32
+ await l({ mfaMethod: "totp", mfaCode: t }), i({ type: "SUBMIT_MFA_CODE_SUCCESS" }), C?.(t);
33
+ } catch (t) {
34
+ const m = t instanceof Error ? t : new Error(typeof t == "string" ? t : "Verification failed");
35
+ u?.(m), i({
36
+ type: "SUBMIT_MFA_CODE_FAILURE",
37
+ payload: {
38
+ error: m.message
39
+ }
40
+ });
41
+ }
42
+ }, d = /* @__PURE__ */ o(
43
+ F,
44
+ {
45
+ autoFocus: r,
46
+ otp: e.mfaCode,
47
+ error: e.error || void 0,
48
+ isPending: e.isPending,
49
+ onOTPChange: h,
50
+ onSubmit: y,
51
+ passwordLength: 6,
52
+ resendCountdown: null,
53
+ successMessage: e.isSuccess ? "Verified!" : void 0
54
+ }
55
+ );
56
+ return s ? /* @__PURE__ */ o(a, { children: s({ step: e.step, Content: d }) }) : d;
57
+ }, D = (r) => /* @__PURE__ */ o(a, { children: "Enter verification code" }), O = (r) => /* @__PURE__ */ o(A, { variant: "secondary", children: /* @__PURE__ */ o(U, {}) }), w = (r) => /* @__PURE__ */ o(a, { children: "Enter the 6-digit code from your authenticator app." }), j = {
58
+ content: v,
59
+ title: D,
60
+ description: w,
61
+ image: O
62
+ };
63
+ export {
64
+ v as TotpContent,
65
+ w as TotpDescription,
66
+ O as TotpImage,
67
+ D as TotpTitle,
68
+ j as totpMethodConfig
69
+ };
@@ -0,0 +1,60 @@
1
+ import { APIError } from '@coinbase/cdp-hooks';
2
+ import { FC, ReactNode } from 'react';
3
+ import { MfaMethod } from '../EnrollMfa/types';
4
+ export { type MfaMethod };
5
+ export interface VerifyMfaMethodComponentProps {
6
+ method?: MfaMethod;
7
+ step?: VerifyMfaState["step"];
8
+ }
9
+ export interface VerifyMfaState {
10
+ method: MfaMethod;
11
+ methods: MfaMethod[];
12
+ step: "verification";
13
+ mfaCode: string;
14
+ error: string | APIError | null;
15
+ isPending: boolean;
16
+ isSuccess: boolean;
17
+ }
18
+ export type VerifyMfaAction = {
19
+ type: "SET_METHOD";
20
+ payload: {
21
+ method: MfaMethod;
22
+ };
23
+ } | {
24
+ type: "SET_MFA_CODE";
25
+ payload: {
26
+ mfaCode: string;
27
+ };
28
+ } | {
29
+ type: "SUBMIT_MFA_CODE";
30
+ payload: {
31
+ mfaCode: string;
32
+ };
33
+ } | {
34
+ type: "SUBMIT_MFA_CODE_SUCCESS";
35
+ } | {
36
+ type: "SUBMIT_MFA_CODE_FAILURE";
37
+ payload: {
38
+ error: string | APIError;
39
+ };
40
+ } | {
41
+ type: "CLEAR_ERROR";
42
+ } | {
43
+ type: "RESET_STATE";
44
+ };
45
+ export interface MfaMethodContentProps {
46
+ step: VerifyMfaState["step"];
47
+ autoFocus?: boolean;
48
+ onError?: (error: Error) => void;
49
+ onSuccess?: (mfaCode: string) => void;
50
+ children?: (props: {
51
+ step: VerifyMfaState["step"];
52
+ Content: ReactNode;
53
+ }) => ReactNode;
54
+ }
55
+ export interface MfaMethodConfig {
56
+ content: FC<MfaMethodContentProps>;
57
+ description: FC<VerifyMfaMethodComponentProps>;
58
+ image: FC<VerifyMfaMethodComponentProps>;
59
+ title: FC<VerifyMfaMethodComponentProps>;
60
+ }
@@ -0,0 +1,2 @@
1
+ import "@coinbase/cdp-hooks";
2
+ import "react";
@@ -0,0 +1,2 @@
1
+ import { VerifyMfaAction, VerifyMfaState } from './types';
2
+ export declare const useVerifyMfaReducer: (initialState: VerifyMfaState) => [VerifyMfaState, import('react').ActionDispatch<[action: VerifyMfaAction]>];
@@ -0,0 +1,61 @@
1
+ import { useReducer as o } from "react";
2
+ import "@coinbase/cdp-hooks";
3
+ function n(e, r) {
4
+ switch (r.type) {
5
+ case "SET_METHOD":
6
+ return {
7
+ ...e,
8
+ method: r.payload.method,
9
+ mfaCode: "",
10
+ error: null
11
+ };
12
+ case "SET_MFA_CODE":
13
+ return {
14
+ ...e,
15
+ mfaCode: r.payload.mfaCode,
16
+ error: null
17
+ };
18
+ case "SUBMIT_MFA_CODE":
19
+ return {
20
+ ...e,
21
+ isPending: !0,
22
+ mfaCode: r.payload.mfaCode,
23
+ error: null
24
+ };
25
+ case "SUBMIT_MFA_CODE_SUCCESS":
26
+ return {
27
+ ...e,
28
+ isPending: !1,
29
+ isSuccess: !0,
30
+ error: null
31
+ };
32
+ case "SUBMIT_MFA_CODE_FAILURE":
33
+ return {
34
+ ...e,
35
+ isPending: !1,
36
+ isSuccess: !1,
37
+ error: r.payload.error
38
+ };
39
+ case "CLEAR_ERROR":
40
+ return {
41
+ ...e,
42
+ error: null
43
+ };
44
+ case "RESET_STATE":
45
+ return {
46
+ method: e.method,
47
+ methods: e.methods,
48
+ step: "verification",
49
+ mfaCode: "",
50
+ error: null,
51
+ isPending: !1,
52
+ isSuccess: !1
53
+ };
54
+ default:
55
+ throw new Error("Unknown action type");
56
+ }
57
+ }
58
+ const d = (e) => o(n, e);
59
+ export {
60
+ d as useVerifyMfaReducer
61
+ };
@@ -0,0 +1,40 @@
1
+ import { ButtonHTMLAttributes, HTMLAttributes, ReactNode } from 'react';
2
+ import { ButtonSize, ButtonVariant } from '../../theme/theme';
3
+ type VerifyMfaInlineView = "verify" | "content";
4
+ type VerifyMfaInlineDirection = "left" | "right";
5
+ interface VerifyMfaInlineContextValue {
6
+ view: VerifyMfaInlineView;
7
+ goToVerify: () => void;
8
+ goToContent: (direction?: VerifyMfaInlineDirection) => void;
9
+ goBack: () => void;
10
+ }
11
+ declare const useVerifyMfaInlineContext: () => VerifyMfaInlineContextValue;
12
+ interface VerifyMfaInlineProps extends HTMLAttributes<HTMLDivElement> {
13
+ children: ReactNode;
14
+ verifyFirst?: boolean;
15
+ onVerified?: () => void;
16
+ onCancel?: () => void;
17
+ successDelay?: number;
18
+ className?: string;
19
+ }
20
+ interface VerifyMfaInlineFlowProps {
21
+ children: ReactNode | ((props: {
22
+ view: "verify";
23
+ Content: ReactNode;
24
+ } | {
25
+ view: "content";
26
+ Content: null;
27
+ }) => ReactNode);
28
+ className?: string;
29
+ animateHeight?: boolean;
30
+ autoFocus?: boolean;
31
+ transition?: "slide" | "fade";
32
+ }
33
+ interface VerifyMfaInlineBackButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
34
+ size?: ButtonSize;
35
+ variant?: ButtonVariant;
36
+ }
37
+ declare const VerifyMfaInlineBackButton: ({ children, onClick, size, variant, ["aria-label"]: ariaLabel, ...props }: VerifyMfaInlineBackButtonProps) => import("react/jsx-runtime").JSX.Element | null;
38
+ declare const VerifyMfaInlineFlow: ({ children, className, animateHeight, autoFocus, transition, }: VerifyMfaInlineFlowProps) => import("react/jsx-runtime").JSX.Element;
39
+ declare const VerifyMfaInline: ({ children, verifyFirst, onVerified, onCancel, successDelay, className, ...props }: VerifyMfaInlineProps) => import("react/jsx-runtime").JSX.Element;
40
+ export { VerifyMfaInline, VerifyMfaInlineBackButton, VerifyMfaInlineFlow, useVerifyMfaInlineContext, type VerifyMfaInlineBackButtonProps, type VerifyMfaInlineContextValue, type VerifyMfaInlineDirection, type VerifyMfaInlineFlowProps, type VerifyMfaInlineProps, type VerifyMfaInlineView, };
@@ -0,0 +1,175 @@
1
+ import { jsx as n, jsxs as R } from "react/jsx-runtime";
2
+ import { isMfaRequired as E } from "@coinbase/cdp-core";
3
+ import { useCancelMfaVerification as j, useIsInitialized as q, useRegisterMfaListener as F } from "@coinbase/cdp-hooks";
4
+ import { u as L } from "../../chunks/useSendComponentCallOnce.BHZMuo6E.js";
5
+ import { createContext as A, useMemo as h, useRef as x, useState as b, useCallback as w, useContext as O } from "react";
6
+ import { c as P } from "../../chunks/lite.1fxw3LjI.js";
7
+ import { Button as W } from "../ui/Button/index.js";
8
+ import { SwitchFadeTransition as X } from "../ui/SwitchFadeTransition/index.js";
9
+ import { SwitchSlideTransition as Y } from "../ui/SwitchSlideTransition/index.js";
10
+ import { V as G } from "../../chunks/CDPReactProvider.CIQm4C4z.js";
11
+ import { IconArrowLeft as J } from "../../icons/IconArrowLeft.js";
12
+ import "../../theme/theme.js";
13
+ import { VerifyMfaImage as Q } from "../VerifyMfa/VerifyMfaImage.js";
14
+ import { VerifyMfaTitle as U } from "../VerifyMfa/VerifyMfaTitle.js";
15
+ import { VerifyMfaDescription as Z } from "../VerifyMfa/VerifyMfaDescription.js";
16
+ import { VerifyMfaFlow as $ } from "../VerifyMfa/VerifyMfaFlow.js";
17
+ import '../../assets/VerifyMfaInline.css';const H = "VerifyMfaInline-module__icon___pezMX", C = {
18
+ "verify-mfa-inline": "VerifyMfaInline-module__verify-mfa-inline___mn38o",
19
+ icon: H,
20
+ "mfa-verification": "VerifyMfaInline-module__mfa-verification___WyY76",
21
+ "mfa-verification-content": "VerifyMfaInline-module__mfa-verification-content___M4fq0",
22
+ "mfa-verification-form": "VerifyMfaInline-module__mfa-verification-form___8h2u-"
23
+ }, z = A(null), S = () => {
24
+ const e = O(z);
25
+ if (!e)
26
+ throw new Error("VerifyMfaInline compound components must be used within VerifyMfaInline");
27
+ return e;
28
+ }, ve = () => {
29
+ const { view: e, goToContent: t, goToVerify: i, goBack: o } = S();
30
+ return h(
31
+ () => ({ view: e, goToVerify: i, goToContent: t, goBack: o }),
32
+ [e, i, t, o]
33
+ );
34
+ }, Ve = ({
35
+ children: e,
36
+ onClick: t,
37
+ size: i = "md",
38
+ variant: o = "transparentSecondary",
39
+ ["aria-label"]: d = "Back",
40
+ ...s
41
+ }) => {
42
+ const { goBack: M, verifyFirst: y, needsMfa: l, view: r } = S(), m = (f) => {
43
+ t?.(f), M();
44
+ };
45
+ return y || !l || r === "content" ? null : /* @__PURE__ */ n(
46
+ W,
47
+ {
48
+ type: "button",
49
+ "aria-label": d,
50
+ onClick: m,
51
+ size: i,
52
+ variant: o,
53
+ ...s,
54
+ children: e || /* @__PURE__ */ n(J, { className: C.icon })
55
+ }
56
+ );
57
+ }, N = ({ onSuccess: e }) => /* @__PURE__ */ n(G, { className: C["mfa-verification"], onSuccess: e, children: /* @__PURE__ */ R("div", { className: C["mfa-verification-content"], children: [
58
+ /* @__PURE__ */ n(Q, {}),
59
+ /* @__PURE__ */ R("div", { children: [
60
+ /* @__PURE__ */ n(U, {}),
61
+ /* @__PURE__ */ n(Z, {})
62
+ ] }),
63
+ /* @__PURE__ */ n($, { className: C["mfa-verification-form"] })
64
+ ] }) }), Me = ({
65
+ children: e,
66
+ className: t = "",
67
+ animateHeight: i = !0,
68
+ autoFocus: o = !0,
69
+ transition: d = "slide"
70
+ }) => {
71
+ const {
72
+ goToContent: s,
73
+ initialView: M,
74
+ direction: y,
75
+ transitionRef: l,
76
+ verifyFirst: r,
77
+ onVerified: m,
78
+ successDelay: f
79
+ } = S(), _ = w(() => {
80
+ m?.(), r && (f > 0 ? setTimeout(() => s(), f) : s());
81
+ }, [s, r, m, f]), v = M === "verify" ? ["verify", "content"] : ["content", "verify"], I = typeof e == "function", V = ({ itemKey: u, ...p }) => {
82
+ let c = null;
83
+ return I ? c = e(
84
+ u === "content" ? { view: "content", Content: null } : { view: u, Content: u === "verify" ? /* @__PURE__ */ n(N, { onSuccess: _ }) : void 0 }
85
+ ) : c = u === "verify" ? /* @__PURE__ */ n(N, { onSuccess: _ }) : e, /* @__PURE__ */ n("div", { ...p, children: c });
86
+ };
87
+ return d === "fade" ? /* @__PURE__ */ n(
88
+ X,
89
+ {
90
+ autoFocus: o,
91
+ animateHeight: i,
92
+ items: v,
93
+ initialEntered: !0,
94
+ transitionRef: l,
95
+ className: t,
96
+ children: V
97
+ }
98
+ ) : /* @__PURE__ */ n(
99
+ Y,
100
+ {
101
+ autoFocus: o,
102
+ animateHeight: i,
103
+ items: v,
104
+ initialEntered: !0,
105
+ direction: y,
106
+ transitionRef: l,
107
+ className: t,
108
+ children: V
109
+ }
110
+ );
111
+ }, _e = ({
112
+ children: e,
113
+ verifyFirst: t = !0,
114
+ onVerified: i,
115
+ onCancel: o,
116
+ successDelay: d = 500,
117
+ className: s = "",
118
+ ...M
119
+ }) => {
120
+ L("verify_mfa_inline");
121
+ const { cancelMfaVerification: y } = j(), { isInitialized: l } = q(), r = h(() => l ? E() : !1, [l]), m = x(null), f = h(() => r && t ? "verify" : "content", [r, t]), [_, v] = b(f), [I, V] = b("left"), u = x(null), p = x(f), c = w((a) => {
122
+ p.current !== a && (p.current = a, u.current?.transition.toggle(a));
123
+ }, []), g = w(
124
+ (a = "left") => {
125
+ V(a), v("verify"), c("verify");
126
+ },
127
+ [c]
128
+ ), T = w(
129
+ (a = "left") => {
130
+ V(a), v("content"), c("content");
131
+ },
132
+ [c]
133
+ ), k = w(() => {
134
+ const a = p.current === "verify", B = a ? "content" : "verify";
135
+ V("right"), v(B), c(B), a && (y(), o?.());
136
+ }, [c, o, y]);
137
+ F(() => g(), {
138
+ scope: m,
139
+ enabled: r
140
+ });
141
+ const D = h(
142
+ () => ({
143
+ view: _,
144
+ goToVerify: g,
145
+ goToContent: T,
146
+ goBack: k,
147
+ needsMfa: r,
148
+ verifyFirst: t,
149
+ initialView: f,
150
+ direction: I,
151
+ transitionRef: u,
152
+ onVerified: i,
153
+ successDelay: d
154
+ }),
155
+ [
156
+ _,
157
+ g,
158
+ T,
159
+ k,
160
+ r,
161
+ t,
162
+ f,
163
+ I,
164
+ i,
165
+ d
166
+ ]
167
+ );
168
+ return /* @__PURE__ */ n(z.Provider, { value: D, children: /* @__PURE__ */ n("div", { ref: m, className: P(C["verify-mfa-inline"], s), ...M, children: e }) });
169
+ };
170
+ export {
171
+ _e as VerifyMfaInline,
172
+ Ve as VerifyMfaInlineBackButton,
173
+ Me as VerifyMfaInlineFlow,
174
+ ve as useVerifyMfaInlineContext
175
+ };
@@ -0,0 +1,23 @@
1
+ import { ReactNode } from 'react';
2
+ import { ButtonProps } from '../ui/Button';
3
+ import { ModalContentProps } from '../ui/Modal';
4
+ import { VerifyMfaProps } from '../VerifyMfa';
5
+ interface VerifyMfaModalTriggerProps extends Partial<Pick<ButtonProps, "className" | "fullWidth" | "size" | "style" | "variant">> {
6
+ children?: ReactNode;
7
+ label?: ReactNode;
8
+ }
9
+ interface VerifyMfaModalProps {
10
+ children?: ReactNode;
11
+ open?: boolean;
12
+ setIsOpen?: (value: boolean) => void;
13
+ onCancel?: () => void;
14
+ onError?: (error: Error) => void;
15
+ onSuccess?: (mfaCode: string) => void;
16
+ }
17
+ interface VerifyMfaModalContentProps extends Omit<ModalContentProps, "children"> {
18
+ children?: VerifyMfaProps["children"];
19
+ }
20
+ declare const VerifyMfaModalTrigger: ({ children, className, label, ...props }: VerifyMfaModalTriggerProps) => import("react/jsx-runtime").JSX.Element;
21
+ declare const VerifyMfaModalContent: ({ children, ...props }: VerifyMfaModalContentProps) => import("react/jsx-runtime").JSX.Element;
22
+ declare const VerifyMfaModal: ({ children, open, setIsOpen, onCancel, onError, onSuccess, }: VerifyMfaModalProps) => import("react/jsx-runtime").JSX.Element;
23
+ export { VerifyMfaModal, VerifyMfaModalContent, VerifyMfaModalTrigger, type VerifyMfaModalProps, type VerifyMfaModalContentProps, type VerifyMfaModalTriggerProps, };
@@ -0,0 +1,19 @@
1
+ import "react/jsx-runtime";
2
+ import "../../chunks/useSendComponentCallOnce.BHZMuo6E.js";
3
+ import "react";
4
+ import "../../chunks/lite.1fxw3LjI.js";
5
+ import { d as g, e as n, f as x } from "../../chunks/CDPReactProvider.CIQm4C4z.js";
6
+ import "../ui/Button/index.js";
7
+ import "../ui/Modal/index.js";
8
+ import "../../icons/IconXMark.js";
9
+ import "../../utils/childrenHasComponent.js";
10
+ import "../VerifyMfa/VerifyMfaImage.js";
11
+ import "../VerifyMfa/VerifyMfaTitle.js";
12
+ import "../VerifyMfa/VerifyMfaDescription.js";
13
+ import "../VerifyMfa/VerifyMfaFlow.js";
14
+ import "../VerifyMfa/VerifyMfaFooter.js";
15
+ export {
16
+ g as VerifyMfaModal,
17
+ n as VerifyMfaModalContent,
18
+ x as VerifyMfaModalTrigger
19
+ };
@@ -1,3 +1,3 @@
1
1
  import { InputHTMLAttributes } from 'react';
2
2
  import { AmountInputProps } from './types';
3
- export declare const AmountInput: import('react').ForwardRefExoticComponent<AmountInputProps & Omit<InputHTMLAttributes<HTMLInputElement>, "type" | "value" | "max" | "min" | "onChange" | "inputMode"> & import('react').RefAttributes<HTMLInputElement>>;
3
+ export declare const AmountInput: import('react').ForwardRefExoticComponent<AmountInputProps & Omit<InputHTMLAttributes<HTMLInputElement>, "type" | "value" | "inputMode" | "onChange" | "max" | "min"> & import('react').RefAttributes<HTMLInputElement>>;