@poe-platform/safe-bash 0.1.616 → 0.1.618
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/safe-bash/chunks/{chunk-PW4WQSCS.js → chunk-3M5F7LD5.js} +2 -2
- package/dist/safe-bash/chunks/{chunk-CEPNDODE.js → chunk-4DBWBEU7.js} +2 -2
- package/dist/safe-bash/chunks/chunk-4DBWBEU7.js.map +7 -0
- package/dist/safe-bash/chunks/{chunk-PFMSKAFQ.js → chunk-KYNRHYHP.js} +4 -4
- package/dist/safe-bash/chunks/{chunk-PFMSKAFQ.js.map → chunk-KYNRHYHP.js.map} +2 -2
- package/dist/safe-bash/chunks/{chunk-F5TCC4UG.js → chunk-X55AMTNM.js} +2 -2
- package/dist/safe-bash/commands/archive/zip/options.d.ts.map +1 -1
- package/dist/safe-bash/commands/archive/zip/options.js +9 -5
- package/dist/safe-bash/commands/archive/zip/options.js.map +1 -1
- package/dist/safe-bash/commands/archive/zip/zip64.d.ts +12 -0
- package/dist/safe-bash/commands/archive/zip/zip64.d.ts.map +1 -0
- package/dist/safe-bash/commands/archive/zip/zip64.js +118 -0
- package/dist/safe-bash/commands/archive/zip/zip64.js.map +1 -0
- package/dist/safe-bash/commands/archive/zip-format.d.ts +4 -1
- package/dist/safe-bash/commands/archive/zip-format.d.ts.map +1 -1
- package/dist/safe-bash/commands/archive/zip-format.js +133 -59
- package/dist/safe-bash/commands/archive/zip-format.js.map +1 -1
- package/dist/safe-bash/commands/archive/zip.d.ts.map +1 -1
- package/dist/safe-bash/commands/archive/zip.js +28 -7
- package/dist/safe-bash/commands/archive/zip.js.map +1 -1
- package/dist/safe-bash/commands/csplit/index.browser.js +2 -2
- package/dist/safe-bash/commands/line-endings/index.browser.js +2 -2
- package/dist/safe-bash/commands/network/index.browser.js +2 -2
- package/dist/safe-bash/commands/network/output.js +2 -2
- package/dist/safe-bash/commands/network/output.js.map +1 -1
- package/dist/safe-bash/contracts/filesystem-output.d.ts +3 -1
- package/dist/safe-bash/contracts/filesystem-output.d.ts.map +1 -1
- package/dist/safe-bash/contracts/filesystem-output.js +2 -1
- package/dist/safe-bash/contracts/filesystem-output.js.map +1 -1
- package/dist/safe-bash/core.browser.js +289 -98
- package/dist/safe-bash/core.browser.js.map +4 -4
- package/package.json +2 -2
- package/dist/safe-bash/chunks/chunk-CEPNDODE.js.map +0 -7
- /package/dist/safe-bash/chunks/{chunk-PW4WQSCS.js.map → chunk-3M5F7LD5.js.map} +0 -0
- /package/dist/safe-bash/chunks/{chunk-F5TCC4UG.js.map → chunk-X55AMTNM.js.map} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../../../src/commands/archive/zip/options.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,UAAW,SAAQ,KAAK;IACd;IAAyB;IAA9C,YAAqB,MAAc,EAAW,KAAa,EAAE,MAAc;QAAI,KAAK,CAAC,MAAM,CAAC,CAAC;QAAxE,WAAM,GAAN,MAAM,CAAQ;QAAW,UAAK,GAAL,KAAK,CAAQ;IAAmC,CAAC;CAChG;AAED,MAAM,WAAW,GAAqC;IACpD,eAAe,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,YAAY,EAAE,GAAG,EAAE,gBAAgB,EAAE,GAAG;IAC1E,QAAQ,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,aAAa,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG;IACvE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,oBAAoB,EAAE,GAAG;IAC7F,YAAY,EAAE,GAAG,EAAE,YAAY,EAAE,GAAG,EAAE,YAAY,EAAE,GAAG,EAAE,YAAY,EAAE,GAAG;IAC1E,YAAY,EAAE,GAAG,EAAE,YAA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,0 +1,12 @@
|
|
|
1
|
+
import { type ArchiveLimits } from "../internal.js";
|
|
2
|
+
export declare function zip64Directory(view: DataView, end: number, limits: ArchiveLimits): {
|
|
3
|
+
members: number;
|
|
4
|
+
centralStart: number;
|
|
5
|
+
centralSize: number;
|
|
6
|
+
centralEnd: number;
|
|
7
|
+
};
|
|
8
|
+
export declare function zip64Fields(data: Uint8Array | undefined, values: readonly number[]): number[];
|
|
9
|
+
export declare function stripZip64(bytes: Uint8Array): Uint8Array;
|
|
10
|
+
export declare function zip64Extra(values: readonly number[], retained: Uint8Array): Uint8Array;
|
|
11
|
+
export declare function writeZip64End(view: DataView, offset: number, count: number, size: number, start: number, recordOffset?: number): number;
|
|
12
|
+
//# sourceMappingURL=zip64.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zip64.d.ts","sourceRoot":"","sources":["../../../../src/commands/archive/zip/zip64.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAS1D,wBAAgB,cAAc,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa;;;;;EA6BhF;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,UAAU,GAAG,SAAS,EAAE,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,EAAE,CAY7F;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU,CAkBxD;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,EAAE,QAAQ,EAAE,UAAU,GAAG,UAAU,CAStF;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,YAAY,SAAS,GAAG,MAAM,CAavI"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { fail } from "../internal.js";
|
|
2
|
+
function wide(view, offset) {
|
|
3
|
+
if (offset < 0 || offset + 8 > view.byteLength)
|
|
4
|
+
fail("ZIP64 truncated numeric field");
|
|
5
|
+
const value = view.getBigUint64(offset, true);
|
|
6
|
+
if (value > BigInt(Number.MAX_SAFE_INTEGER))
|
|
7
|
+
fail("ZIP64 unsafe numeric field");
|
|
8
|
+
return Number(value);
|
|
9
|
+
}
|
|
10
|
+
export function zip64Directory(view, end, limits) {
|
|
11
|
+
let members = view.getUint16(end + 10, true);
|
|
12
|
+
let centralSize = view.getUint32(end + 12, true);
|
|
13
|
+
let centralStart = view.getUint32(end + 16, true);
|
|
14
|
+
let centralEnd = end;
|
|
15
|
+
const diskMembers = view.getUint16(end + 8, true);
|
|
16
|
+
if (view.getUint16(end + 4, true) || view.getUint16(end + 6, true))
|
|
17
|
+
fail("ZIP multi-disk archive is unsupported");
|
|
18
|
+
const locator = end >= 20 && view.getUint32(end - 20, true) === 0x07064b50;
|
|
19
|
+
if (locator) {
|
|
20
|
+
if (view.getUint32(end - 16, true) || view.getUint32(end - 4, true) !== 1)
|
|
21
|
+
fail("ZIP64 multi-disk locator is unsupported");
|
|
22
|
+
centralEnd = wide(view, end - 12);
|
|
23
|
+
if (centralEnd + 56 > end - 20 || view.getUint32(centralEnd, true) !== 0x06064b50)
|
|
24
|
+
fail("ZIP64 invalid end-record span");
|
|
25
|
+
const length = wide(view, centralEnd + 4);
|
|
26
|
+
if (length < 44 || length - 44 > limits.maxPaxBytes || centralEnd + 12 + length !== end - 20)
|
|
27
|
+
fail("ZIP64 invalid end-record length");
|
|
28
|
+
if (view.getUint16(centralEnd + 14, true) !== 45)
|
|
29
|
+
fail("ZIP64 unsupported end-record extraction version");
|
|
30
|
+
if (view.getUint32(centralEnd + 16, true) || view.getUint32(centralEnd + 20, true))
|
|
31
|
+
fail("ZIP64 multi-disk archive is unsupported");
|
|
32
|
+
const count = wide(view, centralEnd + 32);
|
|
33
|
+
if (wide(view, centralEnd + 24) !== count || members !== 65535 && members !== count || diskMembers !== 65535 && diskMembers !== count)
|
|
34
|
+
fail("ZIP64 inconsistent member count");
|
|
35
|
+
const size = wide(view, centralEnd + 40);
|
|
36
|
+
const start = wide(view, centralEnd + 48);
|
|
37
|
+
if (centralSize !== 0xffffffff && centralSize !== size || centralStart !== 0xffffffff && centralStart !== start)
|
|
38
|
+
fail("ZIP64 inconsistent central directory");
|
|
39
|
+
members = count;
|
|
40
|
+
centralSize = size;
|
|
41
|
+
centralStart = start;
|
|
42
|
+
}
|
|
43
|
+
else if (members === 65535 || centralSize === 0xffffffff || centralStart === 0xffffffff)
|
|
44
|
+
fail("ZIP64 missing end record and locator");
|
|
45
|
+
else if (diskMembers !== members)
|
|
46
|
+
fail("ZIP inconsistent member count");
|
|
47
|
+
if (members > limits.maxMembers)
|
|
48
|
+
fail("ZIP member limit exceeded");
|
|
49
|
+
if (centralStart > limits.maxArchiveBytes || centralSize > limits.maxArchiveBytes || centralStart + centralSize !== centralEnd)
|
|
50
|
+
fail("ZIP invalid central directory span");
|
|
51
|
+
return { members, centralStart, centralSize, centralEnd };
|
|
52
|
+
}
|
|
53
|
+
export function zip64Fields(data, values) {
|
|
54
|
+
let offset = 0;
|
|
55
|
+
const view = data && new DataView(data.buffer, data.byteOffset, data.byteLength);
|
|
56
|
+
return values.map((value, index) => {
|
|
57
|
+
if (value !== 0xffffffff)
|
|
58
|
+
return value;
|
|
59
|
+
if (!view)
|
|
60
|
+
fail("ZIP64 missing required extra field");
|
|
61
|
+
const width = index === 3 ? 4 : 8;
|
|
62
|
+
if (offset + width > view.byteLength)
|
|
63
|
+
fail("ZIP64 truncated extra field");
|
|
64
|
+
const resolved = width === 4 ? view.getUint32(offset, true) : wide(view, offset);
|
|
65
|
+
offset += width;
|
|
66
|
+
return resolved;
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
export function stripZip64(bytes) {
|
|
70
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
71
|
+
const retained = [];
|
|
72
|
+
let length = 0;
|
|
73
|
+
for (let offset = 0; offset < bytes.length;) {
|
|
74
|
+
if (offset + 4 > bytes.length)
|
|
75
|
+
fail("ZIP truncated extra field");
|
|
76
|
+
const next = offset + 4 + view.getUint16(offset + 2, true);
|
|
77
|
+
if (next > bytes.length)
|
|
78
|
+
fail("ZIP truncated extra field payload");
|
|
79
|
+
if (view.getUint16(offset, true) !== 1) {
|
|
80
|
+
retained.push(bytes.subarray(offset, next));
|
|
81
|
+
length += next - offset;
|
|
82
|
+
}
|
|
83
|
+
offset = next;
|
|
84
|
+
}
|
|
85
|
+
const result = new Uint8Array(length);
|
|
86
|
+
let offset = 0;
|
|
87
|
+
for (const field of retained) {
|
|
88
|
+
result.set(field, offset);
|
|
89
|
+
offset += field.length;
|
|
90
|
+
}
|
|
91
|
+
return result;
|
|
92
|
+
}
|
|
93
|
+
export function zip64Extra(values, retained) {
|
|
94
|
+
if (retained.length + 4 + values.length * 8 > 65535)
|
|
95
|
+
fail("ZIP64 extra field limit exceeded");
|
|
96
|
+
const bytes = new Uint8Array(4 + values.length * 8 + retained.length);
|
|
97
|
+
const view = new DataView(bytes.buffer);
|
|
98
|
+
view.setUint16(0, 1, true);
|
|
99
|
+
view.setUint16(2, values.length * 8, true);
|
|
100
|
+
values.forEach((value, index) => view.setBigUint64(4 + index * 8, BigInt(value), true));
|
|
101
|
+
bytes.set(retained, 4 + values.length * 8);
|
|
102
|
+
return bytes;
|
|
103
|
+
}
|
|
104
|
+
export function writeZip64End(view, offset, count, size, start, recordOffset = offset) {
|
|
105
|
+
view.setUint32(offset, 0x06064b50, true);
|
|
106
|
+
view.setBigUint64(offset + 4, 44n, true);
|
|
107
|
+
view.setUint16(offset + 12, 0x32d, true);
|
|
108
|
+
view.setUint16(offset + 14, 45, true);
|
|
109
|
+
view.setBigUint64(offset + 24, BigInt(count), true);
|
|
110
|
+
view.setBigUint64(offset + 32, BigInt(count), true);
|
|
111
|
+
view.setBigUint64(offset + 40, BigInt(size), true);
|
|
112
|
+
view.setBigUint64(offset + 48, BigInt(start), true);
|
|
113
|
+
view.setUint32(offset + 56, 0x07064b50, true);
|
|
114
|
+
view.setBigUint64(offset + 64, BigInt(recordOffset), true);
|
|
115
|
+
view.setUint32(offset + 72, 1, true);
|
|
116
|
+
return offset + 76;
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=zip64.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zip64.js","sourceRoot":"","sources":["../../../../src/commands/archive/zip/zip64.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAsB,MAAM,gBAAgB,CAAC;AAE1D,SAAS,IAAI,CAAC,IAAc,EAAE,MAAc;IAC1C,IAAI,MAAM,GAAG,CAAC,IAAI,MAAM,GAAG,CAAC,GAAG,IAAI,CAAC,UAAU;QAAE,IAAI,CAAC,+BAA+B,CAAC,CAAC;IACtF,MAAM,KAAK,GAAG,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAC9C,IAAI,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC;QAAE,IAAI,CAAC,4BAA4B,CAAC,CAAC;IAChF,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,IAAc,EAAE,GAAW,EAAE,MAAqB;IAC/E,IAAI,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,GAAG,EAAE,EAAE,IAAI,CAAC,CAAC;IAC7C,IAAI,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,GAAG,EAAE,EAAE,IAAI,CAAC,CAAC;IACjD,IAAI,YAAY,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,GAAG,EAAE,EAAE,IAAI,CAAC,CAAC;IAClD,IAAI,UAAU,GAAG,GAAG,CAAC;IACrB,MAAM,WAAW,GAAG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AAE,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC;IACnD,IAAI,CAAC,YAAY,CAAC,MAAM,GAAG,EAAE,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,CAAC;IACpD,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,EAAE,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC;IAC9C,IAAI,CAAC,YAAY,CAAC,MAAM,GAAG,EAAE,EAAE,MAAM,CAAC,YAAY,CAAC,EAAE,IAAI,CAAC,CAAC;IAC3D,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,EAAE,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC;IACrC,OAAO,MAAM,GAAG,EAAE,CAAC;AACrB,CAAC"}
|
|
@@ -10,6 +10,7 @@ export interface ZipEntry {
|
|
|
10
10
|
mode: number;
|
|
11
11
|
directory: boolean;
|
|
12
12
|
symlink: boolean;
|
|
13
|
+
zip64?: boolean;
|
|
13
14
|
rawName?: Uint8Array;
|
|
14
15
|
localName?: Uint8Array;
|
|
15
16
|
comment?: Uint8Array;
|
|
@@ -35,5 +36,7 @@ export declare function makeZipEntry(name: string, bytes: Uint8Array, attributes
|
|
|
35
36
|
directory: boolean;
|
|
36
37
|
symlink: boolean;
|
|
37
38
|
}, limits: ArchiveLimits, signal: AbortSignal, level?: number, forceCompression?: boolean): Promise<ZipEntry>;
|
|
38
|
-
export declare function
|
|
39
|
+
export declare function updateZipExtras(entry: ZipEntry, previous: ZipEntry | undefined, mode: "strip" | "all", limits: ArchiveLimits): ZipEntry;
|
|
40
|
+
export declare function streamZipArchive(archive: ZipArchive, limits: ArchiveLimits, signal: AbortSignal, descriptors?: boolean, forceZip64?: boolean): ByteSource;
|
|
41
|
+
export declare function writeZipArchive(archive: ZipArchive, limits: ArchiveLimits, signal: AbortSignal, descriptors?: boolean, forceZip64?: boolean): Promise<Uint8Array>;
|
|
39
42
|
//# sourceMappingURL=zip-format.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zip-format.d.ts","sourceRoot":"","sources":["../../../src/commands/archive/zip-format.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"zip-format.d.ts","sourceRoot":"","sources":["../../../src/commands/archive/zip-format.ts"],"names":[],"mappings":"AACA,OAAO,EAAgB,KAAK,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAGzE,OAAO,EAAc,KAAK,aAAa,EAAE,MAAM,eAAe,CAAC;AAE/D,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,IAAI,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,OAAO,CAAC,EAAE,UAAU,CAAC;IACrB,SAAS,CAAC,EAAE,UAAU,CAAC;IACvB,OAAO,CAAC,EAAE,UAAU,CAAC;IACrB,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,YAAY,CAAC,EAAE,UAAU,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,SAAS,QAAQ,EAAE,CAAC;IAC7B,OAAO,EAAE,UAAU,CAAC;CACrB;AAUD,wBAAgB,KAAK,CAAC,KAAK,EAAE,UAAU,EAAE,QAAQ,SAAI,GAAG,MAAM,CAI7D;A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2
3
|
import { yieldTurn } from "../../contracts/yield.js";
|
|
3
4
|
import { codec, CodecReader } from "../bytes/compression/codec.js";
|
|
4
5
|
import { fail, text } from "./internal.js";
|
|
@@ -70,8 +71,11 @@ function extras(bytes, rawName, comment, central, limits) {
|
|
|
70
71
|
if (seen.has(identifier))
|
|
71
72
|
fail("ZIP duplicate extra field");
|
|
72
73
|
seen.add(identifier);
|
|
73
|
-
if (identifier === 1)
|
|
74
|
-
|
|
74
|
+
if (identifier === 1) {
|
|
75
|
+
if (!length || length > 28 || length % 4)
|
|
76
|
+
fail("ZIP64 invalid extra field length");
|
|
77
|
+
result.zip64 = bytes.subarray(offset, offset + length);
|
|
78
|
+
}
|
|
75
79
|
if (identifier === 0x9901 || identifier === 0x0017 || identifier === 0x0018 || identifier === 0x0019)
|
|
76
80
|
fail("ZIP encryption is unsupported");
|
|
77
81
|
if (identifier === 0x7075 || identifier === 0x6375) {
|
|
@@ -120,7 +124,7 @@ function format(method, flags, version) {
|
|
|
120
124
|
fail("ZIP unsupported general purpose flags");
|
|
121
125
|
if (method !== 0 && method !== 8)
|
|
122
126
|
fail("ZIP unsupported compression method");
|
|
123
|
-
if (version < (method === 8 || flags & 8 ? 20 : 10) || version > 20)
|
|
127
|
+
if (version < (method === 8 || flags & 8 ? 20 : 10) || version > 20 && version !== 45)
|
|
124
128
|
fail("ZIP unsupported extraction version (including ZIP64)");
|
|
125
129
|
}
|
|
126
130
|
function dosModified(date, time) {
|
|
@@ -183,16 +187,7 @@ export async function readZipArchive(bytes, limits, signal) {
|
|
|
183
187
|
}
|
|
184
188
|
if (end === -1)
|
|
185
189
|
fail("ZIP truncated or missing end of central directory");
|
|
186
|
-
const members = view
|
|
187
|
-
const centralSize = view.getUint32(end + 12, true);
|
|
188
|
-
const centralStart = view.getUint32(end + 16, true);
|
|
189
|
-
if (members === 65535 || centralSize === 0xffffffff || centralStart === 0xffffffff)
|
|
190
|
-
fail("ZIP64 is unsupported");
|
|
191
|
-
if (view.getUint16(end + 4, true) || view.getUint16(end + 6, true) || view.getUint16(end + 8, true) !== members)
|
|
192
|
-
fail("ZIP multi-disk or inconsistent member count is unsupported");
|
|
193
|
-
if (centralStart + centralSize !== end)
|
|
194
|
-
fail("ZIP invalid central directory span or unsupported ZIP64/trailing records");
|
|
195
|
-
number(members, limits.maxMembers, "member");
|
|
190
|
+
const { members, centralStart, centralEnd } = zip64Directory(view, end, limits);
|
|
196
191
|
number(bytes.length - end - 22, limits.maxTextBytes, "archive comment");
|
|
197
192
|
const entries = [];
|
|
198
193
|
const spans = [];
|
|
@@ -200,7 +195,7 @@ export async function readZipArchive(bytes, limits, signal) {
|
|
|
200
195
|
let total = 0;
|
|
201
196
|
for (let index = 0; index < members; index++) {
|
|
202
197
|
await yieldTurn(signal);
|
|
203
|
-
if (offset + 46 >
|
|
198
|
+
if (offset + 46 > centralEnd || view.getUint32(offset, true) !== 0x02014b50)
|
|
204
199
|
fail("ZIP truncated or invalid central header");
|
|
205
200
|
const versionMadeBy = view.getUint16(offset + 4, true);
|
|
206
201
|
const version = view.getUint16(offset + 6, true);
|
|
@@ -210,8 +205,8 @@ export async function readZipArchive(bytes, limits, signal) {
|
|
|
210
205
|
const dosTime = view.getUint16(offset + 12, true);
|
|
211
206
|
const dosDate = view.getUint16(offset + 14, true);
|
|
212
207
|
const checksum = view.getUint32(offset + 16, true);
|
|
213
|
-
|
|
214
|
-
|
|
208
|
+
let compressedSize = view.getUint32(offset + 20, true);
|
|
209
|
+
let size = view.getUint32(offset + 24, true);
|
|
215
210
|
const nameLength = view.getUint16(offset + 28, true);
|
|
216
211
|
const extraLength = view.getUint16(offset + 30, true);
|
|
217
212
|
const commentLength = view.getUint16(offset + 32, true);
|
|
@@ -219,18 +214,10 @@ export async function readZipArchive(bytes, limits, signal) {
|
|
|
219
214
|
if (internalAttributes & ~1)
|
|
220
215
|
fail("ZIP unsupported internal attributes");
|
|
221
216
|
const externalAttributes = view.getUint32(offset + 38, true);
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
fail("ZIP multi-disk member is unsupported");
|
|
225
|
-
if (compressedSize === 0xffffffff || size === 0xffffffff || local === 0xffffffff)
|
|
226
|
-
fail("ZIP64 is unsupported");
|
|
227
|
-
number(size, limits.maxEntryBytes, "entry byte");
|
|
228
|
-
if (method === 0 && compressedSize !== size)
|
|
229
|
-
fail("ZIP stored size mismatch");
|
|
230
|
-
total += size;
|
|
231
|
-
number(total, limits.maxTotalBytes, "total byte");
|
|
217
|
+
let local = view.getUint32(offset + 42, true);
|
|
218
|
+
const disk = view.getUint16(offset + 34, true);
|
|
232
219
|
const next = offset + 46 + nameLength + extraLength + commentLength;
|
|
233
|
-
if (next >
|
|
220
|
+
if (next > centralEnd)
|
|
234
221
|
fail("ZIP truncated central metadata");
|
|
235
222
|
number(commentLength, limits.maxTextBytes, "entry comment");
|
|
236
223
|
const rawName = bytes.subarray(offset + 46, offset + 46 + nameLength);
|
|
@@ -239,6 +226,16 @@ export async function readZipArchive(bytes, limits, signal) {
|
|
|
239
226
|
if (flags & 0x800)
|
|
240
227
|
text(comment);
|
|
241
228
|
const centralMetadata = extras(centralExtra, rawName, comment, true, limits);
|
|
229
|
+
const resolved = zip64Fields(centralMetadata.zip64, [size, compressedSize, local, disk === 65535 ? 0xffffffff : disk]);
|
|
230
|
+
[size, compressedSize, local] = resolved;
|
|
231
|
+
if (resolved[3])
|
|
232
|
+
fail("ZIP multi-disk member is unsupported");
|
|
233
|
+
number(size, limits.maxEntryBytes, "entry byte");
|
|
234
|
+
number(compressedSize, limits.maxArchiveBytes, "compressed entry byte");
|
|
235
|
+
if (method === 0 && compressedSize !== size)
|
|
236
|
+
fail("ZIP stored size mismatch");
|
|
237
|
+
total += size;
|
|
238
|
+
number(total, limits.maxTotalBytes, "total byte");
|
|
242
239
|
const name = nameFrom(rawName, flags, centralMetadata, limits);
|
|
243
240
|
if (local + 30 > centralStart || view.getUint32(local, true) !== 0x04034b50)
|
|
244
241
|
fail("ZIP invalid local header span");
|
|
@@ -260,8 +257,10 @@ export async function readZipArchive(bytes, limits, signal) {
|
|
|
260
257
|
fail("ZIP central/local Unicode name mismatch");
|
|
261
258
|
if (centralMetadata.modified !== undefined && localMetadata.modified !== undefined && centralMetadata.modified !== localMetadata.modified)
|
|
262
259
|
fail("ZIP central/local timestamp mismatch");
|
|
263
|
-
|
|
264
|
-
|
|
260
|
+
const rawLocalSize = view.getUint32(local + 22, true);
|
|
261
|
+
const rawLocalCompressed = view.getUint32(local + 18, true);
|
|
262
|
+
const [localSize, localCompressed] = zip64Fields(localMetadata.zip64, [rawLocalSize, rawLocalCompressed]);
|
|
263
|
+
for (const [actual, expected] of [[view.getUint32(local + 14, true), checksum], [localCompressed, compressedSize], [localSize, size]]) {
|
|
265
264
|
if (actual !== expected && (!(flags & 8) || actual !== 0))
|
|
266
265
|
fail("ZIP central/local size or CRC mismatch");
|
|
267
266
|
}
|
|
@@ -269,8 +268,14 @@ export async function readZipArchive(bytes, limits, signal) {
|
|
|
269
268
|
const matches = [];
|
|
270
269
|
for (const signed of [false, true]) {
|
|
271
270
|
const descriptor = payloadEnd + (signed ? 4 : 0);
|
|
272
|
-
|
|
273
|
-
|
|
271
|
+
const wide = rawLocalSize === 0xffffffff || rawLocalCompressed === 0xffffffff;
|
|
272
|
+
const length = wide ? 20 : 12;
|
|
273
|
+
if (descriptor + length > centralStart || signed && view.getUint32(payloadEnd, true) !== 0x08074b50 || view.getUint32(descriptor, true) !== checksum)
|
|
274
|
+
continue;
|
|
275
|
+
const compressed = wide ? view.getBigUint64(descriptor + 4, true) : BigInt(view.getUint32(descriptor + 4, true));
|
|
276
|
+
const expanded = wide ? view.getBigUint64(descriptor + 12, true) : BigInt(view.getUint32(descriptor + 8, true));
|
|
277
|
+
if (compressed === BigInt(compressedSize) && expanded === BigInt(size))
|
|
278
|
+
matches.push(descriptor + length);
|
|
274
279
|
}
|
|
275
280
|
if (matches.length !== 1)
|
|
276
281
|
fail("ZIP truncated, ambiguous or mismatched data descriptor");
|
|
@@ -293,7 +298,7 @@ export async function readZipArchive(bytes, limits, signal) {
|
|
|
293
298
|
spans.push({ start: local, end: payloadEnd });
|
|
294
299
|
offset = next;
|
|
295
300
|
}
|
|
296
|
-
if (offset !==
|
|
301
|
+
if (offset !== centralEnd)
|
|
297
302
|
fail("ZIP central directory size or member count mismatch");
|
|
298
303
|
spans.sort((first, second) => first.start - second.start);
|
|
299
304
|
let covered = 0;
|
|
@@ -401,11 +406,44 @@ function timestampExtra(modified) {
|
|
|
401
406
|
view.setInt32(5, seconds, true);
|
|
402
407
|
return bytes;
|
|
403
408
|
}
|
|
404
|
-
export
|
|
409
|
+
export function updateZipExtras(entry, previous, mode, limits) {
|
|
410
|
+
const fresh = mode === "strip" ? new Uint8Array() : timestampExtra(entry.modified);
|
|
411
|
+
const retained = [];
|
|
412
|
+
for (const [original, central] of [[previous?.localExtra, false], [previous?.centralExtra, true]]) {
|
|
413
|
+
const fields = [];
|
|
414
|
+
let length = fresh.length;
|
|
415
|
+
if (mode === "all" && original) {
|
|
416
|
+
extras(original, previous.rawName ?? pathBytes(previous.name, limits), previous.comment ?? new Uint8Array(), central, limits);
|
|
417
|
+
const view = new DataView(original.buffer, original.byteOffset, original.byteLength);
|
|
418
|
+
for (let offset = 0; offset < original.length;) {
|
|
419
|
+
const identifier = view.getUint16(offset, true);
|
|
420
|
+
const next = offset + 4 + view.getUint16(offset + 2, true);
|
|
421
|
+
// Sizes, timestamps and Unicode names/comments are rebuilt for the new entry.
|
|
422
|
+
if (identifier !== 1 && identifier !== 0x5455 && identifier !== 0x7075 && identifier !== 0x6375) {
|
|
423
|
+
fields.push(original.subarray(offset, next));
|
|
424
|
+
length += next - offset;
|
|
425
|
+
}
|
|
426
|
+
offset = next;
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
number(length, Math.min(limits.maxPaxBytes, 65535), "extra field");
|
|
430
|
+
const bytes = new Uint8Array(length);
|
|
431
|
+
let offset = 0;
|
|
432
|
+
for (const field of fields) {
|
|
433
|
+
bytes.set(field, offset);
|
|
434
|
+
offset += field.length;
|
|
435
|
+
}
|
|
436
|
+
bytes.set(fresh, offset);
|
|
437
|
+
retained.push(bytes);
|
|
438
|
+
}
|
|
439
|
+
return { ...entry, localExtra: retained[0], centralExtra: retained[1] };
|
|
440
|
+
}
|
|
441
|
+
export async function* streamZipArchive(archive, limits, signal, descriptors = false, forceZip64 = false) {
|
|
405
442
|
const chunkSize = admit(limits, signal);
|
|
406
443
|
number(archive.entries.length, Math.min(limits.maxMembers, 65534), "member");
|
|
407
444
|
number(archive.comment.length, Math.min(limits.maxTextBytes, 65535), "archive comment");
|
|
408
|
-
|
|
445
|
+
const wideArchive = forceZip64 || archive.entries.some(entry => entry.zip64);
|
|
446
|
+
let length = 22 + archive.comment.length + (wideArchive ? 76 : 0);
|
|
409
447
|
let localLength = 0;
|
|
410
448
|
let total = 0;
|
|
411
449
|
const encoded = [];
|
|
@@ -423,8 +461,13 @@ export async function writeZipArchive(archive, limits, signal, descriptors = fal
|
|
|
423
461
|
number(comment.length, Math.min(limits.maxTextBytes, 65535), "entry comment");
|
|
424
462
|
if (flags & 0x800)
|
|
425
463
|
text(comment);
|
|
426
|
-
const
|
|
427
|
-
|
|
464
|
+
const originalLocalExtra = entry.localExtra ?? timestampExtra(entry.modified);
|
|
465
|
+
extras(originalLocalExtra, rawName, comment, false, limits);
|
|
466
|
+
const wide = forceZip64 || entry.zip64 === true;
|
|
467
|
+
const localExtra = wide ? zip64Extra([descriptor ? 0 : entry.size, descriptor ? 0 : entry.data.length], stripZip64(originalLocalExtra)) : stripZip64(originalLocalExtra);
|
|
468
|
+
const originalCentralExtra = entry.centralExtra ?? timestampExtra(entry.modified);
|
|
469
|
+
extras(originalCentralExtra, rawName, comment, true, limits);
|
|
470
|
+
const centralExtra = wide ? zip64Extra([entry.size, entry.data.length, localLength], stripZip64(originalCentralExtra)) : stripZip64(originalCentralExtra);
|
|
428
471
|
const localMetadata = extras(localExtra, rawName, comment, false, limits);
|
|
429
472
|
const centralMetadata = extras(centralExtra, rawName, comment, true, limits);
|
|
430
473
|
if (nameFrom(rawName, flags, centralMetadata, limits) !== entry.name || localMetadata.name !== undefined && nameFrom(rawName, flags, localMetadata, limits) !== entry.name || entry.localName && !equal(rawName, entry.localName))
|
|
@@ -452,19 +495,19 @@ export async function writeZipArchive(archive, limits, signal, descriptors = fal
|
|
|
452
495
|
if (mode !== entry.mode || Boolean(entry.externalAttributes & 16) && !entry.directory)
|
|
453
496
|
fail("ZIP retained file attributes mismatch");
|
|
454
497
|
}
|
|
455
|
-
encoded.push({ entry, rawName, flags, localExtra, centralExtra, comment, date, time, offset: localLength });
|
|
456
|
-
localLength += 30 + rawName.length + localExtra.length + entry.data.length + (descriptor ? 16 : 0);
|
|
457
|
-
length += 76 + 2 * rawName.length + localExtra.length + centralExtra.length + comment.length + entry.data.length + (descriptor ? 16 : 0);
|
|
498
|
+
encoded.push({ entry, rawName, wide, flags, localExtra, centralExtra, comment, date, time, offset: localLength });
|
|
499
|
+
localLength += 30 + rawName.length + localExtra.length + entry.data.length + (descriptor ? wide ? 24 : 16 : 0);
|
|
500
|
+
length += 76 + 2 * rawName.length + localExtra.length + centralExtra.length + comment.length + entry.data.length + (descriptor ? wide ? 24 : 16 : 0);
|
|
458
501
|
number(length, Math.min(limits.maxArchiveBytes, 0xfffffffe), "archive byte");
|
|
459
502
|
}
|
|
460
503
|
number(length, Math.min(limits.maxArchiveBytes, 0xfffffffe), "archive byte");
|
|
461
|
-
const bytes = new Uint8Array(length);
|
|
462
|
-
const view = new DataView(bytes.buffer);
|
|
463
|
-
let central = localLength;
|
|
464
504
|
for (const item of encoded) {
|
|
465
505
|
await yieldTurn(signal);
|
|
466
|
-
const { entry, rawName, flags, localExtra,
|
|
467
|
-
const
|
|
506
|
+
const { entry, rawName, wide, flags, localExtra, date, time } = item;
|
|
507
|
+
const offset = 0;
|
|
508
|
+
const bytes = new Uint8Array(30 + rawName.length + localExtra.length);
|
|
509
|
+
const view = new DataView(bytes.buffer);
|
|
510
|
+
const version = wide ? 45 : entry.method === 8 || flags & 8 ? 20 : 10;
|
|
468
511
|
view.setUint32(offset, 0x04034b50, true);
|
|
469
512
|
view.setUint16(offset + 4, version, true);
|
|
470
513
|
view.setUint16(offset + 6, flags, true);
|
|
@@ -472,20 +515,39 @@ export async function writeZipArchive(archive, limits, signal, descriptors = fal
|
|
|
472
515
|
view.setUint16(offset + 10, time, true);
|
|
473
516
|
view.setUint16(offset + 12, date, true);
|
|
474
517
|
view.setUint32(offset + 14, flags & 8 ? 0 : entry.crc32, true);
|
|
475
|
-
view.setUint32(offset + 18, flags & 8 ? 0 : entry.data.length, true);
|
|
476
|
-
view.setUint32(offset + 22, flags & 8 ? 0 : entry.size, true);
|
|
518
|
+
view.setUint32(offset + 18, wide ? 0xffffffff : flags & 8 ? 0 : entry.data.length, true);
|
|
519
|
+
view.setUint32(offset + 22, wide ? 0xffffffff : flags & 8 ? 0 : entry.size, true);
|
|
477
520
|
view.setUint16(offset + 26, rawName.length, true);
|
|
478
521
|
view.setUint16(offset + 28, localExtra.length, true);
|
|
479
522
|
bytes.set(rawName, offset + 30);
|
|
480
523
|
bytes.set(localExtra, offset + 30 + rawName.length);
|
|
481
|
-
|
|
524
|
+
yield* wireChunks(bytes, chunkSize, signal);
|
|
525
|
+
yield* wireChunks(entry.data, chunkSize, signal);
|
|
482
526
|
if (flags & 8) {
|
|
483
|
-
const descriptor =
|
|
527
|
+
const descriptor = 0;
|
|
528
|
+
const bytes = new Uint8Array(wide ? 24 : 16);
|
|
529
|
+
const view = new DataView(bytes.buffer);
|
|
484
530
|
view.setUint32(descriptor, 0x08074b50, true);
|
|
485
531
|
view.setUint32(descriptor + 4, entry.crc32, true);
|
|
486
|
-
|
|
487
|
-
|
|
532
|
+
if (wide) {
|
|
533
|
+
view.setBigUint64(descriptor + 8, BigInt(entry.data.length), true);
|
|
534
|
+
view.setBigUint64(descriptor + 16, BigInt(entry.size), true);
|
|
535
|
+
}
|
|
536
|
+
else {
|
|
537
|
+
view.setUint32(descriptor + 8, entry.data.length, true);
|
|
538
|
+
view.setUint32(descriptor + 12, entry.size, true);
|
|
539
|
+
}
|
|
540
|
+
yield* wireChunks(bytes, chunkSize, signal);
|
|
488
541
|
}
|
|
542
|
+
}
|
|
543
|
+
let centralSize = 0;
|
|
544
|
+
for (const item of encoded) {
|
|
545
|
+
await yieldTurn(signal);
|
|
546
|
+
const { entry, rawName, wide, flags, centralExtra, comment, date, time, offset } = item;
|
|
547
|
+
const version = wide ? 45 : entry.method === 8 || flags & 8 ? 20 : 10;
|
|
548
|
+
const central = 0;
|
|
549
|
+
const bytes = new Uint8Array(46 + rawName.length + centralExtra.length + comment.length);
|
|
550
|
+
const view = new DataView(bytes.buffer);
|
|
489
551
|
view.setUint32(central, 0x02014b50, true);
|
|
490
552
|
view.setUint16(central + 4, entry.versionMadeBy ?? 0x31e, true);
|
|
491
553
|
view.setUint16(central + 6, version, true);
|
|
@@ -494,28 +556,40 @@ export async function writeZipArchive(archive, limits, signal, descriptors = fal
|
|
|
494
556
|
view.setUint16(central + 12, time, true);
|
|
495
557
|
view.setUint16(central + 14, date, true);
|
|
496
558
|
view.setUint32(central + 16, entry.crc32, true);
|
|
497
|
-
view.setUint32(central + 20, entry.data.length, true);
|
|
498
|
-
view.setUint32(central + 24, entry.size, true);
|
|
559
|
+
view.setUint32(central + 20, wide ? 0xffffffff : entry.data.length, true);
|
|
560
|
+
view.setUint32(central + 24, wide ? 0xffffffff : entry.size, true);
|
|
499
561
|
view.setUint16(central + 28, rawName.length, true);
|
|
500
562
|
view.setUint16(central + 30, centralExtra.length, true);
|
|
501
563
|
view.setUint16(central + 32, comment.length, true);
|
|
502
564
|
view.setUint16(central + 36, entry.internalAttributes ?? 0, true);
|
|
503
565
|
const mode = entry.mode & 0o170000 ? entry.mode : entry.mode | (entry.directory ? 0o040000 : entry.symlink ? 0o120000 : 0o100000);
|
|
504
566
|
view.setUint32(central + 38, entry.externalAttributes ?? (mode * 65536 + (entry.directory ? 16 : 0)), true);
|
|
505
|
-
view.setUint32(central + 42, offset, true);
|
|
567
|
+
view.setUint32(central + 42, wide ? 0xffffffff : offset, true);
|
|
506
568
|
bytes.set(rawName, central + 46);
|
|
507
569
|
bytes.set(centralExtra, central + 46 + rawName.length);
|
|
508
570
|
bytes.set(comment, central + 46 + rawName.length + centralExtra.length);
|
|
509
|
-
|
|
571
|
+
centralSize += bytes.length;
|
|
572
|
+
yield* wireChunks(bytes, chunkSize, signal);
|
|
510
573
|
}
|
|
574
|
+
const bytes = new Uint8Array((wideArchive ? 76 : 0) + 22 + archive.comment.length);
|
|
575
|
+
const view = new DataView(bytes.buffer);
|
|
576
|
+
const central = wideArchive ? writeZip64End(view, 0, encoded.length, centralSize, localLength, localLength + centralSize) : 0;
|
|
511
577
|
view.setUint32(central, 0x06054b50, true);
|
|
512
578
|
view.setUint16(central + 8, encoded.length, true);
|
|
513
579
|
view.setUint16(central + 10, encoded.length, true);
|
|
514
|
-
view.setUint32(central + 12,
|
|
515
|
-
view.setUint32(central + 16, localLength, true);
|
|
580
|
+
view.setUint32(central + 12, centralSize, true);
|
|
581
|
+
view.setUint32(central + 16, wideArchive ? 0xffffffff : localLength, true);
|
|
516
582
|
view.setUint16(central + 20, archive.comment.length, true);
|
|
517
583
|
bytes.set(archive.comment, central + 22);
|
|
518
|
-
signal
|
|
519
|
-
|
|
584
|
+
yield* wireChunks(bytes, chunkSize, signal);
|
|
585
|
+
}
|
|
586
|
+
async function* wireChunks(bytes, chunkSize, signal) {
|
|
587
|
+
for (let offset = 0; offset < bytes.length; offset += chunkSize) {
|
|
588
|
+
await yieldTurn(signal);
|
|
589
|
+
yield new Uint8Array(bytes.subarray(offset, Math.min(bytes.length, offset + chunkSize)));
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
export async function writeZipArchive(archive, limits, signal, descriptors = false, forceZip64 = false) {
|
|
593
|
+
return collectBytes(streamZipArchive(archive, limits, signal, descriptors, forceZip64), { maxBytes: limits.maxArchiveBytes, signal });
|
|
520
594
|
}
|
|
521
595
|
//# sourceMappingURL=zip-format.js.map
|