@onmax/nuxt-better-auth 0.0.2-alpha.8 → 0.0.2
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/README.md +57 -17
- package/dist/module.d.mts +28 -1
- package/dist/module.json +3 -3
- package/dist/module.mjs +1272 -339
- package/dist/runtime/app/components/BetterAuthState.d.vue.ts +4 -4
- package/dist/runtime/app/components/BetterAuthState.vue +1 -0
- package/dist/runtime/app/components/BetterAuthState.vue.d.ts +4 -4
- package/dist/runtime/app/composables/useAction.d.ts +2 -0
- package/dist/runtime/app/composables/useAction.js +6 -0
- package/dist/runtime/app/composables/useAuthAsyncData.d.ts +6 -0
- package/dist/runtime/app/composables/useAuthAsyncData.js +16 -0
- package/dist/runtime/app/composables/useAuthClient.d.ts +9 -0
- package/dist/runtime/app/composables/useAuthClient.js +34 -0
- package/dist/runtime/app/composables/useAuthClientAction.d.ts +3 -0
- package/dist/runtime/app/composables/useAuthClientAction.js +15 -0
- package/dist/runtime/app/composables/useAuthRequestFetch.d.ts +11 -0
- package/dist/runtime/app/composables/useAuthRequestFetch.js +4 -0
- package/dist/runtime/app/composables/useSignIn.d.ts +16 -0
- package/dist/runtime/app/composables/useSignIn.js +8 -0
- package/dist/runtime/app/composables/useSignUp.d.ts +5 -0
- package/dist/runtime/app/composables/useSignUp.js +8 -0
- package/dist/runtime/app/composables/useUserSession.d.ts +6 -5
- package/dist/runtime/app/composables/useUserSession.js +189 -100
- package/dist/runtime/app/composables/useUserSessionState.d.ts +3 -0
- package/dist/runtime/app/composables/useUserSessionState.js +4 -0
- package/dist/runtime/app/internal/auth-action-error.d.ts +3 -0
- package/dist/runtime/app/internal/auth-action-error.js +33 -0
- package/dist/runtime/app/internal/auth-action-handles.d.ts +18 -0
- package/dist/runtime/app/internal/auth-action-handles.js +105 -0
- package/dist/runtime/app/internal/redirect-helpers.d.ts +4 -0
- package/dist/runtime/app/internal/redirect-helpers.js +37 -0
- package/dist/runtime/app/internal/session-fetch.d.ts +12 -0
- package/dist/runtime/app/internal/session-fetch.js +56 -0
- package/dist/runtime/app/internal/utils.d.ts +1 -0
- package/dist/runtime/app/internal/utils.js +3 -0
- package/dist/runtime/app/internal/vue-safe-auth-proxy.d.ts +3 -0
- package/dist/runtime/app/internal/vue-safe-auth-proxy.js +68 -0
- package/dist/runtime/app/internal/wrap-auth-method.d.ts +15 -0
- package/dist/runtime/app/internal/wrap-auth-method.js +66 -0
- package/dist/runtime/app/middleware/auth.global.js +77 -15
- package/dist/runtime/app/pages/__better-auth-devtools.vue +4 -10
- package/dist/runtime/composables.d.ts +11 -0
- package/dist/runtime/composables.js +9 -0
- package/dist/runtime/config.d.ts +69 -15
- package/dist/runtime/config.js +9 -2
- package/dist/runtime/server/api/_better-auth/_schema.d.ts +1 -5
- package/dist/runtime/server/api/_better-auth/_schema.js +2 -1
- package/dist/runtime/server/api/_better-auth/accounts.get.d.ts +2 -2
- package/dist/runtime/server/api/_better-auth/accounts.get.js +3 -2
- package/dist/runtime/server/api/_better-auth/config.get.d.ts +9 -3
- package/dist/runtime/server/api/_better-auth/config.get.js +18 -6
- package/dist/runtime/server/api/_better-auth/sessions.delete.js +3 -2
- package/dist/runtime/server/api/_better-auth/sessions.get.d.ts +5 -3
- package/dist/runtime/server/api/_better-auth/sessions.get.js +3 -2
- package/dist/runtime/server/api/_better-auth/users.get.d.ts +2 -2
- package/dist/runtime/server/api/_better-auth/users.get.js +3 -2
- package/dist/runtime/server/api/auth/[...all].js +1 -1
- package/dist/runtime/server/middleware/route-access.js +2 -1
- package/dist/runtime/server/tsconfig.json +9 -1
- package/dist/runtime/server/utils/auth.d.ts +16 -8
- package/dist/runtime/server/utils/auth.js +229 -23
- package/dist/runtime/server/utils/custom-secondary-storage.d.ts +6 -0
- package/dist/runtime/server/utils/custom-secondary-storage.js +8 -0
- package/dist/runtime/server/utils/session.d.ts +6 -8
- package/dist/runtime/server/utils/session.js +216 -4
- package/dist/runtime/server/virtual-modules.d.ts +27 -0
- package/dist/runtime/types/augment.d.ts +18 -4
- package/dist/runtime/types.d.ts +12 -13
- package/dist/types.d.mts +1 -1
- package/package.json +51 -47
package/README.md
CHANGED
|
@@ -1,27 +1,67 @@
|
|
|
1
|
-
|
|
2
|
-
<img src="https://raw.githubusercontent.com/onmax/nuxt-better-auth/main/.github/og.png" alt="Nuxt Better Auth" width="100%">
|
|
3
|
-
<br>
|
|
4
|
-
<sub>Designed by <a href="https://github.com/HugoRCD">HugoRCD</a></sub>
|
|
5
|
-
</p>
|
|
1
|
+
# `@onmax/nuxt-better-auth`
|
|
6
2
|
|
|
7
|
-
|
|
3
|
+
Nuxt module for [Better Auth](https://better-auth.com) with Nuxt-native route protection, SSR-safe session access, auto-imported helpers, and optional NuxtHub-backed schema generation.
|
|
8
4
|
|
|
9
|
-
|
|
5
|
+
## Who this is for
|
|
10
6
|
|
|
11
|
-
|
|
12
|
-
<a href="https://npmjs.com/package/@onmax/nuxt-better-auth"><img src="https://img.shields.io/npm/v/@onmax/nuxt-better-auth/latest.svg?style=flat&colorA=020420&colorB=00DC82" alt="npm version"></a>
|
|
13
|
-
<a href="https://npm.chart.dev/@onmax/nuxt-better-auth"><img src="https://img.shields.io/npm/dm/@onmax/nuxt-better-auth.svg?style=flat&colorA=020420&colorB=00DC82" alt="npm downloads"></a>
|
|
14
|
-
<a href="https://npmjs.com/package/@onmax/nuxt-better-auth"><img src="https://img.shields.io/npm/l/@onmax/nuxt-better-auth.svg?style=flat&colorA=020420&colorB=00DC82" alt="License"></a>
|
|
15
|
-
<a href="https://nuxt.com"><img src="https://img.shields.io/badge/Nuxt-020420?logo=nuxt.js" alt="Nuxt"></a>
|
|
16
|
-
</p>
|
|
7
|
+
Use this module if you want Better Auth in a Nuxt 4 app and you want the Nuxt-specific pieces handled for you:
|
|
17
8
|
|
|
18
|
-
|
|
19
|
-
|
|
9
|
+
- `useUserSession()` for reactive auth state
|
|
10
|
+
- `requireUserSession(event)` and related server helpers
|
|
11
|
+
- route protection through `routeRules` and `definePageMeta({ auth })`
|
|
12
|
+
- generated `server/auth.config.ts` and `app/auth.config.ts`
|
|
13
|
+
- optional NuxtHub database integration and schema generation
|
|
14
|
+
|
|
15
|
+
## Install the module
|
|
16
|
+
|
|
17
|
+
For the fastest path in a Nuxt 4 app:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npx nuxi module add @onmax/nuxt-better-auth
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Then create or confirm these files:
|
|
24
|
+
|
|
25
|
+
- `server/auth.config.ts`
|
|
26
|
+
- `app/auth.config.ts`
|
|
27
|
+
- `.env` with `NUXT_BETTER_AUTH_SECRET`
|
|
28
|
+
|
|
29
|
+
For the full setup flow, follow the [installation guide](https://better-auth.nuxt.dev/getting-started/installation).
|
|
30
|
+
|
|
31
|
+
## Choose your setup path
|
|
32
|
+
|
|
33
|
+
- Use [NuxtHub integration](https://better-auth.nuxt.dev/integrations/nuxthub) if you want the shortest path to database-backed auth.
|
|
34
|
+
- Use [custom database setup](https://better-auth.nuxt.dev/guides/custom-database) if you already have your own database stack.
|
|
35
|
+
- Use [external auth backend](https://better-auth.nuxt.dev/guides/external-auth-backend) if Better Auth runs in a separate service.
|
|
36
|
+
- Use [database-less mode](https://better-auth.nuxt.dev/guides/database-less-mode) for stateless or OAuth-first setups with clear tradeoffs.
|
|
20
37
|
|
|
21
38
|
## Documentation
|
|
22
39
|
|
|
23
|
-
|
|
40
|
+
The documentation site is at [better-auth.nuxt.dev](https://better-auth.nuxt.dev).
|
|
41
|
+
|
|
42
|
+
Recommended reading order:
|
|
43
|
+
|
|
44
|
+
1. [Quickstart](https://better-auth.nuxt.dev/getting-started)
|
|
45
|
+
2. [Installation](https://better-auth.nuxt.dev/getting-started/installation)
|
|
46
|
+
3. [Configuration](https://better-auth.nuxt.dev/getting-started/configuration)
|
|
47
|
+
4. [Client setup](https://better-auth.nuxt.dev/getting-started/client-setup)
|
|
48
|
+
5. [Route protection](https://better-auth.nuxt.dev/core-concepts/route-protection)
|
|
49
|
+
|
|
50
|
+
## Development
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
pnpm install
|
|
54
|
+
pnpm dev:docs
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Useful commands:
|
|
58
|
+
|
|
59
|
+
- `pnpm dev` to run the playground
|
|
60
|
+
- `pnpm dev:docs` to run the docs site
|
|
61
|
+
- `pnpm lint` to lint the repo
|
|
62
|
+
- `pnpm test` to run the test suite
|
|
63
|
+
- `pnpm build:docs` to build the docs site
|
|
24
64
|
|
|
25
65
|
## License
|
|
26
66
|
|
|
27
|
-
MIT
|
|
67
|
+
[MIT](https://github.com/nuxt-modules/better-auth/blob/main/LICENSE)
|
package/dist/module.d.mts
CHANGED
|
@@ -1,9 +1,31 @@
|
|
|
1
1
|
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
+
import { Nuxt } from '@nuxt/schema';
|
|
2
3
|
import { BetterAuthModuleOptions } from '../dist/runtime/config.js';
|
|
3
4
|
export { BetterAuthModuleOptions, defineClientAuth, defineServerAuth } from '../dist/runtime/config.js';
|
|
4
5
|
import { BetterAuthOptions } from 'better-auth';
|
|
5
|
-
export { Auth, AuthMeta, AuthMode, AuthRouteRules, AuthSession, AuthUser, InferSession, InferUser, RequireSessionOptions, ServerAuthContext, UserMatch } from '../dist/runtime/types.js';
|
|
6
|
+
export { AppSession, Auth, AuthActionError, AuthMeta, AuthMode, AuthRouteRules, AuthSession, AuthSocialProviderId, AuthUser, InferSession, InferUser, RequireSessionOptions, ServerAuthContext, UserMatch } from '../dist/runtime/types.js';
|
|
6
7
|
|
|
8
|
+
type DbDialect = 'sqlite' | 'postgresql' | 'mysql';
|
|
9
|
+
|
|
10
|
+
interface BetterAuthDatabaseProviderBuildContext {
|
|
11
|
+
hubDialect: DbDialect;
|
|
12
|
+
usePlural: boolean;
|
|
13
|
+
camelCase: boolean;
|
|
14
|
+
}
|
|
15
|
+
interface BetterAuthDatabaseProviderSetupContext {
|
|
16
|
+
nuxt: Nuxt;
|
|
17
|
+
options: BetterAuthModuleOptions;
|
|
18
|
+
clientOnly: boolean;
|
|
19
|
+
}
|
|
20
|
+
interface BetterAuthDatabaseProviderEnabledContext extends BetterAuthDatabaseProviderSetupContext {
|
|
21
|
+
hasHubDbAvailable: boolean;
|
|
22
|
+
}
|
|
23
|
+
interface BetterAuthDatabaseProviderDefinition {
|
|
24
|
+
buildDatabaseCode: (ctx: BetterAuthDatabaseProviderBuildContext) => string;
|
|
25
|
+
setup?: (ctx: BetterAuthDatabaseProviderSetupContext) => void | Promise<void>;
|
|
26
|
+
isEnabled?: (ctx: BetterAuthDatabaseProviderEnabledContext) => boolean;
|
|
27
|
+
priority?: number;
|
|
28
|
+
}
|
|
7
29
|
declare module '@nuxt/schema' {
|
|
8
30
|
interface NuxtHooks {
|
|
9
31
|
/**
|
|
@@ -12,6 +34,11 @@ declare module '@nuxt/schema' {
|
|
|
12
34
|
* @param config - Partial config to merge into the auth options
|
|
13
35
|
*/
|
|
14
36
|
'better-auth:config:extend': (config: Partial<BetterAuthOptions>) => void | Promise<void>;
|
|
37
|
+
/**
|
|
38
|
+
* Register or override Better Auth database providers.
|
|
39
|
+
* Providers are auto-selected via `isEnabled` + `priority`.
|
|
40
|
+
*/
|
|
41
|
+
'better-auth:database:providers': (providers: Record<string, BetterAuthDatabaseProviderDefinition>) => void | Promise<void>;
|
|
15
42
|
}
|
|
16
43
|
}
|
|
17
44
|
|
package/dist/module.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onmax/nuxt-better-auth",
|
|
3
|
+
"version": "0.0.2",
|
|
3
4
|
"configKey": "auth",
|
|
4
5
|
"compatibility": {
|
|
5
|
-
"nuxt": ">=
|
|
6
|
+
"nuxt": ">=4.0.0"
|
|
6
7
|
},
|
|
7
|
-
"version": "0.0.2-alpha.8",
|
|
8
8
|
"builder": {
|
|
9
9
|
"@nuxt/module-builder": "1.0.2",
|
|
10
|
-
"unbuild": "
|
|
10
|
+
"unbuild": "unknown"
|
|
11
11
|
}
|
|
12
12
|
}
|