feat(core): update session, security system and QR exchange

- Removed session creation and Lightning payment logic
- Refactored security system:
  * no more restrictions
  * all systems enabled on session creation
- Improved QR code exchange for mobile devices
This commit is contained in:
lockbitchat
2025-09-23 20:01:02 -04:00
parent 804b384271
commit 34094956b7
396 changed files with 126516 additions and 11881 deletions

View File

@@ -1,21 +1,16 @@
import { EnhancedSecureCryptoUtils } from '../crypto/EnhancedSecureCryptoUtils.js';
import { EnhancedSecureWebRTCManager } from '../network/EnhancedSecureWebRTCManager.js';
import { PayPerSessionManager } from '../session/PayPerSessionManager.js';
import { EnhancedSecureFileTransfer } from '../transfer/EnhancedSecureFileTransfer.js';
// Import UI components (side-effect: they attach themselves to window.*)
import '../components/ui/SessionTimer.jsx';
import '../components/ui/Header.jsx';
import '../components/ui/SessionTypeSelector.jsx';
import '../components/ui/LightningPayment.jsx';
import '../components/ui/PaymentModal.jsx';
import '../components/ui/DownloadApps.jsx';
import '../components/ui/FileTransfer.jsx';
// Expose to global for legacy usage inside app code
window.EnhancedSecureCryptoUtils = EnhancedSecureCryptoUtils;
window.EnhancedSecureWebRTCManager = EnhancedSecureWebRTCManager;
window.PayPerSessionManager = PayPerSessionManager;
window.EnhancedSecureFileTransfer = EnhancedSecureFileTransfer;
// Mount application once DOM and modules are ready

View File

@@ -1,13 +1,48 @@
// Local QR generator adapter (no external CDNs)
// Exposes: window.generateQRCode(text, { size?: number, margin?: number, errorCorrectionLevel?: 'L'|'M'|'Q'|'H' })
// Local QR generator and scanner with COSE compression (no external CDNs)
// Exposes:
// - window.generateQRCode(text, { size?: number, margin?: number, errorCorrectionLevel?: 'L'|'M'|'Q'|'H' })
// - window.generateCOSEQRCode(data, senderKey?, recipientKey?) - COSE-based compression
// - window.Html5Qrcode (for scanning QR codes)
// - window.packSecurePayload, window.receiveAndProcess (COSE functions)
import * as QRCode from 'qrcode';
import { Html5Qrcode } from 'html5-qrcode';
import { packSecurePayload, receiveAndProcess } from '../crypto/cose-qr.js';
async function generateQRCode(text, opts = {}) {
const size = opts.size || 300;
const size = opts.size || 512;
const margin = opts.margin ?? 2;
const errorCorrectionLevel = opts.errorCorrectionLevel || 'M';
return await QRCode.toDataURL(text, { width: size, margin, errorCorrectionLevel });
}
// COSE-based QR generation for large data
async function generateCOSEQRCode(data, senderKey = null, recipientKey = null) {
try {
console.log('🔐 Generating COSE-based QR code...');
// Pack data using COSE
const chunks = await packSecurePayload(data, senderKey, recipientKey);
if (chunks.length === 1) {
// Single QR code
return await generateQRCode(chunks[0]);
} else {
// Enforce single-QR policy: let caller fallback to template/reference
console.warn(`📊 COSE packing produced ${chunks.length} chunks; falling back to non-COSE strategy`);
throw new Error('COSE QR would require multiple chunks');
}
} catch (error) {
console.error('Error generating COSE QR code:', error);
throw error;
}
}
// Expose functions to global scope
window.generateQRCode = generateQRCode;
window.generateCOSEQRCode = generateCOSEQRCode;
window.Html5Qrcode = Html5Qrcode;
window.packSecurePayload = packSecurePayload;
window.receiveAndProcess = receiveAndProcess;
console.log('QR libraries loaded: generateQRCode, generateCOSEQRCode, Html5Qrcode, COSE functions');