feat!: safe mode by default, trusted replaces untrusted (#323)
Merged
AL
5h ago+533+533+012345678901234567890123456789-433-433-012345678901234567890123456789
Part of #323: safe mode by default, the element side. Embed's trust list and the untrusted SCORM zip, decided in #323, come in a second pull request on top of this one.
What changes (player 2.0)
- Every package plays untrusted unless the page sets
trusted: its own library folders ignored, libraries fromlibraries(defaultpack),content/limited to H5P's file types, the content checked against the libraries' semantics. Whatuntrusteddid. trusted(attribute and property) plays a package as it is, with its own code. Theuntrustedattribute and property are gone; setting the attribute asks for the default.- A message for the case the new default makes common: an untrusted package that neither the sources nor the package has a library for no longer says to set
libraries, which it already has.
Everything that sets trust now
- Verifier: untrusted by default;
--trustedand the optiontrustedplay the package's own code.--untrustedis still taken, so installed skills and older scripts run. The report keeps itsuntrustedfield. - VS Code:
h5pPreview.trusted, off by default, replacesh5pPreview.untrusted; the preview's Untrusted switch starts on; Restricted Mode stays untrusted. - Demo: the player page starts on Untrusted. The app and the cmi5 page play every package untrusted, files and same-site links too, and ask to play one with its own scripts only when it needs them, naming the file or the host. The pages with no setting take the site's own pack (
demo/element.js). - MCP: the local server's check and preview play untrusted against the installed pack (
partsFolder, now exported by h5p-author). The MCP app's play page plays the activity it built untrusted, from the pack copy it builds with. - Embed and SCORM, unchanged in behaviour: the embed site sets
trustedwhere it trusts today (its own origin, listed hosts, a third-party frame), and the SCORM launch page setstrustedon the author's package. The second pull request changes both. - Docs, the skills and the demo pages lead with safe by default and
trustedas the exception.
Breaking, for the release notes
- A page that relied on the old default plays its packages untrusted: libraries from the pack (jsDelivr unless
pack-baseorpack), and a package that needs a library the pack lacks is refused withcarrieduntil the page setstrusted. - On such a page a package's
revisionchanges, since it names the pack parts the package now plays against. Statements carry the new one. Withresume="device"a learner's saved state starts over once: one saved against another revision is dropped, and the runtime says the content has changed. Aresume="host"page that keys its saved state byrevisionsees the same. player.untrusted = falseno longer trusts a package.- h5p-verify plays untrusted unless
--trusted. - VS Code:
h5pPreview.untrustedis no longer read;h5pPreview.trustedplays with the package's own code. - Before the release: publish
@missing-elements/h5p-libraries1.1.2, whichmainnames and every untrusted load now fetches.
Tests
- Player 629 (the fixtures play
trustedthrough the helper, since their content type is in no pack; untrusted plays say so), embed 83, verify 33, VS Code 30 and its suite in a real VS Code (8), demo 24 with two new cases (a same-site link plays untrusted; a file that needs its own code asks, naming it), author 335, MCP 24, MCP app 33, cmi5 50, journeys 56, skills 84. Typecheck and comments pass.
Release: player, verify and the VS Code extension major or breaking; the packages that pin the player follow at the bump.
Summary by cubic
Safe mode is now the default: every package plays untrusted — none of its own code runs, its libraries come only from the libraries sources (the pack by default), and its content is checked against the libraries' semantics — unless the page sets trusted. The untrusted attribute and property are gone; setting one asks for the default.
Breaking changes
- A page that relied on the old default now plays its packages untrusted: a package that needs a library the pack lacks is refused with
carrieduntil the page setstrusted. player.untrusted = falseno longer trusts a package.h5p-verifyplays untrusted unless--trusted;--untrustedis still accepted and does nothing.- VS Code reads
h5pPreview.trustedinstead ofh5pPreview.untrusted. - Before releasing, publish
@missing-elements/h5p-libraries1.1.2, whichmainnames and every untrusted load now fetches.
What it touches
- The verifier, the VS Code extension, the demo app, the cmi5 page, and the MCP server and app all default to untrusted; Embed and the SCORM page set
trustedwhere they already trusted, so their behaviour is unchanged. - Docs, skills and the demo lead with safe by default and
trustedas the exception.