@fails-components/webtransport 1.1.2 → 1.1.4

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.
@@ -5,7 +5,7 @@
5
5
  import { Http3Server } from '../lib/index.js'
6
6
  import { runEchoServer } from './testsuite.js'
7
7
  import { existsSync, readFileSync, writeFile } from 'node:fs'
8
- import { generateWebTransportCertificate } from '../test/fixtures/certificate.js'
8
+ import { generateWebTransportCertificate } from '../../test/fixtures/certificate.js'
9
9
 
10
10
  let certificate = null
11
11
 
package/old_test/test.js CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  // this file runs various tests
6
6
 
7
- import { generateWebTransportCertificate } from '../test/fixtures/certificate.js'
7
+ import { generateWebTransportCertificate } from '../../test/fixtures/certificate.js'
8
8
  import {
9
9
  Http3Server,
10
10
  Http2Server,
package/package.json CHANGED
@@ -1,11 +1,17 @@
1
1
  {
2
2
  "name": "@fails-components/webtransport",
3
- "version": "1.1.2",
3
+ "version": "1.1.4",
4
4
  "description": "A component to add webtransport support (server and client) to node.js using libquiche",
5
5
  "exports": {
6
6
  ".": {
7
- "node": "./lib/index.node.js",
8
- "browser": "./lib/index.browser.js"
7
+ "node": {
8
+ "types": "./dist/lib/index.node.d.ts",
9
+ "import": "./lib/index.node.js"
10
+ },
11
+ "browser": {
12
+ "types": "./dist/lib/index.browser.d.ts",
13
+ "import": "./lib/index.browser.js"
14
+ }
9
15
  }
10
16
  },
11
17
  "engines": {
@@ -15,21 +21,9 @@
15
21
  "types": "./dist/lib/index.types.d.ts",
16
22
  "scripts": {
17
23
  "start": "node test/echoserver.js",
18
- "test": "npm run test:node && npm run test:node:http2 && npm run test:chromium && npm run test:chromium:http2:polyfill && npm run test:chromium:http2:ponyfill && npm run test:firefox:http2:polyfill && npm run test:firefox:http2:ponyfill && npm run test:webkit:http2:polyfill && npm run test:webkit:http2:ponyfill",
19
- "test:node": "node test/index.js node http3",
20
- "test:node:http2": "node test/index.js node http2",
21
- "test:chromium": "node test/index.js chromium http3",
22
- "test:chromium:http2:polyfill": "node test/index.js chromium http2 polyfill",
23
- "test:chromium:http2:ponyfill": "node test/index.js chromium http2 ponyfill",
24
- "test:firefox": "node test/index.js firefox http3",
25
- "test:firefox:http2:polyfill": "node test/index.js firefox http2 polyfill",
26
- "test:firefox:http2:ponyfill": "node test/index.js firefox http2 ponyfill",
27
- "test:webkit": "node test/index.js webkit http3",
28
- "test:webkit:http2:polyfill": "node test/index.js webkit http2 polyfill",
29
- "test:webkit:http2:ponyfill": "node test/index.js webkit http2 ponyfill",
30
24
  "oldtest": "node old_test/test.js",
31
25
  "oldtesthttp2": "node old_test/test.js http2",
32
- "lint": "eslint lib test old_test"
26
+ "lint": "eslint lib old_test"
33
27
  },
34
28
  "repository": {
35
29
  "type": "git",
@@ -57,9 +51,6 @@
57
51
  "@types/dirty-chai": "^2.0.2",
58
52
  "@types/mocha": "^10.0.0",
59
53
  "@types/node": "^18.15.3",
60
- "chai": "^4.3.6",
61
- "chai-as-promised": "^7.1.1",
62
- "dirty-chai": "^2.0.1",
63
54
  "eslint": "^9.3.0",
64
55
  "eslint-config-prettier": "^9.1.0",
65
56
  "eslint-config-standard": "^16.0.2",
@@ -68,10 +59,6 @@
68
59
  "eslint-plugin-prettier": "^5.1.3",
69
60
  "eslint-plugin-promise": "^4.3.1",
70
61
  "eslint-plugin-standard": "^4.1.0",
71
- "execa": "^6.1.0",
72
- "mocha": "^10.1.0",
73
- "node-forge": "^1.3.1",
74
- "playwright-test": "^12.3.4",
75
62
  "prettier": "^3.2.5",
76
63
  "typescript": "^4.8.4",
77
64
  "uint8arrays": "^4.0.2"
@@ -82,8 +69,6 @@
82
69
  ]
83
70
  },
84
71
  "browser": {
85
- "./test/fixtures/webtransport.js": "./test/fixtures/webtransport.browser.js",
86
- "./test/fixtures/quiche.js": "./test/fixtures/quiche.browser.js",
87
72
  "./lib/webstreams.js": "./lib/webstreams.browser.js"
88
73
  }
89
74
  }
package/readme.md CHANGED
@@ -72,8 +72,8 @@ The package `webtransport-transport-http3-quiche` provides prebuild binaries for
72
72
  Other platforms may be possible via cross-compiling in the GitHub actions, if someone needs this, PRs are welcome.
73
73
 
74
74
  Of course, you can also build the binary on your system.
75
- If you are running the compiling install as root, you need to use `--`unsafe-perm` as a flag.
76
- Installing the package without prebuild requires a full building environment including clang-9, perl6, python, golang, `ninja-build, `and `icu``.` See the `Dockerfile` or `Dockerfile.development` for required Debian packages.
75
+ If you are running the compiling install as root, you need to use `--unsafe-perm` as a flag.
76
+ Installing the package without prebuild requires a full building environment including `clang-9`, `perl6`, `python`, `golang`, `ninja-build`, and `icu`. See the `Dockerfile` or `Dockerfile.development` for required Debian packages.
77
77
  This should work for Windows, Linux and Mac OS X.
78
78
  (You may want to check out the building dependencies (especially for Windows) for BoringSSl, zlib, abseil on their respective websites).
79
79
 
@@ -1,150 +0,0 @@
1
- /* eslint-env mocha */
2
-
3
- import { getReaderValue } from './fixtures/reader-value.js'
4
- import { expect } from './fixtures/chai.js'
5
- import { readStream } from './fixtures/read-stream.js'
6
- import { writeStream } from './fixtures/write-stream.js'
7
- import { readCertHash } from './fixtures/read-cert-hash.js'
8
- import WebTransport from './fixtures/webtransport.js'
9
- import { quicheLoaded } from './fixtures/quiche.js'
10
- import * as ui8 from 'uint8arrays'
11
- import {
12
- KNOWN_BYTES,
13
- KNOWN_BYTES_LENGTH,
14
- KNOWN_BYTES_LONG,
15
- KNOWN_BYTES_LONG_LENGTH
16
- } from './fixtures/known-bytes.js'
17
-
18
- /**
19
- * @template T
20
- * @typedef {import('../lib/types').Deferred<T>} Deferred<T>
21
- */
22
- describe('bidirectional streams', function () {
23
- let forceReliable = false
24
- if (process.env.USE_HTTP2 === 'true') forceReliable = true
25
- /** @type {import('../lib/dom').WebTransport | undefined} */
26
- let client
27
-
28
- const wtOptions = {
29
- serverCertificateHashes: [
30
- {
31
- algorithm: 'sha-256',
32
- value: readCertHash(process.env.CERT_HASH)
33
- }
34
- ],
35
- // @ts-ignore
36
- forceReliable
37
- }
38
- if (process.env.NO_CERT_HASHES === 'true')
39
- // @ts-ignore
40
- delete wtOptions.serverCertificateHashes
41
-
42
- // @ts-ignore
43
- beforeEach(async () => {
44
- if (
45
- process.env.USE_HTTP2 !== 'true' &&
46
- process.env.USE_PONYFILL !== 'true' &&
47
- process.env.USE_POLYFILL !== 'true'
48
- ) {
49
- await quicheLoaded
50
- }
51
- })
52
-
53
- // @ts-ignore
54
- afterEach(async () => {
55
- if (client != null) {
56
- client.close()
57
- client = undefined
58
- }
59
- })
60
-
61
- it('sends and receives data over an outgoing bidirectional stream', async () => {
62
- // client context - connects to the server, opens a bidi stream, sends some data and reads the response
63
- client = new WebTransport(
64
- `${process.env.SERVER_URL}/bidirectional_client_initiated_echo`,
65
- wtOptions
66
- )
67
- await client.ready
68
-
69
- const stream = await client.createBidirectionalStream()
70
- await writeStream(stream.writable, KNOWN_BYTES)
71
-
72
- const output = await readStream(stream.readable, KNOWN_BYTES_LENGTH)
73
- expect(ui8.concat(KNOWN_BYTES)).to.deep.equal(
74
- ui8.concat(output),
75
- 'Did not receive the same bytes we sent'
76
- )
77
- })
78
-
79
- it('sends and receives data over an outgoing bidirectional stream with big buffers', async () => {
80
- // client context - connects to the server, opens a bidi stream, sends some data and reads the response
81
- client = new WebTransport(
82
- `${process.env.SERVER_URL}/bidirectional_client_initiated_echo`,
83
- wtOptions
84
- )
85
- await client.ready
86
-
87
- const stream = await client.createBidirectionalStream()
88
- await writeStream(stream.writable, KNOWN_BYTES_LONG)
89
-
90
- const output = await readStream(stream.readable, KNOWN_BYTES_LONG_LENGTH)
91
- const send = ui8.concat(KNOWN_BYTES_LONG)
92
- const received = ui8.concat(output)
93
- let failure = 0
94
- for (let i = 0; i < Math.max(send.byteLength, received.byteLength); i++) {
95
- if (send[i] !== received[i] && failure < 100) {
96
- console.log('d: ', i, ' ,', send[i], ', ', received[i])
97
- failure++
98
- }
99
- }
100
-
101
- expect(ui8.concat(KNOWN_BYTES_LONG)).to.deep.equal(
102
- ui8.concat(output),
103
- 'Did not receive the same bytes we sent'
104
- )
105
- })
106
-
107
- it('sends and receives data over an incoming bidirectional stream', async () => {
108
- // client context - waits for the server to open a bidi stream then pipes it back to them
109
- client = new WebTransport(
110
- `${process.env.SERVER_URL}/bidirectional_server_initiated_echo`,
111
- wtOptions
112
- )
113
- await client.ready
114
-
115
- const bidiStream = await getReaderValue(client.incomingBidirectionalStreams)
116
-
117
- // redirect input to output
118
- try {
119
- await bidiStream.readable.pipeTo(bidiStream.writable)
120
- } catch (error) {
121
- console.log('Pipe to error (ignore)', error) // Actually all you can get is, that the fin is catched
122
- }
123
-
124
- // the remote will close the session
125
- const result = await client.closed
126
-
127
- // should receive the default close info
128
- expect(result).to.have.property('reason', '')
129
- expect(result).to.have.property('closeCode', 0)
130
- })
131
-
132
- it('receives data from server and checks receiving stream fin', async () => {
133
- // client context - waits for the server to open a bidi stream then pipes it back to them
134
- client = new WebTransport(
135
- `${process.env.SERVER_URL}/bidirectional_server_fin_send`,
136
- wtOptions
137
- )
138
- await client.ready
139
-
140
- const bidiStream = await getReaderValue(client.incomingBidirectionalStreams)
141
- const reader = bidiStream.readable.getReader()
142
-
143
- while (true) {
144
- const res = await reader.read()
145
- if (res.done) {
146
- break
147
- }
148
- }
149
- })
150
- })
@@ -1,104 +0,0 @@
1
- /* eslint-env mocha */
2
-
3
- import WebTransport from './fixtures/webtransport.js'
4
- import { expect } from './fixtures/chai.js'
5
- import { readStream } from './fixtures/read-stream.js'
6
- import { readCertHash } from './fixtures/read-cert-hash.js'
7
- import { pTimeout } from './fixtures/p-timeout.js'
8
- import { quicheLoaded } from './fixtures/quiche.js'
9
-
10
- /**
11
- * @template T
12
- * @typedef {import('../lib/types').Deferred<T>} Deferred<T>
13
- */
14
-
15
- describe('datagrams', function () {
16
- /** @type {import('../lib/dom').WebTransport | undefined} */
17
- let client
18
- let forceReliable = false
19
- if (process.env.USE_HTTP2 === 'true') forceReliable = true
20
-
21
- const wtOptions = {
22
- serverCertificateHashes: [
23
- {
24
- algorithm: 'sha-256',
25
- value: readCertHash(process.env.CERT_HASH)
26
- }
27
- ],
28
- // @ts-ignore
29
- forceReliable
30
- }
31
-
32
- if (process.env.NO_CERT_HASHES === 'true')
33
- // @ts-ignore
34
- delete wtOptions.serverCertificateHashes
35
-
36
- // @ts-ignore
37
- beforeEach(async () => {
38
- if (
39
- process.env.USE_HTTP2 !== 'true' &&
40
- process.env.USE_PONYFILL !== 'true' &&
41
- process.env.USE_POLYFILL !== 'true'
42
- ) {
43
- await quicheLoaded
44
- }
45
- })
46
-
47
- // @ts-ignore
48
- afterEach(async () => {
49
- if (client != null) {
50
- client.close()
51
- client = undefined
52
- }
53
- })
54
- it('client sends datagrams to the server', async () => {
55
- // client context - connects to the server, sends some datagrams and reads the response
56
- client = new WebTransport(
57
- `${process.env.SERVER_URL}/datagrams_client_send`,
58
- wtOptions
59
- )
60
- await client.ready
61
-
62
- const writer = client.datagrams.writable.getWriter()
63
- let closed = false
64
-
65
- // write datagrams until the server receives one and closes the connection
66
- // eslint-disable-next-line promise/catch-or-return
67
- Promise.resolve().then(async () => {
68
- while (!closed) {
69
- try {
70
- await writer.ready
71
- await writer.write(Uint8Array.from([0, 1, 2, 3, 4]))
72
- await new Promise((resolve) => setTimeout(resolve, 100))
73
- } catch {
74
- // the session can be closed while we are writing
75
- }
76
- }
77
- })
78
-
79
- const result = await client.closed
80
- closed = true
81
-
82
- // should receive the default close info
83
- expect(result).to.have.property('reason', '')
84
- expect(result).to.have.property('closeCode', 0)
85
- })
86
-
87
- it('receives datagrams from the server', async () => {
88
- // client context - pipes the server's datagrams back to them
89
- client = new WebTransport(
90
- `${process.env.SERVER_URL}/datagrams_server_send`,
91
- wtOptions
92
- )
93
- await client.ready
94
-
95
- // datagram transport is unreliable, at least one message should make it through
96
- const expected = 1
97
-
98
- const received = await pTimeout(
99
- readStream(client.datagrams.readable, expected),
100
- 1000
101
- )
102
- expect(received).to.have.lengthOf(expected)
103
- })
104
- })