@coinbase/cdp-react 0.0.57 → 0.0.60

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 (116) hide show
  1. package/dist/assets/Banner.css +1 -0
  2. package/dist/assets/CopyAddress.css +1 -0
  3. package/dist/assets/ExportWallet.css +1 -0
  4. package/dist/assets/ExportWalletModal.css +1 -0
  5. package/dist/assets/IframeButton.css +1 -0
  6. package/dist/assets/Input.css +1 -1
  7. package/dist/assets/LinkAuth.css +1 -0
  8. package/dist/assets/LinkAuthFlow.css +1 -0
  9. package/dist/assets/LinkAuthFlowBackButton.css +1 -0
  10. package/dist/assets/LinkAuthItem.css +1 -0
  11. package/dist/assets/LinkAuthItems.css +1 -0
  12. package/dist/assets/LinkAuthModal.css +1 -0
  13. package/dist/assets/LinkAuthTitle.css +1 -0
  14. package/dist/assets/SwitchSlideTransition.css +1 -1
  15. package/dist/chunks/LinkAuthFlow.BZtyaLN-.js +111 -0
  16. package/dist/components/CDPReactProvider/index.js +68 -55
  17. package/dist/components/CopyAddress/index.d.ts +8 -0
  18. package/dist/components/CopyAddress/index.js +61 -0
  19. package/dist/components/CopyEvmKeyButton/index.d.ts +13 -0
  20. package/dist/components/CopyEvmKeyButton/index.js +62 -0
  21. package/dist/components/CopySolanaKeyButton/index.d.ts +13 -0
  22. package/dist/components/CopySolanaKeyButton/index.js +62 -0
  23. package/dist/components/ExportWallet/index.d.ts +21 -0
  24. package/dist/components/ExportWallet/index.js +110 -0
  25. package/dist/components/ExportWalletModal/index.d.ts +18 -0
  26. package/dist/components/ExportWalletModal/index.js +96 -0
  27. package/dist/components/LinkAuth/LinkAuthFlow.d.ts +13 -0
  28. package/dist/components/LinkAuth/LinkAuthFlow.js +19 -0
  29. package/dist/components/LinkAuth/LinkAuthFlowBackButton.d.ts +9 -0
  30. package/dist/components/LinkAuth/LinkAuthFlowBackButton.js +40 -0
  31. package/dist/components/LinkAuth/LinkAuthFlowProvider.d.ts +33 -0
  32. package/dist/components/LinkAuth/LinkAuthFlowProvider.js +9 -0
  33. package/dist/components/LinkAuth/LinkAuthItem.d.ts +13 -0
  34. package/dist/components/LinkAuth/LinkAuthItem.js +48 -0
  35. package/dist/components/LinkAuth/LinkAuthItems.d.ts +9 -0
  36. package/dist/components/LinkAuth/LinkAuthItems.js +47 -0
  37. package/dist/components/LinkAuth/LinkAuthProvider.d.ts +12 -0
  38. package/dist/components/LinkAuth/LinkAuthProvider.js +108 -0
  39. package/dist/components/LinkAuth/LinkAuthTitle.d.ts +9 -0
  40. package/dist/components/LinkAuth/LinkAuthTitle.js +19 -0
  41. package/dist/components/LinkAuth/index.d.ts +17 -0
  42. package/dist/components/LinkAuth/index.js +93 -0
  43. package/dist/components/LinkAuth/types.d.ts +32 -0
  44. package/dist/components/LinkAuth/types.js +5 -0
  45. package/dist/components/LinkAuth/utils.d.ts +4 -0
  46. package/dist/components/LinkAuth/utils.js +7 -0
  47. package/dist/components/LinkAuthModal/index.d.ts +21 -0
  48. package/dist/components/LinkAuthModal/index.js +69 -0
  49. package/dist/components/OAuthStatusModal/index.d.ts +7 -1
  50. package/dist/components/OAuthStatusModal/index.js +115 -93
  51. package/dist/components/SignIn/SignInAuthMethodButtons.js +36 -34
  52. package/dist/components/SignIn/SignInForm.d.ts +2 -1
  53. package/dist/components/SignIn/SignInForm.js +19 -18
  54. package/dist/components/SignIn/SignInProvider.d.ts +2 -1
  55. package/dist/components/SignIn/SignInProvider.js +22 -17
  56. package/dist/components/SignIn/flows/SignInWithEmail.d.ts +1 -1
  57. package/dist/components/SignIn/flows/SignInWithEmail.js +66 -61
  58. package/dist/components/SignIn/flows/SignInWithSms.d.ts +1 -1
  59. package/dist/components/SignIn/flows/SignInWithSms.js +90 -2987
  60. package/dist/components/SignIn/hooks/useSignInWithOAuth.d.ts +0 -1
  61. package/dist/components/SignIn/hooks/useSignInWithOAuth.js +19 -20
  62. package/dist/components/SignIn/index.d.ts +3 -1
  63. package/dist/components/SignIn/index.js +16 -11
  64. package/dist/components/SignIn/types.d.ts +2 -0
  65. package/dist/components/SignIn/useSignInReducer.js +1 -0
  66. package/dist/components/SignInModal/index.d.ts +3 -1
  67. package/dist/components/SignInModal/index.js +72 -65
  68. package/dist/components/forms/Label/index.d.ts +2 -2
  69. package/dist/components/forms/PhoneNumberInput/index.js +24 -22
  70. package/dist/components/ui/Banner/index.d.ts +7 -0
  71. package/dist/components/ui/Banner/index.js +27 -0
  72. package/dist/components/ui/IframeButton/index.d.ts +11 -0
  73. package/dist/components/ui/IframeButton/index.js +50 -0
  74. package/dist/components/ui/Modal/index.js +22 -22
  75. package/dist/components/ui/SwitchTransition/index.d.ts +3 -1
  76. package/dist/components/ui/SwitchTransition/index.js +1 -1
  77. package/dist/hooks/useKeyExportPostMessage.d.ts +37 -0
  78. package/dist/hooks/useKeyExportPostMessage.js +86 -0
  79. package/dist/hooks/useTransitionMap.d.ts +50 -0
  80. package/dist/hooks/useTransitionMap.js +92 -0
  81. package/dist/icons/IconCopy.d.ts +2 -0
  82. package/dist/icons/IconCopy.js +10 -0
  83. package/dist/icons/index.d.ts +1 -0
  84. package/dist/icons/index.js +20 -18
  85. package/dist/index.d.ts +2 -2
  86. package/dist/index.js +122 -107
  87. package/dist/theme/theme.d.ts +33 -4
  88. package/dist/theme/tokens.d.ts +99 -12
  89. package/dist/theme/tokens.js +29 -12
  90. package/dist/types/secureIframe.d.ts +30 -0
  91. package/dist/types/secureIframe.js +13 -0
  92. package/dist/utils/childrenHasComponent.d.ts +1 -1
  93. package/dist/utils/formatPhoneNumber.d.ts +1 -0
  94. package/dist/utils/formatPhoneNumber.js +2910 -0
  95. package/dist/utils/index.d.ts +1 -0
  96. package/dist/utils/index.js +8 -6
  97. package/dist/utils/sendIframeMessage.d.ts +1 -0
  98. package/dist/utils/sendIframeMessage.js +13 -0
  99. package/dist/utils/transition.d.ts +30 -0
  100. package/dist/utils/transition.js +43 -0
  101. package/dist/version.d.ts +1 -1
  102. package/dist/version.js +1 -1
  103. package/package.json +8 -9
  104. package/dist/assets/ManageAuth.css +0 -1
  105. package/dist/assets/ManageAuthItem.css +0 -1
  106. package/dist/assets/ManageAuthModal.css +0 -1
  107. package/dist/components/ManageAuth/ManageAuthItem.d.ts +0 -9
  108. package/dist/components/ManageAuth/ManageAuthItem.js +0 -77
  109. package/dist/components/ManageAuth/ManageAuthProvider.d.ts +0 -8
  110. package/dist/components/ManageAuth/ManageAuthProvider.js +0 -64
  111. package/dist/components/ManageAuth/index.d.ts +0 -9
  112. package/dist/components/ManageAuth/index.js +0 -51
  113. package/dist/components/ManageAuth/types.d.ts +0 -13
  114. package/dist/components/ManageAuth/types.js +0 -1
  115. package/dist/components/ManageAuthModal/index.d.ts +0 -20
  116. package/dist/components/ManageAuthModal/index.js +0 -53
