Add method 'createItem' to DB plugins

This commit is contained in:
Esteban Ordano 2014-10-28 15:20:43 -03:00
commit 5eade81294
4 changed files with 34 additions and 0 deletions

View file

@ -16,6 +16,17 @@ InsightStorage.prototype.setCredentials = function(email, password, opts) {
this.password = password;
};
InsightStorage.prototype.createItem = function(name, value, callback) {
var self = this;
this.getItem(name, function(err, retrieved) {
if (err || !retrieved) {
return self.setItem(name, value, callback);
} else {
return callback('EEXISTS');
}
});
};
InsightStorage.prototype.getItem = function(name, callback) {
var key = cryptoUtil.kdf(this.password + this.email);
var secret = cryptoUtil.kdf(key, this.password);