mirror of
https://github.com/openpgpjs/openpgpjs.git
synced 2025-09-14 13:10:11 +00:00
Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
80c433689b | ||
![]() |
b3e4e36d10 | ||
![]() |
bccb2441b9 | ||
![]() |
ce0381c170 | ||
![]() |
dfbc5ea5a6 | ||
![]() |
9b6aaa08d4 | ||
![]() |
aaa4c52374 | ||
![]() |
edd415c958 | ||
![]() |
1bfce40f61 | ||
![]() |
a0726617e5 |
29
Gruntfile.js
29
Gruntfile.js
@ -51,7 +51,8 @@ module.exports = function(grunt) {
|
|||||||
ignore: ['*.min.js'],
|
ignore: ['*.min.js'],
|
||||||
presets: ["es2015"]
|
presets: ["es2015"]
|
||||||
}]
|
}]
|
||||||
]
|
],
|
||||||
|
plugin: [ 'browserify-derequire' ]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
openpgp_debug: {
|
openpgp_debug: {
|
||||||
@ -69,7 +70,8 @@ module.exports = function(grunt) {
|
|||||||
ignore: ['*.min.js'],
|
ignore: ['*.min.js'],
|
||||||
presets: ["es2015"]
|
presets: ["es2015"]
|
||||||
}]
|
}]
|
||||||
]
|
],
|
||||||
|
plugin: [ 'browserify-derequire' ]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
worker: {
|
worker: {
|
||||||
@ -77,11 +79,6 @@ module.exports = function(grunt) {
|
|||||||
'dist/openpgp.worker.js': [ './src/worker/worker.js' ]
|
'dist/openpgp.worker.js': [ './src/worker/worker.js' ]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
worker_min: {
|
|
||||||
files: {
|
|
||||||
'dist/openpgp.worker.min.js': [ './src/worker/worker.js' ]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
unittests: {
|
unittests: {
|
||||||
files: {
|
files: {
|
||||||
'test/lib/unittests-bundle.js': [ './test/unittests.js' ]
|
'test/lib/unittests-bundle.js': [ './test/unittests.js' ]
|
||||||
@ -108,12 +105,20 @@ module.exports = function(grunt) {
|
|||||||
to: 'OpenPGP.js v<%= pkg.version %>'
|
to: 'OpenPGP.js v<%= pkg.version %>'
|
||||||
}]
|
}]
|
||||||
},
|
},
|
||||||
|
openpgp_min: {
|
||||||
|
src: ['dist/openpgp.min.js'],
|
||||||
|
dest: ['dist/openpgp.min.js'],
|
||||||
|
replacements: [{
|
||||||
|
from: "openpgp.worker.js",
|
||||||
|
to: "openpgp.worker.min.js"
|
||||||
|
}]
|
||||||
|
},
|
||||||
worker_min: {
|
worker_min: {
|
||||||
src: ['dist/openpgp.worker.min.js'],
|
src: ['dist/openpgp.worker.min.js'],
|
||||||
dest: ['dist/openpgp.worker.min.js'],
|
dest: ['dist/openpgp.worker.min.js'],
|
||||||
replacements: [{
|
replacements: [{
|
||||||
from: "importScripts('openpgp.js')",
|
from: "openpgp.js",
|
||||||
to: "importScripts('openpgp.min.js')"
|
to: "openpgp.min.js"
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -121,7 +126,7 @@ module.exports = function(grunt) {
|
|||||||
openpgp: {
|
openpgp: {
|
||||||
files: {
|
files: {
|
||||||
'dist/openpgp.min.js' : [ 'dist/openpgp.js' ],
|
'dist/openpgp.min.js' : [ 'dist/openpgp.js' ],
|
||||||
'dist/openpgp.worker.min.js' : [ 'dist/openpgp.worker.min.js' ]
|
'dist/openpgp.worker.min.js' : [ 'dist/openpgp.worker.js' ]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
options: {
|
options: {
|
||||||
@ -290,7 +295,9 @@ module.exports = function(grunt) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Build tasks
|
// Build tasks
|
||||||
grunt.registerTask('default', ['clean', 'copy:zlib', 'browserify', 'replace', 'uglify']);
|
grunt.registerTask('version', ['replace:openpgp', 'replace:openpgp_debug']);
|
||||||
|
grunt.registerTask('replace_min', ['replace:openpgp_min', 'replace:worker_min']);
|
||||||
|
grunt.registerTask('default', ['clean', 'copy:zlib', 'browserify', 'version', 'uglify', 'replace_min']);
|
||||||
grunt.registerTask('documentation', ['jsdoc']);
|
grunt.registerTask('documentation', ['jsdoc']);
|
||||||
// Test/Dev tasks
|
// Test/Dev tasks
|
||||||
grunt.registerTask('test', ['jshint', 'jscs', 'mochaTest']);
|
grunt.registerTask('test', ['jshint', 'jscs', 'mochaTest']);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "openpgp",
|
"name": "openpgp",
|
||||||
"version": "2.3.2",
|
"version": "2.3.5",
|
||||||
"license": "LGPL-3.0+",
|
"license": "LGPL-3.0+",
|
||||||
"homepage": "http://openpgpjs.org/",
|
"homepage": "http://openpgpjs.org/",
|
||||||
"authors": [
|
"authors": [
|
||||||
|
787
dist/openpgp.js
vendored
787
dist/openpgp.js
vendored
File diff suppressed because it is too large
Load Diff
20
dist/openpgp.min.js
vendored
20
dist/openpgp.min.js
vendored
File diff suppressed because one or more lines are too long
10
dist/openpgp.worker.js
vendored
10
dist/openpgp.worker.js
vendored
@ -45,7 +45,7 @@ self.onmessage = function(event) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
delegate(msg.event, msg.options || {});
|
delegate(msg.id, msg.event, msg.options || {});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -76,18 +76,18 @@ function seedRandom(buffer) {
|
|||||||
* @param {String} method The public api function to be delegated to the worker thread
|
* @param {String} method The public api function to be delegated to the worker thread
|
||||||
* @param {Object} options The api function's options
|
* @param {Object} options The api function's options
|
||||||
*/
|
*/
|
||||||
function delegate(method, options) {
|
function delegate(id, method, options) {
|
||||||
if (typeof openpgp[method] !== 'function') {
|
if (typeof openpgp[method] !== 'function') {
|
||||||
response({ event:'method-return', err:'Unknown Worker Event' });
|
response({ id:id, event:'method-return', err:'Unknown Worker Event' });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// parse cloned packets
|
// parse cloned packets
|
||||||
options = openpgp.packet.clone.parseClonedPackets(options, method);
|
options = openpgp.packet.clone.parseClonedPackets(options, method);
|
||||||
openpgp[method](options).then(function(data) {
|
openpgp[method](options).then(function(data) {
|
||||||
// clone packets (for web worker structured cloning algorithm)
|
// clone packets (for web worker structured cloning algorithm)
|
||||||
response({ event:'method-return', data:openpgp.packet.clone.clonePackets(data) });
|
response({ id:id, event:'method-return', data:openpgp.packet.clone.clonePackets(data) });
|
||||||
}).catch(function(e) {
|
}).catch(function(e) {
|
||||||
response({ event:'method-return', err:e.message });
|
response({ id:id, event:'method-return', err:e.message });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
dist/openpgp.worker.min.js
vendored
2
dist/openpgp.worker.min.js
vendored
@ -1 +1 @@
|
|||||||
/*! OpenPGP.js v2.3.2 - 2016-06-08 - this is LGPL licensed code, see LICENSE/our website http://openpgpjs.org/ for more information. */!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){for(var b in a)h.config[b]=a[b]}function e(a){a instanceof Uint8Array||(a=new Uint8Array(a)),h.crypto.random.randomBuffer.set(a)}function f(a,b){return"function"!=typeof h[a]?void g({event:"method-return",err:"Unknown Worker Event"}):(b=h.packet.clone.parseClonedPackets(b,a),void h[a](b).then(function(a){g({event:"method-return",data:h.packet.clone.clonePackets(a)})})["catch"](function(a){g({event:"method-return",err:a.message})}))}function g(a){h.crypto.random.randomBuffer.size<i&&self.postMessage({event:"request-seed"}),self.postMessage(a,h.util.getTransferables.call(h.util,a.data))}self.window={},importScripts("openpgp.min.js");var h=window.openpgp,i=4e4,j=6e4;h.crypto.random.randomBuffer.init(j),self.onmessage=function(a){var b=a.data||{};switch(b.event){case"configure":d(b.config);break;case"seed-random":e(b.buf);break;default:f(b.event,b.options||{})}}},{}]},{},[1]);
|
/*! OpenPGP.js v2.3.5 - 2016-10-26 - this is LGPL licensed code, see LICENSE/our website http://openpgpjs.org/ for more information. */!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){for(var b in a)h.config[b]=a[b]}function e(a){a instanceof Uint8Array||(a=new Uint8Array(a)),h.crypto.random.randomBuffer.set(a)}function f(a,b,c){return"function"!=typeof h[b]?void g({id:a,event:"method-return",err:"Unknown Worker Event"}):(c=h.packet.clone.parseClonedPackets(c,b),void h[b](c).then(function(b){g({id:a,event:"method-return",data:h.packet.clone.clonePackets(b)})})["catch"](function(b){g({id:a,event:"method-return",err:b.message})}))}function g(a){h.crypto.random.randomBuffer.size<i&&self.postMessage({event:"request-seed"}),self.postMessage(a,h.util.getTransferables.call(h.util,a.data))}self.window={},importScripts("openpgp.min.js");var h=window.openpgp,i=4e4,j=6e4;h.crypto.random.randomBuffer.init(j),self.onmessage=function(a){var b=a.data||{};switch(b.event){case"configure":d(b.config);break;case"seed-random":e(b.buf);break;default:f(b.id,b.event,b.options||{})}}},{}]},{},[1]);
|
2
npm-shrinkwrap.json
generated
2
npm-shrinkwrap.json
generated
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "openpgp",
|
"name": "openpgp",
|
||||||
"version": "2.3.2",
|
"version": "2.3.5",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"asmcrypto-lite": {
|
"asmcrypto-lite": {
|
||||||
"version": "1.1.0",
|
"version": "1.1.0",
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "openpgp",
|
"name": "openpgp",
|
||||||
"description": "OpenPGP.js is a Javascript implementation of the OpenPGP protocol. This is defined in RFC 4880.",
|
"description": "OpenPGP.js is a Javascript implementation of the OpenPGP protocol. This is defined in RFC 4880.",
|
||||||
"version": "2.3.2",
|
"version": "2.3.5",
|
||||||
"license": "LGPL-3.0+",
|
"license": "LGPL-3.0+",
|
||||||
"homepage": "http://openpgpjs.org/",
|
"homepage": "http://openpgpjs.org/",
|
||||||
"engines": {
|
"engines": {
|
||||||
@ -35,6 +35,7 @@
|
|||||||
"asmcrypto-lite": "^1.0.0",
|
"asmcrypto-lite": "^1.0.0",
|
||||||
"babel-preset-es2015": "^6.3.13",
|
"babel-preset-es2015": "^6.3.13",
|
||||||
"babelify": "^7.2.0",
|
"babelify": "^7.2.0",
|
||||||
|
"browserify-derequire": "^0.9.4",
|
||||||
"chai": "~3.5.0",
|
"chai": "~3.5.0",
|
||||||
"es6-promise": "^3.1.2",
|
"es6-promise": "^3.1.2",
|
||||||
"grunt": "~0.4.5",
|
"grunt": "~0.4.5",
|
||||||
|
@ -321,6 +321,9 @@ Message.prototype.sign = function(privateKeys) {
|
|||||||
}
|
}
|
||||||
onePassSig.publicKeyAlgorithm = signingKeyPacket.algorithm;
|
onePassSig.publicKeyAlgorithm = signingKeyPacket.algorithm;
|
||||||
onePassSig.signingKeyId = signingKeyPacket.getKeyId();
|
onePassSig.signingKeyId = signingKeyPacket.getKeyId();
|
||||||
|
if (i === privateKeys.length - 1) {
|
||||||
|
onePassSig.flags = 1;
|
||||||
|
}
|
||||||
packetlist.push(onePassSig);
|
packetlist.push(onePassSig);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -269,6 +269,7 @@ SecretKey.prototype.decrypt = function (passphrase) {
|
|||||||
}
|
}
|
||||||
this.mpi = this.mpi.concat(parsedMPI);
|
this.mpi = this.mpi.concat(parsedMPI);
|
||||||
this.isDecrypted = true;
|
this.isDecrypted = true;
|
||||||
|
this.encrypted = null;
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -39,13 +39,24 @@ export default function AsyncProxy({ path='openpgp.worker.js', worker, config }
|
|||||||
throw new Error('Unhandled error in openpgp worker: ' + e.message + ' (' + e.filename + ':' + e.lineno + ')');
|
throw new Error('Unhandled error in openpgp worker: ' + e.message + ' (' + e.filename + ':' + e.lineno + ')');
|
||||||
};
|
};
|
||||||
this.seedRandom(INITIAL_RANDOM_SEED);
|
this.seedRandom(INITIAL_RANDOM_SEED);
|
||||||
// FIFO
|
|
||||||
this.tasks = [];
|
|
||||||
if (config) {
|
if (config) {
|
||||||
this.worker.postMessage({ event:'configure', config });
|
this.worker.postMessage({ event:'configure', config });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Cannot rely on task order being maintained, use object keyed by request ID to track tasks
|
||||||
|
this.tasks = {};
|
||||||
|
this.currentID = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get new request ID
|
||||||
|
* @return {integer} New unique request ID
|
||||||
|
*/
|
||||||
|
AsyncProxy.prototype.getID = function() {
|
||||||
|
return this.currentID++;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Message handling
|
* Message handling
|
||||||
*/
|
*/
|
||||||
@ -55,11 +66,12 @@ AsyncProxy.prototype.onMessage = function(event) {
|
|||||||
case 'method-return':
|
case 'method-return':
|
||||||
if (msg.err) {
|
if (msg.err) {
|
||||||
// fail
|
// fail
|
||||||
this.tasks.shift().reject(new Error(msg.err));
|
this.tasks[msg.id].reject(new Error(msg.err));
|
||||||
} else {
|
} else {
|
||||||
// success
|
// success
|
||||||
this.tasks.shift().resolve(msg.data);
|
this.tasks[msg.id].resolve(msg.data);
|
||||||
}
|
}
|
||||||
|
delete this.tasks[msg.id];
|
||||||
break;
|
break;
|
||||||
case 'request-seed':
|
case 'request-seed':
|
||||||
this.seedRandom(RANDOM_SEED_REQUEST);
|
this.seedRandom(RANDOM_SEED_REQUEST);
|
||||||
@ -106,11 +118,13 @@ AsyncProxy.prototype.terminate = function() {
|
|||||||
* @return {Promise} see the corresponding public api functions for their return types
|
* @return {Promise} see the corresponding public api functions for their return types
|
||||||
*/
|
*/
|
||||||
AsyncProxy.prototype.delegate = function(method, options) {
|
AsyncProxy.prototype.delegate = function(method, options) {
|
||||||
|
const id = this.getID();
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
// clone packets (for web worker structured cloning algorithm)
|
// clone packets (for web worker structured cloning algorithm)
|
||||||
this.worker.postMessage({ event:method, options:packet.clone.clonePackets(options) }, util.getTransferables.call(util, options));
|
this.worker.postMessage({ id:id, event:method, options:packet.clone.clonePackets(options) }, util.getTransferables.call(util, options));
|
||||||
|
|
||||||
// remember to handle parsing cloned packets from worker
|
// remember to handle parsing cloned packets from worker
|
||||||
this.tasks.push({ resolve: data => resolve(packet.clone.parseClonedPackets(data, method)), reject });
|
this.tasks[id] = { resolve: data => resolve(packet.clone.parseClonedPackets(data, method)), reject };
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -44,7 +44,7 @@ self.onmessage = function(event) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
delegate(msg.event, msg.options || {});
|
delegate(msg.id, msg.event, msg.options || {});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -75,18 +75,18 @@ function seedRandom(buffer) {
|
|||||||
* @param {String} method The public api function to be delegated to the worker thread
|
* @param {String} method The public api function to be delegated to the worker thread
|
||||||
* @param {Object} options The api function's options
|
* @param {Object} options The api function's options
|
||||||
*/
|
*/
|
||||||
function delegate(method, options) {
|
function delegate(id, method, options) {
|
||||||
if (typeof openpgp[method] !== 'function') {
|
if (typeof openpgp[method] !== 'function') {
|
||||||
response({ event:'method-return', err:'Unknown Worker Event' });
|
response({ id:id, event:'method-return', err:'Unknown Worker Event' });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// parse cloned packets
|
// parse cloned packets
|
||||||
options = openpgp.packet.clone.parseClonedPackets(options, method);
|
options = openpgp.packet.clone.parseClonedPackets(options, method);
|
||||||
openpgp[method](options).then(function(data) {
|
openpgp[method](options).then(function(data) {
|
||||||
// clone packets (for web worker structured cloning algorithm)
|
// clone packets (for web worker structured cloning algorithm)
|
||||||
response({ event:'method-return', data:openpgp.packet.clone.clonePackets(data) });
|
response({ id:id, event:'method-return', data:openpgp.packet.clone.clonePackets(data) });
|
||||||
}).catch(function(e) {
|
}).catch(function(e) {
|
||||||
response({ event:'method-return', err:e.message });
|
response({ id:id, event:'method-return', err:e.message });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user