From b9bc83ca51c1560178da281f5b8f222deb264e9e Mon Sep 17 00:00:00 2001 From: Roger Qiu Date: Fri, 11 Aug 2023 17:47:55 +1000 Subject: [PATCH 1/7] fix: removed dummy bench --- benches/dummy.ts | 30 ------------------------------ benches/index.ts | 2 -- 2 files changed, 32 deletions(-) delete mode 100644 benches/dummy.ts diff --git a/benches/dummy.ts b/benches/dummy.ts deleted file mode 100644 index f935ecd1..00000000 --- a/benches/dummy.ts +++ /dev/null @@ -1,30 +0,0 @@ -import path from 'path'; -import b from 'benny'; -import { suiteCommon } from './utils'; - -async function main() { - // Running benchmark - const summary = b.suite( - path.basename(__filename, path.extname(__filename)), - b.add('add 1 + 1', async () => { - return 1 + 1; - }), - b.add('subtract 1 - 1', async () => { - return 1 - 1; - }), - b.add('multiply 1 * 1', async () => { - return 1 * 1; - }), - b.add('divide 1 / 1', async () => { - return 1 / 1; - }), - ...suiteCommon, - ); - return summary; -} - -if (require.main === module) { - void main(); -} - -export default main; diff --git a/benches/index.ts b/benches/index.ts index a563b12c..6c712d48 100644 --- a/benches/index.ts +++ b/benches/index.ts @@ -4,13 +4,11 @@ import fs from 'fs'; import path from 'path'; import si from 'systeminformation'; import Stream1KB from './stream_1KB'; -// Import Dummy from './dummy'; async function main(): Promise { await fs.promises.mkdir(path.join(__dirname, 'results'), { recursive: true }); // Running benches await Stream1KB(); - // Await Dummy(); const resultFilenames = await fs.promises.readdir( path.join(__dirname, 'results'), ); From b8fa1ebb6c5355a559a657d7df75015a5e2f1c83 Mon Sep 17 00:00:00 2001 From: Roger Qiu Date: Fri, 11 Aug 2023 17:49:25 +1000 Subject: [PATCH 2/7] chore: updated `package-lock.json` --- package-lock.json | 164 ++++++++++------------------------------------ 1 file changed, 36 insertions(+), 128 deletions(-) diff --git a/package-lock.json b/package-lock.json index 8e438ecf..acaadaf7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1248,6 +1248,42 @@ "version": "3.1.0", "license": "Apache-2.0" }, + "node_modules/@matrixai/quic-darwin-arm64": { + "version": "0.0.14", + "resolved": "https://registry.npmjs.org/@matrixai/quic-darwin-arm64/-/quic-darwin-arm64-0.0.14.tgz", + "integrity": "sha512-cdC6m02aaqKZi0dOulLhTFYNUALqnptsHzgFCwOU2uwiEbBghIkC/gjrPMpj4KmReb55ZZ5z2cap8KrQCcD0Cw==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@matrixai/quic-darwin-x64": { + "version": "0.0.14", + "resolved": "https://registry.npmjs.org/@matrixai/quic-darwin-x64/-/quic-darwin-x64-0.0.14.tgz", + "integrity": "sha512-zvkGeBGFgOKSXnHFcqZyEqmam6ZhvjKXi5oTp5nzYqGw2lf6KorruEmdQoi414fOZwB+uEvTZuH15rCapvZO2w==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@matrixai/quic-linux-x64": { + "version": "0.0.14", + "resolved": "https://registry.npmjs.org/@matrixai/quic-linux-x64/-/quic-linux-x64-0.0.14.tgz", + "integrity": "sha512-t6kCv7Cg9ef6rVMWyH4/mkcRTsxgusXSO+ivlysCOiTK6R+LasTLelzjnWvUvJXfCgY9cJHn7JsZuQsdf/SB0g==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ] + }, "node_modules/@matrixai/resources": { "version": "1.1.5", "resolved": "https://registry.npmjs.org/@matrixai/resources/-/resources-1.1.5.tgz", @@ -1526,86 +1562,6 @@ } } }, - "node_modules/@swc/core-darwin-arm64": { - "version": "1.3.62", - "resolved": "https://registry.npmjs.org/@swc/core-darwin-arm64/-/core-darwin-arm64-1.3.62.tgz", - "integrity": "sha512-MmGilibITz68LEje6vJlKzc2gUUSgzvB3wGLSjEORikTNeM7P8jXVxE4A8fgZqDeudJUm9HVWrxCV+pHDSwXhA==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": ">=10" - } - }, - "node_modules/@swc/core-darwin-x64": { - "version": "1.3.62", - "resolved": "https://registry.npmjs.org/@swc/core-darwin-x64/-/core-darwin-x64-1.3.62.tgz", - "integrity": "sha512-Xl93MMB3sCWVlYWuQIB+v6EQgzoiuQYK5tNt9lsHoIEVu2zLdkQjae+5FUHZb1VYqCXIiWcULFfVz0R4Sjb7JQ==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": ">=10" - } - }, - "node_modules/@swc/core-linux-arm-gnueabihf": { - "version": "1.3.62", - "resolved": "https://registry.npmjs.org/@swc/core-linux-arm-gnueabihf/-/core-linux-arm-gnueabihf-1.3.62.tgz", - "integrity": "sha512-nJsp6O7kCtAjTTMcIjVB0g5y1JNiYAa5q630eiwrnaHUusEFoANDdORI3Z9vXeikMkng+6yIv9/V8Rb093xLjQ==", - "cpu": [ - "arm" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=10" - } - }, - "node_modules/@swc/core-linux-arm64-gnu": { - "version": "1.3.62", - "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-gnu/-/core-linux-arm64-gnu-1.3.62.tgz", - "integrity": "sha512-XGsV93vpUAopDt5y6vPwbK1Nc/MlL55L77bAZUPIiosWD1cWWPHNtNSpriE6+I+JiMHe0pqtfS/SSTk6ZkFQVw==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=10" - } - }, - "node_modules/@swc/core-linux-arm64-musl": { - "version": "1.3.62", - "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-musl/-/core-linux-arm64-musl-1.3.62.tgz", - "integrity": "sha512-ESUmJjSlTTkoBy9dMG49opcNn8BmviqStMhwyeD1G8XRnmRVCZZgoBOKdvCXmJhw8bQXDhZumeaTUB+OFUKVXg==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=10" - } - }, "node_modules/@swc/core-linux-x64-gnu": { "version": "1.3.62", "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.3.62.tgz", @@ -1638,54 +1594,6 @@ "node": ">=10" } }, - "node_modules/@swc/core-win32-arm64-msvc": { - "version": "1.3.62", - "resolved": "https://registry.npmjs.org/@swc/core-win32-arm64-msvc/-/core-win32-arm64-msvc-1.3.62.tgz", - "integrity": "sha512-zv14vlF2VRrxS061XkfzGjCYnOrEo5glKJjLK5PwUKysIoVrx/L8nAbFxjkX5cObdlyoqo+ekelyBPAO+4bS0w==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">=10" - } - }, - "node_modules/@swc/core-win32-ia32-msvc": { - "version": "1.3.62", - "resolved": "https://registry.npmjs.org/@swc/core-win32-ia32-msvc/-/core-win32-ia32-msvc-1.3.62.tgz", - "integrity": "sha512-8MC/PZQSsOP2iA/81tAfNRqMWyEqTS/8zKUI67vPuLvpx6NAjRn3E9qBv7iFqH79iqZNzqSMo3awnLrKZyFbcw==", - "cpu": [ - "ia32" - ], - "dev": true, - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">=10" - } - }, - "node_modules/@swc/core-win32-x64-msvc": { - "version": "1.3.62", - "resolved": "https://registry.npmjs.org/@swc/core-win32-x64-msvc/-/core-win32-x64-msvc-1.3.62.tgz", - "integrity": "sha512-GJSmUJ95HKHZXAxiuPUmrcm/S3ivQvEzXhOZaIqYBIwUsm02vFZkClsV7eIKzWjso1t0+I/8MjrnUNaSWqh1rQ==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">=10" - } - }, "node_modules/@swc/jest": { "version": "0.2.26", "resolved": "https://registry.npmjs.org/@swc/jest/-/jest-0.2.26.tgz", From a99c0e52b2678e0a95a531d8062c9df9108a6877 Mon Sep 17 00:00:00 2001 From: Brian Botha Date: Thu, 17 Aug 2023 15:33:30 +1000 Subject: [PATCH 3/7] fix: better handling for stream cancellation --- src/QUICConnection.ts | 4 +++- src/QUICStream.ts | 37 +++++++++++++++++++++++++++----- src/utils.ts | 4 ++-- tests/QUICStream.test.ts | 46 ++++++++++++++++++++++++++++++---------- tests/utils.ts | 31 +++++++++++++++++++++++++++ 5 files changed, 103 insertions(+), 19 deletions(-) diff --git a/src/QUICConnection.ts b/src/QUICConnection.ts index fc655fef..781b6d55 100644 --- a/src/QUICConnection.ts +++ b/src/QUICConnection.ts @@ -895,8 +895,10 @@ class QUICConnection extends EventTarget { this.dispatchEvent( new events.QUICConnectionStreamEvent({ detail: quicStream }), ); + // No need to read after creation, doing so will throw during early cancellation + } else { + quicStream.read(); } - quicStream.read(); } for (const streamId of this.conn.writable() as Iterable) { const quicStream = this.streamMap.get(streamId); diff --git a/src/QUICStream.ts b/src/QUICStream.ts index e361c788..8d3c9842 100644 --- a/src/QUICStream.ts +++ b/src/QUICStream.ts @@ -88,8 +88,10 @@ class QUICStream // create Peer state. try { connection.conn.streamSend(streamId, new Uint8Array(0), false); - } catch { - // FIXME: If there is an error here then stream will not create? Maybe we should abort? + } catch (e) { + // We ignore any errors here, if this is a server side stream then state already exists. + // But it's possible for the stream to already be closed or have an error here. + // These errors will be handled by the QUICStream and not here. } const stream = new this({ streamId, @@ -163,6 +165,18 @@ class QUICStream // and we need to propagate the error up and down the stream controller.error(reason); await this.closeRecv(true, reason); + // It is possible the stream was cancelled, let's check the writable state; + try { + this.conn.streamWritable(this.streamId, 0); + } catch (e) { + const match = e.message.match(/InvalidStreamState\((.+)\)/); + if (match == null) { + return never( + 'Errors besides [InvalidStreamState(StreamId)] are not expected here', + ); + } + this.writableController.error(reason); + } } break; } @@ -319,8 +333,9 @@ class QUICStream this.readableController.close(); } } catch (e) { - // Ignore if done, not normally meant to happen but possible in rare cases - if (e.message !== 'Done') { + if (e.message === 'Done') { + never(); + } else { this.logger.debug(`Stream recv reported: error ${e.message}`); if (!this._recvClosed) { // Close stream in background @@ -329,6 +344,18 @@ class QUICStream (await this.processSendStreamError(e, 'recv')) ?? e; this.readableController.error(reason); await this.closeRecv(true, reason); + // It is possible the stream was cancelled, let's check the writable state; + try { + this.conn.streamWritable(this.streamId, 0); + } catch (e) { + const match = e.message.match(/InvalidStreamState\((.+)\)/); + if (match == null) { + return never( + 'Errors besides [InvalidStreamState(StreamId)] are not expected here', + ); + } + this.writableController.error(reason); + } })(); } } @@ -488,7 +515,7 @@ class QUICStream match = e.message.match(/InvalidStreamState\((.+)\)/); if (match != null) { // `InvalidStreamState()` returns the stream ID and not any actual error code - return await this.codeToReason(type, 0); + return never('Should never reach an [InvalidState(StreamId)] error'); } return null; } diff --git a/src/utils.ts b/src/utils.ts index 20dcc276..02629003 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -335,8 +335,8 @@ function decodeConnectionId(connIdString: ConnectionIdString): ConnectionId { return Buffer.from(connIdString, 'hex') as ConnectionId; } -function never(): never { - throw new errors.ErrorQUICUndefinedBehaviour(); +function never(message?: string): never { + throw new errors.ErrorQUICUndefinedBehaviour(message); } function certificateDERToPEM(der: Uint8Array): string { diff --git a/tests/QUICStream.test.ts b/tests/QUICStream.test.ts index cbd78a13..2eb10e76 100644 --- a/tests/QUICStream.test.ts +++ b/tests/QUICStream.test.ts @@ -791,12 +791,13 @@ describe(QUICStream.name, () => { await client.destroy({ force: true }); await server.stop({ force: true }); }); - test('streams can be cancelled', async () => { + test('streams can be cancelled after data sent', async () => { const cancelReason = Symbol('CancelReason'); const connectionEventProm = utils.promise(); const tlsConfig1 = await generateConfig(defaultType); const tlsConfig2 = await generateConfig(defaultType); + const reasonConverters = testsUtils.createReasonConverters(); const server = new QUICServer({ crypto: { key, @@ -809,6 +810,7 @@ describe(QUICStream.name, () => { verifyPeer: true, ca: tlsConfig2.ca, }, + ...reasonConverters, }); testsUtils.extractSocket(server, sockets); server.addEventListener( @@ -831,6 +833,7 @@ describe(QUICStream.name, () => { key: tlsConfig2.key, cert: tlsConfig2.cert, }, + ...reasonConverters, }); testsUtils.extractSocket(client, sockets); const conn = (await connectionEventProm.p).detail; @@ -848,7 +851,6 @@ describe(QUICStream.name, () => { const writer = clientStream.writable.getWriter(); await writer.write(message); writer.releaseLock(); - await serverStreamProm.p; clientStream.cancel(cancelReason); await expect(clientStream.readable.getReader().read()).rejects.toBe( cancelReason, @@ -856,11 +858,21 @@ describe(QUICStream.name, () => { await expect(clientStream.writable.getWriter().write()).rejects.toBe( cancelReason, ); + // Let's check that the server side ended const serverStream = await serverStreamProm.p; - await expect( - serverStream.readable.pipeTo(serverStream.writable), - ).rejects.toThrow(); + const serverReadProm = (async () => { + for await (const _ of serverStream.readable) { + // Just consume until stream throws + } + })(); + await expect(serverReadProm).rejects.toBe(cancelReason); + const serverWriter = serverStream.writable.getWriter(); + // Should throw + await expect(serverWriter.write(Buffer.from('hello'))).rejects.toBe( + cancelReason, + ); + // And client stream should've cleaned up await testsUtils.sleep(100); expect(clientStream[destroyed]).toBeTrue(); @@ -873,6 +885,7 @@ describe(QUICStream.name, () => { utils.promise(); const tlsConfig1 = await generateConfig(defaultType); const tlsConfig2 = await generateConfig(defaultType); + const reasonConverters = testsUtils.createReasonConverters(); const server = new QUICServer({ crypto: { key, @@ -885,6 +898,7 @@ describe(QUICStream.name, () => { verifyPeer: true, ca: tlsConfig2.ca, }, + ...reasonConverters, }); testsUtils.extractSocket(server, sockets); server.addEventListener( @@ -907,6 +921,7 @@ describe(QUICStream.name, () => { key: tlsConfig2.key, cert: tlsConfig2.cert, }, + ...reasonConverters, }); testsUtils.extractSocket(client, sockets); const conn = (await connectionEventProm.p).detail; @@ -921,25 +936,34 @@ describe(QUICStream.name, () => { // Let's make a new streams. const clientStream = await client.connection.streamNew(); clientStream.cancel(cancelReason); - await expect(clientStream.readable.getReader().read()).rejects.toBe( cancelReason, ); await expect(clientStream.writable.getWriter().write()).rejects.toBe( cancelReason, ); + // Let's check that the server side ended const serverStream = await serverStreamProm.p; - await expect( - serverStream.readable.pipeTo(serverStream.writable), - ).rejects.toThrow('recv 0'); + const serverReadProm = (async () => { + for await (const _ of serverStream.readable) { + // Just consume until stream throws + } + })(); + await expect(serverReadProm).rejects.toBe(cancelReason); + const serverWriter = serverStream.writable.getWriter(); + // Should throw + await expect(serverWriter.write(Buffer.from('hello'))).rejects.toBe( + cancelReason, + ); + // And client stream should've cleaned up await testsUtils.sleep(100); expect(clientStream[destroyed]).toBeTrue(); await client.destroy({ force: true }); await server.stop({ force: true }); }); - test('Stream will end when waiting for more data', async () => { + test('stream will end when waiting for more data', async () => { // Needed to check that the pull based reading of data doesn't break when we // temporarily run out of data to read const connectionEventProm = @@ -1008,7 +1032,7 @@ describe(QUICStream.name, () => { await client.destroy({ force: true }); await server.stop({ force: true }); }); - test('Stream can error when blocked on data', async () => { + test('stream can error when blocked on data', async () => { // This checks that if the readable web-stream is full and not pulling data, // we will still respond to an error in the readable stream diff --git a/tests/utils.ts b/tests/utils.ts index f04d4388..363382ea 100644 --- a/tests/utils.ts +++ b/tests/utils.ts @@ -4,6 +4,7 @@ import type QUICSocket from '@/QUICSocket'; import type QUICClient from '@/QUICClient'; import type QUICServer from '@/QUICServer'; import type QUICStream from '@/QUICStream'; +import type { StreamCodeToReason, StreamReasonToCode } from '@'; import { Crypto } from '@peculiar/webcrypto'; import * as x509 from '@peculiar/x509'; import { never } from '@/utils'; @@ -740,6 +741,35 @@ async function generateConfig(type: KeyTypes): Promise { }; } +/** + * This will create a `reasonToCode` and `CodeToReason` function that will + * allow errors to "jump" the network boundary. It does this by mapping the + * errors to an incrementing code and returning them on the other end of the + * connection. + * + * Note: this should ONLY be used for testing as it requires the client and + * server to share the same instance of `reasonToCode` and `codeToReason`. + */ +function createReasonConverters() { + const reasonMap = new Map(); + let code = 0; + + const reasonToCode: StreamReasonToCode = (_type, reason) => { + code++; + reasonMap.set(code, reason); + return code; + }; + + const codeToReason: StreamCodeToReason = (_type, code) => { + return reasonMap.get(code) ?? new Error('Reason not found'); + }; + + return { + reasonToCode, + codeToReason, + }; +} + export { sleep, randomBytes, @@ -760,6 +790,7 @@ export { waitForTimeoutNull, connStats, generateConfig, + createReasonConverters, }; export type { Messages, StreamData, KeyTypes, TLSConfigs }; From e7a1039eb632048f1a6bf7d067dd60e28b466e95 Mon Sep 17 00:00:00 2001 From: Brian Botha Date: Thu, 17 Aug 2023 15:46:44 +1000 Subject: [PATCH 4/7] fix: removed unnecessary looping in stream pulling --- src/QUICStream.ts | 76 ++++++++++++++++++++++------------------------- 1 file changed, 35 insertions(+), 41 deletions(-) diff --git a/src/QUICStream.ts b/src/QUICStream.ts index 8d3c9842..85c35ef3 100644 --- a/src/QUICStream.ts +++ b/src/QUICStream.ts @@ -150,50 +150,44 @@ class QUICStream const buf = Buffer.alloc(1024); let recvLength: number, fin: boolean; // Read messages until buffer is empty - while (true) { - try { - [recvLength, fin] = this.conn.streamRecv(this.streamId, buf); - } catch (e) { - this.logger.debug(`Stream recv reported: error ${e.message}`); - // Done means there is no more data to read - if (!this._recvClosed && e.message !== 'Done') { - const reason = - (await this.processSendStreamError(e, 'recv')) ?? e; - // If it is `StreamReset(u64)` error, then the peer has closed - // the stream, and we are receiving the error code - // If it is not a `StreamReset(u64)`, then something else broke, - // and we need to propagate the error up and down the stream - controller.error(reason); - await this.closeRecv(true, reason); - // It is possible the stream was cancelled, let's check the writable state; - try { - this.conn.streamWritable(this.streamId, 0); - } catch (e) { - const match = e.message.match(/InvalidStreamState\((.+)\)/); - if (match == null) { - return never( - 'Errors besides [InvalidStreamState(StreamId)] are not expected here', - ); - } - this.writableController.error(reason); + try { + [recvLength, fin] = this.conn.streamRecv(this.streamId, buf); + } catch (e) { + this.logger.debug(`Stream recv reported: error ${e.message}`); + // Done means there is no more data to read + if (!this._recvClosed && e.message !== 'Done') { + const reason = + (await this.processSendStreamError(e, 'recv')) ?? e; + // If it is `StreamReset(u64)` error, then the peer has closed + // the stream, and we are receiving the error code + // If it is not a `StreamReset(u64)`, then something else broke, + // and we need to propagate the error up and down the stream + controller.error(reason); + await this.closeRecv(true, reason); + // It is possible the stream was cancelled, let's check the writable state; + try { + this.conn.streamWritable(this.streamId, 0); + } catch (e) { + const match = e.message.match(/InvalidStreamState\((.+)\)/); + if (match == null) { + return never( + 'Errors besides [InvalidStreamState(StreamId)] are not expected here', + ); } + this.writableController.error(reason); } - break; - } - this.logger.debug( - `stream read ${recvLength} bytes with fin(${fin})`, - ); - // Check and drop if we're already closed or message is 0-length message - if (!this._recvClosed && recvLength > 0) { - this.readableController.enqueue(buf.subarray(0, recvLength)); - } - // If fin is true, then that means, the stream is CLOSED - if (fin) { - await this.closeRecv(); - controller.close(); - // Return out of the loop - break; } + return; + } + this.logger.debug(`stream read ${recvLength} bytes with fin(${fin})`); + // Check and drop if we're already closed or message is 0-length message + if (!this._recvClosed && recvLength > 0) { + controller.enqueue(buf.subarray(0, recvLength)); + } + // If fin is true, then that means, the stream is CLOSED + if (fin) { + await this.closeRecv(); + controller.close(); } }, cancel: async (reason) => { From 824c4cbea321ac0671da2ec536d3feea8850ac79 Mon Sep 17 00:00:00 2001 From: Brian Botha Date: Thu, 17 Aug 2023 19:04:49 +1000 Subject: [PATCH 5/7] tests: removed commented out utility --- tests/utils.ts | 52 -------------------------------------------------- 1 file changed, 52 deletions(-) diff --git a/tests/utils.ts b/tests/utils.ts index 363382ea..cdfe09ad 100644 --- a/tests/utils.ts +++ b/tests/utils.ts @@ -471,58 +471,6 @@ async function generateCertificate({ return await x509.X509CertificateGenerator.create(certConfig); } -// Async function createTLSConfigWithChain( -// keyPairs: Array<{ -// publicKey: JsonWebKey; -// privateKey: JsonWebKey; -// }>, -// generateCertId?: () => string, -// ): Promise<{ -// certChainPem: string; -// privKeyPem: string; -// caPem: string; -// }> { -// if (keyPairs.length === 0) throw Error('Must have at least 1 keypair'); -// let num = -1; -// const defaultNumGen = () => { -// num += 1; -// return `${num}`; -// }; -// generateCertId = generateCertId ?? defaultNumGen; -// let previousCert: X509Certificate | null = null; -// let previousKeyPair: { -// publicKey: JsonWebKey; -// privateKey: JsonWebKey; -// } | null = null; -// const certChain: Array = []; -// for (const keyPair of keyPairs) { -// const certId = generateCertId(); -// const newCert = await generateCertificate({ -// certId, -// duration: 31536000, -// issuerPrivateKey: previousKeyPair?.privateKey ?? keyPair.privateKey, -// subjectKeyPair: keyPair, -// issuerAttrsExtra: previousCert?.subjectName.toJSON(), -// }); -// certChain.unshift(newCert); -// previousCert = newCert; -// previousKeyPair = keyPair; -// } -// let certChainPEM = ''; -// let caPem: string | null = null; -// for (const certificate of certChain) { -// const pem = certToPEM(certificate); -// caPem = pem; -// certChainPEM += pem; -// } -// -// return { -// privKeyPem: privateKeyToPEM(previousKeyPair!.privateKey), -// certChainPem: certChainPEM, -// caPem: caPem!, -// }; -// } - function certToPEM(cert: X509Certificate): string { return cert.toString('pem') + '\n'; } From e868d2c547bbbdbb024934aa62c8e0f123fa2359 Mon Sep 17 00:00:00 2001 From: Brian Botha Date: Fri, 18 Aug 2023 12:29:03 +1000 Subject: [PATCH 6/7] Revert "chore: updated `package-lock.json`" This reverts commit b8fa1ebb6c5355a559a657d7df75015a5e2f1c83. --- package-lock.json | 164 ++++++++++++++++++++++++++++++++++++---------- 1 file changed, 128 insertions(+), 36 deletions(-) diff --git a/package-lock.json b/package-lock.json index acaadaf7..8e438ecf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1248,42 +1248,6 @@ "version": "3.1.0", "license": "Apache-2.0" }, - "node_modules/@matrixai/quic-darwin-arm64": { - "version": "0.0.14", - "resolved": "https://registry.npmjs.org/@matrixai/quic-darwin-arm64/-/quic-darwin-arm64-0.0.14.tgz", - "integrity": "sha512-cdC6m02aaqKZi0dOulLhTFYNUALqnptsHzgFCwOU2uwiEbBghIkC/gjrPMpj4KmReb55ZZ5z2cap8KrQCcD0Cw==", - "cpu": [ - "arm64" - ], - "optional": true, - "os": [ - "darwin" - ] - }, - "node_modules/@matrixai/quic-darwin-x64": { - "version": "0.0.14", - "resolved": "https://registry.npmjs.org/@matrixai/quic-darwin-x64/-/quic-darwin-x64-0.0.14.tgz", - "integrity": "sha512-zvkGeBGFgOKSXnHFcqZyEqmam6ZhvjKXi5oTp5nzYqGw2lf6KorruEmdQoi414fOZwB+uEvTZuH15rCapvZO2w==", - "cpu": [ - "x64" - ], - "optional": true, - "os": [ - "darwin" - ] - }, - "node_modules/@matrixai/quic-linux-x64": { - "version": "0.0.14", - "resolved": "https://registry.npmjs.org/@matrixai/quic-linux-x64/-/quic-linux-x64-0.0.14.tgz", - "integrity": "sha512-t6kCv7Cg9ef6rVMWyH4/mkcRTsxgusXSO+ivlysCOiTK6R+LasTLelzjnWvUvJXfCgY9cJHn7JsZuQsdf/SB0g==", - "cpu": [ - "x64" - ], - "optional": true, - "os": [ - "linux" - ] - }, "node_modules/@matrixai/resources": { "version": "1.1.5", "resolved": "https://registry.npmjs.org/@matrixai/resources/-/resources-1.1.5.tgz", @@ -1562,6 +1526,86 @@ } } }, + "node_modules/@swc/core-darwin-arm64": { + "version": "1.3.62", + "resolved": "https://registry.npmjs.org/@swc/core-darwin-arm64/-/core-darwin-arm64-1.3.62.tgz", + "integrity": "sha512-MmGilibITz68LEje6vJlKzc2gUUSgzvB3wGLSjEORikTNeM7P8jXVxE4A8fgZqDeudJUm9HVWrxCV+pHDSwXhA==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-darwin-x64": { + "version": "1.3.62", + "resolved": "https://registry.npmjs.org/@swc/core-darwin-x64/-/core-darwin-x64-1.3.62.tgz", + "integrity": "sha512-Xl93MMB3sCWVlYWuQIB+v6EQgzoiuQYK5tNt9lsHoIEVu2zLdkQjae+5FUHZb1VYqCXIiWcULFfVz0R4Sjb7JQ==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-arm-gnueabihf": { + "version": "1.3.62", + "resolved": "https://registry.npmjs.org/@swc/core-linux-arm-gnueabihf/-/core-linux-arm-gnueabihf-1.3.62.tgz", + "integrity": "sha512-nJsp6O7kCtAjTTMcIjVB0g5y1JNiYAa5q630eiwrnaHUusEFoANDdORI3Z9vXeikMkng+6yIv9/V8Rb093xLjQ==", + "cpu": [ + "arm" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-arm64-gnu": { + "version": "1.3.62", + "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-gnu/-/core-linux-arm64-gnu-1.3.62.tgz", + "integrity": "sha512-XGsV93vpUAopDt5y6vPwbK1Nc/MlL55L77bAZUPIiosWD1cWWPHNtNSpriE6+I+JiMHe0pqtfS/SSTk6ZkFQVw==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-arm64-musl": { + "version": "1.3.62", + "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-musl/-/core-linux-arm64-musl-1.3.62.tgz", + "integrity": "sha512-ESUmJjSlTTkoBy9dMG49opcNn8BmviqStMhwyeD1G8XRnmRVCZZgoBOKdvCXmJhw8bQXDhZumeaTUB+OFUKVXg==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, "node_modules/@swc/core-linux-x64-gnu": { "version": "1.3.62", "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.3.62.tgz", @@ -1594,6 +1638,54 @@ "node": ">=10" } }, + "node_modules/@swc/core-win32-arm64-msvc": { + "version": "1.3.62", + "resolved": "https://registry.npmjs.org/@swc/core-win32-arm64-msvc/-/core-win32-arm64-msvc-1.3.62.tgz", + "integrity": "sha512-zv14vlF2VRrxS061XkfzGjCYnOrEo5glKJjLK5PwUKysIoVrx/L8nAbFxjkX5cObdlyoqo+ekelyBPAO+4bS0w==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-win32-ia32-msvc": { + "version": "1.3.62", + "resolved": "https://registry.npmjs.org/@swc/core-win32-ia32-msvc/-/core-win32-ia32-msvc-1.3.62.tgz", + "integrity": "sha512-8MC/PZQSsOP2iA/81tAfNRqMWyEqTS/8zKUI67vPuLvpx6NAjRn3E9qBv7iFqH79iqZNzqSMo3awnLrKZyFbcw==", + "cpu": [ + "ia32" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-win32-x64-msvc": { + "version": "1.3.62", + "resolved": "https://registry.npmjs.org/@swc/core-win32-x64-msvc/-/core-win32-x64-msvc-1.3.62.tgz", + "integrity": "sha512-GJSmUJ95HKHZXAxiuPUmrcm/S3ivQvEzXhOZaIqYBIwUsm02vFZkClsV7eIKzWjso1t0+I/8MjrnUNaSWqh1rQ==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=10" + } + }, "node_modules/@swc/jest": { "version": "0.2.26", "resolved": "https://registry.npmjs.org/@swc/jest/-/jest-0.2.26.tgz", From 2a14b5a7db9e802beb2fc77f5b776a528d9809fe Mon Sep 17 00:00:00 2001 From: Brian Botha Date: Fri, 18 Aug 2023 12:33:23 +1000 Subject: [PATCH 7/7] build: fixing package-lock.json --- package-lock.json | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/package-lock.json b/package-lock.json index 8e438ecf..3e2ec02d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1248,6 +1248,42 @@ "version": "3.1.0", "license": "Apache-2.0" }, + "node_modules/@matrixai/quic-darwin-arm64": { + "version": "0.0.14", + "resolved": "https://registry.npmjs.org/@matrixai/quic-darwin-arm64/-/quic-darwin-arm64-0.0.14.tgz", + "integrity": "sha512-cdC6m02aaqKZi0dOulLhTFYNUALqnptsHzgFCwOU2uwiEbBghIkC/gjrPMpj4KmReb55ZZ5z2cap8KrQCcD0Cw==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@matrixai/quic-darwin-x64": { + "version": "0.0.14", + "resolved": "https://registry.npmjs.org/@matrixai/quic-darwin-x64/-/quic-darwin-x64-0.0.14.tgz", + "integrity": "sha512-zvkGeBGFgOKSXnHFcqZyEqmam6ZhvjKXi5oTp5nzYqGw2lf6KorruEmdQoi414fOZwB+uEvTZuH15rCapvZO2w==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@matrixai/quic-linux-x64": { + "version": "0.0.14", + "resolved": "https://registry.npmjs.org/@matrixai/quic-linux-x64/-/quic-linux-x64-0.0.14.tgz", + "integrity": "sha512-t6kCv7Cg9ef6rVMWyH4/mkcRTsxgusXSO+ivlysCOiTK6R+LasTLelzjnWvUvJXfCgY9cJHn7JsZuQsdf/SB0g==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ] + }, "node_modules/@matrixai/resources": { "version": "1.1.5", "resolved": "https://registry.npmjs.org/@matrixai/resources/-/resources-1.1.5.tgz",