claude-flow-novice 1.6.2 → 1.6.3
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/.claude/settings.json +4 -3
- package/.claude-flow-novice/dist/src/api/auth-service.js +84 -38
- package/.claude-flow-novice/dist/src/api/auth-service.js.map +1 -1
- package/.claude-flow-novice/dist/src/monitoring/apm/apm-integration.js +719 -0
- package/.claude-flow-novice/dist/src/monitoring/apm/apm-integration.js.map +1 -0
- package/.claude-flow-novice/dist/src/monitoring/apm/datadog-collector.js +363 -0
- package/.claude-flow-novice/dist/src/monitoring/apm/datadog-collector.js.map +1 -0
- package/.claude-flow-novice/dist/src/monitoring/apm/index.js +97 -0
- package/.claude-flow-novice/dist/src/monitoring/apm/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/monitoring/apm/newrelic-collector.js +384 -0
- package/.claude-flow-novice/dist/src/monitoring/apm/newrelic-collector.js.map +1 -0
- package/.claude-flow-novice/dist/src/monitoring/apm/performance-optimizer.js +612 -0
- package/.claude-flow-novice/dist/src/monitoring/apm/performance-optimizer.js.map +1 -0
- package/.claude-flow-novice/dist/src/monitoring/metrics-collector.js +282 -0
- package/.claude-flow-novice/dist/src/monitoring/metrics-collector.js.map +1 -0
- package/.claude-flow-novice/dist/src/web/api/apm-routes.js +355 -0
- package/.claude-flow-novice/dist/src/web/api/apm-routes.js.map +1 -0
- package/.claude-flow-novice/dist/src/web/frontend/src/utils/security.js +425 -0
- package/.claude-flow-novice/dist/src/web/frontend/src/utils/security.js.map +1 -0
- package/.claude-flow-novice/dist/src/web/security/security-middleware.js +379 -0
- package/.claude-flow-novice/dist/src/web/security/security-middleware.js.map +1 -0
- package/.claude-flow-novice/dist/src/web/websocket/apm-websocket-handler.js +441 -0
- package/.claude-flow-novice/dist/src/web/websocket/apm-websocket-handler.js.map +1 -0
- package/.claude-flow-novice/dist/src/web/websocket/websocket-manager.js +255 -1
- package/.claude-flow-novice/dist/src/web/websocket/websocket-manager.js.map +1 -1
- package/AGENT_PERFORMANCE_GUIDELINES.md +88 -0
- package/CLAUDE.md +31 -3
- package/MEMORY_LEAK_ROOT_CAUSE.md +149 -0
- package/package.json +4 -2
- package/scripts/monitor-loop.sh +65 -0
- package/scripts/monitor-memory.sh +47 -0
- package/scripts/monitor.py +43 -0
|
@@ -0,0 +1,379 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Security Middleware - Comprehensive security controls for web applications
|
|
3
|
+
* Provides CSRF protection, CSP headers, input validation, and secure cookie handling
|
|
4
|
+
*/ import { randomBytes } from 'crypto';
|
|
5
|
+
export class SecurityMiddleware {
|
|
6
|
+
config;
|
|
7
|
+
logger;
|
|
8
|
+
csrfTokens = {};
|
|
9
|
+
rateLimitMap = new Map();
|
|
10
|
+
cleanupInterval;
|
|
11
|
+
constructor(config, logger){
|
|
12
|
+
this.config = config;
|
|
13
|
+
this.logger = logger;
|
|
14
|
+
// Start cleanup interval for expired tokens and rate limits
|
|
15
|
+
this.cleanupInterval = setInterval(()=>{
|
|
16
|
+
this.cleanupExpiredTokens();
|
|
17
|
+
this.cleanupExpiredRateLimits();
|
|
18
|
+
}, 60000); // Run every minute
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Generate CSRF token for session
|
|
22
|
+
*/ generateCSRFToken(sessionId) {
|
|
23
|
+
const token = randomBytes(32).toString('hex');
|
|
24
|
+
const expires = Date.now() + this.config.csrfTokenExpiry * 1000;
|
|
25
|
+
this.csrfTokens[sessionId] = {
|
|
26
|
+
token,
|
|
27
|
+
expires
|
|
28
|
+
};
|
|
29
|
+
this.logger.debug('CSRF token generated', {
|
|
30
|
+
sessionId
|
|
31
|
+
});
|
|
32
|
+
return token;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Validate CSRF token
|
|
36
|
+
*/ validateCSRFToken(sessionId, providedToken) {
|
|
37
|
+
const storedToken = this.csrfTokens[sessionId];
|
|
38
|
+
if (!storedToken) {
|
|
39
|
+
this.logger.warn('No CSRF token found for session', {
|
|
40
|
+
sessionId
|
|
41
|
+
});
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
if (Date.now() > storedToken.expires) {
|
|
45
|
+
delete this.csrfTokens[sessionId];
|
|
46
|
+
this.logger.warn('CSRF token expired', {
|
|
47
|
+
sessionId
|
|
48
|
+
});
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
const isValid = storedToken.token === providedToken;
|
|
52
|
+
if (!isValid) {
|
|
53
|
+
this.logger.warn('Invalid CSRF token', {
|
|
54
|
+
sessionId
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
return isValid;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Content Security Policy middleware
|
|
61
|
+
*/ contentSecurityPolicy = (req, res, next)=>{
|
|
62
|
+
if (!this.config.cspEnabled) {
|
|
63
|
+
return next();
|
|
64
|
+
}
|
|
65
|
+
const cspHeader = [
|
|
66
|
+
"default-src 'self'",
|
|
67
|
+
"script-src 'self' 'unsafe-inline' 'unsafe-eval' https://cdn.jsdelivr.net",
|
|
68
|
+
"style-src 'self' 'unsafe-inline' https://fonts.googleapis.com",
|
|
69
|
+
"font-src 'self' https://fonts.gstatic.com",
|
|
70
|
+
"img-src 'self' data: https: blob:",
|
|
71
|
+
"connect-src 'self' ws: wss: https:",
|
|
72
|
+
"frame-src 'none'",
|
|
73
|
+
"object-src 'none'",
|
|
74
|
+
"base-uri 'self'",
|
|
75
|
+
"form-action 'self'",
|
|
76
|
+
"frame-ancestors 'none'",
|
|
77
|
+
"upgrade-insecure-requests",
|
|
78
|
+
"block-all-mixed-content"
|
|
79
|
+
].join('; ');
|
|
80
|
+
res.setHeader('Content-Security-Policy', cspHeader);
|
|
81
|
+
res.setHeader('X-Content-Type-Options', 'nosniff');
|
|
82
|
+
res.setHeader('X-Frame-Options', 'DENY');
|
|
83
|
+
res.setHeader('X-XSS-Protection', '1; mode=block');
|
|
84
|
+
res.setHeader('Referrer-Policy', 'strict-origin-when-cross-origin');
|
|
85
|
+
res.setHeader('Permissions-Policy', 'geolocation=(), microphone=(), camera=(), payment=(), usb=(), magnetometer=(), gyroscope=()');
|
|
86
|
+
next();
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* CSRF protection middleware
|
|
90
|
+
*/ csrfProtection = (req, res, next)=>{
|
|
91
|
+
if (!this.config.csrfEnabled) {
|
|
92
|
+
return next();
|
|
93
|
+
}
|
|
94
|
+
// Skip CSRF for GET, HEAD, OPTIONS requests
|
|
95
|
+
if ([
|
|
96
|
+
'GET',
|
|
97
|
+
'HEAD',
|
|
98
|
+
'OPTIONS'
|
|
99
|
+
].includes(req.method)) {
|
|
100
|
+
return next();
|
|
101
|
+
}
|
|
102
|
+
const sessionId = this.getSessionId(req);
|
|
103
|
+
if (!sessionId) {
|
|
104
|
+
this.logger.warn('No session ID found for CSRF validation', {
|
|
105
|
+
method: req.method,
|
|
106
|
+
url: req.url
|
|
107
|
+
});
|
|
108
|
+
return res.status(401).json({
|
|
109
|
+
error: 'Session required'
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
const token = req.get('X-CSRF-Token') || req.body?.csrfToken;
|
|
113
|
+
if (!token) {
|
|
114
|
+
this.logger.warn('No CSRF token provided', {
|
|
115
|
+
sessionId,
|
|
116
|
+
method: req.method,
|
|
117
|
+
url: req.url
|
|
118
|
+
});
|
|
119
|
+
return res.status(403).json({
|
|
120
|
+
error: 'CSRF token required'
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
if (!this.validateCSRFToken(sessionId, token)) {
|
|
124
|
+
this.logger.warn('Invalid CSRF token provided', {
|
|
125
|
+
sessionId,
|
|
126
|
+
method: req.method,
|
|
127
|
+
url: req.url
|
|
128
|
+
});
|
|
129
|
+
return res.status(403).json({
|
|
130
|
+
error: 'Invalid CSRF token'
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
// Generate new token after successful validation
|
|
134
|
+
const newToken = this.generateCSRFToken(sessionId);
|
|
135
|
+
res.set('X-CSRF-Token', newToken);
|
|
136
|
+
next();
|
|
137
|
+
};
|
|
138
|
+
/**
|
|
139
|
+
* Rate limiting middleware
|
|
140
|
+
*/ rateLimiting = (req, res, next)=>{
|
|
141
|
+
if (!this.config.rateLimitingEnabled) {
|
|
142
|
+
return next();
|
|
143
|
+
}
|
|
144
|
+
const key = this.getRateLimitKey(req);
|
|
145
|
+
const now = Date.now();
|
|
146
|
+
const entry = this.rateLimitMap.get(key);
|
|
147
|
+
if (!entry) {
|
|
148
|
+
this.rateLimitMap.set(key, {
|
|
149
|
+
count: 1,
|
|
150
|
+
lastReset: now
|
|
151
|
+
});
|
|
152
|
+
return next();
|
|
153
|
+
}
|
|
154
|
+
// Reset counter if window has expired
|
|
155
|
+
if (now - entry.lastReset > this.config.rateLimitWindow * 1000) {
|
|
156
|
+
this.rateLimitMap.set(key, {
|
|
157
|
+
count: 1,
|
|
158
|
+
lastReset: now
|
|
159
|
+
});
|
|
160
|
+
return next();
|
|
161
|
+
}
|
|
162
|
+
// Check if rate limit exceeded
|
|
163
|
+
if (entry.count >= this.config.rateLimitMax) {
|
|
164
|
+
this.logger.warn('Rate limit exceeded', {
|
|
165
|
+
key,
|
|
166
|
+
count: entry.count,
|
|
167
|
+
limit: this.config.rateLimitMax,
|
|
168
|
+
window: this.config.rateLimitWindow
|
|
169
|
+
});
|
|
170
|
+
res.set({
|
|
171
|
+
'X-RateLimit-Limit': this.config.rateLimitMax.toString(),
|
|
172
|
+
'X-RateLimit-Remaining': '0',
|
|
173
|
+
'X-RateLimit-Reset': new Date(entry.lastReset + this.config.rateLimitWindow * 1000).toISOString()
|
|
174
|
+
});
|
|
175
|
+
return res.status(429).json({
|
|
176
|
+
error: 'Too many requests',
|
|
177
|
+
retryAfter: this.config.rateLimitWindow
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
// Increment counter
|
|
181
|
+
entry.count++;
|
|
182
|
+
res.set({
|
|
183
|
+
'X-RateLimit-Limit': this.config.rateLimitMax.toString(),
|
|
184
|
+
'X-RateLimit-Remaining': (this.config.rateLimitMax - entry.count).toString(),
|
|
185
|
+
'X-RateLimit-Reset': new Date(entry.lastReset + this.config.rateLimitWindow * 1000).toISOString()
|
|
186
|
+
});
|
|
187
|
+
next();
|
|
188
|
+
};
|
|
189
|
+
/**
|
|
190
|
+
* Secure cookies middleware
|
|
191
|
+
*/ secureCookies = (req, res, next)=>{
|
|
192
|
+
// This should be used when setting cookies
|
|
193
|
+
const originalCookie = res.cookie;
|
|
194
|
+
res.cookie = (name, value, options)=>{
|
|
195
|
+
const secureOptions = {
|
|
196
|
+
httpOnly: true,
|
|
197
|
+
secure: this.config.secureCookies,
|
|
198
|
+
sameSite: this.config.sameSiteCookies,
|
|
199
|
+
...options
|
|
200
|
+
};
|
|
201
|
+
return originalCookie.call(res, name, value, secureOptions);
|
|
202
|
+
};
|
|
203
|
+
next();
|
|
204
|
+
};
|
|
205
|
+
/**
|
|
206
|
+
* Origin validation middleware
|
|
207
|
+
*/ originValidation = (req, res, next)=>{
|
|
208
|
+
const origin = req.get('Origin') || req.get('Referer');
|
|
209
|
+
// Skip for same-origin requests
|
|
210
|
+
if (!origin || this.isSameOrigin(req, origin)) {
|
|
211
|
+
return next();
|
|
212
|
+
}
|
|
213
|
+
if (!this.config.allowedOrigins.includes(origin)) {
|
|
214
|
+
this.logger.warn('Invalid origin', {
|
|
215
|
+
origin,
|
|
216
|
+
method: req.method,
|
|
217
|
+
url: req.url,
|
|
218
|
+
ip: req.ip
|
|
219
|
+
});
|
|
220
|
+
return res.status(403).json({
|
|
221
|
+
error: 'Origin not allowed'
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
res.set('Access-Control-Allow-Origin', origin);
|
|
225
|
+
res.set('Access-Control-Allow-Credentials', 'true');
|
|
226
|
+
res.set('Vary', 'Origin');
|
|
227
|
+
next();
|
|
228
|
+
};
|
|
229
|
+
/**
|
|
230
|
+
* Input validation middleware
|
|
231
|
+
*/ inputValidation = (req, res, next)=>{
|
|
232
|
+
// Validate JSON payloads
|
|
233
|
+
if (req.is('json') && req.body) {
|
|
234
|
+
const jsonStr = JSON.stringify(req.body);
|
|
235
|
+
// Check payload size (limit to 1MB)
|
|
236
|
+
if (jsonStr.length > 1024 * 1024) {
|
|
237
|
+
this.logger.warn('Request payload too large', {
|
|
238
|
+
size: jsonStr.length,
|
|
239
|
+
limit: 1024 * 1024
|
|
240
|
+
});
|
|
241
|
+
return res.status(413).json({
|
|
242
|
+
error: 'Request payload too large'
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
// Check for potential XSS in string values
|
|
246
|
+
const xssPatterns = [
|
|
247
|
+
/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,
|
|
248
|
+
/javascript:/gi,
|
|
249
|
+
/on\w+\s*=/gi
|
|
250
|
+
];
|
|
251
|
+
const sanitizeValue = (value)=>{
|
|
252
|
+
if (typeof value === 'string') {
|
|
253
|
+
for (const pattern of xssPatterns){
|
|
254
|
+
if (pattern.test(value)) {
|
|
255
|
+
this.logger.warn('Potential XSS detected in input', {
|
|
256
|
+
value: value.substring(0, 100)
|
|
257
|
+
});
|
|
258
|
+
throw new Error('Invalid input detected');
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
return value;
|
|
262
|
+
} else if (Array.isArray(value)) {
|
|
263
|
+
return value.map(sanitizeValue);
|
|
264
|
+
} else if (typeof value === 'object' && value !== null) {
|
|
265
|
+
const sanitized = {};
|
|
266
|
+
for (const [key, val] of Object.entries(value)){
|
|
267
|
+
sanitized[key] = sanitizeValue(val);
|
|
268
|
+
}
|
|
269
|
+
return sanitized;
|
|
270
|
+
}
|
|
271
|
+
return value;
|
|
272
|
+
};
|
|
273
|
+
try {
|
|
274
|
+
req.body = sanitizeValue(req.body);
|
|
275
|
+
} catch (error) {
|
|
276
|
+
return res.status(400).json({
|
|
277
|
+
error: 'Invalid input detected'
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
next();
|
|
282
|
+
};
|
|
283
|
+
/**
|
|
284
|
+
* Cleanup expired CSRF tokens
|
|
285
|
+
*/ cleanupExpiredTokens() {
|
|
286
|
+
const now = Date.now();
|
|
287
|
+
let cleaned = 0;
|
|
288
|
+
for (const [sessionId, token] of Object.entries(this.csrfTokens)){
|
|
289
|
+
if (now > token.expires) {
|
|
290
|
+
delete this.csrfTokens[sessionId];
|
|
291
|
+
cleaned++;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
if (cleaned > 0) {
|
|
295
|
+
this.logger.debug('Cleaned up expired CSRF tokens', {
|
|
296
|
+
count: cleaned
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Cleanup expired rate limits
|
|
302
|
+
*/ cleanupExpiredRateLimits() {
|
|
303
|
+
const now = Date.now();
|
|
304
|
+
const windowMs = this.config.rateLimitWindow * 1000;
|
|
305
|
+
let cleaned = 0;
|
|
306
|
+
for (const [key, entry] of this.rateLimitMap.entries()){
|
|
307
|
+
if (now - entry.lastReset > windowMs * 2) {
|
|
308
|
+
this.rateLimitMap.delete(key);
|
|
309
|
+
cleaned++;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
if (cleaned > 0) {
|
|
313
|
+
this.logger.debug('Cleaned up expired rate limits', {
|
|
314
|
+
count: cleaned
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* Get session ID from request
|
|
320
|
+
*/ getSessionId(req) {
|
|
321
|
+
// Try to get session ID from various sources
|
|
322
|
+
return req.session?.id || req.sessionID || req.get('Authorization')?.replace('Bearer ', '') || null;
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* Get rate limiting key for request
|
|
326
|
+
*/ getRateLimitKey(req) {
|
|
327
|
+
const ip = req.ip || req.connection.remoteAddress || 'unknown';
|
|
328
|
+
const sessionId = this.getSessionId(req);
|
|
329
|
+
return sessionId ? `session:${sessionId}` : `ip:${ip}`;
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* Check if request is same-origin
|
|
333
|
+
*/ isSameOrigin(req, origin) {
|
|
334
|
+
const host = req.get('Host');
|
|
335
|
+
if (!host) return false;
|
|
336
|
+
const protocol = req.protocol;
|
|
337
|
+
const expectedOrigin = `${protocol}://${host}`;
|
|
338
|
+
return origin === expectedOrigin || origin.startsWith(expectedOrigin);
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Cleanup resources
|
|
342
|
+
*/ destroy() {
|
|
343
|
+
if (this.cleanupInterval) {
|
|
344
|
+
clearInterval(this.cleanupInterval);
|
|
345
|
+
}
|
|
346
|
+
this.csrfTokens = {};
|
|
347
|
+
this.rateLimitMap.clear();
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* Get security statistics
|
|
351
|
+
*/ getStats() {
|
|
352
|
+
return {
|
|
353
|
+
activeCSRFtokens: Object.keys(this.csrfTokens).length,
|
|
354
|
+
activeRateLimits: this.rateLimitMap.size,
|
|
355
|
+
config: {
|
|
356
|
+
...this.config
|
|
357
|
+
}
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
// Default security configuration
|
|
362
|
+
export const defaultSecurityConfig = {
|
|
363
|
+
csrfEnabled: true,
|
|
364
|
+
cspEnabled: true,
|
|
365
|
+
rateLimitingEnabled: true,
|
|
366
|
+
allowedOrigins: [
|
|
367
|
+
'http://localhost:3000',
|
|
368
|
+
'http://localhost:3001',
|
|
369
|
+
'https://localhost:3000',
|
|
370
|
+
'https://localhost:3001'
|
|
371
|
+
],
|
|
372
|
+
csrfTokenExpiry: 3600,
|
|
373
|
+
rateLimitWindow: 900,
|
|
374
|
+
rateLimitMax: 100,
|
|
375
|
+
secureCookies: process.env.NODE_ENV === 'production',
|
|
376
|
+
sameSiteCookies: 'strict'
|
|
377
|
+
};
|
|
378
|
+
|
|
379
|
+
//# sourceMappingURL=security-middleware.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/web/security/security-middleware.ts"],"names":["randomBytes","SecurityMiddleware","csrfTokens","rateLimitMap","Map","cleanupInterval","config","logger","setInterval","cleanupExpiredTokens","cleanupExpiredRateLimits","generateCSRFToken","sessionId","token","toString","expires","Date","now","csrfTokenExpiry","debug","validateCSRFToken","providedToken","storedToken","warn","isValid","contentSecurityPolicy","req","res","next","cspEnabled","cspHeader","join","setHeader","csrfProtection","csrfEnabled","includes","method","getSessionId","url","status","json","error","get","body","csrfToken","newToken","set","rateLimiting","rateLimitingEnabled","key","getRateLimitKey","entry","count","lastReset","rateLimitWindow","rateLimitMax","limit","window","toISOString","retryAfter","secureCookies","originalCookie","cookie","name","value","options","secureOptions","httpOnly","secure","sameSite","sameSiteCookies","call","originValidation","origin","isSameOrigin","allowedOrigins","ip","inputValidation","is","jsonStr","JSON","stringify","length","size","xssPatterns","sanitizeValue","pattern","test","substring","Error","Array","isArray","map","sanitized","val","Object","entries","cleaned","windowMs","delete","session","id","sessionID","replace","connection","remoteAddress","host","protocol","expectedOrigin","startsWith","destroy","clearInterval","clear","getStats","activeCSRFtokens","keys","activeRateLimits","defaultSecurityConfig","process","env","NODE_ENV"],"mappings":"AAAA;;;CAGC,GAGD,SAAqBA,WAAW,QAAQ,SAAS;AA2BjD,OAAO,MAAMC;;;IACHC,aAAyB,CAAC,EAAE;IAC5BC,eAAe,IAAIC,MAA8B;IACjDC,gBAAgC;IAExC,YACE,AAAQC,MAAsB,EAC9B,AAAQC,MAAe,CACvB;aAFQD,SAAAA;aACAC,SAAAA;QAER,4DAA4D;QAC5D,IAAI,CAACF,eAAe,GAAGG,YAAY;YACjC,IAAI,CAACC,oBAAoB;YACzB,IAAI,CAACC,wBAAwB;QAC/B,GAAG,QAAQ,mBAAmB;IAChC;IAEA;;GAEC,GACDC,kBAAkBC,SAAiB,EAAU;QAC3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