fix(apple): preserve archive signatures and metadata byte identity

This commit is contained in:
morluto
2026-10-13 07:34:52 +08:00
parent 653067d799
commit dc038d16bb
12 changed files with 82 additions and 28 deletions
+12
View File
@@ -0,0 +1,12 @@
const BINARY_PLIST_MAGIC = [0x62, 0x70, 0x6c, 0x69, 0x73, 0x74, 0x30, 0x30];
const NIB_ARCHIVE_MAGIC = [
0x4e, 0x49, 0x42, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65,
];
/** Recognize the exact binary plist version supported by the decoder, without validating its body. */
export const hasBinaryPlistSignature = (bytes: Uint8Array): boolean =>
BINARY_PLIST_MAGIC.every((byte, index) => bytes[index] === byte);
/** Recognize the serialized signature without claiming a valid NIB object table. */
export const hasNibArchiveSignature = (bytes: Uint8Array): boolean =>
NIB_ARCHIVE_MAGIC.every((byte, index) => bytes[index] === byte);