@azure/msal-browser 2.34.0 → 2.35.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 +36 -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 +60 -2
  12. package/dist/cache/BrowserCacheManager.d.ts.map +1 -1
  13. package/dist/cache/BrowserCacheManager.js +310 -9
  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 +4 -0
  21. package/dist/config/Configuration.d.ts.map +1 -1
  22. package/dist/config/Configuration.js +4 -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 +1024 -572
  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 +1024 -572
  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";
@@ -39,6 +39,12 @@ export declare class BrowserCacheManager extends CacheManager {
39
39
  * @param storeAuthStateInCookie
40
40
  */
41
41
  protected migrateCacheEntry(newKey: string, value: string | null): void;
42
+ /**
43
+ * Searches all cache entries for MSAL accounts and creates the account key map
44
+ * This is used to migrate users from older versions of MSAL which did not create the map.
45
+ * @returns
46
+ */
47
+ private createKeyMaps;
42
48
  /**
43
49
  * Parses passed value as JSON object, JSON.parse() will throw an error.
44
50
  * @param input
@@ -66,6 +72,58 @@ export declare class BrowserCacheManager extends CacheManager {
66
72
  * @param value
67
73
  */
68
74
  setAccount(account: AccountEntity): void;
75
+ /**
76
+ * Returns the array of account keys currently cached
77
+ * @returns
78
+ */
79
+ getAccountKeys(): Array<string>;
80
+ /**
81
+ * Add a new account to the key map
82
+ * @param key
83
+ */
84
+ addAccountKeyToMap(key: string): void;
85
+ /**
86
+ * Remove an account from the key map
87
+ * @param key
88
+ */
89
+ removeAccountKeyFromMap(key: string): void;
90
+ /**
91
+ * Extends inherited removeAccount function to include removal of the account key from the map
92
+ * @param key
93
+ */
94
+ removeAccount(key: string): Promise<void>;
95
+ /**
96
+ * Removes given idToken from the cache and from the key map
97
+ * @param key
98
+ */
99
+ removeIdToken(key: string): void;
100
+ /**
101
+ * Removes given accessToken from the cache and from the key map
102
+ * @param key
103
+ */
104
+ removeAccessToken(key: string): Promise<void>;
105
+ /**
106
+ * Removes given refreshToken from the cache and from the key map
107
+ * @param key
108
+ */
109
+ removeRefreshToken(key: string): void;
110
+ /**
111
+ * Gets the keys for the cached tokens associated with this clientId
112
+ * @returns
113
+ */
114
+ getTokenKeys(): TokenKeys;
115
+ /**
116
+ * Adds the given key to the token key map
117
+ * @param key
118
+ * @param type
119
+ */
120
+ addTokenKey(key: string, type: CredentialType): void;
121
+ /**
122
+ * Removes the given key from the token key map
123
+ * @param key
124
+ * @param type
125
+ */
126
+ removeTokenKey(key: string, type: CredentialType): void;
69
127
  /**
70
128
  * generates idToken entity from a string
71
129
  * @param idTokenKey
@@ -190,7 +248,7 @@ export declare class BrowserCacheManager extends CacheManager {
190
248
  * Will also clear the cookie item if storeAuthStateInCookie is set to true.
191
249
  * @param key
192
250
  */
193
- removeItem(key: string): boolean;
251
+ removeItem(key: string): void;
194
252
  /**
195
253
  * Checks whether key is in cache.
196
254
  * @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,mBAA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msal-browser v2.35.0 2023-04-03 */
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,7 +20,7 @@ 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;
@@ -28,8 +28,11 @@ var BrowserCacheManager = /** @class */ (function (_super) {
28
28
  _this.internalStorage = new MemoryStorage();
29
29
  _this.browserStorage = _this.setupBrowserStorage(_this.cacheConfig.cacheLocation);
30
30
  _this.temporaryCacheStorage = _this.setupTemporaryCacheStorage(_this.cacheConfig.cacheLocation);
31
- // Migrate any cache entries from older versions of MSAL.
32
- _this.migrateCacheEntries();
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
  /**
@@ -102,6 +105,91 @@ var BrowserCacheManager = /** @class */ (function (_super) {
102
105
  this.setTemporaryCache(newKey, value, true);
103
106
  }
104
107
  };
108
+ /**
109
+ * Searches all cache entries for MSAL accounts and creates the account key map
110
+ * This is used to migrate users from older versions of MSAL which did not create the map.
111
+ * @returns
112
+ */
113
+ BrowserCacheManager.prototype.createKeyMaps = function () {
114
+ var _this = this;
115
+ this.logger.trace("BrowserCacheManager - createKeyMaps called.");
116
+ var accountKeys = this.getItem(StaticCacheKeys.ACCOUNT_KEYS);
117
+ var tokenKeys = this.getItem(StaticCacheKeys.TOKEN_KEYS + "." + this.clientId);
118
+ if (accountKeys && tokenKeys) {
119
+ this.logger.verbose("BrowserCacheManager:createKeyMaps - account and token key maps already exist, skipping migration.");
120
+ // Key maps already exist, no need to iterate through cache
121
+ return;
122
+ }
123
+ var allKeys = this.browserStorage.getKeys();
124
+ allKeys.forEach(function (key) {
125
+ if (_this.isCredentialKey(key)) {
126
+ // Get item, parse, validate and write key to map
127
+ var value = _this.getItem(key);
128
+ if (value) {
129
+ var credObj = _this.validateAndParseJson(value);
130
+ if (credObj && credObj.hasOwnProperty("credentialType")) {
131
+ switch (credObj["credentialType"]) {
132
+ case CredentialType.ID_TOKEN:
133
+ if (IdTokenEntity.isIdTokenEntity(credObj)) {
134
+ _this.logger.trace("BrowserCacheManager:createKeyMaps - idToken found, saving key to token key map");
135
+ _this.logger.tracePii("BrowserCacheManager:createKeyMaps - idToken with key: " + key + " found, saving key to token key map");
136
+ var idTokenEntity = CacheManager.toObject(new IdTokenEntity(), credObj);
137
+ var newKey = _this.updateCredentialCacheKey(key, idTokenEntity);
138
+ _this.addTokenKey(newKey, CredentialType.ID_TOKEN);
139
+ return;
140
+ }
141
+ else {
142
+ _this.logger.trace("BrowserCacheManager:createKeyMaps - key found matching idToken schema with value containing idToken credentialType field but value failed IdTokenEntity validation, skipping.");
143
+ _this.logger.tracePii("BrowserCacheManager:createKeyMaps - failed idToken validation on key: " + key);
144
+ }
145
+ break;
146
+ case CredentialType.ACCESS_TOKEN:
147
+ case CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME:
148
+ if (AccessTokenEntity.isAccessTokenEntity(credObj)) {
149
+ _this.logger.trace("BrowserCacheManager:createKeyMaps - accessToken found, saving key to token key map");
150
+ _this.logger.tracePii("BrowserCacheManager:createKeyMaps - accessToken with key: " + key + " found, saving key to token key map");
151
+ var accessTokenEntity = CacheManager.toObject(new AccessTokenEntity(), credObj);
152
+ var newKey = _this.updateCredentialCacheKey(key, accessTokenEntity);
153
+ _this.addTokenKey(newKey, CredentialType.ACCESS_TOKEN);
154
+ return;
155
+ }
156
+ else {
157
+ _this.logger.trace("BrowserCacheManager:createKeyMaps - key found matching accessToken schema with value containing accessToken credentialType field but value failed AccessTokenEntity validation, skipping.");
158
+ _this.logger.tracePii("BrowserCacheManager:createKeyMaps - failed accessToken validation on key: " + key);
159
+ }
160
+ break;
161
+ case CredentialType.REFRESH_TOKEN:
162
+ if (RefreshTokenEntity.isRefreshTokenEntity(credObj)) {
163
+ _this.logger.trace("BrowserCacheManager:createKeyMaps - refreshToken found, saving key to token key map");
164
+ _this.logger.tracePii("BrowserCacheManager:createKeyMaps - refreshToken with key: " + key + " found, saving key to token key map");
165
+ var refreshTokenEntity = CacheManager.toObject(new RefreshTokenEntity(), credObj);
166
+ var newKey = _this.updateCredentialCacheKey(key, refreshTokenEntity);
167
+ _this.addTokenKey(newKey, CredentialType.REFRESH_TOKEN);
168
+ return;
169
+ }
170
+ else {
171
+ _this.logger.trace("BrowserCacheManager:createKeyMaps - key found matching refreshToken schema with value containing refreshToken credentialType field but value failed RefreshTokenEntity validation, skipping.");
172
+ _this.logger.tracePii("BrowserCacheManager:createKeyMaps - failed refreshToken validation on key: " + key);
173
+ }
174
+ break;
175
+ // If credentialType isn't one of our predefined ones, it may not be an MSAL cache value. Ignore.
176
+ }
177
+ }
178
+ }
179
+ }
180
+ if (_this.isAccountKey(key)) {
181
+ var value = _this.getItem(key);
182
+ if (value) {
183
+ var accountObj = _this.validateAndParseJson(value);
184
+ if (accountObj && AccountEntity.isAccountEntity(accountObj)) {
185
+ _this.logger.trace("BrowserCacheManager:createKeyMaps - account found, saving key to account key map");
186
+ _this.logger.tracePii("BrowserCacheManager:createKeyMaps - account with key: " + key + " found, saving key to account key map");
187
+ _this.addAccountKeyToMap(key);
188
+ }
189
+ }
190
+ }
191
+ });
192
+ };
105
193
  /**
106
194
  * Parses passed value as JSON object, JSON.parse() will throw an error.
107
195
  * @param input
@@ -141,12 +229,15 @@ var BrowserCacheManager = /** @class */ (function (_super) {
141
229
  * @param accountKey
142
230
  */
143
231
  BrowserCacheManager.prototype.getAccount = function (accountKey) {
232
+ this.logger.trace("BrowserCacheManager.getAccount called");
144
233
  var account = this.getItem(accountKey);
145
234
  if (!account) {
235
+ this.removeAccountKeyFromMap(accountKey);
146
236
  return null;
147
237
  }
148
238
  var parsedAccount = this.validateAndParseJson(account);
149
239
  if (!parsedAccount || !AccountEntity.isAccountEntity(parsedAccount)) {
240
+ this.removeAccountKeyFromMap(accountKey);
150
241
  return null;
151
242
  }
152
243
  return CacheManager.toObject(new AccountEntity(), parsedAccount);
@@ -160,6 +251,207 @@ var BrowserCacheManager = /** @class */ (function (_super) {
160
251
  this.logger.trace("BrowserCacheManager.setAccount called");
161
252
  var key = account.generateAccountKey();
162
253
  this.setItem(key, JSON.stringify(account));
254
+ this.addAccountKeyToMap(key);
255
+ };
256
+ /**
257
+ * Returns the array of account keys currently cached
258
+ * @returns
259
+ */
260
+ BrowserCacheManager.prototype.getAccountKeys = function () {
261
+ this.logger.trace("BrowserCacheManager.getAccountKeys called");
262
+ var accountKeys = this.getItem(StaticCacheKeys.ACCOUNT_KEYS);
263
+ if (accountKeys) {
264
+ return JSON.parse(accountKeys);
265
+ }
266
+ this.logger.verbose("BrowserCacheManager.getAccountKeys - No account keys found");
267
+ return [];
268
+ };
269
+ /**
270
+ * Add a new account to the key map
271
+ * @param key
272
+ */
273
+ BrowserCacheManager.prototype.addAccountKeyToMap = function (key) {
274
+ this.logger.trace("BrowserCacheManager.addAccountKeyToMap called");
275
+ this.logger.tracePii("BrowserCacheManager.addAccountKeyToMap called with key: " + key);
276
+ var accountKeys = this.getAccountKeys();
277
+ if (accountKeys.indexOf(key) === -1) {
278
+ // Only add key if it does not already exist in the map
279
+ accountKeys.push(key);
280
+ this.setItem(StaticCacheKeys.ACCOUNT_KEYS, JSON.stringify(accountKeys));
281
+ this.logger.verbose("BrowserCacheManager.addAccountKeyToMap account key added");
282
+ }
283
+ else {
284
+ this.logger.verbose("BrowserCacheManager.addAccountKeyToMap account key already exists in map");
285
+ }
286
+ };
287
+ /**
288
+ * Remove an account from the key map
289
+ * @param key
290
+ */
291
+ BrowserCacheManager.prototype.removeAccountKeyFromMap = function (key) {
292
+ this.logger.trace("BrowserCacheManager.removeAccountKeyFromMap called");
293
+ this.logger.tracePii("BrowserCacheManager.removeAccountKeyFromMap called with key: " + key);
294
+ var accountKeys = this.getAccountKeys();
295
+ var removalIndex = accountKeys.indexOf(key);
296
+ if (removalIndex > -1) {
297
+ accountKeys.splice(removalIndex, 1);
298
+ this.setItem(StaticCacheKeys.ACCOUNT_KEYS, JSON.stringify(accountKeys));
299
+ this.logger.trace("BrowserCacheManager.removeAccountKeyFromMap account key removed");
300
+ }
301
+ else {
302
+ this.logger.trace("BrowserCacheManager.removeAccountKeyFromMap key not found in existing map");
303
+ }
304
+ };
305
+ /**
306
+ * Extends inherited removeAccount function to include removal of the account key from the map
307
+ * @param key
308
+ */
309
+ BrowserCacheManager.prototype.removeAccount = function (key) {
310
+ return __awaiter(this, void 0, void 0, function () {
311
+ return __generator(this, function (_a) {
312
+ _super.prototype.removeAccount.call(this, key);
313
+ this.removeAccountKeyFromMap(key);
314
+ return [2 /*return*/];
315
+ });
316
+ });
317
+ };
318
+ /**
319
+ * Removes given idToken from the cache and from the key map
320
+ * @param key
321
+ */
322
+ BrowserCacheManager.prototype.removeIdToken = function (key) {
323
+ _super.prototype.removeIdToken.call(this, key);
324
+ this.removeTokenKey(key, CredentialType.ID_TOKEN);
325
+ };
326
+ /**
327
+ * Removes given accessToken from the cache and from the key map
328
+ * @param key
329
+ */
330
+ BrowserCacheManager.prototype.removeAccessToken = function (key) {
331
+ return __awaiter(this, void 0, void 0, function () {
332
+ return __generator(this, function (_a) {
333
+ _super.prototype.removeAccessToken.call(this, key);
334
+ this.removeTokenKey(key, CredentialType.ACCESS_TOKEN);
335
+ return [2 /*return*/];
336
+ });
337
+ });
338
+ };
339
+ /**
340
+ * Removes given refreshToken from the cache and from the key map
341
+ * @param key
342
+ */
343
+ BrowserCacheManager.prototype.removeRefreshToken = function (key) {
344
+ _super.prototype.removeRefreshToken.call(this, key);
345
+ this.removeTokenKey(key, CredentialType.REFRESH_TOKEN);
346
+ };
347
+ /**
348
+ * Gets the keys for the cached tokens associated with this clientId
349
+ * @returns
350
+ */
351
+ BrowserCacheManager.prototype.getTokenKeys = function () {
352
+ this.logger.trace("BrowserCacheManager.getTokenKeys called");
353
+ var item = this.getItem(StaticCacheKeys.TOKEN_KEYS + "." + this.clientId);
354
+ if (item) {
355
+ var tokenKeys = this.validateAndParseJson(item);
356
+ if (tokenKeys &&
357
+ tokenKeys.hasOwnProperty("idToken") &&
358
+ tokenKeys.hasOwnProperty("accessToken") &&
359
+ tokenKeys.hasOwnProperty("refreshToken")) {
360
+ return tokenKeys;
361
+ }
362
+ else {
363
+ this.logger.error("BrowserCacheManager.getTokenKeys - Token keys found but in an unknown format. Returning empty key map.");
364
+ }
365
+ }
366
+ else {
367
+ this.logger.verbose("BrowserCacheManager.getTokenKeys - No token keys found");
368
+ }
369
+ return {
370
+ idToken: [],
371
+ accessToken: [],
372
+ refreshToken: []
373
+ };
374
+ };
375
+ /**
376
+ * Adds the given key to the token key map
377
+ * @param key
378
+ * @param type
379
+ */
380
+ BrowserCacheManager.prototype.addTokenKey = function (key, type) {
381
+ this.logger.trace("BrowserCacheManager addTokenKey called");
382
+ var tokenKeys = this.getTokenKeys();
383
+ switch (type) {
384
+ case CredentialType.ID_TOKEN:
385
+ if (tokenKeys.idToken.indexOf(key) === -1) {
386
+ this.logger.info("BrowserCacheManager: addTokenKey - idToken added to map");
387
+ tokenKeys.idToken.push(key);
388
+ }
389
+ break;
390
+ case CredentialType.ACCESS_TOKEN:
391
+ if (tokenKeys.accessToken.indexOf(key) === -1) {
392
+ this.logger.info("BrowserCacheManager: addTokenKey - accessToken added to map");
393
+ tokenKeys.accessToken.push(key);
394
+ }
395
+ break;
396
+ case CredentialType.REFRESH_TOKEN:
397
+ if (tokenKeys.refreshToken.indexOf(key) === -1) {
398
+ this.logger.info("BrowserCacheManager: addTokenKey - refreshToken added to map");
399
+ tokenKeys.refreshToken.push(key);
400
+ }
401
+ break;
402
+ default:
403
+ this.logger.error("BrowserCacheManager:addTokenKey - CredentialType provided invalid. CredentialType: " + type);
404
+ ClientAuthError.createUnexpectedCredentialTypeError();
405
+ }
406
+ this.setItem(StaticCacheKeys.TOKEN_KEYS + "." + this.clientId, JSON.stringify(tokenKeys));
407
+ };
408
+ /**
409
+ * Removes the given key from the token key map
410
+ * @param key
411
+ * @param type
412
+ */
413
+ BrowserCacheManager.prototype.removeTokenKey = function (key, type) {
414
+ this.logger.trace("BrowserCacheManager removeTokenKey called");
415
+ var tokenKeys = this.getTokenKeys();
416
+ switch (type) {
417
+ case CredentialType.ID_TOKEN:
418
+ this.logger.infoPii("BrowserCacheManager: removeTokenKey - attempting to remove idToken with key: " + key + " from map");
419
+ var idRemoval = tokenKeys.idToken.indexOf(key);
420
+ if (idRemoval > -1) {
421
+ this.logger.info("BrowserCacheManager: removeTokenKey - idToken removed from map");
422
+ tokenKeys.idToken.splice(idRemoval, 1);
423
+ }
424
+ else {
425
+ this.logger.info("BrowserCacheManager: removeTokenKey - idToken does not exist in map. Either it was previously removed or it was never added.");
426
+ }
427
+ break;
428
+ case CredentialType.ACCESS_TOKEN:
429
+ this.logger.infoPii("BrowserCacheManager: removeTokenKey - attempting to remove accessToken with key: " + key + " from map");
430
+ var accessRemoval = tokenKeys.accessToken.indexOf(key);
431
+ if (accessRemoval > -1) {
432
+ this.logger.info("BrowserCacheManager: removeTokenKey - accessToken removed from map");
433
+ tokenKeys.idToken.splice(accessRemoval, 1);
434
+ }
435
+ else {
436
+ this.logger.info("BrowserCacheManager: removeTokenKey - accessToken does not exist in map. Either it was previously removed or it was never added.");
437
+ }
438
+ break;
439
+ case CredentialType.REFRESH_TOKEN:
440
+ this.logger.infoPii("BrowserCacheManager: removeTokenKey - attempting to remove refreshToken with key: " + key + " from map");
441
+ var refreshRemoval = tokenKeys.refreshToken.indexOf(key);
442
+ if (refreshRemoval > -1) {
443
+ this.logger.info("BrowserCacheManager: removeTokenKey - refreshToken removed from map");
444
+ tokenKeys.idToken.splice(refreshRemoval, 1);
445
+ }
446
+ else {
447
+ this.logger.info("BrowserCacheManager: removeTokenKey - refreshToken does not exist in map. Either it was previously removed or it was never added.");
448
+ }
449
+ break;
450
+ default:
451
+ this.logger.error("BrowserCacheManager:removeTokenKey - CredentialType provided invalid. CredentialType: " + type);
452
+ ClientAuthError.createUnexpectedCredentialTypeError();
453
+ }
454
+ this.setItem(StaticCacheKeys.TOKEN_KEYS + "." + this.clientId, JSON.stringify(tokenKeys));
163
455
  };
164
456
  /**
165
457
  * generates idToken entity from a string
@@ -169,11 +461,13 @@ var BrowserCacheManager = /** @class */ (function (_super) {
169
461
  var value = this.getItem(idTokenKey);
170
462
  if (!value) {
171
463
  this.logger.trace("BrowserCacheManager.getIdTokenCredential: called, no cache hit");
464
+ this.removeTokenKey(idTokenKey, CredentialType.ID_TOKEN);
172
465
  return null;
173
466
  }
174
467
  var parsedIdToken = this.validateAndParseJson(value);
175
468
  if (!parsedIdToken || !IdTokenEntity.isIdTokenEntity(parsedIdToken)) {
176
469
  this.logger.trace("BrowserCacheManager.getIdTokenCredential: called, no cache hit");
470
+ this.removeTokenKey(idTokenKey, CredentialType.ID_TOKEN);
177
471
  return null;
178
472
  }
179
473
  this.logger.trace("BrowserCacheManager.getIdTokenCredential: cache hit");
@@ -187,6 +481,7 @@ var BrowserCacheManager = /** @class */ (function (_super) {
187
481
  this.logger.trace("BrowserCacheManager.setIdTokenCredential called");
188
482
  var idTokenKey = idToken.generateCredentialKey();
189
483
  this.setItem(idTokenKey, JSON.stringify(idToken));
484
+ this.addTokenKey(idTokenKey, CredentialType.ID_TOKEN);
190
485
  };
191
486
  /**
192
487
  * generates accessToken entity from a string
@@ -196,11 +491,13 @@ var BrowserCacheManager = /** @class */ (function (_super) {
196
491
  var value = this.getItem(accessTokenKey);
197
492
  if (!value) {
198
493
  this.logger.trace("BrowserCacheManager.getAccessTokenCredential: called, no cache hit");
494
+ this.removeTokenKey(accessTokenKey, CredentialType.ACCESS_TOKEN);
199
495
  return null;
200
496
  }
201
497
  var parsedAccessToken = this.validateAndParseJson(value);
202
498
  if (!parsedAccessToken || !AccessTokenEntity.isAccessTokenEntity(parsedAccessToken)) {
203
499
  this.logger.trace("BrowserCacheManager.getAccessTokenCredential: called, no cache hit");
500
+ this.removeTokenKey(accessTokenKey, CredentialType.ACCESS_TOKEN);
204
501
  return null;
205
502
  }
206
503
  this.logger.trace("BrowserCacheManager.getAccessTokenCredential: cache hit");
@@ -214,6 +511,7 @@ var BrowserCacheManager = /** @class */ (function (_super) {
214
511
  this.logger.trace("BrowserCacheManager.setAccessTokenCredential called");
215
512
  var accessTokenKey = accessToken.generateCredentialKey();
216
513
  this.setItem(accessTokenKey, JSON.stringify(accessToken));
514
+ this.addTokenKey(accessTokenKey, CredentialType.ACCESS_TOKEN);
217
515
  };
218
516
  /**
219
517
  * generates refreshToken entity from a string
@@ -223,11 +521,13 @@ var BrowserCacheManager = /** @class */ (function (_super) {
223
521
  var value = this.getItem(refreshTokenKey);
224
522
  if (!value) {
225
523
  this.logger.trace("BrowserCacheManager.getRefreshTokenCredential: called, no cache hit");
524
+ this.removeTokenKey(refreshTokenKey, CredentialType.REFRESH_TOKEN);
226
525
  return null;
227
526
  }
228
527
  var parsedRefreshToken = this.validateAndParseJson(value);
229
528
  if (!parsedRefreshToken || !RefreshTokenEntity.isRefreshTokenEntity(parsedRefreshToken)) {
230
529
  this.logger.trace("BrowserCacheManager.getRefreshTokenCredential: called, no cache hit");
530
+ this.removeTokenKey(refreshTokenKey, CredentialType.REFRESH_TOKEN);
231
531
  return null;
232
532
  }
233
533
  this.logger.trace("BrowserCacheManager.getRefreshTokenCredential: cache hit");
@@ -241,6 +541,7 @@ var BrowserCacheManager = /** @class */ (function (_super) {
241
541
  this.logger.trace("BrowserCacheManager.setRefreshTokenCredential called");
242
542
  var refreshTokenKey = refreshToken.generateCredentialKey();
243
543
  this.setItem(refreshTokenKey, JSON.stringify(refreshToken));
544
+ this.addTokenKey(refreshTokenKey, CredentialType.REFRESH_TOKEN);
244
545
  };
245
546
  /**
246
547
  * fetch appMetadata entity from the platform cache
@@ -538,7 +839,6 @@ var BrowserCacheManager = /** @class */ (function (_super) {
538
839
  this.logger.trace("BrowserCacheManager.removeItem: storeAuthStateInCookie is true, clearing item cookie");
539
840
  this.clearItemCookie(key);
540
841
  }
541
- return true;
542
842
  };
543
843
  /**
544
844
  * Checks whether key is in cache.
@@ -966,7 +1266,8 @@ var DEFAULT_BROWSER_CACHE_MANAGER = function (clientId, logger) {
966
1266
  var cacheOptions = {
967
1267
  cacheLocation: BrowserCacheLocation.MemoryStorage,
968
1268
  storeAuthStateInCookie: false,
969
- secureCookies: false
1269
+ secureCookies: false,
1270
+ cacheMigrationEnabled: false
970
1271
  };
971
1272
  return new BrowserCacheManager(clientId, cacheOptions, DEFAULT_CRYPTO_IMPLEMENTATION, logger);
972
1273
  };