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