@nauth-toolkit/client 0.1.100 → 0.1.102
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 +11 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.mjs +11 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
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 },
|
|
@@ -2305,6 +2312,10 @@ var NAuthClient = class {
|
|
|
2305
2312
|
if (forgetDevice && this.config.tokenDelivery === "json") {
|
|
2306
2313
|
await this.config.storage.removeItem(this.config.deviceTrust.storageKey);
|
|
2307
2314
|
}
|
|
2315
|
+
try {
|
|
2316
|
+
await this.oauthStorage.removeItem(OAUTH_STATE_KEY2);
|
|
2317
|
+
} catch {
|
|
2318
|
+
}
|
|
2308
2319
|
this.config.onAuthStateChange?.(null);
|
|
2309
2320
|
}
|
|
2310
2321
|
/**
|