UNPKG

23.8 kBSource Map (JSON)View Raw
1{"version":3,"file":"packager.js","names":["_promises","require","_nodePath","_archiveFiles","_signature","_sha","Packager","debug","keystore","timestampUrl","descriptorData","descriptorFile","excludes","nobrowse","_isOpen","_isAddingResource","constructor","path","_hasher","_createHasher","isOpen","open","Error","_getDescriptorData","_applicationInfoInit","_open","reset","signed","_createSignature","_getKeystore","certificate","getCertificate","privateKey","getPrivateKey","_addMetaResourcesStart","close","_addMetaResourcesEnd","_close","_applicationInfoClear","write","func","r","call","isExcludedFile","name","exclude","test","addResourceFile","source","destination","options","opts","dest","stat","lstat","isSymbolicLink","isFile","executable","mode","data","readFile","addResource","mtime","addResourceDirectory","fsWalk","basename","isDirectory","pathJoin","_addResource","pathNormalize","HasherSha256","Signature","_metaResourceMimetypePath","_metaResourceApplicationPath","_metaResourceHashPath","_metaResourceDebugPath","_metaResourceSignaturesPath","d","TextEncoder","encode","Uint8Array","buffer","byteOffset","byteLength","_getMimetypeData","mimetype","hashed","update","signature","addFile","_writeResource","applicationData","_addMetaResourceMimetype","_addMetaResourceApplication","_addMetaResourceHash","_addMetaResourceDebug","_addMetaResourceSignatures","bytes","digest","sign","timestamp","exports"],"sources":["../src/packager.ts"],"sourcesContent":["import {lstat, readFile} from 'node:fs/promises';\nimport {join as pathJoin, basename} from 'node:path';\n\nimport {fsWalk, pathNormalize} from '@shockpkg/archive-files';\n\nimport {SecurityKeystore} from './security/keystore';\nimport {Signature} from './signature';\nimport {Hasher} from './hasher';\nimport {HasherSha256} from './hasher/sha256';\n\n/**\n * Options for adding resources.\n */\nexport interface IPackagerResourceOptions {\n\t/**\n\t * Mark file as executable.\n\t */\n\texecutable?: boolean | null;\n\n\t/**\n\t * Specific file modification time.\n\t */\n\tmtime?: Date | null;\n}\n\n/**\n * Packager object.\n */\nexport abstract class Packager {\n\t/**\n\t * Make a debug build.\n\t */\n\tpublic debug = false;\n\n\t/**\n\t * Keystore object to use for signing.\n\t */\n\tpublic keystore: Readonly<SecurityKeystore> | null = null;\n\n\t/**\n\t * Timestamp URL.\n\t */\n\tpublic timestampUrl: string | null = null;\n\n\t/**\n\t * Application descriptor file data.\n\t */\n\tpublic descriptorData:\n\t\t| string\n\t\t| Readonly<Uint8Array>\n\t\t| (() => Readonly<string | Uint8Array>)\n\t\t| (() => Promise<Readonly<string | Uint8Array>>)\n\t\t| null = null;\n\n\t/**\n\t * Application descriptor file path.\n\t */\n\tpublic descriptorFile: string | null = null;\n\n\t/**\n\t * File and directory names to exclude when added a directory.\n\t */\n\tpublic excludes = [/^\\./, /^ehthumbs\\.db$/i, /^Thumbs\\.db$/i];\n\n\t/**\n\t * Set the nobrowse option on mounted disk images.\n\t */\n\tpublic nobrowse = false;\n\n\t/**\n\t * Output path.\n\t */\n\tpublic readonly path: string;\n\n\t/**\n\t * Open flag.\n\t */\n\tprotected _isOpen = false;\n\n\t/**\n\t * Adding a resource flag.\n\t */\n\tprotected _isAddingResource = false;\n\n\t/**\n\t * Hasher object.\n\t */\n\tprotected _hasher: Hasher;\n\n\t/**\n\t * Signature object.\n\t */\n\tprotected _signature: Signature | null = null;\n\n\t/**\n\t * Packager constructor.\n\t *\n\t * @param path Output path.\n\t */\n\tconstructor(path: string) {\n\t\tthis._hasher = this._createHasher();\n\n\t\tthis.path = path;\n\t}\n\n\t/**\n\t * Check if output open.\n\t *\n\t * @returns Returns true if open, else false.\n\t */\n\tpublic get isOpen() {\n\t\treturn this._isOpen;\n\t}\n\n\t/**\n\t * Open with application descriptor XML data.\n\t */\n\tpublic async open() {\n\t\tif (this._isOpen) {\n\t\t\tthrow new Error('Already open');\n\t\t}\n\n\t\tconst descriptorData = await this._getDescriptorData();\n\t\tthis._applicationInfoInit(descriptorData);\n\t\tawait this._open();\n\t\tthis._isOpen = true;\n\n\t\tthis._hasher.reset();\n\n\t\tthis._signature = null;\n\t\tif (this.signed) {\n\t\t\tthis._signature = this._createSignature();\n\t\t\tthis._signature.timestampUrl = this.timestampUrl;\n\n\t\t\tconst keystore = this._getKeystore();\n\t\t\tthis._signature.certificate = keystore.getCertificate();\n\t\t\tthis._signature.privateKey = keystore.getPrivateKey();\n\t\t}\n\n\t\tawait this._addMetaResourcesStart(descriptorData);\n\t}\n\n\t/**\n\t * Close output.\n\t */\n\tpublic async close() {\n\t\tif (!this._isOpen) {\n\t\t\tthrow new Error('Not open');\n\t\t}\n\t\tawait this._addMetaResourcesEnd();\n\t\tawait this._close();\n\t\tthis._isOpen = false;\n\t\tthis._applicationInfoClear();\n\n\t\tthis._hasher.reset();\n\t\tthis._signature = null;\n\t}\n\n\t/**\n\t * Run asyncronous function with automatic open and close.\n\t *\n\t * @param func Async function.\n\t * @returns Return value of the async function.\n\t */\n\tpublic async write<T>(func: (self: this) => Promise<T>): Promise<T> {\n\t\tawait this.open();\n\t\tlet r: T;\n\t\ttry {\n\t\t\tr = (await func.call(this, this)) as T;\n\t\t} finally {\n\t\t\tawait this.close();\n\t\t}\n\t\treturn r;\n\t}\n\n\t/**\n\t * Check if name is excluded file.\n\t *\n\t * @param name File name.\n\t * @returns Returns true if excluded, else false.\n\t */\n\tpublic isExcludedFile(name: string) {\n\t\tfor (const exclude of this.excludes) {\n\t\t\tif (exclude.test(name)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\n\t/**\n\t * Add resource with file.\n\t *\n\t * @param source File path.\n\t * @param destination Packaged file relative destination.\n\t * @param options Resource options.\n\t */\n\tpublic async addResourceFile(\n\t\tsource: string,\n\t\tdestination: string | null = null,\n\t\toptions: Readonly<IPackagerResourceOptions> | null = null\n\t) {\n\t\tconst opts = options || {};\n\t\tconst dest = destination === null ? source : destination;\n\t\tconst stat = await lstat(source);\n\n\t\t// Symlinks would only be allowed in a macOS native extension.\n\t\t// Throw an error like the official packager does.\n\t\tif (stat.isSymbolicLink()) {\n\t\t\tthrow new Error(`Cannot add symlink: ${source}`);\n\t\t}\n\n\t\t// Throw if not a regular file.\n\t\tif (!stat.isFile()) {\n\t\t\tthrow new Error(`Unsupported file type: ${source}`);\n\t\t}\n\n\t\tlet {executable} = opts;\n\t\tif (executable !== true && executable !== false) {\n\t\t\t// eslint-disable-next-line no-bitwise\n\t\t\texecutable = !!(stat.mode & 0b001000000);\n\t\t}\n\n\t\tconst data = await readFile(source);\n\t\tawait this.addResource(dest, data, {\n\t\t\texecutable,\n\t\t\tmtime: opts.mtime || stat.mtime\n\t\t});\n\t}\n\n\t/**\n\t * Add resource with directory.\n\t * Walks the directory looking for files to add, skips excluded file names.\n\t *\n\t * @param source Directory path.\n\t * @param destination Packaged directory relative destination.\n\t * @param options Resource options.\n\t */\n\tpublic async addResourceDirectory(\n\t\tsource: string,\n\t\tdestination: string | null = null,\n\t\toptions: Readonly<IPackagerResourceOptions> | null = null\n\t) {\n\t\tconst dest = destination === null ? source : destination;\n\n\t\tawait fsWalk(source, async (path, stat) => {\n\t\t\t// If this name is excluded, skip without descending.\n\t\t\tif (this.isExcludedFile(basename(path))) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Ignore directories, but descend into them.\n\t\t\t// Only files are listed in the ZIP packages.\n\t\t\t// Created automatically for files in any other package.\n\t\t\tif (stat.isDirectory()) {\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\t// Anything else assume file.\n\t\t\tawait this.addResourceFile(\n\t\t\t\tpathJoin(source, path),\n\t\t\t\tpathJoin(dest, path),\n\t\t\t\toptions\n\t\t\t);\n\n\t\t\treturn true;\n\t\t});\n\t}\n\n\t/**\n\t * Add resource with data.\n\t *\n\t * @param destination Packaged file relative destination.\n\t * @param data Resource data.\n\t * @param options Resource options.\n\t */\n\tpublic async addResource(\n\t\tdestination: string,\n\t\tdata: Readonly<Uint8Array>,\n\t\toptions: Readonly<IPackagerResourceOptions> | null = null\n\t) {\n\t\tif (!this._isOpen) {\n\t\t\tthrow new Error('Not open');\n\t\t}\n\t\tif (this._isAddingResource) {\n\t\t\tthrow new Error('Resources must be added sequentially');\n\t\t}\n\t\tthis._isAddingResource = true;\n\t\tawait this._addResource(\n\t\t\tpathNormalize(destination),\n\t\t\tdata,\n\t\t\toptions || {},\n\t\t\ttrue,\n\t\t\ttrue\n\t\t);\n\t\tthis._isAddingResource = false;\n\t}\n\n\t/**\n\t * Create Hasher object.\n\t *\n\t * @returns Hasher object.\n\t */\n\tprotected _createHasher(): Hasher {\n\t\treturn new HasherSha256();\n\t}\n\n\t/**\n\t * Create Signature object.\n\t *\n\t * @returns Hasher object.\n\t */\n\tprotected _createSignature() {\n\t\treturn new Signature();\n\t}\n\n\t/**\n\t * Path of the mimetype meta resource.\n\t *\n\t * @returns Resource path.\n\t */\n\tprotected get _metaResourceMimetypePath() {\n\t\treturn 'mimetype';\n\t}\n\n\t/**\n\t * Path of the application meta resource.\n\t *\n\t * @returns Resource path.\n\t */\n\tprotected get _metaResourceApplicationPath() {\n\t\treturn 'META-INF/AIR/application.xml';\n\t}\n\n\t/**\n\t * Path of the hash meta resource.\n\t *\n\t * @returns Resource path.\n\t */\n\tprotected get _metaResourceHashPath() {\n\t\treturn 'META-INF/AIR/hash';\n\t}\n\n\t/**\n\t * Path of the debug meta resource.\n\t *\n\t * @returns Resource path.\n\t */\n\tprotected get _metaResourceDebugPath() {\n\t\treturn 'META-INF/AIR/debug';\n\t}\n\n\t/**\n\t * Path of the signatures meta resource.\n\t *\n\t * @returns Resource path.\n\t */\n\tprotected get _metaResourceSignaturesPath() {\n\t\treturn 'META-INF/signatures.xml';\n\t}\n\n\t/**\n\t * Get application descriptor data or throw.\n\t *\n\t * @returns Application descriptor XML data.\n\t */\n\tprotected async _getDescriptorData() {\n\t\tconst {descriptorData, descriptorFile} = this;\n\t\tif (descriptorData) {\n\t\t\tswitch (typeof descriptorData) {\n\t\t\t\tcase 'function': {\n\t\t\t\t\tconst d = await descriptorData();\n\t\t\t\t\treturn typeof d === 'string'\n\t\t\t\t\t\t? new TextEncoder().encode(d)\n\t\t\t\t\t\t: d;\n\t\t\t\t}\n\t\t\t\tcase 'string': {\n\t\t\t\t\treturn new TextEncoder().encode(descriptorData);\n\t\t\t\t}\n\t\t\t\tdefault: {\n\t\t\t\t\treturn descriptorData;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (descriptorFile !== null) {\n\t\t\tconst d = await readFile(descriptorFile);\n\t\t\treturn new Uint8Array(d.buffer, d.byteOffset, d.byteLength);\n\t\t}\n\t\tthrow new Error('Missing application descriptor data');\n\t}\n\n\t/**\n\t * Get encoded mimetype data.\n\t *\n\t * @returns Mimetype data.\n\t */\n\tprotected _getMimetypeData() {\n\t\t// The mimetype is UTF-8.\n\t\treturn new TextEncoder().encode(this.mimetype);\n\t}\n\n\t/**\n\t * Get the keystore object.\n\t *\n\t * @returns Keystore object.\n\t */\n\tprotected _getKeystore() {\n\t\tconst r = this.keystore;\n\t\tif (!r) {\n\t\t\tthrow new Error('A keystore not set');\n\t\t}\n\t\treturn r;\n\t}\n\n\t/**\n\t * Add resource with data, with options controlling hashing and signing.\n\t *\n\t * @param destination Packaged file relative destination.\n\t * @param data Resource data.\n\t * @param options Resource options.\n\t * @param hashed This file is hashed.\n\t * @param signed This file is signed.\n\t */\n\tprotected async _addResource(\n\t\tdestination: string,\n\t\tdata: Readonly<Uint8Array>,\n\t\toptions: Readonly<IPackagerResourceOptions>,\n\t\thashed: boolean,\n\t\tsigned: boolean\n\t) {\n\t\tif (hashed) {\n\t\t\tthis._hasher.update(data);\n\t\t}\n\t\tif (signed) {\n\t\t\tconst signature = this._signature;\n\t\t\tif (signature) {\n\t\t\t\tsignature.addFile(destination, data);\n\t\t\t}\n\t\t}\n\t\tawait this._writeResource(destination, data, options);\n\t}\n\n\t/**\n\t * Add meta resources start.\n\t *\n\t * @param applicationData XML data.\n\t */\n\tprotected async _addMetaResourcesStart(\n\t\tapplicationData: Readonly<Uint8Array>\n\t) {\n\t\tawait this._addMetaResourceMimetype();\n\t\tawait this._addMetaResourceApplication(applicationData);\n\t\tawait this._addMetaResourceHash();\n\t\tif (this.debug) {\n\t\t\tawait this._addMetaResourceDebug();\n\t\t}\n\t}\n\n\t/**\n\t * Add meta resources end.\n\t */\n\tprotected async _addMetaResourcesEnd() {\n\t\tif (this.signed) {\n\t\t\tawait this._addMetaResourceSignatures();\n\t\t}\n\t}\n\n\t/**\n\t * Add meta resource for the mimetype.\n\t */\n\tprotected async _addMetaResourceMimetype() {\n\t\tconst path = this._metaResourceMimetypePath;\n\t\tconst data = this._getMimetypeData();\n\t\tawait this._addResource(path, data, {}, true, true);\n\t}\n\n\t/**\n\t * Add meta resource for the application descriptor.\n\t *\n\t * @param applicationData The application descriptor data.\n\t */\n\tprotected async _addMetaResourceApplication(\n\t\tapplicationData: Readonly<Uint8Array>\n\t) {\n\t\tconst path = this._metaResourceApplicationPath;\n\t\tawait this._addResource(path, applicationData, {}, true, true);\n\t}\n\n\t/**\n\t * Add meta resource for the hash (needs updating on close).\n\t */\n\tprotected async _addMetaResourceHash() {\n\t\tconst path = this._metaResourceHashPath;\n\t\tconst data = new Uint8Array(this._hasher.bytes);\n\t\tawait this._addResource(path, data, {}, false, false);\n\t}\n\n\t/**\n\t * Add meta resource for debug.\n\t */\n\tprotected async _addMetaResourceDebug() {\n\t\tconst path = this._metaResourceDebugPath;\n\t\tconst data = new Uint8Array(0);\n\t\tawait this._addResource(path, data, {}, true, true);\n\t}\n\n\t/**\n\t * Add resource for signatures.\n\t */\n\tprotected async _addMetaResourceSignatures() {\n\t\tconst path = this._metaResourceSignaturesPath;\n\t\tconst signature = this._signature;\n\t\tif (!signature) {\n\t\t\tthrow new Error('Internal error');\n\t\t}\n\n\t\tsignature.digest();\n\t\tsignature.sign();\n\t\tif (signature.timestampUrl) {\n\t\t\tawait signature.timestamp();\n\t\t}\n\n\t\tconst data = signature.encode();\n\t\tawait this._addResource(path, data, {}, false, false);\n\t}\n\n\t/**\n\t * Init application info from descriptor data.\n\t *\n\t * @param applicationData The application descriptor data.\n\t */\n\tprotected _applicationInfoInit(applicationData: Readonly<Uint8Array>) {\n\t\t// Do nothing.\n\t}\n\n\t/**\n\t * Clear application info from descriptor data.\n\t */\n\tprotected _applicationInfoClear() {\n\t\t// Do nothing.\n\t}\n\n\t/**\n\t * Package mimetype.\n\t *\n\t * @returns Mimetype string.\n\t */\n\tpublic abstract get mimetype(): string;\n\n\t/**\n\t * Package signed.\n\t *\n\t * @returns Boolean for if package is signed or not.\n\t */\n\tpublic abstract get signed(): boolean;\n\n\t/**\n\t * Open implementation.\n\t */\n\tprotected abstract _open(): Promise<void>;\n\n\t/**\n\t * Close implementation.\n\t */\n\tprotected abstract _close(): Promise<void>;\n\n\t/**\n\t * Write resource with data implementation.\n\t *\n\t * @param destination Packaged file relative destination.\n\t * @param data Resource data.\n\t * @param options Resource options.\n\t */\n\tprotected abstract _writeResource(\n\t\tdestination: string,\n\t\tdata: Readonly<Uint8Array>,\n\t\toptions: Readonly<IPackagerResourceOptions>\n\t): Promise<void>;\n}\n"],"mappings":";;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AAEA,IAAAE,aAAA,GAAAF,OAAA;AAGA,IAAAG,UAAA,GAAAH,OAAA;AAEA,IAAAI,IAAA,GAAAJ,OAAA;AAEA;AACA;AACA;;AAaA;AACA;AACA;AACO,MAAeK,QAAQ,CAAC;EAC9B;AACD;AACA;EACQC,KAAK,GAAG,KAAK;;EAEpB;AACD;AACA;EACQC,QAAQ,GAAsC,IAAI;;EAEzD;AACD;AACA;EACQC,YAAY,GAAkB,IAAI;;EAEzC;AACD;AACA;EACQC,cAAc,GAKX,IAAI;;EAEd;AACD;AACA;EACQC,cAAc,GAAkB,IAAI;;EAE3C;AACD;AACA;EACQC,QAAQ,GAAG,CAAC,KAAK,EAAE,iBAAiB,EAAE,eAAe,CAAC;;EAE7D;AACD;AACA;EACQC,QAAQ,GAAG,KAAK;;EAEvB;AACD;AACA;;EAGC;AACD;AACA;EACWC,OAAO,GAAG,KAAK;;EAEzB;AACD;AACA;EACWC,iBAAiB,GAAG,KAAK;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