Install it
npm install @valt0/client Clients
npm install @valt0/client openVault loads a vault from the local service. Pass it the id that valt0 info prints for the vault. The service can only open a vault that has been imported into it. A vault you create is imported for you; for one made somewhere else, run valt0 import first.
import { openVault } from '@valt0/client'
const vault = await openVault({
id: 'your-vault-id',
name: 'your-vault-name',
})require:
const { openVault } = require('@valt0/client')vault.secret(name) fetches one secret and resolves to a Secret. Take the value out as bytes where you can: bytes() hands back a copy you can wipe once you are done with it, and destroy() zeroes the secret's own buffer.
reveal().
const secret = await vault.secret('DATABASE_PASSWORD')
// Preferred: raw bytes you can wipe when done
const bytes = secret.bytes()
// Or, when a string is unavoidable
await db.connect({ password: secret.reveal() })
// Zero the underlying buffer as soon as you are finished
secret.destroy()Secret prints as [REDACTED]: in a log line, a template string, JSON and a stack trace alike. The value comes out only through reveal() or bytes().
console.log(secret) // Secret([REDACTED])
console.log(`${secret}`) // [REDACTED]
JSON.stringify({ pw: secret }) // {"pw":"[REDACTED]"}
secret.reveal() // the actual valueid. Throws if the service cannot be reached or the vault cannot be loaded.
Options
idstringvalt0 info prints. It is the only value used to find the vault.namestringFields
idnameMethods
secret(name)Promise<Secret>Methods
bytes()reveal()stringdestroy()