Permalink
Browse files

refactor crypto functions in client to allow us to inspect ciphertext

  • Loading branch information...
1 parent 6723218 commit 7e5cfb8c791fc2c26e9dfd316a280af99ab11c2e @psawaya psawaya committed Jan 16, 2013
Showing with 18 additions and 4 deletions.
  1. +18 −4 client/client.js
View
@@ -162,14 +162,28 @@ GombotClient.prototype = {
});
});
},
- storePayload: function(args, cb) {
+
+ storeEncryptedPayload: function(args,cb) {
args = mergeArgs(args, this);
args.method = 'put';
args.path = this.path + '/v1/payload';
- GombotCrypto.encrypt(this.keys, JSON.stringify(args.payload), function (err, cipherText) {
+ args.data = JSON.stringify({payload: args.cipherText});
+ authRequest(args, cb);
+ },
+
+ createEncryptedPayload: function(payload, cb) {
+ GombotCrypto.encrypt(this.keys, JSON.stringify(payload), function (err, cipherText) {
+ if (err) return cb(err);
+ cb(null, cipherText);
+ });
+ },
+ storePayload: function(args, cb) {
+ args = mergeArgs(args, this);
+ var that = this;
+ this.createEncryptedPayload(args.payload, function(err, cipherText) {
if (err) return cb(err);
- args.data = JSON.stringify({payload: cipherText});
- authRequest(args, cb);
+ args.cipherText = cipherText;
+ that.storeEncryptedPayload(args,cb);
});
},
getPayload: function(args, cb) {

0 comments on commit 7e5cfb8

Please sign in to comment.