diff --git a/.agents/rules/cloud-auth-architecture.md b/.agents/rules/cloud-auth-architecture.md index 49384a12..b6e717a2 100644 --- a/.agents/rules/cloud-auth-architecture.md +++ b/.agents/rules/cloud-auth-architecture.md @@ -2,10 +2,8 @@ description: Cloud edition implementation details, PostgreSQL Row-Level Security (RLS) isolation, cross-subdomain auth, and cryptographic license keys. paths: - "src/lib/auth*" + - "src/lib/auth/**/*" - "src/app/api/auth/**/*" - - "src/core/auth.ts" - - "src/core/storage.ts" - - "src/core/tenant.ts" --- > **SUPERSEDED by ADR-003** (`docs/architecture/decisions/adr-0003-shared-identity-and-ecosystem-auth-host.md`). @@ -177,13 +175,15 @@ DATABASE_URL=postgresql://... ## Edition Adapters -Three thin files are all that differs between editions — everything else is edition-unaware: +Three thin adapter modules provide all edition-specific behaviour -- everything else is edition-unaware: | Adapter | Local | Cloud | Demo | |---|---|---|---| -| `src/core/auth.ts` | Auth.js `Credentials` (bcrypt + PostgreSQL) | Auth.js `@auth/supabase-adapter` | Disabled | -| `src/core/storage.ts` | `fs.writeFile()` to `data/` | Supabase Storage SDK | Read-only | -| `src/core/tenant.ts` | No-op (single tenant) | Sets `app.tenant_id` for RLS | No-op | +| `src/lib/auth.ts` | Auth.js `Credentials` (bcrypt + PostgreSQL) | Auth.js `@auth/supabase-adapter` | Disabled | +| Storage adapter (planned) | `fs.writeFile()` to `data/` | Supabase Storage SDK | Read-only | +| Tenant adapter (planned) | No-op (single tenant) | Sets `app.tenant_id` for RLS | No-op | + +> The storage and tenant adapters listed above are planned for the Cloud edition build-out and are not yet implemented as separate files. Auth is fully implemented in `src/lib/auth.ts` and `src/lib/auth.config.ts`. --- diff --git a/.agents/rules/deployment-and-testing.md b/.agents/rules/deployment-and-testing.md index 3647df0a..3e814bf5 100644 --- a/.agents/rules/deployment-and-testing.md +++ b/.agents/rules/deployment-and-testing.md @@ -206,18 +206,10 @@ Hard refresh: `Ctrl+Shift+R` ## Creating Static OSM Plugins -See full guide: `.agents/skills/osm-static-plugin-creation.md` +Use the `plugin-new` skill (`.agents/skills/plugin-new/SKILL.md`) to scaffold new plugins, including OSM-based static data plugins. The old `scaffold-osm-plugin.mjs` script and `osm-static-plugin-creation.md` skill were removed; static OSM plugins are now built as standard `bundle` format plugins via the wwv-cli: -**Quick start:** ```bash -node scripts/scaffold-osm-plugin.mjs '{ - "name": "volcanoes", - "displayName": "Volcanoes", - "osmTag": "natural=volcano", - "icon": "Mountain", - "color": "#ef4444", - "category": "Natural Disaster" -}' +node packages/wwv-cli/dist/index.js create --local ``` **Manual Overpass API query (PowerShell):** @@ -227,26 +219,29 @@ $body = "data=[out:json][timeout:300];(node[$tag];way[$tag];relation[$tag];);out Invoke-RestMethod -Uri 'https://overpass-api.de/api/interpreter' -Method Post -Body $body -OutFile 'tmp/raw_data.json' ``` -**Note:** OSM data is licensed under **ODbL** — include attribution in plugin READMEs. +**Note:** OSM data is licensed under **ODbL** - include attribution in plugin READMEs. --- ## npm Plugin Publishing -See full guide: `.agents/skills/version-control/npm-plugin-publishing.md` +The `npm-plugin-publishing.md` skill was removed. Use the wwv-cli publish command: ```bash -# First-time publish +# Publish a local plugin +node packages/wwv-cli/dist/index.js publish [--org ] + +# Or publish directly via pnpm (for packages/ workspace members) pnpm publish --workspace=packages/wwv-plugin- --access public -# Future versions — via Trusted Publishing (GitHub Actions CI/CD) +# Future versions via Trusted Publishing (GitHub Actions CI/CD) ``` --- ## Git / Version Control -See full guide: `.agents/skills/version-control/git-version-control.md` +The `git-version-control.md` skill was removed. See `.agents/skills/using-git-worktrees/SKILL.md` for worktree workflows and `.agents/skills/branch-cleanup/SKILL.md` for the post-merge teardown flow. **Commit convention:** `feat:`, `fix:`, `chore:`, `docs:` prefixes. **Commit when:** A new feature is completed (per project rules). @@ -255,7 +250,7 @@ See full guide: `.agents/skills/version-control/git-version-control.md` ## Security Checks -See full guide: `.agents/skills/security/security-check.md` +The `security-check.md` skill was removed. Security reviews are handled by the `security-reviewer` agent (`.agents/agents/security-reviewer.md`). Trigger it after any change touching auth routes, API routes, plugin loading, or marketplace flows. --- diff --git a/.agents/rules/plugin-architecture.md b/.agents/rules/plugin-architecture.md index a8c309af..324c6be5 100644 --- a/.agents/rules/plugin-architecture.md +++ b/.agents/rules/plugin-architecture.md @@ -237,7 +237,7 @@ GET marketplace.worldwideview.dev/api/registry - Trust is **always stamped server-side** — no client-side trust claims accepted - Registry response cached for **5 minutes** (in-memory on each WWV instance) - If registry unreachable, last cached result used; new unknowns default to `unverified` -- **Managing:** Edit `src/data/verifiedPlugins.ts` in marketplace repo and redeploy +- **Managing:** Use the marketplace admin API (`/api/admin/registry`) to manage the signed plugin registry. The old `src/data/verifiedPlugins.ts` static file was replaced by database-driven registry management. - **Revoking:** Remove plugin ID and redeploy — WWV instances drop trust on next cache refresh ### Unverified Plugin Warning @@ -437,7 +437,7 @@ This queries Overpass API, converts to GeoJSON, scaffolds the package, and print | Power plants | `power=plant` | 15k | | Wind farms | `generator:source=wind` | 50k | -See skill: `.agents/skills/osm-static-plugin-creation.md` +The `osm-static-plugin-creation.md` skill was removed. Use `node packages/wwv-cli/dist/index.js create --local` to scaffold a new plugin, then populate it with OSM data fetched via the Overpass API. --- @@ -462,7 +462,7 @@ To solve this friction and make third-party plugin hosting highly intuitive, the 2. **Backend SDK:** They write simple `.ts` fetch scripts returning `GeoEntity[]` and drop them into a mounted `/seeders` volume. 3. **Zero Configuration:** The Docker engine hot-reloads these seeders, handles the Redis caching, and exposes standardized REST or WebSocket endpoints automatically. The developer focuses only on fetching data, avoiding all backend infrastructure setup. -See skill: `.agents/skills/data-engine-seeder-creation.md` +The `data-engine-seeder-creation.md` skill was removed. Seeder implementation rules are documented inline in `.agents/rules/data-engine-architecture.md`. Seeders live in `local-seeders/community/` or `local-seeders/private/` (separate git clones). --- diff --git a/package.json b/package.json index e6159d41..99e75af8 100644 --- a/package.json +++ b/package.json @@ -82,7 +82,7 @@ "@typescript-eslint/parser": "^8.60.1", "@vitejs/plugin-react": "^6.0.2", "@vitest/coverage-v8": "4.1.8", - "concurrently": "^9.2.1", + "concurrently": "^10.0.3", "copy-webpack-plugin": "^14.0.0", "eslint": "^9", "eslint-config-airbnb": "^19.0.4", diff --git a/packages/wwv-cli/package.json b/packages/wwv-cli/package.json index f1ee6d5b..b8472dba 100644 --- a/packages/wwv-cli/package.json +++ b/packages/wwv-cli/package.json @@ -14,7 +14,7 @@ "test": "node --test \"test/**/*.test.mjs\"" }, "dependencies": { - "commander": "^14.0.3", + "commander": "^15.0.0", "prompts": "^2.4.2" }, "devDependencies": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0c0e3f31..1f4e28c4 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -180,8 +180,8 @@ importers: specifier: 4.1.8 version: 4.1.8(vitest@4.1.8) concurrently: - specifier: ^9.2.1 - version: 9.2.1 + specifier: ^10.0.3 + version: 10.0.3 copy-webpack-plugin: specifier: ^14.0.0 version: 14.0.0(webpack@5.105.4(esbuild@0.28.0)) @@ -507,8 +507,8 @@ importers: packages/wwv-cli: dependencies: commander: - specifier: ^14.0.3 - version: 14.0.3 + specifier: ^15.0.0 + version: 15.0.0 prompts: specifier: ^2.4.2 version: 2.4.2 @@ -2709,6 +2709,10 @@ packages: resolution: {integrity: sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==} engines: {node: '>=8'} + ansi-regex@6.2.2: + resolution: {integrity: sha512-Bq3SmSpyFHaWjPk8If9yc6svM8c56dB5BAtW4Qbw5jHTwwXXcTLoRMkpDJp6VL0XzlWaCHTXrkFURMYmD0sLqg==} + engines: {node: '>=12'} + ansi-styles@4.3.0: resolution: {integrity: sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==} engines: {node: '>=8'} @@ -2717,6 +2721,10 @@ packages: resolution: {integrity: sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==} engines: {node: '>=10'} + ansi-styles@6.2.3: + resolution: {integrity: sha512-4Dj6M28JB+oAH8kFkTLUo+a2jwOFkuqb3yucU0CANcRRUbxS0cP0nZYCGjcc3BNXwRIsUVmDGgzawme7zvJHvg==} + engines: {node: '>=12'} + argparse@2.0.1: resolution: {integrity: sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==} @@ -2986,9 +2994,9 @@ packages: client-only@0.0.1: resolution: {integrity: sha512-IV3Ou0jSMzZrd3pZ48nLkT9DA7Ag1pnPzaiQhpW7c3RbcqqzvzzVu+L8gfqMp/8IM2MQtSiqaCxrrcfu8I8rMA==} - cliui@8.0.1: - resolution: {integrity: sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==} - engines: {node: '>=12'} + cliui@9.0.1: + resolution: {integrity: sha512-k7ndgKhwoQveBL+/1tqGJYNz097I7WOvwbmmU2AR5+magtbjPWQTS1C5vzGkBC8Ym8UWRzfKUzUUqFLypY4Q+w==} + engines: {node: '>=20'} cloudflare-video-element@1.3.5: resolution: {integrity: sha512-zj9gjJa6xW8MNrfc4oKuwgGS0njRLpOlQjdifbuNxvy8k4Y3pKCyKCMG2XIsjd2iQGhgjS57b1P5VWdJlxcXBw==} @@ -3015,6 +3023,10 @@ packages: resolution: {integrity: sha512-H+y0Jo/T1RZ9qPP4Eh1pkcQcLRglraJaSLoyOtHxu6AapkjWVCy2Sit1QQ4x3Dng8qDlSsZEet7g5Pq06MvTgw==} engines: {node: '>=20'} + commander@15.0.0: + resolution: {integrity: sha512-z67u4ZhzCL/Tydu1lJARtEZYWbWaN7oYLHbsuzocr6y4N6WZAagG3RQ4FW61V1/0+jImpj293XfrcYnd1qxtPg==} + engines: {node: '>=22.12.0'} + commander@2.20.3: resolution: {integrity: sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==} @@ -3024,9 +3036,9 @@ packages: concat-map@0.0.1: resolution: {integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==} - concurrently@9.2.1: - resolution: {integrity: sha512-fsfrO0MxV64Znoy8/l1vVIjjHa29SZyyqPgQBwhiDcaW8wJc2W3XWVOGx4M3oJBnv/zdUZIIp1gDeS98GzP8Ng==} - engines: {node: '>=18'} + concurrently@10.0.3: + resolution: {integrity: sha512-hc3LH4UaKWd/bbyDK/IGVa4RB6PtQ3CUYwtrkzqHn+wIG3Hr5fhpRlk0L/gCa8ZE1L/Ufj50Zho69cI5w8SQBA==} + engines: {node: '>=22'} hasBin: true confbox@0.2.4: @@ -3263,9 +3275,6 @@ packages: emoji-regex@10.6.0: resolution: {integrity: sha512-toUI84YS5YmxW219erniWD0CIVOo46xGKColeNQRgOzDorgBi1v4D71/OFzgD9GO2UGKIv1C3Sp8DAn0+j5w7A==} - emoji-regex@8.0.0: - resolution: {integrity: sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==} - emoji-regex@9.2.2: resolution: {integrity: sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==} @@ -3696,6 +3705,10 @@ packages: resolution: {integrity: sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==} engines: {node: 6.* || 8.* || >= 10.*} + get-east-asian-width@1.6.0: + resolution: {integrity: sha512-QRbvDIbx6YklUe6RxeTeleMR0yv3cYH6PsPZHcnVn7xv7zO1BHN8r0XETu8n6Ye3Q+ahtSarc3WgtNWmehIBfA==} + engines: {node: '>=18'} + get-intrinsic@1.3.0: resolution: {integrity: sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==} engines: {node: '>= 0.4'} @@ -3985,10 +3998,6 @@ packages: resolution: {integrity: sha512-1pC6N8qWJbWoPtEjgcL2xyhQOP491EQjeUo3qTKcmV8YSDDJrOepfG8pcC7h/QgnQHYSv0mJ3Z/ZWxmatVrysg==} engines: {node: '>= 0.4'} - is-fullwidth-code-point@3.0.0: - resolution: {integrity: sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==} - engines: {node: '>=8'} - is-generator-function@1.1.2: resolution: {integrity: sha512-upqt1SkGkODW9tsGNG5mtXTXtECizwtS2kA161M+gJPc1xdb/Ax629af6YrTwcOeQHbewrPNlE5Dx7kzvXTizA==} engines: {node: '>= 0.4'} @@ -4980,10 +4989,6 @@ packages: engines: {node: '>= 6'} deprecated: request has been deprecated, see https://github.com/request/request/issues/3142 - require-directory@2.1.1: - resolution: {integrity: sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==} - engines: {node: '>=0.10.0'} - require-from-string@2.0.2: resolution: {integrity: sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==} engines: {node: '>=0.10.0'} @@ -5154,8 +5159,8 @@ packages: resolution: {integrity: sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==} engines: {node: '>=8'} - shell-quote@1.8.3: - resolution: {integrity: sha512-ObmnIF4hXNg1BqhnHmgbDETF8dLPCggZWBjkQfhZpbszZnYur5DUljTcCHii5LC3J5E0yeO/1LIMyH+UvHQgyw==} + shell-quote@1.8.4: + resolution: {integrity: sha512-VsC6n6vz1ihYYyZZwX7YZSF5l5x36ca17OC+a69h94YqB7X6XLwf+5MOgynYir2SLFUbl8gIYvBo8K8RoNQ6bQ==} engines: {node: '>= 0.4'} side-channel-list@1.0.1: @@ -5251,9 +5256,9 @@ packages: resolution: {integrity: sha512-eLoXW/DHyl62zxY4SCaIgnRhuMr6ri4juEYARS8E6sCEqzKpOiE521Ucofdx+KnDZl5xmvGYaaKCk5FEOxJCoQ==} engines: {node: '>= 0.4'} - string-width@4.2.3: - resolution: {integrity: sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==} - engines: {node: '>=8'} + string-width@7.2.0: + resolution: {integrity: sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ==} + engines: {node: '>=18'} string.prototype.includes@2.0.1: resolution: {integrity: sha512-o7+c9bW6zpAdJHTtujeePODAhkuicdAryFsfVKwA+wGw89wJ4GTY484WTucM9hLtDEOpOvI+aHnzqnC5lHp4Rg==} @@ -5281,9 +5286,9 @@ packages: string_decoder@1.3.0: resolution: {integrity: sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==} - strip-ansi@6.0.1: - resolution: {integrity: sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==} - engines: {node: '>=8'} + strip-ansi@7.2.0: + resolution: {integrity: sha512-yDPMNjp4WyfYBkHnjIRLfca1i6KMyGCtsVgoKe/z1+6vukgaENdgGBZt+ZmKPc4gavvEZ5OgHfHdrazhgNyG7w==} + engines: {node: '>=12'} strip-bom@3.0.0: resolution: {integrity: sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==} @@ -5326,6 +5331,10 @@ packages: super-media-element@1.4.2: resolution: {integrity: sha512-9pP/CVNp4NF2MNlRzLwQkjiTgKKe9WYXrLh9+8QokWmMxz+zt2mf1utkWLco26IuA3AfVcTb//qtlTIjY3VHxA==} + supports-color@10.2.2: + resolution: {integrity: sha512-SS+jx45GF1QjgEXQx4NJZV9ImqmO2NPz5FNsIHrsDjh2YsHnawpan7SNQ1o8NuhrbHZy9AZhIoCUiCeaW/C80g==} + engines: {node: '>=18'} + supports-color@7.2.0: resolution: {integrity: sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==} engines: {node: '>=8'} @@ -5791,9 +5800,9 @@ packages: resolution: {integrity: sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==} engines: {node: '>=0.10.0'} - wrap-ansi@7.0.0: - resolution: {integrity: sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==} - engines: {node: '>=10'} + wrap-ansi@9.0.2: + resolution: {integrity: sha512-42AtmgqjV+X1VpdOfyTGOYRi0/zsoLqtXQckTmqTeybT+BDIbM/Guxo7x3pE2vtpr1ok6xRqM9OpBe+Jyoqyww==} + engines: {node: '>=18'} wrappy@1.0.2: resolution: {integrity: sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==} @@ -5828,13 +5837,13 @@ packages: yallist@3.1.1: resolution: {integrity: sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==} - yargs-parser@21.1.1: - resolution: {integrity: sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==} - engines: {node: '>=12'} + yargs-parser@22.0.0: + resolution: {integrity: sha512-rwu/ClNdSMpkSrUb+d6BRsSkLUq1fmfsY6TOpYzTwvwkg1/NRG85KBy3kq++A8LKQwX6lsu+aWad+2khvuXrqw==} + engines: {node: ^20.19.0 || ^22.12.0 || >=23} - yargs@17.7.2: - resolution: {integrity: sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==} - engines: {node: '>=12'} + yargs@18.0.0: + resolution: {integrity: sha512-4UEqdc2RYGHZc7Doyqkrqiln3p9X2DZVxaGbwhn2pi7MrRagKaOcIKe8L3OxYcbhXLgLFUS3zAYuQjKBQgmuNg==} + engines: {node: ^20.19.0 || ^22.12.0 || >=23} yocto-queue@0.1.0: resolution: {integrity: sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==} @@ -8034,12 +8043,16 @@ snapshots: ansi-regex@5.0.1: {} + ansi-regex@6.2.2: {} + ansi-styles@4.3.0: dependencies: color-convert: 2.0.1 ansi-styles@5.2.0: {} + ansi-styles@6.2.3: {} + argparse@2.0.1: {} aria-query@5.3.0: @@ -8368,11 +8381,11 @@ snapshots: client-only@0.0.1: {} - cliui@8.0.1: + cliui@9.0.1: dependencies: - string-width: 4.2.3 - strip-ansi: 6.0.1 - wrap-ansi: 7.0.0 + string-width: 7.2.0 + strip-ansi: 7.2.0 + wrap-ansi: 9.0.2 cloudflare-video-element@1.3.5: {} @@ -8392,20 +8405,22 @@ snapshots: commander@14.0.3: {} + commander@15.0.0: {} + commander@2.20.3: {} commondir@1.0.1: {} concat-map@0.0.1: {} - concurrently@9.2.1: + concurrently@10.0.3: dependencies: - chalk: 4.1.2 + chalk: 5.6.2 rxjs: 7.8.2 - shell-quote: 1.8.3 - supports-color: 8.1.1 + shell-quote: 1.8.4 + supports-color: 10.2.2 tree-kill: 1.2.2 - yargs: 17.7.2 + yargs: 18.0.0 confbox@0.2.4: {} @@ -8652,8 +8667,6 @@ snapshots: emoji-regex@10.6.0: {} - emoji-regex@8.0.0: {} - emoji-regex@9.2.2: {} empathic@2.0.0: {} @@ -9278,6 +9291,8 @@ snapshots: get-caller-file@2.0.5: {} + get-east-asian-width@1.6.0: {} + get-intrinsic@1.3.0: dependencies: call-bind-apply-helpers: 1.0.2 @@ -9588,8 +9603,6 @@ snapshots: dependencies: call-bound: 1.0.4 - is-fullwidth-code-point@3.0.0: {} - is-generator-function@1.1.2: dependencies: call-bound: 1.0.4 @@ -10565,8 +10578,6 @@ snapshots: tunnel-agent: 0.6.0 uuid: 3.4.0 - require-directory@2.1.1: {} - require-from-string@2.0.2: {} require-in-the-middle@8.0.1: @@ -10831,7 +10842,7 @@ snapshots: shebang-regex@3.0.0: {} - shell-quote@1.8.3: {} + shell-quote@1.8.4: {} side-channel-list@1.0.1: dependencies: @@ -10929,11 +10940,11 @@ snapshots: es-errors: 1.3.0 internal-slot: 1.1.0 - string-width@4.2.3: + string-width@7.2.0: dependencies: - emoji-regex: 8.0.0 - is-fullwidth-code-point: 3.0.0 - strip-ansi: 6.0.1 + emoji-regex: 10.6.0 + get-east-asian-width: 1.6.0 + strip-ansi: 7.2.0 string.prototype.includes@2.0.1: dependencies: @@ -10990,9 +11001,9 @@ snapshots: safe-buffer: 5.2.1 optional: true - strip-ansi@6.0.1: + strip-ansi@7.2.0: dependencies: - ansi-regex: 5.0.1 + ansi-regex: 6.2.2 strip-bom@3.0.0: {} @@ -11016,6 +11027,8 @@ snapshots: super-media-element@1.4.2: {} + supports-color@10.2.2: {} + supports-color@7.2.0: dependencies: has-flag: 4.0.0 @@ -11534,11 +11547,11 @@ snapshots: word-wrap@1.2.5: {} - wrap-ansi@7.0.0: + wrap-ansi@9.0.2: dependencies: - ansi-styles: 4.3.0 - string-width: 4.2.3 - strip-ansi: 6.0.1 + ansi-styles: 6.2.3 + string-width: 7.2.0 + strip-ansi: 7.2.0 wrappy@1.0.2: {} @@ -11554,17 +11567,16 @@ snapshots: yallist@3.1.1: {} - yargs-parser@21.1.1: {} + yargs-parser@22.0.0: {} - yargs@17.7.2: + yargs@18.0.0: dependencies: - cliui: 8.0.1 + cliui: 9.0.1 escalade: 3.2.0 get-caller-file: 2.0.5 - require-directory: 2.1.1 - string-width: 4.2.3 + string-width: 7.2.0 y18n: 5.0.8 - yargs-parser: 21.1.1 + yargs-parser: 22.0.0 yocto-queue@0.1.0: {} diff --git a/src/core/plugins/validateManifest.test.ts b/src/core/plugins/validateManifest.test.ts index fbdd0d0d..274dd841 100644 --- a/src/core/plugins/validateManifest.test.ts +++ b/src/core/plugins/validateManifest.test.ts @@ -375,3 +375,53 @@ describe("validateManifest no execution field required (MAN-04)", () => { expect(hasExecutionError).toBe(false); }); }); + +// --------------------------------------------------------------------------- +// SEC-URL: entry URL allowlist must host-match the PARSED hostname. +// Substring checks (includes / startsWith on the raw string) are bypassable +// and would allow an attacker-controlled origin to serve the imported bundle. +// --------------------------------------------------------------------------- + +describe("validateManifest entry URL allowlist (security)", () => { + const ERR = + "entry URL must be a relative path, CDN, localhost, or worldwideview.dev domain"; + + const accepts = (entry: string) => { + const result = validateManifest(baseManifest({ entry })); + expect(result.errors, `expected "${entry}" to be accepted`).not.toContain(ERR); + }; + const rejects = (entry: string) => { + const result = validateManifest(baseManifest({ entry })); + expect(result.errors, `expected "${entry}" to be rejected`).toContain(ERR); + }; + + it("accepts relative and exact known-host absolute entries", () => { + accepts("/plugins/test/frontend.mjs"); + accepts("./frontend.mjs"); + accepts("https://unpkg.com/@wwv/plugin/frontend.mjs"); + accepts("https://cdn.jsdelivr.net/npm/@wwv/plugin/frontend.mjs"); + accepts("https://marketplace.worldwideview.dev/p/frontend.mjs"); + accepts("https://worldwideview.dev/p/frontend.mjs"); + accepts("http://localhost:3000/plugins/x/frontend.mjs"); + accepts("http://127.0.0.1:5000/plugins/x/frontend.mjs"); + accepts("http://[::1]:5000/plugins/x/frontend.mjs"); + }); + + it("rejects substring-bypass hostnames the old check allowed", () => { + rejects("https://unpkg.com.evil.com/frontend.mjs"); + rejects("https://cdn.jsdelivr.net.evil.com/frontend.mjs"); + rejects("https://sub.worldwideview.dev.evil.com/frontend.mjs"); + rejects("https://evil.com/#.worldwideview.dev"); + rejects("https://evil.com/?x=.worldwideview.dev"); + rejects("http://localhost.evil.com/frontend.mjs"); + rejects("https://hacker.com/malicious.js"); + }); + + it("rejects protocol-relative, slash-backslash, userinfo and non-http(s) scheme tricks", () => { + rejects("//evil.com/frontend.mjs"); + rejects("/\\evil.com/frontend.mjs"); + rejects("https://unpkg.com@evil.com/frontend.mjs"); + rejects("javascript:alert(1)"); + rejects("data:text/javascript,alert(1)"); + }); +}); diff --git a/src/core/plugins/validateManifest.ts b/src/core/plugins/validateManifest.ts index bf31e013..ef533d80 100644 --- a/src/core/plugins/validateManifest.ts +++ b/src/core/plugins/validateManifest.ts @@ -86,25 +86,41 @@ export function validateManifest( errors.push("Missing required field: entry"); } else { const entry = manifest.entry.trim(); - const isRelative = entry.startsWith("/") || entry.startsWith("./"); - const isLocal = entry.startsWith("http://localhost") || entry.startsWith("http://127.0.0.1"); - const isWWV = entry.includes(".worldwideview.dev"); - const isCDN = entry.startsWith("https://cdn.jsdelivr.net") || entry.startsWith("https://unpkg.com"); + // A relative path starts with "/" or "./". Reject protocol-relative + // ("//host") and slash-backslash ("/\\host") forms: they start with "/" + // but resolve to an EXTERNAL origin when import()-ed. + const isRelative = + entry.startsWith("./") || + (entry.startsWith("/") && entry[1] !== "/" && entry[1] !== "\\"); - // Accept bundles served from a configured marketplace/instance host - // (e.g. marketplace.wwv.local) derived from env, so custom deployment - // hostnames work without being hardcoded. - let isConfiguredHost = false; - if (ENV_ALLOWED_ENTRY_HOSTS.size > 0) { + // Absolute entry URLs are host-matched against an allowlist using the + // PARSED hostname. Substring checks on the raw string (includes / + // startsWith) are bypassable, e.g. "https://unpkg.com.evil.com/x.mjs" + // or "https://sub.worldwideview.dev.evil.com/x.mjs", which would let an + // attacker-controlled origin serve the dynamically imported bundle (RCE). + let isAllowedHost = false; + if (!isRelative) { try { - isConfiguredHost = ENV_ALLOWED_ENTRY_HOSTS.has(new URL(entry).hostname); + const url = new URL(entry); + const host = url.hostname; + const isSecure = url.protocol === "https:"; + const isLocalhost = + (url.protocol === "http:" || isSecure) && + (host === "localhost" || host === "127.0.0.1" || host === "[::1]"); + const isWWV = + isSecure && + (host === "worldwideview.dev" || host.endsWith(".worldwideview.dev")); + const isCDN = isSecure && (host === "cdn.jsdelivr.net" || host === "unpkg.com"); + // Operator-configured hosts (from NEXT_PUBLIC_*MARKETPLACE_URL) are an + // explicit deployment opt-in, so their protocol is trusted as set. + const isConfiguredHost = ENV_ALLOWED_ENTRY_HOSTS.has(host); + isAllowedHost = isLocalhost || isWWV || isCDN || isConfiguredHost; } catch { - // Relative paths and other non-absolute entries aren't parseable - // as full URLs — they're already covered by `isRelative`. + // Not a parseable absolute URL and not relative: rejected below. } } - if (!isRelative && !isLocal && !isWWV && !isCDN && !isConfiguredHost) { + if (!isRelative && !isAllowedHost) { errors.push("entry URL must be a relative path, CDN, localhost, or worldwideview.dev domain"); } }