Git Product home page Git Product logo

key-store's Introduction

key-store

Build Status NPM Version JavaScript Style Guide

Isomorphic encrypted key store. Works in node and in the browser.

Features

๐Ÿ”’ Strong encryption to securily store sensible data
๐Ÿ”‘ Supports distinct passwords for each key
๐Ÿ” Can store unencrypted data alongside each key

Attention: The data is stored in a truly secure way. If you lose your password you will not be able to recover the wallet data! So please make sure to store a backup of the private data in a safe place.

Installation

$ npm install --save key-store

Using yarn:

$ yarn add key-store

Example

import { createStore } from 'key-store'

const store = createStore(saveFile, initialData)

await store.saveKey('test-key', 'arbitrary password', { privateKey: 'super secret private key' })

const { privateKey } = store.getPrivateKeyData('test-key', 'arbitrary password')

console.log(`Stored private key: ${privateKey}`)
console.log(`All stored keys' IDs: ${store.getKeyIDs().join(', ')}`)

Writing and reading keys to a file in node is easy:

import * as fs from 'fs'
import * as util from 'util'
import { createStore } from 'key-store'

const readFile = util.promisify(fs.readFile)
const writeFile = util.promisify(fs.writeFile)

async function createFileStore (filePath) {
  const saveKeys = data => writeFile(filePath, JSON.stringify(data), 'utf8')
  const readKeys = async () => JSON.parse(await readFile(filePath, 'utf8'))

  return createStore(saveKeys, await readKeys())
}

Encryption details

All data private data is encrypted using tweetnacl's xsalsa20-poly1305 implementation. The encryption key is derived from the password using PBKDF2/SHA256. The iteration count for the PBKDF2 invocation is configurable and defaults to 10,000 rounds.

API

Check out the declaration file.

License

MIT

key-store's People

Contributors

andywer avatar aaronjensen avatar paulbernier avatar

Watchers

James Cloos 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.