Skip to content

feat(paywalls): add web_view SDK variables provider (PWENG-98)#3663

Open
alexrepty wants to merge 1 commit into
alexrepty/paywalls-web-view-message-modelfrom
alexrepty/paywalls-web-view-variables-provider
Open

feat(paywalls): add web_view SDK variables provider (PWENG-98)#3663
alexrepty wants to merge 1 commit into
alexrepty/paywalls-web-view-message-modelfrom
alexrepty/paywalls-web-view-variables-provider

Conversation

@alexrepty

@alexrepty alexrepty commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Checklist

  • If applicable, unit tests
  • If applicable, create follow-up issues for purchases-ios and hybrids

Motivation

When web content sends rc:request-variables, the SDK replies with safe, already-available system context. v1 exposes only locale; the paywall's dashboard-defined custom variables are intentionally not passed across the bridge.

Part of PWENG-98.

Description

  • Adds PaywallWebViewVariablesProvider: builds the SDK-managed variables payload ({ locale } only) and sanitizeAppProvidedVariables, which strips reserved top-level keys so app-provided values cannot overwrite SDK-managed ones (they nest under custom).
  • Internal; consumed by the JS bridge in the next PR.
  • Tested by PaywallWebViewVariablesProviderTest.

iOS parity: mirrors purchases-ios (web-view-bridge-wiring), which likewise exposes locale only and treats custom variables as out of scope for v1.
Stack (merge bottom-up): schema → rendering → CSP → value types → message model → variables provider → JS bridge → wiring.


Note

Low Risk
New internal helper and unit tests only; no public API or bridge wiring yet, with deliberate limits on what crosses the web view boundary.

Overview
Adds internal PaywallWebViewVariablesProvider so the upcoming JS bridge can answer rc:request-variables with a v1-safe payload: SDK-managed locale only (no dashboard custom vars, keys, or PII).

sdkManagedVariables(locale) returns { "locale": … } as PaywallWebViewValue map; sanitizeAppProvidedVariables strips reserved top-level keys (today just locale) and logs when apps try to overwrite them—aligned with app vars living under custom via PaywallWebViewController.postVariables.

PaywallWebViewVariablesProviderTest covers locale-only SDK map and reserved-key stripping. Wiring into the bridge is a follow-up PR in the stack.

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

@alexrepty alexrepty changed the title feat(paywalls): add web_view bidirectional messaging feat(paywalls): add web_view SDK variables provider Jun 26, 2026
@alexrepty alexrepty force-pushed the alexrepty/paywalls-web-view-variables-provider branch from 276280e to 7769f56 Compare June 26, 2026 14:20
@alexrepty alexrepty force-pushed the alexrepty/paywalls-web-view-message-model branch from 8558b7d to 2790f47 Compare June 26, 2026 14:20
@alexrepty alexrepty force-pushed the alexrepty/paywalls-web-view-variables-provider branch from 7769f56 to 716657f Compare June 26, 2026 14:26
@alexrepty alexrepty force-pushed the alexrepty/paywalls-web-view-message-model branch 2 times, most recently from 1387950 to ffd8f08 Compare June 26, 2026 14:57
@alexrepty alexrepty force-pushed the alexrepty/paywalls-web-view-variables-provider branch from 716657f to 27bcaa4 Compare June 26, 2026 14:57
@alexrepty alexrepty force-pushed the alexrepty/paywalls-web-view-message-model branch from ffd8f08 to b70692b Compare June 29, 2026 09:30
@alexrepty alexrepty force-pushed the alexrepty/paywalls-web-view-variables-provider branch from 27bcaa4 to c009f2d Compare June 29, 2026 09:30
@alexrepty alexrepty force-pushed the alexrepty/paywalls-web-view-message-model branch from b70692b to c8ba63e Compare June 29, 2026 09:58
@alexrepty alexrepty force-pushed the alexrepty/paywalls-web-view-variables-provider branch from c009f2d to 3ca2b9e Compare June 29, 2026 09:58
@alexrepty alexrepty changed the title feat(paywalls): add web_view SDK variables provider feat(paywalls): add web_view SDK variables provider (PWENG-98) Jun 29, 2026
@alexrepty alexrepty force-pushed the alexrepty/paywalls-web-view-variables-provider branch 2 times, most recently from 9c03cae to c73e87b Compare June 29, 2026 13:58
@alexrepty alexrepty force-pushed the alexrepty/paywalls-web-view-message-model branch 2 times, most recently from 5525f6c to d7f8fa1 Compare June 29, 2026 14:14
@alexrepty alexrepty force-pushed the alexrepty/paywalls-web-view-variables-provider branch from c73e87b to cf8f802 Compare June 29, 2026 14:14
@alexrepty alexrepty marked this pull request as ready for review June 29, 2026 14:43
@alexrepty alexrepty requested a review from a team as a code owner June 29, 2026 14:43
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
@alexrepty alexrepty force-pushed the alexrepty/paywalls-web-view-variables-provider branch from cf8f802 to f341b57 Compare June 30, 2026 07:44
@alexrepty alexrepty force-pushed the alexrepty/paywalls-web-view-message-model branch from d7f8fa1 to 86b7b79 Compare June 30, 2026 07:44
@emerge-tools

emerge-tools Bot commented Jun 30, 2026

Copy link
Copy Markdown

📸 Snapshot Test

2 modified, 591 unchanged

Name Added Removed Modified Renamed Unchanged Errored Approval
TestPurchasesUIAndroidCompatibility
com.revenuecat.testpurchasesuiandroidcompatibility
0 0 2 0 333 0 ⏳ Needs approval
TestPurchasesUIAndroidCompatibility Paparazzi
com.revenuecat.testpurchasesuiandroidcompatibility.paparazzi
0 0 0 0 258 0 N/A

🛸 Powered by Emerge Tools

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant