@coinbase/cdp-react 0.0.108 → 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,69 +1,79 @@
1
- import { jsx as o, jsxs as n, Fragment as d } from "react/jsx-runtime";
1
+ import { jsx as o, jsxs as l, Fragment as d } from "react/jsx-runtime";
2
2
  import { u as p } from "../../chunks/useSendComponentCallOnce.BI4daEvm.js";
3
- import { createContext as f, useMemo as L, useContext as g } from "react";
4
- import { c as A } from "../../chunks/lite.1fxw3LjI.js";
5
- import "../../chunks/CDPReactProvider.CFWIUvzR.js";
6
- import { LinkAuth as C, LinkAuthError as x } from "../LinkAuth/index.js";
7
- import { Button as m } from "../ui/Button/index.js";
8
- import { Modal as b, ModalContent as v, ModalTitle as w, ModalClose as N, ModalTrigger as T } from "../ui/Modal/index.js";
9
- import { VisuallyHidden as y } from "../ui/VisuallyHidden/index.js";
3
+ import { createContext as M, useMemo as g, useCallback as L, useContext as A } from "react";
4
+ import { c as C } from "../../chunks/lite.1fxw3LjI.js";
5
+ import "../../chunks/CDPReactProvider.BWInVuNJ.js";
6
+ import { LinkAuth as x, LinkAuthError as b } from "../LinkAuth/index.js";
7
+ import { isWithinBaseAccountDialog as v } from "../SiweStatusView/connectors/baseAccount.js";
8
+ import { Button as h } from "../ui/Button/index.js";
9
+ import { Modal as w, ModalContent as N, ModalTitle as T, ModalClose as y, ModalTrigger as B } from "../ui/Modal/index.js";
10
+ import { VisuallyHidden as D } from "../ui/VisuallyHidden/index.js";
10
11
  import { IconXMark as F } from "../../icons/IconXMark.js";
11
- import { childrenHasComponent as c } from "../../utils/childrenHasComponent.js";
12
+ import { childrenHasComponent as u } from "../../utils/childrenHasComponent.js";
12
13
  import { LinkAuthTitle as H } from "../LinkAuth/LinkAuthTitle.js";
13
14
  import { LinkAuthFlowBackButton as j } from "../LinkAuth/LinkAuthFlowBackButton.js";
