mirror of
https://github.com/AikidoSec/safe-chain.git
synced 2026-05-26 12:10:49 +00:00
Fix e2e tests
This commit is contained in:
parent
c71320386e
commit
a7fc215354
4 changed files with 47 additions and 124 deletions
|
|
@ -2,8 +2,6 @@ import { generateCACertificate } from "../registryProxy/certUtils.js";
|
|||
import { writeFileSync, mkdirSync } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
import { homedir } from "node:os";
|
||||
import { ui } from "../environment/userInteraction.js";
|
||||
import chalk from "chalk";
|
||||
|
||||
/**
|
||||
* Generate certificate command
|
||||
|
|
@ -34,7 +32,7 @@ export async function generateCertCommand(args) {
|
|||
|
||||
writeFileSync(certPath, cert);
|
||||
writeFileSync(keyPath, key);
|
||||
} catch (/** @type {any} */ error) {
|
||||
} catch {
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,11 +3,34 @@ import path from "path";
|
|||
import fs from "fs";
|
||||
import os from "os";
|
||||
|
||||
const certFolder = process.env.SAFE_CHAIN_CERT_DIR || path.join(os.homedir(), ".safe-chain", "certs");
|
||||
const certFolder = determineCertFolder();
|
||||
const ca = loadCa();
|
||||
|
||||
const certCache = new Map();
|
||||
|
||||
/**
|
||||
* Determine the certificate folder location
|
||||
* Priority:
|
||||
* 1. SAFE_CHAIN_CERT_DIR environment variable (set by installer/LaunchAgent)
|
||||
* 2. System-wide installation directory (if certificates exist there)
|
||||
* 3. User home directory (fallback for CLI wrapper mode and development)
|
||||
*/
|
||||
function determineCertFolder() {
|
||||
// 1. Explicit env var takes precedence (set by LaunchAgent)
|
||||
if (process.env.SAFE_CHAIN_CERT_DIR) {
|
||||
return process.env.SAFE_CHAIN_CERT_DIR;
|
||||
}
|
||||
|
||||
// 2. Check if system-wide installation exists (macOS/Linux standard location)
|
||||
const systemCertDir = "/usr/local/share/safe-chain/certs";
|
||||
if (fs.existsSync(path.join(systemCertDir, "ca-cert.pem"))) {
|
||||
return systemCertDir;
|
||||
}
|
||||
|
||||
// 3. Fallback to user home directory (CLI wrapper mode, development)
|
||||
return path.join(os.homedir(), ".safe-chain", "certs");
|
||||
}
|
||||
|
||||
export function getCaCertPath() {
|
||||
return path.join(certFolder, "ca-cert.pem");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue