cbrowser 14.4.0 → 14.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.
- package/THIRD_PARTY_LICENSES.md +321 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/stealth/framework.d.ts +114 -0
- package/dist/stealth/framework.d.ts.map +1 -0
- package/dist/stealth/framework.js +293 -0
- package/dist/stealth/framework.js.map +1 -0
- package/dist/stealth/index.d.ts +21 -0
- package/dist/stealth/index.d.ts.map +1 -0
- package/dist/stealth/index.js +20 -0
- package/dist/stealth/index.js.map +1 -0
- package/dist/types.d.ts +141 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +19 -0
- package/dist/types.js.map +1 -1
- package/package.json +3 -2
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CBrowser - Cognitive Browser Automation
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2026 WF Media (Alexandria Eden)
|
|
5
|
+
* Email: alexandria.shai.eden@gmail.com
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the Business Source License 1.1
|
|
8
|
+
* found in the LICENSE file in the root directory of this source tree.
|
|
9
|
+
*
|
|
10
|
+
* Non-production use is permitted. Production use requires a commercial license.
|
|
11
|
+
* See LICENSE for full terms.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Default stealth configuration
|
|
15
|
+
*/
|
|
16
|
+
export const DEFAULT_STEALTH_CONFIG = {
|
|
17
|
+
enabled: false,
|
|
18
|
+
authorization: {
|
|
19
|
+
authorizedDomains: [],
|
|
20
|
+
blockedDomains: [],
|
|
21
|
+
requireExplicitAuth: true,
|
|
22
|
+
},
|
|
23
|
+
rateLimits: {
|
|
24
|
+
requestsPerMinute: 30,
|
|
25
|
+
formsPerMinute: 5,
|
|
26
|
+
authAttemptsPerMinute: 3,
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Default rate limits (cannot be lowered by user config)
|
|
31
|
+
*/
|
|
32
|
+
export const MINIMUM_RATE_LIMITS = {
|
|
33
|
+
requestsPerMinute: 10,
|
|
34
|
+
formsPerMinute: 2,
|
|
35
|
+
authAttemptsPerMinute: 2,
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Terms of Service for stealth mode
|
|
39
|
+
* Must be accepted before first use
|
|
40
|
+
*/
|
|
41
|
+
export const STEALTH_TERMS_OF_SERVICE = `
|
|
42
|
+
CBrowser Constitutional Stealth Mode - Terms of Service
|
|
43
|
+
|
|
44
|
+
By enabling stealth mode, you acknowledge and agree that:
|
|
45
|
+
|
|
46
|
+
1. AUTHORIZATION: You have explicit written authorization to perform
|
|
47
|
+
automated testing on all domains you configure.
|
|
48
|
+
|
|
49
|
+
2. OWNERSHIP: You own the domains or have a signed agreement with the owner.
|
|
50
|
+
|
|
51
|
+
3. NO MALICIOUS USE: You will not use stealth mode for:
|
|
52
|
+
- Unauthorized access to any system
|
|
53
|
+
- Bypassing security controls without authorization
|
|
54
|
+
- Scraping data in violation of Terms of Service
|
|
55
|
+
- Account creation automation without permission
|
|
56
|
+
- Any illegal activity
|
|
57
|
+
|
|
58
|
+
4. LIABILITY: You accept full legal responsibility for all actions
|
|
59
|
+
taken using stealth mode.
|
|
60
|
+
|
|
61
|
+
5. AUDIT COMPLIANCE: You consent to audit logs being retained for 90 days.
|
|
62
|
+
|
|
63
|
+
6. RATE LIMITS: You acknowledge that rate limits cannot be disabled
|
|
64
|
+
and are enforced to prevent abuse.
|
|
65
|
+
|
|
66
|
+
Type 'I AGREE' to continue.
|
|
67
|
+
`;
|
|
68
|
+
/**
|
|
69
|
+
* Check if a URL matches an authorized domain pattern
|
|
70
|
+
*/
|
|
71
|
+
export function matchesDomainPattern(url, pattern) {
|
|
72
|
+
try {
|
|
73
|
+
const urlObj = new URL(url);
|
|
74
|
+
const hostname = urlObj.hostname.toLowerCase();
|
|
75
|
+
const patternLower = pattern.toLowerCase();
|
|
76
|
+
// Exact match
|
|
77
|
+
if (hostname === patternLower) {
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
// Wildcard match (*.example.com)
|
|
81
|
+
if (patternLower.startsWith("*.")) {
|
|
82
|
+
const suffix = patternLower.slice(2);
|
|
83
|
+
return hostname.endsWith(suffix) || hostname === suffix.slice(1);
|
|
84
|
+
}
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
catch {
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Check if URL matches any prohibited domain pattern
|
|
93
|
+
*/
|
|
94
|
+
export function isProhibitedDomain(url) {
|
|
95
|
+
const prohibitedPatterns = [
|
|
96
|
+
"*.gov",
|
|
97
|
+
"*.mil",
|
|
98
|
+
"*.edu",
|
|
99
|
+
];
|
|
100
|
+
return prohibitedPatterns.some(pattern => matchesDomainPattern(url, pattern));
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Validate stealth acknowledgment
|
|
104
|
+
*/
|
|
105
|
+
export function validateAcknowledgment(ack) {
|
|
106
|
+
if (!ack.ownershipConfirmed)
|
|
107
|
+
return false;
|
|
108
|
+
if (!ack.authorizedTestingOnly)
|
|
109
|
+
return false;
|
|
110
|
+
if (!ack.acceptsResponsibility)
|
|
111
|
+
return false;
|
|
112
|
+
if (!ack.signedBy || ack.signedBy.trim() === "")
|
|
113
|
+
return false;
|
|
114
|
+
if (!ack.signedAt)
|
|
115
|
+
return false;
|
|
116
|
+
// Check that signature is not too old (90 days)
|
|
117
|
+
const signedDate = new Date(ack.signedAt);
|
|
118
|
+
const now = new Date();
|
|
119
|
+
const daysDiff = (now.getTime() - signedDate.getTime()) / (1000 * 60 * 60 * 24);
|
|
120
|
+
return daysDiff <= 90;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Merge user config with defaults, enforcing minimum rate limits
|
|
124
|
+
*/
|
|
125
|
+
export function mergeStealthConfig(userConfig) {
|
|
126
|
+
const merged = { ...DEFAULT_STEALTH_CONFIG, ...userConfig };
|
|
127
|
+
// Enforce minimum rate limits
|
|
128
|
+
if (merged.rateLimits) {
|
|
129
|
+
merged.rateLimits = {
|
|
130
|
+
requestsPerMinute: Math.max(merged.rateLimits.requestsPerMinute, MINIMUM_RATE_LIMITS.requestsPerMinute),
|
|
131
|
+
formsPerMinute: Math.max(merged.rateLimits.formsPerMinute, MINIMUM_RATE_LIMITS.formsPerMinute),
|
|
132
|
+
authAttemptsPerMinute: Math.max(merged.rateLimits.authAttemptsPerMinute, MINIMUM_RATE_LIMITS.authAttemptsPerMinute),
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
return merged;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Base constitutional enforcer with framework logic
|
|
139
|
+
* Extended by cbrowser-enterprise for full implementation
|
|
140
|
+
*/
|
|
141
|
+
export class BaseConstitutionalEnforcer {
|
|
142
|
+
config;
|
|
143
|
+
auditLog = [];
|
|
144
|
+
requestCounts = new Map();
|
|
145
|
+
constructor(config = {}) {
|
|
146
|
+
this.config = mergeStealthConfig(config);
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Check if domain is authorized
|
|
150
|
+
*/
|
|
151
|
+
isDomainAuthorized(url) {
|
|
152
|
+
// Check prohibited domains first
|
|
153
|
+
if (isProhibitedDomain(url)) {
|
|
154
|
+
return false;
|
|
155
|
+
}
|
|
156
|
+
// Check blocked domains
|
|
157
|
+
for (const blocked of this.config.authorization.blockedDomains) {
|
|
158
|
+
if (matchesDomainPattern(url, blocked)) {
|
|
159
|
+
return false;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
// Check authorized domains
|
|
163
|
+
for (const authorized of this.config.authorization.authorizedDomains) {
|
|
164
|
+
if (matchesDomainPattern(url, authorized)) {
|
|
165
|
+
return true;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return false;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Check if action is allowed with stealth
|
|
172
|
+
*/
|
|
173
|
+
async canExecuteWithStealth(action, url) {
|
|
174
|
+
// 1. Check if stealth is enabled
|
|
175
|
+
if (!this.config.enabled) {
|
|
176
|
+
return {
|
|
177
|
+
allowed: false,
|
|
178
|
+
zone: "red",
|
|
179
|
+
reason: "Stealth mode is not enabled",
|
|
180
|
+
suggestion: "Enable stealth mode in config or with --stealth flag",
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
// 2. Check domain authorization
|
|
184
|
+
if (!this.isDomainAuthorized(url)) {
|
|
185
|
+
return {
|
|
186
|
+
allowed: false,
|
|
187
|
+
zone: "black",
|
|
188
|
+
reason: `Domain not in authorized list: ${new URL(url).hostname}`,
|
|
189
|
+
suggestion: "Add domain to authorizedDomains in stealth config",
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
// 3. Check prohibited actions
|
|
193
|
+
const prohibitedActions = [
|
|
194
|
+
"bypass_captcha",
|
|
195
|
+
"inject_cookies",
|
|
196
|
+
"spoof_identity",
|
|
197
|
+
"mass_account_creation",
|
|
198
|
+
"credential_stuffing",
|
|
199
|
+
"rate_limit_bypass",
|
|
200
|
+
];
|
|
201
|
+
if (prohibitedActions.includes(action)) {
|
|
202
|
+
return {
|
|
203
|
+
allowed: false,
|
|
204
|
+
zone: "black",
|
|
205
|
+
reason: `Action '${action}' is prohibited with stealth mode`,
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
// 4. Check rate limits
|
|
209
|
+
const rateLimitStatus = this.getRateLimitStatus();
|
|
210
|
+
if (rateLimitStatus.remaining <= 0) {
|
|
211
|
+
return {
|
|
212
|
+
allowed: false,
|
|
213
|
+
zone: "red",
|
|
214
|
+
reason: "Rate limit exceeded",
|
|
215
|
+
suggestion: `Wait until ${rateLimitStatus.resetsAt.toISOString()}`,
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
// 5. Check acknowledgment if required
|
|
219
|
+
if (this.config.authorization.requireExplicitAuth && !this.config.acknowledgment) {
|
|
220
|
+
return {
|
|
221
|
+
allowed: false,
|
|
222
|
+
zone: "red",
|
|
223
|
+
reason: "Stealth mode requires signed acknowledgment",
|
|
224
|
+
requiresConfirmation: true,
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
if (this.config.acknowledgment && !validateAcknowledgment(this.config.acknowledgment)) {
|
|
228
|
+
return {
|
|
229
|
+
allowed: false,
|
|
230
|
+
zone: "red",
|
|
231
|
+
reason: "Acknowledgment is invalid or expired (>90 days)",
|
|
232
|
+
requiresConfirmation: true,
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
return {
|
|
236
|
+
allowed: true,
|
|
237
|
+
zone: "green",
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Log audit entry (immutable)
|
|
242
|
+
*/
|
|
243
|
+
async logAudit(entry) {
|
|
244
|
+
const fullEntry = {
|
|
245
|
+
...entry,
|
|
246
|
+
timestamp: new Date().toISOString(),
|
|
247
|
+
};
|
|
248
|
+
this.auditLog.push(fullEntry);
|
|
249
|
+
// Subclass should persist to disk/database
|
|
250
|
+
await this.persistAuditEntry(fullEntry);
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Get rate limit status
|
|
254
|
+
*/
|
|
255
|
+
getRateLimitStatus() {
|
|
256
|
+
const now = new Date();
|
|
257
|
+
const key = "requests";
|
|
258
|
+
const current = this.requestCounts.get(key);
|
|
259
|
+
if (!current || current.resetAt < now) {
|
|
260
|
+
const resetsAt = new Date(now.getTime() + 60000); // 1 minute
|
|
261
|
+
return {
|
|
262
|
+
remaining: this.config.rateLimits.requestsPerMinute,
|
|
263
|
+
resetsAt,
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
return {
|
|
267
|
+
remaining: this.config.rateLimits.requestsPerMinute - current.count,
|
|
268
|
+
resetsAt: current.resetAt,
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Validate acknowledgment
|
|
273
|
+
*/
|
|
274
|
+
validateAcknowledgment(ack) {
|
|
275
|
+
return validateAcknowledgment(ack);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* No-op enforcer for public repo (stealth not available)
|
|
280
|
+
* Stealth implementation requires cbrowser-enterprise
|
|
281
|
+
*/
|
|
282
|
+
export class NoOpConstitutionalEnforcer extends BaseConstitutionalEnforcer {
|
|
283
|
+
async persistAuditEntry(_entry) {
|
|
284
|
+
// No-op in public version
|
|
285
|
+
console.log("[Stealth] Audit entry logged (not persisted - requires cbrowser-enterprise)");
|
|
286
|
+
}
|
|
287
|
+
async applyStealthMeasures(_page) {
|
|
288
|
+
console.warn("[Stealth] Stealth measures not available in public cbrowser.\n" +
|
|
289
|
+
"For full stealth capabilities, upgrade to cbrowser-enterprise.\n" +
|
|
290
|
+
"Contact: alexandria.shai.eden@gmail.com");
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
//# sourceMappingURL=framework.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"framework.js","sourceRoot":"","sources":["../../src/stealth/framework.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AA6BH;;GAEG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAkB;IACnD,OAAO,EAAE,KAAK;IACd,aAAa,EAAE;QACb,iBAAiB,EAAE,EAAE;QACrB,cAAc,EAAE,EAAE;QAClB,mBAAmB,EAAE,IAAI;KAC1B;IACD,UAAU,EAAE;QACV,iBAAiB,EAAE,EAAE;QACrB,cAAc,EAAE,CAAC;QACjB,qBAAqB,EAAE,CAAC;KACzB;CACF,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAsB;IACpD,iBAAiB,EAAE,EAAE;IACrB,cAAc,EAAE,CAAC;IAC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AAO,0BAA2B,SAAQ,0BAA0B;IAC9D,KAAK,CAAC,iBAAiB,CAAC,MAAyB;QACzD,0BAA0B;QAC1B,OAAO,CAAC,GAAG,CAAC,6EAA6E,CAAC,CAAC;IAC7F,CAAC;IAED,KAAK,CAAC,oBAAoB,CAAC,KAAc;QACvC,OAAO,CAAC,IAAI,CACV,gEAAgE;YAChE,kEAAkE;YAClE,yCAAyC,CAC1C,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CBrowser - Cognitive Browser Automation
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2026 WF Media (Alexandria Eden)
|
|
5
|
+
* Email: alexandria.shai.eden@gmail.com
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the Business Source License 1.1
|
|
8
|
+
* found in the LICENSE file in the root directory of this source tree.
|
|
9
|
+
*
|
|
10
|
+
* Non-production use is permitted. Production use requires a commercial license.
|
|
11
|
+
* See LICENSE for full terms.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Constitutional Stealth Framework
|
|
15
|
+
*
|
|
16
|
+
* Public framework for ethical stealth mode.
|
|
17
|
+
* Full implementation available in cbrowser-enterprise.
|
|
18
|
+
*/
|
|
19
|
+
export { DEFAULT_STEALTH_CONFIG, MINIMUM_RATE_LIMITS, STEALTH_TERMS_OF_SERVICE, matchesDomainPattern, isProhibitedDomain, validateAcknowledgment, mergeStealthConfig, BaseConstitutionalEnforcer, NoOpConstitutionalEnforcer, } from "./framework.js";
|
|
20
|
+
export type { StealthConfig, StealthAuthorization, StealthAcknowledgment, StealthRateLimits, StealthAuditEntry, StealthCheckResult, IConstitutionalEnforcer, } from "./framework.js";
|
|
21
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/stealth/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH;;;;;GAKG;AAEH,OAAO,EACL,sBAAsB,EACtB,mBAAmB,EACnB,wBAAwB,EACxB,oBAAoB,EACpB,kBAAkB,EAClB,sBAAsB,EACtB,kBAAkB,EAClB,0BAA0B,EAC1B,0BAA0B,GAC3B,MAAM,gBAAgB,CAAC;AAExB,YAAY,EACV,aAAa,EACb,oBAAoB,EACpB,qBAAqB,EACrB,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,uBAAuB,GACxB,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CBrowser - Cognitive Browser Automation
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2026 WF Media (Alexandria Eden)
|
|
5
|
+
* Email: alexandria.shai.eden@gmail.com
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the Business Source License 1.1
|
|
8
|
+
* found in the LICENSE file in the root directory of this source tree.
|
|
9
|
+
*
|
|
10
|
+
* Non-production use is permitted. Production use requires a commercial license.
|
|
11
|
+
* See LICENSE for full terms.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Constitutional Stealth Framework
|
|
15
|
+
*
|
|
16
|
+
* Public framework for ethical stealth mode.
|
|
17
|
+
* Full implementation available in cbrowser-enterprise.
|
|
18
|
+
*/
|
|
19
|
+
export { DEFAULT_STEALTH_CONFIG, MINIMUM_RATE_LIMITS, STEALTH_TERMS_OF_SERVICE, matchesDomainPattern, isProhibitedDomain, validateAcknowledgment, mergeStealthConfig, BaseConstitutionalEnforcer, NoOpConstitutionalEnforcer, } from "./framework.js";
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/stealth/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH;;;;;GAKG;AAEH,OAAO,EACL,sBAAsB,EACtB,mBAAmB,EACnB,wBAAwB,EACxB,oBAAoB,EACpB,kBAAkB,EAClB,sBAAsB,EACtB,kBAAkB,EAClB,0BAA0B,EAC1B,0BAA0B,GAC3B,MAAM,gBAAgB,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -3222,4 +3222,145 @@ export interface AccessibilityPersona extends Omit<Persona, 'cognitiveTraits'> {
|
|
|
3222
3222
|
/** Cognitive traits (optional partial override) */
|
|
3223
3223
|
cognitiveTraits?: Partial<CognitiveTraits>;
|
|
3224
3224
|
}
|
|
3225
|
+
/**
|
|
3226
|
+
* Domain authorization for stealth mode
|
|
3227
|
+
* Users must explicitly declare which domains they're authorized to test
|
|
3228
|
+
*/
|
|
3229
|
+
export interface StealthAuthorization {
|
|
3230
|
+
/** Domains user owns or has explicit permission to test (supports wildcards) */
|
|
3231
|
+
authorizedDomains: string[];
|
|
3232
|
+
/** Domains explicitly blocked even if matched by wildcard */
|
|
3233
|
+
blockedDomains: string[];
|
|
3234
|
+
/** Require explicit authorization for stealth mode */
|
|
3235
|
+
requireExplicitAuth: boolean;
|
|
3236
|
+
/** How authorization was provided */
|
|
3237
|
+
authorizationSource?: "config" | "cli-flag" | "environment" | "api";
|
|
3238
|
+
}
|
|
3239
|
+
/**
|
|
3240
|
+
* Constitutional stealth configuration
|
|
3241
|
+
*/
|
|
3242
|
+
export interface StealthConfig {
|
|
3243
|
+
/** Whether stealth mode is enabled */
|
|
3244
|
+
enabled: boolean;
|
|
3245
|
+
/** Domain authorization settings */
|
|
3246
|
+
authorization: StealthAuthorization;
|
|
3247
|
+
/** User acknowledgment of ethical use terms */
|
|
3248
|
+
acknowledgment?: StealthAcknowledgment;
|
|
3249
|
+
/** Rate limits (cannot be disabled) */
|
|
3250
|
+
rateLimits: StealthRateLimits;
|
|
3251
|
+
/** Stealth features to enable */
|
|
3252
|
+
features?: StealthFeatures;
|
|
3253
|
+
}
|
|
3254
|
+
/**
|
|
3255
|
+
* User acknowledgment of ethical use terms
|
|
3256
|
+
*/
|
|
3257
|
+
export interface StealthAcknowledgment {
|
|
3258
|
+
/** User confirms ownership/authorization for listed domains */
|
|
3259
|
+
ownershipConfirmed: boolean;
|
|
3260
|
+
/** User confirms authorized testing only */
|
|
3261
|
+
authorizedTestingOnly: boolean;
|
|
3262
|
+
/** User accepts legal responsibility */
|
|
3263
|
+
acceptsResponsibility: boolean;
|
|
3264
|
+
/** Email or identifier of person signing */
|
|
3265
|
+
signedBy: string;
|
|
3266
|
+
/** Timestamp of signing */
|
|
3267
|
+
signedAt: string;
|
|
3268
|
+
}
|
|
3269
|
+
/**
|
|
3270
|
+
* Rate limits for stealth mode (cannot be disabled)
|
|
3271
|
+
*/
|
|
3272
|
+
export interface StealthRateLimits {
|
|
3273
|
+
/** Max requests per minute */
|
|
3274
|
+
requestsPerMinute: number;
|
|
3275
|
+
/** Max form submissions per minute */
|
|
3276
|
+
formsPerMinute: number;
|
|
3277
|
+
/** Max auth attempts per minute */
|
|
3278
|
+
authAttemptsPerMinute: number;
|
|
3279
|
+
}
|
|
3280
|
+
/**
|
|
3281
|
+
* Stealth features that can be enabled
|
|
3282
|
+
*/
|
|
3283
|
+
export interface StealthFeatures {
|
|
3284
|
+
/** Remove webdriver flag */
|
|
3285
|
+
hideWebdriver?: boolean;
|
|
3286
|
+
/** Use headed mode (less detectable) */
|
|
3287
|
+
headedMode?: boolean;
|
|
3288
|
+
/** Randomize fingerprints */
|
|
3289
|
+
fingerprintRandomization?: boolean;
|
|
3290
|
+
/** Use stealth plugin */
|
|
3291
|
+
stealthPlugin?: boolean;
|
|
3292
|
+
/** Emulate human-like timing (CBrowser default) */
|
|
3293
|
+
humanTiming?: boolean;
|
|
3294
|
+
}
|
|
3295
|
+
/**
|
|
3296
|
+
* Audit entry for stealth actions (immutable, 90-day retention)
|
|
3297
|
+
*/
|
|
3298
|
+
export interface StealthAuditEntry {
|
|
3299
|
+
/** Timestamp of action */
|
|
3300
|
+
timestamp: string;
|
|
3301
|
+
/** Action performed */
|
|
3302
|
+
action: string;
|
|
3303
|
+
/** Target URL */
|
|
3304
|
+
url: string;
|
|
3305
|
+
/** Whether stealth was enabled */
|
|
3306
|
+
stealthEnabled: boolean;
|
|
3307
|
+
/** How authorization was provided */
|
|
3308
|
+
authorizationSource: string;
|
|
3309
|
+
/** Which authorized domain matched */
|
|
3310
|
+
authorizedDomain: string;
|
|
3311
|
+
/** Constitutional zone classification */
|
|
3312
|
+
zone: ActionZone;
|
|
3313
|
+
/** Whether force override was used */
|
|
3314
|
+
forceOverride?: boolean;
|
|
3315
|
+
/** Reason for force override */
|
|
3316
|
+
forceReason?: string;
|
|
3317
|
+
/** Requests in last minute (rate limit context) */
|
|
3318
|
+
requestsInLastMinute: number;
|
|
3319
|
+
/** Forms submitted in last minute */
|
|
3320
|
+
formsInLastMinute: number;
|
|
3321
|
+
}
|
|
3322
|
+
/**
|
|
3323
|
+
* Result of constitutional check before stealth action
|
|
3324
|
+
*/
|
|
3325
|
+
export interface StealthCheckResult {
|
|
3326
|
+
/** Whether action is allowed */
|
|
3327
|
+
allowed: boolean;
|
|
3328
|
+
/** Constitutional zone */
|
|
3329
|
+
zone: ActionZone;
|
|
3330
|
+
/** Reason if blocked */
|
|
3331
|
+
reason?: string;
|
|
3332
|
+
/** Whether user confirmation is required */
|
|
3333
|
+
requiresConfirmation?: boolean;
|
|
3334
|
+
/** Suggested alternative if blocked */
|
|
3335
|
+
suggestion?: string;
|
|
3336
|
+
}
|
|
3337
|
+
/**
|
|
3338
|
+
* Actions that are NEVER allowed with stealth mode (Black Zone)
|
|
3339
|
+
*/
|
|
3340
|
+
export declare const STEALTH_PROHIBITED_ACTIONS: readonly ["bypass_captcha", "inject_cookies", "spoof_identity", "mass_account_creation", "credential_stuffing", "rate_limit_bypass"];
|
|
3341
|
+
export type StealthProhibitedAction = typeof STEALTH_PROHIBITED_ACTIONS[number];
|
|
3342
|
+
/**
|
|
3343
|
+
* Domain patterns that are NEVER allowed with stealth mode
|
|
3344
|
+
*/
|
|
3345
|
+
export declare const STEALTH_PROHIBITED_DOMAINS: readonly ["*.gov", "*.mil", "*.edu"];
|
|
3346
|
+
export type StealthProhibitedDomain = typeof STEALTH_PROHIBITED_DOMAINS[number];
|
|
3347
|
+
/**
|
|
3348
|
+
* Abstract interface for constitutional enforcer
|
|
3349
|
+
* Implementation provided by cbrowser-enterprise
|
|
3350
|
+
*/
|
|
3351
|
+
export interface IConstitutionalEnforcer {
|
|
3352
|
+
/** Check if stealth action is allowed */
|
|
3353
|
+
canExecuteWithStealth(action: string, url: string): Promise<StealthCheckResult>;
|
|
3354
|
+
/** Log audit entry (immutable) */
|
|
3355
|
+
logAudit(entry: Omit<StealthAuditEntry, "timestamp">): Promise<void>;
|
|
3356
|
+
/** Check if domain is authorized */
|
|
3357
|
+
isDomainAuthorized(url: string): boolean;
|
|
3358
|
+
/** Get current rate limit status */
|
|
3359
|
+
getRateLimitStatus(): {
|
|
3360
|
+
remaining: number;
|
|
3361
|
+
resetsAt: Date;
|
|
3362
|
+
};
|
|
3363
|
+
/** Validate acknowledgment */
|
|
3364
|
+
validateAcknowledgment(ack: StealthAcknowledgment): boolean;
|
|
3365
|
+
}
|
|
3225
3366
|
//# sourceMappingURL=types.d.ts.map
|