@patrickdk77/archive-defuse 0.0.0-stage → 0.1.0
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/LICENSE +21 -0
- package/README.md +345 -2
- package/dist/aes7z.d.ts +16 -0
- package/dist/aes7z.js +131 -0
- package/dist/alone.d.ts +21 -0
- package/dist/alone.js +65 -0
- package/dist/bcj2.d.ts +21 -0
- package/dist/bcj2.js +140 -0
- package/dist/bzip2.d.ts +21 -0
- package/dist/bzip2.js +688 -0
- package/dist/cab.d.ts +63 -0
- package/dist/cab.js +493 -0
- package/dist/checks.d.ts +23 -0
- package/dist/checks.js +123 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +364 -0
- package/dist/codecs.d.ts +39 -0
- package/dist/codecs.js +124 -0
- package/dist/coders.d.ts +58 -0
- package/dist/coders.js +392 -0
- package/dist/crc32.d.ts +8 -0
- package/dist/crc32.js +59 -0
- package/dist/encoder.d.ts +44 -0
- package/dist/encoder.js +114 -0
- package/dist/engine.d.ts +44 -0
- package/dist/engine.js +753 -0
- package/dist/errors.d.ts +64 -0
- package/dist/errors.js +98 -0
- package/dist/filters.d.ts +34 -0
- package/dist/filters.js +385 -0
- package/dist/findings.d.ts +26 -0
- package/dist/findings.js +176 -0
- package/dist/formats.d.ts +14 -0
- package/dist/formats.js +97 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +50 -0
- package/dist/index.mjs +3 -0
- package/dist/inflate64.d.ts +6 -0
- package/dist/inflate64.js +388 -0
- package/dist/io.d.ts +78 -0
- package/dist/io.js +379 -0
- package/dist/lzma-formats.d.ts +75 -0
- package/dist/lzma-formats.js +373 -0
- package/dist/lzma-sniff.d.ts +20 -0
- package/dist/lzma-sniff.js +73 -0
- package/dist/lzma-writers.d.ts +35 -0
- package/dist/lzma-writers.js +276 -0
- package/dist/lzma1/LICENSE +201 -0
- package/dist/lzma1/NOTICE +36 -0
- package/dist/lzma1/crc32.d.ts +4 -0
- package/dist/lzma1/crc32.js +19 -0
- package/dist/lzma1/hash234.d.ts +22 -0
- package/dist/lzma1/hash234.js +75 -0
- package/dist/lzma1/hc4.d.ts +30 -0
- package/dist/lzma1/hc4.js +142 -0
- package/dist/lzma1/header.d.ts +32 -0
- package/dist/lzma1/header.js +73 -0
- package/dist/lzma1/lz-decoder.d.ts +41 -0
- package/dist/lzma1/lz-decoder.js +128 -0
- package/dist/lzma1/lz-encoder.d.ts +87 -0
- package/dist/lzma1/lz-encoder.js +166 -0
- package/dist/lzma1/lzma-coder.d.ts +107 -0
- package/dist/lzma1/lzma-coder.js +162 -0
- package/dist/lzma1/lzma-decoder.d.ts +36 -0
- package/dist/lzma1/lzma-decoder.js +484 -0
- package/dist/lzma1/lzma-encoder-fast.d.ts +13 -0
- package/dist/lzma1/lzma-encoder-fast.js +114 -0
- package/dist/lzma1/lzma-encoder.d.ts +105 -0
- package/dist/lzma1/lzma-encoder.js +497 -0
- package/dist/lzma1/lzma2-decoder.d.ts +85 -0
- package/dist/lzma1/lzma2-decoder.js +249 -0
- package/dist/lzma1/range-coder.d.ts +18 -0
- package/dist/lzma1/range-coder.js +23 -0
- package/dist/lzma1/range-decoder.d.ts +41 -0
- package/dist/lzma1/range-decoder.js +78 -0
- package/dist/lzma1/range-encoder.d.ts +53 -0
- package/dist/lzma1/range-encoder.js +269 -0
- package/dist/lzma1-stream.d.ts +60 -0
- package/dist/lzma1-stream.js +202 -0
- package/dist/model.d.ts +141 -0
- package/dist/model.js +16 -0
- package/dist/names.d.ts +13 -0
- package/dist/names.js +66 -0
- package/dist/pack.d.ts +72 -0
- package/dist/pack.js +514 -0
- package/dist/plugins.d.ts +13 -0
- package/dist/plugins.js +55 -0
- package/dist/rules.d.ts +25 -0
- package/dist/rules.js +403 -0
- package/dist/score.d.ts +17 -0
- package/dist/score.js +58 -0
- package/dist/seven.d.ts +75 -0
- package/dist/seven.js +492 -0
- package/dist/sevenzip.d.ts +133 -0
- package/dist/sevenzip.js +529 -0
- package/dist/single.d.ts +103 -0
- package/dist/single.js +453 -0
- package/dist/sniff.d.ts +20 -0
- package/dist/sniff.js +224 -0
- package/dist/stream-meter.d.ts +39 -0
- package/dist/stream-meter.js +54 -0
- package/dist/tar.d.ts +102 -0
- package/dist/tar.js +765 -0
- package/dist/types.d.ts +284 -0
- package/dist/types.js +133 -0
- package/dist/unpack.d.ts +67 -0
- package/dist/unpack.js +194 -0
- package/dist/xz.d.ts +25 -0
- package/dist/xz.js +333 -0
- package/dist/zip-lzma.d.ts +15 -0
- package/dist/zip-lzma.js +137 -0
- package/dist/zip-writer.d.ts +41 -0
- package/dist/zip-writer.js +263 -0
- package/dist/zip.d.ts +99 -0
- package/dist/zip.js +901 -0
- package/dist/zipcrypt.d.ts +47 -0
- package/dist/zipcrypt.js +233 -0
- package/dist/zstd.d.ts +25 -0
- package/dist/zstd.js +160 -0
- package/package.json +94 -4
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ZipOutput = exports.METADATA_EXTRAS = void 0;
|
|
4
|
+
exports.writeZip = writeZip;
|
|
5
|
+
// Copied from office-defuse src/zip-writer.ts. Changed: an entry keeps its method, times, permissions, comment and the
|
|
6
|
+
// extra fields the plan keeps, and either copies its compressed bytes without their encryption or is compressed again
|
|
7
|
+
// from the content the plan gives. Data the plan keeps before and after the archive is written around it.
|
|
8
|
+
const codecs_1 = require("./codecs");
|
|
9
|
+
const crc32_1 = require("./crc32");
|
|
10
|
+
const io_1 = require("./io");
|
|
11
|
+
const model_1 = require("./model");
|
|
12
|
+
/** Extra field records that hold only times and owners. The rewrite keeps them unless metadata is stripped. */
|
|
13
|
+
exports.METADATA_EXTRAS = new Set([0x5455, 0x000a, 0x7875, 0x5855, 0x7855]);
|
|
14
|
+
const MAX16 = 0xffff;
|
|
15
|
+
const MAX32 = 0xffffffff;
|
|
16
|
+
/** 1980-01-01 00:00, the earliest date a ZIP header holds, for entries whose times are stripped. */
|
|
17
|
+
const DOS_DATE = (0 << 9) | (1 << 5) | 1;
|
|
18
|
+
/** Unix file type bits, for the attributes of an entry that has permissions. */
|
|
19
|
+
const TYPE_BITS = { file: 0o100000, directory: 0o040000, symlink: 0o120000 };
|
|
20
|
+
class Builder {
|
|
21
|
+
parts = [];
|
|
22
|
+
u16(v) {
|
|
23
|
+
this.parts.push(v & 0xff, (v >>> 8) & 0xff);
|
|
24
|
+
return this;
|
|
25
|
+
}
|
|
26
|
+
u32(v) {
|
|
27
|
+
return this.u16(v & 0xffff).u16(Math.floor(v / 0x10000) & 0xffff);
|
|
28
|
+
}
|
|
29
|
+
u64(v) {
|
|
30
|
+
return this.u32(v % 0x100000000).u32(Math.floor(v / 0x100000000));
|
|
31
|
+
}
|
|
32
|
+
bytes(b) {
|
|
33
|
+
for (const x of b)
|
|
34
|
+
this.parts.push(x);
|
|
35
|
+
return this;
|
|
36
|
+
}
|
|
37
|
+
build() {
|
|
38
|
+
return Uint8Array.from(this.parts);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
const versionFor = (method) => (method === 93 || method === 14 || method === 95 ? 63 : method === 12 ? 46 : method === 9 ? 21 : 20);
|
|
42
|
+
/**
|
|
43
|
+
* Writes the entries of a ZIP archive one after another, then its central directory. Local headers carry the CRC and
|
|
44
|
+
* sizes, so no entry needs a data descriptor. ZIP64 records appear only where a size, an offset or the entry count
|
|
45
|
+
* needs them.
|
|
46
|
+
*/
|
|
47
|
+
class ZipOutput {
|
|
48
|
+
sink;
|
|
49
|
+
offset = 0;
|
|
50
|
+
central = [];
|
|
51
|
+
constructor(sink) {
|
|
52
|
+
this.sink = sink;
|
|
53
|
+
}
|
|
54
|
+
/** Writes bytes as they are, such as data kept before the archive. */
|
|
55
|
+
async put(b) {
|
|
56
|
+
await this.sink.write(b);
|
|
57
|
+
this.offset += b.length;
|
|
58
|
+
}
|
|
59
|
+
/** Writes one entry: its local header, then `chunks`, which must hold exactly `info.compressedSize` bytes. */
|
|
60
|
+
async entry(info, chunks, label) {
|
|
61
|
+
const big = info.size >= MAX32 || info.compressedSize >= MAX32;
|
|
62
|
+
const localOffset = this.offset;
|
|
63
|
+
const local = new Builder()
|
|
64
|
+
.u32(0x04034b50)
|
|
65
|
+
.u16(big ? Math.max(45, info.versionNeeded) : info.versionNeeded)
|
|
66
|
+
.u16(info.flags)
|
|
67
|
+
.u16(info.method)
|
|
68
|
+
.u16(info.time)
|
|
69
|
+
.u16(info.date)
|
|
70
|
+
.u32(info.crc)
|
|
71
|
+
.u32(big ? MAX32 : info.compressedSize)
|
|
72
|
+
.u32(big ? MAX32 : info.size)
|
|
73
|
+
.u16(info.name.length)
|
|
74
|
+
.u16(info.extras.length + (big ? 20 : 0))
|
|
75
|
+
.bytes(info.name);
|
|
76
|
+
if (big)
|
|
77
|
+
local.u16(0x0001).u16(16).u64(info.size).u64(info.compressedSize);
|
|
78
|
+
local.bytes(info.extras);
|
|
79
|
+
await this.put(local.build());
|
|
80
|
+
let written = 0;
|
|
81
|
+
for await (const c of chunks()) {
|
|
82
|
+
written += c.length;
|
|
83
|
+
await this.put(c);
|
|
84
|
+
}
|
|
85
|
+
if (written !== info.compressedSize)
|
|
86
|
+
throw new Error(`Entry ${label} has ${written} compressed bytes, not ${info.compressedSize}`);
|
|
87
|
+
const far = localOffset >= MAX32;
|
|
88
|
+
const z64 = new Builder();
|
|
89
|
+
if (info.size >= MAX32)
|
|
90
|
+
z64.u64(info.size);
|
|
91
|
+
if (info.compressedSize >= MAX32)
|
|
92
|
+
z64.u64(info.compressedSize);
|
|
93
|
+
if (far)
|
|
94
|
+
z64.u64(localOffset);
|
|
95
|
+
const z64Bytes = z64.build();
|
|
96
|
+
const needed = z64Bytes.length ? Math.max(45, info.versionNeeded) : info.versionNeeded;
|
|
97
|
+
const c = new Builder()
|
|
98
|
+
.u32(0x02014b50)
|
|
99
|
+
.u16(info.versionMadeBy)
|
|
100
|
+
.u16(needed)
|
|
101
|
+
.u16(info.flags)
|
|
102
|
+
.u16(info.method)
|
|
103
|
+
.u16(info.time)
|
|
104
|
+
.u16(info.date)
|
|
105
|
+
.u32(info.crc)
|
|
106
|
+
.u32(info.compressedSize >= MAX32 ? MAX32 : info.compressedSize)
|
|
107
|
+
.u32(info.size >= MAX32 ? MAX32 : info.size)
|
|
108
|
+
.u16(info.name.length)
|
|
109
|
+
.u16(info.extras.length + (z64Bytes.length ? z64Bytes.length + 4 : 0))
|
|
110
|
+
.u16(info.comment.length)
|
|
111
|
+
.u16(0)
|
|
112
|
+
.u16(info.internalAttr)
|
|
113
|
+
.u32(info.externalAttr)
|
|
114
|
+
.u32(far ? MAX32 : localOffset)
|
|
115
|
+
.bytes(info.name);
|
|
116
|
+
if (z64Bytes.length)
|
|
117
|
+
c.u16(0x0001).u16(z64Bytes.length).bytes(z64Bytes);
|
|
118
|
+
c.bytes(info.extras).bytes(info.comment);
|
|
119
|
+
this.central.push(c.build());
|
|
120
|
+
}
|
|
121
|
+
/** Writes the central directory and the end records, with the archive's comment. */
|
|
122
|
+
async end(comment) {
|
|
123
|
+
const dirOffset = this.offset;
|
|
124
|
+
for (const c of this.central)
|
|
125
|
+
await this.put(c);
|
|
126
|
+
const dirSize = this.offset - dirOffset;
|
|
127
|
+
const count = this.central.length;
|
|
128
|
+
const big = count >= MAX16 || dirOffset >= MAX32 || dirSize >= MAX32;
|
|
129
|
+
if (big) {
|
|
130
|
+
const end64 = this.offset;
|
|
131
|
+
await this.put(new Builder().u32(0x06064b50).u64(44).u16(45).u16(45).u32(0).u32(0).u64(count).u64(count).u64(dirSize).u64(dirOffset).build());
|
|
132
|
+
await this.put(new Builder().u32(0x07064b50).u32(0).u64(end64).u32(1).build());
|
|
133
|
+
}
|
|
134
|
+
await this.put(new Builder()
|
|
135
|
+
.u32(0x06054b50)
|
|
136
|
+
.u16(0)
|
|
137
|
+
.u16(0)
|
|
138
|
+
.u16(big ? MAX16 : count)
|
|
139
|
+
.u16(big ? MAX16 : count)
|
|
140
|
+
.u32(big ? MAX32 : dirSize)
|
|
141
|
+
.u32(big ? MAX32 : dirOffset)
|
|
142
|
+
.u16(comment.length)
|
|
143
|
+
.bytes(comment)
|
|
144
|
+
.build());
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
exports.ZipOutput = ZipOutput;
|
|
148
|
+
/** Writes `zip` again with the entries `plan` keeps. */
|
|
149
|
+
async function writeZip(zip, plan, sink, context) {
|
|
150
|
+
const out = new ZipOutput(sink);
|
|
151
|
+
if (plan.keepLeading)
|
|
152
|
+
for await (const c of zip.leading())
|
|
153
|
+
await out.put(c);
|
|
154
|
+
for (const k of plan.kept) {
|
|
155
|
+
context.meter().time();
|
|
156
|
+
const p = await prepare(zip, k, plan, context);
|
|
157
|
+
try {
|
|
158
|
+
await out.entry(p.info, p.chunks, k.name);
|
|
159
|
+
}
|
|
160
|
+
finally {
|
|
161
|
+
await p.spill?.dispose();
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
await out.end(plan.stripMetadata ? new Uint8Array(0) : zip.commentBytes);
|
|
165
|
+
if (plan.keepTrailing)
|
|
166
|
+
for await (const c of zip.trailing())
|
|
167
|
+
await out.put(c);
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* An extended timestamp record with its flags naming only the times it holds. The rewrite writes the central
|
|
171
|
+
* directory's record, which may hold the modification time alone, into the local header too, where the flags have to
|
|
172
|
+
* match the times that follow.
|
|
173
|
+
*/
|
|
174
|
+
function timestampFlags(data) {
|
|
175
|
+
let count = (data.length - 1) / 4;
|
|
176
|
+
let flags = 0;
|
|
177
|
+
for (let bit = 1; bit <= 4 && count > 0; bit <<= 1) {
|
|
178
|
+
if (data[0] & bit) {
|
|
179
|
+
flags |= bit;
|
|
180
|
+
count--;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
if (flags === data[0])
|
|
184
|
+
return data;
|
|
185
|
+
const out = Uint8Array.from(data);
|
|
186
|
+
out[0] = flags;
|
|
187
|
+
return out;
|
|
188
|
+
}
|
|
189
|
+
/** The headers and data of one kept entry: its own compressed bytes without their encryption, or its content compressed again. */
|
|
190
|
+
async function prepare(zip, k, plan, context) {
|
|
191
|
+
const e = k.entry;
|
|
192
|
+
const isDir = e.kind === 'directory';
|
|
193
|
+
const name = Buffer.from(isDir && !k.name.endsWith('/') ? `${k.name}/` : k.name, 'utf8');
|
|
194
|
+
const comment = plan.stripMetadata || !e.comment ? Buffer.alloc(0) : Buffer.from(e.comment, 'utf8');
|
|
195
|
+
const flags = /^[\x20-\x7e]*$/.test(k.name) && /^[\x20-\x7e]*$/.test(e.comment && !plan.stripMetadata ? e.comment : '') ? 0 : 0x0800;
|
|
196
|
+
const extras = Buffer.concat(e.extras
|
|
197
|
+
.filter(r => (exports.METADATA_EXTRAS.has(r.id) ? !plan.stripMetadata && (!r.malformed || plan.keepExtraFields) : plan.keepExtraFields))
|
|
198
|
+
.map(r => new Builder()
|
|
199
|
+
.u16(r.id)
|
|
200
|
+
.u16(r.data.length)
|
|
201
|
+
.bytes(r.id === 0x5455 && !r.malformed ? timestampFlags(r.data) : r.data)
|
|
202
|
+
.build()));
|
|
203
|
+
const unix = k.mode !== undefined;
|
|
204
|
+
const typeBits = TYPE_BITS[e.kind] ?? 0;
|
|
205
|
+
const info = {
|
|
206
|
+
name,
|
|
207
|
+
flags,
|
|
208
|
+
method: 0,
|
|
209
|
+
versionNeeded: 20,
|
|
210
|
+
versionMadeBy: unix ? (3 << 8) | 30 : 20,
|
|
211
|
+
externalAttr: unix ? (((typeBits | (k.mode ?? 0)) << 16) >>> 0) | (isDir ? 0x10 : 0) : (e.externalAttr & 0xff & ~0x10) | (isDir ? 0x10 : 0),
|
|
212
|
+
internalAttr: e.internalAttr,
|
|
213
|
+
time: plan.stripMetadata ? 0 : e.dosTime,
|
|
214
|
+
date: plan.stripMetadata ? DOS_DATE : e.dosDate,
|
|
215
|
+
crc: 0,
|
|
216
|
+
compressedSize: 0,
|
|
217
|
+
size: 0,
|
|
218
|
+
extras,
|
|
219
|
+
comment,
|
|
220
|
+
};
|
|
221
|
+
if (isDir)
|
|
222
|
+
return { info, chunks: model_1.nothing };
|
|
223
|
+
if (!k.replacement && !k.recompress) {
|
|
224
|
+
// The compressed bytes are copied, without any encryption they had.
|
|
225
|
+
info.method = e.methodCode;
|
|
226
|
+
info.versionNeeded = versionFor(e.methodCode);
|
|
227
|
+
info.crc = k.crc ?? e.crc;
|
|
228
|
+
info.size = e.size;
|
|
229
|
+
info.compressedSize = zip.plainLength(e);
|
|
230
|
+
return { info, chunks: () => zip.plain(e, k.password) };
|
|
231
|
+
}
|
|
232
|
+
// Compressed again: deflate, or stored when deflate gains nothing or would pass the run's ratio limit.
|
|
233
|
+
const size = (0, model_1.sizeOf)(k);
|
|
234
|
+
let crc = 0;
|
|
235
|
+
async function* withCrc(chunks) {
|
|
236
|
+
for await (const c of chunks) {
|
|
237
|
+
context.meter().time();
|
|
238
|
+
crc = (0, crc32_1.crc32)(c, crc);
|
|
239
|
+
yield c;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
const spill = new io_1.SpillSink(context.temp, context.threshold);
|
|
243
|
+
try {
|
|
244
|
+
for await (const c of (0, codecs_1.deflateRaw)(withCrc((0, model_1.contentOf)(zip, k, context))))
|
|
245
|
+
await spill.write(c);
|
|
246
|
+
await spill.close();
|
|
247
|
+
}
|
|
248
|
+
catch (err) {
|
|
249
|
+
await spill.dispose();
|
|
250
|
+
throw err;
|
|
251
|
+
}
|
|
252
|
+
info.crc = crc;
|
|
253
|
+
info.size = size;
|
|
254
|
+
const passesRatio = size <= 1024 * 1024 || size <= spill.length * plan.ratioLimit;
|
|
255
|
+
if (size > 0 && spill.length < size && passesRatio) {
|
|
256
|
+
info.method = 8;
|
|
257
|
+
info.compressedSize = spill.length;
|
|
258
|
+
return { info, chunks: () => spill.read(), spill };
|
|
259
|
+
}
|
|
260
|
+
await spill.dispose();
|
|
261
|
+
info.compressedSize = size;
|
|
262
|
+
return { info, chunks: () => (0, model_1.contentOf)(zip, k, context) };
|
|
263
|
+
}
|
package/dist/zip.d.ts
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import type { TempDir } from './io';
|
|
2
|
+
import type { Limits } from './stream-meter';
|
|
3
|
+
import { Reader } from './io';
|
|
4
|
+
import type { Archive, Entry, Meter, Note, WriteContext, WritePlan } from './model';
|
|
5
|
+
import { type ByteSink, type ByteSource } from './types';
|
|
6
|
+
export interface ZipLimits {
|
|
7
|
+
entries: number;
|
|
8
|
+
decompressedBytes: number;
|
|
9
|
+
totalDecompressedBytes: number;
|
|
10
|
+
compressionRatio: number;
|
|
11
|
+
}
|
|
12
|
+
/** One record of an extra field. */
|
|
13
|
+
export interface ExtraRecord {
|
|
14
|
+
id: number;
|
|
15
|
+
data: Uint8Array;
|
|
16
|
+
/** A times or owners record that does not have its documented layout. */
|
|
17
|
+
malformed?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export interface ZipEntry extends Entry {
|
|
20
|
+
rawName: Uint8Array;
|
|
21
|
+
flags: number;
|
|
22
|
+
/** The method field of the headers: 99 for AES. */
|
|
23
|
+
storedMethod: number;
|
|
24
|
+
/** The method the data is compressed with, inside any encryption. */
|
|
25
|
+
methodCode: number;
|
|
26
|
+
versionMadeBy: number;
|
|
27
|
+
externalAttr: number;
|
|
28
|
+
internalAttr: number;
|
|
29
|
+
dosTime: number;
|
|
30
|
+
dosDate: number;
|
|
31
|
+
crc: number;
|
|
32
|
+
localOffset: number;
|
|
33
|
+
dataOffset: number;
|
|
34
|
+
/** Where the entry ends, after any data descriptor. */
|
|
35
|
+
end: number;
|
|
36
|
+
/** Central directory extra records, apart from the ones the rewrite replaces. */
|
|
37
|
+
extras: ExtraRecord[];
|
|
38
|
+
/** The entry's comment as stored. */
|
|
39
|
+
commentBytes: Uint8Array;
|
|
40
|
+
/** WinZip AES: 1 for AE-1, which keeps the CRC, 2 for AE-2, which does not. */
|
|
41
|
+
aesVersion?: number;
|
|
42
|
+
aesStrength?: number;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* A ZIP archive read from its central directory, with every local header checked against it. Reading an entry
|
|
46
|
+
* decrypts and decodes it in chunks and checks its size and CRC.
|
|
47
|
+
*/
|
|
48
|
+
export declare class ZipArchive implements Archive<ZipEntry> {
|
|
49
|
+
readonly reader: Reader;
|
|
50
|
+
readonly entries: ZipEntry[];
|
|
51
|
+
readonly notes: Note[];
|
|
52
|
+
/** Where the archive starts in the file: the first local header, or the directory when there is none. */
|
|
53
|
+
readonly start: number;
|
|
54
|
+
/** Where the archive ends: after the end record's comment. */
|
|
55
|
+
readonly end: number;
|
|
56
|
+
readonly commentBytes: Uint8Array;
|
|
57
|
+
/** Where the other end records that lead to a directory sit, which an entry's data can hold. */
|
|
58
|
+
readonly rivals: number[];
|
|
59
|
+
readonly format = "zip";
|
|
60
|
+
readonly single = false;
|
|
61
|
+
readonly lateNotes: Note[];
|
|
62
|
+
comment?: string;
|
|
63
|
+
private constructor();
|
|
64
|
+
/** What LZMA and XZ entries need from the run: its limits, and a temporary folder for an XZ entry's bytes. */
|
|
65
|
+
decoders?: {
|
|
66
|
+
temp: TempDir;
|
|
67
|
+
threshold: number;
|
|
68
|
+
limits: Limits;
|
|
69
|
+
};
|
|
70
|
+
static open(source: ByteSource, limits: ZipLimits, deadline?: number): Promise<ZipArchive>;
|
|
71
|
+
/** One entry from its central directory header. */
|
|
72
|
+
private static central;
|
|
73
|
+
/** The encryption an entry uses, from its flags and its AES field, which also gives the method inside. */
|
|
74
|
+
private static encryption;
|
|
75
|
+
/** Checks a local header and any data descriptor against the central directory, and fills in where the entry's data and the entry end. */
|
|
76
|
+
private static checkLocal;
|
|
77
|
+
/** Bytes before the first entry, bytes between entries and the directory that belong to none, and entries that share bytes. */
|
|
78
|
+
private static coverage;
|
|
79
|
+
hasMetadata(): boolean;
|
|
80
|
+
/** Reads a symbolic link's target, which a ZIP stores as the entry's content. */
|
|
81
|
+
linkTarget(e: ZipEntry, meter: Meter): Promise<string | undefined>;
|
|
82
|
+
/** The stored bytes of an entry. */
|
|
83
|
+
raw(e: ZipEntry): AsyncGenerator<Uint8Array>;
|
|
84
|
+
/** The bytes before the archive and after it. */
|
|
85
|
+
leading(): AsyncGenerator<Uint8Array>;
|
|
86
|
+
trailing(): AsyncGenerator<Uint8Array>;
|
|
87
|
+
/** The 12-byte ZipCrypto header's check byte: the CRC's high byte, or the time's with a data descriptor. */
|
|
88
|
+
private checkByte;
|
|
89
|
+
unlock(e: ZipEntry, password: string): Promise<boolean>;
|
|
90
|
+
/** The entry's compressed bytes without their encryption, for a rewrite that copies them. Their length comes from `plainLength`. */
|
|
91
|
+
plain(e: ZipEntry, password?: string): AsyncGenerator<Uint8Array>;
|
|
92
|
+
/** The length of what plain() yields. */
|
|
93
|
+
plainLength(e: ZipEntry): number;
|
|
94
|
+
/** The entry's content in chunks. Its size, its CRC unless AE-2 leaves it out, and the compressed bytes used must all agree with the central directory. */
|
|
95
|
+
read(e: ZipEntry, meter: Meter, password?: string): AsyncGenerator<Uint8Array>;
|
|
96
|
+
write(plan: WritePlan<ZipEntry>, sink: ByteSink, context: WriteContext): Promise<void>;
|
|
97
|
+
}
|
|
98
|
+
/** True when the file ends in what may be a ZIP archive: an end record signature in the last 64 KiB. */
|
|
99
|
+
export declare function hasZipEnd(source: ByteSource): Promise<boolean>;
|