better-auth-nuxt 0.0.9 → 0.0.10-beta.19

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 (60) hide show
  1. package/README.md +19 -270
  2. package/dist/module.d.mts +13 -40
  3. package/dist/module.json +8 -5
  4. package/dist/module.mjs +625 -358
  5. package/dist/runtime/adapters/convex.d.ts +111 -0
  6. package/dist/runtime/adapters/convex.js +213 -0
  7. package/dist/runtime/app/components/BetterAuthState.d.vue.ts +20 -0
  8. package/dist/runtime/app/components/BetterAuthState.vue +9 -0
  9. package/dist/runtime/app/components/BetterAuthState.vue.d.ts +20 -0
  10. package/dist/runtime/app/composables/useUserSession.d.ts +22 -0
  11. package/dist/runtime/app/composables/useUserSession.js +159 -0
  12. package/dist/runtime/app/middleware/auth.global.d.ts +13 -0
  13. package/dist/runtime/app/middleware/auth.global.js +37 -0
  14. package/dist/runtime/app/pages/__better-auth-devtools.d.vue.ts +3 -0
  15. package/dist/runtime/app/pages/__better-auth-devtools.vue +426 -0
  16. package/dist/runtime/app/pages/__better-auth-devtools.vue.d.ts +3 -0
  17. package/dist/runtime/app/plugins/session.client.d.ts +2 -0
  18. package/dist/runtime/app/plugins/session.client.js +15 -0
  19. package/dist/runtime/app/plugins/session.server.d.ts +2 -0
  20. package/dist/runtime/app/plugins/session.server.js +24 -0
  21. package/dist/runtime/config.d.ts +49 -0
  22. package/dist/runtime/config.js +11 -0
  23. package/dist/runtime/server/api/_better-auth/_schema.d.ts +16 -0
  24. package/dist/runtime/server/api/_better-auth/_schema.js +11 -0
  25. package/dist/runtime/server/api/_better-auth/accounts.get.d.ts +14 -0
  26. package/dist/runtime/server/api/_better-auth/accounts.get.js +28 -0
  27. package/dist/runtime/server/api/_better-auth/config.get.d.ts +35 -0
  28. package/dist/runtime/server/api/_better-auth/config.get.js +47 -0
  29. package/dist/runtime/server/api/_better-auth/sessions.delete.d.ts +4 -0
  30. package/dist/runtime/server/api/_better-auth/sessions.delete.js +22 -0
  31. package/dist/runtime/server/api/_better-auth/sessions.get.d.ts +14 -0
  32. package/dist/runtime/server/api/_better-auth/sessions.get.js +43 -0
  33. package/dist/runtime/server/api/_better-auth/users.get.d.ts +14 -0
  34. package/dist/runtime/server/api/_better-auth/users.get.js +34 -0
  35. package/dist/runtime/server/api/auth/[...all].d.ts +2 -0
  36. package/dist/runtime/server/api/auth/[...all].js +6 -0
  37. package/dist/runtime/server/middleware/route-access.d.ts +2 -0
  38. package/dist/runtime/server/middleware/route-access.js +29 -0
  39. package/dist/runtime/server/tsconfig.json +1 -1
  40. package/dist/runtime/server/utils/auth.d.ts +7 -0
  41. package/dist/runtime/server/utils/auth.js +81 -0
  42. package/dist/runtime/server/utils/session.d.ts +9 -0
  43. package/dist/runtime/server/utils/session.js +23 -0
  44. package/dist/runtime/types/augment.d.ts +42 -0
  45. package/dist/runtime/types/augment.js +0 -0
  46. package/dist/runtime/types.d.ts +23 -0
  47. package/dist/runtime/types.js +0 -0
  48. package/dist/runtime/utils/match-user.d.ts +2 -0
  49. package/dist/runtime/utils/match-user.js +13 -0
  50. package/dist/types.d.mts +8 -6
  51. package/package.json +82 -29
  52. package/LICENSE +0 -21
  53. package/dist/runtime/middleware/auth.d.ts +0 -2
  54. package/dist/runtime/middleware/auth.js +0 -31
  55. package/dist/runtime/plugin.d.ts +0 -2
  56. package/dist/runtime/plugin.js +0 -3
  57. package/dist/runtime/server/handler.d.ts +0 -2
  58. package/dist/runtime/server/handler.js +0 -5
  59. package/dist/runtime/server.d.ts +0 -6
  60. package/dist/runtime/server.js +0 -5
@@ -0,0 +1,47 @@
1
+ import { defineEventHandler } from "nitro/h3";
2
+ import { useRuntimeConfig } from "nitro/runtime-config";
3
+ import { serverAuth } from "../../utils/auth.js";
4
+ export default defineEventHandler(async (event) => {
5
+ try {
6
+ const auth = serverAuth(event);
7
+ const options = auth.options;
8
+ const runtimeConfig = useRuntimeConfig();
9
+ const publicAuth = runtimeConfig.public?.auth;
10
+ const privateAuth = runtimeConfig.auth;
11
+ const sessionConfig = options.session || {};
12
+ const expiresInDays = sessionConfig.expiresIn ? Math.round(sessionConfig.expiresIn / 86400) : 7;
13
+ const updateAgeDays = sessionConfig.updateAge ? Math.round(sessionConfig.updateAge / 86400) : 1;
14
+ return {
15
+ config: {
16
+ // Module config (nuxt.config.ts)
17
+ module: {
18
+ redirects: publicAuth?.redirects || { login: "/login", guest: "/" },
19
+ secondaryStorage: privateAuth?.secondaryStorage ?? false,
20
+ useDatabase: publicAuth?.useDatabase ?? false
21
+ },
22
+ // Server config (server/auth.config.ts)
23
+ server: {
24
+ baseURL: options.baseURL,
25
+ basePath: options.basePath || "/api/auth",
26
+ socialProviders: Object.keys(options.socialProviders || {}),
27
+ plugins: (options.plugins || []).map((p) => p.id || "unknown"),
28
+ trustedOrigins: options.trustedOrigins || [],
29
+ session: {
30
+ expiresIn: `${expiresInDays} days`,
31
+ updateAge: `${updateAgeDays} days`,
32
+ cookieCache: sessionConfig.cookieCache?.enabled ?? false
33
+ },
34
+ emailAndPassword: !!options.emailAndPassword,
35
+ rateLimit: options.rateLimit?.enabled ?? false,
36
+ advanced: {
37
+ useSecureCookies: options.advanced?.useSecureCookies ?? "auto",
38
+ disableCSRFCheck: options.advanced?.disableCSRFCheck ?? false
39
+ }
40
+ }
41
+ }
42
+ };
43
+ } catch (error) {
44
+ console.error("[DevTools] Config fetch failed:", error);
45
+ return { config: null, error: "Failed to fetch configuration" };
46
+ }
47
+ });
@@ -0,0 +1,4 @@
1
+ declare const _default: import("nitro/h3").EventHandlerWithFetch<import("nitro/h3").EventHandlerRequest, Promise<{
2
+ success: boolean;
3
+ }>>;
4
+ export default _default;
@@ -0,0 +1,22 @@
1
+ import { defineEventHandler, HTTPError, readBody } from "nitro/h3";
2
+ import { z } from "zod";
3
+ const deleteSessionSchema = z.object({
4
+ id: z.string().min(1, "Session ID required")
5
+ });
6
+ export default defineEventHandler(async (event) => {
7
+ try {
8
+ const body = deleteSessionSchema.parse(await readBody(event));
9
+ const { db, schema } = await import("@nuxthub/db");
10
+ if (!schema.session)
11
+ throw new HTTPError("Session table not found", { status: 500 });
12
+ const { eq } = await import("drizzle-orm");
13
+ await db.delete(schema.session).where(eq(schema.session.id, body.id));
14
+ return { success: true };
15
+ } catch (error) {
16
+ if (error instanceof z.ZodError) {
17
+ throw new HTTPError(error.errors[0]?.message || "Invalid request", { status: 400 });
18
+ }
19
+ console.error("[DevTools] Delete session failed:", error);
20
+ throw new HTTPError("Failed to delete session", { status: 500 });
21
+ }
22
+ });
@@ -0,0 +1,14 @@
1
+ declare const _default: import("nitro/h3").EventHandlerWithFetch<import("nitro/h3").EventHandlerRequest, Promise<{
2
+ sessions: never[];
3
+ total: number;
4
+ error: string;
5
+ page?: undefined;
6
+ limit?: undefined;
7
+ } | {
8
+ sessions: any;
9
+ total: any;
10
+ page: number;
11
+ limit: number;
12
+ error?: undefined;
13
+ }>>;
14
+ export default _default;
@@ -0,0 +1,43 @@
1
+ import { defineEventHandler, getQuery } from "nitro/h3";
2
+ import { paginationQuerySchema, sanitizeSearchPattern } from "./_schema.js";
3
+ export default defineEventHandler(async (event) => {
4
+ try {
5
+ const { db, schema } = await import("@nuxthub/db");
6
+ if (!schema.session)
7
+ return { sessions: [], total: 0, error: "Session table not found" };
8
+ const query = paginationQuerySchema.parse(getQuery(event));
9
+ const { page, limit, search } = query;
10
+ const offset = (page - 1) * limit;
11
+ const { count, like, or, desc } = await import("drizzle-orm");
12
+ let dbQuery = db.select().from(schema.session);
13
+ let countQuery = db.select({ count: count() }).from(schema.session);
14
+ if (search) {
15
+ const pattern = sanitizeSearchPattern(search);
16
+ const searchCondition = or(
17
+ like(schema.session.userId, pattern),
18
+ schema.session.ipAddress ? like(schema.session.ipAddress, pattern) : void 0
19
+ );
20
+ if (searchCondition) {
21
+ dbQuery = dbQuery.where(searchCondition);
22
+ countQuery = countQuery.where(searchCondition);
23
+ }
24
+ }
25
+ const [sessions, totalResult] = await Promise.all([
26
+ dbQuery.orderBy(desc(schema.session.createdAt)).limit(limit).offset(offset),
27
+ countQuery
28
+ ]);
29
+ const safeSessions = sessions.map((s) => ({
30
+ id: s.id,
31
+ userId: s.userId,
32
+ createdAt: s.createdAt,
33
+ updatedAt: s.updatedAt,
34
+ expiresAt: s.expiresAt,
35
+ ipAddress: s.ipAddress,
36
+ userAgent: s.userAgent
37
+ }));
38
+ return { sessions: safeSessions, total: totalResult[0]?.count ?? 0, page, limit };
39
+ } catch (error) {
40
+ console.error("[DevTools] Fetch sessions failed:", error);
41
+ return { sessions: [], total: 0, error: "Failed to fetch sessions" };
42
+ }
43
+ });
@@ -0,0 +1,14 @@
1
+ declare const _default: import("nitro/h3").EventHandlerWithFetch<import("nitro/h3").EventHandlerRequest, Promise<{
2
+ users: never[];
3
+ total: number;
4
+ error: string;
5
+ page?: undefined;
6
+ limit?: undefined;
7
+ } | {
8
+ users: any;
9
+ total: any;
10
+ page: number;
11
+ limit: number;
12
+ error?: undefined;
13
+ }>>;
14
+ export default _default;
@@ -0,0 +1,34 @@
1
+ import { defineEventHandler, getQuery } from "nitro/h3";
2
+ import { paginationQuerySchema, sanitizeSearchPattern } from "./_schema.js";
3
+ export default defineEventHandler(async (event) => {
4
+ try {
5
+ const { db, schema } = await import("@nuxthub/db");
6
+ if (!schema.user)
7
+ return { users: [], total: 0, error: "User table not found" };
8
+ const query = paginationQuerySchema.parse(getQuery(event));
9
+ const { page, limit, search } = query;
10
+ const offset = (page - 1) * limit;
11
+ const { count, like, or, desc } = await import("drizzle-orm");
12
+ let dbQuery = db.select().from(schema.user);
13
+ let countQuery = db.select({ count: count() }).from(schema.user);
14
+ if (search) {
15
+ const pattern = sanitizeSearchPattern(search);
16
+ const searchCondition = or(
17
+ like(schema.user.name, pattern),
18
+ like(schema.user.email, pattern)
19
+ );
20
+ if (searchCondition) {
21
+ dbQuery = dbQuery.where(searchCondition);
22
+ countQuery = countQuery.where(searchCondition);
23
+ }
24
+ }
25
+ const [users, totalResult] = await Promise.all([
26
+ dbQuery.orderBy(desc(schema.user.createdAt)).limit(limit).offset(offset),
27
+ countQuery
28
+ ]);
29
+ return { users, total: totalResult[0]?.count ?? 0, page, limit };
30
+ } catch (error) {
31
+ console.error("[DevTools] Fetch users failed:", error);
32
+ return { users: [], total: 0, error: "Failed to fetch users" };
33
+ }
34
+ });
@@ -0,0 +1,2 @@
1
+ declare const _default: import("nitro/h3").EventHandlerWithFetch<import("nitro/h3").EventHandlerRequest, Promise<Response>>;
2
+ export default _default;
@@ -0,0 +1,6 @@
1
+ import { defineEventHandler } from "nitro/h3";
2
+ import { serverAuth } from "../../utils/auth.js";
3
+ export default defineEventHandler(async (event) => {
4
+ const auth = serverAuth(event);
5
+ return auth.handler(event.req);
6
+ });
@@ -0,0 +1,2 @@
1
+ declare const _default: import("nitro/h3").EventHandlerWithFetch<import("nitro/h3").EventHandlerRequest, Promise<void>>;
2
+ export default _default;
@@ -0,0 +1,29 @@
1
+ import { getRouteRules } from "nitro/app";
2
+ import { defineEventHandler, getRequestURL, HTTPError } from "nitro/h3";
3
+ import { matchesUser } from "../../utils/match-user.js";
4
+ import { getUserSession, requireUserSession } from "../utils/session.js";
5
+ export default defineEventHandler(async (event) => {
6
+ const path = getRequestURL(event).pathname;
7
+ if (!path.startsWith("/api/"))
8
+ return;
9
+ if (path.startsWith("/api/auth/"))
10
+ return;
11
+ const rules = getRouteRules(event.req.method, path);
12
+ if (!rules.auth)
13
+ return;
14
+ const auth = rules.auth;
15
+ const mode = typeof auth === "string" ? auth : auth?.only ?? "user";
16
+ if (mode === "guest") {
17
+ const session = await getUserSession(event);
18
+ if (session)
19
+ throw new HTTPError("Authenticated users not allowed", { status: 403 });
20
+ return;
21
+ }
22
+ if (mode === "user") {
23
+ const session = await requireUserSession(event);
24
+ if (typeof auth === "object" && auth.user) {
25
+ if (!matchesUser(session.user, auth.user))
26
+ throw new HTTPError("Access denied", { status: 403 });
27
+ }
28
+ }
29
+ });
@@ -1,3 +1,3 @@
1
1
  {
2
- "extends": "../../../.nuxt/tsconfig.server.json",
2
+ "extends": "../../../.nuxt/tsconfig.server.json"
3
3
  }
