Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed userStore from WebStorageStateStore to StateStore #1851

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/oidc-client-ts.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1175,7 +1175,7 @@ export class UserManagerSettingsStore extends OidcClientSettingsStore {
// (undocumented)
readonly stopCheckSessionOnError: boolean;
// (undocumented)
readonly userStore: WebStorageStateStore;
readonly userStore: StateStore;
// (undocumented)
readonly validateSubOnSilentRenew: boolean;
}
Expand Down
26 changes: 18 additions & 8 deletions src/UserManagerSettings.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
// Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.

import { type OidcClientSettings, OidcClientSettingsStore } from "./OidcClientSettings";
import {
type OidcClientSettings,
OidcClientSettingsStore,
} from "./OidcClientSettings";
import type { PopupWindowFeatures } from "./utils/PopupUtils";
import { WebStorageStateStore } from "./WebStorageStateStore";
import { InMemoryWebStorage } from "./InMemoryWebStorage";
import type { StateStore } from "./StateStore";

export const DefaultPopupWindowFeatures: PopupWindowFeatures = {
location: false,
Expand Down Expand Up @@ -82,7 +86,7 @@ export interface UserManagerSettings extends OidcClientSettings {
* Storage object used to persist User for currently authenticated user (default: window.sessionStorage, InMemoryWebStorage iff no window).
* E.g. `userStore: new WebStorageStateStore({ store: window.localStorage })`
*/
userStore?: WebStorageStateStore;
userStore?: StateStore;
}

/**
Expand Down Expand Up @@ -120,7 +124,7 @@ export class UserManagerSettingsStore extends OidcClientSettingsStore {

public readonly accessTokenExpiringNotificationTimeInSeconds: number;

public readonly userStore: WebStorageStateStore;
public readonly userStore: StateStore;

public constructor(args: UserManagerSettings) {
const {
Expand Down Expand Up @@ -169,7 +173,10 @@ export class UserManagerSettingsStore extends OidcClientSettingsStore {
this.iframeScriptOrigin = iframeScriptOrigin;

this.silent_redirect_uri = silent_redirect_uri;
this.silentRequestTimeoutInSeconds = silentRequestTimeoutInSeconds || requestTimeoutInSeconds || DefaultSilentRequestTimeoutInSeconds;
this.silentRequestTimeoutInSeconds =
silentRequestTimeoutInSeconds ||
requestTimeoutInSeconds ||
DefaultSilentRequestTimeoutInSeconds;
this.automaticSilentRenew = automaticSilentRenew;
this.validateSubOnSilentRenew = validateSubOnSilentRenew;
this.includeIdTokenInSilentRenew = includeIdTokenInSilentRenew;
Expand All @@ -184,13 +191,16 @@ export class UserManagerSettingsStore extends OidcClientSettingsStore {
this.revokeTokensOnSignout = revokeTokensOnSignout;
this.includeIdTokenInSilentSignout = includeIdTokenInSilentSignout;

this.accessTokenExpiringNotificationTimeInSeconds = accessTokenExpiringNotificationTimeInSeconds;
this.accessTokenExpiringNotificationTimeInSeconds =
accessTokenExpiringNotificationTimeInSeconds;

if (userStore) {
this.userStore = userStore;
}
else {
const store = typeof window !== "undefined" ? window.sessionStorage : new InMemoryWebStorage();
} else {
const store =
typeof window !== "undefined"
? window.sessionStorage
: new InMemoryWebStorage();
this.userStore = new WebStorageStateStore({ store });
}
}
Expand Down
Loading