From 5b9f22e9cff2f3c7d11e4bb827a672595894ed5f Mon Sep 17 00:00:00 2001 From: pgherveou Date: Wed, 15 Jul 2026 09:44:45 +0200 Subject: [PATCH 01/17] refactor(host): adopt Rust TrUAPI runtime Replace the Nova host-container, auth, and signing path with the worker-backed Rust core. Keep dotli responsible only for browser policy, persistence, UI, and physical chain transports. --- .env.example | 4 - MIGRATION.md | 101 ++ README.md | 14 +- THIRD_PARTY_NOTICES.md | 6 +- apps/host/src/main.ts | 138 +- apps/host/tests/e2e/fixtures/paired.ts | 6 +- apps/host/tests/e2e/global-setup.ts | 7 +- apps/host/tests/e2e/helpers/signing.ts | 46 +- apps/host/tests/e2e/truapi.spec.ts | 85 +- .../tests/functional/auth-subscribe.spec.ts | 87 - apps/host/vite.config.ts | 97 +- apps/protocol/src/main.ts | 18 - bun.lock | 103 +- docs/smoldot.md | 39 +- packages/auth/eslint.config.js | 15 - packages/auth/package.json | 42 - packages/auth/src/account.ts | 103 -- packages/auth/src/auth.ts | 565 ------ packages/auth/src/shared-storage.ts | 123 -- packages/auth/src/signing.ts | 660 ------- packages/auth/tests/account.test.ts | 91 - packages/auth/tests/shared-storage.test.ts | 163 -- packages/auth/tsconfig.json | 7 - packages/auth/vitest.config.ts | 28 - packages/config/src/config.ts | 3 - packages/config/src/network.ts | 21 +- packages/config/tests/gateway-chains.test.ts | 10 +- packages/protocol/src/auth-storage.ts | 21 +- packages/protocol/src/client.ts | 15 +- packages/protocol/src/messages.ts | 1 - packages/protocol/tests/auth-storage.test.ts | 20 +- packages/resolver/package.json | 3 - packages/resolver/src/rpc-chain.ts | 41 +- packages/resolver/tests/chains.test.ts | 15 + packages/resolver/tests/rpc-chain.test.ts | 48 + .../storage/src/scheduled-notifications.ts | 2 +- packages/truapi-debug/DEBUG_PANEL.md | 94 +- packages/truapi-debug/package.json | 4 +- packages/truapi-debug/src/chain-decode.ts | 45 +- packages/truapi-debug/src/chain-summary.ts | 8 +- packages/truapi-debug/src/dotli-debug-bus.ts | 21 +- .../truapi-debug/src/dotli-debug-types.ts | 15 +- packages/truapi-debug/src/event-store.ts | 53 +- packages/truapi-debug/src/index.ts | 5 +- packages/truapi-debug/src/panel.ts | 35 +- .../truapi-debug/src/system-explanations.ts | 184 +- packages/truapi-debug/src/system-summary.ts | 50 - packages/truapi-debug/src/timeline-layout.ts | 34 +- packages/typescript-config/paths.json | 1 - packages/ui/package.json | 13 +- packages/ui/src/allocation-modal.ts | 341 ---- packages/ui/src/bridge.ts | 1034 +++++++++-- packages/ui/src/container.ts | 1584 ----------------- packages/ui/src/host-callbacks/AuthState.ts | 72 + packages/ui/src/host-callbacks/Chain.ts | 130 ++ .../ui/src/host-callbacks/FeatureSupported.ts | 14 + .../ui/src/host-callbacks/LocalStorage.ts | 59 + packages/ui/src/host-callbacks/OpenUrl.ts | 53 + packages/ui/src/host-callbacks/Preimage.ts | 107 ++ .../ui/src/host-callbacks/PromptPermission.ts | 127 ++ .../ui/src/host-callbacks/PushNotification.ts | 60 + .../ui/src/host-callbacks/SessionStore.ts | 251 +++ packages/ui/src/host-callbacks/Theme.ts | 22 + .../ui/src/host-callbacks/UserConfirmation.ts | 394 ++++ packages/ui/src/host-callbacks/handlers.ts | 60 + packages/ui/src/host-callbacks/rate-limit.ts | 21 + .../ui/src/host-callbacks/result-stream.ts | 92 + packages/ui/src/legacy-host-bridge.ts | 67 + packages/ui/src/login-request-error.ts | 35 + packages/ui/src/permission-modal.ts | 35 +- packages/ui/src/permissions.ts | 178 +- packages/ui/src/preimage-submit.ts | 116 -- packages/ui/src/runtime-config.ts | 53 + packages/ui/src/scheduled-notifications.ts | 9 +- packages/ui/src/statement-store-mapping.ts | 177 -- packages/ui/src/styles/signing.css | 132 -- packages/ui/src/styles/themes.css | 42 - packages/ui/src/topbar.ts | 480 ++--- packages/ui/src/wallet-queue.ts | 31 - packages/ui/tests/allocation-modal.test.ts | 181 -- packages/ui/tests/bridge.test.ts | 408 +++++ packages/ui/tests/chain-callback.test.ts | 139 ++ packages/ui/tests/local-storage.test.ts | 76 + packages/ui/tests/notification.test.ts | 169 ++ packages/ui/tests/nova-removal.test.ts | 70 + packages/ui/tests/permission-modal.test.ts | 32 + packages/ui/tests/permissions.test.ts | 239 ++- packages/ui/tests/preimage.test.ts | 74 + packages/ui/tests/runtime-config.test.ts | 59 + packages/ui/tests/session-store.test.ts | 314 ++++ packages/ui/tests/theme.test.ts | 45 + packages/ui/tests/topbar.test.ts | 439 +++++ packages/ui/tests/user-confirmation.test.ts | 252 +++ packages/ui/tests/wallet-queue.test.ts | 111 -- 94 files changed, 5734 insertions(+), 5960 deletions(-) create mode 100644 MIGRATION.md delete mode 100644 apps/host/tests/functional/auth-subscribe.spec.ts delete mode 100644 packages/auth/eslint.config.js delete mode 100644 packages/auth/package.json delete mode 100644 packages/auth/src/account.ts delete mode 100644 packages/auth/src/auth.ts delete mode 100644 packages/auth/src/shared-storage.ts delete mode 100644 packages/auth/src/signing.ts delete mode 100644 packages/auth/tests/account.test.ts delete mode 100644 packages/auth/tests/shared-storage.test.ts delete mode 100644 packages/auth/tsconfig.json delete mode 100644 packages/auth/vitest.config.ts create mode 100644 packages/resolver/tests/chains.test.ts create mode 100644 packages/resolver/tests/rpc-chain.test.ts delete mode 100644 packages/ui/src/allocation-modal.ts delete mode 100644 packages/ui/src/container.ts create mode 100644 packages/ui/src/host-callbacks/AuthState.ts create mode 100644 packages/ui/src/host-callbacks/Chain.ts create mode 100644 packages/ui/src/host-callbacks/FeatureSupported.ts create mode 100644 packages/ui/src/host-callbacks/LocalStorage.ts create mode 100644 packages/ui/src/host-callbacks/OpenUrl.ts create mode 100644 packages/ui/src/host-callbacks/Preimage.ts create mode 100644 packages/ui/src/host-callbacks/PromptPermission.ts create mode 100644 packages/ui/src/host-callbacks/PushNotification.ts create mode 100644 packages/ui/src/host-callbacks/SessionStore.ts create mode 100644 packages/ui/src/host-callbacks/Theme.ts create mode 100644 packages/ui/src/host-callbacks/UserConfirmation.ts create mode 100644 packages/ui/src/host-callbacks/handlers.ts create mode 100644 packages/ui/src/host-callbacks/rate-limit.ts create mode 100644 packages/ui/src/host-callbacks/result-stream.ts create mode 100644 packages/ui/src/legacy-host-bridge.ts create mode 100644 packages/ui/src/login-request-error.ts delete mode 100644 packages/ui/src/preimage-submit.ts create mode 100644 packages/ui/src/runtime-config.ts delete mode 100644 packages/ui/src/statement-store-mapping.ts delete mode 100644 packages/ui/src/wallet-queue.ts delete mode 100644 packages/ui/tests/allocation-modal.test.ts create mode 100644 packages/ui/tests/bridge.test.ts create mode 100644 packages/ui/tests/chain-callback.test.ts create mode 100644 packages/ui/tests/local-storage.test.ts create mode 100644 packages/ui/tests/notification.test.ts create mode 100644 packages/ui/tests/nova-removal.test.ts create mode 100644 packages/ui/tests/permission-modal.test.ts create mode 100644 packages/ui/tests/preimage.test.ts create mode 100644 packages/ui/tests/runtime-config.test.ts create mode 100644 packages/ui/tests/session-store.test.ts create mode 100644 packages/ui/tests/theme.test.ts create mode 100644 packages/ui/tests/topbar.test.ts create mode 100644 packages/ui/tests/user-confirmation.test.ts delete mode 100644 packages/ui/tests/wallet-queue.test.ts diff --git a/.env.example b/.env.example index 37cb25e5..0306e47a 100644 --- a/.env.example +++ b/.env.example @@ -26,10 +26,6 @@ VITE_METRICS= # build time (see packages/sandbox-checker). Leave unset for normal builds. VITE_SANDBOX_CHECKER= -# Set to "true" to use the smoldot light client for the statement store -# chain. Defaults to false; enable in development for testing and feedback. -VITE_SS_USE_SMOLDOT= - # Optional relay chain spec override for the statement store people chain. # Chain-spec file name without `.json`, e.g. "westend-local". When unset, # the default Paseo relay chain is reused. diff --git a/MIGRATION.md b/MIGRATION.md new file mode 100644 index 00000000..5dec5443 --- /dev/null +++ b/MIGRATION.md @@ -0,0 +1,101 @@ +# dotli host layer migration to TrUAPI + +This document records the current dotli host cutover state. The old +`@novasamatech/*` host-container path is no longer part of the runtime design: +dotli launches products through the Rust-backed TrUAPI host bridge and keeps +only its own `.dot` resolution/smoldot protocol outside that boundary. + +## Current integration + +dotli still has two protocol layers: + +1. Host-product API frames, handled by TrUAPI. +2. dotli's internal host-smoldot protocol in `packages/protocol/`, which owns + `.dot` resolution and is not replaced by TrUAPI. + +The active launch path is `packages/ui/src/bridge.ts`: + +- imports `@parity/truapi-host/web` and + `@parity/truapi-host/worker-runtime?worker`; +- starts a Web Worker that owns the `truapi-server` WASM core; +- adapts typed dotli callbacks with `createWasmRawCallbacks(...)`; +- calls `createWebWorkerProvider(new HostWorker(), rawCallbacks, { runtimeConfig })`; +- supplies callbacks from `packages/ui/src/host-callbacks/handlers.ts`; +- calls `createIframeHost(...)` with the product URL, sandbox policy, allowed + origin, and the worker-backed provider. + +Product frames enter the Rust core through the iframe `MessageChannel`. +Account, signing, statement-store, SSO pairing, restore, and logout are +core-owned and do not cross the JS host callback boundary as Nova-specific +routes. + +## dotli callback boundary + +dotli still supplies platform primitives that are host policy or browser UI: + +| Area | Files | +| ------------------------- | -------------------------------------------------------------------------------------- | +| navigation | `packages/ui/src/host-callbacks/OpenUrl.ts` | +| notifications | `packages/ui/src/host-callbacks/PushNotification.ts` | +| device/remote permissions | `packages/ui/src/host-callbacks/PromptPermission.ts`, `packages/ui/src/permissions.ts` | +| feature support | `packages/ui/src/host-callbacks/FeatureSupported.ts` | +| product storage | `packages/ui/src/host-callbacks/LocalStorage.ts` | +| session persistence | `packages/ui/src/host-callbacks/SessionStore.ts` | +| pairing presentation | `packages/ui/src/host-callbacks/AuthState.ts` | +| user confirmations | `packages/ui/src/host-callbacks/UserConfirmation.ts` | +| preimage lookup UI | `packages/ui/src/host-callbacks/Preimage.ts` | +| theme subscription | `packages/ui/src/host-callbacks/Theme.ts` | +| chain backend connection | `packages/ui/src/host-callbacks/Chain.ts` | + +These callbacks must remain generic host primitives. They should not re-add +Nova package imports, wallet-specific JS channels, or statement-store request +routing that belongs inside the Rust core. + +## Dependencies + +`packages/ui/package.json` currently resolves the public TrUAPI package names +through temporary npm aliases: + +```jsonc +"@parity/truapi": "npm:@pgherveou2/truapi-dev@...", +"@parity/truapi-host": "npm:@pgherveou2/truapi-host-dev@..." +``` + +This keeps standalone dotli installs and CI reproducible while the Rust core +port is in review. TrUAPI's development and E2E Make targets run +`bun run link:truapi` after building the local packages, so parent-repo work +always exercises the current checkout instead of the npm artifacts. + +> **TODO(packaging):** publish `@parity/truapi` and +> `@parity/truapi-host`, then replace the temporary aliases before merge. + +The runtime manifests and source must not depend on or import the removed +`@novasamatech/*` runtime packages. + +## Nested dApps + +The old `setupNestedBridgeDetector` path created extra JS bridges for nested +iframe sources. TrUAPI v1 does not create separate nested Rust runtimes, +sessions, product identities, or storage namespaces. If nested traffic is +forwarded later, it must use the shared top-level Rust core/provider context. + +The future usefulness of independent nested-product semantics is tracked in the +parent TrUAPI design note `docs/design/host-contract-and-core-impl/I - +nested-dapps.md`. + +## Non-TrUAPI dotli layers + +These areas remain dotli-owned and are intentionally outside the host-product +replacement: + +- `apps/host/src/main.ts`: landing shell, `.dot` resolution, iframe mounting. +- `apps/sandbox/src/main.ts`: content renderer. +- `packages/protocol/`: smoldot protocol client/broker/session plumbing. +- `packages/resolver/`: `.dot` name resolution. +- `packages/content/` and `packages/storage/`: archive fetch and cache. +- `packages/config/`, `packages/metrics/`, and `packages/shared/`: support + libraries. + +When auditing the migration, treat Nova runtime imports/dependencies as a +regression, but do not confuse dotli's internal `packages/protocol/` with the +removed host-product protocol. diff --git a/README.md b/README.md index a6abb74c..2ee0da81 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ Each product gets its own `