Skip to content

[AI-8410] Feature: Host apps can load Angie sidebar with v2 config — host API bridge - #45

Merged
matipojo merged 3 commits into
masterfrom
AI-8410-v2-host-bridge
Jun 1, 2026
Merged

[AI-8410] Feature: Host apps can load Angie sidebar with v2 config — host API bridge#45
matipojo merged 3 commits into
masterfrom
AI-8410-v2-host-bridge

Conversation

@matipojo

@matipojo matipojo commented May 31, 2026

Copy link
Copy Markdown
Member

Summary

Stacked PR 3/3 for AI-8410: Feature: Host apps can load Angie sidebar with v2 config.

Adds the host API bridge and getExternalHeaders callback wiring for embedded iframe API calls. Completes the split of the original monolithic branch; diff vs AI-8410-load-sidebar-v2 is bridge-only on top of #44.

Jira

https://elementor.atlassian.net/browse/AI-8410

Test plan

  • npm test
  • npm run lint
  • Verify host bridge / external headers in a host app

✨ PR Description

1. Problem & Context

Hosts need bidirectional communication with embedded Angie sidebar to provide external headers, website context, and analytics data. This PR establishes a postMessage-based API bridge enabling the iframe to request host-side information with origin validation.

2. What Changed (Where)

  • host-api-bridge.ts (new): Message handler for GET_EXTERNAL_HEADERS, website/analytics context, and localStorage operations with origin gating
  • config.ts: Added ExternalHeadersCallback type and analytics field to HostConfig; wired getExternalHeaders through CallbacksConfig
  • boot-sidebar.ts: Initialize bridge before rendering with iframe origin and callbacks
  • resolve-config.ts: Pass getExternalHeaders callback through config resolution pipeline
  • Tests & exports: Added comprehensive bridge tests (237 lines), mocked in boot tests, exported new type

3. How It Works

Boot initiates bridge with iframe origin and callback reference → iframe sends MessageEvent with transferable port → bridge validates origin → routes to handler (headers/context/storage) → callback executes if provided → response posted back on port. Undefined headers filtered before sending; errors caught and reported as error payloads.

4. Risks

Origin spoofing: Mitigated by explicit origin check against configured iframe origin. Callback exceptions: Wrapped in try-catch with error reporting. localStorage failures: Gracefully degrade in private browsing mode. No cleanup: bridgeListenerRegistered prevents duplicate listeners but lacks explicit teardown—acceptable for single-boot lifecycle.

Generated by LinearB AI and added by gitStream.
AI-generated content may contain inaccuracies. Please verify before using.
💡 Tip: You can customize your AI Description using Guidelines Learn how

@matipojo
matipojo force-pushed the AI-8410-v2-layouts branch from f963665 to 59356d9 Compare May 31, 2026 07:52
@matipojo
matipojo force-pushed the AI-8410-v2-host-bridge branch 2 times, most recently from 3b1085d to 69a8cd6 Compare May 31, 2026 07:59
@matipojo
matipojo force-pushed the AI-8410-v2-layouts branch from 0c720f6 to db0c562 Compare May 31, 2026 08:01
@matipojo
matipojo force-pushed the AI-8410-v2-host-bridge branch from 69a8cd6 to eaf358d Compare May 31, 2026 08:01
Base automatically changed from AI-8410-v2-layouts to master June 1, 2026 10:01
…ar boot process

- Added ExternalHeadersCallback type to support dynamic header retrieval.
- Integrated initHostApiBridge function to initialize the host API with external headers.
- Updated bootSidebar to call initHostApiBridge with the necessary configuration.
- Created tests for host API bridge to validate header retrieval and error handling.
- Ensured callbacks are preserved in the configuration resolution process.
@matipojo
matipojo force-pushed the AI-8410-v2-host-bridge branch from 3e0b05b to 028ff3a Compare June 1, 2026 10:10
- Added support for retrieving website and analytics context from the host configuration.
- Updated initHostApiBridge to accept host configuration, including website and analytics data.
- Implemented new message types for website and analytics context requests.
- Enhanced tests to validate the retrieval of website and analytics context from the host.
- Introduced localStorage handling for GET and SET operations in the host API bridge.
@wiz-9a149474ff

wiz-9a149474ff Bot commented Jun 1, 2026

Copy link
Copy Markdown

Wiz Scan Summary

Scanner Findings
Vulnerability Finding Vulnerabilities -
Data Finding Sensitive Data -
Secret Finding Secrets -
IaC Misconfiguration IaC Misconfigurations -
SAST Finding SAST Findings 1 Low
Software Management Finding Software Management Findings -
Total 1 Low

View scan details in Wiz

To detect these findings earlier in the dev lifecycle, try using Wiz Code VS Code Extension.

@matipojo
matipojo merged commit 648584e into master Jun 1, 2026
14 checks passed
@matipojo
matipojo deleted the AI-8410-v2-host-bridge branch June 1, 2026 11:26
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