@fails-components/webtransport 1.1.3 → 1.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/old_test/echoserver.js +1 -1
- package/old_test/test.js +1 -1
- package/package.json +2 -23
- package/readme.md +2 -2
- package/test/bidirectional-streams.spec.js +0 -150
- package/test/datagrams.spec.js +0 -104
- package/test/fixtures/certificate.js +0 -456
- package/test/fixtures/chai.js +0 -8
- package/test/fixtures/known-bytes.js +0 -44
- package/test/fixtures/p-timeout.js +0 -33
- package/test/fixtures/quiche.browser.js +0 -2
- package/test/fixtures/quiche.js +0 -1
- package/test/fixtures/read-cert-hash.js +0 -7
- package/test/fixtures/read-stream.js +0 -57
- package/test/fixtures/reader-value.js +0 -51
- package/test/fixtures/server.js +0 -467
- package/test/fixtures/webtransport.browser.js +0 -19
- package/test/fixtures/webtransport.js +0 -3
- package/test/fixtures/write-stream.js +0 -24
- package/test/index.js +0 -124
- package/test/pw-no-https-errors.json +0 -5
- package/test/session.spec.js +0 -199
- package/test/stream-limits.spec.js +0 -259
- package/test/unidirectional-streams.spec.js +0 -133
package/old_test/echoserver.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { Http3Server } from '../lib/index.js'
|
|
6
6
|
import { runEchoServer } from './testsuite.js'
|
|
7
7
|
import { existsSync, readFileSync, writeFile } from 'node:fs'
|
|
8
|
-
import { generateWebTransportCertificate } from '
|
|
8
|
+
import { generateWebTransportCertificate } from '../../test/fixtures/certificate.js'
|
|
9
9
|
|
|
10
10
|
let certificate = null
|
|
11
11
|
|
package/old_test/test.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fails-components/webtransport",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.4",
|
|
4
4
|
"description": "A component to add webtransport support (server and client) to node.js using libquiche",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -21,21 +21,9 @@
|
|
|
21
21
|
"types": "./dist/lib/index.types.d.ts",
|
|
22
22
|
"scripts": {
|
|
23
23
|
"start": "node test/echoserver.js",
|
|
24
|
-
"test": "npm run test:node && npm run test:node:http2 && npm run test:chromium && npm run test:chromium:http2:polyfill && npm run test:chromium:http2:ponyfill && npm run test:firefox:http2:polyfill && npm run test:firefox:http2:ponyfill && npm run test:webkit:http2:polyfill && npm run test:webkit:http2:ponyfill",
|
|
25
|
-
"test:node": "node test/index.js node http3",
|
|
26
|
-
"test:node:http2": "node test/index.js node http2",
|
|
27
|
-
"test:chromium": "node test/index.js chromium http3",
|
|
28
|
-
"test:chromium:http2:polyfill": "node test/index.js chromium http2 polyfill",
|
|
29
|
-
"test:chromium:http2:ponyfill": "node test/index.js chromium http2 ponyfill",
|
|
30
|
-
"test:firefox": "node test/index.js firefox http3",
|
|
31
|
-
"test:firefox:http2:polyfill": "node test/index.js firefox http2 polyfill",
|
|
32
|
-
"test:firefox:http2:ponyfill": "node test/index.js firefox http2 ponyfill",
|
|
33
|
-
"test:webkit": "node test/index.js webkit http3",
|
|
34
|
-
"test:webkit:http2:polyfill": "node test/index.js webkit http2 polyfill",
|
|
35
|
-
"test:webkit:http2:ponyfill": "node test/index.js webkit http2 ponyfill",
|
|
36
24
|
"oldtest": "node old_test/test.js",
|
|
37
25
|
"oldtesthttp2": "node old_test/test.js http2",
|
|
38
|
-
"lint": "eslint lib
|
|
26
|
+
"lint": "eslint lib old_test"
|
|
39
27
|
},
|
|
40
28
|
"repository": {
|
|
41
29
|
"type": "git",
|
|
@@ -63,9 +51,6 @@
|
|
|
63
51
|
"@types/dirty-chai": "^2.0.2",
|
|
64
52
|
"@types/mocha": "^10.0.0",
|
|
65
53
|
"@types/node": "^18.15.3",
|
|
66
|
-
"chai": "^4.3.6",
|
|
67
|
-
"chai-as-promised": "^7.1.1",
|
|
68
|
-
"dirty-chai": "^2.0.1",
|
|
69
54
|
"eslint": "^9.3.0",
|
|
70
55
|
"eslint-config-prettier": "^9.1.0",
|
|
71
56
|
"eslint-config-standard": "^16.0.2",
|
|
@@ -74,10 +59,6 @@
|
|
|
74
59
|
"eslint-plugin-prettier": "^5.1.3",
|
|
75
60
|
"eslint-plugin-promise": "^4.3.1",
|
|
76
61
|
"eslint-plugin-standard": "^4.1.0",
|
|
77
|
-
"execa": "^6.1.0",
|
|
78
|
-
"mocha": "^10.1.0",
|
|
79
|
-
"node-forge": "^1.3.1",
|
|
80
|
-
"playwright-test": "^12.3.4",
|
|
81
62
|
"prettier": "^3.2.5",
|
|
82
63
|
"typescript": "^4.8.4",
|
|
83
64
|
"uint8arrays": "^4.0.2"
|
|
@@ -88,8 +69,6 @@
|
|
|
88
69
|
]
|
|
89
70
|
},
|
|
90
71
|
"browser": {
|
|
91
|
-
"./test/fixtures/webtransport.js": "./test/fixtures/webtransport.browser.js",
|
|
92
|
-
"./test/fixtures/quiche.js": "./test/fixtures/quiche.browser.js",
|
|
93
72
|
"./lib/webstreams.js": "./lib/webstreams.browser.js"
|
|
94
73
|
}
|
|
95
74
|
}
|
package/readme.md
CHANGED
|
@@ -72,8 +72,8 @@ The package `webtransport-transport-http3-quiche` provides prebuild binaries for
|
|
|
72
72
|
Other platforms may be possible via cross-compiling in the GitHub actions, if someone needs this, PRs are welcome.
|
|
73
73
|
|
|
74
74
|
Of course, you can also build the binary on your system.
|
|
75
|
-
If you are running the compiling install as root, you need to use
|
|
76
|
-
Installing the package without prebuild requires a full building environment including clang-9
|
|
75
|
+
If you are running the compiling install as root, you need to use `--unsafe-perm` as a flag.
|
|
76
|
+
Installing the package without prebuild requires a full building environment including `clang-9`, `perl6`, `python`, `golang`, `ninja-build`, and `icu`. See the `Dockerfile` or `Dockerfile.development` for required Debian packages.
|
|
77
77
|
This should work for Windows, Linux and Mac OS X.
|
|
78
78
|
(You may want to check out the building dependencies (especially for Windows) for BoringSSl, zlib, abseil on their respective websites).
|
|
79
79
|
|
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
/* eslint-env mocha */
|
|
2
|
-
|
|
3
|
-
import { getReaderValue } from './fixtures/reader-value.js'
|
|
4
|
-
import { expect } from './fixtures/chai.js'
|
|
5
|
-
import { readStream } from './fixtures/read-stream.js'
|
|
6
|
-
import { writeStream } from './fixtures/write-stream.js'
|
|
7
|
-
import { readCertHash } from './fixtures/read-cert-hash.js'
|
|
8
|
-
import WebTransport from './fixtures/webtransport.js'
|
|
9
|
-
import { quicheLoaded } from './fixtures/quiche.js'
|
|
10
|
-
import * as ui8 from 'uint8arrays'
|
|
11
|
-
import {
|
|
12
|
-
KNOWN_BYTES,
|
|
13
|
-
KNOWN_BYTES_LENGTH,
|
|
14
|
-
KNOWN_BYTES_LONG,
|
|
15
|
-
KNOWN_BYTES_LONG_LENGTH
|
|
16
|
-
} from './fixtures/known-bytes.js'
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* @template T
|
|
20
|
-
* @typedef {import('../lib/types').Deferred<T>} Deferred<T>
|
|
21
|
-
*/
|
|
22
|
-
describe('bidirectional streams', function () {
|
|
23
|
-
let forceReliable = false
|
|
24
|
-
if (process.env.USE_HTTP2 === 'true') forceReliable = true
|
|
25
|
-
/** @type {import('../lib/dom').WebTransport | undefined} */
|
|
26
|
-
let client
|
|
27
|
-
|
|
28
|
-
const wtOptions = {
|
|
29
|
-
serverCertificateHashes: [
|
|
30
|
-
{
|
|
31
|
-
algorithm: 'sha-256',
|
|
32
|
-
value: readCertHash(process.env.CERT_HASH)
|
|
33
|
-
}
|
|
34
|
-
],
|
|
35
|
-
// @ts-ignore
|
|
36
|
-
forceReliable
|
|
37
|
-
}
|
|
38
|
-
if (process.env.NO_CERT_HASHES === 'true')
|
|
39
|
-
// @ts-ignore
|
|
40
|
-
delete wtOptions.serverCertificateHashes
|
|
41
|
-
|
|
42
|
-
// @ts-ignore
|
|
43
|
-
beforeEach(async () => {
|
|
44
|
-
if (
|
|
45
|
-
process.env.USE_HTTP2 !== 'true' &&
|
|
46
|
-
process.env.USE_PONYFILL !== 'true' &&
|
|
47
|
-
process.env.USE_POLYFILL !== 'true'
|
|
48
|
-
) {
|
|
49
|
-
await quicheLoaded
|
|
50
|
-
}
|
|
51
|
-
})
|
|
52
|
-
|
|
53
|
-
// @ts-ignore
|
|
54
|
-
afterEach(async () => {
|
|
55
|
-
if (client != null) {
|
|
56
|
-
client.close()
|
|
57
|
-
client = undefined
|
|
58
|
-
}
|
|
59
|
-
})
|
|
60
|
-
|
|
61
|
-
it('sends and receives data over an outgoing bidirectional stream', async () => {
|
|
62
|
-
// client context - connects to the server, opens a bidi stream, sends some data and reads the response
|
|
63
|
-
client = new WebTransport(
|
|
64
|
-
`${process.env.SERVER_URL}/bidirectional_client_initiated_echo`,
|
|
65
|
-
wtOptions
|
|
66
|
-
)
|
|
67
|
-
await client.ready
|
|
68
|
-
|
|
69
|
-
const stream = await client.createBidirectionalStream()
|
|
70
|
-
await writeStream(stream.writable, KNOWN_BYTES)
|
|
71
|
-
|
|
72
|
-
const output = await readStream(stream.readable, KNOWN_BYTES_LENGTH)
|
|
73
|
-
expect(ui8.concat(KNOWN_BYTES)).to.deep.equal(
|
|
74
|
-
ui8.concat(output),
|
|
75
|
-
'Did not receive the same bytes we sent'
|
|
76
|
-
)
|
|
77
|
-
})
|
|
78
|
-
|
|
79
|
-
it('sends and receives data over an outgoing bidirectional stream with big buffers', async () => {
|
|
80
|
-
// client context - connects to the server, opens a bidi stream, sends some data and reads the response
|
|
81
|
-
client = new WebTransport(
|
|
82
|
-
`${process.env.SERVER_URL}/bidirectional_client_initiated_echo`,
|
|
83
|
-
wtOptions
|
|
84
|
-
)
|
|
85
|
-
await client.ready
|
|
86
|
-
|
|
87
|
-
const stream = await client.createBidirectionalStream()
|
|
88
|
-
await writeStream(stream.writable, KNOWN_BYTES_LONG)
|
|
89
|
-
|
|
90
|
-
const output = await readStream(stream.readable, KNOWN_BYTES_LONG_LENGTH)
|
|
91
|
-
const send = ui8.concat(KNOWN_BYTES_LONG)
|
|
92
|
-
const received = ui8.concat(output)
|
|
93
|
-
let failure = 0
|
|
94
|
-
for (let i = 0; i < Math.max(send.byteLength, received.byteLength); i++) {
|
|
95
|
-
if (send[i] !== received[i] && failure < 100) {
|
|
96
|
-
console.log('d: ', i, ' ,', send[i], ', ', received[i])
|
|
97
|
-
failure++
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
expect(ui8.concat(KNOWN_BYTES_LONG)).to.deep.equal(
|
|
102
|
-
ui8.concat(output),
|
|
103
|
-
'Did not receive the same bytes we sent'
|
|
104
|
-
)
|
|
105
|
-
})
|
|
106
|
-
|
|
107
|
-
it('sends and receives data over an incoming bidirectional stream', async () => {
|
|
108
|
-
// client context - waits for the server to open a bidi stream then pipes it back to them
|
|
109
|
-
client = new WebTransport(
|
|
110
|
-
`${process.env.SERVER_URL}/bidirectional_server_initiated_echo`,
|
|
111
|
-
wtOptions
|
|
112
|
-
)
|
|
113
|
-
await client.ready
|
|
114
|
-
|
|
115
|
-
const bidiStream = await getReaderValue(client.incomingBidirectionalStreams)
|
|
116
|
-
|
|
117
|
-
// redirect input to output
|
|
118
|
-
try {
|
|
119
|
-
await bidiStream.readable.pipeTo(bidiStream.writable)
|
|
120
|
-
} catch (error) {
|
|
121
|
-
console.log('Pipe to error (ignore)', error) // Actually all you can get is, that the fin is catched
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
// the remote will close the session
|
|
125
|
-
const result = await client.closed
|
|
126
|
-
|
|
127
|
-
// should receive the default close info
|
|
128
|
-
expect(result).to.have.property('reason', '')
|
|
129
|
-
expect(result).to.have.property('closeCode', 0)
|
|
130
|
-
})
|
|
131
|
-
|
|
132
|
-
it('receives data from server and checks receiving stream fin', async () => {
|
|
133
|
-
// client context - waits for the server to open a bidi stream then pipes it back to them
|
|
134
|
-
client = new WebTransport(
|
|
135
|
-
`${process.env.SERVER_URL}/bidirectional_server_fin_send`,
|
|
136
|
-
wtOptions
|
|
137
|
-
)
|
|
138
|
-
await client.ready
|
|
139
|
-
|
|
140
|
-
const bidiStream = await getReaderValue(client.incomingBidirectionalStreams)
|
|
141
|
-
const reader = bidiStream.readable.getReader()
|
|
142
|
-
|
|
143
|
-
while (true) {
|
|
144
|
-
const res = await reader.read()
|
|
145
|
-
if (res.done) {
|
|
146
|
-
break
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
})
|
|
150
|
-
})
|
package/test/datagrams.spec.js
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
/* eslint-env mocha */
|
|
2
|
-
|
|
3
|
-
import WebTransport from './fixtures/webtransport.js'
|
|
4
|
-
import { expect } from './fixtures/chai.js'
|
|
5
|
-
import { readStream } from './fixtures/read-stream.js'
|
|
6
|
-
import { readCertHash } from './fixtures/read-cert-hash.js'
|
|
7
|
-
import { pTimeout } from './fixtures/p-timeout.js'
|
|
8
|
-
import { quicheLoaded } from './fixtures/quiche.js'
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* @template T
|
|
12
|
-
* @typedef {import('../lib/types').Deferred<T>} Deferred<T>
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
describe('datagrams', function () {
|
|
16
|
-
/** @type {import('../lib/dom').WebTransport | undefined} */
|
|
17
|
-
let client
|
|
18
|
-
let forceReliable = false
|
|
19
|
-
if (process.env.USE_HTTP2 === 'true') forceReliable = true
|
|
20
|
-
|
|
21
|
-
const wtOptions = {
|
|
22
|
-
serverCertificateHashes: [
|
|
23
|
-
{
|
|
24
|
-
algorithm: 'sha-256',
|
|
25
|
-
value: readCertHash(process.env.CERT_HASH)
|
|
26
|
-
}
|
|
27
|
-
],
|
|
28
|
-
// @ts-ignore
|
|
29
|
-
forceReliable
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if (process.env.NO_CERT_HASHES === 'true')
|
|
33
|
-
// @ts-ignore
|
|
34
|
-
delete wtOptions.serverCertificateHashes
|
|
35
|
-
|
|
36
|
-
// @ts-ignore
|
|
37
|
-
beforeEach(async () => {
|
|
38
|
-
if (
|
|
39
|
-
process.env.USE_HTTP2 !== 'true' &&
|
|
40
|
-
process.env.USE_PONYFILL !== 'true' &&
|
|
41
|
-
process.env.USE_POLYFILL !== 'true'
|
|
42
|
-
) {
|
|
43
|
-
await quicheLoaded
|
|
44
|
-
}
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
// @ts-ignore
|
|
48
|
-
afterEach(async () => {
|
|
49
|
-
if (client != null) {
|
|
50
|
-
client.close()
|
|
51
|
-
client = undefined
|
|
52
|
-
}
|
|
53
|
-
})
|
|
54
|
-
it('client sends datagrams to the server', async () => {
|
|
55
|
-
// client context - connects to the server, sends some datagrams and reads the response
|
|
56
|
-
client = new WebTransport(
|
|
57
|
-
`${process.env.SERVER_URL}/datagrams_client_send`,
|
|
58
|
-
wtOptions
|
|
59
|
-
)
|
|
60
|
-
await client.ready
|
|
61
|
-
|
|
62
|
-
const writer = client.datagrams.writable.getWriter()
|
|
63
|
-
let closed = false
|
|
64
|
-
|
|
65
|
-
// write datagrams until the server receives one and closes the connection
|
|
66
|
-
// eslint-disable-next-line promise/catch-or-return
|
|
67
|
-
Promise.resolve().then(async () => {
|
|
68
|
-
while (!closed) {
|
|
69
|
-
try {
|
|
70
|
-
await writer.ready
|
|
71
|
-
await writer.write(Uint8Array.from([0, 1, 2, 3, 4]))
|
|
72
|
-
await new Promise((resolve) => setTimeout(resolve, 100))
|
|
73
|
-
} catch {
|
|
74
|
-
// the session can be closed while we are writing
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
})
|
|
78
|
-
|
|
79
|
-
const result = await client.closed
|
|
80
|
-
closed = true
|
|
81
|
-
|
|
82
|
-
// should receive the default close info
|
|
83
|
-
expect(result).to.have.property('reason', '')
|
|
84
|
-
expect(result).to.have.property('closeCode', 0)
|
|
85
|
-
})
|
|
86
|
-
|
|
87
|
-
it('receives datagrams from the server', async () => {
|
|
88
|
-
// client context - pipes the server's datagrams back to them
|
|
89
|
-
client = new WebTransport(
|
|
90
|
-
`${process.env.SERVER_URL}/datagrams_server_send`,
|
|
91
|
-
wtOptions
|
|
92
|
-
)
|
|
93
|
-
await client.ready
|
|
94
|
-
|
|
95
|
-
// datagram transport is unreliable, at least one message should make it through
|
|
96
|
-
const expected = 1
|
|
97
|
-
|
|
98
|
-
const received = await pTimeout(
|
|
99
|
-
readStream(client.datagrams.readable, expected),
|
|
100
|
-
1000
|
|
101
|
-
)
|
|
102
|
-
expect(received).to.have.lengthOf(expected)
|
|
103
|
-
})
|
|
104
|
-
})
|