(feat): redesign WASM module, add TypeScript SDK, migrate to pnpm
Some checks failed
CI / rustfmt (push) Successful in 17s
CI / wasm build (push) Successful in 1m16s
CI / clippy (push) Successful in 1m28s
CI / test (push) Successful in 1m48s
CI / example (push) Successful in 1m31s
CI / duplicate code (push) Failing after 33s
CI / web client (push) Failing after 34s
CI / cargo-machete (push) Successful in 1m18s
CI / cargo-deny (push) Failing after 3m2s

This commit is contained in:
Alois 2026-06-27 23:44:27 +02:00
commit 5caa1c9d5f
49 changed files with 3717 additions and 1501 deletions

View file

@ -33,7 +33,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
tls::export_webtransport_cert_hash(&cert_hash)?;
println!("WebTransport certificate sha256: {cert_hash}");
let (host_id, host_keyring) = keys::load_or_generate_host_keys("host_keys.json")?;
let (_host_id, host_keyring) = keys::load_or_generate_host_keys("host_keys.json")?;
keys::export_host_public_keys(&host_keyring)?;
// The keyring is moved into the host config; keep a copy for decrypting the
@ -44,7 +44,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
let (clients, next_id) = clients::load_client_db("clients.json")?;
let clients_for_get = clients.clone();
let get_existing_user = Box::new(move |id: u64| -> Option<mtp::crypto::PublicKeyBundle> {
let get_existing_user = move |id: u64| -> Option<mtp::crypto::PublicKeyBundle> {
let result = clients_for_get.lock().unwrap().get(&id).cloned();
if result.is_some() {
println!("Auth lookup: client ID {id} found");
@ -52,12 +52,12 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
eprintln!("Auth lookup: unknown client ID {id}");
}
result
});
};
let clients_for_register = clients.clone();
let next_id_for_register = next_id.clone();
let clients_path = "clients.json".to_string();
let complete_register = Box::new(move |bundle: mtp::crypto::PublicKeyBundle| -> u64 {
let complete_register = move |bundle: mtp::crypto::PublicKeyBundle| -> u64 {
let mut db = clients_for_register.lock().unwrap();
let mut nid = next_id_for_register.lock().unwrap();
let id = *nid;
@ -72,26 +72,22 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
}
println!("Registered new client with ID: {}", id);
id
});
};
println!("Starting MTP server on port 8080 ...");
let config = HostConfig {
ip: std::net::IpAddr::V4(std::net::Ipv4Addr::UNSPECIFIED),
port: 8080,
tls_fullchain: cert_pem,
tls_key: key_pem,
require_authentication: true,
host_id,
host_keyring,
get_existing_user,
complete_register,
};
let config = HostConfig::new(
std::net::IpAddr::V4(std::net::Ipv4Addr::UNSPECIFIED),
8080,
cert_pem,
key_pem,
)
.with_authentication(host_keyring, get_existing_user, complete_register);
let mut host = MTPHost::new(config).await?;
println!("Server listening on {}", host.local_addr());
while let Some(conn) = host.accept().await {
while let Some(conn) = host.accept().await? {
println!(
"\n--- New authenticated connection (version {}) ---",
conn.version