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..6383a0a1 --- /dev/null +++ b/MIGRATION.md @@ -0,0 +1,97 @@ +# 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` depends on the published TrUAPI packages: + +```jsonc +"@parity/truapi": "0.4.0", +"@parity/truapi-host": "0.1.0" +``` + +Standalone dotli installs and CI exercise these npm artifacts. 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. + +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/Makefile b/Makefile index ff261541..c601a924 100644 --- a/Makefile +++ b/Makefile @@ -59,17 +59,30 @@ RATE_LIMITED_ENVS := paseo dev-test # Default env when none is passed on the command line. ENV ?= paseo +# When this repo is checked out as truapi/hosts/dotli, local make builds should +# consume the checked-out TrUAPI packages instead of the temporary npm aliases. +TRUAPI_REPO ?= $(abspath ../..) +TRUAPI_LOCAL_PACKAGE := $(TRUAPI_REPO)/js/packages/truapi/package.json +TRUAPI_HOST_LOCAL_PACKAGE := $(TRUAPI_REPO)/js/packages/truapi-host/package.json + # Packages required on a fresh Ubuntu 22.04+ box. The brotli module is split # across two packages on noble (filter + static) and both ship a drop-in in # /etc/nginx/modules-enabled/ so they auto-load. curl and ca-certificates # back certbot's API calls. APT_PACKAGES := nginx libnginx-mod-http-brotli-filter libnginx-mod-http-brotli-static certbot python3-certbot-dns-cloudflare rsync ufw curl ca-certificates -.PHONY: build provision provision-prereqs provision-firewall provision-cloudflare-creds provision-cert provision-renewal deploy ci-deploy deploy-nginx render-nginx _require-env _require-env-name +.PHONY: build link-truapi-local provision provision-prereqs provision-firewall provision-cloudflare-creds provision-cert provision-renewal deploy ci-deploy deploy-nginx render-nginx _require-env _require-env-name -build: +build: link-truapi-local bun run build +link-truapi-local: + @if [ -f "$(TRUAPI_LOCAL_PACKAGE)" ] && [ -f "$(TRUAPI_HOST_LOCAL_PACKAGE)" ]; then \ + TRUAPI_REPO="$(TRUAPI_REPO)" bun run link:truapi; \ + else \ + echo "No local TrUAPI checkout found at $(TRUAPI_REPO); using package manager dependencies."; \ + fi + # ==================================================================== # Fresh-server provisioning. Idempotent; safe to re-run. # diff --git a/README.md b/README.md index a6abb74c..74f7d6f1 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ Each product gets its own `