@azure/identity 1.0.0-preview.1 → 1.0.0-preview.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 +24 -0
- package/README.md +50 -23
- package/browser/identity.js +9828 -0
- package/browser/identity.js.map +1 -0
- package/browser/identity.min.js +2 -0
- package/browser/identity.min.js.map +1 -0
- package/dist/index.js +475 -205
- package/dist/index.js.map +1 -1
- package/dist-esm/src/client/errors.d.ts +1 -1
- package/dist-esm/src/client/errors.d.ts.map +1 -1
- package/dist-esm/src/client/errors.js +9 -1
- package/dist-esm/src/client/errors.js.map +1 -1
- package/dist-esm/src/client/identityClient.d.ts +20 -17
- package/dist-esm/src/client/identityClient.d.ts.map +1 -1
- package/dist-esm/src/client/identityClient.js +42 -206
- package/dist-esm/src/client/identityClient.js.map +1 -1
- package/dist-esm/src/credentials/clientCertificateCredential.browser.d.ts +7 -0
- package/dist-esm/src/credentials/clientCertificateCredential.browser.d.ts.map +1 -0
- package/dist-esm/src/credentials/clientCertificateCredential.browser.js +12 -0
- package/dist-esm/src/credentials/clientCertificateCredential.browser.js.map +1 -0
- package/dist-esm/src/credentials/clientCertificateCredential.d.ts +5 -5
- package/dist-esm/src/credentials/clientCertificateCredential.d.ts.map +1 -1
- package/dist-esm/src/credentials/clientCertificateCredential.js +59 -5
- package/dist-esm/src/credentials/clientCertificateCredential.js.map +1 -1
- package/dist-esm/src/credentials/clientSecretCredential.d.ts +3 -3
- package/dist-esm/src/credentials/clientSecretCredential.d.ts.map +1 -1
- package/dist-esm/src/credentials/clientSecretCredential.js +27 -4
- package/dist-esm/src/credentials/clientSecretCredential.js.map +1 -1
- package/dist-esm/src/credentials/deviceCodeCredential.browser.d.ts +7 -0
- package/dist-esm/src/credentials/deviceCodeCredential.browser.d.ts.map +1 -0
- package/dist-esm/src/credentials/deviceCodeCredential.browser.js +12 -0
- package/dist-esm/src/credentials/deviceCodeCredential.browser.js.map +1 -0
- package/dist-esm/src/credentials/deviceCodeCredential.d.ts +67 -0
- package/dist-esm/src/credentials/deviceCodeCredential.d.ts.map +1 -0
- package/dist-esm/src/credentials/deviceCodeCredential.js +139 -0
- package/dist-esm/src/credentials/deviceCodeCredential.js.map +1 -0
- package/dist-esm/src/credentials/environmentCredential.browser.d.ts +7 -0
- package/dist-esm/src/credentials/environmentCredential.browser.d.ts.map +1 -0
- package/dist-esm/src/credentials/environmentCredential.browser.js +12 -0
- package/dist-esm/src/credentials/environmentCredential.browser.js.map +1 -0
- package/dist-esm/src/credentials/environmentCredential.d.ts.map +1 -1
- package/dist-esm/src/credentials/environmentCredential.js +0 -4
- package/dist-esm/src/credentials/environmentCredential.js.map +1 -1
- package/dist-esm/src/credentials/interactiveBrowserCredential.browser.d.ts +32 -0
- package/dist-esm/src/credentials/interactiveBrowserCredential.browser.d.ts.map +1 -0
- package/dist-esm/src/credentials/interactiveBrowserCredential.browser.js +112 -0
- package/dist-esm/src/credentials/interactiveBrowserCredential.browser.js.map +1 -0
- package/dist-esm/src/credentials/interactiveBrowserCredential.d.ts +12 -0
- package/dist-esm/src/credentials/interactiveBrowserCredential.d.ts.map +1 -0
- package/dist-esm/src/credentials/interactiveBrowserCredential.js +17 -0
- package/dist-esm/src/credentials/interactiveBrowserCredential.js.map +1 -0
- package/dist-esm/src/credentials/interactiveBrowserCredentialOptions.d.ts +24 -0
- package/dist-esm/src/credentials/interactiveBrowserCredentialOptions.d.ts.map +1 -0
- package/dist-esm/src/credentials/interactiveBrowserCredentialOptions.js +3 -0
- package/dist-esm/src/credentials/interactiveBrowserCredentialOptions.js.map +1 -0
- package/dist-esm/src/credentials/managedIdentityCredential.browser.d.ts +7 -0
- package/dist-esm/src/credentials/managedIdentityCredential.browser.d.ts.map +1 -0
- package/dist-esm/src/credentials/managedIdentityCredential.browser.js +15 -0
- package/dist-esm/src/credentials/managedIdentityCredential.browser.js.map +1 -0
- package/dist-esm/src/credentials/managedIdentityCredential.d.ts +10 -1
- package/dist-esm/src/credentials/managedIdentityCredential.d.ts.map +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential.js +144 -2
- package/dist-esm/src/credentials/managedIdentityCredential.js.map +1 -1
- package/dist-esm/src/credentials/usernamePasswordCredential.d.ts +39 -0
- package/dist-esm/src/credentials/usernamePasswordCredential.d.ts.map +1 -0
- package/dist-esm/src/credentials/usernamePasswordCredential.js +67 -0
- package/dist-esm/src/credentials/usernamePasswordCredential.js.map +1 -0
- package/dist-esm/src/index.d.ts +4 -0
- package/dist-esm/src/index.d.ts.map +1 -1
- package/dist-esm/src/index.js +3 -0
- package/dist-esm/src/index.js.map +1 -1
- package/package.json +32 -14
- package/src/client/errors.ts +11 -3
- package/src/client/identityClient.ts +64 -246
- package/src/credentials/clientCertificateCredential.browser.ts +27 -0
- package/src/credentials/clientCertificateCredential.ts +72 -22
- package/src/credentials/clientSecretCredential.ts +32 -17
- package/src/credentials/deviceCodeCredential.browser.ts +27 -0
- package/src/credentials/deviceCodeCredential.ts +203 -0
- package/src/credentials/environmentCredential.browser.ts +19 -0
- package/src/credentials/environmentCredential.ts +5 -9
- package/src/credentials/interactiveBrowserCredential.browser.ts +134 -0
- package/src/credentials/interactiveBrowserCredential.ts +31 -0
- package/src/credentials/interactiveBrowserCredentialOptions.ts +30 -0
- package/src/credentials/managedIdentityCredential.browser.ts +22 -0
- package/src/credentials/managedIdentityCredential.ts +179 -8
- package/src/credentials/usernamePasswordCredential.ts +83 -0
- package/src/index.ts +4 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 1.0.0-preview.2 - 2019-08-05
|
|
4
|
+
|
|
5
|
+
- Introduced the following credential types:
|
|
6
|
+
- [`DeviceCodeCredential`](https://azure.github.io/azure-sdk-for-js/identity/classes/devicecodecredential.html)
|
|
7
|
+
- [`InteractiveBrowserCredential`](https://azure.github.io/azure-sdk-for-js/identity/classes/interactivebrowsercredential.html)
|
|
8
|
+
- [`UsernamePasswordCredential`](https://azure.github.io/azure-sdk-for-js/identity/classes/usernamepasswordcredential.html)
|
|
9
|
+
- This library can now be used in the browser! The following credential types supported in browser builds:
|
|
10
|
+
- `ClientSecretCredential`
|
|
11
|
+
- `UsernamePasswordCredential`
|
|
12
|
+
- `InteractiveBrowserCredential`
|
|
13
|
+
|
|
14
|
+
## 1.0.0-preview.1 - 2019-06-27
|
|
15
|
+
|
|
16
|
+
For release notes and more information please visit https://aka.ms/azure-sdk-preview1-js
|
|
17
|
+
|
|
18
|
+
- Introduced the following credential types:
|
|
19
|
+
- [`DefaultAzureCredential`](https://azure.github.io/azure-sdk-for-js/identity/classes/defaultazurecredential.html)
|
|
20
|
+
- [`EnvironmentCredential`](https://azure.github.io/azure-sdk-for-js/identity/classes/environmentcredential.html)
|
|
21
|
+
- [`ManagedIdentityCredential`](https://azure.github.io/azure-sdk-for-js/identity/classes/managedidentitycredential.html)
|
|
22
|
+
- [`ClientSecretCredential`](https://azure.github.io/azure-sdk-for-js/identity/classes/clientsecretcredential.html)
|
|
23
|
+
- [`ClientCertificateCredential`](https://azure.github.io/azure-sdk-for-js/identity/classes/clientcertificatecredential.html)
|
|
24
|
+
- [`ChainedTokenCredential`](https://azure.github.io/azure-sdk-for-js/identity/classes/chainedtokencredential.html)
|
package/README.md
CHANGED
|
@@ -12,11 +12,12 @@ to authenticate API requests. It supports token authentication using an Azure Ac
|
|
|
12
12
|
- if you don't have one, you can sign up for a [free account](https://azure.microsoft.com/free/)
|
|
13
13
|
- Node.js 8 LTS or higher
|
|
14
14
|
|
|
15
|
-
**NOTE:** The credential implementations in this library are not yet supported in the browser.
|
|
15
|
+
**NOTE:** The credential implementations in this library are not yet supported in the browser. We will provide browser-supported implementations for some in a future preview release.
|
|
16
16
|
|
|
17
17
|
### Install the package
|
|
18
18
|
|
|
19
19
|
Install Azure Identity with `npm`:
|
|
20
|
+
|
|
20
21
|
```sh
|
|
21
22
|
npm install --save @azure/identity
|
|
22
23
|
```
|
|
@@ -25,24 +26,27 @@ npm install --save @azure/identity
|
|
|
25
26
|
|
|
26
27
|
### Credentials
|
|
27
28
|
|
|
28
|
-
Azure Identity offers a variety of credential classes that are accepted by Azure SDK data plane clients. Each client library documents its Azure Identity integration in its README and samples.
|
|
29
|
+
Azure Identity offers a variety of credential classes that are accepted by Azure SDK data plane clients. Each client library documents its Azure Identity integration in its README and samples. Azure SDK management plane libraries (those starting with `@azure/arm-*`)
|
|
29
30
|
do not accept these credentials.
|
|
30
31
|
|
|
31
32
|
Credentials differ mostly in configuration:
|
|
32
33
|
|
|
33
|
-
|credential class|identity|configuration
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
34
|
+
| credential class | identity | configuration |
|
|
35
|
+
| ---------------------------------- | ------------------------------------- | ------------------------------------------------------------------------------------------------ |
|
|
36
|
+
| [`DefaultAzureCredential`][1] | service principal or managed identity | none for managed identity; [environment variables](#environment-variables) for service principal |
|
|
37
|
+
| [`ManagedIdentityCredential`][2] | managed identity | none |
|
|
38
|
+
| [`EnvironmentCredential`][3] | service principal | [environment variables](#environment-variables) |
|
|
39
|
+
| [`ClientSecretCredential`][4] | service principal | constructor parameters |
|
|
40
|
+
| [`ClientCertificateCredential`][5] | service principal | constructor parameters |
|
|
41
|
+
| [`DeviceCodeCredential`][6] | app registration details | constructor parameters |
|
|
42
|
+
| [`InteractiveBrowserCredential`][7]| app registration details | constructor parameters |
|
|
43
|
+
| [`UsernamePasswordCredential`][8] | user principal | constructor parameters |
|
|
40
44
|
|
|
41
45
|
Credentials can be chained and tried in turn until one succeeds; see [chaining credentials](#chaining-credentials) for details.
|
|
42
46
|
|
|
43
47
|
### DefaultAzureCredential
|
|
44
48
|
|
|
45
|
-
`DefaultAzureCredential` is appropriate for most scenarios. It supports authenticating as a service principal or managed identity. To authenticate as a service principal, provide configuration in environment variables as described in the next section.
|
|
49
|
+
`DefaultAzureCredential` is appropriate for most scenarios. It supports authenticating as a service principal or managed identity. To authenticate as a service principal, provide configuration in environment variables as described in the next section. Currently this credential attempts to use the `EnvironmentCredential` and `ManagedIdentityCredential`, in that order.
|
|
46
50
|
|
|
47
51
|
Authenticating as a managed identity requires no configuration, but does require platform support. See the [managed identity documentation](https://docs.microsoft.com/en-us/azure/active-directory/managed-identities-azure-resources/services-support-managed-identities) for more information.
|
|
48
52
|
|
|
@@ -50,11 +54,11 @@ Authenticating as a managed identity requires no configuration, but does require
|
|
|
50
54
|
|
|
51
55
|
`DefaultAzureCredential` and `EnvironmentCredential` are configured for service principal authentication with these environment variables:
|
|
52
56
|
|
|
53
|
-
|variable name|value
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
57
|
+
| variable name | value |
|
|
58
|
+
| --------------------- | --------------------------------------------------- |
|
|
59
|
+
| `AZURE_CLIENT_ID` | service principal's app id |
|
|
60
|
+
| `AZURE_TENANT_ID` | id of the principal's Azure Active Directory tenant |
|
|
61
|
+
| `AZURE_CLIENT_SECRET` | one of the service principal's client secrets |
|
|
58
62
|
|
|
59
63
|
## Examples
|
|
60
64
|
|
|
@@ -64,7 +68,7 @@ Authenticating as a managed identity requires no configuration, but does require
|
|
|
64
68
|
// The default credential first checks environment variables for configuration as described above.
|
|
65
69
|
// If environment configuration is incomplete, it will try managed identity.
|
|
66
70
|
const { KeysClient } = require("@azure/keyvault-keys");
|
|
67
|
-
const { DefaultAzureCredential } = require(
|
|
71
|
+
const { DefaultAzureCredential } = require("@azure/identity");
|
|
68
72
|
|
|
69
73
|
// Azure SDK clients accept the credential as a parameter
|
|
70
74
|
const credential = new DefaultAzureCredential();
|
|
@@ -73,23 +77,29 @@ const getResult = await client.getKey("MyKeyName");
|
|
|
73
77
|
```
|
|
74
78
|
|
|
75
79
|
### Authenticating as a service principal:
|
|
80
|
+
|
|
76
81
|
```javascript
|
|
77
82
|
// Using a client secret
|
|
78
|
-
const { ClientSecretCredential } = require(
|
|
83
|
+
const { ClientSecretCredential } = require("@azure/identity");
|
|
79
84
|
const credential = new ClientSecretCredential(tenantId, clientId, clientSecret);
|
|
80
85
|
|
|
81
86
|
// Using a PEM-encoded certificate with a private key, not password protected
|
|
82
|
-
const { ClientCertificateCredential } = require(
|
|
83
|
-
const credential = new ClientCertificateCredential(
|
|
87
|
+
const { ClientCertificateCredential } = require("@azure/identity");
|
|
88
|
+
const credential = new ClientCertificateCredential(
|
|
89
|
+
tenantId,
|
|
90
|
+
clientId,
|
|
91
|
+
"/app/certs/certificate.pem"
|
|
92
|
+
);
|
|
84
93
|
|
|
85
94
|
// Using environment variables (see "Environment variables" above for variable names)
|
|
86
|
-
const { EnvironmentCredential } = require(
|
|
95
|
+
const { EnvironmentCredential } = require("@azure/identity");
|
|
87
96
|
const credential = new EnvironmentCredential();
|
|
88
97
|
```
|
|
89
98
|
|
|
90
99
|
### Chaining credentials:
|
|
100
|
+
|
|
91
101
|
```javascript
|
|
92
|
-
const { ClientSecretCredential, ChainedTokenCredential } = require(
|
|
102
|
+
const { ClientSecretCredential, ChainedTokenCredential } = require("@azure/identity");
|
|
93
103
|
|
|
94
104
|
// When an access token is requested, the chain will try each
|
|
95
105
|
// credential in order, stopping when one provides a token
|
|
@@ -105,16 +115,22 @@ const client = new KeysClient(vaultUrl, credentialChain);
|
|
|
105
115
|
## Troubleshooting
|
|
106
116
|
|
|
107
117
|
### General
|
|
108
|
-
|
|
118
|
+
|
|
119
|
+
Credentials raise `AuthenticationError` when they fail to authenticate. This class has a `message` field which describes why authentication failed. An `AggregateAuthenticationError` will be raised by `ChainedTokenCredential` with an `errors` field containing an array of errors from each credential in the chain.
|
|
109
120
|
|
|
110
121
|
## Next steps
|
|
111
122
|
|
|
123
|
+
### Read the documentation
|
|
124
|
+
|
|
125
|
+
API documentation for this library can be found on our [documentation site](https://azure.github.io/azure-sdk-for-js/identity/index.html).
|
|
126
|
+
|
|
112
127
|
### Provide Feedback
|
|
113
128
|
|
|
114
129
|
If you encounter bugs or have suggestions, please [open an issue](https://github.com/Azure/azure-sdk-for-js/issues).
|
|
115
130
|
|
|
116
131
|
## Contributing
|
|
117
|
-
|
|
132
|
+
|
|
133
|
+
This project welcomes contributions and suggestions. Most contributions require you to agree to a
|
|
118
134
|
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
|
|
119
135
|
the rights to use your contribution. For details, visit [https://cla.microsoft.com](https://cla.microsoft.com).
|
|
120
136
|
|
|
@@ -122,6 +138,17 @@ When you submit a pull request, a CLA-bot will automatically determine whether y
|
|
|
122
138
|
a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions
|
|
123
139
|
provided by the bot. You will only need to do this once across all repos using our CLA.
|
|
124
140
|
|
|
141
|
+
If you'd like to contribute to this library, please read the [contributing guide](../../../CONTRIBUTING.md) to learn more about how to build and test the code.
|
|
142
|
+
|
|
125
143
|
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
|
|
126
144
|
For more information, see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/)
|
|
127
145
|
or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
|
|
146
|
+
|
|
147
|
+
[1]: https://azure.github.io/azure-sdk-for-js/identity/classes/defaultazurecredential.html
|
|
148
|
+
[2]: https://azure.github.io/azure-sdk-for-js/identity/classes/managedidentitycredential.html
|
|
149
|
+
[3]: https://azure.github.io/azure-sdk-for-js/identity/classes/environmentcredential.html
|
|
150
|
+
[4]: https://azure.github.io/azure-sdk-for-js/identity/classes/clientsecretcredential.html
|
|
151
|
+
[5]: https://azure.github.io/azure-sdk-for-js/identity/classes/clientcertificatecredential.html
|
|
152
|
+
[6]: https://azure.github.io/azure-sdk-for-js/identity/classes/devicecodecredential.html
|
|
153
|
+
[7]: https://azure.github.io/azure-sdk-for-js/identity/classes/interactivebrowsercredential.html
|
|
154
|
+
[8]: https://azure.github.io/azure-sdk-for-js/identity/classes/usernamepasswordcredential.html
|