Skip to content

Commit ab1658b

Browse files
author
Corey B
committed
feat(cli): node-fdd-pack now aggressively audits presentation layer template bindings against payload structures during compile
1 parent 9625f4a commit ab1658b

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

lib/node-fdd/src/pack.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,28 @@ async function main() {
2525
mutable = await fs.readFile(mutablePath, 'utf8');
2626
}
2727

28+
const warnings = [];
29+
const autosaveRegex = /name=["']([^"']+)["'][^>]*?autosave/g;
30+
const autosaveReverseRegex = /autosave[^>]*?name=["']([^"']+)["']/g;
31+
const actionRegex = /fdd-target=["']([^"']+)["']/g;
32+
33+
let match;
34+
while ((match = autosaveRegex.exec(template)) !== null) {
35+
if (match[1].startsWith('fdd-data')) warnings.push(`[WARN] Autosave input bound to cryptographic payload: "${match[1]}". This mutation will reject silently in production.`);
36+
}
37+
while ((match = autosaveReverseRegex.exec(template)) !== null) {
38+
if (match[1].startsWith('fdd-data')) warnings.push(`[WARN] Autosave input bound to cryptographic payload: "${match[1]}". This mutation will reject silently in production.`);
39+
}
40+
while ((match = actionRegex.exec(template)) !== null) {
41+
if (match[1].startsWith('fdd-data')) warnings.push(`[WARN] Declarative action target bound to cryptographic payload: "${match[1]}". The OpenFDD standard strictly restricts mutations to the 'user-notes' structure.`);
42+
}
43+
44+
if (warnings.length > 0) {
45+
console.log("\n⚠️ OPENFDD COMPILER WARNINGS ⚠️");
46+
warnings.forEach(w => console.log(w));
47+
console.log("----------------------------------\n");
48+
}
49+
2850
const fdd = `<fdd-container extension=".fdd">
2951
<script type="application/vc+json" id="fdd-data">
3052
${vc.split('\n').join('\n ')}

0 commit comments

Comments
 (0)