@neondatabase/auth 0.1.0-beta.2 → 0.1.0-beta.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/README.md +112 -18
  2. package/dist/{adapter-core-C12KoaiU.d.mts → adapter-core-23fYTUxT.d.mts} +175 -627
  3. package/dist/{adapter-core-BDOw-gBC.mjs → adapter-core-8s6XdCco.mjs} +392 -69
  4. package/dist/{better-auth-react-adapter-FnBHa2nr.mjs → better-auth-react-adapter-D9tIaEyQ.mjs} +10 -8
  5. package/dist/better-auth-react-adapter-QFe5RtaM.d.mts +2170 -0
  6. package/dist/better-auth-types-BUiggBfa.d.mts +9 -0
  7. package/dist/chunk-VCZJYX65-CLnrj1o7-D6ZQkcc_.mjs +543 -0
  8. package/dist/constants-2bpp2_-f.mjs +30 -0
  9. package/dist/index-Bga0CzOO.d.mts +49 -0
  10. package/dist/index.d.mts +5 -98
  11. package/dist/index.mjs +2 -1
  12. package/dist/middleware-C7jHeulu.mjs +303 -0
  13. package/dist/{neon-auth-C9XTFffv.mjs → neon-auth-2f58U8_-.mjs} +7 -4
  14. package/dist/neon-auth-CDYpC_O1.d.mts +107 -0
  15. package/dist/next/index.d.mts +139 -303
  16. package/dist/next/index.mjs +37 -174
  17. package/dist/next/server/index.d.mts +389 -0
  18. package/dist/next/server/index.mjs +432 -0
  19. package/dist/react/adapters/index.d.mts +5 -4
  20. package/dist/react/adapters/index.mjs +2 -1
  21. package/dist/react/index.d.mts +6 -5
  22. package/dist/react/index.mjs +5 -92
  23. package/dist/react/ui/index.d.mts +1 -1
  24. package/dist/react/ui/index.mjs +3 -91
  25. package/dist/react/ui/server.mjs +1 -1
  26. package/dist/{supabase-adapter-ggmqWgPe.mjs → supabase-adapter-BYMJSxOT.mjs} +72 -167
  27. package/dist/supabase-adapter-Dr-pKvPt.d.mts +2258 -0
  28. package/dist/types/index.d.mts +4 -0
  29. package/dist/types/index.mjs +3 -0
  30. package/dist/ui/.safelist.html +3 -0
  31. package/dist/ui/css.css +2 -2
  32. package/dist/ui/tailwind.css +3 -2
  33. package/dist/ui/theme-inline.css +39 -0
  34. package/dist/ui/theme.css +125 -49
  35. package/dist/ui-Cg1EZzGG.mjs +12104 -0
  36. package/dist/vanilla/adapters/index.d.mts +4 -3
  37. package/dist/vanilla/adapters/index.mjs +2 -1
  38. package/dist/vanilla/index.d.mts +4 -3
  39. package/dist/vanilla/index.mjs +2 -1
  40. package/llms.txt +172 -0
  41. package/package.json +21 -10
  42. package/dist/better-auth-react-adapter-BXL48HIU.d.mts +0 -722
  43. package/dist/supabase-adapter-crabDnl2.d.mts +0 -128
  44. package/dist/ui-CNFBSekF.mjs +0 -401
  45. /package/dist/{adapters-Dkx0zoMR.mjs → adapters-B7YKkjaL.mjs} +0 -0
  46. /package/dist/{index-C-svZlpj.d.mts → index-BHI9uOzY.d.mts} +0 -0
  47. /package/dist/{index-DuDD6cIY.d.mts → index-CSe4aQIZ.d.mts} +0 -0
  48. /package/dist/{index-UW23fDSn.d.mts → index-LhFpnU-f.d.mts} +0 -0
