@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.
- package/dist/assets/Banner.css +1 -0
- package/dist/assets/CopyAddress.css +1 -0
- package/dist/assets/ExportWallet.css +1 -0
- package/dist/assets/ExportWalletModal.css +1 -0
- package/dist/assets/IframeButton.css +1 -0
- package/dist/assets/Input.css +1 -1
- package/dist/assets/LinkAuth.css +1 -0
- package/dist/assets/LinkAuthFlow.css +1 -0
- package/dist/assets/LinkAuthFlowBackButton.css +1 -0
- package/dist/assets/LinkAuthItem.css +1 -0
- package/dist/assets/LinkAuthItems.css +1 -0
- package/dist/assets/LinkAuthModal.css +1 -0
- package/dist/assets/LinkAuthTitle.css +1 -0
- package/dist/assets/SwitchSlideTransition.css +1 -1
- package/dist/chunks/LinkAuthFlow.BZtyaLN-.js +111 -0
- package/dist/components/CDPReactProvider/index.js +68 -55
- package/dist/components/CopyAddress/index.d.ts +8 -0
- package/dist/components/CopyAddress/index.js +61 -0
- package/dist/components/CopyEvmKeyButton/index.d.ts +13 -0
- package/dist/components/CopyEvmKeyButton/index.js +62 -0
- package/dist/components/CopySolanaKeyButton/index.d.ts +13 -0
- package/dist/components/CopySolanaKeyButton/index.js +62 -0
- package/dist/components/ExportWallet/index.d.ts +21 -0
- package/dist/components/ExportWallet/index.js +110 -0
- package/dist/components/ExportWalletModal/index.d.ts +18 -0
- package/dist/components/ExportWalletModal/index.js +96 -0
- package/dist/components/LinkAuth/LinkAuthFlow.d.ts +13 -0
- package/dist/components/LinkAuth/LinkAuthFlow.js +19 -0
- package/dist/components/LinkAuth/LinkAuthFlowBackButton.d.ts +9 -0
- package/dist/components/LinkAuth/LinkAuthFlowBackButton.js +40 -0
- package/dist/components/LinkAuth/LinkAuthFlowProvider.d.ts +33 -0
- package/dist/components/LinkAuth/LinkAuthFlowProvider.js +9 -0
- package/dist/components/LinkAuth/LinkAuthItem.d.ts +13 -0
- package/dist/components/LinkAuth/LinkAuthItem.js +48 -0
- package/dist/components/LinkAuth/LinkAuthItems.d.ts +9 -0
- package/dist/components/LinkAuth/LinkAuthItems.js +47 -0
- package/dist/components/LinkAuth/LinkAuthProvider.d.ts +12 -0
- package/dist/components/LinkAuth/LinkAuthProvider.js +108 -0
- package/dist/components/LinkAuth/LinkAuthTitle.d.ts +9 -0
- package/dist/components/LinkAuth/LinkAuthTitle.js +19 -0
- package/dist/components/LinkAuth/index.d.ts +17 -0
- package/dist/components/LinkAuth/index.js +93 -0
- package/dist/components/LinkAuth/types.d.ts +32 -0
- package/dist/components/LinkAuth/types.js +5 -0
- package/dist/components/LinkAuth/utils.d.ts +4 -0
- package/dist/components/LinkAuth/utils.js +7 -0
- package/dist/components/LinkAuthModal/index.d.ts +21 -0
- package/dist/components/LinkAuthModal/index.js +69 -0
- package/dist/components/OAuthStatusModal/index.d.ts +7 -1
- package/dist/components/OAuthStatusModal/index.js +115 -93
- package/dist/components/SignIn/SignInAuthMethodButtons.js +36 -34
- package/dist/components/SignIn/SignInForm.d.ts +2 -1
- package/dist/components/SignIn/SignInForm.js +19 -18
- package/dist/components/SignIn/SignInProvider.d.ts +2 -1
- package/dist/components/SignIn/SignInProvider.js +22 -17
- package/dist/components/SignIn/flows/SignInWithEmail.d.ts +1 -1
- package/dist/components/SignIn/flows/SignInWithEmail.js +66 -61
- package/dist/components/SignIn/flows/SignInWithSms.d.ts +1 -1
- package/dist/components/SignIn/flows/SignInWithSms.js +90 -2987
- package/dist/components/SignIn/hooks/useSignInWithOAuth.d.ts +0 -1
- package/dist/components/SignIn/hooks/useSignInWithOAuth.js +19 -20
- package/dist/components/SignIn/index.d.ts +3 -1
- package/dist/components/SignIn/index.js +16 -11
- package/dist/components/SignIn/types.d.ts +2 -0
- package/dist/components/SignIn/useSignInReducer.js +1 -0
- package/dist/components/SignInModal/index.d.ts +3 -1
- package/dist/components/SignInModal/index.js +72 -65
- package/dist/components/forms/Label/index.d.ts +2 -2
- package/dist/components/forms/PhoneNumberInput/index.js +24 -22
- package/dist/components/ui/Banner/index.d.ts +7 -0
- package/dist/components/ui/Banner/index.js +27 -0
- package/dist/components/ui/IframeButton/index.d.ts +11 -0
- package/dist/components/ui/IframeButton/index.js +50 -0
- package/dist/components/ui/Modal/index.js +22 -22
- package/dist/components/ui/SwitchTransition/index.d.ts +3 -1
- package/dist/components/ui/SwitchTransition/index.js +1 -1
- package/dist/hooks/useKeyExportPostMessage.d.ts +37 -0
- package/dist/hooks/useKeyExportPostMessage.js +86 -0
- package/dist/hooks/useTransitionMap.d.ts +50 -0
- package/dist/hooks/useTransitionMap.js +92 -0
- package/dist/icons/IconCopy.d.ts +2 -0
- package/dist/icons/IconCopy.js +10 -0
- package/dist/icons/index.d.ts +1 -0
- package/dist/icons/index.js +20 -18
- package/dist/index.d.ts +2 -2
- package/dist/index.js +122 -107
- package/dist/theme/theme.d.ts +33 -4
- package/dist/theme/tokens.d.ts +99 -12
- package/dist/theme/tokens.js +29 -12
- package/dist/types/secureIframe.d.ts +30 -0
- package/dist/types/secureIframe.js +13 -0
- package/dist/utils/childrenHasComponent.d.ts +1 -1
- package/dist/utils/formatPhoneNumber.d.ts +1 -0
- package/dist/utils/formatPhoneNumber.js +2910 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +8 -6
- package/dist/utils/sendIframeMessage.d.ts +1 -0
- package/dist/utils/sendIframeMessage.js +13 -0
- package/dist/utils/transition.d.ts +30 -0
- package/dist/utils/transition.js +43 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +8 -9
- package/dist/assets/ManageAuth.css +0 -1
- package/dist/assets/ManageAuthItem.css +0 -1
- package/dist/assets/ManageAuthModal.css +0 -1
- package/dist/components/ManageAuth/ManageAuthItem.d.ts +0 -9
- package/dist/components/ManageAuth/ManageAuthItem.js +0 -77
- package/dist/components/ManageAuth/ManageAuthProvider.d.ts +0 -8
- package/dist/components/ManageAuth/ManageAuthProvider.js +0 -64
- package/dist/components/ManageAuth/index.d.ts +0 -9
- package/dist/components/ManageAuth/index.js +0 -51
- package/dist/components/ManageAuth/types.d.ts +0 -13
- package/dist/components/ManageAuth/types.js +0 -1
- package/dist/components/ManageAuthModal/index.d.ts +0 -20
- 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,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
|
|
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
|
|
4
|
-
import { u as
|
|
5
|
-
import {
|
|
6
|
-
import { useProviderName as
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import
|
|
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:
|
|
24
|
-
graphic:
|
|
25
|
-
pad:
|
|
26
|
-
spinner:
|
|
27
|
-
icon:
|
|
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:
|
|
31
|
-
description:
|
|
32
|
-
ring:
|
|
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:
|
|
36
|
-
},
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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(
|
|
54
|
+
sessionStorage.removeItem(p), o(!0);
|
|
55
|
+
const m = sessionStorage.getItem(g) === "true";
|
|
56
|
+
sessionStorage.removeItem(g), a(m);
|
|
45
57
|
}
|
|
46
|
-
}, [
|
|
47
|
-
/* @__PURE__ */ s(
|
|
48
|
-
/* @__PURE__ */ s(
|
|
49
|
-
|
|
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
|
-
|
|
63
|
+
e?.status ? `${e?.status === "success" ? "successful" : e?.status === "error" ? "failed" : "pending"}` : ""
|
|
53
64
|
] }) }),
|
|
54
|
-
/* @__PURE__ */ s(
|
|
65
|
+
/* @__PURE__ */ s(Z, { isAccountLink: d, handleClose: () => o(!1) })
|
|
55
66
|
] }) });
|
|
56
|
-
},
|
|
57
|
-
|
|
58
|
-
|
|
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
|
|
61
|
-
|
|
62
|
-
}, [
|
|
63
|
-
a !== null && a <= 0 && (
|
|
64
|
-
}, [a,
|
|
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
|
-
|
|
80
|
+
P,
|
|
67
81
|
{
|
|
68
82
|
animateHeight: !1,
|
|
69
|
-
timeout:
|
|
70
|
-
items:
|
|
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, ...
|
|
75
|
-
const
|
|
76
|
-
return /* @__PURE__ */ s("div", { ...
|
|
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(
|
|
101
|
+
/* @__PURE__ */ s(k, {})
|
|
81
102
|
] });
|
|
82
|
-
},
|
|
83
|
-
const
|
|
84
|
-
return /* @__PURE__ */
|
|
85
|
-
/* @__PURE__ */
|
|
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
|
-
|
|
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
|
-
},
|
|
104
|
-
|
|
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(
|
|
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__ */
|
|
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
|
-
|
|
133
|
+
o ?? "soon"
|
|
115
134
|
] })
|
|
116
|
-
] }),
|
|
117
|
-
/* @__PURE__ */
|
|
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(
|
|
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
|
-
] }),
|
|
124
|
-
pending:
|
|
125
|
-
success:
|
|
126
|
-
error:
|
|
127
|
-
},
|
|
128
|
-
google:
|
|
129
|
-
apple:
|
|
130
|
-
x:
|
|
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
|
-
|
|
134
|
-
|
|
135
|
-
|
|
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
|
|
3
|
-
import
|
|
4
|
-
import { useSignInWithOAuth as
|
|
5
|
-
import { useSignInContext as
|
|
6
|
-
import { Button as
|
|
7
|
-
import { ServerError as
|
|
8
|
-
import { IconAppleLogo as
|
|
9
|
-
import { IconEnvelope as
|
|
10
|
-
import { IconGoogleLogo as
|
|
11
|
-
import { IconPhone as
|
|
12
|
-
import { IconXLogo as
|
|
13
|
-
import { toOAuthProviderType as
|
|
14
|
-
import '../../assets/SignInAuthMethodButtons.css';const
|
|
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:
|
|
20
|
-
},
|
|
19
|
+
divider: w
|
|
20
|
+
}, g = {
|
|
21
21
|
email: {
|
|
22
22
|
label: "Continue with email",
|
|
23
|
-
icon: /* @__PURE__ */ n(
|
|
23
|
+
icon: /* @__PURE__ */ n(B, {})
|
|
24
24
|
},
|
|
25
25
|
sms: {
|
|
26
26
|
label: "Continue with phone",
|
|
27
|
-
icon: /* @__PURE__ */ n(
|
|
27
|
+
icon: /* @__PURE__ */ n(P, {})
|
|
28
28
|
},
|
|
29
29
|
"oauth:google": {
|
|
30
30
|
label: "Continue with Google",
|
|
31
|
-
icon: /* @__PURE__ */ n(
|
|
31
|
+
icon: /* @__PURE__ */ n(E, {})
|
|
32
32
|
},
|
|
33
33
|
"oauth:apple": {
|
|
34
34
|
label: "Continue with Apple",
|
|
35
|
-
icon: /* @__PURE__ */ n(
|
|
35
|
+
icon: /* @__PURE__ */ n(k, {})
|
|
36
36
|
},
|
|
37
37
|
"oauth:x": {
|
|
38
38
|
label: "Continue with X",
|
|
39
|
-
icon: /* @__PURE__ */ n(
|
|
39
|
+
icon: /* @__PURE__ */ n(O, {})
|
|
40
40
|
}
|
|
41
|
-
},
|
|
42
|
-
const {
|
|
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
|
-
} =
|
|
49
|
+
} = S(), m = v(
|
|
48
50
|
async (t) => {
|
|
49
|
-
const e =
|
|
51
|
+
const e = b(t);
|
|
50
52
|
e && l(e);
|
|
51
53
|
},
|
|
52
54
|
[l]
|
|
53
|
-
), { dispatch:
|
|
54
|
-
if (!
|
|
55
|
+
), { dispatch: d } = _(), i = y(() => (a || ["email"]).map((t) => {
|
|
56
|
+
if (!g[t])
|
|
55
57
|
return null;
|
|
56
|
-
const { label: e, icon:
|
|
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:
|
|
61
|
-
onClick:
|
|
62
|
-
isPending:
|
|
62
|
+
icon: f,
|
|
63
|
+
onClick: A,
|
|
64
|
+
isPending: I
|
|
63
65
|
};
|
|
64
|
-
}).filter((t) => t !== null), [a,
|
|
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
|
-
|
|
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(
|
|
88
|
+
h && /* @__PURE__ */ n(M, { error: h })
|
|
87
89
|
] });
|
|
88
90
|
};
|
|
89
91
|
export {
|
|
90
|
-
|
|
92
|
+
U as SignInAuthMethodButtons
|
|
91
93
|
};
|