@eqxjs/azure-manage-identity
Version:
For get Azure keyvault secret
28 lines • 1.32 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.removeSecret = removeSecret;
const keyvault_secrets_1 = require("@azure/keyvault-secrets");
const confidential_mgnt_1 = require("../confidential.mgnt");
/**
* Removes a secret from Azure Key Vault and waits until the deletion is complete.
*
* @param keyvaultURL - The URL of the Azure Key Vault instance
* @param secretName - The name of the secret to remove
* @param secretOpt - Optional parameters for the delete operation
* @param clientOptions - Optional configuration for the {@link SecretClient}
* @returns A promise that resolves to the {@link DeletedSecret} object
* @throws {Error} When the secret cannot be deleted
*/
async function removeSecret(keyvaultURL, secretName, secretOpt, clientOptions) {
const tokenCredential = new confidential_mgnt_1.MyClientAssertionCredential();
// create a secret client with the token credential
const keyvault = new keyvault_secrets_1.SecretClient(keyvaultURL, tokenCredential, clientOptions);
const poller = await keyvault
.beginDeleteSecret(secretName, secretOpt)
.catch((error) => {
throw new Error(error);
});
const deletedSecret = await poller.pollUntilDone();
return deletedSecret;
}
//# sourceMappingURL=secret.remove.js.map