simplevault
v0.5.11
Published
Client library for the SimpleVault encryption API
Maintainers
Readme
simplevault
Node.js HTTP client for SimpleVault — a minimal encryption API using AES-256-GCM.
There is no JavaScript server in this package. For local development, run the Rust simplevault binary (see the main repo README and documentation: install script, GitHub Releases, Docker, or cargo run), then point this client at that URL.
Installation
npm install simplevaultClient library
import { SimpleVaultClient } from 'simplevault';
const client = new SimpleVaultClient({
baseUrl: 'http://localhost:8080',
apiKey: 'optional-key', // omit if server has no api_keys
});
const { ciphertext } = await client.encrypt('vault', 'secret message');
const { plaintext } = await client.decrypt('vault', ciphertext);
const { ciphertext: rotated } = await client.rotate('vault', ciphertext);
const { version } = await client.getVersion('vault');
const result = await client.dbQuery('vault', {
ciphertext,
query: {
sql: 'select $1::int as n, $2::text as label, $3::text is null as is_null',
params: [
{ type: 'int4', value: 123 },
{ type: 'text', value: 'gold' },
{ type: 'null', value: null },
],
},
});Contract tests
From the repository root, build the release binary, then from client/:
npm ci
npm run build
node test/run-with-rust-server.mjsOr with a server already running:
SIMPLEVAULT_BASE_URL=http://localhost:8080 npm run test:contractLicense
MIT
