@azure/identity 4.11.0-alpha.20250717.4 → 4.11.0-alpha.20250721.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.
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/defaultAzureCredentialFunctions.d.ts +62 -0
  5. package/dist/browser/credentials/defaultAzureCredentialFunctions.d.ts.map +1 -0
  6. package/dist/browser/credentials/defaultAzureCredentialFunctions.js +143 -0
  7. package/dist/browser/credentials/defaultAzureCredentialFunctions.js.map +1 -0
  8. package/dist/browser/util/processUtils.d.ts +1 -1
  9. package/dist/browser/util/processUtils.d.ts.map +1 -1
  10. package/dist/browser/util/processUtils.js +3 -1
  11. package/dist/browser/util/processUtils.js.map +1 -1
  12. package/dist/commonjs/constants.d.ts +1 -1
  13. package/dist/commonjs/constants.js +1 -1
  14. package/dist/commonjs/constants.js.map +1 -1
  15. package/dist/commonjs/credentials/azureCliCredential.d.ts.map +1 -1
  16. package/dist/commonjs/credentials/azureCliCredential.js +4 -2
  17. package/dist/commonjs/credentials/azureCliCredential.js.map +1 -1
  18. package/dist/commonjs/credentials/azureDeveloperCliCredential.d.ts.map +1 -1
  19. package/dist/commonjs/credentials/azureDeveloperCliCredential.js +4 -2
  20. package/dist/commonjs/credentials/azureDeveloperCliCredential.js.map +1 -1
  21. package/dist/commonjs/credentials/defaultAzureCredential.d.ts +12 -32
  22. package/dist/commonjs/credentials/defaultAzureCredential.d.ts.map +1 -1
  23. package/dist/commonjs/credentials/defaultAzureCredential.js +46 -161
  24. package/dist/commonjs/credentials/defaultAzureCredential.js.map +1 -1
  25. package/dist/commonjs/credentials/defaultAzureCredentialFunctions.d.ts +62 -0
  26. package/dist/commonjs/credentials/defaultAzureCredentialFunctions.d.ts.map +1 -0
  27. package/dist/commonjs/credentials/defaultAzureCredentialFunctions.js +153 -0
  28. package/dist/commonjs/credentials/defaultAzureCredentialFunctions.js.map +1 -0
  29. package/dist/commonjs/tsdoc-metadata.json +11 -11
  30. package/dist/commonjs/util/processUtils.d.ts +1 -1
  31. package/dist/commonjs/util/processUtils.d.ts.map +1 -1
  32. package/dist/commonjs/util/processUtils.js +3 -1
  33. package/dist/commonjs/util/processUtils.js.map +1 -1
  34. package/dist/esm/constants.d.ts +1 -1
  35. package/dist/esm/constants.js +1 -1
  36. package/dist/esm/constants.js.map +1 -1
  37. package/dist/esm/credentials/azureCliCredential.d.ts.map +1 -1
  38. package/dist/esm/credentials/azureCliCredential.js +4 -2
  39. package/dist/esm/credentials/azureCliCredential.js.map +1 -1
  40. package/dist/esm/credentials/azureDeveloperCliCredential.d.ts.map +1 -1
  41. package/dist/esm/credentials/azureDeveloperCliCredential.js +4 -2
  42. package/dist/esm/credentials/azureDeveloperCliCredential.js.map +1 -1
  43. package/dist/esm/credentials/defaultAzureCredential.d.ts +12 -32
  44. package/dist/esm/credentials/defaultAzureCredential.d.ts.map +1 -1
  45. package/dist/esm/credentials/defaultAzureCredential.js +39 -150
  46. package/dist/esm/credentials/defaultAzureCredential.js.map +1 -1
  47. package/dist/esm/credentials/defaultAzureCredentialFunctions.d.ts +62 -0
  48. package/dist/esm/credentials/defaultAzureCredentialFunctions.d.ts.map +1 -0
  49. package/dist/esm/credentials/defaultAzureCredentialFunctions.js +143 -0
  50. package/dist/esm/credentials/defaultAzureCredentialFunctions.js.map +1 -0
  51. package/dist/esm/util/processUtils.d.ts +1 -1
  52. package/dist/esm/util/processUtils.d.ts.map +1 -1
  53. package/dist/esm/util/processUtils.js +3 -1
  54. package/dist/esm/util/processUtils.js.map +1 -1
  55. package/dist/workerd/constants.d.ts +1 -1
  56. package/dist/workerd/constants.js +1 -1
  57. package/dist/workerd/constants.js.map +1 -1
  58. package/dist/workerd/credentials/azureCliCredential.d.ts.map +1 -1
  59. package/dist/workerd/credentials/azureCliCredential.js +4 -2
  60. package/dist/workerd/credentials/azureCliCredential.js.map +1 -1
  61. package/dist/workerd/credentials/azureDeveloperCliCredential.d.ts.map +1 -1
  62. package/dist/workerd/credentials/azureDeveloperCliCredential.js +4 -2
  63. package/dist/workerd/credentials/azureDeveloperCliCredential.js.map +1 -1
  64. package/dist/workerd/credentials/defaultAzureCredential.d.ts +12 -32
  65. package/dist/workerd/credentials/defaultAzureCredential.d.ts.map +1 -1
  66. package/dist/workerd/credentials/defaultAzureCredential.js +39 -150
  67. package/dist/workerd/credentials/defaultAzureCredential.js.map +1 -1
  68. package/dist/workerd/credentials/defaultAzureCredentialFunctions.d.ts +62 -0
  69. package/dist/workerd/credentials/defaultAzureCredentialFunctions.d.ts.map +1 -0
  70. package/dist/workerd/credentials/defaultAzureCredentialFunctions.js +143 -0
  71. package/dist/workerd/credentials/defaultAzureCredentialFunctions.js.map +1 -0
  72. package/dist/workerd/util/processUtils.d.ts +1 -1
  73. package/dist/workerd/util/processUtils.d.ts.map +1 -1
  74. package/dist/workerd/util/processUtils.js +3 -1
  75. package/dist/workerd/util/processUtils.js.map +1 -1
  76. package/package.json +1 -1
@@ -3,156 +3,10 @@
3
3
  // Licensed under the MIT License.
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
5
  exports.DefaultAzureCredential = exports.UnavailableDefaultCredential = void 0;
6
- exports.createDefaultManagedIdentityCredential = createDefaultManagedIdentityCredential;
7
- exports.createDefaultBrokerCredential = createDefaultBrokerCredential;
8
- exports.createEnvironmentCredential = createEnvironmentCredential;
9
- exports.createDefaultVisualStudioCodeCredential = createDefaultVisualStudioCodeCredential;
10
- const index_js_1 = require("./managedIdentityCredential/index.js");
11
- const azureCliCredential_js_1 = require("./azureCliCredential.js");
12
- const azureDeveloperCliCredential_js_1 = require("./azureDeveloperCliCredential.js");
13
- const azurePowerShellCredential_js_1 = require("./azurePowerShellCredential.js");
14
6
  const chainedTokenCredential_js_1 = require("./chainedTokenCredential.js");
15
- const environmentCredential_js_1 = require("./environmentCredential.js");
16
- const workloadIdentityCredential_js_1 = require("./workloadIdentityCredential.js");
17
7
  const logging_js_1 = require("../util/logging.js");
18
- const visualStudioCodeCredential_js_1 = require("./visualStudioCodeCredential.js");
19
- const brokerCredential_js_1 = require("./brokerCredential.js");
8
+ const defaultAzureCredentialFunctions_js_1 = require("./defaultAzureCredentialFunctions.js");
20
9
  const logger = (0, logging_js_1.credentialLogger)("DefaultAzureCredential");
