n8n-nodes-trusera 0.5.2 → 0.6.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.
Files changed (47) hide show
  1. package/README.md +1 -0
  2. package/credentials/TruseraPlatformApi.credentials.ts +49 -0
  3. package/dist/credentials/TruseraPlatformApi.credentials.d.ts +10 -0
  4. package/dist/credentials/TruseraPlatformApi.credentials.d.ts.map +1 -0
  5. package/dist/credentials/TruseraPlatformApi.credentials.js +46 -0
  6. package/dist/credentials/TruseraPlatformApi.credentials.js.map +1 -0
  7. package/dist/index.d.ts +5 -0
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js +6 -0
  10. package/dist/index.js.map +1 -1
  11. package/dist/lib/sidecar/contentFilter.d.ts +21 -0
  12. package/dist/lib/sidecar/contentFilter.d.ts.map +1 -0
  13. package/dist/lib/sidecar/contentFilter.js +120 -0
  14. package/dist/lib/sidecar/contentFilter.js.map +1 -0
  15. package/dist/lib/sidecar/evaluator.d.ts +33 -0
  16. package/dist/lib/sidecar/evaluator.d.ts.map +1 -0
  17. package/dist/lib/sidecar/evaluator.js +270 -0
  18. package/dist/lib/sidecar/evaluator.js.map +1 -0
  19. package/dist/lib/sidecar/pii.d.ts +26 -0
  20. package/dist/lib/sidecar/pii.d.ts.map +1 -0
  21. package/dist/lib/sidecar/pii.js +120 -0
  22. package/dist/lib/sidecar/pii.js.map +1 -0
  23. package/dist/lib/sidecar/reporter.d.ts +28 -0
  24. package/dist/lib/sidecar/reporter.d.ts.map +1 -0
  25. package/dist/lib/sidecar/reporter.js +143 -0
  26. package/dist/lib/sidecar/reporter.js.map +1 -0
  27. package/dist/lib/sidecar/types.d.ts +74 -0
  28. package/dist/lib/sidecar/types.d.ts.map +1 -0
  29. package/dist/lib/sidecar/types.js +17 -0
  30. package/dist/lib/sidecar/types.js.map +1 -0
  31. package/dist/nodes/TruseraSidecar/TruseraSidecar.node.d.ts +6 -0
  32. package/dist/nodes/TruseraSidecar/TruseraSidecar.node.d.ts.map +1 -0
  33. package/dist/nodes/TruseraSidecar/TruseraSidecar.node.js +207 -0
  34. package/dist/nodes/TruseraSidecar/TruseraSidecar.node.js.map +1 -0
  35. package/dist/nodes/TruseraSidecar/trusera.svg +4 -0
  36. package/dist/nodes/TruseraSidecarTool/TruseraSidecarTool.node.d.ts +6 -0
  37. package/dist/nodes/TruseraSidecarTool/TruseraSidecarTool.node.d.ts.map +1 -0
  38. package/dist/nodes/TruseraSidecarTool/TruseraSidecarTool.node.js +177 -0
  39. package/dist/nodes/TruseraSidecarTool/TruseraSidecarTool.node.js.map +1 -0
  40. package/dist/nodes/TruseraSidecarTool/trusera.svg +4 -0
  41. package/nodes/TruseraSidecar/TruseraSidecar.node.json +13 -0
  42. package/nodes/TruseraSidecar/TruseraSidecar.node.ts +236 -0
  43. package/nodes/TruseraSidecar/trusera.svg +4 -0
  44. package/nodes/TruseraSidecarTool/TruseraSidecarTool.node.json +13 -0
  45. package/nodes/TruseraSidecarTool/TruseraSidecarTool.node.ts +213 -0
  46. package/nodes/TruseraSidecarTool/trusera.svg +4 -0
  47. package/package.json +15 -6
package/README.md CHANGED
@@ -326,3 +326,4 @@ The interactive HTML dashboard includes:
326
326
  ## License
327
327
 
328
328
  MIT
329
+
@@ -0,0 +1,49 @@
1
+ import type {
2
+ IAuthenticateGeneric,
3
+ ICredentialTestRequest,
4
+ ICredentialType,
5
+ INodeProperties,
6
+ } from 'n8n-workflow';
7
+
8
+ export class TruseraPlatformApi implements ICredentialType {
9
+ name = 'truseraPlatformApi';
10
+ displayName = 'Trusera Platform API';
11
+ documentationUrl = 'https://docs.trusera.dev/n8n-sidecar';
12
+
13
+ properties: INodeProperties[] = [
14
+ {
15
+ displayName: 'API Key',
16
+ name: 'apiKey',
17
+ type: 'string',
18
+ typeOptions: { password: true },
19
+ default: '',
20
+ required: true,
21
+ description: 'Trusera platform API key (starts with tsk_)',
22
+ },
23
+ {
24
+ displayName: 'Platform URL',
25
+ name: 'platformUrl',
26
+ type: 'string',
27
+ default: 'https://api.trusera.io',
28
+ required: false,
29
+ description: 'Trusera platform API URL',
30
+ },
31
+ ];
32
+
33
+ authenticate: IAuthenticateGeneric = {
34
+ type: 'generic',
35
+ properties: {
36
+ headers: {
37
+ Authorization: '=Bearer {{$credentials.apiKey}}',
38
+ },
39
+ },
40
+ };
41
+
42
+ test: ICredentialTestRequest = {
43
+ request: {
44
+ baseURL: '={{$credentials.platformUrl}}',
45
+ url: '/api/v1/agents/stats',
46
+ method: 'GET',
47
+ },
48
+ };
49
+ }
@@ -0,0 +1,10 @@
1
+ import type { IAuthenticateGeneric, ICredentialTestRequest, ICredentialType, INodeProperties } from 'n8n-workflow';
2
+ export declare class TruseraPlatformApi implements ICredentialType {
3
+ name: string;
4
+ displayName: string;
5
+ documentationUrl: string;
6
+ properties: INodeProperties[];
7
+ authenticate: IAuthenticateGeneric;
8
+ test: ICredentialTestRequest;
9
+ }
10
+ //# sourceMappingURL=TruseraPlatformApi.credentials.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TruseraPlatformApi.credentials.d.ts","sourceRoot":"","sources":["../../credentials/TruseraPlatformApi.credentials.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,sBAAsB,EACtB,eAAe,EACf,eAAe,EAChB,MAAM,cAAc,CAAC;AAEtB,qBAAa,kBAAmB,YAAW,eAAe;IACxD,IAAI,SAAwB;IAC5B,WAAW,SAA0B;IACrC,gBAAgB,SAA0C;IAE1D,UAAU,EAAE,eAAe,EAAE,CAkB3B;IAEF,YAAY,EAAE,oBAAoB,CAOhC;IAEF,IAAI,EAAE,sBAAsB,CAM1B;CACH"}
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TruseraPlatformApi = void 0;
4
+ class TruseraPlatformApi {
5
+ constructor() {
6
+ this.name = 'truseraPlatformApi';
7
+ this.displayName = 'Trusera Platform API';
8
+ this.documentationUrl = 'https://docs.trusera.dev/n8n-sidecar';
9
+ this.properties = [
10
+ {
11
+ displayName: 'API Key',
12
+ name: 'apiKey',
13
+ type: 'string',
14
+ typeOptions: { password: true },
15
+ default: '',
16
+ required: true,
17
+ description: 'Trusera platform API key (starts with tsk_)',
18
+ },
19
+ {
20
+ displayName: 'Platform URL',
21
+ name: 'platformUrl',
22
+ type: 'string',
23
+ default: 'https://api.trusera.io',
24
+ required: false,
25
+ description: 'Trusera platform API URL',
26
+ },
27
+ ];
28
+ this.authenticate = {
29
+ type: 'generic',
30
+ properties: {
31
+ headers: {
32
+ Authorization: '=Bearer {{$credentials.apiKey}}',
33
+ },
34
+ },
35
+ };
36
+ this.test = {
37
+ request: {
38
+ baseURL: '={{$credentials.platformUrl}}',
39
+ url: '/api/v1/agents/stats',
40
+ method: 'GET',
41
+ },
42
+ };
43
+ }
44
+ }
45
+ exports.TruseraPlatformApi = TruseraPlatformApi;
46
+ //# sourceMappingURL=TruseraPlatformApi.credentials.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TruseraPlatformApi.credentials.js","sourceRoot":"","sources":["../../credentials/TruseraPlatformApi.credentials.ts"],"names":[],"mappings":";;;AAOA,MAAa,kBAAkB;IAA/B;QACE,SAAI,GAAG,oBAAoB,CAAC;QAC5B,gBAAW,GAAG,sBAAsB,CAAC;QACrC,qBAAgB,GAAG,sCAAsC,CAAC;QAE1D,eAAU,GAAsB;YAC9B;gBACE,WAAW,EAAE,SAAS;gBACtB,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE;gBAC/B,OAAO,EAAE,EAAE;gBACX,QAAQ,EAAE,IAAI;gBACd,WAAW,EAAE,6CAA6C;aAC3D;YACD;gBACE,WAAW,EAAE,cAAc;gBAC3B,IAAI,EAAE,aAAa;gBACnB,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,wBAAwB;gBACjC,QAAQ,EAAE,KAAK;gBACf,WAAW,EAAE,0BAA0B;aACxC;SACF,CAAC;QAEF,iBAAY,GAAyB;YACnC,IAAI,EAAE,SAAS;YACf,UAAU,EAAE;gBACV,OAAO,EAAE;oBACP,aAAa,EAAE,iCAAiC;iBACjD;aACF;SACF,CAAC;QAEF,SAAI,GAA2B;YAC7B,OAAO,EAAE;gBACP,OAAO,EAAE,+BAA+B;gBACxC,GAAG,EAAE,sBAAsB;gBAC3B,MAAM,EAAE,KAAK;aACd;SACF,CAAC;IACJ,CAAC;CAAA;AAzCD,gDAyCC"}
package/dist/index.d.ts CHANGED
@@ -4,4 +4,9 @@ export * from './lib/riskScorer';
4
4
  export * from './lib/policyEngine';
