Skip to content

web: move the SIWE challenge below the facade #910

Description

@FSM1

Goal

Move the SIWE nonce fetch below the facade so apps/web holds no seam of its own.

Problem

facade.siweLogin(message, signature) exists, but nothing exposes the challenge that an
EIP-4361 message must embed. The engine's API client already has siwe_challenge()
(crates/engine/src/api/client.rs) against POST /auth/siwe/challenge; it is unreachable
from the facade.

Landing #804 therefore left apps/web/src/auth/siweNonce.ts doing a plain fetch against
the API's public challenge endpoint. That is the only direct API call in apps/web and it
contradicts blueprint/web-client.md "apps/web ... no crypto, no seams, no tokens" — its
only vault-facing dependency should be packages/client.

The nonce is public, single-use, and carries no key material, so this is an architecture
debt, not a live vulnerability.

Work

  • Add a siweChallenge read to the engine facade over the existing ApiClient::siwe_challenge,
    and bind it in crates/wasm.
  • Thread it through packages/client: protocol.ts request/response, transport.ts,
    the correlated/broadcast transports, worker/serve.ts, and facade.ts.
  • Delete apps/web/src/auth/siweNonce.ts and have WalletLoginButton read the nonce
    from the facade.

Note

siweLogin is a Command, so it is refused with NotStarted before facade.start. Settle
whether the wallet method belongs on the cold login page at all, or only as a linked
secondary method on an already-started engine, while doing this.

Gate

Client Browser Suite + web unit.

Depends on

Shares a threading surface with #914: both add a facade member and carry it through crates/wasm and
packages/client (protocol.ts, transport.ts, the correlated/broadcast transports, worker/serve.ts,
facade.ts). Land one, rebase the other.

Blocks

Part of #642

Metadata

Metadata

Assignees

No one assigned

    Labels

    comp:webpackages/client + apps/web — WASM host, browser seams, React UIv2-buildv2 rewrite build slice

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions