@azure/identity 4.5.0-alpha.20241004.1 → 4.5.0-alpha.20241007.2

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.js CHANGED
@@ -44,7 +44,7 @@ var child_process__namespace = /*#__PURE__*/_interopNamespaceDefault(child_proce
44
44
  /**
45
45
  * Current version of the `@azure/identity` package.
46
46
  */
47
- const SDK_VERSION = `4.5.0-beta.3`;
47
+ const SDK_VERSION = `4.5.0`;
48
48
  /**
49
49
  * The default client ID for authentication
50
50
  * @internal
@@ -1182,7 +1182,8 @@ function handleMsalError(scopes, error, getTokenOptions) {
1182
1182
  }
1183
1183
  if (error.name === "ClientConfigurationError" ||
1184
1184
  error.name === "BrowserConfigurationAuthError" ||
1185
- error.name === "AbortError") {
1185
+ error.name === "AbortError" ||
1186
+ error.name === "AuthenticationError") {
1186
1187
  return error;
1187
1188
  }
1188
1189
  if (error.name === "NativeAuthError") {
@@ -3810,7 +3811,8 @@ class AzurePipelinesCredential {
3810
3811
  * @param systemAccessToken - The pipeline's <see href="https://learn.microsoft.com/azure/devops/pipelines/build/variables?view=azure-devops%26tabs=yaml#systemaccesstoken">System.AccessToken</see> value.
3811
3812
  * @param options - The identity client options to use for authentication.
3812
3813
  */
3813
- constructor(tenantId, clientId, serviceConnectionId, systemAccessToken, options) {
3814
+ constructor(tenantId, clientId, serviceConnectionId, systemAccessToken, options = {}) {
3815
+ var _a, _b;
3814
3816
  if (!clientId) {
3815
3817
  throw new CredentialUnavailableError(`${credentialName$1}: is unavailable. clientId is a required parameter.`);
3816
3818
  }
@@ -3823,6 +3825,12 @@ class AzurePipelinesCredential {
3823
3825
  if (!systemAccessToken) {
3824
3826
  throw new CredentialUnavailableError(`${credentialName$1}: is unavailable. systemAccessToken is a required parameter.`);
3825
3827
  }
3828
+ // Allow these headers to be logged for troubleshooting by AzurePipelines.
3829
+ options.loggingOptions = Object.assign(Object.assign({}, options === null || options === void 0 ? void 0 : options.loggingOptions), { additionalAllowedHeaderNames: [
3830
+ ...((_b = (_a = options.loggingOptions) === null || _a === void 0 ? void 0 : _a.additionalAllowedHeaderNames) !== null && _b !== void 0 ? _b : []),
3831
+ "x-vss-e2eid",
3832
+ "x-msedge-ref",
3833
+ ] });
3826
3834
  this.identityClient = new IdentityClient(options);
3827
3835
  checkTenantId(logger$2, tenantId);
3828
3836
  logger$2.info(`Invoking AzurePipelinesCredential with tenant ID: ${tenantId}, client ID: ${clientId}, and service connection ID: ${serviceConnectionId}`);
@@ -3871,6 +3879,8 @@ class AzurePipelinesCredential {
3871
3879
  headers: coreRestPipeline.createHttpHeaders({
3872
3880
  "Content-Type": "application/json",
3873
3881
  Authorization: `Bearer ${systemAccessToken}`,
3882
+ // Prevents the service from responding with a redirect HTTP status code (useful for automation).
3883
+ "X-TFS-FedAuthRedirect": "Suppress",
3874
3884
  }),
3875
3885
  });
3876
3886
  const response = await this.identityClient.sendRequest(request);
@@ -3878,6 +3888,7 @@ class AzurePipelinesCredential {
3878
3888
  }
3879
3889
  }
3880
3890
  function handleOidcResponse(response) {
3891
+ // OIDC token is present in `bodyAsText` field
3881
3892
  const text = response.bodyAsText;
3882
3893
  if (!text) {
3883
3894
  logger$2.error(`${credentialName$1}: Authentication Failed. Received null token from OIDC request. Response status- ${response.status}. Complete response - ${JSON.stringify(response)}`);
@@ -3895,7 +3906,7 @@ function handleOidcResponse(response) {
3895
3906
  const errorMessage = `${credentialName$1}: Authentication Failed. oidcToken field not detected in the response.`;
3896
3907
  let errorDescription = ``;
3897
3908
  if (response.status !== 200) {
3898
- errorDescription = `Complete response - ${JSON.stringify(result)}. See the troubleshooting guide for more information: https://aka.ms/azsdk/js/identity/azurepipelinescredential/troubleshoot`;
3909
+ errorDescription = `Response body = ${text}. Response Headers ["x-vss-e2eid"] = ${response.headers.get("x-vss-e2eid")} and ["x-msedge-ref"] = ${response.headers.get("x-msedge-ref")}. See the troubleshooting guide for more information: https://aka.ms/azsdk/js/identity/azurepipelinescredential/troubleshoot`;
3899
3910
  }
3900
3911
  logger$2.error(errorMessage);
3901
3912
  logger$2.error(errorDescription);
@@ -3907,11 +3918,12 @@ function handleOidcResponse(response) {
3907
3918
  }
3908
3919
  catch (e) {
3909
3920
  const errorDetails = `${credentialName$1}: Authentication Failed. oidcToken field not detected in the response.`;
3910
- logger$2.error(`Response from service = ${text} and error message = ${e.message}`);
3921
+ logger$2.error(`Response from service = ${text}, Response Headers ["x-vss-e2eid"] = ${response.headers.get("x-vss-e2eid")}
3922
+ and ["x-msedge-ref"] = ${response.headers.get("x-msedge-ref")}, error message = ${e.message}`);
3911
3923
  logger$2.error(errorDetails);
3912
3924
  throw new AuthenticationError(response.status, {
3913
3925
  error: errorDetails,
3914
- error_description: `Response = ${text}. See the troubleshooting guide for more information: https://aka.ms/azsdk/js/identity/azurepipelinescredential/troubleshoot`,
3926
+ error_description: `Response = ${text}. Response headers ["x-vss-e2eid"] = ${response.headers.get("x-vss-e2eid")} and ["x-msedge-ref"] = ${response.headers.get("x-msedge-ref")}. See the troubleshooting guide for more information: https://aka.ms/azsdk/js/identity/azurepipelinescredential/troubleshoot`,
3915
3927
  });
3916
3928
  }
3917
3929
  }