@azure/msal-common 4.5.1 → 5.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (164) hide show
  1. package/CHANGELOG.json +194 -0
  2. package/{changelog.md → CHANGELOG.md} +61 -1
  3. package/README.md +7 -6
  4. package/dist/_virtual/_tslib.js +1 -1
  5. package/dist/account/AuthToken.js +1 -1
  6. package/dist/account/CcsCredential.js +1 -1
  7. package/dist/account/ClientInfo.js +1 -1
  8. package/dist/account/TokenClaims.d.ts +5 -0
  9. package/dist/account/TokenClaims.d.ts.map +1 -1
  10. package/dist/authority/Authority.d.ts.map +1 -1
  11. package/dist/authority/Authority.js +8 -2
  12. package/dist/authority/Authority.js.map +1 -1
  13. package/dist/authority/AuthorityFactory.js +1 -1
  14. package/dist/authority/AuthorityType.js +1 -1
  15. package/dist/authority/CloudInstanceDiscoveryResponse.js +1 -1
  16. package/dist/authority/OpenIdConfigResponse.d.ts +1 -1
  17. package/dist/authority/OpenIdConfigResponse.d.ts.map +1 -1
  18. package/dist/authority/OpenIdConfigResponse.js +1 -2
  19. package/dist/authority/OpenIdConfigResponse.js.map +1 -1
  20. package/dist/authority/ProtocolMode.js +1 -1
  21. package/dist/authority/RegionDiscovery.js +1 -1
  22. package/dist/cache/CacheManager.d.ts +23 -9
  23. package/dist/cache/CacheManager.d.ts.map +1 -1
  24. package/dist/cache/CacheManager.js +206 -76
  25. package/dist/cache/CacheManager.js.map +1 -1
  26. package/dist/cache/entities/AccessTokenEntity.d.ts +3 -2
  27. package/dist/cache/entities/AccessTokenEntity.d.ts.map +1 -1
  28. package/dist/cache/entities/AccessTokenEntity.js +15 -9
  29. package/dist/cache/entities/AccessTokenEntity.js.map +1 -1
  30. package/dist/cache/entities/AccountEntity.d.ts +2 -2
  31. package/dist/cache/entities/AccountEntity.d.ts.map +1 -1
  32. package/dist/cache/entities/AccountEntity.js +8 -8
  33. package/dist/cache/entities/AccountEntity.js.map +1 -1
  34. package/dist/cache/entities/AppMetadataEntity.js +1 -1
  35. package/dist/cache/entities/AuthorityMetadataEntity.d.ts +1 -1
  36. package/dist/cache/entities/AuthorityMetadataEntity.d.ts.map +1 -1
  37. package/dist/cache/entities/AuthorityMetadataEntity.js +1 -2
  38. package/dist/cache/entities/AuthorityMetadataEntity.js.map +1 -1
  39. package/dist/cache/entities/CacheRecord.js +1 -1
  40. package/dist/cache/entities/CredentialEntity.d.ts +7 -3
  41. package/dist/cache/entities/CredentialEntity.d.ts.map +1 -1
  42. package/dist/cache/entities/CredentialEntity.js +13 -6
  43. package/dist/cache/entities/CredentialEntity.js.map +1 -1
  44. package/dist/cache/entities/IdTokenEntity.js +1 -1
  45. package/dist/cache/entities/RefreshTokenEntity.js +1 -1
  46. package/dist/cache/entities/ServerTelemetryEntity.js +1 -1
  47. package/dist/cache/entities/ThrottlingEntity.js +1 -1
  48. package/dist/cache/interface/ICacheManager.d.ts +5 -5
  49. package/dist/cache/interface/ICacheManager.d.ts.map +1 -1
  50. package/dist/cache/persistence/TokenCacheContext.js +1 -1
  51. package/dist/cache/utils/CacheTypes.d.ts +4 -1
  52. package/dist/cache/utils/CacheTypes.d.ts.map +1 -1
  53. package/dist/client/AuthorizationCodeClient.d.ts +2 -1
  54. package/dist/client/AuthorizationCodeClient.d.ts.map +1 -1
  55. package/dist/client/AuthorizationCodeClient.js +58 -21
  56. package/dist/client/AuthorizationCodeClient.js.map +1 -1
  57. package/dist/client/BaseClient.js +1 -1
  58. package/dist/client/ClientCredentialClient.d.ts.map +1 -1
  59. package/dist/client/ClientCredentialClient.js +8 -2
  60. package/dist/client/ClientCredentialClient.js.map +1 -1
  61. package/dist/client/DeviceCodeClient.d.ts.map +1 -1
  62. package/dist/client/DeviceCodeClient.js +15 -3
  63. package/dist/client/DeviceCodeClient.js.map +1 -1
  64. package/dist/client/OnBehalfOfClient.d.ts.map +1 -1
  65. package/dist/client/OnBehalfOfClient.js +8 -2
  66. package/dist/client/OnBehalfOfClient.js.map +1 -1
  67. package/dist/client/RefreshTokenClient.d.ts.map +1 -1
  68. package/dist/client/RefreshTokenClient.js +28 -11
  69. package/dist/client/RefreshTokenClient.js.map +1 -1
  70. package/dist/client/SilentFlowClient.d.ts.map +1 -1
  71. package/dist/client/SilentFlowClient.js +17 -12
  72. package/dist/client/SilentFlowClient.js.map +1 -1
  73. package/dist/client/UsernamePasswordClient.d.ts.map +1 -1
  74. package/dist/client/UsernamePasswordClient.js +8 -2
  75. package/dist/client/UsernamePasswordClient.js.map +1 -1
  76. package/dist/config/ClientConfiguration.d.ts.map +1 -1
  77. package/dist/config/ClientConfiguration.js +3 -2
  78. package/dist/config/ClientConfiguration.js.map +1 -1
  79. package/dist/crypto/ICrypto.d.ts +11 -1
  80. package/dist/crypto/ICrypto.d.ts.map +1 -1
  81. package/dist/crypto/ICrypto.js +19 -1
  82. package/dist/crypto/ICrypto.js.map +1 -1
  83. package/dist/crypto/PopTokenGenerator.d.ts +21 -4
  84. package/dist/crypto/PopTokenGenerator.d.ts.map +1 -1
  85. package/dist/crypto/PopTokenGenerator.js +37 -26
  86. package/dist/crypto/PopTokenGenerator.js.map +1 -1
  87. package/dist/error/AuthError.d.ts +5 -0
  88. package/dist/error/AuthError.d.ts.map +1 -1
  89. package/dist/error/AuthError.js +4 -1
  90. package/dist/error/AuthError.js.map +1 -1
  91. package/dist/error/ClientAuthError.d.ts +13 -4
  92. package/dist/error/ClientAuthError.d.ts.map +1 -1
  93. package/dist/error/ClientAuthError.js +18 -7
  94. package/dist/error/ClientAuthError.js.map +1 -1
  95. package/dist/error/ClientConfigurationError.d.ts +29 -0
  96. package/dist/error/ClientConfigurationError.d.ts.map +1 -1
  97. package/dist/error/ClientConfigurationError.js +43 -3
  98. package/dist/error/ClientConfigurationError.js.map +1 -1
  99. package/dist/error/InteractionRequiredAuthError.d.ts +24 -5
  100. package/dist/error/InteractionRequiredAuthError.d.ts.map +1 -1
  101. package/dist/error/InteractionRequiredAuthError.js +30 -9
  102. package/dist/error/InteractionRequiredAuthError.js.map +1 -1
  103. package/dist/error/ServerError.js +1 -1
  104. package/dist/index.cjs.js +641 -226
  105. package/dist/index.cjs.js.map +1 -1
  106. package/dist/index.d.ts +7 -2
  107. package/dist/index.d.ts.map +1 -1
  108. package/dist/index.js +6 -2
  109. package/dist/index.js.map +1 -1
  110. package/dist/logger/Logger.d.ts.map +1 -1
  111. package/dist/logger/Logger.js +5 -3
  112. package/dist/logger/Logger.js.map +1 -1
  113. package/dist/network/INetworkModule.js +1 -1
  114. package/dist/network/NetworkManager.js +1 -1
  115. package/dist/network/RequestThumbprint.d.ts +7 -0
  116. package/dist/network/RequestThumbprint.d.ts.map +1 -1
  117. package/dist/network/ThrottlingUtils.d.ts +2 -1
  118. package/dist/network/ThrottlingUtils.d.ts.map +1 -1
  119. package/dist/network/ThrottlingUtils.js +11 -5
  120. package/dist/network/ThrottlingUtils.js.map +1 -1
  121. package/dist/packageMetadata.d.ts +1 -1
  122. package/dist/packageMetadata.js +2 -2
  123. package/dist/packageMetadata.js.map +1 -1
  124. package/dist/request/AuthenticationHeaderParser.d.ts +20 -0
  125. package/dist/request/AuthenticationHeaderParser.d.ts.map +1 -0
  126. package/dist/request/AuthenticationHeaderParser.js +64 -0
  127. package/dist/request/AuthenticationHeaderParser.js.map +1 -0
  128. package/dist/request/BaseAuthRequest.d.ts +7 -1
  129. package/dist/request/BaseAuthRequest.d.ts.map +1 -1
  130. package/dist/request/CommonAuthorizationCodeRequest.d.ts +3 -0
  131. package/dist/request/CommonAuthorizationCodeRequest.d.ts.map +1 -1
  132. package/dist/request/CommonEndSessionRequest.d.ts +4 -0
  133. package/dist/request/CommonEndSessionRequest.d.ts.map +1 -1
  134. package/dist/request/RequestParameterBuilder.d.ts +4 -0
  135. package/dist/request/RequestParameterBuilder.d.ts.map +1 -1
  136. package/dist/request/RequestParameterBuilder.js +10 -1
  137. package/dist/request/RequestParameterBuilder.js.map +1 -1
  138. package/dist/request/RequestValidator.js +1 -1
  139. package/dist/request/ScopeSet.js +1 -1
  140. package/dist/response/AuthenticationResult.d.ts +3 -1
  141. package/dist/response/AuthenticationResult.d.ts.map +1 -1
  142. package/dist/response/ExternalTokenResponse.d.ts +15 -0
  143. package/dist/response/ExternalTokenResponse.d.ts.map +1 -0
  144. package/dist/response/ResponseHandler.d.ts +1 -1
  145. package/dist/response/ResponseHandler.d.ts.map +1 -1
  146. package/dist/response/ResponseHandler.js +21 -15
  147. package/dist/response/ResponseHandler.js.map +1 -1
  148. package/dist/response/ServerAuthorizationTokenResponse.d.ts +6 -2
  149. package/dist/response/ServerAuthorizationTokenResponse.d.ts.map +1 -1
  150. package/dist/telemetry/server/ServerTelemetryManager.js +1 -1
  151. package/dist/url/UrlString.d.ts +0 -6
  152. package/dist/url/UrlString.d.ts.map +1 -1
  153. package/dist/url/UrlString.js +3 -18
  154. package/dist/url/UrlString.js.map +1 -1
  155. package/dist/utils/Constants.d.ts +7 -3
  156. package/dist/utils/Constants.d.ts.map +1 -1
  157. package/dist/utils/Constants.js +6 -2
  158. package/dist/utils/Constants.js.map +1 -1
  159. package/dist/utils/ProtocolUtils.js +1 -1
  160. package/dist/utils/StringUtils.d.ts.map +1 -1
  161. package/dist/utils/StringUtils.js +12 -11
  162. package/dist/utils/StringUtils.js.map +1 -1
  163. package/dist/utils/TimeUtils.js +1 -1
  164. package/package.json +1 -1
