@frequencyads/auth 0.1.0
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/chunk-JIENWB3K.mjs +89 -0
- package/dist/chunk-NS2JRZGO.mjs +38 -0
- package/dist/chunk-OKP757OV.mjs +131 -0
- package/dist/chunk-OUUVIDG6.mjs +63 -0
- package/dist/chunk-P4OKC4U7.mjs +41 -0
- package/dist/chunk-VBLFQXCD.mjs +406 -0
- package/dist/chunk-VQCPN62H.mjs +134 -0
- package/dist/chunk-XJFMS3SM.mjs +21 -0
- package/dist/components/auth-provider.d.mts +24 -0
- package/dist/components/auth-provider.d.ts +24 -0
- package/dist/components/auth-provider.js +107 -0
- package/dist/components/auth-provider.mjs +11 -0
- package/dist/components/login.d.mts +24 -0
- package/dist/components/login.d.ts +24 -0
- package/dist/components/login.js +430 -0
- package/dist/components/login.mjs +9 -0
- package/dist/components/reset-password.d.mts +11 -0
- package/dist/components/reset-password.d.ts +11 -0
- package/dist/components/reset-password.js +283 -0
- package/dist/components/reset-password.mjs +10 -0
- package/dist/components/sign-out-button.d.mts +11 -0
- package/dist/components/sign-out-button.d.ts +11 -0
- package/dist/components/sign-out-button.js +90 -0
- package/dist/components/sign-out-button.mjs +11 -0
- package/dist/components/user-menu.d.mts +5 -0
- package/dist/components/user-menu.d.ts +5 -0
- package/dist/components/user-menu.js +107 -0
- package/dist/components/user-menu.mjs +11 -0
- package/dist/components/verify-code.d.mts +20 -0
- package/dist/components/verify-code.d.ts +20 -0
- package/dist/components/verify-code.js +155 -0
- package/dist/components/verify-code.mjs +9 -0
- package/dist/index.d.mts +44 -0
- package/dist/index.d.ts +44 -0
- package/dist/index.js +1006 -0
- package/dist/index.mjs +159 -0
- package/dist/middleware.d.mts +29 -0
- package/dist/middleware.d.ts +29 -0
- package/dist/middleware.js +114 -0
- package/dist/middleware.mjs +83 -0
- package/dist/proxy.d.mts +9 -0
- package/dist/proxy.d.ts +9 -0
- package/dist/proxy.js +71 -0
- package/dist/proxy.mjs +41 -0
- package/dist/request.d.mts +14 -0
- package/dist/request.d.ts +14 -0
- package/dist/request.js +46 -0
- package/dist/request.mjs +8 -0
- package/package.json +101 -0
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
"use strict";
|
|
3
|
+
"use client";
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
+
|
|
22
|
+
// src/components/reset-password.tsx
|
|
23
|
+
var reset_password_exports = {};
|
|
24
|
+
__export(reset_password_exports, {
|
|
25
|
+
ResetPasswordForm: () => ResetPasswordForm
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(reset_password_exports);
|
|
28
|
+
var import_react2 = require("react");
|
|
29
|
+
var import_core2 = require("@mantine/core");
|
|
30
|
+
var import_client2 = require("@frequencyads/db/client");
|
|
31
|
+
|
|
32
|
+
// src/components/verify-code.tsx
|
|
33
|
+
var import_react = require("react");
|
|
34
|
+
var import_core = require("@mantine/core");
|
|
35
|
+
var import_client = require("@frequencyads/db/client");
|
|
36
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
37
|
+
function VerifyCodeForm({
|
|
38
|
+
email,
|
|
39
|
+
type,
|
|
40
|
+
onSuccess,
|
|
41
|
+
onResend,
|
|
42
|
+
onBack,
|
|
43
|
+
backLabel = "Back to sign in",
|
|
44
|
+
header
|
|
45
|
+
}) {
|
|
46
|
+
const [code, setCode] = (0, import_react.useState)("");
|
|
47
|
+
const [error, setError] = (0, import_react.useState)(null);
|
|
48
|
+
const [loading, setLoading] = (0, import_react.useState)(false);
|
|
49
|
+
const [verified, setVerified] = (0, import_react.useState)(false);
|
|
50
|
+
const [resendCooldown, setResendCooldown] = (0, import_react.useState)(0);
|
|
51
|
+
(0, import_react.useEffect)(() => {
|
|
52
|
+
if (resendCooldown <= 0) return;
|
|
53
|
+
const timer = setTimeout(() => setResendCooldown((c) => c - 1), 1e3);
|
|
54
|
+
return () => clearTimeout(timer);
|
|
55
|
+
}, [resendCooldown]);
|
|
56
|
+
const handleVerify = (0, import_react.useCallback)(
|
|
57
|
+
async (value) => {
|
|
58
|
+
if (value.length !== 6) return;
|
|
59
|
+
setError(null);
|
|
60
|
+
setLoading(true);
|
|
61
|
+
try {
|
|
62
|
+
const supabase = (0, import_client.createBrowserClient)();
|
|
63
|
+
const { error: verifyError } = await supabase.auth.verifyOtp({
|
|
64
|
+
email,
|
|
65
|
+
token: value,
|
|
66
|
+
type
|
|
67
|
+
});
|
|
68
|
+
if (verifyError) {
|
|
69
|
+
setError("This code is invalid or has expired. Please request a new one.");
|
|
70
|
+
setCode("");
|
|
71
|
+
} else {
|
|
72
|
+
setVerified(true);
|
|
73
|
+
onSuccess();
|
|
74
|
+
}
|
|
75
|
+
} finally {
|
|
76
|
+
setLoading(false);
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
[email, type, onSuccess]
|
|
80
|
+
);
|
|
81
|
+
const [resending, setResending] = (0, import_react.useState)(false);
|
|
82
|
+
const handleResend = async () => {
|
|
83
|
+
setError(null);
|
|
84
|
+
setResending(true);
|
|
85
|
+
try {
|
|
86
|
+
const result = await onResend();
|
|
87
|
+
if (result.error) {
|
|
88
|
+
setError(result.error);
|
|
89
|
+
} else {
|
|
90
|
+
setResendCooldown(60);
|
|
91
|
+
}
|
|
92
|
+
} finally {
|
|
93
|
+
setResending(false);
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_core.Box, { w: "100%", maw: 460, children: [
|
|
97
|
+
header && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core.Box, { mb: "lg", style: { textAlign: "center" }, children: header }),
|
|
98
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core.Title, { order: 3, fw: 600, mb: "xs", c: "gray.7", children: type === "email" ? "Verify your email" : "Enter reset code" }),
|
|
99
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_core.Text, { size: "sm", c: "gray.6", mb: "lg", children: [
|
|
100
|
+
"We sent a 6-digit code to ",
|
|
101
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: email })
|
|
102
|
+
] }),
|
|
103
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_core.Stack, { children: [
|
|
104
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
105
|
+
import_core.PinInput,
|
|
106
|
+
{
|
|
107
|
+
length: 6,
|
|
108
|
+
type: "number",
|
|
109
|
+
oneTimeCode: true,
|
|
110
|
+
autoFocus: true,
|
|
111
|
+
size: "lg",
|
|
112
|
+
value: code,
|
|
113
|
+
onChange: (value) => {
|
|
114
|
+
setCode(value);
|
|
115
|
+
if (value.length > 0) setError(null);
|
|
116
|
+
},
|
|
117
|
+
onComplete: handleVerify,
|
|
118
|
+
error: !!error,
|
|
119
|
+
disabled: loading || verified,
|
|
120
|
+
styles: { input: { fontWeight: 600, fontSize: 20 } }
|
|
121
|
+
}
|
|
122
|
+
),
|
|
123
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core.Text, { size: "sm", c: "red", children: error }),
|
|
124
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
125
|
+
import_core.Button,
|
|
126
|
+
{
|
|
127
|
+
fullWidth: true,
|
|
128
|
+
size: "md",
|
|
129
|
+
loading: loading || verified,
|
|
130
|
+
onClick: () => handleVerify(code),
|
|
131
|
+
children: "Verify"
|
|
132
|
+
}
|
|
133
|
+
),
|
|
134
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_core.Text, { size: "sm", c: "gray.6", ta: "center", children: [
|
|
135
|
+
"Didn't receive the code?",
|
|
136
|
+
" ",
|
|
137
|
+
resendCooldown > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_core.Text, { span: true, c: "gray.5", children: [
|
|
138
|
+
"Resend in ",
|
|
139
|
+
resendCooldown,
|
|
140
|
+
"s"
|
|
141
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
142
|
+
import_core.Anchor,
|
|
143
|
+
{
|
|
144
|
+
component: "button",
|
|
145
|
+
type: "button",
|
|
146
|
+
size: "sm",
|
|
147
|
+
onClick: handleResend,
|
|
148
|
+
disabled: resending,
|
|
149
|
+
children: resending ? "Sending\u2026" : "Resend code"
|
|
150
|
+
}
|
|
151
|
+
)
|
|
152
|
+
] }),
|
|
153
|
+
onBack && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core.Anchor, { component: "button", type: "button", size: "sm", onClick: onBack, ta: "center", children: backLabel })
|
|
154
|
+
] })
|
|
155
|
+
] });
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// src/components/reset-password.tsx
|
|
159
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
160
|
+
function ResetPasswordForm({ onComplete, onBackToLogin, header }) {
|
|
161
|
+
const supabase = (0, import_client2.createBrowserClient)();
|
|
162
|
+
const [step, setStep] = (0, import_react2.useState)("email");
|
|
163
|
+
const [email, setEmail] = (0, import_react2.useState)("");
|
|
164
|
+
const [password, setPassword] = (0, import_react2.useState)("");
|
|
165
|
+
const [confirmPassword, setConfirmPassword] = (0, import_react2.useState)("");
|
|
166
|
+
const [error, setError] = (0, import_react2.useState)(null);
|
|
167
|
+
const [loading, setLoading] = (0, import_react2.useState)(false);
|
|
168
|
+
const handleRequestReset = async (e) => {
|
|
169
|
+
e.preventDefault();
|
|
170
|
+
setError(null);
|
|
171
|
+
if (!email.trim()) {
|
|
172
|
+
setError("Email is required.");
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
setLoading(true);
|
|
176
|
+
try {
|
|
177
|
+
const { error: resetError } = await supabase.auth.resetPasswordForEmail(email);
|
|
178
|
+
if (resetError) {
|
|
179
|
+
setError(resetError.message);
|
|
180
|
+
} else {
|
|
181
|
+
setStep("code");
|
|
182
|
+
}
|
|
183
|
+
} finally {
|
|
184
|
+
setLoading(false);
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
const handleSetPassword = async (e) => {
|
|
188
|
+
e.preventDefault();
|
|
189
|
+
setError(null);
|
|
190
|
+
if (password.length < 8) {
|
|
191
|
+
setError("Password must be at least 8 characters.");
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
if (password !== confirmPassword) {
|
|
195
|
+
setError("Passwords do not match.");
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
setLoading(true);
|
|
199
|
+
try {
|
|
200
|
+
const { error: updateError } = await supabase.auth.updateUser({ password });
|
|
201
|
+
if (updateError) {
|
|
202
|
+
setError(updateError.message);
|
|
203
|
+
} else {
|
|
204
|
+
onComplete();
|
|
205
|
+
}
|
|
206
|
+
} finally {
|
|
207
|
+
setLoading(false);
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
if (step === "code") {
|
|
211
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
212
|
+
VerifyCodeForm,
|
|
213
|
+
{
|
|
214
|
+
email,
|
|
215
|
+
type: "recovery",
|
|
216
|
+
onSuccess: () => setStep("password"),
|
|
217
|
+
onResend: async () => {
|
|
218
|
+
const { error: resendError } = await supabase.auth.resetPasswordForEmail(email);
|
|
219
|
+
return { error: resendError == null ? void 0 : resendError.message };
|
|
220
|
+
},
|
|
221
|
+
onBack: onBackToLogin,
|
|
222
|
+
header
|
|
223
|
+
}
|
|
224
|
+
);
|
|
225
|
+
}
|
|
226
|
+
if (step === "password") {
|
|
227
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_core2.Box, { w: "100%", maw: 460, children: [
|
|
228
|
+
header && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_core2.Box, { mb: "lg", style: { textAlign: "center" }, children: header }),
|
|
229
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_core2.Title, { order: 3, fw: 600, mb: "xs", c: "gray.7", children: "Set new password" }),
|
|
230
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_core2.Text, { size: "sm", c: "gray.6", mb: "lg", children: "Choose a new password for your account." }),
|
|
231
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("form", { onSubmit: handleSetPassword, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_core2.Stack, { children: [
|
|
232
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
233
|
+
import_core2.PasswordInput,
|
|
234
|
+
{
|
|
235
|
+
label: "New password",
|
|
236
|
+
placeholder: "At least 8 characters",
|
|
237
|
+
value: password,
|
|
238
|
+
onChange: (e) => setPassword(e.currentTarget.value),
|
|
239
|
+
minLength: 8,
|
|
240
|
+
required: true
|
|
241
|
+
}
|
|
242
|
+
),
|
|
243
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
244
|
+
import_core2.PasswordInput,
|
|
245
|
+
{
|
|
246
|
+
label: "Confirm password",
|
|
247
|
+
placeholder: "Repeat your password",
|
|
248
|
+
value: confirmPassword,
|
|
249
|
+
onChange: (e) => setConfirmPassword(e.currentTarget.value),
|
|
250
|
+
required: true
|
|
251
|
+
}
|
|
252
|
+
),
|
|
253
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_core2.Text, { size: "sm", c: "red", children: error }),
|
|
254
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_core2.Button, { fullWidth: true, size: "md", type: "submit", loading, children: "Update password" })
|
|
255
|
+
] }) })
|
|
256
|
+
] });
|
|
257
|
+
}
|
|
258
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_core2.Box, { w: "100%", maw: 460, children: [
|
|
259
|
+
header && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_core2.Box, { mb: "lg", style: { textAlign: "center" }, children: header }),
|
|
260
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_core2.Title, { order: 3, fw: 600, mb: "xs", c: "gray.7", children: "Reset password" }),
|
|
261
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_core2.Text, { size: "sm", c: "gray.6", mb: "lg", children: "Enter your email and we'll send you a code to reset your password." }),
|
|
262
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("form", { onSubmit: handleRequestReset, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_core2.Stack, { children: [
|
|
263
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
264
|
+
import_core2.TextInput,
|
|
265
|
+
{
|
|
266
|
+
label: "Email",
|
|
267
|
+
placeholder: "you@frequency.media",
|
|
268
|
+
type: "email",
|
|
269
|
+
value: email,
|
|
270
|
+
onChange: (e) => setEmail(e.currentTarget.value),
|
|
271
|
+
required: true
|
|
272
|
+
}
|
|
273
|
+
),
|
|
274
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_core2.Text, { size: "sm", c: "red", children: error }),
|
|
275
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_core2.Button, { fullWidth: true, size: "md", type: "submit", loading, children: "Send reset code" }),
|
|
276
|
+
onBackToLogin && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_core2.Text, { size: "sm", c: "gray.6", ta: "center", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_core2.Anchor, { component: "button", type: "button", size: "sm", onClick: onBackToLogin, children: "Back to sign in" }) })
|
|
277
|
+
] }) })
|
|
278
|
+
] });
|
|
279
|
+
}
|
|
280
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
281
|
+
0 && (module.exports = {
|
|
282
|
+
ResetPasswordForm
|
|
283
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ButtonProps } from '@mantine/core';
|
|
3
|
+
|
|
4
|
+
declare function getSignOutUrl(returnTo?: string): string;
|
|
5
|
+
interface SignOutButtonProps extends Omit<ButtonProps, 'component'> {
|
|
6
|
+
/** URL to redirect to after sign-out. Defaults to `window.location.origin`. */
|
|
7
|
+
returnTo?: string;
|
|
8
|
+
}
|
|
9
|
+
declare function SignOutButton({ returnTo, ...props }: SignOutButtonProps): react_jsx_runtime.JSX.Element;
|
|
10
|
+
|
|
11
|
+
export { SignOutButton, type SignOutButtonProps, getSignOutUrl };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ButtonProps } from '@mantine/core';
|
|
3
|
+
|
|
4
|
+
declare function getSignOutUrl(returnTo?: string): string;
|
|
5
|
+
interface SignOutButtonProps extends Omit<ButtonProps, 'component'> {
|
|
6
|
+
/** URL to redirect to after sign-out. Defaults to `window.location.origin`. */
|
|
7
|
+
returnTo?: string;
|
|
8
|
+
}
|
|
9
|
+
declare function SignOutButton({ returnTo, ...props }: SignOutButtonProps): react_jsx_runtime.JSX.Element;
|
|
10
|
+
|
|
11
|
+
export { SignOutButton, type SignOutButtonProps, getSignOutUrl };
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
"use strict";
|
|
3
|
+
"use client";
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __defProps = Object.defineProperties;
|
|
6
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
8
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
9
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
10
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
11
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
12
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
13
|
+
var __spreadValues = (a, b) => {
|
|
14
|
+
for (var prop in b || (b = {}))
|
|
15
|
+
if (__hasOwnProp.call(b, prop))
|
|
16
|
+
__defNormalProp(a, prop, b[prop]);
|
|
17
|
+
if (__getOwnPropSymbols)
|
|
18
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
19
|
+
if (__propIsEnum.call(b, prop))
|
|
20
|
+
__defNormalProp(a, prop, b[prop]);
|
|
21
|
+
}
|
|
22
|
+
return a;
|
|
23
|
+
};
|
|
24
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
25
|
+
var __objRest = (source, exclude) => {
|
|
26
|
+
var target = {};
|
|
27
|
+
for (var prop in source)
|
|
28
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
29
|
+
target[prop] = source[prop];
|
|
30
|
+
if (source != null && __getOwnPropSymbols)
|
|
31
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
32
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
33
|
+
target[prop] = source[prop];
|
|
34
|
+
}
|
|
35
|
+
return target;
|
|
36
|
+
};
|
|
37
|
+
var __export = (target, all) => {
|
|
38
|
+
for (var name in all)
|
|
39
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
40
|
+
};
|
|
41
|
+
var __copyProps = (to, from, except, desc) => {
|
|
42
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
43
|
+
for (let key of __getOwnPropNames(from))
|
|
44
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
45
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
46
|
+
}
|
|
47
|
+
return to;
|
|
48
|
+
};
|
|
49
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
50
|
+
|
|
51
|
+
// src/components/sign-out-button.tsx
|
|
52
|
+
var sign_out_button_exports = {};
|
|
53
|
+
__export(sign_out_button_exports, {
|
|
54
|
+
SignOutButton: () => SignOutButton,
|
|
55
|
+
getSignOutUrl: () => getSignOutUrl
|
|
56
|
+
});
|
|
57
|
+
module.exports = __toCommonJS(sign_out_button_exports);
|
|
58
|
+
var import_core = require("@mantine/core");
|
|
59
|
+
var import_icons_react = require("@tabler/icons-react");
|
|
60
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
61
|
+
function getSignOutUrl(returnTo) {
|
|
62
|
+
const accountsUrl = process.env.NEXT_PUBLIC_ACCOUNTS_URL;
|
|
63
|
+
if (!accountsUrl) return "#";
|
|
64
|
+
const next = returnTo != null ? returnTo : window.location.origin;
|
|
65
|
+
return `${accountsUrl}/logout?next=${encodeURIComponent(next)}`;
|
|
66
|
+
}
|
|
67
|
+
function SignOutButton(_a) {
|
|
68
|
+
var _b = _a, { returnTo } = _b, props = __objRest(_b, ["returnTo"]);
|
|
69
|
+
var _a2;
|
|
70
|
+
const handleClick = () => {
|
|
71
|
+
window.location.href = getSignOutUrl(returnTo);
|
|
72
|
+
};
|
|
73
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
74
|
+
import_core.Button,
|
|
75
|
+
__spreadProps(__spreadValues({
|
|
76
|
+
onClick: handleClick,
|
|
77
|
+
variant: "light",
|
|
78
|
+
color: "red",
|
|
79
|
+
leftSection: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons_react.IconLogout, { size: 16 }),
|
|
80
|
+
w: "fit-content"
|
|
81
|
+
}, props), {
|
|
82
|
+
children: (_a2 = props.children) != null ? _a2 : "Sign out"
|
|
83
|
+
})
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
87
|
+
0 && (module.exports = {
|
|
88
|
+
SignOutButton,
|
|
89
|
+
getSignOutUrl
|
|
90
|
+
});
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
"use strict";
|
|
3
|
+
"use client";
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
+
|
|
22
|
+
// src/components/user-menu.tsx
|
|
23
|
+
var user_menu_exports = {};
|
|
24
|
+
__export(user_menu_exports, {
|
|
25
|
+
UserMenu: () => UserMenu
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(user_menu_exports);
|
|
28
|
+
var import_core2 = require("@mantine/core");
|
|
29
|
+
var import_icons_react2 = require("@tabler/icons-react");
|
|
30
|
+
var import_react2 = require("react");
|
|
31
|
+
|
|
32
|
+
// src/components/auth-provider.tsx
|
|
33
|
+
var import_react = require("react");
|
|
34
|
+
var import_client = require("@frequencyads/db/client");
|
|
35
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
36
|
+
var Context = (0, import_react.createContext)(void 0);
|
|
37
|
+
function useAuth() {
|
|
38
|
+
const context = (0, import_react.useContext)(Context);
|
|
39
|
+
if (context === void 0) {
|
|
40
|
+
throw new Error("useAuth must be used within an AuthProvider");
|
|
41
|
+
}
|
|
42
|
+
return context;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// src/components/sign-out-button.tsx
|
|
46
|
+
var import_core = require("@mantine/core");
|
|
47
|
+
var import_icons_react = require("@tabler/icons-react");
|
|
48
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
49
|
+
function getSignOutUrl(returnTo) {
|
|
50
|
+
const accountsUrl = process.env.NEXT_PUBLIC_ACCOUNTS_URL;
|
|
51
|
+
if (!accountsUrl) return "#";
|
|
52
|
+
const next = returnTo != null ? returnTo : window.location.origin;
|
|
53
|
+
return `${accountsUrl}/logout?next=${encodeURIComponent(next)}`;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// src/components/user-menu.tsx
|
|
57
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
58
|
+
function UserMenu() {
|
|
59
|
+
const { user, profile } = useAuth();
|
|
60
|
+
const [opened, setOpened] = (0, import_react2.useState)(false);
|
|
61
|
+
if (!user) return null;
|
|
62
|
+
const handleLogout = () => {
|
|
63
|
+
window.location.href = getSignOutUrl();
|
|
64
|
+
};
|
|
65
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
66
|
+
import_core2.Menu,
|
|
67
|
+
{
|
|
68
|
+
width: 260,
|
|
69
|
+
position: "bottom-end",
|
|
70
|
+
transitionProps: { transition: "pop-top-right" },
|
|
71
|
+
opened,
|
|
72
|
+
onChange: setOpened,
|
|
73
|
+
children: [
|
|
74
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_core2.Menu.Target, { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
75
|
+
import_core2.UnstyledButton,
|
|
76
|
+
{
|
|
77
|
+
style: {
|
|
78
|
+
padding: "var(--mantine-spacing-xs)",
|
|
79
|
+
borderRadius: "var(--mantine-radius-sm)",
|
|
80
|
+
transition: "background-color 100ms ease"
|
|
81
|
+
},
|
|
82
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_core2.Group, { gap: 7, children: [
|
|
83
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_core2.Avatar, { src: profile.avatarUrl, alt: profile.name, radius: "xl", size: 32 }),
|
|
84
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_core2.Text, { fw: 500, size: "sm", lh: 1, mr: 3, children: profile.name }),
|
|
85
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_icons_react2.IconChevronDown, { style: { width: (0, import_core2.rem)(12), height: (0, import_core2.rem)(12) }, stroke: 1.5 })
|
|
86
|
+
] })
|
|
87
|
+
}
|
|
88
|
+
) }),
|
|
89
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_core2.Menu.Dropdown, { children: [
|
|
90
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_core2.Menu.Label, { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_core2.Text, { size: "xs", c: "dimmed", truncate: true, children: profile.email }) }),
|
|
91
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
92
|
+
import_core2.Menu.Item,
|
|
93
|
+
{
|
|
94
|
+
leftSection: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_icons_react2.IconLogout, { style: { width: (0, import_core2.rem)(16), height: (0, import_core2.rem)(16) }, stroke: 1.5 }),
|
|
95
|
+
onClick: handleLogout,
|
|
96
|
+
children: "Sign out"
|
|
97
|
+
}
|
|
98
|
+
)
|
|
99
|
+
] })
|
|
100
|
+
]
|
|
101
|
+
}
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
105
|
+
0 && (module.exports = {
|
|
106
|
+
UserMenu
|
|
107
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
|
|
3
|
+
interface VerifyCodeFormProps {
|
|
4
|
+
email: string;
|
|
5
|
+
/** 'email' for signup verification, 'recovery' for password reset */
|
|
6
|
+
type: 'email' | 'recovery';
|
|
7
|
+
onSuccess: () => void;
|
|
8
|
+
onResend: () => Promise<{
|
|
9
|
+
error?: string;
|
|
10
|
+
}>;
|
|
11
|
+
/** Called when user wants to go back (e.g. back to login). */
|
|
12
|
+
onBack?: () => void;
|
|
13
|
+
/** Label for the back link. Defaults to "Back to sign in". */
|
|
14
|
+
backLabel?: string;
|
|
15
|
+
/** Content rendered above the form (e.g. a logo). */
|
|
16
|
+
header?: React.ReactNode;
|
|
17
|
+
}
|
|
18
|
+
declare function VerifyCodeForm({ email, type, onSuccess, onResend, onBack, backLabel, header, }: VerifyCodeFormProps): react_jsx_runtime.JSX.Element;
|
|
19
|
+
|
|
20
|
+
export { VerifyCodeForm };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
|
|
3
|
+
interface VerifyCodeFormProps {
|
|
4
|
+
email: string;
|
|
5
|
+
/** 'email' for signup verification, 'recovery' for password reset */
|
|
6
|
+
type: 'email' | 'recovery';
|
|
7
|
+
onSuccess: () => void;
|
|
8
|
+
onResend: () => Promise<{
|
|
9
|
+
error?: string;
|
|
10
|
+
}>;
|
|
11
|
+
/** Called when user wants to go back (e.g. back to login). */
|
|
12
|
+
onBack?: () => void;
|
|
13
|
+
/** Label for the back link. Defaults to "Back to sign in". */
|
|
14
|
+
backLabel?: string;
|
|
15
|
+
/** Content rendered above the form (e.g. a logo). */
|
|
16
|
+
header?: React.ReactNode;
|
|
17
|
+
}
|
|
18
|
+
declare function VerifyCodeForm({ email, type, onSuccess, onResend, onBack, backLabel, header, }: VerifyCodeFormProps): react_jsx_runtime.JSX.Element;
|
|
19
|
+
|
|
20
|
+
export { VerifyCodeForm };
|