llm-trust-guard 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +318 -0
- package/dist/guards/agent-communication-guard.d.ts +169 -0
- package/dist/guards/agent-communication-guard.d.ts.map +1 -0
- package/dist/guards/agent-communication-guard.js +468 -0
- package/dist/guards/agent-communication-guard.js.map +1 -0
- package/dist/guards/autonomy-escalation-guard.d.ts +137 -0
- package/dist/guards/autonomy-escalation-guard.d.ts.map +1 -0
- package/dist/guards/autonomy-escalation-guard.js +470 -0
- package/dist/guards/autonomy-escalation-guard.js.map +1 -0
- package/dist/guards/circuit-breaker.d.ts +142 -0
- package/dist/guards/circuit-breaker.d.ts.map +1 -0
- package/dist/guards/circuit-breaker.js +347 -0
- package/dist/guards/circuit-breaker.js.map +1 -0
- package/dist/guards/code-execution-guard.d.ts +114 -0
- package/dist/guards/code-execution-guard.d.ts.map +1 -0
- package/dist/guards/code-execution-guard.js +467 -0
- package/dist/guards/code-execution-guard.js.map +1 -0
- package/dist/guards/conversation-guard.d.ts +73 -0
- package/dist/guards/conversation-guard.d.ts.map +1 -0
- package/dist/guards/conversation-guard.js +281 -0
- package/dist/guards/conversation-guard.js.map +1 -0
- package/dist/guards/drift-detector.d.ts +182 -0
- package/dist/guards/drift-detector.d.ts.map +1 -0
- package/dist/guards/drift-detector.js +480 -0
- package/dist/guards/drift-detector.js.map +1 -0
- package/dist/guards/encoding-detector.d.ts +76 -0
- package/dist/guards/encoding-detector.d.ts.map +1 -0
- package/dist/guards/encoding-detector.js +698 -0
- package/dist/guards/encoding-detector.js.map +1 -0
- package/dist/guards/execution-monitor.d.ts +73 -0
- package/dist/guards/execution-monitor.d.ts.map +1 -0
- package/dist/guards/execution-monitor.js +205 -0
- package/dist/guards/execution-monitor.js.map +1 -0
- package/dist/guards/input-sanitizer.d.ts +87 -0
- package/dist/guards/input-sanitizer.d.ts.map +1 -0
- package/dist/guards/input-sanitizer.js +301 -0
- package/dist/guards/input-sanitizer.js.map +1 -0
- package/dist/guards/mcp-security-guard.d.ts +204 -0
- package/dist/guards/mcp-security-guard.d.ts.map +1 -0
- package/dist/guards/mcp-security-guard.js +618 -0
- package/dist/guards/mcp-security-guard.js.map +1 -0
- package/dist/guards/memory-guard.d.ts +124 -0
- package/dist/guards/memory-guard.d.ts.map +1 -0
- package/dist/guards/memory-guard.js +476 -0
- package/dist/guards/memory-guard.js.map +1 -0
- package/dist/guards/multimodal-guard.d.ts +93 -0
- package/dist/guards/multimodal-guard.d.ts.map +1 -0
- package/dist/guards/multimodal-guard.js +507 -0
- package/dist/guards/multimodal-guard.js.map +1 -0
- package/dist/guards/output-filter.d.ts +76 -0
- package/dist/guards/output-filter.d.ts.map +1 -0
- package/dist/guards/output-filter.js +289 -0
- package/dist/guards/output-filter.js.map +1 -0
- package/dist/guards/policy-gate.d.ts +57 -0
- package/dist/guards/policy-gate.d.ts.map +1 -0
- package/dist/guards/policy-gate.js +182 -0
- package/dist/guards/policy-gate.js.map +1 -0
- package/dist/guards/prompt-leakage-guard.d.ts +110 -0
- package/dist/guards/prompt-leakage-guard.d.ts.map +1 -0
- package/dist/guards/prompt-leakage-guard.js +529 -0
- package/dist/guards/prompt-leakage-guard.js.map +1 -0
- package/dist/guards/rag-guard.d.ts +188 -0
- package/dist/guards/rag-guard.d.ts.map +1 -0
- package/dist/guards/rag-guard.js +769 -0
- package/dist/guards/rag-guard.js.map +1 -0
- package/dist/guards/schema-validator.d.ts +35 -0
- package/dist/guards/schema-validator.d.ts.map +1 -0
- package/dist/guards/schema-validator.js +316 -0
- package/dist/guards/schema-validator.js.map +1 -0
- package/dist/guards/state-persistence-guard.d.ts +153 -0
- package/dist/guards/state-persistence-guard.d.ts.map +1 -0
- package/dist/guards/state-persistence-guard.js +484 -0
- package/dist/guards/state-persistence-guard.js.map +1 -0
- package/dist/guards/tenant-boundary.d.ts +67 -0
- package/dist/guards/tenant-boundary.d.ts.map +1 -0
- package/dist/guards/tenant-boundary.js +187 -0
- package/dist/guards/tenant-boundary.js.map +1 -0
- package/dist/guards/tool-chain-validator.d.ts +102 -0
- package/dist/guards/tool-chain-validator.d.ts.map +1 -0
- package/dist/guards/tool-chain-validator.js +480 -0
- package/dist/guards/tool-chain-validator.js.map +1 -0
- package/dist/guards/tool-registry.d.ts +45 -0
- package/dist/guards/tool-registry.d.ts.map +1 -0
- package/dist/guards/tool-registry.js +155 -0
- package/dist/guards/tool-registry.js.map +1 -0
- package/dist/guards/trust-exploitation-guard.d.ts +134 -0
- package/dist/guards/trust-exploitation-guard.d.ts.map +1 -0
- package/dist/guards/trust-exploitation-guard.js +354 -0
- package/dist/guards/trust-exploitation-guard.js.map +1 -0
- package/dist/index.d.ts +133 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +430 -0
- package/dist/index.js.map +1 -0
- package/dist/integrations/express.d.ts +119 -0
- package/dist/integrations/express.d.ts.map +1 -0
- package/dist/integrations/express.js +244 -0
- package/dist/integrations/express.js.map +1 -0
- package/dist/integrations/index.d.ts +9 -0
- package/dist/integrations/index.d.ts.map +1 -0
- package/dist/integrations/index.js +26 -0
- package/dist/integrations/index.js.map +1 -0
- package/dist/integrations/langchain.d.ts +165 -0
- package/dist/integrations/langchain.d.ts.map +1 -0
- package/dist/integrations/langchain.js +308 -0
- package/dist/integrations/langchain.js.map +1 -0
- package/dist/integrations/openai.d.ts +205 -0
- package/dist/integrations/openai.d.ts.map +1 -0
- package/dist/integrations/openai.js +380 -0
- package/dist/integrations/openai.js.map +1 -0
- package/dist/types/index.d.ts +245 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +6 -0
- package/dist/types/index.js.map +1 -0
- package/package.json +64 -0
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* LangChain Integration for llm-trust-guard
|
|
4
|
+
*
|
|
5
|
+
* Provides callbacks, wrappers, and utilities for securing
|
|
6
|
+
* LangChain-based applications.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.TrustGuardViolationError = exports.TrustGuardLangChain = void 0;
|
|
10
|
+
exports.createInputValidator = createInputValidator;
|
|
11
|
+
exports.createOutputFilter = createOutputFilter;
|
|
12
|
+
const index_js_1 = require("../index.js");
|
|
13
|
+
/**
|
|
14
|
+
* TrustGuard wrapper for LangChain
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* import { ChatOpenAI } from '@langchain/openai';
|
|
19
|
+
* import { TrustGuardLangChain } from 'llm-trust-guard/integrations/langchain';
|
|
20
|
+
*
|
|
21
|
+
* const guard = new TrustGuardLangChain({
|
|
22
|
+
* validateInput: true,
|
|
23
|
+
* filterOutput: true,
|
|
24
|
+
* throwOnViolation: true
|
|
25
|
+
* });
|
|
26
|
+
*
|
|
27
|
+
* // Validate before sending to LLM
|
|
28
|
+
* const result = guard.validateInput(userMessage);
|
|
29
|
+
* if (!result.allowed) {
|
|
30
|
+
* throw new Error(`Blocked: ${result.violations.join(', ')}`);
|
|
31
|
+
* }
|
|
32
|
+
*
|
|
33
|
+
* // Use with LangChain
|
|
34
|
+
* const llm = new ChatOpenAI();
|
|
35
|
+
* const response = await llm.invoke(result.sanitizedInput || userMessage);
|
|
36
|
+
*
|
|
37
|
+
* // Filter output before returning to user
|
|
38
|
+
* const filtered = guard.filterOutput(response.content);
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
class TrustGuardLangChain {
|
|
42
|
+
constructor(config = {}) {
|
|
43
|
+
this.config = {
|
|
44
|
+
validateInput: true,
|
|
45
|
+
filterOutput: true,
|
|
46
|
+
validateTools: true,
|
|
47
|
+
throwOnViolation: false,
|
|
48
|
+
...config,
|
|
49
|
+
};
|
|
50
|
+
this.inputSanitizer = new index_js_1.InputSanitizer(config.sanitizerConfig);
|
|
51
|
+
this.encodingDetector = new index_js_1.EncodingDetector();
|
|
52
|
+
this.memoryGuard = new index_js_1.MemoryGuard();
|
|
53
|
+
this.toolChainValidator = new index_js_1.ToolChainValidator();
|
|
54
|
+
this.outputFilter = new index_js_1.OutputFilter(config.outputConfig);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Validate user input before sending to LLM
|
|
58
|
+
*/
|
|
59
|
+
validateInput(input, requestId) {
|
|
60
|
+
const reqId = requestId || `lc-${Date.now()}`;
|
|
61
|
+
// Check input sanitization
|
|
62
|
+
const sanitizeResult = this.inputSanitizer.sanitize(input, reqId);
|
|
63
|
+
if (!sanitizeResult.allowed) {
|
|
64
|
+
this.handleViolation("input_sanitization", sanitizeResult);
|
|
65
|
+
return {
|
|
66
|
+
allowed: false,
|
|
67
|
+
guard: "InputSanitizer",
|
|
68
|
+
violations: sanitizeResult.violations,
|
|
69
|
+
sanitizedInput: sanitizeResult.sanitizedInput,
|
|
70
|
+
details: sanitizeResult,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
// Check encoding attacks
|
|
74
|
+
const encodingResult = this.encodingDetector.detect(input, reqId);
|
|
75
|
+
if (!encodingResult.allowed) {
|
|
76
|
+
this.handleViolation("encoding_attack", encodingResult);
|
|
77
|
+
return {
|
|
78
|
+
allowed: false,
|
|
79
|
+
guard: "EncodingDetector",
|
|
80
|
+
violations: encodingResult.violations,
|
|
81
|
+
details: encodingResult,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
return {
|
|
85
|
+
allowed: true,
|
|
86
|
+
guard: "all",
|
|
87
|
+
violations: [],
|
|
88
|
+
sanitizedInput: sanitizeResult.sanitizedInput,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Validate context/memory before injection
|
|
93
|
+
*/
|
|
94
|
+
validateContext(context, sessionId, requestId) {
|
|
95
|
+
const reqId = requestId || `lc-ctx-${Date.now()}`;
|
|
96
|
+
const result = this.memoryGuard.validateContextInjection(context, sessionId, reqId);
|
|
97
|
+
if (!result.allowed) {
|
|
98
|
+
this.handleViolation("context_injection", result);
|
|
99
|
+
return {
|
|
100
|
+
allowed: false,
|
|
101
|
+
guard: "MemoryGuard",
|
|
102
|
+
violations: result.violations,
|
|
103
|
+
details: result,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
return {
|
|
107
|
+
allowed: true,
|
|
108
|
+
guard: "MemoryGuard",
|
|
109
|
+
violations: [],
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Validate RAG documents before context injection
|
|
114
|
+
*/
|
|
115
|
+
validateDocuments(documents, sessionId) {
|
|
116
|
+
const violations = [];
|
|
117
|
+
for (let i = 0; i < documents.length; i++) {
|
|
118
|
+
const doc = documents[i];
|
|
119
|
+
// Check content for injections
|
|
120
|
+
const contentResult = this.memoryGuard.validateContextInjection(doc.content, sessionId);
|
|
121
|
+
if (!contentResult.allowed) {
|
|
122
|
+
violations.push(`doc[${i}]: ${contentResult.violations.join(", ")}`);
|
|
123
|
+
}
|
|
124
|
+
// Check for encoded threats
|
|
125
|
+
const encodingResult = this.encodingDetector.detect(doc.content);
|
|
126
|
+
if (!encodingResult.allowed) {
|
|
127
|
+
violations.push(`doc[${i}]: encoded threat detected`);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
if (violations.length > 0) {
|
|
131
|
+
this.handleViolation("document_validation", { violations });
|
|
132
|
+
return {
|
|
133
|
+
allowed: false,
|
|
134
|
+
guard: "DocumentValidator",
|
|
135
|
+
violations,
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
return {
|
|
139
|
+
allowed: true,
|
|
140
|
+
guard: "DocumentValidator",
|
|
141
|
+
violations: [],
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Validate tool calls before execution
|
|
146
|
+
*/
|
|
147
|
+
validateToolCall(toolName, toolArgs, sessionId) {
|
|
148
|
+
// Register the tool call
|
|
149
|
+
const result = this.toolChainValidator.validate(sessionId, toolName);
|
|
150
|
+
if (!result.allowed) {
|
|
151
|
+
this.handleViolation("tool_call", result);
|
|
152
|
+
return {
|
|
153
|
+
allowed: false,
|
|
154
|
+
guard: "ToolChainValidator",
|
|
155
|
+
violations: result.violations,
|
|
156
|
+
details: result,
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
return {
|
|
160
|
+
allowed: true,
|
|
161
|
+
guard: "ToolChainValidator",
|
|
162
|
+
violations: [],
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Filter LLM output before returning to user
|
|
167
|
+
*/
|
|
168
|
+
filterOutput(output, requestId) {
|
|
169
|
+
if (!this.config.filterOutput) {
|
|
170
|
+
return output;
|
|
171
|
+
}
|
|
172
|
+
const reqId = requestId || `lc-out-${Date.now()}`;
|
|
173
|
+
const result = this.outputFilter.filter(output, reqId);
|
|
174
|
+
if (result.filtered_response !== output) {
|
|
175
|
+
this.handleViolation("output_filtered", {
|
|
176
|
+
original: output.substring(0, 100),
|
|
177
|
+
pii_detected: result.pii_detected.length,
|
|
178
|
+
secrets_detected: result.secrets_detected.length,
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
return typeof result.filtered_response === 'string' ? result.filtered_response : output;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Create a secure message processor
|
|
185
|
+
*/
|
|
186
|
+
createSecureProcessor(sessionId) {
|
|
187
|
+
return {
|
|
188
|
+
/**
|
|
189
|
+
* Process user message with full validation
|
|
190
|
+
*/
|
|
191
|
+
processUserMessage: (message) => {
|
|
192
|
+
const result = this.validateInput(message);
|
|
193
|
+
return {
|
|
194
|
+
allowed: result.allowed,
|
|
195
|
+
message: result.sanitizedInput || message,
|
|
196
|
+
violations: result.violations,
|
|
197
|
+
};
|
|
198
|
+
},
|
|
199
|
+
/**
|
|
200
|
+
* Process context/RAG content
|
|
201
|
+
*/
|
|
202
|
+
processContext: (context) => {
|
|
203
|
+
const result = this.validateContext(context, sessionId);
|
|
204
|
+
return {
|
|
205
|
+
allowed: result.allowed,
|
|
206
|
+
violations: result.violations,
|
|
207
|
+
};
|
|
208
|
+
},
|
|
209
|
+
/**
|
|
210
|
+
* Process tool call
|
|
211
|
+
*/
|
|
212
|
+
processToolCall: (tool, args) => {
|
|
213
|
+
const result = this.validateToolCall(tool, args, sessionId);
|
|
214
|
+
return {
|
|
215
|
+
allowed: result.allowed,
|
|
216
|
+
violations: result.violations,
|
|
217
|
+
};
|
|
218
|
+
},
|
|
219
|
+
/**
|
|
220
|
+
* Process LLM output
|
|
221
|
+
*/
|
|
222
|
+
processOutput: (output) => {
|
|
223
|
+
return this.filterOutput(output);
|
|
224
|
+
},
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
handleViolation(type, details) {
|
|
228
|
+
if (this.config.onViolation) {
|
|
229
|
+
this.config.onViolation(type, details);
|
|
230
|
+
}
|
|
231
|
+
if (this.config.throwOnViolation) {
|
|
232
|
+
throw new TrustGuardViolationError(type, details);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
exports.TrustGuardLangChain = TrustGuardLangChain;
|
|
237
|
+
/**
|
|
238
|
+
* Error thrown when throwOnViolation is true
|
|
239
|
+
*/
|
|
240
|
+
class TrustGuardViolationError extends Error {
|
|
241
|
+
constructor(type, details) {
|
|
242
|
+
super(`Trust guard violation: ${type}`);
|
|
243
|
+
this.name = "TrustGuardViolationError";
|
|
244
|
+
this.type = type;
|
|
245
|
+
this.details = details;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
exports.TrustGuardViolationError = TrustGuardViolationError;
|
|
249
|
+
/**
|
|
250
|
+
* Create a simple input validator function for use with LangChain
|
|
251
|
+
*
|
|
252
|
+
* @example
|
|
253
|
+
* ```typescript
|
|
254
|
+
* const validateInput = createInputValidator();
|
|
255
|
+
*
|
|
256
|
+
* // In your chain
|
|
257
|
+
* const chain = RunnableSequence.from([
|
|
258
|
+
* new RunnableLambda({ func: (input) => {
|
|
259
|
+
* const result = validateInput(input.message);
|
|
260
|
+
* if (!result.allowed) throw new Error('Blocked');
|
|
261
|
+
* return { ...input, message: result.sanitized };
|
|
262
|
+
* }}),
|
|
263
|
+
* prompt,
|
|
264
|
+
* llm,
|
|
265
|
+
* outputParser
|
|
266
|
+
* ]);
|
|
267
|
+
* ```
|
|
268
|
+
*/
|
|
269
|
+
function createInputValidator(config) {
|
|
270
|
+
const sanitizer = new index_js_1.InputSanitizer(config);
|
|
271
|
+
const encoder = new index_js_1.EncodingDetector();
|
|
272
|
+
return function validateInput(input) {
|
|
273
|
+
const sanitizeResult = sanitizer.sanitize(input);
|
|
274
|
+
if (!sanitizeResult.allowed) {
|
|
275
|
+
return {
|
|
276
|
+
allowed: false,
|
|
277
|
+
sanitized: sanitizeResult.sanitizedInput,
|
|
278
|
+
violations: sanitizeResult.violations,
|
|
279
|
+
pap: sanitizeResult.pap,
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
const encodingResult = encoder.detect(input);
|
|
283
|
+
if (!encodingResult.allowed) {
|
|
284
|
+
return {
|
|
285
|
+
allowed: false,
|
|
286
|
+
sanitized: input,
|
|
287
|
+
violations: encodingResult.violations,
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
return {
|
|
291
|
+
allowed: true,
|
|
292
|
+
sanitized: sanitizeResult.sanitizedInput,
|
|
293
|
+
violations: [],
|
|
294
|
+
pap: sanitizeResult.pap,
|
|
295
|
+
};
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Create an output filter function for use with LangChain
|
|
300
|
+
*/
|
|
301
|
+
function createOutputFilter(config) {
|
|
302
|
+
const filter = new index_js_1.OutputFilter(config);
|
|
303
|
+
return function filterOutput(output) {
|
|
304
|
+
const result = filter.filter(output);
|
|
305
|
+
return typeof result.filtered_response === 'string' ? result.filtered_response : output;
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
//#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,CAAC;AAED;;GAEG;AACH,SAAgB,kBAAkB,CAAC,MAAsD;IACvF,MAAM,MAAM,GAAG,IAAI,uBAAY,CAAC,MAAM,CAAC,CAAC;IAExC,OAAO,SAAS,YAAY,CAAC,MAAc;QACzC,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACrC,OAAO,OAAO,MAAM,CAAC,iBAAiB,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC,CAAC,MAAM,CAAC;IAC1F,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenAI Integration for llm-trust-guard
|
|
3
|
+
*
|
|
4
|
+
* Provides wrappers and utilities for securing OpenAI API calls.
|
|
5
|
+
* Works with both the official OpenAI SDK and direct API calls.
|
|
6
|
+
*/
|
|
7
|
+
import { InputSanitizer, OutputFilter } from "../index.js";
|
|
8
|
+
export interface SecureOpenAIConfig {
|
|
9
|
+
/** Enable input validation */
|
|
10
|
+
validateInput?: boolean;
|
|
11
|
+
/** Enable output filtering */
|
|
12
|
+
filterOutput?: boolean;
|
|
13
|
+
/** Enable function/tool call validation */
|
|
14
|
+
validateFunctions?: boolean;
|
|
15
|
+
/** Throw error on violation */
|
|
16
|
+
throwOnViolation?: boolean;
|
|
17
|
+
/** Custom violation handler */
|
|
18
|
+
onViolation?: (type: string, details: any) => void;
|
|
19
|
+
/** InputSanitizer configuration */
|
|
20
|
+
sanitizerConfig?: ConstructorParameters<typeof InputSanitizer>[0];
|
|
21
|
+
/** OutputFilter configuration */
|
|
22
|
+
outputConfig?: ConstructorParameters<typeof OutputFilter>[0];
|
|
23
|
+
}
|
|
24
|
+
export interface ValidationResult {
|
|
25
|
+
allowed: boolean;
|
|
26
|
+
violations: string[];
|
|
27
|
+
sanitized?: string;
|
|
28
|
+
details?: any;
|
|
29
|
+
}
|
|
30
|
+
export interface SecureMessage {
|
|
31
|
+
role: "system" | "user" | "assistant" | "function" | "tool";
|
|
32
|
+
content: string | null;
|
|
33
|
+
name?: string;
|
|
34
|
+
function_call?: any;
|
|
35
|
+
tool_calls?: any[];
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Secure wrapper for OpenAI API calls
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```typescript
|
|
42
|
+
* import OpenAI from 'openai';
|
|
43
|
+
* import { SecureOpenAI } from 'llm-trust-guard/integrations/openai';
|
|
44
|
+
*
|
|
45
|
+
* const openai = new OpenAI();
|
|
46
|
+
* const secure = new SecureOpenAI({
|
|
47
|
+
* validateInput: true,
|
|
48
|
+
* filterOutput: true,
|
|
49
|
+
* throwOnViolation: true
|
|
50
|
+
* });
|
|
51
|
+
*
|
|
52
|
+
* // Validate messages before sending
|
|
53
|
+
* const messages = [
|
|
54
|
+
* { role: 'system', content: 'You are a helpful assistant.' },
|
|
55
|
+
* { role: 'user', content: userInput }
|
|
56
|
+
* ];
|
|
57
|
+
*
|
|
58
|
+
* const validatedMessages = secure.validateMessages(messages, sessionId);
|
|
59
|
+
* if (!validatedMessages.allowed) {
|
|
60
|
+
* throw new Error(`Blocked: ${validatedMessages.violations.join(', ')}`);
|
|
61
|
+
* }
|
|
62
|
+
*
|
|
63
|
+
* // Make the API call
|
|
64
|
+
* const completion = await openai.chat.completions.create({
|
|
65
|
+
* model: 'gpt-4',
|
|
66
|
+
* messages: validatedMessages.messages
|
|
67
|
+
* });
|
|
68
|
+
*
|
|
69
|
+
* // Filter the response
|
|
70
|
+
* const safeResponse = secure.filterResponse(completion);
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
export declare class SecureOpenAI {
|
|
74
|
+
private inputSanitizer;
|
|
75
|
+
private encodingDetector;
|
|
76
|
+
private memoryGuard;
|
|
77
|
+
private outputFilter;
|
|
78
|
+
private toolChainValidator;
|
|
79
|
+
private config;
|
|
80
|
+
constructor(config?: SecureOpenAIConfig);
|
|
81
|
+
/**
|
|
82
|
+
* Validate a single message content
|
|
83
|
+
*/
|
|
84
|
+
validateContent(content: string, requestId?: string): ValidationResult;
|
|
85
|
+
/**
|
|
86
|
+
* Validate an array of chat messages
|
|
87
|
+
*/
|
|
88
|
+
validateMessages(messages: SecureMessage[], sessionId: string, requestId?: string): {
|
|
89
|
+
allowed: boolean;
|
|
90
|
+
messages: SecureMessage[];
|
|
91
|
+
violations: string[];
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* Validate function/tool definitions
|
|
95
|
+
*/
|
|
96
|
+
validateFunctions(functions: Array<{
|
|
97
|
+
name: string;
|
|
98
|
+
description?: string;
|
|
99
|
+
parameters?: any;
|
|
100
|
+
}>, sessionId: string): ValidationResult;
|
|
101
|
+
/**
|
|
102
|
+
* Validate a function/tool call before execution
|
|
103
|
+
*/
|
|
104
|
+
validateFunctionCall(name: string, args: Record<string, any>, sessionId: string): ValidationResult;
|
|
105
|
+
/**
|
|
106
|
+
* Filter the response from OpenAI
|
|
107
|
+
*/
|
|
108
|
+
filterResponse(response: {
|
|
109
|
+
choices?: Array<{
|
|
110
|
+
message?: {
|
|
111
|
+
content?: string | null;
|
|
112
|
+
function_call?: any;
|
|
113
|
+
tool_calls?: any[];
|
|
114
|
+
};
|
|
115
|
+
text?: string;
|
|
116
|
+
}>;
|
|
117
|
+
}, requestId?: string): typeof response;
|
|
118
|
+
/**
|
|
119
|
+
* Create a secure chat completion wrapper
|
|
120
|
+
*/
|
|
121
|
+
createSecureChat(sessionId: string): {
|
|
122
|
+
/**
|
|
123
|
+
* Prepare messages for API call
|
|
124
|
+
*/
|
|
125
|
+
prepareMessages: (messages: SecureMessage[]) => {
|
|
126
|
+
allowed: boolean;
|
|
127
|
+
messages: SecureMessage[];
|
|
128
|
+
violations: string[];
|
|
129
|
+
};
|
|
130
|
+
/**
|
|
131
|
+
* Validate function call before execution
|
|
132
|
+
*/
|
|
133
|
+
validateFunctionCall: (name: string, args: any) => ValidationResult;
|
|
134
|
+
/**
|
|
135
|
+
* Filter response before returning
|
|
136
|
+
*/
|
|
137
|
+
filterResponse: (response: any) => {
|
|
138
|
+
choices?: Array<{
|
|
139
|
+
message?: {
|
|
140
|
+
content?: string | null;
|
|
141
|
+
function_call?: any;
|
|
142
|
+
tool_calls?: any[];
|
|
143
|
+
};
|
|
144
|
+
text?: string;
|
|
145
|
+
}>;
|
|
146
|
+
};
|
|
147
|
+
};
|
|
148
|
+
private handleViolation;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Error thrown on security violations
|
|
152
|
+
*/
|
|
153
|
+
export declare class OpenAISecurityError extends Error {
|
|
154
|
+
violations: string[];
|
|
155
|
+
constructor(message: string, violations: string[]);
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Create a simple wrapper function for validating OpenAI messages
|
|
159
|
+
*
|
|
160
|
+
* @example
|
|
161
|
+
* ```typescript
|
|
162
|
+
* const validate = createMessageValidator();
|
|
163
|
+
*
|
|
164
|
+
* const userMessage = await getUserInput();
|
|
165
|
+
* const result = validate(userMessage);
|
|
166
|
+
*
|
|
167
|
+
* if (!result.allowed) {
|
|
168
|
+
* console.log('Blocked:', result.violations);
|
|
169
|
+
* return;
|
|
170
|
+
* }
|
|
171
|
+
*
|
|
172
|
+
* // Use result.sanitized in your API call
|
|
173
|
+
* ```
|
|
174
|
+
*/
|
|
175
|
+
export declare function createMessageValidator(config?: ConstructorParameters<typeof InputSanitizer>[0]): (content: string) => {
|
|
176
|
+
allowed: boolean;
|
|
177
|
+
sanitized: string;
|
|
178
|
+
violations: string[];
|
|
179
|
+
};
|
|
180
|
+
/**
|
|
181
|
+
* Middleware-style wrapper for OpenAI client
|
|
182
|
+
*
|
|
183
|
+
* @example
|
|
184
|
+
* ```typescript
|
|
185
|
+
* import OpenAI from 'openai';
|
|
186
|
+
* import { wrapOpenAIClient } from 'llm-trust-guard/integrations/openai';
|
|
187
|
+
*
|
|
188
|
+
* const openai = new OpenAI();
|
|
189
|
+
* const secureOpenAI = wrapOpenAIClient(openai, {
|
|
190
|
+
* validateInput: true,
|
|
191
|
+
* filterOutput: true
|
|
192
|
+
* });
|
|
193
|
+
*
|
|
194
|
+
* // Use secureOpenAI.chat.completions.create() as normal
|
|
195
|
+
* // Input will be validated, output will be filtered
|
|
196
|
+
* ```
|
|
197
|
+
*/
|
|
198
|
+
export declare function wrapOpenAIClient<T extends {
|
|
199
|
+
chat: {
|
|
200
|
+
completions: {
|
|
201
|
+
create: Function;
|
|
202
|
+
};
|
|
203
|
+
};
|
|
204
|
+
}>(client: T, config?: SecureOpenAIConfig): T;
|
|
205
|
+
//# sourceMappingURL=openai.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openai.d.ts","sourceRoot":"","sources":["../../src/integrations/openai.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,cAAc,EAGd,YAAY,EAEb,MAAM,aAAa,CAAC;AAErB,MAAM,WAAW,kBAAkB;IACjC,8BAA8B;IAC9B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,8BAA8B;IAC9B,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,2CAA2C;IAC3C,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,+BAA+B;IAC/B,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,+BAA+B;IAC/B,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,KAAK,IAAI,CAAC;IACnD,mCAAmC;IACnC,eAAe,CAAC,EAAE,qBAAqB,CAAC,OAAO,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;IAClE,iCAAiC;IACjC,YAAY,CAAC,EAAE,qBAAqB,CAAC,OAAO,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;CAC9D;AAED,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,MAAM,EAA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