5
5
  export * from './lib/scanner';
6
6
  export * from './lib/dashboardHtml';
7
+ export * from './lib/sidecar/types';
8
+ export * from './lib/sidecar/pii';
9
+ export * from './lib/sidecar/contentFilter';
10
+ export * from './lib/sidecar/evaluator';
11
+ export * from './lib/sidecar/reporter';
7
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AAGpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC"}
package/dist/index.js CHANGED
@@ -20,4 +20,10 @@ __exportStar(require("./lib/riskScorer"), exports);
20
20
  __exportStar(require("./lib/policyEngine"), exports);
21
21
  __exportStar(require("./lib/scanner"), exports);
22
22
  __exportStar(require("./lib/dashboardHtml"), exports);
23
+ // Sidecar runtime enforcement
24
+ __exportStar(require("./lib/sidecar/types"), exports);
25
+ __exportStar(require("./lib/sidecar/pii"), exports);
26
+ __exportStar(require("./lib/sidecar/contentFilter"), exports);
27
+ __exportStar(require("./lib/sidecar/evaluator"), exports);
28
+ __exportStar(require("./lib/sidecar/reporter"), exports);
23
29
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,+CAA6B;AAC7B,mDAAiC;AACjC,qDAAmC;AACnC,gDAA8B;AAC9B,sDAAoC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,+CAA6B;AAC7B,mDAAiC;AACjC,qDAAmC;AACnC,gDAA8B;AAC9B,sDAAoC;AAEpC,8BAA8B;AAC9B,sDAAoC;AACpC,oDAAkC;AAClC,8DAA4C;AAC5C,0DAAwC;AACxC,yDAAuC"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Content filtering for the Trusera Sidecar.
3
+ *
4
+ * Pattern-based detection for prompt injection and dangerous content.
5
+ * Conservative patterns — high precision, lower recall. The platform's
6
+ * Cedar policies handle nuanced enforcement; these are a lightweight first pass.
7
+ */
8
+ /** A single content filter match. */
9
+ export interface ContentFilterResult {
10
+ type: 'prompt_injection' | 'dangerous_content';
11
+ name: string;
12
+ matched: string;
13
+ severity: 'critical' | 'high' | 'medium' | 'low';
14
+ }
15
+ /** Detect prompt injection patterns. */
16
+ export declare function detectPromptInjection(text: string): ContentFilterResult[];
17
+ /** Detect dangerous content patterns. */
18
+ export declare function detectDangerousContent(text: string): ContentFilterResult[];
19
+ /** Combined content filter — runs both injection + dangerous content checks. */
20
+ export declare function runContentFilter(text: string): ContentFilterResult[];
21
+ //# sourceMappingURL=contentFilter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contentFilter.d.ts","sourceRoot":"","sources":["../../../lib/sidecar/contentFilter.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,qCAAqC;AACrC,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,kBAAkB,GAAG,mBAAmB,CAAC;IAC/C,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,UAAU,GAAG,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAC;CAClD;AA6FD,wCAAwC;AACxC,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,mBAAmB,EAAE,CAIzE;AAED,yCAAyC;AACzC,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,mBAAmB,EAAE,CAI1E;AAED,gFAAgF;AAChF,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,mBAAmB,EAAE,CAOpE"}
@@ -0,0 +1,120 @@
1
+ "use strict";
2
+ /**
3
+ * Content filtering for the Trusera Sidecar.
4
+ *
5
+ * Pattern-based detection for prompt injection and dangerous content.
6
+ * Conservative patterns — high precision, lower recall. The platform's
7
+ * Cedar policies handle nuanced enforcement; these are a lightweight first pass.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.detectPromptInjection = detectPromptInjection;
11
+ exports.detectDangerousContent = detectDangerousContent;
12
+ exports.runContentFilter = runContentFilter;
13
+ /** Maximum text length to scan (100 KB). */
14
+ const MAX_SCAN_LENGTH = 100_000;
15
+ const PROMPT_INJECTION_PATTERNS = [
16
+ {
17
+ name: 'ignore_instructions',
18
+ pattern: /ignore\s+(?:all\s+)?(?:previous|prior|above|earlier)\s+(?:instructions|prompts|context|rules)/gi,
19
+ severity: 'critical',
20
+ type: 'prompt_injection',
21
+ },
22
+ {
23
+ name: 'role_reassignment',
24
+ pattern: /you\s+are\s+now\s+(?:a|an|the|my)\s+/gi,
25
+ severity: 'high',
26
+ type: 'prompt_injection',
27
+ },
28
+ {
29
+ name: 'system_prompt_extraction',
30
+ pattern: /(?:repeat|show|reveal|print|output|display|tell\s+me)\s+(?:your|the)\s+(?:system\s+)?(?:prompt|instructions|rules|guidelines)/gi,
31
+ severity: 'high',
32
+ type: 'prompt_injection',
33
+ },
34
+ {
35
+ name: 'jailbreak_dan',
36
+ pattern: /\bDAN\b.*?(?:do\s+anything\s+now|jailbreak|bypass|unrestricted)/gi,
37
+ severity: 'critical',
38
+ type: 'prompt_injection',
39
+ },
40
+ {
41
+ name: 'delimiter_injection',
42
+ pattern: /(?:<\/?system>|<\/?user>|<\/?assistant>|\[INST\]|\[\/INST\]|<<SYS>>|<\/SYS>>)/gi,
43
+ severity: 'high',
44
+ type: 'prompt_injection',
45
+ },
46
+ {
47
+ name: 'instruction_override',
48
+ pattern: /(?:new\s+instructions?|override\s+(?:instructions?|rules)|forget\s+(?:everything|all|previous))/gi,
49
+ severity: 'critical',
50
+ type: 'prompt_injection',
51
+ },
52
+ {
53
+ name: 'base64_instruction',
54
+ pattern: /(?:decode|execute|run|eval)\s+(?:this\s+)?(?:base64|b64)\s*[:=]/gi,
55
+ severity: 'high',
56
+ type: 'prompt_injection',
57
+ },
58
+ ];
59
+ const DANGEROUS_CONTENT_PATTERNS = [
60
+ {
61
+ name: 'sql_injection_in_llm',
62
+ pattern: /(?:;\s*DROP\s+TABLE|;\s*DELETE\s+FROM|UNION\s+(?:ALL\s+)?SELECT|'\s*OR\s+'1'\s*=\s*'1)/gi,
63
+ severity: 'high',
64
+ type: 'dangerous_content',
65
+ },
66
+ {
67
+ name: 'path_traversal',
68
+ pattern: /(?:\.\.\/){2,}|(?:\.\.\\){2,}/g,
69
+ severity: 'medium',
70
+ type: 'dangerous_content',
71
+ },
72
+ {
73
+ name: 'shell_injection',
74
+ pattern: /(?:;\s*(?:rm|wget|curl|nc|bash|sh|python|perl|ruby)\s+-|`[^`]*`|\$\([^)]*\))/gi,
75
+ severity: 'high',
76
+ type: 'dangerous_content',
77
+ },
78
+ {
79
+ name: 'encoded_payload',
80
+ pattern: /(?:&#x[0-9a-f]{2,4};){3,}|(?:%[0-9a-f]{2}){5,}/gi,
81
+ severity: 'medium',
82
+ type: 'dangerous_content',
83
+ },
84
+ ];
85
+ function runPatterns(text, patterns) {
86
+ const results = [];
87
+ for (const { name, pattern, severity, type } of patterns) {
88
+ pattern.lastIndex = 0;
89
+ const match = pattern.exec(text);
90
+ if (match) {
91
+ results.push({ type, name, matched: match[0], severity });
92
+ }
93
+ }
94
+ return results;
95
+ }
96
+ /** Detect prompt injection patterns. */
97
+ function detectPromptInjection(text) {
98
+ if (!text)
99
+ return [];
100
+ const scanText = text.length > MAX_SCAN_LENGTH ? text.slice(0, MAX_SCAN_LENGTH) : text;
101
+ return runPatterns(scanText, PROMPT_INJECTION_PATTERNS);
102
+ }
103
+ /** Detect dangerous content patterns. */
104
+ function detectDangerousContent(text) {
105
+ if (!text)
106
+ return [];
107
+ const scanText = text.length > MAX_SCAN_LENGTH ? text.slice(0, MAX_SCAN_LENGTH) : text;
108
+ return runPatterns(scanText, DANGEROUS_CONTENT_PATTERNS);
109
+ }
110
+ /** Combined content filter — runs both injection + dangerous content checks. */
111
+ function runContentFilter(text) {
112
+ if (!text)
113
+ return [];
114
+ const scanText = text.length > MAX_SCAN_LENGTH ? text.slice(0, MAX_SCAN_LENGTH) : text;
115
+ return [
116
+ ...runPatterns(scanText, PROMPT_INJECTION_PATTERNS),
117
+ ...runPatterns(scanText, DANGEROUS_CONTENT_PATTERNS),
118
+ ];
119
+ }
120
+ //# sourceMappingURL=contentFilter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contentFilter.js","sourceRoot":"","sources":["../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,MAAM,GAAG,eAAe,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACvF,OAAO,WAAW,CAAC,QAAQ,EAAE,0BAA0B,CAAC,CAAC;AAC3D,CAAC;AAED,gFAAgF;AAChF,SAAgB,gBAAgB,CAAC,IAAY;IAC3C,IAAI,CAAC,IAAI;QAAE,OAAO,EAAE,CAAC;IACrB,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,GAAG,eAAe,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACvF,OAAO;QACL,GAAG,WAAW,CAAC,QAAQ,EAAE,yBAAyB,CAAC;QACnD,GAAG,WAAW,CAAC,QAAQ,EAAE,0BAA0B,CAAC;KACrD,CAAC;AACJ,CAAC"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Core evaluation pipeline for the Trusera Sidecar.
3
+ *
4
+ * Combines Cedar policy evaluation, PII detection, and content filtering
5
+ * into a single evaluation pipeline with fail-open design.
6
+ */
7
+ import type { EvaluatorConfig, EvaluationResult } from './types';
8
+ export declare class SidecarEvaluator {
9
+ private config;
10
+ constructor(config: EvaluatorConfig);
11
+ /** Main evaluation entry point. */
12
+ evaluate(data: Record<string, unknown>): Promise<EvaluationResult>;
13
+ /** PII detection check. */
14
+ private checkPii;
15
+ /** Prompt injection detection check. */
16
+ private checkPromptInjection;
17
+ /** Content filter check. */
18
+ private checkContentFilter;
19
+ /** Cedar policy evaluation — calls platform API or evaluates inline. */
20
+ private evaluateCedarPolicies;
21
+ /** Evaluate against Cedar policies fetched from the platform. */
22
+ private evaluatePlatformCedar;
23
+ /** Evaluate inline Cedar DSL against platform's evaluate endpoint. */
24
+ private evaluateInlineCedar;
25
+ /** Build Cedar evaluation context from input data + prior check results. */
26
+ private buildCedarContext;
27
+ /**
28
+ * Recursively extract all string values from an object into a single text blob.
29
+ * Used for PII detection and content filtering.
30
+ */
31
+ private extractTextContent;
32
+ }
33
+ //# sourceMappingURL=evaluator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evaluator.d.ts","sourceRoot":"","sources":["../../../lib/sidecar/evaluator.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,eAAe,EACf,gBAAgB,EAIjB,MAAM,SAAS,CAAC;AAUjB,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,MAAM,CAAkB;gBAEpB,MAAM,EAAE,eAAe;IAInC,mCAAmC;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAsExE,2BAA2B;IAC3B,OAAO,CAAC,QAAQ;IAchB,wCAAwC;IACxC,OAAO,CAAC,oBAAoB;IAc5B,4BAA4B;IAC5B,OAAO,CAAC,kBAAkB;IAc1B,wEAAwE;YAC1D,qBAAqB;IAenC,iEAAiE;YACnD,qBAAqB;IAwDnC,sEAAsE;YACxD,mBAAmB;IAwDjC,4EAA4E;IAC5E,OAAO,CAAC,iBAAiB;IA0BzB;;;OAGG;IACH,OAAO,CAAC,kBAAkB;CAgB3B"}
@@ -0,0 +1,270 @@
1
+ "use strict";
2
+ /**
3
+ * Core evaluation pipeline for the Trusera Sidecar.
4
+ *
5
+ * Combines Cedar policy evaluation, PII detection, and content filtering
6
+ * into a single evaluation pipeline with fail-open design.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.SidecarEvaluator = void 0;
10
+ const pii_1 = require("./pii");
11
+ const contentFilter_1 = require("./contentFilter");
12
+ /** Max context size sent to platform (50 KB). */
13
+ const MAX_CONTEXT_SIZE = 50_000;
14
+ /** Module-level policy cache. */
15
+ const policyCache = new Map();
16
+ class SidecarEvaluator {
17
+ constructor(config) {
18
+ this.config = config;
19
+ }
20
+ /** Main evaluation entry point. */
21
+ async evaluate(data) {
22
+ const startTime = Date.now();
23
+ const checks = [];
24
+ const violations = [];
25
+ // Extract all text content from the input data
26
+ const textContent = this.extractTextContent(data);
27
+ // Run built-in checks
28
+ if (this.config.enablePiiDetection) {
29
+ const piiCheck = this.checkPii(textContent);
30
+ checks.push(piiCheck);
31
+ if (!piiCheck.passed) {
32
+ violations.push({
33
+ policyName: 'pii_detection',
34
+ reason: `PII detected: ${piiCheck.findings?.join(', ') ?? 'unknown types'}`,
35
+ severity: 'high',
36
+ });
37
+ }
38
+ }
39
+ if (this.config.enablePromptInjection) {
40
+ const injectionCheck = this.checkPromptInjection(textContent);
41
+ checks.push(injectionCheck);
42
+ if (!injectionCheck.passed) {
43
+ violations.push({
44
+ policyName: 'prompt_injection',
45
+ reason: `Prompt injection detected: ${injectionCheck.findings?.join(', ') ?? 'unknown pattern'}`,
46
+ severity: 'critical',
47
+ });
48
+ }
49
+ }
50
+ if (this.config.enableContentFilter) {
51
+ const contentCheck = this.checkContentFilter(textContent);
52
+ checks.push(contentCheck);
53
+ if (!contentCheck.passed) {
54
+ violations.push({
55
+ policyName: 'content_filter',
56
+ reason: `Dangerous content detected: ${contentCheck.findings?.join(', ') ?? 'unknown pattern'}`,
57
+ severity: 'high',
58
+ });
59
+ }
60
+ }
61
+ // Cedar policy evaluation
62
+ const cedarCheck = await this.evaluateCedarPolicies(data, checks);
63
+ checks.push(cedarCheck);
64
+ if (!cedarCheck.passed) {
65
+ violations.push({
66
+ policyName: 'cedar_policy',
67
+ reason: cedarCheck.details,
68
+ severity: 'high',
69
+ });
70
+ }
71
+ const durationMs = Date.now() - startTime;
72
+ const allowed = violations.length === 0 || this.config.enforcementMode !== 'block';
73
+ return {
74
+ allowed: violations.length === 0 ? true : allowed,
75
+ enforcement: this.config.enforcementMode,
76
+ violations,
77
+ checks,
78
+ timestamp: new Date().toISOString(),
79
+ durationMs,
80
+ };
81
+ }
82
+ /** PII detection check. */
83
+ checkPii(text) {
84
+ const matches = (0, pii_1.detectPii)(text);
85
+ if (matches.length === 0) {
86
+ return { name: 'pii_detection', passed: true, details: 'No PII detected' };
87
+ }
88
+ const types = [...new Set(matches.map((m) => m.type))];
89
+ return {
90
+ name: 'pii_detection',
91
+ passed: false,
92
+ details: `Found ${matches.length} PII instance(s): ${types.join(', ')}`,
93
+ findings: types,
94
+ };
95
+ }
96
+ /** Prompt injection detection check. */
97
+ checkPromptInjection(text) {
98
+ const matches = (0, contentFilter_1.detectPromptInjection)(text);
99
+ if (matches.length === 0) {
100
+ return { name: 'prompt_injection', passed: true, details: 'No injection patterns detected' };
101
+ }
102
+ const names = matches.map((m) => m.name);
103
+ return {
104
+ name: 'prompt_injection',
105
+ passed: false,
106
+ details: `Found ${matches.length} injection pattern(s): ${names.join(', ')}`,
107
+ findings: names,
108
+ };
109
+ }
110
+ /** Content filter check. */
111
+ checkContentFilter(text) {
112
+ const matches = (0, contentFilter_1.detectDangerousContent)(text);
113
+ if (matches.length === 0) {
114
+ return { name: 'content_filter', passed: true, details: 'No dangerous content detected' };
115
+ }
116
+ const names = matches.map((m) => m.name);
117
+ return {
118
+ name: 'content_filter',
119
+ passed: false,
120
+ details: `Found ${matches.length} dangerous pattern(s): ${names.join(', ')}`,
121
+ findings: names,
122
+ };
123
+ }
124
+ /** Cedar policy evaluation — calls platform API or evaluates inline. */
125
+ async evaluateCedarPolicies(data, priorChecks) {
126
+ if (this.config.policySource === 'inline' && !this.config.inlineCedarDsl?.trim()) {
127
+ return { name: 'cedar_policy', passed: true, details: 'No inline Cedar policy configured' };
128
+ }
129
+ if (this.config.policySource === 'platform') {
130
+ return this.evaluatePlatformCedar(data, priorChecks);
131
+ }
132
+ return this.evaluateInlineCedar(data, priorChecks);
133
+ }
134
+ /** Evaluate against Cedar policies fetched from the platform. */
135
+ async evaluatePlatformCedar(data, priorChecks) {
136
+ try {
137
+ const context = this.buildCedarContext(data, priorChecks);
138
+ const res = await fetch(`${this.config.platformUrl}/api/v1/cedar/evaluate`, {
139
+ method: 'POST',
140
+ headers: {
141
+ 'Content-Type': 'application/json',
142
+ Authorization: `Bearer ${this.config.apiKey}`,
143
+ },
144
+ body: JSON.stringify({
145
+ principal: { type: 'n8n::Agent', id: this.config.agentName },
146
+ action: { type: 'n8n::Action', id: 'process_data' },
147
+ resource: { type: 'n8n::WorkflowData', id: 'input' },
148
+ context,
149
+ }),
150
+ });
151
+ if (!res.ok) {
152
+ return {
153
+ name: 'cedar_policy',
154
+ passed: true,
155
+ details: `Platform returned ${res.status} — failing open`,
156
+ };
157
+ }
158
+ const result = (await res.json());
159
+ const decision = (result.decision ?? 'allow').toLowerCase();
160
+ if (decision === 'deny') {
161
+ const reasons = result.diagnostic?.reasons ?? ['Policy denied the request'];
162
+ return {
163
+ name: 'cedar_policy',
164
+ passed: false,
165
+ details: reasons.join('; '),
166
+ findings: reasons,
167
+ };
168
+ }
169
+ return { name: 'cedar_policy', passed: true, details: 'Cedar policy evaluation passed' };
170
+ }
171
+ catch {
172
+ // Fail open — platform unreachable
173
+ return {
174
+ name: 'cedar_policy',
175
+ passed: true,
176
+ details: 'Platform unreachable — failing open',
177
+ };
178
+ }
179
+ }
180
+ /** Evaluate inline Cedar DSL against platform's evaluate endpoint. */
181
+ async evaluateInlineCedar(data, priorChecks) {
182
+ try {
183
+ const context = this.buildCedarContext(data, priorChecks);
184
+ const res = await fetch(`${this.config.platformUrl}/api/v1/cedar/evaluate`, {
185
+ method: 'POST',
186
+ headers: {
187
+ 'Content-Type': 'application/json',
188
+ Authorization: `Bearer ${this.config.apiKey}`,
189
+ },
190
+ body: JSON.stringify({
191
+ principal: { type: 'n8n::Agent', id: this.config.agentName },
192
+ action: { type: 'n8n::Action', id: 'process_data' },
193
+ resource: { type: 'n8n::WorkflowData', id: 'input' },
194
+ context,
195
+ inline_policy: this.config.inlineCedarDsl,
196
+ }),
197
+ });
198
+ if (!res.ok) {
199
+ return {
200
+ name: 'cedar_policy',
201
+ passed: true,
202
+ details: `Platform returned ${res.status} — failing open`,
203
+ };
204
+ }
205
+ const result = (await res.json());
206
+ const decision = (result.decision ?? 'allow').toLowerCase();
207
+ if (decision === 'deny') {
208
+ const reasons = result.diagnostic?.reasons ?? ['Inline policy denied the request'];
209
+ return {
210
+ name: 'cedar_policy',
211
+ passed: false,
212
+ details: reasons.join('; '),
213
+ findings: reasons,
214
+ };
215
+ }
216
+ return { name: 'cedar_policy', passed: true, details: 'Inline Cedar policy passed' };
217
+ }
218
+ catch {
219
+ return {
220
+ name: 'cedar_policy',
221
+ passed: true,
222
+ details: 'Platform unreachable — failing open',
223
+ };
224
+ }
225
+ }
226
+ /** Build Cedar evaluation context from input data + prior check results. */
227
+ buildCedarContext(data, priorChecks) {
228
+ const piiCheck = priorChecks.find((c) => c.name === 'pii_detection');
229
+ const injectionCheck = priorChecks.find((c) => c.name === 'prompt_injection');
230
+ const contentCheck = priorChecks.find((c) => c.name === 'content_filter');
231
+ const context = {
232
+ pii_detected: piiCheck ? !piiCheck.passed : false,
233
+ pii_types: piiCheck?.findings ?? [],
234
+ injection_detected: injectionCheck ? !injectionCheck.passed : false,
235
+ content_filter_triggered: contentCheck ? !contentCheck.passed : false,
236
+ data_keys: Object.keys(data),
237
+ data_size: JSON.stringify(data).length,
238
+ };
239
+ // Truncate context to max size
240
+ const contextStr = JSON.stringify(context);
241
+ if (contextStr.length > MAX_CONTEXT_SIZE) {
242
+ delete context.data_keys;
243
+ }
244
+ return context;
245
+ }
246
+ /**
247
+ * Recursively extract all string values from an object into a single text blob.
248
+ * Used for PII detection and content filtering.
249
+ */
250
+ extractTextContent(data) {
251
+ const parts = [];
252
+ function walk(value) {
253
+ if (typeof value === 'string') {
254
+ parts.push(value);
255
+ }
256
+ else if (Array.isArray(value)) {
257
+ for (const item of value)
258
+ walk(item);
259
+ }
260
+ else if (value !== null && typeof value === 'object') {
261
+ for (const v of Object.values(value))
262
+ walk(v);
263
+ }
264
+ }
265
+ walk(data);
266
+ return parts.join(' ');
267
+ }
268
+ }
269
+ exports.SidecarEvaluator = S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AAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;gBAChC,KAAK,MAAM,IAAI,IAAI,KAAK;oBAAE,IAAI,CAAC,IAAI,CAAC,CAAC;YACvC,CAAC;iBAAM,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;gBACvD,KAAK,MAAM,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,KAAgC,CAAC;oBAAE,IAAI,CAAC,CAAC,CAAC,CAAC;YAC3E,CAAC;QACH,CAAC;QAED,IAAI,CAAC,IAAI,CAAC,CAAC;QACX,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACzB,CAAC;CACF;AA5SD,4CA4SC"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * PII detection for the Trusera Sidecar.
3
+ *
4
+ * Regex-based scanning for personally identifiable information.
5
+ * Designed for high precision (few false positives) over recall.
6
+ */
7
+ /** A single PII match. */
8
+ export interface PiiMatch {
9
+ type: string;
10
+ value: string;
11
+ redacted: string;
12
+ position: number;
13
+ }
14
+ /**
15
+ * Detect PII in a text string.
16
+ * Returns all matches found. Scans up to MAX_SCAN_LENGTH bytes.
17
+ */
18
+ export declare function detectPii(text: string): PiiMatch[];
19
+ /**
20
+ * Redact all PII matches in a text string.
21
+ * Replaces each match with [REDACTED_<TYPE>].
22
+ */
23
+ export declare function redactPii(text: string, matches: PiiMatch[]): string;
24
+ /** Quick boolean check: does the text contain any PII? */
25
+ export declare function containsPii(text: string): boolean;
26
+ //# sourceMappingURL=pii.d.ts.map