New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

cspeasy

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cspeasy

A simple way to setup Content Security Policy even with inline scripts and styles!

  • 0.4.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-50%
Maintainers
1
Weekly downloads
 
Created
Source

cspeasy

A simple way to setup Content Security Policy even with inline scripts and styles!

It digests HTML documents so you can have a strong CSP with necessary inline scripts and styles (e.g. Google Analytics).

Example

import { createServer } from "http";
import { readFile } from "fs";
import { ContentSecurityPolicy, Policies } from "../src/main";
import { resolve } from "path";

const server = createServer((req, res) => {
    const csp = new ContentSecurityPolicy({
        defaultSrc: Policies.None,
    });

    readFile(resolve("test/index.html"), null, (error, data) => {
        if (error) {
            throw error;            
        }

        const indexString = data.toString();

        const hashedCsp = csp.addDocument(indexString);

        res.setHeader("Content-Security-Policy", hashedCsp.getHeaderValue());

        res.end(indexString);
    });
});

const port = 3000;

server.listen(port, () => console.log(`listening on ${port}`));

FAQs

Package last updated on 17 Jun 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc