4 lines
2.0 KiB
JavaScript
4 lines
2.0 KiB
JavaScript
import fs from 'node:fs';import crypto from 'node:crypto';import assert from 'node:assert/strict';import {session} from './sgf-single-http.mjs';import {fiscalMapDownload} from '../resources/js/statement-download.js';
|
|
const root=JSON.parse(fs.readFileSync('C:/laragon/data/sgf-tempo/run/modular-regression-current.json')).root+'/private/receipt-composition-cc50a276c10c',sample=JSON.parse(fs.readFileSync(root+'/fiscal-obligations-sample-private.json')),s=await session('sgf:read_only','accounting'),checks=[],ok=(v,n)=>{assert(v,n);checks.push(n);},source=sample.source;
|
|
let r=await s.get('/api/fiscal-assessments/forms/'+source.form_id+'/export',{headers:{'X-SGF-Context':''}});ok(r.status===409,'map export still refuses missing context');let request;const result=await fiscalMapDownload({id:source.form_id,token:s.identity.context.token,sha256:source.export_sha256,isCurrent:()=>true,fetcher:(path,options)=>{request={path,options};return s.get(path,{headers:options.headers});}});ok(result.sha256===source.export_sha256,'existing map bytes match original frozen SHA');ok(request.path==='/api/fiscal-assessments/forms/'+source.form_id+'/export'&&!request.path.includes(s.identity.context.token),'map download uses exact source and token only in header');ok(new TextDecoder().decode(result.bytes).includes('SEM VALIDADE FISCAL'),'existing map synthetic limit retained');const old=JSON.parse(fs.readFileSync('docs/proofs/sgf-fiscal-obligations-20261110.json'));ok(crypto.createHash('sha256').update(fs.readFileSync(old.evidence.ui)).digest('hex')===old.evidence_sha256.ui,'accepted historical UI proof bytes preserved');fs.copyFileSync(root+'/fiscal-obligations-ui-20261110.json',root+'/fiscal-obligations-download-ui-20261111.json');const file=root+'/fiscal-map-download-proof-20261111.json';fs.writeFileSync(file,JSON.stringify({passed:true,checks,business_commands:0,read_download_audit_only:true,map_recreated:false},null,2));console.log(JSON.stringify({passed:true,checks:checks.length,proof:file}));
|