websri/README.md

1.4 KiB

subresourceintegrity

NPM Version jsDocs.io

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

Integrity Metadata:

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

API Reference

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.