@lenne.tech/nuxt-extensions 1.5.4 → 1.6.0
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 +4 -2
- package/dist/module.mjs +13 -1
- package/dist/runtime/composables/auth/use-lt-auth.js +7 -16
- package/dist/runtime/lib/auth-client.d.ts +1 -1
- package/dist/runtime/lib/auth-state.d.ts +33 -2
- package/dist/runtime/lib/auth-state.js +40 -7
- package/dist/runtime/lib/index.d.ts +1 -1
- package/dist/runtime/lib/index.js +15 -1
- package/dist/runtime/types/index.d.ts +1 -1
- package/dist/runtime/types/module.d.ts +35 -0
- package/dist/types.d.mts +2 -2
- package/package.json +14 -35
package/dist/module.d.mts
CHANGED
|
@@ -2,12 +2,14 @@ import * as _nuxt_schema from '@nuxt/schema';
|
|
|
2
2
|
import { LtExtensionsModuleOptions } from '../dist/runtime/types/index.js';
|
|
3
3
|
export { LtAuthClientConfig, LtAuthMode, LtAuthResponse, LtAuthState, LtPasskeyAuthResult, LtPasskeyRegisterResult, LtUser, UseLtAuthReturn } from '../dist/runtime/types/auth.js';
|
|
4
4
|
export { LtFileInfo, LtUploadItem, LtUploadOptions, LtUploadProgress, LtUploadStatus, UseLtFileReturn, UseLtTusUploadReturn } from '../dist/runtime/types/upload.js';
|
|
5
|
-
export { LtAuthModuleOptions, LtErrorTranslationModuleOptions, LtExtensionsModuleOptions, LtExtensionsPublicRuntimeConfig, LtI18nModuleOptions, LtSystemSetupModuleOptions, LtTusModuleOptions } from '../dist/runtime/types/module.js';
|
|
5
|
+
export { LtAuthCookieNamesOptions, LtAuthModuleOptions, LtErrorTranslationModuleOptions, LtExtensionsModuleOptions, LtExtensionsPublicRuntimeConfig, LtI18nModuleOptions, LtSystemSetupModuleOptions, LtTusModuleOptions } from '../dist/runtime/types/module.js';
|
|
6
6
|
export { LtErrorTranslationResponse, LtParsedError, UseLtErrorTranslationReturn } from '../dist/runtime/types/error.js';
|
|
7
7
|
|
|
8
8
|
declare const name = "@lenne.tech/nuxt-extensions";
|
|
9
9
|
declare const version = "1.5.2";
|
|
10
10
|
declare const configKey = "ltExtensions";
|
|
11
|
+
declare const DEFAULT_LT_AUTH_STATE_COOKIE = "lt-auth-state";
|
|
12
|
+
declare const DEFAULT_LT_JWT_TOKEN_COOKIE = "lt-jwt-token";
|
|
11
13
|
declare const _default: _nuxt_schema.NuxtModule<LtExtensionsModuleOptions, LtExtensionsModuleOptions, false>;
|
|
12
14
|
|
|
13
|
-
export { configKey, _default as default, name, version };
|
|
15
|
+
export { DEFAULT_LT_AUTH_STATE_COOKIE, DEFAULT_LT_JWT_TOKEN_COOKIE, configKey, _default as default, name, version };
|
package/dist/module.mjs
CHANGED
|
@@ -3,10 +3,16 @@ import { defineNuxtModule, createResolver, addImports, addComponent, addPlugin,
|
|
|
3
3
|
const name = "@lenne.tech/nuxt-extensions";
|
|
4
4
|
const version = "1.5.2";
|
|
5
5
|
const configKey = "ltExtensions";
|
|
6
|
+
const DEFAULT_LT_AUTH_STATE_COOKIE = "lt-auth-state";
|
|
7
|
+
const DEFAULT_LT_JWT_TOKEN_COOKIE = "lt-jwt-token";
|
|
6
8
|
const defaultOptions = {
|
|
7
9
|
auth: {
|
|
8
10
|
basePath: "/iam",
|
|
9
11
|
baseURL: "",
|
|
12
|
+
cookieNames: {
|
|
13
|
+
state: DEFAULT_LT_AUTH_STATE_COOKIE,
|
|
14
|
+
token: DEFAULT_LT_JWT_TOKEN_COOKIE
|
|
15
|
+
},
|
|
10
16
|
enabled: true,
|
|
11
17
|
enableAdmin: true,
|
|
12
18
|
enablePasskey: true,
|
|
@@ -48,6 +54,7 @@ const module$1 = defineNuxtModule({
|
|
|
48
54
|
auth: {
|
|
49
55
|
...defaultOptions.auth,
|
|
50
56
|
...options.auth,
|
|
57
|
+
cookieNames: { ...defaultOptions.auth.cookieNames, ...options.auth?.cookieNames },
|
|
51
58
|
systemSetup: { ...defaultOptions.auth.systemSetup, ...options.auth?.systemSetup }
|
|
52
59
|
},
|
|
53
60
|
errorTranslation: { ...defaultOptions.errorTranslation, ...options.errorTranslation },
|
|
@@ -65,6 +72,10 @@ const module$1 = defineNuxtModule({
|
|
|
65
72
|
auth: {
|
|
66
73
|
basePath: resolvedOptions.auth?.basePath || "/iam",
|
|
67
74
|
baseURL: resolvedOptions.auth?.baseURL || "",
|
|
75
|
+
cookieNames: {
|
|
76
|
+
state: resolvedOptions.auth?.cookieNames?.state || DEFAULT_LT_AUTH_STATE_COOKIE,
|
|
77
|
+
token: resolvedOptions.auth?.cookieNames?.token || DEFAULT_LT_JWT_TOKEN_COOKIE
|
|
78
|
+
},
|
|
68
79
|
enabled: resolvedOptions.auth?.enabled ?? true,
|
|
69
80
|
enableAdmin: resolvedOptions.auth?.enableAdmin ?? true,
|
|
70
81
|
enablePasskey: resolvedOptions.auth?.enablePasskey ?? true,
|
|
@@ -118,6 +129,7 @@ const module$1 = defineNuxtModule({
|
|
|
118
129
|
{ name: "getLtJwtToken", from: resolve("./runtime/lib/auth-state") },
|
|
119
130
|
{ name: "setLtJwtToken", from: resolve("./runtime/lib/auth-state") },
|
|
120
131
|
{ name: "getLtApiBase", from: resolve("./runtime/lib/auth-state") },
|
|
132
|
+
{ name: "getLtAuthCookieNames", from: resolve("./runtime/lib/auth-state") },
|
|
121
133
|
{ name: "buildLtApiUrl", from: resolve("./runtime/lib/auth-state") },
|
|
122
134
|
{ name: "isLocalDevApiProxy", from: resolve("./runtime/lib/auth-state") },
|
|
123
135
|
{ name: "attemptLtJwtSwitch", from: resolve("./runtime/lib/auth-state") },
|
|
@@ -166,4 +178,4 @@ const module$1 = defineNuxtModule({
|
|
|
166
178
|
}
|
|
167
179
|
});
|
|
168
180
|
|
|
169
|
-
export { configKey, module$1 as default, name, version };
|
|
181
|
+
export { DEFAULT_LT_AUTH_STATE_COOKIE, DEFAULT_LT_JWT_TOKEN_COOKIE, configKey, module$1 as default, name, version };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useNuxtApp, useCookie, useState, ref, computed, watch } from "#imports";
|
|
2
2
|
import { ltArrayBufferToBase64Url, ltBase64UrlToUint8Array } from "../../utils/crypto.js";
|
|
3
|
-
import { getLtApiBase } from "../../lib/auth-state.js";
|
|
3
|
+
import { clearLtAuthCookies, getLtApiBase, getLtAuthCookieNames } from "../../lib/auth-state.js";
|
|
4
4
|
import { useLtAuthClient } from "../use-lt-auth-client.js";
|
|
5
5
|
function useTranslation() {
|
|
6
6
|
const nuxtApp = useNuxtApp();
|
|
@@ -15,14 +15,15 @@ function useTranslation() {
|
|
|
15
15
|
export function useLtAuth() {
|
|
16
16
|
const authClient = useLtAuthClient();
|
|
17
17
|
const t = useTranslation();
|
|
18
|
-
const
|
|
18
|
+
const { state: stateCookieName, token: tokenCookieName } = getLtAuthCookieNames();
|
|
19
|
+
const authState = useCookie(stateCookieName, {
|
|
19
20
|
maxAge: 60 * 60 * 24 * 7,
|
|
20
21
|
// 7 days
|
|
21
22
|
sameSite: "lax"
|
|
22
23
|
});
|
|
23
24
|
if (import.meta.client) {
|
|
24
25
|
try {
|
|
25
|
-
const cookieStr = document.cookie.split("; ").find((row) => row.startsWith(
|
|
26
|
+
const cookieStr = document.cookie.split("; ").find((row) => row.startsWith(`${stateCookieName}=`));
|
|
26
27
|
if (cookieStr) {
|
|
27
28
|
const parts = cookieStr.split("=");
|
|
28
29
|
const value = parts.length > 1 ? decodeURIComponent(parts.slice(1).join("=")) : "";
|
|
@@ -39,7 +40,7 @@ export function useLtAuth() {
|
|
|
39
40
|
if (import.meta.server && (authState.value === null || authState.value === void 0)) {
|
|
40
41
|
authState.value = { user: null, authMode: "cookie" };
|
|
41
42
|
}
|
|
42
|
-
const jwtToken = useCookie(
|
|
43
|
+
const jwtToken = useCookie(tokenCookieName, {
|
|
43
44
|
maxAge: 60 * 60 * 24 * 7,
|
|
44
45
|
// 7 days
|
|
45
46
|
sameSite: "lax"
|
|
@@ -59,7 +60,7 @@ export function useLtAuth() {
|
|
|
59
60
|
if (import.meta.client) {
|
|
60
61
|
const maxAge = 60 * 60 * 24 * 7;
|
|
61
62
|
const secure = globalThis.location?.protocol === "https:" ? "; secure" : "";
|
|
62
|
-
document.cookie =
|
|
63
|
+
document.cookie = `${stateCookieName}=${encodeURIComponent(JSON.stringify(newState))}; path=/; max-age=${maxAge}; samesite=lax${secure}`;
|
|
63
64
|
}
|
|
64
65
|
}
|
|
65
66
|
function clearUser() {
|
|
@@ -67,17 +68,7 @@ export function useLtAuth() {
|
|
|
67
68
|
authState.value = clearedState;
|
|
68
69
|
jwtToken.value = null;
|
|
69
70
|
if (import.meta.client) {
|
|
70
|
-
|
|
71
|
-
const secure = globalThis.location?.protocol === "https:" ? "; secure" : "";
|
|
72
|
-
document.cookie = `lt-auth-state=${encodeURIComponent(JSON.stringify(clearedState))}; path=/; max-age=${maxAge}; samesite=lax${secure}`;
|
|
73
|
-
document.cookie = `lt-jwt-token=; path=/; max-age=0`;
|
|
74
|
-
const sessionCookieNames = ["better-auth.session_token", "better-auth.session", "__Secure-better-auth.session_token", "session_token", "session"];
|
|
75
|
-
for (const name of sessionCookieNames) {
|
|
76
|
-
document.cookie = `${name}=; path=/; max-age=0`;
|
|
77
|
-
document.cookie = `${name}=; path=/api; max-age=0`;
|
|
78
|
-
document.cookie = `${name}=; path=/api/iam; max-age=0`;
|
|
79
|
-
document.cookie = `${name}=; path=/iam; max-age=0`;
|
|
80
|
-
}
|
|
71
|
+
clearLtAuthCookies();
|
|
81
72
|
}
|
|
82
73
|
}
|
|
83
74
|
async function switchToJwtMode() {
|
|
@@ -226,8 +226,8 @@ export declare function createLtAuthClient(config?: LtAuthClientConfig): {
|
|
|
226
226
|
onResponse: ((context: import("better-auth/client").ResponseContext) => Promise<Response | void | import("better-auth/client").ResponseContext> | Response | import("better-auth/client").ResponseContext | void) | undefined;
|
|
227
227
|
};
|
|
228
228
|
})[];
|
|
229
|
-
cache?: RequestCache | undefined;
|
|
230
229
|
priority?: RequestPriority | undefined;
|
|
230
|
+
cache?: RequestCache | undefined;
|
|
231
231
|
credentials?: RequestCredentials;
|
|
232
232
|
headers?: (HeadersInit & (HeadersInit | {
|
|
233
233
|
accept: "application/json" | "text/plain" | "application/octet-stream";
|
|
@@ -12,6 +12,20 @@
|
|
|
12
12
|
* The state is persisted in cookies for SSR compatibility.
|
|
13
13
|
*/
|
|
14
14
|
import type { LtAuthMode } from '../types/index.js';
|
|
15
|
+
/** Default name of the auth-state cookie. Used when the module config has not been resolved yet. */
|
|
16
|
+
export declare const LT_AUTH_STATE_COOKIE_DEFAULT = "lt-auth-state";
|
|
17
|
+
/** Default name of the JWT-token cookie. Used when the module config has not been resolved yet. */
|
|
18
|
+
export declare const LT_JWT_TOKEN_COOKIE_DEFAULT = "lt-jwt-token";
|
|
19
|
+
/**
|
|
20
|
+
* Resolve the configured auth cookie names from runtime config.
|
|
21
|
+
*
|
|
22
|
+
* Falls back to the defaults (`lt-auth-state`, `lt-jwt-token`) so callers
|
|
23
|
+
* keep working even outside a Nuxt context (tests, edge SSR boots).
|
|
24
|
+
*/
|
|
25
|
+
export declare function getLtAuthCookieNames(): {
|
|
26
|
+
state: string;
|
|
27
|
+
token: string;
|
|
28
|
+
};
|
|
15
29
|
/**
|
|
16
30
|
* Determines if HTTP requests should use the Nuxt Vite dev proxy.
|
|
17
31
|
*
|
|
@@ -95,7 +109,24 @@ export declare function getLtJwtToken(): string | null;
|
|
|
95
109
|
*/
|
|
96
110
|
export declare function setLtJwtToken(token: string | null): void;
|
|
97
111
|
/**
|
|
98
|
-
*
|
|
112
|
+
* Hard-delete all auth cookies on logout.
|
|
113
|
+
*
|
|
114
|
+
* This is the single source of truth for "remove every auth cookie this
|
|
115
|
+
* module owns". It expires:
|
|
116
|
+
* - the configured auth-state cookie (default `lt-auth-state`)
|
|
117
|
+
* - the configured JWT token cookie (default `lt-jwt-token`)
|
|
118
|
+
* - the Better-Auth session fallbacks the client may have set
|
|
119
|
+
*
|
|
120
|
+
* Browsers only delete a cookie when the path / sameSite / secure
|
|
121
|
+
* attributes match the ones used when it was written, so we mirror the
|
|
122
|
+
* attributes from `setUser()` / `setLtJwtToken()`. The Better-Auth
|
|
123
|
+
* session cookies are httpOnly when set by the API and cannot be touched
|
|
124
|
+
* from JS — clearing them here is best-effort for any non-httpOnly
|
|
125
|
+
* variant the framework might have written client-side.
|
|
126
|
+
*/
|
|
127
|
+
export declare function clearLtAuthCookies(): void;
|
|
128
|
+
/**
|
|
129
|
+
* Update auth mode in the auth-state cookie
|
|
99
130
|
*/
|
|
100
131
|
export declare function setLtAuthMode(mode: LtAuthMode): void;
|
|
101
132
|
/**
|
|
@@ -117,7 +148,7 @@ export declare function getLtApiBase(basePath?: string): string;
|
|
|
117
148
|
*/
|
|
118
149
|
export declare function attemptLtJwtSwitch(basePath?: string): Promise<boolean>;
|
|
119
150
|
/**
|
|
120
|
-
* Check if user is authenticated (has
|
|
151
|
+
* Check if user is authenticated (has auth-state with user)
|
|
121
152
|
*/
|
|
122
153
|
export declare function isLtAuthenticated(): boolean;
|
|
123
154
|
/**
|
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
import { useRuntimeConfig } from "#imports";
|
|
2
|
+
export const LT_AUTH_STATE_COOKIE_DEFAULT = "lt-auth-state";
|
|
3
|
+
export const LT_JWT_TOKEN_COOKIE_DEFAULT = "lt-jwt-token";
|
|
4
|
+
export function getLtAuthCookieNames() {
|
|
5
|
+
try {
|
|
6
|
+
const runtimeConfig = useRuntimeConfig();
|
|
7
|
+
const configured = runtimeConfig.public?.ltExtensions?.auth?.cookieNames;
|
|
8
|
+
return {
|
|
9
|
+
state: configured?.state || LT_AUTH_STATE_COOKIE_DEFAULT,
|
|
10
|
+
token: configured?.token || LT_JWT_TOKEN_COOKIE_DEFAULT
|
|
11
|
+
};
|
|
12
|
+
} catch {
|
|
13
|
+
return { state: LT_AUTH_STATE_COOKIE_DEFAULT, token: LT_JWT_TOKEN_COOKIE_DEFAULT };
|
|
14
|
+
}
|
|
15
|
+
}
|
|
2
16
|
let _proxyFallbackWarned = false;
|
|
3
17
|
export function isLocalDevApiProxy() {
|
|
4
18
|
if (import.meta.server) {
|
|
@@ -52,7 +66,8 @@ export function buildLtApiUrl(path) {
|
|
|
52
66
|
export function getLtAuthMode() {
|
|
53
67
|
if (import.meta.server) return "cookie";
|
|
54
68
|
try {
|
|
55
|
-
const
|
|
69
|
+
const { state: stateCookieName } = getLtAuthCookieNames();
|
|
70
|
+
const cookie = document.cookie.split("; ").find((row) => row.startsWith(`${stateCookieName}=`));
|
|
56
71
|
if (cookie) {
|
|
57
72
|
const parts = cookie.split("=");
|
|
58
73
|
const value = parts.length > 1 ? decodeURIComponent(parts.slice(1).join("=")) : "";
|
|
@@ -66,7 +81,8 @@ export function getLtAuthMode() {
|
|
|
66
81
|
export function getLtJwtToken() {
|
|
67
82
|
if (import.meta.server) return null;
|
|
68
83
|
try {
|
|
69
|
-
const
|
|
84
|
+
const { token: tokenCookieName } = getLtAuthCookieNames();
|
|
85
|
+
const cookie = document.cookie.split("; ").find((row) => row.startsWith(`${tokenCookieName}=`));
|
|
70
86
|
if (cookie) {
|
|
71
87
|
const parts = cookie.split("=");
|
|
72
88
|
const value = parts.length > 1 ? decodeURIComponent(parts.slice(1).join("=")) : "";
|
|
@@ -81,18 +97,34 @@ export function getLtJwtToken() {
|
|
|
81
97
|
}
|
|
82
98
|
export function setLtJwtToken(token) {
|
|
83
99
|
if (import.meta.server) return;
|
|
100
|
+
const { token: tokenCookieName } = getLtAuthCookieNames();
|
|
84
101
|
const maxAge = 60 * 60 * 24 * 7;
|
|
85
102
|
const secure = globalThis.location?.protocol === "https:" ? "; secure" : "";
|
|
86
103
|
if (token) {
|
|
87
|
-
document.cookie =
|
|
104
|
+
document.cookie = `${tokenCookieName}=${encodeURIComponent(JSON.stringify(token))}; path=/; max-age=${maxAge}; samesite=lax${secure}`;
|
|
88
105
|
} else {
|
|
89
|
-
document.cookie =
|
|
106
|
+
document.cookie = `${tokenCookieName}=; path=/; max-age=0; samesite=lax${secure}`;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
export function clearLtAuthCookies() {
|
|
110
|
+
if (import.meta.server) return;
|
|
111
|
+
const { state: stateCookieName, token: tokenCookieName } = getLtAuthCookieNames();
|
|
112
|
+
const secure = globalThis.location?.protocol === "https:" ? "; secure" : "";
|
|
113
|
+
document.cookie = `${stateCookieName}=; path=/; max-age=0; samesite=lax${secure}`;
|
|
114
|
+
document.cookie = `${tokenCookieName}=; path=/; max-age=0; samesite=lax${secure}`;
|
|
115
|
+
const sessionCookieNames = ["better-auth.session_token", "better-auth.session", "__Secure-better-auth.session_token", "session_token", "session"];
|
|
116
|
+
for (const name of sessionCookieNames) {
|
|
117
|
+
document.cookie = `${name}=; path=/; max-age=0`;
|
|
118
|
+
document.cookie = `${name}=; path=/api; max-age=0`;
|
|
119
|
+
document.cookie = `${name}=; path=/api/iam; max-age=0`;
|
|
120
|
+
document.cookie = `${name}=; path=/iam; max-age=0`;
|
|
90
121
|
}
|
|
91
122
|
}
|
|
92
123
|
export function setLtAuthMode(mode) {
|
|
93
124
|
if (import.meta.server) return;
|
|
94
125
|
try {
|
|
95
|
-
const
|
|
126
|
+
const { state: stateCookieName } = getLtAuthCookieNames();
|
|
127
|
+
const cookie = document.cookie.split("; ").find((row) => row.startsWith(`${stateCookieName}=`));
|
|
96
128
|
let state = { user: null, authMode: mode };
|
|
97
129
|
if (cookie) {
|
|
98
130
|
const parts = cookie.split("=");
|
|
@@ -101,7 +133,7 @@ export function setLtAuthMode(mode) {
|
|
|
101
133
|
}
|
|
102
134
|
const maxAge = 60 * 60 * 24 * 7;
|
|
103
135
|
const secure = globalThis.location?.protocol === "https:" ? "; secure" : "";
|
|
104
|
-
document.cookie =
|
|
136
|
+
document.cookie = `${stateCookieName}=${encodeURIComponent(JSON.stringify(state))}; path=/; max-age=${maxAge}; samesite=lax${secure}`;
|
|
105
137
|
} catch {
|
|
106
138
|
}
|
|
107
139
|
}
|
|
@@ -139,7 +171,8 @@ export async function attemptLtJwtSwitch(basePath = "/iam") {
|
|
|
139
171
|
export function isLtAuthenticated() {
|
|
140
172
|
if (import.meta.server) return false;
|
|
141
173
|
try {
|
|
142
|
-
const
|
|
174
|
+
const { state: stateCookieName } = getLtAuthCookieNames();
|
|
175
|
+
const cookie = document.cookie.split("; ").find((row) => row.startsWith(`${stateCookieName}=`));
|
|
143
176
|
if (cookie) {
|
|
144
177
|
const parts = cookie.split("=");
|
|
145
178
|
const value = parts.length > 1 ? decodeURIComponent(parts.slice(1).join("=")) : "";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { attemptLtJwtSwitch, createLtAuthFetch, getLtApiBase, getLtAuthMode, getLtJwtToken, isLtAuthenticated, ltAuthFetch, setLtAuthMode, setLtJwtToken } from './auth-state.js';
|
|
1
|
+
export { attemptLtJwtSwitch, clearLtAuthCookies, createLtAuthFetch, getLtApiBase, getLtAuthCookieNames, getLtAuthMode, getLtJwtToken, isLtAuthenticated, LT_AUTH_STATE_COOKIE_DEFAULT, LT_JWT_TOKEN_COOKIE_DEFAULT, ltAuthFetch, setLtAuthMode, setLtJwtToken, } from './auth-state.js';
|
|
2
2
|
export { clearLtAuthPluginRegistry, createLtAuthClient, getOrCreateLtAuthClient, getLtAuthPluginRegistry, registerLtAuthPlugins, resetLtAuthClientSingleton, type LtAuthClient, } from './auth-client.js';
|
|
@@ -1,4 +1,18 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export {
|
|
2
|
+
attemptLtJwtSwitch,
|
|
3
|
+
clearLtAuthCookies,
|
|
4
|
+
createLtAuthFetch,
|
|
5
|
+
getLtApiBase,
|
|
6
|
+
getLtAuthCookieNames,
|
|
7
|
+
getLtAuthMode,
|
|
8
|
+
getLtJwtToken,
|
|
9
|
+
isLtAuthenticated,
|
|
10
|
+
LT_AUTH_STATE_COOKIE_DEFAULT,
|
|
11
|
+
LT_JWT_TOKEN_COOKIE_DEFAULT,
|
|
12
|
+
ltAuthFetch,
|
|
13
|
+
setLtAuthMode,
|
|
14
|
+
setLtJwtToken
|
|
15
|
+
} from "./auth-state.js";
|
|
2
16
|
export {
|
|
3
17
|
clearLtAuthPluginRegistry,
|
|
4
18
|
createLtAuthClient,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export type { LtAuthClientConfig, LtAuthMode, LtAuthResponse, LtAuthState, LtPasskeyAuthResult, LtPasskeyRegisterResult, LtUser, UseLtAuthReturn } from './auth.js';
|
|
2
2
|
export type { LtFileInfo, LtUploadItem, LtUploadOptions, LtUploadProgress, LtUploadStatus, UseLtFileReturn, UseLtTusUploadReturn } from './upload.js';
|
|
3
|
-
export type { LtAuthModuleOptions, LtErrorTranslationModuleOptions, LtExtensionsModuleOptions, LtExtensionsPublicRuntimeConfig, LtI18nModuleOptions, LtSystemSetupModuleOptions, LtTusModuleOptions, } from './module.js';
|
|
3
|
+
export type { LtAuthCookieNamesOptions, LtAuthModuleOptions, LtErrorTranslationModuleOptions, LtExtensionsModuleOptions, LtExtensionsPublicRuntimeConfig, LtI18nModuleOptions, LtSystemSetupModuleOptions, LtTusModuleOptions, } from './module.js';
|
|
4
4
|
export type { LtErrorTranslationResponse, LtParsedError, UseLtErrorTranslationReturn } from './error.js';
|
|
@@ -24,11 +24,42 @@ export interface LtSystemSetupModuleOptions {
|
|
|
24
24
|
/** Path to the setup page (default: '/auth/setup') */
|
|
25
25
|
setupPath?: string;
|
|
26
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* Configurable cookie names used by the auth module.
|
|
29
|
+
*
|
|
30
|
+
* The two cookies are written and read across `useLtAuth()` and the
|
|
31
|
+
* `auth-state.ts` helpers. Override them per project to avoid clashes
|
|
32
|
+
* when multiple lenne.tech apps share a domain. Each key is independent;
|
|
33
|
+
* unspecified keys keep their default value.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```typescript
|
|
37
|
+
* // nuxt.config.ts
|
|
38
|
+
* export default defineNuxtConfig({
|
|
39
|
+
* ltExtensions: {
|
|
40
|
+
* auth: {
|
|
41
|
+
* cookieNames: {
|
|
42
|
+
* state: 'my-app-auth-state',
|
|
43
|
+
* token: 'my-app-jwt',
|
|
44
|
+
* },
|
|
45
|
+
* },
|
|
46
|
+
* },
|
|
47
|
+
* });
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export interface LtAuthCookieNamesOptions {
|
|
51
|
+
/** Name of the auth-state cookie (default: 'lt-auth-state') */
|
|
52
|
+
state?: string;
|
|
53
|
+
/** Name of the JWT-token cookie (default: 'lt-jwt-token') */
|
|
54
|
+
token?: string;
|
|
55
|
+
}
|
|
27
56
|
export interface LtAuthModuleOptions {
|
|
28
57
|
/** Auth API base path (default: '/iam' - must match nest-server betterAuth.basePath) */
|
|
29
58
|
basePath?: string;
|
|
30
59
|
/** API base URL (default: from env or http://localhost:3000) */
|
|
31
60
|
baseURL?: string;
|
|
61
|
+
/** Override the cookie names used for auth state and JWT storage */
|
|
62
|
+
cookieNames?: LtAuthCookieNamesOptions;
|
|
32
63
|
/** Enable the auth module (default: true) */
|
|
33
64
|
enabled?: boolean;
|
|
34
65
|
/** Enable admin plugin (default: true) */
|
|
@@ -97,6 +128,10 @@ export interface LtExtensionsPublicRuntimeConfig {
|
|
|
97
128
|
auth: {
|
|
98
129
|
basePath: string;
|
|
99
130
|
baseURL: string;
|
|
131
|
+
cookieNames: {
|
|
132
|
+
state: string;
|
|
133
|
+
token: string;
|
|
134
|
+
};
|
|
100
135
|
enabled: boolean;
|
|
101
136
|
enableAdmin: boolean;
|
|
102
137
|
enablePasskey: boolean;
|
package/dist/types.d.mts
CHANGED
|
@@ -8,8 +8,8 @@ export { type LtAuthClientConfig, type LtAuthMode, type LtAuthResponse, type LtA
|
|
|
8
8
|
|
|
9
9
|
export { type LtFileInfo, type LtUploadItem, type LtUploadOptions, type LtUploadProgress, type LtUploadStatus, type UseLtFileReturn, type UseLtTusUploadReturn } from '../dist/runtime/types/upload.js'
|
|
10
10
|
|
|
11
|
-
export { type LtAuthModuleOptions, type LtErrorTranslationModuleOptions, type LtExtensionsModuleOptions, type LtExtensionsPublicRuntimeConfig, type LtI18nModuleOptions, type LtSystemSetupModuleOptions, type LtTusModuleOptions } from '../dist/runtime/types/module.js'
|
|
11
|
+
export { type LtAuthCookieNamesOptions, type LtAuthModuleOptions, type LtErrorTranslationModuleOptions, type LtExtensionsModuleOptions, type LtExtensionsPublicRuntimeConfig, type LtI18nModuleOptions, type LtSystemSetupModuleOptions, type LtTusModuleOptions } from '../dist/runtime/types/module.js'
|
|
12
12
|
|
|
13
13
|
export { type LtErrorTranslationResponse, type LtParsedError, type UseLtErrorTranslationReturn } from '../dist/runtime/types/error.js'
|
|
14
14
|
|
|
15
|
-
export { type configKey, default, type name, type version } from './module.mjs'
|
|
15
|
+
export { type DEFAULT_LT_AUTH_STATE_COOKIE, type DEFAULT_LT_JWT_TOKEN_COOKIE, type configKey, default, type name, type version } from './module.mjs'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lenne.tech/nuxt-extensions",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "Reusable Nuxt 4 composables, components, and Better-Auth integration for lenne.tech projects",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"release": "pnpm format:check && pnpm lint && pnpm test:types && pnpm test && pnpm prepack"
|
|
71
71
|
},
|
|
72
72
|
"dependencies": {
|
|
73
|
-
"@nuxt/kit": "4.4.
|
|
73
|
+
"@nuxt/kit": "4.4.4"
|
|
74
74
|
},
|
|
75
75
|
"peerDependencies": {
|
|
76
76
|
"@better-auth/passkey": ">=1.0.0",
|
|
@@ -94,49 +94,28 @@
|
|
|
94
94
|
}
|
|
95
95
|
},
|
|
96
96
|
"devDependencies": {
|
|
97
|
-
"@better-auth/passkey": "1.
|
|
97
|
+
"@better-auth/passkey": "1.6.10",
|
|
98
98
|
"@nuxt/devtools": "3.2.4",
|
|
99
99
|
"@nuxt/module-builder": "1.0.2",
|
|
100
|
-
"@nuxt/schema": "4.4.
|
|
100
|
+
"@nuxt/schema": "4.4.4",
|
|
101
101
|
"@playwright/test": "1.59.1",
|
|
102
|
-
"@types/node": "25.
|
|
103
|
-
"@vitest/coverage-v8": "4.1.
|
|
104
|
-
"better-auth": "1.
|
|
105
|
-
"happy-dom": "20.
|
|
106
|
-
"nuxt": "4.4.
|
|
107
|
-
"oxfmt": "0.
|
|
108
|
-
"oxlint": "1.
|
|
102
|
+
"@types/node": "25.6.2",
|
|
103
|
+
"@vitest/coverage-v8": "4.1.5",
|
|
104
|
+
"better-auth": "1.6.10",
|
|
105
|
+
"happy-dom": "20.9.0",
|
|
106
|
+
"nuxt": "4.4.4",
|
|
107
|
+
"oxfmt": "0.48.0",
|
|
108
|
+
"oxlint": "1.63.0",
|
|
109
109
|
"tus-js-client": "4.3.1",
|
|
110
110
|
"typescript": "5.9.3",
|
|
111
|
-
"vitest": "4.1.
|
|
112
|
-
"vue-tsc": "3.2.
|
|
111
|
+
"vitest": "4.1.5",
|
|
112
|
+
"vue-tsc": "3.2.8"
|
|
113
113
|
},
|
|
114
114
|
"pnpm": {
|
|
115
115
|
"onlyBuiltDependencies": [
|
|
116
116
|
"@parcel/watcher",
|
|
117
117
|
"esbuild"
|
|
118
|
-
]
|
|
119
|
-
"overrides": {
|
|
120
|
-
"brace-expansion@<2.0.3": ">=2.0.3",
|
|
121
|
-
"brace-expansion@>=4.0.0 <5.0.5": ">=5.0.5",
|
|
122
|
-
"defu@<=6.1.4": ">=6.1.5",
|
|
123
|
-
"h3@<1.15.9": ">=1.15.9",
|
|
124
|
-
"lodash@<=4.17.23": ">=4.18.0",
|
|
125
|
-
"minimatch@>=5.0.0 <5.1.9": "5.1.9",
|
|
126
|
-
"minimatch@>=9.0.0 <9.0.9": "9.0.9",
|
|
127
|
-
"minimatch@>=10.0.0 <10.2.5": "10.2.5",
|
|
128
|
-
"node-forge@<1.4.0": ">=1.4.0",
|
|
129
|
-
"picomatch@<2.3.2": ">=2.3.2",
|
|
130
|
-
"picomatch@>=4.0.0 <4.0.4": ">=4.0.4",
|
|
131
|
-
"rollup@>=4.0.0 <4.59.0": ">=4.59.0",
|
|
132
|
-
"serialize-javascript@<7.0.5": ">=7.0.5",
|
|
133
|
-
"srvx@<0.11.13": ">=0.11.13",
|
|
134
|
-
"svgo@=4.0.0": ">=4.0.1",
|
|
135
|
-
"tar@<7.5.11": "7.5.11",
|
|
136
|
-
"unhead@<2.1.13": ">=2.1.13",
|
|
137
|
-
"vite@<7.3.2": ">=7.3.2",
|
|
138
|
-
"yaml@>=2.0.0 <2.8.3": ">=2.8.3"
|
|
139
|
-
}
|
|
118
|
+
]
|
|
140
119
|
},
|
|
141
120
|
"keywords": [
|
|
142
121
|
"nuxt",
|