From 13547b4676c3beb3f1b56917bace1fc3b56e75d0 Mon Sep 17 00:00:00 2001 From: Jacob O'Donnell Date: Sat, 20 Jul 2019 07:50:24 -0400 Subject: [PATCH] adding CacheLocationChoices so clients don't need to worry about type widening --- lib/msal-core/src/Configuration.ts | 9 ++++++--- lib/msal-core/src/Constants.ts | 6 +++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/msal-core/src/Configuration.ts b/lib/msal-core/src/Configuration.ts index 49a4018181..cd86570da5 100644 --- a/lib/msal-core/src/Configuration.ts +++ b/lib/msal-core/src/Configuration.ts @@ -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 @@ -120,7 +124,7 @@ const DEFAULT_AUTH_OPTIONS: AuthOptions = { }; const DEFAULT_CACHE_OPTIONS: CacheOptions = { - cacheLocation: "sessionStorage", + cacheLocation: CacheLocationChoices.SessionStorage, storeAuthStateInCookie: false }; @@ -157,4 +161,3 @@ export function buildConfiguration({ auth, cache = {}, system = {}, framework = }; return overlayedConfig; } - diff --git a/lib/msal-core/src/Constants.ts b/lib/msal-core/src/Constants.ts index b906677135..d5e9a908c3 100644 --- a/lib/msal-core/src/Constants.ts +++ b/lib/msal-core/src/Constants.ts @@ -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. @@ -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; } } /**