@coinbase/cdp-react 0.0.58 → 0.0.61

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 (117) hide show
  1. package/README.md +10 -8
  2. package/dist/assets/Banner.css +1 -0
  3. package/dist/assets/CopyAddress.css +1 -0
  4. package/dist/assets/ExportWallet.css +1 -0
  5. package/dist/assets/ExportWalletModal.css +1 -0
  6. package/dist/assets/IframeButton.css +1 -0
  7. package/dist/assets/Input.css +1 -1
  8. package/dist/assets/LinkAuth.css +1 -0
  9. package/dist/assets/LinkAuthFlow.css +1 -0
  10. package/dist/assets/LinkAuthFlowBackButton.css +1 -0
  11. package/dist/assets/LinkAuthItem.css +1 -0
  12. package/dist/assets/LinkAuthItems.css +1 -0
  13. package/dist/assets/LinkAuthModal.css +1 -0
  14. package/dist/assets/LinkAuthTitle.css +1 -0
  15. package/dist/assets/SwitchSlideTransition.css +1 -1
  16. package/dist/chunks/LinkAuthFlow.CxSnHF2p.js +111 -0
  17. package/dist/components/CDPReactProvider/index.js +71 -55
  18. package/dist/components/CopyAddress/index.d.ts +8 -0
  19. package/dist/components/CopyAddress/index.js +61 -0
  20. package/dist/components/CopyEvmKeyButton/index.d.ts +13 -0
  21. package/dist/components/CopyEvmKeyButton/index.js +61 -0
  22. package/dist/components/CopySolanaKeyButton/index.d.ts +13 -0
  23. package/dist/components/CopySolanaKeyButton/index.js +61 -0
  24. package/dist/components/ExportWallet/index.d.ts +21 -0
  25. package/dist/components/ExportWallet/index.js +110 -0
  26. package/dist/components/ExportWalletModal/index.d.ts +18 -0
  27. package/dist/components/ExportWalletModal/index.js +96 -0
  28. package/dist/components/LinkAuth/LinkAuthFlow.d.ts +13 -0
  29. package/dist/components/LinkAuth/LinkAuthFlow.js +19 -0
  30. package/dist/components/LinkAuth/LinkAuthFlowBackButton.d.ts +9 -0
  31. package/dist/components/LinkAuth/LinkAuthFlowBackButton.js +40 -0
  32. package/dist/components/LinkAuth/LinkAuthFlowProvider.d.ts +33 -0
  33. package/dist/components/LinkAuth/LinkAuthFlowProvider.js +9 -0
  34. package/dist/components/LinkAuth/LinkAuthItem.d.ts +13 -0
  35. package/dist/components/LinkAuth/LinkAuthItem.js +48 -0
  36. package/dist/components/LinkAuth/LinkAuthItems.d.ts +9 -0
  37. package/dist/components/LinkAuth/LinkAuthItems.js +47 -0
  38. package/dist/components/LinkAuth/LinkAuthProvider.d.ts +12 -0
  39. package/dist/components/LinkAuth/LinkAuthProvider.js +108 -0
  40. package/dist/components/LinkAuth/LinkAuthTitle.d.ts +6 -0
  41. package/dist/components/LinkAuth/LinkAuthTitle.js +19 -0
  42. package/dist/components/LinkAuth/index.d.ts +17 -0
  43. package/dist/components/LinkAuth/index.js +93 -0
  44. package/dist/components/LinkAuth/types.d.ts +32 -0
  45. package/dist/components/LinkAuth/types.js +5 -0
  46. package/dist/components/LinkAuth/utils.d.ts +4 -0
  47. package/dist/components/LinkAuth/utils.js +7 -0
  48. package/dist/components/LinkAuthModal/index.d.ts +21 -0
  49. package/dist/components/LinkAuthModal/index.js +69 -0
  50. package/dist/components/OAuthStatusModal/index.d.ts +7 -1
  51. package/dist/components/OAuthStatusModal/index.js +115 -93
  52. package/dist/components/SignIn/SignInAuthMethodButtons.js +36 -34
  53. package/dist/components/SignIn/SignInForm.d.ts +2 -1
  54. package/dist/components/SignIn/SignInForm.js +19 -18
  55. package/dist/components/SignIn/SignInProvider.d.ts +2 -1
  56. package/dist/components/SignIn/SignInProvider.js +22 -17
  57. package/dist/components/SignIn/flows/SignInWithEmail.d.ts +1 -1
  58. package/dist/components/SignIn/flows/SignInWithEmail.js +66 -61
  59. package/dist/components/SignIn/flows/SignInWithSms.d.ts +1 -1
  60. package/dist/components/SignIn/flows/SignInWithSms.js +90 -2987
  61. package/dist/components/SignIn/hooks/useSignInWithOAuth.d.ts +0 -1
  62. package/dist/components/SignIn/hooks/useSignInWithOAuth.js +19 -20
  63. package/dist/components/SignIn/index.d.ts +3 -1
  64. package/dist/components/SignIn/index.js +16 -11
  65. package/dist/components/SignIn/types.d.ts +2 -0
  66. package/dist/components/SignIn/useSignInReducer.js +1 -0
  67. package/dist/components/SignInModal/index.d.ts +3 -1
  68. package/dist/components/SignInModal/index.js +72 -65
  69. package/dist/components/forms/Label/index.d.ts +2 -2
  70. package/dist/components/forms/PhoneNumberInput/index.js +24 -22
  71. package/dist/components/ui/Banner/index.d.ts +7 -0
  72. package/dist/components/ui/Banner/index.js +27 -0
  73. package/dist/components/ui/IframeButton/index.d.ts +11 -0
  74. package/dist/components/ui/IframeButton/index.js +50 -0
  75. package/dist/components/ui/Modal/index.js +22 -22
  76. package/dist/components/ui/SwitchTransition/index.d.ts +3 -1
  77. package/dist/components/ui/SwitchTransition/index.js +1 -1
  78. package/dist/hooks/useKeyExportPostMessage.d.ts +38 -0
  79. package/dist/hooks/useKeyExportPostMessage.js +83 -0
  80. package/dist/hooks/useTransitionMap.d.ts +50 -0
  81. package/dist/hooks/useTransitionMap.js +92 -0
  82. package/dist/icons/IconCopy.d.ts +2 -0
  83. package/dist/icons/IconCopy.js +10 -0
  84. package/dist/icons/index.d.ts +1 -0
  85. package/dist/icons/index.js +20 -18
  86. package/dist/index.d.ts +2 -2
  87. package/dist/index.js +122 -107
  88. package/dist/theme/theme.d.ts +33 -4
  89. package/dist/theme/tokens.d.ts +99 -12
  90. package/dist/theme/tokens.js +29 -12
  91. package/dist/types/secureIframe.d.ts +30 -0
  92. package/dist/types/secureIframe.js +13 -0
  93. package/dist/utils/childrenHasComponent.d.ts +1 -1
  94. package/dist/utils/formatPhoneNumber.d.ts +1 -0
  95. package/dist/utils/formatPhoneNumber.js +2910 -0
  96. package/dist/utils/index.d.ts +1 -0
  97. package/dist/utils/index.js +8 -6
  98. package/dist/utils/sendIframeMessage.d.ts +1 -0
  99. package/dist/utils/sendIframeMessage.js +13 -0
  100. package/dist/utils/transition.d.ts +30 -0
  101. package/dist/utils/transition.js +43 -0
  102. package/dist/version.d.ts +1 -1
  103. package/dist/version.js +1 -1
  104. package/package.json +8 -9
  105. package/dist/assets/ManageAuth.css +0 -1
  106. package/dist/assets/ManageAuthItem.css +0 -1
  107. package/dist/assets/ManageAuthModal.css +0 -1
  108. package/dist/components/ManageAuth/ManageAuthItem.d.ts +0 -9
  109. package/dist/components/ManageAuth/ManageAuthItem.js +0 -77
  110. package/dist/components/ManageAuth/ManageAuthProvider.d.ts +0 -8
  111. package/dist/components/ManageAuth/ManageAuthProvider.js +0 -64
  112. package/dist/components/ManageAuth/index.d.ts +0 -9
  113. package/dist/components/ManageAuth/index.js +0 -51
  114. package/dist/components/ManageAuth/types.d.ts +0 -13
  115. package/dist/components/ManageAuth/types.js +0 -1
  116. package/dist/components/ManageAuthModal/index.d.ts +0 -20
  117. package/dist/components/ManageAuthModal/index.js +0 -53
