[AI-9623] Implement SDK host-side soft-mint embed origin for Angie Applications - #112
Draft
naftalis-elementor wants to merge 1 commit into
Draft
naftalis-elementor wants to merge 1 commit into
naftalis-elementor wants to merge 1 commit into
Conversation
…plications - Add embed token minting module (embed-token.ts) with caching and reminting logic - Mint embed session token before opening iframe when appId is provided - Send minted token to iframe via postMessage on ANGIE_READY event - Handle embed token refresh requests from iframe (ANGIE_EMBED_TOKEN_REQUEST) - Add new MessageEventType enums: ANGIE_EMBED_TOKEN_SET and ANGIE_EMBED_TOKEN_REQUEST - Integrate with elementor-ai API endpoint: POST /angie/embed/session - Implement token validation with 60s skew window before expiry - Coalesce concurrent mint requests for same appId - Add comprehensive unit tests for mint, cache, remint, and postMessage flows - Use logger instead of console for error/warning messages - Gracefully handle mint failures (log and continue without token) Co-authored-by: naftalis <naftalis-elementor@users.noreply.github.com>
🎬 Video Proof Test ResultsBranch: Clicked Ask Angie to open the loadSidebarV2 sidebar on the product editor POC. 📸 ScreenshotsArtifacts are also available on the workflow run. |
This branch has not been deployed
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.



Overview
This PR implements the host-side SDK functionality for soft-mint embed origin authentication for Angie Applications (
NG-*apps), as specified in the HLD (section 6.1).Relates to Jira ticket: https://elementor.atlassian.net/browse/AI-9623
Implementation Details
Core Functionality
embed-token.tsmodule handles minting, caching, and reminting of embed session tokensPOST /angie/embed/sessionwith{ appId }- browser setsOriginheader automaticallyappIdwith 60-second skew window before expiryappIdshare a single promisePostMessage Contract
Host → Iframe (Set Token):
angie/embed-token/set(MessageEventType.ANGIE_EMBED_TOKEN_SET){ embedToken: string, exp: number }Iframe → Host (Request Token):
angie/embed-token/request(MessageEventType.ANGIE_EMBED_TOKEN_REQUEST)Integration Points
openSaaSPage.ts: Mints token before opening iframe whenappIdis provided; sends token via postMessage after iframe signalsANGIE_READYhost-api-bridge.ts: Listens forANGIE_EMBED_TOKEN_REQUESTmessages from iframe and remints + resends tokenMint URL
Error Handling
appIdis handled gracefully (no token minted)Remint Behavior
appIduntil it expires (with 60s skew)ANGIE_EMBED_TOKEN_REQUESTmessageANGIE_EMBED_TOKEN_SETTesting
embed-token.test.ts: 14 tests covering mint, cache, remint, expiry, coalescing, error handlingopenSaaSPage.test.ts: Updated with 5 new tests for token minting and postMessage integrationhost-api-bridge.test.ts: Added 5 tests for remint request handlingAll tests pass. Linter checks pass.
Notes
?origin=query behavior for UX/analytics (not used for auth)Related PRs (different repos)