@azure/msal-common 13.0.0 → 14.0.0-alpha.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 (289) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +62 -62
  3. package/dist/account/AccountInfo.d.ts +2 -2
  4. package/dist/account/AccountInfo.d.ts.map +1 -1
  5. package/dist/account/AuthToken.d.ts.map +1 -1
  6. package/dist/account/AuthToken.js +13 -14
  7. package/dist/account/AuthToken.js.map +1 -1
  8. package/dist/account/CcsCredential.d.ts +1 -1
  9. package/dist/account/CcsCredential.d.ts.map +1 -1
  10. package/dist/account/CcsCredential.js +1 -1
  11. package/dist/account/CcsCredential.js.map +1 -1
  12. package/dist/account/ClientCredentials.d.ts +2 -2
  13. package/dist/account/ClientCredentials.d.ts.map +1 -1
  14. package/dist/account/ClientInfo.d.ts +1 -1
  15. package/dist/account/ClientInfo.d.ts.map +1 -1
  16. package/dist/account/ClientInfo.js +6 -4
  17. package/dist/account/ClientInfo.js.map +1 -1
  18. package/dist/account/DecodedAuthToken.d.ts.map +1 -1
  19. package/dist/account/TokenClaims.d.ts +1 -1
  20. package/dist/account/TokenClaims.d.ts.map +1 -1
  21. package/dist/authority/Authority.d.ts.map +1 -1
  22. package/dist/authority/Authority.js +464 -546
  23. package/dist/authority/Authority.js.map +1 -1
  24. package/dist/authority/AuthorityFactory.d.ts.map +1 -1
  25. package/dist/authority/AuthorityFactory.js +19 -34
  26. package/dist/authority/AuthorityFactory.js.map +1 -1
  27. package/dist/authority/AuthorityMetadata.d.ts.map +1 -1
  28. package/dist/authority/AuthorityMetadata.js +873 -4
  29. package/dist/authority/AuthorityMetadata.js.map +1 -1
  30. package/dist/authority/AuthorityOptions.d.ts +1 -1
  31. package/dist/authority/AuthorityOptions.d.ts.map +1 -1
  32. package/dist/authority/AuthorityOptions.js +1 -1
  33. package/dist/authority/AuthorityOptions.js.map +1 -1
  34. package/dist/authority/AuthorityType.js +1 -1
  35. package/dist/authority/AuthorityType.js.map +1 -1
  36. package/dist/authority/AzureRegion.d.ts +1 -1
  37. package/dist/authority/AzureRegion.d.ts.map +1 -1
  38. package/dist/authority/AzureRegionConfiguration.d.ts +1 -1
  39. package/dist/authority/AzureRegionConfiguration.d.ts.map +1 -1
  40. package/dist/authority/CloudDiscoveryMetadata.d.ts +1 -1
  41. package/dist/authority/CloudDiscoveryMetadata.d.ts.map +1 -1
  42. package/dist/authority/CloudInstanceDiscoveryErrorResponse.d.ts +1 -1
  43. package/dist/authority/CloudInstanceDiscoveryErrorResponse.d.ts.map +1 -1
  44. package/dist/authority/CloudInstanceDiscoveryErrorResponse.js +1 -1
  45. package/dist/authority/CloudInstanceDiscoveryErrorResponse.js.map +1 -1
  46. package/dist/authority/CloudInstanceDiscoveryResponse.d.ts +1 -1
  47. package/dist/authority/CloudInstanceDiscoveryResponse.d.ts.map +1 -1
  48. package/dist/authority/CloudInstanceDiscoveryResponse.js +1 -1
  49. package/dist/authority/CloudInstanceDiscoveryResponse.js.map +1 -1
  50. package/dist/authority/ImdsOptions.d.ts +1 -1
  51. package/dist/authority/ImdsOptions.d.ts.map +1 -1
  52. package/dist/authority/OpenIdConfigResponse.d.ts +1 -1
  53. package/dist/authority/OpenIdConfigResponse.d.ts.map +1 -1
  54. package/dist/authority/OpenIdConfigResponse.js +1 -1
  55. package/dist/authority/OpenIdConfigResponse.js.map +1 -1
  56. package/dist/authority/ProtocolMode.js +1 -1
  57. package/dist/authority/ProtocolMode.js.map +1 -1
  58. package/dist/authority/RegionDiscovery.d.ts.map +1 -1
  59. package/dist/authority/RegionDiscovery.js +85 -107
  60. package/dist/authority/RegionDiscovery.js.map +1 -1
  61. package/dist/authority/RegionDiscoveryMetadata.d.ts +1 -1
  62. package/dist/authority/RegionDiscoveryMetadata.d.ts.map +1 -1
  63. package/dist/broker/nativeBroker/INativeBrokerPlugin.d.ts.map +1 -1
  64. package/dist/cache/CacheManager.d.ts.map +1 -1
  65. package/dist/cache/CacheManager.js +440 -475
  66. package/dist/cache/CacheManager.js.map +1 -1
  67. package/dist/cache/entities/AccessTokenEntity.d.ts.map +1 -1
  68. package/dist/cache/entities/AccessTokenEntity.js +21 -22
  69. package/dist/cache/entities/AccessTokenEntity.js.map +1 -1
  70. package/dist/cache/entities/AccountEntity.d.ts.map +1 -1
  71. package/dist/cache/entities/AccountEntity.js +78 -66
  72. package/dist/cache/entities/AccountEntity.js.map +1 -1
  73. package/dist/cache/entities/AppMetadataEntity.d.ts.map +1 -1
  74. package/dist/cache/entities/AppMetadataEntity.js +16 -17
  75. package/dist/cache/entities/AppMetadataEntity.js.map +1 -1
  76. package/dist/cache/entities/AuthorityMetadataEntity.d.ts.map +1 -1
  77. package/dist/cache/entities/AuthorityMetadataEntity.js +22 -19
  78. package/dist/cache/entities/AuthorityMetadataEntity.js.map +1 -1
  79. package/dist/cache/entities/CacheRecord.d.ts.map +1 -1
  80. package/dist/cache/entities/CacheRecord.js +4 -5
  81. package/dist/cache/entities/CacheRecord.js.map +1 -1
  82. package/dist/cache/entities/CredentialEntity.d.ts.map +1 -1
  83. package/dist/cache/entities/CredentialEntity.js +35 -34
  84. package/dist/cache/entities/CredentialEntity.js.map +1 -1
  85. package/dist/cache/entities/IdTokenEntity.d.ts.map +1 -1
  86. package/dist/cache/entities/IdTokenEntity.js +8 -14
  87. package/dist/cache/entities/IdTokenEntity.js.map +1 -1
  88. package/dist/cache/entities/RefreshTokenEntity.d.ts.map +1 -1
  89. package/dist/cache/entities/RefreshTokenEntity.js +8 -14
  90. package/dist/cache/entities/RefreshTokenEntity.js.map +1 -1
  91. package/dist/cache/entities/ServerTelemetryEntity.d.ts.map +1 -1
  92. package/dist/cache/entities/ServerTelemetryEntity.js +8 -9
  93. package/dist/cache/entities/ServerTelemetryEntity.js.map +1 -1
  94. package/dist/cache/entities/ThrottlingEntity.js +9 -11
  95. package/dist/cache/entities/ThrottlingEntity.js.map +1 -1
  96. package/dist/cache/interface/ICacheManager.d.ts.map +1 -1
  97. package/dist/cache/persistence/TokenCacheContext.d.ts.map +1 -1
  98. package/dist/cache/persistence/TokenCacheContext.js +16 -25
  99. package/dist/cache/persistence/TokenCacheContext.js.map +1 -1
  100. package/dist/cache/utils/CacheTypes.d.ts +11 -11
  101. package/dist/cache/utils/CacheTypes.d.ts.map +1 -1
  102. package/dist/client/AuthorizationCodeClient.d.ts.map +1 -1
  103. package/dist/client/AuthorizationCodeClient.js +341 -384
  104. package/dist/client/AuthorizationCodeClient.js.map +1 -1
  105. package/dist/client/BaseClient.d.ts.map +1 -1
  106. package/dist/client/BaseClient.js +27 -35
  107. package/dist/client/BaseClient.js.map +1 -1
  108. package/dist/client/RefreshTokenClient.d.ts.map +1 -1
  109. package/dist/client/RefreshTokenClient.js +208 -241
  110. package/dist/client/RefreshTokenClient.js.map +1 -1
  111. package/dist/client/SilentFlowClient.d.ts.map +1 -1
  112. package/dist/client/SilentFlowClient.js +77 -105
  113. package/dist/client/SilentFlowClient.js.map +1 -1
  114. package/dist/config/AppTokenProvider.d.ts +2 -2
  115. package/dist/config/AppTokenProvider.d.ts.map +1 -1
  116. package/dist/config/ClientConfiguration.d.ts +9 -9
  117. package/dist/config/ClientConfiguration.d.ts.map +1 -1
  118. package/dist/config/ClientConfiguration.js +40 -43
  119. package/dist/config/ClientConfiguration.js.map +1 -1
  120. package/dist/crypto/ICrypto.d.ts +2 -2
  121. package/dist/crypto/ICrypto.d.ts.map +1 -1
  122. package/dist/crypto/ICrypto.js +27 -58
  123. package/dist/crypto/ICrypto.js.map +1 -1
  124. package/dist/crypto/JoseHeader.d.ts +1 -1
  125. package/dist/crypto/JoseHeader.d.ts.map +1 -1
  126. package/dist/crypto/JoseHeader.js +8 -9
  127. package/dist/crypto/JoseHeader.js.map +1 -1
  128. package/dist/crypto/PopTokenGenerator.d.ts +2 -2
  129. package/dist/crypto/PopTokenGenerator.d.ts.map +1 -1
  130. package/dist/crypto/PopTokenGenerator.js +47 -71
  131. package/dist/crypto/PopTokenGenerator.js.map +1 -1
  132. package/dist/crypto/SignedHttpRequest.d.ts +1 -1
  133. package/dist/crypto/SignedHttpRequest.d.ts.map +1 -1
  134. package/dist/error/AuthError.d.ts.map +1 -1
  135. package/dist/error/AuthError.js +25 -28
  136. package/dist/error/AuthError.js.map +1 -1
  137. package/dist/error/ClientAuthError.d.ts +8 -0
  138. package/dist/error/ClientAuthError.d.ts.map +1 -1
  139. package/dist/error/ClientAuthError.js +187 -181
  140. package/dist/error/ClientAuthError.js.map +1 -1
  141. package/dist/error/ClientConfigurationError.d.ts.map +1 -1
  142. package/dist/error/ClientConfigurationError.js +82 -86
  143. package/dist/error/ClientConfigurationError.js.map +1 -1
  144. package/dist/error/InteractionRequiredAuthError.d.ts.map +1 -1
  145. package/dist/error/InteractionRequiredAuthError.js +36 -35
  146. package/dist/error/InteractionRequiredAuthError.js.map +1 -1
  147. package/dist/error/JoseHeaderError.d.ts.map +1 -1
  148. package/dist/error/JoseHeaderError.js +14 -18
  149. package/dist/error/JoseHeaderError.js.map +1 -1
  150. package/dist/error/ServerError.d.ts.map +1 -1
  151. package/dist/error/ServerError.js +7 -11
  152. package/dist/error/ServerError.js.map +1 -1
  153. package/dist/index.cjs.js +4221 -4476
  154. package/dist/index.cjs.js.map +1 -1
  155. package/dist/index.d.ts +20 -21
  156. package/dist/index.d.ts.map +1 -1
  157. package/dist/index.js +5 -6
  158. package/dist/index.js.map +1 -1
  159. package/dist/logger/Logger.d.ts +1 -1
  160. package/dist/logger/Logger.d.ts.map +1 -1
  161. package/dist/logger/Logger.js +70 -60
  162. package/dist/logger/Logger.js.map +1 -1
  163. package/dist/network/INetworkModule.d.ts +1 -1
  164. package/dist/network/INetworkModule.d.ts.map +1 -1
  165. package/dist/network/INetworkModule.js +7 -7
  166. package/dist/network/INetworkModule.js.map +1 -1
  167. package/dist/network/NetworkManager.d.ts +4 -3
  168. package/dist/network/NetworkManager.d.ts.map +1 -1
  169. package/dist/network/NetworkManager.js +21 -35
  170. package/dist/network/NetworkManager.js.map +1 -1
  171. package/dist/network/RequestThumbprint.d.ts +1 -1
  172. package/dist/network/RequestThumbprint.d.ts.map +1 -1
  173. package/dist/network/ThrottlingUtils.d.ts.map +1 -1
  174. package/dist/network/ThrottlingUtils.js +37 -36
  175. package/dist/network/ThrottlingUtils.js.map +1 -1
  176. package/dist/packageMetadata.d.ts +1 -1
  177. package/dist/packageMetadata.d.ts.map +1 -1
  178. package/dist/packageMetadata.js +3 -3
  179. package/dist/packageMetadata.js.map +1 -1
  180. package/dist/request/AuthenticationHeaderParser.d.ts.map +1 -1
  181. package/dist/request/AuthenticationHeaderParser.js +17 -18
  182. package/dist/request/AuthenticationHeaderParser.js.map +1 -1
  183. package/dist/request/BaseAuthRequest.d.ts +1 -1
  184. package/dist/request/BaseAuthRequest.d.ts.map +1 -1
  185. package/dist/request/CommonAuthorizationCodeRequest.d.ts +1 -1
  186. package/dist/request/CommonAuthorizationCodeRequest.d.ts.map +1 -1
  187. package/dist/request/CommonAuthorizationUrlRequest.d.ts +1 -1
  188. package/dist/request/CommonAuthorizationUrlRequest.d.ts.map +1 -1
  189. package/dist/request/CommonClientCredentialRequest.d.ts +1 -1
  190. package/dist/request/CommonClientCredentialRequest.d.ts.map +1 -1
  191. package/dist/request/CommonDeviceCodeRequest.d.ts +1 -1
  192. package/dist/request/CommonDeviceCodeRequest.d.ts.map +1 -1
  193. package/dist/request/CommonEndSessionRequest.d.ts +1 -1
  194. package/dist/request/CommonEndSessionRequest.d.ts.map +1 -1
  195. package/dist/request/CommonOnBehalfOfRequest.d.ts +1 -1
  196. package/dist/request/CommonOnBehalfOfRequest.d.ts.map +1 -1
  197. package/dist/request/CommonRefreshTokenRequest.d.ts +1 -1
  198. package/dist/request/CommonRefreshTokenRequest.d.ts.map +1 -1
  199. package/dist/request/CommonSilentFlowRequest.d.ts +1 -1
  200. package/dist/request/CommonSilentFlowRequest.d.ts.map +1 -1
  201. package/dist/request/CommonUsernamePasswordRequest.d.ts +1 -1
  202. package/dist/request/CommonUsernamePasswordRequest.d.ts.map +1 -1
  203. package/dist/request/NativeRequest.d.ts +1 -1
  204. package/dist/request/NativeRequest.d.ts.map +1 -1
  205. package/dist/request/NativeSignOutRequest.d.ts +1 -1
  206. package/dist/request/NativeSignOutRequest.d.ts.map +1 -1
  207. package/dist/request/RequestParameterBuilder.d.ts.map +1 -1
  208. package/dist/request/RequestParameterBuilder.js +111 -113
  209. package/dist/request/RequestParameterBuilder.js.map +1 -1
  210. package/dist/request/RequestValidator.d.ts.map +1 -1
  211. package/dist/request/RequestValidator.js +23 -28
  212. package/dist/request/RequestValidator.js.map +1 -1
  213. package/dist/request/ScopeSet.d.ts.map +1 -1
  214. package/dist/request/ScopeSet.js +70 -70
  215. package/dist/request/ScopeSet.js.map +1 -1
  216. package/dist/response/AuthenticationResult.d.ts +1 -1
  217. package/dist/response/AuthenticationResult.d.ts.map +1 -1
  218. package/dist/response/AuthorizationCodePayload.d.ts +1 -1
  219. package/dist/response/AuthorizationCodePayload.d.ts.map +1 -1
  220. package/dist/response/DeviceCodeResponse.d.ts +2 -2
  221. package/dist/response/DeviceCodeResponse.d.ts.map +1 -1
  222. package/dist/response/ExternalTokenResponse.d.ts +1 -1
  223. package/dist/response/ExternalTokenResponse.d.ts.map +1 -1
  224. package/dist/response/IMDSBadResponse.d.ts +1 -1
  225. package/dist/response/IMDSBadResponse.d.ts.map +1 -1
  226. package/dist/response/ResponseHandler.d.ts.map +1 -1
  227. package/dist/response/ResponseHandler.js +195 -180
  228. package/dist/response/ResponseHandler.js.map +1 -1
  229. package/dist/response/ServerAuthorizationCodeResponse.d.ts +1 -1
  230. package/dist/response/ServerAuthorizationCodeResponse.d.ts.map +1 -1
  231. package/dist/response/ServerAuthorizationTokenResponse.d.ts +1 -1
  232. package/dist/response/ServerAuthorizationTokenResponse.d.ts.map +1 -1
  233. package/dist/telemetry/performance/IPerformanceClient.d.ts +3 -4
  234. package/dist/telemetry/performance/IPerformanceClient.d.ts.map +1 -1
  235. package/dist/telemetry/performance/PerformanceClient.d.ts +2 -10
  236. package/dist/telemetry/performance/PerformanceClient.d.ts.map +1 -1
  237. package/dist/telemetry/performance/PerformanceClient.js +134 -129
  238. package/dist/telemetry/performance/PerformanceClient.js.map +1 -1
  239. package/dist/telemetry/performance/PerformanceEvent.d.ts +4 -4
  240. package/dist/telemetry/performance/PerformanceEvent.d.ts.map +1 -1
  241. package/dist/telemetry/performance/PerformanceEvent.js +2 -2
  242. package/dist/telemetry/performance/PerformanceEvent.js.map +1 -1
  243. package/dist/telemetry/performance/StubPerformanceClient.d.ts +5 -3
  244. package/dist/telemetry/performance/StubPerformanceClient.d.ts.map +1 -1
  245. package/dist/telemetry/performance/StubPerformanceClient.js +23 -32
  246. package/dist/telemetry/performance/StubPerformanceClient.js.map +1 -1
  247. package/dist/telemetry/server/ServerTelemetryManager.d.ts +1 -2
  248. package/dist/telemetry/server/ServerTelemetryManager.d.ts.map +1 -1
  249. package/dist/telemetry/server/ServerTelemetryManager.js +106 -68
  250. package/dist/telemetry/server/ServerTelemetryManager.js.map +1 -1
  251. package/dist/telemetry/server/ServerTelemetryRequest.d.ts +1 -1
  252. package/dist/telemetry/server/ServerTelemetryRequest.d.ts.map +1 -1
  253. package/dist/url/UrlString.d.ts.map +1 -1
  254. package/dist/url/UrlString.js +85 -74
  255. package/dist/url/UrlString.js.map +1 -1
  256. package/dist/utils/Constants.d.ts.map +1 -1
  257. package/dist/utils/Constants.js +28 -27
  258. package/dist/utils/Constants.js.map +1 -1
  259. package/dist/utils/MsalTypes.d.ts +1 -1
  260. package/dist/utils/MsalTypes.d.ts.map +1 -1
  261. package/dist/utils/ProtocolUtils.d.ts +2 -2
  262. package/dist/utils/ProtocolUtils.d.ts.map +1 -1
  263. package/dist/utils/ProtocolUtils.js +27 -24
  264. package/dist/utils/ProtocolUtils.js.map +1 -1
  265. package/dist/utils/StringUtils.d.ts.map +1 -1
  266. package/dist/utils/StringUtils.js +44 -42
  267. package/dist/utils/StringUtils.js.map +1 -1
  268. package/dist/utils/TimeUtils.d.ts.map +1 -1
  269. package/dist/utils/TimeUtils.js +16 -19
  270. package/dist/utils/TimeUtils.js.map +1 -1
  271. package/package.json +79 -76
  272. package/dist/_virtual/_tslib.js +0 -90
  273. package/dist/_virtual/_tslib.js.map +0 -1
  274. package/dist/client/ClientCredentialClient.d.ts +0 -38
  275. package/dist/client/ClientCredentialClient.d.ts.map +0 -1
  276. package/dist/client/ClientCredentialClient.js +0 -203
  277. package/dist/client/ClientCredentialClient.js.map +0 -1
  278. package/dist/client/DeviceCodeClient.d.ts +0 -57
  279. package/dist/client/DeviceCodeClient.d.ts.map +0 -1
  280. package/dist/client/DeviceCodeClient.js +0 -250
  281. package/dist/client/DeviceCodeClient.js.map +0 -1
  282. package/dist/client/OnBehalfOfClient.d.ts +0 -51
  283. package/dist/client/OnBehalfOfClient.d.ts.map +0 -1
  284. package/dist/client/OnBehalfOfClient.js +0 -248
  285. package/dist/client/OnBehalfOfClient.js.map +0 -1
  286. package/dist/client/UsernamePasswordClient.d.ts +0 -29
  287. package/dist/client/UsernamePasswordClient.d.ts.map +0 -1
  288. package/dist/client/UsernamePasswordClient.js +0 -129
  289. package/dist/client/UsernamePasswordClient.js.map +0 -1
