@demystify/embed-core
v0.1.1
Published
Iframe host for Demystify embedded surfaces: origin-validated postMessage, auto-resize, a11y, theming.
Downloads
803
Readme
@demystify/embed-core
The host side of a Demystify embedded surface. You normally install
@demystify/sign-embed or @demystify/pay-embed
instead — this arrives as their dependency.
Guide: docs/48-UI-INTEGRATION.md.
Why it exists
Receiving a postMessage safely takes four checks, and skipping any one of them is a real
vulnerability that no test in your app will catch:
- Origin, by string equality.
startsWithacceptshttps://sign.demystifysystem.com.attacker.test. - Sender identity.
event.source === iframe.contentWindow. Origin alone does not identify which frame sent a message. - Shape. Parsed against the contract; anything else is ignored rather than guessed at.
- Session. A stale iframe from a previous mount must not drive the current UI.
mountEmbed does all four. It also auto-sizes the frame (an iframe cannot size itself), respects
prefers-reduced-motion, and requires a title so screen-reader users do not land on an
unlabelled frame.
The rule that matters more than any of this
These events are for UX only. A postMessage comes from a browser the end-user controls.
Move your UI on them; never mark an invoice paid or a contract executed. That belongs to the
webhook — signed, retried, idempotent.
