@coinbase/cdp-react 0.0.109 → 0.0.110

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 (101) hide show
  1. package/dist/assets/OAuthStatusModal.css +1 -1
  2. package/dist/assets/SignIn.css +1 -1
  3. package/dist/assets/SignInImage.css +1 -1
  4. package/dist/assets/StatusView.css +1 -0
  5. package/dist/assets/SwitchTransition.css +1 -1
  6. package/dist/chunks/{CDPReactProvider.CFWIUvzR.js → CDPReactProvider.BWInVuNJ.js} +89 -86
  7. package/dist/chunks/LinkAuthFlow.0FnIchwa.js +144 -0
  8. package/dist/chunks/index.Du1vsLh6.js +23 -0
  9. package/dist/components/CDPReactProvider/index.d.ts +7 -1
  10. package/dist/components/CDPReactProvider/index.js +11 -7
  11. package/dist/components/EnrollMfa/index.js +1 -1
  12. package/dist/components/EnrollMfaModal/index.js +1 -1
  13. package/dist/components/ExportWallet/index.js +6 -4
  14. package/dist/components/ExportWalletModal/index.js +1 -1
  15. package/dist/components/Fund/index.js +1 -1
  16. package/dist/components/FundModal/index.js +1 -1
  17. package/dist/components/LinkAuth/LinkAuthFlow.js +9 -5
  18. package/dist/components/LinkAuth/LinkAuthFlowBackButton.js +2 -2
  19. package/dist/components/LinkAuth/LinkAuthFlowProvider.d.ts +22 -8
  20. package/dist/components/LinkAuth/LinkAuthFlowProvider.js +2 -2
  21. package/dist/components/LinkAuth/LinkAuthItem.js +1 -1
  22. package/dist/components/LinkAuth/LinkAuthItems.js +35 -28
  23. package/dist/components/LinkAuth/LinkAuthProvider.js +25 -18
  24. package/dist/components/LinkAuth/index.d.ts +2 -2
  25. package/dist/components/LinkAuth/index.js +63 -62
  26. package/dist/components/LinkAuth/types.d.ts +6 -1
  27. package/dist/components/LinkAuth/types.js +5 -3
  28. package/dist/components/LinkAuth/utils.js +3 -3
  29. package/dist/components/LinkAuthModal/index.d.ts +1 -1
  30. package/dist/components/LinkAuthModal/index.js +56 -46
  31. package/dist/components/OAuthStatusModal/index.js +113 -135
  32. package/dist/components/SignIn/SignInAuthMethodButtons.d.ts +5 -2
  33. package/dist/components/SignIn/SignInAuthMethodButtons.js +83 -52
  34. package/dist/components/SignIn/SignInBackButton.js +1 -1
  35. package/dist/components/SignIn/SignInDescription.js +2 -2
  36. package/dist/components/SignIn/SignInForm.js +2 -2
  37. package/dist/components/SignIn/SignInImage.d.ts +12 -3
  38. package/dist/components/SignIn/SignInImage.js +36 -13
  39. package/dist/components/SignIn/SignInProvider.js +5 -4
  40. package/dist/components/SignIn/SignInTitle.js +2 -2
  41. package/dist/components/SignIn/flows/SignInWithEmail.d.ts +0 -4
  42. package/dist/components/SignIn/flows/SignInWithEmail.js +73 -74
  43. package/dist/components/SignIn/flows/SignInWithOAuth.js +1 -1
  44. package/dist/components/SignIn/flows/SignInWithSiwe.d.ts +27 -0
  45. package/dist/components/SignIn/flows/SignInWithSiwe.js +63 -0
  46. package/dist/components/SignIn/flows/SignInWithSms.d.ts +0 -6
  47. package/dist/components/SignIn/flows/SignInWithSms.js +85 -86
  48. package/dist/components/SignIn/hooks/useEmailForm.js +13 -13
  49. package/dist/components/SignIn/hooks/useFlowTransition.d.ts +14 -0
  50. package/dist/components/SignIn/hooks/useFlowTransition.js +13 -0
  51. package/dist/components/SignIn/hooks/useOTPForm.js +29 -29
  52. package/dist/components/SignIn/hooks/usePhoneNumberForm.js +10 -10
  53. package/dist/components/SignIn/hooks/useStartSiwe.d.ts +10 -0
  54. package/dist/components/SignIn/hooks/useStartSiwe.js +24 -0
  55. package/dist/components/SignIn/index.d.ts +2 -2
  56. package/dist/components/SignIn/index.js +29 -29
  57. package/dist/components/SignIn/types.d.ts +24 -2
  58. package/dist/components/SignIn/types.js +5 -1
  59. package/dist/components/SignIn/useSignInReducer.js +67 -46
  60. package/dist/components/SignInModal/index.d.ts +1 -1
  61. package/dist/components/SignInModal/index.js +77 -67
  62. package/dist/components/SiweStatusView/connectors/baseAccount.d.ts +22 -0
  63. package/dist/components/SiweStatusView/connectors/baseAccount.js +49 -0
  64. package/dist/components/SiweStatusView/connectors/siweConnectors.d.ts +6 -0
  65. package/dist/components/SiweStatusView/connectors/siweConnectors.js +9 -0
  66. package/dist/components/SiweStatusView/connectors/types.d.ts +45 -0
  67. package/dist/components/SiweStatusView/connectors/types.js +2 -0
  68. package/dist/components/SiweStatusView/getSiweErrorMessage.d.ts +13 -0
  69. package/dist/components/SiweStatusView/getSiweErrorMessage.js +15 -0
  70. package/dist/components/SiweStatusView/index.d.ts +36 -0
  71. package/dist/components/SiweStatusView/index.js +71 -0
  72. package/dist/components/SiweStatusView/toSiweProvider.d.ts +10 -0
  73. package/dist/components/SiweStatusView/toSiweProvider.js +13 -0
  74. package/dist/components/SiweStatusView/useSiweFlow.d.ts +37 -0
  75. package/dist/components/SiweStatusView/useSiweFlow.js +35 -0
  76. package/dist/components/VerifyMfa/index.js +1 -1
  77. package/dist/components/VerifyMfaInline/index.js +1 -1
  78. package/dist/components/VerifyMfaModal/index.js +1 -1
  79. package/dist/components/ui/StatusView/index.d.ts +35 -0
  80. package/dist/components/ui/StatusView/index.js +55 -0
  81. package/dist/components/ui/SwitchFadeTransition/index.d.ts +1 -1
  82. package/dist/components/ui/SwitchFadeTransition/index.js +8 -12
  83. package/dist/components/ui/SwitchSlideTransition/index.d.ts +1 -1
  84. package/dist/components/ui/SwitchSlideTransition/index.js +8 -12
  85. package/dist/components/ui/SwitchTransition/index.d.ts +10 -3
  86. package/dist/components/ui/SwitchTransition/index.js +99 -98
  87. package/dist/hooks/useVerifyMfaModal.js +1 -1
  88. package/dist/icons/IconBaseColorLogo.d.ts +10 -0
  89. package/dist/icons/IconBaseColorLogo.js +13 -0
  90. package/dist/icons/IconBaseLogo.d.ts +24 -0
  91. package/dist/icons/IconBaseLogo.js +13 -0
  92. package/dist/icons/index.d.ts +2 -0
  93. package/dist/icons/index.js +36 -32
  94. package/dist/index.js +230 -225
  95. package/dist/version.d.ts +1 -1
  96. package/dist/version.js +1 -1
  97. package/package.json +13 -6
  98. package/dist/assets/SwitchFadeTransition.css +0 -1
  99. package/dist/assets/SwitchSlideTransition.css +0 -1
  100. package/dist/chunks/LinkAuthFlow.S1XbYaG5.js +0 -111
  101. package/dist/chunks/index.IrJ_irKX.js +0 -17