21
- /**
22
- * Creates a {@link ManagedIdentityCredential} from the provided options.
23
- * @param options - Options to configure the credential.
24
- *
25
- * @internal
26
- */
27
- function createDefaultManagedIdentityCredential(options = {}) {
28
- options.retryOptions ??= {
29
- maxRetries: 5,
30
- retryDelayInMs: 800,
31
- };
32
- const managedIdentityClientId = options?.managedIdentityClientId ??
33
- process.env.AZURE_CLIENT_ID;
34
- const workloadIdentityClientId = options?.workloadIdentityClientId ??
35
- managedIdentityClientId;
36
- const managedResourceId = options
37
- ?.managedIdentityResourceId;
38
- const workloadFile = process.env.AZURE_FEDERATED_TOKEN_FILE;
39
- const tenantId = options?.tenantId ?? process.env.AZURE_TENANT_ID;
40
- if (managedResourceId) {
41
- const managedIdentityResourceIdOptions = {
42
- ...options,
43
- resourceId: managedResourceId,
44
- };
45
- return new index_js_1.ManagedIdentityCredential(managedIdentityResourceIdOptions);
46
- }
47
- if (workloadFile && workloadIdentityClientId) {
48
- const workloadIdentityCredentialOptions = {
49
- ...options,
50
- tenantId: tenantId,
51
- };
52
- return new index_js_1.ManagedIdentityCredential(workloadIdentityClientId, workloadIdentityCredentialOptions);
53
- }
54
- if (managedIdentityClientId) {
55
- const managedIdentityClientOptions = {
56
- ...options,
57
- clientId: managedIdentityClientId,
58
- };
59
- return new index_js_1.ManagedIdentityCredential(managedIdentityClientOptions);
60
- }
61
- // We may be able to return a UnavailableCredential here, but that may be a breaking change
62
- return new index_js_1.ManagedIdentityCredential(options);
63
- }
64
- /**
65
- * Creates a {@link WorkloadIdentityCredential} from the provided options.
66
- * @param options - Options to configure the credential.
67
- *
68
- * @internal
69
- */
70
- function createDefaultWorkloadIdentityCredential(options) {
71
- const managedIdentityClientId = options?.managedIdentityClientId ??
72
- process.env.AZURE_CLIENT_ID;
73
- const workloadIdentityClientId = options?.workloadIdentityClientId ??
74
- managedIdentityClientId;
75
- const workloadFile = process.env.AZURE_FEDERATED_TOKEN_FILE;
76
- const tenantId = options?.tenantId ?? process.env.AZURE_TENANT_ID;
77
- if (workloadFile && workloadIdentityClientId) {
78
- const workloadIdentityCredentialOptions = {
79
- ...options,
80
- tenantId,
81
- clientId: workloadIdentityClientId,
82
- tokenFilePath: workloadFile,
83
- };
84
- return new workloadIdentityCredential_js_1.WorkloadIdentityCredential(workloadIdentityCredentialOptions);
85
- }
86
- if (tenantId) {
87
- const workloadIdentityClientTenantOptions = {
88
- ...options,
89
- tenantId,
90
- };
91
- return new workloadIdentityCredential_js_1.WorkloadIdentityCredential(workloadIdentityClientTenantOptions);
92
- }
93
- // We may be able to return a UnavailableCredential here, but that may be a breaking change
94
- return new workloadIdentityCredential_js_1.WorkloadIdentityCredential(options);
95
- }
96
- /**
97
- * Creates a {@link AzureDeveloperCliCredential} from the provided options.
98
- * @param options - Options to configure the credential.
99
- *
100
- * @internal
101
- */
102
- function createDefaultAzureDeveloperCliCredential(options = {}) {
103
- const processTimeoutInMs = options.processTimeoutInMs;
104
- return new azureDeveloperCliCredential_js_1.AzureDeveloperCliCredential({ processTimeoutInMs, ...options });
105
- }
106
- /**
107
- * Creates a {@link AzureCliCredential} from the provided options.
108
- * @param options - Options to configure the credential.
109
- *
110
- * @internal
111
- */
112
- function createDefaultAzureCliCredential(options = {}) {
113
- const processTimeoutInMs = options.processTimeoutInMs;
114
- return new azureCliCredential_js_1.AzureCliCredential({ processTimeoutInMs, ...options });
115
- }
116
- /**
117
- * Creates a {@link AzurePowerShellCredential} from the provided options.
118
- * @param options - Options to configure the credential.
119
- *
120
- * @internal
121
- */
122
- function createDefaultAzurePowershellCredential(options = {}) {
123
- const processTimeoutInMs = options.processTimeoutInMs;
124
- return new azurePowerShellCredential_js_1.AzurePowerShellCredential({ processTimeoutInMs, ...options });
125
- }
126
- /**
127
- * Creates a BrokerCredential instance with the provided options.
128
- * This credential uses the Windows Authentication Manager (WAM) broker for authentication.
129
- * It will only attempt to authenticate silently using the default broker account
130
- *
131
- * @param options - Options for configuring the credential.
132
- *
133
- * @internal
134
- */
135
- function createDefaultBrokerCredential(options = {}) {
136
- return new brokerCredential_js_1.BrokerCredential(options);
137
- }
138
- /**
139
- * Creates an {@link EnvironmentCredential} from the provided options.
140
- * @param options - Options to configure the credential.
141
- *
142
- * @internal
143
- */
144
- function createEnvironmentCredential(options = {}) {
145
- return new environmentCredential_js_1.EnvironmentCredential(options);
146
- }
147
- /**
148
- * Creates a {@link VisualStudioCodeCredential} from the provided options.
149
- * @param options - Options to configure the credential.
150
- *
151
- * @internal
152
- */
153
- function createDefaultVisualStudioCodeCredential(options = {}) {
154
- return new visualStudioCodeCredential_js_1.VisualStudioCodeCredential(options);
155
- }
156
10
  /**
157
11
  * A no-op credential that logs the reason it was skipped if getToken is called.
158
12
  * @internal
@@ -180,13 +34,24 @@ exports.UnavailableDefaultCredential = UnavailableDefaultCredential;
180
34
  * - {@link EnvironmentCredential}
181
35
  * - {@link WorkloadIdentityCredential}
182
36
  * - {@link ManagedIdentityCredential}
37
+ * - {@link VisualStudioCodeCredential}
183
38
  * - {@link AzureCliCredential}
184
39
  * - {@link AzurePowerShellCredential}
185
40
  * - {@link AzureDeveloperCliCredential}
186
- * - {@link VisualStudioCodeCredential}
187
41
  *
188
42
  * Consult the documentation of these credential types for more information
189
43
  * on how they attempt authentication.
44
+ *
45
+ * Selecting credentials
46
+ *
47
+ * Set environment variable AZURE_TOKEN_CREDENTIALS to select a subset of the credential chain.
48
+ * DefaultAzureCredential will try only the specified credential(s), but its other behavior remains the same.
49
+ * Valid values for AZURE_TOKEN_CREDENTIALS are the name of any single type in the above chain, for example
50
+ * "EnvironmentCredential" or "AzureCliCredential", and these special values:
51
+ *
52
+ * - "dev": try [VisualStudioCodeCredential], [AzureCliCredential], [AzurePowerShellCredential] and [AzureDeveloperCliCredential], in that order
53
+ * - "prod": try [EnvironmentCredential], [WorkloadIdentityCredential], and [ManagedIdentityCredential], in that order
54
+ *
190
55
  */