@@ -0,0 +1,93 @@
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 "../CDPReactProvider/index.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";
9
+ import "libphonenumber-js";
10
+ import { toOAuthProviderType as H } from "../../utils/toOAuthProviderType.js";
11
+ import { a as M, L as v } from "../../chunks/LinkAuthFlow.BZtyaLN-.js";
12
+ import { u as mt } from "../../chunks/LinkAuthFlow.BZtyaLN-.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 = {
20
+ "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(
28
+ (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
+ },
31
+ [n]
32
+ ), B = u(() => {
33
+ if (m("right"), l.current?.canGoBack) {
34
+ l.current.goBack();
35
+ return;
36
+ }
37
+ 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(
43
+ async (t) => {
44
+ if (m("left"), t?.startsWith("oauth:")) {
45
+ const T = H(t);
46
+ if (T)
47
+ try {
48
+ await f(T), p(!0);
49
+ } catch (S) {
50
+ n({
51
+ type: "LINK_AUTH_METHOD_ERROR",
52
+ payload: { error: D(S) }
53
+ });
54
+ }
55
+ } else
56
+ e(g(t));
57
+ },
58
+ [f, e, p, n]
59
+ ), _ = typeof o == "function" ? o(a) : o;
60
+ return /* @__PURE__ */ r("div", { className: `${k["link-auth"]} ${c}`, ...s, children: /* @__PURE__ */ h(
61
+ M,
62
+ {
63
+ direction: E,
64
+ onBack: B,
65
+ onLink: R,
66
+ onLinkSuccess: F,
67
+ signInRef: l,
68
+ transitionRef: L,
69
+ children: [
70
+ _,
71
+ !_ && /* @__PURE__ */ h(w, { children: [
72
+ /* @__PURE__ */ h("div", { className: k.header, children: [
73
+ /* @__PURE__ */ r(K, {}),
74
+ /* @__PURE__ */ r(V, {})
75
+ ] }),
76
+ /* @__PURE__ */ r("div", { className: k.error, children: /* @__PURE__ */ r(b, {}) }),
77
+ /* @__PURE__ */ r(v, {})
78
+ ] })
79
+ ]
80
+ }
81
+ ) });
82
+ }, ut = (o) => (I("manage_auth"), /* @__PURE__ */ r(j, { children: /* @__PURE__ */ r(G, { ...o }) }));
83
+ 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
93
+ };
@@ -0,0 +1,32 @@
1
+ import { AuthMethod } from '../CDPReactProvider';
2
+ export type LinkAuthMethod = {
3
+ isLinked: boolean;
4
+ method: AuthMethod;
5
+ userAlias: string;
6
+ };
7
+ export interface LinkAuthState {
8
+ authMethods: LinkAuthMethod[];
9
+ error: string | null;
10
+ isPending: boolean;
11
+ methodToLink: AuthMethod | null;
12
+ }
13
+ export type LinkAuthAction = {
14
+ type: "LINK_AUTH_METHOD";
15
+ payload: {
16
+ method: LinkAuthState["methodToLink"];
17
+ };
18
+ } | {
19
+ type: "LINK_AUTH_METHOD_ERROR";
20
+ payload: {
21
+ error: LinkAuthState["error"];
22
+ };
23
+ } | {
24
+ type: "SET_AUTH_METHODS";
25
+ payload: {
26
+ methods: LinkAuthState["authMethods"];
27
+ };
28
+ } | {
29
+ type: "RESET_STATE";
30
+ };
31
+ export declare const LINK_AUTH_FLOW_VIEWS: readonly ["list", "email", "sms"];
32
+ export type LinkAuthFlowView = (typeof LINK_AUTH_FLOW_VIEWS)[number];
@@ -0,0 +1,5 @@
1
+ import "../CDPReactProvider/index.js";
2
+ const t = ["list", "email", "sms"];
3
+ export {
4
+ t as LINK_AUTH_FLOW_VIEWS
5
+ };
@@ -0,0 +1,4 @@
1
+ import { AuthMethod } from '../CDPReactProvider';
2
+ import { LinkAuthFlowView } from './types';
3
+ export declare const isView: (view: string) => view is LinkAuthFlowView;
4
+ export declare const methodToView: (method: AuthMethod | null) => LinkAuthFlowView;
@@ -0,0 +1,7 @@
1
+ import "../CDPReactProvider/index.js";
2
+ import { LINK_AUTH_FLOW_VIEWS as i } from "./types.js";
3
+ const t = (r) => i.includes(r), o = (r) => r && t(r) ? r : "list";
4
+ export {
5
+ t as isView,
6
+ o as methodToView
7
+ };
@@ -0,0 +1,21 @@
1
+ import { ReactNode } from 'react';
2
+ import { AuthMethod } from '../CDPReactProvider';
3
+ import { ButtonProps } from '../ui/Button';
4
+ import { ModalContentProps } from '../ui/Modal';
5
+ interface LinkAuthModalTriggerProps extends Partial<Pick<ButtonProps, "className" | "fullWidth" | "size" | "style" | "variant">> {
6
+ children?: ReactNode;
7
+ label?: ReactNode;
8
+ }
9
+ interface LinkAuthModalContentProps extends ModalContentProps {
10
+ onLinkSuccess?: (method: string) => void;
11
+ }
12
+ interface LinkAuthModalProps {
13
+ children?: ReactNode;
14
+ open?: boolean;
15
+ setIsOpen?: (value: boolean) => void;
16
+ onLinkSuccess?: (method: AuthMethod | null) => void;
17
+ }
18
+ declare const LinkAuthModalTrigger: ({ children, className, label, ...props }: LinkAuthModalTriggerProps) => import("react/jsx-runtime").JSX.Element;
19
+ declare const LinkAuthModalContent: (props: LinkAuthModalContentProps) => import("react/jsx-runtime").JSX.Element;
20
+ declare const LinkAuthModal: ({ children, open, setIsOpen, onLinkSuccess }: LinkAuthModalProps) => import("react/jsx-runtime").JSX.Element;
21
+ export { LinkAuthModal, LinkAuthModalContent, LinkAuthModalTrigger, type LinkAuthModalProps, type LinkAuthModalContentProps, type LinkAuthModalTriggerProps, };
@@ -0,0 +1,69 @@
1
+ import { jsx as o, jsxs as n, Fragment as d } from "react/jsx-runtime";
2
+ import { u as p } from "../../chunks/useSendComponentCallOnce.BHZMuo6E.js";
3
+ import { createContext as L, useMemo as f, useContext as g } from "react";
4
+ import { c as A } from "../../chunks/lite.1fxw3LjI.js";
5
+ import "../CDPReactProvider/index.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";
10
+ import { IconXMark as F } from "../../icons/IconXMark.js";
11
+ import { childrenHasComponent as c } from "../../utils/childrenHasComponent.js";
12
+ import { LinkAuthTitle as H } from "../LinkAuth/LinkAuthTitle.js";
13
+ import { LinkAuthFlowBackButton as j } from "../LinkAuth/LinkAuthFlowBackButton.js";
14
+ import { L as B } from "../../chunks/LinkAuthFlow.BZtyaLN-.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,
18
+ "close-icon": "LinkAuthModal-module__close-icon___Fe02C",
19
+ "close-button": "LinkAuthModal-module__close-button___x6j3c",
20
+ trigger: E
21
+ }, h = L(null), O = () => {
22
+ const e = g(h);
23
+ if (!e)
24
+ throw new Error("useLinkAuthModalContext must be used within a LinkAuthModal");
25
+ return e;
26
+ }, u = ({
27
+ children: e,
28
+ className: t = "",
29
+ label: l,
30
+ ...i
31
+ }) => /* @__PURE__ */ o(T, { asChild: !0, children: e || /* @__PURE__ */ o(m, { className: A(r.trigger, t), ...i, children: l || "Link accounts" }) }), a = (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: [
37
+ /* @__PURE__ */ o(H, {}),
38
+ /* @__PURE__ */ o(j, {}),
39
+ /* @__PURE__ */ o(N, { asChild: !0, children: /* @__PURE__ */ o(
40
+ m,
41
+ {
42
+ className: r["close-button"],
43
+ "aria-label": "Close",
44
+ size: "md",
45
+ variant: "transparentSecondary",
46
+ children: /* @__PURE__ */ o(F, { className: r["close-icon"] })
47
+ }
48
+ ) })
49
+ ] }),
50
+ /* @__PURE__ */ o("div", { className: r.error, children: /* @__PURE__ */ o(x, {}) }),
51
+ /* @__PURE__ */ o(B, {})
52
+ ] })
53
+ ] });
54
+ }, Z = ({ children: e, open: t, setIsOpen: l, onLinkSuccess: i }) => {
55
+ p("manage_auth_modal");
56
+ const _ = e ? c(e, u) : !1, s = e ? c(e, a) : !1, k = !_ && !s, M = f(() => ({ onLinkSuccess: i }), [i]);
57
+ return /* @__PURE__ */ o(h.Provider, { value: M, children: /* @__PURE__ */ o(b, { open: t, onOpenChange: l, children: k ? /* @__PURE__ */ n(d, { children: [
58
+ /* @__PURE__ */ o(u, { children: e }),
59
+ /* @__PURE__ */ o(a, {})
60
+ ] }) : /* @__PURE__ */ n(d, { children: [
61
+ e,
62
+ !s && /* @__PURE__ */ o(a, {})
63
+ ] }) }) });
64
+ };
65
+ export {
66
+ Z as LinkAuthModal,
67
+ a as LinkAuthModalContent,
68
+ u as LinkAuthModalTrigger
69
+ };
@@ -1,6 +1,12 @@
1
+ export declare const OAUTH_PROVIDER_SESSION_STORAGE_KEY = "cdp-react-sign-in-with-oauth-provider-name";
2
+ export declare const OAUTH_IS_ACCOUNT_LINK_SESSION_STORAGE_KEY = "cdp-react-sign-in-with-oauth-is-account-link";
1
3
  type OAuthStatusModalContentProps = {
4
+ isAccountLink?: boolean;
2
5
  handleClose: () => void;
3
6
  };
