@coinbase/cdp-react 0.0.18 → 0.0.20
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/Input.css +1 -1
- package/dist/assets/Label.css +1 -0
- package/dist/assets/LoadingSkeleton.css +1 -1
- package/dist/assets/LoadingSpinner.css +1 -1
- package/dist/assets/Modal.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/assets/VisuallyHidden.css +1 -1
- package/dist/chunks/index.BzllgVaP.js +12 -0
- package/dist/components/AuthButton/index.js +7 -7
- package/dist/components/CDPReactProvider/index.d.ts +3 -0
- package/dist/components/CDPReactProvider/index.js +20 -13
- package/dist/components/SendTransactionButton/index.js +1 -1
- package/dist/components/SignIn/SignInAuthMethodButtons.d.ts +13 -0
- package/dist/components/SignIn/SignInAuthMethodButtons.js +59 -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 +30 -195
- 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 +6 -0
- package/dist/components/SignIn/flows/SignInWithEmail.js +88 -0
- package/dist/components/SignIn/flows/SignInWithSms.d.ts +8 -0
- package/dist/components/SignIn/flows/SignInWithSms.js +3011 -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 +56 -44
- package/dist/components/SignOutButton/index.js +1 -1
- package/dist/components/ThemeProvider/index.js +1 -1
- package/dist/components/forms/EmailForm/index.d.ts +11 -0
- package/dist/components/forms/EmailForm/index.js +56 -0
- package/dist/components/{Field → forms/Field}/index.d.ts +2 -1
- package/dist/components/forms/Field/index.js +24 -0
- package/dist/components/{Input → forms/Input}/index.js +1 -1
- package/dist/components/forms/Label/index.d.ts +7 -0
- package/dist/components/forms/Label/index.js +13 -0
- package/dist/components/{OTP → forms/OTP}/index.d.ts +3 -0
- package/dist/components/forms/OTP/index.js +65 -0
- package/dist/components/forms/OTPForm/index.d.ts +16 -0
- package/dist/components/forms/OTPForm/index.js +76 -0
- package/dist/components/forms/PhoneNumberForm/index.d.ts +14 -0
- package/dist/components/forms/PhoneNumberForm/index.js +68 -0
- package/dist/components/forms/PhoneNumberInput/PhoneNumberMetadata.d.ts +2 -0
- package/dist/components/forms/PhoneNumberInput/PhoneNumberMetadata.js +5 -0
- package/dist/components/forms/PhoneNumberInput/index.d.ts +10 -0
- package/dist/components/forms/PhoneNumberInput/index.js +76 -0
- package/dist/components/forms/PhoneNumberInput/maskOverride.d.ts +8 -0
- package/dist/components/forms/PhoneNumberInput/maskOverride.js +61 -0
- package/dist/components/forms/PhoneNumberInput/usePhoneNumberFormatter.d.ts +7 -0
- package/dist/components/forms/PhoneNumberInput/usePhoneNumberFormatter.js +52 -0
- package/dist/components/{Button → ui/Button}/index.d.ts +2 -1
- package/dist/components/ui/Button/index.js +75 -0
- package/dist/components/{Error → ui/Error}/index.d.ts +2 -2
- package/dist/components/ui/Error/index.js +16 -0
- package/dist/components/ui/LoadingSkeleton/index.js +19 -0
- package/dist/components/{LoadingSpinner → ui/LoadingSpinner}/index.js +6 -6
- package/dist/components/ui/Modal/index.d.ts +11 -0
- package/dist/components/ui/Modal/index.js +27 -0
- package/dist/components/{ServerError → ui/ServerError}/index.js +4 -4
- package/dist/components/ui/SuccessMessage/index.d.ts +7 -0
- package/dist/components/ui/SuccessMessage/index.js +16 -0
- package/dist/components/ui/SwitchFadeTransition/index.d.ts +5 -0
- package/dist/components/ui/SwitchFadeTransition/index.js +24 -0
- package/dist/components/ui/SwitchSlideTransition/index.d.ts +7 -0
- package/dist/components/ui/SwitchSlideTransition/index.js +27 -0
- package/dist/components/ui/SwitchTransition/index.d.ts +25 -0
- package/dist/components/ui/SwitchTransition/index.js +155 -0
- package/dist/components/{VisuallyHidden → ui/VisuallyHidden}/index.js +2 -2
- 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/package.json +23 -7
- package/dist/components/Button/index.js +0 -50
- package/dist/components/Error/index.js +0 -16
- package/dist/components/Field/index.js +0 -22
- package/dist/components/LoadingSkeleton/index.js +0 -19
- package/dist/components/OTP/index.js +0 -50
- /package/dist/components/{Input → forms/Input}/index.d.ts +0 -0
- /package/dist/components/{LoadingSkeleton → ui/LoadingSkeleton}/index.d.ts +0 -0
- /package/dist/components/{LoadingSpinner → ui/LoadingSpinner}/index.d.ts +0 -0
- /package/dist/components/{ServerError → ui/ServerError}/index.d.ts +0 -0
- /package/dist/components/{VisuallyHidden → ui/VisuallyHidden}/index.d.ts +0 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { APIError } from '@coinbase/cdp-hooks';
|
|
2
|
+
export declare const useEmailForm: ({ submit, }: {
|
|
3
|
+
submit: (email: string) => Promise<{
|
|
4
|
+
flowId: string;
|
|
5
|
+
}>;
|
|
6
|
+
}) => {
|
|
7
|
+
setEmail: (email: string) => void;
|
|
8
|
+
submitEmail: ({ email, onSuccess, onError, }: {
|
|
9
|
+
email: string;
|
|
10
|
+
onSuccess?: () => void;
|
|
11
|
+
onError?: (error: string | APIError) => void;
|
|
12
|
+
}) => Promise<void>;
|
|
13
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import "@coinbase/cdp-hooks";
|
|
2
|
+
import { useCallback as p, useMemo as m } from "react";
|
|
3
|
+
import { isApiError as y } from "../../../utils/isApiError.js";
|
|
4
|
+
import { useSignInContext as d } from "../SignInProvider.js";
|
|
5
|
+
const f = ({
|
|
6
|
+
submit: t
|
|
7
|
+
}) => {
|
|
8
|
+
const { state: n, dispatch: o } = d(), a = "An error occurred while signing in. Please try again.", s = p(
|
|
9
|
+
(e) => {
|
|
10
|
+
o({ type: "SET_EMAIL", payload: { email: e } });
|
|
11
|
+
},
|
|
12
|
+
[o]
|
|
13
|
+
), i = p(
|
|
14
|
+
async ({
|
|
15
|
+
email: e,
|
|
16
|
+
onSuccess: l,
|
|
17
|
+
onError: E
|
|
18
|
+
}) => {
|
|
19
|
+
if (!n.isPending) {
|
|
20
|
+
o({ type: "SUBMIT_EMAIL", payload: { email: e } });
|
|
21
|
+
try {
|
|
22
|
+
const { flowId: r } = await t(e);
|
|
23
|
+
o({ type: "SUBMIT_EMAIL_SUCCESS", payload: { flowId: r } }), l?.();
|
|
24
|
+
} catch (r) {
|
|
25
|
+
const c = y(r) ? r : r instanceof Error && r.message || a;
|
|
26
|
+
o({ type: "SUBMIT_EMAIL_FAILURE", payload: { error: c } }), console.error(r), E?.(c);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
[o, n.isPending, t]
|
|
31
|
+
);
|
|
32
|
+
return m(
|
|
33
|
+
() => ({
|
|
34
|
+
setEmail: s,
|
|
35
|
+
submitEmail: i
|
|
36
|
+
}),
|
|
37
|
+
[s, i]
|
|
38
|
+
);
|
|
39
|
+
};
|
|
40
|
+
export {
|
|
41
|
+
f as useEmailForm
|
|
42
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { APIError } from '@coinbase/cdp-hooks';
|
|
2
|
+
export declare const useOTPForm: <T>({ passwordLength, submit, }: {
|
|
3
|
+
passwordLength: number;
|
|
4
|
+
submit: (otp: string) => Promise<T>;
|
|
5
|
+
}) => {
|
|
6
|
+
resendCountdown: number | null;
|
|
7
|
+
resetOTP: () => void;
|
|
8
|
+
resetResendTimer: () => void;
|
|
9
|
+
setOTP: (otp: string) => void;
|
|
10
|
+
startResendTimer: (durationSeconds: number) => void;
|
|
11
|
+
submitOtp: ({ otp, onSuccess, onError, }: {
|
|
12
|
+
otp: string;
|
|
13
|
+
onSuccess?: () => void;
|
|
14
|
+
onError?: (error: string | APIError) => void;
|
|
15
|
+
}) => Promise<void>;
|
|
16
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import "@coinbase/cdp-hooks";
|
|
2
|
+
import { useCallback as i, useEffect as l, useMemo as u } from "react";
|
|
3
|
+
import { useTimer as E } from "../../../hooks/useTimer.js";
|
|
4
|
+
import { isApiError as S } from "../../../utils/isApiError.js";
|
|
5
|
+
import { useSignInContext as _ } from "../SignInProvider.js";
|
|
6
|
+
const A = ({
|
|
7
|
+
passwordLength: a,
|
|
8
|
+
submit: T
|
|
9
|
+
}) => {
|
|
10
|
+
const { state: n, dispatch: e } = _(), {
|
|
11
|
+
timeRemaining: o,
|
|
12
|
+
start: c,
|
|
13
|
+
reset: r
|
|
14
|
+
} = E(), p = "An error occurred while signing in. Please try again.", m = i(
|
|
15
|
+
(t) => {
|
|
16
|
+
e({ type: "SET_OTP", payload: { otp: t } });
|
|
17
|
+
},
|
|
18
|
+
[e]
|
|
19
|
+
), y = i(
|
|
20
|
+
async ({
|
|
21
|
+
otp: t,
|
|
22
|
+
onSuccess: d,
|
|
23
|
+
onError: f
|
|
24
|
+
}) => {
|
|
25
|
+
if (!n.isPending) {
|
|
26
|
+
if (t.length !== a) {
|
|
27
|
+
e({ type: "SET_OTP", payload: { otp: t } });
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
e({ type: "SUBMIT_OTP", payload: { otp: t } });
|
|
31
|
+
try {
|
|
32
|
+
await T(t), e({ type: "SUBMIT_OTP_SUCCESS", payload: { otp: t } }), d?.(), r();
|
|
33
|
+
} catch (s) {
|
|
34
|
+
const O = S(s) ? s : s instanceof Error && s.message || p;
|
|
35
|
+
e({ type: "SUBMIT_OTP_FAILURE", payload: { error: O } }), console.error(s), f?.(O);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
[e, n.isPending, a, T, r]
|
|
40
|
+
), P = i(() => {
|
|
41
|
+
e({ type: "RESET_OTP" }), r();
|
|
42
|
+
}, [e, r]);
|
|
43
|
+
return l(() => {
|
|
44
|
+
o === 0 && n.step === "verification" && !n.canResetOTP && (e({ type: "ALLOW_RESET_OTP" }), r());
|
|
45
|
+
}, [o, r, n.step, n.canResetOTP, e]), u(
|
|
46
|
+
() => ({
|
|
47
|
+
resendCountdown: o,
|
|
48
|
+
resetOTP: P,
|
|
49
|
+
resetResendTimer: r,
|
|
50
|
+
setOTP: m,
|
|
51
|
+
startResendTimer: c,
|
|
52
|
+
submitOtp: y
|
|
53
|
+
}),
|
|
54
|
+
[o, P, r, m, c, y]
|
|
55
|
+
);
|
|
56
|
+
};
|
|
57
|
+
export {
|
|
58
|
+
A as useOTPForm
|
|
59
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { APIError } from '@coinbase/cdp-hooks';
|
|
2
|
+
export declare const usePhoneNumberForm: ({ submit, }: {
|
|
3
|
+
submit: (phoneNumber: string) => Promise<{
|
|
4
|
+
flowId: string;
|
|
5
|
+
}>;
|
|
6
|
+
}) => {
|
|
7
|
+
setPhoneNumber: (phoneNumber: string) => void;
|
|
8
|
+
submitPhoneNumber: ({ phoneNumber, onSuccess, onError, }: {
|
|
9
|
+
phoneNumber: string;
|
|
10
|
+
onSuccess?: () => void;
|
|
11
|
+
onError?: (error: string | APIError) => void;
|
|
12
|
+
}) => Promise<void>;
|
|
13
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import "@coinbase/cdp-hooks";
|
|
2
|
+
import { useCallback as p, useMemo as l } from "react";
|
|
3
|
+
import { isApiError as y } from "../../../utils/isApiError.js";
|
|
4
|
+
import { useSignInContext as d } from "../SignInProvider.js";
|
|
5
|
+
const U = ({
|
|
6
|
+
submit: t
|
|
7
|
+
}) => {
|
|
8
|
+
const { state: n, dispatch: o } = d(), s = "An error occurred while signing in. Please try again.", a = p(
|
|
9
|
+
(e) => {
|
|
10
|
+
o({ type: "SET_PHONE_NUMBER", payload: { phoneNumber: e } });
|
|
11
|
+
},
|
|
12
|
+
[o]
|
|
13
|
+
), i = p(
|
|
14
|
+
async ({
|
|
15
|
+
phoneNumber: e,
|
|
16
|
+
onSuccess: E,
|
|
17
|
+
onError: m
|
|
18
|
+
}) => {
|
|
19
|
+
if (!n.isPending) {
|
|
20
|
+
o({ type: "SUBMIT_PHONE_NUMBER", payload: { phoneNumber: e } });
|
|
21
|
+
try {
|
|
22
|
+
const { flowId: r } = await t(e);
|
|
23
|
+
o({ type: "SUBMIT_PHONE_NUMBER_SUCCESS", payload: { flowId: r } }), E?.();
|
|
24
|
+
} catch (r) {
|
|
25
|
+
const c = y(r) ? r : r instanceof Error && r.message || s;
|
|
26
|
+
o({ type: "SUBMIT_PHONE_NUMBER_FAILURE", payload: { error: c } }), console.error(r), m?.(c);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
[o, n.isPending, t]
|
|
31
|
+
);
|
|
32
|
+
return l(
|
|
33
|
+
() => ({
|
|
34
|
+
setPhoneNumber: a,
|
|
35
|
+
submitPhoneNumber: i
|
|
36
|
+
}),
|
|
37
|
+
[a, i]
|
|
38
|
+
);
|
|
39
|
+
};
|
|
40
|
+
export {
|
|
41
|
+
U as usePhoneNumberForm
|
|
42
|
+
};
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
+
import { SignInAuthMethodButtons, SignInAuthMethodButtonsProps } from './SignInAuthMethodButtons';
|
|
3
|
+
import { SignInBackButton, SignInBackButtonProps } from './SignInBackButton';
|
|
2
4
|
import { SignInDescription, SignInDescriptionProps } from './SignInDescription';
|
|
5
|
+
import { SignInFooter } from './SignInFooter';
|
|
3
6
|
import { SignInForm, SignInFormProps } from './SignInForm';
|
|
4
7
|
import { SignInImage, SignInImageProps } from './SignInImage';
|
|
5
8
|
import { useSignInContext } from './SignInProvider';
|
|
6
9
|
import { SignInTitle, SignInTitleProps } from './SignInTitle';
|
|
7
|
-
import { SignInState } from './
|
|
10
|
+
import { SignInState, SignInAction } from './types';
|
|
8
11
|
export interface SignInProps {
|
|
9
12
|
children?: ReactNode | ((state: SignInState) => ReactNode);
|
|
10
13
|
className?: string;
|
|
11
14
|
onSuccess?: () => void;
|
|
12
15
|
}
|
|
13
16
|
export declare const SignIn: (props: SignInProps) => import("react/jsx-runtime").JSX.Element;
|
|
14
|
-
export { SignInDescription, SignInForm, SignInImage, SignInTitle, useSignInContext, type SignInDescriptionProps, type SignInFormProps, type SignInImageProps, type SignInTitleProps, };
|
|
17
|
+
export { SignInAuthMethodButtons, SignInBackButton, SignInDescription, SignInFooter, SignInForm, SignInImage, SignInTitle, useSignInContext, type SignInAuthMethodButtonsProps, type SignInBackButtonProps, type SignInDescriptionProps, type SignInFormProps, type SignInImageProps, type SignInTitleProps, type SignInState, type SignInAction, };
|
|
@@ -1,30 +1,48 @@
|
|
|
1
|
-
import { jsx as n, jsxs as
|
|
1
|
+
import { jsx as n, jsxs as t, Fragment as s } from "react/jsx-runtime";
|
|
2
2
|
import "react";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
3
|
+
import { useAppConfig as l } from "../CDPReactProvider/index.js";
|
|
4
|
+
import { SignInAuthMethodButtons as d } from "./SignInAuthMethodButtons.js";
|
|
5
|
+
import { SignInBackButton as f } from "./SignInBackButton.js";
|
|
6
|
+
import { SignInDescription as u } from "./SignInDescription.js";
|
|
7
|
+
import { SignInFooter as I } from "./SignInFooter.js";
|
|
8
|
+
import { SignInForm as S } from "./SignInForm.js";
|
|
9
|
+
import { SignInImage as b } from "./SignInImage.js";
|
|
10
|
+
import { SignInProvider as k, useSignInContext as w } from "./SignInProvider.js";
|
|
11
|
+
import { SignInTitle as h } from "./SignInTitle.js";
|
|
8
12
|
import "@coinbase/cdp-hooks";
|
|
9
|
-
import '../../assets/SignIn.css';const
|
|
10
|
-
"sign-in": "SignIn-module__sign-in___cYpee"
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
13
|
+
import '../../assets/SignIn.css';const v = "SignIn-module__footer___3Gkbc", o = {
|
|
14
|
+
"sign-in": "SignIn-module__sign-in___cYpee",
|
|
15
|
+
"title-desc-wrapper": "SignIn-module__title-desc-wrapper___VpPcA",
|
|
16
|
+
"back-button": "SignIn-module__back-button___bmE-y",
|
|
17
|
+
"back-button-wrapper": "SignIn-module__back-button-wrapper___Q9FA1",
|
|
18
|
+
footer: v
|
|
19
|
+
}, F = ({ className: r = "", children: i, onSuccess: p }) => {
|
|
20
|
+
const { state: a } = w(), { showCoinbaseFooter: _ } = l(), c = typeof i == "function" ? i(a) : i;
|
|
21
|
+
return /* @__PURE__ */ t("div", { className: `${o["sign-in"]} ${r}`, children: [
|
|
22
|
+
c,
|
|
23
|
+
!c && /* @__PURE__ */ t(s, { children: [
|
|
24
|
+
/* @__PURE__ */ n("div", { className: o["back-button-wrapper"], children: /* @__PURE__ */ n(f, { className: o["back-button"] }) }),
|
|
25
|
+
/* @__PURE__ */ n(b, {}),
|
|
26
|
+
/* @__PURE__ */ n(S, { onSuccess: p, children: ({ authMethod: e, step: m, Form: g }) => /* @__PURE__ */ t(s, { children: [
|
|
27
|
+
/* @__PURE__ */ t("div", { className: o["title-desc-wrapper"], children: [
|
|
28
|
+
/* @__PURE__ */ n(h, { step: m, authMethod: e }),
|
|
29
|
+
/* @__PURE__ */ n(u, { step: m, authMethod: e })
|
|
30
|
+
] }),
|
|
31
|
+
g,
|
|
32
|
+
m === "credentials" && /* @__PURE__ */ n(d, { activeMethod: e })
|
|
33
|
+
] }) }),
|
|
34
|
+
_ && /* @__PURE__ */ n(I, { className: o.footer })
|
|
20
35
|
] })
|
|
21
36
|
] });
|
|
22
|
-
},
|
|
37
|
+
}, Q = (r) => /* @__PURE__ */ n(k, { children: /* @__PURE__ */ n(F, { ...r }) });
|
|
23
38
|
export {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
S as
|
|
39
|
+
Q as SignIn,
|
|
40
|
+
d as SignInAuthMethodButtons,
|
|
41
|
+
f as SignInBackButton,
|
|
42
|
+
u as SignInDescription,
|
|
43
|
+
I as SignInFooter,
|
|
44
|
+
S as SignInForm,
|
|
45
|
+
b as SignInImage,
|
|
46
|
+
h as SignInTitle,
|
|
47
|
+
w as useSignInContext
|
|
30
48
|
};
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { APIError } from '@coinbase/cdp-hooks';
|
|
2
|
+
import { FC, ReactNode } from 'react';
|
|
3
|
+
import { AuthMethod } from '../CDPReactProvider';
|
|
4
|
+
export interface SignInTitleAndDescriptionProps {
|
|
5
|
+
authMethod?: AuthMethod;
|
|
6
|
+
step?: SignInState["step"];
|
|
7
|
+
}
|
|
8
|
+
export interface SignInState {
|
|
9
|
+
authMethod: AuthMethod;
|
|
10
|
+
canResetOTP: boolean;
|
|
11
|
+
email: string;
|
|
12
|
+
error: string | APIError | null;
|
|
13
|
+
flowId: string;
|
|
14
|
+
isPending: boolean;
|
|
15
|
+
isSuccess: boolean;
|
|
16
|
+
otp: string;
|
|
17
|
+
phoneNumber: string;
|
|
18
|
+
step: "credentials" | "verification";
|
|
19
|
+
}
|
|
20
|
+
export type SignInAction = {
|
|
21
|
+
type: "SET_AUTH_METHOD";
|
|
22
|
+
payload: {
|
|
23
|
+
authMethod: AuthMethod;
|
|
24
|
+
};
|
|
25
|
+
} | {
|
|
26
|
+
type: "SET_EMAIL";
|
|
27
|
+
payload: {
|
|
28
|
+
email: string;
|
|
29
|
+
};
|
|
30
|
+
} | {
|
|
31
|
+
type: "SUBMIT_EMAIL";
|
|
32
|
+
payload: {
|
|
33
|
+
email: string;
|
|
34
|
+
};
|
|
35
|
+
} | {
|
|
36
|
+
type: "SUBMIT_EMAIL_SUCCESS";
|
|
37
|
+
payload: {
|
|
38
|
+
flowId: string;
|
|
39
|
+
};
|
|
40
|
+
} | {
|
|
41
|
+
type: "SUBMIT_EMAIL_FAILURE";
|
|
42
|
+
payload: {
|
|
43
|
+
error: string | APIError;
|
|
44
|
+
};
|
|
45
|
+
} | {
|
|
46
|
+
type: "SET_PHONE_NUMBER";
|
|
47
|
+
payload: {
|
|
48
|
+
phoneNumber: string;
|
|
49
|
+
};
|
|
50
|
+
} | {
|
|
51
|
+
type: "SUBMIT_PHONE_NUMBER";
|
|
52
|
+
payload: {
|
|
53
|
+
phoneNumber: string;
|
|
54
|
+
};
|
|
55
|
+
} | {
|
|
56
|
+
type: "SUBMIT_PHONE_NUMBER_SUCCESS";
|
|
57
|
+
payload: {
|
|
58
|
+
flowId: string;
|
|
59
|
+
};
|
|
60
|
+
} | {
|
|
61
|
+
type: "SUBMIT_PHONE_NUMBER_FAILURE";
|
|
62
|
+
payload: {
|
|
63
|
+
error: string | APIError;
|
|
64
|
+
};
|
|
65
|
+
} | {
|
|
66
|
+
type: "SET_OTP";
|
|
67
|
+
payload: {
|
|
68
|
+
otp: string;
|
|
69
|
+
};
|
|
70
|
+
} | {
|
|
71
|
+
type: "SUBMIT_OTP";
|
|
72
|
+
payload: {
|
|
73
|
+
otp: string;
|
|
74
|
+
};
|
|
75
|
+
} | {
|
|
76
|
+
type: "SUBMIT_OTP_SUCCESS";
|
|
77
|
+
payload: {
|
|
78
|
+
otp: string;
|
|
79
|
+
};
|
|
80
|
+
} | {
|
|
81
|
+
type: "SUBMIT_OTP_FAILURE";
|
|
82
|
+
payload: {
|
|
83
|
+
error: string | APIError;
|
|
84
|
+
};
|
|
85
|
+
} | {
|
|
86
|
+
type: "ALLOW_RESET_OTP";
|
|
87
|
+
} | {
|
|
88
|
+
type: "RESET_OTP";
|
|
89
|
+
} | {
|
|
90
|
+
type: "CLEAR_ERROR";
|
|
91
|
+
} | {
|
|
92
|
+
type: "RESET_STATE";
|
|
93
|
+
};
|
|
94
|
+
export interface SignInFlowProps {
|
|
95
|
+
step: SignInState["step"];
|
|
96
|
+
onSuccess?: () => void;
|
|
97
|
+
children?: (props: {
|
|
98
|
+
step: SignInState["step"];
|
|
99
|
+
Form: ReactNode;
|
|
100
|
+
}) => ReactNode;
|
|
101
|
+
}
|
|
102
|
+
export interface SignInFlowConfig {
|
|
103
|
+
forms: FC<SignInFlowProps>;
|
|
104
|
+
description: FC<SignInTitleAndDescriptionProps>;
|
|
105
|
+
title: FC<SignInTitleAndDescriptionProps>;
|
|
106
|
+
}
|
|
@@ -1,58 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export interface SignInState {
|
|
3
|
-
canResetOTP: boolean;
|
|
4
|
-
email: string;
|
|
5
|
-
error: string | APIError | null;
|
|
6
|
-
flowId: string;
|
|
7
|
-
isPending: boolean;
|
|
8
|
-
otp: string;
|
|
9
|
-
step: "email" | "otp" | "success";
|
|
10
|
-
}
|
|
11
|
-
export type SignInAction = {
|
|
12
|
-
type: "SET_EMAIL";
|
|
13
|
-
payload: {
|
|
14
|
-
email: string;
|
|
15
|
-
};
|
|
16
|
-
} | {
|
|
17
|
-
type: "SUBMIT_EMAIL";
|
|
18
|
-
payload: {
|
|
19
|
-
email: string;
|
|
20
|
-
};
|
|
21
|
-
} | {
|
|
22
|
-
type: "SUBMIT_EMAIL_SUCCESS";
|
|
23
|
-
payload: {
|
|
24
|
-
flowId: string;
|
|
25
|
-
};
|
|
26
|
-
} | {
|
|
27
|
-
type: "SUBMIT_EMAIL_FAILURE";
|
|
28
|
-
payload: {
|
|
29
|
-
error: string | APIError;
|
|
30
|
-
};
|
|
31
|
-
} | {
|
|
32
|
-
type: "SET_OTP";
|
|
33
|
-
payload: {
|
|
34
|
-
otp: string;
|
|
35
|
-
};
|
|
36
|
-
} | {
|
|
37
|
-
type: "SUBMIT_OTP";
|
|
38
|
-
payload: {
|
|
39
|
-
otp: string;
|
|
40
|
-
};
|
|
41
|
-
} | {
|
|
42
|
-
type: "SUBMIT_OTP_SUCCESS";
|
|
43
|
-
payload: {
|
|
44
|
-
otp: string;
|
|
45
|
-
};
|
|
46
|
-
} | {
|
|
47
|
-
type: "SUBMIT_OTP_FAILURE";
|
|
48
|
-
payload: {
|
|
49
|
-
error: string | APIError;
|
|
50
|
-
};
|
|
51
|
-
} | {
|
|
52
|
-
type: "ALLOW_RESET_OTP";
|
|
53
|
-
} | {
|
|
54
|
-
type: "RESET_OTP";
|
|
55
|
-
} | {
|
|
56
|
-
type: "CLEAR_ERROR";
|
|
57
|
-
};
|
|
1
|
+
import { SignInAction, SignInState } from './types';
|
|
58
2
|
export declare const useSignInReducer: (initialState: SignInState) => [SignInState, import('react').ActionDispatch<[action: SignInAction]>];
|
|
@@ -1,50 +1,92 @@
|
|
|
1
|
-
import "@coinbase/cdp-hooks";
|
|
2
1
|
import { useReducer as n } from "react";
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import "@coinbase/cdp-hooks";
|
|
3
|
+
import "../CDPReactProvider/index.js";
|
|
4
|
+
function l(e, r) {
|
|
5
|
+
switch (r.type) {
|
|
6
|
+
case "SET_AUTH_METHOD":
|
|
7
|
+
return {
|
|
8
|
+
...e,
|
|
9
|
+
authMethod: r.payload.authMethod,
|
|
10
|
+
step: "credentials",
|
|
11
|
+
email: "",
|
|
12
|
+
phoneNumber: "",
|
|
13
|
+
error: null
|
|
14
|
+
};
|
|
5
15
|
case "SET_EMAIL":
|
|
6
|
-
return { ...
|
|
16
|
+
return { ...e, email: r.payload.email, phoneNumber: "", error: null };
|
|
7
17
|
case "SUBMIT_EMAIL":
|
|
8
|
-
return {
|
|
18
|
+
return {
|
|
19
|
+
...e,
|
|
20
|
+
isPending: !0,
|
|
21
|
+
email: r.payload.email,
|
|
22
|
+
phoneNumber: "",
|
|
23
|
+
error: null
|
|
24
|
+
};
|
|
25
|
+
case "SET_PHONE_NUMBER":
|
|
26
|
+
return { ...e, phoneNumber: r.payload.phoneNumber, email: "", error: null };
|
|
27
|
+
case "SUBMIT_PHONE_NUMBER":
|
|
28
|
+
return {
|
|
29
|
+
...e,
|
|
30
|
+
isPending: !0,
|
|
31
|
+
phoneNumber: r.payload.phoneNumber,
|
|
32
|
+
email: "",
|
|
33
|
+
error: null
|
|
34
|
+
};
|
|
9
35
|
case "SUBMIT_EMAIL_SUCCESS":
|
|
36
|
+
case "SUBMIT_PHONE_NUMBER_SUCCESS":
|
|
10
37
|
return {
|
|
11
|
-
...
|
|
38
|
+
...e,
|
|
12
39
|
error: null,
|
|
13
|
-
flowId:
|
|
40
|
+
flowId: r.payload.flowId,
|
|
14
41
|
canResetOTP: !1,
|
|
15
42
|
isPending: !1,
|
|
16
43
|
otp: "",
|
|
17
|
-
step: "
|
|
44
|
+
step: "verification"
|
|
18
45
|
};
|
|
19
46
|
case "SUBMIT_EMAIL_FAILURE":
|
|
47
|
+
case "SUBMIT_PHONE_NUMBER_FAILURE":
|
|
20
48
|
return {
|
|
21
|
-
...
|
|
22
|
-
error:
|
|
49
|
+
...e,
|
|
50
|
+
error: r.payload.error,
|
|
23
51
|
isPending: !1
|
|
24
52
|
};
|
|
25
53
|
case "SET_OTP":
|
|
26
|
-
return { ...
|
|
54
|
+
return { ...e, error: null, otp: r.payload.otp };
|
|
27
55
|
case "SUBMIT_OTP":
|
|
28
|
-
return { ...
|
|
56
|
+
return { ...e, error: null, isPending: !0, otp: r.payload.otp };
|
|
29
57
|
case "SUBMIT_OTP_SUCCESS":
|
|
30
|
-
return { ...
|
|
58
|
+
return { ...e, error: null, isPending: !1, isSuccess: !0 };
|
|
31
59
|
case "SUBMIT_OTP_FAILURE":
|
|
32
60
|
return {
|
|
33
|
-
...
|
|
34
|
-
error:
|
|
35
|
-
isPending: !1
|
|
61
|
+
...e,
|
|
62
|
+
error: r.payload.error,
|
|
63
|
+
isPending: !1,
|
|
64
|
+
isSuccess: !1
|
|
36
65
|
};
|
|
37
66
|
case "ALLOW_RESET_OTP":
|
|
38
|
-
return { ...
|
|
67
|
+
return { ...e, canResetOTP: !0 };
|
|
39
68
|
case "RESET_OTP":
|
|
40
|
-
return { ...
|
|
69
|
+
return { ...e, error: null, canResetOTP: !1 };
|
|
41
70
|
case "CLEAR_ERROR":
|
|
42
|
-
return { ...
|
|
71
|
+
return { ...e, error: null };
|
|
72
|
+
case "RESET_STATE":
|
|
73
|
+
return {
|
|
74
|
+
authMethod: e.authMethod,
|
|
75
|
+
canResetOTP: !1,
|
|
76
|
+
error: null,
|
|
77
|
+
isPending: !1,
|
|
78
|
+
isSuccess: !1,
|
|
79
|
+
email: "",
|
|
80
|
+
flowId: "",
|
|
81
|
+
otp: "",
|
|
82
|
+
phoneNumber: "",
|
|
83
|
+
step: "credentials"
|
|
84
|
+
};
|
|
43
85
|
default:
|
|
44
86
|
throw new Error("Unknown action type");
|
|
45
87
|
}
|
|
46
88
|
}
|
|
47
|
-
const s = (
|
|
89
|
+
const s = (e) => n(l, e);
|
|
48
90
|
export {
|
|
49
91
|
s as useSignInReducer
|
|
50
92
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
export
|
|
2
|
+
export interface SignInModalProps {
|
|
3
3
|
children?: ReactNode;
|
|
4
4
|
open?: boolean;
|
|
5
5
|
setIsOpen?: (value: boolean) => void;
|
|
6
6
|
onSuccess?: () => void;
|
|
7
|
-
}
|
|
7
|
+
}
|
|
8
8
|
export declare const SignInModal: ({ children, open, setIsOpen, onSuccess }: SignInModalProps) => import("react/jsx-runtime").JSX.Element;
|