devfortress-sdk 4.2.0 → 4.2.1

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/dist/index.d.ts CHANGED
@@ -1,35 +1,3 @@
1
- /**
2
- * DevFortress SDK v4.0.0 — Main Entry Point (Node.js)
3
- *
4
- * For browser usage, import from 'devfortress-sdk/browser' instead.
5
- * For zero-config quick start, import from 'devfortress-sdk/quick'.
6
- * For Express middleware, use devfortressMiddleware from this package.
7
- * For FastAPI/Flask, see the Python middleware in src/middleware/
8
- *
9
- * NEW in v4.0 — Closed-Loop Mode Architecture:
10
- * - Three protection modes: external, internal, hybrid
11
- * - Circuit breaker with automatic failover (hybrid mode)
12
- * - Unified audit trail (internal + external merged timeline)
13
- * - Tier-gated feature access (Starter/Pro/Enterprise)
14
- * - Backward compatible — existing external-mode code works unchanged
15
- *
16
- * v3.3:
17
- * - Internal Closed-Loop Engine (3-tier deterministic + ML + async relay)
18
- * - Air-gap mode support (no external dependencies in Tier 1 + 2)
19
- *
20
- * v3.2:
21
- * - Agent security (AgentAdapter, credential management, anomaly detection)
22
- *
23
- * v3.1:
24
- * - Zero-config quick start (df.init({ apiKey }))
25
- * - Privacy-strict mode, Debug mode
26
- *
27
- * v3.0:
28
- * - DevFortress class with observe(), isBlocked(), onThreatDetected()
29
- * - AbuseIPDB integration, Token alias security, Webhook handler
30
- *
31
- * @packageDocumentation
32
- */
33
1
  export { init, getInstance, getDataSnapshot } from './quick';
34
2
  export type { QuickConfig } from './quick';
35
3
  export { DevFortress } from './devfortress';
package/dist/index.js CHANGED
@@ -1,65 +1,27 @@
1
1
  "use strict";
2
- /**
3
- * DevFortress SDK v4.0.0 — Main Entry Point (Node.js)
4
- *
5
- * For browser usage, import from 'devfortress-sdk/browser' instead.
6
- * For zero-config quick start, import from 'devfortress-sdk/quick'.
7
- * For Express middleware, use devfortressMiddleware from this package.
8
- * For FastAPI/Flask, see the Python middleware in src/middleware/
9
- *
10
- * NEW in v4.0 — Closed-Loop Mode Architecture:
11
- * - Three protection modes: external, internal, hybrid
12
- * - Circuit breaker with automatic failover (hybrid mode)
13
- * - Unified audit trail (internal + external merged timeline)
14
- * - Tier-gated feature access (Starter/Pro/Enterprise)
15
- * - Backward compatible — existing external-mode code works unchanged
16
- *
17
- * v3.3:
18
- * - Internal Closed-Loop Engine (3-tier deterministic + ML + async relay)
19
- * - Air-gap mode support (no external dependencies in Tier 1 + 2)
20
- *
21
- * v3.2:
22
- * - Agent security (AgentAdapter, credential management, anomaly detection)
23
- *
24
- * v3.1:
25
- * - Zero-config quick start (df.init({ apiKey }))
26
- * - Privacy-strict mode, Debug mode
27
- *
28
- * v3.0:
29
- * - DevFortress class with observe(), isBlocked(), onThreatDetected()
30
- * - AbuseIPDB integration, Token alias security, Webhook handler
31
- *
32
- * @packageDocumentation
33
- */
34
2
  Object.defineProperty(exports, "__esModule", { value: true });
35
3
  exports.devfortressMiddleware = exports.DevFortressClient = exports.InternalClosedLoopEngine = exports.AgentScopeEnforcer = exports.AgentAnomalyDetector = exports.AgentBaselineEngine = exports.AgentCredentialManager = exports.validateAgentId = exports.AgentAdapter = exports.EmergencyBlocklist = exports.TokenAliasManager = exports.getCachedScore = exports.scoreThreat = exports.syncBlacklist = exports.reportIP = exports.checkIP = exports.TierGate = exports.UnifiedAuditTrail = exports.PlatformCircuitBreaker = exports.DevFortress = exports.getDataSnapshot = exports.getInstance = exports.init = void 0;
36
- // v3.1 — Zero-config quick start
37
4
  var quick_1 = require("./quick");
38
5
  Object.defineProperty(exports, "init", { enumerable: true, get: function () { return quick_1.init; } });
39
6
  Object.defineProperty(exports, "getInstance", { enumerable: true, get: function () { return quick_1.getInstance; } });
40
7
  Object.defineProperty(exports, "getDataSnapshot", { enumerable: true, get: function () { return quick_1.getDataSnapshot; } });
41
- // v3.0 — Primary export
42
8
  var devfortress_1 = require("./devfortress");
43
9
  Object.defineProperty(exports, "DevFortress", { enumerable: true, get: function () { return devfortress_1.DevFortress; } });
44
- // v4.0 — Closed-Loop Mode Architecture
45
10
  var circuit_breaker_1 = require("./circuit-breaker");
46
11
  Object.defineProperty(exports, "PlatformCircuitBreaker", { enumerable: true, get: function () { return circuit_breaker_1.PlatformCircuitBreaker; } });
47
12
  var unified_audit_1 = require("./unified-audit");
48
13
  Object.defineProperty(exports, "UnifiedAuditTrail", { enumerable: true, get: function () { return unified_audit_1.UnifiedAuditTrail; } });
49
14
  var tier_gate_1 = require("./tier-gate");
50
15
  Object.defineProperty(exports, "TierGate", { enumerable: true, get: function () { return tier_gate_1.TierGate; } });
51
- // v3.0 — AbuseIPDB integration
52
16
  var abuseipdb_1 = require("./abuseipdb");
53
17
  Object.defineProperty(exports, "checkIP", { enumerable: true, get: function () { return abuseipdb_1.checkIP; } });
54
18
  Object.defineProperty(exports, "reportIP", { enumerable: true, get: function () { return abuseipdb_1.reportIP; } });
55
19
  Object.defineProperty(exports, "syncBlacklist", { enumerable: true, get: function () { return abuseipdb_1.syncBlacklist; } });
56
20
  Object.defineProperty(exports, "scoreThreat", { enumerable: true, get: function () { return abuseipdb_1.scoreThreat; } });
57
21
  Object.defineProperty(exports, "getCachedScore", { enumerable: true, get: function () { return abuseipdb_1.getCachedScore; } });
58
- // v3.0 — Token alias security
59
22
  var token_alias_1 = require("./token-alias");
60
23
  Object.defineProperty(exports, "TokenAliasManager", { enumerable: true, get: function () { return token_alias_1.TokenAliasManager; } });
61
24
  Object.defineProperty(exports, "EmergencyBlocklist", { enumerable: true, get: function () { return token_alias_1.EmergencyBlocklist; } });
62
- // v3.2 — Agent Security (IP-C1 through IP-C5)
63
25
  var agent_1 = require("./agent");
64
26
  Object.defineProperty(exports, "AgentAdapter", { enumerable: true, get: function () { return agent_1.AgentAdapter; } });
65
27
  Object.defineProperty(exports, "validateAgentId", { enumerable: true, get: function () { return agent_1.validateAgentId; } });
@@ -68,10 +30,8 @@ Object.defineProperty(exports, "AgentCredentialManager", { enumerable: true, get
68
30
  Object.defineProperty(exports, "AgentBaselineEngine", { enumerable: true, get: function () { return agent_security_1.AgentBaselineEngine; } });
69
31
  Object.defineProperty(exports, "AgentAnomalyDetector", { enumerable: true, get: function () { return agent_security_1.AgentAnomalyDetector; } });
70
32
  Object.defineProperty(exports, "AgentScopeEnforcer", { enumerable: true, get: function () { return agent_security_1.AgentScopeEnforcer; } });
71
- // v3.3 — Internal Closed-Loop Engine
72
33
  var internal_closed_loop_engine_1 = require("./internal-closed-loop-engine");
73
34
  Object.defineProperty(exports, "InternalClosedLoopEngine", { enumerable: true, get: function () { return internal_closed_loop_engine_1.InternalClosedLoopEngine; } });
74
- // v1.x — Backward compatible exports
75
35
  var client_1 = require("./client");
76
36
  Object.defineProperty(exports, "DevFortressClient", { enumerable: true, get: function () { return client_1.DevFortressClient; } });
77
37
  var express_1 = require("./middleware/express");
@@ -0,0 +1,123 @@
1
+ import type { ThreatSeverity } from './types';
2
+ export interface InternalCLConfig {
3
+ failMode?: 'closed' | 'open';
4
+ enableExternalRelay?: boolean;
5
+ maxBlockedEntries?: number;
6
+ maxRateLimitEntries?: number;
7
+ maxAuditEntries?: number;
8
+ defaultBlockTtlSeconds?: number;
9
+ tier2Scorer?: (request: InternalCLRequest) => Promise<number> | number;
10
+ blockThreshold?: number;
11
+ rateLimitThreshold?: number;
12
+ rateLimitMax?: number;
13
+ rateLimitWindowMs?: number;
14
+ debug?: boolean;
15
+ onAction?: (action: InternalCLAction) => Promise<void> | void;
16
+ }
17
+ export interface InternalCLRequest {
18
+ ip: string;
19
+ method: string;
20
+ path: string;
21
+ userAgent?: string;
22
+ userId?: string | null;
23
+ sessionId?: string | null;
24
+ body?: string;
25
+ query?: string;
26
+ headers?: Record<string, string>;
27
+ agentId?: string;
28
+ toolName?: string;
29
+ timestamp?: number;
30
+ }
31
+ export type InternalCLDecision = 'allow' | 'block' | 'rate_limit' | 'challenge' | 'quarantine';
32
+ export interface InternalCLResult {
33
+ decision: InternalCLDecision;
34
+ score: number;
35
+ tier: 1 | 2 | 3;
36
+ matchedRules: string[];
37
+ evaluationTimeUs: number;
38
+ actions: InternalCLAction[];
39
+ eventId: string;
40
+ }
41
+ export interface InternalCLAction {
42
+ type: 'block_ip' | 'rate_limit' | 'block_session' | 'block_user' | 'quarantine_agent' | 'log';
43
+ target: string;
44
+ reason: string;
45
+ ttlSeconds: number;
46
+ timestamp: number;
47
+ eventId: string;
48
+ }
49
+ export interface InternalCLAuditEntry {
50
+ eventId: string;
51
+ timestamp: number;
52
+ ip: string;
53
+ decision: InternalCLDecision;
54
+ score: number;
55
+ tier: 1 | 2 | 3;
56
+ matchedRules: string[];
57
+ userId?: string | null;
58
+ agentId?: string;
59
+ path: string;
60
+ method: string;
61
+ }
62
+ export interface InternalCLRule {
63
+ name: string;
64
+ description: string;
65
+ severity: ThreatSeverity;
66
+ score: number;
67
+ decision: InternalCLDecision;
68
+ match: (req: InternalCLRequest) => boolean;
69
+ enabled: boolean;
70
+ }
71
+ export declare class InternalClosedLoopEngine {
72
+ private config;
73
+ private blockedIPs;
74
+ private blockedUsers;
75
+ private blockedSessions;
76
+ private quarantinedAgents;
77
+ private rateLimiter;
78
+ private auditLog;
79
+ private rules;
80
+ private eventCounter;
81
+ constructor(config?: InternalCLConfig);
82
+ evaluate(req: InternalCLRequest): Promise<InternalCLResult>;
83
+ blockIP(ip: string, reason: string, ttlSeconds?: number): void;
84
+ unblockIP(ip: string): boolean;
85
+ blockUser(userId: string, reason: string, ttlSeconds?: number): void;
86
+ blockSession(sessionId: string, reason: string, ttlSeconds?: number): void;
87
+ quarantineAgent(agentId: string, reason: string): void;
88
+ unquarantineAgent(agentId: string): boolean;
89
+ isIPBlocked(ip: string): boolean;
90
+ isAgentQuarantined(agentId: string): boolean;
91
+ addRule(rule: InternalCLRule): void;
92
+ removeRule(name: string): boolean;
93
+ getRules(): ReadonlyArray<Omit<InternalCLRule, 'match'> & {
94
+ name: string;
95
+ }>;
96
+ getAuditLog(limit?: number): ReadonlyArray<InternalCLAuditEntry>;
97
+ getStats(): {
98
+ blockedIPs: number;
99
+ blockedUsers: number;
100
+ blockedSessions: number;
101
+ quarantinedAgents: number;
102
+ rateLimitEntries: number;
103
+ auditLogSize: number;
104
+ rulesCount: number;
105
+ failMode: string;
106
+ };
107
+ importBlockedIPs(entries: Array<{
108
+ ip: string;
109
+ reason: string;
110
+ ttlSeconds?: number;
111
+ }>): number;
112
+ _reset(): void;
113
+ private checkBlocked;
114
+ private evaluateTier1;
115
+ private checkRateLimit;
116
+ private recordRequest;
117
+ private executeActions;
118
+ private recordAudit;
119
+ private relayToExternal;
120
+ private generateEventId;
121
+ private registerDefaultRules;
122
+ private log;
123
+ }