@lenne.tech/nuxt-extensions 1.18.3 → 1.18.5

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
@@ -347,7 +347,7 @@ fields at `app:beforeMount` and restores them at `app:mounted`, dispatching a sy
347
347
  Handling" below).
348
348
  3. **Check existing composables** before creating new ones — this module may already provide what you need
349
349
  4. **Peer dependencies** (`better-auth`, `@better-auth/passkey`, `tus-js-client`) must be installed in the consuming project.
350
- `better-auth` and `@better-auth/passkey` are pinned to **`>=1.7.1 <1.8.0`** — deliberately not a caret.
350
+ `better-auth` and `@better-auth/passkey` are pinned to **`>=1.7.7 <1.8.0`** — deliberately not a caret.
351
351
  **They move in lock-step with `@lenne.tech/nest-server`.** better-auth is one protocol with two ends;
352
352
  this module is the client end, nest-server the server end, and both declare the *same* narrow range.
353
353
  Raising it means raising it in **both** framework repos and pinning the new version in **both** starters,
package/README.md CHANGED
@@ -29,8 +29,8 @@ Reusable Nuxt 4 composables, components, and Better-Auth integration for lenne.t
29
29
  |---|---|---|
30
30
  | Node | `>= 22` | |
31
31
  | Nuxt | `^4.0.0` | |
32
- | `better-auth` | `>=1.7.1 <1.8.0` | **required peer** — pin it, see below |
33
- | `@better-auth/passkey` | `>=1.7.1 <1.8.0` | optional peer, passkey/WebAuthn only |
32
+ | `better-auth` | `>=1.7.7 <1.8.0` | **required peer** — pin it, see below |
33
+ | `@better-auth/passkey` | `>=1.7.7 <1.8.0` | optional peer, passkey/WebAuthn only |
34
34
  | `tus-js-client` | `>=4.0.0` | optional peer, resumable uploads only |
35
35
  | `@lenne.tech/nest-server` | `>= 11.37.0` | **only if you use the backend** — see the lock-step rule |
36
36
 
@@ -38,7 +38,7 @@ Reusable Nuxt 4 composables, components, and Better-Auth integration for lenne.t
38
38
  better-auth is one protocol with two ends. This module is the client end and
39
39
  `@lenne.tech/nest-server` is the server end, and they must resolve the **same**
40
40
  better-auth minor. better-auth breaks in *minor* releases — 1.7 removed subpath
41
- exports and changed the 2FA response shape — so a caret (`^1.7.1`) would re-open the
41
+ exports and changed the 2FA response shape — so a caret (`^1.7.7`) would re-open the
42
42
  hole at 1.8. If the api and the app drift apart, 2FA activation fails at runtime with a
43
43
  generic client error while **both** projects' checks stay green: each is internally
44
44
  consistent, and only the assembled workspace has both halves.
@@ -46,12 +46,17 @@ consistent, and only the assembled workspace has both halves.
46
46
  Raising better-auth therefore means raising it in `@lenne.tech/nest-server` **and**
47
47
  `@lenne.tech/nuxt-extensions` in one step.
48
48
 
