Skip to content
This repository has been archived by the owner on Jan 19, 2022. It is now read-only.

Commit

Permalink
refactor crypto functions in client to allow us to inspect ciphertext
Browse files Browse the repository at this point in the history
  • Loading branch information
psawaya committed Jan 16, 2013
1 parent 6723218 commit 7e5cfb8
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions client/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 7e5cfb8

Please sign in to comment.