@oauth-spa-kit/core 2.0.3 → 2.0.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.
@@ -25,6 +25,19 @@ export interface SessionClient {
25
25
  refresh(): Promise<void>;
26
26
  /** Full-page navigation to the login handler -- there is no silent/iframe path in BFF mode. */
27
27
  login(returnTo?: string): void;
28
+ /**
29
+ * Full-page navigation to the logout handler, same as `login`. RP-Initiated Logout
30
+ * (OIDC section 5) redirects the browser to the IdP's `end_session_endpoint`, which is
31
+ * a *different origin* from this app -- clearing/invalidating that session requires the
32
+ * IdP's own session cookie to actually be sent there and its response cookie actually
33
+ * stored, and browsers only do that for a real top-level navigation, not a `fetch()`
34
+ * (even with `redirect: "follow"`, `credentials: "same-origin"` scopes cookie handling
35
+ * to same-origin hops only, so the cross-origin hop to the IdP carries no cookie either
36
+ * way). A fetch-based logout silently no-ops the IdP side: the local session clears, but
37
+ * the IdP's SSO cookie survives, so the very next login silently re-authenticates through
38
+ * it. Stays `Promise<void>` for call-site compatibility even though the navigation means
39
+ * it never meaningfully resolves.
40
+ */
28
41
  logout(): Promise<void>;
29
42
  }
30
43
  export declare function createSessionClient(options?: SessionClientOptions): SessionClient;
@@ -49,9 +49,8 @@ export function createSessionClient(options = {}) {
49
49
  window.location.assign(url.toString());
50
50
  },
51
51
  async logout() {
52
- await fetchImpl(`${baseUrl}/auth/logout`, { method: "POST", credentials: "same-origin" });
53
- setState({ ready: true, loggedIn: false, user: null });
54
- channel?.postMessage("session-changed");
52
+ const url = new URL(`${baseUrl}/auth/logout`, window.location.origin);
53
+ window.location.assign(url.toString());
55
54
  },
56
55
  };
57
56
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oauth-spa-kit/core",
3
- "version": "2.0.3",
3
+ "version": "2.0.5",
4
4
  "description": "Framework- and runtime-agnostic OAuth 2.1 / OIDC primitives (PKCE, discovery, token exchange, DPoP) plus a fetch-based session client. Runs in the browser, Node, and edge runtimes -- no DOM or Node-only APIs.",
5
5
  "license": "MIT",
6
6
  "repository": {