diff --git a/.changes/web-app-naming.changed.md b/.changes/web-app-naming.changed.md new file mode 100644 index 0000000..fe260fe --- /dev/null +++ b/.changes/web-app-naming.changed.md @@ -0,0 +1 @@ +Registry 安装交接统一使用 `app_origin`,继续接收旧 `client_origin` 链接;拒绝冲突目标,目录导航和安装返回保持同一 Web App。 diff --git a/.changeset/README.md b/.changeset/README.md index 4bfb95b..cb90f6f 100644 --- a/.changeset/README.md +++ b/.changeset/README.md @@ -1,7 +1,7 @@ # Changesets Changesets owns version bumps and changelog entries for the independently -released client-web Extension Host Runtime. Add a changeset to any pull request +released Web app Extension Host Runtime. Add a changeset to any pull request that changes its published behavior. Python package versions and changelogs are managed by Towncrier instead. diff --git a/.changeset/web-app-runtime-name.md b/.changeset/web-app-runtime-name.md new file mode 100644 index 0000000..aa46d29 --- /dev/null +++ b/.changeset/web-app-runtime-name.md @@ -0,0 +1,7 @@ +--- +'@inkcre/extension-runtime-web': patch +--- + +将浏览器 Extension Runtime 更名为 `@inkcre/extension-runtime-web`,目录、构建及独立发布产物使用 Web App 命名;公开运行时 API 和已发布旧名称产物保持兼容。 + +同时将 Runtime 的直接 Zod 依赖升级到 4.6.6,修复超大集合验证导致内存耗尽的问题(GHSA-mrhx-c7xc-m3w5)。 diff --git a/.github/workflows/packages-release.yml b/.github/workflows/packages-release.yml index 625cec6..3731970 100644 --- a/.github/workflows/packages-release.yml +++ b/.github/workflows/packages-release.yml @@ -142,20 +142,20 @@ jobs: - name: Verify managed package versions run: | - web_runtime_version=$(node -p 'require("./runtimes/client-web/package.json").version') + web_runtime_version=$(node -p 'require("./runtimes/web/package.json").version') pdm run check:releases - grep -F -m1 "## $web_runtime_version" runtimes/client-web/CHANGELOG.md + grep -F -m1 "## $web_runtime_version" runtimes/web/CHANGELOG.md - name: Build independent package assets env: SOURCE_DATE_EPOCH: '315532800' run: | - mkdir -p release-assets/toolkit release-assets/runtime-core-py release-assets/runtime-client-web + mkdir -p release-assets/toolkit release-assets/runtime-core-py release-assets/runtime-web pdm build --project toolkit --dest "$GITHUB_WORKSPACE/release-assets/toolkit" pdm build --project runtimes/core-py --dest "$GITHUB_WORKSPACE/release-assets/runtime-core-py" - pnpm --filter @inkcre/extension-runtime-client-web build - pnpm --filter @inkcre/extension-runtime-client-web pack \ - --pack-destination "$GITHUB_WORKSPACE/release-assets/runtime-client-web" + pnpm --filter @inkcre/extension-runtime-web build + pnpm --filter @inkcre/extension-runtime-web pack \ + --pack-destination "$GITHUB_WORKSPACE/release-assets/runtime-web" - name: Create missing independent package releases env: @@ -192,6 +192,10 @@ jobs: else echo "Core Python Runtime has pending release fragments; publication waits for its Version PR." >> "$GITHUB_STEP_SUMMARY" fi - release_package runtime-client-web \ - "$(node -p 'require("./runtimes/client-web/package.json").version')" \ - release-assets/runtime-client-web + if ! find .changeset -maxdepth 1 -name '*.md' ! -name README.md | grep -q .; then + release_package runtime-web \ + "$(node -p 'require("./runtimes/web/package.json").version')" \ + release-assets/runtime-web + else + echo "Web Runtime has pending Changesets; publication waits for its Version PR." >> "$GITHUB_STEP_SUMMARY" + fi diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 268e91b..19ad78b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -51,7 +51,7 @@ Package release intent uses the ecosystem-native release tool: `pdm run towncrier create --config towncrier.toml --dir toolkit 123.added.md`. The root `.changes/` belongs to the Registry service; `toolkit/.changes/` and `runtimes/core-py/.changes/` belong to those independently versioned packages. -- Client Web Runtime changes use `pnpm changeset`. Changesets creates the +- Web Runtime changes use `pnpm changeset`. Changesets creates the protected-main Version PR and updates its version and changelog. The four versions are independent. A Python Version PR consumes pending diff --git a/docs/30-unit-tdd/README.md b/docs/30-unit-tdd/README.md index 5f41740..faa5007 100644 --- a/docs/30-unit-tdd/README.md +++ b/docs/30-unit-tdd/README.md @@ -9,7 +9,7 @@ generated contracts and build checks remain executable authority. - [Registry Web](registry-web.md): discovery, publisher workspace, and design consumption. - [Extension Developer Toolkit](developer-toolkit.md) - [Core Python Extension Host Runtime](core-python-runtime.md) -- [Client Web Extension Runtime](client-web-runtime.md):浏览器生命周期、精确 Peer 管理与发行文档消费。 +- [Web Extension Runtime](web-runtime.md):浏览器生命周期、精确 Peer 管理与发行文档消费。 Shared product behavior and cross-unit Host contracts remain in the InKCre documentation Hub rather than being copied here. diff --git a/docs/30-unit-tdd/registry-web.md b/docs/30-unit-tdd/registry-web.md index c8d1be0..068f242 100644 --- a/docs/30-unit-tdd/registry-web.md +++ b/docs/30-unit-tdd/registry-web.md @@ -20,16 +20,23 @@ version. Missing or withdrawn versions return a human-readable 404. Existing `/v1`, `/simple`, `/packages`, and Module Federation asset paths retain their machine-facing semantics. -The detail page links to client-web's `/extensions?install=&distribution=&version=`. +The detail page links to Web app's `/extensions?install=&distribution=&version=`. The Registry neither reads deployment state nor installs the Release. When a -client-web page opens the Registry, it passes only its Web origin as -`client_origin`; the catalog preserves it through search, filters, and version +Web app page opens the Registry, it passes only its Web origin as +`app_origin`; the catalog preserves it through search, filters, and version links. The Registry accepts HTTPS origins (and local HTTP for development), -then constructs a fixed client-web path and displays the destination host. A +then constructs a fixed Web app path and displays the destination host. A direct Registry visit defaults to `https://app.inkcre.dev`. The return query -contains the Extension name, distribution and exact version; client-web reads the +contains the Extension name, distribution and exact version; Web app reads the Release anew from its own configured Registry and requires confirmation. +The deprecated `client_origin` query remains an input alias for older Apps and +bookmarks. Both names pass the same origin validation; when both are supplied, +the normalized origins must match or the request fails with `400`. The Registry +emits only `app_origin` in new navigation links and forms. During mixed deployment, +Web Apps may send both names with the same value so an older Registry still +returns to the chosen App. This alias carries no credentials or Peer identity. + The UI does not invent descriptions, popularity, trust badges, compatibility verdicts, installation state, or download counts that Registry does not own. Package inspection, copying an ID, and opening the install link do not install @@ -87,9 +94,9 @@ Remote previews run the same CPython image with an isolated PostgreSQL branch an resource lifecycle and source identity belong to the delivery controller; see [Pull-Request Previews](../40-deployment/pull-request-previews.md). -Registry follows the client-web product surface: the 32px geometric InKCre logo, +Registry follows the Web app product surface: the 32px geometric InKCre logo, InkHeader spacing and typography, square InkButton-style controls, bordered extension rows, and compact metadata. `templates/brand.html` contains the SVG -from client-web's `apps/client-web/public/logo/32.svg`. Page content consists of +from Web app's `apps/web/public/logo/32.svg`. Page content consists of catalog, release metadata, and publishing controls; it has no marketing hero, illustration, promotional footer, or persistent tutorial panels. diff --git a/docs/30-unit-tdd/client-web-runtime.md b/docs/30-unit-tdd/web-runtime.md similarity index 65% rename from docs/30-unit-tdd/client-web-runtime.md rename to docs/30-unit-tdd/web-runtime.md index c340f79..a46eb55 100644 --- a/docs/30-unit-tdd/client-web-runtime.md +++ b/docs/30-unit-tdd/web-runtime.md @@ -1,6 +1,6 @@ -# Client Web Extension Runtime +# Web Extension Runtime -`@inkcre/extension-runtime-client-web` 是独立发行的浏览器 Runtime。Host SDK `@inkcre/core` 拥有部署持久化模型、Peer 发现、传输和错误分类;Runtime 拥有 Extension 生命周期编排、管理命令消费和 Registry 发行读取。应用继续决定操作当前浏览器 Runtime、在线远端 Host,还是只改变部署中的 desired state。 +`@inkcre/extension-runtime-web` 是独立发行的浏览器 Runtime。Host SDK `@inkcre/core` 拥有部署持久化模型、Peer 发现、传输和错误分类;Runtime 拥有 Extension 生命周期编排、管理命令消费和 Registry 发行读取。应用继续决定操作当前浏览器 Runtime、在线远端 Host,还是只改变部署中的 desired state。 `listAdvertisedExtensionManagementPeers()` 读取 `PeerManager.listLive()`,只保留宣告精确管理 capability 的 Peer。宣告不是协议支持、路由就绪或运行证明。`manageExtensionOnPeer(peerId, command)` 使用调用者指定的精确 Peer 和固定 capability,发送一次 select、enable、disable 或 patch_config 命令。它不替换目标、不重试、不改写 PeerManager 的传输失败分类;管理 HTTP 错误及无效业务响应不附带可能回显配置凭据的原始正文或校验详情。返回的运行投影区分持久化选择与实际加载结果。 @@ -10,7 +10,7 @@ Runtime 的 Core peer dependency 以实际类型与构建验证为准,不使用 ambient SDK stub。新公共 API 通过 Changesets 声明 minor 发行意图,源包版本由正式版本流程修改。 -Core SDK 开发依赖固定官方 `core-v0.4.2` GitHub Release 的预构建 tgz,冻结锁文件验证下载完整性。该产物同时包含 ESM 和类型声明,type-check 与 build 直接消费它,不检出 client-web 源码、不安装生产者 workspace,也不需要私有 UI 包凭据。仓库门禁通过真实 SDK 和本地 HTTP 运行 `check-boundaries.mjs`;正式 Runtime 包由本仓独立版本流程发布,Core 的 peer dependency 要求至少 0.4.2,以支持宿主声明的开放分发标识。 +Core SDK 开发依赖固定官方 `core-v0.4.2` GitHub Release 的预构建 tgz,冻结锁文件验证下载完整性。该产物同时包含 ESM 和类型声明,type-check 与 build 直接消费它,不检出 Web app 源码、不安装生产者 workspace,也不需要私有 UI 包凭据。仓库门禁通过真实 SDK 和本地 HTTP 运行 `check-boundaries.mjs`;正式 Runtime 包由本仓独立版本流程发布,Core 的 peer dependency 要求至少 0.4.2,以支持宿主声明的开放分发标识。 Runtime 使用 Registry v2 原生坐标查询 MF,公开 catalog 可明确选择 distribution;返回坐标和唯一原生关联均须匹配。安装将共享 Extension 身份与当前 Peer 的精确参与选择分别保存,enable/startup 读取当前 Peer 选择,不追随 latest,不修改其他 Peer 或清理业务 state。旧未知分发仅用当前浏览器支持的 MF 查询同一精确版本,缺失时失败而不替换版本。 @@ -18,4 +18,17 @@ Runtime 使用 Registry v2 原生坐标查询 MF,公开 catalog 可明确选 显式 enable/disable 先按同一 Host、同一 Extension 的命令顺序保存 enabled 意图,再串行执行模块生命周期。disable 在等待在途启动之前保存 false,并在资源清理完成后返回。startup 只恢复已有意图,成功或失败都不反写 enabled;初始化失败保留意图及错误,允许后续恢复重试。 -恢复在加载前及异步 initialize/activate 后重新读取精确参与选择。若 enabled 被撤回、分发或版本改变,迟到的模块会执行 dispose,不能登记为 running。shutdown 等待在途恢复与命令完成并清理模块。同 Host 的串行队列不锁住其他已准入客户端对共享数据库的写入,因此离线意图更新不等于瞬时、原子的进程切换;这些客户端的修改通过重新读取被识别。 +恢复在加载前及异步 initialize/activate 后重新读取精确参与选择。若 enabled 被撤回、分发或版本改变,迟到的模块会执行 dispose,不能登记为 running。shutdown 等待在途恢复与命令完成并清理模块。同 Host 的串行队列不锁住其他已准入 Peer对共享数据库的写入,因此离线意图更新不等于瞬时、原子的进程切换;这些 Peer 的修改通过重新读取被识别。 + +## 名称迁移与交付 + +源码目录为 `runtimes/web`,包名为 `@inkcre/extension-runtime-web`。正式发布使用 +`runtime-web-v` 标签与 `inkcre-extension-runtime-web-.tgz`,Changeset +由 Version PR 消费后才发布;本次重命名不改变 Runtime 导出 API、Host SDK 要求或 +`module_federation` Distribution 标识。 + +已发布的 `@inkcre/extension-runtime-client-web` 包、`runtime-client-web-v0.4.2` +标签与对应 TGZ 保持不可变。新名称包发布前,消费者可把新的 dependency/import key +指向该精确旧 TGZ,锁定其完整性;这只是安装别名,不能描述为新包已经发布。新名称正式产物 +可用后,消费者再替换依赖来源。旧 Host 和 Extension 继续消费已有产物,不要求同时升级。 +Registry 的 `app_origin` 交接及旧参数兼容由 [Registry Web](registry-web.md) 拥有。 diff --git a/docs/40-deployment/README.md b/docs/40-deployment/README.md index 9256b53..2ab9a80 100644 --- a/docs/40-deployment/README.md +++ b/docs/40-deployment/README.md @@ -9,7 +9,7 @@ documents own the operational intent, safety boundaries, failure behavior, and recovery facts that those files cannot express clearly enough. Python release intent belongs to the Registry, Toolkit or Core Runtime -`.changes/` directory and is prepared with Towncrier. Client Web Runtime release +`.changes/` directory and is prepared with Towncrier. Web Runtime release intent belongs to `.changeset/` and is prepared with Changesets. Generated Version PRs run the same required repository check through an explicit workflow dispatch; package publication waits for the prepared version on protected diff --git a/docs/_shared b/docs/_shared index 311c69b..17fc19e 160000 --- a/docs/_shared +++ b/docs/_shared @@ -1 +1 @@ -Subproject commit 311c69bdada4fb291cc7fae0ded5caefa4fdc867 +Subproject commit 17fc19e7230187a7a989815e7b8303bbb380f478 diff --git a/package.json b/package.json index d755791..be7aef1 100644 --- a/package.json +++ b/package.json @@ -7,19 +7,19 @@ "node": "22.x" }, "scripts": { - "build": "SOURCE_DATE_EPOCH=315532800 pdm build --no-sdist --dest \"$INIT_CWD/dist\" && SOURCE_DATE_EPOCH=315532800 pdm build --project toolkit --no-sdist --no-clean --dest \"$INIT_CWD/dist\" && SOURCE_DATE_EPOCH=315532800 pdm build --project runtimes/core-py --no-sdist --no-clean --dest \"$INIT_CWD/dist\" && pnpm --filter @inkcre/extension-runtime-client-web build", + "build": "SOURCE_DATE_EPOCH=315532800 pdm build --no-sdist --dest \"$INIT_CWD/dist\" && SOURCE_DATE_EPOCH=315532800 pdm build --project toolkit --no-sdist --no-clean --dest \"$INIT_CWD/dist\" && SOURCE_DATE_EPOCH=315532800 pdm build --project runtimes/core-py --no-sdist --no-clean --dest \"$INIT_CWD/dist\" && pnpm --filter @inkcre/extension-runtime-web build", "changeset": "changeset", - "check": "pnpm release:check && pnpm web:check && pnpm contracts:check && pnpm format:check && pnpm lint && pnpm type-check && pnpm build && pnpm --filter @inkcre/extension-runtime-client-web exec node check-boundaries.mjs && pnpm packages:check && pnpm registry:check", + "check": "pnpm release:check && pnpm web:check && pnpm contracts:check && pnpm format:check && pnpm lint && pnpm type-check && pnpm build && pnpm --filter @inkcre/extension-runtime-web exec node check-boundaries.mjs && pnpm packages:check && pnpm registry:check", "packages:check": "pdm run python scripts/check_packages.py", - "contracts:check": "pdm run python scripts/generate_contracts.py --check && pdm run python runtimes/core-py/scripts/generate_contracts.py --check && pnpm --filter @inkcre/extension-runtime-client-web check:bindings", - "contracts:generate": "pdm run python scripts/generate_contracts.py && pdm run python runtimes/core-py/scripts/generate_contracts.py && pnpm --filter @inkcre/extension-runtime-client-web generate:bindings", + "contracts:check": "pdm run python scripts/generate_contracts.py --check && pdm run python runtimes/core-py/scripts/generate_contracts.py --check && pnpm --filter @inkcre/extension-runtime-web check:bindings", + "contracts:generate": "pdm run python scripts/generate_contracts.py && pdm run python runtimes/core-py/scripts/generate_contracts.py && pnpm --filter @inkcre/extension-runtime-web generate:bindings", "format": "pdm run ruff format . && prettier --write .", "format:check": "pdm run ruff format --check . && prettier --check .", "lint": "pdm run ruff check .", "registry:check": "pdm run python scripts/check_registry.py", "release:check": "pdm run check:releases ${RELEASE_CHECK_ARGS:-} && node scripts/check_changesets.mjs", "release:version": "changeset version", - "type-check": "pdm run pyright && pnpm --filter @inkcre/extension-runtime-client-web type-check", + "type-check": "pdm run pyright && pnpm --filter @inkcre/extension-runtime-web type-check", "web:build": "sass --pkg-importer=node --no-source-map --style=compressed web/registry.scss src/inkcre_extension_registry/service/static/registry.css", "web:check": "node --check src/inkcre_extension_registry/service/static/registry.js && node scripts/check-web-styles.mjs", "db:migrate": "pdm run tortoise -c inkcre_extension_registry.migration_config.TORTOISE_ORM upgrade", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1c92903..2cb51ea 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -36,14 +36,14 @@ importers: specifier: 4.120.0 version: 4.120.0 - runtimes/client-web: + runtimes/web: dependencies: semver: specifier: 7.8.5 version: 7.8.5 zod: - specifier: 4.1.12 - version: 4.1.12 + specifier: 4.6.6 + version: 4.6.6 devDependencies: '@inkcre/core': specifier: https://github.com/InKCre/impl-ts/releases/download/core-v0.4.2/inkcre-core-0.4.2.tgz @@ -1744,8 +1744,8 @@ packages: yaml: optional: true - zod@4.1.12: - resolution: {integrity: sha512-JInaHOamG8pt5+Ey8kGmdcAcg3OL9reK8ltczgHTAwNhMys/6ThXHityHxVV2p3fkw/c+MAvBHFVYHFZDmjMCQ==} + zod@4.6.6: + resolution: {integrity: sha512-4UmzQUF5fxvfcYHlbjBmejU+w+hbDnWFx4aS8kBx7nPBHcO2SqPbpAG8snbdg+Xse4pRefR98hgjFgIMCI/UhA==} snapshots: @@ -2162,9 +2162,9 @@ snapshots: pinia: 3.0.3(typescript@5.9.3)(vue@3.5.18(typescript@5.9.3)) semver: 7.8.5 vue: 3.5.18(typescript@5.9.3) - zod: 4.1.12 - zod-class: 0.0.18(zod@4.1.12) - zod-config: 1.4.0(dotenv@17.4.2)(yaml@2.9.0)(zod@4.1.12) + zod: 4.6.6 + zod-class: 0.0.18(zod@4.6.6) + zod-config: 1.4.0(dotenv@17.4.2)(yaml@2.9.0)(zod@4.6.6) transitivePeerDependencies: - dotenv - json5 @@ -3184,16 +3184,16 @@ snapshots: '@yuku-parser/binding-win32-arm64': 0.8.7 '@yuku-parser/binding-win32-x64': 0.8.7 - zod-class@0.0.18(zod@4.1.12): + zod-class@0.0.18(zod@4.6.6): dependencies: type-fest: 4.41.0 - zod: 4.1.12 + zod: 4.6.6 - zod-config@1.4.0(dotenv@17.4.2)(yaml@2.9.0)(zod@4.1.12): + zod-config@1.4.0(dotenv@17.4.2)(yaml@2.9.0)(zod@4.6.6): dependencies: - zod: 4.1.12 + zod: 4.6.6 optionalDependencies: dotenv: 17.4.2 yaml: 2.9.0 - zod@4.1.12: {} + zod@4.6.6: {} diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index c14e55d..a278f82 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -1,5 +1,5 @@ packages: - - runtimes/client-web + - runtimes/web autoInstallPeers: false diff --git a/runtimes/client-web/CHANGELOG.md b/runtimes/web/CHANGELOG.md similarity index 96% rename from runtimes/client-web/CHANGELOG.md rename to runtimes/web/CHANGELOG.md index 1679961..3b8a8fb 100644 --- a/runtimes/client-web/CHANGELOG.md +++ b/runtimes/web/CHANGELOG.md @@ -1,4 +1,4 @@ -# @inkcre/extension-runtime-client-web +# @inkcre/extension-runtime-web ## 0.4.2 diff --git a/runtimes/client-web/check-boundaries.mjs b/runtimes/web/check-boundaries.mjs similarity index 100% rename from runtimes/client-web/check-boundaries.mjs rename to runtimes/web/check-boundaries.mjs diff --git a/runtimes/client-web/openapi-ts.config.ts b/runtimes/web/openapi-ts.config.ts similarity index 100% rename from runtimes/client-web/openapi-ts.config.ts rename to runtimes/web/openapi-ts.config.ts diff --git a/runtimes/client-web/package.json b/runtimes/web/package.json similarity index 90% rename from runtimes/client-web/package.json rename to runtimes/web/package.json index 83b0a1a..56278db 100644 --- a/runtimes/client-web/package.json +++ b/runtimes/web/package.json @@ -1,7 +1,7 @@ { - "name": "@inkcre/extension-runtime-client-web", + "name": "@inkcre/extension-runtime-web", "version": "0.4.2", - "description": "InKCre Client Web Extension Host Runtime", + "description": "InKCre Web Extension Host Runtime", "type": "module", "files": [ "dist", @@ -27,7 +27,7 @@ }, "dependencies": { "semver": "7.8.5", - "zod": "4.1.12" + "zod": "4.6.6" }, "peerDependencies": { "@inkcre/core": ">=0.4.2 <0.5.0", diff --git a/runtimes/client-web/src/documentation.ts b/runtimes/web/src/documentation.ts similarity index 100% rename from runtimes/client-web/src/documentation.ts rename to runtimes/web/src/documentation.ts diff --git a/runtimes/client-web/src/errors.ts b/runtimes/web/src/errors.ts similarity index 100% rename from runtimes/client-web/src/errors.ts rename to runtimes/web/src/errors.ts diff --git a/runtimes/client-web/src/generated/client.gen.ts b/runtimes/web/src/generated/client.gen.ts similarity index 100% rename from runtimes/client-web/src/generated/client.gen.ts rename to runtimes/web/src/generated/client.gen.ts diff --git a/runtimes/client-web/src/generated/client/client.gen.ts b/runtimes/web/src/generated/client/client.gen.ts similarity index 100% rename from runtimes/client-web/src/generated/client/client.gen.ts rename to runtimes/web/src/generated/client/client.gen.ts diff --git a/runtimes/client-web/src/generated/client/index.ts b/runtimes/web/src/generated/client/index.ts similarity index 100% rename from runtimes/client-web/src/generated/client/index.ts rename to runtimes/web/src/generated/client/index.ts diff --git a/runtimes/client-web/src/generated/client/types.gen.ts b/runtimes/web/src/generated/client/types.gen.ts similarity index 100% rename from runtimes/client-web/src/generated/client/types.gen.ts rename to runtimes/web/src/generated/client/types.gen.ts diff --git a/runtimes/client-web/src/generated/client/utils.gen.ts b/runtimes/web/src/generated/client/utils.gen.ts similarity index 100% rename from runtimes/client-web/src/generated/client/utils.gen.ts rename to runtimes/web/src/generated/client/utils.gen.ts diff --git a/runtimes/client-web/src/generated/core/auth.gen.ts b/runtimes/web/src/generated/core/auth.gen.ts similarity index 100% rename from runtimes/client-web/src/generated/core/auth.gen.ts rename to runtimes/web/src/generated/core/auth.gen.ts diff --git a/runtimes/client-web/src/generated/core/bodySerializer.gen.ts b/runtimes/web/src/generated/core/bodySerializer.gen.ts similarity index 100% rename from runtimes/client-web/src/generated/core/bodySerializer.gen.ts rename to runtimes/web/src/generated/core/bodySerializer.gen.ts diff --git a/runtimes/client-web/src/generated/core/params.gen.ts b/runtimes/web/src/generated/core/params.gen.ts similarity index 100% rename from runtimes/client-web/src/generated/core/params.gen.ts rename to runtimes/web/src/generated/core/params.gen.ts diff --git a/runtimes/client-web/src/generated/core/pathSerializer.gen.ts b/runtimes/web/src/generated/core/pathSerializer.gen.ts similarity index 100% rename from runtimes/client-web/src/generated/core/pathSerializer.gen.ts rename to runtimes/web/src/generated/core/pathSerializer.gen.ts diff --git a/runtimes/client-web/src/generated/core/queryKeySerializer.gen.ts b/runtimes/web/src/generated/core/queryKeySerializer.gen.ts similarity index 100% rename from runtimes/client-web/src/generated/core/queryKeySerializer.gen.ts rename to runtimes/web/src/generated/core/queryKeySerializer.gen.ts diff --git a/runtimes/client-web/src/generated/core/serverSentEvents.gen.ts b/runtimes/web/src/generated/core/serverSentEvents.gen.ts similarity index 100% rename from runtimes/client-web/src/generated/core/serverSentEvents.gen.ts rename to runtimes/web/src/generated/core/serverSentEvents.gen.ts diff --git a/runtimes/client-web/src/generated/core/types.gen.ts b/runtimes/web/src/generated/core/types.gen.ts similarity index 100% rename from runtimes/client-web/src/generated/core/types.gen.ts rename to runtimes/web/src/generated/core/types.gen.ts diff --git a/runtimes/client-web/src/generated/core/utils.gen.ts b/runtimes/web/src/generated/core/utils.gen.ts similarity index 100% rename from runtimes/client-web/src/generated/core/utils.gen.ts rename to runtimes/web/src/generated/core/utils.gen.ts diff --git a/runtimes/client-web/src/generated/index.ts b/runtimes/web/src/generated/index.ts similarity index 100% rename from runtimes/client-web/src/generated/index.ts rename to runtimes/web/src/generated/index.ts diff --git a/runtimes/client-web/src/generated/sdk.gen.ts b/runtimes/web/src/generated/sdk.gen.ts similarity index 100% rename from runtimes/client-web/src/generated/sdk.gen.ts rename to runtimes/web/src/generated/sdk.gen.ts diff --git a/runtimes/client-web/src/generated/types.gen.ts b/runtimes/web/src/generated/types.gen.ts similarity index 100% rename from runtimes/client-web/src/generated/types.gen.ts rename to runtimes/web/src/generated/types.gen.ts diff --git a/runtimes/client-web/src/generated/zod.gen.ts b/runtimes/web/src/generated/zod.gen.ts similarity index 100% rename from runtimes/client-web/src/generated/zod.gen.ts rename to runtimes/web/src/generated/zod.gen.ts diff --git a/runtimes/client-web/src/index.ts b/runtimes/web/src/index.ts similarity index 100% rename from runtimes/client-web/src/index.ts rename to runtimes/web/src/index.ts diff --git a/runtimes/client-web/src/manager.ts b/runtimes/web/src/manager.ts similarity index 99% rename from runtimes/client-web/src/manager.ts rename to runtimes/web/src/manager.ts index 0baeaaf..6db5f84 100644 --- a/runtimes/client-web/src/manager.ts +++ b/runtimes/web/src/manager.ts @@ -312,7 +312,7 @@ export class ExtensionManager return current } await handle.activate() - // Other admitted clients may change a sleeping Peer directly in the shared store. + // Other admitted Peers may change a sleeping Peer directly in the shared store. // A local queue does not claim ownership of their durable intent. current = await ExtensionParticipationModel.get(peerId, name) if (!this.#matches(current, selected)) { diff --git a/runtimes/client-web/src/module.ts b/runtimes/web/src/module.ts similarity index 100% rename from runtimes/client-web/src/module.ts rename to runtimes/web/src/module.ts diff --git a/runtimes/client-web/src/peer-management.ts b/runtimes/web/src/peer-management.ts similarity index 100% rename from runtimes/client-web/src/peer-management.ts rename to runtimes/web/src/peer-management.ts diff --git a/runtimes/client-web/src/registry.ts b/runtimes/web/src/registry.ts similarity index 100% rename from runtimes/client-web/src/registry.ts rename to runtimes/web/src/registry.ts diff --git a/runtimes/client-web/tsconfig.json b/runtimes/web/tsconfig.json similarity index 100% rename from runtimes/client-web/tsconfig.json rename to runtimes/web/tsconfig.json diff --git a/runtimes/client-web/tsdown.config.mjs b/runtimes/web/tsdown.config.mjs similarity index 100% rename from runtimes/client-web/tsdown.config.mjs rename to runtimes/web/tsdown.config.mjs diff --git a/scripts/check_changesets.mjs b/scripts/check_changesets.mjs index c109260..82c192e 100644 --- a/scripts/check_changesets.mjs +++ b/scripts/check_changesets.mjs @@ -9,7 +9,7 @@ const files = (await readdir(directory)).filter( for (const file of files) { const changeset = parse(await readFile(new URL(file, directory), 'utf8')) for (const release of changeset.releases) { - if (release.name !== '@inkcre/extension-runtime-client-web') { + if (release.name !== '@inkcre/extension-runtime-web') { throw new Error(`${file}: Changesets cannot release Python package ${release.name}`) } } diff --git a/scripts/check_packages.py b/scripts/check_packages.py index 1d626b3..31d1799 100644 --- a/scripts/check_packages.py +++ b/scripts/check_packages.py @@ -16,7 +16,8 @@ import zipfile from pathlib import Path from types import SimpleNamespace -from unittest.mock import Mock, patch +from unittest.mock import AsyncMock, Mock, patch +from urllib.parse import quote from inkcre_extension_toolkit.preview import build_preview_registry from packaging.requirements import Requirement @@ -24,6 +25,105 @@ ROOT = Path(__file__).resolve().parents[1] +def check_web_app_handoff() -> None: + """Exercise the HTTP naming boundary with a controlled repository, without persistence.""" + from fastapi.testclient import TestClient + + from inkcre_extension_registry.contracts.models import ( + ExtensionSummary, + ModuleFederationDistribution, + NativeExtensionRecord, + NativeReleaseRecord, + ) + from inkcre_extension_registry.service.app import create_app + + release = NativeReleaseRecord( + name="check/example", + nickname="Example", + version="1.0.0", + state="published", + distribution="module_federation", + module_federation=ModuleFederationDistribution( + manifest_url="https://registry.invalid/mf-manifest.json", + host_sdk="@inkcre/core", + host_sdk_version=">=0.4.2 <0.5.0", + ), + ) + app = create_app() + app.state.repository = SimpleNamespace( + list_native_extensions=AsyncMock( + return_value=[ExtensionSummary(name=release.name, nickname=release.nickname)] + ), + get_native_extension=AsyncMock( + return_value=NativeExtensionRecord( + name=release.name, nickname=release.nickname, releases=(release,) + ) + ), + ) + app.state.settings = SimpleNamespace(documentation_origin_template=None) + # Deliberately omit lifespan: these routes consume only the controlled repository above. + browser = TestClient(app) + try: + for path in ("/", "/explore/check/example"): + for query, expected_origin in ( + ({"app_origin": "https://app.example"}, "https://app.example"), + ({"client_origin": "https://app.example/"}, "https://app.example"), + ( + {"app_origin": "https://app.example", "client_origin": "https://app.example/"}, + "https://app.example", + ), + ( + { + "app_origin": "https://APP.example:443", + "client_origin": "https://app.example/", + }, + "https://app.example", + ), + ( + {"app_origin": "http://LOCALHOST:80", "client_origin": "http://localhost/"}, + "http://localhost", + ), + ( + {"app_origin": "https://[::1]:443", "client_origin": "https://[::1]/"}, + "https://[::1]", + ), + ({"app_origin": "http://[::1]:5173"}, "http://[::1]:5173"), + ): + response = browser.get(path, params=query) + assert response.status_code == 200, response.text + assert "client_origin" not in response.text + assert f"app_origin={quote(expected_origin)}" in response.text + if path != "/": + assert ( + f'href="{expected_origin}/extensions?install=check%2Fexample' + in response.text + ) + assert browser.get(path).status_code == 200 + assert ( + browser.get( + path, + params={ + "app_origin": "https://one.example", + "client_origin": "https://two.example", + }, + ).status_code + == 400 + ) + for parameter in ("app_origin", "client_origin"): + for invalid in ( + "", + "http://public.example", + "https://app.example/path", + "javascript:bad", + ): + assert browser.get(path, params={parameter: invalid}).status_code == 400 + assert browser.get(path, params={parameter: "x" * 513}).status_code == 422 + assert "https://app.inkcre.dev/extensions?" in browser.get("/explore/check/example").text + finally: + browser.close() + print("Web App handoff preserves legacy origins, canonical links and conflict rejection.") + + def check_production_delivery_boundary() -> None: from contextlib import redirect_stdout @@ -520,6 +620,7 @@ def check(*arguments): def main() -> None: + check_web_app_handoff() check_production_delivery_boundary() check_coordinated_version_preparation() check_native_runtime_boundary() diff --git a/src/inkcre_extension_registry/service/app.py b/src/inkcre_extension_registry/service/app.py index 09b2dfd..065e404 100644 --- a/src/inkcre_extension_registry/service/app.py +++ b/src/inkcre_extension_registry/service/app.py @@ -81,7 +81,7 @@ ) from .storage import ArtifactStore from .ui import ( - DEFAULT_CLIENT_WEB_ORIGIN, + DEFAULT_WEB_APP_ORIGIN, SCRIPT, extension_catalog_html, extension_detail_html, @@ -99,22 +99,30 @@ ) -def _client_web_origin(value: str | None) -> str: +def _web_app_origin(value: str | None, legacy_origin: str | None = None) -> str: + # Older Web Apps use client_origin. Normalize before comparing either spelling. + if legacy_origin is not None: + legacy_origin = _web_app_origin(legacy_origin) + if value is None: + return legacy_origin + if _web_app_origin(value) != legacy_origin: + raise HTTPException(400, "app_origin and legacy client_origin must agree") if value is None: - return DEFAULT_CLIENT_WEB_ORIGIN + return DEFAULT_WEB_APP_ORIGIN if ( not value or any(character.isspace() for character in value) or any(character in value for character in ("\\", "%")) ): - raise HTTPException(400, "client_origin must be a Web origin") + raise HTTPException(400, "app_origin must be a Web origin") try: parsed = urlparse(value) hostname = parsed.hostname - if parsed.port == 0: + port = parsed.port + if port == 0: raise ValueError("invalid port") except ValueError as error: - raise HTTPException(400, "client_origin must be a Web origin") from error + raise HTTPException(400, "app_origin must be a Web origin") from error local_http = parsed.scheme == "http" and hostname in {"localhost", "127.0.0.1", "::1"} if ( not (parsed.scheme == "https" or local_http) @@ -126,8 +134,12 @@ def _client_web_origin(value: str | None) -> str: or parsed.query or parsed.fragment ): - raise HTTPException(400, "client_origin must be a Web origin") - return f"{parsed.scheme}://{parsed.netloc}" + raise HTTPException(400, "app_origin must be a Web origin") + host = f"[{hostname}]" if ":" in hostname else hostname + authority = ( + host if port in {None, 443 if parsed.scheme == "https" else 80} else f"{host}:{port}" + ) + return f"{parsed.scheme}://{authority}" DOCUMENTATION_ERRORS = { @@ -738,16 +750,17 @@ async def extension_catalog( request: Request, q: Annotated[str, Query(max_length=200)] = "", publisher: Annotated[str, Query(max_length=64)] = "", - client_origin: Annotated[str | None, Query(max_length=512)] = None, + app_origin: Annotated[str | None, Query(max_length=512)] = None, + client_origin: Annotated[str | None, Query(max_length=512, deprecated=True)] = None, ) -> HTMLResponse: - web_origin = _client_web_origin(client_origin) + web_origin = _web_app_origin(app_origin, client_origin) extensions = await _repository(request).list_native_extensions() return html_response( extension_catalog_html( extensions, query=q.strip(), namespace=publisher, - client_origin=web_origin, + app_origin=web_origin, ) ) @@ -769,9 +782,10 @@ async def extension_detail( request: Request, distribution: NativeDistribution | None = None, version: Annotated[str | None, Query(max_length=128)] = None, - client_origin: Annotated[str | None, Query(max_length=512)] = None, + app_origin: Annotated[str | None, Query(max_length=512)] = None, + client_origin: Annotated[str | None, Query(max_length=512, deprecated=True)] = None, ) -> HTMLResponse: - web_origin = _client_web_origin(client_origin) + web_origin = _web_app_origin(app_origin, client_origin) extension_name = _validate_identity(namespace, name) selected_distribution = distribution or "module_federation" extension = await _repository(request).get_native_extension( @@ -797,7 +811,7 @@ async def extension_detail( extension, version, hosted, - client_origin=web_origin, + app_origin=web_origin, distribution=selected_distribution, ) if extension diff --git a/src/inkcre_extension_registry/service/templates/base.html b/src/inkcre_extension_registry/service/templates/base.html index 9444f9c..0e14397 100644 --- a/src/inkcre_extension_registry/service/templates/base.html +++ b/src/inkcre_extension_registry/service/templates/base.html @@ -14,12 +14,12 @@