@coinbase/cdp-react 0.0.85 → 0.0.87

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) 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.C38bKQ2x.js +337 -0
  10. package/dist/chunks/{LinkAuthFlow.BaUSMzGH.js → LinkAuthFlow.CLubKoY0.js} +13 -13
  11. package/dist/chunks/{index.C_DV0Ud7.js → index.BN39qScu.js} +1 -1
  12. package/dist/chunks/index.BX4k-ruQ.js +12 -0
  13. package/dist/chunks/index.Bgx0-QLY.js +12 -0
  14. package/dist/components/CDPReactProvider/index.js +1 -1
  15. package/dist/components/EnrollMfa/EnrollMfaDescription.js +4 -3
  16. package/dist/components/EnrollMfa/EnrollMfaFlow.js +27 -26
  17. package/dist/components/EnrollMfa/EnrollMfaFlowBackButton.js +7 -6
  18. package/dist/components/EnrollMfa/EnrollMfaFlowProvider.d.ts +1 -1
  19. package/dist/components/EnrollMfa/EnrollMfaFlowProvider.js +5 -4
  20. package/dist/components/EnrollMfa/EnrollMfaImage.js +7 -6
  21. package/dist/components/EnrollMfa/EnrollMfaItem.js +7 -6
  22. package/dist/components/EnrollMfa/EnrollMfaItems.js +28 -25
  23. package/dist/components/EnrollMfa/EnrollMfaProvider.js +22 -17
  24. package/dist/components/EnrollMfa/EnrollMfaTitle.js +8 -7
  25. package/dist/components/EnrollMfa/index.js +138 -123
  26. package/dist/components/EnrollMfa/methods/sms.d.ts +6 -0
  27. package/dist/components/EnrollMfa/methods/sms.js +148 -0
  28. package/dist/components/EnrollMfa/methods/totp.js +24 -19
  29. package/dist/components/EnrollMfa/types.d.ts +17 -5
  30. package/dist/components/EnrollMfa/types.js +1 -0
  31. package/dist/components/EnrollMfa/useEnrollMfaReducer.js +51 -38
  32. package/dist/components/EnrollMfaModal/index.js +1 -1
  33. package/dist/components/ExportWallet/index.js +109 -101
  34. package/dist/components/ExportWalletModal/index.js +1 -1
  35. package/dist/components/Fund/index.js +1 -1
  36. package/dist/components/FundModal/index.js +1 -1
  37. package/dist/components/LinkAuth/LinkAuthFlow.js +2 -2
  38. package/dist/components/LinkAuth/LinkAuthFlowBackButton.js +2 -2
  39. package/dist/components/LinkAuth/LinkAuthFlowProvider.js +2 -2
  40. package/dist/components/LinkAuth/LinkAuthItem.js +1 -1
  41. package/dist/components/LinkAuth/LinkAuthItems.js +1 -1
  42. package/dist/components/LinkAuth/LinkAuthProvider.js +1 -1
  43. package/dist/components/LinkAuth/index.js +59 -60
  44. package/dist/components/LinkAuth/types.js +1 -1
  45. package/dist/components/LinkAuth/utils.js +1 -1
  46. package/dist/components/LinkAuthModal/index.js +2 -2
  47. package/dist/components/OAuthStatusModal/index.js +1 -1
  48. package/dist/components/SignIn/SignInAuthMethodButtons.js +1 -1
  49. package/dist/components/SignIn/SignInBackButton.js +12 -12
  50. package/dist/components/SignIn/SignInDescription.js +2 -2
  51. package/dist/components/SignIn/SignInForm.js +2 -2
  52. package/dist/components/SignIn/SignInImage.js +1 -1
  53. package/dist/components/SignIn/SignInProvider.js +1 -1
  54. package/dist/components/SignIn/SignInTitle.js +2 -2
  55. package/dist/components/SignIn/flows/SignInWithEmail.js +1 -1
  56. package/dist/components/SignIn/flows/SignInWithOAuth.js +1 -1
  57. package/dist/components/SignIn/flows/SignInWithSms.js +74 -84
  58. package/dist/components/SignIn/index.js +1 -1
  59. package/dist/components/SignIn/types.d.ts +2 -0
  60. package/dist/components/SignIn/types.js +1 -1
  61. package/dist/components/SignIn/useSignInReducer.js +20 -6
  62. package/dist/components/SignInModal/index.js +1 -1
  63. package/dist/components/VerifyMfa/VerifyMfaDescription.d.ts +1 -1
  64. package/dist/components/VerifyMfa/VerifyMfaDescription.js +24 -14
  65. package/dist/components/VerifyMfa/VerifyMfaFlow.d.ts +5 -4
  66. package/dist/components/VerifyMfa/VerifyMfaFlow.js +52 -13
  67. package/dist/components/VerifyMfa/VerifyMfaFlowBackButton.d.ts +9 -0
  68. package/dist/components/VerifyMfa/VerifyMfaFlowBackButton.js +40 -0
  69. package/dist/components/VerifyMfa/VerifyMfaFlowProvider.d.ts +23 -0
  70. package/dist/components/VerifyMfa/VerifyMfaFlowProvider.js +37 -0
  71. package/dist/components/VerifyMfa/VerifyMfaImage.d.ts +1 -1
  72. package/dist/components/VerifyMfa/VerifyMfaImage.js +25 -13
  73. package/dist/components/VerifyMfa/VerifyMfaItem.d.ts +10 -0
  74. package/dist/components/VerifyMfa/VerifyMfaItem.js +27 -0
  75. package/dist/components/VerifyMfa/VerifyMfaItems.d.ts +9 -0
  76. package/dist/components/VerifyMfa/VerifyMfaItems.js +31 -0
  77. package/dist/components/VerifyMfa/VerifyMfaProvider.js +27 -14
  78. package/dist/components/VerifyMfa/VerifyMfaTitle.d.ts +1 -1
  79. package/dist/components/VerifyMfa/VerifyMfaTitle.js +23 -13
  80. package/dist/components/VerifyMfa/index.d.ts +6 -2
  81. package/dist/components/VerifyMfa/index.js +23 -14
  82. package/dist/components/VerifyMfa/methods/sms.d.ts +6 -0
  83. package/dist/components/VerifyMfa/methods/sms.js +90 -0
  84. package/dist/components/VerifyMfa/methods/totp.js +40 -39
  85. package/dist/components/VerifyMfa/types.d.ts +21 -2
  86. package/dist/components/VerifyMfa/types.js +1 -0
  87. package/dist/components/VerifyMfa/useVerifyMfaReducer.d.ts +2 -1
  88. package/dist/components/VerifyMfa/useVerifyMfaReducer.js +29 -4
  89. package/dist/components/VerifyMfaInline/index.d.ts +1 -1
  90. package/dist/components/VerifyMfaInline/index.js +133 -116
  91. package/dist/components/VerifyMfaModal/index.js +7 -5
  92. package/dist/components/ui/SwitchTransition/index.js +3 -3
  93. package/dist/hooks/usePhoneNumberState.d.ts +15 -0
  94. package/dist/hooks/usePhoneNumberState.js +39 -0
  95. package/dist/hooks/useTimeout.d.ts +4 -0
  96. package/dist/hooks/useTimeout.js +16 -0
  97. package/dist/hooks/useTransitionMap.js +58 -50
  98. package/dist/hooks/useVerifyMfaModal.js +1 -1
  99. package/dist/index.js +59 -51
  100. package/dist/utils/transition.d.ts +3 -3
  101. package/dist/utils/transition.js +21 -20
  102. package/dist/version.d.ts +1 -1
  103. package/dist/version.js +1 -1
  104. package/package.json +6 -6
  105. package/dist/chunks/CDPReactProvider.CIQm4C4z.js +0 -299
  106. package/dist/chunks/index.CKQKBoX2.js +0 -9
  107. package/dist/chunks/index.Dp-lIxM1.js +0 -9
