refactor(image4): share DER entry projection (#16185)

This commit is contained in:
Vincent Koc authored and GitHub committed 2026-12-03 02:11:41 +00:00
1 parent bfde1a4b9d
commit 1018091955
1 file changed
+11 -23
+11 -23
View File
@@ -1681,26 +1681,14 @@ const parseRestore = async (
return { properties_present: names, values: "redacted" };
};
const manifestEntry = (range: {
offset: number;
length: number;
}): Image4EntryFact => ({
role: "manifest",
path: "manifest.der",
offset: range.offset,
length: range.length,
encrypted: false,
compression: "none",
});
const restoreEntry = (range: {
offset: number;
length: number;
}): Image4EntryFact => ({
role: "restore-info",
path: "restore-info.der",
offset: range.offset,
length: range.length,
const derEntry = (
role: "manifest" | "restore-info",
{ offset, length }: ByteRange,
): Image4EntryFact => ({
role,
path: `${role}.der`,
offset,
length,
encrypted: false,
compression: "none",
});
@@ -1906,7 +1894,7 @@ export const inspectImage4 = async (
manifest = (await parseManifestKids(kids, walk, 0, notes, counter)) ?? null;
const range = encodedRange(root);
if (manifest !== null && range !== undefined)
entries.push(manifestEntry(range));
entries.push(derEntry("manifest", range));
} else {
// IMG4 is SEQUENCE { "IMG4", IM4P, [0] IM4M, [1] IM4R } (img4tool,
// img4lib). Each slot is read from its position; a value that does not
@@ -1916,9 +1904,9 @@ export const inspectImage4 = async (
manifest = slots.manifest?.facts ?? null;
restore = slots.restore?.facts ?? null;
if (slots.manifest !== undefined)
entries.push(manifestEntry(slots.manifest.range));
entries.push(derEntry("manifest", slots.manifest.range));
if (slots.restore !== undefined)
entries.push(restoreEntry(slots.restore.range));
entries.push(derEntry("restore-info", slots.restore.range));
if (payloadKids === undefined)
notes.add("Image4 container has no IM4P payload.");
else {