# truevaultjs

> TrueVault Client for node.js

Latest version **0.2.5** (published 2016-05-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install truevaultjs
pnpm add truevaultjs
yarn add truevaultjs
bun add truevaultjs
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.5 |
| Published | 2016-05-11 |
| First published | 2013-10-31 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 0.6.x |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 18 |
| Author | Nafis Zebarjadi |
| Maintainers | nafisto |

## Links

- npm: https://www.npmjs.com/package/truevaultjs
- Repository: https://github.com/medicast/truevaultjs
- Issues: http://github.com/medicast/truevaultjs/issues
- npm.io page: https://npm.io/package/truevaultjs

## Dependencies (1)

- [restify](https://npm.io/package/restify.md) ^4.0.4

## Recent versions

- 0.2.5 (latest) — 2016-05-11
- 0.2.4 — 2016-05-11
- 0.2.3 — 2014-07-30
- 0.2.2 — 2014-07-07
- 0.2.1 — 2014-04-27
- 0.2.0 — 2014-04-27
- 0.1.0 — 2013-10-31

## README

# TrueVault Client Library for Node.js

An unofficial JavaScript implementation of the [TrueVault REST API](https://www.truevault.com/rest-api.html).

[TrueVault](https://www.truevault.com/) is a secure "backend-as-a-service" content storage solution for HIPAA compliance.  

## Installing

Use
[npm](http://npmjs.org) to install into your Node.js. Simply include "truevaultjs" as a dependency or type the following into a terminal window:

```sh
npm install truevaultjs
```

## Example

```js

var TrueVault = require('truevaultjs');

var client = new TrueVault('secure_api_key');

var mydoc = { secure: 'data', isPHI: true };
client.json.create(vaultId,mydoc,function(err,result) {
    console.log(result.document_id);
});

mydoc.newField = 12345;
client.json.update(vaultId,mydoc,function(err) {});

client.json.get(vaultId,documentId,function(err,document) {
    assert.equal(mydoc,document);
});

client.json.del(vaultId,documentId,function(err) {});

```

## API

The API is designed to closely mirror the [TrueVault REST API](https://www.truevault.com/rest-api.html).  The client handles authentication headers as well as Base64 encoding and decoding, so all you need to do is plug in your own API key (from the TrueVault Users dashboard), vault ID (also created and managed in the dashboard), and content.

### Initialization

```js

var TrueVault = require('truevaultjs');
var client = new TrueVault('secure_api_key');	// replace with your own

```

### JSON (Document) Store

```js

client.json.create(vaultId,document,callback)
client.json.update(vaultId,documentId,document,callback)
client.json.del(vaultId,documentId,callback)
client.json.get(vaultId,documentId,callback)

```

### BLOB Store

```js

client.blob.create(vaultId,document,callback)
client.blob.update(vaultId,documentId,blob,callback)
client.blob.del(vaultId,documentId,callback)
client.blob.get(vaultId,documentId,callback)

```

### Schema Store

```js

client.json.create(vaultId,document,callback)
client.json.update(vaultId,documentId,document,callback)
client.json.del(vaultId,documentId,callback)
client.json.get(vaultId,documentId,callback)
client.json.all(vaultId,callback)

```

### Search Engine

NOTE: This hasn't been fully implemented yet, so the API is likely to change.

```js

client.json.find(vaultId,query,callback)

```

### Callbacks and Promises

All methods can take a callback as the final argument.  The callback signature follows the typical Node.js form:

```js

var callback = function(err,result) {}
client.json.create('some-vault-id',{ this: 'is', my: 'document' }, callback);

```

If a callback is not provided, methods will return a promise that will be fulfilled as soon as the asynchronous call is completed:

```js

client.json
    .create('some-vault-id'),{ this: 'is', my: 'document' })
    .then(function(result) {
        // promise resolved, i.e. success
    }, function(reason) {
        // promise rejected, i.e. failure
    })
    // ...promise chain...

```

(For more information, check out the [Promises/A+ spec](https://promisesaplus.com/) and the documentation for the excellent [Q library](https://github.com/kriskowal/q)).


## Plain-English Disclaimer

HIPAA compliance is very complicated.  The authors and contributors of this client library cannot guarantee that by using it, you will be compliant.  Please consult experts to make sure you are doing this right!

## License

This SDK is distributed under the
[MIT License](http://opensource.org/licenses/MIT).

```no-highlight
Copyright (c) 2013 Medicast, Inc. or its affiliates.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
```

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