Add ECDSA signature verification and enhance ComboHandler functionality

- Integrated ECDSA for signature verification in ComboHandler.
- Updated event emissions to include additional parameters for better tracking.
- Improved gas tracking during execution of combo plans.
- Enhanced database interactions for storing and retrieving plans, including conflict resolution and status updates.
- Added new dependencies for security and database management in orchestrator.
This commit is contained in:
defiQUG
2025-11-05 16:28:48 -08:00
parent 3b09c35c47
commit f600b7b15e
48 changed files with 3381 additions and 46 deletions

View File

@@ -0,0 +1,74 @@
import pino from "pino";
import { env } from "../config/env";
/**
* Configure Pino logger with structured logging
*/
export const logger = pino({
level: env.LOG_LEVEL,
transport: {
target: "pino-pretty",
options: {
colorize: true,
translateTime: "SYS:standard",
ignore: "pid,hostname",
},
},
formatters: {
level: (label) => {
return { level: label };
},
},
serializers: {
req: (req) => ({
id: req.id,
method: req.method,
url: req.url,
headers: {
host: req.headers.host,
"user-agent": req.headers["user-agent"],
"x-request-id": req.headers["x-request-id"],
},
}),
res: (res) => ({
statusCode: res.statusCode,
}),
err: pino.stdSerializers.err,
},
});
/**
* Mask PII in log data
*/
export function maskPII(data: any): any {
if (typeof data === "string") {
// Mask email addresses
return data.replace(/\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b/g, "[EMAIL]");
}
if (Array.isArray(data)) {
return data.map(maskPII);
}
if (data && typeof data === "object") {
const masked: any = {};
for (const key in data) {
const lowerKey = key.toLowerCase();
if (lowerKey.includes("email") || lowerKey.includes("password") || lowerKey.includes("secret") || lowerKey.includes("token")) {
masked[key] = "[REDACTED]";
} else if (lowerKey.includes("iban") || lowerKey.includes("account")) {
masked[key] = data[key] ? `${String(data[key]).substring(0, 4)}****` : data[key];
} else {
masked[key] = maskPII(data[key]);
}
}
return masked;
}
return data;
}
/**
* Create child logger with context
*/
export function createChildLogger(context: Record<string, any>) {
return logger.child(maskPII(context));
}