fix: wire iframe RPC handshake so WebView elements load merchant customizations#70
Merged
Merged
Conversation
Contributor
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
f335640 to
f3ad41c
Compare
RhysAtBolt
approved these changes
May 7, 2026
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.
Description
Wire the iframe RPC handshake so the embedded WebView's
BoltElementsprovider can resolveloadMerchantDetailsand render merchant copy customizations. Without this, the iframe'swithRPCcall hangs forever and elements display default copy. A newBoltRpcHandlermirrors what the central iframe does in the web embedded app: it sends asetPortbootstrap envelope on bridge-ready, listens on the virtual port, and answersloadMerchantDetailsby fetching from the public merchant API.To support this,
BoltBridgeDispatchergains asendBootstrapPortmethod (queues until ready, like other messages) andonReadynow persists across reset/reload transitions so the handshake re-fires after a WebView reload. The injected bridge'sVirtualMessagePortaddsaddEventListener/removeEventListener(storm's RPC registers viaaddEventListener, not.onmessage) and dispatches events withorigin: ''to match real MessagePort spec — storm filters byportOrigin: ''.Also bundled: rename the postal field placeholder from "Billing zip" to "Postal code" on iOS and Android (matches latest copy direction); make
scripts/gen-bolt-config.jsregenerate when env vars are set instead of always preserving the existing file; addexample/src/boltConfig.tsto the clean script.Testing
src/__tests__/BoltRpcHandler.test.tscover: setPort handshake on bridge ready,loadMerchantDetailshappy path, error path, request caching, and theinitializedno-op.src/__tests__/BoltBridgeDispatcher.test.tscover:sendBootstrapPortenvelope shape, queueing before ready, andonReadyfiring on every ready transition.Security Review
Important
A security review is required for every PR in this repository to comply with PCI requirements.
Security Impact Summary
This PR adds an RPC channel from the embedded iframe to the React Native host that currently exposes a single read-only operation: fetching public merchant details (description and copy_customizations) from the merchant public API using the configured publishable key. No PCI data, no authentication tokens, and no card details flow over this channel. The handler dispatches by an explicit allowlist (
handlersmap) — unknown request types are logged and ignored, never executed. The virtual port is identified by a fixed id (vp_rpc_main) and the iframe origin handshake (postMessageenvelope) matches the existing bridge protocol that already authenticates source via the WebView boundary. No changes to auth, payment, or token-handling code paths.