@@ -1,106 +1,105 @@
1
- import { jsxs as u, Fragment as c, jsx as s } from "react/jsx-runtime";
2
- import { useIsSignedIn as M, useSignInWithSms as H, useLinkSms as V, useVerifySmsOTP as q } from "@coinbase/cdp-hooks";
3
- import { useRef as S, useLayoutEffect as z, useMemo as A } from "react";
4
- import { OTPForm as B } from "../../forms/OTPForm/index.js";
5
- import { PhoneNumberForm as G } from "../../forms/PhoneNumberForm/index.js";
6
- import { SwitchSlideTransition as J } from "../../ui/SwitchSlideTransition/index.js";
7
- import { usePhoneNumberState as Q } from "../../../hooks/usePhoneNumberState.js";
8
- import { formatPhoneNumber as U } from "../../../utils/formatPhoneNumber.js";
9
- import { useOTPForm as X } from "../hooks/useOTPForm.js";
10
- import { usePhoneNumberForm as Y } from "../hooks/usePhoneNumberForm.js";
11
- import { SignInCredentials as Z } from "../SignInCredentials.js";
12
- import { useSignInContext as g } from "../SignInProvider.js";
13
- import "../../../chunks/CDPReactProvider.CFWIUvzR.js";
14
- const _ = ["phoneNumber", "otp"], $ = ({
15
- step: o,
16
- autoFocus: i,
17
- onSuccess: m,
18
- children: a
1
+ import { jsxs as c, Fragment as a, jsx as r } from "react/jsx-runtime";
2
+ import { useIsSignedIn as j, useSignInWithSms as L, useLinkSms as M, useVerifySmsOTP as k } from "@coinbase/cdp-hooks";
3
+ import { useMemo as A } from "react";
4
+ import { OTPForm as H } from "../../forms/OTPForm/index.js";
5
+ import { PhoneNumberForm as V } from "../../forms/PhoneNumberForm/index.js";
6
+ import { SwitchSlideTransition as q } from "../../ui/SwitchSlideTransition/index.js";
7
+ import { usePhoneNumberState as z } from "../../../hooks/usePhoneNumberState.js";
8
+ import { formatPhoneNumber as B } from "../../../utils/formatPhoneNumber.js";
9
+ import { useFlowTransition as G } from "../hooks/useFlowTransition.js";
10
+ import { useOTPForm as J } from "../hooks/useOTPForm.js";
11
+ import { usePhoneNumberForm as Q } from "../hooks/usePhoneNumberForm.js";
12
+ import { SignInCredentials as U } from "../SignInCredentials.js";
13
+ import { useSignInContext as l } from "../SignInProvider.js";
14
+ import { STEPS as X } from "../types.js";
15
+ const Y = ({
16
+ step: t,
17
+ autoFocus: s,
18
+ onSuccess: i,
19
+ children: h
19
20
  }) => {
20
- const h = S(null), P = 6, { isSignedIn: N } = M(), { state: e } = g(), { signInWithSms: T } = H(), { linkSms: C } = V(), { verifySmsOTP: O } = q(), p = o || e.step, t = p === "credentials" ? "phoneNumber" : "otp", d = S(t), { setPhoneNumber: I, submitPhoneNumber: f } = Y({
21
- submit: (n) => N ? C(n) : T({ phoneNumber: n })
22
- }), { phoneNumberObject: v, countryCode: y, handlePhoneNumberChange: F, handleCountryCodeChange: w } = Q({
23
- phoneNumber: e.phoneNumber,
24
- onPhoneNumberChange: I
25
- }), { resendCountdown: R, resetOTP: D, setOTP: W, startResendTimer: x, submitOtp: E } = X({
26
- passwordLength: P,
27
- submit: (n) => O({ flowId: e.flowId, otp: n })
28
- }), l = () => {
29
- x(60);
30
- }, j = () => {
31
- D(), f({ phoneNumber: e.phoneNumber, onSuccess: l });
32
- }, L = (n) => {
33
- n.preventDefault(), f({ phoneNumber: e.phoneNumber, onSuccess: l });
34
- }, k = (n) => {
35
- n.preventDefault();
36
- const r = new FormData(n.currentTarget).get("otp") || e.otp;
37
- E({ otp: r, onSuccess: m });
21
+ const { isSignedIn: b } = j(), { state: n } = l(), { signInWithSms: S } = L(), { linkSms: g } = M(), { verifySmsOTP: P } = k(), m = t || n.step, u = n.authMethod === "sms", { transitionRef: N } = G(m, u), { setPhoneNumber: T, submitPhoneNumber: d } = Q({
22
+ submit: (e) => b ? g(e) : S({ phoneNumber: e })
23
+ }), { phoneNumberObject: C, countryCode: O, handlePhoneNumberChange: v, handleCountryCodeChange: I } = z({
24
+ phoneNumber: n.phoneNumber,
25
+ onPhoneNumberChange: T
26
+ }), { resendCountdown: F, resetOTP: w, setOTP: D, startResendTimer: R, submitOtp: W } = J({
27
+ passwordLength: 6,
28
+ submit: (e) => P({ flowId: n.flowId, otp: e })
29
+ }), p = () => {
30
+ R(60);
31
+ }, x = () => {
32
+ w(), d({ phoneNumber: n.phoneNumber, onSuccess: p });
33
+ }, y = (e) => {
34
+ e.preventDefault(), d({ phoneNumber: n.phoneNumber, onSuccess: p });
35
+ }, E = (e) => {
36
+ e.preventDefault();
37
+ const o = new FormData(e.currentTarget).get("otp") || n.otp;
38
+ W({ otp: o, onSuccess: i });
38
39
  };
39
- return z(() => {
40
- d.current !== t && (h.current?.transition.toggle(t), d.current = t);
41
- }, [t]), /* @__PURE__ */ s(
42
- J,
40
+ return /* @__PURE__ */ r(
41
+ q,
43
42
  {
44
- autoFocus: i ? "input[type='tel']" : !1,
43
+ autoFocus: s ? "input[type='tel']" : !1,
45
44
  animateHeight: !1,
46
- items: _,
45
+ items: X,
47
46
  initialEntered: !0,
48
- direction: t === "otp" ? "left" : "right",
49
- transitionRef: h,
50
- children: ({ itemKey: n, ...b }) => {
51
- let r = null;
52
- return n === "phoneNumber" && (r = /* @__PURE__ */ s(
53
- G,
47
+ direction: m === "verification" ? "left" : "right",
48
+ transitionRef: N,
49
+ children: ({ itemKey: e, ...f }) => {
50
+ let o = null;
51
+ return e === "credentials" && (o = /* @__PURE__ */ r(
52
+ V,
54
53
  {
55
- countryCode: y,
56
- error: t === "phoneNumber" && e.error || "",
57
- isPending: e.isPending,
58
- onCountryCodeChange: w,
59
- onPhoneNumberChange: F,
60
- onSubmit: L,
61
- phoneNumber: v
54
+ countryCode: O,
55
+ error: m === e && n.error || "",
56
+ isPending: u && n.status === "pending",
57
+ onCountryCodeChange: I,
58
+ onPhoneNumberChange: v,
59
+ onSubmit: y,
60
+ phoneNumber: C
62
61
  }
63
- )), n === "otp" && (r = /* @__PURE__ */ s(
64
- B,
62
+ )), e === "verification" && (o = /* @__PURE__ */ r(
63
+ H,
65
64
  {
66
- canResetOTP: e.canResetOTP,
67
- error: t === "otp" && e.error || "",
68
- isPending: e.isPending,
69
- onOTPChange: W,
70
- onResendOTP: j,
71
- onSubmit: k,
72
- otp: e.otp,
73
- resendCountdown: R,
74
- successMessage: e.isSuccess ? "Success!" : void 0
65
+ canResetOTP: n.canResetOTP,
66
+ error: m === e && n.error || "",
67
+ isPending: u && n.status === "pending",
68
+ onOTPChange: D,
69
+ onResendOTP: x,
70
+ onSubmit: E,
71
+ otp: n.otp,
72
+ resendCountdown: F,
73
+ successMessage: u && n.status === "success" ? "Success!" : void 0
75
74
  }
76
- )), /* @__PURE__ */ s("div", { ...b, children: a ? a({ step: p, Form: r }) : r });
75
+ )), /* @__PURE__ */ r("div", { ...f, children: h ? h({ step: e, Form: o }) : o });
77
76
  }
78
77
  }
79
78
  );
80
- }, K = ({ step: o }) => /* @__PURE__ */ u(c, { children: [
81
- o === "credentials" && "Sign in",
82
- o === "verification" && "Enter verification code"
83
- ] }), ee = ({ step: o }) => {
84
- const { state: i } = g(), m = A(
85
- () => U(i.phoneNumber),
86
- [i.phoneNumber]
79
+ }, Z = ({ step: t }) => /* @__PURE__ */ c(a, { children: [
80
+ t === "credentials" && "Sign in",
81
+ t === "verification" && "Enter verification code"
82
+ ] }), _ = ({ step: t }) => {
83
+ const { state: s } = l(), i = A(
84
+ () => B(s.phoneNumber),
85
+ [s.phoneNumber]
87
86
  );
88
- return /* @__PURE__ */ u(c, { children: [
89
- o === "credentials" && "We’ll send you a verification code via text.",
90
- o === "verification" && /* @__PURE__ */ u(c, { children: [
87
+ return /* @__PURE__ */ c(a, { children: [
88
+ t === "credentials" && "We’ll send you a verification code via text.",
89
+ t === "verification" && /* @__PURE__ */ c(a, { children: [
91
90
  "Enter the 6 digit code sent to",
92
91
  " ",
93
- m ? /* @__PURE__ */ s(Z, { children: m }) : "your phone number"
92
+ i ? /* @__PURE__ */ r(U, { children: i }) : "your phone number"
94
93
  ] })
95
94
  ] });
96
- }, fe = {
97
- description: ee,
98
- forms: $,
99
- title: K
95
+ }, pe = {
96
+ description: _,
97
+ forms: Y,
98
+ title: Z
100
99
  };
101
100
  export {
102
- $ as SignInWithSms,
103
- ee as SignInWithSmsDescription,
104
- K as SignInWithSmsTitle,
105
- fe as config
101
+ Y as SignInWithSms,
102
+ _ as SignInWithSmsDescription,
103
+ Z as SignInWithSmsTitle,
104
+ pe as config
106
105
  };
@@ -1,40 +1,40 @@
1
1
  import "@coinbase/cdp-hooks";
2
2
  import { useCallback as p, useMemo as m } from "react";
3
3
  import { isApiError as y } from "../../../utils/isApiError.js";
4
- import { useSignInContext as d } from "../SignInProvider.js";
4
+ import { useSignInContext as u } from "../SignInProvider.js";
5
5
  const f = ({
6
- submit: t
6
+ submit: e
7
7
  }) => {
8
- const { state: n, dispatch: o } = d(), a = "An error occurred while signing in. Please try again.", s = p(
9
- (e) => {
10
- o({ type: "SET_EMAIL", payload: { email: e } });
8
+ const { state: a, dispatch: o } = u(), s = "An error occurred while signing in. Please try again.", n = p(
9
+ (t) => {
10
+ o({ type: "SET_EMAIL", payload: { email: t } });
11
11
  },
12
12
  [o]
13
13
  ), i = p(
14
14
  async ({
15
- email: e,
15
+ email: t,
16
16
  onSuccess: l,
17
17
  onError: E
18
18
  }) => {
19
- if (!n.isPending) {
20
- o({ type: "SUBMIT_EMAIL", payload: { email: e } });
19
+ if (a.status !== "pending") {
20
+ o({ type: "SUBMIT_EMAIL", payload: { email: t } });
21
21
  try {
22
- const { flowId: r } = await t(e);
22
+ const { flowId: r } = await e(t);
23
23
  o({ type: "SUBMIT_EMAIL_SUCCESS", payload: { flowId: r } }), l?.();
24
24
  } catch (r) {
25
- const c = y(r) ? r : r instanceof Error && r.message || a;
25
+ const c = y(r) ? r : r instanceof Error && r.message || s;
26
26
  o({ type: "SUBMIT_EMAIL_FAILURE", payload: { error: c } }), console.error(r), E?.(c);
27
27
  }
28
28
  }
29
29
  },
30
- [o, n.isPending, t]
30
+ [o, a.status, e]
31
31
  );
32
32
  return m(
33
33
  () => ({
34
- setEmail: s,
34
+ setEmail: n,
35
35
  submitEmail: i
36
36
  }),
37
- [s, i]
37
+ [n, i]
38
38
  );
39
39
  };
40
40
  export {
@@ -0,0 +1,14 @@
1
+ import { SwitchTransitionRef } from '../../ui/SwitchTransition';
2
+ import { SignInState } from '../types';
3
+ type Step = SignInState["step"];
4
+ /**
5
+ * A hook that transitions between steps in a sign in flow.
6
+ *
7
+ * @param {Step} step - The step to transition to.
8
+ * @param {boolean} isActive - Whether the flow is active.
9
+ * @returns {SwitchTransitionRef<Step>} - The transition ref.
10
+ */
11
+ export declare const useFlowTransition: (step: Step, isActive: boolean) => {
12
+ transitionRef: import('react').RefObject<SwitchTransitionRef<"verification" | "credentials"> | null>;
13
+ };
14
+ export {};
@@ -0,0 +1,13 @@
1
+ import { useRef as u, useLayoutEffect as e } from "react";
2
+ import "react/jsx-runtime";
3
+ import "@coinbase/cdp-hooks";
4
+ import "../../../chunks/CDPReactProvider.BWInVuNJ.js";
5
+ const l = (r, t) => {
6
+ const n = u(null), o = u(r);
7
+ return e(() => {
8
+ !t || o.current === r || (n.current?.transition.toggle(r), o.current = r);
9
+ }, [t, r]), { transitionRef: n };
10
+ };
11
+ export {
12
+ l as useFlowTransition
13
+ };
@@ -1,57 +1,57 @@
1
1
  import "@coinbase/cdp-hooks";
2
- import { useCallback as i, useEffect as l, useMemo as u } from "react";
2
+ import { useCallback as a, useEffect as f, useMemo as l } from "react";
3
3
  import { useTimer as E } from "../../../hooks/useTimer.js";
4
4
  import { isApiError as S } from "../../../utils/isApiError.js";
5
5
  import { useSignInContext as _ } from "../SignInProvider.js";
6
6
  const A = ({
7
- passwordLength: a,
7
+ passwordLength: i,
8
8
  submit: T
9
9
  }) => {
10
- const { state: n, dispatch: e } = _(), {
10
+ const { state: s, dispatch: e } = _(), {
11
11
  timeRemaining: o,
12
12
  start: c,
13
- reset: r
14
- } = E(), p = "An error occurred while signing in. Please try again.", m = i(
15
- (t) => {
16
- e({ type: "SET_OTP", payload: { otp: t } });
13
+ reset: t
14
+ } = E(), p = "An error occurred while signing in. Please try again.", m = a(
15
+ (r) => {
16
+ e({ type: "SET_OTP", payload: { otp: r } });
17
17
  },
18
18
  [e]
19
- ), y = i(
19
+ ), y = a(
20
20
  async ({
21
- otp: t,
22
- onSuccess: d,
23
- onError: f
21
+ otp: r,
22
+ onSuccess: P,
23
+ onError: d
24
24
  }) => {
25
- if (!n.isPending) {
26
- if (t.length !== a) {
27
- e({ type: "SET_OTP", payload: { otp: t } });
25
+ if (s.status !== "pending") {
26
+ if (r.length !== i) {
27
+ e({ type: "SET_OTP", payload: { otp: r } });
28
28
  return;
29
29
  }
30
- e({ type: "SUBMIT_OTP", payload: { otp: t } });
30
+ e({ type: "SUBMIT_OTP", payload: { otp: r } });
31
31
  try {
32
- await T(t), e({ type: "SUBMIT_OTP_SUCCESS", payload: { otp: t } }), d?.(), r();
33
- } catch (s) {
34
- const O = S(s) ? s : s instanceof Error && s.message || p;
35
- e({ type: "SUBMIT_OTP_FAILURE", payload: { error: O } }), console.error(s), f?.(O);
32
+ await T(r), e({ type: "SUBMIT_OTP_SUCCESS", payload: { otp: r } }), P?.(), t();
33
+ } catch (n) {
34
+ const O = S(n) ? n : n instanceof Error && n.message || p;
35
+ e({ type: "SUBMIT_OTP_FAILURE", payload: { error: O } }), console.error(n), d?.(O);
36
36
  }
37
37
  }
38
38
  },
39
- [e, n.isPending, a, T, r]
40
- ), P = i(() => {
41
- e({ type: "RESET_OTP" }), r();
42
- }, [e, r]);
43
- return l(() => {
44
- o === 0 && n.step === "verification" && !n.canResetOTP && (e({ type: "ALLOW_RESET_OTP" }), r());
45
- }, [o, r, n.step, n.canResetOTP, e]), u(
39
+ [e, s.status, i, T, t]
40
+ ), u = a(() => {
41
+ e({ type: "RESET_OTP" }), t();
42
+ }, [e, t]);
43
+ return f(() => {
44
+ o === 0 && s.step === "verification" && !s.canResetOTP && (e({ type: "ALLOW_RESET_OTP" }), t());
45
+ }, [o, t, s.step, s.canResetOTP, e]), l(
46
46
  () => ({
47
47
  resendCountdown: o,
48
- resetOTP: P,
49
- resetResendTimer: r,
48
+ resetOTP: u,
49
+ resetResendTimer: t,
50
50
  setOTP: m,
51
51
  startResendTimer: c,
52
52
  submitOtp: y
53
53
  }),
54
- [o, P, r, m, c, y]
54
+ [o, u, t, m, c, y]
55
55
  );
56
56
  };
57
57
  export {
@@ -1,11 +1,11 @@
1
1
  import "@coinbase/cdp-hooks";
2
- import { useCallback as p, useMemo as l } from "react";
3
- import { isApiError as y } from "../../../utils/isApiError.js";
4
- import { useSignInContext as d } from "../SignInProvider.js";
5
- const U = ({
2
+ import { useCallback as p, useMemo as u } from "react";
3
+ import { isApiError as l } from "../../../utils/isApiError.js";
4
+ import { useSignInContext as y } from "../SignInProvider.js";
5
+ const M = ({
6
6
  submit: t
7
7
  }) => {
8
- const { state: n, dispatch: o } = d(), s = "An error occurred while signing in. Please try again.", a = p(
8
+ const { state: s, dispatch: o } = y(), n = "An error occurred while signing in. Please try again.", a = p(
9
9
  (e) => {
10
10
  o({ type: "SET_PHONE_NUMBER", payload: { phoneNumber: e } });
11
11
  },
@@ -16,20 +16,20 @@ const U = ({
16
16
  onSuccess: E,
17
17
  onError: m
18
18
  }) => {
19
- if (!n.isPending) {
19
+ if (s.status !== "pending") {
20
20
  o({ type: "SUBMIT_PHONE_NUMBER", payload: { phoneNumber: e } });
21
21
  try {
22
22
  const { flowId: r } = await t(e);
23
23
  o({ type: "SUBMIT_PHONE_NUMBER_SUCCESS", payload: { flowId: r } }), E?.();
24
24
  } catch (r) {
25
- const c = y(r) ? r : r instanceof Error && r.message || s;
25
+ const c = l(r) ? r : r instanceof Error && r.message || n;
26
26
  o({ type: "SUBMIT_PHONE_NUMBER_FAILURE", payload: { error: c } }), console.error(r), m?.(c);
27
27
  }
28
28
  }
29
29
  },
30
- [o, n.isPending, t]
30
+ [o, s.status, t]
31
31
  );
32
- return l(
32
+ return u(
33
33
  () => ({
34
34
  setPhoneNumber: a,
35
35
  submitPhoneNumber: i
@@ -38,5 +38,5 @@ const U = ({
38
38
  );
39
39
  };
40
40
  export {
41
- U as usePhoneNumberForm
41
+ M as usePhoneNumberForm
42
42
  };
@@ -0,0 +1,10 @@
1
+ import { SiweProviderType } from '../../SiweStatusView';
2
+ /**
3
+ * Bridges useSiweFlow to the SignIn reducer so the inline status view reflects the attempt.
4
+ *
5
+ * @param {SiweProviderType} provider - The SIWE provider to authenticate with.
6
+ * @returns {(onSuccess?: () => void) => Promise<void>} A function that starts the SIWE flow.
7
+ *
8
+ * @see {@link useSiweFlow}
9
+ */
10
+ export declare const useStartSiwe: (provider: SiweProviderType) => (onSuccess?: () => void) => Promise<void>;
@@ -0,0 +1,24 @@
1
+ import { useCallback as p } from "react";
2
+ import "react/jsx-runtime";
3
+ import "@coinbase/cdp-hooks";
4
+ import "../../ui/Button/index.js";
5
+ import "@coinbase/cdp-core";
6
+ import { useSiweFlow as s } from "../../SiweStatusView/useSiweFlow.js";
7
+ import "libphonenumber-js";
8
+ import { useSignInContext as a } from "../SignInProvider.js";
9
+ const y = (o) => {
10
+ const { dispatch: t } = a(), { start: r } = s(o);
11
+ return p(
12
+ (S) => r({
13
+ onStart: () => t({ type: "SUBMIT_SIWE", payload: { authMethod: `siwe:${o}` } }),
14
+ onSuccess: () => {
15
+ t({ type: "SUBMIT_SIWE_SUCCESS" }), S?.();
16
+ },
17
+ onError: (e) => t({ type: "SUBMIT_SIWE_FAILURE", payload: { error: e ?? "" } })
18
+ }),
19
+ [r, t, o]
20
+ );
21
+ };
22
+ export {
23
+ y as useStartSiwe
24
+ };
@@ -8,7 +8,7 @@ import { SignInForm, SignInFormProps } from './SignInForm';
8
8
  import { SignInImage, SignInImageProps } from './SignInImage';
9
9
  import { useSignInContext } from './SignInProvider';
10
10
  import { SignInTitle, SignInTitleProps } from './SignInTitle';
11
- import { SignInState, SignInAction } from './types';
11
+ import { SignInState, SignInAction, SignInStatus } from './types';
12
12
  /**
13
13
  * Props for the SignIn component
14
14
  */
@@ -139,4 +139,4 @@ export interface SignInProps extends Omit<HTMLAttributes<HTMLDivElement>, "child
139
139
  * ```
140
140
  */
141
141
  export declare const SignIn: ({ authMethods, ...props }: SignInProps) => import("react/jsx-runtime").JSX.Element;
142
- export { SignInAuthMethodButtons, SignInBackButton, SignInDescription, SignInFooter, SignInForm, SignInImage, SignInTitle, useSignInContext, type SignInAuthMethodButtonsProps, type SignInBackButtonProps, type SignInDescriptionProps, type SignInFormProps, type SignInImageProps, type SignInTitleProps, type SignInState, type SignInAction, };
142
+ export { SignInAuthMethodButtons, SignInBackButton, SignInDescription, SignInFooter, SignInForm, SignInImage, SignInTitle, useSignInContext, type SignInAuthMethodButtonsProps, type SignInBackButtonProps, type SignInDescriptionProps, type SignInFormProps, type SignInImageProps, type SignInTitleProps, type SignInState, type SignInAction, type SignInStatus, };
@@ -1,54 +1,54 @@
1
- import { jsx as n, jsxs as r, Fragment as c } from "react/jsx-runtime";
2
- import { u } from "../../chunks/useSendComponentCallOnce.BI4daEvm.js";
1
+ import { jsx as n, jsxs as e, Fragment as p } from "react/jsx-runtime";
2
+ import { u as f } from "../../chunks/useSendComponentCallOnce.BI4daEvm.js";
3
3
  import "react";
4
- import { u as d } from "../../chunks/CDPReactProvider.CFWIUvzR.js";
5
- import { SignInAuthMethodButtons as f } from "./SignInAuthMethodButtons.js";
4
+ import { u } from "../../chunks/CDPReactProvider.BWInVuNJ.js";
5
+ import { SignInAuthMethodButtons as d } from "./SignInAuthMethodButtons.js";
6
6
  import { SignInBackButton as I } from "./SignInBackButton.js";
7
7
  import { SignInDescription as S } from "./SignInDescription.js";
8
8
  import { SignInFooter as b } from "./SignInFooter.js";
9
9
  import { SignInForm as k } from "./SignInForm.js";
10
10
  import { SignInImage as w } from "./SignInImage.js";
11
- import { SignInProvider as C, useSignInContext as h } from "./SignInProvider.js";
12
- import { SignInTitle as v } from "./SignInTitle.js";
11
+ import { SignInProvider as v, useSignInContext as C } from "./SignInProvider.js";
12
+ import { SignInTitle as N } from "./SignInTitle.js";
13
13
  import "@coinbase/cdp-hooks";
14
- import '../../assets/SignIn.css';const F = "SignIn-module__footer___3Gkbc", t = {
14
+ import '../../assets/SignIn.css';const x = "SignIn-module__footer___3Gkbc", r = {
15
15
  "sign-in": "SignIn-module__sign-in___cYpee",
16
16
  "title-desc-wrapper": "SignIn-module__title-desc-wrapper___VpPcA",
17
17
  "back-button": "SignIn-module__back-button___bmE-y",
18
18
  "back-button-wrapper": "SignIn-module__back-button-wrapper___Q9FA1",
19
- footer: F
20
- }, N = ({
21
- className: e = "",
19
+ footer: x
20
+ }, A = ({
21
+ className: m = "",
22
22
  children: o,
23
- onSuccess: p,
24
- ...a
23
+ onSuccess: s,
24
+ ..._
25
25
  }) => {
26
- const { state: _ } = h(), { showCoinbaseFooter: g } = d(), s = typeof o == "function" ? o(_) : o;
27
- return /* @__PURE__ */ r("div", { className: `${t["sign-in"]} ${e}`, ...a, children: [
28
- s,
29
- !s && /* @__PURE__ */ r(c, { children: [
30
- /* @__PURE__ */ n("div", { className: t["back-button-wrapper"], children: /* @__PURE__ */ n(I, { className: t["back-button"] }) }),
31
- /* @__PURE__ */ n(w, {}),
32
- /* @__PURE__ */ n(k, { onSuccess: p, children: ({ authMethod: i, step: m, Form: l }) => /* @__PURE__ */ r(c, { children: [
33
- /* @__PURE__ */ r("div", { className: t["title-desc-wrapper"], children: [
34
- /* @__PURE__ */ n(v, { step: m, authMethod: i }),
35
- /* @__PURE__ */ n(S, { step: m, authMethod: i })
26
+ const { state: g } = C(), { showCoinbaseFooter: l } = u(), c = typeof o == "function" ? o(g) : o;
27
+ return /* @__PURE__ */ e("div", { className: `${r["sign-in"]} ${m}`, ..._, children: [
28
+ c,
29
+ !c && /* @__PURE__ */ e(p, { children: [
30
+ /* @__PURE__ */ n("div", { className: r["back-button-wrapper"], children: /* @__PURE__ */ n(I, { className: r["back-button"] }) }),
31
+ /* @__PURE__ */ n(k, { onSuccess: s, children: ({ authMethod: t, step: i, Form: a }) => t.startsWith("siwe:") && i === "verification" ? a : /* @__PURE__ */ e(p, { children: [
32
+ /* @__PURE__ */ n(w, { authMethod: t, step: i }),
33
+ /* @__PURE__ */ e("div", { className: r["title-desc-wrapper"], children: [
34
+ /* @__PURE__ */ n(N, { step: i, authMethod: t }),
35
+ /* @__PURE__ */ n(S, { step: i, authMethod: t })
36
36
  ] }),
37
- l,
38
- m === "credentials" && /* @__PURE__ */ n(f, { activeMethod: i })
37
+ a,
38
+ i === "credentials" && /* @__PURE__ */ n(d, { activeMethod: t, onSuccess: s })
39
39
  ] }) }),
40
- g && /* @__PURE__ */ n(b, { className: t.footer })
40
+ l && /* @__PURE__ */ n(b, { className: r.footer })
41
41
  ] })
42
42
  ] });
43
- }, V = ({ authMethods: e, ...o }) => (u("sign_in"), /* @__PURE__ */ n(C, { authMethods: e, children: /* @__PURE__ */ n(N, { ...o }) }));
43
+ }, V = ({ authMethods: m, ...o }) => (f("sign_in"), /* @__PURE__ */ n(v, { authMethods: m, children: /* @__PURE__ */ n(A, { ...o }) }));
44
44
  export {
45
45
  V as SignIn,
46
- f as SignInAuthMethodButtons,
46
+ d as SignInAuthMethodButtons,
47
47
  I as SignInBackButton,
48
48
  S as SignInDescription,
49
49
  b as SignInFooter,
50
50
  k as SignInForm,
51
51
  w as SignInImage,
52
- v as SignInTitle,
53
- h as useSignInContext
52
+ N as SignInTitle,
53
+ C as useSignInContext
54
54
  };
@@ -21,10 +21,11 @@ export interface SignInTitleAndDescriptionProps {
21
21
  * @property {string} email - The email address of the user.
22
22
  * @property {string | APIError | null} error - The error message or APIError object.
23
23
  * @property {string} flowId - The flow ID of the current sign-in flow.
24
- * @property {boolean} isPending - Whether the form state is pending.
25
- * @property {boolean} isSuccess - Whether the sign-in flow is successful.
24
+ * @property {boolean} isPending - Whether the form state is pending. **Deprecated**: use `status === "pending"`.
25
+ * @property {boolean} isSuccess - Whether the sign-in flow is successful. **Deprecated**: use `status === "success"`.
26
26
  * @property {string} otp - The OTP code entered by the user.
27
27
  * @property {string} phoneNumber - The phone number of the user.
28
+ * @property {SignInStatus} status - The current status of the active flow.
28
29
  * @property {AuthMethod | "otp" | "success"} step - The current step of the sign-in flow.
29
30
  *
30
31
  * @see {@link SignIn}
@@ -37,12 +38,20 @@ export interface SignInState {
37
38
  email: string;
38
39
  error: string | APIError | null;
39
40
  flowId: string;
41
+ /** @deprecated Use `status === "pending"` instead. */
40
42
  isPending: boolean;
43
+ /** @deprecated Use `status === "success"` instead. */
41
44
  isSuccess: boolean;
42
45
  otp: string;
43
46
  phoneNumber: string;
47
+ /** The current status of the active flow. */
48
+ status: SignInStatus;
44
49
  step: "credentials" | "verification";
45
50
  }
51
+ /**
52
+ * The status of the active sign-in flow.
53
+ */
54
+ export type SignInStatus = "idle" | "pending" | "success" | "error";
46
55
  /**
47
56
  * The actions that can be performed on the SignIn state.
48
57
  *
@@ -129,6 +138,18 @@ export type SignInAction = {
129
138
  type: "GO_TO_PREVIOUS_STEP";
130
139
  } | {
131
140
  type: "RESET_STATE";
141
+ } | {
142
+ type: "SUBMIT_SIWE";
143
+ payload: {
144
+ authMethod: AuthMethod;
145
+ };
146
+ } | {
147
+ type: "SUBMIT_SIWE_SUCCESS";
148
+ } | {
149
+ type: "SUBMIT_SIWE_FAILURE";
150
+ payload: {
151
+ error: string | APIError;
152
+ };
132
153
  };
133
154
  /**
134
155
  * Shared props for a sign in flow.
@@ -150,3 +171,4 @@ export interface SignInFlowConfig {
150
171
  description: FC<SignInTitleAndDescriptionProps>;
151
172
  title: FC<SignInTitleAndDescriptionProps>;
152
173
  }
174
+ export declare const STEPS: ["credentials", "verification"];
@@ -1,3 +1,7 @@
1
1
  import "@coinbase/cdp-hooks";
2
2
  import "react";
3
- import "../../chunks/CDPReactProvider.CFWIUvzR.js";
3
+ import "../../chunks/CDPReactProvider.BWInVuNJ.js";
4
+ const r = ["credentials", "verification"];
5
+ export {
6
+ r as STEPS
7
+ };