@coinbase/cdp-react 0.0.86 → 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.
- package/dist/assets/CDPReactProvider.css +1 -1
- package/dist/assets/EnrollMfaFlow.css +1 -1
- package/dist/assets/VerifyMfaFlow.css +1 -1
- package/dist/assets/VerifyMfaFlowBackButton.css +1 -0
- package/dist/assets/VerifyMfaInline.css +1 -1
- package/dist/assets/VerifyMfaItem.css +1 -0
- package/dist/assets/VerifyMfaItems.css +1 -0
- package/dist/assets/sms.css +1 -0
- package/dist/chunks/CDPReactProvider.C38bKQ2x.js +337 -0
- package/dist/chunks/{LinkAuthFlow.BaUSMzGH.js → LinkAuthFlow.CLubKoY0.js} +13 -13
- package/dist/chunks/{index.C_DV0Ud7.js → index.BN39qScu.js} +1 -1
- package/dist/chunks/index.BX4k-ruQ.js +12 -0
- package/dist/chunks/index.Bgx0-QLY.js +12 -0
- package/dist/components/CDPReactProvider/index.js +1 -1
- package/dist/components/EnrollMfa/EnrollMfaDescription.js +4 -3
- package/dist/components/EnrollMfa/EnrollMfaFlow.js +27 -26
- package/dist/components/EnrollMfa/EnrollMfaFlowBackButton.js +7 -6
- package/dist/components/EnrollMfa/EnrollMfaFlowProvider.d.ts +1 -1
- package/dist/components/EnrollMfa/EnrollMfaFlowProvider.js +5 -4
- package/dist/components/EnrollMfa/EnrollMfaImage.js +7 -6
- package/dist/components/EnrollMfa/EnrollMfaItem.js +7 -6
- package/dist/components/EnrollMfa/EnrollMfaItems.js +28 -25
- package/dist/components/EnrollMfa/EnrollMfaProvider.js +22 -17
- package/dist/components/EnrollMfa/EnrollMfaTitle.js +8 -7
- package/dist/components/EnrollMfa/index.js +134 -128
- package/dist/components/EnrollMfa/methods/sms.d.ts +6 -0
- package/dist/components/EnrollMfa/methods/sms.js +148 -0
- package/dist/components/EnrollMfa/methods/totp.js +24 -19
- package/dist/components/EnrollMfa/types.d.ts +17 -5
- package/dist/components/EnrollMfa/types.js +1 -0
- package/dist/components/EnrollMfa/useEnrollMfaReducer.js +51 -38
- package/dist/components/EnrollMfaModal/index.js +1 -1
- package/dist/components/ExportWallet/index.js +109 -101
- package/dist/components/ExportWalletModal/index.js +1 -1
- package/dist/components/Fund/index.js +1 -1
- package/dist/components/FundModal/index.js +1 -1
- package/dist/components/LinkAuth/LinkAuthFlow.js +2 -2
- package/dist/components/LinkAuth/LinkAuthFlowBackButton.js +2 -2
- package/dist/components/LinkAuth/LinkAuthFlowProvider.js +2 -2
- package/dist/components/LinkAuth/LinkAuthItem.js +1 -1
- package/dist/components/LinkAuth/LinkAuthItems.js +1 -1
- package/dist/components/LinkAuth/LinkAuthProvider.js +1 -1
- package/dist/components/LinkAuth/index.js +3 -3
- package/dist/components/LinkAuth/types.js +1 -1
- package/dist/components/LinkAuth/utils.js +1 -1
- package/dist/components/LinkAuthModal/index.js +2 -2
- package/dist/components/OAuthStatusModal/index.js +1 -1
- package/dist/components/SignIn/SignInAuthMethodButtons.js +1 -1
- package/dist/components/SignIn/SignInBackButton.js +12 -12
- package/dist/components/SignIn/SignInDescription.js +2 -2
- package/dist/components/SignIn/SignInForm.js +2 -2
- package/dist/components/SignIn/SignInImage.js +1 -1
- package/dist/components/SignIn/SignInProvider.js +1 -1
- package/dist/components/SignIn/SignInTitle.js +2 -2
- package/dist/components/SignIn/flows/SignInWithEmail.js +1 -1
- package/dist/components/SignIn/flows/SignInWithOAuth.js +1 -1
- package/dist/components/SignIn/flows/SignInWithSms.js +74 -84
- package/dist/components/SignIn/index.js +1 -1
- package/dist/components/SignIn/types.d.ts +2 -0
- package/dist/components/SignIn/types.js +1 -1
- package/dist/components/SignIn/useSignInReducer.js +20 -6
- package/dist/components/SignInModal/index.js +1 -1
- package/dist/components/VerifyMfa/VerifyMfaDescription.d.ts +1 -1
- package/dist/components/VerifyMfa/VerifyMfaDescription.js +24 -14
- package/dist/components/VerifyMfa/VerifyMfaFlow.d.ts +5 -4
- package/dist/components/VerifyMfa/VerifyMfaFlow.js +52 -13
- package/dist/components/VerifyMfa/VerifyMfaFlowBackButton.d.ts +9 -0
- package/dist/components/VerifyMfa/VerifyMfaFlowBackButton.js +40 -0
- package/dist/components/VerifyMfa/VerifyMfaFlowProvider.d.ts +23 -0
- package/dist/components/VerifyMfa/VerifyMfaFlowProvider.js +37 -0
- package/dist/components/VerifyMfa/VerifyMfaImage.d.ts +1 -1
- package/dist/components/VerifyMfa/VerifyMfaImage.js +25 -13
- package/dist/components/VerifyMfa/VerifyMfaItem.d.ts +10 -0
- package/dist/components/VerifyMfa/VerifyMfaItem.js +27 -0
- package/dist/components/VerifyMfa/VerifyMfaItems.d.ts +9 -0
- package/dist/components/VerifyMfa/VerifyMfaItems.js +31 -0
- package/dist/components/VerifyMfa/VerifyMfaProvider.js +27 -14
- package/dist/components/VerifyMfa/VerifyMfaTitle.d.ts +1 -1
- package/dist/components/VerifyMfa/VerifyMfaTitle.js +23 -13
- package/dist/components/VerifyMfa/index.d.ts +6 -2
- package/dist/components/VerifyMfa/index.js +23 -14
- package/dist/components/VerifyMfa/methods/sms.d.ts +6 -0
- package/dist/components/VerifyMfa/methods/sms.js +90 -0
- package/dist/components/VerifyMfa/methods/totp.js +40 -39
- package/dist/components/VerifyMfa/types.d.ts +21 -2
- package/dist/components/VerifyMfa/types.js +1 -0
- package/dist/components/VerifyMfa/useVerifyMfaReducer.d.ts +2 -1
- package/dist/components/VerifyMfa/useVerifyMfaReducer.js +29 -4
- package/dist/components/VerifyMfaInline/index.d.ts +1 -1
- package/dist/components/VerifyMfaInline/index.js +133 -116
- package/dist/components/VerifyMfaModal/index.js +7 -5
- package/dist/components/ui/SwitchTransition/index.js +3 -3
- package/dist/hooks/usePhoneNumberState.d.ts +15 -0
- package/dist/hooks/usePhoneNumberState.js +39 -0
- package/dist/hooks/useTransitionMap.js +24 -22
- package/dist/hooks/useVerifyMfaModal.js +1 -1
- package/dist/index.js +59 -51
- package/dist/utils/transition.d.ts +3 -3
- package/dist/utils/transition.js +21 -20
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +6 -6
- package/dist/chunks/CDPReactProvider.CIQm4C4z.js +0 -299
- package/dist/chunks/index.CKQKBoX2.js +0 -9
- package/dist/chunks/index.Dp-lIxM1.js +0 -9
|
@@ -1,21 +1,33 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as t } from "react/jsx-runtime";
|
|
2
2
|
import "react";
|
|
3
|
-
import {
|
|
3
|
+
import { Badge as l } from "../ui/Badge/index.js";
|
|
4
|
+
import { IconShield as g } from "../../icons/IconShield.js";
|
|
5
|
+
import { m as d } from "../../chunks/index.BX4k-ruQ.js";
|
|
4
6
|
import "@coinbase/cdp-hooks";
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
import "@coinbase/cdp-core";
|
|
8
|
+
import { useVerifyMfaContext as h } from "./VerifyMfaProvider.js";
|
|
9
|
+
import '../../assets/VerifyMfaImage.css';const y = "VerifyMfaImage-module__image___xftcN", u = {
|
|
10
|
+
image: y
|
|
11
|
+
}, $ = ({
|
|
9
12
|
as: s = "div",
|
|
10
|
-
children:
|
|
13
|
+
children: o,
|
|
11
14
|
className: a = "",
|
|
12
|
-
method:
|
|
13
|
-
step:
|
|
14
|
-
...
|
|
15
|
+
method: n,
|
|
16
|
+
step: f,
|
|
17
|
+
...p
|
|
15
18
|
}) => {
|
|
16
|
-
const { state:
|
|
17
|
-
|
|
19
|
+
const { state: m } = h(), i = f || m.step, r = n || m.method;
|
|
20
|
+
let e;
|
|
21
|
+
if (o)
|
|
22
|
+
e = o;
|
|
23
|
+
else if (i === "list")
|
|
24
|
+
e = /* @__PURE__ */ t(l, { variant: "primary", children: /* @__PURE__ */ t(g, {}) });
|
|
25
|
+
else {
|
|
26
|
+
const c = d[r].image;
|
|
27
|
+
e = /* @__PURE__ */ t(c, { step: i, method: r });
|
|
28
|
+
}
|
|
29
|
+
return e ? /* @__PURE__ */ t(s, { className: `${u.image} ${a}`, ...p, children: e }) : null;
|
|
18
30
|
};
|
|
19
31
|
export {
|
|
20
|
-
|
|
32
|
+
$ as VerifyMfaImage
|
|
21
33
|
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { MouseEventHandler, ReactNode } from 'react';
|
|
2
|
+
import { MfaMethod } from './types';
|
|
3
|
+
export interface VerifyMfaItemProps {
|
|
4
|
+
method: MfaMethod;
|
|
5
|
+
icon?: ReactNode;
|
|
6
|
+
label: string;
|
|
7
|
+
onSelect: MouseEventHandler<HTMLButtonElement>;
|
|
8
|
+
}
|
|
9
|
+
declare const VerifyMfaItem: ({ icon, label, onSelect }: VerifyMfaItemProps) => import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export { VerifyMfaItem };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsxs as s, jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import "react";
|
|
3
|
+
import { Button as i } from "../ui/Button/index.js";
|
|
4
|
+
import "@coinbase/cdp-hooks";
|
|
5
|
+
import "@coinbase/cdp-core";
|
|
6
|
+
import '../../assets/VerifyMfaItem.css';const m = "VerifyMfaItem-module__btn___7ZZjy", c = "VerifyMfaItem-module__icon___gse6F", a = "VerifyMfaItem-module__text___aV6B6", t = {
|
|
7
|
+
btn: m,
|
|
8
|
+
icon: c,
|
|
9
|
+
text: a
|
|
10
|
+
}, u = ({ icon: e, label: n, onSelect: r }) => /* @__PURE__ */ s(
|
|
11
|
+
i,
|
|
12
|
+
{
|
|
13
|
+
size: "md",
|
|
14
|
+
fullWidth: !0,
|
|
15
|
+
variant: "control",
|
|
16
|
+
className: t.btn,
|
|
17
|
+
onClick: r,
|
|
18
|
+
type: "button",
|
|
19
|
+
children: [
|
|
20
|
+
e && /* @__PURE__ */ o("span", { className: t.icon, children: e }),
|
|
21
|
+
/* @__PURE__ */ o("span", { className: t.text, children: n })
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
);
|
|
25
|
+
export {
|
|
26
|
+
u as VerifyMfaItem
|
|
27
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
import { MfaMethod } from './types';
|
|
3
|
+
import { VerifyMfaItemProps } from './VerifyMfaItem';
|
|
4
|
+
interface VerifyMfaItemsProps extends Omit<HTMLAttributes<HTMLUListElement>, "children" | "onSelect"> {
|
|
5
|
+
children?: (props: VerifyMfaItemProps) => ReactNode;
|
|
6
|
+
onSelect?: (method: MfaMethod) => void;
|
|
7
|
+
}
|
|
8
|
+
declare const VerifyMfaItems: ({ children, className, onSelect, ...props }: VerifyMfaItemsProps) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export { VerifyMfaItems, type VerifyMfaItemsProps };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { c as a } from "../../chunks/lite.1fxw3LjI.js";
|
|
3
|
+
import { useMemo as f } from "react";
|
|
4
|
+
import { IconPhone as u } from "../../icons/IconPhone.js";
|
|
5
|
+
import { IconPinCode as I } from "../../icons/IconPinCode.js";
|
|
6
|
+
import "@coinbase/cdp-hooks";
|
|
7
|
+
import "@coinbase/cdp-core";
|
|
8
|
+
import { VerifyMfaItem as M } from "./VerifyMfaItem.js";
|
|
9
|
+
import { useVerifyMfaContext as y } from "./VerifyMfaProvider.js";
|
|
10
|
+
import '../../assets/VerifyMfaItems.css';const _ = "VerifyMfaItems-module__list___ITk0B", x = {
|
|
11
|
+
list: _
|
|
12
|
+
}, V = {
|
|
13
|
+
totp: { Icon: /* @__PURE__ */ t(I, {}), label: "Authenticator app" },
|
|
14
|
+
sms: { Icon: /* @__PURE__ */ t(u, {}), label: "SMS" }
|
|
15
|
+
}, B = ({ children: i, className: n = "", onSelect: e, ...c }) => {
|
|
16
|
+
const { state: l } = y(), { methods: m } = l, p = f(() => m.map((o) => {
|
|
17
|
+
const { Icon: r, label: s } = V[o];
|
|
18
|
+
return {
|
|
19
|
+
method: o,
|
|
20
|
+
icon: r,
|
|
21
|
+
label: s,
|
|
22
|
+
onSelect: () => e?.(o)
|
|
23
|
+
};
|
|
24
|
+
}), [m, e]);
|
|
25
|
+
return /* @__PURE__ */ t("ul", { className: a(x.list, n), ...c, children: p.map(
|
|
26
|
+
({ method: o, ...r }, s) => s === 0 ? null : /* @__PURE__ */ t("li", { children: i?.({ ...r, method: o }) || /* @__PURE__ */ t(M, { ...r, method: o }) }, o)
|
|
27
|
+
) });
|
|
28
|
+
};
|
|
29
|
+
export {
|
|
30
|
+
B as VerifyMfaItems
|
|
31
|
+
};
|
|
@@ -1,28 +1,41 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import {
|
|
3
|
-
import "@coinbase/cdp-hooks";
|
|
4
|
-
import {
|
|
5
|
-
|
|
1
|
+
import { jsx as d } from "react/jsx-runtime";
|
|
2
|
+
import { getEnrolledMfaMethods as u } from "@coinbase/cdp-core";
|
|
3
|
+
import { useCurrentUser as c } from "@coinbase/cdp-hooks";
|
|
4
|
+
import { createContext as p, useContext as l, useMemo as n, useEffect as h } from "react";
|
|
5
|
+
import { useVerifyMfaReducer as M } from "./useVerifyMfaReducer.js";
|
|
6
|
+
const x = {
|
|
6
7
|
method: "totp",
|
|
7
8
|
methods: ["totp"],
|
|
8
9
|
step: "verification",
|
|
10
|
+
flowDirection: "left",
|
|
9
11
|
mfaCode: "",
|
|
10
12
|
error: null,
|
|
11
13
|
isPending: !1,
|
|
12
14
|
isSuccess: !1
|
|
13
|
-
},
|
|
14
|
-
const e =
|
|
15
|
+
}, a = p(null), E = () => {
|
|
16
|
+
const e = l(a);
|
|
15
17
|
if (!e)
|
|
16
18
|
throw new Error("useVerifyMfaContext must be used within a VerifyMfaProvider");
|
|
17
19
|
return e;
|
|
18
|
-
},
|
|
19
|
-
const
|
|
20
|
-
() =>
|
|
21
|
-
[
|
|
20
|
+
}, P = ({ children: e, onError: f, onSuccess: i }) => {
|
|
21
|
+
const { currentUser: s } = c(), t = n(
|
|
22
|
+
() => s ? u(s) : ["totp"],
|
|
23
|
+
[s]
|
|
24
|
+
), [o, r] = M({
|
|
25
|
+
...x,
|
|
26
|
+
methods: t,
|
|
27
|
+
method: t[0] || "totp"
|
|
28
|
+
});
|
|
29
|
+
h(() => {
|
|
30
|
+
t.join(",") !== o.methods.join(",") && r({ type: "SET_METHODS", payload: { methods: t } });
|
|
31
|
+
}, [t, r, o.methods]);
|
|
32
|
+
const m = n(
|
|
33
|
+
() => ({ state: o, dispatch: r, onSuccess: i, onError: f }),
|
|
34
|
+
[o, r, i, f]
|
|
22
35
|
);
|
|
23
|
-
return /* @__PURE__ */
|
|
36
|
+
return /* @__PURE__ */ d(a.Provider, { value: m, children: e });
|
|
24
37
|
};
|
|
25
38
|
export {
|
|
26
|
-
|
|
27
|
-
|
|
39
|
+
P as VerifyMfaProvider,
|
|
40
|
+
E as useVerifyMfaContext
|
|
28
41
|
};
|
|
@@ -3,4 +3,4 @@ import { VerifyMfaMethodComponentProps } from './types';
|
|
|
3
3
|
export interface VerifyMfaTitleProps extends VerifyMfaMethodComponentProps, HTMLAttributes<HTMLElement> {
|
|
4
4
|
as?: ElementType;
|
|
5
5
|
}
|
|
6
|
-
export declare const VerifyMfaTitle: ({ as: Component, children, className, method: methodFromProps, step: stepFromProps, ...props }: VerifyMfaTitleProps) => import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export declare const VerifyMfaTitle: ({ as: Component, children, className, method: methodFromProps, step: stepFromProps, ...props }: VerifyMfaTitleProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -1,21 +1,31 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as e, Fragment as c } from "react/jsx-runtime";
|
|
2
2
|
import "react";
|
|
3
|
-
import { m as d } from "../../chunks/index.
|
|
3
|
+
import { m as d } from "../../chunks/index.BX4k-ruQ.js";
|
|
4
4
|
import "@coinbase/cdp-hooks";
|
|
5
|
+
import "@coinbase/cdp-core";
|
|
5
6
|
import { useVerifyMfaContext as h } from "./VerifyMfaProvider.js";
|
|
6
|
-
import '../../assets/VerifyMfaTitle.css';const
|
|
7
|
-
heading:
|
|
8
|
-
},
|
|
9
|
-
as:
|
|
10
|
-
children:
|
|
7
|
+
import '../../assets/VerifyMfaTitle.css';const u = "VerifyMfaTitle-module__heading___18nul", y = {
|
|
8
|
+
heading: u
|
|
9
|
+
}, C = ({
|
|
10
|
+
as: r = "h2",
|
|
11
|
+
children: o,
|
|
11
12
|
className: m = "",
|
|
12
|
-
method:
|
|
13
|
-
step:
|
|
14
|
-
...
|
|
13
|
+
method: l,
|
|
14
|
+
step: a,
|
|
15
|
+
...f
|
|
15
16
|
}) => {
|
|
16
|
-
const { state:
|
|
17
|
-
|
|
17
|
+
const { state: i } = h(), s = a || i.step, n = l || i.method;
|
|
18
|
+
let t;
|
|
19
|
+
if (o)
|
|
20
|
+
t = o;
|
|
21
|
+
else if (s === "list")
|
|
22
|
+
t = /* @__PURE__ */ e(c, { children: "Verify it's you" });
|
|
23
|
+
else {
|
|
24
|
+
const p = d[n].title;
|
|
25
|
+
t = /* @__PURE__ */ e(p, { step: s, method: n });
|
|
26
|
+
}
|
|
27
|
+
return t ? /* @__PURE__ */ e(r, { className: `${y.heading} ${m}`, ...f, children: t }) : null;
|
|
18
28
|
};
|
|
19
29
|
export {
|
|
20
|
-
|
|
30
|
+
C as VerifyMfaTitle
|
|
21
31
|
};
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { APIError } from '@coinbase/cdp-hooks';
|
|
2
2
|
import { HTMLAttributes, ReactNode } from 'react';
|
|
3
|
-
import { VerifyMfaAction, VerifyMfaState } from './types';
|
|
3
|
+
import { VerifyMfaAction, VerifyMfaState, VerifyMfaStep } from './types';
|
|
4
4
|
import { VerifyMfaDescription, VerifyMfaDescriptionProps } from './VerifyMfaDescription';
|
|
5
5
|
import { VerifyMfaFlow, VerifyMfaFlowProps } from './VerifyMfaFlow';
|
|
6
|
+
import { VerifyMfaFlowBackButton, VerifyMfaFlowBackButtonProps } from './VerifyMfaFlowBackButton';
|
|
7
|
+
import { useVerifyMfaFlow, VerifyMfaFlowContextValue } from './VerifyMfaFlowProvider';
|
|
6
8
|
import { VerifyMfaFooter } from './VerifyMfaFooter';
|
|
7
9
|
import { VerifyMfaImage, VerifyMfaImageProps } from './VerifyMfaImage';
|
|
10
|
+
import { VerifyMfaItem, VerifyMfaItemProps } from './VerifyMfaItem';
|
|
11
|
+
import { VerifyMfaItems, VerifyMfaItemsProps } from './VerifyMfaItems';
|
|
8
12
|
import { useVerifyMfaContext, VerifyMfaContextValue } from './VerifyMfaProvider';
|
|
9
13
|
import { VerifyMfaTitle, VerifyMfaTitleProps } from './VerifyMfaTitle';
|
|
10
14
|
interface VerifyMfaProps extends Omit<HTMLAttributes<HTMLDivElement>, "children" | "onSubmit" | "onError"> {
|
|
@@ -13,4 +17,4 @@ interface VerifyMfaProps extends Omit<HTMLAttributes<HTMLDivElement>, "children"
|
|
|
13
17
|
onError?: (error: APIError | Error) => void;
|
|
14
18
|
}
|
|
15
19
|
declare const VerifyMfa: ({ onSuccess, onError, ...props }: VerifyMfaProps) => import("react/jsx-runtime").JSX.Element;
|
|
16
|
-
export { VerifyMfa, VerifyMfaDescription,
|
|
20
|
+
export { VerifyMfa, VerifyMfaDescription, VerifyMfaFlow, VerifyMfaFlowBackButton, VerifyMfaFooter, VerifyMfaImage, VerifyMfaItem, VerifyMfaItems, VerifyMfaTitle, useVerifyMfaContext, useVerifyMfaFlow, type VerifyMfaProps, type VerifyMfaContextValue, type VerifyMfaDescriptionProps, type VerifyMfaFlowBackButtonProps, type VerifyMfaFlowContextValue, type VerifyMfaFlowProps, type VerifyMfaImageProps, type VerifyMfaItemProps, type VerifyMfaItemsProps, type VerifyMfaTitleProps, type VerifyMfaAction, type VerifyMfaState, type VerifyMfaStep, };
|
|
@@ -2,19 +2,28 @@ import "react/jsx-runtime";
|
|
|
2
2
|
import "@coinbase/cdp-hooks";
|
|
3
3
|
import "../../chunks/useSendComponentCallOnce.BHZMuo6E.js";
|
|
4
4
|
import "react";
|
|
5
|
-
import { V as
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
5
|
+
import { V as p } from "../../chunks/CDPReactProvider.C38bKQ2x.js";
|
|
6
|
+
import "@coinbase/cdp-core";
|
|
7
|
+
import { VerifyMfaDescription as x } from "./VerifyMfaDescription.js";
|
|
8
|
+
import { VerifyMfaFlow as y } from "./VerifyMfaFlow.js";
|
|
9
|
+
import { VerifyMfaFlowBackButton as s } from "./VerifyMfaFlowBackButton.js";
|
|
10
|
+
import { useVerifyMfaFlow as F } from "./VerifyMfaFlowProvider.js";
|
|
11
|
+
import { VerifyMfaFooter as u } from "./VerifyMfaFooter.js";
|
|
12
|
+
import { VerifyMfaImage as I } from "./VerifyMfaImage.js";
|
|
13
|
+
import { VerifyMfaItem as B } from "./VerifyMfaItem.js";
|
|
14
|
+
import { VerifyMfaItems as k } from "./VerifyMfaItems.js";
|
|
15
|
+
import { useVerifyMfaContext as D } from "./VerifyMfaProvider.js";
|
|
16
|
+
import { VerifyMfaTitle as b } from "./VerifyMfaTitle.js";
|
|
12
17
|
export {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
p as VerifyMfa,
|
|
19
|
+
x as VerifyMfaDescription,
|
|
20
|
+
y as VerifyMfaFlow,
|
|
21
|
+
s as VerifyMfaFlowBackButton,
|
|
22
|
+
u as VerifyMfaFooter,
|
|
23
|
+
I as VerifyMfaImage,
|
|
24
|
+
B as VerifyMfaItem,
|
|
25
|
+
k as VerifyMfaItems,
|
|
26
|
+
b as VerifyMfaTitle,
|
|
27
|
+
D as useVerifyMfaContext,
|
|
28
|
+
F as useVerifyMfaFlow
|
|
20
29
|
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { MfaMethodConfig, MfaMethodContentProps, VerifyMfaMethodComponentProps } from '../types';
|
|
2
|
+
export declare const SmsContent: ({ autoFocus, onError, onSuccess, children, }: MfaMethodContentProps) => import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
export declare const SmsTitle: (_props: VerifyMfaMethodComponentProps) => import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
export declare const SmsImage: (_props: VerifyMfaMethodComponentProps) => import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
export declare const SmsDescription: (_props: VerifyMfaMethodComponentProps) => import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export declare const smsMethodConfig: MfaMethodConfig;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { jsx as r, Fragment as p } from "react/jsx-runtime";
|
|
2
|
+
import { useIsInitialized as V, useCurrentUser as N, useInitiateMfaVerification as v, useSubmitMfaVerification as P } from "@coinbase/cdp-hooks";
|
|
3
|
+
import { useRef as w, useState as M, useEffect as S, useCallback as b } from "react";
|
|
4
|
+
import { OTPForm as B } from "../../forms/OTPForm/index.js";
|
|
5
|
+
import { Badge as L } from "../../ui/Badge/index.js";
|
|
6
|
+
import { useTimer as x } from "../../../hooks/useTimer.js";
|
|
7
|
+
import { IconPhone as z } from "../../../icons/IconPhone.js";
|
|
8
|
+
import "@coinbase/cdp-core";
|
|
9
|
+
import { useVerifyMfaContext as j } from "../VerifyMfaProvider.js";
|
|
10
|
+
const T = 60, k = ({
|
|
11
|
+
autoFocus: o = !0,
|
|
12
|
+
onError: h,
|
|
13
|
+
onSuccess: g,
|
|
14
|
+
children: u
|
|
15
|
+
}) => {
|
|
16
|
+
const { isInitialized: l } = V(), { currentUser: F } = N(), { state: s, dispatch: t } = j(), { initiateMfaVerification: i } = v(), C = w(!1), { submitMfaVerification: R } = P(), {
|
|
17
|
+
timeRemaining: d,
|
|
18
|
+
start: a,
|
|
19
|
+
reset: f
|
|
20
|
+
} = x(), [m, I] = M(!1), [A, E] = M(!1), y = !!F;
|
|
21
|
+
S(() => {
|
|
22
|
+
if (!l || !y || C.current) return;
|
|
23
|
+
C.current = !0, requestAnimationFrame(async () => {
|
|
24
|
+
a(T);
|
|
25
|
+
try {
|
|
26
|
+
await i({ mfaMethod: "sms" });
|
|
27
|
+
} catch (e) {
|
|
28
|
+
const c = e instanceof Error ? e.message : "Failed to send verification code";
|
|
29
|
+
t({ type: "INITIATE_MFA_VERIFICATION_FAILURE", payload: { error: c } });
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}, [l, i, y, a, t]), S(() => {
|
|
33
|
+
d === 0 && !m && (I(!0), f());
|
|
34
|
+
}, [d, m, f]);
|
|
35
|
+
const O = b(async () => {
|
|
36
|
+
t({ type: "SET_MFA_CODE", payload: { mfaCode: "" } }), I(!1), E(!0);
|
|
37
|
+
try {
|
|
38
|
+
await i({ mfaMethod: "sms" });
|
|
39
|
+
} catch (n) {
|
|
40
|
+
const e = n instanceof Error ? n.message : "Failed to resend verification code";
|
|
41
|
+
t({ type: "INITIATE_MFA_VERIFICATION_FAILURE", payload: { error: e } });
|
|
42
|
+
} finally {
|
|
43
|
+
a(T), E(!1);
|
|
44
|
+
}
|
|
45
|
+
}, [t, i, a]), U = (n) => {
|
|
46
|
+
t({ type: "SET_MFA_CODE", payload: { mfaCode: n } });
|
|
47
|
+
}, D = async (n) => {
|
|
48
|
+
n.preventDefault(), t({ type: "SUBMIT_MFA_CODE", payload: { mfaCode: s.mfaCode } });
|
|
49
|
+
try {
|
|
50
|
+
const e = s.mfaCode;
|
|
51
|
+
await R({ mfaMethod: "sms", mfaCode: e }), t({ type: "SUBMIT_MFA_CODE_SUCCESS" }), f(), g?.(e);
|
|
52
|
+
} catch (e) {
|
|
53
|
+
const c = e instanceof Error ? e : new Error(typeof e == "string" ? e : "Verification failed");
|
|
54
|
+
h?.(c), t({
|
|
55
|
+
type: "SUBMIT_MFA_CODE_FAILURE",
|
|
56
|
+
payload: {
|
|
57
|
+
error: c.message
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}, _ = /* @__PURE__ */ r(
|
|
62
|
+
B,
|
|
63
|
+
{
|
|
64
|
+
autoFocus: o,
|
|
65
|
+
otp: s.mfaCode,
|
|
66
|
+
error: s.error || void 0,
|
|
67
|
+
isPending: s.isPending || A,
|
|
68
|
+
onOTPChange: U,
|
|
69
|
+
onResendOTP: O,
|
|
70
|
+
onSubmit: D,
|
|
71
|
+
passwordLength: 6,
|
|
72
|
+
canResetOTP: m,
|
|
73
|
+
resendCountdown: d,
|
|
74
|
+
successMessage: s.isSuccess ? "Verified!" : void 0
|
|
75
|
+
}
|
|
76
|
+
);
|
|
77
|
+
return u ? /* @__PURE__ */ r(p, { children: u({ step: s.step, Content: _ }) }) : _;
|
|
78
|
+
}, q = (o) => /* @__PURE__ */ r(p, { children: "Enter verification code" }), W = (o) => /* @__PURE__ */ r(L, { variant: "secondary", children: /* @__PURE__ */ r(z, {}) }), G = (o) => /* @__PURE__ */ r(p, { children: "Enter the 6-digit code sent to your phone." }), te = {
|
|
79
|
+
content: k,
|
|
80
|
+
title: q,
|
|
81
|
+
description: G,
|
|
82
|
+
image: W
|
|
83
|
+
};
|
|
84
|
+
export {
|
|
85
|
+
k as SmsContent,
|
|
86
|
+
G as SmsDescription,
|
|
87
|
+
W as SmsImage,
|
|
88
|
+
q as SmsTitle,
|
|
89
|
+
te as smsMethodConfig
|
|
90
|
+
};
|
|
@@ -1,69 +1,70 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useIsInitialized as
|
|
3
|
-
import { useRef as
|
|
4
|
-
import { OTPForm as
|
|
5
|
-
import { Badge as
|
|
6
|
-
import { IconSmartPhone as
|
|
7
|
-
import
|
|
1
|
+
import { jsx as r, Fragment as s } from "react/jsx-runtime";
|
|
2
|
+
import { useIsInitialized as E, useCurrentUser as _, useInitiateMfaVerification as g, useSubmitMfaVerification as T } from "@coinbase/cdp-hooks";
|
|
3
|
+
import { useRef as F, useEffect as S } from "react";
|
|
4
|
+
import { OTPForm as A } from "../../forms/OTPForm/index.js";
|
|
5
|
+
import { Badge as U } from "../../ui/Badge/index.js";
|
|
6
|
+
import { IconSmartPhone as V } from "../../../icons/IconSmartPhone.js";
|
|
7
|
+
import "@coinbase/cdp-core";
|
|
8
|
+
import { useVerifyMfaContext as O } from "../VerifyMfaProvider.js";
|
|
8
9
|
const v = ({
|
|
9
|
-
autoFocus:
|
|
10
|
-
onError:
|
|
11
|
-
onSuccess:
|
|
12
|
-
children:
|
|
10
|
+
autoFocus: i = !0,
|
|
11
|
+
onError: C,
|
|
12
|
+
onSuccess: M,
|
|
13
|
+
children: c
|
|
13
14
|
}) => {
|
|
14
|
-
const { isInitialized:
|
|
15
|
-
|
|
16
|
-
if (!
|
|
17
|
-
requestAnimationFrame(async () => {
|
|
18
|
-
p.current = !0;
|
|
15
|
+
const { isInitialized: f } = E(), { currentUser: l } = _(), { state: e, dispatch: o } = O(), { initiateMfaVerification: p } = g(), d = F(!1), { submitMfaVerification: I } = T(), m = !!l;
|
|
16
|
+
S(() => {
|
|
17
|
+
if (!f || !m || d.current) return;
|
|
18
|
+
d.current = !0, requestAnimationFrame(async () => {
|
|
19
19
|
try {
|
|
20
|
-
await
|
|
20
|
+
await p({ mfaMethod: "totp" });
|
|
21
21
|
} catch (t) {
|
|
22
|
-
|
|
22
|
+
const a = t instanceof Error ? t.message : "Failed to send verification code";
|
|
23
|
+
o({ type: "INITIATE_MFA_VERIFICATION_FAILURE", payload: { error: a } });
|
|
23
24
|
}
|
|
24
25
|
});
|
|
25
|
-
}, [
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
},
|
|
29
|
-
n.preventDefault(),
|
|
26
|
+
}, [f, p, m, o]);
|
|
27
|
+
const y = (n) => {
|
|
28
|
+
o({ type: "SET_MFA_CODE", payload: { mfaCode: n } });
|
|
29
|
+
}, h = async (n) => {
|
|
30
|
+
n.preventDefault(), o({ type: "SUBMIT_MFA_CODE", payload: { mfaCode: e.mfaCode } });
|
|
30
31
|
try {
|
|
31
32
|
const t = e.mfaCode;
|
|
32
|
-
await
|
|
33
|
+
await I({ mfaMethod: "totp", mfaCode: t }), o({ type: "SUBMIT_MFA_CODE_SUCCESS" }), M?.(t);
|
|
33
34
|
} catch (t) {
|
|
34
|
-
const
|
|
35
|
-
|
|
35
|
+
const a = t instanceof Error ? t : new Error(typeof t == "string" ? t : "Verification failed");
|
|
36
|
+
C?.(a), o({
|
|
36
37
|
type: "SUBMIT_MFA_CODE_FAILURE",
|
|
37
38
|
payload: {
|
|
38
|
-
error:
|
|
39
|
+
error: a.message
|
|
39
40
|
}
|
|
40
41
|
});
|
|
41
42
|
}
|
|
42
|
-
},
|
|
43
|
-
|
|
43
|
+
}, u = /* @__PURE__ */ r(
|
|
44
|
+
A,
|
|
44
45
|
{
|
|
45
|
-
autoFocus:
|
|
46
|
+
autoFocus: i,
|
|
46
47
|
otp: e.mfaCode,
|
|
47
48
|
error: e.error || void 0,
|
|
48
49
|
isPending: e.isPending,
|
|
49
|
-
onOTPChange:
|
|
50
|
-
onSubmit:
|
|
50
|
+
onOTPChange: y,
|
|
51
|
+
onSubmit: h,
|
|
51
52
|
passwordLength: 6,
|
|
52
53
|
resendCountdown: null,
|
|
53
54
|
successMessage: e.isSuccess ? "Verified!" : void 0
|
|
54
55
|
}
|
|
55
56
|
);
|
|
56
|
-
return
|
|
57
|
-
}, D = (
|
|
57
|
+
return c ? /* @__PURE__ */ r(s, { children: c({ step: e.step, Content: u }) }) : u;
|
|
58
|
+
}, D = (i) => /* @__PURE__ */ r(s, { children: "Enter verification code" }), w = (i) => /* @__PURE__ */ r(U, { variant: "secondary", children: /* @__PURE__ */ r(V, {}) }), P = (i) => /* @__PURE__ */ r(s, { children: "Enter the 6-digit code from your authenticator app." }), q = {
|
|
58
59
|
content: v,
|
|
59
60
|
title: D,
|
|
60
|
-
description:
|
|
61
|
-
image:
|
|
61
|
+
description: P,
|
|
62
|
+
image: w
|
|
62
63
|
};
|
|
63
64
|
export {
|
|
64
65
|
v as TotpContent,
|
|
65
|
-
|
|
66
|
-
|
|
66
|
+
P as TotpDescription,
|
|
67
|
+
w as TotpImage,
|
|
67
68
|
D as TotpTitle,
|
|
68
|
-
|
|
69
|
+
q as totpMethodConfig
|
|
69
70
|
};
|
|
@@ -2,20 +2,29 @@ import { APIError } from '@coinbase/cdp-hooks';
|
|
|
2
2
|
import { FC, ReactNode } from 'react';
|
|
3
3
|
import { MfaMethod } from '../EnrollMfa/types';
|
|
4
4
|
export { type MfaMethod };
|
|
5
|
+
export type VerifyMfaStep = "verification" | "list";
|
|
5
6
|
export interface VerifyMfaMethodComponentProps {
|
|
6
7
|
method?: MfaMethod;
|
|
7
|
-
step?:
|
|
8
|
+
step?: VerifyMfaStep;
|
|
8
9
|
}
|
|
9
10
|
export interface VerifyMfaState {
|
|
10
11
|
method: MfaMethod;
|
|
11
12
|
methods: MfaMethod[];
|
|
12
|
-
step:
|
|
13
|
+
step: VerifyMfaStep;
|
|
14
|
+
flowDirection: "left" | "right";
|
|
13
15
|
mfaCode: string;
|
|
14
16
|
error: string | APIError | null;
|
|
15
17
|
isPending: boolean;
|
|
16
18
|
isSuccess: boolean;
|
|
17
19
|
}
|
|
18
20
|
export type VerifyMfaAction = {
|
|
21
|
+
type: "SET_STEP";
|
|
22
|
+
payload: {
|
|
23
|
+
step: VerifyMfaStep;
|
|
24
|
+
flowDirection?: "left" | "right";
|
|
25
|
+
method?: MfaMethod;
|
|
26
|
+
};
|
|
27
|
+
} | {
|
|
19
28
|
type: "SET_METHOD";
|
|
20
29
|
payload: {
|
|
21
30
|
method: MfaMethod;
|
|
@@ -37,6 +46,16 @@ export type VerifyMfaAction = {
|
|
|
37
46
|
payload: {
|
|
38
47
|
error: string | APIError;
|
|
39
48
|
};
|
|
49
|
+
} | {
|
|
50
|
+
type: "INITIATE_MFA_VERIFICATION_FAILURE";
|
|
51
|
+
payload: {
|
|
52
|
+
error: string | APIError;
|
|
53
|
+
};
|
|
54
|
+
} | {
|
|
55
|
+
type: "SET_METHODS";
|
|
56
|
+
payload: {
|
|
57
|
+
methods: MfaMethod[];
|
|
58
|
+
};
|
|
40
59
|
} | {
|
|
41
60
|
type: "CLEAR_ERROR";
|
|
42
61
|
} | {
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import { VerifyMfaAction, VerifyMfaState } from './types';
|
|
1
|
+
import { VerifyMfaAction, VerifyMfaState, VerifyMfaStep } from './types';
|
|
2
|
+
export declare const STEPS: readonly VerifyMfaStep[];
|
|
2
3
|
export declare const useVerifyMfaReducer: (initialState: VerifyMfaState) => [VerifyMfaState, import('react').ActionDispatch<[action: VerifyMfaAction]>];
|
|
@@ -1,11 +1,24 @@
|
|
|
1
1
|
import { useReducer as o } from "react";
|
|
2
2
|
import "@coinbase/cdp-hooks";
|
|
3
|
-
|
|
3
|
+
import "@coinbase/cdp-core";
|
|
4
|
+
const u = ["verification", "list"];
|
|
5
|
+
function l(e, r) {
|
|
4
6
|
switch (r.type) {
|
|
7
|
+
case "SET_STEP":
|
|
8
|
+
return {
|
|
9
|
+
...e,
|
|
10
|
+
step: r.payload.step,
|
|
11
|
+
flowDirection: r.payload.flowDirection || e.flowDirection,
|
|
12
|
+
method: r.payload.method || e.method,
|
|
13
|
+
mfaCode: "",
|
|
14
|
+
error: null
|
|
15
|
+
};
|
|
5
16
|
case "SET_METHOD":
|
|
6
17
|
return {
|
|
7
18
|
...e,
|
|
8
19
|
method: r.payload.method,
|
|
20
|
+
step: "verification",
|
|
21
|
+
flowDirection: "left",
|
|
9
22
|
mfaCode: "",
|
|
10
23
|
error: null
|
|
11
24
|
};
|
|
@@ -36,6 +49,16 @@ function n(e, r) {
|
|
|
36
49
|
isSuccess: !1,
|
|
37
50
|
error: r.payload.error
|
|
38
51
|
};
|
|
52
|
+
case "INITIATE_MFA_VERIFICATION_FAILURE":
|
|
53
|
+
return {
|
|
54
|
+
...e,
|
|
55
|
+
error: r.payload.error
|
|
56
|
+
};
|
|
57
|
+
case "SET_METHODS":
|
|
58
|
+
return {
|
|
59
|
+
...e,
|
|
60
|
+
methods: r.payload.methods
|
|
61
|
+
};
|
|
39
62
|
case "CLEAR_ERROR":
|
|
40
63
|
return {
|
|
41
64
|
...e,
|
|
@@ -43,9 +66,10 @@ function n(e, r) {
|
|
|
43
66
|
};
|
|
44
67
|
case "RESET_STATE":
|
|
45
68
|
return {
|
|
46
|
-
method: e.method,
|
|
69
|
+
method: e.methods[0] || e.method,
|
|
47
70
|
methods: e.methods,
|
|
48
71
|
step: "verification",
|
|
72
|
+
flowDirection: "left",
|
|
49
73
|
mfaCode: "",
|
|
50
74
|
error: null,
|
|
51
75
|
isPending: !1,
|
|
@@ -55,7 +79,8 @@ function n(e, r) {
|
|
|
55
79
|
throw new Error("Unknown action type");
|
|
56
80
|
}
|
|
57
81
|
}
|
|
58
|
-
const
|
|
82
|
+
const i = (e) => o(l, e);
|
|
59
83
|
export {
|
|
60
|
-
|
|
84
|
+
u as STEPS,
|
|
85
|
+
i as useVerifyMfaReducer
|
|
61
86
|
};
|