@@ -1,128 +0,0 @@
1
- import { n as NeonAuthAdapterCoreAuthOptions, t as NeonAuthAdapterCore } from "./adapter-core-C12KoaiU.mjs";
2
- import { AuthClient, BetterAuthClientOptions } from "better-auth/client";
3
- import * as _supabase_auth_js0 from "@supabase/auth-js";
4
- import { AuthClient as AuthClient$1, JwtHeader, JwtPayload } from "@supabase/auth-js";
5
-
6
- //#region src/adapters/better-auth-vanilla/better-auth-vanilla-adapter.d.ts
7
- type BetterAuthVanillaAdapterOptions = Omit<NeonAuthAdapterCoreAuthOptions, 'baseURL'>;
8
- /**
9
- * Internal implementation class - use BetterAuthVanillaAdapter factory function instead
10
- */
11
- declare class BetterAuthVanillaAdapterImpl extends NeonAuthAdapterCore {
12
- private _betterAuth;
13
- constructor(betterAuthClientOptions: NeonAuthAdapterCoreAuthOptions);
14
- getBetterAuthInstance(): AuthClient<BetterAuthClientOptions>;
15
- getJWTToken(): Promise<string | null>;
16
- }
17
- /** Instance type for BetterAuthVanillaAdapter */
18
- type BetterAuthVanillaAdapterInstance = BetterAuthVanillaAdapterImpl;
19
- /** Builder type that creates adapter instances */
20
- type BetterAuthVanillaAdapterBuilder = (url: string) => BetterAuthVanillaAdapterInstance;
21
- /**
22
- * Factory function that returns an adapter builder.
23
- * The builder is called by createClient/createAuthClient with the URL.
24
- *
25
- * @param options - Optional adapter configuration (baseURL is injected separately)
26
- * @returns A builder function that creates the adapter instance
27
- *
28
- * @example
29
- * ```typescript
30
- * const client = createClient({
31
- * auth: {
32
- * url: 'https://auth.example.com',
33
- * adapter: BetterAuthVanillaAdapter(),
34
- * },
35
- * dataApi: { url: 'https://data-api.example.com' },
36
- * });
37
- * ```
38
- */
39
- declare function BetterAuthVanillaAdapter(options?: BetterAuthVanillaAdapterOptions): BetterAuthVanillaAdapterBuilder;
40
- //#endregion
41
- //#region src/adapters/supabase/auth-interface.d.ts
42
- type _UpstreamAuthClientInstance = InstanceType<typeof AuthClient$1>;
43
- type _AuthClientBase = { [K in keyof _UpstreamAuthClientInstance as _UpstreamAuthClientInstance[K] extends never ? never : K]: _UpstreamAuthClientInstance[K] };
44
- type SupabaseAuthClientInterface = _AuthClientBase;
45
- //#endregion
46
- //#region src/adapters/supabase/supabase-adapter.d.ts
47
- type SupabaseAuthAdapterOptions = Omit<NeonAuthAdapterCoreAuthOptions, 'baseURL'>;
48
- /**
49
- * Internal implementation class - use SupabaseAuthAdapter factory function instead
50
- */
51
- declare class SupabaseAuthAdapterImpl extends NeonAuthAdapterCore implements SupabaseAuthClientInterface {
52
- admin: SupabaseAuthClientInterface['admin'];
53
- mfa: SupabaseAuthClientInterface['mfa'];
54
- oauth: SupabaseAuthClientInterface['oauth'];
55
- private _betterAuth;
56
- private _stateChangeEmitters;
57
- constructor(betterAuthClientOptions: NeonAuthAdapterCoreAuthOptions);
58
- getBetterAuthInstance(): AuthClient<BetterAuthClientOptions>;
59
- getJWTToken(): Promise<string | null>;
60
- initialize: SupabaseAuthClientInterface['initialize'];
61
- getSession(options?: {
62
- forceFetch?: boolean;
63
- }): ReturnType<SupabaseAuthClientInterface['getSession']>;
64
- refreshSession: SupabaseAuthClientInterface['refreshSession'];
65
- setSession: SupabaseAuthClientInterface['setSession'];
66
- signUp: SupabaseAuthClientInterface['signUp'];
67
- signInAnonymously: SupabaseAuthClientInterface['signInAnonymously'];
68
- signInWithPassword: SupabaseAuthClientInterface['signInWithPassword'];
69
- signInWithOAuth: SupabaseAuthClientInterface['signInWithOAuth'];
70
- signInWithOtp: SupabaseAuthClientInterface['signInWithOtp'];
71
- signInWithIdToken: SupabaseAuthClientInterface['signInWithIdToken'];
72
- signInWithSSO: SupabaseAuthClientInterface['signInWithSSO'];
73
- signInWithWeb3: SupabaseAuthClientInterface['signInWithWeb3'];
74
- signOut: SupabaseAuthClientInterface['signOut'];
75
- getUser: SupabaseAuthClientInterface['getUser'];
76
- getClaims: (jwtArg?: string) => Promise<{
77
- data: {
78
- header: JwtHeader;
79
- claims: JwtPayload;
80
- signature: Uint8Array<ArrayBufferLike>;
81
- };
82
- error: null;
83
- } | {
84
- data: null;
85
- error: _supabase_auth_js0.AuthError;
86
- }>;
87
- updateUser: SupabaseAuthClientInterface['updateUser'];
88
- getUserIdentities: SupabaseAuthClientInterface['getUserIdentities'];
89
- linkIdentity: SupabaseAuthClientInterface['linkIdentity'];
90
- unlinkIdentity: SupabaseAuthClientInterface['unlinkIdentity'];
91
- verifyOtp: SupabaseAuthClientInterface['verifyOtp'];
92
- resetPasswordForEmail: SupabaseAuthClientInterface['resetPasswordForEmail'];
93
- reauthenticate: SupabaseAuthClientInterface['reauthenticate'];
94
- resend: SupabaseAuthClientInterface['resend'];
95
- exchangeCodeForSession: SupabaseAuthClientInterface['exchangeCodeForSession'];
96
- onAuthStateChange: SupabaseAuthClientInterface['onAuthStateChange'];
97
- isThrowOnErrorEnabled: SupabaseAuthClientInterface['isThrowOnErrorEnabled'];
98
- startAutoRefresh: SupabaseAuthClientInterface['startAutoRefresh'];
99
- stopAutoRefresh: SupabaseAuthClientInterface['stopAutoRefresh'];
100
- private verifyEmailOtp;
101
- private verifyPhoneOtp;
102
- private emitInitialSession;
103
- }
104
- /** Instance type for SupabaseAuthAdapter */
105
- type SupabaseAuthAdapterInstance = SupabaseAuthAdapterImpl;
106
- /** Builder type that creates adapter instances */
107
- type SupabaseAuthAdapterBuilder = (url: string) => SupabaseAuthAdapterInstance;
108
- /**
109
- * Factory function that returns an adapter builder.
110
- * The builder is called by createClient/createAuthClient with the URL.
111
- *
112
- * @param options - Optional adapter configuration (baseURL is injected separately)
113
- * @returns A builder function that creates the adapter instance
114
- *
115
- * @example
116
- * ```typescript
117
- * const client = createClient({
118
- * auth: {
119
- * url: 'https://auth.example.com',
120
- * adapter: SupabaseAuthAdapter(),
121
- * },
122
- * dataApi: { url: 'https://data-api.example.com' },
123
- * });
124
- * ```
125
- */
126
- declare function SupabaseAuthAdapter(options?: SupabaseAuthAdapterOptions): SupabaseAuthAdapterBuilder;
127
- //#endregion
128
- export { BetterAuthVanillaAdapter as a, BetterAuthVanillaAdapterOptions as c, SupabaseAuthAdapterOptions as i, SupabaseAuthAdapterBuilder as n, BetterAuthVanillaAdapterBuilder as o, SupabaseAuthAdapterInstance as r, BetterAuthVanillaAdapterInstance as s, SupabaseAuthAdapter as t };
@@ -1,401 +0,0 @@
1
- 'use client';
2
- import { AuthUIProvider } from "@daveyplate/better-auth-ui";
3
- import { useCallback, useMemo, useRef, useSyncExternalStore } from "react";
4
- import { Toaster } from "sonner";
5
- import { ThemeProvider, useTheme } from "next-themes";
6
- import { jsx, jsxs } from "react/jsx-runtime";
7
-
8
- //#region rolldown:runtime
9
- var __defProp = Object.defineProperty;
10
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
11
- var __getOwnPropNames = Object.getOwnPropertyNames;
12
- var __hasOwnProp = Object.prototype.hasOwnProperty;
13
- var __export = (all, symbols) => {
14
- let target = {};
15
- for (var name in all) {
16
- __defProp(target, name, {
17
- get: all[name],
18
- enumerable: true
19
- });
20
- }
21
- if (symbols) {
22
- __defProp(target, Symbol.toStringTag, { value: "Module" });
23
- }
24
- return target;
25
- };
26
- var __copyProps = (to, from, except, desc) => {
27
- if (from && typeof from === "object" || typeof from === "function") {
28
- for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
29
- key = keys[i];
30
- if (!__hasOwnProp.call(to, key) && key !== except) {
31
- __defProp(to, key, {
32
- get: ((k) => from[k]).bind(null, key),
33
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
34
- });
35
- }
36
- }
37
- }
38
- return to;
39
- };
40
- var __reExport = (target, mod, secondTarget, symbols) => {
41
- if (symbols) {
42
- __defProp(target, Symbol.toStringTag, { value: "Module" });
43
- secondTarget && __defProp(secondTarget, Symbol.toStringTag, { value: "Module" });
44
- }
45
- __copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default");
46
- };
47
-
48
- //#endregion
49
- //#region ../auth-ui/dist/index.mjs
50
- var dist_exports = /* @__PURE__ */ __export({
51
- NeonAuthUIProvider: () => NeonAuthUIProvider,
52
- useTheme: () => useTheme
53
- });
54
- import * as import___daveyplate_better_auth_ui from "@daveyplate/better-auth-ui";
55
- __reExport(dist_exports, import___daveyplate_better_auth_ui);
56
- const _envShim = Object.create(null);
57
- const _getEnv = (useShim) => globalThis.process?.env || globalThis.Deno?.env.toObject() || globalThis.__env__ || (useShim ? _envShim : globalThis);
58
- const env = new Proxy(_envShim, {
59
- get(_, prop) {
60
- return _getEnv()[prop] ?? _envShim[prop];
61
- },
62
- has(_, prop) {
63
- return prop in _getEnv() || prop in _envShim;
64
- },
65
- set(_, prop, value) {
66
- const env$1 = _getEnv(true);
67
- env$1[prop] = value;
68
- return true;
69
- },
70
- deleteProperty(_, prop) {
71
- if (!prop) return false;
72
- const env$1 = _getEnv(true);
73
- delete env$1[prop];
74
- return true;
75
- },
76
- ownKeys() {
77
- const env$1 = _getEnv(true);
78
- return Object.keys(env$1);
79
- }
80
- });
81
- typeof process !== "undefined" && process.env && process.env.NODE_ENV;
82
- /**
83
- * Get environment variable with fallback
84
- */
85
- function getEnvVar(key, fallback) {
86
- if (typeof process !== "undefined" && process.env) return process.env[key] ?? fallback;
87
- if (typeof Deno !== "undefined") return Deno.env.get(key) ?? fallback;
88
- if (typeof Bun !== "undefined") return Bun.env[key] ?? fallback;
89
- return fallback;
90
- }
91
- Object.freeze({
92
- get BETTER_AUTH_SECRET() {
93
- return getEnvVar("BETTER_AUTH_SECRET");
94
- },
95
- get AUTH_SECRET() {
96
- return getEnvVar("AUTH_SECRET");
97
- },
98
- get BETTER_AUTH_TELEMETRY() {
99
- return getEnvVar("BETTER_AUTH_TELEMETRY");
100
- },
101
- get BETTER_AUTH_TELEMETRY_ID() {
102
- return getEnvVar("BETTER_AUTH_TELEMETRY_ID");
103
- },
104
- get NODE_ENV() {
105
- return getEnvVar("NODE_ENV", "development");
106
- },
107
- get PACKAGE_VERSION() {
108
- return getEnvVar("PACKAGE_VERSION", "0.0.0");
109
- },
110
- get BETTER_AUTH_TELEMETRY_ENDPOINT() {
111
- return getEnvVar("BETTER_AUTH_TELEMETRY_ENDPOINT", "https://telemetry.better-auth.com/v1/track");
112
- }
113
- });
114
- const COLORS_2 = 1;
115
- const COLORS_16 = 4;
116
- const COLORS_256 = 8;
117
- const COLORS_16m = 24;
118
- const TERM_ENVS = {
119
- eterm: COLORS_16,
120
- cons25: COLORS_16,
121
- console: COLORS_16,
122
- cygwin: COLORS_16,
123
- dtterm: COLORS_16,
124
- gnome: COLORS_16,
125
- hurd: COLORS_16,
126
- jfbterm: COLORS_16,
127
- konsole: COLORS_16,
128
- kterm: COLORS_16,
129
- mlterm: COLORS_16,
130
- mosh: COLORS_16m,
131
- putty: COLORS_16,
132
- st: COLORS_16,
133
- "rxvt-unicode-24bit": COLORS_16m,
134
- terminator: COLORS_16m,
135
- "xterm-kitty": COLORS_16m
136
- };
137
- const CI_ENVS_MAP = new Map(Object.entries({
138
- APPVEYOR: COLORS_256,
139
- BUILDKITE: COLORS_256,
140
- CIRCLECI: COLORS_16m,
141
- DRONE: COLORS_256,
142
- GITEA_ACTIONS: COLORS_16m,
143
- GITHUB_ACTIONS: COLORS_16m,
144
- GITLAB_CI: COLORS_256,
145
- TRAVIS: COLORS_256
146
- }));
147
- const TERM_ENVS_REG_EXP = [
148
- /ansi/,
149
- /color/,
150
- /linux/,
151
- /direct/,
152
- /^con[0-9]*x[0-9]/,
153
- /^rxvt/,
154
- /^screen/,
155
- /^xterm/,
156
- /^vt100/,
157
- /^vt220/
158
- ];
159
- function getColorDepth() {
160
- if (getEnvVar("FORCE_COLOR") !== void 0) switch (getEnvVar("FORCE_COLOR")) {
161
- case "":
162
- case "1":
163
- case "true": return COLORS_16;
164
- case "2": return COLORS_256;
165
- case "3": return COLORS_16m;
166
- default: return COLORS_2;
167
- }
168
- 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;
169
- if (getEnvVar("TMUX")) return COLORS_16m;
170
- if ("TF_BUILD" in env && "AGENT_NAME" in env) return COLORS_16;
171
- if ("CI" in env) {
172
- for (const { 0: envName, 1: colors } of CI_ENVS_MAP) if (envName in env) return colors;
173
- if (getEnvVar("CI_NAME") === "codeship") return COLORS_256;
174
- return COLORS_2;
175
- }
176
- if ("TEAMCITY_VERSION" in env) return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.exec(getEnvVar("TEAMCITY_VERSION")) !== null ? COLORS_16 : COLORS_2;
177
- switch (getEnvVar("TERM_PROGRAM")) {
178
- case "iTerm.app":
179
- if (!getEnvVar("TERM_PROGRAM_VERSION") || /^[0-2]\./.exec(getEnvVar("TERM_PROGRAM_VERSION")) !== null) return COLORS_256;
180
- return COLORS_16m;
181
- case "HyperTerm":
182
- case "MacTerm": return COLORS_16m;
183
- case "Apple_Terminal": return COLORS_256;
184
- }
185
- if (getEnvVar("COLORTERM") === "truecolor" || getEnvVar("COLORTERM") === "24bit") return COLORS_16m;
186
- if (getEnvVar("TERM")) {
187
- if (/truecolor/.exec(getEnvVar("TERM")) !== null) return COLORS_16m;
188
- if (/^xterm-256/.exec(getEnvVar("TERM")) !== null) return COLORS_256;
189
- const termEnv = getEnvVar("TERM").toLowerCase();
190
- if (TERM_ENVS[termEnv]) return TERM_ENVS[termEnv];
191
- if (TERM_ENVS_REG_EXP.some((term) => term.exec(termEnv) !== null)) return COLORS_16;
192
- }
193
- if (getEnvVar("COLORTERM")) return COLORS_16;
194
- return COLORS_2;
195
- }
196
- const TTY_COLORS = {
197
- reset: "\x1B[0m",
198
- bright: "\x1B[1m",
199
- dim: "\x1B[2m",
200
- undim: "\x1B[22m",
201
- underscore: "\x1B[4m",
202
- blink: "\x1B[5m",
203
- reverse: "\x1B[7m",
204
- hidden: "\x1B[8m",
205
- fg: {
206
- black: "\x1B[30m",
207
- red: "\x1B[31m",
208
- green: "\x1B[32m",
209
- yellow: "\x1B[33m",
210
- blue: "\x1B[34m",
211
- magenta: "\x1B[35m",
212
- cyan: "\x1B[36m",
213
- white: "\x1B[37m"
214
- },
215
- bg: {
216
- black: "\x1B[40m",
217
- red: "\x1B[41m",
218
- green: "\x1B[42m",
219
- yellow: "\x1B[43m",
220
- blue: "\x1B[44m",
221
- magenta: "\x1B[45m",
222
- cyan: "\x1B[46m",
223
- white: "\x1B[47m"
224
- }
225
- };
226
- const levels = [
227
- "debug",
228
- "info",
229
- "success",
230
- "warn",
231
- "error"
232
- ];
233
- function shouldPublishLog(currentLogLevel, logLevel) {
234
- return levels.indexOf(logLevel) >= levels.indexOf(currentLogLevel);
235
- }
236
- const levelColors = {
237
- info: TTY_COLORS.fg.blue,
238
- success: TTY_COLORS.fg.green,
239
- warn: TTY_COLORS.fg.yellow,
240
- error: TTY_COLORS.fg.red,
241
- debug: TTY_COLORS.fg.magenta
242
- };
243
- const formatMessage = (level, message, colorsEnabled) => {
244
- const timestamp = (/* @__PURE__ */ new Date()).toISOString();
245
- 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}`;
246
- return `${timestamp} ${level.toUpperCase()} [Better Auth]: ${message}`;
247
- };
248
- const createLogger = (options) => {
249
- const enabled = options?.disabled !== true;
250
- const logLevel = options?.level ?? "error";
251
- const colorsEnabled = options?.disableColors !== void 0 ? !options.disableColors : getColorDepth() !== 1;
252
- const LogFunc = (level, message, args = []) => {
253
- if (!enabled || !shouldPublishLog(logLevel, level)) return;
254
- const formattedMessage = formatMessage(level, message, colorsEnabled);
255
- if (!options || typeof options.log !== "function") {
256
- if (level === "error") console.error(formattedMessage, ...args);
257
- else if (level === "warn") console.warn(formattedMessage, ...args);
258
- else console.log(formattedMessage, ...args);
259
- return;
260
- }
261
- options.log(level === "success" ? "info" : level, message, ...args);
262
- };
263
- return {
264
- ...Object.fromEntries(levels.map((level) => [level, (...[message, ...args]) => LogFunc(level, message, args)])),
265
- get level() {
266
- return logLevel;
267
- }
268
- };
269
- };
270
- createLogger();
271
- function defineErrorCodes(codes) {
272
- return codes;
273
- }
274
- defineErrorCodes({
275
- USER_NOT_FOUND: "User not found",
276
- FAILED_TO_CREATE_USER: "Failed to create user",
277
- FAILED_TO_CREATE_SESSION: "Failed to create session",
278
- FAILED_TO_UPDATE_USER: "Failed to update user",
279
- FAILED_TO_GET_SESSION: "Failed to get session",
280
- INVALID_PASSWORD: "Invalid password",
281
- INVALID_EMAIL: "Invalid email",
282
- INVALID_EMAIL_OR_PASSWORD: "Invalid email or password",
283
- SOCIAL_ACCOUNT_ALREADY_LINKED: "Social account already linked",
284
- PROVIDER_NOT_FOUND: "Provider not found",
285
- INVALID_TOKEN: "Invalid token",
286
- ID_TOKEN_NOT_SUPPORTED: "id_token not supported",
287
- FAILED_TO_GET_USER_INFO: "Failed to get user info",
288
- USER_EMAIL_NOT_FOUND: "User email not found",
289
- EMAIL_NOT_VERIFIED: "Email not verified",
290
- PASSWORD_TOO_SHORT: "Password too short",
291
- PASSWORD_TOO_LONG: "Password too long",
292
- USER_ALREADY_EXISTS: "User already exists.",
293
- USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL: "User already exists. Use another email.",
294
- EMAIL_CAN_NOT_BE_UPDATED: "Email can not be updated",
295
- CREDENTIAL_ACCOUNT_NOT_FOUND: "Credential account not found",
296
- SESSION_EXPIRED: "Session expired. Re-authenticate to perform this action.",
297
- FAILED_TO_UNLINK_LAST_ACCOUNT: "You can't unlink your last account",
298
- ACCOUNT_NOT_FOUND: "Account not found",
299
- USER_ALREADY_HAS_PASSWORD: "User already has a password. Provide that to delete the account."
300
- });
301
- Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY;
302
- function listenKeys($store, keys, listener) {
303
- let keysSet = new Set(keys).add(void 0);
304
- return $store.listen((value, oldValue, changed) => {
305
- if (keysSet.has(changed)) listener(value, oldValue, changed);
306
- });
307
- }
308
- /**
309
- * Subscribe to store changes and get store's value.
310
- *
311
- * Can be used with store builder too.
312
- *
313
- * ```js
314
- * import { useStore } from 'nanostores/react'
315
- *
316
- * import { router } from '../store/router'
317
- *
318
- * export const Layout = () => {
319
- * let page = useStore(router)
320
- * if (page.route === 'home') {
321
- * return <HomePage />
322
- * } else {
323
- * return <Error404 />
324
- * }
325
- * }
326
- * ```
327
- *
328
- * @param store Store instance.
329
- * @returns Store value.
330
- */
331
- function useStore(store, options = {}) {
332
- let snapshotRef = useRef(store.get());
333
- const { keys, deps = [store, keys] } = options;
334
- let subscribe = useCallback((onChange) => {
335
- const emitChange = (value) => {
336
- if (snapshotRef.current === value) return;
337
- snapshotRef.current = value;
338
- onChange();
339
- };
340
- emitChange(store.value);
341
- if (keys?.length) return listenKeys(store, keys, emitChange);
342
- return store.listen(emitChange);
343
- }, deps);
344
- let get = () => snapshotRef.current;
345
- return useSyncExternalStore(subscribe, get, get);
346
- }
347
- function isVanillaClient(client) {
348
- return typeof client.useSession !== "function";
349
- }
350
- /**
351
- * Automatically adapt a vanilla better-auth client for React
352
- *
353
- * This function works with Proxy objects by creating a wrapper proxy that:
354
- * 1. Intercepts all property access
355
- * 2. Detects if it's a hook (starts with "use" and is an atom)
356
- * 3. Wraps atoms with useStore for React compatibility
357
- * 4. Passes through everything else unchanged
358
- */
359
- function toReactClient(vanillaClient) {
360
- const hookCache = /* @__PURE__ */ new Map();
361
- return new Proxy(vanillaClient, { get(target, prop, receiver) {
362
- const value = Reflect.get(target, prop, receiver);
363
- if (typeof prop === "string" && prop.startsWith("use") && value && typeof value === "object" && "subscribe" in value && "get" in value) {
364
- if (hookCache.has(prop)) return hookCache.get(prop);
365
- const reactHook = function useReactHook() {
366
- return useStore(value);
367
- };
368
- hookCache.set(prop, reactHook);
369
- return reactHook;
370
- }
371
- return value;
372
- } });
373
- }
374
- function getReactClient(client) {
375
- if (isVanillaClient(client)) return toReactClient(client);
376
- return client;
377
- }
378
- function NeonAuthUIProvider({ authClient, children, ...props }) {
379
- return /* @__PURE__ */ jsx(ThemeProvider, {
380
- attribute: "class",
381
- defaultTheme: "system",
382
- enableSystem: true,
383
- children: /* @__PURE__ */ jsxs(AuthUIProvider, {
384
- authClient: useMemo(() => {
385
- return "getBetterAuthInstance" in authClient ? getReactClient(authClient.getBetterAuthInstance()) : getReactClient(authClient);
386
- }, [authClient]),
387
- ...props,
388
- multiSession: false,
389
- apiKey: false,
390
- magicLink: false,
391
- passkey: false,
392
- oneTap: false,
393
- genericOAuth: void 0,
394
- twoFactor: void 0,
395
- children: [children, /* @__PURE__ */ jsx(Toaster, {})]
396
- })
397
- });
398
- }
399
-
400
- //#endregion
401
- export { dist_exports as n, useTheme as r, NeonAuthUIProvider as t };