Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
119 commits
Select commit Hold shift + click to select a range
8e0e71f
feat(truapi): add testing API and versioned wiring
pgherveou Jun 30, 2026
dea080a
fixup! feat(truapi): add testing API and versioned wiring
pgherveou Jul 1, 2026
3409152
fixup! feat(truapi): add testing API and versioned wiring
pgherveou Jul 1, 2026
0569aaf
fixup! feat(truapi): add testing API and versioned wiring
pgherveou Jul 2, 2026
8c93e99
feat(truapi-platform): add host capability traits
pgherveou Jun 30, 2026
97d0b79
fixup! feat(truapi-platform): add host capability traits
pgherveou Jul 2, 2026
d2e3674
fixup! feat(truapi-platform): add host capability traits
pgherveou Jul 3, 2026
c6f888c
feat(truapi-codegen): emit Rust dispatcher, wire table, and host call…
pgherveou Jun 30, 2026
a37abae
fixup! feat(truapi-codegen): emit Rust dispatcher, wire table, and ho…
pgherveou Jul 2, 2026
99d1b7e
fixup! feat(truapi-codegen): emit Rust dispatcher, wire table, and ho…
pgherveou Jul 2, 2026
1c46353
fixup! feat(truapi-codegen): emit Rust dispatcher, wire table, and ho…
pgherveou Jul 2, 2026
2c52262
fixup! feat(truapi-codegen): emit Rust dispatcher, wire table, and ho…
pgherveou Jul 3, 2026
7bd57b8
fixup! feat(truapi-codegen): emit Rust dispatcher, wire table, and ho…
pgherveou Jul 3, 2026
6964df3
feat(truapi-server): add host logic primitives
pgherveou Jul 1, 2026
c8c4595
fixup! feat(truapi-server): add host logic primitives
pgherveou Jul 1, 2026
88cf1a9
fixup! feat(truapi-server): add host logic primitives
pgherveou Jul 2, 2026
2d88bdf
fixup! feat(truapi-server): add host logic primitives
pgherveou Jul 3, 2026
e1f6790
feat(truapi-server): add wire and chain infrastructure
pgherveou Jul 1, 2026
d959726
fixup! feat(truapi-server): add wire and chain infrastructure
pgherveou Jul 3, 2026
fa642c1
fixup! feat(truapi-server): add host logic primitives
pgherveou Jul 3, 2026
176c6b1
feat(truapi-server): add platform runtime and host bridge
pgherveou Jul 1, 2026
6aa9887
fixup! feat(truapi-server): add platform runtime and host bridge
pgherveou Jul 1, 2026
0f6e16c
fixup! feat(truapi-server): add platform runtime and host bridge
pgherveou Jul 2, 2026
80ff2c7
fixup! feat(truapi-server): add platform runtime and host bridge
pgherveou Jul 2, 2026
c6091f0
fixup! feat(truapi-server): add platform runtime and host bridge
pgherveou Jul 3, 2026
e4d9a0d
fixup! feat(truapi-server): add wire and chain infrastructure
pgherveou Jul 3, 2026
302e84c
feat(host-wasm): add @parity/truapi-host-wasm runtime
pgherveou Jun 30, 2026
63f59f9
fixup! feat(host-wasm): add @parity/truapi-host-wasm runtime
pgherveou Jul 1, 2026
232458b
fixup! feat(host-wasm): add @parity/truapi-host-wasm runtime
pgherveou Jul 2, 2026
7ac562a
fixup! feat(truapi-server): add platform runtime and host bridge
pgherveou Jul 3, 2026
e33df7c
fixup! feat(host-wasm): add @parity/truapi-host-wasm runtime
pgherveou Jul 3, 2026
dab5395
Merge origin/main into rust-core/04-codegen
pgherveou Jul 3, 2026
15e1594
Merge branch 'rust-core/04-codegen' into rust-core/04a-server-host-logic
pgherveou Jul 3, 2026
54f0b20
docs(host-logic): link host-spec sections
pgherveou Jul 3, 2026
2da3da5
Merge branch 'rust-core/04a-server-host-logic' into rust-core/04b-ser…
pgherveou Jul 3, 2026
f7b2424
Merge branch 'rust-core/04b-server-wire-chain' into rust-core/03-serv…
pgherveou Jul 3, 2026
ac7992f
docs(runtime): link host-spec sections
pgherveou Jul 3, 2026
cd15f9c
Merge branch 'rust-core/03-server-runtime' into rust-core/05-host-wasm
pgherveou Jul 3, 2026
67d763b
docs(server): fix wasm rustdoc reference
pgherveou Jul 3, 2026
cda27e1
fixup! feat(truapi-server): add wire and chain infrastructure
pgherveou Jul 3, 2026
227f47c
Merge branch 'rust-core/04b-server-wire-chain' into rust-core/03-serv…
pgherveou Jul 3, 2026
8bd9085
fixup! feat(truapi-server): add platform runtime and host bridge
pgherveou Jul 3, 2026
51f1e1c
Merge branch 'rust-core/03-server-runtime' into rust-core/05-host-wasm
pgherveou Jul 3, 2026
ba2571a
Merge branch 'main' into rust-core/03-server-runtime
pgherveou Jul 3, 2026
b804d04
fix(server): enforce runtime permissions
pgherveou Jul 6, 2026
f22b4b5
feat(codegen): generate wasm bridge callbacks
pgherveou Jul 6, 2026
2cb1e97
Merge branch 'rust-core/04-wasm-bridge-codegen' into rust-core/05-hos…
pgherveou Jul 6, 2026
4c04dd3
refactor(host-wasm): use namespaced callbacks
pgherveou Jul 6, 2026
5de806e
fix(server): include runtime crate in workspace
pgherveou Jul 6, 2026
460dc77
Merge branch 'rust-core/03-server-runtime' into rust-core/04-wasm-bri…
pgherveou Jul 6, 2026
e9888aa
Merge branch 'rust-core/04-wasm-bridge-codegen' into rust-core/05-hos…
pgherveou Jul 6, 2026
0d304f8
docs(server): describe permission flow
pgherveou Jul 6, 2026
cddce3e
Merge branch 'rust-core/03-server-runtime' into rust-core/04-wasm-bri…
pgherveou Jul 6, 2026
b4ac06f
Merge branch 'rust-core/04-wasm-bridge-codegen' into rust-core/05-hos…
pgherveou Jul 6, 2026
a253874
fix(codegen): satisfy wasm bridge clippy
pgherveou Jul 6, 2026
a46e8fe
Merge remote-tracking branch 'origin/rust-core/04-wasm-bridge-codegen…
pgherveou Jul 6, 2026
1735b8a
test(server): wait for auth sync callback
pgherveou Jul 6, 2026
01ddadc
Merge remote-tracking branch 'origin/rust-core/03-server-runtime' int…
pgherveou Jul 6, 2026
487b2d7
Merge remote-tracking branch 'origin/rust-core/04-wasm-bridge-codegen…
pgherveou Jul 6, 2026
f421258
test(server): make pairing snapshot test deterministic
pgherveou Jul 6, 2026
2fc5be9
Merge remote-tracking branch 'origin/rust-core/03-server-runtime' int…
pgherveou Jul 6, 2026
c137fef
Merge remote-tracking branch 'origin/rust-core/04-wasm-bridge-codegen…
pgherveou Jul 6, 2026
7190552
chore(stack): move wasm bridge out of runtime layer
pgherveou Jul 6, 2026
c3c243b
Merge remote-tracking branch 'origin/rust-core/03-server-runtime' int…
pgherveou Jul 6, 2026
71c910f
Merge remote-tracking branch 'origin/rust-core/04-wasm-bridge-codegen…
pgherveou Jul 6, 2026
5fbf0b3
fixup! feat(truapi-server): add platform runtime and host bridge
pgherveou Jul 6, 2026
07a3a1c
Merge branch 'rust-core/03-server-runtime' into rust-core/04-wasm-bri…
pgherveou Jul 6, 2026
c75688a
Merge branch 'rust-core/04-wasm-bridge-codegen' into rust-core/05-hos…
pgherveou Jul 6, 2026
95516f7
fixup! feat(truapi-server): add platform runtime and host bridge
pgherveou Jul 6, 2026
9f0a7ef
Merge branch 'rust-core/03-server-runtime' into rust-core/04-wasm-bri…
pgherveou Jul 6, 2026
00942fa
Merge branch 'rust-core/04-wasm-bridge-codegen' into rust-core/05-hos…
pgherveou Jul 6, 2026
86ffc19
fixup! feat(truapi-server): add platform runtime and host bridge
pgherveou Jul 6, 2026
5f21721
Merge branch 'rust-core/03-server-runtime' into rust-core/04-wasm-bri…
pgherveou Jul 6, 2026
781efcb
Merge branch 'rust-core/04-wasm-bridge-codegen' into rust-core/05-hos…
pgherveou Jul 6, 2026
98b1023
fixup! feat(truapi-server): add platform runtime and host bridge
pgherveou Jul 6, 2026
c4f7c02
Merge branch 'rust-core/03-server-runtime' into rust-core/04-wasm-bri…
pgherveou Jul 6, 2026
0b9c962
Merge branch 'rust-core/04-wasm-bridge-codegen' into rust-core/05-hos…
pgherveou Jul 6, 2026
b639cb7
fixup! feat(truapi-server): add platform runtime and host bridge
pgherveou Jul 7, 2026
ee797ed
Merge branch 'rust-core/03-server-runtime' into rust-core/04-wasm-bri…
pgherveou Jul 7, 2026
95ce2e9
fixup! feat(codegen): generate wasm bridge callbacks
pgherveou Jul 7, 2026
b0887cb
Merge branch 'rust-core/04-wasm-bridge-codegen' into rust-core/05-hos…
pgherveou Jul 7, 2026
4d2fe57
fixup! feat(host-wasm): add @parity/truapi-host-wasm runtime
pgherveou Jul 7, 2026
4bdb9b5
fixup! feat(truapi-server): add platform runtime and host bridge
pgherveou Jul 8, 2026
9875241
Merge branch 'rust-core/03-server-runtime' into rust-core/04-wasm-bri…
pgherveou Jul 8, 2026
9df1053
Merge branch 'rust-core/04-wasm-bridge-codegen' into rust-core/05-hos…
pgherveou Jul 8, 2026
521b20e
Merge branch 'rust-core/04-wasm-bridge-codegen' into rust-core/05-hos…
pgherveou Jul 8, 2026
4fb288e
fixup! feat(codegen): generate wasm bridge callbacks
pgherveou Jul 8, 2026
06af617
fixup! feat(host-wasm): add @parity/truapi-host-wasm runtime
pgherveou Jul 8, 2026
3a64291
refactor(platform): derive allowance Debug
pgherveou Jul 8, 2026
4757653
Merge branch 'rust-core/03-server-runtime' into rust-core/04-wasm-bri…
pgherveou Jul 8, 2026
1e28a14
Merge branch 'rust-core/04-wasm-bridge-codegen' into rust-core/05-hos…
pgherveou Jul 8, 2026
a99f0e5
fix(runtime): keep allowance signing in Rust
pgherveou Jul 8, 2026
e53b78e
Merge branch 'rust-core/03-server-runtime' into rust-core/04-wasm-bri…
pgherveou Jul 8, 2026
7822d7f
Merge branch 'rust-core/04-wasm-bridge-codegen' into rust-core/05-hos…
pgherveou Jul 8, 2026
80135ef
fix(runtime): harden pairing failures
pgherveou Jul 8, 2026
b24a693
Merge branch 'rust-core/03-server-runtime' into rust-core/04-wasm-bri…
pgherveou Jul 8, 2026
b3a8f2d
Merge branch 'rust-core/04-wasm-bridge-codegen' into rust-core/05-hos…
pgherveou Jul 8, 2026
3f775f3
fix(runtime): simplify pairing outcome
pgherveou Jul 8, 2026
defe071
Merge branch 'rust-core/03-server-runtime' into rust-core/04-wasm-bri…
pgherveou Jul 8, 2026
812ddf6
Merge branch 'rust-core/04-wasm-bridge-codegen' into rust-core/05-hos…
pgherveou Jul 8, 2026
3c97ceb
ci: format generated Rust codegen output
pgherveou Jul 8, 2026
8161d60
Merge branch 'rust-core/04-wasm-bridge-codegen' into rust-core/05-hos…
pgherveou Jul 8, 2026
4132406
fixup! feat(codegen): generate wasm bridge callbacks
pgherveou Jul 8, 2026
19210f4
Merge branch 'rust-core/04-wasm-bridge-codegen' into rust-core/05-hos…
pgherveou Jul 8, 2026
d97ffc7
refactor(host-wasm): rename host package
pgherveou Jul 8, 2026
747f412
Merge remote-tracking branch 'origin/main' into rust-core/04-wasm-bri…
pgherveou Jul 9, 2026
4e6ab3b
Merge branch 'rust-core/04-wasm-bridge-codegen' into rust-core/05-hos…
pgherveou Jul 9, 2026
f90c233
ci: install rustfmt for codegen job
pgherveou Jul 9, 2026
0f18a5e
Merge branch 'rust-core/04-wasm-bridge-codegen' into rust-core/05-hos…
pgherveou Jul 9, 2026
1e33292
refactor(codegen): remove flat host callbacks
pgherveou Jul 9, 2026
ff1aaf4
Merge branch 'rust-core/04-wasm-bridge-codegen' into rust-core/05-hos…
pgherveou Jul 9, 2026
4f8379f
test(host): use namespaced callbacks
pgherveou Jul 9, 2026
e7f8d4d
test(host): cover worker permission auth
pgherveou Jul 9, 2026
437650a
fix(host-wasm): address review feedback
pgherveou Jul 9, 2026
7567e00
Merge branch 'rust-core/04-wasm-bridge-codegen' into rust-core/05-hos…
pgherveou Jul 9, 2026
c2444c3
fix(host-wasm): harden worker and iframe plumbing
pgherveou Jul 10, 2026
0a45543
Merge branch 'main' into rust-core/05-host-wasm
pgherveou Jul 10, 2026
0273324
fix(e2e): surface preimage authority failures
pgherveou Jul 10, 2026
e84b9e8
test(host-wasm): wait for subscription errors
pgherveou Jul 10, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ lerna-debug.log*
node_modules
target

