WIP: feat(wasm): expose taildrive WebDAV server and listDrivePeers via JS bridge #10

Draft
codinget wants to merge 1 commits from feat/drive-wasm-bridge into webnet
Owner

Summary

  • Add drive.go: implements drive.FileSystemForRemote with a JS-backed streaming handler. The Go goroutine stays alive for the response duration; JS calls write(chunk)/end() to stream the body back. Request body is streamed chunk-by-chunk via readBodyChunk() (no full-body buffering).
  • Add drive_stub.go: no-op stubs for ts_omit_drive builds.
  • Add peer.go: buildPeerAPIURL helper extracted from the inline logic in run().
  • Modify wasm_js.go: call initDriveForRemote before NewLocalBackend (SubSystem is set-once), expose setDriveHandler and listDrivePeers via wireDriveJS, refactor peerAPI URL logic to use buildPeerAPIURL.

listDrivePeers mirrors native driveRemotesFromPeers: returns empty if DriveAccessEnabled() is false, filters peers by PeerCapabilityTaildriveSharer via the live ACL cap map (lb.PeerCaps(addr).HasCapability()).

Auth is fully handled by handleServeDrive in peerapi_drive.go before our code runs — the JS handler only receives pre-authenticated, permission-scoped requests.

Test plan

  • GOARCH=wasm GOOS=js ./tool/go vet ./cmd/tsconnect/wasm/ passes
  • GOARCH=wasm GOOS=js ./tool/go build ./cmd/tsconnect/wasm/ compiles cleanly
  • setDriveHandler wired up in the JS object returned by newIPN
  • listDrivePeers returns empty array when DriveAccessEnabled() is false
  • End-to-end: peer with drive:share ACL can be browsed via WebDAV from another node

🤖 Generated with Claude Code

## Summary - Add `drive.go`: implements `drive.FileSystemForRemote` with a JS-backed streaming handler. The Go goroutine stays alive for the response duration; JS calls `write(chunk)`/`end()` to stream the body back. Request body is streamed chunk-by-chunk via `readBodyChunk()` (no full-body buffering). - Add `drive_stub.go`: no-op stubs for `ts_omit_drive` builds. - Add `peer.go`: `buildPeerAPIURL` helper extracted from the inline logic in `run()`. - Modify `wasm_js.go`: call `initDriveForRemote` before `NewLocalBackend` (SubSystem is set-once), expose `setDriveHandler` and `listDrivePeers` via `wireDriveJS`, refactor peerAPI URL logic to use `buildPeerAPIURL`. `listDrivePeers` mirrors native `driveRemotesFromPeers`: returns empty if `DriveAccessEnabled()` is false, filters peers by `PeerCapabilityTaildriveSharer` via the live ACL cap map (`lb.PeerCaps(addr).HasCapability()`). Auth is fully handled by `handleServeDrive` in `peerapi_drive.go` before our code runs — the JS handler only receives pre-authenticated, permission-scoped requests. ## Test plan - [ ] `GOARCH=wasm GOOS=js ./tool/go vet ./cmd/tsconnect/wasm/` passes - [ ] `GOARCH=wasm GOOS=js ./tool/go build ./cmd/tsconnect/wasm/` compiles cleanly - [ ] `setDriveHandler` wired up in the JS object returned by `newIPN` - [ ] `listDrivePeers` returns empty array when `DriveAccessEnabled()` is false - [ ] End-to-end: peer with `drive:share` ACL can be browsed via WebDAV from another node 🤖 Generated with [Claude Code](https://claude.com/claude-code)
codinget changed target branch from main to webnet 2026-06-09 23:01:53 +02:00
codinget added 1 commit 2026-06-09 23:01:53 +02:00
Add drive.go (build tag !ts_omit_drive): implements drive.FileSystemForRemote
with a JS-backed handler. Streams request bodies chunk-by-chunk via
readBodyChunk() and response bodies via write()/end() callbacks so no
full-body buffering occurs regardless of file size. The handler is nil-safe:
returns 404 until setDriveHandler() is called from JS.

Add drive_stub.go (build tag ts_omit_drive): no-op stubs for stripped builds.

Add peer.go: extract buildPeerAPIURL helper (previously inline in run()).

Modify wasm_js.go: call initDriveForRemote before NewLocalBackend (SubSystem
is set-once), expose setDriveHandler and listDrivePeers via wireDriveJS,
and refactor the inline peerAPI URL logic to use buildPeerAPIURL.

listDrivePeers mirrors native driveRemotesFromPeers: returns empty if
DriveAccessEnabled() is false, then filters peers by PeerCapabilityTaildriveSharer
using lb.PeerCaps(addr).HasCapability() (the live ACL-derived cap map).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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 feat/drive-wasm-bridge:feat/drive-wasm-bridge
git checkout feat/drive-wasm-bridge
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: webnet/tailscale#10