mirror of
https://github.com/AikidoSec/safe-chain.git
synced 2026-05-26 12:10:49 +00:00
Try set pure javascript for node-forge
This commit is contained in:
parent
8ab4d2955a
commit
20420f865e
3 changed files with 16 additions and 7 deletions
12
build.js
12
build.js
|
|
@ -26,6 +26,15 @@ async function clearOutputFolder() {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function bundleSafeChain() {
|
async function bundleSafeChain() {
|
||||||
|
// Read the forge.js file and modify it to use pure JavaScript
|
||||||
|
const forgeContent = await readFile("./node_modules/node-forge/lib/forge.js", "utf-8");
|
||||||
|
const modifiedForge = forgeContent.replace(
|
||||||
|
"usePureJavaScript: false",
|
||||||
|
"usePureJavaScript: true"
|
||||||
|
);
|
||||||
|
await mkdir("./build/temp", { recursive: true });
|
||||||
|
await writeFile("./build/temp/forge.js", modifiedForge);
|
||||||
|
|
||||||
await build({
|
await build({
|
||||||
entryPoints: ["./packages/safe-chain/bin/safe-chain.js"],
|
entryPoints: ["./packages/safe-chain/bin/safe-chain.js"],
|
||||||
bundle: true,
|
bundle: true,
|
||||||
|
|
@ -33,6 +42,9 @@ async function bundleSafeChain() {
|
||||||
target: "node24",
|
target: "node24",
|
||||||
outfile: "./build/bin/safe-chain.cjs",
|
outfile: "./build/bin/safe-chain.cjs",
|
||||||
external: ["certifi"],
|
external: ["certifi"],
|
||||||
|
alias: {
|
||||||
|
"node-forge/lib/forge": "./build/temp/forge.js",
|
||||||
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import path from "node:path";
|
||||||
import certifi from "certifi";
|
import certifi from "certifi";
|
||||||
import tls from "node:tls";
|
import tls from "node:tls";
|
||||||
import { X509Certificate } from "node:crypto";
|
import { X509Certificate } from "node:crypto";
|
||||||
// import { getCaCertPath } from "./certUtils.js";
|
import { getCaCertPath } from "./certUtils.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if a PEM string contains only parsable cert blocks.
|
* Check if a PEM string contains only parsable cert blocks.
|
||||||
|
|
@ -58,10 +58,10 @@ export function getCombinedCaBundlePath() {
|
||||||
const parts = [];
|
const parts = [];
|
||||||
|
|
||||||
// 1) Safe Chain CA (for MITM'd registries)
|
// 1) Safe Chain CA (for MITM'd registries)
|
||||||
// const safeChainPath = getCaCertPath();
|
const safeChainPath = getCaCertPath();
|
||||||
try {
|
try {
|
||||||
// const safeChainPem = fs.readFileSync(safeChainPath, "utf8");
|
const safeChainPem = fs.readFileSync(safeChainPath, "utf8");
|
||||||
// if (isParsable(safeChainPem)) parts.push(safeChainPem.trim());
|
if (isParsable(safeChainPem)) parts.push(safeChainPem.trim());
|
||||||
} catch {
|
} catch {
|
||||||
// Ignore if Safe Chain CA is not available
|
// Ignore if Safe Chain CA is not available
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,6 @@ import fs from "fs";
|
||||||
import os from "os";
|
import os from "os";
|
||||||
import { ui } from "../environment/userInteraction.js";
|
import { ui } from "../environment/userInteraction.js";
|
||||||
|
|
||||||
// @ts-ignore
|
|
||||||
forge.options.usePureJavaScript = true;
|
|
||||||
|
|
||||||
const certFolder = path.join(os.homedir(), ".safe-chain", "certs");
|
const certFolder = path.join(os.homedir(), ".safe-chain", "certs");
|
||||||
const ca = loadCa();
|
const ca = loadCa();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue