rwebtransport 0.2.1 → 0.2.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/dist/native.d.ts CHANGED
@@ -242,6 +242,7 @@ export declare class SessionCore {
242
242
  sendDatagram(chunk: Uint8Array): Promise<boolean>;
243
243
  maxDatagramSize(): number;
244
244
  close(code: number, reason: string): void;
245
+ abort(message: string): void;
245
246
  drain(): void;
246
247
  getStats(): Promise<WebTransportConnectionStats>;
247
248
  exportKeyingMaterial(label: Uint8Array, context: Uint8Array, length: number): Promise<Uint8Array>;
package/dist/server.d.ts CHANGED
@@ -39,6 +39,7 @@ export declare class WebTransportServer {
39
39
  private incomingController;
40
40
  private boundPort;
41
41
  private closeCalled;
42
+ private incomingCancelled;
42
43
  readonly incomingSessions: ReadableStream<WebTransportServerSession>;
43
44
  constructor(options: WebTransportServerOptions);
44
45
  get ready(): Promise<void>;
package/package.json CHANGED
@@ -1,80 +1,83 @@
1
1
  {
2
- "name": "rwebtransport",
3
- "version": "0.2.1",
4
- "description": "A fully-compatible WebTransport client and server for Node.js, powered by Cloudflare quiche + BoringSSL via neon.",
5
- "author": "Dacely Cloud",
6
- "homepage": "https://github.com/dacely-cloud/rwebtransport#readme",
7
- "repository": {
8
- "type": "git",
9
- "url": "git+https://github.com/dacely-cloud/rwebtransport.git"
10
- },
11
- "bugs": {
12
- "url": "https://github.com/dacely-cloud/rwebtransport/issues"
13
- },
14
- "type": "commonjs",
15
- "main": "./dist/index.js",
16
- "module": "./dist/index.mjs",
17
- "types": "./dist/index.d.ts",
18
- "exports": {
19
- ".": {
20
- "types": "./dist/index.d.ts",
21
- "import": "./dist/index.mjs",
22
- "require": "./dist/index.js"
23
- }
24
- },
25
- "files": [
26
- "dist",
27
- "prebuilds",
28
- "scripts",
29
- "crates",
30
- "vendor",
31
- "Cargo.toml",
32
- "Cargo.lock",
33
- "README.md",
34
- "NOTICE"
35
- ],
36
- "engines": {
37
- "node": ">=24 <25 || >=26 <27"
38
- },
39
- "scripts": {
40
- "build": "npm run build:rust && npm run build:ts",
41
- "build:rust": "node scripts/build.js",
42
- "build:rust:debug": "node scripts/build.js --debug",
43
- "build:ts": "tsup src/index.ts --format cjs,esm --sourcemap --clean --shims --out-dir dist && tsc -p tsconfig.build.json",
44
- "build:echo": "cargo build --release -p rwebtransport-echo-server",
45
- "setup:windows": "powershell -ExecutionPolicy Bypass -File scripts/setup-windows.ps1",
46
- "setup:unix": "bash scripts/setup-unix.sh",
47
- "postinstall": "node scripts/postinstall.js",
48
- "pretest": "npm run build:rust && npm run build:ts && npm run build:echo",
49
- "test": "vitest run",
50
- "test:watch": "vitest",
51
- "typecheck": "tsc --noEmit",
52
- "lint": "eslint .",
53
- "lint:fix": "eslint . --fix",
54
- "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
55
- "format:check": "prettier --check \"src/**/*.ts\" \"test/**/*.ts\""
56
- },
57
- "devDependencies": {
58
- "@eslint/js": "^10.0.1",
59
- "@types/node": "^26.1.1",
60
- "@vitest/coverage-v8": "^4.1.10",
61
- "esbuild": "^0.28.1",
62
- "eslint": "^10.7.0",
63
- "prettier": "^3.9.5",
64
- "tsup": "^8.5.1",
65
- "typescript": "^6.0.3",
66
- "typescript-eslint": "^8.64.0",
67
- "vitest": "^4.1.10"
68
- },
69
- "overrides": {
70
- "esbuild": "^0.28.1"
71
- },
72
- "keywords": [
73
- "webtransport",
74
- "quic",
75
- "http3",
76
- "quiche",
77
- "neon"
78
- ],
79
- "license": "Apache-2.0"
2
+ "name": "rwebtransport",
3
+ "version": "0.2.3",
4
+ "description": "A fully-compatible WebTransport client and server for Node.js, powered by Cloudflare quiche + BoringSSL via neon.",
5
+ "author": "Dacely Cloud",
6
+ "homepage": "https://github.com/dacely-cloud/rwebtransport#readme",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/dacely-cloud/rwebtransport.git"
10
+ },
11
+ "bugs": {
12
+ "url": "https://github.com/dacely-cloud/rwebtransport/issues"
13
+ },
14
+ "type": "commonjs",
15
+ "main": "./dist/index.js",
16
+ "module": "./dist/index.mjs",
17
+ "types": "./dist/index.d.ts",
18
+ "exports": {
19
+ ".": {
20
+ "types": "./dist/index.d.ts",
21
+ "import": "./dist/index.mjs",
22
+ "require": "./dist/index.js"
23
+ }
24
+ },
25
+ "files": [
26
+ "dist",
27
+ "prebuilds",
28
+ "scripts",
29
+ "crates",
30
+ "vendor",
31
+ "Cargo.toml",
32
+ "Cargo.lock",
33
+ "README.md",
34
+ "NOTICE"
35
+ ],
36
+ "engines": {
37
+ "node": ">=24 <25 || >=26 <27"
38
+ },
39
+ "scripts": {
40
+ "build": "npm run build:rust && npm run build:ts",
41
+ "build:rust": "node scripts/build.js",
42
+ "build:rust:debug": "node scripts/build.js --debug",
43
+ "build:ts": "node scripts/build-ts.js && tsc -p tsconfig.build.json",
44
+ "build:echo": "cargo build --release -p rwebtransport-echo-server",
45
+ "setup:windows": "powershell -ExecutionPolicy Bypass -File scripts/setup-windows.ps1",
46
+ "setup:unix": "bash scripts/setup-unix.sh",
47
+ "postinstall": "node scripts/postinstall.js",
48
+ "pretest": "npm run build:rust && npm run build:ts && npm run build:echo",
49
+ "test": "vitest run --project node",
50
+ "test:watch": "vitest --project node",
51
+ "typecheck": "tsc --noEmit",
52
+ "lint": "oxlint .",
53
+ "lint:fix": "oxlint . --fix",
54
+ "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
55
+ "format:check": "prettier --check \"src/**/*.ts\" \"test/**/*.ts\"",
56
+ "test:browser": "npm run pretest && vitest run --project browser",
57
+ "test:all": "npm run pretest && vitest run",
58
+ "test:coverage": "npm run pretest && vitest run --coverage"
59
+ },
60
+ "devDependencies": {
61
+ "@types/node": "^26.6.5",
62
+ "@vitest/coverage-v8": "^5.0.4",
63
+ "esbuild": "^0.28.2",
64
+ "oxlint": "^1.87.0",
65
+ "oxlint-tsgolint": "^7.0.2004",
66
+ "prettier": "^3.9.10",
67
+ "typescript": "^7.0.2",
68
+ "vitest": "^5.0.4",
69
+ "@vitest/browser-webdriverio": "^5.0.0",
70
+ "webdriverio": "^10.0.2"
71
+ },
72
+ "overrides": {
73
+ "esbuild": "$esbuild"
74
+ },
75
+ "keywords": [
76
+ "webtransport",
77
+ "quic",
78
+ "http3",
79
+ "quiche",
80
+ "neon"
81
+ ],
82
+ "license": "Apache-2.0"
80
83
  }
@@ -0,0 +1,41 @@
1
+ #!/usr/bin/env node
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ 'use strict';
4
+
5
+ const { rmSync } = require('node:fs');
6
+ const path = require('node:path');
7
+ const { build } = require('esbuild');
8
+
9
+ const root = path.resolve(__dirname, '..');
10
+
11
+ async function main() {
12
+ rmSync(path.join(root, 'dist'), { recursive: true, force: true });
13
+
14
+ for (const format of ['cjs', 'esm']) {
15
+ await build({
16
+ absWorkingDir: root,
17
+ entryPoints: ['src/index.ts'],
18
+ outfile: `dist/index.${format === 'cjs' ? 'js' : 'mjs'}`,
19
+ bundle: true,
20
+ platform: 'node',
21
+ target: 'node24',
22
+ packages: 'external',
23
+ format,
24
+ sourcemap: true,
25
+ // The native addon loader uses import.meta.url in both bundles.
26
+ ...(format === 'cjs'
27
+ ? {
28
+ define: { 'import.meta.url': '__rwebtransportImportMetaUrl' },
29
+ banner: {
30
+ js: "'use strict';\nconst __rwebtransportImportMetaUrl = require('node:url').pathToFileURL(__filename).href;",
31
+ },
32
+ }
33
+ : {}),
34
+ });
35
+ }
36
+ }
37
+
38
+ main().catch((error) => {
39
+ console.error(error);
40
+ process.exitCode = 1;
41
+ });
@@ -5687,6 +5687,21 @@ impl<F: BufFactory> Connection<F> {
5687
5687
  self.stream_recv_buf(stream_id, out)
5688
5688
  }
5689
5689
 
5690
+ /// Returns the receive-side final size before stream state is collected.
5691
+ /// This is needed for WebTransport session flow control after RESET_STREAM.
5692
+ pub fn stream_recv_final_size(&self, stream_id: u64) -> Option<u64> {
5693
+ self.streams
5694
+ .get(stream_id)
5695
+ .and_then(|stream| stream.recv.final_size())
5696
+ }
5697
+
5698
+ /// Returns the send-side final size, including locally or remotely reset streams.
5699
+ pub fn stream_send_final_size(&self, stream_id: u64) -> Option<u64> {
5700
+ self.streams
5701
+ .get(stream_id)
5702
+ .and_then(|stream| stream.send.final_size())
5703
+ }
5704
+
5690
5705
  /// Reads contiguous data from a stream into the provided [`bytes::BufMut`].
5691
5706
  ///
5692
5707
  /// **NOTE**:
@@ -291,6 +291,11 @@ impl RecvBuf {
291
291
  Ok((len, self.is_fin()))
292
292
  }
293
293
 
294
+ /// The final size supplied by FIN or RESET_STREAM, if known.
295
+ pub fn final_size(&self) -> Option<u64> {
296
+ self.fin_off
297
+ }
298
+
294
299
  /// Resets the stream at the given offset.
295
300
  pub fn reset(
296
301
  &mut self, error_code: u64, final_size: u64,
@@ -460,6 +460,11 @@ impl<F: BufFactory> SendBuf<F> {
460
460
  Ok(self.reset())
461
461
  }
462
462
 
463
+ /// Returns the final offset after FIN or a reset.
464
+ pub fn final_size(&self) -> Option<u64> {
465
+ self.fin_off
466
+ }
467
+
463
468
  /// Returns the largest offset of data buffered.
464
469
  pub fn off_back(&self) -> u64 {
465
470
  self.off