@@ -1,6 +1,5 @@
1
- /*! @azure/msal-common v13.0.0 2023-05-01 */
1
+ /*! @azure/msal-common v14.0.0-alpha.1 2023-05-08 */
2
2
  'use strict';
3
- import { __awaiter, __generator, __assign, __extends } from '../_virtual/_tslib.js';
4
3
  import { Separators, CredentialType, AuthenticationScheme, THE_FAMILY_ID, APP_METADATA, AUTHORITY_METADATA_CONSTANTS } from '../utils/Constants.js';
5
4
  import { ScopeSet } from '../request/ScopeSet.js';
6
5
  import { AccountEntity } from './entities/AccountEntity.js';
@@ -16,8 +15,8 @@ import { name, version } from '../packageMetadata.js';
16
15
  /**
17
16
  * Interface class which implement cache storage functions used by MSAL to perform validity checks, and store tokens.
18
17
  */
19
- var CacheManager = /** @class */ (function () {
20
- function CacheManager(clientId, cryptoImpl, logger) {
18
+ class CacheManager {
19
+ constructor(clientId, cryptoImpl, logger) {
21
20
  this.clientId = clientId;
22
21
  this.cryptoImpl = cryptoImpl;
23
22
  this.commonLogger = logger.clone(name, version);
@@ -25,14 +24,13 @@ var CacheManager = /** @class */ (function () {
25
24
  /**
26
25
  * Returns all accounts in cache
27
26
  */
28
- CacheManager.prototype.getAllAccounts = function () {
29
- var _this = this;
30
- var allAccountKeys = this.getAccountKeys();
27
+ getAllAccounts() {
28
+ const allAccountKeys = this.getAccountKeys();
31
29
  if (allAccountKeys.length < 1) {
32
30
  return [];
33
31
  }
34
- var accountEntities = allAccountKeys.reduce(function (accounts, key) {
35
- var entity = _this.getAccount(key);
32
+ const accountEntities = allAccountKeys.reduce((accounts, key) => {
33
+ const entity = this.getAccount(key);
36
34
  if (!entity) {
37
35
  return accounts;
38
36
  }
@@ -43,112 +41,90 @@ var CacheManager = /** @class */ (function () {
43
41
  return [];
44
42
  }
45
43
  else {
46
- var allAccounts = accountEntities.map(function (accountEntity) {
47
- return _this.getAccountInfoFromEntity(accountEntity);
44
+ const allAccounts = accountEntities.map((accountEntity) => {
45
+ return this.getAccountInfoFromEntity(accountEntity);
48
46
  });
49
47
  return allAccounts;
50
48
  }
51
- };
49
+ }
52
50
  /**
53
51
  * Gets accountInfo object based on provided filters
54
52
  */
55
- CacheManager.prototype.getAccountInfoFilteredBy = function (accountFilter) {
56
- var allAccounts = this.getAccountsFilteredBy(accountFilter);
53
+ getAccountInfoFilteredBy(accountFilter) {
54
+ const allAccounts = this.getAccountsFilteredBy(accountFilter);
57
55
  if (allAccounts.length > 0) {
58
56
  return this.getAccountInfoFromEntity(allAccounts[0]);
59
57
  }
60
58
  else {
61
59
  return null;
62
60
  }
63
- };
64
- CacheManager.prototype.getAccountInfoFromEntity = function (accountEntity) {
65
- var accountInfo = accountEntity.getAccountInfo();
66
- var idToken = this.getIdToken(accountInfo);
61
+ }
62
+ getAccountInfoFromEntity(accountEntity) {
63
+ const accountInfo = accountEntity.getAccountInfo();
64
+ const idToken = this.getIdToken(accountInfo);
67
65
  if (idToken) {
68
66
  accountInfo.idToken = idToken.secret;
69
67
  accountInfo.idTokenClaims = new AuthToken(idToken.secret, this.cryptoImpl).claims;
70
68
  }
71
69
  return accountInfo;
72
- };
70
+ }
73
71
  /**
74
72
  * saves a cache record
75
73
  * @param cacheRecord
76
74
  */
77
- CacheManager.prototype.saveCacheRecord = function (cacheRecord) {
78
- return __awaiter(this, void 0, void 0, function () {
79
- return __generator(this, function (_a) {
80
- switch (_a.label) {
81
- case 0:
82
- if (!cacheRecord) {
83
- throw ClientAuthError.createNullOrUndefinedCacheRecord();
84
- }
85
- if (!!cacheRecord.account) {
86
- this.setAccount(cacheRecord.account);
87
- }
88
- if (!!cacheRecord.idToken) {
89
- this.setIdTokenCredential(cacheRecord.idToken);
90
- }
91
- if (!!!cacheRecord.accessToken) return [3 /*break*/, 2];
92
- return [4 /*yield*/, this.saveAccessToken(cacheRecord.accessToken)];
93
- case 1:
94
- _a.sent();
95
- _a.label = 2;
96
- case 2:
97
- if (!!cacheRecord.refreshToken) {
98
- this.setRefreshTokenCredential(cacheRecord.refreshToken);
99
- }
100
- if (!!cacheRecord.appMetadata) {
101
- this.setAppMetadata(cacheRecord.appMetadata);
102
- }
103
- return [2 /*return*/];
104
- }
105
- });
106
- });
107
- };
75
+ async saveCacheRecord(cacheRecord) {
76
+ if (!cacheRecord) {
77
+ throw ClientAuthError.createNullOrUndefinedCacheRecord();
78
+ }
79
+ if (!!cacheRecord.account) {
80
+ this.setAccount(cacheRecord.account);
81
+ }
82
+ if (!!cacheRecord.idToken) {
83
+ this.setIdTokenCredential(cacheRecord.idToken);
84
+ }
85
+ if (!!cacheRecord.accessToken) {
86
+ await this.saveAccessToken(cacheRecord.accessToken);
87
+ }
88
+ if (!!cacheRecord.refreshToken) {
89
+ this.setRefreshTokenCredential(cacheRecord.refreshToken);
90
+ }
91
+ if (!!cacheRecord.appMetadata) {
92
+ this.setAppMetadata(cacheRecord.appMetadata);
93
+ }
94
+ }
108
95
  /**
109
96
  * saves access token credential
110
97
  * @param credential
111
98
  */
112
- CacheManager.prototype.saveAccessToken = function (credential) {
113
- return __awaiter(this, void 0, void 0, function () {
114
- var accessTokenFilter, tokenKeys, currentScopes, removedAccessTokens;
115
- var _this = this;
116
- return __generator(this, function (_a) {
117
- switch (_a.label) {
118
- case 0:
119
- accessTokenFilter = {
120
- clientId: credential.clientId,
121
- credentialType: credential.credentialType,
122
- environment: credential.environment,
123
- homeAccountId: credential.homeAccountId,
124
- realm: credential.realm,
125
- tokenType: credential.tokenType,
126
- requestedClaimsHash: credential.requestedClaimsHash
127
- };
128
- tokenKeys = this.getTokenKeys();
129
- currentScopes = ScopeSet.fromString(credential.target);
130
- removedAccessTokens = [];
131
- tokenKeys.accessToken.forEach(function (key) {
132
- if (!_this.accessTokenKeyMatchesFilter(key, accessTokenFilter, false)) {
133
- return;
134
- }
135
- var tokenEntity = _this.getAccessTokenCredential(key);
136
- if (tokenEntity && _this.credentialMatchesFilter(tokenEntity, accessTokenFilter)) {
137
- var tokenScopeSet = ScopeSet.fromString(tokenEntity.target);
138
- if (tokenScopeSet.intersectingScopeSets(currentScopes)) {
139
- removedAccessTokens.push(_this.removeAccessToken(key));
140
- }
141
- }
142
- });
143
- return [4 /*yield*/, Promise.all(removedAccessTokens)];
144
- case 1:
145
- _a.sent();
146
- this.setAccessTokenCredential(credential);
147
- return [2 /*return*/];
99
+ async saveAccessToken(credential) {
100
+ const accessTokenFilter = {
101
+ clientId: credential.clientId,
102
+ credentialType: credential.credentialType,
103
+ environment: credential.environment,
104
+ homeAccountId: credential.homeAccountId,
105
+ realm: credential.realm,
106
+ tokenType: credential.tokenType,
107
+ requestedClaimsHash: credential.requestedClaimsHash,
108
+ };
109
+ const tokenKeys = this.getTokenKeys();
110
+ const currentScopes = ScopeSet.fromString(credential.target);
111
+ const removedAccessTokens = [];
112
+ tokenKeys.accessToken.forEach((key) => {
113
+ if (!this.accessTokenKeyMatchesFilter(key, accessTokenFilter, false)) {
114
+ return;
115
+ }
116
+ const tokenEntity = this.getAccessTokenCredential(key);
117
+ if (tokenEntity &&
118
+ this.credentialMatchesFilter(tokenEntity, accessTokenFilter)) {
119
+ const tokenScopeSet = ScopeSet.fromString(tokenEntity.target);
120
+ if (tokenScopeSet.intersectingScopeSets(currentScopes)) {
121
+ removedAccessTokens.push(this.removeAccessToken(key));
148
122
  }
149
- });
123
+ }
150
124
  });
151
- };
125
+ await Promise.all(removedAccessTokens);
126
+ this.setAccessTokenCredential(credential);
127
+ }
152
128
  /**
153
129
  * retrieve accounts matching all provided filters; if no filter is set, get all accounts
154
130
  * not checking for casing as keys are all generated in lower case, remember to convert to lower case if object properties are compared
@@ -156,41 +132,46 @@ var CacheManager = /** @class */ (function () {
156
132
  * @param environment
157
133
  * @param realm
158
134
  */
159
- CacheManager.prototype.getAccountsFilteredBy = function (accountFilter) {
160
- var _this = this;
161
- var allAccountKeys = this.getAccountKeys();
162
- var matchingAccounts = [];
163
- allAccountKeys.forEach(function (cacheKey) {
164
- if (!_this.isAccountKey(cacheKey, accountFilter.homeAccountId, accountFilter.realm)) {
135
+ getAccountsFilteredBy(accountFilter) {
136
+ const allAccountKeys = this.getAccountKeys();
137
+ const matchingAccounts = [];
138
+ allAccountKeys.forEach((cacheKey) => {
139
+ if (!this.isAccountKey(cacheKey, accountFilter.homeAccountId, accountFilter.realm)) {
165
140
  // Don't parse value if the key doesn't match the account filters
166
141
  return;
167
142
  }
168
- var entity = _this.getAccount(cacheKey);
143
+ const entity = this.getAccount(cacheKey);
169
144
  if (!entity) {
170
145
  return;
171
146
  }
172
- if (!!accountFilter.homeAccountId && !_this.matchHomeAccountId(entity, accountFilter.homeAccountId)) {
147
+ if (!!accountFilter.homeAccountId &&
148
+ !this.matchHomeAccountId(entity, accountFilter.homeAccountId)) {
173
149
  return;
174
150
  }
175
- if (!!accountFilter.localAccountId && !_this.matchLocalAccountId(entity, accountFilter.localAccountId)) {
151
+ if (!!accountFilter.localAccountId &&
152
+ !this.matchLocalAccountId(entity, accountFilter.localAccountId)) {
176
153
  return;
177
154
  }
178
- if (!!accountFilter.username && !_this.matchUsername(entity, accountFilter.username)) {
155
+ if (!!accountFilter.username &&
156
+ !this.matchUsername(entity, accountFilter.username)) {
179
157
  return;
180
158
  }
181
- if (!!accountFilter.environment && !_this.matchEnvironment(entity, accountFilter.environment)) {
159
+ if (!!accountFilter.environment &&
160
+ !this.matchEnvironment(entity, accountFilter.environment)) {
182
161
  return;
183
162
  }
184
- if (!!accountFilter.realm && !_this.matchRealm(entity, accountFilter.realm)) {
163
+ if (!!accountFilter.realm &&
164
+ !this.matchRealm(entity, accountFilter.realm)) {
185
165
  return;
186
166
  }
187
- if (!!accountFilter.nativeAccountId && !_this.matchNativeAccountId(entity, accountFilter.nativeAccountId)) {
167
+ if (!!accountFilter.nativeAccountId &&
168
+ !this.matchNativeAccountId(entity, accountFilter.nativeAccountId)) {
188
169
  return;
189
170
  }
190
171
  matchingAccounts.push(entity);
191
172
  });
192
173
  return matchingAccounts;
193
- };
174
+ }
194
175
  /**
195
176
  * Returns true if the given key matches our account key schema. Also matches homeAccountId and/or tenantId if provided
196
177
  * @param key
@@ -198,12 +179,13 @@ var CacheManager = /** @class */ (function () {
198
179
  * @param tenantId
199
180
  * @returns
200
181
  */
201
- CacheManager.prototype.isAccountKey = function (key, homeAccountId, tenantId) {
182
+ isAccountKey(key, homeAccountId, tenantId) {
202
183
  if (key.split(Separators.CACHE_KEY_SEPARATOR).length < 3) {
203
184
  // Account cache keys contain 3 items separated by '-' (each item may also contain '-')
204
185
  return false;
205
186
  }
206
- if (homeAccountId && !key.toLowerCase().includes(homeAccountId.toLowerCase())) {
187
+ if (homeAccountId &&
188
+ !key.toLowerCase().includes(homeAccountId.toLowerCase())) {
207
189
  return false;
208
190
  }
209
191
  if (tenantId && !key.toLowerCase().includes(tenantId.toLowerCase())) {
@@ -211,29 +193,34 @@ var CacheManager = /** @class */ (function () {
211
193
  }
212
194
  // Do not check environment as aliasing can cause false negatives
213
195
  return true;
214
- };
196
+ }
215
197
  /**
216
198
  * Returns true if the given key matches our credential key schema.
217
199
  * @param key
218
200
  */
219
- CacheManager.prototype.isCredentialKey = function (key) {
201
+ isCredentialKey(key) {
220
202
  if (key.split(Separators.CACHE_KEY_SEPARATOR).length < 6) {
221
203
  // Credential cache keys contain 6 items separated by '-' (each item may also contain '-')
222
204
  return false;
223
205
  }
224
- var lowerCaseKey = key.toLowerCase();
206
+ const lowerCaseKey = key.toLowerCase();
225
207
  // Credential keys must indicate what credential type they represent
226
- if (lowerCaseKey.indexOf(CredentialType.ID_TOKEN.toLowerCase()) === -1 &&
227
- lowerCaseKey.indexOf(CredentialType.ACCESS_TOKEN.toLowerCase()) === -1 &&
208
+ if (lowerCaseKey.indexOf(CredentialType.ID_TOKEN.toLowerCase()) ===
209
+ -1 &&
210
+ lowerCaseKey.indexOf(CredentialType.ACCESS_TOKEN.toLowerCase()) ===
211
+ -1 &&
228
212
  lowerCaseKey.indexOf(CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME.toLowerCase()) === -1 &&
229
- lowerCaseKey.indexOf(CredentialType.REFRESH_TOKEN.toLowerCase()) === -1) {
213
+ lowerCaseKey.indexOf(CredentialType.REFRESH_TOKEN.toLowerCase()) ===
214
+ -1) {
230
215
  return false;
231
216
  }
232
- if (lowerCaseKey.indexOf(CredentialType.REFRESH_TOKEN.toLowerCase()) > -1) {
217
+ if (lowerCaseKey.indexOf(CredentialType.REFRESH_TOKEN.toLowerCase()) >
218
+ -1) {
233
219
  // Refresh tokens must contain the client id or family id
234
- var clientIdValidation = "" + CredentialType.REFRESH_TOKEN + Separators.CACHE_KEY_SEPARATOR + this.clientId + Separators.CACHE_KEY_SEPARATOR;
235
- var familyIdValidation = "" + CredentialType.REFRESH_TOKEN + Separators.CACHE_KEY_SEPARATOR + THE_FAMILY_ID + Separators.CACHE_KEY_SEPARATOR;
236
- if (lowerCaseKey.indexOf(clientIdValidation.toLowerCase()) === -1 && lowerCaseKey.indexOf(familyIdValidation.toLowerCase()) === -1) {
220
+ const clientIdValidation = `${CredentialType.REFRESH_TOKEN}${Separators.CACHE_KEY_SEPARATOR}${this.clientId}${Separators.CACHE_KEY_SEPARATOR}`;
221
+ const familyIdValidation = `${CredentialType.REFRESH_TOKEN}${Separators.CACHE_KEY_SEPARATOR}${THE_FAMILY_ID}${Separators.CACHE_KEY_SEPARATOR}`;
222
+ if (lowerCaseKey.indexOf(clientIdValidation.toLowerCase()) === -1 &&
223
+ lowerCaseKey.indexOf(familyIdValidation.toLowerCase()) === -1) {
237
224
  return false;
238
225
  }
239
226
  }
@@ -242,34 +229,38 @@ var CacheManager = /** @class */ (function () {
242
229
  return false;
243
230
  }
244
231
  return true;
245
- };
232
+ }
246
233
  /**
247
234
  * Returns whether or not the given credential entity matches the filter
248
235
  * @param entity
249
236
  * @param filter
250
237
  * @returns
251
238
  */
252
- CacheManager.prototype.credentialMatchesFilter = function (entity, filter) {
239
+ credentialMatchesFilter(entity, filter) {
253
240
  if (!!filter.clientId && !this.matchClientId(entity, filter.clientId)) {
254
241
  return false;
255
242
  }
256
- if (!!filter.userAssertionHash && !this.matchUserAssertionHash(entity, filter.userAssertionHash)) {
243
+ if (!!filter.userAssertionHash &&
244
+ !this.matchUserAssertionHash(entity, filter.userAssertionHash)) {
257
245
  return false;
258
246
  }
259
247
  /*
260
248
  * homeAccountId can be undefined, and we want to filter out cached items that have a homeAccountId of ""
261
249
  * because we don't want a client_credential request to return a cached token that has a homeAccountId
262
250
  */
263
- if ((typeof filter.homeAccountId === "string") && !this.matchHomeAccountId(entity, filter.homeAccountId)) {
251
+ if (typeof filter.homeAccountId === "string" &&
252
+ !this.matchHomeAccountId(entity, filter.homeAccountId)) {
264
253
  return false;
265
254
  }
266
- if (!!filter.environment && !this.matchEnvironment(entity, filter.environment)) {
255
+ if (!!filter.environment &&
256
+ !this.matchEnvironment(entity, filter.environment)) {
267
257
  return false;
268
258
  }
269
259
  if (!!filter.realm && !this.matchRealm(entity, filter.realm)) {
270
260
  return false;
271
261
  }
272
- if (!!filter.credentialType && !this.matchCredentialType(entity, filter.credentialType)) {
262
+ if (!!filter.credentialType &&
263
+ !this.matchCredentialType(entity, filter.credentialType)) {
273
264
  return false;
274
265
  }
275
266
  if (!!filter.familyId && !this.matchFamilyId(entity, filter.familyId)) {
@@ -290,8 +281,10 @@ var CacheManager = /** @class */ (function () {
290
281
  }
291
282
  }
292
283
  // Access Token with Auth Scheme specific matching
293
- if (entity.credentialType === CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME) {
294
- if (!!filter.tokenType && !this.matchTokenType(entity, filter.tokenType)) {
284
+ if (entity.credentialType ===
285
+ CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME) {
286
+ if (!!filter.tokenType &&
287
+ !this.matchTokenType(entity, filter.tokenType)) {
295
288
  return false;
296
289
  }
297
290
  // KeyId (sshKid) in request must match cached SSH certificate keyId because SSH cert is bound to a specific key
@@ -302,58 +295,57 @@ var CacheManager = /** @class */ (function () {
302
295
  }
303
296
  }
304
297
  return true;
305
- };
298
+ }
306
299
  /**
307
300
  * retrieve appMetadata matching all provided filters; if no filter is set, get all appMetadata
308
301
  * @param filter
309
302
  */
310
- CacheManager.prototype.getAppMetadataFilteredBy = function (filter) {
303
+ getAppMetadataFilteredBy(filter) {
311
304
  return this.getAppMetadataFilteredByInternal(filter.environment, filter.clientId);
312
- };
305
+ }
313
306
  /**
314
307
  * Support function to help match appMetadata
315
308
  * @param environment
316
309
  * @param clientId
317
310
  */
318
- CacheManager.prototype.getAppMetadataFilteredByInternal = function (environment, clientId) {
319
- var _this = this;
320
- var allCacheKeys = this.getKeys();
321
- var matchingAppMetadata = {};
322
- allCacheKeys.forEach(function (cacheKey) {
311
+ getAppMetadataFilteredByInternal(environment, clientId) {
312
+ const allCacheKeys = this.getKeys();
313
+ const matchingAppMetadata = {};
314
+ allCacheKeys.forEach((cacheKey) => {
323
315
  // don't parse any non-appMetadata type cache entities
324
- if (!_this.isAppMetadata(cacheKey)) {
316
+ if (!this.isAppMetadata(cacheKey)) {
325
317
  return;
326
318
  }
327
319
  // Attempt retrieval
328
- var entity = _this.getAppMetadata(cacheKey);
320
+ const entity = this.getAppMetadata(cacheKey);
329
321
  if (!entity) {
330
322
  return;
331
323
  }
332
- if (!!environment && !_this.matchEnvironment(entity, environment)) {
324
+ if (!!environment && !this.matchEnvironment(entity, environment)) {
333
325
  return;
334
326
  }
335
- if (!!clientId && !_this.matchClientId(entity, clientId)) {
327
+ if (!!clientId && !this.matchClientId(entity, clientId)) {
336
328
  return;
337
329
  }
338
330
  matchingAppMetadata[cacheKey] = entity;
339
331
  });
340
332
  return matchingAppMetadata;
341
- };
333
+ }
342
334
  /**
343
335
  * retrieve authorityMetadata that contains a matching alias
344
336
  * @param filter
345
337
  */
346
- CacheManager.prototype.getAuthorityMetadataByAlias = function (host) {
347
- var _this = this;
348
- var allCacheKeys = this.getAuthorityMetadataKeys();
349
- var matchedEntity = null;
350
- allCacheKeys.forEach(function (cacheKey) {
338
+ getAuthorityMetadataByAlias(host) {
339
+ const allCacheKeys = this.getAuthorityMetadataKeys();
340
+ let matchedEntity = null;
341
+ allCacheKeys.forEach((cacheKey) => {
351
342
  // don't parse any non-authorityMetadata type cache entities
352
- if (!_this.isAuthorityMetadata(cacheKey) || cacheKey.indexOf(_this.clientId) === -1) {
343
+ if (!this.isAuthorityMetadata(cacheKey) ||
344
+ cacheKey.indexOf(this.clientId) === -1) {
353
345
  return;
354
346
  }
355
347
  // Attempt retrieval
356
- var entity = _this.getAuthorityMetadata(cacheKey);
348
+ const entity = this.getAuthorityMetadata(cacheKey);
357
349
  if (!entity) {
358
350
  return;
359
351
  }
@@ -363,137 +355,94 @@ var CacheManager = /** @class */ (function () {
363
355
  matchedEntity = entity;
364
356
  });
365
357
  return matchedEntity;
366
- };
358
+ }
367
359
  /**
368
360
  * Removes all accounts and related tokens from cache.
369
361
  */
370
- CacheManager.prototype.removeAllAccounts = function () {
371
- return __awaiter(this, void 0, void 0, function () {
372
- var allAccountKeys, removedAccounts;
373
- var _this = this;
374
- return __generator(this, function (_a) {
375
- switch (_a.label) {
376
- case 0:
377
- allAccountKeys = this.getAccountKeys();
378
- removedAccounts = [];
379
- allAccountKeys.forEach(function (cacheKey) {
380
- removedAccounts.push(_this.removeAccount(cacheKey));
381
- });
382
- return [4 /*yield*/, Promise.all(removedAccounts)];
383
- case 1:
384
- _a.sent();
385
- return [2 /*return*/];
386
- }
387
- });
362
+ async removeAllAccounts() {
363
+ const allAccountKeys = this.getAccountKeys();
364
+ const removedAccounts = [];
365
+ allAccountKeys.forEach((cacheKey) => {
366
+ removedAccounts.push(this.removeAccount(cacheKey));
388
367
  });
389
- };
368
+ await Promise.all(removedAccounts);
369
+ }
390
370
  /**
391
371
  * Removes the account and related tokens for a given account key
392
372
  * @param account
393
373
  */
394
- CacheManager.prototype.removeAccount = function (accountKey) {
395
- return __awaiter(this, void 0, void 0, function () {
396
- var account;
397
- return __generator(this, function (_a) {
398
- switch (_a.label) {
399
- case 0:
400
- account = this.getAccount(accountKey);
401
- if (!account) {
402
- throw ClientAuthError.createNoAccountFoundError();
403
- }
404
- return [4 /*yield*/, this.removeAccountContext(account)];
405
- case 1:
406
- _a.sent();
407
- this.removeItem(accountKey);
408
- return [2 /*return*/];
409
- }
410
- });
411
- });
412
- };
374
+ async removeAccount(accountKey) {
375
+ const account = this.getAccount(accountKey);
376
+ if (!account) {
377
+ return;
378
+ }
379
+ await this.removeAccountContext(account);
380
+ this.removeItem(accountKey);
381
+ }
413
382
  /**
414
383
  * Removes credentials associated with the provided account
415
384
  * @param account
416
385
  */
417
- CacheManager.prototype.removeAccountContext = function (account) {
418
- return __awaiter(this, void 0, void 0, function () {
419
- var allTokenKeys, accountId, removedCredentials;
420
- var _this = this;
421
- return __generator(this, function (_a) {
422
- switch (_a.label) {
423
- case 0:
424
- allTokenKeys = this.getTokenKeys();
425
- accountId = account.generateAccountId();
426
- removedCredentials = [];
427
- allTokenKeys.idToken.forEach(function (key) {
428
- if (key.indexOf(accountId) === 0) {
429
- _this.removeIdToken(key);
430
- }
431
- });
432
- allTokenKeys.accessToken.forEach(function (key) {
433
- if (key.indexOf(accountId) === 0) {
434
- removedCredentials.push(_this.removeAccessToken(key));
435
- }
436
- });
437
- allTokenKeys.refreshToken.forEach(function (key) {
438
- if (key.indexOf(accountId) === 0) {
439
- _this.removeRefreshToken(key);
440
- }
441
- });
442
- return [4 /*yield*/, Promise.all(removedCredentials)];
443
- case 1:
444
- _a.sent();
445
- return [2 /*return*/];
446
- }
447
- });
386
+ async removeAccountContext(account) {
387
+ const allTokenKeys = this.getTokenKeys();
388
+ const accountId = account.generateAccountId();
389
+ const removedCredentials = [];
390
+ allTokenKeys.idToken.forEach((key) => {
391
+ if (key.indexOf(accountId) === 0) {
392
+ this.removeIdToken(key);
393
+ }
394
+ });
395
+ allTokenKeys.accessToken.forEach((key) => {
396
+ if (key.indexOf(accountId) === 0) {
397
+ removedCredentials.push(this.removeAccessToken(key));
398
+ }
399
+ });
400
+ allTokenKeys.refreshToken.forEach((key) => {
401
+ if (key.indexOf(accountId) === 0) {
402
+ this.removeRefreshToken(key);
403
+ }
448
404
  });
449
- };
405
+ await Promise.all(removedCredentials);
406
+ }
450
407
  /**
451
408
  * returns a boolean if the given credential is removed
452
409
  * @param credential
453
410
  */
454
- CacheManager.prototype.removeAccessToken = function (key) {
455
- return __awaiter(this, void 0, void 0, function () {
456
- var credential, accessTokenWithAuthSchemeEntity, kid;
457
- return __generator(this, function (_a) {
458
- switch (_a.label) {
459
- case 0:
460
- credential = this.getAccessTokenCredential(key);
461
- if (!credential) {
462
- return [2 /*return*/];
463
- }
464
- if (!(credential.credentialType.toLowerCase() === CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME.toLowerCase())) return [3 /*break*/, 4];
465
- if (!(credential.tokenType === AuthenticationScheme.POP)) return [3 /*break*/, 4];
466
- accessTokenWithAuthSchemeEntity = credential;
467
- kid = accessTokenWithAuthSchemeEntity.keyId;
468
- if (!kid) return [3 /*break*/, 4];
469
- _a.label = 1;
470
- case 1:
471
- _a.trys.push([1, 3, , 4]);
472
- return [4 /*yield*/, this.cryptoImpl.removeTokenBindingKey(kid)];
473
- case 2:
474
- _a.sent();
475
- return [3 /*break*/, 4];
476
- case 3:
477
- _a.sent();
411
+ async removeAccessToken(key) {
412
+ const credential = this.getAccessTokenCredential(key);
413
+ if (!credential) {
414
+ return;
415
+ }
416
+ // Remove Token Binding Key from key store for PoP Tokens Credentials
417
+ if (credential.credentialType.toLowerCase() ===
418
+ CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME.toLowerCase()) {
419
+ if (credential.tokenType === AuthenticationScheme.POP) {
420
+ const accessTokenWithAuthSchemeEntity = credential;
421
+ const kid = accessTokenWithAuthSchemeEntity.keyId;
422
+ if (kid) {
423
+ try {
424
+ await this.cryptoImpl.removeTokenBindingKey(kid);
425
+ }
426
+ catch (error) {
478
427
  throw ClientAuthError.createBindingKeyNotRemovedError();
479
- case 4: return [2 /*return*/, this.removeItem(key)];
428
+ }
480
429
  }
481
- });
482
- });
483
- };
430
+ }
431
+ }
432
+ return this.removeItem(key);
433
+ }
484
434
  /**
485
435
  * Removes all app metadata objects from cache.
486
436
  */
487
- CacheManager.prototype.removeAppMetadata = function () {
488
- var _this = this;
489
- var allCacheKeys = this.getKeys();
490
- allCacheKeys.forEach(function (cacheKey) {
491
- if (_this.isAppMetadata(cacheKey)) {
492
- _this.removeItem(cacheKey);
437
+ removeAppMetadata() {
438
+ const allCacheKeys = this.getKeys();
439
+ allCacheKeys.forEach((cacheKey) => {
440
+ if (this.isAppMetadata(cacheKey)) {
441
+ this.removeItem(cacheKey);
493
442
  }
494
443
  });
495
444
  return true;
496
- };
445
+ }
497
446
  /**
498
447
  * Retrieve the cached credentials into a cacherecord
499
448
  * @param account
@@ -502,13 +451,13 @@ var CacheManager = /** @class */ (function () {
502
451
  * @param environment
503
452
  * @param authScheme
504
453
  */
505
- CacheManager.prototype.readCacheRecord = function (account, request, environment) {
506
- var tokenKeys = this.getTokenKeys();
507
- var cachedAccount = this.readAccountFromCache(account);
508
- var cachedIdToken = this.getIdToken(account, tokenKeys);
509
- var cachedAccessToken = this.getAccessToken(account, request, tokenKeys);
510
- var cachedRefreshToken = this.getRefreshToken(account, false, tokenKeys);
511
- var cachedAppMetadata = this.readAppMetadataFromCache(environment);
454
+ readCacheRecord(account, request, environment) {
455
+ const tokenKeys = this.getTokenKeys();
456
+ const cachedAccount = this.readAccountFromCache(account);
457
+ const cachedIdToken = this.getIdToken(account, tokenKeys);
458
+ const cachedAccessToken = this.getAccessToken(account, request, tokenKeys);
459
+ const cachedRefreshToken = this.getRefreshToken(account, false, tokenKeys);
460
+ const cachedAppMetadata = this.readAppMetadataFromCache(environment);
512
461
  if (cachedAccount && cachedIdToken) {
513
462
  cachedAccount.idTokenClaims = new AuthToken(cachedIdToken.secret, this.cryptoImpl).claims;
514
463
  }
@@ -519,32 +468,32 @@ var CacheManager = /** @class */ (function () {
519
468
  refreshToken: cachedRefreshToken,
520
469
  appMetadata: cachedAppMetadata,
521
470
  };
522
- };
471
+ }
523
472
  /**
524
473
  * Retrieve AccountEntity from cache
525
474
  * @param account
526
475
  */
527
- CacheManager.prototype.readAccountFromCache = function (account) {
528
- var accountKey = AccountEntity.generateAccountCacheKey(account);
476
+ readAccountFromCache(account) {
477
+ const accountKey = AccountEntity.generateAccountCacheKey(account);
529
478
  return this.getAccount(accountKey);
530
- };
479
+ }
531
480
  /**
532
481
  * Retrieve IdTokenEntity from cache
533
482
  * @param clientId
534
483
  * @param account
535
484
  * @param inputRealm
536
485
  */
537
- CacheManager.prototype.getIdToken = function (account, tokenKeys) {
486
+ getIdToken(account, tokenKeys) {
538
487
  this.commonLogger.trace("CacheManager - getIdToken called");
539
- var idTokenFilter = {
488
+ const idTokenFilter = {
540
489
  homeAccountId: account.homeAccountId,
541
490
  environment: account.environment,
542
491
  credentialType: CredentialType.ID_TOKEN,
543
492
  clientId: this.clientId,
544
493
  realm: account.tenantId,
545
494
  };
546
- var idTokens = this.getIdTokensByFilter(idTokenFilter, tokenKeys);
547
- var numIdTokens = idTokens.length;
495
+ const idTokens = this.getIdTokensByFilter(idTokenFilter, tokenKeys);
496
+ const numIdTokens = idTokens.length;
548
497
  if (numIdTokens < 1) {
549
498
  this.commonLogger.info("CacheManager:getIdToken - No token found");
550
499
  return null;
@@ -554,57 +503,61 @@ var CacheManager = /** @class */ (function () {
554
503
  }
555
504
  this.commonLogger.info("CacheManager:getIdToken - Returning id token");
556
505
  return idTokens[0];
557
- };
506
+ }
558
507
  /**
559
508
  * Gets all idTokens matching the given filter
560
509
  * @param filter
561
510
  * @returns
562
511
  */
563
- CacheManager.prototype.getIdTokensByFilter = function (filter, tokenKeys) {
564
- var _this = this;
565
- var idTokenKeys = tokenKeys && tokenKeys.idToken || this.getTokenKeys().idToken;
566
- var idTokens = [];
567
- idTokenKeys.forEach(function (key) {
568
- if (!_this.idTokenKeyMatchesFilter(key, __assign({ clientId: _this.clientId }, filter))) {
512
+ getIdTokensByFilter(filter, tokenKeys) {
513
+ const idTokenKeys = (tokenKeys && tokenKeys.idToken) || this.getTokenKeys().idToken;
514
+ const idTokens = [];
515
+ idTokenKeys.forEach((key) => {
516
+ if (!this.idTokenKeyMatchesFilter(key, {
517
+ clientId: this.clientId,
518
+ ...filter,
519
+ })) {
569
520
  return;
570
521
  }
571
- var idToken = _this.getIdTokenCredential(key);
572
- if (idToken && _this.credentialMatchesFilter(idToken, filter)) {
522
+ const idToken = this.getIdTokenCredential(key);
523
+ if (idToken && this.credentialMatchesFilter(idToken, filter)) {
573
524
  idTokens.push(idToken);
574
525
  }
575
526
  });
576
527
  return idTokens;
577
- };
528
+ }
578
529
  /**
579
530
  * Validate the cache key against filter before retrieving and parsing cache value
580
531
  * @param key
581
532
  * @param filter
582
533
  * @returns
583
534
  */
584
- CacheManager.prototype.idTokenKeyMatchesFilter = function (inputKey, filter) {
585
- var key = inputKey.toLowerCase();
586
- if (filter.clientId && key.indexOf(filter.clientId.toLowerCase()) === -1) {
535
+ idTokenKeyMatchesFilter(inputKey, filter) {
536
+ const key = inputKey.toLowerCase();
537
+ if (filter.clientId &&
538
+ key.indexOf(filter.clientId.toLowerCase()) === -1) {
587
539
  return false;
588
540
  }
589
- if (filter.homeAccountId && key.indexOf(filter.homeAccountId.toLowerCase()) === -1) {
541
+ if (filter.homeAccountId &&
542
+ key.indexOf(filter.homeAccountId.toLowerCase()) === -1) {
590
543
  return false;
591
544
  }
592
545
  return true;
593
- };
546
+ }
594
547
  /**
595
548
  * Removes idToken from the cache
596
549
  * @param key
597
550
  */
598
- CacheManager.prototype.removeIdToken = function (key) {
551
+ removeIdToken(key) {
599
552
  this.removeItem(key);
600
- };
553
+ }
601
554
  /**
602
555
  * Removes refresh token from the cache
603
556
  * @param key
604
557
  */
605
- CacheManager.prototype.removeRefreshToken = function (key) {
558
+ removeRefreshToken(key) {
606
559
  this.removeItem(key);
607
- };
560
+ }
608
561
  /**
609
562
  * Retrieve AccessTokenEntity from cache
610
563
  * @param clientId
@@ -612,17 +565,20 @@ var CacheManager = /** @class */ (function () {
612
565
  * @param scopes
613
566
  * @param authScheme
614
567
  */
615
- CacheManager.prototype.getAccessToken = function (account, request, tokenKeys) {
616
- var _this = this;
568
+ getAccessToken(account, request, tokenKeys) {
617
569
  this.commonLogger.trace("CacheManager - getAccessToken called");
618
- var scopes = ScopeSet.createSearchScopes(request.scopes);
619
- var authScheme = request.authenticationScheme || AuthenticationScheme.BEARER;
570
+ const scopes = ScopeSet.createSearchScopes(request.scopes);
571
+ const authScheme = request.authenticationScheme || AuthenticationScheme.BEARER;
620
572
  /*
621
573
  * Distinguish between Bearer and PoP/SSH token cache types
622
574
  * Cast to lowercase to handle "bearer" from ADFS
623
575
  */
624
- var credentialType = (authScheme && authScheme.toLowerCase() !== AuthenticationScheme.BEARER.toLowerCase()) ? CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME : CredentialType.ACCESS_TOKEN;
625
- var accessTokenFilter = {
576
+ const credentialType = authScheme &&
577
+ authScheme.toLowerCase() !==
578
+ AuthenticationScheme.BEARER.toLowerCase()
579
+ ? CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME
580
+ : CredentialType.ACCESS_TOKEN;
581
+ const accessTokenFilter = {
626
582
  homeAccountId: account.homeAccountId,
627
583
  environment: account.environment,
628
584
  credentialType: credentialType,
@@ -633,19 +589,21 @@ var CacheManager = /** @class */ (function () {
633
589
  keyId: request.sshKid,
634
590
  requestedClaimsHash: request.requestedClaimsHash,
635
591
  };
636
- var accessTokenKeys = tokenKeys && tokenKeys.accessToken || this.getTokenKeys().accessToken;
637
- var accessTokens = [];
638
- accessTokenKeys.forEach(function (key) {
592
+ const accessTokenKeys = (tokenKeys && tokenKeys.accessToken) ||
593
+ this.getTokenKeys().accessToken;
594
+ const accessTokens = [];
595
+ accessTokenKeys.forEach((key) => {
639
596
  // Validate key
640
- if (_this.accessTokenKeyMatchesFilter(key, accessTokenFilter, true)) {
641
- var accessToken = _this.getAccessTokenCredential(key);
597
+ if (this.accessTokenKeyMatchesFilter(key, accessTokenFilter, true)) {
598
+ const accessToken = this.getAccessTokenCredential(key);
642
599
  // Validate value
643
- if (accessToken && _this.credentialMatchesFilter(accessToken, accessTokenFilter)) {
600
+ if (accessToken &&
601
+ this.credentialMatchesFilter(accessToken, accessTokenFilter)) {
644
602
  accessTokens.push(accessToken);
645
603
  }
646
604
  }
647
605
  });
648
- var numAccessTokens = accessTokens.length;
606
+ const numAccessTokens = accessTokens.length;
649
607
  if (numAccessTokens < 1) {
650
608
  this.commonLogger.info("CacheManager:getAccessToken - No token found");
651
609
  return null;
@@ -655,7 +613,7 @@ var CacheManager = /** @class */ (function () {
655
613
  }
656
614
  this.commonLogger.info("CacheManager:getAccessToken - Returning access token");
657
615
  return accessTokens[0];
658
- };
616
+ }
659
617
  /**
660
618
  * Validate the cache key against filter before retrieving and parsing cache value
661
619
  * @param key
@@ -663,85 +621,91 @@ var CacheManager = /** @class */ (function () {
663
621
  * @param keyMustContainAllScopes
664
622
  * @returns
665
623
  */
666
- CacheManager.prototype.accessTokenKeyMatchesFilter = function (inputKey, filter, keyMustContainAllScopes) {
667
- var key = inputKey.toLowerCase();
668
- if (filter.clientId && key.indexOf(filter.clientId.toLowerCase()) === -1) {
624
+ accessTokenKeyMatchesFilter(inputKey, filter, keyMustContainAllScopes) {
625
+ const key = inputKey.toLowerCase();
626
+ if (filter.clientId &&
627
+ key.indexOf(filter.clientId.toLowerCase()) === -1) {
669
628
  return false;
670
629
  }
671
- if (filter.homeAccountId && key.indexOf(filter.homeAccountId.toLowerCase()) === -1) {
630
+ if (filter.homeAccountId &&
631
+ key.indexOf(filter.homeAccountId.toLowerCase()) === -1) {
672
632
  return false;
673
633
  }
674
634
  if (filter.realm && key.indexOf(filter.realm.toLowerCase()) === -1) {
675
635
  return false;
676
636
  }
677
- if (filter.requestedClaimsHash && key.indexOf(filter.requestedClaimsHash.toLowerCase()) === -1) {
637
+ if (filter.requestedClaimsHash &&
638
+ key.indexOf(filter.requestedClaimsHash.toLowerCase()) === -1) {
678
639
  return false;
679
640
  }
680
641
  if (filter.target) {
681
- var scopes = filter.target.asArray();
682
- for (var i = 0; i < scopes.length; i++) {
683
- if (keyMustContainAllScopes && !key.includes(scopes[i].toLowerCase())) {
642
+ const scopes = filter.target.asArray();
643
+ for (let i = 0; i < scopes.length; i++) {
644
+ if (keyMustContainAllScopes &&
645
+ !key.includes(scopes[i].toLowerCase())) {
684
646
  // When performing a cache lookup a missing scope would be a cache miss
685
647
  return false;
686
648
  }
687
- else if (!keyMustContainAllScopes && key.includes(scopes[i].toLowerCase())) {
649
+ else if (!keyMustContainAllScopes &&
650
+ key.includes(scopes[i].toLowerCase())) {
688
651
  // When performing a cache write, any token with a subset of requested scopes should be replaced
689
652
  return true;
690
653
  }
691
654
  }
692
655
  }
693
656
  return true;
694
- };
657
+ }
695
658
  /**
696
659
  * Gets all access tokens matching the filter
697
660
  * @param filter
698
661
  * @returns
699
662
  */
700
- CacheManager.prototype.getAccessTokensByFilter = function (filter) {
701
- var _this = this;
702
- var tokenKeys = this.getTokenKeys();
703
- var accessTokens = [];
704
- tokenKeys.accessToken.forEach(function (key) {
705
- if (!_this.accessTokenKeyMatchesFilter(key, filter, true)) {
663
+ getAccessTokensByFilter(filter) {
664
+ const tokenKeys = this.getTokenKeys();
665
+ const accessTokens = [];
666
+ tokenKeys.accessToken.forEach((key) => {
667
+ if (!this.accessTokenKeyMatchesFilter(key, filter, true)) {
706
668
  return;
707
669
  }
708
- var accessToken = _this.getAccessTokenCredential(key);
709
- if (accessToken && _this.credentialMatchesFilter(accessToken, filter)) {
670
+ const accessToken = this.getAccessTokenCredential(key);
671
+ if (accessToken &&
672
+ this.credentialMatchesFilter(accessToken, filter)) {
710
673
  accessTokens.push(accessToken);
711
674
  }
712
675
  });
713
676
  return accessTokens;
714
- };
677
+ }
715
678
  /**
716
679
  * Helper to retrieve the appropriate refresh token from cache
717
680
  * @param clientId
718
681
  * @param account
719
682
  * @param familyRT
720
683
  */
721
- CacheManager.prototype.getRefreshToken = function (account, familyRT, tokenKeys) {
722
- var _this = this;
684
+ getRefreshToken(account, familyRT, tokenKeys) {
723
685
  this.commonLogger.trace("CacheManager - getRefreshToken called");
724
- var id = familyRT ? THE_FAMILY_ID : undefined;
725
- var refreshTokenFilter = {
686
+ const id = familyRT ? THE_FAMILY_ID : undefined;
687
+ const refreshTokenFilter = {
726
688
  homeAccountId: account.homeAccountId,
727
689
  environment: account.environment,
728
690
  credentialType: CredentialType.REFRESH_TOKEN,
729
691
  clientId: this.clientId,
730
692
  familyId: id,
731
693
  };
732
- var refreshTokenKeys = tokenKeys && tokenKeys.refreshToken || this.getTokenKeys().refreshToken;
733
- var refreshTokens = [];
734
- refreshTokenKeys.forEach(function (key) {
694
+ const refreshTokenKeys = (tokenKeys && tokenKeys.refreshToken) ||
695
+ this.getTokenKeys().refreshToken;
696
+ const refreshTokens = [];
697
+ refreshTokenKeys.forEach((key) => {
735
698
  // Validate key
736
- if (_this.refreshTokenKeyMatchesFilter(key, refreshTokenFilter)) {
737
- var refreshToken = _this.getRefreshTokenCredential(key);
699
+ if (this.refreshTokenKeyMatchesFilter(key, refreshTokenFilter)) {
700
+ const refreshToken = this.getRefreshTokenCredential(key);
738
701
  // Validate value
739
- if (refreshToken && _this.credentialMatchesFilter(refreshToken, refreshTokenFilter)) {
702
+ if (refreshToken &&
703
+ this.credentialMatchesFilter(refreshToken, refreshTokenFilter)) {
740
704
  refreshTokens.push(refreshToken);
741
705
  }
742
706
  }
743
707
  });
744
- var numRefreshTokens = refreshTokens.length;
708
+ const numRefreshTokens = refreshTokens.length;
745
709
  if (numRefreshTokens < 1) {
746
710
  this.commonLogger.info("CacheManager:getRefreshToken - No refresh token found.");
747
711
  return null;
@@ -749,37 +713,41 @@ var CacheManager = /** @class */ (function () {
749
713
  // address the else case after remove functions address environment aliases
750
714
  this.commonLogger.info("CacheManager:getRefreshToken - returning refresh token");
751
715
  return refreshTokens[0];
752
- };
716
+ }
753
717
  /**
754
718
  * Validate the cache key against filter before retrieving and parsing cache value
755
719
  * @param key
756
720
  * @param filter
757
721
  */
758
- CacheManager.prototype.refreshTokenKeyMatchesFilter = function (inputKey, filter) {
759
- var key = inputKey.toLowerCase();
760
- if (filter.familyId && key.indexOf(filter.familyId.toLowerCase()) === -1) {
722
+ refreshTokenKeyMatchesFilter(inputKey, filter) {
723
+ const key = inputKey.toLowerCase();
724
+ if (filter.familyId &&
725
+ key.indexOf(filter.familyId.toLowerCase()) === -1) {
761
726
  return false;
762
727
  }
763
728
  // If familyId is used, clientId is not in the key
764
- if (!filter.familyId && filter.clientId && key.indexOf(filter.clientId.toLowerCase()) === -1) {
729
+ if (!filter.familyId &&
730
+ filter.clientId &&
731
+ key.indexOf(filter.clientId.toLowerCase()) === -1) {
765
732
  return false;
766
733
  }
767
- if (filter.homeAccountId && key.indexOf(filter.homeAccountId.toLowerCase()) === -1) {
734
+ if (filter.homeAccountId &&
735
+ key.indexOf(filter.homeAccountId.toLowerCase()) === -1) {
768
736
  return false;
769
737
  }
770
738
  return true;
771
- };
739
+ }
772
740
  /**
773
741
  * Retrieve AppMetadataEntity from cache
774
742
  */
775
- CacheManager.prototype.readAppMetadataFromCache = function (environment) {
776
- var appMetadataFilter = {
777
- environment: environment,
743
+ readAppMetadataFromCache(environment) {
744
+ const appMetadataFilter = {
745
+ environment,
778
746
  clientId: this.clientId,
779
747
  };
780
- var appMetadata = this.getAppMetadataFilteredBy(appMetadataFilter);
781
- var appMetadataEntries = Object.keys(appMetadata).map(function (key) { return appMetadata[key]; });
782
- var numAppMetadata = appMetadataEntries.length;
748
+ const appMetadata = this.getAppMetadataFilteredBy(appMetadataFilter);
749
+ const appMetadataEntries = Object.keys(appMetadata).map((key) => appMetadata[key]);
750
+ const numAppMetadata = appMetadataEntries.length;
783
751
  if (numAppMetadata < 1) {
784
752
  return null;
785
753
  }
@@ -787,273 +755,270 @@ var CacheManager = /** @class */ (function () {
787
755
  throw ClientAuthError.createMultipleMatchingAppMetadataInCacheError();
788
756
  }
789
757
  return appMetadataEntries[0];
790
- };
758
+ }
791
759
  /**
792
760
  * Return the family_id value associated with FOCI
793
761
  * @param environment
794
762
  * @param clientId
795
763
  */
796
- CacheManager.prototype.isAppMetadataFOCI = function (environment) {
797
- var appMetadata = this.readAppMetadataFromCache(environment);
764
+ isAppMetadataFOCI(environment) {
765
+ const appMetadata = this.readAppMetadataFromCache(environment);
798
766
  return !!(appMetadata && appMetadata.familyId === THE_FAMILY_ID);
799
- };
767
+ }
800
768
  /**
801
769
  * helper to match account ids
802
770
  * @param value
803
771
  * @param homeAccountId
804
772
  */
805
- CacheManager.prototype.matchHomeAccountId = function (entity, homeAccountId) {
806
- return !!((typeof entity.homeAccountId === "string") && (homeAccountId === entity.homeAccountId));
807
- };
773
+ matchHomeAccountId(entity, homeAccountId) {
774
+ return !!(typeof entity.homeAccountId === "string" &&
775
+ homeAccountId === entity.homeAccountId);
776
+ }
808
777
  /**
809
778
  * helper to match account ids
810
779
  * @param entity
811
780
  * @param localAccountId
812
781
  * @returns
813
782
  */
814
- CacheManager.prototype.matchLocalAccountId = function (entity, localAccountId) {
815
- return !!((typeof entity.localAccountId === "string") && (localAccountId === entity.localAccountId));
816
- };
783
+ matchLocalAccountId(entity, localAccountId) {
784
+ return !!(typeof entity.localAccountId === "string" &&
785
+ localAccountId === entity.localAccountId);
786
+ }
817
787
  /**
818
788
  * helper to match usernames
819
789
  * @param entity
820
790
  * @param username
821
791
  * @returns
822
792
  */
823
- CacheManager.prototype.matchUsername = function (entity, username) {
824
- return !!((typeof entity.username === "string") && (username.toLowerCase() === entity.username.toLowerCase()));
825
- };
793
+ matchUsername(entity, username) {
794
+ return !!(typeof entity.username === "string" &&
795
+ username.toLowerCase() === entity.username.toLowerCase());
796
+ }
826
797
  /**
827
798
  * helper to match assertion
828
799
  * @param value
829
800
  * @param oboAssertion
830
801
  */
831
- CacheManager.prototype.matchUserAssertionHash = function (entity, userAssertionHash) {
832
- return !!(entity.userAssertionHash && userAssertionHash === entity.userAssertionHash);
833
- };
802
+ matchUserAssertionHash(entity, userAssertionHash) {
803
+ return !!(entity.userAssertionHash &&
804
+ userAssertionHash === entity.userAssertionHash);
805
+ }
834
806
  /**
835
807
  * helper to match environment
836
808
  * @param value
837
809
  * @param environment
838
810
  */
839
- CacheManager.prototype.matchEnvironment = function (entity, environment) {
840
- var cloudMetadata = this.getAuthorityMetadataByAlias(environment);
841
- if (cloudMetadata && cloudMetadata.aliases.indexOf(entity.environment) > -1) {
811
+ matchEnvironment(entity, environment) {
812
+ const cloudMetadata = this.getAuthorityMetadataByAlias(environment);
813
+ if (cloudMetadata &&
814
+ cloudMetadata.aliases.indexOf(entity.environment) > -1) {
842
815
  return true;
843
816
  }
844
817
  return false;
845
- };
818
+ }
846
819
  /**
847
820
  * helper to match credential type
848
821
  * @param entity
849
822
  * @param credentialType
850
823
  */
851
- CacheManager.prototype.matchCredentialType = function (entity, credentialType) {
852
- return (entity.credentialType && credentialType.toLowerCase() === entity.credentialType.toLowerCase());
853
- };
824
+ matchCredentialType(entity, credentialType) {
825
+ return (entity.credentialType &&
826
+ credentialType.toLowerCase() === entity.credentialType.toLowerCase());
827
+ }
854
828
  /**
855
829
  * helper to match client ids
856
830
  * @param entity
857
831
  * @param clientId
858
832
  */
859
- CacheManager.prototype.matchClientId = function (entity, clientId) {
833
+ matchClientId(entity, clientId) {
860
834
  return !!(entity.clientId && clientId === entity.clientId);
861
- };
835
+ }
862
836
  /**
863
837
  * helper to match family ids
864
838
  * @param entity
865
839
  * @param familyId
866
840
  */
867
- CacheManager.prototype.matchFamilyId = function (entity, familyId) {
841
+ matchFamilyId(entity, familyId) {
868
842
  return !!(entity.familyId && familyId === entity.familyId);
869
- };
843
+ }
870
844
  /**
871
845
  * helper to match realm
872
846
  * @param entity
873
847
  * @param realm
874
848
  */
875
- CacheManager.prototype.matchRealm = function (entity, realm) {
849
+ matchRealm(entity, realm) {
876
850
  return !!(entity.realm && realm === entity.realm);
877
- };
851
+ }
878
852
  /**
879
853
  * helper to match nativeAccountId
880
854
  * @param entity
881
855
  * @param nativeAccountId
882
856
  * @returns boolean indicating the match result
883
857
  */
884
- CacheManager.prototype.matchNativeAccountId = function (entity, nativeAccountId) {
858
+ matchNativeAccountId(entity, nativeAccountId) {
885
859
  return !!(entity.nativeAccountId && nativeAccountId === entity.nativeAccountId);
886
- };
860
+ }
887
861
  /**
888
862
  * Returns true if the target scopes are a subset of the current entity's scopes, false otherwise.
889
863
  * @param entity
890
864
  * @param target
891
865
  */
892
- CacheManager.prototype.matchTarget = function (entity, target) {
893
- var isNotAccessTokenCredential = (entity.credentialType !== CredentialType.ACCESS_TOKEN && entity.credentialType !== CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME);
866
+ matchTarget(entity, target) {
867
+ const isNotAccessTokenCredential = entity.credentialType !== CredentialType.ACCESS_TOKEN &&
868
+ entity.credentialType !==
869
+ CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME;
894
870
  if (isNotAccessTokenCredential || !entity.target) {
895
871
  return false;
896
872
  }
897
- var entityScopeSet = ScopeSet.fromString(entity.target);
873
+ const entityScopeSet = ScopeSet.fromString(entity.target);
898
874
  return entityScopeSet.containsScopeSet(target);
899
- };
875
+ }
900
876
  /**
901
877
  * Returns true if the credential's tokenType or Authentication Scheme matches the one in the request, false otherwise
902
878
  * @param entity
903
879
  * @param tokenType
904
880
  */
905
- CacheManager.prototype.matchTokenType = function (entity, tokenType) {
881
+ matchTokenType(entity, tokenType) {
906
882
  return !!(entity.tokenType && entity.tokenType === tokenType);
907
- };
883
+ }
908
884
  /**
909
885
  * Returns true if the credential's keyId matches the one in the request, false otherwise
910
886
  * @param entity
911
887
  * @param tokenType
912
888
  */
913
- CacheManager.prototype.matchKeyId = function (entity, keyId) {
889
+ matchKeyId(entity, keyId) {
914
890
  return !!(entity.keyId && entity.keyId === keyId);
915
- };
891
+ }
916
892
  /**
917
893
  * returns if a given cache entity is of the type appmetadata
918
894
  * @param key
919
895
  */
920
- CacheManager.prototype.isAppMetadata = function (key) {
896
+ isAppMetadata(key) {
921
897
  return key.indexOf(APP_METADATA) !== -1;
922
- };
898
+ }
923
899
  /**
924
900
  * returns if a given cache entity is of the type authoritymetadata
925
901
  * @param key
926
902
  */
927
- CacheManager.prototype.isAuthorityMetadata = function (key) {
903
+ isAuthorityMetadata(key) {
928
904
  return key.indexOf(AUTHORITY_METADATA_CONSTANTS.CACHE_KEY) !== -1;
929
- };
905
+ }
930
906
  /**
931
907
  * returns cache key used for cloud instance metadata
932
908
  */
933
- CacheManager.prototype.generateAuthorityMetadataCacheKey = function (authority) {
934
- return AUTHORITY_METADATA_CONSTANTS.CACHE_KEY + "-" + this.clientId + "-" + authority;
935
- };
909
+ generateAuthorityMetadataCacheKey(authority) {
910
+ return `${AUTHORITY_METADATA_CONSTANTS.CACHE_KEY}-${this.clientId}-${authority}`;
911
+ }
936
912
  /**
937
913
  * Helper to convert serialized data to object
938
914
  * @param obj
939
915
  * @param json
940
916
  */
941
- CacheManager.toObject = function (obj, json) {
942
- for (var propertyName in json) {
917
+ static toObject(obj, json) {
918
+ for (const propertyName in json) {
943
919
  obj[propertyName] = json[propertyName];
944
920
  }
945
921
  return obj;
946
- };
947
- return CacheManager;
948
- }());
949
- var DefaultStorageClass = /** @class */ (function (_super) {
950
- __extends(DefaultStorageClass, _super);
951
- function DefaultStorageClass() {
952
- return _super !== null && _super.apply(this, arguments) || this;
953
- }
954
- DefaultStorageClass.prototype.setAccount = function () {
955
- var notImplErr = "Storage interface - setAccount() has not been implemented for the cacheStorage interface.";
922
+ }
923
+ }
924
+ class DefaultStorageClass extends CacheManager {
925
+ setAccount() {
926
+ const notImplErr = "Storage interface - setAccount() has not been implemented for the cacheStorage interface.";
956
927
  throw AuthError.createUnexpectedError(notImplErr);
957
- };
958
- DefaultStorageClass.prototype.getAccount = function () {
959
- var notImplErr = "Storage interface - getAccount() has not been implemented for the cacheStorage interface.";
928
+ }
929
+ getAccount() {
930
+ const notImplErr = "Storage interface - getAccount() has not been implemented for the cacheStorage interface.";
960
931
  throw AuthError.createUnexpectedError(notImplErr);
961
- };
962
- DefaultStorageClass.prototype.setIdTokenCredential = function () {
963
- var notImplErr = "Storage interface - setIdTokenCredential() has not been implemented for the cacheStorage interface.";
932
+ }
933
+ setIdTokenCredential() {
934
+ const notImplErr = "Storage interface - setIdTokenCredential() has not been implemented for the cacheStorage interface.";
964
935
  throw AuthError.createUnexpectedError(notImplErr);
965
- };
966
- DefaultStorageClass.prototype.getIdTokenCredential = function () {
967
- var notImplErr = "Storage interface - getIdTokenCredential() has not been implemented for the cacheStorage interface.";
936
+ }
937
+ getIdTokenCredential() {
938
+ const notImplErr = "Storage interface - getIdTokenCredential() has not been implemented for the cacheStorage interface.";
968
939
  throw AuthError.createUnexpectedError(notImplErr);
969
- };
970
- DefaultStorageClass.prototype.setAccessTokenCredential = function () {
971
- var notImplErr = "Storage interface - setAccessTokenCredential() has not been implemented for the cacheStorage interface.";
940
+ }
941
+ setAccessTokenCredential() {
942
+ const notImplErr = "Storage interface - setAccessTokenCredential() has not been implemented for the cacheStorage interface.";
972
943
  throw AuthError.createUnexpectedError(notImplErr);
973
- };
974
- DefaultStorageClass.prototype.getAccessTokenCredential = function () {
975
- var notImplErr = "Storage interface - getAccessTokenCredential() has not been implemented for the cacheStorage interface.";
944
+ }
945
+ getAccessTokenCredential() {
946
+ const notImplErr = "Storage interface - getAccessTokenCredential() has not been implemented for the cacheStorage interface.";
976
947
  throw AuthError.createUnexpectedError(notImplErr);
977
- };
978
- DefaultStorageClass.prototype.setRefreshTokenCredential = function () {
979
- var notImplErr = "Storage interface - setRefreshTokenCredential() has not been implemented for the cacheStorage interface.";
948
+ }
949
+ setRefreshTokenCredential() {
950
+ const notImplErr = "Storage interface - setRefreshTokenCredential() has not been implemented for the cacheStorage interface.";
980
951
  throw AuthError.createUnexpectedError(notImplErr);
981
- };
982
- DefaultStorageClass.prototype.getRefreshTokenCredential = function () {
983
- var notImplErr = "Storage interface - getRefreshTokenCredential() has not been implemented for the cacheStorage interface.";
952
+ }
953
+ getRefreshTokenCredential() {
954
+ const notImplErr = "Storage interface - getRefreshTokenCredential() has not been implemented for the cacheStorage interface.";
984
955
  throw AuthError.createUnexpectedError(notImplErr);
985
- };
986
- DefaultStorageClass.prototype.setAppMetadata = function () {
987
- var notImplErr = "Storage interface - setAppMetadata() has not been implemented for the cacheStorage interface.";
956
+ }
957
+ setAppMetadata() {
958
+ const notImplErr = "Storage interface - setAppMetadata() has not been implemented for the cacheStorage interface.";
988
959
  throw AuthError.createUnexpectedError(notImplErr);
989
- };
990
- DefaultStorageClass.prototype.getAppMetadata = function () {
991
- var notImplErr = "Storage interface - getAppMetadata() has not been implemented for the cacheStorage interface.";
960
+ }
961
+ getAppMetadata() {
962
+ const notImplErr = "Storage interface - getAppMetadata() has not been implemented for the cacheStorage interface.";
963
+ throw AuthError.createUnexpectedError(notImplErr);
964
+ }
965
+ setServerTelemetry() {
966
+ const notImplErr = "Storage interface - setServerTelemetry() has not been implemented for the cacheStorage interface.";
992
967
  throw AuthError.createUnexpectedError(notImplErr);
993
- };
994
- DefaultStorageClass.prototype.setServerTelemetry = function () {
995
- var notImplErr = "Storage interface - setServerTelemetry() has not been implemented for the cacheStorage interface.";
968
+ }
969
+ getServerTelemetry() {
970
+ const notImplErr = "Storage interface - getServerTelemetry() has not been implemented for the cacheStorage interface.";
996
971
  throw AuthError.createUnexpectedError(notImplErr);
997
- };
998
- DefaultStorageClass.prototype.getServerTelemetry = function () {
999
- var notImplErr = "Storage interface - getServerTelemetry() has not been implemented for the cacheStorage interface.";
972
+ }
973
+ setAuthorityMetadata() {
974
+ const notImplErr = "Storage interface - setAuthorityMetadata() has not been implemented for the cacheStorage interface.";
1000
975
  throw AuthError.createUnexpectedError(notImplErr);
1001
- };
1002
- DefaultStorageClass.prototype.setAuthorityMetadata = function () {
1003
- var notImplErr = "Storage interface - setAuthorityMetadata() has not been implemented for the cacheStorage interface.";
976
+ }
977
+ getAuthorityMetadata() {
978
+ const notImplErr = "Storage interface - getAuthorityMetadata() has not been implemented for the cacheStorage interface.";
1004
979
  throw AuthError.createUnexpectedError(notImplErr);
1005
- };
1006
- DefaultStorageClass.prototype.getAuthorityMetadata = function () {
1007
- var notImplErr = "Storage interface - getAuthorityMetadata() has not been implemented for the cacheStorage interface.";
980
+ }
981
+ getAuthorityMetadataKeys() {
982
+ const notImplErr = "Storage interface - getAuthorityMetadataKeys() has not been implemented for the cacheStorage interface.";
1008
983
  throw AuthError.createUnexpectedError(notImplErr);
1009
- };
1010
- DefaultStorageClass.prototype.getAuthorityMetadataKeys = function () {
1011
- var notImplErr = "Storage interface - getAuthorityMetadataKeys() has not been implemented for the cacheStorage interface.";
984
+ }
985
+ setThrottlingCache() {
986
+ const notImplErr = "Storage interface - setThrottlingCache() has not been implemented for the cacheStorage interface.";
1012
987
  throw AuthError.createUnexpectedError(notImplErr);
1013
- };
1014
- DefaultStorageClass.prototype.setThrottlingCache = function () {
1015
- var notImplErr = "Storage interface - setThrottlingCache() has not been implemented for the cacheStorage interface.";
988
+ }
989
+ getThrottlingCache() {
990
+ const notImplErr = "Storage interface - getThrottlingCache() has not been implemented for the cacheStorage interface.";
1016
991
  throw AuthError.createUnexpectedError(notImplErr);
1017
- };
1018
- DefaultStorageClass.prototype.getThrottlingCache = function () {
1019
- var notImplErr = "Storage interface - getThrottlingCache() has not been implemented for the cacheStorage interface.";
992
+ }
993
+ removeItem() {
994
+ const notImplErr = "Storage interface - removeItem() has not been implemented for the cacheStorage interface.";
1020
995
  throw AuthError.createUnexpectedError(notImplErr);
1021
- };
1022
- DefaultStorageClass.prototype.removeItem = function () {
1023
- var notImplErr = "Storage interface - removeItem() has not been implemented for the cacheStorage interface.";
996
+ }
997
+ containsKey() {
998
+ const notImplErr = "Storage interface - containsKey() has not been implemented for the cacheStorage interface.";
1024
999
  throw AuthError.createUnexpectedError(notImplErr);
1025
- };
1026
- DefaultStorageClass.prototype.containsKey = function () {
1027
- var notImplErr = "Storage interface - containsKey() has not been implemented for the cacheStorage interface.";
1000
+ }
1001
+ getKeys() {
1002
+ const notImplErr = "Storage interface - getKeys() has not been implemented for the cacheStorage interface.";
1028
1003
  throw AuthError.createUnexpectedError(notImplErr);
1029
- };
1030
- DefaultStorageClass.prototype.getKeys = function () {
1031
- var notImplErr = "Storage interface - getKeys() has not been implemented for the cacheStorage interface.";
1004
+ }
1005
+ getAccountKeys() {
1006
+ const notImplErr = "Storage interface - getAccountKeys() has not been implemented for the cacheStorage interface.";
1032
1007
  throw AuthError.createUnexpectedError(notImplErr);
1033
- };
1034
- DefaultStorageClass.prototype.getAccountKeys = function () {
1035
- var notImplErr = "Storage interface - getAccountKeys() has not been implemented for the cacheStorage interface.";
1008
+ }
1009
+ getTokenKeys() {
1010
+ const notImplErr = "Storage interface - getTokenKeys() has not been implemented for the cacheStorage interface.";
1036
1011
  throw AuthError.createUnexpectedError(notImplErr);
1037
- };
1038
- DefaultStorageClass.prototype.getTokenKeys = function () {
1039
- var notImplErr = "Storage interface - getTokenKeys() has not been implemented for the cacheStorage interface.";
1012
+ }
1013
+ async clear() {
1014
+ const notImplErr = "Storage interface - clear() has not been implemented for the cacheStorage interface.";
1040
1015
  throw AuthError.createUnexpectedError(notImplErr);
1041
- };
1042
- DefaultStorageClass.prototype.clear = function () {
1043
- return __awaiter(this, void 0, void 0, function () {
1044
- var notImplErr;
1045
- return __generator(this, function (_a) {
1046
- notImplErr = "Storage interface - clear() has not been implemented for the cacheStorage interface.";
1047
- throw AuthError.createUnexpectedError(notImplErr);
1048
- });
1049
- });
1050
- };
1051
- DefaultStorageClass.prototype.updateCredentialCacheKey = function () {
1052
- var notImplErr = "Storage interface - updateCredentialCacheKey() has not been implemented for the cacheStorage interface.";
1016
+ }
1017
+ updateCredentialCacheKey() {
1018
+ const notImplErr = "Storage interface - updateCredentialCacheKey() has not been implemented for the cacheStorage interface.";
1053
1019
  throw AuthError.createUnexpectedError(notImplErr);
1054
- };
1055
- return DefaultStorageClass;
1056
- }(CacheManager));
1020
+ }
1021
+ }
1057
1022
 
1058
1023
  export { CacheManager, DefaultStorageClass };
1059
1024
  //# sourceMappingURL=CacheManager.js.map