@azure/identity 4.5.0-beta.3 → 4.5.0
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +28 -33
- package/dist/index.js +72 -22
- package/dist/index.js.map +1 -1
- package/dist-esm/src/client/identityClient.js +1 -0
- package/dist-esm/src/client/identityClient.js.map +1 -1
- package/dist-esm/src/constants.js +1 -1
- package/dist-esm/src/constants.js.map +1 -1
- package/dist-esm/src/credentials/azureCliCredential.js +2 -0
- package/dist-esm/src/credentials/azureCliCredential.js.map +1 -1
- package/dist-esm/src/credentials/azureDeveloperCliCredential.js +1 -0
- package/dist-esm/src/credentials/azureDeveloperCliCredential.js.map +1 -1
- package/dist-esm/src/credentials/azurePipelinesCredential.js +15 -4
- package/dist-esm/src/credentials/azurePipelinesCredential.js.map +1 -1
- package/dist-esm/src/credentials/azurePowerShellCredential.js +1 -0
- package/dist-esm/src/credentials/azurePowerShellCredential.js.map +1 -1
- package/dist-esm/src/credentials/chainedTokenCredential.js +8 -1
- package/dist-esm/src/credentials/chainedTokenCredential.js.map +1 -1
- package/dist-esm/src/credentials/credentialPersistenceOptions.js.map +1 -1
- package/dist-esm/src/credentials/deviceCodeCredential.js +6 -4
- package/dist-esm/src/credentials/deviceCodeCredential.js.map +1 -1
- package/dist-esm/src/credentials/interactiveBrowserCredential.js.map +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/legacyMsiProvider.js +1 -0
- package/dist-esm/src/credentials/managedIdentityCredential/legacyMsiProvider.js.map +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/msalMsiProvider.js +1 -0
- package/dist-esm/src/credentials/managedIdentityCredential/msalMsiProvider.js.map +1 -1
- package/dist-esm/src/credentials/onBehalfOfCredential.js.map +1 -1
- package/dist-esm/src/msal/browserFlows/msalAuthCode.js +1 -1
- package/dist-esm/src/msal/browserFlows/msalAuthCode.js.map +1 -1
- package/dist-esm/src/msal/browserFlows/msalBrowserCommon.js +1 -0
- package/dist-esm/src/msal/browserFlows/msalBrowserCommon.js.map +1 -1
- package/dist-esm/src/msal/nodeFlows/msalClient.js +25 -0
- package/dist-esm/src/msal/nodeFlows/msalClient.js.map +1 -1
- package/dist-esm/src/msal/utils.js +2 -1
- package/dist-esm/src/msal/utils.js.map +1 -1
- package/dist-esm/src/plugins/consumer.js +6 -8
- package/dist-esm/src/plugins/consumer.js.map +1 -1
- package/dist-esm/src/tokenProvider.js +3 -3
- package/dist-esm/src/tokenProvider.js.map +1 -1
- package/package.json +17 -16
- package/types/identity.d.ts +53 -47
package/types/identity.d.ts
CHANGED
@@ -540,7 +540,14 @@ export declare class ChainedTokenCredential implements TokenCredential {
|
|
540
540
|
* @param sources - `TokenCredential` implementations to be tried in order.
|
541
541
|
*
|
542
542
|
* Example usage:
|
543
|
-
* ```
|
543
|
+
* ```ts snippet:chained_token_credential_example
|
544
|
+
* import { ClientSecretCredential, ChainedTokenCredential } from "@azure/identity";
|
545
|
+
*
|
546
|
+
* const tenantId = "<tenant-id>";
|
547
|
+
* const clientId = "<client-id>";
|
548
|
+
* const clientSecret = "<client-secret>";
|
549
|
+
* const anotherClientId = "<another-client-id>";
|
550
|
+
* const anotherSecret = "<another-client-secret>";
|
544
551
|
* const firstCredential = new ClientSecretCredential(tenantId, clientId, clientSecret);
|
545
552
|
* const secondCredential = new ClientSecretCredential(tenantId, anotherClientId, anotherSecret);
|
546
553
|
* const credentialChain = new ChainedTokenCredential(firstCredential, secondCredential);
|
@@ -758,23 +765,14 @@ export declare interface CredentialPersistenceOptions {
|
|
758
765
|
*
|
759
766
|
* Example:
|
760
767
|
*
|
761
|
-
* ```
|
762
|
-
* import { cachePersistencePlugin } from "@azure/identity-cache-persistence";
|
768
|
+
* ```ts snippet:credential_persistence_options_example
|
763
769
|
* import { useIdentityPlugin, DeviceCodeCredential } from "@azure/identity";
|
764
770
|
*
|
765
771
|
* useIdentityPlugin(cachePersistencePlugin);
|
766
|
-
*
|
767
|
-
*
|
768
|
-
*
|
769
|
-
*
|
770
|
-
* enabled: true
|
771
|
-
* }
|
772
|
-
* });
|
773
|
-
* }
|
774
|
-
*
|
775
|
-
* main().catch((error) => {
|
776
|
-
* console.error("An error occurred:", error);
|
777
|
-
* process.exit(1);
|
772
|
+
* const credential = new DeviceCodeCredential({
|
773
|
+
* tokenCachePersistenceOptions: {
|
774
|
+
* enabled: true,
|
775
|
+
* },
|
778
776
|
* });
|
779
777
|
* ```
|
780
778
|
*/
|
@@ -955,13 +953,15 @@ export declare class DeviceCodeCredential implements TokenCredential {
|
|
955
953
|
*
|
956
954
|
* Developers can configure how this message is shown by passing a custom `userPromptCallback`:
|
957
955
|
*
|
958
|
-
* ```
|
956
|
+
* ```ts snippet:device_code_credential_example
|
957
|
+
* import { DeviceCodeCredential } from "@azure/identity";
|
958
|
+
*
|
959
959
|
* const credential = new DeviceCodeCredential({
|
960
|
-
* tenantId: env.AZURE_TENANT_ID,
|
961
|
-
* clientId: env.AZURE_CLIENT_ID,
|
960
|
+
* tenantId: process.env.AZURE_TENANT_ID,
|
961
|
+
* clientId: process.env.AZURE_CLIENT_ID,
|
962
962
|
* userPromptCallback: (info) => {
|
963
963
|
* console.log("CUSTOMIZED PROMPT CALLBACK", info.message);
|
964
|
-
* }
|
964
|
+
* },
|
965
965
|
* });
|
966
966
|
* ```
|
967
967
|
*
|
@@ -1133,14 +1133,14 @@ export declare interface ErrorResponse {
|
|
1133
1133
|
/**
|
1134
1134
|
* Returns a callback that provides a bearer token.
|
1135
1135
|
* For example, the bearer token can be used to authenticate a request as follows:
|
1136
|
-
* ```
|
1137
|
-
* import { DefaultAzureCredential } from "@azure/identity";
|
1136
|
+
* ```ts snippet:token_provider_example
|
1137
|
+
* import { DefaultAzureCredential, getBearerTokenProvider } from "@azure/identity";
|
1138
|
+
* import { createPipelineRequest } from "@azure/core-rest-pipeline";
|
1138
1139
|
*
|
1139
1140
|
* const credential = new DefaultAzureCredential();
|
1140
1141
|
* const scope = "https://cognitiveservices.azure.com/.default";
|
1141
1142
|
* const getAccessToken = getBearerTokenProvider(credential, scope);
|
1142
1143
|
* const token = await getAccessToken();
|
1143
|
-
*
|
1144
1144
|
* // usage
|
1145
1145
|
* const request = createPipelineRequest({ url: "https://example.com" });
|
1146
1146
|
* request.headers.set("Authorization", `Bearer ${token}`);
|
@@ -1441,15 +1441,17 @@ export declare class OnBehalfOfCredential implements TokenCredential {
|
|
1441
1441
|
*
|
1442
1442
|
* Example using the `KeyClient` from [\@azure/keyvault-keys](https://www.npmjs.com/package/\@azure/keyvault-keys):
|
1443
1443
|
*
|
1444
|
-
* ```ts
|
1444
|
+
* ```ts snippet:on_behalf_of_credential_pem_example
|
1445
|
+
* import { OnBehalfOfCredential } from "@azure/identity";
|
1446
|
+
* import { KeyClient } from "@azure/keyvault-keys";
|
1447
|
+
*
|
1445
1448
|
* const tokenCredential = new OnBehalfOfCredential({
|
1446
|
-
* tenantId,
|
1447
|
-
* clientId,
|
1449
|
+
* tenantId: "tenant-id",
|
1450
|
+
* clientId: "client-id",
|
1448
1451
|
* certificatePath: "/path/to/certificate.pem",
|
1449
|
-
* userAssertionToken: "access-token"
|
1452
|
+
* userAssertionToken: "access-token",
|
1450
1453
|
* });
|
1451
1454
|
* const client = new KeyClient("vault-url", tokenCredential);
|
1452
|
-
*
|
1453
1455
|
* await client.getKey("key-name");
|
1454
1456
|
* ```
|
1455
1457
|
*
|
@@ -1463,15 +1465,17 @@ export declare class OnBehalfOfCredential implements TokenCredential {
|
|
1463
1465
|
*
|
1464
1466
|
* Example using the `KeyClient` from [\@azure/keyvault-keys](https://www.npmjs.com/package/\@azure/keyvault-keys):
|
1465
1467
|
*
|
1466
|
-
* ```ts
|
1468
|
+
* ```ts snippet:on_behalf_of_credential_secret_example
|
1469
|
+
* import { OnBehalfOfCredential } from "@azure/identity";
|
1470
|
+
* import { KeyClient } from "@azure/keyvault-keys";
|
1471
|
+
*
|
1467
1472
|
* const tokenCredential = new OnBehalfOfCredential({
|
1468
|
-
* tenantId,
|
1469
|
-
* clientId,
|
1470
|
-
* clientSecret,
|
1471
|
-
* userAssertionToken: "access-token"
|
1473
|
+
* tenantId: "tenant-id",
|
1474
|
+
* clientId: "client-id",
|
1475
|
+
* clientSecret: "client-secret",
|
1476
|
+
* userAssertionToken: "access-token",
|
1472
1477
|
* });
|
1473
1478
|
* const client = new KeyClient("vault-url", tokenCredential);
|
1474
|
-
*
|
1475
1479
|
* await client.getKey("key-name");
|
1476
1480
|
* ```
|
1477
1481
|
*
|
@@ -1485,15 +1489,19 @@ export declare class OnBehalfOfCredential implements TokenCredential {
|
|
1485
1489
|
*
|
1486
1490
|
* Example using the `KeyClient` from [\@azure/keyvault-keys](https://www.npmjs.com/package/\@azure/keyvault-keys):
|
1487
1491
|
*
|
1488
|
-
* ```ts
|
1492
|
+
* ```ts snippet:on_behalf_of_credential_assertion_example
|
1493
|
+
* import { OnBehalfOfCredential } from "@azure/identity";
|
1494
|
+
* import { KeyClient } from "@azure/keyvault-keys";
|
1495
|
+
*
|
1489
1496
|
* const tokenCredential = new OnBehalfOfCredential({
|
1490
|
-
* tenantId,
|
1491
|
-
* clientId,
|
1492
|
-
* getAssertion: () => {
|
1493
|
-
*
|
1497
|
+
* tenantId: "tenant-id",
|
1498
|
+
* clientId: "client-id",
|
1499
|
+
* getAssertion: () => {
|
1500
|
+
* return Promise.resolve("my-jwt");
|
1501
|
+
* },
|
1502
|
+
* userAssertionToken: "access-token",
|
1494
1503
|
* });
|
1495
1504
|
* const client = new KeyClient("vault-url", tokenCredential);
|
1496
|
-
*
|
1497
1505
|
* await client.getKey("key-name");
|
1498
1506
|
* ```
|
1499
1507
|
*
|
@@ -1666,18 +1674,16 @@ export declare interface TokenCredentialOptions extends CommonClientOptions {
|
|
1666
1674
|
*
|
1667
1675
|
* Example:
|
1668
1676
|
*
|
1669
|
-
* ```
|
1670
|
-
* import {
|
1677
|
+
* ```ts snippet:consumer_example
|
1678
|
+
* import { useIdentityPlugin, DeviceCodeCredential } from "@azure/identity";
|
1671
1679
|
*
|
1672
|
-
* import { useIdentityPlugin, DefaultAzureCredential } from "@azure/identity";
|
1673
1680
|
* useIdentityPlugin(cachePersistencePlugin);
|
1674
|
-
*
|
1675
|
-
* // The plugin has the capability to extend `DefaultAzureCredential` and to
|
1681
|
+
* // The plugin has the capability to extend `DeviceCodeCredential` and to
|
1676
1682
|
* // add middleware to the underlying credentials, such as persistence.
|
1677
|
-
* const credential = new
|
1683
|
+
* const credential = new DeviceCodeCredential({
|
1678
1684
|
* tokenCachePersistenceOptions: {
|
1679
|
-
* enabled: true
|
1680
|
-
* }
|
1685
|
+
* enabled: true,
|
1686
|
+
* },
|
1681
1687
|
* });
|
1682
1688
|
* ```
|
1683
1689
|
*
|