ancient-tome
Advanced tools
Comparing version 1.0.1 to 1.1.1
20
index.js
@@ -61,4 +61,10 @@ var StorageCrypto = require('./crypto.js') | ||
_this._get.bind(_this), | ||
_this._crypto.decrypt, | ||
], cb) | ||
], function(err, encryptedText){ | ||
if (err) return cb(err) | ||
if (encryptedText) { | ||
_this._crypto.decrypt(encryptedText, cb) | ||
} else { | ||
cb() | ||
} | ||
}) | ||
@@ -72,2 +78,10 @@ } | ||
if (typeof value !== 'string' ) { | ||
if (value.toString) { | ||
value = value.toString() | ||
} else { | ||
value = JSON.parse(value) | ||
} | ||
} | ||
async.parallel([ | ||
@@ -91,3 +105,3 @@ _this._crypto.hmac.bind(null, key), | ||
_this._crypto.hmac.bind(null, key), | ||
_this._remove.bind(_this, key), | ||
_this._remove.bind(_this), | ||
], cb) | ||
@@ -94,0 +108,0 @@ } |
{ | ||
"name": "ancient-tome", | ||
"version": "1.0.1", | ||
"version": "1.1.1", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -6,2 +6,17 @@ # Ancient Tome | ||
### Crypto flow: | ||
These are the cryptograph flows used by AncientTome: | ||
``` | ||
init: salt + password --(bcrypt)--> hash --(AES-GCM)--> AES key | ||
init: salt + password --(bcrypt)--> hash --(HMAC+SHA256)--> HMAC key | ||
obfuscate keys: plainText --(HMAC+SHA256)--> cypherText | ||
encrypt values: plainText --(AES-GCM)--> cypherText | ||
``` | ||
The salt is randomly generated on first use and stored in plaintext. | ||
The password is provided by the user and stored in their head. | ||
### Usage: | ||
@@ -46,14 +61,18 @@ | ||
### Crypto flow: | ||
### Extras: | ||
These are the cryptograph flows used by AncientTome: | ||
With obfuscated keys, its hard to keep track of what's been stored. | ||
Use the `TomeIndexer` to augment a tome with a simple index. | ||
Be sure to do this after if you are overriding get/set methods. | ||
``` | ||
init: salt + password --(bcrypt)--> hash --(AES-GCM)--> AES key | ||
init: salt + password --(bcrypt)--> hash --(HMAC+SHA256)--> HMAC key | ||
obfuscate keys: plainText --(HMAC+SHA256)--> cypherText | ||
encrypt values: plainText --(AES-GCM)--> cypherText | ||
``` | ||
```js | ||
var AncientTome = require('ancient-tome') | ||
var TomeIndexer = require('ancient-tome/indexer') | ||
The salt is randomly generated on first use and stored in plaintext. | ||
The password is provided by the user and stored in their head. | ||
var myTome = AncientTome() | ||
TomeIndexer(myTome) | ||
myTome.open(password, function(){ | ||
myTome.index() //=> ['journal', 'bank info'] | ||
}) | ||
``` |
@@ -10,2 +10,3 @@ var test = require('tape') | ||
t.plan(5) | ||
clearLocalStorage() | ||
@@ -31,2 +32,9 @@ var localAncient = LocalAncient() | ||
}) | ||
}) | ||
}) | ||
function clearLocalStorage() { | ||
for (var key in localStorage) { | ||
localStorage.removeItem(key) | ||
} | ||
} |
16810
10
463
76