{"name":"resedit","version":"3.0.0","keywords":["windows","resource","javascript","library","version","icon","edit","resedit","pe-executable","authenticode"],"author":{"name":"jet"},"license":"MIT","_id":"resedit@3.0.0","maintainers":[{"name":"jet2jet","email":"smalljet@hotmail.co.jp"}],"homepage":"https://github.com/jet2jet/resedit-js","bugs":{"url":"https://github.com/jet2jet/resedit-js/issues"},"dist":{"shasum":"b04f3449a5284a7f66d073373c84b1e37a5c6553","tarball":"http://registry-npm.ywwl.com/resedit/download/resedit-3.0.0.tgz","fileCount":79,"integrity":"sha512-WO17omMX6UO8PbI0sI3ehiyD/ZFnGH9/pTb38tWPMstzHNdY5hmZay0V3uid8Qv3kRowR1r8yoSTg8YDnMxbOQ==","signatures":[{"sig":"MEYCIQCSthEOp/1PR4gQ6TyKjVahfouc6clDfcPdxKdFzw4MmgIhAPVYXYEY8hV3rotA+Nf5OZagttbAvVUwnBgDaxDtRwrv","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/resedit@3.0.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":181744,"size":41942,"noattachment":false,"key":"/resedit/-/resedit-3.0.0.tgz"},"type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"npm":">=11.5.1","node":">=20.19.5"},"exports":{".":"./dist/index.js","./cjs":{"require":"./cjs.cjs"}},"funding":{"url":"https://github.com/sponsors/jet2jet","type":"github"},"gitHead":"423511d2a82404752e6fb3c1af08056be02e2e57","scripts":{"lint":"npm run lint:eslint && npm run lint:prettier","test":"npm run test-base -- --config ./jest.config.basic.js","build":"npm run build:esm","version":"node ./tools/updateVersion.js ./src/main/version.ts && git add -A ./src/main/version.ts","lint:fix":"npm run lint:eslint:fix && npm run lint:prettier:fix","build:esm":"tsc -p ./tsconfig.app.json","test-base":"node --experimental-vm-modules node_modules/jest/bin/jest.js","test:lint":"npm run lint","typecheck":"tsc --project tsconfig.json --noEmit && echo \"Done\".","test:basic":"npm run test-base -- --config ./jest.config.basic.js","lint:eslint":"eslint -c eslint.config.mjs --ext .js,.jsx,.ts,.tsx .","test:win-x64":"npm run test-base -- --config ./jest.config.win-x64.js","test:win-x86":"npm run test-base -- --config ./jest.config.win-x86.js","lint:prettier":"prettier --config ./.prettierrc.yml --check \"**/*.{js,jsx,ts,tsx,yml,json,md}\"","lint:eslint:fix":"eslint -c eslint.config.mjs --fix --ext .js,.jsx,.ts,.tsx .","lint:prettier:fix":"prettier --config ./.prettierrc.yml --write \"**/*.{js,jsx,ts,tsx,yml,json,md}\""},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:03c43ea5-438c-4810-8425-214889a342d2"}},"repository":{"url":"git+https://github.com/jet2jet/resedit-js.git","type":"git"},"_npmVersion":"11.5.1","description":"Node.js library editing Windows Resource data","directories":{},"_nodeVersion":"20.19.5","dependencies":{"pe-library":"^2.0.0"},"engineStrict":true,"_hasShrinkwrap":false,"devDependencies":{"jest":"^30.2.0","eslint":"^9.37.0","ts-jest":"^29.4.5","prettier":"^3.6.2","typescript":"~4.9.5","@types/jest":"^30.0.0","@types/node":"~20.19.22","neostandard":"^0.12.2","eslint-plugin-n":"^17.23.1","eslint-plugin-promise":"^7.2.1","eslint-config-prettier":"^10.1.8","eslint-plugin-import-x":"^4.16.1","@typescript-eslint/parser":"^8.46.1","@typescript-eslint/eslint-plugin":"^8.46.1"},"_npmOperationalInternal":{"tmp":"tmp/resedit_3.0.0_1760700604563_0.2742530843386357","host":"s3://npm-registry-packages-npm-production"},"readme":"[![NPM Version](https://img.shields.io/npm/v/resedit)](https://www.npmjs.com/package/resedit)\n[![NPM Downloads](https://img.shields.io/npm/dw/resedit)](https://www.npmjs.com/package/resedit)\n\n# resedit-js\n\nresedit-js is a library that manipulates resouces contained by Windows Executable files. All implementations are written in JavaScript (TypeScript), without using any native binaries. resedit-js works in both Node.js environment and Web environment (with bundlers).\n\nThis library is not tested well for modifying and/or signing executables yet. Please be careful with the emitted binaries.\n\nTo use from command line, [resedit-js-cli](https://www.npmjs.com/package/resedit-cli) is suitable.\n\nThe demo page: [resedit demo](https://www.pg-fl.jp/program/resedit/index.en.htm)\n\n- [Install](#install)\n- [Usage](#usage)\n- [Supported formats](#supported-formats)\n- [Parsing signed executables](#parsing-signed-executables)\n- [Signing executables with resedit-js](#signing-executables-with-resedit-js)\n- [Notes](#notes)\n- [Examples](#examples)\n- [License](#license)\n\n## Install\n\n```\nnpm install resedit\n```\n\n## Usage\n\n- For detailed code using `ResEdit` namespace, see [Examples](#examples).\n- For more APIs, please see `dist` directory of the package. And, [some test codes](./src/test) may help you for usages.\n\nFor ESM (ES Modules):\n\n```js\n//import * as PELibrary from 'pe-library';\nimport * as ResEdit from 'resedit';\n```\n\nFor CJS (CommonJS modules including classic Node.js scripts):\n\n```js\n//const PELibrary = require('pe-library');\nconst ResEdit = require('resedit');\n```\n\n> If your Node.js version is prior to v20.19.5, `require` cannot be used for `'resedit'` package and you must use `'resedit/cjs'` package as described in [Migrate from v1.x to v2.x](#migrate-from-v1x-to-v2x) (collapsed in `Migration from prior resedit versions` area).\n\n<details><summary>Migration from prior resedit versions</summary>\n\n### Migrate from v2.x to v3.x\n\nThis major version up includes 'Change requirements of Node.js version (_v20.19.5 or later_ is required)' and 'Remove TypeScript enum usage' only. If your code base (project) meets following conditions, you can safely upgrade to v3.x (without no more actions):\n\n- You uses resedit v2.x\n  - If you use v1.x, please follow [Migrate from v1.x to v2.x](#migrate-from-v1x-to-v2x).\n- The code base already uses Node.js v20.19.5 or later (including v22, v24, or higher)\n  - Node.js v18 or earlier is already end-of-life. Upgrade to v22 or v24 is recommended.\n  - For using Node.js v20, upgrading to v20.19.5 or later would not be difficult.\n- Following enum's members are not used or used only as values: `VersionFileFlags`, `VersionFileOS`, `VersionFileDriverSubtype`, `VersionFileFontSubtype`, and `VersionFileType`\n  - If you use the members as types (e.g. `let x: VersionFileFlags.Debug`), rewrite with using `typeof` (e.g, `let x: typeof VersionFileFlags.Debug`).\n\n### Migrate from v1.x to v2.x\n\n- If you use from ES module (.mjs) and load by using `import`, no need for migration.\n- If you use from ES module (.mjs) and load by using `require` (Node.js: via `createRequire`), replace with `import` statement: `import * as ResEdit from 'resedit'`.\n- If you use from CommonJS module (.cjs) and load by using `require`, choose followings:\n  - If you are using under Node.js environment, _only_ update Node.js to v20.19.0 or later\n    - Starting from Node.js v20.19.0, you can `require` synchronous ES module. resedit does not use top-level `await`, so you can write `require('resedit')` from CommonJS module.\n  - Convert CommonJS module to ES module and replace `require` call with `import` statement\n  - Use `resedit/cjs` module and call `load` function (see below)\n- If you use TypeScript,\n  - For `\"module\": \"ES2015\"` or higher, no need for migration.\n  - For `\"module\": \"CommonJS\"`, import `resedit/cjs` and call `load` function\n\nThe sample of using `resedit/cjs` in CommonJS module is:\n\n```js\nconst { load } = require('resedit/cjs');\nload().then((ResEdit) => {\n  // ResEdit will be the namespace object of resedit library\n  // (for example ResEdit.Data.IconFile is available)\n});\n```\n\nSimilarly, the sample of using `resedit/cjs` in TypeScript CommonJS module is:\n\n```ts\n// You can use `ResEdit` for type references (cannot be used for value references)\nimport { type ResEdit, load } from 'resedit/cjs';\nload().then((RE: typeof ResEdit) => {\n  // RE will be the namespace object of resedit library\n  // (for example RE.Data.IconFile is available)\n});\n```\n\n</details>\n\n## Supported formats\n\n- Windows Executables (PE Format, such as `.exe` and `.dll`), both 32-bit and 64-bit, are supported.\n  - Executables for 16-bit Windows is not supported.\n- `.res` file is not supported now.\n- PNG-based icon data is supported on `require('resedit').Resource.IconGroupEntry` class.\n\n## Parsing signed executables\n\n- Parsing signed executables (by using Authenticode or etc.) is not allowed by default and an exception will be thrown if `NtExecutable.from` receives a signed binary.\n- To parse signed, `{ ignoreCert: true }` object must be passed to the second argument of `NtExecutable.from`.\n- Although the base executable data is signed, `NtExecutable.generate` will generate unsigned executable binary. If you want to re-sign it, you must use generate-function with signing (see below) or any other signing tool such as Microsoft `signtool`.\n\n## Signing executables with resedit-js\n\nresedit-js provides basic signing process `generateExecutableWithSign` function, which is based on [Authenticode specification](https://download.microsoft.com/download/9/c/5/9c5b2167-8017-4bae-9fde-d599bac8184a/authenticode_pe.docx) and related RFCs.\n\nTo keep resedit-js generic library, the followings are required to use signing process.\n\n- Encryption / calculating hash (digest) process (e.g. Node.js built-in `crypto` module)\n  - A private key data is implicitly required to encrypt data.\n- DER-format certificate binary (such as `*.cer` file data or `*.p7b` file data with DER-format), which is paired with the private key used by encryption process.\n- (optional) Generating timestamp data, especially communicating with TSA server (e.g. HTTP/HTTPS API)\n\nThese requirements are represented as [`SignerObject`](./src/main/sign/SignerObject.ts). The caller of `generateExecutableWithSign` function must implement this object to sign executables.\n\nAn example code is here: [signTest.mjs](./examples/sign/signTest.mjs)\n\nNote that resedit-js only provides basic signing process, and provides as beta version. For example adding more attributes/informations to certificates are not supported now.\n\n> Some digest algorithms, such as SHA3 algorithms, might not be supported by current Windows.\n\n## Notes\n\n- **It is not strongly recommended that the destination executable file is equal to the source executable file (which is not an intermediate data).**\n\n## Examples\n\n```js\nimport * as PELibrary from 'pe-library';\nimport * as ResEdit from 'resedit';\nimport * as fs from 'fs';\n\n// load and parse data\nconst data = fs.readFileSync('MyApp.exe');\n// (the Node.js Buffer instance can be specified directly to NtExecutable.from)\nconst exe = PELibrary.NtExecutable.from(data);\nconst res = PELibrary.NtExecutableResource.from(exe);\n\n// rewrite resources\n// - You can use helper classes as followings:\n//   - ResEdit.Resource.IconGroupEntry: access icon resource data\n//   - ResEdit.Resource.StringTable: access string resource data\n//   - ResEdit.Resource.VersionInfo: access version info data\n\n// -- replace icons\n\n// load icon data from file\n// (you can use ResEdit.Data.IconFile to parse icon data)\nconst iconFile = ResEdit.Data.IconFile.from(fs.readFileSync('MyIcon.ico'));\n\nResEdit.Resource.IconGroupEntry.replaceIconsForResource(\n  // destEntries\n  res.entries,\n  // iconGroupID\n  // - This ID is originally defined in base executable file\n  //   (the ID list can be retrieved by `ResEdit.Resource.IconGroupEntry.fromEntries(res.entries).map((entry) => entry.id)`)\n  101,\n  // lang ('lang: 1033' means 'en-US')\n  1033,\n  // icons (map IconFileItem to IconItem/RawIconItem)\n  iconFile.icons.map((item) => item.data)\n);\n\n// -- replace version\n\nconst viList = ResEdit.Resource.VersionInfo.fromEntries(res.entries);\nconst vi = viList[0];\n// setFileVersion will set `vi.fixedInfo.fileVersionMS`/`fileVersionLS` and 'FileVersion' string value\n// ('1033' means 'en-US')\nvi.setFileVersion(1, 0, 0, 0, 1033);\n// ('lang: 1033' means 'en-US', 'codepage: 1200' is the default codepage)\nvi.setStringValues(\n  { lang: 1033, codepage: 1200 },\n  {\n    FileDescription: 'My application',\n    ProductName: 'My product',\n  }\n);\nvi.outputToResourceEntries(res.entries);\n\n// write to another binary\nres.outputResource(exe);\nconst newBinary = exe.generate();\nfs.writeFileSync('MyApp_modified.exe', Buffer.from(newBinary));\n```\n\n## License\n\n[MIT License](./LICENSE)\n","publish_time":1760700604761,"_cnpm_publish_time":1760700604761,"dist-tags":{"latest":"3.1.0"}}