@@ -0,0 +1,110 @@
1
+ import { jsx as o, jsxs as d, Fragment as _ } from "react/jsx-runtime";
2
+ import { useCurrentUser as W } from "@coinbase/cdp-hooks";
3
+ import { c as i } from "../../chunks/lite.1fxw3LjI.js";
4
+ import { createContext as f, useMemo as c, useContext as C } from "react";
5
+ import { CopyAddress as w } from "../CopyAddress/index.js";
6
+ import { unstable_CopyEvmKeyButton as v } from "../CopyEvmKeyButton/index.js";
7
+ import { unstable_CopySolanaKeyButton as b } from "../CopySolanaKeyButton/index.js";
8
+ import { Banner as h } from "../ui/Banner/index.js";
9
+ import { CoinbaseFooter as A } from "../ui/CoinbaseFooter/index.js";
10
+ import "../../index.js";
11
+ import { useAppConfig as B } from "../CDPReactProvider/index.js";
12
+ import '../../assets/ExportWallet.css';const F = "ExportWallet-module__footer___NvrFY", u = {
13
+ "export-wallet": "ExportWallet-module__export-wallet___EyZys",
14
+ "export-wallet-title": "ExportWallet-module__export-wallet-title___MuI09",
15
+ footer: F
16
+ }, x = f({
17
+ address: "",
18
+ type: "evm"
19
+ }), m = () => {
20
+ const t = C(x);
21
+ if (!t)
22
+ throw new Error("useExportWalletContext must be used within a ExportWalletProvider");
23
+ return t;
24
+ }, K = ({
25
+ address: t,
26
+ children: r,
27
+ onIframeError: e,
28
+ onIframeReady: n,
29
+ onCopySuccess: l
30
+ }) => {
31
+ const { currentUser: a } = W(), p = c(
32
+ () => !!a?.solanaAccounts?.find((E) => E === t),
33
+ [a?.solanaAccounts, t]
34
+ ) ? "solana" : "evm", y = c(
35
+ () => ({ address: t, type: p, onIframeError: e, onIframeReady: n, onCopySuccess: l }),
36
+ [t, p, e, n, l]
37
+ );
38
+ return /* @__PURE__ */ o(x.Provider, { value: y, children: r });
39
+ }, S = ({
40
+ children: t,
41
+ className: r = "",
42
+ as: e = "h2",
43
+ ...n
44
+ }) => /* @__PURE__ */ o(e, { className: i(u["export-wallet-title"], r), ...n, children: t || "Export your wallet" }), g = (t) => /* @__PURE__ */ o(h, { variant: "warning", ...t, children: "Do not share your private key with anyone" }), N = ({
45
+ label: t = "Your wallet address",
46
+ ...r
47
+ }) => {
48
+ const { address: e } = m();
49
+ return /* @__PURE__ */ o(w, { address: e, label: t, ...r });
50
+ }, P = ({
51
+ fullWidth: t = !0,
52
+ ...r
53
+ }) => {
54
+ const { address: e, type: n, onIframeError: l, onIframeReady: a, onCopySuccess: s } = m();
55
+ return n === "solana" ? /* @__PURE__ */ o(
56
+ b,
57
+ {
58
+ fullWidth: t,
59
+ address: e,
60
+ onError: l,
61
+ onReady: a,
62
+ onSuccess: s,
63
+ ...r
64
+ }
65
+ ) : n === "evm" ? /* @__PURE__ */ o(
66
+ v,
67
+ {
68
+ fullWidth: t,
69
+ address: e,
70
+ onError: l,
71
+ onReady: a,
72
+ onSuccess: s,
73
+ ...r
74
+ }
75
+ ) : null;
76
+ }, j = (t) => /* @__PURE__ */ o(A, { ...t }), z = ({
77
+ address: t,
78
+ children: r,
79
+ className: e = "",
80
+ onIframeError: n,
81
+ onIframeReady: l,
82
+ onCopySuccess: a,
83
+ ...s
84
+ }) => {
85
+ const { showCoinbaseFooter: p } = B();
86
+ return /* @__PURE__ */ o("div", { className: i(u["export-wallet"], e), ...s, children: /* @__PURE__ */ o(
87
+ K,
88
+ {
89
+ address: t,
90
+ onIframeReady: l,
91
+ onCopySuccess: a,
92
+ onIframeError: n,
93
+ children: r || /* @__PURE__ */ d(_, { children: [
94
+ /* @__PURE__ */ o(S, {}),
95
+ /* @__PURE__ */ o(g, {}),
96
+ /* @__PURE__ */ o(N, {}),
97
+ /* @__PURE__ */ o(P, {}),
98
+ p && /* @__PURE__ */ o(j, { className: u.footer })
99
+ ] })
100
+ }
101
+ ) });
102
+ };
103
+ export {
104
+ z as unstable_ExportWallet,
105
+ N as unstable_ExportWalletCopyAddress,
106
+ P as unstable_ExportWalletCopyKeyButton,
107
+ j as unstable_ExportWalletFooter,
108
+ S as unstable_ExportWalletTitle,
109
+ g as unstable_ExportWalletWarning
110
+ };
@@ -0,0 +1,18 @@
1
+ import { ReactNode } from 'react';
2
+ import { unstable_ExportWalletProps as ExportWalletProps } from '../ExportWallet';
3
+ import { ButtonProps } from '../ui/Button';
4
+ import { ModalContentProps } from '../ui/Modal';
5
+ interface ExportWalletModalTriggerProps extends Partial<Pick<ButtonProps, "className" | "fullWidth" | "size" | "style" | "variant">> {
6
+ children?: ReactNode;
7
+ label?: ReactNode;
8
+ }
9
+ type ExportWalletModalContentProps = ModalContentProps;
10
+ interface ExportWalletModalProps extends Pick<ExportWalletProps, "address" | "onIframeReady" | "onCopySuccess" | "onIframeError"> {
11
+ children?: ReactNode;
12
+ open?: boolean;
13
+ setIsOpen?: (value: boolean) => void;
14
+ }
15
+ declare const ExportWalletModalTrigger: ({ children, className, label, ...props }: ExportWalletModalTriggerProps) => import("react/jsx-runtime").JSX.Element;
16
+ declare const ExportWalletModalContent: ({ children, className, ...props }: ExportWalletModalContentProps) => import("react/jsx-runtime").JSX.Element;
17
+ declare const ExportWalletModal: ({ address, children, onIframeReady, onCopySuccess, onIframeError, open, setIsOpen, }: ExportWalletModalProps) => import("react/jsx-runtime").JSX.Element;
18
+ export { ExportWalletModal as unstable_ExportWalletModal, ExportWalletModalTrigger as unstable_ExportWalletModalTrigger, ExportWalletModalContent as unstable_ExportWalletModalContent, type ExportWalletModalProps as unstable_ExportWalletModalProps, type ExportWalletModalTriggerProps as unstable_ExportWalletModalTriggerProps, type ExportWalletModalContentProps as unstable_ExportWalletModalContentProps, };
@@ -0,0 +1,96 @@
1
+ import { jsx as t, jsxs as n, Fragment as _ } from "react/jsx-runtime";
2
+ import { u as g } from "../../chunks/useSendComponentCallOnce.BHZMuo6E.js";
3
+ import { createContext as b, useMemo as h, useContext as y } from "react";
4
+ import { c as E } from "../../chunks/lite.1fxw3LjI.js";
5
+ import { useAppConfig as T } from "../CDPReactProvider/index.js";
6
+ import { unstable_ExportWallet as w, unstable_ExportWalletWarning as N, unstable_ExportWalletCopyAddress as v, unstable_ExportWalletCopyKeyButton as A, unstable_ExportWalletFooter as F, unstable_ExportWalletTitle as j } from "../ExportWallet/index.js";
7
+ import { Button as W } from "../ui/Button/index.js";
8
+ import { Modal as k, ModalTrigger as B, ModalContent as K, ModalTitle as P, ModalClose as R } from "../ui/Modal/index.js";
9
+ import { IconXMark as z } from "../../icons/IconXMark.js";
10
+ import { childrenHasComponent as m } from "../../utils/childrenHasComponent.js";
11
+ import '../../assets/ExportWalletModal.css';const D = "ExportWalletModal-module__trigger___zMk8N", I = "ExportWalletModal-module__content___KzNol", O = "ExportWalletModal-module__footer___byg1T", S = "ExportWalletModal-module__modal___pX1AP", e = {
12
+ "export-wallet": "ExportWalletModal-module__export-wallet___--L56",
13
+ "no-footer": "ExportWalletModal-module__no-footer___J8uj2",
14
+ trigger: D,
15
+ "title-bar": "ExportWalletModal-module__title-bar___RTPZq",
16
+ content: I,
17
+ "close-button": "ExportWalletModal-module__close-button___ImsDR",
18
+ "close-icon": "ExportWalletModal-module__close-icon___iAfyT",
19
+ footer: O,
20
+ modal: S
21
+ }, M = b(null), X = () => {
22
+ const o = y(M);
23
+ if (!o)
24
+ throw new Error("useExportWalletModalContext must be used within a ExportWalletModal");
25
+ return o;
26
+ }, u = ({
27
+ children: o,
28
+ className: l = "",
29
+ label: r,
30
+ ...a
31
+ }) => /* @__PURE__ */ t(B, { asChild: !0, children: o || /* @__PURE__ */ t(W, { className: E(e.trigger, l), ...a, children: r || "Export wallet" }) }), $ = ({
32
+ children: o = "Copy private key to export wallet",
33
+ ...l
34
+ }) => /* @__PURE__ */ t(P, { asChild: !0, children: /* @__PURE__ */ t(j, { ...l, children: o }) }), q = ({ children: o }) => /* @__PURE__ */ t(R, { asChild: !0, children: o || /* @__PURE__ */ t(
35
+ W,
36
+ {
37
+ "aria-label": "Close",
38
+ className: e["close-button"],
39
+ variant: "transparentSecondary",
40
+ children: /* @__PURE__ */ t(z, { className: e["close-icon"] })
41
+ }
42
+ ) }), i = ({
43
+ children: o,
44
+ className: l = "",
45
+ ...r
46
+ }) => {
47
+ const { showCoinbaseFooter: a } = T(), { address: s, onIframeReady: d, onCopySuccess: p, onIframeError: c } = X();
48
+ return /* @__PURE__ */ t(K, { "aria-describedby": void 0, className: E(e.modal, l), ...r, children: /* @__PURE__ */ t(
49
+ w,
50
+ {
51
+ address: s,
52
+ onIframeReady: d,
53
+ onCopySuccess: p,
54
+ onIframeError: c,
55
+ className: `${e["export-wallet"]} ${a ? "" : e["no-footer"]}`,
56
+ children: o || /* @__PURE__ */ n(_, { children: [
57
+ /* @__PURE__ */ n("div", { className: e["title-bar"], children: [
58
+ /* @__PURE__ */ t($, {}),
59
+ /* @__PURE__ */ t(q, {})
60
+ ] }),
61
+ /* @__PURE__ */ n("div", { className: e.content, children: [
62
+ /* @__PURE__ */ t(N, {}),
63
+ /* @__PURE__ */ t(v, {}),
64
+ /* @__PURE__ */ t(A, {}),
65
+ a && /* @__PURE__ */ t(F, { className: e.footer })
66
+ ] })
67
+ ] })
68
+ }
69
+ ) });
70
+ }, ot = ({
71
+ address: o,
72
+ children: l,
73
+ onIframeReady: r,
74
+ onCopySuccess: a,
75
+ onIframeError: s,
76
+ open: d,
77
+ setIsOpen: p
78
+ }) => {
79
+ g("export_wallet_modal");
80
+ const c = h(
81
+ () => ({ address: o, onIframeReady: r, onCopySuccess: a, onIframeError: s }),
82
+ [o, r, a, s]
83
+ ), C = l ? m(l, u) : !1, x = l ? m(l, i) : !1, f = !C && !x;
84
+ return /* @__PURE__ */ t(M.Provider, { value: c, children: /* @__PURE__ */ t(k, { open: d, onOpenChange: p, children: f ? /* @__PURE__ */ n(_, { children: [
85
+ /* @__PURE__ */ t(u, { children: l }),
86
+ /* @__PURE__ */ t(i, {})
87
+ ] }) : /* @__PURE__ */ n(_, { children: [
88
+ l,
89
+ !x && /* @__PURE__ */ t(i, {})
90
+ ] }) }) });
91
+ };
92
+ export {
93
+ ot as unstable_ExportWalletModal,
94
+ i as unstable_ExportWalletModalContent,
95
+ u as unstable_ExportWalletModalTrigger
96
+ };
@@ -0,0 +1,13 @@
1
+ import { ReactNode } from 'react';
2
+ import { LinkAuthFlowView } from './types';
3
+ export interface SignInContentRef {
4
+ canGoBack: boolean;
5
+ goBack: () => void;
6
+ }
7
+ export interface LinkAuthFlowProps {
8
+ children?: ((props: {
9
+ view: LinkAuthFlowView;
10
+ Content: ReactNode;
11
+ }) => ReactNode) | undefined;
12
+ }
13
+ export declare const LinkAuthFlow: ({ children }: LinkAuthFlowProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,19 @@
1
+ import "react/jsx-runtime";
2
+ import "react";
3
+ import "../CDPReactProvider/index.js";
4
+ import "../SignIn/index.js";
5
+ import "@coinbase/cdp-hooks";
6
+ import "../ui/SwitchSlideTransition/index.js";
7
+ import "../ui/VisuallyHidden/index.js";
8
+ import { L as x } from "../../chunks/LinkAuthFlow.CxSnHF2p.js";
9
+ import "./LinkAuthItems.js";
10
+ import "./types.js";
11
+ import "../SignIn/SignInProvider.js";
12
+ import "../SignIn/SignInImage.js";
13
+ import "../SignIn/SignInForm.js";
14
+ import "../SignIn/SignInTitle.js";
15
+ import "../SignIn/SignInDescription.js";
16
+ import "../SignIn/SignInFooter.js";
17
+ export {
18
+ x as LinkAuthFlow
19
+ };
@@ -0,0 +1,9 @@
1
+ import { ButtonHTMLAttributes } from 'react';
2
+ import { ButtonProps } from '../ui/Button/Button';
3
+ import { LinkAuthFlowView } from './types';
4
+ export interface LinkAuthFlowBackButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
5
+ view?: LinkAuthFlowView;
6
+ size?: ButtonProps["size"];
7
+ variant?: ButtonProps["variant"];
8
+ }
9
+ export declare const LinkAuthFlowBackButton: ({ ["aria-label"]: ariaLabel, children, className, size, onClick, variant, view: viewFromProps, ...props }: LinkAuthFlowBackButtonProps) => import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,40 @@
1
+ import { jsx as t } from "react/jsx-runtime";
2
+ import { c as k } from "../../chunks/lite.1fxw3LjI.js";
3
+ import "react";
4
+ import { Button as p } from "../ui/Button/index.js";
5
+ import { IconArrowLeft as f } from "../../icons/IconArrowLeft.js";
6
+ import { b as w } from "../../chunks/LinkAuthFlow.CxSnHF2p.js";
7
+ import { useLinkAuthContext as _ } from "./LinkAuthProvider.js";
8
+ import "../CDPReactProvider/index.js";
9
+ import { methodToView as b } from "./utils.js";
10
+ import '../../assets/LinkAuthFlowBackButton.css';const h = "LinkAuthFlowBackButton-module__button___wPKfW", B = "LinkAuthFlowBackButton-module__icon___OUmzY", o = {
11
+ button: h,
12
+ icon: B
13
+ }, T = ({
14
+ ["aria-label"]: n = "Back",
15
+ children: r,
16
+ className: i = "",
17
+ size: e = "md",
18
+ onClick: c,
19
+ variant: m = "transparentSecondary",
20
+ view: a,
21
+ ...s
22
+ }) => {
23
+ const { back: u } = w(), { state: l } = _();
24
+ return (a || b(l.methodToLink)) === "list" ? null : /* @__PURE__ */ t(
25
+ p,
26
+ {
27
+ type: "button",
28
+ "aria-label": n,
29
+ className: k(o.button, i),
30
+ onClick: c ?? u,
31
+ size: e,
32
+ variant: m,
33
+ ...s,
34
+ children: r || /* @__PURE__ */ t(f, { className: o.icon })
35
+ }
36
+ );
37
+ };
38
+ export {
39
+ T as LinkAuthFlowBackButton
40
+ };
@@ -0,0 +1,33 @@
1
+ import { ReactNode, RefObject } from 'react';
2
+ import { AuthMethod } from '../CDPReactProvider';
3
+ import { SwitchSlideTransitionRef } from '../ui/SwitchSlideTransition';
4
+ import { SignInContentRef } from './LinkAuthFlow';
5
+ import { LinkAuthFlowView } from './types';
6
+ export interface LinkAuthFlowContextValue {
7
+ back: () => void;
8
+ direction?: "left" | "right";
9
+ link: (method: AuthMethod) => void;
10
+ linkSuccess: () => void;
11
+ }
12
+ export interface LinkAuthFlowContextValueInternal extends LinkAuthFlowContextValue {
13
+ transitionRef: RefObject<SwitchSlideTransitionRef<LinkAuthFlowView> | null> | null;
14
+ signInRef: RefObject<SignInContentRef | null> | null;
15
+ }
16
+ interface LinkAuthFlowProviderProps {
17
+ children?: ReactNode;
18
+ direction?: LinkAuthFlowContextValue["direction"];
19
+ onBack: LinkAuthFlowContextValue["back"];
20
+ onLink: LinkAuthFlowContextValue["link"];
21
+ onLinkSuccess: LinkAuthFlowContextValue["linkSuccess"];
22
+ transitionRef: LinkAuthFlowContextValueInternal["transitionRef"];
23
+ signInRef: LinkAuthFlowContextValueInternal["signInRef"];
24
+ }
25
+ export declare const useLinkAuthFlowInternal: () => LinkAuthFlowContextValueInternal;
26
+ export declare const useLinkAuthFlow: () => {
27
+ back: () => void;
28
+ direction?: "left" | "right";
29
+ link: (method: AuthMethod) => void;
30
+ linkSuccess: () => void;
31
+ };
32
+ export declare const LinkAuthFlowProvider: ({ direction, children, onBack, onLink, onLinkSuccess, signInRef, transitionRef, }: LinkAuthFlowProviderProps) => import("react/jsx-runtime").JSX.Element;
33
+ export {};
@@ -0,0 +1,9 @@
1
+ import "react/jsx-runtime";
2
+ import "react";
3
+ import "../CDPReactProvider/index.js";
4
+ import { a, u as e, b as n } from "../../chunks/LinkAuthFlow.CxSnHF2p.js";
5
+ export {
6
+ a as LinkAuthFlowProvider,
7
+ e as useLinkAuthFlow,
8
+ n as useLinkAuthFlowInternal
9
+ };
@@ -0,0 +1,13 @@
1
+ import { MouseEventHandler, ReactNode } from 'react';
2
+ import { LinkAuthMethod } from './types';
3
+ interface LinkAuthItemProps {
4
+ authMethod: LinkAuthMethod["method"];
5
+ isLinked: boolean;
6
+ isPending?: boolean;
7
+ icon?: ReactNode;
8
+ label: string;
9
+ userAlias?: string;
10
+ onLink: MouseEventHandler<HTMLButtonElement>;
11
+ }
12
+ declare const LinkAuthItem: ({ authMethod: _authMethod, userAlias, icon, isLinked, isPending, label, onLink, }: LinkAuthItemProps) => import("react/jsx-runtime").JSX.Element;
13
+ export { LinkAuthItem, type LinkAuthItemProps };
@@ -0,0 +1,48 @@
1
+ import { jsxs as _, jsx as t } from "react/jsx-runtime";
2
+ import "react";
3
+ import { Button as o } from "../ui/Button/index.js";
4
+ import { IconMinus as u } from "../../icons/IconMinus.js";
5
+ import { IconPlus as s } from "../../icons/IconPlus.js";
6
+ import "../CDPReactProvider/index.js";
7
+ import '../../assets/LinkAuthItem.css';const d = "LinkAuthItem-module__item___NE3CT", l = "LinkAuthItem-module__button___nM5Tc", i = {
8
+ item: d,
9
+ "item-icon": "LinkAuthItem-module__item-icon___ZIQny",
10
+ "item-text": "LinkAuthItem-module__item-text___-5DVL",
11
+ "item-action": "LinkAuthItem-module__item-action___4wOIN",
12
+ button: l
13
+ }, v = ({
14
+ authMethod: h,
15
+ userAlias: a,
16
+ icon: m,
17
+ isLinked: r,
18
+ isPending: n,
19
+ label: e,
20
+ onLink: c
21
+ }) => /* @__PURE__ */ _("div", { className: i.item, children: [
22
+ m && /* @__PURE__ */ t("div", { className: i["item-icon"], children: m }),
23
+ /* @__PURE__ */ t("div", { className: i["item-text"], children: a || e }),
24
+ /* @__PURE__ */ t("div", { className: i["item-action"], children: r ? /* @__PURE__ */ t(
25
+ o,
26
+ {
27
+ variant: "secondary",
28
+ className: i.button,
29
+ isPending: n,
30
+ disabled: !0,
31
+ "aria-label": `Unlink ${e}`,
32
+ children: /* @__PURE__ */ t(u, { "aria-hidden": "true" })
33
+ }
34
+ ) : /* @__PURE__ */ t(
35
+ o,
36
+ {
37
+ variant: "primary",
38
+ className: i.button,
39
+ onClick: c,
40
+ "aria-label": `Link ${e}`,
41
+ isPending: n,
42
+ children: /* @__PURE__ */ t(s, { "aria-hidden": "true" })
43
+ }
44
+ ) })
45
+ ] });
46
+ export {
47
+ v as LinkAuthItem
48
+ };
@@ -0,0 +1,9 @@
1
+ import { HTMLAttributes, ReactNode } from 'react';
2
+ import { AuthMethod } from '../CDPReactProvider';
3
+ import { LinkAuthItemProps } from './LinkAuthItem';
4
+ interface LinkAuthItemsProps extends Omit<HTMLAttributes<HTMLUListElement>, "children"> {
5
+ children?: (props: LinkAuthItemProps) => ReactNode;
6
+ onLink?: (method: AuthMethod) => void | Promise<void>;
7
+ }
8
+ declare const LinkAuthItems: ({ children, className, onLink, ...props }: LinkAuthItemsProps) => import("react/jsx-runtime").JSX.Element;
9
+ export { LinkAuthItems, type LinkAuthItemsProps };
@@ -0,0 +1,47 @@
1
+ import { jsx as l } from "react/jsx-runtime";
2
+ import { c as I } from "../../chunks/lite.1fxw3LjI.js";
3
+ import { useMemo as b } from "react";
4
+ import "../CDPReactProvider/index.js";
5
+ import { IconAppleLogo as d } from "../../icons/IconAppleLogo.js";
6
+ import { IconEnvelope as f } from "../../icons/IconEnvelope.js";
7
+ import { IconGoogleColorLogo as L } from "../../icons/IconGoogleColorLogo.js";
8
+ import { IconPhone as g } from "../../icons/IconPhone.js";
9
+ import { IconXLogo as _ } from "../../icons/IconXLogo.js";
10
+ import { LinkAuthItem as A } from "./LinkAuthItem.js";
11
+ import { useLinkAuthContext as P } from "./LinkAuthProvider.js";
12
+ import '../../assets/LinkAuthItems.css';const k = "LinkAuthItems-module__list___5AimM", x = {
13
+ list: k
14
+ }, M = {
15
+ email: { Icon: /* @__PURE__ */ l(f, { "aria-label": "Email" }), label: "Email" },
16
+ sms: { Icon: /* @__PURE__ */ l(g, { "aria-label": "Phone" }), label: "Phone" },
17
+ "oauth:google": { Icon: /* @__PURE__ */ l(L, { "aria-label": "Google" }), label: "Google" },
18
+ "oauth:apple": { Icon: /* @__PURE__ */ l(d, { "aria-label": "Apple" }), label: "Apple" },
19
+ "oauth:x": { Icon: /* @__PURE__ */ l(_, { "aria-label": "X" }), label: "X" }
20
+ }, D = ({ children: m, className: s = "", onLink: e, ...c }) => {
21
+ const { state: p, dispatch: i } = P(), { authMethods: a, isPending: n, methodToLink: r } = p, h = b(() => a.map((o) => {
22
+ const { Icon: t, label: u } = M[o.method];
23
+ return {
24
+ ...o,
25
+ icon: t,
26
+ label: u,
27
+ onLink: async () => {
28
+ i({ type: "LINK_AUTH_METHOD", payload: { method: o.method } }), await e?.(o.method);
29
+ }
30
+ };
31
+ }), [a, i, e]);
32
+ return /* @__PURE__ */ l("ul", { className: I(x.list, s), ...c, children: h.map(({ method: o, ...t }) => /* @__PURE__ */ l("li", { children: m?.({
33
+ ...t,
34
+ authMethod: o,
35
+ isPending: n && r === o
36
+ }) || /* @__PURE__ */ l(
37
+ A,
38
+ {
39
+ ...t,
40
+ authMethod: o,
41
+ isPending: n && r === o
42
+ }
43
+ ) }, o)) });
44
+ };
45
+ export {
46
+ D as LinkAuthItems
47
+ };
@@ -0,0 +1,12 @@
1
+ import { Dispatch, ReactNode } from 'react';
2
+ import { LinkAuthAction, LinkAuthState } from './types';
3
+ interface LinkAuthContextValue {
4
+ state: LinkAuthState;
5
+ dispatch: Dispatch<LinkAuthAction>;
6
+ }
7
+ interface LinkAuthProviderProps {
8
+ children: ReactNode;
9
+ }
10
+ declare const LinkAuthProvider: ({ children }: LinkAuthProviderProps) => import("react/jsx-runtime").JSX.Element;
11
+ declare const useLinkAuthContext: () => LinkAuthContextValue;
12
+ export { LinkAuthProvider, useLinkAuthContext, type LinkAuthProviderProps, type LinkAuthContextValue, };
@@ -0,0 +1,108 @@
1
+ import { jsx as m } from "react/jsx-runtime";
2
+ import { useCurrentUser as c } from "@coinbase/cdp-hooks";
3
+ import { createContext as p, useContext as M, useMemo as r, useReducer as A, useEffect as f } from "react";
4
+ import { useAppConfig as L } from "../CDPReactProvider/index.js";
5
+ import { formatPhoneNumber as k } from "../../utils/formatPhoneNumber.js";
6
+ const T = {
7
+ methodToLink: null,
8
+ authMethods: [],
9
+ error: null,
10
+ isPending: !1
11
+ }, d = p(void 0), E = (e, t) => {
12
+ switch (t) {
13
+ case "email":
14
+ return {
15
+ userAlias: e.authenticationMethods.email?.email ?? "",
16
+ isLinked: !!e.authenticationMethods.email
17
+ };
18
+ case "sms":
19
+ return {
20
+ userAlias: e.authenticationMethods.sms?.phoneNumber ? k(e.authenticationMethods.sms?.phoneNumber) : "",
21
+ isLinked: !!e.authenticationMethods.sms
22
+ };
23
+ case "oauth:google":
24
+ return {
25
+ userAlias: e.authenticationMethods.google?.email ?? "",
26
+ isLinked: !!e.authenticationMethods.google
27
+ };
28
+ case "oauth:apple":
29
+ return {
30
+ userAlias: e.authenticationMethods.apple?.email ?? "",
31
+ isLinked: !!e.authenticationMethods.apple
32
+ };
33
+ case "oauth:x":
34
+ return {
35
+ userAlias: (e.authenticationMethods.x?.username ? `@${e.authenticationMethods.x.username}` : e.authenticationMethods.x?.email) ?? "",
36
+ isLinked: !!e.authenticationMethods.x
37
+ };
38
+ default:
39
+ return null;
40
+ }
41
+ };
42
+ function g(e, t) {
43
+ switch (t.type) {
44
+ case "LINK_AUTH_METHOD":
45
+ return {
46
+ ...e,
47
+ error: null,
48
+ isPending: !0,
49
+ methodToLink: t.payload.method
50
+ };
51
+ case "LINK_AUTH_METHOD_ERROR":
52
+ return {
53
+ ...e,
54
+ isPending: !1,
55
+ error: t.payload.error
56
+ };
57
+ case "SET_AUTH_METHODS":
58
+ return {
59
+ ...e,
60
+ authMethods: t.payload.methods
61
+ };
62
+ case "RESET_STATE":
63
+ return {
64
+ authMethods: e.authMethods,
65
+ methodToLink: null,
66
+ error: null,
67
+ isPending: !1
68
+ };
69
+ default:
70
+ throw new Error("Unknown action type");
71
+ }
72
+ }
73
+ const y = ({ children: e }) => {
74
+ const { currentUser: t } = c(), { authMethods: a } = L(), s = r(() => {
75
+ const n = [];
76
+ return a.forEach((i) => {
77
+ if (!t) {
78
+ n.push({
79
+ userAlias: "",
80
+ isLinked: !1,
81
+ method: i
82
+ });
83
+ return;
84
+ }
85
+ const h = E(t, i);
86
+ n.push({
87
+ userAlias: h?.userAlias ?? "",
88
+ isLinked: h?.isLinked ?? !1,
89
+ method: i
90
+ });
91
+ }), n;
92
+ }, [t, a]), [u, o] = A(g, {
93
+ ...T,
94
+ authMethods: s
95
+ }), l = r(() => ({ state: u, dispatch: o }), [u, o]);
96
+ return f(() => {
97
+ o({ type: "SET_AUTH_METHODS", payload: { methods: s } });
98
+ }, [o, s]), /* @__PURE__ */ m(d.Provider, { value: l, children: e });
99
+ }, C = () => {
100
+ const e = M(d);
101
+ if (!e)
102
+ throw new Error("useLinkAuthContext must be used within a LinkAuthProvider");
103
+ return e;
104
+ };
105
+ export {
106
+ y as LinkAuthProvider,
107
+ C as useLinkAuthContext
108
+ };
@@ -0,0 +1,6 @@
1
+ import { ElementType, HTMLAttributes, ReactNode } from 'react';
2
+ export interface LinkAuthTitleProps extends HTMLAttributes<HTMLElement> {
3
+ as?: ElementType;
4
+ children?: ReactNode;
5
+ }
6
+ export declare const LinkAuthTitle: ({ as: Component, children, className, ...props }: LinkAuthTitleProps) => import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,19 @@
1
+ import { jsx as s } from "react/jsx-runtime";
2
+ import { c as l } from "../../chunks/lite.1fxw3LjI.js";
3
+ import "react";
4
+ import { useLinkAuthContext as n } from "./LinkAuthProvider.js";
5
+ import { methodToView as m } from "./utils.js";
6
+ import '../../assets/LinkAuthTitle.css';const c = "LinkAuthTitle-module__title___HIjM6", u = {
7
+ title: c
8
+ }, _ = ({
9
+ as: t = "h2",
10
+ children: i,
11
+ className: e = "",
12
+ ...o
13
+ }) => {
14
+ const { state: r } = n();
15
+ return m(r.methodToLink) !== "list" ? null : /* @__PURE__ */ s(t, { className: l(u.title, e), ...o, children: i || "Link a profile" });
16
+ };
17
+ export {
18
+ _ as LinkAuthTitle
19
+ };
@@ -0,0 +1,17 @@
1
+ import { HTMLAttributes, ReactNode } from 'react';
2
+ import { AuthMethod } from '../CDPReactProvider';
3
+ import { LinkAuthFlow, LinkAuthFlowProps } from './LinkAuthFlow';
4
+ import { LinkAuthFlowBackButton, LinkAuthFlowBackButtonProps } from './LinkAuthFlowBackButton';
5
+ import { useLinkAuthFlow, LinkAuthFlowContextValue } from './LinkAuthFlowProvider';
6
+ import { LinkAuthItem, LinkAuthItemProps } from './LinkAuthItem';
7
+ import { LinkAuthItems, LinkAuthItemsProps } from './LinkAuthItems';
8
+ import { useLinkAuthContext, LinkAuthContextValue } from './LinkAuthProvider';
9
+ import { LinkAuthTitle, LinkAuthTitleProps } from './LinkAuthTitle';
10
+ import { LinkAuthState, LinkAuthMethod, LinkAuthAction } from './types';
11
+ interface LinkAuthProps extends Omit<HTMLAttributes<HTMLDivElement>, "children"> {
12
+ children?: ReactNode | ((state: LinkAuthState) => ReactNode);
13
+ onLinkSuccess?: (method: AuthMethod | null) => void;
14
+ }
15
+ declare const LinkAuthError: ({ role, ...props }: HTMLAttributes<HTMLDivElement>) => import("react/jsx-runtime").JSX.Element | null;
16
+ declare const LinkAuth: (props: LinkAuthProps) => import("react/jsx-runtime").JSX.Element;
17
+ export { LinkAuthError, LinkAuthFlow, LinkAuthFlowBackButton, LinkAuthItem, LinkAuthItems, LinkAuthTitle, LinkAuth, useLinkAuthContext, useLinkAuthFlow, type LinkAuthAction, type LinkAuthContextValue, type LinkAuthFlowBackButtonProps, type LinkAuthFlowContextValue, type LinkAuthFlowProps, type LinkAuthItemProps, type LinkAuthItemsProps, type LinkAuthMethod, type LinkAuthProps, type LinkAuthState, type LinkAuthTitleProps, };