quico 0.1.0 โ†’ 0.1.3

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/CHANGELOG.md CHANGED
@@ -23,3 +23,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
23
23
  ### Notes
24
24
  - This is a pre-release version under heavy development.
25
25
  - API may change without notice.
26
+
27
+
28
+ ## [0.1.1] - 2025-09-30
29
+ - Extracted the TLS implementation into a separate library: **lemon-tls**, for easier maintenance and reuse.
30
+ - Refactored the projectโ€™s file structure for clearer organization and improved modularity.
31
+ - Migrated the codebase from CommonJS (`require`) to **ESM** (`import/export`) for modern compatibility.
package/README.md CHANGED
@@ -1,144 +1,217 @@
1
- <p align="center">
2
- <img src="https://github.com/colocohen/quico/raw/main/quico.svg" width="450" alt="QUICO"/>
3
- </p>
4
-
5
- <h1 align="center">QUICO</h1>
6
- <p align="center">
7
- <em>๐Ÿš€ JavaScript implementation of QUIC, HTTP/3, QPACK & WebTransport for Node.js</em>
8
- </p>
9
-
10
- <p align="center">
11
- <a href="https://www.npmjs.com/package/quico">
12
- <img src="https://img.shields.io/npm/v/quico?color=blue" alt="npm">
13
- </a>
14
- <img src="https://img.shields.io/badge/status-in%20development-yellow" alt="status">
15
- <img src="https://img.shields.io/github/license/colocohen/quico?color=brightgreen" alt="license">
16
- </p>
17
-
18
- ---
19
-
20
- > **โš ๏ธ Project status: _Active development_.**
21
- > APIs may change without notice until we reach v1.0.
22
- > Use at your own risk and please report issues!
23
-
24
- ## โœจ Features
25
- - **Pure JS QUIC**: Initial & 1-RTT packets, connection ID management, ACK & flow-control.
26
- - **TLS 1.3 handshake** in JavaScript (no OpenSSL binding).
27
- - **HTTP/3** control stream, request/response, server push, GOAWAY.
28
- - **WebTransport** streams & datagrams (RFC 9298) โ€” tested with Chrome Canary.
29
- - **QPACK** encoder/decoder with custom Huffman table support.
30
- - Fully self-containedโ€”no native addons, no external OpenSSL.
31
-
32
- ## ๐Ÿ“ฆ Installation
33
-
34
- ```bash
35
- npm install quico
36
- ```
37
-
38
- ## ๐Ÿƒ Quick start
39
-
40
- ### Step 1: Generate a self-signed certificate
41
-
42
- To test QUICO locally, youโ€™ll need a TLS certificate.
43
- Generate one using OpenSSL:
44
-
45
- ```bash
46
- mkdir certs
47
- openssl req -x509 -newkey rsa:2048 -nodes -keyout certs/localhost.key -out certs/localhost.crt -days 365
48
- ```
49
-
50
- ### Step 2: Create a basic HTTP/3 server
51
-
52
- ```js
53
- const fs = require('fs');
54
- const quico = require('quico');
55
-
56
- const server = quico.createServer({
57
- SNICallback: function (servername, cb) {
58
- cb(null, {
59
- key: fs.readFileSync('certs/localhost.key'),
60
- cert: fs.readFileSync('certs/localhost.crt')
61
- });
62
- }
63
- }, function (req, res) {
64
- const data = new TextEncoder().encode('Hello World from HTTP/3 on Node.js!');
65
- res.writeHead(200, {
66
- 'Content-Type': 'text/html; charset=utf-8',
67
- 'Content-Length': data.byteLength
68
- });
69
- res.end(data);
70
- });
71
-
72
- server.listen(4433, function () {
73
- console.log('๐Ÿš€ QUIC server running on https://localhost:4433');
74
- });
75
- ```
76
-
77
- > โœ… You must launch Chrome with `--enable-quic` and `--origin-to-force-quic-on=localhost:4433`
78
- > ๐Ÿ“‚ For more examples, see [`examples/`](./examples)
79
-
80
- ## ๐Ÿ›ฃ Roadmap
81
-
82
- The following roadmap reflects the current and planned status of the QUICO project.
83
- โœ… = Completedโ€ƒ๐Ÿ”„ = In progressโ€ƒโณ = Plannedโ€ƒโŒ = Not planned
84
-
85
- ### โœ… Completed
86
- | Status | Item |
87
- |:------:|------|
88
- | โœ… | QUIC: Initial / Handshake / 1-RTT |
89
- | โœ… | TLS 1.3 handshake & key schedule |
90
- | โœ… | HTTP/3: control streams & basic requests |
91
- | โœ… | QPACK: static & dynamic table |
92
-
93
- ### ๐Ÿ”„ In Progress
94
- | Status | Item | Notes |
95
- |:------:|------|-------|
96
- | ๐Ÿ”„ | QPACK: Huffman encoding/decoding | Custom table support partially working |
97
- | ๐Ÿ”„ | WebTransport: unidirectional & bidirectional streams | Stream interface WIP |
98
- | ๐Ÿ”„ | HTTP/3: GOAWAY & request cancellation | Partial control flow support |
99
- | ๐Ÿ”„ | Integration with Node.js `https`-style API | Goal: seamless compatibility |
100
- | ๐Ÿ”„ | Project modularization & internal refactoring | To improve maintainability |
101
-
102
- ### โณ Planned
103
- | Status | Item | Notes |
104
- |:------:|------|-------|
105
- | โณ | QUIC: 0-RTT support | Will follow key update & early data support |
106
- | โณ | WebTransport: datagram support | Based on RFC 9298 |
107
- | โณ | QUIC: proper connection teardown | CLOSE frame, idle timeout |
108
- | โณ | QUIC: keep-alive & PING frames | For long-lived connections |
109
- | โณ | QUIC: flow control & congestion (BBR / CUBIC) | Needs metrics and simulation |
110
- | โณ | QUIC: session resumption & connection migration | For mobile/roaming support |
111
- | โณ | End-to-end test suite against Chromium | Automate using testh3 and Puppeteer |
112
- | โณ | Benchmarks, performance analysis & tuning | Resource usage, latency, throughput |
113
- | โณ | Fuzz testing and protocol robustness checks | To improve security and reliability |
114
- | โณ | Developer documentation & API reference | For better onboarding |
115
- | โณ | TypeScript typings | Type safety for IDE support |
116
-
117
- _Note: QUICO is a work-in-progress project aiming to provide a full JavaScript implementation of QUIC + HTTP/3. Community contributions are welcome!_
118
-
119
- _Please โญ star the repo to follow progress!_
120
-
121
- ## ๐Ÿ™ Sponsors
122
-
123
- QUICO is an evenings-and-weekends project.
124
- Support development via **GitHub Sponsors** or simply share the project.
125
-
126
- ## ๐Ÿ“œ License
127
-
128
- **Apache License 2.0**
129
-
130
- ```
131
- Copyright ยฉ 2025 colocohen
132
-
133
- Licensed under the Apache License, Version 2.0 (the "License");
134
- you may not use this file except in compliance with the License.
135
- You may obtain a copy of the License at
136
-
137
- http://www.apache.org/licenses/LICENSE-2.0
138
-
139
- Unless required by applicable law or agreed to in writing, software
140
- distributed under the License is distributed on an "AS IS" BASIS,
141
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
142
- See the License for the specific language governing permissions and
143
- limitations under the License.
1
+ <p align="center">
2
+ <img src="https://github.com/colocohen/quico/raw/main/quico.svg" width="450" alt="QUICO"/>
3
+ </p>
4
+
5
+ <h1 align="center">QUICO</h1>
6
+ <p align="center">
7
+ <em>๐Ÿš€ JavaScript implementation of QUIC, HTTP/3, QPACK & WebTransport for Node.js</em>
8
+ </p>
9
+
10
+ <p align="center">
11
+ <a href="https://www.npmjs.com/package/quico">
12
+ <img src="https://img.shields.io/npm/v/quico?color=blue" alt="npm">
13
+ </a>
14
+ <img src="https://img.shields.io/badge/status-in%20development-yellow" alt="status">
15
+ <img src="https://img.shields.io/github/license/colocohen/quico?color=brightgreen" alt="license">
16
+ </p>
17
+
18
+
19
+ > **โš ๏ธ Project status: _Active development_.**
20
+ > APIs may change without notice until we reach v1.0.
21
+ > Use at your own risk and please report issues!
22
+
23
+
24
+
25
+ ## Table of Contents
26
+ 1. [What is QUIC/HTTP3?](#-what-is-quichttp3)
27
+ 2. [Why is QUICO important?](#-why-is-quico-important)
28
+ 3. [Features](#-features)
29
+ 4. [Installation](#-installation)
30
+ 5. [Node.js API Compatibility](#-nodejs-api-compatibility)
31
+ 6. [Testing](#-testing)
32
+ 7. [Roadmap](#-roadmap)
33
+ 8. [Sponsors](#-sponsors)
34
+ 9. [License](#-license)
35
+
36
+
37
+
38
+ ## โšก What is QUIC/HTTP3?
39
+
40
+ **QUIC** is the future of Internet transport protocols. Created at Google and standardized by the IETF, QUIC powers **HTTP/3** and is already deployed at scale by the worldโ€™s largest platforms. It was specifically designed to overcome the limitations of TCP and deliver a faster, smoother, and more resilient web.
41
+
42
+ Key advantages of QUIC include:
43
+
44
+ - **Eliminating bottlenecks**: With TCP, data must arrive strictly in order. If a single packet is lost or delayed, all subsequent packets are blocked until it arrives โ€” a phenomenon called **head-of-line blocking**. QUIC removes this bottleneck by running over UDP, so each package arrives on its own and avoids dependence on delayed pieces of data.
45
+
46
+ - **UDP efficiency**: By running over UDP, QUIC bypasses decades of kernel-level constraints, enabling lightning-fast performance even on constrained devices such as smartphones, IoT hardware, or edge gateways.
47
+
48
+ - **Security by default**: TLS 1.3 is built directly into the protocol. Every connection is encrypted โ€” no exceptions, no downgrade paths.
49
+
50
+ - **Seamless mobility**: Connections remain stable as devices move across networks (e.g., Wi-Fi โ†’ 4G/5G) or switch IP addresses, without breaking the session.
51
+
52
+ - **Lower latency**: QUIC merges the transport and TLS handshake into fewer round-trips, significantly reducing connection setup time.
53
+
54
+ - **Smarter congestion control**: Advanced congestion control algorithms (such as BBR) continuously measure bandwidth, round-trip time, and loss in real time. They dynamically adjust to real-world network conditions.
55
+
56
+
57
+ QUIC combines **UDP speed, TCP reliability, mandatory TLS security, and adaptive multiplexing** into one powerful transport layer.
58
+
59
+ **HTTP/3** (h3 in short) is the layer on top of QUIC. This is the evolution of the webโ€™s application layer. Instead of riding over TCP, HTTP/3 maps HTTP requests and responses directly onto QUIC streams.
60
+ HTTP/3 is also himself dramatically reduces overhead and improves efficiency - thats bring faster page loads and real-time applications that scale across the modern web.
61
+
62
+
63
+
64
+ ## Why is QUICO important?
65
+
66
+ Node.js is the backbone of countless modern web applications, but it currently lacks a native QUIC implementation. Supporting QUIC inside Node.js requires **deep access to TLS internals** that Nodeโ€™s existing TLS APIs donโ€™t expose. Beyond that, QUIC demands a **highly complex architecture**, including intricate state machines, packet schedulers, and congestion control mechanisms.
67
+
68
+ **QUICO** brings this missing capability directly into the **Node.js ecosystem**. It is a from-scratch JavaScript implementation of **QUIC, HTTP/3 and WebTransport**, built without relying on OpenSSL or native code. At its core, it uses [LemonTLS](https://github.com/colocohen/lemon-tls) a pure JavaScript TLS 1.3 library, to provide the cryptographic expose that QUIC requires.
69
+
70
+
71
+
72
+ ## โœจ Features
73
+
74
+ - **Pure JavaScript QUIC**
75
+ Full transport layer written from scratch in JS โ€” including Initial & 1-RTT packet handling, connection ID management, acknowledgments, and flow control. No native bindings required.
76
+
77
+ - **HTTP/3**
78
+ Support for control streams, request/response handling, and GOAWAY frames โ€” the foundation of modern web transport.
79
+
80
+ - **WebTransport**
81
+ Unidirectional and bidirectional streams plus datagrams (RFC 9298), tested with Chrome Canary for real-world compatibility.
82
+
83
+ - **QPACK Compression**
84
+ Full encoder/decoder implementation with support for static, dynamic, and custom Huffman tables to reduce header overhead.
85
+
86
+ > โš ๏ธ **Note**: Currently implemented as **server-side only**. Client support is planned in the roadmap.
87
+
88
+
89
+
90
+ ## ๐Ÿ“ฆ Installation
91
+
92
+ ```bash
93
+ npm install quico
94
+ ```
95
+
96
+
97
+
98
+ ## ๐Ÿ”— Node.js API Compatibility
99
+
100
+ One of the core design goals of QUICO is to provide a **familiar and intuitive API**.
101
+ If you already know how to use Nodeโ€™s built-in `http` or `https` modules, working with QUICO should feel natural.
102
+
103
+ QUICO exposes an API modeled after Nodeโ€™s server interfaces:
104
+ - **`createServer`** works just like in `http` / `https`, accepting request and response objects.
105
+ - **`req` and `res` objects** follow the same semantics you already know: `req.headers`, `res.writeHead()`, `res.end()`, etc.
106
+
107
+
108
+ ```js
109
+ import fs from 'node:fs';
110
+ import quico from 'quico';
111
+ import tls from 'lemon-tls';
112
+
113
+ const server = quico.createServer({
114
+ SNICallback: function (servername, cb) {
115
+ cb(null, tls.createSecureContext({
116
+ key: fs.readFileSync('YOUR_KEY_FILE_PATH'),
117
+ cert: fs.readFileSync('YOUR_CERT_FILE_PATH')
118
+ }));
119
+ }
120
+ }, function (req, res) {
121
+ res.writeHead(200, {
122
+ 'Content-Type': 'text/html; charset=utf-8'
123
+ });
124
+ res.end('Hello World from HTTP/3 on Node.js!');
125
+ });
126
+
127
+ server.listen(4433, function () {
128
+ console.log('๐Ÿš€ QUIC server running on https://localhost:4433');
129
+ });
130
+ ```
131
+
132
+ > ๐Ÿ“‚ For more examples, see [`examples/`](./examples)
133
+
134
+
135
+ ## ๐Ÿงช Testing
136
+
137
+ QUIC requires TLS 1.3 with an ECDSA certificate.
138
+ RSA self-signed certificates usually fail with QUIC/HTTP3.
139
+ For local development the easiest option is [mkcert](https://github.com/FiloSottile/mkcert),
140
+ which generates locally trusted ECDSA certificates automatically.
141
+
142
+ This project supports ALPN `"h3"` only
143
+ (final version, not draft variants like `h3-29` or `h3-32`).
144
+ You must explicitly force h3 when testing.
145
+
146
+ > โœ… Launch Chrome with:
147
+ > `--enable-quic --quic-version=h3 --ignore-certificate-errors --origin-to-force-quic-on=localhost:4433`
148
+ >
149
+ > โœ… Or test with Curl:
150
+ > `curl --http3 -vvv --trace-time --trace-ascii - https://localhost:4433 --insecure`
151
+
152
+
153
+ ## ๐Ÿ›ฃ Roadmap
154
+
155
+ The following roadmap reflects the current and planned status of the QUICO project.
156
+ โœ… = Completedโ€ƒ๐Ÿ”„ = In progressโ€ƒโณ = Plannedโ€ƒโŒ = Not planned
157
+
158
+ ### โœ… Completed
159
+ | Status | Item |
160
+ |:------:|------|
161
+ | โœ… | QUIC: Initial / Handshake / 1-RTT |
162
+ | โœ… | TLS 1.3 handshake & key schedule |
163
+ | โœ… | HTTP/3: control streams & basic requests |
164
+ | โœ… | QPACK: static & dynamic table |
165
+
166
+ ### ๐Ÿ”„ In Progress
167
+ | Status | Item | Notes |
168
+ |:------:|------|-------|
169
+ | ๐Ÿ”„ | QPACK: Huffman encoding/decoding | Custom table support partially working |
170
+ | ๐Ÿ”„ | WebTransport: unidirectional & bidirectional streams | Stream interface WIP |
171
+ | ๐Ÿ”„ | HTTP/3: GOAWAY & request cancellation | Partial control flow support |
172
+ | ๐Ÿ”„ | Integration with Node.js `https`-style API | Goal: seamless compatibility |
173
+ | ๐Ÿ”„ | Project modularization & internal refactoring | To improve maintainability |
174
+
175
+ ### โณ Planned
176
+ | Status | Item | Notes |
177
+ |:------:|------|-------|
178
+ | โณ | QUIC: 0-RTT support | Will follow key update & early data support |
179
+ | โณ | WebTransport: datagram support | Based on RFC 9298 |
180
+ | โณ | QUIC: proper connection teardown | CLOSE frame, idle timeout |
181
+ | โณ | QUIC: keep-alive & PING frames | For long-lived connections |
182
+ | โณ | QUIC: flow control & congestion (BBR / CUBIC) | Needs metrics and simulation |
183
+ | โณ | QUIC: session resumption & connection migration | For mobile/roaming support |
184
+ | โณ | End-to-end test suite against Chromium | Automate using testh3 and Puppeteer |
185
+ | โณ | Benchmarks, performance analysis & tuning | Resource usage, latency, throughput |
186
+ | โณ | Fuzz testing and protocol robustness checks | To improve security and reliability |
187
+ | โณ | Developer documentation & API reference | For better onboarding |
188
+ | โณ | TypeScript typings | Type safety for IDE support |
189
+
190
+ _Note: QUICO is a work-in-progress project aiming to provide a full JavaScript implementation of QUIC + HTTP/3. Community contributions are welcome!_
191
+
192
+ _Please โญ star the repo to follow progress!_
193
+
194
+ ## ๐Ÿ™ Sponsors
195
+
196
+ QUICO is an evenings-and-weekends project.
197
+ Support development via **GitHub Sponsors** or simply share the project.
198
+
199
+ ## ๐Ÿ“œ License
200
+
201
+ **Apache License 2.0**
202
+
203
+ ```
204
+ Copyright ยฉ 2025 colocohen
205
+
206
+ Licensed under the Apache License, Version 2.0 (the "License");
207
+ you may not use this file except in compliance with the License.
208
+ You may obtain a copy of the License at
209
+
210
+ http://www.apache.org/licenses/LICENSE-2.0
211
+
212
+ Unless required by applicable law or agreed to in writing, software
213
+ distributed under the License is distributed on an "AS IS" BASIS,
214
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
215
+ See the License for the specific language governing permissions and
216
+ limitations under the License.
144
217
  ```
@@ -1,27 +1,21 @@
1
- var quico = require('../../index'); // ืื• './index' ืื ืืชื” ืžืจื™ืฅ ืžื”ืฉื•ืจืฉ
2
- var fs = require('fs');
1
+ import quico from 'quico';
2
+ import fs from 'node:fs';
3
+ import tls from 'lemon-tls';
3
4
 
4
5
  var server = quico.createServer({
5
6
  SNICallback: function (servername, cb) {
6
7
  console.log('Getting certificate for:', servername);
7
- cb(null, {
8
- key: fs.readFileSync('certs/localhost.key'),
9
- cert: fs.readFileSync('certs/localhost.crt')
10
- });
8
+ cb(null, tls.createSecureContext({
9
+ key: fs.readFileSync('./certs/localhost2.key'),
10
+ cert: fs.readFileSync('./certs/localhost2.crt')
11
+ }));
11
12
  }
12
- });
13
-
14
- server.on('webtransport', function(session) {
15
- console.log('WebTransport session opened');
13
+ },function(req,res){
14
+ if (req.headers[':protocol'] === 'webtransport') {
15
+ res.writeHead(200);
16
16
 
17
- session.ondatagram = function(data) {
18
- console.log('Datagram from client:', Buffer.from(data).toString());
19
- session.send(data);
20
- };
21
-
22
- session.onclose = function() {
23
- console.log('WebTransport session closed');
24
- };
17
+ //TODO
18
+ }
25
19
  });
26
20
 
27
21
  server.listen(4433, function() {