@azure/msal-common 5.1.0 → 5.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/CHANGELOG.json +31 -0
  2. package/CHANGELOG.md +13 -1
  3. package/dist/_virtual/_tslib.js +1 -1
  4. package/dist/account/AuthToken.js +1 -1
  5. package/dist/account/CcsCredential.js +1 -1
  6. package/dist/account/ClientInfo.js +1 -1
  7. package/dist/authority/Authority.js +1 -1
  8. package/dist/authority/AuthorityFactory.js +1 -1
  9. package/dist/authority/AuthorityType.js +1 -1
  10. package/dist/authority/CloudInstanceDiscoveryResponse.js +1 -1
  11. package/dist/authority/OpenIdConfigResponse.js +1 -1
  12. package/dist/authority/ProtocolMode.js +1 -1
  13. package/dist/authority/RegionDiscovery.js +1 -1
  14. package/dist/cache/CacheManager.js +1 -1
  15. package/dist/cache/entities/AccessTokenEntity.js +1 -1
  16. package/dist/cache/entities/AccountEntity.js +1 -1
  17. package/dist/cache/entities/AppMetadataEntity.js +1 -1
  18. package/dist/cache/entities/AuthorityMetadataEntity.js +1 -1
  19. package/dist/cache/entities/CacheRecord.js +1 -1
  20. package/dist/cache/entities/CredentialEntity.js +1 -1
  21. package/dist/cache/entities/IdTokenEntity.js +1 -1
  22. package/dist/cache/entities/RefreshTokenEntity.js +1 -1
  23. package/dist/cache/entities/ServerTelemetryEntity.js +1 -1
  24. package/dist/cache/entities/ThrottlingEntity.js +1 -1
  25. package/dist/cache/persistence/TokenCacheContext.js +1 -1
  26. package/dist/client/AuthorizationCodeClient.d.ts +1 -0
  27. package/dist/client/AuthorizationCodeClient.d.ts.map +1 -1
  28. package/dist/client/AuthorizationCodeClient.js +33 -9
  29. package/dist/client/AuthorizationCodeClient.js.map +1 -1
  30. package/dist/client/BaseClient.js +1 -1
  31. package/dist/client/ClientCredentialClient.js +1 -1
  32. package/dist/client/DeviceCodeClient.js +1 -1
  33. package/dist/client/OnBehalfOfClient.js +1 -1
  34. package/dist/client/RefreshTokenClient.js +1 -1
  35. package/dist/client/SilentFlowClient.js +1 -1
  36. package/dist/client/UsernamePasswordClient.js +1 -1
  37. package/dist/config/ClientConfiguration.js +1 -1
  38. package/dist/crypto/ICrypto.js +1 -1
  39. package/dist/crypto/PopTokenGenerator.js +1 -1
  40. package/dist/error/AuthError.js +1 -1
  41. package/dist/error/ClientAuthError.js +1 -1
  42. package/dist/error/ClientConfigurationError.js +1 -1
  43. package/dist/error/InteractionRequiredAuthError.js +1 -1
  44. package/dist/error/ServerError.js +1 -1
  45. package/dist/index.cjs.js +37 -12
  46. package/dist/index.cjs.js.map +1 -1
  47. package/dist/index.js +1 -1
  48. package/dist/logger/Logger.js +1 -1
  49. package/dist/network/INetworkModule.js +1 -1
  50. package/dist/network/NetworkManager.js +1 -1
  51. package/dist/network/ThrottlingUtils.js +1 -1
  52. package/dist/packageMetadata.d.ts +1 -1
  53. package/dist/packageMetadata.js +2 -2
  54. package/dist/packageMetadata.js.map +1 -1
  55. package/dist/request/AuthenticationHeaderParser.js +2 -2
  56. package/dist/request/AuthenticationHeaderParser.js.map +1 -1
  57. package/dist/request/CommonAuthorizationCodeRequest.d.ts +3 -0
  58. package/dist/request/CommonAuthorizationCodeRequest.d.ts.map +1 -1
  59. package/dist/request/RequestParameterBuilder.js +1 -1
  60. package/dist/request/RequestValidator.js +1 -1
  61. package/dist/request/ScopeSet.js +1 -1
  62. package/dist/response/AuthenticationResult.d.ts +1 -0
  63. package/dist/response/AuthenticationResult.d.ts.map +1 -1
  64. package/dist/response/ResponseHandler.d.ts +1 -1
  65. package/dist/response/ResponseHandler.d.ts.map +1 -1
  66. package/dist/response/ResponseHandler.js +5 -4
  67. package/dist/response/ResponseHandler.js.map +1 -1
  68. package/dist/response/ServerAuthorizationTokenResponse.d.ts +1 -0
  69. package/dist/response/ServerAuthorizationTokenResponse.d.ts.map +1 -1
  70. package/dist/telemetry/server/ServerTelemetryManager.js +1 -1
  71. package/dist/url/UrlString.js +1 -1
  72. package/dist/utils/Constants.d.ts +2 -1
  73. package/dist/utils/Constants.d.ts.map +1 -1
  74. package/dist/utils/Constants.js +2 -1
  75. package/dist/utils/Constants.js.map +1 -1
  76. package/dist/utils/ProtocolUtils.js +1 -1
  77. package/dist/utils/StringUtils.js +1 -1
  78. package/dist/utils/TimeUtils.js +1 -1
  79. package/package.json +1 -1
