@fails-components/webtransport 0.3.1 → 1.0.1

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 (162) hide show
  1. package/lib/client.js +81 -40
  2. package/lib/dom.ts +7 -5
  3. package/lib/http2/browser/browser.js +168 -0
  4. package/lib/http2/browser/browserparser.js +248 -0
  5. package/lib/http2/flowcontroller.js +371 -0
  6. package/lib/http2/node/capsuleparser.js +291 -0
  7. package/lib/http2/node/client.js +239 -0
  8. package/lib/http2/node/index.js +2 -0
  9. package/lib/http2/node/server.js +499 -0
  10. package/lib/http2/node/websocketparser.js +829 -0
  11. package/lib/http2/parserbase.js +139 -0
  12. package/lib/http2/parserbasehttp2.js +128 -0
  13. package/lib/http2/session.js +225 -0
  14. package/lib/http2/stream.js +354 -0
  15. package/lib/http2/websocketcommon.js +1 -0
  16. package/lib/{index.js → index.browser.js} +6 -10
  17. package/lib/index.node.js +27 -0
  18. package/lib/server.js +252 -69
  19. package/lib/session.js +31 -68
  20. package/lib/stream.js +103 -179
  21. package/lib/types.ts +174 -87
  22. package/lib/utils.js +2 -1
  23. package/lib/webstreams.browser.js +6 -0
  24. package/lib/webstreams.js +7 -0
  25. package/lib/webtransport.browser.js +284 -0
  26. package/lib/webtransport.node.js +137 -0
  27. package/lib/{webtransport.js → webtransportbase.js} +47 -41
  28. package/old_test/test.js +31 -29
  29. package/old_test/testsuite.js +1 -1
  30. package/package.json +18 -17
  31. package/readme.md +94 -30
  32. package/test/bidirectional-streams.spec.js +51 -9
  33. package/test/datagrams.spec.js +8 -2
  34. package/test/fixtures/known-bytes.js +29 -0
  35. package/test/fixtures/read-stream.js +1 -1
  36. package/test/fixtures/reader-value.js +1 -1
  37. package/test/fixtures/server.js +24 -10
  38. package/test/fixtures/webtransport.browser.js +20 -2
  39. package/test/fixtures/webtransport.js +1 -1
  40. package/test/index.js +33 -6
  41. package/test/pw-no-https-errors.json +5 -0
  42. package/test/session.spec.js +71 -52
  43. package/test/unidirectional-streams.spec.js +20 -4
  44. package/CMakeLists.txt +0 -991
  45. package/LICENSE.chromium +0 -27
  46. package/LICENSE.envoy +0 -207
  47. package/build.js +0 -313
  48. package/dist/lib/client.d.ts +0 -78
  49. package/dist/lib/client.d.ts.map +0 -1
  50. package/dist/lib/dom.d.ts +0 -87
  51. package/dist/lib/dom.d.ts.map +0 -1
  52. package/dist/lib/error.d.ts +0 -8
  53. package/dist/lib/error.d.ts.map +0 -1
  54. package/dist/lib/event-loop.d.ts +0 -33
  55. package/dist/lib/event-loop.d.ts.map +0 -1
  56. package/dist/lib/index.d.ts +0 -79
  57. package/dist/lib/index.d.ts.map +0 -1
  58. package/dist/lib/native.d.ts +0 -2
  59. package/dist/lib/native.d.ts.map +0 -1
  60. package/dist/lib/server.d.ts +0 -92
  61. package/dist/lib/server.d.ts.map +0 -1
  62. package/dist/lib/session.d.ts +0 -298
  63. package/dist/lib/session.d.ts.map +0 -1
  64. package/dist/lib/stream.d.ts +0 -135
  65. package/dist/lib/stream.d.ts.map +0 -1
  66. package/dist/lib/transport.d.ts +0 -34
  67. package/dist/lib/transport.d.ts.map +0 -1
  68. package/dist/lib/types.d.ts +0 -212
  69. package/dist/lib/types.d.ts.map +0 -1
  70. package/dist/lib/utils.d.ts +0 -11
  71. package/dist/lib/utils.d.ts.map +0 -1
  72. package/dist/lib/webtransport.d.ts +0 -47
  73. package/dist/lib/webtransport.d.ts.map +0 -1
  74. package/dist/test/bidirectional-streams.spec.d.ts +0 -5
  75. package/dist/test/bidirectional-streams.spec.d.ts.map +0 -1
  76. package/dist/test/datagrams.spec.d.ts +0 -5
  77. package/dist/test/datagrams.spec.d.ts.map +0 -1
  78. package/dist/test/event-loop.node.d.ts +0 -2
  79. package/dist/test/event-loop.node.d.ts.map +0 -1
  80. package/dist/test/fixtures/certificate.d.ts +0 -21
  81. package/dist/test/fixtures/certificate.d.ts.map +0 -1
  82. package/dist/test/fixtures/chai.d.ts +0 -2
  83. package/dist/test/fixtures/chai.d.ts.map +0 -1
  84. package/dist/test/fixtures/known-bytes.d.ts +0 -6
  85. package/dist/test/fixtures/known-bytes.d.ts.map +0 -1
  86. package/dist/test/fixtures/p-timeout.d.ts +0 -8
  87. package/dist/test/fixtures/p-timeout.d.ts.map +0 -1
  88. package/dist/test/fixtures/read-cert-hash.d.ts +0 -6
  89. package/dist/test/fixtures/read-cert-hash.d.ts.map +0 -1
  90. package/dist/test/fixtures/read-stream.d.ts +0 -19
  91. package/dist/test/fixtures/read-stream.d.ts.map +0 -1
  92. package/dist/test/fixtures/reader-value.d.ts +0 -22
  93. package/dist/test/fixtures/reader-value.d.ts.map +0 -1
  94. package/dist/test/fixtures/server.d.ts +0 -5
  95. package/dist/test/fixtures/server.d.ts.map +0 -1
  96. package/dist/test/fixtures/webtransport.browser.d.ts +0 -3
  97. package/dist/test/fixtures/webtransport.browser.d.ts.map +0 -1
  98. package/dist/test/fixtures/webtransport.d.ts +0 -3
  99. package/dist/test/fixtures/webtransport.d.ts.map +0 -1
  100. package/dist/test/fixtures/write-stream.d.ts +0 -10
  101. package/dist/test/fixtures/write-stream.d.ts.map +0 -1
  102. package/dist/test/index.d.ts +0 -2
  103. package/dist/test/index.d.ts.map +0 -1
  104. package/dist/test/session.spec.d.ts +0 -5
  105. package/dist/test/session.spec.d.ts.map +0 -1
  106. package/dist/test/unidirectional-streams.spec.d.ts +0 -2
  107. package/dist/test/unidirectional-streams.spec.d.ts.map +0 -1
  108. package/failslogolicensereadme.txt +0 -4
  109. package/lib/event-loop.js +0 -88
  110. package/lib/native.js +0 -28
  111. package/lib/transport.js +0 -82
  112. package/platform/icufix/fakedata.cpp +0 -8
  113. package/platform/quiche/quic/core/io/socket_win.inc +0 -3
  114. package/platform/quiche_platform_impl/quiche_bug_tracker_impl.h +0 -7
  115. package/platform/quiche_platform_impl/quiche_client_stats_impl.h +0 -7
  116. package/platform/quiche_platform_impl/quiche_command_line_flags_impl.h +0 -7
  117. package/platform/quiche_platform_impl/quiche_containers_impl.h +0 -7
  118. package/platform/quiche_platform_impl/quiche_event_loop_impl.h +0 -7
  119. package/platform/quiche_platform_impl/quiche_export_impl.h +0 -6
  120. package/platform/quiche_platform_impl/quiche_flag_utils_impl.h +0 -11
  121. package/platform/quiche_platform_impl/quiche_flags_impl.h +0 -8
  122. package/platform/quiche_platform_impl/quiche_iovec_impl.h +0 -10
  123. package/platform/quiche_platform_impl/quiche_logging_impl.h +0 -21
  124. package/platform/quiche_platform_impl/quiche_mem_slice_impl.h +0 -2
  125. package/platform/quiche_platform_impl/quiche_mutex_impl.h +0 -8
  126. package/platform/quiche_platform_impl/quiche_prefetch_impl.h +0 -11
  127. package/platform/quiche_platform_impl/quiche_reference_counted_impl.h +0 -16
  128. package/platform/quiche_platform_impl/quiche_server_stats_impl.h +0 -7
  129. package/platform/quiche_platform_impl/quiche_stack_trace_impl.h +0 -12
  130. package/platform/quiche_platform_impl/quiche_stream_buffer_allocator_impl.h +0 -8
  131. package/platform/quiche_platform_impl/quiche_testvalue_impl.h +0 -1
  132. package/platform/quiche_platform_impl/quiche_thread_local_impl.h +0 -6
  133. package/platform/quiche_platform_impl/quiche_time_utils_impl.h +0 -13
  134. package/platform/quiche_platform_impl/quiche_udp_socket_platform_impl.h +0 -39
  135. package/src/http3backendresponse.cc +0 -36
  136. package/src/http3backendresponse.h +0 -109
  137. package/src/http3client.cc +0 -1529
  138. package/src/http3client.h +0 -557
  139. package/src/http3clientsession.cc +0 -65
  140. package/src/http3clientsession.h +0 -60
  141. package/src/http3clientstream.cc +0 -52
  142. package/src/http3clientstream.h +0 -42
  143. package/src/http3dispatcher.cc +0 -62
  144. package/src/http3dispatcher.h +0 -57
  145. package/src/http3eventloop.cc +0 -1107
  146. package/src/http3eventloop.h +0 -316
  147. package/src/http3server.cc +0 -514
  148. package/src/http3server.h +0 -151
  149. package/src/http3serverbackend.cc +0 -105
  150. package/src/http3serverbackend.h +0 -98
  151. package/src/http3serversession.cc +0 -123
  152. package/src/http3serversession.h +0 -95
  153. package/src/http3serverstream.cc +0 -463
  154. package/src/http3serverstream.h +0 -114
  155. package/src/http3sessioncache.cc +0 -85
  156. package/src/http3sessioncache.h +0 -59
  157. package/src/http3wtsessionvisitor.cc +0 -46
  158. package/src/http3wtsessionvisitor.h +0 -397
  159. package/src/http3wtstreamvisitor.cc +0 -155
  160. package/src/http3wtstreamvisitor.h +0 -404
  161. package/test/event-loop.node.js +0 -24
  162. package/tsconfig.json +0 -39
