@poe-platform/safe-bash 0.1.839 → 0.1.840
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/mp4-ast/types.d.ts +4 -2
- package/dist/pdf-ast/cos/security.d.ts +10 -0
- package/dist/pdf-ast/edit/retained-attachment-edits.d.ts +4 -0
- package/dist/pdf-ast/edit/retained-graph.d.ts +1 -1
- package/dist/pdf-ast/image.js +1 -1
- package/dist/pdf-ast/index.d.ts +2 -1
- package/dist/pdf-ast/index.js +7 -1
- package/dist/pdf-ast/vendor/pdfjs-fonts.d.mts +8 -0
- package/dist/pdf-ast/vendor/pdfjs-fonts.mjs +28 -0
- package/dist/safe-bash/command-chunks/{chunk-SG2KOOD4.js → chunk-3SAYZFMD.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-FH5VMAPS.js → chunk-45ZH6CNF.js} +20 -4
- package/dist/safe-bash/command-chunks/{chunk-T6OXG7QQ.js → chunk-AAOPVEPF.js} +66 -1
- package/dist/safe-bash/command-chunks/{chunk-46GA576V.js → chunk-CPKVUB7S.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-MBXNG6C3.js → chunk-DLLN3C3Q.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-ZSQCROFE.js → chunk-DM5T5D2K.js} +5 -1
- package/dist/safe-bash/command-chunks/{chunk-3EAZRKI4.js → chunk-G7HQYFIU.js} +10 -1
- package/dist/safe-bash/command-chunks/{chunk-GYKQ3IOV.js → chunk-LMYQMJYY.js} +94 -18
- package/dist/safe-bash/command-chunks/{chunk-DX7KU6YU.js → chunk-N52AHO6S.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-4BSD2RGK.js → chunk-QPKL5GWH.js} +102 -42
- package/dist/safe-bash/command-chunks/{chunk-Z2T7E4ID.js → chunk-R7QLP5RH.js} +1212 -1119
- package/dist/safe-bash/command-chunks/{chunk-RSFKQE2U.js → chunk-T5WFJ44Z.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-77ROD2TR.js → chunk-X3WNWRVT.js} +11 -5
- package/dist/safe-bash/command-chunks/{chunk-TCXM7BSZ.js → chunk-YFMNXPLP.js} +4 -4
- package/dist/safe-bash/command-chunks/{chunk-DQVOBGI2.js → chunk-YVFQ5I36.js} +7335 -7162
- package/dist/safe-bash-command-exiftool/index.js +25 -1
- package/dist/safe-bash-command-ffmpeg/index.js +174 -41
- package/dist/safe-bash-command-ffprobe/index.js +2 -2
- package/dist/safe-bash-command-ffprobe/media.js +2 -2
- package/dist/safe-bash-command-imagemagick/index.js +482 -98
- package/dist/safe-bash-command-mdq/index.js +2 -0
- package/dist/safe-bash-command-pandoc/citeproc-filters.js +7 -7
- package/dist/safe-bash-command-pandoc/command.js +8 -8
- package/dist/safe-bash-command-pandoc/index.js +51 -51
- package/dist/safe-bash-command-qpdf/index.js +1037 -654
- package/dist/safe-bash-command-qpdf/page-range.d.ts +2 -0
- package/dist/safe-bash-command-soffice/index.js +28 -8
- package/dist/safe-bash-command-sqlite3/btree.d.ts +2 -1
- package/dist/safe-bash-command-sqlite3/engine.d.ts +15 -1
- package/dist/safe-bash-command-sqlite3/index.js +294 -68
- package/dist/safe-bash-command-tar/create.js +2 -2
- package/dist/safe-bash-command-tar/extract.js +2 -2
- package/dist/safe-bash-command-tar/format.js +1 -1
- package/dist/safe-bash-command-tar/index.js +4 -4
- package/dist/safe-bash-command-tar/modes.js +4 -4
- package/dist/safe-bash-command-unzip/index.js +1 -1
- package/dist/safe-bash-command-unzip/unzip.js +1 -1
- package/dist/safe-bash-markdown-engine/commonmark-blocks.d.ts +17 -1
- package/dist/safe-bash-markdown-engine/commonmark-blocks.js +3 -3
- package/dist/safe-bash-markdown-engine/commonmark-inlines.d.ts +1 -1
- package/dist/safe-bash-markdown-engine/commonmark-inlines.js +3 -3
- package/dist/safe-bash-markdown-engine/commonmark-syntax.d.ts +5 -0
- package/dist/safe-bash-markdown-engine/commonmark-syntax.js +5 -1
- package/dist/safe-bash-markdown-engine/gfm-syntax.js +2 -2
- package/dist/safe-bash-markdown-engine/index.js +4 -4
- package/dist/safe-bash-zip-engine/index.js +1 -1
- package/dist/safe-bash-zip-engine/zip/repair.js +1 -1
- package/dist/safe-bash-zip-engine/zip/sfx.js +1 -1
- package/dist/safe-bash-zip-engine/zip-format.d.ts +2 -0
- package/dist/safe-bash-zip-engine/zip-format.js +1 -1
- package/package.json +2 -2
- package/third-party/pdf-ast/THIRD_PARTY_NOTICES.md +2 -0
|
@@ -15519,6 +15519,8 @@ function utf8PasswordToBytes(password) {
|
|
|
15519
15519
|
}
|
|
15520
15520
|
var CipherTransformFactory = class _CipherTransformFactory {
|
|
15521
15521
|
#fileId;
|
|
15522
|
+
passwordType;
|
|
15523
|
+
userPasswordBytes;
|
|
15522
15524
|
static get _defaultPasswordBytes() {
|
|
15523
15525
|
return shadow2(
|
|
15524
15526
|
this,
|
|
@@ -15559,6 +15561,21 @@ var CipherTransformFactory = class _CipherTransformFactory {
|
|
|
15559
15561
|
])
|
|
15560
15562
|
);
|
|
15561
15563
|
}
|
|
15564
|
+
matchesOwnerPassword() {
|
|
15565
|
+
if (this.passwordType === "owner") return true;
|
|
15566
|
+
if (this.passwordType !== "user") return false;
|
|
15567
|
+
const dict = this.dict, revision = dict.get("R");
|
|
15568
|
+
const owner = stringToBytes(dict.get("O"));
|
|
15569
|
+
const user = stringToBytes(dict.get("U"));
|
|
15570
|
+
const password = this.userPasswordBytes;
|
|
15571
|
+
if (revision >= 5) {
|
|
15572
|
+
const algorithm = revision === 6 ? new PDF20() : new PDF17();
|
|
15573
|
+
return algorithm.checkOwnerPassword(password, owner.subarray(32, 40), user.subarray(0, 48), owner.subarray(0, 32));
|
|
15574
|
+
}
|
|
15575
|
+
const keyLength = this.encryptionKey.length * 8;
|
|
15576
|
+
const decoded = this.#decodeUserPassword(password, owner, revision, keyLength);
|
|
15577
|
+
return !!this.#prepareKeyData(stringToBytes(this.#fileId), decoded, owner, user, dict.get("P"), revision, keyLength, this.encryptMetadata);
|
|
15578
|
+
}
|
|
15562
15579
|
#createEncryptionKey20(revision, password, ownerPassword, ownerValidationSalt, ownerKeySalt, uBytes, userPassword, userValidationSalt, userKeySalt, ownerEncryption, userEncryption, perms) {
|
|
15563
15580
|
if (password) {
|
|
15564
15581
|
const passwordLength = Math.min(127, password.length);
|
|
@@ -15568,6 +15585,8 @@ var CipherTransformFactory = class _CipherTransformFactory {
|
|
|
15568
15585
|
}
|
|
15569
15586
|
const pdfAlgorithm = revision === 6 ? new PDF20() : new PDF17();
|
|
15570
15587
|
if (pdfAlgorithm.checkUserPassword(password, userValidationSalt, userPassword)) {
|
|
15588
|
+
this.passwordType = "user";
|
|
15589
|
+
this.userPasswordBytes = Uint8Array.from(password);
|
|
15571
15590
|
return pdfAlgorithm.getUserKey(password, userKeySalt, userEncryption);
|
|
15572
15591
|
} else if (password.length && pdfAlgorithm.checkOwnerPassword(
|
|
15573
15592
|
password,
|
|
@@ -15575,6 +15594,7 @@ var CipherTransformFactory = class _CipherTransformFactory {
|
|
|
15575
15594
|
uBytes,
|
|
15576
15595
|
ownerPassword
|
|
15577
15596
|
)) {
|
|
15597
|
+
this.passwordType = "owner";
|
|
15578
15598
|
return pdfAlgorithm.getOwnerKey(
|
|
15579
15599
|
password,
|
|
15580
15600
|
ownerKeySalt,
|
|
@@ -15782,6 +15802,10 @@ var CipherTransformFactory = class _CipherTransformFactory {
|
|
|
15782
15802
|
keyLength,
|
|
15783
15803
|
encryptMetadata
|
|
15784
15804
|
);
|
|
15805
|
+
if (encryptionKey) {
|
|
15806
|
+
this.passwordType = "user";
|
|
15807
|
+
this.userPasswordBytes = passwordBytes ?? new Uint8Array();
|
|
15808
|
+
}
|
|
15785
15809
|
} else {
|
|
15786
15810
|
const ownerValidationSalt = ownerBytes.subarray(32, 40);
|
|
15787
15811
|
const ownerKeySalt = ownerBytes.subarray(40, 48);
|
|
@@ -15842,6 +15866,10 @@ var CipherTransformFactory = class _CipherTransformFactory {
|
|
|
15842
15866
|
keyLength,
|
|
15843
15867
|
encryptMetadata
|
|
15844
15868
|
);
|
|
15869
|
+
if (encryptionKey) {
|
|
15870
|
+
this.passwordType = "owner";
|
|
15871
|
+
this.userPasswordBytes = decodedPassword;
|
|
15872
|
+
}
|
|
15845
15873
|
}
|
|
15846
15874
|
if (!encryptionKey) {
|
|
15847
15875
|
throw new PasswordException(
|
|
@@ -31444,6 +31472,37 @@ function derivePdfEncryptionKey(encryptDict, documentId0, password = "", options
|
|
|
31444
31472
|
throw new PdfError("E_CAPABILITY", error instanceof Error && error.name === "PasswordException" ? "Invalid PDF password" : `PDF security handler: ${error instanceof Error ? error.message : String(error)}`);
|
|
31445
31473
|
}
|
|
31446
31474
|
}
|
|
31475
|
+
function getPdfEncryptionInfo(state) {
|
|
31476
|
+
const handler = securityHandlers.get(state);
|
|
31477
|
+
if (!handler) throw new PdfError("E_CAPABILITY", "Encryption inspection requires authenticated PDF security state");
|
|
31478
|
+
const { factory } = handler;
|
|
31479
|
+
let userBytes = factory.userPasswordBytes ?? new Uint8Array();
|
|
31480
|
+
if (state.revision < 5) {
|
|
31481
|
+
for (let length = 0; length < userBytes.length; length++) {
|
|
31482
|
+
if (userBytes.subarray(length).every((byte3, index2) => byte3 === PADDING_32[index2])) {
|
|
31483
|
+
userBytes = userBytes.subarray(0, length);
|
|
31484
|
+
break;
|
|
31485
|
+
}
|
|
31486
|
+
}
|
|
31487
|
+
}
|
|
31488
|
+
const method = (filter) => {
|
|
31489
|
+
if (state.version < 4) return "RC4";
|
|
31490
|
+
if (filter.name === "Identity") return "none";
|
|
31491
|
+
const entry = factory.cf?.get(filter.name);
|
|
31492
|
+
const cipher = entry instanceof Dict2 ? entry.get("CFM") : void 0;
|
|
31493
|
+
const name = cipher instanceof Name ? cipher.name : void 0;
|
|
31494
|
+
return name === "V2" ? "RC4" : name === "AESV2" ? "AESv2" : name === "AESV3" ? "AESv3" : "none";
|
|
31495
|
+
};
|
|
31496
|
+
return {
|
|
31497
|
+
permissionsMask: factory.dict.get("P"),
|
|
31498
|
+
ownerPasswordMatched: factory.matchesOwnerPassword(),
|
|
31499
|
+
userPasswordMatched: factory.passwordType === "user",
|
|
31500
|
+
userPassword: state.revision >= 5 ? new TextDecoder().decode(userBytes) : bytesToString3(userBytes),
|
|
31501
|
+
streamMethod: method(factory.stmf),
|
|
31502
|
+
stringMethod: method(factory.strf),
|
|
31503
|
+
fileMethod: method(factory.eff)
|
|
31504
|
+
};
|
|
31505
|
+
}
|
|
31447
31506
|
function decryptPdfBuffer(state, objectNumber, generationNumber, data) {
|
|
31448
31507
|
if (data.length === 0) return data;
|
|
31449
31508
|
const handler = securityHandlers.get(state);
|
|
@@ -64656,6 +64715,11 @@ async function* saveRetainedDocumentChunks(document2, storage, options = {}) {
|
|
|
64656
64715
|
}
|
|
64657
64716
|
try {
|
|
64658
64717
|
for await (const object of retainedCosObjects(document2, storage, { ...options.streamMode ? { streamMode: options.streamMode } : {}, ...options.normalizeContent ? { normalizeContent: true } : {}, ...options.maxObjects === void 0 ? {} : { maxObjects: options.maxObjects }, ...options.maxOutputBytes === void 0 ? {} : { maxStreamBytes: options.maxOutputBytes }, signal })) {
|
|
64718
|
+
const type = object.value.kind === "dict" ? dictGet(object.value, "Type") : void 0;
|
|
64719
|
+
if (object.stream && type?.kind === "name" && type.decoded === "ObjStm") {
|
|
64720
|
+
for await (const ignored of object.stream.chunks) void ignored;
|
|
64721
|
+
continue;
|
|
64722
|
+
}
|
|
64659
64723
|
if (!object.stream && object.value.kind === "dict" && dictGet(object.value, "Linearized") !== void 0) mayLinearize = true;
|
|
64660
64724
|
await objects.set(object);
|
|
64661
64725
|
}
|
|
@@ -66822,44 +66886,22 @@ async function stampRetainedPages(document2, store, storage, getPage, stamps, si
|
|
|
66822
66886
|
}
|
|
66823
66887
|
}
|
|
66824
66888
|
function retainedStampTransform(dstAttributes, srcAttributes) {
|
|
66825
|
-
const
|
|
66826
|
-
const
|
|
66827
|
-
const
|
|
66828
|
-
|
|
66829
|
-
|
|
66830
|
-
|
|
66831
|
-
|
|
66832
|
-
|
|
66833
|
-
|
|
66834
|
-
|
|
66835
|
-
|
|
66836
|
-
|
|
66837
|
-
|
|
66889
|
+
const [dx0, dy0, dx1, dy1] = dstAttributes.mediaBox;
|
|
66890
|
+
const [sx0, sy0, sx1, sy1] = srcAttributes.mediaBox;
|
|
66891
|
+
const width = Math.abs(sx1 - sx0), height = Math.abs(sy1 - sy0);
|
|
66892
|
+
if (width === 0 || height === 0) return "q\n";
|
|
66893
|
+
const rotation = ((dstAttributes.rotation - srcAttributes.rotation) % 360 + 360) % 360;
|
|
66894
|
+
const swapped = rotation === 90 || rotation === 270;
|
|
66895
|
+
const scale = Math.min(1, Math.abs(dx1 - dx0) / (swapped ? height : width), Math.abs(dy1 - dy0) / (swapped ? width : height));
|
|
66896
|
+
const a = rotation === 180 ? -scale : swapped ? 0 : scale;
|
|
66897
|
+
const b = rotation === 90 ? scale : rotation === 270 ? -scale : 0;
|
|
66898
|
+
const c = -b, d = a;
|
|
66899
|
+
const sx = (sx0 + sx1) / 2, sy = (sy0 + sy1) / 2;
|
|
66900
|
+
const tx = (dx0 + dx1) / 2 - a * sx - c * sy;
|
|
66901
|
+
const ty = (dy0 + dy1) / 2 - b * sx - d * sy;
|
|
66902
|
+
return `q
|
|
66903
|
+
${[a, b, c, d, tx, ty].map((n) => Number(n.toFixed(6))).join(" ")} cm
|
|
66838
66904
|
`;
|
|
66839
|
-
} else if (rotDiff === 180) {
|
|
66840
|
-
const s = Math.min(dstSize.width / srcSize.width, dstSize.height / srcSize.height);
|
|
66841
|
-
const ox = (dstSize.width - srcSize.width * s) / 2;
|
|
66842
|
-
const oy = (dstSize.height - srcSize.height * s) / 2;
|
|
66843
|
-
stampOpenStr = `q
|
|
66844
|
-
${fmt6(-s)} 0 0 ${fmt6(-s)} ${fmt4(dstSize.width - ox)} ${fmt4(dstSize.height - oy)} cm
|
|
66845
|
-
`;
|
|
66846
|
-
} else if (rotDiff === 270) {
|
|
66847
|
-
const s = Math.min(dstSize.height / srcSize.width, dstSize.width / srcSize.height);
|
|
66848
|
-
const ox = (dstSize.height - srcSize.width * s) / 2;
|
|
66849
|
-
const oy = (dstSize.width - srcSize.height * s) / 2;
|
|
66850
|
-
stampOpenStr = `q
|
|
66851
|
-
0 ${fmt6(-s)} ${fmt6(s)} 0 ${fmt4(oy)} ${fmt4(dstSize.height - ox)} cm
|
|
66852
|
-
`;
|
|
66853
|
-
} else if (Math.abs(srcSize.width - dstSize.width) > 0.5 || Math.abs(srcSize.height - dstSize.height) > 0.5) {
|
|
66854
|
-
const s = Math.min(dstSize.width / srcSize.width, dstSize.height / srcSize.height);
|
|
66855
|
-
const tx = (dstSize.width - srcSize.width * s) / 2;
|
|
66856
|
-
const ty = (dstSize.height - srcSize.height * s) / 2;
|
|
66857
|
-
stampOpenStr = `q
|
|
66858
|
-
${fmt6(s)} 0 0 ${fmt6(s)} ${fmt4(tx)} ${fmt4(ty)} cm
|
|
66859
|
-
`;
|
|
66860
|
-
}
|
|
66861
|
-
}
|
|
66862
|
-
return stampOpenStr;
|
|
66863
66905
|
}
|
|
66864
66906
|
|
|
66865
66907
|
// packages/pdf-ast/src/edit/retained-inline-images.ts
|
|
@@ -67180,8 +67222,15 @@ var PdfDuplicateAttachment = class extends PdfError {
|
|
|
67180
67222
|
}
|
|
67181
67223
|
key;
|
|
67182
67224
|
};
|
|
67225
|
+
var PdfMissingAttachment = class extends PdfError {
|
|
67226
|
+
constructor(key) {
|
|
67227
|
+
super("E_CAPABILITY", `Attachment ${key} not found`);
|
|
67228
|
+
this.key = key;
|
|
67229
|
+
}
|
|
67230
|
+
key;
|
|
67231
|
+
};
|
|
67183
67232
|
async function editRetainedAttachments(document2, target, storage, remove, additions, signal, preserveTree = false) {
|
|
67184
|
-
const pairs = new PdfMutableObjectStore(storage, { signal });
|
|
67233
|
+
const pairs = new PdfMutableObjectStore(storage, { signal }), requested = new PdfMutableObjectStore(storage, { signal });
|
|
67185
67234
|
const names = new PdfNameIndex(storage, Infinity, signal), removed = new PdfNameIndex(storage, Infinity, signal);
|
|
67186
67235
|
const backing = new PagedStorage30({ fs: storage.fs, cwd: storage.directory, env: {}, signal }, 4), first = new IntegerTable17(backing), removals = new IntegerTable17(backing);
|
|
67187
67236
|
let failed = false, count = 0, work = 0;
|
|
@@ -67221,7 +67270,9 @@ async function editRetainedAttachments(document2, target, storage, remove, addit
|
|
|
67221
67270
|
if (tree.reference) owner = tree;
|
|
67222
67271
|
for await (const key of remove) {
|
|
67223
67272
|
await checkpoint();
|
|
67224
|
-
|
|
67273
|
+
const { index: index2, added } = await removed.intern(key);
|
|
67274
|
+
if (added) await requested.set({ objectNumber: index2 + 1, generationNumber: 0, value: cosString(key) });
|
|
67275
|
+
await removals.set(BigInt(index2), 1n);
|
|
67225
67276
|
}
|
|
67226
67277
|
let keyNode;
|
|
67227
67278
|
for await (const node of retainedAttachmentNameTokens(document2, storage, tree.value, signal, !preserveTree)) {
|
|
@@ -67230,15 +67281,21 @@ async function editRetainedAttachments(document2, target, storage, remove, addit
|
|
|
67230
67281
|
continue;
|
|
67231
67282
|
}
|
|
67232
67283
|
const keyValue = (await resolve2(keyNode))?.value, key = keyValue?.kind === "string" ? decodePdfString(keyValue) : "";
|
|
67233
|
-
|
|
67284
|
+
const removalIndex = BigInt((await removed.intern(key)).index);
|
|
67285
|
+
if (await removals.get(removalIndex) === void 0) {
|
|
67234
67286
|
await pairs.set({ objectNumber: ++count, generationNumber: 0, value: cosArray([keyNode, node]) });
|
|
67235
67287
|
if (keyValue?.kind === "string") {
|
|
67236
67288
|
const name = await names.intern(key);
|
|
67237
67289
|
if (name.added) await first.set(BigInt(name.index), BigInt(count));
|
|
67238
67290
|
}
|
|
67239
|
-
}
|
|
67291
|
+
} else await removals.set(removalIndex, 0n);
|
|
67240
67292
|
keyNode = void 0;
|
|
67241
67293
|
}
|
|
67294
|
+
for await (const request of requested.objects()) {
|
|
67295
|
+
if (await removals.get(BigInt(request.objectNumber - 1)) === 1n && request.value.kind === "string") {
|
|
67296
|
+
throw new PdfMissingAttachment(decodePdfString(request.value));
|
|
67297
|
+
}
|
|
67298
|
+
}
|
|
67242
67299
|
let hasRemovals = false;
|
|
67243
67300
|
for await (const ignored of removals.entries()) {
|
|
67244
67301
|
void ignored;
|
|
@@ -67332,7 +67389,7 @@ async function editRetainedAttachments(document2, target, storage, remove, addit
|
|
|
67332
67389
|
failed = true;
|
|
67333
67390
|
throw error;
|
|
67334
67391
|
} finally {
|
|
67335
|
-
const results = await Promise.allSettled([pairs.close(), names.close(), removed.close(), backing.close()]);
|
|
67392
|
+
const results = await Promise.allSettled([pairs.close(), requested.close(), names.close(), removed.close(), backing.close()]);
|
|
67336
67393
|
if (!failed) {
|
|
67337
67394
|
for (const result of results) if (result.status === "rejected") await Promise.reject(result.reason);
|
|
67338
67395
|
}
|
|
@@ -68954,6 +69011,7 @@ export {
|
|
|
68954
69011
|
encodePermissionsMask,
|
|
68955
69012
|
computeR5R6Hash,
|
|
68956
69013
|
derivePdfEncryptionKey,
|
|
69014
|
+
getPdfEncryptionInfo,
|
|
68957
69015
|
decryptPdfBuffer,
|
|
68958
69016
|
decryptPdfObjectStrings,
|
|
68959
69017
|
decryptedPdfStreamDictionary,
|
|
@@ -69120,7 +69178,9 @@ export {
|
|
|
69120
69178
|
retainedCosObjects,
|
|
69121
69179
|
saveRetainedDocumentChunks,
|
|
69122
69180
|
replaceRetainedPdfName,
|
|
69181
|
+
retainedStampTransform,
|
|
69123
69182
|
PdfDuplicateAttachment,
|
|
69183
|
+
PdfMissingAttachment,
|
|
69124
69184
|
editRetainedDocument,
|
|
69125
69185
|
copyRetainedAttachments,
|
|
69126
69186
|
retainedObjectOrder,
|