@@ -125,7 +125,7 @@ export declare abstract class CacheManager implements ICacheManager {
125
125
  /**
126
126
  * Function which clears cache.
127
127
  */
128
- abstract clear(): void;
128
+ abstract clear(): Promise<void>;
129
129
  /**
130
130
  * Returns all accounts in cache
131
131
  */
@@ -134,7 +134,7 @@ export declare abstract class CacheManager implements ICacheManager {
134
134
  * saves a cache record
135
135
  * @param cacheRecord
136
136
  */
137
- saveCacheRecord(cacheRecord: CacheRecord): void;
137
+ saveCacheRecord(cacheRecord: CacheRecord): Promise<void>;
138
138
  /**
139
139
  * saves access token credential
140
140
  * @param credential
@@ -174,6 +174,8 @@ export declare abstract class CacheManager implements ICacheManager {
174
174
  * @param clientId
175
175
  * @param realm
176
176
  * @param target
177
+ * @param oboAssertion
178
+ * @param tokenType
177
179
  */
178
180
  private getCredentialsFilteredByInternal;
179
181
  /**
@@ -195,22 +197,22 @@ export declare abstract class CacheManager implements ICacheManager {
195
197
  /**
196
198
  * Removes all accounts and related tokens from cache.
197
199
  */
198
- removeAllAccounts(): boolean;
200
+ removeAllAccounts(): Promise<boolean>;
199
201
  /**
200
202
  * returns a boolean if the given account is removed
201
203
  * @param account
202
204
  */
203
- removeAccount(accountKey: string): boolean;
205
+ removeAccount(accountKey: string): Promise<boolean>;
204
206
  /**
205
207
  * returns a boolean if the given account is removed
206
208
  * @param account
207
209
  */
208
- removeAccountContext(account: AccountEntity): boolean;
210
+ removeAccountContext(account: AccountEntity): Promise<boolean>;
209
211
  /**
210
212
  * returns a boolean if the given credential is removed
211
213
  * @param credential
212
214
  */
213
- removeCredential(credential: CredentialEntity): boolean;
215
+ removeCredential(credential: CredentialEntity): Promise<boolean>;
214
216
  /**
215
217
  * Removes all app metadata objects from cache.
216
218
  */
@@ -223,7 +225,7 @@ export declare abstract class CacheManager implements ICacheManager {
223
225
  * @param environment
224
226
  * @param authScheme
225
227
  */
226
- readCacheRecord(account: AccountInfo, clientId: string, scopes: ScopeSet, environment: string, authScheme: AuthenticationScheme): CacheRecord;
228
+ readCacheRecord(account: AccountInfo, clientId: string, scopes: ScopeSet, environment: string, authScheme: AuthenticationScheme, keyId?: string): CacheRecord;
227
229
  /**
228
230
  * Retrieve AccountEntity from cache
229
231
  * @param account
@@ -243,7 +245,7 @@ export declare abstract class CacheManager implements ICacheManager {
243
245
  * @param scopes
244
246
  * @param authScheme
245
247
  */
246
- readAccessTokenFromCache(clientId: string, account: AccountInfo, scopes: ScopeSet, authScheme: AuthenticationScheme): AccessTokenEntity | null;
248
+ readAccessTokenFromCache(clientId: string, account: AccountInfo, scopes: ScopeSet, authScheme: AuthenticationScheme, keyId?: string): AccessTokenEntity | null;
247
249
  /**
248
250
  * Helper to retrieve the appropriate refresh token from cache
249
251
  * @param clientId
@@ -309,6 +311,18 @@ export declare abstract class CacheManager implements ICacheManager {
309
311
  * @param target
310
312
  */
311
313
  private matchTarget;
314
+ /**
315
+ * Returns true if the credential's tokenType or Authentication Scheme matches the one in the request, false otherwise
316
+ * @param entity
317
+ * @param tokenType
318
+ */
319
+ private matchTokenType;
320
+ /**
321
+ * Returns true if the credential's keyId matches the one in the request, false otherwise
322
+ * @param entity
323
+ * @param tokenType
324
+ */
325
+ private matchKeyId;
312
326
  /**
313
327
  * returns if a given cache entity is of the type appmetadata
314
328
  * @param key
@@ -357,6 +371,6 @@ export declare class DefaultStorageClass extends CacheManager {
357
371
  removeItem(): boolean;
358
372
  containsKey(): boolean;
359
373
  getKeys(): string[];
360
- clear(): void;
374
+ clear(): Promise<void>;
361
375
  }
362
376
  //# sourceMappingURL=CacheManager.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"CacheManager.d.ts","sourceRoot":"","sources":["../../src/cache/CacheManager.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,gBAAgB,EAAE,eAAe,EAAuB,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC9J,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAyG,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AACjK,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAEnE,OAAO,EAAE,aAAa,EAAE,MAA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AAI,IAAI;IAI5B,oBAAoB,IAAI,aAAa;IAIrC,wBAAwB,IAAI,IAAI;IAIhC,wBAAwB,IAAI,iBAAiB;IAI7C,yBAAyB,IAAI,IAAI;IAIjC,yBAAyB,IAAI,kBAAkB;IAI/C,cAAc,IAAI,IAAI;IAItB,cAAc,IAAI,iBAAiB;IAInC,kBAAkB,IAAI,IAAI;IAI1B,kBAAkB,IAAI,qBAAqB;IAI3C,oBAAoB,IAAI,IAAI;IAI5B,oBAAoB,IAAI,uBAAuB,GAAG,IAAI;IAItD,wBAAwB,IAAI,KAAK,CAAC,MAAM,CAAC;IAIzC,kBAAkB,IAAI,IAAI;IAI1B,kBAAkB,IAAI,gBAAgB;IAItC,UAAU,IAAI,OAAO;IAIrB,WAAW,IAAI,OAAO;IAItB,OAAO,IAAI,MAAM,EAAE;IAIb,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAI/B"}
@@ -1,7 +1,7 @@
1
- /*! @azure/msal-common v4.5.1 2021-08-02 */
1
+ /*! @azure/msal-common v5.2.0 2021-12-07 */
2
2
  'use strict';
3
- import { __extends } from '../_virtual/_tslib.js';
4
- import { Constants, CredentialType, CacheSchemaType, THE_FAMILY_ID, APP_METADATA, AUTHORITY_METADATA_CONSTANTS, AuthenticationScheme } from '../utils/Constants.js';
3
+ import { __awaiter, __generator, __extends } from '../_virtual/_tslib.js';
4
+ import { Constants, CredentialType, AuthenticationScheme, CacheSchemaType, THE_FAMILY_ID, APP_METADATA, AUTHORITY_METADATA_CONSTANTS } from '../utils/Constants.js';
5
5
  import { CredentialEntity } from './entities/CredentialEntity.js';
6
6
  import { ScopeSet } from '../request/ScopeSet.js';
7
7
  import { AccountEntity } from './entities/AccountEntity.js';
@@ -50,49 +50,75 @@ var CacheManager = /** @class */ (function () {
50
50
  * @param cacheRecord
51
51
  */
52
52
  CacheManager.prototype.saveCacheRecord = function (cacheRecord) {
53
- if (!cacheRecord) {
54
- throw ClientAuthError.createNullOrUndefinedCacheRecord();
55
- }
56
- if (!!cacheRecord.account) {
57
- this.setAccount(cacheRecord.account);
58
- }
59
- if (!!cacheRecord.idToken) {
60
- this.setIdTokenCredential(cacheRecord.idToken);
61
- }
62
- if (!!cacheRecord.accessToken) {
63
- this.saveAccessToken(cacheRecord.accessToken);
64
- }
65
- if (!!cacheRecord.refreshToken) {
66
- this.setRefreshTokenCredential(cacheRecord.refreshToken);
67
- }
68
- if (!!cacheRecord.appMetadata) {
69
- this.setAppMetadata(cacheRecord.appMetadata);
70
- }
53
+ return __awaiter(this, void 0, void 0, function () {
54
+ return __generator(this, function (_a) {
55
+ switch (_a.label) {
56
+ case 0:
57
+ if (!cacheRecord) {
58
+ throw ClientAuthError.createNullOrUndefinedCacheRecord();
59
+ }
60
+ if (!!cacheRecord.account) {
61
+ this.setAccount(cacheRecord.account);
62
+ }
63
+ if (!!cacheRecord.idToken) {
64
+ this.setIdTokenCredential(cacheRecord.idToken);
65
+ }
66
+ if (!!!cacheRecord.accessToken) return [3 /*break*/, 2];
67
+ return [4 /*yield*/, this.saveAccessToken(cacheRecord.accessToken)];
68
+ case 1:
69
+ _a.sent();
70
+ _a.label = 2;
71
+ case 2:
72
+ if (!!cacheRecord.refreshToken) {
73
+ this.setRefreshTokenCredential(cacheRecord.refreshToken);
74
+ }
75
+ if (!!cacheRecord.appMetadata) {
76
+ this.setAppMetadata(cacheRecord.appMetadata);
77
+ }
78
+ return [2 /*return*/];
79
+ }
80
+ });
81
+ });
71
82
  };
72
83
  /**
73
84
  * saves access token credential
74
85
  * @param credential
75
86
  */
76
87
  CacheManager.prototype.saveAccessToken = function (credential) {
77
- var _this = this;
78
- var currentTokenCache = this.getCredentialsFilteredBy({
79
- clientId: credential.clientId,
80
- credentialType: credential.credentialType,
81
- environment: credential.environment,
82
- homeAccountId: credential.homeAccountId,
83
- realm: credential.realm,
84
- });
85
- var currentScopes = ScopeSet.fromString(credential.target);
86
- var currentAccessTokens = Object.keys(currentTokenCache.accessTokens).map(function (key) { return currentTokenCache.accessTokens[key]; });
87
- if (currentAccessTokens) {
88
- currentAccessTokens.forEach(function (tokenEntity) {
89
- var tokenScopeSet = ScopeSet.fromString(tokenEntity.target);
90
- if (tokenScopeSet.intersectingScopeSets(currentScopes)) {
91
- _this.removeCredential(tokenEntity);
88
+ return __awaiter(this, void 0, void 0, function () {
89
+ var currentTokenCache, currentScopes, currentAccessTokens, removedAccessTokens_1;
90
+ var _this = this;
91
+ return __generator(this, function (_a) {
92
+ switch (_a.label) {
93
+ case 0:
94
+ currentTokenCache = this.getCredentialsFilteredBy({
95
+ clientId: credential.clientId,
96
+ credentialType: credential.credentialType,
97
+ environment: credential.environment,
98
+ homeAccountId: credential.homeAccountId,
99
+ realm: credential.realm,
100
+ tokenType: credential.tokenType
101
+ });
102
+ currentScopes = ScopeSet.fromString(credential.target);
103
+ currentAccessTokens = Object.keys(currentTokenCache.accessTokens).map(function (key) { return currentTokenCache.accessTokens[key]; });
104
+ if (!currentAccessTokens) return [3 /*break*/, 2];
105
+ removedAccessTokens_1 = [];
106
+ currentAccessTokens.forEach(function (tokenEntity) {
107
+ var tokenScopeSet = ScopeSet.fromString(tokenEntity.target);
108
+ if (tokenScopeSet.intersectingScopeSets(currentScopes)) {
109
+ removedAccessTokens_1.push(_this.removeCredential(tokenEntity));
110
+ }
111
+ });
112
+ return [4 /*yield*/, Promise.all(removedAccessTokens_1)];
113
+ case 1:
114
+ _a.sent();
115
+ _a.label = 2;
116
+ case 2:
117
+ this.setAccessTokenCredential(credential);
118
+ return [2 /*return*/];
92
119
  }
93
120
  });
94
- }
95
- this.setAccessTokenCredential(credential);
121
+ });
96
122
  };
97
123
  /**
98
124
  * retrieve accounts matching all provided filters; if no filter is set, get all accounts
@@ -143,7 +169,7 @@ var CacheManager = /** @class */ (function () {
143
169
  * @param target
144
170
  */
145
171
  CacheManager.prototype.getCredentialsFilteredBy = function (filter) {
146
- return this.getCredentialsFilteredByInternal(filter.homeAccountId, filter.environment, filter.credentialType, filter.clientId, filter.familyId, filter.realm, filter.target, filter.oboAssertion);
172
+ return this.getCredentialsFilteredByInternal(filter.homeAccountId, filter.environment, filter.credentialType, filter.clientId, filter.familyId, filter.realm, filter.target, filter.oboAssertion, filter.tokenType, filter.keyId);
147
173
  };
148
174
  /**
149
175
  * Support function to help match credentials
@@ -153,8 +179,10 @@ var CacheManager = /** @class */ (function () {
153
179
  * @param clientId
154
180
  * @param realm
155
181
  * @param target
182
+ * @param oboAssertion
183
+ * @param tokenType
156
184
  */
157
- CacheManager.prototype.getCredentialsFilteredByInternal = function (homeAccountId, environment, credentialType, clientId, familyId, realm, target, oboAssertion) {
185
+ CacheManager.prototype.getCredentialsFilteredByInternal = function (homeAccountId, environment, credentialType, clientId, familyId, realm, target, oboAssertion, tokenType, keyId) {
158
186
  var _this = this;
159
187
  var allCacheKeys = this.getKeys();
160
188
  var matchingCredentials = {
@@ -201,6 +229,28 @@ var CacheManager = /** @class */ (function () {
201
229
  if (!!target && !_this.matchTarget(entity, target)) {
202
230
  return;
203
231
  }
232
+ // Access Token with Auth Scheme specific matching
233
+ if (credentialType === CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME) {
234
+ if (!!tokenType && !_this.matchTokenType(entity, tokenType)) {
235
+ return;
236
+ }
237
+ switch (tokenType) {
238
+ case AuthenticationScheme.POP:
239
+ // This check avoids matching outdated POP tokens that don't have the <-scheme> in the cache key
240
+ if (cacheKey.indexOf(AuthenticationScheme.POP) === -1) {
241
+ // AccessToken_With_AuthScheme that doesn't have "-pop" in the key is outdated and needs to be removed
242
+ _this.removeItem(cacheKey, CacheSchemaType.CREDENTIAL);
243
+ return;
244
+ }
245
+ break;
246
+ case AuthenticationScheme.SSH:
247
+ // KeyId (sshKid) in request must match cached SSH certificate keyId because SSH cert is bound to a specific key
248
+ if (keyId && !_this.matchKeyId(entity, keyId)) {
249
+ return;
250
+ }
251
+ break;
252
+ }
253
+ }
204
254
  switch (credType) {
205
255
  case CredentialType.ID_TOKEN:
206
256
  matchingCredentials.idTokens[cacheKey] = entity;
@@ -281,56 +331,112 @@ var CacheManager = /** @class */ (function () {
281
331
  * Removes all accounts and related tokens from cache.
282
332
  */
283
333
  CacheManager.prototype.removeAllAccounts = function () {
284
- var _this = this;
285
- var allCacheKeys = this.getKeys();
286
- allCacheKeys.forEach(function (cacheKey) {
287
- var entity = _this.getAccount(cacheKey);
288
- if (!entity) {
289
- return;
290
- }
291
- _this.removeAccount(cacheKey);
334
+ return __awaiter(this, void 0, void 0, function () {
335
+ var allCacheKeys, removedAccounts;
336
+ var _this = this;
337
+ return __generator(this, function (_a) {
338
+ switch (_a.label) {
339
+ case 0:
340
+ allCacheKeys = this.getKeys();
341
+ removedAccounts = [];
342
+ allCacheKeys.forEach(function (cacheKey) {
343
+ var entity = _this.getAccount(cacheKey);
344
+ if (!entity) {
345
+ return;
346
+ }
347
+ removedAccounts.push(_this.removeAccount(cacheKey));
348
+ });
349
+ return [4 /*yield*/, Promise.all(removedAccounts)];
350
+ case 1:
351
+ _a.sent();
352
+ return [2 /*return*/, true];
353
+ }
354
+ });
292
355
  });
293
- return true;
294
356
  };
295
357
  /**
296
358
  * returns a boolean if the given account is removed
297
359
  * @param account
298
360
  */
299
361
  CacheManager.prototype.removeAccount = function (accountKey) {
300
- var account = this.getAccount(accountKey);
301
- if (!account) {
302
- throw ClientAuthError.createNoAccountFoundError();
303
- }
304
- return (this.removeAccountContext(account) && this.removeItem(accountKey, CacheSchemaType.ACCOUNT));
362
+ return __awaiter(this, void 0, void 0, function () {
363
+ var account;
364
+ return __generator(this, function (_a) {
365
+ switch (_a.label) {
366
+ case 0:
367
+ account = this.getAccount(accountKey);
368
+ if (!account) {
369
+ throw ClientAuthError.createNoAccountFoundError();
370
+ }
371
+ return [4 /*yield*/, this.removeAccountContext(account)];
372
+ case 1: return [2 /*return*/, ((_a.sent()) && this.removeItem(accountKey, CacheSchemaType.ACCOUNT))];
373
+ }
374
+ });
375
+ });
305
376
  };
306
377
  /**
307
378
  * returns a boolean if the given account is removed
308
379
  * @param account
309
380
  */
310
381
  CacheManager.prototype.removeAccountContext = function (account) {
311
- var _this = this;
312
- var allCacheKeys = this.getKeys();
313
- var accountId = account.generateAccountId();
314
- allCacheKeys.forEach(function (cacheKey) {
315
- // don't parse any non-credential type cache entities
316
- var credType = CredentialEntity.getCredentialType(cacheKey);
317
- if (credType === Constants.NOT_DEFINED) {
318
- return;
319
- }
320
- var cacheEntity = _this.getSpecificCredential(cacheKey, credType);
321
- if (!!cacheEntity && accountId === cacheEntity.generateAccountId()) {
322
- _this.removeCredential(cacheEntity);
323
- }
382
+ return __awaiter(this, void 0, void 0, function () {
383
+ var allCacheKeys, accountId, removedCredentials;
384
+ var _this = this;
385
+ return __generator(this, function (_a) {
386
+ switch (_a.label) {
387
+ case 0:
388
+ allCacheKeys = this.getKeys();
389
+ accountId = account.generateAccountId();
390
+ removedCredentials = [];
391
+ allCacheKeys.forEach(function (cacheKey) {
392
+ // don't parse any non-credential type cache entities
393
+ var credType = CredentialEntity.getCredentialType(cacheKey);
394
+ if (credType === Constants.NOT_DEFINED) {
395
+ return;
396
+ }
397
+ var cacheEntity = _this.getSpecificCredential(cacheKey, credType);
398
+ if (!!cacheEntity && accountId === cacheEntity.generateAccountId()) {
399
+ removedCredentials.push(_this.removeCredential(cacheEntity));
400
+ }
401
+ });
402
+ return [4 /*yield*/, Promise.all(removedCredentials)];
403
+ case 1:
404
+ _a.sent();
405
+ return [2 /*return*/, true];
406
+ }
407
+ });
324
408
  });
325
- return true;
326
409
  };
327
410
  /**
328
411
  * returns a boolean if the given credential is removed
329
412
  * @param credential
330
413
  */
331
414
  CacheManager.prototype.removeCredential = function (credential) {
332
- var key = credential.generateCredentialKey();
333
- return this.removeItem(key, CacheSchemaType.CREDENTIAL);
415
+ return __awaiter(this, void 0, void 0, function () {
416
+ var key, accessTokenWithAuthSchemeEntity, kid;
417
+ return __generator(this, function (_a) {
418
+ switch (_a.label) {
419
+ case 0:
420
+ key = credential.generateCredentialKey();
421
+ if (!(credential.credentialType.toLowerCase() === CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME.toLowerCase())) return [3 /*break*/, 4];
422
+ if (!(credential.tokenType === AuthenticationScheme.POP)) return [3 /*break*/, 4];
423
+ accessTokenWithAuthSchemeEntity = credential;
424
+ kid = accessTokenWithAuthSchemeEntity.keyId;
425
+ if (!kid) return [3 /*break*/, 4];
426
+ _a.label = 1;
427
+ case 1:
428
+ _a.trys.push([1, 3, , 4]);
429
+ return [4 /*yield*/, this.cryptoImpl.removeTokenBindingKey(kid)];
430
+ case 2:
431
+ _a.sent();
432
+ return [3 /*break*/, 4];
433
+ case 3:
434
+ _a.sent();
435
+ throw ClientAuthError.createBindingKeyNotRemovedError();
436
+ case 4: return [2 /*return*/, this.removeItem(key, CacheSchemaType.CREDENTIAL)];
437
+ }
438
+ });
439
+ });
334
440
  };
335
441
  /**
336
442
  * Removes all app metadata objects from cache.
@@ -353,10 +459,10 @@ var CacheManager = /** @class */ (function () {
353
459
  * @param environment
354
460
  * @param authScheme
355
461
  */
356
- CacheManager.prototype.readCacheRecord = function (account, clientId, scopes, environment, authScheme) {
462
+ CacheManager.prototype.readCacheRecord = function (account, clientId, scopes, environment, authScheme, keyId) {
357
463
  var cachedAccount = this.readAccountFromCache(account);
358
464
  var cachedIdToken = this.readIdTokenFromCache(clientId, account);
359
- var cachedAccessToken = this.readAccessTokenFromCache(clientId, account, scopes, authScheme);
465
+ var cachedAccessToken = this.readAccessTokenFromCache(clientId, account, scopes, authScheme, keyId);
360
466
  var cachedRefreshToken = this.readRefreshTokenFromCache(clientId, account, false);
361
467
  var cachedAppMetadata = this.readAppMetadataFromCache(environment, clientId);
362
468
  if (cachedAccount && cachedIdToken) {
@@ -410,8 +516,9 @@ var CacheManager = /** @class */ (function () {
410
516
  * @param scopes
411
517
  * @param authScheme
412
518
  */
413
- CacheManager.prototype.readAccessTokenFromCache = function (clientId, account, scopes, authScheme) {
414
- var credentialType = (authScheme === AuthenticationScheme.POP) ? CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME : CredentialType.ACCESS_TOKEN;
519
+ CacheManager.prototype.readAccessTokenFromCache = function (clientId, account, scopes, authScheme, keyId) {
520
+ // Distinguish between Bearer and PoP/SSH token cache types
521
+ var credentialType = (authScheme && authScheme !== AuthenticationScheme.BEARER) ? CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME : CredentialType.ACCESS_TOKEN;
415
522
  var accessTokenFilter = {
416
523
  homeAccountId: account.homeAccountId,
417
524
  environment: account.environment,
@@ -419,6 +526,8 @@ var CacheManager = /** @class */ (function () {
419
526
  clientId: clientId,
420
527
  realm: account.tenantId,
421
528
  target: scopes.printScopesLowerCase(),
529
+ tokenType: authScheme,
530
+ keyId: keyId
422
531
  };
423
532
  var credentialCache = this.getCredentialsFilteredBy(accessTokenFilter);
424
533
  var accessTokens = Object.keys(credentialCache.accessTokens).map(function (key) { return credentialCache.accessTokens[key]; });
@@ -563,6 +672,22 @@ var CacheManager = /** @class */ (function () {
563
672
  }
564
673
  return entityScopeSet.containsScopeSet(requestTargetScopeSet);
565
674
  };
675
+ /**
676
+ * Returns true if the credential's tokenType or Authentication Scheme matches the one in the request, false otherwise
677
+ * @param entity
678
+ * @param tokenType
679
+ */
680
+ CacheManager.prototype.matchTokenType = function (entity, tokenType) {
681
+ return !!(entity.tokenType && entity.tokenType === tokenType);
682
+ };
683
+ /**
684
+ * Returns true if the credential's keyId matches the one in the request, false otherwise
685
+ * @param entity
686
+ * @param tokenType
687
+ */
688
+ CacheManager.prototype.matchKeyId = function (entity, keyId) {
689
+ return !!(entity.keyId && entity.keyId === keyId);
690
+ };
566
691
  /**
567
692
  * returns if a given cache entity is of the type appmetadata
568
693
  * @param key
@@ -703,8 +828,13 @@ var DefaultStorageClass = /** @class */ (function (_super) {
703
828
  throw AuthError.createUnexpectedError(notImplErr);
704
829
  };
705
830
  DefaultStorageClass.prototype.clear = function () {
706
- var notImplErr = "Storage interface - clear() has not been implemented for the cacheStorage interface.";
707
- throw AuthError.createUnexpectedError(notImplErr);
831
+ return __awaiter(this, void 0, void 0, function () {
832
+ var notImplErr;
833
+ return __generator(this, function (_a) {
834
+ notImplErr = "Storage interface - clear() has not been implemented for the cacheStorage interface.";
835
+ throw AuthError.createUnexpectedError(notImplErr);
836
+ });
837
+ });
708
838
  };
709
839
  return DefaultStorageClass;
710
840
  }(CacheManager));