1.0.2 • Published 5 years ago

csp-generator v1.0.2

Weekly downloads
5
License
MIT
Repository
github
Last release
5 years ago

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

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago