@fails-components/webtransport 1.1.3 → 1.2.0
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/dist/lib/dom.d.ts +27 -10
- package/dist/lib/dom.d.ts.map +1 -1
- package/dist/lib/http2/browser/browser.d.ts +5 -2
- package/dist/lib/http2/browser/browser.d.ts.map +1 -1
- package/dist/lib/http2/browser/browserparser.d.ts.map +1 -1
- package/dist/lib/http2/node/capsuleparser.d.ts.map +1 -1
- package/dist/lib/http2/node/client.d.ts +3 -2
- package/dist/lib/http2/node/client.d.ts.map +1 -1
- package/dist/lib/http2/node/server.d.ts +10 -5
- package/dist/lib/http2/node/server.d.ts.map +1 -1
- package/dist/lib/http2/node/websocketparser.d.ts.map +1 -1
- package/dist/lib/http2/parserbase.d.ts +33 -1
- package/dist/lib/http2/parserbase.d.ts.map +1 -1
- package/dist/lib/http2/priorityscheduler.d.ts +167 -0
- package/dist/lib/http2/priorityscheduler.d.ts.map +1 -0
- package/dist/lib/http2/session.d.ts +25 -16
- package/dist/lib/http2/session.d.ts.map +1 -1
- package/dist/lib/http2/stream.d.ts +10 -0
- package/dist/lib/http2/stream.d.ts.map +1 -1
- package/dist/lib/http2/websocketcommon.d.ts.map +1 -1
- package/dist/lib/server.d.ts.map +1 -1
- package/dist/lib/session.d.ts +31 -17
- package/dist/lib/session.d.ts.map +1 -1
- package/dist/lib/stream.d.ts +13 -0
- package/dist/lib/stream.d.ts.map +1 -1
- package/dist/lib/types.d.ts +18 -15
- package/dist/lib/types.d.ts.map +1 -1
- package/dist/lib/webtransport.browser.d.ts +3 -2
- package/dist/lib/webtransport.browser.d.ts.map +1 -1
- package/dist/lib/webtransportbase.d.ts +1 -0
- package/dist/lib/webtransportbase.d.ts.map +1 -1
- package/eslint.config.js +20 -22
- package/lib/dom.ts +31 -13
- package/lib/http2/browser/browser.js +28 -13
- package/lib/http2/browser/browserparser.js +4 -1
- package/lib/http2/node/capsuleparser.js +4 -1
- package/lib/http2/node/client.js +38 -27
- package/lib/http2/node/server.js +56 -19
- package/lib/http2/node/websocketparser.js +5 -2
- package/lib/http2/parserbase.js +76 -7
- package/lib/http2/priorityscheduler.js +654 -0
- package/lib/http2/session.js +69 -20
- package/lib/http2/stream.js +60 -10
- package/lib/http2/websocketcommon.js +1 -1
- package/lib/server.js +0 -1
- package/lib/session.js +128 -64
- package/lib/stream.js +50 -8
- package/lib/types.ts +15 -8
- package/lib/webtransport.browser.js +77 -18
- package/lib/webtransportbase.js +7 -0
- package/old_test/echoserver.js +1 -1
- package/old_test/test.js +1 -1
- package/old_test/testsuite.js +6 -2
- package/package.json +7 -28
- package/readme.md +5 -3
- 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
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
/* eslint-env mocha */
|
|
2
|
-
|
|
3
|
-
import { getReaderValue } from './fixtures/reader-value.js'
|
|
4
|
-
import WebTransport from './fixtures/webtransport.js'
|
|
5
|
-
import { expect } from 'chai'
|
|
6
|
-
import { readStream } from './fixtures/read-stream.js'
|
|
7
|
-
import { writeStream } from './fixtures/write-stream.js'
|
|
8
|
-
import { readCertHash } from './fixtures/read-cert-hash.js'
|
|
9
|
-
import * as ui8 from 'uint8arrays'
|
|
10
|
-
import { KNOWN_BYTES, KNOWN_BYTES_LENGTH } from './fixtures/known-bytes.js'
|
|
11
|
-
import { quicheLoaded } from './fixtures/quiche.js'
|
|
12
|
-
|
|
13
|
-
describe('unidirectional streams', function () {
|
|
14
|
-
/** @type {import('../lib/dom').WebTransport | undefined} */
|
|
15
|
-
let client
|
|
16
|
-
let forceReliable = false
|
|
17
|
-
if (process.env.USE_HTTP2 === 'true') forceReliable = true
|
|
18
|
-
|
|
19
|
-
const wtOptions = {
|
|
20
|
-
serverCertificateHashes: [
|
|
21
|
-
{
|
|
22
|
-
algorithm: 'sha-256',
|
|
23
|
-
value: readCertHash(process.env.CERT_HASH)
|
|
24
|
-
}
|
|
25
|
-
],
|
|
26
|
-
// @ts-ignore
|
|
27
|
-
forceReliable
|
|
28
|
-
}
|
|
29
|
-
if (process.env.NO_CERT_HASHES === 'true')
|
|
30
|
-
// @ts-ignore
|
|
31
|
-
delete wtOptions.serverCertificateHashes
|
|
32
|
-
|
|
33
|
-
// @ts-ignore
|
|
34
|
-
beforeEach(async () => {
|
|
35
|
-
if (
|
|
36
|
-
process.env.USE_HTTP2 !== 'true' &&
|
|
37
|
-
process.env.USE_PONYFILL !== 'true' &&
|
|
38
|
-
process.env.USE_POLYFILL !== 'true'
|
|
39
|
-
) {
|
|
40
|
-
await quicheLoaded
|
|
41
|
-
}
|
|
42
|
-
})
|
|
43
|
-
|
|
44
|
-
// @ts-ignore
|
|
45
|
-
afterEach(async () => {
|
|
46
|
-
if (client != null) {
|
|
47
|
-
client.close()
|
|
48
|
-
client = undefined
|
|
49
|
-
}
|
|
50
|
-
})
|
|
51
|
-
|
|
52
|
-
it('sends data over an outgoing unidirectional stream', async () => {
|
|
53
|
-
// client context - connects to the server, opens a bidi stream, sends some data and reads the response
|
|
54
|
-
try {
|
|
55
|
-
client = new WebTransport(
|
|
56
|
-
`${process.env.SERVER_URL}/unidirectional_client_send`,
|
|
57
|
-
wtOptions
|
|
58
|
-
)
|
|
59
|
-
await client.ready
|
|
60
|
-
} catch (error) {
|
|
61
|
-
console.log('Peak unidirectional error:', error)
|
|
62
|
-
throw error
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const stream = await client.createUnidirectionalStream()
|
|
66
|
-
// correct test
|
|
67
|
-
await writeStream(stream, KNOWN_BYTES)
|
|
68
|
-
|
|
69
|
-
// the remote will close the session
|
|
70
|
-
const result = await client.closed
|
|
71
|
-
client = undefined
|
|
72
|
-
|
|
73
|
-
// should receive the default close info
|
|
74
|
-
expect(result).to.have.property('reason', '')
|
|
75
|
-
expect(result).to.have.property('closeCode', 0)
|
|
76
|
-
})
|
|
77
|
-
|
|
78
|
-
it('receives data over an incoming unidirectional stream', async () => {
|
|
79
|
-
// client context - waits for the server to open a bidi stream then pipes it back to them
|
|
80
|
-
client = new WebTransport(
|
|
81
|
-
`${process.env.SERVER_URL}/unidirectional_server_send`,
|
|
82
|
-
wtOptions
|
|
83
|
-
)
|
|
84
|
-
await client.ready
|
|
85
|
-
|
|
86
|
-
const stream = await getReaderValue(client.incomingUnidirectionalStreams)
|
|
87
|
-
const output = await readStream(stream, KNOWN_BYTES_LENGTH)
|
|
88
|
-
expect(ui8.concat(KNOWN_BYTES)).to.deep.equal(
|
|
89
|
-
ui8.concat(output),
|
|
90
|
-
'Did not receive the same bytes we sent'
|
|
91
|
-
)
|
|
92
|
-
})
|
|
93
|
-
|
|
94
|
-
it('handles fin when paused due to backpressure', async function () {
|
|
95
|
-
let addpolyfill = 0
|
|
96
|
-
if (
|
|
97
|
-
process.env.USE_POLYFILL === 'true' ||
|
|
98
|
-
process.env.USE_PONYFILL === 'true'
|
|
99
|
-
)
|
|
100
|
-
addpolyfill = 4000
|
|
101
|
-
this.timeout(6000 + addpolyfill)
|
|
102
|
-
client = new WebTransport(
|
|
103
|
-
`${process.env.SERVER_URL}/unidirectional_server_delay_before_read`,
|
|
104
|
-
wtOptions
|
|
105
|
-
)
|
|
106
|
-
await client.ready
|
|
107
|
-
|
|
108
|
-
const clientStream = await client.createUnidirectionalStream()
|
|
109
|
-
|
|
110
|
-
const writer = clientStream.getWriter()
|
|
111
|
-
|
|
112
|
-
for (const buf of KNOWN_BYTES) {
|
|
113
|
-
await writer.ready
|
|
114
|
-
await writer.write(buf)
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
await new Promise((resolve) => setTimeout(resolve, 2000))
|
|
118
|
-
try {
|
|
119
|
-
await writer.ready
|
|
120
|
-
await writer.close()
|
|
121
|
-
} catch (error) {
|
|
122
|
-
console.log('Ignore stop sending', error)
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
// the remote will close the session cleanly if everything was ok
|
|
126
|
-
await client.closed
|
|
127
|
-
client = undefined
|
|
128
|
-
|
|
129
|
-
// should receive the default close info, not true on chromium
|
|
130
|
-
// expect(result).to.have.property('reason', '')
|
|
131
|
-
// expect(result).to.have.property('closeCode', 0)
|
|
132
|
-
})
|
|
133
|
-
})
|