@@ -1,93 +1,92 @@
1
- import { jsx as r, jsxs as h, Fragment as w } from "react/jsx-runtime";
2
- import { useLinkOAuth as C } from "@coinbase/cdp-hooks";
3
- import { u as I } from "../../chunks/useSendComponentCallOnce.BHZMuo6E.js";
4
- import { useRef as d, useState as N, useCallback as u } from "react";
5
- import "../../chunks/CDPReactProvider.CIQm4C4z.js";
6
- import { useOauthStatusModal as P } from "../OAuthStatusModal/index.js";
7
- import { Banner as U } from "../ui/Banner/index.js";
8
- import { getMessageFromUnknownError as D } from "../../utils/getMessageFromUnknownError.js";
1
+ import { jsx as r, jsxs as h, Fragment as C } from "react/jsx-runtime";
2
+ import { useLinkOAuth as I } from "@coinbase/cdp-hooks";
3
+ import { u as N } from "../../chunks/useSendComponentCallOnce.BHZMuo6E.js";
4
+ import { useRef as d, useState as P, useCallback as a } from "react";
5
+ import "../../chunks/CDPReactProvider.C38bKQ2x.js";
6
+ import { useOauthStatusModal as U } from "../OAuthStatusModal/index.js";
7
+ import { Banner as D } from "../ui/Banner/index.js";
8
+ import { useTimeout as H } from "../../hooks/useTimeout.js";
9
+ import { getMessageFromUnknownError as M } from "../../utils/getMessageFromUnknownError.js";
9
10
  import "libphonenumber-js";
