@poe-platform/safe-bash 0.1.616 → 0.1.617

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.
Files changed (28) hide show
  1. package/dist/safe-bash/chunks/{chunk-PW4WQSCS.js → chunk-3M5F7LD5.js} +2 -2
  2. package/dist/safe-bash/chunks/{chunk-CEPNDODE.js → chunk-4DBWBEU7.js} +2 -2
  3. package/dist/safe-bash/chunks/chunk-4DBWBEU7.js.map +7 -0
  4. package/dist/safe-bash/chunks/{chunk-PFMSKAFQ.js → chunk-KYNRHYHP.js} +4 -4
  5. package/dist/safe-bash/chunks/{chunk-PFMSKAFQ.js.map → chunk-KYNRHYHP.js.map} +2 -2
  6. package/dist/safe-bash/chunks/{chunk-F5TCC4UG.js → chunk-X55AMTNM.js} +2 -2
  7. package/dist/safe-bash/commands/archive/zip/zip64.d.ts +10 -0
  8. package/dist/safe-bash/commands/archive/zip/zip64.d.ts.map +1 -0
  9. package/dist/safe-bash/commands/archive/zip/zip64.js +93 -0
  10. package/dist/safe-bash/commands/archive/zip/zip64.js.map +1 -0
  11. package/dist/safe-bash/commands/archive/zip-format.d.ts.map +1 -1
  12. package/dist/safe-bash/commands/archive/zip-format.js +43 -34
  13. package/dist/safe-bash/commands/archive/zip-format.js.map +1 -1
  14. package/dist/safe-bash/commands/csplit/index.browser.js +2 -2
  15. package/dist/safe-bash/commands/line-endings/index.browser.js +2 -2
  16. package/dist/safe-bash/commands/network/index.browser.js +2 -2
  17. package/dist/safe-bash/commands/network/output.js +2 -2
  18. package/dist/safe-bash/commands/network/output.js.map +1 -1
  19. package/dist/safe-bash/contracts/filesystem-output.d.ts +3 -1
  20. package/dist/safe-bash/contracts/filesystem-output.d.ts.map +1 -1
  21. package/dist/safe-bash/contracts/filesystem-output.js +2 -1
  22. package/dist/safe-bash/contracts/filesystem-output.js.map +1 -1
  23. package/dist/safe-bash/core.browser.js +117 -30
  24. package/dist/safe-bash/core.browser.js.map +4 -4
  25. package/package.json +2 -2
  26. package/dist/safe-bash/chunks/chunk-CEPNDODE.js.map +0 -7
  27. /package/dist/safe-bash/chunks/{chunk-PW4WQSCS.js.map → chunk-3M5F7LD5.js.map} +0 -0
  28. /package/dist/safe-bash/chunks/{chunk-F5TCC4UG.js.map → chunk-X55AMTNM.js.map} +0 -0
@@ -34,7 +34,7 @@ import {
34
34
  createLineEndingCommands,
35
35
  createUnix2dosCommand,
36
36
  lineEndingCommands
37
- } from "./chunks/chunk-F5TCC4UG.js";
37
+ } from "./chunks/chunk-X55AMTNM.js";
38
38
  import {
39
39
  createLlmCommands,
40
40
  llmCommands
@@ -86,7 +86,7 @@ import {
86
86
  curlCommands,
87
87
  defaultNetworkLimits,
88
88
  networkCommands
89
- } from "./chunks/chunk-PFMSKAFQ.js";
89
+ } from "./chunks/chunk-KYNRHYHP.js";
90
90
  import {
91
91
  RecordBuffer,
92
92
  UsageError,
@@ -138,12 +138,12 @@ import {
138
138
  exprMatchCeilings,
139
139
  matchEre,
140
140
  withRegexSession
141
- } from "./chunks/chunk-PW4WQSCS.js";
141
+ } from "./chunks/chunk-3M5F7LD5.js";
142
142
  import {
143
143
  bindFileOutputBudget,
144
144
  openFileOutput,
145
145
  writeFileOutput
146
- } from "./chunks/chunk-CEPNDODE.js";
146
+ } from "./chunks/chunk-4DBWBEU7.js";
147
147
  import {
148
148
  createOutputOperation
149
149
  } from "./chunks/chunk-RNKTWFEM.js";
