@azure/msal-common 6.3.0 → 6.4.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/dist/_virtual/_tslib.js +1 -1
- package/dist/account/AuthToken.js +1 -1
- package/dist/account/CcsCredential.js +1 -1
- package/dist/account/ClientInfo.js +1 -1
- package/dist/account/TokenClaims.d.ts +1 -1
- package/dist/account/TokenClaims.d.ts.map +1 -1
- package/dist/authority/Authority.js +1 -1
- package/dist/authority/AuthorityFactory.js +1 -1
- package/dist/authority/AuthorityOptions.js +1 -1
- package/dist/authority/AuthorityType.js +1 -1
- package/dist/authority/CloudInstanceDiscoveryResponse.js +1 -1
- package/dist/authority/OpenIdConfigResponse.js +1 -1
- package/dist/authority/ProtocolMode.js +1 -1
- package/dist/authority/RegionDiscovery.js +1 -1
- package/dist/cache/CacheManager.js +1 -1
- package/dist/cache/entities/AccessTokenEntity.js +1 -1
- package/dist/cache/entities/AccountEntity.js +1 -1
- package/dist/cache/entities/AppMetadataEntity.js +1 -1
- package/dist/cache/entities/AuthorityMetadataEntity.js +1 -1
- package/dist/cache/entities/CacheRecord.js +1 -1
- package/dist/cache/entities/CredentialEntity.js +1 -1
- package/dist/cache/entities/IdTokenEntity.js +1 -1
- package/dist/cache/entities/RefreshTokenEntity.js +1 -1
- package/dist/cache/entities/ServerTelemetryEntity.js +1 -1
- package/dist/cache/entities/ThrottlingEntity.js +1 -1
- package/dist/cache/persistence/TokenCacheContext.js +1 -1
- package/dist/client/AuthorizationCodeClient.d.ts.map +1 -1
- package/dist/client/AuthorizationCodeClient.js +14 -16
- package/dist/client/AuthorizationCodeClient.js.map +1 -1
- package/dist/client/BaseClient.js +1 -1
- package/dist/client/ClientCredentialClient.d.ts.map +1 -1
- package/dist/client/ClientCredentialClient.js +4 -3
- package/dist/client/ClientCredentialClient.js.map +1 -1
- package/dist/client/DeviceCodeClient.js +1 -1
- package/dist/client/OnBehalfOfClient.d.ts.map +1 -1
- package/dist/client/OnBehalfOfClient.js +4 -3
- package/dist/client/OnBehalfOfClient.js.map +1 -1
- package/dist/client/RefreshTokenClient.d.ts.map +1 -1
- package/dist/client/RefreshTokenClient.js +7 -6
- package/dist/client/RefreshTokenClient.js.map +1 -1
- package/dist/client/SilentFlowClient.js +1 -1
- package/dist/client/UsernamePasswordClient.d.ts.map +1 -1
- package/dist/client/UsernamePasswordClient.js +4 -3
- package/dist/client/UsernamePasswordClient.js.map +1 -1
- package/dist/config/ClientConfiguration.d.ts +5 -4
- package/dist/config/ClientConfiguration.d.ts.map +1 -1
- package/dist/config/ClientConfiguration.js +1 -1
- package/dist/config/ClientConfiguration.js.map +1 -1
- package/dist/crypto/ICrypto.js +1 -1
- package/dist/crypto/JoseHeader.d.ts +22 -0
- package/dist/crypto/JoseHeader.d.ts.map +1 -0
- package/dist/crypto/JoseHeader.js +45 -0
- package/dist/crypto/JoseHeader.js.map +1 -0
- package/dist/crypto/PopTokenGenerator.d.ts +9 -9
- package/dist/crypto/PopTokenGenerator.d.ts.map +1 -1
- package/dist/crypto/PopTokenGenerator.js +19 -31
- package/dist/crypto/PopTokenGenerator.js.map +1 -1
- package/dist/error/AuthError.js +1 -1
- package/dist/error/ClientAuthError.d.ts +8 -0
- package/dist/error/ClientAuthError.d.ts.map +1 -1
- package/dist/error/ClientAuthError.js +11 -1
- package/dist/error/ClientAuthError.js.map +1 -1
- package/dist/error/ClientConfigurationError.js +1 -1
- package/dist/error/InteractionRequiredAuthError.js +1 -1
- package/dist/error/JoseHeaderError.d.ts +29 -0
- package/dist/error/JoseHeaderError.d.ts.map +1 -0
- package/dist/error/JoseHeaderError.js +50 -0
- package/dist/error/JoseHeaderError.js.map +1 -0
- package/dist/error/ServerError.js +1 -1
- package/dist/index.cjs.js +159 -66
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/logger/Logger.js +1 -1
- package/dist/network/INetworkModule.js +1 -1
- package/dist/network/NetworkManager.js +1 -1
- package/dist/network/ThrottlingUtils.js +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.js +1 -1
- package/dist/request/BaseAuthRequest.d.ts +5 -3
- package/dist/request/BaseAuthRequest.d.ts.map +1 -1
- package/dist/request/RequestParameterBuilder.js +3 -3
- package/dist/request/RequestParameterBuilder.js.map +1 -1
- package/dist/request/RequestValidator.js +1 -1
- package/dist/request/ScopeSet.js +1 -1
- package/dist/response/ResponseHandler.d.ts.map +1 -1
- package/dist/response/ResponseHandler.js +12 -8
- package/dist/response/ResponseHandler.js.map +1 -1
- package/dist/telemetry/performance/PerformanceClient.js +1 -1
- package/dist/telemetry/performance/PerformanceEvent.js +1 -1
- package/dist/telemetry/performance/StubPerformanceClient.js +1 -1
- package/dist/telemetry/server/ServerTelemetryManager.js +1 -1
- package/dist/url/UrlString.js +1 -1
- package/dist/utils/Constants.d.ts +4 -0
- package/dist/utils/Constants.d.ts.map +1 -1
- package/dist/utils/Constants.js +8 -3
- package/dist/utils/Constants.js.map +1 -1
- package/dist/utils/ProtocolUtils.js +1 -1
- package/dist/utils/StringUtils.js +1 -1
- package/dist/utils/TimeUtils.js +1 -1
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @azure/msal-common v6.
|
|
1
|
+
/*! @azure/msal-common v6.4.0 2022-06-06 */
|
|
2
2
|
'use strict';
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
@@ -462,7 +462,12 @@ var CacheOutcome;
|
|
|
462
462
|
CacheOutcome["NO_CACHED_ACCESS_TOKEN"] = "2";
|
|
463
463
|
CacheOutcome["CACHED_ACCESS_TOKEN_EXPIRED"] = "3";
|
|
464
464
|
CacheOutcome["REFRESH_CACHED_ACCESS_TOKEN"] = "4";
|
|
465
|
-
})(CacheOutcome || (CacheOutcome = {}));
|
|
465
|
+
})(CacheOutcome || (CacheOutcome = {}));
|
|
466
|
+
var JsonTypes;
|
|
467
|
+
(function (JsonTypes) {
|
|
468
|
+
JsonTypes["Jwt"] = "JWT";
|
|
469
|
+
JsonTypes["Jwk"] = "JWK";
|
|
470
|
+
})(JsonTypes || (JsonTypes = {}));
|
|
466
471
|
|
|
467
472
|
/*
|
|
468
473
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -767,6 +772,10 @@ var ClientAuthErrorMessage = {
|
|
|
767
772
|
logoutNotSupported: {
|
|
768
773
|
code: "end_session_endpoint_not_supported",
|
|
769
774
|
desc: "Provided authority does not support logout."
|
|
775
|
+
},
|
|
776
|
+
keyIdMissing: {
|
|
777
|
+
code: "key_id_missing",
|
|
778
|
+
desc: "A keyId value is missing from the requested bound token's cache record and is required to match the token to it's stored binding key."
|
|
770
779
|
}
|
|
771
780
|
};
|
|
772
781
|
/**
|
|
@@ -1036,6 +1045,12 @@ var ClientAuthError = /** @class */ (function (_super) {
|
|
|
1036
1045
|
ClientAuthError.createLogoutNotSupportedError = function () {
|
|
1037
1046
|
return new ClientAuthError(ClientAuthErrorMessage.logoutNotSupported.code, ClientAuthErrorMessage.logoutNotSupported.desc);
|
|
1038
1047
|
};
|
|
1048
|
+
/**
|
|
1049
|
+
* Create an error when kid attribute is missing from a PoP token's cache record
|
|
1050
|
+
*/
|
|
1051
|
+
ClientAuthError.createKeyIdMissingError = function () {
|
|
1052
|
+
return new ClientAuthError(ClientAuthErrorMessage.keyIdMissing.code, ClientAuthErrorMessage.keyIdMissing.desc);
|
|
1053
|
+
};
|
|
1039
1054
|
return ClientAuthError;
|
|
1040
1055
|
}(AuthError));
|
|
1041
1056
|
|
|
@@ -1342,7 +1357,7 @@ var Logger = /** @class */ (function () {
|
|
|
1342
1357
|
|
|
1343
1358
|
/* eslint-disable header/header */
|
|
1344
1359
|
var name = "@azure/msal-common";
|
|
1345
|
-
var version = "6.
|
|
1360
|
+
var version = "6.4.0";
|
|
1346
1361
|
|
|
1347
1362
|
/*
|
|
1348
1363
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -3860,14 +3875,14 @@ var RequestParameterBuilder = /** @class */ (function () {
|
|
|
3860
3875
|
* @param username
|
|
3861
3876
|
*/
|
|
3862
3877
|
RequestParameterBuilder.prototype.addUsername = function (username) {
|
|
3863
|
-
this.parameters.set(PasswordGrantConstants.username, username);
|
|
3878
|
+
this.parameters.set(PasswordGrantConstants.username, encodeURIComponent(username));
|
|
3864
3879
|
};
|
|
3865
3880
|
/**
|
|
3866
3881
|
* adds `password` for Password Grant flow
|
|
3867
3882
|
* @param password
|
|
3868
3883
|
*/
|
|
3869
3884
|
RequestParameterBuilder.prototype.addPassword = function (password) {
|
|
3870
|
-
this.parameters.set(PasswordGrantConstants.password, password);
|
|
3885
|
+
this.parameters.set(PasswordGrantConstants.password, encodeURIComponent(password));
|
|
3871
3886
|
};
|
|
3872
3887
|
/**
|
|
3873
3888
|
* add pop_jwk to query params
|
|
@@ -4570,34 +4585,30 @@ var PopTokenGenerator = /** @class */ (function () {
|
|
|
4570
4585
|
}
|
|
4571
4586
|
/**
|
|
4572
4587
|
* Generates the req_cnf validated at the RP in the POP protocol for SHR parameters
|
|
4588
|
+
* and returns an object containing the keyid, the full req_cnf string and the req_cnf string hash
|
|
4573
4589
|
* @param request
|
|
4574
4590
|
* @returns
|
|
4575
4591
|
*/
|
|
4576
4592
|
PopTokenGenerator.prototype.generateCnf = function (request) {
|
|
4577
4593
|
return __awaiter(this, void 0, void 0, function () {
|
|
4578
|
-
var reqCnf;
|
|
4579
|
-
return __generator(this, function (
|
|
4580
|
-
switch (
|
|
4594
|
+
var reqCnf, reqCnfString, _a;
|
|
4595
|
+
return __generator(this, function (_b) {
|
|
4596
|
+
switch (_b.label) {
|
|
4581
4597
|
case 0: return [4 /*yield*/, this.generateKid(request)];
|
|
4582
4598
|
case 1:
|
|
4583
|
-
reqCnf =
|
|
4584
|
-
|
|
4599
|
+
reqCnf = _b.sent();
|
|
4600
|
+
reqCnfString = this.cryptoUtils.base64Encode(JSON.stringify(reqCnf));
|
|
4601
|
+
_a = {
|
|
4602
|
+
kid: reqCnf.kid,
|
|
4603
|
+
reqCnfString: reqCnfString
|
|
4604
|
+
};
|
|
4605
|
+
return [4 /*yield*/, this.cryptoUtils.hashString(reqCnfString)];
|
|
4606
|
+
case 2: return [2 /*return*/, (_a.reqCnfHash = _b.sent(),
|
|
4607
|
+
_a)];
|
|
4585
4608
|
}
|
|
4586
4609
|
});
|
|
4587
4610
|
});
|
|
4588
4611
|
};
|
|
4589
|
-
/**
|
|
4590
|
-
* Generates the hash of the req_cnf
|
|
4591
|
-
* @param cnf
|
|
4592
|
-
* @returns
|
|
4593
|
-
*/
|
|
4594
|
-
PopTokenGenerator.prototype.generateCnfHash = function (cnf) {
|
|
4595
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
4596
|
-
return __generator(this, function (_a) {
|
|
4597
|
-
return [2 /*return*/, this.cryptoUtils.hashString(cnf)];
|
|
4598
|
-
});
|
|
4599
|
-
});
|
|
4600
|
-
};
|
|
4601
4612
|
/**
|
|
4602
4613
|
* Generates key_id for a SHR token request
|
|
4603
4614
|
* @param request
|
|
@@ -4625,16 +4636,10 @@ var PopTokenGenerator = /** @class */ (function () {
|
|
|
4625
4636
|
* @param request
|
|
4626
4637
|
* @returns
|
|
4627
4638
|
*/
|
|
4628
|
-
PopTokenGenerator.prototype.signPopToken = function (accessToken, request) {
|
|
4629
|
-
var _a;
|
|
4639
|
+
PopTokenGenerator.prototype.signPopToken = function (accessToken, keyId, request) {
|
|
4630
4640
|
return __awaiter(this, void 0, void 0, function () {
|
|
4631
|
-
|
|
4632
|
-
|
|
4633
|
-
tokenClaims = AuthToken.extractTokenClaims(accessToken, this.cryptoUtils);
|
|
4634
|
-
if (!((_a = tokenClaims === null || tokenClaims === void 0 ? void 0 : tokenClaims.cnf) === null || _a === void 0 ? void 0 : _a.kid)) {
|
|
4635
|
-
throw ClientAuthError.createTokenClaimsRequiredError();
|
|
4636
|
-
}
|
|
4637
|
-
return [2 /*return*/, this.signPayload(accessToken, tokenClaims.cnf.kid, request)];
|
|
4641
|
+
return __generator(this, function (_a) {
|
|
4642
|
+
return [2 /*return*/, this.signPayload(accessToken, keyId, request)];
|
|
4638
4643
|
});
|
|
4639
4644
|
});
|
|
4640
4645
|
};
|
|
@@ -4646,7 +4651,7 @@ var PopTokenGenerator = /** @class */ (function () {
|
|
|
4646
4651
|
* @param claims
|
|
4647
4652
|
* @returns
|
|
4648
4653
|
*/
|
|
4649
|
-
PopTokenGenerator.prototype.signPayload = function (payload,
|
|
4654
|
+
PopTokenGenerator.prototype.signPayload = function (payload, keyId, request, claims) {
|
|
4650
4655
|
return __awaiter(this, void 0, void 0, function () {
|
|
4651
4656
|
var resourceRequestMethod, resourceRequestUri, shrClaims, shrNonce, resourceUrlString, resourceUrlComponents;
|
|
4652
4657
|
return __generator(this, function (_a) {
|
|
@@ -4655,7 +4660,7 @@ var PopTokenGenerator = /** @class */ (function () {
|
|
|
4655
4660
|
resourceRequestMethod = request.resourceRequestMethod, resourceRequestUri = request.resourceRequestUri, shrClaims = request.shrClaims, shrNonce = request.shrNonce;
|
|
4656
4661
|
resourceUrlString = (resourceRequestUri) ? new UrlString(resourceRequestUri) : undefined;
|
|
4657
4662
|
resourceUrlComponents = resourceUrlString === null || resourceUrlString === void 0 ? void 0 : resourceUrlString.getUrlComponents();
|
|
4658
|
-
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),
|
|
4663
|
+
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), keyId, request.correlationId)];
|
|
4659
4664
|
case 1: return [2 /*return*/, _a.sent()];
|
|
4660
4665
|
}
|
|
4661
4666
|
});
|
|
@@ -4974,9 +4979,9 @@ var ResponseHandler = /** @class */ (function () {
|
|
|
4974
4979
|
ResponseHandler.generateAuthenticationResult = function (cryptoObj, authority, cacheRecord, fromTokenCache, request, idTokenObj, requestState, code) {
|
|
4975
4980
|
var _a, _b, _c;
|
|
4976
4981
|
return __awaiter(this, void 0, void 0, function () {
|
|
4977
|
-
var accessToken, responseScopes, expiresOn, extExpiresOn, familyId, popTokenGenerator, uid, tid;
|
|
4978
|
-
return __generator(this, function (
|
|
4979
|
-
switch (
|
|
4982
|
+
var accessToken, responseScopes, expiresOn, extExpiresOn, familyId, popTokenGenerator, _d, secret, keyId, uid, tid;
|
|
4983
|
+
return __generator(this, function (_e) {
|
|
4984
|
+
switch (_e.label) {
|
|
4980
4985
|
case 0:
|
|
4981
4986
|
accessToken = Constants.EMPTY_STRING;
|
|
4982
4987
|
responseScopes = [];
|
|
@@ -4985,18 +4990,22 @@ var ResponseHandler = /** @class */ (function () {
|
|
|
4985
4990
|
if (!cacheRecord.accessToken) return [3 /*break*/, 4];
|
|
4986
4991
|
if (!(cacheRecord.accessToken.tokenType === exports.AuthenticationScheme.POP)) return [3 /*break*/, 2];
|
|
4987
4992
|
popTokenGenerator = new PopTokenGenerator(cryptoObj);
|
|
4988
|
-
|
|
4993
|
+
_d = cacheRecord.accessToken, secret = _d.secret, keyId = _d.keyId;
|
|
4994
|
+
if (!keyId) {
|
|
4995
|
+
throw ClientAuthError.createKeyIdMissingError();
|
|
4996
|
+
}
|
|
4997
|
+
return [4 /*yield*/, popTokenGenerator.signPopToken(secret, keyId, request)];
|
|
4989
4998
|
case 1:
|
|
4990
|
-
accessToken =
|
|
4999
|
+
accessToken = _e.sent();
|
|
4991
5000
|
return [3 /*break*/, 3];
|
|
4992
5001
|
case 2:
|
|
4993
5002
|
accessToken = cacheRecord.accessToken.secret;
|
|
4994
|
-
|
|
5003
|
+
_e.label = 3;
|
|
4995
5004
|
case 3:
|
|
4996
5005
|
responseScopes = ScopeSet.fromString(cacheRecord.accessToken.target).asArray();
|
|
4997
5006
|
expiresOn = new Date(Number(cacheRecord.accessToken.expiresOn) * 1000);
|
|
4998
5007
|
extExpiresOn = new Date(Number(cacheRecord.accessToken.extendedExpiresOn) * 1000);
|
|
4999
|
-
|
|
5008
|
+
_e.label = 4;
|
|
5000
5009
|
case 4:
|
|
5001
5010
|
if (cacheRecord.appMetadata) {
|
|
5002
5011
|
familyId = cacheRecord.appMetadata.familyId === THE_FAMILY_ID ? THE_FAMILY_ID : Constants.EMPTY_STRING;
|
|
@@ -5196,7 +5205,7 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
|
|
|
5196
5205
|
*/
|
|
5197
5206
|
AuthorizationCodeClient.prototype.createTokenRequestBody = function (request) {
|
|
5198
5207
|
return __awaiter(this, void 0, void 0, function () {
|
|
5199
|
-
var parameterBuilder, clientAssertion, popTokenGenerator,
|
|
5208
|
+
var parameterBuilder, clientAssertion, popTokenGenerator, reqCnfData, correlationId, ccsCred, clientInfo, clientInfo;
|
|
5200
5209
|
var _a;
|
|
5201
5210
|
return __generator(this, function (_b) {
|
|
5202
5211
|
switch (_b.label) {
|
|
@@ -5233,8 +5242,8 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
|
|
|
5233
5242
|
if (this.config.clientCredentials.clientSecret) {
|
|
5234
5243
|
parameterBuilder.addClientSecret(this.config.clientCredentials.clientSecret);
|
|
5235
5244
|
}
|
|
5236
|
-
|
|
5237
|
-
|
|
5245
|
+
clientAssertion = request.clientAssertion || this.config.clientCredentials.clientAssertion;
|
|
5246
|
+
if (clientAssertion) {
|
|
5238
5247
|
parameterBuilder.addClientAssertion(clientAssertion.assertion);
|
|
5239
5248
|
parameterBuilder.addClientAssertionType(clientAssertion.assertionType);
|
|
5240
5249
|
}
|
|
@@ -5244,8 +5253,9 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
|
|
|
5244
5253
|
popTokenGenerator = new PopTokenGenerator(this.cryptoUtils);
|
|
5245
5254
|
return [4 /*yield*/, popTokenGenerator.generateCnf(request)];
|
|
5246
5255
|
case 1:
|
|
5247
|
-
|
|
5248
|
-
|
|
5256
|
+
reqCnfData = _b.sent();
|
|
5257
|
+
// SPA PoP requires full Base64Url encoded req_cnf string (unhashed)
|
|
5258
|
+
parameterBuilder.addPopToken(reqCnfData.reqCnfString);
|
|
5249
5259
|
return [3 /*break*/, 3];
|
|
5250
5260
|
case 2:
|
|
5251
5261
|
if (request.authenticationScheme === exports.AuthenticationScheme.SSH) {
|
|
@@ -5316,7 +5326,7 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
|
|
|
5316
5326
|
*/
|
|
5317
5327
|
AuthorizationCodeClient.prototype.createAuthCodeUrlQueryString = function (request) {
|
|
5318
5328
|
return __awaiter(this, void 0, void 0, function () {
|
|
5319
|
-
var parameterBuilder, requestScopes, correlationId, accountSid, clientInfo, clientInfo, popTokenGenerator,
|
|
5329
|
+
var parameterBuilder, requestScopes, correlationId, accountSid, clientInfo, clientInfo, popTokenGenerator, reqCnfData;
|
|
5320
5330
|
return __generator(this, function (_a) {
|
|
5321
5331
|
switch (_a.label) {
|
|
5322
5332
|
case 0:
|
|
@@ -5408,20 +5418,17 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
|
|
|
5408
5418
|
if (request.extraQueryParameters) {
|
|
5409
5419
|
parameterBuilder.addExtraQueryParameters(request.extraQueryParameters);
|
|
5410
5420
|
}
|
|
5411
|
-
if (!request.nativeBroker) return [3 /*break*/,
|
|
5421
|
+
if (!request.nativeBroker) return [3 /*break*/, 2];
|
|
5412
5422
|
// signal ests that this is a WAM call
|
|
5413
5423
|
parameterBuilder.addNativeBroker();
|
|
5414
|
-
if (!(request.authenticationScheme === exports.AuthenticationScheme.POP)) return [3 /*break*/,
|
|
5424
|
+
if (!(request.authenticationScheme === exports.AuthenticationScheme.POP)) return [3 /*break*/, 2];
|
|
5415
5425
|
popTokenGenerator = new PopTokenGenerator(this.cryptoUtils);
|
|
5416
5426
|
return [4 /*yield*/, popTokenGenerator.generateCnf(request)];
|
|
5417
5427
|
case 1:
|
|
5418
|
-
|
|
5419
|
-
|
|
5420
|
-
|
|
5421
|
-
|
|
5422
|
-
parameterBuilder.addPopToken(cnfHash);
|
|
5423
|
-
_a.label = 3;
|
|
5424
|
-
case 3: return [2 /*return*/, parameterBuilder.createQueryString()];
|
|
5428
|
+
reqCnfData = _a.sent();
|
|
5429
|
+
parameterBuilder.addPopToken(reqCnfData.reqCnfHash);
|
|
5430
|
+
_a.label = 2;
|
|
5431
|
+
case 2: return [2 /*return*/, parameterBuilder.createQueryString()];
|
|
5425
5432
|
}
|
|
5426
5433
|
});
|
|
5427
5434
|
});
|
|
@@ -5818,7 +5825,7 @@ var RefreshTokenClient = /** @class */ (function (_super) {
|
|
|
5818
5825
|
*/
|
|
5819
5826
|
RefreshTokenClient.prototype.createTokenRequestBody = function (request) {
|
|
5820
5827
|
return __awaiter(this, void 0, void 0, function () {
|
|
5821
|
-
var parameterBuilder, correlationId, clientAssertion, popTokenGenerator,
|
|
5828
|
+
var parameterBuilder, correlationId, clientAssertion, popTokenGenerator, reqCnfData, clientInfo;
|
|
5822
5829
|
return __generator(this, function (_a) {
|
|
5823
5830
|
switch (_a.label) {
|
|
5824
5831
|
case 0:
|
|
@@ -5839,8 +5846,8 @@ var RefreshTokenClient = /** @class */ (function (_super) {
|
|
|
5839
5846
|
if (this.config.clientCredentials.clientSecret) {
|
|
5840
5847
|
parameterBuilder.addClientSecret(this.config.clientCredentials.clientSecret);
|
|
5841
5848
|
}
|
|
5842
|
-
|
|
5843
|
-
|
|
5849
|
+
clientAssertion = request.clientAssertion || this.config.clientCredentials.clientAssertion;
|
|
5850
|
+
if (clientAssertion) {
|
|
5844
5851
|
parameterBuilder.addClientAssertion(clientAssertion.assertion);
|
|
5845
5852
|
parameterBuilder.addClientAssertionType(clientAssertion.assertionType);
|
|
5846
5853
|
}
|
|
@@ -5848,8 +5855,9 @@ var RefreshTokenClient = /** @class */ (function (_super) {
|
|
|
5848
5855
|
popTokenGenerator = new PopTokenGenerator(this.cryptoUtils);
|
|
5849
5856
|
return [4 /*yield*/, popTokenGenerator.generateCnf(request)];
|
|
5850
5857
|
case 1:
|
|
5851
|
-
|
|
5852
|
-
|
|
5858
|
+
reqCnfData = _a.sent();
|
|
5859
|
+
// SPA PoP requires full Base64Url encoded req_cnf string (unhashed)
|
|
5860
|
+
parameterBuilder.addPopToken(reqCnfData.reqCnfString);
|
|
5853
5861
|
return [3 /*break*/, 3];
|
|
5854
5862
|
case 2:
|
|
5855
5863
|
if (request.authenticationScheme === exports.AuthenticationScheme.SSH) {
|
|
@@ -6038,8 +6046,9 @@ var ClientCredentialClient = /** @class */ (function (_super) {
|
|
|
6038
6046
|
if (this.config.clientCredentials.clientSecret) {
|
|
6039
6047
|
parameterBuilder.addClientSecret(this.config.clientCredentials.clientSecret);
|
|
6040
6048
|
}
|
|
6041
|
-
|
|
6042
|
-
|
|
6049
|
+
// Use clientAssertion from request, fallback to client assertion in base configuration
|
|
6050
|
+
var clientAssertion = request.clientAssertion || this.config.clientCredentials.clientAssertion;
|
|
6051
|
+
if (clientAssertion) {
|
|
6043
6052
|
parameterBuilder.addClientAssertion(clientAssertion.assertion);
|
|
6044
6053
|
parameterBuilder.addClientAssertionType(clientAssertion.assertionType);
|
|
6045
6054
|
}
|
|
@@ -6243,8 +6252,9 @@ var OnBehalfOfClient = /** @class */ (function (_super) {
|
|
|
6243
6252
|
if (this.config.clientCredentials.clientSecret) {
|
|
6244
6253
|
parameterBuilder.addClientSecret(this.config.clientCredentials.clientSecret);
|
|
6245
6254
|
}
|
|
6246
|
-
|
|
6247
|
-
|
|
6255
|
+
// Use clientAssertion from request, fallback to client assertion in base configuration
|
|
6256
|
+
var clientAssertion = request.clientAssertion || this.config.clientCredentials.clientAssertion;
|
|
6257
|
+
if (clientAssertion) {
|
|
6248
6258
|
parameterBuilder.addClientAssertion(clientAssertion.assertion);
|
|
6249
6259
|
parameterBuilder.addClientAssertionType(clientAssertion.assertionType);
|
|
6250
6260
|
}
|
|
@@ -6458,8 +6468,9 @@ var UsernamePasswordClient = /** @class */ (function (_super) {
|
|
|
6458
6468
|
if (this.config.clientCredentials.clientSecret) {
|
|
6459
6469
|
parameterBuilder.addClientSecret(this.config.clientCredentials.clientSecret);
|
|
6460
6470
|
}
|
|
6461
|
-
|
|
6462
|
-
|
|
6471
|
+
// Use clientAssertion from request, fallback to client assertion in base configuration
|
|
6472
|
+
var clientAssertion = request.clientAssertion || this.config.clientCredentials.clientAssertion;
|
|
6473
|
+
if (clientAssertion) {
|
|
6463
6474
|
parameterBuilder.addClientAssertion(clientAssertion.assertion);
|
|
6464
6475
|
parameterBuilder.addClientAssertionType(clientAssertion.assertionType);
|
|
6465
6476
|
}
|
|
@@ -7416,6 +7427,87 @@ var StubbedNetworkModule = {
|
|
|
7416
7427
|
}
|
|
7417
7428
|
};
|
|
7418
7429
|
|
|
7430
|
+
/*
|
|
7431
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
7432
|
+
* Licensed under the MIT License.
|
|
7433
|
+
*/
|
|
7434
|
+
/**
|
|
7435
|
+
* ClientAuthErrorMessage class containing string constants used by error codes and messages.
|
|
7436
|
+
*/
|
|
7437
|
+
var JoseHeaderErrorMessage = {
|
|
7438
|
+
missingKidError: {
|
|
7439
|
+
code: "missing_kid_error",
|
|
7440
|
+
desc: "The JOSE Header for the requested JWT, JWS or JWK object requires a keyId to be configured as the 'kid' header claim. No 'kid' value was provided."
|
|
7441
|
+
},
|
|
7442
|
+
missingAlgError: {
|
|
7443
|
+
code: "missing_alg_error",
|
|
7444
|
+
desc: "The JOSE Header for the requested JWT, JWS or JWK object requires an algorithm to be specified as the 'alg' header claim. No 'alg' value was provided."
|
|
7445
|
+
},
|
|
7446
|
+
};
|
|
7447
|
+
/**
|
|
7448
|
+
* Error thrown when there is an error in the client code running on the browser.
|
|
7449
|
+
*/
|
|
7450
|
+
var JoseHeaderError = /** @class */ (function (_super) {
|
|
7451
|
+
__extends(JoseHeaderError, _super);
|
|
7452
|
+
function JoseHeaderError(errorCode, errorMessage) {
|
|
7453
|
+
var _this = _super.call(this, errorCode, errorMessage) || this;
|
|
7454
|
+
_this.name = "JoseHeaderError";
|
|
7455
|
+
Object.setPrototypeOf(_this, JoseHeaderError.prototype);
|
|
7456
|
+
return _this;
|
|
7457
|
+
}
|
|
7458
|
+
/**
|
|
7459
|
+
* Creates an error thrown when keyId isn't set on JOSE header.
|
|
7460
|
+
*/
|
|
7461
|
+
JoseHeaderError.createMissingKidError = function () {
|
|
7462
|
+
return new JoseHeaderError(JoseHeaderErrorMessage.missingKidError.code, JoseHeaderErrorMessage.missingKidError.desc);
|
|
7463
|
+
};
|
|
7464
|
+
/**
|
|
7465
|
+
* Creates an error thrown when algorithm isn't set on JOSE header.
|
|
7466
|
+
*/
|
|
7467
|
+
JoseHeaderError.createMissingAlgError = function () {
|
|
7468
|
+
return new JoseHeaderError(JoseHeaderErrorMessage.missingAlgError.code, JoseHeaderErrorMessage.missingAlgError.desc);
|
|
7469
|
+
};
|
|
7470
|
+
return JoseHeaderError;
|
|
7471
|
+
}(AuthError));
|
|
7472
|
+
|
|
7473
|
+
/*
|
|
7474
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
7475
|
+
* Licensed under the MIT License.
|
|
7476
|
+
*/
|
|
7477
|
+
var JoseHeader = /** @class */ (function () {
|
|
7478
|
+
function JoseHeader(options) {
|
|
7479
|
+
this.typ = options.typ;
|
|
7480
|
+
this.alg = options.alg;
|
|
7481
|
+
this.kid = options.kid;
|
|
7482
|
+
}
|
|
7483
|
+
/**
|
|
7484
|
+
* Builds SignedHttpRequest formatted JOSE Header from the
|
|
7485
|
+
* JOSE Header options provided or previously set on the object and returns
|
|
7486
|
+
* the stringified header object.
|
|
7487
|
+
* Throws if keyId or algorithm aren't provided since they are required for Access Token Binding.
|
|
7488
|
+
* @param shrHeaderOptions
|
|
7489
|
+
* @returns
|
|
7490
|
+
*/
|
|
7491
|
+
JoseHeader.getShrHeaderString = function (shrHeaderOptions) {
|
|
7492
|
+
// KeyID is required on the SHR header
|
|
7493
|
+
if (!shrHeaderOptions.kid) {
|
|
7494
|
+
throw JoseHeaderError.createMissingKidError();
|
|
7495
|
+
}
|
|
7496
|
+
// Alg is required on the SHR header
|
|
7497
|
+
if (!shrHeaderOptions.alg) {
|
|
7498
|
+
throw JoseHeaderError.createMissingAlgError();
|
|
7499
|
+
}
|
|
7500
|
+
var shrHeader = new JoseHeader({
|
|
7501
|
+
// Access Token PoP headers must have type JWT, but the type header can be overriden for special cases
|
|
7502
|
+
typ: shrHeaderOptions.typ || JsonTypes.Jwt,
|
|
7503
|
+
kid: shrHeaderOptions.kid,
|
|
7504
|
+
alg: shrHeaderOptions.alg
|
|
7505
|
+
});
|
|
7506
|
+
return JSON.stringify(shrHeader);
|
|
7507
|
+
};
|
|
7508
|
+
return JoseHeader;
|
|
7509
|
+
}());
|
|
7510
|
+
|
|
7419
7511
|
/*
|
|
7420
7512
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
7421
7513
|
* Licensed under the MIT License.
|
|
@@ -8054,6 +8146,7 @@ exports.IdToken = AuthToken;
|
|
|
8054
8146
|
exports.IdTokenEntity = IdTokenEntity;
|
|
8055
8147
|
exports.InteractionRequiredAuthError = InteractionRequiredAuthError;
|
|
8056
8148
|
exports.InteractionRequiredAuthErrorMessage = InteractionRequiredAuthErrorMessage;
|
|
8149
|
+
exports.JoseHeader = JoseHeader;
|
|
8057
8150
|
exports.Logger = Logger;
|
|
8058
8151
|
exports.NetworkManager = NetworkManager;
|
|
8059
8152
|
exports.OIDC_DEFAULT_SCOPES = OIDC_DEFAULT_SCOPES;
|