14
- import { a as B } from "../../chunks/LinkAuthFlow.S1XbYaG5.js";
15
- import '../../assets/LinkAuthModal.css';const S = "LinkAuthModal-module__header___qoco6", D = "LinkAuthModal-module__error___Srl7H", E = "LinkAuthModal-module__trigger___aHDfG", r = {
16
- header: S,
17
- error: D,
15
+ import { a as E } from "../../chunks/LinkAuthFlow.0FnIchwa.js";
16
+ import '../../assets/LinkAuthModal.css';const O = "LinkAuthModal-module__header___qoco6", S = "LinkAuthModal-module__error___Srl7H", I = "LinkAuthModal-module__trigger___aHDfG", i = {
17
+ header: O,
18
+ error: S,
18
19
  "close-icon": "LinkAuthModal-module__close-icon___Fe02C",
19
20
  "close-button": "LinkAuthModal-module__close-button___x6j3c",
20
- trigger: E
21
- }, h = f(null), O = () => {
22
- const e = g(h);
23
- if (!e)
21
+ trigger: I
22
+ }, _ = M(null), V = () => {
23
+ const t = A(_);
24
+ if (!t)
24
25
  throw new Error("useLinkAuthModalContext must be used within a LinkAuthModal");
25
- return e;
26
- }, u = ({
27
- children: e,
28
- className: t = "",
29
- label: i,
30
- ...a
31
- }) => /* @__PURE__ */ o(T, { asChild: !0, children: e || /* @__PURE__ */ o(m, { className: A(r.trigger, t), ...a, children: i || "Link accounts" }) }), l = (e) => {
32
- const { onLinkSuccess: t } = O();
33
- return /* @__PURE__ */ n(v, { "aria-describedby": void 0, ...e, children: [
34
- /* @__PURE__ */ o(y, { children: /* @__PURE__ */ o(w, { children: "Link a profile" }) }),
35
- /* @__PURE__ */ n(C, { onLinkSuccess: t, children: [
36
- /* @__PURE__ */ n("div", { className: r.header, children: [
26
+ return t;
27
+ }, m = ({
28
+ children: t,
29
+ className: r = "",
30
+ label: n,
31
+ ...e
32
+ }) => /* @__PURE__ */ o(B, { asChild: !0, children: t || /* @__PURE__ */ o(h, { className: C(i.trigger, r), ...e, children: n || "Link accounts" }) }), s = ({ onInteractOutside: t, ...r }) => {
33
+ const { onLinkSuccess: n } = V(), e = L(
34
+ (a) => {
35
+ if (v(a.detail.originalEvent.target)) {
36
+ a.preventDefault();
37
+ return;
38
+ }
39
+ t?.(a);
40
+ },
41
+ [t]
42
+ );
43
+ return /* @__PURE__ */ l(N, { "aria-describedby": void 0, ...r, onInteractOutside: e, children: [
44
+ /* @__PURE__ */ o(D, { children: /* @__PURE__ */ o(T, { children: "Link a profile" }) }),
45
+ /* @__PURE__ */ l(x, { onLinkSuccess: n, children: [
46
+ /* @__PURE__ */ l("div", { className: i.header, children: [
37
47
  /* @__PURE__ */ o(H, {}),
38
48
  /* @__PURE__ */ o(j, {}),
39
- /* @__PURE__ */ o(N, { asChild: !0, children: /* @__PURE__ */ o(
40
- m,
49
+ /* @__PURE__ */ o(y, { asChild: !0, children: /* @__PURE__ */ o(
50
+ h,
41
51
  {
42
- className: r["close-button"],
52
+ className: i["close-button"],
43
53
  "aria-label": "Close",
44
54
  size: "md",
45
55
  variant: "transparentSecondary",
46
- children: /* @__PURE__ */ o(F, { className: r["close-icon"] })
56
+ children: /* @__PURE__ */ o(F, { className: i["close-icon"] })
47
57
  }
48
58
  ) })
49
59
  ] }),
50
- /* @__PURE__ */ o("div", { className: r.error, children: /* @__PURE__ */ o(x, {}) }),
51
- /* @__PURE__ */ o(B, {})
60
+ /* @__PURE__ */ o("div", { className: i.error, children: /* @__PURE__ */ o(b, {}) }),
61
+ /* @__PURE__ */ o(E, {})
52
62
  ] })
53
63
  ] });
54
- }, Z = ({ children: e, open: t, setIsOpen: i, onLinkSuccess: a }) => {
64
+ }, to = ({ children: t, open: r, setIsOpen: n, onLinkSuccess: e }) => {
55
65
  p("manage_auth_modal");
56
- const _ = e ? c(e, u) : !1, s = e ? c(e, l) : !1, k = !_ && !s, M = L(() => ({ onLinkSuccess: a }), [a]);
57
- return /* @__PURE__ */ o(h.Provider, { value: M, children: /* @__PURE__ */ o(b, { open: t, onOpenChange: i, children: k ? /* @__PURE__ */ n(d, { children: [
58
- /* @__PURE__ */ o(u, { children: e }),
59
- /* @__PURE__ */ o(l, {})
60
- ] }) : /* @__PURE__ */ n(d, { children: [
61
- e,
62
- !s && /* @__PURE__ */ o(l, {})
66
+ const a = t ? u(t, m) : !1, c = t ? u(t, s) : !1, f = !a && !c, k = g(() => ({ onLinkSuccess: e }), [e]);
67
+ return /* @__PURE__ */ o(_.Provider, { value: k, children: /* @__PURE__ */ o(w, { open: r, onOpenChange: n, children: f ? /* @__PURE__ */ l(d, { children: [
68
+ /* @__PURE__ */ o(m, { children: t }),
69
+ /* @__PURE__ */ o(s, {})
70
+ ] }) : /* @__PURE__ */ l(d, { children: [
71
+ t,
72
+ !c && /* @__PURE__ */ o(s, {})
63
73
  ] }) }) });
64
74
  };
65
75
  export {
66
- Z as LinkAuthModal,
67
- l as LinkAuthModalContent,
68
- u as LinkAuthModalTrigger
76
+ to as LinkAuthModal,
77
+ s as LinkAuthModalContent,
78
+ m as LinkAuthModalTrigger
69
79
  };
@@ -1,162 +1,140 @@
1
- import { jsx as s, jsxs as r, Fragment as f } from "react/jsx-runtime";
1
+ import { jsx as e, jsxs as h } from "react/jsx-runtime";
2
2
  import "@coinbase/cdp-core";
3
- import { useOAuthState as N } from "@coinbase/cdp-hooks";
4
- import { u as b } from "../../chunks/useSendComponentCallOnce.BI4daEvm.js";
5
- import { useState as A, useEffect as g, useRef as I, useCallback as S } from "react";
6
- import { a as v } from "../../chunks/CDPReactProvider.CFWIUvzR.js";
3
+ import { useOAuthState as w } from "@coinbase/cdp-hooks";
4
+ import { u as N } from "../../chunks/useSendComponentCallOnce.BI4daEvm.js";
5
+ import { useState as T, useEffect as f, useRef as S, useCallback as _ } from "react";
6
+ import { a as v } from "../../chunks/CDPReactProvider.BWInVuNJ.js";
7
7
  import { CoinbaseFooter as k } from "../ui/CoinbaseFooter/index.js";
8
- import { LoadingSpinner as w } from "../ui/LoadingSpinner/index.js";
9
- import { Modal as L, ModalContent as E, ModalTitle as y, ModalDescription as R } from "../ui/Modal/index.js";
10
- import { SwitchFadeTransition as P } from "../ui/SwitchFadeTransition/index.js";
11
- import { VisuallyHidden as M } from "../ui/VisuallyHidden/index.js";
8
+ import { Modal as y, ModalContent as R, ModalTitle as $, ModalDescription as P } from "../ui/Modal/index.js";
9
+ import { StatusView as O } from "../ui/StatusView/index.js";
10
+ import { SwitchFadeTransition as H } from "../ui/SwitchFadeTransition/index.js";
11
+ import { VisuallyHidden as C } from "../ui/VisuallyHidden/index.js";
12
12
  import { useTimer as U } from "../../hooks/useTimer.js";
13
- import { IconAppleLogo as K } from "../../icons/IconAppleLogo.js";
14
- import { IconCheck as x } from "../../icons/IconCheck.js";
15
- import { IconGoogleColorLogo as G } from "../../icons/IconGoogleColorLogo.js";
16
- import { IconTelegramLogo as H } from "../../icons/IconTelegramLogo.js";
17
- import { IconXLogo as q } from "../../icons/IconXLogo.js";
18
- import { IconXMark as Y } from "../../icons/IconXMark.js";
19
- import { capitalize as _ } from "../../utils/capitalize.js";
20
- import '../../assets/OAuthStatusModal.css';const j = "OAuthStatusModal-module__status___vU6x7", D = "OAuthStatusModal-module__graphic___2fKoa", F = "OAuthStatusModal-module__pad___oooMz", z = "OAuthStatusModal-module__spinner___Q3dYq", V = "OAuthStatusModal-module__icon___Lj5Gf", W = "OAuthStatusModal-module__subhead___Pg9GI", X = "OAuthStatusModal-module__description___0qOZY", J = "OAuthStatusModal-module__ring___mKwSb", Q = "OAuthStatusModal-module__invisible___IeRd0", t = {
13
+ import { IconAppleLogo as x } from "../../icons/IconAppleLogo.js";
14
+ import { IconGoogleColorLogo as K } from "../../icons/IconGoogleColorLogo.js";
15
+ import { IconTelegramLogo as D } from "../../icons/IconTelegramLogo.js";
16
+ import { IconXLogo as G } from "../../icons/IconXLogo.js";
17
+ import { capitalize as m } from "../../utils/capitalize.js";
18
+ import '../../assets/OAuthStatusModal.css';const V = "OAuthStatusModal-module__status___vU6x7", g = {
21
19
  "oauth-status-modal": "OAuthStatusModal-module__oauth-status-modal___I69Ii",
22
20
  "transition-wrapper": "OAuthStatusModal-module__transition-wrapper___TmPRh",
23
- status: j,
24
- graphic: D,
25
- pad: F,
26
- spinner: z,
27
- icon: V,
28
- "icon-success": "OAuthStatusModal-module__icon-success___gqMWr",
29
- "icon-error": "OAuthStatusModal-module__icon-error___psI7m",
30
- subhead: W,
31
- description: X,
32
- ring: J,
33
- "ring-success": "OAuthStatusModal-module__ring-success___unyM9",
34
- "ring-error": "OAuthStatusModal-module__ring-error___OsgqU",
35
- invisible: Q
36
- }, p = "cdp-react-sign-in-with-oauth-provider-name", h = "cdp-react-sign-in-with-oauth-is-account-link", Z = ["pending", "success", "error"], vt = () => {
37
- const n = v() || "", o = S(
38
- (a) => {
39
- sessionStorage.setItem(p, n), sessionStorage.setItem(
40
- h,
41
- a ? "true" : "false"
21
+ status: V
22
+ }, d = "cdp-react-sign-in-with-oauth-provider-name", p = "cdp-react-sign-in-with-oauth-is-account-link", b = ["pending", "success", "error"], dt = () => {
23
+ const o = v() || "", s = _(
24
+ (n) => {
25
+ sessionStorage.setItem(d, o), sessionStorage.setItem(
26
+ p,
27
+ n ? "true" : "false"
42
28
  );
43
29
  },
44
- [n]
45
- ), e = S(() => {
46
- sessionStorage.removeItem(p), sessionStorage.removeItem(h);
30
+ [o]
31
+ ), t = _(() => {
32
+ sessionStorage.removeItem(d), sessionStorage.removeItem(p);
47
33
  }, []);
48
- return { persistOAuthState: o, cleanupOAuthState: e };
49
- }, $t = () => {
50
- b("oauth_status_modal");
51
- const [n, o] = A(!1), { oauthState: e } = N(), [a, i] = A(!1), u = v(), l = e?.providerType || "google";
52
- return g(() => {
53
- if (e?.status === "pending" || e?.status === "error" || e?.status === "success") {
54
- const d = sessionStorage.getItem(p);
55
- if (d === null || d !== u)
34
+ return { persistOAuthState: s, cleanupOAuthState: t };
35
+ }, pt = () => {
36
+ N("oauth_status_modal");
37
+ const [o, s] = T(!1), { oauthState: t } = w(), [n, r] = T(!1), a = v(), u = t?.providerType || "google";
38
+ return f(() => {
39
+ if (t?.status === "pending" || t?.status === "error" || t?.status === "success") {
40
+ const c = sessionStorage.getItem(d);
41
+ if (c === null || c !== a)
56
42
  return;
57
- sessionStorage.removeItem(p), o(!0);
58
- const m = sessionStorage.getItem(h) === "true";
59
- sessionStorage.removeItem(h), i(m);
43
+ sessionStorage.removeItem(d), s(!0);
44
+ const l = sessionStorage.getItem(p) === "true";
45
+ sessionStorage.removeItem(p), r(l);
60
46
  }
61
- }, [e?.status, u]), /* @__PURE__ */ s(L, { open: n, onOpenChange: o, children: /* @__PURE__ */ r(E, { children: [
62
- /* @__PURE__ */ s(M, { children: /* @__PURE__ */ s(y, { children: "OAuth Status" }) }),
63
- /* @__PURE__ */ s(M, { children: /* @__PURE__ */ r(R, { children: [
64
- a ? `Linking your ${l} account` : `Signing in with ${l}`,
47
+ }, [t?.status, a]), /* @__PURE__ */ e(y, { open: o, onOpenChange: s, children: /* @__PURE__ */ h(R, { children: [
48
+ /* @__PURE__ */ e(C, { children: /* @__PURE__ */ e($, { children: "OAuth Status" }) }),
49
+ /* @__PURE__ */ e(C, { children: /* @__PURE__ */ h(P, { children: [
50
+ n ? `Linking your ${u} account` : `Signing in with ${u}`,
65
51
  " ",
66
- e?.status ? `${e?.status === "success" ? "successful" : e?.status === "error" ? "failed" : "pending"}` : ""
52
+ t?.status ? `${t?.status === "success" ? "successful" : t?.status === "error" ? "failed" : "pending"}` : ""
67
53
  ] }) }),
68
- /* @__PURE__ */ s(B, { isAccountLink: a, handleClose: () => o(!1) })
54
+ /* @__PURE__ */ e(j, { isAccountLink: n, handleClose: () => s(!1) })
69
55
  ] }) });
70
- }, B = ({
71
- isAccountLink: n,
72
- handleClose: o
56
+ }, j = ({
57
+ isAccountLink: o,
58
+ handleClose: s
73
59
  }) => {
74
- const { oauthState: e } = N(), a = e?.providerType || "google", { timeRemaining: i, start: u, reset: l } = U(), d = I(null), m = I(null), $ = 250, O = S((c) => {
75
- m.current === c || c === void 0 || (m.current = c, d.current?.transition.toggle(c));
60
+ const { oauthState: t } = w(), n = t?.providerType || "google", { timeRemaining: r, start: a, reset: u } = U(), c = S(null), l = S(t?.status ?? null), E = 250, A = S(t?.status).current, I = _((i) => {
61
+ l.current === i || i === void 0 || (l.current = i, c.current?.transition.toggle(i));
76
62
  }, []);
77
- return g(() => {
78
- O(e?.status), e?.status === "success" && u(3);
79
- }, [e?.status, O, u]), g(() => {
80
- i !== null && i <= 0 && (l(), o());
81
- }, [i, l, o]), /* @__PURE__ */ r("div", { className: t["oauth-status-modal"], children: [
82
- /* @__PURE__ */ s(
83
- P,
63
+ return f(() => {
64
+ I(t?.status), t?.status === "success" && a(1);
65
+ }, [t?.status, I, a]), f(() => {
66
+ r !== null && r <= 0 && (u(), s());
67
+ }, [r, u, s]), /* @__PURE__ */ h("div", { className: g["oauth-status-modal"], children: [
68
+ /* @__PURE__ */ e(
69
+ H,
84
70
  {
85
71
  animateHeight: !1,
86
- timeout: $,
87
- items: Z,
88
- initialEntered: !1,
89
- transitionRef: d,
90
- className: t["transition-wrapper"],
91
- children: ({ itemKey: c, ...T }) => {
92
- const C = ot[c];
93
- return /* @__PURE__ */ s("div", { ...T, className: t.status, children: /* @__PURE__ */ s(
94
- C,
72
+ timeout: E,
73
+ items: b,
74
+ initialEntered: !!A,
75
+ initialItem: A,
76
+ transitionRef: c,
77
+ className: g["transition-wrapper"],
78
+ children: ({ itemKey: i, ...L }) => {
79
+ const M = J[i];
80
+ return /* @__PURE__ */ e("div", { ...L, className: g.status, children: /* @__PURE__ */ e(
81
+ M,
95
82
  {
96
- isAccountLink: n,
97
- timeRemaining: i,
98
- provider: a
83
+ isAccountLink: o,
84
+ timeRemaining: r,
85
+ provider: n
99
86
  }
100
87
  ) });
101
88
  }
102
89
  }
103
90
  ),
104
- /* @__PURE__ */ s(k, {})
91
+ /* @__PURE__ */ e(k, {})
105
92
  ] });
106
- }, tt = ({ isAccountLink: n, provider: o }) => {
107
- const e = nt[o];
108
- return /* @__PURE__ */ r(f, { children: [
109
- /* @__PURE__ */ r("div", { className: t.graphic, children: [
110
- /* @__PURE__ */ s(
111
- w,
112
- {
113
- strokeWidth: "5%",
114
- staticStroke: !0,
115
- staticStrokeColor: "var(--cdp-web-colors-line-default)",
116
- className: t.spinner
117
- }
118
- ),
119
- e && /* @__PURE__ */ s("span", { className: t.icon, children: /* @__PURE__ */ s(e, {}) })
120
- ] }),
121
- /* @__PURE__ */ s("p", { className: t.subhead, children: n ? `Linking your ${_(o)} account` : `Signing in with ${_(o)}` }),
122
- /* @__PURE__ */ s("p", { className: t.description, children: "Just a moment..." })
123
- ] });
124
- }, st = ({
125
- isAccountLink: n,
126
- timeRemaining: o,
127
- provider: e
128
- }) => /* @__PURE__ */ r(f, { children: [
129
- /* @__PURE__ */ r("div", { className: t.graphic, children: [
130
- /* @__PURE__ */ s("span", { className: `${t.ring} ${t["ring-success"]}` }),
131
- /* @__PURE__ */ s("span", { className: `${t.icon} ${t["icon-success"]}`, children: /* @__PURE__ */ s(x, {}) })
132
- ] }),
133
- /* @__PURE__ */ s("p", { className: t.subhead, children: n ? `${_(e)} account linked` : `Signed in with ${_(e)}` }),
134
- /* @__PURE__ */ r("p", { className: `${t.description} ${o === null ? t.invisible : ""}`, children: [
135
- "This window will automatically close in ",
136
- o ?? "soon"
137
- ] })
138
- ] }), et = ({ isAccountLink: n }) => /* @__PURE__ */ r(f, { children: [
139
- /* @__PURE__ */ r("div", { className: `${t.graphic} ${t.pad}`, children: [
140
- /* @__PURE__ */ s("span", { className: `${t.ring} ${t["ring-error"]}` }),
141
- /* @__PURE__ */ s("span", { className: `${t.icon} ${t["icon-error"]}`, children: /* @__PURE__ */ s(Y, {}) })
142
- ] }),
143
- /* @__PURE__ */ s("p", { className: t.subhead, children: n ? "Account linking failed" : "Sign in failed" }),
144
- /* @__PURE__ */ s("p", { className: t.description, children: "Something went wrong. Please try again." })
145
- ] }), ot = {
146
- pending: tt,
147
- success: st,
148
- error: et
149
- }, nt = {
150
- google: G,
151
- apple: K,
152
- x: q,
153
- telegram: H
93
+ }, F = ({ isAccountLink: o, provider: s }) => {
94
+ const t = X[s];
95
+ return /* @__PURE__ */ e(
96
+ O,
97
+ {
98
+ status: "pending",
99
+ icon: t ? /* @__PURE__ */ e(t, { width: "32", height: "32" }) : void 0,
100
+ title: o ? `Linking your ${m(s)} account` : `Signing in with ${m(s)}`,
101
+ description: "Just a moment..."
102
+ }
103
+ );
104
+ }, Y = ({
105
+ isAccountLink: o,
106
+ timeRemaining: s,
107
+ provider: t
108
+ }) => /* @__PURE__ */ e(
109
+ O,
110
+ {
111
+ status: "success",
112
+ title: o ? `${m(t)} account linked` : `Signed in with ${m(t)}`,
113
+ description: `This window will automatically close in ${s ?? "soon"}`,
114
+ descriptionHidden: s === null
115
+ }
116
+ ), z = ({ isAccountLink: o }) => /* @__PURE__ */ e(
117
+ O,
118
+ {
119
+ status: "error",
120
+ title: o ? "Account linking failed" : "Sign in failed",
121
+ description: "Something went wrong. Please try again."
122
+ }
123
+ ), J = {
124
+ pending: F,
125
+ success: Y,
126
+ error: z
127
+ }, X = {
128
+ google: K,
129
+ apple: x,
130
+ x: G,
131
+ telegram: D
154
132
  };
155
133
  export {
156
- h as OAUTH_IS_ACCOUNT_LINK_SESSION_STORAGE_KEY,
157
- p as OAUTH_PROVIDER_SESSION_STORAGE_KEY,
158
- $t as OAuthStatusModal,
159
- B as OAuthStatusModalContent,
160
- $t as default,
161
- vt as useOauthStatusModal
134
+ p as OAUTH_IS_ACCOUNT_LINK_SESSION_STORAGE_KEY,
135
+ d as OAUTH_PROVIDER_SESSION_STORAGE_KEY,
136
+ pt as OAuthStatusModal,
137
+ j as OAuthStatusModalContent,
138
+ pt as default,
139
+ dt as useOauthStatusModal
162
140
  };
@@ -27,14 +27,17 @@ export interface SignInAuthMethodButtonProps {
27
27
  export interface SignInAuthMethodButtonsProps {
28
28
  /** The active auth method. */
29
29
  activeMethod?: AuthMethod;
30
+ /** Called when an auth method (e.g. SIWE) completes successfully from this surface. */
31
+ onSuccess?: () => void;
30
32
  }
31
33
  /**
32
34
  * The AuthMethodButtons component.
33
35
  *
34
- * @param {AuthMethodButtonProps} props - The props for the AuthMethodButtons component.
36
+ * @param {SignInAuthMethodButtonsProps} props - The props for the AuthMethodButtons component.
35
37
  * @param {AuthMethod} [props.activeMethod] - The active auth method.
38
+ * @param {() => void} [props.onSuccess] - Called when an auth method completes successfully.
36
39
  * @returns {JSX.Element} The AuthMethodButtons component.
37
40
  *
38
41
  * @group Components
39
42
  */
40
- export declare const SignInAuthMethodButtons: ({ activeMethod }: SignInAuthMethodButtonsProps) => import("react/jsx-runtime").JSX.Element | null;
43
+ export declare const SignInAuthMethodButtons: ({ activeMethod, onSuccess, }: SignInAuthMethodButtonsProps) => import("react/jsx-runtime").JSX.Element | null;
@@ -1,98 +1,129 @@
1
- import { jsxs as r, jsx as n } from "react/jsx-runtime";
2
- import { useCallback as v, useMemo as y } from "react";
3
- import "../../chunks/CDPReactProvider.CFWIUvzR.js";
4
- import { useSignInWithOAuth as C } from "./hooks/useSignInWithOAuth.js";
5
- import { useSignInContext as g } from "./SignInProvider.js";
6
- import { Button as S } from "../ui/Button/index.js";
7
- import { ServerError as M } from "../ui/ServerError/index.js";
8
- import { IconAppleLogo as k } from "../../icons/IconAppleLogo.js";
9
- import { IconEnvelope as B } from "../../icons/IconEnvelope.js";
10
- import { IconGoogleLogo as E } from "../../icons/IconGoogleLogo.js";
11
- import { IconPhone as P } from "../../icons/IconPhone.js";
12
- import { IconTelegramLogo as O } from "../../icons/IconTelegramLogo.js";
13
- import { IconXLogo as w } from "../../icons/IconXLogo.js";
14
- import { toOAuthProviderType as b } from "../../utils/toOAuthProviderType.js";
15
- import '../../assets/SignInAuthMethodButtons.css';const T = "SignInAuthMethodButtons-module__divider___zphEh", o = {
1
+ import { jsx as n, jsxs as l } from "react/jsx-runtime";
2
+ import { useMemo as S, useCallback as w } from "react";
3
+ import "../../chunks/CDPReactProvider.BWInVuNJ.js";
4
+ import { useSignInWithOAuth as B } from "./hooks/useSignInWithOAuth.js";
5
+ import { useStartSiwe as M } from "./hooks/useStartSiwe.js";
6
+ import { useSignInContext as E } from "./SignInProvider.js";
7
+ import "@coinbase/cdp-hooks";
8
+ import { Button as O } from "../ui/Button/index.js";
9
+ import { siweConnectors as P } from "../SiweStatusView/connectors/siweConnectors.js";
10
+ import "libphonenumber-js";
11
+ import { toSiweProvider as k } from "../SiweStatusView/toSiweProvider.js";
12
+ import { ServerError as W } from "../ui/ServerError/index.js";
13
+ import { IconAppleLogo as j } from "../../icons/IconAppleLogo.js";
14
+ import { IconEnvelope as T } from "../../icons/IconEnvelope.js";
15
+ import { IconGoogleLogo as x } from "../../icons/IconGoogleLogo.js";
16
+ import { IconPhone as L } from "../../icons/IconPhone.js";
17
+ import { IconTelegramLogo as N } from "../../icons/IconTelegramLogo.js";
18
+ import { IconXLogo as D } from "../../icons/IconXLogo.js";
19
+ import { toOAuthProviderType as I } from "../../utils/toOAuthProviderType.js";
20
+ import '../../assets/SignInAuthMethodButtons.css';const H = "SignInAuthMethodButtons-module__divider___zphEh", e = {
16
21
  "auth-method-buttons": "SignInAuthMethodButtons-module__auth-method-buttons___jYEH7",
17
22
  "auth-btn": "SignInAuthMethodButtons-module__auth-btn___o1a09",
18
23
  "auth-btn-icon": "SignInAuthMethodButtons-module__auth-btn-icon___VjvFY",
19
24
  "auth-btn-label": "SignInAuthMethodButtons-module__auth-btn-label___mEWd3",
20
- divider: T
21
- }, _ = {
25
+ divider: H
26
+ }, G = Object.fromEntries(
27
+ Object.entries(P).map(([r, i]) => {
28
+ const a = i.icon;
29
+ return [`siwe:${r}`, { label: `Continue with ${i.label}`, icon: /* @__PURE__ */ n(a, {}) }];
30
+ })
31
+ ), A = {
22
32
  email: {
23
33
  label: "Continue with email",
24
- icon: /* @__PURE__ */ n(B, {})
34
+ icon: /* @__PURE__ */ n(T, {})
25
35
  },
26
36
  sms: {
27
37
  label: "Continue with phone",
28
- icon: /* @__PURE__ */ n(P, {})
38
+ icon: /* @__PURE__ */ n(L, {})
29
39
  },
30
40
  "oauth:google": {
31
41
  label: "Continue with Google",
32
- icon: /* @__PURE__ */ n(E, {})
42
+ icon: /* @__PURE__ */ n(x, {})
33
43
  },
34
44
  "oauth:apple": {
35
45
  label: "Continue with Apple",
36
- icon: /* @__PURE__ */ n(k, {})
46
+ icon: /* @__PURE__ */ n(j, {})
37
47
  },
38
48
  "oauth:x": {
39
49
  label: "Continue with X",
40
- icon: /* @__PURE__ */ n(w, {})
50
+ icon: /* @__PURE__ */ n(D, {})
41
51
  },
42
52
  "oauth:telegram": {
43
53
  label: "Continue with Telegram",
44
- icon: /* @__PURE__ */ n(O, {})
45
- }
46
- }, q = ({ activeMethod: a }) => {
54
+ icon: /* @__PURE__ */ n(N, {})
55
+ },
56
+ ...G
57
+ }, st = ({
58
+ activeMethod: r,
59
+ onSuccess: i
60
+ }) => {
47
61
  const {
48
- state: { authMethods: l }
49
- } = g(), {
50
- signInWithOAuth: u,
51
- isPending: s,
52
- error: h,
53
- oauthProvider: c
54
- } = C(), m = v(
62
+ state: { authMethods: a },
63
+ dispatch: u
64
+ } = E(), {
65
+ signInWithOAuth: h,
66
+ isPending: c,
67
+ error: m,
68
+ oauthProvider: p
69
+ } = B(), d = M("base"), b = S(
70
+ () => ({ base: d }),
71
+ [d]
72
+ ), g = w(
55
73
  async (t) => {
56
- const i = b(t);
57
- i && u(i);
74
+ const o = I(t);
75
+ o && h(o);
76
+ },
77
+ [h]
78
+ ), _ = w(
79
+ (t) => {
80
+ const o = k(t);
81
+ o && b[o](i);
58
82
  },
59
- [u]
60
- ), { dispatch: p } = g(), e = y(() => (l || ["email"]).map((t) => {
61
- if (!_[t])
83
+ [b, i]
84
+ ), s = S(() => (a || ["email"]).map((t) => {
85
+ if (!A[t])
62
86
  return null;
63
- const { label: i, icon: f } = _[t], d = t.startsWith("oauth:"), A = d ? () => m(t) : () => p({ type: "SET_AUTH_METHOD", payload: { authMethod: t } }), I = d && c.current === b(t) && s;
87
+ const { label: o, icon: v } = A[t], f = t.startsWith("oauth:"), C = t.startsWith("siwe:") ? () => _(t) : f ? () => g(t) : () => u({ type: "SET_AUTH_METHOD", payload: { authMethod: t } }), y = f && p.current === I(t) && c;
64
88
  return {
65
89
  key: t,
66
- label: i,
67
- icon: f,
68
- onClick: A,
69
- isPending: I
90
+ label: o,
91
+ icon: v,
92
+ onClick: C,
93
+ isPending: y
70
94
  };
71
- }).filter((t) => t !== null), [l, p, m, s, c]);
72
- return !e.length || e.length === 1 && e[0].key === a ? null : /* @__PURE__ */ r("div", { className: o["auth-method-buttons"], children: [
73
- /* @__PURE__ */ r("div", { className: o.divider, children: [
95
+ }).filter((t) => t !== null), [
96
+ a,
97
+ u,
98
+ g,
99
+ _,
100
+ c,
101
+ p
102
+ ]);
103
+ return !s.length || s.length === 1 && s[0].key === r ? null : /* @__PURE__ */ l("div", { className: e["auth-method-buttons"], children: [
104
+ /* @__PURE__ */ l("div", { className: e.divider, children: [
74
105
  /* @__PURE__ */ n("hr", {}),
75
106
  /* @__PURE__ */ n("span", { children: "or" })
76
107
  ] }),
77
- e.map((t) => t.key === a ? null : /* @__PURE__ */ r(
78
- S,
108
+ s.map((t) => t.key === r ? null : /* @__PURE__ */ l(
109
+ O,
79
110
  {
80
111
  "aria-label": t.ariaLabel,
81
- className: o["auth-btn"],
112
+ className: e["auth-btn"],
82
113
  type: "button",
83
114
  variant: "secondary",
84
115
  onClick: t.onClick,
85
116
  isPending: t.isPending,
86
117
  children: [
87
- /* @__PURE__ */ n("span", { className: o["auth-btn-icon"], children: t.icon }),
88
- /* @__PURE__ */ n("span", { className: o["auth-btn-label"], children: t.label })
118
+ /* @__PURE__ */ n("span", { className: e["auth-btn-icon"], children: t.icon }),
119
+ /* @__PURE__ */ n("span", { className: e["auth-btn-label"], children: t.label })
89
120
  ]
90
121
  },
91
122
  t.key
92
123
  )),
93
- h && /* @__PURE__ */ n(M, { error: h })
124
+ m && /* @__PURE__ */ n(W, { error: m })
94
125
  ] });
95
126
  };
96
127
  export {
97
- q as SignInAuthMethodButtons
128
+ st as SignInAuthMethodButtons
98
129
  };
@@ -5,7 +5,7 @@ import { IconArrowLeft as S } from "../../icons/IconArrowLeft.js";
5
5
  import "../../theme/theme.js";
6
6
  import { useSignInContext as d } from "./SignInProvider.js";
7
7
  import "@coinbase/cdp-hooks";
8
- import "../../chunks/CDPReactProvider.CFWIUvzR.js";
8
+ import "../../chunks/CDPReactProvider.BWInVuNJ.js";
9
9
  import '../../assets/SignInBackButton.css';const B = "SignInBackButton-module__icon___stNFS", k = {
10
10
  icon: B
11
11
  }, E = ({