@@ -26614,6 +26614,82 @@ init_platform();
26614
26614
 
26615
26615
  // packages/safe-bash/src/commands/archive/zip-format.ts
26616
26616
  init_platform();
26617
+
26618
+ // packages/safe-bash/src/commands/archive/zip/zip64.ts
26619
+ init_platform();
26620
+ function wide(view, offset) {
26621
+ if (offset < 0 || offset + 8 > view.byteLength) fail("ZIP64 truncated numeric field");
26622
+ const value2 = view.getBigUint64(offset, true);
26623
+ if (value2 > BigInt(Number.MAX_SAFE_INTEGER)) fail("ZIP64 unsafe numeric field");
26624
+ return Number(value2);
26625
+ }
26626
+ function zip64Directory(view, end, limits) {
26627
+ let members = view.getUint16(end + 10, true);
26628
+ let centralSize = view.getUint32(end + 12, true);
26629
+ let centralStart = view.getUint32(end + 16, true);
26630
+ let centralEnd = end;
26631
+ const diskMembers = view.getUint16(end + 8, true);
26632
+ if (view.getUint16(end + 4, true) || view.getUint16(end + 6, true)) fail("ZIP multi-disk archive is unsupported");
26633
+ const locator = end >= 20 && view.getUint32(end - 20, true) === 117853008;
26634
+ if (locator) {
26635
+ if (view.getUint32(end - 16, true) || view.getUint32(end - 4, true) !== 1) fail("ZIP64 multi-disk locator is unsupported");
26636
+ centralEnd = wide(view, end - 12);
26637
+ if (centralEnd + 56 > end - 20 || view.getUint32(centralEnd, true) !== 101075792) fail("ZIP64 invalid end-record span");
26638
+ const length = wide(view, centralEnd + 4);
26639
+ if (length < 44 || length - 44 > limits.maxPaxBytes || centralEnd + 12 + length !== end - 20) fail("ZIP64 invalid end-record length");
26640
+ if (view.getUint16(centralEnd + 14, true) !== 45) fail("ZIP64 unsupported end-record extraction version");
26641
+ if (view.getUint32(centralEnd + 16, true) || view.getUint32(centralEnd + 20, true)) fail("ZIP64 multi-disk archive is unsupported");
26642
+ const count2 = wide(view, centralEnd + 32);
26643
+ if (wide(view, centralEnd + 24) !== count2 || members !== 65535 && members !== count2 || diskMembers !== 65535 && diskMembers !== count2) fail("ZIP64 inconsistent member count");
26644
+ const size = wide(view, centralEnd + 40);
26645
+ const start = wide(view, centralEnd + 48);
26646
+ if (centralSize !== 4294967295 && centralSize !== size || centralStart !== 4294967295 && centralStart !== start) fail("ZIP64 inconsistent central directory");
26647
+ members = count2;
26648
+ centralSize = size;
26649
+ centralStart = start;
26650
+ } else if (members === 65535 || centralSize === 4294967295 || centralStart === 4294967295) fail("ZIP64 missing end record and locator");
26651
+ else if (diskMembers !== members) fail("ZIP inconsistent member count");
26652
+ if (members > limits.maxMembers) fail("ZIP member limit exceeded");
26653
+ if (centralStart > limits.maxArchiveBytes || centralSize > limits.maxArchiveBytes || centralStart + centralSize !== centralEnd) fail("ZIP invalid central directory span");
26654
+ return { members, centralStart, centralSize, centralEnd };
26655
+ }
26656
+ function zip64Fields(data2, values) {
26657
+ let offset = 0;
26658
+ const view = data2 && new DataView(data2.buffer, data2.byteOffset, data2.byteLength);
26659
+ return values.map((value2, index) => {
26660
+ if (value2 !== 4294967295) return value2;
26661
+ if (!view) fail("ZIP64 missing required extra field");
26662
+ const width = index === 3 ? 4 : 8;
26663
+ if (offset + width > view.byteLength) fail("ZIP64 truncated extra field");
26664
+ const resolved = width === 4 ? view.getUint32(offset, true) : wide(view, offset);
26665
+ offset += width;
26666
+ return resolved;
26667
+ });
26668
+ }
26669
+ function stripZip64(bytes3) {
26670
+ const view = new DataView(bytes3.buffer, bytes3.byteOffset, bytes3.byteLength);
26671
+ const retained = [];
26672
+ let length = 0;
26673
+ for (let offset2 = 0; offset2 < bytes3.length; ) {
26674
+ if (offset2 + 4 > bytes3.length) fail("ZIP truncated extra field");
26675
+ const next = offset2 + 4 + view.getUint16(offset2 + 2, true);
26676
+ if (next > bytes3.length) fail("ZIP truncated extra field payload");
26677
+ if (view.getUint16(offset2, true) !== 1) {
26678
+ retained.push(bytes3.subarray(offset2, next));
26679
+ length += next - offset2;
26680
+ }
26681
+ offset2 = next;
26682
+ }
26683
+ const result = new Uint8Array(length);
26684
+ let offset = 0;
26685
+ for (const field2 of retained) {
26686
+ result.set(field2, offset);
26687
+ offset += field2.length;
26688
+ }
26689
+ return result;
26690
+ }
26691
+
26692
+ // packages/safe-bash/src/commands/archive/zip-format.ts
26617
26693
  var encoder2 = new TextEncoder();
