@ai-digital-factory/sms
v0.1.3
Published
Provider-neutral secret management for applications.
Readme
@ai-digital-factory/sms
Provider-neutral secret management for applications.
Install
npm install @ai-digital-factory/smsConfigure
import { createSecretManager } from "@ai-digital-factory/sms";
const secrets = createSecretManager({
endpoint: process.env.SMS_ENDPOINT!,
credential: process.env.SMS_CREDENTIAL!,
scope: process.env.SMS_SCOPE!,
});endpoint, credential, and scope are required. timeoutMs is optional.
Use
await secrets.save("database-password", "secret-value");
const password = await secrets.read("database-password");
await secrets.remove("database-password");
const scopes = await secrets.listScopes();
const secretNames = await secrets.listSecretNames();
const databasePassword = await secrets.read(
"database-password",
scopes[0],
);read throws SecretNotFoundError when the secret does not exist. Invalid names, values, or configuration throw InvalidSecretError.
listScopes() discovers descendant secret scopes beneath the configured scope.
listSecretNames(scope?) returns names in the configured scope or a discovered
descendant scope. read(secretName, scope?) accepts the configured scope by
default or a descendant scope. Discovery returns names and scopes only; Vault
credentials need list permission within the configured scope subtree.
CommonJS is also supported:
const { createSecretManager } = require("@ai-digital-factory/sms");