@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
|
@@ -1 +1 @@
|
|
|
1
|
-
const t=new Uint8Array(288);t.fill(8,0,144),t.fill(9,144,256),t.fill(7,256,280),t.fill(8,280,288),new Uint8Array(30).fill(5);const n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e=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[r>>18&63]+n[r>>12&63]+n[r>>6&63]+n[63&r]}const o=r-s;if(1===o){const r=t[s]<<16;e+=n[r>>18&63]+n[r>>12&63]+"=="}else if(2===o){const r=t[s]<<16|t[s+1]<<8;e+=n[r>>18&63]+n[r>>12&63]+n[r>>6&63]+"="}return e}(r)}});export{e as configureWebWorker};
|
|
1
|
+
const t=new Uint8Array(288);t.fill(8,0,144),t.fill(9,144,256),t.fill(7,256,280),t.fill(8,280,288),new Uint8Array(30).fill(5);const n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e=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[r>>18&63]+n[r>>12&63]+n[r>>6&63]+n[63&r]}const s=r-o;if(1===s){const r=t[o]<<16;e+=n[r>>18&63]+n[r>>12&63]+"=="}else if(2===s){const r=t[o]<<16|t[o+1]<<8;e+=n[r>>18&63]+n[r>>12&63]+n[r>>6&63]+"="}return e}(r)}});export{e as configureWebWorker};
|
package/lib/core/zip-fs.js
CHANGED
|
@@ -46,7 +46,8 @@ import {
|
|
|
46
46
|
} from "./io.js";
|
|
47
47
|
import {
|
|
48
48
|
ZipReader,
|
|
49
|
-
ERR_INVALID_PASSWORD
|
|
49
|
+
ERR_INVALID_PASSWORD,
|
|
50
|
+
ERR_ENCRYPTED
|
|
50
51
|
} from "./zip-reader.js";
|
|
51
52
|
import {
|
|
52
53
|
ZipWriter,
|
|
@@ -61,7 +62,8 @@ import { ProgressWatcherStream, callHandler } from "./codec-worker.js";
|
|
|
61
62
|
import {
|
|
62
63
|
UNDEFINED_VALUE,
|
|
63
64
|
FUNCTION_TYPE,
|
|
64
|
-
OBJECT_TYPE
|
|
65
|
+
OBJECT_TYPE,
|
|
66
|
+
STRING_TYPE
|
|
65
67
|
} from "./constants.js";
|
|
66
68
|
import { toExactUint8Array } from "./util/array.js";
|
|
67
69
|
import { toCompatibleReadable, toCompatibleWritable } from "./util/compatible-streams.js";
|
|
@@ -82,7 +84,11 @@ const DUPLICATES_VALUES = new Set([DUPLICATES_THROW, DUPLICATES_KEEP_FIRST, DUPL
|
|
|
82
84
|
const ERR_INVALID_PASS_THROUGH = "Invalid passThrough option (use readerOptions.passThrough or set uncompressedSize for each entry)";
|
|
83
85
|
const ERR_INVALID_READER_OPTIONS = "Invalid readerOptions (must be an object)";
|
|
84
86
|
const ERR_UNSUPPORTED_PASS_THROUGH_VALUE = "The 'compressed' passThrough option is only supported by Entry#getData() and ZipWriter#add()";
|
|
87
|
+
const ERR_INVALID_PASSWORDS = "Invalid passwords option (must be an array of strings)";
|
|
88
|
+
const ERR_INVALID_REQUEST_PASSWORD = "Invalid requestPassword option (must be a function returning a string or undefined)";
|
|
85
89
|
const ERR_ABORT_EXPORT = "zipjs-abort-export";
|
|
90
|
+
const ABORT_ERROR_NAME = "AbortError";
|
|
91
|
+
const EMPTY_RAW_PASSWORD = new Uint8Array(0);
|
|
86
92
|
|
|
87
93
|
class ZipEntry {
|
|
88
94
|
|
|
@@ -455,8 +461,10 @@ class ZipDirectoryEntry extends ZipEntry {
|
|
|
455
461
|
zipReader = new ZipReader(reader, options);
|
|
456
462
|
}
|
|
457
463
|
checkPassThroughValue(options.passThrough);
|
|
464
|
+
checkPasswordCandidatesOptions(options);
|
|
458
465
|
const duplicates = checkDuplicatesOption(options.duplicates);
|
|
459
466
|
const importedEntries = [];
|
|
467
|
+
const passwordState = { known: [] };
|
|
460
468
|
const entries = await zipReader.getEntries(options);
|
|
461
469
|
for (const entry of entries) {
|
|
462
470
|
let parent = this;
|
|
@@ -501,7 +509,7 @@ class ZipDirectoryEntry extends ZipEntry {
|
|
|
501
509
|
}
|
|
502
510
|
importedEntries.push(addChild(parent, name, {
|
|
503
511
|
data: entry,
|
|
504
|
-
Reader: getZipBlobReader(Object.assign({}, options)),
|
|
512
|
+
Reader: getZipBlobReader(Object.assign({}, options), passwordState),
|
|
505
513
|
uncompressedSize: options.passThrough ? entry.compressedSize : entry.uncompressedSize,
|
|
506
514
|
passThrough: options.passThrough
|
|
507
515
|
}));
|
|
@@ -796,7 +804,7 @@ class ZipFS {
|
|
|
796
804
|
}
|
|
797
805
|
|
|
798
806
|
const fs = { FS: ZipFS, ZipDirectoryEntry, ZipFileEntry };
|
|
799
|
-
export { ZipFS, ZipEntry, ZipFileEntry, ZipDirectoryEntry, fs, ERR_ENTRY_EXISTS, ERR_DUPLICATE_IMPORTED_ENTRY, ERR_INVALID_DUPLICATES, ERR_READABLE_CONSUMED, ERR_INVALID_PASS_THROUGH, ERR_UNSUPPORTED_PASS_THROUGH_VALUE, ERR_INVALID_READER_OPTIONS, ERR_ANCESTOR_ENTRY, ERR_ROOT_DIRECTORY_NOT_MOVABLE, ERR_TARGET_NOT_DIRECTORY, ERR_PARENT_NOT_DIRECTORY };
|
|
807
|
+
export { ZipFS, ZipEntry, ZipFileEntry, ZipDirectoryEntry, fs, ERR_ENTRY_EXISTS, ERR_DUPLICATE_IMPORTED_ENTRY, ERR_INVALID_DUPLICATES, ERR_READABLE_CONSUMED, ERR_INVALID_PASS_THROUGH, ERR_UNSUPPORTED_PASS_THROUGH_VALUE, ERR_INVALID_READER_OPTIONS, ERR_INVALID_PASSWORDS, ERR_INVALID_REQUEST_PASSWORD, ERR_ANCESTOR_ENTRY, ERR_ROOT_DIRECTORY_NOT_MOVABLE, ERR_TARGET_NOT_DIRECTORY, ERR_PARENT_NOT_DIRECTORY };
|
|
800
808
|
|
|
801
809
|
function getTotalSize(entries, getEntrySize) {
|
|
802
810
|
let size = 0;
|
|
@@ -831,7 +839,7 @@ function getReadableReader(readable) {
|
|
|
831
839
|
};
|
|
832
840
|
}
|
|
833
841
|
|
|
834
|
-
function getZipBlobReader(options) {
|
|
842
|
+
function getZipBlobReader(options, passwordState) {
|
|
835
843
|
return class extends Reader {
|
|
836
844
|
|
|
837
845
|
constructor(entry, options = {}) {
|
|
@@ -844,12 +852,12 @@ function getZipBlobReader(options) {
|
|
|
844
852
|
const zipBlobReader = this;
|
|
845
853
|
const readerOptions = Object.assign({}, options, zipBlobReader.options);
|
|
846
854
|
const { checkOverlappingEntry, checkOverlappingEntryOnly } = readerOptions;
|
|
847
|
-
const data = await zipBlobReader.entry
|
|
855
|
+
const data = await readEntryData(zipBlobReader.entry, Object.assign(readerOptions, {
|
|
848
856
|
checkPasswordOnly: false,
|
|
849
857
|
checkOverlappingEntry: checkOverlappingEntryOnly || checkOverlappingEntry,
|
|
850
858
|
checkOverlappingEntryOnly: false,
|
|
851
859
|
preventClose: false
|
|
852
|
-
}));
|
|
860
|
+
}), passwordState);
|
|
853
861
|
zipBlobReader.data = data;
|
|
854
862
|
zipBlobReader.blobReader = new BlobReader(data);
|
|
855
863
|
zipBlobReader.size = data.size;
|
|
@@ -911,10 +919,9 @@ async function initReaders(entry, options) {
|
|
|
911
919
|
await initStream(reader);
|
|
912
920
|
} catch (error) {
|
|
913
921
|
try {
|
|
922
|
+
error.entry = child;
|
|
914
923
|
error.entryId = child.id;
|
|
915
|
-
error.
|
|
916
|
-
entry: child
|
|
917
|
-
};
|
|
924
|
+
error.entryName = child.getRelativeName(entry);
|
|
918
925
|
} catch {
|
|
919
926
|
// ignored
|
|
920
927
|
}
|
|
@@ -1006,10 +1013,136 @@ function checkReaderOptions(readerOptions) {
|
|
|
1006
1013
|
}
|
|
1007
1014
|
if (readerOptions) {
|
|
1008
1015
|
checkPassThroughValue(readerOptions.passThrough);
|
|
1016
|
+
checkPasswordCandidatesOptions(readerOptions);
|
|
1009
1017
|
}
|
|
1010
1018
|
return readerOptions;
|
|
1011
1019
|
}
|
|
1012
1020
|
|
|
1021
|
+
function checkPasswordCandidatesOptions(options) {
|
|
1022
|
+
const { passwords, requestPassword } = options;
|
|
1023
|
+
if (passwords && (!Array.isArray(passwords) || passwords.some(password => typeof password != STRING_TYPE))) {
|
|
1024
|
+
throw new Error(ERR_INVALID_PASSWORDS);
|
|
1025
|
+
}
|
|
1026
|
+
if (requestPassword && typeof requestPassword != FUNCTION_TYPE) {
|
|
1027
|
+
throw new Error(ERR_INVALID_REQUEST_PASSWORD);
|
|
1028
|
+
}
|
|
1029
|
+
}
|
|
1030
|
+
|
|
1031
|
+
async function readEntryData(entry, options, passwordState) {
|
|
1032
|
+
checkPasswordCandidatesOptions(options);
|
|
1033
|
+
const { passwords, requestPassword, signal } = options;
|
|
1034
|
+
options = Object.assign({}, options);
|
|
1035
|
+
delete options.passwords;
|
|
1036
|
+
delete options.requestPassword;
|
|
1037
|
+
if (!entry.encrypted || options.passThrough || (!passwords && !requestPassword)) {
|
|
1038
|
+
return entry.getData(new BlobWriter(), options);
|
|
1039
|
+
}
|
|
1040
|
+
const tried = new Set();
|
|
1041
|
+
let error;
|
|
1042
|
+
while (true) {
|
|
1043
|
+
for (const candidate of getPasswordCandidates(options, passwordState, passwords)) {
|
|
1044
|
+
if (!tried.has(candidate.key)) {
|
|
1045
|
+
const result = await tryPasswordCandidate(candidate);
|
|
1046
|
+
if (result.done) {
|
|
1047
|
+
return result.data;
|
|
1048
|
+
}
|
|
1049
|
+
error = result.error;
|
|
1050
|
+
}
|
|
1051
|
+
}
|
|
1052
|
+
if (!requestPassword) {
|
|
1053
|
+
break;
|
|
1054
|
+
}
|
|
1055
|
+
if (passwordState.pendingPrompt) {
|
|
1056
|
+
await passwordState.pendingPrompt;
|
|
1057
|
+
continue;
|
|
1058
|
+
}
|
|
1059
|
+
let release;
|
|
1060
|
+
passwordState.pendingPrompt = new Promise(resolve => release = resolve);
|
|
1061
|
+
try {
|
|
1062
|
+
const answer = await requestPassword(entry, error);
|
|
1063
|
+
if (answer === UNDEFINED_VALUE || answer === null) {
|
|
1064
|
+
break;
|
|
1065
|
+
}
|
|
1066
|
+
// deno-lint-ignore valid-typeof
|
|
1067
|
+
if (typeof answer != STRING_TYPE) {
|
|
1068
|
+
throw new Error(ERR_INVALID_REQUEST_PASSWORD);
|
|
1069
|
+
}
|
|
1070
|
+
const result = await tryPasswordCandidate(getPasswordCandidate(answer));
|
|
1071
|
+
if (result.done) {
|
|
1072
|
+
return result.data;
|
|
1073
|
+
}
|
|
1074
|
+
error = result.error;
|
|
1075
|
+
} finally {
|
|
1076
|
+
passwordState.pendingPrompt = UNDEFINED_VALUE;
|
|
1077
|
+
release();
|
|
1078
|
+
}
|
|
1079
|
+
}
|
|
1080
|
+
throw new Error(tried.size ? ERR_INVALID_PASSWORD : ERR_ENCRYPTED);
|
|
1081
|
+
|
|
1082
|
+
async function tryPasswordCandidate(candidate) {
|
|
1083
|
+
tried.add(candidate.key);
|
|
1084
|
+
const candidateOptions = Object.assign({}, options, candidate.options);
|
|
1085
|
+
if (entry.zipCrypto) {
|
|
1086
|
+
candidateOptions.checkCrc32 = true;
|
|
1087
|
+
try {
|
|
1088
|
+
await entry.getData(null, Object.assign({}, candidateOptions, { checkPasswordOnly: true }));
|
|
1089
|
+
} catch (probeError) {
|
|
1090
|
+
if (isInvalidPasswordError(probeError)) {
|
|
1091
|
+
return { done: false, error: probeError };
|
|
1092
|
+
}
|
|
1093
|
+
throw probeError;
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
try {
|
|
1097
|
+
const data = await entry.getData(new BlobWriter(), candidateOptions);
|
|
1098
|
+
rememberPassword(passwordState, candidate);
|
|
1099
|
+
return { done: true, data };
|
|
1100
|
+
} catch (readError) {
|
|
1101
|
+
if (isAbortError(readError, signal) || (!entry.zipCrypto && !isInvalidPasswordError(readError))) {
|
|
1102
|
+
throw readError;
|
|
1103
|
+
}
|
|
1104
|
+
return { done: false, error: readError };
|
|
1105
|
+
}
|
|
1106
|
+
}
|
|
1107
|
+
}
|
|
1108
|
+
|
|
1109
|
+
function isInvalidPasswordError(error) {
|
|
1110
|
+
return isErrorObject(error) && error.message == ERR_INVALID_PASSWORD;
|
|
1111
|
+
}
|
|
1112
|
+
|
|
1113
|
+
function isAbortError(error, signal) {
|
|
1114
|
+
return Boolean(signal && signal.aborted) || (isErrorObject(error) && error.name == ABORT_ERROR_NAME);
|
|
1115
|
+
}
|
|
1116
|
+
|
|
1117
|
+
function getPasswordCandidates(options, passwordState, passwords) {
|
|
1118
|
+
const candidates = [];
|
|
1119
|
+
const { password, rawPassword } = options;
|
|
1120
|
+
if (rawPassword && rawPassword.length) {
|
|
1121
|
+
candidates.push({ key: rawPassword, options: { password: "", rawPassword } });
|
|
1122
|
+
}
|
|
1123
|
+
if (password) {
|
|
1124
|
+
candidates.push(getPasswordCandidate(password));
|
|
1125
|
+
}
|
|
1126
|
+
candidates.push(...passwordState.known);
|
|
1127
|
+
if (passwords) {
|
|
1128
|
+
candidates.push(...passwords.filter(password => password).map(getPasswordCandidate));
|
|
1129
|
+
}
|
|
1130
|
+
return candidates;
|
|
1131
|
+
}
|
|
1132
|
+
|
|
1133
|
+
function getPasswordCandidate(password) {
|
|
1134
|
+
return { key: password, options: { password, rawPassword: EMPTY_RAW_PASSWORD } };
|
|
1135
|
+
}
|
|
1136
|
+
|
|
1137
|
+
function rememberPassword(passwordState, candidate) {
|
|
1138
|
+
const { known } = passwordState;
|
|
1139
|
+
const index = known.findIndex(knownCandidate => knownCandidate.key === candidate.key);
|
|
1140
|
+
if (index != -1) {
|
|
1141
|
+
known.splice(index, 1);
|
|
1142
|
+
}
|
|
1143
|
+
known.unshift(candidate);
|
|
1144
|
+
}
|
|
1145
|
+
|
|
1013
1146
|
function checkPassThroughValue(passThrough) {
|
|
1014
1147
|
if (checkPassThroughOption(passThrough) === PASS_THROUGH_COMPRESSED) {
|
|
1015
1148
|
throw new Error(ERR_UNSUPPORTED_PASS_THROUGH_VALUE);
|
|
@@ -1147,6 +1280,7 @@ function addFileSystemHandle(zipEntry, handle, options) {
|
|
|
1147
1280
|
async function exportFileSystemHandle(zipEntry, directoryHandle, options) {
|
|
1148
1281
|
const { onstart, onprogress, onend } = options;
|
|
1149
1282
|
checkPassThroughValue(options.passThrough);
|
|
1283
|
+
checkPasswordCandidatesOptions(options);
|
|
1150
1284
|
const readerOptions = checkReaderOptions(options.readerOptions);
|
|
1151
1285
|
const abortController = new AbortController();
|
|
1152
1286
|
const { signal } = abortController;
|
package/lib/core/zip-reader.js
CHANGED
|
@@ -874,8 +874,8 @@ class ZipEntry {
|
|
|
874
874
|
const passThroughCompression = Boolean(passThrough);
|
|
875
875
|
const passThroughEncryption = passThrough === true;
|
|
876
876
|
checkPasswordOption(password, rawPassword);
|
|
877
|
-
password = password && password.length
|
|
878
|
-
rawPassword = rawPassword && rawPassword.length
|
|
877
|
+
password = password && password.length ? password : UNDEFINED_VALUE;
|
|
878
|
+
rawPassword = rawPassword && rawPassword.length ? rawPassword : UNDEFINED_VALUE;
|
|
879
879
|
if (extraFieldAES) {
|
|
880
880
|
if (extraFieldAES.originalCompressionMethod != COMPRESSION_METHOD_AES) {
|
|
881
881
|
throw new Error(ERR_UNSUPPORTED_COMPRESSION);
|
|
@@ -1636,7 +1636,7 @@ function getMaxAppendedDataSize(maxAppendedDataSize, strictness) {
|
|
|
1636
1636
|
async function findEndOfCentralDirectory(reader, rejectAmbiguous, maxAppendedDataSize) {
|
|
1637
1637
|
const { size } = reader;
|
|
1638
1638
|
const anchoredLength = Math.min(size, END_OF_CENTRAL_DIR_LENGTH + MAX_16_BITS);
|
|
1639
|
-
const remoteProbeBudget = {
|
|
1639
|
+
const remoteProbeBudget = { remaining: MAX_END_OF_CENTRAL_DIR_PROBES };
|
|
1640
1640
|
let endOfDirectoryInfo;
|
|
1641
1641
|
let plausibleEndOfDirectoryInfo;
|
|
1642
1642
|
let endOfDirectoryReachingEndCount = 0;
|
|
@@ -1729,8 +1729,8 @@ async function readSignature(reader, view, anchoredOffset, signatureOffset, size
|
|
|
1729
1729
|
if (signatureOffset >= anchoredOffset) {
|
|
1730
1730
|
return getUint32(view, signatureOffset - anchoredOffset);
|
|
1731
1731
|
}
|
|
1732
|
-
if (remoteProbeBudget.
|
|
1733
|
-
remoteProbeBudget.
|
|
1732
|
+
if (remoteProbeBudget.remaining > 0) {
|
|
1733
|
+
remoteProbeBudget.remaining--;
|
|
1734
1734
|
const signatureArray = await readUint8Array(reader, signatureOffset, 4);
|
|
1735
1735
|
return getUint32(getDataView(signatureArray), 0);
|
|
1736
1736
|
}
|
package/lib/core/zip-writer.js
CHANGED
|
@@ -1052,9 +1052,11 @@ function resolveMetadata(zipWriter, name, options) {
|
|
|
1052
1052
|
const passThrough = checkPassThroughOption(getOptionValue(zipWriter, options, OPTION_PASS_THROUGH));
|
|
1053
1053
|
const passThroughCompression = Boolean(passThrough);
|
|
1054
1054
|
const passThroughEncryption = passThrough === true;
|
|
1055
|
-
|
|
1056
|
-
|
|
1055
|
+
let password = getOptionValue(zipWriter, options, OPTION_PASSWORD);
|
|
1056
|
+
let rawPassword = getOptionValue(zipWriter, options, OPTION_RAW_PASSWORD);
|
|
1057
1057
|
checkPasswordOption(password, rawPassword);
|
|
1058
|
+
password = password && password.length ? password : UNDEFINED_VALUE;
|
|
1059
|
+
rawPassword = rawPassword && rawPassword.length ? rawPassword : UNDEFINED_VALUE;
|
|
1058
1060
|
const encryptionStrength = getNumberOptionValue(zipWriter, options, OPTION_ENCRYPTION_STRENGTH, 3);
|
|
1059
1061
|
const zipCrypto = getOptionValue(zipWriter, options, PROPERTY_NAME_ZIPCRYPTO);
|
|
1060
1062
|
const extendedTimestamp = getOptionValue(zipWriter, options, OPTION_EXTENDED_TIMESTAMP, true);
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "A JavaScript library to zip and unzip files in the browser, Deno and Node.js",
|
|
4
4
|
"author": "Gildas Lormeau",
|
|
5
5
|
"license": "BSD-3-Clause",
|
|
6
|
-
"version": "2.
|
|
6
|
+
"version": "2.16.1",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"keywords": [
|
|
9
9
|
"zip",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"release": "sh ./release.sh",
|
|
43
43
|
"lint": "npx eslint . && deno lint",
|
|
44
44
|
"test": "npm run test-ci && npm run test-bun && npm run test-bun-dist",
|
|
45
|
-
"test-ci": "npm run test-registration && npm run test-node && npm run test-deno && npm run test-node-dist && npm run test-deno-dist && npm run test-web-streams-polyfill && npm run test-fidelity && npm run test-types && npm run test-api-symmetry && npm run test-api-shape && npm run test-api-mangling && npm run test-api-exports",
|
|
45
|
+
"test-ci": "npm run test-registration && npm run test-node && npm run test-deno && npm run test-node-dist && npm run test-deno-dist && npm run test-web-streams-polyfill && npm run test-deno-polyfill && npm run test-fidelity && npm run test-types && npm run test-api-symmetry && npm run test-api-shape && npm run test-api-mangling && npm run test-api-exports",
|
|
46
46
|
"test-browsers": "npm run test-chrome && npm run test-firefox && npm run test-safari",
|
|
47
47
|
"serve-tests": "http-server -p 8888 -c-1 .",
|
|
48
48
|
"test-all": "npm run lint && npm run test && npm run test-browsers",
|
|
@@ -52,6 +52,7 @@
|
|
|
52
52
|
"build-doc-markdown": "npx typedoc --plugin typedoc-plugin-markdown --disableSources --out ./docs",
|
|
53
53
|
"test-deno": "cd ./tests && deno test --allow-read ./deno-runner.js",
|
|
54
54
|
"test-web-streams-polyfill": "cd ./tests && deno run --allow-read ./web-streams-polyfill-runner.js",
|
|
55
|
+
"test-deno-polyfill": "cd ./tests && deno test --allow-read ./deno-polyfill-runner.js",
|
|
55
56
|
"test-node": "cd ./tests && node ./node-runner.js",
|
|
56
57
|
"test-bun": "cd ./tests && bun test ./bun-runner.js",
|
|
57
58
|
"test-deno-dist": "./tests/dist-runner.sh deno",
|