26618
26694
  var cp437 = "\xC7\xFC\xE9\xE2\xE4\xE0\xE5\xE7\xEA\xEB\xE8\xEF\xEE\xEC\xC4\xC5\xC9\xE6\xC6\xF4\xF6\xF2\xFB\xF9\xFF\xD6\xDC\xA2\xA3\xA5\u20A7\u0192\xE1\xED\xF3\xFA\xF1\xD1\xAA\xBA\xBF\u2310\xAC\xBD\xBC\xA1\xAB\xBB\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255D\u255C\u255B\u2510\u2514\u2534\u252C\u251C\u2500\u253C\u255E\u255F\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256B\u256A\u2518\u250C\u2588\u2584\u258C\u2590\u2580\u03B1\xDF\u0393\u03C0\u03A3\u03C3\xB5\u03C4\u03A6\u0398\u03A9\u03B4\u221E\u03C6\u03B5\u2229\u2261\xB1\u2265\u2264\u2320\u2321\xF7\u2248\xB0\u2219\xB7\u221A\u207F\xB2\u25A0\xA0";
26619
26695
  var crcTable4 = Uint32Array.from({ length: 256 }, (_, index) => {
@@ -26670,7 +26746,10 @@ function extras(bytes3, rawName, comment2, central, limits) {
26670
26746
  if (offset + length > bytes3.length) fail("ZIP truncated extra field payload");
26671
26747
  if (seen.has(identifier)) fail("ZIP duplicate extra field");
26672
26748
  seen.add(identifier);
26673
- if (identifier === 1) fail("ZIP64 is unsupported");
26749
+ if (identifier === 1) {
26750
+ if (!length || length > 28 || length % 4) fail("ZIP64 invalid extra field length");
26751
+ result.zip64 = bytes3.subarray(offset, offset + length);
26752
+ }
26674
26753
  if (identifier === 39169 || identifier === 23 || identifier === 24 || identifier === 25) fail("ZIP encryption is unsupported");
26675
26754
  if (identifier === 28789 || identifier === 25461) {
26676
26755
  if (length < 5 || bytes3[offset] !== 1) fail("ZIP unsupported or truncated Unicode extra field");
@@ -26706,7 +26785,7 @@ function format(method, flags3, version) {
26706
26785
  if (flags3 & (1 | 64 | 8192)) fail("ZIP encryption is unsupported");
26707
26786
  if (flags3 & ~2062 || method === 0 && flags3 & 6) fail("ZIP unsupported general purpose flags");
26708
26787
  if (method !== 0 && method !== 8) fail("ZIP unsupported compression method");
26709
- if (version < (method === 8 || flags3 & 8 ? 20 : 10) || version > 20) fail("ZIP unsupported extraction version (including ZIP64)");
26788
+ if (version < (method === 8 || flags3 & 8 ? 20 : 10) || version > 20 && version !== 45) fail("ZIP unsupported extraction version (including ZIP64)");
26710
26789
  }
26711
26790
  function dosModified(date2, time) {
26712
26791
  if (!date2 && !time) return new Date(1980, 0, 1);
@@ -26758,13 +26837,7 @@ async function readZipArchive(bytes3, limits, signal) {
26758
26837
  }
26759
26838
  }
26760
26839
  if (end === -1) fail("ZIP truncated or missing end of central directory");
26761
- const members = view.getUint16(end + 10, true);
26762
- const centralSize = view.getUint32(end + 12, true);
26763
- const centralStart = view.getUint32(end + 16, true);
26764
- if (members === 65535 || centralSize === 4294967295 || centralStart === 4294967295) fail("ZIP64 is unsupported");
26765
- if (view.getUint16(end + 4, true) || view.getUint16(end + 6, true) || view.getUint16(end + 8, true) !== members) fail("ZIP multi-disk or inconsistent member count is unsupported");
26766
- if (centralStart + centralSize !== end) fail("ZIP invalid central directory span or unsupported ZIP64/trailing records");
26767
- number3(members, limits.maxMembers, "member");
26840
+ const { members, centralStart, centralEnd } = zip64Directory(view, end, limits);
26768
26841
  number3(bytes3.length - end - 22, limits.maxTextBytes, "archive comment");
26769
26842
  const entries2 = [];
26770
26843
  const spans = [];
@@ -26772,7 +26845,7 @@ async function readZipArchive(bytes3, limits, signal) {
26772
26845
  let total = 0;
26773
26846
  for (let index = 0; index < members; index++) {
26774
26847
  await yieldTurn(signal);
26775
- if (offset + 46 > end || view.getUint32(offset, true) !== 33639248) fail("ZIP truncated or invalid central header");
26848
+ if (offset + 46 > centralEnd || view.getUint32(offset, true) !== 33639248) fail("ZIP truncated or invalid central header");
26776
26849
  const versionMadeBy = view.getUint16(offset + 4, true);
26777
26850
  const version = view.getUint16(offset + 6, true);
26778
26851
  const flags3 = view.getUint16(offset + 8, true);
@@ -26781,29 +26854,32 @@ async function readZipArchive(bytes3, limits, signal) {
26781
26854
  const dosTime = view.getUint16(offset + 12, true);
26782
26855
  const dosDate = view.getUint16(offset + 14, true);
26783
26856
  const checksum = view.getUint32(offset + 16, true);
26784
- const compressedSize = view.getUint32(offset + 20, true);
26785
- const size = view.getUint32(offset + 24, true);
26857
+ let compressedSize = view.getUint32(offset + 20, true);
26858
+ let size = view.getUint32(offset + 24, true);
26786
26859
  const nameLength = view.getUint16(offset + 28, true);
26787
26860
  const extraLength = view.getUint16(offset + 30, true);
26788
26861
  const commentLength = view.getUint16(offset + 32, true);
26789
26862
  const internalAttributes = view.getUint16(offset + 36, true);
26790
26863
  if (internalAttributes & ~1) fail("ZIP unsupported internal attributes");
26791
26864
  const externalAttributes = view.getUint32(offset + 38, true);
26792
- const local = view.getUint32(offset + 42, true);
26793
- if (view.getUint16(offset + 34, true)) fail("ZIP multi-disk member is unsupported");
26794
- if (compressedSize === 4294967295 || size === 4294967295 || local === 4294967295) fail("ZIP64 is unsupported");
26795
- number3(size, limits.maxEntryBytes, "entry byte");
26796
- if (method === 0 && compressedSize !== size) fail("ZIP stored size mismatch");
26797
- total += size;
26798
- number3(total, limits.maxTotalBytes, "total byte");
26865
+ let local = view.getUint32(offset + 42, true);
26866
+ const disk = view.getUint16(offset + 34, true);
26799
26867
  const next = offset + 46 + nameLength + extraLength + commentLength;
26800
- if (next > end) fail("ZIP truncated central metadata");
26868
+ if (next > centralEnd) fail("ZIP truncated central metadata");
26801
26869
  number3(commentLength, limits.maxTextBytes, "entry comment");
26802
26870
  const rawName = bytes3.subarray(offset + 46, offset + 46 + nameLength);
26803
26871
  const centralExtra = bytes3.subarray(offset + 46 + nameLength, next - commentLength);
26804
26872
  const comment2 = bytes3.subarray(next - commentLength, next);
26805
26873
  if (flags3 & 2048) text2(comment2);
26806
26874
  const centralMetadata = extras(centralExtra, rawName, comment2, true, limits);
26875
+ const resolved = zip64Fields(centralMetadata.zip64, [size, compressedSize, local, disk === 65535 ? 4294967295 : disk]);
26876
+ [size, compressedSize, local] = resolved;
26877
+ if (resolved[3]) fail("ZIP multi-disk member is unsupported");
26878
+ number3(size, limits.maxEntryBytes, "entry byte");
26879
+ number3(compressedSize, limits.maxArchiveBytes, "compressed entry byte");
26880
+ if (method === 0 && compressedSize !== size) fail("ZIP stored size mismatch");
26881
+ total += size;
26882
+ number3(total, limits.maxTotalBytes, "total byte");
26807
26883
  const name2 = nameFrom(rawName, flags3, centralMetadata, limits);
26808
26884
  if (local + 30 > centralStart || view.getUint32(local, true) !== 67324752) fail("ZIP invalid local header span");
26809
26885
  if (view.getUint16(local + 4, true) !== version || view.getUint16(local + 6, true) !== flags3 || view.getUint16(local + 8, true) !== method || view.getUint16(local + 10, true) !== dosTime || view.getUint16(local + 12, true) !== dosDate) fail("ZIP central/local metadata mismatch");
@@ -26819,15 +26895,22 @@ async function readZipArchive(bytes3, limits, signal) {
26819
26895
  const localEffective = nameFrom(localName, flags3, localMetadata, limits);
26820
26896
  if (localMetadata.name !== void 0 && localEffective !== name2) fail("ZIP central/local Unicode name mismatch");
26821
26897
  if (centralMetadata.modified !== void 0 && localMetadata.modified !== void 0 && centralMetadata.modified !== localMetadata.modified) fail("ZIP central/local timestamp mismatch");
26822
- for (const [position, expected] of [[14, checksum], [18, compressedSize], [22, size]]) {
26823
- const actual = view.getUint32(local + position, true);
26898
+ const rawLocalSize = view.getUint32(local + 22, true);
26899
+ const rawLocalCompressed = view.getUint32(local + 18, true);
26900
+ const [localSize, localCompressed] = zip64Fields(localMetadata.zip64, [rawLocalSize, rawLocalCompressed]);
26901
+ for (const [actual, expected] of [[view.getUint32(local + 14, true), checksum], [localCompressed, compressedSize], [localSize, size]]) {
26824
26902
  if (actual !== expected && (!(flags3 & 8) || actual !== 0)) fail("ZIP central/local size or CRC mismatch");
26825
26903
  }
26826
26904
  if (flags3 & 8) {
26827
26905
  const matches2 = [];
26828
26906
  for (const signed2 of [false, true]) {
26829
26907
  const descriptor = payloadEnd + (signed2 ? 4 : 0);
26830
- if (descriptor + 12 <= centralStart && (!signed2 || view.getUint32(payloadEnd, true) === 134695760) && view.getUint32(descriptor, true) === checksum && view.getUint32(descriptor + 4, true) === compressedSize && view.getUint32(descriptor + 8, true) === size) matches2.push(descriptor + 12);
26908
+ const wide2 = rawLocalSize === 4294967295 || rawLocalCompressed === 4294967295;
26909
+ const length = wide2 ? 20 : 12;
26910
+ if (descriptor + length > centralStart || signed2 && view.getUint32(payloadEnd, true) !== 134695760 || view.getUint32(descriptor, true) !== checksum) continue;
26911
+ const compressed2 = wide2 ? view.getBigUint64(descriptor + 4, true) : BigInt(view.getUint32(descriptor + 4, true));
26912
+ const expanded = wide2 ? view.getBigUint64(descriptor + 12, true) : BigInt(view.getUint32(descriptor + 8, true));
26913
+ if (compressed2 === BigInt(compressedSize) && expanded === BigInt(size)) matches2.push(descriptor + length);
26831
26914
  }
26832
26915
  if (matches2.length !== 1) fail("ZIP truncated, ambiguous or mismatched data descriptor");
26833
26916
  payloadEnd = matches2[0];
@@ -26847,7 +26930,7 @@ async function readZipArchive(bytes3, limits, signal) {
26847
26930
  spans.push({ start: local, end: payloadEnd });
26848
26931
  offset = next;
26849
26932
  }
26850
- if (offset !== end) fail("ZIP central directory size or member count mismatch");
26933
+ if (offset !== centralEnd) fail("ZIP central directory size or member count mismatch");
26851
26934
  spans.sort((first, second) => first.start - second.start);
26852
26935
  let covered = 0;
26853
26936
  for (const span of spans) {
@@ -26968,8 +27051,12 @@ async function writeZipArchive(archive, limits, signal, descriptors = false) {
26968
27051
  const comment2 = entry.comment ?? new Uint8Array();
26969
27052
  number3(comment2.length, Math.min(limits.maxTextBytes, 65535), "entry comment");
26970
27053
  if (flags3 & 2048) text2(comment2);
26971
- const localExtra = entry.localExtra ?? timestampExtra(entry.modified);
26972
- const centralExtra = entry.centralExtra ?? timestampExtra(entry.modified);
27054
+ const originalLocalExtra = entry.localExtra ?? timestampExtra(entry.modified);
27055
+ extras(originalLocalExtra, rawName, comment2, false, limits);
27056
+ const localExtra = stripZip64(originalLocalExtra);
27057
+ const originalCentralExtra = entry.centralExtra ?? timestampExtra(entry.modified);
27058
+ extras(originalCentralExtra, rawName, comment2, true, limits);
27059
+ const centralExtra = stripZip64(originalCentralExtra);
26973
27060
  const localMetadata = extras(localExtra, rawName, comment2, false, limits);
26974
27061
  const centralMetadata = extras(centralExtra, rawName, comment2, true, limits);
26975
27062
  if (nameFrom(rawName, flags3, centralMetadata, limits) !== entry.name || localMetadata.name !== void 0 && nameFrom(rawName, flags3, localMetadata, limits) !== entry.name || entry.localName && !equal(rawName, entry.localName)) fail("ZIP retained filename metadata mismatch");