<script>
accept integrity
attribute, so I can load a module safely:
<script type="module"
src="https://example.com/module.mjs"
integrity="sha256-2Kok7MbOyxpgUVvAk/HJ2jigOSYS2auK4Pfzbm7uH60="
crossorigin="anonymous"
></script>
But how to keep safe when loading module inside script?
- with import:
import foo from "https://example.com/module.mjs"
- dynamic import:
import("https://example.com/module.mjs").then(console.log)
- or even web worker:
const myWorker = new Worker('worker.js')
integrity
attribute? You can know all about it here: developer.mozilla.org/en-US/docs/Web/Security/… – Examplecat FILENAME.js | openssl dgst -sha384 -binary | openssl base64 -A
whereFILENAME.js
is the file they want to hash. But I am wondering if I have to incorporate this into my package.json and assign it to a global variable. Also instead of doingFILENAME.js
is it okay to put my CDN link there instead? – Litafetch
has a way to specifyintegrity
: fetch.spec.whatwg.org/#concept-request-integrity-metadata – Cayuga