import type { BundleManifest } from "../contracts/core.js"; import { type PlatformSpec } from "./platform.js"; /** * بصمة مجلد: اسم كل ملف ومحتواه، بترتيب مستقرّ. * * الترتيب مقصود: ‎readdirSync‎ لا يضمن ترتيبًا عبر أنظمة الملفات، فبصمة غير مرتّبة تختلف بين آلتين * لنفس المحتوى — وتصير عديمة المعنى ككشفٍ للتغيير. */ export declare function hashDirectory(root: string): { sha256: string; files: number; }; /** * AR: 054: البصمة نفسها **بايتًا ببايت**، لكن بقراءةٍ على دفعات لا تُجمّد العملية، ومع عدّادٍ لما قُرئ. التحديث يعيد * حساب بصمة كل ما سيُستبدل — أربعةٌ وعشرون ألف ملفٍّ في 0.75.0 — والنسخة المتزامنة كانت تُجمّد الطرفية كلها * فلا يتحرّك فيها شيء، والعميل أمام «Verifying fingerprint» يظنّها علقت. النسخة المتزامنة تبقى لخطّ البناء. * EN: 054: the same digest **byte for byte**, but read in chunks that do not freeze the process, with a counter of * what was read. An update recomputes the digest of everything it replaces — twenty-four thousand files in * 0.75.0 — and the synchronous version froze the whole terminal so nothing on it moved, the customer facing * "Verifying fingerprint" and taking it for hung. The synchronous version stays for the build line. */ export declare function hashDirectoryAsync(root: string, onBytes?: (bytes: number) => void): Promise<{ sha256: string; files: number; }>; /** 054: مجموع أحجام ملفّات مجلد — مقام شريط التقدّم قبل أن تبدأ القراءة. */ export declare function directoryBytes(root: string): Promise; export declare function hashFile(path: string): string; export interface ManifestInput { bundleRoot: string; bundleVersion: string; versions: { core: string; live: string; interface: string; supervisor: string; }; ffmpeg: string; ffprobe: string; builtAt: string; unverified: boolean; /** * AR: أدنى إصدار واجهة يقرأ هذه الحزمة (٠٢٦). يكتبه الباني ويقرؤه المُثبِّت قبل التنزيل. * EN: The lowest CLI version that reads this bundle (026). The builder writes it; the installer * reads it before downloading. */ minCliVersion: string; /** * AR: المنصّة التي بُنيت لها هذه الحزمة. **غيابها يعني منصّة الآلة الباني**، فأداةُ إصدارٍ لم * تُحدَّث بعد تكتب على ويندوز ما كانت تكتبه بالضبط. * * وما يُكتب في البيان هو ‎manifestId‎ لا ‎id‎: ‎win32-x64‎ لويندوز، وهي السلسلة التي تقارنها * كل واجهة ‎1.x‎ في الميدان حرفيًّا قبل أن تقبل حزمة. * EN: The platform this bundle was built for. **Its absence means the building machine's own**, so * release tooling that has not been updated writes on Windows exactly what it wrote before. * * What is written into the manifest is `manifestId`, not `id`: `win32-x64` for Windows, the * string every 1.x CLI in the field compares literally before accepting a bundle. */ platform?: PlatformSpec; } export declare function writeManifest(input: ManifestInput): BundleManifest; export declare function readManifest(bundleRoot: string): BundleManifest | undefined; /** حجم شجرة، للتقرير. */ export declare function treeBytes(root: string): number; /** * AR: بصمة البيان **بلا حقل ‎signature‎**. استبعادُه ضرورةٌ لا اختيار: التوقيع يُكتب داخل الملفّ * الذي يشهد له، فلو دخل الحساب لَاستحال إعادة إنتاج الرقم بعد كتابته. * EN: The manifest's digest **excluding the `signature` field**. Excluding it is a necessity rather * than a choice: the signature is written inside the very file it vouches for, so had it entered * the computation the number could never be reproduced once written. */ export declare function manifestDigest(manifest: BundleManifest): { sha256: string; sizeBytes: number; canonical: string; }; export type ManifestSignatureResult = { ok: true; kid: string; signedAt: string; } | { ok: false; reason: "unsigned" | "malformed" | "signature" | "digest"; detail?: string; }; /** * AR: يتحقّق من توقيع البيان بمفاتيح الواجهة المُترجَمة. * * **الترتيب مقصود: التوقيع قبل القراءة، والقراءة قبل المقارنة.** التحقّق من التوقيع أوّلًا يعني * أن ما نقرؤه بعده كتبه من يملك المفتاح؛ ولو قرأنا أوّلًا لَكنّا نحلّل مدخلًا لم يشهد له أحد. * ثم تُقارَن البصمة: التوقيع يشهد لرقم، والرقم يجب أن يكون رقم هذا الملفّ لا ملفٍّ آخر * وُقِّع يومًا. * * **ولا يرمي أبدًا.** فحصٌ يرمي على مدخلٍ مشوَّه يتحوّل من فحصٍ إلى عطل، والمدخل هنا من قرصٍ * يديره غيرنا بحكم التعريف. * EN: Verifies the manifest's signature against the CLI's compiled-in keys. * * **The order is deliberate: signature before parse, parse before comparison.** Verifying the * signature first means whatever we then read was written by the holder of the key; parsing * first would have us analysing input nobody vouched for. Then the digest is compared: the * signature attests a number, and that number must be this file's rather than some other file's * signed once. * * **And it never throws.** A check that throws on malformed input stops being a check and * becomes a fault, and this input comes by definition from a disk somebody else administers. */ export declare function verifyManifestSignature(manifest: BundleManifest, publicKeys?: readonly string[]): ManifestSignatureResult; /** يكتب التوقيع في بيانٍ مكتوبٍ على القرص. يُنادى من خطّ الإصدار بعد أن يوقّع المركز البصمة. */ export declare function writeManifestSignature(bundleRoot: string, signature: string): BundleManifest; /** * AR: المكوّنات التي لا تطابق شجرتُها بصمتَها في البيان (فحص 2026-10-08، U2). التوقيع كان يغطّي ‎versions.json‎ وحده، * والتحقّق قبل التثبيت ‎sha256‎ الأرشيف كما أعلنه المركز — غير موقَّع. فمركزٌ مخترَق يقدّم zip خبيثاً ببصمته هو، * ويحشر داخله البيان الموقَّع الأصليّ، فيمرّ الفحصان ويُثبَّت كودٌ يعمل كـSYSTEM. بصمات المكوّنات **داخل** البيان * الموقَّع، فإعادة حسابها على الشجرة المفكوكة قبل التبديل هي ما يربط التوقيع بما سيُشغَّل فعلاً. * ‎only‎: المداخل التي ستُستبدل — ما لا يُستبدل لا يُفحص هنا. * EN: Components whose tree does not match the digest in the manifest (2026-10-08 assessment, U2). The component * digests live **inside** the signed manifest, so recomputing them over the unpacked tree before the swap is * what binds the signature to what will actually run. */ export declare function componentDigestMismatches(treeRoot: string, manifest: BundleManifest, only?: readonly string[]): string[]; /** * AR: 054: الحكم نفسه بالبصمة غير المتزامنة، مع مجموع البايتات قبل البدء ثم كل ما قُرئ — ليرسم المُحدِّث شريطًا * حقيقيًّا. ‎sets‎ مجموعاتٌ تُفحص معًا (المفكوك، ثم ما يبقى مكانه) فيكون الشريط واحدًا لا اثنين. * EN: 054: the same verdict with the asynchronous digest, with the byte total up front and then everything read — * so the updater draws a real bar. `sets` are checked together (the unpacked tree, then what stays in place) so * the bar is one, not two. */ export declare function componentDigestMismatchesAsync(sets: readonly { treeRoot: string; manifest: BundleManifest; only?: readonly string[]; label?: (name: string) => string; }[], onBytes?: (done: number, total: number) => void): Promise; //# sourceMappingURL=manifest.d.ts.map