@fails-components/webtransport 1.0.11 → 1.1.2

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 (53) hide show
  1. package/dist/lib/client.d.ts.map +1 -1
  2. package/dist/lib/features.d.ts.map +1 -1
  3. package/dist/lib/http2/browser/browser.d.ts.map +1 -1
  4. package/dist/lib/http2/browser/browserparser.d.ts.map +1 -1
  5. package/dist/lib/http2/node/client.d.ts.map +1 -1
  6. package/dist/lib/http2/node/server.d.ts +4 -4
  7. package/dist/lib/http2/node/server.d.ts.map +1 -1
  8. package/dist/lib/http2/node/websocketparser.d.ts.map +1 -1
  9. package/dist/lib/http2/parserbase.d.ts.map +1 -1
  10. package/dist/lib/http2/session.d.ts.map +1 -1
  11. package/dist/lib/index.browser.d.ts.map +1 -1
  12. package/dist/lib/index.node.d.ts.map +1 -1
  13. package/dist/lib/index.types.d.ts.map +1 -1
  14. package/dist/lib/server.d.ts.map +1 -1
  15. package/dist/lib/session.d.ts +8 -4
  16. package/dist/lib/session.d.ts.map +1 -1
  17. package/dist/lib/stream.d.ts.map +1 -1
  18. package/dist/lib/types.d.ts +9 -4
  19. package/dist/lib/types.d.ts.map +1 -1
  20. package/dist/lib/webtransport.browser.d.ts.map +1 -1
  21. package/dist/lib/webtransport.node.d.ts.map +1 -1
  22. package/dist/lib/webtransportbase.d.ts.map +1 -1
  23. package/eslint.config.js +51 -0
  24. package/lib/client.js +1 -0
  25. package/lib/features.js +2 -0
  26. package/lib/http2/browser/browser.js +2 -1
  27. package/lib/http2/browser/browserparser.js +1 -0
  28. package/lib/http2/node/client.js +7 -3
  29. package/lib/http2/node/server.js +66 -39
  30. package/lib/http2/node/websocketparser.js +1 -0
  31. package/lib/http2/parserbase.js +3 -0
  32. package/lib/http2/session.js +3 -0
  33. package/lib/http2/stream.js +1 -1
  34. package/lib/index.browser.js +0 -1
  35. package/lib/index.node.js +0 -1
  36. package/lib/index.types.js +0 -1
  37. package/lib/server.js +7 -4
  38. package/lib/session.js +8 -2
  39. package/lib/stream.js +11 -3
  40. package/lib/types.ts +9 -4
  41. package/lib/webtransport.browser.js +10 -6
  42. package/lib/webtransport.node.js +9 -6
  43. package/lib/webtransportbase.js +2 -0
  44. package/old_test/echoclient.js +0 -1
  45. package/old_test/testsuite.js +4 -4
  46. package/package.json +5 -5
  47. package/test/datagrams.spec.js +0 -1
  48. package/test/fixtures/read-stream.js +20 -7
  49. package/test/fixtures/reader-value.js +0 -5
  50. package/test/fixtures/server.js +51 -1
  51. package/test/fixtures/webtransport.browser.js +1 -2
  52. package/test/index.js +1 -0
  53. package/test/session.spec.js +16 -0
