@coinbase/cdp-react 0.0.17 → 0.0.19
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/Button.css +1 -1
- package/dist/assets/EmailForm.css +1 -0
- package/dist/assets/Error.css +1 -1
- package/dist/assets/Field.css +1 -1
- package/dist/assets/FlowEmailOTP.css +1 -0
- package/dist/assets/FlowPhoneNumberOTP.css +1 -0
- package/dist/assets/Input.css +1 -1
- package/dist/assets/Label.css +1 -0
- package/dist/assets/OTP.css +1 -1
- package/dist/assets/OTPForm.css +1 -0
- package/dist/assets/PhoneNumberForm.css +1 -0
- package/dist/assets/PhoneNumberInput.css +1 -0
- package/dist/assets/SignIn.css +1 -1
- package/dist/assets/SignInAuthMethodButtons.css +1 -0
- package/dist/assets/SignInBackButton.css +1 -0
- package/dist/assets/SignInCredentials.css +1 -0
- package/dist/assets/SignInDescription.css +1 -1
- package/dist/assets/SignInFooter.css +1 -0
- package/dist/assets/SignInForm.css +1 -1
- package/dist/assets/SignInImage.css +1 -1
- package/dist/assets/SignInModal.css +1 -1
- package/dist/assets/SignInTitle.css +1 -1
- package/dist/assets/SuccessMessage.css +1 -0
- package/dist/assets/SwitchFadeTransition.css +1 -0
- package/dist/assets/SwitchSlideTransition.css +1 -0
- package/dist/assets/SwitchTransition.css +1 -0
- package/dist/assets/ThemeProvider.css +1 -1
- package/dist/chunks/index.BzllgVaP.js +12 -0
- package/dist/components/AuthButton/index.js +2 -2
- package/dist/components/Button/index.d.ts +2 -1
- package/dist/components/Button/index.js +47 -22
- package/dist/components/CDPReactProvider/index.d.ts +3 -0
- package/dist/components/CDPReactProvider/index.js +20 -13
- package/dist/components/EmailForm/index.d.ts +11 -0
- package/dist/components/EmailForm/index.js +56 -0
- package/dist/components/Error/index.d.ts +2 -2
- package/dist/components/Error/index.js +11 -11
- package/dist/components/Field/index.d.ts +2 -1
- package/dist/components/Field/index.js +20 -18
- package/dist/components/FlowEmailOTP/index.d.ts +18 -0
- package/dist/components/FlowEmailOTP/index.js +70 -0
- package/dist/components/FlowPhoneNumberOTP/index.d.ts +18 -0
- package/dist/components/FlowPhoneNumberOTP/index.js +75 -0
- package/dist/components/Label/index.d.ts +7 -0
- package/dist/components/Label/index.js +13 -0
- package/dist/components/OTP/index.d.ts +3 -0
- package/dist/components/OTP/index.js +48 -33
- package/dist/components/OTPForm/index.d.ts +16 -0
- package/dist/components/OTPForm/index.js +76 -0
- package/dist/components/PhoneNumberForm/index.d.ts +14 -0
- package/dist/components/PhoneNumberForm/index.js +68 -0
- package/dist/components/PhoneNumberInput/PhoneNumberMetadata.d.ts +2 -0
- package/dist/components/PhoneNumberInput/PhoneNumberMetadata.js +5 -0
- package/dist/components/PhoneNumberInput/index.d.ts +10 -0
- package/dist/components/PhoneNumberInput/index.js +76 -0
- package/dist/components/PhoneNumberInput/maskOverride.d.ts +8 -0
- package/dist/components/PhoneNumberInput/maskOverride.js +61 -0
- package/dist/components/PhoneNumberInput/usePhoneNumberFormatter.d.ts +7 -0
- package/dist/components/PhoneNumberInput/usePhoneNumberFormatter.js +52 -0
- package/dist/components/SendTransactionButton/index.js +1 -1
- package/dist/components/ServerError/index.js +4 -4
- package/dist/components/SignIn/SignInAuthMethodButtons.d.ts +13 -0
- package/dist/components/SignIn/SignInAuthMethodButtons.js +57 -0
- package/dist/components/SignIn/SignInBackButton.d.ts +9 -0
- package/dist/components/SignIn/SignInBackButton.js +38 -0
- package/dist/components/SignIn/SignInCredentials.d.ts +2 -0
- package/dist/components/SignIn/SignInCredentials.js +8 -0
- package/dist/components/SignIn/SignInDescription.d.ts +4 -3
- package/dist/components/SignIn/SignInDescription.js +16 -23
- package/dist/components/SignIn/SignInFooter.d.ts +2 -0
- package/dist/components/SignIn/SignInFooter.js +18 -0
- package/dist/components/SignIn/SignInForm.d.ts +12 -4
- package/dist/components/SignIn/SignInForm.js +25 -196
- package/dist/components/SignIn/SignInImage.d.ts +2 -2
- package/dist/components/SignIn/SignInImage.js +11 -14
- package/dist/components/SignIn/SignInProvider.d.ts +1 -1
- package/dist/components/SignIn/SignInProvider.js +24 -16
- package/dist/components/SignIn/SignInTitle.d.ts +4 -3
- package/dist/components/SignIn/SignInTitle.js +18 -13
- package/dist/components/SignIn/flows/SignInWithEmail.d.ts +5 -0
- package/dist/components/SignIn/flows/SignInWithEmail.js +71 -0
- package/dist/components/SignIn/flows/SignInWithSms.d.ts +5 -0
- package/dist/components/SignIn/flows/SignInWithSms.js +2994 -0
- package/dist/components/SignIn/hooks/useEmailForm.d.ts +13 -0
- package/dist/components/SignIn/hooks/useEmailForm.js +42 -0
- package/dist/components/SignIn/hooks/useOTPForm.d.ts +16 -0
- package/dist/components/SignIn/hooks/useOTPForm.js +59 -0
- package/dist/components/SignIn/hooks/usePhoneNumberForm.d.ts +13 -0
- package/dist/components/SignIn/hooks/usePhoneNumberForm.js +42 -0
- package/dist/components/SignIn/index.d.ts +5 -2
- package/dist/components/SignIn/index.js +42 -24
- package/dist/components/SignIn/types.d.ts +106 -0
- package/dist/components/SignIn/types.js +3 -0
- package/dist/components/SignIn/useSignInReducer.d.ts +1 -57
- package/dist/components/SignIn/useSignInReducer.js +62 -20
- package/dist/components/SignInModal/index.d.ts +2 -2
- package/dist/components/SignInModal/index.js +62 -43
- package/dist/components/SignOutButton/index.js +1 -1
- package/dist/components/SuccessMessage/index.d.ts +7 -0
- package/dist/components/SuccessMessage/index.js +16 -0
- package/dist/components/SwitchFadeTransition/index.d.ts +5 -0
- package/dist/components/SwitchFadeTransition/index.js +24 -0
- package/dist/components/SwitchSlideTransition/index.d.ts +7 -0
- package/dist/components/SwitchSlideTransition/index.js +27 -0
- package/dist/components/SwitchTransition/index.d.ts +25 -0
- package/dist/components/SwitchTransition/index.js +155 -0
- package/dist/data/countries.d.ts +12 -0
- package/dist/data/countries.js +25 -0
- package/dist/data/countryNames.d.ts +1 -0
- package/dist/data/countryNames.js +6 -0
- package/dist/hooks/usePhoneNumberValidators.d.ts +14 -0
- package/dist/hooks/usePhoneNumberValidators.js +36 -0
- package/dist/hooks/useTimer.d.ts +5 -0
- package/dist/hooks/useTimer.js +24 -0
- package/dist/icons/IconArrowLeft.d.ts +2 -0
- package/dist/icons/IconArrowLeft.js +14 -0
- package/dist/icons/IconCheckCircle.js +2 -3
- package/dist/icons/IconCoinbaseWordmark.js +5 -5
- package/dist/icons/IconEnvelope.d.ts +2 -0
- package/dist/icons/IconEnvelope.js +7 -0
- package/dist/icons/IconExclamationCircle.js +3 -4
- package/dist/icons/IconPhone.d.ts +2 -0
- package/dist/icons/IconPhone.js +7 -0
- package/dist/icons/IconXMark.js +6 -5
- package/dist/icons/index.d.ts +3 -0
- package/dist/icons/index.js +14 -8
- package/dist/index.js +66 -53
- package/dist/theme/theme.d.ts +11 -2
- package/dist/theme/tokens.d.ts +30 -6
- package/dist/theme/tokens.js +7 -3
- package/dist/utils/parseValuesFromPhoneNumber.d.ts +6 -0
- package/dist/utils/parseValuesFromPhoneNumber.js +16 -0
- package/dist/utils/validatePhoneNumber.d.ts +1 -0
- package/dist/utils/validatePhoneNumber.js +1 -0
- package/package.json +11 -7
|
@@ -19,7 +19,7 @@ import '../../assets/SendTransactionButton.css';const P = {
|
|
|
19
19
|
variant: p = "primary",
|
|
20
20
|
...g
|
|
21
21
|
}) => {
|
|
22
|
-
const [h, c] = _(!1), m = y(), E = v(
|
|
22
|
+
const [h, c] = _(!1), { sendEvmTransaction: m } = y(), E = v(
|
|
23
23
|
async (d) => {
|
|
24
24
|
d.preventDefault(), o?.(d);
|
|
25
25
|
try {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { jsx as s } from "react/jsx-runtime";
|
|
2
2
|
import "@coinbase/cdp-hooks";
|
|
3
3
|
import { forwardRef as t } from "react";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { Error as p } from "../Error/index.js";
|
|
5
|
+
import { isApiError as f } from "../../utils/isApiError.js";
|
|
6
6
|
const a = t(
|
|
7
7
|
({ error: r, id: o, className: e = "" }, m) => {
|
|
8
|
-
const i =
|
|
9
|
-
return /* @__PURE__ */ s(
|
|
8
|
+
const i = f(r) ? r.errorMessage : r;
|
|
9
|
+
return /* @__PURE__ */ s(p, { ref: m, id: o, className: e, children: i });
|
|
10
10
|
}
|
|
11
11
|
);
|
|
12
12
|
a.displayName = "ServerError";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { AuthMethod } from '../CDPReactProvider/CDPReactProvider';
|
|
3
|
+
export interface SignInAuthMethodButtonProps {
|
|
4
|
+
key: AuthMethod;
|
|
5
|
+
label: string;
|
|
6
|
+
ariaLabel?: string;
|
|
7
|
+
icon: ReactNode;
|
|
8
|
+
onClick: () => void;
|
|
9
|
+
}
|
|
10
|
+
export interface SignInAuthMethodButtonsProps {
|
|
11
|
+
activeMethod?: AuthMethod;
|
|
12
|
+
}
|
|
13
|
+
export declare const SignInAuthMethodButtons: ({ activeMethod }: SignInAuthMethodButtonsProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { jsx as n, jsxs as i } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo as c } from "react";
|
|
3
|
+
import { Button as d } from "../Button/index.js";
|
|
4
|
+
import { useAppConfig as m } from "../CDPReactProvider/index.js";
|
|
5
|
+
import { useSignInContext as p } from "./SignInProvider.js";
|
|
6
|
+
import { IconEnvelope as _ } from "../../icons/IconEnvelope.js";
|
|
7
|
+
import { IconPhone as b } from "../../icons/IconPhone.js";
|
|
8
|
+
import '../../assets/SignInAuthMethodButtons.css';const f = "SignInAuthMethodButtons-module__divider___zphEh", e = {
|
|
9
|
+
"auth-method-buttons": "SignInAuthMethodButtons-module__auth-method-buttons___jYEH7",
|
|
10
|
+
"auth-btn-icon": "SignInAuthMethodButtons-module__auth-btn-icon___VjvFY",
|
|
11
|
+
"auth-btn-label": "SignInAuthMethodButtons-module__auth-btn-label___mEWd3",
|
|
12
|
+
divider: f
|
|
13
|
+
}, r = {
|
|
14
|
+
email: {
|
|
15
|
+
label: "Continue with email",
|
|
16
|
+
icon: /* @__PURE__ */ n(_, {})
|
|
17
|
+
},
|
|
18
|
+
sms: {
|
|
19
|
+
label: "Continue with phone",
|
|
20
|
+
icon: /* @__PURE__ */ n(b, {})
|
|
21
|
+
}
|
|
22
|
+
}, B = ({ activeMethod: l }) => {
|
|
23
|
+
const { authMethods: a } = m(), { dispatch: u } = p(), o = c(() => (a || ["email"]).map((t) => {
|
|
24
|
+
if (!r[t])
|
|
25
|
+
return null;
|
|
26
|
+
const { label: s, icon: h } = r[t];
|
|
27
|
+
return {
|
|
28
|
+
key: t,
|
|
29
|
+
label: s,
|
|
30
|
+
icon: h,
|
|
31
|
+
onClick: () => u({ type: "SET_AUTH_METHOD", payload: { authMethod: t } })
|
|
32
|
+
};
|
|
33
|
+
}).filter((t) => t !== null), [a, u]);
|
|
34
|
+
return !o.length || o.length === 1 && o[0].key === l ? null : /* @__PURE__ */ i("div", { className: e["auth-method-buttons"], children: [
|
|
35
|
+
/* @__PURE__ */ i("div", { className: e.divider, children: [
|
|
36
|
+
/* @__PURE__ */ n("hr", {}),
|
|
37
|
+
/* @__PURE__ */ n("span", { children: "or" })
|
|
38
|
+
] }),
|
|
39
|
+
o.map((t) => t.key === l ? null : /* @__PURE__ */ i(
|
|
40
|
+
d,
|
|
41
|
+
{
|
|
42
|
+
"aria-label": t.ariaLabel,
|
|
43
|
+
type: "button",
|
|
44
|
+
variant: "secondary",
|
|
45
|
+
onClick: t.onClick,
|
|
46
|
+
children: [
|
|
47
|
+
/* @__PURE__ */ n("span", { className: e["auth-btn-icon"], children: t.icon }),
|
|
48
|
+
/* @__PURE__ */ n("span", { className: e["auth-btn-label"], children: t.label })
|
|
49
|
+
]
|
|
50
|
+
},
|
|
51
|
+
t.key
|
|
52
|
+
))
|
|
53
|
+
] });
|
|
54
|
+
};
|
|
55
|
+
export {
|
|
56
|
+
B as SignInAuthMethodButtons
|
|
57
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { HTMLAttributes } from 'react';
|
|
2
|
+
import { ButtonSize, ButtonVariant } from '../../theme/theme';
|
|
3
|
+
import { SignInState } from './types';
|
|
4
|
+
export interface SignInBackButtonProps extends HTMLAttributes<HTMLButtonElement> {
|
|
5
|
+
step?: SignInState["step"];
|
|
6
|
+
size?: ButtonSize;
|
|
7
|
+
variant?: ButtonVariant;
|
|
8
|
+
}
|
|
9
|
+
export declare const SignInBackButton: ({ step: stepFromProps, children, onClick, size, variant, ["aria-label"]: ariaLabel, ...props }: SignInBackButtonProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo as f } from "react";
|
|
3
|
+
import { Button as S } from "../Button/index.js";
|
|
4
|
+
import { IconArrowLeft as d } from "../../icons/IconArrowLeft.js";
|
|
5
|
+
import "../../theme/theme.js";
|
|
6
|
+
import { useSignInContext as B } from "./SignInProvider.js";
|
|
7
|
+
import "@coinbase/cdp-hooks";
|
|
8
|
+
import "../CDPReactProvider/index.js";
|
|
9
|
+
import '../../assets/SignInBackButton.css';const _ = "SignInBackButton-module__icon___stNFS", k = {
|
|
10
|
+
icon: _
|
|
11
|
+
}, T = ({
|
|
12
|
+
step: t,
|
|
13
|
+
children: i,
|
|
14
|
+
onClick: r,
|
|
15
|
+
size: e = "md",
|
|
16
|
+
variant: c = "transparentSecondary",
|
|
17
|
+
["aria-label"]: s = "Back",
|
|
18
|
+
...a
|
|
19
|
+
}) => {
|
|
20
|
+
const { state: o, dispatch: m } = B(), p = f(() => t || o.step, [t, o.step]), l = (u) => {
|
|
21
|
+
r?.(u), m({ type: "RESET_STATE" });
|
|
22
|
+
};
|
|
23
|
+
return p !== "verification" ? null : /* @__PURE__ */ n(
|
|
24
|
+
S,
|
|
25
|
+
{
|
|
26
|
+
type: "button",
|
|
27
|
+
"aria-label": s,
|
|
28
|
+
onClick: l,
|
|
29
|
+
size: e,
|
|
30
|
+
variant: c,
|
|
31
|
+
...a,
|
|
32
|
+
children: i || /* @__PURE__ */ n(d, { className: k.icon })
|
|
33
|
+
}
|
|
34
|
+
);
|
|
35
|
+
};
|
|
36
|
+
export {
|
|
37
|
+
T as SignInBackButton
|
|
38
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as s } from "react/jsx-runtime";
|
|
2
|
+
import "react";
|
|
3
|
+
import '../../assets/SignInCredentials.css';const t = "SignInCredentials-module__credentials___LE04y", r = {
|
|
4
|
+
credentials: t
|
|
5
|
+
}, l = ({ children: e, ...n }) => /* @__PURE__ */ s("span", { className: r.credentials, ...n, children: e });
|
|
6
|
+
export {
|
|
7
|
+
l as SignInCredentials
|
|
8
|
+
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ElementType, HTMLAttributes } from 'react';
|
|
2
|
-
|
|
2
|
+
import { SignInTitleAndDescriptionProps } from './types';
|
|
3
|
+
export interface SignInDescriptionProps extends SignInTitleAndDescriptionProps, HTMLAttributes<HTMLElement> {
|
|
3
4
|
as?: ElementType;
|
|
4
|
-
}
|
|
5
|
-
export declare const SignInDescription: ({ as: Component, children, className, ...props }: SignInDescriptionProps) => import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
}
|
|
6
|
+
export declare const SignInDescription: ({ as: Component, authMethod: authMethodFromProps, children, className, step: stepFromProps, ...props }: SignInDescriptionProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,29 +1,22 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsx as i } from "react/jsx-runtime";
|
|
2
2
|
import "react";
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
"."
|
|
11
|
-
] }), D = () => /* @__PURE__ */ e(i, { children: "You’ve successfully signed in." }), v = ({
|
|
3
|
+
import { a as d } from "../../chunks/index.BzllgVaP.js";
|
|
4
|
+
import { useSignInContext as h } from "./SignInProvider.js";
|
|
5
|
+
import "@coinbase/cdp-hooks";
|
|
6
|
+
import "../CDPReactProvider/index.js";
|
|
7
|
+
import '../../assets/SignInDescription.css';const u = "SignInDescription-module__description___jZLc6", _ = {
|
|
8
|
+
description: u
|
|
9
|
+
}, M = ({
|
|
12
10
|
as: n = "p",
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
authMethod: e,
|
|
12
|
+
children: t,
|
|
13
|
+
className: p = "",
|
|
14
|
+
step: r,
|
|
15
|
+
...c
|
|
16
16
|
}) => {
|
|
17
|
-
const { state:
|
|
18
|
-
return /* @__PURE__ */
|
|
19
|
-
c,
|
|
20
|
-
!c && /* @__PURE__ */ t(i, { children: [
|
|
21
|
-
s === "otp" && /* @__PURE__ */ e(g, { email: p }),
|
|
22
|
-
s === "success" && /* @__PURE__ */ e(D, {}),
|
|
23
|
-
s === "email" && /* @__PURE__ */ e(_, {})
|
|
24
|
-
] })
|
|
25
|
-
] });
|
|
17
|
+
const { state: o } = h(), m = r || o.step, s = e || o.authMethod, a = d[s].description;
|
|
18
|
+
return /* @__PURE__ */ i(n, { className: `${_.description} ${p}`, ...c, children: t || /* @__PURE__ */ i(a, { step: m, authMethod: s }) });
|
|
26
19
|
};
|
|
27
20
|
export {
|
|
28
|
-
|
|
21
|
+
M as SignInDescription
|
|
29
22
|
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsxs as e, jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import "react";
|
|
3
|
+
import { IconCoinbaseWordmark as c } from "../../icons/IconCoinbaseWordmark.js";
|
|
4
|
+
import { IconLock as s } from "../../icons/IconLock.js";
|
|
5
|
+
import '../../assets/SignInFooter.css';const t = "SignInFooter-module__footer___DLNrl", a = "SignInFooter-module__icon___hFhfx", n = {
|
|
6
|
+
footer: t,
|
|
7
|
+
icon: a,
|
|
8
|
+
"coinbase-icon": "SignInFooter-module__coinbase-icon___NeFOp"
|
|
9
|
+
}, f = ({ className: r = "", ...i }) => /* @__PURE__ */ e("div", { className: `${n.footer} ${r}`, ...i, children: [
|
|
10
|
+
/* @__PURE__ */ o(s, { className: n.icon }),
|
|
11
|
+
/* @__PURE__ */ e("p", { children: [
|
|
12
|
+
/* @__PURE__ */ o("span", { children: "Secured by " }),
|
|
13
|
+
/* @__PURE__ */ o(c, { className: n["coinbase-icon"], "aria-label": "Coinbase" })
|
|
14
|
+
] })
|
|
15
|
+
] });
|
|
16
|
+
export {
|
|
17
|
+
f as SignInFooter
|
|
18
|
+
};
|
|
@@ -1,6 +1,14 @@
|
|
|
1
|
-
import { ElementType, HTMLAttributes } from 'react';
|
|
2
|
-
|
|
1
|
+
import { ElementType, HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
import { AuthMethod } from '../CDPReactProvider/CDPReactProvider';
|
|
3
|
+
import { SignInState } from './types';
|
|
4
|
+
export interface SignInFormProps extends Omit<HTMLAttributes<HTMLElement>, "children"> {
|
|
3
5
|
as?: ElementType;
|
|
4
6
|
onSuccess?: () => void;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
+
step?: SignInState["step"];
|
|
8
|
+
children?: (props: {
|
|
9
|
+
step: SignInState["step"];
|
|
10
|
+
authMethod: AuthMethod;
|
|
11
|
+
Form: ReactNode;
|
|
12
|
+
}) => ReactNode;
|
|
13
|
+
}
|
|
14
|
+
export declare const SignInForm: ({ onSuccess, step: stepFromProps, children }: SignInFormProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,202 +1,31 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
import { LoadingSpinner as $ } from "../LoadingSpinner/index.js";
|
|
17
|
-
import { VisuallyHidden as j } from "../VisuallyHidden/index.js";
|
|
18
|
-
import '../../assets/SignInForm.css';const J = "SignInForm-module__form___8Mc3V", G = "SignInForm-module__footer___6Lo9w", H = "SignInForm-module__hr___fOcy4", X = "SignInForm-module__icon___qkJnq", n = {
|
|
19
|
-
"form-wrapper": "SignInForm-module__form-wrapper___SlQkZ",
|
|
20
|
-
form: J,
|
|
21
|
-
"form-footer": "SignInForm-module__form-footer___PqM2J",
|
|
22
|
-
"server-state-wrapper": "SignInForm-module__server-state-wrapper___QVsXy",
|
|
23
|
-
"loading-spinner": "SignInForm-module__loading-spinner___W6gZo",
|
|
24
|
-
"server-error": "SignInForm-module__server-error___dD9VE",
|
|
25
|
-
"resend-wrapper": "SignInForm-module__resend-wrapper___ODSQA",
|
|
26
|
-
"reset-timer": "SignInForm-module__reset-timer___Ms2YZ",
|
|
27
|
-
footer: G,
|
|
28
|
-
"coinbase-icon": "SignInForm-module__coinbase-icon___vGv7u",
|
|
29
|
-
hr: H,
|
|
30
|
-
icon: X
|
|
31
|
-
}, Y = ({ submit: _ }) => {
|
|
32
|
-
const { state: i, dispatch: d } = E(), e = () => d({ type: "CLEAR_ERROR" }), u = (p) => (p.preventDefault(), _(i.email));
|
|
33
|
-
return /* @__PURE__ */ s(
|
|
34
|
-
P,
|
|
1
|
+
import { jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as s, useLayoutEffect as l } from "react";
|
|
3
|
+
import { useAppConfig as g } from "../CDPReactProvider/index.js";
|
|
4
|
+
import { SwitchFadeTransition as M } from "../SwitchFadeTransition/index.js";
|
|
5
|
+
import { a as w } from "../../chunks/index.BzllgVaP.js";
|
|
6
|
+
import { useSignInContext as _ } from "./SignInProvider.js";
|
|
7
|
+
import "@coinbase/cdp-hooks";
|
|
8
|
+
import '../../assets/SignInForm.css';const F = {
|
|
9
|
+
"auth-method-wrapper": "SignInForm-module__auth-method-wrapper___uIOAB"
|
|
10
|
+
}, E = ({ onSuccess: a, step: u, children: h }) => {
|
|
11
|
+
const { state: t } = _(), { authMethods: m } = g(), p = u || t.step, o = s(t.authMethod), r = s(null);
|
|
12
|
+
return l(() => {
|
|
13
|
+
o.current !== t.authMethod && (r.current?.transition.toggle(t.authMethod), o.current = t.authMethod);
|
|
14
|
+
}, [t.authMethod]), /* @__PURE__ */ e(
|
|
15
|
+
M,
|
|
35
16
|
{
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
name: "email",
|
|
45
|
-
validators: [
|
|
46
|
-
["valueMissing", "Email is required"],
|
|
47
|
-
["typeMismatch", "Use a valid email address"],
|
|
48
|
-
[Q, "Use a valid email address"]
|
|
49
|
-
],
|
|
50
|
-
children: Z({
|
|
51
|
-
autoComplete: "email",
|
|
52
|
-
type: "email",
|
|
53
|
-
placeholder: "name@example.com",
|
|
54
|
-
required: !0,
|
|
55
|
-
value: i.email,
|
|
56
|
-
onChange: (p) => {
|
|
57
|
-
d({ type: "SET_EMAIL", payload: { email: p.target.value } });
|
|
58
|
-
}
|
|
59
|
-
})
|
|
60
|
-
}
|
|
61
|
-
),
|
|
62
|
-
i.error && /* @__PURE__ */ o(O, { error: i.error, className: n["server-error"] }),
|
|
63
|
-
/* @__PURE__ */ o(R, { asChild: !0, children: /* @__PURE__ */ o(C, { type: "submit", isPending: i.isPending, children: "Continue with email" }) })
|
|
64
|
-
]
|
|
65
|
-
}
|
|
66
|
-
);
|
|
67
|
-
}, z = ({
|
|
68
|
-
reset: _,
|
|
69
|
-
resetCountdown: i,
|
|
70
|
-
submit: d
|
|
71
|
-
}) => {
|
|
72
|
-
const { state: e, dispatch: u } = E(), p = () => u({ type: "CLEAR_ERROR" }), l = B([]), f = (c) => (c.preventDefault(), d(e.otp)), S = () => {
|
|
73
|
-
_(), l.current[0]?.focus();
|
|
74
|
-
};
|
|
75
|
-
return y(() => {
|
|
76
|
-
e.step === "otp" && l.current[0]?.focus();
|
|
77
|
-
}, [e.step]), /* @__PURE__ */ s(
|
|
78
|
-
P,
|
|
79
|
-
{
|
|
80
|
-
className: `${n.form}`,
|
|
81
|
-
onClearServerErrors: p,
|
|
82
|
-
onSubmit: f,
|
|
83
|
-
children: [
|
|
84
|
-
/* @__PURE__ */ o(
|
|
85
|
-
q,
|
|
86
|
-
{
|
|
87
|
-
ref: l,
|
|
88
|
-
name: "otp",
|
|
89
|
-
"aria-label": "Six-digit Verification Code",
|
|
90
|
-
passwordLength: 6,
|
|
91
|
-
value: e.otp,
|
|
92
|
-
onChange: (c) => c.preventDefault(),
|
|
93
|
-
onValueChange: (c) => {
|
|
94
|
-
u({ type: "SET_OTP", payload: { otp: c } });
|
|
95
|
-
},
|
|
96
|
-
autoSubmit: !0
|
|
97
|
-
}
|
|
98
|
-
),
|
|
99
|
-
/* @__PURE__ */ s("div", { className: n["form-footer"], children: [
|
|
100
|
-
(e.isPending && !e.canResetOTP || e.error) && /* @__PURE__ */ s("div", { className: n["server-state-wrapper"], children: [
|
|
101
|
-
e.isPending && !e.canResetOTP && /* @__PURE__ */ o($, { className: n["loading-spinner"] }),
|
|
102
|
-
e.error && /* @__PURE__ */ o(O, { error: e.error, className: n["server-error"] })
|
|
103
|
-
] }),
|
|
104
|
-
/* @__PURE__ */ s("div", { className: n["resend-wrapper"], children: [
|
|
105
|
-
e.canResetOTP && /* @__PURE__ */ o(R, { asChild: !0, children: /* @__PURE__ */ o(
|
|
106
|
-
C,
|
|
107
|
-
{
|
|
108
|
-
type: "button",
|
|
109
|
-
onClick: S,
|
|
110
|
-
isPending: e.isPending,
|
|
111
|
-
variant: "linkPrimary",
|
|
112
|
-
children: "Resend code"
|
|
113
|
-
}
|
|
114
|
-
) }),
|
|
115
|
-
!e.canResetOTP && /* @__PURE__ */ o("div", { className: n["reset-timer"], children: /* @__PURE__ */ s("p", { children: [
|
|
116
|
-
"Resend code in ",
|
|
117
|
-
/* @__PURE__ */ s("span", { "aria-hidden": "true", children: [
|
|
118
|
-
i,
|
|
119
|
-
"s"
|
|
120
|
-
] }),
|
|
121
|
-
/* @__PURE__ */ s(j, { children: [
|
|
122
|
-
i,
|
|
123
|
-
" ",
|
|
124
|
-
i === 1 ? "second" : "seconds"
|
|
125
|
-
] })
|
|
126
|
-
] }) })
|
|
127
|
-
] })
|
|
128
|
-
] })
|
|
129
|
-
]
|
|
130
|
-
}
|
|
131
|
-
);
|
|
132
|
-
}, Se = ({
|
|
133
|
-
as: _ = "div",
|
|
134
|
-
className: i = "",
|
|
135
|
-
onSuccess: d,
|
|
136
|
-
...e
|
|
137
|
-
}) => {
|
|
138
|
-
const l = "An error occurred while signing in. Please try again.", [f, S] = v(0), [c, h] = v(!1), w = U(), b = V(), { state: a, dispatch: m } = E(), { showCoinbaseFooter: F } = k(), L = (t) => {
|
|
139
|
-
S(t), h(!0);
|
|
140
|
-
};
|
|
141
|
-
y(() => {
|
|
142
|
-
if (!c)
|
|
143
|
-
return;
|
|
144
|
-
const t = setInterval(() => {
|
|
145
|
-
S((r) => r > 1 ? r - 1 : (h(!1), 0));
|
|
146
|
-
}, 1e3);
|
|
147
|
-
return () => clearInterval(t);
|
|
148
|
-
}, [c]), y(() => {
|
|
149
|
-
f === 0 && a.step === "otp" && !a.canResetOTP && m({ type: "ALLOW_RESET_OTP" });
|
|
150
|
-
}, [f, a.step, a.canResetOTP, m]);
|
|
151
|
-
const I = async (t) => {
|
|
152
|
-
if (!a.isPending) {
|
|
153
|
-
m({ type: "SUBMIT_EMAIL", payload: { email: t } });
|
|
154
|
-
try {
|
|
155
|
-
const { flowId: r } = await w({
|
|
156
|
-
email: t
|
|
157
|
-
});
|
|
158
|
-
m({ type: "SUBMIT_EMAIL_SUCCESS", payload: { flowId: r } }), L(60);
|
|
159
|
-
} catch (r) {
|
|
160
|
-
const g = T(r) ? r : r instanceof Error && r.message || l;
|
|
161
|
-
m({ type: "SUBMIT_EMAIL_FAILURE", payload: { error: g } }), console.error(r);
|
|
17
|
+
animateHeight: !0,
|
|
18
|
+
timeout: 250,
|
|
19
|
+
items: m || ["email"],
|
|
20
|
+
initialEntered: !0,
|
|
21
|
+
transitionRef: r,
|
|
22
|
+
children: ({ itemKey: n, ...c }) => {
|
|
23
|
+
const d = w[n].forms;
|
|
24
|
+
return /* @__PURE__ */ e("div", { ...c, className: F["auth-method-wrapper"], children: /* @__PURE__ */ e(d, { step: p, onSuccess: a, children: ({ step: f, Form: i }) => h?.({ step: f, authMethod: n, Form: i }) || i }) });
|
|
162
25
|
}
|
|
163
26
|
}
|
|
164
|
-
|
|
165
|
-
if (!a.isPending) {
|
|
166
|
-
if (t.length !== 6) {
|
|
167
|
-
m({ type: "SET_OTP", payload: { otp: t } });
|
|
168
|
-
return;
|
|
169
|
-
}
|
|
170
|
-
m({ type: "SUBMIT_OTP", payload: { otp: t } });
|
|
171
|
-
try {
|
|
172
|
-
await b({
|
|
173
|
-
flowId: a.flowId,
|
|
174
|
-
otp: t
|
|
175
|
-
}), m({ type: "SUBMIT_OTP_SUCCESS", payload: { otp: t } }), d?.();
|
|
176
|
-
} catch (r) {
|
|
177
|
-
const g = T(r) ? r : r instanceof Error && r.message || l;
|
|
178
|
-
m({ type: "SUBMIT_OTP_FAILURE", payload: { error: g } }), console.error(r);
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
}, N = () => {
|
|
182
|
-
m({ type: "RESET_OTP" }), h(!1), I(a.email);
|
|
183
|
-
};
|
|
184
|
-
return /* @__PURE__ */ s(_, { className: `${n["form-wrapper"]} ${i}`, ...e, children: [
|
|
185
|
-
a.step === "email" && /* @__PURE__ */ o(Y, { submit: I }),
|
|
186
|
-
a.step === "otp" && /* @__PURE__ */ o(z, { submit: M, reset: N, resetCountdown: f }),
|
|
187
|
-
F && /* @__PURE__ */ s(A, { children: [
|
|
188
|
-
/* @__PURE__ */ o("hr", { className: n.hr }),
|
|
189
|
-
/* @__PURE__ */ s("div", { className: n.footer, children: [
|
|
190
|
-
/* @__PURE__ */ o(W, { className: n.icon }),
|
|
191
|
-
/* @__PURE__ */ s("p", { children: [
|
|
192
|
-
"Secured by",
|
|
193
|
-
" ",
|
|
194
|
-
/* @__PURE__ */ o(D, { className: n["coinbase-icon"], "aria-label": "Coinbase" })
|
|
195
|
-
] })
|
|
196
|
-
] })
|
|
197
|
-
] })
|
|
198
|
-
] });
|
|
27
|
+
);
|
|
199
28
|
};
|
|
200
29
|
export {
|
|
201
|
-
|
|
30
|
+
E as SignInForm
|
|
202
31
|
};
|
|
@@ -1,23 +1,20 @@
|
|
|
1
1
|
import { jsx as e } from "react/jsx-runtime";
|
|
2
|
-
import { useAppConfig as
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}, l = (o) => /^https?:\/\//.test(o), S = ({ className: o = "", alt: r, src: t }) => {
|
|
9
|
-
const { state: g } = _(), { step: n } = g, s = p(), m = s.logoUrl && l(s.logoUrl) ? s.logoUrl : void 0, c = t && l(t) ? t : m, u = r || s.name;
|
|
10
|
-
return n !== "success" && c ? /* @__PURE__ */ e(
|
|
2
|
+
import { useAppConfig as m } from "../CDPReactProvider/index.js";
|
|
3
|
+
import '../../assets/SignInImage.css';const p = "SignInImage-module__logo___rlzt-", c = {
|
|
4
|
+
logo: p
|
|
5
|
+
}, n = (t) => /^https?:\/\//.test(t), f = ({ className: t = "", alt: s, src: l }) => {
|
|
6
|
+
const o = m(), r = o.logoUrl && n(o.logoUrl) ? o.logoUrl : void 0, g = l && n(l) ? l : r, i = s || o.name;
|
|
7
|
+
return g ? /* @__PURE__ */ e(
|
|
11
8
|
"img",
|
|
12
9
|
{
|
|
13
|
-
src:
|
|
14
|
-
alt:
|
|
15
|
-
className: `${
|
|
10
|
+
src: g,
|
|
11
|
+
alt: i || "",
|
|
12
|
+
className: `${c.logo} ${t}`,
|
|
16
13
|
width: 64,
|
|
17
14
|
height: 64
|
|
18
15
|
}
|
|
19
|
-
) :
|
|
16
|
+
) : null;
|
|
20
17
|
};
|
|
21
18
|
export {
|
|
22
|
-
|
|
19
|
+
f as SignInImage
|
|
23
20
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Dispatch, ReactNode } from 'react';
|
|
2
|
-
import { SignInAction, SignInState } from './
|
|
2
|
+
import { SignInAction, SignInState } from './types';
|
|
3
3
|
export declare const SignInContext: import('react').Context<{
|
|
4
4
|
state: SignInState;
|
|
5
5
|
dispatch: Dispatch<SignInAction>;
|
|
@@ -1,29 +1,37 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { createContext as
|
|
3
|
-
import {
|
|
4
|
-
|
|
1
|
+
import { jsx as a } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as u, useContext as c, useMemo as m } from "react";
|
|
3
|
+
import { useAppConfig as d } from "../CDPReactProvider/index.js";
|
|
4
|
+
import "@coinbase/cdp-hooks";
|
|
5
|
+
import { useSignInReducer as p } from "./useSignInReducer.js";
|
|
6
|
+
const n = {
|
|
7
|
+
authMethod: "email",
|
|
8
|
+
canResetOTP: !1,
|
|
5
9
|
email: "",
|
|
6
10
|
error: null,
|
|
7
11
|
flowId: "",
|
|
8
|
-
canResetOTP: !1,
|
|
9
12
|
isPending: !1,
|
|
13
|
+
isSuccess: !1,
|
|
10
14
|
otp: "",
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
15
|
+
phoneNumber: "",
|
|
16
|
+
step: "credentials"
|
|
17
|
+
}, s = u({
|
|
18
|
+
state: n,
|
|
14
19
|
dispatch: () => {
|
|
15
20
|
}
|
|
16
|
-
}),
|
|
17
|
-
const t = c(
|
|
21
|
+
}), S = () => {
|
|
22
|
+
const t = c(s);
|
|
18
23
|
if (!t)
|
|
19
24
|
throw new Error("useSignInContext must be used within a SignInProvider");
|
|
20
25
|
return t;
|
|
21
|
-
},
|
|
22
|
-
const
|
|
23
|
-
|
|
26
|
+
}, I = ({ children: t }) => {
|
|
27
|
+
const { authMethods: r } = d(), [e, o] = p({
|
|
28
|
+
...n,
|
|
29
|
+
authMethod: r?.[0] || "email"
|
|
30
|
+
}), i = m(() => ({ state: e, dispatch: o }), [e, o]);
|
|
31
|
+
return /* @__PURE__ */ a(s.Provider, { value: i, children: t });
|
|
24
32
|
};
|
|
25
33
|
export {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
34
|
+
s as SignInContext,
|
|
35
|
+
I as SignInProvider,
|
|
36
|
+
S as useSignInContext
|
|
29
37
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ElementType, HTMLAttributes } from 'react';
|
|
2
|
-
|
|
2
|
+
import { SignInTitleAndDescriptionProps } from './types';
|
|
3
|
+
export interface SignInTitleProps extends SignInTitleAndDescriptionProps, HTMLAttributes<HTMLElement> {
|
|
3
4
|
as?: ElementType;
|
|
4
|
-
}
|
|
5
|
-
export declare const SignInTitle: ({ as: Component, children, className, ...props }: SignInTitleProps) => import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
}
|
|
6
|
+
export declare const SignInTitle: ({ as: Component, children, className, authMethod: authMethodFromProps, step: stepFromProps, ...props }: SignInTitleProps) => import("react/jsx-runtime").JSX.Element;
|