@azure/keyvault-certificates 4.9.1-alpha.20250210.1 → 4.9.1-alpha.20250211.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.
- package/README.md +173 -196
- package/dist/browser/identifier.d.ts +1 -1
- package/dist/browser/identifier.js +1 -1
- package/dist/browser/identifier.js.map +1 -1
- package/dist/browser/index.d.ts +371 -149
- package/dist/browser/index.d.ts.map +1 -1
- package/dist/browser/index.js +371 -149
- package/dist/browser/index.js.map +1 -1
- package/dist/commonjs/identifier.d.ts +1 -1
- package/dist/commonjs/identifier.js +1 -1
- package/dist/commonjs/identifier.js.map +1 -1
- package/dist/commonjs/index.d.ts +371 -149
- package/dist/commonjs/index.d.ts.map +1 -1
- package/dist/commonjs/index.js +371 -149
- package/dist/commonjs/index.js.map +1 -1
- package/dist/esm/identifier.d.ts +1 -1
- package/dist/esm/identifier.js +1 -1
- package/dist/esm/identifier.js.map +1 -1
- package/dist/esm/index.d.ts +371 -149
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +371 -149
- package/dist/esm/index.js.map +1 -1
- package/dist/react-native/identifier.d.ts +1 -1
- package/dist/react-native/identifier.js +1 -1
- package/dist/react-native/identifier.js.map +1 -1
- package/dist/react-native/index.d.ts +371 -149
- package/dist/react-native/index.d.ts.map +1 -1
- package/dist/react-native/index.js +371 -149
- package/dist/react-native/index.js.map +1 -1
- package/package.json +18 -18
|
@@ -38,12 +38,22 @@ export declare class CertificateClient {
|
|
|
38
38
|
* in the response. No values are returned for the certificates. This operations requires the certificates/list permission.
|
|
39
39
|
*
|
|
40
40
|
* Example usage:
|
|
41
|
-
* ```ts
|
|
42
|
-
*
|
|
41
|
+
* ```ts snippet:IndexListCertificates
|
|
42
|
+
* import { DefaultAzureCredential } from "@azure/identity";
|
|
43
|
+
* import { CertificateClient } from "@azure/keyvault-certificates";
|
|
44
|
+
*
|
|
45
|
+
* const credential = new DefaultAzureCredential();
|
|
46
|
+
*
|
|
47
|
+
* const vaultName = "<YOUR KEYVAULT NAME>";
|
|
48
|
+
* const keyVaultUrl = `https://${vaultName}.vault.azure.net`;
|
|
49
|
+
*
|
|
50
|
+
* const client = new CertificateClient(keyVaultUrl, credential);
|
|
51
|
+
*
|
|
43
52
|
* // All in one call
|
|
44
53
|
* for await (const certificateProperties of client.listPropertiesOfCertificates()) {
|
|
45
54
|
* console.log(certificateProperties);
|
|
46
55
|
* }
|
|
56
|
+
*
|
|
47
57
|
* // By pages
|
|
48
58
|
* for await (const page of client.listPropertiesOfCertificates().byPage()) {
|
|
49
59
|
* for (const certificateProperties of page) {
|
|
@@ -60,9 +70,20 @@ export declare class CertificateClient {
|
|
|
60
70
|
* vault. This operation requires the certificates/list permission.
|
|
61
71
|
*
|
|
62
72
|
* Example usage:
|
|
63
|
-
* ```ts
|
|
64
|
-
*
|
|
65
|
-
*
|
|
73
|
+
* ```ts snippet:IndexListCertificateVersions
|
|
74
|
+
* import { DefaultAzureCredential } from "@azure/identity";
|
|
75
|
+
* import { CertificateClient } from "@azure/keyvault-certificates";
|
|
76
|
+
*
|
|
77
|
+
* const credential = new DefaultAzureCredential();
|
|
78
|
+
*
|
|
79
|
+
* const vaultName = "<YOUR KEYVAULT NAME>";
|
|
80
|
+
* const keyVaultUrl = `https://${vaultName}.vault.azure.net`;
|
|
81
|
+
*
|
|
82
|
+
* const client = new CertificateClient(keyVaultUrl, credential);
|
|
83
|
+
*
|
|
84
|
+
* for await (const certificateProperties of client.listPropertiesOfCertificateVersions(
|
|
85
|
+
* "MyCertificate",
|
|
86
|
+
* )) {
|
|
66
87
|
* console.log(certificateProperties.version!);
|
|
67
88
|
* }
|
|
68
89
|
* ```
|
|
@@ -79,25 +100,38 @@ export declare class CertificateClient {
|
|
|
79
100
|
* This operation requires the certificates/delete permission.
|
|
80
101
|
*
|
|
81
102
|
* Example usage:
|
|
82
|
-
* ```ts
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
* issuerName: "Self",
|
|
86
|
-
* subject: "cn=MyCert"
|
|
87
|
-
* });
|
|
88
|
-
* await createPoller.pollUntilDone();
|
|
103
|
+
* ```ts snippet:ReadmeSampleDeleteCertificate
|
|
104
|
+
* import { DefaultAzureCredential } from "@azure/identity";
|
|
105
|
+
* import { CertificateClient } from "@azure/keyvault-certificates";
|
|
89
106
|
*
|
|
90
|
-
* const
|
|
107
|
+
* const credential = new DefaultAzureCredential();
|
|
91
108
|
*
|
|
92
|
-
*
|
|
93
|
-
* const
|
|
109
|
+
* const vaultName = "<YOUR KEYVAULT NAME>";
|
|
110
|
+
* const keyVaultUrl = `https://${vaultName}.vault.azure.net`;
|
|
94
111
|
*
|
|
95
|
-
*
|
|
96
|
-
* // const newPoller = await client.beginDeleteCertificate("MyCertificate", { resumeFrom: serialized });
|
|
112
|
+
* const client = new CertificateClient(keyVaultUrl, credential);
|
|
97
113
|
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
*
|
|
114
|
+
* const certificateName = "MyCertificate";
|
|
115
|
+
*
|
|
116
|
+
* const poller = await client.beginDeleteCertificate(certificateName);
|
|
117
|
+
*
|
|
118
|
+
* // You can use the deleted certificate immediately:
|
|
119
|
+
* const deletedCertificate = poller.getResult();
|
|
120
|
+
*
|
|
121
|
+
* // The certificate is being deleted. Only wait for it if you want to restore it or purge it.
|
|
122
|
+
* await poller.pollUntilDone();
|
|
123
|
+
*
|
|
124
|
+
* // You can also get the deleted certificate this way:
|
|
125
|
+
* await client.getDeletedCertificate(certificateName);
|
|
126
|
+
*
|
|
127
|
+
* // Deleted certificates can also be recovered or purged.
|
|
128
|
+
*
|
|
129
|
+
* // recoverDeletedCertificate returns a poller, just like beginDeleteCertificate.
|
|
130
|
+
* // const recoverPoller = await client.beginRecoverDeletedCertificate(certificateName);
|
|
131
|
+
* // await recoverPoller.pollUntilDone();
|
|
132
|
+
*
|
|
133
|
+
* // If a certificate is done and the Key Vault has soft-delete enabled, the certificate can be purged with:
|
|
134
|
+
* await client.purgeDeletedCertificate(certificateName);
|
|
101
135
|
* ```
|
|
102
136
|
* Deletes a certificate from a specified key vault.
|
|
103
137
|
* @param certificateName - The name of the certificate.
|
|
@@ -108,13 +142,17 @@ export declare class CertificateClient {
|
|
|
108
142
|
* Deletes all of the certificate contacts. This operation requires the certificates/managecontacts permission.
|
|
109
143
|
*
|
|
110
144
|
* Example usage:
|
|
111
|
-
* ```ts
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
*
|
|
145
|
+
* ```ts snippet:CertificateClientDeleteContacts
|
|
146
|
+
* import { DefaultAzureCredential } from "@azure/identity";
|
|
147
|
+
* import { CertificateClient } from "@azure/keyvault-certificates";
|
|
148
|
+
*
|
|
149
|
+
* const credential = new DefaultAzureCredential();
|
|
150
|
+
*
|
|
151
|
+
* const vaultName = "<YOUR KEYVAULT NAME>";
|
|
152
|
+
* const keyVaultUrl = `https://${vaultName}.vault.azure.net`;
|
|
153
|
+
*
|
|
154
|
+
* const client = new CertificateClient(keyVaultUrl, credential);
|
|
155
|
+
*
|
|
118
156
|
* await client.deleteContacts();
|
|
119
157
|
* ```
|
|
120
158
|
* Deletes all of the certificate contacts
|
|
@@ -125,13 +163,24 @@ export declare class CertificateClient {
|
|
|
125
163
|
* Sets the certificate contacts for the key vault. This operation requires the certificates/managecontacts permission.
|
|
126
164
|
*
|
|
127
165
|
* Example usage:
|
|
128
|
-
* ```ts
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
*
|
|
166
|
+
* ```ts snippet:CertificateClientSetContacts
|
|
167
|
+
* import { DefaultAzureCredential } from "@azure/identity";
|
|
168
|
+
* import { CertificateClient } from "@azure/keyvault-certificates";
|
|
169
|
+
*
|
|
170
|
+
* const credential = new DefaultAzureCredential();
|
|
171
|
+
*
|
|
172
|
+
* const vaultName = "<YOUR KEYVAULT NAME>";
|
|
173
|
+
* const keyVaultUrl = `https://${vaultName}.vault.azure.net`;
|
|
174
|
+
*
|
|
175
|
+
* const client = new CertificateClient(keyVaultUrl, credential);
|
|
176
|
+
*
|
|
177
|
+
* await client.setContacts([
|
|
178
|
+
* {
|
|
179
|
+
* email: "b@b.com",
|
|
180
|
+
* name: "b",
|
|
181
|
+
* phone: "222222222222",
|
|
182
|
+
* },
|
|
183
|
+
* ]);
|
|
135
184
|
* ```
|
|
136
185
|
* Sets the certificate contacts.
|
|
137
186
|
* @param contacts - The contacts to use
|
|
@@ -142,15 +191,21 @@ export declare class CertificateClient {
|
|
|
142
191
|
* Returns the set of certificate contact resources in the specified key vault. This operation requires the certificates/managecontacts permission.
|
|
143
192
|
*
|
|
144
193
|
* Example usage:
|
|
145
|
-
* ```ts
|
|
146
|
-
*
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
*
|
|
150
|
-
*
|
|
151
|
-
*
|
|
194
|
+
* ```ts snippet:CertificateClientGetContacts
|
|
195
|
+
* import { DefaultAzureCredential } from "@azure/identity";
|
|
196
|
+
* import { CertificateClient } from "@azure/keyvault-certificates";
|
|
197
|
+
*
|
|
198
|
+
* const credential = new DefaultAzureCredential();
|
|
199
|
+
*
|
|
200
|
+
* const vaultName = "<YOUR KEYVAULT NAME>";
|
|
201
|
+
* const keyVaultUrl = `https://${vaultName}.vault.azure.net`;
|
|
202
|
+
*
|
|
203
|
+
* const client = new CertificateClient(keyVaultUrl, credential);
|
|
204
|
+
*
|
|
152
205
|
* const contacts = await client.getContacts();
|
|
153
|
-
*
|
|
206
|
+
* for (const contact of contacts) {
|
|
207
|
+
* console.log(contact);
|
|
208
|
+
* }
|
|
154
209
|
* ```
|
|
155
210
|
* Sets the certificate contacts.
|
|
156
211
|
* @param options - The optional parameters
|
|
@@ -160,13 +215,24 @@ export declare class CertificateClient {
|
|
|
160
215
|
* Returns the set of certificate issuer resources in the specified key vault. This operation requires the certificates/manageissuers/getissuers permission.
|
|
161
216
|
*
|
|
162
217
|
* Example usage:
|
|
163
|
-
* ```ts
|
|
164
|
-
*
|
|
218
|
+
* ```ts snippet:CertificateClientListIssuers
|
|
219
|
+
* import { DefaultAzureCredential } from "@azure/identity";
|
|
220
|
+
* import { CertificateClient } from "@azure/keyvault-certificates";
|
|
221
|
+
*
|
|
222
|
+
* const credential = new DefaultAzureCredential();
|
|
223
|
+
*
|
|
224
|
+
* const vaultName = "<YOUR KEYVAULT NAME>";
|
|
225
|
+
* const keyVaultUrl = `https://${vaultName}.vault.azure.net`;
|
|
226
|
+
*
|
|
227
|
+
* const client = new CertificateClient(keyVaultUrl, credential);
|
|
228
|
+
*
|
|
165
229
|
* await client.createIssuer("IssuerName", "Test");
|
|
230
|
+
*
|
|
166
231
|
* // All in one call
|
|
167
232
|
* for await (const issuerProperties of client.listPropertiesOfIssuers()) {
|
|
168
233
|
* console.log(issuerProperties);
|
|
169
234
|
* }
|
|
235
|
+
*
|
|
170
236
|
* // By pages
|
|
171
237
|
* for await (const page of client.listPropertiesOfIssuers().byPage()) {
|
|
172
238
|
* for (const issuerProperties of page) {
|
|
@@ -183,8 +249,17 @@ export declare class CertificateClient {
|
|
|
183
249
|
* operation requires the certificates/setissuers permission.
|
|
184
250
|
*
|
|
185
251
|
* Example usage:
|
|
186
|
-
* ```ts
|
|
187
|
-
*
|
|
252
|
+
* ```ts snippet:CertificateClientCreateIssuer
|
|
253
|
+
* import { DefaultAzureCredential } from "@azure/identity";
|
|
254
|
+
* import { CertificateClient } from "@azure/keyvault-certificates";
|
|
255
|
+
*
|
|
256
|
+
* const credential = new DefaultAzureCredential();
|
|
257
|
+
*
|
|
258
|
+
* const vaultName = "<YOUR KEYVAULT NAME>";
|
|
259
|
+
* const keyVaultUrl = `https://${vaultName}.vault.azure.net`;
|
|
260
|
+
*
|
|
261
|
+
* const client = new CertificateClient(keyVaultUrl, credential);
|
|
262
|
+
*
|
|
188
263
|
* await client.createIssuer("IssuerName", "Test");
|
|
189
264
|
* ```
|
|
190
265
|
* Sets the specified certificate issuer.
|
|
@@ -198,11 +273,19 @@ export declare class CertificateClient {
|
|
|
198
273
|
* entity. This operation requires the certificates/setissuers permission.
|
|
199
274
|
*
|
|
200
275
|
* Example usage:
|
|
201
|
-
* ```ts
|
|
202
|
-
*
|
|
203
|
-
*
|
|
276
|
+
* ```ts snippet:CertificateClientUpdateIssuer
|
|
277
|
+
* import { DefaultAzureCredential } from "@azure/identity";
|
|
278
|
+
* import { CertificateClient } from "@azure/keyvault-certificates";
|
|
279
|
+
*
|
|
280
|
+
* const credential = new DefaultAzureCredential();
|
|
281
|
+
*
|
|
282
|
+
* const vaultName = "<YOUR KEYVAULT NAME>";
|
|
283
|
+
* const keyVaultUrl = `https://${vaultName}.vault.azure.net`;
|
|
284
|
+
*
|
|
285
|
+
* const client = new CertificateClient(keyVaultUrl, credential);
|
|
286
|
+
*
|
|
204
287
|
* await client.updateIssuer("IssuerName", {
|
|
205
|
-
* provider: "Provider2"
|
|
288
|
+
* provider: "Provider2",
|
|
206
289
|
* });
|
|
207
290
|
* ```
|
|
208
291
|
* Updates the specified certificate issuer.
|
|
@@ -216,9 +299,17 @@ export declare class CertificateClient {
|
|
|
216
299
|
* permission.
|
|
217
300
|
*
|
|
218
301
|
* Example usage:
|
|
219
|
-
* ```ts
|
|
220
|
-
*
|
|
221
|
-
*
|
|
302
|
+
* ```ts snippet:CertificateClientGetIssuer
|
|
303
|
+
* import { DefaultAzureCredential } from "@azure/identity";
|
|
304
|
+
* import { CertificateClient } from "@azure/keyvault-certificates";
|
|
305
|
+
*
|
|
306
|
+
* const credential = new DefaultAzureCredential();
|
|
307
|
+
*
|
|
308
|
+
* const vaultName = "<YOUR KEYVAULT NAME>";
|
|
309
|
+
* const keyVaultUrl = `https://${vaultName}.vault.azure.net`;
|
|
310
|
+
*
|
|
311
|
+
* const client = new CertificateClient(keyVaultUrl, credential);
|
|
312
|
+
*
|
|
222
313
|
* const certificateIssuer = await client.getIssuer("IssuerName");
|
|
223
314
|
* console.log(certificateIssuer);
|
|
224
315
|
* ```
|
|
@@ -232,9 +323,17 @@ export declare class CertificateClient {
|
|
|
232
323
|
* the vault. This operation requires the certificates/manageissuers/deleteissuers permission.
|
|
233
324
|
*
|
|
234
325
|
* Example usage:
|
|
235
|
-
* ```ts
|
|
236
|
-
*
|
|
237
|
-
*
|
|
326
|
+
* ```ts snippet:CertificateClientDeleteIssuer
|
|
327
|
+
* import { DefaultAzureCredential } from "@azure/identity";
|
|
328
|
+
* import { CertificateClient } from "@azure/keyvault-certificates";
|
|
329
|
+
*
|
|
330
|
+
* const credential = new DefaultAzureCredential();
|
|
331
|
+
*
|
|
332
|
+
* const vaultName = "<YOUR KEYVAULT NAME>";
|
|
333
|
+
* const keyVaultUrl = `https://${vaultName}.vault.azure.net`;
|
|
334
|
+
*
|
|
335
|
+
* const client = new CertificateClient(keyVaultUrl, credential);
|
|
336
|
+
*
|
|
238
337
|
* await client.deleteIssuer("IssuerName");
|
|
239
338
|
* ```
|
|
240
339
|
* Deletes the specified certificate issuer.
|
|
@@ -251,26 +350,31 @@ export declare class CertificateClient {
|
|
|
251
350
|
* This operation requires the certificates/create permission.
|
|
252
351
|
*
|
|
253
352
|
* Example usage:
|
|
254
|
-
* ```ts
|
|
255
|
-
*
|
|
353
|
+
* ```ts snippet:ReadmeSampleCreateCertificatePoller
|
|
354
|
+
* import { DefaultAzureCredential } from "@azure/identity";
|
|
355
|
+
* import { CertificateClient } from "@azure/keyvault-certificates";
|
|
356
|
+
*
|
|
357
|
+
* const credential = new DefaultAzureCredential();
|
|
358
|
+
*
|
|
359
|
+
* const vaultName = "<YOUR KEYVAULT NAME>";
|
|
360
|
+
* const url = `https://${vaultName}.vault.azure.net`;
|
|
361
|
+
*
|
|
362
|
+
* const client = new CertificateClient(url, credential);
|
|
363
|
+
*
|
|
364
|
+
* const certificateName = "MyCertificateName";
|
|
256
365
|
* const certificatePolicy = {
|
|
257
366
|
* issuerName: "Self",
|
|
258
|
-
* subject: "cn=MyCert"
|
|
367
|
+
* subject: "cn=MyCert",
|
|
259
368
|
* };
|
|
260
|
-
* const createPoller = await client.beginCreateCertificate("MyCertificate", certificatePolicy);
|
|
261
369
|
*
|
|
262
|
-
*
|
|
263
|
-
* const pendingCertificate = createPoller.getResult();
|
|
370
|
+
* const poller = await client.beginCreateCertificate(certificateName, certificatePolicy);
|
|
264
371
|
*
|
|
265
|
-
* //
|
|
266
|
-
* const
|
|
267
|
-
*
|
|
268
|
-
* // A new poller can be created with:
|
|
269
|
-
* // const newPoller = await client.beginCreateCertificate("MyCertificate", certificatePolicy, { resumeFrom: serialized });
|
|
372
|
+
* // You can use the pending certificate immediately:
|
|
373
|
+
* const pendingCertificate = poller.getResult();
|
|
270
374
|
*
|
|
271
|
-
* //
|
|
272
|
-
* const
|
|
273
|
-
* console.log(
|
|
375
|
+
* // Or you can wait until the certificate finishes being signed:
|
|
376
|
+
* const keyVaultCertificate = await poller.pollUntilDone();
|
|
377
|
+
* console.log(keyVaultCertificate);
|
|
274
378
|
* ```
|
|
275
379
|
* Creates a certificate
|
|
276
380
|
* @param certificateName - The name of the certificate
|
|
@@ -282,15 +386,21 @@ export declare class CertificateClient {
|
|
|
282
386
|
* Gets the latest information available from a specific certificate, including the certificate's policy. This operation requires the certificates/get permission.
|
|
283
387
|
*
|
|
284
388
|
* Example usage:
|
|
285
|
-
* ```ts
|
|
286
|
-
*
|
|
287
|
-
*
|
|
288
|
-
*
|
|
289
|
-
*
|
|
290
|
-
*
|
|
291
|
-
*
|
|
292
|
-
* const
|
|
293
|
-
*
|
|
389
|
+
* ```ts snippet:CertificateClientGetCertificate
|
|
390
|
+
* import { DefaultAzureCredential } from "@azure/identity";
|
|
391
|
+
* import { CertificateClient } from "@azure/keyvault-certificates";
|
|
392
|
+
*
|
|
393
|
+
* const credential = new DefaultAzureCredential();
|
|
394
|
+
*
|
|
395
|
+
* const vaultName = "<YOUR KEYVAULT NAME>";
|
|
396
|
+
* const keyVaultUrl = `https://${vaultName}.vault.azure.net`;
|
|
397
|
+
*
|
|
398
|
+
* const client = new CertificateClient(keyVaultUrl, credential);
|
|
399
|
+
*
|
|
400
|
+
* const certificateName = "MyCertificate";
|
|
401
|
+
*
|
|
402
|
+
* const result = await client.getCertificate(certificateName);
|
|
403
|
+
* console.log(result.name);
|
|
294
404
|
* ```
|
|
295
405
|
* Retrieves a certificate from the certificate's name (includes the certificate policy)
|
|
296
406
|
* @param certificateName - The name of the certificate
|
|
@@ -301,16 +411,29 @@ export declare class CertificateClient {
|
|
|
301
411
|
* Gets information about a specific certificate on a specific version. It won't return the certificate's policy. This operation requires the certificates/get permission.
|
|
302
412
|
*
|
|
303
413
|
* Example usage:
|
|
304
|
-
* ```ts
|
|
305
|
-
*
|
|
306
|
-
*
|
|
307
|
-
*
|
|
308
|
-
*
|
|
309
|
-
*
|
|
310
|
-
*
|
|
311
|
-
* const
|
|
312
|
-
*
|
|
313
|
-
*
|
|
414
|
+
* ```ts snippet:CertificateClientGetCertificateVersion
|
|
415
|
+
* import { DefaultAzureCredential } from "@azure/identity";
|
|
416
|
+
* import { CertificateClient } from "@azure/keyvault-certificates";
|
|
417
|
+
*
|
|
418
|
+
* const credential = new DefaultAzureCredential();
|
|
419
|
+
*
|
|
420
|
+
* const vaultName = "<YOUR KEYVAULT NAME>";
|
|
421
|
+
* const url = `https://${vaultName}.vault.azure.net`;
|
|
422
|
+
*
|
|
423
|
+
* const client = new CertificateClient(url, credential);
|
|
424
|
+
*
|
|
425
|
+
* const certificateName = "MyCertificateName";
|
|
426
|
+
*
|
|
427
|
+
* const latestCertificate = await client.getCertificate(certificateName);
|
|
428
|
+
* console.log(`Latest version of the certificate ${certificateName}: `, latestCertificate);
|
|
429
|
+
* const specificCertificate = await client.getCertificateVersion(
|
|
430
|
+
* certificateName,
|
|
431
|
+
* latestCertificate.properties.version,
|
|
432
|
+
* );
|
|
433
|
+
* console.log(
|
|
434
|
+
* `The certificate ${certificateName} at the version ${latestCertificate.properties.version}: `,
|
|
435
|
+
* specificCertificate,
|
|
436
|
+
* );
|
|
314
437
|
* ```
|
|
315
438
|
* Retrieves a certificate from the certificate's name and a specified version
|
|
316
439
|
* @param certificateName - The name of the certificate
|
|
@@ -323,19 +446,26 @@ export declare class CertificateClient {
|
|
|
323
446
|
* If the certificate is in PEM format the PEM file must contain the key as well as x509 certificates. This operation requires the certificates/import permission.
|
|
324
447
|
*
|
|
325
448
|
* Example usage:
|
|
326
|
-
* ```ts
|
|
327
|
-
*
|
|
328
|
-
*
|
|
449
|
+
* ```ts snippet:CertificateClientImportCertificate
|
|
450
|
+
* import { DefaultAzureCredential } from "@azure/identity";
|
|
451
|
+
* import { CertificateClient } from "@azure/keyvault-certificates";
|
|
452
|
+
* import { SecretClient } from "@azure/keyvault-secrets";
|
|
453
|
+
* import { isNodeLike } from "@azure/core-util";
|
|
454
|
+
*
|
|
455
|
+
* const credential = new DefaultAzureCredential();
|
|
456
|
+
*
|
|
457
|
+
* const vaultName = "<YOUR KEYVAULT NAME>";
|
|
458
|
+
* const url = `https://${vaultName}.vault.azure.net`;
|
|
459
|
+
*
|
|
460
|
+
* const client = new CertificateClient(url, credential);
|
|
461
|
+
* const secretClient = new SecretClient(url, credential);
|
|
462
|
+
*
|
|
329
463
|
* const certificateSecret = await secretClient.getSecret("MyCertificate");
|
|
330
464
|
* const base64EncodedCertificate = certificateSecret.value!;
|
|
331
|
-
* let buffer: Uint8Array;
|
|
332
|
-
*
|
|
333
|
-
* if (isNode) {
|
|
334
|
-
* buffer = Buffer.from(base64EncodedCertificate, "base64");
|
|
335
|
-
* } else {
|
|
336
|
-
* buffer = Uint8Array.from(atob(base64EncodedCertificate), (c) => c.charCodeAt(0));
|
|
337
|
-
* }
|
|
338
465
|
*
|
|
466
|
+
* const buffer = isNodeLike
|
|
467
|
+
* ? Buffer.from(base64EncodedCertificate, "base64")
|
|
468
|
+
* : Uint8Array.from(atob(base64EncodedCertificate), (c) => c.charCodeAt(0));
|
|
339
469
|
* await client.importCertificate("MyCertificate", buffer);
|
|
340
470
|
* ```
|
|
341
471
|
* Imports a certificate from a certificate's secret value
|
|
@@ -348,12 +478,17 @@ export declare class CertificateClient {
|
|
|
348
478
|
* The getCertificatePolicy operation returns the specified certificate policy resources in the specified key vault. This operation requires the certificates/get permission.
|
|
349
479
|
*
|
|
350
480
|
* Example usage:
|
|
351
|
-
* ```ts
|
|
352
|
-
*
|
|
353
|
-
*
|
|
354
|
-
*
|
|
355
|
-
*
|
|
356
|
-
*
|
|
481
|
+
* ```ts snippet:CertificateClientGetCertificatePolicy
|
|
482
|
+
* import { DefaultAzureCredential } from "@azure/identity";
|
|
483
|
+
* import { CertificateClient } from "@azure/keyvault-certificates";
|
|
484
|
+
*
|
|
485
|
+
* const credential = new DefaultAzureCredential();
|
|
486
|
+
*
|
|
487
|
+
* const vaultName = "<YOUR KEYVAULT NAME>";
|
|
488
|
+
* const url = `https://${vaultName}.vault.azure.net`;
|
|
489
|
+
*
|
|
490
|
+
* const client = new CertificateClient(url, credential);
|
|
491
|
+
*
|
|
357
492
|
* const policy = await client.getCertificatePolicy("MyCertificate");
|
|
358
493
|
* console.log(policy);
|
|
359
494
|
* ```
|
|
@@ -375,19 +510,23 @@ export declare class CertificateClient {
|
|
|
375
510
|
* certificate's attributes. This operation requires the certificates/update permission.
|
|
376
511
|
*
|
|
377
512
|
* Example usage:
|
|
378
|
-
* ```ts
|
|
379
|
-
*
|
|
380
|
-
*
|
|
381
|
-
*
|
|
382
|
-
*
|
|
383
|
-
*
|
|
513
|
+
* ```ts snippet:CertificateClientUpdateCertificate
|
|
514
|
+
* import { DefaultAzureCredential } from "@azure/identity";
|
|
515
|
+
* import { CertificateClient } from "@azure/keyvault-certificates";
|
|
516
|
+
*
|
|
517
|
+
* const credential = new DefaultAzureCredential();
|
|
518
|
+
*
|
|
519
|
+
* const vaultName = "<YOUR KEYVAULT NAME>";
|
|
520
|
+
* const url = `https://${vaultName}.vault.azure.net`;
|
|
521
|
+
*
|
|
522
|
+
* const client = new CertificateClient(url, credential);
|
|
384
523
|
*
|
|
385
524
|
* // You may pass an empty string for version which will update
|
|
386
525
|
* // the latest version of the certificate
|
|
387
526
|
* await client.updateCertificateProperties("MyCertificate", "", {
|
|
388
527
|
* tags: {
|
|
389
|
-
* customTag: "value"
|
|
390
|
-
* }
|
|
528
|
+
* customTag: "value",
|
|
529
|
+
* },
|
|
391
530
|
* });
|
|
392
531
|
* ```
|
|
393
532
|
* Updates a certificate
|
|
@@ -401,11 +540,20 @@ export declare class CertificateClient {
|
|
|
401
540
|
* This function returns a Long Running Operation poller that allows you to wait indefinitely until the certificate is fully recovered.
|
|
402
541
|
*
|
|
403
542
|
* Example usage:
|
|
404
|
-
* ```ts
|
|
405
|
-
*
|
|
543
|
+
* ```ts snippet:CertificateClientGetCertificateOperation
|
|
544
|
+
* import { DefaultAzureCredential } from "@azure/identity";
|
|
545
|
+
* import { CertificateClient } from "@azure/keyvault-certificates";
|
|
546
|
+
*
|
|
547
|
+
* const credential = new DefaultAzureCredential();
|
|
548
|
+
*
|
|
549
|
+
* const vaultName = "<YOUR KEYVAULT NAME>";
|
|
550
|
+
* const url = `https://${vaultName}.vault.azure.net`;
|
|
551
|
+
*
|
|
552
|
+
* const client = new CertificateClient(url, credential);
|
|
553
|
+
*
|
|
406
554
|
* const createPoller = await client.beginCreateCertificate("MyCertificate", {
|
|
407
555
|
* issuerName: "Self",
|
|
408
|
-
* subject: "cn=MyCert"
|
|
556
|
+
* subject: "cn=MyCert",
|
|
409
557
|
* });
|
|
410
558
|
*
|
|
411
559
|
* const poller = await client.getCertificateOperation("MyCertificate");
|
|
@@ -424,14 +572,24 @@ export declare class CertificateClient {
|
|
|
424
572
|
* The certificate is no longer created. This operation requires the certificates/update permission.
|
|
425
573
|
*
|
|
426
574
|
* Example usage:
|
|
427
|
-
* ```ts
|
|
428
|
-
*
|
|
575
|
+
* ```ts snippet:CertificateClientDeleteCertificateOperation
|
|
576
|
+
* import { DefaultAzureCredential } from "@azure/identity";
|
|
577
|
+
* import { CertificateClient } from "@azure/keyvault-certificates";
|
|
578
|
+
*
|
|
579
|
+
* const credential = new DefaultAzureCredential();
|
|
580
|
+
*
|
|
581
|
+
* const vaultName = "<YOUR KEYVAULT NAME>";
|
|
582
|
+
* const url = `https://${vaultName}.vault.azure.net`;
|
|
583
|
+
*
|
|
584
|
+
* const client = new CertificateClient(url, credential);
|
|
585
|
+
*
|
|
429
586
|
* await client.beginCreateCertificate("MyCertificate", {
|
|
430
587
|
* issuerName: "Self",
|
|
431
|
-
* subject: "cn=MyCert"
|
|
588
|
+
* subject: "cn=MyCert",
|
|
432
589
|
* });
|
|
433
590
|
* await client.deleteCertificateOperation("MyCertificate");
|
|
434
|
-
*
|
|
591
|
+
*
|
|
592
|
+
* await client.getCertificateOperation("MyCertificate");
|
|
435
593
|
* ```
|
|
436
594
|
* Delete a certificate's operation
|
|
437
595
|
* @param certificateName - The name of the certificate
|
|
@@ -442,28 +600,41 @@ export declare class CertificateClient {
|
|
|
442
600
|
* Performs the merging of a certificate or certificate chain with a key pair currently available in the service. This operation requires the certificates/create permission.
|
|
443
601
|
*
|
|
444
602
|
* Example usage:
|
|
445
|
-
* ```ts
|
|
446
|
-
*
|
|
603
|
+
* ```ts snippet:CertificateClientMergeCertificate
|
|
604
|
+
* import { DefaultAzureCredential } from "@azure/identity";
|
|
605
|
+
* import { CertificateClient } from "@azure/keyvault-certificates";
|
|
606
|
+
* import { writeFileSync, readFileSync } from "node:fs";
|
|
607
|
+
* import { execSync } from "node:child_process";
|
|
608
|
+
*
|
|
609
|
+
* const credential = new DefaultAzureCredential();
|
|
610
|
+
*
|
|
611
|
+
* const vaultName = "<YOUR KEYVAULT NAME>";
|
|
612
|
+
* const url = `https://${vaultName}.vault.azure.net`;
|
|
613
|
+
*
|
|
614
|
+
* const client = new CertificateClient(url, credential);
|
|
615
|
+
*
|
|
447
616
|
* await client.beginCreateCertificate("MyCertificate", {
|
|
448
617
|
* issuerName: "Unknown",
|
|
449
|
-
* subject: "cn=MyCert"
|
|
618
|
+
* subject: "cn=MyCert",
|
|
450
619
|
* });
|
|
451
620
|
* const poller = await client.getCertificateOperation("MyCertificate");
|
|
452
621
|
* const { csr } = poller.getOperationState().certificateOperation!;
|
|
453
622
|
* const base64Csr = Buffer.from(csr!).toString("base64");
|
|
454
|
-
* const wrappedCsr = [
|
|
623
|
+
* const wrappedCsr = [
|
|
624
|
+
* "-----BEGIN CERTIFICATE REQUEST-----",
|
|
625
|
+
* base64Csr,
|
|
626
|
+
* "-----END CERTIFICATE REQUEST-----",
|
|
627
|
+
* ].join("\n");
|
|
455
628
|
*
|
|
456
|
-
*
|
|
457
|
-
* fs.writeFileSync("test.csr", wrappedCsr);
|
|
629
|
+
* writeFileSync("test.csr", wrappedCsr);
|
|
458
630
|
*
|
|
459
631
|
* // Certificate available locally made using:
|
|
460
632
|
* // openssl genrsa -out ca.key 2048
|
|
461
633
|
* // openssl req -new -x509 -key ca.key -out ca.crt
|
|
462
634
|
* // You can read more about how to create a fake certificate authority here: https://gist.github.com/Soarez/9688998
|
|
463
635
|
*
|
|
464
|
-
*
|
|
465
|
-
*
|
|
466
|
-
* const base64Crt = fs.readFileSync("test.crt").toString().split("\n").slice(1, -1).join("");
|
|
636
|
+
* execSync("openssl x509 -req -in test.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out test.crt");
|
|
637
|
+
* const base64Crt = readFileSync("test.crt").toString().split("\n").slice(1, -1).join("");
|
|
467
638
|
*
|
|
468
639
|
* await client.mergeCertificate("MyCertificate", [Buffer.from(base64Crt)]);
|
|
469
640
|
* ```
|
|
@@ -478,11 +649,20 @@ export declare class CertificateClient {
|
|
|
478
649
|
* This operation requires the certificates/backup permission.
|
|
479
650
|
*
|
|
480
651
|
* Example usage:
|
|
481
|
-
* ```ts
|
|
482
|
-
*
|
|
652
|
+
* ```ts snippet:CertificateClientBackupCertificate
|
|
653
|
+
* import { DefaultAzureCredential } from "@azure/identity";
|
|
654
|
+
* import { CertificateClient } from "@azure/keyvault-certificates";
|
|
655
|
+
*
|
|
656
|
+
* const credential = new DefaultAzureCredential();
|
|
657
|
+
*
|
|
658
|
+
* const vaultName = "<YOUR KEYVAULT NAME>";
|
|
659
|
+
* const url = `https://${vaultName}.vault.azure.net`;
|
|
660
|
+
*
|
|
661
|
+
* const client = new CertificateClient(url, credential);
|
|
662
|
+
*
|
|
483
663
|
* await client.beginCreateCertificate("MyCertificate", {
|
|
484
664
|
* issuerName: "Self",
|
|
485
|
-
* subject: "cn=MyCert"
|
|
665
|
+
* subject: "cn=MyCert",
|
|
486
666
|
* });
|
|
487
667
|
* const backup = await client.backupCertificate("MyCertificate");
|
|
488
668
|
* ```
|
|
@@ -495,15 +675,26 @@ export declare class CertificateClient {
|
|
|
495
675
|
* Restores a backed up certificate, and all its versions, to a vault. This operation requires the certificates/restore permission.
|
|
496
676
|
*
|
|
497
677
|
* Example usage:
|
|
498
|
-
* ```ts
|
|
499
|
-
*
|
|
678
|
+
* ```ts snippet:CertificateClientRestoreCertificateBackup
|
|
679
|
+
* import { DefaultAzureCredential } from "@azure/identity";
|
|
680
|
+
* import { CertificateClient } from "@azure/keyvault-certificates";
|
|
681
|
+
*
|
|
682
|
+
* const credential = new DefaultAzureCredential();
|
|
683
|
+
*
|
|
684
|
+
* const vaultName = "<YOUR KEYVAULT NAME>";
|
|
685
|
+
* const url = `https://${vaultName}.vault.azure.net`;
|
|
686
|
+
*
|
|
687
|
+
* const client = new CertificateClient(url, credential);
|
|
688
|
+
*
|
|
500
689
|
* await client.beginCreateCertificate("MyCertificate", {
|
|
501
690
|
* issuerName: "Self",
|
|
502
|
-
* subject: "cn=MyCert"
|
|
691
|
+
* subject: "cn=MyCert",
|
|
503
692
|
* });
|
|
504
693
|
* const backup = await client.backupCertificate("MyCertificate");
|
|
694
|
+
*
|
|
505
695
|
* const poller = await client.beginDeleteCertificate("MyCertificate");
|
|
506
696
|
* await poller.pollUntilDone();
|
|
697
|
+
*
|
|
507
698
|
* // Some time is required before we're able to restore the certificate
|
|
508
699
|
* await client.restoreCertificateBackup(backup!);
|
|
509
700
|
* ```
|
|
@@ -517,11 +708,21 @@ export declare class CertificateClient {
|
|
|
517
708
|
* information. This operation requires the certificates/get/list permission. This operation can only be enabled on soft-delete enabled vaults.
|
|
518
709
|
*
|
|
519
710
|
* Example usage:
|
|
520
|
-
* ```ts
|
|
521
|
-
*
|
|
711
|
+
* ```ts snippet:CertificateClientListDeletedCertificates
|
|
712
|
+
* import { DefaultAzureCredential } from "@azure/identity";
|
|
713
|
+
* import { CertificateClient } from "@azure/keyvault-certificates";
|
|
714
|
+
*
|
|
715
|
+
* const credential = new DefaultAzureCredential();
|
|
716
|
+
*
|
|
717
|
+
* const vaultName = "<YOUR KEYVAULT NAME>";
|
|
718
|
+
* const url = `https://${vaultName}.vault.azure.net`;
|
|
719
|
+
*
|
|
720
|
+
* const client = new CertificateClient(url, credential);
|
|
721
|
+
*
|
|
522
722
|
* for await (const deletedCertificate of client.listDeletedCertificates()) {
|
|
523
723
|
* console.log(deletedCertificate);
|
|
524
724
|
* }
|
|
725
|
+
*
|
|
525
726
|
* for await (const page of client.listDeletedCertificates().byPage()) {
|
|
526
727
|
* for (const deletedCertificate of page) {
|
|
527
728
|
* console.log(deletedCertificate);
|
|
@@ -537,8 +738,17 @@ export declare class CertificateClient {
|
|
|
537
738
|
* current deletion recovery level. This operation requires the certificates/get permission.
|
|
538
739
|
*
|
|
539
740
|
* Example usage:
|
|
540
|
-
* ```ts
|
|
541
|
-
*
|
|
741
|
+
* ```ts snippet:CertificateClientGetDeletedCertificate
|
|
742
|
+
* import { DefaultAzureCredential } from "@azure/identity";
|
|
743
|
+
* import { CertificateClient } from "@azure/keyvault-certificates";
|
|
744
|
+
*
|
|
745
|
+
* const credential = new DefaultAzureCredential();
|
|
746
|
+
*
|
|
747
|
+
* const vaultName = "<YOUR KEYVAULT NAME>";
|
|
748
|
+
* const url = `https://${vaultName}.vault.azure.net`;
|
|
749
|
+
*
|
|
750
|
+
* const client = new CertificateClient(url, credential);
|
|
751
|
+
*
|
|
542
752
|
* const deletedCertificate = await client.getDeletedCertificate("MyDeletedCertificate");
|
|
543
753
|
* console.log("Deleted certificate:", deletedCertificate);
|
|
544
754
|
* ```
|
|
@@ -552,10 +762,20 @@ export declare class CertificateClient {
|
|
|
552
762
|
* recovery level does not specify 'Purgeable'. This operation requires the certificate/purge permission.
|
|
553
763
|
*
|
|
554
764
|
* Example usage:
|
|
555
|
-
* ```ts
|
|
556
|
-
*
|
|
765
|
+
* ```ts snippet:CertificateClientPurgeDeletedCertificate
|
|
766
|
+
* import { DefaultAzureCredential } from "@azure/identity";
|
|
767
|
+
* import { CertificateClient } from "@azure/keyvault-certificates";
|
|
768
|
+
*
|
|
769
|
+
* const credential = new DefaultAzureCredential();
|
|
770
|
+
*
|
|
771
|
+
* const vaultName = "<YOUR KEYVAULT NAME>";
|
|
772
|
+
* const url = `https://${vaultName}.vault.azure.net`;
|
|
773
|
+
*
|
|
774
|
+
* const client = new CertificateClient(url, credential);
|
|
775
|
+
*
|
|
557
776
|
* const deletePoller = await client.beginDeleteCertificate("MyCertificate");
|
|
558
777
|
* await deletePoller.pollUntilDone();
|
|
778
|
+
*
|
|
559
779
|
* // Deleting a certificate takes time, make sure to wait before purging it
|
|
560
780
|
* client.purgeDeletedCertificate("MyCertificate");
|
|
561
781
|
* ```
|
|
@@ -571,20 +791,22 @@ export declare class CertificateClient {
|
|
|
571
791
|
* This operation requires the certificates/recover permission.
|
|
572
792
|
*
|
|
573
793
|
* Example usage:
|
|
574
|
-
* ```ts
|
|
575
|
-
*
|
|
794
|
+
* ```ts snippet:CertificateClientRecoverDeletedCertificate
|
|
795
|
+
* import { DefaultAzureCredential } from "@azure/identity";
|
|
796
|
+
* import { CertificateClient } from "@azure/keyvault-certificates";
|
|
797
|
+
*
|
|
798
|
+
* const credential = new DefaultAzureCredential();
|
|
799
|
+
*
|
|
800
|
+
* const vaultName = "<YOUR KEYVAULT NAME>";
|
|
801
|
+
* const url = `https://${vaultName}.vault.azure.net`;
|
|
802
|
+
*
|
|
803
|
+
* const client = new CertificateClient(url, credential);
|
|
576
804
|
*
|
|
577
805
|
* const deletePoller = await client.beginDeleteCertificate("MyCertificate");
|
|
578
806
|
* await deletePoller.pollUntilDone();
|
|
579
807
|
*
|
|
580
808
|
* const recoverPoller = await client.beginRecoverDeletedCertificate("MyCertificate");
|
|
581
809
|
*
|
|
582
|
-
* // Serializing the poller
|
|
583
|
-
* const serialized = deletePoller.toString();
|
|
584
|
-
*
|
|
585
|
-
* // A new poller can be created with:
|
|
586
|
-
* // const newPoller = await client.beginRecoverDeletedCertificate("MyCertificate", { resumeFrom: serialized });
|
|
587
|
-
*
|
|
588
810
|
* // Waiting until it's done
|
|
589
811
|
* const certificate = await recoverPoller.pollUntilDone();
|
|
590
812
|
* console.log(certificate);
|