@coinbase/cdp-react 0.0.18 → 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.
Files changed (133) hide show
  1. package/dist/assets/Button.css +1 -1
  2. package/dist/assets/EmailForm.css +1 -0
  3. package/dist/assets/Error.css +1 -1
  4. package/dist/assets/Field.css +1 -1
  5. package/dist/assets/FlowEmailOTP.css +1 -0
  6. package/dist/assets/FlowPhoneNumberOTP.css +1 -0
  7. package/dist/assets/Input.css +1 -1
  8. package/dist/assets/Label.css +1 -0
  9. package/dist/assets/OTP.css +1 -1
  10. package/dist/assets/OTPForm.css +1 -0
  11. package/dist/assets/PhoneNumberForm.css +1 -0
  12. package/dist/assets/PhoneNumberInput.css +1 -0
  13. package/dist/assets/SignIn.css +1 -1
  14. package/dist/assets/SignInAuthMethodButtons.css +1 -0
  15. package/dist/assets/SignInBackButton.css +1 -0
  16. package/dist/assets/SignInCredentials.css +1 -0
  17. package/dist/assets/SignInDescription.css +1 -1
  18. package/dist/assets/SignInFooter.css +1 -0
  19. package/dist/assets/SignInForm.css +1 -1
  20. package/dist/assets/SignInImage.css +1 -1
  21. package/dist/assets/SignInModal.css +1 -1
  22. package/dist/assets/SignInTitle.css +1 -1
  23. package/dist/assets/SuccessMessage.css +1 -0
  24. package/dist/assets/SwitchFadeTransition.css +1 -0
  25. package/dist/assets/SwitchSlideTransition.css +1 -0
  26. package/dist/assets/SwitchTransition.css +1 -0
  27. package/dist/assets/ThemeProvider.css +1 -1
  28. package/dist/chunks/index.BzllgVaP.js +12 -0
  29. package/dist/components/AuthButton/index.js +1 -1
  30. package/dist/components/Button/index.d.ts +2 -1
  31. package/dist/components/Button/index.js +47 -22
  32. package/dist/components/CDPReactProvider/index.d.ts +3 -0
  33. package/dist/components/CDPReactProvider/index.js +20 -13
  34. package/dist/components/EmailForm/index.d.ts +11 -0
  35. package/dist/components/EmailForm/index.js +56 -0
  36. package/dist/components/Error/index.d.ts +2 -2
  37. package/dist/components/Error/index.js +11 -11
  38. package/dist/components/Field/index.d.ts +2 -1
  39. package/dist/components/Field/index.js +20 -18
  40. package/dist/components/FlowEmailOTP/index.d.ts +18 -0
  41. package/dist/components/FlowEmailOTP/index.js +70 -0
  42. package/dist/components/FlowPhoneNumberOTP/index.d.ts +18 -0
  43. package/dist/components/FlowPhoneNumberOTP/index.js +75 -0
  44. package/dist/components/Label/index.d.ts +7 -0
  45. package/dist/components/Label/index.js +13 -0
  46. package/dist/components/OTP/index.d.ts +3 -0
  47. package/dist/components/OTP/index.js +48 -33
  48. package/dist/components/OTPForm/index.d.ts +16 -0
  49. package/dist/components/OTPForm/index.js +76 -0
  50. package/dist/components/PhoneNumberForm/index.d.ts +14 -0
  51. package/dist/components/PhoneNumberForm/index.js +68 -0
  52. package/dist/components/PhoneNumberInput/PhoneNumberMetadata.d.ts +2 -0
  53. package/dist/components/PhoneNumberInput/PhoneNumberMetadata.js +5 -0
  54. package/dist/components/PhoneNumberInput/index.d.ts +10 -0
  55. package/dist/components/PhoneNumberInput/index.js +76 -0
  56. package/dist/components/PhoneNumberInput/maskOverride.d.ts +8 -0
  57. package/dist/components/PhoneNumberInput/maskOverride.js +61 -0
  58. package/dist/components/PhoneNumberInput/usePhoneNumberFormatter.d.ts +7 -0
  59. package/dist/components/PhoneNumberInput/usePhoneNumberFormatter.js +52 -0
  60. package/dist/components/ServerError/index.js +4 -4
  61. package/dist/components/SignIn/SignInAuthMethodButtons.d.ts +13 -0
  62. package/dist/components/SignIn/SignInAuthMethodButtons.js +57 -0
  63. package/dist/components/SignIn/SignInBackButton.d.ts +9 -0
  64. package/dist/components/SignIn/SignInBackButton.js +38 -0
  65. package/dist/components/SignIn/SignInCredentials.d.ts +2 -0
  66. package/dist/components/SignIn/SignInCredentials.js +8 -0
  67. package/dist/components/SignIn/SignInDescription.d.ts +4 -3
  68. package/dist/components/SignIn/SignInDescription.js +16 -23
  69. package/dist/components/SignIn/SignInFooter.d.ts +2 -0
  70. package/dist/components/SignIn/SignInFooter.js +18 -0
  71. package/dist/components/SignIn/SignInForm.d.ts +12 -4
  72. package/dist/components/SignIn/SignInForm.js +25 -196
  73. package/dist/components/SignIn/SignInImage.d.ts +2 -2
  74. package/dist/components/SignIn/SignInImage.js +11 -14
  75. package/dist/components/SignIn/SignInProvider.d.ts +1 -1
  76. package/dist/components/SignIn/SignInProvider.js +24 -16
  77. package/dist/components/SignIn/SignInTitle.d.ts +4 -3
  78. package/dist/components/SignIn/SignInTitle.js +18 -13
  79. package/dist/components/SignIn/flows/SignInWithEmail.d.ts +5 -0
  80. package/dist/components/SignIn/flows/SignInWithEmail.js +71 -0
  81. package/dist/components/SignIn/flows/SignInWithSms.d.ts +5 -0
  82. package/dist/components/SignIn/flows/SignInWithSms.js +2994 -0
  83. package/dist/components/SignIn/hooks/useEmailForm.d.ts +13 -0
  84. package/dist/components/SignIn/hooks/useEmailForm.js +42 -0
  85. package/dist/components/SignIn/hooks/useOTPForm.d.ts +16 -0
  86. package/dist/components/SignIn/hooks/useOTPForm.js +59 -0
  87. package/dist/components/SignIn/hooks/usePhoneNumberForm.d.ts +13 -0
  88. package/dist/components/SignIn/hooks/usePhoneNumberForm.js +42 -0
  89. package/dist/components/SignIn/index.d.ts +5 -2
  90. package/dist/components/SignIn/index.js +42 -24
  91. package/dist/components/SignIn/types.d.ts +106 -0
  92. package/dist/components/SignIn/types.js +3 -0
  93. package/dist/components/SignIn/useSignInReducer.d.ts +1 -57
  94. package/dist/components/SignIn/useSignInReducer.js +62 -20
  95. package/dist/components/SignInModal/index.d.ts +2 -2
  96. package/dist/components/SignInModal/index.js +62 -43
  97. package/dist/components/SuccessMessage/index.d.ts +7 -0
  98. package/dist/components/SuccessMessage/index.js +16 -0
  99. package/dist/components/SwitchFadeTransition/index.d.ts +5 -0
  100. package/dist/components/SwitchFadeTransition/index.js +24 -0
  101. package/dist/components/SwitchSlideTransition/index.d.ts +7 -0
  102. package/dist/components/SwitchSlideTransition/index.js +27 -0
  103. package/dist/components/SwitchTransition/index.d.ts +25 -0
  104. package/dist/components/SwitchTransition/index.js +155 -0
  105. package/dist/data/countries.d.ts +12 -0
  106. package/dist/data/countries.js +25 -0
  107. package/dist/data/countryNames.d.ts +1 -0
  108. package/dist/data/countryNames.js +6 -0
  109. package/dist/hooks/usePhoneNumberValidators.d.ts +14 -0
  110. package/dist/hooks/usePhoneNumberValidators.js +36 -0
  111. package/dist/hooks/useTimer.d.ts +5 -0
  112. package/dist/hooks/useTimer.js +24 -0
  113. package/dist/icons/IconArrowLeft.d.ts +2 -0
  114. package/dist/icons/IconArrowLeft.js +14 -0
  115. package/dist/icons/IconCheckCircle.js +2 -3
  116. package/dist/icons/IconCoinbaseWordmark.js +5 -5
  117. package/dist/icons/IconEnvelope.d.ts +2 -0
  118. package/dist/icons/IconEnvelope.js +7 -0
  119. package/dist/icons/IconExclamationCircle.js +3 -4
  120. package/dist/icons/IconPhone.d.ts +2 -0
  121. package/dist/icons/IconPhone.js +7 -0
  122. package/dist/icons/IconXMark.js +6 -5
  123. package/dist/icons/index.d.ts +3 -0
  124. package/dist/icons/index.js +14 -8
  125. package/dist/index.js +66 -53
  126. package/dist/theme/theme.d.ts +11 -2
  127. package/dist/theme/tokens.d.ts +30 -6
  128. package/dist/theme/tokens.js +7 -3
  129. package/dist/utils/parseValuesFromPhoneNumber.d.ts +6 -0
  130. package/dist/utils/parseValuesFromPhoneNumber.js +16 -0
  131. package/dist/utils/validatePhoneNumber.d.ts +1 -0
  132. package/dist/utils/validatePhoneNumber.js +1 -0
  133. package/package.json +11 -7
