1. sri-toolbox
Subresource Integrity tools
sri-toolbox
Package: sri-toolbox
Created by: neftaly
Last modified: Sun, 26 Jun 2022 23:24:29 GMT
Version: 0.2.0
License: MIT
Downloads: 432,303
Repository: https://github.com/neftaly/npm-sri-toolbox

Install

npm install sri-toolbox
yarn add sri-toolbox

sri-toolbox Build Status Coverage Status

Subresource Integrity tools.

SemVer note: As the SRI spec has not yet been finalized, minor releases < 1.0.0 will contain breaking changes.

Install

 npm install sri-toolbox

Usage

 var sriToolbox = require("sri-toolbox");

var jquerySourceCode = file("jquery-1.10.2.min.js");

var integrity = sriToolbox.generate({
    algorithms: ["sha256"]
}, jquerySourceCode);
//=> "sha256-C6CB9UYIS9UJeqinPHWTHVqh/E1uhG5Twh+Y5qFQmYg="

You may also access the data used to build the integrity attribute, using the option "full":

 var integrityObject = sriToolbox.generate({
    full: true
}, jquerySourceCode);
//=> object
 {
    "hashes": {
        "sha256": "C6CB9UYIS9UJeqinPHWTHVqh/E1uhG5Twh+Y5qFQmYg="
    },
    "integrity": "sha256-C6CB9UYIS9UJeqinPHWTHVqh/E1uhG5Twh+Y5qFQmYg="
}

API

generate

Generate creates a Sub-resource Integrity attribute from a data string.

Options

Key: type name = default

  • array algorithms = ["sha256"]
    List of hashing algorithms

  • string delimiter = " "
    Integrity attribute delimiter

  • boolean full = false
    Return a string if false, object if true. See example.

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code