Skip to content

chore: unwrap bridge envelope in ApplePayWebView message handler#48

Open
unickq wants to merge 4 commits intomainfrom
mchursin/apple-pay-logs
Open

chore: unwrap bridge envelope in ApplePayWebView message handler#48
unickq wants to merge 4 commits intomainfrom
mchursin/apple-pay-logs

Conversation

@unickq
Copy link
Copy Markdown
Contributor

@unickq unickq commented Apr 2, 2026

Description

This pull request introduces an update to how messages from the native bridge are handled in the ApplePayWebView component, ensuring that bridge message envelopes are properly unwrapped before processing.

ApplePayWebView Message Handling Improvements:

  • Updated src/payments/ApplePayWebView.tsx to unwrap bridge postMessage envelopes produced by injectedBridge.ts, ensuring the actual payload is extracted and parsed correctly before further processing. This improves compatibility with the native bridge message format.
  • Changed the call to parseBoltMessage to use the unwrapped message, preventing issues with nested or stringified payloads.

Testing

ScreenRecording_04-02-2026.15-24-54_1.mov

Security Review

Important

A security review is required for every PR in this repository to comply with PCI requirements.

  • I have considered and reviewed security implications of this PR and included the summary below.

Security Impact Summary

n/a

@unickq unickq requested review from a team as code owners April 2, 2026 12:27
@snyk-io
Copy link
Copy Markdown

snyk-io bot commented Apr 2, 2026

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues
Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@unickq unickq changed the title fix: unwrap bridge envelope in ApplePayWebView message handler chore: unwrap bridge envelope in ApplePayWebView message handler Apr 2, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adjusts the Apple Pay WebView message handler to correctly unwrap the injected bridge postMessage envelope so Apple Pay (and iframe height) messages can be interpreted from the inner payload.

Changes:

  • Unwrap __boltBridge postMessage envelopes in ApplePayWebView before handling height changes and Apple Pay result messages.
  • Add a root pod script to run pod install for the example iOS app.
  • Update example app configuration/demo code and refresh example/ios/Podfile.lock.

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/payments/ApplePayWebView.tsx Adds bridge-envelope unwrapping and routes Apple Pay parsing through the unwrapped payload.
package.json Adds a convenience pod script for installing example iOS pods.
example/src/boltConfig.example.ts Updates the example config template (currently includes a concrete publishable key and staging env).
example/src/App.tsx Updates demo state typing and stores Apple Pay results in tokenResult.
example/ios/Podfile.lock Updates the resolved BoltReactNativeSdk pod version/checksum after running pods.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

});
const threeDSecure = useThreeDSecure();
const [tokenResult, setTokenResult] = useState<TokenResult | null>(null);
const [tokenResult, setTokenResult] = useState<
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

May need to rethink or rename this - an ApplePayResult is not just a token but includes other data too. This should be clearer.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I wanted to rename it to setPaymentResult, but that may not be a payment either. Even if it's just an example app. So removed

@unickq unickq force-pushed the mchursin/apple-pay-logs branch from 47f1ef5 to 3b47aff Compare April 2, 2026 17:12

const handleMessage = useCallback(
(event: WebViewMessageEvent) => {
dispatcher.handleMessage(event);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

think we may need to discuss the envelope process, because this dispatcher already has an unwrapping process in it, so any changes means changing code in 2 places now

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

You're right, but I was focused on fixing the ApplePay flow and wasn't familiar with the dispatcher's unwrapping internals.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

to have this as a result

Screenshot 2026-04-02 at 8 24 54 PM

@unickq unickq force-pushed the mchursin/apple-pay-logs branch from 3b47aff to f80a4a5 Compare April 2, 2026 17:21
@unickq unickq requested a review from RhysAtBolt April 2, 2026 17:22
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.

3 participants