mesg-foundation / js-sdk

Javascript mono-repo with all the tools to interact with MESG
https://mesg.com
4 stars 4 forks source link

Add vault implementation #180

Closed antho1404 closed 4 years ago

antho1404 commented 4 years ago

Dependency: https://github.com/mesg-foundation/js-sdk/pull/179

Create @mesg/vault library.

Store securely your information

Usage

const Vault = require('@mesg/vault')
const MemoryStore = require('@mesg/vault/lib/store/memory')
const encryptedStore = new MemoryStore()
const vault = new Vault(encryptedStore)
vault.set('my-key', { foo: 'bar' }, 'my-password')
const data = vault.get('my-key', 'my-password')

Store

@mesg/vault can use different stores to store your data.

Memory store

This store will not persist any data and keep everything in a map in memory.

const MemoryStore = require('@mesg/vault/lib/store/memory')
new Vault(new MemoryStore())

File store

This store will persist the values in a json file on disk (only available in node).

const FileStore = require('@mesg/vault/lib/store/file')
new Vault(new FileStore('./store.json'))

Localstorage

This store is only available on browser and will persist on the localstorage of your browser.

new Vault(localstorage)
antho1404 commented 4 years ago

Encryption inspired by @luniehq https://github.com/luniehq/cosmos-keys/blob/develop/src/cosmos-keystore.ts