feat: add verified offline recovery and retire legacy send assembly
This commit is contained in:
1 parent
84e2f0d9ba
commit
1148aa6f14
19 files changed
+235
-24
No files matched your search
@@ -0,0 +1,12 @@
|
||||
'use strict';
|
||||
const fs=require('node:fs'),path=require('node:path'),{DatabaseSync}=require('node:sqlite'),{BpmVault}=require('../../platform/security/vault.cjs');
|
||||
// Legacy evidence is readable, but never recovered, scheduled, or mutated by the application.
|
||||
class NotificationHistory{
|
||||
constructor(dir){this.dir=dir;const file=path.join(dir,'notifications.sqlite');if(fs.existsSync(file))this.db=new DatabaseSync(file,{readOnly:true});}
|
||||
settings(){if(!this.db)return {enabled:false,historyOnly:true};const row=this.db.prepare('SELECT value FROM settings WHERE id=1').get();const {sourceKey,...settings}=row?JSON.parse(row.value):{};return {...settings,enabled:false,historyOnly:true};}
|
||||
decode(row){const {payload,...metadata}=row;this.vault||=new BpmVault({stateDir:path.join(this.dir,'secrets')});return {...this.vault.decode(row.id,payload),...metadata};}
|
||||
items(){return this.db?this.db.prepare('SELECT * FROM items ORDER BY rowid DESC LIMIT 100').all().map(row=>this.decode(row)):[];}
|
||||
batches(){return this.db?this.db.prepare("SELECT * FROM batches ORDER BY CASE status WHEN 'unknown' THEN 0 ELSE 1 END,rowid DESC LIMIT 100").all().map(row=>this.decode(row)):[];}
|
||||
close(){this.db?.close();this.db=null;this.vault?.destroy();this.vault=null;}
|
||||
}
|
||||
module.exports={NotificationHistory};
|
||||
Reference in new issue
Block a user