Vault

View as Markdown

The vault stores secrets that your runtimes use to authenticate into websites and services. Each entry holds a username, password, optional TOTP seed, and origin matching rules.

Access via bctrl.vault.

get(key)

Retrieve a credential from the vault.

1const cred = await bctrl.vault.get("prod/crm/salesforce");
2if (cred) {
3 console.log(cred.username);
4}
ParameterTypeRequiredDescription
keystringYesVault key path

Returns VaultCredential | null — null if not found.

The returned credential contains:

FieldTypeDescription
usernamestringLogin username
passwordstringLogin password
totpstring?TOTP secret seed (if configured)
labelstring?Human-readable label
originsstring[]?Exact origin matches (e.g., https://login.salesforce.com)
originPatternsstring[]?Glob patterns for origin matching
notesstring?Free-text notes

set(key, credential)

Store or update a credential.

1await bctrl.vault.set("prod/crm/salesforce", {
2 username: "[email protected]",
3 password: "s3cret",
4 totp: "JBSWY3DPEHPK3PXP",
5 origins: ["https://login.salesforce.com"],
6 label: "Salesforce Bot",
7});
ParameterTypeRequiredDescription
keystringYesVault key path
credential.usernamestringYesLogin username
credential.passwordstringYesLogin password
credential.totpstringNoTOTP secret seed for 2FA
credential.originsstring[]NoExact origin matches
credential.originPatternsstring[]NoGlob patterns for origins
credential.matchOriginsstring[]NoAuto-split into origins/originPatterns
credential.labelstringNoHuman-readable label
credential.notesstringNoFree-text notes

delete(key)

Delete a credential from the vault.

1await bctrl.vault.delete("prod/crm/salesforce");
ParameterTypeRequiredDescription
keystringYesVault key path

list(prefix?)

List vault keys, optionally filtered by prefix.

1// All keys
2const keys = await bctrl.vault.list();
3
4// Keys under a prefix
5const prodKeys = await bctrl.vault.list("prod/crm/");
ParameterTypeRequiredDescription
prefixstringNoKey prefix to filter by

Returns string[] — array of matching key paths.


list(options) — with metadata

List credentials with full metadata by passing meta: true.

1const entries = await bctrl.vault.list({
2 meta: true,
3 prefix: "prod/",
4 hasTotp: true,
5 limit: 50,
6});
ParameterTypeRequiredDescription
metatrueYesReturn full metadata
prefixstringNoKey prefix filter
originstringNoFilter by matching origin
hasTotpbooleanNoFilter by TOTP presence
limitnumberNoMax results

Returns VaultCredentialMeta[]


totp(key)

Generate a current TOTP code from a stored credential’s TOTP seed.

1const code = await bctrl.vault.totp("prod/crm/salesforce");
2console.log(code); // e.g., "482910"
ParameterTypeRequiredDescription
keystringYesVault key with a TOTP seed

Returns string — the current 6-digit TOTP code.


Usage with workspaces

Vault access is scoped by key prefix when mounted to a workspace. See Scopes & Inheritance.

1const workspace = await bctrl.workspaces.create({
2 name: "crm-agent",
3 mounts: {
4 vault: {
5 allow: ["prod/crm/"],
6 deny: ["prod/admin/"],
7 allowRawReads: true,
8 },
9 },
10});