@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.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
|
|
|
@@ -3566,7 +3803,7 @@
|
|
|
3566
3803
|
class TextWriter extends BlobWriter {
|
|
3567
3804
|
|
|
3568
3805
|
constructor(encoding) {
|
|
3569
|
-
super(
|
|
3806
|
+
super();
|
|
3570
3807
|
Object.assign(this, {
|
|
3571
3808
|
encoding,
|
|
3572
3809
|
utf8: !encoding || encoding.toLowerCase() == "utf-8"
|
|
@@ -3582,14 +3819,7 @@
|
|
|
3582
3819
|
if (blob.text && utf8) {
|
|
3583
3820
|
return blob.text();
|
|
3584
3821
|
} else {
|
|
3585
|
-
|
|
3586
|
-
return new Promise((resolve, reject) => {
|
|
3587
|
-
Object.assign(reader, {
|
|
3588
|
-
onload: ({ target }) => resolve(target.result),
|
|
3589
|
-
onerror: () => reject(reader.error)
|
|
3590
|
-
});
|
|
3591
|
-
reader.readAsText(blob, encoding);
|
|
3592
|
-
});
|
|
3822
|
+
return decodeTextRemovingBOM(new Uint8Array(await blob.arrayBuffer()), encoding);
|
|
3593
3823
|
}
|
|
3594
3824
|
}
|
|
3595
3825
|
}
|
|
@@ -4257,85 +4487,13 @@
|
|
|
4257
4487
|
return reader.readUint8Array(offset, size);
|
|
4258
4488
|
}
|
|
4259
4489
|
|
|
4260
|
-
|
|
4261
|
-
|
|
4262
|
-
|
|
4263
|
-
|
|
4264
|
-
|
|
4265
|
-
|
|
4266
|
-
1. Redistributions of source code must retain the above copyright notice,
|
|
4267
|
-
this list of conditions and the following disclaimer.
|
|
4268
|
-
|
|
4269
|
-
2. Redistributions in binary form must reproduce the above copyright
|
|
4270
|
-
notice, this list of conditions and the following disclaimer in
|
|
4271
|
-
the documentation and/or other materials provided with the distribution.
|
|
4272
|
-
|
|
4273
|
-
3. The names of the authors may not be used to endorse or promote products
|
|
4274
|
-
derived from this software without specific prior written permission.
|
|
4275
|
-
|
|
4276
|
-
THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
|
4277
|
-
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
4278
|
-
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
|
|
4279
|
-
INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
4280
|
-
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
4281
|
-
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
|
4282
|
-
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
4283
|
-
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
4284
|
-
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
|
4285
|
-
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
4286
|
-
*/
|
|
4287
|
-
|
|
4288
|
-
/* global TextDecoder */
|
|
4289
|
-
|
|
4290
|
-
const CP437 = "\0☺☻♥♦♣♠•◘○◙♂♀♪♫☼►◄↕‼¶§▬↨↑↓→←∟↔▲▼ !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~⌂ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥₧ƒáíóúñѪº¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ ".split("");
|
|
4291
|
-
const VALID_CP437 = CP437.length == 256;
|
|
4292
|
-
|
|
4293
|
-
function decodeCP437(stringValue) {
|
|
4294
|
-
if (VALID_CP437) {
|
|
4295
|
-
let result = "";
|
|
4296
|
-
for (let indexCharacter = 0; indexCharacter < stringValue.length; indexCharacter++) {
|
|
4297
|
-
result += CP437[stringValue[indexCharacter]];
|
|
4298
|
-
}
|
|
4299
|
-
return result;
|
|
4300
|
-
} else {
|
|
4301
|
-
return new TextDecoder().decode(stringValue);
|
|
4302
|
-
}
|
|
4303
|
-
}
|
|
4304
|
-
|
|
4305
|
-
/*
|
|
4306
|
-
Copyright (c) 2022 Gildas Lormeau. All rights reserved.
|
|
4307
|
-
|
|
4308
|
-
Redistribution and use in source and binary forms, with or without
|
|
4309
|
-
modification, are permitted provided that the following conditions are met:
|
|
4310
|
-
|
|
4311
|
-
1. Redistributions of source code must retain the above copyright notice,
|
|
4312
|
-
this list of conditions and the following disclaimer.
|
|
4313
|
-
|
|
4314
|
-
2. Redistributions in binary form must reproduce the above copyright
|
|
4315
|
-
notice, this list of conditions and the following disclaimer in
|
|
4316
|
-
the documentation and/or other materials provided with the distribution.
|
|
4317
|
-
|
|
4318
|
-
3. The names of the authors may not be used to endorse or promote products
|
|
4319
|
-
derived from this software without specific prior written permission.
|
|
4320
|
-
|
|
4321
|
-
THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
|
4322
|
-
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
4323
|
-
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
|
|
4324
|
-
INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
4325
|
-
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
4326
|
-
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
|
4327
|
-
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
4328
|
-
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
4329
|
-
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
|
4330
|
-
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
4331
|
-
*/
|
|
4332
|
-
|
|
4333
|
-
|
|
4334
|
-
function decodeText(value, encoding) {
|
|
4335
|
-
if (encoding && encoding.trim().toLowerCase() == "cp437") {
|
|
4336
|
-
return decodeCP437(value);
|
|
4490
|
+
function createReadable(reader, options) {
|
|
4491
|
+
if (reader.createReadable) {
|
|
4492
|
+
return reader.createReadable(options);
|
|
4493
|
+
} else if (reader.readUint8Array) {
|
|
4494
|
+
return Reader.prototype.createReadable.call(reader, options);
|
|
4337
4495
|
} else {
|
|
4338
|
-
return
|
|
4496
|
+
return reader.readable;
|
|
4339
4497
|
}
|
|
4340
4498
|
}
|
|
4341
4499
|
|
|
@@ -4495,83 +4653,6 @@
|
|
|
4495
4653
|
|
|
4496
4654
|
}
|
|
4497
4655
|
|
|
4498
|
-
/*
|
|
4499
|
-
Copyright (c) 2022 Gildas Lormeau. All rights reserved.
|
|
4500
|
-
|
|
4501
|
-
Redistribution and use in source and binary forms, with or without
|
|
4502
|
-
modification, are permitted provided that the following conditions are met:
|
|
4503
|
-
|
|
4504
|
-
1. Redistributions of source code must retain the above copyright notice,
|
|
4505
|
-
this list of conditions and the following disclaimer.
|
|
4506
|
-
|
|
4507
|
-
2. Redistributions in binary form must reproduce the above copyright
|
|
4508
|
-
notice, this list of conditions and the following disclaimer in
|
|
4509
|
-
the documentation and/or other materials provided with the distribution.
|
|
4510
|
-
|
|
4511
|
-
3. The names of the authors may not be used to endorse or promote products
|
|
4512
|
-
derived from this software without specific prior written permission.
|
|
4513
|
-
|
|
4514
|
-
THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
|
4515
|
-
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
4516
|
-
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
|
|
4517
|
-
INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
4518
|
-
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
4519
|
-
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
|
4520
|
-
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
4521
|
-
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
4522
|
-
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
|
4523
|
-
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
4524
|
-
*/
|
|
4525
|
-
|
|
4526
|
-
const OPTION_FILENAME_ENCODING = "filenameEncoding";
|
|
4527
|
-
const OPTION_COMMENT_ENCODING = "commentEncoding";
|
|
4528
|
-
const OPTION_DECODE_TEXT = "decodeText";
|
|
4529
|
-
const OPTION_EXTRACT_PREPENDED_DATA = "extractPrependedData";
|
|
4530
|
-
const OPTION_EXTRACT_APPENDED_DATA = "extractAppendedData";
|
|
4531
|
-
const OPTION_PASSWORD = "password";
|
|
4532
|
-
const OPTION_RAW_PASSWORD = "rawPassword";
|
|
4533
|
-
const OPTION_PASS_THROUGH = "passThrough";
|
|
4534
|
-
const OPTION_SIGNAL = "signal";
|
|
4535
|
-
const OPTION_CHECK_PASSWORD_ONLY = "checkPasswordOnly";
|
|
4536
|
-
const OPTION_CHECK_OVERLAPPING_ENTRY_ONLY = "checkOverlappingEntryOnly";
|
|
4537
|
-
const OPTION_CHECK_OVERLAPPING_ENTRY = "checkOverlappingEntry";
|
|
4538
|
-
const OPTION_CHECK_AMBIGUITY = "checkAmbiguity";
|
|
4539
|
-
const OPTION_CHECK_LOCAL_DIRECTORY = "checkLocalDirectory";
|
|
4540
|
-
const OPTION_CHECK_SIGNATURE = "checkSignature";
|
|
4541
|
-
const OPTION_CHECK_CRC32 = "checkCrc32";
|
|
4542
|
-
const OPTION_CHECK_AUTHENTICATION_CODE = "checkAuthenticationCode";
|
|
4543
|
-
const OPTION_USE_WEB_WORKERS = "useWebWorkers";
|
|
4544
|
-
const OPTION_USE_COMPRESSION_STREAM = "useCompressionStream";
|
|
4545
|
-
const OPTION_TRANSFER_STREAMS = "transferStreams";
|
|
4546
|
-
const OPTION_PREVENT_CLOSE = "preventClose";
|
|
4547
|
-
const OPTION_ENCRYPTION_STRENGTH = "encryptionStrength";
|
|
4548
|
-
const OPTION_EXTENDED_TIMESTAMP = "extendedTimestamp";
|
|
4549
|
-
const OPTION_NTFS_TIMESTAMP = "ntfsTimestamp";
|
|
4550
|
-
const OPTION_KEEP_ORDER = "keepOrder";
|
|
4551
|
-
const OPTION_LEVEL = "level";
|
|
4552
|
-
const OPTION_BUFFERED_WRITE = "bufferedWrite";
|
|
4553
|
-
const OPTION_CREATE_TEMP_STREAM = "createTempStream";
|
|
4554
|
-
const OPTION_DATA_DESCRIPTOR_SIGNATURE = "dataDescriptorSignature";
|
|
4555
|
-
const OPTION_USE_UNICODE_FILE_NAMES = "useUnicodeFileNames";
|
|
4556
|
-
const OPTION_DATA_DESCRIPTOR = "dataDescriptor";
|
|
4557
|
-
const OPTION_SUPPORT_ZIP64_SPLIT_FILE = "supportZip64SplitFile";
|
|
4558
|
-
const OPTION_ENCODE_TEXT = "encodeText";
|
|
4559
|
-
const OPTION_OFFSET = "offset";
|
|
4560
|
-
const OPTION_USDZ = "usdz";
|
|
4561
|
-
const OPTION_UNIX_EXTRA_FIELD_TYPE = "unixExtraFieldType";
|
|
4562
|
-
const OPTION_LOCAL_EXTRA_FIELD = "localExtraField";
|
|
4563
|
-
const OPTION_STRICTNESS = "strictness";
|
|
4564
|
-
const OPTION_FILENAME_VALIDATION = "filenameValidation";
|
|
4565
|
-
const OPTION_NORMALIZE_FILENAME = "normalizeFilename";
|
|
4566
|
-
const OPTION_MAX_APPENDED_DATA_SIZE = "maxAppendedDataSize";
|
|
4567
|
-
const OPTION_DECRYPT_CENTRAL_DIRECTORY = "decryptCentralDirectory";
|
|
4568
|
-
const OPTION_SIGN_CENTRAL_DIRECTORY = "signCentralDirectory";
|
|
4569
|
-
const TEXT_TYPE_FILENAME = "filename";
|
|
4570
|
-
const TEXT_TYPE_COMMENT = "comment";
|
|
4571
|
-
const STRICTNESS_STRICT = "strict";
|
|
4572
|
-
const STRICTNESS_BALANCED = "balanced";
|
|
4573
|
-
const STRICTNESS_TOLERANT = "tolerant";
|
|
4574
|
-
|
|
4575
4656
|
/*
|
|
4576
4657
|
Copyright (c) 2025 Gildas Lormeau. All rights reserved.
|
|
4577
4658
|
|
|
@@ -4612,6 +4693,7 @@
|
|
|
4612
4693
|
const ERR_UNSUPPORTED_COMPRESSION$1 = "Compression method not supported";
|
|
4613
4694
|
const ERR_SPLIT_ZIP_FILE = "Split zip file";
|
|
4614
4695
|
const ERR_OVERLAPPING_ENTRY = "Overlapping entry found";
|
|
4696
|
+
const ERR_ENTRY_DATA_OUT_OF_BOUNDS = "Entry data out of bounds";
|
|
4615
4697
|
const ERR_AMBIGUOUS_ARCHIVE = "Ambiguous archive";
|
|
4616
4698
|
const ERR_ENCRYPTED_CENTRAL_DIRECTORY = "Encrypted central directory is not supported";
|
|
4617
4699
|
const ERR_UNSAFE_FILENAME = "Unsafe filename";
|
|
@@ -4632,7 +4714,7 @@
|
|
|
4632
4714
|
];
|
|
4633
4715
|
const ZIP64_EXTRACTION = {
|
|
4634
4716
|
[MAX_16_BITS]: {
|
|
4635
|
-
getValue: getUint32,
|
|
4717
|
+
getValue: getUint32$1,
|
|
4636
4718
|
bytes: 4
|
|
4637
4719
|
},
|
|
4638
4720
|
[MAX_32_BITS]: {
|
|
@@ -4641,6 +4723,7 @@
|
|
|
4641
4723
|
}
|
|
4642
4724
|
};
|
|
4643
4725
|
const MAX_END_OF_CENTRAL_DIR_PROBES = 64;
|
|
4726
|
+
const MAX_DEFLATE_EXPANSION_RATIO = 1032;
|
|
4644
4727
|
const CENTRAL_DIRECTORY_UNREACHABLE = 0;
|
|
4645
4728
|
const CENTRAL_DIRECTORY_PLAUSIBLE = 1;
|
|
4646
4729
|
const CENTRAL_DIRECTORY_REACHABLE = 2;
|
|
@@ -4651,7 +4734,6 @@
|
|
|
4651
4734
|
Object.assign(this, {
|
|
4652
4735
|
reader: new GenericReader(reader),
|
|
4653
4736
|
options,
|
|
4654
|
-
config: getConfiguration(),
|
|
4655
4737
|
readRanges: new Map()
|
|
4656
4738
|
});
|
|
4657
4739
|
}
|
|
@@ -4659,7 +4741,6 @@
|
|
|
4659
4741
|
async* getEntriesGenerator(options = {}) {
|
|
4660
4742
|
const zipReader = this;
|
|
4661
4743
|
let { reader } = zipReader;
|
|
4662
|
-
const { config } = zipReader;
|
|
4663
4744
|
await initStream(reader);
|
|
4664
4745
|
if (reader.size === UNDEFINED_VALUE || !reader.readUint8Array) {
|
|
4665
4746
|
reader = new BlobReader(await streamToBlob(reader.readable));
|
|
@@ -4676,9 +4757,7 @@
|
|
|
4676
4757
|
const normalizeFilename = getOptionValue$1(zipReader, options, OPTION_NORMALIZE_FILENAME);
|
|
4677
4758
|
const { endOfDirectoryInfo, endOfDirectoryReachingEndCount } = await findEndOfCentralDirectory(reader, rejectAmbiguousEndOfDirectory, maxAppendedDataSize);
|
|
4678
4759
|
if (!endOfDirectoryInfo) {
|
|
4679
|
-
|
|
4680
|
-
const signatureView = getDataView(signatureArray);
|
|
4681
|
-
if (getUint32(signatureView) == SPLIT_ZIP_FILE_SIGNATURE) {
|
|
4760
|
+
if (await startsWithSplitZipSignature$1(reader)) {
|
|
4682
4761
|
throw new Error(ERR_SPLIT_ZIP_FILE);
|
|
4683
4762
|
} else {
|
|
4684
4763
|
throw new Error(ERR_EOCDR_NOT_FOUND);
|
|
@@ -4688,18 +4767,18 @@
|
|
|
4688
4767
|
throwAmbiguousArchive("multiple end of central directory records");
|
|
4689
4768
|
}
|
|
4690
4769
|
const endOfDirectoryView = getDataView(endOfDirectoryInfo);
|
|
4691
|
-
let directoryDataLength = getUint32(endOfDirectoryView, 12);
|
|
4692
|
-
let directoryDataOffset = getUint32(endOfDirectoryView, 16);
|
|
4770
|
+
let directoryDataLength = getUint32$1(endOfDirectoryView, 12);
|
|
4771
|
+
let directoryDataOffset = getUint32$1(endOfDirectoryView, 16);
|
|
4693
4772
|
const commentOffset = endOfDirectoryInfo.offset;
|
|
4694
|
-
const commentLength = getUint16(endOfDirectoryView, 20);
|
|
4773
|
+
const commentLength = getUint16$1(endOfDirectoryView, 20);
|
|
4695
4774
|
const appendedDataOffset = commentOffset + END_OF_CENTRAL_DIR_LENGTH + commentLength;
|
|
4696
4775
|
if (reader.size - appendedDataOffset > maxAppendedDataSize) {
|
|
4697
4776
|
throwAmbiguousArchive("appended data");
|
|
4698
4777
|
}
|
|
4699
|
-
let lastDiskNumber = getUint16(endOfDirectoryView, 4);
|
|
4778
|
+
let lastDiskNumber = getUint16$1(endOfDirectoryView, 4);
|
|
4700
4779
|
const expectedLastDiskNumber = reader.lastDiskNumber || 0;
|
|
4701
|
-
let diskNumber = getUint16(endOfDirectoryView, 6);
|
|
4702
|
-
let filesLength = getUint16(endOfDirectoryView, 10);
|
|
4780
|
+
let diskNumber = getUint16$1(endOfDirectoryView, 6);
|
|
4781
|
+
let filesLength = getUint16$1(endOfDirectoryView, 10);
|
|
4703
4782
|
let prependedDataLength = 0;
|
|
4704
4783
|
let startOffset;
|
|
4705
4784
|
let zip64EndOfDirectory;
|
|
@@ -4715,12 +4794,12 @@
|
|
|
4715
4794
|
EMPTY_UINT8_ARRAY;
|
|
4716
4795
|
const endOfDirectoryLocatorView = getDataView(endOfDirectoryLocatorArray);
|
|
4717
4796
|
if (endOfDirectoryLocatorArray.length == ZIP64_END_OF_CENTRAL_DIR_LOCATOR_LENGTH &&
|
|
4718
|
-
getUint32(endOfDirectoryLocatorView, 0) == ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIGNATURE) {
|
|
4719
|
-
directoryDataOffset = getDiskOffset$1(reader, getUint32(endOfDirectoryLocatorView, 4)) + getBigUint64(endOfDirectoryLocatorView, 8);
|
|
4797
|
+
getUint32$1(endOfDirectoryLocatorView, 0) == ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIGNATURE) {
|
|
4798
|
+
directoryDataOffset = getDiskOffset$1(reader, getUint32$1(endOfDirectoryLocatorView, 4)) + getBigUint64(endOfDirectoryLocatorView, 8);
|
|
4720
4799
|
let endOfDirectoryArray = await readUint8Array(reader, directoryDataOffset, ZIP64_END_OF_CENTRAL_DIR_LENGTH);
|
|
4721
4800
|
let endOfDirectoryView = getDataView(endOfDirectoryArray);
|
|
4722
4801
|
const expectedDirectoryDataOffset = endOfDirectoryInfo.offset - ZIP64_END_OF_CENTRAL_DIR_LOCATOR_LENGTH - ZIP64_END_OF_CENTRAL_DIR_LENGTH;
|
|
4723
|
-
if ((endOfDirectoryArray.length < ZIP64_END_OF_CENTRAL_DIR_LENGTH || getUint32(endOfDirectoryView, 0) != ZIP64_END_OF_CENTRAL_DIR_SIGNATURE) &&
|
|
4802
|
+
if ((endOfDirectoryArray.length < ZIP64_END_OF_CENTRAL_DIR_LENGTH || getUint32$1(endOfDirectoryView, 0) != ZIP64_END_OF_CENTRAL_DIR_SIGNATURE) &&
|
|
4724
4803
|
directoryDataOffset != expectedDirectoryDataOffset && expectedDirectoryDataOffset >= 0) {
|
|
4725
4804
|
const originalDirectoryDataOffset = directoryDataOffset;
|
|
4726
4805
|
directoryDataOffset = expectedDirectoryDataOffset;
|
|
@@ -4730,7 +4809,7 @@
|
|
|
4730
4809
|
endOfDirectoryArray = await readUint8Array(reader, directoryDataOffset, ZIP64_END_OF_CENTRAL_DIR_LENGTH);
|
|
4731
4810
|
endOfDirectoryView = getDataView(endOfDirectoryArray);
|
|
4732
4811
|
}
|
|
4733
|
-
if (endOfDirectoryArray.length < ZIP64_END_OF_CENTRAL_DIR_LENGTH || getUint32(endOfDirectoryView, 0) != ZIP64_END_OF_CENTRAL_DIR_SIGNATURE) {
|
|
4812
|
+
if (endOfDirectoryArray.length < ZIP64_END_OF_CENTRAL_DIR_LENGTH || getUint32$1(endOfDirectoryView, 0) != ZIP64_END_OF_CENTRAL_DIR_SIGNATURE) {
|
|
4734
4813
|
throw new Error(ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND);
|
|
4735
4814
|
}
|
|
4736
4815
|
zip64EndOfDirectory = true;
|
|
@@ -4745,13 +4824,13 @@
|
|
|
4745
4824
|
}
|
|
4746
4825
|
}
|
|
4747
4826
|
if (lastDiskNumber == MAX_16_BITS) {
|
|
4748
|
-
lastDiskNumber = getUint32(endOfDirectoryView, 16);
|
|
4749
|
-
} else if (checkAmbiguity && lastDiskNumber != getUint32(endOfDirectoryView, 16)) {
|
|
4827
|
+
lastDiskNumber = getUint32$1(endOfDirectoryView, 16);
|
|
4828
|
+
} else if (checkAmbiguity && lastDiskNumber != getUint32$1(endOfDirectoryView, 16)) {
|
|
4750
4829
|
throwAmbiguousArchive("mismatched zip64 end of central directory record");
|
|
4751
4830
|
}
|
|
4752
4831
|
if (diskNumber == MAX_16_BITS) {
|
|
4753
|
-
diskNumber = getUint32(endOfDirectoryView, 20);
|
|
4754
|
-
} else if (checkAmbiguity && diskNumber != getUint32(endOfDirectoryView, 20)) {
|
|
4832
|
+
diskNumber = getUint32$1(endOfDirectoryView, 20);
|
|
4833
|
+
} else if (checkAmbiguity && diskNumber != getUint32$1(endOfDirectoryView, 20)) {
|
|
4755
4834
|
throwAmbiguousArchive("mismatched zip64 end of central directory record");
|
|
4756
4835
|
}
|
|
4757
4836
|
if (filesLength == MAX_16_BITS) {
|
|
@@ -4789,11 +4868,11 @@
|
|
|
4789
4868
|
}
|
|
4790
4869
|
const expectedDirectoryDataOffset = centralDirectoryEndOffset - directoryDataLength;
|
|
4791
4870
|
if (directoryDataOffset != expectedDirectoryDataOffset && diskNumber == lastDiskNumber) {
|
|
4792
|
-
const storedPointsAtDirectory = getUint32(directoryView, offset) == CENTRAL_FILE_HEADER_SIGNATURE;
|
|
4871
|
+
const storedPointsAtDirectory = getUint32$1(directoryView, offset) == CENTRAL_FILE_HEADER_SIGNATURE;
|
|
4793
4872
|
let reconcile = !storedPointsAtDirectory;
|
|
4794
4873
|
if (!reconcile && expectedDirectoryDataOffset >= 0 && expectedDirectoryDataOffset + 4 <= reader.size) {
|
|
4795
4874
|
const expectedSignatureArray = await readUint8Array(reader, expectedDirectoryDataOffset, 4);
|
|
4796
|
-
reconcile = getUint32(getDataView(expectedSignatureArray), 0) == CENTRAL_FILE_HEADER_SIGNATURE;
|
|
4875
|
+
reconcile = getUint32$1(getDataView(expectedSignatureArray), 0) == CENTRAL_FILE_HEADER_SIGNATURE;
|
|
4797
4876
|
}
|
|
4798
4877
|
if (reconcile) {
|
|
4799
4878
|
const originalDirectoryDataOffset = directoryDataOffset;
|
|
@@ -4817,10 +4896,10 @@
|
|
|
4817
4896
|
}
|
|
4818
4897
|
zipReader.directoryOffset = directoryDataOffset;
|
|
4819
4898
|
zipReader.directoryLength = declaredDirectoryDataLength;
|
|
4820
|
-
const decryptCentralDirectory =
|
|
4899
|
+
const decryptCentralDirectory = getFunctionOptionValue$1(zipReader, options, OPTION_DECRYPT_CENTRAL_DIRECTORY);
|
|
4821
4900
|
let decryptedDirectory;
|
|
4822
4901
|
if (decryptCentralDirectory && filesLength && directoryArray.length >= 4 &&
|
|
4823
|
-
getUint32(directoryView, 0) != CENTRAL_FILE_HEADER_SIGNATURE &&
|
|
4902
|
+
getUint32$1(directoryView, 0) != CENTRAL_FILE_HEADER_SIGNATURE &&
|
|
4824
4903
|
(zip64EndOfDirectoryVersion2 || detectEncryptedCentralDirectory(directoryView))) {
|
|
4825
4904
|
directoryArray = await decryptCentralDirectory(directoryArray, directoryEncryptionInfo);
|
|
4826
4905
|
directoryView = getDataView(directoryArray);
|
|
@@ -4833,8 +4912,8 @@
|
|
|
4833
4912
|
const filenames = checkAmbiguity ? new Set() : UNDEFINED_VALUE;
|
|
4834
4913
|
let duplicateFilename;
|
|
4835
4914
|
for (let indexFile = 0; indexFile < filesLength; indexFile++) {
|
|
4836
|
-
const fileEntry = new ZipEntry(reader,
|
|
4837
|
-
if (offset + CENTRAL_FILE_HEADER_LENGTH > directoryArray.length || getUint32(directoryView, offset) != CENTRAL_FILE_HEADER_SIGNATURE) {
|
|
4915
|
+
const fileEntry = new ZipEntry(reader, zipReader.options);
|
|
4916
|
+
if (offset + CENTRAL_FILE_HEADER_LENGTH > directoryArray.length || getUint32$1(directoryView, offset) != CENTRAL_FILE_HEADER_SIGNATURE) {
|
|
4838
4917
|
if (indexFile == 0 && !decryptedDirectory && (zip64EndOfDirectoryVersion2 || detectEncryptedCentralDirectory(directoryView))) {
|
|
4839
4918
|
throw new Error(ERR_ENCRYPTED_CENTRAL_DIRECTORY);
|
|
4840
4919
|
}
|
|
@@ -4845,16 +4924,16 @@
|
|
|
4845
4924
|
const filenameOffset = offset + CENTRAL_FILE_HEADER_LENGTH;
|
|
4846
4925
|
const extraFieldOffset = filenameOffset + fileEntry.filenameLength;
|
|
4847
4926
|
const commentOffset = extraFieldOffset + fileEntry.extraFieldLength;
|
|
4848
|
-
const versionMadeBy = getUint16(directoryView, offset + 4);
|
|
4927
|
+
const versionMadeBy = getUint16$1(directoryView, offset + 4);
|
|
4849
4928
|
const msDosCompatible = versionMadeBy >> 8 == 0;
|
|
4850
4929
|
const unixCompatible = versionMadeBy >> 8 == 3;
|
|
4851
4930
|
const rawFilename = directoryArray.subarray(filenameOffset, extraFieldOffset);
|
|
4852
|
-
const commentLength = getUint16(directoryView, offset + 32);
|
|
4931
|
+
const commentLength = getUint16$1(directoryView, offset + 32);
|
|
4853
4932
|
const endOffset = commentOffset + commentLength;
|
|
4854
4933
|
const rawComment = directoryArray.subarray(commentOffset, endOffset);
|
|
4855
4934
|
const filenameUTF8 = languageEncodingFlag;
|
|
4856
4935
|
const commentUTF8 = languageEncodingFlag;
|
|
4857
|
-
const externalFileAttributes = getUint32(directoryView, offset + 38);
|
|
4936
|
+
const externalFileAttributes = getUint32$1(directoryView, offset + 38);
|
|
4858
4937
|
const msdosAttributesRaw = externalFileAttributes & MAX_8_BITS;
|
|
4859
4938
|
const msdosAttributes = {
|
|
4860
4939
|
readOnly: Boolean(msdosAttributesRaw & FILE_ATTR_MSDOS_READONLY_MASK),
|
|
@@ -4863,8 +4942,8 @@
|
|
|
4863
4942
|
directory: Boolean(msdosAttributesRaw & FILE_ATTR_MSDOS_DIR_MASK),
|
|
4864
4943
|
archive: Boolean(msdosAttributesRaw & FILE_ATTR_MSDOS_ARCHIVE_MASK)
|
|
4865
4944
|
};
|
|
4866
|
-
const offsetFileEntry = getUint32(directoryView, offset + 42);
|
|
4867
|
-
const decode =
|
|
4945
|
+
const offsetFileEntry = getUint32$1(directoryView, offset + 42);
|
|
4946
|
+
const decode = getFunctionOptionValue$1(zipReader, options, OPTION_DECODE_TEXT) || decodeText;
|
|
4868
4947
|
const rawFilenameEncoding = filenameUTF8 ? CHARSET_UTF8 : filenameEncoding || CHARSET_CP437;
|
|
4869
4948
|
const rawCommentEncoding = commentUTF8 ? CHARSET_UTF8 : commentEncoding || CHARSET_CP437;
|
|
4870
4949
|
let filename = decode(rawFilename, rawFilenameEncoding, TEXT_TYPE_FILENAME);
|
|
@@ -4895,8 +4974,8 @@
|
|
|
4895
4974
|
uncompressedSize: 0,
|
|
4896
4975
|
commentLength,
|
|
4897
4976
|
offset: offsetFileEntry,
|
|
4898
|
-
diskNumberStart: getUint16(directoryView, offset + 34),
|
|
4899
|
-
internalFileAttributes: getUint16(directoryView, offset + 36),
|
|
4977
|
+
diskNumberStart: getUint16$1(directoryView, offset + 34),
|
|
4978
|
+
internalFileAttributes: getUint16$1(directoryView, offset + 36),
|
|
4900
4979
|
externalFileAttributes,
|
|
4901
4980
|
msdosAttributesRaw,
|
|
4902
4981
|
msdosAttributes,
|
|
@@ -4964,8 +5043,8 @@
|
|
|
4964
5043
|
yield entry;
|
|
4965
5044
|
}
|
|
4966
5045
|
let offsetAfterSignature = offset;
|
|
4967
|
-
if (offset + 6 <= directoryArray.length && getUint32(directoryView, offset) == DIGITAL_SIGNATURE_RECORD_SIGNATURE) {
|
|
4968
|
-
const signatureDataLength = getUint16(directoryView, offset + 4);
|
|
5046
|
+
if (offset + 6 <= directoryArray.length && getUint32$1(directoryView, offset) == DIGITAL_SIGNATURE_RECORD_SIGNATURE) {
|
|
5047
|
+
const signatureDataLength = getUint16$1(directoryView, offset + 4);
|
|
4969
5048
|
if (offset + 6 + signatureDataLength <= directoryArray.length) {
|
|
4970
5049
|
zipReader.digitalSignature = directoryArray.subarray(offset + 6, offset + 6 + signatureDataLength);
|
|
4971
5050
|
offsetAfterSignature = offset + 6 + signatureDataLength;
|
|
@@ -4977,13 +5056,17 @@
|
|
|
4977
5056
|
if (duplicateFilename) {
|
|
4978
5057
|
throwAmbiguousArchive("duplicate filename");
|
|
4979
5058
|
}
|
|
4980
|
-
if (checkAmbiguity && (prependedDataLength || (filesLength && startOffset > 0))) {
|
|
4981
|
-
throwAmbiguousArchive("prepended data");
|
|
4982
|
-
}
|
|
4983
5059
|
const extractPrependedData = getOptionValue$1(zipReader, options, OPTION_EXTRACT_PREPENDED_DATA);
|
|
4984
5060
|
const extractAppendedData = getOptionValue$1(zipReader, options, OPTION_EXTRACT_APPENDED_DATA);
|
|
5061
|
+
const splitZipSignatureLength = (checkAmbiguity || extractPrependedData) && filesLength &&
|
|
5062
|
+
startOffset == SPLIT_ZIP_FILE_SIGNATURE_LENGTH && await startsWithSplitZipMarker(reader) ? SPLIT_ZIP_FILE_SIGNATURE_LENGTH : 0;
|
|
5063
|
+
if (checkAmbiguity && (prependedDataLength || (filesLength && startOffset > splitZipSignatureLength))) {
|
|
5064
|
+
throwAmbiguousArchive("prepended data");
|
|
5065
|
+
}
|
|
4985
5066
|
if (extractPrependedData) {
|
|
4986
|
-
zipReader.prependedData = startOffset >
|
|
5067
|
+
zipReader.prependedData = startOffset > splitZipSignatureLength ?
|
|
5068
|
+
await readUint8Array(reader, splitZipSignatureLength, startOffset - splitZipSignatureLength) :
|
|
5069
|
+
EMPTY_UINT8_ARRAY;
|
|
4987
5070
|
}
|
|
4988
5071
|
zipReader.comment = commentLength ? await readUint8Array(reader, commentOffset + END_OF_CENTRAL_DIR_LENGTH, commentLength) : EMPTY_UINT8_ARRAY;
|
|
4989
5072
|
if (extractAppendedData) {
|
|
@@ -5050,16 +5133,16 @@
|
|
|
5050
5133
|
|
|
5051
5134
|
class ZipEntry {
|
|
5052
5135
|
|
|
5053
|
-
constructor(reader,
|
|
5136
|
+
constructor(reader, options) {
|
|
5054
5137
|
Object.assign(this, {
|
|
5055
5138
|
reader,
|
|
5056
|
-
config,
|
|
5057
5139
|
options
|
|
5058
5140
|
});
|
|
5059
5141
|
}
|
|
5060
5142
|
|
|
5061
5143
|
async getData(writer, fileEntry, readRanges, options = {}) {
|
|
5062
5144
|
const zipEntry = this;
|
|
5145
|
+
const config = getConfiguration();
|
|
5063
5146
|
const {
|
|
5064
5147
|
reader,
|
|
5065
5148
|
index,
|
|
@@ -5068,7 +5151,6 @@
|
|
|
5068
5151
|
extraFieldAES,
|
|
5069
5152
|
extraFieldZip64,
|
|
5070
5153
|
compressionMethod,
|
|
5071
|
-
config,
|
|
5072
5154
|
bitFlag,
|
|
5073
5155
|
rawBitFlag,
|
|
5074
5156
|
crc32,
|
|
@@ -5086,6 +5168,7 @@
|
|
|
5086
5168
|
let password = getOptionValue$1(zipEntry, options, OPTION_PASSWORD);
|
|
5087
5169
|
let rawPassword = getOptionValue$1(zipEntry, options, OPTION_RAW_PASSWORD);
|
|
5088
5170
|
const passThrough = getOptionValue$1(zipEntry, options, OPTION_PASS_THROUGH);
|
|
5171
|
+
checkPasswordOption(password, rawPassword);
|
|
5089
5172
|
password = password && password.length && password;
|
|
5090
5173
|
rawPassword = rawPassword && rawPassword.length && rawPassword;
|
|
5091
5174
|
if (extraFieldAES) {
|
|
@@ -5093,7 +5176,7 @@
|
|
|
5093
5176
|
throw new Error(ERR_UNSUPPORTED_COMPRESSION$1);
|
|
5094
5177
|
}
|
|
5095
5178
|
}
|
|
5096
|
-
if (dataArray.length < HEADER_SIZE || getUint32(dataView, 0) != LOCAL_FILE_HEADER_SIGNATURE) {
|
|
5179
|
+
if (dataArray.length < HEADER_SIZE || getUint32$1(dataView, 0) != LOCAL_FILE_HEADER_SIGNATURE) {
|
|
5097
5180
|
throw new Error(ERR_LOCAL_FILE_HEADER_NOT_FOUND);
|
|
5098
5181
|
}
|
|
5099
5182
|
readCommonHeader(localDirectory, dataView, 4);
|
|
@@ -5155,9 +5238,12 @@
|
|
|
5155
5238
|
}
|
|
5156
5239
|
}
|
|
5157
5240
|
const dataOffset = localHeaderOffset + HEADER_SIZE + filenameLength + extraFieldLength;
|
|
5241
|
+
if (dataOffset + compressedSize > reader.size) {
|
|
5242
|
+
throw new Error(ERR_ENTRY_DATA_OUT_OF_BOUNDS);
|
|
5243
|
+
}
|
|
5158
5244
|
const size = compressedSize;
|
|
5159
5245
|
const readable = toCompatibleReadable(reader.createReadable({ offset: dataOffset, size }));
|
|
5160
|
-
const signal = getOptionValue$1(zipEntry, options, OPTION_SIGNAL);
|
|
5246
|
+
const signal = checkSignalOption(getOptionValue$1(zipEntry, options, OPTION_SIGNAL));
|
|
5161
5247
|
const checkPasswordOnly = getOptionValue$1(zipEntry, options, OPTION_CHECK_PASSWORD_ONLY);
|
|
5162
5248
|
let checkOverlappingEntry = getOptionValue$1(zipEntry, options, OPTION_CHECK_OVERLAPPING_ENTRY);
|
|
5163
5249
|
const checkOverlappingEntryOnly = getOptionValue$1(zipEntry, options, OPTION_CHECK_OVERLAPPING_ENTRY_ONLY);
|
|
@@ -5165,6 +5251,8 @@
|
|
|
5165
5251
|
checkOverlappingEntry = true;
|
|
5166
5252
|
}
|
|
5167
5253
|
const { onstart, onprogress, onend } = options;
|
|
5254
|
+
const compressed = compressionMethod != COMPRESSION_METHOD_STORE && !passThrough;
|
|
5255
|
+
const outputSize = passThrough ? compressedSize : uncompressedSize;
|
|
5168
5256
|
const deflate64 = compressionMethod == COMPRESSION_METHOD_DEFLATE_64;
|
|
5169
5257
|
let useCompressionStream = getOptionValue$1(zipEntry, options, OPTION_USE_COMPRESSION_STREAM);
|
|
5170
5258
|
if (deflate64) {
|
|
@@ -5185,9 +5273,9 @@
|
|
|
5185
5273
|
checkCrc32,
|
|
5186
5274
|
checkAuthenticationCode: getOptionValue$1(zipEntry, options, OPTION_CHECK_AUTHENTICATION_CODE),
|
|
5187
5275
|
passwordVerification: zipCrypto && (dataDescriptor ? ((rawLastModDate >>> 8) & MAX_8_BITS) : ((crc32 >>> 24) & MAX_8_BITS)),
|
|
5188
|
-
outputSize
|
|
5276
|
+
outputSize,
|
|
5189
5277
|
crc32,
|
|
5190
|
-
compressed
|
|
5278
|
+
compressed,
|
|
5191
5279
|
encrypted,
|
|
5192
5280
|
useWebWorkers: getOptionValue$1(zipEntry, options, OPTION_USE_WEB_WORKERS),
|
|
5193
5281
|
useCompressionStream,
|
|
@@ -5224,11 +5312,11 @@
|
|
|
5224
5312
|
writer = new WritableStream();
|
|
5225
5313
|
}
|
|
5226
5314
|
writer = new GenericWriter(writer);
|
|
5227
|
-
await initStream(writer,
|
|
5315
|
+
await initStream(writer, getDecodableOutputSize(outputSize, compressedSize, compressed));
|
|
5228
5316
|
({ writable } = writer);
|
|
5229
|
-
const { outputSize } = await runWorker({ readable, writable }, workerOptions);
|
|
5230
|
-
writer.size +=
|
|
5231
|
-
if (
|
|
5317
|
+
const { outputSize: writtenSize } = await runWorker({ readable, writable }, workerOptions);
|
|
5318
|
+
writer.size += writtenSize;
|
|
5319
|
+
if (writtenSize != outputSize) {
|
|
5232
5320
|
throw new Error(ERR_INVALID_UNCOMPRESSED_SIZE);
|
|
5233
5321
|
}
|
|
5234
5322
|
}
|
|
@@ -5262,7 +5350,7 @@
|
|
|
5262
5350
|
function detectEncryptedCentralDirectory(directoryView) {
|
|
5263
5351
|
const maxOffset = Math.min(directoryView.byteLength, 1024) - 3;
|
|
5264
5352
|
for (let offset = 0; offset < maxOffset; offset++) {
|
|
5265
|
-
if (getUint32(directoryView, offset) == ARCHIVE_EXTRA_DATA_SIGNATURE) {
|
|
5353
|
+
if (getUint32$1(directoryView, offset) == ARCHIVE_EXTRA_DATA_SIGNATURE) {
|
|
5266
5354
|
return true;
|
|
5267
5355
|
}
|
|
5268
5356
|
}
|
|
@@ -5273,15 +5361,15 @@
|
|
|
5273
5361
|
const directoryEncryptionInfo = { rawExtensibleData };
|
|
5274
5362
|
if (rawExtensibleData.length >= 28) {
|
|
5275
5363
|
const extensibleDataView = getDataView(rawExtensibleData);
|
|
5276
|
-
const hashDataLength = getUint16(extensibleDataView, 26);
|
|
5364
|
+
const hashDataLength = getUint16$1(extensibleDataView, 26);
|
|
5277
5365
|
Object.assign(directoryEncryptionInfo, {
|
|
5278
|
-
compressionMethod: getUint16(extensibleDataView, 0),
|
|
5366
|
+
compressionMethod: getUint16$1(extensibleDataView, 0),
|
|
5279
5367
|
compressedSize: Number(getBigUint64(extensibleDataView, 2)),
|
|
5280
5368
|
uncompressedSize: Number(getBigUint64(extensibleDataView, 10)),
|
|
5281
|
-
encryptionAlgorithm: getUint16(extensibleDataView, 18),
|
|
5282
|
-
bitLength: getUint16(extensibleDataView, 20),
|
|
5283
|
-
flags: getUint16(extensibleDataView, 22),
|
|
5284
|
-
hashAlgorithm: getUint16(extensibleDataView, 24),
|
|
5369
|
+
encryptionAlgorithm: getUint16$1(extensibleDataView, 18),
|
|
5370
|
+
bitLength: getUint16$1(extensibleDataView, 20),
|
|
5371
|
+
flags: getUint16$1(extensibleDataView, 22),
|
|
5372
|
+
hashAlgorithm: getUint16$1(extensibleDataView, 24),
|
|
5285
5373
|
hashData: rawExtensibleData.subarray(28, 28 + hashDataLength)
|
|
5286
5374
|
});
|
|
5287
5375
|
}
|
|
@@ -5289,12 +5377,12 @@
|
|
|
5289
5377
|
}
|
|
5290
5378
|
|
|
5291
5379
|
function readCommonHeader(directory, dataView, offset) {
|
|
5292
|
-
const rawBitFlag = directory.rawBitFlag = getUint16(dataView, offset + 2);
|
|
5380
|
+
const rawBitFlag = directory.rawBitFlag = getUint16$1(dataView, offset + 2);
|
|
5293
5381
|
const encrypted = (rawBitFlag & BITFLAG_ENCRYPTED) == BITFLAG_ENCRYPTED;
|
|
5294
|
-
const rawLastModDate = getUint32(dataView, offset + 6);
|
|
5382
|
+
const rawLastModDate = getUint32$1(dataView, offset + 6);
|
|
5295
5383
|
Object.assign(directory, {
|
|
5296
5384
|
encrypted,
|
|
5297
|
-
version: getUint16(dataView, offset),
|
|
5385
|
+
version: getUint16$1(dataView, offset),
|
|
5298
5386
|
bitFlag: {
|
|
5299
5387
|
level: (rawBitFlag & BITFLAG_LEVEL) >> 1,
|
|
5300
5388
|
dataDescriptor: (rawBitFlag & BITFLAG_DATA_DESCRIPTOR) == BITFLAG_DATA_DESCRIPTOR,
|
|
@@ -5302,8 +5390,8 @@
|
|
|
5302
5390
|
},
|
|
5303
5391
|
rawLastModDate,
|
|
5304
5392
|
lastModDate: getDate(rawLastModDate),
|
|
5305
|
-
filenameLength: getUint16(dataView, offset + 22),
|
|
5306
|
-
extraFieldLength: getUint16(dataView, offset + 24)
|
|
5393
|
+
filenameLength: getUint16$1(dataView, offset + 22),
|
|
5394
|
+
extraFieldLength: getUint16$1(dataView, offset + 24)
|
|
5307
5395
|
});
|
|
5308
5396
|
}
|
|
5309
5397
|
|
|
@@ -5314,8 +5402,8 @@
|
|
|
5314
5402
|
let offsetExtraField = 0;
|
|
5315
5403
|
try {
|
|
5316
5404
|
while (offsetExtraField < rawExtraField.length) {
|
|
5317
|
-
const type = getUint16(rawExtraFieldView, offsetExtraField);
|
|
5318
|
-
const size = getUint16(rawExtraFieldView, offsetExtraField + 2);
|
|
5405
|
+
const type = getUint16$1(rawExtraFieldView, offsetExtraField);
|
|
5406
|
+
const size = getUint16$1(rawExtraFieldView, offsetExtraField + 2);
|
|
5319
5407
|
extraField.set(type, {
|
|
5320
5408
|
type,
|
|
5321
5409
|
data: rawExtraField.slice(offsetExtraField + 4, offsetExtraField + 4 + size)
|
|
@@ -5325,12 +5413,12 @@
|
|
|
5325
5413
|
} catch {
|
|
5326
5414
|
// ignored
|
|
5327
5415
|
}
|
|
5328
|
-
const compressionMethod = getUint16(dataView, offset + 4);
|
|
5416
|
+
const compressionMethod = getUint16$1(dataView, offset + 4);
|
|
5329
5417
|
Object.assign(directory, {
|
|
5330
|
-
signature: getUint32(dataView, offset + HEADER_OFFSET_SIGNATURE),
|
|
5331
|
-
crc32: getUint32(dataView, offset + HEADER_OFFSET_SIGNATURE),
|
|
5332
|
-
compressedSize: getUint32(dataView, offset + HEADER_OFFSET_COMPRESSED_SIZE),
|
|
5333
|
-
uncompressedSize: getUint32(dataView, offset + HEADER_OFFSET_UNCOMPRESSED_SIZE)
|
|
5418
|
+
signature: getUint32$1(dataView, offset + HEADER_OFFSET_SIGNATURE),
|
|
5419
|
+
crc32: getUint32$1(dataView, offset + HEADER_OFFSET_SIGNATURE),
|
|
5420
|
+
compressedSize: getUint32$1(dataView, offset + HEADER_OFFSET_COMPRESSED_SIZE),
|
|
5421
|
+
uncompressedSize: getUint32$1(dataView, offset + HEADER_OFFSET_UNCOMPRESSED_SIZE)
|
|
5334
5422
|
});
|
|
5335
5423
|
const extraFieldZip64 = extraField.get(EXTRAFIELD_TYPE_ZIP64);
|
|
5336
5424
|
if (extraFieldZip64) {
|
|
@@ -5419,11 +5507,11 @@
|
|
|
5419
5507
|
computedCrc32.append(fileEntry[rawPropertyName]);
|
|
5420
5508
|
const computedCrc32View = getDataView(new Uint8Array(4));
|
|
5421
5509
|
computedCrc32View.setUint32(0, computedCrc32.get(), true);
|
|
5422
|
-
const nameCrc32 = getUint32(extraFieldView, 1);
|
|
5510
|
+
const nameCrc32 = getUint32$1(extraFieldView, 1);
|
|
5423
5511
|
Object.assign(extraFieldUnicode, {
|
|
5424
5512
|
version: getUint8(extraFieldView, 0),
|
|
5425
5513
|
[propertyName]: decodeText(extraFieldUnicode.data.subarray(5)),
|
|
5426
|
-
valid: !fileEntry.bitFlag.languageEncodingFlag && nameCrc32 == getUint32(computedCrc32View, 0)
|
|
5514
|
+
valid: !fileEntry.bitFlag.languageEncodingFlag && nameCrc32 == getUint32$1(computedCrc32View, 0)
|
|
5427
5515
|
});
|
|
5428
5516
|
if (extraFieldUnicode.valid) {
|
|
5429
5517
|
directory[propertyName] = extraFieldUnicode[propertyName];
|
|
@@ -5439,7 +5527,7 @@
|
|
|
5439
5527
|
vendorId: getUint8(extraFieldView, 2),
|
|
5440
5528
|
strength,
|
|
5441
5529
|
originalCompressionMethod: compressionMethod,
|
|
5442
|
-
compressionMethod: getUint16(extraFieldView, 5)
|
|
5530
|
+
compressionMethod: getUint16$1(extraFieldView, 5)
|
|
5443
5531
|
});
|
|
5444
5532
|
directory.compressionMethod = extraFieldAES.compressionMethod;
|
|
5445
5533
|
if (extraFieldAES.vendorVersion != VENDOR_VERSION_AE_1$1) {
|
|
@@ -5453,8 +5541,8 @@
|
|
|
5453
5541
|
let tag1Data;
|
|
5454
5542
|
try {
|
|
5455
5543
|
while (offsetExtraField < extraFieldNTFS.data.length && !tag1Data) {
|
|
5456
|
-
const tagValue = getUint16(extraFieldView, offsetExtraField);
|
|
5457
|
-
const attributeSize = getUint16(extraFieldView, offsetExtraField + 2);
|
|
5544
|
+
const tagValue = getUint16$1(extraFieldView, offsetExtraField);
|
|
5545
|
+
const attributeSize = getUint16$1(extraFieldView, offsetExtraField + 2);
|
|
5458
5546
|
if (tagValue == EXTRAFIELD_TYPE_NTFS_TAG1) {
|
|
5459
5547
|
tag1Data = extraFieldNTFS.data.slice(offsetExtraField + 4, offsetExtraField + 4 + attributeSize);
|
|
5460
5548
|
}
|
|
@@ -5487,12 +5575,12 @@
|
|
|
5487
5575
|
return;
|
|
5488
5576
|
}
|
|
5489
5577
|
const extraFieldView = getDataView(extraField.data);
|
|
5490
|
-
const lastAccessDate = new Date((getUint32(extraFieldView, 0) | 0) * 1000);
|
|
5491
|
-
const lastModDate = new Date((getUint32(extraFieldView, 4) | 0) * 1000);
|
|
5578
|
+
const lastAccessDate = new Date((getUint32$1(extraFieldView, 0) | 0) * 1000);
|
|
5579
|
+
const lastModDate = new Date((getUint32$1(extraFieldView, 4) | 0) * 1000);
|
|
5492
5580
|
const extraFieldData = { lastAccessDate, lastModDate };
|
|
5493
5581
|
if (extraField.data.length >= 12) {
|
|
5494
|
-
extraFieldData.uid = getUint16(extraFieldView, 8);
|
|
5495
|
-
extraFieldData.gid = getUint16(extraFieldView, 10);
|
|
5582
|
+
extraFieldData.uid = getUint16$1(extraFieldView, 8);
|
|
5583
|
+
extraFieldData.gid = getUint16$1(extraFieldView, 10);
|
|
5496
5584
|
}
|
|
5497
5585
|
Object.assign(extraField, extraFieldData);
|
|
5498
5586
|
Object.assign(directory, extraFieldData);
|
|
@@ -5512,8 +5600,8 @@
|
|
|
5512
5600
|
gid = unpackUnixId(extraField.data.subarray(offset, offset + gidSize));
|
|
5513
5601
|
Object.assign(extraField, { version, uid, gid });
|
|
5514
5602
|
} else if (extraField.data.length >= 4) {
|
|
5515
|
-
uid = getUint16(view, 0);
|
|
5516
|
-
gid = getUint16(view, 2);
|
|
5603
|
+
uid = getUint16$1(view, 0);
|
|
5604
|
+
gid = getUint16$1(view, 2);
|
|
5517
5605
|
Object.assign(extraField, { uid, gid });
|
|
5518
5606
|
}
|
|
5519
5607
|
if (uid !== UNDEFINED_VALUE) {
|
|
@@ -5563,7 +5651,7 @@
|
|
|
5563
5651
|
let offset = 1;
|
|
5564
5652
|
timeProperties.forEach((propertyName, indexProperty) => {
|
|
5565
5653
|
if (extraFieldExtendedTimestamp.data.length >= offset + 4) {
|
|
5566
|
-
const time = getUint32(extraFieldView, offset);
|
|
5654
|
+
const time = getUint32$1(extraFieldView, offset);
|
|
5567
5655
|
directory[propertyName] = extraFieldExtendedTimestamp[propertyName] = new Date((time | 0) * 1000);
|
|
5568
5656
|
const rawPropertyName = timeRawProperties[indexProperty];
|
|
5569
5657
|
extraFieldExtendedTimestamp[rawPropertyName] = time;
|
|
@@ -5597,7 +5685,7 @@
|
|
|
5597
5685
|
const dataDescriptorArray = await readUint8Array(reader, dataOffset + compressedSize, dataDescriptorLength + DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH);
|
|
5598
5686
|
const dataDescriptorView = getDataView(dataDescriptorArray);
|
|
5599
5687
|
let signature = dataDescriptorArray.length == dataDescriptorLength + DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH &&
|
|
5600
|
-
getUint32(dataDescriptorView, 0) == DATA_DESCRIPTOR_RECORD_SIGNATURE;
|
|
5688
|
+
getUint32$1(dataDescriptorView, 0) == DATA_DESCRIPTOR_RECORD_SIGNATURE;
|
|
5601
5689
|
if (signature) {
|
|
5602
5690
|
const signedDataDescriptor = readDataDescriptor(dataDescriptorView, DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH, extraFieldZip64);
|
|
5603
5691
|
const matchCrc32 = (fileEntry.encrypted && !fileEntry.zipCrypto) || signedDataDescriptor.crc32 == crc32;
|
|
@@ -5631,15 +5719,15 @@
|
|
|
5631
5719
|
}
|
|
5632
5720
|
|
|
5633
5721
|
function readDataDescriptor(dataDescriptorView, offset, extraFieldZip64) {
|
|
5634
|
-
const crc32 = getUint32(dataDescriptorView, offset);
|
|
5722
|
+
const crc32 = getUint32$1(dataDescriptorView, offset);
|
|
5635
5723
|
let compressedSize;
|
|
5636
5724
|
let uncompressedSize;
|
|
5637
5725
|
if (extraFieldZip64) {
|
|
5638
5726
|
compressedSize = getBigUint64(dataDescriptorView, offset + 4);
|
|
5639
5727
|
uncompressedSize = getBigUint64(dataDescriptorView, offset + 12);
|
|
5640
5728
|
} else {
|
|
5641
|
-
compressedSize = getUint32(dataDescriptorView, offset + 4);
|
|
5642
|
-
uncompressedSize = getUint32(dataDescriptorView, offset + 8);
|
|
5729
|
+
compressedSize = getUint32$1(dataDescriptorView, offset + 4);
|
|
5730
|
+
uncompressedSize = getUint32$1(dataDescriptorView, offset + 8);
|
|
5643
5731
|
}
|
|
5644
5732
|
return { crc32, compressedSize, uncompressedSize };
|
|
5645
5733
|
}
|
|
@@ -5648,10 +5736,28 @@
|
|
|
5648
5736
|
return reader.getDiskOffset ? reader.getDiskOffset(diskNumber) : 0;
|
|
5649
5737
|
}
|
|
5650
5738
|
|
|
5739
|
+
async function startsWithSplitZipSignature$1(reader) {
|
|
5740
|
+
return await getFirstSignature(reader) == SPLIT_ZIP_FILE_SIGNATURE;
|
|
5741
|
+
}
|
|
5742
|
+
|
|
5743
|
+
async function startsWithSplitZipMarker(reader) {
|
|
5744
|
+
const signature = await getFirstSignature(reader);
|
|
5745
|
+
return signature == SPLIT_ZIP_FILE_SIGNATURE || signature == TEMPORARY_SPLIT_ZIP_FILE_SIGNATURE;
|
|
5746
|
+
}
|
|
5747
|
+
|
|
5748
|
+
async function getFirstSignature(reader) {
|
|
5749
|
+
const signatureArray = await readUint8Array(reader, 0, SPLIT_ZIP_FILE_SIGNATURE_LENGTH);
|
|
5750
|
+
return getUint32$1(getDataView(signatureArray));
|
|
5751
|
+
}
|
|
5752
|
+
|
|
5651
5753
|
function isStrictnessValue(value) {
|
|
5652
5754
|
return value === STRICTNESS_STRICT || value === STRICTNESS_BALANCED || value === STRICTNESS_TOLERANT;
|
|
5653
5755
|
}
|
|
5654
5756
|
|
|
5757
|
+
function getDecodableOutputSize(outputSize, compressedSize, compressed) {
|
|
5758
|
+
return Math.min(outputSize, compressed ? compressedSize * MAX_DEFLATE_EXPANSION_RATIO : compressedSize);
|
|
5759
|
+
}
|
|
5760
|
+
|
|
5655
5761
|
function getStrictness(options, inheritedOptions) {
|
|
5656
5762
|
return resolveStrictness(options, resolveStrictness(inheritedOptions, STRICTNESS_BALANCED));
|
|
5657
5763
|
}
|
|
@@ -5714,7 +5820,7 @@
|
|
|
5714
5820
|
|
|
5715
5821
|
function getMaxAppendedDataSize(maxAppendedDataSize, strictness) {
|
|
5716
5822
|
if (maxAppendedDataSize !== UNDEFINED_VALUE) {
|
|
5717
|
-
const size = toNumber
|
|
5823
|
+
const size = toNumber(maxAppendedDataSize);
|
|
5718
5824
|
if (typeof size != NUMBER_TYPE || Number.isNaN(size) || size < 0) {
|
|
5719
5825
|
throw new Error(ERR_INVALID_MAX_APPENDED_DATA_SIZE);
|
|
5720
5826
|
}
|
|
@@ -5737,7 +5843,7 @@
|
|
|
5737
5843
|
let plausibleEndOfDirectoryInfo;
|
|
5738
5844
|
let endOfDirectoryReachingEndCount = 0;
|
|
5739
5845
|
for await (const [anchoredView, anchoredOffset, anchoredArray, indexByte, offset] of scanEndOfCentralDirectory(reader, anchoredLength)) {
|
|
5740
|
-
const commentLength = getUint16(anchoredView, indexByte + 20);
|
|
5846
|
+
const commentLength = getUint16$1(anchoredView, indexByte + 20);
|
|
5741
5847
|
if (offset + END_OF_CENTRAL_DIR_LENGTH + commentLength == size) {
|
|
5742
5848
|
const reachability = await getCentralDirectoryReachability(reader, anchoredView, anchoredOffset, indexByte, offset, size, remoteProbeBudget);
|
|
5743
5849
|
if (reachability == CENTRAL_DIRECTORY_REACHABLE) {
|
|
@@ -5788,7 +5894,7 @@
|
|
|
5788
5894
|
const scanArray = await readUint8Array(reader, scanOffset, scanLength);
|
|
5789
5895
|
const scanView = getDataView(scanArray);
|
|
5790
5896
|
for (let indexByte = scanArray.length - END_OF_CENTRAL_DIR_LENGTH; indexByte >= 0; indexByte--) {
|
|
5791
|
-
if (getUint32(scanView, indexByte) == END_OF_CENTRAL_DIR_SIGNATURE) {
|
|
5897
|
+
if (getUint32$1(scanView, indexByte) == END_OF_CENTRAL_DIR_SIGNATURE) {
|
|
5792
5898
|
yield [scanView, scanOffset, scanArray, indexByte, scanOffset + indexByte];
|
|
5793
5899
|
}
|
|
5794
5900
|
}
|
|
@@ -5799,9 +5905,9 @@
|
|
|
5799
5905
|
}
|
|
5800
5906
|
|
|
5801
5907
|
async function getCentralDirectoryReachability(reader, view, anchoredOffset, indexByte, offset, size, remoteProbeBudget) {
|
|
5802
|
-
const filesLength = getUint16(view, indexByte + 10);
|
|
5803
|
-
const directoryDataLength = getUint32(view, indexByte + 12);
|
|
5804
|
-
const directoryDataOffset = getUint32(view, indexByte + 16);
|
|
5908
|
+
const filesLength = getUint16$1(view, indexByte + 10);
|
|
5909
|
+
const directoryDataLength = getUint32$1(view, indexByte + 12);
|
|
5910
|
+
const directoryDataOffset = getUint32$1(view, indexByte + 16);
|
|
5805
5911
|
if (filesLength == MAX_16_BITS || directoryDataLength == MAX_32_BITS || directoryDataOffset == MAX_32_BITS) {
|
|
5806
5912
|
const locatorSignature = await readSignature(reader, view, anchoredOffset, offset - ZIP64_END_OF_CENTRAL_DIR_LOCATOR_LENGTH, size, remoteProbeBudget);
|
|
5807
5913
|
return locatorSignature == ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIGNATURE ? CENTRAL_DIRECTORY_REACHABLE : CENTRAL_DIRECTORY_UNREACHABLE;
|
|
@@ -5809,7 +5915,7 @@
|
|
|
5809
5915
|
if (!filesLength && !directoryDataLength) {
|
|
5810
5916
|
return CENTRAL_DIRECTORY_PLAUSIBLE;
|
|
5811
5917
|
}
|
|
5812
|
-
const directoryDiskNumber = getUint16(view, indexByte + 6);
|
|
5918
|
+
const directoryDiskNumber = getUint16$1(view, indexByte + 6);
|
|
5813
5919
|
for (const centralDirectoryOffset of [offset - directoryDataLength, getDiskOffset$1(reader, directoryDiskNumber) + directoryDataOffset]) {
|
|
5814
5920
|
if (await readSignature(reader, view, anchoredOffset, centralDirectoryOffset, size, remoteProbeBudget) == CENTRAL_FILE_HEADER_SIGNATURE) {
|
|
5815
5921
|
return CENTRAL_DIRECTORY_REACHABLE;
|
|
@@ -5823,12 +5929,12 @@
|
|
|
5823
5929
|
return UNDEFINED_VALUE;
|
|
5824
5930
|
}
|
|
5825
5931
|
if (signatureOffset >= anchoredOffset) {
|
|
5826
|
-
return getUint32(view, signatureOffset - anchoredOffset);
|
|
5932
|
+
return getUint32$1(view, signatureOffset - anchoredOffset);
|
|
5827
5933
|
}
|
|
5828
5934
|
if (remoteProbeBudget.count > 0) {
|
|
5829
5935
|
remoteProbeBudget.count--;
|
|
5830
5936
|
const signatureArray = await readUint8Array(reader, signatureOffset, 4);
|
|
5831
|
-
return getUint32(getDataView(signatureArray), 0);
|
|
5937
|
+
return getUint32$1(getDataView(signatureArray), 0);
|
|
5832
5938
|
}
|
|
5833
5939
|
return UNDEFINED_VALUE;
|
|
5834
5940
|
}
|
|
@@ -5865,10 +5971,11 @@
|
|
|
5865
5971
|
return options[name] === UNDEFINED_VALUE ? zipReader.options[name] : options[name];
|
|
5866
5972
|
}
|
|
5867
5973
|
|
|
5868
|
-
function
|
|
5869
|
-
return
|
|
5974
|
+
function getFunctionOptionValue$1(zipReader, options, name) {
|
|
5975
|
+
return checkFunctionOption(getOptionValue$1(zipReader, options, name));
|
|
5870
5976
|
}
|
|
5871
5977
|
|
|
5978
|
+
|
|
5872
5979
|
function getDate(timeRaw) {
|
|
5873
5980
|
const date = (timeRaw & 0xffff0000) >> 16, time = timeRaw & MAX_16_BITS;
|
|
5874
5981
|
return new Date(1980 + ((date & 0xFE00) >> 9), ((date & 0x01E0) >> 5) - 1, date & 0x001F, (time & 0xF800) >> 11, (time & 0x07E0) >> 5, (time & 0x001F) * 2, 0);
|
|
@@ -5882,11 +5989,11 @@
|
|
|
5882
5989
|
return view.getUint8(offset);
|
|
5883
5990
|
}
|
|
5884
5991
|
|
|
5885
|
-
function getUint16(view, offset) {
|
|
5992
|
+
function getUint16$1(view, offset) {
|
|
5886
5993
|
return view.getUint16(offset, true);
|
|
5887
5994
|
}
|
|
5888
5995
|
|
|
5889
|
-
function getUint32(view, offset) {
|
|
5996
|
+
function getUint32$1(view, offset) {
|
|
5890
5997
|
return view.getUint32(offset, true);
|
|
5891
5998
|
}
|
|
5892
5999
|
|
|
@@ -5901,6 +6008,7 @@
|
|
|
5901
6008
|
ERR_CENTRAL_DIRECTORY_NOT_FOUND: ERR_CENTRAL_DIRECTORY_NOT_FOUND,
|
|
5902
6009
|
ERR_ENCRYPTED: ERR_ENCRYPTED,
|
|
5903
6010
|
ERR_ENCRYPTED_CENTRAL_DIRECTORY: ERR_ENCRYPTED_CENTRAL_DIRECTORY,
|
|
6011
|
+
ERR_ENTRY_DATA_OUT_OF_BOUNDS: ERR_ENTRY_DATA_OUT_OF_BOUNDS,
|
|
5904
6012
|
ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND: ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND,
|
|
5905
6013
|
ERR_EOCDR_NOT_FOUND: ERR_EOCDR_NOT_FOUND,
|
|
5906
6014
|
ERR_EXTRAFIELD_ZIP64_NOT_FOUND: ERR_EXTRAFIELD_ZIP64_NOT_FOUND,
|
|
@@ -5957,12 +6065,16 @@
|
|
|
5957
6065
|
const ERR_INVALID_COMMENT = "Zip file comment exceeds 64KB";
|
|
5958
6066
|
const ERR_INVALID_COMMENT_TYPE = "Invalid zip file comment (must be a Uint8Array)";
|
|
5959
6067
|
const ERR_INVALID_ENTRY_COMMENT = "File entry comment exceeds 64KB";
|
|
6068
|
+
const ERR_INVALID_ENTRY_COMMENT_TYPE = "Invalid file entry comment (must be a string)";
|
|
6069
|
+
const ERR_INVALID_DATE = "Invalid date (must be a valid Date instance)";
|
|
5960
6070
|
const ERR_INVALID_ENTRY_NAME = "File entry name exceeds 64KB";
|
|
5961
6071
|
const ERR_INVALID_VERSION = "Version exceeds 65535";
|
|
5962
6072
|
const ERR_INVALID_ENCRYPTION_STRENGTH = "The strength must equal 1, 2, or 3";
|
|
5963
6073
|
const ERR_UNSUPPORTED_ENCRYPTION_USDZ = "Encryption is not supported in USDZ files";
|
|
5964
6074
|
const ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH = "Encryption is not supported when the 'passThrough' option is set";
|
|
5965
|
-
const
|
|
6075
|
+
const ERR_INVALID_EXTRAFIELD = "Invalid extra field (must be a Map)";
|
|
6076
|
+
const ERR_INVALID_EXTRAFIELD_TYPE = "Invalid extra field type (must be integer 0..65535)";
|
|
6077
|
+
const ERR_INVALID_EXTRAFIELD_DATA_TYPE = "Invalid extra field data (must be a Uint8Array)";
|
|
5966
6078
|
const ERR_INVALID_EXTRAFIELD_DATA = "Extra field data exceeds 64KB";
|
|
5967
6079
|
const ERR_UNSUPPORTED_COMPRESSION = "Compression method not supported";
|
|
5968
6080
|
const MIN_UNIX_TIME = -2147483648;
|
|
@@ -5982,7 +6094,6 @@
|
|
|
5982
6094
|
const ERR_INVALID_MSDOS_ATTRIBUTES = "Invalid msdosAttributesRaw (must be integer 0..255)";
|
|
5983
6095
|
const ERR_INVALID_MSDOS_DATA = "Invalid msdosAttributes (must be an object with boolean flags)";
|
|
5984
6096
|
const ERR_INVALID_LEVEL = "Invalid level (must be integer 0..9)";
|
|
5985
|
-
const ERR_INVALID_PASSWORD_TYPE = "Invalid password (password must be a string, rawPassword must be a Uint8Array)";
|
|
5986
6097
|
const ERR_INVALID_SIGNATURE_DATA = "Signature data exceeds 64KB";
|
|
5987
6098
|
|
|
5988
6099
|
const EXTRAFIELD_DATA_AES = new Uint8Array([0x07, 0x00, 0x02, 0x00, 0x41, 0x45, 0x03, 0x00, 0x00]);
|
|
@@ -6007,8 +6118,7 @@
|
|
|
6007
6118
|
writer,
|
|
6008
6119
|
addSplitZipSignature,
|
|
6009
6120
|
options,
|
|
6010
|
-
|
|
6011
|
-
files: new Map(),
|
|
6121
|
+
fileEntries: new Map(),
|
|
6012
6122
|
filenames: new Set(),
|
|
6013
6123
|
offset: options[OPTION_OFFSET] === UNDEFINED_VALUE ? writer.size || writer.writable.size || 0 : options[OPTION_OFFSET],
|
|
6014
6124
|
initialOffset: options[OPTION_OFFSET] === UNDEFINED_VALUE ? 0 : options[OPTION_OFFSET] - (writer.size || writer.writable.size || 0),
|
|
@@ -6029,14 +6139,23 @@
|
|
|
6029
6139
|
await initStream(reader);
|
|
6030
6140
|
}
|
|
6031
6141
|
const { ZipReader } = await Promise.resolve().then(function () { return zipReader; });
|
|
6032
|
-
const zipReader$1 = new ZipReader(reader
|
|
6142
|
+
const zipReader$1 = new ZipReader(reader);
|
|
6033
6143
|
const entries = await zipReader$1.getEntries();
|
|
6034
6144
|
await zipReader$1.close();
|
|
6035
6145
|
await initStream(this.writer);
|
|
6036
|
-
|
|
6037
|
-
|
|
6146
|
+
const { directoryOffset } = zipReader$1;
|
|
6147
|
+
let splitZipSignatureLength = 0;
|
|
6148
|
+
if (this.addSplitZipSignature) {
|
|
6149
|
+
delete this.addSplitZipSignature;
|
|
6150
|
+
if (!await startsWithSplitZipSignature(reader)) {
|
|
6151
|
+
await writeData(this.writer, getSplitZipSignatureArray());
|
|
6152
|
+
splitZipSignatureLength = SPLIT_ZIP_FILE_SIGNATURE_LENGTH;
|
|
6153
|
+
this.offset += splitZipSignatureLength;
|
|
6154
|
+
}
|
|
6155
|
+
}
|
|
6156
|
+
const entryPositions = await copyZipData(this, reader, entries, directoryOffset, splitZipSignatureLength);
|
|
6038
6157
|
this.filenames = new Set(entries.map(entry => entry.filename));
|
|
6039
|
-
this.
|
|
6158
|
+
this.fileEntries = new Map(entries.map(entry => {
|
|
6040
6159
|
const {
|
|
6041
6160
|
version,
|
|
6042
6161
|
rawLastModDate,
|
|
@@ -6091,11 +6210,12 @@
|
|
|
6091
6210
|
if (crc32 !== UNDEFINED_VALUE) {
|
|
6092
6211
|
setUint32(headerView, HEADER_OFFSET_SIGNATURE, crc32);
|
|
6093
6212
|
}
|
|
6213
|
+
const { offset, diskNumberStart } = entryPositions.get(entry);
|
|
6094
6214
|
Object.assign(entry, {
|
|
6095
6215
|
zip64UncompressedSize,
|
|
6096
6216
|
zip64CompressedSize,
|
|
6097
|
-
|
|
6098
|
-
diskNumberStart
|
|
6217
|
+
offset,
|
|
6218
|
+
diskNumberStart,
|
|
6099
6219
|
zip64DiskNumberStart: false,
|
|
6100
6220
|
rawExtraFieldZip64,
|
|
6101
6221
|
rawExtraFieldAES,
|
|
@@ -6115,11 +6235,8 @@
|
|
|
6115
6235
|
async add(name = "", reader, options = {}) {
|
|
6116
6236
|
const zipWriter = this;
|
|
6117
6237
|
options = Object.assign({}, options);
|
|
6118
|
-
const {
|
|
6119
|
-
|
|
6120
|
-
config
|
|
6121
|
-
} = zipWriter;
|
|
6122
|
-
if (workers < config.maxWorkers) {
|
|
6238
|
+
const { pendingAddFileCalls } = zipWriter;
|
|
6239
|
+
if (workers < getConfiguration().maxWorkers) {
|
|
6123
6240
|
workers++;
|
|
6124
6241
|
} else {
|
|
6125
6242
|
await new Promise(resolve => pendingEntries.push(resolve));
|
|
@@ -6156,16 +6273,16 @@
|
|
|
6156
6273
|
}
|
|
6157
6274
|
|
|
6158
6275
|
remove(entry) {
|
|
6159
|
-
const { filenames,
|
|
6276
|
+
const { filenames, fileEntries } = this;
|
|
6160
6277
|
// deno-lint-ignore valid-typeof
|
|
6161
6278
|
if (typeof entry == STRING_TYPE) {
|
|
6162
|
-
entry =
|
|
6279
|
+
entry = fileEntries.get(entry);
|
|
6163
6280
|
}
|
|
6164
6281
|
if (entry && entry.filename !== UNDEFINED_VALUE) {
|
|
6165
6282
|
const { filename } = entry;
|
|
6166
|
-
if (filenames.has(filename) &&
|
|
6283
|
+
if (filenames.has(filename) && fileEntries.has(filename)) {
|
|
6167
6284
|
filenames.delete(filename);
|
|
6168
|
-
|
|
6285
|
+
fileEntries.delete(filename);
|
|
6169
6286
|
return true;
|
|
6170
6287
|
}
|
|
6171
6288
|
}
|
|
@@ -6262,12 +6379,12 @@
|
|
|
6262
6379
|
const metadataInfo = resolveMetadata(zipWriter, name, options);
|
|
6263
6380
|
const { comment } = metadataInfo;
|
|
6264
6381
|
const extraField = options[PROPERTY_NAME_EXTRA_FIELD];
|
|
6265
|
-
zipWriter.
|
|
6382
|
+
zipWriter.fileEntries.set(name, UNDEFINED_VALUE);
|
|
6266
6383
|
let fileEntry;
|
|
6267
6384
|
try {
|
|
6268
6385
|
const { resolvedOptions } = metadataInfo;
|
|
6269
6386
|
if (resolvedOptions.level != 0 && resolvedOptions.compressionMethod === UNDEFINED_VALUE &&
|
|
6270
|
-
!resolvedOptions.passThrough && !(await supportsDeflate(
|
|
6387
|
+
!resolvedOptions.passThrough && !(await supportsDeflate(getConfiguration()))) {
|
|
6271
6388
|
resolvedOptions.level = 0;
|
|
6272
6389
|
}
|
|
6273
6390
|
const sizesInfo = await resolveSizes(zipWriter, reader, metadataInfo, options);
|
|
@@ -6285,7 +6402,7 @@
|
|
|
6285
6402
|
const metadataSize = getLength(headerInfo.localHeaderArray, dataDescriptorInfo.dataDescriptorArray);
|
|
6286
6403
|
fileEntry = await getFileEntry(zipWriter, name, reader, { headerInfo, dataDescriptorInfo, metadataSize }, options);
|
|
6287
6404
|
} catch (error) {
|
|
6288
|
-
zipWriter.
|
|
6405
|
+
zipWriter.fileEntries.delete(name);
|
|
6289
6406
|
throw error;
|
|
6290
6407
|
}
|
|
6291
6408
|
Object.assign(fileEntry, {
|
|
@@ -6329,9 +6446,9 @@
|
|
|
6329
6446
|
if (unixExtraFieldType === UNDEFINED_VALUE && (uid !== UNDEFINED_VALUE || gid !== UNDEFINED_VALUE)) {
|
|
6330
6447
|
unixExtraFieldType = INFOZIP_EXTRA_FIELD_TYPE;
|
|
6331
6448
|
}
|
|
6332
|
-
let msdosAttributesRaw =
|
|
6449
|
+
let msdosAttributesRaw = getNumberOptionValue(zipWriter, options, PROPERTY_NAME_MSDOS_ATTRIBUTES_RAW);
|
|
6333
6450
|
let msdosAttributes = getOptionValue(zipWriter, options, PROPERTY_NAME_MSDOS_ATTRIBUTES);
|
|
6334
|
-
const hasUnixMetadata = uid !== UNDEFINED_VALUE || gid !== UNDEFINED_VALUE || unixMode !== UNDEFINED_VALUE || unixExtraFieldType;
|
|
6451
|
+
const hasUnixMetadata = uid !== UNDEFINED_VALUE || gid !== UNDEFINED_VALUE || unixMode !== UNDEFINED_VALUE || unixExtraFieldType || executable;
|
|
6335
6452
|
const hasMsDosProvided = msdosAttributesRaw !== UNDEFINED_VALUE || msdosAttributes !== UNDEFINED_VALUE;
|
|
6336
6453
|
if (hasUnixMetadata) {
|
|
6337
6454
|
msDosCompatible = false;
|
|
@@ -6340,10 +6457,10 @@
|
|
|
6340
6457
|
msDosCompatible = true;
|
|
6341
6458
|
versionMadeBy = (versionMadeBy & MAX_8_BITS);
|
|
6342
6459
|
}
|
|
6343
|
-
if (msdosAttributesRaw !== UNDEFINED_VALUE && (msdosAttributesRaw < 0 || msdosAttributesRaw > MAX_8_BITS)) {
|
|
6460
|
+
if (msdosAttributesRaw !== UNDEFINED_VALUE && (!Number.isInteger(msdosAttributesRaw) || msdosAttributesRaw < 0 || msdosAttributesRaw > MAX_8_BITS)) {
|
|
6344
6461
|
throw new Error(ERR_INVALID_MSDOS_ATTRIBUTES);
|
|
6345
6462
|
}
|
|
6346
|
-
if (msdosAttributes && typeof msdosAttributes !== OBJECT_TYPE) {
|
|
6463
|
+
if (msdosAttributes && (typeof msdosAttributes !== OBJECT_TYPE || Array.isArray(msdosAttributes))) {
|
|
6347
6464
|
throw new Error(ERR_INVALID_MSDOS_DATA);
|
|
6348
6465
|
}
|
|
6349
6466
|
if (versionMadeBy > MAX_16_BITS) {
|
|
@@ -6431,7 +6548,7 @@
|
|
|
6431
6548
|
}
|
|
6432
6549
|
|
|
6433
6550
|
function resolveMetadata(zipWriter, name, options) {
|
|
6434
|
-
const encode =
|
|
6551
|
+
const encode = getFunctionOptionValue(zipWriter, options, OPTION_ENCODE_TEXT) || encodeText;
|
|
6435
6552
|
let rawFilename = encode(name, TEXT_TYPE_FILENAME);
|
|
6436
6553
|
if (rawFilename === UNDEFINED_VALUE) {
|
|
6437
6554
|
rawFilename = encodeText(name);
|
|
@@ -6440,6 +6557,10 @@
|
|
|
6440
6557
|
throw new Error(ERR_INVALID_ENTRY_NAME);
|
|
6441
6558
|
}
|
|
6442
6559
|
const comment = options[PROPERTY_NAME_COMMENT] || "";
|
|
6560
|
+
// deno-lint-ignore valid-typeof
|
|
6561
|
+
if (typeof comment != STRING_TYPE) {
|
|
6562
|
+
throw new Error(ERR_INVALID_ENTRY_COMMENT_TYPE);
|
|
6563
|
+
}
|
|
6443
6564
|
let rawComment = encode(comment, TEXT_TYPE_COMMENT);
|
|
6444
6565
|
if (rawComment === UNDEFINED_VALUE) {
|
|
6445
6566
|
rawComment = encodeText(comment);
|
|
@@ -6451,16 +6572,14 @@
|
|
|
6451
6572
|
if (version > MAX_16_BITS) {
|
|
6452
6573
|
throw new Error(ERR_INVALID_VERSION);
|
|
6453
6574
|
}
|
|
6454
|
-
const lastModDate =
|
|
6455
|
-
const lastAccessDate =
|
|
6456
|
-
const creationDate =
|
|
6575
|
+
const lastModDate = getDateOptionValue(zipWriter, options, PROPERTY_NAME_LAST_MODIFICATION_DATE, new Date());
|
|
6576
|
+
const lastAccessDate = getDateOptionValue(zipWriter, options, PROPERTY_NAME_LAST_ACCESS_DATE);
|
|
6577
|
+
const creationDate = getDateOptionValue(zipWriter, options, PROPERTY_NAME_CREATION_DATE);
|
|
6457
6578
|
const internalFileAttributes = getAliasedOptionValue(zipWriter, options, PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTES, PROPERTY_NAME_DEPRECATED_INTERNAL_FILE_ATTRIBUTES, 0);
|
|
6458
6579
|
const passThrough = getOptionValue(zipWriter, options, OPTION_PASS_THROUGH);
|
|
6459
6580
|
const password = getOptionValue(zipWriter, options, OPTION_PASSWORD);
|
|
6460
6581
|
const rawPassword = getOptionValue(zipWriter, options, OPTION_RAW_PASSWORD);
|
|
6461
|
-
|
|
6462
|
-
throw new Error(ERR_INVALID_PASSWORD_TYPE);
|
|
6463
|
-
}
|
|
6582
|
+
checkPasswordOption(password, rawPassword);
|
|
6464
6583
|
const encryptionStrength = getNumberOptionValue(zipWriter, options, OPTION_ENCRYPTION_STRENGTH, 3);
|
|
6465
6584
|
const zipCrypto = getOptionValue(zipWriter, options, PROPERTY_NAME_ZIPCRYPTO);
|
|
6466
6585
|
const extendedTimestamp = getOptionValue(zipWriter, options, OPTION_EXTENDED_TIMESTAMP, true);
|
|
@@ -6469,9 +6588,9 @@
|
|
|
6469
6588
|
const useWebWorkers = getOptionValue(zipWriter, options, OPTION_USE_WEB_WORKERS);
|
|
6470
6589
|
const transferStreams = getOptionValue(zipWriter, options, OPTION_TRANSFER_STREAMS);
|
|
6471
6590
|
const bufferedWrite = getOptionValue(zipWriter, options, OPTION_BUFFERED_WRITE);
|
|
6472
|
-
const createTempStream =
|
|
6591
|
+
const createTempStream = getFunctionOptionValue(zipWriter, options, OPTION_CREATE_TEMP_STREAM);
|
|
6473
6592
|
const dataDescriptorSignature = getOptionValue(zipWriter, options, OPTION_DATA_DESCRIPTOR_SIGNATURE, true);
|
|
6474
|
-
const signal = getOptionValue(zipWriter, options, OPTION_SIGNAL);
|
|
6593
|
+
const signal = checkSignalOption(getOptionValue(zipWriter, options, OPTION_SIGNAL));
|
|
6475
6594
|
const useUnicodeFileNames = getOptionValue(zipWriter, options, OPTION_USE_UNICODE_FILE_NAMES, true);
|
|
6476
6595
|
const compressionMethod = getOptionValue(zipWriter, options, PROPERTY_NAME_COMPRESSION_METHOD);
|
|
6477
6596
|
const registeredCodec = passThrough || compressionMethod === UNDEFINED_VALUE ? UNDEFINED_VALUE : getRegisteredCodec(compressionMethod);
|
|
@@ -6551,18 +6670,26 @@
|
|
|
6551
6670
|
if (!extraField) {
|
|
6552
6671
|
return EMPTY_UINT8_ARRAY;
|
|
6553
6672
|
}
|
|
6673
|
+
if (!(extraField instanceof Map)) {
|
|
6674
|
+
throw new Error(ERR_INVALID_EXTRAFIELD);
|
|
6675
|
+
}
|
|
6554
6676
|
let extraFieldSize = 0;
|
|
6555
6677
|
let offset = 0;
|
|
6556
|
-
extraField.forEach(data => extraFieldSize += 4 + getLength(data));
|
|
6557
|
-
const rawExtraField = new Uint8Array(extraFieldSize);
|
|
6558
|
-
const rawExtraFieldView = getDataView(rawExtraField);
|
|
6559
6678
|
extraField.forEach((data, type) => {
|
|
6560
|
-
if (type > MAX_16_BITS) {
|
|
6679
|
+
if (!Number.isInteger(type) || type < 0 || type > MAX_16_BITS) {
|
|
6561
6680
|
throw new Error(ERR_INVALID_EXTRAFIELD_TYPE);
|
|
6562
6681
|
}
|
|
6682
|
+
if (!(data instanceof Uint8Array)) {
|
|
6683
|
+
throw new Error(ERR_INVALID_EXTRAFIELD_DATA_TYPE);
|
|
6684
|
+
}
|
|
6563
6685
|
if (getLength(data) > MAX_16_BITS) {
|
|
6564
6686
|
throw new Error(ERR_INVALID_EXTRAFIELD_DATA);
|
|
6565
6687
|
}
|
|
6688
|
+
extraFieldSize += 4 + getLength(data);
|
|
6689
|
+
});
|
|
6690
|
+
const rawExtraField = new Uint8Array(extraFieldSize);
|
|
6691
|
+
const rawExtraFieldView = getDataView(rawExtraField);
|
|
6692
|
+
extraField.forEach((data, type) => {
|
|
6566
6693
|
setUint16(rawExtraFieldView, offset, type);
|
|
6567
6694
|
setUint16(rawExtraFieldView, offset + 2, getLength(data));
|
|
6568
6695
|
arraySet(rawExtraField, data, offset + 4);
|
|
@@ -6650,7 +6777,7 @@
|
|
|
6650
6777
|
|
|
6651
6778
|
async function getFileEntry(zipWriter, name, reader, entryInfo, options) {
|
|
6652
6779
|
const {
|
|
6653
|
-
|
|
6780
|
+
fileEntries,
|
|
6654
6781
|
writer
|
|
6655
6782
|
} = zipWriter;
|
|
6656
6783
|
const {
|
|
@@ -6672,12 +6799,12 @@
|
|
|
6672
6799
|
let writerSizeBeforeEntry;
|
|
6673
6800
|
let flushedBufferedSize = 0;
|
|
6674
6801
|
let fileWriter;
|
|
6675
|
-
|
|
6802
|
+
fileEntries.set(name, fileEntry);
|
|
6676
6803
|
zipWriter.lastFileEntry = fileEntry;
|
|
6677
6804
|
try {
|
|
6678
6805
|
let lockPreviousFileEntry;
|
|
6679
6806
|
if (keepOrder) {
|
|
6680
|
-
lockPreviousFileEntry = previousFileEntry && previousFileEntry.
|
|
6807
|
+
lockPreviousFileEntry = previousFileEntry && previousFileEntry.lockFileEntry;
|
|
6681
6808
|
requestLockCurrentFileEntry();
|
|
6682
6809
|
}
|
|
6683
6810
|
if (options.bufferedWrite || !keepOrder || zipWriter.writerLocked || zipWriter.bufferedWrites || !dataDescriptor) {
|
|
@@ -6698,11 +6825,8 @@
|
|
|
6698
6825
|
const diskOffset = getDiskOffset(writer);
|
|
6699
6826
|
if (zipWriter.addSplitZipSignature) {
|
|
6700
6827
|
delete zipWriter.addSplitZipSignature;
|
|
6701
|
-
|
|
6702
|
-
|
|
6703
|
-
setUint32(signatureArrayView, 0, SPLIT_ZIP_FILE_SIGNATURE);
|
|
6704
|
-
await writeData(writer, signatureArray);
|
|
6705
|
-
zipWriter.offset += 4;
|
|
6828
|
+
await writeData(writer, getSplitZipSignatureArray());
|
|
6829
|
+
zipWriter.offset += SPLIT_ZIP_FILE_SIGNATURE_LENGTH;
|
|
6706
6830
|
}
|
|
6707
6831
|
if (usdz && !bufferedWrite) {
|
|
6708
6832
|
appendExtraFieldUSDZ(entryInfo, zipWriter.offset - diskOffset);
|
|
@@ -6720,11 +6844,11 @@
|
|
|
6720
6844
|
writerSizeBeforeEntry = writer.size;
|
|
6721
6845
|
await writeData(fileWriter, localHeaderArray);
|
|
6722
6846
|
}
|
|
6723
|
-
fileEntry = await createFileEntry(reader, fileWriter, fileEntry, entryInfo,
|
|
6847
|
+
fileEntry = await createFileEntry(reader, fileWriter, fileEntry, entryInfo, getConfiguration(), options);
|
|
6724
6848
|
if (!bufferedWrite) {
|
|
6725
6849
|
writingEntryData = false;
|
|
6726
6850
|
}
|
|
6727
|
-
|
|
6851
|
+
fileEntries.set(name, fileEntry);
|
|
6728
6852
|
fileEntry.filename = name;
|
|
6729
6853
|
if (bufferedWrite) {
|
|
6730
6854
|
await Promise.all([fileWriter.writable.getWriter().close(), lockPreviousFileEntry]);
|
|
@@ -6765,7 +6889,7 @@
|
|
|
6765
6889
|
zipWriter.offset += flushedBufferedSize;
|
|
6766
6890
|
}
|
|
6767
6891
|
}
|
|
6768
|
-
|
|
6892
|
+
fileEntries.delete(name);
|
|
6769
6893
|
throw error;
|
|
6770
6894
|
} finally {
|
|
6771
6895
|
if (bufferedWrite) {
|
|
@@ -6787,7 +6911,7 @@
|
|
|
6787
6911
|
}
|
|
6788
6912
|
|
|
6789
6913
|
function requestLockCurrentFileEntry() {
|
|
6790
|
-
fileEntry.
|
|
6914
|
+
fileEntry.lockFileEntry = new Promise(resolve => releaseLockCurrentFileEntry = resolve);
|
|
6791
6915
|
}
|
|
6792
6916
|
|
|
6793
6917
|
async function requestLockWriter() {
|
|
@@ -6807,7 +6931,7 @@
|
|
|
6807
6931
|
}
|
|
6808
6932
|
}
|
|
6809
6933
|
|
|
6810
|
-
async function createFileEntry(reader, writer, { diskNumberStart,
|
|
6934
|
+
async function createFileEntry(reader, writer, { diskNumberStart, lockFileEntry }, entryInfo, config, options) {
|
|
6811
6935
|
const {
|
|
6812
6936
|
headerInfo,
|
|
6813
6937
|
dataDescriptorInfo,
|
|
@@ -6875,7 +6999,7 @@
|
|
|
6875
6999
|
codecURI
|
|
6876
7000
|
} = options;
|
|
6877
7001
|
const fileEntry = {
|
|
6878
|
-
|
|
7002
|
+
lockFileEntry,
|
|
6879
7003
|
versionMadeBy,
|
|
6880
7004
|
zip64,
|
|
6881
7005
|
directory: Boolean(directory),
|
|
@@ -6917,7 +7041,7 @@
|
|
|
6917
7041
|
}
|
|
6918
7042
|
const { writable } = writer;
|
|
6919
7043
|
if (reader) {
|
|
6920
|
-
const readable = toCompatibleReadable(
|
|
7044
|
+
const readable = toCompatibleReadable(createReadable(reader));
|
|
6921
7045
|
const size = reader.size;
|
|
6922
7046
|
const workerOptions = {
|
|
6923
7047
|
options: {
|
|
@@ -7029,14 +7153,14 @@
|
|
|
7029
7153
|
if (zip64 && (zip64UncompressedSize || zip64CompressedSize)) {
|
|
7030
7154
|
const length = 4 + 16;
|
|
7031
7155
|
const extraFieldZip64 = createRecordWriter(length);
|
|
7032
|
-
extraFieldZip64.
|
|
7033
|
-
extraFieldZip64.
|
|
7156
|
+
extraFieldZip64.writeUint16(EXTRAFIELD_TYPE_ZIP64);
|
|
7157
|
+
extraFieldZip64.writeUint16(length - 4);
|
|
7034
7158
|
rawLocalExtraFieldZip64 = extraFieldZip64.array;
|
|
7035
7159
|
if (zip64ExtraFieldComplete) {
|
|
7036
|
-
extraFieldZip64.
|
|
7160
|
+
extraFieldZip64.writeUint64(uncompressedSize);
|
|
7037
7161
|
if (uncompressedFile) {
|
|
7038
7162
|
const encryptionOverhead = encrypted ? (zipCrypto ? 12 : 16 + encryptionStrength * 4) : 0;
|
|
7039
|
-
extraFieldZip64.
|
|
7163
|
+
extraFieldZip64.writeUint64(passThrough ? 0 : uncompressedSize + encryptionOverhead);
|
|
7040
7164
|
}
|
|
7041
7165
|
}
|
|
7042
7166
|
} else {
|
|
@@ -7045,8 +7169,8 @@
|
|
|
7045
7169
|
let rawExtraFieldAES;
|
|
7046
7170
|
if (encrypted && !zipCrypto) {
|
|
7047
7171
|
const extraFieldAES = createRecordWriter(getLength(EXTRAFIELD_DATA_AES) + 2);
|
|
7048
|
-
extraFieldAES.
|
|
7049
|
-
extraFieldAES.
|
|
7172
|
+
extraFieldAES.writeUint16(EXTRAFIELD_TYPE_AES);
|
|
7173
|
+
extraFieldAES.writeBytes(EXTRAFIELD_DATA_AES);
|
|
7050
7174
|
rawExtraFieldAES = extraFieldAES.array;
|
|
7051
7175
|
rawExtraFieldAES[8] = encryptionStrength;
|
|
7052
7176
|
} else {
|
|
@@ -7062,15 +7186,15 @@
|
|
|
7062
7186
|
const extraFieldTimestampLength = 9 + (lastAccessDate ? 4 : 0) + (creationDate ? 4 : 0);
|
|
7063
7187
|
const extraFieldTimestamp = createRecordWriter(extraFieldTimestampLength);
|
|
7064
7188
|
extraFieldExtendedTimestampFlag = 0x1 + (lastAccessDate ? 0x2 : 0) + (creationDate ? 0x4 : 0);
|
|
7065
|
-
extraFieldTimestamp.
|
|
7066
|
-
extraFieldTimestamp.
|
|
7067
|
-
extraFieldTimestamp.
|
|
7068
|
-
extraFieldTimestamp.
|
|
7189
|
+
extraFieldTimestamp.writeUint16(EXTRAFIELD_TYPE_EXTENDED_TIMESTAMP);
|
|
7190
|
+
extraFieldTimestamp.writeUint16(extraFieldTimestampLength - 4);
|
|
7191
|
+
extraFieldTimestamp.writeUint8(extraFieldExtendedTimestampFlag);
|
|
7192
|
+
extraFieldTimestamp.writeUint32(lastModTimeUnix);
|
|
7069
7193
|
if (lastAccessDate) {
|
|
7070
|
-
extraFieldTimestamp.
|
|
7194
|
+
extraFieldTimestamp.writeUint32(clampUnixTime(getTimeUnix(lastAccessDate)));
|
|
7071
7195
|
}
|
|
7072
7196
|
if (creationDate) {
|
|
7073
|
-
extraFieldTimestamp.
|
|
7197
|
+
extraFieldTimestamp.writeUint32(clampUnixTime(getTimeUnix(creationDate)));
|
|
7074
7198
|
}
|
|
7075
7199
|
rawExtraFieldExtendedTimestamp = extraFieldTimestamp.array;
|
|
7076
7200
|
} else {
|
|
@@ -7083,14 +7207,14 @@
|
|
|
7083
7207
|
try {
|
|
7084
7208
|
const lastModTimeNTFS = getTimeNTFS(lastModDate);
|
|
7085
7209
|
const extraFieldNTFS = createRecordWriter(36);
|
|
7086
|
-
extraFieldNTFS.
|
|
7087
|
-
extraFieldNTFS.
|
|
7210
|
+
extraFieldNTFS.writeUint16(EXTRAFIELD_TYPE_NTFS);
|
|
7211
|
+
extraFieldNTFS.writeUint16(32);
|
|
7088
7212
|
extraFieldNTFS.skip(4);
|
|
7089
|
-
extraFieldNTFS.
|
|
7090
|
-
extraFieldNTFS.
|
|
7091
|
-
extraFieldNTFS.
|
|
7092
|
-
extraFieldNTFS.
|
|
7093
|
-
extraFieldNTFS.
|
|
7213
|
+
extraFieldNTFS.writeUint16(EXTRAFIELD_TYPE_NTFS_TAG1);
|
|
7214
|
+
extraFieldNTFS.writeUint16(24);
|
|
7215
|
+
extraFieldNTFS.writeUint64(lastModTimeNTFS);
|
|
7216
|
+
extraFieldNTFS.writeUint64(lastAccessDate ? getTimeNTFS(lastAccessDate) : lastModTimeNTFS);
|
|
7217
|
+
extraFieldNTFS.writeUint64(creationDate ? getTimeNTFS(creationDate) : lastModTimeNTFS);
|
|
7094
7218
|
rawExtraFieldNTFS = extraFieldNTFS.array;
|
|
7095
7219
|
} catch {
|
|
7096
7220
|
rawExtraFieldNTFS = EMPTY_UINT8_ARRAY;
|
|
@@ -7109,20 +7233,20 @@
|
|
|
7109
7233
|
const gidBytes = packUnixId(gid);
|
|
7110
7234
|
const payloadLength = 3 + uidBytes.length + gidBytes.length;
|
|
7111
7235
|
const extraFieldUnix = createRecordWriter(4 + payloadLength);
|
|
7112
|
-
extraFieldUnix.
|
|
7113
|
-
extraFieldUnix.
|
|
7114
|
-
extraFieldUnix.
|
|
7115
|
-
extraFieldUnix.
|
|
7116
|
-
extraFieldUnix.
|
|
7117
|
-
extraFieldUnix.
|
|
7118
|
-
extraFieldUnix.
|
|
7236
|
+
extraFieldUnix.writeUint16(EXTRAFIELD_TYPE_INFOZIP);
|
|
7237
|
+
extraFieldUnix.writeUint16(payloadLength);
|
|
7238
|
+
extraFieldUnix.writeUint8(1);
|
|
7239
|
+
extraFieldUnix.writeUint8(uidBytes.length);
|
|
7240
|
+
extraFieldUnix.writeBytes(uidBytes);
|
|
7241
|
+
extraFieldUnix.writeUint8(gidBytes.length);
|
|
7242
|
+
extraFieldUnix.writeBytes(gidBytes);
|
|
7119
7243
|
rawExtraFieldUnix = extraFieldUnix.array;
|
|
7120
7244
|
} else if (unixExtraFieldType == UNIX_EXTRA_FIELD_TYPE && (uid !== UNDEFINED_VALUE || gid !== UNDEFINED_VALUE)) {
|
|
7121
7245
|
const extraFieldUnix = createRecordWriter(8);
|
|
7122
|
-
extraFieldUnix.
|
|
7123
|
-
extraFieldUnix.
|
|
7124
|
-
extraFieldUnix.
|
|
7125
|
-
extraFieldUnix.
|
|
7246
|
+
extraFieldUnix.writeUint16(EXTRAFIELD_TYPE_UNIX);
|
|
7247
|
+
extraFieldUnix.writeUint16(4);
|
|
7248
|
+
extraFieldUnix.writeUint16((uid === UNDEFINED_VALUE ? 0 : uid) & MAX_16_BITS);
|
|
7249
|
+
extraFieldUnix.writeUint16((gid === UNDEFINED_VALUE ? 0 : gid) & MAX_16_BITS);
|
|
7126
7250
|
rawExtraFieldUnix = extraFieldUnix.array;
|
|
7127
7251
|
} else {
|
|
7128
7252
|
rawExtraFieldUnix = EMPTY_UINT8_ARRAY;
|
|
@@ -7172,18 +7296,18 @@
|
|
|
7172
7296
|
const localHeader = createRecordWriter(HEADER_SIZE + getLength(rawFilename) + extraFieldLength);
|
|
7173
7297
|
const localHeaderArray = localHeader.array;
|
|
7174
7298
|
const localHeaderView = getDataView(localHeaderArray);
|
|
7175
|
-
localHeader.
|
|
7176
|
-
localHeader.
|
|
7177
|
-
localHeader.
|
|
7299
|
+
localHeader.writeUint32(LOCAL_FILE_HEADER_SIGNATURE);
|
|
7300
|
+
localHeader.writeBytes(headerArray);
|
|
7301
|
+
localHeader.writeBytes(rawFilename);
|
|
7178
7302
|
if (writeLocalExtraFieldZip64) {
|
|
7179
|
-
localHeader.
|
|
7180
|
-
}
|
|
7181
|
-
localHeader.
|
|
7182
|
-
localHeader.
|
|
7183
|
-
localHeader.
|
|
7184
|
-
localHeader.
|
|
7185
|
-
localHeader.
|
|
7186
|
-
localHeader.
|
|
7303
|
+
localHeader.writeBytes(rawLocalExtraFieldZip64);
|
|
7304
|
+
}
|
|
7305
|
+
localHeader.writeBytes(rawExtraFieldAES);
|
|
7306
|
+
localHeader.writeBytes(rawExtraFieldExtendedTimestamp);
|
|
7307
|
+
localHeader.writeBytes(rawExtraFieldNTFS);
|
|
7308
|
+
localHeader.writeBytes(rawExtraFieldUnix);
|
|
7309
|
+
localHeader.writeBytes(rawExtraField);
|
|
7310
|
+
localHeader.writeBytes(rawLocalExtraField);
|
|
7187
7311
|
if (dataDescriptor) {
|
|
7188
7312
|
if (!zip64CompressedSize) {
|
|
7189
7313
|
setUint32(localHeaderView, HEADER_OFFSET_COMPRESSED_SIZE + LOCAL_HEADER_COMMON_OFFSET, 0);
|
|
@@ -7373,7 +7497,7 @@
|
|
|
7373
7497
|
|
|
7374
7498
|
|
|
7375
7499
|
async function closeFile(zipWriter, comment, options) {
|
|
7376
|
-
const directoryDataLength = createDirectoryRecords(zipWriter.
|
|
7500
|
+
const directoryDataLength = createDirectoryRecords(zipWriter.fileEntries);
|
|
7377
7501
|
const { directoryStart, directoryArray } = await writeDirectoryRecords(zipWriter, directoryDataLength, options);
|
|
7378
7502
|
const signatureLength = await writeDigitalSignatureRecord(zipWriter, directoryArray, options);
|
|
7379
7503
|
await writeEndOfDirectoryRecord(zipWriter, comment, options, { directoryStart, directoryDataLength, signatureLength });
|
|
@@ -7403,19 +7527,19 @@
|
|
|
7403
7527
|
if (zip64Offset || zip64DiskNumberStart || zip64UncompressedSize || zip64CompressedSize) {
|
|
7404
7528
|
const length = 4 + (zip64UncompressedSize ? 8 : 0) + (zip64CompressedSize ? 8 : 0) + (zip64Offset ? 8 : 0) + (zip64DiskNumberStart ? 4 : 0);
|
|
7405
7529
|
const extraFieldZip64 = createRecordWriter(length);
|
|
7406
|
-
extraFieldZip64.
|
|
7407
|
-
extraFieldZip64.
|
|
7530
|
+
extraFieldZip64.writeUint16(EXTRAFIELD_TYPE_ZIP64);
|
|
7531
|
+
extraFieldZip64.writeUint16(length - 4);
|
|
7408
7532
|
if (zip64UncompressedSize) {
|
|
7409
|
-
extraFieldZip64.
|
|
7533
|
+
extraFieldZip64.writeUint64(uncompressedSize);
|
|
7410
7534
|
}
|
|
7411
7535
|
if (zip64CompressedSize) {
|
|
7412
|
-
extraFieldZip64.
|
|
7536
|
+
extraFieldZip64.writeUint64(compressedSize);
|
|
7413
7537
|
}
|
|
7414
7538
|
if (zip64Offset) {
|
|
7415
|
-
extraFieldZip64.
|
|
7539
|
+
extraFieldZip64.writeUint64(fileEntry.offset);
|
|
7416
7540
|
}
|
|
7417
7541
|
if (zip64DiskNumberStart) {
|
|
7418
|
-
extraFieldZip64.
|
|
7542
|
+
extraFieldZip64.writeUint32(fileEntry.diskNumberStart);
|
|
7419
7543
|
}
|
|
7420
7544
|
rawExtraFieldZip64 = extraFieldZip64.array;
|
|
7421
7545
|
} else {
|
|
@@ -7428,10 +7552,10 @@
|
|
|
7428
7552
|
const lastModTimeUnix = getTimeUnix(lastModDate);
|
|
7429
7553
|
if (extendedTimestamp && inUnixTimeRange(lastModTimeUnix)) {
|
|
7430
7554
|
const extraFieldTimestamp = createRecordWriter(9);
|
|
7431
|
-
extraFieldTimestamp.
|
|
7432
|
-
extraFieldTimestamp.
|
|
7433
|
-
extraFieldTimestamp.
|
|
7434
|
-
extraFieldTimestamp.
|
|
7555
|
+
extraFieldTimestamp.writeUint16(EXTRAFIELD_TYPE_EXTENDED_TIMESTAMP);
|
|
7556
|
+
extraFieldTimestamp.writeUint16(5);
|
|
7557
|
+
extraFieldTimestamp.writeUint8(extraFieldExtendedTimestampFlag);
|
|
7558
|
+
extraFieldTimestamp.writeUint32(lastModTimeUnix);
|
|
7435
7559
|
rawExtraFieldTimestamp = extraFieldTimestamp.array;
|
|
7436
7560
|
} else {
|
|
7437
7561
|
rawExtraFieldTimestamp = EMPTY_UINT8_ARRAY;
|
|
@@ -7453,14 +7577,14 @@
|
|
|
7453
7577
|
}
|
|
7454
7578
|
|
|
7455
7579
|
async function writeDirectoryRecords(zipWriter, directoryDataLength, options) {
|
|
7456
|
-
const {
|
|
7580
|
+
const { fileEntries, writer } = zipWriter;
|
|
7457
7581
|
const directoryArray = new Uint8Array(directoryDataLength);
|
|
7458
7582
|
await initStream(writer);
|
|
7459
7583
|
let offset = 0;
|
|
7460
7584
|
let directoryDiskOffset = 0;
|
|
7461
7585
|
let directoryStartDiskNumber = getDiskNumber(writer);
|
|
7462
7586
|
let directoryStartDiskOffset = getDiskOffset(writer);
|
|
7463
|
-
for (const [indexFileEntry, fileEntry] of Array.from(
|
|
7587
|
+
for (const [indexFileEntry, fileEntry] of Array.from(fileEntries.values()).entries()) {
|
|
7464
7588
|
const {
|
|
7465
7589
|
offset: fileEntryOffset,
|
|
7466
7590
|
rawFilename,
|
|
@@ -7505,28 +7629,28 @@
|
|
|
7505
7629
|
setUint16(headerView, HEADER_OFFSET_VERSION, VERSION_ZIP64);
|
|
7506
7630
|
}
|
|
7507
7631
|
const directoryRecord = createRecordWriter(directoryRecordLength);
|
|
7508
|
-
directoryRecord.
|
|
7509
|
-
directoryRecord.
|
|
7510
|
-
directoryRecord.
|
|
7511
|
-
directoryRecord.
|
|
7512
|
-
directoryRecord.
|
|
7513
|
-
directoryRecord.
|
|
7514
|
-
directoryRecord.
|
|
7515
|
-
directoryRecord.
|
|
7516
|
-
directoryRecord.
|
|
7517
|
-
directoryRecord.
|
|
7518
|
-
directoryRecord.
|
|
7519
|
-
directoryRecord.
|
|
7520
|
-
directoryRecord.
|
|
7521
|
-
directoryRecord.
|
|
7522
|
-
directoryRecord.
|
|
7523
|
-
directoryRecord.
|
|
7524
|
-
directoryRecord.
|
|
7632
|
+
directoryRecord.writeUint32(CENTRAL_FILE_HEADER_SIGNATURE);
|
|
7633
|
+
directoryRecord.writeUint16(versionMadeBy);
|
|
7634
|
+
directoryRecord.writeBytes(headerArray.subarray(0, HEADER_SIZE - 4 - 2));
|
|
7635
|
+
directoryRecord.writeUint16(extraFieldLength);
|
|
7636
|
+
directoryRecord.writeUint16(getLength(rawComment));
|
|
7637
|
+
directoryRecord.writeUint16(zip64DiskNumberStart ? MAX_16_BITS : diskNumberStart);
|
|
7638
|
+
directoryRecord.writeUint16(internalFileAttributes);
|
|
7639
|
+
directoryRecord.writeUint32(externalFileAttributes);
|
|
7640
|
+
directoryRecord.writeUint32(zip64Offset ? MAX_32_BITS : fileEntryOffset);
|
|
7641
|
+
directoryRecord.writeBytes(rawFilename);
|
|
7642
|
+
directoryRecord.writeBytes(rawExtraFieldZip64);
|
|
7643
|
+
directoryRecord.writeBytes(rawExtraFieldAES);
|
|
7644
|
+
directoryRecord.writeBytes(rawExtraFieldExtendedTimestamp);
|
|
7645
|
+
directoryRecord.writeBytes(rawExtraFieldNTFS);
|
|
7646
|
+
directoryRecord.writeBytes(rawExtraFieldUnix);
|
|
7647
|
+
directoryRecord.writeBytes(rawExtraField);
|
|
7648
|
+
directoryRecord.writeBytes(rawComment);
|
|
7525
7649
|
arraySet(directoryArray, directoryRecord.array, offset);
|
|
7526
7650
|
offset += directoryRecordLength;
|
|
7527
7651
|
if (options.onprogress) {
|
|
7528
7652
|
try {
|
|
7529
|
-
await options.onprogress(indexFileEntry + 1,
|
|
7653
|
+
await options.onprogress(indexFileEntry + 1, fileEntries.size, new Entry(fileEntry));
|
|
7530
7654
|
} catch {
|
|
7531
7655
|
// ignored
|
|
7532
7656
|
}
|
|
@@ -7540,7 +7664,7 @@
|
|
|
7540
7664
|
}
|
|
7541
7665
|
|
|
7542
7666
|
async function writeDigitalSignatureRecord(zipWriter, directoryArray, options) {
|
|
7543
|
-
const signCentralDirectory =
|
|
7667
|
+
const signCentralDirectory = getFunctionOptionValue(zipWriter, options, OPTION_SIGN_CENTRAL_DIRECTORY);
|
|
7544
7668
|
if (signCentralDirectory) {
|
|
7545
7669
|
const signatureData = await signCentralDirectory(directoryArray);
|
|
7546
7670
|
const signatureDataLength = getLength(signatureData);
|
|
@@ -7548,9 +7672,9 @@
|
|
|
7548
7672
|
throw new Error(ERR_INVALID_SIGNATURE_DATA);
|
|
7549
7673
|
}
|
|
7550
7674
|
const signatureRecord = createRecordWriter(6 + signatureDataLength);
|
|
7551
|
-
signatureRecord.
|
|
7552
|
-
signatureRecord.
|
|
7553
|
-
signatureRecord.
|
|
7675
|
+
signatureRecord.writeUint32(DIGITAL_SIGNATURE_RECORD_SIGNATURE);
|
|
7676
|
+
signatureRecord.writeUint16(signatureDataLength);
|
|
7677
|
+
signatureRecord.writeBytes(signatureData);
|
|
7554
7678
|
await writeData(zipWriter.writer, signatureRecord.array);
|
|
7555
7679
|
return 6 + signatureDataLength;
|
|
7556
7680
|
}
|
|
@@ -7561,7 +7685,7 @@
|
|
|
7561
7685
|
const { writer } = zipWriter;
|
|
7562
7686
|
const { directoryStart, signatureLength } = cdInfo;
|
|
7563
7687
|
let { directoryDataLength } = cdInfo;
|
|
7564
|
-
let
|
|
7688
|
+
let fileEntriesLength = zipWriter.fileEntries.size;
|
|
7565
7689
|
let diskNumber = directoryStart.diskNumber;
|
|
7566
7690
|
let directoryOffset = getSegmentOffset(zipWriter, directoryStart);
|
|
7567
7691
|
let lastDiskNumber = getDiskNumber(writer);
|
|
@@ -7569,7 +7693,7 @@
|
|
|
7569
7693
|
lastDiskNumber++;
|
|
7570
7694
|
}
|
|
7571
7695
|
let zip64 = getOptionValue(zipWriter, options, PROPERTY_NAME_ZIP64);
|
|
7572
|
-
if (directoryOffset >= MAX_32_BITS || directoryDataLength >= MAX_32_BITS ||
|
|
7696
|
+
if (directoryOffset >= MAX_32_BITS || directoryDataLength >= MAX_32_BITS || fileEntriesLength >= MAX_16_BITS || lastDiskNumber >= MAX_16_BITS) {
|
|
7573
7697
|
if (zip64 === false) {
|
|
7574
7698
|
throw new Error(ERR_UNSUPPORTED_FORMAT);
|
|
7575
7699
|
} else {
|
|
@@ -7586,37 +7710,37 @@
|
|
|
7586
7710
|
}
|
|
7587
7711
|
lastDiskNumber = getDiskNumber(writer);
|
|
7588
7712
|
if (zip64) {
|
|
7589
|
-
endOfdirectoryRecord.
|
|
7590
|
-
endOfdirectoryRecord.
|
|
7591
|
-
endOfdirectoryRecord.
|
|
7592
|
-
endOfdirectoryRecord.
|
|
7593
|
-
endOfdirectoryRecord.
|
|
7594
|
-
endOfdirectoryRecord.
|
|
7595
|
-
endOfdirectoryRecord.
|
|
7596
|
-
endOfdirectoryRecord.
|
|
7597
|
-
endOfdirectoryRecord.
|
|
7598
|
-
endOfdirectoryRecord.
|
|
7599
|
-
endOfdirectoryRecord.
|
|
7600
|
-
endOfdirectoryRecord.
|
|
7601
|
-
endOfdirectoryRecord.
|
|
7602
|
-
endOfdirectoryRecord.
|
|
7713
|
+
endOfdirectoryRecord.writeUint32(ZIP64_END_OF_CENTRAL_DIR_SIGNATURE);
|
|
7714
|
+
endOfdirectoryRecord.writeUint64(44);
|
|
7715
|
+
endOfdirectoryRecord.writeUint16(45);
|
|
7716
|
+
endOfdirectoryRecord.writeUint16(45);
|
|
7717
|
+
endOfdirectoryRecord.writeUint32(lastDiskNumber);
|
|
7718
|
+
endOfdirectoryRecord.writeUint32(diskNumber);
|
|
7719
|
+
endOfdirectoryRecord.writeUint64(fileEntriesLength);
|
|
7720
|
+
endOfdirectoryRecord.writeUint64(fileEntriesLength);
|
|
7721
|
+
endOfdirectoryRecord.writeUint64(directoryDataLength);
|
|
7722
|
+
endOfdirectoryRecord.writeUint64(directoryOffset);
|
|
7723
|
+
endOfdirectoryRecord.writeUint32(ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIGNATURE);
|
|
7724
|
+
endOfdirectoryRecord.writeUint32(lastDiskNumber);
|
|
7725
|
+
endOfdirectoryRecord.writeUint64(BigInt(getSegmentOffset(zipWriter, writer)) + BigInt(directoryDataLength) + BigInt(signatureLength));
|
|
7726
|
+
endOfdirectoryRecord.writeUint32(lastDiskNumber + 1);
|
|
7603
7727
|
const supportZip64SplitFile = getOptionValue(zipWriter, options, OPTION_SUPPORT_ZIP64_SPLIT_FILE, true);
|
|
7604
7728
|
if (supportZip64SplitFile) {
|
|
7605
7729
|
lastDiskNumber = MAX_16_BITS;
|
|
7606
7730
|
diskNumber = MAX_16_BITS;
|
|
7607
7731
|
}
|
|
7608
|
-
|
|
7732
|
+
fileEntriesLength = MAX_16_BITS;
|
|
7609
7733
|
directoryOffset = MAX_32_BITS;
|
|
7610
7734
|
directoryDataLength = MAX_32_BITS;
|
|
7611
7735
|
}
|
|
7612
|
-
endOfdirectoryRecord.
|
|
7613
|
-
endOfdirectoryRecord.
|
|
7614
|
-
endOfdirectoryRecord.
|
|
7615
|
-
endOfdirectoryRecord.
|
|
7616
|
-
endOfdirectoryRecord.
|
|
7617
|
-
endOfdirectoryRecord.
|
|
7618
|
-
endOfdirectoryRecord.
|
|
7619
|
-
endOfdirectoryRecord.
|
|
7736
|
+
endOfdirectoryRecord.writeUint32(END_OF_CENTRAL_DIR_SIGNATURE);
|
|
7737
|
+
endOfdirectoryRecord.writeUint16(lastDiskNumber);
|
|
7738
|
+
endOfdirectoryRecord.writeUint16(diskNumber);
|
|
7739
|
+
endOfdirectoryRecord.writeUint16(fileEntriesLength);
|
|
7740
|
+
endOfdirectoryRecord.writeUint16(fileEntriesLength);
|
|
7741
|
+
endOfdirectoryRecord.writeUint32(directoryDataLength);
|
|
7742
|
+
endOfdirectoryRecord.writeUint32(directoryOffset);
|
|
7743
|
+
endOfdirectoryRecord.writeUint16(commentLength);
|
|
7620
7744
|
await writeData(writer, endOfdirectoryRecord.array);
|
|
7621
7745
|
if (commentLength) {
|
|
7622
7746
|
await writeData(writer, comment);
|
|
@@ -7629,11 +7753,11 @@
|
|
|
7629
7753
|
let offset = 0;
|
|
7630
7754
|
return {
|
|
7631
7755
|
array,
|
|
7632
|
-
|
|
7633
|
-
|
|
7634
|
-
|
|
7635
|
-
|
|
7636
|
-
|
|
7756
|
+
writeUint8: value => { setUint8(view, offset, value); offset += 1; },
|
|
7757
|
+
writeUint16: value => { setUint16(view, offset, value); offset += 2; },
|
|
7758
|
+
writeUint32: value => { setUint32(view, offset, value); offset += 4; },
|
|
7759
|
+
writeUint64: value => { setBigUint64(view, offset, BigInt(value)); offset += 8; },
|
|
7760
|
+
writeBytes: value => { arraySet(array, value, offset); offset += getLength(value); },
|
|
7637
7761
|
skip: count => offset += count
|
|
7638
7762
|
};
|
|
7639
7763
|
}
|
|
@@ -7657,6 +7781,71 @@
|
|
|
7657
7781
|
return zipWriter.offset - diskOffset - (diskNumber ? zipWriter.initialOffset : 0);
|
|
7658
7782
|
}
|
|
7659
7783
|
|
|
7784
|
+
async function startsWithSplitZipSignature(reader) {
|
|
7785
|
+
const signatureArray = await readUint8Array(reader, 0, SPLIT_ZIP_FILE_SIGNATURE_LENGTH);
|
|
7786
|
+
return getUint32(getDataView(signatureArray), 0) == SPLIT_ZIP_FILE_SIGNATURE;
|
|
7787
|
+
}
|
|
7788
|
+
|
|
7789
|
+
async function copyZipData(zipWriter, reader, entries, directoryOffset, splitZipSignatureLength) {
|
|
7790
|
+
const { writer } = zipWriter;
|
|
7791
|
+
const entryPositions = new Map();
|
|
7792
|
+
if (writer.closeDisk) {
|
|
7793
|
+
const sortedEntries = Array.from(entries).sort((firstEntry, secondEntry) =>
|
|
7794
|
+
getSourceOffset(reader, firstEntry) - getSourceOffset(reader, secondEntry));
|
|
7795
|
+
let copiedLength = 0;
|
|
7796
|
+
for (const entry of sortedEntries) {
|
|
7797
|
+
const sourceOffset = getSourceOffset(reader, entry);
|
|
7798
|
+
await copyData(zipWriter, reader, copiedLength, sourceOffset - copiedLength);
|
|
7799
|
+
if (exceedsAvailableSize(writer, await getLocalHeaderLength(reader, sourceOffset))) {
|
|
7800
|
+
await writer.closeDisk();
|
|
7801
|
+
}
|
|
7802
|
+
entryPositions.set(entry, {
|
|
7803
|
+
offset: getSegmentOffset(zipWriter, writer),
|
|
7804
|
+
diskNumberStart: getDiskNumber(writer)
|
|
7805
|
+
});
|
|
7806
|
+
copiedLength = sourceOffset;
|
|
7807
|
+
}
|
|
7808
|
+
await copyData(zipWriter, reader, copiedLength, directoryOffset - copiedLength);
|
|
7809
|
+
} else {
|
|
7810
|
+
await copyData(zipWriter, reader, 0, directoryOffset);
|
|
7811
|
+
entries.forEach(entry => entryPositions.set(entry, {
|
|
7812
|
+
offset: splitZipSignatureLength + getSourceOffset(reader, entry),
|
|
7813
|
+
diskNumberStart: 0
|
|
7814
|
+
}));
|
|
7815
|
+
}
|
|
7816
|
+
return entryPositions;
|
|
7817
|
+
}
|
|
7818
|
+
|
|
7819
|
+
async function copyData(zipWriter, reader, offset, size) {
|
|
7820
|
+
if (size > 0) {
|
|
7821
|
+
const { writer } = zipWriter;
|
|
7822
|
+
await createReadable(reader, { offset, size }).pipeTo(writer.writable, { preventClose: true, preventAbort: true });
|
|
7823
|
+
writer.size += size;
|
|
7824
|
+
zipWriter.offset += size;
|
|
7825
|
+
}
|
|
7826
|
+
}
|
|
7827
|
+
|
|
7828
|
+
async function getLocalHeaderLength(reader, offset) {
|
|
7829
|
+
const headerArray = await readUint8Array(reader, offset, HEADER_SIZE);
|
|
7830
|
+
if (getLength(headerArray) < HEADER_SIZE) {
|
|
7831
|
+
return HEADER_SIZE;
|
|
7832
|
+
}
|
|
7833
|
+
const headerView = getDataView(headerArray);
|
|
7834
|
+
return HEADER_SIZE +
|
|
7835
|
+
getUint16(headerView, HEADER_OFFSET_FILENAME_LENGTH + LOCAL_HEADER_COMMON_OFFSET) +
|
|
7836
|
+
getUint16(headerView, HEADER_OFFSET_EXTRAFIELD_LENGTH + LOCAL_HEADER_COMMON_OFFSET);
|
|
7837
|
+
}
|
|
7838
|
+
|
|
7839
|
+
function getSourceOffset(reader, { offset, diskNumberStart }) {
|
|
7840
|
+
return offset + (reader.getDiskOffset ? reader.getDiskOffset(diskNumberStart) : 0);
|
|
7841
|
+
}
|
|
7842
|
+
|
|
7843
|
+
function getSplitZipSignatureArray() {
|
|
7844
|
+
const signatureArray = new Uint8Array(SPLIT_ZIP_FILE_SIGNATURE_LENGTH);
|
|
7845
|
+
setUint32(getDataView(signatureArray), 0, SPLIT_ZIP_FILE_SIGNATURE);
|
|
7846
|
+
return signatureArray;
|
|
7847
|
+
}
|
|
7848
|
+
|
|
7660
7849
|
async function writeData(writer, array) {
|
|
7661
7850
|
const { writable } = writer;
|
|
7662
7851
|
const streamWriter = writable.getWriter();
|
|
@@ -7708,6 +7897,21 @@
|
|
|
7708
7897
|
return result === UNDEFINED_VALUE ? defaultValue : result;
|
|
7709
7898
|
}
|
|
7710
7899
|
|
|
7900
|
+
function getDateOptionValue(zipWriter, options, name, defaultValue) {
|
|
7901
|
+
const date = getOptionValue(zipWriter, options, name, defaultValue);
|
|
7902
|
+
if (date === null) {
|
|
7903
|
+
return defaultValue;
|
|
7904
|
+
}
|
|
7905
|
+
if (date !== UNDEFINED_VALUE && (typeof date.getTime != FUNCTION_TYPE || Number.isNaN(date.getTime()))) {
|
|
7906
|
+
throw new Error(ERR_INVALID_DATE);
|
|
7907
|
+
}
|
|
7908
|
+
return date;
|
|
7909
|
+
}
|
|
7910
|
+
|
|
7911
|
+
function getFunctionOptionValue(zipWriter, options, name) {
|
|
7912
|
+
return checkFunctionOption(getOptionValue(zipWriter, options, name));
|
|
7913
|
+
}
|
|
7914
|
+
|
|
7711
7915
|
function getAliasedOptionValue(zipWriter, options, name, deprecatedName, defaultValue) {
|
|
7712
7916
|
const value = getAliasedValue(options, name, deprecatedName);
|
|
7713
7917
|
const result = value === UNDEFINED_VALUE ? getAliasedValue(zipWriter.options, name, deprecatedName) : value;
|
|
@@ -7722,9 +7926,6 @@
|
|
|
7722
7926
|
return toNumber(getOptionValue(zipWriter, options, name, defaultValue));
|
|
7723
7927
|
}
|
|
7724
7928
|
|
|
7725
|
-
function toNumber(value) {
|
|
7726
|
-
return typeof value == STRING_TYPE && value.trim() ? Number(value) : value;
|
|
7727
|
-
}
|
|
7728
7929
|
|
|
7729
7930
|
function getMaximumCompressedSize(uncompressedSize) {
|
|
7730
7931
|
return uncompressedSize + (5 * (Math.floor(uncompressedSize / 16383) + 1));
|
|
@@ -7736,6 +7937,14 @@
|
|
|
7736
7937
|
: compressionMethod !== COMPRESSION_METHOD_STORE;
|
|
7737
7938
|
}
|
|
7738
7939
|
|
|
7940
|
+
function getUint16(view, offset) {
|
|
7941
|
+
return view.getUint16(offset, true);
|
|
7942
|
+
}
|
|
7943
|
+
|
|
7944
|
+
function getUint32(view, offset) {
|
|
7945
|
+
return view.getUint32(offset, true);
|
|
7946
|
+
}
|
|
7947
|
+
|
|
7739
7948
|
function setUint8(view, offset, value) {
|
|
7740
7949
|
view.setUint8(offset, value);
|
|
7741
7950
|
}
|
|
@@ -7779,9 +7988,9 @@
|
|
|
7779
7988
|
const headerRecord = createRecordWriter(HEADER_SIZE - 4);
|
|
7780
7989
|
const headerArray = headerRecord.array;
|
|
7781
7990
|
const headerView = getDataView(headerArray);
|
|
7782
|
-
headerRecord.
|
|
7783
|
-
headerRecord.
|
|
7784
|
-
headerRecord.
|
|
7991
|
+
headerRecord.writeUint16(version);
|
|
7992
|
+
headerRecord.writeUint16(bitFlag);
|
|
7993
|
+
headerRecord.writeUint16(compressionMethod);
|
|
7785
7994
|
if (rawLastModDate === UNDEFINED_VALUE) {
|
|
7786
7995
|
const dateArray = new Uint32Array(1);
|
|
7787
7996
|
const dateView = getDataView(dateArray);
|
|
@@ -7789,20 +7998,20 @@
|
|
|
7789
7998
|
setUint16(dateView, 2, ((((lastModDate.getFullYear() - 1980) << 4) | (lastModDate.getMonth() + 1)) << 5) | lastModDate.getDate());
|
|
7790
7999
|
rawLastModDate = dateArray[0];
|
|
7791
8000
|
}
|
|
7792
|
-
headerRecord.
|
|
8001
|
+
headerRecord.writeUint32(rawLastModDate);
|
|
7793
8002
|
headerRecord.skip(4);
|
|
7794
8003
|
if (zip64CompressedSize || compressedSize !== UNDEFINED_VALUE) {
|
|
7795
|
-
headerRecord.
|
|
8004
|
+
headerRecord.writeUint32(zip64CompressedSize ? MAX_32_BITS : compressedSize);
|
|
7796
8005
|
} else {
|
|
7797
8006
|
headerRecord.skip(4);
|
|
7798
8007
|
}
|
|
7799
8008
|
if (zip64UncompressedSize || uncompressedSize !== UNDEFINED_VALUE) {
|
|
7800
|
-
headerRecord.
|
|
8009
|
+
headerRecord.writeUint32(zip64UncompressedSize ? MAX_32_BITS : uncompressedSize);
|
|
7801
8010
|
} else {
|
|
7802
8011
|
headerRecord.skip(4);
|
|
7803
8012
|
}
|
|
7804
|
-
headerRecord.
|
|
7805
|
-
headerRecord.
|
|
8013
|
+
headerRecord.writeUint16(getLength(rawFilename));
|
|
8014
|
+
headerRecord.writeUint16(extraFieldLength);
|
|
7806
8015
|
return {
|
|
7807
8016
|
headerArray,
|
|
7808
8017
|
headerView,
|
|
@@ -8759,6 +8968,7 @@
|
|
|
8759
8968
|
exports.ERR_DUPLICATED_NAME = ERR_DUPLICATED_NAME;
|
|
8760
8969
|
exports.ERR_ENCRYPTED = ERR_ENCRYPTED;
|
|
8761
8970
|
exports.ERR_ENCRYPTED_CENTRAL_DIRECTORY = ERR_ENCRYPTED_CENTRAL_DIRECTORY;
|
|
8971
|
+
exports.ERR_ENTRY_DATA_OUT_OF_BOUNDS = ERR_ENTRY_DATA_OUT_OF_BOUNDS;
|
|
8762
8972
|
exports.ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND = ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND;
|
|
8763
8973
|
exports.ERR_EOCDR_NOT_FOUND = ERR_EOCDR_NOT_FOUND;
|
|
8764
8974
|
exports.ERR_EXTRAFIELD_ZIP64_NOT_FOUND = ERR_EXTRAFIELD_ZIP64_NOT_FOUND;
|
|
@@ -8771,19 +8981,26 @@
|
|
|
8771
8981
|
exports.ERR_INVALID_COMMENT_TYPE = ERR_INVALID_COMMENT_TYPE;
|
|
8772
8982
|
exports.ERR_INVALID_COMPRESSED_DATA = ERR_INVALID_COMPRESSED_DATA;
|
|
8773
8983
|
exports.ERR_INVALID_CRC32 = ERR_INVALID_CRC32;
|
|
8984
|
+
exports.ERR_INVALID_DATE = ERR_INVALID_DATE;
|
|
8774
8985
|
exports.ERR_INVALID_ENCRYPTION_STRENGTH = ERR_INVALID_ENCRYPTION_STRENGTH;
|
|
8775
8986
|
exports.ERR_INVALID_ENTRY_COMMENT = ERR_INVALID_ENTRY_COMMENT;
|
|
8987
|
+
exports.ERR_INVALID_ENTRY_COMMENT_TYPE = ERR_INVALID_ENTRY_COMMENT_TYPE;
|
|
8776
8988
|
exports.ERR_INVALID_ENTRY_NAME = ERR_INVALID_ENTRY_NAME;
|
|
8989
|
+
exports.ERR_INVALID_EXTRAFIELD = ERR_INVALID_EXTRAFIELD;
|
|
8777
8990
|
exports.ERR_INVALID_EXTRAFIELD_DATA = ERR_INVALID_EXTRAFIELD_DATA;
|
|
8991
|
+
exports.ERR_INVALID_EXTRAFIELD_DATA_TYPE = ERR_INVALID_EXTRAFIELD_DATA_TYPE;
|
|
8778
8992
|
exports.ERR_INVALID_EXTRAFIELD_TYPE = ERR_INVALID_EXTRAFIELD_TYPE;
|
|
8779
8993
|
exports.ERR_INVALID_FILENAME_VALIDATION = ERR_INVALID_FILENAME_VALIDATION;
|
|
8994
|
+
exports.ERR_INVALID_FUNCTION_OPTION = ERR_INVALID_FUNCTION_OPTION;
|
|
8780
8995
|
exports.ERR_INVALID_GID = ERR_INVALID_GID;
|
|
8781
8996
|
exports.ERR_INVALID_LEVEL = ERR_INVALID_LEVEL;
|
|
8782
8997
|
exports.ERR_INVALID_MAX_APPENDED_DATA_SIZE = ERR_INVALID_MAX_APPENDED_DATA_SIZE;
|
|
8998
|
+
exports.ERR_INVALID_MAX_WORKERS = ERR_INVALID_MAX_WORKERS;
|
|
8783
8999
|
exports.ERR_INVALID_MSDOS_ATTRIBUTES = ERR_INVALID_MSDOS_ATTRIBUTES;
|
|
8784
9000
|
exports.ERR_INVALID_MSDOS_DATA = ERR_INVALID_MSDOS_DATA;
|
|
8785
9001
|
exports.ERR_INVALID_PASSWORD = ERR_INVALID_PASSWORD;
|
|
8786
9002
|
exports.ERR_INVALID_PASSWORD_TYPE = ERR_INVALID_PASSWORD_TYPE;
|
|
9003
|
+
exports.ERR_INVALID_SIGNAL = ERR_INVALID_SIGNAL;
|
|
8787
9004
|
exports.ERR_INVALID_SIGNATURE = ERR_INVALID_SIGNATURE;
|
|
8788
9005
|
exports.ERR_INVALID_SIGNATURE_DATA = ERR_INVALID_SIGNATURE_DATA;
|
|
8789
9006
|
exports.ERR_INVALID_STRICTNESS = ERR_INVALID_STRICTNESS;
|