# resk-llm-ts: Open Source TypeScript Security Toolkit for LLM Applications

> Source: <https://dev.to/resk/resk-llm-ts-open-source-typescript-security-toolkit-for-llm-applications-h3j>
> Published: 2026-07-10 07:01:46+00:00

Links:

If you are building LLM-powered applications in Node.js or TypeScript, you have probably thought about security. Prompt injection, jailbreak attempts, PII leaks, and data exfiltration are real threats that traditional input sanitization does not catch at the LLM layer.

Most security toolkits are Python-only. TypeScript developers deserve the same protection.

resk-llm-ts is an open source TypeScript security toolkit with 11 threat detectors. It works as Express middleware, Hono middleware, or as an OpenAI-compatible wrapper.

```
npm install resk-llm-ts
js
import { LLMSecurity } from "resk-llm-ts";

const security = new LLMSecurity({
  enabledDetectors: ["injection", "jailbreak", "pii", "exfiltration"],
  mode: "block", // or "log"
});

// Use as middleware with Express
app.post("/api/chat", security.middleware(), async (req, res) => {
  // req.body has been scanned - threats are blocked or logged
  const response = await openai.chat.completions.create({
    model: "gpt-4",
    messages: req.body.messages,
  });
  res.json(response);
});
```

Or use the OpenAI-compatible wrapper:

``` js
import { SecureOpenAI } from "resk-llm-ts";

const client = new SecureOpenAI({
  apiKey: process.env.OPENAI_API_KEY,
  detectors: ["injection", "jailbreak"],
});

const response = await client.chat.completions.create({
  model: "gpt-4",
  messages: [{ role: "user", content: userInput }],
});
```

| Detector | Purpose |
|---|---|
| injection | Prompt injection detection |
| jailbreak | Jailbreak pattern recognition |
| pii | PII and sensitive data scanning |
| exfiltration | Data exfiltration prevention |
| code-injection | Code injection detection |
| toxic-content | Toxic content filtering |
| political | Political content detection |
| adversarial | Adversarial suffix detection |
| encoded-payload | Base64/hex encoded threat detection |
| role-play | Role-play manipulation detection |
| system-prompt | System prompt leak prevention |

Security for LLM applications should not be an afterthought. Add it as middleware and ship with confidence.

Check it out on GitHub: [https://github.com/Resk-Security/resk-llm-ts](https://github.com/Resk-Security/resk-llm-ts)

Install: [https://npmjs.com/package/resk-llm-ts](https://npmjs.com/package/resk-llm-ts)

Learn more: [https://resk.fr](https://resk.fr)
