Adds prettier 3.9.8 (exact) with a shared config (single quotes, 120 columns, trailing commas), .prettierignore, .editorconfig and the `format` / `format:check` scripts, then formats all TypeScript, JavaScript, CSS, JSON and YAML sources. Purely mechanical: no behaviour change. Typecheck passes, the vitest suite and the 74 IDE node tests produce the same results as before (socket-binding tests still cannot run inside this sandbox). Previously the longest source line was ~3000 characters; reviewing the following semantic changes now produces readable diffs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
19 lines
1.2 KiB
JavaScript
19 lines
1.2 KiB
JavaScript
const fs = require('node:fs');
|
|
const path = require('node:path');
|
|
const { generateKeyPairSync, createPrivateKey, createPublicKey } = require('node:crypto');
|
|
const directory = path.resolve(process.argv[2] ?? '.wishforge/gateway-keys');
|
|
fs.mkdirSync(directory, { recursive: true, mode: 0o700 });
|
|
const privateFile = path.join(directory, 'private.pem'),
|
|
publicFile = path.join(directory, 'public.pem');
|
|
if (!fs.existsSync(privateFile)) {
|
|
const keys = generateKeyPairSync('ed25519');
|
|
fs.writeFileSync(privateFile, keys.privateKey.export({ type: 'pkcs8', format: 'pem' }), { flag: 'wx', mode: 0o600 });
|
|
}
|
|
const privateKey = createPrivateKey(fs.readFileSync(privateFile));
|
|
if (privateKey.asymmetricKeyType !== 'ed25519') throw new Error('Existing gateway key is not Ed25519');
|
|
const publicPem = createPublicKey(privateKey).export({ type: 'spki', format: 'pem' });
|
|
if (fs.existsSync(publicFile) && fs.readFileSync(publicFile, 'utf8') !== publicPem)
|
|
throw new Error('Existing public key does not match; inspect key rotation explicitly');
|
|
if (!fs.existsSync(publicFile)) fs.writeFileSync(publicFile, publicPem, { flag: 'wx', mode: 0o644 });
|
|
console.log(JSON.stringify({ privateKeyFile: privateFile, publicKeyFile: publicFile }));
|