diff --git a/src/openpgp.js b/src/openpgp.js index 8085ab16..5142b520 100644 --- a/src/openpgp.js +++ b/src/openpgp.js @@ -345,7 +345,7 @@ export function verify({ message, publicKeys, signature=null, date=new Date() }) publicKeys = toArray(publicKeys); if (asyncProxy) { // use web worker if available - return asyncProxy.delegate('verify', { message, publicKeys, signature }); + return asyncProxy.delegate('verify', { message, publicKeys, signature, date }); } return Promise.resolve().then(async function() { diff --git a/src/packet/clone.js b/src/packet/clone.js index ff120950..b6969003 100644 --- a/src/packet/clone.js +++ b/src/packet/clone.js @@ -60,7 +60,7 @@ export function clonePackets(options) { if (options.message instanceof Message) { options.message = options.message.packets; } else if (options.message instanceof CleartextMessage) { - options.message.signature = options.message.signature.packets; + options.message = { text: options.message.text, signature: options.message.signature.packets }; } } if (options.signature && (options.signature instanceof Signature)) { diff --git a/test/general/openpgp.js b/test/general/openpgp.js index 809fa079..c0bd1e1b 100644 --- a/test/general/openpgp.js +++ b/test/general/openpgp.js @@ -868,7 +868,12 @@ describe('OpenPGP.js public api tests', function() { beforeEach(function (done) { expect(privateKey.keys[0].decrypt(passphrase)).to.be.true; - privateKey.keys[0].verifyPrimaryUser().then(() => done()); + Promise.all([ + privateKey.keys[0].verifyPrimaryUser(), + privateKey_2000_2008.keys[0].verifyPrimaryUser(), + privateKey_1337.keys[0].verifyPrimaryUser(), + privateKey_2038_2045.keys[0].verifyPrimaryUser() + ]).then(() => done()); }); it('should encrypt then decrypt', function () { @@ -1556,27 +1561,27 @@ describe('OpenPGP.js public api tests', function() { const future = new Date(2040, 5, 5, 5, 5, 5, 0); const data = new Uint8Array([3, 14, 15, 92, 65, 35, 59]); const signOpt = { - data, - privateKeys: privateKey_2038_2045.keys, - detached: true, - date: future, - armor: false + data, + privateKeys: privateKey_2038_2045.keys, + detached: true, + date: future, + armor: false }; const verifyOpt = { - publicKeys: publicKey_2038_2045.keys, - date: future + publicKeys: publicKey_2038_2045.keys, + date: future }; return openpgp.sign(signOpt).then(function (signed) { - verifyOpt.message = openpgp.message.fromBinary(data); - verifyOpt.signature = signed.signature; - return openpgp.verify(verifyOpt); + verifyOpt.message = openpgp.message.fromBinary(data); + verifyOpt.signature = signed.signature; + return openpgp.verify(verifyOpt); }).then(function (verified) { - expect(+verified.signatures[0].signature.packets[0].created).to.equal(+future); - expect(verified.data).to.equal(data); - expect(verified.signatures[0].valid).to.be.true; - expect(signOpt.privateKeys[0].getSigningKeyPacket(verified.signatures[0].keyid, future)) - .to.be.not.null; - expect(verified.signatures[0].signature.packets.length).to.equal(1); + expect(+verified.signatures[0].signature.packets[0].created).to.equal(+future); + expect(Array.from(verified.data)).to.deep.equal(Array.from(data)); + expect(verified.signatures[0].valid).to.be.true; + expect(signOpt.privateKeys[0].getSigningKeyPacket(verified.signatures[0].keyid, future)) + .to.be.not.null; + expect(verified.signatures[0].signature.packets.length).to.equal(1); }); });