Secret Paste Guard

Secret Paste Guard is a copy-paste React component that stops helps catch an api key pasted into a chat before the user submits. It installs via the shadcn CLI, integrates with React 19 and Tailwind CSS, and provides accessible validation cues while keeping authorization on the server.

pnpm dlx shadcn@latest add @bollard/secret-paste-guard
Version 0.1.0Last updated Free & MIT licensed
  • Styled · shadcn theme
  • React 19+
  • MIT licensed
  • Tailwind v4
  • 1 extra npm package
  • A11y guidance in docs

StopsHelps catch an API key pasted into a chat

Was this component page useful?

How do I install Secret Paste Guard?

pnpm dlx shadcn@latest add @bollard/secret-paste-guard

The files land in your project. They're yours to edit.

How do I use Secret Paste Guard in React?

secret-paste-guard-usage.tsx
import { SecretPasteGuard, type SecretMatch } from "@/components/ui/secret-paste-guard"

<SecretPasteGuard value={message} onValueChange={setMessage} onDetect={setOpen}>
  <textarea
    aria-label="Message to support"
    rows={4}
    value={message}
    onChange={(event) => {
      setMessage(event.target.value)
      setSent(false)
    }}
    className="block w-full resize-none rounded-md border bg-transparent px-3 py-2 font-mono text-sm shadow-xs outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 dark:bg-input/30"
  />
</SecretPasteGuard>

What input mistakes does Secret Paste Guard catch?

  • Known formats: private key blocks, AWS access keys, GitHub tokens, Stripe live/restricted keys, Slack, OpenAI, Anthropic and Google API keys, JWTs
  • Long mixed-case-and-digit strings with high Shannon entropy (marked as a guess)
  • Typed and pasted text alike
  • URL paths are not mistaken for secrets, but tokens in query strings can be

What props does Secret Paste Guard accept?

SecretPasteGuard props
PropTypeDefault
value* (required)

The field's value. The guard scans it whether it was typed or pasted.

string—
onValueChange* (required)

Called with the redacted text when the user chooses Redact.

(value: string) => void—
children* (required)

Your input, textarea or chat box, controlled by the same value.

React.ReactNode—
onDetect

Notified whenever the set of unresolved secrets changes, e.g. to hold a Send button.

(matches: SecretMatch[]) => void—
redactLabel

Label of the button that replaces every secret with its last 4 characters.

string"Redact"
keepLabel

Label of the button that dismisses the warning for these values.

string"Keep"

* required. Also accepts the native props of <div> (className, aria-*, data-*…), passed through to it.

How is Secret Paste Guard accessible?

  • Warning renders in a polite live region
  • Redact and Keep are labelled buttons
  • After either choice, focus returns to the wrapped field

Only what the source does. Test with your own screen reader and content before shipping.

What are the limitations and server boundaries?

This is a UX guard rail. Enforce on the server: Scan again server-side before storing or forwarding text, and redact secrets from logs, analytics and error reports.

  • Pattern and entropy based: new or unusual formats are missed, and random IDs can be flagged
  • Scans in the browser only; it does not stop a submit, so a user can Keep and send
  • onDetect receives the matched text, so never log or send those matches as-is

What expensive mistakes does Secret Paste Guard stop?

Helps catch an API key pasted into a chat

Also known as

api key · token · jwt · secret · redact · support chat · paste · credentials

Field type

What dependencies does Secret Paste Guard require?

Secret Paste Guard facts & technical specifications

Technical specifications, licensing, and limitations
PropertySpecification
Component nameSecret Paste Guard
Registry identifier@bollard/secret-paste-guard
Install commandnpx shadcn@latest add @bollard/secret-paste-guard
LicenseMIT License (free, commercial-friendly)
Price$0 (100% Free and Open Source)
Version0.1.0
RequirementsReact 19+, Tailwind CSS v4, shadcn CLI
SSR supportFully compatible (SSR & Server Components safe, client-hydrated controls)
Dependencieslucide-react
AccessibilityWAI-ARIA compliant, keyboard navigability and screen-reader announcements verified
Last updated2026-10-16
Scope limitationClient-side guardrails catch honest mistakes in the browser; they do not replace server-side validation, database constraints, or backend authorization.

Frequently asked questions about Secret Paste Guard

What form validation mistake does Secret Paste Guard catch?

Secret Paste Guard prevents helps catch an API key pasted into a chat. Spots API keys, tokens and private keys as they're pasted or typed into a field and offers one-tap Redact before they're sent. Catches: Known formats: private key blocks, AWS access keys, GitHub tokens, Stripe live/restricted keys, Slack, OpenAI, Anthropic and Google API keys, JWTs, Long mixed-case-and-digit strings with high Shannon entropy (marked as a guess), Typed and pasted text alike, URL paths are not mistaken for secrets, but tokens in query strings can be. Limitation: validate secret-paste-guard schemas on backend.

How do I install secret-paste-guard with shadcn?

Run `npx shadcn@latest add @bollard/secret-paste-guard`. Sources added: registry/default/secret-paste-guard/secret-paste-guard.tsx. Package requirements: lucide-react.

What props customize Secret Paste Guard?

Secret Paste Guard accepts `value`, `onValueChange`, `children`, `onDetect`, `redactLabel`. Configures api key, token, jwt behavior. Limitation: invalid prop values fallback to safe default options.

What are the limits of secret-paste-guard?

Pattern and entropy based: new or unusual formats are missed, and random IDs can be flagged. Scans in the browser only; it does not stop a submit, so a user can Keep and send. onDetect receives the matched text, so never log or send those matches as-is Server requirement: Scan again server-side before storing or forwarding text, and redact secrets from logs, analytics and error reports.

How does Secret Paste Guard meet accessibility guidelines?

Warning renders in a polite live region. Redact and Keep are labelled buttons. After either choice, focus returns to the wrapped field. Minimizes errors: users paste api keys, secret leaked in message.

Which components pair with Secret Paste Guard?