pack-crx 1.1.1 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/index.d.ts CHANGED
@@ -297,9 +297,7 @@ export interface PackInput {
297
297
  /** The extension's [manifest](https://developer.chrome.com/docs/extensions/reference/manifest). */
298
298
  manifest?: ChromeManifest | null;
299
299
  }
300
- type SetKeys<A extends object, B extends object> = {
301
- [x in keyof A | keyof B]: x extends keyof B ? unknown extends B[x] ? x extends keyof A ? A[x] : never : B[x] : x extends keyof A ? A[x] : never;
302
- };
300
+ type SetKeys<A extends object, B extends object> = Omit<A, keyof B> & B;
303
301
  export type TransformPack<I extends PackInput> = I["privateKey"] extends string ? TransformPack<SetKeys<I, {
304
302
  privateKey: Uint8Array | undefined;
305
303
  rsa: RSA;
@@ -3,9 +3,9 @@
3
3
  "sources": ["../src/crx3.pb.js", "../src/index.ts"],
4
4
  "sourcesContent": [
5
5
  "// CrxFileHeader ========================================\n\nexport var CrxFileHeader = {};\n\nCrxFileHeader.read = function (pbf, end) {\n return pbf.readFields(\n CrxFileHeader._readField,\n { sha256_with_rsa: [], sha256_with_ecdsa: [], signed_header_data: null },\n end,\n );\n};\nCrxFileHeader._readField = function (tag, obj, pbf) {\n if (tag === 2)\n obj.sha256_with_rsa.push(\n AsymmetricKeyProof.read(pbf, pbf.readVarint() + pbf.pos),\n );\n else if (tag === 3)\n obj.sha256_with_ecdsa.push(\n AsymmetricKeyProof.read(pbf, pbf.readVarint() + pbf.pos),\n );\n else if (tag === 10000) obj.signed_header_data = pbf.readBytes();\n};\nCrxFileHeader.write = function (obj, pbf) {\n if (obj.sha256_with_rsa)\n for (var i = 0; i < obj.sha256_with_rsa.length; i++)\n pbf.writeMessage(2, AsymmetricKeyProof.write, obj.sha256_with_rsa[i]);\n if (obj.sha256_with_ecdsa)\n for (i = 0; i < obj.sha256_with_ecdsa.length; i++)\n pbf.writeMessage(3, AsymmetricKeyProof.write, obj.sha256_with_ecdsa[i]);\n if (obj.signed_header_data)\n pbf.writeBytesField(10000, obj.signed_header_data);\n};\n\n// AsymmetricKeyProof ========================================\n\nexport var AsymmetricKeyProof = {};\n\nAsymmetricKeyProof.read = function (pbf, end) {\n return pbf.readFields(\n AsymmetricKeyProof._readField,\n { public_key: null, signature: null },\n end,\n );\n};\nAsymmetricKeyProof._readField = function (tag, obj, pbf) {\n if (tag === 1) obj.public_key = pbf.readBytes();\n else if (tag === 2) obj.signature = pbf.readBytes();\n};\nAsymmetricKeyProof.write = function (obj, pbf) {\n if (obj.public_key) pbf.writeBytesField(1, obj.public_key);\n if (obj.signature) pbf.writeBytesField(2, obj.signature);\n};\n\n// SignedData ========================================\n\nexport var SignedData = {};\n\nSignedData.read = function (pbf, end) {\n return pbf.readFields(SignedData._readField, { crx_id: null }, end);\n};\nSignedData._readField = function (tag, obj, pbf) {\n if (tag === 1) obj.crx_id = pbf.readBytes();\n};\nSignedData.write = function (obj, pbf) {\n if (obj.crx_id) pbf.writeBytesField(1, obj.crx_id);\n};\n",
6
- "import * as crx3 from \"./crx3.pb\";\nimport { createHash } from \"node:crypto\";\nimport Pbf from \"pbf\";\nimport JSZip from \"jszip\";\nimport fs from \"node:fs/promises\";\nimport { join, relative, resolve } from \"node:path\";\nimport { Buffer } from \"node:buffer\";\nimport RSA from \"node-rsa\";\n\ninterface ChromeBaseManifest {\n // Required keys\n manifest_version: number;\n name: string;\n version: string;\n\n // Required by Chrome Web Store\n description?: string;\n icons?: { [x: `${number}`]: string };\n\n // Optional\n author?: string;\n background?: {\n service_worker?: string;\n type?: \"module\";\n };\n chrome_settings_overrides?: {\n alternate_urls?: string[];\n encoding?: string;\n favicon_url?: string;\n homepage?: string;\n image_url?: string;\n image_url_post_params?: string;\n is_default?: boolean;\n keyword?: string;\n name?: string;\n prepopulated_id?: number;\n search_provider?: object;\n search_url?: string;\n search_url_post_params?: string;\n startup_pages?: string[];\n suggest_url?: string;\n suggest_url_post_params?: string;\n };\n chrome_url_overrides?: {\n bookmarks?: string;\n history?: string;\n newtab?: string;\n };\n commands?: {\n [x: string]: {\n description: string;\n suggested_key?: string;\n };\n };\n content_scripts?: {\n matches: string[];\n css?: string[];\n js?: string[];\n run_at?: \"document_start\" | \"document_end\" | \"document_idle\";\n match_about_blank?: boolean;\n match_origin_as_fallback?: boolean;\n world?: \"ISOLATED\" | \"MAIN\";\n }[];\n content_security_policy?: {\n extension_pages?: string;\n sandbox?: string;\n };\n cross_origin_embedder_policy?: string;\n cross_origin_opener_policy?: string;\n declarative_net_request?: {\n rule_resources?: {\n id: string;\n enabled: boolean;\n path: string;\n }[];\n };\n default_locale?: string;\n devtools_page?: string;\n export?: {\n allowlist?: string[];\n };\n externally_connectable?: {\n ids?: string[];\n matches?: string[];\n accepts_tls_channel_id?: boolean;\n };\n homepage_url?: string;\n host_permissions?: string[];\n import?: {\n id: string;\n minimum_version?: string;\n }[];\n incognito?: \"spanning\" | \"split\" | \"not_allowed\";\n key?: string;\n minimum_chrome_version?: string;\n oauth2?: {\n client_id: string;\n scopes: string[];\n };\n omnibox?: {\n keyword?: string;\n };\n optional_host_permissions?: string[];\n optional_permissions?: string[];\n options_page?: string;\n options_ui?: {\n page: string;\n open_in_tab?: boolean;\n };\n permissions?: string[];\n requirements?: {\n [x: string]: { features: string[] };\n };\n sandbox?: {\n pages: string[];\n };\n short_name?: string;\n side_panel?: string;\n storage?: {\n managed_schema?: string;\n };\n tts_engine?: {\n voices?: {\n voice_name: string;\n lang?: string;\n event_types?: (\n | \"start\"\n | \"word\"\n | \"sentence\"\n | \"marker\"\n | \"end\"\n | \"error\"\n )[];\n }[];\n };\n update_url?: string;\n version_name?: string;\n web_accessible_resources?: ({\n resources: string[];\n } & (\n | {\n matches: string[];\n }\n | {\n extension_ids: string[];\n }\n ))[];\n\n // ChromeOS\n file_browser_handlers?: {\n id: string;\n default_title: string;\n file_filters: string[];\n }[];\n file_handlers?: {\n action: string;\n name: string;\n accept: {\n [x: string]: string[];\n };\n launch_type?: \"single-client\" | \"multiple-clients\";\n }[];\n file_system_provider_capabilities?: {\n configurable?: boolean;\n multiple_mounts?: boolean;\n watchable?: boolean;\n source: \"file\" | \"device\" | \"network\";\n };\n input_components?: {\n name: string;\n id?: string;\n language?: string | string[];\n layouts?: string | string[];\n input_view?: string;\n options_page?: string;\n }[];\n}\n\nexport type ChromeMV2Manifest = ChromeBaseManifest & {\n manifest_version: 2;\n browser_action?: {\n default_icon?: { [x: `${number}`]: string };\n default_title?: string;\n default_popup?: string;\n };\n page_action?: {\n default_icon?: { [x: `${number}`]: string };\n default_title?: string;\n default_popup?: string;\n };\n};\n\nexport type ChromeMV3Manifest = ChromeBaseManifest & {\n manifest_version: 3;\n action?: {\n default_icon?: { [x: `${number}`]: string };\n default_title?: string;\n default_popup?: string;\n };\n};\n\nexport type ChromeManifest = ChromeMV2Manifest | ChromeMV3Manifest;\n\nexport interface CrxFileHeader {\n sha256_with_rsa?: AsymmetricKeyProof[];\n sha256_with_ecdsa?: AsymmetricKeyProof[];\n signed_header_data?: Uint8Array;\n}\n\nexport interface AsymmetricKeyProof {\n public_key?: Uint8Array;\n signature?: Uint8Array;\n}\n\n/**\n * CRX IDs are 16 bytes long\n * @constant\n */\nconst CRX_ID_SIZE = 16;\n\n/**\n * CRX3 uses 32bit numbers in various places,\n * so let's prepare size constant for that.\n * @constant\n */\nconst SIZE_BYTES = 4;\n\n/**\n * Used for file format.\n * @see {@link https://github.com/chromium/chromium/blob/master/components/crx_file/crx3.proto}\n * @constant\n */\nconst kSignature = Uint8Array.from(\"Cr24\", (ch) => ch.charCodeAt(0));\n\n/**\n * Used for file format.\n * @see {@link https://github.com/chromium/chromium/blob/master/components/crx_file/crx3.proto}\n * @constant\n */\nconst kVersion = Uint8Array.from([3, 0, 0, 0]);\n\n/**\n * Used for generating package signatures.\n * @see {@link https://github.com/chromium/chromium/blob/master/components/crx_file/crx3.proto}\n * @constant\n */\nconst kSignatureContext = Uint8Array.from(\"CRX3 SignedData\\x00\", (ch) =>\n ch.charCodeAt(0),\n);\n\n/**\n * Pack a CRX2 extension. Chrome stopped supporting these entirely in version 73.0.3683, which released in October of 2017.\n *\n * @param privateKey The extension's private key.\n * @param publicKey The extension's public key.\n * @param contents The zipped contents of the extension. This should contain a `manifest.json` file directly inside it, but we don't validate that in this function.\n *\n * @returns The contents of the packaged extension.\n *\n * @deprecated\n */\nexport function packCrx2(\n privateKey: Uint8Array,\n publicKey: Uint8Array,\n contents: Uint8Array,\n rsa?: RSA,\n): Uint8Array {\n rsa ??= new RSA(Buffer.from(privateKey), \"pkcs8-private-der\");\n rsa.setOptions({ signingScheme: \"pkcs1-sha1\" });\n const signature = rsa.sign(contents);\n const length =\n 16 /* magic + version + key length + sign length */ +\n publicKey.length +\n signature.length;\n const result = new Uint8Array(length);\n result.set(kSignature, 0);\n const dv = new DataView(result.buffer);\n dv.setUint32(4, 2, true);\n dv.setUint32(8, publicKey.length, true);\n dv.setUint32(12, signature.length, true);\n result.set(publicKey, 16);\n result.set(signature, 16 + publicKey.length);\n result.set(contents, length);\n return result;\n}\n\n/**\n * Pack a CRX3 extension.\n *\n * @param privateKey The extension's private key.\n * @param publicKey The extension's public key.\n * @param contents The zipped contents of the extension. This should contain a `manifest.json` file directly inside it, but we don't validate that in this function.\n *\n * @returns The contents of the packaged extension.\n */\nexport function packCrx3(\n privateKey: Uint8Array,\n publicKey: Uint8Array,\n contents: Uint8Array,\n rsa?: RSA,\n): Uint8Array {\n let pb = new Pbf();\n crx3.SignedData.write(\n {\n crx_id: generateBinaryCrxId(publicKey),\n },\n pb,\n );\n const signedHeaderData = pb.finish();\n\n const signature = generateCrx3Signature(\n privateKey,\n signedHeaderData,\n contents,\n rsa,\n );\n\n pb = new Pbf();\n crx3.CrxFileHeader.write(\n {\n sha256_with_rsa: [\n {\n public_key: publicKey satisfies Uint8Array,\n signature,\n },\n ],\n signed_header_data: signedHeaderData,\n } as CrxFileHeader,\n pb,\n );\n const header = pb.finish();\n\n const size =\n kSignature.length + // Magic constant\n kVersion.length + // Version number\n SIZE_BYTES + // Header size\n header.length +\n contents.length;\n\n const result = new Uint8Array(size);\n\n let index = 0;\n result.set(kSignature, index);\n result.set(kVersion, (index += kSignature.length));\n new DataView(result.buffer).setUint32(\n (index += kVersion.length),\n header.length,\n true,\n );\n result.set(header, (index += SIZE_BYTES));\n result.set(contents, (index += header.length));\n\n return result;\n}\n\nfunction generateBinaryCrxId(publicKey: Uint8Array): Uint8Array {\n var hash = createHash(\"sha256\");\n hash.update(publicKey);\n return Uint8Array.from(hash.digest()).slice(0, CRX_ID_SIZE);\n}\n\nfunction generateCrx3Signature(\n privateKey: Uint8Array,\n signedHeaderData: Uint8Array,\n contents: Uint8Array,\n rsa?: RSA,\n): Uint8Array {\n rsa ??= new RSA(Buffer.from(privateKey), \"pkcs8-private-der\");\n rsa.setOptions({ signingScheme: \"pkcs1-sha256\" });\n\n // Size of signed_header_data\n const sizeOctets = new DataView(new ArrayBuffer(SIZE_BYTES));\n sizeOctets.setUint32(0, signedHeaderData.length, true);\n\n const toSign = Buffer.concat([\n kSignatureContext,\n new Uint8Array(sizeOctets.buffer),\n signedHeaderData,\n contents,\n ]);\n\n return Uint8Array.from(rsa.sign(toSign));\n}\n\n/**\n * Generate an extension's ID (32 characters, a-p) from its public key.\n *\n * @param publicKey The public key of the extension.\n *\n * @returns The generated extension ID.\n */\nexport function generateCrxId(publicKey: Uint8Array): string {\n return createHash(\"sha256\")\n .update(publicKey)\n .digest()\n .toString(\"hex\")\n .split(\"\")\n .map((x) => (parseInt(x, 16) + 0x0a).toString(26))\n .join(\"\")\n .slice(0, 32);\n}\n\n/**\n * Load a directory from the filesystem into a ZIP archive, using the node:fs API.\n *\n * @param where The path to the directory.\n */\nexport async function packContents(where: string): Promise<{\n /** The ZIP-encoded data. */\n contents: Uint8Array;\n /** The manifest for the extension, parsed as JSON. */\n manifest: ChromeManifest;\n}> {\n const zip = new JSZip();\n let manifest: Promise<Uint8Array> | undefined;\n async function f(loc: string) {\n for (const entry of await fs.readdir(loc, { withFileTypes: true })) {\n const fp = join(loc, entry.name);\n if (entry.isDirectory()) {\n await f(fp);\n } else {\n const contents = fs.readFile(fp).then((buf) => Uint8Array.from(buf));\n const rp = relative(where, fp);\n if (rp == \"manifest.json\") manifest ??= contents;\n zip.file(rp, contents);\n }\n }\n }\n await f(resolve(process.cwd(), where));\n if (manifest == undefined) throw new Error(\"Manifest file not found\");\n return {\n contents: await zip.generateAsync({\n compression: \"DEFLATE\",\n type: \"uint8array\",\n }),\n manifest: JSON.parse(new TextDecoder().decode(await manifest)),\n };\n}\n\n/**\n * Generate the updates XML file for [serving an extension yourself](https://developer.chrome.com/docs/extensions/how-to/distribute/host-on-linux).\n *\n * @param crxId The extension's ID.\n * @param url The URL where the extension's CRX file will be hosted.\n * @param version The extension's version.\n * @param minChromeVersion The minimum Chrome version that the extension can be installed on.\n *\n * @returns The updates XML text\n */\nexport function generateUpdateXML(\n crxId: string,\n url: string,\n version: string,\n minChromeVersion?: string,\n): string {\n return `<?xml version='1.0' encoding='UTF-8'?>\n<gupdate xmlns='http://www.google.com/update2/response' protocol='2.0'>\n <app appid='${crxId}'>\n <updatecheck codebase='${url}' version='${version}'${minChromeVersion ? ` prodversionmin='${minChromeVersion}'` : \"\"} />\n </app>\n</gupdate>`;\n}\n\nexport function generatePrivateKey(bits = 4096): Uint8Array {\n return Uint8Array.from(new RSA({ b: bits }).exportKey(\"pkcs8-private-der\"));\n}\n\nexport function generatePublicKey(privateKey: Uint8Array): Uint8Array {\n return Uint8Array.from(\n new RSA(Buffer.from(privateKey), \"pkcs8-private-der\").exportKey(\n \"pkcs8-public-der\",\n ),\n );\n}\n\nexport function convertToPem(\n key: Uint8Array,\n type: \"private\" | \"public\",\n): string {\n return new RSA(Buffer.from(key), `pkcs8-${type}-der`).exportKey(\n `pkcs8-${type}-pem`,\n );\n}\n\nexport function convertFromPem(\n key: string,\n type: \"private\" | \"public\",\n): Uint8Array {\n return Uint8Array.from(\n new RSA(key, `pkcs8-${type}-pem`).exportKey(`pkcs8-${type}-der`),\n );\n}\n\n/**\n * Unpack a CRX file and extract its contents as ZIP data.\n *\n * @param crx The CRX to be unpacked.\n */\nexport function unpack(crx: Uint8Array):\n | {\n /** The ZIP data. */\n archive: Uint8Array;\n /** The CRX format version. */\n crxVersion: 2;\n /** The extension's public key. */\n key: Uint8Array;\n /** The signature over the contents of the extension. */\n sign: Uint8Array;\n }\n | {\n /** The ZIP data. */\n archive: Uint8Array;\n /** The CRX format version. */\n crxVersion: 3;\n /** The header for the CRX file, for signatures and things. */\n header: CrxFileHeader;\n } {\n const abuf = crx.buffer;\n const dv = new DataView(abuf);\n if (kSignature.every((v, i) => dv.getUint8(i) == v)) {\n const crxVersion = dv.getUint32(4, true);\n if (crxVersion == 2) {\n const keyLength = dv.getUint32(8, true);\n const signLength = dv.getUint32(12, true);\n return {\n archive: crx.slice(16 + keyLength + signLength),\n crxVersion: 2,\n key: crx.slice(16, 16 + keyLength),\n sign: crx.slice(16 + keyLength, 16 + keyLength + signLength),\n };\n } else if (crxVersion == 3) {\n const headerLength = dv.getUint32(8, true);\n const archive = crx.slice(12 + headerLength);\n const header = crx.slice(12, 12 + headerLength);\n const pb = new Pbf(header);\n const decodedHeader = crx3.CrxFileHeader.read(pb);\n return { archive, crxVersion: 3, header: decodedHeader };\n }\n }\n throw new Error(\"The file given is not a valid CRX file\");\n}\n\nexport interface PackInput {\n /** The ZIP archive of the contents of the extension, or a path to the folder containing the extension. */\n contents?: Uint8Array | string;\n /** The private key for the extension, or a path to it. */\n privateKey?: Uint8Array | string | null;\n /** The size of key to generate, if needed. */\n keySize?: number;\n /** The public key for the extension, or a path to it. */\n publicKey?: Uint8Array | string | null;\n /** The instance of NodeRSA to use. */\n rsa?: RSA;\n /** The extension's ID. */\n id?: string | null;\n /** The outputted CRX file. */\n crx?: Uint8Array | null;\n /** The CRX format version to use. Defaults to 3. */\n crxVersion?: number;\n /** The URL to where the CRX file (not the updates XML) will be hosted. */\n crxUrl?: string;\n /** The [updates XML file](https://developer.chrome.com/docs/extensions/how-to/distribute/host-on-linux). */\n updateXML?: string | null;\n /** The extension's version. */\n extVersion?: string | null;\n /** The minimum Chrome version the extension requires. */\n minChromeVersion?: string | null;\n /** The extension's [manifest](https://developer.chrome.com/docs/extensions/reference/manifest). */\n manifest?: ChromeManifest | null;\n}\n\ntype SetKeys<A extends object, B extends object> = {\n [x in keyof A | keyof B]: x extends keyof B\n ? unknown extends B[x]\n ? x extends keyof A\n ? A[x]\n : never\n : B[x]\n : x extends keyof A\n ? A[x]\n : never;\n};\n\nexport type TransformPack<I extends PackInput> = I[\"privateKey\"] extends string\n ? TransformPack<\n SetKeys<\n I,\n {\n privateKey: Uint8Array | undefined;\n rsa: RSA;\n }\n >\n >\n : I[\"publicKey\"] extends string\n ? TransformPack<\n SetKeys<\n I,\n {\n publicKey: Uint8Array | undefined;\n }\n >\n >\n : I[\"updateXML\"] extends null\n ? undefined extends I[\"crxUrl\"]\n ? never\n : TransformPack<\n SetKeys<\n I,\n {\n updateXML: string;\n id: undefined extends I[\"id\"] ? null : I[\"id\"];\n extVersion: undefined extends I[\"extVersion\"]\n ? null\n : I[\"extVersion\"];\n minChromeVersion: undefined extends I[\"minChromeVersion\"]\n ? null\n : I[\"minChromeVersion\"];\n }\n >\n >\n : I[\"extVersion\"] extends null\n ? TransformPack<\n SetKeys<\n I,\n {\n extVersion: string;\n manifest: undefined extends I[\"manifest\"]\n ? null\n : I[\"manifest\"];\n }\n >\n >\n : I[\"minChromeVersion\"] extends null\n ? TransformPack<\n SetKeys<\n I,\n {\n minChromeVersion: string | undefined;\n manifest: undefined extends I[\"manifest\"]\n ? null\n : I[\"manifest\"];\n }\n >\n >\n : I[\"manifest\"] extends null\n ? undefined extends I[\"contents\"]\n ? never\n : Uint8Array extends I[\"contents\"]\n ? never\n : TransformPack<\n SetKeys<\n I,\n {\n manifest: ChromeManifest;\n }\n >\n >\n : I[\"crx\"] extends null\n ? undefined extends I[\"contents\"]\n ? never\n : TransformPack<\n SetKeys<\n I,\n {\n crx: Uint8Array;\n privateKey: undefined extends I[\"privateKey\"]\n ? null\n : I[\"privateKey\"];\n publicKey: undefined extends I[\"publicKey\"]\n ? null\n : I[\"publicKey\"];\n }\n >\n >\n : I[\"id\"] extends null\n ? TransformPack<\n SetKeys<\n I,\n {\n id: string;\n publicKey: undefined extends I[\"publicKey\"]\n ? null\n : I[\"publicKey\"];\n }\n >\n >\n : I[\"publicKey\"] extends null\n ? TransformPack<\n SetKeys<\n I,\n {\n publicKey: Uint8Array;\n privateKey: undefined extends I[\"privateKey\"]\n ? null\n : I[\"privateKey\"];\n }\n >\n >\n : I[\"privateKey\"] extends null\n ? TransformPack<\n SetKeys<\n I,\n {\n privateKey: Uint8Array;\n rsa: RSA;\n }\n >\n >\n : I[\"contents\"] extends string\n ? TransformPack<\n SetKeys<\n I,\n {\n contents: Uint8Array;\n manifest: ChromeManifest;\n }\n >\n >\n : I;\n\n/**\n * Use the entirety of this API in one function.\n *\n * @param options An object containing input parameters.\n *\n * If `null` is given for a property, then the function will generate a value for it based on the other properties.\n *\n * If a property requires another but that property is not requested (with `null`), then it is generated and given anyways.\n *\n * If `privateKey` or `publicKey` are strings, `pack` will load the file at each path as a key. If the extension is `.pem`, they are loaded as pkcs8-pem and converted to pkcs8-der.\n *\n * `pack` always returns a `Promise`, even if all of the operations inside are synchronous.\n *\n * However, the return result is the same object as the input - just with the properties modified - so if you *really* want synchronous operations, you can keep a reference to the input object, call the function, and access the synchronous results from that object. Just make sure you don't set `privateKey` or `manifest` to `null` or `contents` to a string, otherwise some of your values might not arrive synchronously.\n */\nexport async function pack<I extends PackInput>(\n options: I,\n): Promise<TransformPack<I>> {\n if (typeof options.privateKey == \"string\") {\n try {\n const isPem = options.privateKey.endsWith(\".pem\");\n const contents = await fs.readFile(options.privateKey);\n if (isPem)\n options.privateKey = Uint8Array.from(\n (options.rsa ??= new RSA(contents, \"pkcs8-private-pem\")).exportKey(\n \"pkcs8-private-der\",\n ),\n );\n else options.privateKey = Uint8Array.from(contents);\n } catch (e) {\n if (!`${e}`.includes(\"ENOENT\")) throw e;\n options.privateKey = undefined;\n }\n }\n if (typeof options.publicKey == \"string\") {\n try {\n const isPem = options.publicKey.endsWith(\".pem\");\n const contents = await fs.readFile(options.publicKey);\n if (isPem)\n options.publicKey = Uint8Array.from(\n new RSA(contents, \"pkcs8-public-pem\").exportKey(\"pkcs8-public-der\"),\n );\n else options.publicKey = Uint8Array.from(contents);\n } catch (e) {\n if (!`${e}`.includes(\"ENOENT\")) throw e;\n options.publicKey = undefined;\n }\n }\n if (options.updateXML === null) {\n if (options.crxUrl === undefined)\n throw new Error(\"crxUrl must be defined to generate updateXML\");\n if (options.id === undefined) options.id = null;\n if (options.extVersion === undefined) options.extVersion = null;\n if (options.minChromeVersion === undefined) options.minChromeVersion = null;\n }\n if (options.extVersion === null) {\n if (options.manifest === undefined) options.manifest = null;\n }\n if (options.minChromeVersion === null) {\n if (options.manifest === undefined) options.manifest = null;\n }\n if (options.crx === null) {\n if (options.contents === undefined)\n throw new Error(\"contents must be defined to generate crx\");\n if (options.privateKey === undefined) options.privateKey = null;\n if (options.publicKey === undefined) options.publicKey = null;\n }\n if (options.id === null) {\n if (options.publicKey === undefined) options.publicKey = null;\n }\n if (options.publicKey === null) {\n if (options.privateKey === undefined) options.privateKey = null;\n }\n\n if (options.privateKey === null) {\n options.rsa ??= new RSA({ b: options.keySize || 4096 });\n options.privateKey = Uint8Array.from(\n options.rsa.exportKey(\"pkcs8-private-der\"),\n );\n options.publicKey = Uint8Array.from(\n options.rsa.exportKey(\"pkcs8-public-der\"),\n );\n }\n if (options.publicKey === null) {\n options.publicKey = Uint8Array.from(\n (options.rsa ??= new RSA(\n Buffer.from(options.privateKey!),\n \"pkcs8-private-der\",\n )).exportKey(\"pkcs8-public-der\"),\n );\n }\n if (typeof options.contents == \"string\") {\n ({ contents: options.contents, manifest: options.manifest } =\n await packContents(options.contents));\n }\n if (options.crx === null) {\n if (options.crxVersion == 3 || options.crxVersion == undefined)\n options.crx = packCrx3(\n options.privateKey!,\n options.publicKey!,\n options.contents!,\n options.rsa,\n );\n else if (options.crxVersion == 2)\n options.crx = packCrx2(\n options.privateKey!,\n options.publicKey!,\n options.contents!,\n options.rsa,\n );\n }\n if (options.id === null) {\n options.id = generateCrxId(options.publicKey!);\n }\n if (options.extVersion === null) {\n if (!options.manifest)\n throw new Error(\"manifest must be defined to generate extVersion\");\n options.extVersion = options.manifest.version;\n }\n if (options.minChromeVersion === null) {\n options.minChromeVersion =\n options.manifest?.minimum_chrome_version ||\n (options.crxVersion == 3 || options.crxVersion == undefined\n ? \"73.0.3683\"\n : undefined);\n }\n if (options.updateXML === null) {\n options.updateXML = generateUpdateXML(\n options.id!,\n options.crxUrl!,\n options.extVersion!,\n options.minChromeVersion,\n );\n }\n return options as any;\n}\n\nexport default pack;\n"
6
+ "import * as crx3 from \"./crx3.pb\";\nimport { createHash } from \"node:crypto\";\nimport Pbf from \"pbf\";\nimport JSZip from \"jszip\";\nimport fs from \"node:fs/promises\";\nimport { join, relative, resolve } from \"node:path\";\nimport { Buffer } from \"node:buffer\";\nimport RSA from \"node-rsa\";\n\ninterface ChromeBaseManifest {\n // Required keys\n manifest_version: number;\n name: string;\n version: string;\n\n // Required by Chrome Web Store\n description?: string;\n icons?: { [x: `${number}`]: string };\n\n // Optional\n author?: string;\n background?: {\n service_worker?: string;\n type?: \"module\";\n };\n chrome_settings_overrides?: {\n alternate_urls?: string[];\n encoding?: string;\n favicon_url?: string;\n homepage?: string;\n image_url?: string;\n image_url_post_params?: string;\n is_default?: boolean;\n keyword?: string;\n name?: string;\n prepopulated_id?: number;\n search_provider?: object;\n search_url?: string;\n search_url_post_params?: string;\n startup_pages?: string[];\n suggest_url?: string;\n suggest_url_post_params?: string;\n };\n chrome_url_overrides?: {\n bookmarks?: string;\n history?: string;\n newtab?: string;\n };\n commands?: {\n [x: string]: {\n description: string;\n suggested_key?: string;\n };\n };\n content_scripts?: {\n matches: string[];\n css?: string[];\n js?: string[];\n run_at?: \"document_start\" | \"document_end\" | \"document_idle\";\n match_about_blank?: boolean;\n match_origin_as_fallback?: boolean;\n world?: \"ISOLATED\" | \"MAIN\";\n }[];\n content_security_policy?: {\n extension_pages?: string;\n sandbox?: string;\n };\n cross_origin_embedder_policy?: string;\n cross_origin_opener_policy?: string;\n declarative_net_request?: {\n rule_resources?: {\n id: string;\n enabled: boolean;\n path: string;\n }[];\n };\n default_locale?: string;\n devtools_page?: string;\n export?: {\n allowlist?: string[];\n };\n externally_connectable?: {\n ids?: string[];\n matches?: string[];\n accepts_tls_channel_id?: boolean;\n };\n homepage_url?: string;\n host_permissions?: string[];\n import?: {\n id: string;\n minimum_version?: string;\n }[];\n incognito?: \"spanning\" | \"split\" | \"not_allowed\";\n key?: string;\n minimum_chrome_version?: string;\n oauth2?: {\n client_id: string;\n scopes: string[];\n };\n omnibox?: {\n keyword?: string;\n };\n optional_host_permissions?: string[];\n optional_permissions?: string[];\n options_page?: string;\n options_ui?: {\n page: string;\n open_in_tab?: boolean;\n };\n permissions?: string[];\n requirements?: {\n [x: string]: { features: string[] };\n };\n sandbox?: {\n pages: string[];\n };\n short_name?: string;\n side_panel?: string;\n storage?: {\n managed_schema?: string;\n };\n tts_engine?: {\n voices?: {\n voice_name: string;\n lang?: string;\n event_types?: (\n | \"start\"\n | \"word\"\n | \"sentence\"\n | \"marker\"\n | \"end\"\n | \"error\"\n )[];\n }[];\n };\n update_url?: string;\n version_name?: string;\n web_accessible_resources?: ({\n resources: string[];\n } & (\n | {\n matches: string[];\n }\n | {\n extension_ids: string[];\n }\n ))[];\n\n // ChromeOS\n file_browser_handlers?: {\n id: string;\n default_title: string;\n file_filters: string[];\n }[];\n file_handlers?: {\n action: string;\n name: string;\n accept: {\n [x: string]: string[];\n };\n launch_type?: \"single-client\" | \"multiple-clients\";\n }[];\n file_system_provider_capabilities?: {\n configurable?: boolean;\n multiple_mounts?: boolean;\n watchable?: boolean;\n source: \"file\" | \"device\" | \"network\";\n };\n input_components?: {\n name: string;\n id?: string;\n language?: string | string[];\n layouts?: string | string[];\n input_view?: string;\n options_page?: string;\n }[];\n}\n\nexport type ChromeMV2Manifest = ChromeBaseManifest & {\n manifest_version: 2;\n browser_action?: {\n default_icon?: { [x: `${number}`]: string };\n default_title?: string;\n default_popup?: string;\n };\n page_action?: {\n default_icon?: { [x: `${number}`]: string };\n default_title?: string;\n default_popup?: string;\n };\n};\n\nexport type ChromeMV3Manifest = ChromeBaseManifest & {\n manifest_version: 3;\n action?: {\n default_icon?: { [x: `${number}`]: string };\n default_title?: string;\n default_popup?: string;\n };\n};\n\nexport type ChromeManifest = ChromeMV2Manifest | ChromeMV3Manifest;\n\nexport interface CrxFileHeader {\n sha256_with_rsa?: AsymmetricKeyProof[];\n sha256_with_ecdsa?: AsymmetricKeyProof[];\n signed_header_data?: Uint8Array;\n}\n\nexport interface AsymmetricKeyProof {\n public_key?: Uint8Array;\n signature?: Uint8Array;\n}\n\n/**\n * CRX IDs are 16 bytes long\n * @constant\n */\nconst CRX_ID_SIZE = 16;\n\n/**\n * CRX3 uses 32bit numbers in various places,\n * so let's prepare size constant for that.\n * @constant\n */\nconst SIZE_BYTES = 4;\n\n/**\n * Used for file format.\n * @see {@link https://github.com/chromium/chromium/blob/master/components/crx_file/crx3.proto}\n * @constant\n */\nconst kSignature = Uint8Array.from(\"Cr24\", (ch) => ch.charCodeAt(0));\n\n/**\n * Used for file format.\n * @see {@link https://github.com/chromium/chromium/blob/master/components/crx_file/crx3.proto}\n * @constant\n */\nconst kVersion = Uint8Array.from([3, 0, 0, 0]);\n\n/**\n * Used for generating package signatures.\n * @see {@link https://github.com/chromium/chromium/blob/master/components/crx_file/crx3.proto}\n * @constant\n */\nconst kSignatureContext = Uint8Array.from(\"CRX3 SignedData\\x00\", (ch) =>\n ch.charCodeAt(0),\n);\n\n/**\n * Pack a CRX2 extension. Chrome stopped supporting these entirely in version 73.0.3683, which released in October of 2017.\n *\n * @param privateKey The extension's private key.\n * @param publicKey The extension's public key.\n * @param contents The zipped contents of the extension. This should contain a `manifest.json` file directly inside it, but we don't validate that in this function.\n *\n * @returns The contents of the packaged extension.\n *\n * @deprecated\n */\nexport function packCrx2(\n privateKey: Uint8Array,\n publicKey: Uint8Array,\n contents: Uint8Array,\n rsa?: RSA,\n): Uint8Array {\n rsa ??= new RSA(Buffer.from(privateKey), \"pkcs8-private-der\");\n rsa.setOptions({ signingScheme: \"pkcs1-sha1\" });\n const signature = rsa.sign(contents);\n const length =\n 16 /* magic + version + key length + sign length */ +\n publicKey.length +\n signature.length;\n const result = new Uint8Array(length);\n result.set(kSignature, 0);\n const dv = new DataView(result.buffer);\n dv.setUint32(4, 2, true);\n dv.setUint32(8, publicKey.length, true);\n dv.setUint32(12, signature.length, true);\n result.set(publicKey, 16);\n result.set(signature, 16 + publicKey.length);\n result.set(contents, length);\n return result;\n}\n\n/**\n * Pack a CRX3 extension.\n *\n * @param privateKey The extension's private key.\n * @param publicKey The extension's public key.\n * @param contents The zipped contents of the extension. This should contain a `manifest.json` file directly inside it, but we don't validate that in this function.\n *\n * @returns The contents of the packaged extension.\n */\nexport function packCrx3(\n privateKey: Uint8Array,\n publicKey: Uint8Array,\n contents: Uint8Array,\n rsa?: RSA,\n): Uint8Array {\n let pb = new Pbf();\n crx3.SignedData.write(\n {\n crx_id: generateBinaryCrxId(publicKey),\n },\n pb,\n );\n const signedHeaderData = pb.finish();\n\n const signature = generateCrx3Signature(\n privateKey,\n signedHeaderData,\n contents,\n rsa,\n );\n\n pb = new Pbf();\n crx3.CrxFileHeader.write(\n {\n sha256_with_rsa: [\n {\n public_key: publicKey satisfies Uint8Array,\n signature,\n },\n ],\n signed_header_data: signedHeaderData,\n } as CrxFileHeader,\n pb,\n );\n const header = pb.finish();\n\n const size =\n kSignature.length + // Magic constant\n kVersion.length + // Version number\n SIZE_BYTES + // Header size\n header.length +\n contents.length;\n\n const result = new Uint8Array(size);\n\n let index = 0;\n result.set(kSignature, index);\n result.set(kVersion, (index += kSignature.length));\n new DataView(result.buffer).setUint32(\n (index += kVersion.length),\n header.length,\n true,\n );\n result.set(header, (index += SIZE_BYTES));\n result.set(contents, (index += header.length));\n\n return result;\n}\n\nfunction generateBinaryCrxId(publicKey: Uint8Array): Uint8Array {\n var hash = createHash(\"sha256\");\n hash.update(publicKey);\n return Uint8Array.from(hash.digest()).slice(0, CRX_ID_SIZE);\n}\n\nfunction generateCrx3Signature(\n privateKey: Uint8Array,\n signedHeaderData: Uint8Array,\n contents: Uint8Array,\n rsa?: RSA,\n): Uint8Array {\n rsa ??= new RSA(Buffer.from(privateKey), \"pkcs8-private-der\");\n rsa.setOptions({ signingScheme: \"pkcs1-sha256\" });\n\n // Size of signed_header_data\n const sizeOctets = new DataView(new ArrayBuffer(SIZE_BYTES));\n sizeOctets.setUint32(0, signedHeaderData.length, true);\n\n const toSign = Buffer.concat([\n kSignatureContext,\n new Uint8Array(sizeOctets.buffer),\n signedHeaderData,\n contents,\n ]);\n\n return Uint8Array.from(rsa.sign(toSign));\n}\n\n/**\n * Generate an extension's ID (32 characters, a-p) from its public key.\n *\n * @param publicKey The public key of the extension.\n *\n * @returns The generated extension ID.\n */\nexport function generateCrxId(publicKey: Uint8Array): string {\n return createHash(\"sha256\")\n .update(publicKey)\n .digest()\n .toString(\"hex\")\n .split(\"\")\n .map((x) => (parseInt(x, 16) + 0x0a).toString(26))\n .join(\"\")\n .slice(0, 32);\n}\n\n/**\n * Load a directory from the filesystem into a ZIP archive, using the node:fs API.\n *\n * @param where The path to the directory.\n */\nexport async function packContents(where: string): Promise<{\n /** The ZIP-encoded data. */\n contents: Uint8Array;\n /** The manifest for the extension, parsed as JSON. */\n manifest: ChromeManifest;\n}> {\n const zip = new JSZip();\n let manifest: Promise<Uint8Array> | undefined;\n async function f(loc: string) {\n for (const entry of await fs.readdir(loc, { withFileTypes: true })) {\n const fp = join(loc, entry.name);\n if (entry.isDirectory()) {\n await f(fp);\n } else {\n const contents = fs.readFile(fp).then((buf) => Uint8Array.from(buf));\n const rp = relative(where, fp);\n if (rp == \"manifest.json\") manifest ??= contents;\n zip.file(rp, contents);\n }\n }\n }\n await f(resolve(process.cwd(), where));\n if (manifest == undefined) throw new Error(\"Manifest file not found\");\n return {\n contents: await zip.generateAsync({\n compression: \"DEFLATE\",\n type: \"uint8array\",\n }),\n manifest: JSON.parse(new TextDecoder().decode(await manifest)),\n };\n}\n\n/**\n * Generate the updates XML file for [serving an extension yourself](https://developer.chrome.com/docs/extensions/how-to/distribute/host-on-linux).\n *\n * @param crxId The extension's ID.\n * @param url The URL where the extension's CRX file will be hosted.\n * @param version The extension's version.\n * @param minChromeVersion The minimum Chrome version that the extension can be installed on.\n *\n * @returns The updates XML text\n */\nexport function generateUpdateXML(\n crxId: string,\n url: string,\n version: string,\n minChromeVersion?: string,\n): string {\n return `<?xml version='1.0' encoding='UTF-8'?>\n<gupdate xmlns='http://www.google.com/update2/response' protocol='2.0'>\n <app appid='${crxId}'>\n <updatecheck codebase='${url}' version='${version}'${minChromeVersion ? ` prodversionmin='${minChromeVersion}'` : \"\"} />\n </app>\n</gupdate>`;\n}\n\nexport function generatePrivateKey(bits = 4096): Uint8Array {\n return Uint8Array.from(new RSA({ b: bits }).exportKey(\"pkcs8-private-der\"));\n}\n\nexport function generatePublicKey(privateKey: Uint8Array): Uint8Array {\n return Uint8Array.from(\n new RSA(Buffer.from(privateKey), \"pkcs8-private-der\").exportKey(\n \"pkcs8-public-der\",\n ),\n );\n}\n\nexport function convertToPem(\n key: Uint8Array,\n type: \"private\" | \"public\",\n): string {\n return new RSA(Buffer.from(key), `pkcs8-${type}-der`).exportKey(\n `pkcs8-${type}-pem`,\n );\n}\n\nexport function convertFromPem(\n key: string,\n type: \"private\" | \"public\",\n): Uint8Array {\n return Uint8Array.from(\n new RSA(key, `pkcs8-${type}-pem`).exportKey(`pkcs8-${type}-der`),\n );\n}\n\n/**\n * Unpack a CRX file and extract its contents as ZIP data.\n *\n * @param crx The CRX to be unpacked.\n */\nexport function unpack(crx: Uint8Array):\n | {\n /** The ZIP data. */\n archive: Uint8Array;\n /** The CRX format version. */\n crxVersion: 2;\n /** The extension's public key. */\n key: Uint8Array;\n /** The signature over the contents of the extension. */\n sign: Uint8Array;\n }\n | {\n /** The ZIP data. */\n archive: Uint8Array;\n /** The CRX format version. */\n crxVersion: 3;\n /** The header for the CRX file, for signatures and things. */\n header: CrxFileHeader;\n } {\n const abuf = crx.buffer;\n const dv = new DataView(abuf);\n if (kSignature.every((v, i) => dv.getUint8(i) == v)) {\n const crxVersion = dv.getUint32(4, true);\n if (crxVersion == 2) {\n const keyLength = dv.getUint32(8, true);\n const signLength = dv.getUint32(12, true);\n return {\n archive: crx.slice(16 + keyLength + signLength),\n crxVersion: 2,\n key: crx.slice(16, 16 + keyLength),\n sign: crx.slice(16 + keyLength, 16 + keyLength + signLength),\n };\n } else if (crxVersion == 3) {\n const headerLength = dv.getUint32(8, true);\n const archive = crx.slice(12 + headerLength);\n const header = crx.slice(12, 12 + headerLength);\n const pb = new Pbf(header);\n const decodedHeader = crx3.CrxFileHeader.read(pb);\n return { archive, crxVersion: 3, header: decodedHeader };\n }\n }\n throw new Error(\"The file given is not a valid CRX file\");\n}\n\nexport interface PackInput {\n /** The ZIP archive of the contents of the extension, or a path to the folder containing the extension. */\n contents?: Uint8Array | string;\n /** The private key for the extension, or a path to it. */\n privateKey?: Uint8Array | string | null;\n /** The size of key to generate, if needed. */\n keySize?: number;\n /** The public key for the extension, or a path to it. */\n publicKey?: Uint8Array | string | null;\n /** The instance of NodeRSA to use. */\n rsa?: RSA;\n /** The extension's ID. */\n id?: string | null;\n /** The outputted CRX file. */\n crx?: Uint8Array | null;\n /** The CRX format version to use. Defaults to 3. */\n crxVersion?: number;\n /** The URL to where the CRX file (not the updates XML) will be hosted. */\n crxUrl?: string;\n /** The [updates XML file](https://developer.chrome.com/docs/extensions/how-to/distribute/host-on-linux). */\n updateXML?: string | null;\n /** The extension's version. */\n extVersion?: string | null;\n /** The minimum Chrome version the extension requires. */\n minChromeVersion?: string | null;\n /** The extension's [manifest](https://developer.chrome.com/docs/extensions/reference/manifest). */\n manifest?: ChromeManifest | null;\n}\n\ntype SetKeys<A extends object, B extends object> = Omit<A, keyof B> & B;\n\nexport type TransformPack<I extends PackInput> = I[\"privateKey\"] extends string\n ? TransformPack<\n SetKeys<\n I,\n {\n privateKey: Uint8Array | undefined;\n rsa: RSA;\n }\n >\n >\n : I[\"publicKey\"] extends string\n ? TransformPack<\n SetKeys<\n I,\n {\n publicKey: Uint8Array | undefined;\n }\n >\n >\n : I[\"updateXML\"] extends null\n ? undefined extends I[\"crxUrl\"]\n ? never\n : TransformPack<\n SetKeys<\n I,\n {\n updateXML: string;\n id: undefined extends I[\"id\"] ? null : I[\"id\"];\n extVersion: undefined extends I[\"extVersion\"]\n ? null\n : I[\"extVersion\"];\n minChromeVersion: undefined extends I[\"minChromeVersion\"]\n ? null\n : I[\"minChromeVersion\"];\n }\n >\n >\n : I[\"extVersion\"] extends null\n ? TransformPack<\n SetKeys<\n I,\n {\n extVersion: string;\n manifest: undefined extends I[\"manifest\"]\n ? null\n : I[\"manifest\"];\n }\n >\n >\n : I[\"minChromeVersion\"] extends null\n ? TransformPack<\n SetKeys<\n I,\n {\n minChromeVersion: string | undefined;\n manifest: undefined extends I[\"manifest\"]\n ? null\n : I[\"manifest\"];\n }\n >\n >\n : I[\"manifest\"] extends null\n ? undefined extends I[\"contents\"]\n ? never\n : Uint8Array extends I[\"contents\"]\n ? never\n : TransformPack<\n SetKeys<\n I,\n {\n manifest: ChromeManifest;\n }\n >\n >\n : I[\"crx\"] extends null\n ? undefined extends I[\"contents\"]\n ? never\n : TransformPack<\n SetKeys<\n I,\n {\n crx: Uint8Array;\n privateKey: undefined extends I[\"privateKey\"]\n ? null\n : I[\"privateKey\"];\n publicKey: undefined extends I[\"publicKey\"]\n ? null\n : I[\"publicKey\"];\n }\n >\n >\n : I[\"id\"] extends null\n ? TransformPack<\n SetKeys<\n I,\n {\n id: string;\n publicKey: undefined extends I[\"publicKey\"]\n ? null\n : I[\"publicKey\"];\n }\n >\n >\n : I[\"publicKey\"] extends null\n ? TransformPack<\n SetKeys<\n I,\n {\n publicKey: Uint8Array;\n privateKey: undefined extends I[\"privateKey\"]\n ? null\n : I[\"privateKey\"];\n }\n >\n >\n : I[\"privateKey\"] extends null\n ? TransformPack<\n SetKeys<\n I,\n {\n privateKey: Uint8Array;\n rsa: RSA;\n }\n >\n >\n : I[\"contents\"] extends string\n ? TransformPack<\n SetKeys<\n I,\n {\n contents: Uint8Array;\n manifest: ChromeManifest;\n }\n >\n >\n : I;\n\n/**\n * Use the entirety of this API in one function.\n *\n * @param options An object containing input parameters.\n *\n * If `null` is given for a property, then the function will generate a value for it based on the other properties.\n *\n * If a property requires another but that property is not requested (with `null`), then it is generated and given anyways.\n *\n * If `privateKey` or `publicKey` are strings, `pack` will load the file at each path as a key. If the extension is `.pem`, they are loaded as pkcs8-pem and converted to pkcs8-der.\n *\n * `pack` always returns a `Promise`, even if all of the operations inside are synchronous.\n *\n * However, the return result is the same object as the input - just with the properties modified - so if you *really* want synchronous operations, you can keep a reference to the input object, call the function, and access the synchronous results from that object. Just make sure you don't set `privateKey` or `manifest` to `null` or `contents` to a string, otherwise some of your values might not arrive synchronously.\n */\nexport async function pack<I extends PackInput>(\n options: I,\n): Promise<TransformPack<I>> {\n if (typeof options.privateKey == \"string\") {\n try {\n const isPem = options.privateKey.endsWith(\".pem\");\n const contents = await fs.readFile(options.privateKey);\n if (isPem)\n options.privateKey = Uint8Array.from(\n (options.rsa ??= new RSA(contents, \"pkcs8-private-pem\")).exportKey(\n \"pkcs8-private-der\",\n ),\n );\n else options.privateKey = Uint8Array.from(contents);\n } catch (e) {\n if (!`${e}`.includes(\"ENOENT\")) throw e;\n options.privateKey = undefined;\n }\n }\n if (typeof options.publicKey == \"string\") {\n try {\n const isPem = options.publicKey.endsWith(\".pem\");\n const contents = await fs.readFile(options.publicKey);\n if (isPem)\n options.publicKey = Uint8Array.from(\n new RSA(contents, \"pkcs8-public-pem\").exportKey(\"pkcs8-public-der\"),\n );\n else options.publicKey = Uint8Array.from(contents);\n } catch (e) {\n if (!`${e}`.includes(\"ENOENT\")) throw e;\n options.publicKey = undefined;\n }\n }\n if (options.updateXML === null) {\n if (options.crxUrl === undefined)\n throw new Error(\"crxUrl must be defined to generate updateXML\");\n if (options.id === undefined) options.id = null;\n if (options.extVersion === undefined) options.extVersion = null;\n if (options.minChromeVersion === undefined) options.minChromeVersion = null;\n }\n if (options.extVersion === null) {\n if (options.manifest === undefined) options.manifest = null;\n }\n if (options.minChromeVersion === null) {\n if (options.manifest === undefined) options.manifest = null;\n }\n if (options.crx === null) {\n if (options.contents === undefined)\n throw new Error(\"contents must be defined to generate crx\");\n if (options.privateKey === undefined) options.privateKey = null;\n if (options.publicKey === undefined) options.publicKey = null;\n }\n if (options.id === null) {\n if (options.publicKey === undefined) options.publicKey = null;\n }\n if (options.publicKey === null) {\n if (options.privateKey === undefined) options.privateKey = null;\n }\n\n if (options.privateKey === null) {\n options.rsa ??= new RSA({ b: options.keySize || 4096 });\n options.privateKey = Uint8Array.from(\n options.rsa.exportKey(\"pkcs8-private-der\"),\n );\n options.publicKey = Uint8Array.from(\n options.rsa.exportKey(\"pkcs8-public-der\"),\n );\n }\n if (options.publicKey === null) {\n options.publicKey = Uint8Array.from(\n (options.rsa ??= new RSA(\n Buffer.from(options.privateKey!),\n \"pkcs8-private-der\",\n )).exportKey(\"pkcs8-public-der\"),\n );\n }\n if (typeof options.contents == \"string\") {\n ({ contents: options.contents, manifest: options.manifest } =\n await packContents(options.contents));\n }\n if (options.crx === null) {\n if (options.crxVersion == 3 || options.crxVersion == undefined)\n options.crx = packCrx3(\n options.privateKey!,\n options.publicKey!,\n options.contents!,\n options.rsa,\n );\n else if (options.crxVersion == 2)\n options.crx = packCrx2(\n options.privateKey!,\n options.publicKey!,\n options.contents!,\n options.rsa,\n );\n }\n if (options.id === null) {\n options.id = generateCrxId(options.publicKey!);\n }\n if (options.extVersion === null) {\n if (!options.manifest)\n throw new Error(\"manifest must be defined to generate extVersion\");\n options.extVersion = options.manifest.version;\n }\n if (options.minChromeVersion === null) {\n options.minChromeVersion =\n options.manifest?.minimum_chrome_version ||\n (options.crxVersion == 3 || options.crxVersion == undefined\n ? \"73.0.3683\"\n : undefined);\n }\n if (options.updateXML === null) {\n options.updateXML = generateUpdateXML(\n options.id!,\n options.crxUrl!,\n options.extVersion!,\n options.minChromeVersion,\n );\n }\n return options as any;\n}\n\nexport default pack;\n"
7
7
  ],
8
- "mappings": "AAEO,IAAI,EAAgB,CAAC,EAE5B,EAAc,KAAO,QAAS,CAAC,EAAK,EAAK,CACvC,OAAO,EAAI,WACT,EAAc,WACd,CAAE,gBAAiB,CAAC,EAAG,kBAAmB,CAAC,EAAG,mBAAoB,IAAK,EACvE,CACF,GAEF,EAAc,WAAa,QAAS,CAAC,EAAK,EAAK,EAAK,CAClD,GAAI,IAAQ,EACV,EAAI,gBAAgB,KAClB,EAAmB,KAAK,EAAK,EAAI,WAAW,EAAI,EAAI,GAAG,CACzD,EACG,QAAI,IAAQ,EACf,EAAI,kBAAkB,KACpB,EAAmB,KAAK,EAAK,EAAI,WAAW,EAAI,EAAI,GAAG,CACzD,EACG,QAAI,IAAQ,IAAO,EAAI,mBAAqB,EAAI,UAAU,GAEjE,EAAc,MAAQ,QAAS,CAAC,EAAK,EAAK,CACxC,GAAI,EAAI,gBACN,QAAS,EAAI,EAAG,EAAI,EAAI,gBAAgB,OAAQ,IAC9C,EAAI,aAAa,EAAG,EAAmB,MAAO,EAAI,gBAAgB,EAAE,EACxE,GAAI,EAAI,kBACN,IAAK,EAAI,EAAG,EAAI,EAAI,kBAAkB,OAAQ,IAC5C,EAAI,aAAa,EAAG,EAAmB,MAAO,EAAI,kBAAkB,EAAE,EAC1E,GAAI,EAAI,mBACN,EAAI,gBAAgB,IAAO,EAAI,kBAAkB,GAK9C,IAAI,EAAqB,CAAC,EAEj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EAAQ,KAAO,KACjB,EAAQ,GAAK,EAAc,EAAQ,SAAU,EAE/C,GAAI,EAAQ,aAAe,KAAM,CAC/B,GAAI,CAAC,EAAQ,SACX,MAAU,MAAM,iDAAiD,EACnE,EAAQ,WAAa,EAAQ,SAAS,QAExC,GAAI,EAAQ,mBAAqB,KAC/B,EAAQ,iBACN,EAAQ,UAAU,yBACjB,EAAQ,YAAc,GAAK,EAAQ,YAAc,KAC9C,YACA,QAER,GAAI,EAAQ,YAAc,KACxB,EAAQ,UAAY,EAClB,EAAQ,GACR,EAAQ,OACR,EAAQ,WACR,EAAQ,gBACV,EAEF,OAAO,EAGT,IAAe",
9
9
  "debugId": "EC4D20858A564FDB64756E2164756E21",
10
10
  "names": []
11
11
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pack-crx",
3
3
  "type": "module",
4
- "version": "1.1.1",
4
+ "version": "1.1.2",
5
5
  "scripts": {
6
6
  "build": "bun build src/index.ts --minify --sourcemap=linked --outdir build --target node --packages external",
7
7
  "build:types": "tsc --emitDeclarationOnly",