@zip.js/zip.js 2.16.0 → 2.16.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/deno.json +1 -1
- package/dist/zip-core-external.js +284 -179
- package/dist/zip-core-external.min.js +1 -1
- package/dist/zip-core.js +108 -61
- package/dist/zip-core.min.js +1 -1
- package/dist/zip-fs-core-external.js +426 -189
- package/dist/zip-fs-core-external.min.js +1 -1
- package/dist/zip-fs-core.js +251 -70
- package/dist/zip-fs-core.min.js +1 -1
- package/dist/zip-fs-external.js +426 -189
- package/dist/zip-fs-external.min.js +1 -1
- package/dist/zip-fs-native.js +253 -72
- package/dist/zip-fs-native.min.js +1 -1
- package/dist/zip-fs.js +428 -189
- package/dist/zip-fs.min.js +1 -1
- package/dist/zip-legacy.js +110 -63
- package/dist/zip-legacy.min.js +1 -1
- package/dist/zip-native.js +110 -63
- 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 +285 -180
- package/dist/zip.min.js +1 -1
- package/eslint.config.mjs +1 -1
- package/index-native.cjs +253 -72
- package/index-native.min.js +1 -1
- package/index.cjs +428 -189
- package/index.d.cts +117 -16
- package/index.d.ts +117 -16
- package/index.min.js +1 -1
- package/lib/core/streams/aes-crypto-stream.js +60 -17
- package/lib/core/streams/zip-crypto-stream.js +7 -7
- package/lib/core/streams/zip-entry-stream.js +22 -26
- package/lib/core/streams/zlib-wasm/zlib-streams.js +176 -118
- package/lib/core/util/compatible-streams.js +10 -5
- package/lib/core/version.js +1 -1
- package/lib/core/web-worker-inline-native.js +1 -1
- package/lib/core/web-worker-inline-wasm.js +1 -1
- package/lib/core/zip-fs.js +144 -10
- package/lib/core/zip-reader.js +5 -5
- package/lib/core/zip-writer.js +4 -2
- package/package.json +3 -2
package/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:p,postMessage:d,TransformStream:h,ReadableStream:y,WritableStream:m,CompressionStream:S,DecompressionStream:g}=self,v=void 0,b="undefined",k="function",z=new c,C=[[],[],[],[],[],[],[],[]];for(let t=0;t<256;t++){let n=t;for(let t=0;t<8;t++)n=1&n?n>>>1^3988292384:n>>>1;C[0][t]=n}for(let t=0;t<256;t++)for(let n=1;n<8;n++){const e=C[n-1][t];C[n][t]=e>>>8^C[0][255&e]}const[I,A,M,x,P,D,F,B]=C;class E{constructor(t){this.o=t||-1}append(t){let n=0|this.o;const e=0|t.length;let o=0;if(e>=8&&t.buffer){const r=new u(t.buffer,t.byteOffset,e),c=e-8;for(;o<=c;o+=8){const t=n^r.getInt32(o,!0),e=r.getInt32(o+4,!0);n=B[255&t]^F[t>>>8&255]^D[t>>>16&255]^P[t>>>24&255]^x[255&e]^M[e>>>8&255]^A[e>>>16&255]^I[e>>>24&255]}}for(;o<e;o++)n=n>>>8^I[255&(n^t[o])];this.o=n}get(){return~this.o}}class R extends h{constructor(){let t;const n=new E;super({transform(t,e){n.append(t),e.enqueue(t)},flush(){const e=new c(4);new u(e.buffer).setUint32(0,n.get()),t.value=e}}),t=this}}function U(t,n){const e=new c(t.length+n.length);return e.set(t),e.set(n,t.length),e}function W(t){return new u(t.buffer,t.byteOffset,t.byteLength)}const V=64,K=20,j=new c([128]),H=new c(1),O=new i([1732584193,4023233417,2562383102,271733878,3285377520]),T=new c(256),L=new i(256),N=new i(256),q=new i(256),G=new i(256);let J=!1;function Q(t,n){!function(){if(!J){let t=1,n=1;do{t=255&(t^t<<1^(128&t?27:0)),n=255&(n^n<<1),n=255&(n^n<<2),n=255&(n^n<<4),128&n&&(n^=9),T[t]=255&(n^(n<<1|n>>7)^(n<<2|n>>6)^(n<<3|n>>5)^(n<<4|n>>4)^99)}while(1!=t);T[0]=99;for(let t=0;t<256;t++){const n=T[t],e=$(n),o=e<<24|n<<16|n<<8|e^n;L[t]=o,N[t]=o>>>8|o<<24,q[t]=o>>>16|o<<16,G[t]=o>>>24|o<<8}J=!0}}();const e=new i(60),o=function(t,n){const e=t.length>>2,o=e+6,r=4*(o+1);let c=1;for(let o=0;o<e;o++)n[o]=t[4*o]<<24|t[4*o+1]<<16|t[4*o+2]<<8|t[4*o+3];for(let t=e;t<r;t++){let o=n[t-1];t%e==0?(o=Y(o<<8|o>>>24)^c<<24,c=$(c)):e>6&&t%e==4&&(o=Y(o)),n[t]=n[t-e]^o}return o}(t,e),r=new i(4),c=X(n);let s=0,a=0,f=0,w=0;return{process(t,n){n&&c.update(t,0,t.length),function(t){const n=new u(t.buffer,t.byteOffset,t.byteLength),e=t.length;let o=0;for(;o+16<=e;o+=16)l(),n.setInt32(o,n.getInt32(o)^r[0]),n.setInt32(o+4,n.getInt32(o+4)^r[1]),n.setInt32(o+8,n.getInt32(o+8)^r[2]),n.setInt32(o+12,n.getInt32(o+12)^r[3]);if(o<e){l();for(let n=0;o<e;o++,n++)t[o]^=r[n>>2]>>>24-8*(3&n)}}(t),n||c.update(t,0,t.length)},digest:()=>c.digest()};function l(){s=s+1|0,s||(a=a+1|0,a||(f=f+1|0,f||(w=w+1|0)));let t=Z(s)^e[0],n=Z(a)^e[1],c=Z(f)^e[2],i=Z(w)^e[3],u=L[t>>>24]^N[n>>>16&255]^q[c>>>8&255]^G[255&i]^e[4],l=L[n>>>24]^N[c>>>16&255]^q[i>>>8&255]^G[255&t]^e[5],p=L[c>>>24]^N[i>>>16&255]^q[t>>>8&255]^G[255&n]^e[6],d=L[i>>>24]^N[t>>>16&255]^q[n>>>8&255]^G[255&c]^e[7];t=L[u>>>24]^N[l>>>16&255]^q[p>>>8&255]^G[255&d]^e[8],n=L[l>>>24]^N[p>>>16&255]^q[d>>>8&255]^G[255&u]^e[9],c=L[p>>>24]^N[d>>>16&255]^q[u>>>8&255]^G[255&l]^e[10],i=L[d>>>24]^N[u>>>16&255]^q[l>>>8&255]^G[255&p]^e[11],u=L[t>>>24]^N[n>>>16&255]^q[c>>>8&255]^G[255&i]^e[12],l=L[n>>>24]^N[c>>>16&255]^q[i>>>8&255]^G[255&t]^e[13],p=L[c>>>24]^N[i>>>16&255]^q[t>>>8&255]^G[255&n]^e[14],d=L[i>>>24]^N[t>>>16&255]^q[n>>>8&255]^G[255&c]^e[15],t=L[u>>>24]^N[l>>>16&255]^q[p>>>8&255]^G[255&d]^e[16],n=L[l>>>24]^N[p>>>16&255]^q[d>>>8&255]^G[255&u]^e[17],c=L[p>>>24]^N[d>>>16&255]^q[u>>>8&255]^G[255&l]^e[18],i=L[d>>>24]^N[u>>>16&255]^q[l>>>8&255]^G[255&p]^e[19],u=L[t>>>24]^N[n>>>16&255]^q[c>>>8&255]^G[255&i]^e[20],l=L[n>>>24]^N[c>>>16&255]^q[i>>>8&255]^G[255&t]^e[21],p=L[c>>>24]^N[i>>>16&255]^q[t>>>8&255]^G[255&n]^e[22],d=L[i>>>24]^N[t>>>16&255]^q[n>>>8&255]^G[255&c]^e[23],t=L[u>>>24]^N[l>>>16&255]^q[p>>>8&255]^G[255&d]^e[24],n=L[l>>>24]^N[p>>>16&255]^q[d>>>8&255]^G[255&u]^e[25],c=L[p>>>24]^N[d>>>16&255]^q[u>>>8&255]^G[255&l]^e[26],i=L[d>>>24]^N[u>>>16&255]^q[l>>>8&255]^G[255&p]^e[27],u=L[t>>>24]^N[n>>>16&255]^q[c>>>8&255]^G[255&i]^e[28],l=L[n>>>24]^N[c>>>16&255]^q[i>>>8&255]^G[255&t]^e[29],p=L[c>>>24]^N[i>>>16&255]^q[t>>>8&255]^G[255&n]^e[30],d=L[i>>>24]^N[t>>>16&255]^q[n>>>8&255]^G[255&c]^e[31],t=L[u>>>24]^N[l>>>16&255]^q[p>>>8&255]^G[255&d]^e[32],n=L[l>>>24]^N[p>>>16&255]^q[d>>>8&255]^G[255&u]^e[33],c=L[p>>>24]^N[d>>>16&255]^q[u>>>8&255]^G[255&l]^e[34],i=L[d>>>24]^N[u>>>16&255]^q[l>>>8&255]^G[255&p]^e[35],u=L[t>>>24]^N[n>>>16&255]^q[c>>>8&255]^G[255&i]^e[36],l=L[n>>>24]^N[c>>>16&255]^q[i>>>8&255]^G[255&t]^e[37],p=L[c>>>24]^N[i>>>16&255]^q[t>>>8&255]^G[255&n]^e[38],d=L[i>>>24]^N[t>>>16&255]^q[n>>>8&255]^G[255&c]^e[39];let h=40;o>10&&(t=L[u>>>24]^N[l>>>16&255]^q[p>>>8&255]^G[255&d]^e[40],n=L[l>>>24]^N[p>>>16&255]^q[d>>>8&255]^G[255&u]^e[41],c=L[p>>>24]^N[d>>>16&255]^q[u>>>8&255]^G[255&l]^e[42],i=L[d>>>24]^N[u>>>16&255]^q[l>>>8&255]^G[255&p]^e[43],u=L[t>>>24]^N[n>>>16&255]^q[c>>>8&255]^G[255&i]^e[44],l=L[n>>>24]^N[c>>>16&255]^q[i>>>8&255]^G[255&t]^e[45],p=L[c>>>24]^N[i>>>16&255]^q[t>>>8&255]^G[255&n]^e[46],d=L[i>>>24]^N[t>>>16&255]^q[n>>>8&255]^G[255&c]^e[47],h=48),o>12&&(t=L[u>>>24]^N[l>>>16&255]^q[p>>>8&255]^G[255&d]^e[48],n=L[l>>>24]^N[p>>>16&255]^q[d>>>8&255]^G[255&u]^e[49],c=L[p>>>24]^N[d>>>16&255]^q[u>>>8&255]^G[255&l]^e[50],i=L[d>>>24]^N[u>>>16&255]^q[l>>>8&255]^G[255&p]^e[51],u=L[t>>>24]^N[n>>>16&255]^q[c>>>8&255]^G[255&i]^e[52],l=L[n>>>24]^N[c>>>16&255]^q[i>>>8&255]^G[255&t]^e[53],p=L[c>>>24]^N[i>>>16&255]^q[t>>>8&255]^G[255&n]^e[54],d=L[i>>>24]^N[t>>>16&255]^q[n>>>8&255]^G[255&c]^e[55],h=56),r[0]=(T[u>>>24]<<24|T[l>>>16&255]<<16|T[p>>>8&255]<<8|T[255&d])^e[h],r[1]=(T[l>>>24]<<24|T[p>>>16&255]<<16|T[d>>>8&255]<<8|T[255&u])^e[h+1],r[2]=(T[p>>>24]<<24|T[d>>>16&255]<<16|T[u>>>8&255]<<8|T[255&l])^e[h+2],r[3]=(T[d>>>24]<<24|T[u>>>16&255]<<16|T[l>>>8&255]<<8|T[255&p])^e[h+3]}}function X(t){const n=function(){const t=new i(O),n=new i(16),e=new c(V),r=new u(e.buffer),s=new c(8);let a=0,f=0;return{update:w,digest:function(){const n=8*f,e=o.floor(n/4294967296),r=n>>>0;for(w(j,0,1);56!=a;)w(H,0,1);s[0]=e>>>24,s[1]=e>>>16,s[2]=e>>>8,s[3]=e,s[4]=r>>>24,s[5]=r>>>16,s[6]=r>>>8,s[7]=r,w(s,0,8);const i=new c(K),l=new u(i.buffer);for(let n=0;n<t.length;n++)l.setInt32(4*n,t[n]);return t.set(O),a=0,f=0,i}};function w(t,n,o){const c=n+o;if(f+=o,a){for(;n<c&&a<V;)e[a++]=t[n++];a==V&&(l(r,0),a=0)}if(n+V<=c){const e=new u(t.buffer,t.byteOffset,t.byteLength);for(;n+V<=c;n+=V)l(e,n)}for(;n<c;)e[a++]=t[n++]}function l(e,o){for(let t=0;t<16;t++)n[t]=e.getInt32(o+4*t);let r,c=t[0],s=t[1],a=t[2],i=t[3],f=t[4];for(let t=0;t<15;t+=5)f=(c<<5|c>>>27)+((a^i)&s^i)+f+1518500249+n[t]|0,s=s<<30|s>>>2,i=(f<<5|f>>>27)+((s^a)&c^a)+i+1518500249+n[t+1]|0,c=c<<30|c>>>2,a=(i<<5|i>>>27)+((c^s)&f^s)+a+1518500249+n[t+2]|0,f=f<<30|f>>>2,s=(a<<5|a>>>27)+((f^c)&i^c)+s+1518500249+n[t+3]|0,i=i<<30|i>>>2,c=(s<<5|s>>>27)+((i^f)&a^f)+c+1518500249+n[t+4]|0,a=a<<30|a>>>2;f=(c<<5|c>>>27)+((a^i)&s^i)+f+1518500249+n[15]|0,s=s<<30|s>>>2,r=n[13]^n[8]^n[2]^n[0],r=r<<1|r>>>31,n[0]=r,i=(f<<5|f>>>27)+((s^a)&c^a)+i+1518500249+r|0,c=c<<30|c>>>2,r=n[14]^n[9]^n[3]^n[1],r=r<<1|r>>>31,n[1]=r,a=(i<<5|i>>>27)+((c^s)&f^s)+a+1518500249+r|0,f=f<<30|f>>>2,r=n[15]^n[10]^n[4]^n[2],r=r<<1|r>>>31,n[2]=r,s=(a<<5|a>>>27)+((f^c)&i^c)+s+1518500249+r|0,i=i<<30|i>>>2,r=n[0]^n[11]^n[5]^n[3],r=r<<1|r>>>31,n[3]=r,c=(s<<5|s>>>27)+((i^f)&a^f)+c+1518500249+r|0,a=a<<30|a>>>2;for(let t=20;t<40;t+=5)r=n[t-3&15]^n[t-8&15]^n[t-14&15]^n[15&t],r=r<<1|r>>>31,n[15&t]=r,f=(c<<5|c>>>27)+(s^a^i)+f+1859775393+r|0,s=s<<30|s>>>2,r=n[t-2&15]^n[t-7&15]^n[t-13&15]^n[t+1&15],r=r<<1|r>>>31,n[t+1&15]=r,i=(f<<5|f>>>27)+(c^s^a)+i+1859775393+r|0,c=c<<30|c>>>2,r=n[t-1&15]^n[t-6&15]^n[t-12&15]^n[t+2&15],r=r<<1|r>>>31,n[t+2&15]=r,a=(i<<5|i>>>27)+(f^c^s)+a+1859775393+r|0,f=f<<30|f>>>2,r=n[15&t]^n[t-5&15]^n[t-11&15]^n[t+3&15],r=r<<1|r>>>31,n[t+3&15]=r,s=(a<<5|a>>>27)+(i^f^c)+s+1859775393+r|0,i=i<<30|i>>>2,r=n[t+1&15]^n[t-4&15]^n[t-10&15]^n[t+4&15],r=r<<1|r>>>31,n[t+4&15]=r,c=(s<<5|s>>>27)+(a^i^f)+c+1859775393+r|0,a=a<<30|a>>>2;for(let t=40;t<60;t+=5)r=n[t-3&15]^n[t-8&15]^n[t-14&15]^n[15&t],r=r<<1|r>>>31,n[15&t]=r,f=(c<<5|c>>>27)+(s&a|(s|a)&i)+f+2400959708+r|0,s=s<<30|s>>>2,r=n[t-2&15]^n[t-7&15]^n[t-13&15]^n[t+1&15],r=r<<1|r>>>31,n[t+1&15]=r,i=(f<<5|f>>>27)+(c&s|(c|s)&a)+i+2400959708+r|0,c=c<<30|c>>>2,r=n[t-1&15]^n[t-6&15]^n[t-12&15]^n[t+2&15],r=r<<1|r>>>31,n[t+2&15]=r,a=(i<<5|i>>>27)+(f&c|(f|c)&s)+a+2400959708+r|0,f=f<<30|f>>>2,r=n[15&t]^n[t-5&15]^n[t-11&15]^n[t+3&15],r=r<<1|r>>>31,n[t+3&15]=r,s=(a<<5|a>>>27)+(i&f|(i|f)&c)+s+2400959708+r|0,i=i<<30|i>>>2,r=n[t+1&15]^n[t-4&15]^n[t-10&15]^n[t+4&15],r=r<<1|r>>>31,n[t+4&15]=r,c=(s<<5|s>>>27)+(a&i|(a|i)&f)+c+2400959708+r|0,a=a<<30|a>>>2;for(let t=60;t<80;t+=5)r=n[t-3&15]^n[t-8&15]^n[t-14&15]^n[15&t],r=r<<1|r>>>31,n[15&t]=r,f=(c<<5|c>>>27)+(s^a^i)+f+3395469782+r|0,s=s<<30|s>>>2,r=n[t-2&15]^n[t-7&15]^n[t-13&15]^n[t+1&15],r=r<<1|r>>>31,n[t+1&15]=r,i=(f<<5|f>>>27)+(c^s^a)+i+3395469782+r|0,c=c<<30|c>>>2,r=n[t-1&15]^n[t-6&15]^n[t-12&15]^n[t+2&15],r=r<<1|r>>>31,n[t+2&15]=r,a=(i<<5|i>>>27)+(f^c^s)+a+3395469782+r|0,f=f<<30|f>>>2,r=n[15&t]^n[t-5&15]^n[t-11&15]^n[t+3&15],r=r<<1|r>>>31,n[t+3&15]=r,s=(a<<5|a>>>27)+(i^f^c)+s+3395469782+r|0,i=i<<30|i>>>2,r=n[t+1&15]^n[t-4&15]^n[t-10&15]^n[t+4&15],r=r<<1|r>>>31,n[t+4&15]=r,c=(s<<5|s>>>27)+(a^i^f)+c+3395469782+r|0,a=a<<30|a>>>2;t[0]=t[0]+c|0,t[1]=t[1]+s|0,t[2]=t[2]+a|0,t[3]=t[3]+i|0,t[4]=t[4]+f|0}}(),e=new c(V),r=new c(V);t.length>V&&(n.update(t,0,t.length),t=n.digest());for(let n=0;n<V;n++){const o=n<t.length?t[n]:0;e[n]=54^o,r[n]=92^o}return n.update(e,0,V),{update(t,e,o){n.update(t,e,o)},digest(){const t=n.digest();n.update(r,0,V),n.update(t,0,K);const o=n.digest();return n.update(e,0,V),o}}}function Y(t){return T[t>>>24]<<24|T[t>>>16&255]<<16|T[t>>>8&255]<<8|T[255&t]}function Z(t){return t<<24|(65280&t)<<8|t>>>8&65280|t>>>24}function $(t){return 255&(t<<1^27*(t>>7))}const _=typeof p!=b&&typeof p.getRandomValues==k,tt="Invalid password",nt="zipjs-abort-check-password";function et(t){if(_)return p.getRandomValues(t);throw new r("Crypto API not supported")}const ot={name:"PBKDF2"},rt=n.assign({hash:{name:"HMAC"}},ot),ct=n.assign({iterations:1e3,hash:{name:"SHA-1"}},ot),st=["deriveBits"],at=[8,12,16],it=[16,24,32],ft=10,ut=typeof p!=b,wt=ut&&p.subtle;let lt=ut&&typeof wt!=b&&typeof wt.importKey==k&&typeof wt.deriveBits==k,pt=Q;class dt extends h{constructor({password:t,rawPassword:n,encryptionStrength:e,checkPasswordOnly:o,checkAuthenticationCode:s=!0}){const a={};super({start(){yt(a,t,n,e)},async transform(t,n){const{password:e,strength:s,l:i,ready:f}=a;if(e?(await async function(t,n,e,o){const c=await vt(t,n,e,kt(o,0,at[n])),s=kt(o,at[n]);if(c[0]!=s[0]||c[1]!=s[1])throw gt(t),new r(tt)}(a,s,e,kt(t,0,at[s]+2)),t=kt(t,at[s]+2),o?(gt(a),n.error(new r(nt))):i()):await f,a.h)return;const u=new c(t.length-ft-(t.length-ft)%16);n.enqueue(St(a,t,u,0,ft,!0))},async flush(t){const{m:n,S:e,ready:o}=a;if(n){if(await o,a.h)return;const i=kt(e,e.length-ft),f=new c(kt(e,0,e.length-ft));n.process(f,!0);const u=n.digest();let w=e.length<ft?1:0;for(let t=0;t<ft;t++)w|=u[t]^i[t];if(w&&s)return void t.error(new r("Invalid authentication code"));t.enqueue(f)}}}),mt(this,a)}}class ht extends h{constructor({password:t,rawPassword:n,encryptionStrength:e}){const o={};super({start(){yt(o,t,n,e)},async transform(t,n){const{password:e,strength:r,l:s,ready:a}=o;let i=z;if(e?(i=await async function(t,n,e){const o=et(new c(at[n]));return U(o,await vt(t,n,e,o))}(o,r,e),s()):await a,o.h)return;const f=new c(i.length+t.length-t.length%16);f.set(i,0),n.enqueue(St(o,t,f,i.length,0,!1))},async flush(t){const{m:n,S:e,ready:r}=o;if(n){if(await r,o.h)return;const s=new c(e);n.process(s,!1);const a=kt(n.digest(),0,ft);t.enqueue(U(s,a))}}}),mt(this,o)}}function yt(t,e,o,r){n.assign(t,{ready:new w(n=>t.l=n),password:bt(e,o),strength:r-1,S:z,h:!1})}function mt(t,e){const o=t.readable.getReader(),r=new y({async pull(t){try{const{value:n,done:e}=await o.read();e?t.close():t.enqueue(n)}catch(t){throw gt(e),o.cancel(t).catch(()=>{}),t}},cancel:t=>(gt(e),o.cancel(t))});n.defineProperty(t,"readable",{get:()=>r})}function St(t,n,e,o,r,s){const{m:a,S:i}=t;i.length&&(n=U(i,n));const f=n.length-r,u=f-f%16;if(e=function(t,n){if(n&&n>t.length){const e=t;(t=new c(n)).set(e,0)}return t}(e,o+u),u){const t=kt(e,o,o+u);t.set(kt(n,0,u)),a.process(t,s)}return t.S=kt(n,u),e}function gt(t){const{m:n}=t;t.h=!0,n&&n.dispose&&n.dispose()}async function vt(t,e,r,s){t.password=null;const a=it[e],i=await async function(t,e,r){if(lt)try{const o=await wt.importKey("raw",t,rt,!1,st);return new c(await wt.deriveBits(n.assign({salt:e},ct),o,8*r))}catch{lt=!1}return function(t,n,e,r){const s=X(t),a=new c(r),i=new c(n.length+4),f=new u(i.buffer);i.set(n);for(let t=1,e=0;e<r;t++,e+=K){f.setUint32(n.length,t),s.update(i,0,i.length);let c=s.digest();const u=c.slice();for(let t=1;t<1e3;t++){s.update(c,0,K),c=s.digest();for(let t=0;t<K;t++)u[t]^=c[t]}a.set(u.subarray(0,o.min(K,r-e)),e)}return a}(t,e,0,r)}(r,s,2*a+2);return t.m=pt(kt(i,0,a),kt(i,a,2*a)),t.h&>(t),kt(i,2*a)}function bt(t,n){return n===v?function(t){if(typeof l==b){t=unescape(encodeURIComponent(t));const n=new c(t.length);for(let e=0;e<n.length;e++)n[e]=t.charCodeAt(e);return n}return(new l).encode(t)}(t):n}function kt(t,n,e){return t.subarray(n,e)}class zt extends h{constructor({password:t,rawPassword:n,passwordVerification:e,checkPasswordOnly:o}){super({start(){It(this,t,n,e)},transform(t,n){const e=this;if(e.password||e.rawPassword){const n=At(e,t.subarray(0,12));if(e.password=e.rawPassword=null,0!=(n[11]^e.passwordVerification))throw new r(tt);t=t.subarray(12)}o?n.error(new r(nt)):n.enqueue(At(e,t))}})}}class Ct extends h{constructor({password:t,rawPassword:n,passwordVerification:e}){super({start(){It(this,t,n,e)},transform(t,n){const e=this;let o,r;if(e.password||e.rawPassword){e.password=e.rawPassword=null;const n=et(new c(12));n[11]=e.passwordVerification,o=new c(t.length+n.length),o.set(Mt(e,n),0),r=12}else o=new c(t.length),r=0;o.set(Mt(e,t),r),n.enqueue(o)}})}}function It(t,e,o,r){n.assign(t,{password:e,rawPassword:o,passwordVerification:r}),function(t,e,o){const r=[305419896,591751049,878082192];if(n.assign(t,{v:r,C:new E(r[0]),I:new E(r[2])}),o)for(let n=0;n<o.length;n++)xt(t,o[n]);else for(let n=0;n<e.length;n++)xt(t,e.charCodeAt(n))}(t,e,o)}function At(t,n){const e=new c(n.length);for(let o=0;o<n.length;o++)e[o]=Pt(t)^n[o],xt(t,e[o]);return e}function Mt(t,n){const e=new c(n.length);for(let o=0;o<n.length;o++)e[o]=Pt(t)^n[o],xt(t,n[o]);return e}function xt(t,n){let[,e]=t.v;t.C.append([n]);const r=~t.C.get();e=Ft(o.imul(Ft(e+Dt(r)),134775813)+1),t.I.append([e>>>24]);const c=~t.I.get();t.v=[r,e,c]}function Pt(t){const n=2|t.v[2];return Dt(o.imul(n,1^n)>>>8)}function Dt(t){return 255&t}function Ft(t){return 4294967295&t}function Bt(t){if(t instanceof y)return t;const n=t.getReader();return new y({async pull(t){try{const{value:e,done:o}=await n.read();o?t.close():t.enqueue(e)}catch(t){throw n.cancel(t).catch(()=>{}),t}},cancel:t=>n.cancel(t)})}const Et=new f;function Rt(t){return Et.get(t)}const Ut="Invalid uncompressed size",Wt="Invalid CRC32",Vt="deflate-raw",Kt="gzip",jt=[31,139,8];class Ht extends h{constructor(t,{chunkSize:n,CompressionStreamFallback:e,CompressionStream:o}){super({});const{compressed:r,encrypted:c,useCompressionStream:s,zipCrypto:a,computeCrc32:i,level:f,deflate64:w,format:l,compressionMethod:p,inputSize:d}=t,h=this;let y,m,S,g=super.readable;const v=l&&Rt(l),b=Gt(s,o,e),k=i&&r&&!w&&!v&&(!c||a)&&Boolean(b);if(c&&!a||!i||k||(y=new R,g=Qt(g,y)),r)if(v)g=Xt(g,qt(v.CompressionStream,l,{level:f,chunkSize:n,compressionMethod:p,uncompressedSize:d}));else if(k)S=new Ot,g=Xt(g,new b(Kt,{level:f,chunkSize:n})),g=Qt(g,S);else try{g=Jt(g,s,{level:f,chunkSize:n},o,e)}catch(t){if(!s&&e)throw t;let n;try{n=new o(Kt)}catch{throw t}g=Xt(g,n),g=Qt(g,new Ot)}c&&(a?g=Qt(g,new Ct(t)):(m=new ht(t),g=Qt(g,m))),Nt(h,g,()=>{c&&!a||!i||(h.crc32=k?S.crc32:new u(y.value.buffer).getUint32(0))})}}class Ot extends h{constructor(){let t,n=10,e=new c(0);super({transform(t,r){if(n){const e=o.min(n,t.length);if(n-=e,!(t=t.subarray(e)).length)return}const c=e.length+t.length;if(c<=8)return void(e=U(e,t));const s=c-8,a=o.min(s,e.length);r.enqueue(U(e.subarray(0,a),t.subarray(0,s-a))),e=U(e.subarray(a),t.subarray(s-a))},flush(){const n=W(e);t.crc32=n.getUint32(0,!0),t.uncompressedSize=n.getUint32(4,!0)}}),t=this}}class Tt extends h{constructor(t,{chunkSize:n,DecompressionStreamFallback:e,DecompressionStream:o}){super({});const{zipCrypto:s,encrypted:a,checkCrc32:i,crc32:f,compressed:l,useCompressionStream:p,deflate64:d,format:h,compressionMethod:m,rawBitFlag:S,outputSize:g}=t;let b,k,z,C=super.readable;if(a&&(s?C=Qt(C,new zt(t)):(k=new dt(t),C=Qt(C,k))),l){const t=h&&Rt(h);if(t)C=Xt(C,qt(t.DecompressionStream,h,{chunkSize:n,compressionMethod:m,rawBitFlag:S,uncompressedSize:g}));else{let t;const s=Gt(p,o,e);if(i&&!d&&f!==v&&g!==v&&s)try{t=new s(Kt,{chunkSize:n})}catch{t=v}if(!t)try{C=Jt(C,p,{chunkSize:n,deflate64:d},o,e)}catch(n){if(d||g===v||!p&&e)throw n;try{t=new o(Kt)}catch{throw n}}t&&(z=!0,C=function(t,n,e,o){const s=n.writable.getWriter(),a=n.readable.getReader(),i=o===v?new E:v;let f,u,l=0,p=!1,d=!1,h=!1,m=0,S=!1;const g=new w((t,n)=>{f=t,u=n});return g.catch(()=>{}),async function(){const n=t.getReader();try{const t=new c(10);for(t.set(jt),await s.write(t);;){await s.ready;const{value:t,done:e}=await n.read();if(e)break;await s.write(t)}p=!0,i&&(S&&k(),await g);const r=new c(8),a=W(r);a.setUint32(0,i?i.get():o,!0),a.setUint32(4,e,!0),d=!0,await s.write(r),await s.close()}catch(t){await Yt(s,t),await Zt(n,t)}}(),new y({async pull(t){try{const{value:n,done:o}=await function(){m++,S=!0;const t=a.read();return t.then(b,b),p&&i&&k(),t}();if(o)t.close();else{if(l+=n.length,l>e)throw new r(Ut);i&&i.append(n),t.enqueue(n)}}catch(t){throw u(t),await Zt(a,t),d?function(t){const n=new r(l==e?Wt:Ut);return n.cause=t,n}(t):t}},cancel:t=>(u(t),a.cancel(t))});function b(){S=!1}async function k(){if(!h){h=!0;const t=m;await new w(t=>{const{port1:n,port2:e}=new MessageChannel;e.onmessage=()=>{n.close(),e.close(),t()},n.postMessage(v)}),h=!1,S&&(m==t?f():k())}}}(C,t,g,f))}C=function(t){const n=t.getReader();return new y({async pull(t){try{const{value:e,done:o}=await n.read();o?t.close():t.enqueue(e)}catch(t){if(await Zt(n,t),t&&t.message)throw t;const e=new r("Invalid compressed data");throw e.cause=t,e}},cancel:t=>n.cancel(t)})}(C)}i&&!z&&(b=new R,C=Qt(C,b)),Nt(this,C,()=>{if(b){const t=new u(b.value.buffer).getUint32(0,!1);if(f!=t)throw new r(Wt)}})}}const Lt=new f;function Nt(t,e,o){e=Qt(e,new h({flush:o})),n.defineProperty(t,"readable",{get:()=>e})}function qt(t,n,e){if(!t)throw new r("Compression method not supported");return new t(n,e)}function Gt(t,n,e){return t&&n?n:e&&e.requiresModule?e:void 0}function Jt(t,n,e,o,r){const c=n&&o?o:r||o,s=e.deflate64?"deflate64-raw":Vt;let a;try{a=new c(s,e)}catch(t){if(!n||!r||c==r)throw t;a=new r(s,e)}return Xt(t,a)}function Qt(t,n){return Bt(t).pipeThrough(n)}function Xt(t,n){const e=n.writable.getWriter(),o=t.getReader();return async function(){try{for(;;){await e.ready;const t=await o.read();if(t.done){await e.close();break}await e.write(t.value)}}catch(t){await Yt(e,t),await Zt(o,t)}}(),n.readable}async function Yt(t,n){try{await t.abort(n)}catch{}}async function Zt(t,n){try{await t.cancel(n)}catch{}}const $t="data",_t="deflate";class tn extends h{constructor(t,e){super({});const o=this,{codecType:c}=t;let s;c.startsWith(_t)?s=Ht:c.startsWith("inflate")&&(s=Tt),o.outputSize=0;let a=0;const i=new s(t,e),f=super.readable,u=new h({transform(t,n){t&&t.length&&(a+=t.length,n.enqueue(t))},flush(){n.assign(o,{inputSize:a})}}),w=new h({transform(n,e){if(n&&n.length&&(e.enqueue(n),o.outputSize+=n.length,t.outputSize!==v&&o.outputSize>t.outputSize))throw new r(Ut)},flush(){const{crc32:t}=i;n.assign(o,{crc32:t,inputSize:a})}});n.defineProperty(o,"readable",{get:()=>f.pipeThrough(u).pipeThrough(i).pipeThrough(w)})}}class nn extends h{constructor(t){const o=[];let r=0,s=0;function a(){const n=new c(t);let e=0;for(;e<t;){const r=o[0],c=t-e;r.length<=c?(n.set(r,e),e+=r.length,o.shift()):(n.set(r.subarray(0,c),e),o[0]=r.subarray(c),e+=c)}return r-=t,n}(!e.isFinite(t)||t<1)&&(t=65536),super({transform(n,e){for(o.push(n),r+=n.length;r>t;)s+=t,e.enqueue(a())},flush(t){r&&(s+=r,t.enqueue(function(t,n){const e=new c(n);let o=0;for(const n of t)e.set(n,o),o+=n.length;return e}(o,r)))}}),n.defineProperty(this,"outputSize",{get:()=>s})}}let en=2;try{typeof navigator!=b&&navigator.hardwareConcurrency&&(en=navigator.hardwareConcurrency)}catch{}function on(t){return Boolean(t)&&"object"==typeof t}const rn=new f,cn=new f,sn=function(){try{return structuredClone(new r)instanceof r}catch{return!1}}();let an=0;async function fn(t){let n,c,s;try{const{options:a,config:i}=t;if(a.format)try{await async function(t,n){!Et.has(t)&&n&&function(t,n){const{CompressionStream:e,DecompressionStream:o}=n;if(typeof e!=k&&typeof o!=k)throw new r("Invalid codec module");Et.set(t,{CompressionStream:e,DecompressionStream:o})}(t,await(import(n)))}(a.format,a.codecURI)}catch(t){if(on(t))try{t.codecImportFailed=!0}catch{}throw t}if(i.CompressionStream=self.CompressionStream,i.DecompressionStream=self.DecompressionStream,a.compressed&&!a.format)if(a.useCompressionStream){if(!function(t,n){if(!t)return!1;let e=Lt.get(t);e||(e=new f,Lt.set(t,e));let o=e.get(n);if(o===v){try{new t(n),o=!0}catch{o=!1}e.set(n,o)}return o}(a.codecType.startsWith(_t)?i.CompressionStream:i.DecompressionStream,Vt))try{await self.initModule(t.config)}catch{}}else try{await self.initModule(t.config)}catch{a.useCompressionStream=!0}if(a.encrypted&&!a.zipCrypto)try{await self.initModule(t.config)}catch{}!i.CompressionStreamFallback&&i.CompressionStreamZlib&&(i.CompressionStreamFallback=i.CompressionStreamZlib),!i.DecompressionStreamFallback&&i.DecompressionStreamZlib&&(i.DecompressionStreamFallback=i.DecompressionStreamZlib);const u={highWaterMark:1},l=t.readable?Bt(t.readable):new y({async pull(t){const n=new w(t=>rn.set(an,t));un({type:"pull",messageId:an}),an=(an+1)%e.MAX_SAFE_INTEGER;const{value:o,done:r}=await n;t.enqueue(o),r&&t.close()}},u);s=t.writable?function(t){if(t instanceof m)return t;const n=t.getWriter();return new m({write:t=>n.write(t),close:()=>n.close(),abort:t=>n.abort(t)})}(t.writable):new m({async write(t){let n;const o=new w(t=>n=t);cn.set(an,n),un({type:$t,value:t,messageId:an}),an=(an+1)%e.MAX_SAFE_INTEGER,await o}},u),n=new tn(a,i),c=new nn(function(t){return r="string"==typeof(n=r=t.chunkSize)&&n.trim()?e(n):n,e.isInteger(r)&&r>=1?o.max(r,64):65536;var n,r}(i)),await l.pipeThrough(n).pipeThrough(c).pipeTo(s,{preventClose:!0,preventAbort:!0}),await s.getWriter().close();const{crc32:p,inputSize:d,outputSize:h}=n;un({type:"close",result:{crc32:p,inputSize:d,outputSize:h}})}catch(t){const n=c?c.outputSize:0;if(on(t))try{t.outputSize=n}catch{}if(s&&!s.locked)try{await s.getWriter().close()}catch{}wn(t,n)}}function un(t){const{value:n}=t;if(n)if(n.length)try{t.value=(e=n,e.byteOffset||e.byteLength!=e.buffer.byteLength?new c(e):e).buffer,d(t,[t.value])}catch{d(t)}else d(t);else d(t);var e}function wn(t,n){const{message:e,stack:o,code:c,name:s,outputSize:a,cause:i,codecImportFailed:f}=function(t=new r("Unknown error")){return on(t)?t:new r(String(t))}(t),u={message:e,stack:o,code:c,name:s,outputSize:a===v?n:a};if(i&&(u.cause={name:i.name,message:i.message}),f&&(u.codecImportFailed=!0),sn)try{return void d({error:u,errorValue:{value:t}})}catch{}d({error:u})}addEventListener("message",({data:t})=>{const{type:n,messageId:e,value:o,done:r}=t;try{if("start"==n&&fn(t),n==$t){const t=rn.get(e);rn.delete(e),t({value:o||new c,done:r})}if("ack"==n){const t=cn.get(e);cn.delete(e),t()}}catch(t){wn(t)}}),d({type:"ready"});const ln="deflate",pn="deflate-raw",dn="deflate64-raw",hn="gzip";let yn,mn,Sn,gn,vn;function bn(t,n,e={}){if(!yn){const t=new r("WASM module not loaded");throw t.cause=vn,t}const s="number"==typeof e.level?e.level:-1,a="number"==typeof e.outBuffer?e.outBuffer:65536,i="number"==typeof e.inBufferSize?e.inBufferSize:65536,f={A:0,in:0,inBufferSize:0,M:0};let u,l,p,d,h=!0,S=!1;return function(){try{let e;if(f.A=mn(a),f.in=mn(i),f.inBufferSize=i,!f.A||!f.in)throw new r("allocation failed");if(t?(f.P=yn.deflate_process,f.D=yn.deflate_last_consumed,f.F=yn.deflate_end,f.M=yn.deflate_new(),e=n===hn?yn.deflate_init_gzip(f.M,s):n===pn?yn.deflate_init_raw(f.M,s):yn.deflate_init(f.M,s)):n===dn?(f.P=yn.inflate9_process,f.D=yn.inflate9_last_consumed,f.F=yn.inflate9_end,f.M=yn.inflate9_new(),e=yn.inflate9_init_raw(f.M)):(f.P=yn.inflate_process,f.D=yn.inflate_last_consumed,f.F=yn.inflate_end,f.M=yn.inflate_new(),e=n===pn?yn.inflate_init_raw(f.M):n===hn?yn.inflate_init_gzip(f.M):yn.inflate_init(f.M)),0!==e)throw new r("init failed:"+e)}catch(t){throw b(f),t}}(),{readable:new y({start(t){u=t},pull(){h=!1,v()},cancel(t){S=!0,d=t,b(f),l.error(t),v()}},{highWaterMark:0}),writable:new m({start(t){l=t},async write(t){if(h&&await new w(t=>p=t),S)throw d;try{!function(t){const n=new c(gn.buffer),e=f.P,s=f.D,i=f.A;let u=0;for(;u<t.length;){const c=o.min(t.length-u,32768);if((!f.in||f.inBufferSize<c)&&(f.in&&Sn&&(Sn(f.in),f.in=0),f.in=mn(c),f.inBufferSize=c,!f.in))throw new r("allocation failed");n.set(t.subarray(u,u+c),f.in);const w=e(f.M,f.in,c,i,a,0),l=w>>24&255,p=128&l?l-256:l;if(p<0)throw new r("process error:"+p);const d=16777215&w;d&&g(n.slice(i,i+d));const h=s(f.M);if(0===h&&0===d)break;u+=h}}(t)}catch(t){throw b(f),u.error(t),t}},close(){if(S)return;try{!function(){const t=new c(gn.buffer),n=f.P,e=f.A;for(;;){const o=n(f.M,0,0,e,a,4),c=o>>24&255,s=128&c?c-256:c;if(s<0)throw new r("process error:"+s);const i=16777215&o;if(i&&g(t.slice(e,e+i)),1===c||0===i)break}}()}catch(t){throw b(f),u.error(t),t}const t=b(f);if(0!==t){const n=new r("end error:"+t);throw u.error(n),n}u.close()},abort(t){b(f),u.error(t)}},{highWaterMark:1})};function g(t){h=!0,u.enqueue(t)}function v(){if(p){const t=p;p=null,t()}}function b(t){let n=0;return t.M&&t.F&&(n=t.F(t.M)),t.M=0,t.in&&Sn&&Sn(t.in),t.in=0,t.A&&Sn&&Sn(t.A),t.A=0,n}}class kn{constructor(t=ln,n){return bn(!0,t,n)}}class zn{constructor(t=ln,n){return bn(!1,t,n)}}kn.requiresModule=!0,zn.requiresModule=!0,kn.supportedFormats=[ln,pn,hn],zn.supportedFormats=[ln,pn,hn,dn];const Cn=65536;let In,An;function Mn(t){return new c(t.memory.buffer)}let xn=!1;!function(t={}){const{init:n,B:e}=t,o=t.CompressionStreamFallback||t.CompressionStreamZlib,r=t.DecompressionStreamFallback||t.DecompressionStreamZlib;e&&(pt=e||Q),self.initModule=async t=>{n&&await n(t),o&&(t.CompressionStreamFallback=o),r&&(t.DecompressionStreamFallback=r)}}({CompressionStreamFallback:kn,DecompressionStreamFallback:zn,B:function(t,n){const e=In;let o=e?function(t,n,e){An||(An=t.malloc(Cn));const o=An?t.aes_hmac_new():0;if(o){const r=Mn(t);if(r.set(n,An),r.set(e,An+n.length),t.aes_hmac_init(o,An,n.length,An+n.length,e.length))return t.aes_hmac_end(o,0),0}return o}(e,t,n):0;if(!o)return Q(t,n);const r=An;return{process(t,n){for(let c=0;c<t.length;c+=Cn){const s=t.subarray(c,c+Cn),a=Mn(e);a.set(s,r),e.aes_hmac_process(o,r,s.length,n?1:0),s.set(a.subarray(r,r+s.length))}},digest:()=>(e.aes_hmac_end(o,r),o=0,Mn(e).slice(r,r+20)),dispose(){o&&(e.aes_hmac_end(o,0),o=0)}}},init:t=>async function(t,{baseURI:n}){if(!xn)try{await async function(t,n){let e,o;try{try{o=new URL(t,n)}catch{}const r=await fetch(o);e=await r.arrayBuffer()}catch(n){if(!t.startsWith("data:application/wasm;base64,"))throw n;e=function(t){const n=t.split(",")[1],e=atob(n),o=e.length,r=new c(o);for(let t=0;t<o;++t)r[t]=e.charCodeAt(t);return r.buffer}(t)}const s=await WebAssembly.instantiate(e);var a;(function(t){if(yn=t,({malloc:mn,free:Sn,memory:gn}=yn),"function"!=typeof mn||"function"!=typeof Sn||!gn)throw yn=mn=Sn=gn=null,new r("Invalid WASM module")})(s.instance.exports),typeof(a=s.instance.exports).aes_hmac_new==k&&(In=a,An=0)}(t,n),xn=!0}catch(t){throw function(t){vn=t}(t),t}}(t.wasmURI,t)})});\n';if("string"==typeof r&&(r=(new TextEncoder).encode(r)),t){const t=new Blob([r],{type:e});return URL.createObjectURL(t)}return "data:"+e+";base64,"+function(t){let e="";const r=t.length;let o=0;for(;o+2<r;o+=3){const r=t[o]<<16|t[o+1]<<8|t[o+2];e+=n$1[r>>18&63]+n$1[r>>12&63]+n$1[r>>6&63]+n$1[63&r];}const s=r-o;if(1===s){const r=t[o]<<16;e+=n$1[r>>18&63]+n$1[r>>12&63]+"==";}else if(2===s){const r=t[o]<<16|t[o+1]<<8;e+=n$1[r>>18&63]+n$1[r>>12&63]+n$1[r>>6&63]+"=";}return e}(r)}});
|
|
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) {
|
|
@@ -1981,28 +2030,25 @@
|
|
|
1981
2030
|
pump();
|
|
1982
2031
|
return new ReadableStream({
|
|
1983
2032
|
async pull(controller) {
|
|
1984
|
-
let result;
|
|
1985
2033
|
try {
|
|
1986
|
-
|
|
2034
|
+
const { value, done } = await read();
|
|
2035
|
+
if (done) {
|
|
2036
|
+
controller.close();
|
|
2037
|
+
} else {
|
|
2038
|
+
outputLength += value.length;
|
|
2039
|
+
if (outputLength > outputSize) {
|
|
2040
|
+
throw new Error(ERR_INVALID_UNCOMPRESSED_SIZE);
|
|
2041
|
+
}
|
|
2042
|
+
if (outputCrc32) {
|
|
2043
|
+
outputCrc32.append(value);
|
|
2044
|
+
}
|
|
2045
|
+
controller.enqueue(value);
|
|
2046
|
+
}
|
|
1987
2047
|
} catch (error) {
|
|
2048
|
+
rejectTrailerReady(error);
|
|
2049
|
+
await cancel(reader, error);
|
|
1988
2050
|
throw trailerWritten ? getTrailerError(error) : error;
|
|
1989
2051
|
}
|
|
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
|
-
}
|
|
2006
2052
|
},
|
|
2007
2053
|
cancel(reason) {
|
|
2008
2054
|
rejectTrailerReady(reason);
|
|
@@ -2281,10 +2327,15 @@
|
|
|
2281
2327
|
const reader = readable.getReader();
|
|
2282
2328
|
return new ReadableStream({
|
|
2283
2329
|
async pull(controller) {
|
|
2284
|
-
let result;
|
|
2285
2330
|
try {
|
|
2286
|
-
|
|
2331
|
+
const { value, done } = await reader.read();
|
|
2332
|
+
if (done) {
|
|
2333
|
+
controller.close();
|
|
2334
|
+
} else {
|
|
2335
|
+
controller.enqueue(value);
|
|
2336
|
+
}
|
|
2287
2337
|
} catch (error) {
|
|
2338
|
+
await cancel(reader, error);
|
|
2288
2339
|
if (error && error.message) {
|
|
2289
2340
|
throw error;
|
|
2290
2341
|
}
|
|
@@ -2292,12 +2343,6 @@
|
|
|
2292
2343
|
mappedError.cause = error;
|
|
2293
2344
|
throw mappedError;
|
|
2294
2345
|
}
|
|
2295
|
-
const { value, done } = result;
|
|
2296
|
-
if (done) {
|
|
2297
|
-
controller.close();
|
|
2298
|
-
} else {
|
|
2299
|
-
controller.enqueue(value);
|
|
2300
|
-
}
|
|
2301
2346
|
},
|
|
2302
2347
|
cancel(reason) {
|
|
2303
2348
|
return reader.cancel(reason);
|
|
@@ -5376,8 +5421,8 @@
|
|
|
5376
5421
|
const passThroughCompression = Boolean(passThrough);
|
|
5377
5422
|
const passThroughEncryption = passThrough === true;
|
|
5378
5423
|
checkPasswordOption(password, rawPassword);
|
|
5379
|
-
password = password && password.length
|
|
5380
|
-
rawPassword = rawPassword && rawPassword.length
|
|
5424
|
+
password = password && password.length ? password : UNDEFINED_VALUE;
|
|
5425
|
+
rawPassword = rawPassword && rawPassword.length ? rawPassword : UNDEFINED_VALUE;
|
|
5381
5426
|
if (extraFieldAES) {
|
|
5382
5427
|
if (extraFieldAES.originalCompressionMethod != COMPRESSION_METHOD_AES) {
|
|
5383
5428
|
throw new Error(ERR_UNSUPPORTED_COMPRESSION);
|
|
@@ -6138,7 +6183,7 @@
|
|
|
6138
6183
|
async function findEndOfCentralDirectory(reader, rejectAmbiguous, maxAppendedDataSize) {
|
|
6139
6184
|
const { size } = reader;
|
|
6140
6185
|
const anchoredLength = Math.min(size, END_OF_CENTRAL_DIR_LENGTH + MAX_16_BITS);
|
|
6141
|
-
const remoteProbeBudget = {
|
|
6186
|
+
const remoteProbeBudget = { remaining: MAX_END_OF_CENTRAL_DIR_PROBES };
|
|
6142
6187
|
let endOfDirectoryInfo;
|
|
6143
6188
|
let plausibleEndOfDirectoryInfo;
|
|
6144
6189
|
let endOfDirectoryReachingEndCount = 0;
|
|
@@ -6231,8 +6276,8 @@
|
|
|
6231
6276
|
if (signatureOffset >= anchoredOffset) {
|
|
6232
6277
|
return getUint32$1(view, signatureOffset - anchoredOffset);
|
|
6233
6278
|
}
|
|
6234
|
-
if (remoteProbeBudget.
|
|
6235
|
-
remoteProbeBudget.
|
|
6279
|
+
if (remoteProbeBudget.remaining > 0) {
|
|
6280
|
+
remoteProbeBudget.remaining--;
|
|
6236
6281
|
const signatureArray = await readUint8Array(reader, signatureOffset, 4);
|
|
6237
6282
|
return getUint32$1(getDataView(signatureArray), 0);
|
|
6238
6283
|
}
|
|
@@ -7148,9 +7193,11 @@
|
|
|
7148
7193
|
const passThrough = checkPassThroughOption(getOptionValue(zipWriter, options, OPTION_PASS_THROUGH));
|
|
7149
7194
|
const passThroughCompression = Boolean(passThrough);
|
|
7150
7195
|
const passThroughEncryption = passThrough === true;
|
|
7151
|
-
|
|
7152
|
-
|
|
7196
|
+
let password = getOptionValue(zipWriter, options, OPTION_PASSWORD);
|
|
7197
|
+
let rawPassword = getOptionValue(zipWriter, options, OPTION_RAW_PASSWORD);
|
|
7153
7198
|
checkPasswordOption(password, rawPassword);
|
|
7199
|
+
password = password && password.length ? password : UNDEFINED_VALUE;
|
|
7200
|
+
rawPassword = rawPassword && rawPassword.length ? rawPassword : UNDEFINED_VALUE;
|
|
7154
7201
|
const encryptionStrength = getNumberOptionValue(zipWriter, options, OPTION_ENCRYPTION_STRENGTH, 3);
|
|
7155
7202
|
const zipCrypto = getOptionValue(zipWriter, options, PROPERTY_NAME_ZIPCRYPTO);
|
|
7156
7203
|
const extendedTimestamp = getOptionValue(zipWriter, options, OPTION_EXTENDED_TIMESTAMP, true);
|
|
@@ -8946,7 +8993,7 @@
|
|
|
8946
8993
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
8947
8994
|
*/
|
|
8948
8995
|
|
|
8949
|
-
const VERSION = "2.16.
|
|
8996
|
+
const VERSION = "2.16.1";
|
|
8950
8997
|
|
|
8951
8998
|
/*
|
|
8952
8999
|
Copyright (c) 2025 Gildas Lormeau. All rights reserved.
|
|
@@ -9425,7 +9472,7 @@
|
|
|
9425
9472
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
9426
9473
|
*/
|
|
9427
9474
|
|
|
9428
|
-
/* global
|
|
9475
|
+
/* global ReadableStream, WritableStream */
|
|
9429
9476
|
|
|
9430
9477
|
const FORMAT_DEFLATE = "deflate";
|
|
9431
9478
|
const FORMAT_DEFLATE_RAW = "deflate-raw";
|
|
@@ -9460,137 +9507,195 @@
|
|
|
9460
9507
|
const level = (typeof options.level === "number") ? options.level : -1;
|
|
9461
9508
|
const outBufferSize = (typeof options.outBuffer === "number") ? options.outBuffer : 64 * 1024;
|
|
9462
9509
|
const inBufferSize = (typeof options.inBufferSize === "number") ? options.inBufferSize : 64 * 1024;
|
|
9463
|
-
|
|
9464
|
-
|
|
9465
|
-
|
|
9510
|
+
const state = { out: 0, in: 0, inBufferSize: 0, streamHandle: 0 };
|
|
9511
|
+
let readableController, writableController, resolveWrite, cancelReason;
|
|
9512
|
+
let backpressure = true;
|
|
9513
|
+
let cancelled = false;
|
|
9514
|
+
initStream();
|
|
9515
|
+
const readable = new ReadableStream({
|
|
9516
|
+
start(controller) {
|
|
9517
|
+
readableController = controller;
|
|
9518
|
+
},
|
|
9519
|
+
pull() {
|
|
9520
|
+
backpressure = false;
|
|
9521
|
+
resumeWrite();
|
|
9522
|
+
},
|
|
9523
|
+
cancel(reason) {
|
|
9524
|
+
cancelled = true;
|
|
9525
|
+
cancelReason = reason;
|
|
9526
|
+
disposeStream(state);
|
|
9527
|
+
writableController.error(reason);
|
|
9528
|
+
resumeWrite();
|
|
9529
|
+
}
|
|
9530
|
+
}, { highWaterMark: 0 });
|
|
9531
|
+
const writable = new WritableStream({
|
|
9532
|
+
start(controller) {
|
|
9533
|
+
writableController = controller;
|
|
9534
|
+
},
|
|
9535
|
+
async write(chunk) {
|
|
9536
|
+
if (backpressure) {
|
|
9537
|
+
await new Promise(resolve => resolveWrite = resolve);
|
|
9538
|
+
}
|
|
9539
|
+
if (cancelled) {
|
|
9540
|
+
throw cancelReason;
|
|
9541
|
+
}
|
|
9466
9542
|
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
|
-
}
|
|
9543
|
+
processChunk(chunk);
|
|
9510
9544
|
} catch (error) {
|
|
9511
|
-
disposeStream(
|
|
9545
|
+
disposeStream(state);
|
|
9546
|
+
readableController.error(error);
|
|
9512
9547
|
throw error;
|
|
9513
9548
|
}
|
|
9514
9549
|
},
|
|
9515
|
-
|
|
9550
|
+
close() {
|
|
9551
|
+
if (cancelled) {
|
|
9552
|
+
return;
|
|
9553
|
+
}
|
|
9516
9554
|
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
|
-
}
|
|
9555
|
+
flushStream();
|
|
9554
9556
|
} catch (error) {
|
|
9555
|
-
disposeStream(
|
|
9556
|
-
|
|
9557
|
+
disposeStream(state);
|
|
9558
|
+
readableController.error(error);
|
|
9559
|
+
throw error;
|
|
9560
|
+
}
|
|
9561
|
+
const result = disposeStream(state);
|
|
9562
|
+
if (result !== 0) {
|
|
9563
|
+
const error = new Error("end error:" + result);
|
|
9564
|
+
readableController.error(error);
|
|
9565
|
+
throw error;
|
|
9557
9566
|
}
|
|
9567
|
+
readableController.close();
|
|
9558
9568
|
},
|
|
9559
|
-
|
|
9560
|
-
|
|
9561
|
-
|
|
9562
|
-
|
|
9563
|
-
|
|
9564
|
-
|
|
9565
|
-
|
|
9566
|
-
|
|
9567
|
-
|
|
9568
|
-
|
|
9569
|
-
|
|
9570
|
-
|
|
9571
|
-
|
|
9572
|
-
|
|
9573
|
-
|
|
9574
|
-
|
|
9575
|
-
|
|
9576
|
-
|
|
9569
|
+
abort(reason) {
|
|
9570
|
+
disposeStream(state);
|
|
9571
|
+
readableController.error(reason);
|
|
9572
|
+
}
|
|
9573
|
+
}, { highWaterMark: 1 });
|
|
9574
|
+
return { readable, writable };
|
|
9575
|
+
|
|
9576
|
+
function initStream() {
|
|
9577
|
+
try {
|
|
9578
|
+
let result;
|
|
9579
|
+
state.out = malloc(outBufferSize);
|
|
9580
|
+
state.in = malloc(inBufferSize);
|
|
9581
|
+
state.inBufferSize = inBufferSize;
|
|
9582
|
+
if (!state.out || !state.in) {
|
|
9583
|
+
throw new Error("allocation failed");
|
|
9584
|
+
}
|
|
9585
|
+
if (isCompress) {
|
|
9586
|
+
state._process = wasm$1.deflate_process;
|
|
9587
|
+
state._last_consumed = wasm$1.deflate_last_consumed;
|
|
9588
|
+
state._end = wasm$1.deflate_end;
|
|
9589
|
+
state.streamHandle = wasm$1.deflate_new();
|
|
9590
|
+
if (type === FORMAT_GZIP) {
|
|
9591
|
+
result = wasm$1.deflate_init_gzip(state.streamHandle, level);
|
|
9592
|
+
} else if (type === FORMAT_DEFLATE_RAW) {
|
|
9593
|
+
result = wasm$1.deflate_init_raw(state.streamHandle, level);
|
|
9594
|
+
} else {
|
|
9595
|
+
result = wasm$1.deflate_init(state.streamHandle, level);
|
|
9596
|
+
}
|
|
9597
|
+
} else {
|
|
9598
|
+
if (type === FORMAT_DEFLATE64_RAW) {
|
|
9599
|
+
state._process = wasm$1.inflate9_process;
|
|
9600
|
+
state._last_consumed = wasm$1.inflate9_last_consumed;
|
|
9601
|
+
state._end = wasm$1.inflate9_end;
|
|
9602
|
+
state.streamHandle = wasm$1.inflate9_new();
|
|
9603
|
+
result = wasm$1.inflate9_init_raw(state.streamHandle);
|
|
9604
|
+
} else {
|
|
9605
|
+
state._process = wasm$1.inflate_process;
|
|
9606
|
+
state._last_consumed = wasm$1.inflate_last_consumed;
|
|
9607
|
+
state._end = wasm$1.inflate_end;
|
|
9608
|
+
state.streamHandle = wasm$1.inflate_new();
|
|
9609
|
+
if (type === FORMAT_DEFLATE_RAW) {
|
|
9610
|
+
result = wasm$1.inflate_init_raw(state.streamHandle);
|
|
9611
|
+
} else if (type === FORMAT_GZIP) {
|
|
9612
|
+
result = wasm$1.inflate_init_gzip(state.streamHandle);
|
|
9613
|
+
} else {
|
|
9614
|
+
result = wasm$1.inflate_init(state.streamHandle);
|
|
9577
9615
|
}
|
|
9578
9616
|
}
|
|
9579
|
-
}
|
|
9580
|
-
|
|
9581
|
-
|
|
9582
|
-
|
|
9583
|
-
|
|
9584
|
-
|
|
9617
|
+
}
|
|
9618
|
+
if (result !== 0) {
|
|
9619
|
+
throw new Error("init failed:" + result);
|
|
9620
|
+
}
|
|
9621
|
+
} catch (error) {
|
|
9622
|
+
disposeStream(state);
|
|
9623
|
+
throw error;
|
|
9624
|
+
}
|
|
9625
|
+
}
|
|
9626
|
+
|
|
9627
|
+
function processChunk(chunk) {
|
|
9628
|
+
const heap = new Uint8Array(memory.buffer);
|
|
9629
|
+
const process = state._process;
|
|
9630
|
+
const last_consumed = state._last_consumed;
|
|
9631
|
+
const out = state.out;
|
|
9632
|
+
let offset = 0;
|
|
9633
|
+
while (offset < chunk.length) {
|
|
9634
|
+
const toRead = Math.min(chunk.length - offset, 32 * 1024);
|
|
9635
|
+
if (!state.in || state.inBufferSize < toRead) {
|
|
9636
|
+
if (state.in && free) {
|
|
9637
|
+
free(state.in);
|
|
9638
|
+
state.in = 0;
|
|
9639
|
+
}
|
|
9640
|
+
state.in = malloc(toRead);
|
|
9641
|
+
state.inBufferSize = toRead;
|
|
9642
|
+
if (!state.in) {
|
|
9643
|
+
throw new Error("allocation failed");
|
|
9585
9644
|
}
|
|
9586
9645
|
}
|
|
9587
|
-
|
|
9588
|
-
|
|
9589
|
-
//
|
|
9590
|
-
|
|
9591
|
-
|
|
9646
|
+
heap.set(chunk.subarray(offset, offset + toRead), state.in);
|
|
9647
|
+
const result = process(state.streamHandle, state.in, toRead, out, outBufferSize, 0);
|
|
9648
|
+
// checked before the byte count is used, so a status code can never be read as one
|
|
9649
|
+
const code = (result >> 24) & 0xff;
|
|
9650
|
+
const signedCode = (code & 0x80) ? code - 256 : code;
|
|
9651
|
+
if (signedCode < 0) {
|
|
9652
|
+
throw new Error("process error:" + signedCode);
|
|
9653
|
+
}
|
|
9654
|
+
const prod = result & 0x00ffffff;
|
|
9655
|
+
if (prod) {
|
|
9656
|
+
enqueue(heap.slice(out, out + prod));
|
|
9657
|
+
}
|
|
9658
|
+
const consumed = last_consumed(state.streamHandle);
|
|
9659
|
+
if (consumed === 0 && prod === 0) {
|
|
9660
|
+
break;
|
|
9661
|
+
}
|
|
9662
|
+
offset += consumed;
|
|
9592
9663
|
}
|
|
9593
|
-
}
|
|
9664
|
+
}
|
|
9665
|
+
|
|
9666
|
+
function flushStream() {
|
|
9667
|
+
const heap = new Uint8Array(memory.buffer);
|
|
9668
|
+
const process = state._process;
|
|
9669
|
+
const out = state.out;
|
|
9670
|
+
while (true) {
|
|
9671
|
+
const result = process(state.streamHandle, 0, 0, out, outBufferSize, 4);
|
|
9672
|
+
const code = (result >> 24) & 0xff;
|
|
9673
|
+
const signedCode = (code & 0x80) ? code - 256 : code;
|
|
9674
|
+
if (signedCode < 0) {
|
|
9675
|
+
throw new Error("process error:" + signedCode);
|
|
9676
|
+
}
|
|
9677
|
+
const produced = result & 0x00ffffff;
|
|
9678
|
+
if (produced) {
|
|
9679
|
+
enqueue(heap.slice(out, out + produced));
|
|
9680
|
+
}
|
|
9681
|
+
if (code === 1 || produced === 0) {
|
|
9682
|
+
break;
|
|
9683
|
+
}
|
|
9684
|
+
}
|
|
9685
|
+
}
|
|
9686
|
+
|
|
9687
|
+
function enqueue(chunk) {
|
|
9688
|
+
backpressure = true;
|
|
9689
|
+
readableController.enqueue(chunk);
|
|
9690
|
+
}
|
|
9691
|
+
|
|
9692
|
+
function resumeWrite() {
|
|
9693
|
+
if (resolveWrite) {
|
|
9694
|
+
const resolve = resolveWrite;
|
|
9695
|
+
resolveWrite = null;
|
|
9696
|
+
resolve();
|
|
9697
|
+
}
|
|
9698
|
+
}
|
|
9594
9699
|
|
|
9595
9700
|
function disposeStream(state) {
|
|
9596
9701
|
let endResult = 0;
|
|
@@ -9946,7 +10051,11 @@
|
|
|
9946
10051
|
const ERR_INVALID_PASS_THROUGH = "Invalid passThrough option (use readerOptions.passThrough or set uncompressedSize for each entry)";
|
|
9947
10052
|
const ERR_INVALID_READER_OPTIONS = "Invalid readerOptions (must be an object)";
|
|
9948
10053
|
const ERR_UNSUPPORTED_PASS_THROUGH_VALUE = "The 'compressed' passThrough option is only supported by Entry#getData() and ZipWriter#add()";
|
|
10054
|
+
const ERR_INVALID_PASSWORDS = "Invalid passwords option (must be an array of strings)";
|
|
10055
|
+
const ERR_INVALID_REQUEST_PASSWORD = "Invalid requestPassword option (must be a function returning a string or undefined)";
|
|
9949
10056
|
const ERR_ABORT_EXPORT = "zipjs-abort-export";
|
|
10057
|
+
const ABORT_ERROR_NAME = "AbortError";
|
|
10058
|
+
const EMPTY_RAW_PASSWORD = new Uint8Array(0);
|
|
9950
10059
|
|
|
9951
10060
|
class ZipEntry {
|
|
9952
10061
|
|
|
@@ -10319,8 +10428,10 @@
|
|
|
10319
10428
|
zipReader = new ZipReader(reader, options);
|
|
10320
10429
|
}
|
|
10321
10430
|
checkPassThroughValue(options.passThrough);
|
|
10431
|
+
checkPasswordCandidatesOptions(options);
|
|
10322
10432
|
const duplicates = checkDuplicatesOption(options.duplicates);
|
|
10323
10433
|
const importedEntries = [];
|
|
10434
|
+
const passwordState = { known: [] };
|
|
10324
10435
|
const entries = await zipReader.getEntries(options);
|
|
10325
10436
|
for (const entry of entries) {
|
|
10326
10437
|
let parent = this;
|
|
@@ -10365,7 +10476,7 @@
|
|
|
10365
10476
|
}
|
|
10366
10477
|
importedEntries.push(addChild(parent, name, {
|
|
10367
10478
|
data: entry,
|
|
10368
|
-
Reader: getZipBlobReader(Object.assign({}, options)),
|
|
10479
|
+
Reader: getZipBlobReader(Object.assign({}, options), passwordState),
|
|
10369
10480
|
uncompressedSize: options.passThrough ? entry.compressedSize : entry.uncompressedSize,
|
|
10370
10481
|
passThrough: options.passThrough
|
|
10371
10482
|
}));
|
|
@@ -10694,7 +10805,7 @@
|
|
|
10694
10805
|
};
|
|
10695
10806
|
}
|
|
10696
10807
|
|
|
10697
|
-
function getZipBlobReader(options) {
|
|
10808
|
+
function getZipBlobReader(options, passwordState) {
|
|
10698
10809
|
return class extends Reader {
|
|
10699
10810
|
|
|
10700
10811
|
constructor(entry, options = {}) {
|
|
@@ -10707,12 +10818,12 @@
|
|
|
10707
10818
|
const zipBlobReader = this;
|
|
10708
10819
|
const readerOptions = Object.assign({}, options, zipBlobReader.options);
|
|
10709
10820
|
const { checkOverlappingEntry, checkOverlappingEntryOnly } = readerOptions;
|
|
10710
|
-
const data = await zipBlobReader.entry
|
|
10821
|
+
const data = await readEntryData(zipBlobReader.entry, Object.assign(readerOptions, {
|
|
10711
10822
|
checkPasswordOnly: false,
|
|
10712
10823
|
checkOverlappingEntry: checkOverlappingEntryOnly || checkOverlappingEntry,
|
|
10713
10824
|
checkOverlappingEntryOnly: false,
|
|
10714
10825
|
preventClose: false
|
|
10715
|
-
}));
|
|
10826
|
+
}), passwordState);
|
|
10716
10827
|
zipBlobReader.data = data;
|
|
10717
10828
|
zipBlobReader.blobReader = new BlobReader(data);
|
|
10718
10829
|
zipBlobReader.size = data.size;
|
|
@@ -10774,10 +10885,9 @@
|
|
|
10774
10885
|
await initStream(reader);
|
|
10775
10886
|
} catch (error) {
|
|
10776
10887
|
try {
|
|
10888
|
+
error.entry = child;
|
|
10777
10889
|
error.entryId = child.id;
|
|
10778
|
-
error.
|
|
10779
|
-
entry: child
|
|
10780
|
-
};
|
|
10890
|
+
error.entryName = child.getRelativeName(entry);
|
|
10781
10891
|
} catch {
|
|
10782
10892
|
// ignored
|
|
10783
10893
|
}
|
|
@@ -10869,10 +10979,136 @@
|
|
|
10869
10979
|
}
|
|
10870
10980
|
if (readerOptions) {
|
|
10871
10981
|
checkPassThroughValue(readerOptions.passThrough);
|
|
10982
|
+
checkPasswordCandidatesOptions(readerOptions);
|
|
10872
10983
|
}
|
|
10873
10984
|
return readerOptions;
|
|
10874
10985
|
}
|
|
10875
10986
|
|
|
10987
|
+
function checkPasswordCandidatesOptions(options) {
|
|
10988
|
+
const { passwords, requestPassword } = options;
|
|
10989
|
+
if (passwords && (!Array.isArray(passwords) || passwords.some(password => typeof password != STRING_TYPE))) {
|
|
10990
|
+
throw new Error(ERR_INVALID_PASSWORDS);
|
|
10991
|
+
}
|
|
10992
|
+
if (requestPassword && typeof requestPassword != FUNCTION_TYPE) {
|
|
10993
|
+
throw new Error(ERR_INVALID_REQUEST_PASSWORD);
|
|
10994
|
+
}
|
|
10995
|
+
}
|
|
10996
|
+
|
|
10997
|
+
async function readEntryData(entry, options, passwordState) {
|
|
10998
|
+
checkPasswordCandidatesOptions(options);
|
|
10999
|
+
const { passwords, requestPassword, signal } = options;
|
|
11000
|
+
options = Object.assign({}, options);
|
|
11001
|
+
delete options.passwords;
|
|
11002
|
+
delete options.requestPassword;
|
|
11003
|
+
if (!entry.encrypted || options.passThrough || (!passwords && !requestPassword)) {
|
|
11004
|
+
return entry.getData(new BlobWriter(), options);
|
|
11005
|
+
}
|
|
11006
|
+
const tried = new Set();
|
|
11007
|
+
let error;
|
|
11008
|
+
while (true) {
|
|
11009
|
+
for (const candidate of getPasswordCandidates(options, passwordState, passwords)) {
|
|
11010
|
+
if (!tried.has(candidate.key)) {
|
|
11011
|
+
const result = await tryPasswordCandidate(candidate);
|
|
11012
|
+
if (result.done) {
|
|
11013
|
+
return result.data;
|
|
11014
|
+
}
|
|
11015
|
+
error = result.error;
|
|
11016
|
+
}
|
|
11017
|
+
}
|
|
11018
|
+
if (!requestPassword) {
|
|
11019
|
+
break;
|
|
11020
|
+
}
|
|
11021
|
+
if (passwordState.pendingPrompt) {
|
|
11022
|
+
await passwordState.pendingPrompt;
|
|
11023
|
+
continue;
|
|
11024
|
+
}
|
|
11025
|
+
let release;
|
|
11026
|
+
passwordState.pendingPrompt = new Promise(resolve => release = resolve);
|
|
11027
|
+
try {
|
|
11028
|
+
const answer = await requestPassword(entry, error);
|
|
11029
|
+
if (answer === UNDEFINED_VALUE || answer === null) {
|
|
11030
|
+
break;
|
|
11031
|
+
}
|
|
11032
|
+
// deno-lint-ignore valid-typeof
|
|
11033
|
+
if (typeof answer != STRING_TYPE) {
|
|
11034
|
+
throw new Error(ERR_INVALID_REQUEST_PASSWORD);
|
|
11035
|
+
}
|
|
11036
|
+
const result = await tryPasswordCandidate(getPasswordCandidate(answer));
|
|
11037
|
+
if (result.done) {
|
|
11038
|
+
return result.data;
|
|
11039
|
+
}
|
|
11040
|
+
error = result.error;
|
|
11041
|
+
} finally {
|
|
11042
|
+
passwordState.pendingPrompt = UNDEFINED_VALUE;
|
|
11043
|
+
release();
|
|
11044
|
+
}
|
|
11045
|
+
}
|
|
11046
|
+
throw new Error(tried.size ? ERR_INVALID_PASSWORD : ERR_ENCRYPTED);
|
|
11047
|
+
|
|
11048
|
+
async function tryPasswordCandidate(candidate) {
|
|
11049
|
+
tried.add(candidate.key);
|
|
11050
|
+
const candidateOptions = Object.assign({}, options, candidate.options);
|
|
11051
|
+
if (entry.zipCrypto) {
|
|
11052
|
+
candidateOptions.checkCrc32 = true;
|
|
11053
|
+
try {
|
|
11054
|
+
await entry.getData(null, Object.assign({}, candidateOptions, { checkPasswordOnly: true }));
|
|
11055
|
+
} catch (probeError) {
|
|
11056
|
+
if (isInvalidPasswordError(probeError)) {
|
|
11057
|
+
return { done: false, error: probeError };
|
|
11058
|
+
}
|
|
11059
|
+
throw probeError;
|
|
11060
|
+
}
|
|
11061
|
+
}
|
|
11062
|
+
try {
|
|
11063
|
+
const data = await entry.getData(new BlobWriter(), candidateOptions);
|
|
11064
|
+
rememberPassword(passwordState, candidate);
|
|
11065
|
+
return { done: true, data };
|
|
11066
|
+
} catch (readError) {
|
|
11067
|
+
if (isAbortError(readError, signal) || (!entry.zipCrypto && !isInvalidPasswordError(readError))) {
|
|
11068
|
+
throw readError;
|
|
11069
|
+
}
|
|
11070
|
+
return { done: false, error: readError };
|
|
11071
|
+
}
|
|
11072
|
+
}
|
|
11073
|
+
}
|
|
11074
|
+
|
|
11075
|
+
function isInvalidPasswordError(error) {
|
|
11076
|
+
return isErrorObject(error) && error.message == ERR_INVALID_PASSWORD;
|
|
11077
|
+
}
|
|
11078
|
+
|
|
11079
|
+
function isAbortError(error, signal) {
|
|
11080
|
+
return Boolean(signal && signal.aborted) || (isErrorObject(error) && error.name == ABORT_ERROR_NAME);
|
|
11081
|
+
}
|
|
11082
|
+
|
|
11083
|
+
function getPasswordCandidates(options, passwordState, passwords) {
|
|
11084
|
+
const candidates = [];
|
|
11085
|
+
const { password, rawPassword } = options;
|
|
11086
|
+
if (rawPassword && rawPassword.length) {
|
|
11087
|
+
candidates.push({ key: rawPassword, options: { password: "", rawPassword } });
|
|
11088
|
+
}
|
|
11089
|
+
if (password) {
|
|
11090
|
+
candidates.push(getPasswordCandidate(password));
|
|
11091
|
+
}
|
|
11092
|
+
candidates.push(...passwordState.known);
|
|
11093
|
+
if (passwords) {
|
|
11094
|
+
candidates.push(...passwords.filter(password => password).map(getPasswordCandidate));
|
|
11095
|
+
}
|
|
11096
|
+
return candidates;
|
|
11097
|
+
}
|
|
11098
|
+
|
|
11099
|
+
function getPasswordCandidate(password) {
|
|
11100
|
+
return { key: password, options: { password, rawPassword: EMPTY_RAW_PASSWORD } };
|
|
11101
|
+
}
|
|
11102
|
+
|
|
11103
|
+
function rememberPassword(passwordState, candidate) {
|
|
11104
|
+
const { known } = passwordState;
|
|
11105
|
+
const index = known.findIndex(knownCandidate => knownCandidate.key === candidate.key);
|
|
11106
|
+
if (index != -1) {
|
|
11107
|
+
known.splice(index, 1);
|
|
11108
|
+
}
|
|
11109
|
+
known.unshift(candidate);
|
|
11110
|
+
}
|
|
11111
|
+
|
|
10876
11112
|
function checkPassThroughValue(passThrough) {
|
|
10877
11113
|
if (checkPassThroughOption(passThrough) === PASS_THROUGH_COMPRESSED) {
|
|
10878
11114
|
throw new Error(ERR_UNSUPPORTED_PASS_THROUGH_VALUE);
|
|
@@ -11010,6 +11246,7 @@
|
|
|
11010
11246
|
async function exportFileSystemHandle(zipEntry, directoryHandle, options) {
|
|
11011
11247
|
const { onstart, onprogress, onend } = options;
|
|
11012
11248
|
checkPassThroughValue(options.passThrough);
|
|
11249
|
+
checkPasswordCandidatesOptions(options);
|
|
11013
11250
|
const readerOptions = checkReaderOptions(options.readerOptions);
|
|
11014
11251
|
const abortController = new AbortController();
|
|
11015
11252
|
const { signal } = abortController;
|
|
@@ -11403,11 +11640,13 @@
|
|
|
11403
11640
|
exports.ERR_INVALID_MSDOS_ATTRIBUTES = ERR_INVALID_MSDOS_ATTRIBUTES;
|
|
11404
11641
|
exports.ERR_INVALID_MSDOS_DATA = ERR_INVALID_MSDOS_DATA;
|
|
11405
11642
|
exports.ERR_INVALID_PASSWORD = ERR_INVALID_PASSWORD;
|
|
11643
|
+
exports.ERR_INVALID_PASSWORDS = ERR_INVALID_PASSWORDS;
|
|
11406
11644
|
exports.ERR_INVALID_PASSWORD_TYPE = ERR_INVALID_PASSWORD_TYPE;
|
|
11407
11645
|
exports.ERR_INVALID_PASS_THROUGH = ERR_INVALID_PASS_THROUGH;
|
|
11408
11646
|
exports.ERR_INVALID_PASS_THROUGH_VALUE = ERR_INVALID_PASS_THROUGH_VALUE;
|
|
11409
11647
|
exports.ERR_INVALID_READER = ERR_INVALID_READER;
|
|
11410
11648
|
exports.ERR_INVALID_READER_OPTIONS = ERR_INVALID_READER_OPTIONS;
|
|
11649
|
+
exports.ERR_INVALID_REQUEST_PASSWORD = ERR_INVALID_REQUEST_PASSWORD;
|
|
11411
11650
|
exports.ERR_INVALID_SIGNAL = ERR_INVALID_SIGNAL;
|
|
11412
11651
|
exports.ERR_INVALID_SIGNATURE_DATA = ERR_INVALID_SIGNATURE_DATA;
|
|
11413
11652
|
exports.ERR_INVALID_STRICTNESS = ERR_INVALID_STRICTNESS;
|