# WASM Client Barycenter includes a Rust-based WebAssembly client that provides browser-side WebAuthn/passkey functionality. The client is compiled from Rust to WebAssembly using `wasm-pack` and loaded by the login and account management pages. ## Building ### Prerequisites Install `wasm-pack` if you do not already have it: ```bash cargo install wasm-pack ``` ### Build Command ```bash cd client-wasm wasm-pack build --target web --out-dir ../static/wasm ``` The `--target web` flag generates ES module output suitable for loading directly in a browser with ` ``` ### Content-Security-Policy Requirement The WASM module requires the `wasm-unsafe-eval` CSP directive. Barycenter's security headers include this: ``` script-src 'self' 'wasm-unsafe-eval' ``` Without `wasm-unsafe-eval`, the browser blocks WebAssembly compilation. This directive is narrowly scoped and does not permit JavaScript `eval()`. ### Browser Compatibility | Browser | WebAuthn | Conditional UI (Autofill) | |---------|----------|--------------------------| | Chrome 108+ | Yes | Yes | | Safari 16+ | Yes | Yes | | Firefox 119+ | Yes | No | | Edge 108+ | Yes | Yes | On browsers that do not support conditional UI, the login page falls back to showing an explicit "Sign in with passkey" button. On browsers without WebAuthn support, passkey features are hidden entirely and password authentication remains available. ## Development Workflow During development, rebuild the WASM module whenever you change the `client-wasm/` source: ```bash cd client-wasm wasm-pack build --target web --out-dir ../static/wasm ``` The WASM output files are not checked into version control. They must be built locally or generated as part of the CI/CD pipeline before deploying.