JSON File adapter for Secretary

Usage no npm install needed!

<script type="module">
  import secretaryJsonFile from 'https://cdn.skypack.dev/@secretary/json-file';


Secretary - JSON File Adapter

This is the JSON File adapter for Secretary


This adapter does NOT use any encryption. It should NOT be used in production.


$ npm install @secretary/core @secretary/json-file


Creating the manager

import {Adapter, Secretary} from '@secretary/json-file';

const manager = new Secretary(new Adapter({file: '../path/to/my/secrets'}));

Fetching a secret

const someSecret = await manager.getSecret({path: 'databases/redis', key: 'dsn'});
console.log(someSecret); // redis://localhost:6379

Fetching a secret path

const someSecrets = await manager.getSecrets({path: 'databases/redis'});
console.log(someSecrets); // {dsn: 'redis://localhost:6379', auth: 'foo'}

Create / Update a secret

await manager.putSecret({path: 'databases/redis', key: 'dsn', value: 'redis://localhost:6379'});
await manager.putSecret({path: 'databases/redis', key: 'auth', value: 'foo'});

Create / Update multiple secrets

Note, this fires off a request for every secret that you send.

await manager.putSecrets([
    {path: 'databases/redis', key: 'dsn', value: 'redis://localhost:6379'},
    {path: 'databases/redis', key: 'auth', value: 'foo'},