# keychain-promise

> Cross-Platform SQLCipher based keychain

Latest version **2.0.0** (published 2018-07-23) · GPL-3.0 license · 0 weekly downloads

## Install

```sh
npm install keychain-promise
pnpm add keychain-promise
yarn add keychain-promise
bun add keychain-promise
```

## 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 | 2.0.0 |
| Published | 2018-07-23 |
| First published | 2018-05-12 |
| Weekly downloads | 0 |
| License | GPL-3.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 10.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Michael Schmidt |
| Maintainers | michael1 |

## Links

- npm: https://www.npmjs.com/package/keychain-promise
- Repository: https://github.com/michael-ts/keychain-promise
- Homepage: https://github.com/michael-ts/keychain-promise#readme
- Issues: https://github.com/michael-ts/keychain-promise/issues
- npm.io page: https://npm.io/package/keychain-promise

## Dependencies (1)

- [cross-sqlcipher-promise](https://npm.io/package/cross-sqlcipher-promise.md) ^1.0.1

## Recent versions

- 2.0.0 (latest) — 2018-07-23
- 2.0.0-beta.0 (beta) — 2019-09-14
- 1.0.1 — 2018-05-30
- 1.0.0 — 2018-05-12

## README

Cross-Platform SQLCipher based keychain
=======================================

# Overview

This package presents a keychain abstraction.  A keychain is a per-user SQLite database encrypted with the user's password, and containing name/key pairs where the name represents a resource and the key is the password or encryption key for that resource. 

# Usage
Create a keychain for user "michael" with password "12345", then add password "asdfg" for resource "test".  Will throw an exception if the keychain already exists:
```
var kc = require("keychain-promise")()
kc.Create("michael","12345").then(db=>{
    return kc.Add(db,"test","asdfg")
}).then(ok => console.log(ok))
```

Retrieve the password and display for resource "test" for user "michael".  The returned key is contained in an object "row" with a key named "key":
```
var kc = require("keychain-promise")()
kc.Get("michael","abcd").then(db=>{
    return kc.Lookup(db,"test")
}).then(row=>console.log(row))
```

Remove the password for resource "test" for user "michael":
```
var kc = require("keychain-promise")()
var db
kc.Get("michael","abcd").then(d=>{
    db = d
    return kc.Remove(db,"test").then(ok=>console.log(ok))
}).then(row=>console.log(row))
```


# API


## Instantiation

```
var kc = require("keychain-promise")(options)
```
If options is present, it is expected to be an object.  The following keys are recognized:

```dir```: string path to the directory containing all keychains


## Create
```
Create(name,password)
=> Promise->db
```
Given a user name and password, create a Promise resolving to an open SQLite database handle for the user's keychain.  Throws an exception if the keychain already exists.


## Get
```
Get(user,password)
=> Promise->db
```
Given a user name and password, return a promise resolving to an open SQLite database handle for the user's already existing keychain.

## Lookup
```
Lookup(db,name)
=> Promise->key
```
Given an open SQLite database handle for the user's keychain, return the key for the specified
name.



## Add
```
UserKeyAdd(db,name,group)
=> Promise->bool
```
Given an open SQLite database handle for the user's keychain, a name, and the group that name belongs to, stores that name/group pair in the keychain.  If the group does not already exists, it is created with a random key.  Returns a promise which resolves to a boolean value indicating success or failure.


## Remove
```
Remove(db,name)
=> Promise->bool
```
Given an open SQLite database handle for the user's keychain, and a name, remove the name/key
pair from the keychain.  Returns a promise which resolves to a boolean value indicating success or failure.

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