@@ -0,0 +1,7 @@
1
+ import type { Auth } from 'better-auth';
2
+ import type { H3Event } from 'nitro/h3';
3
+ import createServerAuth from '#auth/server';
4
+ type AuthInstance = Auth<ReturnType<typeof createServerAuth>>;
5
+ /** Returns Better Auth instance. Pass event for accurate URL detection on first call. */
6
+ export declare function serverAuth(event?: H3Event): AuthInstance;
7
+ export {};
@@ -0,0 +1,81 @@
1
+ import { createDatabase, db } from "#auth/database";
2
+ import { createSecondaryStorage } from "#auth/secondary-storage";
3
+ import createServerAuth from "#auth/server";
4
+ import { betterAuth } from "better-auth";
5
+ import { getRequestHost, getRequestProtocol } from "nitro/h3";
6
+ import { useRuntimeConfig } from "nitro/runtime-config";
7
+ import { withoutProtocol } from "ufo";
8
+ let _auth = null;
9
+ function validateURL(url) {
10
+ try {
11
+ return new URL(url).origin;
12
+ } catch {
13
+ throw new Error(`Invalid siteUrl: "${url}". Must be a valid URL.`);
14
+ }
15
+ }
16
+ function getNitroOrigin(e) {
17
+ const cert = process.env.NITRO_SSL_CERT;
18
+ const key = process.env.NITRO_SSL_KEY;
19
+ let host = process.env.NITRO_HOST || process.env.HOST;
20
+ let port;
21
+ if (import.meta.dev)
22
+ port = process.env.NITRO_PORT || process.env.PORT || "3000";
23
+ let protocol = cert && key || !import.meta.dev ? "https" : "http";
24
+ try {
25
+ if ((import.meta.dev || import.meta.prerender) && process.env.__NUXT_DEV__) {
26
+ const origin = JSON.parse(process.env.__NUXT_DEV__).proxy.url;
27
+ host = withoutProtocol(origin);
28
+ protocol = origin.includes("https") ? "https" : "http";
29
+ } else if ((import.meta.dev || import.meta.prerender) && process.env.NUXT_VITE_NODE_OPTIONS) {
30
+ const origin = JSON.parse(process.env.NUXT_VITE_NODE_OPTIONS).baseURL.replace("/__nuxt_vite_node__", "");
31
+ host = withoutProtocol(origin);
32
+ protocol = origin.includes("https") ? "https" : "http";
33
+ } else if (e) {
34
+ host = getRequestHost(e, { xForwardedHost: true }) || host;
35
+ protocol = getRequestProtocol(e, { xForwardedProto: true }) || protocol;
36
+ }
37
+ } catch {
38
+ }
39
+ if (!host)
40
+ return void 0;
41
+ if (host.includes(":") && !host.startsWith("[")) {
42
+ const hostParts = host.split(":");
43
+ port = hostParts.pop();
44
+ host = hostParts.join(":");
45
+ }
46
+ const portSuffix = port ? `:${port}` : "";
47
+ return `${protocol}://${host}${portSuffix}`;
48
+ }
49
+ function getBaseURL(event) {
50
+ const config = useRuntimeConfig();
51
+ if (config.public.siteUrl && typeof config.public.siteUrl === "string")
52
+ return validateURL(config.public.siteUrl);
53
+ const nitroOrigin = getNitroOrigin(event);
54
+ if (nitroOrigin)
55
+ return validateURL(nitroOrigin);
56
+ if (process.env.VERCEL_URL)
57
+ return validateURL(`https://${process.env.VERCEL_URL}`);
58
+ if (process.env.CF_PAGES_URL)
59
+ return validateURL(`https://${process.env.CF_PAGES_URL}`);
60
+ if (process.env.URL)
61
+ return validateURL(process.env.URL.startsWith("http") ? process.env.URL : `https://${process.env.URL}`);
62
+ if (import.meta.dev)
63
+ return "http://localhost:3000";
64
+ throw new Error("siteUrl required. Set NUXT_PUBLIC_SITE_URL.");
65
+ }
66
+ export function serverAuth(event) {
67
+ if (_auth)
68
+ return _auth;
69
+ const runtimeConfig = useRuntimeConfig();
70
+ const siteUrl = getBaseURL(event);
71
+ const database = createDatabase();
72
+ const userConfig = createServerAuth({ runtimeConfig, db });
73
+ _auth = betterAuth({
74
+ ...userConfig,
75
+ ...database && { database },
76
+ secondaryStorage: createSecondaryStorage(),
77
+ secret: runtimeConfig.betterAuthSecret,
78
+ baseURL: siteUrl
79
+ });
80
+ return _auth;
81
+ }
@@ -0,0 +1,9 @@
1
+ import type { H3Event } from 'nitro/h3';
2
+ import type { AuthSession, AuthUser, RequireSessionOptions } from '../../types.js';
3
+ interface FullSession {
4
+ user: AuthUser;
5
+ session: AuthSession;
6
+ }
7
+ export declare function getUserSession(event: H3Event): Promise<FullSession | null>;
8
+ export declare function requireUserSession(event: H3Event, options?: RequireSessionOptions): Promise<FullSession>;
9
+ export {};
@@ -0,0 +1,23 @@
1
+ import { HTTPError } from "nitro/h3";
2
+ import { matchesUser } from "../../utils/match-user.js";
3
+ import { serverAuth } from "./auth.js";
4
+ export async function getUserSession(event) {
5
+ const auth = serverAuth(event);
6
+ const session = await auth.api.getSession({ headers: event.headers });
7
+ return session;
8
+ }
9
+ export async function requireUserSession(event, options) {
10
+ const session = await getUserSession(event);
11
+ if (!session)
12
+ throw new HTTPError("Authentication required", { status: 401 });
13
+ if (options?.user) {
14
+ if (!matchesUser(session.user, options.user))
15
+ throw new HTTPError("Access denied", { status: 403 });
16
+ }
17
+ if (options?.rule) {
18
+ const allowed = await options.rule({ user: session.user, session: session.session });
19
+ if (!allowed)
20
+ throw new HTTPError("Access denied", { status: 403 });
21
+ }
22
+ return session;
23
+ }
@@ -0,0 +1,42 @@
1
+ import type { ComputedRef, Ref } from 'vue';
2
+ export interface AuthUser {
3
+ id: string;
4
+ createdAt: Date;
5
+ updatedAt: Date;
6
+ email: string;
7
+ emailVerified: boolean;
8
+ name: string;
9
+ image?: string | null;
10
+ }
11
+ export interface AuthSession {
12
+ id: string;
13
+ createdAt: Date;
14
+ updatedAt: Date;
15
+ userId: string;
16
+ expiresAt: Date;
17
+ token: string;
18
+ ipAddress?: string | null;
19
+ userAgent?: string | null;
20
+ }
21
+ export interface ServerAuthContext {
22
+ runtimeConfig: Record<string, unknown>;
23
+ db: unknown;
24
+ }
25
+ export interface UserSessionComposable {
26
+ client: unknown;
27
+ user: Ref<AuthUser | null>;
28
+ session: Ref<AuthSession | null>;
29
+ loggedIn: ComputedRef<boolean>;
30
+ ready: ComputedRef<boolean>;
31
+ signIn: unknown;
32
+ signUp: unknown;
33
+ fetchSession: (options?: {
34
+ headers?: HeadersInit;
35
+ force?: boolean;
36
+ }) => Promise<void>;
37
+ waitForSession: () => Promise<void>;
38
+ signOut: (options?: {
39
+ onSuccess?: () => void | Promise<void>;
40
+ }) => Promise<void>;
41
+ updateUser: (updates: Partial<AuthUser>) => void;
42
+ }
File without changes
@@ -0,0 +1,23 @@
1
+ import type { NitroRouteRules } from 'nitro/types';
2
+ import type { AuthSession, AuthUser } from './types/augment.js';
3
+ export type { AuthSession, AuthUser, ServerAuthContext, UserSessionComposable } from './types/augment.js';
4
+ export type { Auth, InferPluginTypes, InferSession, InferUser } from 'better-auth';
5
+ export type AuthMode = 'guest' | 'user';
6
+ export type UserMatch<T> = {
7
+ [K in keyof T]?: T[K] | T[K][];
8
+ };
9
+ export type AuthMeta = false | AuthMode | {
10
+ only?: AuthMode;
11
+ redirectTo?: string;
12
+ user?: UserMatch<AuthUser>;
13
+ };
14
+ export type AuthRouteRules = NitroRouteRules & {
15
+ auth?: AuthMeta;
16
+ };
17
+ export interface RequireSessionOptions {
18
+ user?: UserMatch<AuthUser>;
19
+ rule?: (ctx: {
20
+ user: AuthUser;
21
+ session: AuthSession;
22
+ }) => boolean | Promise<boolean>;
23
+ }
File without changes
@@ -0,0 +1,2 @@
1
+ import type { UserMatch } from '../types.js';
2
+ export declare function matchesUser<T extends object>(user: T, match: UserMatch<T>): boolean;
@@ -0,0 +1,13 @@
1
+ export function matchesUser(user, match) {
2
+ for (const [key, expected] of Object.entries(match)) {
3
+ const actual = user[key];
4
+ if (Array.isArray(expected)) {
5
+ if (!expected.includes(actual))
6
+ return false;
7
+ } else {
8
+ if (actual !== expected)
9
+ return false;
10
+ }
11
+ }
12
+ return true;
13
+ }
package/dist/types.d.mts CHANGED
@@ -1,9 +1,11 @@
1
- import type { ModulePublicRuntimeConfig } from './module.mjs'
1
+ import type { NuxtModule } from '@nuxt/schema'
2
2
 
