histoire
Version:
A fast story book powered by Vite
33 lines • 1.64 kB
TypeScript
/** Physical files are bounded before allocation or parsing. */
export declare const MAX_CONTENT_BYTES: number;
/** Signals a retryable snapshot race rather than accepting changed bytes. */
export declare class CatalogContentChangedError extends Error {
}
/** Reader failure with a safe public category and no filesystem error cause. */
export declare class RegisteredContentError extends Error {
/** Distinguishes root escapes from invalid, unavailable, or oversized text. */
readonly code: 'PATH_OUTSIDE_ROOT' | 'SOURCE_UNAVAILABLE';
/** Creates a deliberately safe message, excluding any untrusted path. */
constructor(code: RegisteredContentError['code'], message: string);
}
/** Identity captured from an already verified opened file. */
export interface ContentIdentity {
/** Device/inode, size and content-relevant timestamps. */
key: string;
/** Canonical contained path; never serialized publicly. */
absolutePath: string;
}
/** Exact bounded bytes and opened-file identity for freshness checks. */
export interface RegisteredText {
/** Valid original UTF-8 content. */
text: string;
/** Hash of full original bytes. */
sha256: string;
/** Verified file identity. */
identity: ContentIdentity;
}
/** Validates canonical containment without path-prefix vulnerabilities. */
export declare function isPathWithinRoot(root: string, file: string): boolean;
/** Reads valid UTF-8 from a registered file, retrying one unstable identity. */
export declare function readRegisteredText(root: string | undefined, file: string): Promise<RegisteredText>;
//# sourceMappingURL=files.d.ts.map