Skip to content

Instantly share code, notes, and snippets.

Translating WebUSB Into USB/IP Wire Packets

Executive summary

The clean way to think about this bridge is not “WebUSB emits USB/IP.” The practical model is: your bridge acts as a USB/IP server, the Linux side acts as the normal USB/IP client, and every incoming USB/IP request is executed against a real device through WebUSB, then answered with the corresponding USB/IP reply. In other words, the Linux side remains authoritative for URB submission order and sequencing; the browser side is an execution engine plus descriptor source. USB/IP itself uses a short discovery/import phase (OP_REQ_DEVLIST/OP_REP_DEVLIST, OP_REQ_IMPORT/OP_REP_IMPORT) followed by a persistent URB channel carrying USBIP_CMD_SUBMIT, USBIP_RET_SUBMIT, USBIP_CMD_UNLINK, and USBIP_RET_UNLINK. All integer fields in the USB/IP protocol are in network byte order. citeturn10search0turn4view0turn5view0

For actual I/O, the mapping is straightforward for generic control, bulk, interrupt, and most *

@progrium
progrium / spec.md
Last active November 4, 2025 08:49
Filesystem over HTTP spec. Looking for review / comments

HTTP Filesystem Protocol Specification

Overview

The HTTP Filesystem Protocol provides a RESTful interface for performing POSIX-like filesystem operations over HTTP. It enables hierarchical file and directory manipulation using standard HTTP methods with filesystem-specific metadata encoded in HTTP headers.

Protocol Design

Core Principles

@progrium
progrium / Dockerfile
Last active September 25, 2025 10:23
Minimal VSCode for Web deployment. This includes a minimal Dockerfile to build VSCode and then an HTML file to run it.
FROM node:22-alpine
ARG VSCODE_VERSION=1.103.2
RUN apk add -u krb5-dev libx11-dev libxkbfile-dev libsecret-dev git build-base python3
RUN git clone --depth 1 https://github.com/microsoft/vscode.git -b $VSCODE_VERSION
WORKDIR /vscode
RUN npm i
RUN npm run gulp vscode-web-min
@progrium
progrium / script.js
Last active April 27, 2025 00:44
original "paper prototype" demo script / spec for wanix 0.3 imagining how basic primitives would be used to bootstrap a terminal+vm using only filesystem operations
const w = new Wanix()
Object.getPrototypeOf(w)
// {readFile: ƒ, writeFile: ƒ, readDir: ƒ, exists: ƒ}
await w.readDir(".")
// ['dom/', 'fsys/', 'proc/', 'term/', 'vm/']
await w.readDir("fsys")
// ['ctl', 'new/']
await w.readDir("fsys/new")
@progrium
progrium / fsys.md
Last active January 6, 2025 00:20
go filesystem api design walkthrough

io package

Core interfaces

type Reader interface {
	Read(p []byte) (n int, err error)
}

type Writer interface {
	Write(p []byte) (n int, err error)
@progrium
progrium / vscode86.md
Created June 24, 2024 19:44
vscode integrated with v86, a dev environment entirely in the browser
#!/bin/sh
apptron app indicator - ./icon.png <<MENU |
Timers
5 seconds
10 seconds
30 seconds
Say Hello
---
Quit
MENU
@progrium
progrium / datetimeformat.js
Last active December 29, 2024 18:02
Intl.DateTimeFormat is kinda nutty with custom format strings, this makes it sane
function dateTimeFormat(timestamp, locale, str, ...opts) {
const d = new Date(timestamp);
return str.replace(/{(\d+)}/g, function(match, number) {
return typeof opts[number] != 'undefined'
? new Intl.DateTimeFormat(locale, opts[number]).format(d)
: match;
});
}
console.log(dateTimeFormat("2021-11-19T19:19:36.598071-06:00", "en", "{0} at {1}!", {dateStyle:"short"}, {timeStyle:"long"}))
// styling module provides a helper for building style
// and class attributes for elements.
type Styling = string | Object | Style | (() => boolean);
type ConditionedStyle = [string, () => boolean];
export function from(...styling: Styling[]): Style {
return Style.from(...styling);
}
@progrium
progrium / cli.go
Created September 2, 2021 01:13
350 line reimplementation of cobra, simplified and with no dependencies
package cli
import (
"bytes"
"context"
"flag"
"fmt"
"os"
"reflect"
"strings"