@azure/identity 4.14.0-beta.4 → 4.14.0-beta.5

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 (76) hide show
  1. package/dist/browser/constants.d.ts +1 -1
  2. package/dist/browser/constants.js +1 -1
  3. package/dist/browser/constants.js.map +1 -1
  4. package/dist/browser/credentials/clientCertificateCredentialModels.d.ts.map +1 -1
  5. package/dist/browser/credentials/clientCertificateCredentialModels.js.map +1 -1
  6. package/dist/commonjs/constants.d.ts +1 -1
  7. package/dist/commonjs/constants.js +1 -1
  8. package/dist/commonjs/constants.js.map +1 -1
  9. package/dist/commonjs/credentials/azureCliCredential.d.ts.map +1 -1
  10. package/dist/commonjs/credentials/azureCliCredential.js +19 -36
  11. package/dist/commonjs/credentials/azureCliCredential.js.map +3 -3
  12. package/dist/commonjs/credentials/azureDeveloperCliCredential.d.ts.map +1 -1
  13. package/dist/commonjs/credentials/azureDeveloperCliCredential.js +16 -40
  14. package/dist/commonjs/credentials/azureDeveloperCliCredential.js.map +3 -3
  15. package/dist/commonjs/credentials/azurePowerShellCredential.d.ts +10 -0
  16. package/dist/commonjs/credentials/azurePowerShellCredential.d.ts.map +1 -1
  17. package/dist/commonjs/credentials/azurePowerShellCredential.js +36 -11
  18. package/dist/commonjs/credentials/azurePowerShellCredential.js.map +2 -2
  19. package/dist/commonjs/credentials/clientCertificateCredentialModels.d.ts.map +1 -1
  20. package/dist/commonjs/credentials/clientCertificateCredentialModels.js.map +1 -1
  21. package/dist/commonjs/credentials/environmentCredential.d.ts.map +1 -1
  22. package/dist/commonjs/credentials/environmentCredential.js.map +2 -2
  23. package/dist/commonjs/msal/nodeFlows/msalPlugins.d.ts.map +1 -1
  24. package/dist/commonjs/msal/nodeFlows/msalPlugins.js.map +2 -2
  25. package/dist/commonjs/tsdoc-metadata.json +1 -1
  26. package/dist/commonjs/util/processUtils.d.ts +14 -3
  27. package/dist/commonjs/util/processUtils.d.ts.map +1 -1
  28. package/dist/commonjs/util/processUtils.js +35 -28
  29. package/dist/commonjs/util/processUtils.js.map +3 -3
  30. package/dist/esm/constants.d.ts +1 -1
  31. package/dist/esm/constants.js +1 -1
  32. package/dist/esm/constants.js.map +1 -1
  33. package/dist/esm/credentials/azureCliCredential.d.ts.map +1 -1
  34. package/dist/esm/credentials/azureCliCredential.js +21 -24
  35. package/dist/esm/credentials/azureCliCredential.js.map +1 -1
  36. package/dist/esm/credentials/azureDeveloperCliCredential.d.ts.map +1 -1
  37. package/dist/esm/credentials/azureDeveloperCliCredential.js +16 -24
  38. package/dist/esm/credentials/azureDeveloperCliCredential.js.map +1 -1
  39. package/dist/esm/credentials/azurePowerShellCredential.d.ts +10 -0
  40. package/dist/esm/credentials/azurePowerShellCredential.d.ts.map +1 -1
  41. package/dist/esm/credentials/azurePowerShellCredential.js +26 -6
  42. package/dist/esm/credentials/azurePowerShellCredential.js.map +1 -1
  43. package/dist/esm/credentials/clientCertificateCredentialModels.d.ts.map +1 -1
  44. package/dist/esm/credentials/clientCertificateCredentialModels.js.map +1 -1
  45. package/dist/esm/credentials/environmentCredential.d.ts.map +1 -1
  46. package/dist/esm/credentials/environmentCredential.js.map +1 -1
  47. package/dist/esm/msal/nodeFlows/msalPlugins.d.ts.map +1 -1
  48. package/dist/esm/msal/nodeFlows/msalPlugins.js.map +1 -1
  49. package/dist/esm/util/processUtils.d.ts +14 -3
  50. package/dist/esm/util/processUtils.d.ts.map +1 -1
  51. package/dist/esm/util/processUtils.js +36 -19
  52. package/dist/esm/util/processUtils.js.map +1 -1
  53. package/dist/workerd/constants.d.ts +1 -1
  54. package/dist/workerd/constants.js +1 -1
  55. package/dist/workerd/constants.js.map +1 -1
  56. package/dist/workerd/credentials/azureCliCredential.d.ts.map +1 -1
  57. package/dist/workerd/credentials/azureCliCredential.js +21 -24
  58. package/dist/workerd/credentials/azureCliCredential.js.map +1 -1
  59. package/dist/workerd/credentials/azureDeveloperCliCredential.d.ts.map +1 -1
  60. package/dist/workerd/credentials/azureDeveloperCliCredential.js +16 -24
  61. package/dist/workerd/credentials/azureDeveloperCliCredential.js.map +1 -1
  62. package/dist/workerd/credentials/azurePowerShellCredential.d.ts +10 -0
  63. package/dist/workerd/credentials/azurePowerShellCredential.d.ts.map +1 -1
  64. package/dist/workerd/credentials/azurePowerShellCredential.js +26 -6
  65. package/dist/workerd/credentials/azurePowerShellCredential.js.map +1 -1
  66. package/dist/workerd/credentials/clientCertificateCredentialModels.d.ts.map +1 -1
  67. package/dist/workerd/credentials/clientCertificateCredentialModels.js.map +1 -1
  68. package/dist/workerd/credentials/environmentCredential.d.ts.map +1 -1
  69. package/dist/workerd/credentials/environmentCredential.js.map +1 -1
  70. package/dist/workerd/msal/nodeFlows/msalPlugins.d.ts.map +1 -1
  71. package/dist/workerd/msal/nodeFlows/msalPlugins.js.map +1 -1
  72. package/dist/workerd/util/processUtils.d.ts +14 -3
  73. package/dist/workerd/util/processUtils.d.ts.map +1 -1
  74. package/dist/workerd/util/processUtils.js +36 -19
  75. package/dist/workerd/util/processUtils.js.map +1 -1
  76. package/package.json +13 -12
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Current version of the `@azure/identity` package.
3
3
  */
4
- export declare const SDK_VERSION = "4.14.0-beta.4";
4
+ export declare const SDK_VERSION = "4.14.0-beta.5";
5
5
  /**
6
6
  * The default client ID for authentication
7
7
  * @internal
@@ -3,7 +3,7 @@
3
3
  /**
4
4
  * Current version of the `@azure/identity` package.
5
5
  */
