UNPKG

@eqxjs/azure-manage-identity

Version:

For get Azure keyvault secret

28 lines 1.29 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.setSecret = setSecret; const keyvault_secrets_1 = require("@azure/keyvault-secrets"); const confidential_mgnt_1 = require("../confidential.mgnt"); /** * Creates or updates a secret in Azure Key Vault. * * @param keyvaultURL - The URL of the Azure Key Vault instance * @param secretName - The name of the secret to set * @param secretValue - The value to store in the secret * @param secretOpt - Optional parameters for the set-secret operation * @param clientOptions - Optional configuration for the {@link SecretClient} * @returns A promise that resolves to the {@link KeyVaultSecret} object * @throws {Error} When the secret cannot be set */ async function setSecret(keyvaultURL, secretName, secretValue, 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 secret = await keyvault .setSecret(secretName, secretValue, secretOpt) .catch((error) => { throw new Error(error); }); return secret; } //# sourceMappingURL=secret.set.js.map