@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.
Files changed (113) hide show
  1. package/dist/assets/CDPReactProvider.css +1 -1
  2. package/dist/assets/EnrollMfaFlow.css +1 -1
  3. package/dist/assets/VerifyMfaFlow.css +1 -1
  4. package/dist/assets/VerifyMfaFlowBackButton.css +1 -0
  5. package/dist/assets/VerifyMfaInline.css +1 -1
  6. package/dist/assets/VerifyMfaItem.css +1 -0
  7. package/dist/assets/VerifyMfaItems.css +1 -0
  8. package/dist/assets/sms.css +1 -0
  9. package/dist/chunks/CDPReactProvider.BkmtXUv1.js +337 -0
  10. package/dist/chunks/{LinkAuthFlow.BaUSMzGH.js → LinkAuthFlow.B4FAtf4V.js} +13 -13
  11. package/dist/chunks/index.BX4k-ruQ.js +12 -0
  12. package/dist/chunks/index.Bgx0-QLY.js +12 -0
  13. package/dist/chunks/{index.C_DV0Ud7.js → index.DgrgIsTX.js} +1 -1
  14. package/dist/chunks/useSendComponentCallOnce.DGjALrnZ.js +278 -0
  15. package/dist/components/AuthButton/index.js +1 -1
  16. package/dist/components/CDPReactProvider/index.js +1 -1
  17. package/dist/components/CopyEvmKeyButton/index.js +1 -1
  18. package/dist/components/CopySolanaKeyButton/index.js +1 -1
  19. package/dist/components/EnrollMfa/EnrollMfaDescription.js +4 -3
  20. package/dist/components/EnrollMfa/EnrollMfaFlow.js +27 -26
  21. package/dist/components/EnrollMfa/EnrollMfaFlowBackButton.js +7 -6
  22. package/dist/components/EnrollMfa/EnrollMfaFlowProvider.d.ts +1 -1
  23. package/dist/components/EnrollMfa/EnrollMfaFlowProvider.js +5 -4
  24. package/dist/components/EnrollMfa/EnrollMfaImage.js +7 -6
  25. package/dist/components/EnrollMfa/EnrollMfaItem.js +7 -6
  26. package/dist/components/EnrollMfa/EnrollMfaItems.js +28 -25
  27. package/dist/components/EnrollMfa/EnrollMfaProvider.js +22 -17
  28. package/dist/components/EnrollMfa/EnrollMfaTitle.js +8 -7
  29. package/dist/components/EnrollMfa/index.js +134 -128
  30. package/dist/components/EnrollMfa/methods/sms.d.ts +6 -0
  31. package/dist/components/EnrollMfa/methods/sms.js +148 -0
  32. package/dist/components/EnrollMfa/methods/totp.js +24 -19
  33. package/dist/components/EnrollMfa/types.d.ts +17 -5
  34. package/dist/components/EnrollMfa/types.js +1 -0
  35. package/dist/components/EnrollMfa/useEnrollMfaReducer.js +51 -38
  36. package/dist/components/EnrollMfaModal/index.js +2 -2
  37. package/dist/components/ExportWallet/index.js +109 -101
  38. package/dist/components/ExportWalletModal/index.js +2 -2
  39. package/dist/components/Fund/index.js +2 -2
  40. package/dist/components/FundModal/index.js +2 -2
  41. package/dist/components/LinkAuth/LinkAuthFlow.js +2 -2
  42. package/dist/components/LinkAuth/LinkAuthFlowBackButton.js +2 -2
  43. package/dist/components/LinkAuth/LinkAuthFlowProvider.js +2 -2
  44. package/dist/components/LinkAuth/LinkAuthItem.js +1 -1
  45. package/dist/components/LinkAuth/LinkAuthItems.js +1 -1
  46. package/dist/components/LinkAuth/LinkAuthProvider.js +1 -1
  47. package/dist/components/LinkAuth/index.js +4 -4
  48. package/dist/components/LinkAuth/types.js +1 -1
  49. package/dist/components/LinkAuth/utils.js +1 -1
  50. package/dist/components/LinkAuthModal/index.js +3 -3
  51. package/dist/components/OAuthStatusModal/index.js +2 -2
  52. package/dist/components/SendEvmTransactionButton/index.js +1 -1
  53. package/dist/components/SendSolanaTransactionButton/index.js +1 -1
  54. package/dist/components/SignIn/SignInAuthMethodButtons.js +1 -1
  55. package/dist/components/SignIn/SignInBackButton.js +12 -12
  56. package/dist/components/SignIn/SignInDescription.js +2 -2
  57. package/dist/components/SignIn/SignInForm.js +2 -2
  58. package/dist/components/SignIn/SignInImage.js +1 -1
  59. package/dist/components/SignIn/SignInProvider.js +1 -1
  60. package/dist/components/SignIn/SignInTitle.js +2 -2
  61. package/dist/components/SignIn/flows/SignInWithEmail.js +1 -1
  62. package/dist/components/SignIn/flows/SignInWithOAuth.js +1 -1
  63. package/dist/components/SignIn/flows/SignInWithSms.js +74 -84
  64. package/dist/components/SignIn/index.js +2 -2
  65. package/dist/components/SignIn/types.d.ts +2 -0
  66. package/dist/components/SignIn/types.js +1 -1
  67. package/dist/components/SignIn/useSignInReducer.js +20 -6
  68. package/dist/components/SignInModal/index.js +2 -2
  69. package/dist/components/SignOutButton/index.js +1 -1
  70. package/dist/components/VerifyMfa/VerifyMfaDescription.d.ts +1 -1
  71. package/dist/components/VerifyMfa/VerifyMfaDescription.js +24 -14
  72. package/dist/components/VerifyMfa/VerifyMfaFlow.d.ts +5 -4
  73. package/dist/components/VerifyMfa/VerifyMfaFlow.js +52 -13
  74. package/dist/components/VerifyMfa/VerifyMfaFlowBackButton.d.ts +9 -0
  75. package/dist/components/VerifyMfa/VerifyMfaFlowBackButton.js +40 -0
  76. package/dist/components/VerifyMfa/VerifyMfaFlowProvider.d.ts +23 -0
  77. package/dist/components/VerifyMfa/VerifyMfaFlowProvider.js +37 -0
  78. package/dist/components/VerifyMfa/VerifyMfaImage.d.ts +1 -1
  79. package/dist/components/VerifyMfa/VerifyMfaImage.js +25 -13
  80. package/dist/components/VerifyMfa/VerifyMfaItem.d.ts +10 -0
  81. package/dist/components/VerifyMfa/VerifyMfaItem.js +27 -0
  82. package/dist/components/VerifyMfa/VerifyMfaItems.d.ts +9 -0
  83. package/dist/components/VerifyMfa/VerifyMfaItems.js +31 -0
  84. package/dist/components/VerifyMfa/VerifyMfaProvider.js +27 -14
  85. package/dist/components/VerifyMfa/VerifyMfaTitle.d.ts +1 -1
  86. package/dist/components/VerifyMfa/VerifyMfaTitle.js +23 -13
  87. package/dist/components/VerifyMfa/index.d.ts +6 -2
  88. package/dist/components/VerifyMfa/index.js +24 -15
  89. package/dist/components/VerifyMfa/methods/sms.d.ts +6 -0
  90. package/dist/components/VerifyMfa/methods/sms.js +90 -0
  91. package/dist/components/VerifyMfa/methods/totp.js +40 -39
  92. package/dist/components/VerifyMfa/types.d.ts +21 -2
  93. package/dist/components/VerifyMfa/types.js +1 -0
  94. package/dist/components/VerifyMfa/useVerifyMfaReducer.d.ts +2 -1
  95. package/dist/components/VerifyMfa/useVerifyMfaReducer.js +29 -4
  96. package/dist/components/VerifyMfaInline/index.d.ts +1 -1
  97. package/dist/components/VerifyMfaInline/index.js +133 -116
  98. package/dist/components/VerifyMfaModal/index.js +8 -6
  99. package/dist/components/ui/SwitchTransition/index.js +3 -3
  100. package/dist/hooks/usePhoneNumberState.d.ts +15 -0
  101. package/dist/hooks/usePhoneNumberState.js +39 -0
  102. package/dist/hooks/useTransitionMap.js +24 -22
  103. package/dist/hooks/useVerifyMfaModal.js +2 -2
  104. package/dist/index.js +60 -52
  105. package/dist/utils/transition.d.ts +3 -3
  106. package/dist/utils/transition.js +21 -20
  107. package/dist/version.d.ts +1 -1
  108. package/dist/version.js +1 -1
  109. package/package.json +6 -6
  110. package/dist/chunks/CDPReactProvider.CIQm4C4z.js +0 -299
  111. package/dist/chunks/index.CKQKBoX2.js +0 -9
  112. package/dist/chunks/index.Dp-lIxM1.js +0 -9
  113. package/dist/chunks/useSendComponentCallOnce.BHZMuo6E.js +0 -273