@@ -97,6 +97,7 @@ export class Http2WebTransportServer {
97
97
  // ok we got a session and want to measure RTT
98
98
  let pingsender = setInterval(() => {
99
99
  if (!session.closed)
100
+ // eslint-disable-next-line no-unused-vars
100
101
  session.ping((err, duration, payload) => {
101
102
  if (!err) {
102
103
  rtt = adjust * duration + (1 - adjust) * rtt
@@ -127,20 +128,31 @@ export class Http2WebTransportServer {
127
128
  'upgrade',
128
129
  (request, stream /* actually a socket */, head) => {
129
130
  let path = request.url
130
- const header = request.headers
131
131
  if (!path) {
132
132
  stream.destroy()
133
133
  return
134
134
  }
135
+ while (path.length > 1 && path[0] === '/' && path[1] === '/') {
136
+ path = path?.slice(1)
137
+ }
138
+ const header = { ...request.headers, ':path': path }
135
139
  const websocketProt = this.checkProtocolHeader(header)
136
140
  if (!websocketProt) {
137
141
  stream.destroy()
138
142
  return
139
143
  }
140
- while (path.length > 1 && path[0] === '/' && path[1] === '/') {
141
- path = path?.slice(1)
142
- }
143
- if (this.paths[path]) {
144
+ if (this.hasrequesthandler) {
145
+ stream.head = head
146
+
147
+ const retObj = {
148
+ header,
149
+ session: stream,
150
+ protocol: 'websocketoverhttp1',
151
+ head,
152
+ transportPrivate: { websocketProt }
153
+ }
154
+ this.jsobj.onSessionRequest(retObj)
155
+ } else if (this.paths[path]) {
144
156
  this.sendHttp1Headers({ stream, header, protocol: websocketProt })
145
157
  .then(() => {
146
158
  const retObj = {
@@ -189,16 +201,6 @@ export class Http2WebTransportServer {
189
201
  log('Problem sendHttp1Header', error)
190
202
  stream.destroy()
191
203
  })
192
- } else if (this.hasrequesthandler) {
193
- stream.head = head
194
-
195
- const retObj = {
196
- header,
197
- session: stream,
198
- protocol: 'websocketoverhttp1',
199
- head
200
- }
201
- this.jsobj.onSessionRequest(retObj)
202
204
  } else {
203
205
  stream.destroy()
204
206
  }
@@ -245,7 +247,16 @@ export class Http2WebTransportServer {
245
247
  while (path.length > 1 && path[0] === '/' && path[1] === '/') {
246
248
  path = path?.slice(1)
247
249
  }
248
- if (this.paths[path]) {
250
+ header[':path'] = path // also adapt it for the middleware
251
+ if (this.hasrequesthandler) {
252
+ const retObj = {
253
+ header,
254
+ session: stream,
255
+ protocol: websocketProt ? 'websocket' : 'capsule',
256
+ transportPrivate: { websocketProt }
257
+ }
258
+ this.jsobj.onSessionRequest(retObj)
259
+ } else if (this.paths[path]) {
249
260
  const {
250
261
  0x2b65: remoteBidirectionalStreams = undefined,
251
262
  0x2b64: remoteUnidirectionalStreams = undefined,
@@ -327,19 +338,6 @@ export class Http2WebTransportServer {
327
338
  if (websocketProt) resp['sec-websocket-protocol'] = websocketProt
328
339
  stream.respond(resp)
329
340
  this.jsobj.onHttpWTSessionVisitor(retObj)
330
- } else if (this.hasrequesthandler) {
331
- const retObj = {
332
- header,
333
- session: stream,
334
- protocol: websocketProt ? 'websocket' : 'capsule'
335
- }
336
- const resp = {
337
- ':status': '200'
338
- }
339
- // @ts-ignore
340
- if (websocketProt) resp['sec-websocket-protocol'] = websocketProt
341
- stream.respond(resp)
342
- this.jsobj.onSessionRequest(retObj)
343
341
  } else {
344
342
  stream.respond({
345
343
  ':status': '404'
@@ -381,10 +379,11 @@ export class Http2WebTransportServer {
381
379
  }
382
380
 
383
381
  /**
384
- * @param {string} cert
385
- * @param {string} privKey
382
+ * @param {string|string[]} cert
383
+ * @param {string|string[]} privKey
386
384
  * @param {boolean} http2only
387
385
  * */
386
+ // eslint-disable-next-line no-unused-vars
388
387
  updateCert(cert, privKey, http2only) {
389
388
  this.serverInt.setSecureContext({ key: privKey, cert })
390
389
  }
@@ -437,17 +436,35 @@ export class Http2WebTransportServer {
437
436
  /**
438
437
  * @param {import('../../types.js').NativeFinishSessionRequest} args
439
438
  */
440
- finishSessionRequest({ header, session: stream, status, protocol, head }) {
439
+ finishSessionRequest({
440
+ header,
441
+ userData,
442
+ session: stream,
443
+ status,
444
+ protocol,
445
+ head,
446
+ path,
447
+ transportPrivate
448
+ }) {
441
449
  if (status !== 200) {
442
450
  if (protocol === 'websocketoverhttp1') {
443
451
  stream.destroy()
444
452
  } else {
445
- stream.close(constants.HTTP_STATUS_NOT_FOUND)
453
+ stream.respond({
454
+ ':status': status.toString()
455
+ })
456
+ stream.end()
457
+ stream.close()
446
458
  }
447
459
  } else {
448
460
  if (protocol === 'websocketoverhttp1') {
449
- // @ts-ignore
450
- this.sendHttp1Headers({ stream, header })
461
+ this.sendHttp1Headers({
462
+ // @ts-ignore
463
+ stream,
464
+ header,
465
+ // @ts-ignore
466
+ protocol: transportPrivate.websocketProt
467
+ })
451
468
  .then(() => {
452
469
  const retObj = {
453
470
  session: new Http2WebTransportSession({
@@ -484,8 +501,9 @@ export class Http2WebTransportServer {
484
501
  this.sessionShouldAutoTuneReceiveWindow,
485
502
  receiveWindowSizeLimit: this.sessionFlowControlWindowSizeLimit
486
503
  }),
487
- path: header[':path'],
488
- header
504
+ path,
505
+ header,
506
+ userData
489
507
  }
490
508
  // @ts-ignore
491
509
  this.jsobj.onHttpWTSessionVisitor(retObj)
@@ -494,6 +512,14 @@ export class Http2WebTransportServer {
494
512
  log('sendHttp1Headers error', error)
495
513
  })
496
514
  } else {
515
+ const resp = {
516
+ ':status': '200'
517
+ }
518
+ // @ts-ignore
519
+ if (transportPrivate?.websocketProt)
520
+ // @ts-ignore
521
+ resp['sec-websocket-protocol'] = transportPrivate.websocketProt
522
+ stream.respond(resp)
497
523
  const {
498
524
  0x2b65: remoteBidirectionalStreams = undefined,
499
525
  0x2b64: remoteUnidirectionalStreams = undefined,
@@ -566,8 +592,9 @@ export class Http2WebTransportServer {
566
592
  this.sessionShouldAutoTuneReceiveWindow,
567
593
  receiveWindowSizeLimit: this.sessionFlowControlWindowSizeLimit
568
594
  }),
569
- path: header[':path'],
570
- header
595
+ path,
596
+ header,
597
+ userData
571
598
  }
572
599
  // @ts-ignore
573
600
  this.jsobj.onHttpWTSessionVisitor(retObj)
@@ -863,6 +863,7 @@ export class WebSocketParser extends ParserBaseHttp2 {
863
863
  /**
864
864
  * @param {number} code
865
865
  */
866
+ // eslint-disable-next-line no-unused-vars
866
867
  closeHttp2Stream(code) {
867
868
  const stream = this.stream
868
869
  if (stream.close) {
@@ -65,6 +65,7 @@ export class ParserBase {
65
65
  * @abstract
66
66
  * @param {Buffer|Uint8Array} data
67
67
  */
68
+ // eslint-disable-next-line no-unused-vars
68
69
  parseData(data) {
69
70
  throw new Error('Implement parseData in derived Class')
70
71
  }
@@ -73,6 +74,7 @@ export class ParserBase {
73
74
  * @abstract
74
75
  * @param{{type: Number, headerVints: Array<Number|bigint>, payload: Uint8Array|undefined, end?: () => void}} bs
75
76
  */
77
+ // eslint-disable-next-line no-unused-vars
76
78
  writeCapsule({ type, headerVints, payload, end }) {
77
79
  throw new Error('Implement writeCapsule in derived Class')
78
80
  }
@@ -252,6 +254,7 @@ export class ParserBase {
252
254
  /**
253
255
  * @param {number} code
254
256
  */
257
+ // eslint-disable-next-line no-unused-vars
255
258
  closeHttp2Stream(code) {
256
259
  throw new Error('Implement closeHttp2Stream in derived Class')
257
260
  }
@@ -136,6 +136,7 @@ export class Http2WebTransportSession {
136
136
  /**
137
137
  * @param {{sendGroup: WebTransportSendGroup|null, sendOrder: number, waitUntilAvailable: boolean}} opts
138
138
  */
139
+ // eslint-disable-next-line no-unused-vars
139
140
  orderUnidiStream({ sendGroup, sendOrder, waitUntilAvailable }) {
140
141
  const canopen = this.streamIdMngrUni.canOpenNextOutgoingStream()
141
142
  const maxset = this.streamIdMngrUni.isMaxStreamSet() // we block if the maxsetting did not arrive
@@ -167,6 +168,7 @@ export class Http2WebTransportSession {
167
168
  /**
168
169
  * @param {{sendGroup: WebTransportSendGroup|null, sendOrder: number, waitUntilAvailable: boolean}} opts
169
170
  */
171
+ // eslint-disable-next-line no-unused-vars
170
172
  orderBidiStream({ sendGroup, sendOrder, waitUntilAvailable }) {
171
173
  const canopen = this.streamIdMngrBi.canOpenNextOutgoingStream()
172
174
  const maxset = this.streamIdMngrBi.isMaxStreamSet() // we block if the maxsetting did not arrive
@@ -265,6 +267,7 @@ export class Http2WebTransportSession {
265
267
  } else if (this.ws) {
266
268
  // we are at the Browser, so we use the connection rtt?
267
269
  // @ts-ignore
270
+ // eslint-disable-next-line no-undef
268
271
  return navigator?.connection?.rtt || 26
269
272
  }
270
273
  }
@@ -173,7 +173,7 @@ export class Http2WebTransportStream {
173
173
  cur.data.byteOffset + len,
174
174
  cur.data.byteLength - len
175
175
  ),
176
- fin: false || cur.fin
176
+ fin: cur.fin
177
177
  })
178
178
  buffer.fin = false // next round
179
179
  } else {
@@ -1,4 +1,3 @@
1
- /* eslint-disable no-prototype-builtins */
2
1
  // Copyright (c) 2022 Marten Richter or other contributers (see commit). All rights reserved.
3
2
  // Use of this source code is governed by a BSD-style license that can be
4
3
  // found in the LICENSE file.
package/lib/index.node.js CHANGED
@@ -1,4 +1,3 @@
1
- /* eslint-disable no-prototype-builtins */
2
1
  // Copyright (c) 2022 Marten Richter or other contributers (see commit). All rights reserved.
3
2
  // Use of this source code is governed by a BSD-style license that can be
4
3
  // found in the LICENSE file.
@@ -1,4 +1,3 @@
1
- /* eslint-disable no-prototype-builtins */
2
1
  // Copyright (c) 2022 Marten Richter or other contributers (see commit). All rights reserved.
3
2
  // Use of this source code is governed by a BSD-style license that can be
4
3
  // found in the LICENSE file.
package/lib/server.js CHANGED
@@ -82,8 +82,8 @@ class TransportIntServerProxy {
82
82
  }
83
83
 
84
84
  /**
85
- * @param {string} cert
86
- * @param {string} privKey
85
+ * @param {string|string[]} cert
86
+ * @param {string|string[]} privKey
87
87
  * @param {boolean} http2only
88
88
  * */
89
89
  updateCert(cert, privKey, http2only) {
@@ -245,16 +245,18 @@ export class HttpServer {
245
245
  * @param {ServerSessionRequestEvent} args
246
246
  */
247
247
  onSessionRequest(args) {
248
- if (args.promise && args.header) {
248
+ if ((args.promise || args.protocol !== 'http3:libquiche') && args.header) {
249
249
  if (!this.requestHandler) throw new Error('Request handler not set')
250
250
  this.requestHandler({ header: args.header })
251
251
  .then((/** @type {any} */ result) => {
252
252
  log('oSR', result)
253
- args.object.finishSessionRequest({
253
+ this.transportInt.finishSessionRequest({
254
254
  promise: args.promise,
255
255
  header: args.header,
256
256
  session: args.session,
257
257
  head: args.head,
258
+ transportPrivate: args.transportPrivate,
259
+ protocol: args.protocol,
258
260
  ...result
259
261
  })
260
262
  })
@@ -272,6 +274,7 @@ export class HttpServer {
272
274
  const sesobj = new HttpWTSession({
273
275
  object: args.session,
274
276
  header: args.header,
277
+ userData: args.userData ?? {},
275
278
  parentobj: this
276
279
  })
277
280
  args.session.jsobj = sesobj
package/lib/session.js CHANGED
@@ -50,7 +50,8 @@ export class HttpWTSession {
50
50
  * @param {object} args
51
51
  * @param {import('./types').NativeHttpWTSession} [args.object]
52
52
  * @param {HttpServer | HttpClient} args.parentobj
53
- * @param {any | undefined} [args.header= undefined]
53
+ * @param {Object | undefined} [args.header= undefined]
54
+ * @param {Object | undefined} [args.userData= undefined]
54
55
  */
55
56
  constructor(args) {
56
57
  if (args.object) {
@@ -68,8 +69,10 @@ export class HttpWTSession {
68
69
  this.readyResolve = null
69
70
  /** @type {(() => void) | null | undefined} */
70
71
  this.closeHook = null
71
- /** @type {(any | null | undefined)} */
72
+ /** @type {(Object | null | undefined)} */
72
73
  this.header = args.header
74
+ /** @type {(Object | null | undefined)} */
75
+ this.userData = args.userData
73
76
 
74
77
  /** @type {Promise<void>} */
75
78
  this.ready = new Promise((resolve, reject) => {
@@ -136,6 +139,7 @@ export class HttpWTSession {
136
139
  start: (controller) => {
137
140
  this.outgoDatagramController = controller
138
141
  },
142
+ // eslint-disable-next-line no-unused-vars
139
143
  write: (chunk, controller) => {
140
144
  if (this.state === 'closed') throw new Error('Session is closed')
141
145
  if (chunk instanceof Uint8Array) {
@@ -587,6 +591,7 @@ export class HttpWTSession {
587
591
  /**
588
592
  * @param {DatagramSendEvent} args
589
593
  */
594
+ // eslint-disable-next-line no-unused-vars
590
595
  onDatagramSend(args) {
591
596
  if (this.state === 'closed') return
592
597
  this.writeDatagramRej.shift()
@@ -601,6 +606,7 @@ export class HttpWTSession {
601
606
  /**
602
607
  * @param {GoawayReceivedEvent} args
603
608
  */
609
+ // eslint-disable-next-line no-unused-vars
604
610
  onGoAwayReceived(args) {
605
611
  if (this.drainingResolve) this.drainingResolve(undefined)
606
612
  this.state = 'draining'
package/lib/stream.js CHANGED
@@ -52,9 +52,9 @@ export class HttpWTStream {
52
52
  this.pendingres = null
53
53
 
54
54
  /** @type {WebTransportReceiveStream} */
55
- this.readable // eslint-disable-line no-unused-expressions
55
+ this.readable
56
56
  /** @type {WebTransportSendStream} */
57
- this.writable // eslint-disable-line no-unused-expressions
57
+ this.writable
58
58
 
59
59
  /** @type {Promise<void> | null} */
60
60
  this.pendingoperationRead = null
@@ -69,12 +69,13 @@ export class HttpWTStream {
69
69
  this.objint.startReading()
70
70
  },
71
71
  pull: async (
72
+ // eslint-disable-next-line no-unused-vars
72
73
  /** @type {import("stream/web").ReadableByteStreamController} */ controller
73
74
  ) => {
74
75
  if (this.readableclosed) {
75
76
  return Promise.resolve()
76
77
  }
77
-
78
+ // eslint-disable-next-line no-unused-vars
78
79
  this.pendingoperationRead = new Promise((resolve, reject) => {
79
80
  this.pendingresRead = resolve
80
81
  })
@@ -83,6 +84,7 @@ export class HttpWTStream {
83
84
  },
84
85
  cancel: (/** @type {{ code: number; }} */ reason) => {
85
86
  /** @type {Promise<void>} */
87
+ // eslint-disable-next-line no-unused-vars
86
88
  const promise = new Promise((resolve, reject) => {
87
89
  this.cancelres = resolve
88
90
  })
@@ -128,6 +130,7 @@ export class HttpWTStream {
128
130
  start: (controller) => {
129
131
  this.writableController = controller
130
132
  },
133
+ // eslint-disable-next-line no-unused-vars
131
134
  write: (chunk, controller) => {
132
135
  if (this.writableclosed) {
133
136
  return Promise.resolve()
@@ -137,6 +140,7 @@ export class HttpWTStream {
137
140
  wchunk = new Uint8Array(wchunk)
138
141
  }
139
142
  if (wchunk instanceof Uint8Array) {
143
+ // eslint-disable-next-line no-unused-vars
140
144
  this.pendingoperation = new Promise((resolve, reject) => {
141
145
  this.pendingres = resolve
142
146
  })
@@ -161,6 +165,7 @@ export class HttpWTStream {
161
165
  return Promise.resolve()
162
166
  }
163
167
  this.objint.streamFinal()
168
+ // eslint-disable-next-line no-unused-vars
164
169
  this.pendingoperation = new Promise((resolve, reject) => {
165
170
  this.pendingres = resolve
166
171
  })
@@ -168,6 +173,7 @@ export class HttpWTStream {
168
173
  },
169
174
  abort: (reason) => {
170
175
  if (this.writableclosed) {
176
+ // eslint-disable-next-line no-unused-vars
171
177
  return new Promise((resolve, reject) => {
172
178
  resolve()
173
179
  })
@@ -179,6 +185,7 @@ export class HttpWTStream {
179
185
  else code = reason.code
180
186
  }
181
187
  /** @type {Promise<void>} */
188
+ // eslint-disable-next-line no-unused-vars
182
189
  const promise = new Promise((resolve, reject) => {
183
190
  this.abortres = resolve
184
191
  })
@@ -349,6 +356,7 @@ export class HttpWTStream {
349
356
  /**
350
357
  * @param {StreamWriteEvent} args
351
358
  */
359
+ // eslint-disable-next-line no-unused-vars
352
360
  onStreamWrite(args) {
353
361
  // we ignore success
354
362
  if (this.pendingoperation) {
package/lib/types.ts CHANGED
@@ -4,7 +4,7 @@ import type {
4
4
  WebTransportOptions,
5
5
  WebTransportSendGroup
6
6
  } from './dom'
7
- import type { IncomingHttpHeaders, Http2Stream } from 'http2'
7
+ import type { IncomingHttpHeaders, Http2Stream, ServerHttp2Stream } from 'http2'
8
8
  import { ParserBase } from './http2/parserbase'
9
9
  import { Http2WebTransportSession } from './http2/session'
10
10
  import { HttpClient } from './client'
@@ -103,11 +103,14 @@ export interface ReadBuffer {
103
103
  }
104
104
 
105
105
  export interface NativeFinishSessionRequest {
106
+ path: string
106
107
  header: IncomingHttpHeaders
107
- session: Http2Stream
108
+ session: ServerHttp2Stream
108
109
  status: number
109
110
  protocol: 'capsule' | 'websocket' | 'websocketoverhttp1' | 'http3'
110
111
  head?: Buffer
112
+ userData?: object
113
+ transportPrivate?: object
111
114
  }
112
115
 
113
116
  export type Purpose =
@@ -219,6 +222,7 @@ export interface HttpWTServerSessionVisitorEvent
219
222
  extends HttpWTSessionVisitorEvent {
220
223
  path: string
221
224
  header: Object
225
+ userData?: Object | undefined
222
226
  }
223
227
 
224
228
  export interface ServerSessionRequestEvent {
@@ -228,6 +232,7 @@ export interface ServerSessionRequestEvent {
228
232
  session: any
229
233
  object?: any // the actual transport object itself, actually present on all messages, but required here
230
234
  protocol: string //'capsule' | 'websocket' | 'http3'
235
+ transportPrivate?: Object //private information from the transport object
231
236
  }
232
237
 
233
238
  /**
@@ -291,8 +296,8 @@ export interface HttpServerInit extends HttpWebTransportInit {
291
296
  port: string | number
292
297
  host: string
293
298
  secret: string
294
- cert: string
295
- privKey: string
299
+ cert: string | string[]
300
+ privKey: string | string[]
296
301
  maxConnections?: number
297
302
  initialStreamFlowControlWindow?: number
298
303
  streamShouldAutoTuneReceiveWindow?: boolean
@@ -37,6 +37,7 @@ if (globalThis.WebTransport) {
37
37
  .then(() => {
38
38
  try {
39
39
  transport.close()
40
+ // eslint-disable-next-line no-empty, no-unused-vars
40
41
  } catch (error) {}
41
42
  })
42
43
  .catch(() => {})
@@ -61,9 +62,10 @@ export class WebTransportPonyfill extends WebTransportBase {
61
62
  * @param{{client: HttpClient, sessionint: HttpWTSession, ourl: URL}} args
62
63
  */
63
64
  startUpConnection({ client, sessionint, ourl }) {
65
+ const path = ourl.pathname + (ourl.search ?? '')
64
66
  client
65
- .handleConnection({ createTransport: true, path: ourl.pathname })
66
- .then(() => client.createWTSession(sessionint, ourl.pathname))
67
+ .handleConnection({ createTransport: true, path })
68
+ .then(() => client.createWTSession(sessionint, path))
67
69
  .catch((error) => {
68
70
  client.closeHookSession()
69
71
  sessionint.readyReject(error)
@@ -82,6 +84,7 @@ export class WebTransportPonyfill extends WebTransportBase {
82
84
  createClient(args) {
83
85
  this.curtype = 'websocket'
84
86
  const client = new HttpClient({
87
+ // eslint-disable-next-line no-unused-vars
85
88
  createReliableClient: (client) => {
86
89
  // @ts-ignore
87
90
  return new Http2WebTransportBrowser({ ...args })
@@ -214,8 +217,8 @@ export class WebTransportPolyfill {
214
217
  // @ts-ignore
215
218
  this.datagrams = {}
216
219
  // @ts-ignore
217
- // eslint-disable-next-line no-undef
218
220
  this.datagrams.readable = new ReadableStream({
221
+ // eslint-disable-next-line no-unused-vars
219
222
  start: async (controller) => {
220
223
  await this.ready
221
224
  this.datagramsReader = this.curtransport.datagrams.readable.getReader()
@@ -230,12 +233,13 @@ export class WebTransportPolyfill {
230
233
  }
231
234
  })
232
235
  // @ts-ignore
233
- // eslint-disable-next-line no-undef
234
236
  this.datagrams.writable = new WritableStream({
237
+ // eslint-disable-next-line no-unused-vars
235
238
  start: async (controller) => {
236
239
  await this.ready
237
240
  this.datagramsWriter = this.curtransport.datagrams.writable.getWriter()
238
241
  },
242
+ // eslint-disable-next-line no-unused-vars
239
243
  write: async (chunk, controller) => {
240
244
  await this.datagramsWriter.write(chunk)
241
245
  },
@@ -246,8 +250,8 @@ export class WebTransportPolyfill {
246
250
  await this.datagramsWriter.close()
247
251
  }
248
252
  })
249
- // eslint-disable-next-line no-undef
250
253
  this.incomingBidirectionalStreams = new ReadableStream({
254
+ // eslint-disable-next-line no-unused-vars
251
255
  start: async (controller) => {
252
256
  await this.ready
253
257
  this.incomingBidirectionalStreamsReader =
@@ -263,8 +267,8 @@ export class WebTransportPolyfill {
263
267
  await this.incomingBidirectionalStreamsReader.cancel(reason)
264
268
  }
265
269
  })
266
- // eslint-disable-next-line no-undef
267
270
  this.incomingUnidirectionalStreams = new ReadableStream({
271
+ // eslint-disable-next-line no-unused-vars
268
272
  start: async (controller) => {
269
273
  await this.ready
270
274
  this.incomingUnidirectionalStreamsReader =
@@ -23,7 +23,6 @@ let Http3WebTransportClient
23
23
  */
24
24
  let quicheLoadedReady
25
25
  // @ts-ignore
26
- // eslint-disable-next-line no-unused-vars
27
26
  export const quicheLoaded = new Promise((resolve, reject) => {
28
27
  // @ts-ignore
29
28
  import('@fails-components/webtransport-transport-http3-quiche')
@@ -75,17 +74,18 @@ export class WebTransport extends WebTransportBase {
75
74
  * @param{{client: HttpClient, sessionint: HttpWTSession, ourl: URL}} args
76
75
  */
77
76
  startUpConnection({ client, sessionint, ourl }) {
77
+ const path = ourl.pathname + (ourl.search ?? '')
78
78
  client
79
- .handleConnection({ createTransport: true, path: ourl.pathname })
80
- .then(() => client.createWTSession(sessionint, ourl.pathname))
79
+ .handleConnection({ createTransport: true, path })
80
+ .then(() => client.createWTSession(sessionint, path))
81
81
  .catch((error) => {
82
82
  if (client.transportIntSwitchToReliable) {
83
83
  log('Connecting to unreliable failed:', error)
84
84
  log('Now switching to reliable')
85
85
  client.transportIntSwitchToReliable()
86
86
  client
87
- .handleConnection({ createTransport: false, path: ourl.pathname })
88
- .then(() => client.createWTSession(sessionint, ourl.pathname))
87
+ .handleConnection({ createTransport: false, path })
88
+ .then(() => client.createWTSession(sessionint, path))
89
89
  .catch((error) => {
90
90
  client.closeHookSession()
91
91
  sessionint.readyReject(error)
@@ -109,9 +109,11 @@ export class WebTransport extends WebTransportBase {
109
109
  */
110
110
  createClient(args) {
111
111
  let createUnreliableClient
112
- if (!quicheLoadedReady)
112
+ // @ts-ignore
113
+ if (!quicheLoadedReady && !args?.forceReliable)
113
114
  throw new Error('Lib quiche loading attempt did not end')
114
115
  if (checkQuicheInit) {
116
+ // eslint-disable-next-line no-unused-vars
115
117
  createUnreliableClient = function (/** @type {any} */ _client) {
116
118
  if (
117
119
  // @ts-ignore
@@ -130,6 +132,7 @@ export class WebTransport extends WebTransportBase {
130
132
  }
131
133
  }
132
134
  const client = new HttpClient({
135
+ // eslint-disable-next-line no-unused-vars
133
136
  createReliableClient: function (client) {
134
137
  // @ts-ignore
135
138
  return new Http2WebTransportClient({ ...args })
@@ -59,6 +59,7 @@ export class WebTransportBase {
59
59
  * @return {{sessionint: HttpWTSession, client: HttpClient}}
60
60
  * @abstract
61
61
  */
62
+ // eslint-disable-next-line no-unused-vars
62
63
  createClient(args) {
63
64
  throw new Error('Implement createClient')
64
65
  }
@@ -67,6 +68,7 @@ export class WebTransportBase {
67
68
  * @param{{client: HttpClient, sessionint: HttpWTSession, ourl: URL}} args
68
69
  * @abstract
69
70
  */
71
+ // eslint-disable-next-line no-unused-vars
70
72
  startUpConnection({ client, sessionint, ourl }) {
71
73
  throw new Error('Implement startUpConnection')
72
74
  }
@@ -19,7 +19,6 @@ async function startClientTests(args, hashes) {
19
19
  value: Buffer.from(el.value.split(':').map((el) => parseInt(el, 16)))
20
20
  }))
21
21
  }
22
- // eslint-disable-next-line no-undef
23
22
  console.log('hashagrs', hashargs)
24
23
  const transport = new WebTransport(url, hashargs)
25
24
  transport.closed
@@ -147,7 +147,7 @@ export async function echoTestsConnection(transport) {
147
147
  const resultArray1 = new Uint8Array(i)
148
148
  console.log('TEST 1: start')
149
149
 
150
- while (true && i > 0) {
150
+ while (i > 0) {
151
151
  const { done, value } = await reader.read()
152
152
  if (done) {
153
153
  break
@@ -199,7 +199,7 @@ export async function echoTestsConnection(transport) {
199
199
  refArray2.set(data4, data3.length)
200
200
 
201
201
  const resultArray2 = new Uint8Array(i)
202
- while (true && i > 0) {
202
+ while (i > 0) {
203
203
  const { done, value } = await readbd.read()
204
204
  if (done) {
205
205
  break
@@ -255,7 +255,7 @@ export async function echoTestsConnection(transport) {
255
255
 
256
256
  const resultArray3 = new Uint8Array(i)
257
257
 
258
- while (true && i > 0) {
258
+ while (i > 0) {
259
259
  const { done, value } = await readud.read()
260
260
  if (done) {
261
261
  break
@@ -302,7 +302,7 @@ export async function echoTestsConnection(transport) {
302
302
  pos = 0
303
303
  const resultArray4 = new Uint8Array(i)
304
304
 
305
- while (true && i > 0) {
305
+ while (i > 0) {
306
306
  const { done, value } = await readdg.read()
307
307
  if (done) {
308
308
  break