sign-update-manifest.mjs
22 lines 949 B
Raw
sha256:bd1eb24434d281fe65142038c1bf217493421f5a86880c22dff7e6037d2d4700 feat(companion): add production macOS distribution path Human minor ⚠ breaking 25 days ago
1 #!/usr/bin/env node
2 import crypto from 'node:crypto';
3 import fs from 'node:fs';
4
5 function option(name) {
6 const index = process.argv.indexOf(`--${name}`);
7 if (index < 0 || !process.argv[index + 1]) throw new Error(`missing --${name}`);
8 return process.argv[index + 1];
9 }
10
11 const manifestPath = option('manifest');
12 const keyPath = option('key-file');
13 const outputPath = option('output');
14 const expectedKeyID = option('key-id');
15 const manifest = fs.readFileSync(manifestPath);
16 const parsed = JSON.parse(manifest.toString('utf8'));
17 if (parsed.keyID !== expectedKeyID) throw new Error('update key ID does not match manifest');
18 const privateKey = crypto.createPrivateKey(fs.readFileSync(keyPath));
19 if (privateKey.asymmetricKeyType !== 'ed25519') throw new Error('update key must be Ed25519');
20 const signature = crypto.sign(null, manifest, privateKey);
21 fs.writeFileSync(outputPath, signature, { mode: 0o644 });
22 process.stdout.write(`${outputPath}\n`);
File History 1 commit
sha256:bd1eb24434d281fe65142038c1bf217493421f5a86880c22dff7e6037d2d4700 feat(companion): add production macOS distribution path Human minor ⚠ 25 days ago