@zip.js/zip.js 2.8.52 → 2.8.54
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/README.md +1 -1
- package/deno.json +2 -1
- package/dist/zip-core-external.js +839 -528
- package/dist/zip-core-external.min.js +1 -1
- package/dist/zip-core.js +847 -527
- package/dist/zip-core.min.js +1 -1
- package/dist/zip-fs-core-external.js +880 -557
- package/dist/zip-fs-core-external.min.js +1 -1
- package/dist/zip-fs-core.js +829 -538
- package/dist/zip-fs-core.min.js +1 -1
- package/dist/zip-fs-external.js +880 -557
- package/dist/zip-fs-external.min.js +1 -1
- package/dist/zip-fs-native.js +895 -558
- package/dist/zip-fs-native.min.js +1 -1
- package/dist/zip-fs.js +894 -557
- package/dist/zip-fs.min.js +1 -1
- package/dist/zip-legacy.js +849 -529
- package/dist/zip-legacy.min.js +1 -1
- package/dist/zip-native.js +849 -529
- package/dist/zip-native.min.js +1 -1
- package/dist/zip-web-worker-native.js +1 -1
- package/dist/zip-web-worker.js +1 -1
- package/dist/zip.js +848 -528
- package/dist/zip.min.js +1 -1
- package/eslint.config.mjs +2 -1
- package/index-native.cjs +895 -558
- package/index-native.min.js +1 -1
- package/index.cjs +894 -557
- package/index.d.cts +672 -78
- package/index.d.ts +672 -78
- package/index.min.js +1 -1
- package/lib/core/codec-worker-web.js +13 -4
- package/lib/core/configuration.js +62 -21
- package/lib/core/constants.js +16 -1
- package/lib/core/io.js +44 -29
- package/lib/core/options.js +46 -2
- package/lib/core/streams/aes-crypto-stream.js +12 -12
- package/lib/core/util/decode-text.js +11 -2
- package/lib/core/web-worker-base.js +3 -2
- package/lib/core/web-worker-inline-native.js +1 -1
- package/lib/core/web-worker-inline-wasm.js +1 -1
- package/lib/core/zip-entry.js +8 -0
- package/lib/core/zip-fs.js +38 -27
- package/lib/core/zip-reader.js +149 -60
- package/lib/core/zip-writer.js +329 -189
- package/lib/zip-core-base.js +6 -1
- package/lib/zip-core-reader.js +1 -0
- package/lib/zip-core-writer.js +5 -0
- package/package.json +11 -3
package/dist/zip-fs.js
CHANGED
|
@@ -45,6 +45,7 @@
|
|
|
45
45
|
|
|
46
46
|
const LOCAL_FILE_HEADER_SIGNATURE = 0x04034b50;
|
|
47
47
|
const SPLIT_ZIP_FILE_SIGNATURE = 0x08074b50;
|
|
48
|
+
const TEMPORARY_SPLIT_ZIP_FILE_SIGNATURE = 0x30304b50;
|
|
48
49
|
const DATA_DESCRIPTOR_RECORD_SIGNATURE = SPLIT_ZIP_FILE_SIGNATURE;
|
|
49
50
|
const ARCHIVE_EXTRA_DATA_SIGNATURE = 0x08064b50;
|
|
50
51
|
const DIGITAL_SIGNATURE_RECORD_SIGNATURE = 0x05054b50;
|
|
@@ -61,6 +62,7 @@
|
|
|
61
62
|
const DATA_DESCRIPTOR_RECORD_LENGTH = 12;
|
|
62
63
|
const DATA_DESCRIPTOR_RECORD_ZIP_64_LENGTH = 20;
|
|
63
64
|
const DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH = 4;
|
|
65
|
+
const SPLIT_ZIP_FILE_SIGNATURE_LENGTH = 4;
|
|
64
66
|
|
|
65
67
|
const EXTRAFIELD_TYPE_ZIP64 = 0x0001;
|
|
66
68
|
const EXTRAFIELD_TYPE_AES = 0x9901;
|
|
@@ -102,6 +104,9 @@
|
|
|
102
104
|
const VERSION_ZIP64 = 0x2D;
|
|
103
105
|
const VERSION_AES = 0x33;
|
|
104
106
|
|
|
107
|
+
const VERSION_MADE_BY_MSDOS = 0x0014;
|
|
108
|
+
const VERSION_MADE_BY_UNIX = 0x0300;
|
|
109
|
+
|
|
105
110
|
const DIRECTORY_SIGNATURE = "/";
|
|
106
111
|
|
|
107
112
|
const HEADER_SIZE = 30;
|
|
@@ -109,6 +114,8 @@
|
|
|
109
114
|
const HEADER_OFFSET_SIGNATURE = 10;
|
|
110
115
|
const HEADER_OFFSET_COMPRESSED_SIZE = 14;
|
|
111
116
|
const HEADER_OFFSET_UNCOMPRESSED_SIZE = 18;
|
|
117
|
+
const HEADER_OFFSET_FILENAME_LENGTH = 22;
|
|
118
|
+
const HEADER_OFFSET_EXTRAFIELD_LENGTH = 24;
|
|
112
119
|
const LOCAL_HEADER_COMMON_OFFSET = 4;
|
|
113
120
|
|
|
114
121
|
const MAX_DATE = new Date(2107, 11, 31, 23, 59, 58);
|
|
@@ -121,9 +128,116 @@
|
|
|
121
128
|
const OBJECT_TYPE = "object";
|
|
122
129
|
const STRING_TYPE = "string";
|
|
123
130
|
const NUMBER_TYPE = "number";
|
|
131
|
+
const BOOLEAN_TYPE = "boolean";
|
|
124
132
|
|
|
125
133
|
const EMPTY_UINT8_ARRAY = new Uint8Array();
|
|
126
134
|
|
|
135
|
+
/*
|
|
136
|
+
Copyright (c) 2022 Gildas Lormeau. All rights reserved.
|
|
137
|
+
|
|
138
|
+
Redistribution and use in source and binary forms, with or without
|
|
139
|
+
modification, are permitted provided that the following conditions are met:
|
|
140
|
+
|
|
141
|
+
1. Redistributions of source code must retain the above copyright notice,
|
|
142
|
+
this list of conditions and the following disclaimer.
|
|
143
|
+
|
|
144
|
+
2. Redistributions in binary form must reproduce the above copyright
|
|
145
|
+
notice, this list of conditions and the following disclaimer in
|
|
146
|
+
the documentation and/or other materials provided with the distribution.
|
|
147
|
+
|
|
148
|
+
3. The names of the authors may not be used to endorse or promote products
|
|
149
|
+
derived from this software without specific prior written permission.
|
|
150
|
+
|
|
151
|
+
THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
|
152
|
+
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
153
|
+
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
|
|
154
|
+
INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
155
|
+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
156
|
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
|
157
|
+
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
158
|
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
159
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
|
160
|
+
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
161
|
+
*/
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
const OPTION_FILENAME_ENCODING = "filenameEncoding";
|
|
165
|
+
const OPTION_COMMENT_ENCODING = "commentEncoding";
|
|
166
|
+
const OPTION_DECODE_TEXT = "decodeText";
|
|
167
|
+
const OPTION_EXTRACT_PREPENDED_DATA = "extractPrependedData";
|
|
168
|
+
const OPTION_EXTRACT_APPENDED_DATA = "extractAppendedData";
|
|
169
|
+
const OPTION_PASSWORD = "password";
|
|
170
|
+
const OPTION_RAW_PASSWORD = "rawPassword";
|
|
171
|
+
const OPTION_PASS_THROUGH = "passThrough";
|
|
172
|
+
const OPTION_SIGNAL = "signal";
|
|
173
|
+
const OPTION_CHECK_PASSWORD_ONLY = "checkPasswordOnly";
|
|
174
|
+
const OPTION_CHECK_OVERLAPPING_ENTRY_ONLY = "checkOverlappingEntryOnly";
|
|
175
|
+
const OPTION_CHECK_OVERLAPPING_ENTRY = "checkOverlappingEntry";
|
|
176
|
+
const OPTION_CHECK_AMBIGUITY = "checkAmbiguity";
|
|
177
|
+
const OPTION_CHECK_LOCAL_DIRECTORY = "checkLocalDirectory";
|
|
178
|
+
const OPTION_CHECK_SIGNATURE = "checkSignature";
|
|
179
|
+
const OPTION_CHECK_CRC32 = "checkCrc32";
|
|
180
|
+
const OPTION_CHECK_AUTHENTICATION_CODE = "checkAuthenticationCode";
|
|
181
|
+
const OPTION_USE_WEB_WORKERS = "useWebWorkers";
|
|
182
|
+
const OPTION_USE_COMPRESSION_STREAM = "useCompressionStream";
|
|
183
|
+
const OPTION_TRANSFER_STREAMS = "transferStreams";
|
|
184
|
+
const OPTION_PREVENT_CLOSE = "preventClose";
|
|
185
|
+
const OPTION_ENCRYPTION_STRENGTH = "encryptionStrength";
|
|
186
|
+
const OPTION_EXTENDED_TIMESTAMP = "extendedTimestamp";
|
|
187
|
+
const OPTION_NTFS_TIMESTAMP = "ntfsTimestamp";
|
|
188
|
+
const OPTION_KEEP_ORDER = "keepOrder";
|
|
189
|
+
const OPTION_LEVEL = "level";
|
|
190
|
+
const OPTION_BUFFERED_WRITE = "bufferedWrite";
|
|
191
|
+
const OPTION_CREATE_TEMP_STREAM = "createTempStream";
|
|
192
|
+
const OPTION_DATA_DESCRIPTOR_SIGNATURE = "dataDescriptorSignature";
|
|
193
|
+
const OPTION_USE_UNICODE_FILE_NAMES = "useUnicodeFileNames";
|
|
194
|
+
const OPTION_DATA_DESCRIPTOR = "dataDescriptor";
|
|
195
|
+
const OPTION_SUPPORT_ZIP64_SPLIT_FILE = "supportZip64SplitFile";
|
|
196
|
+
const OPTION_ENCODE_TEXT = "encodeText";
|
|
197
|
+
const OPTION_OFFSET = "offset";
|
|
198
|
+
const OPTION_USDZ = "usdz";
|
|
199
|
+
const OPTION_UNIX_EXTRA_FIELD_TYPE = "unixExtraFieldType";
|
|
200
|
+
const OPTION_LOCAL_EXTRA_FIELD = "localExtraField";
|
|
201
|
+
const OPTION_STRICTNESS = "strictness";
|
|
202
|
+
const OPTION_FILENAME_VALIDATION = "filenameValidation";
|
|
203
|
+
const OPTION_NORMALIZE_FILENAME = "normalizeFilename";
|
|
204
|
+
const OPTION_MAX_APPENDED_DATA_SIZE = "maxAppendedDataSize";
|
|
205
|
+
const OPTION_DECRYPT_CENTRAL_DIRECTORY = "decryptCentralDirectory";
|
|
206
|
+
const OPTION_SIGN_CENTRAL_DIRECTORY = "signCentralDirectory";
|
|
207
|
+
const TEXT_TYPE_FILENAME = "filename";
|
|
208
|
+
const TEXT_TYPE_COMMENT = "comment";
|
|
209
|
+
const STRICTNESS_STRICT = "strict";
|
|
210
|
+
const STRICTNESS_BALANCED = "balanced";
|
|
211
|
+
const STRICTNESS_TOLERANT = "tolerant";
|
|
212
|
+
|
|
213
|
+
const ERR_INVALID_FUNCTION_OPTION = "Invalid option (must be a function)";
|
|
214
|
+
const ERR_INVALID_SIGNAL = "Invalid signal (must be an AbortSignal instance)";
|
|
215
|
+
const ERR_INVALID_PASSWORD_TYPE = "Invalid password (password must be a string, rawPassword must be a Uint8Array)";
|
|
216
|
+
|
|
217
|
+
function checkFunctionOption(value) {
|
|
218
|
+
if (value && typeof value != FUNCTION_TYPE) {
|
|
219
|
+
throw new Error(ERR_INVALID_FUNCTION_OPTION);
|
|
220
|
+
}
|
|
221
|
+
return value;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
function checkSignalOption(signal) {
|
|
225
|
+
if (signal && (typeof signal.addEventListener != FUNCTION_TYPE || typeof signal.aborted != BOOLEAN_TYPE)) {
|
|
226
|
+
throw new Error(ERR_INVALID_SIGNAL);
|
|
227
|
+
}
|
|
228
|
+
return signal || UNDEFINED_VALUE;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
function checkPasswordOption(password, rawPassword) {
|
|
232
|
+
if ((password && typeof password != STRING_TYPE) || (rawPassword && !(rawPassword instanceof Uint8Array))) {
|
|
233
|
+
throw new Error(ERR_INVALID_PASSWORD_TYPE);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
function toNumber(value) {
|
|
238
|
+
return typeof value == STRING_TYPE && value.trim() ? Number(value) : value;
|
|
239
|
+
}
|
|
240
|
+
|
|
127
241
|
/*
|
|
128
242
|
Copyright (c) 2025 Gildas Lormeau. All rights reserved.
|
|
129
243
|
|
|
@@ -153,7 +267,10 @@
|
|
|
153
267
|
*/
|
|
154
268
|
|
|
155
269
|
|
|
270
|
+
const DEFAULT_CHUNK_SIZE$1 = 64 * 1024;
|
|
156
271
|
const MINIMUM_CHUNK_SIZE = 64;
|
|
272
|
+
const MINIMUM_PROPERTY_VALUE = 1;
|
|
273
|
+
const ERR_INVALID_MAX_WORKERS = "Invalid maxWorkers (must be an integer greater than 0)";
|
|
157
274
|
let maxWorkers = 2;
|
|
158
275
|
try {
|
|
159
276
|
if (typeof navigator != UNDEFINED_TYPE && navigator.hardwareConcurrency) {
|
|
@@ -165,7 +282,7 @@
|
|
|
165
282
|
const DEFAULT_CONFIGURATION = {
|
|
166
283
|
workerURI: "./core/web-worker-wasm.js",
|
|
167
284
|
wasmURI: "./core/streams/zlib-wasm/zlib-streams.wasm",
|
|
168
|
-
chunkSize:
|
|
285
|
+
chunkSize: DEFAULT_CHUNK_SIZE$1,
|
|
169
286
|
maxWorkers,
|
|
170
287
|
terminateWorkerTimeout: 5000,
|
|
171
288
|
workerStarvationTimeout: 5000,
|
|
@@ -177,24 +294,38 @@
|
|
|
177
294
|
DecompressionStream: typeof DecompressionStream != UNDEFINED_TYPE && DecompressionStream
|
|
178
295
|
};
|
|
179
296
|
|
|
180
|
-
const
|
|
297
|
+
const PROPERTY_NAME_MAX_WORKERS = "maxWorkers";
|
|
298
|
+
|
|
299
|
+
const STRING_PROPERTY_NAMES = [
|
|
181
300
|
"baseURI",
|
|
182
301
|
"wasmURI",
|
|
183
|
-
"workerURI"
|
|
184
|
-
|
|
302
|
+
"workerURI"
|
|
303
|
+
];
|
|
304
|
+
const BOOLEAN_PROPERTY_NAMES = [
|
|
305
|
+
"useCompressionStream",
|
|
306
|
+
"useWebWorkers",
|
|
307
|
+
"transferStreams"
|
|
308
|
+
];
|
|
309
|
+
const NUMBER_PROPERTY_NAMES = [
|
|
185
310
|
"chunkSize",
|
|
186
|
-
|
|
311
|
+
PROPERTY_NAME_MAX_WORKERS,
|
|
187
312
|
"terminateWorkerTimeout",
|
|
188
313
|
"workerStarvationTimeout",
|
|
189
|
-
"workerStartupTimeout"
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
"
|
|
314
|
+
"workerStartupTimeout"
|
|
315
|
+
];
|
|
316
|
+
const FUNCTION_PROPERTY_NAMES = [
|
|
317
|
+
"createWorker",
|
|
193
318
|
"CompressionStream",
|
|
194
319
|
"DecompressionStream",
|
|
195
320
|
"CompressionStreamFallback",
|
|
196
321
|
"DecompressionStreamFallback"
|
|
197
322
|
];
|
|
323
|
+
const CONFIGURABLE_PROPERTY_NAMES = [
|
|
324
|
+
...STRING_PROPERTY_NAMES,
|
|
325
|
+
...BOOLEAN_PROPERTY_NAMES,
|
|
326
|
+
...NUMBER_PROPERTY_NAMES,
|
|
327
|
+
...FUNCTION_PROPERTY_NAMES
|
|
328
|
+
];
|
|
198
329
|
|
|
199
330
|
const config = { ...DEFAULT_CONFIGURATION };
|
|
200
331
|
|
|
@@ -203,20 +334,43 @@
|
|
|
203
334
|
}
|
|
204
335
|
|
|
205
336
|
function getChunkSize(config) {
|
|
206
|
-
return
|
|
337
|
+
return normalizeChunkSize(config.chunkSize);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
function normalizeChunkSize(chunkSize) {
|
|
341
|
+
chunkSize = toNumber(chunkSize);
|
|
342
|
+
return Number.isInteger(chunkSize) && chunkSize >= MINIMUM_PROPERTY_VALUE ? Math.max(chunkSize, MINIMUM_CHUNK_SIZE) : DEFAULT_CHUNK_SIZE$1;
|
|
207
343
|
}
|
|
208
344
|
|
|
209
345
|
function configure(configuration) {
|
|
210
|
-
|
|
346
|
+
Object.assign(config, checkConfiguration(normalizeConfiguration(configuration)));
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
function checkConfiguration(configuration) {
|
|
350
|
+
const checkedConfiguration = {};
|
|
211
351
|
for (const propertyName of CONFIGURABLE_PROPERTY_NAMES) {
|
|
212
352
|
const propertyValue = configuration[propertyName];
|
|
213
353
|
if (propertyValue !== UNDEFINED_VALUE) {
|
|
214
|
-
|
|
354
|
+
checkedConfiguration[propertyName] = checkPropertyValue(propertyName, propertyValue);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
return checkedConfiguration;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
function checkPropertyValue(propertyName, propertyValue) {
|
|
361
|
+
if (NUMBER_PROPERTY_NAMES.includes(propertyName)) {
|
|
362
|
+
propertyValue = toNumber(propertyValue);
|
|
363
|
+
if (propertyName == PROPERTY_NAME_MAX_WORKERS && (!Number.isInteger(propertyValue) || propertyValue < MINIMUM_PROPERTY_VALUE)) {
|
|
364
|
+
throw new Error(ERR_INVALID_MAX_WORKERS);
|
|
215
365
|
}
|
|
366
|
+
} else if (FUNCTION_PROPERTY_NAMES.includes(propertyName)) {
|
|
367
|
+
checkFunctionOption(propertyValue);
|
|
216
368
|
}
|
|
369
|
+
return propertyValue;
|
|
217
370
|
}
|
|
218
371
|
|
|
219
372
|
function normalizeConfiguration(configuration) {
|
|
373
|
+
configuration = configuration || {};
|
|
220
374
|
const { CompressionStreamZlib, DecompressionStreamZlib } = configuration;
|
|
221
375
|
if (CompressionStreamZlib === UNDEFINED_VALUE && DecompressionStreamZlib === UNDEFINED_VALUE) {
|
|
222
376
|
return configuration;
|
|
@@ -232,14 +386,9 @@
|
|
|
232
386
|
}
|
|
233
387
|
|
|
234
388
|
function setDefaultConfiguration(configuration) {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
if (propertyValue !== UNDEFINED_VALUE) {
|
|
239
|
-
DEFAULT_CONFIGURATION[propertyName] = propertyValue;
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
configure(configuration);
|
|
389
|
+
const checkedConfiguration = checkConfiguration(normalizeConfiguration(configuration));
|
|
390
|
+
Object.assign(DEFAULT_CONFIGURATION, checkedConfiguration);
|
|
391
|
+
Object.assign(config, checkedConfiguration);
|
|
243
392
|
}
|
|
244
393
|
|
|
245
394
|
function resetConfiguration() {
|
|
@@ -249,7 +398,7 @@
|
|
|
249
398
|
Object.assign(config, DEFAULT_CONFIGURATION);
|
|
250
399
|
}
|
|
251
400
|
|
|
252
|
-
const t$1=new Uint8Array(288);t$1.fill(8,0,144),t$1.fill(9,144,256),t$1.fill(7,256,280),t$1.fill(8,280,288),new Uint8Array(30).fill(5);const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n$1=t=>t({workerURI:t=>{const n="text/javascript";let s='(t=>{"function"==typeof define&&define.amd?define(t):t()})(function(){"use strict";const{Array:t,Object:e,Number:n,Math:s,Error:r,Uint8Array:o,Uint16Array:c,Uint32Array:i,Int32Array:a,Map:f,DataView:l,Promise:w,TextEncoder:u,crypto:h,postMessage:p,TransformStream:d,ReadableStream:y,WritableStream:m,CompressionStream:S,DecompressionStream:g}=self,v=void 0,b="undefined",k="function",z=new o,C=[[],[],[],[],[],[],[],[]];for(let t=0;256>t;t++){let e=t;for(let t=0;8>t;t++)e=1&e?e>>>1^3988292384:e>>>1;C[0][t]=e}for(let t=0;256>t;t++)for(let e=1;8>e;e++){const n=C[e-1][t];C[e][t]=n>>>8^C[0][255&n]}const[A,I,x,M,P,D,F,B]=C;class R{constructor(t){this.o=t||-1}append(t){let e=0|this.o;const n=0|t.length;let s=0;if(n>=8&&t.buffer){const r=new l(t.buffer,t.byteOffset,n),o=n-8;for(;o>=s;s+=8){const t=e^r.getInt32(s,!0),n=r.getInt32(s+4,!0);e=B[255&t]^F[t>>>8&255]^D[t>>>16&255]^P[t>>>24&255]^M[255&n]^x[n>>>8&255]^I[n>>>16&255]^A[n>>>24&255]}}for(;n>s;s++)e=e>>>8^A[255&(e^t[s])];this.o=e}get(){return~this.o}}class U extends d{constructor(){let t;const e=new R;super({transform(t,n){e.append(t),n.enqueue(t)},flush(){const n=new o(4);new l(n.buffer).setUint32(0,e.get()),t.value=n}}),t=this}}function W(t,e){const n=new o(t.length+e.length);return n.set(t),n.set(e,t.length),n}function _(t){return new l(t.buffer,t.byteOffset,t.byteLength)}const T={concat(t,e){if(0===t.length||0===e.length)return t.concat(e);const n=t[t.length-1],s=T.l(n);return 32===s?t.concat(e):T.h(e,s,0|n,t.slice(0,t.length-1))},bitLength(t){const e=t.length;if(0===e)return 0;const n=t[e-1];return 32*(e-1)+T.l(n)},m(t,e){if(32*t.length<e)return t;const n=(t=t.slice(0,s.ceil(e/32))).length;return e&=31,n>0&&e&&(t[n-1]=T.S(e,t[n-1]&2147483648>>e-1,1)),t},S:(t,e,n)=>32===t?e:(n?0|e:e<<32-t)+1099511627776*t,l:t=>s.round(t/1099511627776)||32,h(t,e,n,s){for(void 0===s&&(s=[]);e>=32;e-=32)s.push(n),n=0;if(0===e)return s.concat(t);for(let r=0;r<t.length;r++)s.push(n|t[r]>>>e),n=t[r]<<32-e;const r=t.length?t[t.length-1]:0,o=T.l(r);return s.push(T.S(e+o&31,e+o>32?n:s.pop(),1)),s}},V={bytes:{v(t){const e=T.bitLength(t)/8,n=new o(e);let s;for(let r=0;e>r;r++)3&r||(s=t[r/4]),n[r]=s>>>24,s<<=8;return n},C(t){const e=[];let n,s=0;for(n=0;n<t.length;n++)s=s<<8|t[n],3&~n||(e.push(s),s=0);return 3&n&&e.push(T.S(8*(3&n),s)),e}}},K=class{constructor(t){const e=this;e.blockSize=512,e.A=[1732584193,4023233417,2562383102,271733878,3285377520],e.I=[1518500249,1859775393,2400959708,3395469782],t?(e.M=t.M.slice(0),e.P=t.P.slice(0),e.D=t.D):e.reset()}reset(){const t=this;return t.M=t.A.slice(0),t.P=[],t.D=0,t}update(t){const e=this;"string"==typeof t&&(t=V.F.C(t));const n=e.P=T.concat(e.P,t),s=e.D,o=e.D=s+T.bitLength(t);if(o>9007199254740991)throw new r("Cannot hash more than 2^53 - 1 bits");const c=new i(n);let a=0;for(let t=e.blockSize+s-(e.blockSize+s&e.blockSize-1);o>=t;t+=e.blockSize)e.B(c.subarray(16*a,16*(a+1))),a+=1;return n.splice(0,16*a),e}R(){const t=this;let e=t.P;const n=t.M;e=T.concat(e,[T.S(1,1)]);for(let t=e.length+2;15&t;t++)e.push(0);for(e.push(s.floor(t.D/4294967296)),e.push(0|t.D);e.length;)t.B(e.splice(0,16));return t.reset(),n}U(t,e,n,s){return t>19?t>39?t>59?t>79?void 0:e^n^s:e&n|e&s|n&s:e^n^s:e&n|~e&s}W(t,e){return e<<t|e>>>32-t}B(e){const n=this,r=n.M,o=t(80);for(let t=0;16>t;t++)o[t]=e[t];let c=r[0],i=r[1],a=r[2],f=r[3],l=r[4];for(let t=0;79>=t;t++){16>t||(o[t]=n.W(1,o[t-3]^o[t-8]^o[t-14]^o[t-16]));const e=n.W(5,c)+n.U(t,i,a,f)+l+o[t]+n.I[s.floor(t/20)]|0;l=f,f=a,a=n.W(30,i),i=c,c=e}r[0]=r[0]+c|0,r[1]=r[1]+i|0,r[2]=r[2]+a|0,r[3]=r[3]+f|0,r[4]=r[4]+l|0}},E={importKey:t=>new E._(V.bytes.C(t)),T(t,e,n,s){if(n=n||1e4,0>s||0>n)throw new r("invalid params to pbkdf2");const o=1+(s>>5)<<2;let c,i,a,f,w;const u=new ArrayBuffer(o),h=new l(u);let p=0;const d=T;for(e=V.bytes.C(e),w=1;(o||1)>p;w++){for(c=i=t.encrypt(d.concat(e,[w])),a=1;n>a;a++)for(i=t.encrypt(i),f=0;f<i.length;f++)c[f]^=i[f];for(a=0;(o||1)>p&&a<c.length;a++)h.setInt32(p,c[a]),p+=4}return u.slice(0,s/8)},_:class{constructor(t){const e=this,n=e.V=K,s=[[],[]];e.K=[new n,new n];const r=e.K[0].blockSize/32;t.length>r&&(t=(new n).update(t).R());for(let e=0;r>e;e++)s[0][e]=909522486^t[e],s[1][e]=1549556828^t[e];e.K[0].update(s[0]),e.K[1].update(s[1]),e.L=new n(e.K[0])}reset(){const t=this;t.L=new t.V(t.K[0]),t.O=!1}update(t){this.O=!0,this.L.update(t)}digest(){const t=this,e=t.L.R(),n=new t.V(t.K[1]).update(e).R();return t.reset(),n}encrypt(t){if(this.O)throw new r("encrypt on already updated hmac called!");return this.update(t),this.digest(t)}}},L=typeof h!=b&&typeof h.getRandomValues==k,O="Invalid password",j="Invalid signature",H=j,N="zipjs-abort-check-password";function q(t){if(L)return h.getRandomValues(t);throw new r("Crypto API not supported")}const G=16,J={name:"PBKDF2"},Q=e.assign({hash:{name:"HMAC"}},J),X=e.assign({iterations:1e3,hash:{name:"SHA-1"}},J),Y=["deriveBits"],Z=[8,12,16],$=[16,24,32],tt=10,et=[0,0,0,0],nt=typeof h!=b,st=nt&&h.subtle,rt=nt&&typeof st!=b,ot=V.bytes,ct=class{constructor(t){const e=this;e.j=[[[],[],[],[],[]],[[],[],[],[],[]]],e.j[0][0][0]||e.H();const n=e.j[0][4],s=e.j[1],o=t.length;let c,i,a,f=1;if(4!==o&&6!==o&&8!==o)throw new r("invalid aes key size");for(e.I=[i=t.slice(0),a=[]],c=o;4*o+28>c;c++){let t=i[c-1];(c%o===0||8===o&&c%o===4)&&(t=n[t>>>24]<<24^n[t>>16&255]<<16^n[t>>8&255]<<8^n[255&t],c%o===0&&(t=t<<8^t>>>24^f<<24,f=f<<1^283*(f>>7))),i[c]=i[c-o]^t}for(let t=0;c;t++,c--){const e=i[3&t?c:c-4];a[t]=4>=c||4>t?e:s[0][n[e>>>24]]^s[1][n[e>>16&255]]^s[2][n[e>>8&255]]^s[3][n[255&e]]}}encrypt(t){return this.N(t,0)}decrypt(t){return this.N(t,1)}H(){const t=this.j[0],e=this.j[1],n=t[4],s=e[4],r=[],o=[];let c,i,a,f;for(let t=0;256>t;t++)o[(r[t]=t<<1^283*(t>>7))^t]=t;for(let l=c=0;!n[l];l^=i||1,c=o[c]||1){let o=c^c<<1^c<<2^c<<3^c<<4;o=o>>8^255&o^99,n[l]=o,s[o]=l,f=r[a=r[i=r[l]]];let w=16843009*f^65537*a^257*i^16843008*l,u=257*r[o]^16843008*o;for(let n=0;4>n;n++)t[n][l]=u=u<<24^u>>>8,e[n][o]=w=w<<24^w>>>8}for(let n=0;5>n;n++)t[n]=t[n].slice(0),e[n]=e[n].slice(0)}N(t,e){if(4!==t.length)throw new r("invalid aes block size");const n=this.I[e],s=n.length/4-2,o=[0,0,0,0],c=this.j[e],i=c[0],a=c[1],f=c[2],l=c[3],w=c[4];let u,h,p,d=t[0]^n[0],y=t[e?3:1]^n[1],m=t[2]^n[2],S=t[e?1:3]^n[3],g=4;for(let t=0;s>t;t++)u=i[d>>>24]^a[y>>16&255]^f[m>>8&255]^l[255&S]^n[g],h=i[y>>>24]^a[m>>16&255]^f[S>>8&255]^l[255&d]^n[g+1],p=i[m>>>24]^a[S>>16&255]^f[d>>8&255]^l[255&y]^n[g+2],S=i[S>>>24]^a[d>>16&255]^f[y>>8&255]^l[255&m]^n[g+3],g+=4,d=u,y=h,m=p;for(let t=0;4>t;t++)o[e?3&-t:t]=w[d>>>24]<<24^w[y>>16&255]<<16^w[m>>8&255]<<8^w[255&S]^n[g++],u=d,d=y,y=m,m=S,S=u;return o}},it=class{constructor(t,e){this.G=t,this.J=e,this.X=e}reset(){this.X=this.J}update(t){return this.Y(this.G,t,this.X)}Z(t){if(255&~(t>>24))t+=1<<24;else{let e=t>>16&255,n=t>>8&255,s=255&t;255===e?(e=0,255===n?(n=0,255===s?s=0:++s):++n):++e,t=0,t+=e<<16,t+=n<<8,t+=s}return t}$(t){0===(t[0]=this.Z(t[0]))&&(t[1]=this.Z(t[1]))}Y(t,e,n){let s;if(!(s=e.length))return[];const r=T.bitLength(e);for(let r=0;s>r;r+=4){this.$(n);const s=t.encrypt(n);e[r]^=s[0],e[r+1]^=s[1],e[r+2]^=s[2],e[r+3]^=s[3]}return T.m(e,r)}},at=E._;let ft=nt&&rt&&typeof st.importKey==k,lt=nt&&rt&&typeof st.deriveBits==k;class wt extends d{constructor({password:t,rawPassword:e,encryptionStrength:n,checkPasswordOnly:s,checkAuthenticationCode:c=!0}){super({start(){ht(this,t,e,n)},async transform(t,e){const n=this,{password:c,strength:i,et:a,ready:f}=n;c?(await(async(t,e,n,s)=>{const o=await dt(t,e,n,mt(s,0,Z[e])),c=mt(s,Z[e]);if(o[0]!=c[0]||o[1]!=c[1])throw new r(O)})(n,i,c,mt(t,0,Z[i]+2)),t=mt(t,Z[i]+2),s?e.error(new r(N)):a()):await f;const l=new o(t.length-tt-(t.length-tt)%G);e.enqueue(pt(n,t,l,0,tt,!0))},async flush(t){const{nt:e,st:n,pending:s,ready:o}=this;if(n&&e){await o;const i=mt(s,0,s.length-tt),a=mt(s,s.length-tt);let f=z;if(i.length){const t=gt(ot,i);n.update(t);const s=e.update(t);f=St(ot,s)}const l=mt(St(ot,n.digest()),0,tt);let w=s.length<tt?1:0;for(let t=0;tt>t;t++)w|=l[t]^a[t];if(w&&c)throw new r(H);t.enqueue(f)}}})}}class ut extends d{constructor({password:t,rawPassword:e,encryptionStrength:n}){super({start(){ht(this,t,e,n)},async transform(t,e){const n=this,{password:s,strength:r,et:c,ready:i}=n;let a=z;s?(a=await(async(t,e,n)=>{const s=q(new o(Z[e]));return W(s,await dt(t,e,n,s))})(n,r,s),c()):await i;const f=new o(a.length+t.length-t.length%G);f.set(a,0),e.enqueue(pt(n,t,f,a.length,0))},async flush(t){const{nt:e,st:n,pending:s,ready:r}=this;if(n&&e){await r;let o=z;if(s.length){const t=e.update(gt(ot,s));n.update(t),o=St(ot,t)}const c=St(ot,n.digest()).slice(0,tt);t.enqueue(W(o,c))}}})}}function ht(t,n,s,r){e.assign(t,{ready:new w(e=>t.et=e),password:yt(n,s),strength:r-1,pending:z})}function pt(t,e,n,s,r,c){const{nt:i,st:a,pending:f}=t;f.length&&(e=W(f,e));const l=e.length-r;let w;for(n=((t,e)=>{if(e&&e>t.length){const n=t;(t=new o(e)).set(n,0)}return t})(n,s+(l-l%G)),w=0;l-G>=w;w+=G){const t=gt(ot,mt(e,w,w+G));c&&a.update(t);const r=i.update(t);c||a.update(r),n.set(St(ot,r),w+s)}return t.pending=mt(e,w),n}async function dt(n,s,r,c){n.password=null;const i=await(async(t,e,n,s,r)=>{if(!ft)return E.importKey(e);try{return await st.importKey("raw",e,n,!1,r)}catch{return ft=!1,E.importKey(e)}})(0,r,Q,0,Y),a=await(async(t,e,n)=>{if(!lt)return E.T(e,t.salt,X.iterations,n);try{return await st.deriveBits(t,e,n)}catch{return lt=!1,E.T(e,t.salt,X.iterations,n)}})(e.assign({salt:c},X),i,8*(2*$[s]+2)),f=new o(a),l=gt(ot,mt(f,0,$[s])),w=gt(ot,mt(f,$[s],2*$[s])),u=mt(f,2*$[s]);return e.assign(n,{keys:{key:l,ot:w,passwordVerification:u},nt:new it(new ct(l),t.from(et)),st:new at(w)}),u}function yt(t,e){return e===v?(t=>{if(typeof u==b){const e=new o((t=unescape(encodeURIComponent(t))).length);for(let n=0;n<e.length;n++)e[n]=t.charCodeAt(n);return e}return(new u).encode(t)})(t):e}function mt(t,e,n){return t.subarray(e,n)}function St(t,e){return t.v(e)}function gt(t,e){return t.C(e)}class vt extends d{constructor({password:t,rawPassword:e,passwordVerification:n,checkPasswordOnly:s}){super({start(){kt(this,t,e,n)},transform(t,e){const n=this;if(n.password||n.rawPassword){const e=zt(n,t.subarray(0,12));if(n.password=n.rawPassword=null,0!=(e[11]^n.passwordVerification))throw new r(O);t=t.subarray(12)}s?e.error(new r(N)):e.enqueue(zt(n,t))}})}}class bt extends d{constructor({password:t,rawPassword:e,passwordVerification:n}){super({start(){kt(this,t,e,n)},transform(t,e){const n=this;let s,r;if(n.password||n.rawPassword){n.password=n.rawPassword=null;const e=q(new o(12));e[11]=n.passwordVerification,s=new o(t.length+e.length),s.set(Ct(n,e),0),r=12}else s=new o(t.length),r=0;s.set(Ct(n,t),r),e.enqueue(s)}})}}function kt(t,n,s,r){e.assign(t,{password:n,rawPassword:s,passwordVerification:r}),((t,n,s)=>{const r=[305419896,591751049,878082192];if(e.assign(t,{keys:r,ct:new R(r[0]),it:new R(r[2])}),s)for(let e=0;e<s.length;e++)At(t,s[e]);else for(let e=0;e<n.length;e++)At(t,n.charCodeAt(e))})(t,n,s)}function zt(t,e){const n=new o(e.length);for(let s=0;s<e.length;s++)n[s]=It(t)^e[s],At(t,n[s]);return n}function Ct(t,e){const n=new o(e.length);for(let s=0;s<e.length;s++)n[s]=It(t)^e[s],At(t,e[s]);return n}function At(t,e){let[,n]=t.keys;t.ct.append([e]);const r=~t.ct.get();n=Mt(s.imul(Mt(n+xt(r)),134775813)+1),t.it.append([n>>>24]);const o=~t.it.get();t.keys=[r,n,o]}function It(t){const e=2|t.keys[2];return xt(s.imul(e,1^e)>>>8)}function xt(t){return 255&t}function Mt(t){return 4294967295&t}const Pt=new f;function Dt(t){return Pt.get(t)}const Ft="Invalid uncompressed size",Bt=j,Rt="deflate-raw",Ut="gzip",Wt=[31,139,8];class _t extends d{constructor(t,{chunkSize:e,CompressionStreamFallback:n,CompressionStream:s}){super({});const{compressed:r,encrypted:o,useCompressionStream:c,zipCrypto:i,computeCrc32:a,level:f,deflate64:w,format:u,compressionMethod:h}=t,p=this;let d,y,m,S=super.readable;const g=u&&Dt(u),v=a&&r&&!w&&!g&&(!o||i)&&!(!c||!s);if(o&&!i||!a||v||(d=new U,S=jt(S,d)),r)if(g)S=Ht(S,Lt(g.CompressionStream,u,{level:f,chunkSize:e,compressionMethod:h}));else if(v)m=new Tt,S=Ht(S,new s(Ut)),S=jt(S,m);else try{S=Ot(S,c,{level:f,chunkSize:e},s,n)}catch(t){let e;try{e=new s(Ut)}catch{throw t}S=Ht(S,e),S=jt(S,new Tt)}o&&(i?S=jt(S,new bt(t)):(y=new ut(t),S=jt(S,y))),Et(p,S,()=>{o&&!i||!a||(p.crc32=v?m.crc32:new l(d.value.buffer).getUint32(0))})}}class Tt extends d{constructor(){let t,e=10,n=new o(0);super({transform(t,r){if(e){const n=s.min(e,t.length);if(e-=n,!(t=t.subarray(n)).length)return}const o=n.length+t.length;if(8>=o)return void(n=W(n,t));const c=o-8,i=s.min(c,n.length);r.enqueue(W(n.subarray(0,i),t.subarray(0,c-i))),n=W(n.subarray(i),t.subarray(c-i))},flush(){const e=_(n);t.crc32=e.getUint32(0,!0),t.uncompressedSize=e.getUint32(4,!0)}}),t=this}}class Vt extends d{constructor(t,{chunkSize:e,DecompressionStreamFallback:n,DecompressionStream:s}){super({});const{zipCrypto:c,encrypted:i,checkCrc32:a,crc32:f,compressed:u,useCompressionStream:h,deflate64:p,format:m,compressionMethod:S,rawBitFlag:g,outputSize:b}=t;let k,z,C=super.readable;if(i&&(c?C=jt(C,new vt(t)):(z=new wt(t),C=jt(C,z))),u){const t=m&&Dt(m);if(t)C=Ht(C,Lt(t.DecompressionStream,m,{chunkSize:e,compressionMethod:S,rawBitFlag:g,uncompressedSize:b}));else try{C=Ot(C,h,{chunkSize:e,deflate64:p},s,n)}catch(t){if(p||b===v)throw t;let e;try{e=new s(Ut)}catch{throw t}C=((t,e,n)=>{const s=new R;let c,i,a,f=0,l=!1;const u=new w((t,e)=>{i=t,a=e});u.catch(()=>{}),n||i();const h=new d({start(t){const e=new o(10);e.set(Wt),t.enqueue(e)},transform(t,e){e.enqueue(t)},async flush(t){l=!0,y();try{await u}finally{m()}const e=new o(8),r=_(e);r.setUint32(0,s.get(),!0),r.setUint32(4,n,!0),t.enqueue(e)},cancel(t){a(t)}}),p=new d({transform(t,e){s.append(t),f+=t.length,n>f?l&&y():i(),e.enqueue(t)},cancel(t){a(t)}});return t=jt(t,h),jt(t=Ht(t,e),p);function y(){m(),c=setTimeout(()=>a(new r(Ft)),5e3)}function m(){clearTimeout(c)}})(C,e,b)}C=(t=>{const e=t.getReader();return new y({async pull(t){let n;try{n=await e.read()}catch(t){if(t&&t.message)throw t;const e=new r("Invalid compressed data");throw e.cause=t,e}const{value:s,done:o}=n;o?t.close():t.enqueue(s)},cancel:t=>e.cancel(t)})})(C)}a&&(k=new U,C=jt(C,k)),Et(this,C,()=>{if(a){const t=new l(k.value.buffer);if(f!=t.getUint32(0,!1))throw new r(Bt)}})}}const Kt=new f;function Et(t,n,s){n=jt(n,new d({flush:s})),e.defineProperty(t,"readable",{get:()=>n})}function Lt(t,e,n){if(!t)throw new r("Compression method not supported");return new t(e,n)}function Ot(t,e,n,s,r){const o=e&&s?s:r||s,c=n.deflate64?"deflate64-raw":Rt;let i;try{i=new o(c,n)}catch(t){if(!e||!r||o==r)throw t;i=new r(c,n)}return Ht(t,i)}function jt(t,e){return(t=>{if(t instanceof y)return t;const e=t.getReader();return new y({async pull(t){const{value:n,done:s}=await e.read();s?t.close():t.enqueue(n)},cancel:t=>e.cancel(t)})})(t).pipeThrough(e)}function Ht(t,e){const n=e.writable.getWriter(),s=t.getReader();return(async()=>{try{for(;;){await n.ready;const t=await s.read();if(t.done){await n.close();break}await n.write(t.value)}}catch(t){await(async(t,e)=>{try{await t.abort(e)}catch{}})(n,t),await(async(t,e)=>{try{await t.cancel(e)}catch{}})(s,t)}})(),e.readable}const Nt="data",qt="close",Gt="deflate";class Jt extends d{constructor(t,n){super({});const s=this,{codecType:o}=t;let c;o.startsWith(Gt)?c=_t:o.startsWith("inflate")&&(c=Vt),s.outputSize=0;let i=0;const a=new c(t,n),f=super.readable,l=new d({transform(t,e){t&&t.length&&(i+=t.length,e.enqueue(t))},flush(){e.assign(s,{inputSize:i})}}),w=new d({transform(e,n){if(e&&e.length&&(n.enqueue(e),s.outputSize+=e.length,t.outputSize!==v&&s.outputSize>t.outputSize))throw new r(Ft)},flush(){const{crc32:t}=a;e.assign(s,{crc32:t,inputSize:i})}});e.defineProperty(s,"readable",{get:()=>f.pipeThrough(l).pipeThrough(a).pipeThrough(w)})}}class Qt extends d{constructor(t){const e=[];let s=0;function r(){const n=new o(t);let r=0;for(;t>r;){const s=e[0],o=t-r;s.length>o?(n.set(s.subarray(0,o),r),e[0]=s.subarray(o),r+=o):(n.set(s,r),r+=s.length,e.shift())}return s-=t,n}n.isFinite(t)&&t>=1||(t=65536),super({transform(n,o){for(e.push(n),s+=n.length;s>t;)o.enqueue(r())},flush(t){s&&t.enqueue(((t,e)=>{const n=new o(e);let s=0;for(const e of t)n.set(e,s),s+=e.length;return n})(e,s))}})}}let Xt=2;try{typeof navigator!=b&&navigator.hardwareConcurrency&&(Xt=navigator.hardwareConcurrency)}catch{}const Yt=new f,Zt=new f;let $t,te,ee,ne,se,re,oe=0;async function ce(t){let e,o;try{const{options:c,config:i}=t;if(c.format)try{await(async(t,e)=>{!Pt.has(t)&&e&&((t,e)=>{const{CompressionStream:n,DecompressionStream:s}=e;if(typeof n!=k&&typeof s!=k)throw new r("Invalid codec module");Pt.set(t,{CompressionStream:n,DecompressionStream:s})})(t,await(import(e)))})(c.format,c.codecURI)}catch(t){throw t.codecImportFailed=!0,t}if(i.CompressionStream=self.CompressionStream,i.DecompressionStream=self.DecompressionStream,c.compressed&&!c.format)if(c.useCompressionStream){if(!((t,e)=>{if(!t)return!1;let n=Kt.get(t);n||(n=new f,Kt.set(t,n));let s=n.get(e);if(s===v){try{new t(e),s=!0}catch{s=!1}n.set(e,s)}return s})(c.codecType.startsWith(Gt)?i.CompressionStream:i.DecompressionStream,Rt))try{await self.initModule(t.config)}catch{}}else try{await self.initModule(t.config)}catch{c.useCompressionStream=!0}!i.CompressionStreamFallback&&i.CompressionStreamZlib&&(i.CompressionStreamFallback=i.CompressionStreamZlib),!i.DecompressionStreamFallback&&i.DecompressionStreamZlib&&(i.DecompressionStreamFallback=i.DecompressionStreamZlib);const a={highWaterMark:1},l=t.readable||new y({async pull(t){const e=new w(t=>Yt.set(oe,t));ie({type:"pull",messageId:oe}),oe=(oe+1)%n.MAX_SAFE_INTEGER;const{value:s,done:r}=await e;t.enqueue(s),r&&t.close()}},a);o=t.writable||new m({async write(t){let e;const s=new w(t=>e=t);Zt.set(oe,e),ie({type:Nt,value:t,messageId:oe}),oe=(oe+1)%n.MAX_SAFE_INTEGER,await s}},a),e=new Jt(c,i),$t=new AbortController;const{signal:u}=$t;await l.pipeThrough(e).pipeThrough(new Qt((t=>s.max(t.chunkSize,64))(i))).pipeTo(o,{signal:u,preventClose:!0,preventAbort:!0}),await o.getWriter().close();const{crc32:h,inputSize:p,outputSize:d}=e;ie({type:qt,result:{crc32:h,inputSize:p,outputSize:d}})}catch(t){if(t.outputSize=e?e.outputSize:0,o&&!o.locked)try{await o.getWriter().close()}catch{}ae(t)}}function ie(t){const{value:e}=t;if(e)if(e.length)try{t.value=(n=e,n.byteOffset||n.byteLength!=n.buffer.byteLength?new o(n):n).buffer,p(t,[t.value])}catch{p(t)}else p(t);else p(t);var n}function ae(t=new r("Unknown error")){const{message:e,stack:n,code:s,name:o,outputSize:c,cause:i,codecImportFailed:a}=t,f={message:e,stack:n,code:s,name:o,outputSize:c};i&&(f.cause={name:i.name,message:i.message}),a&&(f.codecImportFailed=!0),p({error:f})}function fe(t,e,n={}){if(!te){const t=new r("WASM module not loaded");throw t.cause=re,t}const c="number"==typeof n.level?n.level:-1,i="number"==typeof n.outBuffer?n.outBuffer:65536,a="number"==typeof n.inBufferSize?n.inBufferSize:65536;return new d({start(){try{let n;if(this.ft=ee(i),this.in=ee(a),this.inBufferSize=a,!this.ft||!this.in)throw new r("allocation failed");if(this.lt=new o(i),t?(this.wt=te.deflate_process,this.ut=te.deflate_last_consumed,this.ht=te.deflate_end,this.yt=te.deflate_new(),n="gzip"===e?te.deflate_init_gzip(this.yt,c):"deflate-raw"===e?te.deflate_init_raw(this.yt,c):te.deflate_init(this.yt,c)):"deflate64-raw"===e?(this.wt=te.inflate9_process,this.ut=te.inflate9_last_consumed,this.ht=te.inflate9_end,this.yt=te.inflate9_new(),n=te.inflate9_init_raw(this.yt)):(this.wt=te.inflate_process,this.ut=te.inflate_last_consumed,this.ht=te.inflate_end,this.yt=te.inflate_new(),n="deflate-raw"===e?te.inflate_init_raw(this.yt):"gzip"===e?te.inflate_init_gzip(this.yt):te.inflate_init(this.yt)),0!==n)throw new r("init failed:"+n)}catch(t){throw f(this),t}},transform(e,n){try{const c=e,a=new o(se.buffer),f=this.wt,l=this.ut,w=this.ft,u=this.lt;let h=0;for(;h<c.length;){const e=s.min(c.length-h,32768);if((!this.in||this.inBufferSize<e)&&(this.in&&ne&&(ne(this.in),this.in=0),this.in=ee(e),this.inBufferSize=e,!this.in))throw new r("allocation failed");a.set(c.subarray(h,h+e),this.in);const o=f(this.yt,this.in,e,w,i,0),p=16777215&o;if(p&&(u.set(a.subarray(w,w+p),0),n.enqueue(u.slice(0,p))),!t){const t=o>>24&255,e=128&t?t-256:t;if(0>e)throw new r("process error:"+e)}const d=l(this.yt);if(0===d)break;h+=d}}catch(t){f(this),n.error(t)}},flush(e){try{const n=new o(se.buffer),s=this.wt,c=this.ft,a=this.lt;for(;;){const o=s(this.yt,0,0,c,i,4),f=16777215&o,l=o>>24&255;if(!t){const t=128&l?l-256:l;if(0>t)throw new r("process error:"+t)}if(f&&(a.set(n.subarray(c,c+f),0),e.enqueue(a.slice(0,f))),1===l||0===f)break}}catch(t){e.error(t)}finally{const t=f(this);0!==t&&e.error(new r("end error:"+t))}},cancel(){f(this)}});function f(t){let e=0;return t.yt&&t.ht&&(e=t.ht(t.yt)),t.yt=0,t.in&&ne&&ne(t.in),t.in=0,t.ft&&ne&&ne(t.ft),t.ft=0,e}}addEventListener("message",({data:t})=>{const{type:e,messageId:n,value:s,done:r}=t;try{if("start"==e&&ce(t),e==Nt){const t=Yt.get(n);Yt.delete(n),t({value:s||new o,done:r})}if("ack"==e){const t=Zt.get(n);Zt.delete(n),t()}e==qt&&$t.abort()}catch(t){ae(t)}}),p({type:"ready"});class le{constructor(t="deflate",e){return fe(!0,t,e)}}class we{constructor(t="deflate",e){return fe(!1,t,e)}}le.St=!0,we.St=!0;let ue=!1;((t={})=>{const{init:e}=t,n=t.CompressionStreamFallback||t.CompressionStreamZlib,s=t.DecompressionStreamFallback||t.DecompressionStreamZlib;self.initModule=async t=>{e&&await e(t),n&&(t.CompressionStreamFallback=n),s&&(t.DecompressionStreamFallback=s)}})({CompressionStreamFallback:le,DecompressionStreamFallback:we,init:t=>(async(t,{baseURI:e})=>{if(!ue)try{await(async(t,e)=>{let n,s;try{try{s=new URL(t,e)}catch{}const r=await fetch(s);n=await r.arrayBuffer()}catch(e){if(!t.startsWith("data:application/wasm;base64,"))throw e;n=(t=>{const e=t.split(",")[1],n=atob(e),s=n.length,r=new o(s);for(let t=0;s>t;++t)r[t]=n.charCodeAt(t);return r.buffer})(t)}(t=>{if(te=t,({malloc:ee,free:ne,memory:se}=te),"function"!=typeof ee||"function"!=typeof ne||!se)throw te=ee=ne=se=null,new r("Invalid WASM module")})((await WebAssembly.instantiate(n)).instance.exports)})(t,e),ue=!0}catch(t){throw(t=>{re=t})(t),t}})(t.wasmURI,t)})});\n';if("string"==typeof s&&(s=(new TextEncoder).encode(s)),t){const t=new Blob([s],{type:n});return URL.createObjectURL(t)}return "data:"+n+";base64,"+(t=>{let n="";const s=t.length;let r=0;for(;s>r+2;r+=3){const s=t[r]<<16|t[r+1]<<8|t[r+2];n+=e[s>>18&63]+e[s>>12&63]+e[s>>6&63]+e[63&s];}const o=s-r;if(1===o){const s=t[r]<<16;n+=e[s>>18&63]+e[s>>12&63]+"==";}else if(2===o){const s=t[r]<<16|t[r+1]<<8;n+=e[s>>18&63]+e[s>>12&63]+e[s>>6&63]+"=";}return n})(s)}});
|
|
401
|
+
const t$1=new Uint8Array(288);t$1.fill(8,0,144),t$1.fill(9,144,256),t$1.fill(7,256,280),t$1.fill(8,280,288),new Uint8Array(30).fill(5);const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n$1=t=>t({workerURI:t=>{const n="text/javascript";let s='(t=>{"function"==typeof define&&define.amd?define(t):t()})(function(){"use strict";const{Array:t,Object:e,Number:n,Math:s,Error:r,Uint8Array:o,Uint16Array:c,Uint32Array:i,Int32Array:a,Map:f,DataView:l,Promise:u,TextEncoder:w,crypto:h,postMessage:p,TransformStream:d,ReadableStream:y,WritableStream:m,CompressionStream:S,DecompressionStream:g}=self,v=void 0,b="undefined",k="function",z=new o,C=[[],[],[],[],[],[],[],[]];for(let t=0;256>t;t++){let e=t;for(let t=0;8>t;t++)e=1&e?e>>>1^3988292384:e>>>1;C[0][t]=e}for(let t=0;256>t;t++)for(let e=1;8>e;e++){const n=C[e-1][t];C[e][t]=n>>>8^C[0][255&n]}const[I,A,x,M,P,D,F,B]=C;class R{constructor(t){this.o=t||-1}append(t){let e=0|this.o;const n=0|t.length;let s=0;if(n>=8&&t.buffer){const r=new l(t.buffer,t.byteOffset,n),o=n-8;for(;o>=s;s+=8){const t=e^r.getInt32(s,!0),n=r.getInt32(s+4,!0);e=B[255&t]^F[t>>>8&255]^D[t>>>16&255]^P[t>>>24&255]^M[255&n]^x[n>>>8&255]^A[n>>>16&255]^I[n>>>24&255]}}for(;n>s;s++)e=e>>>8^I[255&(e^t[s])];this.o=e}get(){return~this.o}}class U extends d{constructor(){let t;const e=new R;super({transform(t,n){e.append(t),n.enqueue(t)},flush(){const n=new o(4);new l(n.buffer).setUint32(0,e.get()),t.value=n}}),t=this}}function W(t,e){const n=new o(t.length+e.length);return n.set(t),n.set(e,t.length),n}function _(t){return new l(t.buffer,t.byteOffset,t.byteLength)}const T={concat(t,e){if(0===t.length||0===e.length)return t.concat(e);const n=t[t.length-1],s=T.l(n);return 32===s?t.concat(e):T.h(e,s,0|n,t.slice(0,t.length-1))},bitLength(t){const e=t.length;if(0===e)return 0;const n=t[e-1];return 32*(e-1)+T.l(n)},m(t,e){if(32*t.length<e)return t;const n=(t=t.slice(0,s.ceil(e/32))).length;return e&=31,n>0&&e&&(t[n-1]=T.S(e,t[n-1]&2147483648>>e-1,1)),t},S:(t,e,n)=>32===t?e:(n?0|e:e<<32-t)+1099511627776*t,l:t=>s.round(t/1099511627776)||32,h(t,e,n,s){for(void 0===s&&(s=[]);e>=32;e-=32)s.push(n),n=0;if(0===e)return s.concat(t);for(let r=0;r<t.length;r++)s.push(n|t[r]>>>e),n=t[r]<<32-e;const r=t.length?t[t.length-1]:0,o=T.l(r);return s.push(T.S(e+o&31,e+o>32?n:s.pop(),1)),s}},V={bytes:{v(t){const e=T.bitLength(t)/8,n=new o(e);let s;for(let r=0;e>r;r++)3&r||(s=t[r/4]),n[r]=s>>>24,s<<=8;return n},C(t){const e=[];let n,s=0;for(n=0;n<t.length;n++)s=s<<8|t[n],3&~n||(e.push(s),s=0);return 3&n&&e.push(T.S(8*(3&n),s)),e}}},K=class{constructor(t){const e=this;e.blockSize=512,e.I=[1732584193,4023233417,2562383102,271733878,3285377520],e.A=[1518500249,1859775393,2400959708,3395469782],t?(e.M=t.M.slice(0),e.P=t.P.slice(0),e.D=t.D):e.reset()}reset(){const t=this;return t.M=t.I.slice(0),t.P=[],t.D=0,t}update(t){const e=this;"string"==typeof t&&(t=V.F.C(t));const n=e.P=T.concat(e.P,t),s=e.D,o=e.D=s+T.bitLength(t);if(o>9007199254740991)throw new r("Cannot hash more than 2^53 - 1 bits");const c=new i(n);let a=0;for(let t=e.blockSize+s-(e.blockSize+s&e.blockSize-1);o>=t;t+=e.blockSize)e.B(c.subarray(16*a,16*(a+1))),a+=1;return n.splice(0,16*a),e}R(){const t=this;let e=t.P;const n=t.M;e=T.concat(e,[T.S(1,1)]);for(let t=e.length+2;15&t;t++)e.push(0);for(e.push(s.floor(t.D/4294967296)),e.push(0|t.D);e.length;)t.B(e.splice(0,16));return t.reset(),n}U(t,e,n,s){return t>19?t>39?t>59?t>79?void 0:e^n^s:e&n|e&s|n&s:e^n^s:e&n|~e&s}W(t,e){return e<<t|e>>>32-t}B(e){const n=this,r=n.M,o=t(80);for(let t=0;16>t;t++)o[t]=e[t];let c=r[0],i=r[1],a=r[2],f=r[3],l=r[4];for(let t=0;79>=t;t++){16>t||(o[t]=n.W(1,o[t-3]^o[t-8]^o[t-14]^o[t-16]));const e=n.W(5,c)+n.U(t,i,a,f)+l+o[t]+n.A[s.floor(t/20)]|0;l=f,f=a,a=n.W(30,i),i=c,c=e}r[0]=r[0]+c|0,r[1]=r[1]+i|0,r[2]=r[2]+a|0,r[3]=r[3]+f|0,r[4]=r[4]+l|0}},E={importKey:t=>new E._(V.bytes.C(t)),T(t,e,n,s){if(n=n||1e4,0>s||0>n)throw new r("invalid params to pbkdf2");const o=1+(s>>5)<<2;let c,i,a,f,u;const w=new ArrayBuffer(o),h=new l(w);let p=0;const d=T;for(e=V.bytes.C(e),u=1;(o||1)>p;u++){for(c=i=t.encrypt(d.concat(e,[u])),a=1;n>a;a++)for(i=t.encrypt(i),f=0;f<i.length;f++)c[f]^=i[f];for(a=0;(o||1)>p&&a<c.length;a++)h.setInt32(p,c[a]),p+=4}return w.slice(0,s/8)},_:class{constructor(t){const e=this,n=e.V=K,s=[[],[]];e.K=[new n,new n];const r=e.K[0].blockSize/32;t.length>r&&(t=(new n).update(t).R());for(let e=0;r>e;e++)s[0][e]=909522486^t[e],s[1][e]=1549556828^t[e];e.K[0].update(s[0]),e.K[1].update(s[1]),e.L=new n(e.K[0])}reset(){const t=this;t.L=new t.V(t.K[0]),t.O=!1}update(t){this.O=!0,this.L.update(t)}digest(){const t=this,e=t.L.R(),n=new t.V(t.K[1]).update(e).R();return t.reset(),n}encrypt(t){if(this.O)throw new r("encrypt on already updated hmac called!");return this.update(t),this.digest(t)}}},L=typeof h!=b&&typeof h.getRandomValues==k,O="Invalid password",j="Invalid signature",H=j,N="zipjs-abort-check-password";function q(t){if(L)return h.getRandomValues(t);throw new r("Crypto API not supported")}const G=16,J={name:"PBKDF2"},Q=e.assign({hash:{name:"HMAC"}},J),X=e.assign({iterations:1e3,hash:{name:"SHA-1"}},J),Y=["deriveBits"],Z=[8,12,16],$=[16,24,32],tt=10,et=[0,0,0,0],nt=typeof h!=b,st=nt&&h.subtle,rt=nt&&typeof st!=b,ot=V.bytes,ct=class{constructor(t){const e=this;e.j=[[[],[],[],[],[]],[[],[],[],[],[]]],e.j[0][0][0]||e.H();const n=e.j[0][4],s=e.j[1],o=t.length;let c,i,a,f=1;if(4!==o&&6!==o&&8!==o)throw new r("invalid aes key size");for(e.A=[i=t.slice(0),a=[]],c=o;4*o+28>c;c++){let t=i[c-1];(c%o===0||8===o&&c%o===4)&&(t=n[t>>>24]<<24^n[t>>16&255]<<16^n[t>>8&255]<<8^n[255&t],c%o===0&&(t=t<<8^t>>>24^f<<24,f=f<<1^283*(f>>7))),i[c]=i[c-o]^t}for(let t=0;c;t++,c--){const e=i[3&t?c:c-4];a[t]=4>=c||4>t?e:s[0][n[e>>>24]]^s[1][n[e>>16&255]]^s[2][n[e>>8&255]]^s[3][n[255&e]]}}encrypt(t){return this.N(t,0)}decrypt(t){return this.N(t,1)}H(){const t=this.j[0],e=this.j[1],n=t[4],s=e[4],r=[],o=[];let c,i,a,f;for(let t=0;256>t;t++)o[(r[t]=t<<1^283*(t>>7))^t]=t;for(let l=c=0;!n[l];l^=i||1,c=o[c]||1){let o=c^c<<1^c<<2^c<<3^c<<4;o=o>>8^255&o^99,n[l]=o,s[o]=l,f=r[a=r[i=r[l]]];let u=16843009*f^65537*a^257*i^16843008*l,w=257*r[o]^16843008*o;for(let n=0;4>n;n++)t[n][l]=w=w<<24^w>>>8,e[n][o]=u=u<<24^u>>>8}for(let n=0;5>n;n++)t[n]=t[n].slice(0),e[n]=e[n].slice(0)}N(t,e){if(4!==t.length)throw new r("invalid aes block size");const n=this.A[e],s=n.length/4-2,o=[0,0,0,0],c=this.j[e],i=c[0],a=c[1],f=c[2],l=c[3],u=c[4];let w,h,p,d=t[0]^n[0],y=t[e?3:1]^n[1],m=t[2]^n[2],S=t[e?1:3]^n[3],g=4;for(let t=0;s>t;t++)w=i[d>>>24]^a[y>>16&255]^f[m>>8&255]^l[255&S]^n[g],h=i[y>>>24]^a[m>>16&255]^f[S>>8&255]^l[255&d]^n[g+1],p=i[m>>>24]^a[S>>16&255]^f[d>>8&255]^l[255&y]^n[g+2],S=i[S>>>24]^a[d>>16&255]^f[y>>8&255]^l[255&m]^n[g+3],g+=4,d=w,y=h,m=p;for(let t=0;4>t;t++)o[e?3&-t:t]=u[d>>>24]<<24^u[y>>16&255]<<16^u[m>>8&255]<<8^u[255&S]^n[g++],w=d,d=y,y=m,m=S,S=w;return o}},it=class{constructor(t,e){this.G=t,this.J=e,this.X=e}reset(){this.X=this.J}update(t){return this.Y(this.G,t,this.X)}Z(t){if(255&~(t>>24))t+=1<<24;else{let e=t>>16&255,n=t>>8&255,s=255&t;255===e?(e=0,255===n?(n=0,255===s?s=0:++s):++n):++e,t=0,t+=e<<16,t+=n<<8,t+=s}return t}$(t){0===(t[0]=this.Z(t[0]))&&(t[1]=this.Z(t[1]))}Y(t,e,n){let s;if(!(s=e.length))return[];const r=T.bitLength(e);for(let r=0;s>r;r+=4){this.$(n);const s=t.encrypt(n);e[r]^=s[0],e[r+1]^=s[1],e[r+2]^=s[2],e[r+3]^=s[3]}return T.m(e,r)}},at=E._;let ft=nt&&rt&&typeof st.importKey==k,lt=nt&&rt&&typeof st.deriveBits==k;class ut extends d{constructor({password:t,rawPassword:e,encryptionStrength:n,checkPasswordOnly:s,checkAuthenticationCode:c=!0}){super({start(){ht(this,t,e,n)},async transform(t,e){const n=this,{password:c,strength:i,et:a,ready:f}=n;c?(await(async(t,e,n,s)=>{const o=await dt(t,e,n,mt(s,0,Z[e])),c=mt(s,Z[e]);if(o[0]!=c[0]||o[1]!=c[1])throw new r(O)})(n,i,c,mt(t,0,Z[i]+2)),t=mt(t,Z[i]+2),s?e.error(new r(N)):a()):await f;const l=new o(t.length-tt-(t.length-tt)%G);e.enqueue(pt(n,t,l,0,tt,!0))},async flush(t){const{nt:e,st:n,ot:s,ready:o}=this;if(n&&e){await o;const i=mt(s,0,s.length-tt),a=mt(s,s.length-tt);let f=z;if(i.length){const t=gt(ot,i);n.update(t);const s=e.update(t);f=St(ot,s)}const l=mt(St(ot,n.digest()),0,tt);let u=s.length<tt?1:0;for(let t=0;tt>t;t++)u|=l[t]^a[t];if(u&&c)throw new r(H);t.enqueue(f)}}})}}class wt extends d{constructor({password:t,rawPassword:e,encryptionStrength:n}){super({start(){ht(this,t,e,n)},async transform(t,e){const n=this,{password:s,strength:r,et:c,ready:i}=n;let a=z;s?(a=await(async(t,e,n)=>{const s=q(new o(Z[e]));return W(s,await dt(t,e,n,s))})(n,r,s),c()):await i;const f=new o(a.length+t.length-t.length%G);f.set(a,0),e.enqueue(pt(n,t,f,a.length,0))},async flush(t){const{nt:e,st:n,ot:s,ready:r}=this;if(n&&e){await r;let o=z;if(s.length){const t=e.update(gt(ot,s));n.update(t),o=St(ot,t)}const c=St(ot,n.digest()).slice(0,tt);t.enqueue(W(o,c))}}})}}function ht(t,n,s,r){e.assign(t,{ready:new u(e=>t.et=e),password:yt(n,s),strength:r-1,ot:z})}function pt(t,e,n,s,r,c){const{nt:i,st:a,ot:f}=t;f.length&&(e=W(f,e));const l=e.length-r;let u;for(n=((t,e)=>{if(e&&e>t.length){const n=t;(t=new o(e)).set(n,0)}return t})(n,s+(l-l%G)),u=0;l-G>=u;u+=G){const t=gt(ot,mt(e,u,u+G));c&&a.update(t);const r=i.update(t);c||a.update(r),n.set(St(ot,r),u+s)}return t.ot=mt(e,u),n}async function dt(n,s,r,c){n.password=null;const i=await(async(t,e,n,s,r)=>{if(!ft)return E.importKey(e);try{return await st.importKey("raw",e,n,!1,r)}catch{return ft=!1,E.importKey(e)}})(0,r,Q,0,Y),a=await(async(t,e,n)=>{if(!lt)return E.T(e,t.salt,X.iterations,n);try{return await st.deriveBits(t,e,n)}catch{return lt=!1,E.T(e,t.salt,X.iterations,n)}})(e.assign({salt:c},X),i,8*(2*$[s]+2)),f=new o(a),l=gt(ot,mt(f,0,$[s])),u=gt(ot,mt(f,$[s],2*$[s])),w=mt(f,2*$[s]);return e.assign(n,{keys:{key:l,ct:u,passwordVerification:w},nt:new it(new ct(l),t.from(et)),st:new at(u)}),w}function yt(t,e){return e===v?(t=>{if(typeof w==b){const e=new o((t=unescape(encodeURIComponent(t))).length);for(let n=0;n<e.length;n++)e[n]=t.charCodeAt(n);return e}return(new w).encode(t)})(t):e}function mt(t,e,n){return t.subarray(e,n)}function St(t,e){return t.v(e)}function gt(t,e){return t.C(e)}class vt extends d{constructor({password:t,rawPassword:e,passwordVerification:n,checkPasswordOnly:s}){super({start(){kt(this,t,e,n)},transform(t,e){const n=this;if(n.password||n.rawPassword){const e=zt(n,t.subarray(0,12));if(n.password=n.rawPassword=null,0!=(e[11]^n.passwordVerification))throw new r(O);t=t.subarray(12)}s?e.error(new r(N)):e.enqueue(zt(n,t))}})}}class bt extends d{constructor({password:t,rawPassword:e,passwordVerification:n}){super({start(){kt(this,t,e,n)},transform(t,e){const n=this;let s,r;if(n.password||n.rawPassword){n.password=n.rawPassword=null;const e=q(new o(12));e[11]=n.passwordVerification,s=new o(t.length+e.length),s.set(Ct(n,e),0),r=12}else s=new o(t.length),r=0;s.set(Ct(n,t),r),e.enqueue(s)}})}}function kt(t,n,s,r){e.assign(t,{password:n,rawPassword:s,passwordVerification:r}),((t,n,s)=>{const r=[305419896,591751049,878082192];if(e.assign(t,{keys:r,it:new R(r[0]),ft:new R(r[2])}),s)for(let e=0;e<s.length;e++)It(t,s[e]);else for(let e=0;e<n.length;e++)It(t,n.charCodeAt(e))})(t,n,s)}function zt(t,e){const n=new o(e.length);for(let s=0;s<e.length;s++)n[s]=At(t)^e[s],It(t,n[s]);return n}function Ct(t,e){const n=new o(e.length);for(let s=0;s<e.length;s++)n[s]=At(t)^e[s],It(t,e[s]);return n}function It(t,e){let[,n]=t.keys;t.it.append([e]);const r=~t.it.get();n=Mt(s.imul(Mt(n+xt(r)),134775813)+1),t.ft.append([n>>>24]);const o=~t.ft.get();t.keys=[r,n,o]}function At(t){const e=2|t.keys[2];return xt(s.imul(e,1^e)>>>8)}function xt(t){return 255&t}function Mt(t){return 4294967295&t}function Pt(t){if(t instanceof y)return t;const e=t.getReader();return new y({async pull(t){const{value:n,done:s}=await e.read();s?t.close():t.enqueue(n)},cancel:t=>e.cancel(t)})}const Dt=new f;function Ft(t){return Dt.get(t)}const Bt="Invalid uncompressed size",Rt=j,Ut="deflate-raw",Wt="gzip",_t=[31,139,8];class Tt extends d{constructor(t,{chunkSize:e,CompressionStreamFallback:n,CompressionStream:s}){super({});const{compressed:r,encrypted:o,useCompressionStream:c,zipCrypto:i,computeCrc32:a,level:f,deflate64:u,format:w,compressionMethod:h}=t,p=this;let d,y,m,S=super.readable;const g=w&&Ft(w),v=a&&r&&!u&&!g&&(!o||i)&&!(!c||!s);if(o&&!i||!a||v||(d=new U,S=Ht(S,d)),r)if(g)S=Nt(S,Ot(g.CompressionStream,w,{level:f,chunkSize:e,compressionMethod:h}));else if(v)m=new Vt,S=Nt(S,new s(Wt)),S=Ht(S,m);else try{S=jt(S,c,{level:f,chunkSize:e},s,n)}catch(t){let e;try{e=new s(Wt)}catch{throw t}S=Nt(S,e),S=Ht(S,new Vt)}o&&(i?S=Ht(S,new bt(t)):(y=new wt(t),S=Ht(S,y))),Lt(p,S,()=>{o&&!i||!a||(p.crc32=v?m.crc32:new l(d.value.buffer).getUint32(0))})}}class Vt extends d{constructor(){let t,e=10,n=new o(0);super({transform(t,r){if(e){const n=s.min(e,t.length);if(e-=n,!(t=t.subarray(n)).length)return}const o=n.length+t.length;if(8>=o)return void(n=W(n,t));const c=o-8,i=s.min(c,n.length);r.enqueue(W(n.subarray(0,i),t.subarray(0,c-i))),n=W(n.subarray(i),t.subarray(c-i))},flush(){const e=_(n);t.crc32=e.getUint32(0,!0),t.uncompressedSize=e.getUint32(4,!0)}}),t=this}}class Kt extends d{constructor(t,{chunkSize:e,DecompressionStreamFallback:n,DecompressionStream:s}){super({});const{zipCrypto:c,encrypted:i,checkCrc32:a,crc32:f,compressed:w,useCompressionStream:h,deflate64:p,format:m,compressionMethod:S,rawBitFlag:g,outputSize:b}=t;let k,z,C=super.readable;if(i&&(c?C=Ht(C,new vt(t)):(z=new ut(t),C=Ht(C,z))),w){const t=m&&Ft(m);if(t)C=Nt(C,Ot(t.DecompressionStream,m,{chunkSize:e,compressionMethod:S,rawBitFlag:g,uncompressedSize:b}));else try{C=jt(C,h,{chunkSize:e,deflate64:p},s,n)}catch(t){if(p||b===v)throw t;let e;try{e=new s(Wt)}catch{throw t}C=((t,e,n)=>{const s=new R;let c,i,a,f=0,l=!1;const w=new u((t,e)=>{i=t,a=e});w.catch(()=>{}),n||i();const h=new d({start(t){const e=new o(10);e.set(_t),t.enqueue(e)},transform(t,e){e.enqueue(t)},async flush(t){l=!0,y();try{await w}finally{m()}const e=new o(8),r=_(e);r.setUint32(0,s.get(),!0),r.setUint32(4,n,!0),t.enqueue(e)},cancel(t){a(t)}}),p=new d({transform(t,e){s.append(t),f+=t.length,n>f?l&&y():i(),e.enqueue(t)},cancel(t){a(t)}});return t=Ht(t,h),Ht(t=Nt(t,e),p);function y(){m(),c=setTimeout(()=>a(new r(Bt)),5e3)}function m(){clearTimeout(c)}})(C,e,b)}C=(t=>{const e=t.getReader();return new y({async pull(t){let n;try{n=await e.read()}catch(t){if(t&&t.message)throw t;const e=new r("Invalid compressed data");throw e.cause=t,e}const{value:s,done:o}=n;o?t.close():t.enqueue(s)},cancel:t=>e.cancel(t)})})(C)}a&&(k=new U,C=Ht(C,k)),Lt(this,C,()=>{if(a){const t=new l(k.value.buffer);if(f!=t.getUint32(0,!1))throw new r(Rt)}})}}const Et=new f;function Lt(t,n,s){n=Ht(n,new d({flush:s})),e.defineProperty(t,"readable",{get:()=>n})}function Ot(t,e,n){if(!t)throw new r("Compression method not supported");return new t(e,n)}function jt(t,e,n,s,r){const o=e&&s?s:r||s,c=n.deflate64?"deflate64-raw":Ut;let i;try{i=new o(c,n)}catch(t){if(!e||!r||o==r)throw t;i=new r(c,n)}return Nt(t,i)}function Ht(t,e){return Pt(t).pipeThrough(e)}function Nt(t,e){const n=e.writable.getWriter(),s=t.getReader();return(async()=>{try{for(;;){await n.ready;const t=await s.read();if(t.done){await n.close();break}await n.write(t.value)}}catch(t){await(async(t,e)=>{try{await t.abort(e)}catch{}})(n,t),await(async(t,e)=>{try{await t.cancel(e)}catch{}})(s,t)}})(),e.readable}const qt="data",Gt="close",Jt="deflate";class Qt extends d{constructor(t,n){super({});const s=this,{codecType:o}=t;let c;o.startsWith(Jt)?c=Tt:o.startsWith("inflate")&&(c=Kt),s.outputSize=0;let i=0;const a=new c(t,n),f=super.readable,l=new d({transform(t,e){t&&t.length&&(i+=t.length,e.enqueue(t))},flush(){e.assign(s,{inputSize:i})}}),u=new d({transform(e,n){if(e&&e.length&&(n.enqueue(e),s.outputSize+=e.length,t.outputSize!==v&&s.outputSize>t.outputSize))throw new r(Bt)},flush(){const{crc32:t}=a;e.assign(s,{crc32:t,inputSize:i})}});e.defineProperty(s,"readable",{get:()=>f.pipeThrough(l).pipeThrough(a).pipeThrough(u)})}}class Xt extends d{constructor(t){const e=[];let s=0;function r(){const n=new o(t);let r=0;for(;t>r;){const s=e[0],o=t-r;s.length>o?(n.set(s.subarray(0,o),r),e[0]=s.subarray(o),r+=o):(n.set(s,r),r+=s.length,e.shift())}return s-=t,n}n.isFinite(t)&&t>=1||(t=65536),super({transform(n,o){for(e.push(n),s+=n.length;s>t;)o.enqueue(r())},flush(t){s&&t.enqueue(((t,e)=>{const n=new o(e);let s=0;for(const e of t)n.set(e,s),s+=e.length;return n})(e,s))}})}}let Yt=2;try{typeof navigator!=b&&navigator.hardwareConcurrency&&(Yt=navigator.hardwareConcurrency)}catch{}const Zt=new f,$t=new f;let te,ee,ne,se,re,oe,ce=0;async function ie(t){let e,o;try{const{options:c,config:i}=t;if(c.format)try{await(async(t,e)=>{!Dt.has(t)&&e&&((t,e)=>{const{CompressionStream:n,DecompressionStream:s}=e;if(typeof n!=k&&typeof s!=k)throw new r("Invalid codec module");Dt.set(t,{CompressionStream:n,DecompressionStream:s})})(t,await(import(e)))})(c.format,c.codecURI)}catch(t){throw t.codecImportFailed=!0,t}if(i.CompressionStream=self.CompressionStream,i.DecompressionStream=self.DecompressionStream,c.compressed&&!c.format)if(c.useCompressionStream){if(!((t,e)=>{if(!t)return!1;let n=Et.get(t);n||(n=new f,Et.set(t,n));let s=n.get(e);if(s===v){try{new t(e),s=!0}catch{s=!1}n.set(e,s)}return s})(c.codecType.startsWith(Jt)?i.CompressionStream:i.DecompressionStream,Ut))try{await self.initModule(t.config)}catch{}}else try{await self.initModule(t.config)}catch{c.useCompressionStream=!0}!i.CompressionStreamFallback&&i.CompressionStreamZlib&&(i.CompressionStreamFallback=i.CompressionStreamZlib),!i.DecompressionStreamFallback&&i.DecompressionStreamZlib&&(i.DecompressionStreamFallback=i.DecompressionStreamZlib);const a={highWaterMark:1},l=t.readable?Pt(t.readable):new y({async pull(t){const e=new u(t=>Zt.set(ce,t));ae({type:"pull",messageId:ce}),ce=(ce+1)%n.MAX_SAFE_INTEGER;const{value:s,done:r}=await e;t.enqueue(s),r&&t.close()}},a);o=t.writable?(t=>{if(t instanceof m)return t;const e=t.getWriter();return new m({write:t=>e.write(t),close:()=>e.close(),abort:t=>e.abort(t)})})(t.writable):new m({async write(t){let e;const s=new u(t=>e=t);$t.set(ce,e),ae({type:qt,value:t,messageId:ce}),ce=(ce+1)%n.MAX_SAFE_INTEGER,await s}},a),e=new Qt(c,i),te=new AbortController;const{signal:w}=te;await l.pipeThrough(e).pipeThrough(new Xt((t=>{return r="string"==typeof(e=r=t.chunkSize)&&e.trim()?n(e):e,n.isInteger(r)&&r>=1?s.max(r,64):65536;var e,r})(i))).pipeTo(o,{signal:w,preventClose:!0,preventAbort:!0}),await o.getWriter().close();const{crc32:h,inputSize:p,outputSize:d}=e;ae({type:Gt,result:{crc32:h,inputSize:p,outputSize:d}})}catch(t){if(t.outputSize=e?e.outputSize:0,o&&!o.locked)try{await o.getWriter().close()}catch{}fe(t)}}function ae(t){const{value:e}=t;if(e)if(e.length)try{t.value=(n=e,n.byteOffset||n.byteLength!=n.buffer.byteLength?new o(n):n).buffer,p(t,[t.value])}catch{p(t)}else p(t);else p(t);var n}function fe(t=new r("Unknown error")){const{message:e,stack:n,code:s,name:o,outputSize:c,cause:i,codecImportFailed:a}=t,f={message:e,stack:n,code:s,name:o,outputSize:c};i&&(f.cause={name:i.name,message:i.message}),a&&(f.codecImportFailed=!0),p({error:f})}function le(t,e,n={}){if(!ee){const t=new r("WASM module not loaded");throw t.cause=oe,t}const c="number"==typeof n.level?n.level:-1,i="number"==typeof n.outBuffer?n.outBuffer:65536,a="number"==typeof n.inBufferSize?n.inBufferSize:65536;return new d({start(){try{let n;if(this.lt=ne(i),this.in=ne(a),this.inBufferSize=a,!this.lt||!this.in)throw new r("allocation failed");if(this.ut=new o(i),t?(this.wt=ee.deflate_process,this.ht=ee.deflate_last_consumed,this.yt=ee.deflate_end,this.St=ee.deflate_new(),n="gzip"===e?ee.deflate_init_gzip(this.St,c):"deflate-raw"===e?ee.deflate_init_raw(this.St,c):ee.deflate_init(this.St,c)):"deflate64-raw"===e?(this.wt=ee.inflate9_process,this.ht=ee.inflate9_last_consumed,this.yt=ee.inflate9_end,this.St=ee.inflate9_new(),n=ee.inflate9_init_raw(this.St)):(this.wt=ee.inflate_process,this.ht=ee.inflate_last_consumed,this.yt=ee.inflate_end,this.St=ee.inflate_new(),n="deflate-raw"===e?ee.inflate_init_raw(this.St):"gzip"===e?ee.inflate_init_gzip(this.St):ee.inflate_init(this.St)),0!==n)throw new r("init failed:"+n)}catch(t){throw f(this),t}},transform(e,n){try{const c=e,a=new o(re.buffer),f=this.wt,l=this.ht,u=this.lt,w=this.ut;let h=0;for(;h<c.length;){const e=s.min(c.length-h,32768);if((!this.in||this.inBufferSize<e)&&(this.in&&se&&(se(this.in),this.in=0),this.in=ne(e),this.inBufferSize=e,!this.in))throw new r("allocation failed");a.set(c.subarray(h,h+e),this.in);const o=f(this.St,this.in,e,u,i,0),p=16777215&o;if(p&&(w.set(a.subarray(u,u+p),0),n.enqueue(w.slice(0,p))),!t){const t=o>>24&255,e=128&t?t-256:t;if(0>e)throw new r("process error:"+e)}const d=l(this.St);if(0===d)break;h+=d}}catch(t){f(this),n.error(t)}},flush(e){try{const n=new o(re.buffer),s=this.wt,c=this.lt,a=this.ut;for(;;){const o=s(this.St,0,0,c,i,4),f=16777215&o,l=o>>24&255;if(!t){const t=128&l?l-256:l;if(0>t)throw new r("process error:"+t)}if(f&&(a.set(n.subarray(c,c+f),0),e.enqueue(a.slice(0,f))),1===l||0===f)break}}catch(t){e.error(t)}finally{const t=f(this);0!==t&&e.error(new r("end error:"+t))}},cancel(){f(this)}});function f(t){let e=0;return t.St&&t.yt&&(e=t.yt(t.St)),t.St=0,t.in&&se&&se(t.in),t.in=0,t.lt&&se&&se(t.lt),t.lt=0,e}}addEventListener("message",({data:t})=>{const{type:e,messageId:n,value:s,done:r}=t;try{if("start"==e&&ie(t),e==qt){const t=Zt.get(n);Zt.delete(n),t({value:s||new o,done:r})}if("ack"==e){const t=$t.get(n);$t.delete(n),t()}e==Gt&&te.abort()}catch(t){fe(t)}}),p({type:"ready"});class ue{constructor(t="deflate",e){return le(!0,t,e)}}class we{constructor(t="deflate",e){return le(!1,t,e)}}ue.gt=!0,we.gt=!0;let he=!1;((t={})=>{const{init:e}=t,n=t.CompressionStreamFallback||t.CompressionStreamZlib,s=t.DecompressionStreamFallback||t.DecompressionStreamZlib;self.initModule=async t=>{e&&await e(t),n&&(t.CompressionStreamFallback=n),s&&(t.DecompressionStreamFallback=s)}})({CompressionStreamFallback:ue,DecompressionStreamFallback:we,init:t=>(async(t,{baseURI:e})=>{if(!he)try{await(async(t,e)=>{let n,s;try{try{s=new URL(t,e)}catch{}const r=await fetch(s);n=await r.arrayBuffer()}catch(e){if(!t.startsWith("data:application/wasm;base64,"))throw e;n=(t=>{const e=t.split(",")[1],n=atob(e),s=n.length,r=new o(s);for(let t=0;s>t;++t)r[t]=n.charCodeAt(t);return r.buffer})(t)}(t=>{if(ee=t,({malloc:ne,free:se,memory:re}=ee),"function"!=typeof ne||"function"!=typeof se||!re)throw ee=ne=se=re=null,new r("Invalid WASM module")})((await WebAssembly.instantiate(n)).instance.exports)})(t,e),he=!0}catch(t){throw(t=>{oe=t})(t),t}})(t.wasmURI,t)})});\n';if("string"==typeof s&&(s=(new TextEncoder).encode(s)),t){const t=new Blob([s],{type:n});return URL.createObjectURL(t)}return "data:"+n+";base64,"+(t=>{let n="";const s=t.length;let r=0;for(;s>r+2;r+=3){const s=t[r]<<16|t[r+1]<<8|t[r+2];n+=e[s>>18&63]+e[s>>12&63]+e[s>>6&63]+e[63&s];}const o=s-r;if(1===o){const s=t[r]<<16;n+=e[s>>18&63]+e[s>>12&63]+"==";}else if(2===o){const s=t[r]<<16|t[r+1]<<8;n+=e[s>>18&63]+e[s>>12&63]+e[s>>6&63]+"=";}return n})(s)}});
|
|
253
402
|
|
|
254
403
|
/*
|
|
255
404
|
Copyright (c) 2026 Gildas Lormeau. All rights reserved.
|
|
@@ -1397,13 +1546,13 @@
|
|
|
1397
1546
|
const {
|
|
1398
1547
|
ctr,
|
|
1399
1548
|
hmac,
|
|
1400
|
-
|
|
1549
|
+
pendingInput,
|
|
1401
1550
|
ready
|
|
1402
1551
|
} = this;
|
|
1403
1552
|
if (hmac && ctr) {
|
|
1404
1553
|
await ready;
|
|
1405
|
-
const chunkToDecrypt = subarray(
|
|
1406
|
-
const originalAuthenticationCode = subarray(
|
|
1554
|
+
const chunkToDecrypt = subarray(pendingInput, 0, pendingInput.length - AUTHENTICATION_CODE_LENGTH);
|
|
1555
|
+
const originalAuthenticationCode = subarray(pendingInput, pendingInput.length - AUTHENTICATION_CODE_LENGTH);
|
|
1407
1556
|
let decryptedChunkArray = EMPTY_UINT8_ARRAY;
|
|
1408
1557
|
if (chunkToDecrypt.length) {
|
|
1409
1558
|
const encryptedChunk = toBits(codecBytes, chunkToDecrypt);
|
|
@@ -1412,7 +1561,7 @@
|
|
|
1412
1561
|
decryptedChunkArray = fromBits(codecBytes, decryptedChunk);
|
|
1413
1562
|
}
|
|
1414
1563
|
const authenticationCode = subarray(fromBits(codecBytes, hmac.digest()), 0, AUTHENTICATION_CODE_LENGTH);
|
|
1415
|
-
let invalidAuthenticationCode =
|
|
1564
|
+
let invalidAuthenticationCode = pendingInput.length < AUTHENTICATION_CODE_LENGTH ? 1 : 0;
|
|
1416
1565
|
for (let indexByte = 0; indexByte < AUTHENTICATION_CODE_LENGTH; indexByte++) {
|
|
1417
1566
|
invalidAuthenticationCode |= authenticationCode[indexByte] ^ originalAuthenticationCode[indexByte];
|
|
1418
1567
|
}
|
|
@@ -1456,14 +1605,14 @@
|
|
|
1456
1605
|
const {
|
|
1457
1606
|
ctr,
|
|
1458
1607
|
hmac,
|
|
1459
|
-
|
|
1608
|
+
pendingInput,
|
|
1460
1609
|
ready
|
|
1461
1610
|
} = this;
|
|
1462
1611
|
if (hmac && ctr) {
|
|
1463
1612
|
await ready;
|
|
1464
1613
|
let encryptedChunkArray = EMPTY_UINT8_ARRAY;
|
|
1465
|
-
if (
|
|
1466
|
-
const encryptedChunk = ctr.update(toBits(codecBytes,
|
|
1614
|
+
if (pendingInput.length) {
|
|
1615
|
+
const encryptedChunk = ctr.update(toBits(codecBytes, pendingInput));
|
|
1467
1616
|
hmac.update(encryptedChunk);
|
|
1468
1617
|
encryptedChunkArray = fromBits(codecBytes, encryptedChunk);
|
|
1469
1618
|
}
|
|
@@ -1480,7 +1629,7 @@
|
|
|
1480
1629
|
ready: new Promise(resolve => aesCrypto.resolveReady = resolve),
|
|
1481
1630
|
password: encodePassword(password, rawPassword),
|
|
1482
1631
|
strength: encryptionStrength - 1,
|
|
1483
|
-
|
|
1632
|
+
pendingInput: EMPTY_UINT8_ARRAY
|
|
1484
1633
|
});
|
|
1485
1634
|
}
|
|
1486
1635
|
|
|
@@ -1488,10 +1637,10 @@
|
|
|
1488
1637
|
const {
|
|
1489
1638
|
ctr,
|
|
1490
1639
|
hmac,
|
|
1491
|
-
|
|
1640
|
+
pendingInput
|
|
1492
1641
|
} = aesCrypto;
|
|
1493
|
-
if (
|
|
1494
|
-
input = concat(
|
|
1642
|
+
if (pendingInput.length) {
|
|
1643
|
+
input = concat(pendingInput, input);
|
|
1495
1644
|
}
|
|
1496
1645
|
const inputLength = input.length - paddingEnd;
|
|
1497
1646
|
output = expand(output, paddingStart + (inputLength - (inputLength % BLOCK_LENGTH)));
|
|
@@ -1507,7 +1656,7 @@
|
|
|
1507
1656
|
}
|
|
1508
1657
|
output.set(fromBits(codecBytes, outputChunk), offset + paddingStart);
|
|
1509
1658
|
}
|
|
1510
|
-
aesCrypto.
|
|
1659
|
+
aesCrypto.pendingInput = subarray(input, offset);
|
|
1511
1660
|
return output;
|
|
1512
1661
|
}
|
|
1513
1662
|
|
|
@@ -2762,6 +2911,7 @@
|
|
|
2762
2911
|
worker,
|
|
2763
2912
|
workerAlive: false,
|
|
2764
2913
|
terminated: false,
|
|
2914
|
+
startupError: null,
|
|
2765
2915
|
interface: {
|
|
2766
2916
|
run: async () => {
|
|
2767
2917
|
try {
|
|
@@ -2789,6 +2939,13 @@
|
|
|
2789
2939
|
}
|
|
2790
2940
|
|
|
2791
2941
|
async function runWebWorker(workerData, config) {
|
|
2942
|
+
if (!workerData.worker) {
|
|
2943
|
+
const { startupError } = workerData;
|
|
2944
|
+
workerData.startupError = null;
|
|
2945
|
+
const error = startupError || new Error(ERR_WORKER_STARTUP_TIMEOUT);
|
|
2946
|
+
error.workerStartupFailed = true;
|
|
2947
|
+
throw error;
|
|
2948
|
+
}
|
|
2792
2949
|
let resolveResult, rejectResult;
|
|
2793
2950
|
const result = new Promise((resolve, reject) => {
|
|
2794
2951
|
resolveResult = resolve;
|
|
@@ -3002,11 +3159,12 @@
|
|
|
3002
3159
|
if (!workerAlive) {
|
|
3003
3160
|
workerData.worker = null;
|
|
3004
3161
|
}
|
|
3162
|
+
let error = event.error || new Error(event.message || ERROR_EVENT_TYPE);
|
|
3163
|
+
if (!workerAlive) {
|
|
3164
|
+
error = Object.assign(new Error(error.message || ERROR_EVENT_TYPE), { workerStartupFailed: true });
|
|
3165
|
+
workerData.startupError = error;
|
|
3166
|
+
}
|
|
3005
3167
|
if (rejectResult) {
|
|
3006
|
-
let error = event.error || new Error(event.message || ERROR_EVENT_TYPE);
|
|
3007
|
-
if (!workerAlive) {
|
|
3008
|
-
error = Object.assign(new Error(error.message || ERROR_EVENT_TYPE), { workerStartupFailed: true });
|
|
3009
|
-
}
|
|
3010
3168
|
rejectResult(error);
|
|
3011
3169
|
if (writer) {
|
|
3012
3170
|
writer.releaseLock();
|
|
@@ -3275,6 +3433,96 @@
|
|
|
3275
3433
|
resetWebWorkerSupport();
|
|
3276
3434
|
}
|
|
3277
3435
|
|
|
3436
|
+
/*
|
|
3437
|
+
Copyright (c) 2022 Gildas Lormeau. All rights reserved.
|
|
3438
|
+
|
|
3439
|
+
Redistribution and use in source and binary forms, with or without
|
|
3440
|
+
modification, are permitted provided that the following conditions are met:
|
|
3441
|
+
|
|
3442
|
+
1. Redistributions of source code must retain the above copyright notice,
|
|
3443
|
+
this list of conditions and the following disclaimer.
|
|
3444
|
+
|
|
3445
|
+
2. Redistributions in binary form must reproduce the above copyright
|
|
3446
|
+
notice, this list of conditions and the following disclaimer in
|
|
3447
|
+
the documentation and/or other materials provided with the distribution.
|
|
3448
|
+
|
|
3449
|
+
3. The names of the authors may not be used to endorse or promote products
|
|
3450
|
+
derived from this software without specific prior written permission.
|
|
3451
|
+
|
|
3452
|
+
THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
|
3453
|
+
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
3454
|
+
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
|
|
3455
|
+
INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
3456
|
+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
3457
|
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
|
3458
|
+
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
3459
|
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
3460
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
|
3461
|
+
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
3462
|
+
*/
|
|
3463
|
+
|
|
3464
|
+
/* global TextDecoder */
|
|
3465
|
+
|
|
3466
|
+
const CP437 = "\0☺☻♥♦♣♠•◘○◙♂♀♪♫☼►◄↕‼¶§▬↨↑↓→←∟↔▲▼ !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~⌂ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥₧ƒáíóúñѪº¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ ".split("");
|
|
3467
|
+
const VALID_CP437 = CP437.length == 256;
|
|
3468
|
+
|
|
3469
|
+
function decodeCP437(stringValue) {
|
|
3470
|
+
if (VALID_CP437) {
|
|
3471
|
+
let result = "";
|
|
3472
|
+
for (let indexCharacter = 0; indexCharacter < stringValue.length; indexCharacter++) {
|
|
3473
|
+
result += CP437[stringValue[indexCharacter]];
|
|
3474
|
+
}
|
|
3475
|
+
return result;
|
|
3476
|
+
} else {
|
|
3477
|
+
return new TextDecoder().decode(stringValue);
|
|
3478
|
+
}
|
|
3479
|
+
}
|
|
3480
|
+
|
|
3481
|
+
/*
|
|
3482
|
+
Copyright (c) 2022 Gildas Lormeau. All rights reserved.
|
|
3483
|
+
|
|
3484
|
+
Redistribution and use in source and binary forms, with or without
|
|
3485
|
+
modification, are permitted provided that the following conditions are met:
|
|
3486
|
+
|
|
3487
|
+
1. Redistributions of source code must retain the above copyright notice,
|
|
3488
|
+
this list of conditions and the following disclaimer.
|
|
3489
|
+
|
|
3490
|
+
2. Redistributions in binary form must reproduce the above copyright
|
|
3491
|
+
notice, this list of conditions and the following disclaimer in
|
|
3492
|
+
the documentation and/or other materials provided with the distribution.
|
|
3493
|
+
|
|
3494
|
+
3. The names of the authors may not be used to endorse or promote products
|
|
3495
|
+
derived from this software without specific prior written permission.
|
|
3496
|
+
|
|
3497
|
+
THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
|
3498
|
+
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
3499
|
+
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
|
|
3500
|
+
INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
3501
|
+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
3502
|
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
|
3503
|
+
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
3504
|
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
3505
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
|
3506
|
+
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
3507
|
+
*/
|
|
3508
|
+
|
|
3509
|
+
|
|
3510
|
+
function decodeText(value, encoding) {
|
|
3511
|
+
return decode(value, encoding, true);
|
|
3512
|
+
}
|
|
3513
|
+
|
|
3514
|
+
function decodeTextRemovingBOM(value, encoding) {
|
|
3515
|
+
return decode(value, encoding, false);
|
|
3516
|
+
}
|
|
3517
|
+
|
|
3518
|
+
function decode(value, encoding, ignoreBOM) {
|
|
3519
|
+
if (encoding && encoding.trim().toLowerCase() == "cp437") {
|
|
3520
|
+
return decodeCP437(value);
|
|
3521
|
+
} else {
|
|
3522
|
+
return new TextDecoder(encoding, { ignoreBOM }).decode(value);
|
|
3523
|
+
}
|
|
3524
|
+
}
|
|
3525
|
+
|
|
3278
3526
|
/*
|
|
3279
3527
|
Copyright (c) 2025 Gildas Lormeau. All rights reserved.
|
|
3280
3528
|
|
|
@@ -3347,6 +3595,7 @@
|
|
|
3347
3595
|
createReadable({ offset = 0, size, chunkSize = getChunkSize(getConfiguration()) } = {}) {
|
|
3348
3596
|
const reader = this;
|
|
3349
3597
|
let chunkOffset = 0;
|
|
3598
|
+
chunkSize = normalizeChunkSize(chunkSize);
|
|
3350
3599
|
return new ReadableStream({
|
|
3351
3600
|
async pull(controller) {
|
|
3352
3601
|
const dataSize = size === UNDEFINED_VALUE ? chunkSize : Math.min(chunkSize, size - chunkOffset);
|
|
@@ -3354,7 +3603,7 @@
|
|
|
3354
3603
|
if (data.length) {
|
|
3355
3604
|
controller.enqueue(data);
|
|
3356
3605
|
}
|
|
3357
|
-
if ((chunkOffset + chunkSize >= size) || (
|
|
3606
|
+
if ((chunkOffset + chunkSize >= size) || (!data.length && dataSize)) {
|
|
3358
3607
|
controller.close();
|
|
3359
3608
|
} else {
|
|
3360
3609
|
chunkOffset += chunkSize;
|
|
@@ -3434,31 +3683,31 @@
|
|
|
3434
3683
|
Object.assign(this, {
|
|
3435
3684
|
contentType,
|
|
3436
3685
|
data: "data:" + (contentType || "") + ";base64,",
|
|
3437
|
-
|
|
3686
|
+
pendingCharacters: ""
|
|
3438
3687
|
});
|
|
3439
3688
|
}
|
|
3440
3689
|
|
|
3441
3690
|
writeUint8Array(array) {
|
|
3442
3691
|
const writer = this;
|
|
3443
3692
|
let indexArray;
|
|
3444
|
-
let dataString = writer.
|
|
3445
|
-
const delta = writer.
|
|
3446
|
-
writer.
|
|
3693
|
+
let dataString = writer.pendingCharacters;
|
|
3694
|
+
const delta = writer.pendingCharacters.length;
|
|
3695
|
+
writer.pendingCharacters = "";
|
|
3447
3696
|
for (indexArray = 0; indexArray < (Math.floor((delta + array.length) / 3) * 3) - delta; indexArray++) {
|
|
3448
3697
|
dataString += String.fromCharCode(array[indexArray]);
|
|
3449
3698
|
}
|
|
3450
3699
|
for (; indexArray < array.length; indexArray++) {
|
|
3451
|
-
writer.
|
|
3700
|
+
writer.pendingCharacters += String.fromCharCode(array[indexArray]);
|
|
3452
3701
|
}
|
|
3453
3702
|
if (dataString.length > 2) {
|
|
3454
3703
|
writer.data += btoa(dataString);
|
|
3455
3704
|
} else {
|
|
3456
|
-
writer.
|
|
3705
|
+
writer.pendingCharacters = dataString + writer.pendingCharacters;
|
|
3457
3706
|
}
|
|
3458
3707
|
}
|
|
3459
3708
|
|
|
3460
3709
|
getData() {
|
|
3461
|
-
return this.data + btoa(this.
|
|
3710
|
+
return this.data + btoa(this.pendingCharacters);
|
|
3462
3711
|
}
|
|
3463
3712
|
}
|
|
3464
3713
|
|
|
@@ -3488,7 +3737,7 @@
|
|
|
3488
3737
|
constructor(blob) {
|
|
3489
3738
|
super();
|
|
3490
3739
|
Object.assign(this, {
|
|
3491
|
-
blob,
|
|
3740
|
+
sourceBlob: blob,
|
|
3492
3741
|
size: blob.size
|
|
3493
3742
|
});
|
|
3494
3743
|
if (!blobSliceProbe) {
|
|
@@ -3498,13 +3747,13 @@
|
|
|
3498
3747
|
|
|
3499
3748
|
createReadable(options) {
|
|
3500
3749
|
const reader = this;
|
|
3501
|
-
const {
|
|
3750
|
+
const { sourceBlob, size } = reader;
|
|
3502
3751
|
const { offset = 0, size: readSize = size - offset } = options || {};
|
|
3503
3752
|
if (!offset && readSize >= size) {
|
|
3504
|
-
return toCompatibleReadable(
|
|
3753
|
+
return toCompatibleReadable(sourceBlob.stream());
|
|
3505
3754
|
}
|
|
3506
3755
|
if (blobSliceReliable) {
|
|
3507
|
-
return toCompatibleReadable(
|
|
3756
|
+
return toCompatibleReadable(sourceBlob.slice(offset, offset + readSize).stream());
|
|
3508
3757
|
}
|
|
3509
3758
|
return super.createReadable(options);
|
|
3510
3759
|
}
|
|
@@ -3513,7 +3762,7 @@
|
|
|
3513
3762
|
const reader = this;
|
|
3514
3763
|
const offsetEnd = offset + length;
|
|
3515
3764
|
const readsWholeBlob = !offset && offsetEnd >= reader.size;
|
|
3516
|
-
const blob = readsWholeBlob ? reader.
|
|
3765
|
+
const blob = readsWholeBlob ? reader.sourceBlob : reader.sourceBlob.slice(offset, offsetEnd);
|
|
3517
3766
|
let arrayBuffer = await blob.arrayBuffer();
|
|
3518
3767
|
const sliceIgnoredByBuggyImplementation = arrayBuffer.byteLength > length;
|
|
3519
3768
|
if (sliceIgnoredByBuggyImplementation) {
|
|
@@ -3535,12 +3784,12 @@
|
|
|
3535
3784
|
}
|
|
3536
3785
|
});
|
|
3537
3786
|
writer.contentType = contentType;
|
|
3538
|
-
writer.
|
|
3539
|
-
writer.
|
|
3787
|
+
writer.blobPromise = streamToBlob(transformStream.readable, contentType);
|
|
3788
|
+
writer.blobPromise.catch(() => { });
|
|
3540
3789
|
}
|
|
3541
3790
|
|
|
3542
3791
|
getData() {
|
|
3543
|
-
return this.
|
|
3792
|
+
return this.blobPromise;
|
|
3544
3793
|
}
|
|
3545
3794
|
}
|
|
3546
3795
|
|
|
@@ -3574,7 +3823,7 @@
|
|
|
3574
3823
|
class TextWriter extends BlobWriter {
|
|
3575
3824
|
|
|
3576
3825
|
constructor(encoding) {
|
|
3577
|
-
super(
|
|
3826
|
+
super();
|
|
3578
3827
|
Object.assign(this, {
|
|
3579
3828
|
encoding,
|
|
3580
3829
|
utf8: !encoding || encoding.toLowerCase() == "utf-8"
|
|
@@ -3590,14 +3839,7 @@
|
|
|
3590
3839
|
if (blob.text && utf8) {
|
|
3591
3840
|
return blob.text();
|
|
3592
3841
|
} else {
|
|
3593
|
-
|
|
3594
|
-
return new Promise((resolve, reject) => {
|
|
3595
|
-
Object.assign(reader, {
|
|
3596
|
-
onload: ({ target }) => resolve(target.result),
|
|
3597
|
-
onerror: () => reject(reader.error)
|
|
3598
|
-
});
|
|
3599
|
-
reader.readAsText(blob, encoding);
|
|
3600
|
-
});
|
|
3842
|
+
return decodeTextRemovingBOM(new Uint8Array(await blob.arrayBuffer()), encoding);
|
|
3601
3843
|
}
|
|
3602
3844
|
}
|
|
3603
3845
|
}
|
|
@@ -4055,9 +4297,8 @@
|
|
|
4055
4297
|
|
|
4056
4298
|
async init() {
|
|
4057
4299
|
const reader = this;
|
|
4058
|
-
const { readers } = reader;
|
|
4059
4300
|
reader.lastDiskNumber = 0;
|
|
4060
|
-
await Promise.all(readers.map(
|
|
4301
|
+
const readers = reader.readers = await Promise.all(reader.readers.map(initDiskReader));
|
|
4061
4302
|
reader.diskOffsets = readers.map(diskReader => {
|
|
4062
4303
|
const diskOffset = reader.size;
|
|
4063
4304
|
reader.size += diskReader.size;
|
|
@@ -4252,89 +4493,27 @@
|
|
|
4252
4493
|
}
|
|
4253
4494
|
}
|
|
4254
4495
|
|
|
4255
|
-
function
|
|
4256
|
-
|
|
4257
|
-
|
|
4258
|
-
|
|
4259
|
-
|
|
4260
|
-
|
|
4261
|
-
|
|
4262
|
-
Redistribution and use in source and binary forms, with or without
|
|
4263
|
-
modification, are permitted provided that the following conditions are met:
|
|
4264
|
-
|
|
4265
|
-
1. Redistributions of source code must retain the above copyright notice,
|
|
4266
|
-
this list of conditions and the following disclaimer.
|
|
4267
|
-
|
|
4268
|
-
2. Redistributions in binary form must reproduce the above copyright
|
|
4269
|
-
notice, this list of conditions and the following disclaimer in
|
|
4270
|
-
the documentation and/or other materials provided with the distribution.
|
|
4271
|
-
|
|
4272
|
-
3. The names of the authors may not be used to endorse or promote products
|
|
4273
|
-
derived from this software without specific prior written permission.
|
|
4274
|
-
|
|
4275
|
-
THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
|
4276
|
-
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
4277
|
-
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
|
|
4278
|
-
INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
4279
|
-
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
4280
|
-
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
|
4281
|
-
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
4282
|
-
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
4283
|
-
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
|
4284
|
-
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
4285
|
-
*/
|
|
4286
|
-
|
|
4287
|
-
/* global TextDecoder */
|
|
4288
|
-
|
|
4289
|
-
const CP437 = "\0☺☻♥♦♣♠•◘○◙♂♀♪♫☼►◄↕‼¶§▬↨↑↓→←∟↔▲▼ !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~⌂ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥₧ƒáíóúñѪº¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ ".split("");
|
|
4290
|
-
const VALID_CP437 = CP437.length == 256;
|
|
4291
|
-
|
|
4292
|
-
function decodeCP437(stringValue) {
|
|
4293
|
-
if (VALID_CP437) {
|
|
4294
|
-
let result = "";
|
|
4295
|
-
for (let indexCharacter = 0; indexCharacter < stringValue.length; indexCharacter++) {
|
|
4296
|
-
result += CP437[stringValue[indexCharacter]];
|
|
4297
|
-
}
|
|
4298
|
-
return result;
|
|
4299
|
-
} else {
|
|
4300
|
-
return new TextDecoder().decode(stringValue);
|
|
4496
|
+
async function initDiskReader(diskReader) {
|
|
4497
|
+
diskReader = new GenericReader(diskReader);
|
|
4498
|
+
await initStream(diskReader);
|
|
4499
|
+
if (diskReader.size === UNDEFINED_VALUE || !diskReader.readUint8Array) {
|
|
4500
|
+
diskReader = new BlobReader(await streamToBlob(diskReader.readable));
|
|
4501
|
+
await initStream(diskReader);
|
|
4301
4502
|
}
|
|
4503
|
+
return diskReader;
|
|
4302
4504
|
}
|
|
4303
4505
|
|
|
4304
|
-
|
|
4305
|
-
|
|
4306
|
-
|
|
4307
|
-
Redistribution and use in source and binary forms, with or without
|
|
4308
|
-
modification, are permitted provided that the following conditions are met:
|
|
4309
|
-
|
|
4310
|
-
1. Redistributions of source code must retain the above copyright notice,
|
|
4311
|
-
this list of conditions and the following disclaimer.
|
|
4312
|
-
|
|
4313
|
-
2. Redistributions in binary form must reproduce the above copyright
|
|
4314
|
-
notice, this list of conditions and the following disclaimer in
|
|
4315
|
-
the documentation and/or other materials provided with the distribution.
|
|
4316
|
-
|
|
4317
|
-
3. The names of the authors may not be used to endorse or promote products
|
|
4318
|
-
derived from this software without specific prior written permission.
|
|
4319
|
-
|
|
4320
|
-
THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
|
4321
|
-
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
4322
|
-
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
|
|
4323
|
-
INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
4324
|
-
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
4325
|
-
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
|
4326
|
-
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
4327
|
-
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
4328
|
-
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
|
4329
|
-
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
4330
|
-
*/
|
|
4331
|
-
|
|
4506
|
+
function readUint8Array(reader, offset, size) {
|
|
4507
|
+
return reader.readUint8Array(offset, size);
|
|
4508
|
+
}
|
|
4332
4509
|
|
|
4333
|
-
function
|
|
4334
|
-
if (
|
|
4335
|
-
return
|
|
4510
|
+
function createReadable(reader, options) {
|
|
4511
|
+
if (reader.createReadable) {
|
|
4512
|
+
return reader.createReadable(options);
|
|
4513
|
+
} else if (reader.readUint8Array) {
|
|
4514
|
+
return Reader.prototype.createReadable.call(reader, options);
|
|
4336
4515
|
} else {
|
|
4337
|
-
return
|
|
4516
|
+
return reader.readable;
|
|
4338
4517
|
}
|
|
4339
4518
|
}
|
|
4340
4519
|
|
|
@@ -4410,6 +4589,10 @@
|
|
|
4410
4589
|
const PROPERTY_NAME_SETGID = "setgid";
|
|
4411
4590
|
const PROPERTY_NAME_STICKY = "sticky";
|
|
4412
4591
|
const PROPERTY_NAME_BITFLAG = "bitFlag";
|
|
4592
|
+
const PROPERTY_NAME_RAW_BITFLAG = "rawBitFlag";
|
|
4593
|
+
const PROPERTY_NAME_FILENAME_LENGTH = "filenameLength";
|
|
4594
|
+
const PROPERTY_NAME_EXTRA_FIELD_LENGTH = "extraFieldLength";
|
|
4595
|
+
const PROPERTY_NAME_UNIX_EXTERNAL_UPPER = "unixExternalUpper";
|
|
4413
4596
|
const PROPERTY_NAME_FILENAME_UTF8 = "filenameUTF8";
|
|
4414
4597
|
const PROPERTY_NAME_COMMENT_UTF8 = "commentUTF8";
|
|
4415
4598
|
const PROPERTY_NAME_RAW_EXTRA_FIELD = "rawExtraField";
|
|
@@ -4462,10 +4645,14 @@
|
|
|
4462
4645
|
PROPERTY_NAME_UID,
|
|
4463
4646
|
PROPERTY_NAME_GID,
|
|
4464
4647
|
PROPERTY_NAME_UNIX_MODE,
|
|
4648
|
+
PROPERTY_NAME_UNIX_EXTERNAL_UPPER,
|
|
4465
4649
|
PROPERTY_NAME_SETUID,
|
|
4466
4650
|
PROPERTY_NAME_SETGID,
|
|
4467
4651
|
PROPERTY_NAME_STICKY,
|
|
4468
4652
|
PROPERTY_NAME_BITFLAG,
|
|
4653
|
+
PROPERTY_NAME_RAW_BITFLAG,
|
|
4654
|
+
PROPERTY_NAME_FILENAME_LENGTH,
|
|
4655
|
+
PROPERTY_NAME_EXTRA_FIELD_LENGTH,
|
|
4469
4656
|
PROPERTY_NAME_FILENAME_UTF8,
|
|
4470
4657
|
PROPERTY_NAME_COMMENT_UTF8,
|
|
4471
4658
|
PROPERTY_NAME_RAW_EXTRA_FIELD,
|
|
@@ -4486,82 +4673,6 @@
|
|
|
4486
4673
|
|
|
4487
4674
|
}
|
|
4488
4675
|
|
|
4489
|
-
/*
|
|
4490
|
-
Copyright (c) 2022 Gildas Lormeau. All rights reserved.
|
|
4491
|
-
|
|
4492
|
-
Redistribution and use in source and binary forms, with or without
|
|
4493
|
-
modification, are permitted provided that the following conditions are met:
|
|
4494
|
-
|
|
4495
|
-
1. Redistributions of source code must retain the above copyright notice,
|
|
4496
|
-
this list of conditions and the following disclaimer.
|
|
4497
|
-
|
|
4498
|
-
2. Redistributions in binary form must reproduce the above copyright
|
|
4499
|
-
notice, this list of conditions and the following disclaimer in
|
|
4500
|
-
the documentation and/or other materials provided with the distribution.
|
|
4501
|
-
|
|
4502
|
-
3. The names of the authors may not be used to endorse or promote products
|
|
4503
|
-
derived from this software without specific prior written permission.
|
|
4504
|
-
|
|
4505
|
-
THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
|
4506
|
-
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
4507
|
-
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
|
|
4508
|
-
INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
4509
|
-
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
4510
|
-
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
|
4511
|
-
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
4512
|
-
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
4513
|
-
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
|
4514
|
-
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
4515
|
-
*/
|
|
4516
|
-
|
|
4517
|
-
const OPTION_FILENAME_ENCODING = "filenameEncoding";
|
|
4518
|
-
const OPTION_COMMENT_ENCODING = "commentEncoding";
|
|
4519
|
-
const OPTION_DECODE_TEXT = "decodeText";
|
|
4520
|
-
const OPTION_EXTRACT_PREPENDED_DATA = "extractPrependedData";
|
|
4521
|
-
const OPTION_EXTRACT_APPENDED_DATA = "extractAppendedData";
|
|
4522
|
-
const OPTION_PASSWORD = "password";
|
|
4523
|
-
const OPTION_RAW_PASSWORD = "rawPassword";
|
|
4524
|
-
const OPTION_PASS_THROUGH = "passThrough";
|
|
4525
|
-
const OPTION_SIGNAL = "signal";
|
|
4526
|
-
const OPTION_CHECK_PASSWORD_ONLY = "checkPasswordOnly";
|
|
4527
|
-
const OPTION_CHECK_OVERLAPPING_ENTRY_ONLY = "checkOverlappingEntryOnly";
|
|
4528
|
-
const OPTION_CHECK_OVERLAPPING_ENTRY = "checkOverlappingEntry";
|
|
4529
|
-
const OPTION_CHECK_AMBIGUITY = "checkAmbiguity";
|
|
4530
|
-
const OPTION_CHECK_SIGNATURE = "checkSignature";
|
|
4531
|
-
const OPTION_CHECK_CRC32 = "checkCrc32";
|
|
4532
|
-
const OPTION_CHECK_AUTHENTICATION_CODE = "checkAuthenticationCode";
|
|
4533
|
-
const OPTION_USE_WEB_WORKERS = "useWebWorkers";
|
|
4534
|
-
const OPTION_USE_COMPRESSION_STREAM = "useCompressionStream";
|
|
4535
|
-
const OPTION_TRANSFER_STREAMS = "transferStreams";
|
|
4536
|
-
const OPTION_PREVENT_CLOSE = "preventClose";
|
|
4537
|
-
const OPTION_ENCRYPTION_STRENGTH = "encryptionStrength";
|
|
4538
|
-
const OPTION_EXTENDED_TIMESTAMP = "extendedTimestamp";
|
|
4539
|
-
const OPTION_NTFS_TIMESTAMP = "ntfsTimestamp";
|
|
4540
|
-
const OPTION_KEEP_ORDER = "keepOrder";
|
|
4541
|
-
const OPTION_LEVEL = "level";
|
|
4542
|
-
const OPTION_BUFFERED_WRITE = "bufferedWrite";
|
|
4543
|
-
const OPTION_CREATE_TEMP_STREAM = "createTempStream";
|
|
4544
|
-
const OPTION_DATA_DESCRIPTOR_SIGNATURE = "dataDescriptorSignature";
|
|
4545
|
-
const OPTION_USE_UNICODE_FILE_NAMES = "useUnicodeFileNames";
|
|
4546
|
-
const OPTION_DATA_DESCRIPTOR = "dataDescriptor";
|
|
4547
|
-
const OPTION_SUPPORT_ZIP64_SPLIT_FILE = "supportZip64SplitFile";
|
|
4548
|
-
const OPTION_ENCODE_TEXT = "encodeText";
|
|
4549
|
-
const OPTION_OFFSET = "offset";
|
|
4550
|
-
const OPTION_USDZ = "usdz";
|
|
4551
|
-
const OPTION_UNIX_EXTRA_FIELD_TYPE = "unixExtraFieldType";
|
|
4552
|
-
const OPTION_LOCAL_EXTRA_FIELD = "localExtraField";
|
|
4553
|
-
const OPTION_STRICTNESS = "strictness";
|
|
4554
|
-
const OPTION_FILENAME_VALIDATION = "filenameValidation";
|
|
4555
|
-
const OPTION_NORMALIZE_FILENAME = "normalizeFilename";
|
|
4556
|
-
const OPTION_MAX_APPENDED_DATA_SIZE = "maxAppendedDataSize";
|
|
4557
|
-
const OPTION_DECRYPT_CENTRAL_DIRECTORY = "decryptCentralDirectory";
|
|
4558
|
-
const OPTION_SIGN_CENTRAL_DIRECTORY = "signCentralDirectory";
|
|
4559
|
-
const TEXT_TYPE_FILENAME = "filename";
|
|
4560
|
-
const TEXT_TYPE_COMMENT = "comment";
|
|
4561
|
-
const STRICTNESS_STRICT = "strict";
|
|
4562
|
-
const STRICTNESS_BALANCED = "balanced";
|
|
4563
|
-
const STRICTNESS_TOLERANT = "tolerant";
|
|
4564
|
-
|
|
4565
4676
|
/*
|
|
4566
4677
|
Copyright (c) 2025 Gildas Lormeau. All rights reserved.
|
|
4567
4678
|
|
|
@@ -4602,6 +4713,7 @@
|
|
|
4602
4713
|
const ERR_UNSUPPORTED_COMPRESSION$1 = "Compression method not supported";
|
|
4603
4714
|
const ERR_SPLIT_ZIP_FILE = "Split zip file";
|
|
4604
4715
|
const ERR_OVERLAPPING_ENTRY = "Overlapping entry found";
|
|
4716
|
+
const ERR_ENTRY_DATA_OUT_OF_BOUNDS = "Entry data out of bounds";
|
|
4605
4717
|
const ERR_AMBIGUOUS_ARCHIVE = "Ambiguous archive";
|
|
4606
4718
|
const ERR_ENCRYPTED_CENTRAL_DIRECTORY = "Encrypted central directory is not supported";
|
|
4607
4719
|
const ERR_UNSAFE_FILENAME = "Unsafe filename";
|
|
@@ -4622,7 +4734,7 @@
|
|
|
4622
4734
|
];
|
|
4623
4735
|
const ZIP64_EXTRACTION = {
|
|
4624
4736
|
[MAX_16_BITS]: {
|
|
4625
|
-
getValue: getUint32,
|
|
4737
|
+
getValue: getUint32$1,
|
|
4626
4738
|
bytes: 4
|
|
4627
4739
|
},
|
|
4628
4740
|
[MAX_32_BITS]: {
|
|
@@ -4631,6 +4743,7 @@
|
|
|
4631
4743
|
}
|
|
4632
4744
|
};
|
|
4633
4745
|
const MAX_END_OF_CENTRAL_DIR_PROBES = 64;
|
|
4746
|
+
const MAX_DEFLATE_EXPANSION_RATIO = 1032;
|
|
4634
4747
|
const CENTRAL_DIRECTORY_UNREACHABLE = 0;
|
|
4635
4748
|
const CENTRAL_DIRECTORY_PLAUSIBLE = 1;
|
|
4636
4749
|
const CENTRAL_DIRECTORY_REACHABLE = 2;
|
|
@@ -4641,7 +4754,6 @@
|
|
|
4641
4754
|
Object.assign(this, {
|
|
4642
4755
|
reader: new GenericReader(reader),
|
|
4643
4756
|
options,
|
|
4644
|
-
config: getConfiguration(),
|
|
4645
4757
|
readRanges: new Map()
|
|
4646
4758
|
});
|
|
4647
4759
|
}
|
|
@@ -4649,7 +4761,6 @@
|
|
|
4649
4761
|
async* getEntriesGenerator(options = {}) {
|
|
4650
4762
|
const zipReader = this;
|
|
4651
4763
|
let { reader } = zipReader;
|
|
4652
|
-
const { config } = zipReader;
|
|
4653
4764
|
await initStream(reader);
|
|
4654
4765
|
if (reader.size === UNDEFINED_VALUE || !reader.readUint8Array) {
|
|
4655
4766
|
reader = new BlobReader(await streamToBlob(reader.readable));
|
|
@@ -4658,7 +4769,7 @@
|
|
|
4658
4769
|
if (reader.size < END_OF_CENTRAL_DIR_LENGTH) {
|
|
4659
4770
|
throw new Error(ERR_BAD_FORMAT);
|
|
4660
4771
|
}
|
|
4661
|
-
const strictness = getStrictness(
|
|
4772
|
+
const strictness = getStrictness(options, zipReader.options);
|
|
4662
4773
|
const checkAmbiguity = strictness == STRICTNESS_STRICT;
|
|
4663
4774
|
const rejectAmbiguousEndOfDirectory = strictness != STRICTNESS_TOLERANT;
|
|
4664
4775
|
const maxAppendedDataSize = getMaxAppendedDataSize(getOptionValue$1(zipReader, options, OPTION_MAX_APPENDED_DATA_SIZE), strictness);
|
|
@@ -4666,9 +4777,7 @@
|
|
|
4666
4777
|
const normalizeFilename = getOptionValue$1(zipReader, options, OPTION_NORMALIZE_FILENAME);
|
|
4667
4778
|
const { endOfDirectoryInfo, endOfDirectoryReachingEndCount } = await findEndOfCentralDirectory(reader, rejectAmbiguousEndOfDirectory, maxAppendedDataSize);
|
|
4668
4779
|
if (!endOfDirectoryInfo) {
|
|
4669
|
-
|
|
4670
|
-
const signatureView = getDataView(signatureArray);
|
|
4671
|
-
if (getUint32(signatureView) == SPLIT_ZIP_FILE_SIGNATURE) {
|
|
4780
|
+
if (await startsWithSplitZipSignature$1(reader)) {
|
|
4672
4781
|
throw new Error(ERR_SPLIT_ZIP_FILE);
|
|
4673
4782
|
} else {
|
|
4674
4783
|
throw new Error(ERR_EOCDR_NOT_FOUND);
|
|
@@ -4678,18 +4787,18 @@
|
|
|
4678
4787
|
throwAmbiguousArchive("multiple end of central directory records");
|
|
4679
4788
|
}
|
|
4680
4789
|
const endOfDirectoryView = getDataView(endOfDirectoryInfo);
|
|
4681
|
-
let directoryDataLength = getUint32(endOfDirectoryView, 12);
|
|
4682
|
-
let directoryDataOffset = getUint32(endOfDirectoryView, 16);
|
|
4790
|
+
let directoryDataLength = getUint32$1(endOfDirectoryView, 12);
|
|
4791
|
+
let directoryDataOffset = getUint32$1(endOfDirectoryView, 16);
|
|
4683
4792
|
const commentOffset = endOfDirectoryInfo.offset;
|
|
4684
|
-
const commentLength = getUint16(endOfDirectoryView, 20);
|
|
4793
|
+
const commentLength = getUint16$1(endOfDirectoryView, 20);
|
|
4685
4794
|
const appendedDataOffset = commentOffset + END_OF_CENTRAL_DIR_LENGTH + commentLength;
|
|
4686
4795
|
if (reader.size - appendedDataOffset > maxAppendedDataSize) {
|
|
4687
4796
|
throwAmbiguousArchive("appended data");
|
|
4688
4797
|
}
|
|
4689
|
-
let lastDiskNumber = getUint16(endOfDirectoryView, 4);
|
|
4798
|
+
let lastDiskNumber = getUint16$1(endOfDirectoryView, 4);
|
|
4690
4799
|
const expectedLastDiskNumber = reader.lastDiskNumber || 0;
|
|
4691
|
-
let diskNumber = getUint16(endOfDirectoryView, 6);
|
|
4692
|
-
let filesLength = getUint16(endOfDirectoryView, 10);
|
|
4800
|
+
let diskNumber = getUint16$1(endOfDirectoryView, 6);
|
|
4801
|
+
let filesLength = getUint16$1(endOfDirectoryView, 10);
|
|
4693
4802
|
let prependedDataLength = 0;
|
|
4694
4803
|
let startOffset;
|
|
4695
4804
|
let zip64EndOfDirectory;
|
|
@@ -4705,12 +4814,12 @@
|
|
|
4705
4814
|
EMPTY_UINT8_ARRAY;
|
|
4706
4815
|
const endOfDirectoryLocatorView = getDataView(endOfDirectoryLocatorArray);
|
|
4707
4816
|
if (endOfDirectoryLocatorArray.length == ZIP64_END_OF_CENTRAL_DIR_LOCATOR_LENGTH &&
|
|
4708
|
-
getUint32(endOfDirectoryLocatorView, 0) == ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIGNATURE) {
|
|
4709
|
-
directoryDataOffset = getDiskOffset$1(reader, getUint32(endOfDirectoryLocatorView, 4)) + getBigUint64(endOfDirectoryLocatorView, 8);
|
|
4817
|
+
getUint32$1(endOfDirectoryLocatorView, 0) == ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIGNATURE) {
|
|
4818
|
+
directoryDataOffset = getDiskOffset$1(reader, getUint32$1(endOfDirectoryLocatorView, 4)) + getBigUint64(endOfDirectoryLocatorView, 8);
|
|
4710
4819
|
let endOfDirectoryArray = await readUint8Array(reader, directoryDataOffset, ZIP64_END_OF_CENTRAL_DIR_LENGTH);
|
|
4711
4820
|
let endOfDirectoryView = getDataView(endOfDirectoryArray);
|
|
4712
4821
|
const expectedDirectoryDataOffset = endOfDirectoryInfo.offset - ZIP64_END_OF_CENTRAL_DIR_LOCATOR_LENGTH - ZIP64_END_OF_CENTRAL_DIR_LENGTH;
|
|
4713
|
-
if ((endOfDirectoryArray.length < ZIP64_END_OF_CENTRAL_DIR_LENGTH || getUint32(endOfDirectoryView, 0) != ZIP64_END_OF_CENTRAL_DIR_SIGNATURE) &&
|
|
4822
|
+
if ((endOfDirectoryArray.length < ZIP64_END_OF_CENTRAL_DIR_LENGTH || getUint32$1(endOfDirectoryView, 0) != ZIP64_END_OF_CENTRAL_DIR_SIGNATURE) &&
|
|
4714
4823
|
directoryDataOffset != expectedDirectoryDataOffset && expectedDirectoryDataOffset >= 0) {
|
|
4715
4824
|
const originalDirectoryDataOffset = directoryDataOffset;
|
|
4716
4825
|
directoryDataOffset = expectedDirectoryDataOffset;
|
|
@@ -4720,7 +4829,7 @@
|
|
|
4720
4829
|
endOfDirectoryArray = await readUint8Array(reader, directoryDataOffset, ZIP64_END_OF_CENTRAL_DIR_LENGTH);
|
|
4721
4830
|
endOfDirectoryView = getDataView(endOfDirectoryArray);
|
|
4722
4831
|
}
|
|
4723
|
-
if (endOfDirectoryArray.length < ZIP64_END_OF_CENTRAL_DIR_LENGTH || getUint32(endOfDirectoryView, 0) != ZIP64_END_OF_CENTRAL_DIR_SIGNATURE) {
|
|
4832
|
+
if (endOfDirectoryArray.length < ZIP64_END_OF_CENTRAL_DIR_LENGTH || getUint32$1(endOfDirectoryView, 0) != ZIP64_END_OF_CENTRAL_DIR_SIGNATURE) {
|
|
4724
4833
|
throw new Error(ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND);
|
|
4725
4834
|
}
|
|
4726
4835
|
zip64EndOfDirectory = true;
|
|
@@ -4735,13 +4844,13 @@
|
|
|
4735
4844
|
}
|
|
4736
4845
|
}
|
|
4737
4846
|
if (lastDiskNumber == MAX_16_BITS) {
|
|
4738
|
-
lastDiskNumber = getUint32(endOfDirectoryView, 16);
|
|
4739
|
-
} else if (checkAmbiguity && lastDiskNumber != getUint32(endOfDirectoryView, 16)) {
|
|
4847
|
+
lastDiskNumber = getUint32$1(endOfDirectoryView, 16);
|
|
4848
|
+
} else if (checkAmbiguity && lastDiskNumber != getUint32$1(endOfDirectoryView, 16)) {
|
|
4740
4849
|
throwAmbiguousArchive("mismatched zip64 end of central directory record");
|
|
4741
4850
|
}
|
|
4742
4851
|
if (diskNumber == MAX_16_BITS) {
|
|
4743
|
-
diskNumber = getUint32(endOfDirectoryView, 20);
|
|
4744
|
-
} else if (checkAmbiguity && diskNumber != getUint32(endOfDirectoryView, 20)) {
|
|
4852
|
+
diskNumber = getUint32$1(endOfDirectoryView, 20);
|
|
4853
|
+
} else if (checkAmbiguity && diskNumber != getUint32$1(endOfDirectoryView, 20)) {
|
|
4745
4854
|
throwAmbiguousArchive("mismatched zip64 end of central directory record");
|
|
4746
4855
|
}
|
|
4747
4856
|
if (filesLength == MAX_16_BITS) {
|
|
@@ -4779,11 +4888,11 @@
|
|
|
4779
4888
|
}
|
|
4780
4889
|
const expectedDirectoryDataOffset = centralDirectoryEndOffset - directoryDataLength;
|
|
4781
4890
|
if (directoryDataOffset != expectedDirectoryDataOffset && diskNumber == lastDiskNumber) {
|
|
4782
|
-
const storedPointsAtDirectory = getUint32(directoryView, offset) == CENTRAL_FILE_HEADER_SIGNATURE;
|
|
4891
|
+
const storedPointsAtDirectory = getUint32$1(directoryView, offset) == CENTRAL_FILE_HEADER_SIGNATURE;
|
|
4783
4892
|
let reconcile = !storedPointsAtDirectory;
|
|
4784
4893
|
if (!reconcile && expectedDirectoryDataOffset >= 0 && expectedDirectoryDataOffset + 4 <= reader.size) {
|
|
4785
4894
|
const expectedSignatureArray = await readUint8Array(reader, expectedDirectoryDataOffset, 4);
|
|
4786
|
-
reconcile = getUint32(getDataView(expectedSignatureArray), 0) == CENTRAL_FILE_HEADER_SIGNATURE;
|
|
4895
|
+
reconcile = getUint32$1(getDataView(expectedSignatureArray), 0) == CENTRAL_FILE_HEADER_SIGNATURE;
|
|
4787
4896
|
}
|
|
4788
4897
|
if (reconcile) {
|
|
4789
4898
|
const originalDirectoryDataOffset = directoryDataOffset;
|
|
@@ -4807,10 +4916,10 @@
|
|
|
4807
4916
|
}
|
|
4808
4917
|
zipReader.directoryOffset = directoryDataOffset;
|
|
4809
4918
|
zipReader.directoryLength = declaredDirectoryDataLength;
|
|
4810
|
-
const decryptCentralDirectory =
|
|
4919
|
+
const decryptCentralDirectory = getFunctionOptionValue$1(zipReader, options, OPTION_DECRYPT_CENTRAL_DIRECTORY);
|
|
4811
4920
|
let decryptedDirectory;
|
|
4812
4921
|
if (decryptCentralDirectory && filesLength && directoryArray.length >= 4 &&
|
|
4813
|
-
getUint32(directoryView, 0) != CENTRAL_FILE_HEADER_SIGNATURE &&
|
|
4922
|
+
getUint32$1(directoryView, 0) != CENTRAL_FILE_HEADER_SIGNATURE &&
|
|
4814
4923
|
(zip64EndOfDirectoryVersion2 || detectEncryptedCentralDirectory(directoryView))) {
|
|
4815
4924
|
directoryArray = await decryptCentralDirectory(directoryArray, directoryEncryptionInfo);
|
|
4816
4925
|
directoryView = getDataView(directoryArray);
|
|
@@ -4823,8 +4932,8 @@
|
|
|
4823
4932
|
const filenames = checkAmbiguity ? new Set() : UNDEFINED_VALUE;
|
|
4824
4933
|
let duplicateFilename;
|
|
4825
4934
|
for (let indexFile = 0; indexFile < filesLength; indexFile++) {
|
|
4826
|
-
const fileEntry = new ZipEntry$1(reader,
|
|
4827
|
-
if (offset + CENTRAL_FILE_HEADER_LENGTH > directoryArray.length || getUint32(directoryView, offset) != CENTRAL_FILE_HEADER_SIGNATURE) {
|
|
4935
|
+
const fileEntry = new ZipEntry$1(reader, zipReader.options);
|
|
4936
|
+
if (offset + CENTRAL_FILE_HEADER_LENGTH > directoryArray.length || getUint32$1(directoryView, offset) != CENTRAL_FILE_HEADER_SIGNATURE) {
|
|
4828
4937
|
if (indexFile == 0 && !decryptedDirectory && (zip64EndOfDirectoryVersion2 || detectEncryptedCentralDirectory(directoryView))) {
|
|
4829
4938
|
throw new Error(ERR_ENCRYPTED_CENTRAL_DIRECTORY);
|
|
4830
4939
|
}
|
|
@@ -4835,16 +4944,16 @@
|
|
|
4835
4944
|
const filenameOffset = offset + CENTRAL_FILE_HEADER_LENGTH;
|
|
4836
4945
|
const extraFieldOffset = filenameOffset + fileEntry.filenameLength;
|
|
4837
4946
|
const commentOffset = extraFieldOffset + fileEntry.extraFieldLength;
|
|
4838
|
-
const versionMadeBy = getUint16(directoryView, offset + 4);
|
|
4947
|
+
const versionMadeBy = getUint16$1(directoryView, offset + 4);
|
|
4839
4948
|
const msDosCompatible = versionMadeBy >> 8 == 0;
|
|
4840
4949
|
const unixCompatible = versionMadeBy >> 8 == 3;
|
|
4841
4950
|
const rawFilename = directoryArray.subarray(filenameOffset, extraFieldOffset);
|
|
4842
|
-
const commentLength = getUint16(directoryView, offset + 32);
|
|
4951
|
+
const commentLength = getUint16$1(directoryView, offset + 32);
|
|
4843
4952
|
const endOffset = commentOffset + commentLength;
|
|
4844
4953
|
const rawComment = directoryArray.subarray(commentOffset, endOffset);
|
|
4845
4954
|
const filenameUTF8 = languageEncodingFlag;
|
|
4846
4955
|
const commentUTF8 = languageEncodingFlag;
|
|
4847
|
-
const externalFileAttributes = getUint32(directoryView, offset + 38);
|
|
4956
|
+
const externalFileAttributes = getUint32$1(directoryView, offset + 38);
|
|
4848
4957
|
const msdosAttributesRaw = externalFileAttributes & MAX_8_BITS;
|
|
4849
4958
|
const msdosAttributes = {
|
|
4850
4959
|
readOnly: Boolean(msdosAttributesRaw & FILE_ATTR_MSDOS_READONLY_MASK),
|
|
@@ -4853,8 +4962,8 @@
|
|
|
4853
4962
|
directory: Boolean(msdosAttributesRaw & FILE_ATTR_MSDOS_DIR_MASK),
|
|
4854
4963
|
archive: Boolean(msdosAttributesRaw & FILE_ATTR_MSDOS_ARCHIVE_MASK)
|
|
4855
4964
|
};
|
|
4856
|
-
const offsetFileEntry = getUint32(directoryView, offset + 42);
|
|
4857
|
-
const decode =
|
|
4965
|
+
const offsetFileEntry = getUint32$1(directoryView, offset + 42);
|
|
4966
|
+
const decode = getFunctionOptionValue$1(zipReader, options, OPTION_DECODE_TEXT) || decodeText;
|
|
4858
4967
|
const rawFilenameEncoding = filenameUTF8 ? CHARSET_UTF8 : filenameEncoding || CHARSET_CP437;
|
|
4859
4968
|
const rawCommentEncoding = commentUTF8 ? CHARSET_UTF8 : commentEncoding || CHARSET_CP437;
|
|
4860
4969
|
let filename = decode(rawFilename, rawFilenameEncoding, TEXT_TYPE_FILENAME);
|
|
@@ -4880,12 +4989,13 @@
|
|
|
4880
4989
|
index: indexFile,
|
|
4881
4990
|
versionMadeBy,
|
|
4882
4991
|
msDosCompatible,
|
|
4992
|
+
zip64: false,
|
|
4883
4993
|
compressedSize: 0,
|
|
4884
4994
|
uncompressedSize: 0,
|
|
4885
4995
|
commentLength,
|
|
4886
4996
|
offset: offsetFileEntry,
|
|
4887
|
-
diskNumberStart: getUint16(directoryView, offset + 34),
|
|
4888
|
-
internalFileAttributes: getUint16(directoryView, offset + 36),
|
|
4997
|
+
diskNumberStart: getUint16$1(directoryView, offset + 34),
|
|
4998
|
+
internalFileAttributes: getUint16$1(directoryView, offset + 36),
|
|
4889
4999
|
externalFileAttributes,
|
|
4890
5000
|
msdosAttributesRaw,
|
|
4891
5001
|
msdosAttributes,
|
|
@@ -4953,8 +5063,8 @@
|
|
|
4953
5063
|
yield entry;
|
|
4954
5064
|
}
|
|
4955
5065
|
let offsetAfterSignature = offset;
|
|
4956
|
-
if (offset + 6 <= directoryArray.length && getUint32(directoryView, offset) == DIGITAL_SIGNATURE_RECORD_SIGNATURE) {
|
|
4957
|
-
const signatureDataLength = getUint16(directoryView, offset + 4);
|
|
5066
|
+
if (offset + 6 <= directoryArray.length && getUint32$1(directoryView, offset) == DIGITAL_SIGNATURE_RECORD_SIGNATURE) {
|
|
5067
|
+
const signatureDataLength = getUint16$1(directoryView, offset + 4);
|
|
4958
5068
|
if (offset + 6 + signatureDataLength <= directoryArray.length) {
|
|
4959
5069
|
zipReader.digitalSignature = directoryArray.subarray(offset + 6, offset + 6 + signatureDataLength);
|
|
4960
5070
|
offsetAfterSignature = offset + 6 + signatureDataLength;
|
|
@@ -4966,13 +5076,17 @@
|
|
|
4966
5076
|
if (duplicateFilename) {
|
|
4967
5077
|
throwAmbiguousArchive("duplicate filename");
|
|
4968
5078
|
}
|
|
4969
|
-
if (checkAmbiguity && (prependedDataLength || (filesLength && startOffset > 0))) {
|
|
4970
|
-
throwAmbiguousArchive("prepended data");
|
|
4971
|
-
}
|
|
4972
5079
|
const extractPrependedData = getOptionValue$1(zipReader, options, OPTION_EXTRACT_PREPENDED_DATA);
|
|
4973
5080
|
const extractAppendedData = getOptionValue$1(zipReader, options, OPTION_EXTRACT_APPENDED_DATA);
|
|
5081
|
+
const splitZipSignatureLength = (checkAmbiguity || extractPrependedData) && filesLength &&
|
|
5082
|
+
startOffset == SPLIT_ZIP_FILE_SIGNATURE_LENGTH && await startsWithSplitZipMarker(reader) ? SPLIT_ZIP_FILE_SIGNATURE_LENGTH : 0;
|
|
5083
|
+
if (checkAmbiguity && (prependedDataLength || (filesLength && startOffset > splitZipSignatureLength))) {
|
|
5084
|
+
throwAmbiguousArchive("prepended data");
|
|
5085
|
+
}
|
|
4974
5086
|
if (extractPrependedData) {
|
|
4975
|
-
zipReader.prependedData = startOffset >
|
|
5087
|
+
zipReader.prependedData = startOffset > splitZipSignatureLength ?
|
|
5088
|
+
await readUint8Array(reader, splitZipSignatureLength, startOffset - splitZipSignatureLength) :
|
|
5089
|
+
EMPTY_UINT8_ARRAY;
|
|
4976
5090
|
}
|
|
4977
5091
|
zipReader.comment = commentLength ? await readUint8Array(reader, commentOffset + END_OF_CENTRAL_DIR_LENGTH, commentLength) : EMPTY_UINT8_ARRAY;
|
|
4978
5092
|
if (extractAppendedData) {
|
|
@@ -5039,16 +5153,16 @@
|
|
|
5039
5153
|
|
|
5040
5154
|
let ZipEntry$1 = class ZipEntry {
|
|
5041
5155
|
|
|
5042
|
-
constructor(reader,
|
|
5156
|
+
constructor(reader, options) {
|
|
5043
5157
|
Object.assign(this, {
|
|
5044
5158
|
reader,
|
|
5045
|
-
config,
|
|
5046
5159
|
options
|
|
5047
5160
|
});
|
|
5048
5161
|
}
|
|
5049
5162
|
|
|
5050
5163
|
async getData(writer, fileEntry, readRanges, options = {}) {
|
|
5051
5164
|
const zipEntry = this;
|
|
5165
|
+
const config = getConfiguration();
|
|
5052
5166
|
const {
|
|
5053
5167
|
reader,
|
|
5054
5168
|
index,
|
|
@@ -5057,7 +5171,6 @@
|
|
|
5057
5171
|
extraFieldAES,
|
|
5058
5172
|
extraFieldZip64,
|
|
5059
5173
|
compressionMethod,
|
|
5060
|
-
config,
|
|
5061
5174
|
bitFlag,
|
|
5062
5175
|
rawBitFlag,
|
|
5063
5176
|
crc32,
|
|
@@ -5075,6 +5188,7 @@
|
|
|
5075
5188
|
let password = getOptionValue$1(zipEntry, options, OPTION_PASSWORD);
|
|
5076
5189
|
let rawPassword = getOptionValue$1(zipEntry, options, OPTION_RAW_PASSWORD);
|
|
5077
5190
|
const passThrough = getOptionValue$1(zipEntry, options, OPTION_PASS_THROUGH);
|
|
5191
|
+
checkPasswordOption(password, rawPassword);
|
|
5078
5192
|
password = password && password.length && password;
|
|
5079
5193
|
rawPassword = rawPassword && rawPassword.length && rawPassword;
|
|
5080
5194
|
if (extraFieldAES) {
|
|
@@ -5082,7 +5196,7 @@
|
|
|
5082
5196
|
throw new Error(ERR_UNSUPPORTED_COMPRESSION$1);
|
|
5083
5197
|
}
|
|
5084
5198
|
}
|
|
5085
|
-
if (dataArray.length < HEADER_SIZE || getUint32(dataView, 0) != LOCAL_FILE_HEADER_SIGNATURE) {
|
|
5199
|
+
if (dataArray.length < HEADER_SIZE || getUint32$1(dataView, 0) != LOCAL_FILE_HEADER_SIGNATURE) {
|
|
5086
5200
|
throw new Error(ERR_LOCAL_FILE_HEADER_NOT_FOUND);
|
|
5087
5201
|
}
|
|
5088
5202
|
readCommonHeader(localDirectory, dataView, 4);
|
|
@@ -5090,9 +5204,12 @@
|
|
|
5090
5204
|
extraFieldLength,
|
|
5091
5205
|
filenameLength
|
|
5092
5206
|
} = localDirectory;
|
|
5093
|
-
const
|
|
5207
|
+
const checkLocalDirectoryOption = getOptionValue$1(zipEntry, options, OPTION_CHECK_LOCAL_DIRECTORY);
|
|
5208
|
+
const entryStrictness = getStrictness(options, zipEntry.options);
|
|
5209
|
+
const checkLocalDirectory = getCheckLocalDirectory(checkLocalDirectoryOption, entryStrictness);
|
|
5210
|
+
const checkLocalFilename = getCheckLocalFilename(checkLocalDirectoryOption, entryStrictness);
|
|
5094
5211
|
let rawLocalFilename = EMPTY_UINT8_ARRAY;
|
|
5095
|
-
if (
|
|
5212
|
+
if (checkLocalFilename && (filenameLength || extraFieldLength)) {
|
|
5096
5213
|
const trailingDataArray = await readUint8Array(reader, localHeaderOffset + HEADER_SIZE, filenameLength + extraFieldLength);
|
|
5097
5214
|
rawLocalFilename = trailingDataArray.subarray(0, filenameLength);
|
|
5098
5215
|
localDirectory.rawExtraField = trailingDataArray.subarray(filenameLength);
|
|
@@ -5101,17 +5218,26 @@
|
|
|
5101
5218
|
await readUint8Array(reader, localHeaderOffset + HEADER_SIZE + filenameLength, extraFieldLength) :
|
|
5102
5219
|
EMPTY_UINT8_ARRAY;
|
|
5103
5220
|
}
|
|
5221
|
+
if (checkLocalFilename) {
|
|
5222
|
+
localDirectory.rawFilename = rawLocalFilename;
|
|
5223
|
+
}
|
|
5104
5224
|
readCommonFooter(zipEntry, localDirectory, dataView, 4, true);
|
|
5105
|
-
if (
|
|
5106
|
-
|
|
5225
|
+
if (checkLocalDirectory) {
|
|
5226
|
+
validateLocalDirectory(zipEntry, localDirectory, rawLocalFilename, checkLocalFilename);
|
|
5107
5227
|
}
|
|
5108
|
-
const { lastAccessDate, creationDate } = localDirectory;
|
|
5228
|
+
const { lastAccessDate, creationDate, uid, gid } = localDirectory;
|
|
5109
5229
|
if (lastAccessDate) {
|
|
5110
5230
|
fileEntry.lastAccessDate = lastAccessDate;
|
|
5111
5231
|
}
|
|
5112
5232
|
if (creationDate) {
|
|
5113
5233
|
fileEntry.creationDate = creationDate;
|
|
5114
5234
|
}
|
|
5235
|
+
if (uid !== UNDEFINED_VALUE && fileEntry.uid === UNDEFINED_VALUE) {
|
|
5236
|
+
fileEntry.uid = uid;
|
|
5237
|
+
}
|
|
5238
|
+
if (gid !== UNDEFINED_VALUE && fileEntry.gid === UNDEFINED_VALUE) {
|
|
5239
|
+
fileEntry.gid = gid;
|
|
5240
|
+
}
|
|
5115
5241
|
const encrypted = zipEntry.encrypted && localDirectory.encrypted && !passThrough;
|
|
5116
5242
|
const zipCrypto = encrypted && !extraFieldAES;
|
|
5117
5243
|
if (!passThrough) {
|
|
@@ -5132,9 +5258,12 @@
|
|
|
5132
5258
|
}
|
|
5133
5259
|
}
|
|
5134
5260
|
const dataOffset = localHeaderOffset + HEADER_SIZE + filenameLength + extraFieldLength;
|
|
5261
|
+
if (dataOffset + compressedSize > reader.size) {
|
|
5262
|
+
throw new Error(ERR_ENTRY_DATA_OUT_OF_BOUNDS);
|
|
5263
|
+
}
|
|
5135
5264
|
const size = compressedSize;
|
|
5136
5265
|
const readable = toCompatibleReadable(reader.createReadable({ offset: dataOffset, size }));
|
|
5137
|
-
const signal = getOptionValue$1(zipEntry, options, OPTION_SIGNAL);
|
|
5266
|
+
const signal = checkSignalOption(getOptionValue$1(zipEntry, options, OPTION_SIGNAL));
|
|
5138
5267
|
const checkPasswordOnly = getOptionValue$1(zipEntry, options, OPTION_CHECK_PASSWORD_ONLY);
|
|
5139
5268
|
let checkOverlappingEntry = getOptionValue$1(zipEntry, options, OPTION_CHECK_OVERLAPPING_ENTRY);
|
|
5140
5269
|
const checkOverlappingEntryOnly = getOptionValue$1(zipEntry, options, OPTION_CHECK_OVERLAPPING_ENTRY_ONLY);
|
|
@@ -5142,6 +5271,8 @@
|
|
|
5142
5271
|
checkOverlappingEntry = true;
|
|
5143
5272
|
}
|
|
5144
5273
|
const { onstart, onprogress, onend } = options;
|
|
5274
|
+
const compressed = compressionMethod != COMPRESSION_METHOD_STORE && !passThrough;
|
|
5275
|
+
const outputSize = passThrough ? compressedSize : uncompressedSize;
|
|
5145
5276
|
const deflate64 = compressionMethod == COMPRESSION_METHOD_DEFLATE_64;
|
|
5146
5277
|
let useCompressionStream = getOptionValue$1(zipEntry, options, OPTION_USE_COMPRESSION_STREAM);
|
|
5147
5278
|
if (deflate64) {
|
|
@@ -5162,9 +5293,9 @@
|
|
|
5162
5293
|
checkCrc32,
|
|
5163
5294
|
checkAuthenticationCode: getOptionValue$1(zipEntry, options, OPTION_CHECK_AUTHENTICATION_CODE),
|
|
5164
5295
|
passwordVerification: zipCrypto && (dataDescriptor ? ((rawLastModDate >>> 8) & MAX_8_BITS) : ((crc32 >>> 24) & MAX_8_BITS)),
|
|
5165
|
-
outputSize
|
|
5296
|
+
outputSize,
|
|
5166
5297
|
crc32,
|
|
5167
|
-
compressed
|
|
5298
|
+
compressed,
|
|
5168
5299
|
encrypted,
|
|
5169
5300
|
useWebWorkers: getOptionValue$1(zipEntry, options, OPTION_USE_WEB_WORKERS),
|
|
5170
5301
|
useCompressionStream,
|
|
@@ -5201,11 +5332,11 @@
|
|
|
5201
5332
|
writer = new WritableStream();
|
|
5202
5333
|
}
|
|
5203
5334
|
writer = new GenericWriter(writer);
|
|
5204
|
-
await initStream(writer,
|
|
5335
|
+
await initStream(writer, getDecodableOutputSize(outputSize, compressedSize, compressed));
|
|
5205
5336
|
({ writable } = writer);
|
|
5206
|
-
const { outputSize } = await runWorker({ readable, writable }, workerOptions);
|
|
5207
|
-
writer.size +=
|
|
5208
|
-
if (
|
|
5337
|
+
const { outputSize: writtenSize } = await runWorker({ readable, writable }, workerOptions);
|
|
5338
|
+
writer.size += writtenSize;
|
|
5339
|
+
if (writtenSize != outputSize) {
|
|
5209
5340
|
throw new Error(ERR_INVALID_UNCOMPRESSED_SIZE);
|
|
5210
5341
|
}
|
|
5211
5342
|
}
|
|
@@ -5239,7 +5370,7 @@
|
|
|
5239
5370
|
function detectEncryptedCentralDirectory(directoryView) {
|
|
5240
5371
|
const maxOffset = Math.min(directoryView.byteLength, 1024) - 3;
|
|
5241
5372
|
for (let offset = 0; offset < maxOffset; offset++) {
|
|
5242
|
-
if (getUint32(directoryView, offset) == ARCHIVE_EXTRA_DATA_SIGNATURE) {
|
|
5373
|
+
if (getUint32$1(directoryView, offset) == ARCHIVE_EXTRA_DATA_SIGNATURE) {
|
|
5243
5374
|
return true;
|
|
5244
5375
|
}
|
|
5245
5376
|
}
|
|
@@ -5250,15 +5381,15 @@
|
|
|
5250
5381
|
const directoryEncryptionInfo = { rawExtensibleData };
|
|
5251
5382
|
if (rawExtensibleData.length >= 28) {
|
|
5252
5383
|
const extensibleDataView = getDataView(rawExtensibleData);
|
|
5253
|
-
const hashDataLength = getUint16(extensibleDataView, 26);
|
|
5384
|
+
const hashDataLength = getUint16$1(extensibleDataView, 26);
|
|
5254
5385
|
Object.assign(directoryEncryptionInfo, {
|
|
5255
|
-
compressionMethod: getUint16(extensibleDataView, 0),
|
|
5386
|
+
compressionMethod: getUint16$1(extensibleDataView, 0),
|
|
5256
5387
|
compressedSize: Number(getBigUint64(extensibleDataView, 2)),
|
|
5257
5388
|
uncompressedSize: Number(getBigUint64(extensibleDataView, 10)),
|
|
5258
|
-
encryptionAlgorithm: getUint16(extensibleDataView, 18),
|
|
5259
|
-
bitLength: getUint16(extensibleDataView, 20),
|
|
5260
|
-
flags: getUint16(extensibleDataView, 22),
|
|
5261
|
-
hashAlgorithm: getUint16(extensibleDataView, 24),
|
|
5389
|
+
encryptionAlgorithm: getUint16$1(extensibleDataView, 18),
|
|
5390
|
+
bitLength: getUint16$1(extensibleDataView, 20),
|
|
5391
|
+
flags: getUint16$1(extensibleDataView, 22),
|
|
5392
|
+
hashAlgorithm: getUint16$1(extensibleDataView, 24),
|
|
5262
5393
|
hashData: rawExtensibleData.subarray(28, 28 + hashDataLength)
|
|
5263
5394
|
});
|
|
5264
5395
|
}
|
|
@@ -5266,12 +5397,12 @@
|
|
|
5266
5397
|
}
|
|
5267
5398
|
|
|
5268
5399
|
function readCommonHeader(directory, dataView, offset) {
|
|
5269
|
-
const rawBitFlag = directory.rawBitFlag = getUint16(dataView, offset + 2);
|
|
5400
|
+
const rawBitFlag = directory.rawBitFlag = getUint16$1(dataView, offset + 2);
|
|
5270
5401
|
const encrypted = (rawBitFlag & BITFLAG_ENCRYPTED) == BITFLAG_ENCRYPTED;
|
|
5271
|
-
const rawLastModDate = getUint32(dataView, offset + 6);
|
|
5402
|
+
const rawLastModDate = getUint32$1(dataView, offset + 6);
|
|
5272
5403
|
Object.assign(directory, {
|
|
5273
5404
|
encrypted,
|
|
5274
|
-
version: getUint16(dataView, offset),
|
|
5405
|
+
version: getUint16$1(dataView, offset),
|
|
5275
5406
|
bitFlag: {
|
|
5276
5407
|
level: (rawBitFlag & BITFLAG_LEVEL) >> 1,
|
|
5277
5408
|
dataDescriptor: (rawBitFlag & BITFLAG_DATA_DESCRIPTOR) == BITFLAG_DATA_DESCRIPTOR,
|
|
@@ -5279,8 +5410,8 @@
|
|
|
5279
5410
|
},
|
|
5280
5411
|
rawLastModDate,
|
|
5281
5412
|
lastModDate: getDate(rawLastModDate),
|
|
5282
|
-
filenameLength: getUint16(dataView, offset + 22),
|
|
5283
|
-
extraFieldLength: getUint16(dataView, offset + 24)
|
|
5413
|
+
filenameLength: getUint16$1(dataView, offset + 22),
|
|
5414
|
+
extraFieldLength: getUint16$1(dataView, offset + 24)
|
|
5284
5415
|
});
|
|
5285
5416
|
}
|
|
5286
5417
|
|
|
@@ -5291,8 +5422,8 @@
|
|
|
5291
5422
|
let offsetExtraField = 0;
|
|
5292
5423
|
try {
|
|
5293
5424
|
while (offsetExtraField < rawExtraField.length) {
|
|
5294
|
-
const type = getUint16(rawExtraFieldView, offsetExtraField);
|
|
5295
|
-
const size = getUint16(rawExtraFieldView, offsetExtraField + 2);
|
|
5425
|
+
const type = getUint16$1(rawExtraFieldView, offsetExtraField);
|
|
5426
|
+
const size = getUint16$1(rawExtraFieldView, offsetExtraField + 2);
|
|
5296
5427
|
extraField.set(type, {
|
|
5297
5428
|
type,
|
|
5298
5429
|
data: rawExtraField.slice(offsetExtraField + 4, offsetExtraField + 4 + size)
|
|
@@ -5302,12 +5433,12 @@
|
|
|
5302
5433
|
} catch {
|
|
5303
5434
|
// ignored
|
|
5304
5435
|
}
|
|
5305
|
-
const compressionMethod = getUint16(dataView, offset + 4);
|
|
5436
|
+
const compressionMethod = getUint16$1(dataView, offset + 4);
|
|
5306
5437
|
Object.assign(directory, {
|
|
5307
|
-
signature: getUint32(dataView, offset + HEADER_OFFSET_SIGNATURE),
|
|
5308
|
-
crc32: getUint32(dataView, offset + HEADER_OFFSET_SIGNATURE),
|
|
5309
|
-
compressedSize: getUint32(dataView, offset + HEADER_OFFSET_COMPRESSED_SIZE),
|
|
5310
|
-
uncompressedSize: getUint32(dataView, offset + HEADER_OFFSET_UNCOMPRESSED_SIZE)
|
|
5438
|
+
signature: getUint32$1(dataView, offset + HEADER_OFFSET_SIGNATURE),
|
|
5439
|
+
crc32: getUint32$1(dataView, offset + HEADER_OFFSET_SIGNATURE),
|
|
5440
|
+
compressedSize: getUint32$1(dataView, offset + HEADER_OFFSET_COMPRESSED_SIZE),
|
|
5441
|
+
uncompressedSize: getUint32$1(dataView, offset + HEADER_OFFSET_UNCOMPRESSED_SIZE)
|
|
5311
5442
|
});
|
|
5312
5443
|
const extraFieldZip64 = extraField.get(EXTRAFIELD_TYPE_ZIP64);
|
|
5313
5444
|
if (extraFieldZip64) {
|
|
@@ -5347,10 +5478,12 @@
|
|
|
5347
5478
|
directory.extraFieldNTFS = extraFieldNTFS;
|
|
5348
5479
|
}
|
|
5349
5480
|
const extraFieldUnix = extraField.get(EXTRAFIELD_TYPE_UNIX);
|
|
5481
|
+
let unixIdsRead;
|
|
5350
5482
|
if (extraFieldUnix) {
|
|
5351
|
-
readExtraFieldUnix(extraFieldUnix, directory, false);
|
|
5483
|
+
unixIdsRead = readExtraFieldUnix(extraFieldUnix, directory, false);
|
|
5352
5484
|
directory.extraFieldUnix = extraFieldUnix;
|
|
5353
|
-
}
|
|
5485
|
+
}
|
|
5486
|
+
if (!unixIdsRead) {
|
|
5354
5487
|
const extraFieldInfoZip = extraField.get(EXTRAFIELD_TYPE_INFOZIP);
|
|
5355
5488
|
if (extraFieldInfoZip) {
|
|
5356
5489
|
readExtraFieldUnix(extraFieldInfoZip, directory, true);
|
|
@@ -5394,11 +5527,11 @@
|
|
|
5394
5527
|
computedCrc32.append(fileEntry[rawPropertyName]);
|
|
5395
5528
|
const computedCrc32View = getDataView(new Uint8Array(4));
|
|
5396
5529
|
computedCrc32View.setUint32(0, computedCrc32.get(), true);
|
|
5397
|
-
const nameCrc32 = getUint32(extraFieldView, 1);
|
|
5530
|
+
const nameCrc32 = getUint32$1(extraFieldView, 1);
|
|
5398
5531
|
Object.assign(extraFieldUnicode, {
|
|
5399
5532
|
version: getUint8(extraFieldView, 0),
|
|
5400
5533
|
[propertyName]: decodeText(extraFieldUnicode.data.subarray(5)),
|
|
5401
|
-
valid: !fileEntry.bitFlag.languageEncodingFlag && nameCrc32 == getUint32(computedCrc32View, 0)
|
|
5534
|
+
valid: !fileEntry.bitFlag.languageEncodingFlag && nameCrc32 == getUint32$1(computedCrc32View, 0)
|
|
5402
5535
|
});
|
|
5403
5536
|
if (extraFieldUnicode.valid) {
|
|
5404
5537
|
directory[propertyName] = extraFieldUnicode[propertyName];
|
|
@@ -5414,7 +5547,7 @@
|
|
|
5414
5547
|
vendorId: getUint8(extraFieldView, 2),
|
|
5415
5548
|
strength,
|
|
5416
5549
|
originalCompressionMethod: compressionMethod,
|
|
5417
|
-
compressionMethod: getUint16(extraFieldView, 5)
|
|
5550
|
+
compressionMethod: getUint16$1(extraFieldView, 5)
|
|
5418
5551
|
});
|
|
5419
5552
|
directory.compressionMethod = extraFieldAES.compressionMethod;
|
|
5420
5553
|
if (extraFieldAES.vendorVersion != VENDOR_VERSION_AE_1$1) {
|
|
@@ -5428,8 +5561,8 @@
|
|
|
5428
5561
|
let tag1Data;
|
|
5429
5562
|
try {
|
|
5430
5563
|
while (offsetExtraField < extraFieldNTFS.data.length && !tag1Data) {
|
|
5431
|
-
const tagValue = getUint16(extraFieldView, offsetExtraField);
|
|
5432
|
-
const attributeSize = getUint16(extraFieldView, offsetExtraField + 2);
|
|
5564
|
+
const tagValue = getUint16$1(extraFieldView, offsetExtraField);
|
|
5565
|
+
const attributeSize = getUint16$1(extraFieldView, offsetExtraField + 2);
|
|
5433
5566
|
if (tagValue == EXTRAFIELD_TYPE_NTFS_TAG1) {
|
|
5434
5567
|
tag1Data = extraFieldNTFS.data.slice(offsetExtraField + 4, offsetExtraField + 4 + attributeSize);
|
|
5435
5568
|
}
|
|
@@ -5453,7 +5586,7 @@
|
|
|
5453
5586
|
const creationDate = getDateNTFS(rawCreationDate);
|
|
5454
5587
|
const extraFieldData = { lastModDate, lastAccessDate, creationDate };
|
|
5455
5588
|
Object.assign(extraFieldNTFS, extraFieldData);
|
|
5456
|
-
Object.assign(directory, extraFieldData);
|
|
5589
|
+
Object.assign(directory, extraFieldData, { rawLastAccessDate, rawCreationDate });
|
|
5457
5590
|
}
|
|
5458
5591
|
}
|
|
5459
5592
|
|
|
@@ -5462,12 +5595,12 @@
|
|
|
5462
5595
|
return;
|
|
5463
5596
|
}
|
|
5464
5597
|
const extraFieldView = getDataView(extraField.data);
|
|
5465
|
-
const lastAccessDate = new Date((getUint32(extraFieldView, 0) | 0) * 1000);
|
|
5466
|
-
const lastModDate = new Date((getUint32(extraFieldView, 4) | 0) * 1000);
|
|
5598
|
+
const lastAccessDate = new Date((getUint32$1(extraFieldView, 0) | 0) * 1000);
|
|
5599
|
+
const lastModDate = new Date((getUint32$1(extraFieldView, 4) | 0) * 1000);
|
|
5467
5600
|
const extraFieldData = { lastAccessDate, lastModDate };
|
|
5468
5601
|
if (extraField.data.length >= 12) {
|
|
5469
|
-
extraFieldData.uid = getUint16(extraFieldView, 8);
|
|
5470
|
-
extraFieldData.gid = getUint16(extraFieldView, 10);
|
|
5602
|
+
extraFieldData.uid = getUint16$1(extraFieldView, 8);
|
|
5603
|
+
extraFieldData.gid = getUint16$1(extraFieldView, 10);
|
|
5471
5604
|
}
|
|
5472
5605
|
Object.assign(extraField, extraFieldData);
|
|
5473
5606
|
Object.assign(directory, extraFieldData);
|
|
@@ -5487,8 +5620,8 @@
|
|
|
5487
5620
|
gid = unpackUnixId(extraField.data.subarray(offset, offset + gidSize));
|
|
5488
5621
|
Object.assign(extraField, { version, uid, gid });
|
|
5489
5622
|
} else if (extraField.data.length >= 4) {
|
|
5490
|
-
uid = getUint16(view, 0);
|
|
5491
|
-
gid = getUint16(view, 2);
|
|
5623
|
+
uid = getUint16$1(view, 0);
|
|
5624
|
+
gid = getUint16$1(view, 2);
|
|
5492
5625
|
Object.assign(extraField, { uid, gid });
|
|
5493
5626
|
}
|
|
5494
5627
|
if (uid !== UNDEFINED_VALUE) {
|
|
@@ -5497,6 +5630,7 @@
|
|
|
5497
5630
|
if (gid !== UNDEFINED_VALUE) {
|
|
5498
5631
|
directory.gid = gid;
|
|
5499
5632
|
}
|
|
5633
|
+
return uid !== UNDEFINED_VALUE || gid !== UNDEFINED_VALUE;
|
|
5500
5634
|
} catch {
|
|
5501
5635
|
// ignored
|
|
5502
5636
|
}
|
|
@@ -5537,7 +5671,7 @@
|
|
|
5537
5671
|
let offset = 1;
|
|
5538
5672
|
timeProperties.forEach((propertyName, indexProperty) => {
|
|
5539
5673
|
if (extraFieldExtendedTimestamp.data.length >= offset + 4) {
|
|
5540
|
-
const time = getUint32(extraFieldView, offset);
|
|
5674
|
+
const time = getUint32$1(extraFieldView, offset);
|
|
5541
5675
|
directory[propertyName] = extraFieldExtendedTimestamp[propertyName] = new Date((time | 0) * 1000);
|
|
5542
5676
|
const rawPropertyName = timeRawProperties[indexProperty];
|
|
5543
5677
|
extraFieldExtendedTimestamp[rawPropertyName] = time;
|
|
@@ -5569,26 +5703,25 @@
|
|
|
5569
5703
|
}
|
|
5570
5704
|
if (dataDescriptorLength) {
|
|
5571
5705
|
const dataDescriptorArray = await readUint8Array(reader, dataOffset + compressedSize, dataDescriptorLength + DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH);
|
|
5572
|
-
const
|
|
5573
|
-
|
|
5574
|
-
|
|
5575
|
-
|
|
5576
|
-
|
|
5577
|
-
|
|
5578
|
-
if (extraFieldZip64) {
|
|
5579
|
-
readCompressedSize = getBigUint64(getDataView(dataDescriptorArray), 8);
|
|
5580
|
-
readUncompressedSize = getBigUint64(getDataView(dataDescriptorArray), 16);
|
|
5581
|
-
} else {
|
|
5582
|
-
readCompressedSize = getUint32(getDataView(dataDescriptorArray), 8);
|
|
5583
|
-
readUncompressedSize = getUint32(getDataView(dataDescriptorArray), 12);
|
|
5584
|
-
}
|
|
5585
|
-
const matchCrc32 = (fileEntry.encrypted && !fileEntry.zipCrypto) || readCrc32 == crc32;
|
|
5706
|
+
const dataDescriptorView = getDataView(dataDescriptorArray);
|
|
5707
|
+
let signature = dataDescriptorArray.length == dataDescriptorLength + DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH &&
|
|
5708
|
+
getUint32$1(dataDescriptorView, 0) == DATA_DESCRIPTOR_RECORD_SIGNATURE;
|
|
5709
|
+
if (signature) {
|
|
5710
|
+
const signedDataDescriptor = readDataDescriptor(dataDescriptorView, DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH, extraFieldZip64);
|
|
5711
|
+
const matchCrc32 = (fileEntry.encrypted && !fileEntry.zipCrypto) || signedDataDescriptor.crc32 == crc32;
|
|
5586
5712
|
if (matchCrc32 &&
|
|
5587
|
-
|
|
5588
|
-
|
|
5713
|
+
signedDataDescriptor.compressedSize == compressedSize &&
|
|
5714
|
+
signedDataDescriptor.uncompressedSize == uncompressedSize) {
|
|
5589
5715
|
dataDescriptorLength += DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH;
|
|
5716
|
+
} else {
|
|
5717
|
+
signature = false;
|
|
5590
5718
|
}
|
|
5591
5719
|
}
|
|
5720
|
+
if (dataDescriptorArray.length >= dataDescriptorLength) {
|
|
5721
|
+
const localDataDescriptor = readDataDescriptor(dataDescriptorView, signature ? DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH : 0, extraFieldZip64);
|
|
5722
|
+
localDataDescriptor.signature = signature;
|
|
5723
|
+
fileEntry.localDirectory.dataDescriptor = localDataDescriptor;
|
|
5724
|
+
}
|
|
5592
5725
|
}
|
|
5593
5726
|
const range = {
|
|
5594
5727
|
start: offset,
|
|
@@ -5605,22 +5738,80 @@
|
|
|
5605
5738
|
readRanges.set(index, range);
|
|
5606
5739
|
}
|
|
5607
5740
|
|
|
5741
|
+
function readDataDescriptor(dataDescriptorView, offset, extraFieldZip64) {
|
|
5742
|
+
const crc32 = getUint32$1(dataDescriptorView, offset);
|
|
5743
|
+
let compressedSize;
|
|
5744
|
+
let uncompressedSize;
|
|
5745
|
+
if (extraFieldZip64) {
|
|
5746
|
+
compressedSize = getBigUint64(dataDescriptorView, offset + 4);
|
|
5747
|
+
uncompressedSize = getBigUint64(dataDescriptorView, offset + 12);
|
|
5748
|
+
} else {
|
|
5749
|
+
compressedSize = getUint32$1(dataDescriptorView, offset + 4);
|
|
5750
|
+
uncompressedSize = getUint32$1(dataDescriptorView, offset + 8);
|
|
5751
|
+
}
|
|
5752
|
+
return { crc32, compressedSize, uncompressedSize };
|
|
5753
|
+
}
|
|
5754
|
+
|
|
5608
5755
|
function getDiskOffset$1(reader, diskNumber) {
|
|
5609
5756
|
return reader.getDiskOffset ? reader.getDiskOffset(diskNumber) : 0;
|
|
5610
5757
|
}
|
|
5611
5758
|
|
|
5759
|
+
async function startsWithSplitZipSignature$1(reader) {
|
|
5760
|
+
return await getFirstSignature(reader) == SPLIT_ZIP_FILE_SIGNATURE;
|
|
5761
|
+
}
|
|
5762
|
+
|
|
5763
|
+
async function startsWithSplitZipMarker(reader) {
|
|
5764
|
+
const signature = await getFirstSignature(reader);
|
|
5765
|
+
return signature == SPLIT_ZIP_FILE_SIGNATURE || signature == TEMPORARY_SPLIT_ZIP_FILE_SIGNATURE;
|
|
5766
|
+
}
|
|
5767
|
+
|
|
5768
|
+
async function getFirstSignature(reader) {
|
|
5769
|
+
const signatureArray = await readUint8Array(reader, 0, SPLIT_ZIP_FILE_SIGNATURE_LENGTH);
|
|
5770
|
+
return getUint32$1(getDataView(signatureArray));
|
|
5771
|
+
}
|
|
5772
|
+
|
|
5612
5773
|
function isStrictnessValue(value) {
|
|
5613
5774
|
return value === STRICTNESS_STRICT || value === STRICTNESS_BALANCED || value === STRICTNESS_TOLERANT;
|
|
5614
5775
|
}
|
|
5615
5776
|
|
|
5616
|
-
function
|
|
5617
|
-
|
|
5618
|
-
|
|
5777
|
+
function getDecodableOutputSize(outputSize, compressedSize, compressed) {
|
|
5778
|
+
return Math.min(outputSize, compressed ? compressedSize * MAX_DEFLATE_EXPANSION_RATIO : compressedSize);
|
|
5779
|
+
}
|
|
5780
|
+
|
|
5781
|
+
function getStrictness(options, inheritedOptions) {
|
|
5782
|
+
return resolveStrictness(options, resolveStrictness(inheritedOptions, STRICTNESS_BALANCED));
|
|
5783
|
+
}
|
|
5784
|
+
|
|
5785
|
+
function resolveStrictness(options, inheritedStrictness) {
|
|
5786
|
+
const strictness = options[OPTION_STRICTNESS];
|
|
5787
|
+
if (strictness !== UNDEFINED_VALUE) {
|
|
5788
|
+
if (!isStrictnessValue(strictness)) {
|
|
5789
|
+
throw new Error(ERR_INVALID_STRICTNESS);
|
|
5790
|
+
}
|
|
5791
|
+
return strictness;
|
|
5792
|
+
}
|
|
5793
|
+
const checkAmbiguity = options[OPTION_CHECK_AMBIGUITY];
|
|
5794
|
+
if (checkAmbiguity === UNDEFINED_VALUE) {
|
|
5795
|
+
return inheritedStrictness;
|
|
5619
5796
|
}
|
|
5620
|
-
if (
|
|
5621
|
-
|
|
5797
|
+
if (checkAmbiguity) {
|
|
5798
|
+
return STRICTNESS_STRICT;
|
|
5622
5799
|
}
|
|
5623
|
-
return
|
|
5800
|
+
return inheritedStrictness == STRICTNESS_TOLERANT ? STRICTNESS_TOLERANT : STRICTNESS_BALANCED;
|
|
5801
|
+
}
|
|
5802
|
+
|
|
5803
|
+
function getCheckLocalDirectory(checkLocalDirectory, strictness) {
|
|
5804
|
+
if (checkLocalDirectory === UNDEFINED_VALUE) {
|
|
5805
|
+
return strictness != STRICTNESS_TOLERANT;
|
|
5806
|
+
}
|
|
5807
|
+
return Boolean(checkLocalDirectory);
|
|
5808
|
+
}
|
|
5809
|
+
|
|
5810
|
+
function getCheckLocalFilename(checkLocalFilename, strictness) {
|
|
5811
|
+
if (checkLocalFilename === UNDEFINED_VALUE) {
|
|
5812
|
+
return strictness == STRICTNESS_STRICT;
|
|
5813
|
+
}
|
|
5814
|
+
return Boolean(checkLocalFilename);
|
|
5624
5815
|
}
|
|
5625
5816
|
|
|
5626
5817
|
function getFilenameValidation(filenameValidation, strictness) {
|
|
@@ -5649,7 +5840,7 @@
|
|
|
5649
5840
|
|
|
5650
5841
|
function getMaxAppendedDataSize(maxAppendedDataSize, strictness) {
|
|
5651
5842
|
if (maxAppendedDataSize !== UNDEFINED_VALUE) {
|
|
5652
|
-
const size = toNumber
|
|
5843
|
+
const size = toNumber(maxAppendedDataSize);
|
|
5653
5844
|
if (typeof size != NUMBER_TYPE || Number.isNaN(size) || size < 0) {
|
|
5654
5845
|
throw new Error(ERR_INVALID_MAX_APPENDED_DATA_SIZE);
|
|
5655
5846
|
}
|
|
@@ -5672,7 +5863,7 @@
|
|
|
5672
5863
|
let plausibleEndOfDirectoryInfo;
|
|
5673
5864
|
let endOfDirectoryReachingEndCount = 0;
|
|
5674
5865
|
for await (const [anchoredView, anchoredOffset, anchoredArray, indexByte, offset] of scanEndOfCentralDirectory(reader, anchoredLength)) {
|
|
5675
|
-
const commentLength = getUint16(anchoredView, indexByte + 20);
|
|
5866
|
+
const commentLength = getUint16$1(anchoredView, indexByte + 20);
|
|
5676
5867
|
if (offset + END_OF_CENTRAL_DIR_LENGTH + commentLength == size) {
|
|
5677
5868
|
const reachability = await getCentralDirectoryReachability(reader, anchoredView, anchoredOffset, indexByte, offset, size, remoteProbeBudget);
|
|
5678
5869
|
if (reachability == CENTRAL_DIRECTORY_REACHABLE) {
|
|
@@ -5723,7 +5914,7 @@
|
|
|
5723
5914
|
const scanArray = await readUint8Array(reader, scanOffset, scanLength);
|
|
5724
5915
|
const scanView = getDataView(scanArray);
|
|
5725
5916
|
for (let indexByte = scanArray.length - END_OF_CENTRAL_DIR_LENGTH; indexByte >= 0; indexByte--) {
|
|
5726
|
-
if (getUint32(scanView, indexByte) == END_OF_CENTRAL_DIR_SIGNATURE) {
|
|
5917
|
+
if (getUint32$1(scanView, indexByte) == END_OF_CENTRAL_DIR_SIGNATURE) {
|
|
5727
5918
|
yield [scanView, scanOffset, scanArray, indexByte, scanOffset + indexByte];
|
|
5728
5919
|
}
|
|
5729
5920
|
}
|
|
@@ -5734,9 +5925,9 @@
|
|
|
5734
5925
|
}
|
|
5735
5926
|
|
|
5736
5927
|
async function getCentralDirectoryReachability(reader, view, anchoredOffset, indexByte, offset, size, remoteProbeBudget) {
|
|
5737
|
-
const filesLength = getUint16(view, indexByte + 10);
|
|
5738
|
-
const directoryDataLength = getUint32(view, indexByte + 12);
|
|
5739
|
-
const directoryDataOffset = getUint32(view, indexByte + 16);
|
|
5928
|
+
const filesLength = getUint16$1(view, indexByte + 10);
|
|
5929
|
+
const directoryDataLength = getUint32$1(view, indexByte + 12);
|
|
5930
|
+
const directoryDataOffset = getUint32$1(view, indexByte + 16);
|
|
5740
5931
|
if (filesLength == MAX_16_BITS || directoryDataLength == MAX_32_BITS || directoryDataOffset == MAX_32_BITS) {
|
|
5741
5932
|
const locatorSignature = await readSignature(reader, view, anchoredOffset, offset - ZIP64_END_OF_CENTRAL_DIR_LOCATOR_LENGTH, size, remoteProbeBudget);
|
|
5742
5933
|
return locatorSignature == ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIGNATURE ? CENTRAL_DIRECTORY_REACHABLE : CENTRAL_DIRECTORY_UNREACHABLE;
|
|
@@ -5744,7 +5935,7 @@
|
|
|
5744
5935
|
if (!filesLength && !directoryDataLength) {
|
|
5745
5936
|
return CENTRAL_DIRECTORY_PLAUSIBLE;
|
|
5746
5937
|
}
|
|
5747
|
-
const directoryDiskNumber = getUint16(view, indexByte + 6);
|
|
5938
|
+
const directoryDiskNumber = getUint16$1(view, indexByte + 6);
|
|
5748
5939
|
for (const centralDirectoryOffset of [offset - directoryDataLength, getDiskOffset$1(reader, directoryDiskNumber) + directoryDataOffset]) {
|
|
5749
5940
|
if (await readSignature(reader, view, anchoredOffset, centralDirectoryOffset, size, remoteProbeBudget) == CENTRAL_FILE_HEADER_SIGNATURE) {
|
|
5750
5941
|
return CENTRAL_DIRECTORY_REACHABLE;
|
|
@@ -5758,20 +5949,21 @@
|
|
|
5758
5949
|
return UNDEFINED_VALUE;
|
|
5759
5950
|
}
|
|
5760
5951
|
if (signatureOffset >= anchoredOffset) {
|
|
5761
|
-
return getUint32(view, signatureOffset - anchoredOffset);
|
|
5952
|
+
return getUint32$1(view, signatureOffset - anchoredOffset);
|
|
5762
5953
|
}
|
|
5763
5954
|
if (remoteProbeBudget.count > 0) {
|
|
5764
5955
|
remoteProbeBudget.count--;
|
|
5765
5956
|
const signatureArray = await readUint8Array(reader, signatureOffset, 4);
|
|
5766
|
-
return getUint32(getDataView(signatureArray), 0);
|
|
5957
|
+
return getUint32$1(getDataView(signatureArray), 0);
|
|
5767
5958
|
}
|
|
5768
5959
|
return UNDEFINED_VALUE;
|
|
5769
5960
|
}
|
|
5770
5961
|
|
|
5771
|
-
function
|
|
5962
|
+
function validateLocalDirectory(zipEntry, localDirectory, rawLocalFilename, checkLocalFilename) {
|
|
5772
5963
|
const { rawFilename } = zipEntry;
|
|
5773
|
-
if (
|
|
5774
|
-
rawLocalFilename.
|
|
5964
|
+
if (checkLocalFilename &&
|
|
5965
|
+
(rawLocalFilename.length != rawFilename.length ||
|
|
5966
|
+
rawLocalFilename.some((byteValue, indexByte) => byteValue != rawFilename[indexByte]))) {
|
|
5775
5967
|
throwAmbiguousArchive("mismatched local file header (filename)");
|
|
5776
5968
|
}
|
|
5777
5969
|
if ((localDirectory.rawBitFlag & BITFLAG_AMBIGUITY_MASK) != (zipEntry.rawBitFlag & BITFLAG_AMBIGUITY_MASK)) {
|
|
@@ -5799,10 +5991,11 @@
|
|
|
5799
5991
|
return options[name] === UNDEFINED_VALUE ? zipReader.options[name] : options[name];
|
|
5800
5992
|
}
|
|
5801
5993
|
|
|
5802
|
-
function
|
|
5803
|
-
return
|
|
5994
|
+
function getFunctionOptionValue$1(zipReader, options, name) {
|
|
5995
|
+
return checkFunctionOption(getOptionValue$1(zipReader, options, name));
|
|
5804
5996
|
}
|
|
5805
5997
|
|
|
5998
|
+
|
|
5806
5999
|
function getDate(timeRaw) {
|
|
5807
6000
|
const date = (timeRaw & 0xffff0000) >> 16, time = timeRaw & MAX_16_BITS;
|
|
5808
6001
|
return new Date(1980 + ((date & 0xFE00) >> 9), ((date & 0x01E0) >> 5) - 1, date & 0x001F, (time & 0xF800) >> 11, (time & 0x07E0) >> 5, (time & 0x001F) * 2, 0);
|
|
@@ -5816,11 +6009,11 @@
|
|
|
5816
6009
|
return view.getUint8(offset);
|
|
5817
6010
|
}
|
|
5818
6011
|
|
|
5819
|
-
function getUint16(view, offset) {
|
|
6012
|
+
function getUint16$1(view, offset) {
|
|
5820
6013
|
return view.getUint16(offset, true);
|
|
5821
6014
|
}
|
|
5822
6015
|
|
|
5823
|
-
function getUint32(view, offset) {
|
|
6016
|
+
function getUint32$1(view, offset) {
|
|
5824
6017
|
return view.getUint32(offset, true);
|
|
5825
6018
|
}
|
|
5826
6019
|
|
|
@@ -5835,6 +6028,7 @@
|
|
|
5835
6028
|
ERR_CENTRAL_DIRECTORY_NOT_FOUND: ERR_CENTRAL_DIRECTORY_NOT_FOUND,
|
|
5836
6029
|
ERR_ENCRYPTED: ERR_ENCRYPTED,
|
|
5837
6030
|
ERR_ENCRYPTED_CENTRAL_DIRECTORY: ERR_ENCRYPTED_CENTRAL_DIRECTORY,
|
|
6031
|
+
ERR_ENTRY_DATA_OUT_OF_BOUNDS: ERR_ENTRY_DATA_OUT_OF_BOUNDS,
|
|
5838
6032
|
ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND: ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND,
|
|
5839
6033
|
ERR_EOCDR_NOT_FOUND: ERR_EOCDR_NOT_FOUND,
|
|
5840
6034
|
ERR_EXTRAFIELD_ZIP64_NOT_FOUND: ERR_EXTRAFIELD_ZIP64_NOT_FOUND,
|
|
@@ -5889,13 +6083,18 @@
|
|
|
5889
6083
|
|
|
5890
6084
|
const ERR_DUPLICATED_NAME = "File already exists";
|
|
5891
6085
|
const ERR_INVALID_COMMENT = "Zip file comment exceeds 64KB";
|
|
6086
|
+
const ERR_INVALID_COMMENT_TYPE = "Invalid zip file comment (must be a Uint8Array)";
|
|
5892
6087
|
const ERR_INVALID_ENTRY_COMMENT = "File entry comment exceeds 64KB";
|
|
6088
|
+
const ERR_INVALID_ENTRY_COMMENT_TYPE = "Invalid file entry comment (must be a string)";
|
|
6089
|
+
const ERR_INVALID_DATE = "Invalid date (must be a valid Date instance)";
|
|
5893
6090
|
const ERR_INVALID_ENTRY_NAME = "File entry name exceeds 64KB";
|
|
5894
6091
|
const ERR_INVALID_VERSION = "Version exceeds 65535";
|
|
5895
6092
|
const ERR_INVALID_ENCRYPTION_STRENGTH = "The strength must equal 1, 2, or 3";
|
|
5896
6093
|
const ERR_UNSUPPORTED_ENCRYPTION_USDZ = "Encryption is not supported in USDZ files";
|
|
5897
6094
|
const ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH = "Encryption is not supported when the 'passThrough' option is set";
|
|
5898
|
-
const
|
|
6095
|
+
const ERR_INVALID_EXTRAFIELD = "Invalid extra field (must be a Map)";
|
|
6096
|
+
const ERR_INVALID_EXTRAFIELD_TYPE = "Invalid extra field type (must be integer 0..65535)";
|
|
6097
|
+
const ERR_INVALID_EXTRAFIELD_DATA_TYPE = "Invalid extra field data (must be a Uint8Array)";
|
|
5899
6098
|
const ERR_INVALID_EXTRAFIELD_DATA = "Extra field data exceeds 64KB";
|
|
5900
6099
|
const ERR_UNSUPPORTED_COMPRESSION = "Compression method not supported";
|
|
5901
6100
|
const MIN_UNIX_TIME = -2147483648;
|
|
@@ -5915,7 +6114,6 @@
|
|
|
5915
6114
|
const ERR_INVALID_MSDOS_ATTRIBUTES = "Invalid msdosAttributesRaw (must be integer 0..255)";
|
|
5916
6115
|
const ERR_INVALID_MSDOS_DATA = "Invalid msdosAttributes (must be an object with boolean flags)";
|
|
5917
6116
|
const ERR_INVALID_LEVEL = "Invalid level (must be integer 0..9)";
|
|
5918
|
-
const ERR_INVALID_PASSWORD_TYPE = "Invalid password (password must be a string, rawPassword must be a Uint8Array)";
|
|
5919
6117
|
const ERR_INVALID_SIGNATURE_DATA = "Signature data exceeds 64KB";
|
|
5920
6118
|
|
|
5921
6119
|
const EXTRAFIELD_DATA_AES = new Uint8Array([0x07, 0x00, 0x02, 0x00, 0x41, 0x45, 0x03, 0x00, 0x00]);
|
|
@@ -5940,8 +6138,7 @@
|
|
|
5940
6138
|
writer,
|
|
5941
6139
|
addSplitZipSignature,
|
|
5942
6140
|
options,
|
|
5943
|
-
|
|
5944
|
-
files: new Map(),
|
|
6141
|
+
fileEntries: new Map(),
|
|
5945
6142
|
filenames: new Set(),
|
|
5946
6143
|
offset: options[OPTION_OFFSET] === UNDEFINED_VALUE ? writer.size || writer.writable.size || 0 : options[OPTION_OFFSET],
|
|
5947
6144
|
initialOffset: options[OPTION_OFFSET] === UNDEFINED_VALUE ? 0 : options[OPTION_OFFSET] - (writer.size || writer.writable.size || 0),
|
|
@@ -5957,15 +6154,28 @@
|
|
|
5957
6154
|
}
|
|
5958
6155
|
reader = new GenericReader(reader);
|
|
5959
6156
|
await initStream(reader);
|
|
6157
|
+
if (reader.size === UNDEFINED_VALUE || !reader.readUint8Array) {
|
|
6158
|
+
reader = new BlobReader(await streamToBlob(reader.readable));
|
|
6159
|
+
await initStream(reader);
|
|
6160
|
+
}
|
|
5960
6161
|
const { ZipReader } = await Promise.resolve().then(function () { return zipReader; });
|
|
5961
|
-
const zipReader$1 = new ZipReader(reader
|
|
6162
|
+
const zipReader$1 = new ZipReader(reader);
|
|
5962
6163
|
const entries = await zipReader$1.getEntries();
|
|
5963
6164
|
await zipReader$1.close();
|
|
5964
6165
|
await initStream(this.writer);
|
|
5965
|
-
|
|
5966
|
-
|
|
6166
|
+
const { directoryOffset } = zipReader$1;
|
|
6167
|
+
let splitZipSignatureLength = 0;
|
|
6168
|
+
if (this.addSplitZipSignature) {
|
|
6169
|
+
delete this.addSplitZipSignature;
|
|
6170
|
+
if (!await startsWithSplitZipSignature(reader)) {
|
|
6171
|
+
await writeData(this.writer, getSplitZipSignatureArray());
|
|
6172
|
+
splitZipSignatureLength = SPLIT_ZIP_FILE_SIGNATURE_LENGTH;
|
|
6173
|
+
this.offset += splitZipSignatureLength;
|
|
6174
|
+
}
|
|
6175
|
+
}
|
|
6176
|
+
const entryPositions = await copyZipData(this, reader, entries, directoryOffset, splitZipSignatureLength);
|
|
5967
6177
|
this.filenames = new Set(entries.map(entry => entry.filename));
|
|
5968
|
-
this.
|
|
6178
|
+
this.fileEntries = new Map(entries.map(entry => {
|
|
5969
6179
|
const {
|
|
5970
6180
|
version,
|
|
5971
6181
|
rawLastModDate,
|
|
@@ -6020,11 +6230,12 @@
|
|
|
6020
6230
|
if (crc32 !== UNDEFINED_VALUE) {
|
|
6021
6231
|
setUint32(headerView, HEADER_OFFSET_SIGNATURE, crc32);
|
|
6022
6232
|
}
|
|
6233
|
+
const { offset, diskNumberStart } = entryPositions.get(entry);
|
|
6023
6234
|
Object.assign(entry, {
|
|
6024
6235
|
zip64UncompressedSize,
|
|
6025
6236
|
zip64CompressedSize,
|
|
6026
|
-
|
|
6027
|
-
diskNumberStart
|
|
6237
|
+
offset,
|
|
6238
|
+
diskNumberStart,
|
|
6028
6239
|
zip64DiskNumberStart: false,
|
|
6029
6240
|
rawExtraFieldZip64,
|
|
6030
6241
|
rawExtraFieldAES,
|
|
@@ -6044,11 +6255,8 @@
|
|
|
6044
6255
|
async add(name = "", reader, options = {}) {
|
|
6045
6256
|
const zipWriter = this;
|
|
6046
6257
|
options = Object.assign({}, options);
|
|
6047
|
-
const {
|
|
6048
|
-
|
|
6049
|
-
config
|
|
6050
|
-
} = zipWriter;
|
|
6051
|
-
if (workers < config.maxWorkers) {
|
|
6258
|
+
const { pendingAddFileCalls } = zipWriter;
|
|
6259
|
+
if (workers < getConfiguration().maxWorkers) {
|
|
6052
6260
|
workers++;
|
|
6053
6261
|
} else {
|
|
6054
6262
|
await new Promise(resolve => pendingEntries.push(resolve));
|
|
@@ -6085,16 +6293,16 @@
|
|
|
6085
6293
|
}
|
|
6086
6294
|
|
|
6087
6295
|
remove(entry) {
|
|
6088
|
-
const { filenames,
|
|
6296
|
+
const { filenames, fileEntries } = this;
|
|
6089
6297
|
// deno-lint-ignore valid-typeof
|
|
6090
6298
|
if (typeof entry == STRING_TYPE) {
|
|
6091
|
-
entry =
|
|
6299
|
+
entry = fileEntries.get(entry);
|
|
6092
6300
|
}
|
|
6093
6301
|
if (entry && entry.filename !== UNDEFINED_VALUE) {
|
|
6094
6302
|
const { filename } = entry;
|
|
6095
|
-
if (filenames.has(filename) &&
|
|
6303
|
+
if (filenames.has(filename) && fileEntries.has(filename)) {
|
|
6096
6304
|
filenames.delete(filename);
|
|
6097
|
-
|
|
6305
|
+
fileEntries.delete(filename);
|
|
6098
6306
|
return true;
|
|
6099
6307
|
}
|
|
6100
6308
|
}
|
|
@@ -6105,6 +6313,9 @@
|
|
|
6105
6313
|
const zipWriter = this;
|
|
6106
6314
|
const { pendingAddFileCalls, writer } = this;
|
|
6107
6315
|
const { writable } = writer;
|
|
6316
|
+
if (!(comment instanceof Uint8Array)) {
|
|
6317
|
+
throw new Error(ERR_INVALID_COMMENT_TYPE);
|
|
6318
|
+
}
|
|
6108
6319
|
if (getLength(comment) > MAX_16_BITS) {
|
|
6109
6320
|
throw new Error(ERR_INVALID_COMMENT);
|
|
6110
6321
|
}
|
|
@@ -6188,12 +6399,12 @@
|
|
|
6188
6399
|
const metadataInfo = resolveMetadata(zipWriter, name, options);
|
|
6189
6400
|
const { comment } = metadataInfo;
|
|
6190
6401
|
const extraField = options[PROPERTY_NAME_EXTRA_FIELD];
|
|
6191
|
-
zipWriter.
|
|
6402
|
+
zipWriter.fileEntries.set(name, UNDEFINED_VALUE);
|
|
6192
6403
|
let fileEntry;
|
|
6193
6404
|
try {
|
|
6194
6405
|
const { resolvedOptions } = metadataInfo;
|
|
6195
6406
|
if (resolvedOptions.level != 0 && resolvedOptions.compressionMethod === UNDEFINED_VALUE &&
|
|
6196
|
-
!resolvedOptions.passThrough && !(await supportsDeflate(
|
|
6407
|
+
!resolvedOptions.passThrough && !(await supportsDeflate(getConfiguration()))) {
|
|
6197
6408
|
resolvedOptions.level = 0;
|
|
6198
6409
|
}
|
|
6199
6410
|
const sizesInfo = await resolveSizes(zipWriter, reader, metadataInfo, options);
|
|
@@ -6201,8 +6412,6 @@
|
|
|
6201
6412
|
const diskOffset = getDiskOffset(zipWriter.writer);
|
|
6202
6413
|
const diskNumber = getDiskNumber(zipWriter.writer);
|
|
6203
6414
|
options = Object.assign({}, options, attributesInfo.resolvedOptions, metadataInfo.resolvedOptions, sizesInfo.resolvedOptions, {
|
|
6204
|
-
internalFileAttribute: metadataInfo.resolvedOptions.internalFileAttributes,
|
|
6205
|
-
externalFileAttribute: attributesInfo.resolvedOptions.externalFileAttributes,
|
|
6206
6415
|
signature: options[PROPERTY_NAME_SIGNATURE],
|
|
6207
6416
|
crc32: options.crc32 === UNDEFINED_VALUE ? options[PROPERTY_NAME_SIGNATURE] : options.crc32,
|
|
6208
6417
|
offset: zipWriter.offset - diskOffset,
|
|
@@ -6213,17 +6422,23 @@
|
|
|
6213
6422
|
const metadataSize = getLength(headerInfo.localHeaderArray, dataDescriptorInfo.dataDescriptorArray);
|
|
6214
6423
|
fileEntry = await getFileEntry(zipWriter, name, reader, { headerInfo, dataDescriptorInfo, metadataSize }, options);
|
|
6215
6424
|
} catch (error) {
|
|
6216
|
-
zipWriter.
|
|
6425
|
+
zipWriter.fileEntries.delete(name);
|
|
6217
6426
|
throw error;
|
|
6218
6427
|
}
|
|
6219
|
-
Object.assign(fileEntry, {
|
|
6428
|
+
Object.assign(fileEntry, {
|
|
6429
|
+
name,
|
|
6430
|
+
comment,
|
|
6431
|
+
extraField,
|
|
6432
|
+
[PROPERTY_NAME_DEPRECATED_INTERNAL_FILE_ATTRIBUTES]: fileEntry.internalFileAttributes,
|
|
6433
|
+
[PROPERTY_NAME_DEPRECATED_EXTERNAL_FILE_ATTRIBUTES]: fileEntry.externalFileAttributes
|
|
6434
|
+
});
|
|
6220
6435
|
return new Entry(fileEntry);
|
|
6221
6436
|
}
|
|
6222
6437
|
|
|
6223
6438
|
function resolveAttributes(zipWriter, name, options) {
|
|
6224
6439
|
name = name.trim();
|
|
6225
6440
|
let msDosCompatible = getOptionValue(zipWriter, options, PROPERTY_NAME_MS_DOS_COMPATIBLE);
|
|
6226
|
-
let versionMadeBy = getOptionValue(zipWriter, options, PROPERTY_NAME_VERSION_MADE_BY, msDosCompatible ?
|
|
6441
|
+
let versionMadeBy = getOptionValue(zipWriter, options, PROPERTY_NAME_VERSION_MADE_BY, msDosCompatible ? VERSION_MADE_BY_MSDOS : VERSION_MADE_BY_UNIX);
|
|
6227
6442
|
const executable = getOptionValue(zipWriter, options, PROPERTY_NAME_EXECUTABLE);
|
|
6228
6443
|
const uid = getNumberOptionValue(zipWriter, options, PROPERTY_NAME_UID);
|
|
6229
6444
|
const gid = getNumberOptionValue(zipWriter, options, PROPERTY_NAME_GID);
|
|
@@ -6251,21 +6466,21 @@
|
|
|
6251
6466
|
if (unixExtraFieldType === UNDEFINED_VALUE && (uid !== UNDEFINED_VALUE || gid !== UNDEFINED_VALUE)) {
|
|
6252
6467
|
unixExtraFieldType = INFOZIP_EXTRA_FIELD_TYPE$1;
|
|
6253
6468
|
}
|
|
6254
|
-
let msdosAttributesRaw =
|
|
6469
|
+
let msdosAttributesRaw = getNumberOptionValue(zipWriter, options, PROPERTY_NAME_MSDOS_ATTRIBUTES_RAW);
|
|
6255
6470
|
let msdosAttributes = getOptionValue(zipWriter, options, PROPERTY_NAME_MSDOS_ATTRIBUTES);
|
|
6256
|
-
const hasUnixMetadata = uid !== UNDEFINED_VALUE || gid !== UNDEFINED_VALUE || unixMode !== UNDEFINED_VALUE || unixExtraFieldType;
|
|
6471
|
+
const hasUnixMetadata = uid !== UNDEFINED_VALUE || gid !== UNDEFINED_VALUE || unixMode !== UNDEFINED_VALUE || unixExtraFieldType || executable;
|
|
6257
6472
|
const hasMsDosProvided = msdosAttributesRaw !== UNDEFINED_VALUE || msdosAttributes !== UNDEFINED_VALUE;
|
|
6258
6473
|
if (hasUnixMetadata) {
|
|
6259
6474
|
msDosCompatible = false;
|
|
6260
|
-
versionMadeBy = (versionMadeBy &
|
|
6475
|
+
versionMadeBy = (versionMadeBy & MAX_8_BITS) | VERSION_MADE_BY_UNIX;
|
|
6261
6476
|
} else if (hasMsDosProvided) {
|
|
6262
6477
|
msDosCompatible = true;
|
|
6263
6478
|
versionMadeBy = (versionMadeBy & MAX_8_BITS);
|
|
6264
6479
|
}
|
|
6265
|
-
if (msdosAttributesRaw !== UNDEFINED_VALUE && (msdosAttributesRaw < 0 || msdosAttributesRaw > MAX_8_BITS)) {
|
|
6480
|
+
if (msdosAttributesRaw !== UNDEFINED_VALUE && (!Number.isInteger(msdosAttributesRaw) || msdosAttributesRaw < 0 || msdosAttributesRaw > MAX_8_BITS)) {
|
|
6266
6481
|
throw new Error(ERR_INVALID_MSDOS_ATTRIBUTES);
|
|
6267
6482
|
}
|
|
6268
|
-
if (msdosAttributes && typeof msdosAttributes !== OBJECT_TYPE) {
|
|
6483
|
+
if (msdosAttributes && (typeof msdosAttributes !== OBJECT_TYPE || Array.isArray(msdosAttributes))) {
|
|
6269
6484
|
throw new Error(ERR_INVALID_MSDOS_DATA);
|
|
6270
6485
|
}
|
|
6271
6486
|
if (versionMadeBy > MAX_16_BITS) {
|
|
@@ -6297,11 +6512,10 @@
|
|
|
6297
6512
|
externalFileAttributes = FILE_ATTR_UNIX_DEFAULT_MASK << 16;
|
|
6298
6513
|
}
|
|
6299
6514
|
}
|
|
6300
|
-
let unixExternalUpper;
|
|
6301
6515
|
if (!msDosCompatible) {
|
|
6302
6516
|
const unixModeProvided = unixMode !== UNDEFINED_VALUE || Boolean(setuid || setgid || sticky);
|
|
6303
|
-
|
|
6304
|
-
unixMode = unixMode === UNDEFINED_VALUE ?
|
|
6517
|
+
const defaultUnixMode = (externalFileAttributes >> 16) & MAX_16_BITS;
|
|
6518
|
+
unixMode = unixMode === UNDEFINED_VALUE ? defaultUnixMode : (unixMode & MAX_16_BITS);
|
|
6305
6519
|
if (setuid) {
|
|
6306
6520
|
unixMode |= FILE_ATTR_UNIX_SETUID_MASK;
|
|
6307
6521
|
} else {
|
|
@@ -6330,17 +6544,20 @@
|
|
|
6330
6544
|
if (hasMsDosProvided) {
|
|
6331
6545
|
externalFileAttributes = (externalFileAttributes & MAX_32_BITS) | (msdosAttributesRaw & MAX_8_BITS);
|
|
6332
6546
|
}
|
|
6547
|
+
const unixExternalUpper = (externalFileAttributes >> 16) & MAX_16_BITS;
|
|
6548
|
+
const symlink = unixMode !== UNDEFINED_VALUE && ((unixMode & FILE_ATTR_UNIX_TYPE_MASK) == FILE_ATTR_UNIX_TYPE_SYMLINK);
|
|
6333
6549
|
return {
|
|
6334
6550
|
name,
|
|
6335
6551
|
resolvedOptions: {
|
|
6336
6552
|
versionMadeBy,
|
|
6337
|
-
msDosCompatible,
|
|
6553
|
+
msDosCompatible: Boolean(msDosCompatible),
|
|
6338
6554
|
externalFileAttributes,
|
|
6339
6555
|
unixExternalUpper,
|
|
6340
6556
|
uid,
|
|
6341
6557
|
gid,
|
|
6342
6558
|
unixMode,
|
|
6343
6559
|
unixExtraFieldType,
|
|
6560
|
+
symlink,
|
|
6344
6561
|
setuid,
|
|
6345
6562
|
setgid,
|
|
6346
6563
|
sticky,
|
|
@@ -6351,7 +6568,7 @@
|
|
|
6351
6568
|
}
|
|
6352
6569
|
|
|
6353
6570
|
function resolveMetadata(zipWriter, name, options) {
|
|
6354
|
-
const encode =
|
|
6571
|
+
const encode = getFunctionOptionValue(zipWriter, options, OPTION_ENCODE_TEXT) || encodeText;
|
|
6355
6572
|
let rawFilename = encode(name, TEXT_TYPE_FILENAME);
|
|
6356
6573
|
if (rawFilename === UNDEFINED_VALUE) {
|
|
6357
6574
|
rawFilename = encodeText(name);
|
|
@@ -6360,6 +6577,10 @@
|
|
|
6360
6577
|
throw new Error(ERR_INVALID_ENTRY_NAME);
|
|
6361
6578
|
}
|
|
6362
6579
|
const comment = options[PROPERTY_NAME_COMMENT] || "";
|
|
6580
|
+
// deno-lint-ignore valid-typeof
|
|
6581
|
+
if (typeof comment != STRING_TYPE) {
|
|
6582
|
+
throw new Error(ERR_INVALID_ENTRY_COMMENT_TYPE);
|
|
6583
|
+
}
|
|
6363
6584
|
let rawComment = encode(comment, TEXT_TYPE_COMMENT);
|
|
6364
6585
|
if (rawComment === UNDEFINED_VALUE) {
|
|
6365
6586
|
rawComment = encodeText(comment);
|
|
@@ -6371,16 +6592,14 @@
|
|
|
6371
6592
|
if (version > MAX_16_BITS) {
|
|
6372
6593
|
throw new Error(ERR_INVALID_VERSION);
|
|
6373
6594
|
}
|
|
6374
|
-
const lastModDate =
|
|
6375
|
-
const lastAccessDate =
|
|
6376
|
-
const creationDate =
|
|
6595
|
+
const lastModDate = getDateOptionValue(zipWriter, options, PROPERTY_NAME_LAST_MODIFICATION_DATE, new Date());
|
|
6596
|
+
const lastAccessDate = getDateOptionValue(zipWriter, options, PROPERTY_NAME_LAST_ACCESS_DATE);
|
|
6597
|
+
const creationDate = getDateOptionValue(zipWriter, options, PROPERTY_NAME_CREATION_DATE);
|
|
6377
6598
|
const internalFileAttributes = getAliasedOptionValue(zipWriter, options, PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTES, PROPERTY_NAME_DEPRECATED_INTERNAL_FILE_ATTRIBUTES, 0);
|
|
6378
6599
|
const passThrough = getOptionValue(zipWriter, options, OPTION_PASS_THROUGH);
|
|
6379
6600
|
const password = getOptionValue(zipWriter, options, OPTION_PASSWORD);
|
|
6380
6601
|
const rawPassword = getOptionValue(zipWriter, options, OPTION_RAW_PASSWORD);
|
|
6381
|
-
|
|
6382
|
-
throw new Error(ERR_INVALID_PASSWORD_TYPE);
|
|
6383
|
-
}
|
|
6602
|
+
checkPasswordOption(password, rawPassword);
|
|
6384
6603
|
const encryptionStrength = getNumberOptionValue(zipWriter, options, OPTION_ENCRYPTION_STRENGTH, 3);
|
|
6385
6604
|
const zipCrypto = getOptionValue(zipWriter, options, PROPERTY_NAME_ZIPCRYPTO);
|
|
6386
6605
|
const extendedTimestamp = getOptionValue(zipWriter, options, OPTION_EXTENDED_TIMESTAMP, true);
|
|
@@ -6389,9 +6608,9 @@
|
|
|
6389
6608
|
const useWebWorkers = getOptionValue(zipWriter, options, OPTION_USE_WEB_WORKERS);
|
|
6390
6609
|
const transferStreams = getOptionValue(zipWriter, options, OPTION_TRANSFER_STREAMS);
|
|
6391
6610
|
const bufferedWrite = getOptionValue(zipWriter, options, OPTION_BUFFERED_WRITE);
|
|
6392
|
-
const createTempStream =
|
|
6611
|
+
const createTempStream = getFunctionOptionValue(zipWriter, options, OPTION_CREATE_TEMP_STREAM);
|
|
6393
6612
|
const dataDescriptorSignature = getOptionValue(zipWriter, options, OPTION_DATA_DESCRIPTOR_SIGNATURE, true);
|
|
6394
|
-
const signal = getOptionValue(zipWriter, options, OPTION_SIGNAL);
|
|
6613
|
+
const signal = checkSignalOption(getOptionValue(zipWriter, options, OPTION_SIGNAL));
|
|
6395
6614
|
const useUnicodeFileNames = getOptionValue(zipWriter, options, OPTION_USE_UNICODE_FILE_NAMES, true);
|
|
6396
6615
|
const compressionMethod = getOptionValue(zipWriter, options, PROPERTY_NAME_COMPRESSION_METHOD);
|
|
6397
6616
|
const registeredCodec = passThrough || compressionMethod === UNDEFINED_VALUE ? UNDEFINED_VALUE : getRegisteredCodec(compressionMethod);
|
|
@@ -6471,18 +6690,26 @@
|
|
|
6471
6690
|
if (!extraField) {
|
|
6472
6691
|
return EMPTY_UINT8_ARRAY;
|
|
6473
6692
|
}
|
|
6693
|
+
if (!(extraField instanceof Map)) {
|
|
6694
|
+
throw new Error(ERR_INVALID_EXTRAFIELD);
|
|
6695
|
+
}
|
|
6474
6696
|
let extraFieldSize = 0;
|
|
6475
6697
|
let offset = 0;
|
|
6476
|
-
extraField.forEach(data => extraFieldSize += 4 + getLength(data));
|
|
6477
|
-
const rawExtraField = new Uint8Array(extraFieldSize);
|
|
6478
|
-
const rawExtraFieldView = getDataView(rawExtraField);
|
|
6479
6698
|
extraField.forEach((data, type) => {
|
|
6480
|
-
if (type > MAX_16_BITS) {
|
|
6699
|
+
if (!Number.isInteger(type) || type < 0 || type > MAX_16_BITS) {
|
|
6481
6700
|
throw new Error(ERR_INVALID_EXTRAFIELD_TYPE);
|
|
6482
6701
|
}
|
|
6702
|
+
if (!(data instanceof Uint8Array)) {
|
|
6703
|
+
throw new Error(ERR_INVALID_EXTRAFIELD_DATA_TYPE);
|
|
6704
|
+
}
|
|
6483
6705
|
if (getLength(data) > MAX_16_BITS) {
|
|
6484
6706
|
throw new Error(ERR_INVALID_EXTRAFIELD_DATA);
|
|
6485
6707
|
}
|
|
6708
|
+
extraFieldSize += 4 + getLength(data);
|
|
6709
|
+
});
|
|
6710
|
+
const rawExtraField = new Uint8Array(extraFieldSize);
|
|
6711
|
+
const rawExtraFieldView = getDataView(rawExtraField);
|
|
6712
|
+
extraField.forEach((data, type) => {
|
|
6486
6713
|
setUint16(rawExtraFieldView, offset, type);
|
|
6487
6714
|
setUint16(rawExtraFieldView, offset + 2, getLength(data));
|
|
6488
6715
|
arraySet(rawExtraField, data, offset + 4);
|
|
@@ -6569,10 +6796,13 @@
|
|
|
6569
6796
|
}
|
|
6570
6797
|
|
|
6571
6798
|
async function getEntriesSize(writerOptions, entries, writeOrderGuaranteed, comment) {
|
|
6572
|
-
const zipWriter = { options: writerOptions
|
|
6573
|
-
if (writerOptions[OPTION_SIGN_CENTRAL_DIRECTORY]) {
|
|
6799
|
+
const zipWriter = { options: writerOptions };
|
|
6800
|
+
if (checkFunctionOption(writerOptions[OPTION_SIGN_CENTRAL_DIRECTORY])) {
|
|
6574
6801
|
throw new Error(ERR_UNDETERMINED_SIZE);
|
|
6575
6802
|
}
|
|
6803
|
+
if (comment !== UNDEFINED_VALUE && !(comment instanceof Uint8Array)) {
|
|
6804
|
+
throw new Error(ERR_INVALID_COMMENT_TYPE);
|
|
6805
|
+
}
|
|
6576
6806
|
const commentLength = getLength(comment);
|
|
6577
6807
|
if (commentLength > MAX_16_BITS) {
|
|
6578
6808
|
throw new Error(ERR_INVALID_COMMENT);
|
|
@@ -6593,7 +6823,7 @@
|
|
|
6593
6823
|
({ name } = attributesInfo);
|
|
6594
6824
|
const { resolvedOptions: metadata } = resolveMetadata(zipWriter, name, options);
|
|
6595
6825
|
if (metadata.level != 0 && metadata.compressionMethod === UNDEFINED_VALUE &&
|
|
6596
|
-
!metadata.passThrough && !(await supportsDeflate(
|
|
6826
|
+
!metadata.passThrough && !(await supportsDeflate(getConfiguration()))) {
|
|
6597
6827
|
metadata.level = 0;
|
|
6598
6828
|
}
|
|
6599
6829
|
const hasContent = !getOptionValue(zipWriter, options, PROPERTY_NAME_DIRECTORY);
|
|
@@ -6642,7 +6872,7 @@
|
|
|
6642
6872
|
|
|
6643
6873
|
async function getFileEntry(zipWriter, name, reader, entryInfo, options) {
|
|
6644
6874
|
const {
|
|
6645
|
-
|
|
6875
|
+
fileEntries,
|
|
6646
6876
|
writer
|
|
6647
6877
|
} = zipWriter;
|
|
6648
6878
|
const {
|
|
@@ -6664,12 +6894,12 @@
|
|
|
6664
6894
|
let writerSizeBeforeEntry;
|
|
6665
6895
|
let flushedBufferedSize = 0;
|
|
6666
6896
|
let fileWriter;
|
|
6667
|
-
|
|
6897
|
+
fileEntries.set(name, fileEntry);
|
|
6668
6898
|
zipWriter.lastFileEntry = fileEntry;
|
|
6669
6899
|
try {
|
|
6670
6900
|
let lockPreviousFileEntry;
|
|
6671
6901
|
if (keepOrder) {
|
|
6672
|
-
lockPreviousFileEntry = previousFileEntry && previousFileEntry.
|
|
6902
|
+
lockPreviousFileEntry = previousFileEntry && previousFileEntry.lockFileEntry;
|
|
6673
6903
|
requestLockCurrentFileEntry();
|
|
6674
6904
|
}
|
|
6675
6905
|
if (options.bufferedWrite || !keepOrder || zipWriter.writerLocked || zipWriter.bufferedWrites || !dataDescriptor) {
|
|
@@ -6690,11 +6920,8 @@
|
|
|
6690
6920
|
const diskOffset = getDiskOffset(writer);
|
|
6691
6921
|
if (zipWriter.addSplitZipSignature) {
|
|
6692
6922
|
delete zipWriter.addSplitZipSignature;
|
|
6693
|
-
|
|
6694
|
-
|
|
6695
|
-
setUint32(signatureArrayView, 0, SPLIT_ZIP_FILE_SIGNATURE);
|
|
6696
|
-
await writeData(writer, signatureArray);
|
|
6697
|
-
zipWriter.offset += 4;
|
|
6923
|
+
await writeData(writer, getSplitZipSignatureArray());
|
|
6924
|
+
zipWriter.offset += SPLIT_ZIP_FILE_SIGNATURE_LENGTH;
|
|
6698
6925
|
}
|
|
6699
6926
|
if (usdz && !bufferedWrite) {
|
|
6700
6927
|
appendExtraFieldUSDZ(entryInfo, zipWriter.offset - diskOffset);
|
|
@@ -6712,11 +6939,11 @@
|
|
|
6712
6939
|
writerSizeBeforeEntry = writer.size;
|
|
6713
6940
|
await writeData(fileWriter, localHeaderArray);
|
|
6714
6941
|
}
|
|
6715
|
-
fileEntry = await createFileEntry(reader, fileWriter, fileEntry, entryInfo,
|
|
6942
|
+
fileEntry = await createFileEntry(reader, fileWriter, fileEntry, entryInfo, getConfiguration(), options);
|
|
6716
6943
|
if (!bufferedWrite) {
|
|
6717
6944
|
writingEntryData = false;
|
|
6718
6945
|
}
|
|
6719
|
-
|
|
6946
|
+
fileEntries.set(name, fileEntry);
|
|
6720
6947
|
fileEntry.filename = name;
|
|
6721
6948
|
if (bufferedWrite) {
|
|
6722
6949
|
await Promise.all([fileWriter.writable.getWriter().close(), lockPreviousFileEntry]);
|
|
@@ -6757,7 +6984,7 @@
|
|
|
6757
6984
|
zipWriter.offset += flushedBufferedSize;
|
|
6758
6985
|
}
|
|
6759
6986
|
}
|
|
6760
|
-
|
|
6987
|
+
fileEntries.delete(name);
|
|
6761
6988
|
throw error;
|
|
6762
6989
|
} finally {
|
|
6763
6990
|
if (bufferedWrite) {
|
|
@@ -6779,7 +7006,7 @@
|
|
|
6779
7006
|
}
|
|
6780
7007
|
|
|
6781
7008
|
function requestLockCurrentFileEntry() {
|
|
6782
|
-
fileEntry.
|
|
7009
|
+
fileEntry.lockFileEntry = new Promise(resolve => releaseLockCurrentFileEntry = resolve);
|
|
6783
7010
|
}
|
|
6784
7011
|
|
|
6785
7012
|
async function requestLockWriter() {
|
|
@@ -6799,7 +7026,7 @@
|
|
|
6799
7026
|
}
|
|
6800
7027
|
}
|
|
6801
7028
|
|
|
6802
|
-
async function createFileEntry(reader, writer, { diskNumberStart,
|
|
7029
|
+
async function createFileEntry(reader, writer, { diskNumberStart, lockFileEntry }, entryInfo, config, options) {
|
|
6803
7030
|
const {
|
|
6804
7031
|
headerInfo,
|
|
6805
7032
|
dataDescriptorInfo,
|
|
@@ -6854,6 +7081,7 @@
|
|
|
6854
7081
|
uid,
|
|
6855
7082
|
gid,
|
|
6856
7083
|
unixMode,
|
|
7084
|
+
symlink,
|
|
6857
7085
|
setuid,
|
|
6858
7086
|
setgid,
|
|
6859
7087
|
sticky,
|
|
@@ -6866,7 +7094,7 @@
|
|
|
6866
7094
|
codecURI
|
|
6867
7095
|
} = options;
|
|
6868
7096
|
const fileEntry = {
|
|
6869
|
-
|
|
7097
|
+
lockFileEntry,
|
|
6870
7098
|
versionMadeBy,
|
|
6871
7099
|
zip64,
|
|
6872
7100
|
directory: Boolean(directory),
|
|
@@ -6890,6 +7118,7 @@
|
|
|
6890
7118
|
uid,
|
|
6891
7119
|
gid,
|
|
6892
7120
|
unixMode,
|
|
7121
|
+
symlink: Boolean(symlink),
|
|
6893
7122
|
setuid,
|
|
6894
7123
|
setgid,
|
|
6895
7124
|
sticky,
|
|
@@ -6907,7 +7136,7 @@
|
|
|
6907
7136
|
}
|
|
6908
7137
|
const { writable } = writer;
|
|
6909
7138
|
if (reader) {
|
|
6910
|
-
const readable = toCompatibleReadable(
|
|
7139
|
+
const readable = toCompatibleReadable(createReadable(reader));
|
|
6911
7140
|
const size = reader.size;
|
|
6912
7141
|
const workerOptions = {
|
|
6913
7142
|
options: {
|
|
@@ -6970,8 +7199,8 @@
|
|
|
6970
7199
|
rawLastModDate,
|
|
6971
7200
|
creationDate,
|
|
6972
7201
|
lastAccessDate,
|
|
6973
|
-
encrypted,
|
|
6974
|
-
zipCrypto,
|
|
7202
|
+
encrypted: Boolean(encrypted),
|
|
7203
|
+
zipCrypto: Boolean(zipCrypto),
|
|
6975
7204
|
size: metadataSize + compressedSize,
|
|
6976
7205
|
compressionMethod,
|
|
6977
7206
|
version,
|
|
@@ -7019,14 +7248,14 @@
|
|
|
7019
7248
|
if (zip64 && (zip64UncompressedSize || zip64CompressedSize)) {
|
|
7020
7249
|
const length = 4 + 16;
|
|
7021
7250
|
const extraFieldZip64 = createRecordWriter(length);
|
|
7022
|
-
extraFieldZip64.
|
|
7023
|
-
extraFieldZip64.
|
|
7251
|
+
extraFieldZip64.writeUint16(EXTRAFIELD_TYPE_ZIP64);
|
|
7252
|
+
extraFieldZip64.writeUint16(length - 4);
|
|
7024
7253
|
rawLocalExtraFieldZip64 = extraFieldZip64.array;
|
|
7025
7254
|
if (zip64ExtraFieldComplete) {
|
|
7026
|
-
extraFieldZip64.
|
|
7255
|
+
extraFieldZip64.writeUint64(uncompressedSize);
|
|
7027
7256
|
if (uncompressedFile) {
|
|
7028
7257
|
const encryptionOverhead = encrypted ? (zipCrypto ? 12 : 16 + encryptionStrength * 4) : 0;
|
|
7029
|
-
extraFieldZip64.
|
|
7258
|
+
extraFieldZip64.writeUint64(passThrough ? 0 : uncompressedSize + encryptionOverhead);
|
|
7030
7259
|
}
|
|
7031
7260
|
}
|
|
7032
7261
|
} else {
|
|
@@ -7035,8 +7264,8 @@
|
|
|
7035
7264
|
let rawExtraFieldAES;
|
|
7036
7265
|
if (encrypted && !zipCrypto) {
|
|
7037
7266
|
const extraFieldAES = createRecordWriter(getLength(EXTRAFIELD_DATA_AES) + 2);
|
|
7038
|
-
extraFieldAES.
|
|
7039
|
-
extraFieldAES.
|
|
7267
|
+
extraFieldAES.writeUint16(EXTRAFIELD_TYPE_AES);
|
|
7268
|
+
extraFieldAES.writeBytes(EXTRAFIELD_DATA_AES);
|
|
7040
7269
|
rawExtraFieldAES = extraFieldAES.array;
|
|
7041
7270
|
rawExtraFieldAES[8] = encryptionStrength;
|
|
7042
7271
|
} else {
|
|
@@ -7052,15 +7281,15 @@
|
|
|
7052
7281
|
const extraFieldTimestampLength = 9 + (lastAccessDate ? 4 : 0) + (creationDate ? 4 : 0);
|
|
7053
7282
|
const extraFieldTimestamp = createRecordWriter(extraFieldTimestampLength);
|
|
7054
7283
|
extraFieldExtendedTimestampFlag = 0x1 + (lastAccessDate ? 0x2 : 0) + (creationDate ? 0x4 : 0);
|
|
7055
|
-
extraFieldTimestamp.
|
|
7056
|
-
extraFieldTimestamp.
|
|
7057
|
-
extraFieldTimestamp.
|
|
7058
|
-
extraFieldTimestamp.
|
|
7284
|
+
extraFieldTimestamp.writeUint16(EXTRAFIELD_TYPE_EXTENDED_TIMESTAMP);
|
|
7285
|
+
extraFieldTimestamp.writeUint16(extraFieldTimestampLength - 4);
|
|
7286
|
+
extraFieldTimestamp.writeUint8(extraFieldExtendedTimestampFlag);
|
|
7287
|
+
extraFieldTimestamp.writeUint32(lastModTimeUnix);
|
|
7059
7288
|
if (lastAccessDate) {
|
|
7060
|
-
extraFieldTimestamp.
|
|
7289
|
+
extraFieldTimestamp.writeUint32(clampUnixTime(getTimeUnix(lastAccessDate)));
|
|
7061
7290
|
}
|
|
7062
7291
|
if (creationDate) {
|
|
7063
|
-
extraFieldTimestamp.
|
|
7292
|
+
extraFieldTimestamp.writeUint32(clampUnixTime(getTimeUnix(creationDate)));
|
|
7064
7293
|
}
|
|
7065
7294
|
rawExtraFieldExtendedTimestamp = extraFieldTimestamp.array;
|
|
7066
7295
|
} else {
|
|
@@ -7073,14 +7302,14 @@
|
|
|
7073
7302
|
try {
|
|
7074
7303
|
const lastModTimeNTFS = getTimeNTFS(lastModDate);
|
|
7075
7304
|
const extraFieldNTFS = createRecordWriter(36);
|
|
7076
|
-
extraFieldNTFS.
|
|
7077
|
-
extraFieldNTFS.
|
|
7305
|
+
extraFieldNTFS.writeUint16(EXTRAFIELD_TYPE_NTFS);
|
|
7306
|
+
extraFieldNTFS.writeUint16(32);
|
|
7078
7307
|
extraFieldNTFS.skip(4);
|
|
7079
|
-
extraFieldNTFS.
|
|
7080
|
-
extraFieldNTFS.
|
|
7081
|
-
extraFieldNTFS.
|
|
7082
|
-
extraFieldNTFS.
|
|
7083
|
-
extraFieldNTFS.
|
|
7308
|
+
extraFieldNTFS.writeUint16(EXTRAFIELD_TYPE_NTFS_TAG1);
|
|
7309
|
+
extraFieldNTFS.writeUint16(24);
|
|
7310
|
+
extraFieldNTFS.writeUint64(lastModTimeNTFS);
|
|
7311
|
+
extraFieldNTFS.writeUint64(lastAccessDate ? getTimeNTFS(lastAccessDate) : lastModTimeNTFS);
|
|
7312
|
+
extraFieldNTFS.writeUint64(creationDate ? getTimeNTFS(creationDate) : lastModTimeNTFS);
|
|
7084
7313
|
rawExtraFieldNTFS = extraFieldNTFS.array;
|
|
7085
7314
|
} catch {
|
|
7086
7315
|
rawExtraFieldNTFS = EMPTY_UINT8_ARRAY;
|
|
@@ -7099,20 +7328,20 @@
|
|
|
7099
7328
|
const gidBytes = packUnixId(gid);
|
|
7100
7329
|
const payloadLength = 3 + uidBytes.length + gidBytes.length;
|
|
7101
7330
|
const extraFieldUnix = createRecordWriter(4 + payloadLength);
|
|
7102
|
-
extraFieldUnix.
|
|
7103
|
-
extraFieldUnix.
|
|
7104
|
-
extraFieldUnix.
|
|
7105
|
-
extraFieldUnix.
|
|
7106
|
-
extraFieldUnix.
|
|
7107
|
-
extraFieldUnix.
|
|
7108
|
-
extraFieldUnix.
|
|
7331
|
+
extraFieldUnix.writeUint16(EXTRAFIELD_TYPE_INFOZIP);
|
|
7332
|
+
extraFieldUnix.writeUint16(payloadLength);
|
|
7333
|
+
extraFieldUnix.writeUint8(1);
|
|
7334
|
+
extraFieldUnix.writeUint8(uidBytes.length);
|
|
7335
|
+
extraFieldUnix.writeBytes(uidBytes);
|
|
7336
|
+
extraFieldUnix.writeUint8(gidBytes.length);
|
|
7337
|
+
extraFieldUnix.writeBytes(gidBytes);
|
|
7109
7338
|
rawExtraFieldUnix = extraFieldUnix.array;
|
|
7110
7339
|
} else if (unixExtraFieldType == UNIX_EXTRA_FIELD_TYPE && (uid !== UNDEFINED_VALUE || gid !== UNDEFINED_VALUE)) {
|
|
7111
7340
|
const extraFieldUnix = createRecordWriter(8);
|
|
7112
|
-
extraFieldUnix.
|
|
7113
|
-
extraFieldUnix.
|
|
7114
|
-
extraFieldUnix.
|
|
7115
|
-
extraFieldUnix.
|
|
7341
|
+
extraFieldUnix.writeUint16(EXTRAFIELD_TYPE_UNIX);
|
|
7342
|
+
extraFieldUnix.writeUint16(4);
|
|
7343
|
+
extraFieldUnix.writeUint16((uid === UNDEFINED_VALUE ? 0 : uid) & MAX_16_BITS);
|
|
7344
|
+
extraFieldUnix.writeUint16((gid === UNDEFINED_VALUE ? 0 : gid) & MAX_16_BITS);
|
|
7116
7345
|
rawExtraFieldUnix = extraFieldUnix.array;
|
|
7117
7346
|
} else {
|
|
7118
7347
|
rawExtraFieldUnix = EMPTY_UINT8_ARRAY;
|
|
@@ -7162,18 +7391,18 @@
|
|
|
7162
7391
|
const localHeader = createRecordWriter(HEADER_SIZE + getLength(rawFilename) + extraFieldLength);
|
|
7163
7392
|
const localHeaderArray = localHeader.array;
|
|
7164
7393
|
const localHeaderView = getDataView(localHeaderArray);
|
|
7165
|
-
localHeader.
|
|
7166
|
-
localHeader.
|
|
7167
|
-
localHeader.
|
|
7394
|
+
localHeader.writeUint32(LOCAL_FILE_HEADER_SIGNATURE);
|
|
7395
|
+
localHeader.writeBytes(headerArray);
|
|
7396
|
+
localHeader.writeBytes(rawFilename);
|
|
7168
7397
|
if (writeLocalExtraFieldZip64) {
|
|
7169
|
-
localHeader.
|
|
7170
|
-
}
|
|
7171
|
-
localHeader.
|
|
7172
|
-
localHeader.
|
|
7173
|
-
localHeader.
|
|
7174
|
-
localHeader.
|
|
7175
|
-
localHeader.
|
|
7176
|
-
localHeader.
|
|
7398
|
+
localHeader.writeBytes(rawLocalExtraFieldZip64);
|
|
7399
|
+
}
|
|
7400
|
+
localHeader.writeBytes(rawExtraFieldAES);
|
|
7401
|
+
localHeader.writeBytes(rawExtraFieldExtendedTimestamp);
|
|
7402
|
+
localHeader.writeBytes(rawExtraFieldNTFS);
|
|
7403
|
+
localHeader.writeBytes(rawExtraFieldUnix);
|
|
7404
|
+
localHeader.writeBytes(rawExtraField);
|
|
7405
|
+
localHeader.writeBytes(rawLocalExtraField);
|
|
7177
7406
|
if (dataDescriptor) {
|
|
7178
7407
|
if (!zip64CompressedSize) {
|
|
7179
7408
|
setUint32(localHeaderView, HEADER_OFFSET_COMPRESSED_SIZE + LOCAL_HEADER_COMMON_OFFSET, 0);
|
|
@@ -7363,7 +7592,7 @@
|
|
|
7363
7592
|
|
|
7364
7593
|
|
|
7365
7594
|
async function closeFile(zipWriter, comment, options) {
|
|
7366
|
-
const directoryDataLength = createDirectoryRecords(zipWriter.
|
|
7595
|
+
const directoryDataLength = createDirectoryRecords(zipWriter.fileEntries);
|
|
7367
7596
|
const { directoryStart, directoryArray } = await writeDirectoryRecords(zipWriter, directoryDataLength, options);
|
|
7368
7597
|
const signatureLength = await writeDigitalSignatureRecord(zipWriter, directoryArray, options);
|
|
7369
7598
|
await writeEndOfDirectoryRecord(zipWriter, comment, options, { directoryStart, directoryDataLength, signatureLength });
|
|
@@ -7393,19 +7622,19 @@
|
|
|
7393
7622
|
if (zip64Offset || zip64DiskNumberStart || zip64UncompressedSize || zip64CompressedSize) {
|
|
7394
7623
|
const length = 4 + (zip64UncompressedSize ? 8 : 0) + (zip64CompressedSize ? 8 : 0) + (zip64Offset ? 8 : 0) + (zip64DiskNumberStart ? 4 : 0);
|
|
7395
7624
|
const extraFieldZip64 = createRecordWriter(length);
|
|
7396
|
-
extraFieldZip64.
|
|
7397
|
-
extraFieldZip64.
|
|
7625
|
+
extraFieldZip64.writeUint16(EXTRAFIELD_TYPE_ZIP64);
|
|
7626
|
+
extraFieldZip64.writeUint16(length - 4);
|
|
7398
7627
|
if (zip64UncompressedSize) {
|
|
7399
|
-
extraFieldZip64.
|
|
7628
|
+
extraFieldZip64.writeUint64(uncompressedSize);
|
|
7400
7629
|
}
|
|
7401
7630
|
if (zip64CompressedSize) {
|
|
7402
|
-
extraFieldZip64.
|
|
7631
|
+
extraFieldZip64.writeUint64(compressedSize);
|
|
7403
7632
|
}
|
|
7404
7633
|
if (zip64Offset) {
|
|
7405
|
-
extraFieldZip64.
|
|
7634
|
+
extraFieldZip64.writeUint64(fileEntry.offset);
|
|
7406
7635
|
}
|
|
7407
7636
|
if (zip64DiskNumberStart) {
|
|
7408
|
-
extraFieldZip64.
|
|
7637
|
+
extraFieldZip64.writeUint32(fileEntry.diskNumberStart);
|
|
7409
7638
|
}
|
|
7410
7639
|
rawExtraFieldZip64 = extraFieldZip64.array;
|
|
7411
7640
|
} else {
|
|
@@ -7418,10 +7647,10 @@
|
|
|
7418
7647
|
const lastModTimeUnix = getTimeUnix(lastModDate);
|
|
7419
7648
|
if (extendedTimestamp && inUnixTimeRange(lastModTimeUnix)) {
|
|
7420
7649
|
const extraFieldTimestamp = createRecordWriter(9);
|
|
7421
|
-
extraFieldTimestamp.
|
|
7422
|
-
extraFieldTimestamp.
|
|
7423
|
-
extraFieldTimestamp.
|
|
7424
|
-
extraFieldTimestamp.
|
|
7650
|
+
extraFieldTimestamp.writeUint16(EXTRAFIELD_TYPE_EXTENDED_TIMESTAMP);
|
|
7651
|
+
extraFieldTimestamp.writeUint16(5);
|
|
7652
|
+
extraFieldTimestamp.writeUint8(extraFieldExtendedTimestampFlag);
|
|
7653
|
+
extraFieldTimestamp.writeUint32(lastModTimeUnix);
|
|
7425
7654
|
rawExtraFieldTimestamp = extraFieldTimestamp.array;
|
|
7426
7655
|
} else {
|
|
7427
7656
|
rawExtraFieldTimestamp = EMPTY_UINT8_ARRAY;
|
|
@@ -7443,14 +7672,14 @@
|
|
|
7443
7672
|
}
|
|
7444
7673
|
|
|
7445
7674
|
async function writeDirectoryRecords(zipWriter, directoryDataLength, options) {
|
|
7446
|
-
const {
|
|
7675
|
+
const { fileEntries, writer } = zipWriter;
|
|
7447
7676
|
const directoryArray = new Uint8Array(directoryDataLength);
|
|
7448
7677
|
await initStream(writer);
|
|
7449
7678
|
let offset = 0;
|
|
7450
7679
|
let directoryDiskOffset = 0;
|
|
7451
7680
|
let directoryStartDiskNumber = getDiskNumber(writer);
|
|
7452
7681
|
let directoryStartDiskOffset = getDiskOffset(writer);
|
|
7453
|
-
for (const [indexFileEntry, fileEntry] of Array.from(
|
|
7682
|
+
for (const [indexFileEntry, fileEntry] of Array.from(fileEntries.values()).entries()) {
|
|
7454
7683
|
const {
|
|
7455
7684
|
offset: fileEntryOffset,
|
|
7456
7685
|
rawFilename,
|
|
@@ -7495,28 +7724,28 @@
|
|
|
7495
7724
|
setUint16(headerView, HEADER_OFFSET_VERSION, VERSION_ZIP64);
|
|
7496
7725
|
}
|
|
7497
7726
|
const directoryRecord = createRecordWriter(directoryRecordLength);
|
|
7498
|
-
directoryRecord.
|
|
7499
|
-
directoryRecord.
|
|
7500
|
-
directoryRecord.
|
|
7501
|
-
directoryRecord.
|
|
7502
|
-
directoryRecord.
|
|
7503
|
-
directoryRecord.
|
|
7504
|
-
directoryRecord.
|
|
7505
|
-
directoryRecord.
|
|
7506
|
-
directoryRecord.
|
|
7507
|
-
directoryRecord.
|
|
7508
|
-
directoryRecord.
|
|
7509
|
-
directoryRecord.
|
|
7510
|
-
directoryRecord.
|
|
7511
|
-
directoryRecord.
|
|
7512
|
-
directoryRecord.
|
|
7513
|
-
directoryRecord.
|
|
7514
|
-
directoryRecord.
|
|
7727
|
+
directoryRecord.writeUint32(CENTRAL_FILE_HEADER_SIGNATURE);
|
|
7728
|
+
directoryRecord.writeUint16(versionMadeBy);
|
|
7729
|
+
directoryRecord.writeBytes(headerArray.subarray(0, HEADER_SIZE - 4 - 2));
|
|
7730
|
+
directoryRecord.writeUint16(extraFieldLength);
|
|
7731
|
+
directoryRecord.writeUint16(getLength(rawComment));
|
|
7732
|
+
directoryRecord.writeUint16(zip64DiskNumberStart ? MAX_16_BITS : diskNumberStart);
|
|
7733
|
+
directoryRecord.writeUint16(internalFileAttributes);
|
|
7734
|
+
directoryRecord.writeUint32(externalFileAttributes);
|
|
7735
|
+
directoryRecord.writeUint32(zip64Offset ? MAX_32_BITS : fileEntryOffset);
|
|
7736
|
+
directoryRecord.writeBytes(rawFilename);
|
|
7737
|
+
directoryRecord.writeBytes(rawExtraFieldZip64);
|
|
7738
|
+
directoryRecord.writeBytes(rawExtraFieldAES);
|
|
7739
|
+
directoryRecord.writeBytes(rawExtraFieldExtendedTimestamp);
|
|
7740
|
+
directoryRecord.writeBytes(rawExtraFieldNTFS);
|
|
7741
|
+
directoryRecord.writeBytes(rawExtraFieldUnix);
|
|
7742
|
+
directoryRecord.writeBytes(rawExtraField);
|
|
7743
|
+
directoryRecord.writeBytes(rawComment);
|
|
7515
7744
|
arraySet(directoryArray, directoryRecord.array, offset);
|
|
7516
7745
|
offset += directoryRecordLength;
|
|
7517
7746
|
if (options.onprogress) {
|
|
7518
7747
|
try {
|
|
7519
|
-
await options.onprogress(indexFileEntry + 1,
|
|
7748
|
+
await options.onprogress(indexFileEntry + 1, fileEntries.size, new Entry(fileEntry));
|
|
7520
7749
|
} catch {
|
|
7521
7750
|
// ignored
|
|
7522
7751
|
}
|
|
@@ -7530,7 +7759,7 @@
|
|
|
7530
7759
|
}
|
|
7531
7760
|
|
|
7532
7761
|
async function writeDigitalSignatureRecord(zipWriter, directoryArray, options) {
|
|
7533
|
-
const signCentralDirectory =
|
|
7762
|
+
const signCentralDirectory = getFunctionOptionValue(zipWriter, options, OPTION_SIGN_CENTRAL_DIRECTORY);
|
|
7534
7763
|
if (signCentralDirectory) {
|
|
7535
7764
|
const signatureData = await signCentralDirectory(directoryArray);
|
|
7536
7765
|
const signatureDataLength = getLength(signatureData);
|
|
@@ -7538,9 +7767,9 @@
|
|
|
7538
7767
|
throw new Error(ERR_INVALID_SIGNATURE_DATA);
|
|
7539
7768
|
}
|
|
7540
7769
|
const signatureRecord = createRecordWriter(6 + signatureDataLength);
|
|
7541
|
-
signatureRecord.
|
|
7542
|
-
signatureRecord.
|
|
7543
|
-
signatureRecord.
|
|
7770
|
+
signatureRecord.writeUint32(DIGITAL_SIGNATURE_RECORD_SIGNATURE);
|
|
7771
|
+
signatureRecord.writeUint16(signatureDataLength);
|
|
7772
|
+
signatureRecord.writeBytes(signatureData);
|
|
7544
7773
|
await writeData(zipWriter.writer, signatureRecord.array);
|
|
7545
7774
|
return 6 + signatureDataLength;
|
|
7546
7775
|
}
|
|
@@ -7551,7 +7780,7 @@
|
|
|
7551
7780
|
const { writer } = zipWriter;
|
|
7552
7781
|
const { directoryStart, signatureLength } = cdInfo;
|
|
7553
7782
|
let { directoryDataLength } = cdInfo;
|
|
7554
|
-
let
|
|
7783
|
+
let fileEntriesLength = zipWriter.fileEntries.size;
|
|
7555
7784
|
let diskNumber = directoryStart.diskNumber;
|
|
7556
7785
|
let directoryOffset = getSegmentOffset(zipWriter, directoryStart);
|
|
7557
7786
|
let lastDiskNumber = getDiskNumber(writer);
|
|
@@ -7559,7 +7788,7 @@
|
|
|
7559
7788
|
lastDiskNumber++;
|
|
7560
7789
|
}
|
|
7561
7790
|
let zip64 = getOptionValue(zipWriter, options, PROPERTY_NAME_ZIP64);
|
|
7562
|
-
if (directoryOffset >= MAX_32_BITS || directoryDataLength >= MAX_32_BITS ||
|
|
7791
|
+
if (directoryOffset >= MAX_32_BITS || directoryDataLength >= MAX_32_BITS || fileEntriesLength >= MAX_16_BITS || lastDiskNumber >= MAX_16_BITS) {
|
|
7563
7792
|
if (zip64 === false) {
|
|
7564
7793
|
throw new Error(ERR_UNSUPPORTED_FORMAT);
|
|
7565
7794
|
} else {
|
|
@@ -7576,37 +7805,37 @@
|
|
|
7576
7805
|
}
|
|
7577
7806
|
lastDiskNumber = getDiskNumber(writer);
|
|
7578
7807
|
if (zip64) {
|
|
7579
|
-
endOfdirectoryRecord.
|
|
7580
|
-
endOfdirectoryRecord.
|
|
7581
|
-
endOfdirectoryRecord.
|
|
7582
|
-
endOfdirectoryRecord.
|
|
7583
|
-
endOfdirectoryRecord.
|
|
7584
|
-
endOfdirectoryRecord.
|
|
7585
|
-
endOfdirectoryRecord.
|
|
7586
|
-
endOfdirectoryRecord.
|
|
7587
|
-
endOfdirectoryRecord.
|
|
7588
|
-
endOfdirectoryRecord.
|
|
7589
|
-
endOfdirectoryRecord.
|
|
7590
|
-
endOfdirectoryRecord.
|
|
7591
|
-
endOfdirectoryRecord.
|
|
7592
|
-
endOfdirectoryRecord.
|
|
7808
|
+
endOfdirectoryRecord.writeUint32(ZIP64_END_OF_CENTRAL_DIR_SIGNATURE);
|
|
7809
|
+
endOfdirectoryRecord.writeUint64(44);
|
|
7810
|
+
endOfdirectoryRecord.writeUint16(45);
|
|
7811
|
+
endOfdirectoryRecord.writeUint16(45);
|
|
7812
|
+
endOfdirectoryRecord.writeUint32(lastDiskNumber);
|
|
7813
|
+
endOfdirectoryRecord.writeUint32(diskNumber);
|
|
7814
|
+
endOfdirectoryRecord.writeUint64(fileEntriesLength);
|
|
7815
|
+
endOfdirectoryRecord.writeUint64(fileEntriesLength);
|
|
7816
|
+
endOfdirectoryRecord.writeUint64(directoryDataLength);
|
|
7817
|
+
endOfdirectoryRecord.writeUint64(directoryOffset);
|
|
7818
|
+
endOfdirectoryRecord.writeUint32(ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIGNATURE);
|
|
7819
|
+
endOfdirectoryRecord.writeUint32(lastDiskNumber);
|
|
7820
|
+
endOfdirectoryRecord.writeUint64(BigInt(getSegmentOffset(zipWriter, writer)) + BigInt(directoryDataLength) + BigInt(signatureLength));
|
|
7821
|
+
endOfdirectoryRecord.writeUint32(lastDiskNumber + 1);
|
|
7593
7822
|
const supportZip64SplitFile = getOptionValue(zipWriter, options, OPTION_SUPPORT_ZIP64_SPLIT_FILE, true);
|
|
7594
7823
|
if (supportZip64SplitFile) {
|
|
7595
7824
|
lastDiskNumber = MAX_16_BITS;
|
|
7596
7825
|
diskNumber = MAX_16_BITS;
|
|
7597
7826
|
}
|
|
7598
|
-
|
|
7827
|
+
fileEntriesLength = MAX_16_BITS;
|
|
7599
7828
|
directoryOffset = MAX_32_BITS;
|
|
7600
7829
|
directoryDataLength = MAX_32_BITS;
|
|
7601
7830
|
}
|
|
7602
|
-
endOfdirectoryRecord.
|
|
7603
|
-
endOfdirectoryRecord.
|
|
7604
|
-
endOfdirectoryRecord.
|
|
7605
|
-
endOfdirectoryRecord.
|
|
7606
|
-
endOfdirectoryRecord.
|
|
7607
|
-
endOfdirectoryRecord.
|
|
7608
|
-
endOfdirectoryRecord.
|
|
7609
|
-
endOfdirectoryRecord.
|
|
7831
|
+
endOfdirectoryRecord.writeUint32(END_OF_CENTRAL_DIR_SIGNATURE);
|
|
7832
|
+
endOfdirectoryRecord.writeUint16(lastDiskNumber);
|
|
7833
|
+
endOfdirectoryRecord.writeUint16(diskNumber);
|
|
7834
|
+
endOfdirectoryRecord.writeUint16(fileEntriesLength);
|
|
7835
|
+
endOfdirectoryRecord.writeUint16(fileEntriesLength);
|
|
7836
|
+
endOfdirectoryRecord.writeUint32(directoryDataLength);
|
|
7837
|
+
endOfdirectoryRecord.writeUint32(directoryOffset);
|
|
7838
|
+
endOfdirectoryRecord.writeUint16(commentLength);
|
|
7610
7839
|
await writeData(writer, endOfdirectoryRecord.array);
|
|
7611
7840
|
if (commentLength) {
|
|
7612
7841
|
await writeData(writer, comment);
|
|
@@ -7619,11 +7848,11 @@
|
|
|
7619
7848
|
let offset = 0;
|
|
7620
7849
|
return {
|
|
7621
7850
|
array,
|
|
7622
|
-
|
|
7623
|
-
|
|
7624
|
-
|
|
7625
|
-
|
|
7626
|
-
|
|
7851
|
+
writeUint8: value => { setUint8(view, offset, value); offset += 1; },
|
|
7852
|
+
writeUint16: value => { setUint16(view, offset, value); offset += 2; },
|
|
7853
|
+
writeUint32: value => { setUint32(view, offset, value); offset += 4; },
|
|
7854
|
+
writeUint64: value => { setBigUint64(view, offset, BigInt(value)); offset += 8; },
|
|
7855
|
+
writeBytes: value => { arraySet(array, value, offset); offset += getLength(value); },
|
|
7627
7856
|
skip: count => offset += count
|
|
7628
7857
|
};
|
|
7629
7858
|
}
|
|
@@ -7647,6 +7876,71 @@
|
|
|
7647
7876
|
return zipWriter.offset - diskOffset - (diskNumber ? zipWriter.initialOffset : 0);
|
|
7648
7877
|
}
|
|
7649
7878
|
|
|
7879
|
+
async function startsWithSplitZipSignature(reader) {
|
|
7880
|
+
const signatureArray = await readUint8Array(reader, 0, SPLIT_ZIP_FILE_SIGNATURE_LENGTH);
|
|
7881
|
+
return getUint32(getDataView(signatureArray), 0) == SPLIT_ZIP_FILE_SIGNATURE;
|
|
7882
|
+
}
|
|
7883
|
+
|
|
7884
|
+
async function copyZipData(zipWriter, reader, entries, directoryOffset, splitZipSignatureLength) {
|
|
7885
|
+
const { writer } = zipWriter;
|
|
7886
|
+
const entryPositions = new Map();
|
|
7887
|
+
if (writer.closeDisk) {
|
|
7888
|
+
const sortedEntries = Array.from(entries).sort((firstEntry, secondEntry) =>
|
|
7889
|
+
getSourceOffset(reader, firstEntry) - getSourceOffset(reader, secondEntry));
|
|
7890
|
+
let copiedLength = 0;
|
|
7891
|
+
for (const entry of sortedEntries) {
|
|
7892
|
+
const sourceOffset = getSourceOffset(reader, entry);
|
|
7893
|
+
await copyData(zipWriter, reader, copiedLength, sourceOffset - copiedLength);
|
|
7894
|
+
if (exceedsAvailableSize(writer, await getLocalHeaderLength(reader, sourceOffset))) {
|
|
7895
|
+
await writer.closeDisk();
|
|
7896
|
+
}
|
|
7897
|
+
entryPositions.set(entry, {
|
|
7898
|
+
offset: getSegmentOffset(zipWriter, writer),
|
|
7899
|
+
diskNumberStart: getDiskNumber(writer)
|
|
7900
|
+
});
|
|
7901
|
+
copiedLength = sourceOffset;
|
|
7902
|
+
}
|
|
7903
|
+
await copyData(zipWriter, reader, copiedLength, directoryOffset - copiedLength);
|
|
7904
|
+
} else {
|
|
7905
|
+
await copyData(zipWriter, reader, 0, directoryOffset);
|
|
7906
|
+
entries.forEach(entry => entryPositions.set(entry, {
|
|
7907
|
+
offset: splitZipSignatureLength + getSourceOffset(reader, entry),
|
|
7908
|
+
diskNumberStart: 0
|
|
7909
|
+
}));
|
|
7910
|
+
}
|
|
7911
|
+
return entryPositions;
|
|
7912
|
+
}
|
|
7913
|
+
|
|
7914
|
+
async function copyData(zipWriter, reader, offset, size) {
|
|
7915
|
+
if (size > 0) {
|
|
7916
|
+
const { writer } = zipWriter;
|
|
7917
|
+
await createReadable(reader, { offset, size }).pipeTo(writer.writable, { preventClose: true, preventAbort: true });
|
|
7918
|
+
writer.size += size;
|
|
7919
|
+
zipWriter.offset += size;
|
|
7920
|
+
}
|
|
7921
|
+
}
|
|
7922
|
+
|
|
7923
|
+
async function getLocalHeaderLength(reader, offset) {
|
|
7924
|
+
const headerArray = await readUint8Array(reader, offset, HEADER_SIZE);
|
|
7925
|
+
if (getLength(headerArray) < HEADER_SIZE) {
|
|
7926
|
+
return HEADER_SIZE;
|
|
7927
|
+
}
|
|
7928
|
+
const headerView = getDataView(headerArray);
|
|
7929
|
+
return HEADER_SIZE +
|
|
7930
|
+
getUint16(headerView, HEADER_OFFSET_FILENAME_LENGTH + LOCAL_HEADER_COMMON_OFFSET) +
|
|
7931
|
+
getUint16(headerView, HEADER_OFFSET_EXTRAFIELD_LENGTH + LOCAL_HEADER_COMMON_OFFSET);
|
|
7932
|
+
}
|
|
7933
|
+
|
|
7934
|
+
function getSourceOffset(reader, { offset, diskNumberStart }) {
|
|
7935
|
+
return offset + (reader.getDiskOffset ? reader.getDiskOffset(diskNumberStart) : 0);
|
|
7936
|
+
}
|
|
7937
|
+
|
|
7938
|
+
function getSplitZipSignatureArray() {
|
|
7939
|
+
const signatureArray = new Uint8Array(SPLIT_ZIP_FILE_SIGNATURE_LENGTH);
|
|
7940
|
+
setUint32(getDataView(signatureArray), 0, SPLIT_ZIP_FILE_SIGNATURE);
|
|
7941
|
+
return signatureArray;
|
|
7942
|
+
}
|
|
7943
|
+
|
|
7650
7944
|
async function writeData(writer, array) {
|
|
7651
7945
|
const { writable } = writer;
|
|
7652
7946
|
const streamWriter = writable.getWriter();
|
|
@@ -7698,6 +7992,21 @@
|
|
|
7698
7992
|
return result === UNDEFINED_VALUE ? defaultValue : result;
|
|
7699
7993
|
}
|
|
7700
7994
|
|
|
7995
|
+
function getDateOptionValue(zipWriter, options, name, defaultValue) {
|
|
7996
|
+
const date = getOptionValue(zipWriter, options, name, defaultValue);
|
|
7997
|
+
if (date === null) {
|
|
7998
|
+
return defaultValue;
|
|
7999
|
+
}
|
|
8000
|
+
if (date !== UNDEFINED_VALUE && (typeof date.getTime != FUNCTION_TYPE || Number.isNaN(date.getTime()))) {
|
|
8001
|
+
throw new Error(ERR_INVALID_DATE);
|
|
8002
|
+
}
|
|
8003
|
+
return date;
|
|
8004
|
+
}
|
|
8005
|
+
|
|
8006
|
+
function getFunctionOptionValue(zipWriter, options, name) {
|
|
8007
|
+
return checkFunctionOption(getOptionValue(zipWriter, options, name));
|
|
8008
|
+
}
|
|
8009
|
+
|
|
7701
8010
|
function getAliasedOptionValue(zipWriter, options, name, deprecatedName, defaultValue) {
|
|
7702
8011
|
const value = getAliasedValue(options, name, deprecatedName);
|
|
7703
8012
|
const result = value === UNDEFINED_VALUE ? getAliasedValue(zipWriter.options, name, deprecatedName) : value;
|
|
@@ -7712,9 +8021,6 @@
|
|
|
7712
8021
|
return toNumber(getOptionValue(zipWriter, options, name, defaultValue));
|
|
7713
8022
|
}
|
|
7714
8023
|
|
|
7715
|
-
function toNumber(value) {
|
|
7716
|
-
return typeof value == STRING_TYPE && value.trim() ? Number(value) : value;
|
|
7717
|
-
}
|
|
7718
8024
|
|
|
7719
8025
|
function getMaximumCompressedSize(uncompressedSize) {
|
|
7720
8026
|
return uncompressedSize + (5 * (Math.floor(uncompressedSize / 16383) + 1));
|
|
@@ -7726,6 +8032,14 @@
|
|
|
7726
8032
|
: compressionMethod !== COMPRESSION_METHOD_STORE;
|
|
7727
8033
|
}
|
|
7728
8034
|
|
|
8035
|
+
function getUint16(view, offset) {
|
|
8036
|
+
return view.getUint16(offset, true);
|
|
8037
|
+
}
|
|
8038
|
+
|
|
8039
|
+
function getUint32(view, offset) {
|
|
8040
|
+
return view.getUint32(offset, true);
|
|
8041
|
+
}
|
|
8042
|
+
|
|
7729
8043
|
function setUint8(view, offset, value) {
|
|
7730
8044
|
view.setUint8(offset, value);
|
|
7731
8045
|
}
|
|
@@ -7769,9 +8083,9 @@
|
|
|
7769
8083
|
const headerRecord = createRecordWriter(HEADER_SIZE - 4);
|
|
7770
8084
|
const headerArray = headerRecord.array;
|
|
7771
8085
|
const headerView = getDataView(headerArray);
|
|
7772
|
-
headerRecord.
|
|
7773
|
-
headerRecord.
|
|
7774
|
-
headerRecord.
|
|
8086
|
+
headerRecord.writeUint16(version);
|
|
8087
|
+
headerRecord.writeUint16(bitFlag);
|
|
8088
|
+
headerRecord.writeUint16(compressionMethod);
|
|
7775
8089
|
if (rawLastModDate === UNDEFINED_VALUE) {
|
|
7776
8090
|
const dateArray = new Uint32Array(1);
|
|
7777
8091
|
const dateView = getDataView(dateArray);
|
|
@@ -7779,20 +8093,20 @@
|
|
|
7779
8093
|
setUint16(dateView, 2, ((((lastModDate.getFullYear() - 1980) << 4) | (lastModDate.getMonth() + 1)) << 5) | lastModDate.getDate());
|
|
7780
8094
|
rawLastModDate = dateArray[0];
|
|
7781
8095
|
}
|
|
7782
|
-
headerRecord.
|
|
8096
|
+
headerRecord.writeUint32(rawLastModDate);
|
|
7783
8097
|
headerRecord.skip(4);
|
|
7784
8098
|
if (zip64CompressedSize || compressedSize !== UNDEFINED_VALUE) {
|
|
7785
|
-
headerRecord.
|
|
8099
|
+
headerRecord.writeUint32(zip64CompressedSize ? MAX_32_BITS : compressedSize);
|
|
7786
8100
|
} else {
|
|
7787
8101
|
headerRecord.skip(4);
|
|
7788
8102
|
}
|
|
7789
8103
|
if (zip64UncompressedSize || uncompressedSize !== UNDEFINED_VALUE) {
|
|
7790
|
-
headerRecord.
|
|
8104
|
+
headerRecord.writeUint32(zip64UncompressedSize ? MAX_32_BITS : uncompressedSize);
|
|
7791
8105
|
} else {
|
|
7792
8106
|
headerRecord.skip(4);
|
|
7793
8107
|
}
|
|
7794
|
-
headerRecord.
|
|
7795
|
-
headerRecord.
|
|
8108
|
+
headerRecord.writeUint16(getLength(rawFilename));
|
|
8109
|
+
headerRecord.writeUint16(extraFieldLength);
|
|
7796
8110
|
return {
|
|
7797
8111
|
headerArray,
|
|
7798
8112
|
headerView,
|
|
@@ -8740,6 +9054,7 @@
|
|
|
8740
9054
|
const ERR_ENTRY_EXISTS = "Entry filename already exists";
|
|
8741
9055
|
const ERR_READABLE_CONSUMED = "Readable stream already consumed";
|
|
8742
9056
|
const ERR_INVALID_PASS_THROUGH = "Invalid passThrough option (use readerOptions.passThrough or set uncompressedSize for each entry)";
|
|
9057
|
+
const ERR_INVALID_READER_OPTIONS = "Invalid readerOptions (must be an object)";
|
|
8743
9058
|
const ERR_ABORT_EXPORT = "zipjs-abort-export";
|
|
8744
9059
|
const ERR_ABORTED = "The operation was aborted";
|
|
8745
9060
|
const ABORT_ERROR_NAME = "AbortError";
|
|
@@ -8772,13 +9087,14 @@
|
|
|
8772
9087
|
fs,
|
|
8773
9088
|
name,
|
|
8774
9089
|
data: params.data,
|
|
8775
|
-
options: params.options,
|
|
9090
|
+
options: params.options && Object.assign({}, params.options),
|
|
8776
9091
|
id: fs.entryIdCounter++,
|
|
8777
9092
|
parent,
|
|
8778
9093
|
children: [],
|
|
8779
9094
|
uncompressedSize: params.uncompressedSize || 0,
|
|
8780
9095
|
undeterminedSize: params.undeterminedSize || params.uncompressedSize === UNDEFINED_VALUE,
|
|
8781
|
-
passThrough: params.passThrough
|
|
9096
|
+
passThrough: params.passThrough,
|
|
9097
|
+
defaultLastModDate: params.defaultLastModDate || new Date()
|
|
8782
9098
|
});
|
|
8783
9099
|
if (parent || !fs.root) {
|
|
8784
9100
|
fs.entries[zipEntry.id] = zipEntry;
|
|
@@ -8788,12 +9104,6 @@
|
|
|
8788
9104
|
}
|
|
8789
9105
|
}
|
|
8790
9106
|
|
|
8791
|
-
moveTo(target) {
|
|
8792
|
-
// deprecated
|
|
8793
|
-
const zipEntry = this;
|
|
8794
|
-
zipEntry.fs.move(zipEntry, target);
|
|
8795
|
-
}
|
|
8796
|
-
|
|
8797
9107
|
getFullname() {
|
|
8798
9108
|
return this.getRelativeName();
|
|
8799
9109
|
}
|
|
@@ -8825,6 +9135,11 @@
|
|
|
8825
9135
|
this.name = name;
|
|
8826
9136
|
}
|
|
8827
9137
|
}
|
|
9138
|
+
|
|
9139
|
+
setOptions(options) {
|
|
9140
|
+
const entryOptions = Object.assign({}, this.options, options);
|
|
9141
|
+
this.options = Object.fromEntries(Object.entries(entryOptions).filter(([, value]) => value !== UNDEFINED_VALUE));
|
|
9142
|
+
}
|
|
8828
9143
|
}
|
|
8829
9144
|
|
|
8830
9145
|
class ZipFileEntry extends ZipEntry {
|
|
@@ -8851,7 +9166,7 @@
|
|
|
8851
9166
|
const reader = zipEntry.reader = createReader(zipEntry.Reader, zipEntry.data, options);
|
|
8852
9167
|
const dataSize = zipEntry.uncompressedSize || reader.size;
|
|
8853
9168
|
await Promise.all([initStream(reader), initStream(writer, dataSize)]);
|
|
8854
|
-
const
|
|
9169
|
+
const signal = checkSignalOption(options.signal);
|
|
8855
9170
|
const readable = createProgressReadable(zipEntry, reader, options, signal);
|
|
8856
9171
|
const preventClose = !ownsWritable(writer) && Boolean(options.preventClose);
|
|
8857
9172
|
zipEntry.uncompressedSize = reader.size;
|
|
@@ -9069,10 +9384,6 @@
|
|
|
9069
9384
|
});
|
|
9070
9385
|
}
|
|
9071
9386
|
|
|
9072
|
-
addData(name, params) {
|
|
9073
|
-
return addChild(this, name, params);
|
|
9074
|
-
}
|
|
9075
|
-
|
|
9076
9387
|
importBlob(blob, options) {
|
|
9077
9388
|
return this.importZip(new BlobReader(blob), options);
|
|
9078
9389
|
}
|
|
@@ -9186,7 +9497,7 @@
|
|
|
9186
9497
|
if (options.bufferedWrite === UNDEFINED_VALUE) {
|
|
9187
9498
|
options.bufferedWrite = true;
|
|
9188
9499
|
}
|
|
9189
|
-
const [readers] = await Promise.all([initReaders(zipEntry, options.readerOptions), initStream(writer)]);
|
|
9500
|
+
const [readers] = await Promise.all([initReaders(zipEntry, checkReaderOptions(options.readerOptions)), initStream(writer)]);
|
|
9190
9501
|
const zipWriter = new ZipWriter(writer, options);
|
|
9191
9502
|
await exportZip(zipWriter, zipEntry, getTotalSize([zipEntry], getUncompressedSize), options, readers);
|
|
9192
9503
|
await zipWriter.close(options.globalComment);
|
|
@@ -9196,12 +9507,13 @@
|
|
|
9196
9507
|
getExportedSize(options = {}) {
|
|
9197
9508
|
const zipEntry = this;
|
|
9198
9509
|
options = Object.assign({}, options);
|
|
9510
|
+
checkReaderOptions(options.readerOptions);
|
|
9199
9511
|
if (options.bufferedWrite === UNDEFINED_VALUE) {
|
|
9200
9512
|
options.bufferedWrite = true;
|
|
9201
9513
|
}
|
|
9202
9514
|
const writeOrderGuaranteed = !options.bufferedWrite ||
|
|
9203
9515
|
(options.keepOrder !== false && zipEntry.children.every(child => !child.children.length));
|
|
9204
|
-
return getEntriesSize(options,
|
|
9516
|
+
return getEntriesSize(options, zipEntry.getChildren({ recursive: true }).filter(child => !isImplicitDirectory(child)).map(child => {
|
|
9205
9517
|
const { name, entryOptions } = getChildEntryOptions(child, zipEntry, options);
|
|
9206
9518
|
return { name, size: child.directory ? 0 : getDeterminedSize(child, isPassThrough(child, options)), options: entryOptions };
|
|
9207
9519
|
}), writeOrderGuaranteed, options.globalComment);
|
|
@@ -9240,7 +9552,7 @@
|
|
|
9240
9552
|
}
|
|
9241
9553
|
|
|
9242
9554
|
|
|
9243
|
-
class
|
|
9555
|
+
class ZipFS {
|
|
9244
9556
|
|
|
9245
9557
|
constructor() {
|
|
9246
9558
|
resetFS(this);
|
|
@@ -9356,10 +9668,6 @@
|
|
|
9356
9668
|
return this.root.addFile(file, options);
|
|
9357
9669
|
}
|
|
9358
9670
|
|
|
9359
|
-
addData(name, params) {
|
|
9360
|
-
return this.root.addData(name, params);
|
|
9361
|
-
}
|
|
9362
|
-
|
|
9363
9671
|
importBlob(blob, options) {
|
|
9364
9672
|
resetFS(this);
|
|
9365
9673
|
return this.root.importBlob(blob, options);
|
|
@@ -9427,7 +9735,7 @@
|
|
|
9427
9735
|
}
|
|
9428
9736
|
}
|
|
9429
9737
|
|
|
9430
|
-
const fs = { FS, ZipDirectoryEntry, ZipFileEntry };
|
|
9738
|
+
const fs = { FS: ZipFS, ZipDirectoryEntry, ZipFileEntry };
|
|
9431
9739
|
|
|
9432
9740
|
function getTotalSize(entries, getEntrySize) {
|
|
9433
9741
|
let size = 0;
|
|
@@ -9571,7 +9879,7 @@
|
|
|
9571
9879
|
}
|
|
9572
9880
|
|
|
9573
9881
|
function forwardAbort(signal, abortController) {
|
|
9574
|
-
if (!signal) {
|
|
9882
|
+
if (!checkSignalOption(signal)) {
|
|
9575
9883
|
return () => { };
|
|
9576
9884
|
}
|
|
9577
9885
|
if (signal.aborted) {
|
|
@@ -9667,7 +9975,7 @@
|
|
|
9667
9975
|
};
|
|
9668
9976
|
}
|
|
9669
9977
|
}
|
|
9670
|
-
const entryOptions = Object.assign({}, zipEntryMetadata, options,
|
|
9978
|
+
const entryOptions = Object.assign({ lastModDate: child.defaultLastModDate }, zipEntryMetadata, options, childOptions, passThroughOptions, { directory: child.directory });
|
|
9671
9979
|
if (!child.directory && entryOptions.passThrough && entryOptions.uncompressedSize === UNDEFINED_VALUE) {
|
|
9672
9980
|
throw new Error(ERR_INVALID_PASS_THROUGH);
|
|
9673
9981
|
}
|
|
@@ -9682,11 +9990,22 @@
|
|
|
9682
9990
|
return child.undeterminedSize ? UNDEFINED_VALUE : getExtractedSize(child, passThrough);
|
|
9683
9991
|
}
|
|
9684
9992
|
|
|
9993
|
+
function checkReaderOptions(readerOptions) {
|
|
9994
|
+
if (readerOptions && (typeof readerOptions != OBJECT_TYPE || Array.isArray(readerOptions))) {
|
|
9995
|
+
throw new Error(ERR_INVALID_READER_OPTIONS);
|
|
9996
|
+
}
|
|
9997
|
+
return readerOptions;
|
|
9998
|
+
}
|
|
9999
|
+
|
|
9685
10000
|
function isPassThrough(child, options) {
|
|
9686
10001
|
const { readerOptions } = options;
|
|
9687
10002
|
return Boolean(!child.directory && (child.passThrough || (readerOptions && readerOptions.passThrough)));
|
|
9688
10003
|
}
|
|
9689
10004
|
|
|
10005
|
+
function isImplicitDirectory(child) {
|
|
10006
|
+
return child.directory && child.data === null;
|
|
10007
|
+
}
|
|
10008
|
+
|
|
9690
10009
|
function getUserExtraField(extraField) {
|
|
9691
10010
|
if (extraField) {
|
|
9692
10011
|
const userExtraField = new Map();
|
|
@@ -9704,7 +10023,7 @@
|
|
|
9704
10023
|
async function exportZip(zipWriter, entry, totalSize, options, readers) {
|
|
9705
10024
|
const { onstart, onprogress, onend, onentryprogress } = options;
|
|
9706
10025
|
const selectedEntry = entry;
|
|
9707
|
-
const totalEntries = getTotalSize(entry.children, ()
|
|
10026
|
+
const totalEntries = getTotalSize(entry.children, child => isImplicitDirectory(child) ? 0 : 1);
|
|
9708
10027
|
let writtenSize = 0;
|
|
9709
10028
|
let writtenEntries = 0;
|
|
9710
10029
|
if (onstart) {
|
|
@@ -9733,6 +10052,9 @@
|
|
|
9733
10052
|
}
|
|
9734
10053
|
|
|
9735
10054
|
async function addChild(child) {
|
|
10055
|
+
if (isImplicitDirectory(child)) {
|
|
10056
|
+
return;
|
|
10057
|
+
}
|
|
9736
10058
|
const { name, entryOptions } = getChildEntryOptions(child, selectedEntry, options);
|
|
9737
10059
|
let entryWrittenSize = 0;
|
|
9738
10060
|
const entryMetadata = await zipWriter.add(name, readers.get(child), Object.assign(entryOptions, {
|
|
@@ -9766,7 +10088,7 @@
|
|
|
9766
10088
|
if (handle.kind == "file") {
|
|
9767
10089
|
const file = await handle.getFile();
|
|
9768
10090
|
addedEntries.push(
|
|
9769
|
-
parentEntry
|
|
10091
|
+
addChild(parentEntry, file.name, {
|
|
9770
10092
|
Reader: function () {
|
|
9771
10093
|
const readable = file.stream();
|
|
9772
10094
|
const size = file.size;
|
|
@@ -9800,10 +10122,11 @@
|
|
|
9800
10122
|
|
|
9801
10123
|
async function exportFileSystemHandle(zipEntry, directoryHandle, options) {
|
|
9802
10124
|
const { onstart, onprogress, onend } = options;
|
|
10125
|
+
const readerOptions = checkReaderOptions(options.readerOptions);
|
|
9803
10126
|
const abortController = new AbortController();
|
|
9804
10127
|
const { signal } = abortController;
|
|
9805
10128
|
const releaseSignal = forwardAbort(options.signal, abortController);
|
|
9806
|
-
const getDataOptions = Object.assign({}, options,
|
|
10129
|
+
const getDataOptions = Object.assign({}, options, readerOptions, {
|
|
9807
10130
|
signal,
|
|
9808
10131
|
onstart: UNDEFINED_VALUE,
|
|
9809
10132
|
onprogress: UNDEFINED_VALUE,
|
|
@@ -10103,6 +10426,7 @@
|
|
|
10103
10426
|
exports.ERR_DUPLICATED_NAME = ERR_DUPLICATED_NAME;
|
|
10104
10427
|
exports.ERR_ENCRYPTED = ERR_ENCRYPTED;
|
|
10105
10428
|
exports.ERR_ENCRYPTED_CENTRAL_DIRECTORY = ERR_ENCRYPTED_CENTRAL_DIRECTORY;
|
|
10429
|
+
exports.ERR_ENTRY_DATA_OUT_OF_BOUNDS = ERR_ENTRY_DATA_OUT_OF_BOUNDS;
|
|
10106
10430
|
exports.ERR_ENTRY_EXISTS = ERR_ENTRY_EXISTS;
|
|
10107
10431
|
exports.ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND = ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND;
|
|
10108
10432
|
exports.ERR_EOCDR_NOT_FOUND = ERR_EOCDR_NOT_FOUND;
|
|
@@ -10113,22 +10437,31 @@
|
|
|
10113
10437
|
exports.ERR_INVALID_CODEC_DEFINITION = ERR_INVALID_CODEC_DEFINITION;
|
|
10114
10438
|
exports.ERR_INVALID_CODEC_MODULE = ERR_INVALID_CODEC_MODULE;
|
|
10115
10439
|
exports.ERR_INVALID_COMMENT = ERR_INVALID_COMMENT;
|
|
10440
|
+
exports.ERR_INVALID_COMMENT_TYPE = ERR_INVALID_COMMENT_TYPE;
|
|
10116
10441
|
exports.ERR_INVALID_COMPRESSED_DATA = ERR_INVALID_COMPRESSED_DATA;
|
|
10117
10442
|
exports.ERR_INVALID_CRC32 = ERR_INVALID_CRC32;
|
|
10443
|
+
exports.ERR_INVALID_DATE = ERR_INVALID_DATE;
|
|
10118
10444
|
exports.ERR_INVALID_ENCRYPTION_STRENGTH = ERR_INVALID_ENCRYPTION_STRENGTH;
|
|
10119
10445
|
exports.ERR_INVALID_ENTRY_COMMENT = ERR_INVALID_ENTRY_COMMENT;
|
|
10446
|
+
exports.ERR_INVALID_ENTRY_COMMENT_TYPE = ERR_INVALID_ENTRY_COMMENT_TYPE;
|
|
10120
10447
|
exports.ERR_INVALID_ENTRY_NAME = ERR_INVALID_ENTRY_NAME;
|
|
10448
|
+
exports.ERR_INVALID_EXTRAFIELD = ERR_INVALID_EXTRAFIELD;
|
|
10121
10449
|
exports.ERR_INVALID_EXTRAFIELD_DATA = ERR_INVALID_EXTRAFIELD_DATA;
|
|
10450
|
+
exports.ERR_INVALID_EXTRAFIELD_DATA_TYPE = ERR_INVALID_EXTRAFIELD_DATA_TYPE;
|
|
10122
10451
|
exports.ERR_INVALID_EXTRAFIELD_TYPE = ERR_INVALID_EXTRAFIELD_TYPE;
|
|
10123
10452
|
exports.ERR_INVALID_FILENAME_VALIDATION = ERR_INVALID_FILENAME_VALIDATION;
|
|
10453
|
+
exports.ERR_INVALID_FUNCTION_OPTION = ERR_INVALID_FUNCTION_OPTION;
|
|
10124
10454
|
exports.ERR_INVALID_GID = ERR_INVALID_GID;
|
|
10125
10455
|
exports.ERR_INVALID_LEVEL = ERR_INVALID_LEVEL;
|
|
10126
10456
|
exports.ERR_INVALID_MAX_APPENDED_DATA_SIZE = ERR_INVALID_MAX_APPENDED_DATA_SIZE;
|
|
10457
|
+
exports.ERR_INVALID_MAX_WORKERS = ERR_INVALID_MAX_WORKERS;
|
|
10127
10458
|
exports.ERR_INVALID_MSDOS_ATTRIBUTES = ERR_INVALID_MSDOS_ATTRIBUTES;
|
|
10128
10459
|
exports.ERR_INVALID_MSDOS_DATA = ERR_INVALID_MSDOS_DATA;
|
|
10129
10460
|
exports.ERR_INVALID_PASSWORD = ERR_INVALID_PASSWORD;
|
|
10130
10461
|
exports.ERR_INVALID_PASSWORD_TYPE = ERR_INVALID_PASSWORD_TYPE;
|
|
10131
10462
|
exports.ERR_INVALID_PASS_THROUGH = ERR_INVALID_PASS_THROUGH;
|
|
10463
|
+
exports.ERR_INVALID_READER_OPTIONS = ERR_INVALID_READER_OPTIONS;
|
|
10464
|
+
exports.ERR_INVALID_SIGNAL = ERR_INVALID_SIGNAL;
|
|
10132
10465
|
exports.ERR_INVALID_SIGNATURE = ERR_INVALID_SIGNATURE;
|
|
10133
10466
|
exports.ERR_INVALID_SIGNATURE_DATA = ERR_INVALID_SIGNATURE_DATA;
|
|
10134
10467
|
exports.ERR_INVALID_STRICTNESS = ERR_INVALID_STRICTNESS;
|
|
@@ -10168,6 +10501,10 @@
|
|
|
10168
10501
|
exports.Uint8ArrayReader = Uint8ArrayReader;
|
|
10169
10502
|
exports.Uint8ArrayWriter = Uint8ArrayWriter;
|
|
10170
10503
|
exports.Writer = Writer;
|
|
10504
|
+
exports.ZipDirectoryEntry = ZipDirectoryEntry;
|
|
10505
|
+
exports.ZipEntry = ZipEntry;
|
|
10506
|
+
exports.ZipFS = ZipFS;
|
|
10507
|
+
exports.ZipFileEntry = ZipFileEntry;
|
|
10171
10508
|
exports.ZipReader = ZipReader;
|
|
10172
10509
|
exports.ZipReaderStream = ZipReaderStream;
|
|
10173
10510
|
exports.ZipWriter = ZipWriter;
|