@zip.js/zip.js 2.15.0 → 2.16.1
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/BENCHMARKS.md +4 -2
- package/deno.json +1 -1
- package/dist/zip-core-external.js +410 -227
- package/dist/zip-core-external.min.js +1 -1
- package/dist/zip-core.js +234 -109
- package/dist/zip-core.min.js +1 -1
- package/dist/zip-fs-core-external.js +552 -237
- package/dist/zip-fs-core-external.min.js +1 -1
- package/dist/zip-fs-core.js +377 -118
- package/dist/zip-fs-core.min.js +1 -1
- package/dist/zip-fs-external.js +552 -237
- package/dist/zip-fs-external.min.js +1 -1
- package/dist/zip-fs-native.js +379 -120
- package/dist/zip-fs-native.min.js +1 -1
- package/dist/zip-fs.js +554 -237
- package/dist/zip-fs.min.js +1 -1
- package/dist/zip-legacy.js +236 -111
- package/dist/zip-legacy.min.js +1 -1
- package/dist/zip-native.js +236 -111
- 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 +411 -228
- package/dist/zip.min.js +1 -1
- package/eslint.config.mjs +1 -1
- package/index-native.cjs +379 -120
- package/index-native.min.js +1 -1
- package/index.cjs +554 -237
- package/index.d.cts +143 -16
- package/index.d.ts +143 -16
- package/index.min.js +1 -1
- package/lib/core/io.js +3 -2
- package/lib/core/streams/aes-crypto-stream.js +60 -17
- package/lib/core/streams/zip-crypto-stream.js +7 -7
- package/lib/core/streams/zip-entry-stream.js +146 -73
- package/lib/core/streams/zlib-wasm/zlib-streams.js +176 -118
- package/lib/core/util/compatible-streams.js +10 -5
- package/lib/core/version.js +1 -1
- package/lib/core/web-worker-inline-native.js +1 -1
- package/lib/core/web-worker-inline-wasm.js +1 -1
- package/lib/core/zip-fs.js +144 -10
- package/lib/core/zip-reader.js +5 -5
- package/lib/core/zip-writer.js +4 -2
- package/package.json +3 -2
package/index.cjs
CHANGED
|
@@ -217,7 +217,7 @@ const ERR_INVALID_SIGNAL = "Invalid signal (must be an AbortSignal instance)";
|
|
|
217
217
|
const ERR_INVALID_PASSWORD_TYPE = "Invalid password (password must be a string, rawPassword must be a Uint8Array)";
|
|
218
218
|
const ERR_INVALID_PASS_THROUGH_VALUE = "Invalid passThrough option (must be a boolean or 'compressed')";
|
|
219
219
|
const ERR_ABORTED = "The operation was aborted";
|
|
220
|
-
const ABORT_ERROR_NAME = "AbortError";
|
|
220
|
+
const ABORT_ERROR_NAME$1 = "AbortError";
|
|
221
221
|
|
|
222
222
|
function checkFunctionOption(value) {
|
|
223
223
|
if (value && typeof value != FUNCTION_TYPE) {
|
|
@@ -235,7 +235,7 @@ function checkSignalOption(signal) {
|
|
|
235
235
|
|
|
236
236
|
function throwIfAborted(signal) {
|
|
237
237
|
if (signal && signal.aborted) {
|
|
238
|
-
throw signal.reason === UNDEFINED_VALUE ? new DOMException(ERR_ABORTED, ABORT_ERROR_NAME) : signal.reason;
|
|
238
|
+
throw signal.reason === UNDEFINED_VALUE ? new DOMException(ERR_ABORTED, ABORT_ERROR_NAME$1) : signal.reason;
|
|
239
239
|
}
|
|
240
240
|
}
|
|
241
241
|
|
|
@@ -439,7 +439,7 @@ function resetConfiguration() {
|
|
|
439
439
|
Object.assign(config, DEFAULT_CONFIGURATION);
|
|
440
440
|
}
|
|
441
441
|
|
|
442
|
-
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 n$1="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e$1=t=>t({workerURI:t=>{const e="text/javascript";let r='!function(t){"function"==typeof define&&define.amd?define(t):t()}(function(){"use strict";const{Array:t,Object:n,Number:e,Math:o,Error:r,Uint8Array:s,Uint16Array:c,Uint32Array:i,Int32Array:a,Map:f,DataView:u,Promise:w,TextEncoder:l,crypto:h,postMessage:p,TransformStream:d,ReadableStream:y,WritableStream:m,CompressionStream:S,DecompressionStream:g}=self,v=void 0,z="undefined",b="function",k=new s,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,D,F,E]=C;class R{constructor(t){this.o=t||-1}append(t){let n=0|this.o;const e=0|t.length;let o=0;if(e>=8&&t.buffer){const r=new u(t.buffer,t.byteOffset,e),s=e-8;for(;o<=s;o+=8){const t=n^r.getInt32(o,!0),e=r.getInt32(o+4,!0);n=E[255&t]^F[t>>>8&255]^D[t>>>16&255]^P[t>>>24&255]^M[255&e]^x[e>>>8&255]^A[e>>>16&255]^I[e>>>24&255]}}for(;o<e;o++)n=n>>>8^I[255&(n^t[o])];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 s(4);new u(e.buffer).setUint32(0,n.get()),t.value=e}}),t=this}}function B(t,n){const e=new s(t.length+n.length);return e.set(t),e.set(n,t.length),e}function T(t){return new u(t.buffer,t.byteOffset,t.byteLength)}const V=64,W=20,j=new s([128]),K=new s(1),O=new a([1732584193,4023233417,2562383102,271733878,3285377520]),H=new s(256),L=new a(256),N=new a(256),q=new a(256),G=new a(256);let J=!1;function Q(t,n){!function(){if(!J){let t=1,n=1;do{t=255&(t^t<<1^(128&t?27:0)),n=255&(n^n<<1),n=255&(n^n<<2),n=255&(n^n<<4),128&n&&(n^=9),H[t]=255&(n^(n<<1|n>>7)^(n<<2|n>>6)^(n<<3|n>>5)^(n<<4|n>>4)^99)}while(1!=t);H[0]=99;for(let t=0;t<256;t++){const n=H[t],e=$(n),o=e<<24|n<<16|n<<8|e^n;L[t]=o,N[t]=o>>>8|o<<24,q[t]=o>>>16|o<<16,G[t]=o>>>24|o<<8}J=!0}}();const e=new a(60),o=function(t,n){const e=t.length>>2,o=e+6,r=4*(o+1);let s=1;for(let o=0;o<e;o++)n[o]=t[4*o]<<24|t[4*o+1]<<16|t[4*o+2]<<8|t[4*o+3];for(let t=e;t<r;t++){let o=n[t-1];t%e==0?(o=Y(o<<8|o>>>24)^s<<24,s=$(s)):e>6&&t%e==4&&(o=Y(o)),n[t]=n[t-e]^o}return o}(t,e),r=new a(4),s=X(n);let c=0,i=0,f=0,w=0;return{process(t,n){n&&s.update(t,0,t.length),function(t){const n=new u(t.buffer,t.byteOffset,t.byteLength),e=t.length;let o=0;for(;o+16<=e;o+=16)l(),n.setInt32(o,n.getInt32(o)^r[0]),n.setInt32(o+4,n.getInt32(o+4)^r[1]),n.setInt32(o+8,n.getInt32(o+8)^r[2]),n.setInt32(o+12,n.getInt32(o+12)^r[3]);if(o<e){l();for(let n=0;o<e;o++,n++)t[o]^=r[n>>2]>>>24-8*(3&n)}}(t),n||s.update(t,0,t.length)},digest:()=>s.digest()};function l(){c=c+1|0,c||(i=i+1|0,i||(f=f+1|0,f||(w=w+1|0)));let t=Z(c)^e[0],n=Z(i)^e[1],s=Z(f)^e[2],a=Z(w)^e[3],u=L[t>>>24]^N[n>>>16&255]^q[s>>>8&255]^G[255&a]^e[4],l=L[n>>>24]^N[s>>>16&255]^q[a>>>8&255]^G[255&t]^e[5],h=L[s>>>24]^N[a>>>16&255]^q[t>>>8&255]^G[255&n]^e[6],p=L[a>>>24]^N[t>>>16&255]^q[n>>>8&255]^G[255&s]^e[7];t=L[u>>>24]^N[l>>>16&255]^q[h>>>8&255]^G[255&p]^e[8],n=L[l>>>24]^N[h>>>16&255]^q[p>>>8&255]^G[255&u]^e[9],s=L[h>>>24]^N[p>>>16&255]^q[u>>>8&255]^G[255&l]^e[10],a=L[p>>>24]^N[u>>>16&255]^q[l>>>8&255]^G[255&h]^e[11],u=L[t>>>24]^N[n>>>16&255]^q[s>>>8&255]^G[255&a]^e[12],l=L[n>>>24]^N[s>>>16&255]^q[a>>>8&255]^G[255&t]^e[13],h=L[s>>>24]^N[a>>>16&255]^q[t>>>8&255]^G[255&n]^e[14],p=L[a>>>24]^N[t>>>16&255]^q[n>>>8&255]^G[255&s]^e[15],t=L[u>>>24]^N[l>>>16&255]^q[h>>>8&255]^G[255&p]^e[16],n=L[l>>>24]^N[h>>>16&255]^q[p>>>8&255]^G[255&u]^e[17],s=L[h>>>24]^N[p>>>16&255]^q[u>>>8&255]^G[255&l]^e[18],a=L[p>>>24]^N[u>>>16&255]^q[l>>>8&255]^G[255&h]^e[19],u=L[t>>>24]^N[n>>>16&255]^q[s>>>8&255]^G[255&a]^e[20],l=L[n>>>24]^N[s>>>16&255]^q[a>>>8&255]^G[255&t]^e[21],h=L[s>>>24]^N[a>>>16&255]^q[t>>>8&255]^G[255&n]^e[22],p=L[a>>>24]^N[t>>>16&255]^q[n>>>8&255]^G[255&s]^e[23],t=L[u>>>24]^N[l>>>16&255]^q[h>>>8&255]^G[255&p]^e[24],n=L[l>>>24]^N[h>>>16&255]^q[p>>>8&255]^G[255&u]^e[25],s=L[h>>>24]^N[p>>>16&255]^q[u>>>8&255]^G[255&l]^e[26],a=L[p>>>24]^N[u>>>16&255]^q[l>>>8&255]^G[255&h]^e[27],u=L[t>>>24]^N[n>>>16&255]^q[s>>>8&255]^G[255&a]^e[28],l=L[n>>>24]^N[s>>>16&255]^q[a>>>8&255]^G[255&t]^e[29],h=L[s>>>24]^N[a>>>16&255]^q[t>>>8&255]^G[255&n]^e[30],p=L[a>>>24]^N[t>>>16&255]^q[n>>>8&255]^G[255&s]^e[31],t=L[u>>>24]^N[l>>>16&255]^q[h>>>8&255]^G[255&p]^e[32],n=L[l>>>24]^N[h>>>16&255]^q[p>>>8&255]^G[255&u]^e[33],s=L[h>>>24]^N[p>>>16&255]^q[u>>>8&255]^G[255&l]^e[34],a=L[p>>>24]^N[u>>>16&255]^q[l>>>8&255]^G[255&h]^e[35],u=L[t>>>24]^N[n>>>16&255]^q[s>>>8&255]^G[255&a]^e[36],l=L[n>>>24]^N[s>>>16&255]^q[a>>>8&255]^G[255&t]^e[37],h=L[s>>>24]^N[a>>>16&255]^q[t>>>8&255]^G[255&n]^e[38],p=L[a>>>24]^N[t>>>16&255]^q[n>>>8&255]^G[255&s]^e[39];let d=40;o>10&&(t=L[u>>>24]^N[l>>>16&255]^q[h>>>8&255]^G[255&p]^e[40],n=L[l>>>24]^N[h>>>16&255]^q[p>>>8&255]^G[255&u]^e[41],s=L[h>>>24]^N[p>>>16&255]^q[u>>>8&255]^G[255&l]^e[42],a=L[p>>>24]^N[u>>>16&255]^q[l>>>8&255]^G[255&h]^e[43],u=L[t>>>24]^N[n>>>16&255]^q[s>>>8&255]^G[255&a]^e[44],l=L[n>>>24]^N[s>>>16&255]^q[a>>>8&255]^G[255&t]^e[45],h=L[s>>>24]^N[a>>>16&255]^q[t>>>8&255]^G[255&n]^e[46],p=L[a>>>24]^N[t>>>16&255]^q[n>>>8&255]^G[255&s]^e[47],d=48),o>12&&(t=L[u>>>24]^N[l>>>16&255]^q[h>>>8&255]^G[255&p]^e[48],n=L[l>>>24]^N[h>>>16&255]^q[p>>>8&255]^G[255&u]^e[49],s=L[h>>>24]^N[p>>>16&255]^q[u>>>8&255]^G[255&l]^e[50],a=L[p>>>24]^N[u>>>16&255]^q[l>>>8&255]^G[255&h]^e[51],u=L[t>>>24]^N[n>>>16&255]^q[s>>>8&255]^G[255&a]^e[52],l=L[n>>>24]^N[s>>>16&255]^q[a>>>8&255]^G[255&t]^e[53],h=L[s>>>24]^N[a>>>16&255]^q[t>>>8&255]^G[255&n]^e[54],p=L[a>>>24]^N[t>>>16&255]^q[n>>>8&255]^G[255&s]^e[55],d=56),r[0]=(H[u>>>24]<<24|H[l>>>16&255]<<16|H[h>>>8&255]<<8|H[255&p])^e[d],r[1]=(H[l>>>24]<<24|H[h>>>16&255]<<16|H[p>>>8&255]<<8|H[255&u])^e[d+1],r[2]=(H[h>>>24]<<24|H[p>>>16&255]<<16|H[u>>>8&255]<<8|H[255&l])^e[d+2],r[3]=(H[p>>>24]<<24|H[u>>>16&255]<<16|H[l>>>8&255]<<8|H[255&h])^e[d+3]}}function X(t){const n=function(){const t=new a(O),n=new a(16),e=new s(V),r=new u(e.buffer),c=new s(8);let i=0,f=0;return{update:w,digest:function(){const n=8*f,e=o.floor(n/4294967296),r=n>>>0;for(w(j,0,1);56!=i;)w(K,0,1);c[0]=e>>>24,c[1]=e>>>16,c[2]=e>>>8,c[3]=e,c[4]=r>>>24,c[5]=r>>>16,c[6]=r>>>8,c[7]=r,w(c,0,8);const a=new s(W),l=new u(a.buffer);for(let n=0;n<t.length;n++)l.setInt32(4*n,t[n]);return t.set(O),i=0,f=0,a}};function w(t,n,o){const s=n+o;if(f+=o,i){for(;n<s&&i<V;)e[i++]=t[n++];i==V&&(l(r,0),i=0)}if(n+V<=s){const e=new u(t.buffer,t.byteOffset,t.byteLength);for(;n+V<=s;n+=V)l(e,n)}for(;n<s;)e[i++]=t[n++]}function l(e,o){for(let t=0;t<16;t++)n[t]=e.getInt32(o+4*t);let r,s=t[0],c=t[1],i=t[2],a=t[3],f=t[4];for(let t=0;t<15;t+=5)f=(s<<5|s>>>27)+((i^a)&c^a)+f+1518500249+n[t]|0,c=c<<30|c>>>2,a=(f<<5|f>>>27)+((c^i)&s^i)+a+1518500249+n[t+1]|0,s=s<<30|s>>>2,i=(a<<5|a>>>27)+((s^c)&f^c)+i+1518500249+n[t+2]|0,f=f<<30|f>>>2,c=(i<<5|i>>>27)+((f^s)&a^s)+c+1518500249+n[t+3]|0,a=a<<30|a>>>2,s=(c<<5|c>>>27)+((a^f)&i^f)+s+1518500249+n[t+4]|0,i=i<<30|i>>>2;f=(s<<5|s>>>27)+((i^a)&c^a)+f+1518500249+n[15]|0,c=c<<30|c>>>2,r=n[13]^n[8]^n[2]^n[0],r=r<<1|r>>>31,n[0]=r,a=(f<<5|f>>>27)+((c^i)&s^i)+a+1518500249+r|0,s=s<<30|s>>>2,r=n[14]^n[9]^n[3]^n[1],r=r<<1|r>>>31,n[1]=r,i=(a<<5|a>>>27)+((s^c)&f^c)+i+1518500249+r|0,f=f<<30|f>>>2,r=n[15]^n[10]^n[4]^n[2],r=r<<1|r>>>31,n[2]=r,c=(i<<5|i>>>27)+((f^s)&a^s)+c+1518500249+r|0,a=a<<30|a>>>2,r=n[0]^n[11]^n[5]^n[3],r=r<<1|r>>>31,n[3]=r,s=(c<<5|c>>>27)+((a^f)&i^f)+s+1518500249+r|0,i=i<<30|i>>>2;for(let t=20;t<40;t+=5)r=n[t-3&15]^n[t-8&15]^n[t-14&15]^n[15&t],r=r<<1|r>>>31,n[15&t]=r,f=(s<<5|s>>>27)+(c^i^a)+f+1859775393+r|0,c=c<<30|c>>>2,r=n[t-2&15]^n[t-7&15]^n[t-13&15]^n[t+1&15],r=r<<1|r>>>31,n[t+1&15]=r,a=(f<<5|f>>>27)+(s^c^i)+a+1859775393+r|0,s=s<<30|s>>>2,r=n[t-1&15]^n[t-6&15]^n[t-12&15]^n[t+2&15],r=r<<1|r>>>31,n[t+2&15]=r,i=(a<<5|a>>>27)+(f^s^c)+i+1859775393+r|0,f=f<<30|f>>>2,r=n[15&t]^n[t-5&15]^n[t-11&15]^n[t+3&15],r=r<<1|r>>>31,n[t+3&15]=r,c=(i<<5|i>>>27)+(a^f^s)+c+1859775393+r|0,a=a<<30|a>>>2,r=n[t+1&15]^n[t-4&15]^n[t-10&15]^n[t+4&15],r=r<<1|r>>>31,n[t+4&15]=r,s=(c<<5|c>>>27)+(i^a^f)+s+1859775393+r|0,i=i<<30|i>>>2;for(let t=40;t<60;t+=5)r=n[t-3&15]^n[t-8&15]^n[t-14&15]^n[15&t],r=r<<1|r>>>31,n[15&t]=r,f=(s<<5|s>>>27)+(c&i|(c|i)&a)+f+2400959708+r|0,c=c<<30|c>>>2,r=n[t-2&15]^n[t-7&15]^n[t-13&15]^n[t+1&15],r=r<<1|r>>>31,n[t+1&15]=r,a=(f<<5|f>>>27)+(s&c|(s|c)&i)+a+2400959708+r|0,s=s<<30|s>>>2,r=n[t-1&15]^n[t-6&15]^n[t-12&15]^n[t+2&15],r=r<<1|r>>>31,n[t+2&15]=r,i=(a<<5|a>>>27)+(f&s|(f|s)&c)+i+2400959708+r|0,f=f<<30|f>>>2,r=n[15&t]^n[t-5&15]^n[t-11&15]^n[t+3&15],r=r<<1|r>>>31,n[t+3&15]=r,c=(i<<5|i>>>27)+(a&f|(a|f)&s)+c+2400959708+r|0,a=a<<30|a>>>2,r=n[t+1&15]^n[t-4&15]^n[t-10&15]^n[t+4&15],r=r<<1|r>>>31,n[t+4&15]=r,s=(c<<5|c>>>27)+(i&a|(i|a)&f)+s+2400959708+r|0,i=i<<30|i>>>2;for(let t=60;t<80;t+=5)r=n[t-3&15]^n[t-8&15]^n[t-14&15]^n[15&t],r=r<<1|r>>>31,n[15&t]=r,f=(s<<5|s>>>27)+(c^i^a)+f+3395469782+r|0,c=c<<30|c>>>2,r=n[t-2&15]^n[t-7&15]^n[t-13&15]^n[t+1&15],r=r<<1|r>>>31,n[t+1&15]=r,a=(f<<5|f>>>27)+(s^c^i)+a+3395469782+r|0,s=s<<30|s>>>2,r=n[t-1&15]^n[t-6&15]^n[t-12&15]^n[t+2&15],r=r<<1|r>>>31,n[t+2&15]=r,i=(a<<5|a>>>27)+(f^s^c)+i+3395469782+r|0,f=f<<30|f>>>2,r=n[15&t]^n[t-5&15]^n[t-11&15]^n[t+3&15],r=r<<1|r>>>31,n[t+3&15]=r,c=(i<<5|i>>>27)+(a^f^s)+c+3395469782+r|0,a=a<<30|a>>>2,r=n[t+1&15]^n[t-4&15]^n[t-10&15]^n[t+4&15],r=r<<1|r>>>31,n[t+4&15]=r,s=(c<<5|c>>>27)+(i^a^f)+s+3395469782+r|0,i=i<<30|i>>>2;t[0]=t[0]+s|0,t[1]=t[1]+c|0,t[2]=t[2]+i|0,t[3]=t[3]+a|0,t[4]=t[4]+f|0}}(),e=new s(V),r=new s(V);t.length>V&&(n.update(t,0,t.length),t=n.digest());for(let n=0;n<V;n++){const o=n<t.length?t[n]:0;e[n]=54^o,r[n]=92^o}return n.update(e,0,V),{update(t,e,o){n.update(t,e,o)},digest(){const t=n.digest();n.update(r,0,V),n.update(t,0,W);const o=n.digest();return n.update(e,0,V),o}}}function Y(t){return H[t>>>24]<<24|H[t>>>16&255]<<16|H[t>>>8&255]<<8|H[255&t]}function Z(t){return t<<24|(65280&t)<<8|t>>>8&65280|t>>>24}function $(t){return 255&(t<<1^27*(t>>7))}const _=typeof h!=z&&typeof h.getRandomValues==b,tt="Invalid password",nt="zipjs-abort-check-password";function et(t){if(_)return h.getRandomValues(t);throw new r("Crypto API not supported")}const ot={name:"PBKDF2"},rt=n.assign({hash:{name:"HMAC"}},ot),st=n.assign({iterations:1e3,hash:{name:"SHA-1"}},ot),ct=["deriveBits"],it=[8,12,16],at=[16,24,32],ft=10,ut=typeof h!=z,wt=ut&&h.subtle;let lt=ut&&typeof wt!=z&&typeof wt.importKey==b&&typeof wt.deriveBits==b,ht=Q;class pt extends d{constructor({password:t,rawPassword:n,encryptionStrength:e,checkPasswordOnly:o,checkAuthenticationCode:c=!0}){super({start(){yt(this,t,n,e)},async transform(t,n){const e=this,{password:c,strength:i,l:a,ready:f}=e;c?(await async function(t,n,e,o){const s=await gt(t,n,e,zt(o,0,it[n])),c=zt(o,it[n]);if(s[0]!=c[0]||s[1]!=c[1])throw St(t),new r(tt)}(e,i,c,zt(t,0,it[i]+2)),t=zt(t,it[i]+2),o?(St(e),n.error(new r(nt))):a()):await f;const u=new s(t.length-ft-(t.length-ft)%16);n.enqueue(mt(e,t,u,0,ft,!0))},async flush(t){const{h:n,m:e,ready:o}=this;if(n){await o;const i=zt(e,e.length-ft),a=new s(zt(e,0,e.length-ft));n.process(a,!0);const f=n.digest();let u=e.length<ft?1:0;for(let t=0;t<ft;t++)u|=f[t]^i[t];if(u&&c)throw new r("Invalid authentication code");t.enqueue(a)}},cancel(){St(this)}})}}class dt extends d{constructor({password:t,rawPassword:n,encryptionStrength:e}){super({start(){yt(this,t,n,e)},async transform(t,n){const e=this,{password:o,strength:r,l:c,ready:i}=e;let a=k;o?(a=await async function(t,n,e){const o=et(new s(it[n]));return B(o,await gt(t,n,e,o))}(e,r,o),c()):await i;const f=new s(a.length+t.length-t.length%16);f.set(a,0),n.enqueue(mt(e,t,f,a.length,0,!1))},async flush(t){const{h:n,m:e,ready:o}=this;if(n){await o;const r=new s(e);n.process(r,!1);const c=zt(n.digest(),0,ft);t.enqueue(B(r,c))}},cancel(){St(this)}})}}function yt(t,e,o,r){n.assign(t,{ready:new w(n=>t.l=n),password:vt(e,o),strength:r-1,m:k})}function mt(t,n,e,o,r,c){const{h:i,m:a}=t;a.length&&(n=B(a,n));const f=n.length-r,u=f-f%16;if(e=function(t,n){if(n&&n>t.length){const e=t;(t=new s(n)).set(e,0)}return t}(e,o+u),u){const t=zt(e,o,o+u);t.set(zt(n,0,u)),i.process(t,c)}return t.m=zt(n,u),e}function St({h:t}){t&&t.dispose&&t.dispose()}async function gt(t,e,r,c){t.password=null;const i=at[e],a=await async function(t,e,r){if(lt)try{const o=await wt.importKey("raw",t,rt,!1,ct);return new s(await wt.deriveBits(n.assign({salt:e},st),o,8*r))}catch{lt=!1}return function(t,n,e,r){const c=X(t),i=new s(r),a=new s(n.length+4),f=new u(a.buffer);a.set(n);for(let t=1,e=0;e<r;t++,e+=W){f.setUint32(n.length,t),c.update(a,0,a.length);let s=c.digest();const u=s.slice();for(let t=1;t<1e3;t++){c.update(s,0,W),s=c.digest();for(let t=0;t<W;t++)u[t]^=s[t]}i.set(u.subarray(0,o.min(W,r-e)),e)}return i}(t,e,0,r)}(r,c,2*i+2);return t.h=ht(zt(a,0,i),zt(a,i,2*i)),zt(a,2*i)}function vt(t,n){return n===v?function(t){if(typeof l==z){t=unescape(encodeURIComponent(t));const n=new s(t.length);for(let e=0;e<n.length;e++)n[e]=t.charCodeAt(e);return n}return(new l).encode(t)}(t):n}function zt(t,n,e){return t.subarray(n,e)}class bt extends d{constructor({password:t,rawPassword:n,passwordVerification:e,checkPasswordOnly:o}){super({start(){Ct(this,t,n,e)},transform(t,n){const e=this;if(e.password||e.rawPassword){const n=It(e,t.subarray(0,12));if(e.password=e.rawPassword=null,0!=(n[11]^e.passwordVerification))throw new r(tt);t=t.subarray(12)}o?n.error(new r(nt)):n.enqueue(It(e,t))}})}}class kt extends d{constructor({password:t,rawPassword:n,passwordVerification:e}){super({start(){Ct(this,t,n,e)},transform(t,n){const e=this;let o,r;if(e.password||e.rawPassword){e.password=e.rawPassword=null;const n=et(new s(12));n[11]=e.passwordVerification,o=new s(t.length+n.length),o.set(At(e,n),0),r=12}else o=new s(t.length),r=0;o.set(At(e,t),r),n.enqueue(o)}})}}function Ct(t,e,o,r){n.assign(t,{password:e,rawPassword:o,passwordVerification:r}),function(t,e,o){const r=[305419896,591751049,878082192];if(n.assign(t,{keys:r,S:new R(r[0]),v:new R(r[2])}),o)for(let n=0;n<o.length;n++)xt(t,o[n]);else for(let n=0;n<e.length;n++)xt(t,e.charCodeAt(n))}(t,e,o)}function It(t,n){const e=new s(n.length);for(let o=0;o<n.length;o++)e[o]=Mt(t)^n[o],xt(t,e[o]);return e}function At(t,n){const e=new s(n.length);for(let o=0;o<n.length;o++)e[o]=Mt(t)^n[o],xt(t,n[o]);return e}function xt(t,n){let[,e]=t.keys;t.S.append([n]);const r=~t.S.get();e=Dt(o.imul(Dt(e+Pt(r)),134775813)+1),t.v.append([e>>>24]);const s=~t.v.get();t.keys=[r,e,s]}function Mt(t){const n=2|t.keys[2];return Pt(o.imul(n,1^n)>>>8)}function Pt(t){return 255&t}function Dt(t){return 4294967295&t}function Ft(t){if(t instanceof y)return t;const n=t.getReader();return new y({async pull(t){const{value:e,done:o}=await n.read();o?t.close():t.enqueue(e)},cancel:t=>n.cancel(t)})}const Et=new f;function Rt(t){return Et.get(t)}const Ut="Invalid uncompressed size",Bt="deflate-raw",Tt="gzip",Vt=[31,139,8];class Wt extends d{constructor(t,{chunkSize:n,CompressionStreamFallback:e,CompressionStream:o}){super({});const{compressed:r,encrypted:s,useCompressionStream:c,zipCrypto:i,computeCrc32:a,level:f,deflate64:w,format:l,compressionMethod:h,inputSize:p}=t,d=this;let y,m,S,g=super.readable;const v=l&&Rt(l),z=function(t,n,e){return t&&n?n:e&&e.C?e:void 0}(c,o,e),b=a&&r&&!w&&!v&&(!s||i)&&Boolean(z);if(s&&!i||!a||b||(y=new U,g=qt(g,y)),r)if(v)g=Gt(g,Lt(v.CompressionStream,l,{level:f,chunkSize:n,compressionMethod:h,uncompressedSize:p}));else if(b)S=new jt,g=Gt(g,new z(Tt,{level:f,chunkSize:n})),g=qt(g,S);else try{g=Nt(g,c,{level:f,chunkSize:n},o,e)}catch(t){let n;try{n=new o(Tt)}catch{throw t}g=Gt(g,n),g=qt(g,new jt)}s&&(i?g=qt(g,new kt(t)):(m=new dt(t),g=qt(g,m))),Ht(d,g,()=>{s&&!i||!a||(d.crc32=b?S.crc32:new u(y.value.buffer).getUint32(0))})}}class jt extends d{constructor(){let t,n=10,e=new s(0);super({transform(t,r){if(n){const e=o.min(n,t.length);if(n-=e,!(t=t.subarray(e)).length)return}const s=e.length+t.length;if(s<=8)return void(e=B(e,t));const c=s-8,i=o.min(c,e.length);r.enqueue(B(e.subarray(0,i),t.subarray(0,c-i))),e=B(e.subarray(i),t.subarray(c-i))},flush(){const n=T(e);t.crc32=n.getUint32(0,!0),t.uncompressedSize=n.getUint32(4,!0)}}),t=this}}class Kt extends d{constructor(t,{chunkSize:n,DecompressionStreamFallback:e,DecompressionStream:o}){super({});const{zipCrypto:c,encrypted:i,checkCrc32:a,crc32:f,compressed:l,useCompressionStream:h,deflate64:p,format:m,compressionMethod:S,rawBitFlag:g,outputSize:z}=t;let b,k,C,I=super.readable;if(i&&(c?I=qt(I,new bt(t)):(k=new pt(t),I=qt(I,k))),l){const t=m&&Rt(m);if(t)I=Gt(I,Lt(t.DecompressionStream,m,{chunkSize:n,compressionMethod:S,rawBitFlag:g,uncompressedSize:z}));else try{I=Nt(I,h,{chunkSize:n,deflate64:p},o,e)}catch(t){if(p||z===v)throw t;let n;try{n=new o(Tt)}catch{throw t}C=new R,I=function(t,n,e,o){let c,i,a,f=0,u=!1;const l=new w((t,n)=>{i=t,a=n});l.catch(()=>{}),e||i();const h=new d({start(t){const n=new s(10);n.set(Vt),t.enqueue(n)},transform(t,n){n.enqueue(t)},async flush(t){u=!0,y();try{await l}finally{m()}const n=new s(8),r=T(n);r.setUint32(0,o.get(),!0),r.setUint32(4,e,!0),t.enqueue(n)},cancel(t){a(t)}}),p=new d({transform(t,n){o.append(t),f+=t.length,f>=e?i():u&&y(),n.enqueue(t)},cancel(t){a(t)}});return t=qt(t,h),qt(t=Gt(t,n),p);function y(){m(),c=setTimeout(()=>a(new r(Ut)),5e3)}function m(){clearTimeout(c)}}(I,n,z,C)}I=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:o,done:s}=e;s?t.close():t.enqueue(o)},cancel:t=>n.cancel(t)})}(I)}a&&!C&&(b=new U,I=qt(I,b)),Ht(this,I,()=>{if(a){const t=C?C.get()>>>0:new u(b.value.buffer).getUint32(0,!1);if(f!=t)throw new r("Invalid CRC32")}})}}const Ot=new f;function Ht(t,e,o){e=qt(e,new d({flush:o})),n.defineProperty(t,"readable",{get:()=>e})}function Lt(t,n,e){if(!t)throw new r("Compression method not supported");return new t(n,e)}function Nt(t,n,e,o,r){const s=n&&o?o:r||o,c=e.deflate64?"deflate64-raw":Bt;let i;try{i=new s(c,e)}catch(t){if(!n||!r||s==r)throw t;i=new r(c,e)}return Gt(t,i)}function qt(t,n){return Ft(t).pipeThrough(n)}function Gt(t,n){const e=n.writable.getWriter(),o=t.getReader();return async function(){try{for(;;){await e.ready;const t=await o.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{}}(o,t)}}(),n.readable}const Jt="data",Qt="deflate";class Xt extends d{constructor(t,e){super({});const o=this,{codecType:s}=t;let c;s.startsWith(Qt)?c=Wt:s.startsWith("inflate")&&(c=Kt),o.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(o,{inputSize:i})}}),w=new d({transform(n,e){if(n&&n.length&&(e.enqueue(n),o.outputSize+=n.length,t.outputSize!==v&&o.outputSize>t.outputSize))throw new r(Ut)},flush(){const{crc32:t}=a;n.assign(o,{crc32:t,inputSize:i})}});n.defineProperty(o,"readable",{get:()=>f.pipeThrough(u).pipeThrough(a).pipeThrough(w)})}}class Yt extends d{constructor(t){const o=[];let r=0,c=0;function i(){const n=new s(t);let e=0;for(;e<t;){const r=o[0],s=t-e;r.length<=s?(n.set(r,e),e+=r.length,o.shift()):(n.set(r.subarray(0,s),e),o[0]=r.subarray(s),e+=s)}return r-=t,n}(!e.isFinite(t)||t<1)&&(t=65536),super({transform(n,e){for(o.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 s(n);let o=0;for(const n of t)e.set(n,o),o+=n.length;return e}(o,r)))}}),n.defineProperty(this,"outputSize",{get:()=>c})}}let Zt=2;try{typeof navigator!=z&&navigator.hardwareConcurrency&&(Zt=navigator.hardwareConcurrency)}catch{}function $t(t){return Boolean(t)&&"object"==typeof t}const _t=new f,tn=new f,nn=function(){try{return structuredClone(new r)instanceof r}catch{return!1}}();let en=0;async function on(t){let n,s,c;try{const{options:i,config:a}=t;if(i.format)try{await async function(t,n){!Et.has(t)&&n&&function(t,n){const{CompressionStream:e,DecompressionStream:o}=n;if(typeof e!=b&&typeof o!=b)throw new r("Invalid codec module");Et.set(t,{CompressionStream:e,DecompressionStream:o})}(t,await(import(n)))}(i.format,i.codecURI)}catch(t){if($t(t))try{t.codecImportFailed=!0}catch{}throw 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=Ot.get(t);e||(e=new f,Ot.set(t,e));let o=e.get(n);if(o===v){try{new t(n),o=!0}catch{o=!1}e.set(n,o)}return o}(i.codecType.startsWith(Qt)?a.CompressionStream:a.DecompressionStream,Bt))try{await self.initModule(t.config)}catch{}}else try{await self.initModule(t.config)}catch{i.useCompressionStream=!0}if(i.encrypted&&!i.zipCrypto)try{await self.initModule(t.config)}catch{}!a.CompressionStreamFallback&&a.CompressionStreamZlib&&(a.CompressionStreamFallback=a.CompressionStreamZlib),!a.DecompressionStreamFallback&&a.DecompressionStreamZlib&&(a.DecompressionStreamFallback=a.DecompressionStreamZlib);const u={highWaterMark:1},l=t.readable?Ft(t.readable):new y({async pull(t){const n=new w(t=>_t.set(en,t));rn({type:"pull",messageId:en}),en=(en+1)%e.MAX_SAFE_INTEGER;const{value:o,done:r}=await n;t.enqueue(o),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 o=new w(t=>n=t);tn.set(en,n),rn({type:Jt,value:t,messageId:en}),en=(en+1)%e.MAX_SAFE_INTEGER,await o}},u),n=new Xt(i,a),s=new Yt(function(t){return r="string"==typeof(n=r=t.chunkSize)&&n.trim()?e(n):n,e.isInteger(r)&&r>=1?o.max(r,64):65536;var n,r}(a)),await l.pipeThrough(n).pipeThrough(s).pipeTo(c,{preventClose:!0,preventAbort:!0}),await c.getWriter().close();const{crc32:h,inputSize:p,outputSize:d}=n;rn({type:"close",result:{crc32:h,inputSize:p,outputSize:d}})}catch(t){const n=s?s.outputSize:0;if($t(t))try{t.outputSize=n}catch{}if(c&&!c.locked)try{await c.getWriter().close()}catch{}sn(t,n)}}function rn(t){const{value:n}=t;if(n)if(n.length)try{t.value=(e=n,e.byteOffset||e.byteLength!=e.buffer.byteLength?new s(e):e).buffer,p(t,[t.value])}catch{p(t)}else p(t);else p(t);var e}function sn(t,n){const{message:e,stack:o,code:s,name:c,outputSize:i,cause:a,codecImportFailed:f}=function(t=new r("Unknown error")){return $t(t)?t:new r(String(t))}(t),u={message:e,stack:o,code:s,name:c,outputSize:i===v?n:i};if(a&&(u.cause={name:a.name,message:a.message}),f&&(u.codecImportFailed=!0),nn)try{return void p({error:u,errorValue:{value:t}})}catch{}p({error:u})}addEventListener("message",({data:t})=>{const{type:n,messageId:e,value:o,done:r}=t;try{if("start"==n&&on(t),n==Jt){const t=_t.get(e);_t.delete(e),t({value:o||new s,done:r})}if("ack"==n){const t=tn.get(e);tn.delete(e),t()}}catch(t){sn(t)}}),p({type:"ready"});const cn="deflate",an="deflate-raw",fn="deflate64-raw",un="gzip";let wn,ln,hn,pn,dn;function yn(t,n,e={}){if(!wn){const t=new r("WASM module not loaded");throw t.cause=dn,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.I=ln(i),this.in=ln(a),this.inBufferSize=a,!this.I||!this.in)throw new r("allocation failed");if(t?(this.A=wn.deflate_process,this.M=wn.deflate_last_consumed,this.P=wn.deflate_end,this.D=wn.deflate_new(),e=n===un?wn.deflate_init_gzip(this.D,c):n===an?wn.deflate_init_raw(this.D,c):wn.deflate_init(this.D,c)):n===fn?(this.A=wn.inflate9_process,this.M=wn.inflate9_last_consumed,this.P=wn.inflate9_end,this.D=wn.inflate9_new(),e=wn.inflate9_init_raw(this.D)):(this.A=wn.inflate_process,this.M=wn.inflate_last_consumed,this.P=wn.inflate_end,this.D=wn.inflate_new(),e=n===an?wn.inflate_init_raw(this.D):n===un?wn.inflate_init_gzip(this.D):wn.inflate_init(this.D)),0!==e)throw new r("init failed:"+e)}catch(t){throw f(this),t}},transform(t,n){try{const e=t,c=new s(pn.buffer),a=this.A,f=this.M,u=this.I;let w=0;for(;w<e.length;){const t=o.min(e.length-w,32768);if((!this.in||this.inBufferSize<t)&&(this.in&&hn&&(hn(this.in),this.in=0),this.in=ln(t),this.inBufferSize=t,!this.in))throw new r("allocation failed");c.set(e.subarray(w,w+t),this.in);const s=a(this.D,this.in,t,u,i,0),l=s>>24&255,h=128&l?l-256:l;if(h<0)throw new r("process error:"+h);const p=16777215&s;p&&n.enqueue(c.slice(u,u+p));const d=f(this.D);if(0===d&&0===p)break;w+=d}}catch(t){f(this),n.error(t)}},flush(t){try{const n=new s(pn.buffer),e=this.A,o=this.I;for(;;){const s=e(this.D,0,0,o,i,4),c=s>>24&255,a=128&c?c-256:c;if(a<0)throw new r("process error:"+a);const f=16777215&s;if(f&&t.enqueue(n.slice(o,o+f)),1===c||0===f)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.D&&t.P&&(n=t.P(t.D)),t.D=0,t.in&&hn&&hn(t.in),t.in=0,t.I&&hn&&hn(t.I),t.I=0,n}}class mn{constructor(t=cn,n){return yn(!0,t,n)}}class Sn{constructor(t=cn,n){return yn(!1,t,n)}}mn.C=!0,Sn.C=!0,mn.F=[cn,an,un],Sn.F=[cn,an,un,fn];const gn=65536;let vn,zn;function bn(t){return new s(t.memory.buffer)}let kn=!1;!function(t={}){const{init:n,R:e}=t,o=t.CompressionStreamFallback||t.CompressionStreamZlib,r=t.DecompressionStreamFallback||t.DecompressionStreamZlib;e&&(ht=e||Q),self.initModule=async t=>{n&&await n(t),o&&(t.CompressionStreamFallback=o),r&&(t.DecompressionStreamFallback=r)}}({CompressionStreamFallback:mn,DecompressionStreamFallback:Sn,R:function(t,n){const e=vn;let o=e?function(t,n,e){zn||(zn=t.malloc(gn));const o=zn?t.aes_hmac_new():0;if(o){const r=bn(t);if(r.set(n,zn),r.set(e,zn+n.length),t.aes_hmac_init(o,zn,n.length,zn+n.length,e.length))return t.aes_hmac_end(o,0),0}return o}(e,t,n):0;if(!o)return Q(t,n);const r=zn;return{process(t,n){for(let s=0;s<t.length;s+=gn){const c=t.subarray(s,s+gn),i=bn(e);i.set(c,r),e.aes_hmac_process(o,r,c.length,n?1:0),c.set(i.subarray(r,r+c.length))}},digest:()=>(e.aes_hmac_end(o,r),o=0,bn(e).slice(r,r+20)),dispose(){o&&(e.aes_hmac_end(o,0),o=0)}}},init:t=>async function(t,{baseURI:n}){if(!kn)try{await async function(t,n){let e,o;try{try{o=new URL(t,n)}catch{}const r=await fetch(o);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),o=e.length,r=new s(o);for(let t=0;t<o;++t)r[t]=e.charCodeAt(t);return r.buffer}(t)}const c=await WebAssembly.instantiate(e);var i;(function(t){if(wn=t,({malloc:ln,free:hn,memory:pn}=wn),"function"!=typeof ln||"function"!=typeof hn||!pn)throw wn=ln=hn=pn=null,new r("Invalid WASM module")})(c.instance.exports),typeof(i=c.instance.exports).aes_hmac_new==b&&(vn=i,zn=0)}(t,n),kn=!0}catch(t){throw function(t){dn=t}(t),t}}(t.wasmURI,t)})});\n';if("string"==typeof r&&(r=(new TextEncoder).encode(r)),t){const t=new Blob([r],{type:e});return URL.createObjectURL(t)}return "data:"+e+";base64,"+function(t){let e="";const r=t.length;let s=0;for(;s+2<r;s+=3){const r=t[s]<<16|t[s+1]<<8|t[s+2];e+=n$1[r>>18&63]+n$1[r>>12&63]+n$1[r>>6&63]+n$1[63&r];}const o=r-s;if(1===o){const r=t[s]<<16;e+=n$1[r>>18&63]+n$1[r>>12&63]+"==";}else if(2===o){const r=t[s]<<16|t[s+1]<<8;e+=n$1[r>>18&63]+n$1[r>>12&63]+n$1[r>>6&63]+"=";}return e}(r)}});
|
|
442
|
+
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 n$1="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e$1=t=>t({workerURI:t=>{const e="text/javascript";let r='!function(t){"function"==typeof define&&define.amd?define(t):t()}(function(){"use strict";const{Array:t,Object:n,Number:e,Math:o,Error:r,Uint8Array:c,Uint16Array:s,Uint32Array:a,Int32Array:i,Map:f,DataView:u,Promise:w,TextEncoder:l,crypto:p,postMessage:d,TransformStream:h,ReadableStream:y,WritableStream:m,CompressionStream:S,DecompressionStream:g}=self,v=void 0,b="undefined",k="function",z=new c,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,M,x,P,D,F,B]=C;class E{constructor(t){this.o=t||-1}append(t){let n=0|this.o;const e=0|t.length;let o=0;if(e>=8&&t.buffer){const r=new u(t.buffer,t.byteOffset,e),c=e-8;for(;o<=c;o+=8){const t=n^r.getInt32(o,!0),e=r.getInt32(o+4,!0);n=B[255&t]^F[t>>>8&255]^D[t>>>16&255]^P[t>>>24&255]^x[255&e]^M[e>>>8&255]^A[e>>>16&255]^I[e>>>24&255]}}for(;o<e;o++)n=n>>>8^I[255&(n^t[o])];this.o=n}get(){return~this.o}}class R extends h{constructor(){let t;const n=new E;super({transform(t,e){n.append(t),e.enqueue(t)},flush(){const e=new c(4);new u(e.buffer).setUint32(0,n.get()),t.value=e}}),t=this}}function U(t,n){const e=new c(t.length+n.length);return e.set(t),e.set(n,t.length),e}function W(t){return new u(t.buffer,t.byteOffset,t.byteLength)}const V=64,K=20,j=new c([128]),H=new c(1),O=new i([1732584193,4023233417,2562383102,271733878,3285377520]),T=new c(256),L=new i(256),N=new i(256),q=new i(256),G=new i(256);let J=!1;function Q(t,n){!function(){if(!J){let t=1,n=1;do{t=255&(t^t<<1^(128&t?27:0)),n=255&(n^n<<1),n=255&(n^n<<2),n=255&(n^n<<4),128&n&&(n^=9),T[t]=255&(n^(n<<1|n>>7)^(n<<2|n>>6)^(n<<3|n>>5)^(n<<4|n>>4)^99)}while(1!=t);T[0]=99;for(let t=0;t<256;t++){const n=T[t],e=$(n),o=e<<24|n<<16|n<<8|e^n;L[t]=o,N[t]=o>>>8|o<<24,q[t]=o>>>16|o<<16,G[t]=o>>>24|o<<8}J=!0}}();const e=new i(60),o=function(t,n){const e=t.length>>2,o=e+6,r=4*(o+1);let c=1;for(let o=0;o<e;o++)n[o]=t[4*o]<<24|t[4*o+1]<<16|t[4*o+2]<<8|t[4*o+3];for(let t=e;t<r;t++){let o=n[t-1];t%e==0?(o=Y(o<<8|o>>>24)^c<<24,c=$(c)):e>6&&t%e==4&&(o=Y(o)),n[t]=n[t-e]^o}return o}(t,e),r=new i(4),c=X(n);let s=0,a=0,f=0,w=0;return{process(t,n){n&&c.update(t,0,t.length),function(t){const n=new u(t.buffer,t.byteOffset,t.byteLength),e=t.length;let o=0;for(;o+16<=e;o+=16)l(),n.setInt32(o,n.getInt32(o)^r[0]),n.setInt32(o+4,n.getInt32(o+4)^r[1]),n.setInt32(o+8,n.getInt32(o+8)^r[2]),n.setInt32(o+12,n.getInt32(o+12)^r[3]);if(o<e){l();for(let n=0;o<e;o++,n++)t[o]^=r[n>>2]>>>24-8*(3&n)}}(t),n||c.update(t,0,t.length)},digest:()=>c.digest()};function l(){s=s+1|0,s||(a=a+1|0,a||(f=f+1|0,f||(w=w+1|0)));let t=Z(s)^e[0],n=Z(a)^e[1],c=Z(f)^e[2],i=Z(w)^e[3],u=L[t>>>24]^N[n>>>16&255]^q[c>>>8&255]^G[255&i]^e[4],l=L[n>>>24]^N[c>>>16&255]^q[i>>>8&255]^G[255&t]^e[5],p=L[c>>>24]^N[i>>>16&255]^q[t>>>8&255]^G[255&n]^e[6],d=L[i>>>24]^N[t>>>16&255]^q[n>>>8&255]^G[255&c]^e[7];t=L[u>>>24]^N[l>>>16&255]^q[p>>>8&255]^G[255&d]^e[8],n=L[l>>>24]^N[p>>>16&255]^q[d>>>8&255]^G[255&u]^e[9],c=L[p>>>24]^N[d>>>16&255]^q[u>>>8&255]^G[255&l]^e[10],i=L[d>>>24]^N[u>>>16&255]^q[l>>>8&255]^G[255&p]^e[11],u=L[t>>>24]^N[n>>>16&255]^q[c>>>8&255]^G[255&i]^e[12],l=L[n>>>24]^N[c>>>16&255]^q[i>>>8&255]^G[255&t]^e[13],p=L[c>>>24]^N[i>>>16&255]^q[t>>>8&255]^G[255&n]^e[14],d=L[i>>>24]^N[t>>>16&255]^q[n>>>8&255]^G[255&c]^e[15],t=L[u>>>24]^N[l>>>16&255]^q[p>>>8&255]^G[255&d]^e[16],n=L[l>>>24]^N[p>>>16&255]^q[d>>>8&255]^G[255&u]^e[17],c=L[p>>>24]^N[d>>>16&255]^q[u>>>8&255]^G[255&l]^e[18],i=L[d>>>24]^N[u>>>16&255]^q[l>>>8&255]^G[255&p]^e[19],u=L[t>>>24]^N[n>>>16&255]^q[c>>>8&255]^G[255&i]^e[20],l=L[n>>>24]^N[c>>>16&255]^q[i>>>8&255]^G[255&t]^e[21],p=L[c>>>24]^N[i>>>16&255]^q[t>>>8&255]^G[255&n]^e[22],d=L[i>>>24]^N[t>>>16&255]^q[n>>>8&255]^G[255&c]^e[23],t=L[u>>>24]^N[l>>>16&255]^q[p>>>8&255]^G[255&d]^e[24],n=L[l>>>24]^N[p>>>16&255]^q[d>>>8&255]^G[255&u]^e[25],c=L[p>>>24]^N[d>>>16&255]^q[u>>>8&255]^G[255&l]^e[26],i=L[d>>>24]^N[u>>>16&255]^q[l>>>8&255]^G[255&p]^e[27],u=L[t>>>24]^N[n>>>16&255]^q[c>>>8&255]^G[255&i]^e[28],l=L[n>>>24]^N[c>>>16&255]^q[i>>>8&255]^G[255&t]^e[29],p=L[c>>>24]^N[i>>>16&255]^q[t>>>8&255]^G[255&n]^e[30],d=L[i>>>24]^N[t>>>16&255]^q[n>>>8&255]^G[255&c]^e[31],t=L[u>>>24]^N[l>>>16&255]^q[p>>>8&255]^G[255&d]^e[32],n=L[l>>>24]^N[p>>>16&255]^q[d>>>8&255]^G[255&u]^e[33],c=L[p>>>24]^N[d>>>16&255]^q[u>>>8&255]^G[255&l]^e[34],i=L[d>>>24]^N[u>>>16&255]^q[l>>>8&255]^G[255&p]^e[35],u=L[t>>>24]^N[n>>>16&255]^q[c>>>8&255]^G[255&i]^e[36],l=L[n>>>24]^N[c>>>16&255]^q[i>>>8&255]^G[255&t]^e[37],p=L[c>>>24]^N[i>>>16&255]^q[t>>>8&255]^G[255&n]^e[38],d=L[i>>>24]^N[t>>>16&255]^q[n>>>8&255]^G[255&c]^e[39];let h=40;o>10&&(t=L[u>>>24]^N[l>>>16&255]^q[p>>>8&255]^G[255&d]^e[40],n=L[l>>>24]^N[p>>>16&255]^q[d>>>8&255]^G[255&u]^e[41],c=L[p>>>24]^N[d>>>16&255]^q[u>>>8&255]^G[255&l]^e[42],i=L[d>>>24]^N[u>>>16&255]^q[l>>>8&255]^G[255&p]^e[43],u=L[t>>>24]^N[n>>>16&255]^q[c>>>8&255]^G[255&i]^e[44],l=L[n>>>24]^N[c>>>16&255]^q[i>>>8&255]^G[255&t]^e[45],p=L[c>>>24]^N[i>>>16&255]^q[t>>>8&255]^G[255&n]^e[46],d=L[i>>>24]^N[t>>>16&255]^q[n>>>8&255]^G[255&c]^e[47],h=48),o>12&&(t=L[u>>>24]^N[l>>>16&255]^q[p>>>8&255]^G[255&d]^e[48],n=L[l>>>24]^N[p>>>16&255]^q[d>>>8&255]^G[255&u]^e[49],c=L[p>>>24]^N[d>>>16&255]^q[u>>>8&255]^G[255&l]^e[50],i=L[d>>>24]^N[u>>>16&255]^q[l>>>8&255]^G[255&p]^e[51],u=L[t>>>24]^N[n>>>16&255]^q[c>>>8&255]^G[255&i]^e[52],l=L[n>>>24]^N[c>>>16&255]^q[i>>>8&255]^G[255&t]^e[53],p=L[c>>>24]^N[i>>>16&255]^q[t>>>8&255]^G[255&n]^e[54],d=L[i>>>24]^N[t>>>16&255]^q[n>>>8&255]^G[255&c]^e[55],h=56),r[0]=(T[u>>>24]<<24|T[l>>>16&255]<<16|T[p>>>8&255]<<8|T[255&d])^e[h],r[1]=(T[l>>>24]<<24|T[p>>>16&255]<<16|T[d>>>8&255]<<8|T[255&u])^e[h+1],r[2]=(T[p>>>24]<<24|T[d>>>16&255]<<16|T[u>>>8&255]<<8|T[255&l])^e[h+2],r[3]=(T[d>>>24]<<24|T[u>>>16&255]<<16|T[l>>>8&255]<<8|T[255&p])^e[h+3]}}function X(t){const n=function(){const t=new i(O),n=new i(16),e=new c(V),r=new u(e.buffer),s=new c(8);let a=0,f=0;return{update:w,digest:function(){const n=8*f,e=o.floor(n/4294967296),r=n>>>0;for(w(j,0,1);56!=a;)w(H,0,1);s[0]=e>>>24,s[1]=e>>>16,s[2]=e>>>8,s[3]=e,s[4]=r>>>24,s[5]=r>>>16,s[6]=r>>>8,s[7]=r,w(s,0,8);const i=new c(K),l=new u(i.buffer);for(let n=0;n<t.length;n++)l.setInt32(4*n,t[n]);return t.set(O),a=0,f=0,i}};function w(t,n,o){const c=n+o;if(f+=o,a){for(;n<c&&a<V;)e[a++]=t[n++];a==V&&(l(r,0),a=0)}if(n+V<=c){const e=new u(t.buffer,t.byteOffset,t.byteLength);for(;n+V<=c;n+=V)l(e,n)}for(;n<c;)e[a++]=t[n++]}function l(e,o){for(let t=0;t<16;t++)n[t]=e.getInt32(o+4*t);let r,c=t[0],s=t[1],a=t[2],i=t[3],f=t[4];for(let t=0;t<15;t+=5)f=(c<<5|c>>>27)+((a^i)&s^i)+f+1518500249+n[t]|0,s=s<<30|s>>>2,i=(f<<5|f>>>27)+((s^a)&c^a)+i+1518500249+n[t+1]|0,c=c<<30|c>>>2,a=(i<<5|i>>>27)+((c^s)&f^s)+a+1518500249+n[t+2]|0,f=f<<30|f>>>2,s=(a<<5|a>>>27)+((f^c)&i^c)+s+1518500249+n[t+3]|0,i=i<<30|i>>>2,c=(s<<5|s>>>27)+((i^f)&a^f)+c+1518500249+n[t+4]|0,a=a<<30|a>>>2;f=(c<<5|c>>>27)+((a^i)&s^i)+f+1518500249+n[15]|0,s=s<<30|s>>>2,r=n[13]^n[8]^n[2]^n[0],r=r<<1|r>>>31,n[0]=r,i=(f<<5|f>>>27)+((s^a)&c^a)+i+1518500249+r|0,c=c<<30|c>>>2,r=n[14]^n[9]^n[3]^n[1],r=r<<1|r>>>31,n[1]=r,a=(i<<5|i>>>27)+((c^s)&f^s)+a+1518500249+r|0,f=f<<30|f>>>2,r=n[15]^n[10]^n[4]^n[2],r=r<<1|r>>>31,n[2]=r,s=(a<<5|a>>>27)+((f^c)&i^c)+s+1518500249+r|0,i=i<<30|i>>>2,r=n[0]^n[11]^n[5]^n[3],r=r<<1|r>>>31,n[3]=r,c=(s<<5|s>>>27)+((i^f)&a^f)+c+1518500249+r|0,a=a<<30|a>>>2;for(let t=20;t<40;t+=5)r=n[t-3&15]^n[t-8&15]^n[t-14&15]^n[15&t],r=r<<1|r>>>31,n[15&t]=r,f=(c<<5|c>>>27)+(s^a^i)+f+1859775393+r|0,s=s<<30|s>>>2,r=n[t-2&15]^n[t-7&15]^n[t-13&15]^n[t+1&15],r=r<<1|r>>>31,n[t+1&15]=r,i=(f<<5|f>>>27)+(c^s^a)+i+1859775393+r|0,c=c<<30|c>>>2,r=n[t-1&15]^n[t-6&15]^n[t-12&15]^n[t+2&15],r=r<<1|r>>>31,n[t+2&15]=r,a=(i<<5|i>>>27)+(f^c^s)+a+1859775393+r|0,f=f<<30|f>>>2,r=n[15&t]^n[t-5&15]^n[t-11&15]^n[t+3&15],r=r<<1|r>>>31,n[t+3&15]=r,s=(a<<5|a>>>27)+(i^f^c)+s+1859775393+r|0,i=i<<30|i>>>2,r=n[t+1&15]^n[t-4&15]^n[t-10&15]^n[t+4&15],r=r<<1|r>>>31,n[t+4&15]=r,c=(s<<5|s>>>27)+(a^i^f)+c+1859775393+r|0,a=a<<30|a>>>2;for(let t=40;t<60;t+=5)r=n[t-3&15]^n[t-8&15]^n[t-14&15]^n[15&t],r=r<<1|r>>>31,n[15&t]=r,f=(c<<5|c>>>27)+(s&a|(s|a)&i)+f+2400959708+r|0,s=s<<30|s>>>2,r=n[t-2&15]^n[t-7&15]^n[t-13&15]^n[t+1&15],r=r<<1|r>>>31,n[t+1&15]=r,i=(f<<5|f>>>27)+(c&s|(c|s)&a)+i+2400959708+r|0,c=c<<30|c>>>2,r=n[t-1&15]^n[t-6&15]^n[t-12&15]^n[t+2&15],r=r<<1|r>>>31,n[t+2&15]=r,a=(i<<5|i>>>27)+(f&c|(f|c)&s)+a+2400959708+r|0,f=f<<30|f>>>2,r=n[15&t]^n[t-5&15]^n[t-11&15]^n[t+3&15],r=r<<1|r>>>31,n[t+3&15]=r,s=(a<<5|a>>>27)+(i&f|(i|f)&c)+s+2400959708+r|0,i=i<<30|i>>>2,r=n[t+1&15]^n[t-4&15]^n[t-10&15]^n[t+4&15],r=r<<1|r>>>31,n[t+4&15]=r,c=(s<<5|s>>>27)+(a&i|(a|i)&f)+c+2400959708+r|0,a=a<<30|a>>>2;for(let t=60;t<80;t+=5)r=n[t-3&15]^n[t-8&15]^n[t-14&15]^n[15&t],r=r<<1|r>>>31,n[15&t]=r,f=(c<<5|c>>>27)+(s^a^i)+f+3395469782+r|0,s=s<<30|s>>>2,r=n[t-2&15]^n[t-7&15]^n[t-13&15]^n[t+1&15],r=r<<1|r>>>31,n[t+1&15]=r,i=(f<<5|f>>>27)+(c^s^a)+i+3395469782+r|0,c=c<<30|c>>>2,r=n[t-1&15]^n[t-6&15]^n[t-12&15]^n[t+2&15],r=r<<1|r>>>31,n[t+2&15]=r,a=(i<<5|i>>>27)+(f^c^s)+a+3395469782+r|0,f=f<<30|f>>>2,r=n[15&t]^n[t-5&15]^n[t-11&15]^n[t+3&15],r=r<<1|r>>>31,n[t+3&15]=r,s=(a<<5|a>>>27)+(i^f^c)+s+3395469782+r|0,i=i<<30|i>>>2,r=n[t+1&15]^n[t-4&15]^n[t-10&15]^n[t+4&15],r=r<<1|r>>>31,n[t+4&15]=r,c=(s<<5|s>>>27)+(a^i^f)+c+3395469782+r|0,a=a<<30|a>>>2;t[0]=t[0]+c|0,t[1]=t[1]+s|0,t[2]=t[2]+a|0,t[3]=t[3]+i|0,t[4]=t[4]+f|0}}(),e=new c(V),r=new c(V);t.length>V&&(n.update(t,0,t.length),t=n.digest());for(let n=0;n<V;n++){const o=n<t.length?t[n]:0;e[n]=54^o,r[n]=92^o}return n.update(e,0,V),{update(t,e,o){n.update(t,e,o)},digest(){const t=n.digest();n.update(r,0,V),n.update(t,0,K);const o=n.digest();return n.update(e,0,V),o}}}function Y(t){return T[t>>>24]<<24|T[t>>>16&255]<<16|T[t>>>8&255]<<8|T[255&t]}function Z(t){return t<<24|(65280&t)<<8|t>>>8&65280|t>>>24}function $(t){return 255&(t<<1^27*(t>>7))}const _=typeof p!=b&&typeof p.getRandomValues==k,tt="Invalid password",nt="zipjs-abort-check-password";function et(t){if(_)return p.getRandomValues(t);throw new r("Crypto API not supported")}const ot={name:"PBKDF2"},rt=n.assign({hash:{name:"HMAC"}},ot),ct=n.assign({iterations:1e3,hash:{name:"SHA-1"}},ot),st=["deriveBits"],at=[8,12,16],it=[16,24,32],ft=10,ut=typeof p!=b,wt=ut&&p.subtle;let lt=ut&&typeof wt!=b&&typeof wt.importKey==k&&typeof wt.deriveBits==k,pt=Q;class dt extends h{constructor({password:t,rawPassword:n,encryptionStrength:e,checkPasswordOnly:o,checkAuthenticationCode:s=!0}){const a={};super({start(){yt(a,t,n,e)},async transform(t,n){const{password:e,strength:s,l:i,ready:f}=a;if(e?(await async function(t,n,e,o){const c=await vt(t,n,e,kt(o,0,at[n])),s=kt(o,at[n]);if(c[0]!=s[0]||c[1]!=s[1])throw gt(t),new r(tt)}(a,s,e,kt(t,0,at[s]+2)),t=kt(t,at[s]+2),o?(gt(a),n.error(new r(nt))):i()):await f,a.h)return;const u=new c(t.length-ft-(t.length-ft)%16);n.enqueue(St(a,t,u,0,ft,!0))},async flush(t){const{m:n,S:e,ready:o}=a;if(n){if(await o,a.h)return;const i=kt(e,e.length-ft),f=new c(kt(e,0,e.length-ft));n.process(f,!0);const u=n.digest();let w=e.length<ft?1:0;for(let t=0;t<ft;t++)w|=u[t]^i[t];if(w&&s)return void t.error(new r("Invalid authentication code"));t.enqueue(f)}}}),mt(this,a)}}class ht extends h{constructor({password:t,rawPassword:n,encryptionStrength:e}){const o={};super({start(){yt(o,t,n,e)},async transform(t,n){const{password:e,strength:r,l:s,ready:a}=o;let i=z;if(e?(i=await async function(t,n,e){const o=et(new c(at[n]));return U(o,await vt(t,n,e,o))}(o,r,e),s()):await a,o.h)return;const f=new c(i.length+t.length-t.length%16);f.set(i,0),n.enqueue(St(o,t,f,i.length,0,!1))},async flush(t){const{m:n,S:e,ready:r}=o;if(n){if(await r,o.h)return;const s=new c(e);n.process(s,!1);const a=kt(n.digest(),0,ft);t.enqueue(U(s,a))}}}),mt(this,o)}}function yt(t,e,o,r){n.assign(t,{ready:new w(n=>t.l=n),password:bt(e,o),strength:r-1,S:z,h:!1})}function mt(t,e){const o=t.readable.getReader(),r=new y({async pull(t){try{const{value:n,done:e}=await o.read();e?t.close():t.enqueue(n)}catch(t){throw gt(e),o.cancel(t).catch(()=>{}),t}},cancel:t=>(gt(e),o.cancel(t))});n.defineProperty(t,"readable",{get:()=>r})}function St(t,n,e,o,r,s){const{m:a,S:i}=t;i.length&&(n=U(i,n));const f=n.length-r,u=f-f%16;if(e=function(t,n){if(n&&n>t.length){const e=t;(t=new c(n)).set(e,0)}return t}(e,o+u),u){const t=kt(e,o,o+u);t.set(kt(n,0,u)),a.process(t,s)}return t.S=kt(n,u),e}function gt(t){const{m:n}=t;t.h=!0,n&&n.dispose&&n.dispose()}async function vt(t,e,r,s){t.password=null;const a=it[e],i=await async function(t,e,r){if(lt)try{const o=await wt.importKey("raw",t,rt,!1,st);return new c(await wt.deriveBits(n.assign({salt:e},ct),o,8*r))}catch{lt=!1}return function(t,n,e,r){const s=X(t),a=new c(r),i=new c(n.length+4),f=new u(i.buffer);i.set(n);for(let t=1,e=0;e<r;t++,e+=K){f.setUint32(n.length,t),s.update(i,0,i.length);let c=s.digest();const u=c.slice();for(let t=1;t<1e3;t++){s.update(c,0,K),c=s.digest();for(let t=0;t<K;t++)u[t]^=c[t]}a.set(u.subarray(0,o.min(K,r-e)),e)}return a}(t,e,0,r)}(r,s,2*a+2);return t.m=pt(kt(i,0,a),kt(i,a,2*a)),t.h&>(t),kt(i,2*a)}function bt(t,n){return n===v?function(t){if(typeof l==b){t=unescape(encodeURIComponent(t));const n=new c(t.length);for(let e=0;e<n.length;e++)n[e]=t.charCodeAt(e);return n}return(new l).encode(t)}(t):n}function kt(t,n,e){return t.subarray(n,e)}class zt extends h{constructor({password:t,rawPassword:n,passwordVerification:e,checkPasswordOnly:o}){super({start(){It(this,t,n,e)},transform(t,n){const e=this;if(e.password||e.rawPassword){const n=At(e,t.subarray(0,12));if(e.password=e.rawPassword=null,0!=(n[11]^e.passwordVerification))throw new r(tt);t=t.subarray(12)}o?n.error(new r(nt)):n.enqueue(At(e,t))}})}}class Ct extends h{constructor({password:t,rawPassword:n,passwordVerification:e}){super({start(){It(this,t,n,e)},transform(t,n){const e=this;let o,r;if(e.password||e.rawPassword){e.password=e.rawPassword=null;const n=et(new c(12));n[11]=e.passwordVerification,o=new c(t.length+n.length),o.set(Mt(e,n),0),r=12}else o=new c(t.length),r=0;o.set(Mt(e,t),r),n.enqueue(o)}})}}function It(t,e,o,r){n.assign(t,{password:e,rawPassword:o,passwordVerification:r}),function(t,e,o){const r=[305419896,591751049,878082192];if(n.assign(t,{v:r,C:new E(r[0]),I:new E(r[2])}),o)for(let n=0;n<o.length;n++)xt(t,o[n]);else for(let n=0;n<e.length;n++)xt(t,e.charCodeAt(n))}(t,e,o)}function At(t,n){const e=new c(n.length);for(let o=0;o<n.length;o++)e[o]=Pt(t)^n[o],xt(t,e[o]);return e}function Mt(t,n){const e=new c(n.length);for(let o=0;o<n.length;o++)e[o]=Pt(t)^n[o],xt(t,n[o]);return e}function xt(t,n){let[,e]=t.v;t.C.append([n]);const r=~t.C.get();e=Ft(o.imul(Ft(e+Dt(r)),134775813)+1),t.I.append([e>>>24]);const c=~t.I.get();t.v=[r,e,c]}function Pt(t){const n=2|t.v[2];return Dt(o.imul(n,1^n)>>>8)}function Dt(t){return 255&t}function Ft(t){return 4294967295&t}function Bt(t){if(t instanceof y)return t;const n=t.getReader();return new y({async pull(t){try{const{value:e,done:o}=await n.read();o?t.close():t.enqueue(e)}catch(t){throw n.cancel(t).catch(()=>{}),t}},cancel:t=>n.cancel(t)})}const Et=new f;function Rt(t){return Et.get(t)}const Ut="Invalid uncompressed size",Wt="Invalid CRC32",Vt="deflate-raw",Kt="gzip",jt=[31,139,8];class Ht extends h{constructor(t,{chunkSize:n,CompressionStreamFallback:e,CompressionStream:o}){super({});const{compressed:r,encrypted:c,useCompressionStream:s,zipCrypto:a,computeCrc32:i,level:f,deflate64:w,format:l,compressionMethod:p,inputSize:d}=t,h=this;let y,m,S,g=super.readable;const v=l&&Rt(l),b=Gt(s,o,e),k=i&&r&&!w&&!v&&(!c||a)&&Boolean(b);if(c&&!a||!i||k||(y=new R,g=Qt(g,y)),r)if(v)g=Xt(g,qt(v.CompressionStream,l,{level:f,chunkSize:n,compressionMethod:p,uncompressedSize:d}));else if(k)S=new Ot,g=Xt(g,new b(Kt,{level:f,chunkSize:n})),g=Qt(g,S);else try{g=Jt(g,s,{level:f,chunkSize:n},o,e)}catch(t){if(!s&&e)throw t;let n;try{n=new o(Kt)}catch{throw t}g=Xt(g,n),g=Qt(g,new Ot)}c&&(a?g=Qt(g,new Ct(t)):(m=new ht(t),g=Qt(g,m))),Nt(h,g,()=>{c&&!a||!i||(h.crc32=k?S.crc32:new u(y.value.buffer).getUint32(0))})}}class Ot extends h{constructor(){let t,n=10,e=new c(0);super({transform(t,r){if(n){const e=o.min(n,t.length);if(n-=e,!(t=t.subarray(e)).length)return}const c=e.length+t.length;if(c<=8)return void(e=U(e,t));const s=c-8,a=o.min(s,e.length);r.enqueue(U(e.subarray(0,a),t.subarray(0,s-a))),e=U(e.subarray(a),t.subarray(s-a))},flush(){const n=W(e);t.crc32=n.getUint32(0,!0),t.uncompressedSize=n.getUint32(4,!0)}}),t=this}}class Tt extends h{constructor(t,{chunkSize:n,DecompressionStreamFallback:e,DecompressionStream:o}){super({});const{zipCrypto:s,encrypted:a,checkCrc32:i,crc32:f,compressed:l,useCompressionStream:p,deflate64:d,format:h,compressionMethod:m,rawBitFlag:S,outputSize:g}=t;let b,k,z,C=super.readable;if(a&&(s?C=Qt(C,new zt(t)):(k=new dt(t),C=Qt(C,k))),l){const t=h&&Rt(h);if(t)C=Xt(C,qt(t.DecompressionStream,h,{chunkSize:n,compressionMethod:m,rawBitFlag:S,uncompressedSize:g}));else{let t;const s=Gt(p,o,e);if(i&&!d&&f!==v&&g!==v&&s)try{t=new s(Kt,{chunkSize:n})}catch{t=v}if(!t)try{C=Jt(C,p,{chunkSize:n,deflate64:d},o,e)}catch(n){if(d||g===v||!p&&e)throw n;try{t=new o(Kt)}catch{throw n}}t&&(z=!0,C=function(t,n,e,o){const s=n.writable.getWriter(),a=n.readable.getReader(),i=o===v?new E:v;let f,u,l=0,p=!1,d=!1,h=!1,m=0,S=!1;const g=new w((t,n)=>{f=t,u=n});return g.catch(()=>{}),async function(){const n=t.getReader();try{const t=new c(10);for(t.set(jt),await s.write(t);;){await s.ready;const{value:t,done:e}=await n.read();if(e)break;await s.write(t)}p=!0,i&&(S&&k(),await g);const r=new c(8),a=W(r);a.setUint32(0,i?i.get():o,!0),a.setUint32(4,e,!0),d=!0,await s.write(r),await s.close()}catch(t){await Yt(s,t),await Zt(n,t)}}(),new y({async pull(t){try{const{value:n,done:o}=await function(){m++,S=!0;const t=a.read();return t.then(b,b),p&&i&&k(),t}();if(o)t.close();else{if(l+=n.length,l>e)throw new r(Ut);i&&i.append(n),t.enqueue(n)}}catch(t){throw u(t),await Zt(a,t),d?function(t){const n=new r(l==e?Wt:Ut);return n.cause=t,n}(t):t}},cancel:t=>(u(t),a.cancel(t))});function b(){S=!1}async function k(){if(!h){h=!0;const t=m;await new w(t=>{const{port1:n,port2:e}=new MessageChannel;e.onmessage=()=>{n.close(),e.close(),t()},n.postMessage(v)}),h=!1,S&&(m==t?f():k())}}}(C,t,g,f))}C=function(t){const n=t.getReader();return new y({async pull(t){try{const{value:e,done:o}=await n.read();o?t.close():t.enqueue(e)}catch(t){if(await Zt(n,t),t&&t.message)throw t;const e=new r("Invalid compressed data");throw e.cause=t,e}},cancel:t=>n.cancel(t)})}(C)}i&&!z&&(b=new R,C=Qt(C,b)),Nt(this,C,()=>{if(b){const t=new u(b.value.buffer).getUint32(0,!1);if(f!=t)throw new r(Wt)}})}}const Lt=new f;function Nt(t,e,o){e=Qt(e,new h({flush:o})),n.defineProperty(t,"readable",{get:()=>e})}function qt(t,n,e){if(!t)throw new r("Compression method not supported");return new t(n,e)}function Gt(t,n,e){return t&&n?n:e&&e.requiresModule?e:void 0}function Jt(t,n,e,o,r){const c=n&&o?o:r||o,s=e.deflate64?"deflate64-raw":Vt;let a;try{a=new c(s,e)}catch(t){if(!n||!r||c==r)throw t;a=new r(s,e)}return Xt(t,a)}function Qt(t,n){return Bt(t).pipeThrough(n)}function Xt(t,n){const e=n.writable.getWriter(),o=t.getReader();return async function(){try{for(;;){await e.ready;const t=await o.read();if(t.done){await e.close();break}await e.write(t.value)}}catch(t){await Yt(e,t),await Zt(o,t)}}(),n.readable}async function Yt(t,n){try{await t.abort(n)}catch{}}async function Zt(t,n){try{await t.cancel(n)}catch{}}const $t="data",_t="deflate";class tn extends h{constructor(t,e){super({});const o=this,{codecType:c}=t;let s;c.startsWith(_t)?s=Ht:c.startsWith("inflate")&&(s=Tt),o.outputSize=0;let a=0;const i=new s(t,e),f=super.readable,u=new h({transform(t,n){t&&t.length&&(a+=t.length,n.enqueue(t))},flush(){n.assign(o,{inputSize:a})}}),w=new h({transform(n,e){if(n&&n.length&&(e.enqueue(n),o.outputSize+=n.length,t.outputSize!==v&&o.outputSize>t.outputSize))throw new r(Ut)},flush(){const{crc32:t}=i;n.assign(o,{crc32:t,inputSize:a})}});n.defineProperty(o,"readable",{get:()=>f.pipeThrough(u).pipeThrough(i).pipeThrough(w)})}}class nn extends h{constructor(t){const o=[];let r=0,s=0;function a(){const n=new c(t);let e=0;for(;e<t;){const r=o[0],c=t-e;r.length<=c?(n.set(r,e),e+=r.length,o.shift()):(n.set(r.subarray(0,c),e),o[0]=r.subarray(c),e+=c)}return r-=t,n}(!e.isFinite(t)||t<1)&&(t=65536),super({transform(n,e){for(o.push(n),r+=n.length;r>t;)s+=t,e.enqueue(a())},flush(t){r&&(s+=r,t.enqueue(function(t,n){const e=new c(n);let o=0;for(const n of t)e.set(n,o),o+=n.length;return e}(o,r)))}}),n.defineProperty(this,"outputSize",{get:()=>s})}}let en=2;try{typeof navigator!=b&&navigator.hardwareConcurrency&&(en=navigator.hardwareConcurrency)}catch{}function on(t){return Boolean(t)&&"object"==typeof t}const rn=new f,cn=new f,sn=function(){try{return structuredClone(new r)instanceof r}catch{return!1}}();let an=0;async function fn(t){let n,c,s;try{const{options:a,config:i}=t;if(a.format)try{await async function(t,n){!Et.has(t)&&n&&function(t,n){const{CompressionStream:e,DecompressionStream:o}=n;if(typeof e!=k&&typeof o!=k)throw new r("Invalid codec module");Et.set(t,{CompressionStream:e,DecompressionStream:o})}(t,await(import(n)))}(a.format,a.codecURI)}catch(t){if(on(t))try{t.codecImportFailed=!0}catch{}throw t}if(i.CompressionStream=self.CompressionStream,i.DecompressionStream=self.DecompressionStream,a.compressed&&!a.format)if(a.useCompressionStream){if(!function(t,n){if(!t)return!1;let e=Lt.get(t);e||(e=new f,Lt.set(t,e));let o=e.get(n);if(o===v){try{new t(n),o=!0}catch{o=!1}e.set(n,o)}return o}(a.codecType.startsWith(_t)?i.CompressionStream:i.DecompressionStream,Vt))try{await self.initModule(t.config)}catch{}}else try{await self.initModule(t.config)}catch{a.useCompressionStream=!0}if(a.encrypted&&!a.zipCrypto)try{await self.initModule(t.config)}catch{}!i.CompressionStreamFallback&&i.CompressionStreamZlib&&(i.CompressionStreamFallback=i.CompressionStreamZlib),!i.DecompressionStreamFallback&&i.DecompressionStreamZlib&&(i.DecompressionStreamFallback=i.DecompressionStreamZlib);const u={highWaterMark:1},l=t.readable?Bt(t.readable):new y({async pull(t){const n=new w(t=>rn.set(an,t));un({type:"pull",messageId:an}),an=(an+1)%e.MAX_SAFE_INTEGER;const{value:o,done:r}=await n;t.enqueue(o),r&&t.close()}},u);s=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 o=new w(t=>n=t);cn.set(an,n),un({type:$t,value:t,messageId:an}),an=(an+1)%e.MAX_SAFE_INTEGER,await o}},u),n=new tn(a,i),c=new nn(function(t){return r="string"==typeof(n=r=t.chunkSize)&&n.trim()?e(n):n,e.isInteger(r)&&r>=1?o.max(r,64):65536;var n,r}(i)),await l.pipeThrough(n).pipeThrough(c).pipeTo(s,{preventClose:!0,preventAbort:!0}),await s.getWriter().close();const{crc32:p,inputSize:d,outputSize:h}=n;un({type:"close",result:{crc32:p,inputSize:d,outputSize:h}})}catch(t){const n=c?c.outputSize:0;if(on(t))try{t.outputSize=n}catch{}if(s&&!s.locked)try{await s.getWriter().close()}catch{}wn(t,n)}}function un(t){const{value:n}=t;if(n)if(n.length)try{t.value=(e=n,e.byteOffset||e.byteLength!=e.buffer.byteLength?new c(e):e).buffer,d(t,[t.value])}catch{d(t)}else d(t);else d(t);var e}function wn(t,n){const{message:e,stack:o,code:c,name:s,outputSize:a,cause:i,codecImportFailed:f}=function(t=new r("Unknown error")){return on(t)?t:new r(String(t))}(t),u={message:e,stack:o,code:c,name:s,outputSize:a===v?n:a};if(i&&(u.cause={name:i.name,message:i.message}),f&&(u.codecImportFailed=!0),sn)try{return void d({error:u,errorValue:{value:t}})}catch{}d({error:u})}addEventListener("message",({data:t})=>{const{type:n,messageId:e,value:o,done:r}=t;try{if("start"==n&&fn(t),n==$t){const t=rn.get(e);rn.delete(e),t({value:o||new c,done:r})}if("ack"==n){const t=cn.get(e);cn.delete(e),t()}}catch(t){wn(t)}}),d({type:"ready"});const ln="deflate",pn="deflate-raw",dn="deflate64-raw",hn="gzip";let yn,mn,Sn,gn,vn;function bn(t,n,e={}){if(!yn){const t=new r("WASM module not loaded");throw t.cause=vn,t}const s="number"==typeof e.level?e.level:-1,a="number"==typeof e.outBuffer?e.outBuffer:65536,i="number"==typeof e.inBufferSize?e.inBufferSize:65536,f={A:0,in:0,inBufferSize:0,M:0};let u,l,p,d,h=!0,S=!1;return function(){try{let e;if(f.A=mn(a),f.in=mn(i),f.inBufferSize=i,!f.A||!f.in)throw new r("allocation failed");if(t?(f.P=yn.deflate_process,f.D=yn.deflate_last_consumed,f.F=yn.deflate_end,f.M=yn.deflate_new(),e=n===hn?yn.deflate_init_gzip(f.M,s):n===pn?yn.deflate_init_raw(f.M,s):yn.deflate_init(f.M,s)):n===dn?(f.P=yn.inflate9_process,f.D=yn.inflate9_last_consumed,f.F=yn.inflate9_end,f.M=yn.inflate9_new(),e=yn.inflate9_init_raw(f.M)):(f.P=yn.inflate_process,f.D=yn.inflate_last_consumed,f.F=yn.inflate_end,f.M=yn.inflate_new(),e=n===pn?yn.inflate_init_raw(f.M):n===hn?yn.inflate_init_gzip(f.M):yn.inflate_init(f.M)),0!==e)throw new r("init failed:"+e)}catch(t){throw b(f),t}}(),{readable:new y({start(t){u=t},pull(){h=!1,v()},cancel(t){S=!0,d=t,b(f),l.error(t),v()}},{highWaterMark:0}),writable:new m({start(t){l=t},async write(t){if(h&&await new w(t=>p=t),S)throw d;try{!function(t){const n=new c(gn.buffer),e=f.P,s=f.D,i=f.A;let u=0;for(;u<t.length;){const c=o.min(t.length-u,32768);if((!f.in||f.inBufferSize<c)&&(f.in&&Sn&&(Sn(f.in),f.in=0),f.in=mn(c),f.inBufferSize=c,!f.in))throw new r("allocation failed");n.set(t.subarray(u,u+c),f.in);const w=e(f.M,f.in,c,i,a,0),l=w>>24&255,p=128&l?l-256:l;if(p<0)throw new r("process error:"+p);const d=16777215&w;d&&g(n.slice(i,i+d));const h=s(f.M);if(0===h&&0===d)break;u+=h}}(t)}catch(t){throw b(f),u.error(t),t}},close(){if(S)return;try{!function(){const t=new c(gn.buffer),n=f.P,e=f.A;for(;;){const o=n(f.M,0,0,e,a,4),c=o>>24&255,s=128&c?c-256:c;if(s<0)throw new r("process error:"+s);const i=16777215&o;if(i&&g(t.slice(e,e+i)),1===c||0===i)break}}()}catch(t){throw b(f),u.error(t),t}const t=b(f);if(0!==t){const n=new r("end error:"+t);throw u.error(n),n}u.close()},abort(t){b(f),u.error(t)}},{highWaterMark:1})};function g(t){h=!0,u.enqueue(t)}function v(){if(p){const t=p;p=null,t()}}function b(t){let n=0;return t.M&&t.F&&(n=t.F(t.M)),t.M=0,t.in&&Sn&&Sn(t.in),t.in=0,t.A&&Sn&&Sn(t.A),t.A=0,n}}class kn{constructor(t=ln,n){return bn(!0,t,n)}}class zn{constructor(t=ln,n){return bn(!1,t,n)}}kn.requiresModule=!0,zn.requiresModule=!0,kn.supportedFormats=[ln,pn,hn],zn.supportedFormats=[ln,pn,hn,dn];const Cn=65536;let In,An;function Mn(t){return new c(t.memory.buffer)}let xn=!1;!function(t={}){const{init:n,B:e}=t,o=t.CompressionStreamFallback||t.CompressionStreamZlib,r=t.DecompressionStreamFallback||t.DecompressionStreamZlib;e&&(pt=e||Q),self.initModule=async t=>{n&&await n(t),o&&(t.CompressionStreamFallback=o),r&&(t.DecompressionStreamFallback=r)}}({CompressionStreamFallback:kn,DecompressionStreamFallback:zn,B:function(t,n){const e=In;let o=e?function(t,n,e){An||(An=t.malloc(Cn));const o=An?t.aes_hmac_new():0;if(o){const r=Mn(t);if(r.set(n,An),r.set(e,An+n.length),t.aes_hmac_init(o,An,n.length,An+n.length,e.length))return t.aes_hmac_end(o,0),0}return o}(e,t,n):0;if(!o)return Q(t,n);const r=An;return{process(t,n){for(let c=0;c<t.length;c+=Cn){const s=t.subarray(c,c+Cn),a=Mn(e);a.set(s,r),e.aes_hmac_process(o,r,s.length,n?1:0),s.set(a.subarray(r,r+s.length))}},digest:()=>(e.aes_hmac_end(o,r),o=0,Mn(e).slice(r,r+20)),dispose(){o&&(e.aes_hmac_end(o,0),o=0)}}},init:t=>async function(t,{baseURI:n}){if(!xn)try{await async function(t,n){let e,o;try{try{o=new URL(t,n)}catch{}const r=await fetch(o);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),o=e.length,r=new c(o);for(let t=0;t<o;++t)r[t]=e.charCodeAt(t);return r.buffer}(t)}const s=await WebAssembly.instantiate(e);var a;(function(t){if(yn=t,({malloc:mn,free:Sn,memory:gn}=yn),"function"!=typeof mn||"function"!=typeof Sn||!gn)throw yn=mn=Sn=gn=null,new r("Invalid WASM module")})(s.instance.exports),typeof(a=s.instance.exports).aes_hmac_new==k&&(In=a,An=0)}(t,n),xn=!0}catch(t){throw function(t){vn=t}(t),t}}(t.wasmURI,t)})});\n';if("string"==typeof r&&(r=(new TextEncoder).encode(r)),t){const t=new Blob([r],{type:e});return URL.createObjectURL(t)}return "data:"+e+";base64,"+function(t){let e="";const r=t.length;let o=0;for(;o+2<r;o+=3){const r=t[o]<<16|t[o+1]<<8|t[o+2];e+=n$1[r>>18&63]+n$1[r>>12&63]+n$1[r>>6&63]+n$1[63&r];}const s=r-o;if(1===s){const r=t[o]<<16;e+=n$1[r>>18&63]+n$1[r>>12&63]+"==";}else if(2===s){const r=t[o]<<16|t[o+1]<<8;e+=n$1[r>>18&63]+n$1[r>>12&63]+n$1[r>>6&63]+"=";}return e}(r)}});
|
|
443
443
|
|
|
444
444
|
/*
|
|
445
445
|
Copyright (c) 2026 Gildas Lormeau. All rights reserved.
|
|
@@ -1279,12 +1279,12 @@ let createEngine$1 = createEngine$2;
|
|
|
1279
1279
|
class AESDecryptionStream extends TransformStream {
|
|
1280
1280
|
|
|
1281
1281
|
constructor({ password, rawPassword, encryptionStrength, checkPasswordOnly, checkAuthenticationCode = true }) {
|
|
1282
|
+
const aesCrypto = {};
|
|
1282
1283
|
super({
|
|
1283
1284
|
start() {
|
|
1284
|
-
initAesCrypto(
|
|
1285
|
+
initAesCrypto(aesCrypto, password, rawPassword, encryptionStrength);
|
|
1285
1286
|
},
|
|
1286
1287
|
async transform(chunk, controller) {
|
|
1287
|
-
const aesCrypto = this;
|
|
1288
1288
|
const {
|
|
1289
1289
|
password,
|
|
1290
1290
|
strength,
|
|
@@ -1303,6 +1303,9 @@ class AESDecryptionStream extends TransformStream {
|
|
|
1303
1303
|
} else {
|
|
1304
1304
|
await ready;
|
|
1305
1305
|
}
|
|
1306
|
+
if (aesCrypto.discarded) {
|
|
1307
|
+
return;
|
|
1308
|
+
}
|
|
1306
1309
|
const output = new Uint8Array(chunk.length - AUTHENTICATION_CODE_LENGTH - ((chunk.length - AUTHENTICATION_CODE_LENGTH) % BLOCK_LENGTH));
|
|
1307
1310
|
controller.enqueue(append(aesCrypto, chunk, output, 0, AUTHENTICATION_CODE_LENGTH, true));
|
|
1308
1311
|
},
|
|
@@ -1311,9 +1314,12 @@ class AESDecryptionStream extends TransformStream {
|
|
|
1311
1314
|
engine,
|
|
1312
1315
|
pendingInput,
|
|
1313
1316
|
ready
|
|
1314
|
-
} =
|
|
1317
|
+
} = aesCrypto;
|
|
1315
1318
|
if (engine) {
|
|
1316
1319
|
await ready;
|
|
1320
|
+
if (aesCrypto.discarded) {
|
|
1321
|
+
return;
|
|
1322
|
+
}
|
|
1317
1323
|
const originalAuthenticationCode = subarray(pendingInput, pendingInput.length - AUTHENTICATION_CODE_LENGTH);
|
|
1318
1324
|
const decryptedChunkArray = new Uint8Array(subarray(pendingInput, 0, pendingInput.length - AUTHENTICATION_CODE_LENGTH));
|
|
1319
1325
|
engine.process(decryptedChunkArray, true);
|
|
@@ -1323,27 +1329,26 @@ class AESDecryptionStream extends TransformStream {
|
|
|
1323
1329
|
invalidAuthenticationCode |= authenticationCode[indexByte] ^ originalAuthenticationCode[indexByte];
|
|
1324
1330
|
}
|
|
1325
1331
|
if (invalidAuthenticationCode && checkAuthenticationCode) {
|
|
1326
|
-
|
|
1332
|
+
controller.error(new Error(ERR_INVALID_AUTHENTICATION_CODE));
|
|
1333
|
+
return;
|
|
1327
1334
|
}
|
|
1328
1335
|
controller.enqueue(decryptedChunkArray);
|
|
1329
1336
|
}
|
|
1330
|
-
},
|
|
1331
|
-
cancel() {
|
|
1332
|
-
disposeEngine(this);
|
|
1333
1337
|
}
|
|
1334
1338
|
});
|
|
1339
|
+
setDisposingReadable(this, aesCrypto);
|
|
1335
1340
|
}
|
|
1336
1341
|
}
|
|
1337
1342
|
|
|
1338
1343
|
class AESEncryptionStream extends TransformStream {
|
|
1339
1344
|
|
|
1340
1345
|
constructor({ password, rawPassword, encryptionStrength }) {
|
|
1346
|
+
const aesCrypto = {};
|
|
1341
1347
|
super({
|
|
1342
1348
|
start() {
|
|
1343
|
-
initAesCrypto(
|
|
1349
|
+
initAesCrypto(aesCrypto, password, rawPassword, encryptionStrength);
|
|
1344
1350
|
},
|
|
1345
1351
|
async transform(chunk, controller) {
|
|
1346
|
-
const aesCrypto = this;
|
|
1347
1352
|
const {
|
|
1348
1353
|
password,
|
|
1349
1354
|
strength,
|
|
@@ -1357,6 +1362,9 @@ class AESEncryptionStream extends TransformStream {
|
|
|
1357
1362
|
} else {
|
|
1358
1363
|
await ready;
|
|
1359
1364
|
}
|
|
1365
|
+
if (aesCrypto.discarded) {
|
|
1366
|
+
return;
|
|
1367
|
+
}
|
|
1360
1368
|
const output = new Uint8Array(preamble.length + chunk.length - (chunk.length % BLOCK_LENGTH));
|
|
1361
1369
|
output.set(preamble, 0);
|
|
1362
1370
|
controller.enqueue(append(aesCrypto, chunk, output, preamble.length, 0, false));
|
|
@@ -1366,19 +1374,20 @@ class AESEncryptionStream extends TransformStream {
|
|
|
1366
1374
|
engine,
|
|
1367
1375
|
pendingInput,
|
|
1368
1376
|
ready
|
|
1369
|
-
} =
|
|
1377
|
+
} = aesCrypto;
|
|
1370
1378
|
if (engine) {
|
|
1371
1379
|
await ready;
|
|
1380
|
+
if (aesCrypto.discarded) {
|
|
1381
|
+
return;
|
|
1382
|
+
}
|
|
1372
1383
|
const encryptedChunkArray = new Uint8Array(pendingInput);
|
|
1373
1384
|
engine.process(encryptedChunkArray, false);
|
|
1374
1385
|
const authenticationCode = subarray(engine.digest(), 0, AUTHENTICATION_CODE_LENGTH);
|
|
1375
1386
|
controller.enqueue(concat(encryptedChunkArray, authenticationCode));
|
|
1376
1387
|
}
|
|
1377
|
-
},
|
|
1378
|
-
cancel() {
|
|
1379
|
-
disposeEngine(this);
|
|
1380
1388
|
}
|
|
1381
1389
|
});
|
|
1390
|
+
setDisposingReadable(this, aesCrypto);
|
|
1382
1391
|
}
|
|
1383
1392
|
}
|
|
1384
1393
|
|
|
@@ -1391,7 +1400,37 @@ function initAesCrypto(aesCrypto, password, rawPassword, encryptionStrength) {
|
|
|
1391
1400
|
ready: new Promise(resolve => aesCrypto.resolveReady = resolve),
|
|
1392
1401
|
password: encodePassword(password, rawPassword),
|
|
1393
1402
|
strength: encryptionStrength - 1,
|
|
1394
|
-
pendingInput: EMPTY_UINT8_ARRAY
|
|
1403
|
+
pendingInput: EMPTY_UINT8_ARRAY,
|
|
1404
|
+
discarded: false
|
|
1405
|
+
});
|
|
1406
|
+
}
|
|
1407
|
+
|
|
1408
|
+
function setDisposingReadable(stream, aesCrypto) {
|
|
1409
|
+
const reader = stream.readable.getReader();
|
|
1410
|
+
const readable = new ReadableStream({
|
|
1411
|
+
async pull(controller) {
|
|
1412
|
+
try {
|
|
1413
|
+
const { value, done } = await reader.read();
|
|
1414
|
+
if (done) {
|
|
1415
|
+
controller.close();
|
|
1416
|
+
} else {
|
|
1417
|
+
controller.enqueue(value);
|
|
1418
|
+
}
|
|
1419
|
+
} catch (error) {
|
|
1420
|
+
disposeEngine(aesCrypto);
|
|
1421
|
+
reader.cancel(error).catch(() => { });
|
|
1422
|
+
throw error;
|
|
1423
|
+
}
|
|
1424
|
+
},
|
|
1425
|
+
cancel(reason) {
|
|
1426
|
+
disposeEngine(aesCrypto);
|
|
1427
|
+
return reader.cancel(reason);
|
|
1428
|
+
}
|
|
1429
|
+
});
|
|
1430
|
+
Object.defineProperty(stream, "readable", {
|
|
1431
|
+
get() {
|
|
1432
|
+
return readable;
|
|
1433
|
+
}
|
|
1395
1434
|
});
|
|
1396
1435
|
}
|
|
1397
1436
|
|
|
@@ -1424,7 +1463,9 @@ async function createDecryptionKeys(decrypt, strength, password, preamble) {
|
|
|
1424
1463
|
}
|
|
1425
1464
|
}
|
|
1426
1465
|
|
|
1427
|
-
function disposeEngine(
|
|
1466
|
+
function disposeEngine(aesCrypto) {
|
|
1467
|
+
const { engine } = aesCrypto;
|
|
1468
|
+
aesCrypto.discarded = true;
|
|
1428
1469
|
if (engine && engine.dispose) {
|
|
1429
1470
|
engine.dispose();
|
|
1430
1471
|
}
|
|
@@ -1441,6 +1482,9 @@ async function createKeys$1(aesCrypto, strength, password, salt) {
|
|
|
1441
1482
|
const keyLength = KEY_LENGTH[strength];
|
|
1442
1483
|
const compositeKey = await deriveKey(password, salt, keyLength * 2 + PASSWORD_VERIFICATION_LENGTH);
|
|
1443
1484
|
aesCrypto.engine = createEngine$1(subarray(compositeKey, 0, keyLength), subarray(compositeKey, keyLength, keyLength * 2));
|
|
1485
|
+
if (aesCrypto.discarded) {
|
|
1486
|
+
disposeEngine(aesCrypto);
|
|
1487
|
+
}
|
|
1444
1488
|
return subarray(compositeKey, keyLength * 2);
|
|
1445
1489
|
}
|
|
1446
1490
|
|
|
@@ -1592,11 +1636,11 @@ function encrypt(target, input) {
|
|
|
1592
1636
|
}
|
|
1593
1637
|
|
|
1594
1638
|
function createKeys(target, password, rawPassword) {
|
|
1595
|
-
const
|
|
1639
|
+
const cryptoKeys = [0x12345678, 0x23456789, 0x34567890];
|
|
1596
1640
|
Object.assign(target, {
|
|
1597
|
-
|
|
1598
|
-
crcKey0: new Crc32(
|
|
1599
|
-
crcKey2: new Crc32(
|
|
1641
|
+
cryptoKeys,
|
|
1642
|
+
crcKey0: new Crc32(cryptoKeys[0]),
|
|
1643
|
+
crcKey2: new Crc32(cryptoKeys[2])
|
|
1600
1644
|
});
|
|
1601
1645
|
if (rawPassword) {
|
|
1602
1646
|
for (let index = 0; index < rawPassword.length; index++) {
|
|
@@ -1610,17 +1654,17 @@ function createKeys(target, password, rawPassword) {
|
|
|
1610
1654
|
}
|
|
1611
1655
|
|
|
1612
1656
|
function updateKeys(target, byte) {
|
|
1613
|
-
let [, key1] = target.
|
|
1657
|
+
let [, key1] = target.cryptoKeys;
|
|
1614
1658
|
target.crcKey0.append([byte]);
|
|
1615
1659
|
const key0 = ~target.crcKey0.get();
|
|
1616
1660
|
key1 = getInt32(Math.imul(getInt32(key1 + getInt8(key0)), 134775813) + 1);
|
|
1617
1661
|
target.crcKey2.append([key1 >>> 24]);
|
|
1618
1662
|
const key2 = ~target.crcKey2.get();
|
|
1619
|
-
target.
|
|
1663
|
+
target.cryptoKeys = [key0, key1, key2];
|
|
1620
1664
|
}
|
|
1621
1665
|
|
|
1622
1666
|
function getByte(target) {
|
|
1623
|
-
const temp = target.
|
|
1667
|
+
const temp = target.cryptoKeys[2] | 2;
|
|
1624
1668
|
return getInt8(Math.imul(temp, (temp ^ 1)) >>> 8);
|
|
1625
1669
|
}
|
|
1626
1670
|
|
|
@@ -1668,11 +1712,16 @@ function toCompatibleReadable(readable) {
|
|
|
1668
1712
|
const reader = readable.getReader();
|
|
1669
1713
|
return new ReadableStream({
|
|
1670
1714
|
async pull(controller) {
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1715
|
+
try {
|
|
1716
|
+
const { value, done } = await reader.read();
|
|
1717
|
+
if (done) {
|
|
1718
|
+
controller.close();
|
|
1719
|
+
} else {
|
|
1720
|
+
controller.enqueue(value);
|
|
1721
|
+
}
|
|
1722
|
+
} catch (error) {
|
|
1723
|
+
reader.cancel(error).catch(() => { });
|
|
1724
|
+
throw error;
|
|
1676
1725
|
}
|
|
1677
1726
|
},
|
|
1678
1727
|
cancel(reason) {
|
|
@@ -1858,7 +1907,6 @@ const FORMAT_GZIP$1 = "gzip";
|
|
|
1858
1907
|
const GZIP_HEADER_LENGTH = 10;
|
|
1859
1908
|
const GZIP_TRAILER_LENGTH = 8;
|
|
1860
1909
|
const GZIP_HEADER_BYTES = [0x1f, 0x8b, 0x08];
|
|
1861
|
-
const GZIP_OUTPUT_STALL_TIMEOUT = 5000;
|
|
1862
1910
|
|
|
1863
1911
|
class DeflateStream extends TransformStream {
|
|
1864
1912
|
|
|
@@ -1869,7 +1917,7 @@ class DeflateStream extends TransformStream {
|
|
|
1869
1917
|
let crc32Stream, encryptionStream, gzipCrc32Stream;
|
|
1870
1918
|
let readable = super.readable;
|
|
1871
1919
|
const codecStreams = format && getCodecStreams(format);
|
|
1872
|
-
const GzipCompressionStream =
|
|
1920
|
+
const GzipCompressionStream = getGzipCodecStream(useCompressionStream, CompressionStream, CompressionStreamFallback);
|
|
1873
1921
|
const useGzipCrc32 = computeCrc32 && compressed && !deflate64 && !codecStreams && (!encrypted || zipCrypto) && Boolean(GzipCompressionStream);
|
|
1874
1922
|
if ((!encrypted || zipCrypto) && computeCrc32 && !useGzipCrc32) {
|
|
1875
1923
|
crc32Stream = new Crc32Stream();
|
|
@@ -1886,6 +1934,9 @@ class DeflateStream extends TransformStream {
|
|
|
1886
1934
|
try {
|
|
1887
1935
|
readable = pipeThroughCompressionStream(readable, useCompressionStream, { level, chunkSize }, CompressionStream, CompressionStreamFallback);
|
|
1888
1936
|
} catch (error) {
|
|
1937
|
+
if (!useCompressionStream && CompressionStreamFallback) {
|
|
1938
|
+
throw error;
|
|
1939
|
+
}
|
|
1889
1940
|
let gzipStream;
|
|
1890
1941
|
try {
|
|
1891
1942
|
gzipStream = new CompressionStream(FORMAT_GZIP$1);
|
|
@@ -1955,74 +2006,134 @@ class GzipToRawDeflateStream extends TransformStream {
|
|
|
1955
2006
|
}
|
|
1956
2007
|
|
|
1957
2008
|
function pipeThroughGzipDecompressionStream(readable, gzipStream, outputSize, crc32) {
|
|
2009
|
+
const writer = gzipStream.writable.getWriter();
|
|
2010
|
+
const reader = gzipStream.readable.getReader();
|
|
2011
|
+
const outputCrc32 = crc32 === UNDEFINED_VALUE ? new Crc32() : UNDEFINED_VALUE;
|
|
1958
2012
|
let outputLength = 0;
|
|
1959
2013
|
let inputDone = false;
|
|
1960
|
-
let
|
|
2014
|
+
let trailerWritten = false;
|
|
2015
|
+
let idleCheckArmed = false;
|
|
2016
|
+
let readCount = 0;
|
|
2017
|
+
let readPending = false;
|
|
1961
2018
|
let resolveTrailerReady, rejectTrailerReady;
|
|
1962
2019
|
const trailerReady = new Promise((resolve, reject) => {
|
|
1963
2020
|
resolveTrailerReady = resolve;
|
|
1964
2021
|
rejectTrailerReady = reject;
|
|
1965
2022
|
});
|
|
1966
2023
|
trailerReady.catch(() => { });
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
2024
|
+
pump();
|
|
2025
|
+
return new ReadableStream({
|
|
2026
|
+
async pull(controller) {
|
|
2027
|
+
try {
|
|
2028
|
+
const { value, done } = await read();
|
|
2029
|
+
if (done) {
|
|
2030
|
+
controller.close();
|
|
2031
|
+
} else {
|
|
2032
|
+
outputLength += value.length;
|
|
2033
|
+
if (outputLength > outputSize) {
|
|
2034
|
+
throw new Error(ERR_INVALID_UNCOMPRESSED_SIZE);
|
|
2035
|
+
}
|
|
2036
|
+
if (outputCrc32) {
|
|
2037
|
+
outputCrc32.append(value);
|
|
2038
|
+
}
|
|
2039
|
+
controller.enqueue(value);
|
|
2040
|
+
}
|
|
2041
|
+
} catch (error) {
|
|
2042
|
+
rejectTrailerReady(error);
|
|
2043
|
+
await cancel(reader, error);
|
|
2044
|
+
throw trailerWritten ? getTrailerError(error) : error;
|
|
2045
|
+
}
|
|
2046
|
+
},
|
|
2047
|
+
cancel(reason) {
|
|
2048
|
+
rejectTrailerReady(reason);
|
|
2049
|
+
return reader.cancel(reason);
|
|
2050
|
+
}
|
|
2051
|
+
});
|
|
2052
|
+
|
|
2053
|
+
async function pump() {
|
|
2054
|
+
const inputReader = readable.getReader();
|
|
2055
|
+
try {
|
|
1972
2056
|
const header = new Uint8Array(GZIP_HEADER_LENGTH);
|
|
1973
2057
|
header.set(GZIP_HEADER_BYTES);
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
2058
|
+
await writer.write(header);
|
|
2059
|
+
for (; ;) {
|
|
2060
|
+
await writer.ready;
|
|
2061
|
+
const { value, done } = await inputReader.read();
|
|
2062
|
+
if (done) {
|
|
2063
|
+
break;
|
|
2064
|
+
}
|
|
2065
|
+
await writer.write(value);
|
|
2066
|
+
}
|
|
1980
2067
|
inputDone = true;
|
|
1981
|
-
|
|
1982
|
-
|
|
2068
|
+
if (outputCrc32) {
|
|
2069
|
+
if (readPending) {
|
|
2070
|
+
armIdleCheck();
|
|
2071
|
+
}
|
|
1983
2072
|
await trailerReady;
|
|
1984
|
-
} finally {
|
|
1985
|
-
stopWatchdog();
|
|
1986
2073
|
}
|
|
1987
2074
|
const trailer = new Uint8Array(GZIP_TRAILER_LENGTH);
|
|
1988
2075
|
const dataView = getDataView(trailer);
|
|
1989
|
-
dataView.setUint32(0,
|
|
2076
|
+
dataView.setUint32(0, outputCrc32 ? outputCrc32.get() : crc32, true);
|
|
1990
2077
|
dataView.setUint32(4, outputSize, true);
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
2078
|
+
trailerWritten = true;
|
|
2079
|
+
await writer.write(trailer);
|
|
2080
|
+
await writer.close();
|
|
2081
|
+
} catch (error) {
|
|
2082
|
+
await abort(writer, error);
|
|
2083
|
+
await cancel(inputReader, error);
|
|
1995
2084
|
}
|
|
1996
|
-
}
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
}
|
|
2006
|
-
controller.enqueue(chunk);
|
|
2007
|
-
},
|
|
2008
|
-
cancel(reason) {
|
|
2009
|
-
rejectTrailerReady(reason);
|
|
2085
|
+
}
|
|
2086
|
+
|
|
2087
|
+
function read() {
|
|
2088
|
+
readCount++;
|
|
2089
|
+
readPending = true;
|
|
2090
|
+
const result = reader.read();
|
|
2091
|
+
result.then(onReadSettled, onReadSettled);
|
|
2092
|
+
if (inputDone && outputCrc32) {
|
|
2093
|
+
armIdleCheck();
|
|
2010
2094
|
}
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2095
|
+
return result;
|
|
2096
|
+
}
|
|
2097
|
+
|
|
2098
|
+
function onReadSettled() {
|
|
2099
|
+
readPending = false;
|
|
2100
|
+
}
|
|
2015
2101
|
|
|
2016
|
-
function
|
|
2017
|
-
|
|
2018
|
-
|
|
2102
|
+
async function armIdleCheck() {
|
|
2103
|
+
if (!idleCheckArmed) {
|
|
2104
|
+
idleCheckArmed = true;
|
|
2105
|
+
const count = readCount;
|
|
2106
|
+
await nextTask();
|
|
2107
|
+
idleCheckArmed = false;
|
|
2108
|
+
if (readPending) {
|
|
2109
|
+
if (readCount == count) {
|
|
2110
|
+
resolveTrailerReady();
|
|
2111
|
+
} else {
|
|
2112
|
+
armIdleCheck();
|
|
2113
|
+
}
|
|
2114
|
+
}
|
|
2115
|
+
}
|
|
2019
2116
|
}
|
|
2020
2117
|
|
|
2021
|
-
function
|
|
2022
|
-
|
|
2118
|
+
function getTrailerError(error) {
|
|
2119
|
+
const trailerError = new Error(outputLength == outputSize ? ERR_INVALID_CRC32 : ERR_INVALID_UNCOMPRESSED_SIZE);
|
|
2120
|
+
trailerError.cause = error;
|
|
2121
|
+
return trailerError;
|
|
2023
2122
|
}
|
|
2024
2123
|
}
|
|
2025
2124
|
|
|
2125
|
+
function nextTask() {
|
|
2126
|
+
return new Promise(resolve => {
|
|
2127
|
+
const { port1, port2 } = new MessageChannel();
|
|
2128
|
+
port2.onmessage = () => {
|
|
2129
|
+
port1.close();
|
|
2130
|
+
port2.close();
|
|
2131
|
+
resolve();
|
|
2132
|
+
};
|
|
2133
|
+
port1.postMessage(UNDEFINED_VALUE);
|
|
2134
|
+
});
|
|
2135
|
+
}
|
|
2136
|
+
|
|
2026
2137
|
class InflateStream extends TransformStream {
|
|
2027
2138
|
|
|
2028
2139
|
constructor(options, { chunkSize, DecompressionStreamFallback, DecompressionStream }) {
|
|
@@ -2043,20 +2154,32 @@ class InflateStream extends TransformStream {
|
|
|
2043
2154
|
if (codecStreams) {
|
|
2044
2155
|
readable = pipeThroughBackpressured(readable, createCodecStream(codecStreams.DecompressionStream, format, { chunkSize, compressionMethod, rawBitFlag, uncompressedSize: outputSize }));
|
|
2045
2156
|
} else {
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
if (deflate64 || outputSize === UNDEFINED_VALUE) {
|
|
2050
|
-
throw error;
|
|
2051
|
-
}
|
|
2052
|
-
let gzipStream;
|
|
2157
|
+
let gzipStream;
|
|
2158
|
+
const GzipDecompressionStream = getGzipCodecStream(useCompressionStream, DecompressionStream, DecompressionStreamFallback);
|
|
2159
|
+
if (checkCrc32 && !deflate64 && crc32 !== UNDEFINED_VALUE && outputSize !== UNDEFINED_VALUE && GzipDecompressionStream) {
|
|
2053
2160
|
try {
|
|
2054
|
-
gzipStream = new
|
|
2161
|
+
gzipStream = new GzipDecompressionStream(FORMAT_GZIP$1, { chunkSize });
|
|
2055
2162
|
} catch {
|
|
2056
|
-
|
|
2163
|
+
gzipStream = UNDEFINED_VALUE;
|
|
2164
|
+
}
|
|
2165
|
+
}
|
|
2166
|
+
if (!gzipStream) {
|
|
2167
|
+
try {
|
|
2168
|
+
readable = pipeThroughCompressionStream(readable, useCompressionStream, { chunkSize, deflate64 }, DecompressionStream, DecompressionStreamFallback);
|
|
2169
|
+
} catch (error) {
|
|
2170
|
+
if (deflate64 || outputSize === UNDEFINED_VALUE || (!useCompressionStream && DecompressionStreamFallback)) {
|
|
2171
|
+
throw error;
|
|
2172
|
+
}
|
|
2173
|
+
try {
|
|
2174
|
+
gzipStream = new DecompressionStream(FORMAT_GZIP$1);
|
|
2175
|
+
} catch {
|
|
2176
|
+
throw error;
|
|
2177
|
+
}
|
|
2057
2178
|
}
|
|
2058
|
-
|
|
2059
|
-
|
|
2179
|
+
}
|
|
2180
|
+
if (gzipStream) {
|
|
2181
|
+
gzipCrc32 = true;
|
|
2182
|
+
readable = pipeThroughGzipDecompressionStream(readable, gzipStream, outputSize, crc32);
|
|
2060
2183
|
}
|
|
2061
2184
|
}
|
|
2062
2185
|
readable = mapInflateStreamError(readable);
|
|
@@ -2066,8 +2189,8 @@ class InflateStream extends TransformStream {
|
|
|
2066
2189
|
readable = pipeThrough(readable, crc32Stream);
|
|
2067
2190
|
}
|
|
2068
2191
|
setReadable(this, readable, () => {
|
|
2069
|
-
if (
|
|
2070
|
-
const computedCrc32 =
|
|
2192
|
+
if (crc32Stream) {
|
|
2193
|
+
const computedCrc32 = new DataView(crc32Stream.value.buffer).getUint32(0, false);
|
|
2071
2194
|
if (crc32 != computedCrc32) {
|
|
2072
2195
|
throw new Error(ERR_INVALID_CRC32);
|
|
2073
2196
|
}
|
|
@@ -2124,11 +2247,11 @@ function createCodecStream(CodecStreamClass, format, options) {
|
|
|
2124
2247
|
return new CodecStreamClass(format, options);
|
|
2125
2248
|
}
|
|
2126
2249
|
|
|
2127
|
-
function
|
|
2128
|
-
if (useCompressionStream &&
|
|
2129
|
-
return
|
|
2130
|
-
} else if (
|
|
2131
|
-
return
|
|
2250
|
+
function getGzipCodecStream(useCompressionStream, CodecStreamNative, CodecStreamFallback) {
|
|
2251
|
+
if (useCompressionStream && CodecStreamNative) {
|
|
2252
|
+
return CodecStreamNative;
|
|
2253
|
+
} else if (CodecStreamFallback && CodecStreamFallback.requiresModule) {
|
|
2254
|
+
return CodecStreamFallback;
|
|
2132
2255
|
}
|
|
2133
2256
|
}
|
|
2134
2257
|
|
|
@@ -2198,10 +2321,15 @@ function mapInflateStreamError(readable) {
|
|
|
2198
2321
|
const reader = readable.getReader();
|
|
2199
2322
|
return new ReadableStream({
|
|
2200
2323
|
async pull(controller) {
|
|
2201
|
-
let result;
|
|
2202
2324
|
try {
|
|
2203
|
-
|
|
2325
|
+
const { value, done } = await reader.read();
|
|
2326
|
+
if (done) {
|
|
2327
|
+
controller.close();
|
|
2328
|
+
} else {
|
|
2329
|
+
controller.enqueue(value);
|
|
2330
|
+
}
|
|
2204
2331
|
} catch (error) {
|
|
2332
|
+
await cancel(reader, error);
|
|
2205
2333
|
if (error && error.message) {
|
|
2206
2334
|
throw error;
|
|
2207
2335
|
}
|
|
@@ -2209,12 +2337,6 @@ function mapInflateStreamError(readable) {
|
|
|
2209
2337
|
mappedError.cause = error;
|
|
2210
2338
|
throw mappedError;
|
|
2211
2339
|
}
|
|
2212
|
-
const { value, done } = result;
|
|
2213
|
-
if (done) {
|
|
2214
|
-
controller.close();
|
|
2215
|
-
} else {
|
|
2216
|
-
controller.enqueue(value);
|
|
2217
|
-
}
|
|
2218
2340
|
},
|
|
2219
2341
|
cancel(reason) {
|
|
2220
2342
|
return reader.cancel(reason);
|
|
@@ -3730,10 +3852,11 @@ class FetchReader extends Reader {
|
|
|
3730
3852
|
|
|
3731
3853
|
createReadable(options) {
|
|
3732
3854
|
const reader = this;
|
|
3733
|
-
const { useRangeHeader, forceRangeRequests, size } = reader;
|
|
3855
|
+
const { useRangeHeader, forceRangeRequests, size, eocdCache } = reader;
|
|
3734
3856
|
if ((useRangeHeader || forceRangeRequests) && size !== UNDEFINED_VALUE) {
|
|
3735
3857
|
const { offset = 0, size: readSize = size - offset } = options || {};
|
|
3736
|
-
|
|
3858
|
+
const cached = eocdCache && offset >= size - eocdCache.length;
|
|
3859
|
+
if (readSize > 0 && offset < size && !cached) {
|
|
3737
3860
|
return createRangeReadable(reader, offset, Math.min(readSize, size - offset));
|
|
3738
3861
|
}
|
|
3739
3862
|
}
|
|
@@ -5292,8 +5415,8 @@ let ZipEntry$1 = class ZipEntry {
|
|
|
5292
5415
|
const passThroughCompression = Boolean(passThrough);
|
|
5293
5416
|
const passThroughEncryption = passThrough === true;
|
|
5294
5417
|
checkPasswordOption(password, rawPassword);
|
|
5295
|
-
password = password && password.length
|
|
5296
|
-
rawPassword = rawPassword && rawPassword.length
|
|
5418
|
+
password = password && password.length ? password : UNDEFINED_VALUE;
|
|
5419
|
+
rawPassword = rawPassword && rawPassword.length ? rawPassword : UNDEFINED_VALUE;
|
|
5297
5420
|
if (extraFieldAES) {
|
|
5298
5421
|
if (extraFieldAES.originalCompressionMethod != COMPRESSION_METHOD_AES) {
|
|
5299
5422
|
throw new Error(ERR_UNSUPPORTED_COMPRESSION);
|
|
@@ -6054,7 +6177,7 @@ function getMaxAppendedDataSize(maxAppendedDataSize, strictness) {
|
|
|
6054
6177
|
async function findEndOfCentralDirectory(reader, rejectAmbiguous, maxAppendedDataSize) {
|
|
6055
6178
|
const { size } = reader;
|
|
6056
6179
|
const anchoredLength = Math.min(size, END_OF_CENTRAL_DIR_LENGTH + MAX_16_BITS);
|
|
6057
|
-
const remoteProbeBudget = {
|
|
6180
|
+
const remoteProbeBudget = { remaining: MAX_END_OF_CENTRAL_DIR_PROBES };
|
|
6058
6181
|
let endOfDirectoryInfo;
|
|
6059
6182
|
let plausibleEndOfDirectoryInfo;
|
|
6060
6183
|
let endOfDirectoryReachingEndCount = 0;
|
|
@@ -6147,8 +6270,8 @@ async function readSignature(reader, view, anchoredOffset, signatureOffset, size
|
|
|
6147
6270
|
if (signatureOffset >= anchoredOffset) {
|
|
6148
6271
|
return getUint32$1(view, signatureOffset - anchoredOffset);
|
|
6149
6272
|
}
|
|
6150
|
-
if (remoteProbeBudget.
|
|
6151
|
-
remoteProbeBudget.
|
|
6273
|
+
if (remoteProbeBudget.remaining > 0) {
|
|
6274
|
+
remoteProbeBudget.remaining--;
|
|
6152
6275
|
const signatureArray = await readUint8Array(reader, signatureOffset, 4);
|
|
6153
6276
|
return getUint32$1(getDataView(signatureArray), 0);
|
|
6154
6277
|
}
|
|
@@ -7064,9 +7187,11 @@ function resolveMetadata(zipWriter, name, options) {
|
|
|
7064
7187
|
const passThrough = checkPassThroughOption(getOptionValue(zipWriter, options, OPTION_PASS_THROUGH));
|
|
7065
7188
|
const passThroughCompression = Boolean(passThrough);
|
|
7066
7189
|
const passThroughEncryption = passThrough === true;
|
|
7067
|
-
|
|
7068
|
-
|
|
7190
|
+
let password = getOptionValue(zipWriter, options, OPTION_PASSWORD);
|
|
7191
|
+
let rawPassword = getOptionValue(zipWriter, options, OPTION_RAW_PASSWORD);
|
|
7069
7192
|
checkPasswordOption(password, rawPassword);
|
|
7193
|
+
password = password && password.length ? password : UNDEFINED_VALUE;
|
|
7194
|
+
rawPassword = rawPassword && rawPassword.length ? rawPassword : UNDEFINED_VALUE;
|
|
7070
7195
|
const encryptionStrength = getNumberOptionValue(zipWriter, options, OPTION_ENCRYPTION_STRENGTH, 3);
|
|
7071
7196
|
const zipCrypto = getOptionValue(zipWriter, options, PROPERTY_NAME_ZIPCRYPTO);
|
|
7072
7197
|
const extendedTimestamp = getOptionValue(zipWriter, options, OPTION_EXTENDED_TIMESTAMP, true);
|
|
@@ -8862,7 +8987,7 @@ function formatSupported(StreamClass, format) {
|
|
|
8862
8987
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
8863
8988
|
*/
|
|
8864
8989
|
|
|
8865
|
-
const VERSION = "2.
|
|
8990
|
+
const VERSION = "2.16.1";
|
|
8866
8991
|
|
|
8867
8992
|
/*
|
|
8868
8993
|
Copyright (c) 2025 Gildas Lormeau. All rights reserved.
|
|
@@ -9341,7 +9466,7 @@ const n=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,1
|
|
|
9341
9466
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
9342
9467
|
*/
|
|
9343
9468
|
|
|
9344
|
-
/* global
|
|
9469
|
+
/* global ReadableStream, WritableStream */
|
|
9345
9470
|
|
|
9346
9471
|
const FORMAT_DEFLATE = "deflate";
|
|
9347
9472
|
const FORMAT_DEFLATE_RAW = "deflate-raw";
|
|
@@ -9376,137 +9501,195 @@ function _make(isCompress, type, options = {}) {
|
|
|
9376
9501
|
const level = (typeof options.level === "number") ? options.level : -1;
|
|
9377
9502
|
const outBufferSize = (typeof options.outBuffer === "number") ? options.outBuffer : 64 * 1024;
|
|
9378
9503
|
const inBufferSize = (typeof options.inBufferSize === "number") ? options.inBufferSize : 64 * 1024;
|
|
9379
|
-
|
|
9380
|
-
|
|
9381
|
-
|
|
9504
|
+
const state = { out: 0, in: 0, inBufferSize: 0, streamHandle: 0 };
|
|
9505
|
+
let readableController, writableController, resolveWrite, cancelReason;
|
|
9506
|
+
let backpressure = true;
|
|
9507
|
+
let cancelled = false;
|
|
9508
|
+
initStream();
|
|
9509
|
+
const readable = new ReadableStream({
|
|
9510
|
+
start(controller) {
|
|
9511
|
+
readableController = controller;
|
|
9512
|
+
},
|
|
9513
|
+
pull() {
|
|
9514
|
+
backpressure = false;
|
|
9515
|
+
resumeWrite();
|
|
9516
|
+
},
|
|
9517
|
+
cancel(reason) {
|
|
9518
|
+
cancelled = true;
|
|
9519
|
+
cancelReason = reason;
|
|
9520
|
+
disposeStream(state);
|
|
9521
|
+
writableController.error(reason);
|
|
9522
|
+
resumeWrite();
|
|
9523
|
+
}
|
|
9524
|
+
}, { highWaterMark: 0 });
|
|
9525
|
+
const writable = new WritableStream({
|
|
9526
|
+
start(controller) {
|
|
9527
|
+
writableController = controller;
|
|
9528
|
+
},
|
|
9529
|
+
async write(chunk) {
|
|
9530
|
+
if (backpressure) {
|
|
9531
|
+
await new Promise(resolve => resolveWrite = resolve);
|
|
9532
|
+
}
|
|
9533
|
+
if (cancelled) {
|
|
9534
|
+
throw cancelReason;
|
|
9535
|
+
}
|
|
9382
9536
|
try {
|
|
9383
|
-
|
|
9384
|
-
this.out = malloc(outBufferSize);
|
|
9385
|
-
this.in = malloc(inBufferSize);
|
|
9386
|
-
this.inBufferSize = inBufferSize;
|
|
9387
|
-
if (!this.out || !this.in) {
|
|
9388
|
-
throw new Error("allocation failed");
|
|
9389
|
-
}
|
|
9390
|
-
if (isCompress) {
|
|
9391
|
-
this._process = wasm$1.deflate_process;
|
|
9392
|
-
this._last_consumed = wasm$1.deflate_last_consumed;
|
|
9393
|
-
this._end = wasm$1.deflate_end;
|
|
9394
|
-
this.streamHandle = wasm$1.deflate_new();
|
|
9395
|
-
if (type === FORMAT_GZIP) {
|
|
9396
|
-
result = wasm$1.deflate_init_gzip(this.streamHandle, level);
|
|
9397
|
-
} else if (type === FORMAT_DEFLATE_RAW) {
|
|
9398
|
-
result = wasm$1.deflate_init_raw(this.streamHandle, level);
|
|
9399
|
-
} else {
|
|
9400
|
-
result = wasm$1.deflate_init(this.streamHandle, level);
|
|
9401
|
-
}
|
|
9402
|
-
} else {
|
|
9403
|
-
if (type === FORMAT_DEFLATE64_RAW) {
|
|
9404
|
-
this._process = wasm$1.inflate9_process;
|
|
9405
|
-
this._last_consumed = wasm$1.inflate9_last_consumed;
|
|
9406
|
-
this._end = wasm$1.inflate9_end;
|
|
9407
|
-
this.streamHandle = wasm$1.inflate9_new();
|
|
9408
|
-
result = wasm$1.inflate9_init_raw(this.streamHandle);
|
|
9409
|
-
} else {
|
|
9410
|
-
this._process = wasm$1.inflate_process;
|
|
9411
|
-
this._last_consumed = wasm$1.inflate_last_consumed;
|
|
9412
|
-
this._end = wasm$1.inflate_end;
|
|
9413
|
-
this.streamHandle = wasm$1.inflate_new();
|
|
9414
|
-
if (type === FORMAT_DEFLATE_RAW) {
|
|
9415
|
-
result = wasm$1.inflate_init_raw(this.streamHandle);
|
|
9416
|
-
} else if (type === FORMAT_GZIP) {
|
|
9417
|
-
result = wasm$1.inflate_init_gzip(this.streamHandle);
|
|
9418
|
-
} else {
|
|
9419
|
-
result = wasm$1.inflate_init(this.streamHandle);
|
|
9420
|
-
}
|
|
9421
|
-
}
|
|
9422
|
-
}
|
|
9423
|
-
if (result !== 0) {
|
|
9424
|
-
throw new Error("init failed:" + result);
|
|
9425
|
-
}
|
|
9537
|
+
processChunk(chunk);
|
|
9426
9538
|
} catch (error) {
|
|
9427
|
-
disposeStream(
|
|
9539
|
+
disposeStream(state);
|
|
9540
|
+
readableController.error(error);
|
|
9428
9541
|
throw error;
|
|
9429
9542
|
}
|
|
9430
9543
|
},
|
|
9431
|
-
|
|
9544
|
+
close() {
|
|
9545
|
+
if (cancelled) {
|
|
9546
|
+
return;
|
|
9547
|
+
}
|
|
9432
9548
|
try {
|
|
9433
|
-
|
|
9434
|
-
const heap = new Uint8Array(memory.buffer);
|
|
9435
|
-
const process = this._process;
|
|
9436
|
-
const last_consumed = this._last_consumed;
|
|
9437
|
-
const out = this.out;
|
|
9438
|
-
let offset = 0;
|
|
9439
|
-
while (offset < buffer.length) {
|
|
9440
|
-
const toRead = Math.min(buffer.length - offset, 32 * 1024);
|
|
9441
|
-
if (!this.in || this.inBufferSize < toRead) {
|
|
9442
|
-
if (this.in && free) {
|
|
9443
|
-
free(this.in);
|
|
9444
|
-
this.in = 0;
|
|
9445
|
-
}
|
|
9446
|
-
this.in = malloc(toRead);
|
|
9447
|
-
this.inBufferSize = toRead;
|
|
9448
|
-
if (!this.in) {
|
|
9449
|
-
throw new Error("allocation failed");
|
|
9450
|
-
}
|
|
9451
|
-
}
|
|
9452
|
-
heap.set(buffer.subarray(offset, offset + toRead), this.in);
|
|
9453
|
-
const result = process(this.streamHandle, this.in, toRead, out, outBufferSize, 0);
|
|
9454
|
-
// checked before the byte count is used, so a status code can never be read as one
|
|
9455
|
-
const code = (result >> 24) & 0xff;
|
|
9456
|
-
const signedCode = (code & 0x80) ? code - 256 : code;
|
|
9457
|
-
if (signedCode < 0) {
|
|
9458
|
-
throw new Error("process error:" + signedCode);
|
|
9459
|
-
}
|
|
9460
|
-
const prod = result & 0x00ffffff;
|
|
9461
|
-
if (prod) {
|
|
9462
|
-
controller.enqueue(heap.slice(out, out + prod));
|
|
9463
|
-
}
|
|
9464
|
-
const consumed = last_consumed(this.streamHandle);
|
|
9465
|
-
if (consumed === 0 && prod === 0) {
|
|
9466
|
-
break;
|
|
9467
|
-
}
|
|
9468
|
-
offset += consumed;
|
|
9469
|
-
}
|
|
9549
|
+
flushStream();
|
|
9470
9550
|
} catch (error) {
|
|
9471
|
-
disposeStream(
|
|
9472
|
-
|
|
9551
|
+
disposeStream(state);
|
|
9552
|
+
readableController.error(error);
|
|
9553
|
+
throw error;
|
|
9554
|
+
}
|
|
9555
|
+
const result = disposeStream(state);
|
|
9556
|
+
if (result !== 0) {
|
|
9557
|
+
const error = new Error("end error:" + result);
|
|
9558
|
+
readableController.error(error);
|
|
9559
|
+
throw error;
|
|
9473
9560
|
}
|
|
9561
|
+
readableController.close();
|
|
9474
9562
|
},
|
|
9475
|
-
|
|
9476
|
-
|
|
9477
|
-
|
|
9478
|
-
|
|
9479
|
-
|
|
9480
|
-
|
|
9481
|
-
|
|
9482
|
-
|
|
9483
|
-
|
|
9484
|
-
|
|
9485
|
-
|
|
9486
|
-
|
|
9487
|
-
|
|
9488
|
-
|
|
9489
|
-
|
|
9490
|
-
|
|
9491
|
-
|
|
9492
|
-
|
|
9563
|
+
abort(reason) {
|
|
9564
|
+
disposeStream(state);
|
|
9565
|
+
readableController.error(reason);
|
|
9566
|
+
}
|
|
9567
|
+
}, { highWaterMark: 1 });
|
|
9568
|
+
return { readable, writable };
|
|
9569
|
+
|
|
9570
|
+
function initStream() {
|
|
9571
|
+
try {
|
|
9572
|
+
let result;
|
|
9573
|
+
state.out = malloc(outBufferSize);
|
|
9574
|
+
state.in = malloc(inBufferSize);
|
|
9575
|
+
state.inBufferSize = inBufferSize;
|
|
9576
|
+
if (!state.out || !state.in) {
|
|
9577
|
+
throw new Error("allocation failed");
|
|
9578
|
+
}
|
|
9579
|
+
if (isCompress) {
|
|
9580
|
+
state._process = wasm$1.deflate_process;
|
|
9581
|
+
state._last_consumed = wasm$1.deflate_last_consumed;
|
|
9582
|
+
state._end = wasm$1.deflate_end;
|
|
9583
|
+
state.streamHandle = wasm$1.deflate_new();
|
|
9584
|
+
if (type === FORMAT_GZIP) {
|
|
9585
|
+
result = wasm$1.deflate_init_gzip(state.streamHandle, level);
|
|
9586
|
+
} else if (type === FORMAT_DEFLATE_RAW) {
|
|
9587
|
+
result = wasm$1.deflate_init_raw(state.streamHandle, level);
|
|
9588
|
+
} else {
|
|
9589
|
+
result = wasm$1.deflate_init(state.streamHandle, level);
|
|
9590
|
+
}
|
|
9591
|
+
} else {
|
|
9592
|
+
if (type === FORMAT_DEFLATE64_RAW) {
|
|
9593
|
+
state._process = wasm$1.inflate9_process;
|
|
9594
|
+
state._last_consumed = wasm$1.inflate9_last_consumed;
|
|
9595
|
+
state._end = wasm$1.inflate9_end;
|
|
9596
|
+
state.streamHandle = wasm$1.inflate9_new();
|
|
9597
|
+
result = wasm$1.inflate9_init_raw(state.streamHandle);
|
|
9598
|
+
} else {
|
|
9599
|
+
state._process = wasm$1.inflate_process;
|
|
9600
|
+
state._last_consumed = wasm$1.inflate_last_consumed;
|
|
9601
|
+
state._end = wasm$1.inflate_end;
|
|
9602
|
+
state.streamHandle = wasm$1.inflate_new();
|
|
9603
|
+
if (type === FORMAT_DEFLATE_RAW) {
|
|
9604
|
+
result = wasm$1.inflate_init_raw(state.streamHandle);
|
|
9605
|
+
} else if (type === FORMAT_GZIP) {
|
|
9606
|
+
result = wasm$1.inflate_init_gzip(state.streamHandle);
|
|
9607
|
+
} else {
|
|
9608
|
+
result = wasm$1.inflate_init(state.streamHandle);
|
|
9493
9609
|
}
|
|
9494
9610
|
}
|
|
9495
|
-
}
|
|
9496
|
-
|
|
9497
|
-
|
|
9498
|
-
|
|
9499
|
-
|
|
9500
|
-
|
|
9611
|
+
}
|
|
9612
|
+
if (result !== 0) {
|
|
9613
|
+
throw new Error("init failed:" + result);
|
|
9614
|
+
}
|
|
9615
|
+
} catch (error) {
|
|
9616
|
+
disposeStream(state);
|
|
9617
|
+
throw error;
|
|
9618
|
+
}
|
|
9619
|
+
}
|
|
9620
|
+
|
|
9621
|
+
function processChunk(chunk) {
|
|
9622
|
+
const heap = new Uint8Array(memory.buffer);
|
|
9623
|
+
const process = state._process;
|
|
9624
|
+
const last_consumed = state._last_consumed;
|
|
9625
|
+
const out = state.out;
|
|
9626
|
+
let offset = 0;
|
|
9627
|
+
while (offset < chunk.length) {
|
|
9628
|
+
const toRead = Math.min(chunk.length - offset, 32 * 1024);
|
|
9629
|
+
if (!state.in || state.inBufferSize < toRead) {
|
|
9630
|
+
if (state.in && free) {
|
|
9631
|
+
free(state.in);
|
|
9632
|
+
state.in = 0;
|
|
9633
|
+
}
|
|
9634
|
+
state.in = malloc(toRead);
|
|
9635
|
+
state.inBufferSize = toRead;
|
|
9636
|
+
if (!state.in) {
|
|
9637
|
+
throw new Error("allocation failed");
|
|
9501
9638
|
}
|
|
9502
9639
|
}
|
|
9503
|
-
|
|
9504
|
-
|
|
9505
|
-
//
|
|
9506
|
-
|
|
9507
|
-
|
|
9640
|
+
heap.set(chunk.subarray(offset, offset + toRead), state.in);
|
|
9641
|
+
const result = process(state.streamHandle, state.in, toRead, out, outBufferSize, 0);
|
|
9642
|
+
// checked before the byte count is used, so a status code can never be read as one
|
|
9643
|
+
const code = (result >> 24) & 0xff;
|
|
9644
|
+
const signedCode = (code & 0x80) ? code - 256 : code;
|
|
9645
|
+
if (signedCode < 0) {
|
|
9646
|
+
throw new Error("process error:" + signedCode);
|
|
9647
|
+
}
|
|
9648
|
+
const prod = result & 0x00ffffff;
|
|
9649
|
+
if (prod) {
|
|
9650
|
+
enqueue(heap.slice(out, out + prod));
|
|
9651
|
+
}
|
|
9652
|
+
const consumed = last_consumed(state.streamHandle);
|
|
9653
|
+
if (consumed === 0 && prod === 0) {
|
|
9654
|
+
break;
|
|
9655
|
+
}
|
|
9656
|
+
offset += consumed;
|
|
9508
9657
|
}
|
|
9509
|
-
}
|
|
9658
|
+
}
|
|
9659
|
+
|
|
9660
|
+
function flushStream() {
|
|
9661
|
+
const heap = new Uint8Array(memory.buffer);
|
|
9662
|
+
const process = state._process;
|
|
9663
|
+
const out = state.out;
|
|
9664
|
+
while (true) {
|
|
9665
|
+
const result = process(state.streamHandle, 0, 0, out, outBufferSize, 4);
|
|
9666
|
+
const code = (result >> 24) & 0xff;
|
|
9667
|
+
const signedCode = (code & 0x80) ? code - 256 : code;
|
|
9668
|
+
if (signedCode < 0) {
|
|
9669
|
+
throw new Error("process error:" + signedCode);
|
|
9670
|
+
}
|
|
9671
|
+
const produced = result & 0x00ffffff;
|
|
9672
|
+
if (produced) {
|
|
9673
|
+
enqueue(heap.slice(out, out + produced));
|
|
9674
|
+
}
|
|
9675
|
+
if (code === 1 || produced === 0) {
|
|
9676
|
+
break;
|
|
9677
|
+
}
|
|
9678
|
+
}
|
|
9679
|
+
}
|
|
9680
|
+
|
|
9681
|
+
function enqueue(chunk) {
|
|
9682
|
+
backpressure = true;
|
|
9683
|
+
readableController.enqueue(chunk);
|
|
9684
|
+
}
|
|
9685
|
+
|
|
9686
|
+
function resumeWrite() {
|
|
9687
|
+
if (resolveWrite) {
|
|
9688
|
+
const resolve = resolveWrite;
|
|
9689
|
+
resolveWrite = null;
|
|
9690
|
+
resolve();
|
|
9691
|
+
}
|
|
9692
|
+
}
|
|
9510
9693
|
|
|
9511
9694
|
function disposeStream(state) {
|
|
9512
9695
|
let endResult = 0;
|
|
@@ -9862,7 +10045,11 @@ const DUPLICATES_VALUES = new Set([DUPLICATES_THROW, DUPLICATES_KEEP_FIRST, DUPL
|
|
|
9862
10045
|
const ERR_INVALID_PASS_THROUGH = "Invalid passThrough option (use readerOptions.passThrough or set uncompressedSize for each entry)";
|
|
9863
10046
|
const ERR_INVALID_READER_OPTIONS = "Invalid readerOptions (must be an object)";
|
|
9864
10047
|
const ERR_UNSUPPORTED_PASS_THROUGH_VALUE = "The 'compressed' passThrough option is only supported by Entry#getData() and ZipWriter#add()";
|
|
10048
|
+
const ERR_INVALID_PASSWORDS = "Invalid passwords option (must be an array of strings)";
|
|
10049
|
+
const ERR_INVALID_REQUEST_PASSWORD = "Invalid requestPassword option (must be a function returning a string or undefined)";
|
|
9865
10050
|
const ERR_ABORT_EXPORT = "zipjs-abort-export";
|
|
10051
|
+
const ABORT_ERROR_NAME = "AbortError";
|
|
10052
|
+
const EMPTY_RAW_PASSWORD = new Uint8Array(0);
|
|
9866
10053
|
|
|
9867
10054
|
class ZipEntry {
|
|
9868
10055
|
|
|
@@ -10235,8 +10422,10 @@ class ZipDirectoryEntry extends ZipEntry {
|
|
|
10235
10422
|
zipReader = new ZipReader(reader, options);
|
|
10236
10423
|
}
|
|
10237
10424
|
checkPassThroughValue(options.passThrough);
|
|
10425
|
+
checkPasswordCandidatesOptions(options);
|
|
10238
10426
|
const duplicates = checkDuplicatesOption(options.duplicates);
|
|
10239
10427
|
const importedEntries = [];
|
|
10428
|
+
const passwordState = { known: [] };
|
|
10240
10429
|
const entries = await zipReader.getEntries(options);
|
|
10241
10430
|
for (const entry of entries) {
|
|
10242
10431
|
let parent = this;
|
|
@@ -10281,7 +10470,7 @@ class ZipDirectoryEntry extends ZipEntry {
|
|
|
10281
10470
|
}
|
|
10282
10471
|
importedEntries.push(addChild(parent, name, {
|
|
10283
10472
|
data: entry,
|
|
10284
|
-
Reader: getZipBlobReader(Object.assign({}, options)),
|
|
10473
|
+
Reader: getZipBlobReader(Object.assign({}, options), passwordState),
|
|
10285
10474
|
uncompressedSize: options.passThrough ? entry.compressedSize : entry.uncompressedSize,
|
|
10286
10475
|
passThrough: options.passThrough
|
|
10287
10476
|
}));
|
|
@@ -10610,7 +10799,7 @@ function getReadableReader(readable) {
|
|
|
10610
10799
|
};
|
|
10611
10800
|
}
|
|
10612
10801
|
|
|
10613
|
-
function getZipBlobReader(options) {
|
|
10802
|
+
function getZipBlobReader(options, passwordState) {
|
|
10614
10803
|
return class extends Reader {
|
|
10615
10804
|
|
|
10616
10805
|
constructor(entry, options = {}) {
|
|
@@ -10623,12 +10812,12 @@ function getZipBlobReader(options) {
|
|
|
10623
10812
|
const zipBlobReader = this;
|
|
10624
10813
|
const readerOptions = Object.assign({}, options, zipBlobReader.options);
|
|
10625
10814
|
const { checkOverlappingEntry, checkOverlappingEntryOnly } = readerOptions;
|
|
10626
|
-
const data = await zipBlobReader.entry
|
|
10815
|
+
const data = await readEntryData(zipBlobReader.entry, Object.assign(readerOptions, {
|
|
10627
10816
|
checkPasswordOnly: false,
|
|
10628
10817
|
checkOverlappingEntry: checkOverlappingEntryOnly || checkOverlappingEntry,
|
|
10629
10818
|
checkOverlappingEntryOnly: false,
|
|
10630
10819
|
preventClose: false
|
|
10631
|
-
}));
|
|
10820
|
+
}), passwordState);
|
|
10632
10821
|
zipBlobReader.data = data;
|
|
10633
10822
|
zipBlobReader.blobReader = new BlobReader(data);
|
|
10634
10823
|
zipBlobReader.size = data.size;
|
|
@@ -10690,10 +10879,9 @@ async function initReaders(entry, options) {
|
|
|
10690
10879
|
await initStream(reader);
|
|
10691
10880
|
} catch (error) {
|
|
10692
10881
|
try {
|
|
10882
|
+
error.entry = child;
|
|
10693
10883
|
error.entryId = child.id;
|
|
10694
|
-
error.
|
|
10695
|
-
entry: child
|
|
10696
|
-
};
|
|
10884
|
+
error.entryName = child.getRelativeName(entry);
|
|
10697
10885
|
} catch {
|
|
10698
10886
|
// ignored
|
|
10699
10887
|
}
|
|
@@ -10785,10 +10973,136 @@ function checkReaderOptions(readerOptions) {
|
|
|
10785
10973
|
}
|
|
10786
10974
|
if (readerOptions) {
|
|
10787
10975
|
checkPassThroughValue(readerOptions.passThrough);
|
|
10976
|
+
checkPasswordCandidatesOptions(readerOptions);
|
|
10788
10977
|
}
|
|
10789
10978
|
return readerOptions;
|
|
10790
10979
|
}
|
|
10791
10980
|
|
|
10981
|
+
function checkPasswordCandidatesOptions(options) {
|
|
10982
|
+
const { passwords, requestPassword } = options;
|
|
10983
|
+
if (passwords && (!Array.isArray(passwords) || passwords.some(password => typeof password != STRING_TYPE))) {
|
|
10984
|
+
throw new Error(ERR_INVALID_PASSWORDS);
|
|
10985
|
+
}
|
|
10986
|
+
if (requestPassword && typeof requestPassword != FUNCTION_TYPE) {
|
|
10987
|
+
throw new Error(ERR_INVALID_REQUEST_PASSWORD);
|
|
10988
|
+
}
|
|
10989
|
+
}
|
|
10990
|
+
|
|
10991
|
+
async function readEntryData(entry, options, passwordState) {
|
|
10992
|
+
checkPasswordCandidatesOptions(options);
|
|
10993
|
+
const { passwords, requestPassword, signal } = options;
|
|
10994
|
+
options = Object.assign({}, options);
|
|
10995
|
+
delete options.passwords;
|
|
10996
|
+
delete options.requestPassword;
|
|
10997
|
+
if (!entry.encrypted || options.passThrough || (!passwords && !requestPassword)) {
|
|
10998
|
+
return entry.getData(new BlobWriter(), options);
|
|
10999
|
+
}
|
|
11000
|
+
const tried = new Set();
|
|
11001
|
+
let error;
|
|
11002
|
+
while (true) {
|
|
11003
|
+
for (const candidate of getPasswordCandidates(options, passwordState, passwords)) {
|
|
11004
|
+
if (!tried.has(candidate.key)) {
|
|
11005
|
+
const result = await tryPasswordCandidate(candidate);
|
|
11006
|
+
if (result.done) {
|
|
11007
|
+
return result.data;
|
|
11008
|
+
}
|
|
11009
|
+
error = result.error;
|
|
11010
|
+
}
|
|
11011
|
+
}
|
|
11012
|
+
if (!requestPassword) {
|
|
11013
|
+
break;
|
|
11014
|
+
}
|
|
11015
|
+
if (passwordState.pendingPrompt) {
|
|
11016
|
+
await passwordState.pendingPrompt;
|
|
11017
|
+
continue;
|
|
11018
|
+
}
|
|
11019
|
+
let release;
|
|
11020
|
+
passwordState.pendingPrompt = new Promise(resolve => release = resolve);
|
|
11021
|
+
try {
|
|
11022
|
+
const answer = await requestPassword(entry, error);
|
|
11023
|
+
if (answer === UNDEFINED_VALUE || answer === null) {
|
|
11024
|
+
break;
|
|
11025
|
+
}
|
|
11026
|
+
// deno-lint-ignore valid-typeof
|
|
11027
|
+
if (typeof answer != STRING_TYPE) {
|
|
11028
|
+
throw new Error(ERR_INVALID_REQUEST_PASSWORD);
|
|
11029
|
+
}
|
|
11030
|
+
const result = await tryPasswordCandidate(getPasswordCandidate(answer));
|
|
11031
|
+
if (result.done) {
|
|
11032
|
+
return result.data;
|
|
11033
|
+
}
|
|
11034
|
+
error = result.error;
|
|
11035
|
+
} finally {
|
|
11036
|
+
passwordState.pendingPrompt = UNDEFINED_VALUE;
|
|
11037
|
+
release();
|
|
11038
|
+
}
|
|
11039
|
+
}
|
|
11040
|
+
throw new Error(tried.size ? ERR_INVALID_PASSWORD : ERR_ENCRYPTED);
|
|
11041
|
+
|
|
11042
|
+
async function tryPasswordCandidate(candidate) {
|
|
11043
|
+
tried.add(candidate.key);
|
|
11044
|
+
const candidateOptions = Object.assign({}, options, candidate.options);
|
|
11045
|
+
if (entry.zipCrypto) {
|
|
11046
|
+
candidateOptions.checkCrc32 = true;
|
|
11047
|
+
try {
|
|
11048
|
+
await entry.getData(null, Object.assign({}, candidateOptions, { checkPasswordOnly: true }));
|
|
11049
|
+
} catch (probeError) {
|
|
11050
|
+
if (isInvalidPasswordError(probeError)) {
|
|
11051
|
+
return { done: false, error: probeError };
|
|
11052
|
+
}
|
|
11053
|
+
throw probeError;
|
|
11054
|
+
}
|
|
11055
|
+
}
|
|
11056
|
+
try {
|
|
11057
|
+
const data = await entry.getData(new BlobWriter(), candidateOptions);
|
|
11058
|
+
rememberPassword(passwordState, candidate);
|
|
11059
|
+
return { done: true, data };
|
|
11060
|
+
} catch (readError) {
|
|
11061
|
+
if (isAbortError(readError, signal) || (!entry.zipCrypto && !isInvalidPasswordError(readError))) {
|
|
11062
|
+
throw readError;
|
|
11063
|
+
}
|
|
11064
|
+
return { done: false, error: readError };
|
|
11065
|
+
}
|
|
11066
|
+
}
|
|
11067
|
+
}
|
|
11068
|
+
|
|
11069
|
+
function isInvalidPasswordError(error) {
|
|
11070
|
+
return isErrorObject(error) && error.message == ERR_INVALID_PASSWORD;
|
|
11071
|
+
}
|
|
11072
|
+
|
|
11073
|
+
function isAbortError(error, signal) {
|
|
11074
|
+
return Boolean(signal && signal.aborted) || (isErrorObject(error) && error.name == ABORT_ERROR_NAME);
|
|
11075
|
+
}
|
|
11076
|
+
|
|
11077
|
+
function getPasswordCandidates(options, passwordState, passwords) {
|
|
11078
|
+
const candidates = [];
|
|
11079
|
+
const { password, rawPassword } = options;
|
|
11080
|
+
if (rawPassword && rawPassword.length) {
|
|
11081
|
+
candidates.push({ key: rawPassword, options: { password: "", rawPassword } });
|
|
11082
|
+
}
|
|
11083
|
+
if (password) {
|
|
11084
|
+
candidates.push(getPasswordCandidate(password));
|
|
11085
|
+
}
|
|
11086
|
+
candidates.push(...passwordState.known);
|
|
11087
|
+
if (passwords) {
|
|
11088
|
+
candidates.push(...passwords.filter(password => password).map(getPasswordCandidate));
|
|
11089
|
+
}
|
|
11090
|
+
return candidates;
|
|
11091
|
+
}
|
|
11092
|
+
|
|
11093
|
+
function getPasswordCandidate(password) {
|
|
11094
|
+
return { key: password, options: { password, rawPassword: EMPTY_RAW_PASSWORD } };
|
|
11095
|
+
}
|
|
11096
|
+
|
|
11097
|
+
function rememberPassword(passwordState, candidate) {
|
|
11098
|
+
const { known } = passwordState;
|
|
11099
|
+
const index = known.findIndex(knownCandidate => knownCandidate.key === candidate.key);
|
|
11100
|
+
if (index != -1) {
|
|
11101
|
+
known.splice(index, 1);
|
|
11102
|
+
}
|
|
11103
|
+
known.unshift(candidate);
|
|
11104
|
+
}
|
|
11105
|
+
|
|
10792
11106
|
function checkPassThroughValue(passThrough) {
|
|
10793
11107
|
if (checkPassThroughOption(passThrough) === PASS_THROUGH_COMPRESSED) {
|
|
10794
11108
|
throw new Error(ERR_UNSUPPORTED_PASS_THROUGH_VALUE);
|
|
@@ -10926,6 +11240,7 @@ function addFileSystemHandle(zipEntry, handle, options) {
|
|
|
10926
11240
|
async function exportFileSystemHandle(zipEntry, directoryHandle, options) {
|
|
10927
11241
|
const { onstart, onprogress, onend } = options;
|
|
10928
11242
|
checkPassThroughValue(options.passThrough);
|
|
11243
|
+
checkPasswordCandidatesOptions(options);
|
|
10929
11244
|
const readerOptions = checkReaderOptions(options.readerOptions);
|
|
10930
11245
|
const abortController = new AbortController();
|
|
10931
11246
|
const { signal } = abortController;
|
|
@@ -11319,11 +11634,13 @@ exports.ERR_INVALID_MAX_WORKERS = ERR_INVALID_MAX_WORKERS;
|
|
|
11319
11634
|
exports.ERR_INVALID_MSDOS_ATTRIBUTES = ERR_INVALID_MSDOS_ATTRIBUTES;
|
|
11320
11635
|
exports.ERR_INVALID_MSDOS_DATA = ERR_INVALID_MSDOS_DATA;
|
|
11321
11636
|
exports.ERR_INVALID_PASSWORD = ERR_INVALID_PASSWORD;
|
|
11637
|
+
exports.ERR_INVALID_PASSWORDS = ERR_INVALID_PASSWORDS;
|
|
11322
11638
|
exports.ERR_INVALID_PASSWORD_TYPE = ERR_INVALID_PASSWORD_TYPE;
|
|
11323
11639
|
exports.ERR_INVALID_PASS_THROUGH = ERR_INVALID_PASS_THROUGH;
|
|
11324
11640
|
exports.ERR_INVALID_PASS_THROUGH_VALUE = ERR_INVALID_PASS_THROUGH_VALUE;
|
|
11325
11641
|
exports.ERR_INVALID_READER = ERR_INVALID_READER;
|
|
11326
11642
|
exports.ERR_INVALID_READER_OPTIONS = ERR_INVALID_READER_OPTIONS;
|
|
11643
|
+
exports.ERR_INVALID_REQUEST_PASSWORD = ERR_INVALID_REQUEST_PASSWORD;
|
|
11327
11644
|
exports.ERR_INVALID_SIGNAL = ERR_INVALID_SIGNAL;
|
|
11328
11645
|
exports.ERR_INVALID_SIGNATURE_DATA = ERR_INVALID_SIGNATURE_DATA;
|
|
11329
11646
|
exports.ERR_INVALID_STRICTNESS = ERR_INVALID_STRICTNESS;
|