csp-generator

1.0.2 • Public • Published

csp-generator

Content Security Policy Generator

Install

Install with npm

$ npm install csp-generator

Or install with yarn

$ yarn add csp-generator
import CSP from 'csp-generator';

Or umd builds are also available

<script src="path/to/csp-generator.js"></script>

Will expose the global variable to window.CSP.

Usage

const csp = new CSP("script-src 'self' 'unsafe-inline'");
 
// Get a policy
csp.get('script-src');
 
// Add new policy
csp.append('style-src', "'self'");
 
// If there is already a policy, add a new value to the existing policy
csp.append('style-src', "'unsafe-inline'");
 
// Delete a policy
csp.delete('style-src');
 
// Delete a value in a policy
csp.delete('style-src', "'self'");
 
// Get a new csp
csp.generate();

License

MIT © Harvey Zack

Readme

Keywords

Package Sidebar

Install

npm i csp-generator

Weekly Downloads

1

Version

1.0.2

License

MIT

Unpacked Size

10.7 kB

Total Files

16

Last publish

Collaborators

  • zhw2590582