10
- import { toOAuthProviderType as H } from "../../utils/toOAuthProviderType.js";
11
- import { L as M, a as v } from "../../chunks/LinkAuthFlow.BaUSMzGH.js";
12
- import { u as mt } from "../../chunks/LinkAuthFlow.BaUSMzGH.js";
13
- import { LinkAuthFlowBackButton as V } from "./LinkAuthFlowBackButton.js";
14
- import { LinkAuthItem as dt } from "./LinkAuthItem.js";
15
- import { LinkAuthItems as ft } from "./LinkAuthItems.js";
16
- import { useLinkAuthContext as y, LinkAuthProvider as j } from "./LinkAuthProvider.js";
17
- import { LinkAuthTitle as K } from "./LinkAuthTitle.js";
18
- import { methodToView as g } from "./utils.js";
19
- import '../../assets/LinkAuth.css';const W = "LinkAuth-module__header___0UuxP", $ = "LinkAuth-module__error___XUo4W", k = {
11
+ import { toOAuthProviderType as v } from "../../utils/toOAuthProviderType.js";
12
+ import { L as V, a as j } from "../../chunks/LinkAuthFlow.CLubKoY0.js";
13
+ import { u as kt } from "../../chunks/LinkAuthFlow.CLubKoY0.js";
14
+ import { LinkAuthFlowBackButton as K } from "./LinkAuthFlowBackButton.js";
15
+ import { LinkAuthItem as pt } from "./LinkAuthItem.js";
16
+ import { LinkAuthItems as At } from "./LinkAuthItems.js";
17
+ import { useLinkAuthContext as O, LinkAuthProvider as W } from "./LinkAuthProvider.js";
18
+ import { LinkAuthTitle as $ } from "./LinkAuthTitle.js";
19
+ import { methodToView as y } from "./utils.js";
20
+ import '../../assets/LinkAuth.css';const b = "LinkAuth-module__header___0UuxP", G = "LinkAuth-module__error___XUo4W", k = {
20
21
  "link-auth": "LinkAuth-module__link-auth___kPJao",
21
- header: W,
22
- error: $
23
- }, b = ({ role: o = "alert", ...c }) => {
24
- const { state: i } = y(), { error: s } = i;
25
- return s ? /* @__PURE__ */ r(U, { variant: "error", role: o, ...c, children: s }) : null;
26
- }, G = ({ children: o, className: c = "", onLinkSuccess: i, ...s }) => {
27
- const { linkOAuth: f } = C(), { persistOAuthState: p } = P(), { state: a, dispatch: n } = y(), { methodToLink: O } = a, L = d(null), l = d(null), x = g(O), A = d(x), [E, m] = N("left"), e = u(
22
+ header: b,
23
+ error: G
24
+ }, J = ({ role: o = "alert", ...c }) => {
25
+ const { state: i } = O(), { error: s } = i;
26
+ return s ? /* @__PURE__ */ r(D, { variant: "error", role: o, ...c, children: s }) : null;
27
+ }, X = ({ children: o, className: c = "", onLinkSuccess: i, ...s }) => {
28
+ const { linkOAuth: f } = I(), { persistOAuthState: p } = U(), { state: u, dispatch: n } = O(), { methodToLink: x } = u, L = d(null), l = d(null), { schedule: A } = H(), E = y(x), _ = d(E), [B, m] = P("left"), e = a(
28
29
  (t) => {
29
- A.current !== t && (A.current = t, L.current?.transition.toggle(t), t === "list" && n({ type: "RESET_STATE" }), (t === "email" || t === "sms") && n({ type: "LINK_AUTH_METHOD", payload: { method: t } }));
30
+ _.current !== t && (_.current = t, L.current?.transition.toggle(t), t === "list" && n({ type: "RESET_STATE" }), (t === "email" || t === "sms") && n({ type: "LINK_AUTH_METHOD", payload: { method: t } }));
30
31
  },
31
32
  [n]
32
- ), B = u(() => {
33
+ ), F = a(() => {
33
34
  if (m("right"), l.current?.canGoBack) {
34
35
  l.current.goBack();
35
36
  return;
36
37
  }
37
38
  e("list");
38
- }, [e]), F = u(() => {
39
- m("left"), i?.(a.methodToLink), setTimeout(() => {
40
- e("list");
41
- }, 800);
42
- }, [e, a.methodToLink, i]), R = u(
39
+ }, [e]), R = a(() => {
40
+ m("left"), i?.(u.methodToLink), A(() => e("list"), 800);
41
+ }, [e, u.methodToLink, i, A]), S = a(
43
42
  async (t) => {
44
43
  if (m("left"), t?.startsWith("oauth:")) {
45
- const T = H(t);
46
- if (T)
44
+ const g = v(t);
45
+ if (g)
47
46
  try {
48
- await f(T), p(!0);
49
- } catch (S) {
47
+ await f(g), p(!0);
48
+ } catch (w) {
50
49
  n({
51
50
  type: "LINK_AUTH_METHOD_ERROR",
52
- payload: { error: D(S) }
51
+ payload: { error: M(w) }
53
52
  });
54
53
  }
55
54
  } else
56
- e(g(t));
55
+ e(y(t));
57
56
  },
58
57
  [f, e, p, n]
59
- ), _ = typeof o == "function" ? o(a) : o;
58
+ ), T = typeof o == "function" ? o(u) : o;
60
59
  return /* @__PURE__ */ r("div", { className: `${k["link-auth"]} ${c}`, ...s, children: /* @__PURE__ */ h(
61
- M,
60
+ V,
62
61
  {
63
- direction: E,
64
- onBack: B,
65
- onLink: R,
66
- onLinkSuccess: F,
62
+ direction: B,
63
+ onBack: F,
64
+ onLink: S,
65
+ onLinkSuccess: R,
67
66
  signInRef: l,
68
67
  transitionRef: L,
69
68
  children: [
70
- _,
71
- !_ && /* @__PURE__ */ h(w, { children: [
69
+ T,
70
+ !T && /* @__PURE__ */ h(C, { children: [
72
71
  /* @__PURE__ */ h("div", { className: k.header, children: [
73
- /* @__PURE__ */ r(K, {}),
74
- /* @__PURE__ */ r(V, {})
72
+ /* @__PURE__ */ r($, {}),
73
+ /* @__PURE__ */ r(K, {})
75
74
  ] }),
76
- /* @__PURE__ */ r("div", { className: k.error, children: /* @__PURE__ */ r(b, {}) }),
77
- /* @__PURE__ */ r(v, {})
75
+ /* @__PURE__ */ r("div", { className: k.error, children: /* @__PURE__ */ r(J, {}) }),
76
+ /* @__PURE__ */ r(j, {})
78
77
  ] })
79
78
  ]
80
79
  }
81
80
  ) });
82
- }, ut = (o) => (I("manage_auth"), /* @__PURE__ */ r(j, { children: /* @__PURE__ */ r(G, { ...o }) }));
81
+ }, mt = (o) => (N("manage_auth"), /* @__PURE__ */ r(W, { children: /* @__PURE__ */ r(X, { ...o }) }));
83
82
  export {
84
- ut as LinkAuth,
85
- b as LinkAuthError,
86
- v as LinkAuthFlow,
87
- V as LinkAuthFlowBackButton,
88
- dt as LinkAuthItem,
89
- ft as LinkAuthItems,
90
- K as LinkAuthTitle,
91
- y as useLinkAuthContext,
92
- mt as useLinkAuthFlow
83
+ mt as LinkAuth,
84
+ J as LinkAuthError,
85
+ j as LinkAuthFlow,
86
+ K as LinkAuthFlowBackButton,
87
+ pt as LinkAuthItem,
88
+ At as LinkAuthItems,
89
+ $ as LinkAuthTitle,
90
+ O as useLinkAuthContext,
91
+ kt as useLinkAuthFlow
93
92
  };
@@ -1,4 +1,4 @@
1
- import "../../chunks/CDPReactProvider.CIQm4C4z.js";
1
+ import "../../chunks/CDPReactProvider.C38bKQ2x.js";
2
2
  const t = ["list", "email", "sms"];
3
3
  export {
4
4
  t as LINK_AUTH_FLOW_VIEWS
@@ -1,4 +1,4 @@
1
- import "../../chunks/CDPReactProvider.CIQm4C4z.js";
1
+ import "../../chunks/CDPReactProvider.C38bKQ2x.js";
2
2
  import { LINK_AUTH_FLOW_VIEWS as i } from "./types.js";
3
3
  const t = (r) => i.includes(r), o = (r) => r && t(r) ? r : "list";
4
4
  export {
@@ -2,7 +2,7 @@ import { jsx as o, jsxs as n, Fragment as d } from "react/jsx-runtime";
2
2
  import { u as p } from "../../chunks/useSendComponentCallOnce.BHZMuo6E.js";
3
3
  import { createContext as f, useMemo as L, useContext as g } from "react";
4
4
  import { c as A } from "../../chunks/lite.1fxw3LjI.js";
5
- import "../../chunks/CDPReactProvider.CIQm4C4z.js";
5
+ import "../../chunks/CDPReactProvider.C38bKQ2x.js";
6
6
  import { LinkAuth as C, LinkAuthError as x } from "../LinkAuth/index.js";
7
7
  import { Button as m } from "../ui/Button/index.js";
8
8
  import { Modal as b, ModalContent as v, ModalTitle as w, ModalClose as N, ModalTrigger as T } from "../ui/Modal/index.js";
@@ -11,7 +11,7 @@ import { IconXMark as F } from "../../icons/IconXMark.js";
11
11
  import { childrenHasComponent as c } from "../../utils/childrenHasComponent.js";
12
12
  import { LinkAuthTitle as H } from "../LinkAuth/LinkAuthTitle.js";
13
13
  import { LinkAuthFlowBackButton as j } from "../LinkAuth/LinkAuthFlowBackButton.js";
14
- import { a as B } from "../../chunks/LinkAuthFlow.BaUSMzGH.js";
14
+ import { a as B } from "../../chunks/LinkAuthFlow.CLubKoY0.js";
15
15
  import '../../assets/LinkAuthModal.css';const S = "LinkAuthModal-module__header___qoco6", D = "LinkAuthModal-module__error___Srl7H", E = "LinkAuthModal-module__trigger___aHDfG", r = {
16
16
  header: S,
17
17
  error: D,
@@ -3,7 +3,7 @@ import "@coinbase/cdp-core";
3
3
  import { useOAuthState as I } from "@coinbase/cdp-hooks";
4
4
  import { u as b } from "../../chunks/useSendComponentCallOnce.BHZMuo6E.js";
5
5
  import { useCallback as N, useState as O, useEffect as h, useRef as A } from "react";
6
- import { a as $ } from "../../chunks/CDPReactProvider.CIQm4C4z.js";
6
+ import { a as $ } from "../../chunks/CDPReactProvider.C38bKQ2x.js";
7
7
  import { CoinbaseFooter as k } from "../ui/CoinbaseFooter/index.js";
8
8
  import { LoadingSpinner as w } from "../ui/LoadingSpinner/index.js";
9
9
  import { Modal as E, ModalContent as L, ModalTitle as y, ModalDescription as R } from "../ui/Modal/index.js";
@@ -1,6 +1,6 @@
1
1
  import { jsx as n, jsxs as r } from "react/jsx-runtime";
2
2
  import { useCallback as v, useMemo as y } from "react";
3
- import "../../chunks/CDPReactProvider.CIQm4C4z.js";
3
+ import "../../chunks/CDPReactProvider.C38bKQ2x.js";
4
4
  import { useSignInWithOAuth as S } from "./hooks/useSignInWithOAuth.js";
5
5
  import { useSignInContext as _ } from "./SignInProvider.js";
6
6
  import { Button as C } from "../ui/Button/index.js";
@@ -1,14 +1,14 @@
1
1
  import { jsx as n } from "react/jsx-runtime";
2
2
  import { useMemo as f } from "react";
3
- import { Button as S } from "../ui/Button/index.js";
4
- import { IconArrowLeft as d } from "../../icons/IconArrowLeft.js";
3
+ import { Button as _ } from "../ui/Button/index.js";
4
+ import { IconArrowLeft as S } from "../../icons/IconArrowLeft.js";
5
5
  import "../../theme/theme.js";
6
- import { useSignInContext as B } from "./SignInProvider.js";
6
+ import { useSignInContext as d } from "./SignInProvider.js";
7
7
  import "@coinbase/cdp-hooks";
8
- import "../../chunks/CDPReactProvider.CIQm4C4z.js";
9
- import '../../assets/SignInBackButton.css';const _ = "SignInBackButton-module__icon___stNFS", k = {
10
- icon: _
11
- }, T = ({
8
+ import "../../chunks/CDPReactProvider.C38bKQ2x.js";
9
+ import '../../assets/SignInBackButton.css';const B = "SignInBackButton-module__icon___stNFS", k = {
10
+ icon: B
11
+ }, E = ({
12
12
  step: t,
13
13
  children: i,
14
14
  onClick: r,
@@ -17,11 +17,11 @@ import '../../assets/SignInBackButton.css';const _ = "SignInBackButton-module__i
17
17
  ["aria-label"]: s = "Back",
18
18
  ...a
19
19
  }) => {
20
- const { state: o, dispatch: m } = B(), p = f(() => t || o.step, [t, o.step]), l = (u) => {
21
- r?.(u), m({ type: "RESET_STATE" });
20
+ const { state: o, dispatch: m } = d(), p = f(() => t || o.step, [t, o.step]), l = (u) => {
21
+ r?.(u), m({ type: "GO_TO_PREVIOUS_STEP" });
22
22
  };
23
23
  return p !== "verification" ? null : /* @__PURE__ */ n(
24
- S,
24
+ _,
25
25
  {
26
26
  type: "button",
27
27
  "aria-label": s,
@@ -29,10 +29,10 @@ import '../../assets/SignInBackButton.css';const _ = "SignInBackButton-module__i
29
29
  size: e,
30
30
  variant: c,
31
31
  ...a,
32
- children: i || /* @__PURE__ */ n(d, { className: k.icon })
32
+ children: i || /* @__PURE__ */ n(S, { className: k.icon })
33
33
  }
34
34
  );
35
35
  };
36
36
  export {
37
- T as SignInBackButton
37
+ E as SignInBackButton
38
38
  };
@@ -1,9 +1,9 @@
1
1
  import { jsx as i } from "react/jsx-runtime";
2
2
  import "react";
3
- import { a as d } from "../../chunks/index.C_DV0Ud7.js";
3
+ import { a as d } from "../../chunks/index.BN39qScu.js";
4
4
  import { useSignInContext as h } from "./SignInProvider.js";
5
5
  import "@coinbase/cdp-hooks";
6
- import "../../chunks/CDPReactProvider.CIQm4C4z.js";
6
+ import "../../chunks/CDPReactProvider.C38bKQ2x.js";
7
7
  import '../../assets/SignInDescription.css';const u = "SignInDescription-module__description___jZLc6", _ = {
8
8
  description: u
9
9
  }, M = ({
@@ -1,8 +1,8 @@
1
1
  import { jsx as a } from "react/jsx-runtime";
2
2
  import { useRef as d, useState as I, useLayoutEffect as p } from "react";
3
- import "../../chunks/CDPReactProvider.CIQm4C4z.js";
3
+ import "../../chunks/CDPReactProvider.C38bKQ2x.js";
4
4
  import { SwitchFadeTransition as T } from "../ui/SwitchFadeTransition/index.js";
5
- import { a as y } from "../../chunks/index.C_DV0Ud7.js";
5
+ import { a as y } from "../../chunks/index.BN39qScu.js";
6
6
  import { useSignInContext as v } from "./SignInProvider.js";
7
7
  import "@coinbase/cdp-hooks";
8
8
  import '../../assets/SignInForm.css';const E = {
@@ -1,5 +1,5 @@
1
1
  import { jsx as i } from "react/jsx-runtime";
2
- import { u as a } from "../../chunks/CDPReactProvider.CIQm4C4z.js";
2
+ import { u as a } from "../../chunks/CDPReactProvider.C38bKQ2x.js";
3
3
  import '../../assets/SignInImage.css';const e = "SignInImage-module__logo___rlzt-", m = {
4
4
  logo: e
5
5
  }, p = (t) => /^https?:\/\//.test(t), f = ({ className: t = "", alt: s, src: g }) => {
@@ -1,6 +1,6 @@
1
1
  import { jsx as h } from "react/jsx-runtime";
2
2
  import { createContext as m, useContext as l, useMemo as i } from "react";
3
- import { u as f } from "../../chunks/CDPReactProvider.CIQm4C4z.js";
3
+ import { u as f } from "../../chunks/CDPReactProvider.C38bKQ2x.js";
4
4
  import "@coinbase/cdp-hooks";
5
5
  import { useSignInReducer as p } from "./useSignInReducer.js";
6
6
  const a = {
@@ -1,9 +1,9 @@
1
1
  import { jsx as n } from "react/jsx-runtime";
2
2
  import "react";
3
- import { a as c } from "../../chunks/index.C_DV0Ud7.js";
3
+ import { a as c } from "../../chunks/index.BN39qScu.js";
4
4
  import { useSignInContext as d } from "./SignInProvider.js";
5
5
  import "@coinbase/cdp-hooks";
6
- import "../../chunks/CDPReactProvider.CIQm4C4z.js";
6
+ import "../../chunks/CDPReactProvider.C38bKQ2x.js";
7
7
  import '../../assets/SignInTitle.css';const l = "SignInTitle-module__heading___QJ071", g = {
8
8
  heading: l
9
9
  }, S = ({
@@ -8,7 +8,7 @@ import { useEmailForm as A } from "../hooks/useEmailForm.js";
8
8
  import { useOTPForm as B } from "../hooks/useOTPForm.js";
9
9
  import { SignInCredentials as G } from "../SignInCredentials.js";
10
10
  import { useSignInContext as E } from "../SignInProvider.js";
11
- import "../../../chunks/CDPReactProvider.CIQm4C4z.js";
11
+ import "../../../chunks/CDPReactProvider.C38bKQ2x.js";
12
12
  const J = ["email", "otp"], N = ({
13
13
  step: n,
14
14
  autoFocus: s,
@@ -1,7 +1,7 @@
1
1
  import { jsxs as h, Fragment as a, jsx as e } from "react/jsx-runtime";
2
2
  import "@coinbase/cdp-hooks";
3
3
  import { useRef as A, useCallback as S, useEffect as v } from "react";
4
- import { u as m } from "../../../chunks/CDPReactProvider.CIQm4C4z.js";
4
+ import { u as m } from "../../../chunks/CDPReactProvider.C38bKQ2x.js";
5
5
  import { useSignInWithOAuth as O } from "../hooks/useSignInWithOAuth.js";
6
6
  import { Button as W } from "../../ui/Button/index.js";
7
7
  import { ServerError as I } from "../../ui/ServerError/index.js";
@@ -1,116 +1,106 @@
1
- import { jsxs as a, Fragment as p, jsx as s } from "react/jsx-runtime";
2
- import { useIsSignedIn as H, useSignInWithSms as U, useLinkSms as q, useVerifySmsOTP as z } from "@coinbase/cdp-hooks";
3
- import "libphonenumber-js";
4
- import { useRef as N, useState as T, useEffect as A, useLayoutEffect as B, useMemo as G } from "react";
5
- import { OTPForm as J } from "../../forms/OTPForm/index.js";
6
- import { PhoneNumberForm as Q } from "../../forms/PhoneNumberForm/index.js";
7
- import { SwitchSlideTransition as X } from "../../ui/SwitchSlideTransition/index.js";
8
- import { formatPhoneNumber as Y } from "../../../utils/formatPhoneNumber.js";
9
- import { parseValuesFromPhoneNumber as Z } from "../../../utils/parseValuesFromPhoneNumber.js";
10
- import { useOTPForm as _ } from "../hooks/useOTPForm.js";
11
- import { usePhoneNumberForm as $ } from "../hooks/usePhoneNumberForm.js";
12
- import { SignInCredentials as K } from "../SignInCredentials.js";
13
- import { useSignInContext as O } from "../SignInProvider.js";
14
- import "../../../chunks/CDPReactProvider.CIQm4C4z.js";
15
- const ee = ["phoneNumber", "otp"], te = ({
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.C38bKQ2x.js";
14
+ const _ = ["phoneNumber", "otp"], $ = ({
16
15
  step: o,
17
16
  autoFocus: i,
18
17
  onSuccess: m,
19
- children: h
18
+ children: a
20
19
  }) => {
21
- const d = N(null), v = 6, { isSignedIn: C } = H(), { state: t } = O(), { signInWithSms: I } = U(), { linkSms: F } = q(), { verifySmsOTP: y } = z(), [c, w] = T("US"), [u, f] = T({
22
- value: "",
23
- e164: ""
24
- }), l = o || t.step, n = l === "credentials" ? "phoneNumber" : "otp", b = N(n), { setPhoneNumber: R, submitPhoneNumber: S } = $({
25
- submit: (e) => C ? F(e) : I({ phoneNumber: e })
26
- }), { resendCountdown: D, resetOTP: E, setOTP: W, startResendTimer: x, submitOtp: j } = _({
27
- passwordLength: v,
28
- submit: (e) => y({ flowId: t.flowId, otp: e })
29
- }), L = (e) => {
30
- e.value !== u.value && (f(e), R(e.e164));
31
- };
32
- A(() => {
33
- if (t.phoneNumber === u.e164)
34
- return;
35
- const e = Z(t.phoneNumber, c);
36
- f(e);
37
- }, [t.phoneNumber, c, u.e164]);
38
- const g = () => {
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 = () => {
39
29
  x(60);
40
- }, k = () => {
41
- E(), S({ phoneNumber: t.phoneNumber, onSuccess: g });
42
- }, M = (e) => {
43
- e.preventDefault(), S({ phoneNumber: t.phoneNumber, onSuccess: g });
44
- }, V = (e) => {
45
- e.preventDefault();
46
- const r = new FormData(e.currentTarget).get("otp") || t.otp;
47
- j({ otp: r, onSuccess: m });
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 });
48
38
  };
49
- return B(() => {
50
- b.current !== n && (d.current?.transition.toggle(n), b.current = n);
51
- }, [n]), /* @__PURE__ */ s(
52
- X,
39
+ return z(() => {
40
+ d.current !== t && (h.current?.transition.toggle(t), d.current = t);
41
+ }, [t]), /* @__PURE__ */ s(
42
+ J,
53
43
  {
54
44
  autoFocus: i ? "input[type='tel']" : !1,
55
45
  animateHeight: !1,
56
- items: ee,
46
+ items: _,
57
47
  initialEntered: !0,
58
- direction: n === "otp" ? "left" : "right",
59
- transitionRef: d,
60
- children: ({ itemKey: e, ...P }) => {
48
+ direction: t === "otp" ? "left" : "right",
49
+ transitionRef: h,
50
+ children: ({ itemKey: n, ...b }) => {
61
51
  let r = null;
62
- return e === "phoneNumber" && (r = /* @__PURE__ */ s(
63
- Q,
52
+ return n === "phoneNumber" && (r = /* @__PURE__ */ s(
53
+ G,
64
54
  {
65
- countryCode: c,
66
- error: n === "phoneNumber" && t.error || "",
67
- isPending: t.isPending,
55
+ countryCode: y,
56
+ error: t === "phoneNumber" && e.error || "",
57
+ isPending: e.isPending,
68
58
  onCountryCodeChange: w,
69
- onPhoneNumberChange: L,
70
- onSubmit: M,
71
- phoneNumber: u
59
+ onPhoneNumberChange: F,
60
+ onSubmit: L,
61
+ phoneNumber: v
72
62
  }
73
- )), e === "otp" && (r = /* @__PURE__ */ s(
74
- J,
63
+ )), n === "otp" && (r = /* @__PURE__ */ s(
64
+ B,
75
65
  {
76
- canResetOTP: t.canResetOTP,
77
- error: n === "otp" && t.error || "",
78
- isPending: t.isPending,
66
+ canResetOTP: e.canResetOTP,
67
+ error: t === "otp" && e.error || "",
68
+ isPending: e.isPending,
79
69
  onOTPChange: W,
80
- onResendOTP: k,
81
- onSubmit: V,
82
- otp: t.otp,
83
- resendCountdown: D,
84
- successMessage: t.isSuccess ? "Success!" : void 0
70
+ onResendOTP: j,
71
+ onSubmit: k,
72
+ otp: e.otp,
73
+ resendCountdown: R,
74
+ successMessage: e.isSuccess ? "Success!" : void 0
85
75
  }
86
- )), /* @__PURE__ */ s("div", { ...P, children: h ? h({ step: l, Form: r }) : r });
76
+ )), /* @__PURE__ */ s("div", { ...b, children: a ? a({ step: p, Form: r }) : r });
87
77
  }
88
78
  }
89
79
  );
90
- }, ne = ({ step: o }) => /* @__PURE__ */ a(p, { children: [
80
+ }, K = ({ step: o }) => /* @__PURE__ */ u(c, { children: [
91
81
  o === "credentials" && "Sign in",
92
82
  o === "verification" && "Enter verification code"
93
- ] }), oe = ({ step: o }) => {
94
- const { state: i } = O(), m = G(
95
- () => Y(i.phoneNumber),
83
+ ] }), ee = ({ step: o }) => {
84
+ const { state: i } = g(), m = A(
85
+ () => U(i.phoneNumber),
96
86
  [i.phoneNumber]
97
87
  );
98
- return /* @__PURE__ */ a(p, { children: [
88
+ return /* @__PURE__ */ u(c, { children: [
99
89
  o === "credentials" && "We’ll send you a verification code via text.",
100
- o === "verification" && /* @__PURE__ */ a(p, { children: [
90
+ o === "verification" && /* @__PURE__ */ u(c, { children: [
101
91
  "Enter the 6 digit code sent to",
102
92
  " ",
103
- m ? /* @__PURE__ */ s(K, { children: m }) : "your phone number"
93
+ m ? /* @__PURE__ */ s(Z, { children: m }) : "your phone number"
104
94
  ] })
105
95
  ] });
106
- }, ge = {
107
- description: oe,
108
- forms: te,
109
- title: ne
96
+ }, fe = {
97
+ description: ee,
98
+ forms: $,
99
+ title: K
110
100
  };
111
101
  export {
112
- te as SignInWithSms,
113
- oe as SignInWithSmsDescription,
114
- ne as SignInWithSmsTitle,
115
- ge as config
102
+ $ as SignInWithSms,
103
+ ee as SignInWithSmsDescription,
104
+ K as SignInWithSmsTitle,
105
+ fe as config
116
106
  };
@@ -1,7 +1,7 @@
1
1
  import { jsx as n, jsxs as r, Fragment as c } from "react/jsx-runtime";
2
2
  import { u } from "../../chunks/useSendComponentCallOnce.BHZMuo6E.js";
3
3
  import "react";
4
- import { u as d } from "../../chunks/CDPReactProvider.CIQm4C4z.js";
4
+ import { u as d } from "../../chunks/CDPReactProvider.C38bKQ2x.js";
5
5
  import { SignInAuthMethodButtons as f } from "./SignInAuthMethodButtons.js";
6
6
  import { SignInBackButton as I } from "./SignInBackButton.js";
7
7
  import { SignInDescription as S } from "./SignInDescription.js";
@@ -94,6 +94,8 @@ export type SignInAction = {
94
94
  type: "RESET_OTP";
95
95
  } | {
96
96
  type: "CLEAR_ERROR";
97
+ } | {
98
+ type: "GO_TO_PREVIOUS_STEP";
97
99
  } | {
98
100
  type: "RESET_STATE";
99
101
  };
@@ -1,3 +1,3 @@
1
1
  import "@coinbase/cdp-hooks";
2
2
  import "react";
3
- import "../../chunks/CDPReactProvider.CIQm4C4z.js";
3
+ import "../../chunks/CDPReactProvider.C38bKQ2x.js";
@@ -1,7 +1,7 @@
1
- import { useReducer as u } from "react";
1
+ import { useReducer as l } from "react";
2
2
  import "@coinbase/cdp-hooks";
3
- import "../../chunks/CDPReactProvider.CIQm4C4z.js";
4
- function l(e, r) {
3
+ import "../../chunks/CDPReactProvider.C38bKQ2x.js";
4
+ function u(e, r) {
5
5
  switch (r.type) {
6
6
  case "SET_AUTH_METHODS":
7
7
  return {
@@ -13,8 +13,8 @@ function l(e, r) {
13
13
  ...e,
14
14
  authMethod: r.payload.authMethod,
15
15
  step: "credentials",
16
- email: "",
17
- phoneNumber: "",
16
+ phoneNumber: r.payload.authMethod === "sms" ? "" : e.phoneNumber,
17
+ email: r.payload.authMethod === "email" ? "" : e.email,
18
18
  error: null
19
19
  };
20
20
  case "SET_EMAIL":
@@ -74,6 +74,20 @@ function l(e, r) {
74
74
  return { ...e, error: null, canResetOTP: !1 };
75
75
  case "CLEAR_ERROR":
76
76
  return { ...e, error: null };
77
+ case "GO_TO_PREVIOUS_STEP":
78
+ return {
79
+ authMethod: e.authMethod,
80
+ authMethods: e.authMethods,
81
+ canResetOTP: !1,
82
+ error: null,
83
+ isPending: !1,
84
+ isSuccess: !1,
85
+ email: e.email,
86
+ flowId: "",
87
+ otp: "",
88
+ phoneNumber: e.phoneNumber,
89
+ step: "credentials"
90
+ };
77
91
  case "RESET_STATE":
78
92
  return {
79
93
  authMethod: e.authMethod,
@@ -92,7 +106,7 @@ function l(e, r) {
92
106
  throw new Error("Unknown action type");
93
107
  }
94
108
  }
95
- const s = (e) => u(l, e);
109
+ const s = (e) => l(u, e);
96
110
  export {
97
111
  s as useSignInReducer
98
112
  };
@@ -2,7 +2,7 @@ import { jsx as n, jsxs as t, Fragment as c } from "react/jsx-runtime";
2
2
  import { u as C } from "../../chunks/useSendComponentCallOnce.BHZMuo6E.js";
3
3
  import { createContext as b, useMemo as x, useContext as v } from "react";
4
4
  import { c as N } from "../../chunks/lite.1fxw3LjI.js";
5
- import { u as w } from "../../chunks/CDPReactProvider.CIQm4C4z.js";
5
+ import { u as w } from "../../chunks/CDPReactProvider.C38bKQ2x.js";
6
6
  import { SignIn as T } from "../SignIn/index.js";
7
7
  import "@coinbase/cdp-hooks";
8
8
  import { Button as h } from "../ui/Button/index.js";
@@ -3,4 +3,4 @@ import { VerifyMfaMethodComponentProps } from './types';
3
3
  export interface VerifyMfaDescriptionProps extends VerifyMfaMethodComponentProps, HTMLAttributes<HTMLElement> {
4
4
  as?: ElementType;
5
5
  }
6
- export declare const VerifyMfaDescription: ({ as: Component, children, className, method: methodFromProps, step: stepFromProps, ...props }: VerifyMfaDescriptionProps) => import("react/jsx-runtime").JSX.Element;
6
+ export declare const VerifyMfaDescription: ({ as: Component, children, className, method: methodFromProps, step: stepFromProps, ...props }: VerifyMfaDescriptionProps) => import("react/jsx-runtime").JSX.Element | null;