// @shortplay/game-sdk — the OPTIONAL child-side author SDK (D5 progressive enhancement). // // This ships to untrusted third-party authors and runs INSIDE the sandboxed game iframe. // It MUST be standalone: it does NOT import from the app's `src/` graph or use path aliases // (so it never drags the app's tsconfig into a third party's build). The wire format below // is VENDORED from src/runtime/protocol.ts and MUST match it exactly. // // The SDK is DX, NOT a security boundary (docs/07). But the child still authenticates the // parent the same way the parent authenticates the child — there is no trustworthy origin: // (1) source identity — accept only `event.source === window.parent`; // (2) per-mount nonce — read from `location.hash` (`#sp=`); every inbound message // must carry the exact same nonce, else ignore; // (3) schema — validate every inbound message against the parent→game shape. // Outbound, we post to the parent with the nonce and targetOrigin '*' (the parent cannot be // targeted by origin; it re-validates via source + nonce). NEVER trust origin. // // STANDARDS-FIRST (D5): on `pause`/`blur` the SDK also dispatches REAL `visibilitychange` / // `blur` so an UNMODIFIED game (one that never registered SDK callbacks) still pauses. // ----- controller input (shared with the games-worker serve-time input shim) -------------- // // isGameInputMessage / dispatchControllerInput live in ./controllerInputDispatch — a SIBLING // module in this same standalone package (not the app's src/ graph), self-contained by design so // games-worker/src/inputShim.ts can `.toString()` the SAME functions into a literal inline //