@@ -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 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";
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: r = !0,
10
- onError: u,
11
- onSuccess: C,
12
- children: s
10
+ autoFocus: i = !0,
11
+ onError: C,
12
+ onSuccess: M,
13
+ children: c
13
14
  }) => {
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;
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 f({ mfaMethod: "totp" });
20
+ await p({ mfaMethod: "totp" });
21
21
  } catch (t) {
22
- console.error("Failed to initiate MFA verification", t);
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
- }, [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 } });
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 l({ mfaMethod: "totp", mfaCode: t }), i({ type: "SUBMIT_MFA_CODE_SUCCESS" }), C?.(t);
33
+ await I({ mfaMethod: "totp", mfaCode: t }), o({ type: "SUBMIT_MFA_CODE_SUCCESS" }), M?.(t);
33
34
  } catch (t) {
34
- const m = t instanceof Error ? t : new Error(typeof t == "string" ? t : "Verification failed");
35
- u?.(m), i({
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: m.message
39
+ error: a.message
39
40
  }
40
41
  });
41
42
  }
42
- }, d = /* @__PURE__ */ o(
43
- F,
43
+ }, u = /* @__PURE__ */ r(
44
+ A,
44
45
  {
45
- autoFocus: r,
46
+ autoFocus: i,
46
47
  otp: e.mfaCode,
47
48
  error: e.error || void 0,
48
49
  isPending: e.isPending,
49
- onOTPChange: h,
50
- onSubmit: y,
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 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 = {
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: w,
61
- image: O
61
+ description: P,
62
+ image: w
62
63
  };
63
64
  export {
64
65
  v as TotpContent,
65
- w as TotpDescription,
66
- O as TotpImage,
66
+ P as TotpDescription,
67
+ w as TotpImage,
67
68
  D as TotpTitle,
68
- j as totpMethodConfig
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?: VerifyMfaState["step"];
8
+ step?: VerifyMfaStep;
8
9
  }
9
10
  export interface VerifyMfaState {
10
11
  method: MfaMethod;
11
12
  methods: MfaMethod[];
12
- step: "verification";
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
1
  import "@coinbase/cdp-hooks";
2
2
  import "react";
3
+ import "@coinbase/cdp-core";
@@ -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
- function n(e, r) {
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 d = (e) => o(n, e);
82
+ const i = (e) => o(l, e);
59
83
  export {
60
- d as useVerifyMfaReducer
84
+ u as STEPS,
85
+ i as useVerifyMfaReducer
61
86
  };
@@ -34,7 +34,7 @@ interface VerifyMfaInlineBackButtonProps extends ButtonHTMLAttributes<HTMLButton
34
34
  size?: ButtonSize;
35
35
  variant?: ButtonVariant;
36
36
  }
37
- declare const VerifyMfaInlineBackButton: ({ children, onClick, size, variant, ["aria-label"]: ariaLabel, ...props }: VerifyMfaInlineBackButtonProps) => import("react/jsx-runtime").JSX.Element | null;
37
+ declare const VerifyMfaInlineBackButton: ({ children, onClick, size, variant, ["aria-label"]: ariaLabel, className, ...props }: VerifyMfaInlineBackButtonProps) => import("react/jsx-runtime").JSX.Element | null;
38
38
  declare const VerifyMfaInlineFlow: ({ children, className, animateHeight, autoFocus, transition, }: VerifyMfaInlineFlowProps) => import("react/jsx-runtime").JSX.Element;
39
39
  declare const VerifyMfaInline: ({ children, verifyFirst, onVerified, onCancel, successDelay, className, ...props }: VerifyMfaInlineProps) => import("react/jsx-runtime").JSX.Element;
40
40
  export { VerifyMfaInline, VerifyMfaInlineBackButton, VerifyMfaInlineFlow, useVerifyMfaInlineContext, type VerifyMfaInlineBackButtonProps, type VerifyMfaInlineContextValue, type VerifyMfaInlineDirection, type VerifyMfaInlineFlowProps, type VerifyMfaInlineProps, type VerifyMfaInlineView, };
@@ -1,175 +1,192 @@
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";
1
+ import { jsx as t, jsxs as E } from "react/jsx-runtime";
2
+ import { isMfaRequired as q } from "@coinbase/cdp-core";
3
+ import { useCancelMfaVerification as L, useIsInitialized as A, useRegisterMfaListener as O } from "@coinbase/cdp-hooks";
4
+ import { u as P } from "../../chunks/useSendComponentCallOnce.DGjALrnZ.js";
5
+ import { createContext as W, useMemo as h, useRef as k, useState as R, useCallback as C, useContext as X, useEffect as Y } from "react";
6
+ import { c as j } from "../../chunks/lite.1fxw3LjI.js";
7
+ import { Button as H } from "../ui/Button/index.js";
8
+ import { SwitchFadeTransition as J } from "../ui/SwitchFadeTransition/index.js";
9
+ import { SwitchSlideTransition as Q } from "../ui/SwitchSlideTransition/index.js";
10
+ import { V as U } from "../../chunks/CDPReactProvider.BkmtXUv1.js";
11
+ import { IconArrowLeft as Z } from "../../icons/IconArrowLeft.js";
12
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 = {
13
+ import { useVerifyMfaContext as $ } from "../VerifyMfa/VerifyMfaProvider.js";
14
+ import { useVerifyMfaFlow as K } from "../VerifyMfa/VerifyMfaFlowProvider.js";
15
+ import { VerifyMfaFlow as ee } from "../VerifyMfa/VerifyMfaFlow.js";
16
+ import { VerifyMfaImage as ne } from "../VerifyMfa/VerifyMfaImage.js";
17
+ import { VerifyMfaTitle as te } from "../VerifyMfa/VerifyMfaTitle.js";
18
+ import { VerifyMfaDescription as ie } from "../VerifyMfa/VerifyMfaDescription.js";
19
+ import '../../assets/VerifyMfaInline.css';const oe = "VerifyMfaInline-module__icon___pezMX", re = "VerifyMfaInline-module__button___-gTjp", I = {
18
20
  "verify-mfa-inline": "VerifyMfaInline-module__verify-mfa-inline___mn38o",
19
- icon: H,
21
+ icon: oe,
22
+ button: re,
20
23
  "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);
24
+ "mfa-verification-content": "VerifyMfaInline-module__mfa-verification-content___M4fq0"
25
+ }, z = W(null), B = () => {
26
+ const e = X(z);
25
27
  if (!e)
26
28
  throw new Error("VerifyMfaInline compound components must be used within VerifyMfaInline");
27
29
  return e;
28
- }, ve = () => {
29
- const { view: e, goToContent: t, goToVerify: i, goBack: o } = S();
30
+ }, he = () => {
31
+ const { view: e, goToContent: n, goToVerify: i, goBack: o } = B();
30
32
  return h(
31
- () => ({ view: e, goToVerify: i, goToContent: t, goBack: o }),
32
- [e, i, t, o]
33
+ () => ({ view: e, goToVerify: i, goToContent: n, goBack: o }),
34
+ [e, i, n, o]
33
35
  );
34
- }, Ve = ({
36
+ }, Be = ({
35
37
  children: e,
36
- onClick: t,
38
+ onClick: n,
37
39
  size: i = "md",
38
40
  variant: o = "transparentSecondary",
39
- ["aria-label"]: d = "Back",
41
+ ["aria-label"]: f = "Back",
42
+ className: r = "",
40
43
  ...s
41
44
  }) => {
42
- const { goBack: M, verifyFirst: y, needsMfa: l, view: r } = S(), m = (f) => {
43
- t?.(f), M();
45
+ const { goBack: u, verifyFirst: d, needsMfa: c, view: y, canGoBack: l } = B(), V = (M) => {
46
+ n?.(M), u();
44
47
  };
45
- return y || !l || r === "content" ? null : /* @__PURE__ */ n(
46
- W,
48
+ return !c || y === "content" || d && !l ? null : /* @__PURE__ */ t(
49
+ H,
47
50
  {
48
51
  type: "button",
49
- "aria-label": d,
50
- onClick: m,
52
+ "aria-label": f,
53
+ onClick: V,
51
54
  size: i,
52
55
  variant: o,
56
+ className: j(I.button, r),
53
57
  ...s,
54
- children: e || /* @__PURE__ */ n(J, { className: C.icon })
58
+ children: e || /* @__PURE__ */ t(Z, { className: I.icon })
55
59
  }
56
60
  );
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 = ({
61
+ }, fe = () => {
62
+ const { state: e } = $(), { back: n } = K(), { setCanGoBack: i, mfaFlowBackRef: o } = B(), f = e.step === "list" || e.step === "verification" && e.method !== e.methods[0];
63
+ return Y(() => (i(f), o.current = f ? n : null, () => {
64
+ i(!1), o.current = null;
65
+ }), [f, n, i, o]), /* @__PURE__ */ t(ee, { animateHeight: !1, children: ({ step: r, method: s, Content: u }) => /* @__PURE__ */ E("div", { className: I["mfa-verification-content"], children: [
66
+ /* @__PURE__ */ t(ne, { step: r, method: s }),
67
+ /* @__PURE__ */ E("div", { children: [
68
+ /* @__PURE__ */ t(te, { step: r, method: s }),
69
+ /* @__PURE__ */ t(ie, { step: r, method: s })
70
+ ] }),
71
+ u
72
+ ] }) });
73
+ }, N = ({ onSuccess: e }) => /* @__PURE__ */ t(U, { className: I["mfa-verification"], onSuccess: e, children: /* @__PURE__ */ t(fe, {}) }), be = ({
65
74
  children: e,
66
- className: t = "",
75
+ className: n = "",
67
76
  animateHeight: i = !0,
68
77
  autoFocus: o = !0,
69
- transition: d = "slide"
78
+ transition: f = "slide"
70
79
  }) => {
71
80
  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 });
81
+ goToContent: r,
82
+ initialView: s,
83
+ direction: u,
84
+ transitionRef: d,
85
+ verifyFirst: c,
86
+ onVerified: y,
87
+ successDelay: l
88
+ } = B(), V = C(() => {
89
+ y?.(), c && (l > 0 ? setTimeout(() => r(), l) : r());
90
+ }, [r, c, y, l]), M = s === "verify" ? ["verify", "content"] : ["content", "verify"], p = typeof e == "function", w = ({ itemKey: m, ...g }) => {
91
+ let v = null;
92
+ return p ? v = e(
93
+ m === "content" ? { view: "content", Content: null } : { view: m, Content: m === "verify" ? /* @__PURE__ */ t(N, { onSuccess: V }) : void 0 }
94
+ ) : v = m === "verify" ? /* @__PURE__ */ t(N, { onSuccess: V }) : e, /* @__PURE__ */ t("div", { ...g, children: v });
86
95
  };
87
- return d === "fade" ? /* @__PURE__ */ n(
88
- X,
96
+ return f === "fade" ? /* @__PURE__ */ t(
97
+ J,
89
98
  {
90
99
  autoFocus: o,
91
100
  animateHeight: i,
92
- items: v,
101
+ items: M,
93
102
  initialEntered: !0,
94
- transitionRef: l,
95
- className: t,
96
- children: V
103
+ transitionRef: d,
104
+ className: n,
105
+ children: w
97
106
  }
98
- ) : /* @__PURE__ */ n(
99
- Y,
107
+ ) : /* @__PURE__ */ t(
108
+ Q,
100
109
  {
101
110
  autoFocus: o,
102
111
  animateHeight: i,
103
- items: v,
112
+ items: M,
104
113
  initialEntered: !0,
105
- direction: y,
106
- transitionRef: l,
107
- className: t,
108
- children: V
114
+ direction: u,
115
+ transitionRef: d,
116
+ className: n,
117
+ children: w
109
118
  }
110
119
  );
111
- }, _e = ({
120
+ }, xe = ({
112
121
  children: e,
113
- verifyFirst: t = !0,
122
+ verifyFirst: n = !0,
114
123
  onVerified: i,
115
124
  onCancel: o,
116
- successDelay: d = 500,
117
- className: s = "",
118
- ...M
125
+ successDelay: f = 500,
126
+ className: r = "",
127
+ ...s
119
128
  }) => {
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(
129
+ P("verify_mfa_inline");
130
+ const { cancelMfaVerification: u } = L(), { isInitialized: d } = A(), c = h(() => d ? q() : !1, [d]), y = k(null), l = k(null), [V, M] = R(!1), p = h(() => c && n ? "verify" : "content", [c, n]), [w, m] = R(p), [g, v] = R("left"), b = k(null), x = k(p), _ = C((a) => {
131
+ x.current !== a && (x.current = a, b.current?.transition.toggle(a));
132
+ }, []), T = C(
124
133
  (a = "left") => {
125
- V(a), v("verify"), c("verify");
134
+ v(a), m("verify"), _("verify");
126
135
  },
127
- [c]
128
- ), T = w(
136
+ [_]
137
+ ), S = C(
129
138
  (a = "left") => {
130
- V(a), v("content"), c("content");
139
+ v(a), m("content"), _("content");
131
140
  },
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
141
+ [_]
142
+ ), F = C(() => {
143
+ if (v("right"), l.current) {
144
+ l.current();
145
+ return;
146
+ }
147
+ const a = x.current === "verify", G = a ? "content" : "verify";
148
+ m(G), _(G), a && (u(), o?.());
149
+ }, [_, o, u]);
150
+ O(() => T(), {
151
+ scope: y,
152
+ enabled: c
140
153
  });
141
154
  const D = h(
142
155
  () => ({
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,
156
+ view: w,
157
+ goToVerify: T,
158
+ goToContent: S,
159
+ goBack: F,
160
+ needsMfa: c,
161
+ verifyFirst: n,
162
+ initialView: p,
163
+ direction: g,
164
+ transitionRef: b,
165
+ mfaFlowBackRef: l,
166
+ canGoBack: V,
167
+ setCanGoBack: M,
152
168
  onVerified: i,
153
- successDelay: d
169
+ successDelay: f
154
170
  }),
155
171
  [
156
- _,
157
- g,
172
+ w,
158
173
  T,
159
- k,
160
- r,
161
- t,
162
- f,
163
- I,
174
+ S,
175
+ F,
176
+ c,
177
+ n,
178
+ p,
179
+ g,
180
+ V,
164
181
  i,
165
- d
182
+ f
166
183
  ]
167
184
  );
168
- return /* @__PURE__ */ n(z.Provider, { value: D, children: /* @__PURE__ */ n("div", { ref: m, className: P(C["verify-mfa-inline"], s), ...M, children: e }) });
185
+ return /* @__PURE__ */ t(z.Provider, { value: D, children: /* @__PURE__ */ t("div", { ref: y, className: j(I["verify-mfa-inline"], r), ...s, children: e }) });
169
186
  };
170
187
  export {
171
- _e as VerifyMfaInline,
172
- Ve as VerifyMfaInlineBackButton,
173
- Me as VerifyMfaInlineFlow,
174
- ve as useVerifyMfaInlineContext
188
+ xe as VerifyMfaInline,
189
+ Be as VerifyMfaInlineBackButton,
190
+ be as VerifyMfaInlineFlow,
191
+ he as useVerifyMfaInlineContext
175
192
  };