Skip to content

Move WalletKit web into a package-owned worker - #523

Open
Dzejkop wants to merge 6 commits into
codex/supplied-storage-keysfrom
codex/walletkit-web-worker
Open

Move WalletKit web into a package-owned worker#523
Dzejkop wants to merge 6 commits into
codex/supplied-storage-keysfrom
codex/walletkit-web-worker

Conversation

@Dzejkop

@Dzejkop Dzejkop commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Make walletkit-web own its Web Worker and expose an async TypeScript facade. Hosts supply a resolved database key and can configure worker/Wasm URLs; generated Rust bindings remain inside the worker.

  • Implement the worker protocol, lifecycle, and async public API.
  • Update the Next.js demo to use the package worker and databaseKey option. It uses a random in-memory key as a stand-in; passkey acquisition remains host integration work.
  • Add browser coverage for worker lifecycle, URL overrides, exclusive pool ownership, persistent direct keys, and wrong-key rejection. The current browser setup supports one WalletKit worker per origin.

Targets #522 directly, above the original POC (#480). The browser uses StorageKeys.fromBytes and does not need a software keystore or envelope blob database.

Validation: Wasm package build (including TypeScript checking and bundling), fixture TypeScript checking, and all 6 Chrome browser tests pass on the rebased stack.


Note

High Risk
Breaking public API and cryptographic/storage wiring (database keys, OPFS, worker exclusivity); consumers must migrate off raw generated bindings.

Overview
walletkit-web no longer exposes the generated UniFFI namespace. Initialization now requires a 32-byte databaseKey and optional storageId, spins up a package-bundled worker, and returns a WalletKit client with promise-based RPC (register / pollRegistration, initializeAuthenticator, prepareCredential / storeCredential, generateProof, close / terminate). Rust/WASM, SQLite, and OPFS persistence run inside that worker; only plain data crosses the boundary.

The Next.js POC drops its local walletkit.worker.ts and drives the full staging flow from the page via initializeWalletKit, with in-memory keys and updated copy about OPFS persistence after reload.

Tooling/docs: bundle ships walletkit.worker.js, README documents the browser API and storage model, version 0.22.1, plus Playwright + Vite browser tests (lifecycle, exclusive pool, wrong key, URL overrides).

Reviewed by Cursor Bugbot for commit edf57ab. Bugbot is set up for automated code reviews on this repo. Configure here.

@Dzejkop
Dzejkop added this pull request to stack #524 September 9, 2026 13:47
@Dzejkop
Dzejkop removed this pull request from stack #524 September 9, 2026 13:47
@Dzejkop
Dzejkop force-pushed the codex/walletkit-web-worker branch 2 times, most recently from d30490c to d48644b Compare September 9, 2026 13:54
@Dzejkop
Dzejkop changed the base branch from codex/supplied-storage-keys to codex/browser-storage-support September 9, 2026 13:54
@Dzejkop
Dzejkop force-pushed the codex/walletkit-web-worker branch from d48644b to 0de0604 Compare September 9, 2026 14:48
@Dzejkop
Dzejkop force-pushed the codex/walletkit-web-worker branch from 0de0604 to 8468178 Compare September 9, 2026 15:47
@Dzejkop
Dzejkop force-pushed the codex/walletkit-web-worker branch from 8468178 to b8e49f8 Compare September 10, 2026 09:16
@Dzejkop
Dzejkop changed the base branch from codex/browser-storage-support to codex/supplied-storage-keys September 10, 2026 09:16
@Dzejkop
Dzejkop added this pull request to stack #529 September 10, 2026 09:20
@Dzejkop
Dzejkop force-pushed the codex/walletkit-web-worker branch from b8e49f8 to 0fc93c8 Compare September 10, 2026 09:39
@Dzejkop
Dzejkop marked this pull request as ready for review September 10, 2026 12:19
@Dzejkop
Dzejkop force-pushed the codex/walletkit-web-worker branch from 7da011f to 5964061 Compare September 10, 2026 12:28

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 7da011f. Configure here.

if (variants.Batching.instanceOf(status)) return { state: "batching" };

return { state: "queued" };
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Failed registration cannot be retried

Medium Severity

register refuses a second attempt whenever registration is already set, and pollRegistration never clears that handle after a failed status. A gateway failure therefore makes the client permanently unable to start a new registration, while the demo still offers the Register action because it only sets registered on success.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 7da011f. Configure here.

piohei
piohei previously approved these changes Sep 10, 2026
previous build didn't include dist files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants