WIP: quic socket using quicbone2 #3

Draft
insberr wants to merge 3 commits from quicbone2-socket into main
Owner

Implement the quic socket using quicbone2

Implement the quic socket using quicbone2
Have fun with the certs thing yay
Author
Owner

The server side should be working. The code is very example-y though. The authentication to the socket has been ripped out for now. needs to be implemented. guh.

I was trying to test the webtransport connection in the browser. it cant connect because of self signed cert issues. there seems to be a way around this but i wan not able to get it to work, so maybe someone smarter and more dedicated than me can. otherwise you might just be better off obtaining certs signed by a trusted CA and using those. id have to modify some of the server code to accept dev and prod certs in different ways. guh.

The server side should be working. The code is very example-y though. The authentication to the socket has been ripped out for now. needs to be implemented. guh. I was trying to test the webtransport connection in the browser. it cant connect because of self signed cert issues. there seems to [be a way around this](https://developer.mozilla.org/en-US/docs/Web/API/WebTransport/WebTransport#servercertificatehashes) but i wan not able to get it to work, so maybe someone smarter and more dedicated than me can. otherwise you might just be better off obtaining certs signed by a trusted CA and using those. id have to modify some of the server code to accept dev and prod certs in different ways. guh.
insberr self-assigned this 2026-06-02 14:49:07 -07:00
Author
Owner
async function initTransport() {
	// Fetch the raw 32-byte SHA-256 hash from your dev HTTP endpoint
  const res = await fetch('/api/dev/cert-hash');
  const hashBuffer = await res.arrayBuffer(); // already a raw SHA-256 digest

  // Initialize transport connection
  const transport = new WebTransport("https://localhost:6969", {
		serverCertificateHashes: [
			{
				algorithm: "sha-256",
				value: hashBuffer,
			}
		]
	});

  // The connection can be used once ready fulfills
  await transport.ready;
	
	const stream = await transport.createBidirectionalStream({
    sendOrder: "10",
  });
  // stream is a WebTransportBidirectionalStream
  // stream.readable is a ReadableStream
  const readable = stream.readable;
  // stream.writable is a WritableStream
  const writable = stream.writable;

	const writer = writable.getWriter();
  const version = new Uint8Array([1, 0, 0]);
  writer.write(version);

	const reader = readable.getReader();
  while (true) {
    const { value, done } = await reader.read();
    if (done) {
      break;
    }
    // value is a Uint8Array.
    console.log(value);
		let res = new TextDecoder().decode(value);
		if (res !== "accepted") break;
  }
}
initTransport();
```javascript async function initTransport() { // Fetch the raw 32-byte SHA-256 hash from your dev HTTP endpoint const res = await fetch('/api/dev/cert-hash'); const hashBuffer = await res.arrayBuffer(); // already a raw SHA-256 digest // Initialize transport connection const transport = new WebTransport("https://localhost:6969", { serverCertificateHashes: [ { algorithm: "sha-256", value: hashBuffer, } ] }); // The connection can be used once ready fulfills await transport.ready; const stream = await transport.createBidirectionalStream({ sendOrder: "10", }); // stream is a WebTransportBidirectionalStream // stream.readable is a ReadableStream const readable = stream.readable; // stream.writable is a WritableStream const writable = stream.writable; const writer = writable.getWriter(); const version = new Uint8Array([1, 0, 0]); writer.write(version); const reader = readable.getReader(); while (true) { const { value, done } = await reader.read(); if (done) { break; } // value is a Uint8Array. console.log(value); let res = new TextDecoder().decode(value); if (res !== "accepted") break; } } initTransport(); ```
This pull request is marked as a work in progress.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin quicbone2-socket:quicbone2-socket
git switch quicbone2-socket

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch main
git merge --no-ff quicbone2-socket
git switch quicbone2-socket
git rebase main
git switch main
git merge --ff-only quicbone2-socket
git switch quicbone2-socket
git rebase main
git switch main
git merge --no-ff quicbone2-socket
git switch main
git merge --squash quicbone2-socket
git switch main
git merge --ff-only quicbone2-socket
git switch main
git merge quicbone2-socket
git push origin main
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
pyrine/yap!3
No description provided.