Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ssri

Package Overview
Dependencies
Maintainers
6
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ssri

Standard Subresource Integrity library -- parses, serializes, generates, and verifies integrity metadata according to the SRI spec.

  • 12.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
24M
decreased by-8.3%
Maintainers
6
Weekly downloads
 
Created

What is ssri?

The ssri npm package is used for parsing, manipulating, serializing, generating, and verifying Subresource Integrity (SRI) hashes. SRI is a security feature that enables browsers to verify that resources they fetch (for example, from a CDN) are delivered without unexpected manipulation. It works by allowing you to provide a cryptographic hash that a fetched resource must match.

What are ssri's main functionalities?

Generating SRI Hashes

This feature allows you to generate SRI hashes from a given data input. The example code demonstrates how to create an SRI hash using the SHA-384 algorithm.

const ssri = require('ssri');
const integrity = ssri.fromData('some data to hash', {algorithms: ['sha384']});
console.log(integrity.toString());

Parsing SRI Hashes

This feature is used to parse an existing SRI hash string into an object that can be easily manipulated. The example code shows how to parse an SRI hash.

const ssri = require('ssri');
const integrity = ssri.parse('sha384-...');
console.log(integrity);

Verifying SRI Hashes

This feature allows you to verify that a piece of data matches a given SRI hash. The example code demonstrates how to verify the integrity of data against an SRI hash.

const ssri = require('ssri');
const data = 'some data to verify';
const sri = 'sha384-...';
ssri.checkData(data, sri).then(() => {
  console.log('Integrity verified');
}).catch(error => {
  console.log('Integrity verification failed');
});

Other packages similar to ssri

Keywords

FAQs

Package last updated on 25 Sep 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc