@svadmin/sso 0.11.1 → 0.11.2

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.
@@ -17,6 +17,8 @@ export interface SSOConfig {
17
17
  scopes?: string[];
18
18
  /** Where to redirect after logout */
19
19
  postLogoutRedirectUri?: string;
20
+ /** Optional public RP-initiated logout endpoint override. */
21
+ endSessionEndpoint?: string;
20
22
  /** Token storage backend. Default: 'local' (localStorage) */
21
23
  storage?: 'local' | 'session' | TokenStorage;
22
24
  /** Storage namespace. Defaults to an issuer/client-specific key. */
@@ -210,7 +210,10 @@ export function createSSOAuthProvider(config) {
210
210
  if (oidcConfig)
211
211
  return oidcConfig;
212
212
  if (config.manualEndpoints) {
213
- oidcConfig = config.manualEndpoints;
213
+ oidcConfig = {
214
+ ...config.manualEndpoints,
215
+ ...(config.endSessionEndpoint ? { end_session_endpoint: config.endSessionEndpoint } : {}),
216
+ };
214
217
  return oidcConfig;
215
218
  }
216
219
  const url = `${config.issuer.replace(/\/$/, '')}/.well-known/openid-configuration`;
@@ -234,7 +237,10 @@ export function createSSOAuthProvider(config) {
234
237
  cause: error,
235
238
  });
236
239
  }
237
- oidcConfig = readOIDCConfig(discovered);
240
+ const discoveredConfig = readOIDCConfig(discovered);
241
+ oidcConfig = config.endSessionEndpoint
242
+ ? { ...discoveredConfig, end_session_endpoint: config.endSessionEndpoint }
243
+ : discoveredConfig;
238
244
  return oidcConfig;
239
245
  }
240
246
  async function requestToken(endpoint, body, fallbackMessage) {
@@ -408,14 +414,16 @@ export function createSSOAuthProvider(config) {
408
414
  }
409
415
  try {
410
416
  const endpoints = await discover();
411
- if (typeof window !== 'undefined' && endpoints.end_session_endpoint && session?.id_token) {
412
- const params = new URLSearchParams({
413
- id_token_hint: session.id_token,
414
- ...(config.postLogoutRedirectUri
415
- ? { post_logout_redirect_uri: config.postLogoutRedirectUri }
416
- : {}),
417
- });
418
- window.location.href = `${endpoints.end_session_endpoint}?${params}`;
417
+ if (typeof window !== 'undefined' && endpoints.end_session_endpoint) {
418
+ const logoutUrl = new URL(endpoints.end_session_endpoint, window.location.href);
419
+ logoutUrl.searchParams.set('client_id', config.clientId);
420
+ logoutUrl.searchParams.delete('id_token_hint');
421
+ if (session?.id_token)
422
+ logoutUrl.searchParams.set('id_token_hint', session.id_token);
423
+ if (config.postLogoutRedirectUri) {
424
+ logoutUrl.searchParams.set('post_logout_redirect_uri', config.postLogoutRedirectUri);
425
+ }
426
+ window.location.href = logoutUrl.href;
419
427
  return { success: true };
420
428
  }
421
429
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@svadmin/sso",
3
- "version": "0.11.1",
3
+ "version": "0.11.2",
4
4
  "type": "module",
5
5
  "description": "OIDC/OAuth2 SSO AuthProvider plugin for svadmin — supports Okta, Azure AD, Cognito, Keycloak, Google",
6
6
  "license": "MIT",
@@ -32,10 +32,10 @@
32
32
  "dist"
33
33
  ],
34
34
  "peerDependencies": {
35
- "@svadmin/core": "^0.32.1"
35
+ "@svadmin/core": "^0.32.2"
36
36
  },
37
37
  "devDependencies": {
38
- "typescript": "^5.7.0"
38
+ "typescript": "^6.0.3"
39
39
  },
40
40
  "scripts": {
41
41
  "build": "bun ../../scripts/build-node-package.ts"