@azure/msal-common 4.5.0 → 4.5.1

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 (116) hide show
  1. package/CHANGELOG.json +15 -0
  2. package/LICENSE +21 -21
  3. package/README.md +61 -61
  4. package/changelog.md +398 -390
  5. package/dist/_virtual/_tslib.js +1 -1
  6. package/dist/account/AuthToken.js +7 -7
  7. package/dist/account/AuthToken.js.map +1 -1
  8. package/dist/account/CcsCredential.js +1 -1
  9. package/dist/account/CcsCredential.js.map +1 -1
  10. package/dist/account/ClientInfo.js +10 -10
  11. package/dist/account/ClientInfo.js.map +1 -1
  12. package/dist/authority/Authority.js +53 -53
  13. package/dist/authority/Authority.js.map +1 -1
  14. package/dist/authority/AuthorityFactory.js +9 -9
  15. package/dist/authority/AuthorityFactory.js.map +1 -1
  16. package/dist/authority/AuthorityType.js +1 -1
  17. package/dist/authority/AuthorityType.js.map +1 -1
  18. package/dist/authority/CloudInstanceDiscoveryResponse.js +1 -1
  19. package/dist/authority/CloudInstanceDiscoveryResponse.js.map +1 -1
  20. package/dist/authority/OpenIdConfigResponse.js +1 -1
  21. package/dist/authority/OpenIdConfigResponse.js.map +1 -1
  22. package/dist/authority/ProtocolMode.js +1 -1
  23. package/dist/authority/ProtocolMode.js.map +1 -1
  24. package/dist/authority/RegionDiscovery.js +9 -9
  25. package/dist/authority/RegionDiscovery.js.map +1 -1
  26. package/dist/cache/CacheManager.js +47 -47
  27. package/dist/cache/CacheManager.js.map +1 -1
  28. package/dist/cache/entities/AccessTokenEntity.js +11 -11
  29. package/dist/cache/entities/AccessTokenEntity.js.map +1 -1
  30. package/dist/cache/entities/AccountEntity.js +14 -14
  31. package/dist/cache/entities/AccountEntity.js.map +1 -1
  32. package/dist/cache/entities/AppMetadataEntity.js +1 -1
  33. package/dist/cache/entities/AppMetadataEntity.js.map +1 -1
  34. package/dist/cache/entities/AuthorityMetadataEntity.js +5 -5
  35. package/dist/cache/entities/AuthorityMetadataEntity.js.map +1 -1
  36. package/dist/cache/entities/CacheRecord.js +1 -1
  37. package/dist/cache/entities/CacheRecord.js.map +1 -1
  38. package/dist/cache/entities/CredentialEntity.js +5 -5
  39. package/dist/cache/entities/CredentialEntity.js.map +1 -1
  40. package/dist/cache/entities/IdTokenEntity.js +3 -3
  41. package/dist/cache/entities/IdTokenEntity.js.map +1 -1
  42. package/dist/cache/entities/RefreshTokenEntity.js +3 -3
  43. package/dist/cache/entities/RefreshTokenEntity.js.map +1 -1
  44. package/dist/cache/entities/ServerTelemetryEntity.js +1 -1
  45. package/dist/cache/entities/ServerTelemetryEntity.js.map +1 -1
  46. package/dist/cache/entities/ThrottlingEntity.js +1 -1
  47. package/dist/cache/entities/ThrottlingEntity.js.map +1 -1
  48. package/dist/cache/persistence/TokenCacheContext.js +3 -3
  49. package/dist/cache/persistence/TokenCacheContext.js.map +1 -1
  50. package/dist/client/AuthorizationCodeClient.js +32 -32
  51. package/dist/client/AuthorizationCodeClient.js.map +1 -1
  52. package/dist/client/BaseClient.js +11 -11
  53. package/dist/client/BaseClient.js.map +1 -1
  54. package/dist/client/ClientCredentialClient.js +17 -17
  55. package/dist/client/ClientCredentialClient.js.map +1 -1
  56. package/dist/client/DeviceCodeClient.js +25 -25
  57. package/dist/client/DeviceCodeClient.js.map +1 -1
  58. package/dist/client/OnBehalfOfClient.js +19 -19
  59. package/dist/client/OnBehalfOfClient.js.map +1 -1
  60. package/dist/client/RefreshTokenClient.js +25 -25
  61. package/dist/client/RefreshTokenClient.js.map +1 -1
  62. package/dist/client/SilentFlowClient.js +27 -27
  63. package/dist/client/SilentFlowClient.js.map +1 -1
  64. package/dist/client/UsernamePasswordClient.js +11 -11
  65. package/dist/client/UsernamePasswordClient.js.map +1 -1
  66. package/dist/config/ClientConfiguration.js +6 -6
  67. package/dist/config/ClientConfiguration.js.map +1 -1
  68. package/dist/crypto/ICrypto.js +8 -8
  69. package/dist/crypto/ICrypto.js.map +1 -1
  70. package/dist/crypto/PopTokenGenerator.js +9 -9
  71. package/dist/crypto/PopTokenGenerator.js.map +1 -1
  72. package/dist/error/AuthError.js +3 -3
  73. package/dist/error/AuthError.js.map +1 -1
  74. package/dist/error/ClientAuthError.js +3 -3
  75. package/dist/error/ClientAuthError.js.map +1 -1
  76. package/dist/error/ClientConfigurationError.js +3 -3
  77. package/dist/error/ClientConfigurationError.js.map +1 -1
  78. package/dist/error/InteractionRequiredAuthError.js +3 -3
  79. package/dist/error/InteractionRequiredAuthError.js.map +1 -1
  80. package/dist/error/ServerError.js +3 -3
  81. package/dist/error/ServerError.js.map +1 -1
  82. package/dist/index.cjs.js +70 -29
  83. package/dist/index.cjs.js.map +1 -1
  84. package/dist/index.js +29 -29
  85. package/dist/logger/Logger.js +7 -7
  86. package/dist/logger/Logger.js.map +1 -1
  87. package/dist/network/INetworkModule.js +4 -4
  88. package/dist/network/INetworkModule.js.map +1 -1
  89. package/dist/network/NetworkManager.js +8 -8
  90. package/dist/network/NetworkManager.js.map +1 -1
  91. package/dist/network/ThrottlingUtils.js +4 -4
  92. package/dist/network/ThrottlingUtils.js.map +1 -1
  93. package/dist/packageMetadata.d.ts +1 -1
  94. package/dist/packageMetadata.js +2 -2
  95. package/dist/packageMetadata.js.map +1 -1
  96. package/dist/request/RequestParameterBuilder.js +18 -18
  97. package/dist/request/RequestParameterBuilder.js.map +1 -1
  98. package/dist/request/RequestValidator.js +10 -10
  99. package/dist/request/RequestValidator.js.map +1 -1
  100. package/dist/request/ScopeSet.js +14 -14
  101. package/dist/request/ScopeSet.js.map +1 -1
  102. package/dist/response/ResponseHandler.js +61 -61
  103. package/dist/response/ResponseHandler.js.map +1 -1
  104. package/dist/telemetry/server/ServerTelemetryManager.js +13 -13
  105. package/dist/telemetry/server/ServerTelemetryManager.js.map +1 -1
  106. package/dist/url/UrlString.js +24 -24
  107. package/dist/url/UrlString.js.map +1 -1
  108. package/dist/utils/Constants.js +1 -1
  109. package/dist/utils/Constants.js.map +1 -1
  110. package/dist/utils/ProtocolUtils.js +13 -13
  111. package/dist/utils/ProtocolUtils.js.map +1 -1
  112. package/dist/utils/StringUtils.js +5 -5
  113. package/dist/utils/StringUtils.js.map +1 -1
  114. package/dist/utils/TimeUtils.js +1 -1
  115. package/dist/utils/TimeUtils.js.map +1 -1
  116. package/package.json +1 -1
@@ -1,13 +1,13 @@
1
- /*! @azure/msal-common v4.5.0 2021-07-22 */
1
+ /*! @azure/msal-common v4.5.1 2021-08-02 */
2
2
  'use strict';
3
3
  import { __extends } from '../_virtual/_tslib.js';
4
- import { Constants as Constants$1, CredentialType, CacheSchemaType, THE_FAMILY_ID, APP_METADATA, AUTHORITY_METADATA_CONSTANTS, AuthenticationScheme } from '../utils/Constants.js';
5
- import { AuthError as AuthError$1 } from '../error/AuthError.js';
6
- import { ClientAuthError as ClientAuthError$1 } from '../error/ClientAuthError.js';
7
- import { CredentialEntity as CredentialEntity$1 } from './entities/CredentialEntity.js';
8
- import { ScopeSet as ScopeSet$1 } from '../request/ScopeSet.js';
9
- import { AccountEntity as AccountEntity$1 } from './entities/AccountEntity.js';
10
- import { AuthToken as AuthToken$1 } from '../account/AuthToken.js';
4
+ import { Constants, CredentialType, CacheSchemaType, THE_FAMILY_ID, APP_METADATA, AUTHORITY_METADATA_CONSTANTS, AuthenticationScheme } from '../utils/Constants.js';
5
+ import { CredentialEntity } from './entities/CredentialEntity.js';
6
+ import { ScopeSet } from '../request/ScopeSet.js';
7
+ import { AccountEntity } from './entities/AccountEntity.js';
8
+ import { AuthError } from '../error/AuthError.js';
9
+ import { ClientAuthError } from '../error/ClientAuthError.js';
10
+ import { AuthToken } from '../account/AuthToken.js';
11
11
 
12
12
  /*
13
13
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -34,11 +34,11 @@ var CacheManager = /** @class */ (function () {
34
34
  }
35
35
  else {
36
36
  var allAccounts = accountValues.map(function (value) {
37
- var accountEntity = CacheManager.toObject(new AccountEntity$1(), value);
37
+ var accountEntity = CacheManager.toObject(new AccountEntity(), value);
38
38
  var accountInfo = accountEntity.getAccountInfo();
39
39
  var idToken = _this.readIdTokenFromCache(_this.clientId, accountInfo);
40
40
  if (idToken && !accountInfo.idTokenClaims) {
41
- accountInfo.idTokenClaims = new AuthToken$1(idToken.secret, _this.cryptoImpl).claims;
41
+ accountInfo.idTokenClaims = new AuthToken(idToken.secret, _this.cryptoImpl).claims;
42
42
  }
43
43
  return accountInfo;
44
44
  });
@@ -51,7 +51,7 @@ var CacheManager = /** @class */ (function () {
51
51
  */
52
52
  CacheManager.prototype.saveCacheRecord = function (cacheRecord) {
53
53
  if (!cacheRecord) {
54
- throw ClientAuthError$1.createNullOrUndefinedCacheRecord();
54
+ throw ClientAuthError.createNullOrUndefinedCacheRecord();
55
55
  }
56
56
  if (!!cacheRecord.account) {
57
57
  this.setAccount(cacheRecord.account);
@@ -82,11 +82,11 @@ var CacheManager = /** @class */ (function () {
82
82
  homeAccountId: credential.homeAccountId,
83
83
  realm: credential.realm,
84
84
  });
85
- var currentScopes = ScopeSet$1.fromString(credential.target);
85
+ var currentScopes = ScopeSet.fromString(credential.target);
86
86
  var currentAccessTokens = Object.keys(currentTokenCache.accessTokens).map(function (key) { return currentTokenCache.accessTokens[key]; });
87
87
  if (currentAccessTokens) {
88
88
  currentAccessTokens.forEach(function (tokenEntity) {
89
- var tokenScopeSet = ScopeSet$1.fromString(tokenEntity.target);
89
+ var tokenScopeSet = ScopeSet.fromString(tokenEntity.target);
90
90
  if (tokenScopeSet.intersectingScopeSets(currentScopes)) {
91
91
  _this.removeCredential(tokenEntity);
92
92
  }
@@ -164,8 +164,8 @@ var CacheManager = /** @class */ (function () {
164
164
  };
165
165
  allCacheKeys.forEach(function (cacheKey) {
166
166
  // don't parse any non-credential type cache entities
167
- var credType = CredentialEntity$1.getCredentialType(cacheKey);
168
- if (credType === Constants$1.NOT_DEFINED) {
167
+ var credType = CredentialEntity.getCredentialType(cacheKey);
168
+ if (credType === Constants.NOT_DEFINED) {
169
169
  return;
170
170
  }
171
171
  // Attempt retrieval
@@ -299,7 +299,7 @@ var CacheManager = /** @class */ (function () {
299
299
  CacheManager.prototype.removeAccount = function (accountKey) {
300
300
  var account = this.getAccount(accountKey);
301
301
  if (!account) {
302
- throw ClientAuthError$1.createNoAccountFoundError();
302
+ throw ClientAuthError.createNoAccountFoundError();
303
303
  }
304
304
  return (this.removeAccountContext(account) && this.removeItem(accountKey, CacheSchemaType.ACCOUNT));
305
305
  };
@@ -313,8 +313,8 @@ var CacheManager = /** @class */ (function () {
313
313
  var accountId = account.generateAccountId();
314
314
  allCacheKeys.forEach(function (cacheKey) {
315
315
  // don't parse any non-credential type cache entities
316
- var credType = CredentialEntity$1.getCredentialType(cacheKey);
317
- if (credType === Constants$1.NOT_DEFINED) {
316
+ var credType = CredentialEntity.getCredentialType(cacheKey);
317
+ if (credType === Constants.NOT_DEFINED) {
318
318
  return;
319
319
  }
320
320
  var cacheEntity = _this.getSpecificCredential(cacheKey, credType);
@@ -360,7 +360,7 @@ var CacheManager = /** @class */ (function () {
360
360
  var cachedRefreshToken = this.readRefreshTokenFromCache(clientId, account, false);
361
361
  var cachedAppMetadata = this.readAppMetadataFromCache(environment, clientId);
362
362
  if (cachedAccount && cachedIdToken) {
363
- cachedAccount.idTokenClaims = new AuthToken$1(cachedIdToken.secret, this.cryptoImpl).claims;
363
+ cachedAccount.idTokenClaims = new AuthToken(cachedIdToken.secret, this.cryptoImpl).claims;
364
364
  }
365
365
  return {
366
366
  account: cachedAccount,
@@ -375,7 +375,7 @@ var CacheManager = /** @class */ (function () {
375
375
  * @param account
376
376
  */
377
377
  CacheManager.prototype.readAccountFromCache = function (account) {
378
- var accountKey = AccountEntity$1.generateAccountCacheKey(account);
378
+ var accountKey = AccountEntity.generateAccountCacheKey(account);
379
379
  return this.getAccount(accountKey);
380
380
  };
381
381
  /**
@@ -399,7 +399,7 @@ var CacheManager = /** @class */ (function () {
399
399
  return null;
400
400
  }
401
401
  else if (numIdTokens > 1) {
402
- throw ClientAuthError$1.createMultipleMatchingTokensInCacheError();
402
+ throw ClientAuthError.createMultipleMatchingTokensInCacheError();
403
403
  }
404
404
  return idTokens[0];
405
405
  };
@@ -427,7 +427,7 @@ var CacheManager = /** @class */ (function () {
427
427
  return null;
428
428
  }
429
429
  else if (numAccessTokens > 1) {
430
- throw ClientAuthError$1.createMultipleMatchingTokensInCacheError();
430
+ throw ClientAuthError.createMultipleMatchingTokensInCacheError();
431
431
  }
432
432
  return accessTokens[0];
433
433
  };
@@ -470,7 +470,7 @@ var CacheManager = /** @class */ (function () {
470
470
  return null;
471
471
  }
472
472
  else if (numAppMetadata > 1) {
473
- throw ClientAuthError$1.createMultipleMatchingAppMetadataInCacheError();
473
+ throw ClientAuthError.createMultipleMatchingAppMetadataInCacheError();
474
474
  }
475
475
  return appMetadataEntries[0];
476
476
  };
@@ -553,13 +553,13 @@ var CacheManager = /** @class */ (function () {
553
553
  if (isNotAccessTokenCredential || !entity.target) {
554
554
  return false;
555
555
  }
556
- var entityScopeSet = ScopeSet$1.fromString(entity.target);
557
- var requestTargetScopeSet = ScopeSet$1.fromString(target);
556
+ var entityScopeSet = ScopeSet.fromString(entity.target);
557
+ var requestTargetScopeSet = ScopeSet.fromString(target);
558
558
  if (!requestTargetScopeSet.containsOnlyOIDCScopes()) {
559
559
  requestTargetScopeSet.removeOIDCScopes(); // ignore OIDC scopes
560
560
  }
561
561
  else {
562
- requestTargetScopeSet.removeScope(Constants$1.OFFLINE_ACCESS_SCOPE);
562
+ requestTargetScopeSet.removeScope(Constants.OFFLINE_ACCESS_SCOPE);
563
563
  }
564
564
  return entityScopeSet.containsScopeSet(requestTargetScopeSet);
565
565
  };
@@ -624,87 +624,87 @@ var DefaultStorageClass = /** @class */ (function (_super) {
624
624
  }
625
625
  DefaultStorageClass.prototype.setAccount = function () {
626
626
  var notImplErr = "Storage interface - setAccount() has not been implemented for the cacheStorage interface.";
627
- throw AuthError$1.createUnexpectedError(notImplErr);
627
+ throw AuthError.createUnexpectedError(notImplErr);
628
628
  };
629
629
  DefaultStorageClass.prototype.getAccount = function () {
630
630
  var notImplErr = "Storage interface - getAccount() has not been implemented for the cacheStorage interface.";
631
- throw AuthError$1.createUnexpectedError(notImplErr);
631
+ throw AuthError.createUnexpectedError(notImplErr);
632
632
  };
633
633
  DefaultStorageClass.prototype.setIdTokenCredential = function () {
634
634
  var notImplErr = "Storage interface - setIdTokenCredential() has not been implemented for the cacheStorage interface.";
635
- throw AuthError$1.createUnexpectedError(notImplErr);
635
+ throw AuthError.createUnexpectedError(notImplErr);
636
636
  };
637
637
  DefaultStorageClass.prototype.getIdTokenCredential = function () {
638
638
  var notImplErr = "Storage interface - getIdTokenCredential() has not been implemented for the cacheStorage interface.";
639
- throw AuthError$1.createUnexpectedError(notImplErr);
639
+ throw AuthError.createUnexpectedError(notImplErr);
640
640
  };
641
641
  DefaultStorageClass.prototype.setAccessTokenCredential = function () {
642
642
  var notImplErr = "Storage interface - setAccessTokenCredential() has not been implemented for the cacheStorage interface.";
643
- throw AuthError$1.createUnexpectedError(notImplErr);
643
+ throw AuthError.createUnexpectedError(notImplErr);
644
644
  };
645
645
  DefaultStorageClass.prototype.getAccessTokenCredential = function () {
646
646
  var notImplErr = "Storage interface - getAccessTokenCredential() has not been implemented for the cacheStorage interface.";
647
- throw AuthError$1.createUnexpectedError(notImplErr);
647
+ throw AuthError.createUnexpectedError(notImplErr);
648
648
  };
649
649
  DefaultStorageClass.prototype.setRefreshTokenCredential = function () {
650
650
  var notImplErr = "Storage interface - setRefreshTokenCredential() has not been implemented for the cacheStorage interface.";
651
- throw AuthError$1.createUnexpectedError(notImplErr);
651
+ throw AuthError.createUnexpectedError(notImplErr);
652
652
  };
653
653
  DefaultStorageClass.prototype.getRefreshTokenCredential = function () {
654
654
  var notImplErr = "Storage interface - getRefreshTokenCredential() has not been implemented for the cacheStorage interface.";
655
- throw AuthError$1.createUnexpectedError(notImplErr);
655
+ throw AuthError.createUnexpectedError(notImplErr);
656
656
  };
657
657
  DefaultStorageClass.prototype.setAppMetadata = function () {
658
658
  var notImplErr = "Storage interface - setAppMetadata() has not been implemented for the cacheStorage interface.";
659
- throw AuthError$1.createUnexpectedError(notImplErr);
659
+ throw AuthError.createUnexpectedError(notImplErr);
660
660
  };
661
661
  DefaultStorageClass.prototype.getAppMetadata = function () {
662
662
  var notImplErr = "Storage interface - getAppMetadata() has not been implemented for the cacheStorage interface.";
663
- throw AuthError$1.createUnexpectedError(notImplErr);
663
+ throw AuthError.createUnexpectedError(notImplErr);
664
664
  };
665
665
  DefaultStorageClass.prototype.setServerTelemetry = function () {
666
666
  var notImplErr = "Storage interface - setServerTelemetry() has not been implemented for the cacheStorage interface.";
667
- throw AuthError$1.createUnexpectedError(notImplErr);
667
+ throw AuthError.createUnexpectedError(notImplErr);
668
668
  };
669
669
  DefaultStorageClass.prototype.getServerTelemetry = function () {
670
670
  var notImplErr = "Storage interface - getServerTelemetry() has not been implemented for the cacheStorage interface.";
671
- throw AuthError$1.createUnexpectedError(notImplErr);
671
+ throw AuthError.createUnexpectedError(notImplErr);
672
672
  };
673
673
  DefaultStorageClass.prototype.setAuthorityMetadata = function () {
674
674
  var notImplErr = "Storage interface - setAuthorityMetadata() has not been implemented for the cacheStorage interface.";
675
- throw AuthError$1.createUnexpectedError(notImplErr);
675
+ throw AuthError.createUnexpectedError(notImplErr);
676
676
  };
677
677
  DefaultStorageClass.prototype.getAuthorityMetadata = function () {
678
678
  var notImplErr = "Storage interface - getAuthorityMetadata() has not been implemented for the cacheStorage interface.";
679
- throw AuthError$1.createUnexpectedError(notImplErr);
679
+ throw AuthError.createUnexpectedError(notImplErr);
680
680
  };
681
681
  DefaultStorageClass.prototype.getAuthorityMetadataKeys = function () {
682
682
  var notImplErr = "Storage interface - getAuthorityMetadataKeys() has not been implemented for the cacheStorage interface.";
683
- throw AuthError$1.createUnexpectedError(notImplErr);
683
+ throw AuthError.createUnexpectedError(notImplErr);
684
684
  };
685
685
  DefaultStorageClass.prototype.setThrottlingCache = function () {
686
686
  var notImplErr = "Storage interface - setThrottlingCache() has not been implemented for the cacheStorage interface.";
687
- throw AuthError$1.createUnexpectedError(notImplErr);
687
+ throw AuthError.createUnexpectedError(notImplErr);
688
688
  };
689
689
  DefaultStorageClass.prototype.getThrottlingCache = function () {
690
690
  var notImplErr = "Storage interface - getThrottlingCache() has not been implemented for the cacheStorage interface.";
691
- throw AuthError$1.createUnexpectedError(notImplErr);
691
+ throw AuthError.createUnexpectedError(notImplErr);
692
692
  };
693
693
  DefaultStorageClass.prototype.removeItem = function () {
694
694
  var notImplErr = "Storage interface - removeItem() has not been implemented for the cacheStorage interface.";
695
- throw AuthError$1.createUnexpectedError(notImplErr);
695
+ throw AuthError.createUnexpectedError(notImplErr);
696
696
  };
697
697
  DefaultStorageClass.prototype.containsKey = function () {
698
698
  var notImplErr = "Storage interface - containsKey() has not been implemented for the cacheStorage interface.";
699
- throw AuthError$1.createUnexpectedError(notImplErr);
699
+ throw AuthError.createUnexpectedError(notImplErr);
700
700
  };
701
701
  DefaultStorageClass.prototype.getKeys = function () {
702
702
  var notImplErr = "Storage interface - getKeys() has not been implemented for the cacheStorage interface.";
703
- throw AuthError$1.createUnexpectedError(notImplErr);
703
+ throw AuthError.createUnexpectedError(notImplErr);
704
704
  };
705
705
  DefaultStorageClass.prototype.clear = function () {
706
706
  var notImplErr = "Storage interface - clear() has not been implemented for the cacheStorage interface.";
707
- throw AuthError$1.createUnexpectedError(notImplErr);
707
+ throw AuthError.createUnexpectedError(notImplErr);
708
708
  };
709
709
  return DefaultStorageClass;
710
710
  }(CacheManager));
@@ -1 +1 @@
1
- {"version":3,"file":"CacheManager.js","sources":["../../src/cache/CacheManager.ts"],"sourcesContent":["/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport { AccountCache, AccountFilter, CredentialFilter, CredentialCache, ValidCredentialType, AppMetadataFilter, AppMetadataCache } from \"./utils/CacheTypes\";\r\nimport { CacheRecord } from \"./entities/CacheRecord\";\r\nimport { CacheSchemaType, CredentialType, Constants, APP_METADATA, THE_FAMILY_ID, AUTHORITY_METADATA_CONSTANTS, AuthenticationScheme } from \"../utils/Constants\";\r\nimport { CredentialEntity } from \"./entities/CredentialEntity\";\r\nimport { ScopeSet } from \"../request/ScopeSet\";\r\nimport { AccountEntity } from \"./entities/AccountEntity\";\r\nimport { AccessTokenEntity } from \"./entities/AccessTokenEntity\";\r\nimport { IdTokenEntity } from \"./entities/IdTokenEntity\";\r\nimport { RefreshTokenEntity } from \"./entities/RefreshTokenEntity\";\r\nimport { AuthError } from \"../error/AuthError\";\r\nimport { ICacheManager } from \"./interface/ICacheManager\";\r\nimport { ClientAuthError } from \"../error/ClientAuthError\";\r\nimport { AccountInfo } from \"../account/AccountInfo\";\r\nimport { AppMetadataEntity } from \"./entities/AppMetadataEntity\";\r\nimport { ServerTelemetryEntity } from \"./entities/ServerTelemetryEntity\";\r\nimport { ThrottlingEntity } from \"./entities/ThrottlingEntity\";\r\nimport { AuthToken } from \"../account/AuthToken\";\r\nimport { ICrypto } from \"../crypto/ICrypto\";\r\nimport { AuthorityMetadataEntity } from \"./entities/AuthorityMetadataEntity\";\r\n\r\n/**\r\n * Interface class which implement cache storage functions used by MSAL to perform validity checks, and store tokens.\r\n */\r\nexport abstract class CacheManager implements ICacheManager {\r\n protected clientId: string;\r\n protected cryptoImpl: ICrypto;\r\n\r\n constructor(clientId: string, cryptoImpl: ICrypto) {\r\n this.clientId = clientId;\r\n this.cryptoImpl = cryptoImpl;\r\n }\r\n\r\n /**\r\n * fetch the account entity from the platform cache\r\n * @param accountKey\r\n */\r\n abstract getAccount(accountKey: string): AccountEntity | null;\r\n\r\n /**\r\n * set account entity in the platform cache\r\n * @param account\r\n */\r\n abstract setAccount(account: AccountEntity): void;\r\n\r\n /**\r\n * fetch the idToken entity from the platform cache\r\n * @param idTokenKey\r\n */\r\n abstract getIdTokenCredential(idTokenKey: string): IdTokenEntity | null;\r\n\r\n /**\r\n * set idToken entity to the platform cache\r\n * @param idToken\r\n */\r\n abstract setIdTokenCredential(idToken: IdTokenEntity): void;\r\n\r\n /**\r\n * fetch the idToken entity from the platform cache\r\n * @param accessTokenKey\r\n */\r\n abstract getAccessTokenCredential(accessTokenKey: string): AccessTokenEntity | null;\r\n\r\n /**\r\n * set idToken entity to the platform cache\r\n * @param accessToken\r\n */\r\n abstract setAccessTokenCredential(accessToken: AccessTokenEntity): void;\r\n\r\n /**\r\n * fetch the idToken entity from the platform cache\r\n * @param refreshTokenKey\r\n */\r\n abstract getRefreshTokenCredential(refreshTokenKey: string): RefreshTokenEntity | null;\r\n\r\n /**\r\n * set idToken entity to the platform cache\r\n * @param refreshToken\r\n */\r\n abstract setRefreshTokenCredential(refreshToken: RefreshTokenEntity): void;\r\n\r\n /**\r\n * fetch appMetadata entity from the platform cache\r\n * @param appMetadataKey\r\n */\r\n abstract getAppMetadata(appMetadataKey: string): AppMetadataEntity | null;\r\n\r\n /**\r\n * set appMetadata entity to the platform cache\r\n * @param appMetadata\r\n */\r\n abstract setAppMetadata(appMetadata: AppMetadataEntity): void;\r\n\r\n /**\r\n * fetch server telemetry entity from the platform cache\r\n * @param serverTelemetryKey\r\n */\r\n abstract getServerTelemetry(serverTelemetryKey: string): ServerTelemetryEntity | null;\r\n\r\n /**\r\n * set server telemetry entity to the platform cache\r\n * @param serverTelemetryKey\r\n * @param serverTelemetry\r\n */\r\n abstract setServerTelemetry(serverTelemetryKey: string, serverTelemetry: ServerTelemetryEntity): void;\r\n\r\n /**\r\n * fetch cloud discovery metadata entity from the platform cache\r\n * @param key\r\n */\r\n abstract getAuthorityMetadata(key: string): AuthorityMetadataEntity | null;\r\n\r\n /**\r\n * \r\n */\r\n abstract getAuthorityMetadataKeys(): Array<string>;\r\n\r\n /**\r\n * set cloud discovery metadata entity to the platform cache\r\n * @param key\r\n * @param value\r\n */\r\n abstract setAuthorityMetadata(key: string, value: AuthorityMetadataEntity): void;\r\n\r\n /**\r\n * fetch throttling entity from the platform cache\r\n * @param throttlingCacheKey\r\n */\r\n abstract getThrottlingCache(throttlingCacheKey: string): ThrottlingEntity | null;\r\n\r\n /**\r\n * set throttling entity to the platform cache\r\n * @param throttlingCacheKey\r\n * @param throttlingCache\r\n */\r\n abstract setThrottlingCache(throttlingCacheKey: string, throttlingCache: ThrottlingEntity): void;;\r\n\r\n /**\r\n * Function to remove an item from cache given its key.\r\n * @param key\r\n */\r\n abstract removeItem(key: string, type?: string): boolean;\r\n\r\n /**\r\n * Function which returns boolean whether cache contains a specific key.\r\n * @param key\r\n */\r\n abstract containsKey(key: string, type?: string): boolean;\r\n\r\n /**\r\n * Function which retrieves all current keys from the cache.\r\n */\r\n abstract getKeys(): string[];\r\n\r\n /**\r\n * Function which clears cache.\r\n */\r\n abstract clear(): void;\r\n\r\n /**\r\n * Returns all accounts in cache\r\n */\r\n getAllAccounts(): AccountInfo[] {\r\n const currentAccounts: AccountCache = this.getAccountsFilteredBy();\r\n const accountValues: AccountEntity[] = Object.keys(currentAccounts).map(accountKey => currentAccounts[accountKey]);\r\n const numAccounts = accountValues.length;\r\n if (numAccounts < 1) {\r\n return [];\r\n } else {\r\n const allAccounts = accountValues.map<AccountInfo>((value) => {\r\n const accountEntity = CacheManager.toObject<AccountEntity>(new AccountEntity(), value);\r\n const accountInfo = accountEntity.getAccountInfo();\r\n const idToken = this.readIdTokenFromCache(this.clientId, accountInfo);\r\n if (idToken && !accountInfo.idTokenClaims) {\r\n accountInfo.idTokenClaims = new AuthToken(idToken.secret, this.cryptoImpl).claims;\r\n }\r\n\r\n return accountInfo;\r\n \r\n });\r\n return allAccounts;\r\n }\r\n }\r\n\r\n /**\r\n * saves a cache record\r\n * @param cacheRecord\r\n */\r\n saveCacheRecord(cacheRecord: CacheRecord): void {\r\n if (!cacheRecord) {\r\n throw ClientAuthError.createNullOrUndefinedCacheRecord();\r\n }\r\n\r\n if (!!cacheRecord.account) {\r\n this.setAccount(cacheRecord.account);\r\n }\r\n\r\n if (!!cacheRecord.idToken) {\r\n this.setIdTokenCredential(cacheRecord.idToken);\r\n }\r\n\r\n if (!!cacheRecord.accessToken) {\r\n this.saveAccessToken(cacheRecord.accessToken);\r\n }\r\n\r\n if (!!cacheRecord.refreshToken) {\r\n this.setRefreshTokenCredential(cacheRecord.refreshToken);\r\n }\r\n\r\n if (!!cacheRecord.appMetadata) {\r\n this.setAppMetadata(cacheRecord.appMetadata);\r\n }\r\n }\r\n\r\n /**\r\n * saves access token credential\r\n * @param credential\r\n */\r\n private saveAccessToken(credential: AccessTokenEntity): void {\r\n const currentTokenCache = this.getCredentialsFilteredBy({\r\n clientId: credential.clientId,\r\n credentialType: credential.credentialType,\r\n environment: credential.environment,\r\n homeAccountId: credential.homeAccountId,\r\n realm: credential.realm,\r\n });\r\n const currentScopes = ScopeSet.fromString(credential.target);\r\n const currentAccessTokens: AccessTokenEntity[] = Object.keys(currentTokenCache.accessTokens).map(key => currentTokenCache.accessTokens[key]);\r\n if (currentAccessTokens) {\r\n currentAccessTokens.forEach((tokenEntity) => {\r\n const tokenScopeSet = ScopeSet.fromString(tokenEntity.target);\r\n if (tokenScopeSet.intersectingScopeSets(currentScopes)) {\r\n this.removeCredential(tokenEntity);\r\n }\r\n });\r\n }\r\n this.setAccessTokenCredential(credential);\r\n }\r\n\r\n /**\r\n * retrieve accounts matching all provided filters; if no filter is set, get all accounts\r\n * not checking for casing as keys are all generated in lower case, remember to convert to lower case if object properties are compared\r\n * @param homeAccountId\r\n * @param environment\r\n * @param realm\r\n */\r\n getAccountsFilteredBy(accountFilter?: AccountFilter): AccountCache {\r\n return this.getAccountsFilteredByInternal(\r\n accountFilter ? accountFilter.homeAccountId : \"\",\r\n accountFilter ? accountFilter.environment : \"\",\r\n accountFilter ? accountFilter.realm : \"\"\r\n );\r\n }\r\n\r\n /**\r\n * retrieve accounts matching all provided filters; if no filter is set, get all accounts\r\n * not checking for casing as keys are all generated in lower case, remember to convert to lower case if object properties are compared\r\n * @param homeAccountId\r\n * @param environment\r\n * @param realm\r\n */\r\n private getAccountsFilteredByInternal(\r\n homeAccountId?: string,\r\n environment?: string,\r\n realm?: string\r\n ): AccountCache {\r\n const allCacheKeys = this.getKeys();\r\n const matchingAccounts: AccountCache = {};\r\n\r\n allCacheKeys.forEach((cacheKey) => {\r\n const entity: AccountEntity | null = this.getAccount(cacheKey);\r\n\r\n if (!entity) {\r\n return;\r\n }\r\n\r\n if (!!homeAccountId && !this.matchHomeAccountId(entity, homeAccountId)) {\r\n return;\r\n }\r\n\r\n if (!!environment && !this.matchEnvironment(entity, environment)) {\r\n return;\r\n }\r\n\r\n if (!!realm && !this.matchRealm(entity, realm)) {\r\n return;\r\n }\r\n\r\n matchingAccounts[cacheKey] = entity;\r\n });\r\n\r\n return matchingAccounts;\r\n }\r\n\r\n /**\r\n * retrieve credentails matching all provided filters; if no filter is set, get all credentials\r\n * @param homeAccountId\r\n * @param environment\r\n * @param credentialType\r\n * @param clientId\r\n * @param realm\r\n * @param target\r\n */\r\n getCredentialsFilteredBy(filter: CredentialFilter): CredentialCache {\r\n return this.getCredentialsFilteredByInternal(\r\n filter.homeAccountId,\r\n filter.environment,\r\n filter.credentialType,\r\n filter.clientId,\r\n filter.familyId,\r\n filter.realm,\r\n filter.target,\r\n filter.oboAssertion\r\n );\r\n }\r\n\r\n /**\r\n * Support function to help match credentials\r\n * @param homeAccountId\r\n * @param environment\r\n * @param credentialType\r\n * @param clientId\r\n * @param realm\r\n * @param target\r\n */\r\n private getCredentialsFilteredByInternal(\r\n homeAccountId?: string,\r\n environment?: string,\r\n credentialType?: string,\r\n clientId?: string,\r\n familyId?: string,\r\n realm?: string,\r\n target?: string,\r\n oboAssertion?: string\r\n ): CredentialCache {\r\n const allCacheKeys = this.getKeys();\r\n const matchingCredentials: CredentialCache = {\r\n idTokens: {},\r\n accessTokens: {},\r\n refreshTokens: {},\r\n };\r\n \r\n allCacheKeys.forEach((cacheKey) => {\r\n // don't parse any non-credential type cache entities\r\n const credType = CredentialEntity.getCredentialType(cacheKey);\r\n\r\n if (credType === Constants.NOT_DEFINED) {\r\n return;\r\n }\r\n\r\n // Attempt retrieval\r\n const entity = this.getSpecificCredential(cacheKey, credType);\r\n\r\n if (!entity) {\r\n return;\r\n }\r\n\r\n if (!!oboAssertion && !this.matchOboAssertion(entity, oboAssertion)) {\r\n return;\r\n }\r\n\r\n if (!!homeAccountId && !this.matchHomeAccountId(entity, homeAccountId)) {\r\n return;\r\n }\r\n\r\n if (!!environment && !this.matchEnvironment(entity, environment)) {\r\n return;\r\n }\r\n\r\n if (!!realm && !this.matchRealm(entity, realm)) {\r\n return;\r\n }\r\n\r\n if (!!credentialType && !this.matchCredentialType(entity, credentialType)) {\r\n return;\r\n }\r\n\r\n if (!!clientId && !this.matchClientId(entity, clientId)) {\r\n return;\r\n }\r\n\r\n if (!!familyId && !this.matchFamilyId(entity, familyId)) {\r\n return;\r\n }\r\n\r\n /*\r\n * idTokens do not have \"target\", target specific refreshTokens do exist for some types of authentication\r\n * Resource specific refresh tokens case will be added when the support is deemed necessary\r\n */\r\n if (!!target && !this.matchTarget(entity, target)) {\r\n return;\r\n }\r\n\r\n switch (credType) {\r\n case CredentialType.ID_TOKEN:\r\n matchingCredentials.idTokens[cacheKey] = entity as IdTokenEntity;\r\n break;\r\n case CredentialType.ACCESS_TOKEN:\r\n case CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME:\r\n matchingCredentials.accessTokens[cacheKey] = entity as AccessTokenEntity;\r\n break;\r\n case CredentialType.REFRESH_TOKEN:\r\n matchingCredentials.refreshTokens[cacheKey] = entity as RefreshTokenEntity;\r\n break;\r\n }\r\n });\r\n\r\n return matchingCredentials;\r\n }\r\n\r\n /**\r\n * retrieve appMetadata matching all provided filters; if no filter is set, get all appMetadata\r\n * @param filter\r\n */\r\n getAppMetadataFilteredBy(filter: AppMetadataFilter): AppMetadataCache {\r\n return this.getAppMetadataFilteredByInternal(\r\n filter.environment,\r\n filter.clientId,\r\n );\r\n }\r\n\r\n /**\r\n * Support function to help match appMetadata\r\n * @param environment\r\n * @param clientId\r\n */\r\n private getAppMetadataFilteredByInternal(\r\n environment?: string,\r\n clientId?: string\r\n ): AppMetadataCache {\r\n\r\n const allCacheKeys = this.getKeys();\r\n const matchingAppMetadata: AppMetadataCache = {};\r\n\r\n allCacheKeys.forEach((cacheKey) => {\r\n // don't parse any non-appMetadata type cache entities\r\n if (!this.isAppMetadata(cacheKey)) {\r\n return;\r\n }\r\n\r\n // Attempt retrieval\r\n const entity = this.getAppMetadata(cacheKey);\r\n\r\n if (!entity) {\r\n return;\r\n }\r\n\r\n if (!!environment && !this.matchEnvironment(entity, environment)) {\r\n return;\r\n }\r\n\r\n if (!!clientId && !this.matchClientId(entity, clientId)) {\r\n return;\r\n }\r\n\r\n matchingAppMetadata[cacheKey] = entity;\r\n\r\n });\r\n\r\n return matchingAppMetadata;\r\n }\r\n\r\n /**\r\n * retrieve authorityMetadata that contains a matching alias\r\n * @param filter\r\n */\r\n getAuthorityMetadataByAlias(host: string): AuthorityMetadataEntity | null {\r\n const allCacheKeys = this.getAuthorityMetadataKeys();\r\n let matchedEntity = null;\r\n\r\n allCacheKeys.forEach((cacheKey) => {\r\n // don't parse any non-authorityMetadata type cache entities\r\n if (!this.isAuthorityMetadata(cacheKey) || cacheKey.indexOf(this.clientId) === -1) {\r\n return;\r\n }\r\n\r\n // Attempt retrieval\r\n const entity = this.getAuthorityMetadata(cacheKey);\r\n\r\n if (!entity) {\r\n return;\r\n }\r\n\r\n if (entity.aliases.indexOf(host) === -1) {\r\n return;\r\n }\r\n\r\n matchedEntity = entity;\r\n\r\n });\r\n \r\n return matchedEntity;\r\n }\r\n\r\n /**\r\n * Removes all accounts and related tokens from cache.\r\n */\r\n removeAllAccounts(): boolean {\r\n const allCacheKeys = this.getKeys();\r\n allCacheKeys.forEach((cacheKey) => {\r\n const entity = this.getAccount(cacheKey);\r\n if (!entity) {\r\n return;\r\n }\r\n this.removeAccount(cacheKey);\r\n });\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * returns a boolean if the given account is removed\r\n * @param account\r\n */\r\n removeAccount(accountKey: string): boolean {\r\n const account = this.getAccount(accountKey);\r\n if (!account) {\r\n throw ClientAuthError.createNoAccountFoundError();\r\n }\r\n return (this.removeAccountContext(account) && this.removeItem(accountKey, CacheSchemaType.ACCOUNT));\r\n }\r\n\r\n /**\r\n * returns a boolean if the given account is removed\r\n * @param account\r\n */\r\n removeAccountContext(account: AccountEntity): boolean {\r\n const allCacheKeys = this.getKeys();\r\n const accountId = account.generateAccountId();\r\n\r\n allCacheKeys.forEach((cacheKey) => {\r\n // don't parse any non-credential type cache entities\r\n const credType = CredentialEntity.getCredentialType(cacheKey);\r\n if (credType === Constants.NOT_DEFINED) {\r\n return;\r\n }\r\n\r\n const cacheEntity = this.getSpecificCredential(cacheKey, credType);\r\n if (!!cacheEntity && accountId === cacheEntity.generateAccountId()) {\r\n this.removeCredential(cacheEntity);\r\n }\r\n });\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * returns a boolean if the given credential is removed\r\n * @param credential\r\n */\r\n removeCredential(credential: CredentialEntity): boolean {\r\n const key = credential.generateCredentialKey();\r\n return this.removeItem(key, CacheSchemaType.CREDENTIAL);\r\n }\r\n\r\n /**\r\n * Removes all app metadata objects from cache.\r\n */\r\n removeAppMetadata(): boolean {\r\n const allCacheKeys = this.getKeys();\r\n allCacheKeys.forEach((cacheKey) => {\r\n if (this.isAppMetadata(cacheKey)) {\r\n this.removeItem(cacheKey, CacheSchemaType.APP_METADATA);\r\n }\r\n });\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Retrieve the cached credentials into a cacherecord\r\n * @param account\r\n * @param clientId\r\n * @param scopes\r\n * @param environment\r\n * @param authScheme\r\n */\r\n readCacheRecord(account: AccountInfo, clientId: string, scopes: ScopeSet, environment: string, authScheme: AuthenticationScheme): CacheRecord {\r\n const cachedAccount = this.readAccountFromCache(account);\r\n const cachedIdToken = this.readIdTokenFromCache(clientId, account);\r\n const cachedAccessToken = this.readAccessTokenFromCache(clientId, account, scopes, authScheme);\r\n const cachedRefreshToken = this.readRefreshTokenFromCache(clientId, account, false);\r\n const cachedAppMetadata = this.readAppMetadataFromCache(environment, clientId);\r\n\r\n if (cachedAccount && cachedIdToken) {\r\n cachedAccount.idTokenClaims = new AuthToken(cachedIdToken.secret, this.cryptoImpl).claims;\r\n }\r\n\r\n return {\r\n account: cachedAccount,\r\n idToken: cachedIdToken,\r\n accessToken: cachedAccessToken,\r\n refreshToken: cachedRefreshToken,\r\n appMetadata: cachedAppMetadata,\r\n };\r\n }\r\n\r\n /**\r\n * Retrieve AccountEntity from cache\r\n * @param account\r\n */\r\n readAccountFromCache(account: AccountInfo): AccountEntity | null {\r\n const accountKey: string = AccountEntity.generateAccountCacheKey(account);\r\n return this.getAccount(accountKey);\r\n }\r\n\r\n /**\r\n * Retrieve IdTokenEntity from cache\r\n * @param clientId\r\n * @param account\r\n * @param inputRealm\r\n */\r\n readIdTokenFromCache(clientId: string, account: AccountInfo): IdTokenEntity | null {\r\n const idTokenFilter: CredentialFilter = {\r\n homeAccountId: account.homeAccountId,\r\n environment: account.environment,\r\n credentialType: CredentialType.ID_TOKEN,\r\n clientId: clientId,\r\n realm: account.tenantId,\r\n };\r\n\r\n const credentialCache: CredentialCache = this.getCredentialsFilteredBy(idTokenFilter);\r\n const idTokens = Object.keys(credentialCache.idTokens).map((key) => credentialCache.idTokens[key]);\r\n const numIdTokens = idTokens.length;\r\n\r\n if (numIdTokens < 1) {\r\n return null;\r\n } else if (numIdTokens > 1) {\r\n throw ClientAuthError.createMultipleMatchingTokensInCacheError();\r\n }\r\n\r\n return idTokens[0] as IdTokenEntity;\r\n }\r\n\r\n /**\r\n * Retrieve AccessTokenEntity from cache\r\n * @param clientId\r\n * @param account\r\n * @param scopes\r\n * @param authScheme\r\n */\r\n readAccessTokenFromCache(clientId: string, account: AccountInfo, scopes: ScopeSet, authScheme: AuthenticationScheme): AccessTokenEntity | null {\r\n const credentialType = (authScheme === AuthenticationScheme.POP) ? CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME : CredentialType.ACCESS_TOKEN;\r\n\r\n const accessTokenFilter: CredentialFilter = {\r\n homeAccountId: account.homeAccountId,\r\n environment: account.environment,\r\n credentialType: credentialType,\r\n clientId,\r\n realm: account.tenantId,\r\n target: scopes.printScopesLowerCase(),\r\n };\r\n\r\n const credentialCache: CredentialCache = this.getCredentialsFilteredBy(accessTokenFilter);\r\n\r\n const accessTokens = Object.keys(credentialCache.accessTokens).map((key) => credentialCache.accessTokens[key]);\r\n\r\n const numAccessTokens = accessTokens.length;\r\n if (numAccessTokens < 1) {\r\n return null;\r\n } else if (numAccessTokens > 1) {\r\n throw ClientAuthError.createMultipleMatchingTokensInCacheError();\r\n }\r\n\r\n return accessTokens[0] as AccessTokenEntity;\r\n }\r\n\r\n /**\r\n * Helper to retrieve the appropriate refresh token from cache\r\n * @param clientId\r\n * @param account\r\n * @param familyRT\r\n */\r\n readRefreshTokenFromCache(clientId: string, account: AccountInfo, familyRT: boolean): RefreshTokenEntity | null {\r\n const id = familyRT ? THE_FAMILY_ID : undefined;\r\n const refreshTokenFilter: CredentialFilter = {\r\n homeAccountId: account.homeAccountId,\r\n environment: account.environment,\r\n credentialType: CredentialType.REFRESH_TOKEN,\r\n clientId: clientId,\r\n familyId: id\r\n };\r\n\r\n const credentialCache: CredentialCache = this.getCredentialsFilteredBy(refreshTokenFilter);\r\n const refreshTokens = Object.keys(credentialCache.refreshTokens).map((key) => credentialCache.refreshTokens[key]);\r\n\r\n const numRefreshTokens = refreshTokens.length;\r\n if (numRefreshTokens < 1) {\r\n return null;\r\n }\r\n // address the else case after remove functions address environment aliases\r\n\r\n return refreshTokens[0] as RefreshTokenEntity;\r\n }\r\n\r\n /**\r\n * Retrieve AppMetadataEntity from cache\r\n */\r\n readAppMetadataFromCache(environment: string, clientId: string): AppMetadataEntity | null {\r\n const appMetadataFilter: AppMetadataFilter = {\r\n environment,\r\n clientId,\r\n };\r\n\r\n const appMetadata: AppMetadataCache = this.getAppMetadataFilteredBy(appMetadataFilter);\r\n const appMetadataEntries: AppMetadataEntity[] = Object.keys(appMetadata).map((key) => appMetadata[key]);\r\n\r\n const numAppMetadata = appMetadataEntries.length;\r\n if (numAppMetadata < 1) {\r\n return null;\r\n } else if (numAppMetadata > 1) {\r\n throw ClientAuthError.createMultipleMatchingAppMetadataInCacheError();\r\n }\r\n\r\n return appMetadataEntries[0] as AppMetadataEntity;\r\n }\r\n\r\n /**\r\n * Return the family_id value associated with FOCI\r\n * @param environment\r\n * @param clientId\r\n */\r\n isAppMetadataFOCI(environment: string, clientId: string): boolean {\r\n const appMetadata = this.readAppMetadataFromCache(environment, clientId);\r\n return !!(appMetadata && appMetadata.familyId === THE_FAMILY_ID);\r\n }\r\n\r\n /**\r\n * helper to match account ids\r\n * @param value\r\n * @param homeAccountId\r\n */\r\n private matchHomeAccountId(entity: AccountEntity | CredentialEntity, homeAccountId: string): boolean {\r\n return !!(entity.homeAccountId && homeAccountId === entity.homeAccountId);\r\n }\r\n\r\n /**\r\n * helper to match assertion\r\n * @param value\r\n * @param oboAssertion\r\n */\r\n private matchOboAssertion(entity: AccountEntity | CredentialEntity, oboAssertion: string): boolean {\r\n return !!(entity.oboAssertion && oboAssertion === entity.oboAssertion);\r\n }\r\n\r\n /**\r\n * helper to match environment\r\n * @param value\r\n * @param environment\r\n */\r\n private matchEnvironment(entity: AccountEntity | CredentialEntity | AppMetadataEntity, environment: string): boolean {\r\n const cloudMetadata = this.getAuthorityMetadataByAlias(environment);\r\n if (cloudMetadata && cloudMetadata.aliases.indexOf(entity.environment) > -1) {\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n\r\n /**\r\n * helper to match credential type\r\n * @param entity\r\n * @param credentialType\r\n */\r\n private matchCredentialType(entity: CredentialEntity, credentialType: string): boolean {\r\n return (entity.credentialType && credentialType.toLowerCase() === entity.credentialType.toLowerCase());\r\n }\r\n\r\n /**\r\n * helper to match client ids\r\n * @param entity\r\n * @param clientId\r\n */\r\n private matchClientId(entity: CredentialEntity | AppMetadataEntity, clientId: string): boolean {\r\n return !!(entity.clientId && clientId === entity.clientId);\r\n }\r\n\r\n /**\r\n * helper to match family ids\r\n * @param entity\r\n * @param familyId\r\n */\r\n private matchFamilyId(entity: CredentialEntity | AppMetadataEntity, familyId: string): boolean {\r\n return !!(entity.familyId && familyId === entity.familyId);\r\n }\r\n\r\n /**\r\n * helper to match realm\r\n * @param entity\r\n * @param realm\r\n */\r\n private matchRealm(entity: AccountEntity | CredentialEntity, realm: string): boolean {\r\n return !!(entity.realm && realm === entity.realm);\r\n }\r\n\r\n /**\r\n * Returns true if the target scopes are a subset of the current entity's scopes, false otherwise.\r\n * @param entity\r\n * @param target\r\n */\r\n private matchTarget(entity: CredentialEntity, target: string): boolean {\r\n const isNotAccessTokenCredential = (entity.credentialType !== CredentialType.ACCESS_TOKEN && entity.credentialType !== CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME);\r\n\r\n if ( isNotAccessTokenCredential || !entity.target) {\r\n return false;\r\n }\r\n\r\n const entityScopeSet: ScopeSet = ScopeSet.fromString(entity.target);\r\n const requestTargetScopeSet: ScopeSet = ScopeSet.fromString(target);\r\n\r\n if (!requestTargetScopeSet.containsOnlyOIDCScopes()) {\r\n requestTargetScopeSet.removeOIDCScopes(); // ignore OIDC scopes\r\n } else {\r\n requestTargetScopeSet.removeScope(Constants.OFFLINE_ACCESS_SCOPE);\r\n }\r\n return entityScopeSet.containsScopeSet(requestTargetScopeSet);\r\n }\r\n\r\n /**\r\n * returns if a given cache entity is of the type appmetadata\r\n * @param key\r\n */\r\n private isAppMetadata(key: string): boolean {\r\n return key.indexOf(APP_METADATA) !== -1;\r\n }\r\n\r\n /**\r\n * returns if a given cache entity is of the type authoritymetadata\r\n * @param key\r\n */\r\n protected isAuthorityMetadata(key: string): boolean {\r\n return key.indexOf(AUTHORITY_METADATA_CONSTANTS.CACHE_KEY) !== -1;\r\n }\r\n\r\n /**\r\n * returns cache key used for cloud instance metadata\r\n */\r\n generateAuthorityMetadataCacheKey(authority: string): string {\r\n return `${AUTHORITY_METADATA_CONSTANTS.CACHE_KEY}-${this.clientId}-${authority}`;\r\n }\r\n\r\n /**\r\n * Returns the specific credential (IdToken/AccessToken/RefreshToken) from the cache\r\n * @param key\r\n * @param credType\r\n */\r\n private getSpecificCredential(key: string, credType: string): ValidCredentialType | null {\r\n switch (credType) {\r\n case CredentialType.ID_TOKEN: {\r\n return this.getIdTokenCredential(key);\r\n }\r\n case CredentialType.ACCESS_TOKEN:\r\n case CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME: {\r\n return this.getAccessTokenCredential(key);\r\n }\r\n case CredentialType.REFRESH_TOKEN: {\r\n return this.getRefreshTokenCredential(key);\r\n }\r\n default:\r\n return null;\r\n }\r\n }\r\n\r\n /**\r\n * Helper to convert serialized data to object\r\n * @param obj\r\n * @param json\r\n */\r\n static toObject<T>(obj: T, json: object): T {\r\n for (const propertyName in json) {\r\n obj[propertyName] = json[propertyName];\r\n }\r\n return obj;\r\n }\r\n}\r\n\r\nexport class DefaultStorageClass extends CacheManager {\r\n setAccount(): void {\r\n const notImplErr = \"Storage interface - setAccount() has not been implemented for the cacheStorage interface.\";\r\n throw AuthError.createUnexpectedError(notImplErr);\r\n }\r\n getAccount(): AccountEntity {\r\n const notImplErr = \"Storage interface - getAccount() has not been implemented for the cacheStorage interface.\";\r\n throw AuthError.createUnexpectedError(notImplErr);\r\n }\r\n setIdTokenCredential(): void {\r\n const notImplErr = \"Storage interface - setIdTokenCredential() has not been implemented for the cacheStorage interface.\";\r\n throw AuthError.createUnexpectedError(notImplErr);\r\n }\r\n getIdTokenCredential(): IdTokenEntity {\r\n const notImplErr = \"Storage interface - getIdTokenCredential() has not been implemented for the cacheStorage interface.\";\r\n throw AuthError.createUnexpectedError(notImplErr);\r\n }\r\n setAccessTokenCredential(): void {\r\n const notImplErr = \"Storage interface - setAccessTokenCredential() has not been implemented for the cacheStorage interface.\";\r\n throw AuthError.createUnexpectedError(notImplErr);\r\n }\r\n getAccessTokenCredential(): AccessTokenEntity {\r\n const notImplErr = \"Storage interface - getAccessTokenCredential() has not been implemented for the cacheStorage interface.\";\r\n throw AuthError.createUnexpectedError(notImplErr);\r\n }\r\n setRefreshTokenCredential(): void {\r\n const notImplErr = \"Storage interface - setRefreshTokenCredential() has not been implemented for the cacheStorage interface.\";\r\n throw AuthError.createUnexpectedError(notImplErr);\r\n }\r\n getRefreshTokenCredential(): RefreshTokenEntity {\r\n const notImplErr = \"Storage interface - getRefreshTokenCredential() has not been implemented for the cacheStorage interface.\";\r\n throw AuthError.createUnexpectedError(notImplErr);\r\n }\r\n setAppMetadata(): void {\r\n const notImplErr = \"Storage interface - setAppMetadata() has not been implemented for the cacheStorage interface.\";\r\n throw AuthError.createUnexpectedError(notImplErr);\r\n }\r\n getAppMetadata(): AppMetadataEntity {\r\n const notImplErr = \"Storage interface - getAppMetadata() has not been implemented for the cacheStorage interface.\";\r\n throw AuthError.createUnexpectedError(notImplErr);\r\n }\r\n setServerTelemetry(): void {\r\n const notImplErr = \"Storage interface - setServerTelemetry() has not been implemented for the cacheStorage interface.\";\r\n throw AuthError.createUnexpectedError(notImplErr);\r\n }\r\n getServerTelemetry(): ServerTelemetryEntity {\r\n const notImplErr = \"Storage interface - getServerTelemetry() has not been implemented for the cacheStorage interface.\";\r\n throw AuthError.createUnexpectedError(notImplErr);\r\n }\r\n setAuthorityMetadata(): void {\r\n const notImplErr = \"Storage interface - setAuthorityMetadata() has not been implemented for the cacheStorage interface.\";\r\n throw AuthError.createUnexpectedError(notImplErr);\r\n }\r\n getAuthorityMetadata(): AuthorityMetadataEntity | null {\r\n const notImplErr = \"Storage interface - getAuthorityMetadata() has not been implemented for the cacheStorage interface.\";\r\n throw AuthError.createUnexpectedError(notImplErr);\r\n }\r\n getAuthorityMetadataKeys(): Array<string> {\r\n const notImplErr = \"Storage interface - getAuthorityMetadataKeys() has not been implemented for the cacheStorage interface.\";\r\n throw AuthError.createUnexpectedError(notImplErr);\r\n }\r\n setThrottlingCache(): void {\r\n const notImplErr = \"Storage interface - setThrottlingCache() has not been implemented for the cacheStorage interface.\";\r\n throw AuthError.createUnexpectedError(notImplErr);\r\n }\r\n getThrottlingCache(): ThrottlingEntity {\r\n const notImplErr = \"Storage interface - getThrottlingCache() has not been implemented for the cacheStorage interface.\";\r\n throw AuthError.createUnexpectedError(notImplErr);\r\n }\r\n removeItem(): boolean {\r\n const notImplErr = \"Storage interface - removeItem() has not been implemented for the cacheStorage interface.\";\r\n throw AuthError.createUnexpectedError(notImplErr);\r\n }\r\n containsKey(): boolean {\r\n const notImplErr = \"Storage interface - containsKey() has not been implemented for the cacheStorage interface.\";\r\n throw AuthError.createUnexpectedError(notImplErr);\r\n }\r\n getKeys(): string[] {\r\n const notImplErr = \"Storage interface - getKeys() has not been implemented for the cacheStorage interface.\";\r\n throw AuthError.createUnexpectedError(notImplErr);\r\n }\r\n clear(): void {\r\n const notImplErr = \"Storage interface - clear() has not been implemented for the cacheStorage interface.\";\r\n throw AuthError.createUnexpectedError(notImplErr);\r\n }\r\n}\r\n"],"names":["AccountEntity","AuthToken","ClientAuthError","ScopeSet","CredentialEntity","Constants","AuthError"],"mappings":";;;;;;;;;;;AAAA;;;;AAyBA;;;;IAOI,sBAAY,QAAgB,EAAE,UAAmB;QAC7C,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;KAChC;;;;IAmID,qCAAc,GAAd;QAAA,iBAoBC;QAnBG,IAAM,eAAe,GAAiB,IAAI,CAAC,qBAAqB,EAAE,CAAC;QACnE,IAAM,aAAa,GAAoB,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,GAAG,CAAC,UAAA,UAAU,IAAI,OAAA,eAAe,CAAC,UAAU,CAAC,GAAA,CAAC,CAAC;QACnH,IAAM,WAAW,GAAG,aAAa,CAAC,MAAM,CAAC;QACz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;KACrD;IACD,qCAAO,GAAP;QACI,IAAM,UAAU,GAAG,wFAAwF,CAAC;QAC5G,MAAMA,WAAS,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC;KACrD;IACD,mCAAK,GAAL;QACI,IAAM,UAAU,GAAG,sFAAsF,CAAC;QAC1G,MAAMA,WAAS,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC;KACrD;IACL,0BAAC;AAAD,CArFA,CAAyC,YAAY;;;;"}
1
+ {"version":3,"file":"CacheManager.js","sources":["../../src/cache/CacheManager.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { AccountCache, AccountFilter, CredentialFilter, CredentialCache, ValidCredentialType, AppMetadataFilter, AppMetadataCache } from \"./utils/CacheTypes\";\nimport { CacheRecord } from \"./entities/CacheRecord\";\nimport { CacheSchemaType, CredentialType, Constants, APP_METADATA, THE_FAMILY_ID, AUTHORITY_METADATA_CONSTANTS, AuthenticationScheme } from \"../utils/Constants\";\nimport { CredentialEntity } from \"./entities/CredentialEntity\";\nimport { ScopeSet } from \"../request/ScopeSet\";\nimport { AccountEntity } from \"./entities/AccountEntity\";\nimport { AccessTokenEntity } from \"./entities/AccessTokenEntity\";\nimport { IdTokenEntity } from \"./entities/IdTokenEntity\";\nimport { RefreshTokenEntity } from \"./entities/RefreshTokenEntity\";\nimport { AuthError } from \"../error/AuthError\";\nimport { ICacheManager } from \"./interface/ICacheManager\";\nimport { ClientAuthError } from \"../error/ClientAuthError\";\nimport { AccountInfo } from \"../account/AccountInfo\";\nimport { AppMetadataEntity } from \"./entities/AppMetadataEntity\";\nimport { ServerTelemetryEntity } from \"./entities/ServerTelemetryEntity\";\nimport { ThrottlingEntity } from \"./entities/ThrottlingEntity\";\nimport { AuthToken } from \"../account/AuthToken\";\nimport { ICrypto } from \"../crypto/ICrypto\";\nimport { AuthorityMetadataEntity } from \"./entities/AuthorityMetadataEntity\";\n\n/**\n * Interface class which implement cache storage functions used by MSAL to perform validity checks, and store tokens.\n */\nexport abstract class CacheManager implements ICacheManager {\n protected clientId: string;\n protected cryptoImpl: ICrypto;\n\n constructor(clientId: string, cryptoImpl: ICrypto) {\n this.clientId = clientId;\n this.cryptoImpl = cryptoImpl;\n }\n\n /**\n * fetch the account entity from the platform cache\n * @param accountKey\n */\n abstract getAccount(accountKey: string): AccountEntity | null;\n\n /**\n * set account entity in the platform cache\n * @param account\n */\n abstract setAccount(account: AccountEntity): void;\n\n /**\n * fetch the idToken entity from the platform cache\n * @param idTokenKey\n */\n abstract getIdTokenCredential(idTokenKey: string): IdTokenEntity | null;\n\n /**\n * set idToken entity to the platform cache\n * @param idToken\n */\n abstract setIdTokenCredential(idToken: IdTokenEntity): void;\n\n /**\n * fetch the idToken entity from the platform cache\n * @param accessTokenKey\n */\n abstract getAccessTokenCredential(accessTokenKey: string): AccessTokenEntity | null;\n\n /**\n * set idToken entity to the platform cache\n * @param accessToken\n */\n abstract setAccessTokenCredential(accessToken: AccessTokenEntity): void;\n\n /**\n * fetch the idToken entity from the platform cache\n * @param refreshTokenKey\n */\n abstract getRefreshTokenCredential(refreshTokenKey: string): RefreshTokenEntity | null;\n\n /**\n * set idToken entity to the platform cache\n * @param refreshToken\n */\n abstract setRefreshTokenCredential(refreshToken: RefreshTokenEntity): void;\n\n /**\n * fetch appMetadata entity from the platform cache\n * @param appMetadataKey\n */\n abstract getAppMetadata(appMetadataKey: string): AppMetadataEntity | null;\n\n /**\n * set appMetadata entity to the platform cache\n * @param appMetadata\n */\n abstract setAppMetadata(appMetadata: AppMetadataEntity): void;\n\n /**\n * fetch server telemetry entity from the platform cache\n * @param serverTelemetryKey\n */\n abstract getServerTelemetry(serverTelemetryKey: string): ServerTelemetryEntity | null;\n\n /**\n * set server telemetry entity to the platform cache\n * @param serverTelemetryKey\n * @param serverTelemetry\n */\n abstract setServerTelemetry(serverTelemetryKey: string, serverTelemetry: ServerTelemetryEntity): void;\n\n /**\n * fetch cloud discovery metadata entity from the platform cache\n * @param key\n */\n abstract getAuthorityMetadata(key: string): AuthorityMetadataEntity | null;\n\n /**\n * \n */\n abstract getAuthorityMetadataKeys(): Array<string>;\n\n /**\n * set cloud discovery metadata entity to the platform cache\n * @param key\n * @param value\n */\n abstract setAuthorityMetadata(key: string, value: AuthorityMetadataEntity): void;\n\n /**\n * fetch throttling entity from the platform cache\n * @param throttlingCacheKey\n */\n abstract getThrottlingCache(throttlingCacheKey: string): ThrottlingEntity | null;\n\n /**\n * set throttling entity to the platform cache\n * @param throttlingCacheKey\n * @param throttlingCache\n */\n abstract setThrottlingCache(throttlingCacheKey: string, throttlingCache: ThrottlingEntity): void;;\n\n /**\n * Function to remove an item from cache given its key.\n * @param key\n */\n abstract removeItem(key: string, type?: string): boolean;\n\n /**\n * Function which returns boolean whether cache contains a specific key.\n * @param key\n */\n abstract containsKey(key: string, type?: string): boolean;\n\n /**\n * Function which retrieves all current keys from the cache.\n */\n abstract getKeys(): string[];\n\n /**\n * Function which clears cache.\n */\n abstract clear(): void;\n\n /**\n * Returns all accounts in cache\n */\n getAllAccounts(): AccountInfo[] {\n const currentAccounts: AccountCache = this.getAccountsFilteredBy();\n const accountValues: AccountEntity[] = Object.keys(currentAccounts).map(accountKey => currentAccounts[accountKey]);\n const numAccounts = accountValues.length;\n if (numAccounts < 1) {\n return [];\n } else {\n const allAccounts = accountValues.map<AccountInfo>((value) => {\n const accountEntity = CacheManager.toObject<AccountEntity>(new AccountEntity(), value);\n const accountInfo = accountEntity.getAccountInfo();\n const idToken = this.readIdTokenFromCache(this.clientId, accountInfo);\n if (idToken && !accountInfo.idTokenClaims) {\n accountInfo.idTokenClaims = new AuthToken(idToken.secret, this.cryptoImpl).claims;\n }\n\n return accountInfo;\n \n });\n return allAccounts;\n }\n }\n\n /**\n * saves a cache record\n * @param cacheRecord\n */\n saveCacheRecord(cacheRecord: CacheRecord): void {\n if (!cacheRecord) {\n throw ClientAuthError.createNullOrUndefinedCacheRecord();\n }\n\n if (!!cacheRecord.account) {\n this.setAccount(cacheRecord.account);\n }\n\n if (!!cacheRecord.idToken) {\n this.setIdTokenCredential(cacheRecord.idToken);\n }\n\n if (!!cacheRecord.accessToken) {\n this.saveAccessToken(cacheRecord.accessToken);\n }\n\n if (!!cacheRecord.refreshToken) {\n this.setRefreshTokenCredential(cacheRecord.refreshToken);\n }\n\n if (!!cacheRecord.appMetadata) {\n this.setAppMetadata(cacheRecord.appMetadata);\n }\n }\n\n /**\n * saves access token credential\n * @param credential\n */\n private saveAccessToken(credential: AccessTokenEntity): void {\n const currentTokenCache = this.getCredentialsFilteredBy({\n clientId: credential.clientId,\n credentialType: credential.credentialType,\n environment: credential.environment,\n homeAccountId: credential.homeAccountId,\n realm: credential.realm,\n });\n const currentScopes = ScopeSet.fromString(credential.target);\n const currentAccessTokens: AccessTokenEntity[] = Object.keys(currentTokenCache.accessTokens).map(key => currentTokenCache.accessTokens[key]);\n if (currentAccessTokens) {\n currentAccessTokens.forEach((tokenEntity) => {\n const tokenScopeSet = ScopeSet.fromString(tokenEntity.target);\n if (tokenScopeSet.intersectingScopeSets(currentScopes)) {\n this.removeCredential(tokenEntity);\n }\n });\n }\n this.setAccessTokenCredential(credential);\n }\n\n /**\n * retrieve accounts matching all provided filters; if no filter is set, get all accounts\n * not checking for casing as keys are all generated in lower case, remember to convert to lower case if object properties are compared\n * @param homeAccountId\n * @param environment\n * @param realm\n */\n getAccountsFilteredBy(accountFilter?: AccountFilter): AccountCache {\n return this.getAccountsFilteredByInternal(\n accountFilter ? accountFilter.homeAccountId : \"\",\n accountFilter ? accountFilter.environment : \"\",\n accountFilter ? accountFilter.realm : \"\"\n );\n }\n\n /**\n * retrieve accounts matching all provided filters; if no filter is set, get all accounts\n * not checking for casing as keys are all generated in lower case, remember to convert to lower case if object properties are compared\n * @param homeAccountId\n * @param environment\n * @param realm\n */\n private getAccountsFilteredByInternal(\n homeAccountId?: string,\n environment?: string,\n realm?: string\n ): AccountCache {\n const allCacheKeys = this.getKeys();\n const matchingAccounts: AccountCache = {};\n\n allCacheKeys.forEach((cacheKey) => {\n const entity: AccountEntity | null = this.getAccount(cacheKey);\n\n if (!entity) {\n return;\n }\n\n if (!!homeAccountId && !this.matchHomeAccountId(entity, homeAccountId)) {\n return;\n }\n\n if (!!environment && !this.matchEnvironment(entity, environment)) {\n return;\n }\n\n if (!!realm && !this.matchRealm(entity, realm)) {\n return;\n }\n\n matchingAccounts[cacheKey] = entity;\n });\n\n return matchingAccounts;\n }\n\n /**\n * retrieve credentails matching all provided filters; if no filter is set, get all credentials\n * @param homeAccountId\n * @param environment\n * @param credentialType\n * @param clientId\n * @param realm\n * @param target\n */\n getCredentialsFilteredBy(filter: CredentialFilter): CredentialCache {\n return this.getCredentialsFilteredByInternal(\n filter.homeAccountId,\n filter.environment,\n filter.credentialType,\n filter.clientId,\n filter.familyId,\n filter.realm,\n filter.target,\n filter.oboAssertion\n );\n }\n\n /**\n * Support function to help match credentials\n * @param homeAccountId\n * @param environment\n * @param credentialType\n * @param clientId\n * @param realm\n * @param target\n */\n private getCredentialsFilteredByInternal(\n homeAccountId?: string,\n environment?: string,\n credentialType?: string,\n clientId?: string,\n familyId?: string,\n realm?: string,\n target?: string,\n oboAssertion?: string\n ): CredentialCache {\n const allCacheKeys = this.getKeys();\n const matchingCredentials: CredentialCache = {\n idTokens: {},\n accessTokens: {},\n refreshTokens: {},\n };\n \n allCacheKeys.forEach((cacheKey) => {\n // don't parse any non-credential type cache entities\n const credType = CredentialEntity.getCredentialType(cacheKey);\n\n if (credType === Constants.NOT_DEFINED) {\n return;\n }\n\n // Attempt retrieval\n const entity = this.getSpecificCredential(cacheKey, credType);\n\n if (!entity) {\n return;\n }\n\n if (!!oboAssertion && !this.matchOboAssertion(entity, oboAssertion)) {\n return;\n }\n\n if (!!homeAccountId && !this.matchHomeAccountId(entity, homeAccountId)) {\n return;\n }\n\n if (!!environment && !this.matchEnvironment(entity, environment)) {\n return;\n }\n\n if (!!realm && !this.matchRealm(entity, realm)) {\n return;\n }\n\n if (!!credentialType && !this.matchCredentialType(entity, credentialType)) {\n return;\n }\n\n if (!!clientId && !this.matchClientId(entity, clientId)) {\n return;\n }\n\n if (!!familyId && !this.matchFamilyId(entity, familyId)) {\n return;\n }\n\n /*\n * idTokens do not have \"target\", target specific refreshTokens do exist for some types of authentication\n * Resource specific refresh tokens case will be added when the support is deemed necessary\n */\n if (!!target && !this.matchTarget(entity, target)) {\n return;\n }\n\n switch (credType) {\n case CredentialType.ID_TOKEN:\n matchingCredentials.idTokens[cacheKey] = entity as IdTokenEntity;\n break;\n case CredentialType.ACCESS_TOKEN:\n case CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME:\n matchingCredentials.accessTokens[cacheKey] = entity as AccessTokenEntity;\n break;\n case CredentialType.REFRESH_TOKEN:\n matchingCredentials.refreshTokens[cacheKey] = entity as RefreshTokenEntity;\n break;\n }\n });\n\n return matchingCredentials;\n }\n\n /**\n * retrieve appMetadata matching all provided filters; if no filter is set, get all appMetadata\n * @param filter\n */\n getAppMetadataFilteredBy(filter: AppMetadataFilter): AppMetadataCache {\n return this.getAppMetadataFilteredByInternal(\n filter.environment,\n filter.clientId,\n );\n }\n\n /**\n * Support function to help match appMetadata\n * @param environment\n * @param clientId\n */\n private getAppMetadataFilteredByInternal(\n environment?: string,\n clientId?: string\n ): AppMetadataCache {\n\n const allCacheKeys = this.getKeys();\n const matchingAppMetadata: AppMetadataCache = {};\n\n allCacheKeys.forEach((cacheKey) => {\n // don't parse any non-appMetadata type cache entities\n if (!this.isAppMetadata(cacheKey)) {\n return;\n }\n\n // Attempt retrieval\n const entity = this.getAppMetadata(cacheKey);\n\n if (!entity) {\n return;\n }\n\n if (!!environment && !this.matchEnvironment(entity, environment)) {\n return;\n }\n\n if (!!clientId && !this.matchClientId(entity, clientId)) {\n return;\n }\n\n matchingAppMetadata[cacheKey] = entity;\n\n });\n\n return matchingAppMetadata;\n }\n\n /**\n * retrieve authorityMetadata that contains a matching alias\n * @param filter\n */\n getAuthorityMetadataByAlias(host: string): AuthorityMetadataEntity | null {\n const allCacheKeys = this.getAuthorityMetadataKeys();\n let matchedEntity = null;\n\n allCacheKeys.forEach((cacheKey) => {\n // don't parse any non-authorityMetadata type cache entities\n if (!this.isAuthorityMetadata(cacheKey) || cacheKey.indexOf(this.clientId) === -1) {\n return;\n }\n\n // Attempt retrieval\n const entity = this.getAuthorityMetadata(cacheKey);\n\n if (!entity) {\n return;\n }\n\n if (entity.aliases.indexOf(host) === -1) {\n return;\n }\n\n matchedEntity = entity;\n\n });\n \n return matchedEntity;\n }\n\n /**\n * Removes all accounts and related tokens from cache.\n */\n removeAllAccounts(): boolean {\n const allCacheKeys = this.getKeys();\n allCacheKeys.forEach((cacheKey) => {\n const entity = this.getAccount(cacheKey);\n if (!entity) {\n return;\n }\n this.removeAccount(cacheKey);\n });\n\n return true;\n }\n\n /**\n * returns a boolean if the given account is removed\n * @param account\n */\n removeAccount(accountKey: string): boolean {\n const account = this.getAccount(accountKey);\n if (!account) {\n throw ClientAuthError.createNoAccountFoundError();\n }\n return (this.removeAccountContext(account) && this.removeItem(accountKey, CacheSchemaType.ACCOUNT));\n }\n\n /**\n * returns a boolean if the given account is removed\n * @param account\n */\n removeAccountContext(account: AccountEntity): boolean {\n const allCacheKeys = this.getKeys();\n const accountId = account.generateAccountId();\n\n allCacheKeys.forEach((cacheKey) => {\n // don't parse any non-credential type cache entities\n const credType = CredentialEntity.getCredentialType(cacheKey);\n if (credType === Constants.NOT_DEFINED) {\n return;\n }\n\n const cacheEntity = this.getSpecificCredential(cacheKey, credType);\n if (!!cacheEntity && accountId === cacheEntity.generateAccountId()) {\n this.removeCredential(cacheEntity);\n }\n });\n\n return true;\n }\n\n /**\n * returns a boolean if the given credential is removed\n * @param credential\n */\n removeCredential(credential: CredentialEntity): boolean {\n const key = credential.generateCredentialKey();\n return this.removeItem(key, CacheSchemaType.CREDENTIAL);\n }\n\n /**\n * Removes all app metadata objects from cache.\n */\n removeAppMetadata(): boolean {\n const allCacheKeys = this.getKeys();\n allCacheKeys.forEach((cacheKey) => {\n if (this.isAppMetadata(cacheKey)) {\n this.removeItem(cacheKey, CacheSchemaType.APP_METADATA);\n }\n });\n\n return true;\n }\n\n /**\n * Retrieve the cached credentials into a cacherecord\n * @param account\n * @param clientId\n * @param scopes\n * @param environment\n * @param authScheme\n */\n readCacheRecord(account: AccountInfo, clientId: string, scopes: ScopeSet, environment: string, authScheme: AuthenticationScheme): CacheRecord {\n const cachedAccount = this.readAccountFromCache(account);\n const cachedIdToken = this.readIdTokenFromCache(clientId, account);\n const cachedAccessToken = this.readAccessTokenFromCache(clientId, account, scopes, authScheme);\n const cachedRefreshToken = this.readRefreshTokenFromCache(clientId, account, false);\n const cachedAppMetadata = this.readAppMetadataFromCache(environment, clientId);\n\n if (cachedAccount && cachedIdToken) {\n cachedAccount.idTokenClaims = new AuthToken(cachedIdToken.secret, this.cryptoImpl).claims;\n }\n\n return {\n account: cachedAccount,\n idToken: cachedIdToken,\n accessToken: cachedAccessToken,\n refreshToken: cachedRefreshToken,\n appMetadata: cachedAppMetadata,\n };\n }\n\n /**\n * Retrieve AccountEntity from cache\n * @param account\n */\n readAccountFromCache(account: AccountInfo): AccountEntity | null {\n const accountKey: string = AccountEntity.generateAccountCacheKey(account);\n return this.getAccount(accountKey);\n }\n\n /**\n * Retrieve IdTokenEntity from cache\n * @param clientId\n * @param account\n * @param inputRealm\n */\n readIdTokenFromCache(clientId: string, account: AccountInfo): IdTokenEntity | null {\n const idTokenFilter: CredentialFilter = {\n homeAccountId: account.homeAccountId,\n environment: account.environment,\n credentialType: CredentialType.ID_TOKEN,\n clientId: clientId,\n realm: account.tenantId,\n };\n\n const credentialCache: CredentialCache = this.getCredentialsFilteredBy(idTokenFilter);\n const idTokens = Object.keys(credentialCache.idTokens).map((key) => credentialCache.idTokens[key]);\n const numIdTokens = idTokens.length;\n\n if (numIdTokens < 1) {\n return null;\n } else if (numIdTokens > 1) {\n throw ClientAuthError.createMultipleMatchingTokensInCacheError();\n }\n\n return idTokens[0] as IdTokenEntity;\n }\n\n /**\n * Retrieve AccessTokenEntity from cache\n * @param clientId\n * @param account\n * @param scopes\n * @param authScheme\n */\n readAccessTokenFromCache(clientId: string, account: AccountInfo, scopes: ScopeSet, authScheme: AuthenticationScheme): AccessTokenEntity | null {\n const credentialType = (authScheme === AuthenticationScheme.POP) ? CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME : CredentialType.ACCESS_TOKEN;\n\n const accessTokenFilter: CredentialFilter = {\n homeAccountId: account.homeAccountId,\n environment: account.environment,\n credentialType: credentialType,\n clientId,\n realm: account.tenantId,\n target: scopes.printScopesLowerCase(),\n };\n\n const credentialCache: CredentialCache = this.getCredentialsFilteredBy(accessTokenFilter);\n\n const accessTokens = Object.keys(credentialCache.accessTokens).map((key) => credentialCache.accessTokens[key]);\n\n const numAccessTokens = accessTokens.length;\n if (numAccessTokens < 1) {\n return null;\n } else if (numAccessTokens > 1) {\n throw ClientAuthError.createMultipleMatchingTokensInCacheError();\n }\n\n return accessTokens[0] as AccessTokenEntity;\n }\n\n /**\n * Helper to retrieve the appropriate refresh token from cache\n * @param clientId\n * @param account\n * @param familyRT\n */\n readRefreshTokenFromCache(clientId: string, account: AccountInfo, familyRT: boolean): RefreshTokenEntity | null {\n const id = familyRT ? THE_FAMILY_ID : undefined;\n const refreshTokenFilter: CredentialFilter = {\n homeAccountId: account.homeAccountId,\n environment: account.environment,\n credentialType: CredentialType.REFRESH_TOKEN,\n clientId: clientId,\n familyId: id\n };\n\n const credentialCache: CredentialCache = this.getCredentialsFilteredBy(refreshTokenFilter);\n const refreshTokens = Object.keys(credentialCache.refreshTokens).map((key) => credentialCache.refreshTokens[key]);\n\n const numRefreshTokens = refreshTokens.length;\n if (numRefreshTokens < 1) {\n return null;\n }\n // address the else case after remove functions address environment aliases\n\n return refreshTokens[0] as RefreshTokenEntity;\n }\n\n /**\n * Retrieve AppMetadataEntity from cache\n */\n readAppMetadataFromCache(environment: string, clientId: string): AppMetadataEntity | null {\n const appMetadataFilter: AppMetadataFilter = {\n environment,\n clientId,\n };\n\n const appMetadata: AppMetadataCache = this.getAppMetadataFilteredBy(appMetadataFilter);\n const appMetadataEntries: AppMetadataEntity[] = Object.keys(appMetadata).map((key) => appMetadata[key]);\n\n const numAppMetadata = appMetadataEntries.length;\n if (numAppMetadata < 1) {\n return null;\n } else if (numAppMetadata > 1) {\n throw ClientAuthError.createMultipleMatchingAppMetadataInCacheError();\n }\n\n return appMetadataEntries[0] as AppMetadataEntity;\n }\n\n /**\n * Return the family_id value associated with FOCI\n * @param environment\n * @param clientId\n */\n isAppMetadataFOCI(environment: string, clientId: string): boolean {\n const appMetadata = this.readAppMetadataFromCache(environment, clientId);\n return !!(appMetadata && appMetadata.familyId === THE_FAMILY_ID);\n }\n\n /**\n * helper to match account ids\n * @param value\n * @param homeAccountId\n */\n private matchHomeAccountId(entity: AccountEntity | CredentialEntity, homeAccountId: string): boolean {\n return !!(entity.homeAccountId && homeAccountId === entity.homeAccountId);\n }\n\n /**\n * helper to match assertion\n * @param value\n * @param oboAssertion\n */\n private matchOboAssertion(entity: AccountEntity | CredentialEntity, oboAssertion: string): boolean {\n return !!(entity.oboAssertion && oboAssertion === entity.oboAssertion);\n }\n\n /**\n * helper to match environment\n * @param value\n * @param environment\n */\n private matchEnvironment(entity: AccountEntity | CredentialEntity | AppMetadataEntity, environment: string): boolean {\n const cloudMetadata = this.getAuthorityMetadataByAlias(environment);\n if (cloudMetadata && cloudMetadata.aliases.indexOf(entity.environment) > -1) {\n return true;\n }\n\n return false;\n }\n\n /**\n * helper to match credential type\n * @param entity\n * @param credentialType\n */\n private matchCredentialType(entity: CredentialEntity, credentialType: string): boolean {\n return (entity.credentialType && credentialType.toLowerCase() === entity.credentialType.toLowerCase());\n }\n\n /**\n * helper to match client ids\n * @param entity\n * @param clientId\n */\n private matchClientId(entity: CredentialEntity | AppMetadataEntity, clientId: string): boolean {\n return !!(entity.clientId && clientId === entity.clientId);\n }\n\n /**\n * helper to match family ids\n * @param entity\n * @param familyId\n */\n private matchFamilyId(entity: CredentialEntity | AppMetadataEntity, familyId: string): boolean {\n return !!(entity.familyId && familyId === entity.familyId);\n }\n\n /**\n * helper to match realm\n * @param entity\n * @param realm\n */\n private matchRealm(entity: AccountEntity | CredentialEntity, realm: string): boolean {\n return !!(entity.realm && realm === entity.realm);\n }\n\n /**\n * Returns true if the target scopes are a subset of the current entity's scopes, false otherwise.\n * @param entity\n * @param target\n */\n private matchTarget(entity: CredentialEntity, target: string): boolean {\n const isNotAccessTokenCredential = (entity.credentialType !== CredentialType.ACCESS_TOKEN && entity.credentialType !== CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME);\n\n if ( isNotAccessTokenCredential || !entity.target) {\n return false;\n }\n\n const entityScopeSet: ScopeSet = ScopeSet.fromString(entity.target);\n const requestTargetScopeSet: ScopeSet = ScopeSet.fromString(target);\n\n if (!requestTargetScopeSet.containsOnlyOIDCScopes()) {\n requestTargetScopeSet.removeOIDCScopes(); // ignore OIDC scopes\n } else {\n requestTargetScopeSet.removeScope(Constants.OFFLINE_ACCESS_SCOPE);\n }\n return entityScopeSet.containsScopeSet(requestTargetScopeSet);\n }\n\n /**\n * returns if a given cache entity is of the type appmetadata\n * @param key\n */\n private isAppMetadata(key: string): boolean {\n return key.indexOf(APP_METADATA) !== -1;\n }\n\n /**\n * returns if a given cache entity is of the type authoritymetadata\n * @param key\n */\n protected isAuthorityMetadata(key: string): boolean {\n return key.indexOf(AUTHORITY_METADATA_CONSTANTS.CACHE_KEY) !== -1;\n }\n\n /**\n * returns cache key used for cloud instance metadata\n */\n generateAuthorityMetadataCacheKey(authority: string): string {\n return `${AUTHORITY_METADATA_CONSTANTS.CACHE_KEY}-${this.clientId}-${authority}`;\n }\n\n /**\n * Returns the specific credential (IdToken/AccessToken/RefreshToken) from the cache\n * @param key\n * @param credType\n */\n private getSpecificCredential(key: string, credType: string): ValidCredentialType | null {\n switch (credType) {\n case CredentialType.ID_TOKEN: {\n return this.getIdTokenCredential(key);\n }\n case CredentialType.ACCESS_TOKEN:\n case CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME: {\n return this.getAccessTokenCredential(key);\n }\n case CredentialType.REFRESH_TOKEN: {\n return this.getRefreshTokenCredential(key);\n }\n default:\n return null;\n }\n }\n\n /**\n * Helper to convert serialized data to object\n * @param obj\n * @param json\n */\n static toObject<T>(obj: T, json: object): T {\n for (const propertyName in json) {\n obj[propertyName] = json[propertyName];\n }\n return obj;\n }\n}\n\nexport class DefaultStorageClass extends CacheManager {\n setAccount(): void {\n const notImplErr = \"Storage interface - setAccount() has not been implemented for the cacheStorage interface.\";\n throw AuthError.createUnexpectedError(notImplErr);\n }\n getAccount(): AccountEntity {\n const notImplErr = \"Storage interface - getAccount() has not been implemented for the cacheStorage interface.\";\n throw AuthError.createUnexpectedError(notImplErr);\n }\n setIdTokenCredential(): void {\n const notImplErr = \"Storage interface - setIdTokenCredential() has not been implemented for the cacheStorage interface.\";\n throw AuthError.createUnexpectedError(notImplErr);\n }\n getIdTokenCredential(): IdTokenEntity {\n const notImplErr = \"Storage interface - getIdTokenCredential() has not been implemented for the cacheStorage interface.\";\n throw AuthError.createUnexpectedError(notImplErr);\n }\n setAccessTokenCredential(): void {\n const notImplErr = \"Storage interface - setAccessTokenCredential() has not been implemented for the cacheStorage interface.\";\n throw AuthError.createUnexpectedError(notImplErr);\n }\n getAccessTokenCredential(): AccessTokenEntity {\n const notImplErr = \"Storage interface - getAccessTokenCredential() has not been implemented for the cacheStorage interface.\";\n throw AuthError.createUnexpectedError(notImplErr);\n }\n setRefreshTokenCredential(): void {\n const notImplErr = \"Storage interface - setRefreshTokenCredential() has not been implemented for the cacheStorage interface.\";\n throw AuthError.createUnexpectedError(notImplErr);\n }\n getRefreshTokenCredential(): RefreshTokenEntity {\n const notImplErr = \"Storage interface - getRefreshTokenCredential() has not been implemented for the cacheStorage interface.\";\n throw AuthError.createUnexpectedError(notImplErr);\n }\n setAppMetadata(): void {\n const notImplErr = \"Storage interface - setAppMetadata() has not been implemented for the cacheStorage interface.\";\n throw AuthError.createUnexpectedError(notImplErr);\n }\n getAppMetadata(): AppMetadataEntity {\n const notImplErr = \"Storage interface - getAppMetadata() has not been implemented for the cacheStorage interface.\";\n throw AuthError.createUnexpectedError(notImplErr);\n }\n setServerTelemetry(): void {\n const notImplErr = \"Storage interface - setServerTelemetry() has not been implemented for the cacheStorage interface.\";\n throw AuthError.createUnexpectedError(notImplErr);\n }\n getServerTelemetry(): ServerTelemetryEntity {\n const notImplErr = \"Storage interface - getServerTelemetry() has not been implemented for the cacheStorage interface.\";\n throw AuthError.createUnexpectedError(notImplErr);\n }\n setAuthorityMetadata(): void {\n const notImplErr = \"Storage interface - setAuthorityMetadata() has not been implemented for the cacheStorage interface.\";\n throw AuthError.createUnexpectedError(notImplErr);\n }\n getAuthorityMetadata(): AuthorityMetadataEntity | null {\n const notImplErr = \"Storage interface - getAuthorityMetadata() has not been implemented for the cacheStorage interface.\";\n throw AuthError.createUnexpectedError(notImplErr);\n }\n getAuthorityMetadataKeys(): Array<string> {\n const notImplErr = \"Storage interface - getAuthorityMetadataKeys() has not been implemented for the cacheStorage interface.\";\n throw AuthError.createUnexpectedError(notImplErr);\n }\n setThrottlingCache(): void {\n const notImplErr = \"Storage interface - setThrottlingCache() has not been implemented for the cacheStorage interface.\";\n throw AuthError.createUnexpectedError(notImplErr);\n }\n getThrottlingCache(): ThrottlingEntity {\n const notImplErr = \"Storage interface - getThrottlingCache() has not been implemented for the cacheStorage interface.\";\n throw AuthError.createUnexpectedError(notImplErr);\n }\n removeItem(): boolean {\n const notImplErr = \"Storage interface - removeItem() has not been implemented for the cacheStorage interface.\";\n throw AuthError.createUnexpectedError(notImplErr);\n }\n containsKey(): boolean {\n const notImplErr = \"Storage interface - containsKey() has not been implemented for the cacheStorage interface.\";\n throw AuthError.createUnexpectedError(notImplErr);\n }\n getKeys(): string[] {\n const notImplErr = \"Storage interface - getKeys() has not been implemented for the cacheStorage interface.\";\n throw AuthError.createUnexpectedError(notImplErr);\n }\n clear(): void {\n const notImplErr = \"Storage interface - clear() has not been implemented for the cacheStorage interface.\";\n throw AuthError.createUnexpectedError(notImplErr);\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAAA;;;;AAyBA;;;;IAOI,sBAAY,QAAgB,EAAE,UAAmB;QAC7C,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;KAChC;;;;IAmID,qCAAc,GAAd;QAAA,iBAoBC;QAnBG,IAAM,eAAe,GAAiB,IAAI,CAAC,qBAAqB,EAAE,CAAC;QACnE,IAAM,aAAa,GAAoB,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,GAAG,CAAC,UAAA,UAAU,IAAI,OAAA,eAAe,CAAC,UAAU,CAAC,GAAA,CAAC,CAAC;QACnH,IAAM,WAAW,GAAG,aAAa,CAAC,MAAM,CAAC;QACzC,IAAI,WAAW,GAAG,CAAC,EAAE;YACjB,OAAO,EAAE,CAAC;SACb;aAAM;YACH,IAAM,WAAW,GAAG,aAAa,CAAC,GAAG,CAAc,UAAC,KAAK;gBACrD,IAAM,aAAa,GAAG,YAAY,CAAC,QAAQ,CAAgB,IAAI,aAAa,EAAE,EAAE,KAAK,CAAC,CAAC;gBACvF,IAAM,WAAW,GAAG,aAAa,CAAC,cAAc,EAAE,CAAC;gBACnD,IAAM,OAAO,GAAG,KAAI,CAAC,oBAAoB,CAAC,KAAI,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;gBACtE,IAAI,OAAO,IAAI,CAAC,WAAW,CAAC,aAAa,EAAE;oBACvC,WAAW,CAAC,aAAa,GAAG,IAAI,SAAS,CAAC,OAAO,CAAC,MAAM,EAAE,KAAI,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC;iBACrF;gBAED,OAAO,WAAW,CAAC;aAEtB,CAAC,CAAC;YACH,OAAO,WAAW,C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;QACI,IAAM,UAAU,GAAG,yGAAyG,CAAC;QAC7H,MAAM,SAAS,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC;KACrD;IACD,gDAAkB,GAAlB;QACI,IAAM,UAAU,GAAG,mGAAmG,CAAC;QACvH,MAAM,SAAS,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC;KACrD;IACD,gDAAkB,GAAlB;QACI,IAAM,UAAU,GAAG,mGAAmG,CAAC;QACvH,MAAM,SAAS,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC;KACrD;IACD,wCAAU,GAAV;QACI,IAAM,UAAU,GAAG,2FAA2F,CAAC;QAC/G,MAAM,SAAS,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC;KACrD;IACD,yCAAW,GAAX;QACI,IAAM,UAAU,GAAG,4FAA4F,CAAC;QAChH,MAAM,SAAS,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC;KACrD;IACD,qCAAO,GAAP;QACI,IAAM,UAAU,GAAG,wFAAwF,CAAC;QAC5G,MAAM,SAAS,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC;KACrD;IACD,mCAAK,GAAL;QACI,IAAM,UAAU,GAAG,sFAAsF,CAAC;QAC1G,MAAM,SAAS,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC;KACrD;IACL,0BAAC;AAAD,CArFA,CAAyC,YAAY;;;;"}
@@ -1,12 +1,12 @@
1
- /*! @azure/msal-common v4.5.0 2021-07-22 */
1
+ /*! @azure/msal-common v4.5.1 2021-08-02 */
2
2
  'use strict';
3
3
  import { __extends } from '../../_virtual/_tslib.js';
4
+ import { CredentialEntity } from './CredentialEntity.js';
4
5
  import { CredentialType, AuthenticationScheme } from '../../utils/Constants.js';
5
- import { ClientAuthError as ClientAuthError$1 } from '../../error/ClientAuthError.js';
6
- import { StringUtils as StringUtils$1 } from '../../utils/StringUtils.js';
7
- import { CredentialEntity as CredentialEntity$1 } from './CredentialEntity.js';
8
- import { AuthToken as AuthToken$1 } from '../../account/AuthToken.js';
9
- import { TimeUtils as TimeUtils$1 } from '../../utils/TimeUtils.js';
6
+ import { TimeUtils } from '../../utils/TimeUtils.js';
7
+ import { StringUtils } from '../../utils/StringUtils.js';
8
+ import { AuthToken } from '../../account/AuthToken.js';
9
+ import { ClientAuthError } from '../../error/ClientAuthError.js';
10
10
 
11
11
  /*
12
12
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -58,7 +58,7 @@ var AccessTokenEntity = /** @class */ (function (_super) {
58
58
  atEntity.homeAccountId = homeAccountId;
59
59
  atEntity.credentialType = CredentialType.ACCESS_TOKEN;
60
60
  atEntity.secret = accessToken;
61
- var currentTime = TimeUtils$1.nowSeconds();
61
+ var currentTime = TimeUtils.nowSeconds();
62
62
  atEntity.cachedAt = currentTime.toString();
63
63
  /*
64
64
  * Token expiry time.
@@ -74,14 +74,14 @@ var AccessTokenEntity = /** @class */ (function (_super) {
74
74
  atEntity.realm = tenantId;
75
75
  atEntity.target = scopes;
76
76
  atEntity.oboAssertion = oboAssertion;
77
- atEntity.tokenType = StringUtils$1.isEmpty(tokenType) ? AuthenticationScheme.BEARER : tokenType;
77
+ atEntity.tokenType = StringUtils.isEmpty(tokenType) ? AuthenticationScheme.BEARER : tokenType;
78
78
  // Create Access Token With AuthScheme instead of regular access token
79
79
  if (atEntity.tokenType === AuthenticationScheme.POP) {
80
80
  atEntity.credentialType = CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME;
81
81
  // Make sure keyId is present and add it to credential
82
- var tokenClaims = AuthToken$1.extractTokenClaims(accessToken, cryptoUtils);
82
+ var tokenClaims = AuthToken.extractTokenClaims(accessToken, cryptoUtils);
83
83
  if (!((_a = tokenClaims === null || tokenClaims === void 0 ? void 0 : tokenClaims.cnf) === null || _a === void 0 ? void 0 : _a.kid)) {
84
- throw ClientAuthError$1.createTokenClaimsRequiredError();
84
+ throw ClientAuthError.createTokenClaimsRequiredError();
85
85
  }
86
86
  atEntity.keyId = tokenClaims.cnf.kid;
87
87
  }
@@ -105,7 +105,7 @@ var AccessTokenEntity = /** @class */ (function (_super) {
105
105
  (entity["credentialType"] === CredentialType.ACCESS_TOKEN || entity["credentialType"] === CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME));
106
106
  };
107
107
  return AccessTokenEntity;
108
- }(CredentialEntity$1));
108
+ }(CredentialEntity));
109
109
 
110
110
  export { AccessTokenEntity };
111
111
  //# sourceMappingURL=AccessTokenEntity.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"AccessTokenEntity.js","sources":["../../../src/cache/entities/AccessTokenEntity.ts"],"sourcesContent":["/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport { CredentialEntity } from \"./CredentialEntity\";\r\nimport { CredentialType, AuthenticationScheme } from \"../../utils/Constants\";\r\nimport { TimeUtils } from \"../../utils/TimeUtils\";\r\nimport { StringUtils } from \"../../utils/StringUtils\";\r\nimport { ICrypto } from \"../../crypto/ICrypto\";\r\nimport { TokenClaims } from \"../../account/TokenClaims\";\r\nimport { AuthToken } from \"../../account/AuthToken\";\r\nimport { ClientAuthError } from \"../../error/ClientAuthError\";\r\n\r\n/**\r\n * ACCESS_TOKEN Credential Type\r\n *\r\n * Key:Value Schema:\r\n *\r\n * Key Example: uid.utid-login.microsoftonline.com-accesstoken-clientId-contoso.com-user.read\r\n *\r\n * Value Schema:\r\n * {\r\n * homeAccountId: home account identifier for the auth scheme,\r\n * environment: entity that issued the token, represented as a full host\r\n * credentialType: Type of credential as a string, can be one of the following: RefreshToken, AccessToken, IdToken, Password, Cookie, Certificate, Other\r\n * clientId: client ID of the application\r\n * secret: Actual credential as a string\r\n * familyId: Family ID identifier, usually only used for refresh tokens\r\n * realm: Full tenant or organizational identifier that the account belongs to\r\n * target: Permissions that are included in the token, or for refresh tokens, the resource identifier.\r\n * cachedAt: Absolute device time when entry was created in the cache.\r\n * expiresOn: Token expiry time, calculated based on current UTC time in seconds. Represented as a string.\r\n * extendedExpiresOn: Additional extended expiry time until when token is valid in case of server-side outage. Represented as string in UTC seconds.\r\n * keyId: used for POP and SSH tokenTypes\r\n * tokenType: Type of the token issued. Usually \"Bearer\"\r\n * }\r\n */\r\nexport class AccessTokenEntity extends CredentialEntity {\r\n realm: string;\r\n target: string;\r\n cachedAt: string;\r\n expiresOn: string;\r\n extendedExpiresOn?: string;\r\n refreshOn?: string;\r\n keyId?: string; // for POP and SSH tokenTypes\r\n tokenType?: string;\r\n\r\n /**\r\n * Create AccessTokenEntity\r\n * @param homeAccountId\r\n * @param environment\r\n * @param accessToken\r\n * @param clientId\r\n * @param tenantId\r\n * @param scopes\r\n * @param expiresOn\r\n * @param extExpiresOn\r\n */\r\n static createAccessTokenEntity(\r\n homeAccountId: string,\r\n environment: string,\r\n accessToken: string,\r\n clientId: string,\r\n tenantId: string,\r\n scopes: string,\r\n expiresOn: number,\r\n extExpiresOn: number,\r\n cryptoUtils: ICrypto,\r\n refreshOn?: number,\r\n tokenType?: string,\r\n oboAssertion?: string\r\n ): AccessTokenEntity {\r\n const atEntity: AccessTokenEntity = new AccessTokenEntity();\r\n\r\n atEntity.homeAccountId = homeAccountId;\r\n atEntity.credentialType = CredentialType.ACCESS_TOKEN;\r\n atEntity.secret = accessToken;\r\n\r\n const currentTime = TimeUtils.nowSeconds();\r\n atEntity.cachedAt = currentTime.toString();\r\n\r\n /*\r\n * Token expiry time.\r\n * This value should be  calculated based on the current UTC time measured locally and the value  expires_in Represented as a string in JSON.\r\n */\r\n atEntity.expiresOn = expiresOn.toString();\r\n atEntity.extendedExpiresOn = extExpiresOn.toString();\r\n if (refreshOn) {\r\n atEntity.refreshOn = refreshOn.toString();\r\n }\r\n\r\n atEntity.environment = environment;\r\n atEntity.clientId = clientId;\r\n atEntity.realm = tenantId;\r\n atEntity.target = scopes;\r\n atEntity.oboAssertion = oboAssertion;\r\n\r\n atEntity.tokenType = StringUtils.isEmpty(tokenType) ? AuthenticationScheme.BEARER : tokenType;\r\n\r\n // Create Access Token With AuthScheme instead of regular access token\r\n if (atEntity.tokenType === AuthenticationScheme.POP) {\r\n atEntity.credentialType = CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME;\r\n // Make sure keyId is present and add it to credential\r\n const tokenClaims: TokenClaims | null = AuthToken.extractTokenClaims(accessToken, cryptoUtils);\r\n if (!tokenClaims?.cnf?.kid) {\r\n throw ClientAuthError.createTokenClaimsRequiredError();\r\n }\r\n atEntity.keyId = tokenClaims.cnf.kid;\r\n }\r\n\r\n return atEntity;\r\n }\r\n\r\n /**\r\n * Validates an entity: checks for all expected params\r\n * @param entity\r\n */\r\n static isAccessTokenEntity(entity: object): boolean {\r\n\r\n if (!entity) {\r\n return false;\r\n }\r\n\r\n return (\r\n entity.hasOwnProperty(\"homeAccountId\") &&\r\n entity.hasOwnProperty(\"environment\") &&\r\n entity.hasOwnProperty(\"credentialType\") &&\r\n entity.hasOwnProperty(\"realm\") &&\r\n entity.hasOwnProperty(\"clientId\") &&\r\n entity.hasOwnProperty(\"secret\") &&\r\n entity.hasOwnProperty(\"target\") &&\r\n (entity[\"credentialType\"] === CredentialType.ACCESS_TOKEN || entity[\"credentialType\"] === CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME)\r\n );\r\n }\r\n}\r\n"],"names":["TimeUtils","StringUtils","AuthToken","ClientAuthError","CredentialEntity"],"mappings":";;;;;;;;;;AAAA;;;;AAcA;;;;;;;;;;;;;;;;;;;;;;;;;IAwBuC,qCAAgB;IAAvD;;KAiGC;;;;;;;;;;;;IA5EU,yCAAuB,GAA9B,UACI,aAAqB,EACrB,WAAmB,EACnB,WAAmB,EACnB,QAAgB,EAChB,QAAgB,EAChB,MAAc,EACd,SAAiB,EACjB,YAAoB,EACpB,WAAoB,EACpB,SAAkB,EAClB,SAAkB,EAClB,YAAqB;;QAErB,IAAM,QAAQ,GAAsB,IAAI,iBAAiB,EAAE,CAAC;QAE5D,QAAQ,CAAC,aAAa,GAAG,aAAa,C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AC;KACnB;;;;;IAMM,qCAAmB,GAA1B,UAA2B,MAAc;QAErC,IAAI,CAAC,MAAM,EAAE;YACT,OAAO,KAAK,CAAC;SAChB;QAED,QACI,MAAM,CAAC,cAAc,CAAC,eAAe,CAAC;YACtC,MAAM,CAAC,cAAc,CAAC,aAAa,CAAC;YACpC,MAAM,CAAC,cAAc,CAAC,gBAAgB,CAAC;YACvC,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC;YAC9B,MAAM,CAAC,cAAc,CAAC,UAAU,CAAC;YACjC,MAAM,CAAC,cAAc,CAAC,QAAQ,CAAC;YAC/B,MAAM,CAAC,cAAc,CAAC,QAAQ,CAAC;aAC9B,MAAM,CAAC,gBAAgB,CAAC,KAAK,cAAc,CAAC,YAAY,IAAI,MAAM,CAAC,gBAAgB,CAAC,KAAK,cAAc,CAAC,6BAA6B,CAAC,EACzI;KACL;IACL,wBAAC;AAAD,CAjGA,CAAuCC,kBAAgB;;;;"}
1
+ {"version":3,"file":"AccessTokenEntity.js","sources":["../../../src/cache/entities/AccessTokenEntity.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { CredentialEntity } from \"./CredentialEntity\";\nimport { CredentialType, AuthenticationScheme } from \"../../utils/Constants\";\nimport { TimeUtils } from \"../../utils/TimeUtils\";\nimport { StringUtils } from \"../../utils/StringUtils\";\nimport { ICrypto } from \"../../crypto/ICrypto\";\nimport { TokenClaims } from \"../../account/TokenClaims\";\nimport { AuthToken } from \"../../account/AuthToken\";\nimport { ClientAuthError } from \"../../error/ClientAuthError\";\n\n/**\n * ACCESS_TOKEN Credential Type\n *\n * Key:Value Schema:\n *\n * Key Example: uid.utid-login.microsoftonline.com-accesstoken-clientId-contoso.com-user.read\n *\n * Value Schema:\n * {\n * homeAccountId: home account identifier for the auth scheme,\n * environment: entity that issued the token, represented as a full host\n * credentialType: Type of credential as a string, can be one of the following: RefreshToken, AccessToken, IdToken, Password, Cookie, Certificate, Other\n * clientId: client ID of the application\n * secret: Actual credential as a string\n * familyId: Family ID identifier, usually only used for refresh tokens\n * realm: Full tenant or organizational identifier that the account belongs to\n * target: Permissions that are included in the token, or for refresh tokens, the resource identifier.\n * cachedAt: Absolute device time when entry was created in the cache.\n * expiresOn: Token expiry time, calculated based on current UTC time in seconds. Represented as a string.\n * extendedExpiresOn: Additional extended expiry time until when token is valid in case of server-side outage. Represented as string in UTC seconds.\n * keyId: used for POP and SSH tokenTypes\n * tokenType: Type of the token issued. Usually \"Bearer\"\n * }\n */\nexport class AccessTokenEntity extends CredentialEntity {\n realm: string;\n target: string;\n cachedAt: string;\n expiresOn: string;\n extendedExpiresOn?: string;\n refreshOn?: string;\n keyId?: string; // for POP and SSH tokenTypes\n tokenType?: string;\n\n /**\n * Create AccessTokenEntity\n * @param homeAccountId\n * @param environment\n * @param accessToken\n * @param clientId\n * @param tenantId\n * @param scopes\n * @param expiresOn\n * @param extExpiresOn\n */\n static createAccessTokenEntity(\n homeAccountId: string,\n environment: string,\n accessToken: string,\n clientId: string,\n tenantId: string,\n scopes: string,\n expiresOn: number,\n extExpiresOn: number,\n cryptoUtils: ICrypto,\n refreshOn?: number,\n tokenType?: string,\n oboAssertion?: string\n ): AccessTokenEntity {\n const atEntity: AccessTokenEntity = new AccessTokenEntity();\n\n atEntity.homeAccountId = homeAccountId;\n atEntity.credentialType = CredentialType.ACCESS_TOKEN;\n atEntity.secret = accessToken;\n\n const currentTime = TimeUtils.nowSeconds();\n atEntity.cachedAt = currentTime.toString();\n\n /*\n * Token expiry time.\n * This value should be  calculated based on the current UTC time measured locally and the value  expires_in Represented as a string in JSON.\n */\n atEntity.expiresOn = expiresOn.toString();\n atEntity.extendedExpiresOn = extExpiresOn.toString();\n if (refreshOn) {\n atEntity.refreshOn = refreshOn.toString();\n }\n\n atEntity.environment = environment;\n atEntity.clientId = clientId;\n atEntity.realm = tenantId;\n atEntity.target = scopes;\n atEntity.oboAssertion = oboAssertion;\n\n atEntity.tokenType = StringUtils.isEmpty(tokenType) ? AuthenticationScheme.BEARER : tokenType;\n\n // Create Access Token With AuthScheme instead of regular access token\n if (atEntity.tokenType === AuthenticationScheme.POP) {\n atEntity.credentialType = CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME;\n // Make sure keyId is present and add it to credential\n const tokenClaims: TokenClaims | null = AuthToken.extractTokenClaims(accessToken, cryptoUtils);\n if (!tokenClaims?.cnf?.kid) {\n throw ClientAuthError.createTokenClaimsRequiredError();\n }\n atEntity.keyId = tokenClaims.cnf.kid;\n }\n\n return atEntity;\n }\n\n /**\n * Validates an entity: checks for all expected params\n * @param entity\n */\n static isAccessTokenEntity(entity: object): boolean {\n\n if (!entity) {\n return false;\n }\n\n return (\n entity.hasOwnProperty(\"homeAccountId\") &&\n entity.hasOwnProperty(\"environment\") &&\n entity.hasOwnProperty(\"credentialType\") &&\n entity.hasOwnProperty(\"realm\") &&\n entity.hasOwnProperty(\"clientId\") &&\n entity.hasOwnProperty(\"secret\") &&\n entity.hasOwnProperty(\"target\") &&\n (entity[\"credentialType\"] === CredentialType.ACCESS_TOKEN || entity[\"credentialType\"] === CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME)\n );\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;AAAA;;;;AAcA;;;;;;;;;;;;;;;;;;;;;;;;;IAwBuC,qCAAgB;IAAvD;;KAiGC;;;;;;;;;;;;IA5EU,yCAAuB,GAA9B,UACI,aAAqB,EACrB,WAAmB,EACnB,WAAmB,EACnB,QAAgB,EAChB,QAAgB,EAChB,MAAc,EACd,SAAiB,EACjB,YAAoB,EACpB,WAAoB,EACpB,SAAkB,EAClB,SAAkB,EAClB,YAAqB;;QAErB,IAAM,QAAQ,GAAsB,IAAI,iBAAiB,EAAE,CAAC;QAE5D,QAAQ,CAAC,aAAa,GAAG,aAAa,CAAC;QACvC,QAAQ,CAAC,cAAc,GAAG,cAAc,CAAC,YAAY,CAAC;QACtD,QAAQ,CAAC,M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