Skip to content

Commit

Permalink
Merge pull request #851 from jodonnell/dev
Browse files Browse the repository at this point in the history
adding CacheLocationChoices so clients don't need to worry about type widening
  • Loading branch information
Prithvi Kanherkar authored Jul 23, 2019
2 parents 1b55af5 + bdfb6ac commit 9e0dfe8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
9 changes: 6 additions & 3 deletions lib/msal-core/src/Configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ import { TelemetryEmitter } from "./telemetry/TelemetryTypes"
* - local storage: MSAL uses browsers local storage to store its cache
* - session storage: MSAL uses the browsers session storage to store its cache
*/
export type CacheLocation = "localStorage" | "sessionStorage";
export enum CacheLocationChoices {
LocalStorage = "localStorage",
SessionStorage = "sessionStorage"
}
export type CacheLocation = CacheLocationChoices.LocalStorage | CacheLocationChoices.SessionStorage;

/**
* Defaults for the Configuration Options
Expand Down Expand Up @@ -120,7 +124,7 @@ const DEFAULT_AUTH_OPTIONS: AuthOptions = {
};

const DEFAULT_CACHE_OPTIONS: CacheOptions = {
cacheLocation: "sessionStorage",
cacheLocation: CacheLocationChoices.SessionStorage,
storeAuthStateInCookie: false
};

Expand Down Expand Up @@ -157,4 +161,3 @@ export function buildConfiguration({ auth, cache = {}, system = {}, framework =
};
return overlayedConfig;
}

6 changes: 3 additions & 3 deletions lib/msal-core/src/Constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CacheLocation } from "./Configuration";
import { CacheLocation, CacheLocationChoices } from "./Configuration";
import { InteractionRequiredAuthErrorMessage as InteractionError } from "./error/InteractionRequiredAuthError";

// Copyright (c) Microsoft Corporation. All rights reserved.
Expand Down Expand Up @@ -80,8 +80,8 @@ export class Constants {
static get openidScope(): string { return "openid"; }
static get profileScope(): string { return "profile"; }

static get cacheLocationLocal(): CacheLocation { return "localStorage"; }
static get cacheLocationSession(): CacheLocation { return "sessionStorage"; }
static get cacheLocationLocal(): CacheLocation { return CacheLocationChoices.LocalStorage; }
static get cacheLocationSession(): CacheLocation { return CacheLocationChoices.SessionStorage; }

static get interactionTypeRedirect(): InteractionType { return "redirectInteraction"; }
static get interactionTypePopup(): InteractionType { return "popupInteraction"; }
Expand Down

0 comments on commit 9e0dfe8

Please sign in to comment.