@wordrhyme/shadcn-auth 1.0.60 → 2.0.2
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/README.md +154 -1
- package/dist/components/AuthCard.cjs +45 -0
- package/dist/components/AuthCard.d.cts +30 -0
- package/dist/components/AuthCard.d.ts +30 -0
- package/dist/components/AuthCard.js +42 -0
- package/dist/components/AuthForms.cjs +115 -0
- package/dist/components/AuthForms.d.cts +95 -0
- package/dist/components/AuthForms.d.ts +95 -0
- package/dist/components/AuthForms.js +112 -0
- package/dist/components/CompleteProfileForm.cjs +38 -0
- package/dist/components/CompleteProfileForm.d.cts +32 -0
- package/dist/components/CompleteProfileForm.d.ts +32 -0
- package/dist/components/CompleteProfileForm.js +36 -0
- package/dist/components/EmailOtpForm.cjs +181 -0
- package/dist/components/EmailOtpForm.d.cts +56 -0
- package/dist/components/EmailOtpForm.d.ts +56 -0
- package/dist/components/EmailOtpForm.js +176 -0
- package/dist/components/LegalNotice.cjs +37 -0
- package/dist/components/LegalNotice.d.cts +26 -0
- package/dist/components/LegalNotice.d.ts +26 -0
- package/dist/components/LegalNotice.js +35 -0
- package/dist/components/MagicLinkForm.cjs +119 -0
- package/dist/components/MagicLinkForm.d.cts +46 -0
- package/dist/components/MagicLinkForm.d.ts +46 -0
- package/dist/components/MagicLinkForm.js +115 -0
- package/dist/components/ProviderSignInButtons.cjs +65 -0
- package/dist/components/ProviderSignInButtons.d.cts +41 -0
- package/dist/components/ProviderSignInButtons.d.ts +41 -0
- package/dist/components/ProviderSignInButtons.js +62 -0
- package/dist/components/ResetPasswordForm.cjs +89 -0
- package/dist/components/ResetPasswordForm.d.cts +20 -0
- package/dist/components/ResetPasswordForm.d.ts +20 -0
- package/dist/components/ResetPasswordForm.js +85 -0
- package/dist/components/SignInForm.cjs +97 -0
- package/dist/components/SignInForm.d.cts +41 -0
- package/dist/components/SignInForm.d.ts +41 -0
- package/dist/components/SignInForm.js +93 -0
- package/dist/components/SignUpForm.cjs +123 -0
- package/dist/components/SignUpForm.d.cts +40 -0
- package/dist/components/SignUpForm.d.ts +40 -0
- package/dist/components/SignUpForm.js +119 -0
- package/dist/components/auth-pending/AuthButton.cjs +37 -0
- package/dist/components/auth-pending/AuthButton.d.cts +36 -0
- package/dist/components/auth-pending/AuthButton.d.ts +36 -0
- package/dist/components/auth-pending/AuthButton.js +34 -0
- package/dist/components/auth-pending/AuthPendingProvider.cjs +19 -0
- package/dist/components/auth-pending/AuthPendingProvider.d.cts +17 -0
- package/dist/components/auth-pending/AuthPendingProvider.d.ts +17 -0
- package/dist/components/auth-pending/AuthPendingProvider.js +17 -0
- package/dist/components/auth-pending/auth-pending-context.cjs +57 -0
- package/dist/components/auth-pending/auth-pending-context.d.cts +39 -0
- package/dist/components/auth-pending/auth-pending-context.d.ts +39 -0
- package/dist/components/auth-pending/auth-pending-context.js +52 -0
- package/dist/components/auth-pending/index.d.cts +3 -0
- package/dist/components/auth-pending/index.d.ts +3 -0
- package/dist/components/forms/AuthField.cjs +43 -0
- package/dist/components/forms/AuthField.d.cts +26 -0
- package/dist/components/forms/AuthField.d.ts +26 -0
- package/dist/components/forms/AuthField.js +40 -0
- package/dist/components/forms/CompleteProfileFields.cjs +63 -0
- package/dist/components/forms/CompleteProfileFields.d.cts +18 -0
- package/dist/components/forms/CompleteProfileFields.d.ts +18 -0
- package/dist/components/forms/CompleteProfileFields.js +60 -0
- package/dist/components/forms/EmailOtpCodeForm.cjs +78 -0
- package/dist/components/forms/EmailOtpCodeForm.d.cts +18 -0
- package/dist/components/forms/EmailOtpCodeForm.d.ts +18 -0
- package/dist/components/forms/EmailOtpCodeForm.js +75 -0
- package/dist/components/forms/EmailRequestForm.cjs +82 -0
- package/dist/components/forms/EmailRequestForm.d.cts +38 -0
- package/dist/components/forms/EmailRequestForm.d.ts +38 -0
- package/dist/components/forms/EmailRequestForm.js +79 -0
- package/dist/components/forms/SignInCredentialsForm.cjs +79 -0
- package/dist/components/forms/SignInCredentialsForm.d.cts +18 -0
- package/dist/components/forms/SignInCredentialsForm.d.ts +18 -0
- package/dist/components/forms/SignInCredentialsForm.js +76 -0
- package/dist/components/forms/SignUpCredentialsForm.cjs +130 -0
- package/dist/components/forms/SignUpCredentialsForm.d.cts +24 -0
- package/dist/components/forms/SignUpCredentialsForm.d.ts +24 -0
- package/dist/components/forms/SignUpCredentialsForm.js +126 -0
- package/dist/components/index.d.cts +25 -0
- package/dist/components/index.d.ts +25 -0
- package/dist/components/provider-icon/ProviderIcon.cjs +82 -0
- package/dist/components/provider-icon/ProviderIcon.d.cts +21 -0
- package/dist/components/provider-icon/ProviderIcon.d.ts +21 -0
- package/dist/components/provider-icon/ProviderIcon.js +79 -0
- package/dist/components/sign-in-methods/SignInMethodRow.cjs +55 -0
- package/dist/components/sign-in-methods/SignInMethodRow.d.cts +31 -0
- package/dist/components/sign-in-methods/SignInMethodRow.d.ts +31 -0
- package/dist/components/sign-in-methods/SignInMethodRow.js +50 -0
- package/dist/components/sign-in-methods/SignInMethods.cjs +45 -0
- package/dist/components/sign-in-methods/SignInMethods.d.cts +26 -0
- package/dist/components/sign-in-methods/SignInMethods.d.ts +26 -0
- package/dist/components/sign-in-methods/SignInMethods.js +43 -0
- package/dist/components/sign-in-methods/SignInMethodsList.cjs +69 -0
- package/dist/components/sign-in-methods/SignInMethodsList.d.cts +47 -0
- package/dist/components/sign-in-methods/SignInMethodsList.d.ts +47 -0
- package/dist/components/sign-in-methods/SignInMethodsList.js +65 -0
- package/dist/components/sign-in-methods/sign-in-methods-copy.cjs +13 -0
- package/dist/components/sign-in-methods/sign-in-methods-copy.d.cts +11 -0
- package/dist/components/sign-in-methods/sign-in-methods-copy.d.ts +11 -0
- package/dist/components/sign-in-methods/sign-in-methods-copy.js +12 -0
- package/dist/constants/auth-providers.cjs +33 -0
- package/dist/constants/auth-providers.d.cts +14 -0
- package/dist/constants/auth-providers.d.ts +14 -0
- package/dist/constants/auth-providers.js +31 -0
- package/dist/constants/validation.cjs +21 -0
- package/dist/constants/validation.d.cts +17 -0
- package/dist/constants/validation.d.ts +17 -0
- package/dist/constants/validation.js +18 -0
- package/dist/hooks/use-pending-action.cjs +37 -0
- package/dist/hooks/use-pending-action.d.cts +26 -0
- package/dist/hooks/use-pending-action.d.ts +26 -0
- package/dist/hooks/use-pending-action.js +35 -0
- package/dist/hooks/use-reset-on-page-restore.cjs +35 -0
- package/dist/hooks/use-reset-on-page-restore.d.cts +15 -0
- package/dist/hooks/use-reset-on-page-restore.d.ts +15 -0
- package/dist/hooks/use-reset-on-page-restore.js +33 -0
- package/dist/index.cjs +67 -7
- package/dist/index.d.cts +34 -6
- package/dist/index.d.ts +34 -6
- package/dist/index.js +33 -6
- package/dist/utils/build-sign-in-method-rows.cjs +25 -0
- package/dist/utils/build-sign-in-method-rows.d.cts +26 -0
- package/dist/utils/build-sign-in-method-rows.d.ts +26 -0
- package/dist/utils/build-sign-in-method-rows.js +24 -0
- package/dist/utils/until-navigation.cjs +22 -0
- package/dist/utils/until-navigation.d.cts +18 -0
- package/dist/utils/until-navigation.d.ts +18 -0
- package/dist/utils/until-navigation.js +21 -0
- package/dist/utils/validate-email.cjs +22 -0
- package/dist/utils/validate-email.d.cts +14 -0
- package/dist/utils/validate-email.d.ts +14 -0
- package/dist/utils/validate-email.js +21 -0
- package/dist/utils/validate-password.cjs +16 -0
- package/dist/utils/validate-password.d.cts +9 -0
- package/dist/utils/validate-password.d.ts +9 -0
- package/dist/utils/validate-password.js +16 -0
- package/package.json +16 -9
- package/dist/AuthForms.cjs +0 -47
- package/dist/AuthForms.d.cts +0 -23
- package/dist/AuthForms.d.ts +0 -23
- package/dist/AuthForms.js +0 -44
- package/dist/GoogleSignIn.cjs +0 -46
- package/dist/GoogleSignIn.d.cts +0 -10
- package/dist/GoogleSignIn.d.ts +0 -10
- package/dist/GoogleSignIn.js +0 -42
- package/dist/ResetPasswordForm.cjs +0 -106
- package/dist/ResetPasswordForm.d.cts +0 -17
- package/dist/ResetPasswordForm.d.ts +0 -17
- package/dist/ResetPasswordForm.js +0 -100
- package/dist/SignInForm.cjs +0 -164
- package/dist/SignInForm.d.cts +0 -21
- package/dist/SignInForm.d.ts +0 -21
- package/dist/SignInForm.js +0 -159
- package/dist/SignUpForm.cjs +0 -154
- package/dist/SignUpForm.d.cts +0 -19
- package/dist/SignUpForm.d.ts +0 -19
- package/dist/SignUpForm.js +0 -149
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
import { useAuthPendingState } from "./auth-pending/auth-pending-context.js";
|
|
5
|
+
import { AuthButton } from "./auth-pending/AuthButton.js";
|
|
6
|
+
import { AuthPendingProvider } from "./auth-pending/AuthPendingProvider.js";
|
|
7
|
+
import { AuthCard } from "./AuthCard.js";
|
|
8
|
+
import { OTP_LENGTH } from "../constants/validation.js";
|
|
9
|
+
import { EmailOtpCodeForm } from "./forms/EmailOtpCodeForm.js";
|
|
10
|
+
import { EmailRequestForm } from "./forms/EmailRequestForm.js";
|
|
11
|
+
import { ProviderSignInButtons } from "./ProviderSignInButtons.js";
|
|
12
|
+
import { useEffect, useState } from "react";
|
|
13
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
14
|
+
import { Separator } from "@wordrhyme/shadcn";
|
|
15
|
+
import { MailCheck } from "lucide-react";
|
|
16
|
+
|
|
17
|
+
//#region src/components/EmailOtpForm.tsx
|
|
18
|
+
/**
|
|
19
|
+
* Seconds before "Send a new code" becomes available again. Shorter than the
|
|
20
|
+
* code's own lifetime on purpose — this exists to stop a double-click emailing
|
|
21
|
+
* two codes (the second silently invalidating the first), not to ration them.
|
|
22
|
+
*/
|
|
23
|
+
const RESEND_COOLDOWN_SECONDS = 60;
|
|
24
|
+
/** How long the emailed code lasts, for the copy only. Supabase enforces it. */
|
|
25
|
+
const DEFAULT_EXPIRY_MINUTES = 60;
|
|
26
|
+
const MS_PER_SECOND = 1e3;
|
|
27
|
+
/** Key for the "send a new code" button, so only it spins while resending. */
|
|
28
|
+
const RESEND_ACTION = "resend";
|
|
29
|
+
/**
|
|
30
|
+
* The second step: the code itself.
|
|
31
|
+
*
|
|
32
|
+
* Its own component so the parent can mount it under `key={sentTo}` — a new
|
|
33
|
+
* address, or a resent code, then starts with an empty field and a fresh
|
|
34
|
+
* cooldown without an effect reaching in to reset either.
|
|
35
|
+
*/
|
|
36
|
+
function CodeEntryStep({ sentTo, onVerifyEmailOtp, onResend, error, expiryMinutes, onUseDifferentEmail, onSwitchToSignIn }) {
|
|
37
|
+
const [resendIn, setResendIn] = useState(RESEND_COOLDOWN_SECONDS);
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
if (resendIn <= 0) return;
|
|
40
|
+
const timer = setTimeout(() => setResendIn((seconds) => seconds - 1), MS_PER_SECOND);
|
|
41
|
+
return () => clearTimeout(timer);
|
|
42
|
+
}, [resendIn]);
|
|
43
|
+
return /* @__PURE__ */ jsxs(AuthCard, {
|
|
44
|
+
title: "Enter your code",
|
|
45
|
+
error,
|
|
46
|
+
children: [
|
|
47
|
+
/* @__PURE__ */ jsxs("div", {
|
|
48
|
+
className: "mb-4 flex flex-col items-center gap-3 text-center",
|
|
49
|
+
children: [/* @__PURE__ */ jsx(MailCheck, {
|
|
50
|
+
className: "text-primary h-10 w-10",
|
|
51
|
+
"aria-hidden": "true"
|
|
52
|
+
}), /* @__PURE__ */ jsxs("p", {
|
|
53
|
+
className: "text-sm",
|
|
54
|
+
children: [
|
|
55
|
+
"We sent a ",
|
|
56
|
+
OTP_LENGTH,
|
|
57
|
+
"-digit code to",
|
|
58
|
+
" ",
|
|
59
|
+
/* @__PURE__ */ jsx("span", {
|
|
60
|
+
className: "font-medium",
|
|
61
|
+
children: sentTo
|
|
62
|
+
}),
|
|
63
|
+
"."
|
|
64
|
+
]
|
|
65
|
+
})]
|
|
66
|
+
}),
|
|
67
|
+
/* @__PURE__ */ jsx(EmailOtpCodeForm, {
|
|
68
|
+
sentTo,
|
|
69
|
+
onVerifyEmailOtp,
|
|
70
|
+
expiryMinutes
|
|
71
|
+
}),
|
|
72
|
+
/* @__PURE__ */ jsx(Separator, { className: "my-4" }),
|
|
73
|
+
/* @__PURE__ */ jsxs("div", {
|
|
74
|
+
className: "space-y-2 text-center text-sm",
|
|
75
|
+
children: [
|
|
76
|
+
/* @__PURE__ */ jsx("p", { children: /* @__PURE__ */ jsx(AuthButton, {
|
|
77
|
+
variant: "link",
|
|
78
|
+
size: "sm",
|
|
79
|
+
actionKey: RESEND_ACTION,
|
|
80
|
+
onAction: async () => onResend(sentTo),
|
|
81
|
+
disabled: resendIn > 0,
|
|
82
|
+
className: "h-auto p-0",
|
|
83
|
+
children: resendIn > 0 ? `Send a new code in ${resendIn}s` : "Send a new code"
|
|
84
|
+
}) }),
|
|
85
|
+
onUseDifferentEmail && /* @__PURE__ */ jsx("p", { children: /* @__PURE__ */ jsx(AuthButton, {
|
|
86
|
+
variant: "link",
|
|
87
|
+
size: "sm",
|
|
88
|
+
onClick: onUseDifferentEmail,
|
|
89
|
+
className: "h-auto p-0",
|
|
90
|
+
children: "Use a different email"
|
|
91
|
+
}) }),
|
|
92
|
+
onSwitchToSignIn && /* @__PURE__ */ jsx("p", { children: /* @__PURE__ */ jsx(AuthButton, {
|
|
93
|
+
variant: "link",
|
|
94
|
+
size: "sm",
|
|
95
|
+
onClick: onSwitchToSignIn,
|
|
96
|
+
className: "h-auto p-0",
|
|
97
|
+
children: "Back to sign in"
|
|
98
|
+
}) })
|
|
99
|
+
]
|
|
100
|
+
})
|
|
101
|
+
]
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Passwordless sign-in with a code typed back into this page.
|
|
106
|
+
*
|
|
107
|
+
* Two steps in one component, because they are one flow: collect an address,
|
|
108
|
+
* then collect the code that address received. Keeping both here is what lets
|
|
109
|
+
* "use a different email" and "send a new code" stay a single decision the
|
|
110
|
+
* user makes in one place.
|
|
111
|
+
*
|
|
112
|
+
* Doubles as sign-up — an unknown address gets an account — so it carries the
|
|
113
|
+
* same Terms line the password sign-up form does.
|
|
114
|
+
*/
|
|
115
|
+
function EmailOtpForm({ onSendEmailOtp, onVerifyEmailOtp, onGoogleSignIn, onLinkedInSignIn, isLoading, error, sentTo, onUseDifferentEmail, onSwitchToSignIn, expiryMinutes = DEFAULT_EXPIRY_MINUTES, privacyPolicyUrl = "/privacy", privacyNotice, termsUrl = "/terms" }) {
|
|
116
|
+
/**
|
|
117
|
+
* Bumped on every resend. Part of the code step's `key`, so a fresh code
|
|
118
|
+
* gets a fresh field and cooldown even though `sentTo` has not changed.
|
|
119
|
+
*/
|
|
120
|
+
const [resendCount, setResendCount] = useState(0);
|
|
121
|
+
const pending = useAuthPendingState(isLoading);
|
|
122
|
+
const handleResend = async (address) => {
|
|
123
|
+
setResendCount((count) => count + 1);
|
|
124
|
+
return onSendEmailOtp(address);
|
|
125
|
+
};
|
|
126
|
+
if (sentTo != null && sentTo.length > 0) return /* @__PURE__ */ jsx(AuthPendingProvider, {
|
|
127
|
+
value: pending,
|
|
128
|
+
children: /* @__PURE__ */ jsx(CodeEntryStep, {
|
|
129
|
+
sentTo,
|
|
130
|
+
onVerifyEmailOtp,
|
|
131
|
+
onResend: handleResend,
|
|
132
|
+
error,
|
|
133
|
+
expiryMinutes,
|
|
134
|
+
onUseDifferentEmail,
|
|
135
|
+
onSwitchToSignIn
|
|
136
|
+
}, `${sentTo}:${resendCount}`)
|
|
137
|
+
});
|
|
138
|
+
return /* @__PURE__ */ jsx(AuthPendingProvider, {
|
|
139
|
+
value: pending,
|
|
140
|
+
children: /* @__PURE__ */ jsxs(AuthCard, {
|
|
141
|
+
title: "Sign in with email",
|
|
142
|
+
description: "No password needed — we'll email you a single-use code.",
|
|
143
|
+
error,
|
|
144
|
+
children: [
|
|
145
|
+
/* @__PURE__ */ jsx(EmailRequestForm, {
|
|
146
|
+
fieldId: "email-otp-email",
|
|
147
|
+
onSubmitEmail: onSendEmailOtp,
|
|
148
|
+
submitLabel: "Email me a sign-in code",
|
|
149
|
+
submittingLabel: "Sending code...",
|
|
150
|
+
termsUrl,
|
|
151
|
+
privacyPolicyUrl,
|
|
152
|
+
privacyNotice
|
|
153
|
+
}),
|
|
154
|
+
/* @__PURE__ */ jsx(ProviderSignInButtons, {
|
|
155
|
+
onGoogleSignIn,
|
|
156
|
+
onLinkedInSignIn,
|
|
157
|
+
action: "Sign in"
|
|
158
|
+
}),
|
|
159
|
+
/* @__PURE__ */ jsx("div", { className: "my-4" }),
|
|
160
|
+
/* @__PURE__ */ jsx("div", {
|
|
161
|
+
className: "text-center text-sm",
|
|
162
|
+
children: onSwitchToSignIn && /* @__PURE__ */ jsx("p", { children: /* @__PURE__ */ jsx(AuthButton, {
|
|
163
|
+
variant: "link",
|
|
164
|
+
size: "sm",
|
|
165
|
+
onClick: onSwitchToSignIn,
|
|
166
|
+
className: "h-auto p-0",
|
|
167
|
+
children: "Sign in with a password instead"
|
|
168
|
+
}) })
|
|
169
|
+
})
|
|
170
|
+
]
|
|
171
|
+
})
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
//#endregion
|
|
176
|
+
export { EmailOtpForm };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
5
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
6
|
+
react_jsx_runtime = require_rolldown_runtime.__toESM(react_jsx_runtime);
|
|
7
|
+
|
|
8
|
+
//#region src/components/LegalNotice.tsx
|
|
9
|
+
/**
|
|
10
|
+
* The privacy notice shown wherever an account can be created.
|
|
11
|
+
*
|
|
12
|
+
* It is a notice, not a consent: the processing it describes is what delivering
|
|
13
|
+
* the service requires, so presenting it as an opt-in would misstate the legal
|
|
14
|
+
* basis. It lives in its own component because the sign-up form and the
|
|
15
|
+
* passwordless form both create accounts and must say the same thing.
|
|
16
|
+
*/
|
|
17
|
+
function LegalNotice({ privacyPolicyUrl = "/privacy", notice, id }) {
|
|
18
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
19
|
+
id,
|
|
20
|
+
className: "text-muted-foreground text-xs",
|
|
21
|
+
children: notice ?? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
22
|
+
"We process your data to provide the service, as described in our",
|
|
23
|
+
" ",
|
|
24
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
|
|
25
|
+
href: privacyPolicyUrl,
|
|
26
|
+
target: "_blank",
|
|
27
|
+
rel: "noopener noreferrer",
|
|
28
|
+
className: "text-primary underline",
|
|
29
|
+
children: "Privacy Policy"
|
|
30
|
+
}),
|
|
31
|
+
". We do not send marketing email and do not use tracking or advertising cookies."
|
|
32
|
+
] })
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
//#endregion
|
|
37
|
+
exports.LegalNotice = LegalNotice;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import * as react_jsx_runtime10 from "react/jsx-runtime";
|
|
3
|
+
|
|
4
|
+
//#region src/components/LegalNotice.d.ts
|
|
5
|
+
interface LegalNoticeProps {
|
|
6
|
+
privacyPolicyUrl?: string;
|
|
7
|
+
/** Host-provided notice content, including its own link when needed. */
|
|
8
|
+
notice?: React.ReactNode;
|
|
9
|
+
/** Set when a control references this notice via `aria-describedby`. */
|
|
10
|
+
id?: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* The privacy notice shown wherever an account can be created.
|
|
14
|
+
*
|
|
15
|
+
* It is a notice, not a consent: the processing it describes is what delivering
|
|
16
|
+
* the service requires, so presenting it as an opt-in would misstate the legal
|
|
17
|
+
* basis. It lives in its own component because the sign-up form and the
|
|
18
|
+
* passwordless form both create accounts and must say the same thing.
|
|
19
|
+
*/
|
|
20
|
+
declare function LegalNotice({
|
|
21
|
+
privacyPolicyUrl,
|
|
22
|
+
notice,
|
|
23
|
+
id
|
|
24
|
+
}: LegalNoticeProps): react_jsx_runtime10.JSX.Element;
|
|
25
|
+
//#endregion
|
|
26
|
+
export { LegalNotice, LegalNoticeProps };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import * as react_jsx_runtime10 from "react/jsx-runtime";
|
|
3
|
+
|
|
4
|
+
//#region src/components/LegalNotice.d.ts
|
|
5
|
+
interface LegalNoticeProps {
|
|
6
|
+
privacyPolicyUrl?: string;
|
|
7
|
+
/** Host-provided notice content, including its own link when needed. */
|
|
8
|
+
notice?: React.ReactNode;
|
|
9
|
+
/** Set when a control references this notice via `aria-describedby`. */
|
|
10
|
+
id?: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* The privacy notice shown wherever an account can be created.
|
|
14
|
+
*
|
|
15
|
+
* It is a notice, not a consent: the processing it describes is what delivering
|
|
16
|
+
* the service requires, so presenting it as an opt-in would misstate the legal
|
|
17
|
+
* basis. It lives in its own component because the sign-up form and the
|
|
18
|
+
* passwordless form both create accounts and must say the same thing.
|
|
19
|
+
*/
|
|
20
|
+
declare function LegalNotice({
|
|
21
|
+
privacyPolicyUrl,
|
|
22
|
+
notice,
|
|
23
|
+
id
|
|
24
|
+
}: LegalNoticeProps): react_jsx_runtime10.JSX.Element;
|
|
25
|
+
//#endregion
|
|
26
|
+
export { LegalNotice, LegalNoticeProps };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
|
|
6
|
+
//#region src/components/LegalNotice.tsx
|
|
7
|
+
/**
|
|
8
|
+
* The privacy notice shown wherever an account can be created.
|
|
9
|
+
*
|
|
10
|
+
* It is a notice, not a consent: the processing it describes is what delivering
|
|
11
|
+
* the service requires, so presenting it as an opt-in would misstate the legal
|
|
12
|
+
* basis. It lives in its own component because the sign-up form and the
|
|
13
|
+
* passwordless form both create accounts and must say the same thing.
|
|
14
|
+
*/
|
|
15
|
+
function LegalNotice({ privacyPolicyUrl = "/privacy", notice, id }) {
|
|
16
|
+
return /* @__PURE__ */ jsx("p", {
|
|
17
|
+
id,
|
|
18
|
+
className: "text-muted-foreground text-xs",
|
|
19
|
+
children: notice ?? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
20
|
+
"We process your data to provide the service, as described in our",
|
|
21
|
+
" ",
|
|
22
|
+
/* @__PURE__ */ jsx("a", {
|
|
23
|
+
href: privacyPolicyUrl,
|
|
24
|
+
target: "_blank",
|
|
25
|
+
rel: "noopener noreferrer",
|
|
26
|
+
className: "text-primary underline",
|
|
27
|
+
children: "Privacy Policy"
|
|
28
|
+
}),
|
|
29
|
+
". We do not send marketing email and do not use tracking or advertising cookies."
|
|
30
|
+
] })
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
//#endregion
|
|
35
|
+
export { LegalNotice };
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
5
|
+
const require_auth_pending_context = require('./auth-pending/auth-pending-context.cjs');
|
|
6
|
+
const require_AuthButton = require('./auth-pending/AuthButton.cjs');
|
|
7
|
+
const require_AuthPendingProvider = require('./auth-pending/AuthPendingProvider.cjs');
|
|
8
|
+
const require_AuthCard = require('./AuthCard.cjs');
|
|
9
|
+
const require_EmailRequestForm = require('./forms/EmailRequestForm.cjs');
|
|
10
|
+
const require_ProviderSignInButtons = require('./ProviderSignInButtons.cjs');
|
|
11
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
12
|
+
react_jsx_runtime = require_rolldown_runtime.__toESM(react_jsx_runtime);
|
|
13
|
+
let __wordrhyme_shadcn = require("@wordrhyme/shadcn");
|
|
14
|
+
__wordrhyme_shadcn = require_rolldown_runtime.__toESM(__wordrhyme_shadcn);
|
|
15
|
+
let lucide_react = require("lucide-react");
|
|
16
|
+
lucide_react = require_rolldown_runtime.__toESM(lucide_react);
|
|
17
|
+
|
|
18
|
+
//#region src/components/MagicLinkForm.tsx
|
|
19
|
+
/**
|
|
20
|
+
* Passwordless sign-in: type an address, receive a single-use link.
|
|
21
|
+
*
|
|
22
|
+
* Doubles as sign-up — an unknown address gets an account — so it carries the
|
|
23
|
+
* same Terms line the password sign-up form does. There is no separate
|
|
24
|
+
* confirmation step to hang a checkbox on, so acceptance is stated inline
|
|
25
|
+
* against the button that performs it.
|
|
26
|
+
*/
|
|
27
|
+
function MagicLinkForm({ onSendMagicLink, onGoogleSignIn, onLinkedInSignIn, isLoading, error, sentTo, onUseDifferentEmail, onSwitchToSignIn, privacyPolicyUrl = "/privacy", privacyNotice, termsUrl = "/terms" }) {
|
|
28
|
+
const pending = require_auth_pending_context.useAuthPendingState(isLoading);
|
|
29
|
+
if (sentTo != null && sentTo.length > 0) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_AuthPendingProvider.AuthPendingProvider, {
|
|
30
|
+
value: pending,
|
|
31
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_AuthCard.AuthCard, {
|
|
32
|
+
title: "Check your email",
|
|
33
|
+
error,
|
|
34
|
+
children: [
|
|
35
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
36
|
+
className: "flex flex-col items-center gap-4 text-center",
|
|
37
|
+
children: [
|
|
38
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.MailCheck, {
|
|
39
|
+
className: "text-primary h-12 w-12",
|
|
40
|
+
"aria-hidden": "true"
|
|
41
|
+
}),
|
|
42
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
|
|
43
|
+
className: "text-sm",
|
|
44
|
+
children: [
|
|
45
|
+
"We sent a sign-in link to ",
|
|
46
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
47
|
+
className: "font-medium",
|
|
48
|
+
children: sentTo
|
|
49
|
+
}),
|
|
50
|
+
". Open it in this browser to finish signing in."
|
|
51
|
+
]
|
|
52
|
+
}),
|
|
53
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
54
|
+
className: "text-muted-foreground text-xs",
|
|
55
|
+
children: "The link works once and expires shortly. Check your spam folder if it does not arrive."
|
|
56
|
+
})
|
|
57
|
+
]
|
|
58
|
+
}),
|
|
59
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__wordrhyme_shadcn.Separator, { className: "my-4" }),
|
|
60
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
61
|
+
className: "space-y-2 text-center text-sm",
|
|
62
|
+
children: [onUseDifferentEmail && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_AuthButton.AuthButton, {
|
|
63
|
+
variant: "link",
|
|
64
|
+
size: "sm",
|
|
65
|
+
onClick: onUseDifferentEmail,
|
|
66
|
+
className: "h-auto p-0",
|
|
67
|
+
children: "Use a different email"
|
|
68
|
+
}) }), onSwitchToSignIn && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_AuthButton.AuthButton, {
|
|
69
|
+
variant: "link",
|
|
70
|
+
size: "sm",
|
|
71
|
+
onClick: onSwitchToSignIn,
|
|
72
|
+
className: "h-auto p-0",
|
|
73
|
+
children: "Back to sign in"
|
|
74
|
+
}) })]
|
|
75
|
+
})
|
|
76
|
+
]
|
|
77
|
+
})
|
|
78
|
+
});
|
|
79
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_AuthPendingProvider.AuthPendingProvider, {
|
|
80
|
+
value: pending,
|
|
81
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_AuthCard.AuthCard, {
|
|
82
|
+
title: "Sign in with email",
|
|
83
|
+
description: "No password needed — we'll email you a single-use link.",
|
|
84
|
+
error,
|
|
85
|
+
children: [
|
|
86
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
87
|
+
className: "space-y-3",
|
|
88
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_EmailRequestForm.EmailRequestForm, {
|
|
89
|
+
fieldId: "magic-link-email",
|
|
90
|
+
onSubmitEmail: onSendMagicLink,
|
|
91
|
+
submitLabel: "Email me a sign-in link",
|
|
92
|
+
submittingLabel: "Sending link...",
|
|
93
|
+
termsUrl,
|
|
94
|
+
privacyPolicyUrl,
|
|
95
|
+
privacyNotice
|
|
96
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ProviderSignInButtons.ProviderSignInButtons, {
|
|
97
|
+
onGoogleSignIn,
|
|
98
|
+
onLinkedInSignIn,
|
|
99
|
+
action: "Sign in"
|
|
100
|
+
})]
|
|
101
|
+
}),
|
|
102
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__wordrhyme_shadcn.Separator, { className: "my-4" }),
|
|
103
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
104
|
+
className: "text-center text-sm",
|
|
105
|
+
children: onSwitchToSignIn && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_AuthButton.AuthButton, {
|
|
106
|
+
variant: "link",
|
|
107
|
+
size: "sm",
|
|
108
|
+
onClick: onSwitchToSignIn,
|
|
109
|
+
className: "h-auto p-0",
|
|
110
|
+
children: "Sign in with a password instead"
|
|
111
|
+
}) })
|
|
112
|
+
})
|
|
113
|
+
]
|
|
114
|
+
})
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
//#endregion
|
|
119
|
+
exports.MagicLinkForm = MagicLinkForm;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { ProviderSignInHandlers } from "./ProviderSignInButtons.cjs";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import * as react_jsx_runtime11 from "react/jsx-runtime";
|
|
4
|
+
|
|
5
|
+
//#region src/components/MagicLinkForm.d.ts
|
|
6
|
+
interface MagicLinkFormProps extends ProviderSignInHandlers {
|
|
7
|
+
onSendMagicLink: (email: string) => Promise<void>;
|
|
8
|
+
isLoading: boolean;
|
|
9
|
+
error: string | null;
|
|
10
|
+
/**
|
|
11
|
+
* The address a link was just sent to, or `null` while the form is still
|
|
12
|
+
* collecting one. Controlled by the host: only it knows whether the server
|
|
13
|
+
* action succeeded, since a failed send reports through `error` rather than
|
|
14
|
+
* by rejecting.
|
|
15
|
+
*/
|
|
16
|
+
sentTo?: string | null;
|
|
17
|
+
/** Returns to the collect-an-address state, e.g. after a typo. */
|
|
18
|
+
onUseDifferentEmail?: () => void;
|
|
19
|
+
onSwitchToSignIn?: () => void;
|
|
20
|
+
privacyPolicyUrl?: string;
|
|
21
|
+
privacyNotice?: React.ReactNode;
|
|
22
|
+
termsUrl?: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Passwordless sign-in: type an address, receive a single-use link.
|
|
26
|
+
*
|
|
27
|
+
* Doubles as sign-up — an unknown address gets an account — so it carries the
|
|
28
|
+
* same Terms line the password sign-up form does. There is no separate
|
|
29
|
+
* confirmation step to hang a checkbox on, so acceptance is stated inline
|
|
30
|
+
* against the button that performs it.
|
|
31
|
+
*/
|
|
32
|
+
declare function MagicLinkForm({
|
|
33
|
+
onSendMagicLink,
|
|
34
|
+
onGoogleSignIn,
|
|
35
|
+
onLinkedInSignIn,
|
|
36
|
+
isLoading,
|
|
37
|
+
error,
|
|
38
|
+
sentTo,
|
|
39
|
+
onUseDifferentEmail,
|
|
40
|
+
onSwitchToSignIn,
|
|
41
|
+
privacyPolicyUrl,
|
|
42
|
+
privacyNotice,
|
|
43
|
+
termsUrl
|
|
44
|
+
}: MagicLinkFormProps): react_jsx_runtime11.JSX.Element;
|
|
45
|
+
//#endregion
|
|
46
|
+
export { MagicLinkForm, MagicLinkFormProps };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { ProviderSignInHandlers } from "./ProviderSignInButtons.js";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import * as react_jsx_runtime11 from "react/jsx-runtime";
|
|
4
|
+
|
|
5
|
+
//#region src/components/MagicLinkForm.d.ts
|
|
6
|
+
interface MagicLinkFormProps extends ProviderSignInHandlers {
|
|
7
|
+
onSendMagicLink: (email: string) => Promise<void>;
|
|
8
|
+
isLoading: boolean;
|
|
9
|
+
error: string | null;
|
|
10
|
+
/**
|
|
11
|
+
* The address a link was just sent to, or `null` while the form is still
|
|
12
|
+
* collecting one. Controlled by the host: only it knows whether the server
|
|
13
|
+
* action succeeded, since a failed send reports through `error` rather than
|
|
14
|
+
* by rejecting.
|
|
15
|
+
*/
|
|
16
|
+
sentTo?: string | null;
|
|
17
|
+
/** Returns to the collect-an-address state, e.g. after a typo. */
|
|
18
|
+
onUseDifferentEmail?: () => void;
|
|
19
|
+
onSwitchToSignIn?: () => void;
|
|
20
|
+
privacyPolicyUrl?: string;
|
|
21
|
+
privacyNotice?: React.ReactNode;
|
|
22
|
+
termsUrl?: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Passwordless sign-in: type an address, receive a single-use link.
|
|
26
|
+
*
|
|
27
|
+
* Doubles as sign-up — an unknown address gets an account — so it carries the
|
|
28
|
+
* same Terms line the password sign-up form does. There is no separate
|
|
29
|
+
* confirmation step to hang a checkbox on, so acceptance is stated inline
|
|
30
|
+
* against the button that performs it.
|
|
31
|
+
*/
|
|
32
|
+
declare function MagicLinkForm({
|
|
33
|
+
onSendMagicLink,
|
|
34
|
+
onGoogleSignIn,
|
|
35
|
+
onLinkedInSignIn,
|
|
36
|
+
isLoading,
|
|
37
|
+
error,
|
|
38
|
+
sentTo,
|
|
39
|
+
onUseDifferentEmail,
|
|
40
|
+
onSwitchToSignIn,
|
|
41
|
+
privacyPolicyUrl,
|
|
42
|
+
privacyNotice,
|
|
43
|
+
termsUrl
|
|
44
|
+
}: MagicLinkFormProps): react_jsx_runtime11.JSX.Element;
|
|
45
|
+
//#endregion
|
|
46
|
+
export { MagicLinkForm, MagicLinkFormProps };
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
import { useAuthPendingState } from "./auth-pending/auth-pending-context.js";
|
|
5
|
+
import { AuthButton } from "./auth-pending/AuthButton.js";
|
|
6
|
+
import { AuthPendingProvider } from "./auth-pending/AuthPendingProvider.js";
|
|
7
|
+
import { AuthCard } from "./AuthCard.js";
|
|
8
|
+
import { EmailRequestForm } from "./forms/EmailRequestForm.js";
|
|
9
|
+
import { ProviderSignInButtons } from "./ProviderSignInButtons.js";
|
|
10
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
+
import { Separator } from "@wordrhyme/shadcn";
|
|
12
|
+
import { MailCheck } from "lucide-react";
|
|
13
|
+
|
|
14
|
+
//#region src/components/MagicLinkForm.tsx
|
|
15
|
+
/**
|
|
16
|
+
* Passwordless sign-in: type an address, receive a single-use link.
|
|
17
|
+
*
|
|
18
|
+
* Doubles as sign-up — an unknown address gets an account — so it carries the
|
|
19
|
+
* same Terms line the password sign-up form does. There is no separate
|
|
20
|
+
* confirmation step to hang a checkbox on, so acceptance is stated inline
|
|
21
|
+
* against the button that performs it.
|
|
22
|
+
*/
|
|
23
|
+
function MagicLinkForm({ onSendMagicLink, onGoogleSignIn, onLinkedInSignIn, isLoading, error, sentTo, onUseDifferentEmail, onSwitchToSignIn, privacyPolicyUrl = "/privacy", privacyNotice, termsUrl = "/terms" }) {
|
|
24
|
+
const pending = useAuthPendingState(isLoading);
|
|
25
|
+
if (sentTo != null && sentTo.length > 0) return /* @__PURE__ */ jsx(AuthPendingProvider, {
|
|
26
|
+
value: pending,
|
|
27
|
+
children: /* @__PURE__ */ jsxs(AuthCard, {
|
|
28
|
+
title: "Check your email",
|
|
29
|
+
error,
|
|
30
|
+
children: [
|
|
31
|
+
/* @__PURE__ */ jsxs("div", {
|
|
32
|
+
className: "flex flex-col items-center gap-4 text-center",
|
|
33
|
+
children: [
|
|
34
|
+
/* @__PURE__ */ jsx(MailCheck, {
|
|
35
|
+
className: "text-primary h-12 w-12",
|
|
36
|
+
"aria-hidden": "true"
|
|
37
|
+
}),
|
|
38
|
+
/* @__PURE__ */ jsxs("p", {
|
|
39
|
+
className: "text-sm",
|
|
40
|
+
children: [
|
|
41
|
+
"We sent a sign-in link to ",
|
|
42
|
+
/* @__PURE__ */ jsx("span", {
|
|
43
|
+
className: "font-medium",
|
|
44
|
+
children: sentTo
|
|
45
|
+
}),
|
|
46
|
+
". Open it in this browser to finish signing in."
|
|
47
|
+
]
|
|
48
|
+
}),
|
|
49
|
+
/* @__PURE__ */ jsx("p", {
|
|
50
|
+
className: "text-muted-foreground text-xs",
|
|
51
|
+
children: "The link works once and expires shortly. Check your spam folder if it does not arrive."
|
|
52
|
+
})
|
|
53
|
+
]
|
|
54
|
+
}),
|
|
55
|
+
/* @__PURE__ */ jsx(Separator, { className: "my-4" }),
|
|
56
|
+
/* @__PURE__ */ jsxs("div", {
|
|
57
|
+
className: "space-y-2 text-center text-sm",
|
|
58
|
+
children: [onUseDifferentEmail && /* @__PURE__ */ jsx("p", { children: /* @__PURE__ */ jsx(AuthButton, {
|
|
59
|
+
variant: "link",
|
|
60
|
+
size: "sm",
|
|
61
|
+
onClick: onUseDifferentEmail,
|
|
62
|
+
className: "h-auto p-0",
|
|
63
|
+
children: "Use a different email"
|
|
64
|
+
}) }), onSwitchToSignIn && /* @__PURE__ */ jsx("p", { children: /* @__PURE__ */ jsx(AuthButton, {
|
|
65
|
+
variant: "link",
|
|
66
|
+
size: "sm",
|
|
67
|
+
onClick: onSwitchToSignIn,
|
|
68
|
+
className: "h-auto p-0",
|
|
69
|
+
children: "Back to sign in"
|
|
70
|
+
}) })]
|
|
71
|
+
})
|
|
72
|
+
]
|
|
73
|
+
})
|
|
74
|
+
});
|
|
75
|
+
return /* @__PURE__ */ jsx(AuthPendingProvider, {
|
|
76
|
+
value: pending,
|
|
77
|
+
children: /* @__PURE__ */ jsxs(AuthCard, {
|
|
78
|
+
title: "Sign in with email",
|
|
79
|
+
description: "No password needed — we'll email you a single-use link.",
|
|
80
|
+
error,
|
|
81
|
+
children: [
|
|
82
|
+
/* @__PURE__ */ jsxs("div", {
|
|
83
|
+
className: "space-y-3",
|
|
84
|
+
children: [/* @__PURE__ */ jsx(EmailRequestForm, {
|
|
85
|
+
fieldId: "magic-link-email",
|
|
86
|
+
onSubmitEmail: onSendMagicLink,
|
|
87
|
+
submitLabel: "Email me a sign-in link",
|
|
88
|
+
submittingLabel: "Sending link...",
|
|
89
|
+
termsUrl,
|
|
90
|
+
privacyPolicyUrl,
|
|
91
|
+
privacyNotice
|
|
92
|
+
}), /* @__PURE__ */ jsx(ProviderSignInButtons, {
|
|
93
|
+
onGoogleSignIn,
|
|
94
|
+
onLinkedInSignIn,
|
|
95
|
+
action: "Sign in"
|
|
96
|
+
})]
|
|
97
|
+
}),
|
|
98
|
+
/* @__PURE__ */ jsx(Separator, { className: "my-4" }),
|
|
99
|
+
/* @__PURE__ */ jsx("div", {
|
|
100
|
+
className: "text-center text-sm",
|
|
101
|
+
children: onSwitchToSignIn && /* @__PURE__ */ jsx("p", { children: /* @__PURE__ */ jsx(AuthButton, {
|
|
102
|
+
variant: "link",
|
|
103
|
+
size: "sm",
|
|
104
|
+
onClick: onSwitchToSignIn,
|
|
105
|
+
className: "h-auto p-0",
|
|
106
|
+
children: "Sign in with a password instead"
|
|
107
|
+
}) })
|
|
108
|
+
})
|
|
109
|
+
]
|
|
110
|
+
})
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
//#endregion
|
|
115
|
+
export { MagicLinkForm };
|