feat(paywalls): add web_view message model and parsing (PWENG-98)#3654
feat(paywalls): add web_view message model and parsing (PWENG-98)#3654alexrepty wants to merge 1 commit into
Conversation
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
21899a1 to
8558b7d
Compare
66c0ccb to
3e62e49
Compare
8558b7d to
2790f47
Compare
2716386 to
27793a8
Compare
b70692b to
c8ba63e
Compare
c8ba63e to
5525f6c
Compare
27793a8 to
81453b8
Compare
5525f6c to
d7f8fa1
Compare
81453b8 to
5505947
Compare
d7f8fa1 to
86b7b79
Compare
5505947 to
74610d7
Compare
74610d7 to
a42c874
Compare
86b7b79 to
cdc1156
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ 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 cdc1156. Configure here.
| fun parse(rawJson: String, expectedComponentId: String): PaywallWebViewMessage? { | ||
| if (rawJson.toByteArray(Charsets.UTF_8).size > MAX_PAYLOAD_BYTES) { | ||
| Logger.w("Dropping web view message: payload exceeds $MAX_PAYLOAD_BYTES bytes.") | ||
| return null |
There was a problem hiding this comment.
Payload check unbounded allocation
Medium Severity
The 64KB payload cap is enforced by calling toByteArray(UTF_8) on the entire raw JSON string first. A hostile or buggy web view can send a very large string and trigger a huge allocation (and possible OOM) before the message is dropped, even though the limit is meant to bound work.
Reviewed by Cursor Bugbot for commit cdc1156. Configure here.
cdc1156 to
7c75281
Compare
a42c874 to
7aceb78
Compare
Adds a bidirectional JS<->native bridge for the Paywalls V2 `web_view` component: a document-start `window.RevenueCatWebView` shim, message parsing/validation (`WebViewMessageParser`, `WebViewMessageType`), the public `PaywallWebViewMessage` / `PaywallWebViewValue` / `PaywallWebViewMessageHandler` / `PaywallWebViewController` surface, and an SDK-managed variables provider (locale, color scheme, custom variables). Apps opt in via `PaywallOptions.setWebViewMessageHandler(...)`, threaded through `PaywallState` / `OfferingToStateMapper`. Regenerates ui/revenuecatui/api.txt for the new public API. Recommended labels: pr:feat, pr:RevenueCatUI, feat:Paywalls_V2
7aceb78 to
cf8d3d0
Compare
7c75281 to
a1cc787
Compare



Checklist
purchases-iosand hybridsMotivation
Defines the inbound message model and parsing for
web_view↔ native communication, so messages from web content are validated before reaching app code.Part of PWENG-98.
Description
PaywallWebViewMessageplus thePaywallWebViewMessageHandler/PaywallWebViewControllersurface.WebViewMessageTypeandWebViewMessageParser: validates the flat envelope, enforces payload size / nesting-depth caps, requires thecomponent_idto match the rendered component, and validates per-type fields (rc:step-loaded,rc:step-complete,rc:request-variables,rc:error); unknown types are dropped.WebViewbridge yet.WebViewMessageParserTest.iOS parity: mirrors
purchases-ios(web-view-bridge-wiring).Stack (merge bottom-up): schema → rendering → CSP → value types → message model → variables provider → JS bridge → wiring.
Note
Low Risk
Additive public API and internal validation logic with no runtime WebView integration or purchase flow changes in this PR.
Overview
Introduces the public surface for Paywalls V2
web_view↔ native messaging:PaywallWebViewMessage,PaywallWebViewMessageHandler, andPaywallWebViewController(reply viapostVariables/postMessageusingPaywallWebViewValue). App code will wire the handler throughPaywallOptions.Builder.setWebViewMessageHandlerin a follow-up; the SDK does not auto-dismiss or purchase onrc:step-complete.Adds internal parsing via
WebViewMessageParser: validates the flat postMessage envelope, caps payload size (64KB) and nesting depth, requirescomponent_idto match the rendered web view, handlesrc:step-loaded,rc:step-complete,rc:request-variables, andrc:error, and drops unknown types and invalid payloads.api.txtis updated for the new types.No live WebView bridge in this PR—data and validation only, covered by
WebViewMessageParserTest.Reviewed by Cursor Bugbot for commit a1cc787. Bugbot is set up for automated code reviews on this repo. Configure here.