Estructura inicial del proyecto

This commit is contained in:
2026-06-02 16:57:08 +00:00
commit 8b306b9afc
9864 changed files with 1435687 additions and 0 deletions

21
backend/node_modules/@azure/keyvault-keys/LICENSE generated vendored Normal file
View File

@ -0,0 +1,21 @@
Copyright (c) Microsoft Corporation.
MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

777
backend/node_modules/@azure/keyvault-keys/README.md generated vendored Normal file
View File

@ -0,0 +1,777 @@
# Azure Key Vault Key client library for JavaScript
Azure Key Vault is a service that allows you to encrypt authentication keys, storage account keys, data encryption keys, .pfx files, and passwords by using secured keys.
If you would like to know more about Azure Key Vault, you may want to review: [What is Azure Key Vault?][keyvault]
Azure Key Vault Managed HSM is a fully-managed, highly-available, single-tenant, standards-compliant cloud service that enables you to safeguard cryptographic keys for your cloud applications using FIPS 140-2 Level 3 validated HSMs. If you would like to know more about Azure Key Vault Managed HSM, you may want to review: [What is Azure Key Vault Managed HSM?][managedhsm]
The Azure Key Vault key library client supports RSA keys, Elliptic Curve (EC) keys, as well as Symmetric (oct) keys when running against a managed HSM, each with corresponding support in hardware security modules (HSM). It offers operations to create, retrieve, update, delete, purge, backup, restore, and list the keys and its versions.
Use the client library for Azure Key Vault Keys in your Node.js application to:
- Create keys using elliptic curve or RSA encryption, optionally backed by Hardware Security Modules (HSM).
- Import, Delete, and Update keys.
- Get one or more keys and deleted keys, with their attributes.
- Recover a deleted key and restore a backed up key.
- Get the versions of a key.
Using the cryptography client available in this library you also have access to:
- Encrypting
- Decrypting
- Signing
- Verifying
- Wrapping keys
- Unwrapping keys
> Note: This package cannot be used in the browser due to Azure Key Vault service limitations, please refer to [this document][cors] for guidance.
Key links:
- [Source code][package-gh]
- [Package (npm)][package-npm]
- [API Reference Documentation][docs]
- [Product documentation][docs-service]
- [Samples][samples]
## Getting started
### Currently supported environments
- [LTS versions of Node.js](https://github.com/nodejs/release#release-schedule)
### Prerequisites
- An [Azure subscription](https://azure.microsoft.com/free/)
- 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].
- If using Managed HSM, an existing [Azure Key Vault Managed HSM][azure_keyvault_mhsm]. If you need to create a Managed HSM, you can do so using the Azure CLI by following the steps in [this document][azure_keyvault_mhsm_cli].
### Install the package
Install the Azure Key Vault Key client library using npm
`npm install @azure/keyvault-keys`
### Install the identity library
Azure Key Vault clients authenticate using the Azure identity library. Install it as well using npm
`npm install @azure/identity`
### Configure TypeScript
TypeScript users need to have Node type definitions installed:
```bash
npm install @types/node
```
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][tscompileroptions] for more information.
## Key concepts
- The **Key client** is the primary interface to interact with the API methods
related to keys in the Azure Key Vault API from a JavaScript application.
Once initialized, it provides a basic set of methods that can be used to
create, read, update and delete keys.
- A **Key version** is a version of a key in the Key Vault.
Each time a user assigns a value to a unique key name, a new **version**
of that key is created. Retrieving a key by a name will always return
the latest value assigned, unless a specific version is provided to the
query.
- **Soft delete** allows Key Vaults to support deletion and purging as two
separate steps, so deleted keys are not immediately lost. This only happens if the Key Vault
has [soft-delete][softdelete]
enabled.
- A **Key backup** can be generated from any created key. These backups come as
binary data, and can only be used to regenerate a previously deleted key.
- The **Cryptography client** is a separate interface that interacts with the
keys API methods in the Key Vault API. This client focuses only in the
cryptography operations that can be executed using a key that has been
already created in the Key Vault. More about this client in the
[Cryptography](#cryptography) section.
## Authenticating with Azure Active Directory
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/tree/main/sdk/identity/identity/README.md) provides more details and samples to get you started.
In order to interact with the Azure Key Vault service, you will need to create an instance of the `KeyClient` 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.
You can find more information on different ways of authenticating and their corresponding credential types in the [Azure Identity documentation][azure_identity].
Here's a quick example. First, import `DefaultAzureCredential` and `KeyClient`. Once these are imported, we can next connect to the Key Vault service:
```ts snippet:ReadmeSampleCreateClient
import { DefaultAzureCredential } from "@azure/identity";
import { KeyClient } from "@azure/keyvault-keys";
const credential = new DefaultAzureCredential();
// Build the URL to reach your key vault
const vaultName = "<YOUR KEYVAULT NAME>";
const url = `https://${vaultName}.vault.azure.net`; // or `https://${vaultName}.managedhsm.azure.net` for managed HSM.
// Lastly, create our keys client and connect to the service
const client = new KeyClient(url, credential);
```
## Specifying the Azure Key Vault service API version
By default, this package uses the latest Azure Key Vault service version which is `7.2`. You can change the service version being used by setting the option `serviceVersion` in the client constructor as shown below:
```ts snippet:ReadmeSampleCreateClientWithVersion
import { DefaultAzureCredential } from "@azure/identity";
import { KeyClient } from "@azure/keyvault-keys";
const credential = new DefaultAzureCredential();
// Build the URL to reach your key vault
const vaultName = "<YOUR KEYVAULT NAME>";
const url = `https://${vaultName}.vault.azure.net`; // or `https://${vaultName}.managedhsm.azure.net` for managed HSM.
// Change the Azure Key Vault service API version being used via the `serviceVersion` option
const client = new KeyClient(url, credential, {
serviceVersion: "7.0", // Or 7.1
});
```
## Examples
The following sections provide code snippets that cover some of the common
tasks using Azure Key Vault Keys. The scenarios that are covered here consist of:
- [Creating a key](#creating-a-key).
- [Getting a key](#getting-a-key).
- [Creating and updating keys with attributes](#creating-and-updating-keys-with-attributes).
- [Deleting a key](#deleting-a-key).
- [Iterating lists of keys](#iterating-lists-of-keys).
### Creating a key
`createKey` creates a Key to be stored in the Azure Key Vault. If a key with the same name already exists, then a new version of the key is created.
```ts snippet:ReadmeSampleCreateKey
import { DefaultAzureCredential } from "@azure/identity";
import { KeyClient } from "@azure/keyvault-keys";
const credential = new DefaultAzureCredential();
const vaultName = "<YOUR KEYVAULT NAME>";
const url = `https://${vaultName}.vault.azure.net`;
const client = new KeyClient(url, credential);
const keyName = "MyKeyName";
const result = await client.createKey(keyName, "RSA");
console.log("result: ", result);
```
The second parameter sent to `createKey` is the type of the key. The type of keys that are supported will depend on the SKU and whether you are using an Azure Key Vault or an Azure Managed HSM. For an up-to-date list of supported key types please refer to [About keys][aboutkeys]
### Getting a key
The simplest way to read keys back from the vault is to get a key by name. This
will retrieve the most recent version of the key. You can optionally get a
different version of the key if you specify it as part of the optional
parameters.
`getKey` retrieves a key previous stores in the Key Vault.
```ts snippet:ReadmeSampleGetKey
import { DefaultAzureCredential } from "@azure/identity";
import { KeyClient } from "@azure/keyvault-keys";
const credential = new DefaultAzureCredential();
const vaultName = "<YOUR KEYVAULT NAME>";
const url = `https://${vaultName}.vault.azure.net`;
const client = new KeyClient(url, credential);
const keyName = "MyKeyName";
const latestKey = await client.getKey(keyName);
console.log(`Latest version of the key ${keyName}: `, latestKey);
const specificKey = await client.getKey(keyName, { version: latestKey.properties.version! });
console.log(`The key ${keyName} at the version ${latestKey.properties.version!}: `, specificKey);
```
### Creating and updating keys with attributes
The following attributes can also be assigned to any key in a Key Vault:
- `tags`: Any set of key-values that can be used to search and filter keys.
- `keyOps`: An array of the operations that this key will be able to perform (`encrypt`, `decrypt`, `sign`, `verify`, `wrapKey`, `unwrapKey`).
- `enabled`: A boolean value that determines whether the key value can be read or not.
- `notBefore`: A given date after which the key value can be retrieved.
- `expires`: A given date after which the key value cannot be retrieved.
An object with these attributes can be sent as the third parameter of
`createKey`, right after the key's name and value, as follows:
```ts snippet:ReadmeSampleCreateKeyWithAttributes
import { DefaultAzureCredential } from "@azure/identity";
import { KeyClient } from "@azure/keyvault-keys";
const credential = new DefaultAzureCredential();
const vaultName = "<YOUR KEYVAULT NAME>";
const url = `https://${vaultName}.vault.azure.net`;
const client = new KeyClient(url, credential);
const keyName = "MyKeyName";
const result = await client.createKey(keyName, "RSA", {
enabled: false,
});
console.log("result: ", result);
```
This will create a new version of the same key, which will have the latest
provided attributes.
Attributes can also be updated to an existing key version with
`updateKeyProperties`, as follows:
```ts snippet:ReadmeSampleUpdateKeyProperties
import { DefaultAzureCredential } from "@azure/identity";
import { KeyClient } from "@azure/keyvault-keys";
const credential = new DefaultAzureCredential();
const vaultName = "<YOUR KEYVAULT NAME>";
const url = `https://${vaultName}.vault.azure.net`;
const client = new KeyClient(url, credential);
const keyName = "MyKeyName";
const result = await client.createKey(keyName, "RSA");
await client.updateKeyProperties(keyName, result.properties.version, {
enabled: false,
});
```
### Deleting a key
The `beginDeleteKey` method starts the deletion of a key.
This process will happen in the background as soon as the necessary resources
are available.
```ts snippet:ReadmeSampleDeleteKey
import { DefaultAzureCredential } from "@azure/identity";
import { KeyClient } from "@azure/keyvault-keys";
const credential = new DefaultAzureCredential();
const vaultName = "<YOUR KEYVAULT NAME>";
const url = `https://${vaultName}.vault.azure.net`;
const client = new KeyClient(url, credential);
const keyName = "MyKeyName";
const poller = await client.beginDeleteKey(keyName);
await poller.pollUntilDone();
```
If [soft-delete][softdelete]
is enabled for the Key Vault, this operation will only label the key as a
_deleted_ key. A deleted key can't be updated. They can only be
read, recovered or purged.
```ts snippet:ReadmeSampleDeleteKeySoftDelete
import { DefaultAzureCredential } from "@azure/identity";
import { KeyClient } from "@azure/keyvault-keys";
const credential = new DefaultAzureCredential();
const vaultName = "<YOUR KEYVAULT NAME>";
const url = `https://${vaultName}.vault.azure.net`;
const client = new KeyClient(url, credential);
const keyName = "MyKeyName";
const poller = await client.beginDeleteKey(keyName);
// You can use the deleted key immediately:
const deletedKey = poller.getResult();
// The key is being deleted. Only wait for it if you want to restore it or purge it.
await poller.pollUntilDone();
// You can also get the deleted key this way:
await client.getDeletedKey(keyName);
// Deleted keys can also be recovered or purged:
// recoverDeletedKey also returns a poller, just like beginDeleteKey.
const recoverPoller = await client.beginRecoverDeletedKey(keyName);
await recoverPoller.pollUntilDone();
// And here is how to purge a deleted key
await client.purgeDeletedKey(keyName);
```
Since Keys take some time to get fully deleted, `beginDeleteKey`
returns a Poller object that keeps track of the underlying Long Running
Operation according to our guidelines:
https://azure.github.io/azure-sdk/typescript_design.html#ts-lro
The received poller will allow you to get the deleted key by calling to `poller.getResult()`.
You can also wait until the deletion finishes either by running individual service
calls until the key is deleted, or by waiting until the process is done:
```ts snippet:ReadmeSampleDeleteKeyWait
import { DefaultAzureCredential } from "@azure/identity";
import { KeyClient } from "@azure/keyvault-keys";
const credential = new DefaultAzureCredential();
const vaultName = "<YOUR KEYVAULT NAME>";
const url = `https://${vaultName}.vault.azure.net`;
const client = new KeyClient(url, credential);
const keyName = "MyKeyName";
const poller = await client.beginDeleteKey(keyName);
// You can use the deleted key immediately:
let deletedKey = poller.getResult();
// Or you can wait until the key finishes being deleted:
deletedKey = await poller.pollUntilDone();
console.log(deletedKey);
```
Another way to wait until the key is fully deleted is to do individual calls, as follows:
```ts snippet:ReadmeSampleDeleteKeyWaitIndividually
import { DefaultAzureCredential } from "@azure/identity";
import { KeyClient } from "@azure/keyvault-keys";
const credential = new DefaultAzureCredential();
const vaultName = "<YOUR KEYVAULT NAME>";
const url = `https://${vaultName}.vault.azure.net`;
const client = new KeyClient(url, credential);
const keyName = "MyKeyName";
const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
const poller = await client.beginDeleteKey(keyName);
while (!poller.isDone()) {
await poller.poll();
await delay(5000);
}
console.log(`The key ${keyName} is fully deleted`);
```
### Configuring Automatic Key Rotation
Using the KeyClient, you can configure automatic key rotation for a key by specifying the rotation policy.
In addition, KeyClient provides a method to rotate a key on-demand by creating a new version of the given key.
```ts snippet:ReadmeSampleKeyRotation
import { DefaultAzureCredential } from "@azure/identity";
import { KeyClient } from "@azure/keyvault-keys";
const credential = new DefaultAzureCredential();
const vaultName = "<YOUR KEYVAULT NAME>";
const url = `https://${vaultName}.vault.azure.net`;
const client = new KeyClient(url, credential);
const keyName = "MyKeyName";
// Set the key's automated rotation policy to rotate the key 30 days before expiry.
const policy = await client.updateKeyRotationPolicy(keyName, {
lifetimeActions: [
{
action: "Rotate",
timeBeforeExpiry: "P30D",
},
],
// You may also specify the duration after which any newly rotated key will expire.
// In this case, any new key versions will expire after 90 days.
expiresIn: "P90D",
});
// You can get the current key rotation policy of a given key by calling the getKeyRotationPolicy method.
const currentPolicy = await client.getKeyRotationPolicy(keyName);
// Finally, you can rotate a key on-demand by creating a new version of the given key.
const rotatedKey = await client.rotateKey(keyName);
```
### Iterating lists of keys
Using the KeyClient, you can retrieve and iterate through all of the
keys in an Azure Key Vault, as well as through all of the deleted keys and the
versions of a specific key. The following API methods are available:
- `listPropertiesOfKeys` will list all of your non-deleted keys by their names, only
at their latest versions.
- `listDeletedKeys` will list all of your deleted keys by their names,
only at their latest versions.
- `listPropertiesOfKeyVersions` will list all the versions of a key based on a key
name.
Which can be used as follows:
```ts snippet:ReadmeSampleListKeys
import { DefaultAzureCredential } from "@azure/identity";
import { KeyClient } from "@azure/keyvault-keys";
const credential = new DefaultAzureCredential();
const vaultName = "<YOUR KEYVAULT NAME>";
const url = `https://${vaultName}.vault.azure.net`;
const client = new KeyClient(url, credential);
const keyName = "MyKeyName";
for await (const keyProperties of client.listPropertiesOfKeys()) {
console.log("Key properties: ", keyProperties);
}
for await (const deletedKey of client.listDeletedKeys()) {
console.log("Deleted: ", deletedKey);
}
for await (const versionProperties of client.listPropertiesOfKeyVersions(keyName)) {
console.log("Version properties: ", versionProperties);
}
```
All of these methods will return **all of the available results** at once. To
retrieve them by pages, add `.byPage()` right after invoking the API method you
want to use, as follows:
```ts snippet:ReadmeSampleListKeysByPage
import { DefaultAzureCredential } from "@azure/identity";
import { KeyClient } from "@azure/keyvault-keys";
const credential = new DefaultAzureCredential();
const vaultName = "<YOUR KEYVAULT NAME>";
const url = `https://${vaultName}.vault.azure.net`;
const client = new KeyClient(url, credential);
const keyName = "MyKeyName";
for await (const page of client.listPropertiesOfKeys().byPage()) {
for (const keyProperties of page) {
console.log("Key properties: ", keyProperties);
}
}
for await (const page of client.listDeletedKeys().byPage()) {
for (const deletedKey of page) {
console.log("Deleted key: ", deletedKey);
}
}
for await (const page of client.listPropertiesOfKeyVersions(keyName).byPage()) {
for (const versionProperties of page) {
console.log("Version: ", versionProperties);
}
}
```
## Cryptography
This library also offers a set of cryptographic utilities available through
`CryptographyClient`. Similar to the `KeyClient`, `CryptographyClient` will
connect to Azure Key Vault with the provided set of credentials. Once
connected, `CryptographyClient` can encrypt, decrypt, sign, verify, wrap keys,
and unwrap keys.
We can next connect to the key vault service just as we do with the `KeyClient`.
We'll need to copy some settings from the key vault we are
connecting to into our environment variables. Once they are in our environment,
we can access them with the following code:
```ts snippet:ReadmeSampleCreateCryptographyClient
import { DefaultAzureCredential } from "@azure/identity";
import { KeyClient, CryptographyClient } from "@azure/keyvault-keys";
const credential = new DefaultAzureCredential();
const vaultName = "<YOUR KEYVAULT NAME>";
const url = `https://${vaultName}.vault.azure.net`;
const client = new KeyClient(url, credential);
// Create or retrieve a key from the keyvault
const myKey = await client.createKey("MyKey", "RSA");
// Lastly, create our cryptography client and connect to the service
const cryptographyClient = new CryptographyClient(myKey, credential);
```
### Encrypt
`encrypt` will encrypt a message.
```ts snippet:ReadmeSampleEncrypt
import { DefaultAzureCredential } from "@azure/identity";
import { KeyClient, CryptographyClient } from "@azure/keyvault-keys";
const credential = new DefaultAzureCredential();
const vaultName = "<YOUR KEYVAULT NAME>";
const url = `https://${vaultName}.vault.azure.net`;
const client = new KeyClient(url, credential);
const myKey = await client.createKey("MyKey", "RSA");
const cryptographyClient = new CryptographyClient(myKey.id, credential);
const encryptResult = await cryptographyClient.encrypt({
algorithm: "RSA1_5",
plaintext: Buffer.from("My Message"),
});
console.log("encrypt result: ", encryptResult.result);
```
### Decrypt
`decrypt` will decrypt an encrypted message.
```ts snippet:ReadmeSampleDecrypt
import { DefaultAzureCredential } from "@azure/identity";
import { KeyClient, CryptographyClient } from "@azure/keyvault-keys";
const credential = new DefaultAzureCredential();
const vaultName = "<YOUR KEYVAULT NAME>";
const url = `https://${vaultName}.vault.azure.net`;
const client = new KeyClient(url, credential);
const myKey = await client.createKey("MyKey", "RSA");
const cryptographyClient = new CryptographyClient(myKey.id, credential);
const encryptResult = await cryptographyClient.encrypt({
algorithm: "RSA1_5",
plaintext: Buffer.from("My Message"),
});
console.log("encrypt result: ", encryptResult.result);
const decryptResult = await cryptographyClient.decrypt({
algorithm: "RSA1_5",
ciphertext: encryptResult.result,
});
console.log("decrypt result: ", decryptResult.result.toString());
```
### Sign
`sign` will cryptographically sign the digest (hash) of a message with a signature.
```ts snippet:ReadmeSampleSign
import { DefaultAzureCredential } from "@azure/identity";
import { KeyClient, CryptographyClient } from "@azure/keyvault-keys";
import { createHash } from "node:crypto";
const credential = new DefaultAzureCredential();
const vaultName = "<YOUR KEYVAULT NAME>";
const url = `https://${vaultName}.vault.azure.net`;
const client = new KeyClient(url, credential);
let myKey = await client.createKey("MyKey", "RSA");
const cryptographyClient = new CryptographyClient(myKey, credential);
const signatureValue = "MySignature";
const hash = createHash("sha256");
const digest = hash.update(signatureValue).digest();
console.log("digest: ", digest);
const signResult = await cryptographyClient.sign("RS256", digest);
console.log("sign result: ", signResult.result);
```
### Sign Data
`signData` will cryptographically sign a message with a signature.
```ts snippet:ReadmeSampleSignData
import { DefaultAzureCredential } from "@azure/identity";
import { KeyClient, CryptographyClient } from "@azure/keyvault-keys";
const credential = new DefaultAzureCredential();
const vaultName = "<YOUR KEYVAULT NAME>";
const url = `https://${vaultName}.vault.azure.net`;
const client = new KeyClient(url, credential);
const myKey = await client.createKey("MyKey", "RSA");
const cryptographyClient = new CryptographyClient(myKey, credential);
const signResult = await cryptographyClient.signData("RS256", Buffer.from("My Message"));
console.log("sign result: ", signResult.result);
```
### Verify
`verify` will cryptographically verify that the signed digest was signed with the given signature.
```ts snippet:ReadmeSampleVerify
import { DefaultAzureCredential } from "@azure/identity";
import { KeyClient, CryptographyClient } from "@azure/keyvault-keys";
import { createHash } from "node:crypto";
const credential = new DefaultAzureCredential();
const vaultName = "<YOUR KEYVAULT NAME>";
const url = `https://${vaultName}.vault.azure.net`;
const client = new KeyClient(url, credential);
const myKey = await client.createKey("MyKey", "RSA");
const cryptographyClient = new CryptographyClient(myKey, credential);
const hash = createHash("sha256");
hash.update("My Message");
const digest = hash.digest();
const signResult = await cryptographyClient.sign("RS256", digest);
console.log("sign result: ", signResult.result);
const verifyResult = await cryptographyClient.verify("RS256", digest, signResult.result);
console.log("verify result: ", verifyResult.result);
```
### Verify Data
`verifyData` will cryptographically verify that the signed message was signed with the given signature.
```ts snippet:ReadmeSampleVerifyData
import { DefaultAzureCredential } from "@azure/identity";
import { KeyClient, CryptographyClient } from "@azure/keyvault-keys";
const credential = new DefaultAzureCredential();
const vaultName = "<YOUR KEYVAULT NAME>";
const url = `https://${vaultName}.vault.azure.net`;
const client = new KeyClient(url, credential);
const myKey = await client.createKey("MyKey", "RSA");
const cryptographyClient = new CryptographyClient(myKey, credential);
const buffer = Buffer.from("My Message");
const signResult = await cryptographyClient.signData("RS256", buffer);
console.log("sign result: ", signResult.result);
const verifyResult = await cryptographyClient.verifyData("RS256", buffer, signResult.result);
console.log("verify result: ", verifyResult.result);
```
### Wrap Key
`wrapKey` will wrap a key with an encryption layer.
```ts snippet:ReadmeSampleWrapKey
import { DefaultAzureCredential } from "@azure/identity";
import { KeyClient, CryptographyClient } from "@azure/keyvault-keys";
const credential = new DefaultAzureCredential();
const vaultName = "<YOUR KEYVAULT NAME>";
const url = `https://${vaultName}.vault.azure.net`;
const client = new KeyClient(url, credential);
const myKey = await client.createKey("MyKey", "RSA");
const cryptographyClient = new CryptographyClient(myKey, credential);
const wrapResult = await cryptographyClient.wrapKey("RSA-OAEP", Buffer.from("My Key"));
console.log("wrap result:", wrapResult.result);
```
### Unwrap Key
`unwrapKey` will unwrap a wrapped key.
```ts snippet:ReadmeSampleUnwrapKey
import { DefaultAzureCredential } from "@azure/identity";
import { KeyClient, CryptographyClient } from "@azure/keyvault-keys";
const credential = new DefaultAzureCredential();
const vaultName = "<YOUR KEYVAULT NAME>";
const url = `https://${vaultName}.vault.azure.net`;
const client = new KeyClient(url, credential);
const myKey = await client.createKey("MyKey", "RSA");
const cryptographyClient = new CryptographyClient(myKey, credential);
const wrapResult = await cryptographyClient.wrapKey("RSA-OAEP", Buffer.from("My Key"));
console.log("wrap result:", wrapResult.result);
const unwrapResult = await cryptographyClient.unwrapKey("RSA-OAEP", wrapResult.result);
console.log("unwrap result: ", unwrapResult.result);
```
## Troubleshooting
See our [troubleshooting guide](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/keyvault-keys/TROUBLESHOOTING.md) for details on how to diagnose various failure scenarios.
Enabling logging may help uncover useful information about failures. In order to see a log of HTTP requests and responses, set the `AZURE_LOG_LEVEL` environment variable to `info`. Alternatively, logging can be enabled at runtime by calling `setLogLevel` in the `@azure/logger`:
```ts snippet:SetLogLevel
import { setLogLevel } from "@azure/logger";
setLogLevel("info");
```
## Next steps
You can find more code samples through the following links:
- [Key Vault Keys Samples (JavaScript)](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/keyvault-keys/samples/v4/javascript)
- [Key Vault Keys Samples (TypeScript)](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/keyvault-keys/samples/v4/typescript)
- [Key Vault Keys Test Cases](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/keyvault-keys/test/)
## Contributing
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.
[aboutkeys]: https://learn.microsoft.com/azure/key-vault/keys/about-keys
[keyvault]: https://learn.microsoft.com/azure/key-vault/key-vault-overview
[managedhsm]: https://learn.microsoft.com/azure/key-vault/managed-hsm/overview
[cors]: https://github.com/Azure/azure-sdk-for-js/blob/main/samples/cors/ts/README.md
[package-gh]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/keyvault/keyvault-keys
[package-npm]: https://www.npmjs.com/package/@azure/keyvault-keys
[docs]: https://learn.microsoft.com/javascript/api/@azure/keyvault-keys
[docs-service]: https://azure.microsoft.com/services/key-vault/
[samples]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/keyvault-keys/samples
[tscompileroptions]: https://www.typescriptlang.org/docs/handbook/compiler-options.html
[softdelete]: https://learn.microsoft.com/azure/key-vault/key-vault-ovw-soft-delete
[azure_keyvault]: https://learn.microsoft.com/azure/key-vault/general/overview
[azure_keyvault_cli]: https://learn.microsoft.com/azure/key-vault/general/quick-create-cli
[azure_keyvault_portal]: https://learn.microsoft.com/azure/key-vault/general/quick-create-portal
[azure_keyvault_mhsm]: https://learn.microsoft.com/azure/key-vault/managed-hsm/overview
[azure_keyvault_mhsm_cli]: https://learn.microsoft.com/azure/key-vault/managed-hsm/quick-create-cli
[default_azure_credential]: https://learn.microsoft.com/javascript/api/@azure/identity/defaultazurecredential?view=azure-node-latest
[managed_identity]: https://learn.microsoft.com/azure/active-directory/managed-identities-azure-resources/overview
[azure_identity]: https://learn.microsoft.com/javascript/api/overview/azure/identity-readme?view=azure-node-latest

View File

@ -0,0 +1,2 @@
export declare const SDK_VERSION: string;
//# sourceMappingURL=constants.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,WAAW,EAAE,MAAiB,CAAC"}

View File

@ -0,0 +1,4 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
export const SDK_VERSION = "4.10.0";
//# sourceMappingURL=constants.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,MAAM,CAAC,MAAM,WAAW,GAAW,QAAQ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nexport const SDK_VERSION: string = \"4.10.0\";\n"]}

View File

@ -0,0 +1 @@
{"version":3,"file":"aesCryptographyProvider-browser.d.mts","sourceRoot":"","sources":["../../../src/cryptography/aesCryptographyProvider-browser.mts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,oBAAoB,EAAC,MAAM,aAAa,CAAC;AAGvD;;;;;GAKG;AACH,qBAAa,uBAAwB,YAAW,oBAAoB;IAClE,OAAO,IAAI,KAAK;IAKhB,OAAO,IAAI,KAAK;IAMhB;;OAEG;IACH,WAAW,IAAI,OAAO;IAItB,OAAO,IAAI,KAAK;IAMhB,SAAS,IAAI,KAAK;IAMlB,IAAI,IAAI,KAAK;IAMb,QAAQ,IAAI,KAAK;IAMjB,MAAM,IAAI,KAAK;IAMf,UAAU,IAAI,KAAK;CAKpB"}

View File

@ -0,0 +1 @@
{"version":3,"file":"aesCryptographyProvider-browser.mjs","sourceRoot":"","sources":["../../../src/cryptography/aesCryptographyProvider-browser.mts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,iCAAiC,EAAE,MAAM,aAAa,CAAC;AAEhE;;;;;GAKG;AACH,MAAM,OAAO,uBAAuB;IAClC,OAAO;QACL,MAAM,IAAI,iCAAiC,CACzC,yDAAyD,CAC1D,CAAC;IACJ,CAAC;IACD,OAAO;QACL,MAAM,IAAI,iCAAiC,CACzC,yDAAyD,CAC1D,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,WAAW;QACT,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO;QACL,MAAM,IAAI,iCAAiC,CACzC,yDAAyD,CAC1D,CAAC;IACJ,CAAC;IAED,SAAS;QACP,MAAM,IAAI,iCAAiC,CACzC,yDAAyD,CAC1D,CAAC;IACJ,CAAC;IAED,IAAI;QACF,MAAM,IAAI,iCAAiC,CACzC,yDAAyD,CAC1D,CAAC;IACJ,CAAC;IAED,QAAQ;QACN,MAAM,IAAI,iCAAiC,CACzC,yDAAyD,CAC1D,CAAC;IACJ,CAAC;IAED,MAAM;QACJ,MAAM,IAAI,iCAAiC,CACzC,yDAAyD,CAC1D,CAAC;IACJ,CAAC;IAED,UAAU;QACR,MAAM,IAAI,iCAAiC,CACzC,yDAAyD,CAC1D,CAAC;IACJ,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { CryptographyProvider} from \"./models.js\";\nimport { LocalCryptographyUnsupportedError } from \"./models.js\";\n\n/**\n * The browser replacement of the AesCryptographyProvider. Since we do not\n * support local cryptography in the browser this replacement always returns false\n * for `supportsAlgorithm` and `supportsOperation` so that these methods should\n * never be called.\n */\nexport class AesCryptographyProvider implements CryptographyProvider {\n encrypt(): never {\n throw new LocalCryptographyUnsupportedError(\n \"AES Local cryptography is not supported in the browser.\",\n );\n }\n decrypt(): never {\n throw new LocalCryptographyUnsupportedError(\n \"AES Local cryptography is not supported in the browser.\",\n );\n }\n\n /**\n * Browser RSA provider does not support any algorithms or operations.\n */\n isSupported(): boolean {\n return false;\n }\n\n wrapKey(): never {\n throw new LocalCryptographyUnsupportedError(\n \"AES Local cryptography is not supported in the browser.\",\n );\n }\n\n unwrapKey(): never {\n throw new LocalCryptographyUnsupportedError(\n \"AES Local cryptography is not supported in the browser.\",\n );\n }\n\n sign(): never {\n throw new LocalCryptographyUnsupportedError(\n \"AES Local cryptography is not supported in the browser.\",\n );\n }\n\n signData(): never {\n throw new LocalCryptographyUnsupportedError(\n \"AES Local cryptography is not supported in the browser.\",\n );\n }\n\n verify(): never {\n throw new LocalCryptographyUnsupportedError(\n \"AES Local cryptography is not supported in the browser.\",\n );\n }\n\n verifyData(): never {\n throw new LocalCryptographyUnsupportedError(\n \"AES Local cryptography is not supported in the browser.\",\n );\n }\n}\n"]}

View File

@ -0,0 +1,22 @@
import type { CryptographyProvider } from "./models.js";
/**
* The browser replacement of the AesCryptographyProvider. Since we do not
* support local cryptography in the browser this replacement always returns false
* for `supportsAlgorithm` and `supportsOperation` so that these methods should
* never be called.
*/
export declare class AesCryptographyProvider implements CryptographyProvider {
encrypt(): never;
decrypt(): never;
/**
* Browser RSA provider does not support any algorithms or operations.
*/
isSupported(): boolean;
wrapKey(): never;
unwrapKey(): never;
sign(): never;
signData(): never;
verify(): never;
verifyData(): never;
}
//# sourceMappingURL=aesCryptographyProvider-browser.d.mts.map

View File

@ -0,0 +1,42 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { LocalCryptographyUnsupportedError } from "./models.js";
/**
* The browser replacement of the AesCryptographyProvider. Since we do not
* support local cryptography in the browser this replacement always returns false
* for `supportsAlgorithm` and `supportsOperation` so that these methods should
* never be called.
*/
export class AesCryptographyProvider {
encrypt() {
throw new LocalCryptographyUnsupportedError("AES Local cryptography is not supported in the browser.");
}
decrypt() {
throw new LocalCryptographyUnsupportedError("AES Local cryptography is not supported in the browser.");
}
/**
* Browser RSA provider does not support any algorithms or operations.
*/
isSupported() {
return false;
}
wrapKey() {
throw new LocalCryptographyUnsupportedError("AES Local cryptography is not supported in the browser.");
}
unwrapKey() {
throw new LocalCryptographyUnsupportedError("AES Local cryptography is not supported in the browser.");
}
sign() {
throw new LocalCryptographyUnsupportedError("AES Local cryptography is not supported in the browser.");
}
signData() {
throw new LocalCryptographyUnsupportedError("AES Local cryptography is not supported in the browser.");
}
verify() {
throw new LocalCryptographyUnsupportedError("AES Local cryptography is not supported in the browser.");
}
verifyData() {
throw new LocalCryptographyUnsupportedError("AES Local cryptography is not supported in the browser.");
}
}
//# sourceMappingURL=aesCryptographyProvider-browser.mjs.map

View File

@ -0,0 +1,8 @@
import type { JsonWebKey } from "../keysModels.js";
/**
* @internal
* Encode a JWK to PEM format. To do so, it internally repackages the JWK as a DER
* that is then encoded as a PEM.
*/
export declare function convertJWKtoPEM(key: JsonWebKey): string;
//# sourceMappingURL=conversions.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"conversions.d.ts","sourceRoot":"","sources":["../../../src/cryptography/conversions.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAqFnD;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,UAAU,GAAG,MAAM,CAiBvD"}

View File

@ -0,0 +1,99 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
/**
* @internal
* Encodes a length of a packet in DER format
*/
function encodeLength(length) {
if (length <= 127) {
return Uint8Array.of(length);
}
else if (length < 256) {
return Uint8Array.of(0x81, length);
}
else if (length < 65536) {
return Uint8Array.of(0x82, length >> 8, length & 0xff);
}
else {
throw new Error("Unsupported length to encode");
}
}
/**
* @internal
* Encodes a buffer for DER, as sets the id to the given id
*/
function encodeBuffer(buffer, bufferId) {
if (buffer.length === 0) {
return buffer;
}
let result = new Uint8Array(buffer);
// If the high bit is set, prepend a 0
if (result[0] & 0x80) {
const array = new Uint8Array(result.length + 1);
array[0] = 0;
array.set(result, 1);
result = array;
}
// Prepend the DER header for this buffer
const encodedLength = encodeLength(result.length);
const totalLength = 1 + encodedLength.length + result.length;
const outputBuffer = new Uint8Array(totalLength);
outputBuffer[0] = bufferId;
outputBuffer.set(encodedLength, 1);
outputBuffer.set(result, 1 + encodedLength.length);
return outputBuffer;
}
function makeSequence(encodedParts) {
const totalLength = encodedParts.reduce((sum, part) => sum + part.length, 0);
const sequence = new Uint8Array(totalLength);
for (let i = 0; i < encodedParts.length; i++) {
const previousLength = i > 0 ? encodedParts[i - 1].length : 0;
sequence.set(encodedParts[i], previousLength);
}
const full_encoded = encodeBuffer(sequence, 0x30); // SEQUENCE
return Buffer.from(full_encoded).toString("base64");
}
/**
* Fill in the PEM with 64 character lines as per RFC:
*
* "To represent the encapsulated text of a PEM message, the encoding
* function's output is delimited into text lines (using local
* conventions), with each line except the last containing exactly 64
* printable characters and the final line containing 64 or fewer
* printable characters."
*/
function formatBase64Sequence(base64Sequence) {
const lines = base64Sequence.match(/.{1,64}/g);
let result = "";
if (lines) {
for (const line of lines) {
result += line;
result += "\n";
}
}
else {
throw new Error("Could not create correct PEM");
}
return result;
}
/**
* @internal
* Encode a JWK to PEM format. To do so, it internally repackages the JWK as a DER
* that is then encoded as a PEM.
*/
export function convertJWKtoPEM(key) {
let result = "";
if (key.n && key.e) {
const parts = [key.n, key.e];
const encodedParts = parts.map((part) => encodeBuffer(part, 0x2)); // INTEGER
const base64Sequence = makeSequence(encodedParts);
result += "-----BEGIN RSA PUBLIC KEY-----\n";
result += formatBase64Sequence(base64Sequence);
result += "-----END RSA PUBLIC KEY-----\n";
}
if (!result.length) {
throw new Error("Unsupported key format for local operations");
}
return result.slice(0, -1); // Removing the last new line
}
//# sourceMappingURL=conversions.js.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
{"version":3,"file":"crypto-browser.d.mts","sourceRoot":"","sources":["../../../src/cryptography/crypto-browser.mts"],"names":[],"mappings":"AAKA;;;GAGG;AACH,wBAAsB,UAAU,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAIvF;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,GAAG,KAAK,CAIzE;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,UAAU,CAIvD"}

View File

@ -0,0 +1 @@
{"version":3,"file":"crypto-browser.mjs","sourceRoot":"","sources":["../../../src/cryptography/crypto-browser.mts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,iCAAiC,EAAE,MAAM,aAAa,CAAC;AAEhE;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,UAAkB,EAAE,KAAiB;IACpE,MAAM,IAAI,iCAAiC,CACzC,uDAAuD,CACxD,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,UAAkB,EAAE,KAAiB;IAChE,MAAM,IAAI,iCAAiC,CACzC,uDAAuD,CACxD,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,OAAe;IACzC,MAAM,IAAI,iCAAiC,CACzC,sDAAsD,CACvD,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { LocalCryptographyUnsupportedError } from \"./models.js\";\n\n/**\n * @internal\n * Use the platform-local hashing functionality\n */\nexport async function createHash(_algorithm: string, _data: Uint8Array): Promise<Buffer> {\n throw new LocalCryptographyUnsupportedError(\n \"Our libraries don't currently support browser hashing\",\n );\n}\n\n/**\n * @internal\n * Use the platform-local verify functionality\n */\nexport function createVerify(_algorithm: string, _data: Uint8Array): never {\n throw new LocalCryptographyUnsupportedError(\n \"Our libraries don't currently support browser hashing\",\n );\n}\n\n/**\n * @internal\n * Use the platform-local randomBytes functionality\n */\nexport function randomBytes(_length: number): Uint8Array {\n throw new LocalCryptographyUnsupportedError(\n \"Our libraries don't currently support browser crypto\",\n );\n}\n"]}

View File

@ -0,0 +1,16 @@
/**
* @internal
* Use the platform-local hashing functionality
*/
export declare function createHash(_algorithm: string, _data: Uint8Array): Promise<Buffer>;
/**
* @internal
* Use the platform-local verify functionality
*/
export declare function createVerify(_algorithm: string, _data: Uint8Array): never;
/**
* @internal
* Use the platform-local randomBytes functionality
*/
export declare function randomBytes(_length: number): Uint8Array;
//# sourceMappingURL=crypto-browser.d.mts.map

View File

@ -0,0 +1,25 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { LocalCryptographyUnsupportedError } from "./models.js";
/**
* @internal
* Use the platform-local hashing functionality
*/
export async function createHash(_algorithm, _data) {
throw new LocalCryptographyUnsupportedError("Our libraries don't currently support browser hashing");
}
/**
* @internal
* Use the platform-local verify functionality
*/
export function createVerify(_algorithm, _data) {
throw new LocalCryptographyUnsupportedError("Our libraries don't currently support browser hashing");
}
/**
* @internal
* Use the platform-local randomBytes functionality
*/
export function randomBytes(_length) {
throw new LocalCryptographyUnsupportedError("Our libraries don't currently support browser crypto");
}
//# sourceMappingURL=crypto-browser.mjs.map

View File

@ -0,0 +1,101 @@
import type { OperationOptions } from "@azure-rest/core-client";
import type { DecryptOptions, DecryptParameters, DecryptResult, EncryptOptions, EncryptParameters, EncryptResult, KeyWrapAlgorithm, SignOptions, SignResult, SignatureAlgorithm, UnwrapKeyOptions, UnwrapResult, VerifyOptions, VerifyResult, WrapKeyOptions, WrapResult } from "../index.js";
export declare class LocalCryptographyUnsupportedError extends Error {
}
/**
* The set of operations a {@link CryptographyProvider} supports.
*
* This corresponds to every single method on the interface so that providers
* can declare whether they support this method or not.
*
* Purposely more granular than {@link KnownKeyOperations} because some providers
* support verifyData but not verify.
* @internal
*/
export type CryptographyProviderOperation = "encrypt" | "decrypt" | "wrapKey" | "unwrapKey" | "sign" | "signData" | "verify" | "verifyData";
/**
*
* Represents an object that can perform cryptography operations.
* @internal
*/
export interface CryptographyProvider {
/**
* Encrypts the given plaintext with the specified encryption parameters.
* @internal
*
* @param encryptParameters - The encryption parameters, keyed on the encryption algorithm chosen.
* @param options - Additional options.
*/
encrypt(encryptParameters: EncryptParameters, options?: EncryptOptions): Promise<EncryptResult>;
/**
* Decrypts the given ciphertext with the specified decryption parameters.
* @internal
*
* @param decryptParameters - The decryption parameters.
* @param options - Additional options.
*/
decrypt(decryptParameters: DecryptParameters, options?: DecryptOptions): Promise<DecryptResult>;
/**
*
* @param algorithm - The algorithm to check support for.
* @param operation - The {@link CryptographyProviderOperation} to check support for.
*/
isSupported(algorithm: string, operation: CryptographyProviderOperation): boolean;
/**
* Wraps the given key using the specified cryptography algorithm
* @internal
*
* @param algorithm - The encryption algorithm to use to wrap the given key.
* @param keyToWrap - The key to wrap.
* @param options - Additional options.
*/
wrapKey(algorithm: KeyWrapAlgorithm, keyToWrap: Uint8Array, options?: WrapKeyOptions): Promise<WrapResult>;
/**
* Unwraps the given wrapped key using the specified cryptography algorithm
* @internal
*
* @param algorithm - The decryption algorithm to use to unwrap the key.
* @param encryptedKey - The encrypted key to unwrap.
* @param options - Additional options.
*/
unwrapKey(algorithm: KeyWrapAlgorithm, encryptedKey: Uint8Array, options?: UnwrapKeyOptions): Promise<UnwrapResult>;
/**
* Cryptographically sign the digest of a message
* @internal
*
* @param algorithm - The signing algorithm to use.
* @param digest - The digest of the data to sign.
* @param options - Additional options.
*/
sign(algorithm: SignatureAlgorithm, digest: Uint8Array, options?: SignOptions): Promise<SignResult>;
/**
* Cryptographically sign a block of data
* @internal
*
* @param algorithm - The signing algorithm to use.
* @param data - The data to sign.
* @param options - Additional options.
*/
signData(algorithm: SignatureAlgorithm, data: Uint8Array, options?: SignOptions): Promise<SignResult>;
/**
* Verify the signed message digest
* @internal
*
* @param algorithm - The signing algorithm to use to verify with.
* @param digest - The digest to verify.
* @param signature - The signature to verify the digest against.
* @param options - Additional options.
*/
verify(algorithm: SignatureAlgorithm, digest: Uint8Array, signature: Uint8Array, options?: VerifyOptions): Promise<VerifyResult>;
/**
* Verify the signed block of data
* @internal
*
* @param algorithm - The algorithm to use to verify with.
* @param data - The signed block of data to verify.
* @param signature - The signature to verify the block against.
* @param updatedOptions - Additional options.
*/
verifyData(algorithm: string, data: Uint8Array, signature: Uint8Array, updatedOptions: OperationOptions): Promise<VerifyResult>;
}
//# sourceMappingURL=models.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../../../src/cryptography/models.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,KAAK,EACV,cAAc,EACd,iBAAiB,EACjB,aAAa,EACb,cAAc,EACd,iBAAiB,EACjB,aAAa,EACb,gBAAgB,EAChB,WAAW,EACX,UAAU,EACV,kBAAkB,EAClB,gBAAgB,EAChB,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,cAAc,EACd,UAAU,EACX,MAAM,aAAa,CAAC;AAErB,qBAAa,iCAAkC,SAAQ,KAAK;CAAG;AAE/D;;;;;;;;;GASG;AACH,MAAM,MAAM,6BAA6B,GACrC,SAAS,GACT,SAAS,GACT,SAAS,GACT,WAAW,GACX,MAAM,GACN,UAAU,GACV,QAAQ,GACR,YAAY,CAAC;AAEjB;;;;GAIG;AACH,MAAM,WAAW,oBAAoB;IACnC;;;;;;OAMG;IACH,OAAO,CAAC,iBAAiB,EAAE,iBAAiB,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;IAEhG;;;;;;OAMG;IACH,OAAO,CAAC,iBAAiB,EAAE,iBAAiB,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;IAEhG;;;;OAIG;IACH,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,6BAA6B,GAAG,OAAO,CAAC;IAElF;;;;;;;OAOG;IACH,OAAO,CACL,SAAS,EAAE,gBAAgB,EAC3B,SAAS,EAAE,UAAU,EACrB,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,UAAU,CAAC,CAAC;IAEvB;;;;;;;OAOG;IACH,SAAS,CACP,SAAS,EAAE,gBAAgB,EAC3B,YAAY,EAAE,UAAU,EACxB,OAAO,CAAC,EAAE,gBAAgB,GACzB,OAAO,CAAC,YAAY,CAAC,CAAC;IAEzB;;;;;;;OAOG;IACH,IAAI,CACF,SAAS,EAAE,kBAAkB,EAC7B,MAAM,EAAE,UAAU,EAClB,OAAO,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC,UAAU,CAAC,CAAC;IAEvB;;;;;;;OAOG;IACH,QAAQ,CACN,SAAS,EAAE,kBAAkB,EAC7B,IAAI,EAAE,UAAU,EAChB,OAAO,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC,UAAU,CAAC,CAAC;IAEvB;;;;;;;;OAQG;IACH,MAAM,CACJ,SAAS,EAAE,kBAAkB,EAC7B,MAAM,EAAE,UAAU,EAClB,SAAS,EAAE,UAAU,EACrB,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAAC,YAAY,CAAC,CAAC;IAEzB;;;;;;;;OAQG;IACH,UAAU,CACR,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,UAAU,EAChB,SAAS,EAAE,UAAU,EACrB,cAAc,EAAE,gBAAgB,GAC/B,OAAO,CAAC,YAAY,CAAC,CAAC;CAC1B"}

View File

@ -0,0 +1,5 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
export class LocalCryptographyUnsupportedError extends Error {
}
//# sourceMappingURL=models.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"models.js","sourceRoot":"","sources":["../../../src/cryptography/models.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAsBlC,MAAM,OAAO,iCAAkC,SAAQ,KAAK;CAAG","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { OperationOptions } from \"@azure-rest/core-client\";\nimport type {\n DecryptOptions,\n DecryptParameters,\n DecryptResult,\n EncryptOptions,\n EncryptParameters,\n EncryptResult,\n KeyWrapAlgorithm,\n SignOptions,\n SignResult,\n SignatureAlgorithm,\n UnwrapKeyOptions,\n UnwrapResult,\n VerifyOptions,\n VerifyResult,\n WrapKeyOptions,\n WrapResult,\n} from \"../index.js\";\n\nexport class LocalCryptographyUnsupportedError extends Error {}\n\n/**\n * The set of operations a {@link CryptographyProvider} supports.\n *\n * This corresponds to every single method on the interface so that providers\n * can declare whether they support this method or not.\n *\n * Purposely more granular than {@link KnownKeyOperations} because some providers\n * support verifyData but not verify.\n * @internal\n */\nexport type CryptographyProviderOperation =\n | \"encrypt\"\n | \"decrypt\"\n | \"wrapKey\"\n | \"unwrapKey\"\n | \"sign\"\n | \"signData\"\n | \"verify\"\n | \"verifyData\";\n\n/**\n *\n * Represents an object that can perform cryptography operations.\n * @internal\n */\nexport interface CryptographyProvider {\n /**\n * Encrypts the given plaintext with the specified encryption parameters.\n * @internal\n *\n * @param encryptParameters - The encryption parameters, keyed on the encryption algorithm chosen.\n * @param options - Additional options.\n */\n encrypt(encryptParameters: EncryptParameters, options?: EncryptOptions): Promise<EncryptResult>;\n\n /**\n * Decrypts the given ciphertext with the specified decryption parameters.\n * @internal\n *\n * @param decryptParameters - The decryption parameters.\n * @param options - Additional options.\n */\n decrypt(decryptParameters: DecryptParameters, options?: DecryptOptions): Promise<DecryptResult>;\n\n /**\n *\n * @param algorithm - The algorithm to check support for.\n * @param operation - The {@link CryptographyProviderOperation} to check support for.\n */\n isSupported(algorithm: string, operation: CryptographyProviderOperation): boolean;\n\n /**\n * Wraps the given key using the specified cryptography algorithm\n * @internal\n *\n * @param algorithm - The encryption algorithm to use to wrap the given key.\n * @param keyToWrap - The key to wrap.\n * @param options - Additional options.\n */\n wrapKey(\n algorithm: KeyWrapAlgorithm,\n keyToWrap: Uint8Array,\n options?: WrapKeyOptions,\n ): Promise<WrapResult>;\n\n /**\n * Unwraps the given wrapped key using the specified cryptography algorithm\n * @internal\n *\n * @param algorithm - The decryption algorithm to use to unwrap the key.\n * @param encryptedKey - The encrypted key to unwrap.\n * @param options - Additional options.\n */\n unwrapKey(\n algorithm: KeyWrapAlgorithm,\n encryptedKey: Uint8Array,\n options?: UnwrapKeyOptions,\n ): Promise<UnwrapResult>;\n\n /**\n * Cryptographically sign the digest of a message\n * @internal\n *\n * @param algorithm - The signing algorithm to use.\n * @param digest - The digest of the data to sign.\n * @param options - Additional options.\n */\n sign(\n algorithm: SignatureAlgorithm,\n digest: Uint8Array,\n options?: SignOptions,\n ): Promise<SignResult>;\n\n /**\n * Cryptographically sign a block of data\n * @internal\n *\n * @param algorithm - The signing algorithm to use.\n * @param data - The data to sign.\n * @param options - Additional options.\n */\n signData(\n algorithm: SignatureAlgorithm,\n data: Uint8Array,\n options?: SignOptions,\n ): Promise<SignResult>;\n\n /**\n * Verify the signed message digest\n * @internal\n *\n * @param algorithm - The signing algorithm to use to verify with.\n * @param digest - The digest to verify.\n * @param signature - The signature to verify the digest against.\n * @param options - Additional options.\n */\n verify(\n algorithm: SignatureAlgorithm,\n digest: Uint8Array,\n signature: Uint8Array,\n options?: VerifyOptions,\n ): Promise<VerifyResult>;\n\n /**\n * Verify the signed block of data\n * @internal\n *\n * @param algorithm - The algorithm to use to verify with.\n * @param data - The signed block of data to verify.\n * @param signature - The signature to verify the block against.\n * @param updatedOptions - Additional options.\n */\n verifyData(\n algorithm: string,\n data: Uint8Array,\n signature: Uint8Array,\n updatedOptions: OperationOptions,\n ): Promise<VerifyResult>;\n}\n"]}

View File

@ -0,0 +1,58 @@
import type { TokenCredential } from "@azure/core-auth";
import type { DecryptOptions, DecryptParameters, DecryptResult, EncryptOptions, EncryptParameters, EncryptResult, KeyWrapAlgorithm, SignOptions, SignResult, UnwrapKeyOptions, VerifyOptions, VerifyResult, WrapKeyOptions, WrapResult } from "../cryptographyClientModels.js";
import type { UnwrapResult } from "../cryptographyClientModels.js";
import type { CryptographyClientOptions, GetKeyOptions, KeyVaultKey } from "../keysModels.js";
import type { CryptographyProvider, CryptographyProviderOperation } from "./models.js";
/**
* The remote cryptography provider is used to run crypto operations against KeyVault.
* @internal
*/
export declare class RemoteCryptographyProvider implements CryptographyProvider {
constructor(key: string | KeyVaultKey, credential: TokenCredential, pipelineOptions?: CryptographyClientOptions);
isSupported(_algorithm: string, _operation: CryptographyProviderOperation): boolean;
encrypt(encryptParameters: EncryptParameters, options?: EncryptOptions): Promise<EncryptResult>;
decrypt(decryptParameters: DecryptParameters, options?: DecryptOptions): Promise<DecryptResult>;
wrapKey(algorithm: KeyWrapAlgorithm, keyToWrap: Uint8Array, options?: WrapKeyOptions): Promise<WrapResult>;
unwrapKey(algorithm: KeyWrapAlgorithm, encryptedKey: Uint8Array, options?: UnwrapKeyOptions): Promise<UnwrapResult>;
sign(algorithm: string, digest: Uint8Array, options?: SignOptions): Promise<SignResult>;
verifyData(algorithm: string, data: Uint8Array, signature: Uint8Array, options?: VerifyOptions): Promise<VerifyResult>;
verify(algorithm: string, digest: Uint8Array, signature: Uint8Array, options?: VerifyOptions): Promise<VerifyResult>;
signData(algorithm: string, data: Uint8Array, options?: SignOptions): Promise<SignResult>;
/**
* The base URL to the vault.
*/
readonly vaultUrl: string;
/**
* The ID of the key used to perform cryptographic operations for the client.
*/
get keyId(): string | undefined;
/**
* Gets the {@link KeyVaultKey} used for cryptography operations, fetching it
* from KeyVault if necessary.
* @param options - Additional options.
*/
getKey(options?: GetKeyOptions): Promise<KeyVaultKey>;
/**
* A reference to the auto-generated KeyVault HTTP client.
*/
private client;
/**
* A reference to the key used for the cryptographic operations.
* Based on what was provided to the CryptographyClient constructor,
* it can be either a string with the URL of a Key Vault Key, or an already parsed {@link KeyVaultKey}.
*/
private key;
/**
* Name of the key the client represents
*/
private name;
/**
* Version of the key the client represents
*/
private version;
/**
* Attempts to retrieve the ID of the key.
*/
private getKeyID;
}
//# sourceMappingURL=remoteCryptographyProvider.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"remoteCryptographyProvider.d.ts","sourceRoot":"","sources":["../../../src/cryptography/remoteCryptographyProvider.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAExD,OAAO,KAAK,EACV,cAAc,EACd,iBAAiB,EACjB,aAAa,EACb,cAAc,EACd,iBAAiB,EACjB,aAAa,EACb,gBAAgB,EAChB,WAAW,EACX,UAAU,EACV,gBAAgB,EAChB,aAAa,EACb,YAAY,EACZ,cAAc,EACd,UAAU,EACX,MAAM,gCAAgC,CAAC;AAExC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAInE,OAAO,KAAK,EAAE,yBAAyB,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAI9F,OAAO,KAAK,EAAE,oBAAoB,EAAE,6BAA6B,EAAE,MAAM,aAAa,CAAC;AAMvF;;;GAGG;AACH,qBAAa,0BAA2B,YAAW,oBAAoB;gBAEnE,GAAG,EAAE,MAAM,GAAG,WAAW,EACzB,UAAU,EAAE,eAAe,EAC3B,eAAe,GAAE,yBAA8B;IAkCjD,WAAW,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,6BAA6B,GAAG,OAAO;IAInF,OAAO,CACL,iBAAiB,EAAE,iBAAiB,EACpC,OAAO,GAAE,cAAmB,GAC3B,OAAO,CAAC,aAAa,CAAC;IAmCzB,OAAO,CACL,iBAAiB,EAAE,iBAAiB,EACpC,OAAO,GAAE,cAAmB,GAC3B,OAAO,CAAC,aAAa,CAAC;IAmCzB,OAAO,CACL,SAAS,EAAE,gBAAgB,EAC3B,SAAS,EAAE,UAAU,EACrB,OAAO,GAAE,cAAmB,GAC3B,OAAO,CAAC,UAAU,CAAC;IAwBtB,SAAS,CACP,SAAS,EAAE,gBAAgB,EAC3B,YAAY,EAAE,UAAU,EACxB,OAAO,GAAE,gBAAqB,GAC7B,OAAO,CAAC,YAAY,CAAC;IAwBxB,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,GAAE,WAAgB,GAAG,OAAO,CAAC,UAAU,CAAC;IAoB3F,UAAU,CACR,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,UAAU,EAChB,SAAS,EAAE,UAAU,EACrB,OAAO,GAAE,aAAkB,GAC1B,OAAO,CAAC,YAAY,CAAC;IAWxB,MAAM,CACJ,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,UAAU,EAClB,SAAS,EAAE,UAAU,EACrB,OAAO,GAAE,aAAkB,GAC1B,OAAO,CAAC,YAAY,CAAC;IAuBxB,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,GAAE,WAAgB,GAAG,OAAO,CAAC,UAAU,CAAC;IAoB7F;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAE1B;;OAEG;IACH,IAAI,KAAK,IAAI,MAAM,GAAG,SAAS,CAE9B;IAED;;;;OAIG;IACH,MAAM,CAAC,OAAO,GAAE,aAAkB,GAAG,OAAO,CAAC,WAAW,CAAC;IAqBzD;;OAEG;IACH,OAAO,CAAC,MAAM,CAAiB;IAE/B;;;;OAIG;IACH,OAAO,CAAC,GAAG,CAAuB;IAElC;;OAEG;IACH,OAAO,CAAC,IAAI,CAAS;IAErB;;OAEG;IACH,OAAO,CAAC,OAAO,CAAS;IAExB;;OAEG;IACH,OAAO,CAAC,QAAQ;CAUjB"}

View File

@ -0,0 +1,241 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { __rest } from "tslib";
import { SDK_VERSION } from "../constants.js";
import { KeyVaultClient } from "../generated/index.js";
import { parseKeyVaultKeyIdentifier } from "../identifier.js";
import { LATEST_API_VERSION } from "../keysModels.js";
import { getKeyFromKeyBundle } from "../transformations.js";
import { createHash } from "./crypto.js";
import { logger } from "../log.js";
import { keyVaultAuthenticationPolicy } from "@azure/keyvault-common";
import { tracingClient } from "../tracing.js";
import { bearerTokenAuthenticationPolicyName } from "@azure/core-rest-pipeline";
/**
* The remote cryptography provider is used to run crypto operations against KeyVault.
* @internal
*/
export class RemoteCryptographyProvider {
constructor(key, credential, pipelineOptions = {}) {
var _a;
this.key = key;
let keyId;
if (typeof key === "string") {
keyId = key;
}
else {
keyId = key.id;
}
try {
const parsed = parseKeyVaultKeyIdentifier(keyId);
if (parsed.name === "") {
throw new Error("Could not find 'name' of key in key URL");
}
if (!parsed.vaultUrl || parsed.vaultUrl === "") {
throw new Error("Could not find 'vaultUrl' of key in key URL");
}
this.vaultUrl = parsed.vaultUrl;
this.name = parsed.name;
this.version = (_a = parsed.version) !== null && _a !== void 0 ? _a : "";
this.client = getOrInitializeClient(this.vaultUrl, credential, pipelineOptions);
}
catch (err) {
logger.error(err);
throw new Error(`${keyId} is not a valid Key Vault key ID`);
}
}
// The remote client supports all algorithms and all operations.
isSupported(_algorithm, _operation) {
return true;
}
encrypt(encryptParameters, options = {}) {
const { algorithm, plaintext } = encryptParameters, params = __rest(encryptParameters, ["algorithm", "plaintext"]);
const requestOptions = Object.assign(Object.assign({}, options), params);
return tracingClient.withSpan("RemoteCryptographyProvider.encrypt", requestOptions, async (updatedOptions) => {
const result = await this.client.encrypt(this.name, this.version, {
algorithm,
value: plaintext,
aad: "additionalAuthenticatedData" in encryptParameters
? encryptParameters.additionalAuthenticatedData
: undefined,
iv: "iv" in encryptParameters ? encryptParameters.iv : undefined,
}, updatedOptions);
return {
algorithm: encryptParameters.algorithm,
result: result.result,
keyID: this.getKeyID(),
additionalAuthenticatedData: result.additionalAuthenticatedData,
authenticationTag: result.authenticationTag,
iv: result.iv,
};
});
}
decrypt(decryptParameters, options = {}) {
const { algorithm, ciphertext } = decryptParameters, params = __rest(decryptParameters, ["algorithm", "ciphertext"]);
const requestOptions = Object.assign(Object.assign({}, options), params);
return tracingClient.withSpan("RemoteCryptographyProvider.decrypt", requestOptions, async (updatedOptions) => {
const result = await this.client.decrypt(this.name, this.version, {
algorithm,
value: ciphertext,
aad: "additionalAuthenticatedData" in decryptParameters
? decryptParameters.additionalAuthenticatedData
: undefined,
iv: "iv" in decryptParameters ? decryptParameters.iv : undefined,
tag: "authenticationTag" in decryptParameters
? decryptParameters.authenticationTag
: undefined,
}, updatedOptions);
return {
result: result.result,
keyID: this.getKeyID(),
algorithm,
};
});
}
wrapKey(algorithm, keyToWrap, options = {}) {
return tracingClient.withSpan("RemoteCryptographyProvider.wrapKey", options, async (updatedOptions) => {
const result = await this.client.wrapKey(this.name, this.version, {
algorithm,
value: keyToWrap,
}, updatedOptions);
return {
result: result.result,
algorithm,
keyID: this.getKeyID(),
};
});
}
unwrapKey(algorithm, encryptedKey, options = {}) {
return tracingClient.withSpan("RemoteCryptographyProvider.unwrapKey", options, async (updatedOptions) => {
const result = await this.client.unwrapKey(this.name, this.version, {
algorithm,
value: encryptedKey,
}, updatedOptions);
return {
result: result.result,
algorithm,
keyID: this.getKeyID(),
};
});
}
sign(algorithm, digest, options = {}) {
return tracingClient.withSpan("RemoteCryptographyProvider.sign", options, async (updatedOptions) => {
const result = await this.client.sign(this.name, this.version, {
algorithm,
value: digest,
}, updatedOptions);
return { result: result.result, algorithm, keyID: this.getKeyID() };
});
}
verifyData(algorithm, data, signature, options = {}) {
return tracingClient.withSpan("RemoteCryptographyProvider.verifyData", options, async (updatedOptions) => {
const hash = await createHash(algorithm, data);
return this.verify(algorithm, hash, signature, updatedOptions);
});
}
verify(algorithm, digest, signature, options = {}) {
return tracingClient.withSpan("RemoteCryptographyProvider.verify", options, async (updatedOptions) => {
const response = await this.client.verify(this.name, this.version, {
algorithm,
digest,
signature,
}, updatedOptions);
return {
result: response.value ? response.value : false,
keyID: this.getKeyID(),
};
});
}
signData(algorithm, data, options = {}) {
return tracingClient.withSpan("RemoteCryptographyProvider.signData", options, async (updatedOptions) => {
const digest = await createHash(algorithm, data);
const result = await this.client.sign(this.name, this.version, {
algorithm,
value: digest,
}, updatedOptions);
return { result: result.result, algorithm, keyID: this.getKeyID() };
});
}
/**
* The ID of the key used to perform cryptographic operations for the client.
*/
get keyId() {
return this.getKeyID();
}
/**
* Gets the {@link KeyVaultKey} used for cryptography operations, fetching it
* from KeyVault if necessary.
* @param options - Additional options.
*/
getKey(options = {}) {
return tracingClient.withSpan("RemoteCryptographyProvider.getKey", options, async (updatedOptions) => {
if (typeof this.key === "string") {
if (!this.name || this.name === "") {
throw new Error("getKey requires a key with a name");
}
const response = await this.client.getKey(this.name, options && options.version ? options.version : this.version ? this.version : "", updatedOptions);
this.key = getKeyFromKeyBundle(response);
}
return this.key;
});
}
/**
* Attempts to retrieve the ID of the key.
*/
getKeyID() {
let kid;
if (typeof this.key !== "string") {
kid = this.key.id;
}
else {
kid = this.key;
}
return kid;
}
}
/**
* A helper method to either get the passed down generated client or initialize a new one.
* An already constructed generated client may be passed down from {@link KeyClient} in which case we should reuse it.
*
* @internal
* @param credential - The credential to use when initializing a new client.
* @param options - The options for constructing a client or the underlying client if one already exists.
* @returns - A generated client instance
*/
function getOrInitializeClient(vaultUrl, credential, options) {
if (options.generatedClient) {
return options.generatedClient;
}
const libInfo = `azsdk-js-keyvault-keys/${SDK_VERSION}`;
const userAgentOptions = options.userAgentOptions;
options.userAgentOptions = {
userAgentPrefix: userAgentOptions && userAgentOptions.userAgentPrefix
? `${userAgentOptions.userAgentPrefix} ${libInfo}`
: libInfo,
};
const internalPipelineOptions = Object.assign(Object.assign({}, options), { apiVersion: options.serviceVersion || LATEST_API_VERSION, loggingOptions: {
logger: logger.info,
additionalAllowedHeaderNames: [
"x-ms-keyvault-region",
"x-ms-keyvault-network-info",
"x-ms-keyvault-service-version",
],
} });
const client = new KeyVaultClient(vaultUrl, credential, internalPipelineOptions);
client.pipeline.removePolicy({ name: bearerTokenAuthenticationPolicyName });
client.pipeline.addPolicy(keyVaultAuthenticationPolicy(credential, options));
// Workaround for: https://github.com/Azure/azure-sdk-for-js/issues/31843
client.pipeline.addPolicy({
name: "ContentTypePolicy",
sendRequest(request, next) {
var _a;
const contentType = (_a = request.headers.get("Content-Type")) !== null && _a !== void 0 ? _a : "";
if (contentType.startsWith("application/json")) {
request.headers.set("Content-Type", "application/json");
}
return next(request);
},
});
return client;
}
//# sourceMappingURL=remoteCryptographyProvider.js.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
{"version":3,"file":"rsaCryptographyProvider-browser.d.mts","sourceRoot":"","sources":["../../../src/cryptography/rsaCryptographyProvider-browser.mts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,oBAAoB,EAAC,MAAM,aAAa,CAAC;AAGvD;;;;;GAKG;AACH,qBAAa,uBAAwB,YAAW,oBAAoB;IAClE,OAAO,IAAI,KAAK;IAKhB,OAAO,IAAI,KAAK;IAMhB;;OAEG;IACH,WAAW,IAAI,OAAO;IAItB,OAAO,IAAI,KAAK;IAMhB,SAAS,IAAI,KAAK;IAMlB,IAAI,IAAI,KAAK;IAMb,QAAQ,IAAI,KAAK;IAMjB,MAAM,IAAI,KAAK;IAMf,UAAU,IAAI,KAAK;CAKpB"}

View File

@ -0,0 +1 @@
{"version":3,"file":"rsaCryptographyProvider-browser.mjs","sourceRoot":"","sources":["../../../src/cryptography/rsaCryptographyProvider-browser.mts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,iCAAiC,EAAE,MAAM,aAAa,CAAC;AAEhE;;;;;GAKG;AACH,MAAM,OAAO,uBAAuB;IAClC,OAAO;QACL,MAAM,IAAI,iCAAiC,CACzC,yDAAyD,CAC1D,CAAC;IACJ,CAAC;IACD,OAAO;QACL,MAAM,IAAI,iCAAiC,CACzC,yDAAyD,CAC1D,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,WAAW;QACT,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO;QACL,MAAM,IAAI,iCAAiC,CACzC,yDAAyD,CAC1D,CAAC;IACJ,CAAC;IAED,SAAS;QACP,MAAM,IAAI,iCAAiC,CACzC,yDAAyD,CAC1D,CAAC;IACJ,CAAC;IAED,IAAI;QACF,MAAM,IAAI,iCAAiC,CACzC,yDAAyD,CAC1D,CAAC;IACJ,CAAC;IAED,QAAQ;QACN,MAAM,IAAI,iCAAiC,CACzC,yDAAyD,CAC1D,CAAC;IACJ,CAAC;IAED,MAAM;QACJ,MAAM,IAAI,iCAAiC,CACzC,yDAAyD,CAC1D,CAAC;IACJ,CAAC;IAED,UAAU;QACR,MAAM,IAAI,iCAAiC,CACzC,yDAAyD,CAC1D,CAAC;IACJ,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { CryptographyProvider} from \"./models.js\";\nimport { LocalCryptographyUnsupportedError } from \"./models.js\";\n\n/**\n * The browser replacement of the RsaCryptographyProvider. Since we do not\n * support local cryptography in the browser this replacement always returns false\n * for `supportsAlgorithm` and `supportsOperation` so that these methods should\n * never be called.\n */\nexport class RsaCryptographyProvider implements CryptographyProvider {\n encrypt(): never {\n throw new LocalCryptographyUnsupportedError(\n \"RSA Local cryptography is not supported in the browser.\",\n );\n }\n decrypt(): never {\n throw new LocalCryptographyUnsupportedError(\n \"RSA Local cryptography is not supported in the browser.\",\n );\n }\n\n /**\n * Browser RSA Provider does not support any algorithms or operations.\n */\n isSupported(): boolean {\n return false;\n }\n\n wrapKey(): never {\n throw new LocalCryptographyUnsupportedError(\n \"RSA Local cryptography is not supported in the browser.\",\n );\n }\n\n unwrapKey(): never {\n throw new LocalCryptographyUnsupportedError(\n \"RSA Local cryptography is not supported in the browser.\",\n );\n }\n\n sign(): never {\n throw new LocalCryptographyUnsupportedError(\n \"RSA Local cryptography is not supported in the browser.\",\n );\n }\n\n signData(): never {\n throw new LocalCryptographyUnsupportedError(\n \"RSA Local cryptography is not supported in the browser.\",\n );\n }\n\n verify(): never {\n throw new LocalCryptographyUnsupportedError(\n \"RSA Local cryptography is not supported in the browser.\",\n );\n }\n\n verifyData(): never {\n throw new LocalCryptographyUnsupportedError(\n \"RSA Local cryptography is not supported in the browser.\",\n );\n }\n}\n"]}

View File

@ -0,0 +1,22 @@
import type { CryptographyProvider } from "./models.js";
/**
* The browser replacement of the RsaCryptographyProvider. Since we do not
* support local cryptography in the browser this replacement always returns false
* for `supportsAlgorithm` and `supportsOperation` so that these methods should
* never be called.
*/
export declare class RsaCryptographyProvider implements CryptographyProvider {
encrypt(): never;
decrypt(): never;
/**
* Browser RSA Provider does not support any algorithms or operations.
*/
isSupported(): boolean;
wrapKey(): never;
unwrapKey(): never;
sign(): never;
signData(): never;
verify(): never;
verifyData(): never;
}
//# sourceMappingURL=rsaCryptographyProvider-browser.d.mts.map

View File

@ -0,0 +1,42 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { LocalCryptographyUnsupportedError } from "./models.js";
/**
* The browser replacement of the RsaCryptographyProvider. Since we do not
* support local cryptography in the browser this replacement always returns false
* for `supportsAlgorithm` and `supportsOperation` so that these methods should
* never be called.
*/
export class RsaCryptographyProvider {
encrypt() {
throw new LocalCryptographyUnsupportedError("RSA Local cryptography is not supported in the browser.");
}
decrypt() {
throw new LocalCryptographyUnsupportedError("RSA Local cryptography is not supported in the browser.");
}
/**
* Browser RSA Provider does not support any algorithms or operations.
*/
isSupported() {
return false;
}
wrapKey() {
throw new LocalCryptographyUnsupportedError("RSA Local cryptography is not supported in the browser.");
}
unwrapKey() {
throw new LocalCryptographyUnsupportedError("RSA Local cryptography is not supported in the browser.");
}
sign() {
throw new LocalCryptographyUnsupportedError("RSA Local cryptography is not supported in the browser.");
}
signData() {
throw new LocalCryptographyUnsupportedError("RSA Local cryptography is not supported in the browser.");
}
verify() {
throw new LocalCryptographyUnsupportedError("RSA Local cryptography is not supported in the browser.");
}
verifyData() {
throw new LocalCryptographyUnsupportedError("RSA Local cryptography is not supported in the browser.");
}
}
//# sourceMappingURL=rsaCryptographyProvider-browser.mjs.map

View File

@ -0,0 +1,427 @@
import type { TokenCredential } from "@azure/core-auth";
import type { CryptographyClientOptions, JsonWebKey, KeyVaultKey } from "./keysModels.js";
import type { DecryptOptions, DecryptParameters, DecryptResult, EncryptOptions, EncryptParameters, EncryptResult, EncryptionAlgorithm, KeyWrapAlgorithm, SignOptions, SignResult, SignatureAlgorithm, UnwrapKeyOptions, UnwrapResult, VerifyOptions, VerifyResult, WrapKeyOptions, WrapResult } from "./cryptographyClientModels.js";
/**
* A client used to perform cryptographic operations on an Azure Key vault key
* or a local {@link JsonWebKey}.
*/
export declare class CryptographyClient {
/**
* The key the CryptographyClient currently holds.
*/
private key;
/**
* The remote provider, which would be undefined if used in local mode.
*/
private remoteProvider?;
/**
* Constructs a new instance of the Cryptography client for the given key
*
* Example usage:
* ```ts snippet:ReadmeSampleCreateCryptographyClient
* import { DefaultAzureCredential } from "@azure/identity";
* import { KeyClient, CryptographyClient } from "@azure/keyvault-keys";
*
* const credential = new DefaultAzureCredential();
*
* const vaultName = "<YOUR KEYVAULT NAME>";
* const url = `https://${vaultName}.vault.azure.net`;
*
* const client = new KeyClient(url, credential);
*
* // Create or retrieve a key from the keyvault
* const myKey = await client.createKey("MyKey", "RSA");
*
* // Lastly, create our cryptography client and connect to the service
* const cryptographyClient = new CryptographyClient(myKey, credential);
* ```
* @param key - The key to use during cryptography tasks. You can also pass the identifier of the key i.e its url here.
* @param credential - An object that implements the `TokenCredential` interface used to authenticate requests to the service. Use the \@azure/identity package to create a credential that suits your needs.
* @param pipelineOptions - Pipeline options used to configure Key Vault API requests.
* Omit this parameter to use the default pipeline configuration.
*/
constructor(key: string | KeyVaultKey, credential: TokenCredential, pipelineOptions?: CryptographyClientOptions);
/**
* Constructs a new instance of the Cryptography client for the given key in local mode.
*
* Example usage:
* ```ts snippet:ReadmeSampleCreateCryptographyClientLocal
* import { CryptographyClient } from "@azure/keyvault-keys";
*
* const jsonWebKey = {
* kty: "RSA",
* kid: "test-key-123",
* use: "sig",
* alg: "RS256",
* n: new Uint8Array([112, 34, 56, 98, 123, 244, 200, 99]),
* e: new Uint8Array([1, 0, 1]),
* d: new Uint8Array([45, 67, 89, 23, 144, 200, 76, 233]),
* p: new Uint8Array([34, 89, 100, 77, 204, 56, 29, 77]),
* q: new Uint8Array([78, 99, 201, 45, 188, 34, 67, 90]),
* dp: new Uint8Array([23, 45, 78, 56, 200, 144, 32, 67]),
* dq: new Uint8Array([12, 67, 89, 144, 99, 56, 23, 45]),
* qi: new Uint8Array([78, 90, 45, 201, 34, 67, 120, 55]),
* };
* const client = new CryptographyClient(jsonWebKey);
* ```
* @param key - The JsonWebKey to use during cryptography operations.
*/
constructor(key: JsonWebKey);
/**
* The base URL to the vault. If a local {@link JsonWebKey} is used vaultUrl will be empty.
*/
get vaultUrl(): string;
/**
* The ID of the key used to perform cryptographic operations for the client.
*/
get keyID(): string | undefined;
/**
* Encrypts the given plaintext with the specified encryption parameters.
* Depending on the algorithm set in the encryption parameters, the set of possible encryption parameters will change.
*
* Example usage:
* ```ts snippet:ReadmeSampleEncrypt
* import { DefaultAzureCredential } from "@azure/identity";
* import { KeyClient, CryptographyClient } from "@azure/keyvault-keys";
*
* const credential = new DefaultAzureCredential();
*
* const vaultName = "<YOUR KEYVAULT NAME>";
* const url = `https://${vaultName}.vault.azure.net`;
*
* const client = new KeyClient(url, credential);
*
* const myKey = await client.createKey("MyKey", "RSA");
* const cryptographyClient = new CryptographyClient(myKey.id, credential);
*
* const encryptResult = await cryptographyClient.encrypt({
* algorithm: "RSA1_5",
* plaintext: Buffer.from("My Message"),
* });
* console.log("encrypt result: ", encryptResult.result);
* ```
* @param encryptParameters - The encryption parameters, keyed on the encryption algorithm chosen.
* @param options - Additional options.
*/
encrypt(encryptParameters: EncryptParameters, options?: EncryptOptions): Promise<EncryptResult>;
/**
* Encrypts the given plaintext with the specified cryptography algorithm
*
* Example usage:
* ```ts snippet:ReadmeSampleEncrypt
* import { DefaultAzureCredential } from "@azure/identity";
* import { KeyClient, CryptographyClient } from "@azure/keyvault-keys";
*
* const credential = new DefaultAzureCredential();
*
* const vaultName = "<YOUR KEYVAULT NAME>";
* const url = `https://${vaultName}.vault.azure.net`;
*
* const client = new KeyClient(url, credential);
*
* const myKey = await client.createKey("MyKey", "RSA");
* const cryptographyClient = new CryptographyClient(myKey.id, credential);
*
* const encryptResult = await cryptographyClient.encrypt({
* algorithm: "RSA1_5",
* plaintext: Buffer.from("My Message"),
* });
* console.log("encrypt result: ", encryptResult.result);
* ```
* @param algorithm - The algorithm to use.
* @param plaintext - The text to encrypt.
* @param options - Additional options.
* @deprecated Use `encrypt({ algorithm, plaintext }, options)` instead.
*/
encrypt(algorithm: EncryptionAlgorithm, plaintext: Uint8Array, options?: EncryptOptions): Promise<EncryptResult>;
private initializeIV;
/**
* Standardizes the arguments of multiple overloads into a single shape.
* @param args - The encrypt arguments
*/
private disambiguateEncryptArguments;
/**
* Decrypts the given ciphertext with the specified decryption parameters.
* Depending on the algorithm used in the decryption parameters, the set of possible decryption parameters will change.
*
* Microsoft recommends you not use CBC without first ensuring the integrity of the ciphertext using, for example, an HMAC. See https://learn.microsoft.com/dotnet/standard/security/vulnerabilities-cbc-mode for more information.
*
* Example usage:
* ```ts snippet:ReadmeSampleDecrypt
* import { DefaultAzureCredential } from "@azure/identity";
* import { KeyClient, CryptographyClient } from "@azure/keyvault-keys";
*
* const credential = new DefaultAzureCredential();
*
* const vaultName = "<YOUR KEYVAULT NAME>";
* const url = `https://${vaultName}.vault.azure.net`;
*
* const client = new KeyClient(url, credential);
*
* const myKey = await client.createKey("MyKey", "RSA");
* const cryptographyClient = new CryptographyClient(myKey.id, credential);
*
* const encryptResult = await cryptographyClient.encrypt({
* algorithm: "RSA1_5",
* plaintext: Buffer.from("My Message"),
* });
* console.log("encrypt result: ", encryptResult.result);
*
* const decryptResult = await cryptographyClient.decrypt({
* algorithm: "RSA1_5",
* ciphertext: encryptResult.result,
* });
* console.log("decrypt result: ", decryptResult.result.toString());
* ```
* @param decryptParameters - The decryption parameters.
* @param options - Additional options.
*/
decrypt(decryptParameters: DecryptParameters, options?: DecryptOptions): Promise<DecryptResult>;
/**
* Decrypts the given ciphertext with the specified cryptography algorithm
*
* Example usage:
* ```ts snippet:ReadmeSampleDecrypt
* import { DefaultAzureCredential } from "@azure/identity";
* import { KeyClient, CryptographyClient } from "@azure/keyvault-keys";
*
* const credential = new DefaultAzureCredential();
*
* const vaultName = "<YOUR KEYVAULT NAME>";
* const url = `https://${vaultName}.vault.azure.net`;
*
* const client = new KeyClient(url, credential);
*
* const myKey = await client.createKey("MyKey", "RSA");
* const cryptographyClient = new CryptographyClient(myKey.id, credential);
*
* const encryptResult = await cryptographyClient.encrypt({
* algorithm: "RSA1_5",
* plaintext: Buffer.from("My Message"),
* });
* console.log("encrypt result: ", encryptResult.result);
*
* const decryptResult = await cryptographyClient.decrypt({
* algorithm: "RSA1_5",
* ciphertext: encryptResult.result,
* });
* console.log("decrypt result: ", decryptResult.result.toString());
* ```
*
* Microsoft recommends you not use CBC without first ensuring the integrity of the ciphertext using, for example, an HMAC. See https://learn.microsoft.com/dotnet/standard/security/vulnerabilities-cbc-mode for more information.
*
* @param algorithm - The algorithm to use.
* @param ciphertext - The text to decrypt.
* @param options - Additional options.
* @deprecated Use `decrypt({ algorithm, ciphertext }, options)` instead.
*/
decrypt(algorithm: EncryptionAlgorithm, ciphertext: Uint8Array, options?: DecryptOptions): Promise<DecryptResult>;
/**
* Standardizes the arguments of multiple overloads into a single shape.
* @param args - The decrypt arguments
*/
private disambiguateDecryptArguments;
/**
* Wraps the given key using the specified cryptography algorithm
*
* Example usage:
* ```ts snippet:ReadmeSampleWrapKey
* import { DefaultAzureCredential } from "@azure/identity";
* import { KeyClient, CryptographyClient } from "@azure/keyvault-keys";
*
* const credential = new DefaultAzureCredential();
*
* const vaultName = "<YOUR KEYVAULT NAME>";
* const url = `https://${vaultName}.vault.azure.net`;
*
* const client = new KeyClient(url, credential);
*
* const myKey = await client.createKey("MyKey", "RSA");
* const cryptographyClient = new CryptographyClient(myKey, credential);
*
* const wrapResult = await cryptographyClient.wrapKey("RSA-OAEP", Buffer.from("My Key"));
* console.log("wrap result:", wrapResult.result);
* ```
* @param algorithm - The encryption algorithm to use to wrap the given key.
* @param key - The key to wrap.
* @param options - Additional options.
*/
wrapKey(algorithm: KeyWrapAlgorithm, key: Uint8Array, options?: WrapKeyOptions): Promise<WrapResult>;
/**
* Unwraps the given wrapped key using the specified cryptography algorithm
*
* Example usage:
* ```ts snippet:ReadmeSampleUnwrapKey
* import { DefaultAzureCredential } from "@azure/identity";
* import { KeyClient, CryptographyClient } from "@azure/keyvault-keys";
*
* const credential = new DefaultAzureCredential();
*
* const vaultName = "<YOUR KEYVAULT NAME>";
* const url = `https://${vaultName}.vault.azure.net`;
*
* const client = new KeyClient(url, credential);
*
* const myKey = await client.createKey("MyKey", "RSA");
* const cryptographyClient = new CryptographyClient(myKey, credential);
*
* const wrapResult = await cryptographyClient.wrapKey("RSA-OAEP", Buffer.from("My Key"));
* console.log("wrap result:", wrapResult.result);
*
* const unwrapResult = await cryptographyClient.unwrapKey("RSA-OAEP", wrapResult.result);
* console.log("unwrap result: ", unwrapResult.result);
* ```
* @param algorithm - The decryption algorithm to use to unwrap the key.
* @param encryptedKey - The encrypted key to unwrap.
* @param options - Additional options.
*/
unwrapKey(algorithm: KeyWrapAlgorithm, encryptedKey: Uint8Array, options?: UnwrapKeyOptions): Promise<UnwrapResult>;
/**
* Cryptographically sign the digest of a message
*
* Example usage:
* ```ts snippet:ReadmeSampleSign
* import { DefaultAzureCredential } from "@azure/identity";
* import { KeyClient, CryptographyClient } from "@azure/keyvault-keys";
* import { createHash } from "node:crypto";
*
* const credential = new DefaultAzureCredential();
*
* const vaultName = "<YOUR KEYVAULT NAME>";
* const url = `https://${vaultName}.vault.azure.net`;
*
* const client = new KeyClient(url, credential);
*
* let myKey = await client.createKey("MyKey", "RSA");
* const cryptographyClient = new CryptographyClient(myKey, credential);
*
* const signatureValue = "MySignature";
* const hash = createHash("sha256");
*
* const digest = hash.update(signatureValue).digest();
* console.log("digest: ", digest);
*
* const signResult = await cryptographyClient.sign("RS256", digest);
* console.log("sign result: ", signResult.result);
* ```
* @param algorithm - The signing algorithm to use.
* @param digest - The digest of the data to sign.
* @param options - Additional options.
*/
sign(algorithm: SignatureAlgorithm, digest: Uint8Array, options?: SignOptions): Promise<SignResult>;
/**
* Verify the signed message digest
*
* Example usage:
* ```ts snippet:ReadmeSampleVerify
* import { DefaultAzureCredential } from "@azure/identity";
* import { KeyClient, CryptographyClient } from "@azure/keyvault-keys";
* import { createHash } from "node:crypto";
*
* const credential = new DefaultAzureCredential();
*
* const vaultName = "<YOUR KEYVAULT NAME>";
* const url = `https://${vaultName}.vault.azure.net`;
*
* const client = new KeyClient(url, credential);
*
* const myKey = await client.createKey("MyKey", "RSA");
* const cryptographyClient = new CryptographyClient(myKey, credential);
*
* const hash = createHash("sha256");
* hash.update("My Message");
* const digest = hash.digest();
*
* const signResult = await cryptographyClient.sign("RS256", digest);
* console.log("sign result: ", signResult.result);
*
* const verifyResult = await cryptographyClient.verify("RS256", digest, signResult.result);
* console.log("verify result: ", verifyResult.result);
* ```
* @param algorithm - The signing algorithm to use to verify with.
* @param digest - The digest to verify.
* @param signature - The signature to verify the digest against.
* @param options - Additional options.
*/
verify(algorithm: SignatureAlgorithm, digest: Uint8Array, signature: Uint8Array, options?: VerifyOptions): Promise<VerifyResult>;
/**
* Cryptographically sign a block of data
*
* Example usage:
* ```ts snippet:ReadmeSampleSignData
* import { DefaultAzureCredential } from "@azure/identity";
* import { KeyClient, CryptographyClient } from "@azure/keyvault-keys";
*
* const credential = new DefaultAzureCredential();
*
* const vaultName = "<YOUR KEYVAULT NAME>";
* const url = `https://${vaultName}.vault.azure.net`;
*
* const client = new KeyClient(url, credential);
*
* const myKey = await client.createKey("MyKey", "RSA");
* const cryptographyClient = new CryptographyClient(myKey, credential);
*
* const signResult = await cryptographyClient.signData("RS256", Buffer.from("My Message"));
* console.log("sign result: ", signResult.result);
* ```
* @param algorithm - The signing algorithm to use.
* @param data - The data to sign.
* @param options - Additional options.
*/
signData(algorithm: SignatureAlgorithm, data: Uint8Array, options?: SignOptions): Promise<SignResult>;
/**
* Verify the signed block of data
*
* Example usage:
* ```ts snippet:ReadmeSampleVerifyData
* import { DefaultAzureCredential } from "@azure/identity";
* import { KeyClient, CryptographyClient } from "@azure/keyvault-keys";
*
* const credential = new DefaultAzureCredential();
*
* const vaultName = "<YOUR KEYVAULT NAME>";
* const url = `https://${vaultName}.vault.azure.net`;
*
* const client = new KeyClient(url, credential);
*
* const myKey = await client.createKey("MyKey", "RSA");
* const cryptographyClient = new CryptographyClient(myKey, credential);
*
* const buffer = Buffer.from("My Message");
*
* const signResult = await cryptographyClient.signData("RS256", buffer);
* console.log("sign result: ", signResult.result);
*
* const verifyResult = await cryptographyClient.verifyData("RS256", buffer, signResult.result);
* console.log("verify result: ", verifyResult.result);
* ```
* @param algorithm - The algorithm to use to verify with.
* @param data - The signed block of data to verify.
* @param signature - The signature to verify the block against.
* @param options - Additional options.
*/
verifyData(algorithm: SignatureAlgorithm, data: Uint8Array, signature: Uint8Array, options?: VerifyOptions): Promise<VerifyResult>;
/**
* Retrieves the {@link JsonWebKey} from the Key Vault, if possible. Returns undefined if the key could not be retrieved due to insufficient permissions.
* @param options - The additional options.
*/
private getKeyMaterial;
/**
* Returns the underlying key used for cryptographic operations.
* If needed, attempts to fetch the key from KeyVault and exchanges the ID for the actual key.
* @param options - The additional options.
*/
private fetchKey;
private providers?;
/**
* Gets the provider that support this algorithm and operation.
* The available providers are ordered by priority such that the first provider that supports this
* operation is the one we should use.
* @param operation - The {@link KeyOperation}.
* @param algorithm - The algorithm to use.
*/
private getProvider;
private ensureValid;
}
//# sourceMappingURL=cryptographyClient.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"cryptographyClient.d.ts","sourceRoot":"","sources":["../../src/cryptographyClient.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,KAAK,EACV,yBAAyB,EAEzB,UAAU,EAEV,WAAW,EACZ,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,EAIV,cAAc,EACd,iBAAiB,EACjB,aAAa,EACb,cAAc,EACd,iBAAiB,EACjB,aAAa,EACb,mBAAmB,EACnB,gBAAgB,EAChB,WAAW,EACX,UAAU,EACV,kBAAkB,EAClB,gBAAgB,EAChB,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,cAAc,EACd,UAAU,EACX,MAAM,+BAA+B,CAAC;AAUvC;;;GAGG;AACH,qBAAa,kBAAkB;IAC7B;;OAEG;IACH,OAAO,CAAC,GAAG,CAAwB;IAEnC;;OAEG;IACH,OAAO,CAAC,cAAc,CAAC,CAA6B;IAEpD;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;gBAED,GAAG,EAAE,MAAM,GAAG,WAAW,EACzB,UAAU,EAAE,eAAe,EAC3B,eAAe,CAAC,EAAE,yBAAyB;IAE7C;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;gBACS,GAAG,EAAE,UAAU;IAkC3B;;OAEG;IACH,IAAI,QAAQ,IAAI,MAAM,CAErB;IAED;;OAEG;IACH,IAAI,KAAK,IAAI,MAAM,GAAG,SAAS,CAQ9B;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACI,OAAO,CACZ,iBAAiB,EAAE,iBAAiB,EACpC,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,aAAa,CAAC;IACzB;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACI,OAAO,CACZ,SAAS,EAAE,mBAAmB,EAC9B,SAAS,EAAE,UAAU,EACrB,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,aAAa,CAAC;IAsBzB,OAAO,CAAC,YAAY;IAyBpB;;;OAGG;IACH,OAAO,CAAC,4BAA4B;IAkBpC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAmCG;IACU,OAAO,CAClB,iBAAiB,EAAE,iBAAiB,EACpC,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,aAAa,CAAC;IACzB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAqCG;IACI,OAAO,CACZ,SAAS,EAAE,mBAAmB,EAC9B,UAAU,EAAE,UAAU,EACtB,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,aAAa,CAAC;IAsBzB;;;OAGG;IACH,OAAO,CAAC,4BAA4B;IAkBpC;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACI,OAAO,CACZ,SAAS,EAAE,gBAAgB,EAC3B,GAAG,EAAE,UAAU,EACf,OAAO,GAAE,cAAmB,GAC3B,OAAO,CAAC,UAAU,CAAC;IAetB;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACI,SAAS,CACd,SAAS,EAAE,gBAAgB,EAC3B,YAAY,EAAE,UAAU,EACxB,OAAO,GAAE,gBAAqB,GAC7B,OAAO,CAAC,YAAY,CAAC;IAmBxB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA+BG;IACI,IAAI,CACT,SAAS,EAAE,kBAAkB,EAC7B,MAAM,EAAE,UAAU,EAClB,OAAO,GAAE,WAAgB,GACxB,OAAO,CAAC,UAAU,CAAC;IAetB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAiCG;IACI,MAAM,CACX,SAAS,EAAE,kBAAkB,EAC7B,MAAM,EAAE,UAAU,EAClB,SAAS,EAAE,UAAU,EACrB,OAAO,GAAE,aAAkB,GAC1B,OAAO,CAAC,YAAY,CAAC;IAexB;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACI,QAAQ,CACb,SAAS,EAAE,kBAAkB,EAC7B,IAAI,EAAE,UAAU,EAEhB,OAAO,GAAE,WAAgB,GACxB,OAAO,CAAC,UAAU,CAAC;IAmBtB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;IACI,UAAU,CACf,SAAS,EAAE,kBAAkB,EAC7B,IAAI,EAAE,UAAU,EAChB,SAAS,EAAE,UAAU,EAErB,OAAO,GAAE,aAAkB,GAC1B,OAAO,CAAC,YAAY,CAAC;IAmBxB;;;OAGG;YACW,cAAc;IAa5B;;;;OAIG;YACW,QAAQ;IA2BtB,OAAO,CAAC,SAAS,CAAC,CAAyB;IAC3C;;;;;;OAMG;YACW,WAAW;IAsCzB,OAAO,CAAC,WAAW;CA0BpB"}

View File

@ -0,0 +1,529 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { KnownKeyOperations } from "./keysModels.js";
import { RemoteCryptographyProvider } from "./cryptography/remoteCryptographyProvider.js";
import { randomBytes } from "./cryptography/crypto.js";
import { RsaCryptographyProvider } from "./cryptography/rsaCryptographyProvider.js";
import { AesCryptographyProvider } from "./cryptography/aesCryptographyProvider.js";
import { tracingClient } from "./tracing.js";
import { isRestError } from "@azure/core-rest-pipeline";
import { logger } from "./log.js";
/**
* A client used to perform cryptographic operations on an Azure Key vault key
* or a local {@link JsonWebKey}.
*/
export class CryptographyClient {
/**
* Internal constructor implementation for either local or Key Vault backed keys.
* @param key - The key to use during cryptography tasks.
* @param credential - Teh credential to use when constructing a Key Vault Cryptography client.
*/
constructor(key, credential, pipelineOptions = {}) {
if (typeof key === "string") {
// Key URL for remote-local operations.
this.key = {
kind: "identifier",
value: key,
};
this.remoteProvider = new RemoteCryptographyProvider(key, credential, pipelineOptions);
}
else if ("name" in key) {
// KeyVault key for remote-local operations.
this.key = {
kind: "KeyVaultKey",
value: key,
};
this.remoteProvider = new RemoteCryptographyProvider(key, credential, pipelineOptions);
}
else {
// JsonWebKey for local-only operations.
this.key = {
kind: "JsonWebKey",
value: key,
};
}
}
/**
* The base URL to the vault. If a local {@link JsonWebKey} is used vaultUrl will be empty.
*/
get vaultUrl() {
var _a;
return ((_a = this.remoteProvider) === null || _a === void 0 ? void 0 : _a.vaultUrl) || "";
}
/**
* The ID of the key used to perform cryptographic operations for the client.
*/
get keyID() {
if (this.key.kind === "identifier" || this.key.kind === "remoteOnlyIdentifier") {
return this.key.value;
}
else if (this.key.kind === "KeyVaultKey") {
return this.key.value.id;
}
else {
return this.key.value.kid;
}
}
encrypt(...args) {
const [parameters, options] = this.disambiguateEncryptArguments(args);
return tracingClient.withSpan("CryptographyClient.encrypt", options, async (updatedOptions) => {
this.ensureValid(await this.fetchKey(updatedOptions), KnownKeyOperations.Encrypt);
this.initializeIV(parameters);
const provider = await this.getProvider("encrypt", parameters.algorithm, updatedOptions);
try {
return provider.encrypt(parameters, updatedOptions);
}
catch (error) {
if (this.remoteProvider) {
return this.remoteProvider.encrypt(parameters, updatedOptions);
}
throw error;
}
});
}
initializeIV(parameters) {
// For AES-GCM the service **must** generate the IV, so we only populate it for AES-CBC
const algorithmsRequiringIV = [
"A128CBC",
"A128CBCPAD",
"A192CBC",
"A192CBCPAD",
"A256CBC",
"A256CBCPAD",
];
if (parameters.algorithm in algorithmsRequiringIV) {
try {
const cbcParams = parameters;
if (!cbcParams.iv) {
cbcParams.iv = randomBytes(16);
}
}
catch (e) {
throw new Error(`Unable to initialize IV for algorithm ${parameters.algorithm}. You may pass a valid IV to avoid this error. Error: ${e.message}`);
}
}
}
/**
* Standardizes the arguments of multiple overloads into a single shape.
* @param args - The encrypt arguments
*/
disambiguateEncryptArguments(args) {
if (typeof args[0] === "string") {
// Sample shape: ["RSA1_5", buffer, options]
return [
{
algorithm: args[0],
plaintext: args[1],
},
args[2] || {},
];
}
else {
// Sample shape: [{ algorithm: "RSA1_5", plaintext: buffer }, options]
return [args[0], (args[1] || {})];
}
}
decrypt(...args) {
const [parameters, options] = this.disambiguateDecryptArguments(args);
return tracingClient.withSpan("CryptographyClient.decrypt", options, async (updatedOptions) => {
this.ensureValid(await this.fetchKey(updatedOptions), KnownKeyOperations.Decrypt);
const provider = await this.getProvider("decrypt", parameters.algorithm, updatedOptions);
try {
return provider.decrypt(parameters, updatedOptions);
}
catch (error) {
if (this.remoteProvider) {
return this.remoteProvider.decrypt(parameters, updatedOptions);
}
throw error;
}
});
}
/**
* Standardizes the arguments of multiple overloads into a single shape.
* @param args - The decrypt arguments
*/
disambiguateDecryptArguments(args) {
if (typeof args[0] === "string") {
// Sample shape: ["RSA1_5", encryptedBuffer, options]
return [
{
algorithm: args[0],
ciphertext: args[1],
},
args[2] || {},
];
}
else {
// Sample shape: [{ algorithm: "RSA1_5", ciphertext: encryptedBuffer }, options]
return [args[0], (args[1] || {})];
}
}
/**
* Wraps the given key using the specified cryptography algorithm
*
* Example usage:
* ```ts snippet:ReadmeSampleWrapKey
* import { DefaultAzureCredential } from "@azure/identity";
* import { KeyClient, CryptographyClient } from "@azure/keyvault-keys";
*
* const credential = new DefaultAzureCredential();
*
* const vaultName = "<YOUR KEYVAULT NAME>";
* const url = `https://${vaultName}.vault.azure.net`;
*
* const client = new KeyClient(url, credential);
*
* const myKey = await client.createKey("MyKey", "RSA");
* const cryptographyClient = new CryptographyClient(myKey, credential);
*
* const wrapResult = await cryptographyClient.wrapKey("RSA-OAEP", Buffer.from("My Key"));
* console.log("wrap result:", wrapResult.result);
* ```
* @param algorithm - The encryption algorithm to use to wrap the given key.
* @param key - The key to wrap.
* @param options - Additional options.
*/
wrapKey(algorithm, key, options = {}) {
return tracingClient.withSpan("CryptographyClient.wrapKey", options, async (updatedOptions) => {
this.ensureValid(await this.fetchKey(updatedOptions), KnownKeyOperations.WrapKey);
const provider = await this.getProvider("wrapKey", algorithm, updatedOptions);
try {
return provider.wrapKey(algorithm, key, updatedOptions);
}
catch (err) {
if (this.remoteProvider) {
return this.remoteProvider.wrapKey(algorithm, key, options);
}
throw err;
}
});
}
/**
* Unwraps the given wrapped key using the specified cryptography algorithm
*
* Example usage:
* ```ts snippet:ReadmeSampleUnwrapKey
* import { DefaultAzureCredential } from "@azure/identity";
* import { KeyClient, CryptographyClient } from "@azure/keyvault-keys";
*
* const credential = new DefaultAzureCredential();
*
* const vaultName = "<YOUR KEYVAULT NAME>";
* const url = `https://${vaultName}.vault.azure.net`;
*
* const client = new KeyClient(url, credential);
*
* const myKey = await client.createKey("MyKey", "RSA");
* const cryptographyClient = new CryptographyClient(myKey, credential);
*
* const wrapResult = await cryptographyClient.wrapKey("RSA-OAEP", Buffer.from("My Key"));
* console.log("wrap result:", wrapResult.result);
*
* const unwrapResult = await cryptographyClient.unwrapKey("RSA-OAEP", wrapResult.result);
* console.log("unwrap result: ", unwrapResult.result);
* ```
* @param algorithm - The decryption algorithm to use to unwrap the key.
* @param encryptedKey - The encrypted key to unwrap.
* @param options - Additional options.
*/
unwrapKey(algorithm, encryptedKey, options = {}) {
return tracingClient.withSpan("CryptographyClient.unwrapKey", options, async (updatedOptions) => {
this.ensureValid(await this.fetchKey(updatedOptions), KnownKeyOperations.UnwrapKey);
const provider = await this.getProvider("unwrapKey", algorithm, updatedOptions);
try {
return provider.unwrapKey(algorithm, encryptedKey, updatedOptions);
}
catch (err) {
if (this.remoteProvider) {
return this.remoteProvider.unwrapKey(algorithm, encryptedKey, options);
}
throw err;
}
});
}
/**
* Cryptographically sign the digest of a message
*
* Example usage:
* ```ts snippet:ReadmeSampleSign
* import { DefaultAzureCredential } from "@azure/identity";
* import { KeyClient, CryptographyClient } from "@azure/keyvault-keys";
* import { createHash } from "node:crypto";
*
* const credential = new DefaultAzureCredential();
*
* const vaultName = "<YOUR KEYVAULT NAME>";
* const url = `https://${vaultName}.vault.azure.net`;
*
* const client = new KeyClient(url, credential);
*
* let myKey = await client.createKey("MyKey", "RSA");
* const cryptographyClient = new CryptographyClient(myKey, credential);
*
* const signatureValue = "MySignature";
* const hash = createHash("sha256");
*
* const digest = hash.update(signatureValue).digest();
* console.log("digest: ", digest);
*
* const signResult = await cryptographyClient.sign("RS256", digest);
* console.log("sign result: ", signResult.result);
* ```
* @param algorithm - The signing algorithm to use.
* @param digest - The digest of the data to sign.
* @param options - Additional options.
*/
sign(algorithm, digest, options = {}) {
return tracingClient.withSpan("CryptographyClient.sign", options, async (updatedOptions) => {
this.ensureValid(await this.fetchKey(updatedOptions), KnownKeyOperations.Sign);
const provider = await this.getProvider("sign", algorithm, updatedOptions);
try {
return provider.sign(algorithm, digest, updatedOptions);
}
catch (err) {
if (this.remoteProvider) {
return this.remoteProvider.sign(algorithm, digest, updatedOptions);
}
throw err;
}
});
}
/**
* Verify the signed message digest
*
* Example usage:
* ```ts snippet:ReadmeSampleVerify
* import { DefaultAzureCredential } from "@azure/identity";
* import { KeyClient, CryptographyClient } from "@azure/keyvault-keys";
* import { createHash } from "node:crypto";
*
* const credential = new DefaultAzureCredential();
*
* const vaultName = "<YOUR KEYVAULT NAME>";
* const url = `https://${vaultName}.vault.azure.net`;
*
* const client = new KeyClient(url, credential);
*
* const myKey = await client.createKey("MyKey", "RSA");
* const cryptographyClient = new CryptographyClient(myKey, credential);
*
* const hash = createHash("sha256");
* hash.update("My Message");
* const digest = hash.digest();
*
* const signResult = await cryptographyClient.sign("RS256", digest);
* console.log("sign result: ", signResult.result);
*
* const verifyResult = await cryptographyClient.verify("RS256", digest, signResult.result);
* console.log("verify result: ", verifyResult.result);
* ```
* @param algorithm - The signing algorithm to use to verify with.
* @param digest - The digest to verify.
* @param signature - The signature to verify the digest against.
* @param options - Additional options.
*/
verify(algorithm, digest, signature, options = {}) {
return tracingClient.withSpan("CryptographyClient.verify", options, async (updatedOptions) => {
this.ensureValid(await this.fetchKey(updatedOptions), KnownKeyOperations.Verify);
const provider = await this.getProvider("verify", algorithm, updatedOptions);
try {
return provider.verify(algorithm, digest, signature, updatedOptions);
}
catch (err) {
if (this.remoteProvider) {
return this.remoteProvider.verify(algorithm, digest, signature, updatedOptions);
}
throw err;
}
});
}
/**
* Cryptographically sign a block of data
*
* Example usage:
* ```ts snippet:ReadmeSampleSignData
* import { DefaultAzureCredential } from "@azure/identity";
* import { KeyClient, CryptographyClient } from "@azure/keyvault-keys";
*
* const credential = new DefaultAzureCredential();
*
* const vaultName = "<YOUR KEYVAULT NAME>";
* const url = `https://${vaultName}.vault.azure.net`;
*
* const client = new KeyClient(url, credential);
*
* const myKey = await client.createKey("MyKey", "RSA");
* const cryptographyClient = new CryptographyClient(myKey, credential);
*
* const signResult = await cryptographyClient.signData("RS256", Buffer.from("My Message"));
* console.log("sign result: ", signResult.result);
* ```
* @param algorithm - The signing algorithm to use.
* @param data - The data to sign.
* @param options - Additional options.
*/
signData(algorithm, data,
// eslint-disable-next-line @azure/azure-sdk/ts-naming-options
options = {}) {
return tracingClient.withSpan("CryptographyClient.signData", options, async (updatedOptions) => {
this.ensureValid(await this.fetchKey(updatedOptions), KnownKeyOperations.Sign);
const provider = await this.getProvider("signData", algorithm, updatedOptions);
try {
return provider.signData(algorithm, data, updatedOptions);
}
catch (err) {
if (this.remoteProvider) {
return this.remoteProvider.signData(algorithm, data, options);
}
throw err;
}
});
}
/**
* Verify the signed block of data
*
* Example usage:
* ```ts snippet:ReadmeSampleVerifyData
* import { DefaultAzureCredential } from "@azure/identity";
* import { KeyClient, CryptographyClient } from "@azure/keyvault-keys";
*
* const credential = new DefaultAzureCredential();
*
* const vaultName = "<YOUR KEYVAULT NAME>";
* const url = `https://${vaultName}.vault.azure.net`;
*
* const client = new KeyClient(url, credential);
*
* const myKey = await client.createKey("MyKey", "RSA");
* const cryptographyClient = new CryptographyClient(myKey, credential);
*
* const buffer = Buffer.from("My Message");
*
* const signResult = await cryptographyClient.signData("RS256", buffer);
* console.log("sign result: ", signResult.result);
*
* const verifyResult = await cryptographyClient.verifyData("RS256", buffer, signResult.result);
* console.log("verify result: ", verifyResult.result);
* ```
* @param algorithm - The algorithm to use to verify with.
* @param data - The signed block of data to verify.
* @param signature - The signature to verify the block against.
* @param options - Additional options.
*/
verifyData(algorithm, data, signature,
// eslint-disable-next-line @azure/azure-sdk/ts-naming-options
options = {}) {
return tracingClient.withSpan("CryptographyClient.verifyData", options, async (updatedOptions) => {
this.ensureValid(await this.fetchKey(updatedOptions), KnownKeyOperations.Verify);
const provider = await this.getProvider("verifyData", algorithm, updatedOptions);
try {
return provider.verifyData(algorithm, data, signature, updatedOptions);
}
catch (err) {
if (this.remoteProvider) {
return this.remoteProvider.verifyData(algorithm, data, signature, updatedOptions);
}
throw err;
}
});
}
/**
* Retrieves the {@link JsonWebKey} from the Key Vault, if possible. Returns undefined if the key could not be retrieved due to insufficient permissions.
* @param options - The additional options.
*/
async getKeyMaterial(options) {
const key = await this.fetchKey(options);
switch (key.kind) {
case "JsonWebKey":
return key.value;
case "KeyVaultKey":
return key.value.key;
default:
return undefined;
}
}
/**
* Returns the underlying key used for cryptographic operations.
* If needed, attempts to fetch the key from KeyVault and exchanges the ID for the actual key.
* @param options - The additional options.
*/
async fetchKey(options) {
if (this.key.kind === "identifier") {
// Exchange the identifier with the actual key when needed
let key;
try {
key = await this.remoteProvider.getKey(options);
}
catch (e) {
if (isRestError(e) && e.statusCode === 403) {
// If we don't have permission to get the key, we'll fall back to using the remote provider.
// Marking the key as a remoteOnlyIdentifier will ensure that we don't attempt to fetch the key again.
logger.verbose(`Permission denied to get key ${this.key.value}. Falling back to remote operation.`);
this.key = { kind: "remoteOnlyIdentifier", value: this.key.value };
}
else {
throw e;
}
}
if (key) {
this.key = { kind: "KeyVaultKey", value: key };
}
}
return this.key;
}
/**
* Gets the provider that support this algorithm and operation.
* The available providers are ordered by priority such that the first provider that supports this
* operation is the one we should use.
* @param operation - The {@link KeyOperation}.
* @param algorithm - The algorithm to use.
*/
async getProvider(operation, algorithm, options) {
if (!this.providers) {
const keyMaterial = await this.getKeyMaterial(options);
this.providers = [];
// Add local crypto providers as needed
if (keyMaterial) {
this.providers.push(new RsaCryptographyProvider(keyMaterial), new AesCryptographyProvider(keyMaterial));
}
// If the remote provider exists, we're in hybrid-mode. Otherwise we're in local-only mode.
// If we're in hybrid mode the remote provider is used as a catch-all and should be last in the list.
if (this.remoteProvider) {
this.providers.push(this.remoteProvider);
}
}
const providers = this.providers.filter((p) => p.isSupported(algorithm, operation));
if (providers.length === 0) {
throw new Error(`Unable to support operation: "${operation}" with algorithm: "${algorithm}" ${this.key.kind === "JsonWebKey" ? "using a local JsonWebKey" : ""}`);
}
// Return the first provider that supports this request
return providers[0];
}
ensureValid(key, operation) {
var _a;
if (key.kind === "KeyVaultKey") {
const keyOps = key.value.keyOperations;
const { notBefore, expiresOn } = key.value.properties;
const now = new Date();
// Check KeyVault Key Expiration
if (notBefore && now < notBefore) {
throw new Error(`Key ${key.value.id} can't be used before ${notBefore.toISOString()}`);
}
if (expiresOn && now > expiresOn) {
throw new Error(`Key ${key.value.id} expired at ${expiresOn.toISOString()}`);
}
// Check Key operations
if (operation && keyOps && !(keyOps === null || keyOps === void 0 ? void 0 : keyOps.includes(operation))) {
throw new Error(`Operation ${operation} is not supported on key ${key.value.id}`);
}
}
else if (key.kind === "JsonWebKey") {
// Check JsonWebKey Key operations
if (operation && key.value.keyOps && !((_a = key.value.keyOps) === null || _a === void 0 ? void 0 : _a.includes(operation))) {
throw new Error(`Operation ${operation} is not supported on key ${key.value.kid}`);
}
}
}
}
//# sourceMappingURL=cryptographyClient.js.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,304 @@
import type { CryptographyOptions, KeyVaultKey } from "./keysModels.js";
import type { JsonWebKey } from "./generated/models/index.js";
import { JsonWebKeyEncryptionAlgorithm as EncryptionAlgorithm, JsonWebKeyCurveName as KeyCurveName, KnownJsonWebKeyCurveName as KnownKeyCurveNames, KnownJsonWebKeySignatureAlgorithm as KnownSignatureAlgorithms, KnownJsonWebKeyEncryptionAlgorithm as KnownEncryptionAlgorithms, JsonWebKeySignatureAlgorithm as SignatureAlgorithm, KnownJsonWebKeyType as KnownKeyTypes, KnownKeyEncryptionAlgorithm as KnownKeyExportEncryptionAlgorithm } from "./generated/models/index.js";
export { EncryptionAlgorithm, KeyCurveName, KnownEncryptionAlgorithms, KnownKeyCurveNames, KnownKeyExportEncryptionAlgorithm, KnownKeyTypes, KnownSignatureAlgorithms, SignatureAlgorithm, };
/**
* Supported algorithms for key wrapping/unwrapping
*/
export type KeyWrapAlgorithm = "A128KW" | "A192KW" | "A256KW" | "RSA-OAEP" | "RSA-OAEP-256" | "RSA1_5" | "CKM_AES_KEY_WRAP" | "CKM_AES_KEY_WRAP_PAD";
/**
* Result of the {@link encrypt} operation.
*/
export interface EncryptResult {
/**
* Result of the {@link encrypt} operation in bytes.
*/
result: Uint8Array;
/**
* The {@link EncryptionAlgorithm} used to encrypt the data.
*/
algorithm: EncryptionAlgorithm;
/**
* The ID of the Key Vault Key used to encrypt the data.
*/
keyID?: string;
/**
* The initialization vector used for encryption.
*/
iv?: Uint8Array;
/**
* The authentication tag resulting from encryption with a symmetric key including A128GCM, A192GCM, and A256GCM.
*/
authenticationTag?: Uint8Array;
/**
* Additional data that is authenticated during decryption but not encrypted.
*/
additionalAuthenticatedData?: Uint8Array;
}
/**
* Result of the {@link wrap} operation.
*/
export interface WrapResult {
/**
* Result of the {@link wrap} operation in bytes.
*/
result: Uint8Array;
/**
* The ID of the Key Vault Key used to wrap the data.
*/
keyID?: string;
/**
* The {@link EncryptionAlgorithm} used to wrap the data.
*/
algorithm: KeyWrapAlgorithm;
}
/**
* Result of the {@link unwrap} operation.
*/
export interface UnwrapResult {
/**
* Result of the {@link unwrap} operation in bytes.
*/
result: Uint8Array;
/**
* The ID of the Key Vault Key used to unwrap the data.
*/
keyID?: string;
/**
* The {@link KeyWrapAlgorithm} used to unwrap the data.
*/
algorithm: KeyWrapAlgorithm;
}
/**
* Result of the {@link decrypt} operation.
*/
export interface DecryptResult {
/**
* Result of the {@link decrypt} operation in bytes.
*/
result: Uint8Array;
/**
* The ID of the Key Vault Key used to decrypt the encrypted data.
*/
keyID?: string;
/**
* The {@link EncryptionAlgorithm} used to decrypt the encrypted data.
*/
algorithm: EncryptionAlgorithm;
}
/**
* Result of the {@link sign} operation.
*/
export interface SignResult {
/**
* Result of the {@link sign} operation in bytes.
*/
result: Uint8Array;
/**
* The ID of the Key Vault Key used to sign the data.
*/
keyID?: string;
/**
* The {@link EncryptionAlgorithm} used to sign the data.
*/
algorithm: SignatureAlgorithm;
}
/**
* Result of the {@link verify} operation.
*/
export interface VerifyResult {
/**
* Result of the {@link verify} operation in bytes.
*/
result: boolean;
/**
* The ID of the Key Vault Key used to verify the data.
*/
keyID?: string;
}
/**
* Options for {@link encrypt}.
*/
export interface EncryptOptions extends CryptographyOptions {
}
/**
* Options for {@link decrypt}.
*/
export interface DecryptOptions extends CryptographyOptions {
}
/**
* Options for {@link sign}.
*/
export interface SignOptions extends CryptographyOptions {
}
/**
* Options for {@link verify}.
*/
export interface VerifyOptions extends CryptographyOptions {
}
/**
* Options for {@link verifyData}
*/
export interface VerifyDataOptions extends CryptographyOptions {
}
/**
* Options for {@link wrapKey}.
*/
export interface WrapKeyOptions extends CryptographyOptions {
}
/**
* Options for {@link unwrapKey}.
*/
export interface UnwrapKeyOptions extends CryptographyOptions {
}
/**
* A union type representing all supported RSA encryption algorithms.
*/
export type RsaEncryptionAlgorithm = "RSA1_5" | "RSA-OAEP" | "RSA-OAEP-256";
/**
* Encryption parameters for RSA encryption algorithms.
*/
export interface RsaEncryptParameters {
/**
* The encryption algorithm to use.
*/
algorithm: RsaEncryptionAlgorithm;
/**
* The plain text to encrypt.
*/
plaintext: Uint8Array;
}
/**
* A union type representing all supported AES-GCM encryption algorithms.
*/
export type AesGcmEncryptionAlgorithm = "A128GCM" | "A192GCM" | "A256GCM";
/**
* Encryption parameters for AES-GCM encryption algorithms.
*/
export interface AesGcmEncryptParameters {
/**
* The encryption algorithm to use.
*/
algorithm: AesGcmEncryptionAlgorithm;
/**
* The plain text to encrypt.
*/
plaintext: Uint8Array;
/**
* Optional data that is authenticated but not encrypted.
*/
additionalAuthenticatedData?: Uint8Array;
}
/**
* A union type representing all supported AES-CBC encryption algorithms.
*/
export type AesCbcEncryptionAlgorithm = "A128CBC" | "A192CBC" | "A256CBC" | "A128CBCPAD" | "A192CBCPAD" | "A256CBCPAD";
/**
* Encryption parameters for AES-CBC encryption algorithms.
*/
export interface AesCbcEncryptParameters {
/**
* The encryption algorithm to use.
*/
algorithm: AesCbcEncryptionAlgorithm;
/**
* The plain text to encrypt.
*/
plaintext: Uint8Array;
/**
* The initialization vector used for encryption. If omitted we will attempt to generate an IV using crypto's `randomBytes` functionality.
* An error will be thrown if creating an IV fails, and you may recover by passing in your own cryptographically secure IV.
*
* When passing your own IV, make sure you use a cryptographically random, non-repeating IV.
*/
iv?: Uint8Array;
}
/**
* A type representing all currently supported encryption parameters as they apply to different encryption algorithms.
*/
export type EncryptParameters = RsaEncryptParameters | AesGcmEncryptParameters | AesCbcEncryptParameters;
/**
* Decryption parameters for RSA encryption algorithms.
*/
export interface RsaDecryptParameters {
/**
* The encryption algorithm to use.
*/
algorithm: RsaEncryptionAlgorithm;
/**
* The ciphertext to decrypt.
*/
ciphertext: Uint8Array;
}
/**
* Decryption parameters for AES-GCM encryption algorithms.
*/
export interface AesGcmDecryptParameters {
/**
* The encryption algorithm to use.
*/
algorithm: AesGcmEncryptionAlgorithm;
/**
* The ciphertext to decrypt.
*/
ciphertext: Uint8Array;
/**
* The initialization vector (or nonce) generated during encryption.
*/
iv: Uint8Array;
/**
* The authentication tag generated during encryption.
*/
authenticationTag: Uint8Array;
/**
* Optional data that is authenticated but not encrypted.
*/
additionalAuthenticatedData?: Uint8Array;
}
/**
* Decryption parameters for AES-CBC encryption algorithms.
*/
export interface AesCbcDecryptParameters {
/**
* The encryption algorithm to use.
*/
algorithm: AesCbcEncryptionAlgorithm;
/**
* The initialization vector used during encryption.
*/
/**
* The ciphertext to decrypt. Microsoft recommends you not use CBC without first ensuring the integrity of the ciphertext using an HMAC, for example.
* See https://learn.microsoft.com/dotnet/standard/security/vulnerabilities-cbc-mode for more information.
*/
ciphertext: Uint8Array;
/**
* The initialization vector generated during encryption.
*/
iv: Uint8Array;
}
/**
* A type representing all currently supported decryption parameters as they apply to different encryption algorithms.
*/
export type DecryptParameters = RsaDecryptParameters | AesGcmDecryptParameters | AesCbcDecryptParameters;
/**
* The various key types a {@link CryptographyClient} can hold.
* The key may be an identifier (URL) to a KeyVault key, the actual KeyVault key,
* or a local-only JsonWebKey.
*
* If an identifier is used, an attempt will be made to exchange it for a {@link KeyVaultKey} during the first operation call. If this attempt fails, the identifier
* will become a remote-only identifier and the {@link CryptographyClient} will only be able to perform remote operations.
*/
export type CryptographyClientKey = {
kind: "identifier";
value: string;
} | {
kind: "remoteOnlyIdentifier";
value: string;
} | {
kind: "KeyVaultKey";
value: KeyVaultKey;
} | {
kind: "JsonWebKey";
value: JsonWebKey;
};
//# sourceMappingURL=cryptographyClientModels.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"cryptographyClientModels.d.ts","sourceRoot":"","sources":["../../src/cryptographyClientModels.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAExE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EACL,6BAA6B,IAAI,mBAAmB,EACpD,mBAAmB,IAAI,YAAY,EACnC,wBAAwB,IAAI,kBAAkB,EAC9C,iCAAiC,IAAI,wBAAwB,EAC7D,kCAAkC,IAAI,yBAAyB,EAC/D,4BAA4B,IAAI,kBAAkB,EAClD,mBAAmB,IAAI,aAAa,EACpC,2BAA2B,IAAI,iCAAiC,EACjE,MAAM,6BAA6B,CAAC;AAErC,OAAO,EACL,mBAAmB,EACnB,YAAY,EACZ,yBAAyB,EACzB,kBAAkB,EAClB,iCAAiC,EACjC,aAAa,EACb,wBAAwB,EACxB,kBAAkB,GACnB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,gBAAgB,GACxB,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,UAAU,GACV,cAAc,GACd,QAAQ,GACR,kBAAkB,GAClB,sBAAsB,CAAC;AAE3B;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,MAAM,EAAE,UAAU,CAAC;IACnB;;OAEG;IACH,SAAS,EAAE,mBAAmB,CAAC;IAC/B;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,EAAE,CAAC,EAAE,UAAU,CAAC;IAChB;;OAEG;IACH,iBAAiB,CAAC,EAAE,UAAU,CAAC;IAC/B;;OAEG;IACH,2BAA2B,CAAC,EAAE,UAAU,CAAC;CAC1C;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB;;OAEG;IACH,MAAM,EAAE,UAAU,CAAC;IACnB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,SAAS,EAAE,gBAAgB,CAAC;CAC7B;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,MAAM,EAAE,UAAU,CAAC;IACnB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,SAAS,EAAE,gBAAgB,CAAC;CAC7B;AACD;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,MAAM,EAAE,UAAU,CAAC;IACnB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,SAAS,EAAE,mBAAmB,CAAC;CAChC;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB;;OAEG;IACH,MAAM,EAAE,UAAU,CAAC;IACnB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,SAAS,EAAE,kBAAkB,CAAC;CAC/B;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,MAAM,EAAE,OAAO,CAAC;IAChB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,cAAe,SAAQ,mBAAmB;CAAG;AAE9D;;GAEG;AACH,MAAM,WAAW,cAAe,SAAQ,mBAAmB;CAAG;AAE9D;;GAEG;AACH,MAAM,WAAW,WAAY,SAAQ,mBAAmB;CAAG;AAE3D;;GAEG;AACH,MAAM,WAAW,aAAc,SAAQ,mBAAmB;CAAG;AAE7D;;GAEG;AACH,MAAM,WAAW,iBAAkB,SAAQ,mBAAmB;CAAG;AAEjE;;GAEG;AACH,MAAM,WAAW,cAAe,SAAQ,mBAAmB;CAAG;AAE9D;;GAEG;AACH,MAAM,WAAW,gBAAiB,SAAQ,mBAAmB;CAAG;AAEhE;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG,QAAQ,GAAG,UAAU,GAAG,cAAc,CAAC;AAE5E;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,SAAS,EAAE,sBAAsB,CAAC;IAClC;;OAEG;IACH,SAAS,EAAE,UAAU,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,MAAM,yBAAyB,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,CAAC;AAE1E;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC;;OAEG;IACH,SAAS,EAAE,yBAAyB,CAAC;IACrC;;OAEG;IACH,SAAS,EAAE,UAAU,CAAC;IACtB;;OAEG;IACH,2BAA2B,CAAC,EAAE,UAAU,CAAC;CAC1C;AAED;;GAEG;AACH,MAAM,MAAM,yBAAyB,GACjC,SAAS,GACT,SAAS,GACT,SAAS,GACT,YAAY,GACZ,YAAY,GACZ,YAAY,CAAC;AAEjB;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC;;OAEG;IACH,SAAS,EAAE,yBAAyB,CAAC;IACrC;;OAEG;IACH,SAAS,EAAE,UAAU,CAAC;IACtB;;;;;OAKG;IACH,EAAE,CAAC,EAAE,UAAU,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,MAAM,iBAAiB,GACzB,oBAAoB,GACpB,uBAAuB,GACvB,uBAAuB,CAAC;AAE5B;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,SAAS,EAAE,sBAAsB,CAAC;IAClC;;OAEG;IACH,UAAU,EAAE,UAAU,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC;;OAEG;IACH,SAAS,EAAE,yBAAyB,CAAC;IACrC;;OAEG;IACH,UAAU,EAAE,UAAU,CAAC;IACvB;;OAEG;IACH,EAAE,EAAE,UAAU,CAAC;IACf;;OAEG;IACH,iBAAiB,EAAE,UAAU,CAAC;IAC9B;;OAEG;IACH,2BAA2B,CAAC,EAAE,UAAU,CAAC;CAC1C;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC;;OAEG;IACH,SAAS,EAAE,yBAAyB,CAAC;IACrC;;OAEG;IACH;;;OAGG;IACH,UAAU,EAAE,UAAU,CAAC;IACvB;;OAEG;IACH,EAAE,EAAE,UAAU,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,MAAM,iBAAiB,GACzB,oBAAoB,GACpB,uBAAuB,GACvB,uBAAuB,CAAC;AAE5B;;;;;;;GAOG;AACH,MAAM,MAAM,qBAAqB,GAC7B;IACE,IAAI,EAAE,YAAY,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;CACf,GACD;IACE,IAAI,EAAE,sBAAsB,CAAC;IAC7B,KAAK,EAAE,MAAM,CAAC;CACf,GACD;IACE,IAAI,EAAE,aAAa,CAAC;IACpB,KAAK,EAAE,WAAW,CAAC;CACpB,GACD;IACE,IAAI,EAAE,YAAY,CAAC;IACnB,KAAK,EAAE,UAAU,CAAC;CACnB,CAAC"}

View File

@ -0,0 +1,5 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { KnownJsonWebKeyCurveName as KnownKeyCurveNames, KnownJsonWebKeySignatureAlgorithm as KnownSignatureAlgorithms, KnownJsonWebKeyEncryptionAlgorithm as KnownEncryptionAlgorithms, KnownJsonWebKeyType as KnownKeyTypes, KnownKeyEncryptionAlgorithm as KnownKeyExportEncryptionAlgorithm, } from "./generated/models/index.js";
export { KnownEncryptionAlgorithms, KnownKeyCurveNames, KnownKeyExportEncryptionAlgorithm, KnownKeyTypes, KnownSignatureAlgorithms, };
//# sourceMappingURL=cryptographyClientModels.js.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,4 @@
export { createKeyVault, KeyVaultContext, KeyVaultClientOptionalParams, } from "./keyVaultContext.js";
export { getKeyAttestation, getRandomBytes, updateKeyRotationPolicy, getKeyRotationPolicy, recoverDeletedKey, purgeDeletedKey, getDeletedKey, getDeletedKeys, release, unwrapKey, wrapKey, verify, sign, decrypt, encrypt, restoreKey, backupKey, getKeys, getKeyVersions, getKey, updateKey, deleteKey, importKey, rotateKey, createKey, } from "./operations.js";
export { GetKeyAttestationOptionalParams, GetRandomBytesOptionalParams, UpdateKeyRotationPolicyOptionalParams, GetKeyRotationPolicyOptionalParams, RecoverDeletedKeyOptionalParams, PurgeDeletedKeyOptionalParams, GetDeletedKeyOptionalParams, GetDeletedKeysOptionalParams, ReleaseOptionalParams, UnwrapKeyOptionalParams, WrapKeyOptionalParams, VerifyOptionalParams, SignOptionalParams, DecryptOptionalParams, EncryptOptionalParams, RestoreKeyOptionalParams, BackupKeyOptionalParams, GetKeysOptionalParams, GetKeyVersionsOptionalParams, GetKeyOptionalParams, UpdateKeyOptionalParams, DeleteKeyOptionalParams, ImportKeyOptionalParams, RotateKeyOptionalParams, CreateKeyOptionalParams, } from "./options.js";
//# sourceMappingURL=index.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/generated/api/index.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,cAAc,EACd,eAAe,EACf,4BAA4B,GAC7B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,uBAAuB,EACvB,oBAAoB,EACpB,iBAAiB,EACjB,eAAe,EACf,aAAa,EACb,cAAc,EACd,OAAO,EACP,SAAS,EACT,OAAO,EACP,MAAM,EACN,IAAI,EACJ,OAAO,EACP,OAAO,EACP,UAAU,EACV,SAAS,EACT,OAAO,EACP,cAAc,EACd,MAAM,EACN,SAAS,EACT,SAAS,EACT,SAAS,EACT,SAAS,EACT,SAAS,GACV,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,+BAA+B,EAC/B,4BAA4B,EAC5B,qCAAqC,EACrC,kCAAkC,EAClC,+BAA+B,EAC/B,6BAA6B,EAC7B,2BAA2B,EAC3B,4BAA4B,EAC5B,qBAAqB,EACrB,uBAAuB,EACvB,qBAAqB,EACrB,oBAAoB,EACpB,kBAAkB,EAClB,qBAAqB,EACrB,qBAAqB,EACrB,wBAAwB,EACxB,uBAAuB,EACvB,qBAAqB,EACrB,4BAA4B,EAC5B,oBAAoB,EACpB,uBAAuB,EACvB,uBAAuB,EACvB,uBAAuB,EACvB,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,cAAc,CAAC"}

View File

@ -0,0 +1,5 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
export { createKeyVault, } from "./keyVaultContext.js";
export { getKeyAttestation, getRandomBytes, updateKeyRotationPolicy, getKeyRotationPolicy, recoverDeletedKey, purgeDeletedKey, getDeletedKey, getDeletedKeys, release, unwrapKey, wrapKey, verify, sign, decrypt, encrypt, restoreKey, backupKey, getKeys, getKeyVersions, getKey, updateKey, deleteKey, importKey, rotateKey, createKey, } from "./operations.js";
//# sourceMappingURL=index.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/generated/api/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EACL,cAAc,GAGf,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,uBAAuB,EACvB,oBAAoB,EACpB,iBAAiB,EACjB,eAAe,EACf,aAAa,EACb,cAAc,EACd,OAAO,EACP,SAAS,EACT,OAAO,EACP,MAAM,EACN,IAAI,EACJ,OAAO,EACP,OAAO,EACP,UAAU,EACV,SAAS,EACT,OAAO,EACP,cAAc,EACd,MAAM,EACN,SAAS,EACT,SAAS,EACT,SAAS,EACT,SAAS,EACT,SAAS,GACV,MAAM,iBAAiB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nexport {\n createKeyVault,\n KeyVaultContext,\n KeyVaultClientOptionalParams,\n} from \"./keyVaultContext.js\";\nexport {\n getKeyAttestation,\n getRandomBytes,\n updateKeyRotationPolicy,\n getKeyRotationPolicy,\n recoverDeletedKey,\n purgeDeletedKey,\n getDeletedKey,\n getDeletedKeys,\n release,\n unwrapKey,\n wrapKey,\n verify,\n sign,\n decrypt,\n encrypt,\n restoreKey,\n backupKey,\n getKeys,\n getKeyVersions,\n getKey,\n updateKey,\n deleteKey,\n importKey,\n rotateKey,\n createKey,\n} from \"./operations.js\";\nexport {\n GetKeyAttestationOptionalParams,\n GetRandomBytesOptionalParams,\n UpdateKeyRotationPolicyOptionalParams,\n GetKeyRotationPolicyOptionalParams,\n RecoverDeletedKeyOptionalParams,\n PurgeDeletedKeyOptionalParams,\n GetDeletedKeyOptionalParams,\n GetDeletedKeysOptionalParams,\n ReleaseOptionalParams,\n UnwrapKeyOptionalParams,\n WrapKeyOptionalParams,\n VerifyOptionalParams,\n SignOptionalParams,\n DecryptOptionalParams,\n EncryptOptionalParams,\n RestoreKeyOptionalParams,\n BackupKeyOptionalParams,\n GetKeysOptionalParams,\n GetKeyVersionsOptionalParams,\n GetKeyOptionalParams,\n UpdateKeyOptionalParams,\n DeleteKeyOptionalParams,\n ImportKeyOptionalParams,\n RotateKeyOptionalParams,\n CreateKeyOptionalParams,\n} from \"./options.js\";\n"]}

View File

@ -0,0 +1,17 @@
import { Client, ClientOptions } from "@azure-rest/core-client";
import { TokenCredential } from "@azure/core-auth";
/** The key vault client performs cryptographic key operations and vault operations against the Key Vault service. */
export interface KeyVaultContext extends Client {
/** The API version to use for this operation. */
/** Known values of {@link KnownVersions} that the service accepts. */
apiVersion: string;
}
/** Optional parameters for the client. */
export interface KeyVaultClientOptionalParams extends ClientOptions {
/** The API version to use for this operation. */
/** Known values of {@link KnownVersions} that the service accepts. */
apiVersion?: string;
}
/** The key vault client performs cryptographic key operations and vault operations against the Key Vault service. */
export declare function createKeyVault(endpointParam: string, credential: TokenCredential, options?: KeyVaultClientOptionalParams): KeyVaultContext;
//# sourceMappingURL=keyVaultContext.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"keyVaultContext.d.ts","sourceRoot":"","sources":["../../../../src/generated/api/keyVaultContext.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,MAAM,EAAE,aAAa,EAAa,MAAM,yBAAyB,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnD,qHAAqH;AACrH,MAAM,WAAW,eAAgB,SAAQ,MAAM;IAC7C,iDAAiD;IACjD,sEAAsE;IACtE,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,0CAA0C;AAC1C,MAAM,WAAW,4BAA6B,SAAQ,aAAa;IACjE,iDAAiD;IACjD,sEAAsE;IACtE,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,qHAAqH;AACrH,wBAAgB,cAAc,CAC5B,aAAa,EAAE,MAAM,EACrB,UAAU,EAAE,eAAe,EAC3B,OAAO,GAAE,4BAAiC,GACzC,eAAe,CAqCjB"}

View File

@ -0,0 +1,37 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { __rest } from "tslib";
import { logger } from "../logger.js";
import { getClient } from "@azure-rest/core-client";
/** The key vault client performs cryptographic key operations and vault operations against the Key Vault service. */
export function createKeyVault(endpointParam, credential, options = {}) {
var _a, _b, _c, _d, _e, _f, _g, _h;
const endpointUrl = (_b = (_a = options.endpoint) !== null && _a !== void 0 ? _a : options.baseUrl) !== null && _b !== void 0 ? _b : String(endpointParam);
const prefixFromOptions = (_c = options === null || options === void 0 ? void 0 : options.userAgentOptions) === null || _c === void 0 ? void 0 : _c.userAgentPrefix;
const userAgentInfo = `azsdk-js-keyvault-keys/1.0.0-beta.1`;
const userAgentPrefix = prefixFromOptions
? `${prefixFromOptions} azsdk-js-api ${userAgentInfo}`
: `azsdk-js-api ${userAgentInfo}`;
const _j = Object.assign(Object.assign({}, options), { userAgentOptions: { userAgentPrefix }, loggingOptions: { logger: (_e = (_d = options.loggingOptions) === null || _d === void 0 ? void 0 : _d.logger) !== null && _e !== void 0 ? _e : logger.info }, credentials: {
scopes: (_g = (_f = options.credentials) === null || _f === void 0 ? void 0 : _f.scopes) !== null && _g !== void 0 ? _g : [
"https://vault.azure.net/.default",
],
} }), { apiVersion: _ } = _j, updatedOptions = __rest(_j, ["apiVersion"]);
const clientContext = getClient(endpointUrl, credential, updatedOptions);
clientContext.pipeline.removePolicy({ name: "ApiVersionPolicy" });
const apiVersion = (_h = options.apiVersion) !== null && _h !== void 0 ? _h : "7.6";
clientContext.pipeline.addPolicy({
name: "ClientApiVersionPolicy",
sendRequest: (req, next) => {
// Use the apiVersion defined in request url directly
// Append one if there is no apiVersion and we have one at client options
const url = new URL(req.url);
if (!url.searchParams.get("api-version")) {
req.url = `${req.url}${Array.from(url.searchParams.keys()).length > 0 ? "&" : "?"}api-version=${apiVersion}`;
}
return next(req);
},
});
return Object.assign(Object.assign({}, clientContext), { apiVersion });
}
//# sourceMappingURL=keyVaultContext.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"keyVaultContext.js","sourceRoot":"","sources":["../../../../src/generated/api/keyVaultContext.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;AAElC,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC,OAAO,EAAyB,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAiB3E,qHAAqH;AACrH,MAAM,UAAU,cAAc,CAC5B,aAAqB,EACrB,UAA2B,EAC3B,UAAwC,EAAE;;IAE1C,MAAM,WAAW,GACf,MAAA,MAAA,OAAO,CAAC,QAAQ,mCAAI,OAAO,CAAC,OAAO,mCAAI,MAAM,CAAC,aAAa,CAAC,CAAC;IAC/D,MAAM,iBAAiB,GAAG,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,gBAAgB,0CAAE,eAAe,CAAC;IACrE,MAAM,aAAa,GAAG,qCAAqC,CAAC;IAC5D,MAAM,eAAe,GAAG,iBAAiB;QACvC,CAAC,CAAC,GAAG,iBAAiB,iBAAiB,aAAa,EAAE;QACtD,CAAC,CAAC,gBAAgB,aAAa,EAAE,CAAC;IACpC,MAAM,qCACD,OAAO,KACV,gBAAgB,EAAE,EAAE,eAAe,EAAE,EACrC,cAAc,EAAE,EAAE,MAAM,EAAE,MAAA,MAAA,OAAO,CAAC,cAAc,0CAAE,MAAM,mCAAI,MAAM,CAAC,IAAI,EAAE,EACzE,WAAW,EAAE;YACX,MAAM,EAAE,MAAA,MAAA,OAAO,CAAC,WAAW,0CAAE,MAAM,mCAAI;gBACrC,kCAAkC;aACnC;SACF,GACF,EATK,EAAE,UAAU,EAAE,CAAC,OASpB,EATyB,cAAc,cAAlC,cAAoC,CASzC,CAAC;IACF,MAAM,aAAa,GAAG,SAAS,CAAC,WAAW,EAAE,UAAU,EAAE,cAAc,CAAC,CAAC;IACzE,aAAa,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,IAAI,EAAE,kBAAkB,EAAE,CAAC,CAAC;IAClE,MAAM,UAAU,GAAG,MAAA,OAAO,CAAC,UAAU,mCAAI,KAAK,CAAC;IAC/C,aAAa,CAAC,QAAQ,CAAC,SAAS,CAAC;QAC/B,IAAI,EAAE,wBAAwB;QAC9B,WAAW,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;YACzB,qDAAqD;YACrD,yEAAyE;YACzE,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YAC7B,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,CAAC;gBACzC,GAAG,CAAC,GAAG,GAAG,GAAG,GAAG,CAAC,GAAG,GAClB,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GACzD,eAAe,UAAU,EAAE,CAAC;YAC9B,CAAC;YAED,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;QACnB,CAAC;KACF,CAAC,CAAC;IACH,OAAO,gCAAK,aAAa,KAAE,UAAU,GAAqB,CAAC;AAC7D,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { logger } from \"../logger.js\";\nimport { KnownVersions } from \"../models/models.js\";\nimport { Client, ClientOptions, getClient } from \"@azure-rest/core-client\";\nimport { TokenCredential } from \"@azure/core-auth\";\n\n/** The key vault client performs cryptographic key operations and vault operations against the Key Vault service. */\nexport interface KeyVaultContext extends Client {\n /** The API version to use for this operation. */\n /** Known values of {@link KnownVersions} that the service accepts. */\n apiVersion: string;\n}\n\n/** Optional parameters for the client. */\nexport interface KeyVaultClientOptionalParams extends ClientOptions {\n /** The API version to use for this operation. */\n /** Known values of {@link KnownVersions} that the service accepts. */\n apiVersion?: string;\n}\n\n/** The key vault client performs cryptographic key operations and vault operations against the Key Vault service. */\nexport function createKeyVault(\n endpointParam: string,\n credential: TokenCredential,\n options: KeyVaultClientOptionalParams = {},\n): KeyVaultContext {\n const endpointUrl =\n options.endpoint ?? options.baseUrl ?? String(endpointParam);\n const prefixFromOptions = options?.userAgentOptions?.userAgentPrefix;\n const userAgentInfo = `azsdk-js-keyvault-keys/1.0.0-beta.1`;\n const userAgentPrefix = prefixFromOptions\n ? `${prefixFromOptions} azsdk-js-api ${userAgentInfo}`\n : `azsdk-js-api ${userAgentInfo}`;\n const { apiVersion: _, ...updatedOptions } = {\n ...options,\n userAgentOptions: { userAgentPrefix },\n loggingOptions: { logger: options.loggingOptions?.logger ?? logger.info },\n credentials: {\n scopes: options.credentials?.scopes ?? [\n \"https://vault.azure.net/.default\",\n ],\n },\n };\n const clientContext = getClient(endpointUrl, credential, updatedOptions);\n clientContext.pipeline.removePolicy({ name: \"ApiVersionPolicy\" });\n const apiVersion = options.apiVersion ?? \"7.6\";\n clientContext.pipeline.addPolicy({\n name: \"ClientApiVersionPolicy\",\n sendRequest: (req, next) => {\n // Use the apiVersion defined in request url directly\n // Append one if there is no apiVersion and we have one at client options\n const url = new URL(req.url);\n if (!url.searchParams.get(\"api-version\")) {\n req.url = `${req.url}${\n Array.from(url.searchParams.keys()).length > 0 ? \"&\" : \"?\"\n }api-version=${apiVersion}`;\n }\n\n return next(req);\n },\n });\n return { ...clientContext, apiVersion } as KeyVaultContext;\n}\n"]}

View File

@ -0,0 +1,106 @@
import { KeyVaultContext as Client } from "./index.js";
import { KeyCreateParameters, KeyBundle, KeyImportParameters, DeletedKeyBundle, KeyUpdateParameters, _KeyListResult, KeyItem, BackupKeyResult, KeyRestoreParameters, KeyOperationsParameters, KeyOperationResult, KeySignParameters, KeyVerifyParameters, KeyVerifyResult, KeyReleaseParameters, KeyReleaseResult, _DeletedKeyListResult, DeletedKeyItem, KeyRotationPolicy, GetRandomBytesRequest, RandomBytes } from "../models/models.js";
import { GetKeyAttestationOptionalParams, GetRandomBytesOptionalParams, UpdateKeyRotationPolicyOptionalParams, GetKeyRotationPolicyOptionalParams, RecoverDeletedKeyOptionalParams, PurgeDeletedKeyOptionalParams, GetDeletedKeyOptionalParams, GetDeletedKeysOptionalParams, ReleaseOptionalParams, UnwrapKeyOptionalParams, WrapKeyOptionalParams, VerifyOptionalParams, SignOptionalParams, DecryptOptionalParams, EncryptOptionalParams, RestoreKeyOptionalParams, BackupKeyOptionalParams, GetKeysOptionalParams, GetKeyVersionsOptionalParams, GetKeyOptionalParams, UpdateKeyOptionalParams, DeleteKeyOptionalParams, ImportKeyOptionalParams, RotateKeyOptionalParams, CreateKeyOptionalParams } from "./options.js";
import { PagedAsyncIterableIterator } from "../static-helpers/pagingHelpers.js";
import { StreamableMethod, PathUncheckedResponse } from "@azure-rest/core-client";
export declare function _getKeyAttestationSend(context: Client, keyName: string, keyVersion: string, options?: GetKeyAttestationOptionalParams): StreamableMethod;
export declare function _getKeyAttestationDeserialize(result: PathUncheckedResponse): Promise<KeyBundle>;
/** The get key attestation operation returns the key along with its attestation blob. This operation requires the keys/get permission. */
export declare function getKeyAttestation(context: Client, keyName: string, keyVersion: string, options?: GetKeyAttestationOptionalParams): Promise<KeyBundle>;
export declare function _getRandomBytesSend(context: Client, parameters: GetRandomBytesRequest, options?: GetRandomBytesOptionalParams): StreamableMethod;
export declare function _getRandomBytesDeserialize(result: PathUncheckedResponse): Promise<RandomBytes>;
/** Get the requested number of bytes containing random values from a managed HSM. */
export declare function getRandomBytes(context: Client, parameters: GetRandomBytesRequest, options?: GetRandomBytesOptionalParams): Promise<RandomBytes>;
export declare function _updateKeyRotationPolicySend(context: Client, keyName: string, keyRotationPolicy: KeyRotationPolicy, options?: UpdateKeyRotationPolicyOptionalParams): StreamableMethod;
export declare function _updateKeyRotationPolicyDeserialize(result: PathUncheckedResponse): Promise<KeyRotationPolicy>;
/** Set specified members in the key policy. Leave others as undefined. This operation requires the keys/update permission. */
export declare function updateKeyRotationPolicy(context: Client, keyName: string, keyRotationPolicy: KeyRotationPolicy, options?: UpdateKeyRotationPolicyOptionalParams): Promise<KeyRotationPolicy>;
export declare function _getKeyRotationPolicySend(context: Client, keyName: string, options?: GetKeyRotationPolicyOptionalParams): StreamableMethod;
export declare function _getKeyRotationPolicyDeserialize(result: PathUncheckedResponse): Promise<KeyRotationPolicy>;
/** The GetKeyRotationPolicy operation returns the specified key policy resources in the specified key vault. This operation requires the keys/get permission. */
export declare function getKeyRotationPolicy(context: Client, keyName: string, options?: GetKeyRotationPolicyOptionalParams): Promise<KeyRotationPolicy>;
export declare function _recoverDeletedKeySend(context: Client, keyName: string, options?: RecoverDeletedKeyOptionalParams): StreamableMethod;
export declare function _recoverDeletedKeyDeserialize(result: PathUncheckedResponse): Promise<KeyBundle>;
/** The Recover Deleted Key operation is applicable for deleted keys in soft-delete enabled vaults. It recovers the deleted key back to its latest version under /keys. An attempt to recover an non-deleted key will return an error. Consider this the inverse of the delete operation on soft-delete enabled vaults. This operation requires the keys/recover permission. */
export declare function recoverDeletedKey(context: Client, keyName: string, options?: RecoverDeletedKeyOptionalParams): Promise<KeyBundle>;
export declare function _purgeDeletedKeySend(context: Client, keyName: string, options?: PurgeDeletedKeyOptionalParams): StreamableMethod;
export declare function _purgeDeletedKeyDeserialize(result: PathUncheckedResponse): Promise<void>;
/** The Purge Deleted Key operation is applicable for soft-delete enabled vaults. While the operation can be invoked on any vault, it will return an error if invoked on a non soft-delete enabled vault. This operation requires the keys/purge permission. */
export declare function purgeDeletedKey(context: Client, keyName: string, options?: PurgeDeletedKeyOptionalParams): Promise<void>;
export declare function _getDeletedKeySend(context: Client, keyName: string, options?: GetDeletedKeyOptionalParams): StreamableMethod;
export declare function _getDeletedKeyDeserialize(result: PathUncheckedResponse): Promise<DeletedKeyBundle>;
/** The Get Deleted Key operation is applicable for soft-delete enabled vaults. While the operation can be invoked on any vault, it will return an error if invoked on a non soft-delete enabled vault. This operation requires the keys/get permission. */
export declare function getDeletedKey(context: Client, keyName: string, options?: GetDeletedKeyOptionalParams): Promise<DeletedKeyBundle>;
export declare function _getDeletedKeysSend(context: Client, options?: GetDeletedKeysOptionalParams): StreamableMethod;
export declare function _getDeletedKeysDeserialize(result: PathUncheckedResponse): Promise<_DeletedKeyListResult>;
/** Retrieves a list of the keys in the Key Vault as JSON Web Key structures that contain the public part of a deleted key. This operation includes deletion-specific information. The Get Deleted Keys operation is applicable for vaults enabled for soft-delete. While the operation can be invoked on any vault, it will return an error if invoked on a non soft-delete enabled vault. This operation requires the keys/list permission. */
export declare function getDeletedKeys(context: Client, options?: GetDeletedKeysOptionalParams): PagedAsyncIterableIterator<DeletedKeyItem>;
export declare function _releaseSend(context: Client, keyName: string, keyVersion: string, parameters: KeyReleaseParameters, options?: ReleaseOptionalParams): StreamableMethod;
export declare function _releaseDeserialize(result: PathUncheckedResponse): Promise<KeyReleaseResult>;
/** The release key operation is applicable to all key types. The target key must be marked exportable. This operation requires the keys/release permission. */
export declare function release(context: Client, keyName: string, keyVersion: string, parameters: KeyReleaseParameters, options?: ReleaseOptionalParams): Promise<KeyReleaseResult>;
export declare function _unwrapKeySend(context: Client, keyName: string, keyVersion: string, parameters: KeyOperationsParameters, options?: UnwrapKeyOptionalParams): StreamableMethod;
export declare function _unwrapKeyDeserialize(result: PathUncheckedResponse): Promise<KeyOperationResult>;
/** The UNWRAP operation supports decryption of a symmetric key using the target key encryption key. This operation is the reverse of the WRAP operation. The UNWRAP operation applies to asymmetric and symmetric keys stored in Azure Key Vault since it uses the private portion of the key. This operation requires the keys/unwrapKey permission. */
export declare function unwrapKey(context: Client, keyName: string, keyVersion: string, parameters: KeyOperationsParameters, options?: UnwrapKeyOptionalParams): Promise<KeyOperationResult>;
export declare function _wrapKeySend(context: Client, keyName: string, keyVersion: string, parameters: KeyOperationsParameters, options?: WrapKeyOptionalParams): StreamableMethod;
export declare function _wrapKeyDeserialize(result: PathUncheckedResponse): Promise<KeyOperationResult>;
/** The WRAP operation supports encryption of a symmetric key using a key encryption key that has previously been stored in an Azure Key Vault. The WRAP operation is only strictly necessary for symmetric keys stored in Azure Key Vault since protection with an asymmetric key can be performed using the public portion of the key. This operation is supported for asymmetric keys as a convenience for callers that have a key-reference but do not have access to the public key material. This operation requires the keys/wrapKey permission. */
export declare function wrapKey(context: Client, keyName: string, keyVersion: string, parameters: KeyOperationsParameters, options?: WrapKeyOptionalParams): Promise<KeyOperationResult>;
export declare function _verifySend(context: Client, keyName: string, keyVersion: string, parameters: KeyVerifyParameters, options?: VerifyOptionalParams): StreamableMethod;
export declare function _verifyDeserialize(result: PathUncheckedResponse): Promise<KeyVerifyResult>;
/** The VERIFY operation is applicable to symmetric keys stored in Azure Key Vault. VERIFY is not strictly necessary for asymmetric keys stored in Azure Key Vault since signature verification can be performed using the public portion of the key but this operation is supported as a convenience for callers that only have a key-reference and not the public portion of the key. This operation requires the keys/verify permission. */
export declare function verify(context: Client, keyName: string, keyVersion: string, parameters: KeyVerifyParameters, options?: VerifyOptionalParams): Promise<KeyVerifyResult>;
export declare function _signSend(context: Client, keyName: string, keyVersion: string, parameters: KeySignParameters, options?: SignOptionalParams): StreamableMethod;
export declare function _signDeserialize(result: PathUncheckedResponse): Promise<KeyOperationResult>;
/** The SIGN operation is applicable to asymmetric and symmetric keys stored in Azure Key Vault since this operation uses the private portion of the key. This operation requires the keys/sign permission. */
export declare function sign(context: Client, keyName: string, keyVersion: string, parameters: KeySignParameters, options?: SignOptionalParams): Promise<KeyOperationResult>;
export declare function _decryptSend(context: Client, keyName: string, keyVersion: string, parameters: KeyOperationsParameters, options?: DecryptOptionalParams): StreamableMethod;
export declare function _decryptDeserialize(result: PathUncheckedResponse): Promise<KeyOperationResult>;
/** The DECRYPT operation decrypts a well-formed block of ciphertext using the target encryption key and specified algorithm. This operation is the reverse of the ENCRYPT operation; only a single block of data may be decrypted, the size of this block is dependent on the target key and the algorithm to be used. The DECRYPT operation applies to asymmetric and symmetric keys stored in Azure Key Vault since it uses the private portion of the key. This operation requires the keys/decrypt permission. Microsoft recommends not to use CBC algorithms for decryption without first ensuring the integrity of the ciphertext using an HMAC, for example. See https://learn.microsoft.com/dotnet/standard/security/vulnerabilities-cbc-mode for more information. */
export declare function decrypt(context: Client, keyName: string, keyVersion: string, parameters: KeyOperationsParameters, options?: DecryptOptionalParams): Promise<KeyOperationResult>;
export declare function _encryptSend(context: Client, keyName: string, keyVersion: string, parameters: KeyOperationsParameters, options?: EncryptOptionalParams): StreamableMethod;
export declare function _encryptDeserialize(result: PathUncheckedResponse): Promise<KeyOperationResult>;
/** The ENCRYPT operation encrypts an arbitrary sequence of bytes using an encryption key that is stored in Azure Key Vault. Note that the ENCRYPT operation only supports a single block of data, the size of which is dependent on the target key and the encryption algorithm to be used. The ENCRYPT operation is only strictly necessary for symmetric keys stored in Azure Key Vault since protection with an asymmetric key can be performed using public portion of the key. This operation is supported for asymmetric keys as a convenience for callers that have a key-reference but do not have access to the public key material. This operation requires the keys/encrypt permission. */
export declare function encrypt(context: Client, keyName: string, keyVersion: string, parameters: KeyOperationsParameters, options?: EncryptOptionalParams): Promise<KeyOperationResult>;
export declare function _restoreKeySend(context: Client, parameters: KeyRestoreParameters, options?: RestoreKeyOptionalParams): StreamableMethod;
export declare function _restoreKeyDeserialize(result: PathUncheckedResponse): Promise<KeyBundle>;
/** Imports a previously backed up key into Azure Key Vault, restoring the key, its key identifier, attributes and access control policies. The RESTORE operation may be used to import a previously backed up key. Individual versions of a key cannot be restored. The key is restored in its entirety with the same key name as it had when it was backed up. If the key name is not available in the target Key Vault, the RESTORE operation will be rejected. While the key name is retained during restore, the final key identifier will change if the key is restored to a different vault. Restore will restore all versions and preserve version identifiers. The RESTORE operation is subject to security constraints: The target Key Vault must be owned by the same Microsoft Azure Subscription as the source Key Vault The user must have RESTORE permission in the target Key Vault. This operation requires the keys/restore permission. */
export declare function restoreKey(context: Client, parameters: KeyRestoreParameters, options?: RestoreKeyOptionalParams): Promise<KeyBundle>;
export declare function _backupKeySend(context: Client, keyName: string, options?: BackupKeyOptionalParams): StreamableMethod;
export declare function _backupKeyDeserialize(result: PathUncheckedResponse): Promise<BackupKeyResult>;
/** The Key Backup operation exports a key from Azure Key Vault in a protected form. Note that this operation does NOT return key material in a form that can be used outside the Azure Key Vault system, the returned key material is either protected to a Azure Key Vault HSM or to Azure Key Vault itself. The intent of this operation is to allow a client to GENERATE a key in one Azure Key Vault instance, BACKUP the key, and then RESTORE it into another Azure Key Vault instance. The BACKUP operation may be used to export, in protected form, any key type from Azure Key Vault. Individual versions of a key cannot be backed up. BACKUP / RESTORE can be performed within geographical boundaries only; meaning that a BACKUP from one geographical area cannot be restored to another geographical area. For example, a backup from the US geographical area cannot be restored in an EU geographical area. This operation requires the key/backup permission. */
export declare function backupKey(context: Client, keyName: string, options?: BackupKeyOptionalParams): Promise<BackupKeyResult>;
export declare function _getKeysSend(context: Client, options?: GetKeysOptionalParams): StreamableMethod;
export declare function _getKeysDeserialize(result: PathUncheckedResponse): Promise<_KeyListResult>;
/** Retrieves a list of the keys in the Key Vault as JSON Web Key structures that contain the public part of a stored key. The LIST operation is applicable to all key types, however only the base key identifier, attributes, and tags are provided in the response. Individual versions of a key are not listed in the response. This operation requires the keys/list permission. */
export declare function getKeys(context: Client, options?: GetKeysOptionalParams): PagedAsyncIterableIterator<KeyItem>;
export declare function _getKeyVersionsSend(context: Client, keyName: string, options?: GetKeyVersionsOptionalParams): StreamableMethod;
export declare function _getKeyVersionsDeserialize(result: PathUncheckedResponse): Promise<_KeyListResult>;
/** The full key identifier, attributes, and tags are provided in the response. This operation requires the keys/list permission. */
export declare function getKeyVersions(context: Client, keyName: string, options?: GetKeyVersionsOptionalParams): PagedAsyncIterableIterator<KeyItem>;
export declare function _getKeySend(context: Client, keyName: string, keyVersion: string, options?: GetKeyOptionalParams): StreamableMethod;
export declare function _getKeyDeserialize(result: PathUncheckedResponse): Promise<KeyBundle>;
/** The get key operation is applicable to all key types. If the requested key is symmetric, then no key material is released in the response. This operation requires the keys/get permission. */
export declare function getKey(context: Client, keyName: string, keyVersion: string, options?: GetKeyOptionalParams): Promise<KeyBundle>;
export declare function _updateKeySend(context: Client, keyName: string, keyVersion: string, parameters: KeyUpdateParameters, options?: UpdateKeyOptionalParams): StreamableMethod;
export declare function _updateKeyDeserialize(result: PathUncheckedResponse): Promise<KeyBundle>;
/** In order to perform this operation, the key must already exist in the Key Vault. Note: The cryptographic material of a key itself cannot be changed. This operation requires the keys/update permission. */
export declare function updateKey(context: Client, keyName: string, keyVersion: string, parameters: KeyUpdateParameters, options?: UpdateKeyOptionalParams): Promise<KeyBundle>;
export declare function _deleteKeySend(context: Client, keyName: string, options?: DeleteKeyOptionalParams): StreamableMethod;
export declare function _deleteKeyDeserialize(result: PathUncheckedResponse): Promise<DeletedKeyBundle>;
/** The delete key operation cannot be used to remove individual versions of a key. This operation removes the cryptographic material associated with the key, which means the key is not usable for Sign/Verify, Wrap/Unwrap or Encrypt/Decrypt operations. This operation requires the keys/delete permission. */
export declare function deleteKey(context: Client, keyName: string, options?: DeleteKeyOptionalParams): Promise<DeletedKeyBundle>;
export declare function _importKeySend(context: Client, keyName: string, parameters: KeyImportParameters, options?: ImportKeyOptionalParams): StreamableMethod;
export declare function _importKeyDeserialize(result: PathUncheckedResponse): Promise<KeyBundle>;
/** The import key operation may be used to import any key type into an Azure Key Vault. If the named key already exists, Azure Key Vault creates a new version of the key. This operation requires the keys/import permission. */
export declare function importKey(context: Client, keyName: string, parameters: KeyImportParameters, options?: ImportKeyOptionalParams): Promise<KeyBundle>;
export declare function _rotateKeySend(context: Client, keyName: string, options?: RotateKeyOptionalParams): StreamableMethod;
export declare function _rotateKeyDeserialize(result: PathUncheckedResponse): Promise<KeyBundle>;
/** The operation will rotate the key based on the key policy. It requires the keys/rotate permission. */
export declare function rotateKey(context: Client, keyName: string, options?: RotateKeyOptionalParams): Promise<KeyBundle>;
export declare function _createKeySend(context: Client, keyName: string, parameters: KeyCreateParameters, options?: CreateKeyOptionalParams): StreamableMethod;
export declare function _createKeyDeserialize(result: PathUncheckedResponse): Promise<KeyBundle>;
/** The create key operation can be used to create any key type in Azure Key Vault. If the named key already exists, Azure Key Vault creates a new version of the key. It requires the keys/create permission. */
export declare function createKey(context: Client, keyName: string, parameters: KeyCreateParameters, options?: CreateKeyOptionalParams): Promise<KeyBundle>;
//# sourceMappingURL=operations.d.ts.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,663 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { keyCreateParametersSerializer, keyBundleDeserializer, keyVaultErrorDeserializer, keyImportParametersSerializer, deletedKeyBundleDeserializer, keyUpdateParametersSerializer, _keyListResultDeserializer, backupKeyResultDeserializer, keyRestoreParametersSerializer, keyOperationsParametersSerializer, keyOperationResultDeserializer, keySignParametersSerializer, keyVerifyParametersSerializer, keyVerifyResultDeserializer, keyReleaseParametersSerializer, keyReleaseResultDeserializer, _deletedKeyListResultDeserializer, keyRotationPolicySerializer, keyRotationPolicyDeserializer, getRandomBytesRequestSerializer, randomBytesDeserializer, } from "../models/models.js";
import { buildPagedAsyncIterator, } from "../static-helpers/pagingHelpers.js";
import { expandUrlTemplate } from "../static-helpers/urlTemplate.js";
import { createRestError, operationOptionsToRequestParameters, } from "@azure-rest/core-client";
export function _getKeyAttestationSend(context, keyName, keyVersion, options = { requestOptions: {} }) {
var _a, _b;
const path = expandUrlTemplate("/keys/{key-name}/{key-version}/attestation{?api%2Dversion}", {
"key-name": keyName,
"key-version": keyVersion,
"api%2Dversion": context.apiVersion,
}, {
allowReserved: (_a = options === null || options === void 0 ? void 0 : options.requestOptions) === null || _a === void 0 ? void 0 : _a.skipUrlEncoding,
});
return context
.path(path)
.get(Object.assign(Object.assign({}, operationOptionsToRequestParameters(options)), { headers: Object.assign({ accept: "application/json" }, (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.headers) }));
}
export async function _getKeyAttestationDeserialize(result) {
const expectedStatuses = ["200"];
if (!expectedStatuses.includes(result.status)) {
const error = createRestError(result);
error.details = keyVaultErrorDeserializer(result.body);
throw error;
}
return keyBundleDeserializer(result.body);
}
/** The get key attestation operation returns the key along with its attestation blob. This operation requires the keys/get permission. */
export async function getKeyAttestation(context, keyName, keyVersion, options = { requestOptions: {} }) {
const result = await _getKeyAttestationSend(context, keyName, keyVersion, options);
return _getKeyAttestationDeserialize(result);
}
export function _getRandomBytesSend(context, parameters, options = { requestOptions: {} }) {
var _a, _b;
const path = expandUrlTemplate("/rng{?api%2Dversion}", {
"api%2Dversion": context.apiVersion,
}, {
allowReserved: (_a = options === null || options === void 0 ? void 0 : options.requestOptions) === null || _a === void 0 ? void 0 : _a.skipUrlEncoding,
});
return context
.path(path)
.post(Object.assign(Object.assign({}, operationOptionsToRequestParameters(options)), { contentType: "application/json", headers: Object.assign({ accept: "application/json" }, (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.headers), body: getRandomBytesRequestSerializer(parameters) }));
}
export async function _getRandomBytesDeserialize(result) {
const expectedStatuses = ["200"];
if (!expectedStatuses.includes(result.status)) {
const error = createRestError(result);
error.details = keyVaultErrorDeserializer(result.body);
throw error;
}
return randomBytesDeserializer(result.body);
}
/** Get the requested number of bytes containing random values from a managed HSM. */
export async function getRandomBytes(context, parameters, options = { requestOptions: {} }) {
const result = await _getRandomBytesSend(context, parameters, options);
return _getRandomBytesDeserialize(result);
}
export function _updateKeyRotationPolicySend(context, keyName, keyRotationPolicy, options = { requestOptions: {} }) {
var _a, _b;
const path = expandUrlTemplate("/keys/{key-name}/rotationpolicy{?api%2Dversion}", {
"key-name": keyName,
"api%2Dversion": context.apiVersion,
}, {
allowReserved: (_a = options === null || options === void 0 ? void 0 : options.requestOptions) === null || _a === void 0 ? void 0 : _a.skipUrlEncoding,
});
return context
.path(path)
.put(Object.assign(Object.assign({}, operationOptionsToRequestParameters(options)), { contentType: "application/json", headers: Object.assign({ accept: "application/json" }, (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.headers), body: keyRotationPolicySerializer(keyRotationPolicy) }));
}
export async function _updateKeyRotationPolicyDeserialize(result) {
const expectedStatuses = ["200"];
if (!expectedStatuses.includes(result.status)) {
const error = createRestError(result);
error.details = keyVaultErrorDeserializer(result.body);
throw error;
}
return keyRotationPolicyDeserializer(result.body);
}
/** Set specified members in the key policy. Leave others as undefined. This operation requires the keys/update permission. */
export async function updateKeyRotationPolicy(context, keyName, keyRotationPolicy, options = { requestOptions: {} }) {
const result = await _updateKeyRotationPolicySend(context, keyName, keyRotationPolicy, options);
return _updateKeyRotationPolicyDeserialize(result);
}
export function _getKeyRotationPolicySend(context, keyName, options = { requestOptions: {} }) {
var _a, _b;
const path = expandUrlTemplate("/keys/{key-name}/rotationpolicy{?api%2Dversion}", {
"key-name": keyName,
"api%2Dversion": context.apiVersion,
}, {
allowReserved: (_a = options === null || options === void 0 ? void 0 : options.requestOptions) === null || _a === void 0 ? void 0 : _a.skipUrlEncoding,
});
return context
.path(path)
.get(Object.assign(Object.assign({}, operationOptionsToRequestParameters(options)), { headers: Object.assign({ accept: "application/json" }, (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.headers) }));
}
export async function _getKeyRotationPolicyDeserialize(result) {
const expectedStatuses = ["200"];
if (!expectedStatuses.includes(result.status)) {
const error = createRestError(result);
error.details = keyVaultErrorDeserializer(result.body);
throw error;
}
return keyRotationPolicyDeserializer(result.body);
}
/** The GetKeyRotationPolicy operation returns the specified key policy resources in the specified key vault. This operation requires the keys/get permission. */
export async function getKeyRotationPolicy(context, keyName, options = { requestOptions: {} }) {
const result = await _getKeyRotationPolicySend(context, keyName, options);
return _getKeyRotationPolicyDeserialize(result);
}
export function _recoverDeletedKeySend(context, keyName, options = { requestOptions: {} }) {
var _a, _b;
const path = expandUrlTemplate("/deletedkeys/{key-name}/recover{?api%2Dversion}", {
"key-name": keyName,
"api%2Dversion": context.apiVersion,
}, {
allowReserved: (_a = options === null || options === void 0 ? void 0 : options.requestOptions) === null || _a === void 0 ? void 0 : _a.skipUrlEncoding,
});
return context
.path(path)
.post(Object.assign(Object.assign({}, operationOptionsToRequestParameters(options)), { headers: Object.assign({ accept: "application/json" }, (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.headers) }));
}
export async function _recoverDeletedKeyDeserialize(result) {
const expectedStatuses = ["200"];
if (!expectedStatuses.includes(result.status)) {
const error = createRestError(result);
error.details = keyVaultErrorDeserializer(result.body);
throw error;
}
return keyBundleDeserializer(result.body);
}
/** The Recover Deleted Key operation is applicable for deleted keys in soft-delete enabled vaults. It recovers the deleted key back to its latest version under /keys. An attempt to recover an non-deleted key will return an error. Consider this the inverse of the delete operation on soft-delete enabled vaults. This operation requires the keys/recover permission. */
export async function recoverDeletedKey(context, keyName, options = { requestOptions: {} }) {
const result = await _recoverDeletedKeySend(context, keyName, options);
return _recoverDeletedKeyDeserialize(result);
}
export function _purgeDeletedKeySend(context, keyName, options = { requestOptions: {} }) {
var _a, _b;
const path = expandUrlTemplate("/deletedkeys/{key-name}{?api%2Dversion}", {
"key-name": keyName,
"api%2Dversion": context.apiVersion,
}, {
allowReserved: (_a = options === null || options === void 0 ? void 0 : options.requestOptions) === null || _a === void 0 ? void 0 : _a.skipUrlEncoding,
});
return context
.path(path)
.delete(Object.assign(Object.assign({}, operationOptionsToRequestParameters(options)), { headers: Object.assign({ accept: "application/json" }, (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.headers) }));
}
export async function _purgeDeletedKeyDeserialize(result) {
const expectedStatuses = ["204"];
if (!expectedStatuses.includes(result.status)) {
const error = createRestError(result);
error.details = keyVaultErrorDeserializer(result.body);
throw error;
}
return;
}
/** The Purge Deleted Key operation is applicable for soft-delete enabled vaults. While the operation can be invoked on any vault, it will return an error if invoked on a non soft-delete enabled vault. This operation requires the keys/purge permission. */
export async function purgeDeletedKey(context, keyName, options = { requestOptions: {} }) {
const result = await _purgeDeletedKeySend(context, keyName, options);
return _purgeDeletedKeyDeserialize(result);
}
export function _getDeletedKeySend(context, keyName, options = { requestOptions: {} }) {
var _a, _b;
const path = expandUrlTemplate("/deletedkeys/{key-name}{?api%2Dversion}", {
"key-name": keyName,
"api%2Dversion": context.apiVersion,
}, {
allowReserved: (_a = options === null || options === void 0 ? void 0 : options.requestOptions) === null || _a === void 0 ? void 0 : _a.skipUrlEncoding,
});
return context
.path(path)
.get(Object.assign(Object.assign({}, operationOptionsToRequestParameters(options)), { headers: Object.assign({ accept: "application/json" }, (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.headers) }));
}
export async function _getDeletedKeyDeserialize(result) {
const expectedStatuses = ["200"];
if (!expectedStatuses.includes(result.status)) {
const error = createRestError(result);
error.details = keyVaultErrorDeserializer(result.body);
throw error;
}
return deletedKeyBundleDeserializer(result.body);
}
/** The Get Deleted Key operation is applicable for soft-delete enabled vaults. While the operation can be invoked on any vault, it will return an error if invoked on a non soft-delete enabled vault. This operation requires the keys/get permission. */
export async function getDeletedKey(context, keyName, options = { requestOptions: {} }) {
const result = await _getDeletedKeySend(context, keyName, options);
return _getDeletedKeyDeserialize(result);
}
export function _getDeletedKeysSend(context, options = { requestOptions: {} }) {
var _a, _b;
const path = expandUrlTemplate("/deletedkeys{?api%2Dversion,maxresults}", {
"api%2Dversion": context.apiVersion,
maxresults: options === null || options === void 0 ? void 0 : options.maxresults,
}, {
allowReserved: (_a = options === null || options === void 0 ? void 0 : options.requestOptions) === null || _a === void 0 ? void 0 : _a.skipUrlEncoding,
});
return context
.path(path)
.get(Object.assign(Object.assign({}, operationOptionsToRequestParameters(options)), { headers: Object.assign({ accept: "application/json" }, (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.headers) }));
}
export async function _getDeletedKeysDeserialize(result) {
const expectedStatuses = ["200"];
if (!expectedStatuses.includes(result.status)) {
const error = createRestError(result);
error.details = keyVaultErrorDeserializer(result.body);
throw error;
}
return _deletedKeyListResultDeserializer(result.body);
}
/** Retrieves a list of the keys in the Key Vault as JSON Web Key structures that contain the public part of a deleted key. This operation includes deletion-specific information. The Get Deleted Keys operation is applicable for vaults enabled for soft-delete. While the operation can be invoked on any vault, it will return an error if invoked on a non soft-delete enabled vault. This operation requires the keys/list permission. */
export function getDeletedKeys(context, options = { requestOptions: {} }) {
return buildPagedAsyncIterator(context, () => _getDeletedKeysSend(context, options), _getDeletedKeysDeserialize, ["200"], { itemName: "value", nextLinkName: "nextLink" });
}
export function _releaseSend(context, keyName, keyVersion, parameters, options = { requestOptions: {} }) {
var _a, _b;
const path = expandUrlTemplate("/keys/{key-name}/{key-version}/release{?api%2Dversion}", {
"key-name": keyName,
"key-version": keyVersion,
"api%2Dversion": context.apiVersion,
}, {
allowReserved: (_a = options === null || options === void 0 ? void 0 : options.requestOptions) === null || _a === void 0 ? void 0 : _a.skipUrlEncoding,
});
return context
.path(path)
.post(Object.assign(Object.assign({}, operationOptionsToRequestParameters(options)), { contentType: "application/json", headers: Object.assign({ accept: "application/json" }, (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.headers), body: keyReleaseParametersSerializer(parameters) }));
}
export async function _releaseDeserialize(result) {
const expectedStatuses = ["200"];
if (!expectedStatuses.includes(result.status)) {
const error = createRestError(result);
error.details = keyVaultErrorDeserializer(result.body);
throw error;
}
return keyReleaseResultDeserializer(result.body);
}
/** The release key operation is applicable to all key types. The target key must be marked exportable. This operation requires the keys/release permission. */
export async function release(context, keyName, keyVersion, parameters, options = { requestOptions: {} }) {
const result = await _releaseSend(context, keyName, keyVersion, parameters, options);
return _releaseDeserialize(result);
}
export function _unwrapKeySend(context, keyName, keyVersion, parameters, options = { requestOptions: {} }) {
var _a, _b;
const path = expandUrlTemplate("/keys/{key-name}/{key-version}/unwrapkey{?api%2Dversion}", {
"key-name": keyName,
"key-version": keyVersion,
"api%2Dversion": context.apiVersion,
}, {
allowReserved: (_a = options === null || options === void 0 ? void 0 : options.requestOptions) === null || _a === void 0 ? void 0 : _a.skipUrlEncoding,
});
return context
.path(path)
.post(Object.assign(Object.assign({}, operationOptionsToRequestParameters(options)), { contentType: "application/json", headers: Object.assign({ accept: "application/json" }, (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.headers), body: keyOperationsParametersSerializer(parameters) }));
}
export async function _unwrapKeyDeserialize(result) {
const expectedStatuses = ["200"];
if (!expectedStatuses.includes(result.status)) {
const error = createRestError(result);
error.details = keyVaultErrorDeserializer(result.body);
throw error;
}
return keyOperationResultDeserializer(result.body);
}
/** The UNWRAP operation supports decryption of a symmetric key using the target key encryption key. This operation is the reverse of the WRAP operation. The UNWRAP operation applies to asymmetric and symmetric keys stored in Azure Key Vault since it uses the private portion of the key. This operation requires the keys/unwrapKey permission. */
export async function unwrapKey(context, keyName, keyVersion, parameters, options = { requestOptions: {} }) {
const result = await _unwrapKeySend(context, keyName, keyVersion, parameters, options);
return _unwrapKeyDeserialize(result);
}
export function _wrapKeySend(context, keyName, keyVersion, parameters, options = { requestOptions: {} }) {
var _a, _b;
const path = expandUrlTemplate("/keys/{key-name}/{key-version}/wrapkey{?api%2Dversion}", {
"key-name": keyName,
"key-version": keyVersion,
"api%2Dversion": context.apiVersion,
}, {
allowReserved: (_a = options === null || options === void 0 ? void 0 : options.requestOptions) === null || _a === void 0 ? void 0 : _a.skipUrlEncoding,
});
return context
.path(path)
.post(Object.assign(Object.assign({}, operationOptionsToRequestParameters(options)), { contentType: "application/json", headers: Object.assign({ accept: "application/json" }, (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.headers), body: keyOperationsParametersSerializer(parameters) }));
}
export async function _wrapKeyDeserialize(result) {
const expectedStatuses = ["200"];
if (!expectedStatuses.includes(result.status)) {
const error = createRestError(result);
error.details = keyVaultErrorDeserializer(result.body);
throw error;
}
return keyOperationResultDeserializer(result.body);
}
/** The WRAP operation supports encryption of a symmetric key using a key encryption key that has previously been stored in an Azure Key Vault. The WRAP operation is only strictly necessary for symmetric keys stored in Azure Key Vault since protection with an asymmetric key can be performed using the public portion of the key. This operation is supported for asymmetric keys as a convenience for callers that have a key-reference but do not have access to the public key material. This operation requires the keys/wrapKey permission. */
export async function wrapKey(context, keyName, keyVersion, parameters, options = { requestOptions: {} }) {
const result = await _wrapKeySend(context, keyName, keyVersion, parameters, options);
return _wrapKeyDeserialize(result);
}
export function _verifySend(context, keyName, keyVersion, parameters, options = { requestOptions: {} }) {
var _a, _b;
const path = expandUrlTemplate("/keys/{key-name}/{key-version}/verify{?api%2Dversion}", {
"key-name": keyName,
"key-version": keyVersion,
"api%2Dversion": context.apiVersion,
}, {
allowReserved: (_a = options === null || options === void 0 ? void 0 : options.requestOptions) === null || _a === void 0 ? void 0 : _a.skipUrlEncoding,
});
return context
.path(path)
.post(Object.assign(Object.assign({}, operationOptionsToRequestParameters(options)), { contentType: "application/json", headers: Object.assign({ accept: "application/json" }, (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.headers), body: keyVerifyParametersSerializer(parameters) }));
}
export async function _verifyDeserialize(result) {
const expectedStatuses = ["200"];
if (!expectedStatuses.includes(result.status)) {
const error = createRestError(result);
error.details = keyVaultErrorDeserializer(result.body);
throw error;
}
return keyVerifyResultDeserializer(result.body);
}
/** The VERIFY operation is applicable to symmetric keys stored in Azure Key Vault. VERIFY is not strictly necessary for asymmetric keys stored in Azure Key Vault since signature verification can be performed using the public portion of the key but this operation is supported as a convenience for callers that only have a key-reference and not the public portion of the key. This operation requires the keys/verify permission. */
export async function verify(context, keyName, keyVersion, parameters, options = { requestOptions: {} }) {
const result = await _verifySend(context, keyName, keyVersion, parameters, options);
return _verifyDeserialize(result);
}
export function _signSend(context, keyName, keyVersion, parameters, options = { requestOptions: {} }) {
var _a, _b;
const path = expandUrlTemplate("/keys/{key-name}/{key-version}/sign{?api%2Dversion}", {
"key-name": keyName,
"key-version": keyVersion,
"api%2Dversion": context.apiVersion,
}, {
allowReserved: (_a = options === null || options === void 0 ? void 0 : options.requestOptions) === null || _a === void 0 ? void 0 : _a.skipUrlEncoding,
});
return context
.path(path)
.post(Object.assign(Object.assign({}, operationOptionsToRequestParameters(options)), { contentType: "application/json", headers: Object.assign({ accept: "application/json" }, (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.headers), body: keySignParametersSerializer(parameters) }));
}
export async function _signDeserialize(result) {
const expectedStatuses = ["200"];
if (!expectedStatuses.includes(result.status)) {
const error = createRestError(result);
error.details = keyVaultErrorDeserializer(result.body);
throw error;
}
return keyOperationResultDeserializer(result.body);
}
/** The SIGN operation is applicable to asymmetric and symmetric keys stored in Azure Key Vault since this operation uses the private portion of the key. This operation requires the keys/sign permission. */
export async function sign(context, keyName, keyVersion, parameters, options = { requestOptions: {} }) {
const result = await _signSend(context, keyName, keyVersion, parameters, options);
return _signDeserialize(result);
}
export function _decryptSend(context, keyName, keyVersion, parameters, options = { requestOptions: {} }) {
var _a, _b;
const path = expandUrlTemplate("/keys/{key-name}/{key-version}/decrypt{?api%2Dversion}", {
"key-name": keyName,
"key-version": keyVersion,
"api%2Dversion": context.apiVersion,
}, {
allowReserved: (_a = options === null || options === void 0 ? void 0 : options.requestOptions) === null || _a === void 0 ? void 0 : _a.skipUrlEncoding,
});
return context
.path(path)
.post(Object.assign(Object.assign({}, operationOptionsToRequestParameters(options)), { contentType: "application/json", headers: Object.assign({ accept: "application/json" }, (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.headers), body: keyOperationsParametersSerializer(parameters) }));
}
export async function _decryptDeserialize(result) {
const expectedStatuses = ["200"];
if (!expectedStatuses.includes(result.status)) {
const error = createRestError(result);
error.details = keyVaultErrorDeserializer(result.body);
throw error;
}
return keyOperationResultDeserializer(result.body);
}
/** The DECRYPT operation decrypts a well-formed block of ciphertext using the target encryption key and specified algorithm. This operation is the reverse of the ENCRYPT operation; only a single block of data may be decrypted, the size of this block is dependent on the target key and the algorithm to be used. The DECRYPT operation applies to asymmetric and symmetric keys stored in Azure Key Vault since it uses the private portion of the key. This operation requires the keys/decrypt permission. Microsoft recommends not to use CBC algorithms for decryption without first ensuring the integrity of the ciphertext using an HMAC, for example. See https://learn.microsoft.com/dotnet/standard/security/vulnerabilities-cbc-mode for more information. */
export async function decrypt(context, keyName, keyVersion, parameters, options = { requestOptions: {} }) {
const result = await _decryptSend(context, keyName, keyVersion, parameters, options);
return _decryptDeserialize(result);
}
export function _encryptSend(context, keyName, keyVersion, parameters, options = { requestOptions: {} }) {
var _a, _b;
const path = expandUrlTemplate("/keys/{key-name}/{key-version}/encrypt{?api%2Dversion}", {
"key-name": keyName,
"key-version": keyVersion,
"api%2Dversion": context.apiVersion,
}, {
allowReserved: (_a = options === null || options === void 0 ? void 0 : options.requestOptions) === null || _a === void 0 ? void 0 : _a.skipUrlEncoding,
});
return context
.path(path)
.post(Object.assign(Object.assign({}, operationOptionsToRequestParameters(options)), { contentType: "application/json", headers: Object.assign({ accept: "application/json" }, (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.headers), body: keyOperationsParametersSerializer(parameters) }));
}
export async function _encryptDeserialize(result) {
const expectedStatuses = ["200"];
if (!expectedStatuses.includes(result.status)) {
const error = createRestError(result);
error.details = keyVaultErrorDeserializer(result.body);
throw error;
}
return keyOperationResultDeserializer(result.body);
}
/** The ENCRYPT operation encrypts an arbitrary sequence of bytes using an encryption key that is stored in Azure Key Vault. Note that the ENCRYPT operation only supports a single block of data, the size of which is dependent on the target key and the encryption algorithm to be used. The ENCRYPT operation is only strictly necessary for symmetric keys stored in Azure Key Vault since protection with an asymmetric key can be performed using public portion of the key. This operation is supported for asymmetric keys as a convenience for callers that have a key-reference but do not have access to the public key material. This operation requires the keys/encrypt permission. */
export async function encrypt(context, keyName, keyVersion, parameters, options = { requestOptions: {} }) {
const result = await _encryptSend(context, keyName, keyVersion, parameters, options);
return _encryptDeserialize(result);
}
export function _restoreKeySend(context, parameters, options = { requestOptions: {} }) {
var _a, _b;
const path = expandUrlTemplate("/keys/restore{?api%2Dversion}", {
"api%2Dversion": context.apiVersion,
}, {
allowReserved: (_a = options === null || options === void 0 ? void 0 : options.requestOptions) === null || _a === void 0 ? void 0 : _a.skipUrlEncoding,
});
return context
.path(path)
.post(Object.assign(Object.assign({}, operationOptionsToRequestParameters(options)), { contentType: "application/json", headers: Object.assign({ accept: "application/json" }, (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.headers), body: keyRestoreParametersSerializer(parameters) }));
}
export async function _restoreKeyDeserialize(result) {
const expectedStatuses = ["200"];
if (!expectedStatuses.includes(result.status)) {
const error = createRestError(result);
error.details = keyVaultErrorDeserializer(result.body);
throw error;
}
return keyBundleDeserializer(result.body);
}
/** Imports a previously backed up key into Azure Key Vault, restoring the key, its key identifier, attributes and access control policies. The RESTORE operation may be used to import a previously backed up key. Individual versions of a key cannot be restored. The key is restored in its entirety with the same key name as it had when it was backed up. If the key name is not available in the target Key Vault, the RESTORE operation will be rejected. While the key name is retained during restore, the final key identifier will change if the key is restored to a different vault. Restore will restore all versions and preserve version identifiers. The RESTORE operation is subject to security constraints: The target Key Vault must be owned by the same Microsoft Azure Subscription as the source Key Vault The user must have RESTORE permission in the target Key Vault. This operation requires the keys/restore permission. */
export async function restoreKey(context, parameters, options = { requestOptions: {} }) {
const result = await _restoreKeySend(context, parameters, options);
return _restoreKeyDeserialize(result);
}
export function _backupKeySend(context, keyName, options = { requestOptions: {} }) {
var _a, _b;
const path = expandUrlTemplate("/keys/{key-name}/backup{?api%2Dversion}", {
"key-name": keyName,
"api%2Dversion": context.apiVersion,
}, {
allowReserved: (_a = options === null || options === void 0 ? void 0 : options.requestOptions) === null || _a === void 0 ? void 0 : _a.skipUrlEncoding,
});
return context
.path(path)
.post(Object.assign(Object.assign({}, operationOptionsToRequestParameters(options)), { headers: Object.assign({ accept: "application/json" }, (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.headers) }));
}
export async function _backupKeyDeserialize(result) {
const expectedStatuses = ["200"];
if (!expectedStatuses.includes(result.status)) {
const error = createRestError(result);
error.details = keyVaultErrorDeserializer(result.body);
throw error;
}
return backupKeyResultDeserializer(result.body);
}
/** The Key Backup operation exports a key from Azure Key Vault in a protected form. Note that this operation does NOT return key material in a form that can be used outside the Azure Key Vault system, the returned key material is either protected to a Azure Key Vault HSM or to Azure Key Vault itself. The intent of this operation is to allow a client to GENERATE a key in one Azure Key Vault instance, BACKUP the key, and then RESTORE it into another Azure Key Vault instance. The BACKUP operation may be used to export, in protected form, any key type from Azure Key Vault. Individual versions of a key cannot be backed up. BACKUP / RESTORE can be performed within geographical boundaries only; meaning that a BACKUP from one geographical area cannot be restored to another geographical area. For example, a backup from the US geographical area cannot be restored in an EU geographical area. This operation requires the key/backup permission. */
export async function backupKey(context, keyName, options = { requestOptions: {} }) {
const result = await _backupKeySend(context, keyName, options);
return _backupKeyDeserialize(result);
}
export function _getKeysSend(context, options = { requestOptions: {} }) {
var _a, _b;
const path = expandUrlTemplate("/keys{?api%2Dversion,maxresults}", {
"api%2Dversion": context.apiVersion,
maxresults: options === null || options === void 0 ? void 0 : options.maxresults,
}, {
allowReserved: (_a = options === null || options === void 0 ? void 0 : options.requestOptions) === null || _a === void 0 ? void 0 : _a.skipUrlEncoding,
});
return context
.path(path)
.get(Object.assign(Object.assign({}, operationOptionsToRequestParameters(options)), { headers: Object.assign({ accept: "application/json" }, (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.headers) }));
}
export async function _getKeysDeserialize(result) {
const expectedStatuses = ["200"];
if (!expectedStatuses.includes(result.status)) {
const error = createRestError(result);
error.details = keyVaultErrorDeserializer(result.body);
throw error;
}
return _keyListResultDeserializer(result.body);
}
/** Retrieves a list of the keys in the Key Vault as JSON Web Key structures that contain the public part of a stored key. The LIST operation is applicable to all key types, however only the base key identifier, attributes, and tags are provided in the response. Individual versions of a key are not listed in the response. This operation requires the keys/list permission. */
export function getKeys(context, options = { requestOptions: {} }) {
return buildPagedAsyncIterator(context, () => _getKeysSend(context, options), _getKeysDeserialize, ["200"], { itemName: "value", nextLinkName: "nextLink" });
}
export function _getKeyVersionsSend(context, keyName, options = { requestOptions: {} }) {
var _a, _b;
const path = expandUrlTemplate("/keys/{key-name}/versions{?api%2Dversion,maxresults}", {
"key-name": keyName,
"api%2Dversion": context.apiVersion,
maxresults: options === null || options === void 0 ? void 0 : options.maxresults,
}, {
allowReserved: (_a = options === null || options === void 0 ? void 0 : options.requestOptions) === null || _a === void 0 ? void 0 : _a.skipUrlEncoding,
});
return context
.path(path)
.get(Object.assign(Object.assign({}, operationOptionsToRequestParameters(options)), { headers: Object.assign({ accept: "application/json" }, (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.headers) }));
}
export async function _getKeyVersionsDeserialize(result) {
const expectedStatuses = ["200"];
if (!expectedStatuses.includes(result.status)) {
const error = createRestError(result);
error.details = keyVaultErrorDeserializer(result.body);
throw error;
}
return _keyListResultDeserializer(result.body);
}
/** The full key identifier, attributes, and tags are provided in the response. This operation requires the keys/list permission. */
export function getKeyVersions(context, keyName, options = { requestOptions: {} }) {
return buildPagedAsyncIterator(context, () => _getKeyVersionsSend(context, keyName, options), _getKeyVersionsDeserialize, ["200"], { itemName: "value", nextLinkName: "nextLink" });
}
export function _getKeySend(context, keyName, keyVersion, options = { requestOptions: {} }) {
var _a, _b;
const path = expandUrlTemplate("/keys/{key-name}/{key-version}{?api%2Dversion}", {
"key-name": keyName,
"key-version": keyVersion,
"api%2Dversion": context.apiVersion,
}, {
allowReserved: (_a = options === null || options === void 0 ? void 0 : options.requestOptions) === null || _a === void 0 ? void 0 : _a.skipUrlEncoding,
});
return context
.path(path)
.get(Object.assign(Object.assign({}, operationOptionsToRequestParameters(options)), { headers: Object.assign({ accept: "application/json" }, (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.headers) }));
}
export async function _getKeyDeserialize(result) {
const expectedStatuses = ["200"];
if (!expectedStatuses.includes(result.status)) {
const error = createRestError(result);
error.details = keyVaultErrorDeserializer(result.body);
throw error;
}
return keyBundleDeserializer(result.body);
}
/** The get key operation is applicable to all key types. If the requested key is symmetric, then no key material is released in the response. This operation requires the keys/get permission. */
export async function getKey(context, keyName, keyVersion, options = { requestOptions: {} }) {
const result = await _getKeySend(context, keyName, keyVersion, options);
return _getKeyDeserialize(result);
}
export function _updateKeySend(context, keyName, keyVersion, parameters, options = { requestOptions: {} }) {
var _a, _b;
const path = expandUrlTemplate("/keys/{key-name}/{key-version}{?api%2Dversion}", {
"key-name": keyName,
"key-version": keyVersion,
"api%2Dversion": context.apiVersion,
}, {
allowReserved: (_a = options === null || options === void 0 ? void 0 : options.requestOptions) === null || _a === void 0 ? void 0 : _a.skipUrlEncoding,
});
return context
.path(path)
.patch(Object.assign(Object.assign({}, operationOptionsToRequestParameters(options)), { contentType: "application/json", headers: Object.assign({ accept: "application/json" }, (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.headers), body: keyUpdateParametersSerializer(parameters) }));
}
export async function _updateKeyDeserialize(result) {
const expectedStatuses = ["200"];
if (!expectedStatuses.includes(result.status)) {
const error = createRestError(result);
error.details = keyVaultErrorDeserializer(result.body);
throw error;
}
return keyBundleDeserializer(result.body);
}
/** In order to perform this operation, the key must already exist in the Key Vault. Note: The cryptographic material of a key itself cannot be changed. This operation requires the keys/update permission. */
export async function updateKey(context, keyName, keyVersion, parameters, options = { requestOptions: {} }) {
const result = await _updateKeySend(context, keyName, keyVersion, parameters, options);
return _updateKeyDeserialize(result);
}
export function _deleteKeySend(context, keyName, options = { requestOptions: {} }) {
var _a, _b;
const path = expandUrlTemplate("/keys/{key-name}{?api%2Dversion}", {
"key-name": keyName,
"api%2Dversion": context.apiVersion,
}, {
allowReserved: (_a = options === null || options === void 0 ? void 0 : options.requestOptions) === null || _a === void 0 ? void 0 : _a.skipUrlEncoding,
});
return context
.path(path)
.delete(Object.assign(Object.assign({}, operationOptionsToRequestParameters(options)), { headers: Object.assign({ accept: "application/json" }, (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.headers) }));
}
export async function _deleteKeyDeserialize(result) {
const expectedStatuses = ["200"];
if (!expectedStatuses.includes(result.status)) {
const error = createRestError(result);
error.details = keyVaultErrorDeserializer(result.body);
throw error;
}
return deletedKeyBundleDeserializer(result.body);
}
/** The delete key operation cannot be used to remove individual versions of a key. This operation removes the cryptographic material associated with the key, which means the key is not usable for Sign/Verify, Wrap/Unwrap or Encrypt/Decrypt operations. This operation requires the keys/delete permission. */
export async function deleteKey(context, keyName, options = { requestOptions: {} }) {
const result = await _deleteKeySend(context, keyName, options);
return _deleteKeyDeserialize(result);
}
export function _importKeySend(context, keyName, parameters, options = { requestOptions: {} }) {
var _a, _b;
const path = expandUrlTemplate("/keys/{key-name}{?api%2Dversion}", {
"key-name": keyName,
"api%2Dversion": context.apiVersion,
}, {
allowReserved: (_a = options === null || options === void 0 ? void 0 : options.requestOptions) === null || _a === void 0 ? void 0 : _a.skipUrlEncoding,
});
return context
.path(path)
.put(Object.assign(Object.assign({}, operationOptionsToRequestParameters(options)), { contentType: "application/json", headers: Object.assign({ accept: "application/json" }, (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.headers), body: keyImportParametersSerializer(parameters) }));
}
export async function _importKeyDeserialize(result) {
const expectedStatuses = ["200"];
if (!expectedStatuses.includes(result.status)) {
const error = createRestError(result);
error.details = keyVaultErrorDeserializer(result.body);
throw error;
}
return keyBundleDeserializer(result.body);
}
/** The import key operation may be used to import any key type into an Azure Key Vault. If the named key already exists, Azure Key Vault creates a new version of the key. This operation requires the keys/import permission. */
export async function importKey(context, keyName, parameters, options = { requestOptions: {} }) {
const result = await _importKeySend(context, keyName, parameters, options);
return _importKeyDeserialize(result);
}
export function _rotateKeySend(context, keyName, options = { requestOptions: {} }) {
var _a, _b;
const path = expandUrlTemplate("/keys/{key-name}/rotate{?api%2Dversion}", {
"key-name": keyName,
"api%2Dversion": context.apiVersion,
}, {
allowReserved: (_a = options === null || options === void 0 ? void 0 : options.requestOptions) === null || _a === void 0 ? void 0 : _a.skipUrlEncoding,
});
return context
.path(path)
.post(Object.assign(Object.assign({}, operationOptionsToRequestParameters(options)), { headers: Object.assign({ accept: "application/json" }, (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.headers) }));
}
export async function _rotateKeyDeserialize(result) {
const expectedStatuses = ["200"];
if (!expectedStatuses.includes(result.status)) {
const error = createRestError(result);
error.details = keyVaultErrorDeserializer(result.body);
throw error;
}
return keyBundleDeserializer(result.body);
}
/** The operation will rotate the key based on the key policy. It requires the keys/rotate permission. */
export async function rotateKey(context, keyName, options = { requestOptions: {} }) {
const result = await _rotateKeySend(context, keyName, options);
return _rotateKeyDeserialize(result);
}
export function _createKeySend(context, keyName, parameters, options = { requestOptions: {} }) {
var _a, _b;
const path = expandUrlTemplate("/keys/{key-name}/create{?api%2Dversion}", {
"key-name": keyName,
"api%2Dversion": context.apiVersion,
}, {
allowReserved: (_a = options === null || options === void 0 ? void 0 : options.requestOptions) === null || _a === void 0 ? void 0 : _a.skipUrlEncoding,
});
return context
.path(path)
.post(Object.assign(Object.assign({}, operationOptionsToRequestParameters(options)), { contentType: "application/json", headers: Object.assign({ accept: "application/json" }, (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.headers), body: keyCreateParametersSerializer(parameters) }));
}
export async function _createKeyDeserialize(result) {
const expectedStatuses = ["200"];
if (!expectedStatuses.includes(result.status)) {
const error = createRestError(result);
error.details = keyVaultErrorDeserializer(result.body);
throw error;
}
return keyBundleDeserializer(result.body);
}
/** The create key operation can be used to create any key type in Azure Key Vault. If the named key already exists, Azure Key Vault creates a new version of the key. It requires the keys/create permission. */
export async function createKey(context, keyName, parameters, options = { requestOptions: {} }) {
const result = await _createKeySend(context, keyName, parameters, options);
return _createKeyDeserialize(result);
}
//# sourceMappingURL=operations.js.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,83 @@
import { OperationOptions } from "@azure-rest/core-client";
/** Optional parameters. */
export interface GetKeyAttestationOptionalParams extends OperationOptions {
}
/** Optional parameters. */
export interface GetRandomBytesOptionalParams extends OperationOptions {
}
/** Optional parameters. */
export interface UpdateKeyRotationPolicyOptionalParams extends OperationOptions {
}
/** Optional parameters. */
export interface GetKeyRotationPolicyOptionalParams extends OperationOptions {
}
/** Optional parameters. */
export interface RecoverDeletedKeyOptionalParams extends OperationOptions {
}
/** Optional parameters. */
export interface PurgeDeletedKeyOptionalParams extends OperationOptions {
}
/** Optional parameters. */
export interface GetDeletedKeyOptionalParams extends OperationOptions {
}
/** Optional parameters. */
export interface GetDeletedKeysOptionalParams extends OperationOptions {
/** Maximum number of results to return in a page. If not specified the service will return up to 25 results. */
maxresults?: number;
}
/** Optional parameters. */
export interface ReleaseOptionalParams extends OperationOptions {
}
/** Optional parameters. */
export interface UnwrapKeyOptionalParams extends OperationOptions {
}
/** Optional parameters. */
export interface WrapKeyOptionalParams extends OperationOptions {
}
/** Optional parameters. */
export interface VerifyOptionalParams extends OperationOptions {
}
/** Optional parameters. */
export interface SignOptionalParams extends OperationOptions {
}
/** Optional parameters. */
export interface DecryptOptionalParams extends OperationOptions {
}
/** Optional parameters. */
export interface EncryptOptionalParams extends OperationOptions {
}
/** Optional parameters. */
export interface RestoreKeyOptionalParams extends OperationOptions {
}
/** Optional parameters. */
export interface BackupKeyOptionalParams extends OperationOptions {
}
/** Optional parameters. */
export interface GetKeysOptionalParams extends OperationOptions {
/** Maximum number of results to return in a page. If not specified the service will return up to 25 results. */
maxresults?: number;
}
/** Optional parameters. */
export interface GetKeyVersionsOptionalParams extends OperationOptions {
/** Maximum number of results to return in a page. If not specified the service will return up to 25 results. */
maxresults?: number;
}
/** Optional parameters. */
export interface GetKeyOptionalParams extends OperationOptions {
}
/** Optional parameters. */
export interface UpdateKeyOptionalParams extends OperationOptions {
}
/** Optional parameters. */
export interface DeleteKeyOptionalParams extends OperationOptions {
}
/** Optional parameters. */
export interface ImportKeyOptionalParams extends OperationOptions {
}
/** Optional parameters. */
export interface RotateKeyOptionalParams extends OperationOptions {
}
/** Optional parameters. */
export interface CreateKeyOptionalParams extends OperationOptions {
}
//# sourceMappingURL=options.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../../../src/generated/api/options.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,2BAA2B;AAC3B,MAAM,WAAW,+BAAgC,SAAQ,gBAAgB;CAAG;AAE5E,2BAA2B;AAC3B,MAAM,WAAW,4BAA6B,SAAQ,gBAAgB;CAAG;AAEzE,2BAA2B;AAC3B,MAAM,WAAW,qCACf,SAAQ,gBAAgB;CAAG;AAE7B,2BAA2B;AAC3B,MAAM,WAAW,kCAAmC,SAAQ,gBAAgB;CAAG;AAE/E,2BAA2B;AAC3B,MAAM,WAAW,+BAAgC,SAAQ,gBAAgB;CAAG;AAE5E,2BAA2B;AAC3B,MAAM,WAAW,6BAA8B,SAAQ,gBAAgB;CAAG;AAE1E,2BAA2B;AAC3B,MAAM,WAAW,2BAA4B,SAAQ,gBAAgB;CAAG;AAExE,2BAA2B;AAC3B,MAAM,WAAW,4BAA6B,SAAQ,gBAAgB;IACpE,gHAAgH;IAChH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,2BAA2B;AAC3B,MAAM,WAAW,qBAAsB,SAAQ,gBAAgB;CAAG;AAElE,2BAA2B;AAC3B,MAAM,WAAW,uBAAwB,SAAQ,gBAAgB;CAAG;AAEpE,2BAA2B;AAC3B,MAAM,WAAW,qBAAsB,SAAQ,gBAAgB;CAAG;AAElE,2BAA2B;AAC3B,MAAM,WAAW,oBAAqB,SAAQ,gBAAgB;CAAG;AAEjE,2BAA2B;AAC3B,MAAM,WAAW,kBAAmB,SAAQ,gBAAgB;CAAG;AAE/D,2BAA2B;AAC3B,MAAM,WAAW,qBAAsB,SAAQ,gBAAgB;CAAG;AAElE,2BAA2B;AAC3B,MAAM,WAAW,qBAAsB,SAAQ,gBAAgB;CAAG;AAElE,2BAA2B;AAC3B,MAAM,WAAW,wBAAyB,SAAQ,gBAAgB;CAAG;AAErE,2BAA2B;AAC3B,MAAM,WAAW,uBAAwB,SAAQ,gBAAgB;CAAG;AAEpE,2BAA2B;AAC3B,MAAM,WAAW,qBAAsB,SAAQ,gBAAgB;IAC7D,gHAAgH;IAChH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,2BAA2B;AAC3B,MAAM,WAAW,4BAA6B,SAAQ,gBAAgB;IACpE,gHAAgH;IAChH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,2BAA2B;AAC3B,MAAM,WAAW,oBAAqB,SAAQ,gBAAgB;CAAG;AAEjE,2BAA2B;AAC3B,MAAM,WAAW,uBAAwB,SAAQ,gBAAgB;CAAG;AAEpE,2BAA2B;AAC3B,MAAM,WAAW,uBAAwB,SAAQ,gBAAgB;CAAG;AAEpE,2BAA2B;AAC3B,MAAM,WAAW,uBAAwB,SAAQ,gBAAgB;CAAG;AAEpE,2BAA2B;AAC3B,MAAM,WAAW,uBAAwB,SAAQ,gBAAgB;CAAG;AAEpE,2BAA2B;AAC3B,MAAM,WAAW,uBAAwB,SAAQ,gBAAgB;CAAG"}

View File

@ -0,0 +1,4 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
export {};
//# sourceMappingURL=options.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../../../src/generated/api/options.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { OperationOptions } from \"@azure-rest/core-client\";\n\n/** Optional parameters. */\nexport interface GetKeyAttestationOptionalParams extends OperationOptions {}\n\n/** Optional parameters. */\nexport interface GetRandomBytesOptionalParams extends OperationOptions {}\n\n/** Optional parameters. */\nexport interface UpdateKeyRotationPolicyOptionalParams\n extends OperationOptions {}\n\n/** Optional parameters. */\nexport interface GetKeyRotationPolicyOptionalParams extends OperationOptions {}\n\n/** Optional parameters. */\nexport interface RecoverDeletedKeyOptionalParams extends OperationOptions {}\n\n/** Optional parameters. */\nexport interface PurgeDeletedKeyOptionalParams extends OperationOptions {}\n\n/** Optional parameters. */\nexport interface GetDeletedKeyOptionalParams extends OperationOptions {}\n\n/** Optional parameters. */\nexport interface GetDeletedKeysOptionalParams extends OperationOptions {\n /** Maximum number of results to return in a page. If not specified the service will return up to 25 results. */\n maxresults?: number;\n}\n\n/** Optional parameters. */\nexport interface ReleaseOptionalParams extends OperationOptions {}\n\n/** Optional parameters. */\nexport interface UnwrapKeyOptionalParams extends OperationOptions {}\n\n/** Optional parameters. */\nexport interface WrapKeyOptionalParams extends OperationOptions {}\n\n/** Optional parameters. */\nexport interface VerifyOptionalParams extends OperationOptions {}\n\n/** Optional parameters. */\nexport interface SignOptionalParams extends OperationOptions {}\n\n/** Optional parameters. */\nexport interface DecryptOptionalParams extends OperationOptions {}\n\n/** Optional parameters. */\nexport interface EncryptOptionalParams extends OperationOptions {}\n\n/** Optional parameters. */\nexport interface RestoreKeyOptionalParams extends OperationOptions {}\n\n/** Optional parameters. */\nexport interface BackupKeyOptionalParams extends OperationOptions {}\n\n/** Optional parameters. */\nexport interface GetKeysOptionalParams extends OperationOptions {\n /** Maximum number of results to return in a page. If not specified the service will return up to 25 results. */\n maxresults?: number;\n}\n\n/** Optional parameters. */\nexport interface GetKeyVersionsOptionalParams extends OperationOptions {\n /** Maximum number of results to return in a page. If not specified the service will return up to 25 results. */\n maxresults?: number;\n}\n\n/** Optional parameters. */\nexport interface GetKeyOptionalParams extends OperationOptions {}\n\n/** Optional parameters. */\nexport interface UpdateKeyOptionalParams extends OperationOptions {}\n\n/** Optional parameters. */\nexport interface DeleteKeyOptionalParams extends OperationOptions {}\n\n/** Optional parameters. */\nexport interface ImportKeyOptionalParams extends OperationOptions {}\n\n/** Optional parameters. */\nexport interface RotateKeyOptionalParams extends OperationOptions {}\n\n/** Optional parameters. */\nexport interface CreateKeyOptionalParams extends OperationOptions {}\n"]}

View File

@ -0,0 +1,6 @@
import { PageSettings, ContinuablePage, PagedAsyncIterableIterator } from "./static-helpers/pagingHelpers.js";
export { KeyVaultClient } from "./keyVaultClient.js";
export { KeyCreateParameters, KnownJsonWebKeyType, JsonWebKeyType, KnownJsonWebKeyOperation, JsonWebKeyOperation, KeyAttributes, KnownDeletionRecoveryLevel, DeletionRecoveryLevel, KeyAttestation, KnownJsonWebKeyCurveName, JsonWebKeyCurveName, KeyReleasePolicy, KeyBundle, JsonWebKey, KeyVaultError, ErrorModel, KeyImportParameters, DeletedKeyBundle, KeyUpdateParameters, KeyItem, BackupKeyResult, KeyRestoreParameters, KeyOperationsParameters, KnownJsonWebKeyEncryptionAlgorithm, JsonWebKeyEncryptionAlgorithm, KeyOperationResult, KeySignParameters, KnownJsonWebKeySignatureAlgorithm, JsonWebKeySignatureAlgorithm, KeyVerifyParameters, KeyVerifyResult, KeyReleaseParameters, KnownKeyEncryptionAlgorithm, KeyEncryptionAlgorithm, KeyReleaseResult, DeletedKeyItem, KeyRotationPolicy, LifetimeActions, LifetimeActionsTrigger, LifetimeActionsType, KeyRotationPolicyAction, KeyRotationPolicyAttributes, GetRandomBytesRequest, RandomBytes, KnownVersions, } from "./models/index.js";
export { KeyVaultClientOptionalParams, GetKeyAttestationOptionalParams, GetRandomBytesOptionalParams, UpdateKeyRotationPolicyOptionalParams, GetKeyRotationPolicyOptionalParams, RecoverDeletedKeyOptionalParams, PurgeDeletedKeyOptionalParams, GetDeletedKeyOptionalParams, GetDeletedKeysOptionalParams, ReleaseOptionalParams, UnwrapKeyOptionalParams, WrapKeyOptionalParams, VerifyOptionalParams, SignOptionalParams, DecryptOptionalParams, EncryptOptionalParams, RestoreKeyOptionalParams, BackupKeyOptionalParams, GetKeysOptionalParams, GetKeyVersionsOptionalParams, GetKeyOptionalParams, UpdateKeyOptionalParams, DeleteKeyOptionalParams, ImportKeyOptionalParams, RotateKeyOptionalParams, CreateKeyOptionalParams, } from "./api/index.js";
export { PageSettings, ContinuablePage, PagedAsyncIterableIterator };
//# sourceMappingURL=index.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/generated/index.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,YAAY,EACZ,eAAe,EACf,0BAA0B,EAC3B,MAAM,mCAAmC,CAAC;AAE3C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,cAAc,EACd,wBAAwB,EACxB,mBAAmB,EACnB,aAAa,EACb,0BAA0B,EAC1B,qBAAqB,EACrB,cAAc,EACd,wBAAwB,EACxB,mBAAmB,EACnB,gBAAgB,EAChB,SAAS,EACT,UAAU,EACV,aAAa,EACb,UAAU,EACV,mBAAmB,EACnB,gBAAgB,EAChB,mBAAmB,EACnB,OAAO,EACP,eAAe,EACf,oBAAoB,EACpB,uBAAuB,EACvB,kCAAkC,EAClC,6BAA6B,EAC7B,kBAAkB,EAClB,iBAAiB,EACjB,iCAAiC,EACjC,4BAA4B,EAC5B,mBAAmB,EACnB,eAAe,EACf,oBAAoB,EACpB,2BAA2B,EAC3B,sBAAsB,EACtB,gBAAgB,EAChB,cAAc,EACd,iBAAiB,EACjB,eAAe,EACf,sBAAsB,EACtB,mBAAmB,EACnB,uBAAuB,EACvB,2BAA2B,EAC3B,qBAAqB,EACrB,WAAW,EACX,aAAa,GACd,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,4BAA4B,EAC5B,+BAA+B,EAC/B,4BAA4B,EAC5B,qCAAqC,EACrC,kCAAkC,EAClC,+BAA+B,EAC/B,6BAA6B,EAC7B,2BAA2B,EAC3B,4BAA4B,EAC5B,qBAAqB,EACrB,uBAAuB,EACvB,qBAAqB,EACrB,oBAAoB,EACpB,kBAAkB,EAClB,qBAAqB,EACrB,qBAAqB,EACrB,wBAAwB,EACxB,uBAAuB,EACvB,qBAAqB,EACrB,4BAA4B,EAC5B,oBAAoB,EACpB,uBAAuB,EACvB,uBAAuB,EACvB,uBAAuB,EACvB,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,0BAA0B,EAAE,CAAC"}

View File

@ -0,0 +1,5 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
export { KeyVaultClient } from "./keyVaultClient.js";
export { KnownJsonWebKeyType, KnownJsonWebKeyOperation, KnownDeletionRecoveryLevel, KnownJsonWebKeyCurveName, KnownJsonWebKeyEncryptionAlgorithm, KnownJsonWebKeySignatureAlgorithm, KnownKeyEncryptionAlgorithm, KnownVersions, } from "./models/index.js";
//# sourceMappingURL=index.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/generated/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAQlC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAEL,mBAAmB,EAEnB,wBAAwB,EAGxB,0BAA0B,EAG1B,wBAAwB,EAcxB,kCAAkC,EAIlC,iCAAiC,EAKjC,2BAA2B,EAY3B,aAAa,GACd,MAAM,mBAAmB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport {\n PageSettings,\n ContinuablePage,\n PagedAsyncIterableIterator,\n} from \"./static-helpers/pagingHelpers.js\";\n\nexport { KeyVaultClient } from \"./keyVaultClient.js\";\nexport {\n KeyCreateParameters,\n KnownJsonWebKeyType,\n JsonWebKeyType,\n KnownJsonWebKeyOperation,\n JsonWebKeyOperation,\n KeyAttributes,\n KnownDeletionRecoveryLevel,\n DeletionRecoveryLevel,\n KeyAttestation,\n KnownJsonWebKeyCurveName,\n JsonWebKeyCurveName,\n KeyReleasePolicy,\n KeyBundle,\n JsonWebKey,\n KeyVaultError,\n ErrorModel,\n KeyImportParameters,\n DeletedKeyBundle,\n KeyUpdateParameters,\n KeyItem,\n BackupKeyResult,\n KeyRestoreParameters,\n KeyOperationsParameters,\n KnownJsonWebKeyEncryptionAlgorithm,\n JsonWebKeyEncryptionAlgorithm,\n KeyOperationResult,\n KeySignParameters,\n KnownJsonWebKeySignatureAlgorithm,\n JsonWebKeySignatureAlgorithm,\n KeyVerifyParameters,\n KeyVerifyResult,\n KeyReleaseParameters,\n KnownKeyEncryptionAlgorithm,\n KeyEncryptionAlgorithm,\n KeyReleaseResult,\n DeletedKeyItem,\n KeyRotationPolicy,\n LifetimeActions,\n LifetimeActionsTrigger,\n LifetimeActionsType,\n KeyRotationPolicyAction,\n KeyRotationPolicyAttributes,\n GetRandomBytesRequest,\n RandomBytes,\n KnownVersions,\n} from \"./models/index.js\";\nexport {\n KeyVaultClientOptionalParams,\n GetKeyAttestationOptionalParams,\n GetRandomBytesOptionalParams,\n UpdateKeyRotationPolicyOptionalParams,\n GetKeyRotationPolicyOptionalParams,\n RecoverDeletedKeyOptionalParams,\n PurgeDeletedKeyOptionalParams,\n GetDeletedKeyOptionalParams,\n GetDeletedKeysOptionalParams,\n ReleaseOptionalParams,\n UnwrapKeyOptionalParams,\n WrapKeyOptionalParams,\n VerifyOptionalParams,\n SignOptionalParams,\n DecryptOptionalParams,\n EncryptOptionalParams,\n RestoreKeyOptionalParams,\n BackupKeyOptionalParams,\n GetKeysOptionalParams,\n GetKeyVersionsOptionalParams,\n GetKeyOptionalParams,\n UpdateKeyOptionalParams,\n DeleteKeyOptionalParams,\n ImportKeyOptionalParams,\n RotateKeyOptionalParams,\n CreateKeyOptionalParams,\n} from \"./api/index.js\";\nexport { PageSettings, ContinuablePage, PagedAsyncIterableIterator };\n"]}

View File

@ -0,0 +1,65 @@
import { KeyVaultClientOptionalParams } from "./api/index.js";
import { KeyCreateParameters, KeyBundle, KeyImportParameters, DeletedKeyBundle, KeyUpdateParameters, KeyItem, BackupKeyResult, KeyRestoreParameters, KeyOperationsParameters, KeyOperationResult, KeySignParameters, KeyVerifyParameters, KeyVerifyResult, KeyReleaseParameters, KeyReleaseResult, DeletedKeyItem, KeyRotationPolicy, GetRandomBytesRequest, RandomBytes } from "./models/models.js";
import { GetKeyAttestationOptionalParams, GetRandomBytesOptionalParams, UpdateKeyRotationPolicyOptionalParams, GetKeyRotationPolicyOptionalParams, RecoverDeletedKeyOptionalParams, PurgeDeletedKeyOptionalParams, GetDeletedKeyOptionalParams, GetDeletedKeysOptionalParams, ReleaseOptionalParams, UnwrapKeyOptionalParams, WrapKeyOptionalParams, VerifyOptionalParams, SignOptionalParams, DecryptOptionalParams, EncryptOptionalParams, RestoreKeyOptionalParams, BackupKeyOptionalParams, GetKeysOptionalParams, GetKeyVersionsOptionalParams, GetKeyOptionalParams, UpdateKeyOptionalParams, DeleteKeyOptionalParams, ImportKeyOptionalParams, RotateKeyOptionalParams, CreateKeyOptionalParams } from "./api/options.js";
import { PagedAsyncIterableIterator } from "./static-helpers/pagingHelpers.js";
import { Pipeline } from "@azure/core-rest-pipeline";
import { TokenCredential } from "@azure/core-auth";
export { KeyVaultClientOptionalParams } from "./api/keyVaultContext.js";
export declare class KeyVaultClient {
private _client;
/** The pipeline used by this client to make requests */
readonly pipeline: Pipeline;
/** The key vault client performs cryptographic key operations and vault operations against the Key Vault service. */
constructor(endpointParam: string, credential: TokenCredential, options?: KeyVaultClientOptionalParams);
/** The get key attestation operation returns the key along with its attestation blob. This operation requires the keys/get permission. */
getKeyAttestation(keyName: string, keyVersion: string, options?: GetKeyAttestationOptionalParams): Promise<KeyBundle>;
/** Get the requested number of bytes containing random values from a managed HSM. */
getRandomBytes(parameters: GetRandomBytesRequest, options?: GetRandomBytesOptionalParams): Promise<RandomBytes>;
/** Set specified members in the key policy. Leave others as undefined. This operation requires the keys/update permission. */
updateKeyRotationPolicy(keyName: string, keyRotationPolicy: KeyRotationPolicy, options?: UpdateKeyRotationPolicyOptionalParams): Promise<KeyRotationPolicy>;
/** The GetKeyRotationPolicy operation returns the specified key policy resources in the specified key vault. This operation requires the keys/get permission. */
getKeyRotationPolicy(keyName: string, options?: GetKeyRotationPolicyOptionalParams): Promise<KeyRotationPolicy>;
/** The Recover Deleted Key operation is applicable for deleted keys in soft-delete enabled vaults. It recovers the deleted key back to its latest version under /keys. An attempt to recover an non-deleted key will return an error. Consider this the inverse of the delete operation on soft-delete enabled vaults. This operation requires the keys/recover permission. */
recoverDeletedKey(keyName: string, options?: RecoverDeletedKeyOptionalParams): Promise<KeyBundle>;
/** The Purge Deleted Key operation is applicable for soft-delete enabled vaults. While the operation can be invoked on any vault, it will return an error if invoked on a non soft-delete enabled vault. This operation requires the keys/purge permission. */
purgeDeletedKey(keyName: string, options?: PurgeDeletedKeyOptionalParams): Promise<void>;
/** The Get Deleted Key operation is applicable for soft-delete enabled vaults. While the operation can be invoked on any vault, it will return an error if invoked on a non soft-delete enabled vault. This operation requires the keys/get permission. */
getDeletedKey(keyName: string, options?: GetDeletedKeyOptionalParams): Promise<DeletedKeyBundle>;
/** Retrieves a list of the keys in the Key Vault as JSON Web Key structures that contain the public part of a deleted key. This operation includes deletion-specific information. The Get Deleted Keys operation is applicable for vaults enabled for soft-delete. While the operation can be invoked on any vault, it will return an error if invoked on a non soft-delete enabled vault. This operation requires the keys/list permission. */
getDeletedKeys(options?: GetDeletedKeysOptionalParams): PagedAsyncIterableIterator<DeletedKeyItem>;
/** The release key operation is applicable to all key types. The target key must be marked exportable. This operation requires the keys/release permission. */
release(keyName: string, keyVersion: string, parameters: KeyReleaseParameters, options?: ReleaseOptionalParams): Promise<KeyReleaseResult>;
/** The UNWRAP operation supports decryption of a symmetric key using the target key encryption key. This operation is the reverse of the WRAP operation. The UNWRAP operation applies to asymmetric and symmetric keys stored in Azure Key Vault since it uses the private portion of the key. This operation requires the keys/unwrapKey permission. */
unwrapKey(keyName: string, keyVersion: string, parameters: KeyOperationsParameters, options?: UnwrapKeyOptionalParams): Promise<KeyOperationResult>;
/** The WRAP operation supports encryption of a symmetric key using a key encryption key that has previously been stored in an Azure Key Vault. The WRAP operation is only strictly necessary for symmetric keys stored in Azure Key Vault since protection with an asymmetric key can be performed using the public portion of the key. This operation is supported for asymmetric keys as a convenience for callers that have a key-reference but do not have access to the public key material. This operation requires the keys/wrapKey permission. */
wrapKey(keyName: string, keyVersion: string, parameters: KeyOperationsParameters, options?: WrapKeyOptionalParams): Promise<KeyOperationResult>;
/** The VERIFY operation is applicable to symmetric keys stored in Azure Key Vault. VERIFY is not strictly necessary for asymmetric keys stored in Azure Key Vault since signature verification can be performed using the public portion of the key but this operation is supported as a convenience for callers that only have a key-reference and not the public portion of the key. This operation requires the keys/verify permission. */
verify(keyName: string, keyVersion: string, parameters: KeyVerifyParameters, options?: VerifyOptionalParams): Promise<KeyVerifyResult>;
/** The SIGN operation is applicable to asymmetric and symmetric keys stored in Azure Key Vault since this operation uses the private portion of the key. This operation requires the keys/sign permission. */
sign(keyName: string, keyVersion: string, parameters: KeySignParameters, options?: SignOptionalParams): Promise<KeyOperationResult>;
/** The DECRYPT operation decrypts a well-formed block of ciphertext using the target encryption key and specified algorithm. This operation is the reverse of the ENCRYPT operation; only a single block of data may be decrypted, the size of this block is dependent on the target key and the algorithm to be used. The DECRYPT operation applies to asymmetric and symmetric keys stored in Azure Key Vault since it uses the private portion of the key. This operation requires the keys/decrypt permission. Microsoft recommends not to use CBC algorithms for decryption without first ensuring the integrity of the ciphertext using an HMAC, for example. See https://learn.microsoft.com/dotnet/standard/security/vulnerabilities-cbc-mode for more information. */
decrypt(keyName: string, keyVersion: string, parameters: KeyOperationsParameters, options?: DecryptOptionalParams): Promise<KeyOperationResult>;
/** The ENCRYPT operation encrypts an arbitrary sequence of bytes using an encryption key that is stored in Azure Key Vault. Note that the ENCRYPT operation only supports a single block of data, the size of which is dependent on the target key and the encryption algorithm to be used. The ENCRYPT operation is only strictly necessary for symmetric keys stored in Azure Key Vault since protection with an asymmetric key can be performed using public portion of the key. This operation is supported for asymmetric keys as a convenience for callers that have a key-reference but do not have access to the public key material. This operation requires the keys/encrypt permission. */
encrypt(keyName: string, keyVersion: string, parameters: KeyOperationsParameters, options?: EncryptOptionalParams): Promise<KeyOperationResult>;
/** Imports a previously backed up key into Azure Key Vault, restoring the key, its key identifier, attributes and access control policies. The RESTORE operation may be used to import a previously backed up key. Individual versions of a key cannot be restored. The key is restored in its entirety with the same key name as it had when it was backed up. If the key name is not available in the target Key Vault, the RESTORE operation will be rejected. While the key name is retained during restore, the final key identifier will change if the key is restored to a different vault. Restore will restore all versions and preserve version identifiers. The RESTORE operation is subject to security constraints: The target Key Vault must be owned by the same Microsoft Azure Subscription as the source Key Vault The user must have RESTORE permission in the target Key Vault. This operation requires the keys/restore permission. */
restoreKey(parameters: KeyRestoreParameters, options?: RestoreKeyOptionalParams): Promise<KeyBundle>;
/** The Key Backup operation exports a key from Azure Key Vault in a protected form. Note that this operation does NOT return key material in a form that can be used outside the Azure Key Vault system, the returned key material is either protected to a Azure Key Vault HSM or to Azure Key Vault itself. The intent of this operation is to allow a client to GENERATE a key in one Azure Key Vault instance, BACKUP the key, and then RESTORE it into another Azure Key Vault instance. The BACKUP operation may be used to export, in protected form, any key type from Azure Key Vault. Individual versions of a key cannot be backed up. BACKUP / RESTORE can be performed within geographical boundaries only; meaning that a BACKUP from one geographical area cannot be restored to another geographical area. For example, a backup from the US geographical area cannot be restored in an EU geographical area. This operation requires the key/backup permission. */
backupKey(keyName: string, options?: BackupKeyOptionalParams): Promise<BackupKeyResult>;
/** Retrieves a list of the keys in the Key Vault as JSON Web Key structures that contain the public part of a stored key. The LIST operation is applicable to all key types, however only the base key identifier, attributes, and tags are provided in the response. Individual versions of a key are not listed in the response. This operation requires the keys/list permission. */
getKeys(options?: GetKeysOptionalParams): PagedAsyncIterableIterator<KeyItem>;
/** The full key identifier, attributes, and tags are provided in the response. This operation requires the keys/list permission. */
getKeyVersions(keyName: string, options?: GetKeyVersionsOptionalParams): PagedAsyncIterableIterator<KeyItem>;
/** The get key operation is applicable to all key types. If the requested key is symmetric, then no key material is released in the response. This operation requires the keys/get permission. */
getKey(keyName: string, keyVersion: string, options?: GetKeyOptionalParams): Promise<KeyBundle>;
/** In order to perform this operation, the key must already exist in the Key Vault. Note: The cryptographic material of a key itself cannot be changed. This operation requires the keys/update permission. */
updateKey(keyName: string, keyVersion: string, parameters: KeyUpdateParameters, options?: UpdateKeyOptionalParams): Promise<KeyBundle>;
/** The delete key operation cannot be used to remove individual versions of a key. This operation removes the cryptographic material associated with the key, which means the key is not usable for Sign/Verify, Wrap/Unwrap or Encrypt/Decrypt operations. This operation requires the keys/delete permission. */
deleteKey(keyName: string, options?: DeleteKeyOptionalParams): Promise<DeletedKeyBundle>;
/** The import key operation may be used to import any key type into an Azure Key Vault. If the named key already exists, Azure Key Vault creates a new version of the key. This operation requires the keys/import permission. */
importKey(keyName: string, parameters: KeyImportParameters, options?: ImportKeyOptionalParams): Promise<KeyBundle>;
/** The operation will rotate the key based on the key policy. It requires the keys/rotate permission. */
rotateKey(keyName: string, options?: RotateKeyOptionalParams): Promise<KeyBundle>;
/** The create key operation can be used to create any key type in Azure Key Vault. If the named key already exists, Azure Key Vault creates a new version of the key. It requires the keys/create permission. */
createKey(keyName: string, parameters: KeyCreateParameters, options?: CreateKeyOptionalParams): Promise<KeyBundle>;
}
//# sourceMappingURL=keyVaultClient.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"keyVaultClient.d.ts","sourceRoot":"","sources":["../../../src/generated/keyVaultClient.ts"],"names":[],"mappings":"AAGA,OAAO,EAGL,4BAA4B,EAC7B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,mBAAmB,EACnB,SAAS,EACT,mBAAmB,EACnB,gBAAgB,EAChB,mBAAmB,EACnB,OAAO,EACP,eAAe,EACf,oBAAoB,EACpB,uBAAuB,EACvB,kBAAkB,EAClB,iBAAiB,EACjB,mBAAmB,EACnB,eAAe,EACf,oBAAoB,EACpB,gBAAgB,EAChB,cAAc,EACd,iBAAiB,EACjB,qBAAqB,EACrB,WAAW,EACZ,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,+BAA+B,EAC/B,4BAA4B,EAC5B,qCAAqC,EACrC,kCAAkC,EAClC,+BAA+B,EAC/B,6BAA6B,EAC7B,2BAA2B,EAC3B,4BAA4B,EAC5B,qBAAqB,EACrB,uBAAuB,EACvB,qBAAqB,EACrB,oBAAoB,EACpB,kBAAkB,EAClB,qBAAqB,EACrB,qBAAqB,EACrB,wBAAwB,EACxB,uBAAuB,EACvB,qBAAqB,EACrB,4BAA4B,EAC5B,oBAAoB,EACpB,uBAAuB,EACvB,uBAAuB,EACvB,uBAAuB,EACvB,uBAAuB,EACvB,uBAAuB,EACxB,MAAM,kBAAkB,CAAC;AA4B1B,OAAO,EAAE,0BAA0B,EAAE,MAAM,mCAAmC,CAAC;AAC/E,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,EAAE,4BAA4B,EAAE,MAAM,0BAA0B,CAAC;AAExE,qBAAa,cAAc;IACzB,OAAO,CAAC,OAAO,CAAkB;IACjC,wDAAwD;IACxD,SAAgB,QAAQ,EAAE,QAAQ,CAAC;IAEnC,qHAAqH;gBAEnH,aAAa,EAAE,MAAM,EACrB,UAAU,EAAE,eAAe,EAC3B,OAAO,GAAE,4BAAiC;IAa5C,0IAA0I;IAC1I,iBAAiB,CACf,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,OAAO,GAAE,+BAAwD,GAChE,OAAO,CAAC,SAAS,CAAC;IAIrB,qFAAqF;IACrF,cAAc,CACZ,UAAU,EAAE,qBAAqB,EACjC,OAAO,GAAE,4BAAqD,GAC7D,OAAO,CAAC,WAAW,CAAC;IAIvB,8HAA8H;IAC9H,uBAAuB,CACrB,OAAO,EAAE,MAAM,EACf,iBAAiB,EAAE,iBAAiB,EACpC,OAAO,GAAE,qCAA8D,GACtE,OAAO,CAAC,iBAAiB,CAAC;IAS7B,iKAAiK;IACjK,oBAAoB,CAClB,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,kCAA2D,GACnE,OAAO,CAAC,iBAAiB,CAAC;IAI7B,+WAA+W;IAC/W,iBAAiB,CACf,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,+BAAwD,GAChE,OAAO,CAAC,SAAS,CAAC;IAIrB,+PAA+P;IAC/P,eAAe,CACb,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,6BAAsD,GAC9D,OAAO,CAAC,IAAI,CAAC;IAIhB,2PAA2P;IAC3P,aAAa,CACX,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,2BAAoD,GAC5D,OAAO,CAAC,gBAAgB,CAAC;IAI5B,gbAAgb;IAChb,cAAc,CACZ,OAAO,GAAE,4BAAqD,GAC7D,0BAA0B,CAAC,cAAc,CAAC;IAI7C,+JAA+J;IAC/J,OAAO,CACL,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,oBAAoB,EAChC,OAAO,GAAE,qBAA8C,GACtD,OAAO,CAAC,gBAAgB,CAAC;IAI5B,yVAAyV;IACzV,SAAS,CACP,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,uBAAuB,EACnC,OAAO,GAAE,uBAAgD,GACxD,OAAO,CAAC,kBAAkB,CAAC;IAI9B,0hBAA0hB;IAC1hB,OAAO,CACL,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,uBAAuB,EACnC,OAAO,GAAE,qBAA8C,GACtD,OAAO,CAAC,kBAAkB,CAAC;IAI9B,8aAA8a;IAC9a,MAAM,CACJ,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,mBAAmB,EAC/B,OAAO,GAAE,oBAA6C,GACrD,OAAO,CAAC,eAAe,CAAC;IAI3B,8MAA8M;IAC9M,IAAI,CACF,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,iBAAiB,EAC7B,OAAO,GAAE,kBAA2C,GACnD,OAAO,CAAC,kBAAkB,CAAC;IAI9B,+uBAA+uB;IAC/uB,OAAO,CACL,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,uBAAuB,EACnC,OAAO,GAAE,qBAA8C,GACtD,OAAO,CAAC,kBAAkB,CAAC;IAI9B,sqBAAsqB;IACtqB,OAAO,CACL,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,uBAAuB,EACnC,OAAO,GAAE,qBAA8C,GACtD,OAAO,CAAC,kBAAkB,CAAC;IAI9B,45BAA45B;IAC55B,UAAU,CACR,UAAU,EAAE,oBAAoB,EAChC,OAAO,GAAE,wBAAiD,GACzD,OAAO,CAAC,SAAS,CAAC;IAIrB,o7BAAo7B;IACp7B,SAAS,CACP,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,uBAAgD,GACxD,OAAO,CAAC,eAAe,CAAC;IAI3B,wXAAwX;IACxX,OAAO,CACL,OAAO,GAAE,qBAA8C,GACtD,0BAA0B,CAAC,OAAO,CAAC;IAItC,oIAAoI;IACpI,cAAc,CACZ,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,4BAAqD,GAC7D,0BAA0B,CAAC,OAAO,CAAC;IAItC,kMAAkM;IAClM,MAAM,CACJ,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,OAAO,GAAE,oBAA6C,GACrD,OAAO,CAAC,SAAS,CAAC;IAIrB,+MAA+M;IAC/M,SAAS,CACP,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,mBAAmB,EAC/B,OAAO,GAAE,uBAAgD,GACxD,OAAO,CAAC,SAAS,CAAC;IAIrB,mTAAmT;IACnT,SAAS,CACP,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,uBAAgD,GACxD,OAAO,CAAC,gBAAgB,CAAC;IAI5B,kOAAkO;IAClO,SAAS,CACP,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,mBAAmB,EAC/B,OAAO,GAAE,uBAAgD,GACxD,OAAO,CAAC,SAAS,CAAC;IAIrB,yGAAyG;IACzG,SAAS,CACP,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,uBAAgD,GACxD,OAAO,CAAC,SAAS,CAAC;IAIrB,iNAAiN;IACjN,SAAS,CACP,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,mBAAmB,EAC/B,OAAO,GAAE,uBAAgD,GACxD,OAAO,CAAC,SAAS,CAAC;CAGtB"}

View File

@ -0,0 +1,117 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { createKeyVault, } from "./api/index.js";
import { getKeyAttestation, getRandomBytes, updateKeyRotationPolicy, getKeyRotationPolicy, recoverDeletedKey, purgeDeletedKey, getDeletedKey, getDeletedKeys, release, unwrapKey, wrapKey, verify, sign, decrypt, encrypt, restoreKey, backupKey, getKeys, getKeyVersions, getKey, updateKey, deleteKey, importKey, rotateKey, createKey, } from "./api/operations.js";
export class KeyVaultClient {
/** The key vault client performs cryptographic key operations and vault operations against the Key Vault service. */
constructor(endpointParam, credential, options = {}) {
var _a;
const prefixFromOptions = (_a = options === null || options === void 0 ? void 0 : options.userAgentOptions) === null || _a === void 0 ? void 0 : _a.userAgentPrefix;
const userAgentPrefix = prefixFromOptions
? `${prefixFromOptions} azsdk-js-client`
: `azsdk-js-client`;
this._client = createKeyVault(endpointParam, credential, Object.assign(Object.assign({}, options), { userAgentOptions: { userAgentPrefix } }));
this.pipeline = this._client.pipeline;
}
/** The get key attestation operation returns the key along with its attestation blob. This operation requires the keys/get permission. */
getKeyAttestation(keyName, keyVersion, options = { requestOptions: {} }) {
return getKeyAttestation(this._client, keyName, keyVersion, options);
}
/** Get the requested number of bytes containing random values from a managed HSM. */
getRandomBytes(parameters, options = { requestOptions: {} }) {
return getRandomBytes(this._client, parameters, options);
}
/** Set specified members in the key policy. Leave others as undefined. This operation requires the keys/update permission. */
updateKeyRotationPolicy(keyName, keyRotationPolicy, options = { requestOptions: {} }) {
return updateKeyRotationPolicy(this._client, keyName, keyRotationPolicy, options);
}
/** The GetKeyRotationPolicy operation returns the specified key policy resources in the specified key vault. This operation requires the keys/get permission. */
getKeyRotationPolicy(keyName, options = { requestOptions: {} }) {
return getKeyRotationPolicy(this._client, keyName, options);
}
/** The Recover Deleted Key operation is applicable for deleted keys in soft-delete enabled vaults. It recovers the deleted key back to its latest version under /keys. An attempt to recover an non-deleted key will return an error. Consider this the inverse of the delete operation on soft-delete enabled vaults. This operation requires the keys/recover permission. */
recoverDeletedKey(keyName, options = { requestOptions: {} }) {
return recoverDeletedKey(this._client, keyName, options);
}
/** The Purge Deleted Key operation is applicable for soft-delete enabled vaults. While the operation can be invoked on any vault, it will return an error if invoked on a non soft-delete enabled vault. This operation requires the keys/purge permission. */
purgeDeletedKey(keyName, options = { requestOptions: {} }) {
return purgeDeletedKey(this._client, keyName, options);
}
/** The Get Deleted Key operation is applicable for soft-delete enabled vaults. While the operation can be invoked on any vault, it will return an error if invoked on a non soft-delete enabled vault. This operation requires the keys/get permission. */
getDeletedKey(keyName, options = { requestOptions: {} }) {
return getDeletedKey(this._client, keyName, options);
}
/** Retrieves a list of the keys in the Key Vault as JSON Web Key structures that contain the public part of a deleted key. This operation includes deletion-specific information. The Get Deleted Keys operation is applicable for vaults enabled for soft-delete. While the operation can be invoked on any vault, it will return an error if invoked on a non soft-delete enabled vault. This operation requires the keys/list permission. */
getDeletedKeys(options = { requestOptions: {} }) {
return getDeletedKeys(this._client, options);
}
/** The release key operation is applicable to all key types. The target key must be marked exportable. This operation requires the keys/release permission. */
release(keyName, keyVersion, parameters, options = { requestOptions: {} }) {
return release(this._client, keyName, keyVersion, parameters, options);
}
/** The UNWRAP operation supports decryption of a symmetric key using the target key encryption key. This operation is the reverse of the WRAP operation. The UNWRAP operation applies to asymmetric and symmetric keys stored in Azure Key Vault since it uses the private portion of the key. This operation requires the keys/unwrapKey permission. */
unwrapKey(keyName, keyVersion, parameters, options = { requestOptions: {} }) {
return unwrapKey(this._client, keyName, keyVersion, parameters, options);
}
/** The WRAP operation supports encryption of a symmetric key using a key encryption key that has previously been stored in an Azure Key Vault. The WRAP operation is only strictly necessary for symmetric keys stored in Azure Key Vault since protection with an asymmetric key can be performed using the public portion of the key. This operation is supported for asymmetric keys as a convenience for callers that have a key-reference but do not have access to the public key material. This operation requires the keys/wrapKey permission. */
wrapKey(keyName, keyVersion, parameters, options = { requestOptions: {} }) {
return wrapKey(this._client, keyName, keyVersion, parameters, options);
}
/** The VERIFY operation is applicable to symmetric keys stored in Azure Key Vault. VERIFY is not strictly necessary for asymmetric keys stored in Azure Key Vault since signature verification can be performed using the public portion of the key but this operation is supported as a convenience for callers that only have a key-reference and not the public portion of the key. This operation requires the keys/verify permission. */
verify(keyName, keyVersion, parameters, options = { requestOptions: {} }) {
return verify(this._client, keyName, keyVersion, parameters, options);
}
/** The SIGN operation is applicable to asymmetric and symmetric keys stored in Azure Key Vault since this operation uses the private portion of the key. This operation requires the keys/sign permission. */
sign(keyName, keyVersion, parameters, options = { requestOptions: {} }) {
return sign(this._client, keyName, keyVersion, parameters, options);
}
/** The DECRYPT operation decrypts a well-formed block of ciphertext using the target encryption key and specified algorithm. This operation is the reverse of the ENCRYPT operation; only a single block of data may be decrypted, the size of this block is dependent on the target key and the algorithm to be used. The DECRYPT operation applies to asymmetric and symmetric keys stored in Azure Key Vault since it uses the private portion of the key. This operation requires the keys/decrypt permission. Microsoft recommends not to use CBC algorithms for decryption without first ensuring the integrity of the ciphertext using an HMAC, for example. See https://learn.microsoft.com/dotnet/standard/security/vulnerabilities-cbc-mode for more information. */
decrypt(keyName, keyVersion, parameters, options = { requestOptions: {} }) {
return decrypt(this._client, keyName, keyVersion, parameters, options);
}
/** The ENCRYPT operation encrypts an arbitrary sequence of bytes using an encryption key that is stored in Azure Key Vault. Note that the ENCRYPT operation only supports a single block of data, the size of which is dependent on the target key and the encryption algorithm to be used. The ENCRYPT operation is only strictly necessary for symmetric keys stored in Azure Key Vault since protection with an asymmetric key can be performed using public portion of the key. This operation is supported for asymmetric keys as a convenience for callers that have a key-reference but do not have access to the public key material. This operation requires the keys/encrypt permission. */
encrypt(keyName, keyVersion, parameters, options = { requestOptions: {} }) {
return encrypt(this._client, keyName, keyVersion, parameters, options);
}
/** Imports a previously backed up key into Azure Key Vault, restoring the key, its key identifier, attributes and access control policies. The RESTORE operation may be used to import a previously backed up key. Individual versions of a key cannot be restored. The key is restored in its entirety with the same key name as it had when it was backed up. If the key name is not available in the target Key Vault, the RESTORE operation will be rejected. While the key name is retained during restore, the final key identifier will change if the key is restored to a different vault. Restore will restore all versions and preserve version identifiers. The RESTORE operation is subject to security constraints: The target Key Vault must be owned by the same Microsoft Azure Subscription as the source Key Vault The user must have RESTORE permission in the target Key Vault. This operation requires the keys/restore permission. */
restoreKey(parameters, options = { requestOptions: {} }) {
return restoreKey(this._client, parameters, options);
}
/** The Key Backup operation exports a key from Azure Key Vault in a protected form. Note that this operation does NOT return key material in a form that can be used outside the Azure Key Vault system, the returned key material is either protected to a Azure Key Vault HSM or to Azure Key Vault itself. The intent of this operation is to allow a client to GENERATE a key in one Azure Key Vault instance, BACKUP the key, and then RESTORE it into another Azure Key Vault instance. The BACKUP operation may be used to export, in protected form, any key type from Azure Key Vault. Individual versions of a key cannot be backed up. BACKUP / RESTORE can be performed within geographical boundaries only; meaning that a BACKUP from one geographical area cannot be restored to another geographical area. For example, a backup from the US geographical area cannot be restored in an EU geographical area. This operation requires the key/backup permission. */
backupKey(keyName, options = { requestOptions: {} }) {
return backupKey(this._client, keyName, options);
}
/** Retrieves a list of the keys in the Key Vault as JSON Web Key structures that contain the public part of a stored key. The LIST operation is applicable to all key types, however only the base key identifier, attributes, and tags are provided in the response. Individual versions of a key are not listed in the response. This operation requires the keys/list permission. */
getKeys(options = { requestOptions: {} }) {
return getKeys(this._client, options);
}
/** The full key identifier, attributes, and tags are provided in the response. This operation requires the keys/list permission. */
getKeyVersions(keyName, options = { requestOptions: {} }) {
return getKeyVersions(this._client, keyName, options);
}
/** The get key operation is applicable to all key types. If the requested key is symmetric, then no key material is released in the response. This operation requires the keys/get permission. */
getKey(keyName, keyVersion, options = { requestOptions: {} }) {
return getKey(this._client, keyName, keyVersion, options);
}
/** In order to perform this operation, the key must already exist in the Key Vault. Note: The cryptographic material of a key itself cannot be changed. This operation requires the keys/update permission. */
updateKey(keyName, keyVersion, parameters, options = { requestOptions: {} }) {
return updateKey(this._client, keyName, keyVersion, parameters, options);
}
/** The delete key operation cannot be used to remove individual versions of a key. This operation removes the cryptographic material associated with the key, which means the key is not usable for Sign/Verify, Wrap/Unwrap or Encrypt/Decrypt operations. This operation requires the keys/delete permission. */
deleteKey(keyName, options = { requestOptions: {} }) {
return deleteKey(this._client, keyName, options);
}
/** The import key operation may be used to import any key type into an Azure Key Vault. If the named key already exists, Azure Key Vault creates a new version of the key. This operation requires the keys/import permission. */
importKey(keyName, parameters, options = { requestOptions: {} }) {
return importKey(this._client, keyName, parameters, options);
}
/** The operation will rotate the key based on the key policy. It requires the keys/rotate permission. */
rotateKey(keyName, options = { requestOptions: {} }) {
return rotateKey(this._client, keyName, options);
}
/** The create key operation can be used to create any key type in Azure Key Vault. If the named key already exists, Azure Key Vault creates a new version of the key. It requires the keys/create permission. */
createKey(keyName, parameters, options = { requestOptions: {} }) {
return createKey(this._client, keyName, parameters, options);
}
}
//# sourceMappingURL=keyVaultClient.js.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,2 @@
export declare const logger: import("@azure/logger").AzureLogger;
//# sourceMappingURL=logger.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../src/generated/logger.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,MAAM,qCAAsC,CAAC"}

View File

@ -0,0 +1,5 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { createClientLogger } from "@azure/logger";
export const logger = createClientLogger("keyvault-keys");
//# sourceMappingURL=logger.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../../src/generated/logger.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,MAAM,CAAC,MAAM,MAAM,GAAG,kBAAkB,CAAC,eAAe,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { createClientLogger } from \"@azure/logger\";\nexport const logger = createClientLogger(\"keyvault-keys\");\n"]}

View File

@ -0,0 +1,2 @@
export { KeyCreateParameters, KnownJsonWebKeyType, JsonWebKeyType, KnownJsonWebKeyOperation, JsonWebKeyOperation, KeyAttributes, KnownDeletionRecoveryLevel, DeletionRecoveryLevel, KeyAttestation, KnownJsonWebKeyCurveName, JsonWebKeyCurveName, KeyReleasePolicy, KeyBundle, JsonWebKey, KeyVaultError, ErrorModel, KeyImportParameters, DeletedKeyBundle, KeyUpdateParameters, KeyItem, BackupKeyResult, KeyRestoreParameters, KeyOperationsParameters, KnownJsonWebKeyEncryptionAlgorithm, JsonWebKeyEncryptionAlgorithm, KeyOperationResult, KeySignParameters, KnownJsonWebKeySignatureAlgorithm, JsonWebKeySignatureAlgorithm, KeyVerifyParameters, KeyVerifyResult, KeyReleaseParameters, KnownKeyEncryptionAlgorithm, KeyEncryptionAlgorithm, KeyReleaseResult, DeletedKeyItem, KeyRotationPolicy, LifetimeActions, LifetimeActionsTrigger, LifetimeActionsType, KeyRotationPolicyAction, KeyRotationPolicyAttributes, GetRandomBytesRequest, RandomBytes, KnownVersions, } from "./models.js";
//# sourceMappingURL=index.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/generated/models/index.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,cAAc,EACd,wBAAwB,EACxB,mBAAmB,EACnB,aAAa,EACb,0BAA0B,EAC1B,qBAAqB,EACrB,cAAc,EACd,wBAAwB,EACxB,mBAAmB,EACnB,gBAAgB,EAChB,SAAS,EACT,UAAU,EACV,aAAa,EACb,UAAU,EACV,mBAAmB,EACnB,gBAAgB,EAChB,mBAAmB,EACnB,OAAO,EACP,eAAe,EACf,oBAAoB,EACpB,uBAAuB,EACvB,kCAAkC,EAClC,6BAA6B,EAC7B,kBAAkB,EAClB,iBAAiB,EACjB,iCAAiC,EACjC,4BAA4B,EAC5B,mBAAmB,EACnB,eAAe,EACf,oBAAoB,EACpB,2BAA2B,EAC3B,sBAAsB,EACtB,gBAAgB,EAChB,cAAc,EACd,iBAAiB,EACjB,eAAe,EACf,sBAAsB,EACtB,mBAAmB,EACnB,uBAAuB,EACvB,2BAA2B,EAC3B,qBAAqB,EACrB,WAAW,EACX,aAAa,GACd,MAAM,aAAa,CAAC"}

View File

@ -0,0 +1,4 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
export { KnownJsonWebKeyType, KnownJsonWebKeyOperation, KnownDeletionRecoveryLevel, KnownJsonWebKeyCurveName, KnownJsonWebKeyEncryptionAlgorithm, KnownJsonWebKeySignatureAlgorithm, KnownKeyEncryptionAlgorithm, KnownVersions, } from "./models.js";
//# sourceMappingURL=index.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/generated/models/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAEL,mBAAmB,EAEnB,wBAAwB,EAGxB,0BAA0B,EAG1B,wBAAwB,EAcxB,kCAAkC,EAIlC,iCAAiC,EAKjC,2BAA2B,EAY3B,aAAa,GACd,MAAM,aAAa,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nexport {\n KeyCreateParameters,\n KnownJsonWebKeyType,\n JsonWebKeyType,\n KnownJsonWebKeyOperation,\n JsonWebKeyOperation,\n KeyAttributes,\n KnownDeletionRecoveryLevel,\n DeletionRecoveryLevel,\n KeyAttestation,\n KnownJsonWebKeyCurveName,\n JsonWebKeyCurveName,\n KeyReleasePolicy,\n KeyBundle,\n JsonWebKey,\n KeyVaultError,\n ErrorModel,\n KeyImportParameters,\n DeletedKeyBundle,\n KeyUpdateParameters,\n KeyItem,\n BackupKeyResult,\n KeyRestoreParameters,\n KeyOperationsParameters,\n KnownJsonWebKeyEncryptionAlgorithm,\n JsonWebKeyEncryptionAlgorithm,\n KeyOperationResult,\n KeySignParameters,\n KnownJsonWebKeySignatureAlgorithm,\n JsonWebKeySignatureAlgorithm,\n KeyVerifyParameters,\n KeyVerifyResult,\n KeyReleaseParameters,\n KnownKeyEncryptionAlgorithm,\n KeyEncryptionAlgorithm,\n KeyReleaseResult,\n DeletedKeyItem,\n KeyRotationPolicy,\n LifetimeActions,\n LifetimeActionsTrigger,\n LifetimeActionsType,\n KeyRotationPolicyAction,\n KeyRotationPolicyAttributes,\n GetRandomBytesRequest,\n RandomBytes,\n KnownVersions,\n} from \"./models.js\";\n"]}

View File

@ -0,0 +1,635 @@
/** The key create parameters. */
export interface KeyCreateParameters {
/** The type of key to create. For valid values, see JsonWebKeyType. */
kty: JsonWebKeyType;
/** The key size in bits. For example: 2048, 3072, or 4096 for RSA. */
keySize?: number;
/** The public exponent for a RSA key. */
publicExponent?: number;
/** Json web key operations. For more information on possible key operations, see JsonWebKeyOperation. */
keyOps?: JsonWebKeyOperation[];
/** The attributes of a key managed by the key vault service. */
keyAttributes?: KeyAttributes;
/** Application specific metadata in the form of key-value pairs. */
tags?: Record<string, string>;
/** Elliptic curve name. For valid values, see JsonWebKeyCurveName. */
curve?: JsonWebKeyCurveName;
/** The policy rules under which the key can be exported. */
releasePolicy?: KeyReleasePolicy;
}
export declare function keyCreateParametersSerializer(item: KeyCreateParameters): any;
/** JsonWebKey Key Type (kty), as defined in https://tools.ietf.org/html/draft-ietf-jose-json-web-algorithms-40. */
export declare enum KnownJsonWebKeyType {
/** Elliptic Curve. */
EC = "EC",
/** Elliptic Curve with a private key which is stored in the HSM. */
ECHSM = "EC-HSM",
/** RSA (https://tools.ietf.org/html/rfc3447) */
RSA = "RSA",
/** RSA with a private key which is stored in the HSM. */
RSAHSM = "RSA-HSM",
/** Octet sequence (used to represent symmetric keys) */
Oct = "oct",
/** Octet sequence (used to represent symmetric keys) which is stored the HSM. */
OctHSM = "oct-HSM"
}
/**
* JsonWebKey Key Type (kty), as defined in https://tools.ietf.org/html/draft-ietf-jose-json-web-algorithms-40. \
* {@link KnownJsonWebKeyType} can be used interchangeably with JsonWebKeyType,
* this enum contains the known values that the service supports.
* ### Known values supported by the service
* **EC**: Elliptic Curve. \
* **EC-HSM**: Elliptic Curve with a private key which is stored in the HSM. \
* **RSA**: RSA (https:\//tools.ietf.org\/html\/rfc3447) \
* **RSA-HSM**: RSA with a private key which is stored in the HSM. \
* **oct**: Octet sequence (used to represent symmetric keys) \
* **oct-HSM**: Octet sequence (used to represent symmetric keys) which is stored the HSM.
*/
export type JsonWebKeyType = string;
/** JSON web key operations. For more information, see JsonWebKeyOperation. */
export declare enum KnownJsonWebKeyOperation {
/** Indicates that the key can be used to encrypt. */
Encrypt = "encrypt",
/** Indicates that the key can be used to decrypt. */
Decrypt = "decrypt",
/** Indicates that the key can be used to sign. */
Sign = "sign",
/** Indicates that the key can be used to verify. */
Verify = "verify",
/** Indicates that the key can be used to wrap another key. */
WrapKey = "wrapKey",
/** Indicates that the key can be used to unwrap another key. */
UnwrapKey = "unwrapKey",
/** Indicates that the key can be imported during creation. */
Import = "import",
/** Indicates that the private component of the key can be exported. */
Export = "export"
}
/**
* JSON web key operations. For more information, see JsonWebKeyOperation. \
* {@link KnownJsonWebKeyOperation} can be used interchangeably with JsonWebKeyOperation,
* this enum contains the known values that the service supports.
* ### Known values supported by the service
* **encrypt**: Indicates that the key can be used to encrypt. \
* **decrypt**: Indicates that the key can be used to decrypt. \
* **sign**: Indicates that the key can be used to sign. \
* **verify**: Indicates that the key can be used to verify. \
* **wrapKey**: Indicates that the key can be used to wrap another key. \
* **unwrapKey**: Indicates that the key can be used to unwrap another key. \
* **import**: Indicates that the key can be imported during creation. \
* **export**: Indicates that the private component of the key can be exported.
*/
export type JsonWebKeyOperation = string;
/** The attributes of a key managed by the key vault service. */
export interface KeyAttributes {
/** Determines whether the object is enabled. */
enabled?: boolean;
/** Not before date in UTC. */
notBefore?: Date;
/** Expiry date in UTC. */
expires?: Date;
/** Creation time in UTC. */
readonly created?: Date;
/** Last updated time in UTC. */
readonly updated?: Date;
/** softDelete data retention days. Value should be >=7 and <=90 when softDelete enabled, otherwise 0. */
readonly recoverableDays?: number;
/** Reflects the deletion recovery level currently in effect for keys in the current vault. If it contains 'Purgeable' the key can be permanently deleted by a privileged user; otherwise, only the system can purge the key, at the end of the retention interval. */
readonly recoveryLevel?: DeletionRecoveryLevel;
/** Indicates if the private key can be exported. Release policy must be provided when creating the first version of an exportable key. */
exportable?: boolean;
/** The underlying HSM Platform. */
readonly hsmPlatform?: string;
/** The key or key version attestation information. */
readonly attestation?: KeyAttestation;
}
export declare function keyAttributesSerializer(item: KeyAttributes): any;
export declare function keyAttributesDeserializer(item: any): KeyAttributes;
/** Reflects the deletion recovery level currently in effect for certificates in the current vault. If it contains 'Purgeable', the certificate can be permanently deleted by a privileged user; otherwise, only the system can purge the certificate, at the end of the retention interval. */
export declare enum KnownDeletionRecoveryLevel {
/** Denotes a vault state in which deletion is an irreversible operation, without the possibility for recovery. This level corresponds to no protection being available against a Delete operation; the data is irretrievably lost upon accepting a Delete operation at the entity level or higher (vault, resource group, subscription etc.) */
Purgeable = "Purgeable",
/** Denotes a vault state in which deletion is recoverable, and which also permits immediate and permanent deletion (i.e. purge). This level guarantees the recoverability of the deleted entity during the retention interval (90 days), unless a Purge operation is requested, or the subscription is cancelled. System wil permanently delete it after 90 days, if not recovered */
RecoverablePurgeable = "Recoverable+Purgeable",
/** Denotes a vault state in which deletion is recoverable without the possibility for immediate and permanent deletion (i.e. purge). This level guarantees the recoverability of the deleted entity during the retention interval(90 days) and while the subscription is still available. System wil permanently delete it after 90 days, if not recovered */
Recoverable = "Recoverable",
/** Denotes a vault and subscription state in which deletion is recoverable within retention interval (90 days), immediate and permanent deletion (i.e. purge) is not permitted, and in which the subscription itself cannot be permanently canceled. System wil permanently delete it after 90 days, if not recovered */
RecoverableProtectedSubscription = "Recoverable+ProtectedSubscription",
/** Denotes a vault state in which deletion is recoverable, and which also permits immediate and permanent deletion (i.e. purge when 7 <= SoftDeleteRetentionInDays < 90). This level guarantees the recoverability of the deleted entity during the retention interval, unless a Purge operation is requested, or the subscription is cancelled. */
CustomizedRecoverablePurgeable = "CustomizedRecoverable+Purgeable",
/** Denotes a vault state in which deletion is recoverable without the possibility for immediate and permanent deletion (i.e. purge when 7 <= SoftDeleteRetentionInDays < 90).This level guarantees the recoverability of the deleted entity during the retention interval and while the subscription is still available. */
CustomizedRecoverable = "CustomizedRecoverable",
/** Denotes a vault and subscription state in which deletion is recoverable, immediate and permanent deletion (i.e. purge) is not permitted, and in which the subscription itself cannot be permanently canceled when 7 <= SoftDeleteRetentionInDays < 90. This level guarantees the recoverability of the deleted entity during the retention interval, and also reflects the fact that the subscription itself cannot be cancelled. */
CustomizedRecoverableProtectedSubscription = "CustomizedRecoverable+ProtectedSubscription"
}
/**
* Reflects the deletion recovery level currently in effect for certificates in the current vault. If it contains 'Purgeable', the certificate can be permanently deleted by a privileged user; otherwise, only the system can purge the certificate, at the end of the retention interval. \
* {@link KnownDeletionRecoveryLevel} can be used interchangeably with DeletionRecoveryLevel,
* this enum contains the known values that the service supports.
* ### Known values supported by the service
* **Purgeable**: Denotes a vault state in which deletion is an irreversible operation, without the possibility for recovery. This level corresponds to no protection being available against a Delete operation; the data is irretrievably lost upon accepting a Delete operation at the entity level or higher (vault, resource group, subscription etc.) \
* **Recoverable+Purgeable**: Denotes a vault state in which deletion is recoverable, and which also permits immediate and permanent deletion (i.e. purge). This level guarantees the recoverability of the deleted entity during the retention interval (90 days), unless a Purge operation is requested, or the subscription is cancelled. System wil permanently delete it after 90 days, if not recovered \
* **Recoverable**: Denotes a vault state in which deletion is recoverable without the possibility for immediate and permanent deletion (i.e. purge). This level guarantees the recoverability of the deleted entity during the retention interval(90 days) and while the subscription is still available. System wil permanently delete it after 90 days, if not recovered \
* **Recoverable+ProtectedSubscription**: Denotes a vault and subscription state in which deletion is recoverable within retention interval (90 days), immediate and permanent deletion (i.e. purge) is not permitted, and in which the subscription itself cannot be permanently canceled. System wil permanently delete it after 90 days, if not recovered \
* **CustomizedRecoverable+Purgeable**: Denotes a vault state in which deletion is recoverable, and which also permits immediate and permanent deletion (i.e. purge when 7 <= SoftDeleteRetentionInDays < 90). This level guarantees the recoverability of the deleted entity during the retention interval, unless a Purge operation is requested, or the subscription is cancelled. \
* **CustomizedRecoverable**: Denotes a vault state in which deletion is recoverable without the possibility for immediate and permanent deletion (i.e. purge when 7 <= SoftDeleteRetentionInDays < 90).This level guarantees the recoverability of the deleted entity during the retention interval and while the subscription is still available. \
* **CustomizedRecoverable+ProtectedSubscription**: Denotes a vault and subscription state in which deletion is recoverable, immediate and permanent deletion (i.e. purge) is not permitted, and in which the subscription itself cannot be permanently canceled when 7 <= SoftDeleteRetentionInDays < 90. This level guarantees the recoverability of the deleted entity during the retention interval, and also reflects the fact that the subscription itself cannot be cancelled.
*/
export type DeletionRecoveryLevel = string;
/** The key attestation information. */
export interface KeyAttestation {
/** A base64url-encoded string containing certificates in PEM format, used for attestation validation. */
certificatePemFile?: Uint8Array;
/** The attestation blob bytes encoded as base64url string corresponding to a private key. */
privateKeyAttestation?: Uint8Array;
/** The attestation blob bytes encoded as base64url string corresponding to a public key in case of asymmetric key. */
publicKeyAttestation?: Uint8Array;
/** The version of the attestation. */
version?: string;
}
export declare function keyAttestationDeserializer(item: any): KeyAttestation;
/** Elliptic curve name. For valid values, see JsonWebKeyCurveName. */
export declare enum KnownJsonWebKeyCurveName {
/** The NIST P-256 elliptic curve, AKA SECG curve SECP256R1. */
P256 = "P-256",
/** The NIST P-384 elliptic curve, AKA SECG curve SECP384R1. */
P384 = "P-384",
/** The NIST P-521 elliptic curve, AKA SECG curve SECP521R1. */
P521 = "P-521",
/** The SECG SECP256K1 elliptic curve. */
P256K = "P-256K"
}
/**
* Elliptic curve name. For valid values, see JsonWebKeyCurveName. \
* {@link KnownJsonWebKeyCurveName} can be used interchangeably with JsonWebKeyCurveName,
* this enum contains the known values that the service supports.
* ### Known values supported by the service
* **P-256**: The NIST P-256 elliptic curve, AKA SECG curve SECP256R1. \
* **P-384**: The NIST P-384 elliptic curve, AKA SECG curve SECP384R1. \
* **P-521**: The NIST P-521 elliptic curve, AKA SECG curve SECP521R1. \
* **P-256K**: The SECG SECP256K1 elliptic curve.
*/
export type JsonWebKeyCurveName = string;
/** The policy rules under which the key can be exported. */
export interface KeyReleasePolicy {
/** Content type and version of key release policy */
contentType?: string;
/** Defines the mutability state of the policy. Once marked immutable, this flag cannot be reset and the policy cannot be changed under any circumstances. */
immutable?: boolean;
/** Blob encoding the policy rules under which the key can be released. Blob must be base64 URL encoded. */
encodedPolicy?: Uint8Array;
}
export declare function keyReleasePolicySerializer(item: KeyReleasePolicy): any;
export declare function keyReleasePolicyDeserializer(item: any): KeyReleasePolicy;
/** A KeyBundle consisting of a WebKey plus its attributes. */
export interface KeyBundle {
/** The Json web key. */
key?: JsonWebKey;
/** The key management attributes. */
attributes?: KeyAttributes;
/** Application specific metadata in the form of key-value pairs. */
tags?: Record<string, string>;
/** True if the key's lifetime is managed by key vault. If this is a key backing a certificate, then managed will be true. */
readonly managed?: boolean;
/** The policy rules under which the key can be exported. */
releasePolicy?: KeyReleasePolicy;
}
export declare function keyBundleDeserializer(item: any): KeyBundle;
/** As of http://tools.ietf.org/html/draft-ietf-jose-json-web-key-18 */
export interface JsonWebKey {
/** Key identifier. */
kid?: string;
/** JsonWebKey Key Type (kty), as defined in https://tools.ietf.org/html/draft-ietf-jose-json-web-algorithms-40. */
kty?: JsonWebKeyType;
/** Json web key operations. For more information on possible key operations, see JsonWebKeyOperation. */
keyOps?: string[];
/** RSA modulus. */
n?: Uint8Array;
/** RSA public exponent. */
e?: Uint8Array;
/** RSA private exponent, or the D component of an EC private key. */
d?: Uint8Array;
/** RSA private key parameter. */
dp?: Uint8Array;
/** RSA private key parameter. */
dq?: Uint8Array;
/** RSA private key parameter. */
qi?: Uint8Array;
/** RSA secret prime. */
p?: Uint8Array;
/** RSA secret prime, with p < q. */
q?: Uint8Array;
/** Symmetric key. */
k?: Uint8Array;
/** Protected Key, used with 'Bring Your Own Key'. */
t?: Uint8Array;
/** Elliptic curve name. For valid values, see JsonWebKeyCurveName. */
crv?: JsonWebKeyCurveName;
/** X component of an EC public key. */
x?: Uint8Array;
/** Y component of an EC public key. */
y?: Uint8Array;
}
export declare function jsonWebKeySerializer(item: JsonWebKey): any;
export declare function jsonWebKeyDeserializer(item: any): JsonWebKey;
/** The key vault error exception. */
export interface KeyVaultError {
/** The key vault server error. */
readonly error?: ErrorModel;
}
export declare function keyVaultErrorDeserializer(item: any): KeyVaultError;
/** Alias for ErrorModel */
export type ErrorModel = {
code?: string;
message?: string;
innerError?: ErrorModel;
} | null;
/** model interface _KeyVaultErrorError */
export interface _KeyVaultErrorError {
/** The error code. */
readonly code?: string;
/** The error message. */
readonly message?: string;
/** The key vault server error. */
readonly innerError?: ErrorModel;
}
export declare function _keyVaultErrorErrorDeserializer(item: any): _KeyVaultErrorError;
/** The key import parameters. */
export interface KeyImportParameters {
/** Whether to import as a hardware key (HSM) or software key. */
hsm?: boolean;
/** The Json web key */
key: JsonWebKey;
/** The key management attributes. */
keyAttributes?: KeyAttributes;
/** Application specific metadata in the form of key-value pairs. */
tags?: Record<string, string>;
/** The policy rules under which the key can be exported. */
releasePolicy?: KeyReleasePolicy;
}
export declare function keyImportParametersSerializer(item: KeyImportParameters): any;
/** A DeletedKeyBundle consisting of a WebKey plus its Attributes and deletion info */
export interface DeletedKeyBundle {
/** The Json web key. */
key?: JsonWebKey;
/** The key management attributes. */
attributes?: KeyAttributes;
/** Application specific metadata in the form of key-value pairs. */
tags?: Record<string, string>;
/** True if the key's lifetime is managed by key vault. If this is a key backing a certificate, then managed will be true. */
readonly managed?: boolean;
/** The policy rules under which the key can be exported. */
releasePolicy?: KeyReleasePolicy;
/** The url of the recovery object, used to identify and recover the deleted key. */
recoveryId?: string;
/** The time when the key is scheduled to be purged, in UTC */
readonly scheduledPurgeDate?: Date;
/** The time when the key was deleted, in UTC */
readonly deletedDate?: Date;
}
export declare function deletedKeyBundleDeserializer(item: any): DeletedKeyBundle;
/** The key update parameters. */
export interface KeyUpdateParameters {
/** Json web key operations. For more information on possible key operations, see JsonWebKeyOperation. */
keyOps?: JsonWebKeyOperation[];
/** The attributes of a key managed by the key vault service. */
keyAttributes?: KeyAttributes;
/** Application specific metadata in the form of key-value pairs. */
tags?: Record<string, string>;
/** The policy rules under which the key can be exported. */
releasePolicy?: KeyReleasePolicy;
}
export declare function keyUpdateParametersSerializer(item: KeyUpdateParameters): any;
/** The key list result. */
export interface _KeyListResult {
/** A response message containing a list of keys in the key vault along with a link to the next page of keys. */
readonly value?: KeyItem[];
/** The URL to get the next set of keys. */
readonly nextLink?: string;
}
export declare function _keyListResultDeserializer(item: any): _KeyListResult;
export declare function keyItemArrayDeserializer(result: Array<KeyItem>): any[];
/** The key item containing key metadata. */
export interface KeyItem {
/** Key identifier. */
kid?: string;
/** The key management attributes. */
attributes?: KeyAttributes;
/** Application specific metadata in the form of key-value pairs. */
tags?: Record<string, string>;
/** True if the key's lifetime is managed by key vault. If this is a key backing a certificate, then managed will be true. */
readonly managed?: boolean;
}
export declare function keyItemDeserializer(item: any): KeyItem;
/** The backup key result, containing the backup blob. */
export interface BackupKeyResult {
/** The backup blob containing the backed up key. */
readonly value?: Uint8Array;
}
export declare function backupKeyResultDeserializer(item: any): BackupKeyResult;
/** The key restore parameters. */
export interface KeyRestoreParameters {
/** The backup blob associated with a key bundle. */
keyBundleBackup: Uint8Array;
}
export declare function keyRestoreParametersSerializer(item: KeyRestoreParameters): any;
/** The key operations parameters. */
export interface KeyOperationsParameters {
/** algorithm identifier */
algorithm: JsonWebKeyEncryptionAlgorithm;
/** The value to operate on. */
value: Uint8Array;
/** Cryptographically random, non-repeating initialization vector for symmetric algorithms. */
iv?: Uint8Array;
/** Additional data to authenticate but not encrypt/decrypt when using authenticated crypto algorithms. */
aad?: Uint8Array;
/** The tag to authenticate when performing decryption with an authenticated algorithm. */
tag?: Uint8Array;
}
export declare function keyOperationsParametersSerializer(item: KeyOperationsParameters): any;
/** An algorithm used for encryption and decryption. */
export declare enum KnownJsonWebKeyEncryptionAlgorithm {
/** [Not recommended] RSAES using Optimal Asymmetric Encryption Padding (OAEP), as described in https://tools.ietf.org/html/rfc3447, with the default parameters specified by RFC 3447 in Section A.2.1. Those default parameters are using a hash function of SHA-1 and a mask generation function of MGF1 with SHA-1. Microsoft recommends using RSA_OAEP_256 or stronger algorithms for enhanced security. Microsoft does *not* recommend RSA_OAEP, which is included solely for backwards compatibility. RSA_OAEP utilizes SHA1, which has known collision problems. */
RSAOaep = "RSA-OAEP",
/** RSAES using Optimal Asymmetric Encryption Padding with a hash function of SHA-256 and a mask generation function of MGF1 with SHA-256. */
RSAOaep256 = "RSA-OAEP-256",
/** [Not recommended] RSAES-PKCS1-V1_5 key encryption, as described in https://tools.ietf.org/html/rfc3447. Microsoft recommends using RSA_OAEP_256 or stronger algorithms for enhanced security. Microsoft does *not* recommend RSA_1_5, which is included solely for backwards compatibility. Cryptographic standards no longer consider RSA with the PKCS#1 v1.5 padding scheme secure for encryption. */
RSA15 = "RSA1_5",
/** 128-bit AES-GCM. */
A128GCM = "A128GCM",
/** 192-bit AES-GCM. */
A192GCM = "A192GCM",
/** 256-bit AES-GCM. */
A256GCM = "A256GCM",
/** 128-bit AES key wrap. */
A128KW = "A128KW",
/** 192-bit AES key wrap. */
A192KW = "A192KW",
/** 256-bit AES key wrap. */
A256KW = "A256KW",
/** 128-bit AES-CBC. */
A128CBC = "A128CBC",
/** 192-bit AES-CBC. */
A192CBC = "A192CBC",
/** 256-bit AES-CBC. */
A256CBC = "A256CBC",
/** 128-bit AES-CBC with PKCS padding. */
A128Cbcpad = "A128CBCPAD",
/** 192-bit AES-CBC with PKCS padding. */
A192Cbcpad = "A192CBCPAD",
/** 256-bit AES-CBC with PKCS padding. */
A256Cbcpad = "A256CBCPAD",
/** CKM AES key wrap. */
CkmAesKeyWrap = "CKM_AES_KEY_WRAP",
/** CKM AES key wrap with padding. */
CkmAesKeyWrapPad = "CKM_AES_KEY_WRAP_PAD"
}
/**
* An algorithm used for encryption and decryption. \
* {@link KnownJsonWebKeyEncryptionAlgorithm} can be used interchangeably with JsonWebKeyEncryptionAlgorithm,
* this enum contains the known values that the service supports.
* ### Known values supported by the service
* **RSA-OAEP**: [Not recommended] RSAES using Optimal Asymmetric Encryption Padding (OAEP), as described in https:\//tools.ietf.org\/html\/rfc3447, with the default parameters specified by RFC 3447 in Section A.2.1. Those default parameters are using a hash function of SHA-1 and a mask generation function of MGF1 with SHA-1. Microsoft recommends using RSA_OAEP_256 or stronger algorithms for enhanced security. Microsoft does *not* recommend RSA_OAEP, which is included solely for backwards compatibility. RSA_OAEP utilizes SHA1, which has known collision problems. \
* **RSA-OAEP-256**: RSAES using Optimal Asymmetric Encryption Padding with a hash function of SHA-256 and a mask generation function of MGF1 with SHA-256. \
* **RSA1_5**: [Not recommended] RSAES-PKCS1-V1_5 key encryption, as described in https:\//tools.ietf.org\/html\/rfc3447. Microsoft recommends using RSA_OAEP_256 or stronger algorithms for enhanced security. Microsoft does *not* recommend RSA_1_5, which is included solely for backwards compatibility. Cryptographic standards no longer consider RSA with the PKCS#1 v1.5 padding scheme secure for encryption. \
* **A128GCM**: 128-bit AES-GCM. \
* **A192GCM**: 192-bit AES-GCM. \
* **A256GCM**: 256-bit AES-GCM. \
* **A128KW**: 128-bit AES key wrap. \
* **A192KW**: 192-bit AES key wrap. \
* **A256KW**: 256-bit AES key wrap. \
* **A128CBC**: 128-bit AES-CBC. \
* **A192CBC**: 192-bit AES-CBC. \
* **A256CBC**: 256-bit AES-CBC. \
* **A128CBCPAD**: 128-bit AES-CBC with PKCS padding. \
* **A192CBCPAD**: 192-bit AES-CBC with PKCS padding. \
* **A256CBCPAD**: 256-bit AES-CBC with PKCS padding. \
* **CKM_AES_KEY_WRAP**: CKM AES key wrap. \
* **CKM_AES_KEY_WRAP_PAD**: CKM AES key wrap with padding.
*/
export type JsonWebKeyEncryptionAlgorithm = string;
/** The key operation result. */
export interface KeyOperationResult {
/** Key identifier */
readonly kid?: string;
/** The result of the operation. */
readonly result?: Uint8Array;
/** Cryptographically random, non-repeating initialization vector for symmetric algorithms. */
readonly iv?: Uint8Array;
/** The tag to authenticate when performing decryption with an authenticated algorithm. */
readonly authenticationTag?: Uint8Array;
/** Additional data to authenticate but not encrypt/decrypt when using authenticated crypto algorithms. */
readonly additionalAuthenticatedData?: Uint8Array;
}
export declare function keyOperationResultDeserializer(item: any): KeyOperationResult;
/** The key operations parameters. */
export interface KeySignParameters {
/** The signing/verification algorithm identifier. For more information on possible algorithm types, see JsonWebKeySignatureAlgorithm. */
algorithm: JsonWebKeySignatureAlgorithm;
/** The value to operate on. */
value: Uint8Array;
}
export declare function keySignParametersSerializer(item: KeySignParameters): any;
/** The signing/verification algorithm identifier. For more information on possible algorithm types, see JsonWebKeySignatureAlgorithm. */
export declare enum KnownJsonWebKeySignatureAlgorithm {
/** RSASSA-PSS using SHA-256 and MGF1 with SHA-256, as described in https://tools.ietf.org/html/rfc7518 */
PS256 = "PS256",
/** RSASSA-PSS using SHA-384 and MGF1 with SHA-384, as described in https://tools.ietf.org/html/rfc7518 */
PS384 = "PS384",
/** RSASSA-PSS using SHA-512 and MGF1 with SHA-512, as described in https://tools.ietf.org/html/rfc7518 */
PS512 = "PS512",
/** RSASSA-PKCS1-v1_5 using SHA-256, as described in https://tools.ietf.org/html/rfc7518 */
RS256 = "RS256",
/** RSASSA-PKCS1-v1_5 using SHA-384, as described in https://tools.ietf.org/html/rfc7518 */
RS384 = "RS384",
/** RSASSA-PKCS1-v1_5 using SHA-512, as described in https://tools.ietf.org/html/rfc7518 */
RS512 = "RS512",
/** HMAC using SHA-256, as described in https://tools.ietf.org/html/rfc7518 */
HS256 = "HS256",
/** HMAC using SHA-384, as described in https://tools.ietf.org/html/rfc7518 */
HS384 = "HS384",
/** HMAC using SHA-512, as described in https://tools.ietf.org/html/rfc7518 */
HS512 = "HS512",
/** Reserved */
Rsnull = "RSNULL",
/** ECDSA using P-256 and SHA-256, as described in https://tools.ietf.org/html/rfc7518. */
ES256 = "ES256",
/** ECDSA using P-384 and SHA-384, as described in https://tools.ietf.org/html/rfc7518 */
ES384 = "ES384",
/** ECDSA using P-521 and SHA-512, as described in https://tools.ietf.org/html/rfc7518 */
ES512 = "ES512",
/** ECDSA using P-256K and SHA-256, as described in https://tools.ietf.org/html/rfc7518 */
ES256K = "ES256K"
}
/**
* The signing/verification algorithm identifier. For more information on possible algorithm types, see JsonWebKeySignatureAlgorithm. \
* {@link KnownJsonWebKeySignatureAlgorithm} can be used interchangeably with JsonWebKeySignatureAlgorithm,
* this enum contains the known values that the service supports.
* ### Known values supported by the service
* **PS256**: RSASSA-PSS using SHA-256 and MGF1 with SHA-256, as described in https:\//tools.ietf.org\/html\/rfc7518 \
* **PS384**: RSASSA-PSS using SHA-384 and MGF1 with SHA-384, as described in https:\//tools.ietf.org\/html\/rfc7518 \
* **PS512**: RSASSA-PSS using SHA-512 and MGF1 with SHA-512, as described in https:\//tools.ietf.org\/html\/rfc7518 \
* **RS256**: RSASSA-PKCS1-v1_5 using SHA-256, as described in https:\//tools.ietf.org\/html\/rfc7518 \
* **RS384**: RSASSA-PKCS1-v1_5 using SHA-384, as described in https:\//tools.ietf.org\/html\/rfc7518 \
* **RS512**: RSASSA-PKCS1-v1_5 using SHA-512, as described in https:\//tools.ietf.org\/html\/rfc7518 \
* **HS256**: HMAC using SHA-256, as described in https:\//tools.ietf.org\/html\/rfc7518 \
* **HS384**: HMAC using SHA-384, as described in https:\//tools.ietf.org\/html\/rfc7518 \
* **HS512**: HMAC using SHA-512, as described in https:\//tools.ietf.org\/html\/rfc7518 \
* **RSNULL**: Reserved \
* **ES256**: ECDSA using P-256 and SHA-256, as described in https:\//tools.ietf.org\/html\/rfc7518. \
* **ES384**: ECDSA using P-384 and SHA-384, as described in https:\//tools.ietf.org\/html\/rfc7518 \
* **ES512**: ECDSA using P-521 and SHA-512, as described in https:\//tools.ietf.org\/html\/rfc7518 \
* **ES256K**: ECDSA using P-256K and SHA-256, as described in https:\//tools.ietf.org\/html\/rfc7518
*/
export type JsonWebKeySignatureAlgorithm = string;
/** The key verify parameters. */
export interface KeyVerifyParameters {
/** The signing/verification algorithm. For more information on possible algorithm types, see JsonWebKeySignatureAlgorithm. */
algorithm: JsonWebKeySignatureAlgorithm;
/** The digest used for signing. */
digest: Uint8Array;
/** The signature to be verified. */
signature: Uint8Array;
}
export declare function keyVerifyParametersSerializer(item: KeyVerifyParameters): any;
/** The key verify result. */
export interface KeyVerifyResult {
/** True if the signature is verified, otherwise false. */
readonly value?: boolean;
}
export declare function keyVerifyResultDeserializer(item: any): KeyVerifyResult;
/** The release key parameters. */
export interface KeyReleaseParameters {
/** The attestation assertion for the target of the key release. */
targetAttestationToken: string;
/** A client provided nonce for freshness. */
nonce?: string;
/** The encryption algorithm to use to protected the exported key material */
enc?: KeyEncryptionAlgorithm;
}
export declare function keyReleaseParametersSerializer(item: KeyReleaseParameters): any;
/** The encryption algorithm to use to protected the exported key material */
export declare enum KnownKeyEncryptionAlgorithm {
/** The CKM_RSA_AES_KEY_WRAP key wrap mechanism. */
CkmRsaAesKeyWrap = "CKM_RSA_AES_KEY_WRAP",
/** The RSA_AES_KEY_WRAP_256 key wrap mechanism. */
RsaAesKeyWrap256 = "RSA_AES_KEY_WRAP_256",
/** The RSA_AES_KEY_WRAP_384 key wrap mechanism. */
RsaAesKeyWrap384 = "RSA_AES_KEY_WRAP_384"
}
/**
* The encryption algorithm to use to protected the exported key material \
* {@link KnownKeyEncryptionAlgorithm} can be used interchangeably with KeyEncryptionAlgorithm,
* this enum contains the known values that the service supports.
* ### Known values supported by the service
* **CKM_RSA_AES_KEY_WRAP**: The CKM_RSA_AES_KEY_WRAP key wrap mechanism. \
* **RSA_AES_KEY_WRAP_256**: The RSA_AES_KEY_WRAP_256 key wrap mechanism. \
* **RSA_AES_KEY_WRAP_384**: The RSA_AES_KEY_WRAP_384 key wrap mechanism.
*/
export type KeyEncryptionAlgorithm = string;
/** The release result, containing the released key. */
export interface KeyReleaseResult {
/** A signed object containing the released key. */
readonly value?: string;
}
export declare function keyReleaseResultDeserializer(item: any): KeyReleaseResult;
/** A list of keys that have been deleted in this vault. */
export interface _DeletedKeyListResult {
/** A response message containing a list of deleted keys in the key vault along with a link to the next page of deleted keys. */
readonly value?: DeletedKeyItem[];
/** The URL to get the next set of deleted keys. */
readonly nextLink?: string;
}
export declare function _deletedKeyListResultDeserializer(item: any): _DeletedKeyListResult;
export declare function deletedKeyItemArrayDeserializer(result: Array<DeletedKeyItem>): any[];
/** The deleted key item containing the deleted key metadata and information about deletion. */
export interface DeletedKeyItem {
/** Key identifier. */
kid?: string;
/** The key management attributes. */
attributes?: KeyAttributes;
/** Application specific metadata in the form of key-value pairs. */
tags?: Record<string, string>;
/** True if the key's lifetime is managed by key vault. If this is a key backing a certificate, then managed will be true. */
readonly managed?: boolean;
/** The url of the recovery object, used to identify and recover the deleted key. */
recoveryId?: string;
/** The time when the key is scheduled to be purged, in UTC */
readonly scheduledPurgeDate?: Date;
/** The time when the key was deleted, in UTC */
readonly deletedDate?: Date;
}
export declare function deletedKeyItemDeserializer(item: any): DeletedKeyItem;
/** Management policy for a key. */
export interface KeyRotationPolicy {
/** The key policy id. */
readonly id?: string;
/** Actions that will be performed by Key Vault over the lifetime of a key. For preview, lifetimeActions can only have two items at maximum: one for rotate, one for notify. Notification time would be default to 30 days before expiry and it is not configurable. */
lifetimeActions?: LifetimeActions[];
/** The key rotation policy attributes. */
attributes?: KeyRotationPolicyAttributes;
}
export declare function keyRotationPolicySerializer(item: KeyRotationPolicy): any;
export declare function keyRotationPolicyDeserializer(item: any): KeyRotationPolicy;
export declare function lifetimeActionsArraySerializer(result: Array<LifetimeActions>): any[];
export declare function lifetimeActionsArrayDeserializer(result: Array<LifetimeActions>): any[];
/** Action and its trigger that will be performed by Key Vault over the lifetime of a key. */
export interface LifetimeActions {
/** The condition that will execute the action. */
trigger?: LifetimeActionsTrigger;
/** The action that will be executed. */
action?: LifetimeActionsType;
}
export declare function lifetimeActionsSerializer(item: LifetimeActions): any;
export declare function lifetimeActionsDeserializer(item: any): LifetimeActions;
/** A condition to be satisfied for an action to be executed. */
export interface LifetimeActionsTrigger {
/** Time after creation to attempt to rotate. It only applies to rotate. It will be in ISO 8601 duration format. Example: 90 days : "P90D" */
timeAfterCreate?: string;
/** Time before expiry to attempt to rotate or notify. It will be in ISO 8601 duration format. Example: 90 days : "P90D" */
timeBeforeExpiry?: string;
}
export declare function lifetimeActionsTriggerSerializer(item: LifetimeActionsTrigger): any;
export declare function lifetimeActionsTriggerDeserializer(item: any): LifetimeActionsTrigger;
/** The action that will be executed. */
export interface LifetimeActionsType {
/** The type of the action. The value should be compared case-insensitively. */
type?: KeyRotationPolicyAction;
}
export declare function lifetimeActionsTypeSerializer(item: LifetimeActionsType): any;
export declare function lifetimeActionsTypeDeserializer(item: any): LifetimeActionsType;
/** The type of the action. The value should be compared case-insensitively. */
export type KeyRotationPolicyAction = "Rotate" | "Notify";
/** The key rotation policy attributes. */
export interface KeyRotationPolicyAttributes {
/** The expiryTime will be applied on the new key version. It should be at least 28 days. It will be in ISO 8601 Format. Examples: 90 days: P90D, 3 months: P3M, 48 hours: PT48H, 1 year and 10 days: P1Y10D */
expiryTime?: string;
/** The key rotation policy created time in UTC. */
readonly created?: Date;
/** The key rotation policy's last updated time in UTC. */
readonly updated?: Date;
}
export declare function keyRotationPolicyAttributesSerializer(item: KeyRotationPolicyAttributes): any;
export declare function keyRotationPolicyAttributesDeserializer(item: any): KeyRotationPolicyAttributes;
/** The get random bytes request object. */
export interface GetRandomBytesRequest {
/** The requested number of random bytes. */
count: number;
}
export declare function getRandomBytesRequestSerializer(item: GetRandomBytesRequest): any;
/** The get random bytes response object containing the bytes. */
export interface RandomBytes {
/** The bytes encoded as a base64url string. */
value: Uint8Array;
}
export declare function randomBytesDeserializer(item: any): RandomBytes;
/** The available API versions. */
export declare enum KnownVersions {
/** The 7.5 API version. */
V75 = "7.5",
/** The 7.6-preview.2 API version. */
V76Preview2 = "7.6-preview.2",
/** The 7.6 API version. */
V76 = "7.6"
}
//# sourceMappingURL=models.d.ts.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,656 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { uint8ArrayToString, stringToUint8Array } from "@azure/core-util";
export function keyCreateParametersSerializer(item) {
return {
kty: item["kty"],
key_size: item["keySize"],
public_exponent: item["publicExponent"],
key_ops: !item["keyOps"]
? item["keyOps"]
: item["keyOps"].map((p) => {
return p;
}),
attributes: !item["keyAttributes"]
? item["keyAttributes"]
: keyAttributesSerializer(item["keyAttributes"]),
tags: item["tags"],
crv: item["curve"],
release_policy: !item["releasePolicy"]
? item["releasePolicy"]
: keyReleasePolicySerializer(item["releasePolicy"]),
};
}
/** JsonWebKey Key Type (kty), as defined in https://tools.ietf.org/html/draft-ietf-jose-json-web-algorithms-40. */
export var KnownJsonWebKeyType;
(function (KnownJsonWebKeyType) {
/** Elliptic Curve. */
KnownJsonWebKeyType["EC"] = "EC";
/** Elliptic Curve with a private key which is stored in the HSM. */
KnownJsonWebKeyType["ECHSM"] = "EC-HSM";
/** RSA (https://tools.ietf.org/html/rfc3447) */
KnownJsonWebKeyType["RSA"] = "RSA";
/** RSA with a private key which is stored in the HSM. */
KnownJsonWebKeyType["RSAHSM"] = "RSA-HSM";
/** Octet sequence (used to represent symmetric keys) */
KnownJsonWebKeyType["Oct"] = "oct";
/** Octet sequence (used to represent symmetric keys) which is stored the HSM. */
KnownJsonWebKeyType["OctHSM"] = "oct-HSM";
})(KnownJsonWebKeyType || (KnownJsonWebKeyType = {}));
/** JSON web key operations. For more information, see JsonWebKeyOperation. */
export var KnownJsonWebKeyOperation;
(function (KnownJsonWebKeyOperation) {
/** Indicates that the key can be used to encrypt. */
KnownJsonWebKeyOperation["Encrypt"] = "encrypt";
/** Indicates that the key can be used to decrypt. */
KnownJsonWebKeyOperation["Decrypt"] = "decrypt";
/** Indicates that the key can be used to sign. */
KnownJsonWebKeyOperation["Sign"] = "sign";
/** Indicates that the key can be used to verify. */
KnownJsonWebKeyOperation["Verify"] = "verify";
/** Indicates that the key can be used to wrap another key. */
KnownJsonWebKeyOperation["WrapKey"] = "wrapKey";
/** Indicates that the key can be used to unwrap another key. */
KnownJsonWebKeyOperation["UnwrapKey"] = "unwrapKey";
/** Indicates that the key can be imported during creation. */
KnownJsonWebKeyOperation["Import"] = "import";
/** Indicates that the private component of the key can be exported. */
KnownJsonWebKeyOperation["Export"] = "export";
})(KnownJsonWebKeyOperation || (KnownJsonWebKeyOperation = {}));
export function keyAttributesSerializer(item) {
return {
enabled: item["enabled"],
nbf: !item["notBefore"]
? item["notBefore"]
: (item["notBefore"].getTime() / 1000) | 0,
exp: !item["expires"]
? item["expires"]
: (item["expires"].getTime() / 1000) | 0,
exportable: item["exportable"],
};
}
export function keyAttributesDeserializer(item) {
return {
enabled: item["enabled"],
notBefore: !item["nbf"] ? item["nbf"] : new Date(item["nbf"] * 1000),
expires: !item["exp"] ? item["exp"] : new Date(item["exp"] * 1000),
created: !item["created"]
? item["created"]
: new Date(item["created"] * 1000),
updated: !item["updated"]
? item["updated"]
: new Date(item["updated"] * 1000),
recoverableDays: item["recoverableDays"],
recoveryLevel: item["recoveryLevel"],
exportable: item["exportable"],
hsmPlatform: item["hsmPlatform"],
attestation: !item["attestation"]
? item["attestation"]
: keyAttestationDeserializer(item["attestation"]),
};
}
/** Reflects the deletion recovery level currently in effect for certificates in the current vault. If it contains 'Purgeable', the certificate can be permanently deleted by a privileged user; otherwise, only the system can purge the certificate, at the end of the retention interval. */
export var KnownDeletionRecoveryLevel;
(function (KnownDeletionRecoveryLevel) {
/** Denotes a vault state in which deletion is an irreversible operation, without the possibility for recovery. This level corresponds to no protection being available against a Delete operation; the data is irretrievably lost upon accepting a Delete operation at the entity level or higher (vault, resource group, subscription etc.) */
KnownDeletionRecoveryLevel["Purgeable"] = "Purgeable";
/** Denotes a vault state in which deletion is recoverable, and which also permits immediate and permanent deletion (i.e. purge). This level guarantees the recoverability of the deleted entity during the retention interval (90 days), unless a Purge operation is requested, or the subscription is cancelled. System wil permanently delete it after 90 days, if not recovered */
KnownDeletionRecoveryLevel["RecoverablePurgeable"] = "Recoverable+Purgeable";
/** Denotes a vault state in which deletion is recoverable without the possibility for immediate and permanent deletion (i.e. purge). This level guarantees the recoverability of the deleted entity during the retention interval(90 days) and while the subscription is still available. System wil permanently delete it after 90 days, if not recovered */
KnownDeletionRecoveryLevel["Recoverable"] = "Recoverable";
/** Denotes a vault and subscription state in which deletion is recoverable within retention interval (90 days), immediate and permanent deletion (i.e. purge) is not permitted, and in which the subscription itself cannot be permanently canceled. System wil permanently delete it after 90 days, if not recovered */
KnownDeletionRecoveryLevel["RecoverableProtectedSubscription"] = "Recoverable+ProtectedSubscription";
/** Denotes a vault state in which deletion is recoverable, and which also permits immediate and permanent deletion (i.e. purge when 7 <= SoftDeleteRetentionInDays < 90). This level guarantees the recoverability of the deleted entity during the retention interval, unless a Purge operation is requested, or the subscription is cancelled. */
KnownDeletionRecoveryLevel["CustomizedRecoverablePurgeable"] = "CustomizedRecoverable+Purgeable";
/** Denotes a vault state in which deletion is recoverable without the possibility for immediate and permanent deletion (i.e. purge when 7 <= SoftDeleteRetentionInDays < 90).This level guarantees the recoverability of the deleted entity during the retention interval and while the subscription is still available. */
KnownDeletionRecoveryLevel["CustomizedRecoverable"] = "CustomizedRecoverable";
/** Denotes a vault and subscription state in which deletion is recoverable, immediate and permanent deletion (i.e. purge) is not permitted, and in which the subscription itself cannot be permanently canceled when 7 <= SoftDeleteRetentionInDays < 90. This level guarantees the recoverability of the deleted entity during the retention interval, and also reflects the fact that the subscription itself cannot be cancelled. */
KnownDeletionRecoveryLevel["CustomizedRecoverableProtectedSubscription"] = "CustomizedRecoverable+ProtectedSubscription";
})(KnownDeletionRecoveryLevel || (KnownDeletionRecoveryLevel = {}));
export function keyAttestationDeserializer(item) {
return {
certificatePemFile: !item["certificatePemFile"]
? item["certificatePemFile"]
: typeof item["certificatePemFile"] === "string"
? stringToUint8Array(item["certificatePemFile"], "base64url")
: item["certificatePemFile"],
privateKeyAttestation: !item["privateKeyAttestation"]
? item["privateKeyAttestation"]
: typeof item["privateKeyAttestation"] === "string"
? stringToUint8Array(item["privateKeyAttestation"], "base64url")
: item["privateKeyAttestation"],
publicKeyAttestation: !item["publicKeyAttestation"]
? item["publicKeyAttestation"]
: typeof item["publicKeyAttestation"] === "string"
? stringToUint8Array(item["publicKeyAttestation"], "base64url")
: item["publicKeyAttestation"],
version: item["version"],
};
}
/** Elliptic curve name. For valid values, see JsonWebKeyCurveName. */
export var KnownJsonWebKeyCurveName;
(function (KnownJsonWebKeyCurveName) {
/** The NIST P-256 elliptic curve, AKA SECG curve SECP256R1. */
KnownJsonWebKeyCurveName["P256"] = "P-256";
/** The NIST P-384 elliptic curve, AKA SECG curve SECP384R1. */
KnownJsonWebKeyCurveName["P384"] = "P-384";
/** The NIST P-521 elliptic curve, AKA SECG curve SECP521R1. */
KnownJsonWebKeyCurveName["P521"] = "P-521";
/** The SECG SECP256K1 elliptic curve. */
KnownJsonWebKeyCurveName["P256K"] = "P-256K";
})(KnownJsonWebKeyCurveName || (KnownJsonWebKeyCurveName = {}));
export function keyReleasePolicySerializer(item) {
return {
contentType: item["contentType"],
immutable: item["immutable"],
data: !item["encodedPolicy"]
? item["encodedPolicy"]
: uint8ArrayToString(item["encodedPolicy"], "base64url"),
};
}
export function keyReleasePolicyDeserializer(item) {
return {
contentType: item["contentType"],
immutable: item["immutable"],
encodedPolicy: !item["data"]
? item["data"]
: typeof item["data"] === "string"
? stringToUint8Array(item["data"], "base64url")
: item["data"],
};
}
export function keyBundleDeserializer(item) {
return {
key: !item["key"] ? item["key"] : jsonWebKeyDeserializer(item["key"]),
attributes: !item["attributes"]
? item["attributes"]
: keyAttributesDeserializer(item["attributes"]),
tags: item["tags"],
managed: item["managed"],
releasePolicy: !item["release_policy"]
? item["release_policy"]
: keyReleasePolicyDeserializer(item["release_policy"]),
};
}
export function jsonWebKeySerializer(item) {
return {
kid: item["kid"],
kty: item["kty"],
key_ops: !item["keyOps"]
? item["keyOps"]
: item["keyOps"].map((p) => {
return p;
}),
n: !item["n"] ? item["n"] : uint8ArrayToString(item["n"], "base64url"),
e: !item["e"] ? item["e"] : uint8ArrayToString(item["e"], "base64url"),
d: !item["d"] ? item["d"] : uint8ArrayToString(item["d"], "base64url"),
dp: !item["dp"] ? item["dp"] : uint8ArrayToString(item["dp"], "base64url"),
dq: !item["dq"] ? item["dq"] : uint8ArrayToString(item["dq"], "base64url"),
qi: !item["qi"] ? item["qi"] : uint8ArrayToString(item["qi"], "base64url"),
p: !item["p"] ? item["p"] : uint8ArrayToString(item["p"], "base64url"),
q: !item["q"] ? item["q"] : uint8ArrayToString(item["q"], "base64url"),
k: !item["k"] ? item["k"] : uint8ArrayToString(item["k"], "base64url"),
key_hsm: !item["t"]
? item["t"]
: uint8ArrayToString(item["t"], "base64url"),
crv: item["crv"],
x: !item["x"] ? item["x"] : uint8ArrayToString(item["x"], "base64url"),
y: !item["y"] ? item["y"] : uint8ArrayToString(item["y"], "base64url"),
};
}
export function jsonWebKeyDeserializer(item) {
return {
kid: item["kid"],
kty: item["kty"],
keyOps: !item["key_ops"]
? item["key_ops"]
: item["key_ops"].map((p) => {
return p;
}),
n: !item["n"]
? item["n"]
: typeof item["n"] === "string"
? stringToUint8Array(item["n"], "base64url")
: item["n"],
e: !item["e"]
? item["e"]
: typeof item["e"] === "string"
? stringToUint8Array(item["e"], "base64url")
: item["e"],
d: !item["d"]
? item["d"]
: typeof item["d"] === "string"
? stringToUint8Array(item["d"], "base64url")
: item["d"],
dp: !item["dp"]
? item["dp"]
: typeof item["dp"] === "string"
? stringToUint8Array(item["dp"], "base64url")
: item["dp"],
dq: !item["dq"]
? item["dq"]
: typeof item["dq"] === "string"
? stringToUint8Array(item["dq"], "base64url")
: item["dq"],
qi: !item["qi"]
? item["qi"]
: typeof item["qi"] === "string"
? stringToUint8Array(item["qi"], "base64url")
: item["qi"],
p: !item["p"]
? item["p"]
: typeof item["p"] === "string"
? stringToUint8Array(item["p"], "base64url")
: item["p"],
q: !item["q"]
? item["q"]
: typeof item["q"] === "string"
? stringToUint8Array(item["q"], "base64url")
: item["q"],
k: !item["k"]
? item["k"]
: typeof item["k"] === "string"
? stringToUint8Array(item["k"], "base64url")
: item["k"],
t: !item["key_hsm"]
? item["key_hsm"]
: typeof item["key_hsm"] === "string"
? stringToUint8Array(item["key_hsm"], "base64url")
: item["key_hsm"],
crv: item["crv"],
x: !item["x"]
? item["x"]
: typeof item["x"] === "string"
? stringToUint8Array(item["x"], "base64url")
: item["x"],
y: !item["y"]
? item["y"]
: typeof item["y"] === "string"
? stringToUint8Array(item["y"], "base64url")
: item["y"],
};
}
export function keyVaultErrorDeserializer(item) {
return {
error: !item["error"]
? item["error"]
: _keyVaultErrorErrorDeserializer(item["error"]),
};
}
export function _keyVaultErrorErrorDeserializer(item) {
return {
code: item["code"],
message: item["message"],
innerError: !item["innererror"]
? item["innererror"]
: _keyVaultErrorErrorDeserializer(item["innererror"]),
};
}
export function keyImportParametersSerializer(item) {
return {
Hsm: item["hsm"],
key: jsonWebKeySerializer(item["key"]),
attributes: !item["keyAttributes"]
? item["keyAttributes"]
: keyAttributesSerializer(item["keyAttributes"]),
tags: item["tags"],
release_policy: !item["releasePolicy"]
? item["releasePolicy"]
: keyReleasePolicySerializer(item["releasePolicy"]),
};
}
export function deletedKeyBundleDeserializer(item) {
return {
key: !item["key"] ? item["key"] : jsonWebKeyDeserializer(item["key"]),
attributes: !item["attributes"]
? item["attributes"]
: keyAttributesDeserializer(item["attributes"]),
tags: item["tags"],
managed: item["managed"],
releasePolicy: !item["release_policy"]
? item["release_policy"]
: keyReleasePolicyDeserializer(item["release_policy"]),
recoveryId: item["recoveryId"],
scheduledPurgeDate: !item["scheduledPurgeDate"]
? item["scheduledPurgeDate"]
: new Date(item["scheduledPurgeDate"] * 1000),
deletedDate: !item["deletedDate"]
? item["deletedDate"]
: new Date(item["deletedDate"] * 1000),
};
}
export function keyUpdateParametersSerializer(item) {
return {
key_ops: !item["keyOps"]
? item["keyOps"]
: item["keyOps"].map((p) => {
return p;
}),
attributes: !item["keyAttributes"]
? item["keyAttributes"]
: keyAttributesSerializer(item["keyAttributes"]),
tags: item["tags"],
release_policy: !item["releasePolicy"]
? item["releasePolicy"]
: keyReleasePolicySerializer(item["releasePolicy"]),
};
}
export function _keyListResultDeserializer(item) {
return {
value: !item["value"]
? item["value"]
: keyItemArrayDeserializer(item["value"]),
nextLink: item["nextLink"],
};
}
export function keyItemArrayDeserializer(result) {
return result.map((item) => {
return keyItemDeserializer(item);
});
}
export function keyItemDeserializer(item) {
return {
kid: item["kid"],
attributes: !item["attributes"]
? item["attributes"]
: keyAttributesDeserializer(item["attributes"]),
tags: item["tags"],
managed: item["managed"],
};
}
export function backupKeyResultDeserializer(item) {
return {
value: !item["value"]
? item["value"]
: typeof item["value"] === "string"
? stringToUint8Array(item["value"], "base64url")
: item["value"],
};
}
export function keyRestoreParametersSerializer(item) {
return { value: uint8ArrayToString(item["keyBundleBackup"], "base64url") };
}
export function keyOperationsParametersSerializer(item) {
return {
alg: item["algorithm"],
value: uint8ArrayToString(item["value"], "base64url"),
iv: !item["iv"] ? item["iv"] : uint8ArrayToString(item["iv"], "base64url"),
aad: !item["aad"]
? item["aad"]
: uint8ArrayToString(item["aad"], "base64url"),
tag: !item["tag"]
? item["tag"]
: uint8ArrayToString(item["tag"], "base64url"),
};
}
/** An algorithm used for encryption and decryption. */
export var KnownJsonWebKeyEncryptionAlgorithm;
(function (KnownJsonWebKeyEncryptionAlgorithm) {
/** [Not recommended] RSAES using Optimal Asymmetric Encryption Padding (OAEP), as described in https://tools.ietf.org/html/rfc3447, with the default parameters specified by RFC 3447 in Section A.2.1. Those default parameters are using a hash function of SHA-1 and a mask generation function of MGF1 with SHA-1. Microsoft recommends using RSA_OAEP_256 or stronger algorithms for enhanced security. Microsoft does *not* recommend RSA_OAEP, which is included solely for backwards compatibility. RSA_OAEP utilizes SHA1, which has known collision problems. */
KnownJsonWebKeyEncryptionAlgorithm["RSAOaep"] = "RSA-OAEP";
/** RSAES using Optimal Asymmetric Encryption Padding with a hash function of SHA-256 and a mask generation function of MGF1 with SHA-256. */
KnownJsonWebKeyEncryptionAlgorithm["RSAOaep256"] = "RSA-OAEP-256";
/** [Not recommended] RSAES-PKCS1-V1_5 key encryption, as described in https://tools.ietf.org/html/rfc3447. Microsoft recommends using RSA_OAEP_256 or stronger algorithms for enhanced security. Microsoft does *not* recommend RSA_1_5, which is included solely for backwards compatibility. Cryptographic standards no longer consider RSA with the PKCS#1 v1.5 padding scheme secure for encryption. */
KnownJsonWebKeyEncryptionAlgorithm["RSA15"] = "RSA1_5";
/** 128-bit AES-GCM. */
KnownJsonWebKeyEncryptionAlgorithm["A128GCM"] = "A128GCM";
/** 192-bit AES-GCM. */
KnownJsonWebKeyEncryptionAlgorithm["A192GCM"] = "A192GCM";
/** 256-bit AES-GCM. */
KnownJsonWebKeyEncryptionAlgorithm["A256GCM"] = "A256GCM";
/** 128-bit AES key wrap. */
KnownJsonWebKeyEncryptionAlgorithm["A128KW"] = "A128KW";
/** 192-bit AES key wrap. */
KnownJsonWebKeyEncryptionAlgorithm["A192KW"] = "A192KW";
/** 256-bit AES key wrap. */
KnownJsonWebKeyEncryptionAlgorithm["A256KW"] = "A256KW";
/** 128-bit AES-CBC. */
KnownJsonWebKeyEncryptionAlgorithm["A128CBC"] = "A128CBC";
/** 192-bit AES-CBC. */
KnownJsonWebKeyEncryptionAlgorithm["A192CBC"] = "A192CBC";
/** 256-bit AES-CBC. */
KnownJsonWebKeyEncryptionAlgorithm["A256CBC"] = "A256CBC";
/** 128-bit AES-CBC with PKCS padding. */
KnownJsonWebKeyEncryptionAlgorithm["A128Cbcpad"] = "A128CBCPAD";
/** 192-bit AES-CBC with PKCS padding. */
KnownJsonWebKeyEncryptionAlgorithm["A192Cbcpad"] = "A192CBCPAD";
/** 256-bit AES-CBC with PKCS padding. */
KnownJsonWebKeyEncryptionAlgorithm["A256Cbcpad"] = "A256CBCPAD";
/** CKM AES key wrap. */
KnownJsonWebKeyEncryptionAlgorithm["CkmAesKeyWrap"] = "CKM_AES_KEY_WRAP";
/** CKM AES key wrap with padding. */
KnownJsonWebKeyEncryptionAlgorithm["CkmAesKeyWrapPad"] = "CKM_AES_KEY_WRAP_PAD";
})(KnownJsonWebKeyEncryptionAlgorithm || (KnownJsonWebKeyEncryptionAlgorithm = {}));
export function keyOperationResultDeserializer(item) {
return {
kid: item["kid"],
result: !item["value"]
? item["value"]
: typeof item["value"] === "string"
? stringToUint8Array(item["value"], "base64url")
: item["value"],
iv: !item["iv"]
? item["iv"]
: typeof item["iv"] === "string"
? stringToUint8Array(item["iv"], "base64url")
: item["iv"],
authenticationTag: !item["tag"]
? item["tag"]
: typeof item["tag"] === "string"
? stringToUint8Array(item["tag"], "base64url")
: item["tag"],
additionalAuthenticatedData: !item["aad"]
? item["aad"]
: typeof item["aad"] === "string"
? stringToUint8Array(item["aad"], "base64url")
: item["aad"],
};
}
export function keySignParametersSerializer(item) {
return {
alg: item["algorithm"],
value: uint8ArrayToString(item["value"], "base64url"),
};
}
/** The signing/verification algorithm identifier. For more information on possible algorithm types, see JsonWebKeySignatureAlgorithm. */
export var KnownJsonWebKeySignatureAlgorithm;
(function (KnownJsonWebKeySignatureAlgorithm) {
/** RSASSA-PSS using SHA-256 and MGF1 with SHA-256, as described in https://tools.ietf.org/html/rfc7518 */
KnownJsonWebKeySignatureAlgorithm["PS256"] = "PS256";
/** RSASSA-PSS using SHA-384 and MGF1 with SHA-384, as described in https://tools.ietf.org/html/rfc7518 */
KnownJsonWebKeySignatureAlgorithm["PS384"] = "PS384";
/** RSASSA-PSS using SHA-512 and MGF1 with SHA-512, as described in https://tools.ietf.org/html/rfc7518 */
KnownJsonWebKeySignatureAlgorithm["PS512"] = "PS512";
/** RSASSA-PKCS1-v1_5 using SHA-256, as described in https://tools.ietf.org/html/rfc7518 */
KnownJsonWebKeySignatureAlgorithm["RS256"] = "RS256";
/** RSASSA-PKCS1-v1_5 using SHA-384, as described in https://tools.ietf.org/html/rfc7518 */
KnownJsonWebKeySignatureAlgorithm["RS384"] = "RS384";
/** RSASSA-PKCS1-v1_5 using SHA-512, as described in https://tools.ietf.org/html/rfc7518 */
KnownJsonWebKeySignatureAlgorithm["RS512"] = "RS512";
/** HMAC using SHA-256, as described in https://tools.ietf.org/html/rfc7518 */
KnownJsonWebKeySignatureAlgorithm["HS256"] = "HS256";
/** HMAC using SHA-384, as described in https://tools.ietf.org/html/rfc7518 */
KnownJsonWebKeySignatureAlgorithm["HS384"] = "HS384";
/** HMAC using SHA-512, as described in https://tools.ietf.org/html/rfc7518 */
KnownJsonWebKeySignatureAlgorithm["HS512"] = "HS512";
/** Reserved */
KnownJsonWebKeySignatureAlgorithm["Rsnull"] = "RSNULL";
/** ECDSA using P-256 and SHA-256, as described in https://tools.ietf.org/html/rfc7518. */
KnownJsonWebKeySignatureAlgorithm["ES256"] = "ES256";
/** ECDSA using P-384 and SHA-384, as described in https://tools.ietf.org/html/rfc7518 */
KnownJsonWebKeySignatureAlgorithm["ES384"] = "ES384";
/** ECDSA using P-521 and SHA-512, as described in https://tools.ietf.org/html/rfc7518 */
KnownJsonWebKeySignatureAlgorithm["ES512"] = "ES512";
/** ECDSA using P-256K and SHA-256, as described in https://tools.ietf.org/html/rfc7518 */
KnownJsonWebKeySignatureAlgorithm["ES256K"] = "ES256K";
})(KnownJsonWebKeySignatureAlgorithm || (KnownJsonWebKeySignatureAlgorithm = {}));
export function keyVerifyParametersSerializer(item) {
return {
alg: item["algorithm"],
digest: uint8ArrayToString(item["digest"], "base64url"),
value: uint8ArrayToString(item["signature"], "base64url"),
};
}
export function keyVerifyResultDeserializer(item) {
return {
value: item["value"],
};
}
export function keyReleaseParametersSerializer(item) {
return {
target: item["targetAttestationToken"],
nonce: item["nonce"],
enc: item["enc"],
};
}
/** The encryption algorithm to use to protected the exported key material */
export var KnownKeyEncryptionAlgorithm;
(function (KnownKeyEncryptionAlgorithm) {
/** The CKM_RSA_AES_KEY_WRAP key wrap mechanism. */
KnownKeyEncryptionAlgorithm["CkmRsaAesKeyWrap"] = "CKM_RSA_AES_KEY_WRAP";
/** The RSA_AES_KEY_WRAP_256 key wrap mechanism. */
KnownKeyEncryptionAlgorithm["RsaAesKeyWrap256"] = "RSA_AES_KEY_WRAP_256";
/** The RSA_AES_KEY_WRAP_384 key wrap mechanism. */
KnownKeyEncryptionAlgorithm["RsaAesKeyWrap384"] = "RSA_AES_KEY_WRAP_384";
})(KnownKeyEncryptionAlgorithm || (KnownKeyEncryptionAlgorithm = {}));
export function keyReleaseResultDeserializer(item) {
return {
value: item["value"],
};
}
export function _deletedKeyListResultDeserializer(item) {
return {
value: !item["value"]
? item["value"]
: deletedKeyItemArrayDeserializer(item["value"]),
nextLink: item["nextLink"],
};
}
export function deletedKeyItemArrayDeserializer(result) {
return result.map((item) => {
return deletedKeyItemDeserializer(item);
});
}
export function deletedKeyItemDeserializer(item) {
return {
kid: item["kid"],
attributes: !item["attributes"]
? item["attributes"]
: keyAttributesDeserializer(item["attributes"]),
tags: item["tags"],
managed: item["managed"],
recoveryId: item["recoveryId"],
scheduledPurgeDate: !item["scheduledPurgeDate"]
? item["scheduledPurgeDate"]
: new Date(item["scheduledPurgeDate"] * 1000),
deletedDate: !item["deletedDate"]
? item["deletedDate"]
: new Date(item["deletedDate"] * 1000),
};
}
export function keyRotationPolicySerializer(item) {
return {
lifetimeActions: !item["lifetimeActions"]
? item["lifetimeActions"]
: lifetimeActionsArraySerializer(item["lifetimeActions"]),
attributes: !item["attributes"]
? item["attributes"]
: keyRotationPolicyAttributesSerializer(item["attributes"]),
};
}
export function keyRotationPolicyDeserializer(item) {
return {
id: item["id"],
lifetimeActions: !item["lifetimeActions"]
? item["lifetimeActions"]
: lifetimeActionsArrayDeserializer(item["lifetimeActions"]),
attributes: !item["attributes"]
? item["attributes"]
: keyRotationPolicyAttributesDeserializer(item["attributes"]),
};
}
export function lifetimeActionsArraySerializer(result) {
return result.map((item) => {
return lifetimeActionsSerializer(item);
});
}
export function lifetimeActionsArrayDeserializer(result) {
return result.map((item) => {
return lifetimeActionsDeserializer(item);
});
}
export function lifetimeActionsSerializer(item) {
return {
trigger: !item["trigger"]
? item["trigger"]
: lifetimeActionsTriggerSerializer(item["trigger"]),
action: !item["action"]
? item["action"]
: lifetimeActionsTypeSerializer(item["action"]),
};
}
export function lifetimeActionsDeserializer(item) {
return {
trigger: !item["trigger"]
? item["trigger"]
: lifetimeActionsTriggerDeserializer(item["trigger"]),
action: !item["action"]
? item["action"]
: lifetimeActionsTypeDeserializer(item["action"]),
};
}
export function lifetimeActionsTriggerSerializer(item) {
return {
timeAfterCreate: item["timeAfterCreate"],
timeBeforeExpiry: item["timeBeforeExpiry"],
};
}
export function lifetimeActionsTriggerDeserializer(item) {
return {
timeAfterCreate: item["timeAfterCreate"],
timeBeforeExpiry: item["timeBeforeExpiry"],
};
}
export function lifetimeActionsTypeSerializer(item) {
return { type: item["type"] };
}
export function lifetimeActionsTypeDeserializer(item) {
return {
type: item["type"],
};
}
export function keyRotationPolicyAttributesSerializer(item) {
return { expiryTime: item["expiryTime"] };
}
export function keyRotationPolicyAttributesDeserializer(item) {
return {
expiryTime: item["expiryTime"],
created: !item["created"]
? item["created"]
: new Date(item["created"] * 1000),
updated: !item["updated"]
? item["updated"]
: new Date(item["updated"] * 1000),
};
}
export function getRandomBytesRequestSerializer(item) {
return { count: item["count"] };
}
export function randomBytesDeserializer(item) {
return {
value: typeof item["value"] === "string"
? stringToUint8Array(item["value"], "base64url")
: item["value"],
};
}
/** The available API versions. */
export var KnownVersions;
(function (KnownVersions) {
/** The 7.5 API version. */
KnownVersions["V75"] = "7.5";
/** The 7.6-preview.2 API version. */
KnownVersions["V76Preview2"] = "7.6-preview.2";
/** The 7.6 API version. */
KnownVersions["V76"] = "7.6";
})(KnownVersions || (KnownVersions = {}));
//# sourceMappingURL=models.js.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,72 @@
import { Client, PathUncheckedResponse } from "@azure-rest/core-client";
/**
* Options for the byPage method
*/
export interface PageSettings {
/**
* A reference to a specific page to start iterating from.
*/
continuationToken?: string;
}
/**
* An interface that describes a page of results.
*/
export type ContinuablePage<TElement, TPage = TElement[]> = TPage & {
/**
* The token that keeps track of where to continue the iterator
*/
continuationToken?: string;
};
/**
* An interface that allows async iterable iteration both to completion and by page.
*/
export interface PagedAsyncIterableIterator<TElement, TPage = TElement[], TPageSettings extends PageSettings = PageSettings> {
/**
* The next method, part of the iteration protocol
*/
next(): Promise<IteratorResult<TElement>>;
/**
* The connection to the async iterator, part of the iteration protocol
*/
[Symbol.asyncIterator](): PagedAsyncIterableIterator<TElement, TPage, TPageSettings>;
/**
* Return an AsyncIterableIterator that works a page at a time
*/
byPage: (settings?: TPageSettings) => AsyncIterableIterator<ContinuablePage<TElement, TPage>>;
}
/**
* An interface that describes how to communicate with the service.
*/
export interface PagedResult<TElement, TPage = TElement[], TPageSettings extends PageSettings = PageSettings> {
/**
* Link to the first page of results.
*/
firstPageLink?: string;
/**
* A method that returns a page of results.
*/
getPage: (pageLink?: string) => Promise<{
page: TPage;
nextPageLink?: string;
} | undefined>;
/**
* a function to implement the `byPage` method on the paged async iterator.
*/
byPage?: (settings?: TPageSettings) => AsyncIterableIterator<ContinuablePage<TElement, TPage>>;
/**
* A function to extract elements from a page.
*/
toElements?: (page: TPage) => TElement[];
}
/**
* Options for the paging helper
*/
export interface BuildPagedAsyncIteratorOptions {
itemName?: string;
nextLinkName?: string;
}
/**
* Helper to paginate results in a generic way and return a PagedAsyncIterableIterator
*/
export declare function buildPagedAsyncIterator<TElement, TPage = TElement[], TPageSettings extends PageSettings = PageSettings, TResponse extends PathUncheckedResponse = PathUncheckedResponse>(client: Client, getInitialResponse: () => PromiseLike<TResponse>, processResponseBody: (result: TResponse) => PromiseLike<unknown>, expectedStatuses: string[], options?: BuildPagedAsyncIteratorOptions): PagedAsyncIterableIterator<TElement, TPage, TPageSettings>;
//# sourceMappingURL=pagingHelpers.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"pagingHelpers.d.ts","sourceRoot":"","sources":["../../../../src/generated/static-helpers/pagingHelpers.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,MAAM,EAEN,qBAAqB,EACtB,MAAM,yBAAyB,CAAC;AAGjC;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED;;GAEG;AACH,MAAM,MAAM,eAAe,CAAC,QAAQ,EAAE,KAAK,GAAG,QAAQ,EAAE,IAAI,KAAK,GAAG;IAClE;;OAEG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,0BAA0B,CACzC,QAAQ,EACR,KAAK,GAAG,QAAQ,EAAE,EAClB,aAAa,SAAS,YAAY,GAAG,YAAY;IAEjD;;OAEG;IACH,IAAI,IAAI,OAAO,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC1C;;OAEG;IACH,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,0BAA0B,CAClD,QAAQ,EACR,KAAK,EACL,aAAa,CACd,CAAC;IACF;;OAEG;IACH,MAAM,EAAE,CACN,QAAQ,CAAC,EAAE,aAAa,KACrB,qBAAqB,CAAC,eAAe,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC;CAC9D;AAED;;GAEG;AACH,MAAM,WAAW,WAAW,CAC1B,QAAQ,EACR,KAAK,GAAG,QAAQ,EAAE,EAClB,aAAa,SAAS,YAAY,GAAG,YAAY;IAEjD;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,OAAO,EAAE,CACP,QAAQ,CAAC,EAAE,MAAM,KACd,OAAO,CAAC;QAAE,IAAI,EAAE,KAAK,CAAC;QAAC,YAAY,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS,CAAC,CAAC;IACjE;;OAEG;IACH,MAAM,CAAC,EAAE,CACP,QAAQ,CAAC,EAAE,aAAa,KACrB,qBAAqB,CAAC,eAAe,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC;IAE7D;;OAEG;IACH,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,KAAK,KAAK,QAAQ,EAAE,CAAC;CAC1C;AAED;;GAEG;AACH,MAAM,WAAW,8BAA8B;IAC7C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CACrC,QAAQ,EACR,KAAK,GAAG,QAAQ,EAAE,EAClB,aAAa,SAAS,YAAY,GAAG,YAAY,EACjD,SAAS,SAAS,qBAAqB,GAAG,qBAAqB,EAE/D,MAAM,EAAE,MAAM,EACd,kBAAkB,EAAE,MAAM,WAAW,CAAC,SAAS,CAAC,EAChD,mBAAmB,EAAE,CAAC,MAAM,EAAE,SAAS,KAAK,WAAW,CAAC,OAAO,CAAC,EAChE,gBAAgB,EAAE,MAAM,EAAE,EAC1B,OAAO,GAAE,8BAAmC,GAC3C,0BAA0B,CAAC,QAAQ,EAAE,KAAK,EAAE,aAAa,CAAC,CA0B5D"}

View File

@ -0,0 +1,139 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { __asyncDelegator, __asyncGenerator, __asyncValues, __await } from "tslib";
import { createRestError, } from "@azure-rest/core-client";
import { RestError } from "@azure/core-rest-pipeline";
/**
* Helper to paginate results in a generic way and return a PagedAsyncIterableIterator
*/
export function buildPagedAsyncIterator(client, getInitialResponse, processResponseBody, expectedStatuses, options = {}) {
var _a, _b;
const itemName = (_a = options.itemName) !== null && _a !== void 0 ? _a : "value";
const nextLinkName = (_b = options.nextLinkName) !== null && _b !== void 0 ? _b : "nextLink";
const pagedResult = {
getPage: async (pageLink) => {
const result = pageLink === undefined
? await getInitialResponse()
: await client.pathUnchecked(pageLink).get();
checkPagingRequest(result, expectedStatuses);
const results = await processResponseBody(result);
const nextLink = getNextLink(results, nextLinkName);
const values = getElements(results, itemName);
return {
page: values,
nextPageLink: nextLink,
};
},
byPage: (settings) => {
const { continuationToken } = settings !== null && settings !== void 0 ? settings : {};
return getPageAsyncIterator(pagedResult, {
pageLink: continuationToken,
});
},
};
return getPagedAsyncIterator(pagedResult);
}
/**
* returns an async iterator that iterates over results. It also has a `byPage`
* method that returns pages of items at once.
*
* @param pagedResult - an object that specifies how to get pages.
* @returns a paged async iterator that iterates over results.
*/
function getPagedAsyncIterator(pagedResult) {
var _a;
const iter = getItemAsyncIterator(pagedResult);
return {
next() {
return iter.next();
},
[Symbol.asyncIterator]() {
return this;
},
byPage: (_a = pagedResult === null || pagedResult === void 0 ? void 0 : pagedResult.byPage) !== null && _a !== void 0 ? _a : ((settings) => {
const { continuationToken } = settings !== null && settings !== void 0 ? settings : {};
return getPageAsyncIterator(pagedResult, {
pageLink: continuationToken,
});
}),
};
}
function getItemAsyncIterator(pagedResult) {
return __asyncGenerator(this, arguments, function* getItemAsyncIterator_1() {
var _a, e_1, _b, _c;
const pages = getPageAsyncIterator(pagedResult);
try {
for (var _d = true, pages_1 = __asyncValues(pages), pages_1_1; pages_1_1 = yield __await(pages_1.next()), _a = pages_1_1.done, !_a; _d = true) {
_c = pages_1_1.value;
_d = false;
const page = _c;
yield __await(yield* __asyncDelegator(__asyncValues(page)));
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (!_d && !_a && (_b = pages_1.return)) yield __await(_b.call(pages_1));
}
finally { if (e_1) throw e_1.error; }
}
});
}
function getPageAsyncIterator(pagedResult_1) {
return __asyncGenerator(this, arguments, function* getPageAsyncIterator_1(pagedResult, options = {}) {
const { pageLink } = options;
let response = yield __await(pagedResult.getPage(pageLink !== null && pageLink !== void 0 ? pageLink : pagedResult.firstPageLink));
if (!response) {
return yield __await(void 0);
}
let result = response.page;
result.continuationToken = response.nextPageLink;
yield yield __await(result);
while (response.nextPageLink) {
response = yield __await(pagedResult.getPage(response.nextPageLink));
if (!response) {
return yield __await(void 0);
}
result = response.page;
result.continuationToken = response.nextPageLink;
yield yield __await(result);
}
});
}
/**
* Gets for the value of nextLink in the body
*/
function getNextLink(body, nextLinkName) {
if (!nextLinkName) {
return undefined;
}
const nextLink = body[nextLinkName];
if (typeof nextLink !== "string" &&
typeof nextLink !== "undefined" &&
nextLink !== null) {
throw new RestError(`Body Property ${nextLinkName} should be a string or undefined or null but got ${typeof nextLink}`);
}
if (nextLink === null) {
return undefined;
}
return nextLink;
}
/**
* Gets the elements of the current request in the body.
*/
function getElements(body, itemName) {
const value = body[itemName];
if (!Array.isArray(value)) {
throw new RestError(`Couldn't paginate response\n Body doesn't contain an array property with name: ${itemName}`);
}
return value !== null && value !== void 0 ? value : [];
}
/**
* Checks if a request failed
*/
function checkPagingRequest(response, expectedStatuses) {
if (!expectedStatuses.includes(response.status)) {
throw createRestError(`Pagination failed with unexpected statusCode ${response.status}`, response);
}
}
//# sourceMappingURL=pagingHelpers.js.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,5 @@
export interface UrlTemplateOptions {
allowReserved?: boolean;
}
export declare function expandUrlTemplate(template: string, context: Record<string, any>, option?: UrlTemplateOptions): string;
//# sourceMappingURL=urlTemplate.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"urlTemplate.d.ts","sourceRoot":"","sources":["../../../../src/generated/static-helpers/urlTemplate.ts"],"names":[],"mappings":"AAeA,MAAM,WAAW,kBAAkB;IAEjC,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAmJD,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC5B,MAAM,CAAC,EAAE,kBAAkB,GAC1B,MAAM,CA8BR"}

View File

@ -0,0 +1,172 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
// ---------------------
// helpers
// ---------------------
function encodeComponent(val, reserved, op) {
return (reserved !== null && reserved !== void 0 ? reserved : op === "+") || op === "#"
? encodeReservedComponent(val)
: encodeRFC3986URIComponent(val);
}
function encodeReservedComponent(str) {
return str
.split(/(%[0-9A-Fa-f]{2})/g)
.map((part) => (!/%[0-9A-Fa-f]/.test(part) ? encodeURI(part) : part))
.join("");
}
function encodeRFC3986URIComponent(str) {
return encodeURIComponent(str).replace(/[!'()*]/g, (c) => `%${c.charCodeAt(0).toString(16).toUpperCase()}`);
}
function isDefined(val) {
return val !== undefined && val !== null;
}
function getNamedAndIfEmpty(op) {
return [
!!op && [";", "?", "&"].includes(op),
!!op && ["?", "&"].includes(op) ? "=" : "",
];
}
function getFirstOrSep(op, isFirst = false) {
if (isFirst) {
return !op || op === "+" ? "" : op;
}
else if (!op || op === "+" || op === "#") {
return ",";
}
else if (op === "?") {
return "&";
}
else {
return op;
}
}
function getExpandedValue(option) {
let isFirst = option.isFirst;
const { op, varName, varValue: value, reserved } = option;
const vals = [];
const [named, ifEmpty] = getNamedAndIfEmpty(op);
if (Array.isArray(value)) {
for (const val of value.filter(isDefined)) {
// prepare the following parts: separator, varName, value
vals.push(`${getFirstOrSep(op, isFirst)}`);
if (named && varName) {
vals.push(`${encodeURIComponent(varName)}`);
val === "" ? vals.push(ifEmpty) : vals.push("=");
}
vals.push(encodeComponent(val, reserved, op));
isFirst = false;
}
}
else if (typeof value === "object") {
for (const key of Object.keys(value)) {
const val = value[key];
if (!isDefined(val)) {
continue;
}
// prepare the following parts: separator, key, value
vals.push(`${getFirstOrSep(op, isFirst)}`);
if (key) {
vals.push(`${encodeURIComponent(key)}`);
named && val === "" ? vals.push(ifEmpty) : vals.push("=");
}
vals.push(encodeComponent(val, reserved, op));
isFirst = false;
}
}
return vals.join("");
}
function getNonExpandedValue(option) {
const { op, varName, varValue: value, isFirst, reserved } = option;
const vals = [];
const first = getFirstOrSep(op, isFirst);
const [named, ifEmpty] = getNamedAndIfEmpty(op);
if (named && varName) {
vals.push(encodeComponent(varName, reserved, op));
if (value === "") {
if (!ifEmpty) {
vals.push(ifEmpty);
}
return !vals.join("") ? undefined : `${first}${vals.join("")}`;
}
vals.push("=");
}
const items = [];
if (Array.isArray(value)) {
for (const val of value.filter(isDefined)) {
items.push(encodeComponent(val, reserved, op));
}
}
else if (typeof value === "object") {
for (const key of Object.keys(value)) {
if (!isDefined(value[key])) {
continue;
}
items.push(encodeRFC3986URIComponent(key));
items.push(encodeComponent(value[key], reserved, op));
}
}
vals.push(items.join(","));
return !vals.join(",") ? undefined : `${first}${vals.join("")}`;
}
function getVarValue(option) {
const { op, varName, modifier, isFirst, reserved, varValue: value } = option;
if (!isDefined(value)) {
return undefined;
}
else if (["string", "number", "boolean"].includes(typeof value)) {
let val = value.toString();
const [named, ifEmpty] = getNamedAndIfEmpty(op);
const vals = [getFirstOrSep(op, isFirst)];
if (named && varName) {
// No need to encode varName considering it is already encoded
vals.push(varName);
val === "" ? vals.push(ifEmpty) : vals.push("=");
}
if (modifier && modifier !== "*") {
val = val.substring(0, parseInt(modifier, 10));
}
vals.push(encodeComponent(val, reserved, op));
return vals.join("");
}
else if (modifier === "*") {
return getExpandedValue(option);
}
else {
return getNonExpandedValue(option);
}
}
// ---------------------------------------------------------------------------------------------------
// This is an implementation of RFC 6570 URI Template: https://datatracker.ietf.org/doc/html/rfc6570.
// ---------------------------------------------------------------------------------------------------
export function expandUrlTemplate(template, context, option) {
return template.replace(/\{([^\{\}]+)\}|([^\{\}]+)/g, (_, expr, text) => {
if (!expr) {
return encodeReservedComponent(text);
}
let op;
if (["+", "#", ".", "/", ";", "?", "&"].includes(expr[0])) {
(op = expr[0]), (expr = expr.slice(1));
}
const varList = expr.split(/,/g);
const result = [];
for (const varSpec of varList) {
const varMatch = /([^:\*]*)(?::(\d+)|(\*))?/.exec(varSpec);
if (!varMatch || !varMatch[1]) {
continue;
}
const varValue = getVarValue({
isFirst: result.length === 0,
op,
varValue: context[varMatch[1]],
varName: varMatch[1],
modifier: varMatch[2] || varMatch[3],
reserved: option === null || option === void 0 ? void 0 : option.allowReserved,
});
if (varValue) {
result.push(varValue);
}
}
return result.join("");
});
}
//# sourceMappingURL=urlTemplate.js.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,42 @@
/**
* Represents the segments that compose a Key Vault Key Id.
*/
export interface KeyVaultKeyIdentifier {
/**
* The complete representation of the Key Vault Key Id. For example:
*
* https://<keyvault-name>.vault.azure.net/keys/<key-name>/<unique-version-id>
*
*/
sourceId: string;
/**
* The URL of the Azure Key Vault instance to which the Key belongs.
*/
vaultUrl: string;
/**
* The version of Key Vault Key. Might be undefined.
*/
version?: string;
/**
* The name of the Key Vault Key.
*/
name: string;
}
/**
* Parses the given Key Vault Key Id. An example is:
*
* https://<keyvault-name>.vault.azure.net/keys/<key-name>/<unique-version-id>
*
* On parsing the above Id, this function returns:
*```ts snippet:ignore
* {
* sourceId: "https://<keyvault-name>.vault.azure.net/keys/<key-name>/<unique-version-id>",
* vaultUrl: "https://<keyvault-name>.vault.azure.net",
* version: "<unique-version-id>",
* name: "<key-name>"
* }
*```
* @param id - The Id of the Key Vault Key.
*/
export declare function parseKeyVaultKeyIdentifier(id: string): KeyVaultKeyIdentifier;
//# sourceMappingURL=identifier.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"identifier.d.ts","sourceRoot":"","sources":["../../src/identifier.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC;;;;;OAKG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,0BAA0B,CAAC,EAAE,EAAE,MAAM,GAAG,qBAAqB,CAQ5E"}

View File

@ -0,0 +1,25 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { parseKeyVaultIdentifier } from "@azure/keyvault-common";
/**
* Parses the given Key Vault Key Id. An example is:
*
* https://<keyvault-name>.vault.azure.net/keys/<key-name>/<unique-version-id>
*
* On parsing the above Id, this function returns:
*```ts snippet:ignore
* {
* sourceId: "https://<keyvault-name>.vault.azure.net/keys/<key-name>/<unique-version-id>",
* vaultUrl: "https://<keyvault-name>.vault.azure.net",
* version: "<unique-version-id>",
* name: "<key-name>"
* }
*```
* @param id - The Id of the Key Vault Key.
*/
export function parseKeyVaultKeyIdentifier(id) {
const urlParts = id.split("/");
const collection = urlParts[3];
return Object.assign({ sourceId: id }, parseKeyVaultIdentifier(collection, id));
}
//# sourceMappingURL=identifier.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"identifier.js","sourceRoot":"","sources":["../../src/identifier.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AA8BjE;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,0BAA0B,CAAC,EAAU;IACnD,MAAM,QAAQ,GAAG,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC/B,MAAM,UAAU,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IAE/B,uBACE,QAAQ,EAAE,EAAE,IACT,uBAAuB,CAAC,UAAU,EAAE,EAAE,CAAC,EAC1C;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { parseKeyVaultIdentifier } from \"@azure/keyvault-common\";\n\n/**\n * Represents the segments that compose a Key Vault Key Id.\n */\nexport interface KeyVaultKeyIdentifier {\n /**\n * The complete representation of the Key Vault Key Id. For example:\n *\n * https://<keyvault-name>.vault.azure.net/keys/<key-name>/<unique-version-id>\n *\n */\n sourceId: string;\n\n /**\n * The URL of the Azure Key Vault instance to which the Key belongs.\n */\n vaultUrl: string;\n\n /**\n * The version of Key Vault Key. Might be undefined.\n */\n version?: string;\n\n /**\n * The name of the Key Vault Key.\n */\n name: string;\n}\n\n/**\n * Parses the given Key Vault Key Id. An example is:\n *\n * https://<keyvault-name>.vault.azure.net/keys/<key-name>/<unique-version-id>\n *\n * On parsing the above Id, this function returns:\n *```ts snippet:ignore\n * {\n * sourceId: \"https://<keyvault-name>.vault.azure.net/keys/<key-name>/<unique-version-id>\",\n * vaultUrl: \"https://<keyvault-name>.vault.azure.net\",\n * version: \"<unique-version-id>\",\n * name: \"<key-name>\"\n * }\n *```\n * @param id - The Id of the Key Vault Key.\n */\nexport function parseKeyVaultKeyIdentifier(id: string): KeyVaultKeyIdentifier {\n const urlParts = id.split(\"/\");\n const collection = urlParts[3];\n\n return {\n sourceId: id,\n ...parseKeyVaultIdentifier(collection, id),\n };\n}\n"]}

View File

@ -0,0 +1,766 @@
import type { TokenCredential } from "@azure/core-auth";
import { logger } from "./log.js";
import { PageSettings, PagedAsyncIterableIterator } from "@azure/core-paging";
import { PollOperationState, PollerLike } from "@azure/core-lro";
import { DeletionRecoveryLevel, KnownDeletionRecoveryLevel } from "./generated/models/index.js";
import { BackupKeyOptions, BeginDeleteKeyOptions, BeginRecoverDeletedKeyOptions, CreateEcKeyOptions, CreateKeyOptions, CreateOctKeyOptions, CreateRsaKeyOptions, CryptographyClientOptions, CryptographyOptions, DeletedKey, GetCryptographyClientOptions, GetDeletedKeyOptions, GetKeyAttestationOptions, GetKeyOptions, GetKeyRotationPolicyOptions, GetRandomBytesOptions, ImportKeyOptions, JsonWebKey, KeyAttestation, KeyClientOptions, KeyExportEncryptionAlgorithm, KeyOperation, KeyPollerOptions, KeyProperties, KeyReleasePolicy, KeyRotationLifetimeAction, KeyRotationPolicy, KeyRotationPolicyAction, KeyRotationPolicyProperties, KeyType, KeyVaultKey, KnownKeyOperations, ListDeletedKeysOptions, ListPropertiesOfKeyVersionsOptions, ListPropertiesOfKeysOptions, PurgeDeletedKeyOptions, ReleaseKeyOptions, ReleaseKeyResult, RestoreKeyBackupOptions, RotateKeyOptions, UpdateKeyPropertiesOptions, UpdateKeyRotationPolicyOptions } from "./keysModels.js";
import { CryptographyClient } from "./cryptographyClient.js";
import { AesCbcDecryptParameters, AesCbcEncryptParameters, AesCbcEncryptionAlgorithm, AesGcmDecryptParameters, AesGcmEncryptParameters, AesGcmEncryptionAlgorithm, DecryptOptions, DecryptParameters, DecryptResult, EncryptOptions, EncryptParameters, EncryptResult, EncryptionAlgorithm, KeyCurveName, KeyWrapAlgorithm, KnownKeyExportEncryptionAlgorithm, KnownEncryptionAlgorithms, KnownKeyTypes, KnownKeyCurveNames, KnownSignatureAlgorithms, RsaDecryptParameters, RsaEncryptParameters, RsaEncryptionAlgorithm, SignOptions, SignResult, SignatureAlgorithm, UnwrapKeyOptions, UnwrapResult, VerifyDataOptions, VerifyOptions, VerifyResult, WrapKeyOptions, WrapResult } from "./cryptographyClientModels.js";
import { KeyVaultKeyIdentifier, parseKeyVaultKeyIdentifier } from "./identifier.js";
export { CryptographyClientOptions, KeyClientOptions, BackupKeyOptions, CreateEcKeyOptions, CreateKeyOptions, CreateRsaKeyOptions, CreateOctKeyOptions, CryptographyClient, CryptographyOptions, RsaEncryptionAlgorithm, RsaDecryptParameters, AesGcmEncryptionAlgorithm, AesGcmDecryptParameters, AesCbcEncryptionAlgorithm, AesCbcDecryptParameters, DecryptParameters, DecryptOptions, DecryptResult, DeletedKey, DeletionRecoveryLevel, KnownDeletionRecoveryLevel, RsaEncryptParameters, AesGcmEncryptParameters, AesCbcEncryptParameters, EncryptParameters, EncryptOptions, EncryptResult, GetDeletedKeyOptions, GetKeyAttestationOptions, GetKeyOptions, GetRandomBytesOptions, ImportKeyOptions, JsonWebKey, KeyAttestation, KeyCurveName, KnownKeyCurveNames, KnownKeyExportEncryptionAlgorithm, EncryptionAlgorithm, KnownEncryptionAlgorithms, KeyOperation, KnownKeyOperations, KeyType, KnownKeyTypes, KeyPollerOptions, BeginDeleteKeyOptions, BeginRecoverDeletedKeyOptions, KeyProperties, SignatureAlgorithm, KnownSignatureAlgorithms, KeyVaultKey, KeyWrapAlgorithm, ListPropertiesOfKeysOptions, ListPropertiesOfKeyVersionsOptions, ListDeletedKeysOptions, PageSettings, PagedAsyncIterableIterator, KeyVaultKeyIdentifier, parseKeyVaultKeyIdentifier, PollOperationState, PollerLike, PurgeDeletedKeyOptions, RestoreKeyBackupOptions, RotateKeyOptions, SignOptions, SignResult, UnwrapKeyOptions, UnwrapResult, UpdateKeyPropertiesOptions, VerifyOptions, VerifyDataOptions, VerifyResult, WrapKeyOptions, WrapResult, ReleaseKeyOptions, ReleaseKeyResult, KeyReleasePolicy, KeyExportEncryptionAlgorithm, GetCryptographyClientOptions, KeyRotationPolicyAction, KeyRotationPolicyProperties, KeyRotationPolicy, KeyRotationLifetimeAction, UpdateKeyRotationPolicyOptions, GetKeyRotationPolicyOptions, logger, };
/**
* The KeyClient provides methods to manage {@link KeyVaultKey} in the
* Azure Key Vault. The client supports creating, retrieving, updating,
* deleting, purging, backing up, restoring and listing KeyVaultKeys. The
* client also supports listing {@link DeletedKey} for a soft-delete enabled Azure Key
* Vault.
*/
export declare class KeyClient {
/**
* The base URL to the vault
*/
readonly vaultUrl: string;
/**
* A reference to the auto-generated Key Vault HTTP client.
*/
private readonly client;
/**
* A reference to the credential that was used to construct this client.
* Later used to instantiate a {@link CryptographyClient} with the same credential.
*/
private readonly credential;
/**
* Creates an instance of KeyClient.
*
* Example usage:
* ```ts snippet:ReadmeSampleCreateClient
* import { DefaultAzureCredential } from "@azure/identity";
* import { KeyClient } from "@azure/keyvault-keys";
*
* const credential = new DefaultAzureCredential();
*
* // Build the URL to reach your key vault
* const vaultName = "<YOUR KEYVAULT NAME>";
* const url = `https://${vaultName}.vault.azure.net`; // or `https://${vaultName}.managedhsm.azure.net` for managed HSM.
*
* // Lastly, create our keys client and connect to the service
* const client = new KeyClient(url, credential);
* ```
* @param vaultUrl - the URL of the Key Vault. It should have this shape: `https://${your-key-vault-name}.vault.azure.net`. You should validate that this URL references a valid Key Vault or Managed HSM resource. See https://aka.ms/azsdk/blog/vault-uri for details.
* @param credential - An object that implements the `TokenCredential` interface used to authenticate requests to the service. Use the \@azure/identity package to create a credential that suits your needs.
* @param pipelineOptions - Pipeline options used to configure Key Vault API requests. Omit this parameter to use the default pipeline configuration.
*/
constructor(vaultUrl: string, credential: TokenCredential, pipelineOptions?: KeyClientOptions);
/**
* The create key operation can be used to create any key type in Azure Key Vault. If the named key
* already exists, Azure Key Vault creates a new version of the key. It requires the keys/create
* permission.
*
* Example usage:
* ```ts snippet:ReadmeSampleCreateKey
* import { DefaultAzureCredential } from "@azure/identity";
* import { KeyClient } from "@azure/keyvault-keys";
*
* const credential = new DefaultAzureCredential();
*
* const vaultName = "<YOUR KEYVAULT NAME>";
* const url = `https://${vaultName}.vault.azure.net`;
*
* const client = new KeyClient(url, credential);
*
* const keyName = "MyKeyName";
* const result = await client.createKey(keyName, "RSA");
* console.log("result: ", result);
* ```
* Creates a new key, stores it, then returns key parameters and properties to the client.
* @param name - The name of the key.
* @param keyType - The type of the key. One of the following: 'EC', 'EC-HSM', 'RSA', 'RSA-HSM', 'oct'.
* @param options - The optional parameters.
*/
createKey(name: string, keyType: KeyType, options?: CreateKeyOptions): Promise<KeyVaultKey>;
/**
* The createEcKey method creates a new elliptic curve key in Azure Key Vault. If the named key
* already exists, Azure Key Vault creates a new version of the key. It requires the keys/create
* permission.
*
* Example usage:
* ```ts snippet:ReadmeSampleCreateEcKey
* import { DefaultAzureCredential } from "@azure/identity";
* import { KeyClient } from "@azure/keyvault-keys";
*
* const credential = new DefaultAzureCredential();
*
* const vaultName = "<YOUR KEYVAULT NAME>";
* const url = `https://${vaultName}.vault.azure.net`;
*
* const client = new KeyClient(url, credential);
*
* const keyName = "MyKeyName";
* const result = await client.createEcKey(keyName, { curve: "P-256" });
* console.log("result: ", result);
* ```
* Creates a new key, stores it, then returns key parameters and properties to the client.
* @param name - The name of the key.
* @param options - The optional parameters.
*/
createEcKey(name: string, options?: CreateEcKeyOptions): Promise<KeyVaultKey>;
/**
* The createRSAKey method creates a new RSA key in Azure Key Vault. If the named key
* already exists, Azure Key Vault creates a new version of the key. It requires the keys/create
* permission.
*
* Example usage:
* ```ts snippet:ReadmeSampleCreateRsaKey
* import { DefaultAzureCredential } from "@azure/identity";
* import { KeyClient } from "@azure/keyvault-keys";
*
* const credential = new DefaultAzureCredential();
*
* const vaultName = "<YOUR KEYVAULT NAME>";
* const url = `https://${vaultName}.vault.azure.net`;
*
* const client = new KeyClient(url, credential);
*
* const keyName = "MyKeyName";
* const result = await client.createRsaKey("MyKey", { keySize: 2048 });
* console.log("result: ", result);
* ```
* Creates a new key, stores it, then returns key parameters and properties to the client.
* @param name - The name of the key.
* @param options - The optional parameters.
*/
createRsaKey(name: string, options?: CreateRsaKeyOptions): Promise<KeyVaultKey>;
/**
* The createOctKey method creates a new OCT key in Azure Key Vault. If the named key
* already exists, Azure Key Vault creates a new version of the key. It requires the keys/create
* permission.
*
* Example usage:
* ```ts snippet:ReadmeSampleCreateOctKey
* import { DefaultAzureCredential } from "@azure/identity";
* import { KeyClient } from "@azure/keyvault-keys";
*
* const credential = new DefaultAzureCredential();
*
* const vaultName = "<YOUR KEYVAULT NAME>";
* const url = `https://${vaultName}.vault.azure.net`;
*
* const client = new KeyClient(url, credential);
*
* const keyName = "MyKeyName";
* const result = await client.createOctKey("MyKey", { hsm: true });
* console.log("result: ", result);
* ```
* Creates a new key, stores it, then returns key parameters and properties to the client.
* @param name - The name of the key.
* @param options - The optional parameters.
*/
createOctKey(name: string, options?: CreateOctKeyOptions): Promise<KeyVaultKey>;
/**
* The import key operation may be used to import any key type into an Azure Key Vault. If the
* named key already exists, Azure Key Vault creates a new version of the key. This operation
* requires the keys/import permission.
*
* Example usage:
* ```ts snippet:ReadmeSampleImportKey
* import { DefaultAzureCredential } from "@azure/identity";
* import { KeyClient } from "@azure/keyvault-keys";
*
* const credential = new DefaultAzureCredential();
*
* const vaultName = "<YOUR KEYVAULT NAME>";
* const url = `https://${vaultName}.vault.azure.net`;
*
* const client = new KeyClient(url, credential);
*
* const jsonWebKey = {
* kty: "RSA",
* kid: "test-key-123",
* use: "sig",
* alg: "RS256",
* n: new Uint8Array([112, 34, 56, 98, 123, 244, 200, 99]),
* e: new Uint8Array([1, 0, 1]),
* d: new Uint8Array([45, 67, 89, 23, 144, 200, 76, 233]),
* p: new Uint8Array([34, 89, 100, 77, 204, 56, 29, 77]),
* q: new Uint8Array([78, 99, 201, 45, 188, 34, 67, 90]),
* dp: new Uint8Array([23, 45, 78, 56, 200, 144, 32, 67]),
* dq: new Uint8Array([12, 67, 89, 144, 99, 56, 23, 45]),
* qi: new Uint8Array([78, 90, 45, 201, 34, 67, 120, 55]),
* };
*
* const result = await client.importKey("MyKey", jsonWebKey);
* ```
* Imports an externally created key, stores it, and returns key parameters and properties
* to the client.
* @param name - Name for the imported key.
* @param key - The JSON web key.
* @param options - The optional parameters.
*/
importKey(name: string, key: JsonWebKey, options?: ImportKeyOptions): Promise<KeyVaultKey>;
/**
* Gets a {@link CryptographyClient} for the given key.
*
* Example usage:
* ```ts snippet:ReadmeSampleGetCryptographyClient
* import { DefaultAzureCredential } from "@azure/identity";
* import { KeyClient } from "@azure/keyvault-keys";
*
* const credential = new DefaultAzureCredential();
*
* const vaultName = "<YOUR KEYVAULT NAME>";
* const url = `https://${vaultName}.vault.azure.net`;
*
* const client = new KeyClient(url, credential);
*
* // Get a cryptography client for a given key
* const cryptographyClient = client.getCryptographyClient("MyKey");
* ```
* @param name - The name of the key used to perform cryptographic operations.
* @param version - Optional version of the key used to perform cryptographic operations.
* @returns - A {@link CryptographyClient} using the same options, credentials, and http client as this {@link KeyClient}
*/
getCryptographyClient(keyName: string, options?: GetCryptographyClientOptions): CryptographyClient;
/**
* The delete operation applies to any key stored in Azure Key Vault. Individual versions
* of a key can not be deleted, only all versions of a given key at once.
*
* This function returns a Long Running Operation poller that allows you to wait indefinitely until the key is deleted.
*
* This operation requires the keys/delete permission.
*
* Example usage:
* ```ts snippet:ReadmeSampleDeleteKey
* import { DefaultAzureCredential } from "@azure/identity";
* import { KeyClient } from "@azure/keyvault-keys";
*
* const credential = new DefaultAzureCredential();
*
* const vaultName = "<YOUR KEYVAULT NAME>";
* const url = `https://${vaultName}.vault.azure.net`;
*
* const client = new KeyClient(url, credential);
*
* const keyName = "MyKeyName";
*
* const poller = await client.beginDeleteKey(keyName);
* await poller.pollUntilDone();
* ```
* Deletes a key from a specified key vault.
* @param name - The name of the key.
* @param options - The optional parameters.
*/
beginDeleteKey(name: string, options?: BeginDeleteKeyOptions): Promise<PollerLike<PollOperationState<DeletedKey>, DeletedKey>>;
/**
* The updateKeyProperties method changes specified properties of an existing stored key. Properties that
* are not specified in the request are left unchanged. The value of a key itself cannot be
* changed. This operation requires the keys/set permission.
*
* Example usage:
* ```ts snippet:ReadmeSampleUpdateKeyProperties
* import { DefaultAzureCredential } from "@azure/identity";
* import { KeyClient } from "@azure/keyvault-keys";
*
* const credential = new DefaultAzureCredential();
*
* const vaultName = "<YOUR KEYVAULT NAME>";
* const url = `https://${vaultName}.vault.azure.net`;
*
* const client = new KeyClient(url, credential);
*
* const keyName = "MyKeyName";
*
* const result = await client.createKey(keyName, "RSA");
* await client.updateKeyProperties(keyName, result.properties.version, {
* enabled: false,
* });
* ```
* Updates the properties associated with a specified key in a given key vault.
* @param name - The name of the key.
* @param keyVersion - The version of the key.
* @param options - The optional parameters.
*/
updateKeyProperties(name: string, keyVersion: string, options?: UpdateKeyPropertiesOptions): Promise<KeyVaultKey>;
/**
* The updateKeyProperties method changes specified properties of the latest version of an existing stored key. Properties that
* are not specified in the request are left unchanged. The value of a key itself cannot be
* changed. This operation requires the keys/set permission.
*
* Example usage:
* ```ts snippet:ReadmeSampleUpdateKeyProperties
* import { DefaultAzureCredential } from "@azure/identity";
* import { KeyClient } from "@azure/keyvault-keys";
*
* const credential = new DefaultAzureCredential();
*
* const vaultName = "<YOUR KEYVAULT NAME>";
* const url = `https://${vaultName}.vault.azure.net`;
*
* const client = new KeyClient(url, credential);
*
* const keyName = "MyKeyName";
*
* const result = await client.createKey(keyName, "RSA");
* await client.updateKeyProperties(keyName, result.properties.version, {
* enabled: false,
* });
* ```
* Updates the properties associated with a specified key in a given key vault.
* @param name - The name of the key.
* @param keyVersion - The version of the key.
* @param options - The optional parameters.
*/
updateKeyProperties(name: string, options?: UpdateKeyPropertiesOptions): Promise<KeyVaultKey>;
/**
* Standardizes an overloaded arguments collection for the updateKeyProperties method.
*
* @param args - The arguments collection.
* @returns - The standardized arguments collection.
*/
private disambiguateUpdateKeyPropertiesArgs;
/**
* The getKey method gets a specified key and is applicable to any key stored in Azure Key Vault.
* This operation requires the keys/get permission.
*
* Example usage:
* ```ts snippet:ReadmeSampleGetKey
* import { DefaultAzureCredential } from "@azure/identity";
* import { KeyClient } from "@azure/keyvault-keys";
*
* const credential = new DefaultAzureCredential();
*
* const vaultName = "<YOUR KEYVAULT NAME>";
* const url = `https://${vaultName}.vault.azure.net`;
*
* const client = new KeyClient(url, credential);
*
* const keyName = "MyKeyName";
*
* const latestKey = await client.getKey(keyName);
* console.log(`Latest version of the key ${keyName}: `, latestKey);
*
* const specificKey = await client.getKey(keyName, { version: latestKey.properties.version! });
* console.log(`The key ${keyName} at the version ${latestKey.properties.version!}: `, specificKey);
* ```
* Get a specified key from a given key vault.
* @param name - The name of the key.
* @param options - The optional parameters.
*/
getKey(name: string, options?: GetKeyOptions): Promise<KeyVaultKey>;
/**
* The getKeyAttestation method gets a specified key and its attestation blob and is applicable to any key stored in Azure Key Vault Managed HSM.
* This operation requires the keys/get permission.
*
* Example usage:
* ```ts snippet:ReadmeSampleGetKeyAttestation
* import { DefaultAzureCredential } from "@azure/identity";
* import { KeyClient } from "@azure/keyvault-keys";
*
* const credential = new DefaultAzureCredential();
*
* const vaultName = "<YOUR KEYVAULT MANAGED HSM NAME>";
* const url = `https://${vaultName}.managedhsm.azure.net`;
*
* const client = new KeyClient(url, credential);
*
* const keyName = "MyKeyName";
*
* const latestKey = await client.getKeyAttestation(keyName);
* console.log(`Latest version of the key ${keyName}: `, latestKey);
*
* const specificKey = await client.getKeyAttestation(keyName, {
* version: latestKey.properties.version!,
* });
* console.log(`The key ${keyName} at the version ${latestKey.properties.version!}: `, specificKey);
* ```
* Get a specified key from a given key vault.
* @param name - The name of the key.
* @param options - The optional parameters.
*/
getKeyAttestation(name: string, options?: GetKeyAttestationOptions): Promise<KeyVaultKey>;
/**
* The getDeletedKey method returns the specified deleted key along with its properties.
* This operation requires the keys/get permission.
*
* Example usage:
* ```ts snippet:ReadmeSampleGetDeletedKey
* import { DefaultAzureCredential } from "@azure/identity";
* import { KeyClient } from "@azure/keyvault-keys";
*
* const credential = new DefaultAzureCredential();
*
* const vaultName = "<YOUR KEYVAULT NAME>";
* const url = `https://${vaultName}.vault.azure.net`;
*
* const client = new KeyClient(url, credential);
*
* const keyName = "MyKeyName";
*
* await client.getDeletedKey(keyName);
* ```
* Gets the specified deleted key.
* @param name - The name of the key.
* @param options - The optional parameters.
*/
getDeletedKey(name: string, options?: GetDeletedKeyOptions): Promise<DeletedKey>;
/**
* The purge deleted key operation removes the key permanently, without the possibility of
* recovery. This operation can only be enabled on a soft-delete enabled vault. This operation
* requires the keys/purge permission.
*
* Example usage:
* ```ts snippet:ReadmeSamplePurgeDeletedKey
* import { DefaultAzureCredential } from "@azure/identity";
* import { KeyClient } from "@azure/keyvault-keys";
*
* const credential = new DefaultAzureCredential();
*
* const vaultName = "<YOUR KEYVAULT NAME>";
* const url = `https://${vaultName}.vault.azure.net`;
*
* const client = new KeyClient(url, credential);
*
* const keyName = "MyKeyName";
*
* const deletePoller = await client.beginDeleteKey(keyName);
* await deletePoller.pollUntilDone();
*
* await client.purgeDeletedKey(keyName);
* ```
* Permanently deletes the specified key.
* @param name - The name of the key.
* @param options - The optional parameters.
*/
purgeDeletedKey(name: string, options?: PurgeDeletedKeyOptions): Promise<void>;
/**
* Recovers the deleted key in the specified vault. This operation can only be performed on a
* soft-delete enabled vault.
*
* This function returns a Long Running Operation poller that allows you to wait indefinitely until the deleted key is recovered.
*
* This operation requires the keys/recover permission.
*
* Example usage:
* ```ts snippet:ReadmeSampleRecoverDeletedKey
* import { DefaultAzureCredential } from "@azure/identity";
* import { KeyClient } from "@azure/keyvault-keys";
*
* const credential = new DefaultAzureCredential();
*
* const vaultName = "<YOUR KEYVAULT NAME>";
* const url = `https://${vaultName}.vault.azure.net`;
*
* const client = new KeyClient(url, credential);
*
* const keyName = "MyKeyName";
*
* const deletePoller = await client.beginDeleteKey(keyName);
* await deletePoller.pollUntilDone();
*
* const recoverPoller = await client.beginRecoverDeletedKey(keyName);
* const recoveredKey = await recoverPoller.pollUntilDone();
* ```
* Recovers the deleted key to the latest version.
* @param name - The name of the deleted key.
* @param options - The optional parameters.
*/
beginRecoverDeletedKey(name: string, options?: BeginRecoverDeletedKeyOptions): Promise<PollerLike<PollOperationState<DeletedKey>, DeletedKey>>;
/**
* Requests that a backup of the specified key be downloaded to the client. All versions of the
* key will be downloaded. This operation requires the keys/backup permission.
*
* Example usage:
* ```ts snippet:ReadmeSampleBackupKey
* import { DefaultAzureCredential } from "@azure/identity";
* import { KeyClient } from "@azure/keyvault-keys";
*
* const credential = new DefaultAzureCredential();
*
* const vaultName = "<YOUR KEYVAULT NAME>";
* const url = `https://${vaultName}.vault.azure.net`;
*
* const client = new KeyClient(url, credential);
*
* const keyName = "MyKeyName";
*
* const backupContents = await client.backupKey(keyName);
* ```
* Backs up the specified key.
* @param name - The name of the key.
* @param options - The optional parameters.
*/
backupKey(name: string, options?: BackupKeyOptions): Promise<Uint8Array | undefined>;
/**
* Restores a backed up key, and all its versions, to a vault. This operation requires the
* keys/restore permission.
*
* Example usage:
* ```ts snippet:ReadmeSampleRestoreKeyBackup
* import { DefaultAzureCredential } from "@azure/identity";
* import { KeyClient } from "@azure/keyvault-keys";
*
* const credential = new DefaultAzureCredential();
*
* const vaultName = "<YOUR KEYVAULT NAME>";
* const url = `https://${vaultName}.vault.azure.net`;
*
* const client = new KeyClient(url, credential);
*
* const keyName = "MyKeyName";
*
* const backupContents = await client.backupKey(keyName);
*
* const key = await client.restoreKeyBackup(backupContents);
* ```
* Restores a backed up key to a vault.
* @param backup - The backup blob associated with a key bundle.
* @param options - The optional parameters.
*/
restoreKeyBackup(backup: Uint8Array, options?: RestoreKeyBackupOptions): Promise<KeyVaultKey>;
/**
* Gets the requested number of bytes containing random values from a managed HSM.
* This operation requires the managedHsm/rng permission.
*
* Example usage:
* ```ts snippet:ReadmeSampleGetRandomBytes
* import { DefaultAzureCredential } from "@azure/identity";
* import { KeyClient } from "@azure/keyvault-keys";
*
* const credential = new DefaultAzureCredential();
*
* const vaultName = "<YOUR KEYVAULT NAME>";
* const url = `https://${vaultName}.vault.azure.net`;
*
* const client = new KeyClient(url, credential);
*
* const bytes = await client.getRandomBytes(10);
* ```
* @param count - The number of bytes to generate between 1 and 128 inclusive.
* @param options - The optional parameters.
*/
getRandomBytes(count: number, options?: GetRandomBytesOptions): Promise<Uint8Array>;
/**
* Rotates the key based on the key policy by generating a new version of the key. This operation requires the keys/rotate permission.
*
* Example usage:
* ```ts snippet:ReadmeSampleKeyRotation
* import { DefaultAzureCredential } from "@azure/identity";
* import { KeyClient } from "@azure/keyvault-keys";
*
* const credential = new DefaultAzureCredential();
*
* const vaultName = "<YOUR KEYVAULT NAME>";
* const url = `https://${vaultName}.vault.azure.net`;
*
* const client = new KeyClient(url, credential);
*
* const keyName = "MyKeyName";
*
* // Set the key's automated rotation policy to rotate the key 30 days before expiry.
* const policy = await client.updateKeyRotationPolicy(keyName, {
* lifetimeActions: [
* {
* action: "Rotate",
* timeBeforeExpiry: "P30D",
* },
* ],
* // You may also specify the duration after which any newly rotated key will expire.
* // In this case, any new key versions will expire after 90 days.
* expiresIn: "P90D",
* });
*
* // You can get the current key rotation policy of a given key by calling the getKeyRotationPolicy method.
* const currentPolicy = await client.getKeyRotationPolicy(keyName);
*
* // Finally, you can rotate a key on-demand by creating a new version of the given key.
* const rotatedKey = await client.rotateKey(keyName);
* ```
*
* @param name - The name of the key to rotate.
* @param options - The optional parameters.
*/
rotateKey(name: string, options?: RotateKeyOptions): Promise<KeyVaultKey>;
/**
* Releases a key from a managed HSM.
*
* The release key operation is applicable to all key types. The operation requires the key to be marked exportable and the keys/release permission.
*
* Example usage:
* ```ts snippet:ReadmeSampleReleaseKey
* import { DefaultAzureCredential } from "@azure/identity";
* import { KeyClient } from "@azure/keyvault-keys";
*
* const credential = new DefaultAzureCredential();
*
* const vaultName = "<YOUR KEYVAULT NAME>";
* const url = `https://${vaultName}.vault.azure.net`;
*
* const client = new KeyClient(url, credential);
*
* const keyName = "MyKeyName";
*
* const result = await client.releaseKey("myKey", "<attestation-target>");
* ```
*
* @param name - The name of the key.
* @param targetAttestationToken - The attestation assertion for the target of the key release.
* @param options - The optional parameters.
*/
releaseKey(name: string, targetAttestationToken: string, options?: ReleaseKeyOptions): Promise<ReleaseKeyResult>;
/**
* Gets the rotation policy of a Key Vault Key.
* By default, all keys have a policy that will notify 30 days before expiry.
*
* This operation requires the keys/get permission.
* Example usage:
* ```ts snippet:ReadmeSampleGetKeyRotationPolicy
* import { DefaultAzureCredential } from "@azure/identity";
* import { KeyClient } from "@azure/keyvault-keys";
*
* const credential = new DefaultAzureCredential();
*
* const vaultName = "<YOUR KEYVAULT NAME>";
* const url = `https://${vaultName}.vault.azure.net`;
*
* const client = new KeyClient(url, credential);
*
* const keyName = "MyKeyName";
*
* const result = await client.getKeyRotationPolicy(keyName);
* ```
*
* @param keyName - The name of the key.
* @param options - The optional parameters.
*/
getKeyRotationPolicy(keyName: string, options?: GetKeyRotationPolicyOptions): Promise<KeyRotationPolicy>;
/**
* Updates the rotation policy of a Key Vault Key.
* This operation requires the keys/update permission.
*
* Example usage:
* ```ts snippet:ReadmeSampleUpdateKeyRotationPolicy
* import { DefaultAzureCredential } from "@azure/identity";
* import { KeyClient } from "@azure/keyvault-keys";
*
* const credential = new DefaultAzureCredential();
*
* const vaultName = "<YOUR KEYVAULT NAME>";
* const url = `https://${vaultName}.vault.azure.net`;
*
* const client = new KeyClient(url, credential);
*
* const keyName = "MyKeyName";
*
* const myPolicy = await client.getKeyRotationPolicy(keyName);
*
* const setPolicy = await client.updateKeyRotationPolicy(keyName, myPolicy);
* ```
*
* @param keyName - The name of the key.
* @param policyProperties - The {@link KeyRotationPolicyProperties} for the policy.
* @param options - The optional parameters.
*/
updateKeyRotationPolicy(keyName: string, policy: KeyRotationPolicyProperties, options?: UpdateKeyRotationPolicyOptions): Promise<KeyRotationPolicy>;
/**
* Iterates all versions of the given key in the vault. The full key identifier, properties, and tags are provided
* in the response. This operation requires the keys/list permission.
*
* Example usage:
* ```ts snippet:ReadmeSampleListKeys
* import { DefaultAzureCredential } from "@azure/identity";
* import { KeyClient } from "@azure/keyvault-keys";
*
* const credential = new DefaultAzureCredential();
*
* const vaultName = "<YOUR KEYVAULT NAME>";
* const url = `https://${vaultName}.vault.azure.net`;
*
* const client = new KeyClient(url, credential);
*
* const keyName = "MyKeyName";
*
* for await (const keyProperties of client.listPropertiesOfKeys()) {
* console.log("Key properties: ", keyProperties);
* }
*
* for await (const deletedKey of client.listDeletedKeys()) {
* console.log("Deleted: ", deletedKey);
* }
*
* for await (const versionProperties of client.listPropertiesOfKeyVersions(keyName)) {
* console.log("Version properties: ", versionProperties);
* }
* ```
* @param name - Name of the key to fetch versions for
* @param options - The optional parameters.
*/
listPropertiesOfKeyVersions(name: string, options?: ListPropertiesOfKeyVersionsOptions): PagedAsyncIterableIterator<KeyProperties>;
/**
* Iterates the latest version of all keys in the vault. The full key identifier and properties are provided
* in the response. No values are returned for the keys. This operations requires the keys/list permission.
*
* Example usage:
* ```ts snippet:ReadmeSampleListKeys
* import { DefaultAzureCredential } from "@azure/identity";
* import { KeyClient } from "@azure/keyvault-keys";
*
* const credential = new DefaultAzureCredential();
*
* const vaultName = "<YOUR KEYVAULT NAME>";
* const url = `https://${vaultName}.vault.azure.net`;
*
* const client = new KeyClient(url, credential);
*
* const keyName = "MyKeyName";
*
* for await (const keyProperties of client.listPropertiesOfKeys()) {
* console.log("Key properties: ", keyProperties);
* }
*
* for await (const deletedKey of client.listDeletedKeys()) {
* console.log("Deleted: ", deletedKey);
* }
*
* for await (const versionProperties of client.listPropertiesOfKeyVersions(keyName)) {
* console.log("Version properties: ", versionProperties);
* }
* ```
* List all keys in the vault
* @param options - The optional parameters.
*/
listPropertiesOfKeys(options?: ListPropertiesOfKeysOptions): PagedAsyncIterableIterator<KeyProperties>;
/**
* Iterates the deleted keys in the vault. The full key identifier and properties are provided
* in the response. No values are returned for the keys. This operations requires the keys/list permission.
*
* Example usage:
* ```ts snippet:ReadmeSampleListKeys
* import { DefaultAzureCredential } from "@azure/identity";
* import { KeyClient } from "@azure/keyvault-keys";
*
* const credential = new DefaultAzureCredential();
*
* const vaultName = "<YOUR KEYVAULT NAME>";
* const url = `https://${vaultName}.vault.azure.net`;
*
* const client = new KeyClient(url, credential);
*
* const keyName = "MyKeyName";
*
* for await (const keyProperties of client.listPropertiesOfKeys()) {
* console.log("Key properties: ", keyProperties);
* }
*
* for await (const deletedKey of client.listDeletedKeys()) {
* console.log("Deleted: ", deletedKey);
* }
*
* for await (const versionProperties of client.listPropertiesOfKeyVersions(keyName)) {
* console.log("Version properties: ", versionProperties);
* }
* ```
* List all keys in the vault
* @param options - The optional parameters.
*/
listDeletedKeys(options?: ListDeletedKeysOptions): PagedAsyncIterableIterator<DeletedKey>;
}
//# sourceMappingURL=index.d.ts.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,905 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
/// <reference lib="esnext.asynciterable" />
import { __rest } from "tslib";
import { logger } from "./log.js";
import { KnownDeletionRecoveryLevel } from "./generated/models/index.js";
import { KeyVaultClient } from "./generated/keyVaultClient.js";
import { SDK_VERSION } from "./constants.js";
import { keyVaultAuthenticationPolicy } from "@azure/keyvault-common";
import { DeleteKeyPoller } from "./lro/delete/poller.js";
import { RecoverDeletedKeyPoller } from "./lro/recover/poller.js";
import { KnownKeyOperations, LATEST_API_VERSION, } from "./keysModels.js";
import { CryptographyClient } from "./cryptographyClient.js";
import { KnownKeyExportEncryptionAlgorithm, KnownEncryptionAlgorithms, KnownKeyTypes, KnownKeyCurveNames, KnownSignatureAlgorithms, } from "./cryptographyClientModels.js";
import { parseKeyVaultKeyIdentifier } from "./identifier.js";
import { getDeletedKeyFromDeletedKeyItem, getKeyFromKeyBundle, getKeyPropertiesFromKeyItem, keyRotationTransformations, mapPagedAsyncIterable, } from "./transformations.js";
import { tracingClient } from "./tracing.js";
import { bearerTokenAuthenticationPolicyName } from "@azure/core-rest-pipeline";
export { CryptographyClient, KnownDeletionRecoveryLevel, KnownKeyCurveNames, KnownKeyExportEncryptionAlgorithm, KnownEncryptionAlgorithms, KnownKeyOperations, KnownKeyTypes, KnownSignatureAlgorithms, parseKeyVaultKeyIdentifier, logger, };
/**
* The KeyClient provides methods to manage {@link KeyVaultKey} in the
* Azure Key Vault. The client supports creating, retrieving, updating,
* deleting, purging, backing up, restoring and listing KeyVaultKeys. The
* client also supports listing {@link DeletedKey} for a soft-delete enabled Azure Key
* Vault.
*/
export class KeyClient {
/**
* Creates an instance of KeyClient.
*
* Example usage:
* ```ts snippet:ReadmeSampleCreateClient
* import { DefaultAzureCredential } from "@azure/identity";
* import { KeyClient } from "@azure/keyvault-keys";
*
* const credential = new DefaultAzureCredential();
*
* // Build the URL to reach your key vault
* const vaultName = "<YOUR KEYVAULT NAME>";
* const url = `https://${vaultName}.vault.azure.net`; // or `https://${vaultName}.managedhsm.azure.net` for managed HSM.
*
* // Lastly, create our keys client and connect to the service
* const client = new KeyClient(url, credential);
* ```
* @param vaultUrl - the URL of the Key Vault. It should have this shape: `https://${your-key-vault-name}.vault.azure.net`. You should validate that this URL references a valid Key Vault or Managed HSM resource. See https://aka.ms/azsdk/blog/vault-uri for details.
* @param credential - An object that implements the `TokenCredential` interface used to authenticate requests to the service. Use the \@azure/identity package to create a credential that suits your needs.
* @param pipelineOptions - Pipeline options used to configure Key Vault API requests. Omit this parameter to use the default pipeline configuration.
*/
constructor(vaultUrl, credential, pipelineOptions = {}) {
this.vaultUrl = vaultUrl;
const libInfo = `azsdk-js-keyvault-keys/${SDK_VERSION}`;
const userAgentOptions = pipelineOptions.userAgentOptions;
pipelineOptions.userAgentOptions = {
userAgentPrefix: userAgentOptions && userAgentOptions.userAgentPrefix
? `${userAgentOptions.userAgentPrefix} ${libInfo}`
: libInfo,
};
const internalPipelineOptions = Object.assign(Object.assign({}, pipelineOptions), { apiVersion: pipelineOptions.serviceVersion || LATEST_API_VERSION, loggingOptions: {
logger: logger.info,
additionalAllowedHeaderNames: [
"x-ms-keyvault-region",
"x-ms-keyvault-network-info",
"x-ms-keyvault-service-version",
],
} });
this.credential = credential;
this.client = new KeyVaultClient(vaultUrl, credential, internalPipelineOptions);
this.client.pipeline.removePolicy({ name: bearerTokenAuthenticationPolicyName });
this.client.pipeline.addPolicy(keyVaultAuthenticationPolicy(credential, pipelineOptions));
// Workaround for: https://github.com/Azure/azure-sdk-for-js/issues/31843
this.client.pipeline.addPolicy({
name: "ContentTypePolicy",
sendRequest(request, next) {
var _a;
const contentType = (_a = request.headers.get("Content-Type")) !== null && _a !== void 0 ? _a : "";
if (contentType.startsWith("application/json")) {
request.headers.set("Content-Type", "application/json");
}
return next(request);
},
});
}
/**
* The create key operation can be used to create any key type in Azure Key Vault. If the named key
* already exists, Azure Key Vault creates a new version of the key. It requires the keys/create
* permission.
*
* Example usage:
* ```ts snippet:ReadmeSampleCreateKey
* import { DefaultAzureCredential } from "@azure/identity";
* import { KeyClient } from "@azure/keyvault-keys";
*
* const credential = new DefaultAzureCredential();
*
* const vaultName = "<YOUR KEYVAULT NAME>";
* const url = `https://${vaultName}.vault.azure.net`;
*
* const client = new KeyClient(url, credential);
*
* const keyName = "MyKeyName";
* const result = await client.createKey(keyName, "RSA");
* console.log("result: ", result);
* ```
* Creates a new key, stores it, then returns key parameters and properties to the client.
* @param name - The name of the key.
* @param keyType - The type of the key. One of the following: 'EC', 'EC-HSM', 'RSA', 'RSA-HSM', 'oct'.
* @param options - The optional parameters.
*/
createKey(name, keyType, options = {}) {
return tracingClient.withSpan("KeyClient.createKey", options, async (updatedOptions) => {
const response = await this.client.createKey(name, {
kty: keyType,
curve: options === null || options === void 0 ? void 0 : options.curve,
keyAttributes: {
enabled: options === null || options === void 0 ? void 0 : options.enabled,
notBefore: options === null || options === void 0 ? void 0 : options.notBefore,
expires: options === null || options === void 0 ? void 0 : options.expiresOn,
exportable: options === null || options === void 0 ? void 0 : options.exportable,
},
keyOps: options === null || options === void 0 ? void 0 : options.keyOps,
keySize: options === null || options === void 0 ? void 0 : options.keySize,
releasePolicy: options === null || options === void 0 ? void 0 : options.releasePolicy,
tags: options === null || options === void 0 ? void 0 : options.tags,
}, updatedOptions);
return getKeyFromKeyBundle(response);
});
}
/**
* The createEcKey method creates a new elliptic curve key in Azure Key Vault. If the named key
* already exists, Azure Key Vault creates a new version of the key. It requires the keys/create
* permission.
*
* Example usage:
* ```ts snippet:ReadmeSampleCreateEcKey
* import { DefaultAzureCredential } from "@azure/identity";
* import { KeyClient } from "@azure/keyvault-keys";
*
* const credential = new DefaultAzureCredential();
*
* const vaultName = "<YOUR KEYVAULT NAME>";
* const url = `https://${vaultName}.vault.azure.net`;
*
* const client = new KeyClient(url, credential);
*
* const keyName = "MyKeyName";
* const result = await client.createEcKey(keyName, { curve: "P-256" });
* console.log("result: ", result);
* ```
* Creates a new key, stores it, then returns key parameters and properties to the client.
* @param name - The name of the key.
* @param options - The optional parameters.
*/
async createEcKey(name, options) {
const keyType = (options === null || options === void 0 ? void 0 : options.hsm) ? KnownKeyTypes.ECHSM : KnownKeyTypes.EC;
return this.createKey(name, keyType, options);
}
/**
* The createRSAKey method creates a new RSA key in Azure Key Vault. If the named key
* already exists, Azure Key Vault creates a new version of the key. It requires the keys/create
* permission.
*
* Example usage:
* ```ts snippet:ReadmeSampleCreateRsaKey
* import { DefaultAzureCredential } from "@azure/identity";
* import { KeyClient } from "@azure/keyvault-keys";
*
* const credential = new DefaultAzureCredential();
*
* const vaultName = "<YOUR KEYVAULT NAME>";
* const url = `https://${vaultName}.vault.azure.net`;
*
* const client = new KeyClient(url, credential);
*
* const keyName = "MyKeyName";
* const result = await client.createRsaKey("MyKey", { keySize: 2048 });
* console.log("result: ", result);
* ```
* Creates a new key, stores it, then returns key parameters and properties to the client.
* @param name - The name of the key.
* @param options - The optional parameters.
*/
async createRsaKey(name, options) {
const keyType = (options === null || options === void 0 ? void 0 : options.hsm) ? KnownKeyTypes.RSAHSM : KnownKeyTypes.RSA;
return this.createKey(name, keyType, options);
}
/**
* The createOctKey method creates a new OCT key in Azure Key Vault. If the named key
* already exists, Azure Key Vault creates a new version of the key. It requires the keys/create
* permission.
*
* Example usage:
* ```ts snippet:ReadmeSampleCreateOctKey
* import { DefaultAzureCredential } from "@azure/identity";
* import { KeyClient } from "@azure/keyvault-keys";
*
* const credential = new DefaultAzureCredential();
*
* const vaultName = "<YOUR KEYVAULT NAME>";
* const url = `https://${vaultName}.vault.azure.net`;
*
* const client = new KeyClient(url, credential);
*
* const keyName = "MyKeyName";
* const result = await client.createOctKey("MyKey", { hsm: true });
* console.log("result: ", result);
* ```
* Creates a new key, stores it, then returns key parameters and properties to the client.
* @param name - The name of the key.
* @param options - The optional parameters.
*/
async createOctKey(name, options) {
const keyType = (options === null || options === void 0 ? void 0 : options.hsm) ? KnownKeyTypes.OctHSM : KnownKeyTypes.Oct;
return this.createKey(name, keyType, options);
}
/**
* The import key operation may be used to import any key type into an Azure Key Vault. If the
* named key already exists, Azure Key Vault creates a new version of the key. This operation
* requires the keys/import permission.
*
* Example usage:
* ```ts snippet:ReadmeSampleImportKey
* import { DefaultAzureCredential } from "@azure/identity";
* import { KeyClient } from "@azure/keyvault-keys";
*
* const credential = new DefaultAzureCredential();
*
* const vaultName = "<YOUR KEYVAULT NAME>";
* const url = `https://${vaultName}.vault.azure.net`;
*
* const client = new KeyClient(url, credential);
*
* const jsonWebKey = {
* kty: "RSA",
* kid: "test-key-123",
* use: "sig",
* alg: "RS256",
* n: new Uint8Array([112, 34, 56, 98, 123, 244, 200, 99]),
* e: new Uint8Array([1, 0, 1]),
* d: new Uint8Array([45, 67, 89, 23, 144, 200, 76, 233]),
* p: new Uint8Array([34, 89, 100, 77, 204, 56, 29, 77]),
* q: new Uint8Array([78, 99, 201, 45, 188, 34, 67, 90]),
* dp: new Uint8Array([23, 45, 78, 56, 200, 144, 32, 67]),
* dq: new Uint8Array([12, 67, 89, 144, 99, 56, 23, 45]),
* qi: new Uint8Array([78, 90, 45, 201, 34, 67, 120, 55]),
* };
*
* const result = await client.importKey("MyKey", jsonWebKey);
* ```
* Imports an externally created key, stores it, and returns key parameters and properties
* to the client.
* @param name - Name for the imported key.
* @param key - The JSON web key.
* @param options - The optional parameters.
*/
importKey(name, key, options = {}) {
return tracingClient.withSpan(`KeyClient.importKey`, options, async (updatedOptions) => {
const { enabled, notBefore, expiresOn: expires, exportable, releasePolicy, tags } = options;
const keyAttributes = {
enabled,
notBefore,
expires,
exportable,
};
const parameters = {
key,
hsm: options === null || options === void 0 ? void 0 : options.hardwareProtected,
keyAttributes,
releasePolicy,
tags,
};
const response = await this.client.importKey(name, parameters, updatedOptions);
return getKeyFromKeyBundle(response);
});
}
/**
* Gets a {@link CryptographyClient} for the given key.
*
* Example usage:
* ```ts snippet:ReadmeSampleGetCryptographyClient
* import { DefaultAzureCredential } from "@azure/identity";
* import { KeyClient } from "@azure/keyvault-keys";
*
* const credential = new DefaultAzureCredential();
*
* const vaultName = "<YOUR KEYVAULT NAME>";
* const url = `https://${vaultName}.vault.azure.net`;
*
* const client = new KeyClient(url, credential);
*
* // Get a cryptography client for a given key
* const cryptographyClient = client.getCryptographyClient("MyKey");
* ```
* @param name - The name of the key used to perform cryptographic operations.
* @param version - Optional version of the key used to perform cryptographic operations.
* @returns - A {@link CryptographyClient} using the same options, credentials, and http client as this {@link KeyClient}
*/
getCryptographyClient(keyName, options) {
const keyUrl = new URL(["keys", keyName, options === null || options === void 0 ? void 0 : options.keyVersion].filter(Boolean).join("/"), this.vaultUrl);
// The goals of this method are discoverability and performance (by sharing a client and pipeline).
// The existing cryptography client does not accept a pipeline as an argument, nor does it expose it.
// In order to avoid publicly exposing the pipeline we will pass in the underlying client as an undocumented
// property to the constructor so that crypto providers downstream can use it.
const constructorOptions = {
generatedClient: this.client,
};
const cryptoClient = new CryptographyClient(keyUrl.toString(), this.credential, constructorOptions);
return cryptoClient;
}
/**
* The delete operation applies to any key stored in Azure Key Vault. Individual versions
* of a key can not be deleted, only all versions of a given key at once.
*
* This function returns a Long Running Operation poller that allows you to wait indefinitely until the key is deleted.
*
* This operation requires the keys/delete permission.
*
* Example usage:
* ```ts snippet:ReadmeSampleDeleteKey
* import { DefaultAzureCredential } from "@azure/identity";
* import { KeyClient } from "@azure/keyvault-keys";
*
* const credential = new DefaultAzureCredential();
*
* const vaultName = "<YOUR KEYVAULT NAME>";
* const url = `https://${vaultName}.vault.azure.net`;
*
* const client = new KeyClient(url, credential);
*
* const keyName = "MyKeyName";
*
* const poller = await client.beginDeleteKey(keyName);
* await poller.pollUntilDone();
* ```
* Deletes a key from a specified key vault.
* @param name - The name of the key.
* @param options - The optional parameters.
*/
async beginDeleteKey(name, options = {}) {
const poller = new DeleteKeyPoller({
name,
client: this.client,
intervalInMs: options.intervalInMs,
resumeFrom: options.resumeFrom,
operationOptions: options,
});
// This will initialize the poller's operation (the deletion of the key).
await poller.poll();
return poller;
}
updateKeyProperties(...args) {
const [name, keyVersion, options] = this.disambiguateUpdateKeyPropertiesArgs(args);
return tracingClient.withSpan(`KeyClient.updateKeyProperties`, options, async (updatedOptions) => {
const response = await this.client.updateKey(name, keyVersion, {
keyAttributes: {
enabled: options === null || options === void 0 ? void 0 : options.enabled,
notBefore: options === null || options === void 0 ? void 0 : options.notBefore,
expires: options === null || options === void 0 ? void 0 : options.expiresOn,
},
keyOps: options === null || options === void 0 ? void 0 : options.keyOps,
releasePolicy: options === null || options === void 0 ? void 0 : options.releasePolicy,
tags: options === null || options === void 0 ? void 0 : options.tags,
}, updatedOptions);
return getKeyFromKeyBundle(response);
});
}
/**
* Standardizes an overloaded arguments collection for the updateKeyProperties method.
*
* @param args - The arguments collection.
* @returns - The standardized arguments collection.
*/
disambiguateUpdateKeyPropertiesArgs(args) {
if (typeof args[1] === "string") {
// [name, keyVersion, options?] => [name, keyVersion, options || {}]
return [args[0], args[1], args[2] || {}];
}
else {
// [name, options?] => [name , "", options || {}]
return [args[0], "", args[1] || {}];
}
}
/**
* The getKey method gets a specified key and is applicable to any key stored in Azure Key Vault.
* This operation requires the keys/get permission.
*
* Example usage:
* ```ts snippet:ReadmeSampleGetKey
* import { DefaultAzureCredential } from "@azure/identity";
* import { KeyClient } from "@azure/keyvault-keys";
*
* const credential = new DefaultAzureCredential();
*
* const vaultName = "<YOUR KEYVAULT NAME>";
* const url = `https://${vaultName}.vault.azure.net`;
*
* const client = new KeyClient(url, credential);
*
* const keyName = "MyKeyName";
*
* const latestKey = await client.getKey(keyName);
* console.log(`Latest version of the key ${keyName}: `, latestKey);
*
* const specificKey = await client.getKey(keyName, { version: latestKey.properties.version! });
* console.log(`The key ${keyName} at the version ${latestKey.properties.version!}: `, specificKey);
* ```
* Get a specified key from a given key vault.
* @param name - The name of the key.
* @param options - The optional parameters.
*/
getKey(name, options = {}) {
return tracingClient.withSpan(`KeyClient.getKey`, options, async (updatedOptions) => {
const response = await this.client.getKey(name, options.version || "", updatedOptions);
return getKeyFromKeyBundle(response);
});
}
/**
* The getKeyAttestation method gets a specified key and its attestation blob and is applicable to any key stored in Azure Key Vault Managed HSM.
* This operation requires the keys/get permission.
*
* Example usage:
* ```ts snippet:ReadmeSampleGetKeyAttestation
* import { DefaultAzureCredential } from "@azure/identity";
* import { KeyClient } from "@azure/keyvault-keys";
*
* const credential = new DefaultAzureCredential();
*
* const vaultName = "<YOUR KEYVAULT MANAGED HSM NAME>";
* const url = `https://${vaultName}.managedhsm.azure.net`;
*
* const client = new KeyClient(url, credential);
*
* const keyName = "MyKeyName";
*
* const latestKey = await client.getKeyAttestation(keyName);
* console.log(`Latest version of the key ${keyName}: `, latestKey);
*
* const specificKey = await client.getKeyAttestation(keyName, {
* version: latestKey.properties.version!,
* });
* console.log(`The key ${keyName} at the version ${latestKey.properties.version!}: `, specificKey);
* ```
* Get a specified key from a given key vault.
* @param name - The name of the key.
* @param options - The optional parameters.
*/
getKeyAttestation(name, options = {}) {
return tracingClient.withSpan(`KeyClient.getKeyAttestation`, options, async (updatedOptions) => {
var _a;
const response = await this.client.getKeyAttestation(name, (_a = updatedOptions.version) !== null && _a !== void 0 ? _a : "", updatedOptions);
return getKeyFromKeyBundle(response);
});
}
/**
* The getDeletedKey method returns the specified deleted key along with its properties.
* This operation requires the keys/get permission.
*
* Example usage:
* ```ts snippet:ReadmeSampleGetDeletedKey
* import { DefaultAzureCredential } from "@azure/identity";
* import { KeyClient } from "@azure/keyvault-keys";
*
* const credential = new DefaultAzureCredential();
*
* const vaultName = "<YOUR KEYVAULT NAME>";
* const url = `https://${vaultName}.vault.azure.net`;
*
* const client = new KeyClient(url, credential);
*
* const keyName = "MyKeyName";
*
* await client.getDeletedKey(keyName);
* ```
* Gets the specified deleted key.
* @param name - The name of the key.
* @param options - The optional parameters.
*/
getDeletedKey(name, options = {}) {
return tracingClient.withSpan(`KeyClient.getDeletedKey`, options, async (updatedOptions) => {
const response = await this.client.getDeletedKey(name, updatedOptions);
return getKeyFromKeyBundle(response);
});
}
/**
* The purge deleted key operation removes the key permanently, without the possibility of
* recovery. This operation can only be enabled on a soft-delete enabled vault. This operation
* requires the keys/purge permission.
*
* Example usage:
* ```ts snippet:ReadmeSamplePurgeDeletedKey
* import { DefaultAzureCredential } from "@azure/identity";
* import { KeyClient } from "@azure/keyvault-keys";
*
* const credential = new DefaultAzureCredential();
*
* const vaultName = "<YOUR KEYVAULT NAME>";
* const url = `https://${vaultName}.vault.azure.net`;
*
* const client = new KeyClient(url, credential);
*
* const keyName = "MyKeyName";
*
* const deletePoller = await client.beginDeleteKey(keyName);
* await deletePoller.pollUntilDone();
*
* await client.purgeDeletedKey(keyName);
* ```
* Permanently deletes the specified key.
* @param name - The name of the key.
* @param options - The optional parameters.
*/
purgeDeletedKey(name, options = {}) {
return tracingClient.withSpan(`KeyClient.purgeDeletedKey`, options, async (updatedOptions) => {
await this.client.purgeDeletedKey(name, updatedOptions);
});
}
/**
* Recovers the deleted key in the specified vault. This operation can only be performed on a
* soft-delete enabled vault.
*
* This function returns a Long Running Operation poller that allows you to wait indefinitely until the deleted key is recovered.
*
* This operation requires the keys/recover permission.
*
* Example usage:
* ```ts snippet:ReadmeSampleRecoverDeletedKey
* import { DefaultAzureCredential } from "@azure/identity";
* import { KeyClient } from "@azure/keyvault-keys";
*
* const credential = new DefaultAzureCredential();
*
* const vaultName = "<YOUR KEYVAULT NAME>";
* const url = `https://${vaultName}.vault.azure.net`;
*
* const client = new KeyClient(url, credential);
*
* const keyName = "MyKeyName";
*
* const deletePoller = await client.beginDeleteKey(keyName);
* await deletePoller.pollUntilDone();
*
* const recoverPoller = await client.beginRecoverDeletedKey(keyName);
* const recoveredKey = await recoverPoller.pollUntilDone();
* ```
* Recovers the deleted key to the latest version.
* @param name - The name of the deleted key.
* @param options - The optional parameters.
*/
async beginRecoverDeletedKey(name, options = {}) {
const poller = new RecoverDeletedKeyPoller({
name,
client: this.client,
intervalInMs: options.intervalInMs,
resumeFrom: options.resumeFrom,
operationOptions: options,
});
// This will initialize the poller's operation (the deletion of the key).
await poller.poll();
return poller;
}
/**
* Requests that a backup of the specified key be downloaded to the client. All versions of the
* key will be downloaded. This operation requires the keys/backup permission.
*
* Example usage:
* ```ts snippet:ReadmeSampleBackupKey
* import { DefaultAzureCredential } from "@azure/identity";
* import { KeyClient } from "@azure/keyvault-keys";
*
* const credential = new DefaultAzureCredential();
*
* const vaultName = "<YOUR KEYVAULT NAME>";
* const url = `https://${vaultName}.vault.azure.net`;
*
* const client = new KeyClient(url, credential);
*
* const keyName = "MyKeyName";
*
* const backupContents = await client.backupKey(keyName);
* ```
* Backs up the specified key.
* @param name - The name of the key.
* @param options - The optional parameters.
*/
backupKey(name, options = {}) {
return tracingClient.withSpan(`KeyClient.backupKey`, options, async (updatedOptions) => {
const response = await this.client.backupKey(name, updatedOptions);
return response.value;
});
}
/**
* Restores a backed up key, and all its versions, to a vault. This operation requires the
* keys/restore permission.
*
* Example usage:
* ```ts snippet:ReadmeSampleRestoreKeyBackup
* import { DefaultAzureCredential } from "@azure/identity";
* import { KeyClient } from "@azure/keyvault-keys";
*
* const credential = new DefaultAzureCredential();
*
* const vaultName = "<YOUR KEYVAULT NAME>";
* const url = `https://${vaultName}.vault.azure.net`;
*
* const client = new KeyClient(url, credential);
*
* const keyName = "MyKeyName";
*
* const backupContents = await client.backupKey(keyName);
*
* const key = await client.restoreKeyBackup(backupContents);
* ```
* Restores a backed up key to a vault.
* @param backup - The backup blob associated with a key bundle.
* @param options - The optional parameters.
*/
async restoreKeyBackup(backup, options = {}) {
return tracingClient.withSpan(`KeyClient.restoreKeyBackup`, options, async (updatedOptions) => {
const response = await this.client.restoreKey({ keyBundleBackup: backup }, updatedOptions);
return getKeyFromKeyBundle(response);
});
}
/**
* Gets the requested number of bytes containing random values from a managed HSM.
* This operation requires the managedHsm/rng permission.
*
* Example usage:
* ```ts snippet:ReadmeSampleGetRandomBytes
* import { DefaultAzureCredential } from "@azure/identity";
* import { KeyClient } from "@azure/keyvault-keys";
*
* const credential = new DefaultAzureCredential();
*
* const vaultName = "<YOUR KEYVAULT NAME>";
* const url = `https://${vaultName}.vault.azure.net`;
*
* const client = new KeyClient(url, credential);
*
* const bytes = await client.getRandomBytes(10);
* ```
* @param count - The number of bytes to generate between 1 and 128 inclusive.
* @param options - The optional parameters.
*/
getRandomBytes(count, options = {}) {
return tracingClient.withSpan("KeyClient.getRandomBytes", options, async (updatedOptions) => {
const response = await this.client.getRandomBytes({ count }, updatedOptions);
return response.value;
});
}
/**
* Rotates the key based on the key policy by generating a new version of the key. This operation requires the keys/rotate permission.
*
* Example usage:
* ```ts snippet:ReadmeSampleKeyRotation
* import { DefaultAzureCredential } from "@azure/identity";
* import { KeyClient } from "@azure/keyvault-keys";
*
* const credential = new DefaultAzureCredential();
*
* const vaultName = "<YOUR KEYVAULT NAME>";
* const url = `https://${vaultName}.vault.azure.net`;
*
* const client = new KeyClient(url, credential);
*
* const keyName = "MyKeyName";
*
* // Set the key's automated rotation policy to rotate the key 30 days before expiry.
* const policy = await client.updateKeyRotationPolicy(keyName, {
* lifetimeActions: [
* {
* action: "Rotate",
* timeBeforeExpiry: "P30D",
* },
* ],
* // You may also specify the duration after which any newly rotated key will expire.
* // In this case, any new key versions will expire after 90 days.
* expiresIn: "P90D",
* });
*
* // You can get the current key rotation policy of a given key by calling the getKeyRotationPolicy method.
* const currentPolicy = await client.getKeyRotationPolicy(keyName);
*
* // Finally, you can rotate a key on-demand by creating a new version of the given key.
* const rotatedKey = await client.rotateKey(keyName);
* ```
*
* @param name - The name of the key to rotate.
* @param options - The optional parameters.
*/
rotateKey(name, options = {}) {
return tracingClient.withSpan("KeyClient.rotateKey", options, async (updatedOptions) => {
const key = await this.client.rotateKey(name, updatedOptions);
return getKeyFromKeyBundle(key);
});
}
/**
* Releases a key from a managed HSM.
*
* The release key operation is applicable to all key types. The operation requires the key to be marked exportable and the keys/release permission.
*
* Example usage:
* ```ts snippet:ReadmeSampleReleaseKey
* import { DefaultAzureCredential } from "@azure/identity";
* import { KeyClient } from "@azure/keyvault-keys";
*
* const credential = new DefaultAzureCredential();
*
* const vaultName = "<YOUR KEYVAULT NAME>";
* const url = `https://${vaultName}.vault.azure.net`;
*
* const client = new KeyClient(url, credential);
*
* const keyName = "MyKeyName";
*
* const result = await client.releaseKey("myKey", "<attestation-target>");
* ```
*
* @param name - The name of the key.
* @param targetAttestationToken - The attestation assertion for the target of the key release.
* @param options - The optional parameters.
*/
releaseKey(name, targetAttestationToken, options = {}) {
return tracingClient.withSpan("KeyClient.releaseKey", options, async (updatedOptions) => {
const { nonce, algorithm } = updatedOptions, rest = __rest(updatedOptions, ["nonce", "algorithm"]);
const result = await this.client.release(name, (options === null || options === void 0 ? void 0 : options.version) || "", {
targetAttestationToken,
enc: algorithm,
nonce,
}, rest);
return { value: result.value };
});
}
/**
* Gets the rotation policy of a Key Vault Key.
* By default, all keys have a policy that will notify 30 days before expiry.
*
* This operation requires the keys/get permission.
* Example usage:
* ```ts snippet:ReadmeSampleGetKeyRotationPolicy
* import { DefaultAzureCredential } from "@azure/identity";
* import { KeyClient } from "@azure/keyvault-keys";
*
* const credential = new DefaultAzureCredential();
*
* const vaultName = "<YOUR KEYVAULT NAME>";
* const url = `https://${vaultName}.vault.azure.net`;
*
* const client = new KeyClient(url, credential);
*
* const keyName = "MyKeyName";
*
* const result = await client.getKeyRotationPolicy(keyName);
* ```
*
* @param keyName - The name of the key.
* @param options - The optional parameters.
*/
getKeyRotationPolicy(keyName, options = {}) {
return tracingClient.withSpan("KeyClient.getKeyRotationPolicy", options, async () => {
const policy = await this.client.getKeyRotationPolicy(keyName);
return keyRotationTransformations.generatedToPublic(policy);
});
}
/**
* Updates the rotation policy of a Key Vault Key.
* This operation requires the keys/update permission.
*
* Example usage:
* ```ts snippet:ReadmeSampleUpdateKeyRotationPolicy
* import { DefaultAzureCredential } from "@azure/identity";
* import { KeyClient } from "@azure/keyvault-keys";
*
* const credential = new DefaultAzureCredential();
*
* const vaultName = "<YOUR KEYVAULT NAME>";
* const url = `https://${vaultName}.vault.azure.net`;
*
* const client = new KeyClient(url, credential);
*
* const keyName = "MyKeyName";
*
* const myPolicy = await client.getKeyRotationPolicy(keyName);
*
* const setPolicy = await client.updateKeyRotationPolicy(keyName, myPolicy);
* ```
*
* @param keyName - The name of the key.
* @param policyProperties - The {@link KeyRotationPolicyProperties} for the policy.
* @param options - The optional parameters.
*/
updateKeyRotationPolicy(keyName, policy, options = {}) {
return tracingClient.withSpan("KeyClient.updateKeyRotationPolicy", options, async (updatedOptions) => {
const result = await this.client.updateKeyRotationPolicy(keyName, keyRotationTransformations.propertiesToGenerated(policy), updatedOptions);
return keyRotationTransformations.generatedToPublic(result);
});
}
/**
* Iterates all versions of the given key in the vault. The full key identifier, properties, and tags are provided
* in the response. This operation requires the keys/list permission.
*
* Example usage:
* ```ts snippet:ReadmeSampleListKeys
* import { DefaultAzureCredential } from "@azure/identity";
* import { KeyClient } from "@azure/keyvault-keys";
*
* const credential = new DefaultAzureCredential();
*
* const vaultName = "<YOUR KEYVAULT NAME>";
* const url = `https://${vaultName}.vault.azure.net`;
*
* const client = new KeyClient(url, credential);
*
* const keyName = "MyKeyName";
*
* for await (const keyProperties of client.listPropertiesOfKeys()) {
* console.log("Key properties: ", keyProperties);
* }
*
* for await (const deletedKey of client.listDeletedKeys()) {
* console.log("Deleted: ", deletedKey);
* }
*
* for await (const versionProperties of client.listPropertiesOfKeyVersions(keyName)) {
* console.log("Version properties: ", versionProperties);
* }
* ```
* @param name - Name of the key to fetch versions for
* @param options - The optional parameters.
*/
listPropertiesOfKeyVersions(name, options = {}) {
return mapPagedAsyncIterable(options, (mappedOptions) => this.client.getKeyVersions(name, mappedOptions), getKeyPropertiesFromKeyItem);
}
/**
* Iterates the latest version of all keys in the vault. The full key identifier and properties are provided
* in the response. No values are returned for the keys. This operations requires the keys/list permission.
*
* Example usage:
* ```ts snippet:ReadmeSampleListKeys
* import { DefaultAzureCredential } from "@azure/identity";
* import { KeyClient } from "@azure/keyvault-keys";
*
* const credential = new DefaultAzureCredential();
*
* const vaultName = "<YOUR KEYVAULT NAME>";
* const url = `https://${vaultName}.vault.azure.net`;
*
* const client = new KeyClient(url, credential);
*
* const keyName = "MyKeyName";
*
* for await (const keyProperties of client.listPropertiesOfKeys()) {
* console.log("Key properties: ", keyProperties);
* }
*
* for await (const deletedKey of client.listDeletedKeys()) {
* console.log("Deleted: ", deletedKey);
* }
*
* for await (const versionProperties of client.listPropertiesOfKeyVersions(keyName)) {
* console.log("Version properties: ", versionProperties);
* }
* ```
* List all keys in the vault
* @param options - The optional parameters.
*/
listPropertiesOfKeys(options = {}) {
return mapPagedAsyncIterable(options, this.client.getKeys.bind(this.client), getKeyPropertiesFromKeyItem);
}
/**
* Iterates the deleted keys in the vault. The full key identifier and properties are provided
* in the response. No values are returned for the keys. This operations requires the keys/list permission.
*
* Example usage:
* ```ts snippet:ReadmeSampleListKeys
* import { DefaultAzureCredential } from "@azure/identity";
* import { KeyClient } from "@azure/keyvault-keys";
*
* const credential = new DefaultAzureCredential();
*
* const vaultName = "<YOUR KEYVAULT NAME>";
* const url = `https://${vaultName}.vault.azure.net`;
*
* const client = new KeyClient(url, credential);
*
* const keyName = "MyKeyName";
*
* for await (const keyProperties of client.listPropertiesOfKeys()) {
* console.log("Key properties: ", keyProperties);
* }
*
* for await (const deletedKey of client.listDeletedKeys()) {
* console.log("Deleted: ", deletedKey);
* }
*
* for await (const versionProperties of client.listPropertiesOfKeyVersions(keyName)) {
* console.log("Version properties: ", versionProperties);
* }
* ```
* List all keys in the vault
* @param options - The optional parameters.
*/
listDeletedKeys(options = {}) {
return mapPagedAsyncIterable(options, this.client.getDeletedKeys.bind(this.client), getDeletedKeyFromDeletedKeyItem);
}
}
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,696 @@
import type * as coreClient from "@azure-rest/core-client";
import type { ExtendedCommonClientOptions } from "@azure/core-http-compat";
import type { DeletionRecoveryLevel } from "./generated/models/index.js";
import { JsonWebKeyOperation as KeyOperation, JsonWebKeyType as KeyType } from "./generated/models/index.js";
import type { KeyCurveName } from "./cryptographyClientModels.js";
export { KeyType, KeyOperation };
/**
* The latest supported Key Vault service API version
*/
export declare const LATEST_API_VERSION = "7.6";
/**
* The optional parameters accepted by the KeyVault's KeyClient
*/
export interface KeyClientOptions extends ExtendedCommonClientOptions {
/**
* The version of the KeyVault's service API to make calls against.
*/
serviceVersion?: string;
/**
* Whether to disable verification that the authentication challenge resource matches the Key Vault or Managed HSM domain.
* Defaults to false.
*/
disableChallengeResourceVerification?: boolean;
}
/**
* The optional parameters accepted by the KeyVault's CryptographyClient
*/
export interface CryptographyClientOptions extends KeyClientOptions {
}
/**
* As of http://tools.ietf.org/html/draft-ietf-jose-json-web-key-18
*/
export interface JsonWebKey {
/**
* Key identifier.
*/
kid?: string;
/**
* JsonWebKey Key Type (kty), as defined in
* https://tools.ietf.org/html/draft-ietf-jose-json-web-algorithms-40. Possible values include:
* 'EC', 'EC-HSM', 'RSA', 'RSA-HSM', 'oct', "oct-HSM"
*/
kty?: KeyType;
/**
* Json web key operations. For more
* information on possible key operations, see KeyOperation.
*/
keyOps?: KeyOperation[];
/**
* RSA modulus.
*/
n?: Uint8Array;
/**
* RSA public exponent.
*/
e?: Uint8Array;
/**
* RSA private exponent, or the D component of an EC private key.
*/
d?: Uint8Array;
/**
* RSA private key parameter.
*/
dp?: Uint8Array;
/**
* RSA private key parameter.
*/
dq?: Uint8Array;
/**
* RSA private key parameter.
*/
qi?: Uint8Array;
/**
* RSA secret prime.
*/
p?: Uint8Array;
/**
* RSA secret prime, with `p < q`.
*/
q?: Uint8Array;
/**
* Symmetric key.
*/
k?: Uint8Array;
/**
* HSM Token, used with 'Bring Your Own Key'.
*/
t?: Uint8Array;
/**
* Elliptic curve name. For valid values, see KeyCurveName. Possible values include:
* 'P-256', 'P-384', 'P-521', 'P-256K'
*/
crv?: KeyCurveName;
/**
* X component of an EC public key.
*/
x?: Uint8Array;
/**
* Y component of an EC public key.
*/
y?: Uint8Array;
}
/**
* An interface representing a Key Vault Key, with its name, value and {@link KeyProperties}.
*/
export interface KeyVaultKey {
/**
* The key value.
*/
key?: JsonWebKey;
/**
* The name of the key.
*/
name: string;
/**
* Key identifier.
*/
id?: string;
/**
* JsonWebKey Key Type (kty), as defined in
* https://tools.ietf.org/html/draft-ietf-jose-json-web-algorithms-40. Possible values include:
* 'EC', 'EC-HSM', 'RSA', 'RSA-HSM', 'oct', "oct-HSM"
*/
keyType?: KeyType;
/**
* Operations allowed on this key
*/
keyOperations?: KeyOperation[];
/**
* The properties of the key.
*/
properties: KeyProperties;
}
/**
* An interface representing the properties of a key's attestation
*/
export interface KeyAttestation {
/**
* The certificate used for attestation validation, in PEM format.
*/
certificatePemFile?: Uint8Array;
/**
* The key attestation corresponding to the private key material of the key.
*/
privateKeyAttestation?: Uint8Array;
/**
* The key attestation corresponding to the public key material of the key.
*/
publicKeyAttestation?: Uint8Array;
/**
* The version of the attestation.
*/
version?: string;
}
/**
* An interface representing the Properties of {@link KeyVaultKey}
*/
export interface KeyProperties {
/**
* Key identifier.
*/
id?: string;
/**
* The name of the key.
*/
name: string;
/**
* The vault URI.
*/
vaultUrl: string;
/**
* The version of the key. May be undefined.
*/
version?: string;
/**
* Determines whether the object is enabled.
*/
enabled?: boolean;
/**
* Not before date in UTC.
*/
notBefore?: Date;
/**
* Expiry date in UTC.
*/
expiresOn?: Date;
/**
* Application specific metadata in the form of key-value pairs.
*/
tags?: {
[propertyName: string]: string;
};
/**
* Creation time in UTC.
* **NOTE: This property will not be serialized. It can only be populated by
* the server.**
*/
readonly createdOn?: Date;
/**
* Last updated time in UTC.
* **NOTE: This property will not be serialized. It can only be populated by
* the server.**
*/
readonly updatedOn?: Date;
/**
* Reflects the deletion recovery level currently in effect for keys in the current vault.
* If it contains 'Purgeable' the key can be permanently deleted by a privileged
* user; otherwise, only the system can purge the key, at the end of the
* retention interval. Possible values include: 'Purgeable',
* 'Recoverable+Purgeable', 'Recoverable',
* 'Recoverable+ProtectedSubscription'
* **NOTE: This property will not be serialized. It can only be populated by
* the server.**
*/
readonly recoveryLevel?: DeletionRecoveryLevel;
/**
* The retention dates of the softDelete data.
* The value should be `>=7` and `<=90` when softDelete enabled.
* **NOTE: This property will not be serialized. It can only be populated by the server.**
*/
recoverableDays?: number;
/**
* True if the secret's lifetime is managed by
* key vault. If this is a secret backing a certificate, then managed will be
* true.
* **NOTE: This property will not be serialized. It can only be populated by
* the server.**
*/
readonly managed?: boolean;
/**
* Indicates whether the private key can be exported.
*/
exportable?: boolean;
/**
* A {@link KeyReleasePolicy} object specifying the rules under which the key can be exported.
*/
releasePolicy?: KeyReleasePolicy;
/**
* The underlying HSM Platform.
* NOTE: This property will not be serialized. It can only be populated by the server.
*/
readonly hsmPlatform?: string;
/**
* The key attestation, if available and requested.
*/
attestation?: KeyAttestation;
}
/**
* An interface representing a deleted Key Vault Key.
*/
export interface DeletedKey {
/**
* The key value.
*/
key?: JsonWebKey;
/**
* The name of the key.
*/
name: string;
/**
* Key identifier.
*/
id?: string;
/**
* JsonWebKey Key Type (kty), as defined in
* https://tools.ietf.org/html/draft-ietf-jose-json-web-algorithms-40. Possible values include:
* 'EC', 'EC-HSM', 'RSA', 'RSA-HSM', 'oct', "oct-HSM"
*/
keyType?: KeyType;
/**
* Operations allowed on this key
*/
keyOperations?: KeyOperation[];
/**
* The properties of the key.
*/
properties: KeyProperties & {
/**
* The url of the recovery object, used to
* identify and recover the deleted key.
*/
readonly recoveryId?: string;
/**
* The time when the key is scheduled to be purged, in UTC
* **NOTE: This property will not be serialized. It can only be populated by
* the server.**
*/
readonly scheduledPurgeDate?: Date;
/**
* The time when the key was deleted, in UTC
* **NOTE: This property will not be serialized. It can only be populated by
* the server.**
*/
deletedOn?: Date;
};
}
/**
* The policy rules under which a key can be exported.
*/
export interface KeyReleasePolicy {
/**
* Content type and version of key release policy.
*
* Defaults to "application/json; charset=utf-8" if omitted.
*/
contentType?: string;
/**
* The policy rules under which the key can be released. Encoded based on the {@link KeyReleasePolicy.contentType}.
*
* For more information regarding the release policy grammar for Azure Key Vault, please refer to:
* - https://aka.ms/policygrammarkeys for Azure Key Vault release policy grammar.
* - https://aka.ms/policygrammarmhsm for Azure Managed HSM release policy grammar.
*/
encodedPolicy?: Uint8Array;
/** Marks a release policy as immutable. An immutable release policy cannot be changed or updated after being marked immutable. */
immutable?: boolean;
}
/**
* An interface representing the optional parameters that can be
* passed to {@link createKey}
*/
export interface CreateKeyOptions extends coreClient.OperationOptions {
/**
* Application specific metadata in the form of key-value pairs.
*/
tags?: {
[propertyName: string]: string;
};
/**
* Json web key operations. For more
* information on possible key operations, see KeyOperation.
*/
keyOps?: KeyOperation[];
/**
* Determines whether the object is enabled.
*/
enabled?: boolean;
/**
* Not before date in UTC.
*/
notBefore?: Date;
/**
* Expiry date in UTC.
*/
readonly expiresOn?: Date;
/**
* The key size in bits. For example: 2048, 3072, or 4096 for RSA.
*/
keySize?: number;
/**
* Elliptic curve name. For valid values, see KeyCurveName.
* Possible values include: 'P-256', 'P-384', 'P-521', 'P-256K'
*/
curve?: KeyCurveName;
/**
* Whether to import as a hardware key (HSM) or software key.
*/
hsm?: boolean;
/**
* Indicates whether the private key can be exported.
*/
exportable?: boolean;
/**
* A {@link KeyReleasePolicy} object specifying the rules under which the key can be exported.
*/
releasePolicy?: KeyReleasePolicy;
}
/**
* An interface representing the optional parameters that can be
* passed to {@link beginDeleteKey} and {@link beginRecoverDeletedKey}
*/
export interface KeyPollerOptions extends coreClient.OperationOptions {
/**
* Time between each polling
*/
intervalInMs?: number;
/**
* A serialized poller, used to resume an existing operation
*/
resumeFrom?: string;
}
/**
* An interface representing the optional parameters that can be
* passed to {@link beginDeleteKey}
*/
export interface BeginDeleteKeyOptions extends KeyPollerOptions {
}
/**
* An interface representing the optional parameters that can be
* passed to {@link beginRecoverDeletedKey}
*/
export interface BeginRecoverDeletedKeyOptions extends KeyPollerOptions {
}
/**
* An interface representing the optional parameters that can be
* passed to {@link createEcKey}
*/
export interface CreateEcKeyOptions extends CreateKeyOptions {
}
/**
* An interface representing the optional parameters that can be
* passed to {@link createRsaKey}
*/
export interface CreateRsaKeyOptions extends CreateKeyOptions {
/** The public exponent for a RSA key. */
publicExponent?: number;
}
/**
* An interface representing the optional parameters that can be
* passed to {@link createOctKey}
*/
export interface CreateOctKeyOptions extends CreateKeyOptions {
}
/**
* An interface representing the optional parameters that can be
* passed to {@link importKey}
*/
export interface ImportKeyOptions extends coreClient.OperationOptions {
/**
* Application specific metadata in the form of key-value pairs.
*/
tags?: {
[propertyName: string]: string;
};
/**
* Whether to import as a hardware key (HSM) or software key.
*/
hardwareProtected?: boolean;
/**
* Determines whether the object is enabled.
*/
enabled?: boolean;
/**
* Not before date in UTC.
*/
notBefore?: Date;
/**
* Expiry date in UTC.
*/
expiresOn?: Date;
/**
* Indicates whether the private key can be exported.
*/
exportable?: boolean;
/**
* A {@link KeyReleasePolicy} object specifying the rules under which the key can be exported.
*/
releasePolicy?: KeyReleasePolicy;
}
/**
* Options for {@link updateKeyProperties}.
*/
export interface UpdateKeyPropertiesOptions extends coreClient.OperationOptions {
/**
* Json web key operations. For more
* information on possible key operations, see KeyOperation.
*/
keyOps?: KeyOperation[];
/**
* Determines whether the object is enabled.
*/
enabled?: boolean;
/**
* Not before date in UTC.
*/
notBefore?: Date;
/**
* Expiry date in UTC.
*/
expiresOn?: Date;
/**
* Application specific metadata in the form of key-value pairs.
*/
tags?: {
[propertyName: string]: string;
};
/**
* A {@link KeyReleasePolicy} object specifying the rules under which the key can be exported.
* Only valid if the key is marked exportable, which cannot be changed after key creation.
*/
releasePolicy?: KeyReleasePolicy;
}
/**
* Options for {@link getKey}.
*/
export interface GetKeyOptions extends coreClient.OperationOptions {
/**
* The version of the secret to retrieve. If not
* specified the latest version of the secret will be retrieved.
*/
version?: string;
}
/**
* Options for {@link getKeyAttestation}.
*/
export interface GetKeyAttestationOptions extends coreClient.OperationOptions {
/**
* The version of the key to retrieve the attestation for. If not
* specified the latest version of the key will be retrieved.
*/
version?: string;
}
/**
* An interface representing optional parameters for KeyClient paged operations passed to {@link listKeys}.
*/
export interface ListKeysOptions extends coreClient.OperationOptions {
}
/**
* An interface representing optional parameters for KeyClient paged operations passed to {@link listPropertiesOfKeys}.
*/
export interface ListPropertiesOfKeysOptions extends coreClient.OperationOptions {
}
/**
* An interface representing optional parameters for KeyClient paged operations passed to {@link listPropertiesOfKeyVersions}.
*/
export interface ListPropertiesOfKeyVersionsOptions extends coreClient.OperationOptions {
}
/**
* An interface representing optional parameters for KeyClient paged operations passed to {@link listDeletedKeys}.
*/
export interface ListDeletedKeysOptions extends coreClient.OperationOptions {
}
/**
* Options for {@link getDeletedKey}.
*/
export interface GetDeletedKeyOptions extends coreClient.OperationOptions {
}
/**
* Options for {@link purgeDeletedKey}.
*/
export interface PurgeDeletedKeyOptions extends coreClient.OperationOptions {
}
/**
* @internal
* Options for {@link recoverDeletedKey}.
*/
export interface RecoverDeletedKeyOptions extends coreClient.OperationOptions {
}
/**
* @internal
* Options for {@link deleteKey}.
*/
export interface DeleteKeyOptions extends coreClient.OperationOptions {
}
/**
* Options for {@link backupKey}.
*/
export interface BackupKeyOptions extends coreClient.OperationOptions {
}
/**
* Options for {@link restoreKeyBackup}.
*/
export interface RestoreKeyBackupOptions extends coreClient.OperationOptions {
}
/**
* An interface representing the options of the cryptography API methods, go to the {@link CryptographyClient} for more information.
*/
export interface CryptographyOptions extends coreClient.OperationOptions {
}
/**
* Options for {@link KeyClient.getRandomBytes}
*/
export interface GetRandomBytesOptions extends coreClient.OperationOptions {
}
/**
* Options for {@link KeyClient.releaseKey}
*/
export interface ReleaseKeyOptions extends coreClient.OperationOptions {
/** A client provided nonce for freshness. */
nonce?: string;
/** The {@link KeyExportEncryptionAlgorithm} to for protecting the exported key material. */
algorithm?: KeyExportEncryptionAlgorithm;
/**
* The version of the key to release. Defaults to the latest version of the key if omitted.
*/
version?: string;
}
/**
* Result of the {@link KeyClient.releaseKey} operation.
*/
export interface ReleaseKeyResult {
/** A signed token containing the released key. */
value: string;
}
/** Known values of {@link KeyOperation} that the service accepts. */
export declare enum KnownKeyOperations {
/** Key operation - encrypt */
Encrypt = "encrypt",
/** Key operation - decrypt */
Decrypt = "decrypt",
/** Key operation - sign */
Sign = "sign",
/** Key operation - verify */
Verify = "verify",
/** Key operation - wrapKey */
WrapKey = "wrapKey",
/** Key operation - unwrapKey */
UnwrapKey = "unwrapKey",
/** Key operation - import */
Import = "import"
}
/**
* Defines values for KeyEncryptionAlgorithm.
* {@link KnownKeyExportEncryptionAlgorithm} can be used interchangeably with KeyEncryptionAlgorithm,
* this enum contains the known values that the service supports.
* ### Known values supported by the service
* **CKM_RSA_AES_KEY_WRAP** \
* **RSA_AES_KEY_WRAP_256** \
* **RSA_AES_KEY_WRAP_384**
*/
export type KeyExportEncryptionAlgorithm = string;
/**
* Options for {@link KeyClient.getCryptographyClient}.
*/
export interface GetCryptographyClientOptions {
/**
* The version of the key to use for cryptographic operations.
*
* When undefined, the latest version of the key will be used.
*/
keyVersion?: string;
}
/**
* Options for {@link KeyClient.rotateKey}
*/
export interface RotateKeyOptions extends coreClient.OperationOptions {
}
/**
* The properties of a key rotation policy that the client can set for a given key.
*
* You may also reset the key rotation policy to its default values by setting lifetimeActions to an empty array.
*/
export interface KeyRotationPolicyProperties {
/**
* Optional key expiration period used to define the duration after which a newly rotated key will expire, defined as an ISO 8601 duration.
*/
expiresIn?: string;
/**
* Actions that will be performed by Key Vault over the lifetime of a key.
*
* You may also pass an empty array to restore to its default values.
*/
lifetimeActions?: KeyRotationLifetimeAction[];
}
/**
* The complete key rotation policy that belongs to a key.
*/
export interface KeyRotationPolicy extends KeyRotationPolicyProperties {
/**
* The identifier of the Key Rotation Policy.
* May be undefined if a policy has not been explicitly set.
*/
readonly id?: string;
/**
* The created time in UTC.
* May be undefined if a policy has not been explicitly set.
*/
readonly createdOn?: Date;
/**
* The last updated time in UTC.
* May be undefined if a policy has not been explicitly set.
*/
readonly updatedOn?: Date;
}
/**
* An action and its corresponding trigger that will be performed by Key Vault over the lifetime of a key.
*/
export interface KeyRotationLifetimeAction {
/**
* Time after creation to attempt the specified action, defined as an ISO 8601 duration.
*/
timeAfterCreate?: string;
/**
* Time before expiry to attempt the specified action, defined as an ISO 8601 duration.
*/
timeBeforeExpiry?: string;
/**
* The action that will be executed.
*/
action: KeyRotationPolicyAction;
}
/**
* The action that will be executed.
*/
export type KeyRotationPolicyAction = "Rotate" | "Notify";
/**
* Options for {@link KeyClient.updateKeyRotationPolicy}
*/
export interface UpdateKeyRotationPolicyOptions extends coreClient.OperationOptions {
}
/**
* Options for {@link KeyClient.getRotationPolicy}
*/
export interface GetKeyRotationPolicyOptions extends coreClient.OperationOptions {
}
//# sourceMappingURL=keysModels.d.ts.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,25 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
/**
* The latest supported Key Vault service API version
*/
export const LATEST_API_VERSION = "7.6";
/** Known values of {@link KeyOperation} that the service accepts. */
export var KnownKeyOperations;
(function (KnownKeyOperations) {
/** Key operation - encrypt */
KnownKeyOperations["Encrypt"] = "encrypt";
/** Key operation - decrypt */
KnownKeyOperations["Decrypt"] = "decrypt";
/** Key operation - sign */
KnownKeyOperations["Sign"] = "sign";
/** Key operation - verify */
KnownKeyOperations["Verify"] = "verify";
/** Key operation - wrapKey */
KnownKeyOperations["WrapKey"] = "wrapKey";
/** Key operation - unwrapKey */
KnownKeyOperations["UnwrapKey"] = "unwrapKey";
/** Key operation - import */
KnownKeyOperations["Import"] = "import";
})(KnownKeyOperations || (KnownKeyOperations = {}));
//# sourceMappingURL=keysModels.js.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,5 @@
/**
* The \@azure/logger configuration for this package.
*/
export declare const logger: import("@azure/logger").AzureLogger;
//# sourceMappingURL=log.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../src/log.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,eAAO,MAAM,MAAM,qCAAsC,CAAC"}

View File

@ -0,0 +1,8 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { createClientLogger } from "@azure/logger";
/**
* The \@azure/logger configuration for this package.
*/
export const logger = createClientLogger("keyvault-keys");
//# sourceMappingURL=log.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"log.js","sourceRoot":"","sources":["../../src/log.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEnD;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,kBAAkB,CAAC,eAAe,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { createClientLogger } from \"@azure/logger\";\n\n/**\n * The \\@azure/logger configuration for this package.\n */\nexport const logger = createClientLogger(\"keyvault-keys\");\n"]}

View File

@ -0,0 +1,35 @@
import type { AbortSignalLike } from "@azure/abort-controller";
import type { OperationOptions } from "@azure-rest/core-client";
import type { KeyVaultClient } from "../../generated/keyVaultClient.js";
import type { DeletedKey } from "../../keysModels.js";
import type { KeyVaultKeyPollOperationState } from "../keyVaultKeyPoller.js";
import { KeyVaultKeyPollOperation } from "../keyVaultKeyPoller.js";
/**
* An interface representing the state of a delete key's poll operation
*/
export interface DeleteKeyPollOperationState extends KeyVaultKeyPollOperationState<DeletedKey> {
}
export declare class DeleteKeyPollOperation extends KeyVaultKeyPollOperation<DeleteKeyPollOperationState, DeletedKey> {
state: DeleteKeyPollOperationState;
private client;
private operationOptions;
constructor(state: DeleteKeyPollOperationState, client: KeyVaultClient, operationOptions?: OperationOptions);
/**
* Sends a delete request for the given Key Vault Key's name to the Key Vault service.
* Since the Key Vault Key won't be immediately deleted, we have {@link beginDeleteKey}.
*/
private deleteKey;
/**
* The getDeletedKey method returns the specified deleted key along with its properties.
* This operation requires the keys/get permission.
*/
private getDeletedKey;
/**
* Reaches to the service and updates the delete key's poll operation.
*/
update(options?: {
abortSignal?: AbortSignalLike;
fireProgress?: (state: DeleteKeyPollOperationState) => void;
}): Promise<DeleteKeyPollOperation>;
}
//# sourceMappingURL=operation.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"operation.d.ts","sourceRoot":"","sources":["../../../../src/lro/delete/operation.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,KAAK,EAAoB,UAAU,EAAwB,MAAM,qBAAqB,CAAC;AAG9F,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,yBAAyB,CAAC;AAC7E,OAAO,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AAEnE;;GAEG;AACH,MAAM,WAAW,2BAA4B,SAAQ,6BAA6B,CAAC,UAAU,CAAC;CAAG;AAEjG,qBAAa,sBAAuB,SAAQ,wBAAwB,CAClE,2BAA2B,EAC3B,UAAU,CACX;IAEU,KAAK,EAAE,2BAA2B;IACzC,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,gBAAgB;gBAFjB,KAAK,EAAE,2BAA2B,EACjC,MAAM,EAAE,cAAc,EACtB,gBAAgB,GAAE,gBAAqB;IAKjD;;;OAGG;IACH,OAAO,CAAC,SAAS;IAOjB;;;OAGG;IACH,OAAO,CAAC,aAAa;IAWrB;;OAEG;IACU,MAAM,CACjB,OAAO,GAAE;QACP,WAAW,CAAC,EAAE,eAAe,CAAC;QAC9B,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,2BAA2B,KAAK,IAAI,CAAC;KACxD,GACL,OAAO,CAAC,sBAAsB,CAAC;CAmCnC"}

Some files were not shown because too many files have changed in this diff Show More