@nauth-toolkit/client 0.1.99 → 0.1.101

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.cjs CHANGED
@@ -1667,6 +1667,9 @@ var NAuthClient = class {
1667
1667
  * - In cookie delivery modes, httpOnly cookies can only be cleared by the backend; this method
1668
1668
  * only clears client-side state (e.g., cached user + persisted tokens in JSON mode).
1669
1669
  *
1670
+ * IMPORTANT: Also clears any pending challenge sessions to prevent ghost states where the UI
1671
+ * shows a challenge screen but the backend session is invalid.
1672
+ *
1670
1673
  * @param options - Optional behavior flags
1671
1674
  * @returns Promise that resolves when local state is cleared
1672
1675
  *
@@ -1678,6 +1681,7 @@ var NAuthClient = class {
1678
1681
  */
1679
1682
  async clearLocalAuthState(options) {
1680
1683
  await this.clearAuthState(options?.forgetDevice ?? false);
1684
+ await this.clearChallenge();
1681
1685
  }
1682
1686
  /**
1683
1687
  * Logout current session.
@@ -1694,6 +1698,7 @@ var NAuthClient = class {
1694
1698
  console.warn("[nauth] Logout request failed (session may already be invalid):", error);
1695
1699
  } finally {
1696
1700
  await this.clearAuthState(forgetDevice);
1701
+ await this.clearChallenge();
1697
1702
  this.eventEmitter.emit({
1698
1703
  type: "auth:logout",
1699
1704
  data: { forgetDevice: !!forgetDevice, global: false },
@@ -1721,6 +1726,7 @@ var NAuthClient = class {
1721
1726
  true
1722
1727
  );
1723
1728
  await this.clearAuthState(forgetDevices);
1729
+ await this.clearChallenge();
1724
1730
  this.eventEmitter.emit({
1725
1731
  type: "auth:logout",
1726
1732
  data: { forgetDevice: !!forgetDevices, global: true },
@@ -1729,6 +1735,7 @@ var NAuthClient = class {
1729
1735
  return { revokedCount: result.revokedCount };
1730
1736
  } catch (error) {
1731
1737
  await this.clearAuthState(forgetDevices);
1738
+ await this.clearChallenge();
1732
1739
  this.eventEmitter.emit({
1733
1740
  type: "auth:logout",
1734
1741
  data: { forgetDevice: !!forgetDevices, global: true },
@@ -2048,6 +2055,9 @@ var NAuthClient = class {
2048
2055
  if (typeof options?.appState === "string" && options.appState.trim() !== "") {
2049
2056
  startUrl.searchParams.set("appState", options.appState);
2050
2057
  }
2058
+ if (options?.oauthParams && Object.keys(options.oauthParams).length > 0) {
2059
+ startUrl.searchParams.set("oauthParams", JSON.stringify(options.oauthParams));
2060
+ }
2051
2061
  window.location.href = startUrl.toString();
2052
2062
  }
2053
2063
  }
@@ -2302,6 +2312,10 @@ var NAuthClient = class {
2302
2312
  if (forgetDevice && this.config.tokenDelivery === "json") {
2303
2313
  await this.config.storage.removeItem(this.config.deviceTrust.storageKey);
2304
2314
  }
2315
+ try {
2316
+ await this.oauthStorage.removeItem(OAUTH_STATE_KEY2);
2317
+ } catch {
2318
+ }
2305
2319
  this.config.onAuthStateChange?.(null);
2306
2320
  }
2307
2321
  /**