mirror of
https://github.com/AikidoSec/safe-chain.git
synced 2026-05-26 12:10:49 +00:00
Add installer changes
This commit is contained in:
parent
e765ccf303
commit
2158478894
13 changed files with 674 additions and 21 deletions
46
installer/generate-certs.js
Normal file
46
installer/generate-certs.js
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
#!/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);
|
||||
});
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue