Home/Tools/@tpmjs/tools-csp-compose

cspComposeTool

@tpmjs/tools-csp-compose

Compose a Content Security Policy (CSP) header from directive configurations. Validates directives, checks for security issues, and determines if the policy is strict. Returns the formatted CSP header string, directive details, and security warnings.

Official
security
v0.2.0
MIT

Interactive Playground

Test @tpmjs/tools-csp-compose (cspComposeTool) with AI-powered execution

0/2000 characters

Installation & Usage

Install this tool and use it with the AI SDK

1. Install the package

npm install @tpmjs/tools-csp-compose
pnpm add @tpmjs/tools-csp-compose
yarn add @tpmjs/tools-csp-compose
bun add @tpmjs/tools-csp-compose
deno add npm:@tpmjs/tools-csp-compose

2. Import the tool

import { cspComposeTool } from '@tpmjs/tools-csp-compose';

3. Use with AI SDK

import { generateText } from 'ai';
import { openai } from '@ai-sdk/openai';
import { cspComposeTool } from '@tpmjs/tools-csp-compose';

const result = await generateText({
  model: openai('gpt-4o'),
  tools: { cspComposeTool },
  prompt: 'Your prompt here...',
});

console.log(result.text);

Parameters

Available configuration options

Auto-extracted
policies
Required
Type: object

CSP directives mapped to arrays of source values. Example: { "default-src": ["'self'"], "script-src": ["'nonce-abc123'", "https://cdn.example.com"] }

Schema extracted: 1/1/2026, 1:05:58 AM

README

ERROR: No README data found!

Statistics

Downloads/month

0

Quality Score

67%

Bundle Size

NPM Keywords

tpmjs
security
csp
content-security-policy

Maintainers

thomasdavis(thomasalwyndavis@gmail.com)

Frameworks

vercel-ai