prompt-chainmail
Version:
Security middleware that shields AI applications from prompt injection, jailbreaking, and obfuscated attacks through composable defense layers.
60 lines • 1.75 kB
TypeScript
import { Rivets, applyThreatPenalty } from "./rivets/index";
import { Chainmails } from "./chainmails/index";
import { ChainmailResult, ChainmailRivet } from "./types";
export { Rivets, Chainmails, applyThreatPenalty };
export type { ChainmailRivet };
/**
* Core chainmail class for forging security rivets
*
* @example
* ```typescript
* const chainmail = new PromptChainmail()
* .forge(Rivets.sanitize())
* .forge(Rivets.patternDetection())
* .forge(Rivets.confidenceFilter(0.7));
*
* const result = await chainmail.protect(userInput);
* ```
*/
export declare class PromptChainmail {
private rivets;
/**
* Forge a new rivet into the chainmail
*/
forge(rivet: ChainmailRivet): this;
/**
* Protect input by running it through all forged rivets
*/
protect(input: string | ReadableStream | ArrayBuffer | Uint8Array): Promise<ChainmailResult>;
/**
* Convert a large string to ReadableStream for chunked processing
*/
private stringToStream;
/**
* Protect string input (original implementation)
*/
private protectString;
/**
* Protect streaming input by processing chunks
*/
private protectStream;
private processChunkThroughRivets;
private createStreamResult;
/**
* Create a protected context that prevents blocked property from being unset once locked
*/
private createContext;
/**
* Create a secure result that derives success from blocked state
*/
private createResult;
/**
* Create a new chainmail with the same rivets
*/
clone(): PromptChainmail;
/**
* Get the number of rivets in the chainmail
*/
get length(): number;
}
//# sourceMappingURL=index.d.ts.map