npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@ibmcloud/ajv-csp-compatibility

v8.20.0-csp.1

Published

Another JSON Schema Validator

Downloads

283

Readme

 

🛠️ About This Fork

This is a fork of ajv (based on v8.20.0) created to improve Content Security Policy (CSP) compliance for secure web environments.

🚨 Why Fork?

Upstream Ajv compiles every JSON Schema (and JSON Type Definition parser/serializer) into JavaScript source code and turns it into a function using new Function(). This is blocked under CSP unless unsafe-eval is allowed in script-src, which presents security concerns for browser-based applications that enforce strict CSP rules. Without unsafe-eval, schema compilation fails with an error like:

EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script

✅ What Was Changed

  • 🔁 Replaced new Function() with the SVAL JavaScript interpreter (see lib/interprete.ts), so the generated validation code is interpreted instead of evaluated. This applies to:
  • 🧪 Adjusted unit tests to work with the interpreted functions.
  • 🔒 Ensures JSON Schema validation can run in environments with strict CSP (e.g. browsers without unsafe-eval).
  • 📦 Adds the sval runtime dependency.

Ajv JSON schema validator

JSON validator for Node.js and browser. Upstream Ajv is the fastest JSON validator, but this fork trades some of that speed for CSP compatibility (see Performance).

Supports JSON Schema draft-04/06/07/2019-09/2020-12 (draft-04 support requires ajv-draft-04 package) and JSON Type Definition RFC8927.

build npm npm downloads Coverage Status SimpleX Gitter GitHub Sponsors

Ajv sponsors

Contributing

More than 100 people contributed to Ajv, and we would love to have you join the development. We welcome implementing new features that will benefit many users and ideas to improve our documentation.

Please review Contributing guidelines and Code components.

Documentation

All documentation is available on the Ajv website.

Some useful site links:

Please sponsor Ajv development

Since I asked to support Ajv development 40 people and 6 organizations contributed via GitHub and OpenCollective - this support helped receiving the MOSS grant!

Your continuing support is very important - the funds will be used to develop and maintain Ajv once the next major version is released.

Please sponsor Ajv via:

Thank you.

Open Collective sponsors

Performance

Note for this fork: the generated validation code is executed by the SVAL interpreter instead of new Function(), so it is not JIT-compiled by V8. Validation is slower than in upstream Ajv, and the benchmarks below describe upstream Ajv only. If your environment allows unsafe-eval and you need maximum performance, use upstream ajv.

Upstream Ajv generates code to turn JSON Schemas into super-fast validation functions that are efficient for v8 optimization.

Upstream Ajv is the fastest and the most standard compliant validator according to these benchmarks:

Performance of different validators by json-schema-benchmark:

performance

Features

Install

To install version 8:

npm install ajv-csp-compatibility

Getting started

In JavaScript:

// or ESM/TypeScript import
import Ajv from "ajv-csp-compatibility"
// Node.js require:
const Ajv = require("ajv-csp-compatibility")

const ajv = new Ajv() // options can be passed, e.g. {allErrors: true}

const schema = {
  type: "object",
  properties: {
    foo: {type: "integer"},
    bar: {type: "string"},
  },
  required: ["foo"],
  additionalProperties: false,
}

const data = {
  foo: 1,
  bar: "abc",
}

const validate = ajv.compile(schema)
const valid = validate(data)
if (!valid) console.log(validate.errors)

Learn how to use Ajv and see more examples in the Guide: getting started

Changes history

See https://github.com/ajv-validator/ajv/releases

Please note: Changes in version 8.0.0

Version 7.0.0

Version 6.0.0.

Code of conduct

Please review and follow the Code of conduct.

Please report any unacceptable behaviour to [email protected] - it will be reviewed by the project team.

Security contact

To report a security vulnerability, please use the Tidelift security contact. Tidelift will coordinate the fix and disclosure. Please do NOT report security vulnerabilities via GitHub issues.

Open-source software support

Ajv is a part of Tidelift subscription - it provides a centralised support to open-source software users, in addition to the support provided by software maintainers.

License

MIT