sync: update from private repo (bd7e2ac0)
All checks were successful
CI / build-and-test (push) Successful in 6m50s

This commit is contained in:
oss-sync 2026-07-09 02:02:26 +00:00
parent fb1477c9d5
commit 96bffa9a15

View File

@ -81,10 +81,22 @@ export interface RunningTestServer {
forceClose(): Promise<void>; forceClose(): Promise<void>;
} }
/** Generate a fresh ed25519 keypair in OpenSSH format (parseable by ssh2 both sides). */ /**
* Generate a fresh ed25519 keypair in OpenSSH format (parseable by ssh2 both sides).
* ssh2's ed25519 generation has a ~0.4% chance of producing a key that it cannot parse;
* this function validates and retries up to 10 times to avoid the flake.
*/
export function generateEd25519Pair(): { privatePem: string; publicSsh: string } { export function generateEd25519Pair(): { privatePem: string; publicSsh: string } {
const kp = sshUtils.generateKeyPairSync('ed25519'); let lastError: Error | null = null;
return { privatePem: kp.private, publicSsh: kp.public }; for (let attempt = 0; attempt < 10; attempt++) {
const kp = sshUtils.generateKeyPairSync('ed25519');
const parsed = sshUtils.parseKey(kp.private);
if (!(parsed instanceof Error)) {
return { privatePem: kp.private, publicSsh: kp.public };
}
lastError = parsed;
}
throw lastError || new Error('Failed to generate valid ed25519 keypair after 10 attempts');
} }
/** Generate an RSA-2048 PKCS#1 PEM keypair (parseable by ssh2.utils.parseKey). */ /** Generate an RSA-2048 PKCS#1 PEM keypair (parseable by ssh2.utils.parseKey). */