@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.
Files changed (75) hide show
  1. package/dist/lib/dom.d.ts +27 -10
  2. package/dist/lib/dom.d.ts.map +1 -1
  3. package/dist/lib/http2/browser/browser.d.ts +5 -2
  4. package/dist/lib/http2/browser/browser.d.ts.map +1 -1
  5. package/dist/lib/http2/browser/browserparser.d.ts.map +1 -1
  6. package/dist/lib/http2/node/capsuleparser.d.ts.map +1 -1
  7. package/dist/lib/http2/node/client.d.ts +3 -2
  8. package/dist/lib/http2/node/client.d.ts.map +1 -1
  9. package/dist/lib/http2/node/server.d.ts +10 -5
  10. package/dist/lib/http2/node/server.d.ts.map +1 -1
  11. package/dist/lib/http2/node/websocketparser.d.ts.map +1 -1
  12. package/dist/lib/http2/parserbase.d.ts +33 -1
  13. package/dist/lib/http2/parserbase.d.ts.map +1 -1
  14. package/dist/lib/http2/priorityscheduler.d.ts +167 -0
  15. package/dist/lib/http2/priorityscheduler.d.ts.map +1 -0
  16. package/dist/lib/http2/session.d.ts +25 -16
  17. package/dist/lib/http2/session.d.ts.map +1 -1
  18. package/dist/lib/http2/stream.d.ts +10 -0
  19. package/dist/lib/http2/stream.d.ts.map +1 -1
  20. package/dist/lib/http2/websocketcommon.d.ts.map +1 -1
  21. package/dist/lib/server.d.ts.map +1 -1
  22. package/dist/lib/session.d.ts +31 -17
  23. package/dist/lib/session.d.ts.map +1 -1
  24. package/dist/lib/stream.d.ts +13 -0
  25. package/dist/lib/stream.d.ts.map +1 -1
  26. package/dist/lib/types.d.ts +18 -15
  27. package/dist/lib/types.d.ts.map +1 -1
  28. package/dist/lib/webtransport.browser.d.ts +3 -2
  29. package/dist/lib/webtransport.browser.d.ts.map +1 -1
  30. package/dist/lib/webtransportbase.d.ts +1 -0
  31. package/dist/lib/webtransportbase.d.ts.map +1 -1
  32. package/eslint.config.js +20 -22
  33. package/lib/dom.ts +31 -13
  34. package/lib/http2/browser/browser.js +28 -13
  35. package/lib/http2/browser/browserparser.js +4 -1
  36. package/lib/http2/node/capsuleparser.js +4 -1
  37. package/lib/http2/node/client.js +38 -27
  38. package/lib/http2/node/server.js +56 -19
  39. package/lib/http2/node/websocketparser.js +5 -2
  40. package/lib/http2/parserbase.js +76 -7
  41. package/lib/http2/priorityscheduler.js +654 -0
  42. package/lib/http2/session.js +69 -20
  43. package/lib/http2/stream.js +60 -10
  44. package/lib/http2/websocketcommon.js +1 -1
  45. package/lib/server.js +0 -1
  46. package/lib/session.js +128 -64
  47. package/lib/stream.js +50 -8
  48. package/lib/types.ts +15 -8
  49. package/lib/webtransport.browser.js +77 -18
  50. package/lib/webtransportbase.js +7 -0
  51. package/old_test/echoserver.js +1 -1
  52. package/old_test/test.js +1 -1
  53. package/old_test/testsuite.js +6 -2
  54. package/package.json +7 -28
  55. package/readme.md +5 -3
  56. package/test/bidirectional-streams.spec.js +0 -150
  57. package/test/datagrams.spec.js +0 -104
  58. package/test/fixtures/certificate.js +0 -456
  59. package/test/fixtures/chai.js +0 -8
  60. package/test/fixtures/known-bytes.js +0 -44
  61. package/test/fixtures/p-timeout.js +0 -33
  62. package/test/fixtures/quiche.browser.js +0 -2
  63. package/test/fixtures/quiche.js +0 -1
  64. package/test/fixtures/read-cert-hash.js +0 -7
  65. package/test/fixtures/read-stream.js +0 -57
  66. package/test/fixtures/reader-value.js +0 -51
  67. package/test/fixtures/server.js +0 -467
  68. package/test/fixtures/webtransport.browser.js +0 -19
  69. package/test/fixtures/webtransport.js +0 -3
  70. package/test/fixtures/write-stream.js +0 -24
  71. package/test/index.js +0 -124
  72. package/test/pw-no-https-errors.json +0 -5
  73. package/test/session.spec.js +0 -199
  74. package/test/stream-limits.spec.js +0 -259
  75. 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
- })