/** * core/mjksmap.ts * * MajikSignatureMap — a single manifest mapping every file in a batch/zip * to its detached MajikSignatureEnvelope. * * Design constraints (same as MajikSignatureEnvelope): * - Pure/structural only. No crypto — verification is composed by callers * via MajikSignature.verifyFileDetached() using an entry's envelope. * - Immutable. withEntry() returns a new instance. * - Keyed by path, not contentHash — duplicate-content files across a * batch are legitimate and must not collide. contentHash is retained * per-entry as an integrity check and as a secondary lookup index. */ import { MajikSignatureEnvelope } from "./envelope"; import type { MjksMapEntry, MjksMapFindResult, MjksMapJSON, MjksMapResolveResult } from "./types"; export declare class MajikSignatureMap { #private; private readonly _version; private readonly _createdAt; private readonly _entries; private readonly _byPath; private readonly _byHash; private constructor(); get version(): 1; get createdAt(): string; get entries(): readonly MjksMapEntry[]; get size(): number; /** * Resolve a file against the map, tolerating relocation. * * Tries the exact given path first (cheap, no hashing needed for the miss * case... well, actually a match still needs the hash check below). If * that path isn't in the map, falls back to a content-based search — this * is what makes the map resilient to the batch being reorganized, renamed, * or moved to a different folder/device after signing, since none of that * changes a file's content or its signatures. * * "relocated" is reported as its own status rather than folded into * "path_match" — a caller may reasonably want to flag/re-index a file * that moved, even though its signature is still perfectly valid. */ resolveEntry(path: string, file: Blob): Promise; /** Raw entry lookup by exact path — no hash verification, no file needed. */ getEntry(path: string): MjksMapEntry | undefined; /** * Resolve a specific file's envelope, given its path AND its current bytes. * Recomputes the hash and compares against the stored contentHash — this * is the integrity check that catches "same name, edited after signing." * * Returns { found: false } if no entry exists at that path at all. * Returns { found: true, hashMatches: false } if the entry exists but the * file's current content no longer matches what was signed — the caller * decides whether that's fatal (it usually should be, but this method * doesn't throw so the caller can present a clear message rather than * catching an exception). */ findEntry(path: string, file: Blob): Promise; /** * Find every entry matching a file's content, regardless of path. * Returns an array (not a single entry) because duplicate-content files * are legitimate — collapsing to one result would silently hide the rest. * Use when the file may have been renamed/relocated after extraction. */ findEntriesByHash(file: Blob): Promise; /** * Resolve a specific entry's envelope as a rich MajikSignatureEnvelope * instance (not just the stored JSON) — matches the convention that every * "give me a signature-shaped thing" method in this library returns the * behavior-rich class, not raw wire JSON. * Returns null if no entry exists at that path. */ getEnvelope(path: string): MajikSignatureEnvelope | null; /** * All envelopes in the map, each paired with its path, as rich * MajikSignatureEnvelope instances. Useful for bulk operations — * e.g. rendering a signing-status table for an entire extracted batch * without looking up each file individually. */ getAllEnvelopes(): { path: string; envelope: MajikSignatureEnvelope; }[]; hasEntry(path: string): boolean; /** * Add or replace an entry by path. Path is normalized before storage and * before the uniqueness check, so "docs/a.pdf" and "docs\\a.pdf" collide * as the same key rather than silently duplicating. */ withEntry(entry: MjksMapEntry): MajikSignatureMap; withoutEntry(path: string): MajikSignatureMap; toJSON(): MjksMapJSON; toMJKSMAPBytes(): Uint8Array; toMJKSMAP(): Blob; static fromMJKSMAP(input: Blob | Uint8Array): Promise; static isMJKSMAP(input: Blob | Uint8Array): Promise; static empty(): MajikSignatureMap; static fromJSON(json: MjksMapJSON | string): MajikSignatureMap; /** Accepts an instance, its JSON shape, or MJKSMAP bytes/Blob. */ static from(input: MajikSignatureMap | MjksMapJSON | Uint8Array | Blob): Promise; validate(): void; isValid(): boolean; }