@thunderid/browser 0.8.1 → 0.9.0

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.js CHANGED
@@ -2823,10 +2823,30 @@ var ThunderIDBrowserClient = class ThunderIDBrowserClient extends ThunderIDJavaS
2823
2823
  }
2824
2824
  async signOut(_options, sessionIdOrAfterSignOut, afterSignOutParam) {
2825
2825
  let afterSignOut;
2826
+ let sessionId;
2826
2827
  if (typeof sessionIdOrAfterSignOut === "function") afterSignOut = sessionIdOrAfterSignOut;
2827
- else if (typeof sessionIdOrAfterSignOut === "string") afterSignOut = afterSignOutParam;
2828
+ else if (typeof sessionIdOrAfterSignOut === "string") {
2829
+ sessionId = sessionIdOrAfterSignOut;
2830
+ afterSignOut = afterSignOutParam;
2831
+ }
2828
2832
  const config = await this.getStorageManager().getConfigData();
2829
- this.clearSession();
2833
+ if (config?.rpInitiatedLogout !== false) {
2834
+ let signOutUrl = sessionId ? "" : SPAUtils_default.getSignOutUrl(config.clientId, this._browserInstanceId);
2835
+ if (!signOutUrl) try {
2836
+ signOutUrl = await this.getSignOutUrl(sessionId);
2837
+ } catch (error) {
2838
+ logger$2.debug("Could not build the RP-initiated logout URL; falling back to a local sign out.", error);
2839
+ signOutUrl = "";
2840
+ }
2841
+ if (signOutUrl) {
2842
+ await this.clearSessionAsync(sessionId);
2843
+ afterSignOut?.(signOutUrl);
2844
+ location.href = signOutUrl;
2845
+ await SPAUtils_default.waitTillPageRedirect();
2846
+ return signOutUrl;
2847
+ }
2848
+ }
2849
+ this.clearSession(sessionId);
2830
2850
  if (config?.signInUrl) navigate_default(config.signInUrl);
2831
2851
  else this.signIn(config?.signInOptions);
2832
2852
  afterSignOut?.(config?.afterSignOutUrl || "");