6
- export const SDK_VERSION = `4.14.0-beta.4`;
6
+ export const SDK_VERSION = `4.14.0-beta.5`;
7
7
  /**
8
8
  * The default client ID for authentication
9
9
  * @internal
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,eAAe,CAAC;AAE3C;;;GAGG;AACH,2EAA2E;AAC3E,6CAA6C;AAC7C,uGAAuG;AACvG,MAAM,CAAC,MAAM,uBAAuB,GAAG,sCAAsC,CAAC;AAE9E;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,QAAQ,CAAC;AAExC;;GAEG;AACH,MAAM,CAAN,IAAY,mBAoBX;AApBD,WAAY,mBAAmB;IAC7B;;OAEG;IACH,oEAA6C,CAAA;IAC7C;;;;;SAKK;IACL,wEAAiD,CAAA;IACjD;;OAEG;IACH,2EAAoD,CAAA;IACpD;;OAEG;IACH,6EAAsD,CAAA;AACxD,CAAC,EApBW,mBAAmB,KAAnB,mBAAmB,QAoB9B;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,mBAAmB,CAAC,gBAAgB,CAAC;AAEzE;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,2BAA2B,CAAC;AAE5D;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAa,CAAC,GAAG,CAAC,CAAC;AAE3C;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,CAAC;AAEtC;;GAEG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,OAAO,CAAC;AAE5C;;;;;GAKG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,YAAY,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n/**\n * Current version of the `@azure/identity` package.\n */\nexport const SDK_VERSION = `4.14.0-beta.4`;\n\n/**\n * The default client ID for authentication\n * @internal\n */\n// TODO: temporary - this is the Azure CLI clientID - we'll replace it when\n// Developer Sign On application is available\n// https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/identity/Azure.Identity/src/Constants.cs#L9\nexport const DeveloperSignOnClientId = \"04b07795-8ddb-461a-bbee-02f9e1bf7b46\";\n\n/**\n * The default tenant for authentication\n * @internal\n */\nexport const DefaultTenantId = \"common\";\n\n/**\n * A list of known Azure authority hosts\n */\nexport enum AzureAuthorityHosts {\n /**\n * China-based Azure Authority Host\n */\n AzureChina = \"https://login.chinacloudapi.cn\",\n /**\n * Germany-based Azure Authority Host\n *\n * @deprecated Microsoft Cloud Germany was closed on October 29th, 2021.\n *\n * */\n AzureGermany = \"https://login.microsoftonline.de\",\n /**\n * US Government Azure Authority Host\n */\n AzureGovernment = \"https://login.microsoftonline.us\",\n /**\n * Public Cloud Azure Authority Host\n */\n AzurePublicCloud = \"https://login.microsoftonline.com\",\n}\n\n/**\n * @internal\n * The default authority host.\n */\nexport const DefaultAuthorityHost = AzureAuthorityHosts.AzurePublicCloud;\n\n/**\n * @internal\n * The default environment host for Azure Public Cloud\n */\nexport const DefaultAuthority = \"login.microsoftonline.com\";\n\n/**\n * @internal\n * Allow acquiring tokens for any tenant for multi-tentant auth.\n */\nexport const ALL_TENANTS: string[] = [\"*\"];\n\n/**\n * @internal\n */\nexport const CACHE_CAE_SUFFIX = \"cae\";\n\n/**\n * @internal\n */\nexport const CACHE_NON_CAE_SUFFIX = \"nocae\";\n\n/**\n * @internal\n *\n * The default name for the cache persistence plugin.\n * Matches the constant defined in the cache persistence package.\n */\nexport const DEFAULT_TOKEN_CACHE_NAME = \"msal.cache\";\n"]}
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,eAAe,CAAC;AAE3C;;;GAGG;AACH,2EAA2E;AAC3E,6CAA6C;AAC7C,uGAAuG;AACvG,MAAM,CAAC,MAAM,uBAAuB,GAAG,sCAAsC,CAAC;AAE9E;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,QAAQ,CAAC;AAExC;;GAEG;AACH,MAAM,CAAN,IAAY,mBAoBX;AApBD,WAAY,mBAAmB;IAC7B;;OAEG;IACH,oEAA6C,CAAA;IAC7C;;;;;SAKK;IACL,wEAAiD,CAAA;IACjD;;OAEG;IACH,2EAAoD,CAAA;IACpD;;OAEG;IACH,6EAAsD,CAAA;AACxD,CAAC,EApBW,mBAAmB,KAAnB,mBAAmB,QAoB9B;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,mBAAmB,CAAC,gBAAgB,CAAC;AAEzE;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,2BAA2B,CAAC;AAE5D;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAa,CAAC,GAAG,CAAC,CAAC;AAE3C;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,CAAC;AAEtC;;GAEG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,OAAO,CAAC;AAE5C;;;;;GAKG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,YAAY,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n/**\n * Current version of the `@azure/identity` package.\n */\nexport const SDK_VERSION = `4.14.0-beta.5`;\n\n/**\n * The default client ID for authentication\n * @internal\n */\n// TODO: temporary - this is the Azure CLI clientID - we'll replace it when\n// Developer Sign On application is available\n// https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/identity/Azure.Identity/src/Constants.cs#L9\nexport const DeveloperSignOnClientId = \"04b07795-8ddb-461a-bbee-02f9e1bf7b46\";\n\n/**\n * The default tenant for authentication\n * @internal\n */\nexport const DefaultTenantId = \"common\";\n\n/**\n * A list of known Azure authority hosts\n */\nexport enum AzureAuthorityHosts {\n /**\n * China-based Azure Authority Host\n */\n AzureChina = \"https://login.chinacloudapi.cn\",\n /**\n * Germany-based Azure Authority Host\n *\n * @deprecated Microsoft Cloud Germany was closed on October 29th, 2021.\n *\n * */\n AzureGermany = \"https://login.microsoftonline.de\",\n /**\n * US Government Azure Authority Host\n */\n AzureGovernment = \"https://login.microsoftonline.us\",\n /**\n * Public Cloud Azure Authority Host\n */\n AzurePublicCloud = \"https://login.microsoftonline.com\",\n}\n\n/**\n * @internal\n * The default authority host.\n */\nexport const DefaultAuthorityHost = AzureAuthorityHosts.AzurePublicCloud;\n\n/**\n * @internal\n * The default environment host for Azure Public Cloud\n */\nexport const DefaultAuthority = \"login.microsoftonline.com\";\n\n/**\n * @internal\n * Allow acquiring tokens for any tenant for multi-tentant auth.\n */\nexport const ALL_TENANTS: string[] = [\"*\"];\n\n/**\n * @internal\n */\nexport const CACHE_CAE_SUFFIX = \"cae\";\n\n/**\n * @internal\n */\nexport const CACHE_NON_CAE_SUFFIX = \"nocae\";\n\n/**\n * @internal\n *\n * The default name for the cache persistence plugin.\n * Matches the constant defined in the cache persistence package.\n */\nexport const DEFAULT_TOKEN_CACHE_NAME = \"msal.cache\";\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"clientCertificateCredentialModels.d.ts","sourceRoot":"","sources":["../../../src/credentials/clientCertificateCredentialModels.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,WAAW,+BAA+B;IAC9C;;;OAGG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AACD;;GAEG;AACH,MAAM,WAAW,mCAAmC;IAClD;;OAEG;IACH,eAAe,EAAE,MAAM,CAAC;IAExB;;OAEG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AACD;;GAEG;AACH,MAAM,MAAM,2CAA2C,GACnD,+BAA+B,GAC/B,mCAAmC,CAAC"}
1
+ {"version":3,"file":"clientCertificateCredentialModels.d.ts","sourceRoot":"","sources":["../../../src/credentials/clientCertificateCredentialModels.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,WAAW,+BAA+B;IAC9C;;;OAGG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AACD;;GAEG;AACH,MAAM,WAAW,mCAAmC;IAClD;;OAEG;IACH,eAAe,EAAE,MAAM,CAAC;IAExB;;OAEG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AACD;;GAEG;AACH,MAAM,MAAM,2CAA2C,GACrD,+BAA+B,GAAG,mCAAmC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"clientCertificateCredentialModels.js","sourceRoot":"","sources":["../../../src/credentials/clientCertificateCredentialModels.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n/**\n * Required configuration options for the {@link ClientCertificateCredential}, with the string contents of a PEM certificate\n */\nexport interface ClientCertificatePEMCertificate {\n /**\n * The PEM-encoded public/private key certificate on the filesystem.\n * Ensure that certificate is in PEM format and contains both the public and private keys.\n */\n certificate: string;\n\n /**\n * The password for the certificate file.\n */\n certificatePassword?: string;\n}\n/**\n * Required configuration options for the {@link ClientCertificateCredential}, with the path to a PEM certificate.\n */\nexport interface ClientCertificatePEMCertificatePath {\n /**\n * The path to the PEM-encoded public/private key certificate on the filesystem.\n */\n certificatePath: string;\n\n /**\n * The password for the certificate file.\n */\n certificatePassword?: string;\n}\n/**\n * Required configuration options for the {@link ClientCertificateCredential}, with either the string contents of a PEM certificate, or the path to a PEM certificate.\n */\nexport type ClientCertificateCredentialPEMConfiguration =\n | ClientCertificatePEMCertificate\n | ClientCertificatePEMCertificatePath;\n"]}
1
+ {"version":3,"file":"clientCertificateCredentialModels.js","sourceRoot":"","sources":["../../../src/credentials/clientCertificateCredentialModels.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n/**\n * Required configuration options for the {@link ClientCertificateCredential}, with the string contents of a PEM certificate\n */\nexport interface ClientCertificatePEMCertificate {\n /**\n * The PEM-encoded public/private key certificate on the filesystem.\n * Ensure that certificate is in PEM format and contains both the public and private keys.\n */\n certificate: string;\n\n /**\n * The password for the certificate file.\n */\n certificatePassword?: string;\n}\n/**\n * Required configuration options for the {@link ClientCertificateCredential}, with the path to a PEM certificate.\n */\nexport interface ClientCertificatePEMCertificatePath {\n /**\n * The path to the PEM-encoded public/private key certificate on the filesystem.\n */\n certificatePath: string;\n\n /**\n * The password for the certificate file.\n */\n certificatePassword?: string;\n}\n/**\n * Required configuration options for the {@link ClientCertificateCredential}, with either the string contents of a PEM certificate, or the path to a PEM certificate.\n */\nexport type ClientCertificateCredentialPEMConfiguration =\n ClientCertificatePEMCertificate | ClientCertificatePEMCertificatePath;\n"]}
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Current version of the `@azure/identity` package.
3
3
  */
4
- export declare const SDK_VERSION = "4.14.0-beta.4";
4
+ export declare const SDK_VERSION = "4.14.0-beta.5";
5
5
  /**
6
6
  * The default client ID for authentication
7
7
  * @internal
@@ -29,7 +29,7 @@ __export(constants_exports, {
29
29
  SDK_VERSION: () => SDK_VERSION
30
30
  });
31
31
  module.exports = __toCommonJS(constants_exports);
32
- const SDK_VERSION = `4.14.0-beta.4`;
32
+ const SDK_VERSION = `4.14.0-beta.5`;
33
33
  const DeveloperSignOnClientId = "04b07795-8ddb-461a-bbee-02f9e1bf7b46";
34
34
  const DefaultTenantId = "common";
35
35
  var AzureAuthorityHosts = /* @__PURE__ */ ((AzureAuthorityHosts2) => {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/constants.ts"],
4
- "sourcesContent": ["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n/**\n * Current version of the `@azure/identity` package.\n */\nexport const SDK_VERSION = `4.14.0-beta.4`;\n\n/**\n * The default client ID for authentication\n * @internal\n */\n// TODO: temporary - this is the Azure CLI clientID - we'll replace it when\n// Developer Sign On application is available\n// https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/identity/Azure.Identity/src/Constants.cs#L9\nexport const DeveloperSignOnClientId = \"04b07795-8ddb-461a-bbee-02f9e1bf7b46\";\n\n/**\n * The default tenant for authentication\n * @internal\n */\nexport const DefaultTenantId = \"common\";\n\n/**\n * A list of known Azure authority hosts\n */\nexport enum AzureAuthorityHosts {\n /**\n * China-based Azure Authority Host\n */\n AzureChina = \"https://login.chinacloudapi.cn\",\n /**\n * Germany-based Azure Authority Host\n *\n * @deprecated Microsoft Cloud Germany was closed on October 29th, 2021.\n *\n * */\n AzureGermany = \"https://login.microsoftonline.de\",\n /**\n * US Government Azure Authority Host\n */\n AzureGovernment = \"https://login.microsoftonline.us\",\n /**\n * Public Cloud Azure Authority Host\n */\n AzurePublicCloud = \"https://login.microsoftonline.com\",\n}\n\n/**\n * @internal\n * The default authority host.\n */\nexport const DefaultAuthorityHost = AzureAuthorityHosts.AzurePublicCloud;\n\n/**\n * @internal\n * The default environment host for Azure Public Cloud\n */\nexport const DefaultAuthority = \"login.microsoftonline.com\";\n\n/**\n * @internal\n * Allow acquiring tokens for any tenant for multi-tentant auth.\n */\nexport const ALL_TENANTS: string[] = [\"*\"];\n\n/**\n * @internal\n */\nexport const CACHE_CAE_SUFFIX = \"cae\";\n\n/**\n * @internal\n */\nexport const CACHE_NON_CAE_SUFFIX = \"nocae\";\n\n/**\n * @internal\n *\n * The default name for the cache persistence plugin.\n * Matches the constant defined in the cache persistence package.\n */\nexport const DEFAULT_TOKEN_CACHE_NAME = \"msal.cache\";\n"],
4
+ "sourcesContent": ["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n/**\n * Current version of the `@azure/identity` package.\n */\nexport const SDK_VERSION = `4.14.0-beta.5`;\n\n/**\n * The default client ID for authentication\n * @internal\n */\n// TODO: temporary - this is the Azure CLI clientID - we'll replace it when\n// Developer Sign On application is available\n// https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/identity/Azure.Identity/src/Constants.cs#L9\nexport const DeveloperSignOnClientId = \"04b07795-8ddb-461a-bbee-02f9e1bf7b46\";\n\n/**\n * The default tenant for authentication\n * @internal\n */\nexport const DefaultTenantId = \"common\";\n\n/**\n * A list of known Azure authority hosts\n */\nexport enum AzureAuthorityHosts {\n /**\n * China-based Azure Authority Host\n */\n AzureChina = \"https://login.chinacloudapi.cn\",\n /**\n * Germany-based Azure Authority Host\n *\n * @deprecated Microsoft Cloud Germany was closed on October 29th, 2021.\n *\n * */\n AzureGermany = \"https://login.microsoftonline.de\",\n /**\n * US Government Azure Authority Host\n */\n AzureGovernment = \"https://login.microsoftonline.us\",\n /**\n * Public Cloud Azure Authority Host\n */\n AzurePublicCloud = \"https://login.microsoftonline.com\",\n}\n\n/**\n * @internal\n * The default authority host.\n */\nexport const DefaultAuthorityHost = AzureAuthorityHosts.AzurePublicCloud;\n\n/**\n * @internal\n * The default environment host for Azure Public Cloud\n */\nexport const DefaultAuthority = \"login.microsoftonline.com\";\n\n/**\n * @internal\n * Allow acquiring tokens for any tenant for multi-tentant auth.\n */\nexport const ALL_TENANTS: string[] = [\"*\"];\n\n/**\n * @internal\n */\nexport const CACHE_CAE_SUFFIX = \"cae\";\n\n/**\n * @internal\n */\nexport const CACHE_NON_CAE_SUFFIX = \"nocae\";\n\n/**\n * @internal\n *\n * The default name for the cache persistence plugin.\n * Matches the constant defined in the cache persistence package.\n */\nexport const DEFAULT_TOKEN_CACHE_NAME = \"msal.cache\";\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMO,MAAM,cAAc;AASpB,MAAM,0BAA0B;AAMhC,MAAM,kBAAkB;AAKxB,IAAK,sBAAL,kBAAKA,yBAAL;AAIL,EAAAA,qBAAA,gBAAa;AAOb,EAAAA,qBAAA,kBAAe;AAIf,EAAAA,qBAAA,qBAAkB;AAIlB,EAAAA,qBAAA,sBAAmB;AAnBT,SAAAA;AAAA,GAAA;AA0BL,MAAM,uBAAuB;AAM7B,MAAM,mBAAmB;AAMzB,MAAM,cAAwB,CAAC,GAAG;AAKlC,MAAM,mBAAmB;AAKzB,MAAM,uBAAuB;AAQ7B,MAAM,2BAA2B;",
6
6
  "names": ["AzureAuthorityHosts"]
7
7
  }
@@ -1 +1 @@
1
- {"version":3,"file":"azureCliCredential.d.ts","sourceRoot":"","sources":["../../../src/credentials/azureCliCredential.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAStF,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAShF;;;GAGG;AACH,eAAO,MAAM,2BAA2B;;;;;;CAUvC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,sBAAsB;IACjC;;OAEG;yBACkB,MAAM;IAgB3B;;;;OAIG;qCAES,MAAM,aACL,MAAM,iBACF,MAAM,YACX,MAAM,GACf,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAA;KAAE,CAAC;CAmCpE,CAAC;AAEF;;;;;GAKG;AACH,qBAAa,kBAAmB,YAAW,eAAe;IACxD,OAAO,CAAC,QAAQ,CAAC,CAAS;IAC1B,OAAO,CAAC,4BAA4B,CAAW;IAC/C,OAAO,CAAC,OAAO,CAAC,CAAS;IACzB,OAAO,CAAC,YAAY,CAAC,CAAS;IAE9B;;;;;;;OAOG;gBACS,OAAO,CAAC,EAAE,yBAAyB;IAe/C;;;;;;;OAOG;IACU,QAAQ,CACnB,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,EACzB,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,WAAW,CAAC;IAiFvB;;;;;;;;;OASG;IACH,OAAO,CAAC,gBAAgB;CA+BzB"}
1
+ {"version":3,"file":"azureCliCredential.d.ts","sourceRoot":"","sources":["../../../src/credentials/azureCliCredential.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAStF,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAUhF;;;GAGG;AACH,eAAO,MAAM,2BAA2B;;;;;;CAUvC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,sBAAsB;IACjC;;OAEG;yBACkB,MAAM;IAgB3B;;;;OAIG;qCAES,MAAM,aACL,MAAM,iBACF,MAAM,YACX,MAAM,GACf,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAA;KAAE,CAAC;CA0BpE,CAAC;AAEF;;;;;GAKG;AACH,qBAAa,kBAAmB,YAAW,eAAe;IACxD,OAAO,CAAC,QAAQ,CAAC,CAAS;IAC1B,OAAO,CAAC,4BAA4B,CAAW;IAC/C,OAAO,CAAC,OAAO,CAAC,CAAS;IACzB,OAAO,CAAC,YAAY,CAAC,CAAS;IAE9B;;;;;;;OAOG;gBACS,OAAO,CAAC,EAAE,yBAAyB;IAe/C;;;;;;;OAOG;IACU,QAAQ,CACnB,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,EACzB,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,WAAW,CAAC;IAmFvB;;;;;;;;;OASG;IACH,OAAO,CAAC,gBAAgB;CA+BzB"}
@@ -1,8 +1,6 @@
1
- var __create = Object.create;
2
1
  var __defProp = Object.defineProperty;
3
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
5
  var __export = (target, all) => {
8
6
  for (var name in all)
@@ -16,14 +14,6 @@ var __copyProps = (to, from, except, desc) => {
16
14
  }
17
15
  return to;
18
16
  };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
18
  var azureCliCredential_exports = {};
29
19
  __export(azureCliCredential_exports, {
@@ -36,10 +26,11 @@ var import_tenantIdUtils = require("../util/tenantIdUtils.js");
36
26
  var import_logging = require("../util/logging.js");
37
27
  var import_scopeUtils = require("../util/scopeUtils.js");
38
28
  var import_errors = require("../errors.js");
39
- var import_child_process = __toESM(require("child_process"));
40
29
  var import_core_util = require("@azure/core-util");
41
30
  var import_tracing = require("../util/tracing.js");
42
31
  var import_subscriptionUtils = require("../util/subscriptionUtils.js");
32
+ var import_processUtils = require("../util/processUtils.js");
33
+ var import_core_process = require("@azure/core-process");
43
34
  const logger = (0, import_logging.credentialLogger)("AzureCliCredential");
44
35
  const azureCliPublicErrorMessages = {
45
36
  claim: "This credential doesn't support claims challenges. To authenticate with the required claims, please run the following command:",
@@ -78,31 +69,23 @@ const cliCredentialInternals = {
78
69
  tenantSection = ["--tenant", tenantId];
79
70
  }
80
71
  if (subscription) {
81
- subscriptionSection = ["--subscription", `"${subscription}"`];
72
+ subscriptionSection = ["--subscription", subscription];
82
73
  }
83
- return new Promise((resolve, reject) => {
84
- try {
85
- const args = [
86
- "account",
87
- "get-access-token",
88
- "--output",
89
- "json",
90
- "--resource",
91
- resource,
92
- ...tenantSection,
93
- ...subscriptionSection
94
- ];
95
- const command = ["az", ...args].join(" ");
96
- import_child_process.default.exec(
97
- command,
98
- { cwd: cliCredentialInternals.getSafeWorkingDir(), timeout },
99
- (error, stdout, stderr) => {
100
- resolve({ stdout, stderr, error });
101
- }
102
- );
103
- } catch (err) {
104
- reject(err);
105
- }
74
+ const args = [
75
+ "account",
76
+ "get-access-token",
77
+ "--output",
78
+ "json",
79
+ "--resource",
80
+ resource,
81
+ ...tenantSection,
82
+ ...subscriptionSection
83
+ ];
84
+ return import_processUtils.processUtils.execFileWithResult("az", args, {
85
+ allowWindowsBatchFiles: true,
86
+ cwd: cliCredentialInternals.getSafeWorkingDir(),
87
+ encoding: "utf8",
88
+ timeout
106
89
  });
107
90
  }
108
91
  };
@@ -181,7 +164,7 @@ class AzureCliCredential {
181
164
  );
182
165
  const specificScope = obj.stderr?.match("(.*)az login --scope(.*)");
183
166
  const isLoginError = obj.stderr?.match("(.*)az login(.*)") && !specificScope;
184
- const isNotInstallError = obj.stderr?.match("az:(.*)not found") || obj.stderr?.startsWith("'az' is not recognized");
167
+ const isNotInstallError = obj.stderr?.match("az:(.*)not found") || obj.stderr?.startsWith("'az' is not recognized") || obj.error && (0, import_core_process.isProcessError)(obj.error) && obj.error.code === "ENOENT";
185
168
  if (isNotInstallError) {
186
169
  const error = new import_errors.CredentialUnavailableError(azureCliPublicErrorMessages.notInstalled);
187
170
  logger.getToken.info((0, import_logging.formatError)(scopes, error));
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/credentials/azureCliCredential.ts"],
4
- "sourcesContent": ["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { AccessToken, GetTokenOptions, TokenCredential } from \"@azure/core-auth\";\nimport {\n checkTenantId,\n processMultiTenantRequest,\n resolveAdditionallyAllowedTenantIds,\n} from \"../util/tenantIdUtils.js\";\nimport { credentialLogger, formatError, formatSuccess } from \"../util/logging.js\";\nimport { ensureValidScopeForDevTimeCreds, getScopeResource } from \"../util/scopeUtils.js\";\n\nimport type { AzureCliCredentialOptions } from \"./azureCliCredentialOptions.js\";\nimport { CredentialUnavailableError } from \"../errors.js\";\nimport child_process from \"child_process\";\nimport { uint8ArrayToString, stringToUint8Array } from \"@azure/core-util\";\nimport { tracingClient } from \"../util/tracing.js\";\nimport { checkSubscription } from \"../util/subscriptionUtils.js\";\n\nconst logger = credentialLogger(\"AzureCliCredential\");\n\n/**\n * Messages to use when throwing in this credential.\n * @internal\n */\nexport const azureCliPublicErrorMessages = {\n claim:\n \"This credential doesn't support claims challenges. To authenticate with the required claims, please run the following command:\",\n notInstalled:\n \"Azure CLI could not be found. Please visit https://aka.ms/azure-cli for installation instructions and then, once installed, authenticate to your Azure account using 'az login'.\",\n login:\n \"Please run 'az login' from a command prompt to authenticate before using this credential.\",\n unknown: \"Unknown error while trying to retrieve the access token\",\n unexpectedResponse:\n 'Unexpected response from Azure CLI when getting token. Expected \"expiresOn\" to be a RFC3339 date string. Got:',\n};\n\n/**\n * Mockable reference to the CLI credential cliCredentialFunctions\n * @internal\n */\nexport const cliCredentialInternals = {\n /**\n * @internal\n */\n getSafeWorkingDir(): string {\n if (process.platform === \"win32\") {\n let systemRoot = process.env.SystemRoot || process.env[\"SYSTEMROOT\"];\n if (!systemRoot) {\n logger.getToken.warning(\n \"The SystemRoot environment variable is not set. This may cause issues when using the Azure CLI credential.\",\n );\n\n systemRoot = \"C:\\\\Windows\";\n }\n return systemRoot;\n } else {\n return \"/bin\";\n }\n },\n\n /**\n * Gets the access token from Azure CLI\n * @param resource - The resource to use when getting the token\n * @internal\n */\n async getAzureCliAccessToken(\n resource: string,\n tenantId?: string,\n subscription?: string,\n timeout?: number,\n ): Promise<{ stdout: string; stderr: string; error: Error | null }> {\n let tenantSection: string[] = [];\n let subscriptionSection: string[] = [];\n if (tenantId) {\n tenantSection = [\"--tenant\", tenantId];\n }\n if (subscription) {\n // Add quotes around the subscription to handle subscriptions with spaces\n subscriptionSection = [\"--subscription\", `\"${subscription}\"`];\n }\n return new Promise((resolve, reject) => {\n try {\n const args = [\n \"account\",\n \"get-access-token\",\n \"--output\",\n \"json\",\n \"--resource\",\n resource,\n ...tenantSection,\n ...subscriptionSection,\n ];\n const command = [\"az\", ...args].join(\" \");\n child_process.exec(\n command,\n { cwd: cliCredentialInternals.getSafeWorkingDir(), timeout },\n (error, stdout, stderr) => {\n resolve({ stdout: stdout, stderr: stderr, error });\n },\n );\n } catch (err: any) {\n reject(err);\n }\n });\n },\n};\n\n/**\n * This credential will use the currently logged-in user login information\n * via the Azure CLI ('az') commandline tool.\n * To do so, it will read the user access token and expire time\n * with Azure CLI command \"az account get-access-token\".\n */\nexport class AzureCliCredential implements TokenCredential {\n private tenantId?: string;\n private additionallyAllowedTenantIds: string[];\n private timeout?: number;\n private subscription?: string;\n\n /**\n * Creates an instance of the {@link AzureCliCredential}.\n *\n * To use this credential, ensure that you have already logged\n * in via the 'az' tool using the command \"az login\" from the commandline.\n *\n * @param options - Options, to optionally allow multi-tenant requests.\n */\n constructor(options?: AzureCliCredentialOptions) {\n if (options?.tenantId) {\n checkTenantId(logger, options?.tenantId);\n this.tenantId = options?.tenantId;\n }\n if (options?.subscription) {\n checkSubscription(logger, options?.subscription);\n this.subscription = options?.subscription;\n }\n this.additionallyAllowedTenantIds = resolveAdditionallyAllowedTenantIds(\n options?.additionallyAllowedTenants,\n );\n this.timeout = options?.processTimeoutInMs;\n }\n\n /**\n * Authenticates with Microsoft Entra ID and returns an access token if successful.\n * If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.\n *\n * @param scopes - The list of scopes for which the token will have access.\n * @param options - The options used to configure any requests this\n * TokenCredential implementation might make.\n */\n public async getToken(\n scopes: string | string[],\n options: GetTokenOptions = {},\n ): Promise<AccessToken> {\n const scope = typeof scopes === \"string\" ? scopes : scopes[0];\n const claimsValue = options.claims;\n if (claimsValue && claimsValue.trim()) {\n const encodedClaims = uint8ArrayToString(stringToUint8Array(claimsValue, \"utf-8\"), \"base64\");\n let loginCmd = `az login --claims-challenge ${encodedClaims} --scope ${scope}`;\n\n const tenantIdFromOptions = options.tenantId;\n if (tenantIdFromOptions) {\n loginCmd += ` --tenant ${tenantIdFromOptions}`;\n }\n\n const error = new CredentialUnavailableError(\n `${azureCliPublicErrorMessages.claim} ${loginCmd}`,\n );\n logger.getToken.info(formatError(scope, error));\n throw error;\n }\n\n const tenantId = processMultiTenantRequest(\n this.tenantId,\n options,\n this.additionallyAllowedTenantIds,\n );\n if (tenantId) {\n checkTenantId(logger, tenantId);\n }\n if (this.subscription) {\n checkSubscription(logger, this.subscription);\n }\n logger.getToken.info(`Using the scope ${scope}`);\n\n return tracingClient.withSpan(`${this.constructor.name}.getToken`, options, async () => {\n try {\n ensureValidScopeForDevTimeCreds(scope, logger);\n const resource = getScopeResource(scope);\n const obj = await cliCredentialInternals.getAzureCliAccessToken(\n resource,\n tenantId,\n this.subscription,\n this.timeout,\n );\n const specificScope = obj.stderr?.match(\"(.*)az login --scope(.*)\");\n const isLoginError = obj.stderr?.match(\"(.*)az login(.*)\") && !specificScope;\n const isNotInstallError =\n obj.stderr?.match(\"az:(.*)not found\") || obj.stderr?.startsWith(\"'az' is not recognized\");\n\n if (isNotInstallError) {\n const error = new CredentialUnavailableError(azureCliPublicErrorMessages.notInstalled);\n logger.getToken.info(formatError(scopes, error));\n throw error;\n }\n if (isLoginError) {\n const error = new CredentialUnavailableError(azureCliPublicErrorMessages.login);\n logger.getToken.info(formatError(scopes, error));\n throw error;\n }\n try {\n const responseData = obj.stdout;\n const response: AccessToken = this.parseRawResponse(responseData);\n logger.getToken.info(formatSuccess(scopes));\n return response;\n } catch (e: any) {\n if (obj.stderr) {\n throw new CredentialUnavailableError(obj.stderr);\n }\n throw e;\n }\n } catch (err: any) {\n const error =\n err.name === \"CredentialUnavailableError\"\n ? err\n : new CredentialUnavailableError(\n (err as Error).message || azureCliPublicErrorMessages.unknown,\n );\n logger.getToken.info(formatError(scopes, error));\n throw error;\n }\n });\n }\n\n /**\n * Parses the raw JSON response from the Azure CLI into a usable AccessToken object\n *\n * @param rawResponse - The raw JSON response from the Azure CLI\n * @returns An access token with the expiry time parsed from the raw response\n *\n * The expiryTime of the credential's access token, in milliseconds, is calculated as follows:\n *\n * When available, expires_on (introduced in Azure CLI v2.54.0) will be preferred. Otherwise falls back to expiresOn.\n */\n private parseRawResponse(rawResponse: string): AccessToken {\n const response: any = JSON.parse(rawResponse);\n const token = response.accessToken;\n // if available, expires_on will be a number representing seconds since epoch.\n // ensure it's a number or NaN\n let expiresOnTimestamp = Number.parseInt(response.expires_on, 10) * 1000;\n if (!isNaN(expiresOnTimestamp)) {\n logger.getToken.info(\"expires_on is available and is valid, using it\");\n return {\n token,\n expiresOnTimestamp,\n tokenType: \"Bearer\",\n };\n }\n\n // fallback to the older expiresOn - an RFC3339 date string\n expiresOnTimestamp = new Date(response.expiresOn).getTime();\n\n // ensure expiresOn is well-formatted\n if (isNaN(expiresOnTimestamp)) {\n throw new CredentialUnavailableError(\n `${azureCliPublicErrorMessages.unexpectedResponse} \"${response.expiresOn}\"`,\n );\n }\n\n return {\n token,\n expiresOnTimestamp,\n tokenType: \"Bearer\",\n };\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,2BAIO;AACP,qBAA6D;AAC7D,wBAAkE;AAGlE,oBAA2C;AAC3C,2BAA0B;AAC1B,uBAAuD;AACvD,qBAA8B;AAC9B,+BAAkC;AAElC,MAAM,aAAS,iCAAiB,oBAAoB;AAM7C,MAAM,8BAA8B;AAAA,EACzC,OACE;AAAA,EACF,cACE;AAAA,EACF,OACE;AAAA,EACF,SAAS;AAAA,EACT,oBACE;AACJ;AAMO,MAAM,yBAAyB;AAAA;AAAA;AAAA;AAAA,EAIpC,oBAA4B;AAC1B,QAAI,QAAQ,aAAa,SAAS;AAChC,UAAI,aAAa,QAAQ,IAAI,cAAc,QAAQ,IAAI,YAAY;AACnE,UAAI,CAAC,YAAY;AACf,eAAO,SAAS;AAAA,UACd;AAAA,QACF;AAEA,qBAAa;AAAA,MACf;AACA,aAAO;AAAA,IACT,OAAO;AACL,aAAO;AAAA,IACT;AAAA,EACF;AAAA;AAAA;AAAA;AAAA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,MAC1E;AAAA,IACF;AAEA,WAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA,WAAW;AAAA,IACb;AAAA,EACF;AACF;",
6
- "names": ["child_process"]
4
+ "sourcesContent": ["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { AccessToken, GetTokenOptions, TokenCredential } from \"@azure/core-auth\";\nimport {\n checkTenantId,\n processMultiTenantRequest,\n resolveAdditionallyAllowedTenantIds,\n} from \"../util/tenantIdUtils.js\";\nimport { credentialLogger, formatError, formatSuccess } from \"../util/logging.js\";\nimport { ensureValidScopeForDevTimeCreds, getScopeResource } from \"../util/scopeUtils.js\";\n\nimport type { AzureCliCredentialOptions } from \"./azureCliCredentialOptions.js\";\nimport { CredentialUnavailableError } from \"../errors.js\";\nimport { uint8ArrayToString, stringToUint8Array } from \"@azure/core-util\";\nimport { tracingClient } from \"../util/tracing.js\";\nimport { checkSubscription } from \"../util/subscriptionUtils.js\";\nimport { processUtils } from \"../util/processUtils.js\";\nimport { isProcessError } from \"@azure/core-process\";\n\nconst logger = credentialLogger(\"AzureCliCredential\");\n\n/**\n * Messages to use when throwing in this credential.\n * @internal\n */\nexport const azureCliPublicErrorMessages = {\n claim:\n \"This credential doesn't support claims challenges. To authenticate with the required claims, please run the following command:\",\n notInstalled:\n \"Azure CLI could not be found. Please visit https://aka.ms/azure-cli for installation instructions and then, once installed, authenticate to your Azure account using 'az login'.\",\n login:\n \"Please run 'az login' from a command prompt to authenticate before using this credential.\",\n unknown: \"Unknown error while trying to retrieve the access token\",\n unexpectedResponse:\n 'Unexpected response from Azure CLI when getting token. Expected \"expiresOn\" to be a RFC3339 date string. Got:',\n};\n\n/**\n * Mockable reference to the CLI credential cliCredentialFunctions\n * @internal\n */\nexport const cliCredentialInternals = {\n /**\n * @internal\n */\n getSafeWorkingDir(): string {\n if (process.platform === \"win32\") {\n let systemRoot = process.env.SystemRoot || process.env[\"SYSTEMROOT\"];\n if (!systemRoot) {\n logger.getToken.warning(\n \"The SystemRoot environment variable is not set. This may cause issues when using the Azure CLI credential.\",\n );\n\n systemRoot = \"C:\\\\Windows\";\n }\n return systemRoot;\n } else {\n return \"/bin\";\n }\n },\n\n /**\n * Gets the access token from Azure CLI\n * @param resource - The resource to use when getting the token\n * @internal\n */\n async getAzureCliAccessToken(\n resource: string,\n tenantId?: string,\n subscription?: string,\n timeout?: number,\n ): Promise<{ stdout: string; stderr: string; error: Error | null }> {\n let tenantSection: string[] = [];\n let subscriptionSection: string[] = [];\n if (tenantId) {\n tenantSection = [\"--tenant\", tenantId];\n }\n if (subscription) {\n subscriptionSection = [\"--subscription\", subscription];\n }\n const args = [\n \"account\",\n \"get-access-token\",\n \"--output\",\n \"json\",\n \"--resource\",\n resource,\n ...tenantSection,\n ...subscriptionSection,\n ];\n return processUtils.execFileWithResult(\"az\", args, {\n allowWindowsBatchFiles: true,\n cwd: cliCredentialInternals.getSafeWorkingDir(),\n encoding: \"utf8\",\n timeout,\n });\n },\n};\n\n/**\n * This credential will use the currently logged-in user login information\n * via the Azure CLI ('az') commandline tool.\n * To do so, it will read the user access token and expire time\n * with Azure CLI command \"az account get-access-token\".\n */\nexport class AzureCliCredential implements TokenCredential {\n private tenantId?: string;\n private additionallyAllowedTenantIds: string[];\n private timeout?: number;\n private subscription?: string;\n\n /**\n * Creates an instance of the {@link AzureCliCredential}.\n *\n * To use this credential, ensure that you have already logged\n * in via the 'az' tool using the command \"az login\" from the commandline.\n *\n * @param options - Options, to optionally allow multi-tenant requests.\n */\n constructor(options?: AzureCliCredentialOptions) {\n if (options?.tenantId) {\n checkTenantId(logger, options?.tenantId);\n this.tenantId = options?.tenantId;\n }\n if (options?.subscription) {\n checkSubscription(logger, options?.subscription);\n this.subscription = options?.subscription;\n }\n this.additionallyAllowedTenantIds = resolveAdditionallyAllowedTenantIds(\n options?.additionallyAllowedTenants,\n );\n this.timeout = options?.processTimeoutInMs;\n }\n\n /**\n * Authenticates with Microsoft Entra ID and returns an access token if successful.\n * If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.\n *\n * @param scopes - The list of scopes for which the token will have access.\n * @param options - The options used to configure any requests this\n * TokenCredential implementation might make.\n */\n public async getToken(\n scopes: string | string[],\n options: GetTokenOptions = {},\n ): Promise<AccessToken> {\n const scope = typeof scopes === \"string\" ? scopes : scopes[0];\n const claimsValue = options.claims;\n if (claimsValue && claimsValue.trim()) {\n const encodedClaims = uint8ArrayToString(stringToUint8Array(claimsValue, \"utf-8\"), \"base64\");\n let loginCmd = `az login --claims-challenge ${encodedClaims} --scope ${scope}`;\n\n const tenantIdFromOptions = options.tenantId;\n if (tenantIdFromOptions) {\n loginCmd += ` --tenant ${tenantIdFromOptions}`;\n }\n\n const error = new CredentialUnavailableError(\n `${azureCliPublicErrorMessages.claim} ${loginCmd}`,\n );\n logger.getToken.info(formatError(scope, error));\n throw error;\n }\n\n const tenantId = processMultiTenantRequest(\n this.tenantId,\n options,\n this.additionallyAllowedTenantIds,\n );\n if (tenantId) {\n checkTenantId(logger, tenantId);\n }\n if (this.subscription) {\n checkSubscription(logger, this.subscription);\n }\n logger.getToken.info(`Using the scope ${scope}`);\n\n return tracingClient.withSpan(`${this.constructor.name}.getToken`, options, async () => {\n try {\n ensureValidScopeForDevTimeCreds(scope, logger);\n const resource = getScopeResource(scope);\n const obj = await cliCredentialInternals.getAzureCliAccessToken(\n resource,\n tenantId,\n this.subscription,\n this.timeout,\n );\n const specificScope = obj.stderr?.match(\"(.*)az login --scope(.*)\");\n const isLoginError = obj.stderr?.match(\"(.*)az login(.*)\") && !specificScope;\n const isNotInstallError =\n obj.stderr?.match(\"az:(.*)not found\") ||\n obj.stderr?.startsWith(\"'az' is not recognized\") ||\n (obj.error && isProcessError(obj.error) && obj.error.code === \"ENOENT\");\n\n if (isNotInstallError) {\n const error = new CredentialUnavailableError(azureCliPublicErrorMessages.notInstalled);\n logger.getToken.info(formatError(scopes, error));\n throw error;\n }\n if (isLoginError) {\n const error = new CredentialUnavailableError(azureCliPublicErrorMessages.login);\n logger.getToken.info(formatError(scopes, error));\n throw error;\n }\n try {\n const responseData = obj.stdout;\n const response: AccessToken = this.parseRawResponse(responseData);\n logger.getToken.info(formatSuccess(scopes));\n return response;\n } catch (e: any) {\n if (obj.stderr) {\n throw new CredentialUnavailableError(obj.stderr);\n }\n throw e;\n }\n } catch (err: any) {\n const error =\n err.name === \"CredentialUnavailableError\"\n ? err\n : new CredentialUnavailableError(\n (err as Error).message || azureCliPublicErrorMessages.unknown,\n );\n logger.getToken.info(formatError(scopes, error));\n throw error;\n }\n });\n }\n\n /**\n * Parses the raw JSON response from the Azure CLI into a usable AccessToken object\n *\n * @param rawResponse - The raw JSON response from the Azure CLI\n * @returns An access token with the expiry time parsed from the raw response\n *\n * The expiryTime of the credential's access token, in milliseconds, is calculated as follows:\n *\n * When available, expires_on (introduced in Azure CLI v2.54.0) will be preferred. Otherwise falls back to expiresOn.\n */\n private parseRawResponse(rawResponse: string): AccessToken {\n const response: any = JSON.parse(rawResponse);\n const token = response.accessToken;\n // if available, expires_on will be a number representing seconds since epoch.\n // ensure it's a number or NaN\n let expiresOnTimestamp = Number.parseInt(response.expires_on, 10) * 1000;\n if (!isNaN(expiresOnTimestamp)) {\n logger.getToken.info(\"expires_on is available and is valid, using it\");\n return {\n token,\n expiresOnTimestamp,\n tokenType: \"Bearer\",\n };\n }\n\n // fallback to the older expiresOn - an RFC3339 date string\n expiresOnTimestamp = new Date(response.expiresOn).getTime();\n\n // ensure expiresOn is well-formatted\n if (isNaN(expiresOnTimestamp)) {\n throw new CredentialUnavailableError(\n `${azureCliPublicErrorMessages.unexpectedResponse} \"${response.expiresOn}\"`,\n );\n }\n\n return {\n token,\n expiresOnTimestamp,\n tokenType: \"Bearer\",\n };\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,2BAIO;AACP,qBAA6D;AAC7D,wBAAkE;AAGlE,oBAA2C;AAC3C,uBA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OAAO,SAAS,SAAS,YAAY,EAAE,IAAI;AACpE,QAAI,CAAC,MAAM,kBAAkB,GAAG;AAC9B,aAAO,SAAS,KAAK,gDAAgD;AACrE,aAAO;AAAA,QACL;AAAA,QACA;AAAA,QACA,WAAW;AAAA,MACb;AAAA,IACF;AAGA,yBAAqB,IAAI,KAAK,SAAS,SAAS,EAAE,QAAQ;AAG1D,QAAI,MAAM,kBAAkB,GAAG;AAC7B,YAAM,IAAI;AAAA,QACR,GAAG,4BAA4B,kBAAkB,KAAK,SAAS,SAAS;AAAA,MAC1E;AAAA,IACF;AAEA,WAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA,WAAW;AAAA,IACb;AAAA,EACF;AACF;",
6
+ "names": []
7
7
  }
@@ -1 +1 @@
1
- {"version":3,"file":"azureDeveloperCliCredential.d.ts","sourceRoot":"","sources":["../../../src/credentials/azureDeveloperCliCredential.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEtF,OAAO,KAAK,EAAE,kCAAkC,EAAE,MAAM,yCAAyC,CAAC;AAclG;;;GAGG;AACH,eAAO,MAAM,oCAAoC;;;;;CAQhD,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,+BAA+B;IAC1C;;;;;;;;;;;;;;;;OAgBG;2BACoB,MAAM,GAAG,MAAM;IAoCtC;;OAEG;yBACkB,MAAM;IAiB3B;;;;OAIG;8BAEO,MAAM,EAAE,aACL,MAAM,YACP,MAAM,WACP,MAAM,GACd,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAA;KAAE,CAAC;CA0CpE,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,qBAAa,2BAA4B,YAAW,eAAe;IACjE,OAAO,CAAC,QAAQ,CAAC,CAAS;IAC1B,OA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C5B,OAAO,CAAC,WAAW,CAAC;CAyFxB"}
@@ -1,8 +1,6 @@
1
- var __create = Object.create;
2
1
  var __defProp = Object.defineProperty;
3
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
5
  var __export = (target, all) => {
8
6
  for (var name in all)
@@ -16,14 +14,6 @@ var __copyProps = (to, from, except, desc) => {
16
14
  }
17
15
  return to;
18
16
  };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
18
  var azureDeveloperCliCredential_exports = {};
29
19
  __export(azureDeveloperCliCredential_exports, {
@@ -34,11 +24,11 @@ __export(azureDeveloperCliCredential_exports, {
34
24
  module.exports = __toCommonJS(azureDeveloperCliCredential_exports);
35
25
  var import_logging = require("../util/logging.js");
36
26
  var import_errors = require("../errors.js");
37
- var import_child_process = __toESM(require("child_process"));
38
27
  var import_tenantIdUtils = require("../util/tenantIdUtils.js");
39
28
  var import_tracing = require("../util/tracing.js");
40
29
  var import_scopeUtils = require("../util/scopeUtils.js");
41
30
  var import_core_util = require("@azure/core-util");
31
+ var import_processUtils = require("../util/processUtils.js");
42
32
  const logger = (0, import_logging.credentialLogger)("AzureDeveloperCliCredential");
43
33
  const azureDeveloperCliPublicErrorMessages = {
44
34
  notInstalled: "Azure Developer CLI couldn't be found. To mitigate this issue, see the troubleshooting guidelines at https://aka.ms/azsdk/js/identity/azdevclicredential/troubleshoot.",
@@ -124,35 +114,21 @@ const developerCliCredentialInternals = {
124
114
  const encodedClaims = (0, import_core_util.uint8ArrayToString)((0, import_core_util.stringToUint8Array)(claims, "utf-8"), "base64");
125
115
  claimsSections = ["--claims", encodedClaims];
126
116
  }
127
- return new Promise((resolve, reject) => {
128
- try {
129
- const args = [
130
- "auth",
131
- "token",
132
- "--output",
133
- "json",
134
- "--no-prompt",
135
- ...scopes.reduce(
136
- (previous, current) => previous.concat("--scope", current),
137
- []
138
- ),
139
- ...tenantSection,
140
- ...claimsSections
141
- ];
142
- const command = ["azd", ...args].join(" ");
143
- import_child_process.default.exec(
144
- command,
145
- {
146
- cwd: developerCliCredentialInternals.getSafeWorkingDir(),
147
- timeout
148
- },
149
- (error, stdout, stderr) => {
150
- resolve({ stdout, stderr, error });
151
- }
152
- );
153
- } catch (err) {
154
- reject(err);
155
- }
117
+ const args = [
118
+ "auth",
119
+ "token",
120
+ "--output",
121
+ "json",
122
+ "--no-prompt",
123
+ ...scopes.reduce((previous, current) => previous.concat("--scope", current), []),
124
+ ...tenantSection,
125
+ ...claimsSections
126
+ ];
127
+ return import_processUtils.processUtils.execFileWithResult("azd", args, {
128
+ allowWindowsBatchFiles: true,
129
+ cwd: developerCliCredentialInternals.getSafeWorkingDir(),
130
+ encoding: "utf8",
131
+ timeout
156
132
  });
157
133
  }
158
134
  };
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/credentials/azureDeveloperCliCredential.ts"],
4
- "sourcesContent": ["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { AccessToken, GetTokenOptions, TokenCredential } from \"@azure/core-auth\";\nimport { credentialLogger, formatError, formatSuccess } from \"../util/logging.js\";\nimport type { AzureDeveloperCliCredentialOptions } from \"./azureDeveloperCliCredentialOptions.js\";\nimport { CredentialUnavailableError } from \"../errors.js\";\nimport child_process from \"child_process\";\nimport {\n checkTenantId,\n processMultiTenantRequest,\n resolveAdditionallyAllowedTenantIds,\n} from \"../util/tenantIdUtils.js\";\nimport { tracingClient } from \"../util/tracing.js\";\nimport { ensureValidScopeForDevTimeCreds } from \"../util/scopeUtils.js\";\nimport { uint8ArrayToString, stringToUint8Array } from \"@azure/core-util\";\n\nconst logger = credentialLogger(\"AzureDeveloperCliCredential\");\n\n/**\n * Messages to use when throwing in this credential.\n * @internal\n */\nexport const azureDeveloperCliPublicErrorMessages = {\n notInstalled:\n \"Azure Developer CLI couldn't be found. To mitigate this issue, see the troubleshooting guidelines at https://aka.ms/azsdk/js/identity/azdevclicredential/troubleshoot.\",\n login:\n \"Please run 'azd auth login' from a command prompt to authenticate before using this credential. For more information, see the troubleshooting guidelines at https://aka.ms/azsdk/js/identity/azdevclicredential/troubleshoot.\",\n unknown: \"Unknown error while trying to retrieve the access token\",\n claim:\n \"This credential doesn't support claims challenges. To authenticate with the required claims, please run the following command:\",\n};\n\n/**\n * Mockable reference to the Developer CLI credential cliCredentialFunctions\n * @internal\n */\nexport const developerCliCredentialInternals = {\n /**\n * Parses azd stderr JSON output to extract a human-readable error message.\n *\n * Three formats are supported across azd versions:\n * - pre-v1.23.7: `{\"type\":\"consoleMessage\",\"data\":{\"message\":\"...\"}}`\n * - v1.23.7 - v1.23.15: an empty `consoleMessage` line followed by `{\"error\":\"...\",\"message\":\"...\",\"suggestion\":\"...\"}`\n * - v1.24.0+: `{\"error\":\"...\",\"message\":\"...\",\"suggestion\":\"...\"}`\n *\n * The structured `error` field is preferred. If absent, falls back to the\n * first non-empty `data.message` from a legacy `consoleMessage` line. If\n * neither is found, the raw stderr is returned unchanged so plain-text and\n * malformed output continue to surface to callers.\n *\n * @param stderr - The stderr output from azd command\n * @returns The parsed error message or raw stderr\n * @internal\n */\n parseAzdStderr(stderr: string): string {\n if (!stderr?.trim()) {\n return stderr;\n }\n\n let fallback: string | undefined;\n\n for (const rawLine of stderr.split(\"\\n\")) {\n const line = rawLine.trim();\n if (!line.startsWith(\"{\")) {\n continue;\n }\n\n let parsed: any;\n try {\n parsed = JSON.parse(line);\n } catch {\n // Not valid JSON on this line; continue.\n continue;\n }\n\n if (typeof parsed?.error === \"string\" && parsed.error.trim()) {\n return parsed.error.trim();\n }\n\n if (fallback === undefined) {\n const message = parsed?.data?.message;\n if (typeof message === \"string\" && message.trim()) {\n fallback = message.trim();\n }\n }\n }\n\n return fallback ?? stderr;\n },\n\n /**\n * @internal\n */\n getSafeWorkingDir(): string {\n if (process.platform === \"win32\") {\n let systemRoot = process.env.SystemRoot || process.env[\"SYSTEMROOT\"];\n if (!systemRoot) {\n logger.getToken.warning(\n \"The SystemRoot environment variable is not set. This may cause issues when using the Azure Developer CLI credential.\",\n );\n\n systemRoot = \"C:\\\\Windows\";\n }\n\n return systemRoot;\n } else {\n return \"/bin\";\n }\n },\n\n /**\n * Gets the access token from Azure Developer CLI\n * @param scopes - The scopes to use when getting the token\n * @internal\n */\n async getAzdAccessToken(\n scopes: string[],\n tenantId?: string,\n timeout?: number,\n claims?: string,\n ): Promise<{ stdout: string; stderr: string; error: Error | null }> {\n let tenantSection: string[] = [];\n if (tenantId) {\n tenantSection = [\"--tenant-id\", tenantId];\n }\n\n let claimsSections: string[] = [];\n if (claims) {\n const encodedClaims = uint8ArrayToString(stringToUint8Array(claims, \"utf-8\"), \"base64\");\n claimsSections = [\"--claims\", encodedClaims];\n }\n return new Promise((resolve, reject) => {\n try {\n const args = [\n \"auth\",\n \"token\",\n \"--output\",\n \"json\",\n \"--no-prompt\",\n ...scopes.reduce<string[]>(\n (previous, current) => previous.concat(\"--scope\", current),\n [],\n ),\n ...tenantSection,\n ...claimsSections,\n ];\n const command = [\"azd\", ...args].join(\" \");\n child_process.exec(\n command,\n {\n cwd: developerCliCredentialInternals.getSafeWorkingDir(),\n timeout,\n },\n (error, stdout, stderr) => {\n resolve({ stdout, stderr, error });\n },\n );\n } catch (err: any) {\n reject(err);\n }\n });\n },\n};\n\n/**\n * Azure Developer CLI is a command-line interface tool that allows developers to create, manage, and deploy\n * resources in Azure. It's built on top of the Azure CLI and provides additional functionality specific\n * to Azure developers. It allows users to authenticate as a user and/or a service principal against\n * <a href=\"https://learn.microsoft.com/entra/fundamentals/\">Microsoft Entra ID</a>. The\n * AzureDeveloperCliCredential authenticates in a development environment and acquires a token on behalf of\n * the logged-in user or service principal in the Azure Developer CLI. It acts as the Azure Developer CLI logged in user or\n * service principal and executes an Azure CLI command underneath to authenticate the application against\n * Microsoft Entra ID.\n *\n * <h2> Configure AzureDeveloperCliCredential </h2>\n *\n * To use this credential, the developer needs to authenticate locally in Azure Developer CLI using one of the\n * commands below:\n *\n * <ol>\n * <li>Run \"azd auth login\" in Azure Developer CLI to authenticate interactively as a user.</li>\n * <li>Run \"azd auth login --client-id clientID --client-secret clientSecret\n * --tenant-id tenantID\" to authenticate as a service principal.</li>\n * </ol>\n *\n * You may need to repeat this process after a certain time period, depending on the refresh token validity in your\n * organization. Generally, the refresh token validity period is a few weeks to a few months.\n * AzureDeveloperCliCredential will prompt you to sign in again.\n */\nexport class AzureDeveloperCliCredential implements TokenCredential {\n private tenantId?: string;\n private additionallyAllowedTenantIds: string[];\n private timeout?: number;\n\n /**\n * Creates an instance of the {@link AzureDeveloperCliCredential}.\n *\n * To use this credential, ensure that you have already logged\n * in via the 'azd' tool using the command \"azd auth login\" from the commandline.\n *\n * @param options - Options, to optionally allow multi-tenant requests.\n */\n constructor(options?: AzureDeveloperCliCredentialOptions) {\n if (options?.tenantId) {\n checkTenantId(logger, options?.tenantId);\n this.tenantId = options?.tenantId;\n }\n this.additionallyAllowedTenantIds = resolveAdditionallyAllowedTenantIds(\n options?.additionallyAllowedTenants,\n );\n this.timeout = options?.processTimeoutInMs;\n }\n\n /**\n * Authenticates with Microsoft Entra ID and returns an access token if successful.\n * If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.\n *\n * @param scopes - The list of scopes for which the token will have access.\n * @param options - The options used to configure any requests this\n * TokenCredential implementation might make.\n */\n public async getToken(\n scopes: string | string[],\n options: GetTokenOptions = {},\n ): Promise<AccessToken> {\n const tenantId = processMultiTenantRequest(\n this.tenantId,\n options,\n this.additionallyAllowedTenantIds,\n );\n if (tenantId) {\n checkTenantId(logger, tenantId);\n }\n let scopeList: string[];\n if (typeof scopes === \"string\") {\n scopeList = [scopes];\n } else {\n scopeList = scopes;\n }\n logger.getToken.info(`Using the scopes ${scopes}`);\n\n return tracingClient.withSpan(`${this.constructor.name}.getToken`, options, async () => {\n try {\n scopeList.forEach((scope) => {\n ensureValidScopeForDevTimeCreds(scope, logger);\n });\n const obj = await developerCliCredentialInternals.getAzdAccessToken(\n scopeList,\n tenantId,\n this.timeout,\n options.claims,\n );\n const isMFARequiredError =\n obj.stderr?.match(\"must use multi-factor authentication\") ||\n obj.stderr?.match(\"reauthentication required\");\n const isNotLoggedInError =\n obj.stderr?.match(\"not logged in, run `azd login` to login\") ||\n obj.stderr?.match(\"not logged in, run `azd auth login` to login\");\n const isNotInstallError =\n obj.stderr?.match(\"azd:(.*)not found\") ||\n obj.stderr?.startsWith(\"'azd' is not recognized\");\n if (isNotInstallError || (obj.error && (obj.error as any).code === \"ENOENT\")) {\n const error = new CredentialUnavailableError(\n azureDeveloperCliPublicErrorMessages.notInstalled,\n );\n logger.getToken.info(formatError(scopes, error));\n throw error;\n }\n\n if (isNotLoggedInError) {\n const error = new CredentialUnavailableError(azureDeveloperCliPublicErrorMessages.login);\n logger.getToken.info(formatError(scopes, error));\n throw error;\n }\n if (isMFARequiredError) {\n const scope = scopeList\n .reduce<string[]>((previous, current) => previous.concat(\"--scope\", current), [])\n .join(\" \");\n const loginCmd = `azd auth login ${scope}`;\n const error = new CredentialUnavailableError(\n `${azureDeveloperCliPublicErrorMessages.claim} ${loginCmd}`,\n );\n logger.getToken.info(formatError(scopes, error));\n throw error;\n }\n\n try {\n const resp: { token: string; expiresOn: string } = JSON.parse(obj.stdout);\n logger.getToken.info(formatSuccess(scopes));\n return {\n token: resp.token,\n expiresOnTimestamp: new Date(resp.expiresOn).getTime(),\n tokenType: \"Bearer\",\n } as AccessToken;\n } catch (e: any) {\n if (obj.stderr) {\n const errorMessage = developerCliCredentialInternals.parseAzdStderr(obj.stderr);\n throw new CredentialUnavailableError(errorMessage);\n }\n throw e;\n }\n } catch (err: any) {\n const error =\n err.name === \"CredentialUnavailableError\"\n ? err\n : new CredentialUnavailableError(\n (err as Error).message || azureDeveloperCliPublicErrorMessages.unknown,\n );\n logger.getToken.info(formatError(scopes, error));\n throw error;\n }\n });\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,qBAA6D;AAE7D,oBAA2C;AAC3C,2BAA0B;AAC1B,2BAIO;AACP,qBAA8B;AAC9B,wBAAgD;AAChD,uBAAuD;AAEvD,MAAM,aAAS,iCAAiB,6BAA6B;AAMtD,MAAM,uCAAuC;AAAA,EAClD,cACE;AAAA,EACF,OACE;AAAA,EACF,SAAS;AAAA,EACT,OACE;AACJ;AAMO,MAAM,kCAAkC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAkB7C,eAAe,QAAwB;AACrC,QAAI,CAAC,QAAQ,KAAK,GAAG;AACnB,aAAO;AAAA,IACT;AAEA,QAAI;AAEJ,eAAW,WAAW,OAAO,MAAM,IAAI,GAAG;AACxC,YAAM,OAAO,QAAQ,KAAK;AAC1B,UAAI,CAAC,KAAK,WAAW,GAAG,GAAG;AACzB;AAAA,MACF;AAEA,UAAI;AACJ,UAAI;AACF,iBAAS,KAAK,MAAM,IAAI;AAAA,MAC1B,QAAQ;AAEN;AAAA,MACF;AAEA,UAAI,OAAO,QAAQ,UAAU,YAAY,OAAO,MAAM,KAAK,GAAG;AAC5D,eAAO,OAAO,MAAM,KAAK;AAAA,MAC3B;AAEA,UAAI,aAAa,QAAW;AAC1B,cA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AA,UACD,IAAc,WAAW,qCAAqC;AAAA,QACjE;AACN,eAAO,SAAS,SAAK,4BAAY,QAAQ,KAAK,CAAC;AAC/C,cAAM;AAAA,MACR;AAAA,IACF,CAAC;AAAA,EACH;AACF;",
6
- "names": ["child_process"]
4
+ "sourcesContent": ["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { AccessToken, GetTokenOptions, TokenCredential } from \"@azure/core-auth\";\nimport { credentialLogger, formatError, formatSuccess } from \"../util/logging.js\";\nimport type { AzureDeveloperCliCredentialOptions } from \"./azureDeveloperCliCredentialOptions.js\";\nimport { CredentialUnavailableError } from \"../errors.js\";\nimport {\n checkTenantId,\n processMultiTenantRequest,\n resolveAdditionallyAllowedTenantIds,\n} from \"../util/tenantIdUtils.js\";\nimport { tracingClient } from \"../util/tracing.js\";\nimport { ensureValidScopeForDevTimeCreds } from \"../util/scopeUtils.js\";\nimport { uint8ArrayToString, stringToUint8Array } from \"@azure/core-util\";\nimport { processUtils } from \"../util/processUtils.js\";\n\nconst logger = credentialLogger(\"AzureDeveloperCliCredential\");\n\n/**\n * Messages to use when throwing in this credential.\n * @internal\n */\nexport const azureDeveloperCliPublicErrorMessages = {\n notInstalled:\n \"Azure Developer CLI couldn't be found. To mitigate this issue, see the troubleshooting guidelines at https://aka.ms/azsdk/js/identity/azdevclicredential/troubleshoot.\",\n login:\n \"Please run 'azd auth login' from a command prompt to authenticate before using this credential. For more information, see the troubleshooting guidelines at https://aka.ms/azsdk/js/identity/azdevclicredential/troubleshoot.\",\n unknown: \"Unknown error while trying to retrieve the access token\",\n claim:\n \"This credential doesn't support claims challenges. To authenticate with the required claims, please run the following command:\",\n};\n\n/**\n * Mockable reference to the Developer CLI credential cliCredentialFunctions\n * @internal\n */\nexport const developerCliCredentialInternals = {\n /**\n * Parses azd stderr JSON output to extract a human-readable error message.\n *\n * Three formats are supported across azd versions:\n * - pre-v1.23.7: `{\"type\":\"consoleMessage\",\"data\":{\"message\":\"...\"}}`\n * - v1.23.7 - v1.23.15: an empty `consoleMessage` line followed by `{\"error\":\"...\",\"message\":\"...\",\"suggestion\":\"...\"}`\n * - v1.24.0+: `{\"error\":\"...\",\"message\":\"...\",\"suggestion\":\"...\"}`\n *\n * The structured `error` field is preferred. If absent, falls back to the\n * first non-empty `data.message` from a legacy `consoleMessage` line. If\n * neither is found, the raw stderr is returned unchanged so plain-text and\n * malformed output continue to surface to callers.\n *\n * @param stderr - The stderr output from azd command\n * @returns The parsed error message or raw stderr\n * @internal\n */\n parseAzdStderr(stderr: string): string {\n if (!stderr?.trim()) {\n return stderr;\n }\n\n let fallback: string | undefined;\n\n for (const rawLine of stderr.split(\"\\n\")) {\n const line = rawLine.trim();\n if (!line.startsWith(\"{\")) {\n continue;\n }\n\n let parsed: any;\n try {\n parsed = JSON.parse(line);\n } catch {\n // Not valid JSON on this line; continue.\n continue;\n }\n\n if (typeof parsed?.error === \"string\" && parsed.error.trim()) {\n return parsed.error.trim();\n }\n\n if (fallback === undefined) {\n const message = parsed?.data?.message;\n if (typeof message === \"string\" && message.trim()) {\n fallback = message.trim();\n }\n }\n }\n\n return fallback ?? stderr;\n },\n\n /**\n * @internal\n */\n getSafeWorkingDir(): string {\n if (process.platform === \"win32\") {\n let systemRoot = process.env.SystemRoot || process.env[\"SYSTEMROOT\"];\n if (!systemRoot) {\n logger.getToken.warning(\n \"The SystemRoot environment variable is not set. This may cause issues when using the Azure Developer CLI credential.\",\n );\n\n systemRoot = \"C:\\\\Windows\";\n }\n\n return systemRoot;\n } else {\n return \"/bin\";\n }\n },\n\n /**\n * Gets the access token from Azure Developer CLI\n * @param scopes - The scopes to use when getting the token\n * @internal\n */\n async getAzdAccessToken(\n scopes: string[],\n tenantId?: string,\n timeout?: number,\n claims?: string,\n ): Promise<{ stdout: string; stderr: string; error: Error | null }> {\n let tenantSection: string[] = [];\n if (tenantId) {\n tenantSection = [\"--tenant-id\", tenantId];\n }\n\n let claimsSections: string[] = [];\n if (claims) {\n const encodedClaims = uint8ArrayToString(stringToUint8Array(claims, \"utf-8\"), \"base64\");\n claimsSections = [\"--claims\", encodedClaims];\n }\n const args = [\n \"auth\",\n \"token\",\n \"--output\",\n \"json\",\n \"--no-prompt\",\n ...scopes.reduce<string[]>((previous, current) => previous.concat(\"--scope\", current), []),\n ...tenantSection,\n ...claimsSections,\n ];\n return processUtils.execFileWithResult(\"azd\", args, {\n allowWindowsBatchFiles: true,\n cwd: developerCliCredentialInternals.getSafeWorkingDir(),\n encoding: \"utf8\",\n timeout,\n });\n },\n};\n\n/**\n * Azure Developer CLI is a command-line interface tool that allows developers to create, manage, and deploy\n * resources in Azure. It's built on top of the Azure CLI and provides additional functionality specific\n * to Azure developers. It allows users to authenticate as a user and/or a service principal against\n * <a href=\"https://learn.microsoft.com/entra/fundamentals/\">Microsoft Entra ID</a>. The\n * AzureDeveloperCliCredential authenticates in a development environment and acquires a token on behalf of\n * the logged-in user or service principal in the Azure Developer CLI. It acts as the Azure Developer CLI logged in user or\n * service principal and executes an Azure CLI command underneath to authenticate the application against\n * Microsoft Entra ID.\n *\n * <h2> Configure AzureDeveloperCliCredential </h2>\n *\n * To use this credential, the developer needs to authenticate locally in Azure Developer CLI using one of the\n * commands below:\n *\n * <ol>\n * <li>Run \"azd auth login\" in Azure Developer CLI to authenticate interactively as a user.</li>\n * <li>Run \"azd auth login --client-id clientID --client-secret clientSecret\n * --tenant-id tenantID\" to authenticate as a service principal.</li>\n * </ol>\n *\n * You may need to repeat this process after a certain time period, depending on the refresh token validity in your\n * organization. Generally, the refresh token validity period is a few weeks to a few months.\n * AzureDeveloperCliCredential will prompt you to sign in again.\n */\nexport class AzureDeveloperCliCredential implements TokenCredential {\n private tenantId?: string;\n private additionallyAllowedTenantIds: string[];\n private timeout?: number;\n\n /**\n * Creates an instance of the {@link AzureDeveloperCliCredential}.\n *\n * To use this credential, ensure that you have already logged\n * in via the 'azd' tool using the command \"azd auth login\" from the commandline.\n *\n * @param options - Options, to optionally allow multi-tenant requests.\n */\n constructor(options?: AzureDeveloperCliCredentialOptions) {\n if (options?.tenantId) {\n checkTenantId(logger, options?.tenantId);\n this.tenantId = options?.tenantId;\n }\n this.additionallyAllowedTenantIds = resolveAdditionallyAllowedTenantIds(\n options?.additionallyAllowedTenants,\n );\n this.timeout = options?.processTimeoutInMs;\n }\n\n /**\n * Authenticates with Microsoft Entra ID and returns an access token if successful.\n * If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.\n *\n * @param scopes - The list of scopes for which the token will have access.\n * @param options - The options used to configure any requests this\n * TokenCredential implementation might make.\n */\n public async getToken(\n scopes: string | string[],\n options: GetTokenOptions = {},\n ): Promise<AccessToken> {\n const tenantId = processMultiTenantRequest(\n this.tenantId,\n options,\n this.additionallyAllowedTenantIds,\n );\n if (tenantId) {\n checkTenantId(logger, tenantId);\n }\n let scopeList: string[];\n if (typeof scopes === \"string\") {\n scopeList = [scopes];\n } else {\n scopeList = scopes;\n }\n logger.getToken.info(`Using the scopes ${scopes}`);\n\n return tracingClient.withSpan(`${this.constructor.name}.getToken`, options, async () => {\n try {\n scopeList.forEach((scope) => {\n ensureValidScopeForDevTimeCreds(scope, logger);\n });\n const obj = await developerCliCredentialInternals.getAzdAccessToken(\n scopeList,\n tenantId,\n this.timeout,\n options.claims,\n );\n const isMFARequiredError =\n obj.stderr?.match(\"must use multi-factor authentication\") ||\n obj.stderr?.match(\"reauthentication required\");\n const isNotLoggedInError =\n obj.stderr?.match(\"not logged in, run `azd login` to login\") ||\n obj.stderr?.match(\"not logged in, run `azd auth login` to login\");\n const isNotInstallError =\n obj.stderr?.match(\"azd:(.*)not found\") ||\n obj.stderr?.startsWith(\"'azd' is not recognized\");\n if (isNotInstallError || (obj.error && (obj.error as any).code === \"ENOENT\")) {\n const error = new CredentialUnavailableError(\n azureDeveloperCliPublicErrorMessages.notInstalled,\n );\n logger.getToken.info(formatError(scopes, error));\n throw error;\n }\n\n if (isNotLoggedInError) {\n const error = new CredentialUnavailableError(azureDeveloperCliPublicErrorMessages.login);\n logger.getToken.info(formatError(scopes, error));\n throw error;\n }\n if (isMFARequiredError) {\n const scope = scopeList\n .reduce<string[]>((previous, current) => previous.concat(\"--scope\", current), [])\n .join(\" \");\n const loginCmd = `azd auth login ${scope}`;\n const error = new CredentialUnavailableError(\n `${azureDeveloperCliPublicErrorMessages.claim} ${loginCmd}`,\n );\n logger.getToken.info(formatError(scopes, error));\n throw error;\n }\n\n try {\n const resp: { token: string; expiresOn: string } = JSON.parse(obj.stdout);\n logger.getToken.info(formatSuccess(scopes));\n return {\n token: resp.token,\n expiresOnTimestamp: new Date(resp.expiresOn).getTime(),\n tokenType: \"Bearer\",\n } as AccessToken;\n } catch (e: any) {\n if (obj.stderr) {\n const errorMessage = developerCliCredentialInternals.parseAzdStderr(obj.stderr);\n throw new CredentialUnavailableError(errorMessage);\n }\n throw e;\n }\n } catch (err: any) {\n const error =\n err.name === \"CredentialUnavailableError\"\n ? err\n : new CredentialUnavailableError(\n (err as Error).message || azureDeveloperCliPublicErrorMessages.unknown,\n );\n logger.getToken.info(formatError(scopes, error));\n throw error;\n }\n });\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,qBAA6D;AAE7D,oBAA2C;AAC3C,2BAIO;AACP,qBAA8B;AAC9B,wBAAgD;AAChD,uBAAuD;AACvD,0BAA6B;AAE7B,MAAM,aAAS,iCAAiB,6BAA6B;AAMtD,MAAM,uCAAuC;AAAA,EAClD,cACE;AAAA,EACF,OACE;AAAA,EACF,SAAS;AAAA,EACT,OACE;AACJ;AAMO,MAAM,kCAAkC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAkB7C,eAAe,QAAwB;AACrC,QAAI,CAAC,QAAQ,KAAK,GAAG;AACnB,aAAO;AAAA,IACT;AAEA,QAAI;AAEJ,eA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ACA,gBAAM;AAAA,QACR;AAAA,MACF,SAAS,KAAU;AACjB,cAAM,QACJ,IAAI,SAAS,+BACT,MACA,IAAI;AAAA,UACD,IAAc,WAAW,qCAAqC;AAAA,QACjE;AACN,eAAO,SAAS,SAAK,4BAAY,QAAQ,KAAK,CAAC;AAC/C,cAAM;AAAA,MACR;AAAA,IACF,CAAC;AAAA,EACH;AACF;",
6
+ "names": []
7
7
  }
@@ -1,5 +1,15 @@
1
1
  import type { AccessToken, GetTokenOptions, TokenCredential } from "@azure/core-auth";
2
2
  import type { AzurePowerShellCredentialOptions } from "./azurePowerShellCredentialOptions.js";
3
+ /**
4
+ * Creates the child environment used to pass private values to PowerShell.
5
+ *
6
+ * @param resource - The resource passed to PowerShell.
7
+ * @param tenantId - The optional tenant ID passed to PowerShell.
8
+ * @param environment - The environment to copy.
9
+ * @returns A child environment containing canonical private variable names.
10
+ * @internal
11
+ */
12
+ export declare function createPowerShellEnvironment(resource: string, tenantId: string | undefined, environment?: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
3
13
  /**
4
14
  * Returns a platform-appropriate command name by appending ".exe" on Windows.
5
15
  *
@@ -1 +1 @@
1
- {"version":3,"file":"azurePowerShellCredential.d.ts","sourceRoot":"","sources":["../../../src/credentials/azurePowerShellCredential.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAStF,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,uCAAuC,CAAC;AAU9F;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAMzD;AAuBD;;;GAGG;AACH,eAAO,MAAM,gBAAgB;;;CAI5B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,6BAA6B;;;;;CAOzC,CAAC;AAUF;;;;GAIG;AACH,eAAO,MAAM,YAAY,UAA0B,CAAC;AAMpD;;;;GAIG;AACH,qBAAa,yBAA0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,CAAC,CAAS;IAC1B,OAAO,CAAC,4BAA4B,CAAW;IAC/C,OAAO,CAAC,OAAO,CAAC,CAAS;IAEzB;;;;;;;;;;OAUG;gBACS,OAAO,CAAC,EAAE,gCAAgC;IAWtD;;;OAGG;YACW,6BAA6B;IA6E3C;;;;;;OAMG;IACU,QAAQ,CACnB,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,EACzB,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,WAAW,CAAC;CA6DxB;AAED;;;GAGG;AACH,wBAAsB,cAAc,CAClC,MAAM,EAAE,MAAM,GACb,OAAO,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC,CAyB/C"}
@@ -19,6 +19,7 @@ var azurePowerShellCredential_exports = {};
19
19
  __export(azurePowerShellCredential_exports, {
20
20
  AzurePowerShellCredential: () => AzurePowerShellCredential,
21
21
  commandStack: () => commandStack,
22
+ createPowerShellEnvironment: () => createPowerShellEnvironment,
22
23
  formatCommand: () => formatCommand,
23
24
  parseJsonToken: () => parseJsonToken,
24
25
  powerShellErrors: () => powerShellErrors,
@@ -34,6 +35,23 @@ var import_tracing = require("../util/tracing.js");
34
35
  var import_core_util = require("@azure/core-util");
35
36
  const logger = (0, import_logging.credentialLogger)("AzurePowerShellCredential");
36
37
  const isWindows = process.platform === "win32";
38
+ const powerShellResourceEnvironmentVariable = "AZURE_IDENTITY_POWERSHELL_RESOURCE";
39
+ const powerShellTenantEnvironmentVariable = "AZURE_IDENTITY_POWERSHELL_TENANT_ID";
40
+ const powerShellPrivateEnvironmentVariables = new Set(
41
+ [powerShellResourceEnvironmentVariable, powerShellTenantEnvironmentVariable].map(
42
+ (name) => name.toLowerCase()
43
+ )
44
+ );
45
+ function createPowerShellEnvironment(resource, tenantId, environment = process.env) {
46
+ const childEnvironment = Object.fromEntries(
47
+ Object.entries(environment).filter(
48
+ ([name]) => !powerShellPrivateEnvironmentVariables.has(name.toLowerCase())
49
+ )
50
+ );
51
+ childEnvironment[powerShellResourceEnvironmentVariable] = resource;
52
+ childEnvironment[powerShellTenantEnvironmentVariable] = tenantId ?? "";
53
+ return childEnvironment;
54
+ }
37
55
  function formatCommand(commandName) {
38
56
  if (isWindows) {
39
57
  return `${commandName}.exe`;
@@ -41,12 +59,13 @@ function formatCommand(commandName) {
41
59
  return commandName;
42
60
  }
43
61
  }
44
- async function runCommands(commands, timeout) {
62
+ async function runCommands(commands, timeout, env) {
45
63
  const results = [];
46
64
  for (const command of commands) {
47
65
  const [file, ...parameters] = command;
48
66
  const result = await import_processUtils.processUtils.execFile(file, parameters, {
49
67
  encoding: "utf8",
68
+ env,
50
69
  timeout
51
70
  });
52
71
  results.push(result);
@@ -106,19 +125,21 @@ class AzurePowerShellCredential {
106
125
  commandStack.shift();
107
126
  continue;
108
127
  }
109
- const results = await runCommands([
128
+ const results = await runCommands(
110
129
  [
111
- powerShellCommand,
112
- "-NoProfile",
113
- "-NonInteractive",
114
- "-Command",
115
- `
116
- $tenantId = "${tenantId ?? ""}"
130
+ [
131
+ powerShellCommand,
132
+ "-NoProfile",
133
+ "-NonInteractive",
134
+ "-Command",
135
+ `
136
+ $tenantId = $env:${powerShellTenantEnvironmentVariable}
137
+ $resource = $env:${powerShellResourceEnvironmentVariable}
117
138
  $m = Import-Module Az.Accounts -MinimumVersion 2.2.0 -PassThru
118
139
  $useSecureString = $m.Version -ge [version]'2.17.0' -and $m.Version -lt [version]'5.0.0'
119
140
 
120
141
  $params = @{
121
- ResourceUrl = "${resource}"
142
+ ResourceUrl = $resource
122
143
  }
123
144
 
124
145
  if ($tenantId.Length -gt 0) {
@@ -154,8 +175,11 @@ class AzurePowerShellCredential {
154
175
 
155
176
  Write-Output (ConvertTo-Json $result)
156
177
  `
157
- ]
158
- ]);
178
+ ]
179
+ ],
180
+ timeout,
181
+ createPowerShellEnvironment(resource, tenantId)
182
+ );
159
183
  const result = results[0];
160
184
  return parseJsonToken(result);
161
185
  }
@@ -256,6 +280,7 @@ async function parseJsonToken(result) {
256
280
  0 && (module.exports = {
257
281
  AzurePowerShellCredential,
258
282
  commandStack,
283
+ createPowerShellEnvironment,
259
284
  formatCommand,
260
285
  parseJsonToken,
261
286
  powerShellErrors,