@acorex/connectivity 20.6.0-next.20 → 20.6.0-next.22

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/api/index.d.ts CHANGED
@@ -144,6 +144,12 @@ declare class AXCAPIOidcStrategy extends AXPAuthStrategy {
144
144
  updateToken(params: {
145
145
  [key: string]: any;
146
146
  }): Promise<AXPSignInResult | void>;
147
+ /**
148
+ * Signs out the user according to OpenID Connect standards.
149
+ * Tries to call the standard OIDC end_session_endpoint if available, else falls back to configured logoutUrl.
150
+ * Falls back to root landing page on local logout if nothing is provided.
151
+ * This runs in the background (without redirecting user immediately to the endpoint).
152
+ */
147
153
  signout(): Promise<void>;
148
154
  refreshToken(context: AXPSessionContext): Promise<AXPSignInResult>;
149
155
  private loadAuthData;
@@ -639,13 +639,40 @@ class AXCAPIOidcStrategy extends AXPAuthStrategy {
639
639
  this.handleError(error);
640
640
  }
641
641
  }
642
+ /**
643
+ * Signs out the user according to OpenID Connect standards.
644
+ * Tries to call the standard OIDC end_session_endpoint if available, else falls back to configured logoutUrl.
645
+ * Falls back to root landing page on local logout if nothing is provided.
646
+ * This runs in the background (without redirecting user immediately to the endpoint).
647
+ */
642
648
  async signout() {
643
649
  localStorage.removeItem('pkce_code_verifier');
644
650
  localStorage.removeItem('oauth_provider');
645
- console.log(this.openidConfigurationInfo?.info?.discoveryDocument);
646
- // Use configured logoutUrl or derive from baseUrl
647
- const logoutUrl = this.aXMAuthConfigs.logoutUrl || `connect/logout`;
648
- window.location.href = logoutUrl;
651
+ // Standard OIDC logout: try to use end_session_endpoint if found in the discovery document
652
+ const discoveryDoc = this.openidConfigurationInfo?.info?.discoveryDocument;
653
+ let logoutUrl;
654
+ if (discoveryDoc?.end_session_endpoint) {
655
+ logoutUrl = discoveryDoc.end_session_endpoint;
656
+ // Optional: append id_token_hint, post_logout_redirect_uri or others as needed by your IdP
657
+ // For example: logoutUrl += `?post_logout_redirect_uri=${encodeURIComponent(window.location.origin)}`;
658
+ }
659
+ else if (this.aXMAuthConfigs.logoutUrl) {
660
+ logoutUrl = this.aXMAuthConfigs.logoutUrl;
661
+ }
662
+ // Call logout in the background (don't redirect)
663
+ if (logoutUrl) {
664
+ // Fire-and-forget: Create an invisible iframe to make the logout request in the background
665
+ const iframe = document.createElement('iframe');
666
+ iframe.style.display = 'none';
667
+ iframe.src = logoutUrl;
668
+ document.body.appendChild(iframe);
669
+ // Optionally, remove iframe after load
670
+ iframe.onload = () => {
671
+ setTimeout(() => document.body.removeChild(iframe), 1000);
672
+ };
673
+ }
674
+ // Always send user to landing page after local logout, regardless
675
+ window.location.href = '/';
649
676
  }
650
677
  async refreshToken(context) {
651
678
  try {