fix(types): support @types/node v26 KeyObject.export and group Babel dependabot updates

- Cast KeyObject.export({ format: "pem" }) via String(...) in manifest-signing.ts
  and manifest-verify.ts so string | Buffer union satisfies @types/node >=26
  where string.toString() takes 0 arguments.
- Group @babel/* and @types/babel__* in .github/dependabot.yml to prevent split
  Babel v7/v8 AST type mismatches across individual PRs.

Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
qybaihe
2026-11-07 20:00:40 +08:00
parent b1015268fe
commit c54bc433eb
3 changed files with 15 additions and 10 deletions
+5
View File
@@ -7,6 +7,11 @@ updates:
open-pull-requests-limit: 10
labels:
- dependencies
groups:
babel:
patterns:
- "@babel/*"
- "@types/babel__*"
- package-ecosystem: github-actions
directory: "/"
schedule:
+7 -7
View File
@@ -53,8 +53,8 @@ export interface ManifestSigningKeyPair {
export function generateManifestSigningKeyPair(): ManifestSigningKeyPair {
const { privateKey, publicKey } = generateKeyPairSync("ed25519");
return {
privateKeyPem: privateKey.export({ type: "pkcs8", format: "pem" }).toString("utf8"),
publicKeyPem: publicKey.export({ type: "spki", format: "pem" }).toString("utf8"),
privateKeyPem: String(privateKey.export({ type: "pkcs8", format: "pem" })),
publicKeyPem: String(publicKey.export({ type: "spki", format: "pem" })),
};
}
@@ -70,9 +70,9 @@ export function signManifestPayload<T extends object>(
const privateKey = createPrivateKey(privateKeyPem);
const canonical = canonicalManifestJson(payload);
const value = cryptoSign(null, Buffer.from(canonical, "utf8"), privateKey).toString("base64");
const publicKeyPem = createPublicKey(privateKey)
.export({ type: "spki", format: "pem" })
.toString("utf8");
const publicKeyPem = String(
createPublicKey(privateKey).export({ type: "spki", format: "pem" }),
);
return {
...payload,
signature: { algorithm: "ed25519", publicKey: publicKeyPem, value, canonicalization: "sorted-keys-v1" },
@@ -110,8 +110,8 @@ export function verifyManifestSignature(
const publicKey = createPublicKey(signature.publicKey);
if (expectedPublicKeyPem !== undefined) {
const pinned = createPublicKey(expectedPublicKeyPem);
const embeddedSpki = publicKey.export({ type: "spki", format: "pem" }).toString("utf8");
const pinnedSpki = pinned.export({ type: "spki", format: "pem" }).toString("utf8");
const embeddedSpki = String(publicKey.export({ type: "spki", format: "pem" }));
const pinnedSpki = String(pinned.export({ type: "spki", format: "pem" }));
if (embeddedSpki !== pinnedSpki) return false;
}
const { signature: _ignored, ...rest } = manifest;
+3 -3
View File
@@ -14,9 +14,9 @@ export interface ManifestVerifyResult {
}
function normalizePublicKeyPem(pem: string): string {
return createPublicKey(pem)
.export({ type: "spki", format: "pem" })
.toString("utf8");
return String(
createPublicKey(pem).export({ type: "spki", format: "pem" }),
);
}
/**