@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
|
@@ -1,202 +1,37 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
import { withValidityState as Z } from "../Input/index.js";
|
|
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: s, dispatch: d } = E(), e = () => d({ type: "CLEAR_ERROR" }), u = (p) => (p.preventDefault(), _(s.email));
|
|
33
|
-
return /* @__PURE__ */ i(
|
|
34
|
-
P,
|
|
35
|
-
{
|
|
36
|
-
className: n.form,
|
|
37
|
-
onClearServerErrors: e,
|
|
38
|
-
onSubmit: u,
|
|
39
|
-
children: [
|
|
40
|
-
/* @__PURE__ */ o(
|
|
41
|
-
x,
|
|
42
|
-
{
|
|
43
|
-
label: "Email address",
|
|
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: s.email,
|
|
56
|
-
onChange: (p) => {
|
|
57
|
-
d({ type: "SET_EMAIL", payload: { email: p.target.value } });
|
|
58
|
-
}
|
|
59
|
-
})
|
|
60
|
-
}
|
|
61
|
-
),
|
|
62
|
-
s.error && /* @__PURE__ */ o(O, { error: s.error, className: n["server-error"] }),
|
|
63
|
-
/* @__PURE__ */ o(R, { asChild: !0, children: /* @__PURE__ */ o(C, { type: "submit", isPending: s.isPending, children: "Continue with email" }) })
|
|
64
|
-
]
|
|
65
|
-
}
|
|
66
|
-
);
|
|
67
|
-
}, z = ({
|
|
68
|
-
reset: _,
|
|
69
|
-
resetCountdown: s,
|
|
70
|
-
submit: d
|
|
1
|
+
import { jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as s, useLayoutEffect as g } from "react";
|
|
3
|
+
import { useAppConfig as M } from "../CDPReactProvider/index.js";
|
|
4
|
+
import { SwitchFadeTransition as w } from "../ui/SwitchFadeTransition/index.js";
|
|
5
|
+
import { a as _ } from "../../chunks/index.BzllgVaP.js";
|
|
6
|
+
import { useSignInContext as F } from "./SignInProvider.js";
|
|
7
|
+
import "@coinbase/cdp-hooks";
|
|
8
|
+
import '../../assets/SignInForm.css';const I = {
|
|
9
|
+
"auth-method-wrapper": "SignInForm-module__auth-method-wrapper___uIOAB"
|
|
10
|
+
}, T = ({
|
|
11
|
+
onSuccess: a,
|
|
12
|
+
step: u,
|
|
13
|
+
children: h,
|
|
14
|
+
...m
|
|
71
15
|
}) => {
|
|
72
|
-
const { state:
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}, [e.step]), /* @__PURE__ */ i(
|
|
78
|
-
P,
|
|
16
|
+
const { state: t } = F(), { authMethods: p } = M(), c = u || t.step, o = s(t.authMethod), r = s(null);
|
|
17
|
+
return g(() => {
|
|
18
|
+
o.current !== t.authMethod && (r.current?.transition.toggle(t.authMethod), o.current = t.authMethod);
|
|
19
|
+
}, [t.authMethod]), /* @__PURE__ */ e(
|
|
20
|
+
w,
|
|
79
21
|
{
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
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__ */ i("div", { className: n["form-footer"], children: [
|
|
100
|
-
(e.isPending && !e.canResetOTP || e.error) && /* @__PURE__ */ i("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__ */ i("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: h,
|
|
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__ */ i("p", { children: [
|
|
116
|
-
"Resend code in ",
|
|
117
|
-
/* @__PURE__ */ i("span", { "aria-hidden": "true", children: [
|
|
118
|
-
s,
|
|
119
|
-
"s"
|
|
120
|
-
] }),
|
|
121
|
-
/* @__PURE__ */ i(j, { children: [
|
|
122
|
-
s,
|
|
123
|
-
" ",
|
|
124
|
-
s === 1 ? "second" : "seconds"
|
|
125
|
-
] })
|
|
126
|
-
] }) })
|
|
127
|
-
] })
|
|
128
|
-
] })
|
|
129
|
-
]
|
|
130
|
-
}
|
|
131
|
-
);
|
|
132
|
-
}, he = ({
|
|
133
|
-
as: _ = "div",
|
|
134
|
-
className: s = "",
|
|
135
|
-
onSuccess: d,
|
|
136
|
-
...e
|
|
137
|
-
}) => {
|
|
138
|
-
const l = "An error occurred while signing in. Please try again.", [f, h] = v(0), [c, S] = v(!1), { signInWithEmail: w } = U(), { verifyEmailOTP: b } = V(), { state: a, dispatch: m } = E(), { showCoinbaseFooter: F } = k(), L = (t) => {
|
|
139
|
-
h(t), S(!0);
|
|
140
|
-
};
|
|
141
|
-
y(() => {
|
|
142
|
-
if (!c)
|
|
143
|
-
return;
|
|
144
|
-
const t = setInterval(() => {
|
|
145
|
-
h((r) => r > 1 ? r - 1 : (S(!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);
|
|
22
|
+
animateHeight: !0,
|
|
23
|
+
timeout: 250,
|
|
24
|
+
items: p || ["email"],
|
|
25
|
+
initialEntered: !0,
|
|
26
|
+
transitionRef: r,
|
|
27
|
+
...m,
|
|
28
|
+
children: ({ itemKey: n, ...d }) => {
|
|
29
|
+
const f = _[n].forms;
|
|
30
|
+
return /* @__PURE__ */ e("div", { ...d, className: I["auth-method-wrapper"], children: /* @__PURE__ */ e(f, { step: c, onSuccess: a, children: ({ step: l, Form: i }) => h?.({ step: l, authMethod: n, Form: i }) || i }) });
|
|
162
31
|
}
|
|
163
32
|
}
|
|
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" }), S(!1), I(a.email);
|
|
183
|
-
};
|
|
184
|
-
return /* @__PURE__ */ i(_, { className: `${n["form-wrapper"]} ${s}`, ...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__ */ i(A, { children: [
|
|
188
|
-
/* @__PURE__ */ o("hr", { className: n.hr }),
|
|
189
|
-
/* @__PURE__ */ i("div", { className: n.footer, children: [
|
|
190
|
-
/* @__PURE__ */ o(W, { className: n.icon }),
|
|
191
|
-
/* @__PURE__ */ i("p", { children: [
|
|
192
|
-
"Secured by",
|
|
193
|
-
" ",
|
|
194
|
-
/* @__PURE__ */ o(D, { className: n["coinbase-icon"], "aria-label": "Coinbase" })
|
|
195
|
-
] })
|
|
196
|
-
] })
|
|
197
|
-
] })
|
|
198
|
-
] });
|
|
33
|
+
);
|
|
199
34
|
};
|
|
200
35
|
export {
|
|
201
|
-
|
|
36
|
+
T as SignInForm
|
|
202
37
|
};
|
|
@@ -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;
|
|
@@ -1,17 +1,22 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
2
|
+
import "react";
|
|
3
|
+
import { a as c } from "../../chunks/index.BzllgVaP.js";
|
|
4
|
+
import { useSignInContext as d } from "./SignInProvider.js";
|
|
5
|
+
import "@coinbase/cdp-hooks";
|
|
6
|
+
import "../CDPReactProvider/index.js";
|
|
7
|
+
import '../../assets/SignInTitle.css';const l = "SignInTitle-module__heading___QJ071", g = {
|
|
8
|
+
heading: l
|
|
9
|
+
}, S = ({
|
|
10
|
+
as: s = "h2",
|
|
11
|
+
children: t,
|
|
12
|
+
className: i = "",
|
|
13
|
+
authMethod: a,
|
|
14
|
+
step: h,
|
|
15
|
+
...m
|
|
11
16
|
}) => {
|
|
12
|
-
const { state:
|
|
13
|
-
return /* @__PURE__ */
|
|
17
|
+
const { state: o } = d(), r = h || o.step, e = a || o.authMethod, p = c[e].title;
|
|
18
|
+
return /* @__PURE__ */ n(s, { className: `${g.heading} ${i}`, ...m, children: t || /* @__PURE__ */ n(p, { step: r, authMethod: e }) });
|
|
14
19
|
};
|
|
15
20
|
export {
|
|
16
|
-
|
|
21
|
+
S as SignInTitle
|
|
17
22
|
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { SignInFlowProps, SignInTitleAndDescriptionProps, SignInFlowConfig } from '../types';
|
|
2
|
+
export type Step = "email" | "otp";
|
|
3
|
+
export declare const SignInWithEmail: ({ step: stepFromProps, onSuccess, children }: SignInFlowProps) => import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
export declare const SignInWithEmailTitle: ({ step }: SignInTitleAndDescriptionProps) => import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
export declare const SignInWithEmailDescription: ({ step }: SignInTitleAndDescriptionProps) => import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export declare const config: SignInFlowConfig;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { jsx as o, jsxs as m, Fragment as a } from "react/jsx-runtime";
|
|
2
|
+
import { useSignInWithEmail as x, useVerifyEmailOTP as y } from "@coinbase/cdp-hooks";
|
|
3
|
+
import { useRef as g, useLayoutEffect as D } from "react";
|
|
4
|
+
import { EmailForm as j } from "../../forms/EmailForm/index.js";
|
|
5
|
+
import { OTPForm as L } from "../../forms/OTPForm/index.js";
|
|
6
|
+
import { SwitchSlideTransition as H } from "../../ui/SwitchSlideTransition/index.js";
|
|
7
|
+
import { useEmailForm as M } from "../hooks/useEmailForm.js";
|
|
8
|
+
import { useOTPForm as V } from "../hooks/useOTPForm.js";
|
|
9
|
+
import { SignInCredentials as k } from "../SignInCredentials.js";
|
|
10
|
+
import { useSignInContext as S } from "../SignInProvider.js";
|
|
11
|
+
import "../../CDPReactProvider/index.js";
|
|
12
|
+
const q = ["email", "otp"], z = ({ step: n, onSuccess: s, children: c }) => {
|
|
13
|
+
const l = g(null), h = 6, { state: e } = S(), { signInWithEmail: E } = x(), { verifyEmailOTP: P } = y(), u = n || e.step, i = u === "credentials" ? "email" : "otp", d = g(i), { setEmail: T, submitEmail: f } = M({
|
|
14
|
+
submit: (t) => E({ email: t })
|
|
15
|
+
}), { resendCountdown: O, resetOTP: v, setOTP: I, startResendTimer: b, submitOtp: F } = V({
|
|
16
|
+
passwordLength: h,
|
|
17
|
+
submit: (t) => P({ flowId: e.flowId, otp: t })
|
|
18
|
+
}), p = () => {
|
|
19
|
+
b(60);
|
|
20
|
+
}, R = () => {
|
|
21
|
+
v(), f({ email: e.email, onSuccess: p });
|
|
22
|
+
}, w = (t) => {
|
|
23
|
+
t.preventDefault(), f({ email: e.email, onSuccess: p });
|
|
24
|
+
}, W = (t) => {
|
|
25
|
+
t.preventDefault(), F({ otp: e.otp, onSuccess: s });
|
|
26
|
+
};
|
|
27
|
+
return D(() => {
|
|
28
|
+
d.current !== i && (l.current?.transition.toggle(i), d.current = i);
|
|
29
|
+
}, [i]), /* @__PURE__ */ o(
|
|
30
|
+
H,
|
|
31
|
+
{
|
|
32
|
+
autoFocus: !0,
|
|
33
|
+
animateHeight: !1,
|
|
34
|
+
items: q,
|
|
35
|
+
initialEntered: !0,
|
|
36
|
+
direction: i === "otp" ? "left" : "right",
|
|
37
|
+
transitionRef: l,
|
|
38
|
+
children: ({ itemKey: t, ...C }) => {
|
|
39
|
+
let r = null;
|
|
40
|
+
return t === "email" && (r = /* @__PURE__ */ o(
|
|
41
|
+
j,
|
|
42
|
+
{
|
|
43
|
+
email: e.email,
|
|
44
|
+
error: i === "email" && e.error || "",
|
|
45
|
+
isPending: e.isPending,
|
|
46
|
+
onEmailChange: T,
|
|
47
|
+
onSubmit: w
|
|
48
|
+
}
|
|
49
|
+
)), t === "otp" && (r = /* @__PURE__ */ o(
|
|
50
|
+
L,
|
|
51
|
+
{
|
|
52
|
+
canResetOTP: e.canResetOTP,
|
|
53
|
+
error: i === "otp" && e.error || "",
|
|
54
|
+
isPending: e.isPending,
|
|
55
|
+
onOTPChange: I,
|
|
56
|
+
onResendOTP: R,
|
|
57
|
+
onSubmit: W,
|
|
58
|
+
otp: e.otp,
|
|
59
|
+
resendCountdown: O,
|
|
60
|
+
successMessage: e.isSuccess ? "Success!" : void 0
|
|
61
|
+
}
|
|
62
|
+
)), /* @__PURE__ */ o("div", { ...C, children: c ? c({ step: u, Form: r }) : r });
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
);
|
|
66
|
+
}, A = ({ step: n }) => /* @__PURE__ */ m(a, { children: [
|
|
67
|
+
n === "credentials" && "Sign in",
|
|
68
|
+
n === "verification" && "Enter verification code"
|
|
69
|
+
] }), B = ({ step: n }) => {
|
|
70
|
+
const { state: s } = S();
|
|
71
|
+
return /* @__PURE__ */ m(a, { children: [
|
|
72
|
+
n === "credentials" && "We’ll send you a verification code via email.",
|
|
73
|
+
n === "verification" && /* @__PURE__ */ m(a, { children: [
|
|
74
|
+
"Enter the 6 digit code sent to ",
|
|
75
|
+
/* @__PURE__ */ o(k, { children: s.email })
|
|
76
|
+
] })
|
|
77
|
+
] });
|
|
78
|
+
}, ee = {
|
|
79
|
+
description: B,
|
|
80
|
+
forms: z,
|
|
81
|
+
title: A
|
|
82
|
+
};
|
|
83
|
+
export {
|
|
84
|
+
z as SignInWithEmail,
|
|
85
|
+
B as SignInWithEmailDescription,
|
|
86
|
+
A as SignInWithEmailTitle,
|
|
87
|
+
ee as config
|
|
88
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { SignInFlowProps, SignInTitleAndDescriptionProps, SignInFlowConfig } from '../types';
|
|
2
|
+
declare const STEPS: readonly ["phoneNumber", "otp"];
|
|
3
|
+
export type Step = (typeof STEPS)[number];
|
|
4
|
+
export declare const SignInWithSms: ({ step: stepFromProps, onSuccess, children }: SignInFlowProps) => import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
export declare const SignInWithSmsTitle: ({ step }: SignInTitleAndDescriptionProps) => import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export declare const SignInWithSmsDescription: ({ step }: SignInTitleAndDescriptionProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export declare const config: SignInFlowConfig;
|
|
8
|
+
export {};
|