@lenne.tech/nuxt-extensions 1.5.3 → 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 +23 -20
- package/dist/runtime/components/transition/LtTransitionFade.vue +1 -3
- package/dist/runtime/components/transition/LtTransitionFadeScale.vue +1 -3
- package/dist/runtime/composables/auth/use-lt-auth.d.ts +1 -1
- package/dist/runtime/composables/auth/use-lt-auth.js +12 -35
- package/dist/runtime/composables/auth/use-system-setup.d.ts +1 -1
- package/dist/runtime/composables/index.d.ts +7 -7
- package/dist/runtime/composables/use-lt-auth-client.d.ts +1 -1
- package/dist/runtime/composables/use-lt-auth-client.js +1 -4
- package/dist/runtime/composables/use-lt-error-translation.d.ts +1 -1
- package/dist/runtime/composables/use-lt-error-translation.js +1 -4
- package/dist/runtime/composables/use-lt-file.d.ts +1 -1
- package/dist/runtime/composables/use-lt-share.js +1 -4
- package/dist/runtime/composables/use-lt-tus-upload.d.ts +1 -1
- package/dist/runtime/composables/use-lt-tus-upload.js +1 -3
- package/dist/runtime/lib/auth-client.d.ts +2 -2
- package/dist/runtime/lib/auth-client.js +4 -16
- package/dist/runtime/lib/auth-state.d.ts +34 -3
- package/dist/runtime/lib/auth-state.js +41 -10
- package/dist/runtime/lib/index.d.ts +2 -2
- package/dist/runtime/lib/index.js +4 -0
- package/dist/runtime/middleware/setup.d.ts +1 -1
- package/dist/runtime/plugins/auth-interceptor.client.d.ts +1 -1
- package/dist/runtime/plugins/auth-interceptor.client.js +1 -8
- package/dist/runtime/plugins/error-translation.client.d.ts +1 -1
- package/dist/runtime/testing/index.d.ts +1 -1
- package/dist/runtime/testing/playwright-helpers.d.ts +2 -2
- package/dist/runtime/types/auth.d.ts +2 -2
- package/dist/runtime/types/error.d.ts +1 -1
- package/dist/runtime/types/index.d.ts +4 -4
- package/dist/runtime/types/module.d.ts +37 -2
- package/dist/runtime/types/upload.d.ts +2 -2
- package/dist/runtime/utils/index.d.ts +2 -2
- package/dist/types.d.mts +2 -2
- package/package.json +15 -34
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") },
|
|
@@ -125,13 +137,7 @@ const module$1 = defineNuxtModule({
|
|
|
125
137
|
{ name: "createLtAuthFetch", from: resolve("./runtime/lib/auth-state") },
|
|
126
138
|
{ name: "ltAuthFetch", from: resolve("./runtime/lib/auth-state") }
|
|
127
139
|
]);
|
|
128
|
-
const transitionComponents = [
|
|
129
|
-
"LtTransitionFade",
|
|
130
|
-
"LtTransitionSlide",
|
|
131
|
-
"LtTransitionSlideBottom",
|
|
132
|
-
"LtTransitionSlideRevert",
|
|
133
|
-
"LtTransitionFadeScale"
|
|
134
|
-
];
|
|
140
|
+
const transitionComponents = ["LtTransitionFade", "LtTransitionSlide", "LtTransitionSlideBottom", "LtTransitionSlideRevert", "LtTransitionFadeScale"];
|
|
135
141
|
for (const componentName of transitionComponents) {
|
|
136
142
|
addComponent({
|
|
137
143
|
name: componentName,
|
|
@@ -152,18 +158,15 @@ const module$1 = defineNuxtModule({
|
|
|
152
158
|
addPlugin(resolve("./runtime/plugins/error-translation.client"));
|
|
153
159
|
}
|
|
154
160
|
if (resolvedOptions.i18n?.autoMerge) {
|
|
155
|
-
nuxt.hook(
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
);
|
|
161
|
+
nuxt.hook("i18n:registerModule", (register) => {
|
|
162
|
+
register({
|
|
163
|
+
langDir: resolve("./runtime/locales"),
|
|
164
|
+
locales: [
|
|
165
|
+
{ code: "en", file: "en.json" },
|
|
166
|
+
{ code: "de", file: "de.json" }
|
|
167
|
+
]
|
|
168
|
+
});
|
|
169
|
+
});
|
|
167
170
|
}
|
|
168
171
|
nuxt.options.build.transpile.push(resolve("./runtime"));
|
|
169
172
|
nuxt.options.build.transpile.push("tus-js-client");
|
|
@@ -175,4 +178,4 @@ const module$1 = defineNuxtModule({
|
|
|
175
178
|
}
|
|
176
179
|
});
|
|
177
180
|
|
|
178
|
-
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 };
|
|
@@ -6,9 +6,7 @@ const props = defineProps({
|
|
|
6
6
|
</script>
|
|
7
7
|
|
|
8
8
|
<template>
|
|
9
|
-
<div
|
|
10
|
-
:style="`--start-duration: ${props.startDuration}ms; --leave-duration: ${props.leaveDuration}ms;`"
|
|
11
|
-
>
|
|
9
|
+
<div :style="`--start-duration: ${props.startDuration}ms; --leave-duration: ${props.leaveDuration}ms;`">
|
|
12
10
|
<Transition
|
|
13
11
|
enter-active-class="transition ease-out duration-[--start-duration]"
|
|
14
12
|
enter-from-class="transform opacity-0"
|
|
@@ -6,9 +6,7 @@ const props = defineProps({
|
|
|
6
6
|
</script>
|
|
7
7
|
|
|
8
8
|
<template>
|
|
9
|
-
<div
|
|
10
|
-
:style="`--start-duration: ${props.startDuration}ms; --leave-duration: ${props.leaveDuration}ms;`"
|
|
11
|
-
>
|
|
9
|
+
<div :style="`--start-duration: ${props.startDuration}ms; --leave-duration: ${props.leaveDuration}ms;`">
|
|
12
10
|
<Transition
|
|
13
11
|
enter-active-class="transition ease-out duration-[--start-duration]"
|
|
14
12
|
enter-from-class="transform opacity-0 scale-95"
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* - If session cookie works -> use cookies
|
|
10
10
|
* - If cookies fail (401) -> switch to JWT mode
|
|
11
11
|
*/
|
|
12
|
-
import type { UseLtAuthReturn } from
|
|
12
|
+
import type { UseLtAuthReturn } from '../../types/index.js';
|
|
13
13
|
/**
|
|
14
14
|
* Better Auth composable with Cookie/JWT dual-mode authentication
|
|
15
15
|
*
|
|
@@ -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"
|
|
@@ -51,10 +52,7 @@ export function useLtAuth() {
|
|
|
51
52
|
const isAuthenticated = computed(() => !!user.value);
|
|
52
53
|
const isAdmin = computed(() => user.value?.role === "admin");
|
|
53
54
|
const is2FAEnabled = computed(() => user.value?.twoFactorEnabled ?? false);
|
|
54
|
-
const features = useState(
|
|
55
|
-
"lt-auth-features",
|
|
56
|
-
() => ({})
|
|
57
|
-
);
|
|
55
|
+
const features = useState("lt-auth-features", () => ({}));
|
|
58
56
|
const featuresFetched = useState("lt-auth-features-fetched", () => false);
|
|
59
57
|
function setUser(userData, mode = "cookie") {
|
|
60
58
|
const newState = { user: userData, authMode: mode };
|
|
@@ -62,7 +60,7 @@ export function useLtAuth() {
|
|
|
62
60
|
if (import.meta.client) {
|
|
63
61
|
const maxAge = 60 * 60 * 24 * 7;
|
|
64
62
|
const secure = globalThis.location?.protocol === "https:" ? "; secure" : "";
|
|
65
|
-
document.cookie =
|
|
63
|
+
document.cookie = `${stateCookieName}=${encodeURIComponent(JSON.stringify(newState))}; path=/; max-age=${maxAge}; samesite=lax${secure}`;
|
|
66
64
|
}
|
|
67
65
|
}
|
|
68
66
|
function clearUser() {
|
|
@@ -70,23 +68,7 @@ export function useLtAuth() {
|
|
|
70
68
|
authState.value = clearedState;
|
|
71
69
|
jwtToken.value = null;
|
|
72
70
|
if (import.meta.client) {
|
|
73
|
-
|
|
74
|
-
const secure = globalThis.location?.protocol === "https:" ? "; secure" : "";
|
|
75
|
-
document.cookie = `lt-auth-state=${encodeURIComponent(JSON.stringify(clearedState))}; path=/; max-age=${maxAge}; samesite=lax${secure}`;
|
|
76
|
-
document.cookie = `lt-jwt-token=; path=/; max-age=0`;
|
|
77
|
-
const sessionCookieNames = [
|
|
78
|
-
"better-auth.session_token",
|
|
79
|
-
"better-auth.session",
|
|
80
|
-
"__Secure-better-auth.session_token",
|
|
81
|
-
"session_token",
|
|
82
|
-
"session"
|
|
83
|
-
];
|
|
84
|
-
for (const name of sessionCookieNames) {
|
|
85
|
-
document.cookie = `${name}=; path=/; max-age=0`;
|
|
86
|
-
document.cookie = `${name}=; path=/api; max-age=0`;
|
|
87
|
-
document.cookie = `${name}=; path=/api/iam; max-age=0`;
|
|
88
|
-
document.cookie = `${name}=; path=/iam; max-age=0`;
|
|
89
|
-
}
|
|
71
|
+
clearLtAuthCookies();
|
|
90
72
|
}
|
|
91
73
|
}
|
|
92
74
|
async function switchToJwtMode() {
|
|
@@ -180,9 +162,7 @@ export function useLtAuth() {
|
|
|
180
162
|
async function fetchFeatures() {
|
|
181
163
|
try {
|
|
182
164
|
const apiBase = getLtApiBase();
|
|
183
|
-
const result = await $fetch(
|
|
184
|
-
`${apiBase}/features`
|
|
185
|
-
);
|
|
165
|
+
const result = await $fetch(`${apiBase}/features`);
|
|
186
166
|
if (result) {
|
|
187
167
|
features.value = result;
|
|
188
168
|
featuresFetched.value = true;
|
|
@@ -258,12 +238,9 @@ export function useLtAuth() {
|
|
|
258
238
|
isLoading.value = true;
|
|
259
239
|
try {
|
|
260
240
|
const apiBase = getLtApiBase();
|
|
261
|
-
const optionsResponse = await fetchWithAuth(
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
method: "GET"
|
|
265
|
-
}
|
|
266
|
-
);
|
|
241
|
+
const optionsResponse = await fetchWithAuth(`${apiBase}/passkey/generate-authenticate-options`, {
|
|
242
|
+
method: "GET"
|
|
243
|
+
});
|
|
267
244
|
if (!optionsResponse.ok) {
|
|
268
245
|
return {
|
|
269
246
|
success: false,
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*
|
|
9
9
|
* URL handling is delegated to {@link buildLtApiUrl} (SSR / proxy / direct).
|
|
10
10
|
*/
|
|
11
|
-
import type { ComputedRef } from
|
|
11
|
+
import type { ComputedRef } from 'vue';
|
|
12
12
|
export interface UseSystemSetupReturn {
|
|
13
13
|
/** Whether the system needs initial setup (null = not checked yet) */
|
|
14
14
|
needsSetup: ComputedRef<boolean | null>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { useLtAuth } from
|
|
2
|
-
export { useSystemSetup } from
|
|
3
|
-
export { useLtAuthClient, ltAuthClient } from
|
|
4
|
-
export { useLtTusUpload } from
|
|
5
|
-
export { useLtFile } from
|
|
6
|
-
export { useLtShare, type UseLtShareReturn } from
|
|
7
|
-
export { useLtErrorTranslation } from
|
|
1
|
+
export { useLtAuth } from './auth/use-lt-auth.js';
|
|
2
|
+
export { useSystemSetup } from './auth/use-system-setup.js';
|
|
3
|
+
export { useLtAuthClient, ltAuthClient } from './use-lt-auth-client.js';
|
|
4
|
+
export { useLtTusUpload } from './use-lt-tus-upload.js';
|
|
5
|
+
export { useLtFile } from './use-lt-file.js';
|
|
6
|
+
export { useLtShare, type UseLtShareReturn } from './use-lt-share.js';
|
|
7
|
+
export { useLtErrorTranslation } from './use-lt-error-translation.js';
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* await authClient.passkey.listUserPasskeys();
|
|
17
17
|
* ```
|
|
18
18
|
*/
|
|
19
|
-
import { type LtAuthClient } from
|
|
19
|
+
import { type LtAuthClient } from '../lib/auth-client.js';
|
|
20
20
|
/**
|
|
21
21
|
* Reset the auth client singleton (useful for testing or config changes)
|
|
22
22
|
*/
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import { useRuntimeConfig } from "#imports";
|
|
2
|
-
import {
|
|
3
|
-
getOrCreateLtAuthClient,
|
|
4
|
-
resetLtAuthClientSingleton
|
|
5
|
-
} from "../lib/auth-client.js";
|
|
2
|
+
import { getOrCreateLtAuthClient, resetLtAuthClientSingleton } from "../lib/auth-client.js";
|
|
6
3
|
import { isLocalDevApiProxy } from "../lib/auth-state.js";
|
|
7
4
|
export function resetLtAuthClient() {
|
|
8
5
|
resetLtAuthClientSingleton();
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
*
|
|
10
10
|
* URL handling is delegated to {@link buildLtApiUrl} (SSR / proxy / direct).
|
|
11
11
|
*/
|
|
12
|
-
import type { UseLtErrorTranslationReturn } from
|
|
12
|
+
import type { UseLtErrorTranslationReturn } from '../types/error.js';
|
|
13
13
|
/**
|
|
14
14
|
* Error Translation composable
|
|
15
15
|
*
|
|
@@ -4,10 +4,7 @@ const ERROR_CODE_REGEX = /^#([A-Z_]+_\d+):\s*(.+)$/;
|
|
|
4
4
|
export function useLtErrorTranslation() {
|
|
5
5
|
const nuxtApp = useNuxtApp();
|
|
6
6
|
const runtimeConfig = useRuntimeConfig();
|
|
7
|
-
const translations = useState(
|
|
8
|
-
"lt-error-translations",
|
|
9
|
-
() => ({})
|
|
10
|
-
);
|
|
7
|
+
const translations = useState("lt-error-translations", () => ({}));
|
|
11
8
|
const isLoading = ref(false);
|
|
12
9
|
const config = runtimeConfig.public?.ltExtensions?.errorTranslation;
|
|
13
10
|
function t(key, germanFallback) {
|
|
@@ -32,10 +32,7 @@ export function useLtShare() {
|
|
|
32
32
|
const toast = useToast();
|
|
33
33
|
toast.add({
|
|
34
34
|
color: "success",
|
|
35
|
-
description: t(
|
|
36
|
-
"lt.share.copiedDescription",
|
|
37
|
-
"Der Link wurde in die Zwischenablage kopiert."
|
|
38
|
-
),
|
|
35
|
+
description: t("lt.share.copiedDescription", "Der Link wurde in die Zwischenablage kopiert."),
|
|
39
36
|
title: t("lt.share.copied", "Link kopiert")
|
|
40
37
|
});
|
|
41
38
|
} catch {
|
|
@@ -5,9 +5,7 @@ async function getTusModule() {
|
|
|
5
5
|
try {
|
|
6
6
|
tusModule = await import("tus-js-client");
|
|
7
7
|
} catch {
|
|
8
|
-
throw new Error(
|
|
9
|
-
"[useLtTusUpload] tus-js-client is not installed. Please install it: npm install tus-js-client"
|
|
10
|
-
);
|
|
8
|
+
throw new Error("[useLtTusUpload] tus-js-client is not installed. Please install it: npm install tus-js-client");
|
|
11
9
|
}
|
|
12
10
|
}
|
|
13
11
|
return tusModule;
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* SECURITY: Passwords are hashed with SHA256 client-side to prevent
|
|
8
8
|
* plain text password transmission over the network.
|
|
9
9
|
*/
|
|
10
|
-
import type { LtAuthClientConfig } from
|
|
10
|
+
import type { LtAuthClientConfig } from '../types/index.js';
|
|
11
11
|
/**
|
|
12
12
|
* Register additional Better Auth plugins before auth client initialization.
|
|
13
13
|
*
|
|
@@ -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";
|
|
@@ -95,14 +95,8 @@ export function createLtAuthClient(config = {}) {
|
|
|
95
95
|
*/
|
|
96
96
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
97
97
|
changePassword: async (params, options) => {
|
|
98
|
-
const [hashedCurrent, hashedNew] = await Promise.all([
|
|
99
|
-
|
|
100
|
-
ltSha256(params.newPassword)
|
|
101
|
-
]);
|
|
102
|
-
return baseClient.changePassword?.(
|
|
103
|
-
{ currentPassword: hashedCurrent, newPassword: hashedNew },
|
|
104
|
-
options
|
|
105
|
-
);
|
|
98
|
+
const [hashedCurrent, hashedNew] = await Promise.all([ltSha256(params.currentPassword), ltSha256(params.newPassword)]);
|
|
99
|
+
return baseClient.changePassword?.({ currentPassword: hashedCurrent, newPassword: hashedNew }, options);
|
|
106
100
|
},
|
|
107
101
|
/**
|
|
108
102
|
* Reset password with token (new password is hashed before sending)
|
|
@@ -110,10 +104,7 @@ export function createLtAuthClient(config = {}) {
|
|
|
110
104
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
111
105
|
resetPassword: async (params, options) => {
|
|
112
106
|
const hashedPassword = await ltSha256(params.newPassword);
|
|
113
|
-
return baseClient.resetPassword?.(
|
|
114
|
-
{ newPassword: hashedPassword, token: params.token },
|
|
115
|
-
options
|
|
116
|
-
);
|
|
107
|
+
return baseClient.resetPassword?.({ newPassword: hashedPassword, token: params.token }, options);
|
|
117
108
|
},
|
|
118
109
|
// Override signIn to hash password (keep passkey method from plugin)
|
|
119
110
|
signIn: {
|
|
@@ -173,10 +164,7 @@ export function createLtAuthClient(config = {}) {
|
|
|
173
164
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
174
165
|
generateBackupCodes: async (params, options) => {
|
|
175
166
|
const hashedPassword = await ltSha256(params.password);
|
|
176
|
-
return baseClient.twoFactor.generateBackupCodes(
|
|
177
|
-
{ password: hashedPassword },
|
|
178
|
-
options
|
|
179
|
-
);
|
|
167
|
+
return baseClient.twoFactor.generateBackupCodes({ password: hashedPassword }, options);
|
|
180
168
|
},
|
|
181
169
|
/**
|
|
182
170
|
* Verify TOTP code (pass through to base client)
|
|
@@ -11,7 +11,21 @@
|
|
|
11
11
|
*
|
|
12
12
|
* The state is persisted in cookies for SSR compatibility.
|
|
13
13
|
*/
|
|
14
|
-
import type { LtAuthMode } from
|
|
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) {
|
|
@@ -33,9 +47,7 @@ export function buildLtApiUrl(path) {
|
|
|
33
47
|
if (import.meta.server) {
|
|
34
48
|
const apiUrl2 = runtimeConfig.apiUrl || publicUrl || authBaseURL;
|
|
35
49
|
if (!apiUrl2) {
|
|
36
|
-
console.warn(
|
|
37
|
-
"[LtExtensions] No API URL configured. Set NUXT_API_URL or NUXT_PUBLIC_API_URL."
|
|
38
|
-
);
|
|
50
|
+
console.warn("[LtExtensions] No API URL configured. Set NUXT_API_URL or NUXT_PUBLIC_API_URL.");
|
|
39
51
|
}
|
|
40
52
|
return `${(apiUrl2 || "").replace(/\/+$/, "")}${path}`;
|
|
41
53
|
}
|
|
@@ -54,7 +66,8 @@ export function buildLtApiUrl(path) {
|
|
|
54
66
|
export function getLtAuthMode() {
|
|
55
67
|
if (import.meta.server) return "cookie";
|
|
56
68
|
try {
|
|
57
|
-
const
|
|
69
|
+
const { state: stateCookieName } = getLtAuthCookieNames();
|
|
70
|
+
const cookie = document.cookie.split("; ").find((row) => row.startsWith(`${stateCookieName}=`));
|
|
58
71
|
if (cookie) {
|
|
59
72
|
const parts = cookie.split("=");
|
|
60
73
|
const value = parts.length > 1 ? decodeURIComponent(parts.slice(1).join("=")) : "";
|
|
@@ -68,7 +81,8 @@ export function getLtAuthMode() {
|
|
|
68
81
|
export function getLtJwtToken() {
|
|
69
82
|
if (import.meta.server) return null;
|
|
70
83
|
try {
|
|
71
|
-
const
|
|
84
|
+
const { token: tokenCookieName } = getLtAuthCookieNames();
|
|
85
|
+
const cookie = document.cookie.split("; ").find((row) => row.startsWith(`${tokenCookieName}=`));
|
|
72
86
|
if (cookie) {
|
|
73
87
|
const parts = cookie.split("=");
|
|
74
88
|
const value = parts.length > 1 ? decodeURIComponent(parts.slice(1).join("=")) : "";
|
|
@@ -83,18 +97,34 @@ export function getLtJwtToken() {
|
|
|
83
97
|
}
|
|
84
98
|
export function setLtJwtToken(token) {
|
|
85
99
|
if (import.meta.server) return;
|
|
100
|
+
const { token: tokenCookieName } = getLtAuthCookieNames();
|
|
86
101
|
const maxAge = 60 * 60 * 24 * 7;
|
|
87
102
|
const secure = globalThis.location?.protocol === "https:" ? "; secure" : "";
|
|
88
103
|
if (token) {
|
|
89
|
-
document.cookie =
|
|
104
|
+
document.cookie = `${tokenCookieName}=${encodeURIComponent(JSON.stringify(token))}; path=/; max-age=${maxAge}; samesite=lax${secure}`;
|
|
90
105
|
} else {
|
|
91
|
-
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`;
|
|
92
121
|
}
|
|
93
122
|
}
|
|
94
123
|
export function setLtAuthMode(mode) {
|
|
95
124
|
if (import.meta.server) return;
|
|
96
125
|
try {
|
|
97
|
-
const
|
|
126
|
+
const { state: stateCookieName } = getLtAuthCookieNames();
|
|
127
|
+
const cookie = document.cookie.split("; ").find((row) => row.startsWith(`${stateCookieName}=`));
|
|
98
128
|
let state = { user: null, authMode: mode };
|
|
99
129
|
if (cookie) {
|
|
100
130
|
const parts = cookie.split("=");
|
|
@@ -103,7 +133,7 @@ export function setLtAuthMode(mode) {
|
|
|
103
133
|
}
|
|
104
134
|
const maxAge = 60 * 60 * 24 * 7;
|
|
105
135
|
const secure = globalThis.location?.protocol === "https:" ? "; secure" : "";
|
|
106
|
-
document.cookie =
|
|
136
|
+
document.cookie = `${stateCookieName}=${encodeURIComponent(JSON.stringify(state))}; path=/; max-age=${maxAge}; samesite=lax${secure}`;
|
|
107
137
|
} catch {
|
|
108
138
|
}
|
|
109
139
|
}
|
|
@@ -141,7 +171,8 @@ export async function attemptLtJwtSwitch(basePath = "/iam") {
|
|
|
141
171
|
export function isLtAuthenticated() {
|
|
142
172
|
if (import.meta.server) return false;
|
|
143
173
|
try {
|
|
144
|
-
const
|
|
174
|
+
const { state: stateCookieName } = getLtAuthCookieNames();
|
|
175
|
+
const cookie = document.cookie.split("; ").find((row) => row.startsWith(`${stateCookieName}=`));
|
|
145
176
|
if (cookie) {
|
|
146
177
|
const parts = cookie.split("=");
|
|
147
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
|
|
2
|
-
export { clearLtAuthPluginRegistry, createLtAuthClient, getOrCreateLtAuthClient, getLtAuthPluginRegistry, registerLtAuthPlugins, resetLtAuthClientSingleton, type LtAuthClient, } from
|
|
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
|
+
export { clearLtAuthPluginRegistry, createLtAuthClient, getOrCreateLtAuthClient, getLtAuthPluginRegistry, registerLtAuthPlugins, resetLtAuthClientSingleton, type LtAuthClient, } from './auth-client.js';
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
export {
|
|
2
2
|
attemptLtJwtSwitch,
|
|
3
|
+
clearLtAuthCookies,
|
|
3
4
|
createLtAuthFetch,
|
|
4
5
|
getLtApiBase,
|
|
6
|
+
getLtAuthCookieNames,
|
|
5
7
|
getLtAuthMode,
|
|
6
8
|
getLtJwtToken,
|
|
7
9
|
isLtAuthenticated,
|
|
10
|
+
LT_AUTH_STATE_COOKIE_DEFAULT,
|
|
11
|
+
LT_JWT_TOKEN_COOKIE_DEFAULT,
|
|
8
12
|
ltAuthFetch,
|
|
9
13
|
setLtAuthMode,
|
|
10
14
|
setLtJwtToken
|
|
@@ -8,6 +8,6 @@
|
|
|
8
8
|
* - needsSetup === true AND route != setupPath -> redirect to setupPath
|
|
9
9
|
* - needsSetup === false AND route === setupPath -> redirect to loginPath
|
|
10
10
|
*/
|
|
11
|
-
import type { RouteMiddleware } from
|
|
11
|
+
import type { RouteMiddleware } from '#app';
|
|
12
12
|
declare const _default: RouteMiddleware;
|
|
13
13
|
export default _default;
|
|
@@ -9,6 +9,6 @@
|
|
|
9
9
|
* Note: This is a client-only plugin (.client.ts) since auth state
|
|
10
10
|
* management only makes sense in the browser context.
|
|
11
11
|
*/
|
|
12
|
-
import type { NuxtApp } from
|
|
12
|
+
import type { NuxtApp } from '#app';
|
|
13
13
|
declare const _default: (nuxtApp: NuxtApp) => void;
|
|
14
14
|
export default _default;
|
|
@@ -12,14 +12,7 @@ export default (nuxtApp) => {
|
|
|
12
12
|
const loginPath = runtimeConfig.loginPath || "/auth/login";
|
|
13
13
|
const configuredPublicPaths = runtimeConfig.interceptor?.publicPaths || [];
|
|
14
14
|
let isHandling401 = false;
|
|
15
|
-
const defaultPublicPaths = [
|
|
16
|
-
"/auth/login",
|
|
17
|
-
"/auth/register",
|
|
18
|
-
"/auth/forgot-password",
|
|
19
|
-
"/auth/reset-password",
|
|
20
|
-
"/auth/2fa",
|
|
21
|
-
"/auth/setup"
|
|
22
|
-
];
|
|
15
|
+
const defaultPublicPaths = ["/auth/login", "/auth/register", "/auth/forgot-password", "/auth/reset-password", "/auth/2fa", "/auth/setup"];
|
|
23
16
|
const publicAuthPaths = [.../* @__PURE__ */ new Set([...defaultPublicPaths, ...configuredPublicPaths])];
|
|
24
17
|
function isPublicAuthRoute() {
|
|
25
18
|
const router = nuxtApp.$router;
|
|
@@ -4,6 +4,6 @@
|
|
|
4
4
|
* Automatically loads error translations on app start.
|
|
5
5
|
* Provides global helper methods: $ltTranslateError, $ltShowErrorToast
|
|
6
6
|
*/
|
|
7
|
-
import type { ObjectPlugin, Plugin } from
|
|
7
|
+
import type { ObjectPlugin, Plugin } from '#app';
|
|
8
8
|
declare const _default: Plugin & ObjectPlugin;
|
|
9
9
|
export default _default;
|
|
@@ -18,4 +18,4 @@
|
|
|
18
18
|
*
|
|
19
19
|
* @packageDocumentation
|
|
20
20
|
*/
|
|
21
|
-
export { waitForHydration, gotoAndWaitForHydration, waitForURLAndHydration, DEFAULT_HYDRATION_TIMEOUT, fillInput, fillInputs, generateTestUser, generateRandomString, generateTOTP, extractTOTPSecret, parseTOTPUrl, waitForElement, waitForNetworkIdle, hasText, getAllText, type TestUser, } from
|
|
21
|
+
export { waitForHydration, gotoAndWaitForHydration, waitForURLAndHydration, DEFAULT_HYDRATION_TIMEOUT, fillInput, fillInputs, generateTestUser, generateRandomString, generateTOTP, extractTOTPSecret, parseTOTPUrl, waitForElement, waitForNetworkIdle, hasText, getAllText, type TestUser, } from './playwright-helpers.js';
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
* });
|
|
21
21
|
* ```
|
|
22
22
|
*/
|
|
23
|
-
import type { Page } from
|
|
23
|
+
import type { Page } from '@playwright/test';
|
|
24
24
|
/**
|
|
25
25
|
* Default timeout for hydration waiting (in milliseconds)
|
|
26
26
|
*/
|
|
@@ -191,7 +191,7 @@ export declare function generateRandomString(length?: number, charset?: string):
|
|
|
191
191
|
export declare function generateTOTP(secret: string, options?: {
|
|
192
192
|
digits?: number;
|
|
193
193
|
period?: number;
|
|
194
|
-
algorithm?:
|
|
194
|
+
algorithm?: 'sha1' | 'sha256' | 'sha512';
|
|
195
195
|
}): string;
|
|
196
196
|
/**
|
|
197
197
|
* Extract TOTP secret from otpauth:// URL
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ComputedRef, Ref } from
|
|
1
|
+
import type { ComputedRef, Ref } from 'vue';
|
|
2
2
|
/**
|
|
3
3
|
* User type for Better Auth session
|
|
4
4
|
* Compatible with @lenne.tech/nest-server IAM module
|
|
@@ -20,7 +20,7 @@ export interface LtUser {
|
|
|
20
20
|
* - 'cookie': Primary mode using HttpOnly session cookies (more secure)
|
|
21
21
|
* - 'jwt': Fallback mode using JWT tokens in Authorization header
|
|
22
22
|
*/
|
|
23
|
-
export type LtAuthMode =
|
|
23
|
+
export type LtAuthMode = 'cookie' | 'jwt';
|
|
24
24
|
/**
|
|
25
25
|
* Stored auth state (persisted in cookie for SSR compatibility)
|
|
26
26
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type { LtAuthClientConfig, LtAuthMode, LtAuthResponse, LtAuthState, LtPasskeyAuthResult, LtPasskeyRegisterResult, LtUser, UseLtAuthReturn
|
|
2
|
-
export type { LtFileInfo, LtUploadItem, LtUploadOptions, LtUploadProgress, LtUploadStatus, UseLtFileReturn, UseLtTusUploadReturn
|
|
3
|
-
export type { LtAuthModuleOptions, LtErrorTranslationModuleOptions, LtExtensionsModuleOptions, LtExtensionsPublicRuntimeConfig, LtI18nModuleOptions, LtSystemSetupModuleOptions, LtTusModuleOptions, } from
|
|
4
|
-
export type { LtErrorTranslationResponse, LtParsedError, UseLtErrorTranslationReturn
|
|
1
|
+
export type { LtAuthClientConfig, LtAuthMode, LtAuthResponse, LtAuthState, LtPasskeyAuthResult, LtPasskeyRegisterResult, LtUser, UseLtAuthReturn } from './auth.js';
|
|
2
|
+
export type { LtFileInfo, LtUploadItem, LtUploadOptions, LtUploadProgress, LtUploadStatus, UseLtFileReturn, UseLtTusUploadReturn } from './upload.js';
|
|
3
|
+
export type { LtAuthCookieNamesOptions, LtAuthModuleOptions, LtErrorTranslationModuleOptions, LtExtensionsModuleOptions, LtExtensionsPublicRuntimeConfig, LtI18nModuleOptions, LtSystemSetupModuleOptions, LtTusModuleOptions, } from './module.js';
|
|
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;
|
|
@@ -122,11 +157,11 @@ export interface LtExtensionsPublicRuntimeConfig {
|
|
|
122
157
|
};
|
|
123
158
|
};
|
|
124
159
|
}
|
|
125
|
-
declare module
|
|
160
|
+
declare module 'nuxt/schema' {
|
|
126
161
|
interface PublicRuntimeConfig extends LtExtensionsPublicRuntimeConfig {
|
|
127
162
|
}
|
|
128
163
|
}
|
|
129
|
-
declare module
|
|
164
|
+
declare module '@nuxt/schema' {
|
|
130
165
|
interface PublicRuntimeConfig extends LtExtensionsPublicRuntimeConfig {
|
|
131
166
|
}
|
|
132
167
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { ComputedRef } from
|
|
1
|
+
import type { ComputedRef } from 'vue';
|
|
2
2
|
/**
|
|
3
3
|
* Status of an upload item
|
|
4
4
|
*/
|
|
5
|
-
export type LtUploadStatus =
|
|
5
|
+
export type LtUploadStatus = 'completed' | 'error' | 'idle' | 'paused' | 'uploading';
|
|
6
6
|
/**
|
|
7
7
|
* Progress information for an upload
|
|
8
8
|
*/
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { ltArrayBufferToBase64Url, ltBase64UrlToUint8Array, ltSha256 } from
|
|
2
|
-
export { tw } from
|
|
1
|
+
export { ltArrayBufferToBase64Url, ltBase64UrlToUint8Array, ltSha256 } from './crypto.js';
|
|
2
|
+
export { tw } from './tw.js';
|
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",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"prepare": "git config core.hooksPath .githooks",
|
|
51
51
|
"prepack": "node scripts/sync-module-version.mjs && nuxt-module-build build",
|
|
52
52
|
"c": "pnpm run check",
|
|
53
|
-
"check": "pnpm audit && pnpm run format:check && pnpm run lint && pnpm test:types && pnpm test && pnpm run build",
|
|
53
|
+
"check": "pnpm audit && pnpm run format:check && pnpm run lint && pnpm run dev:prepare && pnpm test:types && pnpm test && pnpm run build",
|
|
54
54
|
"check:fix": "pnpm install && pnpm audit --fix && pnpm run format && pnpm run lint:fix && pnpm test:types && pnpm test && pnpm run build",
|
|
55
55
|
"check:naf": "pnpm install && pnpm run format && pnpm run lint:fix && pnpm test:types && pnpm test && pnpm run build",
|
|
56
56
|
"cf": "pnpm run check:fix",
|
|
@@ -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,47 +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
|
-
"yaml@>=2.0.0 <2.8.3": ">=2.8.3"
|
|
137
|
-
}
|
|
118
|
+
]
|
|
138
119
|
},
|
|
139
120
|
"keywords": [
|
|
140
121
|
"nuxt",
|