PromptShield logo PromptShield
API DocsFunctions

scan()

scan(text, options?, context?): ScanResult

Defined in: core.ts:48

Core scanning entry point.

Executes all enabled detectors in priority order:

  1. Trojan Source (BIDI logic manipulation)
  2. Invisible characters
  3. Homoglyph spoofing
  4. Unicode normalization anomalies
  5. Smuggling techniques

The provided context object is shared across detectors and may be mutated for performance optimizations (e.g., caching line offsets).

Parameters

text

string

options?

ScanOptions = {}

context?

ScanContext = {}

Returns

ScanResult

Example

import { scan } from '@promptshield/core';

const result = scan("Hello\u200BWorld");
if (!result.isClean) {
  console.log(result.threats);
}

On this page