Release new version
This commit is contained in:
parent
e4b2b8208e
commit
1962760344
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "openpgp",
|
||||
"version": "1.5.7",
|
||||
"version": "2.0.0",
|
||||
"license": "LGPL-3.0+",
|
||||
"homepage": "http://openpgpjs.org/",
|
||||
"authors": [
|
||||
|
|
15500
dist/openpgp.js
vendored
15500
dist/openpgp.js
vendored
File diff suppressed because one or more lines are too long
18
dist/openpgp.min.js
vendored
18
dist/openpgp.min.js
vendored
File diff suppressed because one or more lines are too long
150
dist/openpgp.worker.js
vendored
150
dist/openpgp.worker.js
vendored
|
@ -16,7 +16,9 @@
|
|||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
window = {}; // to make UMD bundles work
|
||||
/* globals self: true */
|
||||
|
||||
self.window = {}; // to make UMD bundles work
|
||||
|
||||
// Mozilla bind polyfill because phantomjs is stupid
|
||||
if (!Function.prototype.bind) {
|
||||
|
@ -41,152 +43,50 @@ if (!Function.prototype.bind) {
|
|||
}
|
||||
|
||||
importScripts('openpgp.js');
|
||||
var openpgp = window.openpgp;
|
||||
|
||||
var MIN_SIZE_RANDOM_BUFFER = 40000;
|
||||
var MAX_SIZE_RANDOM_BUFFER = 60000;
|
||||
|
||||
window.openpgp.crypto.random.randomBuffer.init(MAX_SIZE_RANDOM_BUFFER);
|
||||
openpgp.crypto.random.randomBuffer.init(MAX_SIZE_RANDOM_BUFFER);
|
||||
|
||||
self.onmessage = function (event) {
|
||||
var data = null,
|
||||
err = null,
|
||||
msg = event.data,
|
||||
correct = false;
|
||||
var msg = event.data || {},
|
||||
options = msg.options || {};
|
||||
|
||||
switch (msg.event) {
|
||||
case 'configure':
|
||||
for (var i in msg.config) {
|
||||
window.openpgp.config[i] = msg.config[i];
|
||||
openpgp.config[i] = msg.config[i];
|
||||
}
|
||||
break;
|
||||
|
||||
case 'seed-random':
|
||||
if (!(msg.buf instanceof Uint8Array)) {
|
||||
msg.buf = new Uint8Array(msg.buf);
|
||||
}
|
||||
window.openpgp.crypto.random.randomBuffer.set(msg.buf);
|
||||
break;
|
||||
case 'encrypt-message':
|
||||
if (!msg.keys.length) {
|
||||
msg.keys = [msg.keys];
|
||||
}
|
||||
msg.keys = msg.keys.map(packetlistCloneToKey);
|
||||
window.openpgp.encryptMessage(msg.keys, msg.text).then(function(data) {
|
||||
response({event: 'method-return', data: data});
|
||||
}).catch(function(e) {
|
||||
response({event: 'method-return', err: e.message});
|
||||
});
|
||||
break;
|
||||
case 'sign-and-encrypt-message':
|
||||
if (!msg.publicKeys.length) {
|
||||
msg.publicKeys = [msg.publicKeys];
|
||||
}
|
||||
msg.publicKeys = msg.publicKeys.map(packetlistCloneToKey);
|
||||
msg.privateKey = packetlistCloneToKey(msg.privateKey);
|
||||
window.openpgp.signAndEncryptMessage(msg.publicKeys, msg.privateKey, msg.text).then(function(data) {
|
||||
response({event: 'method-return', data: data});
|
||||
}).catch(function(e) {
|
||||
response({event: 'method-return', err: e.message});
|
||||
});
|
||||
break;
|
||||
case 'decrypt-message':
|
||||
msg.privateKey = packetlistCloneToKey(msg.privateKey);
|
||||
msg.message = packetlistCloneToMessage(msg.message.packets);
|
||||
window.openpgp.decryptMessage(msg.privateKey, msg.message).then(function(data) {
|
||||
response({event: 'method-return', data: data});
|
||||
}).catch(function(e) {
|
||||
response({event: 'method-return', err: e.message});
|
||||
});
|
||||
break;
|
||||
case 'decrypt-and-verify-message':
|
||||
msg.privateKey = packetlistCloneToKey(msg.privateKey);
|
||||
if (!msg.publicKeys.length) {
|
||||
msg.publicKeys = [msg.publicKeys];
|
||||
}
|
||||
msg.publicKeys = msg.publicKeys.map(packetlistCloneToKey);
|
||||
msg.message = packetlistCloneToMessage(msg.message.packets);
|
||||
window.openpgp.decryptAndVerifyMessage(msg.privateKey, msg.publicKeys, msg.message).then(function(data) {
|
||||
response({event: 'method-return', data: data});
|
||||
}).catch(function(e) {
|
||||
response({event: 'method-return', err: e.message});
|
||||
});
|
||||
break;
|
||||
case 'sign-clear-message':
|
||||
msg.privateKeys = msg.privateKeys.map(packetlistCloneToKey);
|
||||
window.openpgp.signClearMessage(msg.privateKeys, msg.text).then(function(data) {
|
||||
response({event: 'method-return', data: data});
|
||||
}).catch(function(e) {
|
||||
response({event: 'method-return', err: e.message});
|
||||
});
|
||||
break;
|
||||
case 'verify-clear-signed-message':
|
||||
if (!msg.publicKeys.length) {
|
||||
msg.publicKeys = [msg.publicKeys];
|
||||
}
|
||||
msg.publicKeys = msg.publicKeys.map(packetlistCloneToKey);
|
||||
var packetlist = window.openpgp.packet.List.fromStructuredClone(msg.message.packets);
|
||||
msg.message = new window.openpgp.cleartext.CleartextMessage(msg.message.text, packetlist);
|
||||
window.openpgp.verifyClearSignedMessage(msg.publicKeys, msg.message).then(function(data) {
|
||||
response({event: 'method-return', data: data});
|
||||
}).catch(function(e) {
|
||||
response({event: 'method-return', err: e.message});
|
||||
});
|
||||
break;
|
||||
case 'generate-key-pair':
|
||||
window.openpgp.generateKeyPair(msg.options).then(function(data) {
|
||||
data.key = data.key.toPacketlist();
|
||||
response({event: 'method-return', data: data});
|
||||
}).catch(function(e) {
|
||||
response({event: 'method-return', err: e.message});
|
||||
});
|
||||
break;
|
||||
case 'decrypt-key':
|
||||
try {
|
||||
msg.privateKey = packetlistCloneToKey(msg.privateKey);
|
||||
correct = msg.privateKey.decrypt(msg.password);
|
||||
if (correct) {
|
||||
data = msg.privateKey.toPacketlist();
|
||||
} else {
|
||||
err = 'Wrong password';
|
||||
}
|
||||
} catch (e) {
|
||||
err = e.message;
|
||||
}
|
||||
response({event: 'method-return', data: data, err: err});
|
||||
break;
|
||||
case 'decrypt-key-packet':
|
||||
try {
|
||||
msg.privateKey = packetlistCloneToKey(msg.privateKey);
|
||||
msg.keyIds = msg.keyIds.map(window.openpgp.Keyid.fromClone);
|
||||
correct = msg.privateKey.decryptKeyPacket(msg.keyIds, msg.password);
|
||||
if (correct) {
|
||||
data = msg.privateKey.toPacketlist();
|
||||
} else {
|
||||
err = 'Wrong password';
|
||||
}
|
||||
} catch (e) {
|
||||
err = e.message;
|
||||
}
|
||||
response({event: 'method-return', data: data, err: err});
|
||||
openpgp.crypto.random.randomBuffer.set(msg.buf);
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new Error('Unknown Worker Event.');
|
||||
if (typeof openpgp[msg.event] !== 'function') {
|
||||
throw new Error('Unknown Worker Event');
|
||||
}
|
||||
|
||||
// parse cloned packets
|
||||
openpgp[msg.event](openpgp.packet.clone.parseClonedPackets(options, msg.event)).then(function(data) {
|
||||
// clone packets (for web worker structured cloning algorithm)
|
||||
response({ event:'method-return', data:openpgp.packet.clone.clonePackets(data) });
|
||||
}).catch(function(e) {
|
||||
response({ event:'method-return', err:e.message });
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
function response(event) {
|
||||
if (window.openpgp.crypto.random.randomBuffer.size < MIN_SIZE_RANDOM_BUFFER) {
|
||||
postMessage({event: 'request-seed'});
|
||||
if (openpgp.crypto.random.randomBuffer.size < MIN_SIZE_RANDOM_BUFFER) {
|
||||
self.postMessage({event: 'request-seed'});
|
||||
}
|
||||
postMessage(event);
|
||||
}
|
||||
|
||||
function packetlistCloneToKey(packetlistClone) {
|
||||
var packetlist = window.openpgp.packet.List.fromStructuredClone(packetlistClone);
|
||||
return new window.openpgp.key.Key(packetlist);
|
||||
}
|
||||
|
||||
function packetlistCloneToMessage(packetlistClone) {
|
||||
var packetlist = window.openpgp.packet.List.fromStructuredClone(packetlistClone);
|
||||
return new window.openpgp.message.Message(packetlist);
|
||||
self.postMessage(event, openpgp.util.getTransferables.call(openpgp.util, event.data));
|
||||
}
|
||||
},{}]},{},[1]);
|
||||
|
|
2
dist/openpgp.worker.min.js
vendored
2
dist/openpgp.worker.min.js
vendored
|
@ -1 +1 @@
|
|||
/*! OpenPGPjs.org this is LGPL licensed code, see LICENSE/our website for more information.- v1.5.7 - 2016-01-31 */!function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c?c:a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a,b,c){function d(a){window.openpgp.crypto.random.randomBuffer.size<g&&postMessage({event:"request-seed"}),postMessage(a)}function e(a){var b=window.openpgp.packet.List.fromStructuredClone(a);return new window.openpgp.key.Key(b)}function f(a){var b=window.openpgp.packet.List.fromStructuredClone(a);return new window.openpgp.message.Message(b)}window={},Function.prototype.bind||(Function.prototype.bind=function(a){if("function"!=typeof this)throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");var b=Array.prototype.slice.call(arguments,1),c=this,d=function(){},e=function(){return c.apply(this instanceof d&&a?this:a,b.concat(Array.prototype.slice.call(arguments)))};return d.prototype=this.prototype,e.prototype=new d,e}),importScripts("openpgp.min.js");var g=4e4,h=6e4;window.openpgp.crypto.random.randomBuffer.init(h),self.onmessage=function(a){var b=null,c=null,g=a.data,h=!1;switch(g.event){case"configure":for(var i in g.config)window.openpgp.config[i]=g.config[i];break;case"seed-random":g.buf instanceof Uint8Array||(g.buf=new Uint8Array(g.buf)),window.openpgp.crypto.random.randomBuffer.set(g.buf);break;case"encrypt-message":g.keys.length||(g.keys=[g.keys]),g.keys=g.keys.map(e),window.openpgp.encryptMessage(g.keys,g.text).then(function(a){d({event:"method-return",data:a})})["catch"](function(a){d({event:"method-return",err:a.message})});break;case"sign-and-encrypt-message":g.publicKeys.length||(g.publicKeys=[g.publicKeys]),g.publicKeys=g.publicKeys.map(e),g.privateKey=e(g.privateKey),window.openpgp.signAndEncryptMessage(g.publicKeys,g.privateKey,g.text).then(function(a){d({event:"method-return",data:a})})["catch"](function(a){d({event:"method-return",err:a.message})});break;case"decrypt-message":g.privateKey=e(g.privateKey),g.message=f(g.message.packets),window.openpgp.decryptMessage(g.privateKey,g.message).then(function(a){d({event:"method-return",data:a})})["catch"](function(a){d({event:"method-return",err:a.message})});break;case"decrypt-and-verify-message":g.privateKey=e(g.privateKey),g.publicKeys.length||(g.publicKeys=[g.publicKeys]),g.publicKeys=g.publicKeys.map(e),g.message=f(g.message.packets),window.openpgp.decryptAndVerifyMessage(g.privateKey,g.publicKeys,g.message).then(function(a){d({event:"method-return",data:a})})["catch"](function(a){d({event:"method-return",err:a.message})});break;case"sign-clear-message":g.privateKeys=g.privateKeys.map(e),window.openpgp.signClearMessage(g.privateKeys,g.text).then(function(a){d({event:"method-return",data:a})})["catch"](function(a){d({event:"method-return",err:a.message})});break;case"verify-clear-signed-message":g.publicKeys.length||(g.publicKeys=[g.publicKeys]),g.publicKeys=g.publicKeys.map(e);var j=window.openpgp.packet.List.fromStructuredClone(g.message.packets);g.message=new window.openpgp.cleartext.CleartextMessage(g.message.text,j),window.openpgp.verifyClearSignedMessage(g.publicKeys,g.message).then(function(a){d({event:"method-return",data:a})})["catch"](function(a){d({event:"method-return",err:a.message})});break;case"generate-key-pair":window.openpgp.generateKeyPair(g.options).then(function(a){a.key=a.key.toPacketlist(),d({event:"method-return",data:a})})["catch"](function(a){d({event:"method-return",err:a.message})});break;case"decrypt-key":try{g.privateKey=e(g.privateKey),h=g.privateKey.decrypt(g.password),h?b=g.privateKey.toPacketlist():c="Wrong password"}catch(k){c=k.message}d({event:"method-return",data:b,err:c});break;case"decrypt-key-packet":try{g.privateKey=e(g.privateKey),g.keyIds=g.keyIds.map(window.openpgp.Keyid.fromClone),h=g.privateKey.decryptKeyPacket(g.keyIds,g.password),h?b=g.privateKey.toPacketlist():c="Wrong password"}catch(k){c=k.message}d({event:"method-return",data:b,err:c});break;default:throw new Error("Unknown Worker Event.")}}},{}]},{},[1]);
|
||||
/*! OpenPGPjs.org this is LGPL licensed code, see LICENSE/our website for more information.- v2.0.0 - 2016-02-13 */!function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c?c:a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a,b,c){function d(a){e.crypto.random.randomBuffer.size<f&&self.postMessage({event:"request-seed"}),self.postMessage(a,e.util.getTransferables.call(e.util,a.data))}self.window={},Function.prototype.bind||(Function.prototype.bind=function(a){if("function"!=typeof this)throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");var b=Array.prototype.slice.call(arguments,1),c=this,d=function(){},e=function(){return c.apply(this instanceof d&&a?this:a,b.concat(Array.prototype.slice.call(arguments)))};return d.prototype=this.prototype,e.prototype=new d,e}),importScripts("openpgp.min.js");var e=window.openpgp,f=4e4,g=6e4;e.crypto.random.randomBuffer.init(g),self.onmessage=function(a){var b=a.data||{},c=b.options||{};switch(b.event){case"configure":for(var f in b.config)e.config[f]=b.config[f];break;case"seed-random":b.buf instanceof Uint8Array||(b.buf=new Uint8Array(b.buf)),e.crypto.random.randomBuffer.set(b.buf);break;default:if("function"!=typeof e[b.event])throw new Error("Unknown Worker Event");e[b.event](e.packet.clone.parseClonedPackets(c,b.event)).then(function(a){d({event:"method-return",data:e.packet.clone.clonePackets(a)})})["catch"](function(a){d({event:"method-return",err:a.message})})}}},{}]},{},[1]);
|
2
npm-shrinkwrap.json
generated
2
npm-shrinkwrap.json
generated
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "openpgp",
|
||||
"version": "2.0.0-dev",
|
||||
"version": "2.0.0",
|
||||
"dependencies": {
|
||||
"asmcrypto-lite": {
|
||||
"version": "1.0.1",
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "openpgp",
|
||||
"description": "OpenPGP.js is a Javascript implementation of the OpenPGP protocol. This is defined in RFC 4880.",
|
||||
"version": "2.0.0-dev",
|
||||
"version": "2.0.0",
|
||||
"license": "LGPL-3.0+",
|
||||
"homepage": "http://openpgpjs.org/",
|
||||
"engines": {
|
||||
|
|
Loading…
Reference in New Issue
Block a user