2024-09-03 03:57:12 +09:00
# websri
2024-09-03 03:14:59 +09:00
2024-09-03 03:57:12 +09:00
[![NPM Version ](https://img.shields.io/npm/v/websri )](https://www.npmjs.com/package/websri) [![jsDocs.io ](https://img.shields.io/badge/jsDocs.io-reference-blue )](https://www.jsdocs.io/package/websri)
2024-09-03 03:14:59 +09:00
2024-09-03 03:57:12 +09:00
`websri` is a universal Subresource Integrity (SRI) utility for Node.js, browsers, Cloudflare Workers, Deno, Bun, and other web-compatible runtimes.
2024-09-03 03:14:59 +09:00
## Usage
Install package:
```sh
# npm
2024-09-03 03:57:12 +09:00
npm install websri
2024-09-03 03:14:59 +09:00
# yarn
2024-09-03 03:57:12 +09:00
yarn add websri
2024-09-03 03:14:59 +09:00
# pnpm
2024-09-18 16:28:15 +09:00
pnpm add websri
2024-09-03 03:14:59 +09:00
2024-09-03 09:50:43 +09:00
# deno
deno add npm:websri
2024-09-03 03:14:59 +09:00
# bun
2024-09-18 16:28:15 +09:00
bun add websri
2024-09-03 03:14:59 +09:00
```
[Integrity Metadata ](https://www.w3.org/TR/SRI/#integrity-metadata ):
```ts
2024-09-03 03:57:12 +09:00
import { createIntegrityMetadata } from "websri";
2024-09-03 03:14:59 +09:00
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
2024-09-03 03:57:12 +09:00
[API Reference ](https://www.jsdocs.io/package/websri )
2024-09-03 03:14:59 +09:00
## FAQ
### What is Subresource Integrity?
[Subresource Integrity (SRI) ](https://www.w3.org/TR/SRI/ ) is a security feature that allows user agents to verify that a fetched resource has not been manipulated unexpectedly.
## License
2024-09-03 03:57:12 +09:00
`websri` is released under the MIT License.