فینورا پرو - سامانه جامع حسابداری و صدور فاکتور
feat(A03): include audit chain head anchor in company backup
davoodmehraban89 committed
Oct 20, 2026 at 08:38 UTC
51f2949eba9af7268ef9d24ad8190757cb85ec5c
1 file changed
+5
src/controllers/SettingsController.js
+5
@@ -7,6 +7,7 @@ import { StorageService, STORES } from '../core/StorageService.js';
7
import { Auth } from '../core/Auth.js';
8
import { DataScope } from '../core/DataScope.js';
9
import { restoreCompanyBackup, COMPANY_BACKUP_STORES } from '../core/CompanyBackupService.js';
10
+import { verifyChain } from '../core/AuditChain.js';
11
12
class SettingsControllerImpl {
13
async getInvoiceSettings() {
@@ -77,6 +78,10 @@ class SettingsControllerImpl {
78
}
79
}
80
81
+ const events = [...backup.data.audit_events].sort((a,b) => (a.chainIndex ?? 0) - (b.chainIndex ?? 0));
82
+ const result = verifyChain(events);
83
+ if (!result.valid) throw new Error('زنجیره ممیزی هنگام تهیه پشتیبان نامعتبر است');
84
+ backup.auditAnchor = { count: result.count, headHash: result.headHash };
85
return backup;
86
}
87