@poe-platform/safe-bash 0.1.773 → 0.1.774
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/image-ast/index.browser.js +742 -150
- package/dist/image-ast/index.js +742 -150
- package/dist/pdf-ast/index.js +742 -150
- package/dist/pdf-ast/vendor/pdfjs-fonts.d.mts +12 -0
- package/dist/pdf-ast/vendor/pdfjs-fonts.mjs +702 -0
- package/dist/safe-bash/command-chunks/{chunk-5VXZSNM2.js → chunk-4ZHDCMQX.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-G3NVK25P.js → chunk-HH5QPKIN.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-B2MM5DIT.js → chunk-PM63UJE6.js} +742 -150
- package/dist/safe-bash/core.browser.js +63 -7
- package/dist/safe-bash/shell/runtime.js +17 -9
- package/dist/safe-bash/shell/sync-posix-regex.d.ts +3 -0
- package/dist/safe-bash/shell/sync-posix-regex.js +48 -0
- package/dist/safe-bash-command-ffmpeg/index.js +7250 -7046
- package/dist/safe-bash-command-gpg/index.js +28 -7
- package/dist/safe-bash-command-imagemagick/index.js +2 -2
- package/dist/safe-bash-command-openssl/index.js +24 -6
- package/dist/safe-bash-command-pandoc/command.js +3 -3
- package/dist/safe-bash-command-pandoc/index.js +3 -3
- package/dist/safe-bash-command-pdfimages/index.js +742 -150
- package/dist/safe-bash-command-pdfinfo/index.js +742 -150
- package/dist/safe-bash-command-pdftk/index.js +742 -150
- package/dist/safe-bash-command-pdftoppm/index.js +742 -150
- package/dist/safe-bash-command-pdftotext/index.js +742 -150
- package/dist/safe-bash-command-qpdf/index.js +742 -150
- package/dist/safe-bash-command-sips/index.js +2 -2
- package/dist/safe-bash-command-soffice/index.js +1 -1
- package/dist/safe-bash-command-ssconvert/index.js +742 -150
- package/dist/safe-bash-command-ssh/index.js +124 -23
- package/dist/safe-bash-command-wkhtmltopdf/index.js +748 -150
- package/package.json +2 -2
- package/third-party/pdf-ast/THIRD_PARTY_NOTICES.md +22 -0
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
|
|
5
5
|
// packages/safe-bash-command-gpg/dist/index.js
|
|
6
6
|
init_buffer();
|
|
7
|
-
import { commandRuntimeIdentity, getCommandArguments, readBytes, writeText } from "../safe-bash-contracts/index.js";
|
|
7
|
+
import { FsError, commandRuntimeIdentity, getCommandArguments, readBytes, writeText } from "../safe-bash-contracts/index.js";
|
|
8
8
|
import { PublicDiagnostic } from "../safe-bash-contracts/diagnostics.js";
|
|
9
9
|
import { writeFileOutput } from "../safe-bash-contracts/filesystem-output-budget.js";
|
|
10
10
|
import { yieldTurn } from "../safe-bash-contracts/yield.js";
|
|
@@ -184,7 +184,7 @@ ${crc}
|
|
|
184
184
|
`;
|
|
185
185
|
return { armor, keyIdHex };
|
|
186
186
|
}
|
|
187
|
-
async function verifyOpenPgpDetachedSignature(armor, payload) {
|
|
187
|
+
async function verifyOpenPgpDetachedSignature(armor, payload, keys) {
|
|
188
188
|
const b64 = armor.split("\n").map((l) => l.trim()).filter((l) => !l.startsWith("-----") && !l.startsWith("=") && !l.includes(":") && l.length > 0).join("");
|
|
189
189
|
const pkt = base64ToBytes(b64);
|
|
190
190
|
if (pkt.byteLength < 10 || pkt[0] !== 194) {
|
|
@@ -234,6 +234,13 @@ async function verifyOpenPgpDetachedSignature(armor, payload) {
|
|
|
234
234
|
if (!pubKey || unhashedEnd + 2 + 68 > body.byteLength) {
|
|
235
235
|
return { valid: false, signerUid, keyIdHex };
|
|
236
236
|
}
|
|
237
|
+
const fingerprint = new Uint8Array(await globalThis.crypto.subtle.digest("SHA-256", new Uint8Array(pubKey)));
|
|
238
|
+
const derivedKeyId = bytesToHex(fingerprint.slice(24, 32)).toUpperCase();
|
|
239
|
+
const trustedKey = keys.find((key) => key.keyIdHex === derivedKeyId && key.pubHex.toLowerCase() === bytesToHex(pubKey));
|
|
240
|
+
if (keyIdHex !== derivedKeyId || !trustedKey) {
|
|
241
|
+
return { valid: false, signerUid, keyIdHex };
|
|
242
|
+
}
|
|
243
|
+
signerUid = trustedKey.uid;
|
|
237
244
|
const mpiStart = unhashedEnd + 2;
|
|
238
245
|
const sigBytes = new Uint8Array(64);
|
|
239
246
|
sigBytes.set(body.slice(mpiStart + 2, mpiStart + 34), 0);
|
|
@@ -327,6 +334,20 @@ async function collectSourceBytes(source, maxBytes, signal) {
|
|
|
327
334
|
}
|
|
328
335
|
return result;
|
|
329
336
|
}
|
|
337
|
+
async function readLimitedFile(context, path, maxBytes) {
|
|
338
|
+
try {
|
|
339
|
+
const bytes = await context.fs.readFile(path, { ...maxBytes === Infinity ? {} : { maxBytes }, signal: context.signal });
|
|
340
|
+
if (bytes.byteLength > maxBytes) {
|
|
341
|
+
throw new PublicDiagnostic(`input exceeds maximum buffered size of ${maxBytes} bytes`);
|
|
342
|
+
}
|
|
343
|
+
return bytes;
|
|
344
|
+
} catch (error) {
|
|
345
|
+
if (error instanceof FsError && error.code === "EFBIG") {
|
|
346
|
+
throw new PublicDiagnostic(`input exceeds maximum buffered size of ${maxBytes} bytes`);
|
|
347
|
+
}
|
|
348
|
+
throw error;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
330
351
|
function createGpgCommand(options = {}) {
|
|
331
352
|
const limits = settings(options);
|
|
332
353
|
return {
|
|
@@ -416,7 +437,7 @@ ${bytesToBase64(textEncoder.encode(JSON.stringify(keys)), 64)}
|
|
|
416
437
|
return { exitCode: 0 };
|
|
417
438
|
}
|
|
418
439
|
if (importKeys) {
|
|
419
|
-
const input = positionals[0] ? await context
|
|
440
|
+
const input = positionals[0] ? await readLimitedFile(context, pathPosix.resolve(context.cwd, positionals[0]), maxBytes) : await collectSourceBytes(context.stdin, maxBytes, context.signal);
|
|
420
441
|
const b64 = textDecoder.decode(input).split("\n").filter((l) => !l.startsWith("-----") && l.trim().length > 0).join("");
|
|
421
442
|
const imported = JSON.parse(textDecoder.decode(base64ToBytes(b64)));
|
|
422
443
|
const existing = await loadKeyring(context);
|
|
@@ -431,7 +452,7 @@ gpg: imported: ${imported.length}
|
|
|
431
452
|
return { exitCode: 0 };
|
|
432
453
|
}
|
|
433
454
|
if (detachSign) {
|
|
434
|
-
const payload = positionals[0] ? await context
|
|
455
|
+
const payload = positionals[0] ? await readLimitedFile(context, pathPosix.resolve(context.cwd, positionals[0]), maxBytes) : await collectSourceBytes(context.stdin, maxBytes, context.signal);
|
|
435
456
|
const key = await ensureKeyForUid(context, signerUid);
|
|
436
457
|
const { armor, keyIdHex } = await createOpenPgpDetachedSignature(key.seed, key.pubKey, key.uid, payload);
|
|
437
458
|
if (statusFd) {
|
|
@@ -449,9 +470,9 @@ gpg: imported: ${imported.length}
|
|
|
449
470
|
const sigPath = positionals[0];
|
|
450
471
|
if (!sigPath)
|
|
451
472
|
throw new PublicDiagnostic("missing signature file for --verify");
|
|
452
|
-
const sigArmor = textDecoder.decode(await context
|
|
453
|
-
const dataBytes = positionals[1] ? await context
|
|
454
|
-
const res = await verifyOpenPgpDetachedSignature(sigArmor, dataBytes);
|
|
473
|
+
const sigArmor = textDecoder.decode(await readLimitedFile(context, pathPosix.resolve(context.cwd, sigPath), maxBytes));
|
|
474
|
+
const dataBytes = positionals[1] ? await readLimitedFile(context, pathPosix.resolve(context.cwd, positionals[1]), maxBytes) : await collectSourceBytes(context.stdin, maxBytes, context.signal);
|
|
475
|
+
const res = await verifyOpenPgpDetachedSignature(sigArmor, dataBytes, await loadKeyring(context));
|
|
455
476
|
if (!res.valid) {
|
|
456
477
|
await writeText(context.stderr, `gpg: BAD signature from "${res.signerUid}"
|
|
457
478
|
`);
|
|
@@ -28,8 +28,8 @@ import {
|
|
|
28
28
|
thresholdImage,
|
|
29
29
|
tintImage,
|
|
30
30
|
trimImage
|
|
31
|
-
} from "../safe-bash/command-chunks/chunk-
|
|
32
|
-
import "../safe-bash/command-chunks/chunk-
|
|
31
|
+
} from "../safe-bash/command-chunks/chunk-HH5QPKIN.js";
|
|
32
|
+
import "../safe-bash/command-chunks/chunk-PM63UJE6.js";
|
|
33
33
|
import {
|
|
34
34
|
init_buffer
|
|
35
35
|
} from "../safe-bash/command-chunks/chunk-HX3SHTCE.js";
|
|
@@ -175,6 +175,20 @@ async function pbkdf2DeriveKeyAndIv(password, salt, iterations) {
|
|
|
175
175
|
iv: derived.slice(32, 48)
|
|
176
176
|
};
|
|
177
177
|
}
|
|
178
|
+
async function readLimitedFile(context, path, maxBytes) {
|
|
179
|
+
try {
|
|
180
|
+
const bytes = await context.fs.readFile(path, { ...maxBytes === Infinity ? {} : { maxBytes }, signal: context.signal });
|
|
181
|
+
if (bytes.byteLength > maxBytes) {
|
|
182
|
+
throw new PublicDiagnostic(`input exceeds maximum buffered size of ${maxBytes} bytes`);
|
|
183
|
+
}
|
|
184
|
+
return bytes;
|
|
185
|
+
} catch (error) {
|
|
186
|
+
if (error instanceof FsError && error.code === "EFBIG") {
|
|
187
|
+
throw new PublicDiagnostic(`input exceeds maximum buffered size of ${maxBytes} bytes`);
|
|
188
|
+
}
|
|
189
|
+
throw error;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
178
192
|
function createOpensslCommand(options = {}) {
|
|
179
193
|
const limits = settings(options);
|
|
180
194
|
return {
|
|
@@ -216,7 +230,11 @@ function createOpensslCommand(options = {}) {
|
|
|
216
230
|
throw new PublicDiagnostic(`invalid random byte count: ${numBytes}`);
|
|
217
231
|
}
|
|
218
232
|
const raw = new Uint8Array(numBytes);
|
|
219
|
-
|
|
233
|
+
for (let offset = 0; offset < raw.byteLength; offset += 65536) {
|
|
234
|
+
globalThis.crypto.getRandomValues(raw.subarray(offset, Math.min(offset + 65536, raw.byteLength)));
|
|
235
|
+
if (offset + 65536 < raw.byteLength)
|
|
236
|
+
await yieldTurn(context.signal);
|
|
237
|
+
}
|
|
220
238
|
const out = hex ? textEncoder.encode(`${bytesToHex(raw)}
|
|
221
239
|
`) : b64 ? textEncoder.encode(`${bytesToBase64(raw, true)}
|
|
222
240
|
`) : raw;
|
|
@@ -241,7 +259,7 @@ function createOpensslCommand(options = {}) {
|
|
|
241
259
|
else if (a === "-out" && i + 1 < rest.length)
|
|
242
260
|
outFile = rest[++i];
|
|
243
261
|
}
|
|
244
|
-
const input = inFile ? await context
|
|
262
|
+
const input = inFile ? await readLimitedFile(context, pathPosix.resolve(context.cwd, inFile), maxBytes) : await collectSourceBytes(context.stdin, maxBytes, context.signal);
|
|
245
263
|
if (input.byteLength > maxBytes) {
|
|
246
264
|
throw new PublicDiagnostic(`input exceeds maximum buffered size of ${maxBytes} bytes`);
|
|
247
265
|
}
|
|
@@ -290,7 +308,7 @@ function createOpensslCommand(options = {}) {
|
|
|
290
308
|
const textLines = [];
|
|
291
309
|
let lastBinary = new Uint8Array(0);
|
|
292
310
|
for (const f of targets) {
|
|
293
|
-
const bytes = f ? await context
|
|
311
|
+
const bytes = f ? await readLimitedFile(context, pathPosix.resolve(context.cwd, f), maxBytes) : await collectSourceBytes(context.stdin, maxBytes, context.signal);
|
|
294
312
|
if (bytes.byteLength > maxBytes) {
|
|
295
313
|
throw new PublicDiagnostic(`input exceeds maximum buffered size of ${maxBytes} bytes`);
|
|
296
314
|
}
|
|
@@ -336,7 +354,7 @@ function createOpensslCommand(options = {}) {
|
|
|
336
354
|
else if (a === "-out" && i + 1 < rest.length)
|
|
337
355
|
outFile = rest[++i];
|
|
338
356
|
}
|
|
339
|
-
const rawInput = inFile ? await context
|
|
357
|
+
const rawInput = inFile ? await readLimitedFile(context, pathPosix.resolve(context.cwd, inFile), maxBytes) : await collectSourceBytes(context.stdin, maxBytes, context.signal);
|
|
340
358
|
if (rawInput.byteLength > maxBytes) {
|
|
341
359
|
throw new PublicDiagnostic(`input exceeds maximum buffered size of ${maxBytes} bytes`);
|
|
342
360
|
}
|
|
@@ -406,7 +424,7 @@ ${bytesToBase64(pkcs8, true)}
|
|
|
406
424
|
else if (rest[i] === "-pubout")
|
|
407
425
|
pubOut = true;
|
|
408
426
|
}
|
|
409
|
-
const inputBytes = inFile ? await context
|
|
427
|
+
const inputBytes = inFile ? await readLimitedFile(context, pathPosix.resolve(context.cwd, inFile), maxBytes) : await collectSourceBytes(context.stdin, maxBytes, context.signal);
|
|
410
428
|
const pemText = textDecoder.decode(inputBytes);
|
|
411
429
|
const b64Body = pemText.split("\n").filter((l) => !l.startsWith("-----")).join("");
|
|
412
430
|
const pkcs8 = base64ToBytes(b64Body);
|
|
@@ -486,7 +504,7 @@ ${bytesToBase64(textEncoder.encode(certMeta), true)}
|
|
|
486
504
|
else if (a === "-dates")
|
|
487
505
|
showDates = true;
|
|
488
506
|
}
|
|
489
|
-
const inputBytes = inFile ? await context
|
|
507
|
+
const inputBytes = inFile ? await readLimitedFile(context, pathPosix.resolve(context.cwd, inFile), maxBytes) : await collectSourceBytes(context.stdin, maxBytes, context.signal);
|
|
490
508
|
const pemText = textDecoder.decode(inputBytes);
|
|
491
509
|
const b64Body = pemText.split("\n").filter((l) => !l.startsWith("-----")).join("");
|
|
492
510
|
const rawCert = base64ToBytes(b64Body);
|
|
@@ -2,11 +2,11 @@ import {
|
|
|
2
2
|
createPandocCommand,
|
|
3
3
|
createPandocCommands,
|
|
4
4
|
pandocCommands
|
|
5
|
-
} from "../safe-bash/command-chunks/chunk-
|
|
5
|
+
} from "../safe-bash/command-chunks/chunk-4ZHDCMQX.js";
|
|
6
6
|
import "../safe-bash/command-chunks/chunk-MKQVQMXO.js";
|
|
7
7
|
import "../safe-bash/command-chunks/chunk-RDV7UCYZ.js";
|
|
8
|
-
import "../safe-bash/command-chunks/chunk-
|
|
9
|
-
import "../safe-bash/command-chunks/chunk-
|
|
8
|
+
import "../safe-bash/command-chunks/chunk-HH5QPKIN.js";
|
|
9
|
+
import "../safe-bash/command-chunks/chunk-PM63UJE6.js";
|
|
10
10
|
import "../safe-bash/command-chunks/chunk-Y2KHC6TZ.js";
|
|
11
11
|
import "../safe-bash/command-chunks/chunk-YGYOVXTO.js";
|
|
12
12
|
import "../safe-bash/command-chunks/chunk-I5GLTNVH.js";
|
|
@@ -21,11 +21,11 @@ import {
|
|
|
21
21
|
readDocument,
|
|
22
22
|
resolveConversionArgs,
|
|
23
23
|
writeDocument
|
|
24
|
-
} from "../safe-bash/command-chunks/chunk-
|
|
24
|
+
} from "../safe-bash/command-chunks/chunk-4ZHDCMQX.js";
|
|
25
25
|
import "../safe-bash/command-chunks/chunk-MKQVQMXO.js";
|
|
26
26
|
import "../safe-bash/command-chunks/chunk-RDV7UCYZ.js";
|
|
27
|
-
import "../safe-bash/command-chunks/chunk-
|
|
28
|
-
import "../safe-bash/command-chunks/chunk-
|
|
27
|
+
import "../safe-bash/command-chunks/chunk-HH5QPKIN.js";
|
|
28
|
+
import "../safe-bash/command-chunks/chunk-PM63UJE6.js";
|
|
29
29
|
import {
|
|
30
30
|
createLuaFilterCapability
|
|
31
31
|
} from "../safe-bash/command-chunks/chunk-Y2KHC6TZ.js";
|