# keystorage-lib

> A simple service to store encrypted ethereum keys.

Latest version **1.0.1** (published 2016-05-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install keystorage-lib
pnpm add keystorage-lib
yarn add keystorage-lib
bun add keystorage-lib
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2016-05-13 |
| First published | 2016-05-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Johann Barbie |
| Maintainers | polycarpik |
| Keywords | ethereum, keychain |

## Links

- npm: https://www.npmjs.com/package/keystorage-lib
- Repository: https://github.com/Ambisafe/keystorage-docs
- Homepage: https://github.com/Ambisafe/keystorage-docs#readme
- Issues: https://github.com/Ambisafe/keystorage-docs/issues
- npm.io page: https://npm.io/package/keystorage-lib

## Dependencies (4)

- [superagent](https://npm.io/package/superagent.md) ^1.8.3
- [es6-promise](https://npm.io/package/es6-promise.md) ^3.2.1
- [superagent-jsonapify](https://npm.io/package/superagent-jsonapify.md) ^1.4.1
- [superagent-promise-plugin](https://npm.io/package/superagent-promise-plugin.md) ^3.2.0

## Recent versions

- 1.0.1 (latest) — 2016-05-13
- 1.0.0 — 2016-05-11

## README

# Keystorage Service

simple API to store and retrieve keys.

## Features

- open standard storage format used: [Ethereum Secret Storage Definition](https://github.com/ethereum/wiki/wiki/Web3-Secret-Storage-Definition)
- no authentication for GET, UUID v4 generated by client used as secret key
- rate-limiting used to prevent brute-force attacks

## Usage

### Installation instructions

```
  npm install keystorage-lib
```

### Reading wallet from storage


```javascript
  var lib = require('keystorage-lib');
  var walletUuid = '88a23fc8-09fa-4cd5-a3a4-0d4f3a496602';
  lib.get(walletUuid)
    .then(function(result){
        //This is where you would put a success callback
    }).catch( function(result){
        //This is where you would put an error callback
    });

```

Example output of `res.body`:

```JSON
{
  address: "0xe6b032b23bc145ed19e23792e2a107d0794fe65a",
  id: "88a23fc8-09fa-4cd5-a3a4-0d4f3a496602",
  version: 3,
  crypto: {
    kdfparams: {
      prf: "hmac-sha256",
      c: 262144,
      dklen: 32,
      salt: "ae3cd4e7013836a3df6bd7241b12db061dbe2c6785853cce422d148a624ce0bd"
    },
    ciphertext: "5318b4d5bcd28de64ee5559e671353e16f075ecae9f99c7a79a38af5f869aa46",
    mac: "517ead924a9d0dc3124507e3393d175ce3ff7c1e96529c6c555ce9e51205e9b2",
    cipher: "aes-128-ctr",
    kdf: "pbkdf2",
    cipherparams: {
      iv: "6087dab2f9fdbbfaddc31a909735c1e6"
    }
  }
}
```

### Storing encrypted wallet in storage

Each API call returns a promise, that invokes either a success and failure callback.

```
  var lib = require('keystorage-lib');

  var wallet = {
    "crypto" : {
      "cipher" : "aes-128-ctr",
      "cipherparams" : {
        "iv" : "6087dab2f9fdbbfaddc31a909735c1e6"
      },
      "ciphertext" : "5318b4d5bcd28de64ee5559e671353e16f075ecae9f99c7a79a38af5f869aa46",
      "kdf" : "pbkdf2",
      "kdfparams" : {
        "c" : 262144,
        "dklen" : 32,
        "prf" : "hmac-sha256",
        "salt" : "ae3cd4e7013836a3df6bd7241b12db061dbe2c6785853cce422d148a624ce0bd"
      },
      "mac" : "517ead924a9d0dc3124507e3393d175ce3ff7c1e96529c6c555ce9e51205e9b2"
    },
    "id": "88a23fc8-09fa-4cd5-a3a4-0d4f3a496602",
    "address" : "0xe6b032b23bc145ed19e23792e2a107d0794fe65a",
    "version" : 3
  };

  var token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJhZTU5NmFlOC00NjVjLTRkMWEtOWE4MC1mOTJlY2QyNDE2MzUiLCJzdWIiOiJzdG9yYWdlIiwianRpIjoiMTIzNCIsImF1ZCI6ImFtYmlzYWZlIiwiZXhwIjoxNDYxNzkxMDI2MDQyfQ.IJdbUMCN7O8LOHNY0H19pGFMmw3GBaDtybh-3BllM_g';

  lib.store(wallet, token)
    .then(function(result){
        //This is where you would put a success callback
    }).catch( function(result){
        //This is where you would put an error callback
    });
```

---
_Source: https://npm.io/package/keystorage-lib · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
