@azure/msal-browser 2.34.0 → 2.36.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/README.md +1 -1
  2. package/dist/_virtual/_tslib.js +1 -1
  3. package/dist/app/ClientApplication.d.ts +2 -2
  4. package/dist/app/ClientApplication.d.ts.map +1 -1
  5. package/dist/app/ClientApplication.js +37 -20
  6. package/dist/app/ClientApplication.js.map +1 -1
  7. package/dist/app/IPublicClientApplication.js +1 -1
  8. package/dist/app/PublicClientApplication.js +1 -1
  9. package/dist/broker/nativeBroker/NativeMessageHandler.js +1 -1
  10. package/dist/cache/AsyncMemoryStorage.js +1 -1
  11. package/dist/cache/BrowserCacheManager.d.ts +63 -4
  12. package/dist/cache/BrowserCacheManager.d.ts.map +1 -1
  13. package/dist/cache/BrowserCacheManager.js +320 -15
  14. package/dist/cache/BrowserCacheManager.js.map +1 -1
  15. package/dist/cache/BrowserStorage.js +1 -1
  16. package/dist/cache/CryptoKeyStore.js +1 -1
  17. package/dist/cache/DatabaseStorage.js +1 -1
  18. package/dist/cache/MemoryStorage.js +1 -1
  19. package/dist/cache/TokenCache.js +1 -1
  20. package/dist/config/Configuration.d.ts +9 -1
  21. package/dist/config/Configuration.d.ts.map +1 -1
  22. package/dist/config/Configuration.js +5 -2
  23. package/dist/config/Configuration.js.map +1 -1
  24. package/dist/crypto/BrowserCrypto.js +1 -1
  25. package/dist/crypto/CryptoOps.js +1 -1
  26. package/dist/crypto/GuidGenerator.js +1 -1
  27. package/dist/crypto/ModernBrowserCrypto.js +1 -1
  28. package/dist/crypto/MsBrowserCrypto.js +1 -1
  29. package/dist/crypto/MsrBrowserCrypto.js +1 -1
  30. package/dist/crypto/PkceGenerator.js +1 -1
  31. package/dist/crypto/SignedHttpRequest.js +1 -1
  32. package/dist/encode/Base64Decode.js +1 -1
  33. package/dist/encode/Base64Encode.js +1 -1
  34. package/dist/error/BrowserAuthError.js +1 -1
  35. package/dist/error/BrowserConfigurationAuthError.js +1 -1
  36. package/dist/error/NativeAuthError.js +1 -1
  37. package/dist/event/EventHandler.js +1 -1
  38. package/dist/event/EventMessage.js +1 -1
  39. package/dist/event/EventType.js +1 -1
  40. package/dist/index.cjs.js +1036 -578
  41. package/dist/index.cjs.js.map +1 -1
  42. package/dist/index.js +1 -1
  43. package/dist/interaction_client/BaseInteractionClient.js +1 -1
  44. package/dist/interaction_client/HybridSpaAuthorizationCodeClient.js +1 -1
  45. package/dist/interaction_client/NativeInteractionClient.d.ts.map +1 -1
  46. package/dist/interaction_client/NativeInteractionClient.js +8 -9
  47. package/dist/interaction_client/NativeInteractionClient.js.map +1 -1
  48. package/dist/interaction_client/PopupClient.js +1 -1
  49. package/dist/interaction_client/RedirectClient.js +1 -1
  50. package/dist/interaction_client/SilentAuthCodeClient.js +1 -1
  51. package/dist/interaction_client/SilentCacheClient.js +1 -1
  52. package/dist/interaction_client/SilentIframeClient.js +1 -1
  53. package/dist/interaction_client/SilentRefreshClient.js +1 -1
  54. package/dist/interaction_client/StandardInteractionClient.js +1 -1
  55. package/dist/interaction_handler/InteractionHandler.js +1 -1
  56. package/dist/interaction_handler/RedirectHandler.js +1 -1
  57. package/dist/interaction_handler/SilentHandler.js +1 -1
  58. package/dist/internals.js +1 -1
  59. package/dist/navigation/NavigationClient.js +1 -1
  60. package/dist/network/FetchClient.js +1 -1
  61. package/dist/network/XhrClient.js +1 -1
  62. package/dist/packageMetadata.d.ts +1 -1
  63. package/dist/packageMetadata.js +2 -2
  64. package/dist/packageMetadata.js.map +1 -1
  65. package/dist/telemetry/BrowserPerformanceClient.js +2 -2
  66. package/dist/telemetry/BrowserPerformanceClient.js.map +1 -1
  67. package/dist/telemetry/BrowserPerformanceMeasurement.js +1 -1
  68. package/dist/utils/BrowserConstants.d.ts +4 -0
  69. package/dist/utils/BrowserConstants.d.ts.map +1 -1
  70. package/dist/utils/BrowserConstants.js +7 -2
  71. package/dist/utils/BrowserConstants.js.map +1 -1
  72. package/dist/utils/BrowserProtocolUtils.js +1 -1
  73. package/dist/utils/BrowserStringUtils.js +1 -1
  74. package/dist/utils/BrowserUtils.js +1 -1
  75. package/dist/utils/MathUtils.js +1 -1
  76. package/lib/msal-browser.js +1036 -578
  77. package/lib/msal-browser.js.map +1 -1
  78. package/lib/msal-browser.min.js +38 -40
  79. package/package.json +2 -2
@@ -1,4 +1,4 @@
1
- import { CommonAuthorizationCodeRequest, ICrypto, AccountEntity, IdTokenEntity, AccessTokenEntity, RefreshTokenEntity, AppMetadataEntity, CacheManager, ServerTelemetryEntity, ThrottlingEntity, Logger, AuthorityMetadataEntity, AccountInfo, ValidCredentialType } from "@azure/msal-common";
1
+ import { CommonAuthorizationCodeRequest, ICrypto, AccountEntity, IdTokenEntity, AccessTokenEntity, RefreshTokenEntity, AppMetadataEntity, CacheManager, ServerTelemetryEntity, ThrottlingEntity, Logger, AuthorityMetadataEntity, AccountInfo, ValidCredentialType, TokenKeys, CredentialType } from "@azure/msal-common";
2
2
  import { CacheOptions } from "../config/Configuration";
3
3
  import { BrowserCacheLocation, InteractionType } from "../utils/BrowserConstants";
4
4
  import { MemoryStorage } from "./MemoryStorage";
@@ -23,10 +23,11 @@ export declare class BrowserCacheManager extends CacheManager {
23
23
  */
24
24
  protected setupBrowserStorage(cacheLocation: BrowserCacheLocation | string): IWindowStorage<string>;
25
25
  /**
26
- *
26
+ * Returns a window storage class implementing the IWindowStorage interface that corresponds to the configured temporaryCacheLocation.
27
+ * @param temporaryCacheLocation
27
28
  * @param cacheLocation
28
29
  */
29
- protected setupTemporaryCacheStorage(cacheLocation: BrowserCacheLocation | string): IWindowStorage<string>;
30
+ protected setupTemporaryCacheStorage(temporaryCacheLocation: BrowserCacheLocation | string, cacheLocation: BrowserCacheLocation | string): IWindowStorage<string>;
30
31
  /**
31
32
  * Migrate all old cache entries to new schema. No rollback supported.
32
33
  * @param storeAuthStateInCookie
@@ -39,6 +40,12 @@ export declare class BrowserCacheManager extends CacheManager {
39
40
  * @param storeAuthStateInCookie
40
41
  */
41
42
  protected migrateCacheEntry(newKey: string, value: string | null): void;
43
+ /**
44
+ * Searches all cache entries for MSAL accounts and creates the account key map
45
+ * This is used to migrate users from older versions of MSAL which did not create the map.
46
+ * @returns
47
+ */
48
+ private createKeyMaps;
42
49
  /**
43
50
  * Parses passed value as JSON object, JSON.parse() will throw an error.
44
51
  * @param input
@@ -66,6 +73,58 @@ export declare class BrowserCacheManager extends CacheManager {
66
73
  * @param value
67
74
  */
68
75
  setAccount(account: AccountEntity): void;
76
+ /**
77
+ * Returns the array of account keys currently cached
78
+ * @returns
79
+ */
80
+ getAccountKeys(): Array<string>;
81
+ /**
82
+ * Add a new account to the key map
83
+ * @param key
84
+ */
85
+ addAccountKeyToMap(key: string): void;
86
+ /**
87
+ * Remove an account from the key map
88
+ * @param key
89
+ */
90
+ removeAccountKeyFromMap(key: string): void;
91
+ /**
92
+ * Extends inherited removeAccount function to include removal of the account key from the map
93
+ * @param key
94
+ */
95
+ removeAccount(key: string): Promise<void>;
96
+ /**
97
+ * Removes given idToken from the cache and from the key map
98
+ * @param key
99
+ */
100
+ removeIdToken(key: string): void;
101
+ /**
102
+ * Removes given accessToken from the cache and from the key map
103
+ * @param key
104
+ */
105
+ removeAccessToken(key: string): Promise<void>;
106
+ /**
107
+ * Removes given refreshToken from the cache and from the key map
108
+ * @param key
109
+ */
110
+ removeRefreshToken(key: string): void;
111
+ /**
112
+ * Gets the keys for the cached tokens associated with this clientId
113
+ * @returns
114
+ */
115
+ getTokenKeys(): TokenKeys;
116
+ /**
117
+ * Adds the given key to the token key map
118
+ * @param key
119
+ * @param type
120
+ */
121
+ addTokenKey(key: string, type: CredentialType): void;
122
+ /**
123
+ * Removes the given key from the token key map
124
+ * @param key
125
+ * @param type
126
+ */
127
+ removeTokenKey(key: string, type: CredentialType): void;
69
128
  /**
70
129
  * generates idToken entity from a string
71
130
  * @param idTokenKey
@@ -190,7 +249,7 @@ export declare class BrowserCacheManager extends CacheManager {
190
249
  * Will also clear the cookie item if storeAuthStateInCookie is set to true.
191
250
  * @param key
192
251
  */
193
- removeItem(key: string): boolean;
252
+ removeItem(key: string): void;
194
253
  /**
195
254
  * Checks whether key is in cache.
196
255
  * @param key
@@ -1 +1 @@
1
- {"version":3,"file":"BrowserCacheManager.d.ts","sourceRoot":"","sources":["../../src/cache/BrowserCacheManager.ts"],"names":[],"mappings":"AAKA,OAAO,EAA+C,8BAA8B,EAAE,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,YAAY,EAAE,qBAAqB,EAAE,gBAAgB,EAAiB,MAAM,EAAE,uBAAuB,EAAiC,WAAW,EAAmE,mBAAmB,EAAmB,MAAM,oBAAoB,CAAC;AAC5c,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEvD,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAyC,MAAM,2BAA2B,CAAC;AAEzH,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAE1E;;;;GAIG;AACH,qBAAa,mBAAoB,SAAQ,YAAY;IAGjD,SAAS,CAAC,WAAW,EAAE,QAAQ,CAAC,YAAY,CAAC,CAAC;IAE9C,SAAS,CAAC,cAAc,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC;IAEjD,SAAS,CAAC,eAAe,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAEjD,SAAS,CAAC,qBAAqB,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC;IAExD,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC;IAGzB,SAAS,CAAC,QAAQ,CAAC,sBAAsB,SAAuB;gBAEpD,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,QAAQ,CAAC,YAAY,CAAC,EAAE,UAAU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UzD,wBAAwB,IAAI,MAAM,GAAG,IAAI;IAKzC,wBAAwB,CAAC,UAAU,EAAE,OAAO,GAAG,IAAI;IAenD;;OAEG;IACH,kBAAkB,IAAI,MAAM,GAAG,IAAI;IAkCnC;;OAEG;IACH,wBAAwB,CAAC,eAAe,EAAE,MAAM,EAAE,UAAU,EAAE,mBAAmB,GAAG,MAAM;IAkB1F;;OAEG;IACH,yBAAyB,IAAI,MAAM,GAAG,IAAI;IAI1C;;;OAGG;IACH,yBAAyB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;CAGjD;AAED,eAAO,MAAM,6BAA6B,aAAc,MAAM,UAAU,MAAM,KAAG,mBAShF,CAAC"}
@@ -1,9 +1,9 @@
1
- /*! @azure/msal-browser v2.34.0 2023-03-07 */
1
+ /*! @azure/msal-browser v2.36.0 2023-04-18 */
2
2
  'use strict';
3
- import { __extends, __spread, __awaiter, __generator } from '../_virtual/_tslib.js';
4
- import { AccountEntity, CacheManager, IdTokenEntity, AccessTokenEntity, RefreshTokenEntity, AppMetadataEntity, ServerTelemetryEntity, AuthorityMetadataEntity, Constants, PersistentCacheKeys, ClientAuthError, ThrottlingEntity, StringUtils, ProtocolUtils, CcsCredentialType, IdToken, DEFAULT_CRYPTO_IMPLEMENTATION } from '@azure/msal-common';
3
+ import { __extends, __awaiter, __generator, __spread } from '../_virtual/_tslib.js';
4
+ import { CredentialType, RefreshTokenEntity, CacheManager, AccessTokenEntity, IdTokenEntity, AccountEntity, ClientAuthError, AppMetadataEntity, ServerTelemetryEntity, AuthorityMetadataEntity, Constants, PersistentCacheKeys, ThrottlingEntity, StringUtils, ProtocolUtils, CcsCredentialType, IdToken, DEFAULT_CRYPTO_IMPLEMENTATION } from '@azure/msal-common';
5
5
  import { BrowserAuthError } from '../error/BrowserAuthError.js';
6
- import { BrowserCacheLocation, InMemoryCacheKeys, TemporaryCacheKeys } from '../utils/BrowserConstants.js';
6
+ import { BrowserCacheLocation, StaticCacheKeys, InMemoryCacheKeys, TemporaryCacheKeys } from '../utils/BrowserConstants.js';
7
7
  import { BrowserStorage } from './BrowserStorage.js';
8
8
  import { MemoryStorage } from './MemoryStorage.js';
9
9
  import { BrowserProtocolUtils } from '../utils/BrowserProtocolUtils.js';
@@ -20,16 +20,19 @@ import { BrowserProtocolUtils } from '../utils/BrowserProtocolUtils.js';
20
20
  var BrowserCacheManager = /** @class */ (function (_super) {
21
21
  __extends(BrowserCacheManager, _super);
22
22
  function BrowserCacheManager(clientId, cacheConfig, cryptoImpl, logger) {
23
- var _this = _super.call(this, clientId, cryptoImpl) || this;
23
+ var _this = _super.call(this, clientId, cryptoImpl, logger) || this;
24
24
  // Cookie life calculation (hours * minutes * seconds * ms)
25
25
  _this.COOKIE_LIFE_MULTIPLIER = 24 * 60 * 60 * 1000;
26
26
  _this.cacheConfig = cacheConfig;
27
27
  _this.logger = logger;
28
28
  _this.internalStorage = new MemoryStorage();
29
29
  _this.browserStorage = _this.setupBrowserStorage(_this.cacheConfig.cacheLocation);
30
- _this.temporaryCacheStorage = _this.setupTemporaryCacheStorage(_this.cacheConfig.cacheLocation);
31
- // Migrate any cache entries from older versions of MSAL.
32
- _this.migrateCacheEntries();
30
+ _this.temporaryCacheStorage = _this.setupTemporaryCacheStorage(_this.cacheConfig.temporaryCacheLocation, _this.cacheConfig.cacheLocation);
31
+ // Migrate cache entries from older versions of MSAL.
32
+ if (cacheConfig.cacheMigrationEnabled) {
33
+ _this.migrateCacheEntries();
34
+ _this.createKeyMaps();
35
+ }
33
36
  return _this;
34
37
  }
35
38
  /**
@@ -41,7 +44,6 @@ var BrowserCacheManager = /** @class */ (function (_super) {
41
44
  case BrowserCacheLocation.LocalStorage:
42
45
  case BrowserCacheLocation.SessionStorage:
43
46
  try {
44
- // Temporary cache items will always be stored in session storage to mitigate problems caused by multiple tabs
45
47
  return new BrowserStorage(cacheLocation);
46
48
  }
47
49
  catch (e) {
@@ -53,16 +55,20 @@ var BrowserCacheManager = /** @class */ (function (_super) {
53
55
  return new MemoryStorage();
54
56
  };
55
57
  /**
56
- *
58
+ * Returns a window storage class implementing the IWindowStorage interface that corresponds to the configured temporaryCacheLocation.
59
+ * @param temporaryCacheLocation
57
60
  * @param cacheLocation
58
61
  */
59
- BrowserCacheManager.prototype.setupTemporaryCacheStorage = function (cacheLocation) {
62
+ BrowserCacheManager.prototype.setupTemporaryCacheStorage = function (temporaryCacheLocation, cacheLocation) {
60
63
  switch (cacheLocation) {
61
64
  case BrowserCacheLocation.LocalStorage:
62
65
  case BrowserCacheLocation.SessionStorage:
63
66
  try {
64
- // Temporary cache items will always be stored in session storage to mitigate problems caused by multiple tabs
65
- return new BrowserStorage(BrowserCacheLocation.SessionStorage);
67
+ /*
68
+ * When users do not explicitly choose their own temporaryCacheLocation,
69
+ * temporary cache items will always be stored in session storage to mitigate problems caused by multiple tabs
70
+ */
71
+ return new BrowserStorage(temporaryCacheLocation || BrowserCacheLocation.SessionStorage);
66
72
  }
67
73
  catch (e) {
68
74
  this.logger.verbose(e);
@@ -102,6 +108,91 @@ var BrowserCacheManager = /** @class */ (function (_super) {
102
108
  this.setTemporaryCache(newKey, value, true);
103
109
  }
104
110
  };
111
+ /**
112
+ * Searches all cache entries for MSAL accounts and creates the account key map
113
+ * This is used to migrate users from older versions of MSAL which did not create the map.
114
+ * @returns
115
+ */
116
+ BrowserCacheManager.prototype.createKeyMaps = function () {
117
+ var _this = this;
118
+ this.logger.trace("BrowserCacheManager - createKeyMaps called.");
119
+ var accountKeys = this.getItem(StaticCacheKeys.ACCOUNT_KEYS);
120
+ var tokenKeys = this.getItem(StaticCacheKeys.TOKEN_KEYS + "." + this.clientId);
121
+ if (accountKeys && tokenKeys) {
122
+ this.logger.verbose("BrowserCacheManager:createKeyMaps - account and token key maps already exist, skipping migration.");
123
+ // Key maps already exist, no need to iterate through cache
124
+ return;
125
+ }
126
+ var allKeys = this.browserStorage.getKeys();
127
+ allKeys.forEach(function (key) {
128
+ if (_this.isCredentialKey(key)) {
129
+ // Get item, parse, validate and write key to map
130
+ var value = _this.getItem(key);
131
+ if (value) {
132
+ var credObj = _this.validateAndParseJson(value);
133
+ if (credObj && credObj.hasOwnProperty("credentialType")) {
134
+ switch (credObj["credentialType"]) {
135
+ case CredentialType.ID_TOKEN:
136
+ if (IdTokenEntity.isIdTokenEntity(credObj)) {
137
+ _this.logger.trace("BrowserCacheManager:createKeyMaps - idToken found, saving key to token key map");
138
+ _this.logger.tracePii("BrowserCacheManager:createKeyMaps - idToken with key: " + key + " found, saving key to token key map");
139
+ var idTokenEntity = CacheManager.toObject(new IdTokenEntity(), credObj);
140
+ var newKey = _this.updateCredentialCacheKey(key, idTokenEntity);
141
+ _this.addTokenKey(newKey, CredentialType.ID_TOKEN);
142
+ return;
143
+ }
144
+ else {
145
+ _this.logger.trace("BrowserCacheManager:createKeyMaps - key found matching idToken schema with value containing idToken credentialType field but value failed IdTokenEntity validation, skipping.");
146
+ _this.logger.tracePii("BrowserCacheManager:createKeyMaps - failed idToken validation on key: " + key);
147
+ }
148
+ break;
149
+ case CredentialType.ACCESS_TOKEN:
150
+ case CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME:
151
+ if (AccessTokenEntity.isAccessTokenEntity(credObj)) {
152
+ _this.logger.trace("BrowserCacheManager:createKeyMaps - accessToken found, saving key to token key map");
153
+ _this.logger.tracePii("BrowserCacheManager:createKeyMaps - accessToken with key: " + key + " found, saving key to token key map");
154
+ var accessTokenEntity = CacheManager.toObject(new AccessTokenEntity(), credObj);
155
+ var newKey = _this.updateCredentialCacheKey(key, accessTokenEntity);
156
+ _this.addTokenKey(newKey, CredentialType.ACCESS_TOKEN);
157
+ return;
158
+ }
159
+ else {
160
+ _this.logger.trace("BrowserCacheManager:createKeyMaps - key found matching accessToken schema with value containing accessToken credentialType field but value failed AccessTokenEntity validation, skipping.");
161
+ _this.logger.tracePii("BrowserCacheManager:createKeyMaps - failed accessToken validation on key: " + key);
162
+ }
163
+ break;
164
+ case CredentialType.REFRESH_TOKEN:
165
+ if (RefreshTokenEntity.isRefreshTokenEntity(credObj)) {
166
+ _this.logger.trace("BrowserCacheManager:createKeyMaps - refreshToken found, saving key to token key map");
167
+ _this.logger.tracePii("BrowserCacheManager:createKeyMaps - refreshToken with key: " + key + " found, saving key to token key map");
168
+ var refreshTokenEntity = CacheManager.toObject(new RefreshTokenEntity(), credObj);
169
+ var newKey = _this.updateCredentialCacheKey(key, refreshTokenEntity);
170
+ _this.addTokenKey(newKey, CredentialType.REFRESH_TOKEN);
171
+ return;
172
+ }
173
+ else {
174
+ _this.logger.trace("BrowserCacheManager:createKeyMaps - key found matching refreshToken schema with value containing refreshToken credentialType field but value failed RefreshTokenEntity validation, skipping.");
175
+ _this.logger.tracePii("BrowserCacheManager:createKeyMaps - failed refreshToken validation on key: " + key);
176
+ }
177
+ break;
178
+ // If credentialType isn't one of our predefined ones, it may not be an MSAL cache value. Ignore.
179
+ }
180
+ }
181
+ }
182
+ }
183
+ if (_this.isAccountKey(key)) {
184
+ var value = _this.getItem(key);
185
+ if (value) {
186
+ var accountObj = _this.validateAndParseJson(value);
187
+ if (accountObj && AccountEntity.isAccountEntity(accountObj)) {
188
+ _this.logger.trace("BrowserCacheManager:createKeyMaps - account found, saving key to account key map");
189
+ _this.logger.tracePii("BrowserCacheManager:createKeyMaps - account with key: " + key + " found, saving key to account key map");
190
+ _this.addAccountKeyToMap(key);
191
+ }
192
+ }
193
+ }
194
+ });
195
+ };
105
196
  /**
106
197
  * Parses passed value as JSON object, JSON.parse() will throw an error.
107
198
  * @param input
@@ -141,12 +232,15 @@ var BrowserCacheManager = /** @class */ (function (_super) {
141
232
  * @param accountKey
142
233
  */
143
234
  BrowserCacheManager.prototype.getAccount = function (accountKey) {
235
+ this.logger.trace("BrowserCacheManager.getAccount called");
144
236
  var account = this.getItem(accountKey);
145
237
  if (!account) {
238
+ this.removeAccountKeyFromMap(accountKey);
146
239
  return null;
147
240
  }
148
241
  var parsedAccount = this.validateAndParseJson(account);
149
242
  if (!parsedAccount || !AccountEntity.isAccountEntity(parsedAccount)) {
243
+ this.removeAccountKeyFromMap(accountKey);
150
244
  return null;
151
245
  }
152
246
  return CacheManager.toObject(new AccountEntity(), parsedAccount);
@@ -160,6 +254,207 @@ var BrowserCacheManager = /** @class */ (function (_super) {
160
254
  this.logger.trace("BrowserCacheManager.setAccount called");
161
255
  var key = account.generateAccountKey();
162
256
  this.setItem(key, JSON.stringify(account));
257
+ this.addAccountKeyToMap(key);
258
+ };
259
+ /**
260
+ * Returns the array of account keys currently cached
261
+ * @returns
262
+ */
263
+ BrowserCacheManager.prototype.getAccountKeys = function () {
264
+ this.logger.trace("BrowserCacheManager.getAccountKeys called");
265
+ var accountKeys = this.getItem(StaticCacheKeys.ACCOUNT_KEYS);
266
+ if (accountKeys) {
267
+ return JSON.parse(accountKeys);
268
+ }
269
+ this.logger.verbose("BrowserCacheManager.getAccountKeys - No account keys found");
270
+ return [];
271
+ };
272
+ /**
273
+ * Add a new account to the key map
274
+ * @param key
275
+ */
276
+ BrowserCacheManager.prototype.addAccountKeyToMap = function (key) {
277
+ this.logger.trace("BrowserCacheManager.addAccountKeyToMap called");
278
+ this.logger.tracePii("BrowserCacheManager.addAccountKeyToMap called with key: " + key);
279
+ var accountKeys = this.getAccountKeys();
280
+ if (accountKeys.indexOf(key) === -1) {
281
+ // Only add key if it does not already exist in the map
282
+ accountKeys.push(key);
283
+ this.setItem(StaticCacheKeys.ACCOUNT_KEYS, JSON.stringify(accountKeys));
284
+ this.logger.verbose("BrowserCacheManager.addAccountKeyToMap account key added");
285
+ }
286
+ else {
287
+ this.logger.verbose("BrowserCacheManager.addAccountKeyToMap account key already exists in map");
288
+ }
289
+ };
290
+ /**
291
+ * Remove an account from the key map
292
+ * @param key
293
+ */
294
+ BrowserCacheManager.prototype.removeAccountKeyFromMap = function (key) {
295
+ this.logger.trace("BrowserCacheManager.removeAccountKeyFromMap called");
296
+ this.logger.tracePii("BrowserCacheManager.removeAccountKeyFromMap called with key: " + key);
297
+ var accountKeys = this.getAccountKeys();
298
+ var removalIndex = accountKeys.indexOf(key);
299
+ if (removalIndex > -1) {
300
+ accountKeys.splice(removalIndex, 1);
301
+ this.setItem(StaticCacheKeys.ACCOUNT_KEYS, JSON.stringify(accountKeys));
302
+ this.logger.trace("BrowserCacheManager.removeAccountKeyFromMap account key removed");
303
+ }
304
+ else {
305
+ this.logger.trace("BrowserCacheManager.removeAccountKeyFromMap key not found in existing map");
306
+ }
307
+ };
308
+ /**
309
+ * Extends inherited removeAccount function to include removal of the account key from the map
310
+ * @param key
311
+ */
312
+ BrowserCacheManager.prototype.removeAccount = function (key) {
313
+ return __awaiter(this, void 0, void 0, function () {
314
+ return __generator(this, function (_a) {
315
+ _super.prototype.removeAccount.call(this, key);
316
+ this.removeAccountKeyFromMap(key);
317
+ return [2 /*return*/];
318
+ });
319
+ });
320
+ };
321
+ /**
322
+ * Removes given idToken from the cache and from the key map
323
+ * @param key
324
+ */
325
+ BrowserCacheManager.prototype.removeIdToken = function (key) {
326
+ _super.prototype.removeIdToken.call(this, key);
327
+ this.removeTokenKey(key, CredentialType.ID_TOKEN);
328
+ };
329
+ /**
330
+ * Removes given accessToken from the cache and from the key map
331
+ * @param key
332
+ */
333
+ BrowserCacheManager.prototype.removeAccessToken = function (key) {
334
+ return __awaiter(this, void 0, void 0, function () {
335
+ return __generator(this, function (_a) {
336
+ _super.prototype.removeAccessToken.call(this, key);
337
+ this.removeTokenKey(key, CredentialType.ACCESS_TOKEN);
338
+ return [2 /*return*/];
339
+ });
340
+ });
341
+ };
342
+ /**
343
+ * Removes given refreshToken from the cache and from the key map
344
+ * @param key
345
+ */
346
+ BrowserCacheManager.prototype.removeRefreshToken = function (key) {
347
+ _super.prototype.removeRefreshToken.call(this, key);
348
+ this.removeTokenKey(key, CredentialType.REFRESH_TOKEN);
349
+ };
350
+ /**
351
+ * Gets the keys for the cached tokens associated with this clientId
352
+ * @returns
353
+ */
354
+ BrowserCacheManager.prototype.getTokenKeys = function () {
355
+ this.logger.trace("BrowserCacheManager.getTokenKeys called");
356
+ var item = this.getItem(StaticCacheKeys.TOKEN_KEYS + "." + this.clientId);
357
+ if (item) {
358
+ var tokenKeys = this.validateAndParseJson(item);
359
+ if (tokenKeys &&
360
+ tokenKeys.hasOwnProperty("idToken") &&
361
+ tokenKeys.hasOwnProperty("accessToken") &&
362
+ tokenKeys.hasOwnProperty("refreshToken")) {
363
+ return tokenKeys;
364
+ }
365
+ else {
366
+ this.logger.error("BrowserCacheManager.getTokenKeys - Token keys found but in an unknown format. Returning empty key map.");
367
+ }
368
+ }
369
+ else {
370
+ this.logger.verbose("BrowserCacheManager.getTokenKeys - No token keys found");
371
+ }
372
+ return {
373
+ idToken: [],
374
+ accessToken: [],
375
+ refreshToken: []
376
+ };
377
+ };
378
+ /**
379
+ * Adds the given key to the token key map
380
+ * @param key
381
+ * @param type
382
+ */
383
+ BrowserCacheManager.prototype.addTokenKey = function (key, type) {
384
+ this.logger.trace("BrowserCacheManager addTokenKey called");
385
+ var tokenKeys = this.getTokenKeys();
386
+ switch (type) {
387
+ case CredentialType.ID_TOKEN:
388
+ if (tokenKeys.idToken.indexOf(key) === -1) {
389
+ this.logger.info("BrowserCacheManager: addTokenKey - idToken added to map");
390
+ tokenKeys.idToken.push(key);
391
+ }
392
+ break;
393
+ case CredentialType.ACCESS_TOKEN:
394
+ if (tokenKeys.accessToken.indexOf(key) === -1) {
395
+ this.logger.info("BrowserCacheManager: addTokenKey - accessToken added to map");
396
+ tokenKeys.accessToken.push(key);
397
+ }
398
+ break;
399
+ case CredentialType.REFRESH_TOKEN:
400
+ if (tokenKeys.refreshToken.indexOf(key) === -1) {
401
+ this.logger.info("BrowserCacheManager: addTokenKey - refreshToken added to map");
402
+ tokenKeys.refreshToken.push(key);
403
+ }
404
+ break;
405
+ default:
406
+ this.logger.error("BrowserCacheManager:addTokenKey - CredentialType provided invalid. CredentialType: " + type);
407
+ ClientAuthError.createUnexpectedCredentialTypeError();
408
+ }
409
+ this.setItem(StaticCacheKeys.TOKEN_KEYS + "." + this.clientId, JSON.stringify(tokenKeys));
410
+ };
411
+ /**
412
+ * Removes the given key from the token key map
413
+ * @param key
414
+ * @param type
415
+ */
416
+ BrowserCacheManager.prototype.removeTokenKey = function (key, type) {
417
+ this.logger.trace("BrowserCacheManager removeTokenKey called");
418
+ var tokenKeys = this.getTokenKeys();
419
+ switch (type) {
420
+ case CredentialType.ID_TOKEN:
421
+ this.logger.infoPii("BrowserCacheManager: removeTokenKey - attempting to remove idToken with key: " + key + " from map");
422
+ var idRemoval = tokenKeys.idToken.indexOf(key);
423
+ if (idRemoval > -1) {
424
+ this.logger.info("BrowserCacheManager: removeTokenKey - idToken removed from map");
425
+ tokenKeys.idToken.splice(idRemoval, 1);
426
+ }
427
+ else {
428
+ this.logger.info("BrowserCacheManager: removeTokenKey - idToken does not exist in map. Either it was previously removed or it was never added.");
429
+ }
430
+ break;
431
+ case CredentialType.ACCESS_TOKEN:
432
+ this.logger.infoPii("BrowserCacheManager: removeTokenKey - attempting to remove accessToken with key: " + key + " from map");
433
+ var accessRemoval = tokenKeys.accessToken.indexOf(key);
434
+ if (accessRemoval > -1) {
435
+ this.logger.info("BrowserCacheManager: removeTokenKey - accessToken removed from map");
436
+ tokenKeys.accessToken.splice(accessRemoval, 1);
437
+ }
438
+ else {
439
+ this.logger.info("BrowserCacheManager: removeTokenKey - accessToken does not exist in map. Either it was previously removed or it was never added.");
440
+ }
441
+ break;
442
+ case CredentialType.REFRESH_TOKEN:
443
+ this.logger.infoPii("BrowserCacheManager: removeTokenKey - attempting to remove refreshToken with key: " + key + " from map");
444
+ var refreshRemoval = tokenKeys.refreshToken.indexOf(key);
445
+ if (refreshRemoval > -1) {
446
+ this.logger.info("BrowserCacheManager: removeTokenKey - refreshToken removed from map");
447
+ tokenKeys.refreshToken.splice(refreshRemoval, 1);
448
+ }
449
+ else {
450
+ this.logger.info("BrowserCacheManager: removeTokenKey - refreshToken does not exist in map. Either it was previously removed or it was never added.");
451
+ }
452
+ break;
453
+ default:
454
+ this.logger.error("BrowserCacheManager:removeTokenKey - CredentialType provided invalid. CredentialType: " + type);
455
+ ClientAuthError.createUnexpectedCredentialTypeError();
456
+ }
457
+ this.setItem(StaticCacheKeys.TOKEN_KEYS + "." + this.clientId, JSON.stringify(tokenKeys));
163
458
  };
164
459
  /**
165
460
  * generates idToken entity from a string
@@ -169,11 +464,13 @@ var BrowserCacheManager = /** @class */ (function (_super) {
169
464
  var value = this.getItem(idTokenKey);
170
465
  if (!value) {
171
466
  this.logger.trace("BrowserCacheManager.getIdTokenCredential: called, no cache hit");
467
+ this.removeTokenKey(idTokenKey, CredentialType.ID_TOKEN);
172
468
  return null;
173
469
  }
174
470
  var parsedIdToken = this.validateAndParseJson(value);
175
471
  if (!parsedIdToken || !IdTokenEntity.isIdTokenEntity(parsedIdToken)) {
176
472
  this.logger.trace("BrowserCacheManager.getIdTokenCredential: called, no cache hit");
473
+ this.removeTokenKey(idTokenKey, CredentialType.ID_TOKEN);
177
474
  return null;
178
475
  }
179
476
  this.logger.trace("BrowserCacheManager.getIdTokenCredential: cache hit");
@@ -187,6 +484,7 @@ var BrowserCacheManager = /** @class */ (function (_super) {
187
484
  this.logger.trace("BrowserCacheManager.setIdTokenCredential called");
188
485
  var idTokenKey = idToken.generateCredentialKey();
189
486
  this.setItem(idTokenKey, JSON.stringify(idToken));
487
+ this.addTokenKey(idTokenKey, CredentialType.ID_TOKEN);
190
488
  };
191
489
  /**
192
490
  * generates accessToken entity from a string
@@ -196,11 +494,13 @@ var BrowserCacheManager = /** @class */ (function (_super) {
196
494
  var value = this.getItem(accessTokenKey);
197
495
  if (!value) {
198
496
  this.logger.trace("BrowserCacheManager.getAccessTokenCredential: called, no cache hit");
497
+ this.removeTokenKey(accessTokenKey, CredentialType.ACCESS_TOKEN);
199
498
  return null;
200
499
  }
201
500
  var parsedAccessToken = this.validateAndParseJson(value);
202
501
  if (!parsedAccessToken || !AccessTokenEntity.isAccessTokenEntity(parsedAccessToken)) {
203
502
  this.logger.trace("BrowserCacheManager.getAccessTokenCredential: called, no cache hit");
503
+ this.removeTokenKey(accessTokenKey, CredentialType.ACCESS_TOKEN);
204
504
  return null;
205
505
  }
206
506
  this.logger.trace("BrowserCacheManager.getAccessTokenCredential: cache hit");
@@ -214,6 +514,7 @@ var BrowserCacheManager = /** @class */ (function (_super) {
214
514
  this.logger.trace("BrowserCacheManager.setAccessTokenCredential called");
215
515
  var accessTokenKey = accessToken.generateCredentialKey();
216
516
  this.setItem(accessTokenKey, JSON.stringify(accessToken));
517
+ this.addTokenKey(accessTokenKey, CredentialType.ACCESS_TOKEN);
217
518
  };
218
519
  /**
219
520
  * generates refreshToken entity from a string
@@ -223,11 +524,13 @@ var BrowserCacheManager = /** @class */ (function (_super) {
223
524
  var value = this.getItem(refreshTokenKey);
224
525
  if (!value) {
225
526
  this.logger.trace("BrowserCacheManager.getRefreshTokenCredential: called, no cache hit");
527
+ this.removeTokenKey(refreshTokenKey, CredentialType.REFRESH_TOKEN);
226
528
  return null;
227
529
  }
228
530
  var parsedRefreshToken = this.validateAndParseJson(value);
229
531
  if (!parsedRefreshToken || !RefreshTokenEntity.isRefreshTokenEntity(parsedRefreshToken)) {
230
532
  this.logger.trace("BrowserCacheManager.getRefreshTokenCredential: called, no cache hit");
533
+ this.removeTokenKey(refreshTokenKey, CredentialType.REFRESH_TOKEN);
231
534
  return null;
232
535
  }
233
536
  this.logger.trace("BrowserCacheManager.getRefreshTokenCredential: cache hit");
@@ -241,6 +544,7 @@ var BrowserCacheManager = /** @class */ (function (_super) {
241
544
  this.logger.trace("BrowserCacheManager.setRefreshTokenCredential called");
242
545
  var refreshTokenKey = refreshToken.generateCredentialKey();
243
546
  this.setItem(refreshTokenKey, JSON.stringify(refreshToken));
547
+ this.addTokenKey(refreshTokenKey, CredentialType.REFRESH_TOKEN);
244
548
  };
245
549
  /**
246
550
  * fetch appMetadata entity from the platform cache
@@ -538,7 +842,6 @@ var BrowserCacheManager = /** @class */ (function (_super) {
538
842
  this.logger.trace("BrowserCacheManager.removeItem: storeAuthStateInCookie is true, clearing item cookie");
539
843
  this.clearItemCookie(key);
540
844
  }
541
- return true;
542
845
  };
543
846
  /**
544
847
  * Checks whether key is in cache.
@@ -965,8 +1268,10 @@ var BrowserCacheManager = /** @class */ (function (_super) {
965
1268
  var DEFAULT_BROWSER_CACHE_MANAGER = function (clientId, logger) {
966
1269
  var cacheOptions = {
967
1270
  cacheLocation: BrowserCacheLocation.MemoryStorage,
1271
+ temporaryCacheLocation: BrowserCacheLocation.MemoryStorage,
968
1272
  storeAuthStateInCookie: false,
969
- secureCookies: false
1273
+ secureCookies: false,
1274
+ cacheMigrationEnabled: false
970
1275
  };
971
1276
  return new BrowserCacheManager(clientId, cacheOptions, DEFAULT_CRYPTO_IMPLEMENTATION, logger);
972
1277
  };