@onmax/nuxt-better-auth 0.0.2-alpha.7 → 0.0.2-alpha.9
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/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -319,6 +319,18 @@ declare module '#nuxt-better-auth' {
|
|
|
319
319
|
${hasHubDb ? `db: typeof import('hub:db')['db']` : ""}
|
|
320
320
|
}
|
|
321
321
|
}
|
|
322
|
+
|
|
323
|
+
// Augment the config module to use the extended ServerAuthContext
|
|
324
|
+
interface _AugmentedServerAuthContext {
|
|
325
|
+
runtimeConfig: RuntimeConfig
|
|
326
|
+
${hasHubDb ? `db: typeof import('hub:db')['db']` : "db: unknown"}
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
declare module '@onmax/nuxt-better-auth/config' {
|
|
330
|
+
import type { BetterAuthOptions } from 'better-auth'
|
|
331
|
+
type ServerAuthConfig = Omit<BetterAuthOptions, 'database' | 'secret' | 'baseURL'>
|
|
332
|
+
export function defineServerAuth<T extends ServerAuthConfig>(config: (ctx: _AugmentedServerAuthContext) => T): (ctx: _AugmentedServerAuthContext) => T
|
|
333
|
+
}
|
|
322
334
|
`
|
|
323
335
|
});
|
|
324
336
|
addTypeTemplate({
|
|
@@ -333,13 +345,25 @@ declare module '#nuxt-better-auth' {
|
|
|
333
345
|
addTypeTemplate({
|
|
334
346
|
filename: "types/nuxt-better-auth-nitro.d.ts",
|
|
335
347
|
getContents: () => `
|
|
348
|
+
declare module 'nitropack' {
|
|
349
|
+
interface NitroRouteRules {
|
|
350
|
+
auth?: import('${resolver.resolve("./runtime/types")}').AuthMeta
|
|
351
|
+
}
|
|
352
|
+
interface NitroRouteConfig {
|
|
353
|
+
auth?: import('${resolver.resolve("./runtime/types")}').AuthMeta
|
|
354
|
+
}
|
|
355
|
+
}
|
|
336
356
|
declare module 'nitropack/types' {
|
|
337
357
|
interface NitroRouteRules {
|
|
338
358
|
auth?: import('${resolver.resolve("./runtime/types")}').AuthMeta
|
|
339
359
|
}
|
|
360
|
+
interface NitroRouteConfig {
|
|
361
|
+
auth?: import('${resolver.resolve("./runtime/types")}').AuthMeta
|
|
362
|
+
}
|
|
340
363
|
}
|
|
364
|
+
export {}
|
|
341
365
|
`
|
|
342
|
-
});
|
|
366
|
+
}, { nuxt: true, nitro: true, node: true });
|
|
343
367
|
nuxt.hook("builder:watch", async (_event, relativePath) => {
|
|
344
368
|
if (relativePath.includes("auth.config")) {
|
|
345
369
|
await updateTemplates({ filter: (t) => t.filename.includes("nuxt-better-auth") });
|
|
@@ -1,20 +1,22 @@
|
|
|
1
|
-
import type { AuthUser } from '#nuxt-better-auth';
|
|
1
|
+
import type { AppAuthClient, AuthSession, AuthUser } from '#nuxt-better-auth';
|
|
2
|
+
import type { ComputedRef, Ref } from 'vue';
|
|
2
3
|
export interface SignOutOptions {
|
|
3
4
|
onSuccess?: () => void | Promise<void>;
|
|
4
5
|
}
|
|
5
|
-
export
|
|
6
|
-
client:
|
|
7
|
-
session:
|
|
8
|
-
user:
|
|
9
|
-
loggedIn:
|
|
10
|
-
ready:
|
|
11
|
-
signIn:
|
|
12
|
-
signUp:
|
|
13
|
-
signOut: (options?: SignOutOptions) => Promise<
|
|
6
|
+
export interface UseUserSessionReturn {
|
|
7
|
+
client: AppAuthClient | null;
|
|
8
|
+
session: Ref<AuthSession | null>;
|
|
9
|
+
user: Ref<AuthUser | null>;
|
|
10
|
+
loggedIn: ComputedRef<boolean>;
|
|
11
|
+
ready: ComputedRef<boolean>;
|
|
12
|
+
signIn: NonNullable<AppAuthClient>['signIn'];
|
|
13
|
+
signUp: NonNullable<AppAuthClient>['signUp'];
|
|
14
|
+
signOut: (options?: SignOutOptions) => Promise<void>;
|
|
14
15
|
waitForSession: () => Promise<void>;
|
|
15
16
|
fetchSession: (options?: {
|
|
16
17
|
headers?: HeadersInit;
|
|
17
18
|
force?: boolean;
|
|
18
19
|
}) => Promise<void>;
|
|
19
20
|
updateUser: (updates: Partial<AuthUser>) => void;
|
|
20
|
-
}
|
|
21
|
+
}
|
|
22
|
+
export declare function useUserSession(): UseUserSessionReturn;
|
|
@@ -138,11 +138,10 @@ export function useUserSession() {
|
|
|
138
138
|
async function signOut(options) {
|
|
139
139
|
if (!client)
|
|
140
140
|
throw new Error("signOut can only be called on client-side");
|
|
141
|
-
|
|
141
|
+
await client.signOut();
|
|
142
142
|
clearSession();
|
|
143
143
|
if (options?.onSuccess)
|
|
144
144
|
await options.onSuccess();
|
|
145
|
-
return response;
|
|
146
145
|
}
|
|
147
146
|
return {
|
|
148
147
|
client,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onmax/nuxt-better-auth",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.2-alpha.
|
|
4
|
+
"version": "0.0.2-alpha.9",
|
|
5
5
|
"packageManager": "pnpm@10.15.1",
|
|
6
6
|
"description": "Nuxt module for Better Auth integration with NuxtHub, route protection, session management, and role-based access",
|
|
7
7
|
"author": "onmax",
|