@orkestrel/sea 0.0.4 → 0.0.5
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.
|
@@ -519,7 +519,8 @@ function stripPESignature(path) {
|
|
|
519
519
|
if (certOffset <= fileSize && certOffset + certSize === fileSize) (0, node_fs.ftruncateSync)(fd, certOffset);
|
|
520
520
|
}
|
|
521
521
|
}
|
|
522
|
-
|
|
522
|
+
const zeroes = Buffer.alloc(8);
|
|
523
|
+
(0, node_fs.writeSync)(fd, zeroes, 0, 8, securityDirOffset);
|
|
523
524
|
} finally {
|
|
524
525
|
(0, node_fs.closeSync)(fd);
|
|
525
526
|
}
|
|
@@ -600,8 +601,8 @@ function createSignCommand(sign, target) {
|
|
|
600
601
|
*/
|
|
601
602
|
function formatSize(bytes) {
|
|
602
603
|
if (bytes < 1024) return `${String(bytes)} B`;
|
|
603
|
-
if (bytes <
|
|
604
|
-
return `${(bytes /
|
|
604
|
+
if (bytes < 1048576) return `${(bytes / 1024).toFixed(1)} KB`;
|
|
605
|
+
return `${(bytes / 1048576).toFixed(2)} MB`;
|
|
605
606
|
}
|
|
606
607
|
/**
|
|
607
608
|
* Assert that an asset key is safe to use as a relative filesystem/archive key.
|
|
@@ -891,7 +892,7 @@ function buildELFNoteHeader(resource, blobSize) {
|
|
|
891
892
|
* copyRange(srcFd, dstFd, 1024, 4096)
|
|
892
893
|
* ```
|
|
893
894
|
*/
|
|
894
|
-
function copyRange(source, target, start, length, chunk =
|
|
895
|
+
function copyRange(source, target, start, length, chunk = 4194304) {
|
|
895
896
|
if (length <= 0) return;
|
|
896
897
|
const bufferSize = Math.min(chunk, length);
|
|
897
898
|
const buffer = Buffer.alloc(bufferSize);
|
|
@@ -925,7 +926,7 @@ function patchSentinelFuse(executable, fuse) {
|
|
|
925
926
|
const fd = (0, node_fs.openSync)(executable, "r+");
|
|
926
927
|
try {
|
|
927
928
|
const needle = Buffer.from(fuse, "utf-8");
|
|
928
|
-
const chunkSize =
|
|
929
|
+
const chunkSize = 67108864;
|
|
929
930
|
const readSize = chunkSize + needle.length;
|
|
930
931
|
const buffer = Buffer.alloc(readSize);
|
|
931
932
|
let offset = 0;
|
|
@@ -1030,9 +1031,7 @@ var Injector = class {
|
|
|
1030
1031
|
case "elf":
|
|
1031
1032
|
this.#injectElf();
|
|
1032
1033
|
break;
|
|
1033
|
-
case "macho":
|
|
1034
|
-
this.#injectMacho();
|
|
1035
|
-
break;
|
|
1034
|
+
case "macho": this.#injectMacho();
|
|
1036
1035
|
}
|
|
1037
1036
|
if (this.#options.fuse !== void 0) patchSentinelFuse(this.#options.executable, this.#options.fuse);
|
|
1038
1037
|
if (peOptionalOffset !== void 0) this.#patchChecksum(peOptionalOffset);
|
|
@@ -1485,12 +1484,13 @@ var Injector = class {
|
|
|
1485
1484
|
const fd = (0, node_fs.openSync)(this.#options.executable, "r+");
|
|
1486
1485
|
try {
|
|
1487
1486
|
const fileSize = (0, node_fs.statSync)(this.#options.executable).size;
|
|
1488
|
-
const chunkSize =
|
|
1487
|
+
const chunkSize = 4194304;
|
|
1489
1488
|
const chunk = Buffer.alloc(Math.min(chunkSize, fileSize));
|
|
1490
1489
|
let sum = 0;
|
|
1491
1490
|
let offset = 0;
|
|
1492
1491
|
while (offset < fileSize) {
|
|
1493
|
-
const
|
|
1492
|
+
const toRead = Math.min(chunkSize, fileSize - offset);
|
|
1493
|
+
const bytesRead = (0, node_fs.readSync)(fd, chunk, 0, toRead, offset);
|
|
1494
1494
|
if (bytesRead === 0) break;
|
|
1495
1495
|
for (let i = 0; i < bytesRead; i += 2) {
|
|
1496
1496
|
const absolute = offset + i;
|
|
@@ -1981,14 +1981,15 @@ var Injector = class {
|
|
|
1981
1981
|
}
|
|
1982
1982
|
/** Append sourceFile to targetFile by streaming in 4 MB chunks */
|
|
1983
1983
|
#appendFile(targetPath, sourcePath) {
|
|
1984
|
-
const chunkSize =
|
|
1984
|
+
const chunkSize = 4194304;
|
|
1985
1985
|
const srcFd = (0, node_fs.openSync)(sourcePath, "r");
|
|
1986
1986
|
try {
|
|
1987
1987
|
const srcSize = (0, node_fs.statSync)(sourcePath).size;
|
|
1988
1988
|
const chunk = Buffer.alloc(Math.min(chunkSize, srcSize));
|
|
1989
1989
|
let offset = 0;
|
|
1990
1990
|
while (offset < srcSize) {
|
|
1991
|
-
const
|
|
1991
|
+
const toRead = Math.min(chunkSize, srcSize - offset);
|
|
1992
|
+
const bytesRead = (0, node_fs.readSync)(srcFd, chunk, 0, toRead, offset);
|
|
1992
1993
|
if (bytesRead === 0) break;
|
|
1993
1994
|
(0, node_fs.appendFileSync)(targetPath, chunk.subarray(0, bytesRead));
|
|
1994
1995
|
offset += bytesRead;
|
|
@@ -2099,7 +2100,8 @@ var SEA = class {
|
|
|
2099
2100
|
const directories = [];
|
|
2100
2101
|
let total = 0;
|
|
2101
2102
|
for (const path of compression.paths) {
|
|
2102
|
-
|
|
2103
|
+
const candidate = (0, node_path.resolve)(root, path);
|
|
2104
|
+
if (!(0, node_fs.existsSync)(candidate)) continue;
|
|
2103
2105
|
this.#check();
|
|
2104
2106
|
const directory = ensureContained(root, path);
|
|
2105
2107
|
directories.push(directory);
|
|
@@ -2163,7 +2165,8 @@ var SEA = class {
|
|
|
2163
2165
|
if (platform === void 0) throw new SEAError("PLATFORM", `Unsupported platform: ${process.platform}`, { platform: process.platform });
|
|
2164
2166
|
const output = (0, node_path.resolve)(root, this.#options.output);
|
|
2165
2167
|
const ext = process.platform === "win32" ? ".exe" : "";
|
|
2166
|
-
const
|
|
2168
|
+
const name = process.platform === "win32" ? `${this.#options.name}.exe` : this.#options.name;
|
|
2169
|
+
const finalOutput = (0, node_path.join)(output, name);
|
|
2167
2170
|
const temp = (0, node_path.join)(output, `.${this.#options.name}-${(0, node_crypto.randomUUID)()}.tmp${ext}`);
|
|
2168
2171
|
const shell = this.#options.signal === void 0 ? {} : { signal: this.#options.signal };
|
|
2169
2172
|
let signed = false;
|