3
- declare module '@nuxt/schema' {
4
- interface PublicRuntimeConfig extends ModulePublicRuntimeConfig {}
5
- }
3
+ import type { default as Module } from './module.mjs'
6
4
 
7
- export { default } from './module.mjs'
5
+ export type ModuleOptions = typeof Module extends NuxtModule<infer O> ? Partial<O> : Record<string, any>
6
+
7
+ export { type BetterAuthModuleOptions, type defineClientAuth, type defineServerAuth } from '../dist/runtime/config.js'
8
8
 
9
- export { type ModuleClientOptions, type ModuleOptions, type ModulePublicRuntimeConfig, type ModuleServerOptions } from './module.mjs'
9
+ export { type Auth, type AuthMeta, type AuthMode, type AuthRouteRules, type AuthSession, type AuthUser, type InferSession, type InferUser, type RequireSessionOptions, type ServerAuthContext, type UserMatch } from '../dist/runtime/types.js'
10
+
11
+ export { default } from './module.mjs'
package/package.json CHANGED
@@ -1,14 +1,34 @@
1
1
  {
2
2
  "name": "better-auth-nuxt",
3
- "version": "0.0.9",
4
- "description": "Better Auth Nuxt Module",
5
- "repository": "productdevbook/better-auth-nuxt",
6
- "license": "MIT",
7
3
  "type": "module",
4
+ "version": "0.0.10-beta.19",
5
+ "description": "Nuxt module for Better Auth integration with NuxtHub, route protection, session management, and role-based access",
6
+ "author": "onmax",
7
+ "license": "MIT",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/onmax/nuxt-better-auth"
11
+ },
12
+ "agents": {
13
+ "skills": [
14
+ {
15
+ "name": "nuxt-better-auth",
16
+ "path": "./skills/nuxt-better-auth"
17
+ }
18
+ ]
19
+ },
8
20
  "exports": {
9
21
  ".": {
10
22
  "types": "./dist/types.d.mts",
11
23
  "import": "./dist/module.mjs"
24
+ },
25
+ "./config": {
26
+ "types": "./dist/runtime/config.d.ts",
27
+ "import": "./dist/runtime/config.js"
28
+ },
29
+ "./adapters/convex": {
30
+ "types": "./dist/runtime/adapters/convex.d.ts",
31
+ "import": "./dist/runtime/adapters/convex.js"
12
32
  }
13
33
  },