49
+ **Why the floor is 1.7.7:** better-auth below 1.7.7 is affected by
50
+ [GHSA-965c-763c-88jm](https://github.com/better-auth/better-auth/security/advisories/GHSA-965c-763c-88jm)
51
+ (critical): the OAuth state can be used as a magic link to sign in as another user. The flaw
52
+ is in the server end, so your API must run 1.7.7 too, and the pin below keeps both halves on it.
53
+
49
54
  ## Installation
50
55
 
51
56
  ```bash
52
- npm install @lenne.tech/nuxt-extensions better-auth@1.7.1
57
+ npm install @lenne.tech/nuxt-extensions better-auth@1.7.7
53
58
  # Optional: For passkey support
54
- npm install @better-auth/passkey@1.7.1
59
+ npm install @better-auth/passkey@1.7.7
55
60
  # Optional: For TUS file uploads
56
61
  npm install tus-js-client
57
62
  ```
@@ -61,8 +66,8 @@ In a fullstack monorepo, pin it workspace-wide so the api and the app cannot dri
61
66
  ```yaml
62
67
  # pnpm-workspace.yaml
63
68
  overrides:
64
- better-auth: 1.7.1
65
- '@better-auth/passkey': 1.7.1
69
+ better-auth: 1.7.7
70
+ '@better-auth/passkey': 1.7.7
66
71
  ```
67
72
 
68
73
  ## Features
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.18.3";
6
+ declare const version = "1.18.5";
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.18.3",
4
+ "version": "1.18.5",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.3",
7
7
  "unbuild": "3.6.1"
package/dist/module.mjs CHANGED
@@ -2,7 +2,7 @@ import { defineNuxtModule, createResolver, tryResolveModule, addImports, addComp
2
2
  import { pathToFileURL } from 'node:url';
3
3
 
4
4
  const name = "@lenne.tech/nuxt-extensions";
5
- const version = "1.18.3";
5
+ const version = "1.18.5";
6
6
  const configKey = "ltExtensions";
7
7
  const DEFAULT_LT_AUTH_STATE_COOKIE = "lt-auth-state";
8
8
  const DEFAULT_LT_JWT_TOKEN_COOKIE = "lt-jwt-token";
@@ -82,6 +82,13 @@ const module$1 = defineNuxtModule({
82
82
  nuxt.options.nitro ??= {};
83
83
  nuxt.options.nitro.alias = { ...nuxt.options.nitro.alias, "@better-auth/passkey/client": passkeyStub };
84
84
  }
85
+ const uiToastAvailable = !!await tryResolveModule("@nuxt/ui/composables/useToast", [new URL(import.meta.url), pathToFileURL(`${nuxt.options.rootDir}/`)]);
86
+ if (!uiToastAvailable) {
87
+ const uiToastStub = resolve("./runtime/lib/ui-toast-stub");
88
+ nuxt.options.alias["@nuxt/ui/composables/useToast"] = uiToastStub;
89
+ nuxt.options.nitro ??= {};
90
+ nuxt.options.nitro.alias = { ...nuxt.options.nitro.alias, "@nuxt/ui/composables/useToast": uiToastStub };
91
+ }
85
92
  const enablePasskey = (resolvedOptions.auth?.enablePasskey ?? true) && passkeyAvailable;
86
93
  if ((resolvedOptions.auth?.enablePasskey ?? true) && !passkeyAvailable) {
87
94
  console.warn(
@@ -26,8 +26,8 @@ type __VLS_Slots = {} & {
26
26
  default?: (props: typeof __VLS_7) => any;
27
27
  };
28
28
  declare const __VLS_base: import("@vue/runtime-core").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("@vue/runtime-core").ComponentOptionsMixin, import("@vue/runtime-core").ComponentOptionsMixin, {}, string, import("@vue/runtime-core").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
29
- leaveDuration: `${number}` | number;
30
- startDuration: `${number}` | number;
29
+ leaveDuration: number | `${number}`;
30
+ startDuration: number | `${number}`;
31
31
  }, {}, {}, {}, string, import("@vue/runtime-core").ComponentProvideOptions, false, {}, any>;
32
32
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
33
33
  declare const _default: typeof __VLS_export;
@@ -26,8 +26,8 @@ type __VLS_Slots = {} & {
26
26
  default?: (props: typeof __VLS_7) => any;
27
27
  };
28
28
  declare const __VLS_base: import("@vue/runtime-core").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("@vue/runtime-core").ComponentOptionsMixin, import("@vue/runtime-core").ComponentOptionsMixin, {}, string, import("@vue/runtime-core").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
29
- leaveDuration: `${number}` | number;
30
- startDuration: `${number}` | number;
29
+ leaveDuration: number | `${number}`;
30
+ startDuration: number | `${number}`;
31
31
  }, {}, {}, {}, string, import("@vue/runtime-core").ComponentProvideOptions, false, {}, any>;
32
32
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
33
33
  declare const _default: typeof __VLS_export;
@@ -29,8 +29,8 @@ type __VLS_Slots = {} & {
29
29
  default?: (props: typeof __VLS_7) => any;
30
30
  };
31
31
  declare const __VLS_base: import("@vue/runtime-core").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("@vue/runtime-core").ComponentOptionsMixin, import("@vue/runtime-core").ComponentOptionsMixin, {}, string, import("@vue/runtime-core").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
32
- leaveDuration: `${number}` | number;
33
- startDuration: `${number}` | number;
32
+ leaveDuration: number | `${number}`;
33
+ startDuration: number | `${number}`;
34
34
  }, {}, {}, {}, string, import("@vue/runtime-core").ComponentProvideOptions, false, {}, any>;
35
35
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
36
36
  declare const _default: typeof __VLS_export;
@@ -29,8 +29,8 @@ type __VLS_Slots = {} & {
29
29
  default?: (props: typeof __VLS_7) => any;
30
30
  };
31
31
  declare const __VLS_base: import("@vue/runtime-core").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("@vue/runtime-core").ComponentOptionsMixin, import("@vue/runtime-core").ComponentOptionsMixin, {}, string, import("@vue/runtime-core").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
32
- leaveDuration: `${number}` | number;
33
- startDuration: `${number}` | number;
32
+ leaveDuration: number | `${number}`;
33
+ startDuration: number | `${number}`;
34
34
  }, {}, {}, {}, string, import("@vue/runtime-core").ComponentProvideOptions, false, {}, any>;
35
35
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
36
36
  declare const _default: typeof __VLS_export;
@@ -1,5 +1,6 @@
1
1
  import { computed, ref, useState, useNuxtApp, useRuntimeConfig } from "#imports";
2
2
  import { buildLtApiUrl } from "../lib/auth-state.js";
3
+ import { ltAddToast } from "../lib/toast.js";
3
4
  const ERROR_CODE_REGEX = /^#([A-Z_]+_\d+):\s*(.+)$/;
4
5
  export function useLtErrorTranslation() {
5
6
  const nuxtApp = useNuxtApp();
@@ -101,21 +102,14 @@ export function useLtErrorTranslation() {
101
102
  return;
102
103
  }
103
104
  const parsed = parseError(errorOrMessage);
104
- try {
105
- nuxtApp.runWithContext(() => {
106
- const toastComposable = nuxtApp.useToast || globalThis.useToast;
107
- if (typeof toastComposable === "function") {
108
- const toast = toastComposable();
109
- toast.add({
110
- color: "error",
111
- title: title || t("lt.error.title", "Fehler"),
112
- description: parsed.translatedMessage
113
- });
114
- } else {
115
- console.error("[LtErrorTranslation]", parsed.translatedMessage);
116
- }
117
- });
118
- } catch {
105
+ const shown = nuxtApp.runWithContext(
106
+ () => ltAddToast({
107
+ color: "error",
108
+ description: parsed.translatedMessage,
109
+ title: title || t("lt.error.title", "Fehler")
110
+ })
111
+ );
112
+ if (!shown) {
119
113
  console.error("[LtErrorTranslation]", parsed.translatedMessage);
120
114
  }
121
115
  }
@@ -1,4 +1,5 @@
1
1
  import { useNuxtApp, useRoute } from "#imports";
2
+ import { ltAddToast } from "../lib/toast.js";
2
3
  export function useLtShare() {
3
4
  const route = useRoute();
4
5
  const nuxtApp = useNuxtApp();
@@ -26,19 +27,14 @@ export function useLtShare() {
26
27
  } else {
27
28
  try {
28
29
  await navigator.clipboard.writeText(url ?? window.location.origin);
29
- const useToast = nuxtApp.$useToast || globalThis.useToast;
30
- if (typeof useToast === "function") {
31
- try {
32
- const toast = useToast();
33
- toast.add({
34
- color: "success",
35
- description: t("lt.share.copiedDescription", "Der Link wurde in die Zwischenablage kopiert."),
36
- title: t("lt.share.copied", "Link kopiert")
37
- });
38
- } catch {
39
- console.debug("Link copied to clipboard");
40
- }
41
- } else {
30
+ const shown = nuxtApp.runWithContext(
31
+ () => ltAddToast({
32
+ color: "success",
33
+ description: t("lt.share.copiedDescription", "Der Link wurde in die Zwischenablage kopiert."),
34
+ title: t("lt.share.copied", "Link kopiert")
35
+ })
36
+ );
37
+ if (!shown) {
42
38
  console.debug("Link copied to clipboard");
43
39
  }
44
40
  } catch (error) {
@@ -169,7 +169,14 @@ export declare function createLtAuthClient(config?: LtAuthClientConfig): {
169
169
  query?: import("better-auth").SessionQueryParams;
170
170
  } | undefined) => Promise<void>;
171
171
  }>>;
172
- <F extends (...args: any) => any>(useFetch: F): Promise<{
172
+ (useFetch: (url: string, options: {
173
+ headers?: HeadersInit;
174
+ key: string;
175
+ watch: import("vue").WatchSource<unknown>[];
176
+ }) => Promise<{
177
+ data: import("vue").Ref<unknown>;
178
+ error: import("vue").Ref<unknown>;
179
+ }>): Promise<{
173
180
  data: import("vue").Ref<{
174
181
  user: import("better-auth").StripEmptyObjects<{
175
182
  id: string;
@@ -281,17 +288,17 @@ export declare function createLtAuthClient(config?: LtAuthClientConfig): {
281
288
  onResponse: ((context: import("better-auth/client").ResponseContext) => Promise<Response | void | import("better-auth/client").ResponseContext> | Response | import("better-auth/client").ResponseContext | void) | undefined;
282
289
  };
283
290
  })[];
284
- priority?: RequestPriority | undefined;
285
291
  cache?: RequestCache | undefined;
286
292
  credentials?: RequestCredentials;
287
293
  integrity?: string | undefined;
288
294
  keepalive?: boolean | undefined;
289
295
  method: string;
290
296
  mode?: RequestMode | undefined;
297
+ priority?: RequestPriority | undefined;
291
298
  redirect?: RequestRedirect | undefined;
292
299
  referrer?: string | undefined;
293
300
  referrerPolicy?: ReferrerPolicy | undefined;
294
- signal?: (AbortSignal | null) | undefined;
301
+ signal?: AbortSignal | null;
295
302
  window?: null | undefined;
296
303
  onRetry?: ((response: import("better-auth/client").ResponseContext) => Promise<void> | void) | undefined;
297
304
  hookOptions?: {
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Toast helper
3
+ *
4
+ * Single place where the module talks to Nuxt UI's toaster.
5
+ *
6
+ * Composables used to look the composable up on `nuxtApp` / `globalThis`
7
+ * (`(nuxtApp as any).useToast || (globalThis as any).useToast`). Nuxt UI exposes
8
+ * `useToast` as an auto-import and puts it on neither, so that lookup was always
9
+ * `undefined` and every toast silently degraded to a `console.*` line — users
10
+ * got no visible feedback at all.
11
+ *
12
+ * Importing Nuxt UI's `useToast` directly is what actually works. The specifier
13
+ * resolves to the very same file the auto-import points at, so the toast lands
14
+ * in the `useState('toasts')` array that `<UApp>` / `<UToaster>` renders.
15
+ * `module.ts` aliases it onto {@link ui-toast-stub} when `@nuxt/ui` is not
16
+ * installed, which keeps it an optional peer.
17
+ */
18
+ /** Semantic toast colors — mirrors Nuxt UI's color tokens. */
19
+ export type LtToastColor = 'error' | 'info' | 'neutral' | 'primary' | 'secondary' | 'success' | 'warning';
20
+ export interface LtToastOptions {
21
+ color?: LtToastColor;
22
+ description?: string;
23
+ title?: string;
24
+ }
25
+ /**
26
+ * Show a toast, if the app has a toaster.
27
+ *
28
+ * Call it inside `nuxtApp.runWithContext()` when you are past an `await` or
29
+ * outside a component: `useToast()` needs the Nuxt instance for `useState`.
30
+ *
31
+ * @param options - Toast color, title and description
32
+ * @returns `true` when the toast was handed to Nuxt UI, `false` when no toaster
33
+ * is available (or it threw) — callers use this to fall back to the console
34
+ * instead of swallowing the message.
35
+ *
36
+ * @example
37
+ * ```typescript
38
+ * if (!ltAddToast({ color: 'error', description: message, title: 'Fehler' })) {
39
+ * console.error('[MyComposable]', message);
40
+ * }
41
+ * ```
42
+ */
43
+ export declare function ltAddToast(options: LtToastOptions): boolean;
@@ -0,0 +1,13 @@
1
+ import { useToast } from "@nuxt/ui/composables/useToast";
2
+ export function ltAddToast(options) {
3
+ try {
4
+ const toast = useToast();
5
+ if (typeof toast?.add !== "function") {
6
+ return false;
7
+ }
8
+ toast.add(options);
9
+ return true;
10
+ } catch {
11
+ return false;
12
+ }
13
+ }
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Build-time stand-in for Nuxt UI's `@nuxt/ui/composables/useToast`.
3
+ *
4
+ * `@nuxt/ui` is an OPTIONAL peer of this module, but `runtime/lib/toast.ts`
5
+ * imports `useToast` at the top level — so the bundler must resolve the
6
+ * specifier even in a project that ships a different UI layer. `module.ts`
7
+ * aliases `@nuxt/ui/composables/useToast` onto this file when the package is
8
+ * absent; without it the build would fail on an unresolved optional peer
9
+ * instead of honouring the optionality (same pattern as `passkey-stub.ts`).
10
+ *
11
+ * The alias rewrites the specifier for the WHOLE consumer app, so this file
12
+ * mirrors every name the real module exports. `test/lt-toast.test.ts` pins that
13
+ * surface against the real package.
14
+ */
15
+ /** Mirror of Nuxt UI's injection key for the toaster's `max` prop. */
16
+ export declare const toastMaxInjectionKey: unique symbol;
17
+ /**
18
+ * No-op replacement for Nuxt UI's `useToast()`.
19
+ *
20
+ * Returning `undefined` — rather than an object whose `add()` silently swallows
21
+ * the toast — is what lets {@link ltAddToast} report "no toast was shown", so
22
+ * callers keep their console fallback.
23
+ */
24
+ export declare function useToast(): undefined;
@@ -0,0 +1,4 @@
1
+ export const toastMaxInjectionKey = Symbol("nuxt-ui.toast-max");
2
+ export function useToast() {
3
+ return void 0;
4
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lenne.tech/nuxt-extensions",
3
- "version": "1.18.3",
3
+ "version": "1.18.5",
4
4
  "description": "Reusable Nuxt 4 composables, components, and Better-Auth integration for lenne.tech projects",
5
5
  "repository": {
6
6
  "type": "git",
@@ -79,9 +79,9 @@
79
79
  "@nuxt/kit": "^4.0.0"
80
80
  },
81
81
  "peerDependencies": {
82
- "@better-auth/passkey": ">=1.7.1 <1.8.0",
82
+ "@better-auth/passkey": ">=1.7.7 <1.8.0",
83
83
  "@playwright/test": ">=1.0.0",
84
- "better-auth": ">=1.7.1 <1.8.0",
84
+ "better-auth": ">=1.7.7 <1.8.0",
85
85
  "nuxt": "^4.0.0",
86
86
  "tus-js-client": ">=4.0.0"
87
87
  },
@@ -100,25 +100,25 @@
100
100
  }
101
101
  },
102
102
  "devDependencies": {
103
- "@better-auth/passkey": "1.7.1",
103
+ "@better-auth/passkey": "1.7.7",
104
104
  "@nuxt/module-builder": "1.0.3",
105
- "@nuxt/schema": "4.5.2",
106
- "@nuxt/ui": "4.11.2",
105
+ "@nuxt/schema": "4.6.0",
106
+ "@nuxt/ui": "4.11.3",
107
107
  "@playwright/test": "1.63.0",
108
- "@types/node": "26.6.3",
109
- "@vitest/coverage-v8": "4.1.11",
108
+ "@types/node": "26.6.4",
109
+ "@vitest/coverage-v8": "5.0.3",
110
110
  "@vue/server-renderer": "3.5.43",
111
- "better-auth": "1.7.1",
111
+ "better-auth": "1.7.7",
112
112
  "cross-spawn": "7.0.6",
113
113
  "happy-dom": "20.14.5",
114
- "nuxt": "4.5.2",
115
- "oxfmt": "0.70.0",
116
- "oxlint": "1.85.0",
117
- "reka-ui": "2.10.4",
114
+ "nuxt": "4.6.0",
115
+ "oxfmt": "0.72.0",
116
+ "oxlint": "1.87.0",
117
+ "reka-ui": "2.10.5",
118
118
  "tus-js-client": "4.3.1",
119
119
  "typescript": "5.9.3",
120
- "vitest": "4.1.11",
121
- "vue-tsc": "3.3.11"
120
+ "vitest": "5.0.3",
121
+ "vue-tsc": "3.3.12"
122
122
  },
123
123
  "keywords": [
124
124
  "nuxt",