# content-security-policy-parser

> Parse Content Security Policy directives.

Latest version **0.6.0** (published 2024-02-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install content-security-policy-parser
pnpm add content-security-policy-parser
yarn add content-security-policy-parser
bun add content-security-policy-parser
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.6.0 |
| Published | 2024-02-10 |
| First published | 2015-12-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=18.0.0 |
| Dependencies | 0 |
| Unpacked size | 11.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Evan Hahn |
| Maintainers | evanhahn |
| Keywords | security, content, security, policy, csp, parser |

## Links

- npm: https://www.npmjs.com/package/content-security-policy-parser
- Repository: https://github.com/helmetjs/content-security-policy-parser
- Issues: https://github.com/helmetjs/content-security-policy-parser/issues
- npm.io page: https://npm.io/package/content-security-policy-parser

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 0.6.0 (latest) — 2024-02-10
- 0.5.0 — 2024-01-26
- 0.4.1 — 2022-03-24
- 0.4.0 — 2020-12-22
- 0.3.0 — 2019-09-02
- 0.2.0 — 2019-06-15
- 0.1.1 — 2017-08-30
- 0.1.0 — 2015-12-18

## README

# Content Security Policy parser

Take a Content Security Policy string and parse it via
[the spec](https://w3c.github.io/webappsec-csp/#parse-serialized-policy).

Usage:

```javascript
import parseContentSecurityPolicy from "content-security-policy-parser";

parseContentSecurityPolicy(
  "default-src 'self'; script-src 'unsafe-eval' scripts.example; object-src; style-src styles.example",
);
// => Map(4) {
//      "default-src" => ["'self'"],
//      "script-src" => ["'unsafe-eval'", "scripts.example"],
//      "object-src" => [],
//      "style-src" => ["styles.example"],
//    }
```

This module is considered "complete". I expect to continue maintenance if
needed, but I don't plan to add features or make breaking changes.

---
_Source: https://npm.io/package/content-security-policy-parser · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
