Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added decryptPayload

  • Loading branch information...
commit 82034510bc6cdab3de29779df5a463926c3f02e6 1 parent a0593c4
@ckarlof ckarlof authored
Showing with 10 additions and 3 deletions.
  1. +10 −3 client/client.js
View
13 client/client.js
@@ -181,11 +181,17 @@ GombotClient.prototype = {
// update
storePayload: function(args, cb) {
args = mergeArgs(args, this);
- var that = this;
+ var self = this;
this.createEncryptedPayload(args.payload, function(err, ciphertext) {
if (err) return cb(err);
args.ciphertext = ciphertext;
- that.storeEncryptedPayload(args,cb);
+ self.storeEncryptedPayload(args,cb);
+ });
+ },
+ decryptPayload: function(encryptedPayload, cb) {
+ GombotCrypto.decrypt(this.keys, encryptedPayload, function (err, plaintext) {
+ if (err) return cb(err);
+ cb(null, plaintext);
});
},
// read
@@ -195,9 +201,10 @@ GombotClient.prototype = {
args.path = this.path + '/v1/payload';
var keys = this.keys;
+ var self = this;
authRequest(args, function (err, data) {
if (err) return cb(err);
- GombotCrypto.decrypt(keys, data.payload, function (err, plaintext) {
+ self.decryptPayload(data.payload, function (err, plaintext) {
if (err) return cb(err);
cb(null, {success: data.success, payload: JSON.parse(plaintext), updated: data.updated, ciphertext: data.payload });
});
Please sign in to comment.
Something went wrong with that request. Please try again.