7
+ export declare const useOauthStatusModal: () => {
8
+ persistOAuthState: (isAccountLink?: boolean) => void;
9
+ };
4
10
  export declare const OAuthStatusModal: () => import("react/jsx-runtime").JSX.Element;
5
- export declare const OAuthStatusModalContent: ({ handleClose }: OAuthStatusModalContentProps) => import("react/jsx-runtime").JSX.Element;
11
+ export declare const OAuthStatusModalContent: ({ isAccountLink, handleClose, }: OAuthStatusModalContentProps) => import("react/jsx-runtime").JSX.Element;
6
12
  export default OAuthStatusModal;
@@ -1,90 +1,111 @@
1
- import { jsx as s, jsxs as e, Fragment as l } from "react/jsx-runtime";
1
+ import { jsx as s, jsxs as r, Fragment as S } from "react/jsx-runtime";
2
2
  import "@coinbase/cdp-core";
3
- import { useOAuthState as O } from "@coinbase/cdp-hooks";
4
- import { u as I } from "../../chunks/useSendComponentCallOnce.BHZMuo6E.js";
5
- import { useState as C, useEffect as u, useRef as g, useCallback as b } from "react";
6
- import { useProviderName as v } from "../CDPReactProvider/index.js";
7
- import { OAUTH_PROVIDER_SESSION_STORAGE_KEY as S } from "../SignIn/hooks/useSignInWithOAuth.js";
8
- import { CoinbaseFooter as T } from "../ui/CoinbaseFooter/index.js";
9
- import { LoadingSpinner as $ } from "../ui/LoadingSpinner/index.js";
10
- import { Modal as w, ModalContent as E, ModalTitle as P, ModalDescription as R } from "../ui/Modal/index.js";
11
- import { SwitchFadeTransition as y } from "../ui/SwitchFadeTransition/index.js";
12
- import { VisuallyHidden as f } from "../ui/VisuallyHidden/index.js";
13
- import { useTimer as k } from "../../hooks/useTimer.js";
14
- import { IconAppleLogo as x } from "../../icons/IconAppleLogo.js";
15
- import { IconCheck as L } from "../../icons/IconCheck.js";
16
- import { IconGoogleColorLogo as U } from "../../icons/IconGoogleColorLogo.js";
17
- import { IconXLogo as q } from "../../icons/IconXLogo.js";
18
- import { IconXMark as G } from "../../icons/IconXMark.js";
19
- import { capitalize as d } from "../../utils/capitalize.js";
20
- import '../../assets/OAuthStatusModal.css';const H = "OAuthStatusModal-module__status___vU6x7", K = "OAuthStatusModal-module__graphic___2fKoa", j = "OAuthStatusModal-module__pad___oooMz", D = "OAuthStatusModal-module__spinner___Q3dYq", F = "OAuthStatusModal-module__icon___Lj5Gf", Y = "OAuthStatusModal-module__subhead___Pg9GI", z = "OAuthStatusModal-module__description___0qOZY", V = "OAuthStatusModal-module__ring___mKwSb", W = "OAuthStatusModal-module__invisible___IeRd0", t = {
3
+ import { useOAuthState as I } from "@coinbase/cdp-hooks";
4
+ import { u as b } from "../../chunks/useSendComponentCallOnce.BHZMuo6E.js";
5
+ import { useCallback as N, useState as O, useEffect as h, useRef as A } from "react";
6
+ import { useProviderName as $ } from "../CDPReactProvider/index.js";
7
+ import { CoinbaseFooter as k } from "../ui/CoinbaseFooter/index.js";
8
+ import { LoadingSpinner as w } from "../ui/LoadingSpinner/index.js";
9
+ import { Modal as E, ModalContent as L, 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";
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 { IconXLogo as H } from "../../icons/IconXLogo.js";
17
+ import { IconXMark as q } from "../../icons/IconXMark.js";
18
+ import { capitalize as _ } from "../../utils/capitalize.js";
19
+ import '../../assets/OAuthStatusModal.css';const Y = "OAuthStatusModal-module__status___vU6x7", j = "OAuthStatusModal-module__graphic___2fKoa", D = "OAuthStatusModal-module__pad___oooMz", F = "OAuthStatusModal-module__spinner___Q3dYq", z = "OAuthStatusModal-module__icon___Lj5Gf", V = "OAuthStatusModal-module__subhead___Pg9GI", W = "OAuthStatusModal-module__description___0qOZY", X = "OAuthStatusModal-module__ring___mKwSb", J = "OAuthStatusModal-module__invisible___IeRd0", t = {
21
20
  "oauth-status-modal": "OAuthStatusModal-module__oauth-status-modal___I69Ii",
22
21
  "transition-wrapper": "OAuthStatusModal-module__transition-wrapper___TmPRh",
23
- status: H,
24
- graphic: K,
25
- pad: j,
26
- spinner: D,
27
- icon: F,
22
+ status: Y,
23
+ graphic: j,
24
+ pad: D,
25
+ spinner: F,
26
+ icon: z,
28
27
  "icon-success": "OAuthStatusModal-module__icon-success___gqMWr",
29
28
  "icon-error": "OAuthStatusModal-module__icon-error___psI7m",
30
- subhead: Y,
31
- description: z,
32
- ring: V,
29
+ subhead: V,
30
+ description: W,
31
+ ring: X,
33
32
  "ring-success": "OAuthStatusModal-module__ring-success___unyM9",
34
33
  "ring-error": "OAuthStatusModal-module__ring-error___OsgqU",
35
- invisible: W
36
- }, X = ["pending", "success", "error"], Mt = () => {
37
- I("oauth_status_modal");
38
- const [n, o] = C(!1), { oauthState: r } = O(), a = v();
39
- return u(() => {
40
- if (r?.status === "pending" || r?.status === "error" || r?.status === "success") {
41
- const c = sessionStorage.getItem(S);
42
- if (c === null || c !== a)
34
+ invisible: J
35
+ }, p = "cdp-react-sign-in-with-oauth-provider-name", g = "cdp-react-sign-in-with-oauth-is-account-link", Q = ["pending", "success", "error"], It = () => {
36
+ const n = $() || "";
37
+ return { persistOAuthState: N(
38
+ (e) => {
39
+ sessionStorage.setItem(p, n), sessionStorage.setItem(
40
+ g,
41
+ e ? "true" : "false"
42
+ );
43
+ },
44
+ [n]
45
+ ) };
46
+ }, Nt = () => {
47
+ b("oauth_status_modal");
48
+ const [n, o] = O(!1), { oauthState: e } = I(), [d, a] = O(!1), c = $(), u = e?.providerType || "google";
49
+ return h(() => {
50
+ if (e?.status === "pending" || e?.status === "error" || e?.status === "success") {
51
+ const l = sessionStorage.getItem(p);
52
+ if (l === null || l !== c)
43
53
  return;
44
- sessionStorage.removeItem(S), o(!0);
54
+ sessionStorage.removeItem(p), o(!0);
55
+ const m = sessionStorage.getItem(g) === "true";
56
+ sessionStorage.removeItem(g), a(m);
45
57
  }
46
- }, [r?.status, a]), /* @__PURE__ */ s(w, { open: n, onOpenChange: o, children: /* @__PURE__ */ e(E, { children: [
47
- /* @__PURE__ */ s(f, { children: /* @__PURE__ */ s(P, { children: "OAuth Status" }) }),
48
- /* @__PURE__ */ s(f, { children: /* @__PURE__ */ e(R, { children: [
49
- "Sign in with ",
50
- d(a),
58
+ }, [e?.status, c]), /* @__PURE__ */ s(E, { open: n, onOpenChange: o, children: /* @__PURE__ */ r(L, { children: [
59
+ /* @__PURE__ */ s(M, { children: /* @__PURE__ */ s(y, { children: "OAuth Status" }) }),
60
+ /* @__PURE__ */ s(M, { children: /* @__PURE__ */ r(R, { children: [
61
+ d ? `Linking your ${u} account` : `Signing in with ${u}`,
51
62
  " ",
52
- r?.status ? `${r?.status === "success" ? "successful" : r?.status === "error" ? "failed" : "pending"}` : ""
63
+ e?.status ? `${e?.status === "success" ? "successful" : e?.status === "error" ? "failed" : "pending"}` : ""
53
64
  ] }) }),
54
- /* @__PURE__ */ s(J, { handleClose: () => o(!1) })
65
+ /* @__PURE__ */ s(Z, { isAccountLink: d, handleClose: () => o(!1) })
55
66
  ] }) });
56
- }, J = ({ handleClose: n }) => {
57
- const { oauthState: o } = O(), r = o?.providerType || "google", { timeRemaining: a, start: c, reset: m } = k(), _ = g(null), p = g(null), A = 250, h = b((i) => {
58
- p.current === i || i === void 0 || (p.current = i, _.current?.transition.toggle(i));
67
+ }, Z = ({
68
+ isAccountLink: n,
69
+ handleClose: o
70
+ }) => {
71
+ const { oauthState: e } = I(), d = e?.providerType || "google", { timeRemaining: a, start: c, reset: u } = U(), l = A(null), m = A(null), v = 250, f = N((i) => {
72
+ m.current === i || i === void 0 || (m.current = i, l.current?.transition.toggle(i));
59
73
  }, []);
60
- return u(() => {
61
- h(o?.status), o?.status === "success" && c(3);
62
- }, [o?.status, h, c]), u(() => {
63
- a !== null && a <= 0 && (m(), n());
64
- }, [a, m, n]), /* @__PURE__ */ e("div", { className: t["oauth-status-modal"], children: [
74
+ return h(() => {
75
+ f(e?.status), e?.status === "success" && c(3);
76
+ }, [e?.status, f, c]), h(() => {
77
+ a !== null && a <= 0 && (u(), o());
78
+ }, [a, u, o]), /* @__PURE__ */ r("div", { className: t["oauth-status-modal"], children: [
65
79
  /* @__PURE__ */ s(
66
- y,
80
+ P,
67
81
  {
68
82
  animateHeight: !1,
69
- timeout: A,
70
- items: X,
83
+ timeout: v,
84
+ items: Q,
71
85
  initialEntered: !1,
72
- transitionRef: _,
86
+ transitionRef: l,
73
87
  className: t["transition-wrapper"],
74
- children: ({ itemKey: i, ...M }) => {
75
- const N = tt[i];
76
- return /* @__PURE__ */ s("div", { ...M, className: t.status, children: /* @__PURE__ */ s(N, { timeRemaining: a, provider: r }) });
88
+ children: ({ itemKey: i, ...C }) => {
89
+ const T = et[i];
90
+ return /* @__PURE__ */ s("div", { ...C, className: t.status, children: /* @__PURE__ */ s(
91
+ T,
92
+ {
93
+ isAccountLink: n,
94
+ timeRemaining: a,
95
+ provider: d
96
+ }
97
+ ) });
77
98
  }
78
99
  }
79
100
  ),
80
- /* @__PURE__ */ s(T, {})
101
+ /* @__PURE__ */ s(k, {})
81
102
  ] });
82
- }, Q = ({ provider: n }) => {
83
- const o = st[n];
84
- return /* @__PURE__ */ e(l, { children: [
85
- /* @__PURE__ */ e("div", { className: t.graphic, children: [
103
+ }, B = ({ isAccountLink: n, provider: o }) => {
104
+ const e = ot[o];
105
+ return /* @__PURE__ */ r(S, { children: [
106
+ /* @__PURE__ */ r("div", { className: t.graphic, children: [
86
107
  /* @__PURE__ */ s(
87
- $,
108
+ w,
88
109
  {
89
110
  strokeWidth: "5%",
90
111
  staticStroke: !0,
@@ -92,45 +113,46 @@ import '../../assets/OAuthStatusModal.css';const H = "OAuthStatusModal-module__s
92
113
  className: t.spinner
93
114
  }
94
115
  ),
95
- o && /* @__PURE__ */ s("span", { className: t.icon, children: /* @__PURE__ */ s(o, {}) })
96
- ] }),
97
- /* @__PURE__ */ e("p", { className: t.subhead, children: [
98
- "Signing in with ",
99
- d(n)
116
+ e && /* @__PURE__ */ s("span", { className: t.icon, children: /* @__PURE__ */ s(e, {}) })
100
117
  ] }),
118
+ /* @__PURE__ */ s("p", { className: t.subhead, children: n ? `Linking your ${_(o)} account` : `Signing in with ${_(o)}` }),
101
119
  /* @__PURE__ */ s("p", { className: t.description, children: "Just a moment..." })
102
120
  ] });
103
- }, Z = ({ timeRemaining: n, provider: o }) => /* @__PURE__ */ e(l, { children: [
104
- /* @__PURE__ */ e("div", { className: t.graphic, children: [
121
+ }, tt = ({
122
+ isAccountLink: n,
123
+ timeRemaining: o,
124
+ provider: e
125
+ }) => /* @__PURE__ */ r(S, { children: [
126
+ /* @__PURE__ */ r("div", { className: t.graphic, children: [
105
127
  /* @__PURE__ */ s("span", { className: `${t.ring} ${t["ring-success"]}` }),
106
- /* @__PURE__ */ s("span", { className: `${t.icon} ${t["icon-success"]}`, children: /* @__PURE__ */ s(L, {}) })
107
- ] }),
108
- /* @__PURE__ */ e("p", { className: t.subhead, children: [
109
- "Signed in with ",
110
- d(o)
128
+ /* @__PURE__ */ s("span", { className: `${t.icon} ${t["icon-success"]}`, children: /* @__PURE__ */ s(x, {}) })
111
129
  ] }),
112
- /* @__PURE__ */ e("p", { className: `${t.description} ${n === null ? t.invisible : ""}`, children: [
130
+ /* @__PURE__ */ s("p", { className: t.subhead, children: n ? `${_(e)} account linked` : `Signed in with ${_(e)}` }),
131
+ /* @__PURE__ */ r("p", { className: `${t.description} ${o === null ? t.invisible : ""}`, children: [
113
132
  "This window will automatically close in ",
114
- n ?? "soon"
133
+ o ?? "soon"
115
134
  ] })
116
- ] }), B = () => /* @__PURE__ */ e(l, { children: [
117
- /* @__PURE__ */ e("div", { className: `${t.graphic} ${t.pad}`, children: [
135
+ ] }), st = ({ isAccountLink: n }) => /* @__PURE__ */ r(S, { children: [
136
+ /* @__PURE__ */ r("div", { className: `${t.graphic} ${t.pad}`, children: [
118
137
  /* @__PURE__ */ s("span", { className: `${t.ring} ${t["ring-error"]}` }),
119
- /* @__PURE__ */ s("span", { className: `${t.icon} ${t["icon-error"]}`, children: /* @__PURE__ */ s(G, {}) })
138
+ /* @__PURE__ */ s("span", { className: `${t.icon} ${t["icon-error"]}`, children: /* @__PURE__ */ s(q, {}) })
120
139
  ] }),
121
- /* @__PURE__ */ s("p", { className: t.subhead, children: "Sign in failed" }),
140
+ /* @__PURE__ */ s("p", { className: t.subhead, children: n ? "Account linking failed" : "Sign in failed" }),
122
141
  /* @__PURE__ */ s("p", { className: t.description, children: "Something went wrong. Please try again." })
123
- ] }), tt = {
124
- pending: Q,
125
- success: Z,
126
- error: B
127
- }, st = {
128
- google: U,
129
- apple: x,
130
- x: q
142
+ ] }), et = {
143
+ pending: B,
144
+ success: tt,
145
+ error: st
146
+ }, ot = {
147
+ google: G,
148
+ apple: K,
149
+ x: H
131
150
  };
132
151
  export {
133
- Mt as OAuthStatusModal,
134
- J as OAuthStatusModalContent,
135
- Mt as default
152
+ g as OAUTH_IS_ACCOUNT_LINK_SESSION_STORAGE_KEY,
153
+ p as OAUTH_PROVIDER_SESSION_STORAGE_KEY,
154
+ Nt as OAuthStatusModal,
155
+ Z as OAuthStatusModalContent,
156
+ Nt as default,
157
+ It as useOauthStatusModal
136
158
  };
@@ -1,74 +1,76 @@
1
1
  import { jsx as n, jsxs as r } from "react/jsx-runtime";
2
- import { useCallback as I, useMemo as v } from "react";
3
- import { useAppConfig as y } from "../CDPReactProvider/index.js";
4
- import { useSignInWithOAuth as C } from "./hooks/useSignInWithOAuth.js";
5
- import { useSignInContext as S } from "./SignInProvider.js";
6
- import { Button as M } from "../ui/Button/index.js";
7
- import { ServerError as k } from "../ui/ServerError/index.js";
8
- import { IconAppleLogo as B } from "../../icons/IconAppleLogo.js";
9
- import { IconEnvelope as E } from "../../icons/IconEnvelope.js";
10
- import { IconGoogleLogo as P } from "../../icons/IconGoogleLogo.js";
11
- import { IconPhone as O } from "../../icons/IconPhone.js";
12
- import { IconXLogo as w } from "../../icons/IconXLogo.js";
13
- import { toOAuthProviderType as _ } from "../../utils/toOAuthProviderType.js";
14
- import '../../assets/SignInAuthMethodButtons.css';const x = "SignInAuthMethodButtons-module__divider___zphEh", o = {
2
+ import { useCallback as v, useMemo as y } from "react";
3
+ import "../CDPReactProvider/index.js";
4
+ import { useSignInWithOAuth as S } from "./hooks/useSignInWithOAuth.js";
5
+ import { useSignInContext as _ } from "./SignInProvider.js";
6
+ import { Button as C } 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 { IconXLogo as O } from "../../icons/IconXLogo.js";
13
+ import { toOAuthProviderType as b } from "../../utils/toOAuthProviderType.js";
14
+ import '../../assets/SignInAuthMethodButtons.css';const w = "SignInAuthMethodButtons-module__divider___zphEh", o = {
15
15
  "auth-method-buttons": "SignInAuthMethodButtons-module__auth-method-buttons___jYEH7",
16
16
  "auth-btn": "SignInAuthMethodButtons-module__auth-btn___o1a09",
17
17
  "auth-btn-icon": "SignInAuthMethodButtons-module__auth-btn-icon___VjvFY",
18
18
  "auth-btn-label": "SignInAuthMethodButtons-module__auth-btn-label___mEWd3",
19
- divider: x
20
- }, b = {
19
+ divider: w
20
+ }, g = {
21
21
  email: {
22
22
  label: "Continue with email",
23
- icon: /* @__PURE__ */ n(E, {})
23
+ icon: /* @__PURE__ */ n(B, {})
24
24
  },
25
25
  sms: {
26
26
  label: "Continue with phone",
27
- icon: /* @__PURE__ */ n(O, {})
27
+ icon: /* @__PURE__ */ n(P, {})
28
28
  },
29
29
  "oauth:google": {
30
30
  label: "Continue with Google",
31
- icon: /* @__PURE__ */ n(P, {})
31
+ icon: /* @__PURE__ */ n(E, {})
32
32
  },
33
33
  "oauth:apple": {
34
34
  label: "Continue with Apple",
35
- icon: /* @__PURE__ */ n(B, {})
35
+ icon: /* @__PURE__ */ n(k, {})
36
36
  },
37
37
  "oauth:x": {
38
38
  label: "Continue with X",
39
- icon: /* @__PURE__ */ n(w, {})
39
+ icon: /* @__PURE__ */ n(O, {})
40
40
  }
41
- }, V = ({ activeMethod: u }) => {
42
- const { authMethods: a } = y(), {
41
+ }, U = ({ activeMethod: u }) => {
42
+ const {
43
+ state: { authMethods: a }
44
+ } = _(), {
43
45
  signInWithOAuth: l,
44
46
  isPending: s,
45
47
  error: h,
46
48
  oauthProvider: c
47
- } = C(), m = I(
49
+ } = S(), m = v(
48
50
  async (t) => {
49
- const e = _(t);
51
+ const e = b(t);
50
52
  e && l(e);
51
53
  },
52
54
  [l]
53
- ), { dispatch: p } = S(), i = v(() => (a || ["email"]).map((t) => {
54
- if (!b[t])
55
+ ), { dispatch: d } = _(), i = y(() => (a || ["email"]).map((t) => {
56
+ if (!g[t])
55
57
  return null;
56
- const { label: e, icon: g } = b[t], d = t.startsWith("oauth:"), f = d ? () => m(t) : () => p({ type: "SET_AUTH_METHOD", payload: { authMethod: t } }), A = d && c.current === _(t) && s;
58
+ const { label: e, icon: f } = g[t], p = t.startsWith("oauth:"), A = p ? () => m(t) : () => d({ type: "SET_AUTH_METHOD", payload: { authMethod: t } }), I = p && c.current === b(t) && s;
57
59
  return {
58
60
  key: t,
59
61
  label: e,
60
- icon: g,
61
- onClick: f,
62
- isPending: A
62
+ icon: f,
63
+ onClick: A,
64
+ isPending: I
63
65
  };
64
- }).filter((t) => t !== null), [a, p, m, s, c]);
66
+ }).filter((t) => t !== null), [a, d, m, s, c]);
65
67
  return !i.length || i.length === 1 && i[0].key === u ? null : /* @__PURE__ */ r("div", { className: o["auth-method-buttons"], children: [
66
68
  /* @__PURE__ */ r("div", { className: o.divider, children: [
67
69
  /* @__PURE__ */ n("hr", {}),
68
70
  /* @__PURE__ */ n("span", { children: "or" })
69
71
  ] }),
70
72
  i.map((t) => t.key === u ? null : /* @__PURE__ */ r(
71
- M,
73
+ C,
72
74
  {
73
75
  "aria-label": t.ariaLabel,
74
76
  className: o["auth-btn"],
@@ -83,9 +85,9 @@ import '../../assets/SignInAuthMethodButtons.css';const x = "SignInAuthMethodBut
83
85
  },
84
86
  t.key
85
87
  )),
86
- h && /* @__PURE__ */ n(k, { error: h })
88
+ h && /* @__PURE__ */ n(M, { error: h })
87
89
  ] });
88
90
  };
89
91
  export {
90
- V as SignInAuthMethodButtons
92
+ U as SignInAuthMethodButtons
91
93
  };