@lenne.tech/nuxt-extensions 4.0.6 → 4.0.7

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
@@ -325,6 +325,12 @@ unchanged. That token is the session token, the value the API keeps in the httpO
325
325
  interceptor never fired either). **Never drop the confirming probe**: Better Auth's session atom
326
326
  can hold a stale empty answer after a sign-in that does not refetch it, and a page load must not
327
327
  undo a sign-in. `clearUser()`, not `signOut()`: an expired session deletes no offline-sync data.
328
+ **The sign-out keeps the redirect** (since 4.0.7): it sets `setLtSignedOutAtValidation(true)`
329
+ (`lib/auth-state.ts`, internal), and the interceptor handles a 401 without a signed-in user when
330
+ that note is set, so the next 401 confirms the dead session and goes to the login page as it did
331
+ for the cached user. In 4.0.6 the guard `if (!isAuthenticated) return` swallowed it, and the
332
+ visitor stayed on the protected page, shown as signed out, with every request failing (ng-base
333
+ found the same gap in 22.1.4). `setUser()` and `clearUser()` reset the note.
328
334
  - **`useLtAuthClient().twoFactor.verify*` / `enable` / `disable`, `changePassword` and
329
335
  `signIn.social` strip a non-JWT `token` from the answer**, and `authenticateWithPasskey()`
330
336
  returns no `session`. Keep all of them: application code that never receives the session token
package/README.md CHANGED
@@ -564,6 +564,9 @@ or `exposeTokenInBody`): the JWT of the session that is valid after the answer.
564
564
  answered 401. JWT mode with a stored JWT keeps the user, and so does an answer that is not a
565
565
  verdict (a timeout, a network error, a 5xx). Unsent offline-sync changes stay, as after any
566
566
  expired session.
567
+ The visitor can still be on a protected page then: the next request that answers 401 takes them
568
+ to the login page, as it did for the cached user (since 4.0.7; in 4.0.6 that 401 was ignored,
569
+ because nobody was signed in any more).
567
570
  - **`useLtAuthClient().twoFactor.verifyTotp()`, `verifyBackupCode()`, `enable()`, `disable()`
568
571
  and `changePassword()` return no session token.** A JWT in the answer stays, and the client
569
572
  stores it in `lt-jwt-token` (since 4.0.5); the auth mode is left as it is. From nest-server
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 = "4.0.6";
6
+ declare const version = "4.0.7";
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": "4.0.6",
4
+ "version": "4.0.7",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.4",
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 = "4.0.6";
6
+ const version = "4.0.7";
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";
@@ -11,6 +11,7 @@ import {
11
11
  noteLtJwtServedByPayload,
12
12
  requestLtJwt,
13
13
  resolveLtAuthState,
14
+ setLtSignedOutAtValidation,
14
15
  toLtStoredAuthState,
15
16
  warnLtAdminPluginUnserved
16
17
  } from "../../lib/auth-state.js";
@@ -108,6 +109,7 @@ export function useLtAuth() {
108
109
  authState.value = newState;
109
110
  }
110
111
  if (import.meta.client) {
112
+ setLtSignedOutAtValidation(false);
111
113
  const maxAge = 60 * 60 * 24 * 7;
112
114
  const secure = globalThis.location?.protocol === "https:" ? "; secure" : "";
113
115
  const encoded = encodeURIComponent(JSON.stringify(newState));
@@ -123,6 +125,7 @@ export function useLtAuth() {
123
125
  if (import.meta.client) {
124
126
  authState.value = { user: null, authMode: "cookie" };
125
127
  jwtToken.value = null;
128
+ setLtSignedOutAtValidation(false);
126
129
  clearLtAuthCookies();
127
130
  }
128
131
  }
@@ -237,6 +240,7 @@ export function useLtAuth() {
237
240
  const answeredWithoutSession = !session.value.isPending && !session.value.error;
238
241
  if (answeredWithoutSession && !(isJwtMode.value && jwtToken.value) && await probeSession() === false) {
239
242
  clearUser();
243
+ setLtSignedOutAtValidation(true);
240
244
  return false;
241
245
  }
242
246
  switchToJwtMode().catch(() => {
@@ -427,6 +427,10 @@ export interface LtAuthFetchOptions {
427
427
  cookiesInJwtMode?: 'always' | 'auth-paths';
428
428
  state: LtAuthFetchState;
429
429
  }
430
+ /** @internal See {@link ltSignedOutAtValidation}. */
431
+ export declare function setLtSignedOutAtValidation(value: boolean): void;
432
+ /** @internal See {@link ltSignedOutAtValidation}. */
433
+ export declare function isLtSignedOutAtValidation(): boolean;
430
434
  /**
431
435
  * The authenticated fetch, one implementation for every caller.
432
436
  *
@@ -330,6 +330,13 @@ const ltCookieAuthFetchState = {
330
330
  jwtToken: getLtJwtToken,
331
331
  mode: getLtAuthMode
332
332
  };
333
+ let ltSignedOutAtValidation = false;
334
+ export function setLtSignedOutAtValidation(value) {
335
+ ltSignedOutAtValidation = value;
336
+ }
337
+ export function isLtSignedOutAtValidation() {
338
+ return ltSignedOutAtValidation;
339
+ }
333
340
  let ltJwtAfter401 = null;
334
341
  function requestLtJwtAfter401(basePath) {
335
342
  if (!import.meta.client) {
@@ -1,6 +1,6 @@
1
1
  import { defineNuxtPlugin } from "#imports";
2
2
  import { useLtAuth } from "../composables/auth/use-lt-auth.js";
3
- import { getLtApiBase } from "../lib/auth-state.js";
3
+ import { getLtApiBase, isLtSignedOutAtValidation } from "../lib/auth-state.js";
4
4
  export default defineNuxtPlugin((nuxtApp) => {
5
5
  if (import.meta.server) return;
6
6
  let _authInstance = null;
@@ -97,7 +97,7 @@ export default defineNuxtPlugin((nuxtApp) => {
97
97
  return;
98
98
  }
99
99
  const { clearUser, isAuthenticated } = getAuth();
100
- if (!isAuthenticated.value) {
100
+ if (!isAuthenticated.value && !isLtSignedOutAtValidation()) {
101
101
  return;
102
102
  }
103
103
  isHandling401 = true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lenne.tech/nuxt-extensions",
3
- "version": "4.0.6",
3
+ "version": "4.0.7",
4
4
  "description": "Reusable Nuxt 4 composables, components, and Better-Auth integration for lenne.tech projects",
5
5
  "repository": {
6
6
  "type": "git",