/// import { SecurityKeystore } from './security/keystore'; import { Signature } from './signature'; import { Hasher } from './hasher'; /** * Options for adding resources. */ export interface IPackagerResourceOptions { /** * Mark file as executable. */ executable?: boolean | null; /** * Specific file modification time. */ mtime?: Date | null; } /** * Packager constructor. * * @param path Output path. */ export declare abstract class Packager extends Object { /** * Make a debug build. */ debug: boolean; /** * Keystore object to use for signing. */ keystore: Readonly | null; /** * Timestamp URL. */ timestampUrl: string | null; /** * File and directory names to exclude when added a directory. */ excludes: RegExp[]; /** * Output path. */ readonly path: string; /** * Open flag. */ protected _isOpen: boolean; /** * Adding a resource flag. */ protected _isAddingResource: boolean; /** * Hasher object. */ protected _hasher: Hasher; /** * Signature object. */ protected _signature: Signature | null; constructor(path: string); /** * Check if output open. * * @returns Returns true if open, else false. */ get isOpen(): boolean; /** * Open with application descriptor XML data. * * @param applicationData XML data. */ open(applicationData: Readonly): Promise; /** * Open with application descriptor file. * * @param descriptorFile Application descriptor file. */ openFile(descriptorFile: string): Promise; /** * Close output. */ close(): Promise; /** * Run asyncronous function with automatic open and close. * * @param applicationData XML data. * @param func Async function. * @returns Return value of the async function. */ with(applicationData: Readonly, func: (self: this) => Promise): Promise; /** * Run asyncronous function with automatic open and close. * * @param descriptorFile Application descriptor file. * @param func Async function. * @returns Return value of the async function. */ withFile(descriptorFile: string, func: (self: this) => Promise): Promise; /** * Check if name is excluded file. * * @param name File name. * @returns Returns true if excluded, else false. */ isExcludedFile(name: string): boolean; /** * Add resource with file. * * @param source File path. * @param destination Packaged file relative destination. * @param options Resource options. */ addResourceFile(source: string, destination?: string | null, options?: Readonly | null): Promise; /** * Add resource with directory. * Walks the directory looking for files to add, skips excluded file names. * * @param source Directory path. * @param destination Packaged directory relative destination. * @param options Resource options. */ addResourceDirectory(source: string, destination?: string | null, options?: Readonly | null): Promise; /** * Add resource with data. * * @param destination Packaged file relative destination. * @param data Resource data. * @param options Resource options. */ addResource(destination: string, data: Readonly, options?: Readonly | null): Promise; /** * Create Hasher object. * * @returns Hasher object. */ protected _createHasher(): Hasher; /** * Create Signature object. * * @returns Hasher object. */ protected _createSignature(): Signature; /** * Path of the mimetype meta resource. * * @returns Resource path. */ protected get _metaResourceMimetypePath(): string; /** * Path of the application meta resource. * * @returns Resource path. */ protected get _metaResourceApplicationPath(): string; /** * Path of the hash meta resource. * * @returns Resource path. */ protected get _metaResourceHashPath(): string; /** * Path of the debug meta resource. * * @returns Resource path. */ protected get _metaResourceDebugPath(): string; /** * Path of the signatures meta resource. * * @returns Resource path. */ protected get _metaResourceSignaturesPath(): string; /** * Get encoded mimetype data. * * @returns Mimetype buffer. */ protected _getMimetypeData(): Buffer; /** * Get the keystore object. * * @returns Keystore object. */ protected _getKeystore(): Readonly; /** * Add resource with data, with options controlling hashing and signing. * * @param destination Packaged file relative destination. * @param data Resource data. * @param options Resource options. * @param hashed This file is hashed. * @param signed This file is signed. */ protected _addResource(destination: string, data: Readonly, options: Readonly, hashed: boolean, signed: boolean): Promise; /** * Add meta resources start. * * @param applicationData XML data. */ protected _addMetaResourcesStart(applicationData: Readonly): Promise; /** * Add meta resources end. */ protected _addMetaResourcesEnd(): Promise; /** * Add meta resource for the mimetype. */ protected _addMetaResourceMimetype(): Promise; /** * Add meta resource for the application descriptor. * * @param applicationData The application descriptor data. */ protected _addMetaResourceApplication(applicationData: Readonly): Promise; /** * Add meta resource for the hash (needs updating on close). */ protected _addMetaResourceHash(): Promise; /** * Add meta resource for debug. */ protected _addMetaResourceDebug(): Promise; /** * Add resource for signatures. */ protected _addMetaResourceSignatures(): Promise; /** * Init application info from descriptor data. * * @param applicationData The application descriptor data. */ protected _applicationInfoInit(applicationData: Readonly): void; /** * Clear application info from descriptor data. */ protected _applicationInfoClear(): void; /** * Open path as archive. * * @param path Archive path. * @returns Archive instance. */ protected _openArchive(path: string): Promise; /** * Package mimetype. * * @returns Mimetype string. */ abstract get mimetype(): string; /** * Package signed. * * @returns Boolean for if package is signed or not. */ abstract get signed(): boolean; /** * Open implementation. * * @param applicationData The application descriptor data. */ protected abstract _open(applicationData: Readonly): Promise; /** * Close implementation. */ protected abstract _close(): Promise; /** * Write resource with data implementation. * * @param destination Packaged file relative destination. * @param data Resource data. * @param options Resource options. */ protected abstract _writeResource(destination: string, data: Readonly, options: Readonly): Promise; }