package/dist/index.cjs.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! @azure/msal-common v5.1.0 2021-11-02 */
1
+ /*! @azure/msal-common v5.2.0 2021-12-07 */
2
2
  'use strict';
3
3
  'use strict';
4
4
 
@@ -225,6 +225,7 @@ var AADServerParamKeys;
225
225
  AADServerParamKeys["ON_BEHALF_OF"] = "on_behalf_of";
226
226
  AADServerParamKeys["FOCI"] = "foci";
227
227
  AADServerParamKeys["CCS_HEADER"] = "X-AnchorMailbox";
228
+ AADServerParamKeys["RETURN_SPA_CODE"] = "return_spa_code";
228
229
  })(AADServerParamKeys || (AADServerParamKeys = {}));
229
230
  /**
230
231
  * Claims request keys
@@ -1325,7 +1326,7 @@ var Logger = /** @class */ (function () {
1325
1326
 
1326
1327
  /* eslint-disable header/header */
1327
1328
  var name = "@azure/msal-common";
1328
- var version = "5.1.0";
1329
+ var version = "5.2.0";
1329
1330
 
1330
1331
  /*
1331
1332
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4720,7 +4721,7 @@ var ResponseHandler = /** @class */ (function () {
4720
4721
  _a.sent();
4721
4722
  _a.label = 7;
4722
4723
  case 7: return [7 /*endfinally*/];
4723
- case 8: return [2 /*return*/, ResponseHandler.generateAuthenticationResult(this.cryptoObj, authority, cacheRecord, false, request, idTokenObj, requestStateObj)];
4724
+ case 8: return [2 /*return*/, ResponseHandler.generateAuthenticationResult(this.cryptoObj, authority, cacheRecord, false, request, idTokenObj, requestStateObj, serverTokenResponse.spa_code)];
4724
4725
  }
4725
4726
  });
4726
4727
  });
@@ -4806,7 +4807,7 @@ var ResponseHandler = /** @class */ (function () {
4806
4807
  * @param fromTokenCache
4807
4808
  * @param stateString
4808
4809
  */
4809
- ResponseHandler.generateAuthenticationResult = function (cryptoObj, authority, cacheRecord, fromTokenCache, request, idTokenObj, requestState) {
4810
+ ResponseHandler.generateAuthenticationResult = function (cryptoObj, authority, cacheRecord, fromTokenCache, request, idTokenObj, requestState, code) {
4810
4811
  var _a, _b, _c;
4811
4812
  return __awaiter(this, void 0, void 0, function () {
4812
4813
  var accessToken, responseScopes, expiresOn, extExpiresOn, familyId, popTokenGenerator, uid, tid;
@@ -4855,7 +4856,8 @@ var ResponseHandler = /** @class */ (function () {
4855
4856
  tokenType: ((_a = cacheRecord.accessToken) === null || _a === void 0 ? void 0 : _a.tokenType) || Constants.EMPTY_STRING,
4856
4857
  state: requestState ? requestState.userRequestState : Constants.EMPTY_STRING,
4857
4858
  cloudGraphHostName: ((_b = cacheRecord.account) === null || _b === void 0 ? void 0 : _b.cloudGraphHostName) || Constants.EMPTY_STRING,
4858
- msGraphHost: ((_c = cacheRecord.account) === null || _c === void 0 ? void 0 : _c.msGraphHost) || Constants.EMPTY_STRING
4859
+ msGraphHost: ((_c = cacheRecord.account) === null || _c === void 0 ? void 0 : _c.msGraphHost) || Constants.EMPTY_STRING,
4860
+ code: code
4859
4861
  }];
4860
4862
  }
4861
4863
  });
@@ -4874,7 +4876,10 @@ var ResponseHandler = /** @class */ (function () {
4874
4876
  var AuthorizationCodeClient = /** @class */ (function (_super) {
4875
4877
  __extends(AuthorizationCodeClient, _super);
4876
4878
  function AuthorizationCodeClient(configuration) {
4877
- return _super.call(this, configuration) || this;
4879
+ var _this = _super.call(this, configuration) || this;
4880
+ // Flag to indicate if client is for hybrid spa auth code redemption
4881
+ _this.includeRedirectUri = true;
4882
+ return _this;
4878
4883
  }
4879
4884
  /**
4880
4885
  * Creates the URL of the authorization request letting the user input credentials and consent to the
@@ -5023,13 +5028,24 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
5023
5028
  AuthorizationCodeClient.prototype.createTokenRequestBody = function (request) {
5024
5029
  return __awaiter(this, void 0, void 0, function () {
5025
5030
  var parameterBuilder, clientAssertion, popTokenGenerator, cnfString, correlationId, ccsCred, clientInfo, clientInfo;
5026
- return __generator(this, function (_a) {
5027
- switch (_a.label) {
5031
+ var _a;
5032
+ return __generator(this, function (_b) {
5033
+ switch (_b.label) {
5028
5034
  case 0:
5029
5035
  parameterBuilder = new RequestParameterBuilder();
5030
5036
  parameterBuilder.addClientId(this.config.authOptions.clientId);
5031
- // validate the redirectUri (to be a non null value)
5032
- parameterBuilder.addRedirectUri(request.redirectUri);
5037
+ /*
5038
+ * For hybrid spa flow, there will be a code but no verifier
5039
+ * In this scenario, don't include redirect uri as auth code will not be bound to redirect URI
5040
+ */
5041
+ if (!this.includeRedirectUri) {
5042
+ // Just validate
5043
+ RequestValidator.validateRedirectUri(request.redirectUri);
5044
+ }
5045
+ else {
5046
+ // Validate and include redirect uri
5047
+ parameterBuilder.addRedirectUri(request.redirectUri);
5048
+ }
5033
5049
  // Add scope array, parameter builder will add default scopes and dedupe
5034
5050
  parameterBuilder.addScopes(request.scopes);
5035
5051
  // add code: user set, not validated
@@ -5058,7 +5074,7 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
5058
5074
  popTokenGenerator = new PopTokenGenerator(this.cryptoUtils);
5059
5075
  return [4 /*yield*/, popTokenGenerator.generateCnf(request)];
5060
5076
  case 1:
5061
- cnfString = _a.sent();
5077
+ cnfString = _b.sent();
5062
5078
  parameterBuilder.addPopToken(cnfString);
5063
5079
  return [3 /*break*/, 3];
5064
5080
  case 2:
@@ -5070,7 +5086,7 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
5070
5086
  throw ClientConfigurationError.createMissingSshJwkError();
5071
5087
  }
5072
5088
  }
5073
- _a.label = 3;
5089
+ _b.label = 3;
5074
5090
  case 3:
5075
5091
  correlationId = request.correlationId || this.config.cryptoInterface.createNewGuid();
5076
5092
  parameterBuilder.addCorrelationId(correlationId);
@@ -5110,6 +5126,15 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
5110
5126
  break;
5111
5127
  }
5112
5128
  }
5129
+ if (request.tokenBodyParameters) {
5130
+ parameterBuilder.addExtraQueryParameters(request.tokenBodyParameters);
5131
+ }
5132
+ // Add hybrid spa parameters if not already provided
5133
+ if (request.enableSpaAuthorizationCode && (!request.tokenBodyParameters || !request.tokenBodyParameters[AADServerParamKeys.RETURN_SPA_CODE])) {
5134
+ parameterBuilder.addExtraQueryParameters((_a = {},
5135
+ _a[AADServerParamKeys.RETURN_SPA_CODE] = "1",
5136
+ _a));
5137
+ }
5113
5138
  return [2 /*return*/, parameterBuilder.createQueryString()];
5114
5139
  }
5115
5140
  });