Skip to content

Commit a5e9e7c

Browse files
committed
feat(truapi-server): add host logic primitives
1 parent 2cc45b1 commit a5e9e7c

21 files changed

Lines changed: 8124 additions & 446 deletions

Cargo.lock

Lines changed: 3468 additions & 445 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
[workspace]
22
resolver = "2"
33
members = ["rust/crates/*"]
4-
exclude = ["rust/crates/truapi-server"]
54

65
[workspace.package]
76
edition = "2024"

deny.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
allow = [
66
"MIT",
77
"Apache-2.0",
8+
"BSD-2-Clause",
9+
"BSD-3-Clause",
10+
"CC0-1.0",
811
"Unicode-3.0",
912
"Unlicense",
1013
"Zlib",
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
[package]
2+
name = "truapi-server"
3+
version = "0.1.0"
4+
edition.workspace = true
5+
description = "TrUAPI server runtime: dispatcher, frames, SCALE, streams"
6+
license = "MIT"
7+
8+
[lib]
9+
crate-type = ["rlib", "cdylib"]
10+
11+
[features]
12+
default = []
13+
14+
[dependencies]
15+
truapi = { path = "../truapi" }
16+
truapi-platform = { path = "../truapi-platform" }
17+
async-trait = "0.1"
18+
derive_more = { version = "2", features = ["display"] }
19+
futures = "0.3"
20+
futures-timer = { version = "3", features = ["wasm-bindgen"] }
21+
parity-scale-codec = { version = "3", features = ["derive"] }
22+
primitive-types = { version = "0.13", default-features = false, features = ["serde"] }
23+
serde = { version = "1", features = ["derive"] }
24+
serde_json = "1"
25+
thiserror = "1"
26+
unicode-normalization = "0.1"
27+
url = "2"
28+
hex = "0.4"
29+
blake2-rfc = { version = "0.2", default-features = false }
30+
sp-crypto-hashing = { version = "0.1", default-features = false }
31+
bs58 = { version = "0.5", default-features = false, features = ["alloc"] }
32+
schnorrkel = { version = "0.11.5", default-features = false, features = ["alloc", "getrandom"] }
33+
getrandom = { version = "0.2", features = ["js"] }
34+
p256 = { version = "0.13", default-features = false, features = ["ecdh"] }
35+
hkdf = "0.12"
36+
sha2 = "0.10"
37+
aes-gcm = { version = "0.10", default-features = false, features = ["aes", "alloc"] }
38+
tracing = "0.1"
39+
# `registry` + `std` only: pulls the Registry + per-layer filter/reload, but
40+
# not `env-filter` (which drags in `regex`, heavy on wasm).
41+
tracing-subscriber = { version = "0.3", default-features = false, features = ["registry", "std"] }
42+
43+
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
44+
subxt-rpcs = { version = "0.50.1", default-features = false, features = ["native"] }
45+
46+
[target.'cfg(target_arch = "wasm32")'.dependencies]
47+
js-sys = "0.3"
48+
subxt-rpcs = { version = "0.50.1", default-features = false, features = ["web"] }
49+
wasm-bindgen = "0.2.118"
50+
wasm-bindgen-futures = "0.4"
51+
console_error_panic_hook = "0.1"
52+
futures-util = "0.3"
53+
pin-project = "1"
54+
send_wrapper = { version = "0.6", features = ["futures"] }
55+
web-time = "1"
56+
web-sys = { version = "0.3", features = [
57+
"BinaryType",
58+
"CloseEvent",
59+
"console",
60+
"Event",
61+
"MessageEvent",
62+
"WebSocket",
63+
] }
64+
65+
[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
66+
wasm-bindgen-test = "0.3"
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# truapi-server
2+
3+
_Runtime core for TrUAPI: dispatcher, protocol frames, SCALE-coded wire envelope._
4+
5+
## What this crate is for
6+
7+
`truapi-server` is the runtime that turns trait implementations of the
8+
`truapi` API into a working host. It owns:
9+
10+
- the [`ProtocolMessage`] wire envelope and SCALE codec
11+
- the [`Dispatcher`] that routes incoming frames to per-method handlers
12+
- the subscription lifecycle (start/receive/stop/interrupt)
13+
- the [`Transport`] trait that platform-specific IPC backends implement
14+
- the auto-generated dispatcher/wire-table tables shipped under
15+
[`crate::generated`]
16+
17+
## Wire envelope
18+
19+
Every frame on the wire is encoded as:
20+
21+
```text
22+
[requestId: SCALE str][discriminant: u8][payload bytes...]
23+
```
24+
25+
The discriminant identifies a method + frame kind via the auto-generated
26+
[`crate::generated::wire_table::WIRE_TABLE`]. Each method's ids are exposed
27+
as a named const (`PREIMAGE_SUBMIT`, ...); both `WIRE_TABLE` and the generated
28+
dispatcher reference those consts. Method ordering is part of the wire
29+
protocol; only ever append.
30+
31+
The payload bytes are the SCALE-encoded inner value, inlined without a
32+
length prefix. The discriminant is carried directly as `Payload::id`, and the
33+
dispatcher routes on that numeric id via id-keyed tables.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//! Host-agnostic logic the Rust core owns on behalf of every platform host.
2+
//!
3+
//! Platform callbacks are a syscall layer for OS primitives (modals, native
4+
//! storage, URL handler, notification center). Everything else lives here so
5+
//! iOS, Android, and web hosts share one canonical implementation.
6+
7+
pub mod dotns;
8+
pub mod entropy;
9+
pub mod features;
10+
pub mod identity;
11+
pub mod permissions;
12+
pub mod product_account;
13+
pub mod session;
14+
pub mod session_store;
15+
pub mod sso;
16+
pub mod statement_store;

0 commit comments

Comments
 (0)