@azure/msal-common 4.5.0 → 5.1.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.
- package/CHANGELOG.json +178 -0
- package/{changelog.md → CHANGELOG.md} +446 -390
- package/LICENSE +21 -21
- package/README.md +62 -61
- package/dist/_virtual/_tslib.js +1 -1
- package/dist/account/AuthToken.js +7 -7
- package/dist/account/AuthToken.js.map +1 -1
- package/dist/account/CcsCredential.js +1 -1
- package/dist/account/CcsCredential.js.map +1 -1
- package/dist/account/ClientInfo.js +10 -10
- package/dist/account/ClientInfo.js.map +1 -1
- package/dist/account/TokenClaims.d.ts +5 -0
- package/dist/account/TokenClaims.d.ts.map +1 -1
- package/dist/authority/Authority.d.ts.map +1 -1
- package/dist/authority/Authority.js +60 -54
- package/dist/authority/Authority.js.map +1 -1
- package/dist/authority/AuthorityFactory.js +9 -9
- package/dist/authority/AuthorityFactory.js.map +1 -1
- package/dist/authority/AuthorityType.js +1 -1
- package/dist/authority/AuthorityType.js.map +1 -1
- package/dist/authority/CloudInstanceDiscoveryResponse.js +1 -1
- package/dist/authority/CloudInstanceDiscoveryResponse.js.map +1 -1
- package/dist/authority/OpenIdConfigResponse.d.ts +1 -1
- package/dist/authority/OpenIdConfigResponse.d.ts.map +1 -1
- package/dist/authority/OpenIdConfigResponse.js +1 -2
- package/dist/authority/OpenIdConfigResponse.js.map +1 -1
- package/dist/authority/ProtocolMode.js +1 -1
- package/dist/authority/ProtocolMode.js.map +1 -1
- package/dist/authority/RegionDiscovery.js +9 -9
- package/dist/authority/RegionDiscovery.js.map +1 -1
- package/dist/cache/CacheManager.d.ts +23 -9
- package/dist/cache/CacheManager.d.ts.map +1 -1
- package/dist/cache/CacheManager.js +244 -114
- package/dist/cache/CacheManager.js.map +1 -1
- package/dist/cache/entities/AccessTokenEntity.d.ts +3 -2
- package/dist/cache/entities/AccessTokenEntity.d.ts.map +1 -1
- package/dist/cache/entities/AccessTokenEntity.js +23 -17
- package/dist/cache/entities/AccessTokenEntity.js.map +1 -1
- package/dist/cache/entities/AccountEntity.d.ts +2 -2
- package/dist/cache/entities/AccountEntity.d.ts.map +1 -1
- package/dist/cache/entities/AccountEntity.js +18 -18
- package/dist/cache/entities/AccountEntity.js.map +1 -1
- package/dist/cache/entities/AppMetadataEntity.js +1 -1
- package/dist/cache/entities/AppMetadataEntity.js.map +1 -1
- package/dist/cache/entities/AuthorityMetadataEntity.d.ts +1 -1
- package/dist/cache/entities/AuthorityMetadataEntity.d.ts.map +1 -1
- package/dist/cache/entities/AuthorityMetadataEntity.js +5 -6
- package/dist/cache/entities/AuthorityMetadataEntity.js.map +1 -1
- package/dist/cache/entities/CacheRecord.js +1 -1
- package/dist/cache/entities/CacheRecord.js.map +1 -1
- package/dist/cache/entities/CredentialEntity.d.ts +7 -3
- package/dist/cache/entities/CredentialEntity.d.ts.map +1 -1
- package/dist/cache/entities/CredentialEntity.js +16 -9
- package/dist/cache/entities/CredentialEntity.js.map +1 -1
- package/dist/cache/entities/IdTokenEntity.js +3 -3
- package/dist/cache/entities/IdTokenEntity.js.map +1 -1
- package/dist/cache/entities/RefreshTokenEntity.js +3 -3
- package/dist/cache/entities/RefreshTokenEntity.js.map +1 -1
- package/dist/cache/entities/ServerTelemetryEntity.js +1 -1
- package/dist/cache/entities/ServerTelemetryEntity.js.map +1 -1
- package/dist/cache/entities/ThrottlingEntity.js +1 -1
- package/dist/cache/entities/ThrottlingEntity.js.map +1 -1
- package/dist/cache/interface/ICacheManager.d.ts +5 -5
- package/dist/cache/interface/ICacheManager.d.ts.map +1 -1
- package/dist/cache/persistence/TokenCacheContext.js +3 -3
- package/dist/cache/persistence/TokenCacheContext.js.map +1 -1
- package/dist/cache/utils/CacheTypes.d.ts +4 -1
- package/dist/cache/utils/CacheTypes.d.ts.map +1 -1
- package/dist/client/AuthorizationCodeClient.d.ts +1 -1
- package/dist/client/AuthorizationCodeClient.d.ts.map +1 -1
- package/dist/client/AuthorizationCodeClient.js +56 -43
- package/dist/client/AuthorizationCodeClient.js.map +1 -1
- package/dist/client/BaseClient.js +11 -11
- package/dist/client/BaseClient.js.map +1 -1
- package/dist/client/ClientCredentialClient.d.ts.map +1 -1
- package/dist/client/ClientCredentialClient.js +24 -18
- package/dist/client/ClientCredentialClient.js.map +1 -1
- package/dist/client/DeviceCodeClient.d.ts.map +1 -1
- package/dist/client/DeviceCodeClient.js +39 -27
- package/dist/client/DeviceCodeClient.js.map +1 -1
- package/dist/client/OnBehalfOfClient.d.ts.map +1 -1
- package/dist/client/OnBehalfOfClient.js +26 -20
- package/dist/client/OnBehalfOfClient.js.map +1 -1
- package/dist/client/RefreshTokenClient.d.ts.map +1 -1
- package/dist/client/RefreshTokenClient.js +49 -32
- package/dist/client/RefreshTokenClient.js.map +1 -1
- package/dist/client/SilentFlowClient.d.ts.map +1 -1
- package/dist/client/SilentFlowClient.js +40 -35
- package/dist/client/SilentFlowClient.js.map +1 -1
- package/dist/client/UsernamePasswordClient.d.ts.map +1 -1
- package/dist/client/UsernamePasswordClient.js +18 -12
- package/dist/client/UsernamePasswordClient.js.map +1 -1
- package/dist/config/ClientConfiguration.d.ts.map +1 -1
- package/dist/config/ClientConfiguration.js +8 -7
- package/dist/config/ClientConfiguration.js.map +1 -1
- package/dist/crypto/ICrypto.d.ts +11 -1
- package/dist/crypto/ICrypto.d.ts.map +1 -1
- package/dist/crypto/ICrypto.js +26 -8
- package/dist/crypto/ICrypto.js.map +1 -1
- package/dist/crypto/PopTokenGenerator.d.ts +21 -4
- package/dist/crypto/PopTokenGenerator.d.ts.map +1 -1
- package/dist/crypto/PopTokenGenerator.js +42 -31
- package/dist/crypto/PopTokenGenerator.js.map +1 -1
- package/dist/error/AuthError.d.ts +5 -0
- package/dist/error/AuthError.d.ts.map +1 -1
- package/dist/error/AuthError.js +6 -3
- package/dist/error/AuthError.js.map +1 -1
- package/dist/error/ClientAuthError.d.ts +13 -4
- package/dist/error/ClientAuthError.d.ts.map +1 -1
- package/dist/error/ClientAuthError.js +20 -9
- package/dist/error/ClientAuthError.js.map +1 -1
- package/dist/error/ClientConfigurationError.d.ts +29 -0
- package/dist/error/ClientConfigurationError.d.ts.map +1 -1
- package/dist/error/ClientConfigurationError.js +45 -5
- package/dist/error/ClientConfigurationError.js.map +1 -1
- package/dist/error/InteractionRequiredAuthError.d.ts +24 -5
- package/dist/error/InteractionRequiredAuthError.d.ts.map +1 -1
- package/dist/error/InteractionRequiredAuthError.js +30 -9
- package/dist/error/InteractionRequiredAuthError.js.map +1 -1
- package/dist/error/ServerError.js +3 -3
- package/dist/error/ServerError.js.map +1 -1
- package/dist/index.cjs.js +675 -244
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +7 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +33 -29
- package/dist/index.js.map +1 -1
- package/dist/logger/Logger.d.ts.map +1 -1
- package/dist/logger/Logger.js +11 -9
- package/dist/logger/Logger.js.map +1 -1
- package/dist/network/INetworkModule.js +4 -4
- package/dist/network/INetworkModule.js.map +1 -1
- package/dist/network/NetworkManager.js +8 -8
- package/dist/network/NetworkManager.js.map +1 -1
- package/dist/network/RequestThumbprint.d.ts +7 -0
- package/dist/network/RequestThumbprint.d.ts.map +1 -1
- package/dist/network/ThrottlingUtils.d.ts +2 -1
- package/dist/network/ThrottlingUtils.d.ts.map +1 -1
- package/dist/network/ThrottlingUtils.js +14 -8
- package/dist/network/ThrottlingUtils.js.map +1 -1
- package/dist/packageMetadata.d.ts +1 -1
- package/dist/packageMetadata.js +2 -2
- package/dist/packageMetadata.js.map +1 -1
- package/dist/request/AuthenticationHeaderParser.d.ts +20 -0
- package/dist/request/AuthenticationHeaderParser.d.ts.map +1 -0
- package/dist/request/AuthenticationHeaderParser.js +64 -0
- package/dist/request/AuthenticationHeaderParser.js.map +1 -0
- package/dist/request/BaseAuthRequest.d.ts +7 -1
- package/dist/request/BaseAuthRequest.d.ts.map +1 -1
- package/dist/request/CommonEndSessionRequest.d.ts +4 -0
- package/dist/request/CommonEndSessionRequest.d.ts.map +1 -1
- package/dist/request/RequestParameterBuilder.d.ts +4 -0
- package/dist/request/RequestParameterBuilder.d.ts.map +1 -1
- package/dist/request/RequestParameterBuilder.js +27 -18
- package/dist/request/RequestParameterBuilder.js.map +1 -1
- package/dist/request/RequestValidator.js +10 -10
- package/dist/request/RequestValidator.js.map +1 -1
- package/dist/request/ScopeSet.js +14 -14
- package/dist/request/ScopeSet.js.map +1 -1
- package/dist/response/AuthenticationResult.d.ts +2 -1
- package/dist/response/AuthenticationResult.d.ts.map +1 -1
- package/dist/response/ExternalTokenResponse.d.ts +15 -0
- package/dist/response/ExternalTokenResponse.d.ts.map +1 -0
- package/dist/response/ResponseHandler.d.ts.map +1 -1
- package/dist/response/ResponseHandler.js +74 -69
- package/dist/response/ResponseHandler.js.map +1 -1
- package/dist/response/ServerAuthorizationTokenResponse.d.ts +5 -2
- package/dist/response/ServerAuthorizationTokenResponse.d.ts.map +1 -1
- package/dist/telemetry/server/ServerTelemetryManager.js +13 -13
- package/dist/telemetry/server/ServerTelemetryManager.js.map +1 -1
- package/dist/url/UrlString.d.ts +0 -6
- package/dist/url/UrlString.d.ts.map +1 -1
- package/dist/url/UrlString.js +25 -40
- package/dist/url/UrlString.js.map +1 -1
- package/dist/utils/Constants.d.ts +5 -2
- package/dist/utils/Constants.d.ts.map +1 -1
- package/dist/utils/Constants.js +5 -2
- package/dist/utils/Constants.js.map +1 -1
- package/dist/utils/ProtocolUtils.js +13 -13
- package/dist/utils/ProtocolUtils.js.map +1 -1
- package/dist/utils/StringUtils.d.ts.map +1 -1
- package/dist/utils/StringUtils.js +15 -14
- package/dist/utils/StringUtils.js.map +1 -1
- package/dist/utils/TimeUtils.js +1 -1
- package/dist/utils/TimeUtils.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @azure/msal-common
|
|
1
|
+
/*! @azure/msal-common v5.1.0 2021-11-02 */
|
|
2
2
|
'use strict';
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
@@ -153,7 +153,13 @@ var HeaderNames;
|
|
|
153
153
|
HeaderNames["CONTENT_TYPE"] = "Content-Type";
|
|
154
154
|
HeaderNames["RETRY_AFTER"] = "Retry-After";
|
|
155
155
|
HeaderNames["CCS_HEADER"] = "X-AnchorMailbox";
|
|
156
|
+
HeaderNames["WWWAuthenticate"] = "WWW-Authenticate";
|
|
157
|
+
HeaderNames["AuthenticationInfo"] = "Authentication-Info";
|
|
156
158
|
})(HeaderNames || (HeaderNames = {}));
|
|
159
|
+
/**
|
|
160
|
+
* Persistent cache keys MSAL which stay while user is logged in.
|
|
161
|
+
*/
|
|
162
|
+
exports.PersistentCacheKeys = void 0;
|
|
157
163
|
(function (PersistentCacheKeys) {
|
|
158
164
|
PersistentCacheKeys["ID_TOKEN"] = "idtoken";
|
|
159
165
|
PersistentCacheKeys["CLIENT_INFO"] = "client.info";
|
|
@@ -258,7 +264,7 @@ var SSOTypes;
|
|
|
258
264
|
/**
|
|
259
265
|
* Disallowed extra query parameters.
|
|
260
266
|
*/
|
|
261
|
-
|
|
267
|
+
[
|
|
262
268
|
SSOTypes.SID,
|
|
263
269
|
SSOTypes.LOGIN_HINT
|
|
264
270
|
];
|
|
@@ -269,6 +275,10 @@ var CodeChallengeMethodValues = {
|
|
|
269
275
|
PLAIN: "plain",
|
|
270
276
|
S256: "S256"
|
|
271
277
|
};
|
|
278
|
+
/**
|
|
279
|
+
* allowed values for response_mode
|
|
280
|
+
*/
|
|
281
|
+
exports.ResponseMode = void 0;
|
|
272
282
|
(function (ResponseMode) {
|
|
273
283
|
ResponseMode["QUERY"] = "query";
|
|
274
284
|
ResponseMode["FRAGMENT"] = "fragment";
|
|
@@ -287,6 +297,10 @@ var GrantType;
|
|
|
287
297
|
GrantType["DEVICE_CODE_GRANT"] = "device_code";
|
|
288
298
|
GrantType["JWT_BEARER"] = "urn:ietf:params:oauth:grant-type:jwt-bearer";
|
|
289
299
|
})(GrantType || (GrantType = {}));
|
|
300
|
+
/**
|
|
301
|
+
* Account types in Cache
|
|
302
|
+
*/
|
|
303
|
+
exports.CacheAccountType = void 0;
|
|
290
304
|
(function (CacheAccountType) {
|
|
291
305
|
CacheAccountType["MSSTS_ACCOUNT_TYPE"] = "MSSTS";
|
|
292
306
|
CacheAccountType["ADFS_ACCOUNT_TYPE"] = "ADFS";
|
|
@@ -301,12 +315,20 @@ var Separators;
|
|
|
301
315
|
Separators["CACHE_KEY_SEPARATOR"] = "-";
|
|
302
316
|
Separators["CLIENT_INFO_SEPARATOR"] = ".";
|
|
303
317
|
})(Separators || (Separators = {}));
|
|
318
|
+
/**
|
|
319
|
+
* Credential Type stored in the cache
|
|
320
|
+
*/
|
|
321
|
+
exports.CredentialType = void 0;
|
|
304
322
|
(function (CredentialType) {
|
|
305
323
|
CredentialType["ID_TOKEN"] = "IdToken";
|
|
306
324
|
CredentialType["ACCESS_TOKEN"] = "AccessToken";
|
|
307
325
|
CredentialType["ACCESS_TOKEN_WITH_AUTH_SCHEME"] = "AccessToken_With_AuthScheme";
|
|
308
326
|
CredentialType["REFRESH_TOKEN"] = "RefreshToken";
|
|
309
327
|
})(exports.CredentialType || (exports.CredentialType = {}));
|
|
328
|
+
/**
|
|
329
|
+
* Credential Type stored in the cache
|
|
330
|
+
*/
|
|
331
|
+
exports.CacheSchemaType = void 0;
|
|
310
332
|
(function (CacheSchemaType) {
|
|
311
333
|
CacheSchemaType["ACCOUNT"] = "Account";
|
|
312
334
|
CacheSchemaType["CREDENTIAL"] = "Credential";
|
|
@@ -319,6 +341,10 @@ var Separators;
|
|
|
319
341
|
CacheSchemaType["UNDEFINED"] = "Undefined";
|
|
320
342
|
CacheSchemaType["THROTTLING"] = "Throttling";
|
|
321
343
|
})(exports.CacheSchemaType || (exports.CacheSchemaType = {}));
|
|
344
|
+
/**
|
|
345
|
+
* Combine all cache types
|
|
346
|
+
*/
|
|
347
|
+
exports.CacheType = void 0;
|
|
322
348
|
(function (CacheType) {
|
|
323
349
|
CacheType[CacheType["ADFS"] = 1001] = "ADFS";
|
|
324
350
|
CacheType[CacheType["MSA"] = 1002] = "MSA";
|
|
@@ -358,9 +384,14 @@ var SERVER_TELEM_CONSTANTS = {
|
|
|
358
384
|
OVERFLOW_FALSE: "0",
|
|
359
385
|
UNKNOWN_ERROR: "unknown_error"
|
|
360
386
|
};
|
|
387
|
+
/**
|
|
388
|
+
* Type of the authentication request
|
|
389
|
+
*/
|
|
390
|
+
exports.AuthenticationScheme = void 0;
|
|
361
391
|
(function (AuthenticationScheme) {
|
|
362
|
-
AuthenticationScheme["POP"] = "pop";
|
|
363
392
|
AuthenticationScheme["BEARER"] = "Bearer";
|
|
393
|
+
AuthenticationScheme["POP"] = "pop";
|
|
394
|
+
AuthenticationScheme["SSH"] = "ssh-cert";
|
|
364
395
|
})(exports.AuthenticationScheme || (exports.AuthenticationScheme = {}));
|
|
365
396
|
/**
|
|
366
397
|
* Constants related to throttling
|
|
@@ -454,6 +485,9 @@ var AuthError = /** @class */ (function (_super) {
|
|
|
454
485
|
_this.name = "AuthError";
|
|
455
486
|
return _this;
|
|
456
487
|
}
|
|
488
|
+
AuthError.prototype.setCorrelationId = function (correlationId) {
|
|
489
|
+
this.correlationId = correlationId;
|
|
490
|
+
};
|
|
457
491
|
/**
|
|
458
492
|
* Creates an error that is thrown when something unexpected happens in the library.
|
|
459
493
|
* @param errDesc
|
|
@@ -499,6 +533,24 @@ var DEFAULT_CRYPTO_IMPLEMENTATION = {
|
|
|
499
533
|
});
|
|
500
534
|
});
|
|
501
535
|
},
|
|
536
|
+
removeTokenBindingKey: function () {
|
|
537
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
538
|
+
var notImplErr;
|
|
539
|
+
return __generator(this, function (_a) {
|
|
540
|
+
notImplErr = "Crypto interface - removeTokenBindingKey() has not been implemented";
|
|
541
|
+
throw AuthError.createUnexpectedError(notImplErr);
|
|
542
|
+
});
|
|
543
|
+
});
|
|
544
|
+
},
|
|
545
|
+
clearKeystore: function () {
|
|
546
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
547
|
+
var notImplErr;
|
|
548
|
+
return __generator(this, function (_a) {
|
|
549
|
+
notImplErr = "Crypto interface - clearKeystore() has not been implemented";
|
|
550
|
+
throw AuthError.createUnexpectedError(notImplErr);
|
|
551
|
+
});
|
|
552
|
+
});
|
|
553
|
+
},
|
|
502
554
|
signJwt: function () {
|
|
503
555
|
return __awaiter(this, void 0, void 0, function () {
|
|
504
556
|
var notImplErr;
|
|
@@ -690,6 +742,14 @@ var ClientAuthErrorMessage = {
|
|
|
690
742
|
accessTokenEntityNullError: {
|
|
691
743
|
code: "access_token_entity_null",
|
|
692
744
|
desc: "Access token entity is null, please check logs and cache to ensure a valid access token is present."
|
|
745
|
+
},
|
|
746
|
+
bindingKeyNotRemovedError: {
|
|
747
|
+
code: "binding_key_not_removed",
|
|
748
|
+
desc: "Could not remove the credential's binding key from storage."
|
|
749
|
+
},
|
|
750
|
+
logoutNotSupported: {
|
|
751
|
+
code: "end_session_endpoint_not_supported",
|
|
752
|
+
desc: "Provided authority does not support logout."
|
|
693
753
|
}
|
|
694
754
|
};
|
|
695
755
|
/**
|
|
@@ -789,12 +849,6 @@ var ClientAuthError = /** @class */ (function (_super) {
|
|
|
789
849
|
ClientAuthError.createNonceNotFoundError = function (missingNonce) {
|
|
790
850
|
return new ClientAuthError(ClientAuthErrorMessage.nonceNotFoundError.code, ClientAuthErrorMessage.nonceNotFoundError.desc + ": " + missingNonce);
|
|
791
851
|
};
|
|
792
|
-
/**
|
|
793
|
-
* Creates an error thrown when the authorization code required for a token request is null or empty.
|
|
794
|
-
*/
|
|
795
|
-
ClientAuthError.createNoTokensFoundError = function () {
|
|
796
|
-
return new ClientAuthError(ClientAuthErrorMessage.noTokensFoundError.code, ClientAuthErrorMessage.noTokensFoundError.desc);
|
|
797
|
-
};
|
|
798
852
|
/**
|
|
799
853
|
* Throws error when multiple tokens are in cache.
|
|
800
854
|
*/
|
|
@@ -956,6 +1010,15 @@ var ClientAuthError = /** @class */ (function (_super) {
|
|
|
956
1010
|
ClientAuthError.createNoAuthCodeInServerResponseError = function () {
|
|
957
1011
|
return new ClientAuthError(ClientAuthErrorMessage.noAuthorizationCodeFromServer.code, ClientAuthErrorMessage.noAuthorizationCodeFromServer.desc);
|
|
958
1012
|
};
|
|
1013
|
+
ClientAuthError.createBindingKeyNotRemovedError = function () {
|
|
1014
|
+
return new ClientAuthError(ClientAuthErrorMessage.bindingKeyNotRemovedError.code, ClientAuthErrorMessage.bindingKeyNotRemovedError.desc);
|
|
1015
|
+
};
|
|
1016
|
+
/**
|
|
1017
|
+
* Thrown when logout is attempted for an authority that doesnt have an end_session_endpoint
|
|
1018
|
+
*/
|
|
1019
|
+
ClientAuthError.createLogoutNotSupportedError = function () {
|
|
1020
|
+
return new ClientAuthError(ClientAuthErrorMessage.logoutNotSupported.code, ClientAuthErrorMessage.logoutNotSupported.desc);
|
|
1021
|
+
};
|
|
959
1022
|
return ClientAuthError;
|
|
960
1023
|
}(AuthError));
|
|
961
1024
|
|
|
@@ -1024,16 +1087,17 @@ var StringUtils = /** @class */ (function () {
|
|
|
1024
1087
|
* @param query
|
|
1025
1088
|
*/
|
|
1026
1089
|
StringUtils.queryStringToObject = function (query) {
|
|
1027
|
-
var match; // Regex for replacing addition symbol with a space
|
|
1028
|
-
var pl = /\+/g;
|
|
1029
|
-
var search = /([^&=]+)=([^&]*)/g;
|
|
1030
|
-
var decode = function (s) { return decodeURIComponent(decodeURIComponent(s.replace(pl, " "))); };
|
|
1031
1090
|
var obj = {};
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1091
|
+
var params = query.split("&");
|
|
1092
|
+
var decode = function (s) { return decodeURIComponent(s.replace(/\+/g, " ")); };
|
|
1093
|
+
params.forEach(function (pair) {
|
|
1094
|
+
if (pair.trim()) {
|
|
1095
|
+
var _a = pair.split(/=(.+)/g, 2), key = _a[0], value = _a[1]; // Split on the first occurence of the '=' character
|
|
1096
|
+
if (key && value) {
|
|
1097
|
+
obj[decode(key)] = decode(value);
|
|
1098
|
+
}
|
|
1099
|
+
}
|
|
1100
|
+
});
|
|
1037
1101
|
return obj;
|
|
1038
1102
|
};
|
|
1039
1103
|
/**
|
|
@@ -1075,7 +1139,7 @@ var StringUtils = /** @class */ (function () {
|
|
|
1075
1139
|
* Wildcard support: https://stackoverflow.com/a/3117248/4888559
|
|
1076
1140
|
* Queries: replaces "?" in string with escaped "\?" for regex test
|
|
1077
1141
|
*/
|
|
1078
|
-
var regex = new RegExp(pattern.replace(/\*/g, "[^ ]*").replace(/\?/g, "\\\?"));
|
|
1142
|
+
var regex = new RegExp(pattern.replace(/\\/g, "\\\\").replace(/\*/g, "[^ ]*").replace(/\?/g, "\\\?")); // eslint-disable-line security/detect-non-literal-regexp
|
|
1079
1143
|
return regex.test(input);
|
|
1080
1144
|
};
|
|
1081
1145
|
return StringUtils;
|
|
@@ -1085,6 +1149,10 @@ var StringUtils = /** @class */ (function () {
|
|
|
1085
1149
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
1086
1150
|
* Licensed under the MIT License.
|
|
1087
1151
|
*/
|
|
1152
|
+
/**
|
|
1153
|
+
* Log message level.
|
|
1154
|
+
*/
|
|
1155
|
+
exports.LogLevel = void 0;
|
|
1088
1156
|
(function (LogLevel) {
|
|
1089
1157
|
LogLevel[LogLevel["Error"] = 0] = "Error";
|
|
1090
1158
|
LogLevel[LogLevel["Warning"] = 1] = "Warning";
|
|
@@ -1099,10 +1167,12 @@ var Logger = /** @class */ (function () {
|
|
|
1099
1167
|
function Logger(loggerOptions, packageName, packageVersion) {
|
|
1100
1168
|
// Current log level, defaults to info.
|
|
1101
1169
|
this.level = exports.LogLevel.Info;
|
|
1102
|
-
var defaultLoggerCallback = function () {
|
|
1170
|
+
var defaultLoggerCallback = function () {
|
|
1171
|
+
return;
|
|
1172
|
+
};
|
|
1103
1173
|
this.localCallback = loggerOptions.loggerCallback || defaultLoggerCallback;
|
|
1104
1174
|
this.piiLoggingEnabled = loggerOptions.piiLoggingEnabled || false;
|
|
1105
|
-
this.level = loggerOptions.logLevel
|
|
1175
|
+
this.level = typeof (loggerOptions.logLevel) === "number" ? loggerOptions.logLevel : exports.LogLevel.Info;
|
|
1106
1176
|
this.correlationId = loggerOptions.correlationId || "";
|
|
1107
1177
|
this.packageName = packageName || Constants.EMPTY_STRING;
|
|
1108
1178
|
this.packageVersion = packageVersion || Constants.EMPTY_STRING;
|
|
@@ -1255,7 +1325,7 @@ var Logger = /** @class */ (function () {
|
|
|
1255
1325
|
|
|
1256
1326
|
/* eslint-disable header/header */
|
|
1257
1327
|
var name = "@azure/msal-common";
|
|
1258
|
-
var version = "
|
|
1328
|
+
var version = "5.1.0";
|
|
1259
1329
|
|
|
1260
1330
|
/*
|
|
1261
1331
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1266,7 +1336,7 @@ var version = "4.5.0";
|
|
|
1266
1336
|
*
|
|
1267
1337
|
* Key:Value Schema:
|
|
1268
1338
|
*
|
|
1269
|
-
* Key: <home_account_id*>-<environment>-<credential_type>-<client_id>-<realm*>-<target
|
|
1339
|
+
* Key: <home_account_id*>-<environment>-<credential_type>-<client_id>-<realm*>-<target*>-<scheme>
|
|
1270
1340
|
*
|
|
1271
1341
|
* Value Schema:
|
|
1272
1342
|
* {
|
|
@@ -1279,6 +1349,7 @@ var version = "4.5.0";
|
|
|
1279
1349
|
* realm: Full tenant or organizational identifier that the account belongs to
|
|
1280
1350
|
* target: Permissions that are included in the token, or for refresh tokens, the resource identifier.
|
|
1281
1351
|
* oboAssertion: access token passed in as part of OBO request
|
|
1352
|
+
* tokenType: Matches the authentication scheme for which the token was issued (i.e. Bearer or pop)
|
|
1282
1353
|
* }
|
|
1283
1354
|
*/
|
|
1284
1355
|
var CredentialEntity = /** @class */ (function () {
|
|
@@ -1306,7 +1377,7 @@ var CredentialEntity = /** @class */ (function () {
|
|
|
1306
1377
|
* generates credential key
|
|
1307
1378
|
*/
|
|
1308
1379
|
CredentialEntity.prototype.generateCredentialKey = function () {
|
|
1309
|
-
return CredentialEntity.generateCredentialCacheKey(this.homeAccountId, this.environment, this.credentialType, this.clientId, this.realm, this.target, this.familyId);
|
|
1380
|
+
return CredentialEntity.generateCredentialCacheKey(this.homeAccountId, this.environment, this.credentialType, this.clientId, this.realm, this.target, this.familyId, this.tokenType);
|
|
1310
1381
|
};
|
|
1311
1382
|
/**
|
|
1312
1383
|
* returns the type of the cache (in this case credential)
|
|
@@ -1316,6 +1387,7 @@ var CredentialEntity = /** @class */ (function () {
|
|
|
1316
1387
|
case exports.CredentialType.ID_TOKEN:
|
|
1317
1388
|
return exports.CacheType.ID_TOKEN;
|
|
1318
1389
|
case exports.CredentialType.ACCESS_TOKEN:
|
|
1390
|
+
case exports.CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME:
|
|
1319
1391
|
return exports.CacheType.ACCESS_TOKEN;
|
|
1320
1392
|
case exports.CredentialType.REFRESH_TOKEN:
|
|
1321
1393
|
return exports.CacheType.REFRESH_TOKEN;
|
|
@@ -1347,13 +1419,18 @@ var CredentialEntity = /** @class */ (function () {
|
|
|
1347
1419
|
};
|
|
1348
1420
|
/**
|
|
1349
1421
|
* generates credential key
|
|
1422
|
+
* <home_account_id*>-\<environment>-<credential_type>-<client_id>-<realm\*>-<target\*>-<scheme\*>
|
|
1350
1423
|
*/
|
|
1351
|
-
CredentialEntity.generateCredentialCacheKey = function (homeAccountId, environment, credentialType, clientId, realm, target, familyId) {
|
|
1424
|
+
CredentialEntity.generateCredentialCacheKey = function (homeAccountId, environment, credentialType, clientId, realm, target, familyId, tokenType) {
|
|
1352
1425
|
var credentialKey = [
|
|
1353
1426
|
this.generateAccountIdForCacheKey(homeAccountId, environment),
|
|
1354
1427
|
this.generateCredentialIdForCacheKey(credentialType, clientId, realm, familyId),
|
|
1355
|
-
this.generateTargetForCacheKey(target)
|
|
1428
|
+
this.generateTargetForCacheKey(target)
|
|
1356
1429
|
];
|
|
1430
|
+
// PoP Tokens and SSH certs include scheme in cache key
|
|
1431
|
+
if (tokenType && tokenType !== exports.AuthenticationScheme.BEARER) {
|
|
1432
|
+
credentialKey.push(tokenType.toLowerCase());
|
|
1433
|
+
}
|
|
1357
1434
|
return credentialKey.join(Separators.CACHE_KEY_SEPARATOR).toLowerCase();
|
|
1358
1435
|
};
|
|
1359
1436
|
/**
|
|
@@ -1462,15 +1539,31 @@ var ClientConfigurationErrorMessage = {
|
|
|
1462
1539
|
},
|
|
1463
1540
|
invalidCloudDiscoveryMetadata: {
|
|
1464
1541
|
code: "invalid_cloud_discovery_metadata",
|
|
1465
|
-
desc: "Invalid cloudDiscoveryMetadata provided. Must be a JSON object containing tenant_discovery_endpoint and metadata fields"
|
|
1542
|
+
desc: "Invalid cloudDiscoveryMetadata provided. Must be a stringified JSON object containing tenant_discovery_endpoint and metadata fields"
|
|
1466
1543
|
},
|
|
1467
1544
|
invalidAuthorityMetadata: {
|
|
1468
1545
|
code: "invalid_authority_metadata",
|
|
1469
|
-
desc: "Invalid authorityMetadata provided. Must by a JSON object containing authorization_endpoint, token_endpoint,
|
|
1546
|
+
desc: "Invalid authorityMetadata provided. Must by a stringified JSON object containing authorization_endpoint, token_endpoint, issuer fields."
|
|
1470
1547
|
},
|
|
1471
1548
|
untrustedAuthority: {
|
|
1472
1549
|
code: "untrusted_authority",
|
|
1473
1550
|
desc: "The provided authority is not a trusted authority. Please include this authority in the knownAuthorities config parameter."
|
|
1551
|
+
},
|
|
1552
|
+
missingSshJwk: {
|
|
1553
|
+
code: "missing_ssh_jwk",
|
|
1554
|
+
desc: "Missing sshJwk in SSH certificate request. A stringified JSON Web Key is required when using the SSH authentication scheme."
|
|
1555
|
+
},
|
|
1556
|
+
missingSshKid: {
|
|
1557
|
+
code: "missing_ssh_kid",
|
|
1558
|
+
desc: "Missing sshKid in SSH certificate request. A string that uniquely identifies the public SSH key is required when using the SSH authentication scheme."
|
|
1559
|
+
},
|
|
1560
|
+
missingNonceAuthenticationHeader: {
|
|
1561
|
+
code: "missing_nonce_authentication_header",
|
|
1562
|
+
desc: "Unable to find an authentication header containing server nonce. Either the Authentication-Info or WWW-Authenticate headers must be present in order to obtain a server nonce."
|
|
1563
|
+
},
|
|
1564
|
+
invalidAuthenticationHeader: {
|
|
1565
|
+
code: "invalid_authentication_header",
|
|
1566
|
+
desc: "Invalid authentication header provided"
|
|
1474
1567
|
}
|
|
1475
1568
|
};
|
|
1476
1569
|
/**
|
|
@@ -1592,6 +1685,30 @@ var ClientConfigurationError = /** @class */ (function (_super) {
|
|
|
1592
1685
|
ClientConfigurationError.createUntrustedAuthorityError = function () {
|
|
1593
1686
|
return new ClientConfigurationError(ClientConfigurationErrorMessage.untrustedAuthority.code, ClientConfigurationErrorMessage.untrustedAuthority.desc);
|
|
1594
1687
|
};
|
|
1688
|
+
/*
|
|
1689
|
+
* Throws an error when the authentication scheme is set to SSH but the SSH public key is omitted from the request
|
|
1690
|
+
*/
|
|
1691
|
+
ClientConfigurationError.createMissingSshJwkError = function () {
|
|
1692
|
+
return new ClientConfigurationError(ClientConfigurationErrorMessage.missingSshJwk.code, ClientConfigurationErrorMessage.missingSshJwk.desc);
|
|
1693
|
+
};
|
|
1694
|
+
/**
|
|
1695
|
+
* Throws an error when the authentication scheme is set to SSH but the SSH public key ID is omitted from the request
|
|
1696
|
+
*/
|
|
1697
|
+
ClientConfigurationError.createMissingSshKidError = function () {
|
|
1698
|
+
return new ClientConfigurationError(ClientConfigurationErrorMessage.missingSshKid.code, ClientConfigurationErrorMessage.missingSshKid.desc);
|
|
1699
|
+
};
|
|
1700
|
+
/**
|
|
1701
|
+
* Throws error when provided headers don't contain a header that a server nonce can be extracted from
|
|
1702
|
+
*/
|
|
1703
|
+
ClientConfigurationError.createMissingNonceAuthenticationHeadersError = function () {
|
|
1704
|
+
return new ClientConfigurationError(ClientConfigurationErrorMessage.missingNonceAuthenticationHeader.code, ClientConfigurationErrorMessage.missingNonceAuthenticationHeader.desc);
|
|
1705
|
+
};
|
|
1706
|
+
/**
|
|
1707
|
+
* Throws error when a provided header is invalid in any way
|
|
1708
|
+
*/
|
|
1709
|
+
ClientConfigurationError.createInvalidAuthenticationHeaderError = function (invalidHeaderName, details) {
|
|
1710
|
+
return new ClientConfigurationError(ClientConfigurationErrorMessage.invalidAuthenticationHeader.code, ClientConfigurationErrorMessage.invalidAuthenticationHeader.desc + ". Invalid header: " + invalidHeaderName + ". Details: " + details);
|
|
1711
|
+
};
|
|
1595
1712
|
return ClientConfigurationError;
|
|
1596
1713
|
}(ClientAuthError));
|
|
1597
1714
|
|
|
@@ -1817,6 +1934,10 @@ function buildClientInfoFromHomeAccountId(homeAccountId) {
|
|
|
1817
1934
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
1818
1935
|
* Licensed under the MIT License.
|
|
1819
1936
|
*/
|
|
1937
|
+
/**
|
|
1938
|
+
* Authority types supported by MSAL.
|
|
1939
|
+
*/
|
|
1940
|
+
exports.AuthorityType = void 0;
|
|
1820
1941
|
(function (AuthorityType) {
|
|
1821
1942
|
AuthorityType[AuthorityType["Default"] = 0] = "Default";
|
|
1822
1943
|
AuthorityType[AuthorityType["Adfs"] = 1] = "Adfs";
|
|
@@ -1922,14 +2043,14 @@ var AccountEntity = /** @class */ (function () {
|
|
|
1922
2043
|
* @param idToken
|
|
1923
2044
|
* @param policy
|
|
1924
2045
|
*/
|
|
1925
|
-
AccountEntity.createAccount = function (clientInfo, homeAccountId,
|
|
2046
|
+
AccountEntity.createAccount = function (clientInfo, homeAccountId, idToken, authority, oboAssertion, cloudGraphHostName, msGraphHost, environment) {
|
|
1926
2047
|
var _a, _b, _c, _d, _e, _f;
|
|
1927
2048
|
var account = new AccountEntity();
|
|
1928
2049
|
account.authorityType = exports.CacheAccountType.MSSTS_ACCOUNT_TYPE;
|
|
1929
2050
|
account.clientInfo = clientInfo;
|
|
1930
2051
|
account.homeAccountId = homeAccountId;
|
|
1931
|
-
var env = authority.getPreferredCache();
|
|
1932
|
-
if (
|
|
2052
|
+
var env = environment || (authority && authority.getPreferredCache());
|
|
2053
|
+
if (!env) {
|
|
1933
2054
|
throw ClientAuthError.createInvalidCacheEnvironmentError();
|
|
1934
2055
|
}
|
|
1935
2056
|
account.environment = env;
|
|
@@ -1956,16 +2077,16 @@ var AccountEntity = /** @class */ (function () {
|
|
|
1956
2077
|
* @param authority
|
|
1957
2078
|
* @param idToken
|
|
1958
2079
|
*/
|
|
1959
|
-
AccountEntity.createGenericAccount = function (
|
|
2080
|
+
AccountEntity.createGenericAccount = function (homeAccountId, idToken, authority, oboAssertion, cloudGraphHostName, msGraphHost, environment) {
|
|
1960
2081
|
var _a, _b, _c, _d;
|
|
1961
2082
|
var account = new AccountEntity();
|
|
1962
|
-
account.authorityType = (authority.authorityType === exports.AuthorityType.Adfs) ? exports.CacheAccountType.ADFS_ACCOUNT_TYPE : exports.CacheAccountType.GENERIC_ACCOUNT_TYPE;
|
|
2083
|
+
account.authorityType = (authority && authority.authorityType === exports.AuthorityType.Adfs) ? exports.CacheAccountType.ADFS_ACCOUNT_TYPE : exports.CacheAccountType.GENERIC_ACCOUNT_TYPE;
|
|
1963
2084
|
account.homeAccountId = homeAccountId;
|
|
1964
2085
|
// non AAD scenarios can have empty realm
|
|
1965
2086
|
account.realm = "";
|
|
1966
2087
|
account.oboAssertion = oboAssertion;
|
|
1967
|
-
var env = authority.getPreferredCache();
|
|
1968
|
-
if (
|
|
2088
|
+
var env = environment || authority && authority.getPreferredCache();
|
|
2089
|
+
if (!env) {
|
|
1969
2090
|
throw ClientAuthError.createInvalidCacheEnvironmentError();
|
|
1970
2091
|
}
|
|
1971
2092
|
if (idToken) {
|
|
@@ -2131,49 +2252,75 @@ var CacheManager = /** @class */ (function () {
|
|
|
2131
2252
|
* @param cacheRecord
|
|
2132
2253
|
*/
|
|
2133
2254
|
CacheManager.prototype.saveCacheRecord = function (cacheRecord) {
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2255
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2256
|
+
return __generator(this, function (_a) {
|
|
2257
|
+
switch (_a.label) {
|
|
2258
|
+
case 0:
|
|
2259
|
+
if (!cacheRecord) {
|
|
2260
|
+
throw ClientAuthError.createNullOrUndefinedCacheRecord();
|
|
2261
|
+
}
|
|
2262
|
+
if (!!cacheRecord.account) {
|
|
2263
|
+
this.setAccount(cacheRecord.account);
|
|
2264
|
+
}
|
|
2265
|
+
if (!!cacheRecord.idToken) {
|
|
2266
|
+
this.setIdTokenCredential(cacheRecord.idToken);
|
|
2267
|
+
}
|
|
2268
|
+
if (!!!cacheRecord.accessToken) return [3 /*break*/, 2];
|
|
2269
|
+
return [4 /*yield*/, this.saveAccessToken(cacheRecord.accessToken)];
|
|
2270
|
+
case 1:
|
|
2271
|
+
_a.sent();
|
|
2272
|
+
_a.label = 2;
|
|
2273
|
+
case 2:
|
|
2274
|
+
if (!!cacheRecord.refreshToken) {
|
|
2275
|
+
this.setRefreshTokenCredential(cacheRecord.refreshToken);
|
|
2276
|
+
}
|
|
2277
|
+
if (!!cacheRecord.appMetadata) {
|
|
2278
|
+
this.setAppMetadata(cacheRecord.appMetadata);
|
|
2279
|
+
}
|
|
2280
|
+
return [2 /*return*/];
|
|
2281
|
+
}
|
|
2282
|
+
});
|
|
2283
|
+
});
|
|
2152
2284
|
};
|
|
2153
2285
|
/**
|
|
2154
2286
|
* saves access token credential
|
|
2155
2287
|
* @param credential
|
|
2156
2288
|
*/
|
|
2157
2289
|
CacheManager.prototype.saveAccessToken = function (credential) {
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2290
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2291
|
+
var currentTokenCache, currentScopes, currentAccessTokens, removedAccessTokens_1;
|
|
2292
|
+
var _this = this;
|
|
2293
|
+
return __generator(this, function (_a) {
|
|
2294
|
+
switch (_a.label) {
|
|
2295
|
+
case 0:
|
|
2296
|
+
currentTokenCache = this.getCredentialsFilteredBy({
|
|
2297
|
+
clientId: credential.clientId,
|
|
2298
|
+
credentialType: credential.credentialType,
|
|
2299
|
+
environment: credential.environment,
|
|
2300
|
+
homeAccountId: credential.homeAccountId,
|
|
2301
|
+
realm: credential.realm,
|
|
2302
|
+
tokenType: credential.tokenType
|
|
2303
|
+
});
|
|
2304
|
+
currentScopes = ScopeSet.fromString(credential.target);
|
|
2305
|
+
currentAccessTokens = Object.keys(currentTokenCache.accessTokens).map(function (key) { return currentTokenCache.accessTokens[key]; });
|
|
2306
|
+
if (!currentAccessTokens) return [3 /*break*/, 2];
|
|
2307
|
+
removedAccessTokens_1 = [];
|
|
2308
|
+
currentAccessTokens.forEach(function (tokenEntity) {
|
|
2309
|
+
var tokenScopeSet = ScopeSet.fromString(tokenEntity.target);
|
|
2310
|
+
if (tokenScopeSet.intersectingScopeSets(currentScopes)) {
|
|
2311
|
+
removedAccessTokens_1.push(_this.removeCredential(tokenEntity));
|
|
2312
|
+
}
|
|
2313
|
+
});
|
|
2314
|
+
return [4 /*yield*/, Promise.all(removedAccessTokens_1)];
|
|
2315
|
+
case 1:
|
|
2316
|
+
_a.sent();
|
|
2317
|
+
_a.label = 2;
|
|
2318
|
+
case 2:
|
|
2319
|
+
this.setAccessTokenCredential(credential);
|
|
2320
|
+
return [2 /*return*/];
|
|
2173
2321
|
}
|
|
2174
2322
|
});
|
|
2175
|
-
}
|
|
2176
|
-
this.setAccessTokenCredential(credential);
|
|
2323
|
+
});
|
|
2177
2324
|
};
|
|
2178
2325
|
/**
|
|
2179
2326
|
* retrieve accounts matching all provided filters; if no filter is set, get all accounts
|
|
@@ -2224,7 +2371,7 @@ var CacheManager = /** @class */ (function () {
|
|
|
2224
2371
|
* @param target
|
|
2225
2372
|
*/
|
|
2226
2373
|
CacheManager.prototype.getCredentialsFilteredBy = function (filter) {
|
|
2227
|
-
return this.getCredentialsFilteredByInternal(filter.homeAccountId, filter.environment, filter.credentialType, filter.clientId, filter.familyId, filter.realm, filter.target, filter.oboAssertion);
|
|
2374
|
+
return this.getCredentialsFilteredByInternal(filter.homeAccountId, filter.environment, filter.credentialType, filter.clientId, filter.familyId, filter.realm, filter.target, filter.oboAssertion, filter.tokenType, filter.keyId);
|
|
2228
2375
|
};
|
|
2229
2376
|
/**
|
|
2230
2377
|
* Support function to help match credentials
|
|
@@ -2234,8 +2381,10 @@ var CacheManager = /** @class */ (function () {
|
|
|
2234
2381
|
* @param clientId
|
|
2235
2382
|
* @param realm
|
|
2236
2383
|
* @param target
|
|
2384
|
+
* @param oboAssertion
|
|
2385
|
+
* @param tokenType
|
|
2237
2386
|
*/
|
|
2238
|
-
CacheManager.prototype.getCredentialsFilteredByInternal = function (homeAccountId, environment, credentialType, clientId, familyId, realm, target, oboAssertion) {
|
|
2387
|
+
CacheManager.prototype.getCredentialsFilteredByInternal = function (homeAccountId, environment, credentialType, clientId, familyId, realm, target, oboAssertion, tokenType, keyId) {
|
|
2239
2388
|
var _this = this;
|
|
2240
2389
|
var allCacheKeys = this.getKeys();
|
|
2241
2390
|
var matchingCredentials = {
|
|
@@ -2282,6 +2431,28 @@ var CacheManager = /** @class */ (function () {
|
|
|
2282
2431
|
if (!!target && !_this.matchTarget(entity, target)) {
|
|
2283
2432
|
return;
|
|
2284
2433
|
}
|
|
2434
|
+
// Access Token with Auth Scheme specific matching
|
|
2435
|
+
if (credentialType === exports.CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME) {
|
|
2436
|
+
if (!!tokenType && !_this.matchTokenType(entity, tokenType)) {
|
|
2437
|
+
return;
|
|
2438
|
+
}
|
|
2439
|
+
switch (tokenType) {
|
|
2440
|
+
case exports.AuthenticationScheme.POP:
|
|
2441
|
+
// This check avoids matching outdated POP tokens that don't have the <-scheme> in the cache key
|
|
2442
|
+
if (cacheKey.indexOf(exports.AuthenticationScheme.POP) === -1) {
|
|
2443
|
+
// AccessToken_With_AuthScheme that doesn't have "-pop" in the key is outdated and needs to be removed
|
|
2444
|
+
_this.removeItem(cacheKey, exports.CacheSchemaType.CREDENTIAL);
|
|
2445
|
+
return;
|
|
2446
|
+
}
|
|
2447
|
+
break;
|
|
2448
|
+
case exports.AuthenticationScheme.SSH:
|
|
2449
|
+
// KeyId (sshKid) in request must match cached SSH certificate keyId because SSH cert is bound to a specific key
|
|
2450
|
+
if (keyId && !_this.matchKeyId(entity, keyId)) {
|
|
2451
|
+
return;
|
|
2452
|
+
}
|
|
2453
|
+
break;
|
|
2454
|
+
}
|
|
2455
|
+
}
|
|
2285
2456
|
switch (credType) {
|
|
2286
2457
|
case exports.CredentialType.ID_TOKEN:
|
|
2287
2458
|
matchingCredentials.idTokens[cacheKey] = entity;
|
|
@@ -2362,56 +2533,112 @@ var CacheManager = /** @class */ (function () {
|
|
|
2362
2533
|
* Removes all accounts and related tokens from cache.
|
|
2363
2534
|
*/
|
|
2364
2535
|
CacheManager.prototype.removeAllAccounts = function () {
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2536
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2537
|
+
var allCacheKeys, removedAccounts;
|
|
2538
|
+
var _this = this;
|
|
2539
|
+
return __generator(this, function (_a) {
|
|
2540
|
+
switch (_a.label) {
|
|
2541
|
+
case 0:
|
|
2542
|
+
allCacheKeys = this.getKeys();
|
|
2543
|
+
removedAccounts = [];
|
|
2544
|
+
allCacheKeys.forEach(function (cacheKey) {
|
|
2545
|
+
var entity = _this.getAccount(cacheKey);
|
|
2546
|
+
if (!entity) {
|
|
2547
|
+
return;
|
|
2548
|
+
}
|
|
2549
|
+
removedAccounts.push(_this.removeAccount(cacheKey));
|
|
2550
|
+
});
|
|
2551
|
+
return [4 /*yield*/, Promise.all(removedAccounts)];
|
|
2552
|
+
case 1:
|
|
2553
|
+
_a.sent();
|
|
2554
|
+
return [2 /*return*/, true];
|
|
2555
|
+
}
|
|
2556
|
+
});
|
|
2373
2557
|
});
|
|
2374
|
-
return true;
|
|
2375
2558
|
};
|
|
2376
2559
|
/**
|
|
2377
2560
|
* returns a boolean if the given account is removed
|
|
2378
2561
|
* @param account
|
|
2379
2562
|
*/
|
|
2380
2563
|
CacheManager.prototype.removeAccount = function (accountKey) {
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2564
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2565
|
+
var account;
|
|
2566
|
+
return __generator(this, function (_a) {
|
|
2567
|
+
switch (_a.label) {
|
|
2568
|
+
case 0:
|
|
2569
|
+
account = this.getAccount(accountKey);
|
|
2570
|
+
if (!account) {
|
|
2571
|
+
throw ClientAuthError.createNoAccountFoundError();
|
|
2572
|
+
}
|
|
2573
|
+
return [4 /*yield*/, this.removeAccountContext(account)];
|
|
2574
|
+
case 1: return [2 /*return*/, ((_a.sent()) && this.removeItem(accountKey, exports.CacheSchemaType.ACCOUNT))];
|
|
2575
|
+
}
|
|
2576
|
+
});
|
|
2577
|
+
});
|
|
2386
2578
|
};
|
|
2387
2579
|
/**
|
|
2388
2580
|
* returns a boolean if the given account is removed
|
|
2389
2581
|
* @param account
|
|
2390
2582
|
*/
|
|
2391
2583
|
CacheManager.prototype.removeAccountContext = function (account) {
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2584
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2585
|
+
var allCacheKeys, accountId, removedCredentials;
|
|
2586
|
+
var _this = this;
|
|
2587
|
+
return __generator(this, function (_a) {
|
|
2588
|
+
switch (_a.label) {
|
|
2589
|
+
case 0:
|
|
2590
|
+
allCacheKeys = this.getKeys();
|
|
2591
|
+
accountId = account.generateAccountId();
|
|
2592
|
+
removedCredentials = [];
|
|
2593
|
+
allCacheKeys.forEach(function (cacheKey) {
|
|
2594
|
+
// don't parse any non-credential type cache entities
|
|
2595
|
+
var credType = CredentialEntity.getCredentialType(cacheKey);
|
|
2596
|
+
if (credType === Constants.NOT_DEFINED) {
|
|
2597
|
+
return;
|
|
2598
|
+
}
|
|
2599
|
+
var cacheEntity = _this.getSpecificCredential(cacheKey, credType);
|
|
2600
|
+
if (!!cacheEntity && accountId === cacheEntity.generateAccountId()) {
|
|
2601
|
+
removedCredentials.push(_this.removeCredential(cacheEntity));
|
|
2602
|
+
}
|
|
2603
|
+
});
|
|
2604
|
+
return [4 /*yield*/, Promise.all(removedCredentials)];
|
|
2605
|
+
case 1:
|
|
2606
|
+
_a.sent();
|
|
2607
|
+
return [2 /*return*/, true];
|
|
2608
|
+
}
|
|
2609
|
+
});
|
|
2405
2610
|
});
|
|
2406
|
-
return true;
|
|
2407
2611
|
};
|
|
2408
2612
|
/**
|
|
2409
2613
|
* returns a boolean if the given credential is removed
|
|
2410
2614
|
* @param credential
|
|
2411
2615
|
*/
|
|
2412
2616
|
CacheManager.prototype.removeCredential = function (credential) {
|
|
2413
|
-
|
|
2414
|
-
|
|
2617
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2618
|
+
var key, accessTokenWithAuthSchemeEntity, kid;
|
|
2619
|
+
return __generator(this, function (_a) {
|
|
2620
|
+
switch (_a.label) {
|
|
2621
|
+
case 0:
|
|
2622
|
+
key = credential.generateCredentialKey();
|
|
2623
|
+
if (!(credential.credentialType.toLowerCase() === exports.CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME.toLowerCase())) return [3 /*break*/, 4];
|
|
2624
|
+
if (!(credential.tokenType === exports.AuthenticationScheme.POP)) return [3 /*break*/, 4];
|
|
2625
|
+
accessTokenWithAuthSchemeEntity = credential;
|
|
2626
|
+
kid = accessTokenWithAuthSchemeEntity.keyId;
|
|
2627
|
+
if (!kid) return [3 /*break*/, 4];
|
|
2628
|
+
_a.label = 1;
|
|
2629
|
+
case 1:
|
|
2630
|
+
_a.trys.push([1, 3, , 4]);
|
|
2631
|
+
return [4 /*yield*/, this.cryptoImpl.removeTokenBindingKey(kid)];
|
|
2632
|
+
case 2:
|
|
2633
|
+
_a.sent();
|
|
2634
|
+
return [3 /*break*/, 4];
|
|
2635
|
+
case 3:
|
|
2636
|
+
_a.sent();
|
|
2637
|
+
throw ClientAuthError.createBindingKeyNotRemovedError();
|
|
2638
|
+
case 4: return [2 /*return*/, this.removeItem(key, exports.CacheSchemaType.CREDENTIAL)];
|
|
2639
|
+
}
|
|
2640
|
+
});
|
|
2641
|
+
});
|
|
2415
2642
|
};
|
|
2416
2643
|
/**
|
|
2417
2644
|
* Removes all app metadata objects from cache.
|
|
@@ -2434,10 +2661,10 @@ var CacheManager = /** @class */ (function () {
|
|
|
2434
2661
|
* @param environment
|
|
2435
2662
|
* @param authScheme
|
|
2436
2663
|
*/
|
|
2437
|
-
CacheManager.prototype.readCacheRecord = function (account, clientId, scopes, environment, authScheme) {
|
|
2664
|
+
CacheManager.prototype.readCacheRecord = function (account, clientId, scopes, environment, authScheme, keyId) {
|
|
2438
2665
|
var cachedAccount = this.readAccountFromCache(account);
|
|
2439
2666
|
var cachedIdToken = this.readIdTokenFromCache(clientId, account);
|
|
2440
|
-
var cachedAccessToken = this.readAccessTokenFromCache(clientId, account, scopes, authScheme);
|
|
2667
|
+
var cachedAccessToken = this.readAccessTokenFromCache(clientId, account, scopes, authScheme, keyId);
|
|
2441
2668
|
var cachedRefreshToken = this.readRefreshTokenFromCache(clientId, account, false);
|
|
2442
2669
|
var cachedAppMetadata = this.readAppMetadataFromCache(environment, clientId);
|
|
2443
2670
|
if (cachedAccount && cachedIdToken) {
|
|
@@ -2491,8 +2718,9 @@ var CacheManager = /** @class */ (function () {
|
|
|
2491
2718
|
* @param scopes
|
|
2492
2719
|
* @param authScheme
|
|
2493
2720
|
*/
|
|
2494
|
-
CacheManager.prototype.readAccessTokenFromCache = function (clientId, account, scopes, authScheme) {
|
|
2495
|
-
|
|
2721
|
+
CacheManager.prototype.readAccessTokenFromCache = function (clientId, account, scopes, authScheme, keyId) {
|
|
2722
|
+
// Distinguish between Bearer and PoP/SSH token cache types
|
|
2723
|
+
var credentialType = (authScheme && authScheme !== exports.AuthenticationScheme.BEARER) ? exports.CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME : exports.CredentialType.ACCESS_TOKEN;
|
|
2496
2724
|
var accessTokenFilter = {
|
|
2497
2725
|
homeAccountId: account.homeAccountId,
|
|
2498
2726
|
environment: account.environment,
|
|
@@ -2500,6 +2728,8 @@ var CacheManager = /** @class */ (function () {
|
|
|
2500
2728
|
clientId: clientId,
|
|
2501
2729
|
realm: account.tenantId,
|
|
2502
2730
|
target: scopes.printScopesLowerCase(),
|
|
2731
|
+
tokenType: authScheme,
|
|
2732
|
+
keyId: keyId
|
|
2503
2733
|
};
|
|
2504
2734
|
var credentialCache = this.getCredentialsFilteredBy(accessTokenFilter);
|
|
2505
2735
|
var accessTokens = Object.keys(credentialCache.accessTokens).map(function (key) { return credentialCache.accessTokens[key]; });
|
|
@@ -2644,6 +2874,22 @@ var CacheManager = /** @class */ (function () {
|
|
|
2644
2874
|
}
|
|
2645
2875
|
return entityScopeSet.containsScopeSet(requestTargetScopeSet);
|
|
2646
2876
|
};
|
|
2877
|
+
/**
|
|
2878
|
+
* Returns true if the credential's tokenType or Authentication Scheme matches the one in the request, false otherwise
|
|
2879
|
+
* @param entity
|
|
2880
|
+
* @param tokenType
|
|
2881
|
+
*/
|
|
2882
|
+
CacheManager.prototype.matchTokenType = function (entity, tokenType) {
|
|
2883
|
+
return !!(entity.tokenType && entity.tokenType === tokenType);
|
|
2884
|
+
};
|
|
2885
|
+
/**
|
|
2886
|
+
* Returns true if the credential's keyId matches the one in the request, false otherwise
|
|
2887
|
+
* @param entity
|
|
2888
|
+
* @param tokenType
|
|
2889
|
+
*/
|
|
2890
|
+
CacheManager.prototype.matchKeyId = function (entity, keyId) {
|
|
2891
|
+
return !!(entity.keyId && entity.keyId === keyId);
|
|
2892
|
+
};
|
|
2647
2893
|
/**
|
|
2648
2894
|
* returns if a given cache entity is of the type appmetadata
|
|
2649
2895
|
* @param key
|
|
@@ -2784,8 +3030,13 @@ var DefaultStorageClass = /** @class */ (function (_super) {
|
|
|
2784
3030
|
throw AuthError.createUnexpectedError(notImplErr);
|
|
2785
3031
|
};
|
|
2786
3032
|
DefaultStorageClass.prototype.clear = function () {
|
|
2787
|
-
|
|
2788
|
-
|
|
3033
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
3034
|
+
var notImplErr;
|
|
3035
|
+
return __generator(this, function (_a) {
|
|
3036
|
+
notImplErr = "Storage interface - clear() has not been implemented for the cacheStorage interface.";
|
|
3037
|
+
throw AuthError.createUnexpectedError(notImplErr);
|
|
3038
|
+
});
|
|
3039
|
+
});
|
|
2789
3040
|
};
|
|
2790
3041
|
return DefaultStorageClass;
|
|
2791
3042
|
}(CacheManager));
|
|
@@ -2847,10 +3098,11 @@ var DEFAULT_CLIENT_CREDENTIALS = {
|
|
|
2847
3098
|
*/
|
|
2848
3099
|
function buildClientConfiguration(_a) {
|
|
2849
3100
|
var userAuthOptions = _a.authOptions, userSystemOptions = _a.systemOptions, userLoggerOption = _a.loggerOptions, storageImplementation = _a.storageInterface, networkImplementation = _a.networkInterface, cryptoImplementation = _a.cryptoInterface, clientCredentials = _a.clientCredentials, libraryInfo = _a.libraryInfo, serverTelemetryManager = _a.serverTelemetryManager, persistencePlugin = _a.persistencePlugin, serializableCache = _a.serializableCache;
|
|
3101
|
+
var loggerOptions = __assign(__assign({}, DEFAULT_LOGGER_IMPLEMENTATION), userLoggerOption);
|
|
2850
3102
|
return {
|
|
2851
3103
|
authOptions: buildAuthOptions(userAuthOptions),
|
|
2852
3104
|
systemOptions: __assign(__assign({}, DEFAULT_SYSTEM_OPTIONS), userSystemOptions),
|
|
2853
|
-
loggerOptions:
|
|
3105
|
+
loggerOptions: loggerOptions,
|
|
2854
3106
|
storageInterface: storageImplementation || new DefaultStorageClass(userAuthOptions.clientId, DEFAULT_CRYPTO_IMPLEMENTATION),
|
|
2855
3107
|
networkInterface: networkImplementation || DEFAULT_NETWORK_IMPLEMENTATION,
|
|
2856
3108
|
cryptoInterface: cryptoImplementation || DEFAULT_CRYPTO_IMPLEMENTATION,
|
|
@@ -2962,12 +3214,18 @@ var ThrottlingUtils = /** @class */ (function () {
|
|
|
2962
3214
|
var currentSeconds = Date.now() / 1000;
|
|
2963
3215
|
return Math.floor(Math.min(currentSeconds + (time || ThrottlingConstants.DEFAULT_THROTTLE_TIME_SECONDS), currentSeconds + ThrottlingConstants.DEFAULT_MAX_THROTTLE_TIME_SECONDS) * 1000);
|
|
2964
3216
|
};
|
|
2965
|
-
ThrottlingUtils.removeThrottle = function (cacheManager, clientId,
|
|
3217
|
+
ThrottlingUtils.removeThrottle = function (cacheManager, clientId, request, homeAccountIdentifier) {
|
|
2966
3218
|
var thumbprint = {
|
|
2967
3219
|
clientId: clientId,
|
|
2968
|
-
authority: authority,
|
|
2969
|
-
scopes: scopes,
|
|
2970
|
-
homeAccountIdentifier: homeAccountIdentifier
|
|
3220
|
+
authority: request.authority,
|
|
3221
|
+
scopes: request.scopes,
|
|
3222
|
+
homeAccountIdentifier: homeAccountIdentifier,
|
|
3223
|
+
authenticationScheme: request.authenticationScheme,
|
|
3224
|
+
resourceRequestMethod: request.resourceRequestMethod,
|
|
3225
|
+
resourceRequestUri: request.resourceRequestUri,
|
|
3226
|
+
shrClaims: request.shrClaims,
|
|
3227
|
+
sshJwk: request.sshJwk,
|
|
3228
|
+
sshKid: request.sshKid
|
|
2971
3229
|
};
|
|
2972
3230
|
var key = this.generateThrottlingStorageKey(thumbprint);
|
|
2973
3231
|
return cacheManager.removeItem(key, exports.CacheSchemaType.THROTTLING);
|
|
@@ -3026,6 +3284,7 @@ var NetworkManager = /** @class */ (function () {
|
|
|
3026
3284
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3027
3285
|
* Licensed under the MIT License.
|
|
3028
3286
|
*/
|
|
3287
|
+
exports.CcsCredentialType = void 0;
|
|
3029
3288
|
(function (CcsCredentialType) {
|
|
3030
3289
|
CcsCredentialType["HOME_ACCOUNT_ID"] = "home_account_id";
|
|
3031
3290
|
CcsCredentialType["UPN"] = "UPN";
|
|
@@ -3504,6 +3763,15 @@ var RequestParameterBuilder = /** @class */ (function () {
|
|
|
3504
3763
|
this.parameters.set(AADServerParamKeys.REQ_CNF, encodeURIComponent(cnfString));
|
|
3505
3764
|
}
|
|
3506
3765
|
};
|
|
3766
|
+
/**
|
|
3767
|
+
* add SSH JWK and key ID to query params
|
|
3768
|
+
*/
|
|
3769
|
+
RequestParameterBuilder.prototype.addSshJwk = function (sshJwkString) {
|
|
3770
|
+
if (!StringUtils.isEmpty(sshJwkString)) {
|
|
3771
|
+
this.parameters.set(AADServerParamKeys.TOKEN_TYPE, exports.AuthenticationScheme.SSH);
|
|
3772
|
+
this.parameters.set(AADServerParamKeys.REQ_CNF, encodeURIComponent(sshJwkString));
|
|
3773
|
+
}
|
|
3774
|
+
};
|
|
3507
3775
|
/**
|
|
3508
3776
|
* add server telemetry fields
|
|
3509
3777
|
* @param serverTelemetryManager
|
|
@@ -3687,7 +3955,7 @@ var AccessTokenEntity = /** @class */ (function (_super) {
|
|
|
3687
3955
|
* @param expiresOn
|
|
3688
3956
|
* @param extExpiresOn
|
|
3689
3957
|
*/
|
|
3690
|
-
AccessTokenEntity.createAccessTokenEntity = function (homeAccountId, environment, accessToken, clientId, tenantId, scopes, expiresOn, extExpiresOn, cryptoUtils, refreshOn, tokenType, oboAssertion) {
|
|
3958
|
+
AccessTokenEntity.createAccessTokenEntity = function (homeAccountId, environment, accessToken, clientId, tenantId, scopes, expiresOn, extExpiresOn, cryptoUtils, refreshOn, tokenType, oboAssertion, keyId) {
|
|
3691
3959
|
var _a;
|
|
3692
3960
|
var atEntity = new AccessTokenEntity();
|
|
3693
3961
|
atEntity.homeAccountId = homeAccountId;
|
|
@@ -3710,15 +3978,21 @@ var AccessTokenEntity = /** @class */ (function (_super) {
|
|
|
3710
3978
|
atEntity.target = scopes;
|
|
3711
3979
|
atEntity.oboAssertion = oboAssertion;
|
|
3712
3980
|
atEntity.tokenType = StringUtils.isEmpty(tokenType) ? exports.AuthenticationScheme.BEARER : tokenType;
|
|
3713
|
-
// Create Access Token With
|
|
3714
|
-
if (atEntity.tokenType
|
|
3981
|
+
// Create Access Token With Auth Scheme instead of regular access token
|
|
3982
|
+
if (atEntity.tokenType !== exports.AuthenticationScheme.BEARER) {
|
|
3715
3983
|
atEntity.credentialType = exports.CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME;
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
|
|
3984
|
+
switch (atEntity.tokenType) {
|
|
3985
|
+
case exports.AuthenticationScheme.POP:
|
|
3986
|
+
// Make sure keyId is present and add it to credential
|
|
3987
|
+
var tokenClaims = AuthToken.extractTokenClaims(accessToken, cryptoUtils);
|
|
3988
|
+
if (!((_a = tokenClaims === null || tokenClaims === void 0 ? void 0 : tokenClaims.cnf) === null || _a === void 0 ? void 0 : _a.kid)) {
|
|
3989
|
+
throw ClientAuthError.createTokenClaimsRequiredError();
|
|
3990
|
+
}
|
|
3991
|
+
atEntity.keyId = tokenClaims.cnf.kid;
|
|
3992
|
+
break;
|
|
3993
|
+
case exports.AuthenticationScheme.SSH:
|
|
3994
|
+
atEntity.keyId = keyId;
|
|
3720
3995
|
}
|
|
3721
|
-
atEntity.keyId = tokenClaims.cnf.kid;
|
|
3722
3996
|
}
|
|
3723
3997
|
return atEntity;
|
|
3724
3998
|
};
|
|
@@ -3812,9 +4086,9 @@ var RefreshTokenEntity = /** @class */ (function (_super) {
|
|
|
3812
4086
|
* Licensed under the MIT License.
|
|
3813
4087
|
*/
|
|
3814
4088
|
/**
|
|
3815
|
-
*
|
|
4089
|
+
* InteractionRequiredServerErrorMessage contains string constants used by error codes and messages returned by the server indicating interaction is required
|
|
3816
4090
|
*/
|
|
3817
|
-
var
|
|
4091
|
+
var InteractionRequiredServerErrorMessage = [
|
|
3818
4092
|
"interaction_required",
|
|
3819
4093
|
"consent_required",
|
|
3820
4094
|
"login_required"
|
|
@@ -3827,7 +4101,16 @@ var InteractionRequiredAuthSubErrorMessage = [
|
|
|
3827
4101
|
"consent_required"
|
|
3828
4102
|
];
|
|
3829
4103
|
/**
|
|
3830
|
-
*
|
|
4104
|
+
* Interaction required errors defined by the SDK
|
|
4105
|
+
*/
|
|
4106
|
+
var InteractionRequiredAuthErrorMessage = {
|
|
4107
|
+
noTokensFoundError: {
|
|
4108
|
+
code: "no_tokens_found",
|
|
4109
|
+
desc: "No refresh token found in the cache. Please sign-in."
|
|
4110
|
+
}
|
|
4111
|
+
};
|
|
4112
|
+
/**
|
|
4113
|
+
* Error thrown when user interaction is required.
|
|
3831
4114
|
*/
|
|
3832
4115
|
var InteractionRequiredAuthError = /** @class */ (function (_super) {
|
|
3833
4116
|
__extends(InteractionRequiredAuthError, _super);
|
|
@@ -3837,16 +4120,28 @@ var InteractionRequiredAuthError = /** @class */ (function (_super) {
|
|
|
3837
4120
|
Object.setPrototypeOf(_this, InteractionRequiredAuthError.prototype);
|
|
3838
4121
|
return _this;
|
|
3839
4122
|
}
|
|
4123
|
+
/**
|
|
4124
|
+
* Helper function used to determine if an error thrown by the server requires interaction to resolve
|
|
4125
|
+
* @param errorCode
|
|
4126
|
+
* @param errorString
|
|
4127
|
+
* @param subError
|
|
4128
|
+
*/
|
|
3840
4129
|
InteractionRequiredAuthError.isInteractionRequiredError = function (errorCode, errorString, subError) {
|
|
3841
|
-
var isInteractionRequiredErrorCode = !!errorCode &&
|
|
4130
|
+
var isInteractionRequiredErrorCode = !!errorCode && InteractionRequiredServerErrorMessage.indexOf(errorCode) > -1;
|
|
3842
4131
|
var isInteractionRequiredSubError = !!subError && InteractionRequiredAuthSubErrorMessage.indexOf(subError) > -1;
|
|
3843
|
-
var isInteractionRequiredErrorDesc = !!errorString &&
|
|
4132
|
+
var isInteractionRequiredErrorDesc = !!errorString && InteractionRequiredServerErrorMessage.some(function (irErrorCode) {
|
|
3844
4133
|
return errorString.indexOf(irErrorCode) > -1;
|
|
3845
4134
|
});
|
|
3846
4135
|
return isInteractionRequiredErrorCode || isInteractionRequiredErrorDesc || isInteractionRequiredSubError;
|
|
3847
4136
|
};
|
|
4137
|
+
/**
|
|
4138
|
+
* Creates an error thrown when the authorization code required for a token request is null or empty.
|
|
4139
|
+
*/
|
|
4140
|
+
InteractionRequiredAuthError.createNoTokensFoundError = function () {
|
|
4141
|
+
return new InteractionRequiredAuthError(InteractionRequiredAuthErrorMessage.noTokensFoundError.code, InteractionRequiredAuthErrorMessage.noTokensFoundError.desc);
|
|
4142
|
+
};
|
|
3848
4143
|
return InteractionRequiredAuthError;
|
|
3849
|
-
}(
|
|
4144
|
+
}(AuthError));
|
|
3850
4145
|
|
|
3851
4146
|
/*
|
|
3852
4147
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -3915,7 +4210,7 @@ var ProtocolUtils = /** @class */ (function () {
|
|
|
3915
4210
|
}
|
|
3916
4211
|
try {
|
|
3917
4212
|
// Split the state between library state and user passed state and decode them separately
|
|
3918
|
-
var splitState =
|
|
4213
|
+
var splitState = state.split(Constants.RESOURCE_DELIM);
|
|
3919
4214
|
var libraryState = splitState[0];
|
|
3920
4215
|
var userState = splitState.length > 1 ? splitState.slice(1).join(Constants.RESOURCE_DELIM) : "";
|
|
3921
4216
|
var libraryStateString = cryptoObj.base64Decode(libraryState);
|
|
@@ -3954,7 +4249,7 @@ var UrlString = /** @class */ (function () {
|
|
|
3954
4249
|
get: function () {
|
|
3955
4250
|
return this._urlString;
|
|
3956
4251
|
},
|
|
3957
|
-
enumerable:
|
|
4252
|
+
enumerable: false,
|
|
3958
4253
|
configurable: true
|
|
3959
4254
|
});
|
|
3960
4255
|
/**
|
|
@@ -3998,22 +4293,6 @@ var UrlString = /** @class */ (function () {
|
|
|
3998
4293
|
throw ClientConfigurationError.createInsecureAuthorityUriError(this.urlString);
|
|
3999
4294
|
}
|
|
4000
4295
|
};
|
|
4001
|
-
/**
|
|
4002
|
-
* Function to remove query string params from url. Returns the new url.
|
|
4003
|
-
* @param url
|
|
4004
|
-
* @param name
|
|
4005
|
-
*/
|
|
4006
|
-
UrlString.prototype.urlRemoveQueryStringParameter = function (name) {
|
|
4007
|
-
var regex = new RegExp("(\\&" + name + "=)[^\&]+");
|
|
4008
|
-
this._urlString = this.urlString.replace(regex, "");
|
|
4009
|
-
// name=value&
|
|
4010
|
-
regex = new RegExp("(" + name + "=)[^\&]+&");
|
|
4011
|
-
this._urlString = this.urlString.replace(regex, "");
|
|
4012
|
-
// name=value
|
|
4013
|
-
regex = new RegExp("(" + name + "=)[^\&]+");
|
|
4014
|
-
this._urlString = this.urlString.replace(regex, "");
|
|
4015
|
-
return this.urlString;
|
|
4016
|
-
};
|
|
4017
4296
|
/**
|
|
4018
4297
|
* Given a url and a query string return the url with provided query string appended
|
|
4019
4298
|
* @param url
|
|
@@ -4134,7 +4413,8 @@ var UrlString = /** @class */ (function () {
|
|
|
4134
4413
|
* Check if the hash of the URL string contains known properties
|
|
4135
4414
|
*/
|
|
4136
4415
|
UrlString.hashContainsKnownProperties = function (hash) {
|
|
4137
|
-
if (StringUtils.isEmpty(hash)) {
|
|
4416
|
+
if (StringUtils.isEmpty(hash) || hash.indexOf("=") < 0) {
|
|
4417
|
+
// Hash doesn't contain key/value pairs
|
|
4138
4418
|
return false;
|
|
4139
4419
|
}
|
|
4140
4420
|
var parameters = UrlString.getDeserializedHash(hash);
|
|
@@ -4161,17 +4441,29 @@ var PopTokenGenerator = /** @class */ (function () {
|
|
|
4161
4441
|
}
|
|
4162
4442
|
PopTokenGenerator.prototype.generateCnf = function (request) {
|
|
4163
4443
|
return __awaiter(this, void 0, void 0, function () {
|
|
4164
|
-
var
|
|
4444
|
+
var reqCnf;
|
|
4445
|
+
return __generator(this, function (_a) {
|
|
4446
|
+
switch (_a.label) {
|
|
4447
|
+
case 0: return [4 /*yield*/, this.generateKid(request)];
|
|
4448
|
+
case 1:
|
|
4449
|
+
reqCnf = _a.sent();
|
|
4450
|
+
return [2 /*return*/, this.cryptoUtils.base64Encode(JSON.stringify(reqCnf))];
|
|
4451
|
+
}
|
|
4452
|
+
});
|
|
4453
|
+
});
|
|
4454
|
+
};
|
|
4455
|
+
PopTokenGenerator.prototype.generateKid = function (request) {
|
|
4456
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
4457
|
+
var kidThumbprint;
|
|
4165
4458
|
return __generator(this, function (_a) {
|
|
4166
4459
|
switch (_a.label) {
|
|
4167
4460
|
case 0: return [4 /*yield*/, this.cryptoUtils.getPublicKeyThumbprint(request)];
|
|
4168
4461
|
case 1:
|
|
4169
4462
|
kidThumbprint = _a.sent();
|
|
4170
|
-
|
|
4171
|
-
|
|
4172
|
-
|
|
4173
|
-
|
|
4174
|
-
return [2 /*return*/, this.cryptoUtils.base64Encode(JSON.stringify(reqCnf))];
|
|
4463
|
+
return [2 /*return*/, {
|
|
4464
|
+
kid: kidThumbprint,
|
|
4465
|
+
xms_ksl: KeyLocation.SW
|
|
4466
|
+
}];
|
|
4175
4467
|
}
|
|
4176
4468
|
});
|
|
4177
4469
|
});
|
|
@@ -4179,28 +4471,27 @@ var PopTokenGenerator = /** @class */ (function () {
|
|
|
4179
4471
|
PopTokenGenerator.prototype.signPopToken = function (accessToken, request) {
|
|
4180
4472
|
var _a;
|
|
4181
4473
|
return __awaiter(this, void 0, void 0, function () {
|
|
4182
|
-
var tokenClaims
|
|
4474
|
+
var tokenClaims;
|
|
4183
4475
|
return __generator(this, function (_b) {
|
|
4184
|
-
|
|
4476
|
+
tokenClaims = AuthToken.extractTokenClaims(accessToken, this.cryptoUtils);
|
|
4477
|
+
if (!((_a = tokenClaims === null || tokenClaims === void 0 ? void 0 : tokenClaims.cnf) === null || _a === void 0 ? void 0 : _a.kid)) {
|
|
4478
|
+
throw ClientAuthError.createTokenClaimsRequiredError();
|
|
4479
|
+
}
|
|
4480
|
+
return [2 /*return*/, this.signPayload(accessToken, tokenClaims.cnf.kid, request)];
|
|
4481
|
+
});
|
|
4482
|
+
});
|
|
4483
|
+
};
|
|
4484
|
+
PopTokenGenerator.prototype.signPayload = function (payload, kid, request, claims) {
|
|
4485
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
4486
|
+
var resourceRequestMethod, resourceRequestUri, shrClaims, shrNonce, resourceUrlString, resourceUrlComponents;
|
|
4487
|
+
return __generator(this, function (_a) {
|
|
4488
|
+
switch (_a.label) {
|
|
4185
4489
|
case 0:
|
|
4186
|
-
|
|
4187
|
-
resourceRequestMethod = request.resourceRequestMethod, resourceRequestUri = request.resourceRequestUri, shrClaims = request.shrClaims;
|
|
4490
|
+
resourceRequestMethod = request.resourceRequestMethod, resourceRequestUri = request.resourceRequestUri, shrClaims = request.shrClaims, shrNonce = request.shrNonce;
|
|
4188
4491
|
resourceUrlString = (resourceRequestUri) ? new UrlString(resourceRequestUri) : undefined;
|
|
4189
4492
|
resourceUrlComponents = resourceUrlString === null || resourceUrlString === void 0 ? void 0 : resourceUrlString.getUrlComponents();
|
|
4190
|
-
|
|
4191
|
-
|
|
4192
|
-
}
|
|
4193
|
-
return [4 /*yield*/, this.cryptoUtils.signJwt({
|
|
4194
|
-
at: accessToken,
|
|
4195
|
-
ts: TimeUtils.nowSeconds(),
|
|
4196
|
-
m: resourceRequestMethod === null || resourceRequestMethod === void 0 ? void 0 : resourceRequestMethod.toUpperCase(),
|
|
4197
|
-
u: resourceUrlComponents === null || resourceUrlComponents === void 0 ? void 0 : resourceUrlComponents.HostNameAndPort,
|
|
4198
|
-
nonce: this.cryptoUtils.createNewGuid(),
|
|
4199
|
-
p: resourceUrlComponents === null || resourceUrlComponents === void 0 ? void 0 : resourceUrlComponents.AbsolutePath,
|
|
4200
|
-
q: (resourceUrlComponents === null || resourceUrlComponents === void 0 ? void 0 : resourceUrlComponents.QueryString) ? [[], resourceUrlComponents.QueryString] : undefined,
|
|
4201
|
-
client_claims: shrClaims || undefined
|
|
4202
|
-
}, tokenClaims.cnf.kid)];
|
|
4203
|
-
case 1: return [2 /*return*/, _b.sent()];
|
|
4493
|
+
return [4 /*yield*/, this.cryptoUtils.signJwt(__assign({ at: payload, ts: TimeUtils.nowSeconds(), m: resourceRequestMethod === null || resourceRequestMethod === void 0 ? void 0 : resourceRequestMethod.toUpperCase(), u: resourceUrlComponents === null || resourceUrlComponents === void 0 ? void 0 : resourceUrlComponents.HostNameAndPort, nonce: shrNonce || this.cryptoUtils.createNewGuid(), p: resourceUrlComponents === null || resourceUrlComponents === void 0 ? void 0 : resourceUrlComponents.AbsolutePath, q: (resourceUrlComponents === null || resourceUrlComponents === void 0 ? void 0 : resourceUrlComponents.QueryString) ? [[], resourceUrlComponents.QueryString] : undefined, client_claims: shrClaims || undefined }, claims), kid)];
|
|
4494
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
4204
4495
|
}
|
|
4205
4496
|
});
|
|
4206
4497
|
});
|
|
@@ -4295,7 +4586,7 @@ var AppMetadataEntity = /** @class */ (function () {
|
|
|
4295
4586
|
get: function () {
|
|
4296
4587
|
return this.hasChanged;
|
|
4297
4588
|
},
|
|
4298
|
-
enumerable:
|
|
4589
|
+
enumerable: false,
|
|
4299
4590
|
configurable: true
|
|
4300
4591
|
});
|
|
4301
4592
|
Object.defineProperty(TokenCacheContext.prototype, "tokenCache", {
|
|
@@ -4305,7 +4596,7 @@ var AppMetadataEntity = /** @class */ (function () {
|
|
|
4305
4596
|
get: function () {
|
|
4306
4597
|
return this.cache;
|
|
4307
4598
|
},
|
|
4308
|
-
enumerable:
|
|
4599
|
+
enumerable: false,
|
|
4309
4600
|
configurable: true
|
|
4310
4601
|
});
|
|
4311
4602
|
return TokenCacheContext;
|
|
@@ -4390,10 +4681,12 @@ var ResponseHandler = /** @class */ (function () {
|
|
|
4390
4681
|
if (!!authCodePayload && !!authCodePayload.state) {
|
|
4391
4682
|
requestStateObj = ProtocolUtils.parseRequestState(this.cryptoObj, authCodePayload.state);
|
|
4392
4683
|
}
|
|
4684
|
+
// Add keyId from request to serverTokenResponse if defined
|
|
4685
|
+
serverTokenResponse.key_id = serverTokenResponse.key_id || request.sshKid || undefined;
|
|
4393
4686
|
cacheRecord = this.generateCacheRecord(serverTokenResponse, authority, reqTimestamp, idTokenObj, request.scopes, oboAssertion, authCodePayload);
|
|
4394
4687
|
_a.label = 1;
|
|
4395
4688
|
case 1:
|
|
4396
|
-
_a.trys.push([1, ,
|
|
4689
|
+
_a.trys.push([1, , 5, 8]);
|
|
4397
4690
|
if (!(this.persistencePlugin && this.serializableCache)) return [3 /*break*/, 3];
|
|
4398
4691
|
this.logger.verbose("Persistence enabled, calling beforeCacheAccess");
|
|
4399
4692
|
cacheContext = new TokenCacheContext(this.serializableCache, true);
|
|
@@ -4415,17 +4708,19 @@ var ResponseHandler = /** @class */ (function () {
|
|
|
4415
4708
|
return [2 /*return*/, ResponseHandler.generateAuthenticationResult(this.cryptoObj, authority, cacheRecord, false, request, idTokenObj, requestStateObj)];
|
|
4416
4709
|
}
|
|
4417
4710
|
}
|
|
4418
|
-
this.cacheStorage.saveCacheRecord(cacheRecord);
|
|
4419
|
-
return [3 /*break*/, 7];
|
|
4711
|
+
return [4 /*yield*/, this.cacheStorage.saveCacheRecord(cacheRecord)];
|
|
4420
4712
|
case 4:
|
|
4421
|
-
|
|
4713
|
+
_a.sent();
|
|
4714
|
+
return [3 /*break*/, 8];
|
|
4715
|
+
case 5:
|
|
4716
|
+
if (!(this.persistencePlugin && this.serializableCache && cacheContext)) return [3 /*break*/, 7];
|
|
4422
4717
|
this.logger.verbose("Persistence enabled, calling afterCacheAccess");
|
|
4423
4718
|
return [4 /*yield*/, this.persistencePlugin.afterCacheAccess(cacheContext)];
|
|
4424
|
-
case
|
|
4719
|
+
case 6:
|
|
4425
4720
|
_a.sent();
|
|
4426
|
-
_a.label =
|
|
4427
|
-
case
|
|
4428
|
-
case
|
|
4721
|
+
_a.label = 7;
|
|
4722
|
+
case 7: return [7 /*endfinally*/];
|
|
4723
|
+
case 8: return [2 /*return*/, ResponseHandler.generateAuthenticationResult(this.cryptoObj, authority, cacheRecord, false, request, idTokenObj, requestStateObj)];
|
|
4429
4724
|
}
|
|
4430
4725
|
});
|
|
4431
4726
|
});
|
|
@@ -4464,7 +4759,7 @@ var ResponseHandler = /** @class */ (function () {
|
|
|
4464
4759
|
var extendedTokenExpirationSeconds = tokenExpirationSeconds + extExpiresIn;
|
|
4465
4760
|
var refreshOnSeconds = refreshIn && refreshIn > 0 ? reqTimestamp + refreshIn : undefined;
|
|
4466
4761
|
// non AAD scenarios can have empty realm
|
|
4467
|
-
cachedAccessToken = AccessTokenEntity.createAccessTokenEntity(this.homeAccountIdentifier, env, serverTokenResponse.access_token || Constants.EMPTY_STRING, this.clientId, idTokenObj ? idTokenObj.claims.tid || Constants.EMPTY_STRING : authority.tenant, responseScopes.printScopes(), tokenExpirationSeconds, extendedTokenExpirationSeconds, this.cryptoObj, refreshOnSeconds, serverTokenResponse.token_type, oboAssertion);
|
|
4762
|
+
cachedAccessToken = AccessTokenEntity.createAccessTokenEntity(this.homeAccountIdentifier, env, serverTokenResponse.access_token || Constants.EMPTY_STRING, this.clientId, idTokenObj ? idTokenObj.claims.tid || Constants.EMPTY_STRING : authority.tenant, responseScopes.printScopes(), tokenExpirationSeconds, extendedTokenExpirationSeconds, this.cryptoObj, refreshOnSeconds, serverTokenResponse.token_type, oboAssertion, serverTokenResponse.key_id);
|
|
4468
4763
|
}
|
|
4469
4764
|
// refreshToken
|
|
4470
4765
|
var cachedRefreshToken = null;
|
|
@@ -4491,15 +4786,15 @@ var ResponseHandler = /** @class */ (function () {
|
|
|
4491
4786
|
// ADFS does not require client_info in the response
|
|
4492
4787
|
if (authorityType === exports.AuthorityType.Adfs) {
|
|
4493
4788
|
this.logger.verbose("Authority type is ADFS, creating ADFS account");
|
|
4494
|
-
return AccountEntity.createGenericAccount(
|
|
4789
|
+
return AccountEntity.createGenericAccount(this.homeAccountIdentifier, idToken, authority, oboAssertion, cloudGraphHostName, msGraphhost);
|
|
4495
4790
|
}
|
|
4496
4791
|
// This fallback applies to B2C as well as they fall under an AAD account type.
|
|
4497
4792
|
if (StringUtils.isEmpty(serverTokenResponse.client_info) && authority.protocolMode === "AAD") {
|
|
4498
4793
|
throw ClientAuthError.createClientInfoEmptyError();
|
|
4499
4794
|
}
|
|
4500
4795
|
return serverTokenResponse.client_info ?
|
|
4501
|
-
AccountEntity.createAccount(serverTokenResponse.client_info, this.homeAccountIdentifier,
|
|
4502
|
-
AccountEntity.createGenericAccount(
|
|
4796
|
+
AccountEntity.createAccount(serverTokenResponse.client_info, this.homeAccountIdentifier, idToken, authority, oboAssertion, cloudGraphHostName, msGraphhost) :
|
|
4797
|
+
AccountEntity.createGenericAccount(this.homeAccountIdentifier, idToken, authority, oboAssertion, cloudGraphHostName, msGraphhost);
|
|
4503
4798
|
};
|
|
4504
4799
|
/**
|
|
4505
4800
|
* Creates an @AuthenticationResult from @CacheRecord , @IdToken , and a boolean that states whether or not the result is from cache.
|
|
@@ -4554,6 +4849,7 @@ var ResponseHandler = /** @class */ (function () {
|
|
|
4554
4849
|
accessToken: accessToken,
|
|
4555
4850
|
fromCache: fromTokenCache,
|
|
4556
4851
|
expiresOn: expiresOn,
|
|
4852
|
+
correlationId: request.correlationId,
|
|
4557
4853
|
extExpiresOn: extExpiresOn,
|
|
4558
4854
|
familyId: familyId,
|
|
4559
4855
|
tokenType: ((_a = cacheRecord.accessToken) === null || _a === void 0 ? void 0 : _a.tokenType) || Constants.EMPTY_STRING,
|
|
@@ -4650,7 +4946,7 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
|
|
|
4650
4946
|
code: serverParams.code });
|
|
4651
4947
|
};
|
|
4652
4948
|
/**
|
|
4653
|
-
*
|
|
4949
|
+
* Used to log out the current user, and redirect the user to the postLogoutRedirectUri.
|
|
4654
4950
|
* Default behaviour is to redirect the user to `window.location.href`.
|
|
4655
4951
|
* @param authorityUri
|
|
4656
4952
|
*/
|
|
@@ -4659,14 +4955,6 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
|
|
|
4659
4955
|
if (!logoutRequest) {
|
|
4660
4956
|
throw ClientConfigurationError.createEmptyLogoutRequestError();
|
|
4661
4957
|
}
|
|
4662
|
-
if (logoutRequest.account) {
|
|
4663
|
-
// Clear given account.
|
|
4664
|
-
this.cacheManager.removeAccount(AccountEntity.generateAccountCacheKey(logoutRequest.account));
|
|
4665
|
-
}
|
|
4666
|
-
else {
|
|
4667
|
-
// Clear all accounts and tokens
|
|
4668
|
-
this.cacheManager.clear();
|
|
4669
|
-
}
|
|
4670
4958
|
var queryString = this.createLogoutUrlQueryString(logoutRequest);
|
|
4671
4959
|
// Construct logout URI.
|
|
4672
4960
|
return UrlString.appendQueryString(this.authority.endSessionEndpoint, queryString);
|
|
@@ -4685,7 +4973,13 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
|
|
|
4685
4973
|
thumbprint = {
|
|
4686
4974
|
clientId: this.config.authOptions.clientId,
|
|
4687
4975
|
authority: authority.canonicalAuthority,
|
|
4688
|
-
scopes: request.scopes
|
|
4976
|
+
scopes: request.scopes,
|
|
4977
|
+
authenticationScheme: request.authenticationScheme,
|
|
4978
|
+
resourceRequestMethod: request.resourceRequestMethod,
|
|
4979
|
+
resourceRequestUri: request.resourceRequestUri,
|
|
4980
|
+
shrClaims: request.shrClaims,
|
|
4981
|
+
sshJwk: request.sshJwk,
|
|
4982
|
+
sshKid: request.sshKid
|
|
4689
4983
|
};
|
|
4690
4984
|
return [4 /*yield*/, this.createTokenRequestBody(request)];
|
|
4691
4985
|
case 1:
|
|
@@ -4766,8 +5060,18 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
|
|
|
4766
5060
|
case 1:
|
|
4767
5061
|
cnfString = _a.sent();
|
|
4768
5062
|
parameterBuilder.addPopToken(cnfString);
|
|
4769
|
-
|
|
5063
|
+
return [3 /*break*/, 3];
|
|
4770
5064
|
case 2:
|
|
5065
|
+
if (request.authenticationScheme === exports.AuthenticationScheme.SSH) {
|
|
5066
|
+
if (request.sshJwk) {
|
|
5067
|
+
parameterBuilder.addSshJwk(request.sshJwk);
|
|
5068
|
+
}
|
|
5069
|
+
else {
|
|
5070
|
+
throw ClientConfigurationError.createMissingSshJwkError();
|
|
5071
|
+
}
|
|
5072
|
+
}
|
|
5073
|
+
_a.label = 3;
|
|
5074
|
+
case 3:
|
|
4771
5075
|
correlationId = request.correlationId || this.config.cryptoInterface.createNewGuid();
|
|
4772
5076
|
parameterBuilder.addCorrelationId(correlationId);
|
|
4773
5077
|
if (!StringUtils.isEmptyObj(request.claims) || this.config.authOptions.clientCapabilities && this.config.authOptions.clientCapabilities.length > 0) {
|
|
@@ -4921,6 +5225,12 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
|
|
|
4921
5225
|
if (request.idTokenHint) {
|
|
4922
5226
|
parameterBuilder.addIdTokenHint(request.idTokenHint);
|
|
4923
5227
|
}
|
|
5228
|
+
if (request.state) {
|
|
5229
|
+
parameterBuilder.addState(request.state);
|
|
5230
|
+
}
|
|
5231
|
+
if (request.extraQueryParameters) {
|
|
5232
|
+
parameterBuilder.addExtraQueryParameters(request.extraQueryParameters);
|
|
5233
|
+
}
|
|
4924
5234
|
return parameterBuilder.createQueryString();
|
|
4925
5235
|
};
|
|
4926
5236
|
/**
|
|
@@ -4989,7 +5299,13 @@ var DeviceCodeClient = /** @class */ (function (_super) {
|
|
|
4989
5299
|
thumbprint = {
|
|
4990
5300
|
clientId: this.config.authOptions.clientId,
|
|
4991
5301
|
authority: request.authority,
|
|
4992
|
-
scopes: request.scopes
|
|
5302
|
+
scopes: request.scopes,
|
|
5303
|
+
authenticationScheme: request.authenticationScheme,
|
|
5304
|
+
resourceRequestMethod: request.resourceRequestMethod,
|
|
5305
|
+
resourceRequestUri: request.resourceRequestUri,
|
|
5306
|
+
shrClaims: request.shrClaims,
|
|
5307
|
+
sshJwk: request.sshJwk,
|
|
5308
|
+
sshKid: request.sshKid
|
|
4993
5309
|
};
|
|
4994
5310
|
return [2 /*return*/, this.executePostRequestToDeviceCodeEndpoint(this.authority.deviceCodeEndpoint, queryString, headers, thumbprint)];
|
|
4995
5311
|
});
|
|
@@ -5082,7 +5398,13 @@ var DeviceCodeClient = /** @class */ (function (_super) {
|
|
|
5082
5398
|
thumbprint = {
|
|
5083
5399
|
clientId: this.config.authOptions.clientId,
|
|
5084
5400
|
authority: request.authority,
|
|
5085
|
-
scopes: request.scopes
|
|
5401
|
+
scopes: request.scopes,
|
|
5402
|
+
authenticationScheme: request.authenticationScheme,
|
|
5403
|
+
resourceRequestMethod: request.resourceRequestMethod,
|
|
5404
|
+
resourceRequestUri: request.resourceRequestUri,
|
|
5405
|
+
shrClaims: request.shrClaims,
|
|
5406
|
+
sshJwk: request.sshJwk,
|
|
5407
|
+
sshKid: request.sshKid
|
|
5086
5408
|
};
|
|
5087
5409
|
return [4 /*yield*/, this.executePostToTokenEndpoint(this.authority.tokenEndpoint, requestBody, headers, thumbprint)];
|
|
5088
5410
|
case 2:
|
|
@@ -5188,7 +5510,7 @@ var RefreshTokenClient = /** @class */ (function (_super) {
|
|
|
5188
5510
|
return [2 /*return*/, this.acquireTokenWithCachedRefreshToken(request, true)];
|
|
5189
5511
|
}
|
|
5190
5512
|
catch (e) {
|
|
5191
|
-
noFamilyRTInCache = e instanceof
|
|
5513
|
+
noFamilyRTInCache = e instanceof InteractionRequiredAuthError && e.errorCode === InteractionRequiredAuthErrorMessage.noTokensFoundError.code;
|
|
5192
5514
|
clientMismatchErrorWithFamilyRT = e instanceof ServerError && e.errorCode === Errors.INVALID_GRANT_ERROR && e.subError === Errors.CLIENT_MISMATCH_ERROR;
|
|
5193
5515
|
// if family Refresh Token (FRT) cache acquisition fails or if client_mismatch error is seen with FRT, reattempt with application Refresh Token (ART)
|
|
5194
5516
|
if (noFamilyRTInCache || clientMismatchErrorWithFamilyRT) {
|
|
@@ -5216,7 +5538,7 @@ var RefreshTokenClient = /** @class */ (function (_super) {
|
|
|
5216
5538
|
refreshToken = this.cacheManager.readRefreshTokenFromCache(this.config.authOptions.clientId, request.account, foci);
|
|
5217
5539
|
// no refresh Token
|
|
5218
5540
|
if (!refreshToken) {
|
|
5219
|
-
throw
|
|
5541
|
+
throw InteractionRequiredAuthError.createNoTokensFoundError();
|
|
5220
5542
|
}
|
|
5221
5543
|
refreshTokenRequest = __assign(__assign({}, request), { refreshToken: refreshToken.secret, authenticationScheme: request.authenticationScheme || exports.AuthenticationScheme.BEARER, ccsCredential: {
|
|
5222
5544
|
credential: request.account.homeAccountId,
|
|
@@ -5244,7 +5566,13 @@ var RefreshTokenClient = /** @class */ (function (_super) {
|
|
|
5244
5566
|
thumbprint = {
|
|
5245
5567
|
clientId: this.config.authOptions.clientId,
|
|
5246
5568
|
authority: authority.canonicalAuthority,
|
|
5247
|
-
scopes: request.scopes
|
|
5569
|
+
scopes: request.scopes,
|
|
5570
|
+
authenticationScheme: request.authenticationScheme,
|
|
5571
|
+
resourceRequestMethod: request.resourceRequestMethod,
|
|
5572
|
+
resourceRequestUri: request.resourceRequestUri,
|
|
5573
|
+
shrClaims: request.shrClaims,
|
|
5574
|
+
sshJwk: request.sshJwk,
|
|
5575
|
+
sshKid: request.sshKid
|
|
5248
5576
|
};
|
|
5249
5577
|
endpoint = UrlString.appendQueryString(authority.tokenEndpoint, queryParameters);
|
|
5250
5578
|
return [2 /*return*/, this.executePostToTokenEndpoint(endpoint, requestBody, headers, thumbprint)];
|
|
@@ -5269,9 +5597,9 @@ var RefreshTokenClient = /** @class */ (function (_super) {
|
|
|
5269
5597
|
*/
|
|
5270
5598
|
RefreshTokenClient.prototype.createTokenRequestBody = function (request) {
|
|
5271
5599
|
return __awaiter(this, void 0, void 0, function () {
|
|
5272
|
-
var parameterBuilder, correlationId, clientAssertion, popTokenGenerator,
|
|
5273
|
-
return __generator(this, function (
|
|
5274
|
-
switch (
|
|
5600
|
+
var parameterBuilder, correlationId, clientAssertion, popTokenGenerator, cnfString, clientInfo;
|
|
5601
|
+
return __generator(this, function (_a) {
|
|
5602
|
+
switch (_a.label) {
|
|
5275
5603
|
case 0:
|
|
5276
5604
|
parameterBuilder = new RequestParameterBuilder();
|
|
5277
5605
|
parameterBuilder.addClientId(this.config.authOptions.clientId);
|
|
@@ -5296,12 +5624,22 @@ var RefreshTokenClient = /** @class */ (function (_super) {
|
|
|
5296
5624
|
}
|
|
5297
5625
|
if (!(request.authenticationScheme === exports.AuthenticationScheme.POP)) return [3 /*break*/, 2];
|
|
5298
5626
|
popTokenGenerator = new PopTokenGenerator(this.cryptoUtils);
|
|
5299
|
-
_b = (_a = parameterBuilder).addPopToken;
|
|
5300
5627
|
return [4 /*yield*/, popTokenGenerator.generateCnf(request)];
|
|
5301
5628
|
case 1:
|
|
5302
|
-
|
|
5303
|
-
|
|
5629
|
+
cnfString = _a.sent();
|
|
5630
|
+
parameterBuilder.addPopToken(cnfString);
|
|
5631
|
+
return [3 /*break*/, 3];
|
|
5304
5632
|
case 2:
|
|
5633
|
+
if (request.authenticationScheme === exports.AuthenticationScheme.SSH) {
|
|
5634
|
+
if (request.sshJwk) {
|
|
5635
|
+
parameterBuilder.addSshJwk(request.sshJwk);
|
|
5636
|
+
}
|
|
5637
|
+
else {
|
|
5638
|
+
throw ClientConfigurationError.createMissingSshJwkError();
|
|
5639
|
+
}
|
|
5640
|
+
}
|
|
5641
|
+
_a.label = 3;
|
|
5642
|
+
case 3:
|
|
5305
5643
|
if (!StringUtils.isEmptyObj(request.claims) || this.config.authOptions.clientCapabilities && this.config.authOptions.clientCapabilities.length > 0) {
|
|
5306
5644
|
parameterBuilder.addClaims(request.claims, this.config.authOptions.clientCapabilities);
|
|
5307
5645
|
}
|
|
@@ -5436,7 +5774,13 @@ var ClientCredentialClient = /** @class */ (function (_super) {
|
|
|
5436
5774
|
thumbprint = {
|
|
5437
5775
|
clientId: this.config.authOptions.clientId,
|
|
5438
5776
|
authority: request.authority,
|
|
5439
|
-
scopes: request.scopes
|
|
5777
|
+
scopes: request.scopes,
|
|
5778
|
+
authenticationScheme: request.authenticationScheme,
|
|
5779
|
+
resourceRequestMethod: request.resourceRequestMethod,
|
|
5780
|
+
resourceRequestUri: request.resourceRequestUri,
|
|
5781
|
+
shrClaims: request.shrClaims,
|
|
5782
|
+
sshJwk: request.sshJwk,
|
|
5783
|
+
sshKid: request.sshKid
|
|
5440
5784
|
};
|
|
5441
5785
|
reqTimestamp = TimeUtils.nowSeconds();
|
|
5442
5786
|
return [4 /*yield*/, this.executePostToTokenEndpoint(authority.tokenEndpoint, requestBody, headers, thumbprint)];
|
|
@@ -5631,7 +5975,13 @@ var OnBehalfOfClient = /** @class */ (function (_super) {
|
|
|
5631
5975
|
thumbprint = {
|
|
5632
5976
|
clientId: this.config.authOptions.clientId,
|
|
5633
5977
|
authority: request.authority,
|
|
5634
|
-
scopes: request.scopes
|
|
5978
|
+
scopes: request.scopes,
|
|
5979
|
+
authenticationScheme: request.authenticationScheme,
|
|
5980
|
+
resourceRequestMethod: request.resourceRequestMethod,
|
|
5981
|
+
resourceRequestUri: request.resourceRequestUri,
|
|
5982
|
+
shrClaims: request.shrClaims,
|
|
5983
|
+
sshJwk: request.sshJwk,
|
|
5984
|
+
sshKid: request.sshKid
|
|
5635
5985
|
};
|
|
5636
5986
|
reqTimestamp = TimeUtils.nowSeconds();
|
|
5637
5987
|
return [4 /*yield*/, this.executePostToTokenEndpoint(authority.tokenEndpoint, requestBody, headers, thumbprint)];
|
|
@@ -5731,6 +6081,17 @@ var SilentFlowClient = /** @class */ (function (_super) {
|
|
|
5731
6081
|
if (!request) {
|
|
5732
6082
|
throw ClientConfigurationError.createEmptyTokenRequestError();
|
|
5733
6083
|
}
|
|
6084
|
+
if (request.forceRefresh) {
|
|
6085
|
+
// Must refresh due to present force_refresh flag.
|
|
6086
|
+
(_a = this.serverTelemetryManager) === null || _a === void 0 ? void 0 : _a.setCacheOutcome(CacheOutcome.FORCE_REFRESH);
|
|
6087
|
+
this.logger.info("SilentFlowClient:acquireCachedToken - Skipping cache because forceRefresh is true.");
|
|
6088
|
+
throw ClientAuthError.createRefreshRequiredError();
|
|
6089
|
+
}
|
|
6090
|
+
else if (!StringUtils.isEmptyObj(request.claims)) {
|
|
6091
|
+
// Must refresh due to request parameters.
|
|
6092
|
+
this.logger.info("SilentFlowClient:acquireCachedToken - Skipping cache because claims are requested.");
|
|
6093
|
+
throw ClientAuthError.createRefreshRequiredError();
|
|
6094
|
+
}
|
|
5734
6095
|
// We currently do not support silent flow for account === null use cases; This will be revisited for confidential flow usecases
|
|
5735
6096
|
if (!request.account) {
|
|
5736
6097
|
throw ClientAuthError.createNoAccountInSilentRequestError();
|
|
@@ -5738,30 +6099,24 @@ var SilentFlowClient = /** @class */ (function (_super) {
|
|
|
5738
6099
|
requestScopes = new ScopeSet(request.scopes || []);
|
|
5739
6100
|
environment = request.authority || this.authority.getPreferredCache();
|
|
5740
6101
|
authScheme = request.authenticationScheme || exports.AuthenticationScheme.BEARER;
|
|
5741
|
-
cacheRecord = this.cacheManager.readCacheRecord(request.account, this.config.authOptions.clientId, requestScopes, environment, authScheme);
|
|
5742
|
-
if (
|
|
5743
|
-
// Must refresh due to present force_refresh flag.
|
|
5744
|
-
(_a = this.serverTelemetryManager) === null || _a === void 0 ? void 0 : _a.setCacheOutcome(CacheOutcome.FORCE_REFRESH);
|
|
5745
|
-
throw ClientAuthError.createRefreshRequiredError();
|
|
5746
|
-
}
|
|
5747
|
-
else if (!cacheRecord.accessToken) {
|
|
6102
|
+
cacheRecord = this.cacheManager.readCacheRecord(request.account, this.config.authOptions.clientId, requestScopes, environment, authScheme, request.sshKid);
|
|
6103
|
+
if (!cacheRecord.accessToken) {
|
|
5748
6104
|
// Must refresh due to non-existent access_token.
|
|
5749
6105
|
(_b = this.serverTelemetryManager) === null || _b === void 0 ? void 0 : _b.setCacheOutcome(CacheOutcome.NO_CACHED_ACCESS_TOKEN);
|
|
6106
|
+
this.logger.info("SilentFlowClient:acquireCachedToken - No access token found in cache for the given properties.");
|
|
5750
6107
|
throw ClientAuthError.createRefreshRequiredError();
|
|
5751
6108
|
}
|
|
5752
6109
|
else if (TimeUtils.wasClockTurnedBack(cacheRecord.accessToken.cachedAt) ||
|
|
5753
6110
|
TimeUtils.isTokenExpired(cacheRecord.accessToken.expiresOn, this.config.systemOptions.tokenRenewalOffsetSeconds)) {
|
|
5754
6111
|
// Must refresh due to expired access_token.
|
|
5755
6112
|
(_c = this.serverTelemetryManager) === null || _c === void 0 ? void 0 : _c.setCacheOutcome(CacheOutcome.CACHED_ACCESS_TOKEN_EXPIRED);
|
|
6113
|
+
this.logger.info("SilentFlowClient:acquireCachedToken - Cached access token is expired or will expire within " + this.config.systemOptions.tokenRenewalOffsetSeconds + " seconds.");
|
|
5756
6114
|
throw ClientAuthError.createRefreshRequiredError();
|
|
5757
6115
|
}
|
|
5758
6116
|
else if (cacheRecord.accessToken.refreshOn && TimeUtils.isTokenExpired(cacheRecord.accessToken.refreshOn, 0)) {
|
|
5759
6117
|
// Must refresh due to the refresh_in value.
|
|
5760
6118
|
(_d = this.serverTelemetryManager) === null || _d === void 0 ? void 0 : _d.setCacheOutcome(CacheOutcome.REFRESH_CACHED_ACCESS_TOKEN);
|
|
5761
|
-
|
|
5762
|
-
}
|
|
5763
|
-
else if (!StringUtils.isEmptyObj(request.claims)) {
|
|
5764
|
-
// Must refresh due to request parameters.
|
|
6119
|
+
this.logger.info("SilentFlowClient:acquireCachedToken - Cached access token's refreshOn property has been exceeded'.");
|
|
5765
6120
|
throw ClientAuthError.createRefreshRequiredError();
|
|
5766
6121
|
}
|
|
5767
6122
|
if (this.config.serverTelemetryManager) {
|
|
@@ -5845,7 +6200,13 @@ var UsernamePasswordClient = /** @class */ (function (_super) {
|
|
|
5845
6200
|
thumbprint = {
|
|
5846
6201
|
clientId: this.config.authOptions.clientId,
|
|
5847
6202
|
authority: authority.canonicalAuthority,
|
|
5848
|
-
scopes: request.scopes
|
|
6203
|
+
scopes: request.scopes,
|
|
6204
|
+
authenticationScheme: request.authenticationScheme,
|
|
6205
|
+
resourceRequestMethod: request.resourceRequestMethod,
|
|
6206
|
+
resourceRequestUri: request.resourceRequestUri,
|
|
6207
|
+
shrClaims: request.shrClaims,
|
|
6208
|
+
sshJwk: request.sshJwk,
|
|
6209
|
+
sshKid: request.sshKid
|
|
5849
6210
|
};
|
|
5850
6211
|
requestBody = this.createTokenRequestBody(request);
|
|
5851
6212
|
headers = this.createTokenRequestHeaders({
|
|
@@ -5901,7 +6262,6 @@ var UsernamePasswordClient = /** @class */ (function (_super) {
|
|
|
5901
6262
|
function isOpenIdConfigResponse(response) {
|
|
5902
6263
|
return (response.hasOwnProperty("authorization_endpoint") &&
|
|
5903
6264
|
response.hasOwnProperty("token_endpoint") &&
|
|
5904
|
-
response.hasOwnProperty("end_session_endpoint") &&
|
|
5905
6265
|
response.hasOwnProperty("issuer"));
|
|
5906
6266
|
}
|
|
5907
6267
|
|
|
@@ -5909,6 +6269,10 @@ function isOpenIdConfigResponse(response) {
|
|
|
5909
6269
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
5910
6270
|
* Licensed under the MIT License.
|
|
5911
6271
|
*/
|
|
6272
|
+
/**
|
|
6273
|
+
* Protocol modes supported by MSAL.
|
|
6274
|
+
*/
|
|
6275
|
+
exports.ProtocolMode = void 0;
|
|
5912
6276
|
(function (ProtocolMode) {
|
|
5913
6277
|
ProtocolMode["AAD"] = "AAD";
|
|
5914
6278
|
ProtocolMode["OIDC"] = "OIDC";
|
|
@@ -5979,7 +6343,6 @@ var AuthorityMetadataEntity = /** @class */ (function () {
|
|
|
5979
6343
|
entity.hasOwnProperty("canonical_authority") &&
|
|
5980
6344
|
entity.hasOwnProperty("authorization_endpoint") &&
|
|
5981
6345
|
entity.hasOwnProperty("token_endpoint") &&
|
|
5982
|
-
entity.hasOwnProperty("end_session_endpoint") &&
|
|
5983
6346
|
entity.hasOwnProperty("issuer") &&
|
|
5984
6347
|
entity.hasOwnProperty("aliasesFromNetwork") &&
|
|
5985
6348
|
entity.hasOwnProperty("endpointsFromNetwork") &&
|
|
@@ -6012,7 +6375,7 @@ var RegionDiscovery = /** @class */ (function () {
|
|
|
6012
6375
|
*/
|
|
6013
6376
|
RegionDiscovery.prototype.detectRegion = function (environmentRegion, regionDiscoveryMetadata) {
|
|
6014
6377
|
return __awaiter(this, void 0, void 0, function () {
|
|
6015
|
-
var autodetectedRegionName, localIMDSVersionResponse, currentIMDSVersion, currentIMDSVersionResponse
|
|
6378
|
+
var autodetectedRegionName, localIMDSVersionResponse, currentIMDSVersion, currentIMDSVersionResponse;
|
|
6016
6379
|
return __generator(this, function (_a) {
|
|
6017
6380
|
switch (_a.label) {
|
|
6018
6381
|
case 0:
|
|
@@ -6046,7 +6409,7 @@ var RegionDiscovery = /** @class */ (function () {
|
|
|
6046
6409
|
_a.label = 5;
|
|
6047
6410
|
case 5: return [3 /*break*/, 7];
|
|
6048
6411
|
case 6:
|
|
6049
|
-
|
|
6412
|
+
_a.sent();
|
|
6050
6413
|
regionDiscoveryMetadata.region_source = RegionDiscoverySources.FAILED_AUTO_DETECTION;
|
|
6051
6414
|
return [2 /*return*/, null];
|
|
6052
6415
|
case 7: return [3 /*break*/, 9];
|
|
@@ -6083,7 +6446,7 @@ var RegionDiscovery = /** @class */ (function () {
|
|
|
6083
6446
|
*/
|
|
6084
6447
|
RegionDiscovery.prototype.getCurrentVersion = function () {
|
|
6085
6448
|
return __awaiter(this, void 0, void 0, function () {
|
|
6086
|
-
var response
|
|
6449
|
+
var response;
|
|
6087
6450
|
return __generator(this, function (_a) {
|
|
6088
6451
|
switch (_a.label) {
|
|
6089
6452
|
case 0:
|
|
@@ -6097,7 +6460,7 @@ var RegionDiscovery = /** @class */ (function () {
|
|
|
6097
6460
|
}
|
|
6098
6461
|
return [2 /*return*/, null];
|
|
6099
6462
|
case 2:
|
|
6100
|
-
|
|
6463
|
+
_a.sent();
|
|
6101
6464
|
return [2 /*return*/, null];
|
|
6102
6465
|
case 3: return [2 /*return*/];
|
|
6103
6466
|
}
|
|
@@ -6136,7 +6499,7 @@ var Authority = /** @class */ (function () {
|
|
|
6136
6499
|
}
|
|
6137
6500
|
return exports.AuthorityType.Default;
|
|
6138
6501
|
},
|
|
6139
|
-
enumerable:
|
|
6502
|
+
enumerable: false,
|
|
6140
6503
|
configurable: true
|
|
6141
6504
|
});
|
|
6142
6505
|
Object.defineProperty(Authority.prototype, "protocolMode", {
|
|
@@ -6146,7 +6509,7 @@ var Authority = /** @class */ (function () {
|
|
|
6146
6509
|
get: function () {
|
|
6147
6510
|
return this.authorityOptions.protocolMode;
|
|
6148
6511
|
},
|
|
6149
|
-
enumerable:
|
|
6512
|
+
enumerable: false,
|
|
6150
6513
|
configurable: true
|
|
6151
6514
|
});
|
|
6152
6515
|
Object.defineProperty(Authority.prototype, "options", {
|
|
@@ -6156,7 +6519,7 @@ var Authority = /** @class */ (function () {
|
|
|
6156
6519
|
get: function () {
|
|
6157
6520
|
return this.authorityOptions;
|
|
6158
6521
|
},
|
|
6159
|
-
enumerable:
|
|
6522
|
+
enumerable: false,
|
|
6160
6523
|
configurable: true
|
|
6161
6524
|
});
|
|
6162
6525
|
Object.defineProperty(Authority.prototype, "canonicalAuthority", {
|
|
@@ -6174,7 +6537,7 @@ var Authority = /** @class */ (function () {
|
|
|
6174
6537
|
this._canonicalAuthority.validateAsUri();
|
|
6175
6538
|
this._canonicalAuthorityUrlComponents = null;
|
|
6176
6539
|
},
|
|
6177
|
-
enumerable:
|
|
6540
|
+
enumerable: false,
|
|
6178
6541
|
configurable: true
|
|
6179
6542
|
});
|
|
6180
6543
|
Object.defineProperty(Authority.prototype, "canonicalAuthorityUrlComponents", {
|
|
@@ -6187,7 +6550,7 @@ var Authority = /** @class */ (function () {
|
|
|
6187
6550
|
}
|
|
6188
6551
|
return this._canonicalAuthorityUrlComponents;
|
|
6189
6552
|
},
|
|
6190
|
-
enumerable:
|
|
6553
|
+
enumerable: false,
|
|
6191
6554
|
configurable: true
|
|
6192
6555
|
});
|
|
6193
6556
|
Object.defineProperty(Authority.prototype, "hostnameAndPort", {
|
|
@@ -6197,7 +6560,7 @@ var Authority = /** @class */ (function () {
|
|
|
6197
6560
|
get: function () {
|
|
6198
6561
|
return this.canonicalAuthorityUrlComponents.HostNameAndPort.toLowerCase();
|
|
6199
6562
|
},
|
|
6200
|
-
enumerable:
|
|
6563
|
+
enumerable: false,
|
|
6201
6564
|
configurable: true
|
|
6202
6565
|
});
|
|
6203
6566
|
Object.defineProperty(Authority.prototype, "tenant", {
|
|
@@ -6207,7 +6570,7 @@ var Authority = /** @class */ (function () {
|
|
|
6207
6570
|
get: function () {
|
|
6208
6571
|
return this.canonicalAuthorityUrlComponents.PathSegments[0];
|
|
6209
6572
|
},
|
|
6210
|
-
enumerable:
|
|
6573
|
+
enumerable: false,
|
|
6211
6574
|
configurable: true
|
|
6212
6575
|
});
|
|
6213
6576
|
Object.defineProperty(Authority.prototype, "authorizationEndpoint", {
|
|
@@ -6223,7 +6586,7 @@ var Authority = /** @class */ (function () {
|
|
|
6223
6586
|
throw ClientAuthError.createEndpointDiscoveryIncompleteError("Discovery incomplete.");
|
|
6224
6587
|
}
|
|
6225
6588
|
},
|
|
6226
|
-
enumerable:
|
|
6589
|
+
enumerable: false,
|
|
6227
6590
|
configurable: true
|
|
6228
6591
|
});
|
|
6229
6592
|
Object.defineProperty(Authority.prototype, "tokenEndpoint", {
|
|
@@ -6239,7 +6602,7 @@ var Authority = /** @class */ (function () {
|
|
|
6239
6602
|
throw ClientAuthError.createEndpointDiscoveryIncompleteError("Discovery incomplete.");
|
|
6240
6603
|
}
|
|
6241
6604
|
},
|
|
6242
|
-
enumerable:
|
|
6605
|
+
enumerable: false,
|
|
6243
6606
|
configurable: true
|
|
6244
6607
|
});
|
|
6245
6608
|
Object.defineProperty(Authority.prototype, "deviceCodeEndpoint", {
|
|
@@ -6252,7 +6615,7 @@ var Authority = /** @class */ (function () {
|
|
|
6252
6615
|
throw ClientAuthError.createEndpointDiscoveryIncompleteError("Discovery incomplete.");
|
|
6253
6616
|
}
|
|
6254
6617
|
},
|
|
6255
|
-
enumerable:
|
|
6618
|
+
enumerable: false,
|
|
6256
6619
|
configurable: true
|
|
6257
6620
|
});
|
|
6258
6621
|
Object.defineProperty(Authority.prototype, "endSessionEndpoint", {
|
|
@@ -6261,6 +6624,10 @@ var Authority = /** @class */ (function () {
|
|
|
6261
6624
|
*/
|
|
6262
6625
|
get: function () {
|
|
6263
6626
|
if (this.discoveryComplete()) {
|
|
6627
|
+
// ROPC policies may not have end_session_endpoint set
|
|
6628
|
+
if (!this.metadata.end_session_endpoint) {
|
|
6629
|
+
throw ClientAuthError.createLogoutNotSupportedError();
|
|
6630
|
+
}
|
|
6264
6631
|
var endpoint = this.replacePath(this.metadata.end_session_endpoint);
|
|
6265
6632
|
return this.replaceTenant(endpoint);
|
|
6266
6633
|
}
|
|
@@ -6268,7 +6635,7 @@ var Authority = /** @class */ (function () {
|
|
|
6268
6635
|
throw ClientAuthError.createEndpointDiscoveryIncompleteError("Discovery incomplete.");
|
|
6269
6636
|
}
|
|
6270
6637
|
},
|
|
6271
|
-
enumerable:
|
|
6638
|
+
enumerable: false,
|
|
6272
6639
|
configurable: true
|
|
6273
6640
|
});
|
|
6274
6641
|
Object.defineProperty(Authority.prototype, "selfSignedJwtAudience", {
|
|
@@ -6284,7 +6651,7 @@ var Authority = /** @class */ (function () {
|
|
|
6284
6651
|
throw ClientAuthError.createEndpointDiscoveryIncompleteError("Discovery incomplete.");
|
|
6285
6652
|
}
|
|
6286
6653
|
},
|
|
6287
|
-
enumerable:
|
|
6654
|
+
enumerable: false,
|
|
6288
6655
|
configurable: true
|
|
6289
6656
|
});
|
|
6290
6657
|
/**
|
|
@@ -6321,7 +6688,7 @@ var Authority = /** @class */ (function () {
|
|
|
6321
6688
|
}
|
|
6322
6689
|
return this.canonicalAuthority + "v2.0/.well-known/openid-configuration";
|
|
6323
6690
|
},
|
|
6324
|
-
enumerable:
|
|
6691
|
+
enumerable: false,
|
|
6325
6692
|
configurable: true
|
|
6326
6693
|
});
|
|
6327
6694
|
/**
|
|
@@ -6453,7 +6820,7 @@ var Authority = /** @class */ (function () {
|
|
|
6453
6820
|
*/
|
|
6454
6821
|
Authority.prototype.getEndpointMetadataFromNetwork = function () {
|
|
6455
6822
|
return __awaiter(this, void 0, void 0, function () {
|
|
6456
|
-
var response
|
|
6823
|
+
var response;
|
|
6457
6824
|
return __generator(this, function (_a) {
|
|
6458
6825
|
switch (_a.label) {
|
|
6459
6826
|
case 0:
|
|
@@ -6463,7 +6830,7 @@ var Authority = /** @class */ (function () {
|
|
|
6463
6830
|
response = _a.sent();
|
|
6464
6831
|
return [2 /*return*/, isOpenIdConfigResponse(response.body) ? response.body : null];
|
|
6465
6832
|
case 2:
|
|
6466
|
-
|
|
6833
|
+
_a.sent();
|
|
6467
6834
|
return [2 /*return*/, null];
|
|
6468
6835
|
case 3: return [2 /*return*/];
|
|
6469
6836
|
}
|
|
@@ -6535,7 +6902,7 @@ var Authority = /** @class */ (function () {
|
|
|
6535
6902
|
*/
|
|
6536
6903
|
Authority.prototype.getCloudDiscoveryMetadataFromNetwork = function () {
|
|
6537
6904
|
return __awaiter(this, void 0, void 0, function () {
|
|
6538
|
-
var instanceDiscoveryEndpoint, match, response, metadata
|
|
6905
|
+
var instanceDiscoveryEndpoint, match, response, metadata;
|
|
6539
6906
|
return __generator(this, function (_a) {
|
|
6540
6907
|
switch (_a.label) {
|
|
6541
6908
|
case 0:
|
|
@@ -6555,7 +6922,7 @@ var Authority = /** @class */ (function () {
|
|
|
6555
6922
|
match = Authority.getCloudDiscoveryMetadataFromNetworkResponse(metadata, this.hostnameAndPort);
|
|
6556
6923
|
return [3 /*break*/, 4];
|
|
6557
6924
|
case 3:
|
|
6558
|
-
|
|
6925
|
+
_a.sent();
|
|
6559
6926
|
return [2 /*return*/, null];
|
|
6560
6927
|
case 4:
|
|
6561
6928
|
if (!match) {
|
|
@@ -6661,7 +7028,9 @@ var Authority = /** @class */ (function () {
|
|
|
6661
7028
|
metadata.authorization_endpoint = Authority.buildRegionalAuthorityString(metadata.authorization_endpoint, azureRegion);
|
|
6662
7029
|
// TODO: Enquire on whether we should leave the query string or remove it before releasing the feature
|
|
6663
7030
|
metadata.token_endpoint = Authority.buildRegionalAuthorityString(metadata.token_endpoint, azureRegion, "allowestsrnonmsi=true");
|
|
6664
|
-
|
|
7031
|
+
if (metadata.end_session_endpoint) {
|
|
7032
|
+
metadata.end_session_endpoint = Authority.buildRegionalAuthorityString(metadata.end_session_endpoint, azureRegion);
|
|
7033
|
+
}
|
|
6665
7034
|
return metadata;
|
|
6666
7035
|
};
|
|
6667
7036
|
return Authority;
|
|
@@ -6796,6 +7165,63 @@ var StubbedNetworkModule = {
|
|
|
6796
7165
|
}
|
|
6797
7166
|
};
|
|
6798
7167
|
|
|
7168
|
+
/*
|
|
7169
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
7170
|
+
* Licensed under the MIT License.
|
|
7171
|
+
*/
|
|
7172
|
+
/**
|
|
7173
|
+
* This is a helper class that parses supported HTTP response authentication headers to extract and return
|
|
7174
|
+
* header challenge values that can be used outside the basic authorization flows.
|
|
7175
|
+
*/
|
|
7176
|
+
var AuthenticationHeaderParser = /** @class */ (function () {
|
|
7177
|
+
function AuthenticationHeaderParser(headers) {
|
|
7178
|
+
this.headers = headers;
|
|
7179
|
+
}
|
|
7180
|
+
/**
|
|
7181
|
+
* This method parses the SHR nonce value out of either the Authentication-Info or WWW-Authenticate authentication headers.
|
|
7182
|
+
* @returns
|
|
7183
|
+
*/
|
|
7184
|
+
AuthenticationHeaderParser.prototype.getShrNonce = function () {
|
|
7185
|
+
// Attempt to parse nonce from Authentiacation-Info
|
|
7186
|
+
var authenticationInfo = this.headers[HeaderNames.AuthenticationInfo];
|
|
7187
|
+
if (authenticationInfo) {
|
|
7188
|
+
var authenticationInfoChallenges = this.parseChallenges(authenticationInfo);
|
|
7189
|
+
if (authenticationInfoChallenges.nextnonce) {
|
|
7190
|
+
return authenticationInfoChallenges.nextnonce;
|
|
7191
|
+
}
|
|
7192
|
+
throw ClientConfigurationError.createInvalidAuthenticationHeaderError(HeaderNames.AuthenticationInfo, "nextnonce challenge is missing.");
|
|
7193
|
+
}
|
|
7194
|
+
// Attempt to parse nonce from WWW-Authenticate
|
|
7195
|
+
var wwwAuthenticate = this.headers[HeaderNames.WWWAuthenticate];
|
|
7196
|
+
if (wwwAuthenticate) {
|
|
7197
|
+
var wwwAuthenticateChallenges = this.parseChallenges(wwwAuthenticate);
|
|
7198
|
+
if (wwwAuthenticateChallenges.nonce) {
|
|
7199
|
+
return wwwAuthenticateChallenges.nonce;
|
|
7200
|
+
}
|
|
7201
|
+
throw ClientConfigurationError.createInvalidAuthenticationHeaderError(HeaderNames.WWWAuthenticate, "nonce challenge is missing.");
|
|
7202
|
+
}
|
|
7203
|
+
// If neither header is present, throw missing headers error
|
|
7204
|
+
throw ClientConfigurationError.createMissingNonceAuthenticationHeadersError();
|
|
7205
|
+
};
|
|
7206
|
+
/**
|
|
7207
|
+
* Parses an HTTP header's challenge set into a key/value map.
|
|
7208
|
+
* @param header
|
|
7209
|
+
* @returns
|
|
7210
|
+
*/
|
|
7211
|
+
AuthenticationHeaderParser.prototype.parseChallenges = function (header) {
|
|
7212
|
+
var schemeSeparator = header.indexOf(" ");
|
|
7213
|
+
var challenges = header.substr(schemeSeparator + 1).split(",");
|
|
7214
|
+
var challengeMap = {};
|
|
7215
|
+
challenges.forEach(function (challenge) {
|
|
7216
|
+
var _a = challenge.split("="), key = _a[0], value = _a[1];
|
|
7217
|
+
// Remove escaped quotation marks (', ") from challenge string to keep only the challenge value
|
|
7218
|
+
challengeMap[key] = unescape(value.replace(/['"]+/g, ""));
|
|
7219
|
+
});
|
|
7220
|
+
return challengeMap;
|
|
7221
|
+
};
|
|
7222
|
+
return AuthenticationHeaderParser;
|
|
7223
|
+
}());
|
|
7224
|
+
|
|
6799
7225
|
/*
|
|
6800
7226
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
6801
7227
|
* Licensed under the MIT License.
|
|
@@ -6962,6 +7388,7 @@ exports.AppMetadataEntity = AppMetadataEntity;
|
|
|
6962
7388
|
exports.AuthError = AuthError;
|
|
6963
7389
|
exports.AuthErrorMessage = AuthErrorMessage;
|
|
6964
7390
|
exports.AuthToken = AuthToken;
|
|
7391
|
+
exports.AuthenticationHeaderParser = AuthenticationHeaderParser;
|
|
6965
7392
|
exports.Authority = Authority;
|
|
6966
7393
|
exports.AuthorityFactory = AuthorityFactory;
|
|
6967
7394
|
exports.AuthorityMetadataEntity = AuthorityMetadataEntity;
|
|
@@ -6981,14 +7408,17 @@ exports.DeviceCodeClient = DeviceCodeClient;
|
|
|
6981
7408
|
exports.IdToken = AuthToken;
|
|
6982
7409
|
exports.IdTokenEntity = IdTokenEntity;
|
|
6983
7410
|
exports.InteractionRequiredAuthError = InteractionRequiredAuthError;
|
|
7411
|
+
exports.InteractionRequiredAuthErrorMessage = InteractionRequiredAuthErrorMessage;
|
|
6984
7412
|
exports.Logger = Logger;
|
|
6985
7413
|
exports.NetworkManager = NetworkManager;
|
|
6986
7414
|
exports.OIDC_DEFAULT_SCOPES = OIDC_DEFAULT_SCOPES;
|
|
6987
7415
|
exports.OnBehalfOfClient = OnBehalfOfClient;
|
|
7416
|
+
exports.PopTokenGenerator = PopTokenGenerator;
|
|
6988
7417
|
exports.PromptValue = PromptValue;
|
|
6989
7418
|
exports.ProtocolUtils = ProtocolUtils;
|
|
6990
7419
|
exports.RefreshTokenClient = RefreshTokenClient;
|
|
6991
7420
|
exports.RefreshTokenEntity = RefreshTokenEntity;
|
|
7421
|
+
exports.ScopeSet = ScopeSet;
|
|
6992
7422
|
exports.ServerError = ServerError;
|
|
6993
7423
|
exports.ServerTelemetryEntity = ServerTelemetryEntity;
|
|
6994
7424
|
exports.ServerTelemetryManager = ServerTelemetryManager;
|
|
@@ -7001,4 +7431,5 @@ exports.TimeUtils = TimeUtils;
|
|
|
7001
7431
|
exports.TokenCacheContext = TokenCacheContext;
|
|
7002
7432
|
exports.UrlString = UrlString;
|
|
7003
7433
|
exports.UsernamePasswordClient = UsernamePasswordClient;
|
|
7434
|
+
exports.version = version;
|
|
7004
7435
|
//# sourceMappingURL=index.cjs.js.map
|