@@ -10,9 +10,8 @@ import { expect } from './fixtures/chai.js'
10
10
  */
11
11
 
12
12
  describe('session', function () {
13
- // FIXME: sometimes there are seemingly arbitrary 5s delays in
14
- // communicating with the server under node.js
15
- this.timeout(30000)
13
+ let forceReliable = false
14
+ if (process.env.USE_HTTP2 === 'true') forceReliable = true
16
15
 
17
16
  /** @type {import('../lib/dom').WebTransport | undefined} */
18
17
  let client
@@ -32,7 +31,9 @@ describe('session', function () {
32
31
  algorithm: 'sha-256',
33
32
  value: readCertHash(process.env.CERT_HASH)
34
33
  }
35
- ]
34
+ ],
35
+ // @ts-ignore
36
+ forceReliable
36
37
  })
37
38
  await client.ready
38
39
 
@@ -51,14 +52,18 @@ describe('session', function () {
51
52
  algorithm: 'sha-256',
52
53
  value: readCertHash(process.env.CERT_HASH)
53
54
  }
54
- ]
55
+ ],
56
+ // @ts-ignore
57
+ forceReliable
55
58
  }
56
59
  )
57
60
  await client.ready
58
61
 
59
62
  const result = await client.closed
60
63
  expect(result).to.have.property('closeCode', 7)
