@azure/identity 2.1.0-alpha.20220414.1 → 2.1.0-alpha.20220415.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of @azure/identity might be problematic. Click here for more details.
- package/CHANGELOG.md +4 -0
- package/dist/index.js +25 -21
- package/dist/index.js.map +1 -1
- package/dist-esm/src/credentials/authorizationCodeCredential.js +2 -1
- package/dist-esm/src/credentials/authorizationCodeCredential.js.map +1 -1
- package/dist-esm/src/credentials/azureCliCredential.js +21 -18
- package/dist-esm/src/credentials/azureCliCredential.js.map +1 -1
- package/dist-esm/src/msal/nodeFlows/msalAuthorizationCode.js +2 -2
- package/dist-esm/src/msal/nodeFlows/msalAuthorizationCode.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,10 @@
|
|
|
8
8
|
|
|
9
9
|
### Bugs Fixed
|
|
10
10
|
|
|
11
|
+
- Fixed a bug that would break the AzureCliCredential if the Azure CLI reported a warning. See: [21075](https://github.com/Azure/azure-sdk-for-js/issues/21075).
|
|
12
|
+
- Fixed a bug in `AuthorizationCodeCredential` where the tenant id was not being used. The `common` tenant was the only tenant being used by this credential.
|
|
13
|
+
- Fixed a bug in `AuthorizationCodeCredential` where the public client was not being used. Due to this bug, without passing in the client secret, this credential would fail.
|
|
14
|
+
|
|
11
15
|
### Other Changes
|
|
12
16
|
|
|
13
17
|
- Upgraded to `@azure/core-tracing` version `^1.0.0`.
|
package/dist/index.js
CHANGED
|
@@ -1541,29 +1541,24 @@ class AzureCliCredential {
|
|
|
1541
1541
|
logger$h.getToken.info(`Using the scope ${scope}`);
|
|
1542
1542
|
ensureValidScope(scope, logger$h);
|
|
1543
1543
|
const resource = getScopeResource(scope);
|
|
1544
|
-
let responseData = "";
|
|
1545
1544
|
return tracingClient.withSpan(`${this.constructor.name}.getToken`, options, async () => {
|
|
1545
|
+
var _a, _b, _c;
|
|
1546
1546
|
try {
|
|
1547
1547
|
const obj = await cliCredentialInternals.getAzureCliAccessToken(resource, tenantId);
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
const error = new CredentialUnavailableError("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'.");
|
|
1553
|
-
logger$h.getToken.info(formatError(scopes, error));
|
|
1554
|
-
throw error;
|
|
1555
|
-
}
|
|
1556
|
-
else if (isLoginError) {
|
|
1557
|
-
const error = new CredentialUnavailableError("Please run 'az login' from a command prompt to authenticate before using this credential.");
|
|
1558
|
-
logger$h.getToken.info(formatError(scopes, error));
|
|
1559
|
-
throw error;
|
|
1560
|
-
}
|
|
1561
|
-
const error = new CredentialUnavailableError(obj.stderr);
|
|
1548
|
+
const isLoginError = (_a = obj.stderr) === null || _a === void 0 ? void 0 : _a.match("(.*)az login(.*)");
|
|
1549
|
+
const isNotInstallError = ((_b = obj.stderr) === null || _b === void 0 ? void 0 : _b.match("az:(.*)not found")) || ((_c = obj.stderr) === null || _c === void 0 ? void 0 : _c.startsWith("'az' is not recognized"));
|
|
1550
|
+
if (isNotInstallError) {
|
|
1551
|
+
const error = new CredentialUnavailableError("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'.");
|
|
1562
1552
|
logger$h.getToken.info(formatError(scopes, error));
|
|
1563
1553
|
throw error;
|
|
1564
1554
|
}
|
|
1565
|
-
|
|
1566
|
-
|
|
1555
|
+
if (isLoginError) {
|
|
1556
|
+
const error = new CredentialUnavailableError("Please run 'az login' from a command prompt to authenticate before using this credential.");
|
|
1557
|
+
logger$h.getToken.info(formatError(scopes, error));
|
|
1558
|
+
throw error;
|
|
1559
|
+
}
|
|
1560
|
+
try {
|
|
1561
|
+
const responseData = obj.stdout;
|
|
1567
1562
|
const response = JSON.parse(responseData);
|
|
1568
1563
|
logger$h.getToken.info(formatSuccess(scopes));
|
|
1569
1564
|
const returnValue = {
|
|
@@ -1572,9 +1567,17 @@ class AzureCliCredential {
|
|
|
1572
1567
|
};
|
|
1573
1568
|
return returnValue;
|
|
1574
1569
|
}
|
|
1570
|
+
catch (e) {
|
|
1571
|
+
if (obj.stderr) {
|
|
1572
|
+
throw new CredentialUnavailableError(obj.stderr);
|
|
1573
|
+
}
|
|
1574
|
+
throw e;
|
|
1575
|
+
}
|
|
1575
1576
|
}
|
|
1576
1577
|
catch (err) {
|
|
1577
|
-
const error =
|
|
1578
|
+
const error = err.name === "CredentialUnavailableError"
|
|
1579
|
+
? err
|
|
1580
|
+
: new Error(err.message || "Unknown error while trying to retrieve the access token");
|
|
1578
1581
|
logger$h.getToken.info(formatError(scopes, error));
|
|
1579
1582
|
throw error;
|
|
1580
1583
|
}
|
|
@@ -3440,12 +3443,12 @@ class MsalAuthorizationCode extends MsalNode {
|
|
|
3440
3443
|
}
|
|
3441
3444
|
async getAuthCodeUrl(options) {
|
|
3442
3445
|
await this.init();
|
|
3443
|
-
return this.confidentialApp.getAuthCodeUrl(options);
|
|
3446
|
+
return (this.confidentialApp || this.publicApp).getAuthCodeUrl(options);
|
|
3444
3447
|
}
|
|
3445
3448
|
async doGetToken(scopes, options) {
|
|
3446
3449
|
var _a;
|
|
3447
3450
|
try {
|
|
3448
|
-
const result = await ((_a = this.confidentialApp) === null || _a === void 0 ? void 0 : _a.acquireTokenByCode({
|
|
3451
|
+
const result = await ((_a = (this.confidentialApp || this.publicApp)) === null || _a === void 0 ? void 0 : _a.acquireTokenByCode({
|
|
3449
3452
|
scopes,
|
|
3450
3453
|
redirectUri: this.redirectUri,
|
|
3451
3454
|
code: this.authorizationCode,
|
|
@@ -3494,7 +3497,8 @@ class AuthorizationCodeCredential {
|
|
|
3494
3497
|
options = redirectUriOrOptions;
|
|
3495
3498
|
}
|
|
3496
3499
|
this.msalFlow = new MsalAuthorizationCode(Object.assign(Object.assign({}, options), { clientSecret,
|
|
3497
|
-
clientId,
|
|
3500
|
+
clientId,
|
|
3501
|
+
tenantId, tokenCredentialOptions: options || {}, logger: logger$1, redirectUri: this.redirectUri, authorizationCode: this.authorizationCode }));
|
|
3498
3502
|
}
|
|
3499
3503
|
/**
|
|
3500
3504
|
* Authenticates with Azure Active Directory and returns an access token if successful.
|