1.0.1 • Published 2 years ago

html-csp-hash-generator v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

html-csp-hash-generator

Tool to generate hash for inline scripts and styles for CSP.

Usage

const { readFileSync } = require('fs');
const getCspHashes = require('html-csp-hash-generator');

const html = readFileSync('index.html', { encoding: 'utf8' });
const hashes = getCspHashes(html);

const staticPreset = {
    [csp.SCRIPT]: [cdnHost, ...hashes.scripts],
    [csp.STYLE]: [cdnHost, ...hashes.styles],
};

Coverage

coverage