mirror of
https://github.com/openpgpjs/openpgpjs.git
synced 2025-11-23 22:15:52 +00:00
Switch from seek-bzip to unbzip2-stream (#1887)
To allow streaming decompression of bzip2 data.
This commit is contained in:
parent
04c59a297a
commit
1af590a417
43
package-lock.json
generated
43
package-lock.json
generated
@ -14,8 +14,8 @@
|
||||
"@noble/curves": "^1.9.7",
|
||||
"@noble/hashes": "^1.8.0",
|
||||
"@openpgp/jsdoc": "^4.0.4",
|
||||
"@openpgp/seek-bzip": "^1.0.5-git",
|
||||
"@openpgp/tweetnacl": "^1.0.4-2",
|
||||
"@openpgp/unbzip2-stream": "^2.0.0",
|
||||
"@openpgp/web-stream-tools": "~0.3.0",
|
||||
"@rollup/plugin-alias": "^5.1.1",
|
||||
"@rollup/plugin-commonjs": "^28.0.9",
|
||||
@ -1407,20 +1407,6 @@
|
||||
"node": ">=12.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@openpgp/seek-bzip": {
|
||||
"version": "1.0.5-git",
|
||||
"resolved": "https://registry.npmjs.org/@openpgp/seek-bzip/-/seek-bzip-1.0.5-git.tgz",
|
||||
"integrity": "sha512-1493w5yzXmAss9GEbNPYwX9UjROLfCTB8vjiTlT/HNzSH9b1FL4kJFH5iBV/+v6Ur5wlbCatGHinvqPeY0BwCw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"commander": "~2.8.1"
|
||||
},
|
||||
"bin": {
|
||||
"seek-bunzip": "bin/seek-bunzip",
|
||||
"seek-table": "bin/seek-bzip-table"
|
||||
}
|
||||
},
|
||||
"node_modules/@openpgp/tweetnacl": {
|
||||
"version": "1.0.4-2",
|
||||
"resolved": "https://registry.npmjs.org/@openpgp/tweetnacl/-/tweetnacl-1.0.4-2.tgz",
|
||||
@ -1428,6 +1414,13 @@
|
||||
"dev": true,
|
||||
"license": "Unlicense"
|
||||
},
|
||||
"node_modules/@openpgp/unbzip2-stream": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@openpgp/unbzip2-stream/-/unbzip2-stream-2.0.0.tgz",
|
||||
"integrity": "sha512-BK82KQDoqzuHpTDebSbH/DPqmACXzCiWbaaW4cwifG0ii9PjPImwthHIAI9F9DgOoS9RC4yGuKZ1Wu4XNYiBPQ==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@openpgp/web-stream-tools": {
|
||||
"version": "0.3.0",
|
||||
"resolved": "https://registry.npmjs.org/@openpgp/web-stream-tools/-/web-stream-tools-0.3.0.tgz",
|
||||
@ -4940,19 +4933,6 @@
|
||||
"node": ">=12.17"
|
||||
}
|
||||
},
|
||||
"node_modules/commander": {
|
||||
"version": "2.8.1",
|
||||
"resolved": "https://registry.npmjs.org/commander/-/commander-2.8.1.tgz",
|
||||
"integrity": "sha512-+pJLBFVk+9ZZdlAOB5WuIElVPPth47hILFkmGym57aq8kwxsowvByvB0DHs1vQAhyMZzdcpTtF0VDKGkSDR4ZQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"graceful-readlink": ">= 1.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.6.x"
|
||||
}
|
||||
},
|
||||
"node_modules/comment-parser": {
|
||||
"version": "1.4.1",
|
||||
"resolved": "https://registry.npmjs.org/comment-parser/-/comment-parser-1.4.1.tgz",
|
||||
@ -7584,13 +7564,6 @@
|
||||
"dev": true,
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/graceful-readlink": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/graceful-readlink/-/graceful-readlink-1.0.1.tgz",
|
||||
"integrity": "sha512-8tLu60LgxF6XpdbK8OW3FA+IfTNBn1ZHGHKF4KQbEeSkajYw5PlYJcKluntgegDPTg8UkHjpet1T82vk6TQ68w==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/grapheme-splitter": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmjs.org/grapheme-splitter/-/grapheme-splitter-1.0.4.tgz",
|
||||
|
||||
@ -68,8 +68,8 @@
|
||||
"@noble/curves": "^1.9.7",
|
||||
"@noble/hashes": "^1.8.0",
|
||||
"@openpgp/jsdoc": "^4.0.4",
|
||||
"@openpgp/seek-bzip": "^1.0.5-git",
|
||||
"@openpgp/tweetnacl": "^1.0.4-2",
|
||||
"@openpgp/unbzip2-stream": "^2.0.0",
|
||||
"@openpgp/web-stream-tools": "~0.3.0",
|
||||
"@rollup/plugin-alias": "^5.1.1",
|
||||
"@rollup/plugin-commonjs": "^28.0.9",
|
||||
|
||||
@ -28,8 +28,8 @@ const getChunkFileName = (chunkInfo, extension) => `[name].${extension}`;
|
||||
* by default. We want to preserve the module name instead.
|
||||
*/
|
||||
const setManualChunkName = chunkId => {
|
||||
if (chunkId.includes('seek-bzip')) {
|
||||
return 'seek-bzip';
|
||||
if (chunkId.includes('unbzip2-stream')) {
|
||||
return 'unbzip2-stream';
|
||||
} else if (chunkId.includes('argon2id')) {
|
||||
return 'argon2id';
|
||||
} else {
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
import { Inflate, Deflate, Zlib, Unzlib } from 'fflate';
|
||||
import { isArrayStream, fromAsync as streamFromAsync, parse as streamParse, readToEnd as streamReadToEnd } from '@openpgp/web-stream-tools';
|
||||
import { isArrayStream, toStream, fromAsync as streamFromAsync, parse as streamParse, readToEnd as streamReadToEnd } from '@openpgp/web-stream-tools';
|
||||
import enums from '../enums';
|
||||
import util from '../util';
|
||||
import defaultConfig from '../config';
|
||||
@ -212,8 +212,12 @@ function zlib(compressionStreamInstantiator, ZlibStreamedConstructor) {
|
||||
|
||||
function bzip2Decompress() {
|
||||
return async function(data) {
|
||||
const { decode: bunzipDecode } = await import('@openpgp/seek-bzip');
|
||||
return streamFromAsync(async () => bunzipDecode(await streamReadToEnd(data)));
|
||||
const { default: unbzip2Stream } = await import('@openpgp/unbzip2-stream');
|
||||
let decompressed = unbzip2Stream(toStream(data));
|
||||
if (isArrayStream(data)) {
|
||||
decompressed = await streamReadToEnd(decompressed);
|
||||
}
|
||||
return decompressed;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user