Import-Map Integrity
WICG Import Maps + Subresource Integrity (SRI) extension. When a page declares , each mapped module SHOULD carry an integrity hash so the browser refuses to execute the module if the bytes don't match.
b.importmapIntegrity.build({ specifiers, sha256, sha384, sha512 }) hashes each operator-supplied module body and emits the JSON with an integrity map alongside the imports map. Composes existing b.crypto.sri.
b.importmapIntegrity.build(opts) #
{
modules: { "": { url, body: Buffer|string } },
hash: "sha256"|"sha384"|"sha512", // default sha384
}
Build an import-map JSON shape { imports, integrity } per WICG Import-Maps-SRI. Each module body is hashed with opts.hash (default sha384 per current SRI convention).
var im = b.importmapIntegrity.build({
modules: {
"@org/lib": { url: "/static/lib.js", body: fileBytes },
},
});
// Embed with the " in a module url and breaks out of the tag.
res.end(b.importmapIntegrity.scriptTag(im));
b.importmapIntegrity.scriptTag(importmap, opts?) #
{ nonce: string, // CSP nonce added as nonce="…" on thetag using the-safe JSON serializer. RawJSON.stringifydoes not escapein a module url, so concatenating it into the page lets ain a url close the element and inject markup — this escapes< > &(and the U+2028 / U+2029 separators) so no url can break out.res.end(b.importmapIntegrity.scriptTag(im, { nonce: req.cspNonce }));Last updated 2026-08-08T16:39:49.652Z by seeder.