From 0186ca8a246e6e6dc9bdd1ec210dac55abadeddd Mon Sep 17 00:00:00 2001 From: Bart Butler Date: Mon, 26 Feb 2018 14:45:05 -0800 Subject: [PATCH 1/2] tree shake sinon to just get what we need --- test/general/openpgp.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/test/general/openpgp.js b/test/general/openpgp.js index 477f1291..6a71eec6 100644 --- a/test/general/openpgp.js +++ b/test/general/openpgp.js @@ -2,7 +2,8 @@ const openpgp = typeof window !== 'undefined' && window.openpgp ? window.openpgp : require('../../dist/openpgp'); -const sinon = require('sinon'); +const spy = require('sinon/lib/sinon/spy'); +const stub = require('sinon/lib/sinon/stub'); const chai = require('chai'); chai.use(require('chai-as-promised')); @@ -314,8 +315,8 @@ function withCompression(tests) { let decompressSpy; beforeEach(function () { - compressSpy = sinon.spy(openpgp.packet.Compressed.prototype, 'compress'); - decompressSpy = sinon.spy(openpgp.packet.Compressed.prototype, 'decompress'); + compressSpy = spy(openpgp.packet.Compressed.prototype, 'compress'); + decompressSpy = spy(openpgp.packet.Compressed.prototype, 'decompress'); }); afterEach(function () { @@ -388,9 +389,9 @@ describe('OpenPGP.js public api tests', function() { }; } }; - keyGenStub = sinon.stub(openpgp.key, 'generate'); + keyGenStub = stub(openpgp.key, 'generate'); keyGenStub.returns(resolves(keyObjStub)); - getWebCryptoAllStub = sinon.stub(openpgp.util, 'getWebCryptoAll'); + getWebCryptoAllStub = stub(openpgp.util, 'getWebCryptoAll'); }); afterEach(function() { @@ -523,7 +524,7 @@ describe('OpenPGP.js public api tests', function() { openpgp.initWorker({ worker: workerStub }); - const proxyGenStub = sinon.stub(openpgp.getWorker(), 'delegate'); + const proxyGenStub = stub(openpgp.getWorker(), 'delegate'); getWebCryptoAllStub.returns(); openpgp.generateKey(); From 51adfcc244c6c1f774e1279067faf23791a8e8d4 Mon Sep 17 00:00:00 2001 From: Sanjana Rajan Date: Tue, 27 Feb 2018 23:15:42 +0100 Subject: [PATCH 2/2] fromClone function for ecdh symkey --- src/type/ecdh_symkey.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/type/ecdh_symkey.js b/src/type/ecdh_symkey.js index ec38430d..87f9cf3e 100644 --- a/src/type/ecdh_symkey.js +++ b/src/type/ecdh_symkey.js @@ -63,3 +63,7 @@ ECDHSymmetricKey.prototype.read = function (input) { ECDHSymmetricKey.prototype.write = function () { return util.concatUint8Array([new Uint8Array([this.data.length]), this.data]); }; + +ECDHSymmetricKey.fromClone = function (clone) { + return new ECDHSymmetricKey(clone.data); +};