Appearance
configure-csp
This skill automates declaring Content Security Policy exceptions in a PPTB tool's package.json — the narrowly-scoped permissions a tool requests when it needs to reach a CDN, an external API, a webfont, or embed external content beyond the host's strict default policy. A developer reaches for it whenever a tool hits a CSP violation in the console, or before adding a new external dependency that the default policy would block.
Every exception this skill adds must use the most specific domain possible, carry an exceptionReason written for the end user, and be marked optional: true when the tool's core functionality doesn't strictly require it — the host only relaxes the default policy after the user explicitly consents to what the dialog shows.
When to use it
- "My tool is getting CSP violation errors in the console"
- "Add a CSP exception so I can call this external API"
- "I need to load a CDN library / webfont / external stylesheet"
- "Allow this tool to embed content from this domain in an iframe"
- "Let users click mailto links in my tool"
- Before submitting a tool to the registry, to confirm
cspExceptionsare minimal and justified
Inputs
- Which directive is needed:
connect-src,script-src,style-src,img-src,font-src,frame-src,media-src, ormailto - The specific external domain(s) the tool needs to reach
- Why the tool needs each domain (used to write
exceptionReason) - Whether the exception is essential to core functionality or merely enhances it (determines
optional) - Whether a bundling, backend-proxy, or built-in Dataverse API alternative was already considered
What it does
- Adds a
cspExceptionsobject topackage.json(if not already present) with an array under the relevant directive(s):connect-src,script-src,style-src,img-src,font-src,frame-src,media-src,mailto. - For each domain, adds an entry object with
domain(required),exceptionReason(markdown, written for the end user, shown in the consent dialog), andoptional: truewhen the feature is non-essential — defaultingoptionaltofalse/omitted otherwise. - Prefers the most specific domain pattern available (e.g.
https://cdn.example.comoverhttps://*.example.com), and refuses to generate a barehttps:scheme or an unscoped*. - Before adding an exception, checks for and surfaces alternatives: bundling the library instead of loading it from a CDN, proxying API calls through a secure backend, or using PPTB's built-in
dataverseAPIinstead of calling Dataverse endpoints directly. - Reminds the developer to reload the tool after editing
cspExceptionsso the consent dialog reflects the change. - Keeps the
cspExceptionsblock inpackage.jsonin sync with what will be submitted in the registry entry at publish time.
Example
Before: a tool with no cspExceptions that needs to call Power BI's embed API and load Mermaid from a CDN.
After (package.json):
json
{
"cspExceptions": {
"connect-src": [
{
"domain": "https://api.powerbi.com",
"exceptionReason": "Embeds Power BI reports."
},
{
"domain": "https://*.dynamics.com",
"exceptionReason": "Fetches Dataverse metadata."
}
],
"script-src": [
{
"domain": "https://cdn.jsdelivr.net/npm/mermaid@10",
"exceptionReason": "Loads the **Mermaid** library used to render entity relationship diagrams."
}
],
"style-src": [
{
"domain": "https://cdn.jsdelivr.net/npm/mermaid@10",
"exceptionReason": "Loads Mermaid's bundled stylesheet for diagram rendering.",
"optional": true
}
]
}
}Checklist it enforces
- [ ] Every requested exception uses the most specific domain possible — no bare
*or unscopedhttps:. - [ ] Every entry has an
exceptionReasonwritten for the end user, using markdown where helpful. - [ ] Non-essential exceptions are marked
optional: true. - [ ] Alternatives (bundling, backend proxy, built-in Dataverse API) were considered before requesting an exception.
- [ ] The tool is reloaded after editing
cspExceptionsto confirm the consent dialog reflects the change. - [ ]
cspExceptionsinpackage.jsonmatches what's submitted in the registry entry.
Related
- CSP Configuration — the CSP model and directive reference this skill is built on
- Related skills:
../create-pptb-tool/,../validate-pptb-tool/