[wip] feat: Add WASM build target for browser integration#6
Closed
lukehalasy-anchorage wants to merge 14 commits intoanchorageoss:mainfrom
Closed
[wip] feat: Add WASM build target for browser integration#6lukehalasy-anchorage wants to merge 14 commits intoanchorageoss:mainfrom
lukehalasy-anchorage wants to merge 14 commits intoanchorageoss:mainfrom
Conversation
- Add cmd/wasm/main.go with JavaScript-callable parseTransaction function - Implement wasm/key_provider.go for in-memory credential management - Implement wasm/http_client.go using JavaScript fetch API - Compile to turnkey_client.wasm (6.1MB) for browser use This enables calling Turnkey's VisualSign API directly from the browser by compiling the turnkeyclient to WebAssembly. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Replace the Go WASM implementation with a minimal C++ build using wasi-sdk, reducing binary size from 6.1MB to <100KB while maintaining full functionality. Changes: - Remove Go WASM files (cmd/wasm/main.go, wasm/*.go) - Add C++ WASM implementation in cpp/wasm/ directory - Add Makefile targets for building and cleaning WASM artifacts - Update README with WASM documentation and usage examples The C++ approach uses wasi-sdk to produce a minimal WASI-compliant binary without JavaScript runtime bloat, inspired by minimal WASM projects like MiniLisp C++. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Add comprehensive proof-of-concept test suite for the C++ WASM module: - Interactive browser test page (test.html) - Node.js command-line test (test.js) - Complete documentation (TEST_POC.md) - ES6 module exports for browser compatibility Testing shows successful WASM loading: - File size: 413.67 KB (vs 6.1 MB Go WASM) - Load time: ~4ms - Memory: 16 MB linear memory allocation - All exports validated including parseTransaction 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
45dbfd3 to
7b4a066
Compare
This change enables C++ code to call async JavaScript functions (fetch, crypto APIs) as if they were synchronous by using Asyncify transformation. Changes: - build.sh: Apply asyncify transformation via wasm-opt before optimization - js_glue.js: Convert js_fetch, js_sign_message, js_sha256 to async/await - test.html: Fix WASM path to load from parent directory 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Replace hardcoded values throughout WASM code with compile-time constants for better maintainability and type safety. - Add buffer size constants (SIGNATURE_BUFFER_SIZE, HTTP_RESPONSE_BUFFER_SIZE, etc.) - Add API endpoint constants (API_BASE_URL, CREATE_SIGNABLE_PAYLOAD_PATH) - Add JSON field name constants (UNSIGNED_PAYLOAD, CHAIN, SIGNABLE_PAYLOAD) - Add crypto separator constants (STAMP_SEPARATOR, STAMP_FORMAT_SEPARATOR) - Add HTTP header name constants (CONTENT_TYPE, X_ORG_ID, X_STAMP) - Update all files to use new constants instead of magic numbers/strings Benefits: - Zero runtime cost (resolved at compile-time) - Single source of truth for configuration - Type-safe string literals - Self-documenting code 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Replace remaining magic numbers and compile-time constants with constexpr for better code clarity and optimization opportunities: - Error message strings in main.cpp - HTTP status codes and method names - Hex encoding constants (width, chars per byte, base) - JS fetch return codes Fixes namespace qualification issues for json_fields constants. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Update POC test files to import from parent directory's js_glue.js instead of maintaining a duplicate copy. This reduces code duplication and PR line count by 260 lines. Changes: - Remove cpp/wasm/poc/js_glue.js (duplicate) - Update test.js and test.html to import from ../js_glue.js - Verified build still works with make build-wasm 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Move build logic from build.sh directly into Makefile to reduce code duplication and PR line count. This saves 75 lines while maintaining identical functionality. Changes: - Remove cpp/wasm/build.sh - Inline all build commands into Makefile build-wasm target - Add prerequisite documentation in comments (wasi-sdk, wasm-opt) - Verified build works with make build-wasm (produces 809KB WASM) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
prasanna-anchorage
requested changes
Dec 28, 2025
Contributor
prasanna-anchorage
left a comment
There was a problem hiding this comment.
actually you can do the http calls using standard JavaScript and only verification needs to be done with WASM. This is re-implementing everything in C++ instead of compiling to WASM target from the same Go codebase that I had in #2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Testing
Browser test:
🤖 Generated with Claude Code