Embed protocol
Every postMessage exchanged between the iframe and the parent is JSON of the form { source, v, type, data }.
Iframe → parent (events)
Each event has source: "mtga" and v: 1.
| type | data |
|---|---|
| ready | {} |
| lesson.completed | { lessonId, moduleId, programId } |
| module.completed | { moduleId, programId, score? } |
| program.completed | { programId, completedAt, issuanceIds[] } |
| assessment.passed | { assessmentId, score, attemptNumber } |
| assessment.failed | { assessmentId, score, attemptNumber, attemptsRemaining } |
| navigation | { path } |
| height | { px } |
| error | { code, message } |
Parent → iframe (commands)
Each command has source: "mtga-host" and v: 1. Send via iframe.contentWindow.postMessage(...).
| type | data |
|---|---|
| navigate | { path } |
| refresh-token | { token } |
| set-locale | { locale: 'en' | 'es' } |