All checks were successful
Dev Deployment (Zero Downtime) / deploy-dev (push) Successful in 13m33s
Build Optimizations: - Enable Docker BuildKit cache for faster builds (7min → 3-4min) - Add .dockerignore to reduce build context - Optimize Dockerfile with better layer caching - Run linting and tests in parallel - Skip blocking checks for dev deployments Rollback Functionality: - Add rollback.sh script to restore previous versions - Supports both production and dev environments - Automatic health checks after rollback Security Improvements: - Add authentication to n8n/generate-image endpoint - Add rate limiting to all n8n endpoints (10-30 req/min) - Create email obfuscation utilities - Add ObfuscatedEmail React component - Document security best practices Files: - .dockerignore - Faster builds - scripts/rollback.sh - Rollback functionality - lib/email-obfuscate.ts - Email obfuscation utilities - components/ObfuscatedEmail.tsx - React component - SECURITY_IMPROVEMENTS.md - Security documentation
70 lines
2.2 KiB
TypeScript
70 lines
2.2 KiB
TypeScript
/**
|
|
* Email and URL obfuscation utilities
|
|
* Prevents automated scraping while keeping functionality
|
|
*/
|
|
|
|
/**
|
|
* Obfuscates an email address by encoding it
|
|
* @param email - The email address to obfuscate
|
|
* @returns Obfuscated email string that can be decoded by JavaScript
|
|
*/
|
|
export function obfuscateEmail(email: string): string {
|
|
// Simple base64 encoding (can be decoded by bots, but adds a layer)
|
|
// For better protection, use a custom encoding scheme
|
|
return Buffer.from(email).toString('base64');
|
|
}
|
|
|
|
/**
|
|
* Deobfuscates an email address
|
|
* @param obfuscated - The obfuscated email string
|
|
* @returns Original email address
|
|
*/
|
|
export function deobfuscateEmail(obfuscated: string): string {
|
|
try {
|
|
return Buffer.from(obfuscated, 'base64').toString('utf-8');
|
|
} catch {
|
|
return obfuscated; // Return as-is if decoding fails
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Creates an obfuscated mailto link component
|
|
* @param email - The email address
|
|
* @param displayText - Text to display (optional, defaults to email)
|
|
* @returns HTML string with obfuscated email
|
|
*/
|
|
export function createObfuscatedMailto(email: string, displayText?: string): string {
|
|
const obfuscated = obfuscateEmail(email);
|
|
const text = displayText || email;
|
|
|
|
// Use data attributes and JavaScript to decode
|
|
return `<a href="#" data-email="${obfuscated}" class="obfuscated-email" onclick="this.href='mailto:'+atob(this.dataset.email); return true;">${text}</a>`;
|
|
}
|
|
|
|
/**
|
|
* Obfuscates a URL by encoding parts of it
|
|
* @param url - The URL to obfuscate
|
|
* @returns Obfuscated URL string
|
|
*/
|
|
export function obfuscateUrl(url: string): string {
|
|
// Encode the URL
|
|
return Buffer.from(url).toString('base64');
|
|
}
|
|
|
|
/**
|
|
* Creates an obfuscated link
|
|
* @param url - The URL
|
|
* @param displayText - Text to display
|
|
* @returns HTML string with obfuscated URL
|
|
*/
|
|
export function createObfuscatedLink(url: string, displayText: string): string {
|
|
const obfuscated = obfuscateUrl(url);
|
|
return `<a href="#" data-url="${obfuscated}" class="obfuscated-link" onclick="this.href=atob(this.dataset.url); return true;">${displayText}</a>`;
|
|
}
|
|
|
|
/**
|
|
* React component helper for obfuscated emails
|
|
* Note: This is a TypeScript utility file. For React components, create a separate .tsx file
|
|
* or use the HTML string functions instead.
|
|
*/
|