{"version":3,"file":"BrowserStorage.js","sources":["../../src/cache/BrowserStorage.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { BrowserConfigurationAuthError } from \"../error/BrowserConfigurationAuthError\";\nimport { BrowserCacheLocation } from \"../utils/BrowserConstants\";\nimport { IWindowStorage } from \"./IWindowStorage\";\n\nexport class BrowserStorage implements IWindowStorage {\n\n private windowStorage: Storage;\n\n constructor(cacheLocation: string) {\n this.validateWindowStorage(cacheLocation);\n this.windowStorage = window[cacheLocation];\n }\n\n private validateWindowStorage(cacheLocation: string): void {\n if (cacheLocation !== BrowserCacheLocation.LocalStorage && cacheLocation !== BrowserCacheLocation.SessionStorage) {\n throw BrowserConfigurationAuthError.createStorageNotSupportedError(cacheLocation);\n }\n const storageSupported = !!window[cacheLocation];\n if (!storageSupported) {\n throw BrowserConfigurationAuthError.createStorageNotSupportedError(cacheLocation);\n }\n }\n\n getItem(key: string): string | null {\n return this.windowStorage.getItem(key);\n }\n\n setItem(key: string, value: string): void {\n this.windowStorage.setItem(key, value);\n }\n\n removeItem(key: string): void {\n this.windowStorage.removeItem(key);\n }\n\n getKeys(): string[] {\n return Object.keys(this.windowStorage);\n }\n\n containsKey(key: string): boolean {\n return this.windowStorage.hasOwnProperty(key);\n }\n}\n"],"names":[],"mappings":";;;;;AAAA;;;;;IAaI,wBAAY,aAAqB;QAC7B,IAAI,CAAC,qBAAqB,CAAC,aAAa,CAAC,CAAC;QAC1C,IAAI,CAAC,aAAa,GAAG,MAAM,CAAC,aAAa,CAAC,CAAC;KAC9C;IAEO,8CAAqB,GAA7B,UAA8B,aAAqB;QAC/C,IAAI,aAAa,KAAK,oBAAoB,CAAC,YAAY,IAAI,aAAa,KAAK,oBAAoB,CAAC,cAAc,EAAE;YAC9G,MAAM,6BAA6B,CAAC,8BAA8B,CAAC,aAAa,CAAC,CAAC;SACrF;QACD,IAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;QACjD,IAAI,CAAC,gBAAgB,EAAE;YACnB,MAAM,6BAA6B,CAAC,8BAA8B,CAAC,aAAa,CAAC,CAAC;SACrF;KACJ;IAED,gCAAO,GAAP,UAAQ,GAAW;QACf,OAAO,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;KAC1C;IAED,gCAAO,GAAP,UAAQ,GAAW,EAAE,KAAa;QAC9B,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;KAC1C;IAED,mCAAU,GAAV,UAAW,GAAW;QAClB,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;KACtC;IAED,gCAAO,GAAP;QACI,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;KAC1C;IAED,oCAAW,GAAX,UAAY,GAAW;QACnB,OAAO,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;KACjD;IACL,qBAAC;AAAD,CAAC;;;;"}