@azure/keyvault-certificates 4.5.0-beta.1 → 4.5.0
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.
- package/README.md +21 -55
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist-esm/keyvault-certificates/src/constants.js +1 -1
- package/dist-esm/keyvault-certificates/src/constants.js.map +1 -1
- package/dist-esm/keyvault-certificates/src/generated/keyVaultClient.js +1 -1
- package/dist-esm/keyvault-certificates/src/generated/keyVaultClient.js.map +1 -1
- package/package.json +10 -10
package/README.md
CHANGED
|
@@ -33,7 +33,7 @@ Key links:
|
|
|
33
33
|
### Prerequisites
|
|
34
34
|
|
|
35
35
|
- An [Azure subscription](https://azure.microsoft.com/free/)
|
|
36
|
-
-
|
|
36
|
+
- An existing [Azure Key Vault][azure_keyvault]. If you need to create a key vault, you can do so in the Azure Portal by following the steps in [this document][azure_keyvault_portal]. Alternatively, use the Azure CLI by following [these steps][azure_keyvault_cli].
|
|
37
37
|
|
|
38
38
|
### Install the package
|
|
39
39
|
|
|
@@ -57,52 +57,14 @@ npm install @types/node
|
|
|
57
57
|
|
|
58
58
|
You also need to enable `compilerOptions.allowSyntheticDefaultImports` in your tsconfig.json. Note that if you have enabled `compilerOptions.esModuleInterop`, `allowSyntheticDefaultImports` is enabled by default. See [TypeScript's compiler options handbook](https://www.typescriptlang.org/docs/handbook/compiler-options.html) for more information.
|
|
59
59
|
|
|
60
|
-
### Configuring your Key Vault
|
|
61
|
-
|
|
62
|
-
Use the [Azure Cloud Shell](https://shell.azure.com/bash) snippet below to create/get client secret credentials.
|
|
63
|
-
|
|
64
|
-
- Create a service principal and configure its access to Azure resources:
|
|
65
|
-
```Bash
|
|
66
|
-
az ad sp create-for-rbac -n <your-application-name> --skip-assignment
|
|
67
|
-
```
|
|
68
|
-
Output:
|
|
69
|
-
```json
|
|
70
|
-
{
|
|
71
|
-
"appId": "generated-app-ID",
|
|
72
|
-
"displayName": "dummy-app-name",
|
|
73
|
-
"name": "http://dummy-app-name",
|
|
74
|
-
"password": "random-password",
|
|
75
|
-
"tenant": "tenant-ID"
|
|
76
|
-
}
|
|
77
|
-
```
|
|
78
|
-
- Use the above returned credentials information to set **AZURE_CLIENT_ID**(appId), **AZURE_CLIENT_SECRET**(password) and **AZURE_TENANT_ID**(tenant) environment variables. The following example shows a way to do this in Bash:
|
|
79
|
-
|
|
80
|
-
```Bash
|
|
81
|
-
export AZURE_CLIENT_ID="generated-app-ID"
|
|
82
|
-
export AZURE_CLIENT_SECRET="random-password"
|
|
83
|
-
export AZURE_TENANT_ID="tenant-ID"
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
- Grant the above mentioned application authorization to perform certificate operations on the keyvault:
|
|
87
|
-
|
|
88
|
-
```Bash
|
|
89
|
-
az keyvault set-policy --name <your-key-vault-name> --spn $AZURE_CLIENT_ID --certificate-permissions backup create delete deleteissuers get getissuers import list listissuers managecontacts manageissuers purge recover restore setissuers update
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
> --certificate-permissions:
|
|
93
|
-
> Accepted values: backup, create, delete, deleteissuers, get, getissuers, import, list, listissuers, managecontacts, manageissuers, purge, recover, restore, setissuers, update
|
|
94
|
-
|
|
95
|
-
If you have enabled role-based access control (RBAC) for Key Vault instead, you can find roles like "Key Vault Certificates Officer" in our [RBAC guide](https://docs.microsoft.com/azure/key-vault/general/rbac-guide).
|
|
96
|
-
|
|
97
|
-
- Use the above mentioned Key Vault name to retrieve details of your Vault which also contains your Key Vault URL:
|
|
98
|
-
```Bash
|
|
99
|
-
az keyvault show --name <your-key-vault-name>
|
|
100
|
-
```
|
|
101
|
-
|
|
102
60
|
## Authenticating with Azure Active Directory
|
|
103
61
|
|
|
104
62
|
The Key Vault service relies on Azure Active Directory to authenticate requests to its APIs. The [`@azure/identity`](https://www.npmjs.com/package/@azure/identity) package provides a variety of credential types that your application can use to do this. The [README for `@azure/identity`](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/README.md) provides more details and samples to get you started.
|
|
105
63
|
|
|
64
|
+
In order to interact with the Azure Key Vault service, you will need to create an instance of the [`CertificateClient`](#creating-and-setting-a-certificate) class, a **vault url** and a credential object. The examples shown in this document use a credential object named [`DefaultAzureCredential`][default_azure_credential], which is appropriate for most scenarios, including local development and production environments. Additionally, we recommend using a [managed identity][managed_identity] for authentication in production environments.
|
|
65
|
+
|
|
66
|
+
You can find more information on different ways of authenticating and their corresponding credential types in the [Azure Identity documentation][azure_identity].
|
|
67
|
+
|
|
106
68
|
Here's a quick example. First, import `DefaultAzureCredential` and `CertificateClient`:
|
|
107
69
|
|
|
108
70
|
```javascript
|
|
@@ -110,16 +72,12 @@ const { DefaultAzureCredential } = require("@azure/identity");
|
|
|
110
72
|
const { CertificateClient } = require("@azure/keyvault-certificates");
|
|
111
73
|
```
|
|
112
74
|
|
|
113
|
-
Once these are imported, we can next connect to the key vault service
|
|
75
|
+
Once these are imported, we can next connect to the key vault service:
|
|
114
76
|
|
|
115
77
|
```javascript
|
|
116
78
|
const { DefaultAzureCredential } = require("@azure/identity");
|
|
117
79
|
const { CertificateClient } = require("@azure/keyvault-certificates");
|
|
118
80
|
|
|
119
|
-
// DefaultAzureCredential expects the following three environment variables:
|
|
120
|
-
// * AZURE_TENANT_ID: The tenant ID in Azure Active Directory
|
|
121
|
-
// * AZURE_CLIENT_ID: The application (client) ID registered in the AAD tenant
|
|
122
|
-
// * AZURE_CLIENT_SECRET: The client secret for the registered application
|
|
123
81
|
const credential = new DefaultAzureCredential();
|
|
124
82
|
|
|
125
83
|
// Build the URL to reach your key vault
|
|
@@ -366,7 +324,7 @@ main();
|
|
|
366
324
|
|
|
367
325
|
### Getting the full information of a certificate
|
|
368
326
|
|
|
369
|
-
Azure
|
|
327
|
+
Azure Key Vault's design makes sharp distinctions between Keys,
|
|
370
328
|
Secrets and Certificates. The Key Vault service's Certificates
|
|
371
329
|
features were designed making use of it's Keys and Secrets capabilities.
|
|
372
330
|
Let's evaluate the composition of a Key Vault Certificate:
|
|
@@ -375,12 +333,12 @@ Let's evaluate the composition of a Key Vault Certificate:
|
|
|
375
333
|
> and secret are also created with the same name. The Key Vault
|
|
376
334
|
> key allows key operations and the Key Vault secret allows retrieval
|
|
377
335
|
> of the certificate value as a secret. A Key Vault certificate
|
|
378
|
-
> also contains public x509 certificate metadata.
|
|
336
|
+
> also contains public x509 certificate metadata.
|
|
379
337
|
> _Source: [Composition of a Certificate][composition-of-a-certificate]._
|
|
380
338
|
|
|
381
339
|
Knowing that the private key is stored in a Key Vault Secret,
|
|
382
340
|
with the public certificate included, we can retrieve it
|
|
383
|
-
by using the
|
|
341
|
+
by using the Key Vault Secrets client.
|
|
384
342
|
|
|
385
343
|
```ts
|
|
386
344
|
// Using the same credential object we used before,
|
|
@@ -402,7 +360,7 @@ fs.writeFileSync("myCertificate.p12", PKCS12Certificate);
|
|
|
402
360
|
```
|
|
403
361
|
|
|
404
362
|
Note that, by default, the content type of the certificates
|
|
405
|
-
is
|
|
363
|
+
is PKCS 12. By specifying the content type
|
|
406
364
|
of your certificate, you'll be able to retrieve it in PEM format.
|
|
407
365
|
Before showing how to create PEM certificates,
|
|
408
366
|
let's first explore how to retrieve a PEM secret key
|
|
@@ -691,12 +649,20 @@ See our [troubleshooting guide](https://github.com/Azure/azure-sdk-for-js/blob/m
|
|
|
691
649
|
|
|
692
650
|
You can find more code samples through the following links:
|
|
693
651
|
|
|
694
|
-
- [
|
|
695
|
-
- [
|
|
696
|
-
- [
|
|
652
|
+
- [Key Vault Certificates Samples (JavaScript)](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/keyvault-certificates/samples/v4/javascript)
|
|
653
|
+
- [Key Vault Certificates Samples (TypeScript)](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/keyvault-certificates/samples/v4/typescript)
|
|
654
|
+
- [Key Vault Certificates Test Cases](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/keyvault-certificates/test/)
|
|
697
655
|
|
|
698
656
|
## Contributing
|
|
699
657
|
|
|
700
658
|
If you'd like to contribute to this library, please read the [contributing guide](https://github.com/Azure/azure-sdk-for-js/blob/main/CONTRIBUTING.md) to learn more about how to build and test the code.
|
|
701
659
|
|
|
660
|
+
[azure_keyvault]: https://docs.microsoft.com/azure/key-vault/general/overview
|
|
661
|
+
[azure_keyvault_cli]: https://docs.microsoft.com/azure/key-vault/general/quick-create-cli
|
|
662
|
+
[azure_keyvault_portal]: https://docs.microsoft.com/azure/key-vault/general/quick-create-portal
|
|
663
|
+
[default_azure_credential]: https://docs.microsoft.com/java/api/overview/azure/identity-readme?view=azure-java-stable#defaultazurecredential
|
|
664
|
+
[managed_identity]: https://docs.microsoft.com/azure/active-directory/managed-identities-azure-resources/overview
|
|
665
|
+
[azure_identity]: https://docs.microsoft.com/java/api/overview/azure/identity-readme?view=azure-java-stable
|
|
666
|
+
[composition-of-a-certificate]: https://docs.microsoft.com/azure/key-vault/certificates/about-certificates#composition-of-a-certificate
|
|
667
|
+
|
|
702
668
|

|
package/dist/index.js
CHANGED
|
@@ -1617,7 +1617,7 @@ class KeyVaultClient extends coreHttpCompat__namespace.ExtendedServiceClient {
|
|
|
1617
1617
|
const defaults = {
|
|
1618
1618
|
requestContentType: "application/json; charset=utf-8"
|
|
1619
1619
|
};
|
|
1620
|
-
const packageDetails = `azsdk-js-keyvault-certificates/4.5.0
|
|
1620
|
+
const packageDetails = `azsdk-js-keyvault-certificates/4.5.0`;
|
|
1621
1621
|
const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
|
|
1622
1622
|
? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`
|
|
1623
1623
|
: `${packageDetails}`;
|
|
@@ -3100,7 +3100,7 @@ function getPropertiesFromCertificateBundle(certificateBundle) {
|
|
|
3100
3100
|
|
|
3101
3101
|
// Copyright (c) Microsoft Corporation.
|
|
3102
3102
|
// Licensed under the MIT license.
|
|
3103
|
-
const SDK_VERSION = "4.5.0
|
|
3103
|
+
const SDK_VERSION = "4.5.0";
|
|
3104
3104
|
|
|
3105
3105
|
// Copyright (c) Microsoft Corporation.
|
|
3106
3106
|
const tracingClient = coreTracing.createTracingClient({
|