feat(updates): verify and install launcher releases
Check the versioned release channel, verify the signed manifest and installer digest, and open the installer only after confirmation. Verified type checks, the Windows package, and an upgrade handoff from a local release fixture, including tampering and interrupted downloads.
This commit is contained in:
1 parent
31b38518f8
commit
746b74c564
24 files changed
+638
-28
No files matched your search
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Ed25519 signatures of adaptation packs.
|
||||
* Ed25519 signatures for project releases.
|
||||
*
|
||||
* The private key never enters the repository: the release workflow reads it from the GitHub
|
||||
* secret PATCH_SIGNING_KEY, and the developer keeps a backup outside the repository. The public
|
||||
@@ -32,18 +32,20 @@ export function packSigningPublicKey(): string | null {
|
||||
return existsSync(SIGNING_PUBLIC_KEY_FILE) ? readFileSync(SIGNING_PUBLIC_KEY_FILE, 'utf8') : null;
|
||||
}
|
||||
|
||||
export function signPatchPack(zip: Uint8Array, privateKeyPem: string): string {
|
||||
export function signEd25519(bytes: Uint8Array, privateKeyPem: string): string {
|
||||
const key = ed25519Key(() => createPrivateKey(privateKeyPem), 'private');
|
||||
return `${sign(null, zip, key).toString('base64')}\n`;
|
||||
return `${sign(null, bytes, key).toString('base64')}\n`;
|
||||
}
|
||||
|
||||
export function verifyPatchPack(zip: Uint8Array, signatureText: string, publicKeyPem: string): boolean {
|
||||
export function verifyEd25519(bytes: Uint8Array, signatureText: string, publicKeyPem: string): boolean {
|
||||
const key = ed25519Key(() => createPublicKey(publicKeyPem), 'public');
|
||||
const signature = Buffer.from(signatureText.trim(), 'base64');
|
||||
if (signature.length !== 64) return false;
|
||||
return verify(null, zip, key, signature);
|
||||
return verify(null, bytes, key, signature);
|
||||
}
|
||||
|
||||
export { signEd25519 as signPatchPack, verifyEd25519 as verifyPatchPack };
|
||||
|
||||
function ed25519Key(read: () => KeyObject, kind: 'private' | 'public'): KeyObject {
|
||||
let key: KeyObject;
|
||||
try {
|
||||
|
||||
Reference in new issue
Block a user