Skip to content

Instantly share code, notes, and snippets.

@Zemnmez
Created Aug 12, 2021
Embed
What would you like to do?
async function main() {
window.parent.postMessage("ready", "*");
const config = await new Promise((ok, fail) => {
console.log("waiting for config...")
window.addEventListener("message", ({ data }) => {
console.log("got config message");
if (data.type !== "config") return fail(`did not get config, instead got ${JSON.stringify(data)}`);
return ok(data);
}, { once: true })
});
console.log({ config });
console.log("now any data the null origin gets is sent to the icloud iframe...");
window.addEventListener("message", ({ data }) => {
console.log("forwarding to idmsa", data)
window.top.frames[config.idmsaFrameId].postMessage(data, "*");
});
}
main().catch(e => console.error(e))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment