GithubHelp home page GithubHelp logo

jamoy / locker Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 56 KB

Locker is an embedded secrets-management store specifically made for binaries that are bundled as single-executable CLI apps.

License: MIT License

JavaScript 100.00%
vault secrets-management sidecar

locker's Introduction

Locker

Locker is an embedded secrets-management store specifically made for binaries that are bundled as single-executable CLI apps.

Install

npm i locker
// or
yarn add locker

Usage

import Locker from 'locker';

// set a master key
Locker.config.master = 'THIS WILL BE AUTOGENERATED IF IT IS NOT AVAILABLE';

// for an instance with cluster support
const locker = new Locker();

// or through a network
const locker = new Locker('127.0.0.1:7200');

// or unix socket
const locker = new Locker('/tmp/locker');

// storing plain strings
locker.write('/test/string', 'plain-text');

// storing with a ttl of 15 minutes
locker.write('/test/string', 'plain-text', { ttl: 500 });

// reading
locker.read('/test/string');

// set expiry in 50 seconds or extend ttl without decrypting
locker.expire('/test/string', { ttl: 50 });

// delete a key
locker.delete('/test/string');

// storing a binary
locker.write('/test/keypair', Buffer.from(source));

// storing a key pair
locker.write('/test/keypair', { private: '', public: '', passphrase: '' });

// storing a pgp key
locker.write('/test/keypair', { private: '', public: '', pgp: true });

// listen to events
locker.on('write', (namespace) => console.log('wrote a secret on namespace: ' + namespace));

// rotate key
locker.rotate();

API Reference

const locker = new Locker(source: string, opts: LockerOptions)

locker.write(namespace: String, value: any, opts: WriteOptions)

locker.read(namespace: String)

locker.readMeta(namespace: String)

If the secret value is a key pair, try to infer the key information.

locker.delete(namespace: String)

locker.expire(namespace: String, opts: ExpireOptions)

locker.rotate()

Will create a new signing key and will use that for the next signing execution.

locker.on(event: String, callback: Function)

Listen to the following events thrown by the library. This is used mainly for auditing and logging.

Events:

  • write
  • read
  • extend
  • delete
  • rotate

Contribution

You can run the test suite by running the command below.

yarn test

Make sure that you run this before you send a PR.

License

Locker is licensed as open-source under the MIT License. See License.

locker's People

Contributors

jamoy avatar

Stargazers

Roman avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.