Some cleanup

This commit is contained in:
Reinier Criel 2025-11-19 13:54:12 -08:00
parent 97bbc77162
commit c71320386e
13 changed files with 1601 additions and 240 deletions

View file

@ -9,3 +9,26 @@ The installer bundles the Safe Chain Node.js application into a standalone binar
1. Install the `safe-chain` binary to the system PATH
2. Generate and install the CA certificate in the OS trust store
3. Configure the system for automatic MITM proxy interception
## Building the Installer
To build the installer for the current platform, run the following command from the root of the workspace:
```bash
npm run build:installer
```
To build for a specific platform, you can pass arguments to the script:
```bash
# macOS
npm run build:installer -- --platform=macos
# Linux
npm run build:installer -- --platform=linux
# Windows
npm run build:installer -- --platform=windows
```
The build artifacts (binaries and installer packages) will be created in the `installer/dist` directory.

View file

@ -1,46 +0,0 @@
#!/usr/bin/env node
/**
* Wrapper script for certificate generation during installer build
* This re-exports the certificate generation functionality from the main package
*/
import { generateCACertificate } from '../packages/safe-chain/src/registryProxy/certUtils.js';
import { writeFileSync, mkdirSync } from 'node:fs';
import { join } from 'node:path';
/**
* Generate certificate files (simple version for installer build)
* For the full CLI version with nice output, use: safe-chain _generate-cert
*
* @param {string} outputDir - Directory to save certificate files
* @returns {Promise<{certPath: string, keyPath: string}>}
*/
export async function generateCertificates(outputDir) {
console.log('Generating Safe Chain CA certificate...');
mkdirSync(outputDir, { recursive: true });
const { cert, key } = generateCACertificate();
const certPath = join(outputDir, 'ca-cert.pem');
const keyPath = join(outputDir, 'ca-key.pem');
writeFileSync(certPath, cert);
writeFileSync(keyPath, key);
console.log('✓ Certificate generated:');
console.log(` Certificate: ${certPath}`);
console.log(` Private Key: ${keyPath}`);
return { certPath, keyPath };
}
// CLI usage - when run directly
if (import.meta.url === `file://${process.argv[1]}`) {
const outputDir = process.argv[2] || './certs';
generateCertificates(outputDir).catch(error => {
console.error('Error generating certificates:', error);
process.exit(1);
});
}

1545
installer/package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

View file

@ -1,21 +0,0 @@
#!/bin/bash
set -e
# Get the directory where this script is located
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
INSTALLER_ROOT="${SCRIPT_DIR}/.."
echo "=== Building Safe Chain Installer for macOS ==="
# Ensure we are in the installer directory
cd "${INSTALLER_ROOT}"
# Install dependencies
echo "Installing build dependencies..."
npm install
# Build the binary and installer using the Node.js build script
echo "Building binary and installer..."
node build.js --platform=macos
echo "Done."

View file

@ -3,6 +3,12 @@ set -e
echo "Installing Safe Chain..."
# Get the actual user (console user)
ACTUAL_USER=$(stat -f '%Su' /dev/console)
if [ -z "$ACTUAL_USER" ] || [ "$ACTUAL_USER" = "root" ]; then
echo "Warning: Could not detect console user, defaulting to root ownership might cause issues."
fi
# The binary is installed to the location specified by --install-location
# which is passed as $3 (installation volume/mountpoint)
INSTALL_LOCATION="${3}/tmp/safe-chain-install"
@ -53,8 +59,6 @@ fi
echo "Starting Safe Chain proxy service..."
# Get the actual user to install the LaunchAgent in their home
# (We still need this for the LaunchAgent, but not for file permissions)
ACTUAL_USER=$(stat -f '%Su' /dev/console)
USER_HOME=$(eval echo "~${ACTUAL_USER}")
# Create LaunchAgent for auto-start on login

View file

@ -1,5 +0,0 @@
#!/bin/bash
echo "=== Building Safe Chain Installer for Linux ==="
echo "TODO: Implement Linux installer build"
echo "This is a placeholder script."
exit 0

View file

@ -1,5 +0,0 @@
@echo off
echo === Building Safe Chain Installer for Windows ===
echo TODO: Implement Windows installer build
echo This is a placeholder script.
exit /b 0