14
34
  "main": "./dist/module.mjs",
@@ -16,51 +36,84 @@
16
36
  "*": {
17
37
  ".": [
18
38
  "./dist/types.d.mts"
39
+ ],
40
+ "config": [
41
+ "./dist/runtime/config.d.ts"
42
+ ],
43
+ "adapters/convex": [
44
+ "./dist/runtime/adapters/convex.d.ts"
19
45
  ]
20
46
  }
21
47
  },
22
48
  "files": [
23
- "dist"
49
+ "dist",
50
+ "skills"
24
51
  ],
25
52
  "peerDependencies": {
26
- "better-auth": ">=1.2.7"
53
+ "@nuxthub/core": ">=0.10.5",
54
+ "better-auth": ">=1.0.0",
55
+ "convex": ">=1.25.0"
56
+ },
57
+ "peerDependenciesMeta": {
58
+ "@nuxthub/core": {
59
+ "optional": true
60
+ },
61
+ "convex": {
62
+ "optional": true
63
+ }
27
64
  },
28
65
  "dependencies": {
29
- "@fastify/deepmerge": "^3.1.0",
30
- "@nuxt/kit": "^3.17.3",
66
+ "@better-auth/cli": "^1.5.0-beta.3",
67
+ "@nuxt/kit": "^4.2.2",
68
+ "@nuxt/ui": "^4.2.1",
31
69
  "defu": "^6.1.4",
32
- "ohash": "^2.0.11",
70
+ "jiti": "^2.4.2",
33
71
  "pathe": "^2.0.3",
34
- "scule": "^1.3.0",
35
- "tinyglobby": "^0.2.13"
72
+ "radix3": "^1.1.2",
73
+ "std-env": "^3.10.0"
36
74
  },