191
56
  class DefaultAzureCredential extends chainedTokenCredential_js_1.ChainedTokenCredential {
192
57
  constructor(options) {
@@ -195,34 +60,54 @@ class DefaultAzureCredential extends chainedTokenCredential_js_1.ChainedTokenCre
195
60
  ? process.env.AZURE_TOKEN_CREDENTIALS.trim().toLowerCase()
196
61
  : undefined;
197
62
  const devCredentialFunctions = [
198
- createDefaultVisualStudioCodeCredential,
199
- createDefaultAzureCliCredential,
200
- createDefaultAzurePowershellCredential,
201
- createDefaultAzureDeveloperCliCredential,
202
- createDefaultBrokerCredential,
63
+ defaultAzureCredentialFunctions_js_1.createDefaultVisualStudioCodeCredential,
64
+ defaultAzureCredentialFunctions_js_1.createDefaultAzureCliCredential,
65
+ defaultAzureCredentialFunctions_js_1.createDefaultAzurePowershellCredential,
66
+ defaultAzureCredentialFunctions_js_1.createDefaultAzureDeveloperCliCredential,
67
+ defaultAzureCredentialFunctions_js_1.createDefaultBrokerCredential,
203
68
  ];
204
69
  const prodCredentialFunctions = [
205
- createEnvironmentCredential,
206
- createDefaultWorkloadIdentityCredential,
207
- createDefaultManagedIdentityCredential,
70
+ defaultAzureCredentialFunctions_js_1.createDefaultEnvironmentCredential,
71
+ defaultAzureCredentialFunctions_js_1.createDefaultWorkloadIdentityCredential,
72
+ defaultAzureCredentialFunctions_js_1.createDefaultManagedIdentityCredential,
208
73
  ];
209
74
  let credentialFunctions = [];
75
+ const validCredentialNames = "EnvironmentCredential, WorkloadIdentityCredential, ManagedIdentityCredential, VisualStudioCodeCredential, AzureCliCredential, AzurePowerShellCredential, AzureDeveloperCliCredential";
210
76
  // If AZURE_TOKEN_CREDENTIALS is set, use it to determine which credentials to use.
211
- // The value of AZURE_TOKEN_CREDENTIALS should be either "dev" or "prod".
77
+ // The value of AZURE_TOKEN_CREDENTIALS should be either "dev" or "prod" or any one of these credentials - {validCredentialNames}.
212
78
  if (azureTokenCredentials) {
213
79
  switch (azureTokenCredentials) {
214
80
  case "dev":
215
- // If AZURE_TOKEN_CREDENTIALS is set to "dev", use the developer tool-based credential chain.
216
81
  credentialFunctions = devCredentialFunctions;
217
82
  break;
218
83
  case "prod":
219
- // If AZURE_TOKEN_CREDENTIALS is set to "prod", use the production credential chain.
220
84
  credentialFunctions = prodCredentialFunctions;
221
85
  break;
86
+ case "environmentcredential":
87
+ credentialFunctions = [defaultAzureCredentialFunctions_js_1.createDefaultEnvironmentCredential];
88
+ break;
89
+ case "workloadidentitycredential":
90
+ credentialFunctions = [defaultAzureCredentialFunctions_js_1.createDefaultWorkloadIdentityCredential];
91
+ break;
92
+ case "managedidentitycredential":
93
+ credentialFunctions = [defaultAzureCredentialFunctions_js_1.createDefaultManagedIdentityCredential];
94
+ break;
95
+ case "visualstudiocodecredential":
96
+ credentialFunctions = [defaultAzureCredentialFunctions_js_1.createDefaultVisualStudioCodeCredential];
97
+ break;
98
+ case "azureclicredential":
99
+ credentialFunctions = [defaultAzureCredentialFunctions_js_1.createDefaultAzureCliCredential];
100
+ break;
101
+ case "azurepowershellcredential":
102
+ credentialFunctions = [defaultAzureCredentialFunctions_js_1.createDefaultAzurePowershellCredential];
103
+ break;
104
+ case "azuredeveloperclicredential":
105
+ credentialFunctions = [defaultAzureCredentialFunctions_js_1.createDefaultAzureDeveloperCliCredential];
106
+ break;
222
107
  default: {
223
108
  // If AZURE_TOKEN_CREDENTIALS is set to an unsupported value, throw an error.
224
- // We will throw an error here to prevent the creation of the DefaultAzureCredential.
225
- const errorMessage = `Invalid value for AZURE_TOKEN_CREDENTIALS = ${process.env.AZURE_TOKEN_CREDENTIALS}. Valid values are 'prod' or 'dev'.`;
109
+ // This will prevent the creation of the DefaultAzureCredential.
110
+ const errorMessage = `Invalid value for AZURE_TOKEN_CREDENTIALS = ${process.env.AZURE_TOKEN_CREDENTIALS}. Valid values are 'prod' or 'dev' or any of these credentials - ${validCredentialNames}.`;
226
111
  logger.warning(errorMessage);
227
112
  throw new Error(errorMessage);
228
113
  }
@@ -1 +1 @@
1
- {"version":3,"file":"defaultAzureCredential.js","sourceRoot":"","sources":["../../../src/credentials/defaultAzureCredential.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAiClC,wFAmDC;AAwFD,sEAIC;AAQD,kEAIC;AAQD,0FAIC;AA7LD,mEAAiF;AAEjF,mEAA6D;AAC7D,qFAA+E;AAC/E,iFAA2E;AAC3E,2EAAqE;AACrE,yEAAmE;AAEnE,mFAA6E;AAE7E,mDAAsD;AACtD,mFAA6E;AAC7E,+DAAyD;AAEzD,MAAM,MAAM,GAAG,IAAA,6BAAgB,EAAC,wBAAwB,CAAC,CAAC;AAE1D;;;;;GAKG;AACH,SAAgB,sCAAsC,CACpD,UAG4C,EAAE;IAE9C,OAAO,CAAC,YAAY,KAAK;QACvB,UAAU,EAAE,CAAC;QACb,cAAc,EAAE,GAAG;KACpB,CAAC;IACF,MAAM,uBAAuB,GAC1B,OAAiD,EAAE,uBAAuB;QAC3E,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC;IAC9B,MAAM,wBAAwB,GAC3B,OAAiD,EAAE,wBAAwB;QAC5E,uBAAuB,CAAC;IAC1B,MAAM,iBAAiB,GAAI,OAAmD;QAC5E,EAAE,yBAAyB,CAAC;IAC9B,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,0BAA0B,CAAC;IAC5D,MAAM,QAAQ,GAAG,OAAO,EAAE,QAAQ,IAAI,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC;IAClE,IAAI,iBAAiB,EAAE,CAAC;QACtB,MAAM,gCAAgC,GAA+C;YACnF,GAAG,OAAO;YACV,UAAU,EAAE,iBAAiB;SAC9B,CAAC;QACF,OAAO,IAAI,oCAAyB,CAAC,gCAAgC,CAAC,CAAC;IACzE,CAAC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K,CAAC,YAAY,CAAC,CAAC;gBAChC,CAAC;YACH,CAAC;QACH,CAAC;aAAM,CAAC;YACN,2EAA2E;YAC3E,mBAAmB,GAAG,CAAC,GAAG,uBAAuB,EAAE,GAAG,sBAAsB,CAAC,CAAC;QAChF,CAAC;QAED,gLAAgL;QAChL,8DAA8D;QAC9D,6DAA6D;QAC7D,gEAAgE;QAChE,sHAAsH;QACtH,MAAM,WAAW,GAAsB,mBAAmB,CAAC,GAAG,CAAC,CAAC,kBAAkB,EAAE,EAAE;YACpF,IAAI,CAAC;gBACH,OAAO,kBAAkB,CAAC,OAAO,CAAC,CAAC;YACrC,CAAC;YAAC,OAAO,GAAQ,EAAE,CAAC;gBAClB,MAAM,CAAC,OAAO,CACZ,WAAW,kBAAkB,CAAC,IAAI,iDAAiD,GAAG,EAAE,CACzF,CAAC;gBACF,OAAO,IAAI,4BAA4B,CAAC,kBAAkB,CAAC,IAAI,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;YAChF,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,KAAK,CAAC,GAAG,WAAW,CAAC,CAAC;IACxB,CAAC;CACF;AAnFD,wDAmFC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type {\n DefaultAzureCredentialClientIdOptions,\n DefaultAzureCredentialOptions,\n DefaultAzureCredentialResourceIdOptions,\n} from \"./defaultAzureCredentialOptions.js\";\nimport type {\n ManagedIdentityCredentialClientIdOptions,\n ManagedIdentityCredentialResourceIdOptions,\n} from \"./managedIdentityCredential/options.js\";\nimport { ManagedIdentityCredential } from \"./managedIdentityCredential/index.js\";\n\nimport { AzureCliCredential } from \"./azureCliCredential.js\";\nimport { AzureDeveloperCliCredential } from \"./azureDeveloperCliCredential.js\";\nimport { AzurePowerShellCredential } from \"./azurePowerShellCredential.js\";\nimport { ChainedTokenCredential } from \"./chainedTokenCredential.js\";\nimport { EnvironmentCredential } from \"./environmentCredential.js\";\nimport type { TokenCredential } from \"@azure/core-auth\";\nimport { WorkloadIdentityCredential } from \"./workloadIdentityCredential.js\";\nimport type { WorkloadIdentityCredentialOptions } from \"./workloadIdentityCredentialOptions.js\";\nimport { credentialLogger } from \"../util/logging.js\";\nimport { VisualStudioCodeCredential } from \"./visualStudioCodeCredential.js\";\nimport { BrokerCredential } from \"./brokerCredential.js\";\n\nconst logger = credentialLogger(\"DefaultAzureCredential\");\n\n/**\n * Creates a {@link ManagedIdentityCredential} from the provided options.\n * @param options - Options to configure the credential.\n *\n * @internal\n */\nexport function createDefaultManagedIdentityCredential(\n options:\n | DefaultAzureCredentialOptions\n | DefaultAzureCredentialResourceIdOptions\n | DefaultAzureCredentialClientIdOptions = {},\n): TokenCredential {\n options.retryOptions ??= {\n maxRetries: 5,\n retryDelayInMs: 800,\n };\n const managedIdentityClientId =\n (options as DefaultAzureCredentialClientIdOptions)?.managedIdentityClientId ??\n process.env.AZURE_CLIENT_ID;\n const workloadIdentityClientId =\n (options as DefaultAzureCredentialClientIdOptions)?.workloadIdentityClientId ??\n managedIdentityClientId;\n const managedResourceId = (options as DefaultAzureCredentialResourceIdOptions)\n ?.managedIdentityResourceId;\n const workloadFile = process.env.AZURE_FEDERATED_TOKEN_FILE;\n const tenantId = options?.tenantId ?? process.env.AZURE_TENANT_ID;\n if (managedResourceId) {\n const managedIdentityResourceIdOptions: ManagedIdentityCredentialResourceIdOptions = {\n ...options,\n resourceId: managedResourceId,\n };\n return new ManagedIdentityCredential(managedIdentityResourceIdOptions);\n }\n\n if (workloadFile && workloadIdentityClientId) {\n const workloadIdentityCredentialOptions: DefaultAzureCredentialOptions = {\n ...options,\n tenantId: tenantId,\n };\n\n return new ManagedIdentityCredential(\n workloadIdentityClientId,\n workloadIdentityCredentialOptions,\n );\n }\n\n if (managedIdentityClientId) {\n const managedIdentityClientOptions: ManagedIdentityCredentialClientIdOptions = {\n ...options,\n clientId: managedIdentityClientId,\n };\n\n return new ManagedIdentityCredential(managedIdentityClientOptions);\n }\n\n // We may be able to return a UnavailableCredential here, but that may be a breaking change\n return new ManagedIdentityCredential(options);\n}\n\n/**\n * Creates a {@link WorkloadIdentityCredential} from the provided options.\n * @param options - Options to configure the credential.\n *\n * @internal\n */\nfunction createDefaultWorkloadIdentityCredential(\n options?: DefaultAzureCredentialOptions | DefaultAzureCredentialClientIdOptions,\n): TokenCredential {\n const managedIdentityClientId =\n (options as DefaultAzureCredentialClientIdOptions)?.managedIdentityClientId ??\n process.env.AZURE_CLIENT_ID;\n const workloadIdentityClientId =\n (options as DefaultAzureCredentialClientIdOptions)?.workloadIdentityClientId ??\n managedIdentityClientId;\n const workloadFile = process.env.AZURE_FEDERATED_TOKEN_FILE;\n const tenantId = options?.tenantId ?? process.env.AZURE_TENANT_ID;\n if (workloadFile && workloadIdentityClientId) {\n const workloadIdentityCredentialOptions: WorkloadIdentityCredentialOptions = {\n ...options,\n tenantId,\n clientId: workloadIdentityClientId,\n tokenFilePath: workloadFile,\n };\n return new WorkloadIdentityCredential(workloadIdentityCredentialOptions);\n }\n if (tenantId) {\n const workloadIdentityClientTenantOptions: WorkloadIdentityCredentialOptions = {\n ...options,\n tenantId,\n };\n return new WorkloadIdentityCredential(workloadIdentityClientTenantOptions);\n }\n\n // We may be able to return a UnavailableCredential here, but that may be a breaking change\n return new WorkloadIdentityCredential(options);\n}\n\n/**\n * Creates a {@link AzureDeveloperCliCredential} from the provided options.\n * @param options - Options to configure the credential.\n *\n * @internal\n */\nfunction createDefaultAzureDeveloperCliCredential(\n options: DefaultAzureCredentialOptions = {},\n): TokenCredential {\n const processTimeoutInMs = options.processTimeoutInMs;\n return new AzureDeveloperCliCredential({ processTimeoutInMs, ...options });\n}\n\n/**\n * Creates a {@link AzureCliCredential} from the provided options.\n * @param options - Options to configure the credential.\n *\n * @internal\n */\nfunction createDefaultAzureCliCredential(\n options: DefaultAzureCredentialOptions = {},\n): TokenCredential {\n const processTimeoutInMs = options.processTimeoutInMs;\n return new AzureCliCredential({ processTimeoutInMs, ...options });\n}\n\n/**\n * Creates a {@link AzurePowerShellCredential} from the provided options.\n * @param options - Options to configure the credential.\n *\n * @internal\n */\nfunction createDefaultAzurePowershellCredential(\n options: DefaultAzureCredentialOptions = {},\n): TokenCredential {\n const processTimeoutInMs = options.processTimeoutInMs;\n return new AzurePowerShellCredential({ processTimeoutInMs, ...options });\n}\n\n/**\n * Creates a BrokerCredential instance with the provided options.\n * This credential uses the Windows Authentication Manager (WAM) broker for authentication.\n * It will only attempt to authenticate silently using the default broker account\n *\n * @param options - Options for configuring the credential.\n *\n * @internal\n */\nexport function createDefaultBrokerCredential(\n options: DefaultAzureCredentialOptions = {},\n): TokenCredential {\n return new BrokerCredential(options);\n}\n\n/**\n * Creates an {@link EnvironmentCredential} from the provided options.\n * @param options - Options to configure the credential.\n *\n * @internal\n */\nexport function createEnvironmentCredential(\n options: DefaultAzureCredentialOptions = {},\n): TokenCredential {\n return new EnvironmentCredential(options);\n}\n\n/**\n * Creates a {@link VisualStudioCodeCredential} from the provided options.\n * @param options - Options to configure the credential.\n *\n * @internal\n */\nexport function createDefaultVisualStudioCodeCredential(\n options: DefaultAzureCredentialOptions = {},\n): TokenCredential {\n return new VisualStudioCodeCredential(options);\n}\n\n/**\n * A no-op credential that logs the reason it was skipped if getToken is called.\n * @internal\n */\nexport class UnavailableDefaultCredential implements TokenCredential {\n credentialUnavailableErrorMessage: string;\n credentialName: string;\n\n constructor(credentialName: string, message: string) {\n this.credentialName = credentialName;\n this.credentialUnavailableErrorMessage = message;\n }\n\n getToken(): Promise<null> {\n logger.getToken.info(\n `Skipping ${this.credentialName}, reason: ${this.credentialUnavailableErrorMessage}`,\n );\n return Promise.resolve(null);\n }\n}\n\n/**\n * Provides a default {@link ChainedTokenCredential} configuration that works for most\n * applications that use Azure SDK client libraries. For more information, see\n * [DefaultAzureCredential overview](https://aka.ms/azsdk/js/identity/credential-chains#use-defaultazurecredential-for-flexibility).\n *\n * The following credential types will be tried, in order:\n *\n * - {@link EnvironmentCredential}\n * - {@link WorkloadIdentityCredential}\n * - {@link ManagedIdentityCredential}\n * - {@link AzureCliCredential}\n * - {@link AzurePowerShellCredential}\n * - {@link AzureDeveloperCliCredential}\n * - {@link VisualStudioCodeCredential}\n *\n * Consult the documentation of these credential types for more information\n * on how they attempt authentication.\n */\nexport class DefaultAzureCredential extends ChainedTokenCredential {\n /**\n * Creates an instance of the DefaultAzureCredential class with {@link DefaultAzureCredentialClientIdOptions}.\n *\n * @param options - Optional parameters. See {@link DefaultAzureCredentialClientIdOptions}.\n */\n constructor(options?: DefaultAzureCredentialClientIdOptions);\n\n /**\n * Creates an instance of the DefaultAzureCredential class with {@link DefaultAzureCredentialResourceIdOptions}.\n *\n * @param options - Optional parameters. See {@link DefaultAzureCredentialResourceIdOptions}.\n */\n constructor(options?: DefaultAzureCredentialResourceIdOptions);\n\n /**\n * Creates an instance of the DefaultAzureCredential class with {@link DefaultAzureCredentialOptions}.\n *\n * @param options - Optional parameters. See {@link DefaultAzureCredentialOptions}.\n */\n constructor(options?: DefaultAzureCredentialOptions);\n\n constructor(options?: DefaultAzureCredentialOptions) {\n // If AZURE_TOKEN_CREDENTIALS is not set, use the default credential chain.\n const azureTokenCredentials = process.env.AZURE_TOKEN_CREDENTIALS\n ? process.env.AZURE_TOKEN_CREDENTIALS.trim().toLowerCase()\n : undefined;\n const devCredentialFunctions = [\n createDefaultVisualStudioCodeCredential,\n createDefaultAzureCliCredential,\n createDefaultAzurePowershellCredential,\n createDefaultAzureDeveloperCliCredential,\n createDefaultBrokerCredential,\n ];\n const prodCredentialFunctions = [\n createEnvironmentCredential,\n createDefaultWorkloadIdentityCredential,\n createDefaultManagedIdentityCredential,\n ];\n let credentialFunctions = [];\n // If AZURE_TOKEN_CREDENTIALS is set, use it to determine which credentials to use.\n // The value of AZURE_TOKEN_CREDENTIALS should be either \"dev\" or \"prod\".\n if (azureTokenCredentials) {\n switch (azureTokenCredentials) {\n case \"dev\":\n // If AZURE_TOKEN_CREDENTIALS is set to \"dev\", use the developer tool-based credential chain.\n credentialFunctions = devCredentialFunctions;\n break;\n case \"prod\":\n // If AZURE_TOKEN_CREDENTIALS is set to \"prod\", use the production credential chain.\n credentialFunctions = prodCredentialFunctions;\n break;\n default: {\n // If AZURE_TOKEN_CREDENTIALS is set to an unsupported value, throw an error.\n // We will throw an error here to prevent the creation of the DefaultAzureCredential.\n const errorMessage = `Invalid value for AZURE_TOKEN_CREDENTIALS = ${process.env.AZURE_TOKEN_CREDENTIALS}. Valid values are 'prod' or 'dev'.`;\n logger.warning(errorMessage);\n throw new Error(errorMessage);\n }\n }\n } else {\n // If AZURE_TOKEN_CREDENTIALS is not set, use the default credential chain.\n credentialFunctions = [...prodCredentialFunctions, ...devCredentialFunctions];\n }\n\n // Errors from individual credentials should not be thrown in the DefaultAzureCredential constructor, instead throwing on getToken() which is handled by ChainedTokenCredential.\n // When adding new credentials to the default chain, consider:\n // 1. Making the constructor parameters required and explicit\n // 2. Validating any required parameters in the factory function\n // 3. Returning a UnavailableDefaultCredential from the factory function if a credential is unavailable for any reason\n const credentials: TokenCredential[] = credentialFunctions.map((createCredentialFn) => {\n try {\n return createCredentialFn(options);\n } catch (err: any) {\n logger.warning(\n `Skipped ${createCredentialFn.name} because of an error creating the credential: ${err}`,\n );\n return new UnavailableDefaultCredential(createCredentialFn.name, err.message);\n }\n });\n\n super(...credentials);\n }\n}\n"]}
1
+ {"version":3,"file":"defaultAzureCredential.js","sourceRoot":"","sources":["../../../src/credentials/defaultAzureCredential.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAalC,2EAAqE;AAIrE,mDAAsD;AACtD,6FAS8C;AAE9C,MAAM,MAAM,GAAG,IAAA,6BAAgB,EAAC,wBAAwB,CAAC,CAAC;AAE1D;;;GAGG;AACH,MAAa,4BAA4B;IACvC,iCAAiC,CAAS;IAC1C,cAAc,CAAS;IAEvB,YAAY,cAAsB,EAAE,OAAe;QACjD,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,IAAI,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CAAC,CAAC;YAChF,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,KAAK,CAAC,GAAG,WAAW,CAAC,CAAC;IACxB,CAAC;CACF;AAxGD,wDAwGC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type {\n DefaultAzureCredentialClientIdOptions,\n DefaultAzureCredentialOptions,\n DefaultAzureCredentialResourceIdOptions,\n} from \"./defaultAzureCredentialOptions.js\";\n\nimport { ManagedIdentityCredential } from \"./managedIdentityCredential/index.js\";\nimport { VisualStudioCodeCredential } from \"./visualStudioCodeCredential.js\";\nimport { AzureCliCredential } from \"./azureCliCredential.js\";\nimport { AzureDeveloperCliCredential } from \"./azureDeveloperCliCredential.js\";\nimport { AzurePowerShellCredential } from \"./azurePowerShellCredential.js\";\nimport { ChainedTokenCredential } from \"./chainedTokenCredential.js\";\nimport { EnvironmentCredential } from \"./environmentCredential.js\";\nimport type { TokenCredential } from \"@azure/core-auth\";\nimport { WorkloadIdentityCredential } from \"./workloadIdentityCredential.js\";\nimport { credentialLogger } from \"../util/logging.js\";\nimport {\n createDefaultAzureCliCredential,\n createDefaultAzureDeveloperCliCredential,\n createDefaultAzurePowershellCredential,\n createDefaultBrokerCredential,\n createDefaultManagedIdentityCredential,\n createDefaultVisualStudioCodeCredential,\n createDefaultWorkloadIdentityCredential,\n createDefaultEnvironmentCredential,\n} from \"./defaultAzureCredentialFunctions.js\";\n\nconst logger = credentialLogger(\"DefaultAzureCredential\");\n\n/**\n * A no-op credential that logs the reason it was skipped if getToken is called.\n * @internal\n */\nexport class UnavailableDefaultCredential implements TokenCredential {\n credentialUnavailableErrorMessage: string;\n credentialName: string;\n\n constructor(credentialName: string, message: string) {\n this.credentialName = credentialName;\n this.credentialUnavailableErrorMessage = message;\n }\n\n getToken(): Promise<null> {\n logger.getToken.info(\n `Skipping ${this.credentialName}, reason: ${this.credentialUnavailableErrorMessage}`,\n );\n return Promise.resolve(null);\n }\n}\n\n/**\n * Provides a default {@link ChainedTokenCredential} configuration that works for most\n * applications that use Azure SDK client libraries. For more information, see\n * [DefaultAzureCredential overview](https://aka.ms/azsdk/js/identity/credential-chains#use-defaultazurecredential-for-flexibility).\n *\n * The following credential types will be tried, in order:\n *\n * - {@link EnvironmentCredential}\n * - {@link WorkloadIdentityCredential}\n * - {@link ManagedIdentityCredential}\n * - {@link VisualStudioCodeCredential}\n * - {@link AzureCliCredential}\n * - {@link AzurePowerShellCredential}\n * - {@link AzureDeveloperCliCredential}\n *\n * Consult the documentation of these credential types for more information\n * on how they attempt authentication.\n *\n * Selecting credentials\n *\n * Set environment variable AZURE_TOKEN_CREDENTIALS to select a subset of the credential chain.\n * DefaultAzureCredential will try only the specified credential(s), but its other behavior remains the same.\n * Valid values for AZURE_TOKEN_CREDENTIALS are the name of any single type in the above chain, for example\n * \"EnvironmentCredential\" or \"AzureCliCredential\", and these special values:\n *\n * - \"dev\": try [VisualStudioCodeCredential], [AzureCliCredential], [AzurePowerShellCredential] and [AzureDeveloperCliCredential], in that order\n * - \"prod\": try [EnvironmentCredential], [WorkloadIdentityCredential], and [ManagedIdentityCredential], in that order\n *\n */\nexport class DefaultAzureCredential extends ChainedTokenCredential {\n /**\n * Creates an instance of the DefaultAzureCredential class with {@link DefaultAzureCredentialClientIdOptions}.\n *\n * @param options - Optional parameters. See {@link DefaultAzureCredentialClientIdOptions}.\n */\n constructor(options?: DefaultAzureCredentialClientIdOptions);\n\n /**\n * Creates an instance of the DefaultAzureCredential class with {@link DefaultAzureCredentialResourceIdOptions}.\n *\n * @param options - Optional parameters. See {@link DefaultAzureCredentialResourceIdOptions}.\n */\n constructor(options?: DefaultAzureCredentialResourceIdOptions);\n\n /**\n * Creates an instance of the DefaultAzureCredential class with {@link DefaultAzureCredentialOptions}.\n *\n * @param options - Optional parameters. See {@link DefaultAzureCredentialOptions}.\n */\n constructor(options?: DefaultAzureCredentialOptions);\n\n constructor(options?: DefaultAzureCredentialOptions) {\n // If AZURE_TOKEN_CREDENTIALS is not set, use the default credential chain.\n const azureTokenCredentials = process.env.AZURE_TOKEN_CREDENTIALS\n ? process.env.AZURE_TOKEN_CREDENTIALS.trim().toLowerCase()\n : undefined;\n const devCredentialFunctions = [\n createDefaultVisualStudioCodeCredential,\n createDefaultAzureCliCredential,\n createDefaultAzurePowershellCredential,\n createDefaultAzureDeveloperCliCredential,\n createDefaultBrokerCredential,\n ];\n const prodCredentialFunctions = [\n createDefaultEnvironmentCredential,\n createDefaultWorkloadIdentityCredential,\n createDefaultManagedIdentityCredential,\n ];\n let credentialFunctions = [];\n const validCredentialNames =\n \"EnvironmentCredential, WorkloadIdentityCredential, ManagedIdentityCredential, VisualStudioCodeCredential, AzureCliCredential, AzurePowerShellCredential, AzureDeveloperCliCredential\";\n // If AZURE_TOKEN_CREDENTIALS is set, use it to determine which credentials to use.\n // The value of AZURE_TOKEN_CREDENTIALS should be either \"dev\" or \"prod\" or any one of these credentials - {validCredentialNames}.\n if (azureTokenCredentials) {\n switch (azureTokenCredentials) {\n case \"dev\":\n credentialFunctions = devCredentialFunctions;\n break;\n case \"prod\":\n credentialFunctions = prodCredentialFunctions;\n break;\n case \"environmentcredential\":\n credentialFunctions = [createDefaultEnvironmentCredential];\n break;\n case \"workloadidentitycredential\":\n credentialFunctions = [createDefaultWorkloadIdentityCredential];\n break;\n case \"managedidentitycredential\":\n credentialFunctions = [createDefaultManagedIdentityCredential];\n break;\n case \"visualstudiocodecredential\":\n credentialFunctions = [createDefaultVisualStudioCodeCredential];\n break;\n case \"azureclicredential\":\n credentialFunctions = [createDefaultAzureCliCredential];\n break;\n case \"azurepowershellcredential\":\n credentialFunctions = [createDefaultAzurePowershellCredential];\n break;\n case \"azuredeveloperclicredential\":\n credentialFunctions = [createDefaultAzureDeveloperCliCredential];\n break;\n default: {\n // If AZURE_TOKEN_CREDENTIALS is set to an unsupported value, throw an error.\n // This will prevent the creation of the DefaultAzureCredential.\n const errorMessage = `Invalid value for AZURE_TOKEN_CREDENTIALS = ${process.env.AZURE_TOKEN_CREDENTIALS}. Valid values are 'prod' or 'dev' or any of these credentials - ${validCredentialNames}.`;\n logger.warning(errorMessage);\n throw new Error(errorMessage);\n }\n }\n } else {\n // If AZURE_TOKEN_CREDENTIALS is not set, use the default credential chain.\n credentialFunctions = [...prodCredentialFunctions, ...devCredentialFunctions];\n }\n\n // Errors from individual credentials should not be thrown in the DefaultAzureCredential constructor, instead throwing on getToken() which is handled by ChainedTokenCredential.\n // When adding new credentials to the default chain, consider:\n // 1. Making the constructor parameters required and explicit\n // 2. Validating any required parameters in the factory function\n // 3. Returning a UnavailableDefaultCredential from the factory function if a credential is unavailable for any reason\n const credentials: TokenCredential[] = credentialFunctions.map((createCredentialFn) => {\n try {\n return createCredentialFn(options);\n } catch (err: any) {\n logger.warning(\n `Skipped ${createCredentialFn.name} because of an error creating the credential: ${err}`,\n );\n return new UnavailableDefaultCredential(createCredentialFn.name, err.message);\n }\n });\n\n super(...credentials);\n }\n}\n"]}
@@ -0,0 +1,62 @@
1
+ import type { TokenCredential } from "@azure/core-auth";
2
+ import type { DefaultAzureCredentialClientIdOptions, DefaultAzureCredentialOptions, DefaultAzureCredentialResourceIdOptions } from "./defaultAzureCredentialOptions.js";
3
+ /**
4
+ * Creates a {@link BrokerCredential} instance with the provided options.
5
+ * This credential uses the Windows Authentication Manager (WAM) broker for authentication.
6
+ * It will only attempt to authenticate silently using the default broker account
7
+ *
8
+ * @param options - Options for configuring the credential.
9
+ *
10
+ * @internal
11
+ */
12
+ export declare function createDefaultBrokerCredential(options?: DefaultAzureCredentialOptions): TokenCredential;
13
+ /**
14
+ * Creates a {@link VisualStudioCodeCredential} from the provided options.
15
+ * @param options - Options to configure the credential.
16
+ *
17
+ * @internal
18
+ */
19
+ export declare function createDefaultVisualStudioCodeCredential(options?: DefaultAzureCredentialOptions): TokenCredential;
20
+ /**
21
+ * Creates a {@link ManagedIdentityCredential} from the provided options.
22
+ * @param options - Options to configure the credential.
23
+ *
24
+ * @internal
25
+ */
26
+ export declare function createDefaultManagedIdentityCredential(options?: DefaultAzureCredentialOptions | DefaultAzureCredentialResourceIdOptions | DefaultAzureCredentialClientIdOptions): TokenCredential;
27
+ /**
28
+ * Creates a {@link WorkloadIdentityCredential} from the provided options.
29
+ * @param options - Options to configure the credential.
30
+ *
31
+ * @internal
32
+ */
33
+ export declare function createDefaultWorkloadIdentityCredential(options?: DefaultAzureCredentialOptions | DefaultAzureCredentialClientIdOptions): TokenCredential;
34
+ /**
35
+ * Creates a {@link AzureDeveloperCliCredential} from the provided options.
36
+ * @param options - Options to configure the credential.
37
+ *
38
+ * @internal
39
+ */
40
+ export declare function createDefaultAzureDeveloperCliCredential(options?: DefaultAzureCredentialOptions): TokenCredential;
41
+ /**
42
+ * Creates a {@link AzureCliCredential} from the provided options.
43
+ * @param options - Options to configure the credential.
44
+ *
45
+ * @internal
46
+ */
47
+ export declare function createDefaultAzureCliCredential(options?: DefaultAzureCredentialOptions): TokenCredential;
48
+ /**
49
+ * Creates a {@link AzurePowerShellCredential} from the provided options.
50
+ * @param options - Options to configure the credential.
51
+ *
52
+ * @internal
53
+ */
54
+ export declare function createDefaultAzurePowershellCredential(options?: DefaultAzureCredentialOptions): TokenCredential;
55
+ /**
56
+ * Creates an {@link EnvironmentCredential} from the provided options.
57
+ * @param options - Options to configure the credential.
58
+ *
59
+ * @internal
60
+ */
61
+ export declare function createDefaultEnvironmentCredential(options?: DefaultAzureCredentialOptions): TokenCredential;
62
+ //# sourceMappingURL=defaultAzureCredentialFunctions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaultAzureCredentialFunctions.d.ts","sourceRoot":"","sources":["../../../src/credentials/defaultAzureCredentialFunctions.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,KAAK,EACV,qCAAqC,EACrC,6BAA6B,EAC7B,uCAAuC,EACxC,MAAM,oCAAoC,CAAC;AAe5C;;;;;;;;GAQG;AACH,wBAAgB,6BAA6B,CAC3C,OAAO,GAAE,6BAAkC,GAC1C,eAAe,CAEjB;AAED;;;;;GAKG;AACH,wBAAgB,uCAAuC,CACrD,OAAO,GAAE,6BAAkC,GAC1C,eAAe,CAEjB;AAED;;;;;GAKG;AACH,wBAAgB,sCAAsC,CACpD,OAAO,GACH,6BAA6B,GAC7B,uCAAuC,GACvC,qCAA0C,GAC7C,eAAe,CA8CjB;AAED;;;;;GAKG;AACH,wBAAgB,uCAAuC,CACrD,OAAO,CAAC,EAAE,6BAA6B,GAAG,qCAAqC,GAC9E,eAAe,CA4BjB;AAED;;;;;GAKG;AACH,wBAAgB,wCAAwC,CACtD,OAAO,GAAE,6BAAkC,GAC1C,eAAe,CAEjB;AAED;;;;;GAKG;AACH,wBAAgB,+BAA+B,CAC7C,OAAO,GAAE,6BAAkC,GAC1C,eAAe,CAEjB;AAED;;;;;GAKG;AACH,wBAAgB,sCAAsC,CACpD,OAAO,GAAE,6BAAkC,GAC1C,eAAe,CAEjB;AAED;;;;;GAKG;AACH,wBAAgB,kCAAkC,CAChD,OAAO,GAAE,6BAAkC,GAC1C,eAAe,CAEjB"}
@@ -0,0 +1,153 @@
1
+ "use strict";
2
+ // Copyright (c) Microsoft Corporation.
3
+ // Licensed under the MIT License.
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.createDefaultBrokerCredential = createDefaultBrokerCredential;
6
+ exports.createDefaultVisualStudioCodeCredential = createDefaultVisualStudioCodeCredential;
7
+ exports.createDefaultManagedIdentityCredential = createDefaultManagedIdentityCredential;
8
+ exports.createDefaultWorkloadIdentityCredential = createDefaultWorkloadIdentityCredential;
9
+ exports.createDefaultAzureDeveloperCliCredential = createDefaultAzureDeveloperCliCredential;
10
+ exports.createDefaultAzureCliCredential = createDefaultAzureCliCredential;
11
+ exports.createDefaultAzurePowershellCredential = createDefaultAzurePowershellCredential;
12
+ exports.createDefaultEnvironmentCredential = createDefaultEnvironmentCredential;
13
+ const environmentCredential_js_1 = require("./environmentCredential.js");
14
+ const index_js_1 = require("./managedIdentityCredential/index.js");
15
+ const workloadIdentityCredential_js_1 = require("./workloadIdentityCredential.js");
16
+ const azureDeveloperCliCredential_js_1 = require("./azureDeveloperCliCredential.js");
17
+ const azureCliCredential_js_1 = require("./azureCliCredential.js");
18
+ const azurePowerShellCredential_js_1 = require("./azurePowerShellCredential.js");
19
+ const visualStudioCodeCredential_js_1 = require("./visualStudioCodeCredential.js");
20
+ const brokerCredential_js_1 = require("./brokerCredential.js");
21
+ /**
22
+ * Creates a {@link BrokerCredential} instance with the provided options.
23
+ * This credential uses the Windows Authentication Manager (WAM) broker for authentication.
24
+ * It will only attempt to authenticate silently using the default broker account
25
+ *
26
+ * @param options - Options for configuring the credential.
27
+ *
28
+ * @internal
29
+ */
30
+ function createDefaultBrokerCredential(options = {}) {
31
+ return new brokerCredential_js_1.BrokerCredential(options);
32
+ }
33
+ /**
34
+ * Creates a {@link VisualStudioCodeCredential} from the provided options.
35
+ * @param options - Options to configure the credential.
36
+ *
37
+ * @internal
38
+ */
39
+ function createDefaultVisualStudioCodeCredential(options = {}) {
40
+ return new visualStudioCodeCredential_js_1.VisualStudioCodeCredential(options);
41
+ }
42
+ /**
43
+ * Creates a {@link ManagedIdentityCredential} from the provided options.
44
+ * @param options - Options to configure the credential.
45
+ *
46
+ * @internal
47
+ */
48
+ function createDefaultManagedIdentityCredential(options = {}) {
49
+ options.retryOptions ??= {
50
+ maxRetries: 5,
51
+ retryDelayInMs: 800,
52
+ };
53
+ const managedIdentityClientId = options?.managedIdentityClientId ??
54
+ process.env.AZURE_CLIENT_ID;
55
+ const workloadIdentityClientId = options?.workloadIdentityClientId ??
56
+ managedIdentityClientId;
57
+ const managedResourceId = options
58
+ ?.managedIdentityResourceId;
59
+ const workloadFile = process.env.AZURE_FEDERATED_TOKEN_FILE;
60
+ const tenantId = options?.tenantId ?? process.env.AZURE_TENANT_ID;
61
+ if (managedResourceId) {
62
+ const managedIdentityResourceIdOptions = {
63
+ ...options,
64
+ resourceId: managedResourceId,
65
+ };
66
+ return new index_js_1.ManagedIdentityCredential(managedIdentityResourceIdOptions);
67
+ }
68
+ if (workloadFile && workloadIdentityClientId) {
69
+ const workloadIdentityCredentialOptions = {
70
+ ...options,
71
+ tenantId: tenantId,
72
+ };
73
+ return new index_js_1.ManagedIdentityCredential(workloadIdentityClientId, workloadIdentityCredentialOptions);
74
+ }
75
+ if (managedIdentityClientId) {
76
+ const managedIdentityClientOptions = {
77
+ ...options,
78
+ clientId: managedIdentityClientId,
79
+ };
80
+ return new index_js_1.ManagedIdentityCredential(managedIdentityClientOptions);
81
+ }
82
+ // We may be able to return a UnavailableCredential here, but that may be a breaking change
83
+ return new index_js_1.ManagedIdentityCredential(options);
84
+ }
85
+ /**
86
+ * Creates a {@link WorkloadIdentityCredential} from the provided options.
87
+ * @param options - Options to configure the credential.
88
+ *
89
+ * @internal
90
+ */
91
+ function createDefaultWorkloadIdentityCredential(options) {
92
+ const managedIdentityClientId = options?.managedIdentityClientId ??
93
+ process.env.AZURE_CLIENT_ID;
94
+ const workloadIdentityClientId = options?.workloadIdentityClientId ??
95
+ managedIdentityClientId;
96
+ const workloadFile = process.env.AZURE_FEDERATED_TOKEN_FILE;
97
+ const tenantId = options?.tenantId ?? process.env.AZURE_TENANT_ID;
98
+ if (workloadFile && workloadIdentityClientId) {
99
+ const workloadIdentityCredentialOptions = {
100
+ ...options,
101
+ tenantId,
102
+ clientId: workloadIdentityClientId,
103
+ tokenFilePath: workloadFile,
104
+ };
105
+ return new workloadIdentityCredential_js_1.WorkloadIdentityCredential(workloadIdentityCredentialOptions);
106
+ }
107
+ if (tenantId) {
108
+ const workloadIdentityClientTenantOptions = {
109
+ ...options,
110
+ tenantId,
111
+ };
112
+ return new workloadIdentityCredential_js_1.WorkloadIdentityCredential(workloadIdentityClientTenantOptions);
113
+ }
114
+ // We may be able to return a UnavailableCredential here, but that may be a breaking change
115
+ return new workloadIdentityCredential_js_1.WorkloadIdentityCredential(options);
116
+ }
117
+ /**
118
+ * Creates a {@link AzureDeveloperCliCredential} from the provided options.
119
+ * @param options - Options to configure the credential.
120
+ *
121
+ * @internal
122
+ */
123
+ function createDefaultAzureDeveloperCliCredential(options = {}) {
124
+ return new azureDeveloperCliCredential_js_1.AzureDeveloperCliCredential(options);
125
+ }
126
+ /**
127
+ * Creates a {@link AzureCliCredential} from the provided options.
128
+ * @param options - Options to configure the credential.
129
+ *
130
+ * @internal
131
+ */
132
+ function createDefaultAzureCliCredential(options = {}) {
133
+ return new azureCliCredential_js_1.AzureCliCredential(options);
134
+ }
135
+ /**
136
+ * Creates a {@link AzurePowerShellCredential} from the provided options.
137
+ * @param options - Options to configure the credential.
138
+ *
139
+ * @internal
140
+ */
141
+ function createDefaultAzurePowershellCredential(options = {}) {
142
+ return new azurePowerShellCredential_js_1.AzurePowerShellCredential(options);
143
+ }
144
+ /**
145
+ * Creates an {@link EnvironmentCredential} from the provided options.
146
+ * @param options - Options to configure the credential.
147
+ *
148
+ * @internal
149
+ */
150
+ function createDefaultEnvironmentCredential(options = {}) {
151
+ return new environmentCredential_js_1.EnvironmentCredential(options);
152
+ }
153
+ //# sourceMappingURL=defaultAzureCredentialFunctions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaultAzureCredentialFunctions.js","sourceRoot":"","sources":["../../../src/credentials/defaultAzureCredentialFunctions.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;AA+BlC,sEAIC;AAQD,0FAIC;AAQD,wFAmDC;AAQD,0FA8BC;AAQD,4FAIC;AAQD,0EAIC;AAQD,wFAIC;AAQD,gFAIC;AAxLD,yEAAmE;AAKnE,mEAAiF;AACjF,mFAA6E;AAC7E,qFAA+E;AAC/E,mEAA6D;AAC7D,iFAA2E;AAE3E,mFAA6E;AAC7E,+DAAyD;AAEzD;;;;;;;;GAQG;AACH,SAAgB,6BAA6B,CAC3C,UAAyC,EAAE;IAE3C,OAAO,IAAI,sCAAgB,CAAC,OAAO,CAAC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wDAAyB,CAAC,OAAO,CAAC,CAAC;AAChD,CAAC;AAED;;;;;GAKG;AACH,SAAgB,kCAAkC,CAChD,UAAyC,EAAE;IAE3C,OAAO,IAAI,gDAAqB,CAAC,OAAO,CAAC,CAAC;AAC5C,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { TokenCredential } from \"@azure/core-auth\";\nimport type {\n DefaultAzureCredentialClientIdOptions,\n DefaultAzureCredentialOptions,\n DefaultAzureCredentialResourceIdOptions,\n} from \"./defaultAzureCredentialOptions.js\";\nimport { EnvironmentCredential } from \"./environmentCredential.js\";\nimport type {\n ManagedIdentityCredentialClientIdOptions,\n ManagedIdentityCredentialResourceIdOptions,\n} from \"./managedIdentityCredential/options.js\";\nimport { ManagedIdentityCredential } from \"./managedIdentityCredential/index.js\";\nimport { WorkloadIdentityCredential } from \"./workloadIdentityCredential.js\";\nimport { AzureDeveloperCliCredential } from \"./azureDeveloperCliCredential.js\";\nimport { AzureCliCredential } from \"./azureCliCredential.js\";\nimport { AzurePowerShellCredential } from \"./azurePowerShellCredential.js\";\nimport type { WorkloadIdentityCredentialOptions } from \"./workloadIdentityCredentialOptions.js\";\nimport { VisualStudioCodeCredential } from \"./visualStudioCodeCredential.js\";\nimport { BrokerCredential } from \"./brokerCredential.js\";\n\n/**\n * Creates a {@link BrokerCredential} instance with the provided options.\n * This credential uses the Windows Authentication Manager (WAM) broker for authentication.\n * It will only attempt to authenticate silently using the default broker account\n *\n * @param options - Options for configuring the credential.\n *\n * @internal\n */\nexport function createDefaultBrokerCredential(\n options: DefaultAzureCredentialOptions = {},\n): TokenCredential {\n return new BrokerCredential(options);\n}\n\n/**\n * Creates a {@link VisualStudioCodeCredential} from the provided options.\n * @param options - Options to configure the credential.\n *\n * @internal\n */\nexport function createDefaultVisualStudioCodeCredential(\n options: DefaultAzureCredentialOptions = {},\n): TokenCredential {\n return new VisualStudioCodeCredential(options);\n}\n\n/**\n * Creates a {@link ManagedIdentityCredential} from the provided options.\n * @param options - Options to configure the credential.\n *\n * @internal\n */\nexport function createDefaultManagedIdentityCredential(\n options:\n | DefaultAzureCredentialOptions\n | DefaultAzureCredentialResourceIdOptions\n | DefaultAzureCredentialClientIdOptions = {},\n): TokenCredential {\n options.retryOptions ??= {\n maxRetries: 5,\n retryDelayInMs: 800,\n };\n const managedIdentityClientId =\n (options as DefaultAzureCredentialClientIdOptions)?.managedIdentityClientId ??\n process.env.AZURE_CLIENT_ID;\n const workloadIdentityClientId =\n (options as DefaultAzureCredentialClientIdOptions)?.workloadIdentityClientId ??\n managedIdentityClientId;\n const managedResourceId = (options as DefaultAzureCredentialResourceIdOptions)\n ?.managedIdentityResourceId;\n const workloadFile = process.env.AZURE_FEDERATED_TOKEN_FILE;\n const tenantId = options?.tenantId ?? process.env.AZURE_TENANT_ID;\n if (managedResourceId) {\n const managedIdentityResourceIdOptions: ManagedIdentityCredentialResourceIdOptions = {\n ...options,\n resourceId: managedResourceId,\n };\n return new ManagedIdentityCredential(managedIdentityResourceIdOptions);\n }\n\n if (workloadFile && workloadIdentityClientId) {\n const workloadIdentityCredentialOptions: DefaultAzureCredentialOptions = {\n ...options,\n tenantId: tenantId,\n };\n\n return new ManagedIdentityCredential(\n workloadIdentityClientId,\n workloadIdentityCredentialOptions,\n );\n }\n\n if (managedIdentityClientId) {\n const managedIdentityClientOptions: ManagedIdentityCredentialClientIdOptions = {\n ...options,\n clientId: managedIdentityClientId,\n };\n\n return new ManagedIdentityCredential(managedIdentityClientOptions);\n }\n\n // We may be able to return a UnavailableCredential here, but that may be a breaking change\n return new ManagedIdentityCredential(options);\n}\n\n/**\n * Creates a {@link WorkloadIdentityCredential} from the provided options.\n * @param options - Options to configure the credential.\n *\n * @internal\n */\nexport function createDefaultWorkloadIdentityCredential(\n options?: DefaultAzureCredentialOptions | DefaultAzureCredentialClientIdOptions,\n): TokenCredential {\n const managedIdentityClientId =\n (options as DefaultAzureCredentialClientIdOptions)?.managedIdentityClientId ??\n process.env.AZURE_CLIENT_ID;\n const workloadIdentityClientId =\n (options as DefaultAzureCredentialClientIdOptions)?.workloadIdentityClientId ??\n managedIdentityClientId;\n const workloadFile = process.env.AZURE_FEDERATED_TOKEN_FILE;\n const tenantId = options?.tenantId ?? process.env.AZURE_TENANT_ID;\n if (workloadFile && workloadIdentityClientId) {\n const workloadIdentityCredentialOptions: WorkloadIdentityCredentialOptions = {\n ...options,\n tenantId,\n clientId: workloadIdentityClientId,\n tokenFilePath: workloadFile,\n };\n return new WorkloadIdentityCredential(workloadIdentityCredentialOptions);\n }\n if (tenantId) {\n const workloadIdentityClientTenantOptions: WorkloadIdentityCredentialOptions = {\n ...options,\n tenantId,\n };\n return new WorkloadIdentityCredential(workloadIdentityClientTenantOptions);\n }\n\n // We may be able to return a UnavailableCredential here, but that may be a breaking change\n return new WorkloadIdentityCredential(options);\n}\n\n/**\n * Creates a {@link AzureDeveloperCliCredential} from the provided options.\n * @param options - Options to configure the credential.\n *\n * @internal\n */\nexport function createDefaultAzureDeveloperCliCredential(\n options: DefaultAzureCredentialOptions = {},\n): TokenCredential {\n return new AzureDeveloperCliCredential(options);\n}\n\n/**\n * Creates a {@link AzureCliCredential} from the provided options.\n * @param options - Options to configure the credential.\n *\n * @internal\n */\nexport function createDefaultAzureCliCredential(\n options: DefaultAzureCredentialOptions = {},\n): TokenCredential {\n return new AzureCliCredential(options);\n}\n\n/**\n * Creates a {@link AzurePowerShellCredential} from the provided options.\n * @param options - Options to configure the credential.\n *\n * @internal\n */\nexport function createDefaultAzurePowershellCredential(\n options: DefaultAzureCredentialOptions = {},\n): TokenCredential {\n return new AzurePowerShellCredential(options);\n}\n\n/**\n * Creates an {@link EnvironmentCredential} from the provided options.\n * @param options - Options to configure the credential.\n *\n * @internal\n */\nexport function createDefaultEnvironmentCredential(\n options: DefaultAzureCredentialOptions = {},\n): TokenCredential {\n return new EnvironmentCredential(options);\n}\n"]}
@@ -1,11 +1,11 @@
1
- // This file is read by tools that parse documentation comments conforming to the TSDoc standard.
2
- // It should be published with your NPM package. It should not be tracked by Git.
3
- {
4
- "tsdocVersion": "0.12",
5
- "toolPackages": [
6
- {
7
- "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.52.8"
9
- }
10
- ]
11
- }
1
+ // This file is read by tools that parse documentation comments conforming to the TSDoc standard.
2
+ // It should be published with your NPM package. It should not be tracked by Git.
3
+ {
4
+ "tsdocVersion": "0.12",
5
+ "toolPackages": [
6
+ {
7
+ "packageName": "@microsoft/api-extractor",
8
+ "packageVersion": "7.52.8"
9
+ }
10
+ ]
11
+ }
@@ -8,6 +8,6 @@ export declare const processUtils: {
8
8
  * Promisifying childProcess.execFile
9
9
  * @internal
10
10
  */
11
- execFile(file: string, params: string[], options?: childProcess.ExecFileOptionsWithStringEncoding): Promise<string | Buffer>;
11
+ execFile(file: string, params: string[], options?: Omit<childProcess.ExecFileOptionsWithStringEncoding, "shell">): Promise<string | Buffer>;
12
12
  };
13
13
  //# sourceMappingURL=processUtils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"processUtils.d.ts","sourceRoot":"","sources":["../../../src/util/processUtils.ts"],"names":[],"mappings":"AAGA,OAAO,YAAY,MAAM,oBAAoB,CAAC;AAE9C;;;GAGG;AACH,eAAO,MAAM,YAAY;IACvB;;;OAGG;mBAEK,MAAM,UACJ,MAAM,EAAE,YACN,YAAY,CAAC,iCAAiC,GACvD,OAAO,CAAC,MAAM,GAAG,MAAM,CAAC;CAiB5B,CAAC"}
1
+ {"version":3,"file":"processUtils.d.ts","sourceRoot":"","sources":["../../../src/util/processUtils.ts"],"names":[],"mappings":"AAGA,OAAO,YAAY,MAAM,oBAAoB,CAAC;AAE9C;;;GAGG;AACH,eAAO,MAAM,YAAY;IACvB;;;OAGG;mBAEK,MAAM,UACJ,MAAM,EAAE,YACN,IAAI,CAAC,YAAY,CAAC,iCAAiC,EAAE,OAAO,CAAC,GACtE,OAAO,CAAC,MAAM,GAAG,MAAM,CAAC;CAmB5B,CAAC"}
@@ -16,7 +16,9 @@ exports.processUtils = {
16
16
  */
17
17
  execFile(file, params, options) {
18
18
  return new Promise((resolve, reject) => {
19
- node_child_process_1.default.execFile(file, params, options, (error, stdout, stderr) => {
19
+ const args = [...params];
20
+ const command = [file, ...args].join(" ");
21
+ node_child_process_1.default.exec(command, options, (error, stdout, stderr) => {
20
22
  if (Buffer.isBuffer(stdout)) {
21
23
  stdout = stdout.toString("utf8");
22
24
  }
@@ -1 +1 @@
1
- {"version":3,"file":"processUtils.js","sourceRoot":"","sources":["../../../src/util/processUtils.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;;AAElC,oFAA8C;AAE9C;;;GAGG;AACU,QAAA,YAAY,GAAG;IAC1B;;;OAGG;IACH,QAAQ,CACN,IAAY,EACZ,MAAgB,EAChB,OAAwD;QAExD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrC,4BAAY,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE;gBACrE,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;oBAC5B,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;gBACnC,CAAC;gBACD,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;oBAC5B,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;gBACnC,CAAC;gBACD,IAAI,MAAM,IAAI,KAAK,EAAE,CAAC;oBACpB,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;gBAC7C,CAAC;qBAAM,CAAC;oBACN,OAAO,CAAC,MAAM,CAAC,CAAC;gBAClB,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CACF,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport childProcess from \"node:child_process\";\n\n/**\n * Easy to mock childProcess utils.\n * @internal\n */\nexport const processUtils = {\n /**\n * Promisifying childProcess.execFile\n * @internal\n */\n execFile(\n file: string,\n params: string[],\n options?: childProcess.ExecFileOptionsWithStringEncoding,\n ): Promise<string | Buffer> {\n return new Promise((resolve, reject) => {\n childProcess.execFile(file, params, options, (error, stdout, stderr) => {\n if (Buffer.isBuffer(stdout)) {\n stdout = stdout.toString(\"utf8\");\n }\n if (Buffer.isBuffer(stderr)) {\n stderr = stderr.toString(\"utf8\");\n }\n if (stderr || error) {\n reject(stderr ? new Error(stderr) : error);\n } else {\n resolve(stdout);\n }\n });\n });\n },\n};\n"]}
1
+ {"version":3,"file":"processUtils.js","sourceRoot":"","sources":["../../../src/util/processUtils.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;;AAElC,oFAA8C;AAE9C;;;GAGG;AACU,QAAA,YAAY,GAAG;IAC1B;;;OAGG;IACH,QAAQ,CACN,IAAY,EACZ,MAAgB,EAChB,OAAuE;QAEvE,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrC,MAAM,IAAI,GAAG,CAAC,GAAG,MAAM,CAAC,CAAC;YACzB,MAAM,OAAO,GAAG,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YAC1C,4BAAY,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE;gBAC5D,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;oBAC5B,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;gBACnC,CAAC;gBACD,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;oBAC5B,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;gBACnC,CAAC;gBACD,IAAI,MAAM,IAAI,KAAK,EAAE,CAAC;oBACpB,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;gBAC7C,CAAC;qBAAM,CAAC;oBACN,OAAO,CAAC,MAAM,CAAC,CAAC;gBAClB,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CACF,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport childProcess from \"node:child_process\";\n\n/**\n * Easy to mock childProcess utils.\n * @internal\n */\nexport const processUtils = {\n /**\n * Promisifying childProcess.execFile\n * @internal\n */\n execFile(\n file: string,\n params: string[],\n options?: Omit<childProcess.ExecFileOptionsWithStringEncoding, \"shell\">,\n ): Promise<string | Buffer> {\n return new Promise((resolve, reject) => {\n const args = [...params];\n const command = [file, ...args].join(\" \");\n childProcess.exec(command, options, (error, stdout, stderr) => {\n if (Buffer.isBuffer(stdout)) {\n stdout = stdout.toString(\"utf8\");\n }\n if (Buffer.isBuffer(stderr)) {\n stderr = stderr.toString(\"utf8\");\n }\n if (stderr || error) {\n reject(stderr ? new Error(stderr) : error);\n } else {\n resolve(stdout);\n }\n });\n });\n },\n};\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.11.0-beta.1";
4
+ export declare const SDK_VERSION = "4.11.0-beta.2";
5
5
  /**
6
6
  * The default client ID for authentication
7
7
  * @internal