@azure/identity 2.1.0 → 3.0.0-alpha.20220804.2

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.

Potentially problematic release.


This version of @azure/identity might be problematic. Click here for more details.

package/dist/index.js CHANGED
@@ -189,7 +189,7 @@ function getIdentityTokenEndpointSuffix(tenantId) {
189
189
  /**
190
190
  * Current version of the `@azure/identity` package.
191
191
  */
192
- const SDK_VERSION = `2.1.0`;
192
+ const SDK_VERSION = `3.0.0-beta.1`;
193
193
  /**
194
194
  * The default client ID for authentication
195
195
  * @internal
@@ -1918,9 +1918,26 @@ class MsalClientCertificate extends MsalNode {
1918
1918
  async init(options) {
1919
1919
  try {
1920
1920
  const parts = await parseCertificate(this.configuration, this.sendCertificateChain);
1921
+ let privateKey;
1922
+ if (this.configuration.certificatePassword !== undefined) {
1923
+ const privateKeyObject = crypto.createPrivateKey({
1924
+ key: parts.certificateContents,
1925
+ passphrase: this.configuration.certificatePassword,
1926
+ format: "pem",
1927
+ });
1928
+ privateKey = privateKeyObject
1929
+ .export({
1930
+ format: "pem",
1931
+ type: "pkcs8",
1932
+ })
1933
+ .toString();
1934
+ }
1935
+ else {
1936
+ privateKey = parts.certificateContents;
1937
+ }
1921
1938
  this.msalConfig.auth.clientCertificate = {
1922
1939
  thumbprint: parts.thumbprint,
1923
- privateKey: parts.certificateContents,
1940
+ privateKey: privateKey,
1924
1941
  x5c: parts.x5c,
1925
1942
  };
1926
1943
  }
@@ -2095,6 +2112,7 @@ const AllSupportedEnvironmentVariables = [
2095
2112
  "AZURE_CLIENT_ID",
2096
2113
  "AZURE_CLIENT_SECRET",
2097
2114
  "AZURE_CLIENT_CERTIFICATE_PATH",
2115
+ "AZURE_CLIENT_CERTIFICATE_PASSWORD",
2098
2116
  "AZURE_USERNAME",
2099
2117
  "AZURE_PASSWORD",
2100
2118
  ];
@@ -2115,6 +2133,7 @@ class EnvironmentCredential {
2115
2133
  * Environment variables used for client credential authentication:
2116
2134
  * - `AZURE_CLIENT_SECRET`: A client secret that was generated for the App Registration.
2117
2135
  * - `AZURE_CLIENT_CERTIFICATE_PATH`: The path to a PEM certificate to use during the authentication, instead of the client secret.
2136
+ * - `AZURE_CLIENT_CERTIFICATE_PASSWORD`: (optional) password for the certificate file.
2118
2137
  *
2119
2138
  * Alternatively, users can provide environment variables for username and password authentication:
2120
2139
  * - `AZURE_USERNAME`: Username to authenticate with.
@@ -2140,9 +2159,10 @@ class EnvironmentCredential {
2140
2159
  return;
2141
2160
  }
2142
2161
  const certificatePath = process.env.AZURE_CLIENT_CERTIFICATE_PATH;
2162
+ const certificatePassword = process.env.AZURE_CLIENT_CERTIFICATE_PASSWORD;
2143
2163
  if (tenantId && clientId && certificatePath) {
2144
2164
  logger$d.info(`Invoking ClientCertificateCredential with tenant ID: ${tenantId}, clientId: ${clientId} and certificatePath: ${certificatePath}`);
2145
- this._credential = new ClientCertificateCredential(tenantId, clientId, { certificatePath }, options);
2165
+ this._credential = new ClientCertificateCredential(tenantId, clientId, { certificatePath, certificatePassword }, options);
2146
2166
  return;
2147
2167
  }
2148
2168
  const username = process.env.AZURE_USERNAME;