# Gradle (Android workspace at repo root)
/.gradle/
/build/
/android/*/build/
local.properties

# Environment / secrets (never commit real env files; keep example templates)
.env
.env.*
Expand Down Expand Up @@ -39,3 +45,16 @@ playground/public/static.files

# Auto-generated by truapi-codegen (typecheck fixtures for rustdoc ts blocks)
playground/test/generated/

# Auto-generated FFI / WASM binding outputs
android/truapi-host/src/main/kotlin/generated/
ios/truapi-host/Sources/TrUAPIHost/truapi_server.swift
ios/truapi-host/Sources/truapi_serverFFI/
rust/crates/truapi-server/pkg/
js/packages/truapi/src/generated/
js/packages/truapi/dist/generated/
js/packages/truapi-host/src/generated/
js/packages/truapi-host/dist/generated/
js/packages/truapi-host-wasm/src/generated/
js/packages/truapi-host-wasm/dist/generated/
js/packages/truapi-host-wasm/dist/wasm/
5 changes: 4 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
"endOfLine": "lf",
"overrides": [
{
"files": "js/packages/truapi/src/**/*.test.ts",
"files": [
"js/packages/truapi/src/**/*.test.ts",
"js/packages/truapi-host-wasm/src/**/*.test.ts"
],
"options": {
"tabWidth": 4,
"printWidth": 100
Expand Down
11 changes: 11 additions & 0 deletions js/packages/truapi-host/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
node_modules/
*.tsbuildinfo
# Ignore compiled TS output (top-level + the web/ and electron/ entry subdirs)
# Generated WASM artifacts under dist/wasm/ are ignored by the repo root.
dist/**/*.js
dist/**/*.d.ts
dist/**/*.js.map
dist/**/*.d.ts.map
dist/generated/
# Codegen output from truapi-codegen --platform-ts-output.
src/generated/
21 changes: 21 additions & 0 deletions js/packages/truapi-host/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2026 Parity Technologies

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
79 changes: 79 additions & 0 deletions js/packages/truapi-host/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# @parity/truapi-host

WASM-backed TrUAPI host runtime. It embeds the `truapi-server` Rust core (compiled to WASM)
behind a Web Worker provider, plus per-environment integration entry points. It is the
counterpart to the native Android/iOS host shells.

## Entry points

The package exposes tree-shakeable subpath exports — import only what your environment needs:

| Import | Provides |
| ------------------------------------ | ------------------------------------------------------------------------------------------------------------------- |
| `@parity/truapi-host` | Shared runtime types plus generated typed host callback contracts. |
| `@parity/truapi-host/web` | Browser pairing host: `createIframeHost` (iframe MessageChannel handshake) and `createWebWorkerPairingHostRuntime`. |
| `@parity/truapi-host/worker-runtime` | Web Worker entrypoint (import with your bundler's `?worker` suffix) so the WASM core runs off the page main thread. |
| `@parity/truapi-host/wasm/web` | The raw browser `wasm-bindgen` glue, if you need to instantiate the core yourself. |

## Generated WASM artefacts

The ignored bundle under `dist/wasm/web/` is built with host-owned chain access.
Hosts wire their JSON-RPC provider through `chainConnect`; if they omit it,
chain calls fail with the core's standard unavailable error. The bundled WASM is
about 1 MB (release build with `wasm-opt`).

Build them after editing `rust/crates/truapi-server` and before packaging, publishing, or running
tests that load the raw WASM bundle (requires `wasm-pack` on PATH):

```bash
npm run build:wasm # or `make wasm` from the repo root
```

## Example — browser (Web Worker)

```ts
import HostWorker from "@parity/truapi-host/worker-runtime?worker";
import { createWebWorkerPairingHostRuntime } from "@parity/truapi-host/web";

const runtime = await createWebWorkerPairingHostRuntime(
new HostWorker(),
callbacks,
{
hostConfig,
},
);

const firstProvider = await runtime.createProvider({ productId: "first.dot" });
const secondProvider = await runtime.createProvider({
productId: "second.dot",
});
```

`@parity/truapi-host/web` also exports `createIframeHost` for the
protocol-iframe MessageChannel handshake. Host code creates one worker runtime
and then opens one provider per product id.

## Publishing

This package is published by the root `Release` workflow through
`paritytech/npm_publish_automation`. Do not run `npm publish` locally. Cut a
`release:` PR with a changeset for `@parity/truapi-host`; the workflow builds
the generated host bindings, the browser WASM bundle, packs the tarball, and
publishes it when the `@parity/truapi-host@<version>` tag does not already
exist.

## Architecture

```text
JS host code
protocol handlers / typed callbacks
(types from @parity/truapi-host)
|
v
createWebWorkerPairingHostRuntime
shared worker runtime: pairing session, chain runtime, WASM instance
|
+-- createProvider({ productId }) -> product core / WireProvider
|
+-- createProvider({ productId }) -> product core / WireProvider
```
59 changes: 59 additions & 0 deletions js/packages/truapi-host/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"name": "@parity/truapi-host",
"version": "0.1.0",
"description": "WASM-backed TrUAPI host runtime: embeds the Rust core, with web iframe and Web Worker entry points",
"license": "MIT",
"author": "Parity Technologies <admin@parity.io>",
"repository": {
"type": "git",
"url": "git+https://github.com/paritytech/truapi.git",
"directory": "js/packages/truapi-host"
},
"homepage": "https://github.com/paritytech/truapi#readme",
"bugs": {
"url": "https://github.com/paritytech/truapi/issues"
},
"type": "module",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"sideEffects": [
"./dist/worker-runtime.js",
"./dist/wasm/**"
],
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js"
},
"./web": {
"types": "./dist/web/index.d.ts",
"import": "./dist/web/index.js"
},
"./worker-runtime": {
"types": "./dist/worker-runtime.d.ts",
"import": "./dist/worker-runtime.js"
},
"./wasm/web": {
"types": "./dist/wasm/web/truapi_server.d.ts",
"import": "./dist/wasm/web/truapi_server.js"
}
},
"files": [
"dist",
"README.md",
"LICENSE"
],
"scripts": {
"build": "tsc -b",
"build:wasm": "node scripts/build-wasm.mjs",
"test": "bun test"
},
"dependencies": {
"@parity/truapi": "file:../truapi"
},
"devDependencies": {
"@types/bun": "^1.3.0",
"neverthrow": "^8.2.0",
"typescript": "^5.7"
}
}
63 changes: 63 additions & 0 deletions js/packages/truapi-host/scripts/build-wasm.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/usr/bin/env node
// Rebuild the browser truapi-server WASM artefacts generated under
// `dist/wasm/web/`. wasm-pack is required.

