@hakobu/hakobu 1.0.0
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/LICENSE +21 -0
- package/README.md +673 -0
- package/dictionary/angular-bridge.js +3 -0
- package/dictionary/any-promise.js +3 -0
- package/dictionary/async.js +3 -0
- package/dictionary/aws-sdk.js +7 -0
- package/dictionary/babel-core.js +3 -0
- package/dictionary/batch.js +3 -0
- package/dictionary/bcrypt.js +3 -0
- package/dictionary/better-sqlite3.js +3 -0
- package/dictionary/bignum.js +3 -0
- package/dictionary/bindings.js +3 -0
- package/dictionary/blessed.js +8 -0
- package/dictionary/body-parser.js +9 -0
- package/dictionary/browserify.js +7 -0
- package/dictionary/bson.js +3 -0
- package/dictionary/buffermaker.js +7 -0
- package/dictionary/bunyan.js +9 -0
- package/dictionary/busboy.js +7 -0
- package/dictionary/bytes.js +3 -0
- package/dictionary/callsites.js +3 -0
- package/dictionary/chokidar.js +3 -0
- package/dictionary/coffee-script.js +7 -0
- package/dictionary/colors.js +3 -0
- package/dictionary/compression.js +3 -0
- package/dictionary/compressjs.js +7 -0
- package/dictionary/connect-mongo.js +3 -0
- package/dictionary/connect-mongodb.js +3 -0
- package/dictionary/connect-redis.js +3 -0
- package/dictionary/connect.js +10 -0
- package/dictionary/consolidate.js +3 -0
- package/dictionary/cookie-parser.js +3 -0
- package/dictionary/cookie.js +3 -0
- package/dictionary/cors.js +3 -0
- package/dictionary/cron.js +3 -0
- package/dictionary/cross-env.js +11 -0
- package/dictionary/cross-spawn-async.js +3 -0
- package/dictionary/curve25519.js +3 -0
- package/dictionary/data-preflight.js +7 -0
- package/dictionary/debug.js +3 -0
- package/dictionary/denymount.js +3 -0
- package/dictionary/diff.js +3 -0
- package/dictionary/drivelist.js +22 -0
- package/dictionary/ed25519.js +3 -0
- package/dictionary/ejs.js +3 -0
- package/dictionary/elasticsearch.js +3 -0
- package/dictionary/electron.js +17 -0
- package/dictionary/emailjs.js +3 -0
- package/dictionary/engine.io.js +3 -0
- package/dictionary/epoll.js +3 -0
- package/dictionary/errorhandler.js +7 -0
- package/dictionary/errors.js +7 -0
- package/dictionary/eslint.js +7 -0
- package/dictionary/etcher-image-write.js +3 -0
- package/dictionary/exceljs.js +21 -0
- package/dictionary/exiftool.exe.js +13 -0
- package/dictionary/exiftool.pl.js +13 -0
- package/dictionary/express-load.js +12 -0
- package/dictionary/express-session.js +3 -0
- package/dictionary/express.js +14 -0
- package/dictionary/extender.js +11 -0
- package/dictionary/extsprintf.js +3 -0
- package/dictionary/faye-websocket.js +3 -0
- package/dictionary/feathers.js +3 -0
- package/dictionary/findup-sync.js +3 -0
- package/dictionary/floordate.js +3 -0
- package/dictionary/fmt.js +3 -0
- package/dictionary/formidable.js +3 -0
- package/dictionary/fs-extra.js +3 -0
- package/dictionary/fsevents.js +3 -0
- package/dictionary/geoip-lite.js +7 -0
- package/dictionary/github.js +7 -0
- package/dictionary/gm.js +3 -0
- package/dictionary/google-closure-compiler-java.js +13 -0
- package/dictionary/google-closure-compiler.js +13 -0
- package/dictionary/googleapis.js +7 -0
- package/dictionary/got.js +3 -0
- package/dictionary/graceful-fs.js +19 -0
- package/dictionary/grpc.js +11 -0
- package/dictionary/gulp.js +3 -0
- package/dictionary/hap-nodejs.js +3 -0
- package/dictionary/heapdump.js +3 -0
- package/dictionary/hoek.js +3 -0
- package/dictionary/homebridge.js +3 -0
- package/dictionary/http-proxy.js +3 -0
- package/dictionary/http-server.js +3 -0
- package/dictionary/image-size.js +3 -0
- package/dictionary/indexof.js +3 -0
- package/dictionary/inquirer.js +3 -0
- package/dictionary/j.js +16 -0
- package/dictionary/jade.js +3 -0
- package/dictionary/jsdom.js +3 -0
- package/dictionary/json-stringify-date.js +3 -0
- package/dictionary/json-stringify-safe.js +3 -0
- package/dictionary/jsonwebtoken.js +3 -0
- package/dictionary/kerberos.js +3 -0
- package/dictionary/knex.js +7 -0
- package/dictionary/later.js +7 -0
- package/dictionary/level.js +3 -0
- package/dictionary/leveldown.js +10 -0
- package/dictionary/levelup.js +3 -0
- package/dictionary/liftoff.js +12 -0
- package/dictionary/lodash.js +3 -0
- package/dictionary/log4js.js +7 -0
- package/dictionary/logform.js +7 -0
- package/dictionary/machinepack-urls.js +7 -0
- package/dictionary/markdown.js +3 -0
- package/dictionary/mdns.js +6 -0
- package/dictionary/method-override.js +3 -0
- package/dictionary/microjob.js +16 -0
- package/dictionary/mime-types.js +3 -0
- package/dictionary/mime.js +3 -0
- package/dictionary/minimatch.js +3 -0
- package/dictionary/minstache.js +3 -0
- package/dictionary/module-deps.js +3 -0
- package/dictionary/moment-timezone.js +3 -0
- package/dictionary/moment.js +7 -0
- package/dictionary/mongodb-core.js +22 -0
- package/dictionary/mongodb.js +7 -0
- package/dictionary/mongoose.js +7 -0
- package/dictionary/mongoskin.js +7 -0
- package/dictionary/ms.js +3 -0
- package/dictionary/msgpack.js +3 -0
- package/dictionary/multer.js +3 -0
- package/dictionary/muri.js +3 -0
- package/dictionary/native-or-bluebird.js +3 -0
- package/dictionary/natives.js +3 -0
- package/dictionary/nconf.js +7 -0
- package/dictionary/nedb.js +3 -0
- package/dictionary/negotiator.js +7 -0
- package/dictionary/newrelic.js +3 -0
- package/dictionary/nib.js +3 -0
- package/dictionary/nightmare.js +18 -0
- package/dictionary/node-forge.js +7 -0
- package/dictionary/node-libcurl.js +3 -0
- package/dictionary/node-notifier.js +30 -0
- package/dictionary/node-pre-gyp.js +7 -0
- package/dictionary/node-redis-pubsub.js +3 -0
- package/dictionary/node-sass.js +3 -0
- package/dictionary/node-uuid.js +3 -0
- package/dictionary/node-xlsx.js +3 -0
- package/dictionary/node-zookeeper-client.js +7 -0
- package/dictionary/nodegit.js +7 -0
- package/dictionary/nodemailer-sendmail-transport.js +3 -0
- package/dictionary/nodemailer.js +3 -0
- package/dictionary/npm-registry-client.js +7 -0
- package/dictionary/npm.js +7 -0
- package/dictionary/nssocket.js +3 -0
- package/dictionary/oauth2orize.js +7 -0
- package/dictionary/octobat.js +3 -0
- package/dictionary/open.js +13 -0
- package/dictionary/opn.js +4 -0
- package/dictionary/optimist.js +3 -0
- package/dictionary/passport-local.js +3 -0
- package/dictionary/passport.js +3 -0
- package/dictionary/pg-cursor.js +3 -0
- package/dictionary/pg-query-stream.js +3 -0
- package/dictionary/pg-types.js +7 -0
- package/dictionary/pg.js +7 -0
- package/dictionary/pg.js.js +7 -0
- package/dictionary/pgpass.js +7 -0
- package/dictionary/phantom.js +19 -0
- package/dictionary/phantomjs-prebuilt.js +16 -0
- package/dictionary/pkginfo.js +3 -0
- package/dictionary/pm2.js +7 -0
- package/dictionary/pmx.js +3 -0
- package/dictionary/pouchdb.js +3 -0
- package/dictionary/primus-emitter.js +3 -0
- package/dictionary/primus-spark-latency.js +3 -0
- package/dictionary/primus.js +3 -0
- package/dictionary/publicsuffixlist.js +15 -0
- package/dictionary/pug.js +3 -0
- package/dictionary/punt.js +3 -0
- package/dictionary/puppeteer.js +13 -0
- package/dictionary/pwd.js +3 -0
- package/dictionary/q.js +3 -0
- package/dictionary/raven.js +3 -0
- package/dictionary/rc.js +12 -0
- package/dictionary/readable-stream.js +3 -0
- package/dictionary/rechoir.js +3 -0
- package/dictionary/redis-parser.js +3 -0
- package/dictionary/redis.js +3 -0
- package/dictionary/regression.js +3 -0
- package/dictionary/reload.js +7 -0
- package/dictionary/request.js +3 -0
- package/dictionary/require-uncached.js +3 -0
- package/dictionary/require_optional.js +3 -0
- package/dictionary/s3.js +3 -0
- package/dictionary/safe_datejs.js +3 -0
- package/dictionary/sails.js +33 -0
- package/dictionary/sax.js +3 -0
- package/dictionary/scrypt.js +3 -0
- package/dictionary/semver.js +3 -0
- package/dictionary/sequelize.js +7 -0
- package/dictionary/serialport.js +3 -0
- package/dictionary/sha3.js +3 -0
- package/dictionary/sharp.js +11 -0
- package/dictionary/shelljs.js +7 -0
- package/dictionary/sinon.js +3 -0
- package/dictionary/socket.io-client.js +13 -0
- package/dictionary/socket.io.js +12 -0
- package/dictionary/sqip.js +7 -0
- package/dictionary/sqlite3.js +7 -0
- package/dictionary/steam-crypto.js +7 -0
- package/dictionary/steam-resources.js +19 -0
- package/dictionary/steam.js +3 -0
- package/dictionary/stripe-webhook-middleware.js +3 -0
- package/dictionary/stripe.js +3 -0
- package/dictionary/strong-globalize.js +3 -0
- package/dictionary/stylus.js +14 -0
- package/dictionary/supervisor.js +3 -0
- package/dictionary/svgo.js +8 -0
- package/dictionary/tabtab.js +3 -0
- package/dictionary/tesseract.js.js +7 -0
- package/dictionary/thread-stream.js +7 -0
- package/dictionary/throng.js +3 -0
- package/dictionary/time.js +3 -0
- package/dictionary/tinify.js +7 -0
- package/dictionary/tiny-worker.js +7 -0
- package/dictionary/tmp.js +3 -0
- package/dictionary/transformers.js +3 -0
- package/dictionary/uglify-js.js +9 -0
- package/dictionary/umd.js +19 -0
- package/dictionary/underscore.js +3 -0
- package/dictionary/union.js +3 -0
- package/dictionary/update-notifier.js +3 -0
- package/dictionary/usage.js +7 -0
- package/dictionary/v8flags.js +13 -0
- package/dictionary/verror.js +3 -0
- package/dictionary/voc.js +3 -0
- package/dictionary/webdriverio.js +7 -0
- package/dictionary/winston-uber.js +7 -0
- package/dictionary/winston.js +7 -0
- package/dictionary/ws.js +3 -0
- package/dictionary/xlsx.js +16 -0
- package/dictionary/xml2js.js +3 -0
- package/dictionary/yargs.js +3 -0
- package/dictionary/zeromq.js +13 -0
- package/lib-es5/addon-extract.js +164 -0
- package/lib-es5/analyzer.js +687 -0
- package/lib-es5/app-bundle.js +133 -0
- package/lib-es5/appdir.js +265 -0
- package/lib-es5/bin.js +304 -0
- package/lib-es5/bootstrap.js +179 -0
- package/lib-es5/bundler.js +496 -0
- package/lib-es5/chmod.js +15 -0
- package/lib-es5/colors.js +12 -0
- package/lib-es5/commands.js +376 -0
- package/lib-es5/common.js +328 -0
- package/lib-es5/compress_type.js +10 -0
- package/lib-es5/config.js +291 -0
- package/lib-es5/detector.js +421 -0
- package/lib-es5/esm-hooks.js +366 -0
- package/lib-es5/esm-resolver.js +292 -0
- package/lib-es5/esm-transformer.js +378 -0
- package/lib-es5/exports-resolver.js +184 -0
- package/lib-es5/external-artifacts.js +170 -0
- package/lib-es5/fabricator.js +137 -0
- package/lib-es5/follow.js +190 -0
- package/lib-es5/help.js +52 -0
- package/lib-es5/index.d.ts +2 -0
- package/lib-es5/index.js +552 -0
- package/lib-es5/log.js +7 -0
- package/lib-es5/mach-o.js +262 -0
- package/lib-es5/manifest.js +21 -0
- package/lib-es5/options.js +19 -0
- package/lib-es5/packager.js +1036 -0
- package/lib-es5/packer.js +137 -0
- package/lib-es5/pe-metadata.js +130 -0
- package/lib-es5/producer.js +378 -0
- package/lib-es5/refiner.js +87 -0
- package/lib-es5/resolver.js +142 -0
- package/lib-es5/runtime-diagnostics.js +172 -0
- package/lib-es5/sea.js +307 -0
- package/lib-es5/snapshot-fs-patch.js +396 -0
- package/lib-es5/snapshot-fs.js +255 -0
- package/lib-es5/snapshot-index.js +135 -0
- package/lib-es5/snapshot-path.js +168 -0
- package/lib-es5/types.js +9 -0
- package/lib-es5/walker.js +1019 -0
- package/lib-es5/windows-sign.js +139 -0
- package/package.json +99 -0
- package/prelude/bootstrap.js +2263 -0
- package/prelude/diagnostic.js +147 -0
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const assert_1 = __importDefault(require("assert"));
|
|
7
|
+
const fs_1 = require("fs");
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const common_1 = require("./common");
|
|
10
|
+
const log_1 = require("./log");
|
|
11
|
+
const { version } = JSON.parse((0, fs_1.readFileSync)(path_1.default.join(__dirname, '../package.json'), 'utf-8'));
|
|
12
|
+
const bootstrapText = (0, fs_1.readFileSync)(require.resolve('../prelude/bootstrap.js'), 'utf8').replace('%VERSION%', version);
|
|
13
|
+
const commonText = (0, fs_1.readFileSync)(require.resolve('./common'), 'utf8');
|
|
14
|
+
const diagnosticText = (0, fs_1.readFileSync)(require.resolve('../prelude/diagnostic.js'), 'utf8');
|
|
15
|
+
function itemsToText(items) {
|
|
16
|
+
const len = items.length;
|
|
17
|
+
return len.toString() + (len % 10 === 1 ? ' item' : ' items');
|
|
18
|
+
}
|
|
19
|
+
function hasAnyStore(record) {
|
|
20
|
+
// discarded records like native addons
|
|
21
|
+
for (const store of [common_1.STORE_BLOB, common_1.STORE_CONTENT, common_1.STORE_LINKS, common_1.STORE_STAT]) {
|
|
22
|
+
if (record[store])
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
function packer({ records, entrypoint, bytecode, }) {
|
|
28
|
+
const stripes = [];
|
|
29
|
+
// If the entrypoint was a .mjs file that got transformed, update its extension
|
|
30
|
+
if (records[entrypoint]?.wasTransformed && entrypoint.endsWith('.mjs')) {
|
|
31
|
+
entrypoint = `${entrypoint.slice(0, -4)}.js`;
|
|
32
|
+
}
|
|
33
|
+
for (let snap in records) {
|
|
34
|
+
if (records[snap]) {
|
|
35
|
+
const record = records[snap];
|
|
36
|
+
const { file } = record;
|
|
37
|
+
if (!hasAnyStore(record)) {
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
// If .mjs file was transformed to CJS, rename it to .js in the snapshot
|
|
41
|
+
// This prevents Node.js from treating it as an ES module
|
|
42
|
+
if (record.wasTransformed && snap.endsWith('.mjs')) {
|
|
43
|
+
snap = `${snap.slice(0, -4)}.js`;
|
|
44
|
+
}
|
|
45
|
+
(0, assert_1.default)(record[common_1.STORE_STAT], 'packer: no STORE_STAT');
|
|
46
|
+
(0, assert_1.default)(record[common_1.STORE_BLOB] ||
|
|
47
|
+
record[common_1.STORE_CONTENT] ||
|
|
48
|
+
record[common_1.STORE_LINKS] ||
|
|
49
|
+
record[common_1.STORE_STAT]);
|
|
50
|
+
if (record[common_1.STORE_BLOB] && !bytecode) {
|
|
51
|
+
delete record[common_1.STORE_BLOB];
|
|
52
|
+
if (!record[common_1.STORE_CONTENT]) {
|
|
53
|
+
// TODO make a test for it?
|
|
54
|
+
throw (0, log_1.wasReported)('--no-bytecode and no source breaks final executable', [
|
|
55
|
+
file,
|
|
56
|
+
'Please run with "-d" and without "--no-bytecode" first, and make',
|
|
57
|
+
'sure that debug log does not contain "was included as bytecode".',
|
|
58
|
+
]);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
for (const store of [
|
|
62
|
+
common_1.STORE_BLOB,
|
|
63
|
+
common_1.STORE_CONTENT,
|
|
64
|
+
common_1.STORE_LINKS,
|
|
65
|
+
common_1.STORE_STAT,
|
|
66
|
+
]) {
|
|
67
|
+
const value = record[store];
|
|
68
|
+
if (!value) {
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
if (store === common_1.STORE_BLOB || store === common_1.STORE_CONTENT) {
|
|
72
|
+
if (record.body === undefined) {
|
|
73
|
+
stripes.push({ snap, store, file });
|
|
74
|
+
}
|
|
75
|
+
else if (Buffer.isBuffer(record.body)) {
|
|
76
|
+
stripes.push({ snap, store, buffer: record.body });
|
|
77
|
+
}
|
|
78
|
+
else if (typeof record.body === 'string') {
|
|
79
|
+
stripes.push({ snap, store, buffer: Buffer.from(record.body) });
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
(0, assert_1.default)(false, 'packer: bad STORE_BLOB/STORE_CONTENT');
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
else if (store === common_1.STORE_LINKS) {
|
|
86
|
+
if (Array.isArray(value)) {
|
|
87
|
+
const dedupedValue = [...new Set(value)];
|
|
88
|
+
log_1.log.debug('files & folders deduped = ', dedupedValue);
|
|
89
|
+
const buffer = Buffer.from(JSON.stringify(dedupedValue));
|
|
90
|
+
stripes.push({ snap, store, buffer });
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
(0, assert_1.default)(false, 'packer: bad STORE_LINKS');
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
else if (store === common_1.STORE_STAT) {
|
|
97
|
+
if (typeof value === 'object') {
|
|
98
|
+
const newStat = { ...value };
|
|
99
|
+
const buffer = Buffer.from(JSON.stringify(newStat));
|
|
100
|
+
stripes.push({ snap, store, buffer });
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
(0, assert_1.default)(false, 'packer: unknown store');
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
if (record[common_1.STORE_CONTENT]) {
|
|
107
|
+
const disclosed = (0, common_1.isDotJS)(file) || (0, common_1.isDotJSON)(file);
|
|
108
|
+
log_1.log.debug(disclosed
|
|
109
|
+
? 'The file was included as DISCLOSED code (with sources)'
|
|
110
|
+
: 'The file was included as asset content', file);
|
|
111
|
+
}
|
|
112
|
+
else if (record[common_1.STORE_BLOB]) {
|
|
113
|
+
log_1.log.debug('The file was included as bytecode (no sources)', file);
|
|
114
|
+
}
|
|
115
|
+
else if (record[common_1.STORE_LINKS]) {
|
|
116
|
+
const link = record[common_1.STORE_LINKS];
|
|
117
|
+
log_1.log.debug(`The directory files list was included (${itemsToText(link)})`, file);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
const prelude = `return (function (REQUIRE_COMMON, VIRTUAL_FILESYSTEM, DEFAULT_ENTRYPOINT, SYMLINKS, DICT, DOCOMPRESS) {
|
|
123
|
+
${bootstrapText}${log_1.log.debugMode ? diagnosticText : ''}\n})(function (exports) {\n${commonText}\n},\n` +
|
|
124
|
+
`%VIRTUAL_FILESYSTEM%` +
|
|
125
|
+
`\n,\n` +
|
|
126
|
+
`%DEFAULT_ENTRYPOINT%` +
|
|
127
|
+
`\n,\n` +
|
|
128
|
+
`%SYMLINKS%` +
|
|
129
|
+
'\n,\n' +
|
|
130
|
+
'%DICT%' +
|
|
131
|
+
'\n,\n' +
|
|
132
|
+
'%DOCOMPRESS%' +
|
|
133
|
+
`\n);`;
|
|
134
|
+
return { prelude, entrypoint, stripes };
|
|
135
|
+
}
|
|
136
|
+
exports.default = packer;
|
|
137
|
+
//# sourceMappingURL=packer.js.map
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Windows PE Metadata Injection
|
|
4
|
+
*
|
|
5
|
+
* Injects VERSIONINFO resources and optionally an application icon
|
|
6
|
+
* into Windows PE executables (.exe) using resedit.
|
|
7
|
+
*
|
|
8
|
+
* This runs after packaging but before Authenticode signing (signing
|
|
9
|
+
* must be the last step since it covers the entire file).
|
|
10
|
+
*
|
|
11
|
+
* Environment: resedit is a pure-JS PE resource editor that works
|
|
12
|
+
* cross-platform — metadata can be injected from macOS/Linux too.
|
|
13
|
+
*/
|
|
14
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
15
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
16
|
+
};
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.injectPeMetadata = void 0;
|
|
19
|
+
const fs_1 = __importDefault(require("fs"));
|
|
20
|
+
const log_1 = require("./log");
|
|
21
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
22
|
+
// Version parsing
|
|
23
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
24
|
+
function parseVersionQuad(v) {
|
|
25
|
+
const parts = v.split('.').map(Number);
|
|
26
|
+
return [
|
|
27
|
+
parts[0] || 0,
|
|
28
|
+
parts[1] || 0,
|
|
29
|
+
parts[2] || 0,
|
|
30
|
+
parts[3] || 0,
|
|
31
|
+
];
|
|
32
|
+
}
|
|
33
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
34
|
+
// Injection
|
|
35
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
36
|
+
/**
|
|
37
|
+
* Inject metadata into a Windows PE executable.
|
|
38
|
+
*
|
|
39
|
+
* Modifies the file in-place. Must be called BEFORE Authenticode
|
|
40
|
+
* signing (signing covers the entire file including resources).
|
|
41
|
+
*
|
|
42
|
+
* Uses dynamic import for resedit (ESM-only in v3). If resedit is
|
|
43
|
+
* not installed, throws a clear error.
|
|
44
|
+
*/
|
|
45
|
+
async function injectPeMetadata(exePath, metadata) {
|
|
46
|
+
// Load resedit dynamically (ESM package with CJS shim)
|
|
47
|
+
let resedit;
|
|
48
|
+
try {
|
|
49
|
+
const cjsEntry = require.resolve('resedit/cjs');
|
|
50
|
+
const { load } = require(cjsEntry);
|
|
51
|
+
resedit = await load();
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
throw new Error('Cannot inject PE metadata: resedit is not installed.\n' +
|
|
55
|
+
'Install it with: pnpm add resedit\n' +
|
|
56
|
+
'resedit is a pure-JS PE resource editor that works cross-platform.');
|
|
57
|
+
}
|
|
58
|
+
const { NtExecutable, NtExecutableResource, Resource, Data } = resedit;
|
|
59
|
+
// Read the executable
|
|
60
|
+
const exeData = fs_1.default.readFileSync(exePath);
|
|
61
|
+
const exe = NtExecutable.from(exeData);
|
|
62
|
+
const res = NtExecutableResource.from(exe);
|
|
63
|
+
// ── Version info ──
|
|
64
|
+
if (metadata.fileVersion || metadata.productVersion || metadata.productName ||
|
|
65
|
+
metadata.fileDescription || metadata.companyName || metadata.legalCopyright) {
|
|
66
|
+
// Get existing version info or create new
|
|
67
|
+
const viList = Resource.VersionInfo.fromEntries(res.entries);
|
|
68
|
+
let vi;
|
|
69
|
+
if (viList.length > 0) {
|
|
70
|
+
vi = viList[0];
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
vi = Resource.VersionInfo.createEmpty();
|
|
74
|
+
}
|
|
75
|
+
const lang = 0x0409; // English (US)
|
|
76
|
+
const codepage = 0x04B0; // Unicode
|
|
77
|
+
if (metadata.fileVersion) {
|
|
78
|
+
const [a, b, c, d] = parseVersionQuad(metadata.fileVersion);
|
|
79
|
+
vi.setFileVersion(a, b, c, d, lang);
|
|
80
|
+
}
|
|
81
|
+
if (metadata.productVersion || metadata.fileVersion) {
|
|
82
|
+
const ver = metadata.productVersion || metadata.fileVersion;
|
|
83
|
+
const [a, b, c, d] = parseVersionQuad(ver);
|
|
84
|
+
vi.setProductVersion(a, b, c, d, lang);
|
|
85
|
+
}
|
|
86
|
+
const strings = {};
|
|
87
|
+
if (metadata.fileDescription)
|
|
88
|
+
strings.FileDescription = metadata.fileDescription;
|
|
89
|
+
if (metadata.productName)
|
|
90
|
+
strings.ProductName = metadata.productName;
|
|
91
|
+
if (metadata.companyName)
|
|
92
|
+
strings.CompanyName = metadata.companyName;
|
|
93
|
+
if (metadata.legalCopyright)
|
|
94
|
+
strings.LegalCopyright = metadata.legalCopyright;
|
|
95
|
+
if (metadata.fileVersion)
|
|
96
|
+
strings.FileVersion = metadata.fileVersion;
|
|
97
|
+
if (metadata.productVersion || metadata.fileVersion) {
|
|
98
|
+
strings.ProductVersion = metadata.productVersion || metadata.fileVersion;
|
|
99
|
+
}
|
|
100
|
+
if (Object.keys(strings).length > 0) {
|
|
101
|
+
vi.setStringValues({ lang, codepage }, strings);
|
|
102
|
+
}
|
|
103
|
+
vi.outputToResourceEntries(res.entries);
|
|
104
|
+
}
|
|
105
|
+
// ── Icon ──
|
|
106
|
+
if (metadata.icon) {
|
|
107
|
+
if (!fs_1.default.existsSync(metadata.icon)) {
|
|
108
|
+
throw new Error(`Icon file not found: ${metadata.icon}`);
|
|
109
|
+
}
|
|
110
|
+
const iconData = fs_1.default.readFileSync(metadata.icon);
|
|
111
|
+
const iconFile = Data.IconFile.from(iconData);
|
|
112
|
+
// Remove existing icon groups and add new one
|
|
113
|
+
Resource.IconGroupEntry.replaceIconsForResource(res.entries, 1, // resource ID
|
|
114
|
+
0x0409, iconFile.icons.map((icon) => icon.data));
|
|
115
|
+
}
|
|
116
|
+
// Write back
|
|
117
|
+
res.outputResource(exe);
|
|
118
|
+
const output = exe.generate();
|
|
119
|
+
fs_1.default.writeFileSync(exePath, Buffer.from(output));
|
|
120
|
+
const fields = [];
|
|
121
|
+
if (metadata.productName)
|
|
122
|
+
fields.push(`product="${metadata.productName}"`);
|
|
123
|
+
if (metadata.fileVersion)
|
|
124
|
+
fields.push(`version=${metadata.fileVersion}`);
|
|
125
|
+
if (metadata.icon)
|
|
126
|
+
fields.push('icon=embedded');
|
|
127
|
+
log_1.log.info(`Injected PE metadata: ${fields.join(', ')}`);
|
|
128
|
+
}
|
|
129
|
+
exports.injectPeMetadata = injectPeMetadata;
|
|
130
|
+
//# sourceMappingURL=pe-metadata.js.map
|
|
@@ -0,0 +1,378 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const zlib_1 = require("zlib");
|
|
7
|
+
const multistream_1 = __importDefault(require("multistream"));
|
|
8
|
+
const assert_1 = __importDefault(require("assert"));
|
|
9
|
+
const child_process_1 = require("child_process");
|
|
10
|
+
const fs_1 = __importDefault(require("fs"));
|
|
11
|
+
const into_stream_1 = __importDefault(require("into-stream"));
|
|
12
|
+
const path_1 = __importDefault(require("path"));
|
|
13
|
+
const stream_meter_1 = __importDefault(require("stream-meter"));
|
|
14
|
+
const common_1 = require("./common");
|
|
15
|
+
const log_1 = require("./log");
|
|
16
|
+
const fabricator_1 = require("./fabricator");
|
|
17
|
+
const types_1 = require("./types");
|
|
18
|
+
const compress_type_1 = require("./compress_type");
|
|
19
|
+
function discoverPlaceholder(binaryBuffer, searchString, padder, searchOffset = 0) {
|
|
20
|
+
const placeholder = Buffer.from(searchString);
|
|
21
|
+
const position = binaryBuffer.indexOf(placeholder, searchOffset);
|
|
22
|
+
if (position === -1) {
|
|
23
|
+
return { notFound: true };
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* the PAYLOAD/PRELUDE placeholders can occur twice in the binaries:
|
|
27
|
+
* - in source text as a string literal
|
|
28
|
+
* - in bytecode as a raw string
|
|
29
|
+
* the ordering depends on the platform - we need to make sure that
|
|
30
|
+
* the bytecode string is replaced, not the source literal.
|
|
31
|
+
*
|
|
32
|
+
* this rejects the source code literal if it occurs first in the binary
|
|
33
|
+
* also see: https://github.com/yao-pkg/pkg/pull/86
|
|
34
|
+
*/
|
|
35
|
+
if (binaryBuffer[position - 1] === 39 /* ascii for ' APOSTROPHE */) {
|
|
36
|
+
const nextPlaceholder = discoverPlaceholder(binaryBuffer, searchString, padder, position + placeholder.length);
|
|
37
|
+
if (!('notFound' in nextPlaceholder)) {
|
|
38
|
+
return nextPlaceholder;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return { position, size: placeholder.length, padder };
|
|
42
|
+
}
|
|
43
|
+
function injectPlaceholder(fd, placeholder, value, cb) {
|
|
44
|
+
if ('notFound' in placeholder) {
|
|
45
|
+
(0, assert_1.default)(false, 'Placeholder for not found');
|
|
46
|
+
}
|
|
47
|
+
const { position, size, padder } = placeholder;
|
|
48
|
+
let stringValue = Buffer.from('');
|
|
49
|
+
if (typeof value === 'number') {
|
|
50
|
+
stringValue = Buffer.from(value.toString());
|
|
51
|
+
}
|
|
52
|
+
else if (typeof value === 'string') {
|
|
53
|
+
stringValue = Buffer.from(value);
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
stringValue = value;
|
|
57
|
+
}
|
|
58
|
+
const padding = Buffer.from(padder.repeat(size - stringValue.length));
|
|
59
|
+
stringValue = Buffer.concat([stringValue, padding]);
|
|
60
|
+
fs_1.default.write(fd, stringValue, 0, stringValue.length, position, cb);
|
|
61
|
+
}
|
|
62
|
+
function discoverPlaceholders(binaryBuffer) {
|
|
63
|
+
return {
|
|
64
|
+
BAKERY: discoverPlaceholder(binaryBuffer, `\0${'// BAKERY '.repeat(20)}`, '\0'),
|
|
65
|
+
PAYLOAD_POSITION: discoverPlaceholder(binaryBuffer, '// PAYLOAD_POSITION //', ' '),
|
|
66
|
+
PAYLOAD_SIZE: discoverPlaceholder(binaryBuffer, '// PAYLOAD_SIZE //', ' '),
|
|
67
|
+
PRELUDE_POSITION: discoverPlaceholder(binaryBuffer, '// PRELUDE_POSITION //', ' '),
|
|
68
|
+
PRELUDE_SIZE: discoverPlaceholder(binaryBuffer, '// PRELUDE_SIZE //', ' '),
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
function injectPlaceholders(fd, placeholders, values, cb) {
|
|
72
|
+
injectPlaceholder(fd, placeholders.BAKERY, values.BAKERY, (error) => {
|
|
73
|
+
if (error) {
|
|
74
|
+
return cb(error);
|
|
75
|
+
}
|
|
76
|
+
injectPlaceholder(fd, placeholders.PAYLOAD_POSITION, values.PAYLOAD_POSITION, (error2) => {
|
|
77
|
+
if (error2) {
|
|
78
|
+
return cb(error2);
|
|
79
|
+
}
|
|
80
|
+
injectPlaceholder(fd, placeholders.PAYLOAD_SIZE, values.PAYLOAD_SIZE, (error3) => {
|
|
81
|
+
if (error3) {
|
|
82
|
+
return cb(error3);
|
|
83
|
+
}
|
|
84
|
+
injectPlaceholder(fd, placeholders.PRELUDE_POSITION, values.PRELUDE_POSITION, (error4) => {
|
|
85
|
+
if (error4) {
|
|
86
|
+
return cb(error4);
|
|
87
|
+
}
|
|
88
|
+
injectPlaceholder(fd, placeholders.PRELUDE_SIZE, values.PRELUDE_SIZE, cb);
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
function makeBakeryValueFromBakes(bakes) {
|
|
95
|
+
const parts = [];
|
|
96
|
+
if (bakes.length) {
|
|
97
|
+
for (let i = 0; i < bakes.length; i += 1) {
|
|
98
|
+
parts.push(Buffer.from(bakes[i]));
|
|
99
|
+
parts.push(Buffer.alloc(1));
|
|
100
|
+
}
|
|
101
|
+
parts.push(Buffer.alloc(1));
|
|
102
|
+
}
|
|
103
|
+
return Buffer.concat(parts);
|
|
104
|
+
}
|
|
105
|
+
function replaceDollarWise(s, sf, st) {
|
|
106
|
+
return s.replace(sf, () => st);
|
|
107
|
+
}
|
|
108
|
+
function makePreludeBufferFromPrelude(prelude) {
|
|
109
|
+
return Buffer.from(`(function(process, require, console, EXECPATH_FD, PAYLOAD_POSITION, PAYLOAD_SIZE) { ${prelude}\n})`);
|
|
110
|
+
}
|
|
111
|
+
function findPackageJson(nodeFile) {
|
|
112
|
+
let dir = nodeFile;
|
|
113
|
+
while (dir !== '/') {
|
|
114
|
+
dir = path_1.default.dirname(dir);
|
|
115
|
+
if (fs_1.default.existsSync(path_1.default.join(dir, 'package.json'))) {
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
if (dir === '/') {
|
|
120
|
+
throw new Error(`package.json not found for "${nodeFile}"`);
|
|
121
|
+
}
|
|
122
|
+
return dir;
|
|
123
|
+
}
|
|
124
|
+
function getPrebuildEnvPrefix(pkgName) {
|
|
125
|
+
return `npm_config_${(pkgName || '')
|
|
126
|
+
.replace(/[^a-zA-Z0-9]/g, '_')
|
|
127
|
+
.replace(/^_/, '')}`;
|
|
128
|
+
}
|
|
129
|
+
function nativePrebuildInstall(target, nodeFile) {
|
|
130
|
+
const prebuildInstall = path_1.default.join(__dirname, '../node_modules/.bin/prebuild-install');
|
|
131
|
+
const dir = findPackageJson(nodeFile);
|
|
132
|
+
const packageJson = JSON.parse(fs_1.default.readFileSync(path_1.default.join(dir, 'package.json'), { encoding: 'utf-8' }));
|
|
133
|
+
// only try prebuild-install for packages that actually use it or if
|
|
134
|
+
// explicitly configured via environment variables
|
|
135
|
+
const envPrefix = getPrebuildEnvPrefix(packageJson.name);
|
|
136
|
+
if (packageJson.dependencies?.['prebuild-install'] == null &&
|
|
137
|
+
![
|
|
138
|
+
`${envPrefix}_binary_host`,
|
|
139
|
+
`${envPrefix}_binary_host_mirror`,
|
|
140
|
+
`${envPrefix}_local_prebuilds`,
|
|
141
|
+
].some((i) => i in process.env)) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
// parse the target node version from the binaryPath
|
|
145
|
+
const nodeVersion = path_1.default.basename(target.binaryPath).split('-')[1];
|
|
146
|
+
if (!/^v[0-9]+\.[0-9]+\.[0-9]+$/.test(nodeVersion)) {
|
|
147
|
+
throw new Error(`Couldn't find node version, instead got: ${nodeVersion}`);
|
|
148
|
+
}
|
|
149
|
+
const nativeFile = `${nodeFile}.${target.platform}.${target.arch}.${nodeVersion}`;
|
|
150
|
+
if (fs_1.default.existsSync(nativeFile)) {
|
|
151
|
+
return nativeFile;
|
|
152
|
+
}
|
|
153
|
+
// prebuild-install will overwrite the target .node file, so take a backup
|
|
154
|
+
if (!fs_1.default.existsSync(`${nodeFile}.bak`)) {
|
|
155
|
+
fs_1.default.copyFileSync(nodeFile, `${nodeFile}.bak`);
|
|
156
|
+
}
|
|
157
|
+
const napiVersions = packageJson?.binary?.napi_versions;
|
|
158
|
+
const options = [
|
|
159
|
+
'--platform',
|
|
160
|
+
types_1.platform[target.platform],
|
|
161
|
+
'--arch',
|
|
162
|
+
target.arch,
|
|
163
|
+
];
|
|
164
|
+
if (napiVersions == null) {
|
|
165
|
+
// TODO: consider target node version and supported n-api version
|
|
166
|
+
options.push('--target', nodeVersion);
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
options.push('--runtime', 'napi');
|
|
170
|
+
}
|
|
171
|
+
// run prebuild
|
|
172
|
+
(0, child_process_1.execFileSync)(prebuildInstall, options, { cwd: dir });
|
|
173
|
+
// move the prebuild to a new name with a platform/version extension
|
|
174
|
+
fs_1.default.copyFileSync(nodeFile, nativeFile);
|
|
175
|
+
// put the backed up file back
|
|
176
|
+
fs_1.default.renameSync(`${nodeFile}.bak`, nodeFile);
|
|
177
|
+
return nativeFile;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* instead of creating a vfs dicionnary with actual path as key
|
|
181
|
+
* we use a compression mechanism that can reduce significantly
|
|
182
|
+
* the memory footprint of the vfs in the code.
|
|
183
|
+
*
|
|
184
|
+
* without vfs compression:
|
|
185
|
+
*
|
|
186
|
+
* vfs = {
|
|
187
|
+
* "/folder1/folder2/file1.js": {};
|
|
188
|
+
* "/folder1/folder2/folder3/file2.js": {};
|
|
189
|
+
* "/folder1/folder2/folder3/file3.js": {};
|
|
190
|
+
* }
|
|
191
|
+
*
|
|
192
|
+
* with compression :
|
|
193
|
+
*
|
|
194
|
+
* fileDictionary = {
|
|
195
|
+
* "folder1": "1",
|
|
196
|
+
* "folder2": "2",
|
|
197
|
+
* "file1": "3",
|
|
198
|
+
* "folder3": "4",
|
|
199
|
+
* "file2": "5",
|
|
200
|
+
* "file3": "6",
|
|
201
|
+
* }
|
|
202
|
+
* vfs = {
|
|
203
|
+
* "/1/2/3": {};
|
|
204
|
+
* "/1/2/4/5": {};
|
|
205
|
+
* "/1/2/4/6": {};
|
|
206
|
+
* }
|
|
207
|
+
*
|
|
208
|
+
* note: the key is computed in base36 for further compression.
|
|
209
|
+
*/
|
|
210
|
+
const fileDictionary = {};
|
|
211
|
+
let counter = 0;
|
|
212
|
+
function getOrCreateHash(fileOrFolderName) {
|
|
213
|
+
let existingKey = fileDictionary[fileOrFolderName];
|
|
214
|
+
if (!existingKey) {
|
|
215
|
+
const newkey = counter;
|
|
216
|
+
counter += 1;
|
|
217
|
+
existingKey = newkey.toString(36);
|
|
218
|
+
fileDictionary[fileOrFolderName] = existingKey;
|
|
219
|
+
}
|
|
220
|
+
return existingKey;
|
|
221
|
+
}
|
|
222
|
+
const separator = '/';
|
|
223
|
+
function makeKey(doCompression, fullpath, slash) {
|
|
224
|
+
if (doCompression === compress_type_1.CompressType.None)
|
|
225
|
+
return fullpath;
|
|
226
|
+
return fullpath.split(slash).map(getOrCreateHash).join(separator);
|
|
227
|
+
}
|
|
228
|
+
function producer({ backpack, bakes, slash, target, symLinks, doCompress, nativeBuild, }) {
|
|
229
|
+
return new Promise((resolve, reject) => {
|
|
230
|
+
if (!Buffer.alloc) {
|
|
231
|
+
throw (0, log_1.wasReported)('Your node.js does not have Buffer.alloc. Please upgrade!');
|
|
232
|
+
}
|
|
233
|
+
const { prelude } = backpack;
|
|
234
|
+
let { entrypoint, stripes } = backpack;
|
|
235
|
+
entrypoint = (0, common_1.snapshotify)(entrypoint, slash);
|
|
236
|
+
stripes = stripes.slice();
|
|
237
|
+
const vfs = {};
|
|
238
|
+
for (const stripe of stripes) {
|
|
239
|
+
let { snap } = stripe;
|
|
240
|
+
snap = (0, common_1.snapshotify)(snap, slash);
|
|
241
|
+
const vfsKey = makeKey(doCompress, snap, slash);
|
|
242
|
+
if (!vfs[vfsKey])
|
|
243
|
+
vfs[vfsKey] = {};
|
|
244
|
+
}
|
|
245
|
+
const snapshotSymLinks = {};
|
|
246
|
+
for (const [key, value] of Object.entries(symLinks)) {
|
|
247
|
+
const k = (0, common_1.snapshotify)(key, slash);
|
|
248
|
+
const v = (0, common_1.snapshotify)(value, slash);
|
|
249
|
+
const vfsKey = makeKey(doCompress, k, slash);
|
|
250
|
+
snapshotSymLinks[vfsKey] = makeKey(doCompress, v, slash);
|
|
251
|
+
}
|
|
252
|
+
let meter;
|
|
253
|
+
let count = 0;
|
|
254
|
+
function pipeToNewMeter(s) {
|
|
255
|
+
meter = (0, stream_meter_1.default)();
|
|
256
|
+
return s.pipe(meter);
|
|
257
|
+
}
|
|
258
|
+
function pipeMayCompressToNewMeter(s) {
|
|
259
|
+
if (doCompress === compress_type_1.CompressType.GZip) {
|
|
260
|
+
return pipeToNewMeter(s.pipe((0, zlib_1.createGzip)()));
|
|
261
|
+
}
|
|
262
|
+
if (doCompress === compress_type_1.CompressType.Brotli) {
|
|
263
|
+
return pipeToNewMeter(s.pipe((0, zlib_1.createBrotliCompress)()));
|
|
264
|
+
}
|
|
265
|
+
return pipeToNewMeter(s);
|
|
266
|
+
}
|
|
267
|
+
function next(s) {
|
|
268
|
+
count += 1;
|
|
269
|
+
return pipeToNewMeter(s);
|
|
270
|
+
}
|
|
271
|
+
const binaryBuffer = fs_1.default.readFileSync(target.binaryPath);
|
|
272
|
+
const placeholders = discoverPlaceholders(binaryBuffer);
|
|
273
|
+
let track = 0;
|
|
274
|
+
let prevStripe;
|
|
275
|
+
let payloadPosition;
|
|
276
|
+
let payloadSize;
|
|
277
|
+
let preludePosition;
|
|
278
|
+
let preludeSize;
|
|
279
|
+
new multistream_1.default((cb) => {
|
|
280
|
+
if (count === 0) {
|
|
281
|
+
return cb(null, next((0, into_stream_1.default)(binaryBuffer)));
|
|
282
|
+
}
|
|
283
|
+
if (count === 1) {
|
|
284
|
+
payloadPosition = meter.bytes;
|
|
285
|
+
return cb(null, next((0, into_stream_1.default)(Buffer.alloc(0))));
|
|
286
|
+
}
|
|
287
|
+
if (count === 2) {
|
|
288
|
+
if (prevStripe && !prevStripe.skip) {
|
|
289
|
+
const { store } = prevStripe;
|
|
290
|
+
let { snap } = prevStripe;
|
|
291
|
+
snap = (0, common_1.snapshotify)(snap, slash);
|
|
292
|
+
const vfsKey = makeKey(doCompress, snap, slash);
|
|
293
|
+
vfs[vfsKey][store] = [track, meter.bytes];
|
|
294
|
+
track += meter.bytes;
|
|
295
|
+
}
|
|
296
|
+
if (stripes.length) {
|
|
297
|
+
// clone to prevent 'skip' propagate
|
|
298
|
+
// to other targets, since same stripe
|
|
299
|
+
// is used for several targets
|
|
300
|
+
const stripe = { ...stripes.shift() };
|
|
301
|
+
prevStripe = stripe;
|
|
302
|
+
if (stripe.buffer) {
|
|
303
|
+
if (stripe.store === common_1.STORE_BLOB) {
|
|
304
|
+
const snap = (0, common_1.snapshotify)(stripe.snap, slash);
|
|
305
|
+
return (0, fabricator_1.fabricateTwice)(bakes, target.fabricator, snap, stripe.buffer, (error, buffer) => {
|
|
306
|
+
if (error) {
|
|
307
|
+
log_1.log.warn(error.message);
|
|
308
|
+
stripe.skip = true;
|
|
309
|
+
return cb(null, (0, into_stream_1.default)(Buffer.alloc(0)));
|
|
310
|
+
}
|
|
311
|
+
cb(null, pipeMayCompressToNewMeter((0, into_stream_1.default)(buffer || Buffer.from(''))));
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
return cb(null, pipeMayCompressToNewMeter((0, into_stream_1.default)(stripe.buffer)));
|
|
315
|
+
}
|
|
316
|
+
if (stripe.file) {
|
|
317
|
+
if (stripe.file === target.output) {
|
|
318
|
+
return cb((0, log_1.wasReported)('Trying to take executable into executable', stripe.file), null);
|
|
319
|
+
}
|
|
320
|
+
assert_1.default.strictEqual(stripe.store, common_1.STORE_CONTENT); // others must be buffers from walker
|
|
321
|
+
if ((0, common_1.isDotNODE)(stripe.file) && nativeBuild) {
|
|
322
|
+
try {
|
|
323
|
+
const platformFile = nativePrebuildInstall(target, stripe.file);
|
|
324
|
+
if (platformFile && fs_1.default.existsSync(platformFile)) {
|
|
325
|
+
return cb(null, pipeMayCompressToNewMeter(fs_1.default.createReadStream(platformFile)));
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
catch (err) {
|
|
329
|
+
log_1.log.debug(`prebuild-install failed[${stripe.file}]:`, err.message);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
return cb(null, pipeMayCompressToNewMeter(fs_1.default.createReadStream(stripe.file)));
|
|
333
|
+
}
|
|
334
|
+
(0, assert_1.default)(false, 'producer: bad stripe');
|
|
335
|
+
}
|
|
336
|
+
else {
|
|
337
|
+
payloadSize = track;
|
|
338
|
+
preludePosition = payloadPosition + payloadSize;
|
|
339
|
+
return cb(null, next((0, into_stream_1.default)(makePreludeBufferFromPrelude(replaceDollarWise(replaceDollarWise(replaceDollarWise(replaceDollarWise(replaceDollarWise(prelude, '%VIRTUAL_FILESYSTEM%', JSON.stringify(vfs)), '%DEFAULT_ENTRYPOINT%', JSON.stringify(entrypoint)), '%SYMLINKS%', JSON.stringify(snapshotSymLinks)), '%DICT%', JSON.stringify(fileDictionary)), '%DOCOMPRESS%', JSON.stringify(doCompress))))));
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
else {
|
|
343
|
+
return cb(null, null);
|
|
344
|
+
}
|
|
345
|
+
})
|
|
346
|
+
.on('error', (error) => {
|
|
347
|
+
reject(error);
|
|
348
|
+
})
|
|
349
|
+
.pipe(fs_1.default.createWriteStream(target.output))
|
|
350
|
+
.on('error', (error) => {
|
|
351
|
+
reject(error);
|
|
352
|
+
})
|
|
353
|
+
.on('close', () => {
|
|
354
|
+
preludeSize = meter.bytes;
|
|
355
|
+
fs_1.default.open(target.output, 'r+', (error, fd) => {
|
|
356
|
+
if (error)
|
|
357
|
+
return reject(error);
|
|
358
|
+
injectPlaceholders(fd, placeholders, {
|
|
359
|
+
BAKERY: makeBakeryValueFromBakes(bakes),
|
|
360
|
+
PAYLOAD_POSITION: payloadPosition,
|
|
361
|
+
PAYLOAD_SIZE: payloadSize,
|
|
362
|
+
PRELUDE_POSITION: preludePosition,
|
|
363
|
+
PRELUDE_SIZE: preludeSize,
|
|
364
|
+
}, (error2) => {
|
|
365
|
+
if (error2)
|
|
366
|
+
return reject(error2);
|
|
367
|
+
fs_1.default.close(fd, (error3) => {
|
|
368
|
+
if (error3)
|
|
369
|
+
return reject(error3);
|
|
370
|
+
resolve();
|
|
371
|
+
});
|
|
372
|
+
});
|
|
373
|
+
});
|
|
374
|
+
});
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
exports.default = producer;
|
|
378
|
+
//# sourceMappingURL=producer.js.map
|