1b4b497fdf
Mirror to GitHub / mirror (push) Successful in 44s
Test and Lint / backend-test (push) Successful in 1m42s
Test and Lint / frontend-test (push) Has been cancelled
Version and Release / version-bump (push) Has been cancelled
Version and Release / trigger-drone (push) Has been cancelled
- Remove all console.log/debug statements from production code - Add NODE_ENV checks for development-only logging - Remove test scripts (test-feedback, test-image-security, test-backup-*, test-restore) - Remove one-time fix scripts (fix-temp-photos, fix-migration-state, mark-migration-applied) - Remove sensitive files (.env.backup, ADMIN_CREDENTIALS.txt) - Update package.json to remove references to deleted scripts - Replace console statements with logger utility in backend - Secure error boundaries to not expose stack traces in production This makes the codebase production-ready with no debug output or test scripts. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
113 lines
3.4 KiB
TypeScript
113 lines
3.4 KiB
TypeScript
import React from 'react';
|
|
import { Shield, AlertTriangle, X } from 'lucide-react';
|
|
|
|
interface ProtectionWarningProps {
|
|
type: 'devtools' | 'screenshot' | 'violation' | 'general';
|
|
message?: string;
|
|
onClose?: () => void;
|
|
severity?: 'low' | 'medium' | 'high';
|
|
autoClose?: boolean;
|
|
autoCloseDelay?: number;
|
|
}
|
|
|
|
export const ProtectionWarning: React.FC<ProtectionWarningProps> = ({
|
|
type,
|
|
message,
|
|
onClose,
|
|
severity = 'medium',
|
|
autoClose = false,
|
|
autoCloseDelay = 5000
|
|
}) => {
|
|
// Auto close functionality
|
|
React.useEffect(() => {
|
|
if (autoClose && autoCloseDelay > 0 && onClose) {
|
|
const timer = setTimeout(() => {
|
|
onClose();
|
|
}, autoCloseDelay);
|
|
|
|
return () => clearTimeout(timer);
|
|
}
|
|
}, [autoClose, autoCloseDelay, onClose]);
|
|
|
|
const getWarningConfig = () => {
|
|
switch (type) {
|
|
case 'devtools':
|
|
return {
|
|
icon: <AlertTriangle className="w-5 h-5" />,
|
|
title: 'Developer Tools Detected',
|
|
defaultMessage: 'Developer tools access has been detected. This action has been logged for security purposes.',
|
|
bgColor: 'bg-red-500',
|
|
textColor: 'text-white'
|
|
};
|
|
case 'screenshot':
|
|
return {
|
|
icon: <Shield className="w-5 h-5" />,
|
|
title: 'Screenshot Attempt Detected',
|
|
defaultMessage: 'A screenshot attempt has been detected. This gallery is protected from unauthorized copying.',
|
|
bgColor: 'bg-orange-500',
|
|
textColor: 'text-white'
|
|
};
|
|
case 'violation':
|
|
return {
|
|
icon: <Shield className="w-5 h-5" />,
|
|
title: 'Protection Violation',
|
|
defaultMessage: 'An unauthorized action has been detected and blocked.',
|
|
bgColor: severity === 'high' ? 'bg-red-500' : severity === 'medium' ? 'bg-orange-500' : 'bg-yellow-500',
|
|
textColor: 'text-white'
|
|
};
|
|
default:
|
|
return {
|
|
icon: <Shield className="w-5 h-5" />,
|
|
title: 'Security Notice',
|
|
defaultMessage: 'This content is protected. Unauthorized access attempts are monitored.',
|
|
bgColor: 'bg-blue-500',
|
|
textColor: 'text-white'
|
|
};
|
|
}
|
|
};
|
|
|
|
const config = getWarningConfig();
|
|
|
|
return (
|
|
<div className={`fixed top-4 right-4 ${config.bgColor} ${config.textColor} p-4 rounded-lg shadow-lg z-50 max-w-sm`}>
|
|
<div className="flex items-start gap-3">
|
|
<div className="flex-shrink-0 mt-0.5">
|
|
{config.icon}
|
|
</div>
|
|
<div className="flex-1 min-w-0">
|
|
<div className="text-sm font-medium">
|
|
{config.title}
|
|
</div>
|
|
<div className="text-xs mt-1 opacity-90">
|
|
{message || config.defaultMessage}
|
|
</div>
|
|
</div>
|
|
{onClose && (
|
|
<button
|
|
onClick={onClose}
|
|
className="flex-shrink-0 ml-2 -mr-1 -mt-1 p-1 rounded-full hover:bg-white/20 transition-colors"
|
|
aria-label="Close warning"
|
|
>
|
|
<X className="w-4 h-4" />
|
|
</button>
|
|
)}
|
|
</div>
|
|
{autoClose && (
|
|
<div
|
|
className="absolute bottom-0 left-0 h-0.5 bg-white/30 animate-pulse"
|
|
style={{
|
|
width: '100%',
|
|
animation: `shrink ${autoCloseDelay}ms linear`
|
|
}}
|
|
/>
|
|
)}
|
|
|
|
<style jsx>{`
|
|
@keyframes shrink {
|
|
from { width: 100%; }
|
|
to { width: 0%; }
|
|
}
|
|
`}</style>
|
|
</div>
|
|
);
|
|
}; |