Skip to content

Commit af51b5b

Browse files
authored
Merge pull request #1392 from authts/fix-1379-revert-1341
Fix 1379 revert 1341
2 parents b58bbb4 + 8d6c944 commit af51b5b

File tree

4 files changed

+5
-65
lines changed

4 files changed

+5
-65
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
.idea
21

32
# build artifacts
43
*.tsbuildinfo

docs/migration.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22

33
The API is largely backwards-compatible.
44

5-
The "crypto-js" software library has been removed; the native crypto/crypto.subtle module built into the
6-
browser is instead used. All modern browsers are expected to support it.
7-
If you need to support older browsers stay with v2.4!
5+
The "crypto-js" software library has been removed; the native crypto/crypto.subtle module built into the browser is instead used. All modern browsers are expected to support it. If you need to support older browsers stay with v2.4!
86

97
The behavior of merging claims has been improved.
108

@@ -17,8 +15,6 @@ The behavior of merging claims has been improved.
1715
- the `mergeClaims` has been replaced by `mergeClaimsStrategy`
1816
- if the previous behavior is required `mergeClaimsStrategy: { array: "merge" }` comes close to it
1917
- default of `response_mode` changed from `query` → `undefined`
20-
- when using `signoutRedirect` a working callback is required to remove the user and raise an event. As usual
21-
either call `signoutCallback` or `signoutRedirectCallback` in this situation.
2218

2319

2420
## oidc-client v1.11.5 → oidc-client-ts v2.0.0

src/UserManager.test.ts

Lines changed: 1 addition & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,7 @@
22
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
33

44
import { once } from "events";
5-
import {
6-
RedirectNavigator,
7-
type PopupWindow,
8-
PopupNavigator,
9-
IFrameNavigator,
10-
type NavigateResponse,
11-
} from "./navigators";
5+
import { RedirectNavigator, type PopupWindow, PopupNavigator, IFrameNavigator } from "./navigators";
126
import type { SigninResponse } from "./SigninResponse";
137
import type { SignoutResponse } from "./SignoutResponse";
148
import { UserManager, type SigninPopupArgs, type SigninRedirectArgs, type SigninSilentArgs, type SignoutSilentArgs } from "./UserManager";
@@ -39,7 +33,6 @@ describe("UserManager", () => {
3933
userStore: userStoreMock,
4034
metadata: {
4135
authorization_endpoint: "http://sts/oidc/authorize",
42-
end_session_endpoint: "http://sts/oidc/logout",
4336
token_endpoint: "http://sts/oidc/token",
4437
revocation_endpoint: "http://sts/oidc/revoke",
4538
},
@@ -845,53 +838,6 @@ describe("UserManager", () => {
845838
});
846839
});
847840

848-
describe("signoutRedirect", () => {
849-
it("should not unload user to avoid race condition between actual signout and signout event handlers", async () => {
850-
// arrange
851-
const navigateMock = jest.fn().mockReturnValue(Promise.resolve({
852-
url: "http://localhost:8080",
853-
} as NavigateResponse));
854-
jest.spyOn(subject["_redirectNavigator"], "prepare").mockReturnValue(Promise.resolve({
855-
navigate: navigateMock,
856-
close: () => {},
857-
}));
858-
const user = new User({
859-
access_token: "access_token",
860-
token_type: "token_type",
861-
profile: {} as UserProfile,
862-
});
863-
await subject.storeUser(user);
864-
865-
// act
866-
await subject.signoutRedirect();
867-
868-
// assert
869-
expect(navigateMock).toHaveBeenCalledTimes(1);
870-
const storageString = await subject.settings.userStore.get(subject["_userStoreKey"]);
871-
expect(storageString).not.toBeNull();
872-
});
873-
});
874-
875-
describe("signoutRedirectCallback", () => {
876-
it("should unload user", async () => {
877-
// arrange
878-
const user = new User({
879-
access_token: "access_token",
880-
token_type: "token_type",
881-
profile: {} as UserProfile,
882-
});
883-
await subject.storeUser(user);
884-
885-
expect(await subject.settings.userStore.get(subject["_userStoreKey"])).not.toBeNull();
886-
887-
// act
888-
await subject.signoutRedirectCallback();
889-
890-
// assert
891-
expect(await subject.settings.userStore.get(subject["_userStoreKey"])).toBeNull();
892-
});
893-
});
894-
895841
describe("storeUser", () => {
896842
it("should add user to store", async () => {
897843
// arrange

src/UserManager.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,9 @@ export class UserManager {
620620
args.id_token_hint = id_token;
621621
}
622622

623+
await this.removeUser();
624+
logger.debug("user removed, creating signout request");
625+
623626
const signoutRequest = await this._client.createSignoutRequest(args);
624627
logger.debug("got signout request");
625628

@@ -635,15 +638,11 @@ export class UserManager {
635638
throw err;
636639
}
637640
}
638-
639641
protected async _signoutEnd(url: string): Promise<SignoutResponse> {
640642
const logger = this._logger.create("_signoutEnd");
641643
const signoutResponse = await this._client.processSignoutResponse(url);
642644
logger.debug("got signout response");
643645

644-
await this.removeUser();
645-
logger.debug("user removed");
646-
647646
return signoutResponse;
648647
}
649648

0 commit comments

Comments
 (0)