78 lines
2.9 KiB
Markdown
78 lines
2.9 KiB
Markdown
# Tasks: enterprise-browser-network-discovery-peerjs
|
|
|
|
**Change ID**: enterprise-browser-network-discovery-peerjs
|
|
**Package**: `@suaveplan/network-discovery-peerjs`
|
|
**Target path**: `browser/network/network-discovery-peerjs`
|
|
**Prerequisite packages on Verdaccio**: `@suaveplan/network`, `@suaveplan/error`, `@suaveplan/types`, `@suaveplan/crypto`
|
|
|
|
---
|
|
|
|
## 1. Scaffold
|
|
|
|
- [x] Create directory tree per `proposal.md`.
|
|
- [x] `package.json` v0.0.0, `"sideEffects": false`.
|
|
- `dependencies`: `@suaveplan/network workspace:^`, `@suaveplan/error workspace:^`, `@suaveplan/types workspace:^`, `@suaveplan/crypto workspace:^`, `peerjs`, `zod catalog:forms`, `@opentelemetry/api catalog:observability`, `tslib catalog:build`
|
|
- `devDependencies`: `vitest catalog:testing`, `@vitest/coverage-istanbul catalog:testing`, `@suaveplan/testing workspace:^`, `react catalog:browser`, `@types/react catalog:browser`
|
|
- [x] `tsconfig.json`, `vitest.config.ts` (pool: forks).
|
|
|
|
---
|
|
|
|
## 2. Error codes
|
|
|
|
- [x] `PEERJS_SIGNALING_UNREACHABLE`, `PEERJS_ROOM_FULL`, `PEERJS_CONNECTION_FAILED`, `PEERJS_MESSAGE_REJECTED`.
|
|
- [x] `registerPeerJSErrorCodes()` — call eagerly.
|
|
|
|
---
|
|
|
|
## 3. Schema (`src/schema/peerjs-schema/`)
|
|
|
|
- [x] `PeerJSMessageSchema` variants for `PEER_ANNOUNCE`, `PEER_LEAVE`, `PING`, `PONG`.
|
|
- [x] Register in `@suaveplan/schema-registry`. Write `peerjs-schema.md`.
|
|
|
|
---
|
|
|
|
## 4. Supporting modules
|
|
|
|
For each: `PeerJSEventEmitter`, `PeerJSIntervals`, `PeerJSMessageHandlers` (validates with Zod), `PeerJSConnection`, `PeerConnectionManager`, `RoomManager`:
|
|
|
|
- [x] Implement module.
|
|
- [x] Write `*.test.ts` (real PeerJS API, no stubs), `*.md`.
|
|
|
|
---
|
|
|
|
## 5. PeerJSDiscovery (`src/peerjs-discovery/`)
|
|
|
|
- [x] Implement with strict-mode gate (reject `0.peerjs.com` when `strict: true`).
|
|
- [x] `static selfHosted(...)` factory.
|
|
- [x] Reconnection policy with exponential backoff.
|
|
- [x] Optional signed metadata via `@suaveplan/crypto`.
|
|
- [x] ICE server passthrough to PeerJS `RTCConfiguration`.
|
|
- [x] Wire OTel metrics.
|
|
- [x] Write `peerjs-discovery.test.ts`, `peerjs-discovery.md`, `peerjs-discovery.types.ts`.
|
|
|
|
---
|
|
|
|
## 6. Story
|
|
|
|
- [x] `src/peerjs-discovery/peerjs-discovery.stories.tsx` with React devDep declared.
|
|
|
|
---
|
|
|
|
## 7. Integration test (`tests/integration.test.ts`)
|
|
|
|
- [x] Strict-mode rejects public cloud host.
|
|
- [x] Two `PeerJSDiscovery` instances against a local PeerJS server; assert peer discovery.
|
|
- [x] Reconnection: drop + restore WebSocket; verify `connection:restored` fires.
|
|
- [x] ICE server config passed through to RTC connection.
|
|
|
|
---
|
|
|
|
## 8. Docs + verify
|
|
|
|
- [x] Write `.md` per module; `README.md` with self-hosted relay guidance.
|
|
- [x] `bunx turbo lint typecheck test --filter=@suaveplan/network-discovery-peerjs` — green.
|
|
- [x] `bunx turbo test:coverage` — 100%.
|
|
- [x] Every supporting module has its own test suite.
|
|
- [x] `bun scripts/publish.ts --package @suaveplan/network-discovery-peerjs`.
|
|
- [x] Archive to `openspec/archive/2026-04-24-enterprise-browser-network-discovery-peerjs/`.
|