@zip.js/zip.js 2.16.0 → 2.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/deno.json +1 -1
- package/dist/zip-core-external.js +429 -274
- package/dist/zip-core-external.min.js +1 -1
- package/dist/zip-core.js +230 -151
- package/dist/zip-core.min.js +1 -1
- package/dist/zip-fs-core-external.js +580 -283
- package/dist/zip-fs-core-external.min.js +1 -1
- package/dist/zip-fs-core.js +383 -160
- package/dist/zip-fs-core.min.js +1 -1
- package/dist/zip-fs-external.js +580 -283
- package/dist/zip-fs-external.min.js +1 -1
- package/dist/zip-fs-native.js +386 -163
- package/dist/zip-fs-native.min.js +1 -1
- package/dist/zip-fs.js +583 -283
- package/dist/zip-fs.min.js +1 -1
- package/dist/zip-legacy.js +232 -153
- package/dist/zip-legacy.min.js +1 -1
- package/dist/zip-native.js +233 -154
- 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 +430 -274
- package/dist/zip.min.js +1 -1
- package/eslint.config.mjs +1 -1
- package/index-native.cjs +386 -163
- package/index-native.min.js +1 -1
- package/index.cjs +583 -283
- package/index.d.cts +168 -29
- package/index.d.ts +168 -29
- package/index.min.js +1 -1
- package/lib/core/codec-pool.js +2 -0
- package/lib/core/codec-worker-web.js +11 -3
- package/lib/core/codec-worker.js +2 -1
- package/lib/core/streams/aes-crypto-stream.js +60 -17
- package/lib/core/streams/codec-stream.js +2 -0
- package/lib/core/streams/zip-crypto-stream.js +7 -7
- package/lib/core/streams/zip-entry-stream.js +130 -113
- package/lib/core/streams/zlib-js/zlib-streams.min.js +1 -1
- package/lib/core/streams/zlib-wasm/zlib-streams.js +199 -122
- package/lib/core/util/compatible-streams.js +10 -5
- package/lib/core/version.js +1 -1
- package/lib/core/web-worker-base.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 +157 -10
- package/lib/core/zip-reader.js +8 -5
- package/lib/core/zip-writer.js +5 -2
- package/lib/zip-core-reader.js +1 -0
- package/package.json +3 -2
package/dist/zip.js
CHANGED
|
@@ -445,7 +445,7 @@
|
|
|
445
445
|
Object.assign(config, DEFAULT_CONFIGURATION);
|
|
446
446
|
}
|
|
447
447
|
|
|
448
|
-
const t$1=new Uint8Array(288);t$1.fill(8,0,144),t$1.fill(9,144,256),t$1.fill(7,256,280),t$1.fill(8,280,288),new Uint8Array(30).fill(5);const n$1="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e$1=t=>t({workerURI:t=>{const e="text/javascript";let s='!function(t){"function"==typeof define&&define.amd?define(t):t()}(function(){"use strict";const{Array:t,Object:n,Number:e,Math:o,Error:s,Uint8Array:r,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,k="undefined",z="function",b=new r,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,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 s=new u(t.buffer,t.byteOffset,e),r=e-8;for(;o<=r;o+=8){const t=n^s.getInt32(o,!0),e=s.getInt32(o+4,!0);n=E[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 U extends d{constructor(){let t;const n=new R;super({transform(t,e){n.append(t),e.enqueue(t)},flush(){const e=new r(4);new u(e.buffer).setUint32(0,n.get()),t.value=e}}),t=this}}function B(t,n){const e=new r(t.length+n.length);return e.set(t),e.set(n,t.length),e}function V(t){return new u(t.buffer,t.byteOffset,t.byteLength)}const W=64,j=20,K=new r([128]),O=new r(1),T=new a([1732584193,4023233417,2562383102,271733878,3285377520]),H=new r(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,s=4*(o+1);let r=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<s;t++){let o=n[t-1];t%e==0?(o=Y(o<<8|o>>>24)^r<<24,r=$(r)):e>6&&t%e==4&&(o=Y(o)),n[t]=n[t-e]^o}return o}(t,e),s=new a(4),r=X(n);let c=0,i=0,f=0,w=0;return{process(t,n){n&&r.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)^s[0]),n.setInt32(o+4,n.getInt32(o+4)^s[1]),n.setInt32(o+8,n.getInt32(o+8)^s[2]),n.setInt32(o+12,n.getInt32(o+12)^s[3]);if(o<e){l();for(let n=0;o<e;o++,n++)t[o]^=s[n>>2]>>>24-8*(3&n)}}(t),n||r.update(t,0,t.length)},digest:()=>r.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],r=Z(f)^e[2],a=Z(w)^e[3],u=L[t>>>24]^N[n>>>16&255]^q[r>>>8&255]^G[255&a]^e[4],l=L[n>>>24]^N[r>>>16&255]^q[a>>>8&255]^G[255&t]^e[5],h=L[r>>>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&r]^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],r=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[r>>>8&255]^G[255&a]^e[12],l=L[n>>>24]^N[r>>>16&255]^q[a>>>8&255]^G[255&t]^e[13],h=L[r>>>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&r]^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],r=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[r>>>8&255]^G[255&a]^e[20],l=L[n>>>24]^N[r>>>16&255]^q[a>>>8&255]^G[255&t]^e[21],h=L[r>>>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&r]^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],r=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[r>>>8&255]^G[255&a]^e[28],l=L[n>>>24]^N[r>>>16&255]^q[a>>>8&255]^G[255&t]^e[29],h=L[r>>>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&r]^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],r=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[r>>>8&255]^G[255&a]^e[36],l=L[n>>>24]^N[r>>>16&255]^q[a>>>8&255]^G[255&t]^e[37],h=L[r>>>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&r]^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],r=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[r>>>8&255]^G[255&a]^e[44],l=L[n>>>24]^N[r>>>16&255]^q[a>>>8&255]^G[255&t]^e[45],h=L[r>>>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&r]^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],r=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[r>>>8&255]^G[255&a]^e[52],l=L[n>>>24]^N[r>>>16&255]^q[a>>>8&255]^G[255&t]^e[53],h=L[r>>>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&r]^e[55],d=56),s[0]=(H[u>>>24]<<24|H[l>>>16&255]<<16|H[h>>>8&255]<<8|H[255&p])^e[d],s[1]=(H[l>>>24]<<24|H[h>>>16&255]<<16|H[p>>>8&255]<<8|H[255&u])^e[d+1],s[2]=(H[h>>>24]<<24|H[p>>>16&255]<<16|H[u>>>8&255]<<8|H[255&l])^e[d+2],s[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(T),n=new a(16),e=new r(W),s=new u(e.buffer),c=new r(8);let i=0,f=0;return{update:w,digest:function(){const n=8*f,e=o.floor(n/4294967296),s=n>>>0;for(w(K,0,1);56!=i;)w(O,0,1);c[0]=e>>>24,c[1]=e>>>16,c[2]=e>>>8,c[3]=e,c[4]=s>>>24,c[5]=s>>>16,c[6]=s>>>8,c[7]=s,w(c,0,8);const a=new r(j),l=new u(a.buffer);for(let n=0;n<t.length;n++)l.setInt32(4*n,t[n]);return t.set(T),i=0,f=0,a}};function w(t,n,o){const r=n+o;if(f+=o,i){for(;n<r&&i<W;)e[i++]=t[n++];i==W&&(l(s,0),i=0)}if(n+W<=r){const e=new u(t.buffer,t.byteOffset,t.byteLength);for(;n+W<=r;n+=W)l(e,n)}for(;n<r;)e[i++]=t[n++]}function l(e,o){for(let t=0;t<16;t++)n[t]=e.getInt32(o+4*t);let s,r=t[0],c=t[1],i=t[2],a=t[3],f=t[4];for(let t=0;t<15;t+=5)f=(r<<5|r>>>27)+((i^a)&c^a)+f+1518500249+n[t]|0,c=c<<30|c>>>2,a=(f<<5|f>>>27)+((c^i)&r^i)+a+1518500249+n[t+1]|0,r=r<<30|r>>>2,i=(a<<5|a>>>27)+((r^c)&f^c)+i+1518500249+n[t+2]|0,f=f<<30|f>>>2,c=(i<<5|i>>>27)+((f^r)&a^r)+c+1518500249+n[t+3]|0,a=a<<30|a>>>2,r=(c<<5|c>>>27)+((a^f)&i^f)+r+1518500249+n[t+4]|0,i=i<<30|i>>>2;f=(r<<5|r>>>27)+((i^a)&c^a)+f+1518500249+n[15]|0,c=c<<30|c>>>2,s=n[13]^n[8]^n[2]^n[0],s=s<<1|s>>>31,n[0]=s,a=(f<<5|f>>>27)+((c^i)&r^i)+a+1518500249+s|0,r=r<<30|r>>>2,s=n[14]^n[9]^n[3]^n[1],s=s<<1|s>>>31,n[1]=s,i=(a<<5|a>>>27)+((r^c)&f^c)+i+1518500249+s|0,f=f<<30|f>>>2,s=n[15]^n[10]^n[4]^n[2],s=s<<1|s>>>31,n[2]=s,c=(i<<5|i>>>27)+((f^r)&a^r)+c+1518500249+s|0,a=a<<30|a>>>2,s=n[0]^n[11]^n[5]^n[3],s=s<<1|s>>>31,n[3]=s,r=(c<<5|c>>>27)+((a^f)&i^f)+r+1518500249+s|0,i=i<<30|i>>>2;for(let t=20;t<40;t+=5)s=n[t-3&15]^n[t-8&15]^n[t-14&15]^n[15&t],s=s<<1|s>>>31,n[15&t]=s,f=(r<<5|r>>>27)+(c^i^a)+f+1859775393+s|0,c=c<<30|c>>>2,s=n[t-2&15]^n[t-7&15]^n[t-13&15]^n[t+1&15],s=s<<1|s>>>31,n[t+1&15]=s,a=(f<<5|f>>>27)+(r^c^i)+a+1859775393+s|0,r=r<<30|r>>>2,s=n[t-1&15]^n[t-6&15]^n[t-12&15]^n[t+2&15],s=s<<1|s>>>31,n[t+2&15]=s,i=(a<<5|a>>>27)+(f^r^c)+i+1859775393+s|0,f=f<<30|f>>>2,s=n[15&t]^n[t-5&15]^n[t-11&15]^n[t+3&15],s=s<<1|s>>>31,n[t+3&15]=s,c=(i<<5|i>>>27)+(a^f^r)+c+1859775393+s|0,a=a<<30|a>>>2,s=n[t+1&15]^n[t-4&15]^n[t-10&15]^n[t+4&15],s=s<<1|s>>>31,n[t+4&15]=s,r=(c<<5|c>>>27)+(i^a^f)+r+1859775393+s|0,i=i<<30|i>>>2;for(let t=40;t<60;t+=5)s=n[t-3&15]^n[t-8&15]^n[t-14&15]^n[15&t],s=s<<1|s>>>31,n[15&t]=s,f=(r<<5|r>>>27)+(c&i|(c|i)&a)+f+2400959708+s|0,c=c<<30|c>>>2,s=n[t-2&15]^n[t-7&15]^n[t-13&15]^n[t+1&15],s=s<<1|s>>>31,n[t+1&15]=s,a=(f<<5|f>>>27)+(r&c|(r|c)&i)+a+2400959708+s|0,r=r<<30|r>>>2,s=n[t-1&15]^n[t-6&15]^n[t-12&15]^n[t+2&15],s=s<<1|s>>>31,n[t+2&15]=s,i=(a<<5|a>>>27)+(f&r|(f|r)&c)+i+2400959708+s|0,f=f<<30|f>>>2,s=n[15&t]^n[t-5&15]^n[t-11&15]^n[t+3&15],s=s<<1|s>>>31,n[t+3&15]=s,c=(i<<5|i>>>27)+(a&f|(a|f)&r)+c+2400959708+s|0,a=a<<30|a>>>2,s=n[t+1&15]^n[t-4&15]^n[t-10&15]^n[t+4&15],s=s<<1|s>>>31,n[t+4&15]=s,r=(c<<5|c>>>27)+(i&a|(i|a)&f)+r+2400959708+s|0,i=i<<30|i>>>2;for(let t=60;t<80;t+=5)s=n[t-3&15]^n[t-8&15]^n[t-14&15]^n[15&t],s=s<<1|s>>>31,n[15&t]=s,f=(r<<5|r>>>27)+(c^i^a)+f+3395469782+s|0,c=c<<30|c>>>2,s=n[t-2&15]^n[t-7&15]^n[t-13&15]^n[t+1&15],s=s<<1|s>>>31,n[t+1&15]=s,a=(f<<5|f>>>27)+(r^c^i)+a+3395469782+s|0,r=r<<30|r>>>2,s=n[t-1&15]^n[t-6&15]^n[t-12&15]^n[t+2&15],s=s<<1|s>>>31,n[t+2&15]=s,i=(a<<5|a>>>27)+(f^r^c)+i+3395469782+s|0,f=f<<30|f>>>2,s=n[15&t]^n[t-5&15]^n[t-11&15]^n[t+3&15],s=s<<1|s>>>31,n[t+3&15]=s,c=(i<<5|i>>>27)+(a^f^r)+c+3395469782+s|0,a=a<<30|a>>>2,s=n[t+1&15]^n[t-4&15]^n[t-10&15]^n[t+4&15],s=s<<1|s>>>31,n[t+4&15]=s,r=(c<<5|c>>>27)+(i^a^f)+r+3395469782+s|0,i=i<<30|i>>>2;t[0]=t[0]+r|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 r(W),s=new r(W);t.length>W&&(n.update(t,0,t.length),t=n.digest());for(let n=0;n<W;n++){const o=n<t.length?t[n]:0;e[n]=54^o,s[n]=92^o}return n.update(e,0,W),{update(t,e,o){n.update(t,e,o)},digest(){const t=n.digest();n.update(s,0,W),n.update(t,0,j);const o=n.digest();return n.update(e,0,W),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!=k&&typeof h.getRandomValues==z,tt="Invalid password",nt="zipjs-abort-check-password";function et(t){if(_)return h.getRandomValues(t);throw new s("Crypto API not supported")}const ot={name:"PBKDF2"},st=n.assign({hash:{name:"HMAC"}},ot),rt=n.assign({iterations:1e3,hash:{name:"SHA-1"}},ot),ct=["deriveBits"],it=[8,12,16],at=[16,24,32],ft=10,ut=typeof h!=k,wt=ut&&h.subtle;let lt=ut&&typeof wt!=k&&typeof wt.importKey==z&&typeof wt.deriveBits==z,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 r=await gt(t,n,e,kt(o,0,it[n])),c=kt(o,it[n]);if(r[0]!=c[0]||r[1]!=c[1])throw St(t),new s(tt)}(e,i,c,kt(t,0,it[i]+2)),t=kt(t,it[i]+2),o?(St(e),n.error(new s(nt))):a()):await f;const u=new r(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=kt(e,e.length-ft),a=new r(kt(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 s("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:s,l:c,ready:i}=e;let a=b;o?(a=await async function(t,n,e){const o=et(new r(it[n]));return B(o,await gt(t,n,e,o))}(e,s,o),c()):await i;const f=new r(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 s=new r(e);n.process(s,!1);const c=kt(n.digest(),0,ft);t.enqueue(B(s,c))}},cancel(){St(this)}})}}function yt(t,e,o,s){n.assign(t,{ready:new w(n=>t.l=n),password:vt(e,o),strength:s-1,m:b})}function mt(t,n,e,o,s,c){const{h:i,m:a}=t;a.length&&(n=B(a,n));const f=n.length-s,u=f-f%16;if(e=function(t,n){if(n&&n>t.length){const e=t;(t=new r(n)).set(e,0)}return t}(e,o+u),u){const t=kt(e,o,o+u);t.set(kt(n,0,u)),i.process(t,c)}return t.m=kt(n,u),e}function St({h:t}){t&&t.dispose&&t.dispose()}async function gt(t,e,s,c){t.password=null;const i=at[e],a=await async function(t,e,s){if(lt)try{const o=await wt.importKey("raw",t,st,!1,ct);return new r(await wt.deriveBits(n.assign({salt:e},rt),o,8*s))}catch{lt=!1}return function(t,n,e,s){const c=X(t),i=new r(s),a=new r(n.length+4),f=new u(a.buffer);a.set(n);for(let t=1,e=0;e<s;t++,e+=j){f.setUint32(n.length,t),c.update(a,0,a.length);let r=c.digest();const u=r.slice();for(let t=1;t<1e3;t++){c.update(r,0,j),r=c.digest();for(let t=0;t<j;t++)u[t]^=r[t]}i.set(u.subarray(0,o.min(j,s-e)),e)}return i}(t,e,0,s)}(s,c,2*i+2);return t.h=ht(kt(a,0,i),kt(a,i,2*i)),kt(a,2*i)}function vt(t,n){return n===v?function(t){if(typeof l==k){t=unescape(encodeURIComponent(t));const n=new r(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 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 s(tt);t=t.subarray(12)}o?n.error(new s(nt)):n.enqueue(It(e,t))}})}}class bt extends d{constructor({password:t,rawPassword:n,passwordVerification:e}){super({start(){Ct(this,t,n,e)},transform(t,n){const e=this;let o,s;if(e.password||e.rawPassword){e.password=e.rawPassword=null;const n=et(new r(12));n[11]=e.passwordVerification,o=new r(t.length+n.length),o.set(At(e,n),0),s=12}else o=new r(t.length),s=0;o.set(At(e,t),s),n.enqueue(o)}})}}function Ct(t,e,o,s){n.assign(t,{password:e,rawPassword:o,passwordVerification:s}),function(t,e,o){const s=[305419896,591751049,878082192];if(n.assign(t,{keys:s,S:new R(s[0]),v:new R(s[2])}),o)for(let n=0;n<o.length;n++)Mt(t,o[n]);else for(let n=0;n<e.length;n++)Mt(t,e.charCodeAt(n))}(t,e,o)}function It(t,n){const e=new r(n.length);for(let o=0;o<n.length;o++)e[o]=xt(t)^n[o],Mt(t,e[o]);return e}function At(t,n){const e=new r(n.length);for(let o=0;o<n.length;o++)e[o]=xt(t)^n[o],Mt(t,n[o]);return e}function Mt(t,n){let[,e]=t.keys;t.S.append([n]);const s=~t.S.get();e=Dt(o.imul(Dt(e+Pt(s)),134775813)+1),t.v.append([e>>>24]);const r=~t.v.get();t.keys=[s,e,r]}function xt(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="Invalid CRC32",Vt="deflate-raw",Wt="gzip",jt=[31,139,8];class Kt extends d{constructor(t,{chunkSize:n,CompressionStreamFallback:e,CompressionStream:o}){super({});const{compressed:s,encrypted:r,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),k=qt(c,o,e),z=a&&s&&!w&&!v&&(!r||i)&&Boolean(k);if(r&&!i||!a||z||(y=new U,g=Jt(g,y)),s)if(v)g=Qt(g,Nt(v.CompressionStream,l,{level:f,chunkSize:n,compressionMethod:h,uncompressedSize:p}));else if(z)S=new Ot,g=Qt(g,new k(Wt,{level:f,chunkSize:n})),g=Jt(g,S);else try{g=Gt(g,c,{level:f,chunkSize:n},o,e)}catch(t){if(!c&&e)throw t;let n;try{n=new o(Wt)}catch{throw t}g=Qt(g,n),g=Jt(g,new Ot)}r&&(i?g=Jt(g,new bt(t)):(m=new dt(t),g=Jt(g,m))),Lt(d,g,()=>{r&&!i||!a||(d.crc32=z?S.crc32:new u(y.value.buffer).getUint32(0))})}}class Ot extends d{constructor(){let t,n=10,e=new r(0);super({transform(t,s){if(n){const e=o.min(n,t.length);if(n-=e,!(t=t.subarray(e)).length)return}const r=e.length+t.length;if(r<=8)return void(e=B(e,t));const c=r-8,i=o.min(c,e.length);s.enqueue(B(e.subarray(0,i),t.subarray(0,c-i))),e=B(e.subarray(i),t.subarray(c-i))},flush(){const n=V(e);t.crc32=n.getUint32(0,!0),t.uncompressedSize=n.getUint32(4,!0)}}),t=this}}class Tt 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:d,compressionMethod:m,rawBitFlag:S,outputSize:g}=t;let k,z,b,C=super.readable;if(i&&(c?C=Jt(C,new zt(t)):(z=new pt(t),C=Jt(C,z))),l){const t=d&&Rt(d);if(t)C=Qt(C,Nt(t.DecompressionStream,d,{chunkSize:n,compressionMethod:m,rawBitFlag:S,uncompressedSize:g}));else{let t;const c=qt(h,o,e);if(a&&!p&&f!==v&&g!==v&&c)try{t=new c(Wt,{chunkSize:n})}catch{t=v}if(!t)try{C=Gt(C,h,{chunkSize:n,deflate64:p},o,e)}catch(n){if(p||g===v||!h&&e)throw n;try{t=new o(Wt)}catch{throw n}}t&&(b=!0,C=function(t,n,e,o){const c=n.writable.getWriter(),i=n.readable.getReader(),a=o===v?new R:v;let f,u,l=0,h=!1,p=!1,d=!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 r(10);for(t.set(jt),await c.write(t);;){await c.ready;const{value:t,done:e}=await n.read();if(e)break;await c.write(t)}h=!0,a&&(S&&z(),await g);const s=new r(8),i=V(s);i.setUint32(0,a?a.get():o,!0),i.setUint32(4,e,!0),p=!0,await c.write(s),await c.close()}catch(t){await Xt(c,t),await Yt(n,t)}}(),new y({async pull(t){let n;try{n=await function(){m++,S=!0;const t=i.read();return t.then(k,k),h&&a&&z(),t}()}catch(t){throw p?function(t){const n=new s(l==e?Bt:Ut);return n.cause=t,n}(t):t}const{value:o,done:r}=n;if(r)t.close();else{if(l+=o.length,l>e){const t=new s(Ut);throw u(t),await Yt(i,t),t}a&&a.append(o),t.enqueue(o)}},cancel:t=>(u(t),i.cancel(t))});function k(){S=!1}async function z(){if(!d){d=!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)}),d=!1,S&&(m==t?f():z())}}}(C,t,g,f))}C=function(t){const n=t.getReader();return new y({async pull(t){let e;try{e=await n.read()}catch(t){if(t&&t.message)throw t;const n=new s("Invalid compressed data");throw n.cause=t,n}const{value:o,done:r}=e;r?t.close():t.enqueue(o)},cancel:t=>n.cancel(t)})}(C)}a&&!b&&(k=new U,C=Jt(C,k)),Lt(this,C,()=>{if(k){const t=new u(k.value.buffer).getUint32(0,!1);if(f!=t)throw new s(Bt)}})}}const Ht=new f;function Lt(t,e,o){e=Jt(e,new d({flush:o})),n.defineProperty(t,"readable",{get:()=>e})}function Nt(t,n,e){if(!t)throw new s("Compression method not supported");return new t(n,e)}function qt(t,n,e){return t&&n?n:e&&e.requiresModule?e:void 0}function Gt(t,n,e,o,s){const r=n&&o?o:s||o,c=e.deflate64?"deflate64-raw":Vt;let i;try{i=new r(c,e)}catch(t){if(!n||!s||r==s)throw t;i=new s(c,e)}return Qt(t,i)}function Jt(t,n){return Ft(t).pipeThrough(n)}function Qt(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 Xt(e,t),await Yt(o,t)}}(),n.readable}async function Xt(t,n){try{await t.abort(n)}catch{}}async function Yt(t,n){try{await t.cancel(n)}catch{}}const Zt="data",$t="deflate";class _t extends d{constructor(t,e){super({});const o=this,{codecType:r}=t;let c;r.startsWith($t)?c=Kt:r.startsWith("inflate")&&(c=Tt),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 s(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 tn extends d{constructor(t){const o=[];let s=0,c=0;function i(){const n=new r(t);let e=0;for(;e<t;){const s=o[0],r=t-e;s.length<=r?(n.set(s,e),e+=s.length,o.shift()):(n.set(s.subarray(0,r),e),o[0]=s.subarray(r),e+=r)}return s-=t,n}(!e.isFinite(t)||t<1)&&(t=65536),super({transform(n,e){for(o.push(n),s+=n.length;s>t;)c+=t,e.enqueue(i())},flush(t){s&&(c+=s,t.enqueue(function(t,n){const e=new r(n);let o=0;for(const n of t)e.set(n,o),o+=n.length;return e}(o,s)))}}),n.defineProperty(this,"outputSize",{get:()=>c})}}let nn=2;try{typeof navigator!=k&&navigator.hardwareConcurrency&&(nn=navigator.hardwareConcurrency)}catch{}function en(t){return Boolean(t)&&"object"==typeof t}const on=new f,sn=new f,rn=function(){try{return structuredClone(new s)instanceof s}catch{return!1}}();let cn=0;async function an(t){let n,r,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!=z&&typeof o!=z)throw new s("Invalid codec module");Et.set(t,{CompressionStream:e,DecompressionStream:o})}(t,await(import(n)))}(i.format,i.codecURI)}catch(t){if(en(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=Ht.get(t);e||(e=new f,Ht.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($t)?a.CompressionStream:a.DecompressionStream,Vt))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=>on.set(cn,t));fn({type:"pull",messageId:cn}),cn=(cn+1)%e.MAX_SAFE_INTEGER;const{value:o,done:s}=await n;t.enqueue(o),s&&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);sn.set(cn,n),fn({type:Zt,value:t,messageId:cn}),cn=(cn+1)%e.MAX_SAFE_INTEGER,await o}},u),n=new _t(i,a),r=new tn(function(t){return s="string"==typeof(n=s=t.chunkSize)&&n.trim()?e(n):n,e.isInteger(s)&&s>=1?o.max(s,64):65536;var n,s}(a)),await l.pipeThrough(n).pipeThrough(r).pipeTo(c,{preventClose:!0,preventAbort:!0}),await c.getWriter().close();const{crc32:h,inputSize:p,outputSize:d}=n;fn({type:"close",result:{crc32:h,inputSize:p,outputSize:d}})}catch(t){const n=r?r.outputSize:0;if(en(t))try{t.outputSize=n}catch{}if(c&&!c.locked)try{await c.getWriter().close()}catch{}un(t,n)}}function fn(t){const{value:n}=t;if(n)if(n.length)try{t.value=(e=n,e.byteOffset||e.byteLength!=e.buffer.byteLength?new r(e):e).buffer,p(t,[t.value])}catch{p(t)}else p(t);else p(t);var e}function un(t,n){const{message:e,stack:o,code:r,name:c,outputSize:i,cause:a,codecImportFailed:f}=function(t=new s("Unknown error")){return en(t)?t:new s(String(t))}(t),u={message:e,stack:o,code:r,name:c,outputSize:i===v?n:i};if(a&&(u.cause={name:a.name,message:a.message}),f&&(u.codecImportFailed=!0),rn)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:s}=t;try{if("start"==n&&an(t),n==Zt){const t=on.get(e);on.delete(e),t({value:o||new r,done:s})}if("ack"==n){const t=sn.get(e);sn.delete(e),t()}}catch(t){un(t)}}),p({type:"ready"});const wn="deflate",ln="deflate-raw",hn="deflate64-raw",pn="gzip";let dn,yn,mn,Sn,gn;function vn(t,n,e={}){if(!dn){const t=new s("WASM module not loaded");throw t.cause=gn,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.C=yn(i),this.in=yn(a),this.inBufferSize=a,!this.C||!this.in)throw new s("allocation failed");if(t?(this.I=dn.deflate_process,this.A=dn.deflate_last_consumed,this.M=dn.deflate_end,this.P=dn.deflate_new(),e=n===pn?dn.deflate_init_gzip(this.P,c):n===ln?dn.deflate_init_raw(this.P,c):dn.deflate_init(this.P,c)):n===hn?(this.I=dn.inflate9_process,this.A=dn.inflate9_last_consumed,this.M=dn.inflate9_end,this.P=dn.inflate9_new(),e=dn.inflate9_init_raw(this.P)):(this.I=dn.inflate_process,this.A=dn.inflate_last_consumed,this.M=dn.inflate_end,this.P=dn.inflate_new(),e=n===ln?dn.inflate_init_raw(this.P):n===pn?dn.inflate_init_gzip(this.P):dn.inflate_init(this.P)),0!==e)throw new s("init failed:"+e)}catch(t){throw f(this),t}},transform(t,n){try{const e=t,c=new r(Sn.buffer),a=this.I,f=this.A,u=this.C;let w=0;for(;w<e.length;){const t=o.min(e.length-w,32768);if((!this.in||this.inBufferSize<t)&&(this.in&&mn&&(mn(this.in),this.in=0),this.in=yn(t),this.inBufferSize=t,!this.in))throw new s("allocation failed");c.set(e.subarray(w,w+t),this.in);const r=a(this.P,this.in,t,u,i,0),l=r>>24&255,h=128&l?l-256:l;if(h<0)throw new s("process error:"+h);const p=16777215&r;p&&n.enqueue(c.slice(u,u+p));const d=f(this.P);if(0===d&&0===p)break;w+=d}}catch(t){f(this),n.error(t)}},flush(t){try{const n=new r(Sn.buffer),e=this.I,o=this.C;for(;;){const r=e(this.P,0,0,o,i,4),c=r>>24&255,a=128&c?c-256:c;if(a<0)throw new s("process error:"+a);const f=16777215&r;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 s("end error:"+n))}},cancel(){f(this)}});function f(t){let n=0;return t.P&&t.M&&(n=t.M(t.P)),t.P=0,t.in&&mn&&mn(t.in),t.in=0,t.C&&mn&&mn(t.C),t.C=0,n}}class kn{constructor(t=wn,n){return vn(!0,t,n)}}class zn{constructor(t=wn,n){return vn(!1,t,n)}}kn.requiresModule=!0,zn.requiresModule=!0,kn.supportedFormats=[wn,ln,pn],zn.supportedFormats=[wn,ln,pn,hn];const bn=65536;let Cn,In;function An(t){return new r(t.memory.buffer)}let Mn=!1;!function(t={}){const{init:n,D:e}=t,o=t.CompressionStreamFallback||t.CompressionStreamZlib,s=t.DecompressionStreamFallback||t.DecompressionStreamZlib;e&&(ht=e||Q),self.initModule=async t=>{n&&await n(t),o&&(t.CompressionStreamFallback=o),s&&(t.DecompressionStreamFallback=s)}}({CompressionStreamFallback:kn,DecompressionStreamFallback:zn,D:function(t,n){const e=Cn;let o=e?function(t,n,e){In||(In=t.malloc(bn));const o=In?t.aes_hmac_new():0;if(o){const s=An(t);if(s.set(n,In),s.set(e,In+n.length),t.aes_hmac_init(o,In,n.length,In+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 s=In;return{process(t,n){for(let r=0;r<t.length;r+=bn){const c=t.subarray(r,r+bn),i=An(e);i.set(c,s),e.aes_hmac_process(o,s,c.length,n?1:0),c.set(i.subarray(s,s+c.length))}},digest:()=>(e.aes_hmac_end(o,s),o=0,An(e).slice(s,s+20)),dispose(){o&&(e.aes_hmac_end(o,0),o=0)}}},init:t=>async function(t,{baseURI:n}){if(!Mn)try{await async function(t,n){let e,o;try{try{o=new URL(t,n)}catch{}const s=await fetch(o);e=await s.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,s=new r(o);for(let t=0;t<o;++t)s[t]=e.charCodeAt(t);return s.buffer}(t)}const c=await WebAssembly.instantiate(e);var i;(function(t){if(dn=t,({malloc:yn,free:mn,memory:Sn}=dn),"function"!=typeof yn||"function"!=typeof mn||!Sn)throw dn=yn=mn=Sn=null,new s("Invalid WASM module")})(c.instance.exports),typeof(i=c.instance.exports).aes_hmac_new==z&&(Cn=i,In=0)}(t,n),Mn=!0}catch(t){throw function(t){gn=t}(t),t}}(t.wasmURI,t)})});\n';if("string"==typeof s&&(s=(new TextEncoder).encode(s)),t){const t=new Blob([s],{type:e});return URL.createObjectURL(t)}return "data:"+e+";base64,"+function(t){let e="";const s=t.length;let r=0;for(;r+2<s;r+=3){const s=t[r]<<16|t[r+1]<<8|t[r+2];e+=n$1[s>>18&63]+n$1[s>>12&63]+n$1[s>>6&63]+n$1[63&s];}const o=s-r;if(1===o){const s=t[r]<<16;e+=n$1[s>>18&63]+n$1[s>>12&63]+"==";}else if(2===o){const s=t[r]<<16|t[r+1]<<8;e+=n$1[s>>18&63]+n$1[s>>12&63]+n$1[s>>6&63]+"=";}return e}(s)}});
|
|
448
|
+
const t$1=new Uint8Array(288);t$1.fill(8,0,144),t$1.fill(9,144,256),t$1.fill(7,256,280),t$1.fill(8,280,288),new Uint8Array(30).fill(5);const 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:d,postMessage:p,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,M,A,E,R,x,P,D]=C;class F{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=D[255&t]^P[t>>>8&255]^x[t>>>16&255]^R[t>>>24&255]^E[255&e]^A[e>>>8&255]^M[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 h{constructor(){let t;const n=new F;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 B(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 O=64,V=20,K=new c([128]),T=new c(1),_=new i([1732584193,4023233417,2562383102,271733878,3285377520]),j=new c(256),H=new i(256),L=new i(256),Z=new i(256),N=new i(256);let q=!1;function G(t,n){!function(){if(!q){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),j[t]=255&(n^(n<<1|n>>7)^(n<<2|n>>6)^(n<<3|n>>5)^(n<<4|n>>4)^99)}while(1!=t);j[0]=99;for(let t=0;t<256;t++){const n=j[t],e=Y(n),o=e<<24|n<<16|n<<8|e^n;H[t]=o,L[t]=o>>>8|o<<24,Z[t]=o>>>16|o<<16,N[t]=o>>>24|o<<8}q=!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=Q(o<<8|o>>>24)^c<<24,c=Y(c)):e>6&&t%e==4&&(o=Q(o)),n[t]=n[t-e]^o}return o}(t,e),r=new i(4),c=J(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=X(s)^e[0],n=X(a)^e[1],c=X(f)^e[2],i=X(w)^e[3],u=H[t>>>24]^L[n>>>16&255]^Z[c>>>8&255]^N[255&i]^e[4],l=H[n>>>24]^L[c>>>16&255]^Z[i>>>8&255]^N[255&t]^e[5],d=H[c>>>24]^L[i>>>16&255]^Z[t>>>8&255]^N[255&n]^e[6],p=H[i>>>24]^L[t>>>16&255]^Z[n>>>8&255]^N[255&c]^e[7];t=H[u>>>24]^L[l>>>16&255]^Z[d>>>8&255]^N[255&p]^e[8],n=H[l>>>24]^L[d>>>16&255]^Z[p>>>8&255]^N[255&u]^e[9],c=H[d>>>24]^L[p>>>16&255]^Z[u>>>8&255]^N[255&l]^e[10],i=H[p>>>24]^L[u>>>16&255]^Z[l>>>8&255]^N[255&d]^e[11],u=H[t>>>24]^L[n>>>16&255]^Z[c>>>8&255]^N[255&i]^e[12],l=H[n>>>24]^L[c>>>16&255]^Z[i>>>8&255]^N[255&t]^e[13],d=H[c>>>24]^L[i>>>16&255]^Z[t>>>8&255]^N[255&n]^e[14],p=H[i>>>24]^L[t>>>16&255]^Z[n>>>8&255]^N[255&c]^e[15],t=H[u>>>24]^L[l>>>16&255]^Z[d>>>8&255]^N[255&p]^e[16],n=H[l>>>24]^L[d>>>16&255]^Z[p>>>8&255]^N[255&u]^e[17],c=H[d>>>24]^L[p>>>16&255]^Z[u>>>8&255]^N[255&l]^e[18],i=H[p>>>24]^L[u>>>16&255]^Z[l>>>8&255]^N[255&d]^e[19],u=H[t>>>24]^L[n>>>16&255]^Z[c>>>8&255]^N[255&i]^e[20],l=H[n>>>24]^L[c>>>16&255]^Z[i>>>8&255]^N[255&t]^e[21],d=H[c>>>24]^L[i>>>16&255]^Z[t>>>8&255]^N[255&n]^e[22],p=H[i>>>24]^L[t>>>16&255]^Z[n>>>8&255]^N[255&c]^e[23],t=H[u>>>24]^L[l>>>16&255]^Z[d>>>8&255]^N[255&p]^e[24],n=H[l>>>24]^L[d>>>16&255]^Z[p>>>8&255]^N[255&u]^e[25],c=H[d>>>24]^L[p>>>16&255]^Z[u>>>8&255]^N[255&l]^e[26],i=H[p>>>24]^L[u>>>16&255]^Z[l>>>8&255]^N[255&d]^e[27],u=H[t>>>24]^L[n>>>16&255]^Z[c>>>8&255]^N[255&i]^e[28],l=H[n>>>24]^L[c>>>16&255]^Z[i>>>8&255]^N[255&t]^e[29],d=H[c>>>24]^L[i>>>16&255]^Z[t>>>8&255]^N[255&n]^e[30],p=H[i>>>24]^L[t>>>16&255]^Z[n>>>8&255]^N[255&c]^e[31],t=H[u>>>24]^L[l>>>16&255]^Z[d>>>8&255]^N[255&p]^e[32],n=H[l>>>24]^L[d>>>16&255]^Z[p>>>8&255]^N[255&u]^e[33],c=H[d>>>24]^L[p>>>16&255]^Z[u>>>8&255]^N[255&l]^e[34],i=H[p>>>24]^L[u>>>16&255]^Z[l>>>8&255]^N[255&d]^e[35],u=H[t>>>24]^L[n>>>16&255]^Z[c>>>8&255]^N[255&i]^e[36],l=H[n>>>24]^L[c>>>16&255]^Z[i>>>8&255]^N[255&t]^e[37],d=H[c>>>24]^L[i>>>16&255]^Z[t>>>8&255]^N[255&n]^e[38],p=H[i>>>24]^L[t>>>16&255]^Z[n>>>8&255]^N[255&c]^e[39];let h=40;o>10&&(t=H[u>>>24]^L[l>>>16&255]^Z[d>>>8&255]^N[255&p]^e[40],n=H[l>>>24]^L[d>>>16&255]^Z[p>>>8&255]^N[255&u]^e[41],c=H[d>>>24]^L[p>>>16&255]^Z[u>>>8&255]^N[255&l]^e[42],i=H[p>>>24]^L[u>>>16&255]^Z[l>>>8&255]^N[255&d]^e[43],u=H[t>>>24]^L[n>>>16&255]^Z[c>>>8&255]^N[255&i]^e[44],l=H[n>>>24]^L[c>>>16&255]^Z[i>>>8&255]^N[255&t]^e[45],d=H[c>>>24]^L[i>>>16&255]^Z[t>>>8&255]^N[255&n]^e[46],p=H[i>>>24]^L[t>>>16&255]^Z[n>>>8&255]^N[255&c]^e[47],h=48),o>12&&(t=H[u>>>24]^L[l>>>16&255]^Z[d>>>8&255]^N[255&p]^e[48],n=H[l>>>24]^L[d>>>16&255]^Z[p>>>8&255]^N[255&u]^e[49],c=H[d>>>24]^L[p>>>16&255]^Z[u>>>8&255]^N[255&l]^e[50],i=H[p>>>24]^L[u>>>16&255]^Z[l>>>8&255]^N[255&d]^e[51],u=H[t>>>24]^L[n>>>16&255]^Z[c>>>8&255]^N[255&i]^e[52],l=H[n>>>24]^L[c>>>16&255]^Z[i>>>8&255]^N[255&t]^e[53],d=H[c>>>24]^L[i>>>16&255]^Z[t>>>8&255]^N[255&n]^e[54],p=H[i>>>24]^L[t>>>16&255]^Z[n>>>8&255]^N[255&c]^e[55],h=56),r[0]=(j[u>>>24]<<24|j[l>>>16&255]<<16|j[d>>>8&255]<<8|j[255&p])^e[h],r[1]=(j[l>>>24]<<24|j[d>>>16&255]<<16|j[p>>>8&255]<<8|j[255&u])^e[h+1],r[2]=(j[d>>>24]<<24|j[p>>>16&255]<<16|j[u>>>8&255]<<8|j[255&l])^e[h+2],r[3]=(j[p>>>24]<<24|j[u>>>16&255]<<16|j[l>>>8&255]<<8|j[255&d])^e[h+3]}}function J(t){const n=function(){const t=new i(_),n=new i(16),e=new c(O),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(K,0,1);56!=a;)w(T,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(V),l=new u(i.buffer);for(let n=0;n<t.length;n++)l.setInt32(4*n,t[n]);return t.set(_),a=0,f=0,i}};function w(t,n,o){const c=n+o;if(f+=o,a){for(;n<c&&a<O;)e[a++]=t[n++];a==O&&(l(r,0),a=0)}if(n+O<=c){const e=new u(t.buffer,t.byteOffset,t.byteLength);for(;n+O<=c;n+=O)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(O),r=new c(O);t.length>O&&(n.update(t,0,t.length),t=n.digest());for(let n=0;n<O;n++){const o=n<t.length?t[n]:0;e[n]=54^o,r[n]=92^o}return n.update(e,0,O),{update(t,e,o){n.update(t,e,o)},digest(){const t=n.digest();n.update(r,0,O),n.update(t,0,V);const o=n.digest();return n.update(e,0,O),o}}}function Q(t){return j[t>>>24]<<24|j[t>>>16&255]<<16|j[t>>>8&255]<<8|j[255&t]}function X(t){return t<<24|(65280&t)<<8|t>>>8&65280|t>>>24}function Y(t){return 255&(t<<1^27*(t>>7))}const $=typeof d!=b&&typeof d.getRandomValues==k,tt="Invalid password",nt="zipjs-abort-check-password";function et(t){if($)return d.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 d!=b,wt=ut&&d.subtle;let lt=ut&&typeof wt!=b&&typeof wt.importKey==k&&typeof wt.deriveBits==k,dt=G;class pt 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 B(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(B(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=B(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=J(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+=V){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,V),c=s.digest();for(let t=0;t<V;t++)u[t]^=c[t]}a.set(u.subarray(0,o.min(V,r-e)),e)}return a}(t,e,0,r)}(r,s,2*a+2);return t.m=dt(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=Mt(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(Mt(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(At(e,n),0),r=12}else o=new c(t.length),r=0;o.set(At(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 F(r[0]),I:new F(r[2])}),o)for(let n=0;n<o.length;n++)Et(t,o[n]);else for(let n=0;n<e.length;n++)Et(t,e.charCodeAt(n))}(t,e,o)}function Mt(t,n){const e=new c(n.length);for(let o=0;o<n.length;o++)e[o]=Rt(t)^n[o],Et(t,e[o]);return e}function At(t,n){const e=new c(n.length);for(let o=0;o<n.length;o++)e[o]=Rt(t)^n[o],Et(t,n[o]);return e}function Et(t,n){let[,e]=t.v;t.C.append([n]);const r=~t.C.get();e=Pt(o.imul(Pt(e+xt(r)),134775813)+1),t.I.append([e>>>24]);const c=~t.I.get();t.v=[r,e,c]}function Rt(t){const n=2|t.v[2];return xt(o.imul(n,1^n)>>>8)}function xt(t){return 255&t}function Pt(t){return 4294967295&t}function Dt(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)})}function Ft(t){return Boolean(t)&&"object"==typeof t}const Ut=new f;function Bt(t){return Ut.get(t)}const Wt="Invalid uncompressed size",Ot="Codec out of memory",Vt="Invalid CRC32",Kt="deflate-raw",Tt="gzip",_t=[31,139,8];class jt 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:d,inputSize:p}=t,h=this;let y,m,S,g=super.readable;const v=l&&Bt(l),b=Gt(s,o,e),k=i&&r&&!w&&!v&&(!c||a)&&Boolean(b);if(c&&!a||!i||k||(y=new U,g=Qt(g,y)),r)if(v)g=Xt(g,qt(v.CompressionStream,l,{level:f,chunkSize:n,compressionMethod:d,uncompressedSize:p}));else if(k)S=new Ht,g=Xt(g,new b(Tt,{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 en(t);let n;try{n=new o(Tt)}catch{throw en(t)}g=Xt(g,n),g=Qt(g,new Ht)}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 Ht 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=B(e,t));const s=c-8,a=o.min(s,e.length);r.enqueue(B(e.subarray(0,a),t.subarray(0,s-a))),e=B(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 Lt extends h{constructor(t,{chunkSize:n,DecompressionStreamFallback:e,DecompressionStream:o}){super({});const{zipCrypto:s,encrypted:a,checkCrc32:i,crc32:f,compressed:l,useCompressionStream:d,deflate64:p,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 pt(t),C=Qt(C,k))),l){const t=new Set,s=h&&Bt(h);let a;if(s)C=Xt(C,qt(s.DecompressionStream,h,{chunkSize:n,compressionMethod:m,rawBitFlag:S,uncompressedSize:g}),t);else{const r=Gt(d,o,e);if(i&&!p&&f!==v&&g!==v&&r)try{a=new r(Tt,{chunkSize:n})}catch{a=v}if(!a)try{C=Jt(C,d,{chunkSize:n,deflate64:p},o,e,t)}catch(t){if(p||g===v||!d&&e)throw en(t);try{a=new o(Tt)}catch{throw en(t)}}}a?(z=!0,C=function(t,n,e,o,s){const a=n.writable.getWriter(),i=n.readable.getReader(),f=o===v?new F:v;let u,l,d=0,p=!1,h=!1;const m=new y({start(t){l=t},pull(){b()},cancel:t=>(h=!0,b(),i.cancel(t))});return async function(){const n=t.getReader();try{const t=new c(10);for(t.set(_t),await a.write(t);;){await g(),await a.ready;const{value:t,done:e}=await tn(n,s);if(e)break;await a.write(t)}f&&await a.write(new c(0));const r=new c(8),i=W(r);i.setUint32(0,f?f.get():o,!0),i.setUint32(4,e,!0),p=!0,await a.write(r),await a.close()}catch(t){await Yt(a,t),await $t(n,t)}}(),async function(){try{for(;;){const{value:t,done:n}=await S();if(n)break;if(d+=t.length,d>e)throw new r(Wt);f&&f.append(t),l.enqueue(t)}h||(h=!0,l.close())}catch(t){!function(t){h||(h=!0,l.error(t),b())}(t),await $t(i,t)}}(),m;function S(){return i.read().catch(t=>{if(p){if(!f)throw rn(t,Vt);if(d!=e)throw rn(t,Wt);return{done:!0}}throw nn(t,s)})}function g(){if(!h&&l.desiredSize<=0)return new w(t=>u=t)}function b(){if(u){const t=u;u=v,t()}}}(C,a,g,f,t)):C=function(t,n){const e=t.getReader();return new y({async pull(t){try{const{value:n,done:o}=await e.read();o?t.close():t.enqueue(n)}catch(t){throw await $t(e,t),nn(t,n)}},cancel:t=>e.cancel(t)})}(C,t)}i&&!z&&(b=new U,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(Vt)}})}}const Zt=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,c){const s=n&&o?o:r||o,a=e.deflate64?"deflate64-raw":Kt;let i;try{i=new s(a,e)}catch(t){if(!n||!r||s==r)throw t;i=new r(a,e)}return Xt(t,i,c)}function Qt(t,n){return Dt(t).pipeThrough(n)}function Xt(t,n,e){const o=n.writable.getWriter(),r=t.getReader();return async function(){try{for(;;){await o.ready;const t=await tn(r,e);if(t.done){await o.close();break}await o.write(t.value)}}catch(t){await Yt(o,t),await $t(r,t)}}(),n.readable}async function Yt(t,n){try{await t.abort(n)}catch{}}async function $t(t,n){try{await t.cancel(n)}catch{}}function tn(t,n){const e=t.read();return n?e.catch(t=>{throw n.add(t),t}):e}function nn(t,n){return n.has(t)?t:rn(t,on(t)?Ot:"Invalid compressed data")}function en(t){return on(t)?rn(t,Ot):t}function on(t){return Ft(t)&&"Z_MEM_ERROR"==t.code}function rn(t,n){const e=new r(n);return e.cause=t,e}const cn="data",sn="deflate";class an extends h{constructor(t,e){super({});const o=this,{codecType:c}=t;let s;c.startsWith(sn)?s=jt:c.startsWith("inflate")&&(s=Lt),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(Wt)},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 fn 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 un=2;try{typeof navigator!=b&&navigator.hardwareConcurrency&&(un=navigator.hardwareConcurrency)}catch{}const wn=new f,ln=new f,dn=function(){try{return structuredClone(new r)instanceof r}catch{return!1}}();let pn=0;async function hn(t){let n,c,s;try{const{options:a,config:i}=t;if(a.format)try{await async function(t,n){!Ut.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");Ut.set(t,{CompressionStream:e,DecompressionStream:o})}(t,await(import(n)))}(a.format,a.codecURI)}catch(t){if(Ft(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=Zt.get(t);e||(e=new f,Zt.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(sn)?i.CompressionStream:i.DecompressionStream,Kt))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?Dt(t.readable):new y({async pull(t){const n=new w(t=>wn.set(pn,t));yn({type:"pull",messageId:pn}),pn=(pn+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);ln.set(pn,n),yn({type:cn,value:t,messageId:pn}),pn=(pn+1)%e.MAX_SAFE_INTEGER,await o}},u),n=new an(a,i),c=new fn(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:d,inputSize:p,outputSize:h}=n;yn({type:"close",result:{crc32:d,inputSize:p,outputSize:h}})}catch(t){const n=c?c.outputSize:0;if(Ft(t))try{t.outputSize=n}catch{}if(s&&!s.locked)try{await s.getWriter().close()}catch{}mn(t,n)}}function yn(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,p(t,[t.value])}catch{p(t)}else p(t);else p(t);var e}function mn(t,n){const{message:e,stack:o,code:c,name:s,outputSize:a,cause:i,codecImportFailed:f}=function(t=new r("Unknown error")){return Ft(t)?t:new r(String(t))}(t),u={message:e,stack:o,code:c,name:s,outputSize:a===v?n:a};if(Ft(i)&&(u.cause={name:i.name,message:i.message}),f&&(u.codecImportFailed=!0),dn)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&&hn(t),n==cn){const t=wn.get(e);wn.delete(e),t({value:o||new c,done:r})}if("ack"==n){const t=ln.get(e);ln.delete(e),t()}}catch(t){mn(t)}}),p({type:"ready"});const Sn="deflate",gn="deflate-raw",vn="deflate64-raw",bn="gzip",kn=[Sn,gn,bn],zn=[Sn,gn,bn,vn];let Cn,In,Mn,An,En;function Rn(t,n){return-4===n&&(t.code="Z_MEM_ERROR"),t}function xn(t,n,e={}){if(!(t?kn:zn).includes(n))throw new TypeError("Unsupported format: "+n);if(!Cn){const t=new r("WASM module not loaded");throw t.cause=En,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={M:0,in:0,inBufferSize:0,A:0,R:!1};let u,l,d,p,h=!0,S=!1;return function(){try{let e;if(f.M=In(a),f.in=In(i),f.inBufferSize=i,!f.M||!f.in)throw Rn(new r("allocation failed"),-4);if(t?(f.P=Cn.deflate_process,f.D=Cn.deflate_last_consumed,f.F=Cn.deflate_end,f.A=Cn.deflate_new(),e=n===bn?Cn.deflate_init_gzip(f.A,s):n===gn?Cn.deflate_init_raw(f.A,s):Cn.deflate_init(f.A,s)):n===vn?(f.P=Cn.inflate9_process,f.D=Cn.inflate9_last_consumed,f.F=Cn.inflate9_end,f.A=Cn.inflate9_new(),e=Cn.inflate9_init_raw(f.A)):(f.P=Cn.inflate_process,f.D=Cn.inflate_last_consumed,f.F=Cn.inflate_end,f.A=Cn.inflate_new(),e=n===gn?Cn.inflate_init_raw(f.A):n===bn?Cn.inflate_init_gzip(f.A):Cn.inflate_init(f.A)),0!==e)throw Rn(new r("init failed:"+e),e)}catch(t){throw b(f),t}}(),{readable:new y({start(t){u=t},pull(){h=!1,v()},cancel(t){S=!0,p=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=>d=t),S)throw p;try{!function(t){const n=new c(An.buffer),e=f.P,s=f.D,i=f.M;let u=0;for(;u<t.length;){if(f.R)throw new r("trailing data after the end of the stream");const c=o.min(t.length-u,32768);if((!f.in||f.inBufferSize<c)&&(f.in&&Mn&&(Mn(f.in),f.in=0),f.in=In(c),f.inBufferSize=c,!f.in))throw Rn(new r("allocation failed"),-4);n.set(t.subarray(u,u+c),f.in);const w=e(f.A,f.in,c,i,a,0),l=w>>24&255,d=128&l?l-256:l;if(d<0)throw Rn(new r("process error:"+d),d);const p=16777215&w;p&&g(n.slice(i,i+p));const h=s(f.A);if(1===l)f.R=!0;else if(0===h&&0===p)break;u+=h}}(t)}catch(t){throw b(f),u.error(t),t}},close(){if(S)return;try{!function(){const t=new c(An.buffer),n=f.P,e=f.M;for(;;){const o=n(f.A,0,0,e,a,4),c=o>>24&255,s=128&c?c-256:c;if(s<0)throw Rn(new r("process error:"+s),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=Rn(new r("end error:"+t),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(d){const t=d;d=null,t()}}function b(t){let n=0;return t.A&&t.F&&(n=t.F(t.A)),t.A=0,t.in&&Mn&&Mn(t.in),t.in=0,t.M&&Mn&&Mn(t.M),t.M=0,n}}class Pn{constructor(t=Sn,n){return xn(!0,t,n)}}class Dn{constructor(t=Sn,n){return xn(!1,t,n)}}Pn.requiresModule=!0,Dn.requiresModule=!0,Pn.supportedFormats=kn,Dn.supportedFormats=zn;const Fn=65536;let Un,Bn;function Wn(t){return new c(t.memory.buffer)}let On=!1;!function(t={}){const{init:n,U:e}=t,o=t.CompressionStreamFallback||t.CompressionStreamZlib,r=t.DecompressionStreamFallback||t.DecompressionStreamZlib;e&&(dt=e||G),self.initModule=async t=>{n&&await n(t),o&&(t.CompressionStreamFallback=o),r&&(t.DecompressionStreamFallback=r)}}({CompressionStreamFallback:Pn,DecompressionStreamFallback:Dn,U:function(t,n){const e=Un;let o=e?function(t,n,e){Bn||(Bn=t.malloc(Fn));const o=Bn?t.aes_hmac_new():0;if(o){const r=Wn(t);if(r.set(n,Bn),r.set(e,Bn+n.length),t.aes_hmac_init(o,Bn,n.length,Bn+n.length,e.length))return t.aes_hmac_end(o,0),0}return o}(e,t,n):0;if(!o)return G(t,n);const r=Bn;return{process(t,n){for(let c=0;c<t.length;c+=Fn){const s=t.subarray(c,c+Fn),a=Wn(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,Wn(e).slice(r,r+20)),dispose(){o&&(e.aes_hmac_end(o,0),o=0)}}},init:t=>async function(t,{baseURI:n}){if(!On)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(Cn=t,({malloc:In,free:Mn,memory:An}=Cn),"function"!=typeof In||"function"!=typeof Mn||!An)throw Cn=In=Mn=An=null,new r("Invalid WASM module")})(s.instance.exports),typeof(a=s.instance.exports).aes_hmac_new==k&&(Un=a,Bn=0)}(t,n),On=!0}catch(t){throw function(t){En=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)}});
|
|
449
449
|
|
|
450
450
|
/*
|
|
451
451
|
Copyright (c) 2026 Gildas Lormeau. All rights reserved.
|
|
@@ -1285,12 +1285,12 @@
|
|
|
1285
1285
|
class AESDecryptionStream extends TransformStream {
|
|
1286
1286
|
|
|
1287
1287
|
constructor({ password, rawPassword, encryptionStrength, checkPasswordOnly, checkAuthenticationCode = true }) {
|
|
1288
|
+
const aesCrypto = {};
|
|
1288
1289
|
super({
|
|
1289
1290
|
start() {
|
|
1290
|
-
initAesCrypto(
|
|
1291
|
+
initAesCrypto(aesCrypto, password, rawPassword, encryptionStrength);
|
|
1291
1292
|
},
|
|
1292
1293
|
async transform(chunk, controller) {
|
|
1293
|
-
const aesCrypto = this;
|
|
1294
1294
|
const {
|
|
1295
1295
|
password,
|
|
1296
1296
|
strength,
|
|
@@ -1309,6 +1309,9 @@
|
|
|
1309
1309
|
} else {
|
|
1310
1310
|
await ready;
|
|
1311
1311
|
}
|
|
1312
|
+
if (aesCrypto.discarded) {
|
|
1313
|
+
return;
|
|
1314
|
+
}
|
|
1312
1315
|
const output = new Uint8Array(chunk.length - AUTHENTICATION_CODE_LENGTH - ((chunk.length - AUTHENTICATION_CODE_LENGTH) % BLOCK_LENGTH));
|
|
1313
1316
|
controller.enqueue(append(aesCrypto, chunk, output, 0, AUTHENTICATION_CODE_LENGTH, true));
|
|
1314
1317
|
},
|
|
@@ -1317,9 +1320,12 @@
|
|
|
1317
1320
|
engine,
|
|
1318
1321
|
pendingInput,
|
|
1319
1322
|
ready
|
|
1320
|
-
} =
|
|
1323
|
+
} = aesCrypto;
|
|
1321
1324
|
if (engine) {
|
|
1322
1325
|
await ready;
|
|
1326
|
+
if (aesCrypto.discarded) {
|
|
1327
|
+
return;
|
|
1328
|
+
}
|
|
1323
1329
|
const originalAuthenticationCode = subarray(pendingInput, pendingInput.length - AUTHENTICATION_CODE_LENGTH);
|
|
1324
1330
|
const decryptedChunkArray = new Uint8Array(subarray(pendingInput, 0, pendingInput.length - AUTHENTICATION_CODE_LENGTH));
|
|
1325
1331
|
engine.process(decryptedChunkArray, true);
|
|
@@ -1329,27 +1335,26 @@
|
|
|
1329
1335
|
invalidAuthenticationCode |= authenticationCode[indexByte] ^ originalAuthenticationCode[indexByte];
|
|
1330
1336
|
}
|
|
1331
1337
|
if (invalidAuthenticationCode && checkAuthenticationCode) {
|
|
1332
|
-
|
|
1338
|
+
controller.error(new Error(ERR_INVALID_AUTHENTICATION_CODE));
|
|
1339
|
+
return;
|
|
1333
1340
|
}
|
|
1334
1341
|
controller.enqueue(decryptedChunkArray);
|
|
1335
1342
|
}
|
|
1336
|
-
},
|
|
1337
|
-
cancel() {
|
|
1338
|
-
disposeEngine(this);
|
|
1339
1343
|
}
|
|
1340
1344
|
});
|
|
1345
|
+
setDisposingReadable(this, aesCrypto);
|
|
1341
1346
|
}
|
|
1342
1347
|
}
|
|
1343
1348
|
|
|
1344
1349
|
class AESEncryptionStream extends TransformStream {
|
|
1345
1350
|
|
|
1346
1351
|
constructor({ password, rawPassword, encryptionStrength }) {
|
|
1352
|
+
const aesCrypto = {};
|
|
1347
1353
|
super({
|
|
1348
1354
|
start() {
|
|
1349
|
-
initAesCrypto(
|
|
1355
|
+
initAesCrypto(aesCrypto, password, rawPassword, encryptionStrength);
|
|
1350
1356
|
},
|
|
1351
1357
|
async transform(chunk, controller) {
|
|
1352
|
-
const aesCrypto = this;
|
|
1353
1358
|
const {
|
|
1354
1359
|
password,
|
|
1355
1360
|
strength,
|
|
@@ -1363,6 +1368,9 @@
|
|
|
1363
1368
|
} else {
|
|
1364
1369
|
await ready;
|
|
1365
1370
|
}
|
|
1371
|
+
if (aesCrypto.discarded) {
|
|
1372
|
+
return;
|
|
1373
|
+
}
|
|
1366
1374
|
const output = new Uint8Array(preamble.length + chunk.length - (chunk.length % BLOCK_LENGTH));
|
|
1367
1375
|
output.set(preamble, 0);
|
|
1368
1376
|
controller.enqueue(append(aesCrypto, chunk, output, preamble.length, 0, false));
|
|
@@ -1372,19 +1380,20 @@
|
|
|
1372
1380
|
engine,
|
|
1373
1381
|
pendingInput,
|
|
1374
1382
|
ready
|
|
1375
|
-
} =
|
|
1383
|
+
} = aesCrypto;
|
|
1376
1384
|
if (engine) {
|
|
1377
1385
|
await ready;
|
|
1386
|
+
if (aesCrypto.discarded) {
|
|
1387
|
+
return;
|
|
1388
|
+
}
|
|
1378
1389
|
const encryptedChunkArray = new Uint8Array(pendingInput);
|
|
1379
1390
|
engine.process(encryptedChunkArray, false);
|
|
1380
1391
|
const authenticationCode = subarray(engine.digest(), 0, AUTHENTICATION_CODE_LENGTH);
|
|
1381
1392
|
controller.enqueue(concat(encryptedChunkArray, authenticationCode));
|
|
1382
1393
|
}
|
|
1383
|
-
},
|
|
1384
|
-
cancel() {
|
|
1385
|
-
disposeEngine(this);
|
|
1386
1394
|
}
|
|
1387
1395
|
});
|
|
1396
|
+
setDisposingReadable(this, aesCrypto);
|
|
1388
1397
|
}
|
|
1389
1398
|
}
|
|
1390
1399
|
|
|
@@ -1397,7 +1406,37 @@
|
|
|
1397
1406
|
ready: new Promise(resolve => aesCrypto.resolveReady = resolve),
|
|
1398
1407
|
password: encodePassword(password, rawPassword),
|
|
1399
1408
|
strength: encryptionStrength - 1,
|
|
1400
|
-
pendingInput: EMPTY_UINT8_ARRAY
|
|
1409
|
+
pendingInput: EMPTY_UINT8_ARRAY,
|
|
1410
|
+
discarded: false
|
|
1411
|
+
});
|
|
1412
|
+
}
|
|
1413
|
+
|
|
1414
|
+
function setDisposingReadable(stream, aesCrypto) {
|
|
1415
|
+
const reader = stream.readable.getReader();
|
|
1416
|
+
const readable = new ReadableStream({
|
|
1417
|
+
async pull(controller) {
|
|
1418
|
+
try {
|
|
1419
|
+
const { value, done } = await reader.read();
|
|
1420
|
+
if (done) {
|
|
1421
|
+
controller.close();
|
|
1422
|
+
} else {
|
|
1423
|
+
controller.enqueue(value);
|
|
1424
|
+
}
|
|
1425
|
+
} catch (error) {
|
|
1426
|
+
disposeEngine(aesCrypto);
|
|
1427
|
+
reader.cancel(error).catch(() => { });
|
|
1428
|
+
throw error;
|
|
1429
|
+
}
|
|
1430
|
+
},
|
|
1431
|
+
cancel(reason) {
|
|
1432
|
+
disposeEngine(aesCrypto);
|
|
1433
|
+
return reader.cancel(reason);
|
|
1434
|
+
}
|
|
1435
|
+
});
|
|
1436
|
+
Object.defineProperty(stream, "readable", {
|
|
1437
|
+
get() {
|
|
1438
|
+
return readable;
|
|
1439
|
+
}
|
|
1401
1440
|
});
|
|
1402
1441
|
}
|
|
1403
1442
|
|
|
@@ -1430,7 +1469,9 @@
|
|
|
1430
1469
|
}
|
|
1431
1470
|
}
|
|
1432
1471
|
|
|
1433
|
-
function disposeEngine(
|
|
1472
|
+
function disposeEngine(aesCrypto) {
|
|
1473
|
+
const { engine } = aesCrypto;
|
|
1474
|
+
aesCrypto.discarded = true;
|
|
1434
1475
|
if (engine && engine.dispose) {
|
|
1435
1476
|
engine.dispose();
|
|
1436
1477
|
}
|
|
@@ -1447,6 +1488,9 @@
|
|
|
1447
1488
|
const keyLength = KEY_LENGTH[strength];
|
|
1448
1489
|
const compositeKey = await deriveKey(password, salt, keyLength * 2 + PASSWORD_VERIFICATION_LENGTH);
|
|
1449
1490
|
aesCrypto.engine = createEngine$1(subarray(compositeKey, 0, keyLength), subarray(compositeKey, keyLength, keyLength * 2));
|
|
1491
|
+
if (aesCrypto.discarded) {
|
|
1492
|
+
disposeEngine(aesCrypto);
|
|
1493
|
+
}
|
|
1450
1494
|
return subarray(compositeKey, keyLength * 2);
|
|
1451
1495
|
}
|
|
1452
1496
|
|
|
@@ -1598,11 +1642,11 @@
|
|
|
1598
1642
|
}
|
|
1599
1643
|
|
|
1600
1644
|
function createKeys(target, password, rawPassword) {
|
|
1601
|
-
const
|
|
1645
|
+
const cryptoKeys = [0x12345678, 0x23456789, 0x34567890];
|
|
1602
1646
|
Object.assign(target, {
|
|
1603
|
-
|
|
1604
|
-
crcKey0: new Crc32(
|
|
1605
|
-
crcKey2: new Crc32(
|
|
1647
|
+
cryptoKeys,
|
|
1648
|
+
crcKey0: new Crc32(cryptoKeys[0]),
|
|
1649
|
+
crcKey2: new Crc32(cryptoKeys[2])
|
|
1606
1650
|
});
|
|
1607
1651
|
if (rawPassword) {
|
|
1608
1652
|
for (let index = 0; index < rawPassword.length; index++) {
|
|
@@ -1616,17 +1660,17 @@
|
|
|
1616
1660
|
}
|
|
1617
1661
|
|
|
1618
1662
|
function updateKeys(target, byte) {
|
|
1619
|
-
let [, key1] = target.
|
|
1663
|
+
let [, key1] = target.cryptoKeys;
|
|
1620
1664
|
target.crcKey0.append([byte]);
|
|
1621
1665
|
const key0 = ~target.crcKey0.get();
|
|
1622
1666
|
key1 = getInt32(Math.imul(getInt32(key1 + getInt8(key0)), 134775813) + 1);
|
|
1623
1667
|
target.crcKey2.append([key1 >>> 24]);
|
|
1624
1668
|
const key2 = ~target.crcKey2.get();
|
|
1625
|
-
target.
|
|
1669
|
+
target.cryptoKeys = [key0, key1, key2];
|
|
1626
1670
|
}
|
|
1627
1671
|
|
|
1628
1672
|
function getByte(target) {
|
|
1629
|
-
const temp = target.
|
|
1673
|
+
const temp = target.cryptoKeys[2] | 2;
|
|
1630
1674
|
return getInt8(Math.imul(temp, (temp ^ 1)) >>> 8);
|
|
1631
1675
|
}
|
|
1632
1676
|
|
|
@@ -1674,11 +1718,16 @@
|
|
|
1674
1718
|
const reader = readable.getReader();
|
|
1675
1719
|
return new ReadableStream({
|
|
1676
1720
|
async pull(controller) {
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1721
|
+
try {
|
|
1722
|
+
const { value, done } = await reader.read();
|
|
1723
|
+
if (done) {
|
|
1724
|
+
controller.close();
|
|
1725
|
+
} else {
|
|
1726
|
+
controller.enqueue(value);
|
|
1727
|
+
}
|
|
1728
|
+
} catch (error) {
|
|
1729
|
+
reader.cancel(error).catch(() => { });
|
|
1730
|
+
throw error;
|
|
1682
1731
|
}
|
|
1683
1732
|
},
|
|
1684
1733
|
cancel(reason) {
|
|
@@ -1857,7 +1906,9 @@
|
|
|
1857
1906
|
|
|
1858
1907
|
const ERR_INVALID_UNCOMPRESSED_SIZE = "Invalid uncompressed size";
|
|
1859
1908
|
const ERR_INVALID_COMPRESSED_DATA = "Invalid compressed data";
|
|
1909
|
+
const ERR_CODEC_OUT_OF_MEMORY = "Codec out of memory";
|
|
1860
1910
|
const ERR_INVALID_CRC32 = "Invalid CRC32";
|
|
1911
|
+
const Z_MEM_ERROR_CODE$1 = "Z_MEM_ERROR";
|
|
1861
1912
|
const FORMAT_DEFLATE_RAW$1 = "deflate-raw";
|
|
1862
1913
|
const FORMAT_DEFLATE64_RAW$1 = "deflate64-raw";
|
|
1863
1914
|
const FORMAT_GZIP$1 = "gzip";
|
|
@@ -1892,13 +1943,13 @@
|
|
|
1892
1943
|
readable = pipeThroughCompressionStream(readable, useCompressionStream, { level, chunkSize }, CompressionStream, CompressionStreamFallback);
|
|
1893
1944
|
} catch (error) {
|
|
1894
1945
|
if (!useCompressionStream && CompressionStreamFallback) {
|
|
1895
|
-
throw error;
|
|
1946
|
+
throw mapMemoryError(error);
|
|
1896
1947
|
}
|
|
1897
1948
|
let gzipStream;
|
|
1898
1949
|
try {
|
|
1899
1950
|
gzipStream = new CompressionStream(FORMAT_GZIP$1);
|
|
1900
1951
|
} catch {
|
|
1901
|
-
throw error;
|
|
1952
|
+
throw mapMemoryError(error);
|
|
1902
1953
|
}
|
|
1903
1954
|
readable = pipeThroughBackpressured(readable, gzipStream);
|
|
1904
1955
|
readable = pipeThrough(readable, new GzipToRawDeflateStream());
|
|
@@ -1962,53 +2013,30 @@
|
|
|
1962
2013
|
}
|
|
1963
2014
|
}
|
|
1964
2015
|
|
|
1965
|
-
function pipeThroughGzipDecompressionStream(readable, gzipStream, outputSize, crc32) {
|
|
2016
|
+
function pipeThroughGzipDecompressionStream(readable, gzipStream, outputSize, crc32, sourceErrors) {
|
|
1966
2017
|
const writer = gzipStream.writable.getWriter();
|
|
1967
2018
|
const reader = gzipStream.readable.getReader();
|
|
1968
2019
|
const outputCrc32 = crc32 === UNDEFINED_VALUE ? new Crc32() : UNDEFINED_VALUE;
|
|
1969
2020
|
let outputLength = 0;
|
|
1970
|
-
let inputDone = false;
|
|
1971
2021
|
let trailerWritten = false;
|
|
1972
|
-
let
|
|
1973
|
-
let
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
trailerReady.catch(() => { });
|
|
1981
|
-
pump();
|
|
1982
|
-
return new ReadableStream({
|
|
1983
|
-
async pull(controller) {
|
|
1984
|
-
let result;
|
|
1985
|
-
try {
|
|
1986
|
-
result = await read();
|
|
1987
|
-
} catch (error) {
|
|
1988
|
-
throw trailerWritten ? getTrailerError(error) : error;
|
|
1989
|
-
}
|
|
1990
|
-
const { value, done } = result;
|
|
1991
|
-
if (done) {
|
|
1992
|
-
controller.close();
|
|
1993
|
-
} else {
|
|
1994
|
-
outputLength += value.length;
|
|
1995
|
-
if (outputLength > outputSize) {
|
|
1996
|
-
const error = new Error(ERR_INVALID_UNCOMPRESSED_SIZE);
|
|
1997
|
-
rejectTrailerReady(error);
|
|
1998
|
-
await cancel(reader, error);
|
|
1999
|
-
throw error;
|
|
2000
|
-
}
|
|
2001
|
-
if (outputCrc32) {
|
|
2002
|
-
outputCrc32.append(value);
|
|
2003
|
-
}
|
|
2004
|
-
controller.enqueue(value);
|
|
2005
|
-
}
|
|
2022
|
+
let settled = false;
|
|
2023
|
+
let resolvePull, controller;
|
|
2024
|
+
const output = new ReadableStream({
|
|
2025
|
+
start(streamController) {
|
|
2026
|
+
controller = streamController;
|
|
2027
|
+
},
|
|
2028
|
+
pull() {
|
|
2029
|
+
resumePump();
|
|
2006
2030
|
},
|
|
2007
2031
|
cancel(reason) {
|
|
2008
|
-
|
|
2032
|
+
settled = true;
|
|
2033
|
+
resumePump();
|
|
2009
2034
|
return reader.cancel(reason);
|
|
2010
2035
|
}
|
|
2011
2036
|
});
|
|
2037
|
+
pump();
|
|
2038
|
+
drain();
|
|
2039
|
+
return output;
|
|
2012
2040
|
|
|
2013
2041
|
async function pump() {
|
|
2014
2042
|
const inputReader = readable.getReader();
|
|
@@ -2017,19 +2045,16 @@
|
|
|
2017
2045
|
header.set(GZIP_HEADER_BYTES);
|
|
2018
2046
|
await writer.write(header);
|
|
2019
2047
|
for (; ;) {
|
|
2048
|
+
await outputCapacity();
|
|
2020
2049
|
await writer.ready;
|
|
2021
|
-
const { value, done } = await inputReader
|
|
2050
|
+
const { value, done } = await readSource(inputReader, sourceErrors);
|
|
2022
2051
|
if (done) {
|
|
2023
2052
|
break;
|
|
2024
2053
|
}
|
|
2025
2054
|
await writer.write(value);
|
|
2026
2055
|
}
|
|
2027
|
-
inputDone = true;
|
|
2028
2056
|
if (outputCrc32) {
|
|
2029
|
-
|
|
2030
|
-
armIdleCheck();
|
|
2031
|
-
}
|
|
2032
|
-
await trailerReady;
|
|
2057
|
+
await writer.write(new Uint8Array(0));
|
|
2033
2058
|
}
|
|
2034
2059
|
const trailer = new Uint8Array(GZIP_TRAILER_LENGTH);
|
|
2035
2060
|
const dataView = getDataView(trailer);
|
|
@@ -2044,54 +2069,68 @@
|
|
|
2044
2069
|
}
|
|
2045
2070
|
}
|
|
2046
2071
|
|
|
2047
|
-
function
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2072
|
+
async function drain() {
|
|
2073
|
+
try {
|
|
2074
|
+
for (; ;) {
|
|
2075
|
+
const { value, done } = await read();
|
|
2076
|
+
if (done) {
|
|
2077
|
+
break;
|
|
2078
|
+
}
|
|
2079
|
+
outputLength += value.length;
|
|
2080
|
+
if (outputLength > outputSize) {
|
|
2081
|
+
throw new Error(ERR_INVALID_UNCOMPRESSED_SIZE);
|
|
2082
|
+
}
|
|
2083
|
+
if (outputCrc32) {
|
|
2084
|
+
outputCrc32.append(value);
|
|
2085
|
+
}
|
|
2086
|
+
controller.enqueue(value);
|
|
2087
|
+
}
|
|
2088
|
+
if (!settled) {
|
|
2089
|
+
settled = true;
|
|
2090
|
+
controller.close();
|
|
2091
|
+
}
|
|
2092
|
+
} catch (error) {
|
|
2093
|
+
fail(error);
|
|
2094
|
+
await cancel(reader, error);
|
|
2054
2095
|
}
|
|
2055
|
-
return result;
|
|
2056
2096
|
}
|
|
2057
2097
|
|
|
2058
|
-
function
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
await nextTask();
|
|
2067
|
-
idleCheckArmed = false;
|
|
2068
|
-
if (readPending) {
|
|
2069
|
-
if (readCount == count) {
|
|
2070
|
-
resolveTrailerReady();
|
|
2071
|
-
} else {
|
|
2072
|
-
armIdleCheck();
|
|
2098
|
+
function read() {
|
|
2099
|
+
return reader.read().catch(error => {
|
|
2100
|
+
if (trailerWritten) {
|
|
2101
|
+
if (!outputCrc32) {
|
|
2102
|
+
throw mapError(error, ERR_INVALID_CRC32);
|
|
2103
|
+
}
|
|
2104
|
+
if (outputLength != outputSize) {
|
|
2105
|
+
throw mapError(error, ERR_INVALID_UNCOMPRESSED_SIZE);
|
|
2073
2106
|
}
|
|
2107
|
+
return { done: true };
|
|
2074
2108
|
}
|
|
2075
|
-
|
|
2109
|
+
throw mapCodecError(error, sourceErrors);
|
|
2110
|
+
});
|
|
2076
2111
|
}
|
|
2077
2112
|
|
|
2078
|
-
function
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2113
|
+
function outputCapacity() {
|
|
2114
|
+
if (!settled && controller.desiredSize <= 0) {
|
|
2115
|
+
return new Promise(resolve => resolvePull = resolve);
|
|
2116
|
+
}
|
|
2082
2117
|
}
|
|
2083
|
-
}
|
|
2084
2118
|
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
port1.close();
|
|
2090
|
-
port2.close();
|
|
2119
|
+
function resumePump() {
|
|
2120
|
+
if (resolvePull) {
|
|
2121
|
+
const resolve = resolvePull;
|
|
2122
|
+
resolvePull = UNDEFINED_VALUE;
|
|
2091
2123
|
resolve();
|
|
2092
|
-
}
|
|
2093
|
-
|
|
2094
|
-
|
|
2124
|
+
}
|
|
2125
|
+
}
|
|
2126
|
+
|
|
2127
|
+
function fail(error) {
|
|
2128
|
+
if (!settled) {
|
|
2129
|
+
settled = true;
|
|
2130
|
+
controller.error(error);
|
|
2131
|
+
resumePump();
|
|
2132
|
+
}
|
|
2133
|
+
}
|
|
2095
2134
|
}
|
|
2096
2135
|
|
|
2097
2136
|
class InflateStream extends TransformStream {
|
|
@@ -2110,11 +2149,12 @@
|
|
|
2110
2149
|
}
|
|
2111
2150
|
}
|
|
2112
2151
|
if (compressed) {
|
|
2152
|
+
const sourceErrors = new Set();
|
|
2113
2153
|
const codecStreams = format && getCodecStreams(format);
|
|
2154
|
+
let gzipStream;
|
|
2114
2155
|
if (codecStreams) {
|
|
2115
|
-
readable = pipeThroughBackpressured(readable, createCodecStream(codecStreams.DecompressionStream, format, { chunkSize, compressionMethod, rawBitFlag, uncompressedSize: outputSize }));
|
|
2156
|
+
readable = pipeThroughBackpressured(readable, createCodecStream(codecStreams.DecompressionStream, format, { chunkSize, compressionMethod, rawBitFlag, uncompressedSize: outputSize }), sourceErrors);
|
|
2116
2157
|
} else {
|
|
2117
|
-
let gzipStream;
|
|
2118
2158
|
const GzipDecompressionStream = getGzipCodecStream(useCompressionStream, DecompressionStream, DecompressionStreamFallback);
|
|
2119
2159
|
if (checkCrc32 && !deflate64 && crc32 !== UNDEFINED_VALUE && outputSize !== UNDEFINED_VALUE && GzipDecompressionStream) {
|
|
2120
2160
|
try {
|
|
@@ -2125,24 +2165,25 @@
|
|
|
2125
2165
|
}
|
|
2126
2166
|
if (!gzipStream) {
|
|
2127
2167
|
try {
|
|
2128
|
-
readable = pipeThroughCompressionStream(readable, useCompressionStream, { chunkSize, deflate64 }, DecompressionStream, DecompressionStreamFallback);
|
|
2168
|
+
readable = pipeThroughCompressionStream(readable, useCompressionStream, { chunkSize, deflate64 }, DecompressionStream, DecompressionStreamFallback, sourceErrors);
|
|
2129
2169
|
} catch (error) {
|
|
2130
2170
|
if (deflate64 || outputSize === UNDEFINED_VALUE || (!useCompressionStream && DecompressionStreamFallback)) {
|
|
2131
|
-
throw error;
|
|
2171
|
+
throw mapMemoryError(error);
|
|
2132
2172
|
}
|
|
2133
2173
|
try {
|
|
2134
2174
|
gzipStream = new DecompressionStream(FORMAT_GZIP$1);
|
|
2135
2175
|
} catch {
|
|
2136
|
-
throw error;
|
|
2176
|
+
throw mapMemoryError(error);
|
|
2137
2177
|
}
|
|
2138
2178
|
}
|
|
2139
2179
|
}
|
|
2140
|
-
if (gzipStream) {
|
|
2141
|
-
gzipCrc32 = true;
|
|
2142
|
-
readable = pipeThroughGzipDecompressionStream(readable, gzipStream, outputSize, crc32);
|
|
2143
|
-
}
|
|
2144
2180
|
}
|
|
2145
|
-
|
|
2181
|
+
if (gzipStream) {
|
|
2182
|
+
gzipCrc32 = true;
|
|
2183
|
+
readable = pipeThroughGzipDecompressionStream(readable, gzipStream, outputSize, crc32, sourceErrors);
|
|
2184
|
+
} else {
|
|
2185
|
+
readable = mapInflateStreamError(readable, sourceErrors);
|
|
2186
|
+
}
|
|
2146
2187
|
}
|
|
2147
2188
|
if (checkCrc32 && !gzipCrc32) {
|
|
2148
2189
|
crc32Stream = new Crc32Stream();
|
|
@@ -2215,7 +2256,7 @@
|
|
|
2215
2256
|
}
|
|
2216
2257
|
}
|
|
2217
2258
|
|
|
2218
|
-
function pipeThroughCompressionStream(readable, useCompressionStream, options, CompressionStreamNative, CompressionStreamFallback) {
|
|
2259
|
+
function pipeThroughCompressionStream(readable, useCompressionStream, options, CompressionStreamNative, CompressionStreamFallback, sourceErrors) {
|
|
2219
2260
|
const Stream = useCompressionStream && CompressionStreamNative ?
|
|
2220
2261
|
CompressionStreamNative :
|
|
2221
2262
|
CompressionStreamFallback || CompressionStreamNative;
|
|
@@ -2230,14 +2271,14 @@
|
|
|
2230
2271
|
throw error;
|
|
2231
2272
|
}
|
|
2232
2273
|
}
|
|
2233
|
-
return pipeThroughBackpressured(readable, codecStream);
|
|
2274
|
+
return pipeThroughBackpressured(readable, codecStream, sourceErrors);
|
|
2234
2275
|
}
|
|
2235
2276
|
|
|
2236
2277
|
function pipeThrough(readable, transformStream) {
|
|
2237
2278
|
return toCompatibleReadable(readable).pipeThrough(transformStream);
|
|
2238
2279
|
}
|
|
2239
2280
|
|
|
2240
|
-
function pipeThroughBackpressured(readable, transformStream) {
|
|
2281
|
+
function pipeThroughBackpressured(readable, transformStream, sourceErrors) {
|
|
2241
2282
|
const writer = transformStream.writable.getWriter();
|
|
2242
2283
|
const reader = readable.getReader();
|
|
2243
2284
|
pump();
|
|
@@ -2247,7 +2288,7 @@
|
|
|
2247
2288
|
try {
|
|
2248
2289
|
for (; ;) {
|
|
2249
2290
|
await writer.ready;
|
|
2250
|
-
const result = await reader
|
|
2291
|
+
const result = await readSource(reader, sourceErrors);
|
|
2251
2292
|
if (result.done) {
|
|
2252
2293
|
await writer.close();
|
|
2253
2294
|
break;
|
|
@@ -2277,26 +2318,49 @@
|
|
|
2277
2318
|
}
|
|
2278
2319
|
}
|
|
2279
2320
|
|
|
2280
|
-
function
|
|
2321
|
+
function readSource(reader, sourceErrors) {
|
|
2322
|
+
const result = reader.read();
|
|
2323
|
+
return sourceErrors ? result.catch(error => {
|
|
2324
|
+
sourceErrors.add(error);
|
|
2325
|
+
throw error;
|
|
2326
|
+
}) : result;
|
|
2327
|
+
}
|
|
2328
|
+
|
|
2329
|
+
function mapCodecError(error, sourceErrors) {
|
|
2330
|
+
if (sourceErrors.has(error)) {
|
|
2331
|
+
return error;
|
|
2332
|
+
}
|
|
2333
|
+
return mapError(error, isMemoryError(error) ? ERR_CODEC_OUT_OF_MEMORY : ERR_INVALID_COMPRESSED_DATA);
|
|
2334
|
+
}
|
|
2335
|
+
|
|
2336
|
+
function mapMemoryError(error) {
|
|
2337
|
+
return isMemoryError(error) ? mapError(error, ERR_CODEC_OUT_OF_MEMORY) : error;
|
|
2338
|
+
}
|
|
2339
|
+
|
|
2340
|
+
function isMemoryError(error) {
|
|
2341
|
+
return isErrorObject(error) && error.code == Z_MEM_ERROR_CODE$1;
|
|
2342
|
+
}
|
|
2343
|
+
|
|
2344
|
+
function mapError(error, message) {
|
|
2345
|
+
const mappedError = new Error(message);
|
|
2346
|
+
mappedError.cause = error;
|
|
2347
|
+
return mappedError;
|
|
2348
|
+
}
|
|
2349
|
+
|
|
2350
|
+
function mapInflateStreamError(readable, sourceErrors) {
|
|
2281
2351
|
const reader = readable.getReader();
|
|
2282
2352
|
return new ReadableStream({
|
|
2283
2353
|
async pull(controller) {
|
|
2284
|
-
let result;
|
|
2285
2354
|
try {
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2355
|
+
const { value, done } = await reader.read();
|
|
2356
|
+
if (done) {
|
|
2357
|
+
controller.close();
|
|
2358
|
+
} else {
|
|
2359
|
+
controller.enqueue(value);
|
|
2290
2360
|
}
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
throw
|
|
2294
|
-
}
|
|
2295
|
-
const { value, done } = result;
|
|
2296
|
-
if (done) {
|
|
2297
|
-
controller.close();
|
|
2298
|
-
} else {
|
|
2299
|
-
controller.enqueue(value);
|
|
2361
|
+
} catch (error) {
|
|
2362
|
+
await cancel(reader, error);
|
|
2363
|
+
throw mapCodecError(error, sourceErrors);
|
|
2300
2364
|
}
|
|
2301
2365
|
},
|
|
2302
2366
|
cancel(reason) {
|
|
@@ -2664,10 +2728,11 @@
|
|
|
2664
2728
|
}
|
|
2665
2729
|
codecStream = new CodecStream(options, config);
|
|
2666
2730
|
chunkStream = new ChunkStream(getChunkSize(config));
|
|
2731
|
+
const { signal } = workerOptions.streamOptions;
|
|
2667
2732
|
await readable
|
|
2668
2733
|
.pipeThrough(codecStream)
|
|
2669
2734
|
.pipeThrough(chunkStream)
|
|
2670
|
-
.pipeTo(writable, { preventClose: true, preventAbort: true });
|
|
2735
|
+
.pipeTo(writable, { preventClose: true, preventAbort: true, signal });
|
|
2671
2736
|
const {
|
|
2672
2737
|
crc32,
|
|
2673
2738
|
inputSize,
|
|
@@ -2735,6 +2800,7 @@
|
|
|
2735
2800
|
const MODULE_WORKER_OPTIONS = { type: "module" };
|
|
2736
2801
|
const ERROR_EVENT_TYPE = "error";
|
|
2737
2802
|
const MESSAGE_ERROR_EVENT_TYPE = "messageerror";
|
|
2803
|
+
const ABORT_EVENT_TYPE = "abort";
|
|
2738
2804
|
|
|
2739
2805
|
let webWorkerSource, webWorkerURI, webWorkerOptions;
|
|
2740
2806
|
let transferStreamsSupported = true;
|
|
@@ -2911,6 +2977,13 @@
|
|
|
2911
2977
|
Object.assign(workerData, { destinationFailed: true, destinationError: error });
|
|
2912
2978
|
}
|
|
2913
2979
|
});
|
|
2980
|
+
const { signal } = workerData.workerOptions.streamOptions;
|
|
2981
|
+
if (signal) {
|
|
2982
|
+
const onAbort = () => abortController.abort(signal.reason);
|
|
2983
|
+
const removeAbortListener = () => signal.removeEventListener(ABORT_EVENT_TYPE, onAbort);
|
|
2984
|
+
signal.addEventListener(ABORT_EVENT_TYPE, onAbort);
|
|
2985
|
+
closed.then(removeAbortListener, removeAbortListener);
|
|
2986
|
+
}
|
|
2914
2987
|
return {
|
|
2915
2988
|
writable, closed, abortPipe: () => {
|
|
2916
2989
|
aborting = true;
|
|
@@ -3173,9 +3246,6 @@
|
|
|
3173
3246
|
responseError = errorValue.value;
|
|
3174
3247
|
} else {
|
|
3175
3248
|
responseError = Object.assign(new Error(message), { stack, code, name });
|
|
3176
|
-
if (cause) {
|
|
3177
|
-
responseError.cause = Object.assign(new Error(cause.message), { name: cause.name });
|
|
3178
|
-
}
|
|
3179
3249
|
}
|
|
3180
3250
|
if (isErrorObject(responseError)) {
|
|
3181
3251
|
try {
|
|
@@ -3185,6 +3255,9 @@
|
|
|
3185
3255
|
if (codecImportFailed) {
|
|
3186
3256
|
responseError.codecImportFailed = true;
|
|
3187
3257
|
}
|
|
3258
|
+
if (cause && !isErrorObject(responseError.cause)) {
|
|
3259
|
+
responseError.cause = Object.assign(new Error(cause.message), { name: cause.name });
|
|
3260
|
+
}
|
|
3188
3261
|
if (errorValue) {
|
|
3189
3262
|
if (responseError.name !== name) {
|
|
3190
3263
|
responseError.name = name;
|
|
@@ -5356,8 +5429,8 @@
|
|
|
5356
5429
|
const passThroughCompression = Boolean(passThrough);
|
|
5357
5430
|
const passThroughEncryption = passThrough === true;
|
|
5358
5431
|
checkPasswordOption(password, rawPassword);
|
|
5359
|
-
password = password && password.length
|
|
5360
|
-
rawPassword = rawPassword && rawPassword.length
|
|
5432
|
+
password = password && password.length ? password : UNDEFINED_VALUE;
|
|
5433
|
+
rawPassword = rawPassword && rawPassword.length ? rawPassword : UNDEFINED_VALUE;
|
|
5361
5434
|
if (extraFieldAES) {
|
|
5362
5435
|
if (extraFieldAES.originalCompressionMethod != COMPRESSION_METHOD_AES) {
|
|
5363
5436
|
throw new Error(ERR_UNSUPPORTED_COMPRESSION);
|
|
@@ -5507,6 +5580,7 @@
|
|
|
5507
5580
|
({ writable } = writer);
|
|
5508
5581
|
const readable = toCompatibleReadable(reader.createReadable({ offset: dataOffset, size }));
|
|
5509
5582
|
const { outputSize: writtenSize } = await runWorker({ readable, writable }, workerOptions);
|
|
5583
|
+
throwIfAborted(signal);
|
|
5510
5584
|
if (writtenSize != outputSize) {
|
|
5511
5585
|
throw Object.assign(new Error(ERR_INVALID_UNCOMPRESSED_SIZE), { outputSize: writtenSize });
|
|
5512
5586
|
}
|
|
@@ -6118,7 +6192,7 @@
|
|
|
6118
6192
|
async function findEndOfCentralDirectory(reader, rejectAmbiguous, maxAppendedDataSize) {
|
|
6119
6193
|
const { size } = reader;
|
|
6120
6194
|
const anchoredLength = Math.min(size, END_OF_CENTRAL_DIR_LENGTH + MAX_16_BITS);
|
|
6121
|
-
const remoteProbeBudget = {
|
|
6195
|
+
const remoteProbeBudget = { remaining: MAX_END_OF_CENTRAL_DIR_PROBES };
|
|
6122
6196
|
let endOfDirectoryInfo;
|
|
6123
6197
|
let plausibleEndOfDirectoryInfo;
|
|
6124
6198
|
let endOfDirectoryReachingEndCount = 0;
|
|
@@ -6211,8 +6285,8 @@
|
|
|
6211
6285
|
if (signatureOffset >= anchoredOffset) {
|
|
6212
6286
|
return getUint32$1(view, signatureOffset - anchoredOffset);
|
|
6213
6287
|
}
|
|
6214
|
-
if (remoteProbeBudget.
|
|
6215
|
-
remoteProbeBudget.
|
|
6288
|
+
if (remoteProbeBudget.remaining > 0) {
|
|
6289
|
+
remoteProbeBudget.remaining--;
|
|
6216
6290
|
const signatureArray = await readUint8Array(reader, signatureOffset, 4);
|
|
6217
6291
|
return getUint32$1(getDataView(signatureArray), 0);
|
|
6218
6292
|
}
|
|
@@ -6302,6 +6376,7 @@
|
|
|
6302
6376
|
ERR_AMBIGUOUS_ARCHIVE: ERR_AMBIGUOUS_ARCHIVE,
|
|
6303
6377
|
ERR_BAD_FORMAT: ERR_BAD_FORMAT,
|
|
6304
6378
|
ERR_CENTRAL_DIRECTORY_NOT_FOUND: ERR_CENTRAL_DIRECTORY_NOT_FOUND,
|
|
6379
|
+
ERR_CODEC_OUT_OF_MEMORY: ERR_CODEC_OUT_OF_MEMORY,
|
|
6305
6380
|
ERR_ENCRYPTED: ERR_ENCRYPTED,
|
|
6306
6381
|
ERR_ENCRYPTED_CENTRAL_DIRECTORY: ERR_ENCRYPTED_CENTRAL_DIRECTORY,
|
|
6307
6382
|
ERR_ENTRY_DATA_OUT_OF_BOUNDS: ERR_ENTRY_DATA_OUT_OF_BOUNDS,
|
|
@@ -7128,9 +7203,11 @@
|
|
|
7128
7203
|
const passThrough = checkPassThroughOption(getOptionValue(zipWriter, options, OPTION_PASS_THROUGH));
|
|
7129
7204
|
const passThroughCompression = Boolean(passThrough);
|
|
7130
7205
|
const passThroughEncryption = passThrough === true;
|
|
7131
|
-
|
|
7132
|
-
|
|
7206
|
+
let password = getOptionValue(zipWriter, options, OPTION_PASSWORD);
|
|
7207
|
+
let rawPassword = getOptionValue(zipWriter, options, OPTION_RAW_PASSWORD);
|
|
7133
7208
|
checkPasswordOption(password, rawPassword);
|
|
7209
|
+
password = password && password.length ? password : UNDEFINED_VALUE;
|
|
7210
|
+
rawPassword = rawPassword && rawPassword.length ? rawPassword : UNDEFINED_VALUE;
|
|
7134
7211
|
const encryptionStrength = getNumberOptionValue(zipWriter, options, OPTION_ENCRYPTION_STRENGTH, 3);
|
|
7135
7212
|
const zipCrypto = getOptionValue(zipWriter, options, PROPERTY_NAME_ZIPCRYPTO);
|
|
7136
7213
|
const extendedTimestamp = getOptionValue(zipWriter, options, OPTION_EXTENDED_TIMESTAMP, true);
|
|
@@ -7649,6 +7726,7 @@
|
|
|
7649
7726
|
const result = await runWorker({ readable, writable }, workerOptions);
|
|
7650
7727
|
compressedSize = result.outputSize;
|
|
7651
7728
|
writer.size += compressedSize;
|
|
7729
|
+
throwIfAborted(signal);
|
|
7652
7730
|
if (!passThroughCompression) {
|
|
7653
7731
|
uncompressedSize = result.inputSize;
|
|
7654
7732
|
if (!encrypted || zipCrypto) {
|
|
@@ -8828,7 +8906,7 @@
|
|
|
8828
8906
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
8829
8907
|
*/
|
|
8830
8908
|
|
|
8831
|
-
const VERSION = "2.
|
|
8909
|
+
const VERSION = "2.17.0";
|
|
8832
8910
|
|
|
8833
8911
|
/*
|
|
8834
8912
|
Copyright (c) 2025 Gildas Lormeau. All rights reserved.
|
|
@@ -9307,12 +9385,16 @@
|
|
|
9307
9385
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
9308
9386
|
*/
|
|
9309
9387
|
|
|
9310
|
-
/* global
|
|
9388
|
+
/* global ReadableStream, WritableStream */
|
|
9311
9389
|
|
|
9312
9390
|
const FORMAT_DEFLATE = "deflate";
|
|
9313
9391
|
const FORMAT_DEFLATE_RAW = "deflate-raw";
|
|
9314
9392
|
const FORMAT_DEFLATE64_RAW = "deflate64-raw";
|
|
9315
9393
|
const FORMAT_GZIP = "gzip";
|
|
9394
|
+
const Z_MEM_ERROR = -4;
|
|
9395
|
+
const Z_MEM_ERROR_CODE = "Z_MEM_ERROR";
|
|
9396
|
+
const COMPRESSION_FORMATS = [FORMAT_DEFLATE, FORMAT_DEFLATE_RAW, FORMAT_GZIP];
|
|
9397
|
+
const DECOMPRESSION_FORMATS = [FORMAT_DEFLATE, FORMAT_DEFLATE_RAW, FORMAT_GZIP, FORMAT_DEFLATE64_RAW];
|
|
9316
9398
|
|
|
9317
9399
|
let wasm$1, malloc, free, memory, initError;
|
|
9318
9400
|
|
|
@@ -9333,7 +9415,17 @@
|
|
|
9333
9415
|
wasm$1 = malloc = free = memory = initError = null;
|
|
9334
9416
|
}
|
|
9335
9417
|
|
|
9418
|
+
function setZlibCode(error, result) {
|
|
9419
|
+
if (result === Z_MEM_ERROR) {
|
|
9420
|
+
error.code = Z_MEM_ERROR_CODE;
|
|
9421
|
+
}
|
|
9422
|
+
return error;
|
|
9423
|
+
}
|
|
9424
|
+
|
|
9336
9425
|
function _make(isCompress, type, options = {}) {
|
|
9426
|
+
if (!(isCompress ? COMPRESSION_FORMATS : DECOMPRESSION_FORMATS).includes(type)) {
|
|
9427
|
+
throw new TypeError("Unsupported format: " + type);
|
|
9428
|
+
}
|
|
9337
9429
|
if (!wasm$1) {
|
|
9338
9430
|
const error = new Error("WASM module not loaded");
|
|
9339
9431
|
error.cause = initError;
|
|
@@ -9342,137 +9434,200 @@
|
|
|
9342
9434
|
const level = (typeof options.level === "number") ? options.level : -1;
|
|
9343
9435
|
const outBufferSize = (typeof options.outBuffer === "number") ? options.outBuffer : 64 * 1024;
|
|
9344
9436
|
const inBufferSize = (typeof options.inBufferSize === "number") ? options.inBufferSize : 64 * 1024;
|
|
9345
|
-
|
|
9346
|
-
|
|
9347
|
-
|
|
9437
|
+
const state = { out: 0, in: 0, inBufferSize: 0, streamHandle: 0, streamEnded: false };
|
|
9438
|
+
let readableController, writableController, resolveWrite, cancelReason;
|
|
9439
|
+
let backpressure = true;
|
|
9440
|
+
let cancelled = false;
|
|
9441
|
+
initStream();
|
|
9442
|
+
const readable = new ReadableStream({
|
|
9443
|
+
start(controller) {
|
|
9444
|
+
readableController = controller;
|
|
9445
|
+
},
|
|
9446
|
+
pull() {
|
|
9447
|
+
backpressure = false;
|
|
9448
|
+
resumeWrite();
|
|
9449
|
+
},
|
|
9450
|
+
cancel(reason) {
|
|
9451
|
+
cancelled = true;
|
|
9452
|
+
cancelReason = reason;
|
|
9453
|
+
disposeStream(state);
|
|
9454
|
+
writableController.error(reason);
|
|
9455
|
+
resumeWrite();
|
|
9456
|
+
}
|
|
9457
|
+
}, { highWaterMark: 0 });
|
|
9458
|
+
const writable = new WritableStream({
|
|
9459
|
+
start(controller) {
|
|
9460
|
+
writableController = controller;
|
|
9461
|
+
},
|
|
9462
|
+
async write(chunk) {
|
|
9463
|
+
if (backpressure) {
|
|
9464
|
+
await new Promise(resolve => resolveWrite = resolve);
|
|
9465
|
+
}
|
|
9466
|
+
if (cancelled) {
|
|
9467
|
+
throw cancelReason;
|
|
9468
|
+
}
|
|
9348
9469
|
try {
|
|
9349
|
-
|
|
9350
|
-
this.out = malloc(outBufferSize);
|
|
9351
|
-
this.in = malloc(inBufferSize);
|
|
9352
|
-
this.inBufferSize = inBufferSize;
|
|
9353
|
-
if (!this.out || !this.in) {
|
|
9354
|
-
throw new Error("allocation failed");
|
|
9355
|
-
}
|
|
9356
|
-
if (isCompress) {
|
|
9357
|
-
this._process = wasm$1.deflate_process;
|
|
9358
|
-
this._last_consumed = wasm$1.deflate_last_consumed;
|
|
9359
|
-
this._end = wasm$1.deflate_end;
|
|
9360
|
-
this.streamHandle = wasm$1.deflate_new();
|
|
9361
|
-
if (type === FORMAT_GZIP) {
|
|
9362
|
-
result = wasm$1.deflate_init_gzip(this.streamHandle, level);
|
|
9363
|
-
} else if (type === FORMAT_DEFLATE_RAW) {
|
|
9364
|
-
result = wasm$1.deflate_init_raw(this.streamHandle, level);
|
|
9365
|
-
} else {
|
|
9366
|
-
result = wasm$1.deflate_init(this.streamHandle, level);
|
|
9367
|
-
}
|
|
9368
|
-
} else {
|
|
9369
|
-
if (type === FORMAT_DEFLATE64_RAW) {
|
|
9370
|
-
this._process = wasm$1.inflate9_process;
|
|
9371
|
-
this._last_consumed = wasm$1.inflate9_last_consumed;
|
|
9372
|
-
this._end = wasm$1.inflate9_end;
|
|
9373
|
-
this.streamHandle = wasm$1.inflate9_new();
|
|
9374
|
-
result = wasm$1.inflate9_init_raw(this.streamHandle);
|
|
9375
|
-
} else {
|
|
9376
|
-
this._process = wasm$1.inflate_process;
|
|
9377
|
-
this._last_consumed = wasm$1.inflate_last_consumed;
|
|
9378
|
-
this._end = wasm$1.inflate_end;
|
|
9379
|
-
this.streamHandle = wasm$1.inflate_new();
|
|
9380
|
-
if (type === FORMAT_DEFLATE_RAW) {
|
|
9381
|
-
result = wasm$1.inflate_init_raw(this.streamHandle);
|
|
9382
|
-
} else if (type === FORMAT_GZIP) {
|
|
9383
|
-
result = wasm$1.inflate_init_gzip(this.streamHandle);
|
|
9384
|
-
} else {
|
|
9385
|
-
result = wasm$1.inflate_init(this.streamHandle);
|
|
9386
|
-
}
|
|
9387
|
-
}
|
|
9388
|
-
}
|
|
9389
|
-
if (result !== 0) {
|
|
9390
|
-
throw new Error("init failed:" + result);
|
|
9391
|
-
}
|
|
9470
|
+
processChunk(chunk);
|
|
9392
9471
|
} catch (error) {
|
|
9393
|
-
disposeStream(
|
|
9472
|
+
disposeStream(state);
|
|
9473
|
+
readableController.error(error);
|
|
9394
9474
|
throw error;
|
|
9395
9475
|
}
|
|
9396
9476
|
},
|
|
9397
|
-
|
|
9477
|
+
close() {
|
|
9478
|
+
if (cancelled) {
|
|
9479
|
+
return;
|
|
9480
|
+
}
|
|
9398
9481
|
try {
|
|
9399
|
-
|
|
9400
|
-
const heap = new Uint8Array(memory.buffer);
|
|
9401
|
-
const process = this._process;
|
|
9402
|
-
const last_consumed = this._last_consumed;
|
|
9403
|
-
const out = this.out;
|
|
9404
|
-
let offset = 0;
|
|
9405
|
-
while (offset < buffer.length) {
|
|
9406
|
-
const toRead = Math.min(buffer.length - offset, 32 * 1024);
|
|
9407
|
-
if (!this.in || this.inBufferSize < toRead) {
|
|
9408
|
-
if (this.in && free) {
|
|
9409
|
-
free(this.in);
|
|
9410
|
-
this.in = 0;
|
|
9411
|
-
}
|
|
9412
|
-
this.in = malloc(toRead);
|
|
9413
|
-
this.inBufferSize = toRead;
|
|
9414
|
-
if (!this.in) {
|
|
9415
|
-
throw new Error("allocation failed");
|
|
9416
|
-
}
|
|
9417
|
-
}
|
|
9418
|
-
heap.set(buffer.subarray(offset, offset + toRead), this.in);
|
|
9419
|
-
const result = process(this.streamHandle, this.in, toRead, out, outBufferSize, 0);
|
|
9420
|
-
// checked before the byte count is used, so a status code can never be read as one
|
|
9421
|
-
const code = (result >> 24) & 0xff;
|
|
9422
|
-
const signedCode = (code & 0x80) ? code - 256 : code;
|
|
9423
|
-
if (signedCode < 0) {
|
|
9424
|
-
throw new Error("process error:" + signedCode);
|
|
9425
|
-
}
|
|
9426
|
-
const prod = result & 0x00ffffff;
|
|
9427
|
-
if (prod) {
|
|
9428
|
-
controller.enqueue(heap.slice(out, out + prod));
|
|
9429
|
-
}
|
|
9430
|
-
const consumed = last_consumed(this.streamHandle);
|
|
9431
|
-
if (consumed === 0 && prod === 0) {
|
|
9432
|
-
break;
|
|
9433
|
-
}
|
|
9434
|
-
offset += consumed;
|
|
9435
|
-
}
|
|
9482
|
+
flushStream();
|
|
9436
9483
|
} catch (error) {
|
|
9437
|
-
disposeStream(
|
|
9438
|
-
|
|
9484
|
+
disposeStream(state);
|
|
9485
|
+
readableController.error(error);
|
|
9486
|
+
throw error;
|
|
9439
9487
|
}
|
|
9488
|
+
const result = disposeStream(state);
|
|
9489
|
+
if (result !== 0) {
|
|
9490
|
+
const error = setZlibCode(new Error("end error:" + result), result);
|
|
9491
|
+
readableController.error(error);
|
|
9492
|
+
throw error;
|
|
9493
|
+
}
|
|
9494
|
+
readableController.close();
|
|
9440
9495
|
},
|
|
9441
|
-
|
|
9442
|
-
|
|
9443
|
-
|
|
9444
|
-
|
|
9445
|
-
|
|
9446
|
-
|
|
9447
|
-
|
|
9448
|
-
|
|
9449
|
-
|
|
9450
|
-
|
|
9451
|
-
|
|
9452
|
-
|
|
9453
|
-
|
|
9454
|
-
|
|
9455
|
-
|
|
9456
|
-
|
|
9457
|
-
|
|
9458
|
-
|
|
9496
|
+
abort(reason) {
|
|
9497
|
+
disposeStream(state);
|
|
9498
|
+
readableController.error(reason);
|
|
9499
|
+
}
|
|
9500
|
+
}, { highWaterMark: 1 });
|
|
9501
|
+
return { readable, writable };
|
|
9502
|
+
|
|
9503
|
+
function initStream() {
|
|
9504
|
+
try {
|
|
9505
|
+
let result;
|
|
9506
|
+
state.out = malloc(outBufferSize);
|
|
9507
|
+
state.in = malloc(inBufferSize);
|
|
9508
|
+
state.inBufferSize = inBufferSize;
|
|
9509
|
+
if (!state.out || !state.in) {
|
|
9510
|
+
throw setZlibCode(new Error("allocation failed"), Z_MEM_ERROR);
|
|
9511
|
+
}
|
|
9512
|
+
if (isCompress) {
|
|
9513
|
+
state._process = wasm$1.deflate_process;
|
|
9514
|
+
state._last_consumed = wasm$1.deflate_last_consumed;
|
|
9515
|
+
state._end = wasm$1.deflate_end;
|
|
9516
|
+
state.streamHandle = wasm$1.deflate_new();
|
|
9517
|
+
if (type === FORMAT_GZIP) {
|
|
9518
|
+
result = wasm$1.deflate_init_gzip(state.streamHandle, level);
|
|
9519
|
+
} else if (type === FORMAT_DEFLATE_RAW) {
|
|
9520
|
+
result = wasm$1.deflate_init_raw(state.streamHandle, level);
|
|
9521
|
+
} else {
|
|
9522
|
+
result = wasm$1.deflate_init(state.streamHandle, level);
|
|
9523
|
+
}
|
|
9524
|
+
} else {
|
|
9525
|
+
if (type === FORMAT_DEFLATE64_RAW) {
|
|
9526
|
+
state._process = wasm$1.inflate9_process;
|
|
9527
|
+
state._last_consumed = wasm$1.inflate9_last_consumed;
|
|
9528
|
+
state._end = wasm$1.inflate9_end;
|
|
9529
|
+
state.streamHandle = wasm$1.inflate9_new();
|
|
9530
|
+
result = wasm$1.inflate9_init_raw(state.streamHandle);
|
|
9531
|
+
} else {
|
|
9532
|
+
state._process = wasm$1.inflate_process;
|
|
9533
|
+
state._last_consumed = wasm$1.inflate_last_consumed;
|
|
9534
|
+
state._end = wasm$1.inflate_end;
|
|
9535
|
+
state.streamHandle = wasm$1.inflate_new();
|
|
9536
|
+
if (type === FORMAT_DEFLATE_RAW) {
|
|
9537
|
+
result = wasm$1.inflate_init_raw(state.streamHandle);
|
|
9538
|
+
} else if (type === FORMAT_GZIP) {
|
|
9539
|
+
result = wasm$1.inflate_init_gzip(state.streamHandle);
|
|
9540
|
+
} else {
|
|
9541
|
+
result = wasm$1.inflate_init(state.streamHandle);
|
|
9459
9542
|
}
|
|
9460
9543
|
}
|
|
9461
|
-
}
|
|
9462
|
-
|
|
9463
|
-
|
|
9464
|
-
|
|
9465
|
-
|
|
9466
|
-
|
|
9544
|
+
}
|
|
9545
|
+
if (result !== 0) {
|
|
9546
|
+
throw setZlibCode(new Error("init failed:" + result), result);
|
|
9547
|
+
}
|
|
9548
|
+
} catch (error) {
|
|
9549
|
+
disposeStream(state);
|
|
9550
|
+
throw error;
|
|
9551
|
+
}
|
|
9552
|
+
}
|
|
9553
|
+
|
|
9554
|
+
function processChunk(chunk) {
|
|
9555
|
+
const heap = new Uint8Array(memory.buffer);
|
|
9556
|
+
const process = state._process;
|
|
9557
|
+
const last_consumed = state._last_consumed;
|
|
9558
|
+
const out = state.out;
|
|
9559
|
+
let offset = 0;
|
|
9560
|
+
while (offset < chunk.length) {
|
|
9561
|
+
if (state.streamEnded) {
|
|
9562
|
+
throw new Error("trailing data after the end of the stream");
|
|
9563
|
+
}
|
|
9564
|
+
const toRead = Math.min(chunk.length - offset, 32 * 1024);
|
|
9565
|
+
if (!state.in || state.inBufferSize < toRead) {
|
|
9566
|
+
if (state.in && free) {
|
|
9567
|
+
free(state.in);
|
|
9568
|
+
state.in = 0;
|
|
9569
|
+
}
|
|
9570
|
+
state.in = malloc(toRead);
|
|
9571
|
+
state.inBufferSize = toRead;
|
|
9572
|
+
if (!state.in) {
|
|
9573
|
+
throw setZlibCode(new Error("allocation failed"), Z_MEM_ERROR);
|
|
9467
9574
|
}
|
|
9468
9575
|
}
|
|
9469
|
-
|
|
9470
|
-
|
|
9471
|
-
//
|
|
9472
|
-
|
|
9473
|
-
|
|
9576
|
+
heap.set(chunk.subarray(offset, offset + toRead), state.in);
|
|
9577
|
+
const result = process(state.streamHandle, state.in, toRead, out, outBufferSize, 0);
|
|
9578
|
+
// checked before the byte count is used, so a status code can never be read as one
|
|
9579
|
+
const code = (result >> 24) & 0xff;
|
|
9580
|
+
const signedCode = (code & 0x80) ? code - 256 : code;
|
|
9581
|
+
if (signedCode < 0) {
|
|
9582
|
+
throw setZlibCode(new Error("process error:" + signedCode), signedCode);
|
|
9583
|
+
}
|
|
9584
|
+
const prod = result & 0x00ffffff;
|
|
9585
|
+
if (prod) {
|
|
9586
|
+
enqueue(heap.slice(out, out + prod));
|
|
9587
|
+
}
|
|
9588
|
+
const consumed = last_consumed(state.streamHandle);
|
|
9589
|
+
if (code === 1) {
|
|
9590
|
+
state.streamEnded = true;
|
|
9591
|
+
} else if (consumed === 0 && prod === 0) {
|
|
9592
|
+
break;
|
|
9593
|
+
}
|
|
9594
|
+
offset += consumed;
|
|
9474
9595
|
}
|
|
9475
|
-
}
|
|
9596
|
+
}
|
|
9597
|
+
|
|
9598
|
+
function flushStream() {
|
|
9599
|
+
const heap = new Uint8Array(memory.buffer);
|
|
9600
|
+
const process = state._process;
|
|
9601
|
+
const out = state.out;
|
|
9602
|
+
while (true) {
|
|
9603
|
+
const result = process(state.streamHandle, 0, 0, out, outBufferSize, 4);
|
|
9604
|
+
const code = (result >> 24) & 0xff;
|
|
9605
|
+
const signedCode = (code & 0x80) ? code - 256 : code;
|
|
9606
|
+
if (signedCode < 0) {
|
|
9607
|
+
throw setZlibCode(new Error("process error:" + signedCode), signedCode);
|
|
9608
|
+
}
|
|
9609
|
+
const produced = result & 0x00ffffff;
|
|
9610
|
+
if (produced) {
|
|
9611
|
+
enqueue(heap.slice(out, out + produced));
|
|
9612
|
+
}
|
|
9613
|
+
if (code === 1 || produced === 0) {
|
|
9614
|
+
break;
|
|
9615
|
+
}
|
|
9616
|
+
}
|
|
9617
|
+
}
|
|
9618
|
+
|
|
9619
|
+
function enqueue(chunk) {
|
|
9620
|
+
backpressure = true;
|
|
9621
|
+
readableController.enqueue(chunk);
|
|
9622
|
+
}
|
|
9623
|
+
|
|
9624
|
+
function resumeWrite() {
|
|
9625
|
+
if (resolveWrite) {
|
|
9626
|
+
const resolve = resolveWrite;
|
|
9627
|
+
resolveWrite = null;
|
|
9628
|
+
resolve();
|
|
9629
|
+
}
|
|
9630
|
+
}
|
|
9476
9631
|
|
|
9477
9632
|
function disposeStream(state) {
|
|
9478
9633
|
let endResult = 0;
|
|
@@ -9508,10 +9663,10 @@
|
|
|
9508
9663
|
CompressionStreamZlib.requiresModule = true;
|
|
9509
9664
|
DecompressionStreamZlib.requiresModule = true;
|
|
9510
9665
|
// Constructing these classes before the module is loaded throws, so capability probes cannot rely
|
|
9511
|
-
// on trying the constructor; the formats are declared instead,
|
|
9512
|
-
//
|
|
9513
|
-
CompressionStreamZlib.supportedFormats =
|
|
9514
|
-
DecompressionStreamZlib.supportedFormats =
|
|
9666
|
+
// on trying the constructor; the formats are declared instead, the lists _make() checks a format
|
|
9667
|
+
// against before anything else.
|
|
9668
|
+
CompressionStreamZlib.supportedFormats = COMPRESSION_FORMATS;
|
|
9669
|
+
DecompressionStreamZlib.supportedFormats = DECOMPRESSION_FORMATS;
|
|
9515
9670
|
|
|
9516
9671
|
/*
|
|
9517
9672
|
Copyright (c) 2026 Gildas Lormeau. All rights reserved.
|
|
@@ -9823,6 +9978,7 @@
|
|
|
9823
9978
|
exports.ERR_AMBIGUOUS_ARCHIVE = ERR_AMBIGUOUS_ARCHIVE;
|
|
9824
9979
|
exports.ERR_BAD_FORMAT = ERR_BAD_FORMAT;
|
|
9825
9980
|
exports.ERR_CENTRAL_DIRECTORY_NOT_FOUND = ERR_CENTRAL_DIRECTORY_NOT_FOUND;
|
|
9981
|
+
exports.ERR_CODEC_OUT_OF_MEMORY = ERR_CODEC_OUT_OF_MEMORY;
|
|
9826
9982
|
exports.ERR_DUPLICATED_NAME = ERR_DUPLICATED_NAME;
|
|
9827
9983
|
exports.ERR_ENCRYPTED = ERR_ENCRYPTED;
|
|
9828
9984
|
exports.ERR_ENCRYPTED_CENTRAL_DIRECTORY = ERR_ENCRYPTED_CENTRAL_DIRECTORY;
|