@lenne.tech/nuxt-extensions 1.28.0 → 4.0.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/CLAUDE.md CHANGED
@@ -29,7 +29,7 @@ src/
29
29
  | `useLtAuthClient()` | Raw Better Auth client access (`twoFactor.*`, `admin.*`, `passkey`) |
30
30
  | `useSystemSetup()` | First-admin setup flow: status, HTTP-setup release + setup token (nest-server >= 12.4.0) |
31
31
  | `useLtTusUpload()` | TUS resumable file uploads |
32
- | `useLtFile()` | File utilities (size formatting, URLs) |
32
+ | `useLtFile()` | File utilities (size formatting; file links on the API, the public URL also during SSR) |
33
33
  | `useLtShare()` | Web Share API with clipboard fallback |
34
34
  | `useLtErrorTranslation()` | Translate backend error codes |
35
35
 
@@ -65,7 +65,7 @@ export default defineNuxtConfig({
65
65
  enabled: true, // only gates the 401 interceptor (= interceptor.enabled); the auth composables stay
66
66
  basePath: '/iam', // Better-Auth endpoint prefix
67
67
  loginPath: '/auth/login',
68
- enableAdmin: true,
68
+ enableAdmin: false, // nest-server serves no admin routes (DEV-4076)
69
69
  enablePasskey: true,
70
70
  enableTwoFactor: true,
71
71
  },
@@ -74,7 +74,7 @@ export default defineNuxtConfig({
74
74
  defaultLocale: 'de',
75
75
  },
76
76
  tus: {
77
- defaultEndpoint: '/files/upload',
77
+ defaultEndpoint: '/tus', // nest-server's TUS path (default)
78
78
  defaultChunkSize: 5 * 1024 * 1024, // 5MB
79
79
  },
80
80
  i18n: {
@@ -378,9 +378,11 @@ passwords this library does **not** hash. (The setup token of `useSystemSetup().
378
378
  unhashed too, by design — see "First Admin Setup" below.)
379
379
 
380
380
  Today that is harmless: `@lenne.tech/nest-server` does not register better-auth's `admin()`
381
- plugin and has no option to enable it, so those routes 404. But `auth.enableAdmin` defaults to
382
- `true`, meaning the admin *client* plugin is registered in every consuming project — the trap is
383
- armed and waiting for a server that answers.
381
+ plugin and has no option to enable it, so those routes 404. Until DEV-4076 `auth.enableAdmin`
382
+ defaulted to `true`, so the admin *client* plugin was registered in every consuming project — a
383
+ trap armed and waiting for a server that answers. It now defaults to `false`, and `useLtAuth()`
384
+ warns once when a project switches it on while `/iam/features` reports no admin plugin
385
+ (`warnLtAdminPluginUnserved`). Do not flip the default back without the lock-step below.
384
386
 
385
387
  **Enabling `admin()` server-side is therefore a lock-step change across both repos in one
386
388
  release:** the two routes join nest-server's password-normalisation table, and these two methods
@@ -434,6 +436,22 @@ optionally behind a setup token (`LTNS_0054` when wrong). `GET /system-setup/sta
434
436
  - **One declaration per type** under `src/runtime/types`. `test/package-exports.test.ts` holds
435
437
  the last three rules.
436
438
 
439
+ ## Versioning (since 4.0.0)
440
+
441
+ **MAJOR is the Nuxt major, and nothing else moves it.** `4.x` is the line for Nuxt 4. A MINOR is a
442
+ change a project has to act on when it updates (behaviour, code or configuration) and always comes
443
+ with a migration guide; a PATCH is a fix or addition it takes as it is. The same scheme as
444
+ nest-server (major = NestJS) and ng-base (major = Angular). Full rules and the release steps:
445
+ `.claude/rules/versioning.md` (in the repository, not in the npm package).
446
+
447
+ - **A breaking change is a MINOR.** Never raise the major for it, however big the change feels.
448
+ - **2.x and 3.x do not exist.** 4.0.0 follows 1.28.0 directly: 1.x was the Nuxt 4 line, but its
449
+ major did not say so. Older docs here saying "the major digit tracks Nuxt (1.x is Nuxt 4)" mean
450
+ that offset.
451
+ - **When updating a project, read the migration guide of every MINOR in between**
452
+ (`migration-guides/<from>.x-to-<to>.0.md`, from 1.x: `1.x-to-4.0.0.md`). A caret range takes
453
+ MINORs, so the starters pin the exact version.
454
+
437
455
  ## Error Translation: loaded after mount (DEV-4078)
438
456
 
439
457
  `plugins/error-translation.client.ts` starts `loadTranslations()` in `app:mounted` and does not
package/README.md CHANGED
@@ -91,6 +91,24 @@ overrides:
91
91
  '@better-auth/core': 1.7.16 # the api of nest-server-starter projects depends on it directly
92
92
  ```
93
93
 
94
+ ## Versioning
95
+
96
+ Since 4.0.0 the version follows the scheme of `@lenne.tech/nest-server` and `@lenne.tech/ng-base`:
97
+
98
+ | Part | Meaning |
99
+ |---|---|
100
+ | **MAJOR** | The Nuxt major this module is built for: `4.x.x` = Nuxt 4. It moves only with Nuxt. |
101
+ | **MINOR** | A change you have to act on when you update (behaviour, code or configuration), always with a migration guide in [`migration-guides/`](./migration-guides). A breaking change is a minor. |
102
+ | **PATCH** | A fix or addition you can take as it is. |
103
+
104
+ **2.x and 3.x do not exist.** 4.0.0 follows 1.28.0 directly; 1.x was already the Nuxt 4 line. Coming
105
+ from 1.x, read [`migration-guides/1.x-to-4.0.0.md`](./migration-guides/1.x-to-4.0.0.md).
106
+
107
+ **Pin the exact version** (`npm install --save-exact @lenne.tech/nuxt-extensions`), as the starters
108
+ do: a caret range takes minors, which are exactly the changes you have to act on.
109
+ [nuxt-base-starter](https://github.com/lenneTech/nuxt-base-starter) carries the same version as the
110
+ nuxt-extensions release it pins.
111
+
94
112
  ## Features
95
113
 
96
114
  - **Better-Auth Integration** - Login, 2FA, Passkey/WebAuthn support
@@ -175,7 +193,7 @@ export default defineNuxtConfig({
175
193
  twoFactorRedirectPath: '/auth/2fa', // 2FA redirect path
176
194
 
177
195
  // Plugin options
178
- enableAdmin: true, // Admin plugin
196
+ enableAdmin: false, // Admin client plugin (off: nest-server serves no admin routes)
179
197
  enableTwoFactor: true, // 2FA plugin
180
198
  enablePasskey: true, // Passkey/WebAuthn plugin
181
199
 
@@ -200,7 +218,7 @@ export default defineNuxtConfig({
200
218
 
201
219
  // TUS upload configuration
202
220
  tus: {
203
- defaultEndpoint: '/tus', // nest-server's TUS path (module default: '/files/upload')
221
+ defaultEndpoint: '/tus', // nest-server's TUS path (the module default)
204
222
  defaultChunkSize: 5 * 1024 * 1024, // 5MB
205
223
  resolveAgainstApi: true, // relative endpoint = path on the API, like auth/AI requests
206
224
  },
@@ -821,6 +839,17 @@ from the `X-File-Id` response header (nest-server 11.42.13+). Use it for file li
821
839
  is undefined when the backend sends no such header (an older nest-server, or an `onUploadComplete()`
822
840
  override that never calls `super.onUploadComplete(upload)`).
823
841
 
842
+ **File links.** `useLtFile().getFileUrl(id)`, `getDownloadUrl(id, filename?)` and `getFileInfo(id)`
843
+ follow the same rule: they are paths on the API, below the base derived from an endpoint ending in
844
+ `/upload`, otherwise `/files`. The two link helpers point at nest-server's `GET /files/id/<id>`
845
+ (since 11.8.0), which sends the file with the stored filename; nest-server has no rename
846
+ parameter, so `getDownloadUrl()` returns the same URL and ignores `filename`. `getFileInfo()` reads
847
+ `GET /files/info/<id>` (the starter's file controller). `tus.resolveAgainstApi: false` keeps them
848
+ on the app origin, and an absolute base is used as it is.
849
+ The two link helpers return the URL the browser uses, during SSR too: they never contain the
850
+ server-only `NUXT_API_URL`, and server and browser render the same `src`. Only the request
851
+ `getFileInfo()` makes on the server goes to the server-side API URL.
852
+
824
853
  ### Transition Components
825
854
 
826
855
  ```vue
package/dist/module.d.mts CHANGED
@@ -3,7 +3,7 @@ import { LtExtensionsModuleOptions } from '../dist/runtime/types/index.js';
3
3
  export * from '../dist/runtime/types/index.js';
4
4
 
5
5
  declare const name = "@lenne.tech/nuxt-extensions";
6
- declare const version = "1.28.0";
6
+ declare const version = "4.0.0";
7
7
  declare const configKey = "ltExtensions";
8
8
  declare const DEFAULT_LT_AUTH_STATE_COOKIE = "lt-auth-state";
9
9
  declare const DEFAULT_LT_JWT_TOKEN_COOKIE = "lt-jwt-token";
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "configKey": "ltExtensions",
3
3
  "name": "@lenne.tech/nuxt-extensions",
4
- "version": "1.28.0",
4
+ "version": "4.0.0",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.3",
7
7
  "unbuild": "3.6.1"
package/dist/module.mjs CHANGED
@@ -3,7 +3,7 @@ import { pathToFileURL } from 'node:url';
3
3
  import { SECURITY_TXT_DEFAULT_VALID_DAYS, SECURITY_TXT_DEFAULT_LANGUAGES, SECURITY_TXT_DEFAULT_CONTACT, SECURITY_TXT_PATH } from '../dist/runtime/server/lib/security-txt.js';
4
4
 
5
5
  const name = "@lenne.tech/nuxt-extensions";
6
- const version = "1.28.0";
6
+ const version = "4.0.0";
7
7
  const configKey = "ltExtensions";
8
8
  const DEFAULT_LT_AUTH_STATE_COOKIE = "lt-auth-state";
9
9
  const DEFAULT_LT_JWT_TOKEN_COOKIE = "lt-jwt-token";
@@ -20,7 +20,7 @@ const defaultOptions = {
20
20
  token: DEFAULT_LT_JWT_TOKEN_COOKIE
21
21
  },
22
22
  enabled: true,
23
- enableAdmin: true,
23
+ enableAdmin: false,
24
24
  enablePasskey: true,
25
25
  enableTwoFactor: true,
26
26
  interceptor: {
@@ -61,7 +61,7 @@ const defaultOptions = {
61
61
  tus: {
62
62
  defaultChunkSize: 5 * 1024 * 1024,
63
63
  // 5MB
64
- defaultEndpoint: "/files/upload",
64
+ defaultEndpoint: "/tus",
65
65
  resolveAgainstApi: true
66
66
  }
67
67
  };
@@ -133,7 +133,7 @@ const module$1 = defineNuxtModule({
133
133
  token: resolvedOptions.auth?.cookieNames?.token || DEFAULT_LT_JWT_TOKEN_COOKIE
134
134
  },
135
135
  enabled: resolvedOptions.auth?.enabled ?? true,
136
- enableAdmin: resolvedOptions.auth?.enableAdmin ?? true,
136
+ enableAdmin: resolvedOptions.auth?.enableAdmin ?? false,
137
137
  enablePasskey,
138
138
  enableTwoFactor: resolvedOptions.auth?.enableTwoFactor ?? true,
139
139
  interceptor: {
@@ -166,7 +166,7 @@ const module$1 = defineNuxtModule({
166
166
  },
167
167
  tus: {
168
168
  defaultChunkSize: resolvedOptions.tus?.defaultChunkSize || 5 * 1024 * 1024,
169
- defaultEndpoint: resolvedOptions.tus?.defaultEndpoint || "/files/upload",
169
+ defaultEndpoint: resolvedOptions.tus?.defaultEndpoint || "/tus",
170
170
  resolveAgainstApi: resolvedOptions.tus?.resolveAgainstApi ?? true
171
171
  }
172
172
  };
@@ -1,6 +1,16 @@
1
1
  import { useNuxtApp, useCookie, useState, useRequestHeaders, useRuntimeConfig, ref, computed, watch } from "#imports";
2
2
  import { ltArrayBufferToBase64Url, ltBase64UrlToUint8Array } from "../../utils/crypto.js";
3
- import { clearLtAuthCookies, createLtAuthFetchFor, getLtApiBase, getLtAuthCookieNames, getLtJwtToken, isLtJwtShaped, requestLtJwt, resolveLtAuthState } from "../../lib/auth-state.js";
3
+ import {
4
+ clearLtAuthCookies,
5
+ createLtAuthFetchFor,
6
+ getLtApiBase,
7
+ getLtAuthCookieNames,
8
+ getLtJwtToken,
9
+ isLtJwtShaped,
10
+ requestLtJwt,
11
+ resolveLtAuthState,
12
+ warnLtAdminPluginUnserved
13
+ } from "../../lib/auth-state.js";
4
14
  import { useLtAuthClient } from "../use-lt-auth-client.js";
5
15
  const VALIDATE_SESSION_TIMEOUT_MS = 1e4;
6
16
  const LT_SYNC_SIGN_OUT_FLUSH_MS = 5e3;
@@ -205,6 +215,7 @@ export function useLtAuth() {
205
215
  if (result) {
206
216
  features.value = result;
207
217
  featuresFetched.value = true;
218
+ warnLtAdminPluginUnserved(result);
208
219
  }
209
220
  return features.value;
210
221
  } catch {
@@ -1,10 +1,33 @@
1
1
  import { useRuntimeConfig } from "#imports";
2
+ import { resolveLtApiBaseUrl, resolveLtPublicApiBaseUrl, warnMissingLtApiUrl } from "../lib/auth-state.js";
3
+ const ABSOLUTE_URL = /^(?:[a-z][a-z\d+.-]*:|\/\/)/i;
2
4
  export function useLtFile() {
3
5
  const config = useRuntimeConfig();
6
+ const apiBases = (() => {
7
+ try {
8
+ return { link: resolveLtPublicApiBaseUrl(), request: resolveLtApiBaseUrl() };
9
+ } catch {
10
+ return null;
11
+ }
12
+ })();
4
13
  function getFileApiBase() {
5
14
  const endpoint = config.public.ltExtensions?.tus?.defaultEndpoint;
6
15
  return (endpoint?.endsWith("/upload") ? endpoint.slice(0, -"/upload".length) : "") || "/files";
7
16
  }
17
+ function fileApiUrl(path, scope) {
18
+ const url = `${getFileApiBase()}${path}`;
19
+ if (config.public.ltExtensions?.tus?.resolveAgainstApi === false || ABSOLUTE_URL.test(url)) {
20
+ return url;
21
+ }
22
+ if (!apiBases) {
23
+ return url;
24
+ }
25
+ const base = scope === "link" ? apiBases.link : apiBases.request;
26
+ if (base.missing) {
27
+ warnMissingLtApiUrl(scope === "link" ? "client" : apiBases.request.scope);
28
+ }
29
+ return `${base.baseUrl}${url}`;
30
+ }
8
31
  function isValidMongoID(id) {
9
32
  return /^[a-f\d]{24}$/i.test(id);
10
33
  }
@@ -16,8 +39,7 @@ export function useLtFile() {
16
39
  return id;
17
40
  }
18
41
  try {
19
- const apiBase = getFileApiBase();
20
- const response = await $fetch(`${apiBase}/info/${id}`, {
42
+ const response = await $fetch(fileApiUrl(`/info/${id}`, "request"), {
21
43
  credentials: "include",
22
44
  method: "GET"
23
45
  });
@@ -28,13 +50,10 @@ export function useLtFile() {
28
50
  }
29
51
  }
30
52
  function getFileUrl(id) {
31
- const apiBase = getFileApiBase();
32
- return `${apiBase}/${id}`;
53
+ return fileApiUrl(`/id/${encodeURIComponent(id)}`, "link");
33
54
  }
34
- function getDownloadUrl(id, filename) {
35
- const apiBase = getFileApiBase();
36
- const base = `${apiBase}/download/${id}`;
37
- return filename ? `${base}?filename=${encodeURIComponent(filename)}` : base;
55
+ function getDownloadUrl(id, _filename) {
56
+ return getFileUrl(id);
38
57
  }
39
58
  function formatFileSize(bytes) {
40
59
  if (bytes === 0) return "0 B";
@@ -28,7 +28,7 @@ export function useLtTusUpload(defaultOptions = {}) {
28
28
  autoStart: true,
29
29
  chunkSize: tusConfig?.defaultChunkSize || 5 * 1024 * 1024,
30
30
  // 5MB chunks
31
- endpoint: tusConfig?.defaultEndpoint || "/files/upload",
31
+ endpoint: tusConfig?.defaultEndpoint || "/tus",
32
32
  parallelUploads: 3,
33
33
  retryDelays: [0, 1e3, 3e3, 5e3, 1e4],
34
34
  ...Object.fromEntries(Object.entries(defaultOptions).filter(([, value]) => value !== void 0))
@@ -240,9 +240,9 @@ export declare function createLtAuthClient(config?: LtAuthClientConfig): {
240
240
  * normalising those routes, this wrapper would CREATE the credential-store desync it
241
241
  * was meant to prevent.
242
242
  *
243
- * What that costs, stated plainly: `auth.enableAdmin` defaults to `true`, so the admin
244
- * CLIENT plugin is registered in every consuming project. The trap is armed and waiting
245
- * for a server that answers. Enabling `admin()` server-side is therefore a LOCKSTEP
243
+ * What that costs, stated plainly: a project that sets `auth.enableAdmin: true` (the
244
+ * default until DEV-4076) registers the admin CLIENT plugin, and the trap is armed and
245
+ * waiting for a server that answers. Enabling `admin()` server-side is therefore a LOCKSTEP
246
246
  * change — the routes join nest-server's password-normalisation table and these two
247
247
  * methods get `ltSha256` wrappers here, in one release. Half of it produces accounts
248
248
  * whose password nobody can log in with, and nothing warns.
@@ -46,7 +46,7 @@ export function createLtAuthClient(config = {}) {
46
46
  baseURL = defaultBaseURL,
47
47
  basePath = defaultBasePath,
48
48
  twoFactorRedirectPath = "/auth/2fa",
49
- enableAdmin = true,
49
+ enableAdmin = false,
50
50
  enableTwoFactor = true,
51
51
  enablePasskey = true,
52
52
  plugins: externalPlugins = []
@@ -94,9 +94,9 @@ export function createLtAuthClient(config = {}) {
94
94
  * normalising those routes, this wrapper would CREATE the credential-store desync it
95
95
  * was meant to prevent.
96
96
  *
97
- * What that costs, stated plainly: `auth.enableAdmin` defaults to `true`, so the admin
98
- * CLIENT plugin is registered in every consuming project. The trap is armed and waiting
99
- * for a server that answers. Enabling `admin()` server-side is therefore a LOCKSTEP
97
+ * What that costs, stated plainly: a project that sets `auth.enableAdmin: true` (the
98
+ * default until DEV-4076) registers the admin CLIENT plugin, and the trap is armed and
99
+ * waiting for a server that answers. Enabling `admin()` server-side is therefore a LOCKSTEP
100
100
  * change — the routes join nest-server's password-normalisation table and these two
101
101
  * methods get `ltSha256` wrappers here, in one release. Half of it produces accounts
102
102
  * whose password nobody can log in with, and nothing warns.
@@ -90,6 +90,17 @@ export declare function getLtAuthCookieNames(): {
90
90
  * unchanged by the duplicate-tolerant read; it only decides which twin wins.
91
91
  */
92
92
  export declare function resolveLtAuthState(cookieString: string, stateCookieName?: string): LtAuthState | null;
93
+ /**
94
+ * Warn, once, when `auth.enableAdmin` is on but the backend's `/iam/features` reports no admin
95
+ * plugin (DEV-4076).
96
+ *
97
+ * `@lenne.tech/nest-server` does not register Better-Auth's `admin()` plugin: every `admin.*` call
98
+ * answers 404, and `admin.createUser` / `admin.setUserPassword` would send their passwords unhashed
99
+ * if a server ever answered them. A backend that does serve the routes reports `admin: true`.
100
+ *
101
+ * INTERNAL — called by `useLtAuth().fetchFeatures()`. Not part of the public API.
102
+ */
103
+ export declare function warnLtAdminPluginUnserved(features: Record<string, unknown>): void;
93
104
  /**
94
105
  * Clear the one-shot warning state.
95
106
  *
@@ -211,6 +222,33 @@ export declare function warnMissingLtApiUrl(scope: 'client' | 'server'): void;
211
222
  * @param path - The API path (e.g., `/system-setup/status`, `/i18n/errors/de`)
212
223
  */
213
224
  export declare function buildLtApiUrl(path: string): string;
225
+ /**
226
+ * The URL the browser uses for an API path, built the same way during SSR.
227
+ *
228
+ * For links and `src` attributes the server renders and the browser then follows (file links of
229
+ * `useLtFile()`): {@link buildLtApiUrl} would put the server-only `NUXT_API_URL` (an internal
230
+ * cluster address) into the HTML during SSR, and behind the dev proxy the server and the browser
231
+ * would render different strings, a hydration mismatch. Requests the server makes itself keep
232
+ * using {@link buildLtApiUrl}.
233
+ *
234
+ * `/api` + path while the dev proxy is on, otherwise `NUXT_PUBLIC_API_URL` (or `auth.baseURL`) +
235
+ * path; relative (with the one-shot warning) when neither is configured.
236
+ *
237
+ * @param path - The API path (e.g. `/files/abc`)
238
+ */
239
+ export declare function buildLtPublicApiUrl(path: string): string;
240
+ /**
241
+ * The base of {@link buildLtPublicApiUrl}: `'/api'` behind the dev proxy, otherwise the public API
242
+ * URL; `missing` when neither is configured.
243
+ *
244
+ * INTERNAL — for callers that read the base once, while the Nuxt context exists, and build URLs
245
+ * later (`useLtFile()`: after an `await` in a `useAsyncData` handler, `useRuntimeConfig()` throws
246
+ * during SSR). Throws outside a Nuxt runtime-config context; callers catch.
247
+ */
248
+ export declare function resolveLtPublicApiBaseUrl(): {
249
+ baseUrl: string;
250
+ missing: boolean;
251
+ };
214
252
  /**
215
253
  * Get the current auth mode from cookie
216
254
  */
@@ -50,6 +50,20 @@ function warnOnce(key, message) {
50
50
  warnedKeys.add(key);
51
51
  console.warn(message);
52
52
  }
53
+ export function warnLtAdminPluginUnserved(features) {
54
+ try {
55
+ const enableAdmin = useRuntimeConfig().public?.ltExtensions?.auth?.enableAdmin;
56
+ if (enableAdmin !== true || features.admin === true) {
57
+ return;
58
+ }
59
+ } catch {
60
+ return;
61
+ }
62
+ warnOnce(
63
+ "admin-plugin-unserved",
64
+ "[LtAuth] ltExtensions.auth.enableAdmin is on, but the API reports no admin plugin (no `admin` in /iam/features). admin.* calls answer 404, and admin.createUser / admin.setUserPassword are not password-hashed by this module. Switch enableAdmin off unless your backend serves the Better-Auth admin routes."
65
+ );
66
+ }
53
67
  export function resetLtWarnOnceState() {
54
68
  warnedKeys.clear();
55
69
  }
@@ -57,6 +71,9 @@ export function isLocalDevApiProxy() {
57
71
  if (import.meta.server) {
58
72
  return false;
59
73
  }
74
+ return isLtApiProxyConfigured();
75
+ }
76
+ function isLtApiProxyConfigured() {
60
77
  try {
61
78
  const runtimeConfig = useRuntimeConfig();
62
79
  const apiProxy = runtimeConfig.public?.apiProxy;
@@ -111,6 +128,25 @@ export function buildLtApiUrl(path) {
111
128
  return path;
112
129
  }
113
130
  }
131
+ export function buildLtPublicApiUrl(path) {
132
+ try {
133
+ const { baseUrl, missing } = resolveLtPublicApiBaseUrl();
134
+ if (missing) {
135
+ warnMissingLtApiUrl("client");
136
+ }
137
+ return `${baseUrl}${path}`;
138
+ } catch {
139
+ return path;
140
+ }
141
+ }
142
+ export function resolveLtPublicApiBaseUrl() {
143
+ if (isLtApiProxyConfigured()) {
144
+ return { baseUrl: "/api", missing: false };
145
+ }
146
+ const pub = useRuntimeConfig().public;
147
+ const publicUrl = pub.apiUrl || pub.ltExtensions?.auth?.baseURL || "";
148
+ return { baseUrl: stripTrailingSlashes(publicUrl), missing: !publicUrl };
149
+ }
114
150
  export function getLtAuthMode() {
115
151
  if (import.meta.server) return "cookie";
116
152
  return resolveLtAuthState(document.cookie)?.authMode || "cookie";
@@ -74,7 +74,7 @@ export interface LtAuthClientConfig {
74
74
  baseURL?: string;
75
75
  /** Auth API base path (default: '/iam' - must match nest-server betterAuth.basePath) */
76
76
  basePath?: string;
77
- /** Enable admin plugin (default: true) */
77
+ /** Register Better-Auth's admin client plugin (default: false; nest-server serves no admin routes) */
78
78
  enableAdmin?: boolean;
79
79
  /** Enable passkey plugin (default: true) */
80
80
  enablePasskey?: boolean;
@@ -69,7 +69,14 @@ export interface LtAuthModuleOptions {
69
69
  * `interceptor.enabled: false`; prefer that.
70
70
  */
71
71
  enabled?: boolean;
72
- /** Enable admin plugin (default: true) */
72
+ /**
73
+ * Register Better-Auth's admin client plugin (`admin.*`, default: false).
74
+ *
75
+ * `@lenne.tech/nest-server` does not register the server-side `admin()` plugin, so the routes
76
+ * answer 404, and `admin.createUser` / `admin.setUserPassword` are not password-hashed by this
77
+ * module. Switch it on only for a backend that serves them; `useLtAuth()` warns once when it is on
78
+ * and `/iam/features` reports no admin plugin. It does not affect `isAdmin`.
79
+ */
73
80
  enableAdmin?: boolean;
74
81
  /** Enable passkey plugin (default: true) */
75
82
  enablePasskey?: boolean;
@@ -96,10 +103,12 @@ export interface LtTusModuleOptions {
96
103
  /** Default chunk size in bytes (default: 5MB) */
97
104
  defaultChunkSize?: number;
98
105
  /**
99
- * Default TUS upload endpoint (default: '/files/upload').
106
+ * Default TUS upload endpoint (default: '/tus', nest-server's TUS path unless its `tus.path` is
107
+ * changed; before DEV-4072 the default was '/files/upload').
100
108
  *
101
- * nest-server serves TUS at `/tus` unless its `tus.path` is changed. A relative value is a path
102
- * on the API while `resolveAgainstApi` is on; an absolute URL is used as it is.
109
+ * A relative value is a path on the API while `resolveAgainstApi` is on; an absolute URL is used
110
+ * as it is. An endpoint ending in `/upload` also sets the base of the `useLtFile()` routes
111
+ * (`'/api/files/upload'` → `'/api/files'`); any other endpoint leaves them at `/files`.
103
112
  */
104
113
  defaultEndpoint?: string;
105
114
  /**
@@ -109,6 +118,9 @@ export interface LtTusModuleOptions {
109
118
  * `/api` dev-proxy prefix while `NUXT_PUBLIC_API_PROXY` is on. Without it, a relative endpoint
110
119
  * goes to the app origin, where nothing serves TUS unless the project put its own proxy in
111
120
  * front. Set it to `false` for exactly that setup. Absolute endpoints are never rewritten.
121
+ *
122
+ * Also governs the file routes of `useLtFile()` (links, downloads, file info), which are API
123
+ * routes as well.
112
124
  */
113
125
  resolveAgainstApi?: boolean;
114
126
  }
@@ -129,11 +129,11 @@ export interface UseLtFileReturn {
129
129
  formatDuration: (seconds: number) => string;
130
130
  /** Format bytes to human readable string (e.g., "1.5 MB") */
131
131
  formatFileSize: (bytes: number) => string;
132
- /** Get download URL for a file by ID */
132
+ /** Download URL of a file by ID (nest-server `GET /files/id/:id`; `filename` is ignored, the server names the download after the stored file) */
133
133
  getDownloadUrl: (id: string, filename?: string) => string;
134
134
  /** Get file info from the server by ID */
135
135
  getFileInfo: (id: string | undefined) => Promise<LtFileInfo | null | string>;
136
- /** Get direct file URL by ID */
136
+ /** URL of a file by ID (nest-server `GET /files/id/:id`) */
137
137
  getFileUrl: (id: string) => string;
138
138
  /** Check if a string is a valid MongoDB ObjectId */
139
139
  isValidMongoID: (id: string) => boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lenne.tech/nuxt-extensions",
3
- "version": "1.28.0",
3
+ "version": "4.0.0",
4
4
  "description": "Reusable Nuxt 4 composables, components, and Better-Auth integration for lenne.tech projects",
5
5
  "repository": {
6
6
  "type": "git",