OIDC: Persist details in session storage, create store (#11302)

* utils to persist clientId and issuer after oidc authentication

* add dep oidc-client-ts

* persist issuer and clientId after successful oidc auth

* add OidcClientStore

* comments and tidy

* format
This commit is contained in:
Kerry 2023-07-21 09:30:19 +12:00 committed by GitHub
parent 882c85a028
commit 0b0d77cbcc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 446 additions and 2 deletions

View file

@ -17,6 +17,7 @@ limitations under the License.
import { MatrixClient } from "matrix-js-sdk/src/matrix";
import { SdkContextClass } from "../../src/contexts/SDKContext";
import { OidcClientStore } from "../../src/stores/oidc/OidcClientStore";
import { UserProfilesStore } from "../../src/stores/UserProfilesStore";
import { VoiceBroadcastPreRecordingStore } from "../../src/voice-broadcast";
import { createTestClient } from "../test-utils";
@ -52,6 +53,12 @@ describe("SdkContextClass", () => {
}).toThrow("Unable to create UserProfilesStore without a client");
});
it("oidcClientStore should raise an error without a client", () => {
expect(() => {
sdkContext.oidcClientStore;
}).toThrow("Unable to create OidcClientStore without a client");
});
describe("when SDKContext has a client", () => {
beforeEach(() => {
sdkContext.client = client;
@ -69,5 +76,12 @@ describe("SdkContextClass", () => {
sdkContext.onLoggedOut();
expect(sdkContext.userProfilesStore).not.toBe(store);
});
it("oidcClientstore should return a OidcClientStore", () => {
const store = sdkContext.oidcClientStore;
expect(store).toBeInstanceOf(OidcClientStore);
// it should return the same instance
expect(sdkContext.oidcClientStore).toBe(store);
});
});
});