@fails-components/webtransport 1.3.0 → 1.4.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/http2/browser/browser.d.ts.map +1 -1
- package/dist/lib/http2/node/client.d.ts.map +1 -1
- package/dist/lib/http2/node/server.d.ts.map +1 -1
- package/eslint.config.js +13 -2
- package/lib/http2/browser/browser.js +2 -0
- package/lib/http2/node/client.js +6 -1
- package/lib/http2/node/server.js +39 -3
- package/lib/webtransport.browser.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../../../lib/http2/browser/browser.js"],"names":[],"mappings":"AAOA;IACE;;OAEG;IACH,kBAFW,OAAO,gBAAgB,EAAE,mBAAmB,EAiCtD;IA9BC,aAA6B;IAC7B,iBAAyC;IACzC,oBAAsC;IACtC,uCACmD;IACnD,wCACoD;IAEpD,oCAC8C;IAC9C,qCAC+C;IAE/C,wCACgD;IAChD,yCAC2D;IAE3D,yCACiD;IACjD,0CAC6D;IAC7D,oDAAoD;IAEpD,OAFW,OAAO,kBAAkB,EAAE,UAAU,CAE1B;IACtB,wBAAwB;IAExB,WAFW,SAAS,CAEM;IAC1B,+BAA+B;IAC/B,uBADW,SAAS,GAAC,MAAM,CACW;IAGxC;;OAEG;IACH,0BAFW;QAAC,IAAI,EAAE,MAAM,CAAA;KAAC,
|
|
1
|
+
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../../../lib/http2/browser/browser.js"],"names":[],"mappings":"AAOA;IACE;;OAEG;IACH,kBAFW,OAAO,gBAAgB,EAAE,mBAAmB,EAiCtD;IA9BC,aAA6B;IAC7B,iBAAyC;IACzC,oBAAsC;IACtC,uCACmD;IACnD,wCACoD;IAEpD,oCAC8C;IAC9C,qCAC+C;IAE/C,wCACgD;IAChD,yCAC2D;IAE3D,yCACiD;IACjD,0CAC6D;IAC7D,oDAAoD;IAEpD,OAFW,OAAO,kBAAkB,EAAE,UAAU,CAE1B;IACtB,wBAAwB;IAExB,WAFW,SAAS,CAEM;IAC1B,+BAA+B;IAC/B,uBADW,SAAS,GAAC,MAAM,CACW;IAGxC;;OAEG;IACH,0BAFW;QAAC,IAAI,EAAE,MAAM,CAAA;KAAC,QA+ExB;IAED;;OAEG;IAEH,oBAHW,MAAM,QAkHhB;IAED,oBAGC;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../lib/http2/node/client.js"],"names":[],"mappings":";AAOA;IACE;;OAEG;IACH,kBAFW,OAAO,gBAAgB,EAAE,mBAAmB,EAkCtD;IA7BC,aAAwB;IACxB,iBAAyC;IACzC,mEAAyE;IACzE,oBAAsC;IACtC,8BAAqD;IACrD,sBAA+C;IAC/C,mBAAyC;IACzC,uCACmD;IACnD,wCACoD;IAEpD,oCAC8C;IAC9C,qCAC+C;IAE/C,wCACgD;IAChD,yCAC2D;IAE3D,yCACiD;IACjD,0CAC6D;IAC7D,oDAAoD;IAEpD,OAFW,OAAO,kBAAkB,EAAE,UAAU,CAE1B;IAGxB,wBAiKC;IAnGC,0DAGC;IAkGH;;OAEG;IACH,oBAFW,MAAM,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../lib/http2/node/client.js"],"names":[],"mappings":";AAOA;IACE;;OAEG;IACH,kBAFW,OAAO,gBAAgB,EAAE,mBAAmB,EAkCtD;IA7BC,aAAwB;IACxB,iBAAyC;IACzC,mEAAyE;IACzE,oBAAsC;IACtC,8BAAqD;IACrD,sBAA+C;IAC/C,mBAAyC;IACzC,uCACmD;IACnD,wCACoD;IAEpD,oCAC8C;IAC9C,qCAC+C;IAE/C,wCACgD;IAChD,yCAC2D;IAE3D,yCACiD;IACjD,0CAC6D;IAC7D,oDAAoD;IAEpD,OAFW,OAAO,kBAAkB,EAAE,UAAU,CAE1B;IAGxB,wBAiKC;IAnGC,0DAGC;IAkGH;;OAEG;IACH,oBAFW,MAAM,QAuEhB;IAED,oBAEC;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../../lib/http2/node/server.js"],"names":[],"mappings":";;AASA;IACE;;OAEG;IACH,kBAFW,OAAO,gBAAgB,EAAE,mBAAmB,
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../../lib/http2/node/server.js"],"names":[],"mappings":";;AASA;IACE;;OAEG;IACH,kBAFW,OAAO,gBAAgB,EAAE,mBAAmB,EAyYtD;IApYC,aAAwB;IACxB,eAA0B;IAE1B,aAAqC;IAMrC,uCACmD;IACnD,wCACoD;IAEpD,oCAA2E;IAC3E,qCAC2C;IAE3C,wCACgD;IAChD,yCAC2D;IAE3D,yCACiD;IACjD,0CAC6D;IAE7D,sCAAsC;IACtC,OADW,OAAO,MAAM,EAAE,OAAO,CAAC,CACnB;IACf,2BAA8B;IAC9B,oDAAoD;IAEpD,OAFW,OAAO,kBAAkB,EAAE,UAAU,CAE1B;IAEtB,2BAA8B;IAG9B,iNAgBE;IAqG6B,4BAYb;IA+NpB;;;OAGG;IACH,4BAHW,OAAO,OAAO,EAAE,mBAAmB,GAClC;QAAC,aAAa,EAAE,MAAM,GAAC,SAAS,CAAC;QAAC,gBAAgB,CAAC,EAAE,MAAM,CAAA;KAAC,CA+BvE;IAED,oBAEC;IAED,mBAGC;IAED;;;;SAIK;IAEL,iBALW,MAAM,GAAC,MAAM,EAAE,WACf,MAAM,GAAC,MAAM,EAAE,aACf,OAAO,QAKjB;IAED;;OAEG;IACH,2BAFW,OAAO,QAIjB;IAED;;OAEG;IACH,cAFW,MAAM,QAIhB;IAED;;OAEG;IACH,+CAFW;QAAC,MAAM,EAAE,OAAO,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,GAAG,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAC,iBA4BvE;IAED;;OAEG;IACH,2IAFW,OAAO,gBAAgB,EAAE,0BAA0B,QAmL7D;CACF"}
|
package/eslint.config.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import js from '@eslint/js'
|
|
2
2
|
import promise from 'eslint-plugin-promise'
|
|
3
3
|
import babelParser from '@babel/eslint-parser'
|
|
4
|
+
import importplug from 'eslint-plugin-import'
|
|
5
|
+
// eslint-disable-next-line import/extensions
|
|
4
6
|
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended'
|
|
5
7
|
import globals from 'globals'
|
|
6
8
|
|
|
@@ -9,7 +11,8 @@ export default [
|
|
|
9
11
|
eslintPluginPrettierRecommended,
|
|
10
12
|
{
|
|
11
13
|
plugins: {
|
|
12
|
-
promise
|
|
14
|
+
promise,
|
|
15
|
+
import: importplug
|
|
13
16
|
},
|
|
14
17
|
languageOptions: {
|
|
15
18
|
globals: {
|
|
@@ -37,7 +40,15 @@ export default [
|
|
|
37
40
|
'import/export': 0,
|
|
38
41
|
'promise/catch-or-return': 'error',
|
|
39
42
|
'no-useless-return': 1,
|
|
40
|
-
camelcase: 1
|
|
43
|
+
camelcase: 1,
|
|
44
|
+
'import/extensions': [
|
|
45
|
+
'error',
|
|
46
|
+
'always',
|
|
47
|
+
{
|
|
48
|
+
js: 'always',
|
|
49
|
+
jsx: 'always'
|
|
50
|
+
}
|
|
51
|
+
]
|
|
41
52
|
}
|
|
42
53
|
},
|
|
43
54
|
{
|
|
@@ -54,10 +54,12 @@ export class Http2WebTransportBrowser {
|
|
|
54
54
|
(/** @type {string} */ el) => 'webtransport_' + el
|
|
55
55
|
)
|
|
56
56
|
if (this.protocols.length > 0) {
|
|
57
|
+
const oldprotocols = protocols
|
|
57
58
|
protocols = protocols
|
|
58
59
|
.filter((el) => el !== 'kDraft1')
|
|
59
60
|
.map((el) => this.protocols.map((el2) => el + '_' + el2))
|
|
60
61
|
.flat(1)
|
|
62
|
+
protocols.push(...oldprotocols) // also need to support no protocol selection
|
|
61
63
|
}
|
|
62
64
|
// eslint-disable-next-line no-undef
|
|
63
65
|
this.clientInt = new WebSocket(url, protocols)
|
package/lib/http2/node/client.js
CHANGED
|
@@ -222,7 +222,12 @@ export class Http2WebTransportClient {
|
|
|
222
222
|
}
|
|
223
223
|
if (this.protocols.length > 0) {
|
|
224
224
|
// @ts-ignore
|
|
225
|
-
requestOpts['wt-available-protocols'] =
|
|
225
|
+
requestOpts['wt-available-protocols'] =
|
|
226
|
+
'"' +
|
|
227
|
+
this.protocols
|
|
228
|
+
.map((el) => el.replace(/\\/g, '\\\\').replace(/"/g, '\\"'))
|
|
229
|
+
.join('","') +
|
|
230
|
+
'"'
|
|
226
231
|
}
|
|
227
232
|
|
|
228
233
|
const stream = this.clientInt.request(requestOpts)
|
package/lib/http2/node/server.js
CHANGED
|
@@ -241,6 +241,40 @@ export class Http2WebTransportServer {
|
|
|
241
241
|
header['wt-available-protocols'] = obj.webtransportProt
|
|
242
242
|
}
|
|
243
243
|
}
|
|
244
|
+
if (
|
|
245
|
+
header[':protocol'] === 'webtransport' &&
|
|
246
|
+
header['wt-available-protocols']
|
|
247
|
+
) {
|
|
248
|
+
let splitted = header['wt-available-protocols']
|
|
249
|
+
// @ts-ignore
|
|
250
|
+
.split(',')
|
|
251
|
+
.map((/** @type {string} */ el) => el.trim())
|
|
252
|
+
if (
|
|
253
|
+
splitted.some(
|
|
254
|
+
(/** @type {string} */ el) =>
|
|
255
|
+
typeof el !== 'string' ||
|
|
256
|
+
el.length < 2 ||
|
|
257
|
+
el[0] !== '"' ||
|
|
258
|
+
el.at(-1) !== '"'
|
|
259
|
+
)
|
|
260
|
+
) {
|
|
261
|
+
stream.respond({
|
|
262
|
+
':status': '406'
|
|
263
|
+
})
|
|
264
|
+
stream.close(constants.NGHTTP2_REFUSED_STREAM)
|
|
265
|
+
return
|
|
266
|
+
}
|
|
267
|
+
splitted = splitted.map((/** @type {string} */ el) => el.slice(1, -1))
|
|
268
|
+
if (
|
|
269
|
+
splitted.some((/** @type {string} */ el) => /\\([^"\\])/.test(el))
|
|
270
|
+
) {
|
|
271
|
+
stream.close(constants.NGHTTP2_REFUSED_STREAM)
|
|
272
|
+
return
|
|
273
|
+
}
|
|
274
|
+
header['wt-available-protocols'] = splitted.map(
|
|
275
|
+
(/** @type {string} */ el) => el.replace(/\\(["\\])/g, '$1')
|
|
276
|
+
)
|
|
277
|
+
}
|
|
244
278
|
if (header[':protocol'] !== 'webtransport' && !websocketProt) {
|
|
245
279
|
stream.respond({
|
|
246
280
|
':status': '406'
|
|
@@ -393,11 +427,13 @@ export class Http2WebTransportServer {
|
|
|
393
427
|
prots = prots.filter((el) => el[1] === selWtVersion)
|
|
394
428
|
/** @type {{websocketProt: string|undefined, webtransportProt?: string}} */
|
|
395
429
|
const retObj = { websocketProt: prots[0].slice(0, 2).join('_') }
|
|
396
|
-
if (prots[
|
|
430
|
+
if (prots.some((el) => el[2])) {
|
|
397
431
|
// @ts-ignore
|
|
398
432
|
retObj.webtransportProt = [
|
|
399
|
-
...new Set(
|
|
400
|
-
|
|
433
|
+
...new Set(
|
|
434
|
+
prots.filter((el) => el[2]).map((el) => el.slice(2).join('_'))
|
|
435
|
+
)
|
|
436
|
+
]
|
|
401
437
|
}
|
|
402
438
|
return retObj
|
|
403
439
|
} else return { websocketProt: undefined }
|
|
@@ -3,7 +3,7 @@ import { HttpWTSession } from './session.js'
|
|
|
3
3
|
import { HttpClient } from './client.js'
|
|
4
4
|
import { Http2WebTransportBrowser } from './http2/browser/browser.js'
|
|
5
5
|
import { logger } from './utils.js'
|
|
6
|
-
import { WebTransportError } from './error'
|
|
6
|
+
import { WebTransportError } from './error.js'
|
|
7
7
|
|
|
8
8
|
const log = logger(`webtransport:browser()`)
|
|
9
9
|
|