@erikey/react 0.3.5 → 0.4.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-Y3WVYSUI.mjs +1150 -0
- package/dist/chunk-Y3WVYSUI.mjs.map +1 -0
- package/dist/index.d.mts +858 -3823
- package/dist/index.mjs +573 -1034
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +1039 -81
- package/dist/styles.css.map +1 -1
- package/dist/ui/index.mjs +17230 -908
- package/dist/ui/index.mjs.map +1 -1
- package/package.json +30 -9
- package/dist/ui/index.css +0 -797
- package/dist/ui/index.css.map +0 -1
- package/dist/ui/index.d.mts +0 -729
|
@@ -0,0 +1,1150 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
+
|
|
5
|
+
// ../../../node_modules/.pnpm/@better-auth+core@1.4.10_@better-auth+utils@0.3.0_@better-fetch+fetch@1.1.21_better-call@1.1._s4ptmt7cznbdkhj2rfry3i4hxy/node_modules/@better-auth/core/dist/env-DbssmzoK.mjs
|
|
6
|
+
var _envShim = /* @__PURE__ */ Object.create(null);
|
|
7
|
+
var _getEnv = (useShim) => globalThis.process?.env || globalThis.Deno?.env.toObject() || globalThis.__env__ || (useShim ? _envShim : globalThis);
|
|
8
|
+
var env = new Proxy(_envShim, {
|
|
9
|
+
get(_, prop) {
|
|
10
|
+
return _getEnv()[prop] ?? _envShim[prop];
|
|
11
|
+
},
|
|
12
|
+
has(_, prop) {
|
|
13
|
+
return prop in _getEnv() || prop in _envShim;
|
|
14
|
+
},
|
|
15
|
+
set(_, prop, value) {
|
|
16
|
+
const env$1 = _getEnv(true);
|
|
17
|
+
env$1[prop] = value;
|
|
18
|
+
return true;
|
|
19
|
+
},
|
|
20
|
+
deleteProperty(_, prop) {
|
|
21
|
+
if (!prop) return false;
|
|
22
|
+
const env$1 = _getEnv(true);
|
|
23
|
+
delete env$1[prop];
|
|
24
|
+
return true;
|
|
25
|
+
},
|
|
26
|
+
ownKeys() {
|
|
27
|
+
const env$1 = _getEnv(true);
|
|
28
|
+
return Object.keys(env$1);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
var nodeENV = typeof process !== "undefined" && process.env && process.env.NODE_ENV || "";
|
|
32
|
+
function getEnvVar(key, fallback) {
|
|
33
|
+
if (typeof process !== "undefined" && process.env) return process.env[key] ?? fallback;
|
|
34
|
+
if (typeof Deno !== "undefined") return Deno.env.get(key) ?? fallback;
|
|
35
|
+
if (typeof Bun !== "undefined") return Bun.env[key] ?? fallback;
|
|
36
|
+
return fallback;
|
|
37
|
+
}
|
|
38
|
+
var ENV = Object.freeze({
|
|
39
|
+
get BETTER_AUTH_SECRET() {
|
|
40
|
+
return getEnvVar("BETTER_AUTH_SECRET");
|
|
41
|
+
},
|
|
42
|
+
get AUTH_SECRET() {
|
|
43
|
+
return getEnvVar("AUTH_SECRET");
|
|
44
|
+
},
|
|
45
|
+
get BETTER_AUTH_TELEMETRY() {
|
|
46
|
+
return getEnvVar("BETTER_AUTH_TELEMETRY");
|
|
47
|
+
},
|
|
48
|
+
get BETTER_AUTH_TELEMETRY_ID() {
|
|
49
|
+
return getEnvVar("BETTER_AUTH_TELEMETRY_ID");
|
|
50
|
+
},
|
|
51
|
+
get NODE_ENV() {
|
|
52
|
+
return getEnvVar("NODE_ENV", "development");
|
|
53
|
+
},
|
|
54
|
+
get PACKAGE_VERSION() {
|
|
55
|
+
return getEnvVar("PACKAGE_VERSION", "0.0.0");
|
|
56
|
+
},
|
|
57
|
+
get BETTER_AUTH_TELEMETRY_ENDPOINT() {
|
|
58
|
+
return getEnvVar("BETTER_AUTH_TELEMETRY_ENDPOINT", "https://telemetry.better-auth.com/v1/track");
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
var COLORS_2 = 1;
|
|
62
|
+
var COLORS_16 = 4;
|
|
63
|
+
var COLORS_256 = 8;
|
|
64
|
+
var COLORS_16m = 24;
|
|
65
|
+
var TERM_ENVS = {
|
|
66
|
+
eterm: COLORS_16,
|
|
67
|
+
cons25: COLORS_16,
|
|
68
|
+
console: COLORS_16,
|
|
69
|
+
cygwin: COLORS_16,
|
|
70
|
+
dtterm: COLORS_16,
|
|
71
|
+
gnome: COLORS_16,
|
|
72
|
+
hurd: COLORS_16,
|
|
73
|
+
jfbterm: COLORS_16,
|
|
74
|
+
konsole: COLORS_16,
|
|
75
|
+
kterm: COLORS_16,
|
|
76
|
+
mlterm: COLORS_16,
|
|
77
|
+
mosh: COLORS_16m,
|
|
78
|
+
putty: COLORS_16,
|
|
79
|
+
st: COLORS_16,
|
|
80
|
+
"rxvt-unicode-24bit": COLORS_16m,
|
|
81
|
+
terminator: COLORS_16m,
|
|
82
|
+
"xterm-kitty": COLORS_16m
|
|
83
|
+
};
|
|
84
|
+
var CI_ENVS_MAP = new Map(Object.entries({
|
|
85
|
+
APPVEYOR: COLORS_256,
|
|
86
|
+
BUILDKITE: COLORS_256,
|
|
87
|
+
CIRCLECI: COLORS_16m,
|
|
88
|
+
DRONE: COLORS_256,
|
|
89
|
+
GITEA_ACTIONS: COLORS_16m,
|
|
90
|
+
GITHUB_ACTIONS: COLORS_16m,
|
|
91
|
+
GITLAB_CI: COLORS_256,
|
|
92
|
+
TRAVIS: COLORS_256
|
|
93
|
+
}));
|
|
94
|
+
var TERM_ENVS_REG_EXP = [
|
|
95
|
+
/ansi/,
|
|
96
|
+
/color/,
|
|
97
|
+
/linux/,
|
|
98
|
+
/direct/,
|
|
99
|
+
/^con[0-9]*x[0-9]/,
|
|
100
|
+
/^rxvt/,
|
|
101
|
+
/^screen/,
|
|
102
|
+
/^xterm/,
|
|
103
|
+
/^vt100/,
|
|
104
|
+
/^vt220/
|
|
105
|
+
];
|
|
106
|
+
function getColorDepth() {
|
|
107
|
+
if (getEnvVar("FORCE_COLOR") !== void 0) switch (getEnvVar("FORCE_COLOR")) {
|
|
108
|
+
case "":
|
|
109
|
+
case "1":
|
|
110
|
+
case "true":
|
|
111
|
+
return COLORS_16;
|
|
112
|
+
case "2":
|
|
113
|
+
return COLORS_256;
|
|
114
|
+
case "3":
|
|
115
|
+
return COLORS_16m;
|
|
116
|
+
default:
|
|
117
|
+
return COLORS_2;
|
|
118
|
+
}
|
|
119
|
+
if (getEnvVar("NODE_DISABLE_COLORS") !== void 0 && getEnvVar("NODE_DISABLE_COLORS") !== "" || getEnvVar("NO_COLOR") !== void 0 && getEnvVar("NO_COLOR") !== "" || getEnvVar("TERM") === "dumb") return COLORS_2;
|
|
120
|
+
if (getEnvVar("TMUX")) return COLORS_16m;
|
|
121
|
+
if ("TF_BUILD" in env && "AGENT_NAME" in env) return COLORS_16;
|
|
122
|
+
if ("CI" in env) {
|
|
123
|
+
for (const { 0: envName, 1: colors } of CI_ENVS_MAP) if (envName in env) return colors;
|
|
124
|
+
if (getEnvVar("CI_NAME") === "codeship") return COLORS_256;
|
|
125
|
+
return COLORS_2;
|
|
126
|
+
}
|
|
127
|
+
if ("TEAMCITY_VERSION" in env) return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.exec(getEnvVar("TEAMCITY_VERSION")) !== null ? COLORS_16 : COLORS_2;
|
|
128
|
+
switch (getEnvVar("TERM_PROGRAM")) {
|
|
129
|
+
case "iTerm.app":
|
|
130
|
+
if (!getEnvVar("TERM_PROGRAM_VERSION") || /^[0-2]\./.exec(getEnvVar("TERM_PROGRAM_VERSION")) !== null) return COLORS_256;
|
|
131
|
+
return COLORS_16m;
|
|
132
|
+
case "HyperTerm":
|
|
133
|
+
case "MacTerm":
|
|
134
|
+
return COLORS_16m;
|
|
135
|
+
case "Apple_Terminal":
|
|
136
|
+
return COLORS_256;
|
|
137
|
+
}
|
|
138
|
+
if (getEnvVar("COLORTERM") === "truecolor" || getEnvVar("COLORTERM") === "24bit") return COLORS_16m;
|
|
139
|
+
if (getEnvVar("TERM")) {
|
|
140
|
+
if (/truecolor/.exec(getEnvVar("TERM")) !== null) return COLORS_16m;
|
|
141
|
+
if (/^xterm-256/.exec(getEnvVar("TERM")) !== null) return COLORS_256;
|
|
142
|
+
const termEnv = getEnvVar("TERM").toLowerCase();
|
|
143
|
+
if (TERM_ENVS[termEnv]) return TERM_ENVS[termEnv];
|
|
144
|
+
if (TERM_ENVS_REG_EXP.some((term) => term.exec(termEnv) !== null)) return COLORS_16;
|
|
145
|
+
}
|
|
146
|
+
if (getEnvVar("COLORTERM")) return COLORS_16;
|
|
147
|
+
return COLORS_2;
|
|
148
|
+
}
|
|
149
|
+
var TTY_COLORS = {
|
|
150
|
+
reset: "\x1B[0m",
|
|
151
|
+
bright: "\x1B[1m",
|
|
152
|
+
dim: "\x1B[2m",
|
|
153
|
+
undim: "\x1B[22m",
|
|
154
|
+
underscore: "\x1B[4m",
|
|
155
|
+
blink: "\x1B[5m",
|
|
156
|
+
reverse: "\x1B[7m",
|
|
157
|
+
hidden: "\x1B[8m",
|
|
158
|
+
fg: {
|
|
159
|
+
black: "\x1B[30m",
|
|
160
|
+
red: "\x1B[31m",
|
|
161
|
+
green: "\x1B[32m",
|
|
162
|
+
yellow: "\x1B[33m",
|
|
163
|
+
blue: "\x1B[34m",
|
|
164
|
+
magenta: "\x1B[35m",
|
|
165
|
+
cyan: "\x1B[36m",
|
|
166
|
+
white: "\x1B[37m"
|
|
167
|
+
},
|
|
168
|
+
bg: {
|
|
169
|
+
black: "\x1B[40m",
|
|
170
|
+
red: "\x1B[41m",
|
|
171
|
+
green: "\x1B[42m",
|
|
172
|
+
yellow: "\x1B[43m",
|
|
173
|
+
blue: "\x1B[44m",
|
|
174
|
+
magenta: "\x1B[45m",
|
|
175
|
+
cyan: "\x1B[46m",
|
|
176
|
+
white: "\x1B[47m"
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
var levels = [
|
|
180
|
+
"debug",
|
|
181
|
+
"info",
|
|
182
|
+
"success",
|
|
183
|
+
"warn",
|
|
184
|
+
"error"
|
|
185
|
+
];
|
|
186
|
+
function shouldPublishLog(currentLogLevel, logLevel) {
|
|
187
|
+
return levels.indexOf(logLevel) >= levels.indexOf(currentLogLevel);
|
|
188
|
+
}
|
|
189
|
+
var levelColors = {
|
|
190
|
+
info: TTY_COLORS.fg.blue,
|
|
191
|
+
success: TTY_COLORS.fg.green,
|
|
192
|
+
warn: TTY_COLORS.fg.yellow,
|
|
193
|
+
error: TTY_COLORS.fg.red,
|
|
194
|
+
debug: TTY_COLORS.fg.magenta
|
|
195
|
+
};
|
|
196
|
+
var formatMessage = (level, message, colorsEnabled) => {
|
|
197
|
+
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
198
|
+
if (colorsEnabled) return `${TTY_COLORS.dim}${timestamp}${TTY_COLORS.reset} ${levelColors[level]}${level.toUpperCase()}${TTY_COLORS.reset} ${TTY_COLORS.bright}[Better Auth]:${TTY_COLORS.reset} ${message}`;
|
|
199
|
+
return `${timestamp} ${level.toUpperCase()} [Better Auth]: ${message}`;
|
|
200
|
+
};
|
|
201
|
+
var createLogger = (options) => {
|
|
202
|
+
const enabled = options?.disabled !== true;
|
|
203
|
+
const logLevel = options?.level ?? "error";
|
|
204
|
+
const colorsEnabled = options?.disableColors !== void 0 ? !options.disableColors : getColorDepth() !== 1;
|
|
205
|
+
const LogFunc = (level, message, args = []) => {
|
|
206
|
+
if (!enabled || !shouldPublishLog(logLevel, level)) return;
|
|
207
|
+
const formattedMessage = formatMessage(level, message, colorsEnabled);
|
|
208
|
+
if (!options || typeof options.log !== "function") {
|
|
209
|
+
if (level === "error") console.error(formattedMessage, ...args);
|
|
210
|
+
else if (level === "warn") console.warn(formattedMessage, ...args);
|
|
211
|
+
else console.log(formattedMessage, ...args);
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
options.log(level === "success" ? "info" : level, message, ...args);
|
|
215
|
+
};
|
|
216
|
+
return {
|
|
217
|
+
...Object.fromEntries(levels.map((level) => [level, (...[message, ...args]) => LogFunc(level, message, args)])),
|
|
218
|
+
get level() {
|
|
219
|
+
return logLevel;
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
};
|
|
223
|
+
var logger = createLogger();
|
|
224
|
+
|
|
225
|
+
// ../../../node_modules/.pnpm/@better-auth+core@1.4.10_@better-auth+utils@0.3.0_@better-fetch+fetch@1.1.21_better-call@1.1._s4ptmt7cznbdkhj2rfry3i4hxy/node_modules/@better-auth/core/dist/utils-NloIXYE0.mjs
|
|
226
|
+
function defineErrorCodes(codes) {
|
|
227
|
+
return codes;
|
|
228
|
+
}
|
|
229
|
+
function capitalizeFirstLetter(str) {
|
|
230
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// ../../../node_modules/.pnpm/@better-auth+core@1.4.10_@better-auth+utils@0.3.0_@better-fetch+fetch@1.1.21_better-call@1.1._s4ptmt7cznbdkhj2rfry3i4hxy/node_modules/@better-auth/core/dist/error-RtKwr3Pu.mjs
|
|
234
|
+
var BASE_ERROR_CODES = defineErrorCodes({
|
|
235
|
+
USER_NOT_FOUND: "User not found",
|
|
236
|
+
FAILED_TO_CREATE_USER: "Failed to create user",
|
|
237
|
+
FAILED_TO_CREATE_SESSION: "Failed to create session",
|
|
238
|
+
FAILED_TO_UPDATE_USER: "Failed to update user",
|
|
239
|
+
FAILED_TO_GET_SESSION: "Failed to get session",
|
|
240
|
+
INVALID_PASSWORD: "Invalid password",
|
|
241
|
+
INVALID_EMAIL: "Invalid email",
|
|
242
|
+
INVALID_EMAIL_OR_PASSWORD: "Invalid email or password",
|
|
243
|
+
SOCIAL_ACCOUNT_ALREADY_LINKED: "Social account already linked",
|
|
244
|
+
PROVIDER_NOT_FOUND: "Provider not found",
|
|
245
|
+
INVALID_TOKEN: "Invalid token",
|
|
246
|
+
ID_TOKEN_NOT_SUPPORTED: "id_token not supported",
|
|
247
|
+
FAILED_TO_GET_USER_INFO: "Failed to get user info",
|
|
248
|
+
USER_EMAIL_NOT_FOUND: "User email not found",
|
|
249
|
+
EMAIL_NOT_VERIFIED: "Email not verified",
|
|
250
|
+
PASSWORD_TOO_SHORT: "Password too short",
|
|
251
|
+
PASSWORD_TOO_LONG: "Password too long",
|
|
252
|
+
USER_ALREADY_EXISTS: "User already exists.",
|
|
253
|
+
USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL: "User already exists. Use another email.",
|
|
254
|
+
EMAIL_CAN_NOT_BE_UPDATED: "Email can not be updated",
|
|
255
|
+
CREDENTIAL_ACCOUNT_NOT_FOUND: "Credential account not found",
|
|
256
|
+
SESSION_EXPIRED: "Session expired. Re-authenticate to perform this action.",
|
|
257
|
+
FAILED_TO_UNLINK_LAST_ACCOUNT: "You can't unlink your last account",
|
|
258
|
+
ACCOUNT_NOT_FOUND: "Account not found",
|
|
259
|
+
USER_ALREADY_HAS_PASSWORD: "User already has a password. Provide that to delete the account.",
|
|
260
|
+
CROSS_SITE_NAVIGATION_LOGIN_BLOCKED: "Cross-site navigation login blocked. This request appears to be a CSRF attack.",
|
|
261
|
+
VERIFICATION_EMAIL_NOT_ENABLED: "Verification email isn't enabled",
|
|
262
|
+
EMAIL_ALREADY_VERIFIED: "Email is already verified",
|
|
263
|
+
EMAIL_MISMATCH: "Email mismatch",
|
|
264
|
+
SESSION_NOT_FRESH: "Session is not fresh",
|
|
265
|
+
LINKED_ACCOUNT_ALREADY_EXISTS: "Linked account already exists",
|
|
266
|
+
INVALID_ORIGIN: "Invalid origin",
|
|
267
|
+
INVALID_CALLBACK_URL: "Invalid callbackURL",
|
|
268
|
+
INVALID_REDIRECT_URL: "Invalid redirectURL",
|
|
269
|
+
INVALID_ERROR_CALLBACK_URL: "Invalid errorCallbackURL",
|
|
270
|
+
INVALID_NEW_USER_CALLBACK_URL: "Invalid newUserCallbackURL",
|
|
271
|
+
MISSING_OR_NULL_ORIGIN: "Missing or null Origin",
|
|
272
|
+
CALLBACK_URL_REQUIRED: "callbackURL is required",
|
|
273
|
+
FAILED_TO_CREATE_VERIFICATION: "Unable to create verification",
|
|
274
|
+
FIELD_NOT_ALLOWED: "Field not allowed to be set",
|
|
275
|
+
ASYNC_VALIDATION_NOT_SUPPORTED: "Async validation is not supported",
|
|
276
|
+
VALIDATION_ERROR: "Validation Error",
|
|
277
|
+
MISSING_FIELD: "Field is required"
|
|
278
|
+
});
|
|
279
|
+
var BetterAuthError = class extends Error {
|
|
280
|
+
constructor(message, cause) {
|
|
281
|
+
super(message);
|
|
282
|
+
this.name = "BetterAuthError";
|
|
283
|
+
this.message = message;
|
|
284
|
+
this.cause = cause;
|
|
285
|
+
this.stack = "";
|
|
286
|
+
}
|
|
287
|
+
};
|
|
288
|
+
|
|
289
|
+
// ../../../node_modules/.pnpm/better-auth@1.4.10_drizzle-kit@0.31.8_drizzle-orm@0.45.1_@cloudflare+workers-types@4.20251119_hirg525kbrpwuqvxcih3czaike/node_modules/better-auth/dist/utils/url.mjs
|
|
290
|
+
function checkHasPath(url) {
|
|
291
|
+
try {
|
|
292
|
+
return (new URL(url).pathname.replace(/\/+$/, "") || "/") !== "/";
|
|
293
|
+
} catch {
|
|
294
|
+
throw new BetterAuthError(`Invalid base URL: ${url}. Please provide a valid base URL.`);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
function assertHasProtocol(url) {
|
|
298
|
+
try {
|
|
299
|
+
const parsedUrl = new URL(url);
|
|
300
|
+
if (parsedUrl.protocol !== "http:" && parsedUrl.protocol !== "https:") throw new BetterAuthError(`Invalid base URL: ${url}. URL must include 'http://' or 'https://'`);
|
|
301
|
+
} catch (error) {
|
|
302
|
+
if (error instanceof BetterAuthError) throw error;
|
|
303
|
+
throw new BetterAuthError(`Invalid base URL: ${url}. Please provide a valid base URL.`, String(error));
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
function withPath(url, path = "/api/auth") {
|
|
307
|
+
assertHasProtocol(url);
|
|
308
|
+
if (checkHasPath(url)) return url;
|
|
309
|
+
const trimmedUrl = url.replace(/\/+$/, "");
|
|
310
|
+
if (!path || path === "/") return trimmedUrl;
|
|
311
|
+
path = path.startsWith("/") ? path : `/${path}`;
|
|
312
|
+
return `${trimmedUrl}${path}`;
|
|
313
|
+
}
|
|
314
|
+
function validateProxyHeader(header, type) {
|
|
315
|
+
if (!header || header.trim() === "") return false;
|
|
316
|
+
if (type === "proto") return header === "http" || header === "https";
|
|
317
|
+
if (type === "host") {
|
|
318
|
+
if ([
|
|
319
|
+
/\.\./,
|
|
320
|
+
/\0/,
|
|
321
|
+
/[\s]/,
|
|
322
|
+
/^[.]/,
|
|
323
|
+
/[<>'"]/,
|
|
324
|
+
/javascript:/i,
|
|
325
|
+
/file:/i,
|
|
326
|
+
/data:/i
|
|
327
|
+
].some((pattern) => pattern.test(header))) return false;
|
|
328
|
+
return /^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*(:[0-9]{1,5})?$/.test(header) || /^(\d{1,3}\.){3}\d{1,3}(:[0-9]{1,5})?$/.test(header) || /^\[[0-9a-fA-F:]+\](:[0-9]{1,5})?$/.test(header) || /^localhost(:[0-9]{1,5})?$/i.test(header);
|
|
329
|
+
}
|
|
330
|
+
return false;
|
|
331
|
+
}
|
|
332
|
+
function getBaseURL(url, path, request, loadEnv, trustedProxyHeaders) {
|
|
333
|
+
if (url) return withPath(url, path);
|
|
334
|
+
if (loadEnv !== false) {
|
|
335
|
+
const fromEnv = env.BETTER_AUTH_URL || env.NEXT_PUBLIC_BETTER_AUTH_URL || env.PUBLIC_BETTER_AUTH_URL || env.NUXT_PUBLIC_BETTER_AUTH_URL || env.NUXT_PUBLIC_AUTH_URL || (env.BASE_URL !== "/" ? env.BASE_URL : void 0);
|
|
336
|
+
if (fromEnv) return withPath(fromEnv, path);
|
|
337
|
+
}
|
|
338
|
+
const fromRequest = request?.headers.get("x-forwarded-host");
|
|
339
|
+
const fromRequestProto = request?.headers.get("x-forwarded-proto");
|
|
340
|
+
if (fromRequest && fromRequestProto && trustedProxyHeaders) {
|
|
341
|
+
if (validateProxyHeader(fromRequestProto, "proto") && validateProxyHeader(fromRequest, "host")) try {
|
|
342
|
+
return withPath(`${fromRequestProto}://${fromRequest}`, path);
|
|
343
|
+
} catch (_error) {
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
if (request) {
|
|
347
|
+
const url$1 = getOrigin(request.url);
|
|
348
|
+
if (!url$1) throw new BetterAuthError("Could not get origin from request. Please provide a valid base URL.");
|
|
349
|
+
return withPath(url$1, path);
|
|
350
|
+
}
|
|
351
|
+
if (typeof window !== "undefined" && window.location) return withPath(window.location.origin, path);
|
|
352
|
+
}
|
|
353
|
+
function getOrigin(url) {
|
|
354
|
+
try {
|
|
355
|
+
const parsedUrl = new URL(url);
|
|
356
|
+
return parsedUrl.origin === "null" ? null : parsedUrl.origin;
|
|
357
|
+
} catch {
|
|
358
|
+
return null;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
// ../../../node_modules/.pnpm/better-auth@1.4.10_drizzle-kit@0.31.8_drizzle-orm@0.45.1_@cloudflare+workers-types@4.20251119_hirg525kbrpwuqvxcih3czaike/node_modules/better-auth/dist/client/fetch-plugins.mjs
|
|
363
|
+
var redirectPlugin = {
|
|
364
|
+
id: "redirect",
|
|
365
|
+
name: "Redirect",
|
|
366
|
+
hooks: { onSuccess(context) {
|
|
367
|
+
if (context.data?.url && context.data?.redirect) {
|
|
368
|
+
if (typeof window !== "undefined" && window.location) {
|
|
369
|
+
if (window.location) try {
|
|
370
|
+
window.location.href = context.data.url;
|
|
371
|
+
} catch {
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
} }
|
|
376
|
+
};
|
|
377
|
+
|
|
378
|
+
// ../../../node_modules/.pnpm/better-auth@1.4.10_drizzle-kit@0.31.8_drizzle-orm@0.45.1_@cloudflare+workers-types@4.20251119_hirg525kbrpwuqvxcih3czaike/node_modules/better-auth/dist/client/parser.mjs
|
|
379
|
+
var PROTO_POLLUTION_PATTERNS = {
|
|
380
|
+
proto: /"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,
|
|
381
|
+
constructor: /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,
|
|
382
|
+
protoShort: /"__proto__"\s*:/,
|
|
383
|
+
constructorShort: /"constructor"\s*:/
|
|
384
|
+
};
|
|
385
|
+
var JSON_SIGNATURE = /^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;
|
|
386
|
+
var SPECIAL_VALUES = {
|
|
387
|
+
true: true,
|
|
388
|
+
false: false,
|
|
389
|
+
null: null,
|
|
390
|
+
undefined: void 0,
|
|
391
|
+
nan: NaN,
|
|
392
|
+
infinity: Number.POSITIVE_INFINITY,
|
|
393
|
+
"-infinity": Number.NEGATIVE_INFINITY
|
|
394
|
+
};
|
|
395
|
+
var ISO_DATE_REGEX = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,7}))?(?:Z|([+-])(\d{2}):(\d{2}))$/;
|
|
396
|
+
function isValidDate(date) {
|
|
397
|
+
return date instanceof Date && !isNaN(date.getTime());
|
|
398
|
+
}
|
|
399
|
+
function parseISODate(value) {
|
|
400
|
+
const match = ISO_DATE_REGEX.exec(value);
|
|
401
|
+
if (!match) return null;
|
|
402
|
+
const [, year, month, day, hour, minute, second, ms, offsetSign, offsetHour, offsetMinute] = match;
|
|
403
|
+
let date = new Date(Date.UTC(parseInt(year, 10), parseInt(month, 10) - 1, parseInt(day, 10), parseInt(hour, 10), parseInt(minute, 10), parseInt(second, 10), ms ? parseInt(ms.padEnd(3, "0"), 10) : 0));
|
|
404
|
+
if (offsetSign) {
|
|
405
|
+
const offset = (parseInt(offsetHour, 10) * 60 + parseInt(offsetMinute, 10)) * (offsetSign === "+" ? -1 : 1);
|
|
406
|
+
date.setUTCMinutes(date.getUTCMinutes() + offset);
|
|
407
|
+
}
|
|
408
|
+
return isValidDate(date) ? date : null;
|
|
409
|
+
}
|
|
410
|
+
function betterJSONParse(value, options = {}) {
|
|
411
|
+
const { strict = false, warnings = false, reviver, parseDates = true } = options;
|
|
412
|
+
if (typeof value !== "string") return value;
|
|
413
|
+
const trimmed = value.trim();
|
|
414
|
+
if (trimmed.length > 0 && trimmed[0] === '"' && trimmed.endsWith('"') && !trimmed.slice(1, -1).includes('"')) return trimmed.slice(1, -1);
|
|
415
|
+
const lowerValue = trimmed.toLowerCase();
|
|
416
|
+
if (lowerValue.length <= 9 && lowerValue in SPECIAL_VALUES) return SPECIAL_VALUES[lowerValue];
|
|
417
|
+
if (!JSON_SIGNATURE.test(trimmed)) {
|
|
418
|
+
if (strict) throw new SyntaxError("[better-json] Invalid JSON");
|
|
419
|
+
return value;
|
|
420
|
+
}
|
|
421
|
+
if (Object.entries(PROTO_POLLUTION_PATTERNS).some(([key, pattern]) => {
|
|
422
|
+
const matches = pattern.test(trimmed);
|
|
423
|
+
if (matches && warnings) console.warn(`[better-json] Detected potential prototype pollution attempt using ${key} pattern`);
|
|
424
|
+
return matches;
|
|
425
|
+
}) && strict) throw new Error("[better-json] Potential prototype pollution attempt detected");
|
|
426
|
+
try {
|
|
427
|
+
const secureReviver = (key, value$1) => {
|
|
428
|
+
if (key === "__proto__" || key === "constructor" && value$1 && typeof value$1 === "object" && "prototype" in value$1) {
|
|
429
|
+
if (warnings) console.warn(`[better-json] Dropping "${key}" key to prevent prototype pollution`);
|
|
430
|
+
return;
|
|
431
|
+
}
|
|
432
|
+
if (parseDates && typeof value$1 === "string") {
|
|
433
|
+
const date = parseISODate(value$1);
|
|
434
|
+
if (date) return date;
|
|
435
|
+
}
|
|
436
|
+
return reviver ? reviver(key, value$1) : value$1;
|
|
437
|
+
};
|
|
438
|
+
return JSON.parse(trimmed, secureReviver);
|
|
439
|
+
} catch (error) {
|
|
440
|
+
if (strict) throw error;
|
|
441
|
+
return value;
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
function parseJSON(value, options = { strict: true }) {
|
|
445
|
+
return betterJSONParse(value, options);
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
// ../../../node_modules/.pnpm/nanostores@1.1.0/node_modules/nanostores/clean-stores/index.js
|
|
449
|
+
var clean = Symbol("clean");
|
|
450
|
+
|
|
451
|
+
// ../../../node_modules/.pnpm/nanostores@1.1.0/node_modules/nanostores/atom/index.js
|
|
452
|
+
var listenerQueue = [];
|
|
453
|
+
var lqIndex = 0;
|
|
454
|
+
var QUEUE_ITEMS_PER_LISTENER = 4;
|
|
455
|
+
var epoch = 0;
|
|
456
|
+
var atom = /* @__NO_SIDE_EFFECTS__ */ (initialValue) => {
|
|
457
|
+
let listeners = [];
|
|
458
|
+
let $atom = {
|
|
459
|
+
get() {
|
|
460
|
+
if (!$atom.lc) {
|
|
461
|
+
$atom.listen(() => {
|
|
462
|
+
})();
|
|
463
|
+
}
|
|
464
|
+
return $atom.value;
|
|
465
|
+
},
|
|
466
|
+
lc: 0,
|
|
467
|
+
listen(listener) {
|
|
468
|
+
$atom.lc = listeners.push(listener);
|
|
469
|
+
return () => {
|
|
470
|
+
for (let i = lqIndex + QUEUE_ITEMS_PER_LISTENER; i < listenerQueue.length; ) {
|
|
471
|
+
if (listenerQueue[i] === listener) {
|
|
472
|
+
listenerQueue.splice(i, QUEUE_ITEMS_PER_LISTENER);
|
|
473
|
+
} else {
|
|
474
|
+
i += QUEUE_ITEMS_PER_LISTENER;
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
let index = listeners.indexOf(listener);
|
|
478
|
+
if (~index) {
|
|
479
|
+
listeners.splice(index, 1);
|
|
480
|
+
if (!--$atom.lc) $atom.off();
|
|
481
|
+
}
|
|
482
|
+
};
|
|
483
|
+
},
|
|
484
|
+
notify(oldValue, changedKey) {
|
|
485
|
+
epoch++;
|
|
486
|
+
let runListenerQueue = !listenerQueue.length;
|
|
487
|
+
for (let listener of listeners) {
|
|
488
|
+
listenerQueue.push(listener, $atom.value, oldValue, changedKey);
|
|
489
|
+
}
|
|
490
|
+
if (runListenerQueue) {
|
|
491
|
+
for (lqIndex = 0; lqIndex < listenerQueue.length; lqIndex += QUEUE_ITEMS_PER_LISTENER) {
|
|
492
|
+
listenerQueue[lqIndex](
|
|
493
|
+
listenerQueue[lqIndex + 1],
|
|
494
|
+
listenerQueue[lqIndex + 2],
|
|
495
|
+
listenerQueue[lqIndex + 3]
|
|
496
|
+
);
|
|
497
|
+
}
|
|
498
|
+
listenerQueue.length = 0;
|
|
499
|
+
}
|
|
500
|
+
},
|
|
501
|
+
/* It will be called on last listener unsubscribing.
|
|
502
|
+
We will redefine it in onMount and onStop. */
|
|
503
|
+
off() {
|
|
504
|
+
},
|
|
505
|
+
set(newValue) {
|
|
506
|
+
let oldValue = $atom.value;
|
|
507
|
+
if (oldValue !== newValue) {
|
|
508
|
+
$atom.value = newValue;
|
|
509
|
+
$atom.notify(oldValue);
|
|
510
|
+
}
|
|
511
|
+
},
|
|
512
|
+
subscribe(listener) {
|
|
513
|
+
let unbind = $atom.listen(listener);
|
|
514
|
+
listener($atom.value);
|
|
515
|
+
return unbind;
|
|
516
|
+
},
|
|
517
|
+
value: initialValue
|
|
518
|
+
};
|
|
519
|
+
if (process.env.NODE_ENV !== "production") {
|
|
520
|
+
$atom[clean] = () => {
|
|
521
|
+
listeners = [];
|
|
522
|
+
$atom.lc = 0;
|
|
523
|
+
$atom.off();
|
|
524
|
+
};
|
|
525
|
+
}
|
|
526
|
+
return $atom;
|
|
527
|
+
};
|
|
528
|
+
|
|
529
|
+
// ../../../node_modules/.pnpm/nanostores@1.1.0/node_modules/nanostores/lifecycle/index.js
|
|
530
|
+
var MOUNT = 5;
|
|
531
|
+
var UNMOUNT = 6;
|
|
532
|
+
var REVERT_MUTATION = 10;
|
|
533
|
+
var on = (object, listener, eventKey, mutateStore) => {
|
|
534
|
+
object.events = object.events || {};
|
|
535
|
+
if (!object.events[eventKey + REVERT_MUTATION]) {
|
|
536
|
+
object.events[eventKey + REVERT_MUTATION] = mutateStore((eventProps) => {
|
|
537
|
+
object.events[eventKey].reduceRight((event, l) => (l(event), event), {
|
|
538
|
+
shared: {},
|
|
539
|
+
...eventProps
|
|
540
|
+
});
|
|
541
|
+
});
|
|
542
|
+
}
|
|
543
|
+
object.events[eventKey] = object.events[eventKey] || [];
|
|
544
|
+
object.events[eventKey].push(listener);
|
|
545
|
+
return () => {
|
|
546
|
+
let currentListeners = object.events[eventKey];
|
|
547
|
+
let index = currentListeners.indexOf(listener);
|
|
548
|
+
currentListeners.splice(index, 1);
|
|
549
|
+
if (!currentListeners.length) {
|
|
550
|
+
delete object.events[eventKey];
|
|
551
|
+
object.events[eventKey + REVERT_MUTATION]();
|
|
552
|
+
delete object.events[eventKey + REVERT_MUTATION];
|
|
553
|
+
}
|
|
554
|
+
};
|
|
555
|
+
};
|
|
556
|
+
var STORE_UNMOUNT_DELAY = 1e3;
|
|
557
|
+
var onMount = ($store, initialize) => {
|
|
558
|
+
let listener = (payload) => {
|
|
559
|
+
let destroy = initialize(payload);
|
|
560
|
+
if (destroy) $store.events[UNMOUNT].push(destroy);
|
|
561
|
+
};
|
|
562
|
+
return on($store, listener, MOUNT, (runListeners) => {
|
|
563
|
+
let originListen = $store.listen;
|
|
564
|
+
$store.listen = (...args) => {
|
|
565
|
+
if (!$store.lc && !$store.active) {
|
|
566
|
+
$store.active = true;
|
|
567
|
+
runListeners();
|
|
568
|
+
}
|
|
569
|
+
return originListen(...args);
|
|
570
|
+
};
|
|
571
|
+
let originOff = $store.off;
|
|
572
|
+
$store.events[UNMOUNT] = [];
|
|
573
|
+
$store.off = () => {
|
|
574
|
+
originOff();
|
|
575
|
+
setTimeout(() => {
|
|
576
|
+
if ($store.active && !$store.lc) {
|
|
577
|
+
$store.active = false;
|
|
578
|
+
for (let destroy of $store.events[UNMOUNT]) destroy();
|
|
579
|
+
$store.events[UNMOUNT] = [];
|
|
580
|
+
}
|
|
581
|
+
}, STORE_UNMOUNT_DELAY);
|
|
582
|
+
};
|
|
583
|
+
if (process.env.NODE_ENV !== "production") {
|
|
584
|
+
let originClean = $store[clean];
|
|
585
|
+
$store[clean] = () => {
|
|
586
|
+
for (let destroy of $store.events[UNMOUNT]) destroy();
|
|
587
|
+
$store.events[UNMOUNT] = [];
|
|
588
|
+
$store.active = false;
|
|
589
|
+
originClean();
|
|
590
|
+
};
|
|
591
|
+
}
|
|
592
|
+
return () => {
|
|
593
|
+
$store.listen = originListen;
|
|
594
|
+
$store.off = originOff;
|
|
595
|
+
};
|
|
596
|
+
});
|
|
597
|
+
};
|
|
598
|
+
|
|
599
|
+
// ../../../node_modules/.pnpm/nanostores@1.1.0/node_modules/nanostores/listen-keys/index.js
|
|
600
|
+
function listenKeys($store, keys, listener) {
|
|
601
|
+
let keysSet = new Set(keys).add(void 0);
|
|
602
|
+
return $store.listen((value, oldValue, changed) => {
|
|
603
|
+
if (keysSet.has(changed)) {
|
|
604
|
+
listener(value, oldValue, changed);
|
|
605
|
+
}
|
|
606
|
+
});
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
// ../../../node_modules/.pnpm/better-auth@1.4.10_drizzle-kit@0.31.8_drizzle-orm@0.45.1_@cloudflare+workers-types@4.20251119_hirg525kbrpwuqvxcih3czaike/node_modules/better-auth/dist/client/query.mjs
|
|
610
|
+
var isServer = () => typeof window === "undefined";
|
|
611
|
+
var useAuthQuery = (initializedAtom, path, $fetch, options) => {
|
|
612
|
+
const value = atom({
|
|
613
|
+
data: null,
|
|
614
|
+
error: null,
|
|
615
|
+
isPending: true,
|
|
616
|
+
isRefetching: false,
|
|
617
|
+
refetch: (queryParams) => fn(queryParams)
|
|
618
|
+
});
|
|
619
|
+
const fn = async (queryParams) => {
|
|
620
|
+
return new Promise((resolve) => {
|
|
621
|
+
const opts = typeof options === "function" ? options({
|
|
622
|
+
data: value.get().data,
|
|
623
|
+
error: value.get().error,
|
|
624
|
+
isPending: value.get().isPending
|
|
625
|
+
}) : options;
|
|
626
|
+
$fetch(path, {
|
|
627
|
+
...opts,
|
|
628
|
+
query: {
|
|
629
|
+
...opts?.query,
|
|
630
|
+
...queryParams?.query
|
|
631
|
+
},
|
|
632
|
+
async onSuccess(context) {
|
|
633
|
+
value.set({
|
|
634
|
+
data: context.data,
|
|
635
|
+
error: null,
|
|
636
|
+
isPending: false,
|
|
637
|
+
isRefetching: false,
|
|
638
|
+
refetch: value.value.refetch
|
|
639
|
+
});
|
|
640
|
+
await opts?.onSuccess?.(context);
|
|
641
|
+
},
|
|
642
|
+
async onError(context) {
|
|
643
|
+
const { request } = context;
|
|
644
|
+
const retryAttempts = typeof request.retry === "number" ? request.retry : request.retry?.attempts;
|
|
645
|
+
const retryAttempt = request.retryAttempt || 0;
|
|
646
|
+
if (retryAttempts && retryAttempt < retryAttempts) return;
|
|
647
|
+
value.set({
|
|
648
|
+
error: context.error,
|
|
649
|
+
data: null,
|
|
650
|
+
isPending: false,
|
|
651
|
+
isRefetching: false,
|
|
652
|
+
refetch: value.value.refetch
|
|
653
|
+
});
|
|
654
|
+
await opts?.onError?.(context);
|
|
655
|
+
},
|
|
656
|
+
async onRequest(context) {
|
|
657
|
+
const currentValue = value.get();
|
|
658
|
+
value.set({
|
|
659
|
+
isPending: currentValue.data === null,
|
|
660
|
+
data: currentValue.data,
|
|
661
|
+
error: null,
|
|
662
|
+
isRefetching: true,
|
|
663
|
+
refetch: value.value.refetch
|
|
664
|
+
});
|
|
665
|
+
await opts?.onRequest?.(context);
|
|
666
|
+
}
|
|
667
|
+
}).catch((error) => {
|
|
668
|
+
value.set({
|
|
669
|
+
error,
|
|
670
|
+
data: null,
|
|
671
|
+
isPending: false,
|
|
672
|
+
isRefetching: false,
|
|
673
|
+
refetch: value.value.refetch
|
|
674
|
+
});
|
|
675
|
+
}).finally(() => {
|
|
676
|
+
resolve(void 0);
|
|
677
|
+
});
|
|
678
|
+
});
|
|
679
|
+
};
|
|
680
|
+
initializedAtom = Array.isArray(initializedAtom) ? initializedAtom : [initializedAtom];
|
|
681
|
+
let isMounted = false;
|
|
682
|
+
for (const initAtom of initializedAtom) initAtom.subscribe(async () => {
|
|
683
|
+
if (isServer()) return;
|
|
684
|
+
if (isMounted) await fn();
|
|
685
|
+
else onMount(value, () => {
|
|
686
|
+
const timeoutId = setTimeout(async () => {
|
|
687
|
+
if (!isMounted) {
|
|
688
|
+
await fn();
|
|
689
|
+
isMounted = true;
|
|
690
|
+
}
|
|
691
|
+
}, 0);
|
|
692
|
+
return () => {
|
|
693
|
+
value.off();
|
|
694
|
+
initAtom.off();
|
|
695
|
+
clearTimeout(timeoutId);
|
|
696
|
+
};
|
|
697
|
+
});
|
|
698
|
+
});
|
|
699
|
+
return value;
|
|
700
|
+
};
|
|
701
|
+
|
|
702
|
+
// ../../../node_modules/.pnpm/better-auth@1.4.10_drizzle-kit@0.31.8_drizzle-orm@0.45.1_@cloudflare+workers-types@4.20251119_hirg525kbrpwuqvxcih3czaike/node_modules/better-auth/dist/client/broadcast-channel.mjs
|
|
703
|
+
var kBroadcastChannel = Symbol.for("better-auth:broadcast-channel");
|
|
704
|
+
var now = () => Math.floor(Date.now() / 1e3);
|
|
705
|
+
var WindowBroadcastChannel = class {
|
|
706
|
+
constructor(name = "better-auth.message") {
|
|
707
|
+
__publicField(this, "listeners", /* @__PURE__ */ new Set());
|
|
708
|
+
__publicField(this, "name");
|
|
709
|
+
this.name = name;
|
|
710
|
+
}
|
|
711
|
+
subscribe(listener) {
|
|
712
|
+
this.listeners.add(listener);
|
|
713
|
+
return () => {
|
|
714
|
+
this.listeners.delete(listener);
|
|
715
|
+
};
|
|
716
|
+
}
|
|
717
|
+
post(message) {
|
|
718
|
+
if (typeof window === "undefined") return;
|
|
719
|
+
try {
|
|
720
|
+
localStorage.setItem(this.name, JSON.stringify({
|
|
721
|
+
...message,
|
|
722
|
+
timestamp: now()
|
|
723
|
+
}));
|
|
724
|
+
} catch {
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
setup() {
|
|
728
|
+
if (typeof window === "undefined" || typeof window.addEventListener === "undefined") return () => {
|
|
729
|
+
};
|
|
730
|
+
const handler = (event) => {
|
|
731
|
+
if (event.key !== this.name) return;
|
|
732
|
+
const message = JSON.parse(event.newValue ?? "{}");
|
|
733
|
+
if (message?.event !== "session" || !message?.data) return;
|
|
734
|
+
this.listeners.forEach((listener) => listener(message));
|
|
735
|
+
};
|
|
736
|
+
window.addEventListener("storage", handler);
|
|
737
|
+
return () => {
|
|
738
|
+
window.removeEventListener("storage", handler);
|
|
739
|
+
};
|
|
740
|
+
}
|
|
741
|
+
};
|
|
742
|
+
function getGlobalBroadcastChannel(name = "better-auth.message") {
|
|
743
|
+
if (!globalThis[kBroadcastChannel]) globalThis[kBroadcastChannel] = new WindowBroadcastChannel(name);
|
|
744
|
+
return globalThis[kBroadcastChannel];
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
// ../../../node_modules/.pnpm/better-auth@1.4.10_drizzle-kit@0.31.8_drizzle-orm@0.45.1_@cloudflare+workers-types@4.20251119_hirg525kbrpwuqvxcih3czaike/node_modules/better-auth/dist/client/focus-manager.mjs
|
|
748
|
+
var kFocusManager = Symbol.for("better-auth:focus-manager");
|
|
749
|
+
var WindowFocusManager = class {
|
|
750
|
+
constructor() {
|
|
751
|
+
__publicField(this, "listeners", /* @__PURE__ */ new Set());
|
|
752
|
+
}
|
|
753
|
+
subscribe(listener) {
|
|
754
|
+
this.listeners.add(listener);
|
|
755
|
+
return () => {
|
|
756
|
+
this.listeners.delete(listener);
|
|
757
|
+
};
|
|
758
|
+
}
|
|
759
|
+
setFocused(focused) {
|
|
760
|
+
this.listeners.forEach((listener) => listener(focused));
|
|
761
|
+
}
|
|
762
|
+
setup() {
|
|
763
|
+
if (typeof window === "undefined" || typeof document === "undefined" || typeof window.addEventListener === "undefined") return () => {
|
|
764
|
+
};
|
|
765
|
+
const visibilityHandler = () => {
|
|
766
|
+
if (document.visibilityState === "visible") this.setFocused(true);
|
|
767
|
+
};
|
|
768
|
+
document.addEventListener("visibilitychange", visibilityHandler, false);
|
|
769
|
+
return () => {
|
|
770
|
+
document.removeEventListener("visibilitychange", visibilityHandler, false);
|
|
771
|
+
};
|
|
772
|
+
}
|
|
773
|
+
};
|
|
774
|
+
function getGlobalFocusManager() {
|
|
775
|
+
if (!globalThis[kFocusManager]) globalThis[kFocusManager] = new WindowFocusManager();
|
|
776
|
+
return globalThis[kFocusManager];
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
// ../../../node_modules/.pnpm/better-auth@1.4.10_drizzle-kit@0.31.8_drizzle-orm@0.45.1_@cloudflare+workers-types@4.20251119_hirg525kbrpwuqvxcih3czaike/node_modules/better-auth/dist/client/online-manager.mjs
|
|
780
|
+
var kOnlineManager = Symbol.for("better-auth:online-manager");
|
|
781
|
+
var WindowOnlineManager = class {
|
|
782
|
+
constructor() {
|
|
783
|
+
__publicField(this, "listeners", /* @__PURE__ */ new Set());
|
|
784
|
+
__publicField(this, "isOnline", typeof navigator !== "undefined" ? navigator.onLine : true);
|
|
785
|
+
}
|
|
786
|
+
subscribe(listener) {
|
|
787
|
+
this.listeners.add(listener);
|
|
788
|
+
return () => {
|
|
789
|
+
this.listeners.delete(listener);
|
|
790
|
+
};
|
|
791
|
+
}
|
|
792
|
+
setOnline(online) {
|
|
793
|
+
this.isOnline = online;
|
|
794
|
+
this.listeners.forEach((listener) => listener(online));
|
|
795
|
+
}
|
|
796
|
+
setup() {
|
|
797
|
+
if (typeof window === "undefined" || typeof window.addEventListener === "undefined") return () => {
|
|
798
|
+
};
|
|
799
|
+
const onOnline = () => this.setOnline(true);
|
|
800
|
+
const onOffline = () => this.setOnline(false);
|
|
801
|
+
window.addEventListener("online", onOnline, false);
|
|
802
|
+
window.addEventListener("offline", onOffline, false);
|
|
803
|
+
return () => {
|
|
804
|
+
window.removeEventListener("online", onOnline, false);
|
|
805
|
+
window.removeEventListener("offline", onOffline, false);
|
|
806
|
+
};
|
|
807
|
+
}
|
|
808
|
+
};
|
|
809
|
+
function getGlobalOnlineManager() {
|
|
810
|
+
if (!globalThis[kOnlineManager]) globalThis[kOnlineManager] = new WindowOnlineManager();
|
|
811
|
+
return globalThis[kOnlineManager];
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
// ../../../node_modules/.pnpm/better-auth@1.4.10_drizzle-kit@0.31.8_drizzle-orm@0.45.1_@cloudflare+workers-types@4.20251119_hirg525kbrpwuqvxcih3czaike/node_modules/better-auth/dist/client/session-refresh.mjs
|
|
815
|
+
var now2 = () => Math.floor(Date.now() / 1e3);
|
|
816
|
+
var FOCUS_REFETCH_RATE_LIMIT_SECONDS = 5;
|
|
817
|
+
function createSessionRefreshManager(opts) {
|
|
818
|
+
const { sessionAtom, sessionSignal, $fetch, options = {} } = opts;
|
|
819
|
+
const refetchInterval = options.sessionOptions?.refetchInterval ?? 0;
|
|
820
|
+
const refetchOnWindowFocus = options.sessionOptions?.refetchOnWindowFocus ?? true;
|
|
821
|
+
const refetchWhenOffline = options.sessionOptions?.refetchWhenOffline ?? false;
|
|
822
|
+
const state = {
|
|
823
|
+
lastSync: 0,
|
|
824
|
+
lastSessionRequest: 0,
|
|
825
|
+
cachedSession: void 0
|
|
826
|
+
};
|
|
827
|
+
const shouldRefetch = () => {
|
|
828
|
+
return refetchWhenOffline || getGlobalOnlineManager().isOnline;
|
|
829
|
+
};
|
|
830
|
+
const triggerRefetch = (event) => {
|
|
831
|
+
if (!shouldRefetch()) return;
|
|
832
|
+
if (event?.event === "storage") {
|
|
833
|
+
state.lastSync = now2();
|
|
834
|
+
sessionSignal.set(!sessionSignal.get());
|
|
835
|
+
return;
|
|
836
|
+
}
|
|
837
|
+
const currentSession = sessionAtom.get();
|
|
838
|
+
if (event?.event === "poll") {
|
|
839
|
+
state.lastSessionRequest = now2();
|
|
840
|
+
$fetch("/get-session").then((res) => {
|
|
841
|
+
if (res.error) sessionAtom.set({
|
|
842
|
+
...currentSession,
|
|
843
|
+
data: null,
|
|
844
|
+
error: res.error
|
|
845
|
+
});
|
|
846
|
+
else sessionAtom.set({
|
|
847
|
+
...currentSession,
|
|
848
|
+
data: res.data,
|
|
849
|
+
error: null
|
|
850
|
+
});
|
|
851
|
+
state.lastSync = now2();
|
|
852
|
+
sessionSignal.set(!sessionSignal.get());
|
|
853
|
+
}).catch(() => {
|
|
854
|
+
});
|
|
855
|
+
return;
|
|
856
|
+
}
|
|
857
|
+
if (event?.event === "visibilitychange") {
|
|
858
|
+
if (now2() - state.lastSessionRequest < FOCUS_REFETCH_RATE_LIMIT_SECONDS) return;
|
|
859
|
+
state.lastSessionRequest = now2();
|
|
860
|
+
}
|
|
861
|
+
if (currentSession?.data === null || currentSession?.data === void 0 || event?.event === "visibilitychange") {
|
|
862
|
+
state.lastSync = now2();
|
|
863
|
+
sessionSignal.set(!sessionSignal.get());
|
|
864
|
+
}
|
|
865
|
+
};
|
|
866
|
+
const broadcastSessionUpdate = (trigger) => {
|
|
867
|
+
getGlobalBroadcastChannel().post({
|
|
868
|
+
event: "session",
|
|
869
|
+
data: { trigger },
|
|
870
|
+
clientId: Math.random().toString(36).substring(7)
|
|
871
|
+
});
|
|
872
|
+
};
|
|
873
|
+
const setupPolling = () => {
|
|
874
|
+
if (refetchInterval && refetchInterval > 0) state.pollInterval = setInterval(() => {
|
|
875
|
+
if (sessionAtom.get()?.data) triggerRefetch({ event: "poll" });
|
|
876
|
+
}, refetchInterval * 1e3);
|
|
877
|
+
};
|
|
878
|
+
const setupBroadcast = () => {
|
|
879
|
+
state.unsubscribeBroadcast = getGlobalBroadcastChannel().subscribe(() => {
|
|
880
|
+
triggerRefetch({ event: "storage" });
|
|
881
|
+
});
|
|
882
|
+
};
|
|
883
|
+
const setupFocusRefetch = () => {
|
|
884
|
+
if (!refetchOnWindowFocus) return;
|
|
885
|
+
state.unsubscribeFocus = getGlobalFocusManager().subscribe(() => {
|
|
886
|
+
triggerRefetch({ event: "visibilitychange" });
|
|
887
|
+
});
|
|
888
|
+
};
|
|
889
|
+
const setupOnlineRefetch = () => {
|
|
890
|
+
state.unsubscribeOnline = getGlobalOnlineManager().subscribe((online) => {
|
|
891
|
+
if (online) triggerRefetch({ event: "visibilitychange" });
|
|
892
|
+
});
|
|
893
|
+
};
|
|
894
|
+
const init = () => {
|
|
895
|
+
setupPolling();
|
|
896
|
+
setupBroadcast();
|
|
897
|
+
setupFocusRefetch();
|
|
898
|
+
setupOnlineRefetch();
|
|
899
|
+
getGlobalBroadcastChannel().setup();
|
|
900
|
+
getGlobalFocusManager().setup();
|
|
901
|
+
getGlobalOnlineManager().setup();
|
|
902
|
+
};
|
|
903
|
+
const cleanup = () => {
|
|
904
|
+
if (state.pollInterval) {
|
|
905
|
+
clearInterval(state.pollInterval);
|
|
906
|
+
state.pollInterval = void 0;
|
|
907
|
+
}
|
|
908
|
+
if (state.unsubscribeBroadcast) {
|
|
909
|
+
state.unsubscribeBroadcast();
|
|
910
|
+
state.unsubscribeBroadcast = void 0;
|
|
911
|
+
}
|
|
912
|
+
if (state.unsubscribeFocus) {
|
|
913
|
+
state.unsubscribeFocus();
|
|
914
|
+
state.unsubscribeFocus = void 0;
|
|
915
|
+
}
|
|
916
|
+
if (state.unsubscribeOnline) {
|
|
917
|
+
state.unsubscribeOnline();
|
|
918
|
+
state.unsubscribeOnline = void 0;
|
|
919
|
+
}
|
|
920
|
+
state.lastSync = 0;
|
|
921
|
+
state.lastSessionRequest = 0;
|
|
922
|
+
state.cachedSession = void 0;
|
|
923
|
+
};
|
|
924
|
+
return {
|
|
925
|
+
init,
|
|
926
|
+
cleanup,
|
|
927
|
+
triggerRefetch,
|
|
928
|
+
broadcastSessionUpdate
|
|
929
|
+
};
|
|
930
|
+
}
|
|
931
|
+
|
|
932
|
+
// ../../../node_modules/.pnpm/better-auth@1.4.10_drizzle-kit@0.31.8_drizzle-orm@0.45.1_@cloudflare+workers-types@4.20251119_hirg525kbrpwuqvxcih3czaike/node_modules/better-auth/dist/client/session-atom.mjs
|
|
933
|
+
function getSessionAtom($fetch, options) {
|
|
934
|
+
const $signal = atom(false);
|
|
935
|
+
const session = useAuthQuery($signal, "/get-session", $fetch, { method: "GET" });
|
|
936
|
+
onMount(session, () => {
|
|
937
|
+
const refreshManager = createSessionRefreshManager({
|
|
938
|
+
sessionAtom: session,
|
|
939
|
+
sessionSignal: $signal,
|
|
940
|
+
$fetch,
|
|
941
|
+
options
|
|
942
|
+
});
|
|
943
|
+
refreshManager.init();
|
|
944
|
+
return () => {
|
|
945
|
+
refreshManager.cleanup();
|
|
946
|
+
};
|
|
947
|
+
});
|
|
948
|
+
return {
|
|
949
|
+
session,
|
|
950
|
+
$sessionSignal: $signal
|
|
951
|
+
};
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
// ../../../node_modules/.pnpm/better-auth@1.4.10_drizzle-kit@0.31.8_drizzle-orm@0.45.1_@cloudflare+workers-types@4.20251119_hirg525kbrpwuqvxcih3czaike/node_modules/better-auth/dist/client/config.mjs
|
|
955
|
+
import { createFetch } from "@better-fetch/fetch";
|
|
956
|
+
var getClientConfig = (options, loadEnv) => {
|
|
957
|
+
const isCredentialsSupported = "credentials" in Request.prototype;
|
|
958
|
+
const baseURL = getBaseURL(options?.baseURL, options?.basePath, void 0, loadEnv) ?? "/api/auth";
|
|
959
|
+
const pluginsFetchPlugins = options?.plugins?.flatMap((plugin) => plugin.fetchPlugins).filter((pl) => pl !== void 0) || [];
|
|
960
|
+
const lifeCyclePlugin = {
|
|
961
|
+
id: "lifecycle-hooks",
|
|
962
|
+
name: "lifecycle-hooks",
|
|
963
|
+
hooks: {
|
|
964
|
+
onSuccess: options?.fetchOptions?.onSuccess,
|
|
965
|
+
onError: options?.fetchOptions?.onError,
|
|
966
|
+
onRequest: options?.fetchOptions?.onRequest,
|
|
967
|
+
onResponse: options?.fetchOptions?.onResponse
|
|
968
|
+
}
|
|
969
|
+
};
|
|
970
|
+
const { onSuccess: _onSuccess, onError: _onError, onRequest: _onRequest, onResponse: _onResponse, ...restOfFetchOptions } = options?.fetchOptions || {};
|
|
971
|
+
const $fetch = createFetch({
|
|
972
|
+
baseURL,
|
|
973
|
+
...isCredentialsSupported ? { credentials: "include" } : {},
|
|
974
|
+
method: "GET",
|
|
975
|
+
jsonParser(text) {
|
|
976
|
+
if (!text) return null;
|
|
977
|
+
return parseJSON(text, { strict: false });
|
|
978
|
+
},
|
|
979
|
+
customFetchImpl: fetch,
|
|
980
|
+
...restOfFetchOptions,
|
|
981
|
+
plugins: [
|
|
982
|
+
lifeCyclePlugin,
|
|
983
|
+
...restOfFetchOptions.plugins || [],
|
|
984
|
+
...options?.disableDefaultFetchPlugins ? [] : [redirectPlugin],
|
|
985
|
+
...pluginsFetchPlugins
|
|
986
|
+
]
|
|
987
|
+
});
|
|
988
|
+
const { $sessionSignal, session } = getSessionAtom($fetch, options);
|
|
989
|
+
const plugins = options?.plugins || [];
|
|
990
|
+
let pluginsActions = {};
|
|
991
|
+
let pluginsAtoms = {
|
|
992
|
+
$sessionSignal,
|
|
993
|
+
session
|
|
994
|
+
};
|
|
995
|
+
let pluginPathMethods = {
|
|
996
|
+
"/sign-out": "POST",
|
|
997
|
+
"/revoke-sessions": "POST",
|
|
998
|
+
"/revoke-other-sessions": "POST",
|
|
999
|
+
"/delete-user": "POST"
|
|
1000
|
+
};
|
|
1001
|
+
const atomListeners = [{
|
|
1002
|
+
signal: "$sessionSignal",
|
|
1003
|
+
matcher(path) {
|
|
1004
|
+
return path === "/sign-out" || path === "/update-user" || path === "/sign-up/email" || path === "/sign-in/email" || path === "/delete-user" || path === "/verify-email" || path === "/revoke-sessions" || path === "/revoke-session" || path === "/change-email";
|
|
1005
|
+
}
|
|
1006
|
+
}];
|
|
1007
|
+
for (const plugin of plugins) {
|
|
1008
|
+
if (plugin.getAtoms) Object.assign(pluginsAtoms, plugin.getAtoms?.($fetch));
|
|
1009
|
+
if (plugin.pathMethods) Object.assign(pluginPathMethods, plugin.pathMethods);
|
|
1010
|
+
if (plugin.atomListeners) atomListeners.push(...plugin.atomListeners);
|
|
1011
|
+
}
|
|
1012
|
+
const $store = {
|
|
1013
|
+
notify: (signal) => {
|
|
1014
|
+
pluginsAtoms[signal].set(!pluginsAtoms[signal].get());
|
|
1015
|
+
},
|
|
1016
|
+
listen: (signal, listener) => {
|
|
1017
|
+
pluginsAtoms[signal].subscribe(listener);
|
|
1018
|
+
},
|
|
1019
|
+
atoms: pluginsAtoms
|
|
1020
|
+
};
|
|
1021
|
+
for (const plugin of plugins) if (plugin.getActions) Object.assign(pluginsActions, plugin.getActions?.($fetch, $store, options));
|
|
1022
|
+
return {
|
|
1023
|
+
get baseURL() {
|
|
1024
|
+
return baseURL;
|
|
1025
|
+
},
|
|
1026
|
+
pluginsActions,
|
|
1027
|
+
pluginsAtoms,
|
|
1028
|
+
pluginPathMethods,
|
|
1029
|
+
atomListeners,
|
|
1030
|
+
$fetch,
|
|
1031
|
+
$store
|
|
1032
|
+
};
|
|
1033
|
+
};
|
|
1034
|
+
|
|
1035
|
+
// ../../../node_modules/.pnpm/better-auth@1.4.10_drizzle-kit@0.31.8_drizzle-orm@0.45.1_@cloudflare+workers-types@4.20251119_hirg525kbrpwuqvxcih3czaike/node_modules/better-auth/dist/utils/is-atom.mjs
|
|
1036
|
+
function isAtom(value) {
|
|
1037
|
+
return typeof value === "object" && value !== null && "get" in value && typeof value.get === "function" && "lc" in value && typeof value.lc === "number";
|
|
1038
|
+
}
|
|
1039
|
+
|
|
1040
|
+
// ../../../node_modules/.pnpm/better-auth@1.4.10_drizzle-kit@0.31.8_drizzle-orm@0.45.1_@cloudflare+workers-types@4.20251119_hirg525kbrpwuqvxcih3czaike/node_modules/better-auth/dist/client/proxy.mjs
|
|
1041
|
+
function getMethod(path, knownPathMethods, args) {
|
|
1042
|
+
const method = knownPathMethods[path];
|
|
1043
|
+
const { fetchOptions, query: _query, ...body } = args || {};
|
|
1044
|
+
if (method) return method;
|
|
1045
|
+
if (fetchOptions?.method) return fetchOptions.method;
|
|
1046
|
+
if (body && Object.keys(body).length > 0) return "POST";
|
|
1047
|
+
return "GET";
|
|
1048
|
+
}
|
|
1049
|
+
function createDynamicPathProxy(routes, client, knownPathMethods, atoms, atomListeners) {
|
|
1050
|
+
function createProxy(path = []) {
|
|
1051
|
+
return new Proxy(function() {
|
|
1052
|
+
}, {
|
|
1053
|
+
get(_, prop) {
|
|
1054
|
+
if (typeof prop !== "string") return;
|
|
1055
|
+
if (prop === "then" || prop === "catch" || prop === "finally") return;
|
|
1056
|
+
const fullPath = [...path, prop];
|
|
1057
|
+
let current = routes;
|
|
1058
|
+
for (const segment of fullPath) if (current && typeof current === "object" && segment in current) current = current[segment];
|
|
1059
|
+
else {
|
|
1060
|
+
current = void 0;
|
|
1061
|
+
break;
|
|
1062
|
+
}
|
|
1063
|
+
if (typeof current === "function") return current;
|
|
1064
|
+
if (isAtom(current)) return current;
|
|
1065
|
+
return createProxy(fullPath);
|
|
1066
|
+
},
|
|
1067
|
+
apply: async (_, __, args) => {
|
|
1068
|
+
const routePath = "/" + path.map((segment) => segment.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`)).join("/");
|
|
1069
|
+
const arg = args[0] || {};
|
|
1070
|
+
const fetchOptions = args[1] || {};
|
|
1071
|
+
const { query, fetchOptions: argFetchOptions, ...body } = arg;
|
|
1072
|
+
const options = {
|
|
1073
|
+
...fetchOptions,
|
|
1074
|
+
...argFetchOptions
|
|
1075
|
+
};
|
|
1076
|
+
const method = getMethod(routePath, knownPathMethods, arg);
|
|
1077
|
+
return await client(routePath, {
|
|
1078
|
+
...options,
|
|
1079
|
+
body: method === "GET" ? void 0 : {
|
|
1080
|
+
...body,
|
|
1081
|
+
...options?.body || {}
|
|
1082
|
+
},
|
|
1083
|
+
query: query || options?.query,
|
|
1084
|
+
method,
|
|
1085
|
+
async onSuccess(context) {
|
|
1086
|
+
await options?.onSuccess?.(context);
|
|
1087
|
+
if (!atomListeners || options.disableSignal) return;
|
|
1088
|
+
const matches = atomListeners.filter((s) => s.matcher(routePath));
|
|
1089
|
+
if (!matches.length) return;
|
|
1090
|
+
const visited = /* @__PURE__ */ new Set();
|
|
1091
|
+
for (const match of matches) {
|
|
1092
|
+
const signal = atoms[match.signal];
|
|
1093
|
+
if (!signal) return;
|
|
1094
|
+
if (visited.has(match.signal)) continue;
|
|
1095
|
+
visited.add(match.signal);
|
|
1096
|
+
const val = signal.get();
|
|
1097
|
+
setTimeout(() => {
|
|
1098
|
+
signal.set(!val);
|
|
1099
|
+
}, 10);
|
|
1100
|
+
}
|
|
1101
|
+
}
|
|
1102
|
+
});
|
|
1103
|
+
}
|
|
1104
|
+
});
|
|
1105
|
+
}
|
|
1106
|
+
return createProxy();
|
|
1107
|
+
}
|
|
1108
|
+
|
|
1109
|
+
// ../../../node_modules/.pnpm/better-auth@1.4.10_drizzle-kit@0.31.8_drizzle-orm@0.45.1_@cloudflare+workers-types@4.20251119_hirg525kbrpwuqvxcih3czaike/node_modules/better-auth/dist/client/react/react-store.mjs
|
|
1110
|
+
import { useCallback, useRef, useSyncExternalStore } from "react";
|
|
1111
|
+
function useStore(store, options = {}) {
|
|
1112
|
+
let snapshotRef = useRef(store.get());
|
|
1113
|
+
const { keys, deps = [store, keys] } = options;
|
|
1114
|
+
let subscribe = useCallback((onChange) => {
|
|
1115
|
+
const emitChange = (value) => {
|
|
1116
|
+
if (snapshotRef.current === value) return;
|
|
1117
|
+
snapshotRef.current = value;
|
|
1118
|
+
onChange();
|
|
1119
|
+
};
|
|
1120
|
+
emitChange(store.value);
|
|
1121
|
+
if (keys?.length) return listenKeys(store, keys, emitChange);
|
|
1122
|
+
return store.listen(emitChange);
|
|
1123
|
+
}, deps);
|
|
1124
|
+
let get = () => snapshotRef.current;
|
|
1125
|
+
return useSyncExternalStore(subscribe, get, get);
|
|
1126
|
+
}
|
|
1127
|
+
|
|
1128
|
+
// ../../../node_modules/.pnpm/better-auth@1.4.10_drizzle-kit@0.31.8_drizzle-orm@0.45.1_@cloudflare+workers-types@4.20251119_hirg525kbrpwuqvxcih3czaike/node_modules/better-auth/dist/client/react/index.mjs
|
|
1129
|
+
function getAtomKey(str) {
|
|
1130
|
+
return `use${capitalizeFirstLetter(str)}`;
|
|
1131
|
+
}
|
|
1132
|
+
function createAuthClient(options) {
|
|
1133
|
+
const { pluginPathMethods, pluginsActions, pluginsAtoms, $fetch, $store, atomListeners } = getClientConfig(options);
|
|
1134
|
+
let resolvedHooks = {};
|
|
1135
|
+
for (const [key, value] of Object.entries(pluginsAtoms)) resolvedHooks[getAtomKey(key)] = () => useStore(value);
|
|
1136
|
+
return createDynamicPathProxy({
|
|
1137
|
+
...pluginsActions,
|
|
1138
|
+
...resolvedHooks,
|
|
1139
|
+
$fetch,
|
|
1140
|
+
$store
|
|
1141
|
+
}, $fetch, pluginPathMethods, pluginsAtoms, atomListeners);
|
|
1142
|
+
}
|
|
1143
|
+
|
|
1144
|
+
export {
|
|
1145
|
+
BetterAuthError,
|
|
1146
|
+
atom,
|
|
1147
|
+
useAuthQuery,
|
|
1148
|
+
createAuthClient
|
|
1149
|
+
};
|
|
1150
|
+
//# sourceMappingURL=chunk-Y3WVYSUI.mjs.map
|