mirror of
https://github.com/kou029w/websri.git
synced 2025-01-18 08:05:13 +00:00
1.4 KiB
1.4 KiB
subresourceintegrity
subresourceintegrity
is a utility designed for Subresource Integrity that works across various web-interoperable runtimes, including Node.js, browsers, Cloudflare Workers, Deno, Bun, and others.
Usage
Install package:
# npm
npm install subresourceintegrity
# yarn
yarn add subresourceintegrity
# pnpm
pnpm install subresourceintegrity
# bun
bun install subresourceintegrity
import { createIntegrityMetadata } from "subresourceintegrity";
const res = new Response("Hello, world!");
const data = await res.arrayBuffer();
const integrityMetadata = await createIntegrityMetadata("sha256", data);
console.log(integrityMetadata.toString());
// sha256-MV9b23bQeMQ7isAGTkoBZGErH853yGk0W/yUx1iU7dM=
Documentation
FAQ
What is Subresource Integrity?
Subresource Integrity (SRI) is a security feature that allows user agents to verify that a fetched resource has not been manipulated unexpectedly.
License
subresourceintegrity
is released under the MIT License.