61
- expect(result).to.have.property('reason', 'this is the reason')
64
+ if (process.env.USE_HTTP2 !== 'true')
65
+ // unsupported for http2
66
+ expect(result).to.have.property('reason', 'this is the reason')
62
67
  })
63
68
 
64
69
  it('should error when connecting to a server that does not exist', async () => {
@@ -70,7 +75,9 @@ describe('session', function () {
70
75
  }
71
76
  ],
72
77
  quicConnectTimeout: 100,
73
- webTransportConnectTimeout: 100
78
+ webTransportConnectTimeout: 100,
79
+ // @ts-ignore
80
+ forceReliable
74
81
  })
75
82
 
76
83
  const [closedResult, readyResult] = await Promise.all([
@@ -93,7 +100,9 @@ describe('session', function () {
93
100
  algorithm: 'sha-256',
94
101
  value: readCertHash(process.env.CERT_HASH)
95
102
  }
96
- ]
103
+ ],
104
+ // @ts-ignore
105
+ forceReliable
97
106
  })
98
107
 
99
108
  const [closedResult, readyResult] = await Promise.all([
@@ -109,51 +118,61 @@ describe('session', function () {
109
118
  .with.property('message', 'Opening handshake failed.')
110
119
  })
111
120
 
112
- it('should error when connecting with a bad certificate', async () => {
113
- client = new WebTransport(`${process.env.SERVER_URL}/session_close`, {
114
- serverCertificateHashes: [
115
- {
116
- algorithm: 'sha-256',
117
- value: readCertHash(process.env.CERT_HASH + ':DE:AD:BE:EF')
118
- }
119
- ]
121
+ if (
122
+ process.env.USE_POLYFILL !== 'true' &&
123
+ process.env.USE_PONYFILL !== 'true'
124
+ ) {
125
+ // deactivated in polyfill case, no test necessary
126
+ it('should error when connecting with a bad certificate', async () => {
127
+ client = new WebTransport(`${process.env.SERVER_URL}/session_close`, {
128
+ serverCertificateHashes: [
129
+ {
130
+ algorithm: 'sha-256',
131
+ value: readCertHash(process.env.CERT_HASH + ':DE:AD:BE:EF')
132
+ }
133
+ ],
134
+ // @ts-ignore
135
+ forceReliable
136
+ })
137
+
138
+ const [closedResult, readyResult] = await Promise.all([
139
+ client.closed.catch((err) => err),
140
+ client.ready.catch((err) => err)
141
+ ])
142
+
143
+ expect(closedResult)
144
+ .to.be.a('WebTransportError')
145
+ .with.property('message', 'Opening handshake failed.')
146
+ expect(readyResult)
147
+ .to.be.a('WebTransportError')
148
+ .with.property('message', 'Opening handshake failed.')
120
149
  })
121
150
 
122
- const [closedResult, readyResult] = await Promise.all([
123
- client.closed.catch((err) => err),
124
- client.ready.catch((err) => err)
125
- ])
126
-
127
- expect(closedResult)
128
- .to.be.a('WebTransportError')
129
- .with.property('message', 'Opening handshake failed.')
130
- expect(readyResult)
131
- .to.be.a('WebTransportError')
132
- .with.property('message', 'Opening handshake failed.')
133
- })
134
-
135
- it('should error when connecting with the wrong certificate', async () => {
136
- client = new WebTransport(`${process.env.SERVER_URL}/session_close`, {
137
- serverCertificateHashes: [
138
- {
139
- algorithm: 'sha-256',
140
- value: readCertHash(
141
- 'DE:AD:BE:EF:' + process.env.CERT_HASH?.substring(12)
142
- )
143
- }
144
- ]
151
+ it('should error when connecting with the wrong certificate', async () => {
152
+ client = new WebTransport(`${process.env.SERVER_URL}/session_close`, {
153
+ serverCertificateHashes: [
154
+ {
155
+ algorithm: 'sha-256',
156
+ value: readCertHash(
157
+ 'DE:AD:BE:EF:' + process.env.CERT_HASH?.substring(12)
158
+ )
159
+ }
160
+ ],
161
+ // @ts-ignore
162
+ forceReliable
163
+ })
164
+
165
+ const [closedResult, readyResult] = await Promise.all([
166
+ client.closed.catch((err) => err),
167
+ client.ready.catch((err) => err)
168
+ ])
169
+
170
+ expect(closedResult)
171
+ .to.be.a('WebTransportError')
172
+ .with.property('message', 'Opening handshake failed.')
173
+ expect(readyResult)
174
+ .to.be.a('WebTransportError')
175
+ .with.property('message', 'Opening handshake failed.')
145
176
  })
146
-
147
- const [closedResult, readyResult] = await Promise.all([
148
- client.closed.catch((err) => err),
149
- client.ready.catch((err) => err)
150
- ])
151
-
152
- expect(closedResult)
153
- .to.be.a('WebTransportError')
154
- .with.property('message', 'Opening handshake failed.')
155
- expect(readyResult)
156
- .to.be.a('WebTransportError')
157
- .with.property('message', 'Opening handshake failed.')
158
- })
177
+ }
159
178
  })
@@ -12,6 +12,8 @@ import { KNOWN_BYTES, KNOWN_BYTES_LENGTH } from './fixtures/known-bytes.js'
12
12
  describe('unidirectional streams', function () {
13
13
  /** @type {import('../lib/dom').WebTransport | undefined} */
14
14
  let client
15
+ let forceReliable = false
16
+ if (process.env.USE_HTTP2 === 'true') forceReliable = true
15
17
 
16
18
  // @ts-ignore
17
19
  afterEach(async () => {
@@ -32,7 +34,9 @@ describe('unidirectional streams', function () {
32
34
  algorithm: 'sha-256',
33
35
  value: readCertHash(process.env.CERT_HASH)
34
36
  }
35
- ]
37
+ ],
38
+ // @ts-ignore
39
+ forceReliable
36
40
  }
37
41
  )
38
42
  await client.ready
@@ -47,6 +51,7 @@ describe('unidirectional streams', function () {
47
51
 
48
52
  // the remote will close the session
49
53
  const result = await client.closed
54
+ client = undefined
50
55
 
51
56
  // should receive the default close info
52
57
  expect(result).to.have.property('reason', '')
@@ -63,7 +68,9 @@ describe('unidirectional streams', function () {
63
68
  algorithm: 'sha-256',
64
69
  value: readCertHash(process.env.CERT_HASH)
65
70
  }
66
- ]
71
+ ],
72
+ // @ts-ignore
73
+ forceReliable
67
74
  }
68
75
  )
69
76
  await client.ready
@@ -77,7 +84,13 @@ describe('unidirectional streams', function () {
77
84
  })
78
85
 
79
86
  it('handles fin when paused due to backpressure', async function () {
80
- this.timeout(6000)
87
+ let addpolyfill = 0
88
+ if (
89
+ process.env.USE_POLYFILL === 'true' ||
90
+ process.env.USE_PONYFILL === 'true'
91
+ )
92
+ addpolyfill = 4000
93
+ this.timeout(6000 + addpolyfill)
81
94
  client = new WebTransport(
82
95
  `${process.env.SERVER_URL}/unidirectional_server_delay_before_read`,
83
96
  {
@@ -86,7 +99,9 @@ describe('unidirectional streams', function () {
86
99
  algorithm: 'sha-256',
87
100
  value: readCertHash(process.env.CERT_HASH)
88
101
  }
89
- ]
102
+ ],
103
+ // @ts-ignore
104
+ forceReliable
90
105
  }
91
106
  )
92
107
  await client.ready
@@ -110,6 +125,7 @@ describe('unidirectional streams', function () {
110
125
 
111
126
  // the remote will close the session cleanly if everything was ok
112
127
  await client.closed
128
+ client = undefined
113
129
 
114
130
  // should receive the default close info, not true on chromium
115
131
  // expect(result).to.have.property('reason', '')