@zip.js/zip.js 2.11.3 → 2.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/deno.json +1 -1
- package/dist/zip-core-external.js +444 -114
- package/dist/zip-core-external.min.js +1 -1
- package/dist/zip-core.js +454 -111
- package/dist/zip-core.min.js +1 -1
- package/dist/zip-fs-core-external.js +509 -236
- package/dist/zip-fs-core-external.min.js +1 -1
- package/dist/zip-fs-core.js +522 -233
- package/dist/zip-fs-core.min.js +1 -1
- package/dist/zip-fs-external.js +509 -236
- package/dist/zip-fs-external.min.js +1 -1
- package/dist/zip-fs-native.js +524 -235
- package/dist/zip-fs-native.min.js +1 -1
- package/dist/zip-fs.js +525 -236
- package/dist/zip-fs.min.js +1 -1
- package/dist/zip-legacy.js +456 -113
- package/dist/zip-legacy.min.js +1 -1
- package/dist/zip-native.js +456 -113
- 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 +457 -114
- package/dist/zip.min.js +1 -1
- package/index-native.cjs +524 -235
- package/index-native.min.js +1 -1
- package/index.cjs +525 -236
- package/index.d.cts +480 -59
- package/index.d.ts +480 -59
- package/index.min.js +1 -1
- package/lib/core/codec-worker-web.js +10 -2
- package/lib/core/codec-worker.js +4 -3
- package/lib/core/configuration.js +20 -5
- package/lib/core/constants.js +2 -0
- package/lib/core/io.js +20 -10
- package/lib/core/options.js +29 -0
- package/lib/core/streams/codec-stream.js +6 -0
- package/lib/core/util/warnings.js +42 -0
- package/lib/core/version.js +1 -1
- package/lib/core/web-worker-base.js +4 -3
- package/lib/core/web-worker-inline-native.js +1 -1
- package/lib/core/web-worker-inline-wasm.js +1 -1
- package/lib/core/zip-entry.js +49 -1
- package/lib/core/zip-fs.js +43 -134
- package/lib/core/zip-reader.js +108 -47
- package/lib/core/zip-writer.js +238 -54
- package/lib/zip-core-base.js +9 -3
- package/lib/zip-core-reader.js +2 -0
- package/lib/zip-core-writer.js +6 -1
- package/lib/zip-module-wasm-base.js +2 -2
- package/package.json +5 -3
package/dist/zip.js
CHANGED
|
@@ -134,6 +134,7 @@
|
|
|
134
134
|
const BOOLEAN_TYPE = "boolean";
|
|
135
135
|
|
|
136
136
|
const EMPTY_UINT8_ARRAY = new Uint8Array();
|
|
137
|
+
const SYMBOL_ASYNC_DISPOSE = Symbol.asyncDispose || Symbol();
|
|
137
138
|
|
|
138
139
|
/*
|
|
139
140
|
Copyright (c) 2022 Gildas Lormeau. All rights reserved.
|
|
@@ -178,6 +179,7 @@
|
|
|
178
179
|
const OPTION_CHECK_OVERLAPPING_ENTRY = "checkOverlappingEntry";
|
|
179
180
|
const OPTION_CHECK_AMBIGUITY = "checkAmbiguity";
|
|
180
181
|
const OPTION_CHECK_LOCAL_DIRECTORY = "checkLocalDirectory";
|
|
182
|
+
const OPTION_CHECK_LOCAL_FILENAME = "checkLocalFilename";
|
|
181
183
|
const OPTION_CHECK_SIGNATURE = "checkSignature";
|
|
182
184
|
const OPTION_CHECK_CRC32 = "checkCrc32";
|
|
183
185
|
const OPTION_CHECK_AUTHENTICATION_CODE = "checkAuthenticationCode";
|
|
@@ -208,15 +210,20 @@
|
|
|
208
210
|
const OPTION_MAX_APPENDED_DATA_SIZE = "maxAppendedDataSize";
|
|
209
211
|
const OPTION_DECRYPT_CENTRAL_DIRECTORY = "decryptCentralDirectory";
|
|
210
212
|
const OPTION_SIGN_CENTRAL_DIRECTORY = "signCentralDirectory";
|
|
213
|
+
const OPTION_ENTRY = "entry";
|
|
211
214
|
const TEXT_TYPE_FILENAME = "filename";
|
|
212
215
|
const TEXT_TYPE_COMMENT = "comment";
|
|
213
216
|
const STRICTNESS_STRICT = "strict";
|
|
214
217
|
const STRICTNESS_BALANCED = "balanced";
|
|
215
218
|
const STRICTNESS_TOLERANT = "tolerant";
|
|
219
|
+
const PASS_THROUGH_COMPRESSED = "compressed";
|
|
216
220
|
|
|
217
221
|
const ERR_INVALID_FUNCTION_OPTION = "Invalid option (must be a function)";
|
|
218
222
|
const ERR_INVALID_SIGNAL = "Invalid signal (must be an AbortSignal instance)";
|
|
219
223
|
const ERR_INVALID_PASSWORD_TYPE = "Invalid password (password must be a string, rawPassword must be a Uint8Array)";
|
|
224
|
+
const ERR_INVALID_PASS_THROUGH_VALUE = "Invalid passThrough option (must be a boolean or 'compressed')";
|
|
225
|
+
const ERR_ABORTED = "The operation was aborted";
|
|
226
|
+
const ABORT_ERROR_NAME = "AbortError";
|
|
220
227
|
|
|
221
228
|
function checkFunctionOption(value) {
|
|
222
229
|
if (value && typeof value != FUNCTION_TYPE) {
|
|
@@ -232,12 +239,25 @@
|
|
|
232
239
|
return signal || UNDEFINED_VALUE;
|
|
233
240
|
}
|
|
234
241
|
|
|
242
|
+
function throwIfAborted(signal) {
|
|
243
|
+
if (signal && signal.aborted) {
|
|
244
|
+
throw signal.reason === UNDEFINED_VALUE ? new DOMException(ERR_ABORTED, ABORT_ERROR_NAME) : signal.reason;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
235
248
|
function checkPasswordOption(password, rawPassword) {
|
|
236
249
|
if ((password && typeof password != STRING_TYPE) || (rawPassword && !(rawPassword instanceof Uint8Array))) {
|
|
237
250
|
throw new Error(ERR_INVALID_PASSWORD_TYPE);
|
|
238
251
|
}
|
|
239
252
|
}
|
|
240
253
|
|
|
254
|
+
function checkPassThroughOption(passThrough) {
|
|
255
|
+
if (passThrough !== UNDEFINED_VALUE && typeof passThrough != BOOLEAN_TYPE && passThrough !== PASS_THROUGH_COMPRESSED) {
|
|
256
|
+
throw new Error(ERR_INVALID_PASS_THROUGH_VALUE);
|
|
257
|
+
}
|
|
258
|
+
return passThrough;
|
|
259
|
+
}
|
|
260
|
+
|
|
241
261
|
function checkInteger(value, maxValue, errorMessage) {
|
|
242
262
|
if (!Number.isInteger(value) || value < 0 || value > maxValue) {
|
|
243
263
|
throw new Error(errorMessage);
|
|
@@ -287,6 +307,8 @@
|
|
|
287
307
|
const MINIMUM_CHUNK_SIZE = 64;
|
|
288
308
|
const MINIMUM_PROPERTY_VALUE = 1;
|
|
289
309
|
const ERR_INVALID_MAX_WORKERS = "Invalid maxWorkers (must be an integer greater than 0)";
|
|
310
|
+
const ERR_INVALID_BASE_URI = "Invalid baseURI (must be a string)";
|
|
311
|
+
const ERR_INVALID_URI = "Invalid URI (must be a string or a function returning a string)";
|
|
290
312
|
let maxWorkers = 2;
|
|
291
313
|
try {
|
|
292
314
|
if (typeof navigator != UNDEFINED_TYPE && navigator.hardwareConcurrency) {
|
|
@@ -311,9 +333,9 @@
|
|
|
311
333
|
};
|
|
312
334
|
|
|
313
335
|
const PROPERTY_NAME_MAX_WORKERS = "maxWorkers";
|
|
336
|
+
const PROPERTY_NAME_BASE_URI = "baseURI";
|
|
314
337
|
|
|
315
|
-
const
|
|
316
|
-
"baseURI",
|
|
338
|
+
const URI_PROPERTY_NAMES = [
|
|
317
339
|
"wasmURI",
|
|
318
340
|
"workerURI"
|
|
319
341
|
];
|
|
@@ -337,7 +359,8 @@
|
|
|
337
359
|
"DecompressionStreamFallback"
|
|
338
360
|
];
|
|
339
361
|
const CONFIGURABLE_PROPERTY_NAMES = [
|
|
340
|
-
|
|
362
|
+
PROPERTY_NAME_BASE_URI,
|
|
363
|
+
...URI_PROPERTY_NAMES,
|
|
341
364
|
...BOOLEAN_PROPERTY_NAMES,
|
|
342
365
|
...NUMBER_PROPERTY_NAMES,
|
|
343
366
|
...FUNCTION_PROPERTY_NAMES
|
|
@@ -381,6 +404,14 @@
|
|
|
381
404
|
}
|
|
382
405
|
} else if (FUNCTION_PROPERTY_NAMES.includes(propertyName)) {
|
|
383
406
|
checkFunctionOption(propertyValue);
|
|
407
|
+
} else if (propertyName == PROPERTY_NAME_BASE_URI) {
|
|
408
|
+
if (propertyValue && typeof propertyValue != STRING_TYPE) {
|
|
409
|
+
throw new Error(ERR_INVALID_BASE_URI);
|
|
410
|
+
}
|
|
411
|
+
} else if (URI_PROPERTY_NAMES.includes(propertyName)) {
|
|
412
|
+
if (propertyValue && typeof propertyValue != STRING_TYPE && typeof propertyValue != FUNCTION_TYPE) {
|
|
413
|
+
throw new Error(ERR_INVALID_URI);
|
|
414
|
+
}
|
|
384
415
|
}
|
|
385
416
|
return propertyValue;
|
|
386
417
|
}
|
|
@@ -414,7 +445,7 @@
|
|
|
414
445
|
Object.assign(config, DEFAULT_CONFIGURATION);
|
|
415
446
|
}
|
|
416
447
|
|
|
417
|
-
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$1="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n$1=t=>t({workerURI:t=>{const n="text/javascript";let s='!function(t){"function"==typeof define&&define.amd?define(t):t()}(function(){"use strict";const{Array:t,Object:n,Number:e,Math:s,Error:r,Uint8Array:o,Uint16Array:c,Uint32Array:i,Int32Array:a,Map:f,DataView:u,Promise:l,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;t<256;t++){let n=t;for(let t=0;t<8;t++)n=1&n?n>>>1^3988292384:n>>>1;C[0][t]=n}for(let t=0;t<256;t++)for(let n=1;n<8;n++){const e=C[n-1][t];C[n][t]=e>>>8^C[0][255&e]}const[I,A,x,M,P,B,D,F]=C;class R{constructor(t){this.o=t||-1}append(t){let n=0|this.o;const e=0|t.length;let s=0;if(e>=8&&t.buffer){const r=new u(t.buffer,t.byteOffset,e),o=e-8;for(;s<=o;s+=8){const t=n^r.getInt32(s,!0),e=r.getInt32(s+4,!0);n=F[255&t]^D[t>>>8&255]^B[t>>>16&255]^P[t>>>24&255]^M[255&e]^x[e>>>8&255]^A[e>>>16&255]^I[e>>>24&255]}}for(;s<e;s++)n=n>>>8^I[255&(n^t[s])];this.o=n}get(){return~this.o}}class U extends d{constructor(){let t;const n=new R;super({transform(t,e){n.append(t),e.enqueue(t)},flush(){const e=new o(4);new u(e.buffer).setUint32(0,n.get()),t.value=e}}),t=this}}function W(t,n){const e=new o(t.length+n.length);return e.set(t),e.set(n,t.length),e}function _(t){return new u(t.buffer,t.byteOffset,t.byteLength)}const T={concat(t,n){if(0===t.length||0===n.length)return t.concat(n);const e=t[t.length-1],s=T.l(e);return 32===s?t.concat(n):T.h(n,s,0|e,t.slice(0,t.length-1))},bitLength(t){const n=t.length;if(0===n)return 0;const e=t[n-1];return 32*(n-1)+T.l(e)},m(t,n){if(32*t.length<n)return t;const e=(t=t.slice(0,s.ceil(n/32))).length;return n&=31,e>0&&n&&(t[e-1]=T.S(n,t[e-1]&2147483648>>n-1,1)),t},S:(t,n,e)=>32===t?n:(e?0|n:n<<32-t)+1099511627776*t,l:t=>s.round(t/1099511627776)||32,h(t,n,e,s){for(void 0===s&&(s=[]);n>=32;n-=32)s.push(e),e=0;if(0===n)return s.concat(t);for(let r=0;r<t.length;r++)s.push(e|t[r]>>>n),e=t[r]<<32-n;const r=t.length?t[t.length-1]:0,o=T.l(r);return s.push(T.S(n+o&31,n+o>32?e:s.pop(),1)),s}},V={bytes:{v(t){const n=T.bitLength(t)/8,e=new o(n);let s;for(let r=0;r<n;r++)3&r||(s=t[r/4]),e[r]=s>>>24,s<<=8;return e},C(t){const n=[];let e,s=0;for(e=0;e<t.length;e++)s=s<<8|t[e],3&~e||(n.push(s),s=0);return 3&e&&n.push(T.S(8*(3&e),s)),n}}},K=class{constructor(t){const n=this;n.blockSize=512,n.I=[1732584193,4023233417,2562383102,271733878,3285377520],n.A=[1518500249,1859775393,2400959708,3395469782],t?(n.M=t.M.slice(0),n.P=t.P.slice(0),n.B=t.B):n.reset()}reset(){const t=this;return t.M=t.I.slice(0),t.P=[],t.B=0,t}update(t){const n=this;"string"==typeof t&&(t=V.D.C(t));const e=n.P=T.concat(n.P,t),s=n.B,o=n.B=s+T.bitLength(t);if(o>9007199254740991)throw new r("Cannot hash more than 2^53 - 1 bits");const c=new i(e);let a=0;for(let t=n.blockSize+s-(n.blockSize+s&n.blockSize-1);t<=o;t+=n.blockSize)n.F(c.subarray(16*a,16*(a+1))),a+=1;return e.splice(0,16*a),n}R(){const t=this;let n=t.P;const e=t.M;n=T.concat(n,[T.S(1,1)]);for(let t=n.length+2;15&t;t++)n.push(0);for(n.push(s.floor(t.B/4294967296)),n.push(0|t.B);n.length;)t.F(n.splice(0,16));return t.reset(),e}U(t,n,e,s){return t<=19?n&e|~n&s:t<=39?n^e^s:t<=59?n&e|n&s|e&s:t<=79?n^e^s:void 0}W(t,n){return n<<t|n>>>32-t}F(n){const e=this,r=e.M,o=t(80);for(let t=0;t<16;t++)o[t]=n[t];let c=r[0],i=r[1],a=r[2],f=r[3],u=r[4];for(let t=0;t<=79;t++){t>=16&&(o[t]=e.W(1,o[t-3]^o[t-8]^o[t-14]^o[t-16]));const n=e.W(5,c)+e.U(t,i,a,f)+u+o[t]+e.A[s.floor(t/20)]|0;u=f,f=a,a=e.W(30,i),i=c,c=n}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]+u|0}},E={importKey:t=>new E._(V.bytes.C(t)),T(t,n,e,s){if(e=e||1e4,s<0||e<0)throw new r("invalid params to pbkdf2");const o=1+(s>>5)<<2;let c,i,a,f,l;const w=new ArrayBuffer(o),h=new u(w);let p=0;const d=T;for(n=V.bytes.C(n),l=1;p<(o||1);l++){for(c=i=t.encrypt(d.concat(n,[l])),a=1;a<e;a++)for(i=t.encrypt(i),f=0;f<i.length;f++)c[f]^=i[f];for(a=0;p<(o||1)&&a<c.length;a++)h.setInt32(p,c[a]),p+=4}return w.slice(0,s/8)},_:class{constructor(t){const n=this,e=n.V=K,s=[[],[]];n.K=[new e,new e];const r=n.K[0].blockSize/32;t.length>r&&(t=(new e).update(t).R());for(let n=0;n<r;n++)s[0][n]=909522486^t[n],s[1][n]=1549556828^t[n];n.K[0].update(s[0]),n.K[1].update(s[1]),n.L=new e(n.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,n=t.L.R(),e=new t.V(t.K[1]).update(n).R();return t.reset(),e}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="zipjs-abort-check-password";function H(t){if(L)return h.getRandomValues(t);throw new r("Crypto API not supported")}const N=16,q={name:"PBKDF2"},G=n.assign({hash:{name:"HMAC"}},q),J=n.assign({iterations:1e3,hash:{name:"SHA-1"}},q),Q=["deriveBits"],X=[8,12,16],Y=[16,24,32],Z=10,$=[0,0,0,0],tt=typeof h!=b,nt=tt&&h.subtle,et=tt&&typeof nt!=b,st=V.bytes,rt=class{constructor(t){const n=this;n.j=[[[],[],[],[],[]],[[],[],[],[],[]]],n.j[0][0][0]||n.H();const e=n.j[0][4],s=n.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(n.A=[i=t.slice(0),a=[]],c=o;c<4*o+28;c++){let t=i[c-1];(c%o===0||8===o&&c%o===4)&&(t=e[t>>>24]<<24^e[t>>16&255]<<16^e[t>>8&255]<<8^e[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 n=i[3&t?c:c-4];a[t]=c<=4||t<4?n:s[0][e[n>>>24]]^s[1][e[n>>16&255]]^s[2][e[n>>8&255]]^s[3][e[255&n]]}}encrypt(t){return this.N(t,0)}decrypt(t){return this.N(t,1)}H(){const t=this.j[0],n=this.j[1],e=t[4],s=n[4],r=[],o=[];let c,i,a,f;for(let t=0;t<256;t++)o[(r[t]=t<<1^283*(t>>7))^t]=t;for(let u=c=0;!e[u];u^=i||1,c=o[c]||1){let o=c^c<<1^c<<2^c<<3^c<<4;o=o>>8^255&o^99,e[u]=o,s[o]=u,f=r[a=r[i=r[u]]];let l=16843009*f^65537*a^257*i^16843008*u,w=257*r[o]^16843008*o;for(let e=0;e<4;e++)t[e][u]=w=w<<24^w>>>8,n[e][o]=l=l<<24^l>>>8}for(let e=0;e<5;e++)t[e]=t[e].slice(0),n[e]=n[e].slice(0)}N(t,n){if(4!==t.length)throw new r("invalid aes block size");const e=this.A[n],s=e.length/4-2,o=[0,0,0,0],c=this.j[n],i=c[0],a=c[1],f=c[2],u=c[3],l=c[4];let w,h,p,d=t[0]^e[0],y=t[n?3:1]^e[1],m=t[2]^e[2],S=t[n?1:3]^e[3],g=4;for(let t=0;t<s;t++)w=i[d>>>24]^a[y>>16&255]^f[m>>8&255]^u[255&S]^e[g],h=i[y>>>24]^a[m>>16&255]^f[S>>8&255]^u[255&d]^e[g+1],p=i[m>>>24]^a[S>>16&255]^f[d>>8&255]^u[255&y]^e[g+2],S=i[S>>>24]^a[d>>16&255]^f[y>>8&255]^u[255&m]^e[g+3],g+=4,d=w,y=h,m=p;for(let t=0;t<4;t++)o[n?3&-t:t]=l[d>>>24]<<24^l[y>>16&255]<<16^l[m>>8&255]<<8^l[255&S]^e[g++],w=d,d=y,y=m,m=S,S=w;return o}},ot=class{constructor(t,n){this.G=t,this.J=n,this.X=n}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 n=t>>16&255,e=t>>8&255,s=255&t;255===n?(n=0,255===e?(e=0,255===s?s=0:++s):++e):++n,t=0,t+=n<<16,t+=e<<8,t+=s}return t}$(t){0===(t[0]=this.Z(t[0]))&&(t[1]=this.Z(t[1]))}Y(t,n,e){let s;if(!(s=n.length))return[];const r=T.bitLength(n);for(let r=0;r<s;r+=4){this.$(e);const s=t.encrypt(e);n[r]^=s[0],n[r+1]^=s[1],n[r+2]^=s[2],n[r+3]^=s[3]}return T.m(n,r)}},ct=E._;let it=tt&&et&&typeof nt.importKey==k,at=tt&&et&&typeof nt.deriveBits==k;class ft extends d{constructor({password:t,rawPassword:n,encryptionStrength:e,checkPasswordOnly:s,checkAuthenticationCode:c=!0}){super({start(){lt(this,t,n,e)},async transform(t,n){const e=this,{password:c,strength:i,nt:a,ready:f}=e;c?(await async function(t,n,e,s){const o=await ht(t,n,e,dt(s,0,X[n])),c=dt(s,X[n]);if(o[0]!=c[0]||o[1]!=c[1])throw new r(O)}(e,i,c,dt(t,0,X[i]+2)),t=dt(t,X[i]+2),s?n.error(new r(j)):a()):await f;const u=new o(t.length-Z-(t.length-Z)%N);n.enqueue(wt(e,t,u,0,Z,!0))},async flush(t){const{et:n,st:e,ot:s,ready:o}=this;if(e&&n){await o;const i=dt(s,0,s.length-Z),a=dt(s,s.length-Z);let f=z;if(i.length){const t=mt(st,i);e.update(t);const s=n.update(t);f=yt(st,s)}const u=dt(yt(st,e.digest()),0,Z);let l=s.length<Z?1:0;for(let t=0;t<Z;t++)l|=u[t]^a[t];if(l&&c)throw new r("Invalid authentication code");t.enqueue(f)}}})}}class ut extends d{constructor({password:t,rawPassword:n,encryptionStrength:e}){super({start(){lt(this,t,n,e)},async transform(t,n){const e=this,{password:s,strength:r,nt:c,ready:i}=e;let a=z;s?(a=await async function(t,n,e){const s=H(new o(X[n]));return W(s,await ht(t,n,e,s))}(e,r,s),c()):await i;const f=new o(a.length+t.length-t.length%N);f.set(a,0),n.enqueue(wt(e,t,f,a.length,0))},async flush(t){const{et:n,st:e,ot:s,ready:r}=this;if(e&&n){await r;let o=z;if(s.length){const t=n.update(mt(st,s));e.update(t),o=yt(st,t)}const c=yt(st,e.digest()).slice(0,Z);t.enqueue(W(o,c))}}})}}function lt(t,e,s,r){n.assign(t,{ready:new l(n=>t.nt=n),password:pt(e,s),strength:r-1,ot:z})}function wt(t,n,e,s,r,c){const{et:i,st:a,ot:f}=t;f.length&&(n=W(f,n));const u=n.length-r;let l;for(e=function(t,n){if(n&&n>t.length){const e=t;(t=new o(n)).set(e,0)}return t}(e,s+(u-u%N)),l=0;l<=u-N;l+=N){const t=mt(st,dt(n,l,l+N));c&&a.update(t);const r=i.update(t);c||a.update(r),e.set(yt(st,r),l+s)}return t.ot=dt(n,l),e}async function ht(e,s,r,c){e.password=null;const i=await async function(t,n,e,s,r){if(!it)return E.importKey(n);try{return await nt.importKey("raw",n,e,!1,r)}catch{return it=!1,E.importKey(n)}}(0,r,G,0,Q),a=await async function(t,n,e){if(!at)return E.T(n,t.salt,J.iterations,e);try{return await nt.deriveBits(t,n,e)}catch{return at=!1,E.T(n,t.salt,J.iterations,e)}}(n.assign({salt:c},J),i,8*(2*Y[s]+2)),f=new o(a),u=mt(st,dt(f,0,Y[s])),l=mt(st,dt(f,Y[s],2*Y[s])),w=dt(f,2*Y[s]);return n.assign(e,{keys:{key:u,ct:l,passwordVerification:w},et:new ot(new rt(u),t.from($)),st:new ct(l)}),w}function pt(t,n){return n===v?function(t){if(typeof w==b){t=unescape(encodeURIComponent(t));const n=new o(t.length);for(let e=0;e<n.length;e++)n[e]=t.charCodeAt(e);return n}return(new w).encode(t)}(t):n}function dt(t,n,e){return t.subarray(n,e)}function yt(t,n){return t.v(n)}function mt(t,n){return t.C(n)}class St extends d{constructor({password:t,rawPassword:n,passwordVerification:e,checkPasswordOnly:s}){super({start(){vt(this,t,n,e)},transform(t,n){const e=this;if(e.password||e.rawPassword){const n=bt(e,t.subarray(0,12));if(e.password=e.rawPassword=null,0!=(n[11]^e.passwordVerification))throw new r(O);t=t.subarray(12)}s?n.error(new r(j)):n.enqueue(bt(e,t))}})}}class gt extends d{constructor({password:t,rawPassword:n,passwordVerification:e}){super({start(){vt(this,t,n,e)},transform(t,n){const e=this;let s,r;if(e.password||e.rawPassword){e.password=e.rawPassword=null;const n=H(new o(12));n[11]=e.passwordVerification,s=new o(t.length+n.length),s.set(kt(e,n),0),r=12}else s=new o(t.length),r=0;s.set(kt(e,t),r),n.enqueue(s)}})}}function vt(t,e,s,r){n.assign(t,{password:e,rawPassword:s,passwordVerification:r}),function(t,e,s){const r=[305419896,591751049,878082192];if(n.assign(t,{keys:r,it:new R(r[0]),ft:new R(r[2])}),s)for(let n=0;n<s.length;n++)zt(t,s[n]);else for(let n=0;n<e.length;n++)zt(t,e.charCodeAt(n))}(t,e,s)}function bt(t,n){const e=new o(n.length);for(let s=0;s<n.length;s++)e[s]=Ct(t)^n[s],zt(t,e[s]);return e}function kt(t,n){const e=new o(n.length);for(let s=0;s<n.length;s++)e[s]=Ct(t)^n[s],zt(t,n[s]);return e}function zt(t,n){let[,e]=t.keys;t.it.append([n]);const r=~t.it.get();e=At(s.imul(At(e+It(r)),134775813)+1),t.ft.append([e>>>24]);const o=~t.ft.get();t.keys=[r,e,o]}function Ct(t){const n=2|t.keys[2];return It(s.imul(n,1^n)>>>8)}function It(t){return 255&t}function At(t){return 4294967295&t}function xt(t){if(t instanceof y)return t;const n=t.getReader();return new y({async pull(t){const{value:e,done:s}=await n.read();s?t.close():t.enqueue(e)},cancel:t=>n.cancel(t)})}const Mt=new f;function Pt(t){return Mt.get(t)}const Bt="Invalid uncompressed size",Dt="deflate-raw",Ft="gzip",Rt=[31,139,8];class Ut extends d{constructor(t,{chunkSize:n,CompressionStreamFallback:e,CompressionStream:s}){super({});const{compressed:r,encrypted:o,useCompressionStream:c,zipCrypto:i,computeCrc32:a,level:f,deflate64:l,format:w,compressionMethod:h,inputSize:p}=t,d=this;let y,m,S,g=super.readable;const v=w&&Pt(w),b=a&&r&&!l&&!v&&(!o||i)&&Boolean(c&&s);if(o&&!i||!a||b||(y=new U,g=Lt(g,y)),r)if(v)g=Ot(g,Kt(v.CompressionStream,w,{level:f,chunkSize:n,compressionMethod:h,uncompressedSize:p}));else if(b)S=new Wt,g=Ot(g,new s(Ft)),g=Lt(g,S);else try{g=Et(g,c,{level:f,chunkSize:n},s,e)}catch(t){let n;try{n=new s(Ft)}catch{throw t}g=Ot(g,n),g=Lt(g,new Wt)}o&&(i?g=Lt(g,new gt(t)):(m=new ut(t),g=Lt(g,m))),Vt(d,g,()=>{o&&!i||!a||(d.crc32=b?S.crc32:new u(y.value.buffer).getUint32(0))})}}class Wt extends d{constructor(){let t,n=10,e=new o(0);super({transform(t,r){if(n){const e=s.min(n,t.length);if(n-=e,!(t=t.subarray(e)).length)return}const o=e.length+t.length;if(o<=8)return void(e=W(e,t));const c=o-8,i=s.min(c,e.length);r.enqueue(W(e.subarray(0,i),t.subarray(0,c-i))),e=W(e.subarray(i),t.subarray(c-i))},flush(){const n=_(e);t.crc32=n.getUint32(0,!0),t.uncompressedSize=n.getUint32(4,!0)}}),t=this}}class _t extends d{constructor(t,{chunkSize:n,DecompressionStreamFallback:e,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=Lt(C,new St(t)):(z=new ft(t),C=Lt(C,z))),w){const t=m&&Pt(m);if(t)C=Ot(C,Kt(t.DecompressionStream,m,{chunkSize:n,compressionMethod:S,rawBitFlag:g,uncompressedSize:b}));else try{C=Et(C,h,{chunkSize:n,deflate64:p},s,e)}catch(t){if(p||b===v)throw t;let n;try{n=new s(Ft)}catch{throw t}C=function(t,n,e){const s=new R;let c,i,a,f=0,u=!1;const w=new l((t,n)=>{i=t,a=n});w.catch(()=>{}),e||i();const h=new d({start(t){const n=new o(10);n.set(Rt),t.enqueue(n)},transform(t,n){n.enqueue(t)},async flush(t){u=!0,y();try{await w}finally{m()}const n=new o(8),r=_(n);r.setUint32(0,s.get(),!0),r.setUint32(4,e,!0),t.enqueue(n)},cancel(t){a(t)}}),p=new d({transform(t,n){s.append(t),f+=t.length,f>=e?i():u&&y(),n.enqueue(t)},cancel(t){a(t)}});return t=Lt(t,h),Lt(t=Ot(t,n),p);function y(){m(),c=setTimeout(()=>a(new r(Bt)),5e3)}function m(){clearTimeout(c)}}(C,n,b)}C=function(t){const n=t.getReader();return new y({async pull(t){let e;try{e=await n.read()}catch(t){if(t&&t.message)throw t;const n=new r("Invalid compressed data");throw n.cause=t,n}const{value:s,done:o}=e;o?t.close():t.enqueue(s)},cancel:t=>n.cancel(t)})}(C)}a&&(k=new U,C=Lt(C,k)),Vt(this,C,()=>{if(a){const t=new u(k.value.buffer);if(f!=t.getUint32(0,!1))throw new r("Invalid CRC32")}})}}const Tt=new f;function Vt(t,e,s){e=Lt(e,new d({flush:s})),n.defineProperty(t,"readable",{get:()=>e})}function Kt(t,n,e){if(!t)throw new r("Compression method not supported");return new t(n,e)}function Et(t,n,e,s,r){const o=n&&s?s:r||s,c=e.deflate64?"deflate64-raw":Dt;let i;try{i=new o(c,e)}catch(t){if(!n||!r||o==r)throw t;i=new r(c,e)}return Ot(t,i)}function Lt(t,n){return xt(t).pipeThrough(n)}function Ot(t,n){const e=n.writable.getWriter(),s=t.getReader();return async function(){try{for(;;){await e.ready;const t=await s.read();if(t.done){await e.close();break}await e.write(t.value)}}catch(t){await async function(t,n){try{await t.abort(n)}catch{}}(e,t),await async function(t,n){try{await t.cancel(n)}catch{}}(s,t)}}(),n.readable}const jt="data",Ht="close",Nt="deflate";class qt extends d{constructor(t,e){super({});const s=this,{codecType:o}=t;let c;o.startsWith(Nt)?c=Ut:o.startsWith("inflate")&&(c=_t),s.outputSize=0;let i=0;const a=new c(t,e),f=super.readable,u=new d({transform(t,n){t&&t.length&&(i+=t.length,n.enqueue(t))},flush(){n.assign(s,{inputSize:i})}}),l=new d({transform(n,e){if(n&&n.length&&(e.enqueue(n),s.outputSize+=n.length,t.outputSize!==v&&s.outputSize>t.outputSize))throw new r(Bt)},flush(){const{crc32:t}=a;n.assign(s,{crc32:t,inputSize:i})}});n.defineProperty(s,"readable",{get:()=>f.pipeThrough(u).pipeThrough(a).pipeThrough(l)})}}class Gt extends d{constructor(t){const n=[];let s=0;function r(){const e=new o(t);let r=0;for(;r<t;){const s=n[0],o=t-r;s.length<=o?(e.set(s,r),r+=s.length,n.shift()):(e.set(s.subarray(0,o),r),n[0]=s.subarray(o),r+=o)}return s-=t,e}(!e.isFinite(t)||t<1)&&(t=65536),super({transform(e,o){for(n.push(e),s+=e.length;s>t;)o.enqueue(r())},flush(t){s&&t.enqueue(function(t,n){const e=new o(n);let s=0;for(const n of t)e.set(n,s),s+=n.length;return e}(n,s))}})}}let Jt=2;try{typeof navigator!=b&&navigator.hardwareConcurrency&&(Jt=navigator.hardwareConcurrency)}catch{}const Qt=new f,Xt=new f;let Yt,Zt=0;async function $t(t){let n,o;try{const{options:c,config:i}=t;if(c.format)try{await async function(t,n){!Mt.has(t)&&n&&function(t,n){const{CompressionStream:e,DecompressionStream:s}=n;if(typeof e!=k&&typeof s!=k)throw new r("Invalid codec module");Mt.set(t,{CompressionStream:e,DecompressionStream:s})}(t,await(import(n)))}(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(!function(t,n){if(!t)return!1;let e=Tt.get(t);e||(e=new f,Tt.set(t,e));let s=e.get(n);if(s===v){try{new t(n),s=!0}catch{s=!1}e.set(n,s)}return s}(c.codecType.startsWith(Nt)?i.CompressionStream:i.DecompressionStream,Dt))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},u=t.readable?xt(t.readable):new y({async pull(t){const n=new l(t=>Qt.set(Zt,t));tn({type:"pull",messageId:Zt}),Zt=(Zt+1)%e.MAX_SAFE_INTEGER;const{value:s,done:r}=await n;t.enqueue(s),r&&t.close()}},a);o=t.writable?function(t){if(t instanceof m)return t;const n=t.getWriter();return new m({write:t=>n.write(t),close:()=>n.close(),abort:t=>n.abort(t)})}(t.writable):new m({async write(t){let n;const s=new l(t=>n=t);Xt.set(Zt,n),tn({type:jt,value:t,messageId:Zt}),Zt=(Zt+1)%e.MAX_SAFE_INTEGER,await s}},a),n=new qt(c,i),Yt=new AbortController;const{signal:w}=Yt;await u.pipeThrough(n).pipeThrough(new Gt(function(t){return r="string"==typeof(n=r=t.chunkSize)&&n.trim()?e(n):n,e.isInteger(r)&&r>=1?s.max(r,64):65536;var n,r}(i))).pipeTo(o,{signal:w,preventClose:!0,preventAbort:!0}),await o.getWriter().close();const{crc32:h,inputSize:p,outputSize:d}=n;tn({type:Ht,result:{crc32:h,inputSize:p,outputSize:d}})}catch(t){if(t.outputSize=n?n.outputSize:0,o&&!o.locked)try{await o.getWriter().close()}catch{}nn(t)}}function tn(t){const{value:n}=t;if(n)if(n.length)try{t.value=(e=n,e.byteOffset||e.byteLength!=e.buffer.byteLength?new o(e):e).buffer,p(t,[t.value])}catch{p(t)}else p(t);else p(t);var e}function nn(t=new r("Unknown error")){const{message:n,stack:e,code:s,name:o,outputSize:c,cause:i,codecImportFailed:a}=t,f={message:n,stack:e,code:s,name:o,outputSize:c};i&&(f.cause={name:i.name,message:i.message}),a&&(f.codecImportFailed=!0),p({error:f})}addEventListener("message",({data:t})=>{const{type:n,messageId:e,value:s,done:r}=t;try{if("start"==n&&$t(t),n==jt){const t=Qt.get(e);Qt.delete(e),t({value:s||new o,done:r})}if("ack"==n){const t=Xt.get(e);Xt.delete(e),t()}n==Ht&&Yt.abort()}catch(t){nn(t)}}),p({type:"ready"});const en="deflate",sn="deflate-raw",rn="deflate64-raw",on="gzip";let cn,an,fn,un,ln;function wn(t,n,e={}){if(!cn){const t=new r("WASM module not loaded");throw t.cause=ln,t}const c="number"==typeof e.level?e.level:-1,i="number"==typeof e.outBuffer?e.outBuffer:65536,a="number"==typeof e.inBufferSize?e.inBufferSize:65536;return new d({start(){try{let e;if(this.ut=an(i),this.in=an(a),this.inBufferSize=a,!this.ut||!this.in)throw new r("allocation failed");if(this.lt=new o(i),t?(this.wt=cn.deflate_process,this.ht=cn.deflate_last_consumed,this.yt=cn.deflate_end,this.St=cn.deflate_new(),e=n===on?cn.deflate_init_gzip(this.St,c):n===sn?cn.deflate_init_raw(this.St,c):cn.deflate_init(this.St,c)):n===rn?(this.wt=cn.inflate9_process,this.ht=cn.inflate9_last_consumed,this.yt=cn.inflate9_end,this.St=cn.inflate9_new(),e=cn.inflate9_init_raw(this.St)):(this.wt=cn.inflate_process,this.ht=cn.inflate_last_consumed,this.yt=cn.inflate_end,this.St=cn.inflate_new(),e=n===sn?cn.inflate_init_raw(this.St):n===on?cn.inflate_init_gzip(this.St):cn.inflate_init(this.St)),0!==e)throw new r("init failed:"+e)}catch(t){throw f(this),t}},transform(t,n){try{const e=t,c=new o(un.buffer),a=this.wt,f=this.ht,u=this.ut,l=this.lt;let w=0;for(;w<e.length;){const t=s.min(e.length-w,32768);if((!this.in||this.inBufferSize<t)&&(this.in&&fn&&(fn(this.in),this.in=0),this.in=an(t),this.inBufferSize=t,!this.in))throw new r("allocation failed");c.set(e.subarray(w,w+t),this.in);const o=a(this.St,this.in,t,u,i,0),h=o>>24&255,p=128&h?h-256:h;if(p<0)throw new r("process error:"+p);const d=16777215&o;d&&(l.set(c.subarray(u,u+d),0),n.enqueue(l.slice(0,d)));const y=f(this.St);if(0===y&&0===d)break;w+=y}}catch(t){f(this),n.error(t)}},flush(t){try{const n=new o(un.buffer),e=this.wt,s=this.ut,c=this.lt;for(;;){const o=e(this.St,0,0,s,i,4),a=o>>24&255,f=128&a?a-256:a;if(f<0)throw new r("process error:"+f);const u=16777215&o;if(u&&(c.set(n.subarray(s,s+u),0),t.enqueue(c.slice(0,u))),1===a||0===u)break}}catch(n){t.error(n)}finally{const n=f(this);0!==n&&t.error(new r("end error:"+n))}},cancel(){f(this)}});function f(t){let n=0;return t.St&&t.yt&&(n=t.yt(t.St)),t.St=0,t.in&&fn&&fn(t.in),t.in=0,t.ut&&fn&&fn(t.ut),t.ut=0,n}}class hn{constructor(t=en,n){return wn(!0,t,n)}}class pn{constructor(t=en,n){return wn(!1,t,n)}}hn.gt=!0,pn.gt=!0,hn.vt=[en,sn,on],pn.vt=[en,sn,on,rn];let dn=!1;!function(t={}){const{init:n}=t,e=t.CompressionStreamFallback||t.CompressionStreamZlib,s=t.DecompressionStreamFallback||t.DecompressionStreamZlib;self.initModule=async t=>{n&&await n(t),e&&(t.CompressionStreamFallback=e),s&&(t.DecompressionStreamFallback=s)}}({CompressionStreamFallback:hn,DecompressionStreamFallback:pn,init:t=>async function(t,{baseURI:n}){if(!dn)try{await async function(t,n){let e,s;try{try{s=new URL(t,n)}catch{}const r=await fetch(s);e=await r.arrayBuffer()}catch(n){if(!t.startsWith("data:application/wasm;base64,"))throw n;e=function(t){const n=t.split(",")[1],e=atob(n),s=e.length,r=new o(s);for(let t=0;t<s;++t)r[t]=e.charCodeAt(t);return r.buffer}(t)}!function(t){if(cn=t,({malloc:an,free:fn,memory:un}=cn),"function"!=typeof an||"function"!=typeof fn||!un)throw cn=an=fn=un=null,new r("Invalid WASM module")}((await WebAssembly.instantiate(e)).instance.exports)}(t,n),dn=!0}catch(t){throw function(t){ln=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,"+function(t){let n="";const s=t.length;let r=0;for(;r+2<s;r+=3){const s=t[r]<<16|t[r+1]<<8|t[r+2];n+=e$1[s>>18&63]+e$1[s>>12&63]+e$1[s>>6&63]+e$1[63&s];}const o=s-r;if(1===o){const s=t[r]<<16;n+=e$1[s>>18&63]+e$1[s>>12&63]+"==";}else if(2===o){const s=t[r]<<16|t[r+1]<<8;n+=e$1[s>>18&63]+e$1[s>>12&63]+e$1[s>>6&63]+"=";}return n}(s)}});
|
|
448
|
+
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$1="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n$1=t=>t({workerURI:t=>{const n="text/javascript";let s='!function(t){"function"==typeof define&&define.amd?define(t):t()}(function(){"use strict";const{Array:t,Object:n,Number:e,Math:s,Error:r,Uint8Array:o,Uint16Array:c,Uint32Array:i,Int32Array:a,Map:f,DataView:u,Promise:l,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;t<256;t++){let n=t;for(let t=0;t<8;t++)n=1&n?n>>>1^3988292384:n>>>1;C[0][t]=n}for(let t=0;t<256;t++)for(let n=1;n<8;n++){const e=C[n-1][t];C[n][t]=e>>>8^C[0][255&e]}const[I,A,x,M,P,B,D,F]=C;class R{constructor(t){this.o=t||-1}append(t){let n=0|this.o;const e=0|t.length;let s=0;if(e>=8&&t.buffer){const r=new u(t.buffer,t.byteOffset,e),o=e-8;for(;s<=o;s+=8){const t=n^r.getInt32(s,!0),e=r.getInt32(s+4,!0);n=F[255&t]^D[t>>>8&255]^B[t>>>16&255]^P[t>>>24&255]^M[255&e]^x[e>>>8&255]^A[e>>>16&255]^I[e>>>24&255]}}for(;s<e;s++)n=n>>>8^I[255&(n^t[s])];this.o=n}get(){return~this.o}}class U extends d{constructor(){let t;const n=new R;super({transform(t,e){n.append(t),e.enqueue(t)},flush(){const e=new o(4);new u(e.buffer).setUint32(0,n.get()),t.value=e}}),t=this}}function W(t,n){const e=new o(t.length+n.length);return e.set(t),e.set(n,t.length),e}function _(t){return new u(t.buffer,t.byteOffset,t.byteLength)}const T={concat(t,n){if(0===t.length||0===n.length)return t.concat(n);const e=t[t.length-1],s=T.l(e);return 32===s?t.concat(n):T.h(n,s,0|e,t.slice(0,t.length-1))},bitLength(t){const n=t.length;if(0===n)return 0;const e=t[n-1];return 32*(n-1)+T.l(e)},m(t,n){if(32*t.length<n)return t;const e=(t=t.slice(0,s.ceil(n/32))).length;return n&=31,e>0&&n&&(t[e-1]=T.S(n,t[e-1]&2147483648>>n-1,1)),t},S:(t,n,e)=>32===t?n:(e?0|n:n<<32-t)+1099511627776*t,l:t=>s.round(t/1099511627776)||32,h(t,n,e,s){for(void 0===s&&(s=[]);n>=32;n-=32)s.push(e),e=0;if(0===n)return s.concat(t);for(let r=0;r<t.length;r++)s.push(e|t[r]>>>n),e=t[r]<<32-n;const r=t.length?t[t.length-1]:0,o=T.l(r);return s.push(T.S(n+o&31,n+o>32?e:s.pop(),1)),s}},V={bytes:{v(t){const n=T.bitLength(t)/8,e=new o(n);let s;for(let r=0;r<n;r++)3&r||(s=t[r/4]),e[r]=s>>>24,s<<=8;return e},C(t){const n=[];let e,s=0;for(e=0;e<t.length;e++)s=s<<8|t[e],3&~e||(n.push(s),s=0);return 3&e&&n.push(T.S(8*(3&e),s)),n}}},K=class{constructor(t){const n=this;n.blockSize=512,n.I=[1732584193,4023233417,2562383102,271733878,3285377520],n.A=[1518500249,1859775393,2400959708,3395469782],t?(n.M=t.M.slice(0),n.P=t.P.slice(0),n.B=t.B):n.reset()}reset(){const t=this;return t.M=t.I.slice(0),t.P=[],t.B=0,t}update(t){const n=this;"string"==typeof t&&(t=V.D.C(t));const e=n.P=T.concat(n.P,t),s=n.B,o=n.B=s+T.bitLength(t);if(o>9007199254740991)throw new r("Cannot hash more than 2^53 - 1 bits");const c=new i(e);let a=0;for(let t=n.blockSize+s-(n.blockSize+s&n.blockSize-1);t<=o;t+=n.blockSize)n.F(c.subarray(16*a,16*(a+1))),a+=1;return e.splice(0,16*a),n}R(){const t=this;let n=t.P;const e=t.M;n=T.concat(n,[T.S(1,1)]);for(let t=n.length+2;15&t;t++)n.push(0);for(n.push(s.floor(t.B/4294967296)),n.push(0|t.B);n.length;)t.F(n.splice(0,16));return t.reset(),e}U(t,n,e,s){return t<=19?n&e|~n&s:t<=39?n^e^s:t<=59?n&e|n&s|e&s:t<=79?n^e^s:void 0}W(t,n){return n<<t|n>>>32-t}F(n){const e=this,r=e.M,o=t(80);for(let t=0;t<16;t++)o[t]=n[t];let c=r[0],i=r[1],a=r[2],f=r[3],u=r[4];for(let t=0;t<=79;t++){t>=16&&(o[t]=e.W(1,o[t-3]^o[t-8]^o[t-14]^o[t-16]));const n=e.W(5,c)+e.U(t,i,a,f)+u+o[t]+e.A[s.floor(t/20)]|0;u=f,f=a,a=e.W(30,i),i=c,c=n}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]+u|0}},E={importKey:t=>new E._(V.bytes.C(t)),T(t,n,e,s){if(e=e||1e4,s<0||e<0)throw new r("invalid params to pbkdf2");const o=1+(s>>5)<<2;let c,i,a,f,l;const w=new ArrayBuffer(o),h=new u(w);let p=0;const d=T;for(n=V.bytes.C(n),l=1;p<(o||1);l++){for(c=i=t.encrypt(d.concat(n,[l])),a=1;a<e;a++)for(i=t.encrypt(i),f=0;f<i.length;f++)c[f]^=i[f];for(a=0;p<(o||1)&&a<c.length;a++)h.setInt32(p,c[a]),p+=4}return w.slice(0,s/8)},_:class{constructor(t){const n=this,e=n.V=K,s=[[],[]];n.K=[new e,new e];const r=n.K[0].blockSize/32;t.length>r&&(t=(new e).update(t).R());for(let n=0;n<r;n++)s[0][n]=909522486^t[n],s[1][n]=1549556828^t[n];n.K[0].update(s[0]),n.K[1].update(s[1]),n.L=new e(n.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,n=t.L.R(),e=new t.V(t.K[1]).update(n).R();return t.reset(),e}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="zipjs-abort-check-password";function H(t){if(L)return h.getRandomValues(t);throw new r("Crypto API not supported")}const N=16,q={name:"PBKDF2"},G=n.assign({hash:{name:"HMAC"}},q),J=n.assign({iterations:1e3,hash:{name:"SHA-1"}},q),Q=["deriveBits"],X=[8,12,16],Y=[16,24,32],Z=10,$=[0,0,0,0],tt=typeof h!=b,nt=tt&&h.subtle,et=tt&&typeof nt!=b,st=V.bytes,rt=class{constructor(t){const n=this;n.j=[[[],[],[],[],[]],[[],[],[],[],[]]],n.j[0][0][0]||n.H();const e=n.j[0][4],s=n.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(n.A=[i=t.slice(0),a=[]],c=o;c<4*o+28;c++){let t=i[c-1];(c%o===0||8===o&&c%o===4)&&(t=e[t>>>24]<<24^e[t>>16&255]<<16^e[t>>8&255]<<8^e[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 n=i[3&t?c:c-4];a[t]=c<=4||t<4?n:s[0][e[n>>>24]]^s[1][e[n>>16&255]]^s[2][e[n>>8&255]]^s[3][e[255&n]]}}encrypt(t){return this.N(t,0)}decrypt(t){return this.N(t,1)}H(){const t=this.j[0],n=this.j[1],e=t[4],s=n[4],r=[],o=[];let c,i,a,f;for(let t=0;t<256;t++)o[(r[t]=t<<1^283*(t>>7))^t]=t;for(let u=c=0;!e[u];u^=i||1,c=o[c]||1){let o=c^c<<1^c<<2^c<<3^c<<4;o=o>>8^255&o^99,e[u]=o,s[o]=u,f=r[a=r[i=r[u]]];let l=16843009*f^65537*a^257*i^16843008*u,w=257*r[o]^16843008*o;for(let e=0;e<4;e++)t[e][u]=w=w<<24^w>>>8,n[e][o]=l=l<<24^l>>>8}for(let e=0;e<5;e++)t[e]=t[e].slice(0),n[e]=n[e].slice(0)}N(t,n){if(4!==t.length)throw new r("invalid aes block size");const e=this.A[n],s=e.length/4-2,o=[0,0,0,0],c=this.j[n],i=c[0],a=c[1],f=c[2],u=c[3],l=c[4];let w,h,p,d=t[0]^e[0],y=t[n?3:1]^e[1],m=t[2]^e[2],S=t[n?1:3]^e[3],g=4;for(let t=0;t<s;t++)w=i[d>>>24]^a[y>>16&255]^f[m>>8&255]^u[255&S]^e[g],h=i[y>>>24]^a[m>>16&255]^f[S>>8&255]^u[255&d]^e[g+1],p=i[m>>>24]^a[S>>16&255]^f[d>>8&255]^u[255&y]^e[g+2],S=i[S>>>24]^a[d>>16&255]^f[y>>8&255]^u[255&m]^e[g+3],g+=4,d=w,y=h,m=p;for(let t=0;t<4;t++)o[n?3&-t:t]=l[d>>>24]<<24^l[y>>16&255]<<16^l[m>>8&255]<<8^l[255&S]^e[g++],w=d,d=y,y=m,m=S,S=w;return o}},ot=class{constructor(t,n){this.G=t,this.J=n,this.X=n}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 n=t>>16&255,e=t>>8&255,s=255&t;255===n?(n=0,255===e?(e=0,255===s?s=0:++s):++e):++n,t=0,t+=n<<16,t+=e<<8,t+=s}return t}$(t){0===(t[0]=this.Z(t[0]))&&(t[1]=this.Z(t[1]))}Y(t,n,e){let s;if(!(s=n.length))return[];const r=T.bitLength(n);for(let r=0;r<s;r+=4){this.$(e);const s=t.encrypt(e);n[r]^=s[0],n[r+1]^=s[1],n[r+2]^=s[2],n[r+3]^=s[3]}return T.m(n,r)}},ct=E._;let it=tt&&et&&typeof nt.importKey==k,at=tt&&et&&typeof nt.deriveBits==k;class ft extends d{constructor({password:t,rawPassword:n,encryptionStrength:e,checkPasswordOnly:s,checkAuthenticationCode:c=!0}){super({start(){lt(this,t,n,e)},async transform(t,n){const e=this,{password:c,strength:i,nt:a,ready:f}=e;c?(await async function(t,n,e,s){const o=await ht(t,n,e,dt(s,0,X[n])),c=dt(s,X[n]);if(o[0]!=c[0]||o[1]!=c[1])throw new r(O)}(e,i,c,dt(t,0,X[i]+2)),t=dt(t,X[i]+2),s?n.error(new r(j)):a()):await f;const u=new o(t.length-Z-(t.length-Z)%N);n.enqueue(wt(e,t,u,0,Z,!0))},async flush(t){const{et:n,st:e,ot:s,ready:o}=this;if(e&&n){await o;const i=dt(s,0,s.length-Z),a=dt(s,s.length-Z);let f=z;if(i.length){const t=mt(st,i);e.update(t);const s=n.update(t);f=yt(st,s)}const u=dt(yt(st,e.digest()),0,Z);let l=s.length<Z?1:0;for(let t=0;t<Z;t++)l|=u[t]^a[t];if(l&&c)throw new r("Invalid authentication code");t.enqueue(f)}}})}}class ut extends d{constructor({password:t,rawPassword:n,encryptionStrength:e}){super({start(){lt(this,t,n,e)},async transform(t,n){const e=this,{password:s,strength:r,nt:c,ready:i}=e;let a=z;s?(a=await async function(t,n,e){const s=H(new o(X[n]));return W(s,await ht(t,n,e,s))}(e,r,s),c()):await i;const f=new o(a.length+t.length-t.length%N);f.set(a,0),n.enqueue(wt(e,t,f,a.length,0))},async flush(t){const{et:n,st:e,ot:s,ready:r}=this;if(e&&n){await r;let o=z;if(s.length){const t=n.update(mt(st,s));e.update(t),o=yt(st,t)}const c=yt(st,e.digest()).slice(0,Z);t.enqueue(W(o,c))}}})}}function lt(t,e,s,r){n.assign(t,{ready:new l(n=>t.nt=n),password:pt(e,s),strength:r-1,ot:z})}function wt(t,n,e,s,r,c){const{et:i,st:a,ot:f}=t;f.length&&(n=W(f,n));const u=n.length-r;let l;for(e=function(t,n){if(n&&n>t.length){const e=t;(t=new o(n)).set(e,0)}return t}(e,s+(u-u%N)),l=0;l<=u-N;l+=N){const t=mt(st,dt(n,l,l+N));c&&a.update(t);const r=i.update(t);c||a.update(r),e.set(yt(st,r),l+s)}return t.ot=dt(n,l),e}async function ht(e,s,r,c){e.password=null;const i=await async function(t,n,e,s,r){if(!it)return E.importKey(n);try{return await nt.importKey("raw",n,e,!1,r)}catch{return it=!1,E.importKey(n)}}(0,r,G,0,Q),a=await async function(t,n,e){if(!at)return E.T(n,t.salt,J.iterations,e);try{return await nt.deriveBits(t,n,e)}catch{return at=!1,E.T(n,t.salt,J.iterations,e)}}(n.assign({salt:c},J),i,8*(2*Y[s]+2)),f=new o(a),u=mt(st,dt(f,0,Y[s])),l=mt(st,dt(f,Y[s],2*Y[s])),w=dt(f,2*Y[s]);return n.assign(e,{keys:{key:u,ct:l,passwordVerification:w},et:new ot(new rt(u),t.from($)),st:new ct(l)}),w}function pt(t,n){return n===v?function(t){if(typeof w==b){t=unescape(encodeURIComponent(t));const n=new o(t.length);for(let e=0;e<n.length;e++)n[e]=t.charCodeAt(e);return n}return(new w).encode(t)}(t):n}function dt(t,n,e){return t.subarray(n,e)}function yt(t,n){return t.v(n)}function mt(t,n){return t.C(n)}class St extends d{constructor({password:t,rawPassword:n,passwordVerification:e,checkPasswordOnly:s}){super({start(){vt(this,t,n,e)},transform(t,n){const e=this;if(e.password||e.rawPassword){const n=bt(e,t.subarray(0,12));if(e.password=e.rawPassword=null,0!=(n[11]^e.passwordVerification))throw new r(O);t=t.subarray(12)}s?n.error(new r(j)):n.enqueue(bt(e,t))}})}}class gt extends d{constructor({password:t,rawPassword:n,passwordVerification:e}){super({start(){vt(this,t,n,e)},transform(t,n){const e=this;let s,r;if(e.password||e.rawPassword){e.password=e.rawPassword=null;const n=H(new o(12));n[11]=e.passwordVerification,s=new o(t.length+n.length),s.set(kt(e,n),0),r=12}else s=new o(t.length),r=0;s.set(kt(e,t),r),n.enqueue(s)}})}}function vt(t,e,s,r){n.assign(t,{password:e,rawPassword:s,passwordVerification:r}),function(t,e,s){const r=[305419896,591751049,878082192];if(n.assign(t,{keys:r,it:new R(r[0]),ft:new R(r[2])}),s)for(let n=0;n<s.length;n++)zt(t,s[n]);else for(let n=0;n<e.length;n++)zt(t,e.charCodeAt(n))}(t,e,s)}function bt(t,n){const e=new o(n.length);for(let s=0;s<n.length;s++)e[s]=Ct(t)^n[s],zt(t,e[s]);return e}function kt(t,n){const e=new o(n.length);for(let s=0;s<n.length;s++)e[s]=Ct(t)^n[s],zt(t,n[s]);return e}function zt(t,n){let[,e]=t.keys;t.it.append([n]);const r=~t.it.get();e=At(s.imul(At(e+It(r)),134775813)+1),t.ft.append([e>>>24]);const o=~t.ft.get();t.keys=[r,e,o]}function Ct(t){const n=2|t.keys[2];return It(s.imul(n,1^n)>>>8)}function It(t){return 255&t}function At(t){return 4294967295&t}function xt(t){if(t instanceof y)return t;const n=t.getReader();return new y({async pull(t){const{value:e,done:s}=await n.read();s?t.close():t.enqueue(e)},cancel:t=>n.cancel(t)})}const Mt=new f;function Pt(t){return Mt.get(t)}const Bt="Invalid uncompressed size",Dt="deflate-raw",Ft="gzip",Rt=[31,139,8];class Ut extends d{constructor(t,{chunkSize:n,CompressionStreamFallback:e,CompressionStream:s}){super({});const{compressed:r,encrypted:o,useCompressionStream:c,zipCrypto:i,computeCrc32:a,level:f,deflate64:l,format:w,compressionMethod:h,inputSize:p}=t,d=this;let y,m,S,g=super.readable;const v=w&&Pt(w),b=a&&r&&!l&&!v&&(!o||i)&&Boolean(c&&s);if(o&&!i||!a||b||(y=new U,g=Lt(g,y)),r)if(v)g=Ot(g,Kt(v.CompressionStream,w,{level:f,chunkSize:n,compressionMethod:h,uncompressedSize:p}));else if(b)S=new Wt,g=Ot(g,new s(Ft)),g=Lt(g,S);else try{g=Et(g,c,{level:f,chunkSize:n},s,e)}catch(t){let n;try{n=new s(Ft)}catch{throw t}g=Ot(g,n),g=Lt(g,new Wt)}o&&(i?g=Lt(g,new gt(t)):(m=new ut(t),g=Lt(g,m))),Vt(d,g,()=>{o&&!i||!a||(d.crc32=b?S.crc32:new u(y.value.buffer).getUint32(0))})}}class Wt extends d{constructor(){let t,n=10,e=new o(0);super({transform(t,r){if(n){const e=s.min(n,t.length);if(n-=e,!(t=t.subarray(e)).length)return}const o=e.length+t.length;if(o<=8)return void(e=W(e,t));const c=o-8,i=s.min(c,e.length);r.enqueue(W(e.subarray(0,i),t.subarray(0,c-i))),e=W(e.subarray(i),t.subarray(c-i))},flush(){const n=_(e);t.crc32=n.getUint32(0,!0),t.uncompressedSize=n.getUint32(4,!0)}}),t=this}}class _t extends d{constructor(t,{chunkSize:n,DecompressionStreamFallback:e,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=Lt(C,new St(t)):(z=new ft(t),C=Lt(C,z))),w){const t=m&&Pt(m);if(t)C=Ot(C,Kt(t.DecompressionStream,m,{chunkSize:n,compressionMethod:S,rawBitFlag:g,uncompressedSize:b}));else try{C=Et(C,h,{chunkSize:n,deflate64:p},s,e)}catch(t){if(p||b===v)throw t;let n;try{n=new s(Ft)}catch{throw t}C=function(t,n,e){const s=new R;let c,i,a,f=0,u=!1;const w=new l((t,n)=>{i=t,a=n});w.catch(()=>{}),e||i();const h=new d({start(t){const n=new o(10);n.set(Rt),t.enqueue(n)},transform(t,n){n.enqueue(t)},async flush(t){u=!0,y();try{await w}finally{m()}const n=new o(8),r=_(n);r.setUint32(0,s.get(),!0),r.setUint32(4,e,!0),t.enqueue(n)},cancel(t){a(t)}}),p=new d({transform(t,n){s.append(t),f+=t.length,f>=e?i():u&&y(),n.enqueue(t)},cancel(t){a(t)}});return t=Lt(t,h),Lt(t=Ot(t,n),p);function y(){m(),c=setTimeout(()=>a(new r(Bt)),5e3)}function m(){clearTimeout(c)}}(C,n,b)}C=function(t){const n=t.getReader();return new y({async pull(t){let e;try{e=await n.read()}catch(t){if(t&&t.message)throw t;const n=new r("Invalid compressed data");throw n.cause=t,n}const{value:s,done:o}=e;o?t.close():t.enqueue(s)},cancel:t=>n.cancel(t)})}(C)}a&&(k=new U,C=Lt(C,k)),Vt(this,C,()=>{if(a){const t=new u(k.value.buffer);if(f!=t.getUint32(0,!1))throw new r("Invalid CRC32")}})}}const Tt=new f;function Vt(t,e,s){e=Lt(e,new d({flush:s})),n.defineProperty(t,"readable",{get:()=>e})}function Kt(t,n,e){if(!t)throw new r("Compression method not supported");return new t(n,e)}function Et(t,n,e,s,r){const o=n&&s?s:r||s,c=e.deflate64?"deflate64-raw":Dt;let i;try{i=new o(c,e)}catch(t){if(!n||!r||o==r)throw t;i=new r(c,e)}return Ot(t,i)}function Lt(t,n){return xt(t).pipeThrough(n)}function Ot(t,n){const e=n.writable.getWriter(),s=t.getReader();return async function(){try{for(;;){await e.ready;const t=await s.read();if(t.done){await e.close();break}await e.write(t.value)}}catch(t){await async function(t,n){try{await t.abort(n)}catch{}}(e,t),await async function(t,n){try{await t.cancel(n)}catch{}}(s,t)}}(),n.readable}const jt="data",Ht="close",Nt="deflate";class qt extends d{constructor(t,e){super({});const s=this,{codecType:o}=t;let c;o.startsWith(Nt)?c=Ut:o.startsWith("inflate")&&(c=_t),s.outputSize=0;let i=0;const a=new c(t,e),f=super.readable,u=new d({transform(t,n){t&&t.length&&(i+=t.length,n.enqueue(t))},flush(){n.assign(s,{inputSize:i})}}),l=new d({transform(n,e){if(n&&n.length&&(e.enqueue(n),s.outputSize+=n.length,t.outputSize!==v&&s.outputSize>t.outputSize))throw new r(Bt)},flush(){const{crc32:t}=a;n.assign(s,{crc32:t,inputSize:i})}});n.defineProperty(s,"readable",{get:()=>f.pipeThrough(u).pipeThrough(a).pipeThrough(l)})}}class Gt extends d{constructor(t){const s=[];let r=0,c=0;function i(){const n=new o(t);let e=0;for(;e<t;){const r=s[0],o=t-e;r.length<=o?(n.set(r,e),e+=r.length,s.shift()):(n.set(r.subarray(0,o),e),s[0]=r.subarray(o),e+=o)}return r-=t,n}(!e.isFinite(t)||t<1)&&(t=65536),super({transform(n,e){for(s.push(n),r+=n.length;r>t;)c+=t,e.enqueue(i())},flush(t){r&&(c+=r,t.enqueue(function(t,n){const e=new o(n);let s=0;for(const n of t)e.set(n,s),s+=n.length;return e}(s,r)))}}),n.defineProperty(this,"outputSize",{get:()=>c})}}let Jt=2;try{typeof navigator!=b&&navigator.hardwareConcurrency&&(Jt=navigator.hardwareConcurrency)}catch{}const Qt=new f,Xt=new f;let Yt,Zt=0;async function $t(t){let n,o,c;try{const{options:i,config:a}=t;if(i.format)try{await async function(t,n){!Mt.has(t)&&n&&function(t,n){const{CompressionStream:e,DecompressionStream:s}=n;if(typeof e!=k&&typeof s!=k)throw new r("Invalid codec module");Mt.set(t,{CompressionStream:e,DecompressionStream:s})}(t,await(import(n)))}(i.format,i.codecURI)}catch(t){throw t.codecImportFailed=!0,t}if(a.CompressionStream=self.CompressionStream,a.DecompressionStream=self.DecompressionStream,i.compressed&&!i.format)if(i.useCompressionStream){if(!function(t,n){if(!t)return!1;let e=Tt.get(t);e||(e=new f,Tt.set(t,e));let s=e.get(n);if(s===v){try{new t(n),s=!0}catch{s=!1}e.set(n,s)}return s}(i.codecType.startsWith(Nt)?a.CompressionStream:a.DecompressionStream,Dt))try{await self.initModule(t.config)}catch{}}else try{await self.initModule(t.config)}catch{i.useCompressionStream=!0}!a.CompressionStreamFallback&&a.CompressionStreamZlib&&(a.CompressionStreamFallback=a.CompressionStreamZlib),!a.DecompressionStreamFallback&&a.DecompressionStreamZlib&&(a.DecompressionStreamFallback=a.DecompressionStreamZlib);const u={highWaterMark:1},w=t.readable?xt(t.readable):new y({async pull(t){const n=new l(t=>Qt.set(Zt,t));tn({type:"pull",messageId:Zt}),Zt=(Zt+1)%e.MAX_SAFE_INTEGER;const{value:s,done:r}=await n;t.enqueue(s),r&&t.close()}},u);c=t.writable?function(t){if(t instanceof m)return t;const n=t.getWriter();return new m({write:t=>n.write(t),close:()=>n.close(),abort:t=>n.abort(t)})}(t.writable):new m({async write(t){let n;const s=new l(t=>n=t);Xt.set(Zt,n),tn({type:jt,value:t,messageId:Zt}),Zt=(Zt+1)%e.MAX_SAFE_INTEGER,await s}},u),n=new qt(i,a),o=new Gt(function(t){return r="string"==typeof(n=r=t.chunkSize)&&n.trim()?e(n):n,e.isInteger(r)&&r>=1?s.max(r,64):65536;var n,r}(a)),Yt=new AbortController;const{signal:h}=Yt;await w.pipeThrough(n).pipeThrough(o).pipeTo(c,{signal:h,preventClose:!0,preventAbort:!0}),await c.getWriter().close();const{crc32:p,inputSize:d,outputSize:S}=n;tn({type:Ht,result:{crc32:p,inputSize:d,outputSize:S}})}catch(t){if(t.outputSize=o?o.outputSize:0,c&&!c.locked)try{await c.getWriter().close()}catch{}nn(t)}}function tn(t){const{value:n}=t;if(n)if(n.length)try{t.value=(e=n,e.byteOffset||e.byteLength!=e.buffer.byteLength?new o(e):e).buffer,p(t,[t.value])}catch{p(t)}else p(t);else p(t);var e}function nn(t=new r("Unknown error")){const{message:n,stack:e,code:s,name:o,outputSize:c,cause:i,codecImportFailed:a}=t,f={message:n,stack:e,code:s,name:o,outputSize:c};i&&(f.cause={name:i.name,message:i.message}),a&&(f.codecImportFailed=!0),p({error:f})}addEventListener("message",({data:t})=>{const{type:n,messageId:e,value:s,done:r}=t;try{if("start"==n&&$t(t),n==jt){const t=Qt.get(e);Qt.delete(e),t({value:s||new o,done:r})}if("ack"==n){const t=Xt.get(e);Xt.delete(e),t()}n==Ht&&Yt.abort()}catch(t){nn(t)}}),p({type:"ready"});const en="deflate",sn="deflate-raw",rn="deflate64-raw",on="gzip";let cn,an,fn,un,ln;function wn(t,n,e={}){if(!cn){const t=new r("WASM module not loaded");throw t.cause=ln,t}const c="number"==typeof e.level?e.level:-1,i="number"==typeof e.outBuffer?e.outBuffer:65536,a="number"==typeof e.inBufferSize?e.inBufferSize:65536;return new d({start(){try{let e;if(this.ut=an(i),this.in=an(a),this.inBufferSize=a,!this.ut||!this.in)throw new r("allocation failed");if(this.lt=new o(i),t?(this.wt=cn.deflate_process,this.ht=cn.deflate_last_consumed,this.yt=cn.deflate_end,this.St=cn.deflate_new(),e=n===on?cn.deflate_init_gzip(this.St,c):n===sn?cn.deflate_init_raw(this.St,c):cn.deflate_init(this.St,c)):n===rn?(this.wt=cn.inflate9_process,this.ht=cn.inflate9_last_consumed,this.yt=cn.inflate9_end,this.St=cn.inflate9_new(),e=cn.inflate9_init_raw(this.St)):(this.wt=cn.inflate_process,this.ht=cn.inflate_last_consumed,this.yt=cn.inflate_end,this.St=cn.inflate_new(),e=n===sn?cn.inflate_init_raw(this.St):n===on?cn.inflate_init_gzip(this.St):cn.inflate_init(this.St)),0!==e)throw new r("init failed:"+e)}catch(t){throw f(this),t}},transform(t,n){try{const e=t,c=new o(un.buffer),a=this.wt,f=this.ht,u=this.ut,l=this.lt;let w=0;for(;w<e.length;){const t=s.min(e.length-w,32768);if((!this.in||this.inBufferSize<t)&&(this.in&&fn&&(fn(this.in),this.in=0),this.in=an(t),this.inBufferSize=t,!this.in))throw new r("allocation failed");c.set(e.subarray(w,w+t),this.in);const o=a(this.St,this.in,t,u,i,0),h=o>>24&255,p=128&h?h-256:h;if(p<0)throw new r("process error:"+p);const d=16777215&o;d&&(l.set(c.subarray(u,u+d),0),n.enqueue(l.slice(0,d)));const y=f(this.St);if(0===y&&0===d)break;w+=y}}catch(t){f(this),n.error(t)}},flush(t){try{const n=new o(un.buffer),e=this.wt,s=this.ut,c=this.lt;for(;;){const o=e(this.St,0,0,s,i,4),a=o>>24&255,f=128&a?a-256:a;if(f<0)throw new r("process error:"+f);const u=16777215&o;if(u&&(c.set(n.subarray(s,s+u),0),t.enqueue(c.slice(0,u))),1===a||0===u)break}}catch(n){t.error(n)}finally{const n=f(this);0!==n&&t.error(new r("end error:"+n))}},cancel(){f(this)}});function f(t){let n=0;return t.St&&t.yt&&(n=t.yt(t.St)),t.St=0,t.in&&fn&&fn(t.in),t.in=0,t.ut&&fn&&fn(t.ut),t.ut=0,n}}class hn{constructor(t=en,n){return wn(!0,t,n)}}class pn{constructor(t=en,n){return wn(!1,t,n)}}hn.gt=!0,pn.gt=!0,hn.vt=[en,sn,on],pn.vt=[en,sn,on,rn];let dn=!1;!function(t={}){const{init:n}=t,e=t.CompressionStreamFallback||t.CompressionStreamZlib,s=t.DecompressionStreamFallback||t.DecompressionStreamZlib;self.initModule=async t=>{n&&await n(t),e&&(t.CompressionStreamFallback=e),s&&(t.DecompressionStreamFallback=s)}}({CompressionStreamFallback:hn,DecompressionStreamFallback:pn,init:t=>async function(t,{baseURI:n}){if(!dn)try{await async function(t,n){let e,s;try{try{s=new URL(t,n)}catch{}const r=await fetch(s);e=await r.arrayBuffer()}catch(n){if(!t.startsWith("data:application/wasm;base64,"))throw n;e=function(t){const n=t.split(",")[1],e=atob(n),s=e.length,r=new o(s);for(let t=0;t<s;++t)r[t]=e.charCodeAt(t);return r.buffer}(t)}!function(t){if(cn=t,({malloc:an,free:fn,memory:un}=cn),"function"!=typeof an||"function"!=typeof fn||!un)throw cn=an=fn=un=null,new r("Invalid WASM module")}((await WebAssembly.instantiate(e)).instance.exports)}(t,n),dn=!0}catch(t){throw function(t){ln=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,"+function(t){let n="";const s=t.length;let r=0;for(;r+2<s;r+=3){const s=t[r]<<16|t[r+1]<<8|t[r+2];n+=e$1[s>>18&63]+e$1[s>>12&63]+e$1[s>>6&63]+e$1[63&s];}const o=s-r;if(1===o){const s=t[r]<<16;n+=e$1[s>>18&63]+e$1[s>>12&63]+"==";}else if(2===o){const s=t[r]<<16|t[r+1]<<8;n+=e$1[s>>18&63]+e$1[s>>12&63]+e$1[s>>6&63]+"=";}return n}(s)}});
|
|
418
449
|
|
|
419
450
|
/*
|
|
420
451
|
Copyright (c) 2026 Gildas Lormeau. All rights reserved.
|
|
@@ -2599,6 +2630,7 @@
|
|
|
2599
2630
|
constructor(chunkSize) {
|
|
2600
2631
|
const pendingChunks = [];
|
|
2601
2632
|
let pendingLength = 0;
|
|
2633
|
+
let outputSize = 0;
|
|
2602
2634
|
if (!Number.isFinite(chunkSize) || chunkSize < 1) {
|
|
2603
2635
|
chunkSize = DEFAULT_CHUNK_SIZE;
|
|
2604
2636
|
}
|
|
@@ -2607,15 +2639,20 @@
|
|
|
2607
2639
|
pendingChunks.push(chunk);
|
|
2608
2640
|
pendingLength += chunk.length;
|
|
2609
2641
|
while (pendingLength > chunkSize) {
|
|
2642
|
+
outputSize += chunkSize;
|
|
2610
2643
|
controller.enqueue(shiftChunk());
|
|
2611
2644
|
}
|
|
2612
2645
|
},
|
|
2613
2646
|
flush(controller) {
|
|
2614
2647
|
if (pendingLength) {
|
|
2648
|
+
outputSize += pendingLength;
|
|
2615
2649
|
controller.enqueue(concatChunks(pendingChunks, pendingLength));
|
|
2616
2650
|
}
|
|
2617
2651
|
}
|
|
2618
2652
|
});
|
|
2653
|
+
Object.defineProperty(this, "outputSize", {
|
|
2654
|
+
get: () => outputSize
|
|
2655
|
+
});
|
|
2619
2656
|
|
|
2620
2657
|
function shiftChunk() {
|
|
2621
2658
|
const result = new Uint8Array(chunkSize);
|
|
@@ -2820,7 +2857,7 @@
|
|
|
2820
2857
|
}
|
|
2821
2858
|
|
|
2822
2859
|
async function runWorker$1({ options, readable, writable, onTaskFinished }, config) {
|
|
2823
|
-
let codecStream;
|
|
2860
|
+
let codecStream, chunkStream;
|
|
2824
2861
|
try {
|
|
2825
2862
|
if (options.compressed && !options.format) {
|
|
2826
2863
|
const deflate = options.codecType.startsWith(CODEC_DEFLATE);
|
|
@@ -2843,9 +2880,10 @@
|
|
|
2843
2880
|
}
|
|
2844
2881
|
}
|
|
2845
2882
|
codecStream = new CodecStream(options, config);
|
|
2883
|
+
chunkStream = new ChunkStream(getChunkSize(config));
|
|
2846
2884
|
await readable
|
|
2847
2885
|
.pipeThrough(codecStream)
|
|
2848
|
-
.pipeThrough(
|
|
2886
|
+
.pipeThrough(chunkStream)
|
|
2849
2887
|
.pipeTo(writable, { preventClose: true, preventAbort: true });
|
|
2850
2888
|
const {
|
|
2851
2889
|
crc32,
|
|
@@ -2859,7 +2897,7 @@
|
|
|
2859
2897
|
};
|
|
2860
2898
|
} catch (error) {
|
|
2861
2899
|
if (codecStream) {
|
|
2862
|
-
error.outputSize =
|
|
2900
|
+
error.outputSize = chunkStream ? chunkStream.outputSize : 0;
|
|
2863
2901
|
}
|
|
2864
2902
|
throw error;
|
|
2865
2903
|
} finally {
|
|
@@ -2968,11 +3006,17 @@
|
|
|
2968
3006
|
let resolveResult, rejectResult;
|
|
2969
3007
|
const result = new Promise((resolve, reject) => {
|
|
2970
3008
|
resolveResult = resolve;
|
|
2971
|
-
rejectResult =
|
|
3009
|
+
rejectResult = error => {
|
|
3010
|
+
if (error && error.outputSize === UNDEFINED_VALUE) {
|
|
3011
|
+
error.outputSize = workerData.outputSize;
|
|
3012
|
+
}
|
|
3013
|
+
reject(error);
|
|
3014
|
+
};
|
|
2972
3015
|
});
|
|
2973
3016
|
Object.assign(workerData, {
|
|
2974
3017
|
reader: null,
|
|
2975
3018
|
writer: null,
|
|
3019
|
+
outputSize: 0,
|
|
2976
3020
|
resolveResult,
|
|
2977
3021
|
rejectResult,
|
|
2978
3022
|
result
|
|
@@ -3256,8 +3300,10 @@
|
|
|
3256
3300
|
}
|
|
3257
3301
|
}
|
|
3258
3302
|
if (type == MESSAGE_DATA) {
|
|
3303
|
+
const chunk = new Uint8Array(value);
|
|
3259
3304
|
await writer.ready;
|
|
3260
|
-
await writer.write(
|
|
3305
|
+
await writer.write(chunk);
|
|
3306
|
+
workerData.outputSize += chunk.length;
|
|
3261
3307
|
if (!stale()) {
|
|
3262
3308
|
sendMessage({ type: MESSAGE_ACK_DATA, messageId }, workerData);
|
|
3263
3309
|
}
|
|
@@ -3565,10 +3611,13 @@
|
|
|
3565
3611
|
|
|
3566
3612
|
|
|
3567
3613
|
const ERR_HTTP_STATUS = "HTTP error ";
|
|
3614
|
+
const MIN_SUCCESS_HTTP_STATUS = 200;
|
|
3615
|
+
const MAX_SUCCESS_HTTP_STATUS = 299;
|
|
3568
3616
|
const ERR_HTTP_RANGE = "HTTP Range not supported";
|
|
3569
3617
|
const ERR_HTTP_RESOURCE_CHANGED = "HTTP resource changed";
|
|
3570
3618
|
const ERR_ITERATOR_COMPLETED_TOO_SOON = "Writer iterator completed too soon";
|
|
3571
3619
|
const ERR_WRITER_NOT_INITIALIZED = "Writer not initialized";
|
|
3620
|
+
const ERR_WRITER_SIZE_NOT_WRITABLE = "Invalid writer (size must be writable)";
|
|
3572
3621
|
|
|
3573
3622
|
const CONTENT_TYPE_TEXT_PLAIN = "text/plain";
|
|
3574
3623
|
const HTTP_HEADER_CONTENT_LENGTH = "Content-Length";
|
|
@@ -3760,11 +3809,14 @@
|
|
|
3760
3809
|
const reader = this;
|
|
3761
3810
|
const { sourceBlob, size } = reader;
|
|
3762
3811
|
const { offset = 0, size: readSize = size - offset } = options || {};
|
|
3763
|
-
|
|
3764
|
-
|
|
3765
|
-
|
|
3766
|
-
|
|
3767
|
-
|
|
3812
|
+
// deno-lint-ignore valid-typeof
|
|
3813
|
+
if (typeof sourceBlob.stream == FUNCTION_TYPE) {
|
|
3814
|
+
if (!offset && readSize >= size) {
|
|
3815
|
+
return toCompatibleReadable(sourceBlob.stream());
|
|
3816
|
+
}
|
|
3817
|
+
if (blobSliceReliable) {
|
|
3818
|
+
return toCompatibleReadable(sourceBlob.slice(offset, offset + readSize).stream());
|
|
3819
|
+
}
|
|
3768
3820
|
}
|
|
3769
3821
|
return super.createReadable(options);
|
|
3770
3822
|
}
|
|
@@ -4144,7 +4196,7 @@
|
|
|
4144
4196
|
|
|
4145
4197
|
async function sendFetchRequest(method, { fetch: fetchFunction = fetch, options, url }, headers) {
|
|
4146
4198
|
const response = await fetchFunction(url, Object.assign({}, options, { method, headers }));
|
|
4147
|
-
if (response.status
|
|
4199
|
+
if (response.status >= MIN_SUCCESS_HTTP_STATUS && response.status <= MAX_SUCCESS_HTTP_STATUS) {
|
|
4148
4200
|
return response;
|
|
4149
4201
|
} else {
|
|
4150
4202
|
throw response.status == 416 ? new Error(ERR_HTTP_RANGE) : new Error(ERR_HTTP_STATUS + (response.statusText || response.status));
|
|
@@ -4155,7 +4207,7 @@
|
|
|
4155
4207
|
return new Promise((resolve, reject) => {
|
|
4156
4208
|
const request = new XMLHttpRequest();
|
|
4157
4209
|
request.addEventListener("load", () => {
|
|
4158
|
-
if (request.status
|
|
4210
|
+
if (request.status >= MIN_SUCCESS_HTTP_STATUS && request.status <= MAX_SUCCESS_HTTP_STATUS) {
|
|
4159
4211
|
const headers = [];
|
|
4160
4212
|
request.getAllResponseHeaders().trim().split(/[\r\n]+/).forEach(header => {
|
|
4161
4213
|
const splitHeader = header.trim().split(/\s*:\s*/);
|
|
@@ -4459,8 +4511,10 @@
|
|
|
4459
4511
|
writable: toCompatibleWritable(writer)
|
|
4460
4512
|
};
|
|
4461
4513
|
}
|
|
4462
|
-
|
|
4463
|
-
writer.size = 0;
|
|
4514
|
+
try {
|
|
4515
|
+
writer.size = writer.size === UNDEFINED_VALUE ? 0 : writer.size;
|
|
4516
|
+
} catch {
|
|
4517
|
+
throw new Error(ERR_WRITER_SIZE_NOT_WRITABLE);
|
|
4464
4518
|
}
|
|
4465
4519
|
return writer;
|
|
4466
4520
|
}
|
|
@@ -4508,6 +4562,45 @@
|
|
|
4508
4562
|
}
|
|
4509
4563
|
}
|
|
4510
4564
|
|
|
4565
|
+
/*
|
|
4566
|
+
Copyright (c) 2026 Gildas Lormeau. All rights reserved.
|
|
4567
|
+
|
|
4568
|
+
Redistribution and use in source and binary forms, with or without
|
|
4569
|
+
modification, are permitted provided that the following conditions are met:
|
|
4570
|
+
|
|
4571
|
+
1. Redistributions of source code must retain the above copyright notice,
|
|
4572
|
+
this list of conditions and the following disclaimer.
|
|
4573
|
+
|
|
4574
|
+
2. Redistributions in binary form must reproduce the above copyright
|
|
4575
|
+
notice, this list of conditions and the following disclaimer in
|
|
4576
|
+
the documentation and/or other materials provided with the distribution.
|
|
4577
|
+
|
|
4578
|
+
3. The names of the authors may not be used to endorse or promote products
|
|
4579
|
+
derived from this software without specific prior written permission.
|
|
4580
|
+
|
|
4581
|
+
THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
|
4582
|
+
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
4583
|
+
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
|
|
4584
|
+
INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
4585
|
+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
4586
|
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
|
4587
|
+
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
4588
|
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
4589
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
|
4590
|
+
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
4591
|
+
*/
|
|
4592
|
+
|
|
4593
|
+
|
|
4594
|
+
function addWarning(warnings, reason, filename) {
|
|
4595
|
+
if (!warnings.some(warning => warning.reason == reason)) {
|
|
4596
|
+
const warning = { reason };
|
|
4597
|
+
if (filename !== UNDEFINED_VALUE) {
|
|
4598
|
+
warning.filename = filename;
|
|
4599
|
+
}
|
|
4600
|
+
warnings.push(warning);
|
|
4601
|
+
}
|
|
4602
|
+
}
|
|
4603
|
+
|
|
4511
4604
|
/*
|
|
4512
4605
|
Copyright (c) 2025 Gildas Lormeau. All rights reserved.
|
|
4513
4606
|
|
|
@@ -4536,6 +4629,7 @@
|
|
|
4536
4629
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
4537
4630
|
*/
|
|
4538
4631
|
|
|
4632
|
+
|
|
4539
4633
|
const PROPERTY_NAME_FILENAME = "filename";
|
|
4540
4634
|
const PROPERTY_NAME_RAW_FILENAME = "rawFilename";
|
|
4541
4635
|
const PROPERTY_NAME_COMMENT = "comment";
|
|
@@ -4660,6 +4754,38 @@
|
|
|
4660
4754
|
|
|
4661
4755
|
}
|
|
4662
4756
|
|
|
4757
|
+
const INTERPRETED_EXTRA_FIELD_TYPES = new Set([
|
|
4758
|
+
EXTRAFIELD_TYPE_ZIP64,
|
|
4759
|
+
EXTRAFIELD_TYPE_AES,
|
|
4760
|
+
EXTRAFIELD_TYPE_NTFS,
|
|
4761
|
+
EXTRAFIELD_TYPE_EXTENDED_TIMESTAMP,
|
|
4762
|
+
EXTRAFIELD_TYPE_UNICODE_PATH,
|
|
4763
|
+
EXTRAFIELD_TYPE_UNICODE_COMMENT,
|
|
4764
|
+
EXTRAFIELD_TYPE_USDZ,
|
|
4765
|
+
EXTRAFIELD_TYPE_INFOZIP,
|
|
4766
|
+
EXTRAFIELD_TYPE_UNIX,
|
|
4767
|
+
EXTRAFIELD_TYPE_UNIX_TYPE1,
|
|
4768
|
+
EXTRAFIELD_TYPE_PKWARE_UNIX
|
|
4769
|
+
]);
|
|
4770
|
+
|
|
4771
|
+
function getUserExtraField(extraField) {
|
|
4772
|
+
if (extraField) {
|
|
4773
|
+
const userExtraField = new Map();
|
|
4774
|
+
extraField.forEach((field, type) => {
|
|
4775
|
+
if (!INTERPRETED_EXTRA_FIELD_TYPES.has(type)) {
|
|
4776
|
+
userExtraField.set(type, field.data);
|
|
4777
|
+
}
|
|
4778
|
+
});
|
|
4779
|
+
if (userExtraField.size) {
|
|
4780
|
+
return userExtraField;
|
|
4781
|
+
}
|
|
4782
|
+
}
|
|
4783
|
+
}
|
|
4784
|
+
|
|
4785
|
+
function getEncryptionOverhead(encrypted, zipCrypto, encryptionStrength) {
|
|
4786
|
+
return encrypted ? (zipCrypto ? 12 : 16 + encryptionStrength * 4) : 0;
|
|
4787
|
+
}
|
|
4788
|
+
|
|
4663
4789
|
/*
|
|
4664
4790
|
Copyright (c) 2025 Gildas Lormeau. All rights reserved.
|
|
4665
4791
|
|
|
@@ -4719,6 +4845,8 @@
|
|
|
4719
4845
|
const WARNING_TRAILING_CENTRAL_DIRECTORY_DATA = "trailing central directory data";
|
|
4720
4846
|
const WARNING_DUPLICATE_FILENAME = "duplicate filename";
|
|
4721
4847
|
const WARNING_MISMATCHED_ZIP64_END_OF_CENTRAL_DIRECTORY = "mismatched zip64 end of central directory record";
|
|
4848
|
+
const WARNING_MULTIPLE_END_OF_CENTRAL_DIRECTORY = "multiple end of central directory records";
|
|
4849
|
+
const WARNING_MISMATCHED_LOCAL_FILE_HEADER_FILENAME = "mismatched local file header (filename)";
|
|
4722
4850
|
const WARNING_MISMATCHED_LOCAL_FILE_HEADER_BIT_FLAG = "mismatched local file header (general purpose bit flag)";
|
|
4723
4851
|
const WARNING_MISMATCHED_LOCAL_FILE_HEADER_COMPRESSION_METHOD = "mismatched local file header (compression method)";
|
|
4724
4852
|
const WARNING_MISMATCHED_LOCAL_FILE_HEADER_CRC32_OR_SIZES = "mismatched local file header (crc32 or sizes)";
|
|
@@ -4789,7 +4917,7 @@
|
|
|
4789
4917
|
}
|
|
4790
4918
|
}
|
|
4791
4919
|
if (rejectAmbiguousEndOfDirectory && endOfDirectoryReachingEndCount > 1) {
|
|
4792
|
-
throwAmbiguousArchive(
|
|
4920
|
+
throwAmbiguousArchive(WARNING_MULTIPLE_END_OF_CENTRAL_DIRECTORY);
|
|
4793
4921
|
}
|
|
4794
4922
|
const endOfDirectoryView = getDataView(endOfDirectoryInfo);
|
|
4795
4923
|
let directoryDataLength = getUint32$1(endOfDirectoryView, 12);
|
|
@@ -5087,7 +5215,8 @@
|
|
|
5087
5215
|
const writer = new TransformStream();
|
|
5088
5216
|
const arrayBufferPromise = streamToBlob(writer.readable).then(blob => blob.arrayBuffer());
|
|
5089
5217
|
arrayBufferPromise.catch(() => { });
|
|
5090
|
-
await fileEntry.getData(writer, entry, zipReader.readRanges,
|
|
5218
|
+
await fileEntry.getData(writer, entry, zipReader.readRanges,
|
|
5219
|
+
Object.assign({}, options, { preventClose: false }));
|
|
5091
5220
|
return arrayBufferPromise;
|
|
5092
5221
|
};
|
|
5093
5222
|
offset = endOffset;
|
|
@@ -5168,48 +5297,101 @@
|
|
|
5168
5297
|
await reader.readable.cancel();
|
|
5169
5298
|
}
|
|
5170
5299
|
}
|
|
5300
|
+
|
|
5301
|
+
[SYMBOL_ASYNC_DISPOSE]() {
|
|
5302
|
+
return this.close();
|
|
5303
|
+
}
|
|
5171
5304
|
}
|
|
5172
5305
|
|
|
5173
5306
|
class ZipReaderStream {
|
|
5174
5307
|
|
|
5175
5308
|
constructor(options = {}) {
|
|
5176
|
-
|
|
5177
|
-
const
|
|
5309
|
+
let sourceController;
|
|
5310
|
+
const { readable, writable } = new TransformStream({
|
|
5311
|
+
start(controller) {
|
|
5312
|
+
sourceController = controller;
|
|
5313
|
+
}
|
|
5314
|
+
});
|
|
5315
|
+
const zipReader = new ZipReader(readable, options);
|
|
5316
|
+
const gen = zipReader.getEntriesGenerator();
|
|
5317
|
+
const pendingEntries = new Set();
|
|
5178
5318
|
this.readable = new ReadableStream({
|
|
5179
5319
|
async pull(controller) {
|
|
5180
5320
|
const { done, value } = await gen.next();
|
|
5181
5321
|
if (done)
|
|
5182
5322
|
return controller.close();
|
|
5323
|
+
const entryStream = createEntryStream(value, pendingEntries);
|
|
5183
5324
|
const chunk = {
|
|
5184
5325
|
...value,
|
|
5185
|
-
readable:
|
|
5186
|
-
const { readable, writable } = new TransformStream();
|
|
5187
|
-
if (value.getData) {
|
|
5188
|
-
getData();
|
|
5189
|
-
return readable;
|
|
5190
|
-
}
|
|
5191
|
-
|
|
5192
|
-
async function getData() {
|
|
5193
|
-
try {
|
|
5194
|
-
await value.getData(writable);
|
|
5195
|
-
} catch (error) {
|
|
5196
|
-
try {
|
|
5197
|
-
await writable.abort(error);
|
|
5198
|
-
} catch {
|
|
5199
|
-
// ignored
|
|
5200
|
-
}
|
|
5201
|
-
}
|
|
5202
|
-
}
|
|
5203
|
-
})()
|
|
5326
|
+
readable: entryStream.readable
|
|
5204
5327
|
};
|
|
5205
5328
|
delete chunk.getData;
|
|
5329
|
+
Object.defineProperties(chunk, {
|
|
5330
|
+
localDirectory: {
|
|
5331
|
+
get: () => value.localDirectory,
|
|
5332
|
+
enumerable: true
|
|
5333
|
+
},
|
|
5334
|
+
warnings: {
|
|
5335
|
+
get: () => value.warnings,
|
|
5336
|
+
enumerable: true
|
|
5337
|
+
}
|
|
5338
|
+
});
|
|
5206
5339
|
controller.enqueue(chunk);
|
|
5340
|
+
},
|
|
5341
|
+
async cancel(reason) {
|
|
5342
|
+
const entryStreams = Array.from(pendingEntries);
|
|
5343
|
+
pendingEntries.clear();
|
|
5344
|
+
sourceController.error(reason);
|
|
5345
|
+
await Promise.allSettled(entryStreams.map(entryStream => entryStream.cancel(reason)));
|
|
5346
|
+
await Promise.allSettled([gen.return(), zipReader.close()]);
|
|
5207
5347
|
}
|
|
5208
5348
|
});
|
|
5209
5349
|
this.writable = writable;
|
|
5210
5350
|
}
|
|
5211
5351
|
}
|
|
5212
5352
|
|
|
5353
|
+
function createEntryStream(entry, pendingEntries) {
|
|
5354
|
+
const { readable, writable } = new TransformStream();
|
|
5355
|
+
let dataReader;
|
|
5356
|
+
const entryStream = {
|
|
5357
|
+
cancel: async reason => {
|
|
5358
|
+
pendingEntries.delete(entryStream);
|
|
5359
|
+
await (dataReader ? dataReader.cancel(reason) : readable.cancel(reason));
|
|
5360
|
+
}
|
|
5361
|
+
};
|
|
5362
|
+
entryStream.readable = new ReadableStream({
|
|
5363
|
+
async pull(controller) {
|
|
5364
|
+
if (!dataReader) {
|
|
5365
|
+
dataReader = readable.getReader();
|
|
5366
|
+
pendingEntries.add(entryStream);
|
|
5367
|
+
getData();
|
|
5368
|
+
}
|
|
5369
|
+
const { done, value } = await dataReader.read();
|
|
5370
|
+
if (done) {
|
|
5371
|
+
controller.close();
|
|
5372
|
+
} else {
|
|
5373
|
+
controller.enqueue(value);
|
|
5374
|
+
}
|
|
5375
|
+
},
|
|
5376
|
+
cancel: reason => entryStream.cancel(reason)
|
|
5377
|
+
}, { highWaterMark: 0 });
|
|
5378
|
+
return entryStream;
|
|
5379
|
+
|
|
5380
|
+
async function getData() {
|
|
5381
|
+
try {
|
|
5382
|
+
await entry.getData(writable, { preventClose: false });
|
|
5383
|
+
} catch (error) {
|
|
5384
|
+
try {
|
|
5385
|
+
await writable.abort(error);
|
|
5386
|
+
} catch {
|
|
5387
|
+
// ignored
|
|
5388
|
+
}
|
|
5389
|
+
} finally {
|
|
5390
|
+
pendingEntries.delete(entryStream);
|
|
5391
|
+
}
|
|
5392
|
+
}
|
|
5393
|
+
}
|
|
5394
|
+
|
|
5213
5395
|
async function isZipFile(reader, options = {}) {
|
|
5214
5396
|
reader = new GenericReader(reader);
|
|
5215
5397
|
await initStream(reader);
|
|
@@ -5269,7 +5451,9 @@
|
|
|
5269
5451
|
const dataView = getDataView(dataArray);
|
|
5270
5452
|
let password = getOptionValue$1(zipEntry, options, OPTION_PASSWORD);
|
|
5271
5453
|
let rawPassword = getOptionValue$1(zipEntry, options, OPTION_RAW_PASSWORD);
|
|
5272
|
-
const passThrough = getOptionValue$1(zipEntry, options, OPTION_PASS_THROUGH);
|
|
5454
|
+
const passThrough = checkPassThroughOption(getOptionValue$1(zipEntry, options, OPTION_PASS_THROUGH));
|
|
5455
|
+
const passThroughCompression = Boolean(passThrough);
|
|
5456
|
+
const passThroughEncryption = passThrough === true;
|
|
5273
5457
|
checkPasswordOption(password, rawPassword);
|
|
5274
5458
|
password = password && password.length && password;
|
|
5275
5459
|
rawPassword = rawPassword && rawPassword.length && rawPassword;
|
|
@@ -5290,7 +5474,9 @@
|
|
|
5290
5474
|
const checkLocalDirectoryOption = getOptionValue$1(zipEntry, options, OPTION_CHECK_LOCAL_DIRECTORY);
|
|
5291
5475
|
const entryStrictness = getStrictness(options, zipEntry.options);
|
|
5292
5476
|
const checkLocalDirectory = getCheckLocalDirectory(checkLocalDirectoryOption, entryStrictness);
|
|
5293
|
-
const
|
|
5477
|
+
const checkLocalFilenameOption = getOptionValue$1(zipEntry, options, OPTION_CHECK_LOCAL_FILENAME);
|
|
5478
|
+
const checkLocalFilename = getCheckLocalFilename(
|
|
5479
|
+
checkLocalFilenameOption === UNDEFINED_VALUE ? checkLocalDirectoryOption : checkLocalFilenameOption, entryStrictness);
|
|
5294
5480
|
let rawLocalFilename = EMPTY_UINT8_ARRAY;
|
|
5295
5481
|
if (checkLocalFilename && (filenameLength || extraFieldLength)) {
|
|
5296
5482
|
const trailingDataArray = await readUint8Array(reader, localHeaderOffset + HEADER_SIZE, filenameLength + extraFieldLength);
|
|
@@ -5321,16 +5507,17 @@
|
|
|
5321
5507
|
if (gid !== UNDEFINED_VALUE && fileEntry.gid === UNDEFINED_VALUE) {
|
|
5322
5508
|
fileEntry.gid = gid;
|
|
5323
5509
|
}
|
|
5324
|
-
const
|
|
5510
|
+
const checkPasswordOnly = getOptionValue$1(zipEntry, options, OPTION_CHECK_PASSWORD_ONLY);
|
|
5511
|
+
const encrypted = zipEntry.encrypted && localDirectory.encrypted && (!passThroughEncryption || checkPasswordOnly);
|
|
5325
5512
|
const zipCrypto = encrypted && !extraFieldAES;
|
|
5326
|
-
if (!
|
|
5513
|
+
if (!passThroughEncryption) {
|
|
5327
5514
|
fileEntry.zipCrypto = zipCrypto;
|
|
5328
5515
|
}
|
|
5329
5516
|
if (encrypted && (localDirectory.rawBitFlag & BITFLAG_STRONG_ENCRYPTION) == BITFLAG_STRONG_ENCRYPTION) {
|
|
5330
5517
|
throw new Error(ERR_UNSUPPORTED_ENCRYPTION);
|
|
5331
5518
|
}
|
|
5332
|
-
const registeredCodec =
|
|
5333
|
-
if (compressionMethod != COMPRESSION_METHOD_STORE && compressionMethod != COMPRESSION_METHOD_DEFLATE && compressionMethod != COMPRESSION_METHOD_DEFLATE_64 && !registeredCodec && !
|
|
5519
|
+
const registeredCodec = passThroughCompression ? UNDEFINED_VALUE : getRegisteredCodec(compressionMethod);
|
|
5520
|
+
if (compressionMethod != COMPRESSION_METHOD_STORE && compressionMethod != COMPRESSION_METHOD_DEFLATE && compressionMethod != COMPRESSION_METHOD_DEFLATE_64 && !registeredCodec && !passThroughCompression) {
|
|
5334
5521
|
throw new Error(ERR_UNSUPPORTED_COMPRESSION);
|
|
5335
5522
|
}
|
|
5336
5523
|
if (encrypted) {
|
|
@@ -5346,15 +5533,17 @@
|
|
|
5346
5533
|
const size = compressedSize;
|
|
5347
5534
|
const readable = toCompatibleReadable(reader.createReadable({ offset: dataOffset, size }));
|
|
5348
5535
|
const signal = checkSignalOption(getOptionValue$1(zipEntry, options, OPTION_SIGNAL));
|
|
5349
|
-
|
|
5536
|
+
throwIfAborted(signal);
|
|
5350
5537
|
let checkOverlappingEntry = getOptionValue$1(zipEntry, options, OPTION_CHECK_OVERLAPPING_ENTRY);
|
|
5351
5538
|
const checkOverlappingEntryOnly = getOptionValue$1(zipEntry, options, OPTION_CHECK_OVERLAPPING_ENTRY_ONLY);
|
|
5352
5539
|
if (checkOverlappingEntryOnly) {
|
|
5353
5540
|
checkOverlappingEntry = true;
|
|
5354
5541
|
}
|
|
5355
5542
|
const { onstart, onprogress, onend } = options;
|
|
5356
|
-
const compressed = compressionMethod != COMPRESSION_METHOD_STORE && !
|
|
5357
|
-
const outputSize =
|
|
5543
|
+
const compressed = compressionMethod != COMPRESSION_METHOD_STORE && !passThroughCompression;
|
|
5544
|
+
const outputSize = passThroughCompression ?
|
|
5545
|
+
compressedSize - getEncryptionOverhead(encrypted, zipCrypto, extraFieldAES && extraFieldAES.strength) :
|
|
5546
|
+
uncompressedSize;
|
|
5358
5547
|
const deflate64 = compressionMethod == COMPRESSION_METHOD_DEFLATE_64;
|
|
5359
5548
|
let useCompressionStream = getOptionValue$1(zipEntry, options, OPTION_USE_COMPRESSION_STREAM);
|
|
5360
5549
|
if (deflate64) {
|
|
@@ -5363,7 +5552,7 @@
|
|
|
5363
5552
|
const checkCrc32Option = getOptionValue$1(zipEntry, options, OPTION_CHECK_CRC32);
|
|
5364
5553
|
const checkCrc32 = (checkCrc32Option === UNDEFINED_VALUE ?
|
|
5365
5554
|
getOptionValue$1(zipEntry, options, OPTION_CHECK_SIGNATURE) :
|
|
5366
|
-
checkCrc32Option) && !
|
|
5555
|
+
checkCrc32Option) && !passThroughCompression &&
|
|
5367
5556
|
(!encrypted || zipCrypto || (extraFieldAES && extraFieldAES.vendorVersion == VENDOR_VERSION_AE_1$1));
|
|
5368
5557
|
const workerOptions = {
|
|
5369
5558
|
options: {
|
|
@@ -5417,10 +5606,10 @@
|
|
|
5417
5606
|
await initStream(writer, getDecodableOutputSize(outputSize, compressedSize, compressed));
|
|
5418
5607
|
({ writable } = writer);
|
|
5419
5608
|
const { outputSize: writtenSize } = await runWorker({ readable, writable }, workerOptions);
|
|
5420
|
-
writer.size += writtenSize;
|
|
5421
5609
|
if (writtenSize != outputSize) {
|
|
5422
|
-
throw new Error(ERR_INVALID_UNCOMPRESSED_SIZE);
|
|
5610
|
+
throw Object.assign(new Error(ERR_INVALID_UNCOMPRESSED_SIZE), { outputSize: writtenSize });
|
|
5423
5611
|
}
|
|
5612
|
+
writer.size += writtenSize;
|
|
5424
5613
|
}
|
|
5425
5614
|
} catch (error) {
|
|
5426
5615
|
if (error.outputSize !== UNDEFINED_VALUE) {
|
|
@@ -6086,7 +6275,7 @@
|
|
|
6086
6275
|
if (checkLocalFilename && !maskedLocalDirectory &&
|
|
6087
6276
|
(rawLocalFilename.length != rawFilename.length ||
|
|
6088
6277
|
rawLocalFilename.some((byteValue, indexByte) => byteValue != rawFilename[indexByte]))) {
|
|
6089
|
-
reportAmbiguity(reject, warnings,
|
|
6278
|
+
reportAmbiguity(reject, warnings, WARNING_MISMATCHED_LOCAL_FILE_HEADER_FILENAME);
|
|
6090
6279
|
}
|
|
6091
6280
|
if ((localDirectory.rawBitFlag & BITFLAG_AMBIGUITY_MASK) != (zipEntry.rawBitFlag & BITFLAG_AMBIGUITY_MASK)) {
|
|
6092
6281
|
reportAmbiguity(reject, warnings, WARNING_MISMATCHED_LOCAL_FILE_HEADER_BIT_FLAG);
|
|
@@ -6111,16 +6300,6 @@
|
|
|
6111
6300
|
}
|
|
6112
6301
|
}
|
|
6113
6302
|
|
|
6114
|
-
function addWarning(warnings, reason, filename) {
|
|
6115
|
-
if (!warnings.some(warning => warning.reason == reason)) {
|
|
6116
|
-
const warning = { reason };
|
|
6117
|
-
if (filename !== UNDEFINED_VALUE) {
|
|
6118
|
-
warning.filename = filename;
|
|
6119
|
-
}
|
|
6120
|
-
warnings.push(warning);
|
|
6121
|
-
}
|
|
6122
|
-
}
|
|
6123
|
-
|
|
6124
6303
|
function throwAmbiguousArchive(reason) {
|
|
6125
6304
|
const error = new Error(ERR_AMBIGUOUS_ARCHIVE);
|
|
6126
6305
|
error.reason = reason;
|
|
@@ -6200,7 +6379,9 @@
|
|
|
6200
6379
|
WARNING_MISMATCHED_LOCAL_FILE_HEADER_BIT_FLAG: WARNING_MISMATCHED_LOCAL_FILE_HEADER_BIT_FLAG,
|
|
6201
6380
|
WARNING_MISMATCHED_LOCAL_FILE_HEADER_COMPRESSION_METHOD: WARNING_MISMATCHED_LOCAL_FILE_HEADER_COMPRESSION_METHOD,
|
|
6202
6381
|
WARNING_MISMATCHED_LOCAL_FILE_HEADER_CRC32_OR_SIZES: WARNING_MISMATCHED_LOCAL_FILE_HEADER_CRC32_OR_SIZES,
|
|
6382
|
+
WARNING_MISMATCHED_LOCAL_FILE_HEADER_FILENAME: WARNING_MISMATCHED_LOCAL_FILE_HEADER_FILENAME,
|
|
6203
6383
|
WARNING_MISMATCHED_ZIP64_END_OF_CENTRAL_DIRECTORY: WARNING_MISMATCHED_ZIP64_END_OF_CENTRAL_DIRECTORY,
|
|
6384
|
+
WARNING_MULTIPLE_END_OF_CENTRAL_DIRECTORY: WARNING_MULTIPLE_END_OF_CENTRAL_DIRECTORY,
|
|
6204
6385
|
WARNING_PREPENDED_CENTRAL_DIRECTORY: WARNING_PREPENDED_CENTRAL_DIRECTORY,
|
|
6205
6386
|
WARNING_PREPENDED_DATA: WARNING_PREPENDED_DATA,
|
|
6206
6387
|
WARNING_TRAILING_CENTRAL_DIRECTORY_DATA: WARNING_TRAILING_CENTRAL_DIRECTORY_DATA,
|
|
@@ -6253,7 +6434,7 @@
|
|
|
6253
6434
|
const ERR_INVALID_ENCRYPTION_STRENGTH = "The strength must equal 1, 2, or 3";
|
|
6254
6435
|
const ERR_UNSUPPORTED_ENCRYPTION_USDZ = "Encryption is not supported in USDZ files";
|
|
6255
6436
|
const ERR_UNSUPPORTED_SPLIT_USDZ = "Split zip files are not supported in USDZ files";
|
|
6256
|
-
const ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH = "Encryption is not supported when the 'passThrough' option is set";
|
|
6437
|
+
const ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH = "Encryption is not supported when the 'passThrough' option is set to true (use 'compressed' instead)";
|
|
6257
6438
|
const ERR_INVALID_EXTRAFIELD = "Invalid extra field (must be a Map)";
|
|
6258
6439
|
const ERR_INVALID_EXTRAFIELD_TYPE = "Invalid extra field type (must be integer 0..65535)";
|
|
6259
6440
|
const ERR_INVALID_EXTRAFIELD_DATA_TYPE = "Invalid extra field data (must be a Uint8Array)";
|
|
@@ -6265,6 +6446,7 @@
|
|
|
6265
6446
|
const ERR_UNSUPPORTED_FORMAT = "Zip64 is not supported (set the 'zip64' option to 'true')";
|
|
6266
6447
|
const ERR_UNDEFINED_UNCOMPRESSED_SIZE = "Undefined uncompressed size";
|
|
6267
6448
|
const ERR_UNDEFINED_COMPRESSION_METHOD = "Undefined compression method";
|
|
6449
|
+
const ERR_UNDEFINED_CRC32 = "Undefined CRC32";
|
|
6268
6450
|
const ERR_UNDETERMINED_SIZE = "Undetermined size";
|
|
6269
6451
|
const ERR_UNDEFINED_READER = "Undefined reader";
|
|
6270
6452
|
const ERR_INVALID_READER = "Invalid reader (must be a Reader instance, a ReadableStream instance, or an object with a 'readable' property)";
|
|
@@ -6278,14 +6460,21 @@
|
|
|
6278
6460
|
const ERR_INVALID_MSDOS_DATA = "Invalid msdosAttributes (must be an object with boolean flags)";
|
|
6279
6461
|
const ERR_INVALID_LEVEL = "Invalid level (must be integer 0..9)";
|
|
6280
6462
|
const ERR_INVALID_SIGNATURE_DATA = "Signature data exceeds 64KB";
|
|
6463
|
+
const ERR_INVALID_ENTRY = "Invalid entry option (must be an entry returned by ZipReader#getEntries())";
|
|
6464
|
+
const ERR_ZIP_CRYPTO_LAST_MOD_DATE = "The last modification date of an entry encrypted with ZipCrypto cannot be changed when passThrough is set";
|
|
6465
|
+
const WARNING_COMPRESSION_UNAVAILABLE = "compression unavailable";
|
|
6466
|
+
const WARNING_CLAMPED_LAST_MODIFICATION_DATE = "clamped last modification date";
|
|
6281
6467
|
|
|
6282
6468
|
const EXTRAFIELD_DATA_AES = new Uint8Array([0x07, 0x00, 0x02, 0x00, 0x41, 0x45, 0x03, 0x00, 0x00]);
|
|
6283
6469
|
const EXTRAFIELD_OFFSET_AES_VENDOR_VERSION = 4;
|
|
6284
6470
|
const EXTRAFIELD_OFFSET_AES_COMPRESSION_METHOD = 9;
|
|
6285
6471
|
const EXTRAFIELD_USDZ_MAX_LENGTH = 67;
|
|
6472
|
+
const MIN_PRINTABLE_ASCII_CHARACTER_CODE = 0x20;
|
|
6473
|
+
const MAX_PRINTABLE_ASCII_CHARACTER_CODE = 0x7e;
|
|
6286
6474
|
const VENDOR_VERSION_AE_1 = 1;
|
|
6287
6475
|
const INFOZIP_EXTRA_FIELD_TYPE = "infozip";
|
|
6288
6476
|
const UNIX_EXTRA_FIELD_TYPE = "unix";
|
|
6477
|
+
const LEVEL_BY_BITFLAG_LEVEL = [8, 9, 5, 3];
|
|
6289
6478
|
const MAX_LEVEL = 9;
|
|
6290
6479
|
|
|
6291
6480
|
let workers = 0;
|
|
@@ -6312,9 +6501,11 @@
|
|
|
6312
6501
|
initialOffset: options[OPTION_OFFSET] === UNDEFINED_VALUE ? 0 : options[OPTION_OFFSET] - (writer.size || writer.writable.size || 0),
|
|
6313
6502
|
pendingAddFileCalls: new Set(),
|
|
6314
6503
|
pendingErrors: [],
|
|
6504
|
+
warnings: [],
|
|
6315
6505
|
bufferedWrites: 0,
|
|
6316
6506
|
directWrites: 0,
|
|
6317
|
-
lastFileEntry: UNDEFINED_VALUE
|
|
6507
|
+
lastFileEntry: UNDEFINED_VALUE,
|
|
6508
|
+
archiveClosed: false
|
|
6318
6509
|
});
|
|
6319
6510
|
}
|
|
6320
6511
|
|
|
@@ -6479,6 +6670,9 @@
|
|
|
6479
6670
|
const zipWriter = this;
|
|
6480
6671
|
const { pendingAddFileCalls, writer } = this;
|
|
6481
6672
|
const { writable } = writer;
|
|
6673
|
+
if (zipWriter.archiveClosed) {
|
|
6674
|
+
return getWriterData(writer);
|
|
6675
|
+
}
|
|
6482
6676
|
if (!(comment instanceof Uint8Array)) {
|
|
6483
6677
|
throw new Error(ERR_INVALID_COMMENT_TYPE);
|
|
6484
6678
|
}
|
|
@@ -6502,11 +6696,16 @@
|
|
|
6502
6696
|
throw error;
|
|
6503
6697
|
}
|
|
6504
6698
|
await closeFile(zipWriter, comment, options);
|
|
6699
|
+
zipWriter.archiveClosed = true;
|
|
6505
6700
|
const preventClose = !ownsWritable(writer) && getOptionValue(zipWriter, options, OPTION_PREVENT_CLOSE);
|
|
6506
6701
|
if (!preventClose) {
|
|
6507
6702
|
await writable.getWriter().close();
|
|
6508
6703
|
}
|
|
6509
|
-
return writer
|
|
6704
|
+
return getWriterData(writer);
|
|
6705
|
+
}
|
|
6706
|
+
|
|
6707
|
+
[SYMBOL_ASYNC_DISPOSE]() {
|
|
6708
|
+
return this.close();
|
|
6510
6709
|
}
|
|
6511
6710
|
}
|
|
6512
6711
|
|
|
@@ -6585,6 +6784,10 @@
|
|
|
6585
6784
|
}
|
|
6586
6785
|
}
|
|
6587
6786
|
|
|
6787
|
+
function getWriterData(writer) {
|
|
6788
|
+
return writer.getData ? writer.getData() : writer.writable;
|
|
6789
|
+
}
|
|
6790
|
+
|
|
6588
6791
|
function watchPromiseError(zipWriter, promise) {
|
|
6589
6792
|
const watchedPromise = new WatchedPromise((resolve, reject) => Promise.prototype.then.call(promise, resolve, reject));
|
|
6590
6793
|
const watcher = {};
|
|
@@ -6603,6 +6806,14 @@
|
|
|
6603
6806
|
|
|
6604
6807
|
async function addFileEntry(zipWriter, name, reader, options) {
|
|
6605
6808
|
options = Object.assign({}, options);
|
|
6809
|
+
const entry = options[OPTION_ENTRY];
|
|
6810
|
+
if (entry !== UNDEFINED_VALUE) {
|
|
6811
|
+
const { entryOptions, passThroughOptions } = getSourceEntryOptions(entry,
|
|
6812
|
+
checkPassThroughOption(getOptionValue(zipWriter, options, OPTION_PASS_THROUGH)),
|
|
6813
|
+
getOptionValue(zipWriter, options, PROPERTY_NAME_LAST_MODIFICATION_DATE));
|
|
6814
|
+
delete options[OPTION_ENTRY];
|
|
6815
|
+
options = Object.assign(entryOptions, passThroughOptions, options);
|
|
6816
|
+
}
|
|
6606
6817
|
if (getOptionValue(zipWriter, options, PROPERTY_NAME_DIRECTORY) && !name.endsWith(DIRECTORY_SIGNATURE)) {
|
|
6607
6818
|
name += DIRECTORY_SIGNATURE;
|
|
6608
6819
|
}
|
|
@@ -6667,21 +6878,33 @@
|
|
|
6667
6878
|
try {
|
|
6668
6879
|
const { resolvedOptions } = metadataInfo;
|
|
6669
6880
|
if (resolvedOptions.level != 0 && resolvedOptions.compressionMethod === UNDEFINED_VALUE &&
|
|
6670
|
-
!resolvedOptions.
|
|
6881
|
+
!resolvedOptions.passThroughCompression && !(await supportsDeflate(getConfiguration()))) {
|
|
6671
6882
|
resolvedOptions.level = 0;
|
|
6883
|
+
addWarning(zipWriter.warnings, WARNING_COMPRESSION_UNAVAILABLE, name);
|
|
6672
6884
|
}
|
|
6673
6885
|
const sizesInfo = await resolveSizes(zipWriter, reader, metadataInfo, options);
|
|
6674
6886
|
({ reader } = sizesInfo);
|
|
6675
6887
|
const diskOffset = getDiskOffset(zipWriter.writer);
|
|
6676
6888
|
const diskNumber = getDiskNumber(zipWriter.writer);
|
|
6889
|
+
let crc32 = options.crc32 === UNDEFINED_VALUE ? options[PROPERTY_NAME_SIGNATURE] : options.crc32;
|
|
6890
|
+
const storesAE2 = sizesInfo.resolvedOptions.encrypted && !resolvedOptions.zipCrypto;
|
|
6891
|
+
if (resolvedOptions.passThroughCompression && !resolvedOptions.passThroughEncryption && storesAE2) {
|
|
6892
|
+
crc32 = UNDEFINED_VALUE;
|
|
6893
|
+
}
|
|
6894
|
+
if (resolvedOptions.passThroughCompression && reader && !storesAE2 && crc32 === UNDEFINED_VALUE) {
|
|
6895
|
+
throw new Error(ERR_UNDEFINED_CRC32);
|
|
6896
|
+
}
|
|
6677
6897
|
options = Object.assign({}, options, attributesInfo.resolvedOptions, metadataInfo.resolvedOptions, sizesInfo.resolvedOptions, {
|
|
6678
6898
|
signature: options[PROPERTY_NAME_SIGNATURE],
|
|
6679
|
-
crc32
|
|
6899
|
+
crc32,
|
|
6680
6900
|
offset: zipWriter.offset - diskOffset,
|
|
6681
6901
|
diskNumberStart: diskNumber,
|
|
6682
6902
|
[OPTION_USDZ]: zipWriter.options[OPTION_USDZ]
|
|
6683
6903
|
});
|
|
6684
6904
|
const headerInfo = getHeaderInfo(options);
|
|
6905
|
+
if (headerInfo.lastModDateClamped) {
|
|
6906
|
+
addWarning(zipWriter.warnings, WARNING_CLAMPED_LAST_MODIFICATION_DATE, name);
|
|
6907
|
+
}
|
|
6685
6908
|
const dataDescriptorInfo = getDataDescriptorInfo(options);
|
|
6686
6909
|
const metadataSize = getLength(headerInfo.localHeaderArray, dataDescriptorInfo.dataDescriptorArray);
|
|
6687
6910
|
fileEntry = await getFileEntry(zipWriter, name, reader, {
|
|
@@ -6708,6 +6931,95 @@
|
|
|
6708
6931
|
return new Entry(fileEntry);
|
|
6709
6932
|
}
|
|
6710
6933
|
|
|
6934
|
+
function getSourceEntryOptions(entry, passThrough, lastModDateOverride) {
|
|
6935
|
+
if (entry === null || typeof entry != OBJECT_TYPE || Array.isArray(entry)) {
|
|
6936
|
+
throw new Error(ERR_INVALID_ENTRY);
|
|
6937
|
+
}
|
|
6938
|
+
const {
|
|
6939
|
+
externalFileAttributes,
|
|
6940
|
+
versionMadeBy,
|
|
6941
|
+
comment,
|
|
6942
|
+
lastModDate,
|
|
6943
|
+
rawLastModDate,
|
|
6944
|
+
creationDate,
|
|
6945
|
+
lastAccessDate,
|
|
6946
|
+
uncompressedSize,
|
|
6947
|
+
encrypted,
|
|
6948
|
+
zipCrypto,
|
|
6949
|
+
crc32,
|
|
6950
|
+
compressionMethod,
|
|
6951
|
+
extraFieldAES,
|
|
6952
|
+
extraFieldUnix,
|
|
6953
|
+
internalFileAttributes,
|
|
6954
|
+
extraField,
|
|
6955
|
+
bitFlag,
|
|
6956
|
+
directory,
|
|
6957
|
+
uid,
|
|
6958
|
+
gid
|
|
6959
|
+
} = entry;
|
|
6960
|
+
const entryOptions = {
|
|
6961
|
+
externalFileAttributes,
|
|
6962
|
+
versionMadeBy,
|
|
6963
|
+
comment,
|
|
6964
|
+
lastModDate,
|
|
6965
|
+
creationDate,
|
|
6966
|
+
lastAccessDate,
|
|
6967
|
+
internalFileAttributes,
|
|
6968
|
+
directory
|
|
6969
|
+
};
|
|
6970
|
+
if (bitFlag && bitFlag.languageEncodingFlag) {
|
|
6971
|
+
entryOptions[OPTION_USE_UNICODE_FILE_NAMES] = true;
|
|
6972
|
+
}
|
|
6973
|
+
const userExtraField = getUserExtraField(extraField);
|
|
6974
|
+
if (userExtraField) {
|
|
6975
|
+
entryOptions[PROPERTY_NAME_EXTRA_FIELD] = userExtraField;
|
|
6976
|
+
}
|
|
6977
|
+
if (uid !== UNDEFINED_VALUE || gid !== UNDEFINED_VALUE) {
|
|
6978
|
+
Object.assign(entryOptions, {
|
|
6979
|
+
uid,
|
|
6980
|
+
gid,
|
|
6981
|
+
unixExtraFieldType: extraFieldUnix ? UNIX_EXTRA_FIELD_TYPE : INFOZIP_EXTRA_FIELD_TYPE
|
|
6982
|
+
});
|
|
6983
|
+
}
|
|
6984
|
+
const passThroughOptions = {};
|
|
6985
|
+
if (passThrough && !directory) {
|
|
6986
|
+
Object.assign(passThroughOptions, {
|
|
6987
|
+
uncompressedSize,
|
|
6988
|
+
crc32,
|
|
6989
|
+
compressionMethod
|
|
6990
|
+
});
|
|
6991
|
+
if (passThrough !== PASS_THROUGH_COMPRESSED) {
|
|
6992
|
+
Object.assign(passThroughOptions, {
|
|
6993
|
+
encrypted,
|
|
6994
|
+
zipCrypto,
|
|
6995
|
+
encryptionStrength: extraFieldAES ? extraFieldAES.strength : UNDEFINED_VALUE
|
|
6996
|
+
});
|
|
6997
|
+
}
|
|
6998
|
+
if (bitFlag) {
|
|
6999
|
+
passThroughOptions.dataDescriptor = bitFlag.dataDescriptor;
|
|
7000
|
+
passThroughOptions[OPTION_LEVEL] = LEVEL_BY_BITFLAG_LEVEL[bitFlag.level];
|
|
7001
|
+
}
|
|
7002
|
+
if (lastModDateOverride === UNDEFINED_VALUE) {
|
|
7003
|
+
passThroughOptions.rawLastModDate = rawLastModDate;
|
|
7004
|
+
} else if (passThrough !== PASS_THROUGH_COMPRESSED && zipCrypto && (!bitFlag || bitFlag.dataDescriptor) &&
|
|
7005
|
+
lastModDateOverride instanceof Date &&
|
|
7006
|
+
getDosTimeHighByte(lastModDateOverride) != ((rawLastModDate >>> 8) & MAX_8_BITS)) {
|
|
7007
|
+
throw new Error(ERR_ZIP_CRYPTO_LAST_MOD_DATE);
|
|
7008
|
+
}
|
|
7009
|
+
}
|
|
7010
|
+
return { entryOptions, passThroughOptions };
|
|
7011
|
+
}
|
|
7012
|
+
|
|
7013
|
+
function getDosTimeHighByte(lastModDate) {
|
|
7014
|
+
let dosLastModDate = new Date(Math.ceil(Math.floor(lastModDate.getTime() / 1000) / 2) * 2000);
|
|
7015
|
+
if (dosLastModDate < MIN_DATE) {
|
|
7016
|
+
dosLastModDate = MIN_DATE;
|
|
7017
|
+
} else if (dosLastModDate > MAX_DATE) {
|
|
7018
|
+
dosLastModDate = MAX_DATE;
|
|
7019
|
+
}
|
|
7020
|
+
return ((dosLastModDate.getHours() << 3) | (dosLastModDate.getMinutes() >> 3)) & MAX_8_BITS;
|
|
7021
|
+
}
|
|
7022
|
+
|
|
6711
7023
|
function resolveAttributes(zipWriter, name, options) {
|
|
6712
7024
|
let msDosCompatible = getOptionValue(zipWriter, options, PROPERTY_NAME_MS_DOS_COMPATIBLE);
|
|
6713
7025
|
let versionMadeBy = getOptionValue(zipWriter, options, PROPERTY_NAME_VERSION_MADE_BY, msDosCompatible ? VERSION_MADE_BY_MSDOS : VERSION_MADE_BY_UNIX);
|
|
@@ -6861,7 +7173,9 @@
|
|
|
6861
7173
|
const lastAccessDate = getDateOptionValue(zipWriter, options, PROPERTY_NAME_LAST_ACCESS_DATE);
|
|
6862
7174
|
const creationDate = getDateOptionValue(zipWriter, options, PROPERTY_NAME_CREATION_DATE);
|
|
6863
7175
|
const internalFileAttributes = getOptionValue(zipWriter, options, PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTES, 0);
|
|
6864
|
-
const passThrough = getOptionValue(zipWriter, options, OPTION_PASS_THROUGH);
|
|
7176
|
+
const passThrough = checkPassThroughOption(getOptionValue(zipWriter, options, OPTION_PASS_THROUGH));
|
|
7177
|
+
const passThroughCompression = Boolean(passThrough);
|
|
7178
|
+
const passThroughEncryption = passThrough === true;
|
|
6865
7179
|
const password = getOptionValue(zipWriter, options, OPTION_PASSWORD);
|
|
6866
7180
|
const rawPassword = getOptionValue(zipWriter, options, OPTION_RAW_PASSWORD);
|
|
6867
7181
|
checkPasswordOption(password, rawPassword);
|
|
@@ -6876,10 +7190,12 @@
|
|
|
6876
7190
|
const createTempStream = getFunctionOptionValue(zipWriter, options, OPTION_CREATE_TEMP_STREAM);
|
|
6877
7191
|
const dataDescriptorSignature = getOptionValue(zipWriter, options, OPTION_DATA_DESCRIPTOR_SIGNATURE, true);
|
|
6878
7192
|
const signal = checkSignalOption(getOptionValue(zipWriter, options, OPTION_SIGNAL));
|
|
6879
|
-
|
|
7193
|
+
throwIfAborted(signal);
|
|
7194
|
+
const useUnicodeFileNames = getOptionValue(zipWriter, options, OPTION_USE_UNICODE_FILE_NAMES,
|
|
7195
|
+
!isPrintableASCIIText(rawFilename) || !isPrintableASCIIText(rawComment));
|
|
6880
7196
|
const compressionMethod = getOptionValue(zipWriter, options, PROPERTY_NAME_COMPRESSION_METHOD);
|
|
6881
|
-
const registeredCodec =
|
|
6882
|
-
if (!
|
|
7197
|
+
const registeredCodec = passThroughCompression || compressionMethod === UNDEFINED_VALUE ? UNDEFINED_VALUE : getRegisteredCodec(compressionMethod);
|
|
7198
|
+
if (!passThroughCompression && compressionMethod !== UNDEFINED_VALUE &&
|
|
6883
7199
|
compressionMethod !== COMPRESSION_METHOD_STORE && compressionMethod !== COMPRESSION_METHOD_DEFLATE && !registeredCodec) {
|
|
6884
7200
|
throw new Error(ERR_UNSUPPORTED_COMPRESSION);
|
|
6885
7201
|
}
|
|
@@ -6893,15 +7209,15 @@
|
|
|
6893
7209
|
level = 0;
|
|
6894
7210
|
}
|
|
6895
7211
|
}
|
|
6896
|
-
if (
|
|
6897
|
-
level =
|
|
7212
|
+
if (passThroughCompression) {
|
|
7213
|
+
level = toNumber(options[OPTION_LEVEL]);
|
|
6898
7214
|
}
|
|
6899
7215
|
let useCompressionStream = getOptionValue(zipWriter, options, OPTION_USE_COMPRESSION_STREAM);
|
|
6900
7216
|
let dataDescriptor = getOptionValue(zipWriter, options, OPTION_DATA_DESCRIPTOR);
|
|
6901
7217
|
if (bufferedWrite && dataDescriptor === UNDEFINED_VALUE) {
|
|
6902
7218
|
dataDescriptor = false;
|
|
6903
7219
|
}
|
|
6904
|
-
if (dataDescriptor === UNDEFINED_VALUE || (zipCrypto && !
|
|
7220
|
+
if (dataDescriptor === UNDEFINED_VALUE || (zipCrypto && !passThroughEncryption)) {
|
|
6905
7221
|
dataDescriptor = true;
|
|
6906
7222
|
}
|
|
6907
7223
|
if (level !== UNDEFINED_VALUE && level != 6) {
|
|
@@ -6925,7 +7241,8 @@
|
|
|
6925
7241
|
lastAccessDate,
|
|
6926
7242
|
creationDate,
|
|
6927
7243
|
internalFileAttributes,
|
|
6928
|
-
|
|
7244
|
+
passThroughCompression,
|
|
7245
|
+
passThroughEncryption,
|
|
6929
7246
|
password,
|
|
6930
7247
|
rawPassword,
|
|
6931
7248
|
encryptionStrength,
|
|
@@ -6986,7 +7303,7 @@
|
|
|
6986
7303
|
}
|
|
6987
7304
|
|
|
6988
7305
|
async function resolveSizes(zipWriter, reader, { resolvedOptions: metadata }, options) {
|
|
6989
|
-
if (metadata.
|
|
7306
|
+
if (metadata.passThroughCompression && !reader && !getOptionValue(zipWriter, options, PROPERTY_NAME_DIRECTORY)) {
|
|
6990
7307
|
throw new Error(ERR_UNDEFINED_READER);
|
|
6991
7308
|
}
|
|
6992
7309
|
let contentSize;
|
|
@@ -7002,12 +7319,12 @@
|
|
|
7002
7319
|
}
|
|
7003
7320
|
|
|
7004
7321
|
function resolveEntrySizes(zipWriter, hasContent, contentSize, metadata, options) {
|
|
7005
|
-
const {
|
|
7322
|
+
const { passThroughCompression, passThroughEncryption, zipCrypto, password, rawPassword, encryptionStrength } = metadata;
|
|
7006
7323
|
let { dataDescriptor, zip64, level, compressionMethod } = metadata;
|
|
7007
7324
|
let maximumCompressedSize = 0;
|
|
7008
7325
|
let uncompressedSize = 0;
|
|
7009
7326
|
let unknownSize = false;
|
|
7010
|
-
if (
|
|
7327
|
+
if (passThroughCompression && hasContent) {
|
|
7011
7328
|
uncompressedSize = options[PROPERTY_NAME_UNCOMPRESSED_SIZE];
|
|
7012
7329
|
if (uncompressedSize === UNDEFINED_VALUE) {
|
|
7013
7330
|
throw new Error(ERR_UNDEFINED_UNCOMPRESSED_SIZE);
|
|
@@ -7018,17 +7335,17 @@
|
|
|
7018
7335
|
}
|
|
7019
7336
|
const zip64Enabled = zip64 === true;
|
|
7020
7337
|
const encrypted = getOptionValue(zipWriter, options, PROPERTY_NAME_ENCRYPTED);
|
|
7021
|
-
if (hasContent &&
|
|
7338
|
+
if (hasContent && passThroughEncryption && !encrypted && getLength(password, rawPassword)) {
|
|
7022
7339
|
throw new Error(ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH);
|
|
7023
7340
|
}
|
|
7024
|
-
const encryptedEntry = hasContent && (Boolean((password && getLength(password)) || (rawPassword && getLength(rawPassword))) || (
|
|
7341
|
+
const encryptedEntry = hasContent && (Boolean((password && getLength(password)) || (rawPassword && getLength(rawPassword))) || (passThroughEncryption && encrypted));
|
|
7025
7342
|
if (!hasContent) {
|
|
7026
7343
|
level = 0;
|
|
7027
7344
|
compressionMethod = COMPRESSION_METHOD_STORE;
|
|
7028
7345
|
}
|
|
7029
|
-
const encryptionOverhead = encryptedEntry
|
|
7346
|
+
const encryptionOverhead = getEncryptionOverhead(encryptedEntry, zipCrypto, encryptionStrength);
|
|
7030
7347
|
if (hasContent) {
|
|
7031
|
-
if (!
|
|
7348
|
+
if (!passThroughCompression) {
|
|
7032
7349
|
if (contentSize === UNDEFINED_VALUE) {
|
|
7033
7350
|
dataDescriptor = true;
|
|
7034
7351
|
if (zip64 || zip64 === UNDEFINED_VALUE) {
|
|
@@ -7041,10 +7358,12 @@
|
|
|
7041
7358
|
}
|
|
7042
7359
|
} else {
|
|
7043
7360
|
options.uncompressedSize = uncompressedSize;
|
|
7044
|
-
maximumCompressedSize = contentSize === UNDEFINED_VALUE ?
|
|
7361
|
+
maximumCompressedSize = contentSize === UNDEFINED_VALUE ?
|
|
7362
|
+
getMaximumCompressedSize(uncompressedSize) + encryptionOverhead :
|
|
7363
|
+
contentSize + (passThroughEncryption ? 0 : encryptionOverhead);
|
|
7045
7364
|
}
|
|
7046
7365
|
}
|
|
7047
|
-
const emptyEntry = !encryptedEntry && (!hasContent || (contentSize === 0 && !
|
|
7366
|
+
const emptyEntry = !encryptedEntry && (!hasContent || (contentSize === 0 && !passThroughCompression)) && !isCompressed(compressionMethod, level);
|
|
7048
7367
|
if (emptyEntry && !zipCrypto && getOptionValue(zipWriter, options, OPTION_DATA_DESCRIPTOR) === UNDEFINED_VALUE) {
|
|
7049
7368
|
dataDescriptor = false;
|
|
7050
7369
|
}
|
|
@@ -7251,6 +7570,7 @@
|
|
|
7251
7570
|
localExtraFieldZip64Length,
|
|
7252
7571
|
rawExtraFieldExtendedTimestamp,
|
|
7253
7572
|
extraFieldExtendedTimestampFlag,
|
|
7573
|
+
extraFieldExtendedTimestampTime,
|
|
7254
7574
|
rawExtraFieldNTFS,
|
|
7255
7575
|
rawExtraFieldUnix,
|
|
7256
7576
|
rawExtraFieldAES,
|
|
@@ -7263,6 +7583,7 @@
|
|
|
7263
7583
|
password,
|
|
7264
7584
|
rawPassword,
|
|
7265
7585
|
level,
|
|
7586
|
+
useUnicodeFileNames,
|
|
7266
7587
|
zip64,
|
|
7267
7588
|
zip64Enabled,
|
|
7268
7589
|
zip64UncompressedSize,
|
|
@@ -7297,7 +7618,8 @@
|
|
|
7297
7618
|
msdosAttributesRaw,
|
|
7298
7619
|
msdosAttributes,
|
|
7299
7620
|
useCompressionStream,
|
|
7300
|
-
|
|
7621
|
+
passThroughCompression,
|
|
7622
|
+
passThroughEncryption,
|
|
7301
7623
|
format,
|
|
7302
7624
|
codecURI
|
|
7303
7625
|
} = options;
|
|
@@ -7308,9 +7630,9 @@
|
|
|
7308
7630
|
zip64Enabled,
|
|
7309
7631
|
directory: Boolean(directory),
|
|
7310
7632
|
executable: Boolean(executable),
|
|
7311
|
-
filenameUTF8:
|
|
7633
|
+
filenameUTF8: Boolean(useUnicodeFileNames),
|
|
7312
7634
|
rawFilename,
|
|
7313
|
-
commentUTF8:
|
|
7635
|
+
commentUTF8: Boolean(useUnicodeFileNames),
|
|
7314
7636
|
rawComment,
|
|
7315
7637
|
rawExtraFieldZip64,
|
|
7316
7638
|
localExtraFieldZip64Length,
|
|
@@ -7341,7 +7663,7 @@
|
|
|
7341
7663
|
uncompressedSize
|
|
7342
7664
|
} = options;
|
|
7343
7665
|
let compressedSize = 0;
|
|
7344
|
-
if (!
|
|
7666
|
+
if (!passThroughCompression) {
|
|
7345
7667
|
uncompressedSize = 0;
|
|
7346
7668
|
}
|
|
7347
7669
|
const { writable } = writer;
|
|
@@ -7358,9 +7680,9 @@
|
|
|
7358
7680
|
encryptionStrength,
|
|
7359
7681
|
zipCrypto: encrypted && zipCrypto,
|
|
7360
7682
|
passwordVerification: encrypted && zipCrypto && (rawLastModDate >> 8) & MAX_8_BITS,
|
|
7361
|
-
computeCrc32: !
|
|
7362
|
-
compressed: compressed && !
|
|
7363
|
-
encrypted: encrypted && !
|
|
7683
|
+
computeCrc32: !passThroughCompression,
|
|
7684
|
+
compressed: compressed && !passThroughCompression,
|
|
7685
|
+
encrypted: encrypted && !passThroughEncryption,
|
|
7364
7686
|
useWebWorkers,
|
|
7365
7687
|
useCompressionStream,
|
|
7366
7688
|
transferStreams,
|
|
@@ -7375,7 +7697,7 @@
|
|
|
7375
7697
|
const result = await runWorker({ readable, writable }, workerOptions);
|
|
7376
7698
|
compressedSize = result.outputSize;
|
|
7377
7699
|
writer.size += compressedSize;
|
|
7378
|
-
if (!
|
|
7700
|
+
if (!passThroughCompression) {
|
|
7379
7701
|
uncompressedSize = result.inputSize;
|
|
7380
7702
|
if (!encrypted || zipCrypto) {
|
|
7381
7703
|
crc32 = result.crc32;
|
|
@@ -7418,8 +7740,9 @@
|
|
|
7418
7740
|
headerArray,
|
|
7419
7741
|
headerView,
|
|
7420
7742
|
signature: crc32,
|
|
7421
|
-
crc32: encrypted && !zipCrypto && !
|
|
7743
|
+
crc32: encrypted && !zipCrypto && !passThroughCompression ? UNDEFINED_VALUE : crc32,
|
|
7422
7744
|
extraFieldExtendedTimestampFlag,
|
|
7745
|
+
extraFieldExtendedTimestampTime,
|
|
7423
7746
|
zip64UncompressedSize,
|
|
7424
7747
|
zip64CompressedSize
|
|
7425
7748
|
});
|
|
@@ -7444,7 +7767,7 @@
|
|
|
7444
7767
|
encryptionStrength,
|
|
7445
7768
|
extendedTimestamp,
|
|
7446
7769
|
ntfsTimestamp,
|
|
7447
|
-
|
|
7770
|
+
passThroughCompression,
|
|
7448
7771
|
encrypted,
|
|
7449
7772
|
zip64UncompressedSize,
|
|
7450
7773
|
zip64CompressedSize,
|
|
@@ -7455,7 +7778,7 @@
|
|
|
7455
7778
|
let { version, compressionMethod } = options;
|
|
7456
7779
|
const compressed = !directory && isCompressed(compressionMethod, level);
|
|
7457
7780
|
let rawLocalExtraFieldZip64;
|
|
7458
|
-
const uncompressedFile =
|
|
7781
|
+
const uncompressedFile = passThroughCompression || !compressed;
|
|
7459
7782
|
const zip64ExtraFieldComplete = zip64 && (options.bufferedWrite || !dataDescriptor || ((!zip64UncompressedSize && !zip64CompressedSize) || (uncompressedFile && !unknownSize)));
|
|
7460
7783
|
const writeLocalExtraFieldZip64 = zip64ExtraFieldComplete || (zip64 && dataDescriptor && (zip64UncompressedSize || zip64CompressedSize));
|
|
7461
7784
|
if (zip64 && (zip64UncompressedSize || zip64CompressedSize)) {
|
|
@@ -7467,8 +7790,8 @@
|
|
|
7467
7790
|
if (zip64ExtraFieldComplete) {
|
|
7468
7791
|
extraFieldZip64.writeUint64(uncompressedSize);
|
|
7469
7792
|
if (uncompressedFile) {
|
|
7470
|
-
const encryptionOverhead = encrypted
|
|
7471
|
-
extraFieldZip64.writeUint64(
|
|
7793
|
+
const encryptionOverhead = getEncryptionOverhead(encrypted, zipCrypto, encryptionStrength);
|
|
7794
|
+
extraFieldZip64.writeUint64(passThroughCompression ? 0 : uncompressedSize + encryptionOverhead);
|
|
7472
7795
|
}
|
|
7473
7796
|
}
|
|
7474
7797
|
} else {
|
|
@@ -7487,6 +7810,7 @@
|
|
|
7487
7810
|
let rawExtraFieldNTFS;
|
|
7488
7811
|
let rawExtraFieldExtendedTimestamp;
|
|
7489
7812
|
let extraFieldExtendedTimestampFlag;
|
|
7813
|
+
let extraFieldExtendedTimestampTime;
|
|
7490
7814
|
if (extendedTimestamp) {
|
|
7491
7815
|
const lastModTimeUnix = getTimeUnix(lastModDate);
|
|
7492
7816
|
const lastModTimeUnixInRange = inUnixTimeRange(lastModTimeUnix);
|
|
@@ -7494,6 +7818,7 @@
|
|
|
7494
7818
|
const extraFieldTimestampLength = 9 + (lastAccessDate ? 4 : 0) + (creationDate ? 4 : 0);
|
|
7495
7819
|
const extraFieldTimestamp = createRecordWriter(extraFieldTimestampLength);
|
|
7496
7820
|
extraFieldExtendedTimestampFlag = 0x1 + (lastAccessDate ? 0x2 : 0) + (creationDate ? 0x4 : 0);
|
|
7821
|
+
extraFieldExtendedTimestampTime = lastModTimeUnix;
|
|
7497
7822
|
extraFieldTimestamp.writeUint16(EXTRAFIELD_TYPE_EXTENDED_TIMESTAMP);
|
|
7498
7823
|
extraFieldTimestamp.writeUint16(extraFieldTimestampLength - 4);
|
|
7499
7824
|
extraFieldTimestamp.writeUint8(extraFieldExtendedTimestampFlag);
|
|
@@ -7577,7 +7902,7 @@
|
|
|
7577
7902
|
}
|
|
7578
7903
|
if (encrypted && !zipCrypto) {
|
|
7579
7904
|
version = version > VERSION_AES ? version : VERSION_AES;
|
|
7580
|
-
if (
|
|
7905
|
+
if (passThroughCompression && crc32 !== UNDEFINED_VALUE) {
|
|
7581
7906
|
rawExtraFieldAES[EXTRAFIELD_OFFSET_AES_VENDOR_VERSION] = VENDOR_VERSION_AE_1;
|
|
7582
7907
|
}
|
|
7583
7908
|
setUint16(getDataView(rawExtraFieldAES), EXTRAFIELD_OFFSET_AES_COMPRESSION_METHOD, compressionMethod);
|
|
@@ -7639,12 +7964,14 @@
|
|
|
7639
7964
|
headerArray,
|
|
7640
7965
|
headerView,
|
|
7641
7966
|
lastModDate: storedLastModDate,
|
|
7967
|
+
lastModDateClamped: storedLastModDate === clampedLastModDate && dosLastModDate.getTime() != clampedLastModDate.getTime(),
|
|
7642
7968
|
rawLastModDate,
|
|
7643
7969
|
encrypted,
|
|
7644
7970
|
compressed,
|
|
7645
7971
|
version,
|
|
7646
7972
|
compressionMethod,
|
|
7647
7973
|
extraFieldExtendedTimestampFlag,
|
|
7974
|
+
extraFieldExtendedTimestampTime,
|
|
7648
7975
|
rawExtraFieldZip64: EMPTY_UINT8_ARRAY,
|
|
7649
7976
|
localExtraFieldZip64Length,
|
|
7650
7977
|
rawExtraFieldExtendedTimestamp,
|
|
@@ -7747,7 +8074,7 @@
|
|
|
7747
8074
|
}, {
|
|
7748
8075
|
zip64,
|
|
7749
8076
|
zipCrypto,
|
|
7750
|
-
|
|
8077
|
+
passThroughCompression,
|
|
7751
8078
|
dataDescriptor
|
|
7752
8079
|
}) {
|
|
7753
8080
|
const {
|
|
@@ -7758,7 +8085,7 @@
|
|
|
7758
8085
|
dataDescriptorView,
|
|
7759
8086
|
dataDescriptorOffset
|
|
7760
8087
|
} = dataDescriptorInfo;
|
|
7761
|
-
if ((!encrypted || zipCrypto ||
|
|
8088
|
+
if ((!encrypted || zipCrypto || passThroughCompression) && crc32 !== UNDEFINED_VALUE) {
|
|
7762
8089
|
setUint32(headerView, HEADER_OFFSET_SIGNATURE, crc32);
|
|
7763
8090
|
if (dataDescriptor) {
|
|
7764
8091
|
setUint32(dataDescriptorView, dataDescriptorOffset, crc32);
|
|
@@ -7789,9 +8116,9 @@
|
|
|
7789
8116
|
uncompressedSize,
|
|
7790
8117
|
zip64UncompressedSize,
|
|
7791
8118
|
zip64CompressedSize
|
|
7792
|
-
}, localHeaderView, { dataDescriptor,
|
|
8119
|
+
}, localHeaderView, { dataDescriptor, passThroughCompression }) {
|
|
7793
8120
|
if (!dataDescriptor) {
|
|
7794
|
-
if (!encrypted || (
|
|
8121
|
+
if (!encrypted || (passThroughCompression && crc32 !== UNDEFINED_VALUE)) {
|
|
7795
8122
|
setUint32(localHeaderView, HEADER_OFFSET_SIGNATURE + LOCAL_HEADER_COMMON_OFFSET, crc32);
|
|
7796
8123
|
}
|
|
7797
8124
|
if (!zip64CompressedSize) {
|
|
@@ -7828,9 +8155,8 @@
|
|
|
7828
8155
|
rawExtraFieldUnix,
|
|
7829
8156
|
rawExtraField,
|
|
7830
8157
|
rawCentralExtraField,
|
|
7831
|
-
extendedTimestamp,
|
|
7832
8158
|
extraFieldExtendedTimestampFlag,
|
|
7833
|
-
|
|
8159
|
+
extraFieldExtendedTimestampTime,
|
|
7834
8160
|
zip64Enabled,
|
|
7835
8161
|
uncompressedSize,
|
|
7836
8162
|
compressedSize
|
|
@@ -7873,16 +8199,15 @@
|
|
|
7873
8199
|
fileEntry.zip64Offset = zip64Offset;
|
|
7874
8200
|
fileEntry.zip64DiskNumberStart = zip64DiskNumberStart;
|
|
7875
8201
|
let rawExtraFieldTimestamp;
|
|
7876
|
-
|
|
7877
|
-
|
|
8202
|
+
if (extraFieldExtendedTimestampTime === UNDEFINED_VALUE) {
|
|
8203
|
+
rawExtraFieldTimestamp = EMPTY_UINT8_ARRAY;
|
|
8204
|
+
} else {
|
|
7878
8205
|
const extraFieldTimestamp = createRecordWriter(9);
|
|
7879
8206
|
extraFieldTimestamp.writeUint16(EXTRAFIELD_TYPE_EXTENDED_TIMESTAMP);
|
|
7880
8207
|
extraFieldTimestamp.writeUint16(5);
|
|
7881
8208
|
extraFieldTimestamp.writeUint8(extraFieldExtendedTimestampFlag);
|
|
7882
|
-
extraFieldTimestamp.writeUint32(
|
|
8209
|
+
extraFieldTimestamp.writeUint32(extraFieldExtendedTimestampTime);
|
|
7883
8210
|
rawExtraFieldTimestamp = extraFieldTimestamp.array;
|
|
7884
|
-
} else {
|
|
7885
|
-
rawExtraFieldTimestamp = EMPTY_UINT8_ARRAY;
|
|
7886
8211
|
}
|
|
7887
8212
|
fileEntry.rawExtraFieldExtendedTimestamp = rawExtraFieldTimestamp;
|
|
7888
8213
|
const extraFieldLength = getLength(
|
|
@@ -8382,6 +8707,11 @@
|
|
|
8382
8707
|
};
|
|
8383
8708
|
}
|
|
8384
8709
|
|
|
8710
|
+
function isPrintableASCIIText(rawText) {
|
|
8711
|
+
return rawText.every(characterCode =>
|
|
8712
|
+
characterCode >= MIN_PRINTABLE_ASCII_CHARACTER_CODE && characterCode <= MAX_PRINTABLE_ASCII_CHARACTER_CODE);
|
|
8713
|
+
}
|
|
8714
|
+
|
|
8385
8715
|
function getBitFlag(level, useUnicodeFileNames, dataDescriptor, encrypted, compressionMethod) {
|
|
8386
8716
|
let bitFlag = 0;
|
|
8387
8717
|
if (useUnicodeFileNames) {
|
|
@@ -8543,7 +8873,7 @@
|
|
|
8543
8873
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
8544
8874
|
*/
|
|
8545
8875
|
|
|
8546
|
-
const VERSION = "2.
|
|
8876
|
+
const VERSION = "2.12.0";
|
|
8547
8877
|
|
|
8548
8878
|
/*
|
|
8549
8879
|
Copyright (c) 2025 Gildas Lormeau. All rights reserved.
|
|
@@ -9365,9 +9695,9 @@
|
|
|
9365
9695
|
DecompressionStreamFallback: DecompressionStreamZlib
|
|
9366
9696
|
});
|
|
9367
9697
|
|
|
9368
|
-
function terminateWorkersAndModule() {
|
|
9698
|
+
async function terminateWorkersAndModule() {
|
|
9699
|
+
await terminateWorkers();
|
|
9369
9700
|
modulePromise = null;
|
|
9370
|
-
terminateWorkers();
|
|
9371
9701
|
resetWasmModule();
|
|
9372
9702
|
}
|
|
9373
9703
|
|
|
@@ -9437,6 +9767,7 @@
|
|
|
9437
9767
|
exports.BlobWriter = BlobWriter;
|
|
9438
9768
|
exports.Data64URIReader = Data64URIReader;
|
|
9439
9769
|
exports.Data64URIWriter = Data64URIWriter;
|
|
9770
|
+
exports.ERR_ABORTED = ERR_ABORTED;
|
|
9440
9771
|
exports.ERR_AMBIGUOUS_ARCHIVE = ERR_AMBIGUOUS_ARCHIVE;
|
|
9441
9772
|
exports.ERR_BAD_FORMAT = ERR_BAD_FORMAT;
|
|
9442
9773
|
exports.ERR_CENTRAL_DIRECTORY_NOT_FOUND = ERR_CENTRAL_DIRECTORY_NOT_FOUND;
|
|
@@ -9449,7 +9780,9 @@
|
|
|
9449
9780
|
exports.ERR_EXTRAFIELD_ZIP64_NOT_FOUND = ERR_EXTRAFIELD_ZIP64_NOT_FOUND;
|
|
9450
9781
|
exports.ERR_HTTP_RANGE = ERR_HTTP_RANGE;
|
|
9451
9782
|
exports.ERR_HTTP_RESOURCE_CHANGED = ERR_HTTP_RESOURCE_CHANGED;
|
|
9783
|
+
exports.ERR_HTTP_STATUS = ERR_HTTP_STATUS;
|
|
9452
9784
|
exports.ERR_INVALID_AUTHENTICATION_CODE = ERR_INVALID_AUTHENTICATION_CODE;
|
|
9785
|
+
exports.ERR_INVALID_BASE_URI = ERR_INVALID_BASE_URI;
|
|
9453
9786
|
exports.ERR_INVALID_CODEC_DEFINITION = ERR_INVALID_CODEC_DEFINITION;
|
|
9454
9787
|
exports.ERR_INVALID_CODEC_MODULE = ERR_INVALID_CODEC_MODULE;
|
|
9455
9788
|
exports.ERR_INVALID_COMMENT = ERR_INVALID_COMMENT;
|
|
@@ -9458,6 +9791,7 @@
|
|
|
9458
9791
|
exports.ERR_INVALID_CRC32 = ERR_INVALID_CRC32;
|
|
9459
9792
|
exports.ERR_INVALID_DATE = ERR_INVALID_DATE;
|
|
9460
9793
|
exports.ERR_INVALID_ENCRYPTION_STRENGTH = ERR_INVALID_ENCRYPTION_STRENGTH;
|
|
9794
|
+
exports.ERR_INVALID_ENTRY = ERR_INVALID_ENTRY;
|
|
9461
9795
|
exports.ERR_INVALID_ENTRY_COMMENT = ERR_INVALID_ENTRY_COMMENT;
|
|
9462
9796
|
exports.ERR_INVALID_ENTRY_COMMENT_TYPE = ERR_INVALID_ENTRY_COMMENT_TYPE;
|
|
9463
9797
|
exports.ERR_INVALID_ENTRY_NAME = ERR_INVALID_ENTRY_NAME;
|
|
@@ -9475,6 +9809,7 @@
|
|
|
9475
9809
|
exports.ERR_INVALID_MSDOS_DATA = ERR_INVALID_MSDOS_DATA;
|
|
9476
9810
|
exports.ERR_INVALID_PASSWORD = ERR_INVALID_PASSWORD;
|
|
9477
9811
|
exports.ERR_INVALID_PASSWORD_TYPE = ERR_INVALID_PASSWORD_TYPE;
|
|
9812
|
+
exports.ERR_INVALID_PASS_THROUGH_VALUE = ERR_INVALID_PASS_THROUGH_VALUE;
|
|
9478
9813
|
exports.ERR_INVALID_READER = ERR_INVALID_READER;
|
|
9479
9814
|
exports.ERR_INVALID_SIGNAL = ERR_INVALID_SIGNAL;
|
|
9480
9815
|
exports.ERR_INVALID_SIGNATURE_DATA = ERR_INVALID_SIGNATURE_DATA;
|
|
@@ -9484,6 +9819,7 @@
|
|
|
9484
9819
|
exports.ERR_INVALID_UNIX_EXTRA_FIELD_TYPE = ERR_INVALID_UNIX_EXTRA_FIELD_TYPE;
|
|
9485
9820
|
exports.ERR_INVALID_UNIX_ID_SIZE = ERR_INVALID_UNIX_ID_SIZE;
|
|
9486
9821
|
exports.ERR_INVALID_UNIX_MODE = ERR_INVALID_UNIX_MODE;
|
|
9822
|
+
exports.ERR_INVALID_URI = ERR_INVALID_URI;
|
|
9487
9823
|
exports.ERR_INVALID_VERSION = ERR_INVALID_VERSION;
|
|
9488
9824
|
exports.ERR_ITERATOR_COMPLETED_TOO_SOON = ERR_ITERATOR_COMPLETED_TOO_SOON;
|
|
9489
9825
|
exports.ERR_LOCAL_FILE_HEADER_NOT_FOUND = ERR_LOCAL_FILE_HEADER_NOT_FOUND;
|
|
@@ -9491,6 +9827,7 @@
|
|
|
9491
9827
|
exports.ERR_RESERVED_COMPRESSION_METHOD = ERR_RESERVED_COMPRESSION_METHOD;
|
|
9492
9828
|
exports.ERR_SPLIT_ZIP_FILE = ERR_SPLIT_ZIP_FILE;
|
|
9493
9829
|
exports.ERR_UNDEFINED_COMPRESSION_METHOD = ERR_UNDEFINED_COMPRESSION_METHOD;
|
|
9830
|
+
exports.ERR_UNDEFINED_CRC32 = ERR_UNDEFINED_CRC32;
|
|
9494
9831
|
exports.ERR_UNDEFINED_READER = ERR_UNDEFINED_READER;
|
|
9495
9832
|
exports.ERR_UNDEFINED_UNCOMPRESSED_SIZE = ERR_UNDEFINED_UNCOMPRESSED_SIZE;
|
|
9496
9833
|
exports.ERR_UNDETERMINED_SIZE = ERR_UNDETERMINED_SIZE;
|
|
@@ -9506,6 +9843,8 @@
|
|
|
9506
9843
|
exports.ERR_UNSUPPORTED_UINT64 = ERR_UNSUPPORTED_UINT64;
|
|
9507
9844
|
exports.ERR_WORKER_STARTUP_TIMEOUT = ERR_WORKER_STARTUP_TIMEOUT;
|
|
9508
9845
|
exports.ERR_WRITER_NOT_INITIALIZED = ERR_WRITER_NOT_INITIALIZED;
|
|
9846
|
+
exports.ERR_WRITER_SIZE_NOT_WRITABLE = ERR_WRITER_SIZE_NOT_WRITABLE;
|
|
9847
|
+
exports.ERR_ZIP_CRYPTO_LAST_MOD_DATE = ERR_ZIP_CRYPTO_LAST_MOD_DATE;
|
|
9509
9848
|
exports.ERR_ZIP_NOT_EMPTY = ERR_ZIP_NOT_EMPTY;
|
|
9510
9849
|
exports.HttpRangeReader = HttpRangeReader;
|
|
9511
9850
|
exports.HttpReader = HttpReader;
|
|
@@ -9518,13 +9857,17 @@
|
|
|
9518
9857
|
exports.Uint8ArrayWriter = Uint8ArrayWriter;
|
|
9519
9858
|
exports.VERSION = VERSION;
|
|
9520
9859
|
exports.WARNING_APPENDED_DATA = WARNING_APPENDED_DATA;
|
|
9860
|
+
exports.WARNING_CLAMPED_LAST_MODIFICATION_DATE = WARNING_CLAMPED_LAST_MODIFICATION_DATE;
|
|
9521
9861
|
exports.WARNING_COMPRESSED_PATCHED_DATA = WARNING_COMPRESSED_PATCHED_DATA;
|
|
9862
|
+
exports.WARNING_COMPRESSION_UNAVAILABLE = WARNING_COMPRESSION_UNAVAILABLE;
|
|
9522
9863
|
exports.WARNING_DUPLICATE_FILENAME = WARNING_DUPLICATE_FILENAME;
|
|
9523
9864
|
exports.WARNING_MALFORMED_EXTRA_FIELD = WARNING_MALFORMED_EXTRA_FIELD;
|
|
9524
9865
|
exports.WARNING_MISMATCHED_LOCAL_FILE_HEADER_BIT_FLAG = WARNING_MISMATCHED_LOCAL_FILE_HEADER_BIT_FLAG;
|
|
9525
9866
|
exports.WARNING_MISMATCHED_LOCAL_FILE_HEADER_COMPRESSION_METHOD = WARNING_MISMATCHED_LOCAL_FILE_HEADER_COMPRESSION_METHOD;
|
|
9526
9867
|
exports.WARNING_MISMATCHED_LOCAL_FILE_HEADER_CRC32_OR_SIZES = WARNING_MISMATCHED_LOCAL_FILE_HEADER_CRC32_OR_SIZES;
|
|
9868
|
+
exports.WARNING_MISMATCHED_LOCAL_FILE_HEADER_FILENAME = WARNING_MISMATCHED_LOCAL_FILE_HEADER_FILENAME;
|
|
9527
9869
|
exports.WARNING_MISMATCHED_ZIP64_END_OF_CENTRAL_DIRECTORY = WARNING_MISMATCHED_ZIP64_END_OF_CENTRAL_DIRECTORY;
|
|
9870
|
+
exports.WARNING_MULTIPLE_END_OF_CENTRAL_DIRECTORY = WARNING_MULTIPLE_END_OF_CENTRAL_DIRECTORY;
|
|
9528
9871
|
exports.WARNING_PREPENDED_CENTRAL_DIRECTORY = WARNING_PREPENDED_CENTRAL_DIRECTORY;
|
|
9529
9872
|
exports.WARNING_PREPENDED_DATA = WARNING_PREPENDED_DATA;
|
|
9530
9873
|
exports.WARNING_TRAILING_CENTRAL_DIRECTORY_DATA = WARNING_TRAILING_CENTRAL_DIRECTORY_DATA;
|