Try to get it to work :/

This commit is contained in:
Sander Declerck 2025-11-28 15:44:45 +01:00
parent 95d436100d
commit ae9bc8a75d
No known key found for this signature in database

View file

@ -35,14 +35,25 @@ async function bundleSafeChain() {
external: ["certifi"], external: ["certifi"],
}); });
// Post-process: Replace all usePureJavaScript: false with true // Post-process: Force node-forge to use pure JavaScript
// This ensures node-forge uses pure JavaScript crypto instead of native bindings // This prevents segmentation faults in pkg binaries on Linux
// which prevents segmentation faults in pkg binaries on Linux
let bundledContent = await readFile("./build/bin/safe-chain.cjs", "utf-8"); let bundledContent = await readFile("./build/bin/safe-chain.cjs", "utf-8");
// 1. Set the option to true
bundledContent = bundledContent.replace( bundledContent = bundledContent.replace(
/usePureJavaScript:\s*false/g, /usePureJavaScript:\s*false/g,
"usePureJavaScript: true" "usePureJavaScript: true"
); );
// 2. Replace all checks that would enable native crypto
// Change: if (!forge2.options.usePureJavaScript && ...)
// To: if (false && ...)
// This makes the native crypto branches unreachable
bundledContent = bundledContent.replace(
/!forge2\.options\.usePureJavaScript/g,
"false"
);
await writeFile("./build/bin/safe-chain.cjs", bundledContent); await writeFile("./build/bin/safe-chain.cjs", bundledContent);
} }