@meistrari/auth-nuxt 3.3.2 → 3.3.4

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.d.mts CHANGED
@@ -1,5 +1,28 @@
1
1
  import { NuxtModule } from '@nuxt/schema';
2
2
 
3
+ /**
4
+ * Configuration options for the `@meistrari/auth-nuxt` Nuxt module.
5
+ *
6
+ * Set these under the `telaAuth` key in your `nuxt.config.ts`:
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * export default defineNuxtConfig({
11
+ * modules: ['@meistrari/auth-nuxt'],
12
+ * telaAuth: {
13
+ * apiUrl: 'https://auth.example.com',
14
+ * jwtCookieName: 'tela-jwt',
15
+ * skipServerMiddleware: false,
16
+ * application: {
17
+ * enabled: true,
18
+ * dashboardUrl: 'https://dashboard.example.com',
19
+ * applicationId: 'app-123',
20
+ * redirectUri: 'https://myapp.com/auth/callback',
21
+ * },
22
+ * },
23
+ * })
24
+ * ```
25
+ */
3
26
  interface ModuleOptions {
4
27
  /** Auth API base URL */
5
28
  apiUrl: string;
@@ -22,6 +45,17 @@ interface ModuleOptions {
22
45
  unauthorizedPath?: string;
23
46
  };
24
47
  }
48
+ /**
49
+ * The `@meistrari/auth-nuxt` Nuxt module.
50
+ *
51
+ * Registers composables, plugins, server middleware, and server routes for
52
+ * authentication. Supports two modes:
53
+ *
54
+ * - **Application mode** (`application.enabled: true`): OAuth 2.0 PKCE flow with
55
+ * access/refresh token management, role-based route guards, and organization switching.
56
+ * - **Session mode** (default): JWT handshake-based authentication with session
57
+ * and organization composables.
58
+ */
25
59
  declare const module$1: NuxtModule<ModuleOptions, ModuleOptions, false>;
26
60
 
27
61
  export { module$1 as default };
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@meistrari/auth-nuxt",
3
3
  "configKey": "telaAuth",
4
- "version": "3.3.2",
4
+ "version": "3.3.4",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
@@ -42,6 +42,12 @@ export declare function useOrganizationState(): {
42
42
  };
43
43
  } | null>;
44
44
  };
45
+ /**
46
+ * Shared state for application-mode authentication.
47
+ * This module provides access to user and organization state for the OAuth 2.0 PKCE flow.
48
+ *
49
+ * @returns An object containing reactive references to the current user and active organization
50
+ */
45
51
  export declare function useApplicationSessionState(): {
46
52
  user: Ref<User | null>;
47
53
  activeOrganization: Ref<FullOrganization | null>;
@@ -1,4 +1,22 @@
1
1
  import type { AuthenticatedH3Event } from '../types/h3.js';
2
+ /**
3
+ * Creates a server middleware that verifies the JWT token using JWKS and calls
4
+ * the provided handler with an authenticated event context.
5
+ *
6
+ * Use this to wrap individual route handlers when the global middleware is disabled
7
+ * via `skipServerMiddleware: true` in application authentication mode.
8
+ *
9
+ * @param callback - The event handler to call with the authenticated event
10
+ * @returns An H3 event handler with authentication context
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * export default meistrariApplicationAuthMiddleware(async (event) => {
15
+ * const user = event.context.auth.user
16
+ * return { user }
17
+ * })
18
+ * ```
19
+ */
2
20
  export declare function meistrariApplicationAuthMiddleware(callback: (event: AuthenticatedH3Event) => void | Promise<void>): import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<void>>;
3
21
  declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<void>>;
4
22
  export default _default;
@@ -1,4 +1,22 @@
1
1
  import type { AuthenticatedH3Event } from '../types/h3.js';
2
+ /**
3
+ * Creates a server middleware that validates the JWT token and calls the provided
4
+ * handler with an authenticated event context.
5
+ *
6
+ * Use this to wrap individual route handlers when the global middleware is disabled
7
+ * via `skipServerMiddleware: true`.
8
+ *
9
+ * @param callback - The event handler to call with the authenticated event
10
+ * @returns An H3 event handler with authentication context
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * export default meistrariAuthMiddleware(async (event) => {
15
+ * const user = event.context.auth.user
16
+ * return { user }
17
+ * })
18
+ * ```
19
+ */
2
20
  export declare function meistrariAuthMiddleware(callback: (event: AuthenticatedH3Event) => void | Promise<void>): import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<void>>;
3
21
  declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<void>>;
4
22
  export default _default;
@@ -1,3 +1,11 @@
1
+ /**
2
+ * Server route handler for user logout
3
+ *
4
+ * This route:
5
+ * 1. Deletes the access and refresh token cookies
6
+ * 2. Calls the auth API to invalidate the refresh token server-side
7
+ * 3. Returns success even if the remote invalidation fails (local logout is sufficient)
8
+ */
1
9
  declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<{
2
10
  success: boolean;
3
11
  }>>;
@@ -1,4 +1,12 @@
1
1
  import type { FullOrganization, User } from '@meistrari/auth-core';
2
+ /**
3
+ * Server route handler for retrieving the current user and active organization
4
+ *
5
+ * This route:
6
+ * 1. Retrieves the access token from the cookie
7
+ * 2. Calls the auth API to get the current user and organization data
8
+ * 3. Returns the user and organization
9
+ */
2
10
  declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<{
3
11
  success: boolean;
4
12
  user: User;
@@ -1,2 +1,13 @@
1
1
  import { AuthClient } from '@meistrari/auth-core';
2
+ /**
3
+ * Creates an {@link AuthClient} instance configured for use within a Nuxt application.
4
+ *
5
+ * Automatically sets the `X-User-Agent` header with SDK version and service name,
6
+ * and attaches authorization and refresh token headers to outgoing requests.
7
+ *
8
+ * @param apiUrl - The base URL of the authentication API
9
+ * @param getAuthToken - Function that returns the current JWT access token, or `null` if not available
10
+ * @param getRefreshToken - Function that returns the current refresh token, or `null` if not available
11
+ * @returns A configured {@link AuthClient} instance
12
+ */
2
13
  export declare function createNuxtAuthClient(apiUrl: string, getAuthToken: () => string | null, getRefreshToken?: () => string | null): AuthClient;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meistrari/auth-nuxt",
3
- "version": "3.3.2",
3
+ "version": "3.3.4",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -32,7 +32,8 @@
32
32
  "dist"
33
33
  ],
34
34
  "scripts": {
35
- "build": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxt-module-build build"
35
+ "build": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxt-module-build build",
36
+ "docs": "typedoc"
36
37
  },
37
38
  "dependencies": {
38
39
  "@meistrari/auth-core": "1.15.0",
@@ -54,6 +55,8 @@
54
55
  "nuxt": "4.0.3",
55
56
  "typescript": "5.9.2",
56
57
  "unbuild": "3.6.1",
58
+ "typedoc": "0.28.18",
59
+ "typedoc-plugin-markdown": "4.11.0",
57
60
  "vitest": "3.2.4",
58
61
  "vue-tsc": "3.0.6"
59
62
  }