Files
zeekay 215cbfaaa9 @hanzo/zap-web v0.1.0 — initial scaffold (WS transport + serve + connect + mintCap slot)
Browser-frontend RPC over ZAP: a drop-in tRPC replacement speaking native ZAP
envelopes over WebSocket binary frames, layered on @hanzo/zap. No JSON, no
Cap'n Proto, no bearer-JWT plumbing.

Surfaces:
  - transport.ts: isomorphic WsTransport (node `ws` + browser native WebSocket);
    one ZAP envelope per WS binary message; text frames close with code 1003.
  - conn.ts: transport-agnostic request/response correlation (the ZapClient
    correlation logic generalised over WS, both directions).
  - server.ts: serve(httpServer, opts) attaches a ws.Server to http.Server's
    upgrade event for opts.path; mintCap(req) runs at the boundary (null → 401);
    rootCap(ctx) yields the per-conn dispatch handler.
  - client.ts: connect(url, opts) opens the WS, awaits open, returns
    { bootstrap, close }; bearer rides an Authorization header on header-capable
    impls (node ws), query-param fallback for the browser native WebSocket.
  - auth.ts: MintCap<Ctx> SLOT — apps supply (req) => Promise<Ctx|null>. The
    canonical ML-DSA-65 signed Capability mint (zap-spec/capabilities.zap) lands
    in a later version; documented honestly in README.
  - errors.ts: re-exports ZapParseError; adds WebRpcError for transport failures.

Tests (test/echo.test.ts, 3/3 passing): real end-to-end ZAP roundtrip over a
live WebSocket (no mocks) using an `echo.zap` schema codegen'd via
`zapgen --target=ts`; 401 rejection when mintCap returns null; two sequential
calls sharing one conn.

Reality-vs-spec notes (the task spec was written against a fictional Cap'n
Proto `@zap-proto/zap` v1.1.0):
  - The real foundation is `@hanzo/zap` v0.1.0 — a zero-copy ZAP wire format,
    explicitly NOT Cap'n Proto, with no `src/rpc/` Transport/Conn/Server/Client
    /bootstrap-capability API. Built honestly on what exists (buildRequest/
    parseRequest/buildResponse/parseResponse + method ordinals from .zap structs).
  - Package named `@hanzo/zap-web` (not `@zap-proto/web`) to depend cleanly on
    the real sibling `@hanzo/zap`. GitHub repo is zap-proto/web as requested.
  - `@hanzo/zap` is not on npm yet, so the dep is `link:../zap-ts` and vitest
    aliases `@hanzo/zap` → ../zap-ts/src. TODO: flip to npm semver once published.

Pre-1.0 by policy: NOT tagged, NOT published, no Docker.
2026-06-15 14:30:00 -07:00

22 lines
1.1 KiB
Plaintext

MIT License
Copyright (C) 2025, Lux Industries Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.