@peterbud/nuxt-aegis 1.1.0-alpha → 1.1.0-alpha.1
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
CHANGED
|
@@ -48,7 +48,7 @@ You get full control over user data persistence while Aegis handles the security
|
|
|
48
48
|
### 1. Install
|
|
49
49
|
|
|
50
50
|
```bash
|
|
51
|
-
npx nuxi module add nuxt-aegis
|
|
51
|
+
npx nuxi module add @peterbud/nuxt-aegis
|
|
52
52
|
```
|
|
53
53
|
|
|
54
54
|
### 2. Configure
|
|
@@ -57,7 +57,7 @@ Add the module and provider configuration to `nuxt.config.ts`:
|
|
|
57
57
|
|
|
58
58
|
```typescript
|
|
59
59
|
export default defineNuxtConfig({
|
|
60
|
-
modules: ['nuxt-aegis'],
|
|
60
|
+
modules: ['@peterbud/nuxt-aegis'],
|
|
61
61
|
|
|
62
62
|
nuxtAegis: {
|
|
63
63
|
token: {
|
|
@@ -114,17 +114,20 @@ const { user, isLoggedIn, login, logout } = useAuth()
|
|
|
114
114
|
|
|
115
115
|
Ready to dive deeper? Check out the full documentation:
|
|
116
116
|
|
|
117
|
-
- **[Getting Started](
|
|
118
|
-
- **[
|
|
119
|
-
- **[
|
|
120
|
-
- **[
|
|
121
|
-
- **[
|
|
117
|
+
- **[Getting Started](https://peterbud.github.io/nuxt-aegis/getting-started/installation)** - Installation and setup guides.
|
|
118
|
+
- **[Architecture](https://peterbud.github.io/nuxt-aegis/architecture/)** - Overview of the system architecture.
|
|
119
|
+
- **[Providers](https://peterbud.github.io/nuxt-aegis/providers/)** - Configure Google, GitHub, Auth0, Password, and Mock providers.
|
|
120
|
+
- **[Configuration](https://peterbud.github.io/nuxt-aegis/configuration/)** - Detailed configuration options.
|
|
121
|
+
- **[Route Protection](https://peterbud.github.io/nuxt-aegis/guides/route-protection)** - Learn how to protect your pages and API routes.
|
|
122
|
+
- **[Custom Claims](https://peterbud.github.io/nuxt-aegis/guides/custom-claims)** - Add custom data to your JWTs.
|
|
123
|
+
- **[API Reference](https://peterbud.github.io/nuxt-aegis/api/)** - Detailed API documentation.
|
|
122
124
|
|
|
123
125
|
## Contributing
|
|
124
126
|
|
|
125
127
|
Contributions are welcome! Please see the [Requirements Specification](/specs/requirements.md) for detailed technical requirements.
|
|
126
128
|
|
|
127
|
-
|
|
129
|
+
<details>
|
|
130
|
+
<summary>Local development</summary>
|
|
128
131
|
|
|
129
132
|
```bash
|
|
130
133
|
# Install dependencies
|
|
@@ -139,6 +142,10 @@ pnpm test
|
|
|
139
142
|
# Lint & type check
|
|
140
143
|
pnpm lint
|
|
141
144
|
```
|
|
145
|
+
</details>
|
|
146
|
+
|
|
147
|
+
If you want to report a bug, please make sure you have a minimal reproduction of the issue. You can use the [minimal example](https://stackblitz.com/github/peterbud/nuxt-aegis/tree/main/examples/minimal?title=Nuxt-Aegis%20Minimal%20Example) to create a reproduction.
|
|
148
|
+
|
|
142
149
|
|
|
143
150
|
## License
|
|
144
151
|
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineNuxtModule, updateRuntimeConfig, useLogger, createResolver, addPlugin, addImports, extendPages, addServerImportsDir, addServerImports, addServerHandler, addServerPlugin, addRouteMiddleware,
|
|
1
|
+
import { defineNuxtModule, updateRuntimeConfig, useLogger, createResolver, addPlugin, addImports, extendPages, addServerImportsDir, addServerImports, addServerHandler, addServerPlugin, addRouteMiddleware, addTypeTemplate } from '@nuxt/kit';
|
|
2
2
|
import { defu } from 'defu';
|
|
3
3
|
|
|
4
4
|
const module$1 = defineNuxtModule({
|
|
@@ -139,7 +139,6 @@ const module$1 = defineNuxtModule({
|
|
|
139
139
|
// Authentication utilities (from auth.ts)
|
|
140
140
|
{ name: "requireAuth", from: resolver.resolve("./runtime/server/utils/auth") },
|
|
141
141
|
{ name: "getAuthUser", from: resolver.resolve("./runtime/server/utils/auth") },
|
|
142
|
-
{ name: "generateAccessToken", from: resolver.resolve("./runtime/server/utils/auth") },
|
|
143
142
|
{ name: "verifyToken", from: resolver.resolve("./runtime/server/utils/auth") },
|
|
144
143
|
{ name: "generateAuthTokens", from: resolver.resolve("./runtime/server/utils/auth") },
|
|
145
144
|
// Refresh token management utilities (from refreshToken.ts)
|
|
@@ -148,9 +147,6 @@ const module$1 = defineNuxtModule({
|
|
|
148
147
|
{ name: "hashRefreshToken", from: resolver.resolve("./runtime/server/utils/refreshToken") },
|
|
149
148
|
// Cookie utilities (from cookies.ts)
|
|
150
149
|
{ name: "setRefreshTokenCookie", from: resolver.resolve("./runtime/server/utils/cookies") },
|
|
151
|
-
{ name: "getRefreshTokenFromCookie", from: resolver.resolve("./runtime/server/utils/cookies") },
|
|
152
|
-
// Custom claims utilities (from customClaims.ts)
|
|
153
|
-
{ name: "applyCustomClaims", from: resolver.resolve("./runtime/server/utils/customClaims") },
|
|
154
150
|
// Handler utilities (from handler.ts)
|
|
155
151
|
{ name: "defineAegisHandler", from: resolver.resolve("./runtime/server/utils/handler") },
|
|
156
152
|
{ name: "useAegisHandler", from: resolver.resolve("./runtime/server/utils/handler") }
|
|
@@ -309,12 +305,18 @@ const module$1 = defineNuxtModule({
|
|
|
309
305
|
path: resolver.resolve("./runtime/app/router.options")
|
|
310
306
|
});
|
|
311
307
|
});
|
|
308
|
+
nuxt.options.alias["#nuxt-aegis"] = resolver.resolve(
|
|
309
|
+
"./runtime/types/index"
|
|
310
|
+
);
|
|
311
|
+
nuxt.hook("nitro:config", (nitroConfig) => {
|
|
312
|
+
nitroConfig.alias = nitroConfig.alias || {};
|
|
313
|
+
nitroConfig.alias["#nuxt-aegis"] = resolver.resolve("./runtime/types/index");
|
|
314
|
+
});
|
|
312
315
|
const typesPath = resolver.resolve("./runtime/types");
|
|
313
|
-
|
|
314
|
-
filename: "types/nuxt-aegis.d.ts",
|
|
315
|
-
write: true,
|
|
316
|
+
addTypeTemplate({
|
|
317
|
+
filename: "types/nuxt-aegis-nitro.d.ts",
|
|
316
318
|
getContents: () => {
|
|
317
|
-
return `import type { NitroAegisAuth
|
|
319
|
+
return `import type { NitroAegisAuth } from ${JSON.stringify(typesPath)}
|
|
318
320
|
|
|
319
321
|
type NuxtAegisRouteRules = {
|
|
320
322
|
/**
|
|
@@ -344,8 +346,7 @@ declare module 'nitropack' {
|
|
|
344
346
|
}
|
|
345
347
|
}
|
|
346
348
|
|
|
347
|
-
|
|
348
|
-
export { type CustomTokenClaims }`;
|
|
349
|
+
export {}`;
|
|
349
350
|
}
|
|
350
351
|
});
|
|
351
352
|
}
|
|
@@ -69,7 +69,7 @@ interface UseAuthReturn<T extends TokenPayload = TokenPayload> {
|
|
|
69
69
|
* const { user, login, logout } = useAuth()
|
|
70
70
|
*
|
|
71
71
|
* // With custom claims
|
|
72
|
-
* import type { CustomTokenClaims } from '#
|
|
72
|
+
* import type { CustomTokenClaims } from '#nuxt-aegis'
|
|
73
73
|
*
|
|
74
74
|
* type AppTokenPayload = CustomTokenClaims<{
|
|
75
75
|
* role: string
|
|
@@ -91,4 +91,4 @@ export declare function requireAuth<T extends TokenPayload = TokenPayload>(event
|
|
|
91
91
|
* })
|
|
92
92
|
* ```
|
|
93
93
|
*/
|
|
94
|
-
export declare function getAuthUser<T extends TokenPayload = TokenPayload>(event: H3Event): T;
|
|
94
|
+
export declare function getAuthUser<T extends TokenPayload = TokenPayload>(event: H3Event): T | null;
|
|
@@ -44,11 +44,7 @@ export function requireAuth(event) {
|
|
|
44
44
|
}
|
|
45
45
|
export function getAuthUser(event) {
|
|
46
46
|
if (!event.context.user) {
|
|
47
|
-
|
|
48
|
-
statusCode: 401,
|
|
49
|
-
statusMessage: "Unauthorized",
|
|
50
|
-
message: "Authentication required"
|
|
51
|
-
});
|
|
47
|
+
return null;
|
|
52
48
|
}
|
|
53
49
|
return event.context.user;
|
|
54
50
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@peterbud/nuxt-aegis",
|
|
3
|
-
"version": "1.1.0-alpha",
|
|
3
|
+
"version": "1.1.0-alpha.1",
|
|
4
4
|
"description": "Nuxt module for authentication with JWT token generation and session management.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -43,6 +43,7 @@
|
|
|
43
43
|
"dev:build": "nuxi build playground",
|
|
44
44
|
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
|
|
45
45
|
"docs:dev": "pnpm --filter docs docs:dev",
|
|
46
|
+
"docs:build": "pnpm --filter docs docs:build",
|
|
46
47
|
"release": "pnpm run lint && pnpm run test && pnpm run prepack && changelogen --release && npm publish && git push --follow-tags",
|
|
47
48
|
"lint": "eslint .",
|
|
48
49
|
"lint:fix": "eslint . --fix",
|