@sandrobuilds/tracerney 0.9.6

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 (138) hide show
  1. package/README.md +702 -0
  2. package/dist/application/ShieldApplicationService.d.ts +94 -0
  3. package/dist/application/ShieldApplicationService.d.ts.map +1 -0
  4. package/dist/application/ShieldApplicationService.js +223 -0
  5. package/dist/application/ShieldApplicationService.js.map +1 -0
  6. package/dist/application/ShieldBlockError.d.ts +10 -0
  7. package/dist/application/ShieldBlockError.d.ts.map +1 -0
  8. package/dist/application/ShieldBlockError.js +13 -0
  9. package/dist/application/ShieldBlockError.js.map +1 -0
  10. package/dist/application/index.d.ts +9 -0
  11. package/dist/application/index.d.ts.map +1 -0
  12. package/dist/application/index.js +8 -0
  13. package/dist/application/index.js.map +1 -0
  14. package/dist/application/ports/ILLMProvider.d.ts +71 -0
  15. package/dist/application/ports/ILLMProvider.d.ts.map +1 -0
  16. package/dist/application/ports/ILLMProvider.js +15 -0
  17. package/dist/application/ports/ILLMProvider.js.map +1 -0
  18. package/dist/application/ports/IPatternRepository.d.ts +20 -0
  19. package/dist/application/ports/IPatternRepository.d.ts.map +1 -0
  20. package/dist/application/ports/IPatternRepository.js +7 -0
  21. package/dist/application/ports/IPatternRepository.js.map +1 -0
  22. package/dist/application/ports/ISentinel.d.ts +22 -0
  23. package/dist/application/ports/ISentinel.d.ts.map +1 -0
  24. package/dist/application/ports/ISentinel.js +8 -0
  25. package/dist/application/ports/ISentinel.js.map +1 -0
  26. package/dist/application/ports/ITelemetrySink.d.ts +35 -0
  27. package/dist/application/ports/ITelemetrySink.d.ts.map +1 -0
  28. package/dist/application/ports/ITelemetrySink.js +7 -0
  29. package/dist/application/ports/ITelemetrySink.js.map +1 -0
  30. package/dist/application/ports/index.d.ts +10 -0
  31. package/dist/application/ports/index.d.ts.map +1 -0
  32. package/dist/application/ports/index.js +7 -0
  33. package/dist/application/ports/index.js.map +1 -0
  34. package/dist/application/utils/index.d.ts +6 -0
  35. package/dist/application/utils/index.d.ts.map +1 -0
  36. package/dist/application/utils/index.js +6 -0
  37. package/dist/application/utils/index.js.map +1 -0
  38. package/dist/application/utils/jitter.d.ts +10 -0
  39. package/dist/application/utils/jitter.d.ts.map +1 -0
  40. package/dist/application/utils/jitter.js +13 -0
  41. package/dist/application/utils/jitter.js.map +1 -0
  42. package/dist/application/utils/normalizePrompt.d.ts +18 -0
  43. package/dist/application/utils/normalizePrompt.d.ts.map +1 -0
  44. package/dist/application/utils/normalizePrompt.js +36 -0
  45. package/dist/application/utils/normalizePrompt.js.map +1 -0
  46. package/dist/domain/detection/InjectionThreat.d.ts +19 -0
  47. package/dist/domain/detection/InjectionThreat.d.ts.map +1 -0
  48. package/dist/domain/detection/InjectionThreat.js +18 -0
  49. package/dist/domain/detection/InjectionThreat.js.map +1 -0
  50. package/dist/domain/detection/PatternMatcher.d.ts +36 -0
  51. package/dist/domain/detection/PatternMatcher.d.ts.map +1 -0
  52. package/dist/domain/detection/PatternMatcher.js +65 -0
  53. package/dist/domain/detection/PatternMatcher.js.map +1 -0
  54. package/dist/domain/detection/VanguardPattern.d.ts +19 -0
  55. package/dist/domain/detection/VanguardPattern.d.ts.map +1 -0
  56. package/dist/domain/detection/VanguardPattern.js +21 -0
  57. package/dist/domain/detection/VanguardPattern.js.map +1 -0
  58. package/dist/domain/detection/index.d.ts +11 -0
  59. package/dist/domain/detection/index.d.ts.map +1 -0
  60. package/dist/domain/detection/index.js +8 -0
  61. package/dist/domain/detection/index.js.map +1 -0
  62. package/dist/domain/events/SecurityEvent.d.ts +30 -0
  63. package/dist/domain/events/SecurityEvent.d.ts.map +1 -0
  64. package/dist/domain/events/SecurityEvent.js +21 -0
  65. package/dist/domain/events/SecurityEvent.js.map +1 -0
  66. package/dist/domain/events/SecurityEventType.d.ts +13 -0
  67. package/dist/domain/events/SecurityEventType.d.ts.map +1 -0
  68. package/dist/domain/events/SecurityEventType.js +15 -0
  69. package/dist/domain/events/SecurityEventType.js.map +1 -0
  70. package/dist/domain/events/ThreatSeverity.d.ts +13 -0
  71. package/dist/domain/events/ThreatSeverity.d.ts.map +1 -0
  72. package/dist/domain/events/ThreatSeverity.js +15 -0
  73. package/dist/domain/events/ThreatSeverity.js.map +1 -0
  74. package/dist/domain/events/index.d.ts +11 -0
  75. package/dist/domain/events/index.d.ts.map +1 -0
  76. package/dist/domain/events/index.js +8 -0
  77. package/dist/domain/events/index.js.map +1 -0
  78. package/dist/domain/guard/ToolGuard.d.ts +35 -0
  79. package/dist/domain/guard/ToolGuard.d.ts.map +1 -0
  80. package/dist/domain/guard/ToolGuard.js +49 -0
  81. package/dist/domain/guard/ToolGuard.js.map +1 -0
  82. package/dist/domain/guard/ToolPolicy.d.ts +16 -0
  83. package/dist/domain/guard/ToolPolicy.d.ts.map +1 -0
  84. package/dist/domain/guard/ToolPolicy.js +19 -0
  85. package/dist/domain/guard/ToolPolicy.js.map +1 -0
  86. package/dist/domain/guard/ToolViolation.d.ts +14 -0
  87. package/dist/domain/guard/ToolViolation.d.ts.map +1 -0
  88. package/dist/domain/guard/ToolViolation.js +15 -0
  89. package/dist/domain/guard/ToolViolation.js.map +1 -0
  90. package/dist/domain/guard/index.d.ts +11 -0
  91. package/dist/domain/guard/index.d.ts.map +1 -0
  92. package/dist/domain/guard/index.js +8 -0
  93. package/dist/domain/guard/index.js.map +1 -0
  94. package/dist/index.d.ts +168 -0
  95. package/dist/index.d.ts.map +1 -0
  96. package/dist/index.js +173 -0
  97. package/dist/index.js.map +1 -0
  98. package/dist/infrastructure/llm/OpenRouterProvider.d.ts +32 -0
  99. package/dist/infrastructure/llm/OpenRouterProvider.d.ts.map +1 -0
  100. package/dist/infrastructure/llm/OpenRouterProvider.js +119 -0
  101. package/dist/infrastructure/llm/OpenRouterProvider.js.map +1 -0
  102. package/dist/infrastructure/llm/index.d.ts +7 -0
  103. package/dist/infrastructure/llm/index.d.ts.map +1 -0
  104. package/dist/infrastructure/llm/index.js +6 -0
  105. package/dist/infrastructure/llm/index.js.map +1 -0
  106. package/dist/infrastructure/patterns/BundledPatternRepository.d.ts +16 -0
  107. package/dist/infrastructure/patterns/BundledPatternRepository.d.ts.map +1 -0
  108. package/dist/infrastructure/patterns/BundledPatternRepository.js +19 -0
  109. package/dist/infrastructure/patterns/BundledPatternRepository.js.map +1 -0
  110. package/dist/infrastructure/patterns/RemotePatternRepository.d.ts +77 -0
  111. package/dist/infrastructure/patterns/RemotePatternRepository.d.ts.map +1 -0
  112. package/dist/infrastructure/patterns/RemotePatternRepository.js +176 -0
  113. package/dist/infrastructure/patterns/RemotePatternRepository.js.map +1 -0
  114. package/dist/infrastructure/patterns/bundled-patterns.d.ts +9 -0
  115. package/dist/infrastructure/patterns/bundled-patterns.d.ts.map +1 -0
  116. package/dist/infrastructure/patterns/bundled-patterns.js +2082 -0
  117. package/dist/infrastructure/patterns/bundled-patterns.js.map +1 -0
  118. package/dist/infrastructure/patterns/index.d.ts +9 -0
  119. package/dist/infrastructure/patterns/index.d.ts.map +1 -0
  120. package/dist/infrastructure/patterns/index.js +8 -0
  121. package/dist/infrastructure/patterns/index.js.map +1 -0
  122. package/dist/infrastructure/sentinel/LLMSentinel.d.ts +48 -0
  123. package/dist/infrastructure/sentinel/LLMSentinel.d.ts.map +1 -0
  124. package/dist/infrastructure/sentinel/LLMSentinel.js +142 -0
  125. package/dist/infrastructure/sentinel/LLMSentinel.js.map +1 -0
  126. package/dist/infrastructure/telemetry/HttpShadowLogSink.d.ts +30 -0
  127. package/dist/infrastructure/telemetry/HttpShadowLogSink.d.ts.map +1 -0
  128. package/dist/infrastructure/telemetry/HttpShadowLogSink.js +40 -0
  129. package/dist/infrastructure/telemetry/HttpShadowLogSink.js.map +1 -0
  130. package/dist/infrastructure/telemetry/HttpSignalSink.d.ts +51 -0
  131. package/dist/infrastructure/telemetry/HttpSignalSink.d.ts.map +1 -0
  132. package/dist/infrastructure/telemetry/HttpSignalSink.js +134 -0
  133. package/dist/infrastructure/telemetry/HttpSignalSink.js.map +1 -0
  134. package/dist/infrastructure/telemetry/index.d.ts +9 -0
  135. package/dist/infrastructure/telemetry/index.d.ts.map +1 -0
  136. package/dist/infrastructure/telemetry/index.js +7 -0
  137. package/dist/infrastructure/telemetry/index.js.map +1 -0
  138. package/package.json +44 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/application/ports/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Application utility exports
3
+ */
4
+ export { normalizePrompt, normalizePrompts } from './normalizePrompt';
5
+ export { jitter } from './jitter';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/application/utils/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Application utility exports
3
+ */
4
+ export { normalizePrompt, normalizePrompts } from './normalizePrompt.js';
5
+ export { jitter } from './jitter.js';
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/application/utils/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Latency jitter to obfuscate security layer timing
3
+ *
4
+ * Prevents attackers from timing responses to identify which security layer
5
+ * blocked their attack or determine if the system is even protecting them.
6
+ *
7
+ * Default range: 300-500ms (adds consistent overhead to all outcomes)
8
+ */
9
+ export declare function jitter(minMs?: number, maxMs?: number): Promise<void>;
10
+ //# sourceMappingURL=jitter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jitter.d.ts","sourceRoot":"","sources":["../../../src/application/utils/jitter.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,wBAAsB,MAAM,CAAC,KAAK,GAAE,MAAY,EAAE,KAAK,GAAE,MAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAGpF"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Latency jitter to obfuscate security layer timing
3
+ *
4
+ * Prevents attackers from timing responses to identify which security layer
5
+ * blocked their attack or determine if the system is even protecting them.
6
+ *
7
+ * Default range: 300-500ms (adds consistent overhead to all outcomes)
8
+ */
9
+ export async function jitter(minMs = 300, maxMs = 500) {
10
+ const delay = Math.random() * (maxMs - minMs) + minMs;
11
+ return new Promise((resolve) => setTimeout(resolve, delay));
12
+ }
13
+ //# sourceMappingURL=jitter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jitter.js","sourceRoot":"","sources":["../../../src/application/utils/jitter.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,QAAgB,GAAG,EAAE,QAAgB,GAAG;IACnE,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,GAAG,KAAK,CAAC,GAAG,KAAK,CAAC;IACtD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC;AAC9D,CAAC"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Normalize prompt text for consistent pattern matching
3
+ *
4
+ * Steps:
5
+ * 1. Lowercase
6
+ * 2. Unicode NFKC normalization (collapses homoglyphs: p→p, ABC→ABC)
7
+ * 3. Strip non-alphanumeric except basic punctuation
8
+ * 4. Collapse multiple whitespace → single space
9
+ * 5. Trim
10
+ *
11
+ * This prevents attackers from using Unicode tricks or weird spacing to bypass regex.
12
+ */
13
+ export declare function normalizePrompt(input: string): string;
14
+ /**
15
+ * Batch normalize multiple prompts
16
+ */
17
+ export declare function normalizePrompts(inputs: string[]): string[];
18
+ //# sourceMappingURL=normalizePrompt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalizePrompt.d.ts","sourceRoot":"","sources":["../../../src/application/utils/normalizePrompt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAkBrD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAE3D"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Normalize prompt text for consistent pattern matching
3
+ *
4
+ * Steps:
5
+ * 1. Lowercase
6
+ * 2. Unicode NFKC normalization (collapses homoglyphs: p→p, ABC→ABC)
7
+ * 3. Strip non-alphanumeric except basic punctuation
8
+ * 4. Collapse multiple whitespace → single space
9
+ * 5. Trim
10
+ *
11
+ * This prevents attackers from using Unicode tricks or weird spacing to bypass regex.
12
+ */
13
+ export function normalizePrompt(input) {
14
+ if (!input || typeof input !== 'string') {
15
+ return '';
16
+ }
17
+ let normalized = input
18
+ // Step 1: Lowercase
19
+ .toLowerCase()
20
+ // Step 2: Unicode normalization (NFKC collapses fullwidth, superscripts, ligatures, etc.)
21
+ .normalize('NFKC')
22
+ // Step 3: Keep only alphanumeric + basic punctuation (. , ! ? ' " - _ ( ) [ ])
23
+ .replace(/[^\w\s.,'!?"_\-()[\]]/g, '')
24
+ // Step 4: Collapse multiple spaces/newlines/tabs into single space
25
+ .replace(/\s+/g, ' ')
26
+ // Step 5: Trim
27
+ .trim();
28
+ return normalized;
29
+ }
30
+ /**
31
+ * Batch normalize multiple prompts
32
+ */
33
+ export function normalizePrompts(inputs) {
34
+ return inputs.map(normalizePrompt);
35
+ }
36
+ //# sourceMappingURL=normalizePrompt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalizePrompt.js","sourceRoot":"","sources":["../../../src/application/utils/normalizePrompt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,MAAM,UAAU,eAAe,CAAC,KAAa;IAC3C,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QACxC,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,IAAI,UAAU,GAAG,KAAK;QACpB,oBAAoB;SACnB,WAAW,EAAE;QACd,0FAA0F;SACzF,SAAS,CAAC,MAAM,CAAC;QAClB,+EAA+E;SAC9E,OAAO,CAAC,wBAAwB,EAAE,EAAE,CAAC;QACtC,mEAAmE;SAClE,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC;QACrB,eAAe;SACd,IAAI,EAAE,CAAC;IAEV,OAAO,UAAU,CAAC;AACpB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAAgB;IAC/C,OAAO,MAAM,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;AACrC,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Injection Threat
3
+ * Domain value object: represents a confirmed pattern match
4
+ */
5
+ import { ThreatSeverity } from "../events/ThreatSeverity";
6
+ import { PatternCategory } from "./VanguardPattern";
7
+ export interface InjectionThreat {
8
+ readonly patternId: string;
9
+ readonly patternName: string;
10
+ readonly category: PatternCategory;
11
+ readonly severity: ThreatSeverity;
12
+ readonly description: string;
13
+ readonly matchedAt: number;
14
+ }
15
+ /**
16
+ * Factory to create an InjectionThreat from a matched pattern
17
+ */
18
+ export declare function createInjectionThreat(patternId: string, patternName: string, category: PatternCategory, severity: ThreatSeverity, description: string, matchedAt?: number): InjectionThreat;
19
+ //# sourceMappingURL=InjectionThreat.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InjectionThreat.d.ts","sourceRoot":"","sources":["../../../src/domain/detection/InjectionThreat.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,QAAQ,EAAE,eAAe,CAAC;IACnC,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC;IAClC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,eAAe,EACzB,QAAQ,EAAE,cAAc,EACxB,WAAW,EAAE,MAAM,EACnB,SAAS,CAAC,EAAE,MAAM,GACjB,eAAe,CASjB"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Injection Threat
3
+ * Domain value object: represents a confirmed pattern match
4
+ */
5
+ /**
6
+ * Factory to create an InjectionThreat from a matched pattern
7
+ */
8
+ export function createInjectionThreat(patternId, patternName, category, severity, description, matchedAt) {
9
+ return {
10
+ patternId,
11
+ patternName,
12
+ category,
13
+ severity,
14
+ description,
15
+ matchedAt: matchedAt ?? Date.now(),
16
+ };
17
+ }
18
+ //# sourceMappingURL=InjectionThreat.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InjectionThreat.js","sourceRoot":"","sources":["../../../src/domain/detection/InjectionThreat.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAcH;;GAEG;AACH,MAAM,UAAU,qBAAqB,CACnC,SAAiB,EACjB,WAAmB,EACnB,QAAyB,EACzB,QAAwB,EACxB,WAAmB,EACnB,SAAkB;IAElB,OAAO;QACL,SAAS;QACT,WAAW;QACX,QAAQ;QACR,QAAQ;QACR,WAAW;QACX,SAAS,EAAE,SAAS,IAAI,IAAI,CAAC,GAAG,EAAE;KACnC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Pattern Matcher
3
+ * Domain service: pure injection detection logic, no I/O side effects
4
+ */
5
+ import { VanguardPattern } from "./VanguardPattern";
6
+ import { InjectionThreat } from "./InjectionThreat";
7
+ export interface PatternMatcherStats {
8
+ readonly totalPatterns: number;
9
+ readonly bySeverity: {
10
+ readonly critical: number;
11
+ readonly high: number;
12
+ readonly medium: number;
13
+ readonly low: number;
14
+ };
15
+ readonly byCategory: Record<string, number>;
16
+ }
17
+ export declare class PatternMatcher {
18
+ private readonly patterns;
19
+ constructor(patterns: readonly VanguardPattern[]);
20
+ /**
21
+ * Scan a prompt against all patterns.
22
+ * Returns on first match (early exit for <2ms latency).
23
+ * Returns null if no match found.
24
+ */
25
+ match(prompt: string): InjectionThreat | null;
26
+ /**
27
+ * Scan a prompt and return all matches.
28
+ * Used for audit/analysis purposes.
29
+ */
30
+ matchAll(prompt: string): InjectionThreat[];
31
+ /**
32
+ * Get statistics about the loaded patterns
33
+ */
34
+ stats(): PatternMatcherStats;
35
+ }
36
+ //# sourceMappingURL=PatternMatcher.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PatternMatcher.d.ts","sourceRoot":"","sources":["../../../src/domain/detection/PatternMatcher.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAyB,MAAM,mBAAmB,CAAC;AAE3E,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,UAAU,EAAE;QACnB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;QAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;QACxB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;KACtB,CAAC;IACF,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC7C;AAED,qBAAa,cAAc;IACb,OAAO,CAAC,QAAQ,CAAC,QAAQ;gBAAR,QAAQ,EAAE,SAAS,eAAe,EAAE;IAMjE;;;;OAIG;IACH,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,eAAe,GAAG,IAAI;IAqB7C;;;OAGG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,eAAe,EAAE;IAsB3C;;OAEG;IACH,KAAK,IAAI,mBAAmB;CAkB7B"}
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Pattern Matcher
3
+ * Domain service: pure injection detection logic, no I/O side effects
4
+ */
5
+ import { createInjectionThreat } from './InjectionThreat.js';
6
+ export class PatternMatcher {
7
+ constructor(patterns) {
8
+ this.patterns = patterns;
9
+ if (!patterns || patterns.length === 0) {
10
+ throw new Error("[PatternMatcher] At least one pattern is required");
11
+ }
12
+ }
13
+ /**
14
+ * Scan a prompt against all patterns.
15
+ * Returns on first match (early exit for <2ms latency).
16
+ * Returns null if no match found.
17
+ */
18
+ match(prompt) {
19
+ if (!prompt || typeof prompt !== "string") {
20
+ return null;
21
+ }
22
+ // Early exit on first match
23
+ for (const pattern of this.patterns) {
24
+ if (pattern.pattern.test(prompt)) {
25
+ return createInjectionThreat(pattern.id, pattern.name, pattern.category, pattern.severity, pattern.description);
26
+ }
27
+ }
28
+ return null;
29
+ }
30
+ /**
31
+ * Scan a prompt and return all matches.
32
+ * Used for audit/analysis purposes.
33
+ */
34
+ matchAll(prompt) {
35
+ if (!prompt || typeof prompt !== "string") {
36
+ return [];
37
+ }
38
+ const matches = [];
39
+ for (const pattern of this.patterns) {
40
+ if (pattern.pattern.test(prompt)) {
41
+ matches.push(createInjectionThreat(pattern.id, pattern.name, pattern.category, pattern.severity, pattern.description));
42
+ }
43
+ }
44
+ return matches;
45
+ }
46
+ /**
47
+ * Get statistics about the loaded patterns
48
+ */
49
+ stats() {
50
+ return {
51
+ totalPatterns: this.patterns.length,
52
+ bySeverity: {
53
+ critical: this.patterns.filter((p) => p.severity === "critical").length,
54
+ high: this.patterns.filter((p) => p.severity === "high").length,
55
+ medium: this.patterns.filter((p) => p.severity === "medium").length,
56
+ low: this.patterns.filter((p) => p.severity === "low").length,
57
+ },
58
+ byCategory: this.patterns.reduce((acc, p) => {
59
+ acc[p.category] = (acc[p.category] || 0) + 1;
60
+ return acc;
61
+ }, {}),
62
+ };
63
+ }
64
+ }
65
+ //# sourceMappingURL=PatternMatcher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PatternMatcher.js","sourceRoot":"","sources":["../../../src/domain/detection/PatternMatcher.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAmB,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAa3E,MAAM,OAAO,cAAc;IACzB,YAA6B,QAAoC;QAApC,aAAQ,GAAR,QAAQ,CAA4B;QAC/D,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACvC,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;QACvE,CAAC;IACH,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,MAAc;QAClB,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;YAC1C,OAAO,IAAI,CAAC;QACd,CAAC;QAED,4BAA4B;QAC5B,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YACpC,IAAI,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;gBACjC,OAAO,qBAAqB,CAC1B,OAAO,CAAC,EAAE,EACV,OAAO,CAAC,IAAI,EACZ,OAAO,CAAC,QAAQ,EAChB,OAAO,CAAC,QAAQ,EAChB,OAAO,CAAC,WAAW,CACpB,CAAC;YACJ,CAAC;QACH,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;OAGG;IACH,QAAQ,CAAC,MAAc;QACrB,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;YAC1C,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,MAAM,OAAO,GAAsB,EAAE,CAAC;QACtC,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YACpC,IAAI,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;gBACjC,OAAO,CAAC,IAAI,CACV,qBAAqB,CACnB,OAAO,CAAC,EAAE,EACV,OAAO,CAAC,IAAI,EACZ,OAAO,CAAC,QAAQ,EAChB,OAAO,CAAC,QAAQ,EAChB,OAAO,CAAC,WAAW,CACpB,CACF,CAAC;YACJ,CAAC;QACH,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;IAED;;OAEG;IACH,KAAK;QACH,OAAO;YACL,aAAa,EAAE,IAAI,CAAC,QAAQ,CAAC,MAAM;YACnC,UAAU,EAAE;gBACV,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,UAAU,CAAC,CAAC,MAAM;gBACvE,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,MAAM,CAAC,CAAC,MAAM;gBAC/D,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC,MAAM;gBACnE,GAAG,EAAE,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,KAAK,CAAC,CAAC,MAAM;aAC9D;YACD,UAAU,EAAE,IAAI,CAAC,QAAQ,CAAC,MAAM,CAC9B,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE;gBACT,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;gBAC7C,OAAO,GAAG,CAAC;YACb,CAAC,EACD,EAA4B,CAC7B;SACF,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Vanguard Pattern
3
+ * Domain value object: immutable pattern definition for injection detection
4
+ */
5
+ import { ThreatSeverity } from "../events/ThreatSeverity";
6
+ export type PatternCategory = "system_override" | "prompt_leak" | "privilege_escalation" | "data_exfiltration" | "code_injection" | "unknown";
7
+ export interface VanguardPattern {
8
+ readonly id: string;
9
+ readonly name: string;
10
+ readonly pattern: RegExp;
11
+ readonly severity: ThreatSeverity;
12
+ readonly description: string;
13
+ readonly category: PatternCategory;
14
+ }
15
+ /**
16
+ * Factory to create a VanguardPattern with validation
17
+ */
18
+ export declare function createVanguardPattern(id: string, name: string, pattern: RegExp, severity: ThreatSeverity, description: string, category: PatternCategory): VanguardPattern;
19
+ //# sourceMappingURL=VanguardPattern.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"VanguardPattern.d.ts","sourceRoot":"","sources":["../../../src/domain/detection/VanguardPattern.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE1D,MAAM,MAAM,eAAe,GACvB,iBAAiB,GACjB,aAAa,GACb,sBAAsB,GACtB,mBAAmB,GACnB,gBAAgB,GAChB,SAAS,CAAC;AAEd,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC;IAClC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,QAAQ,EAAE,eAAe,CAAC;CACpC;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,cAAc,EACxB,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,eAAe,GACxB,eAAe,CAYjB"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Vanguard Pattern
3
+ * Domain value object: immutable pattern definition for injection detection
4
+ */
5
+ /**
6
+ * Factory to create a VanguardPattern with validation
7
+ */
8
+ export function createVanguardPattern(id, name, pattern, severity, description, category) {
9
+ if (!id || !name || !pattern || !description) {
10
+ throw new Error("[VanguardPattern] All required fields must be non-empty");
11
+ }
12
+ return {
13
+ id,
14
+ name,
15
+ pattern,
16
+ severity,
17
+ description,
18
+ category,
19
+ };
20
+ }
21
+ //# sourceMappingURL=VanguardPattern.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"VanguardPattern.js","sourceRoot":"","sources":["../../../src/domain/detection/VanguardPattern.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAqBH;;GAEG;AACH,MAAM,UAAU,qBAAqB,CACnC,EAAU,EACV,IAAY,EACZ,OAAe,EACf,QAAwB,EACxB,WAAmB,EACnB,QAAyB;IAEzB,IAAI,CAAC,EAAE,IAAI,CAAC,IAAI,IAAI,CAAC,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC;QAC7C,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAC;IAC7E,CAAC;IACD,OAAO;QACL,EAAE;QACF,IAAI;QACJ,OAAO;QACP,QAAQ;QACR,WAAW;QACX,QAAQ;KACT,CAAC;AACJ,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Detection Bounded Context
3
+ * Barrel export
4
+ */
5
+ export { createVanguardPattern } from "./VanguardPattern";
6
+ export type { VanguardPattern, PatternCategory } from "./VanguardPattern";
7
+ export { createInjectionThreat } from "./InjectionThreat";
8
+ export type { InjectionThreat } from "./InjectionThreat";
9
+ export { PatternMatcher } from "./PatternMatcher";
10
+ export type { PatternMatcherStats } from "./PatternMatcher";
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/domain/detection/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,YAAY,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAE1E,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,YAAY,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEzD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,YAAY,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Detection Bounded Context
3
+ * Barrel export
4
+ */
5
+ export { createVanguardPattern } from './VanguardPattern.js';
6
+ export { createInjectionThreat } from './InjectionThreat.js';
7
+ export { PatternMatcher } from './PatternMatcher.js';
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/domain/detection/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAG1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAG1D,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Security Event
3
+ * Domain entity: represents a security incident that was blocked
4
+ * Has identity (eventId), immutable after construction
5
+ */
6
+ import { SecurityEventType } from "./SecurityEventType";
7
+ import { ThreatSeverity } from "./ThreatSeverity";
8
+ export interface SecurityEventMetadata {
9
+ readonly toolName?: string;
10
+ readonly patternName?: string;
11
+ readonly requestSnippet?: string;
12
+ readonly blockLatencyMs?: number;
13
+ readonly modelName?: string;
14
+ readonly provider?: string;
15
+ }
16
+ export interface SecurityEvent {
17
+ readonly id: string;
18
+ readonly requestId: string;
19
+ readonly type: SecurityEventType;
20
+ readonly severity: ThreatSeverity;
21
+ readonly timestamp: number;
22
+ readonly blockReason: string;
23
+ readonly metadata: SecurityEventMetadata;
24
+ readonly anonymized: boolean;
25
+ }
26
+ /**
27
+ * Factory function to construct a SecurityEvent with a unique ID
28
+ */
29
+ export declare function createSecurityEvent(requestId: string, type: SecurityEventType, severity: ThreatSeverity, blockReason: string, metadata: SecurityEventMetadata, timestamp?: number): SecurityEvent;
30
+ //# sourceMappingURL=SecurityEvent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SecurityEvent.d.ts","sourceRoot":"","sources":["../../../src/domain/events/SecurityEvent.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,iBAAiB,CAAC;IACjC,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC;IAClC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,QAAQ,EAAE,qBAAqB,CAAC;IACzC,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;CAC9B;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,iBAAiB,EACvB,QAAQ,EAAE,cAAc,EACxB,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,qBAAqB,EAC/B,SAAS,CAAC,EAAE,MAAM,GACjB,aAAa,CAWf"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Security Event
3
+ * Domain entity: represents a security incident that was blocked
4
+ * Has identity (eventId), immutable after construction
5
+ */
6
+ /**
7
+ * Factory function to construct a SecurityEvent with a unique ID
8
+ */
9
+ export function createSecurityEvent(requestId, type, severity, blockReason, metadata, timestamp) {
10
+ return {
11
+ id: `event_${Date.now()}_${Math.random().toString(36).substring(2, 9)}`,
12
+ requestId,
13
+ type,
14
+ severity,
15
+ timestamp: timestamp ?? Date.now(),
16
+ blockReason,
17
+ metadata,
18
+ anonymized: true,
19
+ };
20
+ }
21
+ //# sourceMappingURL=SecurityEvent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SecurityEvent.js","sourceRoot":"","sources":["../../../src/domain/events/SecurityEvent.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAyBH;;GAEG;AACH,MAAM,UAAU,mBAAmB,CACjC,SAAiB,EACjB,IAAuB,EACvB,QAAwB,EACxB,WAAmB,EACnB,QAA+B,EAC/B,SAAkB;IAElB,OAAO;QACL,EAAE,EAAE,SAAS,IAAI,CAAC,GAAG,EAAE,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE;QACvE,SAAS;QACT,IAAI;QACJ,QAAQ;QACR,SAAS,EAAE,SAAS,IAAI,IAAI,CAAC,GAAG,EAAE;QAClC,WAAW;QACX,QAAQ;QACR,UAAU,EAAE,IAAI;KACjB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Security Event Types
3
+ * Domain value object (enum)
4
+ */
5
+ export declare enum SecurityEventType {
6
+ PROMPT_INJECTION = "PROMPT_INJECTION",
7
+ UNAUTHORIZED_TOOL = "UNAUTHORIZED_TOOL",
8
+ PATTERN_MATCH = "PATTERN_MATCH",
9
+ SCHEMA_VIOLATION = "SCHEMA_VIOLATION"
10
+ }
11
+ export type SecurityEventTypeString = keyof typeof SecurityEventType;
12
+ export declare function isSecurityEventType(value: unknown): value is SecurityEventType;
13
+ //# sourceMappingURL=SecurityEventType.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SecurityEventType.d.ts","sourceRoot":"","sources":["../../../src/domain/events/SecurityEventType.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,oBAAY,iBAAiB;IAC3B,gBAAgB,qBAAqB;IACrC,iBAAiB,sBAAsB;IACvC,aAAa,kBAAkB;IAC/B,gBAAgB,qBAAqB;CACtC;AAED,MAAM,MAAM,uBAAuB,GAAG,MAAM,OAAO,iBAAiB,CAAC;AAErE,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,iBAAiB,CAE9E"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Security Event Types
3
+ * Domain value object (enum)
4
+ */
5
+ export var SecurityEventType;
6
+ (function (SecurityEventType) {
7
+ SecurityEventType["PROMPT_INJECTION"] = "PROMPT_INJECTION";
8
+ SecurityEventType["UNAUTHORIZED_TOOL"] = "UNAUTHORIZED_TOOL";
9
+ SecurityEventType["PATTERN_MATCH"] = "PATTERN_MATCH";
10
+ SecurityEventType["SCHEMA_VIOLATION"] = "SCHEMA_VIOLATION";
11
+ })(SecurityEventType || (SecurityEventType = {}));
12
+ export function isSecurityEventType(value) {
13
+ return Object.values(SecurityEventType).includes(value);
14
+ }
15
+ //# sourceMappingURL=SecurityEventType.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SecurityEventType.js","sourceRoot":"","sources":["../../../src/domain/events/SecurityEventType.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,CAAN,IAAY,iBAKX;AALD,WAAY,iBAAiB;IAC3B,0DAAqC,CAAA;IACrC,4DAAuC,CAAA;IACvC,oDAA+B,CAAA;IAC/B,0DAAqC,CAAA;AACvC,CAAC,EALW,iBAAiB,KAAjB,iBAAiB,QAK5B;AAID,MAAM,UAAU,mBAAmB,CAAC,KAAc;IAChD,OAAO,MAAM,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC,QAAQ,CAAC,KAA0B,CAAC,CAAC;AAC/E,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Threat Severity Levels
3
+ * Domain value object (enum)
4
+ */
5
+ export declare enum ThreatSeverity {
6
+ LOW = "low",
7
+ MEDIUM = "medium",
8
+ HIGH = "high",
9
+ CRITICAL = "critical"
10
+ }
11
+ export type ThreatSeverityString = keyof typeof ThreatSeverity;
12
+ export declare function isThreatSeverity(value: unknown): value is ThreatSeverity;
13
+ //# sourceMappingURL=ThreatSeverity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ThreatSeverity.d.ts","sourceRoot":"","sources":["../../../src/domain/events/ThreatSeverity.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,oBAAY,cAAc;IACxB,GAAG,QAAQ;IACX,MAAM,WAAW;IACjB,IAAI,SAAS;IACb,QAAQ,aAAa;CACtB;AAED,MAAM,MAAM,oBAAoB,GAAG,MAAM,OAAO,cAAc,CAAC;AAE/D,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,cAAc,CAExE"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Threat Severity Levels
3
+ * Domain value object (enum)
4
+ */
5
+ export var ThreatSeverity;
6
+ (function (ThreatSeverity) {
7
+ ThreatSeverity["LOW"] = "low";
8
+ ThreatSeverity["MEDIUM"] = "medium";
9
+ ThreatSeverity["HIGH"] = "high";
10
+ ThreatSeverity["CRITICAL"] = "critical";
11
+ })(ThreatSeverity || (ThreatSeverity = {}));
12
+ export function isThreatSeverity(value) {
13
+ return Object.values(ThreatSeverity).includes(value);
14
+ }
15
+ //# sourceMappingURL=ThreatSeverity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ThreatSeverity.js","sourceRoot":"","sources":["../../../src/domain/events/ThreatSeverity.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,CAAN,IAAY,cAKX;AALD,WAAY,cAAc;IACxB,6BAAW,CAAA;IACX,mCAAiB,CAAA;IACjB,+BAAa,CAAA;IACb,uCAAqB,CAAA;AACvB,CAAC,EALW,cAAc,KAAd,cAAc,QAKzB;AAID,MAAM,UAAU,gBAAgB,CAAC,KAAc;IAC7C,OAAO,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,QAAQ,CAAC,KAAuB,CAAC,CAAC;AACzE,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Events Bounded Context
3
+ * Barrel export
4
+ */
5
+ export { ThreatSeverity, isThreatSeverity } from "./ThreatSeverity";
6
+ export type { ThreatSeverityString } from "./ThreatSeverity";
7
+ export { SecurityEventType, isSecurityEventType } from "./SecurityEventType";
8
+ export type { SecurityEventTypeString } from "./SecurityEventType";
9
+ export { createSecurityEvent } from "./SecurityEvent";
10
+ export type { SecurityEvent, SecurityEventMetadata } from "./SecurityEvent";
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/domain/events/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpE,YAAY,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAE7D,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC7E,YAAY,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAEnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,YAAY,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Events Bounded Context
3
+ * Barrel export
4
+ */
5
+ export { ThreatSeverity, isThreatSeverity } from './ThreatSeverity.js';
6
+ export { SecurityEventType, isSecurityEventType } from './SecurityEventType.js';
7
+ export { createSecurityEvent } from './SecurityEvent.js';
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/domain/events/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAGpE,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAG7E,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Tool Guard
3
+ * Domain service: pure tool call validation, no I/O side effects
4
+ * Does NOT throw — callers decide what to do with violations
5
+ */
6
+ import { ToolPolicy } from "./ToolPolicy";
7
+ import { ToolViolation } from "./ToolViolation";
8
+ export interface ToolCall {
9
+ readonly id: string;
10
+ readonly function: {
11
+ readonly name: string;
12
+ readonly arguments?: string | Record<string, unknown>;
13
+ };
14
+ readonly type?: "function";
15
+ }
16
+ export declare class ToolGuard {
17
+ private policy;
18
+ constructor(policy: ToolPolicy);
19
+ /**
20
+ * Validate a set of tool calls against the policy.
21
+ * Returns null if all tools are compliant.
22
+ * Returns the first violation found.
23
+ * Does NOT throw.
24
+ */
25
+ validate(toolCalls: readonly ToolCall[] | undefined, requestId: string): ToolViolation | null;
26
+ /**
27
+ * Update the policy at runtime
28
+ */
29
+ updatePolicy(policy: ToolPolicy): void;
30
+ /**
31
+ * Get current allowed tools (for diagnostics)
32
+ */
33
+ getAllowedTools(): readonly string[];
34
+ }
35
+ //# sourceMappingURL=ToolGuard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ToolGuard.d.ts","sourceRoot":"","sources":["../../../src/domain/guard/ToolGuard.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,UAAU,EAAiB,MAAM,cAAc,CAAC;AACzD,OAAO,EAAE,aAAa,EAAuB,MAAM,iBAAiB,CAAC;AAErE,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,QAAQ,EAAE;QACjB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACvD,CAAC;IACF,QAAQ,CAAC,IAAI,CAAC,EAAE,UAAU,CAAC;CAC5B;AAED,qBAAa,SAAS;IACR,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,UAAU;IAMtC;;;;;OAKG;IACH,QAAQ,CACN,SAAS,EAAE,SAAS,QAAQ,EAAE,GAAG,SAAS,EAC1C,SAAS,EAAE,MAAM,GAChB,aAAa,GAAG,IAAI;IAgBvB;;OAEG;IACH,YAAY,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;IAOtC;;OAEG;IACH,eAAe,IAAI,SAAS,MAAM,EAAE;CAGrC"}
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Tool Guard
3
+ * Domain service: pure tool call validation, no I/O side effects
4
+ * Does NOT throw — callers decide what to do with violations
5
+ */
6
+ import { isToolAllowed } from './ToolPolicy.js';
7
+ import { createToolViolation } from './ToolViolation.js';
8
+ export class ToolGuard {
9
+ constructor(policy) {
10
+ this.policy = policy;
11
+ if (!policy || !policy.allowedTools) {
12
+ throw new Error("[ToolGuard] Policy is required");
13
+ }
14
+ }
15
+ /**
16
+ * Validate a set of tool calls against the policy.
17
+ * Returns null if all tools are compliant.
18
+ * Returns the first violation found.
19
+ * Does NOT throw.
20
+ */
21
+ validate(toolCalls, requestId) {
22
+ if (!toolCalls || toolCalls.length === 0) {
23
+ return null; // No tools called — compliant
24
+ }
25
+ for (const toolCall of toolCalls) {
26
+ const toolName = toolCall.function.name;
27
+ if (!isToolAllowed(this.policy, toolName)) {
28
+ return createToolViolation(toolName, requestId);
29
+ }
30
+ }
31
+ return null; // All tools are allowed
32
+ }
33
+ /**
34
+ * Update the policy at runtime
35
+ */
36
+ updatePolicy(policy) {
37
+ if (!policy || !policy.allowedTools) {
38
+ throw new Error("[ToolGuard] Policy is required");
39
+ }
40
+ this.policy = policy;
41
+ }
42
+ /**
43
+ * Get current allowed tools (for diagnostics)
44
+ */
45
+ getAllowedTools() {
46
+ return Array.from(this.policy.allowedTools);
47
+ }
48
+ }
49
+ //# sourceMappingURL=ToolGuard.js.map