@zip.js/zip.js 2.8.53 → 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 +691 -482
- package/dist/zip-core-external.min.js +1 -1
- package/dist/zip-core.js +698 -481
- package/dist/zip-core.min.js +1 -1
- package/dist/zip-fs-core-external.js +729 -511
- package/dist/zip-fs-core-external.min.js +1 -1
- package/dist/zip-fs-core.js +691 -496
- package/dist/zip-fs-core.min.js +1 -1
- package/dist/zip-fs-external.js +729 -511
- package/dist/zip-fs-external.min.js +1 -1
- package/dist/zip-fs-native.js +743 -512
- package/dist/zip-fs-native.min.js +1 -1
- package/dist/zip-fs.js +742 -511
- package/dist/zip-fs.min.js +1 -1
- package/dist/zip-legacy.js +700 -483
- package/dist/zip-legacy.min.js +1 -1
- package/dist/zip-native.js +700 -483
- 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 +699 -482
- package/dist/zip.min.js +1 -1
- package/eslint.config.mjs +1 -0
- package/index-native.cjs +743 -512
- package/index-native.min.js +1 -1
- package/index.cjs +742 -511
- package/index.d.cts +398 -42
- package/index.d.ts +398 -42
- package/index.min.js +1 -1
- package/lib/core/configuration.js +62 -21
- package/lib/core/constants.js +11 -1
- package/lib/core/io.js +33 -27
- package/lib/core/options.js +44 -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-fs.js +38 -27
- package/lib/core/zip-reader.js +58 -26
- package/lib/core/zip-writer.js +293 -177
- package/lib/zip-core-base.js +6 -1
- package/lib/zip-core-reader.js +1 -0
- package/lib/zip-core-writer.js +4 -0
- package/package.json +8 -2
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;
|
|
@@ -112,6 +114,8 @@
|
|
|
112
114
|
const HEADER_OFFSET_SIGNATURE = 10;
|
|
113
115
|
const HEADER_OFFSET_COMPRESSED_SIZE = 14;
|
|
114
116
|
const HEADER_OFFSET_UNCOMPRESSED_SIZE = 18;
|
|
117
|
+
const HEADER_OFFSET_FILENAME_LENGTH = 22;
|
|
118
|
+
const HEADER_OFFSET_EXTRAFIELD_LENGTH = 24;
|
|
115
119
|
const LOCAL_HEADER_COMMON_OFFSET = 4;
|
|
116
120
|
|
|
117
121
|
const MAX_DATE = new Date(2107, 11, 31, 23, 59, 58);
|
|
@@ -124,9 +128,116 @@
|
|
|
124
128
|
const OBJECT_TYPE = "object";
|
|
125
129
|
const STRING_TYPE = "string";
|
|
126
130
|
const NUMBER_TYPE = "number";
|
|
131
|
+
const BOOLEAN_TYPE = "boolean";
|
|
127
132
|
|
|
128
133
|
const EMPTY_UINT8_ARRAY = new Uint8Array();
|
|
129
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
|
+
|
|
130
241
|
/*
|
|
131
242
|
Copyright (c) 2025 Gildas Lormeau. All rights reserved.
|
|
132
243
|
|
|
@@ -156,7 +267,10 @@
|
|
|
156
267
|
*/
|
|
157
268
|
|
|
158
269
|
|
|
270
|
+
const DEFAULT_CHUNK_SIZE$1 = 64 * 1024;
|
|
159
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)";
|
|
160
274
|
let maxWorkers = 2;
|
|
161
275
|
try {
|
|
162
276
|
if (typeof navigator != UNDEFINED_TYPE && navigator.hardwareConcurrency) {
|
|
@@ -168,7 +282,7 @@
|
|
|
168
282
|
const DEFAULT_CONFIGURATION = {
|
|
169
283
|
workerURI: "./core/web-worker-wasm.js",
|
|
170
284
|
wasmURI: "./core/streams/zlib-wasm/zlib-streams.wasm",
|
|
171
|
-
chunkSize:
|
|
285
|
+
chunkSize: DEFAULT_CHUNK_SIZE$1,
|
|
172
286
|
maxWorkers,
|
|
173
287
|
terminateWorkerTimeout: 5000,
|
|
174
288
|
workerStarvationTimeout: 5000,
|
|
@@ -180,24 +294,38 @@
|
|
|
180
294
|
DecompressionStream: typeof DecompressionStream != UNDEFINED_TYPE && DecompressionStream
|
|
181
295
|
};
|
|
182
296
|
|
|
183
|
-
const
|
|
297
|
+
const PROPERTY_NAME_MAX_WORKERS = "maxWorkers";
|
|
298
|
+
|
|
299
|
+
const STRING_PROPERTY_NAMES = [
|
|
184
300
|
"baseURI",
|
|
185
301
|
"wasmURI",
|
|
186
|
-
"workerURI"
|
|
187
|
-
|
|
302
|
+
"workerURI"
|
|
303
|
+
];
|
|
304
|
+
const BOOLEAN_PROPERTY_NAMES = [
|
|
305
|
+
"useCompressionStream",
|
|
306
|
+
"useWebWorkers",
|
|
307
|
+
"transferStreams"
|
|
308
|
+
];
|
|
309
|
+
const NUMBER_PROPERTY_NAMES = [
|
|
188
310
|
"chunkSize",
|
|
189
|
-
|
|
311
|
+
PROPERTY_NAME_MAX_WORKERS,
|
|
190
312
|
"terminateWorkerTimeout",
|
|
191
313
|
"workerStarvationTimeout",
|
|
192
|
-
"workerStartupTimeout"
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
"
|
|
314
|
+
"workerStartupTimeout"
|
|
315
|
+
];
|
|
316
|
+
const FUNCTION_PROPERTY_NAMES = [
|
|
317
|
+
"createWorker",
|
|
196
318
|
"CompressionStream",
|
|
197
319
|
"DecompressionStream",
|
|
198
320
|
"CompressionStreamFallback",
|
|
199
321
|
"DecompressionStreamFallback"
|
|
200
322
|
];
|
|
323
|
+
const CONFIGURABLE_PROPERTY_NAMES = [
|
|
324
|
+
...STRING_PROPERTY_NAMES,
|
|
325
|
+
...BOOLEAN_PROPERTY_NAMES,
|
|
326
|
+
...NUMBER_PROPERTY_NAMES,
|
|
327
|
+
...FUNCTION_PROPERTY_NAMES
|
|
328
|
+
];
|
|
201
329
|
|
|
202
330
|
const config = { ...DEFAULT_CONFIGURATION };
|
|
203
331
|
|
|
@@ -206,20 +334,43 @@
|
|
|
206
334
|
}
|
|
207
335
|
|
|
208
336
|
function getChunkSize(config) {
|
|
209
|
-
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;
|
|
210
343
|
}
|
|
211
344
|
|
|
212
345
|
function configure(configuration) {
|
|
213
|
-
|
|
346
|
+
Object.assign(config, checkConfiguration(normalizeConfiguration(configuration)));
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
function checkConfiguration(configuration) {
|
|
350
|
+
const checkedConfiguration = {};
|
|
214
351
|
for (const propertyName of CONFIGURABLE_PROPERTY_NAMES) {
|
|
215
352
|
const propertyValue = configuration[propertyName];
|
|
216
353
|
if (propertyValue !== UNDEFINED_VALUE) {
|
|
217
|
-
|
|
354
|
+
checkedConfiguration[propertyName] = checkPropertyValue(propertyName, propertyValue);
|
|
218
355
|
}
|
|
219
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);
|
|
365
|
+
}
|
|
366
|
+
} else if (FUNCTION_PROPERTY_NAMES.includes(propertyName)) {
|
|
367
|
+
checkFunctionOption(propertyValue);
|
|
368
|
+
}
|
|
369
|
+
return propertyValue;
|
|
220
370
|
}
|
|
221
371
|
|
|
222
372
|
function normalizeConfiguration(configuration) {
|
|
373
|
+
configuration = configuration || {};
|
|
223
374
|
const { CompressionStreamZlib, DecompressionStreamZlib } = configuration;
|
|
224
375
|
if (CompressionStreamZlib === UNDEFINED_VALUE && DecompressionStreamZlib === UNDEFINED_VALUE) {
|
|
225
376
|
return configuration;
|
|
@@ -235,14 +386,9 @@
|
|
|
235
386
|
}
|
|
236
387
|
|
|
237
388
|
function setDefaultConfiguration(configuration) {
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
if (propertyValue !== UNDEFINED_VALUE) {
|
|
242
|
-
DEFAULT_CONFIGURATION[propertyName] = propertyValue;
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
configure(configuration);
|
|
389
|
+
const checkedConfiguration = checkConfiguration(normalizeConfiguration(configuration));
|
|
390
|
+
Object.assign(DEFAULT_CONFIGURATION, checkedConfiguration);
|
|
391
|
+
Object.assign(config, checkedConfiguration);
|
|
246
392
|
}
|
|
247
393
|
|
|
248
394
|
function resetConfiguration() {
|
|
@@ -252,7 +398,7 @@
|
|
|
252
398
|
Object.assign(config, DEFAULT_CONFIGURATION);
|
|
253
399
|
}
|
|
254
400
|
|
|
255
|
-
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)}});
|
|
256
402
|
|
|
257
403
|
/*
|
|
258
404
|
Copyright (c) 2026 Gildas Lormeau. All rights reserved.
|
|
@@ -1400,13 +1546,13 @@
|
|
|
1400
1546
|
const {
|
|
1401
1547
|
ctr,
|
|
1402
1548
|
hmac,
|
|
1403
|
-
|
|
1549
|
+
pendingInput,
|
|
1404
1550
|
ready
|
|
1405
1551
|
} = this;
|
|
1406
1552
|
if (hmac && ctr) {
|
|
1407
1553
|
await ready;
|
|
1408
|
-
const chunkToDecrypt = subarray(
|
|
1409
|
-
const originalAuthenticationCode = subarray(
|
|
1554
|
+
const chunkToDecrypt = subarray(pendingInput, 0, pendingInput.length - AUTHENTICATION_CODE_LENGTH);
|
|
1555
|
+
const originalAuthenticationCode = subarray(pendingInput, pendingInput.length - AUTHENTICATION_CODE_LENGTH);
|
|
1410
1556
|
let decryptedChunkArray = EMPTY_UINT8_ARRAY;
|
|
1411
1557
|
if (chunkToDecrypt.length) {
|
|
1412
1558
|
const encryptedChunk = toBits(codecBytes, chunkToDecrypt);
|
|
@@ -1415,7 +1561,7 @@
|
|
|
1415
1561
|
decryptedChunkArray = fromBits(codecBytes, decryptedChunk);
|
|
1416
1562
|
}
|
|
1417
1563
|
const authenticationCode = subarray(fromBits(codecBytes, hmac.digest()), 0, AUTHENTICATION_CODE_LENGTH);
|
|
1418
|
-
let invalidAuthenticationCode =
|
|
1564
|
+
let invalidAuthenticationCode = pendingInput.length < AUTHENTICATION_CODE_LENGTH ? 1 : 0;
|
|
1419
1565
|
for (let indexByte = 0; indexByte < AUTHENTICATION_CODE_LENGTH; indexByte++) {
|
|
1420
1566
|
invalidAuthenticationCode |= authenticationCode[indexByte] ^ originalAuthenticationCode[indexByte];
|
|
1421
1567
|
}
|
|
@@ -1459,14 +1605,14 @@
|
|
|
1459
1605
|
const {
|
|
1460
1606
|
ctr,
|
|
1461
1607
|
hmac,
|
|
1462
|
-
|
|
1608
|
+
pendingInput,
|
|
1463
1609
|
ready
|
|
1464
1610
|
} = this;
|
|
1465
1611
|
if (hmac && ctr) {
|
|
1466
1612
|
await ready;
|
|
1467
1613
|
let encryptedChunkArray = EMPTY_UINT8_ARRAY;
|
|
1468
|
-
if (
|
|
1469
|
-
const encryptedChunk = ctr.update(toBits(codecBytes,
|
|
1614
|
+
if (pendingInput.length) {
|
|
1615
|
+
const encryptedChunk = ctr.update(toBits(codecBytes, pendingInput));
|
|
1470
1616
|
hmac.update(encryptedChunk);
|
|
1471
1617
|
encryptedChunkArray = fromBits(codecBytes, encryptedChunk);
|
|
1472
1618
|
}
|
|
@@ -1483,7 +1629,7 @@
|
|
|
1483
1629
|
ready: new Promise(resolve => aesCrypto.resolveReady = resolve),
|
|
1484
1630
|
password: encodePassword(password, rawPassword),
|
|
1485
1631
|
strength: encryptionStrength - 1,
|
|
1486
|
-
|
|
1632
|
+
pendingInput: EMPTY_UINT8_ARRAY
|
|
1487
1633
|
});
|
|
1488
1634
|
}
|
|
1489
1635
|
|
|
@@ -1491,10 +1637,10 @@
|
|
|
1491
1637
|
const {
|
|
1492
1638
|
ctr,
|
|
1493
1639
|
hmac,
|
|
1494
|
-
|
|
1640
|
+
pendingInput
|
|
1495
1641
|
} = aesCrypto;
|
|
1496
|
-
if (
|
|
1497
|
-
input = concat(
|
|
1642
|
+
if (pendingInput.length) {
|
|
1643
|
+
input = concat(pendingInput, input);
|
|
1498
1644
|
}
|
|
1499
1645
|
const inputLength = input.length - paddingEnd;
|
|
1500
1646
|
output = expand(output, paddingStart + (inputLength - (inputLength % BLOCK_LENGTH)));
|
|
@@ -1510,7 +1656,7 @@
|
|
|
1510
1656
|
}
|
|
1511
1657
|
output.set(fromBits(codecBytes, outputChunk), offset + paddingStart);
|
|
1512
1658
|
}
|
|
1513
|
-
aesCrypto.
|
|
1659
|
+
aesCrypto.pendingInput = subarray(input, offset);
|
|
1514
1660
|
return output;
|
|
1515
1661
|
}
|
|
1516
1662
|
|
|
@@ -3287,6 +3433,96 @@
|
|
|
3287
3433
|
resetWebWorkerSupport();
|
|
3288
3434
|
}
|
|
3289
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
|
+
|
|
3290
3526
|
/*
|
|
3291
3527
|
Copyright (c) 2025 Gildas Lormeau. All rights reserved.
|
|
3292
3528
|
|
|
@@ -3359,6 +3595,7 @@
|
|
|
3359
3595
|
createReadable({ offset = 0, size, chunkSize = getChunkSize(getConfiguration()) } = {}) {
|
|
3360
3596
|
const reader = this;
|
|
3361
3597
|
let chunkOffset = 0;
|
|
3598
|
+
chunkSize = normalizeChunkSize(chunkSize);
|
|
3362
3599
|
return new ReadableStream({
|
|
3363
3600
|
async pull(controller) {
|
|
3364
3601
|
const dataSize = size === UNDEFINED_VALUE ? chunkSize : Math.min(chunkSize, size - chunkOffset);
|
|
@@ -3366,7 +3603,7 @@
|
|
|
3366
3603
|
if (data.length) {
|
|
3367
3604
|
controller.enqueue(data);
|
|
3368
3605
|
}
|
|
3369
|
-
if ((chunkOffset + chunkSize >= size) || (
|
|
3606
|
+
if ((chunkOffset + chunkSize >= size) || (!data.length && dataSize)) {
|
|
3370
3607
|
controller.close();
|
|
3371
3608
|
} else {
|
|
3372
3609
|
chunkOffset += chunkSize;
|
|
@@ -3446,31 +3683,31 @@
|
|
|
3446
3683
|
Object.assign(this, {
|
|
3447
3684
|
contentType,
|
|
3448
3685
|
data: "data:" + (contentType || "") + ";base64,",
|
|
3449
|
-
|
|
3686
|
+
pendingCharacters: ""
|
|
3450
3687
|
});
|
|
3451
3688
|
}
|
|
3452
3689
|
|
|
3453
3690
|
writeUint8Array(array) {
|
|
3454
3691
|
const writer = this;
|
|
3455
3692
|
let indexArray;
|
|
3456
|
-
let dataString = writer.
|
|
3457
|
-
const delta = writer.
|
|
3458
|
-
writer.
|
|
3693
|
+
let dataString = writer.pendingCharacters;
|
|
3694
|
+
const delta = writer.pendingCharacters.length;
|
|
3695
|
+
writer.pendingCharacters = "";
|
|
3459
3696
|
for (indexArray = 0; indexArray < (Math.floor((delta + array.length) / 3) * 3) - delta; indexArray++) {
|
|
3460
3697
|
dataString += String.fromCharCode(array[indexArray]);
|
|
3461
3698
|
}
|
|
3462
3699
|
for (; indexArray < array.length; indexArray++) {
|
|
3463
|
-
writer.
|
|
3700
|
+
writer.pendingCharacters += String.fromCharCode(array[indexArray]);
|
|
3464
3701
|
}
|
|
3465
3702
|
if (dataString.length > 2) {
|
|
3466
3703
|
writer.data += btoa(dataString);
|
|
3467
3704
|
} else {
|
|
3468
|
-
writer.
|
|
3705
|
+
writer.pendingCharacters = dataString + writer.pendingCharacters;
|
|
3469
3706
|
}
|
|
3470
3707
|
}
|
|
3471
3708
|
|
|
3472
3709
|
getData() {
|
|
3473
|
-
return this.data + btoa(this.
|
|
3710
|
+
return this.data + btoa(this.pendingCharacters);
|
|
3474
3711
|
}
|
|
3475
3712
|
}
|
|
3476
3713
|
|
|
@@ -3500,7 +3737,7 @@
|
|
|
3500
3737
|
constructor(blob) {
|
|
3501
3738
|
super();
|
|
3502
3739
|
Object.assign(this, {
|
|
3503
|
-
blob,
|
|
3740
|
+
sourceBlob: blob,
|
|
3504
3741
|
size: blob.size
|
|
3505
3742
|
});
|
|
3506
3743
|
if (!blobSliceProbe) {
|
|
@@ -3510,13 +3747,13 @@
|
|
|
3510
3747
|
|
|
3511
3748
|
createReadable(options) {
|
|
3512
3749
|
const reader = this;
|
|
3513
|
-
const {
|
|
3750
|
+
const { sourceBlob, size } = reader;
|
|
3514
3751
|
const { offset = 0, size: readSize = size - offset } = options || {};
|
|
3515
3752
|
if (!offset && readSize >= size) {
|
|
3516
|
-
return toCompatibleReadable(
|
|
3753
|
+
return toCompatibleReadable(sourceBlob.stream());
|
|
3517
3754
|
}
|
|
3518
3755
|
if (blobSliceReliable) {
|
|
3519
|
-
return toCompatibleReadable(
|
|
3756
|
+
return toCompatibleReadable(sourceBlob.slice(offset, offset + readSize).stream());
|
|
3520
3757
|
}
|
|
3521
3758
|
return super.createReadable(options);
|
|
3522
3759
|
}
|
|
@@ -3525,7 +3762,7 @@
|
|
|
3525
3762
|
const reader = this;
|
|
3526
3763
|
const offsetEnd = offset + length;
|
|
3527
3764
|
const readsWholeBlob = !offset && offsetEnd >= reader.size;
|
|
3528
|
-
const blob = readsWholeBlob ? reader.
|
|
3765
|
+
const blob = readsWholeBlob ? reader.sourceBlob : reader.sourceBlob.slice(offset, offsetEnd);
|
|
3529
3766
|
let arrayBuffer = await blob.arrayBuffer();
|
|
3530
3767
|
const sliceIgnoredByBuggyImplementation = arrayBuffer.byteLength > length;
|
|
3531
3768
|
if (sliceIgnoredByBuggyImplementation) {
|
|
@@ -3547,12 +3784,12 @@
|
|
|
3547
3784
|
}
|
|
3548
3785
|
});
|
|
3549
3786
|
writer.contentType = contentType;
|
|
3550
|
-
writer.
|
|
3551
|
-
writer.
|
|
3787
|
+
writer.blobPromise = streamToBlob(transformStream.readable, contentType);
|
|
3788
|
+
writer.blobPromise.catch(() => { });
|
|
3552
3789
|
}
|
|
3553
3790
|
|
|
3554
3791
|
getData() {
|
|
3555
|
-
return this.
|
|
3792
|
+
return this.blobPromise;
|
|
3556
3793
|
}
|
|
3557
3794
|
}
|
|
3558
3795
|
|
|
@@ -3586,7 +3823,7 @@
|
|
|
3586
3823
|
class TextWriter extends BlobWriter {
|
|
3587
3824
|
|
|
3588
3825
|
constructor(encoding) {
|
|
3589
|
-
super(
|
|
3826
|
+
super();
|
|
3590
3827
|
Object.assign(this, {
|
|
3591
3828
|
encoding,
|
|
3592
3829
|
utf8: !encoding || encoding.toLowerCase() == "utf-8"
|
|
@@ -3602,14 +3839,7 @@
|
|
|
3602
3839
|
if (blob.text && utf8) {
|
|
3603
3840
|
return blob.text();
|
|
3604
3841
|
} else {
|
|
3605
|
-
|
|
3606
|
-
return new Promise((resolve, reject) => {
|
|
3607
|
-
Object.assign(reader, {
|
|
3608
|
-
onload: ({ target }) => resolve(target.result),
|
|
3609
|
-
onerror: () => reject(reader.error)
|
|
3610
|
-
});
|
|
3611
|
-
reader.readAsText(blob, encoding);
|
|
3612
|
-
});
|
|
3842
|
+
return decodeTextRemovingBOM(new Uint8Array(await blob.arrayBuffer()), encoding);
|
|
3613
3843
|
}
|
|
3614
3844
|
}
|
|
3615
3845
|
}
|
|
@@ -4277,85 +4507,13 @@
|
|
|
4277
4507
|
return reader.readUint8Array(offset, size);
|
|
4278
4508
|
}
|
|
4279
4509
|
|
|
4280
|
-
|
|
4281
|
-
|
|
4282
|
-
|
|
4283
|
-
|
|
4284
|
-
|
|
4285
|
-
|
|
4286
|
-
1. Redistributions of source code must retain the above copyright notice,
|
|
4287
|
-
this list of conditions and the following disclaimer.
|
|
4288
|
-
|
|
4289
|
-
2. Redistributions in binary form must reproduce the above copyright
|
|
4290
|
-
notice, this list of conditions and the following disclaimer in
|
|
4291
|
-
the documentation and/or other materials provided with the distribution.
|
|
4292
|
-
|
|
4293
|
-
3. The names of the authors may not be used to endorse or promote products
|
|
4294
|
-
derived from this software without specific prior written permission.
|
|
4295
|
-
|
|
4296
|
-
THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
|
4297
|
-
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
4298
|
-
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
|
|
4299
|
-
INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
4300
|
-
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
4301
|
-
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
|
4302
|
-
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
4303
|
-
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
4304
|
-
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
|
4305
|
-
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
4306
|
-
*/
|
|
4307
|
-
|
|
4308
|
-
/* global TextDecoder */
|
|
4309
|
-
|
|
4310
|
-
const CP437 = "\0☺☻♥♦♣♠•◘○◙♂♀♪♫☼►◄↕‼¶§▬↨↑↓→←∟↔▲▼ !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~⌂ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥₧ƒáíóúñѪº¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ ".split("");
|
|
4311
|
-
const VALID_CP437 = CP437.length == 256;
|
|
4312
|
-
|
|
4313
|
-
function decodeCP437(stringValue) {
|
|
4314
|
-
if (VALID_CP437) {
|
|
4315
|
-
let result = "";
|
|
4316
|
-
for (let indexCharacter = 0; indexCharacter < stringValue.length; indexCharacter++) {
|
|
4317
|
-
result += CP437[stringValue[indexCharacter]];
|
|
4318
|
-
}
|
|
4319
|
-
return result;
|
|
4320
|
-
} else {
|
|
4321
|
-
return new TextDecoder().decode(stringValue);
|
|
4322
|
-
}
|
|
4323
|
-
}
|
|
4324
|
-
|
|
4325
|
-
/*
|
|
4326
|
-
Copyright (c) 2022 Gildas Lormeau. All rights reserved.
|
|
4327
|
-
|
|
4328
|
-
Redistribution and use in source and binary forms, with or without
|
|
4329
|
-
modification, are permitted provided that the following conditions are met:
|
|
4330
|
-
|
|
4331
|
-
1. Redistributions of source code must retain the above copyright notice,
|
|
4332
|
-
this list of conditions and the following disclaimer.
|
|
4333
|
-
|
|
4334
|
-
2. Redistributions in binary form must reproduce the above copyright
|
|
4335
|
-
notice, this list of conditions and the following disclaimer in
|
|
4336
|
-
the documentation and/or other materials provided with the distribution.
|
|
4337
|
-
|
|
4338
|
-
3. The names of the authors may not be used to endorse or promote products
|
|
4339
|
-
derived from this software without specific prior written permission.
|
|
4340
|
-
|
|
4341
|
-
THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
|
4342
|
-
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
4343
|
-
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
|
|
4344
|
-
INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
4345
|
-
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
4346
|
-
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
|
4347
|
-
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
4348
|
-
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
4349
|
-
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
|
4350
|
-
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
4351
|
-
*/
|
|
4352
|
-
|
|
4353
|
-
|
|
4354
|
-
function decodeText(value, encoding) {
|
|
4355
|
-
if (encoding && encoding.trim().toLowerCase() == "cp437") {
|
|
4356
|
-
return decodeCP437(value);
|
|
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);
|
|
4357
4515
|
} else {
|
|
4358
|
-
return
|
|
4516
|
+
return reader.readable;
|
|
4359
4517
|
}
|
|
4360
4518
|
}
|
|
4361
4519
|
|
|
@@ -4515,83 +4673,6 @@
|
|
|
4515
4673
|
|
|
4516
4674
|
}
|
|
4517
4675
|
|
|
4518
|
-
/*
|
|
4519
|
-
Copyright (c) 2022 Gildas Lormeau. All rights reserved.
|
|
4520
|
-
|
|
4521
|
-
Redistribution and use in source and binary forms, with or without
|
|
4522
|
-
modification, are permitted provided that the following conditions are met:
|
|
4523
|
-
|
|
4524
|
-
1. Redistributions of source code must retain the above copyright notice,
|
|
4525
|
-
this list of conditions and the following disclaimer.
|
|
4526
|
-
|
|
4527
|
-
2. Redistributions in binary form must reproduce the above copyright
|
|
4528
|
-
notice, this list of conditions and the following disclaimer in
|
|
4529
|
-
the documentation and/or other materials provided with the distribution.
|
|
4530
|
-
|
|
4531
|
-
3. The names of the authors may not be used to endorse or promote products
|
|
4532
|
-
derived from this software without specific prior written permission.
|
|
4533
|
-
|
|
4534
|
-
THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
|
4535
|
-
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
4536
|
-
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
|
|
4537
|
-
INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
4538
|
-
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
4539
|
-
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
|
4540
|
-
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
4541
|
-
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
4542
|
-
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
|
4543
|
-
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
4544
|
-
*/
|
|
4545
|
-
|
|
4546
|
-
const OPTION_FILENAME_ENCODING = "filenameEncoding";
|
|
4547
|
-
const OPTION_COMMENT_ENCODING = "commentEncoding";
|
|
4548
|
-
const OPTION_DECODE_TEXT = "decodeText";
|
|
4549
|
-
const OPTION_EXTRACT_PREPENDED_DATA = "extractPrependedData";
|
|
4550
|
-
const OPTION_EXTRACT_APPENDED_DATA = "extractAppendedData";
|
|
4551
|
-
const OPTION_PASSWORD = "password";
|
|
4552
|
-
const OPTION_RAW_PASSWORD = "rawPassword";
|
|
4553
|
-
const OPTION_PASS_THROUGH = "passThrough";
|
|
4554
|
-
const OPTION_SIGNAL = "signal";
|
|
4555
|
-
const OPTION_CHECK_PASSWORD_ONLY = "checkPasswordOnly";
|
|
4556
|
-
const OPTION_CHECK_OVERLAPPING_ENTRY_ONLY = "checkOverlappingEntryOnly";
|
|
4557
|
-
const OPTION_CHECK_OVERLAPPING_ENTRY = "checkOverlappingEntry";
|
|
4558
|
-
const OPTION_CHECK_AMBIGUITY = "checkAmbiguity";
|
|
4559
|
-
const OPTION_CHECK_LOCAL_DIRECTORY = "checkLocalDirectory";
|
|
4560
|
-
const OPTION_CHECK_SIGNATURE = "checkSignature";
|
|
4561
|
-
const OPTION_CHECK_CRC32 = "checkCrc32";
|
|
4562
|
-
const OPTION_CHECK_AUTHENTICATION_CODE = "checkAuthenticationCode";
|
|
4563
|
-
const OPTION_USE_WEB_WORKERS = "useWebWorkers";
|
|
4564
|
-
const OPTION_USE_COMPRESSION_STREAM = "useCompressionStream";
|
|
4565
|
-
const OPTION_TRANSFER_STREAMS = "transferStreams";
|
|
4566
|
-
const OPTION_PREVENT_CLOSE = "preventClose";
|
|
4567
|
-
const OPTION_ENCRYPTION_STRENGTH = "encryptionStrength";
|
|
4568
|
-
const OPTION_EXTENDED_TIMESTAMP = "extendedTimestamp";
|
|
4569
|
-
const OPTION_NTFS_TIMESTAMP = "ntfsTimestamp";
|
|
4570
|
-
const OPTION_KEEP_ORDER = "keepOrder";
|
|
4571
|
-
const OPTION_LEVEL = "level";
|
|
4572
|
-
const OPTION_BUFFERED_WRITE = "bufferedWrite";
|
|
4573
|
-
const OPTION_CREATE_TEMP_STREAM = "createTempStream";
|
|
4574
|
-
const OPTION_DATA_DESCRIPTOR_SIGNATURE = "dataDescriptorSignature";
|
|
4575
|
-
const OPTION_USE_UNICODE_FILE_NAMES = "useUnicodeFileNames";
|
|
4576
|
-
const OPTION_DATA_DESCRIPTOR = "dataDescriptor";
|
|
4577
|
-
const OPTION_SUPPORT_ZIP64_SPLIT_FILE = "supportZip64SplitFile";
|
|
4578
|
-
const OPTION_ENCODE_TEXT = "encodeText";
|
|
4579
|
-
const OPTION_OFFSET = "offset";
|
|
4580
|
-
const OPTION_USDZ = "usdz";
|
|
4581
|
-
const OPTION_UNIX_EXTRA_FIELD_TYPE = "unixExtraFieldType";
|
|
4582
|
-
const OPTION_LOCAL_EXTRA_FIELD = "localExtraField";
|
|
4583
|
-
const OPTION_STRICTNESS = "strictness";
|
|
4584
|
-
const OPTION_FILENAME_VALIDATION = "filenameValidation";
|
|
4585
|
-
const OPTION_NORMALIZE_FILENAME = "normalizeFilename";
|
|
4586
|
-
const OPTION_MAX_APPENDED_DATA_SIZE = "maxAppendedDataSize";
|
|
4587
|
-
const OPTION_DECRYPT_CENTRAL_DIRECTORY = "decryptCentralDirectory";
|
|
4588
|
-
const OPTION_SIGN_CENTRAL_DIRECTORY = "signCentralDirectory";
|
|
4589
|
-
const TEXT_TYPE_FILENAME = "filename";
|
|
4590
|
-
const TEXT_TYPE_COMMENT = "comment";
|
|
4591
|
-
const STRICTNESS_STRICT = "strict";
|
|
4592
|
-
const STRICTNESS_BALANCED = "balanced";
|
|
4593
|
-
const STRICTNESS_TOLERANT = "tolerant";
|
|
4594
|
-
|
|
4595
4676
|
/*
|
|
4596
4677
|
Copyright (c) 2025 Gildas Lormeau. All rights reserved.
|
|
4597
4678
|
|
|
@@ -4632,6 +4713,7 @@
|
|
|
4632
4713
|
const ERR_UNSUPPORTED_COMPRESSION$1 = "Compression method not supported";
|
|
4633
4714
|
const ERR_SPLIT_ZIP_FILE = "Split zip file";
|
|
4634
4715
|
const ERR_OVERLAPPING_ENTRY = "Overlapping entry found";
|
|
4716
|
+
const ERR_ENTRY_DATA_OUT_OF_BOUNDS = "Entry data out of bounds";
|
|
4635
4717
|
const ERR_AMBIGUOUS_ARCHIVE = "Ambiguous archive";
|
|
4636
4718
|
const ERR_ENCRYPTED_CENTRAL_DIRECTORY = "Encrypted central directory is not supported";
|
|
4637
4719
|
const ERR_UNSAFE_FILENAME = "Unsafe filename";
|
|
@@ -4652,7 +4734,7 @@
|
|
|
4652
4734
|
];
|
|
4653
4735
|
const ZIP64_EXTRACTION = {
|
|
4654
4736
|
[MAX_16_BITS]: {
|
|
4655
|
-
getValue: getUint32,
|
|
4737
|
+
getValue: getUint32$1,
|
|
4656
4738
|
bytes: 4
|
|
4657
4739
|
},
|
|
4658
4740
|
[MAX_32_BITS]: {
|
|
@@ -4661,6 +4743,7 @@
|
|
|
4661
4743
|
}
|
|
4662
4744
|
};
|
|
4663
4745
|
const MAX_END_OF_CENTRAL_DIR_PROBES = 64;
|
|
4746
|
+
const MAX_DEFLATE_EXPANSION_RATIO = 1032;
|
|
4664
4747
|
const CENTRAL_DIRECTORY_UNREACHABLE = 0;
|
|
4665
4748
|
const CENTRAL_DIRECTORY_PLAUSIBLE = 1;
|
|
4666
4749
|
const CENTRAL_DIRECTORY_REACHABLE = 2;
|
|
@@ -4671,7 +4754,6 @@
|
|
|
4671
4754
|
Object.assign(this, {
|
|
4672
4755
|
reader: new GenericReader(reader),
|
|
4673
4756
|
options,
|
|
4674
|
-
config: getConfiguration(),
|
|
4675
4757
|
readRanges: new Map()
|
|
4676
4758
|
});
|
|
4677
4759
|
}
|
|
@@ -4679,7 +4761,6 @@
|
|
|
4679
4761
|
async* getEntriesGenerator(options = {}) {
|
|
4680
4762
|
const zipReader = this;
|
|
4681
4763
|
let { reader } = zipReader;
|
|
4682
|
-
const { config } = zipReader;
|
|
4683
4764
|
await initStream(reader);
|
|
4684
4765
|
if (reader.size === UNDEFINED_VALUE || !reader.readUint8Array) {
|
|
4685
4766
|
reader = new BlobReader(await streamToBlob(reader.readable));
|
|
@@ -4696,9 +4777,7 @@
|
|
|
4696
4777
|
const normalizeFilename = getOptionValue$1(zipReader, options, OPTION_NORMALIZE_FILENAME);
|
|
4697
4778
|
const { endOfDirectoryInfo, endOfDirectoryReachingEndCount } = await findEndOfCentralDirectory(reader, rejectAmbiguousEndOfDirectory, maxAppendedDataSize);
|
|
4698
4779
|
if (!endOfDirectoryInfo) {
|
|
4699
|
-
|
|
4700
|
-
const signatureView = getDataView(signatureArray);
|
|
4701
|
-
if (getUint32(signatureView) == SPLIT_ZIP_FILE_SIGNATURE) {
|
|
4780
|
+
if (await startsWithSplitZipSignature$1(reader)) {
|
|
4702
4781
|
throw new Error(ERR_SPLIT_ZIP_FILE);
|
|
4703
4782
|
} else {
|
|
4704
4783
|
throw new Error(ERR_EOCDR_NOT_FOUND);
|
|
@@ -4708,18 +4787,18 @@
|
|
|
4708
4787
|
throwAmbiguousArchive("multiple end of central directory records");
|
|
4709
4788
|
}
|
|
4710
4789
|
const endOfDirectoryView = getDataView(endOfDirectoryInfo);
|
|
4711
|
-
let directoryDataLength = getUint32(endOfDirectoryView, 12);
|
|
4712
|
-
let directoryDataOffset = getUint32(endOfDirectoryView, 16);
|
|
4790
|
+
let directoryDataLength = getUint32$1(endOfDirectoryView, 12);
|
|
4791
|
+
let directoryDataOffset = getUint32$1(endOfDirectoryView, 16);
|
|
4713
4792
|
const commentOffset = endOfDirectoryInfo.offset;
|
|
4714
|
-
const commentLength = getUint16(endOfDirectoryView, 20);
|
|
4793
|
+
const commentLength = getUint16$1(endOfDirectoryView, 20);
|
|
4715
4794
|
const appendedDataOffset = commentOffset + END_OF_CENTRAL_DIR_LENGTH + commentLength;
|
|
4716
4795
|
if (reader.size - appendedDataOffset > maxAppendedDataSize) {
|
|
4717
4796
|
throwAmbiguousArchive("appended data");
|
|
4718
4797
|
}
|
|
4719
|
-
let lastDiskNumber = getUint16(endOfDirectoryView, 4);
|
|
4798
|
+
let lastDiskNumber = getUint16$1(endOfDirectoryView, 4);
|
|
4720
4799
|
const expectedLastDiskNumber = reader.lastDiskNumber || 0;
|
|
4721
|
-
let diskNumber = getUint16(endOfDirectoryView, 6);
|
|
4722
|
-
let filesLength = getUint16(endOfDirectoryView, 10);
|
|
4800
|
+
let diskNumber = getUint16$1(endOfDirectoryView, 6);
|
|
4801
|
+
let filesLength = getUint16$1(endOfDirectoryView, 10);
|
|
4723
4802
|
let prependedDataLength = 0;
|
|
4724
4803
|
let startOffset;
|
|
4725
4804
|
let zip64EndOfDirectory;
|
|
@@ -4735,12 +4814,12 @@
|
|
|
4735
4814
|
EMPTY_UINT8_ARRAY;
|
|
4736
4815
|
const endOfDirectoryLocatorView = getDataView(endOfDirectoryLocatorArray);
|
|
4737
4816
|
if (endOfDirectoryLocatorArray.length == ZIP64_END_OF_CENTRAL_DIR_LOCATOR_LENGTH &&
|
|
4738
|
-
getUint32(endOfDirectoryLocatorView, 0) == ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIGNATURE) {
|
|
4739
|
-
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);
|
|
4740
4819
|
let endOfDirectoryArray = await readUint8Array(reader, directoryDataOffset, ZIP64_END_OF_CENTRAL_DIR_LENGTH);
|
|
4741
4820
|
let endOfDirectoryView = getDataView(endOfDirectoryArray);
|
|
4742
4821
|
const expectedDirectoryDataOffset = endOfDirectoryInfo.offset - ZIP64_END_OF_CENTRAL_DIR_LOCATOR_LENGTH - ZIP64_END_OF_CENTRAL_DIR_LENGTH;
|
|
4743
|
-
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) &&
|
|
4744
4823
|
directoryDataOffset != expectedDirectoryDataOffset && expectedDirectoryDataOffset >= 0) {
|
|
4745
4824
|
const originalDirectoryDataOffset = directoryDataOffset;
|
|
4746
4825
|
directoryDataOffset = expectedDirectoryDataOffset;
|
|
@@ -4750,7 +4829,7 @@
|
|
|
4750
4829
|
endOfDirectoryArray = await readUint8Array(reader, directoryDataOffset, ZIP64_END_OF_CENTRAL_DIR_LENGTH);
|
|
4751
4830
|
endOfDirectoryView = getDataView(endOfDirectoryArray);
|
|
4752
4831
|
}
|
|
4753
|
-
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) {
|
|
4754
4833
|
throw new Error(ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND);
|
|
4755
4834
|
}
|
|
4756
4835
|
zip64EndOfDirectory = true;
|
|
@@ -4765,13 +4844,13 @@
|
|
|
4765
4844
|
}
|
|
4766
4845
|
}
|
|
4767
4846
|
if (lastDiskNumber == MAX_16_BITS) {
|
|
4768
|
-
lastDiskNumber = getUint32(endOfDirectoryView, 16);
|
|
4769
|
-
} else if (checkAmbiguity && lastDiskNumber != getUint32(endOfDirectoryView, 16)) {
|
|
4847
|
+
lastDiskNumber = getUint32$1(endOfDirectoryView, 16);
|
|
4848
|
+
} else if (checkAmbiguity && lastDiskNumber != getUint32$1(endOfDirectoryView, 16)) {
|
|
4770
4849
|
throwAmbiguousArchive("mismatched zip64 end of central directory record");
|
|
4771
4850
|
}
|
|
4772
4851
|
if (diskNumber == MAX_16_BITS) {
|
|
4773
|
-
diskNumber = getUint32(endOfDirectoryView, 20);
|
|
4774
|
-
} else if (checkAmbiguity && diskNumber != getUint32(endOfDirectoryView, 20)) {
|
|
4852
|
+
diskNumber = getUint32$1(endOfDirectoryView, 20);
|
|
4853
|
+
} else if (checkAmbiguity && diskNumber != getUint32$1(endOfDirectoryView, 20)) {
|
|
4775
4854
|
throwAmbiguousArchive("mismatched zip64 end of central directory record");
|
|
4776
4855
|
}
|
|
4777
4856
|
if (filesLength == MAX_16_BITS) {
|
|
@@ -4809,11 +4888,11 @@
|
|
|
4809
4888
|
}
|
|
4810
4889
|
const expectedDirectoryDataOffset = centralDirectoryEndOffset - directoryDataLength;
|
|
4811
4890
|
if (directoryDataOffset != expectedDirectoryDataOffset && diskNumber == lastDiskNumber) {
|
|
4812
|
-
const storedPointsAtDirectory = getUint32(directoryView, offset) == CENTRAL_FILE_HEADER_SIGNATURE;
|
|
4891
|
+
const storedPointsAtDirectory = getUint32$1(directoryView, offset) == CENTRAL_FILE_HEADER_SIGNATURE;
|
|
4813
4892
|
let reconcile = !storedPointsAtDirectory;
|
|
4814
4893
|
if (!reconcile && expectedDirectoryDataOffset >= 0 && expectedDirectoryDataOffset + 4 <= reader.size) {
|
|
4815
4894
|
const expectedSignatureArray = await readUint8Array(reader, expectedDirectoryDataOffset, 4);
|
|
4816
|
-
reconcile = getUint32(getDataView(expectedSignatureArray), 0) == CENTRAL_FILE_HEADER_SIGNATURE;
|
|
4895
|
+
reconcile = getUint32$1(getDataView(expectedSignatureArray), 0) == CENTRAL_FILE_HEADER_SIGNATURE;
|
|
4817
4896
|
}
|
|
4818
4897
|
if (reconcile) {
|
|
4819
4898
|
const originalDirectoryDataOffset = directoryDataOffset;
|
|
@@ -4837,10 +4916,10 @@
|
|
|
4837
4916
|
}
|
|
4838
4917
|
zipReader.directoryOffset = directoryDataOffset;
|
|
4839
4918
|
zipReader.directoryLength = declaredDirectoryDataLength;
|
|
4840
|
-
const decryptCentralDirectory =
|
|
4919
|
+
const decryptCentralDirectory = getFunctionOptionValue$1(zipReader, options, OPTION_DECRYPT_CENTRAL_DIRECTORY);
|
|
4841
4920
|
let decryptedDirectory;
|
|
4842
4921
|
if (decryptCentralDirectory && filesLength && directoryArray.length >= 4 &&
|
|
4843
|
-
getUint32(directoryView, 0) != CENTRAL_FILE_HEADER_SIGNATURE &&
|
|
4922
|
+
getUint32$1(directoryView, 0) != CENTRAL_FILE_HEADER_SIGNATURE &&
|
|
4844
4923
|
(zip64EndOfDirectoryVersion2 || detectEncryptedCentralDirectory(directoryView))) {
|
|
4845
4924
|
directoryArray = await decryptCentralDirectory(directoryArray, directoryEncryptionInfo);
|
|
4846
4925
|
directoryView = getDataView(directoryArray);
|
|
@@ -4853,8 +4932,8 @@
|
|
|
4853
4932
|
const filenames = checkAmbiguity ? new Set() : UNDEFINED_VALUE;
|
|
4854
4933
|
let duplicateFilename;
|
|
4855
4934
|
for (let indexFile = 0; indexFile < filesLength; indexFile++) {
|
|
4856
|
-
const fileEntry = new ZipEntry$1(reader,
|
|
4857
|
-
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) {
|
|
4858
4937
|
if (indexFile == 0 && !decryptedDirectory && (zip64EndOfDirectoryVersion2 || detectEncryptedCentralDirectory(directoryView))) {
|
|
4859
4938
|
throw new Error(ERR_ENCRYPTED_CENTRAL_DIRECTORY);
|
|
4860
4939
|
}
|
|
@@ -4865,16 +4944,16 @@
|
|
|
4865
4944
|
const filenameOffset = offset + CENTRAL_FILE_HEADER_LENGTH;
|
|
4866
4945
|
const extraFieldOffset = filenameOffset + fileEntry.filenameLength;
|
|
4867
4946
|
const commentOffset = extraFieldOffset + fileEntry.extraFieldLength;
|
|
4868
|
-
const versionMadeBy = getUint16(directoryView, offset + 4);
|
|
4947
|
+
const versionMadeBy = getUint16$1(directoryView, offset + 4);
|
|
4869
4948
|
const msDosCompatible = versionMadeBy >> 8 == 0;
|
|
4870
4949
|
const unixCompatible = versionMadeBy >> 8 == 3;
|
|
4871
4950
|
const rawFilename = directoryArray.subarray(filenameOffset, extraFieldOffset);
|
|
4872
|
-
const commentLength = getUint16(directoryView, offset + 32);
|
|
4951
|
+
const commentLength = getUint16$1(directoryView, offset + 32);
|
|
4873
4952
|
const endOffset = commentOffset + commentLength;
|
|
4874
4953
|
const rawComment = directoryArray.subarray(commentOffset, endOffset);
|
|
4875
4954
|
const filenameUTF8 = languageEncodingFlag;
|
|
4876
4955
|
const commentUTF8 = languageEncodingFlag;
|
|
4877
|
-
const externalFileAttributes = getUint32(directoryView, offset + 38);
|
|
4956
|
+
const externalFileAttributes = getUint32$1(directoryView, offset + 38);
|
|
4878
4957
|
const msdosAttributesRaw = externalFileAttributes & MAX_8_BITS;
|
|
4879
4958
|
const msdosAttributes = {
|
|
4880
4959
|
readOnly: Boolean(msdosAttributesRaw & FILE_ATTR_MSDOS_READONLY_MASK),
|
|
@@ -4883,8 +4962,8 @@
|
|
|
4883
4962
|
directory: Boolean(msdosAttributesRaw & FILE_ATTR_MSDOS_DIR_MASK),
|
|
4884
4963
|
archive: Boolean(msdosAttributesRaw & FILE_ATTR_MSDOS_ARCHIVE_MASK)
|
|
4885
4964
|
};
|
|
4886
|
-
const offsetFileEntry = getUint32(directoryView, offset + 42);
|
|
4887
|
-
const decode =
|
|
4965
|
+
const offsetFileEntry = getUint32$1(directoryView, offset + 42);
|
|
4966
|
+
const decode = getFunctionOptionValue$1(zipReader, options, OPTION_DECODE_TEXT) || decodeText;
|
|
4888
4967
|
const rawFilenameEncoding = filenameUTF8 ? CHARSET_UTF8 : filenameEncoding || CHARSET_CP437;
|
|
4889
4968
|
const rawCommentEncoding = commentUTF8 ? CHARSET_UTF8 : commentEncoding || CHARSET_CP437;
|
|
4890
4969
|
let filename = decode(rawFilename, rawFilenameEncoding, TEXT_TYPE_FILENAME);
|
|
@@ -4915,8 +4994,8 @@
|
|
|
4915
4994
|
uncompressedSize: 0,
|
|
4916
4995
|
commentLength,
|
|
4917
4996
|
offset: offsetFileEntry,
|
|
4918
|
-
diskNumberStart: getUint16(directoryView, offset + 34),
|
|
4919
|
-
internalFileAttributes: getUint16(directoryView, offset + 36),
|
|
4997
|
+
diskNumberStart: getUint16$1(directoryView, offset + 34),
|
|
4998
|
+
internalFileAttributes: getUint16$1(directoryView, offset + 36),
|
|
4920
4999
|
externalFileAttributes,
|
|
4921
5000
|
msdosAttributesRaw,
|
|
4922
5001
|
msdosAttributes,
|
|
@@ -4984,8 +5063,8 @@
|
|
|
4984
5063
|
yield entry;
|
|
4985
5064
|
}
|
|
4986
5065
|
let offsetAfterSignature = offset;
|
|
4987
|
-
if (offset + 6 <= directoryArray.length && getUint32(directoryView, offset) == DIGITAL_SIGNATURE_RECORD_SIGNATURE) {
|
|
4988
|
-
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);
|
|
4989
5068
|
if (offset + 6 + signatureDataLength <= directoryArray.length) {
|
|
4990
5069
|
zipReader.digitalSignature = directoryArray.subarray(offset + 6, offset + 6 + signatureDataLength);
|
|
4991
5070
|
offsetAfterSignature = offset + 6 + signatureDataLength;
|
|
@@ -4997,13 +5076,17 @@
|
|
|
4997
5076
|
if (duplicateFilename) {
|
|
4998
5077
|
throwAmbiguousArchive("duplicate filename");
|
|
4999
5078
|
}
|
|
5000
|
-
if (checkAmbiguity && (prependedDataLength || (filesLength && startOffset > 0))) {
|
|
5001
|
-
throwAmbiguousArchive("prepended data");
|
|
5002
|
-
}
|
|
5003
5079
|
const extractPrependedData = getOptionValue$1(zipReader, options, OPTION_EXTRACT_PREPENDED_DATA);
|
|
5004
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
|
+
}
|
|
5005
5086
|
if (extractPrependedData) {
|
|
5006
|
-
zipReader.prependedData = startOffset >
|
|
5087
|
+
zipReader.prependedData = startOffset > splitZipSignatureLength ?
|
|
5088
|
+
await readUint8Array(reader, splitZipSignatureLength, startOffset - splitZipSignatureLength) :
|
|
5089
|
+
EMPTY_UINT8_ARRAY;
|
|
5007
5090
|
}
|
|
5008
5091
|
zipReader.comment = commentLength ? await readUint8Array(reader, commentOffset + END_OF_CENTRAL_DIR_LENGTH, commentLength) : EMPTY_UINT8_ARRAY;
|
|
5009
5092
|
if (extractAppendedData) {
|
|
@@ -5070,16 +5153,16 @@
|
|
|
5070
5153
|
|
|
5071
5154
|
let ZipEntry$1 = class ZipEntry {
|
|
5072
5155
|
|
|
5073
|
-
constructor(reader,
|
|
5156
|
+
constructor(reader, options) {
|
|
5074
5157
|
Object.assign(this, {
|
|
5075
5158
|
reader,
|
|
5076
|
-
config,
|
|
5077
5159
|
options
|
|
5078
5160
|
});
|
|
5079
5161
|
}
|
|
5080
5162
|
|
|
5081
5163
|
async getData(writer, fileEntry, readRanges, options = {}) {
|
|
5082
5164
|
const zipEntry = this;
|
|
5165
|
+
const config = getConfiguration();
|
|
5083
5166
|
const {
|
|
5084
5167
|
reader,
|
|
5085
5168
|
index,
|
|
@@ -5088,7 +5171,6 @@
|
|
|
5088
5171
|
extraFieldAES,
|
|
5089
5172
|
extraFieldZip64,
|
|
5090
5173
|
compressionMethod,
|
|
5091
|
-
config,
|
|
5092
5174
|
bitFlag,
|
|
5093
5175
|
rawBitFlag,
|
|
5094
5176
|
crc32,
|
|
@@ -5106,6 +5188,7 @@
|
|
|
5106
5188
|
let password = getOptionValue$1(zipEntry, options, OPTION_PASSWORD);
|
|
5107
5189
|
let rawPassword = getOptionValue$1(zipEntry, options, OPTION_RAW_PASSWORD);
|
|
5108
5190
|
const passThrough = getOptionValue$1(zipEntry, options, OPTION_PASS_THROUGH);
|
|
5191
|
+
checkPasswordOption(password, rawPassword);
|
|
5109
5192
|
password = password && password.length && password;
|
|
5110
5193
|
rawPassword = rawPassword && rawPassword.length && rawPassword;
|
|
5111
5194
|
if (extraFieldAES) {
|
|
@@ -5113,7 +5196,7 @@
|
|
|
5113
5196
|
throw new Error(ERR_UNSUPPORTED_COMPRESSION$1);
|
|
5114
5197
|
}
|
|
5115
5198
|
}
|
|
5116
|
-
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) {
|
|
5117
5200
|
throw new Error(ERR_LOCAL_FILE_HEADER_NOT_FOUND);
|
|
5118
5201
|
}
|
|
5119
5202
|
readCommonHeader(localDirectory, dataView, 4);
|
|
@@ -5175,9 +5258,12 @@
|
|
|
5175
5258
|
}
|
|
5176
5259
|
}
|
|
5177
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
|
+
}
|
|
5178
5264
|
const size = compressedSize;
|
|
5179
5265
|
const readable = toCompatibleReadable(reader.createReadable({ offset: dataOffset, size }));
|
|
5180
|
-
const signal = getOptionValue$1(zipEntry, options, OPTION_SIGNAL);
|
|
5266
|
+
const signal = checkSignalOption(getOptionValue$1(zipEntry, options, OPTION_SIGNAL));
|
|
5181
5267
|
const checkPasswordOnly = getOptionValue$1(zipEntry, options, OPTION_CHECK_PASSWORD_ONLY);
|
|
5182
5268
|
let checkOverlappingEntry = getOptionValue$1(zipEntry, options, OPTION_CHECK_OVERLAPPING_ENTRY);
|
|
5183
5269
|
const checkOverlappingEntryOnly = getOptionValue$1(zipEntry, options, OPTION_CHECK_OVERLAPPING_ENTRY_ONLY);
|
|
@@ -5185,6 +5271,8 @@
|
|
|
5185
5271
|
checkOverlappingEntry = true;
|
|
5186
5272
|
}
|
|
5187
5273
|
const { onstart, onprogress, onend } = options;
|
|
5274
|
+
const compressed = compressionMethod != COMPRESSION_METHOD_STORE && !passThrough;
|
|
5275
|
+
const outputSize = passThrough ? compressedSize : uncompressedSize;
|
|
5188
5276
|
const deflate64 = compressionMethod == COMPRESSION_METHOD_DEFLATE_64;
|
|
5189
5277
|
let useCompressionStream = getOptionValue$1(zipEntry, options, OPTION_USE_COMPRESSION_STREAM);
|
|
5190
5278
|
if (deflate64) {
|
|
@@ -5205,9 +5293,9 @@
|
|
|
5205
5293
|
checkCrc32,
|
|
5206
5294
|
checkAuthenticationCode: getOptionValue$1(zipEntry, options, OPTION_CHECK_AUTHENTICATION_CODE),
|
|
5207
5295
|
passwordVerification: zipCrypto && (dataDescriptor ? ((rawLastModDate >>> 8) & MAX_8_BITS) : ((crc32 >>> 24) & MAX_8_BITS)),
|
|
5208
|
-
outputSize
|
|
5296
|
+
outputSize,
|
|
5209
5297
|
crc32,
|
|
5210
|
-
compressed
|
|
5298
|
+
compressed,
|
|
5211
5299
|
encrypted,
|
|
5212
5300
|
useWebWorkers: getOptionValue$1(zipEntry, options, OPTION_USE_WEB_WORKERS),
|
|
5213
5301
|
useCompressionStream,
|
|
@@ -5244,11 +5332,11 @@
|
|
|
5244
5332
|
writer = new WritableStream();
|
|
5245
5333
|
}
|
|
5246
5334
|
writer = new GenericWriter(writer);
|
|
5247
|
-
await initStream(writer,
|
|
5335
|
+
await initStream(writer, getDecodableOutputSize(outputSize, compressedSize, compressed));
|
|
5248
5336
|
({ writable } = writer);
|
|
5249
|
-
const { outputSize } = await runWorker({ readable, writable }, workerOptions);
|
|
5250
|
-
writer.size +=
|
|
5251
|
-
if (
|
|
5337
|
+
const { outputSize: writtenSize } = await runWorker({ readable, writable }, workerOptions);
|
|
5338
|
+
writer.size += writtenSize;
|
|
5339
|
+
if (writtenSize != outputSize) {
|
|
5252
5340
|
throw new Error(ERR_INVALID_UNCOMPRESSED_SIZE);
|
|
5253
5341
|
}
|
|
5254
5342
|
}
|
|
@@ -5282,7 +5370,7 @@
|
|
|
5282
5370
|
function detectEncryptedCentralDirectory(directoryView) {
|
|
5283
5371
|
const maxOffset = Math.min(directoryView.byteLength, 1024) - 3;
|
|
5284
5372
|
for (let offset = 0; offset < maxOffset; offset++) {
|
|
5285
|
-
if (getUint32(directoryView, offset) == ARCHIVE_EXTRA_DATA_SIGNATURE) {
|
|
5373
|
+
if (getUint32$1(directoryView, offset) == ARCHIVE_EXTRA_DATA_SIGNATURE) {
|
|
5286
5374
|
return true;
|
|
5287
5375
|
}
|
|
5288
5376
|
}
|
|
@@ -5293,15 +5381,15 @@
|
|
|
5293
5381
|
const directoryEncryptionInfo = { rawExtensibleData };
|
|
5294
5382
|
if (rawExtensibleData.length >= 28) {
|
|
5295
5383
|
const extensibleDataView = getDataView(rawExtensibleData);
|
|
5296
|
-
const hashDataLength = getUint16(extensibleDataView, 26);
|
|
5384
|
+
const hashDataLength = getUint16$1(extensibleDataView, 26);
|
|
5297
5385
|
Object.assign(directoryEncryptionInfo, {
|
|
5298
|
-
compressionMethod: getUint16(extensibleDataView, 0),
|
|
5386
|
+
compressionMethod: getUint16$1(extensibleDataView, 0),
|
|
5299
5387
|
compressedSize: Number(getBigUint64(extensibleDataView, 2)),
|
|
5300
5388
|
uncompressedSize: Number(getBigUint64(extensibleDataView, 10)),
|
|
5301
|
-
encryptionAlgorithm: getUint16(extensibleDataView, 18),
|
|
5302
|
-
bitLength: getUint16(extensibleDataView, 20),
|
|
5303
|
-
flags: getUint16(extensibleDataView, 22),
|
|
5304
|
-
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),
|
|
5305
5393
|
hashData: rawExtensibleData.subarray(28, 28 + hashDataLength)
|
|
5306
5394
|
});
|
|
5307
5395
|
}
|
|
@@ -5309,12 +5397,12 @@
|
|
|
5309
5397
|
}
|
|
5310
5398
|
|
|
5311
5399
|
function readCommonHeader(directory, dataView, offset) {
|
|
5312
|
-
const rawBitFlag = directory.rawBitFlag = getUint16(dataView, offset + 2);
|
|
5400
|
+
const rawBitFlag = directory.rawBitFlag = getUint16$1(dataView, offset + 2);
|
|
5313
5401
|
const encrypted = (rawBitFlag & BITFLAG_ENCRYPTED) == BITFLAG_ENCRYPTED;
|
|
5314
|
-
const rawLastModDate = getUint32(dataView, offset + 6);
|
|
5402
|
+
const rawLastModDate = getUint32$1(dataView, offset + 6);
|
|
5315
5403
|
Object.assign(directory, {
|
|
5316
5404
|
encrypted,
|
|
5317
|
-
version: getUint16(dataView, offset),
|
|
5405
|
+
version: getUint16$1(dataView, offset),
|
|
5318
5406
|
bitFlag: {
|
|
5319
5407
|
level: (rawBitFlag & BITFLAG_LEVEL) >> 1,
|
|
5320
5408
|
dataDescriptor: (rawBitFlag & BITFLAG_DATA_DESCRIPTOR) == BITFLAG_DATA_DESCRIPTOR,
|
|
@@ -5322,8 +5410,8 @@
|
|
|
5322
5410
|
},
|
|
5323
5411
|
rawLastModDate,
|
|
5324
5412
|
lastModDate: getDate(rawLastModDate),
|
|
5325
|
-
filenameLength: getUint16(dataView, offset + 22),
|
|
5326
|
-
extraFieldLength: getUint16(dataView, offset + 24)
|
|
5413
|
+
filenameLength: getUint16$1(dataView, offset + 22),
|
|
5414
|
+
extraFieldLength: getUint16$1(dataView, offset + 24)
|
|
5327
5415
|
});
|
|
5328
5416
|
}
|
|
5329
5417
|
|
|
@@ -5334,8 +5422,8 @@
|
|
|
5334
5422
|
let offsetExtraField = 0;
|
|
5335
5423
|
try {
|
|
5336
5424
|
while (offsetExtraField < rawExtraField.length) {
|
|
5337
|
-
const type = getUint16(rawExtraFieldView, offsetExtraField);
|
|
5338
|
-
const size = getUint16(rawExtraFieldView, offsetExtraField + 2);
|
|
5425
|
+
const type = getUint16$1(rawExtraFieldView, offsetExtraField);
|
|
5426
|
+
const size = getUint16$1(rawExtraFieldView, offsetExtraField + 2);
|
|
5339
5427
|
extraField.set(type, {
|
|
5340
5428
|
type,
|
|
5341
5429
|
data: rawExtraField.slice(offsetExtraField + 4, offsetExtraField + 4 + size)
|
|
@@ -5345,12 +5433,12 @@
|
|
|
5345
5433
|
} catch {
|
|
5346
5434
|
// ignored
|
|
5347
5435
|
}
|
|
5348
|
-
const compressionMethod = getUint16(dataView, offset + 4);
|
|
5436
|
+
const compressionMethod = getUint16$1(dataView, offset + 4);
|
|
5349
5437
|
Object.assign(directory, {
|
|
5350
|
-
signature: getUint32(dataView, offset + HEADER_OFFSET_SIGNATURE),
|
|
5351
|
-
crc32: getUint32(dataView, offset + HEADER_OFFSET_SIGNATURE),
|
|
5352
|
-
compressedSize: getUint32(dataView, offset + HEADER_OFFSET_COMPRESSED_SIZE),
|
|
5353
|
-
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)
|
|
5354
5442
|
});
|
|
5355
5443
|
const extraFieldZip64 = extraField.get(EXTRAFIELD_TYPE_ZIP64);
|
|
5356
5444
|
if (extraFieldZip64) {
|
|
@@ -5439,11 +5527,11 @@
|
|
|
5439
5527
|
computedCrc32.append(fileEntry[rawPropertyName]);
|
|
5440
5528
|
const computedCrc32View = getDataView(new Uint8Array(4));
|
|
5441
5529
|
computedCrc32View.setUint32(0, computedCrc32.get(), true);
|
|
5442
|
-
const nameCrc32 = getUint32(extraFieldView, 1);
|
|
5530
|
+
const nameCrc32 = getUint32$1(extraFieldView, 1);
|
|
5443
5531
|
Object.assign(extraFieldUnicode, {
|
|
5444
5532
|
version: getUint8(extraFieldView, 0),
|
|
5445
5533
|
[propertyName]: decodeText(extraFieldUnicode.data.subarray(5)),
|
|
5446
|
-
valid: !fileEntry.bitFlag.languageEncodingFlag && nameCrc32 == getUint32(computedCrc32View, 0)
|
|
5534
|
+
valid: !fileEntry.bitFlag.languageEncodingFlag && nameCrc32 == getUint32$1(computedCrc32View, 0)
|
|
5447
5535
|
});
|
|
5448
5536
|
if (extraFieldUnicode.valid) {
|
|
5449
5537
|
directory[propertyName] = extraFieldUnicode[propertyName];
|
|
@@ -5459,7 +5547,7 @@
|
|
|
5459
5547
|
vendorId: getUint8(extraFieldView, 2),
|
|
5460
5548
|
strength,
|
|
5461
5549
|
originalCompressionMethod: compressionMethod,
|
|
5462
|
-
compressionMethod: getUint16(extraFieldView, 5)
|
|
5550
|
+
compressionMethod: getUint16$1(extraFieldView, 5)
|
|
5463
5551
|
});
|
|
5464
5552
|
directory.compressionMethod = extraFieldAES.compressionMethod;
|
|
5465
5553
|
if (extraFieldAES.vendorVersion != VENDOR_VERSION_AE_1$1) {
|
|
@@ -5473,8 +5561,8 @@
|
|
|
5473
5561
|
let tag1Data;
|
|
5474
5562
|
try {
|
|
5475
5563
|
while (offsetExtraField < extraFieldNTFS.data.length && !tag1Data) {
|
|
5476
|
-
const tagValue = getUint16(extraFieldView, offsetExtraField);
|
|
5477
|
-
const attributeSize = getUint16(extraFieldView, offsetExtraField + 2);
|
|
5564
|
+
const tagValue = getUint16$1(extraFieldView, offsetExtraField);
|
|
5565
|
+
const attributeSize = getUint16$1(extraFieldView, offsetExtraField + 2);
|
|
5478
5566
|
if (tagValue == EXTRAFIELD_TYPE_NTFS_TAG1) {
|
|
5479
5567
|
tag1Data = extraFieldNTFS.data.slice(offsetExtraField + 4, offsetExtraField + 4 + attributeSize);
|
|
5480
5568
|
}
|
|
@@ -5507,12 +5595,12 @@
|
|
|
5507
5595
|
return;
|
|
5508
5596
|
}
|
|
5509
5597
|
const extraFieldView = getDataView(extraField.data);
|
|
5510
|
-
const lastAccessDate = new Date((getUint32(extraFieldView, 0) | 0) * 1000);
|
|
5511
|
-
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);
|
|
5512
5600
|
const extraFieldData = { lastAccessDate, lastModDate };
|
|
5513
5601
|
if (extraField.data.length >= 12) {
|
|
5514
|
-
extraFieldData.uid = getUint16(extraFieldView, 8);
|
|
5515
|
-
extraFieldData.gid = getUint16(extraFieldView, 10);
|
|
5602
|
+
extraFieldData.uid = getUint16$1(extraFieldView, 8);
|
|
5603
|
+
extraFieldData.gid = getUint16$1(extraFieldView, 10);
|
|
5516
5604
|
}
|
|
5517
5605
|
Object.assign(extraField, extraFieldData);
|
|
5518
5606
|
Object.assign(directory, extraFieldData);
|
|
@@ -5532,8 +5620,8 @@
|
|
|
5532
5620
|
gid = unpackUnixId(extraField.data.subarray(offset, offset + gidSize));
|
|
5533
5621
|
Object.assign(extraField, { version, uid, gid });
|
|
5534
5622
|
} else if (extraField.data.length >= 4) {
|
|
5535
|
-
uid = getUint16(view, 0);
|
|
5536
|
-
gid = getUint16(view, 2);
|
|
5623
|
+
uid = getUint16$1(view, 0);
|
|
5624
|
+
gid = getUint16$1(view, 2);
|
|
5537
5625
|
Object.assign(extraField, { uid, gid });
|
|
5538
5626
|
}
|
|
5539
5627
|
if (uid !== UNDEFINED_VALUE) {
|
|
@@ -5583,7 +5671,7 @@
|
|
|
5583
5671
|
let offset = 1;
|
|
5584
5672
|
timeProperties.forEach((propertyName, indexProperty) => {
|
|
5585
5673
|
if (extraFieldExtendedTimestamp.data.length >= offset + 4) {
|
|
5586
|
-
const time = getUint32(extraFieldView, offset);
|
|
5674
|
+
const time = getUint32$1(extraFieldView, offset);
|
|
5587
5675
|
directory[propertyName] = extraFieldExtendedTimestamp[propertyName] = new Date((time | 0) * 1000);
|
|
5588
5676
|
const rawPropertyName = timeRawProperties[indexProperty];
|
|
5589
5677
|
extraFieldExtendedTimestamp[rawPropertyName] = time;
|
|
@@ -5617,7 +5705,7 @@
|
|
|
5617
5705
|
const dataDescriptorArray = await readUint8Array(reader, dataOffset + compressedSize, dataDescriptorLength + DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH);
|
|
5618
5706
|
const dataDescriptorView = getDataView(dataDescriptorArray);
|
|
5619
5707
|
let signature = dataDescriptorArray.length == dataDescriptorLength + DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH &&
|
|
5620
|
-
getUint32(dataDescriptorView, 0) == DATA_DESCRIPTOR_RECORD_SIGNATURE;
|
|
5708
|
+
getUint32$1(dataDescriptorView, 0) == DATA_DESCRIPTOR_RECORD_SIGNATURE;
|
|
5621
5709
|
if (signature) {
|
|
5622
5710
|
const signedDataDescriptor = readDataDescriptor(dataDescriptorView, DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH, extraFieldZip64);
|
|
5623
5711
|
const matchCrc32 = (fileEntry.encrypted && !fileEntry.zipCrypto) || signedDataDescriptor.crc32 == crc32;
|
|
@@ -5651,15 +5739,15 @@
|
|
|
5651
5739
|
}
|
|
5652
5740
|
|
|
5653
5741
|
function readDataDescriptor(dataDescriptorView, offset, extraFieldZip64) {
|
|
5654
|
-
const crc32 = getUint32(dataDescriptorView, offset);
|
|
5742
|
+
const crc32 = getUint32$1(dataDescriptorView, offset);
|
|
5655
5743
|
let compressedSize;
|
|
5656
5744
|
let uncompressedSize;
|
|
5657
5745
|
if (extraFieldZip64) {
|
|
5658
5746
|
compressedSize = getBigUint64(dataDescriptorView, offset + 4);
|
|
5659
5747
|
uncompressedSize = getBigUint64(dataDescriptorView, offset + 12);
|
|
5660
5748
|
} else {
|
|
5661
|
-
compressedSize = getUint32(dataDescriptorView, offset + 4);
|
|
5662
|
-
uncompressedSize = getUint32(dataDescriptorView, offset + 8);
|
|
5749
|
+
compressedSize = getUint32$1(dataDescriptorView, offset + 4);
|
|
5750
|
+
uncompressedSize = getUint32$1(dataDescriptorView, offset + 8);
|
|
5663
5751
|
}
|
|
5664
5752
|
return { crc32, compressedSize, uncompressedSize };
|
|
5665
5753
|
}
|
|
@@ -5668,10 +5756,28 @@
|
|
|
5668
5756
|
return reader.getDiskOffset ? reader.getDiskOffset(diskNumber) : 0;
|
|
5669
5757
|
}
|
|
5670
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
|
+
|
|
5671
5773
|
function isStrictnessValue(value) {
|
|
5672
5774
|
return value === STRICTNESS_STRICT || value === STRICTNESS_BALANCED || value === STRICTNESS_TOLERANT;
|
|
5673
5775
|
}
|
|
5674
5776
|
|
|
5777
|
+
function getDecodableOutputSize(outputSize, compressedSize, compressed) {
|
|
5778
|
+
return Math.min(outputSize, compressed ? compressedSize * MAX_DEFLATE_EXPANSION_RATIO : compressedSize);
|
|
5779
|
+
}
|
|
5780
|
+
|
|
5675
5781
|
function getStrictness(options, inheritedOptions) {
|
|
5676
5782
|
return resolveStrictness(options, resolveStrictness(inheritedOptions, STRICTNESS_BALANCED));
|
|
5677
5783
|
}
|
|
@@ -5734,7 +5840,7 @@
|
|
|
5734
5840
|
|
|
5735
5841
|
function getMaxAppendedDataSize(maxAppendedDataSize, strictness) {
|
|
5736
5842
|
if (maxAppendedDataSize !== UNDEFINED_VALUE) {
|
|
5737
|
-
const size = toNumber
|
|
5843
|
+
const size = toNumber(maxAppendedDataSize);
|
|
5738
5844
|
if (typeof size != NUMBER_TYPE || Number.isNaN(size) || size < 0) {
|
|
5739
5845
|
throw new Error(ERR_INVALID_MAX_APPENDED_DATA_SIZE);
|
|
5740
5846
|
}
|
|
@@ -5757,7 +5863,7 @@
|
|
|
5757
5863
|
let plausibleEndOfDirectoryInfo;
|
|
5758
5864
|
let endOfDirectoryReachingEndCount = 0;
|
|
5759
5865
|
for await (const [anchoredView, anchoredOffset, anchoredArray, indexByte, offset] of scanEndOfCentralDirectory(reader, anchoredLength)) {
|
|
5760
|
-
const commentLength = getUint16(anchoredView, indexByte + 20);
|
|
5866
|
+
const commentLength = getUint16$1(anchoredView, indexByte + 20);
|
|
5761
5867
|
if (offset + END_OF_CENTRAL_DIR_LENGTH + commentLength == size) {
|
|
5762
5868
|
const reachability = await getCentralDirectoryReachability(reader, anchoredView, anchoredOffset, indexByte, offset, size, remoteProbeBudget);
|
|
5763
5869
|
if (reachability == CENTRAL_DIRECTORY_REACHABLE) {
|
|
@@ -5808,7 +5914,7 @@
|
|
|
5808
5914
|
const scanArray = await readUint8Array(reader, scanOffset, scanLength);
|
|
5809
5915
|
const scanView = getDataView(scanArray);
|
|
5810
5916
|
for (let indexByte = scanArray.length - END_OF_CENTRAL_DIR_LENGTH; indexByte >= 0; indexByte--) {
|
|
5811
|
-
if (getUint32(scanView, indexByte) == END_OF_CENTRAL_DIR_SIGNATURE) {
|
|
5917
|
+
if (getUint32$1(scanView, indexByte) == END_OF_CENTRAL_DIR_SIGNATURE) {
|
|
5812
5918
|
yield [scanView, scanOffset, scanArray, indexByte, scanOffset + indexByte];
|
|
5813
5919
|
}
|
|
5814
5920
|
}
|
|
@@ -5819,9 +5925,9 @@
|
|
|
5819
5925
|
}
|
|
5820
5926
|
|
|
5821
5927
|
async function getCentralDirectoryReachability(reader, view, anchoredOffset, indexByte, offset, size, remoteProbeBudget) {
|
|
5822
|
-
const filesLength = getUint16(view, indexByte + 10);
|
|
5823
|
-
const directoryDataLength = getUint32(view, indexByte + 12);
|
|
5824
|
-
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);
|
|
5825
5931
|
if (filesLength == MAX_16_BITS || directoryDataLength == MAX_32_BITS || directoryDataOffset == MAX_32_BITS) {
|
|
5826
5932
|
const locatorSignature = await readSignature(reader, view, anchoredOffset, offset - ZIP64_END_OF_CENTRAL_DIR_LOCATOR_LENGTH, size, remoteProbeBudget);
|
|
5827
5933
|
return locatorSignature == ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIGNATURE ? CENTRAL_DIRECTORY_REACHABLE : CENTRAL_DIRECTORY_UNREACHABLE;
|
|
@@ -5829,7 +5935,7 @@
|
|
|
5829
5935
|
if (!filesLength && !directoryDataLength) {
|
|
5830
5936
|
return CENTRAL_DIRECTORY_PLAUSIBLE;
|
|
5831
5937
|
}
|
|
5832
|
-
const directoryDiskNumber = getUint16(view, indexByte + 6);
|
|
5938
|
+
const directoryDiskNumber = getUint16$1(view, indexByte + 6);
|
|
5833
5939
|
for (const centralDirectoryOffset of [offset - directoryDataLength, getDiskOffset$1(reader, directoryDiskNumber) + directoryDataOffset]) {
|
|
5834
5940
|
if (await readSignature(reader, view, anchoredOffset, centralDirectoryOffset, size, remoteProbeBudget) == CENTRAL_FILE_HEADER_SIGNATURE) {
|
|
5835
5941
|
return CENTRAL_DIRECTORY_REACHABLE;
|
|
@@ -5843,12 +5949,12 @@
|
|
|
5843
5949
|
return UNDEFINED_VALUE;
|
|
5844
5950
|
}
|
|
5845
5951
|
if (signatureOffset >= anchoredOffset) {
|
|
5846
|
-
return getUint32(view, signatureOffset - anchoredOffset);
|
|
5952
|
+
return getUint32$1(view, signatureOffset - anchoredOffset);
|
|
5847
5953
|
}
|
|
5848
5954
|
if (remoteProbeBudget.count > 0) {
|
|
5849
5955
|
remoteProbeBudget.count--;
|
|
5850
5956
|
const signatureArray = await readUint8Array(reader, signatureOffset, 4);
|
|
5851
|
-
return getUint32(getDataView(signatureArray), 0);
|
|
5957
|
+
return getUint32$1(getDataView(signatureArray), 0);
|
|
5852
5958
|
}
|
|
5853
5959
|
return UNDEFINED_VALUE;
|
|
5854
5960
|
}
|
|
@@ -5885,10 +5991,11 @@
|
|
|
5885
5991
|
return options[name] === UNDEFINED_VALUE ? zipReader.options[name] : options[name];
|
|
5886
5992
|
}
|
|
5887
5993
|
|
|
5888
|
-
function
|
|
5889
|
-
return
|
|
5994
|
+
function getFunctionOptionValue$1(zipReader, options, name) {
|
|
5995
|
+
return checkFunctionOption(getOptionValue$1(zipReader, options, name));
|
|
5890
5996
|
}
|
|
5891
5997
|
|
|
5998
|
+
|
|
5892
5999
|
function getDate(timeRaw) {
|
|
5893
6000
|
const date = (timeRaw & 0xffff0000) >> 16, time = timeRaw & MAX_16_BITS;
|
|
5894
6001
|
return new Date(1980 + ((date & 0xFE00) >> 9), ((date & 0x01E0) >> 5) - 1, date & 0x001F, (time & 0xF800) >> 11, (time & 0x07E0) >> 5, (time & 0x001F) * 2, 0);
|
|
@@ -5902,11 +6009,11 @@
|
|
|
5902
6009
|
return view.getUint8(offset);
|
|
5903
6010
|
}
|
|
5904
6011
|
|
|
5905
|
-
function getUint16(view, offset) {
|
|
6012
|
+
function getUint16$1(view, offset) {
|
|
5906
6013
|
return view.getUint16(offset, true);
|
|
5907
6014
|
}
|
|
5908
6015
|
|
|
5909
|
-
function getUint32(view, offset) {
|
|
6016
|
+
function getUint32$1(view, offset) {
|
|
5910
6017
|
return view.getUint32(offset, true);
|
|
5911
6018
|
}
|
|
5912
6019
|
|
|
@@ -5921,6 +6028,7 @@
|
|
|
5921
6028
|
ERR_CENTRAL_DIRECTORY_NOT_FOUND: ERR_CENTRAL_DIRECTORY_NOT_FOUND,
|
|
5922
6029
|
ERR_ENCRYPTED: ERR_ENCRYPTED,
|
|
5923
6030
|
ERR_ENCRYPTED_CENTRAL_DIRECTORY: ERR_ENCRYPTED_CENTRAL_DIRECTORY,
|
|
6031
|
+
ERR_ENTRY_DATA_OUT_OF_BOUNDS: ERR_ENTRY_DATA_OUT_OF_BOUNDS,
|
|
5924
6032
|
ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND: ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND,
|
|
5925
6033
|
ERR_EOCDR_NOT_FOUND: ERR_EOCDR_NOT_FOUND,
|
|
5926
6034
|
ERR_EXTRAFIELD_ZIP64_NOT_FOUND: ERR_EXTRAFIELD_ZIP64_NOT_FOUND,
|
|
@@ -5977,12 +6085,16 @@
|
|
|
5977
6085
|
const ERR_INVALID_COMMENT = "Zip file comment exceeds 64KB";
|
|
5978
6086
|
const ERR_INVALID_COMMENT_TYPE = "Invalid zip file comment (must be a Uint8Array)";
|
|
5979
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)";
|
|
5980
6090
|
const ERR_INVALID_ENTRY_NAME = "File entry name exceeds 64KB";
|
|
5981
6091
|
const ERR_INVALID_VERSION = "Version exceeds 65535";
|
|
5982
6092
|
const ERR_INVALID_ENCRYPTION_STRENGTH = "The strength must equal 1, 2, or 3";
|
|
5983
6093
|
const ERR_UNSUPPORTED_ENCRYPTION_USDZ = "Encryption is not supported in USDZ files";
|
|
5984
6094
|
const ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH = "Encryption is not supported when the 'passThrough' option is set";
|
|
5985
|
-
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)";
|
|
5986
6098
|
const ERR_INVALID_EXTRAFIELD_DATA = "Extra field data exceeds 64KB";
|
|
5987
6099
|
const ERR_UNSUPPORTED_COMPRESSION = "Compression method not supported";
|
|
5988
6100
|
const MIN_UNIX_TIME = -2147483648;
|
|
@@ -6002,7 +6114,6 @@
|
|
|
6002
6114
|
const ERR_INVALID_MSDOS_ATTRIBUTES = "Invalid msdosAttributesRaw (must be integer 0..255)";
|
|
6003
6115
|
const ERR_INVALID_MSDOS_DATA = "Invalid msdosAttributes (must be an object with boolean flags)";
|
|
6004
6116
|
const ERR_INVALID_LEVEL = "Invalid level (must be integer 0..9)";
|
|
6005
|
-
const ERR_INVALID_PASSWORD_TYPE = "Invalid password (password must be a string, rawPassword must be a Uint8Array)";
|
|
6006
6117
|
const ERR_INVALID_SIGNATURE_DATA = "Signature data exceeds 64KB";
|
|
6007
6118
|
|
|
6008
6119
|
const EXTRAFIELD_DATA_AES = new Uint8Array([0x07, 0x00, 0x02, 0x00, 0x41, 0x45, 0x03, 0x00, 0x00]);
|
|
@@ -6027,8 +6138,7 @@
|
|
|
6027
6138
|
writer,
|
|
6028
6139
|
addSplitZipSignature,
|
|
6029
6140
|
options,
|
|
6030
|
-
|
|
6031
|
-
files: new Map(),
|
|
6141
|
+
fileEntries: new Map(),
|
|
6032
6142
|
filenames: new Set(),
|
|
6033
6143
|
offset: options[OPTION_OFFSET] === UNDEFINED_VALUE ? writer.size || writer.writable.size || 0 : options[OPTION_OFFSET],
|
|
6034
6144
|
initialOffset: options[OPTION_OFFSET] === UNDEFINED_VALUE ? 0 : options[OPTION_OFFSET] - (writer.size || writer.writable.size || 0),
|
|
@@ -6049,14 +6159,23 @@
|
|
|
6049
6159
|
await initStream(reader);
|
|
6050
6160
|
}
|
|
6051
6161
|
const { ZipReader } = await Promise.resolve().then(function () { return zipReader; });
|
|
6052
|
-
const zipReader$1 = new ZipReader(reader
|
|
6162
|
+
const zipReader$1 = new ZipReader(reader);
|
|
6053
6163
|
const entries = await zipReader$1.getEntries();
|
|
6054
6164
|
await zipReader$1.close();
|
|
6055
6165
|
await initStream(this.writer);
|
|
6056
|
-
|
|
6057
|
-
|
|
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);
|
|
6058
6177
|
this.filenames = new Set(entries.map(entry => entry.filename));
|
|
6059
|
-
this.
|
|
6178
|
+
this.fileEntries = new Map(entries.map(entry => {
|
|
6060
6179
|
const {
|
|
6061
6180
|
version,
|
|
6062
6181
|
rawLastModDate,
|
|
@@ -6111,11 +6230,12 @@
|
|
|
6111
6230
|
if (crc32 !== UNDEFINED_VALUE) {
|
|
6112
6231
|
setUint32(headerView, HEADER_OFFSET_SIGNATURE, crc32);
|
|
6113
6232
|
}
|
|
6233
|
+
const { offset, diskNumberStart } = entryPositions.get(entry);
|
|
6114
6234
|
Object.assign(entry, {
|
|
6115
6235
|
zip64UncompressedSize,
|
|
6116
6236
|
zip64CompressedSize,
|
|
6117
|
-
|
|
6118
|
-
diskNumberStart
|
|
6237
|
+
offset,
|
|
6238
|
+
diskNumberStart,
|
|
6119
6239
|
zip64DiskNumberStart: false,
|
|
6120
6240
|
rawExtraFieldZip64,
|
|
6121
6241
|
rawExtraFieldAES,
|
|
@@ -6135,11 +6255,8 @@
|
|
|
6135
6255
|
async add(name = "", reader, options = {}) {
|
|
6136
6256
|
const zipWriter = this;
|
|
6137
6257
|
options = Object.assign({}, options);
|
|
6138
|
-
const {
|
|
6139
|
-
|
|
6140
|
-
config
|
|
6141
|
-
} = zipWriter;
|
|
6142
|
-
if (workers < config.maxWorkers) {
|
|
6258
|
+
const { pendingAddFileCalls } = zipWriter;
|
|
6259
|
+
if (workers < getConfiguration().maxWorkers) {
|
|
6143
6260
|
workers++;
|
|
6144
6261
|
} else {
|
|
6145
6262
|
await new Promise(resolve => pendingEntries.push(resolve));
|
|
@@ -6176,16 +6293,16 @@
|
|
|
6176
6293
|
}
|
|
6177
6294
|
|
|
6178
6295
|
remove(entry) {
|
|
6179
|
-
const { filenames,
|
|
6296
|
+
const { filenames, fileEntries } = this;
|
|
6180
6297
|
// deno-lint-ignore valid-typeof
|
|
6181
6298
|
if (typeof entry == STRING_TYPE) {
|
|
6182
|
-
entry =
|
|
6299
|
+
entry = fileEntries.get(entry);
|
|
6183
6300
|
}
|
|
6184
6301
|
if (entry && entry.filename !== UNDEFINED_VALUE) {
|
|
6185
6302
|
const { filename } = entry;
|
|
6186
|
-
if (filenames.has(filename) &&
|
|
6303
|
+
if (filenames.has(filename) && fileEntries.has(filename)) {
|
|
6187
6304
|
filenames.delete(filename);
|
|
6188
|
-
|
|
6305
|
+
fileEntries.delete(filename);
|
|
6189
6306
|
return true;
|
|
6190
6307
|
}
|
|
6191
6308
|
}
|
|
@@ -6282,12 +6399,12 @@
|
|
|
6282
6399
|
const metadataInfo = resolveMetadata(zipWriter, name, options);
|
|
6283
6400
|
const { comment } = metadataInfo;
|
|
6284
6401
|
const extraField = options[PROPERTY_NAME_EXTRA_FIELD];
|
|
6285
|
-
zipWriter.
|
|
6402
|
+
zipWriter.fileEntries.set(name, UNDEFINED_VALUE);
|
|
6286
6403
|
let fileEntry;
|
|
6287
6404
|
try {
|
|
6288
6405
|
const { resolvedOptions } = metadataInfo;
|
|
6289
6406
|
if (resolvedOptions.level != 0 && resolvedOptions.compressionMethod === UNDEFINED_VALUE &&
|
|
6290
|
-
!resolvedOptions.passThrough && !(await supportsDeflate(
|
|
6407
|
+
!resolvedOptions.passThrough && !(await supportsDeflate(getConfiguration()))) {
|
|
6291
6408
|
resolvedOptions.level = 0;
|
|
6292
6409
|
}
|
|
6293
6410
|
const sizesInfo = await resolveSizes(zipWriter, reader, metadataInfo, options);
|
|
@@ -6305,7 +6422,7 @@
|
|
|
6305
6422
|
const metadataSize = getLength(headerInfo.localHeaderArray, dataDescriptorInfo.dataDescriptorArray);
|
|
6306
6423
|
fileEntry = await getFileEntry(zipWriter, name, reader, { headerInfo, dataDescriptorInfo, metadataSize }, options);
|
|
6307
6424
|
} catch (error) {
|
|
6308
|
-
zipWriter.
|
|
6425
|
+
zipWriter.fileEntries.delete(name);
|
|
6309
6426
|
throw error;
|
|
6310
6427
|
}
|
|
6311
6428
|
Object.assign(fileEntry, {
|
|
@@ -6349,9 +6466,9 @@
|
|
|
6349
6466
|
if (unixExtraFieldType === UNDEFINED_VALUE && (uid !== UNDEFINED_VALUE || gid !== UNDEFINED_VALUE)) {
|
|
6350
6467
|
unixExtraFieldType = INFOZIP_EXTRA_FIELD_TYPE$1;
|
|
6351
6468
|
}
|
|
6352
|
-
let msdosAttributesRaw =
|
|
6469
|
+
let msdosAttributesRaw = getNumberOptionValue(zipWriter, options, PROPERTY_NAME_MSDOS_ATTRIBUTES_RAW);
|
|
6353
6470
|
let msdosAttributes = getOptionValue(zipWriter, options, PROPERTY_NAME_MSDOS_ATTRIBUTES);
|
|
6354
|
-
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;
|
|
6355
6472
|
const hasMsDosProvided = msdosAttributesRaw !== UNDEFINED_VALUE || msdosAttributes !== UNDEFINED_VALUE;
|
|
6356
6473
|
if (hasUnixMetadata) {
|
|
6357
6474
|
msDosCompatible = false;
|
|
@@ -6360,10 +6477,10 @@
|
|
|
6360
6477
|
msDosCompatible = true;
|
|
6361
6478
|
versionMadeBy = (versionMadeBy & MAX_8_BITS);
|
|
6362
6479
|
}
|
|
6363
|
-
if (msdosAttributesRaw !== UNDEFINED_VALUE && (msdosAttributesRaw < 0 || msdosAttributesRaw > MAX_8_BITS)) {
|
|
6480
|
+
if (msdosAttributesRaw !== UNDEFINED_VALUE && (!Number.isInteger(msdosAttributesRaw) || msdosAttributesRaw < 0 || msdosAttributesRaw > MAX_8_BITS)) {
|
|
6364
6481
|
throw new Error(ERR_INVALID_MSDOS_ATTRIBUTES);
|
|
6365
6482
|
}
|
|
6366
|
-
if (msdosAttributes && typeof msdosAttributes !== OBJECT_TYPE) {
|
|
6483
|
+
if (msdosAttributes && (typeof msdosAttributes !== OBJECT_TYPE || Array.isArray(msdosAttributes))) {
|
|
6367
6484
|
throw new Error(ERR_INVALID_MSDOS_DATA);
|
|
6368
6485
|
}
|
|
6369
6486
|
if (versionMadeBy > MAX_16_BITS) {
|
|
@@ -6451,7 +6568,7 @@
|
|
|
6451
6568
|
}
|
|
6452
6569
|
|
|
6453
6570
|
function resolveMetadata(zipWriter, name, options) {
|
|
6454
|
-
const encode =
|
|
6571
|
+
const encode = getFunctionOptionValue(zipWriter, options, OPTION_ENCODE_TEXT) || encodeText;
|
|
6455
6572
|
let rawFilename = encode(name, TEXT_TYPE_FILENAME);
|
|
6456
6573
|
if (rawFilename === UNDEFINED_VALUE) {
|
|
6457
6574
|
rawFilename = encodeText(name);
|
|
@@ -6460,6 +6577,10 @@
|
|
|
6460
6577
|
throw new Error(ERR_INVALID_ENTRY_NAME);
|
|
6461
6578
|
}
|
|
6462
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
|
+
}
|
|
6463
6584
|
let rawComment = encode(comment, TEXT_TYPE_COMMENT);
|
|
6464
6585
|
if (rawComment === UNDEFINED_VALUE) {
|
|
6465
6586
|
rawComment = encodeText(comment);
|
|
@@ -6471,16 +6592,14 @@
|
|
|
6471
6592
|
if (version > MAX_16_BITS) {
|
|
6472
6593
|
throw new Error(ERR_INVALID_VERSION);
|
|
6473
6594
|
}
|
|
6474
|
-
const lastModDate =
|
|
6475
|
-
const lastAccessDate =
|
|
6476
|
-
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);
|
|
6477
6598
|
const internalFileAttributes = getAliasedOptionValue(zipWriter, options, PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTES, PROPERTY_NAME_DEPRECATED_INTERNAL_FILE_ATTRIBUTES, 0);
|
|
6478
6599
|
const passThrough = getOptionValue(zipWriter, options, OPTION_PASS_THROUGH);
|
|
6479
6600
|
const password = getOptionValue(zipWriter, options, OPTION_PASSWORD);
|
|
6480
6601
|
const rawPassword = getOptionValue(zipWriter, options, OPTION_RAW_PASSWORD);
|
|
6481
|
-
|
|
6482
|
-
throw new Error(ERR_INVALID_PASSWORD_TYPE);
|
|
6483
|
-
}
|
|
6602
|
+
checkPasswordOption(password, rawPassword);
|
|
6484
6603
|
const encryptionStrength = getNumberOptionValue(zipWriter, options, OPTION_ENCRYPTION_STRENGTH, 3);
|
|
6485
6604
|
const zipCrypto = getOptionValue(zipWriter, options, PROPERTY_NAME_ZIPCRYPTO);
|
|
6486
6605
|
const extendedTimestamp = getOptionValue(zipWriter, options, OPTION_EXTENDED_TIMESTAMP, true);
|
|
@@ -6489,9 +6608,9 @@
|
|
|
6489
6608
|
const useWebWorkers = getOptionValue(zipWriter, options, OPTION_USE_WEB_WORKERS);
|
|
6490
6609
|
const transferStreams = getOptionValue(zipWriter, options, OPTION_TRANSFER_STREAMS);
|
|
6491
6610
|
const bufferedWrite = getOptionValue(zipWriter, options, OPTION_BUFFERED_WRITE);
|
|
6492
|
-
const createTempStream =
|
|
6611
|
+
const createTempStream = getFunctionOptionValue(zipWriter, options, OPTION_CREATE_TEMP_STREAM);
|
|
6493
6612
|
const dataDescriptorSignature = getOptionValue(zipWriter, options, OPTION_DATA_DESCRIPTOR_SIGNATURE, true);
|
|
6494
|
-
const signal = getOptionValue(zipWriter, options, OPTION_SIGNAL);
|
|
6613
|
+
const signal = checkSignalOption(getOptionValue(zipWriter, options, OPTION_SIGNAL));
|
|
6495
6614
|
const useUnicodeFileNames = getOptionValue(zipWriter, options, OPTION_USE_UNICODE_FILE_NAMES, true);
|
|
6496
6615
|
const compressionMethod = getOptionValue(zipWriter, options, PROPERTY_NAME_COMPRESSION_METHOD);
|
|
6497
6616
|
const registeredCodec = passThrough || compressionMethod === UNDEFINED_VALUE ? UNDEFINED_VALUE : getRegisteredCodec(compressionMethod);
|
|
@@ -6571,18 +6690,26 @@
|
|
|
6571
6690
|
if (!extraField) {
|
|
6572
6691
|
return EMPTY_UINT8_ARRAY;
|
|
6573
6692
|
}
|
|
6693
|
+
if (!(extraField instanceof Map)) {
|
|
6694
|
+
throw new Error(ERR_INVALID_EXTRAFIELD);
|
|
6695
|
+
}
|
|
6574
6696
|
let extraFieldSize = 0;
|
|
6575
6697
|
let offset = 0;
|
|
6576
|
-
extraField.forEach(data => extraFieldSize += 4 + getLength(data));
|
|
6577
|
-
const rawExtraField = new Uint8Array(extraFieldSize);
|
|
6578
|
-
const rawExtraFieldView = getDataView(rawExtraField);
|
|
6579
6698
|
extraField.forEach((data, type) => {
|
|
6580
|
-
if (type > MAX_16_BITS) {
|
|
6699
|
+
if (!Number.isInteger(type) || type < 0 || type > MAX_16_BITS) {
|
|
6581
6700
|
throw new Error(ERR_INVALID_EXTRAFIELD_TYPE);
|
|
6582
6701
|
}
|
|
6702
|
+
if (!(data instanceof Uint8Array)) {
|
|
6703
|
+
throw new Error(ERR_INVALID_EXTRAFIELD_DATA_TYPE);
|
|
6704
|
+
}
|
|
6583
6705
|
if (getLength(data) > MAX_16_BITS) {
|
|
6584
6706
|
throw new Error(ERR_INVALID_EXTRAFIELD_DATA);
|
|
6585
6707
|
}
|
|
6708
|
+
extraFieldSize += 4 + getLength(data);
|
|
6709
|
+
});
|
|
6710
|
+
const rawExtraField = new Uint8Array(extraFieldSize);
|
|
6711
|
+
const rawExtraFieldView = getDataView(rawExtraField);
|
|
6712
|
+
extraField.forEach((data, type) => {
|
|
6586
6713
|
setUint16(rawExtraFieldView, offset, type);
|
|
6587
6714
|
setUint16(rawExtraFieldView, offset + 2, getLength(data));
|
|
6588
6715
|
arraySet(rawExtraField, data, offset + 4);
|
|
@@ -6669,8 +6796,8 @@
|
|
|
6669
6796
|
}
|
|
6670
6797
|
|
|
6671
6798
|
async function getEntriesSize(writerOptions, entries, writeOrderGuaranteed, comment) {
|
|
6672
|
-
const zipWriter = { options: writerOptions
|
|
6673
|
-
if (writerOptions[OPTION_SIGN_CENTRAL_DIRECTORY]) {
|
|
6799
|
+
const zipWriter = { options: writerOptions };
|
|
6800
|
+
if (checkFunctionOption(writerOptions[OPTION_SIGN_CENTRAL_DIRECTORY])) {
|
|
6674
6801
|
throw new Error(ERR_UNDETERMINED_SIZE);
|
|
6675
6802
|
}
|
|
6676
6803
|
if (comment !== UNDEFINED_VALUE && !(comment instanceof Uint8Array)) {
|
|
@@ -6696,7 +6823,7 @@
|
|
|
6696
6823
|
({ name } = attributesInfo);
|
|
6697
6824
|
const { resolvedOptions: metadata } = resolveMetadata(zipWriter, name, options);
|
|
6698
6825
|
if (metadata.level != 0 && metadata.compressionMethod === UNDEFINED_VALUE &&
|
|
6699
|
-
!metadata.passThrough && !(await supportsDeflate(
|
|
6826
|
+
!metadata.passThrough && !(await supportsDeflate(getConfiguration()))) {
|
|
6700
6827
|
metadata.level = 0;
|
|
6701
6828
|
}
|
|
6702
6829
|
const hasContent = !getOptionValue(zipWriter, options, PROPERTY_NAME_DIRECTORY);
|
|
@@ -6745,7 +6872,7 @@
|
|
|
6745
6872
|
|
|
6746
6873
|
async function getFileEntry(zipWriter, name, reader, entryInfo, options) {
|
|
6747
6874
|
const {
|
|
6748
|
-
|
|
6875
|
+
fileEntries,
|
|
6749
6876
|
writer
|
|
6750
6877
|
} = zipWriter;
|
|
6751
6878
|
const {
|
|
@@ -6767,12 +6894,12 @@
|
|
|
6767
6894
|
let writerSizeBeforeEntry;
|
|
6768
6895
|
let flushedBufferedSize = 0;
|
|
6769
6896
|
let fileWriter;
|
|
6770
|
-
|
|
6897
|
+
fileEntries.set(name, fileEntry);
|
|
6771
6898
|
zipWriter.lastFileEntry = fileEntry;
|
|
6772
6899
|
try {
|
|
6773
6900
|
let lockPreviousFileEntry;
|
|
6774
6901
|
if (keepOrder) {
|
|
6775
|
-
lockPreviousFileEntry = previousFileEntry && previousFileEntry.
|
|
6902
|
+
lockPreviousFileEntry = previousFileEntry && previousFileEntry.lockFileEntry;
|
|
6776
6903
|
requestLockCurrentFileEntry();
|
|
6777
6904
|
}
|
|
6778
6905
|
if (options.bufferedWrite || !keepOrder || zipWriter.writerLocked || zipWriter.bufferedWrites || !dataDescriptor) {
|
|
@@ -6793,11 +6920,8 @@
|
|
|
6793
6920
|
const diskOffset = getDiskOffset(writer);
|
|
6794
6921
|
if (zipWriter.addSplitZipSignature) {
|
|
6795
6922
|
delete zipWriter.addSplitZipSignature;
|
|
6796
|
-
|
|
6797
|
-
|
|
6798
|
-
setUint32(signatureArrayView, 0, SPLIT_ZIP_FILE_SIGNATURE);
|
|
6799
|
-
await writeData(writer, signatureArray);
|
|
6800
|
-
zipWriter.offset += 4;
|
|
6923
|
+
await writeData(writer, getSplitZipSignatureArray());
|
|
6924
|
+
zipWriter.offset += SPLIT_ZIP_FILE_SIGNATURE_LENGTH;
|
|
6801
6925
|
}
|
|
6802
6926
|
if (usdz && !bufferedWrite) {
|
|
6803
6927
|
appendExtraFieldUSDZ(entryInfo, zipWriter.offset - diskOffset);
|
|
@@ -6815,11 +6939,11 @@
|
|
|
6815
6939
|
writerSizeBeforeEntry = writer.size;
|
|
6816
6940
|
await writeData(fileWriter, localHeaderArray);
|
|
6817
6941
|
}
|
|
6818
|
-
fileEntry = await createFileEntry(reader, fileWriter, fileEntry, entryInfo,
|
|
6942
|
+
fileEntry = await createFileEntry(reader, fileWriter, fileEntry, entryInfo, getConfiguration(), options);
|
|
6819
6943
|
if (!bufferedWrite) {
|
|
6820
6944
|
writingEntryData = false;
|
|
6821
6945
|
}
|
|
6822
|
-
|
|
6946
|
+
fileEntries.set(name, fileEntry);
|
|
6823
6947
|
fileEntry.filename = name;
|
|
6824
6948
|
if (bufferedWrite) {
|
|
6825
6949
|
await Promise.all([fileWriter.writable.getWriter().close(), lockPreviousFileEntry]);
|
|
@@ -6860,7 +6984,7 @@
|
|
|
6860
6984
|
zipWriter.offset += flushedBufferedSize;
|
|
6861
6985
|
}
|
|
6862
6986
|
}
|
|
6863
|
-
|
|
6987
|
+
fileEntries.delete(name);
|
|
6864
6988
|
throw error;
|
|
6865
6989
|
} finally {
|
|
6866
6990
|
if (bufferedWrite) {
|
|
@@ -6882,7 +7006,7 @@
|
|
|
6882
7006
|
}
|
|
6883
7007
|
|
|
6884
7008
|
function requestLockCurrentFileEntry() {
|
|
6885
|
-
fileEntry.
|
|
7009
|
+
fileEntry.lockFileEntry = new Promise(resolve => releaseLockCurrentFileEntry = resolve);
|
|
6886
7010
|
}
|
|
6887
7011
|
|
|
6888
7012
|
async function requestLockWriter() {
|
|
@@ -6902,7 +7026,7 @@
|
|
|
6902
7026
|
}
|
|
6903
7027
|
}
|
|
6904
7028
|
|
|
6905
|
-
async function createFileEntry(reader, writer, { diskNumberStart,
|
|
7029
|
+
async function createFileEntry(reader, writer, { diskNumberStart, lockFileEntry }, entryInfo, config, options) {
|
|
6906
7030
|
const {
|
|
6907
7031
|
headerInfo,
|
|
6908
7032
|
dataDescriptorInfo,
|
|
@@ -6970,7 +7094,7 @@
|
|
|
6970
7094
|
codecURI
|
|
6971
7095
|
} = options;
|
|
6972
7096
|
const fileEntry = {
|
|
6973
|
-
|
|
7097
|
+
lockFileEntry,
|
|
6974
7098
|
versionMadeBy,
|
|
6975
7099
|
zip64,
|
|
6976
7100
|
directory: Boolean(directory),
|
|
@@ -7012,7 +7136,7 @@
|
|
|
7012
7136
|
}
|
|
7013
7137
|
const { writable } = writer;
|
|
7014
7138
|
if (reader) {
|
|
7015
|
-
const readable = toCompatibleReadable(
|
|
7139
|
+
const readable = toCompatibleReadable(createReadable(reader));
|
|
7016
7140
|
const size = reader.size;
|
|
7017
7141
|
const workerOptions = {
|
|
7018
7142
|
options: {
|
|
@@ -7124,14 +7248,14 @@
|
|
|
7124
7248
|
if (zip64 && (zip64UncompressedSize || zip64CompressedSize)) {
|
|
7125
7249
|
const length = 4 + 16;
|
|
7126
7250
|
const extraFieldZip64 = createRecordWriter(length);
|
|
7127
|
-
extraFieldZip64.
|
|
7128
|
-
extraFieldZip64.
|
|
7251
|
+
extraFieldZip64.writeUint16(EXTRAFIELD_TYPE_ZIP64);
|
|
7252
|
+
extraFieldZip64.writeUint16(length - 4);
|
|
7129
7253
|
rawLocalExtraFieldZip64 = extraFieldZip64.array;
|
|
7130
7254
|
if (zip64ExtraFieldComplete) {
|
|
7131
|
-
extraFieldZip64.
|
|
7255
|
+
extraFieldZip64.writeUint64(uncompressedSize);
|
|
7132
7256
|
if (uncompressedFile) {
|
|
7133
7257
|
const encryptionOverhead = encrypted ? (zipCrypto ? 12 : 16 + encryptionStrength * 4) : 0;
|
|
7134
|
-
extraFieldZip64.
|
|
7258
|
+
extraFieldZip64.writeUint64(passThrough ? 0 : uncompressedSize + encryptionOverhead);
|
|
7135
7259
|
}
|
|
7136
7260
|
}
|
|
7137
7261
|
} else {
|
|
@@ -7140,8 +7264,8 @@
|
|
|
7140
7264
|
let rawExtraFieldAES;
|
|
7141
7265
|
if (encrypted && !zipCrypto) {
|
|
7142
7266
|
const extraFieldAES = createRecordWriter(getLength(EXTRAFIELD_DATA_AES) + 2);
|
|
7143
|
-
extraFieldAES.
|
|
7144
|
-
extraFieldAES.
|
|
7267
|
+
extraFieldAES.writeUint16(EXTRAFIELD_TYPE_AES);
|
|
7268
|
+
extraFieldAES.writeBytes(EXTRAFIELD_DATA_AES);
|
|
7145
7269
|
rawExtraFieldAES = extraFieldAES.array;
|
|
7146
7270
|
rawExtraFieldAES[8] = encryptionStrength;
|
|
7147
7271
|
} else {
|
|
@@ -7157,15 +7281,15 @@
|
|
|
7157
7281
|
const extraFieldTimestampLength = 9 + (lastAccessDate ? 4 : 0) + (creationDate ? 4 : 0);
|
|
7158
7282
|
const extraFieldTimestamp = createRecordWriter(extraFieldTimestampLength);
|
|
7159
7283
|
extraFieldExtendedTimestampFlag = 0x1 + (lastAccessDate ? 0x2 : 0) + (creationDate ? 0x4 : 0);
|
|
7160
|
-
extraFieldTimestamp.
|
|
7161
|
-
extraFieldTimestamp.
|
|
7162
|
-
extraFieldTimestamp.
|
|
7163
|
-
extraFieldTimestamp.
|
|
7284
|
+
extraFieldTimestamp.writeUint16(EXTRAFIELD_TYPE_EXTENDED_TIMESTAMP);
|
|
7285
|
+
extraFieldTimestamp.writeUint16(extraFieldTimestampLength - 4);
|
|
7286
|
+
extraFieldTimestamp.writeUint8(extraFieldExtendedTimestampFlag);
|
|
7287
|
+
extraFieldTimestamp.writeUint32(lastModTimeUnix);
|
|
7164
7288
|
if (lastAccessDate) {
|
|
7165
|
-
extraFieldTimestamp.
|
|
7289
|
+
extraFieldTimestamp.writeUint32(clampUnixTime(getTimeUnix(lastAccessDate)));
|
|
7166
7290
|
}
|
|
7167
7291
|
if (creationDate) {
|
|
7168
|
-
extraFieldTimestamp.
|
|
7292
|
+
extraFieldTimestamp.writeUint32(clampUnixTime(getTimeUnix(creationDate)));
|
|
7169
7293
|
}
|
|
7170
7294
|
rawExtraFieldExtendedTimestamp = extraFieldTimestamp.array;
|
|
7171
7295
|
} else {
|
|
@@ -7178,14 +7302,14 @@
|
|
|
7178
7302
|
try {
|
|
7179
7303
|
const lastModTimeNTFS = getTimeNTFS(lastModDate);
|
|
7180
7304
|
const extraFieldNTFS = createRecordWriter(36);
|
|
7181
|
-
extraFieldNTFS.
|
|
7182
|
-
extraFieldNTFS.
|
|
7305
|
+
extraFieldNTFS.writeUint16(EXTRAFIELD_TYPE_NTFS);
|
|
7306
|
+
extraFieldNTFS.writeUint16(32);
|
|
7183
7307
|
extraFieldNTFS.skip(4);
|
|
7184
|
-
extraFieldNTFS.
|
|
7185
|
-
extraFieldNTFS.
|
|
7186
|
-
extraFieldNTFS.
|
|
7187
|
-
extraFieldNTFS.
|
|
7188
|
-
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);
|
|
7189
7313
|
rawExtraFieldNTFS = extraFieldNTFS.array;
|
|
7190
7314
|
} catch {
|
|
7191
7315
|
rawExtraFieldNTFS = EMPTY_UINT8_ARRAY;
|
|
@@ -7204,20 +7328,20 @@
|
|
|
7204
7328
|
const gidBytes = packUnixId(gid);
|
|
7205
7329
|
const payloadLength = 3 + uidBytes.length + gidBytes.length;
|
|
7206
7330
|
const extraFieldUnix = createRecordWriter(4 + payloadLength);
|
|
7207
|
-
extraFieldUnix.
|
|
7208
|
-
extraFieldUnix.
|
|
7209
|
-
extraFieldUnix.
|
|
7210
|
-
extraFieldUnix.
|
|
7211
|
-
extraFieldUnix.
|
|
7212
|
-
extraFieldUnix.
|
|
7213
|
-
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);
|
|
7214
7338
|
rawExtraFieldUnix = extraFieldUnix.array;
|
|
7215
7339
|
} else if (unixExtraFieldType == UNIX_EXTRA_FIELD_TYPE && (uid !== UNDEFINED_VALUE || gid !== UNDEFINED_VALUE)) {
|
|
7216
7340
|
const extraFieldUnix = createRecordWriter(8);
|
|
7217
|
-
extraFieldUnix.
|
|
7218
|
-
extraFieldUnix.
|
|
7219
|
-
extraFieldUnix.
|
|
7220
|
-
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);
|
|
7221
7345
|
rawExtraFieldUnix = extraFieldUnix.array;
|
|
7222
7346
|
} else {
|
|
7223
7347
|
rawExtraFieldUnix = EMPTY_UINT8_ARRAY;
|
|
@@ -7267,18 +7391,18 @@
|
|
|
7267
7391
|
const localHeader = createRecordWriter(HEADER_SIZE + getLength(rawFilename) + extraFieldLength);
|
|
7268
7392
|
const localHeaderArray = localHeader.array;
|
|
7269
7393
|
const localHeaderView = getDataView(localHeaderArray);
|
|
7270
|
-
localHeader.
|
|
7271
|
-
localHeader.
|
|
7272
|
-
localHeader.
|
|
7394
|
+
localHeader.writeUint32(LOCAL_FILE_HEADER_SIGNATURE);
|
|
7395
|
+
localHeader.writeBytes(headerArray);
|
|
7396
|
+
localHeader.writeBytes(rawFilename);
|
|
7273
7397
|
if (writeLocalExtraFieldZip64) {
|
|
7274
|
-
localHeader.
|
|
7275
|
-
}
|
|
7276
|
-
localHeader.
|
|
7277
|
-
localHeader.
|
|
7278
|
-
localHeader.
|
|
7279
|
-
localHeader.
|
|
7280
|
-
localHeader.
|
|
7281
|
-
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);
|
|
7282
7406
|
if (dataDescriptor) {
|
|
7283
7407
|
if (!zip64CompressedSize) {
|
|
7284
7408
|
setUint32(localHeaderView, HEADER_OFFSET_COMPRESSED_SIZE + LOCAL_HEADER_COMMON_OFFSET, 0);
|
|
@@ -7468,7 +7592,7 @@
|
|
|
7468
7592
|
|
|
7469
7593
|
|
|
7470
7594
|
async function closeFile(zipWriter, comment, options) {
|
|
7471
|
-
const directoryDataLength = createDirectoryRecords(zipWriter.
|
|
7595
|
+
const directoryDataLength = createDirectoryRecords(zipWriter.fileEntries);
|
|
7472
7596
|
const { directoryStart, directoryArray } = await writeDirectoryRecords(zipWriter, directoryDataLength, options);
|
|
7473
7597
|
const signatureLength = await writeDigitalSignatureRecord(zipWriter, directoryArray, options);
|
|
7474
7598
|
await writeEndOfDirectoryRecord(zipWriter, comment, options, { directoryStart, directoryDataLength, signatureLength });
|
|
@@ -7498,19 +7622,19 @@
|
|
|
7498
7622
|
if (zip64Offset || zip64DiskNumberStart || zip64UncompressedSize || zip64CompressedSize) {
|
|
7499
7623
|
const length = 4 + (zip64UncompressedSize ? 8 : 0) + (zip64CompressedSize ? 8 : 0) + (zip64Offset ? 8 : 0) + (zip64DiskNumberStart ? 4 : 0);
|
|
7500
7624
|
const extraFieldZip64 = createRecordWriter(length);
|
|
7501
|
-
extraFieldZip64.
|
|
7502
|
-
extraFieldZip64.
|
|
7625
|
+
extraFieldZip64.writeUint16(EXTRAFIELD_TYPE_ZIP64);
|
|
7626
|
+
extraFieldZip64.writeUint16(length - 4);
|
|
7503
7627
|
if (zip64UncompressedSize) {
|
|
7504
|
-
extraFieldZip64.
|
|
7628
|
+
extraFieldZip64.writeUint64(uncompressedSize);
|
|
7505
7629
|
}
|
|
7506
7630
|
if (zip64CompressedSize) {
|
|
7507
|
-
extraFieldZip64.
|
|
7631
|
+
extraFieldZip64.writeUint64(compressedSize);
|
|
7508
7632
|
}
|
|
7509
7633
|
if (zip64Offset) {
|
|
7510
|
-
extraFieldZip64.
|
|
7634
|
+
extraFieldZip64.writeUint64(fileEntry.offset);
|
|
7511
7635
|
}
|
|
7512
7636
|
if (zip64DiskNumberStart) {
|
|
7513
|
-
extraFieldZip64.
|
|
7637
|
+
extraFieldZip64.writeUint32(fileEntry.diskNumberStart);
|
|
7514
7638
|
}
|
|
7515
7639
|
rawExtraFieldZip64 = extraFieldZip64.array;
|
|
7516
7640
|
} else {
|
|
@@ -7523,10 +7647,10 @@
|
|
|
7523
7647
|
const lastModTimeUnix = getTimeUnix(lastModDate);
|
|
7524
7648
|
if (extendedTimestamp && inUnixTimeRange(lastModTimeUnix)) {
|
|
7525
7649
|
const extraFieldTimestamp = createRecordWriter(9);
|
|
7526
|
-
extraFieldTimestamp.
|
|
7527
|
-
extraFieldTimestamp.
|
|
7528
|
-
extraFieldTimestamp.
|
|
7529
|
-
extraFieldTimestamp.
|
|
7650
|
+
extraFieldTimestamp.writeUint16(EXTRAFIELD_TYPE_EXTENDED_TIMESTAMP);
|
|
7651
|
+
extraFieldTimestamp.writeUint16(5);
|
|
7652
|
+
extraFieldTimestamp.writeUint8(extraFieldExtendedTimestampFlag);
|
|
7653
|
+
extraFieldTimestamp.writeUint32(lastModTimeUnix);
|
|
7530
7654
|
rawExtraFieldTimestamp = extraFieldTimestamp.array;
|
|
7531
7655
|
} else {
|
|
7532
7656
|
rawExtraFieldTimestamp = EMPTY_UINT8_ARRAY;
|
|
@@ -7548,14 +7672,14 @@
|
|
|
7548
7672
|
}
|
|
7549
7673
|
|
|
7550
7674
|
async function writeDirectoryRecords(zipWriter, directoryDataLength, options) {
|
|
7551
|
-
const {
|
|
7675
|
+
const { fileEntries, writer } = zipWriter;
|
|
7552
7676
|
const directoryArray = new Uint8Array(directoryDataLength);
|
|
7553
7677
|
await initStream(writer);
|
|
7554
7678
|
let offset = 0;
|
|
7555
7679
|
let directoryDiskOffset = 0;
|
|
7556
7680
|
let directoryStartDiskNumber = getDiskNumber(writer);
|
|
7557
7681
|
let directoryStartDiskOffset = getDiskOffset(writer);
|
|
7558
|
-
for (const [indexFileEntry, fileEntry] of Array.from(
|
|
7682
|
+
for (const [indexFileEntry, fileEntry] of Array.from(fileEntries.values()).entries()) {
|
|
7559
7683
|
const {
|
|
7560
7684
|
offset: fileEntryOffset,
|
|
7561
7685
|
rawFilename,
|
|
@@ -7600,28 +7724,28 @@
|
|
|
7600
7724
|
setUint16(headerView, HEADER_OFFSET_VERSION, VERSION_ZIP64);
|
|
7601
7725
|
}
|
|
7602
7726
|
const directoryRecord = createRecordWriter(directoryRecordLength);
|
|
7603
|
-
directoryRecord.
|
|
7604
|
-
directoryRecord.
|
|
7605
|
-
directoryRecord.
|
|
7606
|
-
directoryRecord.
|
|
7607
|
-
directoryRecord.
|
|
7608
|
-
directoryRecord.
|
|
7609
|
-
directoryRecord.
|
|
7610
|
-
directoryRecord.
|
|
7611
|
-
directoryRecord.
|
|
7612
|
-
directoryRecord.
|
|
7613
|
-
directoryRecord.
|
|
7614
|
-
directoryRecord.
|
|
7615
|
-
directoryRecord.
|
|
7616
|
-
directoryRecord.
|
|
7617
|
-
directoryRecord.
|
|
7618
|
-
directoryRecord.
|
|
7619
|
-
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);
|
|
7620
7744
|
arraySet(directoryArray, directoryRecord.array, offset);
|
|
7621
7745
|
offset += directoryRecordLength;
|
|
7622
7746
|
if (options.onprogress) {
|
|
7623
7747
|
try {
|
|
7624
|
-
await options.onprogress(indexFileEntry + 1,
|
|
7748
|
+
await options.onprogress(indexFileEntry + 1, fileEntries.size, new Entry(fileEntry));
|
|
7625
7749
|
} catch {
|
|
7626
7750
|
// ignored
|
|
7627
7751
|
}
|
|
@@ -7635,7 +7759,7 @@
|
|
|
7635
7759
|
}
|
|
7636
7760
|
|
|
7637
7761
|
async function writeDigitalSignatureRecord(zipWriter, directoryArray, options) {
|
|
7638
|
-
const signCentralDirectory =
|
|
7762
|
+
const signCentralDirectory = getFunctionOptionValue(zipWriter, options, OPTION_SIGN_CENTRAL_DIRECTORY);
|
|
7639
7763
|
if (signCentralDirectory) {
|
|
7640
7764
|
const signatureData = await signCentralDirectory(directoryArray);
|
|
7641
7765
|
const signatureDataLength = getLength(signatureData);
|
|
@@ -7643,9 +7767,9 @@
|
|
|
7643
7767
|
throw new Error(ERR_INVALID_SIGNATURE_DATA);
|
|
7644
7768
|
}
|
|
7645
7769
|
const signatureRecord = createRecordWriter(6 + signatureDataLength);
|
|
7646
|
-
signatureRecord.
|
|
7647
|
-
signatureRecord.
|
|
7648
|
-
signatureRecord.
|
|
7770
|
+
signatureRecord.writeUint32(DIGITAL_SIGNATURE_RECORD_SIGNATURE);
|
|
7771
|
+
signatureRecord.writeUint16(signatureDataLength);
|
|
7772
|
+
signatureRecord.writeBytes(signatureData);
|
|
7649
7773
|
await writeData(zipWriter.writer, signatureRecord.array);
|
|
7650
7774
|
return 6 + signatureDataLength;
|
|
7651
7775
|
}
|
|
@@ -7656,7 +7780,7 @@
|
|
|
7656
7780
|
const { writer } = zipWriter;
|
|
7657
7781
|
const { directoryStart, signatureLength } = cdInfo;
|
|
7658
7782
|
let { directoryDataLength } = cdInfo;
|
|
7659
|
-
let
|
|
7783
|
+
let fileEntriesLength = zipWriter.fileEntries.size;
|
|
7660
7784
|
let diskNumber = directoryStart.diskNumber;
|
|
7661
7785
|
let directoryOffset = getSegmentOffset(zipWriter, directoryStart);
|
|
7662
7786
|
let lastDiskNumber = getDiskNumber(writer);
|
|
@@ -7664,7 +7788,7 @@
|
|
|
7664
7788
|
lastDiskNumber++;
|
|
7665
7789
|
}
|
|
7666
7790
|
let zip64 = getOptionValue(zipWriter, options, PROPERTY_NAME_ZIP64);
|
|
7667
|
-
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) {
|
|
7668
7792
|
if (zip64 === false) {
|
|
7669
7793
|
throw new Error(ERR_UNSUPPORTED_FORMAT);
|
|
7670
7794
|
} else {
|
|
@@ -7681,37 +7805,37 @@
|
|
|
7681
7805
|
}
|
|
7682
7806
|
lastDiskNumber = getDiskNumber(writer);
|
|
7683
7807
|
if (zip64) {
|
|
7684
|
-
endOfdirectoryRecord.
|
|
7685
|
-
endOfdirectoryRecord.
|
|
7686
|
-
endOfdirectoryRecord.
|
|
7687
|
-
endOfdirectoryRecord.
|
|
7688
|
-
endOfdirectoryRecord.
|
|
7689
|
-
endOfdirectoryRecord.
|
|
7690
|
-
endOfdirectoryRecord.
|
|
7691
|
-
endOfdirectoryRecord.
|
|
7692
|
-
endOfdirectoryRecord.
|
|
7693
|
-
endOfdirectoryRecord.
|
|
7694
|
-
endOfdirectoryRecord.
|
|
7695
|
-
endOfdirectoryRecord.
|
|
7696
|
-
endOfdirectoryRecord.
|
|
7697
|
-
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);
|
|
7698
7822
|
const supportZip64SplitFile = getOptionValue(zipWriter, options, OPTION_SUPPORT_ZIP64_SPLIT_FILE, true);
|
|
7699
7823
|
if (supportZip64SplitFile) {
|
|
7700
7824
|
lastDiskNumber = MAX_16_BITS;
|
|
7701
7825
|
diskNumber = MAX_16_BITS;
|
|
7702
7826
|
}
|
|
7703
|
-
|
|
7827
|
+
fileEntriesLength = MAX_16_BITS;
|
|
7704
7828
|
directoryOffset = MAX_32_BITS;
|
|
7705
7829
|
directoryDataLength = MAX_32_BITS;
|
|
7706
7830
|
}
|
|
7707
|
-
endOfdirectoryRecord.
|
|
7708
|
-
endOfdirectoryRecord.
|
|
7709
|
-
endOfdirectoryRecord.
|
|
7710
|
-
endOfdirectoryRecord.
|
|
7711
|
-
endOfdirectoryRecord.
|
|
7712
|
-
endOfdirectoryRecord.
|
|
7713
|
-
endOfdirectoryRecord.
|
|
7714
|
-
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);
|
|
7715
7839
|
await writeData(writer, endOfdirectoryRecord.array);
|
|
7716
7840
|
if (commentLength) {
|
|
7717
7841
|
await writeData(writer, comment);
|
|
@@ -7724,11 +7848,11 @@
|
|
|
7724
7848
|
let offset = 0;
|
|
7725
7849
|
return {
|
|
7726
7850
|
array,
|
|
7727
|
-
|
|
7728
|
-
|
|
7729
|
-
|
|
7730
|
-
|
|
7731
|
-
|
|
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); },
|
|
7732
7856
|
skip: count => offset += count
|
|
7733
7857
|
};
|
|
7734
7858
|
}
|
|
@@ -7752,6 +7876,71 @@
|
|
|
7752
7876
|
return zipWriter.offset - diskOffset - (diskNumber ? zipWriter.initialOffset : 0);
|
|
7753
7877
|
}
|
|
7754
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
|
+
|
|
7755
7944
|
async function writeData(writer, array) {
|
|
7756
7945
|
const { writable } = writer;
|
|
7757
7946
|
const streamWriter = writable.getWriter();
|
|
@@ -7803,6 +7992,21 @@
|
|
|
7803
7992
|
return result === UNDEFINED_VALUE ? defaultValue : result;
|
|
7804
7993
|
}
|
|
7805
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
|
+
|
|
7806
8010
|
function getAliasedOptionValue(zipWriter, options, name, deprecatedName, defaultValue) {
|
|
7807
8011
|
const value = getAliasedValue(options, name, deprecatedName);
|
|
7808
8012
|
const result = value === UNDEFINED_VALUE ? getAliasedValue(zipWriter.options, name, deprecatedName) : value;
|
|
@@ -7817,9 +8021,6 @@
|
|
|
7817
8021
|
return toNumber(getOptionValue(zipWriter, options, name, defaultValue));
|
|
7818
8022
|
}
|
|
7819
8023
|
|
|
7820
|
-
function toNumber(value) {
|
|
7821
|
-
return typeof value == STRING_TYPE && value.trim() ? Number(value) : value;
|
|
7822
|
-
}
|
|
7823
8024
|
|
|
7824
8025
|
function getMaximumCompressedSize(uncompressedSize) {
|
|
7825
8026
|
return uncompressedSize + (5 * (Math.floor(uncompressedSize / 16383) + 1));
|
|
@@ -7831,6 +8032,14 @@
|
|
|
7831
8032
|
: compressionMethod !== COMPRESSION_METHOD_STORE;
|
|
7832
8033
|
}
|
|
7833
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
|
+
|
|
7834
8043
|
function setUint8(view, offset, value) {
|
|
7835
8044
|
view.setUint8(offset, value);
|
|
7836
8045
|
}
|
|
@@ -7874,9 +8083,9 @@
|
|
|
7874
8083
|
const headerRecord = createRecordWriter(HEADER_SIZE - 4);
|
|
7875
8084
|
const headerArray = headerRecord.array;
|
|
7876
8085
|
const headerView = getDataView(headerArray);
|
|
7877
|
-
headerRecord.
|
|
7878
|
-
headerRecord.
|
|
7879
|
-
headerRecord.
|
|
8086
|
+
headerRecord.writeUint16(version);
|
|
8087
|
+
headerRecord.writeUint16(bitFlag);
|
|
8088
|
+
headerRecord.writeUint16(compressionMethod);
|
|
7880
8089
|
if (rawLastModDate === UNDEFINED_VALUE) {
|
|
7881
8090
|
const dateArray = new Uint32Array(1);
|
|
7882
8091
|
const dateView = getDataView(dateArray);
|
|
@@ -7884,20 +8093,20 @@
|
|
|
7884
8093
|
setUint16(dateView, 2, ((((lastModDate.getFullYear() - 1980) << 4) | (lastModDate.getMonth() + 1)) << 5) | lastModDate.getDate());
|
|
7885
8094
|
rawLastModDate = dateArray[0];
|
|
7886
8095
|
}
|
|
7887
|
-
headerRecord.
|
|
8096
|
+
headerRecord.writeUint32(rawLastModDate);
|
|
7888
8097
|
headerRecord.skip(4);
|
|
7889
8098
|
if (zip64CompressedSize || compressedSize !== UNDEFINED_VALUE) {
|
|
7890
|
-
headerRecord.
|
|
8099
|
+
headerRecord.writeUint32(zip64CompressedSize ? MAX_32_BITS : compressedSize);
|
|
7891
8100
|
} else {
|
|
7892
8101
|
headerRecord.skip(4);
|
|
7893
8102
|
}
|
|
7894
8103
|
if (zip64UncompressedSize || uncompressedSize !== UNDEFINED_VALUE) {
|
|
7895
|
-
headerRecord.
|
|
8104
|
+
headerRecord.writeUint32(zip64UncompressedSize ? MAX_32_BITS : uncompressedSize);
|
|
7896
8105
|
} else {
|
|
7897
8106
|
headerRecord.skip(4);
|
|
7898
8107
|
}
|
|
7899
|
-
headerRecord.
|
|
7900
|
-
headerRecord.
|
|
8108
|
+
headerRecord.writeUint16(getLength(rawFilename));
|
|
8109
|
+
headerRecord.writeUint16(extraFieldLength);
|
|
7901
8110
|
return {
|
|
7902
8111
|
headerArray,
|
|
7903
8112
|
headerView,
|
|
@@ -8845,6 +9054,7 @@
|
|
|
8845
9054
|
const ERR_ENTRY_EXISTS = "Entry filename already exists";
|
|
8846
9055
|
const ERR_READABLE_CONSUMED = "Readable stream already consumed";
|
|
8847
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)";
|
|
8848
9058
|
const ERR_ABORT_EXPORT = "zipjs-abort-export";
|
|
8849
9059
|
const ERR_ABORTED = "The operation was aborted";
|
|
8850
9060
|
const ABORT_ERROR_NAME = "AbortError";
|
|
@@ -8877,13 +9087,14 @@
|
|
|
8877
9087
|
fs,
|
|
8878
9088
|
name,
|
|
8879
9089
|
data: params.data,
|
|
8880
|
-
options: params.options,
|
|
9090
|
+
options: params.options && Object.assign({}, params.options),
|
|
8881
9091
|
id: fs.entryIdCounter++,
|
|
8882
9092
|
parent,
|
|
8883
9093
|
children: [],
|
|
8884
9094
|
uncompressedSize: params.uncompressedSize || 0,
|
|
8885
9095
|
undeterminedSize: params.undeterminedSize || params.uncompressedSize === UNDEFINED_VALUE,
|
|
8886
|
-
passThrough: params.passThrough
|
|
9096
|
+
passThrough: params.passThrough,
|
|
9097
|
+
defaultLastModDate: params.defaultLastModDate || new Date()
|
|
8887
9098
|
});
|
|
8888
9099
|
if (parent || !fs.root) {
|
|
8889
9100
|
fs.entries[zipEntry.id] = zipEntry;
|
|
@@ -8893,12 +9104,6 @@
|
|
|
8893
9104
|
}
|
|
8894
9105
|
}
|
|
8895
9106
|
|
|
8896
|
-
moveTo(target) {
|
|
8897
|
-
// deprecated
|
|
8898
|
-
const zipEntry = this;
|
|
8899
|
-
zipEntry.fs.move(zipEntry, target);
|
|
8900
|
-
}
|
|
8901
|
-
|
|
8902
9107
|
getFullname() {
|
|
8903
9108
|
return this.getRelativeName();
|
|
8904
9109
|
}
|
|
@@ -8930,6 +9135,11 @@
|
|
|
8930
9135
|
this.name = name;
|
|
8931
9136
|
}
|
|
8932
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
|
+
}
|
|
8933
9143
|
}
|
|
8934
9144
|
|
|
8935
9145
|
class ZipFileEntry extends ZipEntry {
|
|
@@ -8956,7 +9166,7 @@
|
|
|
8956
9166
|
const reader = zipEntry.reader = createReader(zipEntry.Reader, zipEntry.data, options);
|
|
8957
9167
|
const dataSize = zipEntry.uncompressedSize || reader.size;
|
|
8958
9168
|
await Promise.all([initStream(reader), initStream(writer, dataSize)]);
|
|
8959
|
-
const
|
|
9169
|
+
const signal = checkSignalOption(options.signal);
|
|
8960
9170
|
const readable = createProgressReadable(zipEntry, reader, options, signal);
|
|
8961
9171
|
const preventClose = !ownsWritable(writer) && Boolean(options.preventClose);
|
|
8962
9172
|
zipEntry.uncompressedSize = reader.size;
|
|
@@ -9174,10 +9384,6 @@
|
|
|
9174
9384
|
});
|
|
9175
9385
|
}
|
|
9176
9386
|
|
|
9177
|
-
addData(name, params) {
|
|
9178
|
-
return addChild(this, name, params);
|
|
9179
|
-
}
|
|
9180
|
-
|
|
9181
9387
|
importBlob(blob, options) {
|
|
9182
9388
|
return this.importZip(new BlobReader(blob), options);
|
|
9183
9389
|
}
|
|
@@ -9291,7 +9497,7 @@
|
|
|
9291
9497
|
if (options.bufferedWrite === UNDEFINED_VALUE) {
|
|
9292
9498
|
options.bufferedWrite = true;
|
|
9293
9499
|
}
|
|
9294
|
-
const [readers] = await Promise.all([initReaders(zipEntry, options.readerOptions), initStream(writer)]);
|
|
9500
|
+
const [readers] = await Promise.all([initReaders(zipEntry, checkReaderOptions(options.readerOptions)), initStream(writer)]);
|
|
9295
9501
|
const zipWriter = new ZipWriter(writer, options);
|
|
9296
9502
|
await exportZip(zipWriter, zipEntry, getTotalSize([zipEntry], getUncompressedSize), options, readers);
|
|
9297
9503
|
await zipWriter.close(options.globalComment);
|
|
@@ -9301,12 +9507,13 @@
|
|
|
9301
9507
|
getExportedSize(options = {}) {
|
|
9302
9508
|
const zipEntry = this;
|
|
9303
9509
|
options = Object.assign({}, options);
|
|
9510
|
+
checkReaderOptions(options.readerOptions);
|
|
9304
9511
|
if (options.bufferedWrite === UNDEFINED_VALUE) {
|
|
9305
9512
|
options.bufferedWrite = true;
|
|
9306
9513
|
}
|
|
9307
9514
|
const writeOrderGuaranteed = !options.bufferedWrite ||
|
|
9308
9515
|
(options.keepOrder !== false && zipEntry.children.every(child => !child.children.length));
|
|
9309
|
-
return getEntriesSize(options,
|
|
9516
|
+
return getEntriesSize(options, zipEntry.getChildren({ recursive: true }).filter(child => !isImplicitDirectory(child)).map(child => {
|
|
9310
9517
|
const { name, entryOptions } = getChildEntryOptions(child, zipEntry, options);
|
|
9311
9518
|
return { name, size: child.directory ? 0 : getDeterminedSize(child, isPassThrough(child, options)), options: entryOptions };
|
|
9312
9519
|
}), writeOrderGuaranteed, options.globalComment);
|
|
@@ -9345,7 +9552,7 @@
|
|
|
9345
9552
|
}
|
|
9346
9553
|
|
|
9347
9554
|
|
|
9348
|
-
class
|
|
9555
|
+
class ZipFS {
|
|
9349
9556
|
|
|
9350
9557
|
constructor() {
|
|
9351
9558
|
resetFS(this);
|
|
@@ -9461,10 +9668,6 @@
|
|
|
9461
9668
|
return this.root.addFile(file, options);
|
|
9462
9669
|
}
|
|
9463
9670
|
|
|
9464
|
-
addData(name, params) {
|
|
9465
|
-
return this.root.addData(name, params);
|
|
9466
|
-
}
|
|
9467
|
-
|
|
9468
9671
|
importBlob(blob, options) {
|
|
9469
9672
|
resetFS(this);
|
|
9470
9673
|
return this.root.importBlob(blob, options);
|
|
@@ -9532,7 +9735,7 @@
|
|
|
9532
9735
|
}
|
|
9533
9736
|
}
|
|
9534
9737
|
|
|
9535
|
-
const fs = { FS, ZipDirectoryEntry, ZipFileEntry };
|
|
9738
|
+
const fs = { FS: ZipFS, ZipDirectoryEntry, ZipFileEntry };
|
|
9536
9739
|
|
|
9537
9740
|
function getTotalSize(entries, getEntrySize) {
|
|
9538
9741
|
let size = 0;
|
|
@@ -9676,7 +9879,7 @@
|
|
|
9676
9879
|
}
|
|
9677
9880
|
|
|
9678
9881
|
function forwardAbort(signal, abortController) {
|
|
9679
|
-
if (!signal) {
|
|
9882
|
+
if (!checkSignalOption(signal)) {
|
|
9680
9883
|
return () => { };
|
|
9681
9884
|
}
|
|
9682
9885
|
if (signal.aborted) {
|
|
@@ -9772,7 +9975,7 @@
|
|
|
9772
9975
|
};
|
|
9773
9976
|
}
|
|
9774
9977
|
}
|
|
9775
|
-
const entryOptions = Object.assign({}, zipEntryMetadata, options,
|
|
9978
|
+
const entryOptions = Object.assign({ lastModDate: child.defaultLastModDate }, zipEntryMetadata, options, childOptions, passThroughOptions, { directory: child.directory });
|
|
9776
9979
|
if (!child.directory && entryOptions.passThrough && entryOptions.uncompressedSize === UNDEFINED_VALUE) {
|
|
9777
9980
|
throw new Error(ERR_INVALID_PASS_THROUGH);
|
|
9778
9981
|
}
|
|
@@ -9787,11 +9990,22 @@
|
|
|
9787
9990
|
return child.undeterminedSize ? UNDEFINED_VALUE : getExtractedSize(child, passThrough);
|
|
9788
9991
|
}
|
|
9789
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
|
+
|
|
9790
10000
|
function isPassThrough(child, options) {
|
|
9791
10001
|
const { readerOptions } = options;
|
|
9792
10002
|
return Boolean(!child.directory && (child.passThrough || (readerOptions && readerOptions.passThrough)));
|
|
9793
10003
|
}
|
|
9794
10004
|
|
|
10005
|
+
function isImplicitDirectory(child) {
|
|
10006
|
+
return child.directory && child.data === null;
|
|
10007
|
+
}
|
|
10008
|
+
|
|
9795
10009
|
function getUserExtraField(extraField) {
|
|
9796
10010
|
if (extraField) {
|
|
9797
10011
|
const userExtraField = new Map();
|
|
@@ -9809,7 +10023,7 @@
|
|
|
9809
10023
|
async function exportZip(zipWriter, entry, totalSize, options, readers) {
|
|
9810
10024
|
const { onstart, onprogress, onend, onentryprogress } = options;
|
|
9811
10025
|
const selectedEntry = entry;
|
|
9812
|
-
const totalEntries = getTotalSize(entry.children, ()
|
|
10026
|
+
const totalEntries = getTotalSize(entry.children, child => isImplicitDirectory(child) ? 0 : 1);
|
|
9813
10027
|
let writtenSize = 0;
|
|
9814
10028
|
let writtenEntries = 0;
|
|
9815
10029
|
if (onstart) {
|
|
@@ -9838,6 +10052,9 @@
|
|
|
9838
10052
|
}
|
|
9839
10053
|
|
|
9840
10054
|
async function addChild(child) {
|
|
10055
|
+
if (isImplicitDirectory(child)) {
|
|
10056
|
+
return;
|
|
10057
|
+
}
|
|
9841
10058
|
const { name, entryOptions } = getChildEntryOptions(child, selectedEntry, options);
|
|
9842
10059
|
let entryWrittenSize = 0;
|
|
9843
10060
|
const entryMetadata = await zipWriter.add(name, readers.get(child), Object.assign(entryOptions, {
|
|
@@ -9871,7 +10088,7 @@
|
|
|
9871
10088
|
if (handle.kind == "file") {
|
|
9872
10089
|
const file = await handle.getFile();
|
|
9873
10090
|
addedEntries.push(
|
|
9874
|
-
parentEntry
|
|
10091
|
+
addChild(parentEntry, file.name, {
|
|
9875
10092
|
Reader: function () {
|
|
9876
10093
|
const readable = file.stream();
|
|
9877
10094
|
const size = file.size;
|
|
@@ -9905,10 +10122,11 @@
|
|
|
9905
10122
|
|
|
9906
10123
|
async function exportFileSystemHandle(zipEntry, directoryHandle, options) {
|
|
9907
10124
|
const { onstart, onprogress, onend } = options;
|
|
10125
|
+
const readerOptions = checkReaderOptions(options.readerOptions);
|
|
9908
10126
|
const abortController = new AbortController();
|
|
9909
10127
|
const { signal } = abortController;
|
|
9910
10128
|
const releaseSignal = forwardAbort(options.signal, abortController);
|
|
9911
|
-
const getDataOptions = Object.assign({}, options,
|
|
10129
|
+
const getDataOptions = Object.assign({}, options, readerOptions, {
|
|
9912
10130
|
signal,
|
|
9913
10131
|
onstart: UNDEFINED_VALUE,
|
|
9914
10132
|
onprogress: UNDEFINED_VALUE,
|
|
@@ -10208,6 +10426,7 @@
|
|
|
10208
10426
|
exports.ERR_DUPLICATED_NAME = ERR_DUPLICATED_NAME;
|
|
10209
10427
|
exports.ERR_ENCRYPTED = ERR_ENCRYPTED;
|
|
10210
10428
|
exports.ERR_ENCRYPTED_CENTRAL_DIRECTORY = ERR_ENCRYPTED_CENTRAL_DIRECTORY;
|
|
10429
|
+
exports.ERR_ENTRY_DATA_OUT_OF_BOUNDS = ERR_ENTRY_DATA_OUT_OF_BOUNDS;
|
|
10211
10430
|
exports.ERR_ENTRY_EXISTS = ERR_ENTRY_EXISTS;
|
|
10212
10431
|
exports.ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND = ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND;
|
|
10213
10432
|
exports.ERR_EOCDR_NOT_FOUND = ERR_EOCDR_NOT_FOUND;
|
|
@@ -10221,20 +10440,28 @@
|
|
|
10221
10440
|
exports.ERR_INVALID_COMMENT_TYPE = ERR_INVALID_COMMENT_TYPE;
|
|
10222
10441
|
exports.ERR_INVALID_COMPRESSED_DATA = ERR_INVALID_COMPRESSED_DATA;
|
|
10223
10442
|
exports.ERR_INVALID_CRC32 = ERR_INVALID_CRC32;
|
|
10443
|
+
exports.ERR_INVALID_DATE = ERR_INVALID_DATE;
|
|
10224
10444
|
exports.ERR_INVALID_ENCRYPTION_STRENGTH = ERR_INVALID_ENCRYPTION_STRENGTH;
|
|
10225
10445
|
exports.ERR_INVALID_ENTRY_COMMENT = ERR_INVALID_ENTRY_COMMENT;
|
|
10446
|
+
exports.ERR_INVALID_ENTRY_COMMENT_TYPE = ERR_INVALID_ENTRY_COMMENT_TYPE;
|
|
10226
10447
|
exports.ERR_INVALID_ENTRY_NAME = ERR_INVALID_ENTRY_NAME;
|
|
10448
|
+
exports.ERR_INVALID_EXTRAFIELD = ERR_INVALID_EXTRAFIELD;
|
|
10227
10449
|
exports.ERR_INVALID_EXTRAFIELD_DATA = ERR_INVALID_EXTRAFIELD_DATA;
|
|
10450
|
+
exports.ERR_INVALID_EXTRAFIELD_DATA_TYPE = ERR_INVALID_EXTRAFIELD_DATA_TYPE;
|
|
10228
10451
|
exports.ERR_INVALID_EXTRAFIELD_TYPE = ERR_INVALID_EXTRAFIELD_TYPE;
|
|
10229
10452
|
exports.ERR_INVALID_FILENAME_VALIDATION = ERR_INVALID_FILENAME_VALIDATION;
|
|
10453
|
+
exports.ERR_INVALID_FUNCTION_OPTION = ERR_INVALID_FUNCTION_OPTION;
|
|
10230
10454
|
exports.ERR_INVALID_GID = ERR_INVALID_GID;
|
|
10231
10455
|
exports.ERR_INVALID_LEVEL = ERR_INVALID_LEVEL;
|
|
10232
10456
|
exports.ERR_INVALID_MAX_APPENDED_DATA_SIZE = ERR_INVALID_MAX_APPENDED_DATA_SIZE;
|
|
10457
|
+
exports.ERR_INVALID_MAX_WORKERS = ERR_INVALID_MAX_WORKERS;
|
|
10233
10458
|
exports.ERR_INVALID_MSDOS_ATTRIBUTES = ERR_INVALID_MSDOS_ATTRIBUTES;
|
|
10234
10459
|
exports.ERR_INVALID_MSDOS_DATA = ERR_INVALID_MSDOS_DATA;
|
|
10235
10460
|
exports.ERR_INVALID_PASSWORD = ERR_INVALID_PASSWORD;
|
|
10236
10461
|
exports.ERR_INVALID_PASSWORD_TYPE = ERR_INVALID_PASSWORD_TYPE;
|
|
10237
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;
|
|
10238
10465
|
exports.ERR_INVALID_SIGNATURE = ERR_INVALID_SIGNATURE;
|
|
10239
10466
|
exports.ERR_INVALID_SIGNATURE_DATA = ERR_INVALID_SIGNATURE_DATA;
|
|
10240
10467
|
exports.ERR_INVALID_STRICTNESS = ERR_INVALID_STRICTNESS;
|
|
@@ -10274,6 +10501,10 @@
|
|
|
10274
10501
|
exports.Uint8ArrayReader = Uint8ArrayReader;
|
|
10275
10502
|
exports.Uint8ArrayWriter = Uint8ArrayWriter;
|
|
10276
10503
|
exports.Writer = Writer;
|
|
10504
|
+
exports.ZipDirectoryEntry = ZipDirectoryEntry;
|
|
10505
|
+
exports.ZipEntry = ZipEntry;
|
|
10506
|
+
exports.ZipFS = ZipFS;
|
|
10507
|
+
exports.ZipFileEntry = ZipFileEntry;
|
|
10277
10508
|
exports.ZipReader = ZipReader;
|
|
10278
10509
|
exports.ZipReaderStream = ZipReaderStream;
|
|
10279
10510
|
exports.ZipWriter = ZipWriter;
|