Skip to content

Commit

Permalink
fix: Prevent accessing the global window object when instantiating Pa…
Browse files Browse the repository at this point in the history
…ssport (#888)
  • Loading branch information
Jon-Alonso authored Sep 21, 2023
1 parent 96df388 commit f710bce
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/passport/sdk/src/authManager.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
InMemoryWebStorage,
User as OidcUser,
UserManager,
UserManagerSettings,
Expand Down Expand Up @@ -31,6 +32,9 @@ const getAuthConfiguration = ({
oidcConfiguration,
authenticationDomain,
}: PassportConfiguration): UserManagerSettings => {
const store = typeof window !== 'undefined' ? window.localStorage : new InMemoryWebStorage();
const userStore = new WebStorageStateStore({ store });

const baseConfiguration: UserManagerSettings = {
authority: authenticationDomain,
redirect_uri: oidcConfiguration.redirectUri,
Expand All @@ -48,7 +52,7 @@ const getAuthConfiguration = ({
mergeClaims: true,
loadUserInfo: true,
scope: oidcConfiguration.scope,
userStore: new WebStorageStateStore({ store: window.localStorage }),
userStore,
};

if (oidcConfiguration.audience) {
Expand Down

0 comments on commit f710bce

Please sign in to comment.