fix(protocols): make admission and certificate success types exact

This commit is contained in:
morluto
2026-10-24 02:40:11 +08:00
parent 3602cc851f
commit 39f362dcee
4 changed files with 7 additions and 12 deletions
+1 -1
View File
@@ -24,7 +24,7 @@ const attempt = <T>(read: () => T): T | null => {
};
/** Identity is the raw-DER fingerprint; parsed X.509 facts are null when unreadable. */
export const certificateFacts = (der: Uint8Array): Certificate => {
export const certificateFacts = (der: Uint8Array): NonNullable<Certificate> => {
const cert = attempt(() => {
// OpenSSL auto-detects PEM before DER, including PEM embedded in an extension.
// An explicit envelope makes it decode the selected bytes; raw equality also
+4 -10
View File
@@ -186,16 +186,10 @@ export const v1SignerFacts = ({
// Without verification, a block with several SignerInfos has no one signer.
certificate:
infos.length === 1 ? named(infos[0]?.certificateIndex ?? null) : null,
certificates: facts.flatMap((fact) =>
fact === null
? []
: [
{
sha256_fingerprint: fact.sha256_fingerprint,
subject: fact.subject,
},
],
),
certificates: facts.map(({ sha256_fingerprint, subject }) => ({
sha256_fingerprint,
subject,
})),
signer_infos: infos.map((info) => ({
identified_by: info.identifiedBy,
certificate_sha256:
@@ -100,6 +100,7 @@ const admitDescriptorRegistry = async (
stack.push({ message: nested, prefix: length });
}
}
return undefined;
};
const scalarValue = (reader: BinaryReader, scalar: ScalarType): string => {
@@ -240,7 +240,7 @@ it.each([0, 7])(
expect(projectAnalysisError(retry.error)).toMatchObject({
code: "cleanup_incomplete",
details: {
resources: expect.arrayContaining(result.error.cleanupResources),
resources: expect.arrayContaining([...result.error.cleanupResources]),
},
});
expect(retry.error.cleanupResources.length).toBeGreaterThan(0);