Implement security patches: CSP headers, console disabling, key rotation, clipboard security, network blocking, log cleanup, and PGP validation

This commit is contained in:
LC mac
2026-02-12 02:24:06 +08:00
parent 20cf558e83
commit 6c6379fcd4
11 changed files with 3365 additions and 135 deletions

View File

@@ -18,12 +18,14 @@ export const QrDisplay: React.FC<QrDisplayProps> = ({ value }) => {
const generateQR = async () => {
try {
console.log('🎨 QrDisplay generating QR for:', value);
console.log(' - Type:', value instanceof Uint8Array ? 'Uint8Array' : typeof value);
console.log(' - Length:', value.length);
if (import.meta.env.DEV) {
console.debug('QR generation started', {
type: value instanceof Uint8Array ? 'Uint8Array' : typeof value,
length: value instanceof Uint8Array || typeof value === 'string' ? value.length : 0
});
}
if (value instanceof Uint8Array) {
console.log(' - Hex:', Array.from(value).map(b => b.toString(16).padStart(2, '0')).join(''));
// Create canvas manually for precise control
const canvas = document.createElement('canvas');
@@ -45,7 +47,6 @@ export const QrDisplay: React.FC<QrDisplayProps> = ({ value }) => {
const url = canvas.toDataURL('image/png');
setDataUrl(url);
setDebugInfo(`Binary QR: ${value.length} bytes`);
console.log('✅ Binary QR generated successfully');
} else {
// For string data
console.log(' - String data:', value.slice(0, 50));
@@ -63,11 +64,12 @@ export const QrDisplay: React.FC<QrDisplayProps> = ({ value }) => {
setDataUrl(url);
setDebugInfo(`String QR: ${value.length} chars`);
console.log('✅ String QR generated successfully');
}
} catch (err) {
console.error('❌ QR generation error:', err);
setDebugInfo(`Error: ${err}`);
if (import.meta.env.DEV) {
console.error('QR generation error:', err);
}
setDebugInfo(`Error generating QR code`);
}
};