37
75
  "devDependencies": {
38
- "@nuxt/devtools": "^2.4.1",
39
- "@nuxt/eslint-config": "^1.4.0",
40
- "@nuxt/module-builder": "^1.0.1",
41
- "@nuxt/schema": "^3.17.3",
42
- "@nuxt/test-utils": "^3.19.0",
43
- "@tailwindcss/vite": "^4.1.7",
76
+ "@antfu/eslint-config": "^4.12.0",
77
+ "@libsql/client": "^0.15.15",
78
+ "@nuxt/devtools": "^3.1.1",
79
+ "@nuxt/devtools-kit": "^3.1.1",
80
+ "@nuxt/kit": "https://pkg.pr.new/@nuxt/kit@33005",
81
+ "@nuxt/module-builder": "^1.0.2",
82
+ "@nuxt/schema": "https://pkg.pr.new/@nuxt/schema@33005",
83
+ "@nuxt/test-utils": "^3.21.0",
84
+ "@nuxthub/core": "^0.10.5",
44
85
  "@types/better-sqlite3": "^7.6.13",
45
86
  "@types/node": "latest",
46
- "better-auth": "^1.2.8",
47
- "better-sqlite3": "^11.10.0",
48
- "changelogen": "^0.6.1",
49
- "eslint": "^9.26.0",
50
- "nuxt": "^3.17.3",
51
- "typescript": "~5.8.3",
52
- "vitest": "^3.1.3",
53
- "vue-tsc": "^2.2.10"
87
+ "better-auth": "^1.5.0-beta.3",
88
+ "better-sqlite3": "^11.9.1",
89
+ "bumpp": "^10.3.2",
90
+ "changelogen": "^0.6.2",
91
+ "consola": "^3.4.2",
92
+ "drizzle-kit": "^0.31.8",
93
+ "drizzle-orm": "^0.38.4",
94
+ "eslint": "^9.39.1",
95
+ "nitro": "3.0.1-alpha.2",
96
+ "npm-agentskills": "https://pkg.pr.new/onmax/npm-agentskills@394499e",
97
+ "nuxt": "https://pkg.pr.new/nuxt@33005",
98
+ "tinyexec": "^1.0.2",
99
+ "typescript": "~5.9.3",
100
+ "vitest": "^4.0.15",
101
+ "vitest-package-exports": "^0.1.1",
102
+ "vue-tsc": "^3.1.7",
103
+ "yaml": "^2.8.2"
54
104
  },
55
105
  "scripts": {
56
- "dev": "nuxi dev playground",
106
+ "dev": "pnpm dev:prepare && nuxi dev playground",
57
107
  "dev:build": "nuxi build playground",
58
108
  "dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
59
- "release": "npm run lint && npm run test && npm run prepack && changelogen --release && pnpm publish --no-git-checks --access public && git push --follow-tags",
109
+ "dev:docs": "nuxi dev docs",
110
+ "build:docs": "nuxi build docs",
111
+ "release": "pnpm publish --no-git-checks --access public --tag beta",
60
112
  "lint": "eslint .",
61
113
  "lint:fix": "eslint . --fix",
114
+ "typecheck": "vue-tsc --noEmit",
115
+ "typecheck:playground": "cd playground && vue-tsc --noEmit",
62
116
  "test": "vitest run",
63
- "test:watch": "vitest watch",
64
- "test:types": "vue-tsc --noEmit && cd playground && vue-tsc --noEmit"
117
+ "test:watch": "vitest watch"
65
118
  }
66
119
  }
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 Wind
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
@@ -1,2 +0,0 @@
1
- declare const _default: any;
2
- export default _default;