@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-fs.js
CHANGED
|
@@ -223,7 +223,7 @@
|
|
|
223
223
|
const ERR_INVALID_PASSWORD_TYPE = "Invalid password (password must be a string, rawPassword must be a Uint8Array)";
|
|
224
224
|
const ERR_INVALID_PASS_THROUGH_VALUE = "Invalid passThrough option (must be a boolean or 'compressed')";
|
|
225
225
|
const ERR_ABORTED = "The operation was aborted";
|
|
226
|
-
const ABORT_ERROR_NAME = "AbortError";
|
|
226
|
+
const ABORT_ERROR_NAME$1 = "AbortError";
|
|
227
227
|
|
|
228
228
|
function checkFunctionOption(value) {
|
|
229
229
|
if (value && typeof value != FUNCTION_TYPE) {
|
|
@@ -241,7 +241,7 @@
|
|
|
241
241
|
|
|
242
242
|
function throwIfAborted(signal) {
|
|
243
243
|
if (signal && signal.aborted) {
|
|
244
|
-
throw signal.reason === UNDEFINED_VALUE ? new DOMException(ERR_ABORTED, ABORT_ERROR_NAME) : signal.reason;
|
|
244
|
+
throw signal.reason === UNDEFINED_VALUE ? new DOMException(ERR_ABORTED, ABORT_ERROR_NAME$1) : signal.reason;
|
|
245
245
|
}
|
|
246
246
|
}
|
|
247
247
|
|
|
@@ -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
|
-
if (!idleCheckArmed) {
|
|
2064
|
-
idleCheckArmed = true;
|
|
2065
|
-
const count = readCount;
|
|
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);
|
|
2073
2103
|
}
|
|
2104
|
+
if (outputLength != outputSize) {
|
|
2105
|
+
throw mapError(error, ERR_INVALID_UNCOMPRESSED_SIZE);
|
|
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;
|
|
@@ -5376,8 +5449,8 @@
|
|
|
5376
5449
|
const passThroughCompression = Boolean(passThrough);
|
|
5377
5450
|
const passThroughEncryption = passThrough === true;
|
|
5378
5451
|
checkPasswordOption(password, rawPassword);
|
|
5379
|
-
password = password && password.length
|
|
5380
|
-
rawPassword = rawPassword && rawPassword.length
|
|
5452
|
+
password = password && password.length ? password : UNDEFINED_VALUE;
|
|
5453
|
+
rawPassword = rawPassword && rawPassword.length ? rawPassword : UNDEFINED_VALUE;
|
|
5381
5454
|
if (extraFieldAES) {
|
|
5382
5455
|
if (extraFieldAES.originalCompressionMethod != COMPRESSION_METHOD_AES) {
|
|
5383
5456
|
throw new Error(ERR_UNSUPPORTED_COMPRESSION);
|
|
@@ -5527,6 +5600,7 @@
|
|
|
5527
5600
|
({ writable } = writer);
|
|
5528
5601
|
const readable = toCompatibleReadable(reader.createReadable({ offset: dataOffset, size }));
|
|
5529
5602
|
const { outputSize: writtenSize } = await runWorker({ readable, writable }, workerOptions);
|
|
5603
|
+
throwIfAborted(signal);
|
|
5530
5604
|
if (writtenSize != outputSize) {
|
|
5531
5605
|
throw Object.assign(new Error(ERR_INVALID_UNCOMPRESSED_SIZE), { outputSize: writtenSize });
|
|
5532
5606
|
}
|
|
@@ -6138,7 +6212,7 @@
|
|
|
6138
6212
|
async function findEndOfCentralDirectory(reader, rejectAmbiguous, maxAppendedDataSize) {
|
|
6139
6213
|
const { size } = reader;
|
|
6140
6214
|
const anchoredLength = Math.min(size, END_OF_CENTRAL_DIR_LENGTH + MAX_16_BITS);
|
|
6141
|
-
const remoteProbeBudget = {
|
|
6215
|
+
const remoteProbeBudget = { remaining: MAX_END_OF_CENTRAL_DIR_PROBES };
|
|
6142
6216
|
let endOfDirectoryInfo;
|
|
6143
6217
|
let plausibleEndOfDirectoryInfo;
|
|
6144
6218
|
let endOfDirectoryReachingEndCount = 0;
|
|
@@ -6231,8 +6305,8 @@
|
|
|
6231
6305
|
if (signatureOffset >= anchoredOffset) {
|
|
6232
6306
|
return getUint32$1(view, signatureOffset - anchoredOffset);
|
|
6233
6307
|
}
|
|
6234
|
-
if (remoteProbeBudget.
|
|
6235
|
-
remoteProbeBudget.
|
|
6308
|
+
if (remoteProbeBudget.remaining > 0) {
|
|
6309
|
+
remoteProbeBudget.remaining--;
|
|
6236
6310
|
const signatureArray = await readUint8Array(reader, signatureOffset, 4);
|
|
6237
6311
|
return getUint32$1(getDataView(signatureArray), 0);
|
|
6238
6312
|
}
|
|
@@ -6322,6 +6396,7 @@
|
|
|
6322
6396
|
ERR_AMBIGUOUS_ARCHIVE: ERR_AMBIGUOUS_ARCHIVE,
|
|
6323
6397
|
ERR_BAD_FORMAT: ERR_BAD_FORMAT,
|
|
6324
6398
|
ERR_CENTRAL_DIRECTORY_NOT_FOUND: ERR_CENTRAL_DIRECTORY_NOT_FOUND,
|
|
6399
|
+
ERR_CODEC_OUT_OF_MEMORY: ERR_CODEC_OUT_OF_MEMORY,
|
|
6325
6400
|
ERR_ENCRYPTED: ERR_ENCRYPTED,
|
|
6326
6401
|
ERR_ENCRYPTED_CENTRAL_DIRECTORY: ERR_ENCRYPTED_CENTRAL_DIRECTORY,
|
|
6327
6402
|
ERR_ENTRY_DATA_OUT_OF_BOUNDS: ERR_ENTRY_DATA_OUT_OF_BOUNDS,
|
|
@@ -7148,9 +7223,11 @@
|
|
|
7148
7223
|
const passThrough = checkPassThroughOption(getOptionValue(zipWriter, options, OPTION_PASS_THROUGH));
|
|
7149
7224
|
const passThroughCompression = Boolean(passThrough);
|
|
7150
7225
|
const passThroughEncryption = passThrough === true;
|
|
7151
|
-
|
|
7152
|
-
|
|
7226
|
+
let password = getOptionValue(zipWriter, options, OPTION_PASSWORD);
|
|
7227
|
+
let rawPassword = getOptionValue(zipWriter, options, OPTION_RAW_PASSWORD);
|
|
7153
7228
|
checkPasswordOption(password, rawPassword);
|
|
7229
|
+
password = password && password.length ? password : UNDEFINED_VALUE;
|
|
7230
|
+
rawPassword = rawPassword && rawPassword.length ? rawPassword : UNDEFINED_VALUE;
|
|
7154
7231
|
const encryptionStrength = getNumberOptionValue(zipWriter, options, OPTION_ENCRYPTION_STRENGTH, 3);
|
|
7155
7232
|
const zipCrypto = getOptionValue(zipWriter, options, PROPERTY_NAME_ZIPCRYPTO);
|
|
7156
7233
|
const extendedTimestamp = getOptionValue(zipWriter, options, OPTION_EXTENDED_TIMESTAMP, true);
|
|
@@ -7767,6 +7844,7 @@
|
|
|
7767
7844
|
const result = await runWorker({ readable, writable }, workerOptions);
|
|
7768
7845
|
compressedSize = result.outputSize;
|
|
7769
7846
|
writer.size += compressedSize;
|
|
7847
|
+
throwIfAborted(signal);
|
|
7770
7848
|
if (!passThroughCompression) {
|
|
7771
7849
|
uncompressedSize = result.inputSize;
|
|
7772
7850
|
if (!encrypted || zipCrypto) {
|
|
@@ -8946,7 +9024,7 @@
|
|
|
8946
9024
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
8947
9025
|
*/
|
|
8948
9026
|
|
|
8949
|
-
const VERSION = "2.
|
|
9027
|
+
const VERSION = "2.17.0";
|
|
8950
9028
|
|
|
8951
9029
|
/*
|
|
8952
9030
|
Copyright (c) 2025 Gildas Lormeau. All rights reserved.
|
|
@@ -9425,12 +9503,16 @@
|
|
|
9425
9503
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
9426
9504
|
*/
|
|
9427
9505
|
|
|
9428
|
-
/* global
|
|
9506
|
+
/* global ReadableStream, WritableStream */
|
|
9429
9507
|
|
|
9430
9508
|
const FORMAT_DEFLATE = "deflate";
|
|
9431
9509
|
const FORMAT_DEFLATE_RAW = "deflate-raw";
|
|
9432
9510
|
const FORMAT_DEFLATE64_RAW = "deflate64-raw";
|
|
9433
9511
|
const FORMAT_GZIP = "gzip";
|
|
9512
|
+
const Z_MEM_ERROR = -4;
|
|
9513
|
+
const Z_MEM_ERROR_CODE = "Z_MEM_ERROR";
|
|
9514
|
+
const COMPRESSION_FORMATS = [FORMAT_DEFLATE, FORMAT_DEFLATE_RAW, FORMAT_GZIP];
|
|
9515
|
+
const DECOMPRESSION_FORMATS = [FORMAT_DEFLATE, FORMAT_DEFLATE_RAW, FORMAT_GZIP, FORMAT_DEFLATE64_RAW];
|
|
9434
9516
|
|
|
9435
9517
|
let wasm$1, malloc, free, memory, initError;
|
|
9436
9518
|
|
|
@@ -9451,7 +9533,17 @@
|
|
|
9451
9533
|
wasm$1 = malloc = free = memory = initError = null;
|
|
9452
9534
|
}
|
|
9453
9535
|
|
|
9536
|
+
function setZlibCode(error, result) {
|
|
9537
|
+
if (result === Z_MEM_ERROR) {
|
|
9538
|
+
error.code = Z_MEM_ERROR_CODE;
|
|
9539
|
+
}
|
|
9540
|
+
return error;
|
|
9541
|
+
}
|
|
9542
|
+
|
|
9454
9543
|
function _make(isCompress, type, options = {}) {
|
|
9544
|
+
if (!(isCompress ? COMPRESSION_FORMATS : DECOMPRESSION_FORMATS).includes(type)) {
|
|
9545
|
+
throw new TypeError("Unsupported format: " + type);
|
|
9546
|
+
}
|
|
9455
9547
|
if (!wasm$1) {
|
|
9456
9548
|
const error = new Error("WASM module not loaded");
|
|
9457
9549
|
error.cause = initError;
|
|
@@ -9460,137 +9552,200 @@
|
|
|
9460
9552
|
const level = (typeof options.level === "number") ? options.level : -1;
|
|
9461
9553
|
const outBufferSize = (typeof options.outBuffer === "number") ? options.outBuffer : 64 * 1024;
|
|
9462
9554
|
const inBufferSize = (typeof options.inBufferSize === "number") ? options.inBufferSize : 64 * 1024;
|
|
9463
|
-
|
|
9464
|
-
|
|
9465
|
-
|
|
9555
|
+
const state = { out: 0, in: 0, inBufferSize: 0, streamHandle: 0, streamEnded: false };
|
|
9556
|
+
let readableController, writableController, resolveWrite, cancelReason;
|
|
9557
|
+
let backpressure = true;
|
|
9558
|
+
let cancelled = false;
|
|
9559
|
+
initStream();
|
|
9560
|
+
const readable = new ReadableStream({
|
|
9561
|
+
start(controller) {
|
|
9562
|
+
readableController = controller;
|
|
9563
|
+
},
|
|
9564
|
+
pull() {
|
|
9565
|
+
backpressure = false;
|
|
9566
|
+
resumeWrite();
|
|
9567
|
+
},
|
|
9568
|
+
cancel(reason) {
|
|
9569
|
+
cancelled = true;
|
|
9570
|
+
cancelReason = reason;
|
|
9571
|
+
disposeStream(state);
|
|
9572
|
+
writableController.error(reason);
|
|
9573
|
+
resumeWrite();
|
|
9574
|
+
}
|
|
9575
|
+
}, { highWaterMark: 0 });
|
|
9576
|
+
const writable = new WritableStream({
|
|
9577
|
+
start(controller) {
|
|
9578
|
+
writableController = controller;
|
|
9579
|
+
},
|
|
9580
|
+
async write(chunk) {
|
|
9581
|
+
if (backpressure) {
|
|
9582
|
+
await new Promise(resolve => resolveWrite = resolve);
|
|
9583
|
+
}
|
|
9584
|
+
if (cancelled) {
|
|
9585
|
+
throw cancelReason;
|
|
9586
|
+
}
|
|
9466
9587
|
try {
|
|
9467
|
-
|
|
9468
|
-
this.out = malloc(outBufferSize);
|
|
9469
|
-
this.in = malloc(inBufferSize);
|
|
9470
|
-
this.inBufferSize = inBufferSize;
|
|
9471
|
-
if (!this.out || !this.in) {
|
|
9472
|
-
throw new Error("allocation failed");
|
|
9473
|
-
}
|
|
9474
|
-
if (isCompress) {
|
|
9475
|
-
this._process = wasm$1.deflate_process;
|
|
9476
|
-
this._last_consumed = wasm$1.deflate_last_consumed;
|
|
9477
|
-
this._end = wasm$1.deflate_end;
|
|
9478
|
-
this.streamHandle = wasm$1.deflate_new();
|
|
9479
|
-
if (type === FORMAT_GZIP) {
|
|
9480
|
-
result = wasm$1.deflate_init_gzip(this.streamHandle, level);
|
|
9481
|
-
} else if (type === FORMAT_DEFLATE_RAW) {
|
|
9482
|
-
result = wasm$1.deflate_init_raw(this.streamHandle, level);
|
|
9483
|
-
} else {
|
|
9484
|
-
result = wasm$1.deflate_init(this.streamHandle, level);
|
|
9485
|
-
}
|
|
9486
|
-
} else {
|
|
9487
|
-
if (type === FORMAT_DEFLATE64_RAW) {
|
|
9488
|
-
this._process = wasm$1.inflate9_process;
|
|
9489
|
-
this._last_consumed = wasm$1.inflate9_last_consumed;
|
|
9490
|
-
this._end = wasm$1.inflate9_end;
|
|
9491
|
-
this.streamHandle = wasm$1.inflate9_new();
|
|
9492
|
-
result = wasm$1.inflate9_init_raw(this.streamHandle);
|
|
9493
|
-
} else {
|
|
9494
|
-
this._process = wasm$1.inflate_process;
|
|
9495
|
-
this._last_consumed = wasm$1.inflate_last_consumed;
|
|
9496
|
-
this._end = wasm$1.inflate_end;
|
|
9497
|
-
this.streamHandle = wasm$1.inflate_new();
|
|
9498
|
-
if (type === FORMAT_DEFLATE_RAW) {
|
|
9499
|
-
result = wasm$1.inflate_init_raw(this.streamHandle);
|
|
9500
|
-
} else if (type === FORMAT_GZIP) {
|
|
9501
|
-
result = wasm$1.inflate_init_gzip(this.streamHandle);
|
|
9502
|
-
} else {
|
|
9503
|
-
result = wasm$1.inflate_init(this.streamHandle);
|
|
9504
|
-
}
|
|
9505
|
-
}
|
|
9506
|
-
}
|
|
9507
|
-
if (result !== 0) {
|
|
9508
|
-
throw new Error("init failed:" + result);
|
|
9509
|
-
}
|
|
9588
|
+
processChunk(chunk);
|
|
9510
9589
|
} catch (error) {
|
|
9511
|
-
disposeStream(
|
|
9590
|
+
disposeStream(state);
|
|
9591
|
+
readableController.error(error);
|
|
9512
9592
|
throw error;
|
|
9513
9593
|
}
|
|
9514
9594
|
},
|
|
9515
|
-
|
|
9595
|
+
close() {
|
|
9596
|
+
if (cancelled) {
|
|
9597
|
+
return;
|
|
9598
|
+
}
|
|
9516
9599
|
try {
|
|
9517
|
-
|
|
9518
|
-
const heap = new Uint8Array(memory.buffer);
|
|
9519
|
-
const process = this._process;
|
|
9520
|
-
const last_consumed = this._last_consumed;
|
|
9521
|
-
const out = this.out;
|
|
9522
|
-
let offset = 0;
|
|
9523
|
-
while (offset < buffer.length) {
|
|
9524
|
-
const toRead = Math.min(buffer.length - offset, 32 * 1024);
|
|
9525
|
-
if (!this.in || this.inBufferSize < toRead) {
|
|
9526
|
-
if (this.in && free) {
|
|
9527
|
-
free(this.in);
|
|
9528
|
-
this.in = 0;
|
|
9529
|
-
}
|
|
9530
|
-
this.in = malloc(toRead);
|
|
9531
|
-
this.inBufferSize = toRead;
|
|
9532
|
-
if (!this.in) {
|
|
9533
|
-
throw new Error("allocation failed");
|
|
9534
|
-
}
|
|
9535
|
-
}
|
|
9536
|
-
heap.set(buffer.subarray(offset, offset + toRead), this.in);
|
|
9537
|
-
const result = process(this.streamHandle, this.in, toRead, out, outBufferSize, 0);
|
|
9538
|
-
// checked before the byte count is used, so a status code can never be read as one
|
|
9539
|
-
const code = (result >> 24) & 0xff;
|
|
9540
|
-
const signedCode = (code & 0x80) ? code - 256 : code;
|
|
9541
|
-
if (signedCode < 0) {
|
|
9542
|
-
throw new Error("process error:" + signedCode);
|
|
9543
|
-
}
|
|
9544
|
-
const prod = result & 0x00ffffff;
|
|
9545
|
-
if (prod) {
|
|
9546
|
-
controller.enqueue(heap.slice(out, out + prod));
|
|
9547
|
-
}
|
|
9548
|
-
const consumed = last_consumed(this.streamHandle);
|
|
9549
|
-
if (consumed === 0 && prod === 0) {
|
|
9550
|
-
break;
|
|
9551
|
-
}
|
|
9552
|
-
offset += consumed;
|
|
9553
|
-
}
|
|
9600
|
+
flushStream();
|
|
9554
9601
|
} catch (error) {
|
|
9555
|
-
disposeStream(
|
|
9556
|
-
|
|
9602
|
+
disposeStream(state);
|
|
9603
|
+
readableController.error(error);
|
|
9604
|
+
throw error;
|
|
9557
9605
|
}
|
|
9606
|
+
const result = disposeStream(state);
|
|
9607
|
+
if (result !== 0) {
|
|
9608
|
+
const error = setZlibCode(new Error("end error:" + result), result);
|
|
9609
|
+
readableController.error(error);
|
|
9610
|
+
throw error;
|
|
9611
|
+
}
|
|
9612
|
+
readableController.close();
|
|
9558
9613
|
},
|
|
9559
|
-
|
|
9560
|
-
|
|
9561
|
-
|
|
9562
|
-
|
|
9563
|
-
|
|
9564
|
-
|
|
9565
|
-
|
|
9566
|
-
|
|
9567
|
-
|
|
9568
|
-
|
|
9569
|
-
|
|
9570
|
-
|
|
9571
|
-
|
|
9572
|
-
|
|
9573
|
-
|
|
9574
|
-
|
|
9575
|
-
|
|
9576
|
-
|
|
9614
|
+
abort(reason) {
|
|
9615
|
+
disposeStream(state);
|
|
9616
|
+
readableController.error(reason);
|
|
9617
|
+
}
|
|
9618
|
+
}, { highWaterMark: 1 });
|
|
9619
|
+
return { readable, writable };
|
|
9620
|
+
|
|
9621
|
+
function initStream() {
|
|
9622
|
+
try {
|
|
9623
|
+
let result;
|
|
9624
|
+
state.out = malloc(outBufferSize);
|
|
9625
|
+
state.in = malloc(inBufferSize);
|
|
9626
|
+
state.inBufferSize = inBufferSize;
|
|
9627
|
+
if (!state.out || !state.in) {
|
|
9628
|
+
throw setZlibCode(new Error("allocation failed"), Z_MEM_ERROR);
|
|
9629
|
+
}
|
|
9630
|
+
if (isCompress) {
|
|
9631
|
+
state._process = wasm$1.deflate_process;
|
|
9632
|
+
state._last_consumed = wasm$1.deflate_last_consumed;
|
|
9633
|
+
state._end = wasm$1.deflate_end;
|
|
9634
|
+
state.streamHandle = wasm$1.deflate_new();
|
|
9635
|
+
if (type === FORMAT_GZIP) {
|
|
9636
|
+
result = wasm$1.deflate_init_gzip(state.streamHandle, level);
|
|
9637
|
+
} else if (type === FORMAT_DEFLATE_RAW) {
|
|
9638
|
+
result = wasm$1.deflate_init_raw(state.streamHandle, level);
|
|
9639
|
+
} else {
|
|
9640
|
+
result = wasm$1.deflate_init(state.streamHandle, level);
|
|
9641
|
+
}
|
|
9642
|
+
} else {
|
|
9643
|
+
if (type === FORMAT_DEFLATE64_RAW) {
|
|
9644
|
+
state._process = wasm$1.inflate9_process;
|
|
9645
|
+
state._last_consumed = wasm$1.inflate9_last_consumed;
|
|
9646
|
+
state._end = wasm$1.inflate9_end;
|
|
9647
|
+
state.streamHandle = wasm$1.inflate9_new();
|
|
9648
|
+
result = wasm$1.inflate9_init_raw(state.streamHandle);
|
|
9649
|
+
} else {
|
|
9650
|
+
state._process = wasm$1.inflate_process;
|
|
9651
|
+
state._last_consumed = wasm$1.inflate_last_consumed;
|
|
9652
|
+
state._end = wasm$1.inflate_end;
|
|
9653
|
+
state.streamHandle = wasm$1.inflate_new();
|
|
9654
|
+
if (type === FORMAT_DEFLATE_RAW) {
|
|
9655
|
+
result = wasm$1.inflate_init_raw(state.streamHandle);
|
|
9656
|
+
} else if (type === FORMAT_GZIP) {
|
|
9657
|
+
result = wasm$1.inflate_init_gzip(state.streamHandle);
|
|
9658
|
+
} else {
|
|
9659
|
+
result = wasm$1.inflate_init(state.streamHandle);
|
|
9577
9660
|
}
|
|
9578
9661
|
}
|
|
9579
|
-
}
|
|
9580
|
-
|
|
9581
|
-
|
|
9582
|
-
|
|
9583
|
-
|
|
9584
|
-
|
|
9662
|
+
}
|
|
9663
|
+
if (result !== 0) {
|
|
9664
|
+
throw setZlibCode(new Error("init failed:" + result), result);
|
|
9665
|
+
}
|
|
9666
|
+
} catch (error) {
|
|
9667
|
+
disposeStream(state);
|
|
9668
|
+
throw error;
|
|
9669
|
+
}
|
|
9670
|
+
}
|
|
9671
|
+
|
|
9672
|
+
function processChunk(chunk) {
|
|
9673
|
+
const heap = new Uint8Array(memory.buffer);
|
|
9674
|
+
const process = state._process;
|
|
9675
|
+
const last_consumed = state._last_consumed;
|
|
9676
|
+
const out = state.out;
|
|
9677
|
+
let offset = 0;
|
|
9678
|
+
while (offset < chunk.length) {
|
|
9679
|
+
if (state.streamEnded) {
|
|
9680
|
+
throw new Error("trailing data after the end of the stream");
|
|
9681
|
+
}
|
|
9682
|
+
const toRead = Math.min(chunk.length - offset, 32 * 1024);
|
|
9683
|
+
if (!state.in || state.inBufferSize < toRead) {
|
|
9684
|
+
if (state.in && free) {
|
|
9685
|
+
free(state.in);
|
|
9686
|
+
state.in = 0;
|
|
9687
|
+
}
|
|
9688
|
+
state.in = malloc(toRead);
|
|
9689
|
+
state.inBufferSize = toRead;
|
|
9690
|
+
if (!state.in) {
|
|
9691
|
+
throw setZlibCode(new Error("allocation failed"), Z_MEM_ERROR);
|
|
9585
9692
|
}
|
|
9586
9693
|
}
|
|
9587
|
-
|
|
9588
|
-
|
|
9589
|
-
//
|
|
9590
|
-
|
|
9591
|
-
|
|
9694
|
+
heap.set(chunk.subarray(offset, offset + toRead), state.in);
|
|
9695
|
+
const result = process(state.streamHandle, state.in, toRead, out, outBufferSize, 0);
|
|
9696
|
+
// checked before the byte count is used, so a status code can never be read as one
|
|
9697
|
+
const code = (result >> 24) & 0xff;
|
|
9698
|
+
const signedCode = (code & 0x80) ? code - 256 : code;
|
|
9699
|
+
if (signedCode < 0) {
|
|
9700
|
+
throw setZlibCode(new Error("process error:" + signedCode), signedCode);
|
|
9701
|
+
}
|
|
9702
|
+
const prod = result & 0x00ffffff;
|
|
9703
|
+
if (prod) {
|
|
9704
|
+
enqueue(heap.slice(out, out + prod));
|
|
9705
|
+
}
|
|
9706
|
+
const consumed = last_consumed(state.streamHandle);
|
|
9707
|
+
if (code === 1) {
|
|
9708
|
+
state.streamEnded = true;
|
|
9709
|
+
} else if (consumed === 0 && prod === 0) {
|
|
9710
|
+
break;
|
|
9711
|
+
}
|
|
9712
|
+
offset += consumed;
|
|
9592
9713
|
}
|
|
9593
|
-
}
|
|
9714
|
+
}
|
|
9715
|
+
|
|
9716
|
+
function flushStream() {
|
|
9717
|
+
const heap = new Uint8Array(memory.buffer);
|
|
9718
|
+
const process = state._process;
|
|
9719
|
+
const out = state.out;
|
|
9720
|
+
while (true) {
|
|
9721
|
+
const result = process(state.streamHandle, 0, 0, out, outBufferSize, 4);
|
|
9722
|
+
const code = (result >> 24) & 0xff;
|
|
9723
|
+
const signedCode = (code & 0x80) ? code - 256 : code;
|
|
9724
|
+
if (signedCode < 0) {
|
|
9725
|
+
throw setZlibCode(new Error("process error:" + signedCode), signedCode);
|
|
9726
|
+
}
|
|
9727
|
+
const produced = result & 0x00ffffff;
|
|
9728
|
+
if (produced) {
|
|
9729
|
+
enqueue(heap.slice(out, out + produced));
|
|
9730
|
+
}
|
|
9731
|
+
if (code === 1 || produced === 0) {
|
|
9732
|
+
break;
|
|
9733
|
+
}
|
|
9734
|
+
}
|
|
9735
|
+
}
|
|
9736
|
+
|
|
9737
|
+
function enqueue(chunk) {
|
|
9738
|
+
backpressure = true;
|
|
9739
|
+
readableController.enqueue(chunk);
|
|
9740
|
+
}
|
|
9741
|
+
|
|
9742
|
+
function resumeWrite() {
|
|
9743
|
+
if (resolveWrite) {
|
|
9744
|
+
const resolve = resolveWrite;
|
|
9745
|
+
resolveWrite = null;
|
|
9746
|
+
resolve();
|
|
9747
|
+
}
|
|
9748
|
+
}
|
|
9594
9749
|
|
|
9595
9750
|
function disposeStream(state) {
|
|
9596
9751
|
let endResult = 0;
|
|
@@ -9626,10 +9781,10 @@
|
|
|
9626
9781
|
CompressionStreamZlib.requiresModule = true;
|
|
9627
9782
|
DecompressionStreamZlib.requiresModule = true;
|
|
9628
9783
|
// Constructing these classes before the module is loaded throws, so capability probes cannot rely
|
|
9629
|
-
// on trying the constructor; the formats are declared instead,
|
|
9630
|
-
//
|
|
9631
|
-
CompressionStreamZlib.supportedFormats =
|
|
9632
|
-
DecompressionStreamZlib.supportedFormats =
|
|
9784
|
+
// on trying the constructor; the formats are declared instead, the lists _make() checks a format
|
|
9785
|
+
// against before anything else.
|
|
9786
|
+
CompressionStreamZlib.supportedFormats = COMPRESSION_FORMATS;
|
|
9787
|
+
DecompressionStreamZlib.supportedFormats = DECOMPRESSION_FORMATS;
|
|
9633
9788
|
|
|
9634
9789
|
/*
|
|
9635
9790
|
Copyright (c) 2026 Gildas Lormeau. All rights reserved.
|
|
@@ -9946,7 +10101,12 @@
|
|
|
9946
10101
|
const ERR_INVALID_PASS_THROUGH = "Invalid passThrough option (use readerOptions.passThrough or set uncompressedSize for each entry)";
|
|
9947
10102
|
const ERR_INVALID_READER_OPTIONS = "Invalid readerOptions (must be an object)";
|
|
9948
10103
|
const ERR_UNSUPPORTED_PASS_THROUGH_VALUE = "The 'compressed' passThrough option is only supported by Entry#getData() and ZipWriter#add()";
|
|
10104
|
+
const ERR_INVALID_PASSWORDS = "Invalid passwords option (must be an array of strings)";
|
|
10105
|
+
const ERR_INVALID_REQUEST_PASSWORD = "Invalid requestPassword option (must be a function returning a string or undefined)";
|
|
9949
10106
|
const ERR_ABORT_EXPORT = "zipjs-abort-export";
|
|
10107
|
+
const ABORT_ERROR_NAME = "AbortError";
|
|
10108
|
+
const EMPTY_RAW_PASSWORD = new Uint8Array(0);
|
|
10109
|
+
const FALSE_ACCEPT_ERRORS = new Set([ERR_INVALID_CRC32, ERR_INVALID_UNCOMPRESSED_SIZE, ERR_INVALID_COMPRESSED_DATA]);
|
|
9950
10110
|
|
|
9951
10111
|
class ZipEntry {
|
|
9952
10112
|
|
|
@@ -10319,8 +10479,10 @@
|
|
|
10319
10479
|
zipReader = new ZipReader(reader, options);
|
|
10320
10480
|
}
|
|
10321
10481
|
checkPassThroughValue(options.passThrough);
|
|
10482
|
+
checkPasswordCandidatesOptions(options);
|
|
10322
10483
|
const duplicates = checkDuplicatesOption(options.duplicates);
|
|
10323
10484
|
const importedEntries = [];
|
|
10485
|
+
const passwordState = { known: [] };
|
|
10324
10486
|
const entries = await zipReader.getEntries(options);
|
|
10325
10487
|
for (const entry of entries) {
|
|
10326
10488
|
let parent = this;
|
|
@@ -10365,7 +10527,7 @@
|
|
|
10365
10527
|
}
|
|
10366
10528
|
importedEntries.push(addChild(parent, name, {
|
|
10367
10529
|
data: entry,
|
|
10368
|
-
Reader: getZipBlobReader(Object.assign({}, options)),
|
|
10530
|
+
Reader: getZipBlobReader(Object.assign({}, options), passwordState),
|
|
10369
10531
|
uncompressedSize: options.passThrough ? entry.compressedSize : entry.uncompressedSize,
|
|
10370
10532
|
passThrough: options.passThrough
|
|
10371
10533
|
}));
|
|
@@ -10694,7 +10856,7 @@
|
|
|
10694
10856
|
};
|
|
10695
10857
|
}
|
|
10696
10858
|
|
|
10697
|
-
function getZipBlobReader(options) {
|
|
10859
|
+
function getZipBlobReader(options, passwordState) {
|
|
10698
10860
|
return class extends Reader {
|
|
10699
10861
|
|
|
10700
10862
|
constructor(entry, options = {}) {
|
|
@@ -10707,12 +10869,12 @@
|
|
|
10707
10869
|
const zipBlobReader = this;
|
|
10708
10870
|
const readerOptions = Object.assign({}, options, zipBlobReader.options);
|
|
10709
10871
|
const { checkOverlappingEntry, checkOverlappingEntryOnly } = readerOptions;
|
|
10710
|
-
const data = await zipBlobReader.entry
|
|
10872
|
+
const data = await readEntryData(zipBlobReader.entry, Object.assign(readerOptions, {
|
|
10711
10873
|
checkPasswordOnly: false,
|
|
10712
10874
|
checkOverlappingEntry: checkOverlappingEntryOnly || checkOverlappingEntry,
|
|
10713
10875
|
checkOverlappingEntryOnly: false,
|
|
10714
10876
|
preventClose: false
|
|
10715
|
-
}));
|
|
10877
|
+
}), passwordState);
|
|
10716
10878
|
zipBlobReader.data = data;
|
|
10717
10879
|
zipBlobReader.blobReader = new BlobReader(data);
|
|
10718
10880
|
zipBlobReader.size = data.size;
|
|
@@ -10774,10 +10936,9 @@
|
|
|
10774
10936
|
await initStream(reader);
|
|
10775
10937
|
} catch (error) {
|
|
10776
10938
|
try {
|
|
10939
|
+
error.entry = child;
|
|
10777
10940
|
error.entryId = child.id;
|
|
10778
|
-
error.
|
|
10779
|
-
entry: child
|
|
10780
|
-
};
|
|
10941
|
+
error.entryName = child.getRelativeName(entry);
|
|
10781
10942
|
} catch {
|
|
10782
10943
|
// ignored
|
|
10783
10944
|
}
|
|
@@ -10869,10 +11030,145 @@
|
|
|
10869
11030
|
}
|
|
10870
11031
|
if (readerOptions) {
|
|
10871
11032
|
checkPassThroughValue(readerOptions.passThrough);
|
|
11033
|
+
checkPasswordCandidatesOptions(readerOptions);
|
|
10872
11034
|
}
|
|
10873
11035
|
return readerOptions;
|
|
10874
11036
|
}
|
|
10875
11037
|
|
|
11038
|
+
function checkPasswordCandidatesOptions(options) {
|
|
11039
|
+
const { passwords, requestPassword } = options;
|
|
11040
|
+
if (passwords && (!Array.isArray(passwords) || passwords.some(password => typeof password != STRING_TYPE))) {
|
|
11041
|
+
throw new Error(ERR_INVALID_PASSWORDS);
|
|
11042
|
+
}
|
|
11043
|
+
if (requestPassword && typeof requestPassword != FUNCTION_TYPE) {
|
|
11044
|
+
throw new Error(ERR_INVALID_REQUEST_PASSWORD);
|
|
11045
|
+
}
|
|
11046
|
+
}
|
|
11047
|
+
|
|
11048
|
+
async function readEntryData(entry, options, passwordState) {
|
|
11049
|
+
checkPasswordCandidatesOptions(options);
|
|
11050
|
+
const { passwords, requestPassword, signal } = options;
|
|
11051
|
+
options = Object.assign({}, options);
|
|
11052
|
+
delete options.passwords;
|
|
11053
|
+
delete options.requestPassword;
|
|
11054
|
+
if (!entry.encrypted || options.passThrough || (!passwords && !requestPassword)) {
|
|
11055
|
+
return entry.getData(new BlobWriter(), options);
|
|
11056
|
+
}
|
|
11057
|
+
const tried = new Set();
|
|
11058
|
+
let error;
|
|
11059
|
+
while (true) {
|
|
11060
|
+
for (const candidate of getPasswordCandidates(options, passwordState, passwords)) {
|
|
11061
|
+
if (!tried.has(candidate.key)) {
|
|
11062
|
+
const result = await tryPasswordCandidate(candidate);
|
|
11063
|
+
if (result.done) {
|
|
11064
|
+
return result.data;
|
|
11065
|
+
}
|
|
11066
|
+
error = result.error;
|
|
11067
|
+
}
|
|
11068
|
+
}
|
|
11069
|
+
if (!requestPassword) {
|
|
11070
|
+
break;
|
|
11071
|
+
}
|
|
11072
|
+
if (passwordState.pendingPrompt) {
|
|
11073
|
+
await passwordState.pendingPrompt;
|
|
11074
|
+
continue;
|
|
11075
|
+
}
|
|
11076
|
+
let release;
|
|
11077
|
+
passwordState.pendingPrompt = new Promise(resolve => release = resolve);
|
|
11078
|
+
try {
|
|
11079
|
+
const answer = await requestPassword(entry, error);
|
|
11080
|
+
if (answer === UNDEFINED_VALUE || answer === null) {
|
|
11081
|
+
break;
|
|
11082
|
+
}
|
|
11083
|
+
// deno-lint-ignore valid-typeof
|
|
11084
|
+
if (typeof answer != STRING_TYPE) {
|
|
11085
|
+
throw new Error(ERR_INVALID_REQUEST_PASSWORD);
|
|
11086
|
+
}
|
|
11087
|
+
const result = await tryPasswordCandidate(getPasswordCandidate(answer));
|
|
11088
|
+
if (result.done) {
|
|
11089
|
+
return result.data;
|
|
11090
|
+
}
|
|
11091
|
+
error = result.error;
|
|
11092
|
+
} finally {
|
|
11093
|
+
passwordState.pendingPrompt = UNDEFINED_VALUE;
|
|
11094
|
+
release();
|
|
11095
|
+
}
|
|
11096
|
+
}
|
|
11097
|
+
if (!tried.size) {
|
|
11098
|
+
throw new Error(ERR_ENCRYPTED);
|
|
11099
|
+
}
|
|
11100
|
+
const passwordError = new Error(ERR_INVALID_PASSWORD);
|
|
11101
|
+
passwordError.cause = error;
|
|
11102
|
+
throw passwordError;
|
|
11103
|
+
|
|
11104
|
+
async function tryPasswordCandidate(candidate) {
|
|
11105
|
+
tried.add(candidate.key);
|
|
11106
|
+
const candidateOptions = Object.assign({}, options, candidate.options);
|
|
11107
|
+
if (entry.zipCrypto) {
|
|
11108
|
+
candidateOptions.checkCrc32 = true;
|
|
11109
|
+
try {
|
|
11110
|
+
await entry.getData(null, Object.assign({}, candidateOptions, { checkPasswordOnly: true }));
|
|
11111
|
+
} catch (probeError) {
|
|
11112
|
+
if (isInvalidPasswordError(probeError)) {
|
|
11113
|
+
return { done: false, error: probeError };
|
|
11114
|
+
}
|
|
11115
|
+
throw probeError;
|
|
11116
|
+
}
|
|
11117
|
+
}
|
|
11118
|
+
try {
|
|
11119
|
+
const data = await entry.getData(new BlobWriter(), candidateOptions);
|
|
11120
|
+
rememberPassword(passwordState, candidate);
|
|
11121
|
+
return { done: true, data };
|
|
11122
|
+
} catch (readError) {
|
|
11123
|
+
if (isAbortError(readError, signal) || !isWrongPasswordError(readError, entry)) {
|
|
11124
|
+
throw readError;
|
|
11125
|
+
}
|
|
11126
|
+
return { done: false, error: readError };
|
|
11127
|
+
}
|
|
11128
|
+
}
|
|
11129
|
+
}
|
|
11130
|
+
|
|
11131
|
+
function isInvalidPasswordError(error) {
|
|
11132
|
+
return isErrorObject(error) && error.message == ERR_INVALID_PASSWORD;
|
|
11133
|
+
}
|
|
11134
|
+
|
|
11135
|
+
function isWrongPasswordError(error, entry) {
|
|
11136
|
+
return isInvalidPasswordError(error) || (entry.zipCrypto && isErrorObject(error) && FALSE_ACCEPT_ERRORS.has(error.message));
|
|
11137
|
+
}
|
|
11138
|
+
|
|
11139
|
+
function isAbortError(error, signal) {
|
|
11140
|
+
return Boolean(signal && signal.aborted) || (isErrorObject(error) && error.name == ABORT_ERROR_NAME);
|
|
11141
|
+
}
|
|
11142
|
+
|
|
11143
|
+
function getPasswordCandidates(options, passwordState, passwords) {
|
|
11144
|
+
const candidates = [];
|
|
11145
|
+
const { password, rawPassword } = options;
|
|
11146
|
+
if (rawPassword && rawPassword.length) {
|
|
11147
|
+
candidates.push({ key: rawPassword, options: { password: "", rawPassword } });
|
|
11148
|
+
}
|
|
11149
|
+
if (password) {
|
|
11150
|
+
candidates.push(getPasswordCandidate(password));
|
|
11151
|
+
}
|
|
11152
|
+
candidates.push(...passwordState.known);
|
|
11153
|
+
if (passwords) {
|
|
11154
|
+
candidates.push(...passwords.filter(password => password).map(getPasswordCandidate));
|
|
11155
|
+
}
|
|
11156
|
+
return candidates;
|
|
11157
|
+
}
|
|
11158
|
+
|
|
11159
|
+
function getPasswordCandidate(password) {
|
|
11160
|
+
return { key: password, options: { password, rawPassword: EMPTY_RAW_PASSWORD } };
|
|
11161
|
+
}
|
|
11162
|
+
|
|
11163
|
+
function rememberPassword(passwordState, candidate) {
|
|
11164
|
+
const { known } = passwordState;
|
|
11165
|
+
const index = known.findIndex(knownCandidate => knownCandidate.key === candidate.key);
|
|
11166
|
+
if (index != -1) {
|
|
11167
|
+
known.splice(index, 1);
|
|
11168
|
+
}
|
|
11169
|
+
known.unshift(candidate);
|
|
11170
|
+
}
|
|
11171
|
+
|
|
10876
11172
|
function checkPassThroughValue(passThrough) {
|
|
10877
11173
|
if (checkPassThroughOption(passThrough) === PASS_THROUGH_COMPRESSED) {
|
|
10878
11174
|
throw new Error(ERR_UNSUPPORTED_PASS_THROUGH_VALUE);
|
|
@@ -11010,6 +11306,7 @@
|
|
|
11010
11306
|
async function exportFileSystemHandle(zipEntry, directoryHandle, options) {
|
|
11011
11307
|
const { onstart, onprogress, onend } = options;
|
|
11012
11308
|
checkPassThroughValue(options.passThrough);
|
|
11309
|
+
checkPasswordCandidatesOptions(options);
|
|
11013
11310
|
const readerOptions = checkReaderOptions(options.readerOptions);
|
|
11014
11311
|
const abortController = new AbortController();
|
|
11015
11312
|
const { signal } = abortController;
|
|
@@ -11363,6 +11660,7 @@
|
|
|
11363
11660
|
exports.ERR_ANCESTOR_ENTRY = ERR_ANCESTOR_ENTRY;
|
|
11364
11661
|
exports.ERR_BAD_FORMAT = ERR_BAD_FORMAT;
|
|
11365
11662
|
exports.ERR_CENTRAL_DIRECTORY_NOT_FOUND = ERR_CENTRAL_DIRECTORY_NOT_FOUND;
|
|
11663
|
+
exports.ERR_CODEC_OUT_OF_MEMORY = ERR_CODEC_OUT_OF_MEMORY;
|
|
11366
11664
|
exports.ERR_DUPLICATED_NAME = ERR_DUPLICATED_NAME;
|
|
11367
11665
|
exports.ERR_DUPLICATE_IMPORTED_ENTRY = ERR_DUPLICATE_IMPORTED_ENTRY;
|
|
11368
11666
|
exports.ERR_ENCRYPTED = ERR_ENCRYPTED;
|
|
@@ -11403,11 +11701,13 @@
|
|
|
11403
11701
|
exports.ERR_INVALID_MSDOS_ATTRIBUTES = ERR_INVALID_MSDOS_ATTRIBUTES;
|
|
11404
11702
|
exports.ERR_INVALID_MSDOS_DATA = ERR_INVALID_MSDOS_DATA;
|
|
11405
11703
|
exports.ERR_INVALID_PASSWORD = ERR_INVALID_PASSWORD;
|
|
11704
|
+
exports.ERR_INVALID_PASSWORDS = ERR_INVALID_PASSWORDS;
|
|
11406
11705
|
exports.ERR_INVALID_PASSWORD_TYPE = ERR_INVALID_PASSWORD_TYPE;
|
|
11407
11706
|
exports.ERR_INVALID_PASS_THROUGH = ERR_INVALID_PASS_THROUGH;
|
|
11408
11707
|
exports.ERR_INVALID_PASS_THROUGH_VALUE = ERR_INVALID_PASS_THROUGH_VALUE;
|
|
11409
11708
|
exports.ERR_INVALID_READER = ERR_INVALID_READER;
|
|
11410
11709
|
exports.ERR_INVALID_READER_OPTIONS = ERR_INVALID_READER_OPTIONS;
|
|
11710
|
+
exports.ERR_INVALID_REQUEST_PASSWORD = ERR_INVALID_REQUEST_PASSWORD;
|
|
11411
11711
|
exports.ERR_INVALID_SIGNAL = ERR_INVALID_SIGNAL;
|
|
11412
11712
|
exports.ERR_INVALID_SIGNATURE_DATA = ERR_INVALID_SIGNATURE_DATA;
|
|
11413
11713
|
exports.ERR_INVALID_STRICTNESS = ERR_INVALID_STRICTNESS;
|