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

@openpolicy/sdk

v0.0.34

Published

Public API for defining privacy policies with OpenPolicy

Readme

@openpolicy/sdk

TypeScript SDK for defining privacy and cookie policies as code.

Part of OpenPolicy — a policy-as-code framework that compiles legal agreements from TypeScript at build time.

Not legal advice. OpenPolicy generates policy documents from your config. It does not provide legal advice. Have a lawyer review your policies before publication. See the legal notice.

Install

bun add @openpolicy/sdk
# or: npm install @openpolicy/sdk

Usage

Privacy policy

// openpolicy.ts
import { ContractPrerequisite, defineConfig, LegalBases, Voluntary } from "@openpolicy/sdk";

export default defineConfig({
	company: {
		name: "Acme",
		legalName: "Acme, Inc.",
		address: "123 Main St, San Francisco, CA 94105",
		contact: { email: "[email protected]" },
	},
	effectiveDate: "2026-01-01",
	jurisdictions: ["eu", "us-ca"],
	data: {
		collected: {
			"Account information": ["Email address", "Display name"],
			"Usage data": ["Pages visited", "Session duration"],
		},
		context: {
			"Account information": {
				purpose: "To create and manage user accounts",
				lawfulBasis: LegalBases.Contract,
				retention: "Until account deletion",
				provision: ContractPrerequisite("We cannot create or operate your account."),
			},
			"Usage data": {
				purpose: "To understand product usage and improve the service",
				lawfulBasis: LegalBases.LegitimateInterests,
				retention: "13 months",
				provision: Voluntary("None — your service is unaffected."),
			},
		},
	},
	thirdParties: [
		{ name: "Vercel", purpose: "Hosting" },
		{ name: "Plausible", purpose: "Privacy-friendly analytics" },
	],
});

Cookie policy

// openpolicy.ts
import { defineConfig, LegalBases } from "@openpolicy/sdk";

export default defineConfig({
	company: {
		name: "Acme",
		legalName: "Acme, Inc.",
		address: "123 Main St, San Francisco, CA 94105",
		contact: { email: "[email protected]" },
	},
	effectiveDate: "2026-01-01",
	jurisdictions: ["eu", "us-ca"],
	cookies: {
		used: { essential: true, analytics: true, marketing: false },
		context: {
			essential: { lawfulBasis: LegalBases.LegalObligation },
			analytics: { lawfulBasis: LegalBases.Consent },
			marketing: { lawfulBasis: LegalBases.Consent },
		},
	},
});

Rendering policies

The SDK exports types and helper functions for defining policies. To render them in your app, pair it with one of:

  • @openpolicy/react<PrivacyPolicy /> / <CookiePolicy /> components for React
  • @openpolicy/vue — Vue 3 components
  • @openpolicy/vite — Vite plugin that scans source for collecting() / thirdParty() annotations at build time
  • @openpolicy/cli — one-command project setup: installs the right packages, scaffolds a config, and prints a prompt for your coding agent

Documentation

Full field reference and guides: openpolicy.sh/docs

AI Agents

If you use an AI coding agent (Claude Code, Cursor, Copilot, etc.), run:

npx @tanstack/intent@latest install

This installs skill files that give your agent accurate, up-to-date guidance for OpenPolicy APIs.

Links