import { execFile } from "node:child_process";
import { rm } from "node:fs/promises";
import { dirname, resolve } from "node:path";
import { fileURLToPath } from "node:url";
import { promisify } from "node:util";

const execFileAsync = promisify(execFile);
const __dirname = dirname(fileURLToPath(import.meta.url));
const pkgRoot = resolve(__dirname, "..");
const repoRoot = resolve(pkgRoot, "../../..");
const rustCrate = resolve(repoRoot, "rust/crates/truapi-server");
const wasmProfile = process.env.TRUAPI_WASM_PROFILE ?? "release";

function args(target, outDir) {
const command = [
"build",
"--target",
target,
"--out-dir",
outDir,
"--out-name",
"truapi_server",
];
if (wasmProfile === "dev") {
command.push("--dev");
} else if (wasmProfile === "profiling") {
command.push("--profiling");
} else if (wasmProfile !== "release") {
throw new Error(
`Unsupported TRUAPI_WASM_PROFILE=${wasmProfile}; expected release, dev, or profiling`,
);
}
command.push(rustCrate, "--no-default-features");
return command;
}

async function build(target, subdir) {
const outDir = resolve(pkgRoot, "dist/wasm", subdir);
process.stdout.write(
`wasm-pack build --target ${target} --${wasmProfile} → ${outDir}\n`,
);
try {
await execFileAsync("wasm-pack", args(target, outDir), { cwd: repoRoot });
} catch (err) {
if (err?.code === "ENOENT") {
console.error(
"wasm-pack is required. Install it with `cargo install wasm-pack` " +
"or see https://rustwasm.github.io/wasm-pack/installer/",
);
process.exit(1);
}
throw err;
}
// wasm-pack writes a nested `.gitignore: *`; the repo-level ignore already
// owns generated WASM outputs.
await rm(resolve(outDir, ".gitignore"), { force: true });
}

await build("web", "web");
Loading