commit
67de70fa01
|
@ -192,12 +192,6 @@ module.exports = function(grunt) {
|
||||||
src: ['mocha/mocha.css', 'mocha/mocha.js'],
|
src: ['mocha/mocha.css', 'mocha/mocha.js'],
|
||||||
dest: 'test/lib/'
|
dest: 'test/lib/'
|
||||||
},
|
},
|
||||||
bzip2: {
|
|
||||||
expand: true,
|
|
||||||
cwd: 'node_modules/compressjs/bin/',
|
|
||||||
src: ['bzip2.build.js'],
|
|
||||||
dest: 'src/compression/'
|
|
||||||
},
|
|
||||||
openpgp_compat: {
|
openpgp_compat: {
|
||||||
expand: true,
|
expand: true,
|
||||||
cwd: 'dist/',
|
cwd: 'dist/',
|
||||||
|
@ -305,7 +299,7 @@ module.exports = function(grunt) {
|
||||||
// Build tasks
|
// Build tasks
|
||||||
grunt.registerTask('version', ['replace:openpgp']);
|
grunt.registerTask('version', ['replace:openpgp']);
|
||||||
grunt.registerTask('replace_min', ['replace:openpgp_min', 'replace:worker_min']);
|
grunt.registerTask('replace_min', ['replace:openpgp_min', 'replace:worker_min']);
|
||||||
grunt.registerTask('build', ['copy:bzip2', 'browserify:openpgp', 'browserify:worker', 'version', 'uglify', 'replace_min']);
|
grunt.registerTask('build', ['browserify:openpgp', 'browserify:worker', 'version', 'uglify', 'replace_min']);
|
||||||
grunt.registerTask('documentation', ['jsdoc']);
|
grunt.registerTask('documentation', ['jsdoc']);
|
||||||
grunt.registerTask('default', ['build']);
|
grunt.registerTask('default', ['build']);
|
||||||
// Test/Dev tasks
|
// Test/Dev tasks
|
||||||
|
|
|
@ -259,13 +259,12 @@ ciphertext = await openpgp.encrypt(options); // use ciphertext
|
||||||
Or, override the config to enable compression:
|
Or, override the config to enable compression:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
openpgp.config.compression = openpgp.enums.compression.zip
|
openpgp.config.compression = openpgp.enums.compression.zlib
|
||||||
```
|
```
|
||||||
|
|
||||||
Where the value can be any of:
|
Where the value can be any of:
|
||||||
* `openpgp.enums.compression.zip`
|
* `openpgp.enums.compression.zip`
|
||||||
* `openpgp.enums.compression.zlib`
|
* `openpgp.enums.compression.zlib`
|
||||||
* `openpgp.enums.compression.bzip2`
|
|
||||||
|
|
||||||
|
|
||||||
#### Streaming encrypt *Uint8Array* data with a password
|
#### Streaming encrypt *Uint8Array* data with a password
|
||||||
|
|
40
npm-shrinkwrap.json
generated
40
npm-shrinkwrap.json
generated
|
@ -169,7 +169,8 @@
|
||||||
"amdefine": {
|
"amdefine": {
|
||||||
"version": "1.0.1",
|
"version": "1.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/amdefine/-/amdefine-1.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/amdefine/-/amdefine-1.0.1.tgz",
|
||||||
"integrity": "sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU="
|
"integrity": "sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU=",
|
||||||
|
"dev": true
|
||||||
},
|
},
|
||||||
"ansi-escapes": {
|
"ansi-escapes": {
|
||||||
"version": "3.0.0",
|
"version": "3.0.0",
|
||||||
|
@ -1829,24 +1830,6 @@
|
||||||
"integrity": "sha512-BFnaq5ZOGcDN7FlrtBT4xxkgIToalIIxwjxLWVJ8bGTpe1LroqMiqQXdA7ygc7CRvaYS+9zfPGFnJqFSayx+AA==",
|
"integrity": "sha512-BFnaq5ZOGcDN7FlrtBT4xxkgIToalIIxwjxLWVJ8bGTpe1LroqMiqQXdA7ygc7CRvaYS+9zfPGFnJqFSayx+AA==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"compressjs": {
|
|
||||||
"version": "github:openpgpjs/compressjs#ce5ccbede61f075926081e29573c8a79ddf10d88",
|
|
||||||
"from": "github:openpgpjs/compressjs",
|
|
||||||
"requires": {
|
|
||||||
"amdefine": "~1.0.0",
|
|
||||||
"commander": "~2.8.1"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"commander": {
|
|
||||||
"version": "2.8.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/commander/-/commander-2.8.1.tgz",
|
|
||||||
"integrity": "sha1-Br42f+v9oMMwqh4qBy09yXYkJdQ=",
|
|
||||||
"requires": {
|
|
||||||
"graceful-readlink": ">= 1.0.0"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"concat-map": {
|
"concat-map": {
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
|
||||||
|
@ -6547,6 +6530,23 @@
|
||||||
"https-proxy-agent": "^1.0.0"
|
"https-proxy-agent": "^1.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"seek-bzip": {
|
||||||
|
"version": "github:openpgpjs/seek-bzip#3aca608ffedc055a1da1d898ecb244804ef32209",
|
||||||
|
"from": "github:openpgpjs/seek-bzip",
|
||||||
|
"requires": {
|
||||||
|
"commander": "~2.8.1"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"commander": {
|
||||||
|
"version": "2.8.1",
|
||||||
|
"resolved": "http://registry.npmjs.org/commander/-/commander-2.8.1.tgz",
|
||||||
|
"integrity": "sha1-Br42f+v9oMMwqh4qBy09yXYkJdQ=",
|
||||||
|
"requires": {
|
||||||
|
"graceful-readlink": ">= 1.0.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"semver": {
|
"semver": {
|
||||||
"version": "5.4.1",
|
"version": "5.4.1",
|
||||||
"resolved": "https://registry.npmjs.org/semver/-/semver-5.4.1.tgz",
|
"resolved": "https://registry.npmjs.org/semver/-/semver-5.4.1.tgz",
|
||||||
|
@ -7417,7 +7417,7 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"web-stream-tools": {
|
"web-stream-tools": {
|
||||||
"version": "github:openpgpjs/web-stream-tools#37c3542b11455856012b5ad87c39088457e2b3a1",
|
"version": "github:openpgpjs/web-stream-tools#9ab800d46add161db496506d67338202ad0114ce",
|
||||||
"from": "github:openpgpjs/web-stream-tools"
|
"from": "github:openpgpjs/web-stream-tools"
|
||||||
},
|
},
|
||||||
"websocket-driver": {
|
"websocket-driver": {
|
||||||
|
|
|
@ -77,12 +77,12 @@
|
||||||
"asn1.js": "^5.0.0",
|
"asn1.js": "^5.0.0",
|
||||||
"bn.js": "^4.11.8",
|
"bn.js": "^4.11.8",
|
||||||
"buffer": "^5.0.8",
|
"buffer": "^5.0.8",
|
||||||
"compressjs": "github:openpgpjs/compressjs",
|
|
||||||
"elliptic": "github:openpgpjs/elliptic",
|
"elliptic": "github:openpgpjs/elliptic",
|
||||||
"hash.js": "^1.1.3",
|
"hash.js": "^1.1.3",
|
||||||
"node-fetch": "^2.1.2",
|
"node-fetch": "^2.1.2",
|
||||||
"node-localstorage": "~1.3.0",
|
"node-localstorage": "~1.3.0",
|
||||||
"pako": "^1.0.6",
|
"pako": "^1.0.6",
|
||||||
|
"seek-bzip": "github:openpgpjs/seek-bzip",
|
||||||
"web-stream-tools": "github:openpgpjs/web-stream-tools"
|
"web-stream-tools": "github:openpgpjs/web-stream-tools"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|
|
@ -25,11 +25,11 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import pako from 'pako';
|
import pako from 'pako';
|
||||||
|
import Bunzip from 'seek-bzip';
|
||||||
import stream from 'web-stream-tools';
|
import stream from 'web-stream-tools';
|
||||||
import config from '../config';
|
import config from '../config';
|
||||||
import enums from '../enums';
|
import enums from '../enums';
|
||||||
import util from '../util';
|
import util from '../util';
|
||||||
import Bzip2 from '../compression/bzip2.build.js';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of the Compressed Data Packet (Tag 8)
|
* Implementation of the Compressed Data Packet (Tag 8)
|
||||||
|
@ -103,7 +103,7 @@ Compressed.prototype.write = function () {
|
||||||
Compressed.prototype.decompress = async function () {
|
Compressed.prototype.decompress = async function () {
|
||||||
|
|
||||||
if (!decompress_fns[this.algorithm]) {
|
if (!decompress_fns[this.algorithm]) {
|
||||||
throw new Error("Compression algorithm unknown :" + this.algorithm);
|
throw new Error(this.algorithm + ' decompression not supported');
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.packets.read(decompress_fns[this.algorithm](this.compressed));
|
await this.packets.read(decompress_fns[this.algorithm](this.compressed));
|
||||||
|
@ -115,7 +115,7 @@ Compressed.prototype.decompress = async function () {
|
||||||
Compressed.prototype.compress = function () {
|
Compressed.prototype.compress = function () {
|
||||||
|
|
||||||
if (!compress_fns[this.algorithm]) {
|
if (!compress_fns[this.algorithm]) {
|
||||||
throw new Error("Compression algorithm unknown :" + this.algorithm);
|
throw new Error(this.algorithm + ' compression not supported');
|
||||||
}
|
}
|
||||||
|
|
||||||
this.compressed = compress_fns[this.algorithm](this.packets.write());
|
this.compressed = compress_fns[this.algorithm](this.packets.write());
|
||||||
|
@ -160,30 +160,24 @@ let compress_fns;
|
||||||
let decompress_fns;
|
let decompress_fns;
|
||||||
if (nodeZlib) { // Use Node native zlib for DEFLATE compression/decompression
|
if (nodeZlib) { // Use Node native zlib for DEFLATE compression/decompression
|
||||||
compress_fns = {
|
compress_fns = {
|
||||||
// eslint-disable-next-line no-sync
|
|
||||||
zip: node_zlib(nodeZlib.createDeflateRaw, { level: config.deflate_level }),
|
zip: node_zlib(nodeZlib.createDeflateRaw, { level: config.deflate_level }),
|
||||||
// eslint-disable-next-line no-sync
|
zlib: node_zlib(nodeZlib.createDeflate, { level: config.deflate_level })
|
||||||
zlib: node_zlib(nodeZlib.createDeflate, { level: config.deflate_level }),
|
|
||||||
bzip2: bzip2(Bzip2.compressFile)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
decompress_fns = {
|
decompress_fns = {
|
||||||
// eslint-disable-next-line no-sync
|
|
||||||
zip: node_zlib(nodeZlib.createInflateRaw),
|
zip: node_zlib(nodeZlib.createInflateRaw),
|
||||||
// eslint-disable-next-line no-sync
|
|
||||||
zlib: node_zlib(nodeZlib.createInflate),
|
zlib: node_zlib(nodeZlib.createInflate),
|
||||||
bzip2: bzip2(Bzip2.decompressFile)
|
bzip2: bzip2(Bunzip.decode)
|
||||||
};
|
};
|
||||||
} else { // Use JS fallbacks
|
} else { // Use JS fallbacks
|
||||||
compress_fns = {
|
compress_fns = {
|
||||||
zip: pako_zlib(pako.Deflate, { raw: true, level: config.deflate_level }),
|
zip: pako_zlib(pako.Deflate, { raw: true, level: config.deflate_level }),
|
||||||
zlib: pako_zlib(pako.Deflate, { level: config.deflate_level }),
|
zlib: pako_zlib(pako.Deflate, { level: config.deflate_level })
|
||||||
bzip2: bzip2(Bzip2.compressFile)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
decompress_fns = {
|
decompress_fns = {
|
||||||
zip: pako_zlib(pako.Inflate, { raw: true }),
|
zip: pako_zlib(pako.Inflate, { raw: true }),
|
||||||
zlib: pako_zlib(pako.Inflate),
|
zlib: pako_zlib(pako.Inflate),
|
||||||
bzip2: bzip2(Bzip2.decompressFile)
|
bzip2: bzip2(Bunzip.decode)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -309,6 +309,9 @@ function withCompression(tests) {
|
||||||
|
|
||||||
compressionTypes.forEach(function (compression) {
|
compressionTypes.forEach(function (compression) {
|
||||||
const compressionName = openpgp.enums.read(openpgp.enums.compression, compression);
|
const compressionName = openpgp.enums.read(openpgp.enums.compression, compression);
|
||||||
|
if (compressionName === 'bzip2') {
|
||||||
|
return; // bzip2 compression is not supported.
|
||||||
|
}
|
||||||
const group = `compression - ${compressionName}`;
|
const group = `compression - ${compressionName}`;
|
||||||
|
|
||||||
describe(group, function() {
|
describe(group, function() {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user