@@ -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 './useSignInReducer';
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 r, Fragment as s } from "react/jsx-runtime";
1
+ import { jsx as n, jsxs as t, Fragment as s } from "react/jsx-runtime";
2
2
  import "react";
3
- import { SignInDescription as g } from "./SignInDescription.js";
4
- import { SignInForm as p } from "./SignInForm.js";
5
- import { SignInImage as c } from "./SignInImage.js";
6
- import { SignInProvider as I, useSignInContext as S } from "./SignInProvider.js";
7
- import { SignInTitle as f } from "./SignInTitle.js";
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 a = {
10
- "sign-in": "SignIn-module__sign-in___cYpee"
11
- }, l = ({ className: i = "", children: t, onSuccess: e }) => {
12
- const { state: m } = S(), o = typeof t == "function" ? t(m) : t;
13
- return /* @__PURE__ */ r("div", { className: `${a["sign-in"]} ${i}`, children: [
14
- o,
15
- !o && /* @__PURE__ */ r(s, { children: [
16
- /* @__PURE__ */ n(c, {}),
17
- /* @__PURE__ */ n(f, {}),
18
- /* @__PURE__ */ n(g, {}),
19
- /* @__PURE__ */ n(p, { onSuccess: e })
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
- }, F = (i) => /* @__PURE__ */ n(I, { children: /* @__PURE__ */ n(l, { ...i }) });
37
+ }, Q = (r) => /* @__PURE__ */ n(k, { children: /* @__PURE__ */ n(F, { ...r }) });
23
38
  export {
24
- F as SignIn,
25
- g as SignInDescription,
26
- p as SignInForm,
27
- c as SignInImage,
28
- f as SignInTitle,
29
- S as useSignInContext
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
+ }
@@ -0,0 +1,3 @@
1
+ import "@coinbase/cdp-hooks";
2
+ import "react";
3
+ import "../CDPReactProvider/index.js";
@@ -1,58 +1,2 @@
1
- import { APIError } from '@coinbase/cdp-hooks';
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
- function l(r, e) {
4
- switch (e.type) {
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 { ...r, email: e.payload.email, error: null };
16
+ return { ...e, email: r.payload.email, phoneNumber: "", error: null };
7
17
  case "SUBMIT_EMAIL":
8
- return { ...r, isPending: !0, email: e.payload.email, error: null };
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
- ...r,
38
+ ...e,
12
39
  error: null,
13
- flowId: e.payload.flowId,
40
+ flowId: r.payload.flowId,
14
41
  canResetOTP: !1,
15
42
  isPending: !1,
16
43
  otp: "",
17
- step: "otp"
44
+ step: "verification"
18
45
  };
19
46
  case "SUBMIT_EMAIL_FAILURE":
47
+ case "SUBMIT_PHONE_NUMBER_FAILURE":
20
48
  return {
21
- ...r,
22
- error: e.payload.error,
49
+ ...e,
50
+ error: r.payload.error,
23
51
  isPending: !1
24
52
  };
25
53
  case "SET_OTP":
26
- return { ...r, error: null, otp: e.payload.otp };
54
+ return { ...e, error: null, otp: r.payload.otp };
27
55
  case "SUBMIT_OTP":
28
- return { ...r, error: null, isPending: !0, otp: e.payload.otp };
56
+ return { ...e, error: null, isPending: !0, otp: r.payload.otp };
29
57
  case "SUBMIT_OTP_SUCCESS":
30
- return { ...r, error: null, isPending: !1, step: "success" };
58
+ return { ...e, error: null, isPending: !1, isSuccess: !0 };
31
59
  case "SUBMIT_OTP_FAILURE":
32
60
  return {
33
- ...r,
34
- error: e.payload.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 { ...r, canResetOTP: !0 };
67
+ return { ...e, canResetOTP: !0 };
39
68
  case "RESET_OTP":
40
- return { ...r, error: null, canResetOTP: !1 };
69
+ return { ...e, error: null, canResetOTP: !1 };
41
70
  case "CLEAR_ERROR":
42
- return { ...r, error: null };
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 = (r) => n(l, r);
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 type SignInModalProps = {
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;