@spacelr/sdk 0.8.0 → 0.8.1

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/index.d.mts CHANGED
@@ -406,6 +406,14 @@ interface HttpRequestOptions {
406
406
  path: string;
407
407
  body?: unknown;
408
408
  authenticated?: boolean;
409
+ /**
410
+ * Suppress the 401 auto-recovery (forceRefresh + emitAuthLost) for this
411
+ * request. Used by logout: a 401 there means the session is already gone,
412
+ * so triggering a refresh/auth-lost would recurse (auth-lost handlers that
413
+ * call logout re-fire the same 401). The token is still sent so the server
414
+ * can revoke it when it is valid.
415
+ */
416
+ skipAuthRefresh?: boolean;
409
417
  headers?: Record<string, string>;
410
418
  query?: Record<string, string | number | undefined>;
411
419
  /** Send cookies cross-origin (credentials: 'include'). Defaults to true for /auth/ paths. */
package/dist/index.d.ts CHANGED
@@ -406,6 +406,14 @@ interface HttpRequestOptions {
406
406
  path: string;
407
407
  body?: unknown;
408
408
  authenticated?: boolean;
409
+ /**
410
+ * Suppress the 401 auto-recovery (forceRefresh + emitAuthLost) for this
411
+ * request. Used by logout: a 401 there means the session is already gone,
412
+ * so triggering a refresh/auth-lost would recurse (auth-lost handlers that
413
+ * call logout re-fire the same 401). The token is still sent so the server
414
+ * can revoke it when it is valid.
415
+ */
416
+ skipAuthRefresh?: boolean;
409
417
  headers?: Record<string, string>;
410
418
  query?: Record<string, string | number | undefined>;
411
419
  /** Send cookies cross-origin (credentials: 'include'). Defaults to true for /auth/ paths. */
package/dist/index.js CHANGED
@@ -158,7 +158,7 @@ var HttpClient = class {
158
158
  });
159
159
  const responseBody = await this.parseResponse(response);
160
160
  if (!response.ok) {
161
- if (options.authenticated && response.status === 401) {
161
+ if (options.authenticated && response.status === 401 && !options.skipAuthRefresh) {
162
162
  if (await this.recoverFromAuthFailure(isRetry)) {
163
163
  return this.requestWithRetry(options, true);
164
164
  }
@@ -1438,7 +1438,11 @@ var AuthModule = class {
1438
1438
  await this.http.request({
1439
1439
  method: "POST",
1440
1440
  path: "/auth/logout",
1441
- authenticated: true
1441
+ authenticated: true,
1442
+ // A 401 here means the session is already gone — do not trigger the
1443
+ // refresh/auth-lost recovery, or an auth-lost handler that calls
1444
+ // logout would recurse into an endless 401 loop.
1445
+ skipAuthRefresh: true
1442
1446
  });
1443
1447
  } catch {
1444
1448
  }