New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

keystore-idb

Package Overview
Dependencies
Maintainers
1
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

keystore-idb

[![Build Status](https://travis-ci.org/fission-suite/keystore-idb.svg?branch=master)](https://travis-ci.org/fission-suite/PROJECTNAME) [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/fission-suite/blob/master/LI

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
162
increased by18.25%
Maintainers
1
Weekly downloads
 
Created
Source

IndexedDB KeyStore

Build Status License Maintainability Built by FISSION Discord Discourse

In-browser key management with IndexedDB and the Web Crypto API.

Securely store and use keys for encryption, decryption, and signatures. IndexedDB and Web Crypto keep keys safe from malicious javascript.

Supports both RSA (RSA-PSS & RSA-OAEP) and Elliptic Curves (P-256, P-381 & P-521).

ECC (Elliptic Curve Cryptography) is only available on Chrome. Firefox and Safari do not support ECC and must use RSA.

Config

Below is the default config and all possible values

const defaultConfig = {
  type: 'ecc', // 'ecc' | 'rsa'
  curve: 'P-256', // 'P-256' | 'P-384' | 'P-521'
  rsaSize: 2048, // 1024 | 2048 | 4096
  symmAlg: 'AES-CTR', // 'AES-CTR' | 'AES-GCM' | 'AES-CBC'
  hashAlg: 'SHA-256', // 'SHA-1' | 'SHA-256' | 'SHA-384' | 'SHA-512'
  readKeyName: 'read-key', // any string
  writeKeyName: 'write-key', // any string
}

Note: if you don't include a crypto "type" ('ecc' | 'rsa'), the library will check if your browser supports ECC. If so (Chrome), it will use ECC, if not (Firefox, Safari) it will fall back to RSA.

Example Usage

  import KeyStore from './keystore'

  const ALG = 'rsa'
  await KeyStore.clear()
  const ks1 = await KeyStore.init({ type: ALG, readKeyName: 'read-key-1', writeKeyName: 'write-key-1' })
  const ks2 = await KeyStore.init({ type: ALG, readKeyName: 'read-key-2', writeKeyName: 'write-key-2' })

  const msg = "Incididunt id ullamco et do."
  const readKey1 = ks1.readKey
  const readKey2 = ks2.readKey
  const writeKey1 = ks1.writeKey

  const sig = await ks1.sign(msg)
  const valid = await ks2.verify(msg, sig, writeKey1.publicKey)
  console.log('sig: ', sig)
  console.log('valid: ', valid)

  const cipher = await ks1.encrypt(msg, readKey2.publicKey)
  const decipher = await ks2.decrypt(cipher, readKey1.publicKey)
  console.log('cipher: ', cipher)
  console.log('decipher: ', decipher)

  // read keys are write keys are separate because of the Web Crypto API
  const readKey = await ks1.publicReadKey()
  const writeKey = await ks1.publicWriteKey()
  console.log('readKey: ', readKey)
  console.log('writeKey: ', writeKey)

Development

# install dependencies
yarn

# run development server
yarn start

# build
yarn build

# test
yarn test

FAQs

Package last updated on 24 Feb 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc