mirror of
https://github.com/openpgpjs/openpgpjs.git
synced 2025-11-23 22:15:52 +00:00
Use bufferless transforms
Don't pull the input stream as much while the output stream isn't being read yet. This should reduce memory usage somewhat when streaming.
This commit is contained in:
parent
9764b268b3
commit
afa7e083de
9
package-lock.json
generated
9
package-lock.json
generated
@ -16,7 +16,7 @@
|
||||
"@openpgp/jsdoc": "^4.0.4",
|
||||
"@openpgp/seek-bzip": "^1.0.5-git",
|
||||
"@openpgp/tweetnacl": "^1.0.4-2",
|
||||
"@openpgp/web-stream-tools": "~0.2.1",
|
||||
"@openpgp/web-stream-tools": "~0.3.0",
|
||||
"@rollup/plugin-alias": "^5.1.1",
|
||||
"@rollup/plugin-commonjs": "^28.0.9",
|
||||
"@rollup/plugin-node-resolve": "^16.0.3",
|
||||
@ -1429,11 +1429,10 @@
|
||||
"license": "Unlicense"
|
||||
},
|
||||
"node_modules/@openpgp/web-stream-tools": {
|
||||
"version": "0.2.1",
|
||||
"resolved": "https://registry.npmjs.org/@openpgp/web-stream-tools/-/web-stream-tools-0.2.1.tgz",
|
||||
"integrity": "sha512-gE6+8mVrpKOa9RurAP+TToUo/DCGLNfpnRiq/YuA5Dq/rUAVSeM6Ejrgl25qpRiOQb/qcGyM25m1l9eE4aPdfw==",
|
||||
"version": "0.3.0",
|
||||
"resolved": "https://registry.npmjs.org/@openpgp/web-stream-tools/-/web-stream-tools-0.3.0.tgz",
|
||||
"integrity": "sha512-WGCcIti5uAwySkdny5IJ975Vu6fS45LE9Ce3M7vylIWOZwzL4qFUFclskZ6JU7rQ1zgoze6CQ//QKFc/ML2uqw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 18.0.0"
|
||||
},
|
||||
|
||||
@ -70,7 +70,7 @@
|
||||
"@openpgp/jsdoc": "^4.0.4",
|
||||
"@openpgp/seek-bzip": "^1.0.5-git",
|
||||
"@openpgp/tweetnacl": "^1.0.4-2",
|
||||
"@openpgp/web-stream-tools": "~0.2.1",
|
||||
"@openpgp/web-stream-tools": "~0.3.0",
|
||||
"@rollup/plugin-alias": "^5.1.1",
|
||||
"@rollup/plugin-commonjs": "^28.0.9",
|
||||
"@rollup/plugin-node-resolve": "^16.0.3",
|
||||
|
||||
@ -988,12 +988,12 @@ AkLaG/AkATpuH+DMkYDmKbDLGgD+N4yuxXBJmBfC2IBe4J1S2Gg=
|
||||
format: 'object'
|
||||
});
|
||||
await loadStreamsPolyfill();
|
||||
const { signatures: [sigInfo] } = await openpgp.verify({
|
||||
const { data, signatures: [sigInfo] } = await openpgp.verify({
|
||||
verificationKeys: expiredKey,
|
||||
message: await openpgp.readMessage({ armoredMessage: stream.toStream(armoredMessage) }),
|
||||
config: { minRSABits: 1024 }
|
||||
|
||||
});
|
||||
await stream.readToEnd(data);
|
||||
await expect(sigInfo.verified).to.be.rejectedWith(/Primary key is expired/);
|
||||
});
|
||||
|
||||
@ -1019,11 +1019,12 @@ aMsUdQBgnPAcSGVsbG8gV29ybGQgOik=
|
||||
format: 'object'
|
||||
});
|
||||
await loadStreamsPolyfill();
|
||||
const { signatures: [sigInfo] } = await openpgp.verify({
|
||||
const { data, signatures: [sigInfo] } = await openpgp.verify({
|
||||
verificationKeys: expiredKey,
|
||||
message: await openpgp.readMessage({ armoredMessage: stream.toStream(armoredMessage) }),
|
||||
config: { minRSABits: 1024 }
|
||||
});
|
||||
await stream.readToEnd(data);
|
||||
await expect(sigInfo.verified).to.be.rejectedWith(/Primary key is expired/);
|
||||
});
|
||||
|
||||
@ -1049,11 +1050,12 @@ eSvSZutLuKKbidSYMLhWROPlwKc2GU2ws6PrLZAyCAel/lU=
|
||||
format: 'object'
|
||||
});
|
||||
await loadStreamsPolyfill();
|
||||
const { signatures: [sigInfo] } = await openpgp.verify({
|
||||
const { data, signatures: [sigInfo] } = await openpgp.verify({
|
||||
verificationKeys: expiredKey,
|
||||
message: await openpgp.readMessage({ armoredMessage: stream.toStream(armoredMessage) }),
|
||||
config: { minRSABits: 1024 }
|
||||
});
|
||||
await stream.readToEnd(data);
|
||||
expect(await sigInfo.verified).to.be.true;
|
||||
});
|
||||
|
||||
@ -1078,11 +1080,12 @@ eSvSZutLuKKbidSYMLhWROPlwKc2GU2ws6PrLZAyCAel/lU=
|
||||
date: key.keyPacket.created,
|
||||
format: 'object'
|
||||
});
|
||||
const { signatures: [sigInfo] } = await openpgp.verify({
|
||||
const { data, signatures: [sigInfo] } = await openpgp.verify({
|
||||
verificationKeys: expiredKey,
|
||||
message: await openpgp.readMessage({ armoredMessage }),
|
||||
config: { minRSABits: 1024 }
|
||||
});
|
||||
await stream.readToEnd(data);
|
||||
expect(await sigInfo.verified).to.be.true;
|
||||
});
|
||||
|
||||
|
||||
@ -223,10 +223,10 @@ import {
|
||||
} catch {}
|
||||
const webTextStream = new WebReadableStream<string>();
|
||||
const messageFromWebTextStream = await createMessage({ text: webTextStream });
|
||||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
|
||||
(await encrypt({ message: messageFromWebTextStream, passwords: 'password', format: 'armored' })) as WebStream<string>;
|
||||
messageFromWebTextStream.getText() as WebStream<string>;
|
||||
messageFromWebTextStream.getLiteralData() as WebStream<Uint8Array>;
|
||||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
|
||||
(await encrypt({ message: messageFromWebTextStream, passwords: 'password', format: 'armored' })) as WebStream<string>;
|
||||
|
||||
// Streaming - encrypt binary message (binary output)
|
||||
try {
|
||||
@ -237,10 +237,10 @@ import {
|
||||
} catch {}
|
||||
const webBinaryStream = new WebReadableStream<Uint8Array>();
|
||||
const messageFromWebBinaryStream = await createMessage({ binary: webBinaryStream });
|
||||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
|
||||
(await encrypt({ message: messageFromWebBinaryStream, passwords: 'password', format: 'binary' })) as WebStream<Uint8Array>;
|
||||
messageFromWebBinaryStream.getText() as WebStream<string>;
|
||||
messageFromWebBinaryStream.getLiteralData() as WebStream<Uint8Array>;
|
||||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
|
||||
(await encrypt({ message: messageFromWebBinaryStream, passwords: 'password', format: 'binary' })) as WebStream<Uint8Array>;
|
||||
|
||||
console.log('TypeScript definitions are correct');
|
||||
})().catch(e => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user