Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support obtaining consent from CMPs when loaded from sub frames #164

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

zapo
Copy link
Member

@zapo zapo commented Jan 23, 2025

It's possible that the web-sdk is loaded from within iframes, in which case window.__tcfapi and window.__gpp won't be installed and consent won't be available at all to the SDK.

In order to preserve consent handling in such case, this PR leverage the postMessage CMP APIs for gpp and tcf.

New helpers are introduced so that if the corresponding CMP proxy iframe is found in parent frames, a mocked window function is installed which will communicate with the iframe through the postMessage API.

This allows consumers like getConsent to transparently look for and use __{cmpapi} function on window without having to know if it communicates directly or through the frame proxy with the CMP.

@zapo zapo force-pushed the support-get-consent-from-iframe branch from 7792a3d to 4241792 Compare January 23, 2025 21:00
@zapo zapo force-pushed the support-get-consent-from-iframe branch from 4241792 to 4cb6466 Compare January 23, 2025 21:12
@zapo zapo marked this pull request as ready for review January 23, 2025 21:12
@zapo zapo changed the title Support obtaining consent from cmpapi through iframe postmessage Support obtaining consent from CMPs when loaded from sub frames Jan 23, 2025
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.

1 participant