Add configuration files, database migrations, and authentication implementation scaffolding
This commit is contained in:
29
web/dashboard/src/workers/crypto.worker.ts
Normal file
29
web/dashboard/src/workers/crypto.worker.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
// crypto.worker.ts
|
||||
import { importKey, decryptLog } from '../lib/crypto';
|
||||
|
||||
let cryptoKey: CryptoKey | null = null;
|
||||
|
||||
self.onmessage = async (event) => {
|
||||
const { type, payload } = event.data;
|
||||
|
||||
switch (type) {
|
||||
case 'SET_KEY':
|
||||
// payload is the raw Uint8Array key
|
||||
cryptoKey = await importKey(payload);
|
||||
self.postMessage({ type: 'KEY_READY' });
|
||||
break;
|
||||
|
||||
case 'DECRYPT':
|
||||
if (!cryptoKey) {
|
||||
self.postMessage({ type: 'ERROR', message: 'No key set' });
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const decrypted = await decryptLog(payload, cryptoKey);
|
||||
self.postMessage({ type: 'DECRYPTED', payload: decrypted });
|
||||
} catch (err) {
|
||||
self.postMessage({ type: 'ERROR', message: 'Decryption failed' });
|
||||
}
|
||||
break;
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user