csp-generator
v1.0.2
Published
Content Security Policy Generator
Downloads
4
Readme
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