Install it
npm install @valt0/client @valt0/client connects to the Valt0 service and opens the vaults that have been imported into it with valt0 import.
npm install @valt0/client openVault loads a vault from the local service, the service can only open a vault that has been imported into it, so run valt0 import on the vault 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] rather than its value: in a log line, a template string, JSON and a stack trace alike. The value comes out only where you ask for it, with reveal() or bytes().
console.log(secret) // Secret([REDACTED])
console.log(`${secret}`) // [REDACTED]
JSON.stringify({ pw: secret }) // {"pw":"[REDACTED]"}
secret.reveal() // the actual valueoptions.
Options
idstringvalt0 info prints.namestringFields
idnameMethods
secret(name)Promise<Secret>Methods
bytes()reveal()stringdestroy()