@coinbase/cdp-react 0.0.86 → 0.0.88
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.BkmtXUv1.js +337 -0
- package/dist/chunks/{LinkAuthFlow.BaUSMzGH.js → LinkAuthFlow.B4FAtf4V.js} +13 -13
- package/dist/chunks/index.BX4k-ruQ.js +12 -0
- package/dist/chunks/index.Bgx0-QLY.js +12 -0
- package/dist/chunks/{index.C_DV0Ud7.js → index.DgrgIsTX.js} +1 -1
- package/dist/chunks/useSendComponentCallOnce.DGjALrnZ.js +278 -0
- package/dist/components/AuthButton/index.js +1 -1
- package/dist/components/CDPReactProvider/index.js +1 -1
- package/dist/components/CopyEvmKeyButton/index.js +1 -1
- package/dist/components/CopySolanaKeyButton/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 +2 -2
- package/dist/components/ExportWallet/index.js +109 -101
- package/dist/components/ExportWalletModal/index.js +2 -2
- package/dist/components/Fund/index.js +2 -2
- package/dist/components/FundModal/index.js +2 -2
- 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 +4 -4
- package/dist/components/LinkAuth/types.js +1 -1
- package/dist/components/LinkAuth/utils.js +1 -1
- package/dist/components/LinkAuthModal/index.js +3 -3
- package/dist/components/OAuthStatusModal/index.js +2 -2
- package/dist/components/SendEvmTransactionButton/index.js +1 -1
- package/dist/components/SendSolanaTransactionButton/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 +2 -2
- 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 +2 -2
- package/dist/components/SignOutButton/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 +24 -15
- 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 +8 -6
- 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 +2 -2
- package/dist/index.js +60 -52
- 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
- package/dist/chunks/useSendComponentCallOnce.BHZMuo6E.js +0 -273
|
@@ -1,24 +1,29 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { createContext as
|
|
1
|
+
import { jsx as f } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as s, useContext as a, useEffect as u, useMemo as c } from "react";
|
|
3
|
+
import "@coinbase/cdp-core";
|
|
3
4
|
import "@coinbase/cdp-hooks";
|
|
4
|
-
import { useEnrollMfaReducer as
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
if (!
|
|
5
|
+
import { useEnrollMfaReducer as p } from "./useEnrollMfaReducer.js";
|
|
6
|
+
const i = s(null), C = () => {
|
|
7
|
+
const o = a(i);
|
|
8
|
+
if (!o)
|
|
8
9
|
throw new Error("useEnrollMfaContext must be used within EnrollMfaProvider");
|
|
9
|
-
return
|
|
10
|
-
},
|
|
11
|
-
children:
|
|
12
|
-
onEnrollSuccess:
|
|
13
|
-
methods:
|
|
10
|
+
return o;
|
|
11
|
+
}, v = ({
|
|
12
|
+
children: o,
|
|
13
|
+
onEnrollSuccess: n,
|
|
14
|
+
methods: t
|
|
14
15
|
}) => {
|
|
15
|
-
const [r, e] =
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
const [r, e] = p(t);
|
|
17
|
+
u(() => {
|
|
18
|
+
t && t.join(",") !== r.methods.join(",") && e({ type: "SET_METHODS", payload: { methods: t } });
|
|
19
|
+
}, [t, e, r.methods]);
|
|
20
|
+
const l = c(
|
|
21
|
+
() => ({ state: r, dispatch: e, onEnrollSuccess: n }),
|
|
22
|
+
[r, e, n]
|
|
18
23
|
);
|
|
19
|
-
return /* @__PURE__ */ i
|
|
24
|
+
return /* @__PURE__ */ f(i.Provider, { value: l, children: o });
|
|
20
25
|
};
|
|
21
26
|
export {
|
|
22
|
-
|
|
23
|
-
|
|
27
|
+
v as EnrollMfaProvider,
|
|
28
|
+
C as useEnrollMfaContext
|
|
24
29
|
};
|
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
import { jsx as t, Fragment as h } from "react/jsx-runtime";
|
|
2
2
|
import "react";
|
|
3
3
|
import { useEnrollMfaContext as p } from "./EnrollMfaProvider.js";
|
|
4
|
-
import { m as f } from "../../chunks/index.
|
|
4
|
+
import { m as f } from "../../chunks/index.Bgx0-QLY.js";
|
|
5
|
+
import "@coinbase/cdp-core";
|
|
5
6
|
import "@coinbase/cdp-hooks";
|
|
6
7
|
import '../../assets/EnrollMfaTitle.css';const g = "EnrollMfaTitle-module__heading___ogrZZ", u = {
|
|
7
8
|
heading: g
|
|
8
|
-
},
|
|
9
|
-
as:
|
|
10
|
-
children:
|
|
11
|
-
className:
|
|
9
|
+
}, C = ({
|
|
10
|
+
as: i = "h2",
|
|
11
|
+
children: r,
|
|
12
|
+
className: s = "",
|
|
12
13
|
method: l,
|
|
13
14
|
step: m,
|
|
14
15
|
...a
|
|
15
16
|
}) => {
|
|
16
17
|
const { state: o } = p(), e = m || o.step, n = l || o.method, c = f[n].title, d = e === "list" ? /* @__PURE__ */ t(h, { children: "Add multi-factor authentication" }) : /* @__PURE__ */ t(c, { step: e, method: n });
|
|
17
|
-
return /* @__PURE__ */ t(
|
|
18
|
+
return /* @__PURE__ */ t(i, { className: `${u.heading} ${s}`, ...a, children: r ?? d });
|
|
18
19
|
};
|
|
19
20
|
export {
|
|
20
|
-
|
|
21
|
+
C as EnrollMfaTitle
|
|
21
22
|
};
|
|
@@ -1,180 +1,186 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
1
|
+
import { jsx as r, jsxs as s, Fragment as u } from "react/jsx-runtime";
|
|
2
|
+
import { getEnabledMfaMethods as $, getEnrolledMfaMethods as k } from "@coinbase/cdp-core";
|
|
3
|
+
import { useCurrentUser as w, useIsInitialized as V, useInitiateMfaEnrollment as j, useSubmitMfaEnrollment as z, useRecordMfaEnrollmentPrompted as q } from "@coinbase/cdp-hooks";
|
|
4
|
+
import { u as J } from "../../chunks/useSendComponentCallOnce.DGjALrnZ.js";
|
|
5
|
+
import { useMemo as C, useRef as _, useEffect as v, useCallback as p, useLayoutEffect as K } from "react";
|
|
6
|
+
import { c as G } from "../../chunks/lite.1fxw3LjI.js";
|
|
7
|
+
import { u as X } from "../../chunks/CDPReactProvider.BkmtXUv1.js";
|
|
8
|
+
import { useTimeout as Y } from "../../hooks/useTimeout.js";
|
|
9
|
+
import { isApiError as Z } from "../../utils/isApiError.js";
|
|
9
10
|
import "libphonenumber-js";
|
|
10
|
-
import { EnrollMfaDescription as
|
|
11
|
-
import { EnrollMfaFlow as
|
|
12
|
-
import { EnrollMfaFlowBackButton as
|
|
13
|
-
import { EnrollMfaFlowProvider as
|
|
14
|
-
import { useEnrollMfaFlow as
|
|
15
|
-
import { EnrollMfaFooter as
|
|
16
|
-
import { EnrollMfaImage as
|
|
17
|
-
import { EnrollMfaItem as
|
|
18
|
-
import { EnrollMfaItems as
|
|
19
|
-
import { EnrollMfaProvider as
|
|
20
|
-
import { EnrollMfaTitle as
|
|
21
|
-
import {
|
|
22
|
-
import
|
|
11
|
+
import { EnrollMfaDescription as O } from "./EnrollMfaDescription.js";
|
|
12
|
+
import { EnrollMfaFlow as H } from "./EnrollMfaFlow.js";
|
|
13
|
+
import { EnrollMfaFlowBackButton as Q } from "./EnrollMfaFlowBackButton.js";
|
|
14
|
+
import { EnrollMfaFlowProvider as W } from "./EnrollMfaFlowProvider.js";
|
|
15
|
+
import { useEnrollMfaFlow as Fe } from "./EnrollMfaFlowProvider.js";
|
|
16
|
+
import { EnrollMfaFooter as ee } from "./EnrollMfaFooter.js";
|
|
17
|
+
import { EnrollMfaImage as te } from "./EnrollMfaImage.js";
|
|
18
|
+
import { EnrollMfaItem as Pe } from "./EnrollMfaItem.js";
|
|
19
|
+
import { EnrollMfaItems as De } from "./EnrollMfaItems.js";
|
|
20
|
+
import { EnrollMfaProvider as oe, useEnrollMfaContext as A } from "./EnrollMfaProvider.js";
|
|
21
|
+
import { EnrollMfaTitle as U } from "./EnrollMfaTitle.js";
|
|
22
|
+
import { m as re } from "../../chunks/index.Bgx0-QLY.js";
|
|
23
|
+
import { Banner as ne } from "../ui/Banner/index.js";
|
|
24
|
+
import '../../assets/EnrollMfa.css';const le = "EnrollMfa-module__img___JmjV1", ae = "EnrollMfa-module__centered___YxB8I", ie = "EnrollMfa-module__footer___Zro3u", a = {
|
|
23
25
|
"mfa-enrollment": "EnrollMfa-module__mfa-enrollment___80xnL",
|
|
24
|
-
img:
|
|
26
|
+
img: le,
|
|
25
27
|
"flex-container": "EnrollMfa-module__flex-container___9Dazs",
|
|
26
28
|
"gap-2": "EnrollMfa-module__gap-2___BKEqR",
|
|
27
29
|
"gap-3": "EnrollMfa-module__gap-3___JKVyF",
|
|
28
|
-
centered:
|
|
29
|
-
footer:
|
|
30
|
-
},
|
|
31
|
-
const { state:
|
|
32
|
-
return
|
|
33
|
-
},
|
|
34
|
-
className:
|
|
35
|
-
children:
|
|
36
|
-
resetOnSuccess:
|
|
37
|
-
...
|
|
30
|
+
centered: ae,
|
|
31
|
+
footer: ie
|
|
32
|
+
}, se = 5 * 60 * 1e3, me = ({ role: d = "alert", ...m }) => {
|
|
33
|
+
const { state: i } = A(), { error: l } = i;
|
|
34
|
+
return l ? /* @__PURE__ */ r(ne, { variant: "error", role: d, ...m, children: Z(l) ? l.message : l }) : null;
|
|
35
|
+
}, ce = ({
|
|
36
|
+
className: d = "",
|
|
37
|
+
children: m,
|
|
38
|
+
resetOnSuccess: i = !0,
|
|
39
|
+
...l
|
|
38
40
|
}) => {
|
|
39
|
-
const { isInitialized:
|
|
40
|
-
|
|
41
|
-
!
|
|
42
|
-
}, [
|
|
41
|
+
const { isInitialized: c } = V(), { currentUser: E } = w(), { state: e, dispatch: o, onEnrollSuccess: M } = A(), { initiateMfaEnrollment: h } = j(), { submitMfaEnrollment: I } = z(), { recordMfaEnrollmentPrompted: S } = q(), { showCoinbaseFooter: F } = X(), g = _(!1), y = !!E;
|
|
42
|
+
v(() => {
|
|
43
|
+
!c || !y || g.current || (S(), g.current = !0);
|
|
44
|
+
}, [S, c, y]), v(() => {
|
|
43
45
|
if (!e.initiatedAt) return;
|
|
44
46
|
const t = () => {
|
|
45
|
-
e.initiatedAt && Date.now() - e.initiatedAt >=
|
|
47
|
+
e.initiatedAt && Date.now() - e.initiatedAt >= se && o({ type: "ENROLLMENT_SESSION_EXPIRED" });
|
|
46
48
|
};
|
|
47
49
|
t();
|
|
48
|
-
const
|
|
49
|
-
return () => clearInterval(
|
|
50
|
-
}, [e.initiatedAt,
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
}, []),
|
|
54
|
-
|
|
55
|
-
}, [
|
|
50
|
+
const n = setInterval(t, 1e3);
|
|
51
|
+
return () => clearInterval(n);
|
|
52
|
+
}, [e.initiatedAt, o]);
|
|
53
|
+
const T = _(e.step), N = _(null), { schedule: L } = Y(), R = p((t) => {
|
|
54
|
+
T.current !== t && (T.current = t, N.current?.transition.toggle(t));
|
|
55
|
+
}, []), B = p(() => {
|
|
56
|
+
o({ type: "GO_TO_PREVIOUS_STEP" });
|
|
57
|
+
}, [o]), P = p(
|
|
56
58
|
async (t) => {
|
|
57
|
-
if (
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
59
|
+
if (!c) return;
|
|
60
|
+
const n = re[t];
|
|
61
|
+
if (n.requiresInput && e.step !== "setup") {
|
|
62
|
+
o({
|
|
63
|
+
type: "SET_STEP",
|
|
64
|
+
payload: { step: "setup", flowDirection: "left", method: t }
|
|
65
|
+
});
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
o({ type: "INITIATE_ENROLLMENT", payload: { method: t } });
|
|
69
|
+
try {
|
|
70
|
+
const f = n.getInitiateOptions(e), D = await h(f);
|
|
71
|
+
o({ type: "INITIATE_ENROLLMENT_SUCCESS", payload: D });
|
|
72
|
+
} catch (f) {
|
|
73
|
+
o({
|
|
74
|
+
type: "INITIATE_ENROLLMENT_FAILURE",
|
|
75
|
+
payload: {
|
|
76
|
+
error: f instanceof Error ? f.message : "Failed to initiate enrollment"
|
|
77
|
+
}
|
|
78
|
+
});
|
|
76
79
|
}
|
|
77
80
|
},
|
|
78
|
-
[
|
|
79
|
-
),
|
|
81
|
+
[o, h, c, e]
|
|
82
|
+
), b = p(
|
|
80
83
|
async (t) => {
|
|
81
|
-
t.preventDefault(),
|
|
84
|
+
t.preventDefault(), o({ type: "SUBMIT_ENROLLMENT" });
|
|
82
85
|
try {
|
|
83
|
-
await
|
|
86
|
+
await I({
|
|
84
87
|
mfaMethod: e.method,
|
|
85
88
|
mfaCode: e.mfaCode
|
|
86
|
-
}),
|
|
87
|
-
|
|
89
|
+
}), o({ type: "SUBMIT_ENROLLMENT_SUCCESS" }), M?.(), i && L(() => {
|
|
90
|
+
o({ type: "SET_STEP", payload: { step: "list", flowDirection: "left" } });
|
|
88
91
|
}, 800);
|
|
89
|
-
} catch (
|
|
90
|
-
|
|
92
|
+
} catch (n) {
|
|
93
|
+
o({
|
|
91
94
|
type: "SUBMIT_ENROLLMENT_FAILURE",
|
|
92
95
|
payload: {
|
|
93
|
-
error:
|
|
96
|
+
error: n instanceof Error ? n.message : "Verification failed"
|
|
94
97
|
}
|
|
95
98
|
});
|
|
96
99
|
}
|
|
97
100
|
},
|
|
98
101
|
[
|
|
99
|
-
|
|
102
|
+
o,
|
|
100
103
|
e.method,
|
|
101
104
|
e.mfaCode,
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
105
|
+
I,
|
|
106
|
+
M,
|
|
107
|
+
i,
|
|
108
|
+
L
|
|
106
109
|
]
|
|
107
110
|
);
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}, [e.step,
|
|
111
|
-
const
|
|
112
|
-
return /* @__PURE__ */
|
|
113
|
-
|
|
111
|
+
K(() => {
|
|
112
|
+
R(e.step);
|
|
113
|
+
}, [e.step, R]);
|
|
114
|
+
const x = typeof m == "function" ? m(e) : m;
|
|
115
|
+
return /* @__PURE__ */ r(
|
|
116
|
+
W,
|
|
114
117
|
{
|
|
115
|
-
onBack:
|
|
116
|
-
onStartEnrollment:
|
|
117
|
-
onSubmit:
|
|
118
|
-
transitionRef:
|
|
119
|
-
children: /* @__PURE__ */
|
|
120
|
-
|
|
121
|
-
!
|
|
122
|
-
/* @__PURE__ */
|
|
118
|
+
onBack: B,
|
|
119
|
+
onStartEnrollment: P,
|
|
120
|
+
onSubmit: b,
|
|
121
|
+
transitionRef: N,
|
|
122
|
+
children: /* @__PURE__ */ s("div", { className: `${a["mfa-enrollment"]} ${d}`, ...l, children: [
|
|
123
|
+
x,
|
|
124
|
+
!x && /* @__PURE__ */ s(u, { children: [
|
|
125
|
+
/* @__PURE__ */ s(
|
|
123
126
|
"div",
|
|
124
127
|
{
|
|
125
|
-
className:
|
|
126
|
-
|
|
127
|
-
e.step === "list" ?
|
|
128
|
+
className: G(
|
|
129
|
+
a["flex-container"],
|
|
130
|
+
e.step === "list" ? a["gap-3"] : ""
|
|
128
131
|
),
|
|
129
132
|
children: [
|
|
130
|
-
e.step === "list" ? /* @__PURE__ */
|
|
131
|
-
/* @__PURE__ */
|
|
132
|
-
/* @__PURE__ */
|
|
133
|
-
/* @__PURE__ */
|
|
133
|
+
e.step === "list" ? /* @__PURE__ */ s(u, { children: [
|
|
134
|
+
/* @__PURE__ */ s("div", { children: [
|
|
135
|
+
/* @__PURE__ */ r(U, { step: "list", method: e.method }),
|
|
136
|
+
/* @__PURE__ */ r(O, { step: "list", method: e.method })
|
|
134
137
|
] }),
|
|
135
|
-
/* @__PURE__ */
|
|
136
|
-
] }) : /* @__PURE__ */
|
|
137
|
-
/* @__PURE__ */
|
|
138
|
-
t !== "list" && /* @__PURE__ */
|
|
139
|
-
/* @__PURE__ */
|
|
140
|
-
|
|
138
|
+
/* @__PURE__ */ r(me, {})
|
|
139
|
+
] }) : /* @__PURE__ */ r("div", { children: /* @__PURE__ */ r(Q, { step: e.step }) }),
|
|
140
|
+
/* @__PURE__ */ r(H, { children: ({ step: t, method: n, Content: f }) => /* @__PURE__ */ s("div", { className: `${a["flex-container"]} ${a["gap-2"]}`, children: [
|
|
141
|
+
t !== "list" && /* @__PURE__ */ s(u, { children: [
|
|
142
|
+
/* @__PURE__ */ r(
|
|
143
|
+
te,
|
|
141
144
|
{
|
|
142
|
-
className: `${
|
|
145
|
+
className: `${a.img} ${a.centered}`,
|
|
143
146
|
step: t,
|
|
144
|
-
method:
|
|
147
|
+
method: n
|
|
145
148
|
}
|
|
146
149
|
),
|
|
147
|
-
/* @__PURE__ */
|
|
148
|
-
/* @__PURE__ */
|
|
149
|
-
/* @__PURE__ */
|
|
150
|
+
/* @__PURE__ */ s("div", { className: a.centered, children: [
|
|
151
|
+
/* @__PURE__ */ r(U, { step: t, method: n }),
|
|
152
|
+
/* @__PURE__ */ r(O, { step: t, method: n })
|
|
150
153
|
] })
|
|
151
154
|
] }),
|
|
152
|
-
|
|
155
|
+
f
|
|
153
156
|
] }) })
|
|
154
157
|
]
|
|
155
158
|
}
|
|
156
159
|
),
|
|
157
|
-
|
|
160
|
+
F && /* @__PURE__ */ r(ee, { className: a.footer })
|
|
158
161
|
] })
|
|
159
162
|
] })
|
|
160
163
|
}
|
|
161
164
|
);
|
|
162
|
-
},
|
|
163
|
-
|
|
164
|
-
const
|
|
165
|
-
|
|
165
|
+
}, Ue = ({ onEnrollSuccess: d, ...m }) => {
|
|
166
|
+
J("enroll_mfa");
|
|
167
|
+
const { currentUser: i } = w(), l = $(), c = C(
|
|
168
|
+
() => i ? k(i) : [],
|
|
169
|
+
[i]
|
|
170
|
+
), E = C(() => [.../* @__PURE__ */ new Set([...l, ...c])], [l, c]);
|
|
171
|
+
return /* @__PURE__ */ r(oe, { methods: E, onEnrollSuccess: d, children: /* @__PURE__ */ r(ce, { ...m }) });
|
|
166
172
|
};
|
|
167
173
|
export {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
174
|
+
Ue as EnrollMfa,
|
|
175
|
+
O as EnrollMfaDescription,
|
|
176
|
+
me as EnrollMfaError,
|
|
177
|
+
H as EnrollMfaFlow,
|
|
178
|
+
Q as EnrollMfaFlowBackButton,
|
|
179
|
+
ee as EnrollMfaFooter,
|
|
180
|
+
te as EnrollMfaImage,
|
|
181
|
+
Pe as EnrollMfaItem,
|
|
182
|
+
De as EnrollMfaItems,
|
|
183
|
+
U as EnrollMfaTitle,
|
|
184
|
+
A as useEnrollMfaContext,
|
|
185
|
+
Fe as useEnrollMfaFlow
|
|
180
186
|
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { EnrollMfaMethodConfig, EnrollMfaMethodContentProps, EnrollMfaMethodComponentProps } from '../types';
|
|
2
|
+
export declare const SmsContent: ({ autoFocus, step, onSubmit, children, }: EnrollMfaMethodContentProps) => import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
export declare const SmsTitle: ({ step }: EnrollMfaMethodComponentProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
4
|
+
export declare const SmsDescription: ({ step }: EnrollMfaMethodComponentProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
5
|
+
export declare const SmsImage: ({ step }: EnrollMfaMethodComponentProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
6
|
+
export declare const smsMethodConfig: EnrollMfaMethodConfig;
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { jsx as t, Fragment as a, jsxs as D } from "react/jsx-runtime";
|
|
2
|
+
import { useState as M, useCallback as i, useEffect as E, useMemo as w } from "react";
|
|
3
|
+
import { OTPForm as x } from "../../forms/OTPForm/index.js";
|
|
4
|
+
import { PhoneNumberForm as F } from "../../forms/PhoneNumberForm/index.js";
|
|
5
|
+
import { Badge as U } from "../../ui/Badge/index.js";
|
|
6
|
+
import { usePhoneNumberState as j } from "../../../hooks/usePhoneNumberState.js";
|
|
7
|
+
import { useTimer as I } from "../../../hooks/useTimer.js";
|
|
8
|
+
import { IconPhone as W } from "../../../icons/IconPhone.js";
|
|
9
|
+
import { formatPhoneNumber as k } from "../../../utils/formatPhoneNumber.js";
|
|
10
|
+
import { useEnrollMfaFlow as A } from "../EnrollMfaFlowProvider.js";
|
|
11
|
+
import { useEnrollMfaContext as _ } from "../EnrollMfaProvider.js";
|
|
12
|
+
import "@coinbase/cdp-core";
|
|
13
|
+
import "@coinbase/cdp-hooks";
|
|
14
|
+
import '../../../assets/sms.css';const L = "sms-module__form___G393d", B = "sms-module__credentials___jMUzc", f = {
|
|
15
|
+
form: L,
|
|
16
|
+
"otp-form": "sms-module__otp-form___yNrQa",
|
|
17
|
+
credentials: B
|
|
18
|
+
}, q = ({
|
|
19
|
+
autoFocus: e = !0,
|
|
20
|
+
step: o,
|
|
21
|
+
onSubmit: m,
|
|
22
|
+
children: h
|
|
23
|
+
}) => {
|
|
24
|
+
const { state: r, dispatch: n } = _(), { startEnrollment: c } = A(), {
|
|
25
|
+
timeRemaining: l,
|
|
26
|
+
start: u,
|
|
27
|
+
reset: N
|
|
28
|
+
} = I(), [p, C] = M(!1), b = i(
|
|
29
|
+
(s) => {
|
|
30
|
+
n({ type: "SET_PHONE_NUMBER", payload: { phoneNumber: s } });
|
|
31
|
+
},
|
|
32
|
+
[n]
|
|
33
|
+
), { phoneNumberObject: S, countryCode: g, handlePhoneNumberChange: O, handleCountryCodeChange: P } = j({
|
|
34
|
+
phoneNumber: r.phoneNumber,
|
|
35
|
+
onPhoneNumberChange: b
|
|
36
|
+
}), v = i(
|
|
37
|
+
(s) => {
|
|
38
|
+
n({ type: "SET_MFA_CODE", payload: { mfaCode: s } });
|
|
39
|
+
},
|
|
40
|
+
[n]
|
|
41
|
+
), y = i(() => {
|
|
42
|
+
n({ type: "CLEAR_ERROR" });
|
|
43
|
+
}, [n]), R = i(
|
|
44
|
+
(s) => {
|
|
45
|
+
s.preventDefault(), c("sms");
|
|
46
|
+
},
|
|
47
|
+
[c]
|
|
48
|
+
), T = i(async () => {
|
|
49
|
+
n({ type: "SET_MFA_CODE", payload: { mfaCode: "" } }), C(!1), u(60), c("sms");
|
|
50
|
+
}, [n, c, u]);
|
|
51
|
+
E(() => {
|
|
52
|
+
o === "setup-verification" && u(60);
|
|
53
|
+
}, [o, u]), E(() => {
|
|
54
|
+
l === 0 && !p && (C(!0), N());
|
|
55
|
+
}, [l, p, N]);
|
|
56
|
+
let d;
|
|
57
|
+
switch (o) {
|
|
58
|
+
case "setup":
|
|
59
|
+
d = /* @__PURE__ */ t(
|
|
60
|
+
F,
|
|
61
|
+
{
|
|
62
|
+
className: f.form,
|
|
63
|
+
autoFocus: e,
|
|
64
|
+
phoneNumber: S,
|
|
65
|
+
countryCode: g,
|
|
66
|
+
onPhoneNumberChange: O,
|
|
67
|
+
onCountryCodeChange: P,
|
|
68
|
+
error: r.error && r.step === "setup" ? r.error : void 0,
|
|
69
|
+
isPending: r.isPending,
|
|
70
|
+
onClearServerErrors: y,
|
|
71
|
+
onSubmit: R,
|
|
72
|
+
submitLabel: "Continue"
|
|
73
|
+
}
|
|
74
|
+
);
|
|
75
|
+
break;
|
|
76
|
+
case "setup-verification":
|
|
77
|
+
d = /* @__PURE__ */ t(
|
|
78
|
+
x,
|
|
79
|
+
{
|
|
80
|
+
className: f["otp-form"],
|
|
81
|
+
autoFocus: e,
|
|
82
|
+
otp: r.mfaCode,
|
|
83
|
+
error: r.error && r.step === "setup-verification" ? r.error : void 0,
|
|
84
|
+
isPending: r.isPending,
|
|
85
|
+
onOTPChange: v,
|
|
86
|
+
onResendOTP: T,
|
|
87
|
+
onSubmit: m,
|
|
88
|
+
passwordLength: 6,
|
|
89
|
+
canResetOTP: p,
|
|
90
|
+
resendCountdown: l,
|
|
91
|
+
successMessage: r.isSuccess ? "Enrolled!" : void 0
|
|
92
|
+
}
|
|
93
|
+
);
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
return h ? /* @__PURE__ */ t(a, { children: h({ step: o, Content: d }) }) : d;
|
|
97
|
+
}, z = ({ step: e }) => {
|
|
98
|
+
switch (e) {
|
|
99
|
+
case "setup":
|
|
100
|
+
return /* @__PURE__ */ t(a, { children: "Enter phone number" });
|
|
101
|
+
case "setup-verification":
|
|
102
|
+
return /* @__PURE__ */ t(a, { children: "Enter verification code" });
|
|
103
|
+
default:
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
}, G = ({ step: e }) => {
|
|
107
|
+
const { state: o } = _(), m = w(
|
|
108
|
+
() => e === "setup-verification" ? k(o.phoneNumber) : "",
|
|
109
|
+
[o.phoneNumber, e]
|
|
110
|
+
);
|
|
111
|
+
switch (e) {
|
|
112
|
+
case "setup":
|
|
113
|
+
return /* @__PURE__ */ t(a, { children: "We'll send you a verification code via text." });
|
|
114
|
+
case "setup-verification":
|
|
115
|
+
return /* @__PURE__ */ D(a, { children: [
|
|
116
|
+
"Enter the 6 digit code sent to",
|
|
117
|
+
" ",
|
|
118
|
+
m ? /* @__PURE__ */ t("span", { className: f.credentials, children: m }) : "your phone number"
|
|
119
|
+
] });
|
|
120
|
+
default:
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
123
|
+
}, H = ({ step: e }) => {
|
|
124
|
+
switch (e) {
|
|
125
|
+
case "setup":
|
|
126
|
+
case "setup-verification":
|
|
127
|
+
return /* @__PURE__ */ t(U, { variant: "secondary", children: /* @__PURE__ */ t(W, {}) });
|
|
128
|
+
default:
|
|
129
|
+
return null;
|
|
130
|
+
}
|
|
131
|
+
}, ie = {
|
|
132
|
+
content: q,
|
|
133
|
+
description: G,
|
|
134
|
+
getInitiateOptions: (e) => ({
|
|
135
|
+
mfaMethod: "sms",
|
|
136
|
+
phoneNumber: e.phoneNumber
|
|
137
|
+
}),
|
|
138
|
+
image: H,
|
|
139
|
+
requiresInput: !0,
|
|
140
|
+
title: z
|
|
141
|
+
};
|
|
142
|
+
export {
|
|
143
|
+
q as SmsContent,
|
|
144
|
+
G as SmsDescription,
|
|
145
|
+
H as SmsImage,
|
|
146
|
+
z as SmsTitle,
|
|
147
|
+
ie as smsMethodConfig
|
|
148
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as t, jsxs as l, Fragment as i } from "react/jsx-runtime";
|
|
2
2
|
import { c as u } from "../../../chunks/lite.1fxw3LjI.js";
|
|
3
|
-
import { useCallback as
|
|
3
|
+
import { useCallback as c } from "react";
|
|
4
4
|
import { OTPForm as E } from "../../forms/OTPForm/index.js";
|
|
5
5
|
import { Badge as C } from "../../ui/Badge/index.js";
|
|
6
6
|
import { Button as m } from "../../ui/Button/index.js";
|
|
@@ -8,8 +8,10 @@ import { CopyTextField as T } from "../../ui/CopyTextField/index.js";
|
|
|
8
8
|
import { Error as f } from "../../ui/Error/index.js";
|
|
9
9
|
import { QRCode as v } from "../../ui/QRCode/index.js";
|
|
10
10
|
import { IconSmartPhone as k } from "../../../icons/IconSmartPhone.js";
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
11
|
+
import { isApiError as S } from "../../../utils/isApiError.js";
|
|
12
|
+
import { useEnrollMfaFlow as w } from "../EnrollMfaFlowProvider.js";
|
|
13
|
+
import { useEnrollMfaContext as M } from "../EnrollMfaProvider.js";
|
|
14
|
+
import "@coinbase/cdp-core";
|
|
13
15
|
import "@coinbase/cdp-hooks";
|
|
14
16
|
import '../../../assets/totp.css';const P = "totp-module__expired___SKiyj", F = "totp-module__container___1aL5H", o = {
|
|
15
17
|
"qr-code": "totp-module__qr-code___qyK1k",
|
|
@@ -17,24 +19,24 @@ import '../../../assets/totp.css';const P = "totp-module__expired___SKiyj", F =
|
|
|
17
19
|
container: F,
|
|
18
20
|
"copy-key": "totp-module__copy-key___iwzZf",
|
|
19
21
|
"otp-form": "totp-module__otp-form___OzooV"
|
|
20
|
-
},
|
|
22
|
+
}, b = ({
|
|
21
23
|
autoFocus: r = !0,
|
|
22
|
-
step:
|
|
24
|
+
step: a,
|
|
23
25
|
onSubmit: h,
|
|
24
26
|
children: p
|
|
25
27
|
}) => {
|
|
26
|
-
const { state: e, dispatch: n } =
|
|
28
|
+
const { state: e, dispatch: n } = M(), { startEnrollment: d } = w(), _ = c(() => {
|
|
27
29
|
d(e.method);
|
|
28
|
-
}, [d, e.method]), y =
|
|
30
|
+
}, [d, e.method]), y = c(() => {
|
|
29
31
|
n({ type: "SET_STEP", payload: { step: "setup-verification", flowDirection: "left" } });
|
|
30
|
-
}, [n]), g =
|
|
32
|
+
}, [n]), g = c(
|
|
31
33
|
(x) => {
|
|
32
34
|
n({ type: "SET_MFA_CODE", payload: { mfaCode: x } });
|
|
33
35
|
},
|
|
34
36
|
[n]
|
|
35
37
|
);
|
|
36
38
|
let s;
|
|
37
|
-
switch (
|
|
39
|
+
switch (a) {
|
|
38
40
|
case "setup":
|
|
39
41
|
s = /* @__PURE__ */ l("div", { className: o.container, children: [
|
|
40
42
|
/* @__PURE__ */ t("div", { className: u(o["qr-code"], e.isExpired ? o.expired : ""), children: /* @__PURE__ */ t(v, { value: e.authUrl || "", size: 128, ecl: "L" }) }),
|
|
@@ -48,7 +50,7 @@ import '../../../assets/totp.css';const P = "totp-module__expired___SKiyj", F =
|
|
|
48
50
|
}
|
|
49
51
|
),
|
|
50
52
|
e.isExpired && /* @__PURE__ */ t(f, { children: "Verification timed out. For your security, try again." }),
|
|
51
|
-
!e.isExpired && !!e.error && e.step === "setup" && /* @__PURE__ */ t(f, { children:
|
|
53
|
+
!e.isExpired && !!e.error && e.step === "setup" && /* @__PURE__ */ t(f, { children: S(e.error) ? e.error.message : e.error })
|
|
52
54
|
] }),
|
|
53
55
|
e.isExpired ? /* @__PURE__ */ t(
|
|
54
56
|
m,
|
|
@@ -79,8 +81,8 @@ import '../../../assets/totp.css';const P = "totp-module__expired___SKiyj", F =
|
|
|
79
81
|
);
|
|
80
82
|
break;
|
|
81
83
|
}
|
|
82
|
-
return p ? /* @__PURE__ */ t(i, { children: p({ step:
|
|
83
|
-
},
|
|
84
|
+
return p ? /* @__PURE__ */ t(i, { children: p({ step: a, Content: s }) }) : s;
|
|
85
|
+
}, O = ({ step: r }) => {
|
|
84
86
|
switch (r) {
|
|
85
87
|
case "setup":
|
|
86
88
|
return /* @__PURE__ */ t(i, { children: "Set up authenticator" });
|
|
@@ -105,16 +107,19 @@ import '../../../assets/totp.css';const P = "totp-module__expired___SKiyj", F =
|
|
|
105
107
|
default:
|
|
106
108
|
return null;
|
|
107
109
|
}
|
|
108
|
-
},
|
|
109
|
-
content:
|
|
110
|
-
title:
|
|
110
|
+
}, G = {
|
|
111
|
+
content: b,
|
|
112
|
+
title: O,
|
|
111
113
|
description: q,
|
|
112
|
-
image: A
|
|
114
|
+
image: A,
|
|
115
|
+
getInitiateOptions: () => ({
|
|
116
|
+
mfaMethod: "totp"
|
|
117
|
+
})
|
|
113
118
|
};
|
|
114
119
|
export {
|
|
115
|
-
|
|
120
|
+
b as TotpContent,
|
|
116
121
|
q as TotpDescription,
|
|
117
122
|
A as TotpImage,
|
|
118
|
-
|
|
119
|
-
|
|
123
|
+
O as TotpTitle,
|
|
124
|
+
G as totpMethodConfig
|
|
120
125
|
};
|