@zip.js/zip.js 2.8.42 → 2.8.44
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/README.md +0 -37
- package/deno.json +1 -1
- package/dist/zip-core-external.js +178 -77
- package/dist/zip-core-external.min.js +1 -1
- package/dist/zip-core.js +179 -76
- package/dist/zip-core.min.js +1 -1
- package/dist/zip-fs-core-external.js +178 -77
- package/dist/zip-fs-core-external.min.js +1 -1
- package/dist/zip-fs-core.js +177 -76
- package/dist/zip-fs-core.min.js +1 -1
- package/dist/zip-fs-external.js +178 -77
- package/dist/zip-fs-external.min.js +1 -1
- package/dist/zip-fs-native.js +180 -77
- package/dist/zip-fs-native.min.js +1 -1
- package/dist/zip-fs.js +180 -77
- package/dist/zip-fs.min.js +1 -1
- package/dist/zip-legacy.js +180 -77
- package/dist/zip-legacy.min.js +1 -1
- package/dist/zip-native.js +180 -77
- 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 +180 -77
- package/dist/zip.min.js +1 -1
- package/index-native.cjs +180 -77
- package/index-native.min.js +1 -1
- package/index.cjs +180 -77
- package/index.d.cts +80 -7
- package/index.d.ts +80 -7
- package/index.min.js +1 -1
- package/lib/core/codec-pool.js +6 -2
- package/lib/core/codec-worker.js +23 -2
- package/lib/core/options.js +4 -0
- package/lib/core/streams/aes-crypto-stream.js +4 -4
- package/lib/core/streams/codec-stream.js +8 -2
- package/lib/core/streams/common-crypto.js +2 -0
- package/lib/core/streams/zip-entry-stream.js +102 -36
- package/lib/core/web-worker-inline-native.js +1 -1
- package/lib/core/web-worker-inline-wasm.js +1 -1
- package/lib/core/web-worker-wasm.js +4 -8
- package/lib/core/zip-entry.js +3 -0
- package/lib/core/zip-reader.js +35 -26
- package/lib/core/zip-writer.js +22 -10
- package/lib/zip-core-reader.js +2 -0
- package/package.json +1 -1
- package/worker-message-property-names.js +1 -1
package/index.cjs
CHANGED
|
@@ -218,7 +218,7 @@ function resetConfiguration() {
|
|
|
218
218
|
Object.assign(config, DEFAULT_CONFIGURATION);
|
|
219
219
|
}
|
|
220
220
|
|
|
221
|
-
function t$1(t){const e='(t=>{"function"==typeof define&&define.amd?define(t):t()})(function(){"use strict";const{Array:t,Object:e,Number:n,Math:s,Error:r,Uint8Array:o,Uint16Array:c,Uint32Array:i,Int32Array:a,Map:f,DataView:l,Promise:u,TextEncoder:w,crypto:h,postMessage:p,TransformStream:d,ReadableStream:y,WritableStream:m,CompressionStream:g,DecompressionStream:S}=self,v=void 0,b="undefined",z="function",k=new o,C=[[],[],[],[],[],[],[],[]];for(let t=0;256>t;t++){let e=t;for(let t=0;8>t;t++)e=1&e?e>>>1^3988292384:e>>>1;C[0][t]=e}for(let t=0;256>t;t++)for(let e=1;8>e;e++){const n=C[e-1][t];C[e][t]=n>>>8^C[0][255&n]}const[A,I,x,M,P,B,D,R]=C;class U{constructor(t){this.o=t||-1}append(t){let e=0|this.o;const n=0|t.length;let s=0;if(n>=8&&t.buffer){const r=new l(t.buffer,t.byteOffset,n),o=n-8;for(;o>=s;s+=8){const t=e^r.getInt32(s,!0),n=r.getInt32(s+4,!0);e=R[255&t]^D[t>>>8&255]^B[t>>>16&255]^P[t>>>24&255]^M[255&n]^x[n>>>8&255]^I[n>>>16&255]^A[n>>>24&255]}}for(;n>s;s++)e=e>>>8^A[255&(e^t[s])];this.o=e}get(){return~this.o}}class W extends d{constructor(){let t;const e=new U;super({transform(t,n){e.append(t),n.enqueue(t)},flush(){const n=new o(4);new l(n.buffer).setUint32(0,e.get()),t.value=n}}),t=this}}function _(t,e){const n=new o(t.length+e.length);return n.set(t),n.set(e,t.length),n}function V(t){return new l(t.buffer,t.byteOffset,t.byteLength)}const K={concat(t,e){if(0===t.length||0===e.length)return t.concat(e);const n=t[t.length-1],s=K.l(n);return 32===s?t.concat(e):K.h(e,s,0|n,t.slice(0,t.length-1))},m(t){const e=t.length;if(0===e)return 0;const n=t[e-1];return 32*(e-1)+K.l(n)},S(t,e){if(32*t.length<e)return t;const n=(t=t.slice(0,s.ceil(e/32))).length;return e&=31,n>0&&e&&(t[n-1]=K.v(e,t[n-1]&2147483648>>e-1,1)),t},v:(t,e,n)=>32===t?e:(n?0|e:e<<32-t)+1099511627776*t,l:t=>s.round(t/1099511627776)||32,h(t,e,n,s){for(void 0===s&&(s=[]);e>=32;e-=32)s.push(n),n=0;if(0===e)return s.concat(t);for(let r=0;r<t.length;r++)s.push(n|t[r]>>>e),n=t[r]<<32-e;const r=t.length?t[t.length-1]:0,o=K.l(r);return s.push(K.v(e+o&31,e+o>32?n:s.pop(),1)),s}},E={bytes:{C(t){const e=K.m(t)/8,n=new o(e);let s;for(let r=0;e>r;r++)3&r||(s=t[r/4]),n[r]=s>>>24,s<<=8;return n},A(t){const e=[];let n,s=0;for(n=0;n<t.length;n++)s=s<<8|t[n],3&~n||(e.push(s),s=0);return 3&n&&e.push(K.v(8*(3&n),s)),e}}},F=class{constructor(t){const e=this;e.blockSize=512,e.I=[1732584193,4023233417,2562383102,271733878,3285377520],e.M=[1518500249,1859775393,2400959708,3395469782],t?(e.P=t.P.slice(0),e.B=t.B.slice(0),e.D=t.D):e.reset()}reset(){const t=this;return t.P=t.I.slice(0),t.B=[],t.D=0,t}update(t){const e=this;"string"==typeof t&&(t=E.R.A(t));const n=e.B=K.concat(e.B,t),s=e.D,o=e.D=s+K.m(t);if(o>9007199254740991)throw new r("Cannot hash more than 2^53 - 1 bits");const c=new i(n);let a=0;for(let t=e.blockSize+s-(e.blockSize+s&e.blockSize-1);o>=t;t+=e.blockSize)e.U(c.subarray(16*a,16*(a+1))),a+=1;return n.splice(0,16*a),e}W(){const t=this;let e=t.B;const n=t.P;e=K.concat(e,[K.v(1,1)]);for(let t=e.length+2;15&t;t++)e.push(0);for(e.push(s.floor(t.D/4294967296)),e.push(0|t.D);e.length;)t.U(e.splice(0,16));return t.reset(),n}_(t,e,n,s){return t>19?t>39?t>59?t>79?void 0:e^n^s:e&n|e&s|n&s:e^n^s:e&n|~e&s}V(t,e){return e<<t|e>>>32-t}U(e){const n=this,r=n.P,o=t(80);for(let t=0;16>t;t++)o[t]=e[t];let c=r[0],i=r[1],a=r[2],f=r[3],l=r[4];for(let t=0;79>=t;t++){16>t||(o[t]=n.V(1,o[t-3]^o[t-8]^o[t-14]^o[t-16]));const e=n.V(5,c)+n._(t,i,a,f)+l+o[t]+n.M[s.floor(t/20)]|0;l=f,f=a,a=n.V(30,i),i=c,c=e}r[0]=r[0]+c|0,r[1]=r[1]+i|0,r[2]=r[2]+a|0,r[3]=r[3]+f|0,r[4]=r[4]+l|0}},L={importKey:t=>new L.K(E.bytes.A(t)),F(t,e,n,s){if(n=n||1e4,0>s||0>n)throw new r("invalid params to pbkdf2");const o=1+(s>>5)<<2;let c,i,a,f,u;const w=new ArrayBuffer(o),h=new l(w);let p=0;const d=K;for(e=E.bytes.A(e),u=1;(o||1)>p;u++){for(c=i=t.encrypt(d.concat(e,[u])),a=1;n>a;a++)for(i=t.encrypt(i),f=0;f<i.length;f++)c[f]^=i[f];for(a=0;(o||1)>p&&a<c.length;a++)h.setInt32(p,c[a]),p+=4}return w.slice(0,s/8)},K:class{constructor(t){const e=this,n=e.L=F,s=[[],[]];e.O=[new n,new n];const r=e.O[0].blockSize/32;t.length>r&&(t=(new n).update(t).W());for(let e=0;r>e;e++)s[0][e]=909522486^t[e],s[1][e]=1549556828^t[e];e.O[0].update(s[0]),e.O[1].update(s[1]),e.T=new n(e.O[0])}reset(){const t=this;t.T=new t.L(t.O[0]),t.j=!1}update(t){this.j=!0,this.T.update(t)}digest(){const t=this,e=t.T.W(),n=new t.L(t.O[1]).update(e).W();return t.reset(),n}encrypt(t){if(this.j)throw new r("encrypt on already updated hmac called!");return this.update(t),this.digest(t)}}},O=typeof h!=b&&typeof h.getRandomValues==z,T="Invalid password",j="Invalid signature",H="zipjs-abort-check-password";function Z(t){if(O)return h.getRandomValues(t);throw new r("Crypto API not supported")}const N=16,q={name:"PBKDF2"},G=e.assign({hash:{name:"HMAC"}},q),J=e.assign({iterations:1e3,hash:{name:"SHA-1"}},q),Q=["deriveBits"],X=[8,12,16],Y=[16,24,32],$=10,tt=[0,0,0,0],et=typeof h!=b,nt=et&&h.subtle,st=et&&typeof nt!=b,rt=E.bytes,ot=class{constructor(t){const e=this;e.H=[[[],[],[],[],[]],[[],[],[],[],[]]],e.H[0][0][0]||e.Z();const n=e.H[0][4],s=e.H[1],o=t.length;let c,i,a,f=1;if(4!==o&&6!==o&&8!==o)throw new r("invalid aes key size");for(e.M=[i=t.slice(0),a=[]],c=o;4*o+28>c;c++){let t=i[c-1];(c%o===0||8===o&&c%o===4)&&(t=n[t>>>24]<<24^n[t>>16&255]<<16^n[t>>8&255]<<8^n[255&t],c%o===0&&(t=t<<8^t>>>24^f<<24,f=f<<1^283*(f>>7))),i[c]=i[c-o]^t}for(let t=0;c;t++,c--){const e=i[3&t?c:c-4];a[t]=4>=c||4>t?e:s[0][n[e>>>24]]^s[1][n[e>>16&255]]^s[2][n[e>>8&255]]^s[3][n[255&e]]}}encrypt(t){return this.N(t,0)}decrypt(t){return this.N(t,1)}Z(){const t=this.H[0],e=this.H[1],n=t[4],s=e[4],r=[],o=[];let c,i,a,f;for(let t=0;256>t;t++)o[(r[t]=t<<1^283*(t>>7))^t]=t;for(let l=c=0;!n[l];l^=i||1,c=o[c]||1){let o=c^c<<1^c<<2^c<<3^c<<4;o=o>>8^255&o^99,n[l]=o,s[o]=l,f=r[a=r[i=r[l]]];let u=16843009*f^65537*a^257*i^16843008*l,w=257*r[o]^16843008*o;for(let n=0;4>n;n++)t[n][l]=w=w<<24^w>>>8,e[n][o]=u=u<<24^u>>>8}for(let n=0;5>n;n++)t[n]=t[n].slice(0),e[n]=e[n].slice(0)}N(t,e){if(4!==t.length)throw new r("invalid aes block size");const n=this.M[e],s=n.length/4-2,o=[0,0,0,0],c=this.H[e],i=c[0],a=c[1],f=c[2],l=c[3],u=c[4];let w,h,p,d=t[0]^n[0],y=t[e?3:1]^n[1],m=t[2]^n[2],g=t[e?1:3]^n[3],S=4;for(let t=0;s>t;t++)w=i[d>>>24]^a[y>>16&255]^f[m>>8&255]^l[255&g]^n[S],h=i[y>>>24]^a[m>>16&255]^f[g>>8&255]^l[255&d]^n[S+1],p=i[m>>>24]^a[g>>16&255]^f[d>>8&255]^l[255&y]^n[S+2],g=i[g>>>24]^a[d>>16&255]^f[y>>8&255]^l[255&m]^n[S+3],S+=4,d=w,y=h,m=p;for(let t=0;4>t;t++)o[e?3&-t:t]=u[d>>>24]<<24^u[y>>16&255]<<16^u[m>>8&255]<<8^u[255&g]^n[S++],w=d,d=y,y=m,m=g,g=w;return o}},ct=class{constructor(t,e){this.G=t,this.J=e,this.X=e}reset(){this.X=this.J}update(t){return this.Y(this.G,t,this.X)}$(t){if(255&~(t>>24))t+=1<<24;else{let e=t>>16&255,n=t>>8&255,s=255&t;255===e?(e=0,255===n?(n=0,255===s?s=0:++s):++n):++e,t=0,t+=e<<16,t+=n<<8,t+=s}return t}et(t){0===(t[0]=this.$(t[0]))&&(t[1]=this.$(t[1]))}Y(t,e,n){let s;if(!(s=e.length))return[];const r=K.m(e);for(let r=0;s>r;r+=4){this.et(n);const s=t.encrypt(n);e[r]^=s[0],e[r+1]^=s[1],e[r+2]^=s[2],e[r+3]^=s[3]}return K.S(e,r)}},it=L.K;let at=et&&st&&typeof nt.importKey==z,ft=et&&st&&typeof nt.deriveBits==z;class lt extends d{constructor({password:t,rawPassword:e,encryptionStrength:n,checkPasswordOnly:s}){super({start(){wt(this,t,e,n)},async transform(t,e){const n=this,{password:c,strength:i,nt:a,ready:f}=n;c?(await(async(t,e,n,s)=>{const o=await pt(t,e,n,yt(s,0,X[e])),c=yt(s,X[e]);if(o[0]!=c[0]||o[1]!=c[1])throw new r(T)})(n,i,c,yt(t,0,X[i]+2)),t=yt(t,X[i]+2),s?e.error(new r(H)):a()):await f;const l=new o(t.length-$-(t.length-$)%N);e.enqueue(ht(n,t,l,0,$,!0))},async flush(t){const{st:e,ot:n,pending:s,ready:o}=this;if(n&&e){await o;const c=yt(s,0,s.length-$),i=yt(s,s.length-$);let a=k;if(c.length){const t=gt(rt,c);n.update(t);const s=e.update(t);a=mt(rt,s)}const f=yt(mt(rt,n.digest()),0,$);let l=s.length<$?1:0;for(let t=0;$>t;t++)l|=f[t]^i[t];if(l)throw new r(j);t.enqueue(a)}}})}}class ut extends d{constructor({password:t,rawPassword:e,encryptionStrength:n}){let s;super({start(){wt(this,t,e,n)},async transform(t,e){const n=this,{password:s,strength:r,nt:c,ready:i}=n;let a=k;s?(a=await(async(t,e,n)=>{const s=Z(new o(X[e]));return _(s,await pt(t,e,n,s))})(n,r,s),c()):await i;const f=new o(a.length+t.length-t.length%N);f.set(a,0),e.enqueue(ht(n,t,f,a.length,0))},async flush(t){const{st:e,ot:n,pending:r,ready:o}=this;if(n&&e){await o;let c=k;if(r.length){const t=e.update(gt(rt,r));n.update(t),c=mt(rt,t)}s.signature=mt(rt,n.digest()).slice(0,$),t.enqueue(_(c,s.signature))}}}),s=this}}function wt(t,n,s,r){e.assign(t,{ready:new u(e=>t.nt=e),password:dt(n,s),strength:r-1,pending:k})}function ht(t,e,n,s,r,c){const{st:i,ot:a,pending:f}=t;f.length&&(e=_(f,e));const l=e.length-r;let u;for(n=((t,e)=>{if(e&&e>t.length){const n=t;(t=new o(e)).set(n,0)}return t})(n,s+(l-l%N)),u=0;l-N>=u;u+=N){const t=gt(rt,yt(e,u,u+N));c&&a.update(t);const r=i.update(t);c||a.update(r),n.set(mt(rt,r),u+s)}return t.pending=yt(e,u),n}async function pt(n,s,r,c){n.password=null;const i=await(async(t,e,n,s,r)=>{if(!at)return L.importKey(e);try{return await nt.importKey("raw",e,n,!1,r)}catch{return at=!1,L.importKey(e)}})(0,r,G,0,Q),a=await(async(t,e,n)=>{if(!ft)return L.F(e,t.salt,J.iterations,n);try{return await nt.deriveBits(t,e,n)}catch{return ft=!1,L.F(e,t.salt,J.iterations,n)}})(e.assign({salt:c},J),i,8*(2*Y[s]+2)),f=new o(a),l=gt(rt,yt(f,0,Y[s])),u=gt(rt,yt(f,Y[s],2*Y[s])),w=yt(f,2*Y[s]);return e.assign(n,{keys:{key:l,ct:u,passwordVerification:w},st:new ct(new ot(l),t.from(tt)),ot:new it(u)}),w}function dt(t,e){return e===v?(t=>{if(typeof w==b){const e=new o((t=unescape(encodeURIComponent(t))).length);for(let n=0;n<e.length;n++)e[n]=t.charCodeAt(n);return e}return(new w).encode(t)})(t):e}function yt(t,e,n){return t.subarray(e,n)}function mt(t,e){return t.C(e)}function gt(t,e){return t.A(e)}class St extends d{constructor({password:t,rawPassword:e,passwordVerification:n,checkPasswordOnly:s}){super({start(){bt(this,t,e,n)},transform(t,e){const n=this;if(n.password||n.rawPassword){const e=zt(n,t.subarray(0,12));if(n.password=n.rawPassword=null,0!=(e[11]^n.passwordVerification))throw new r(T);t=t.subarray(12)}s?e.error(new r(H)):e.enqueue(zt(n,t))}})}}class vt extends d{constructor({password:t,rawPassword:e,passwordVerification:n}){super({start(){bt(this,t,e,n)},transform(t,e){const n=this;let s,r;if(n.password||n.rawPassword){n.password=n.rawPassword=null;const e=Z(new o(12));e[11]=n.passwordVerification,s=new o(t.length+e.length),s.set(kt(n,e),0),r=12}else s=new o(t.length),r=0;s.set(kt(n,t),r),e.enqueue(s)}})}}function bt(t,n,s,r){e.assign(t,{password:n,rawPassword:s,passwordVerification:r}),((t,n,s)=>{const r=[305419896,591751049,878082192];if(e.assign(t,{keys:r,it:new U(r[0]),ft:new U(r[2])}),s)for(let e=0;e<s.length;e++)Ct(t,s[e]);else for(let e=0;e<n.length;e++)Ct(t,n.charCodeAt(e))})(t,n,s)}function zt(t,e){const n=new o(e.length);for(let s=0;s<e.length;s++)n[s]=At(t)^e[s],Ct(t,n[s]);return n}function kt(t,e){const n=new o(e.length);for(let s=0;s<e.length;s++)n[s]=At(t)^e[s],Ct(t,e[s]);return n}function Ct(t,e){let[,n]=t.keys;t.it.append([e]);const r=~t.it.get();n=xt(s.imul(xt(n+It(r)),134775813)+1),t.ft.append([n>>>24]);const o=~t.ft.get();t.keys=[r,n,o]}function At(t){const e=2|t.keys[2];return It(s.imul(e,1^e)>>>8)}function It(t){return 255&t}function xt(t){return 4294967295&t}const Mt=new f;function Pt(t){return Mt.get(t)}const Bt="deflate-raw",Dt="gzip",Rt=[31,139,8];class Ut extends d{constructor(t,{chunkSize:e,CompressionStreamZlib:n,CompressionStream:s}){super({});const{compressed:r,encrypted:o,useCompressionStream:c,zipCrypto:i,signed:a,level:f,deflate64:u,format:w,compressionMethod:h}=t,p=this;let d,y,m,g=super.readable;const S=w&&Pt(w),v=a&&r&&!u&&!S&&(!o||i)&&!(!c||!s);if(o&&!i||!a||v||(d=new W,g=Ot(g,d)),r)if(S)g=Tt(g,Ft(S.CompressionStream,w,{level:f,chunkSize:e,compressionMethod:h}));else if(v)m=new Wt,g=Tt(g,new s(Dt)),g=Ot(g,m);else try{g=Lt(g,c,{level:f,chunkSize:e},s,n)}catch(t){let e;try{e=new s(Dt)}catch{throw t}g=Tt(g,e),g=Ot(g,new Wt)}o&&(i?g=Ot(g,new vt(t)):(y=new ut(t),g=Ot(g,y))),Et(p,g,()=>{let t;o&&!i&&(t=y.signature),o&&!i||!a||(t=v?m.signature:new l(d.value.buffer).getUint32(0)),p.signature=t})}}class Wt extends d{constructor(){let t,e=10,n=new o(0);super({transform(t,r){if(e){const n=s.min(e,t.length);if(e-=n,!(t=t.subarray(n)).length)return}const o=n.length+t.length;if(8>=o)return void(n=_(n,t));const c=o-8,i=s.min(c,n.length);r.enqueue(_(n.subarray(0,i),t.subarray(0,c-i))),n=_(n.subarray(i),t.subarray(c-i))},flush(){const e=V(n);t.signature=e.getUint32(0,!0),t.uncompressedSize=e.getUint32(4,!0)}}),t=this}}class _t extends d{constructor(t,e){super({start(t){const e=new o(10);e.set(Rt),t.enqueue(e)},transform(t,e){e.enqueue(t)},flush(n){const s=new o(8),r=V(s);r.setUint32(0,t,!0),r.setUint32(4,e,!0),n.enqueue(s)}})}}class Vt extends d{constructor(t,{chunkSize:e,DecompressionStreamZlib:n,DecompressionStream:s}){super({});const{zipCrypto:o,encrypted:c,signed:i,signature:a,compressed:f,useCompressionStream:u,deflate64:w,format:h,compressionMethod:p,rawBitFlag:d,outputSize:m}=t;let g,S,b=super.readable;if(c&&(o?b=Ot(b,new St(t)):(S=new lt(t),b=Ot(b,S))),f){const t=h&&Pt(h);if(t)b=Tt(b,Ft(t.DecompressionStream,h,{chunkSize:e,compressionMethod:p,rawBitFlag:d,uncompressedSize:m}));else try{b=Lt(b,u,{chunkSize:e,deflate64:w},s,n)}catch(t){if(w||c&&!o||a===v||m===v)throw t;let e;try{e=new s(Dt)}catch{throw t}b=Ot(b,new _t(a,m)),b=Tt(b,e)}b=(t=>{const e=t.getReader();return new y({async pull(t){let n;try{n=await e.read()}catch(t){if(t&&t.message)throw t;const e=new r("Invalid compressed data");throw e.cause=t,e}const{value:s,done:o}=n;o?t.close():t.enqueue(s)},cancel:t=>e.cancel(t)})})(b)}c&&!o||!i||(g=new W,b=Ot(b,g)),Et(this,b,()=>{if((!c||o)&&i){const t=new l(g.value.buffer);if(a!=t.getUint32(0,!1))throw new r(j)}})}}const Kt=new f;function Et(t,n,s){n=Ot(n,new d({flush:s})),e.defineProperty(t,"readable",{get:()=>n})}function Ft(t,e,n){if(!t)throw new r("Compression method not supported");return new t(e,n)}function Lt(t,e,n,s,r){const o=e&&s?s:r||s,c=n.deflate64?"deflate64-raw":Bt;let i;try{i=new o(c,n)}catch(t){if(!e||!r||o==r)throw t;i=new r(c,n)}return Tt(t,i)}function Ot(t,e){return(t=>{if(t instanceof y)return t;const e=t.getReader();return new y({async pull(t){const{value:n,done:s}=await e.read();s?t.close():t.enqueue(n)},cancel:t=>e.cancel(t)})})(t).pipeThrough(e)}function Tt(t,e){const n=e.writable.getWriter(),s=t.getReader();return(async()=>{try{for(;;){await n.ready;const t=await s.read();if(t.done){await n.close();break}await n.write(t.value)}}catch(t){await(async(t,e)=>{try{await t.abort(e)}catch{}})(n,t),await(async(t,e)=>{try{await t.cancel(e)}catch{}})(s,t)}})(),e.readable}const jt="data",Ht="close",Zt="deflate";class Nt extends d{constructor(t,n){super({});const s=this,{codecType:o}=t;let c;o.startsWith(Zt)?c=Ut:o.startsWith("inflate")&&(c=Vt),s.outputSize=0;let i=0;const a=new c(t,n),f=super.readable,l=new d({transform(t,e){t&&t.length&&(i+=t.length,e.enqueue(t))},flush(){e.assign(s,{inputSize:i})}}),u=new d({transform(e,n){if(e&&e.length&&(n.enqueue(e),s.outputSize+=e.length,t.outputSize!==v&&s.outputSize>t.outputSize))throw new r("Invalid uncompressed size")},flush(){const{signature:t}=a;e.assign(s,{signature:t,inputSize:i})}});e.defineProperty(s,"readable",{get:()=>f.pipeThrough(l).pipeThrough(a).pipeThrough(u)})}}class qt extends d{constructor(t){const e=[];let s=0;function r(){const n=new o(t);let r=0;for(;t>r;){const s=e[0],o=t-r;s.length>o?(n.set(s.subarray(0,o),r),e[0]=s.subarray(o),r+=o):(n.set(s,r),r+=s.length,e.shift())}return s-=t,n}n.isFinite(t)&&t>=1||(t=65536),super({transform(n,o){for(e.push(n),s+=n.length;s>t;)o.enqueue(r())},flush(t){s&&t.enqueue(((t,e)=>{const n=new o(e);let s=0;for(const e of t)n.set(e,s),s+=e.length;return n})(e,s))}})}}let Gt=2;try{typeof navigator!=b&&navigator.hardwareConcurrency&&(Gt=navigator.hardwareConcurrency)}catch{}const Jt=new f,Qt=new f;let Xt,Yt,$t,te,ee,ne,se=0;async function re(t){let e,o;try{const{options:c,config:i}=t;if(c.format&&await(async(t,e)=>{!Mt.has(t)&&e&&((t,e)=>{const{CompressionStream:n,DecompressionStream:s}=e;if(typeof n!=z&&typeof s!=z)throw new r("Invalid codec module");Mt.set(t,{CompressionStream:n,DecompressionStream:s})})(t,await(import(e)))})(c.format,c.codecURI),i.CompressionStream=self.CompressionStream,i.DecompressionStream=self.DecompressionStream,c.compressed&&!c.format)if(c.useCompressionStream){if(!(t=>{if(!t)return!1;let e=Kt.get(t);if(e===v){try{new t(Bt),e=!0}catch{e=!1}Kt.set(t,e)}return e})(c.codecType.startsWith(Zt)?i.CompressionStream:i.DecompressionStream))try{await self.initModule(t.config)}catch{}}else try{await self.initModule(t.config)}catch{c.useCompressionStream=!0}const a={highWaterMark:1},f=t.readable||new y({async pull(t){const e=new u(t=>Jt.set(se,t));oe({type:"pull",messageId:se}),se=(se+1)%n.MAX_SAFE_INTEGER;const{value:s,done:r}=await e;t.enqueue(s),r&&t.close()}},a);o=t.writable||new m({async write(t){let e;const s=new u(t=>e=t);Qt.set(se,e),oe({type:jt,value:t,messageId:se}),se=(se+1)%n.MAX_SAFE_INTEGER,await s}},a),e=new Nt(c,i),Xt=new AbortController;const{signal:l}=Xt;await f.pipeThrough(e).pipeThrough(new qt((t=>s.max(t.chunkSize,64))(i))).pipeTo(o,{signal:l,preventClose:!0,preventAbort:!0}),await o.getWriter().close();const{signature:w,inputSize:h,outputSize:p}=e;oe({type:Ht,result:{signature:w,inputSize:h,outputSize:p}})}catch(t){if(t.outputSize=e?e.outputSize:0,o&&!o.locked)try{await o.getWriter().close()}catch{}ce(t)}}function oe(t){const{value:e}=t;if(e)if(e.length)try{t.value=(n=e,n.byteOffset||n.byteLength!=n.buffer.byteLength?new o(n):n).buffer,p(t,[t.value])}catch{p(t)}else p(t);else p(t);var n}function ce(t=new r("Unknown error")){const{message:e,stack:n,code:s,name:o,outputSize:c,cause:i}=t,a={message:e,stack:n,code:s,name:o,outputSize:c};i&&(a.cause={name:i.name,message:i.message}),p({error:a})}function ie(t,e,n={}){if(!Yt){const t=new r("WASM module not loaded");throw t.cause=ne,t}const c="number"==typeof n.level?n.level:-1,i="number"==typeof n.outBuffer?n.outBuffer:65536,a="number"==typeof n.inBufferSize?n.inBufferSize:65536;return new d({start(){try{let n;if(this.lt=$t(i),this.in=$t(a),this.inBufferSize=a,!this.lt||!this.in)throw new r("allocation failed");if(this.ut=new o(i),t?(this.wt=Yt.deflate_process,this.ht=Yt.deflate_last_consumed,this.yt=Yt.deflate_end,this.gt=Yt.deflate_new(),n="gzip"===e?Yt.deflate_init_gzip(this.gt,c):"deflate-raw"===e?Yt.deflate_init_raw(this.gt,c):Yt.deflate_init(this.gt,c)):"deflate64-raw"===e?(this.wt=Yt.inflate9_process,this.ht=Yt.inflate9_last_consumed,this.yt=Yt.inflate9_end,this.gt=Yt.inflate9_new(),n=Yt.inflate9_init_raw(this.gt)):(this.wt=Yt.inflate_process,this.ht=Yt.inflate_last_consumed,this.yt=Yt.inflate_end,this.gt=Yt.inflate_new(),n="deflate-raw"===e?Yt.inflate_init_raw(this.gt):"gzip"===e?Yt.inflate_init_gzip(this.gt):Yt.inflate_init(this.gt)),0!==n)throw new r("init failed:"+n)}catch(t){throw f(this),t}},transform(e,n){try{const c=e,a=new o(ee.buffer),f=this.wt,l=this.ht,u=this.lt,w=this.ut;let h=0;for(;h<c.length;){const e=s.min(c.length-h,32768);if((!this.in||this.inBufferSize<e)&&(this.in&&te&&(te(this.in),this.in=0),this.in=$t(e),this.inBufferSize=e,!this.in))throw new r("allocation failed");a.set(c.subarray(h,h+e),this.in);const o=f(this.gt,this.in,e,u,i,0),p=16777215&o;if(p&&(w.set(a.subarray(u,u+p),0),n.enqueue(w.slice(0,p))),!t){const t=o>>24&255,e=128&t?t-256:t;if(0>e)throw new r("process error:"+e)}const d=l(this.gt);if(0===d)break;h+=d}}catch(t){f(this),n.error(t)}},flush(e){try{const n=new o(ee.buffer),s=this.wt,c=this.lt,a=this.ut;for(;;){const o=s(this.gt,0,0,c,i,4),f=16777215&o,l=o>>24&255;if(!t){const t=128&l?l-256:l;if(0>t)throw new r("process error:"+t)}if(f&&(a.set(n.subarray(c,c+f),0),e.enqueue(a.slice(0,f))),1===l||0===f)break}}catch(t){e.error(t)}finally{const t=f(this);0!==t&&e.error(new r("end error:"+t))}},cancel(){f(this)}});function f(t){let e=0;return t.gt&&t.yt&&(e=t.yt(t.gt)),t.gt=0,t.in&&te&&te(t.in),t.in=0,t.lt&&te&&te(t.lt),t.lt=0,e}}addEventListener("message",({data:t})=>{const{type:e,messageId:n,value:s,done:r}=t;try{if("start"==e&&re(t),e==jt){const t=Jt.get(n);Jt.delete(n),t({value:s||new o,done:r})}if("ack"==e){const t=Qt.get(n);Qt.delete(n),t()}e==Ht&&Xt.abort()}catch(t){ce(t)}}),p({type:"ready"});class ae{constructor(t="deflate",e){return ie(!0,t,e)}}class fe{constructor(t="deflate",e){return ie(!1,t,e)}}ae.St=!0,fe.St=!0;let le=!1;self.initModule=async t=>{try{const e=await(async(t,{baseURI:e})=>{if(!le)try{await(async(t,e)=>{let n,s;try{try{s=new URL(t,e)}catch{}const r=await fetch(s);n=await r.arrayBuffer()}catch(e){if(!t.startsWith("data:application/wasm;base64,"))throw e;n=(t=>{const e=t.split(",")[1],n=atob(e),s=n.length,r=new o(s);for(let t=0;s>t;++t)r[t]=n.charCodeAt(t);return r.buffer})(t)}(t=>{if(Yt=t,({malloc:$t,free:te,memory:ee}=Yt),"function"!=typeof $t||"function"!=typeof te||!ee)throw Yt=$t=te=ee=null,new r("Invalid WASM module")})((await WebAssembly.instantiate(n)).instance.exports)})(t,e),le=!0}catch(t){throw(t=>{ne=t})(t),t}})(t.wasmURI,t);return t.CompressionStreamZlib=ae,t.DecompressionStreamZlib=fe,e}catch{}}});\n';t({workerURI:t=>{const n="text/javascript";if(t){const t=new Blob([e],{type:n});return URL.createObjectURL(t)}return "data:"+n+","+encodeURIComponent(e)}});}
|
|
221
|
+
function t$1(t){const e='(t=>{"function"==typeof define&&define.amd?define(t):t()})(function(){"use strict";const{Array:t,Object:e,Number:n,Math:s,Error:r,Uint8Array:o,Uint16Array:c,Uint32Array:i,Int32Array:a,Map:f,DataView:l,Promise:u,TextEncoder:w,crypto:h,postMessage:p,TransformStream:d,ReadableStream:y,WritableStream:m,CompressionStream:g,DecompressionStream:S}=self,v=void 0,b="undefined",k="function",z=new o,C=[[],[],[],[],[],[],[],[]];for(let t=0;256>t;t++){let e=t;for(let t=0;8>t;t++)e=1&e?e>>>1^3988292384:e>>>1;C[0][t]=e}for(let t=0;256>t;t++)for(let e=1;8>e;e++){const n=C[e-1][t];C[e][t]=n>>>8^C[0][255&n]}const[A,I,x,M,P,B,D,R]=C;class U{constructor(t){this.o=t||-1}append(t){let e=0|this.o;const n=0|t.length;let s=0;if(n>=8&&t.buffer){const r=new l(t.buffer,t.byteOffset,n),o=n-8;for(;o>=s;s+=8){const t=e^r.getInt32(s,!0),n=r.getInt32(s+4,!0);e=R[255&t]^D[t>>>8&255]^B[t>>>16&255]^P[t>>>24&255]^M[255&n]^x[n>>>8&255]^I[n>>>16&255]^A[n>>>24&255]}}for(;n>s;s++)e=e>>>8^A[255&(e^t[s])];this.o=e}get(){return~this.o}}class W extends d{constructor(){let t;const e=new U;super({transform(t,n){e.append(t),n.enqueue(t)},flush(){const n=new o(4);new l(n.buffer).setUint32(0,e.get()),t.value=n}}),t=this}}function _(t,e){const n=new o(t.length+e.length);return n.set(t),n.set(e,t.length),n}function T(t){return new l(t.buffer,t.byteOffset,t.byteLength)}const V={concat(t,e){if(0===t.length||0===e.length)return t.concat(e);const n=t[t.length-1],s=V.l(n);return 32===s?t.concat(e):V.h(e,s,0|n,t.slice(0,t.length-1))},m(t){const e=t.length;if(0===e)return 0;const n=t[e-1];return 32*(e-1)+V.l(n)},S(t,e){if(32*t.length<e)return t;const n=(t=t.slice(0,s.ceil(e/32))).length;return e&=31,n>0&&e&&(t[n-1]=V.v(e,t[n-1]&2147483648>>e-1,1)),t},v:(t,e,n)=>32===t?e:(n?0|e:e<<32-t)+1099511627776*t,l:t=>s.round(t/1099511627776)||32,h(t,e,n,s){for(void 0===s&&(s=[]);e>=32;e-=32)s.push(n),n=0;if(0===e)return s.concat(t);for(let r=0;r<t.length;r++)s.push(n|t[r]>>>e),n=t[r]<<32-e;const r=t.length?t[t.length-1]:0,o=V.l(r);return s.push(V.v(e+o&31,e+o>32?n:s.pop(),1)),s}},K={bytes:{C(t){const e=V.m(t)/8,n=new o(e);let s;for(let r=0;e>r;r++)3&r||(s=t[r/4]),n[r]=s>>>24,s<<=8;return n},A(t){const e=[];let n,s=0;for(n=0;n<t.length;n++)s=s<<8|t[n],3&~n||(e.push(s),s=0);return 3&n&&e.push(V.v(8*(3&n),s)),e}}},E=class{constructor(t){const e=this;e.blockSize=512,e.I=[1732584193,4023233417,2562383102,271733878,3285377520],e.M=[1518500249,1859775393,2400959708,3395469782],t?(e.P=t.P.slice(0),e.B=t.B.slice(0),e.D=t.D):e.reset()}reset(){const t=this;return t.P=t.I.slice(0),t.B=[],t.D=0,t}update(t){const e=this;"string"==typeof t&&(t=K.R.A(t));const n=e.B=V.concat(e.B,t),s=e.D,o=e.D=s+V.m(t);if(o>9007199254740991)throw new r("Cannot hash more than 2^53 - 1 bits");const c=new i(n);let a=0;for(let t=e.blockSize+s-(e.blockSize+s&e.blockSize-1);o>=t;t+=e.blockSize)e.U(c.subarray(16*a,16*(a+1))),a+=1;return n.splice(0,16*a),e}W(){const t=this;let e=t.B;const n=t.P;e=V.concat(e,[V.v(1,1)]);for(let t=e.length+2;15&t;t++)e.push(0);for(e.push(s.floor(t.D/4294967296)),e.push(0|t.D);e.length;)t.U(e.splice(0,16));return t.reset(),n}_(t,e,n,s){return t>19?t>39?t>59?t>79?void 0:e^n^s:e&n|e&s|n&s:e^n^s:e&n|~e&s}T(t,e){return e<<t|e>>>32-t}U(e){const n=this,r=n.P,o=t(80);for(let t=0;16>t;t++)o[t]=e[t];let c=r[0],i=r[1],a=r[2],f=r[3],l=r[4];for(let t=0;79>=t;t++){16>t||(o[t]=n.T(1,o[t-3]^o[t-8]^o[t-14]^o[t-16]));const e=n.T(5,c)+n._(t,i,a,f)+l+o[t]+n.M[s.floor(t/20)]|0;l=f,f=a,a=n.T(30,i),i=c,c=e}r[0]=r[0]+c|0,r[1]=r[1]+i|0,r[2]=r[2]+a|0,r[3]=r[3]+f|0,r[4]=r[4]+l|0}},F={importKey:t=>new F.V(K.bytes.A(t)),K(t,e,n,s){if(n=n||1e4,0>s||0>n)throw new r("invalid params to pbkdf2");const o=1+(s>>5)<<2;let c,i,a,f,u;const w=new ArrayBuffer(o),h=new l(w);let p=0;const d=V;for(e=K.bytes.A(e),u=1;(o||1)>p;u++){for(c=i=t.encrypt(d.concat(e,[u])),a=1;n>a;a++)for(i=t.encrypt(i),f=0;f<i.length;f++)c[f]^=i[f];for(a=0;(o||1)>p&&a<c.length;a++)h.setInt32(p,c[a]),p+=4}return w.slice(0,s/8)},V:class{constructor(t){const e=this,n=e.F=E,s=[[],[]];e.L=[new n,new n];const r=e.L[0].blockSize/32;t.length>r&&(t=(new n).update(t).W());for(let e=0;r>e;e++)s[0][e]=909522486^t[e],s[1][e]=1549556828^t[e];e.L[0].update(s[0]),e.L[1].update(s[1]),e.O=new n(e.L[0])}reset(){const t=this;t.O=new t.F(t.L[0]),t.j=!1}update(t){this.j=!0,this.O.update(t)}digest(){const t=this,e=t.O.W(),n=new t.F(t.L[1]).update(e).W();return t.reset(),n}encrypt(t){if(this.j)throw new r("encrypt on already updated hmac called!");return this.update(t),this.digest(t)}}},L=typeof h!=b&&typeof h.getRandomValues==k,O="Invalid password",j="Invalid signature",H=j,Z="zipjs-abort-check-password";function N(t){if(L)return h.getRandomValues(t);throw new r("Crypto API not supported")}const q=16,G={name:"PBKDF2"},J=e.assign({hash:{name:"HMAC"}},G),Q=e.assign({iterations:1e3,hash:{name:"SHA-1"}},G),X=["deriveBits"],Y=[8,12,16],$=[16,24,32],tt=10,et=[0,0,0,0],nt=typeof h!=b,st=nt&&h.subtle,rt=nt&&typeof st!=b,ot=K.bytes,ct=class{constructor(t){const e=this;e.H=[[[],[],[],[],[]],[[],[],[],[],[]]],e.H[0][0][0]||e.Z();const n=e.H[0][4],s=e.H[1],o=t.length;let c,i,a,f=1;if(4!==o&&6!==o&&8!==o)throw new r("invalid aes key size");for(e.M=[i=t.slice(0),a=[]],c=o;4*o+28>c;c++){let t=i[c-1];(c%o===0||8===o&&c%o===4)&&(t=n[t>>>24]<<24^n[t>>16&255]<<16^n[t>>8&255]<<8^n[255&t],c%o===0&&(t=t<<8^t>>>24^f<<24,f=f<<1^283*(f>>7))),i[c]=i[c-o]^t}for(let t=0;c;t++,c--){const e=i[3&t?c:c-4];a[t]=4>=c||4>t?e:s[0][n[e>>>24]]^s[1][n[e>>16&255]]^s[2][n[e>>8&255]]^s[3][n[255&e]]}}encrypt(t){return this.N(t,0)}decrypt(t){return this.N(t,1)}Z(){const t=this.H[0],e=this.H[1],n=t[4],s=e[4],r=[],o=[];let c,i,a,f;for(let t=0;256>t;t++)o[(r[t]=t<<1^283*(t>>7))^t]=t;for(let l=c=0;!n[l];l^=i||1,c=o[c]||1){let o=c^c<<1^c<<2^c<<3^c<<4;o=o>>8^255&o^99,n[l]=o,s[o]=l,f=r[a=r[i=r[l]]];let u=16843009*f^65537*a^257*i^16843008*l,w=257*r[o]^16843008*o;for(let n=0;4>n;n++)t[n][l]=w=w<<24^w>>>8,e[n][o]=u=u<<24^u>>>8}for(let n=0;5>n;n++)t[n]=t[n].slice(0),e[n]=e[n].slice(0)}N(t,e){if(4!==t.length)throw new r("invalid aes block size");const n=this.M[e],s=n.length/4-2,o=[0,0,0,0],c=this.H[e],i=c[0],a=c[1],f=c[2],l=c[3],u=c[4];let w,h,p,d=t[0]^n[0],y=t[e?3:1]^n[1],m=t[2]^n[2],g=t[e?1:3]^n[3],S=4;for(let t=0;s>t;t++)w=i[d>>>24]^a[y>>16&255]^f[m>>8&255]^l[255&g]^n[S],h=i[y>>>24]^a[m>>16&255]^f[g>>8&255]^l[255&d]^n[S+1],p=i[m>>>24]^a[g>>16&255]^f[d>>8&255]^l[255&y]^n[S+2],g=i[g>>>24]^a[d>>16&255]^f[y>>8&255]^l[255&m]^n[S+3],S+=4,d=w,y=h,m=p;for(let t=0;4>t;t++)o[e?3&-t:t]=u[d>>>24]<<24^u[y>>16&255]<<16^u[m>>8&255]<<8^u[255&g]^n[S++],w=d,d=y,y=m,m=g,g=w;return o}},it=class{constructor(t,e){this.G=t,this.J=e,this.X=e}reset(){this.X=this.J}update(t){return this.Y(this.G,t,this.X)}$(t){if(255&~(t>>24))t+=1<<24;else{let e=t>>16&255,n=t>>8&255,s=255&t;255===e?(e=0,255===n?(n=0,255===s?s=0:++s):++n):++e,t=0,t+=e<<16,t+=n<<8,t+=s}return t}et(t){0===(t[0]=this.$(t[0]))&&(t[1]=this.$(t[1]))}Y(t,e,n){let s;if(!(s=e.length))return[];const r=V.m(e);for(let r=0;s>r;r+=4){this.et(n);const s=t.encrypt(n);e[r]^=s[0],e[r+1]^=s[1],e[r+2]^=s[2],e[r+3]^=s[3]}return V.S(e,r)}},at=F.V;let ft=nt&&rt&&typeof st.importKey==k,lt=nt&&rt&&typeof st.deriveBits==k;class ut extends d{constructor({password:t,rawPassword:e,encryptionStrength:n,checkPasswordOnly:s,checkAuthenticationCode:c=!0}){super({start(){ht(this,t,e,n)},async transform(t,e){const n=this,{password:c,strength:i,nt:a,ready:f}=n;c?(await(async(t,e,n,s)=>{const o=await dt(t,e,n,mt(s,0,Y[e])),c=mt(s,Y[e]);if(o[0]!=c[0]||o[1]!=c[1])throw new r(O)})(n,i,c,mt(t,0,Y[i]+2)),t=mt(t,Y[i]+2),s?e.error(new r(Z)):a()):await f;const l=new o(t.length-tt-(t.length-tt)%q);e.enqueue(pt(n,t,l,0,tt,!0))},async flush(t){const{st:e,ot:n,pending:s,ready:o}=this;if(n&&e){await o;const i=mt(s,0,s.length-tt),a=mt(s,s.length-tt);let f=z;if(i.length){const t=St(ot,i);n.update(t);const s=e.update(t);f=gt(ot,s)}const l=mt(gt(ot,n.digest()),0,tt);let u=s.length<tt?1:0;for(let t=0;tt>t;t++)u|=l[t]^a[t];if(u&&c)throw new r(H);t.enqueue(f)}}})}}class wt extends d{constructor({password:t,rawPassword:e,encryptionStrength:n}){let s;super({start(){ht(this,t,e,n)},async transform(t,e){const n=this,{password:s,strength:r,nt:c,ready:i}=n;let a=z;s?(a=await(async(t,e,n)=>{const s=N(new o(Y[e]));return _(s,await dt(t,e,n,s))})(n,r,s),c()):await i;const f=new o(a.length+t.length-t.length%q);f.set(a,0),e.enqueue(pt(n,t,f,a.length,0))},async flush(t){const{st:e,ot:n,pending:r,ready:o}=this;if(n&&e){await o;let c=z;if(r.length){const t=e.update(St(ot,r));n.update(t),c=gt(ot,t)}s.signature=gt(ot,n.digest()).slice(0,tt),t.enqueue(_(c,s.signature))}}}),s=this}}function ht(t,n,s,r){e.assign(t,{ready:new u(e=>t.nt=e),password:yt(n,s),strength:r-1,pending:z})}function pt(t,e,n,s,r,c){const{st:i,ot:a,pending:f}=t;f.length&&(e=_(f,e));const l=e.length-r;let u;for(n=((t,e)=>{if(e&&e>t.length){const n=t;(t=new o(e)).set(n,0)}return t})(n,s+(l-l%q)),u=0;l-q>=u;u+=q){const t=St(ot,mt(e,u,u+q));c&&a.update(t);const r=i.update(t);c||a.update(r),n.set(gt(ot,r),u+s)}return t.pending=mt(e,u),n}async function dt(n,s,r,c){n.password=null;const i=await(async(t,e,n,s,r)=>{if(!ft)return F.importKey(e);try{return await st.importKey("raw",e,n,!1,r)}catch{return ft=!1,F.importKey(e)}})(0,r,J,0,X),a=await(async(t,e,n)=>{if(!lt)return F.K(e,t.salt,Q.iterations,n);try{return await st.deriveBits(t,e,n)}catch{return lt=!1,F.K(e,t.salt,Q.iterations,n)}})(e.assign({salt:c},Q),i,8*(2*$[s]+2)),f=new o(a),l=St(ot,mt(f,0,$[s])),u=St(ot,mt(f,$[s],2*$[s])),w=mt(f,2*$[s]);return e.assign(n,{keys:{key:l,ct:u,passwordVerification:w},st:new it(new ct(l),t.from(et)),ot:new at(u)}),w}function yt(t,e){return e===v?(t=>{if(typeof w==b){const e=new o((t=unescape(encodeURIComponent(t))).length);for(let n=0;n<e.length;n++)e[n]=t.charCodeAt(n);return e}return(new w).encode(t)})(t):e}function mt(t,e,n){return t.subarray(e,n)}function gt(t,e){return t.C(e)}function St(t,e){return t.A(e)}class vt extends d{constructor({password:t,rawPassword:e,passwordVerification:n,checkPasswordOnly:s}){super({start(){kt(this,t,e,n)},transform(t,e){const n=this;if(n.password||n.rawPassword){const e=zt(n,t.subarray(0,12));if(n.password=n.rawPassword=null,0!=(e[11]^n.passwordVerification))throw new r(O);t=t.subarray(12)}s?e.error(new r(Z)):e.enqueue(zt(n,t))}})}}class bt extends d{constructor({password:t,rawPassword:e,passwordVerification:n}){super({start(){kt(this,t,e,n)},transform(t,e){const n=this;let s,r;if(n.password||n.rawPassword){n.password=n.rawPassword=null;const e=N(new o(12));e[11]=n.passwordVerification,s=new o(t.length+e.length),s.set(Ct(n,e),0),r=12}else s=new o(t.length),r=0;s.set(Ct(n,t),r),e.enqueue(s)}})}}function kt(t,n,s,r){e.assign(t,{password:n,rawPassword:s,passwordVerification:r}),((t,n,s)=>{const r=[305419896,591751049,878082192];if(e.assign(t,{keys:r,it:new U(r[0]),ft:new U(r[2])}),s)for(let e=0;e<s.length;e++)At(t,s[e]);else for(let e=0;e<n.length;e++)At(t,n.charCodeAt(e))})(t,n,s)}function zt(t,e){const n=new o(e.length);for(let s=0;s<e.length;s++)n[s]=It(t)^e[s],At(t,n[s]);return n}function Ct(t,e){const n=new o(e.length);for(let s=0;s<e.length;s++)n[s]=It(t)^e[s],At(t,e[s]);return n}function At(t,e){let[,n]=t.keys;t.it.append([e]);const r=~t.it.get();n=Mt(s.imul(Mt(n+xt(r)),134775813)+1),t.ft.append([n>>>24]);const o=~t.ft.get();t.keys=[r,n,o]}function It(t){const e=2|t.keys[2];return xt(s.imul(e,1^e)>>>8)}function xt(t){return 255&t}function Mt(t){return 4294967295&t}const Pt=new f;function Bt(t){return Pt.get(t)}const Dt="Invalid uncompressed size",Rt=j,Ut="deflate-raw",Wt="gzip",_t=[31,139,8];class Tt extends d{constructor(t,{chunkSize:e,CompressionStreamZlib:n,CompressionStream:s}){super({});const{compressed:r,encrypted:o,useCompressionStream:c,zipCrypto:i,computeCrc32:a,level:f,deflate64:u,format:w,compressionMethod:h}=t,p=this;let d,y,m,g=super.readable;const S=w&&Bt(w),v=a&&r&&!u&&!S&&(!o||i)&&!(!c||!s);if(o&&!i||!a||v||(d=new W,g=jt(g,d)),r)if(S)g=Ht(g,Lt(S.CompressionStream,w,{level:f,chunkSize:e,compressionMethod:h}));else if(v)m=new Vt,g=Ht(g,new s(Wt)),g=jt(g,m);else try{g=Ot(g,c,{level:f,chunkSize:e},s,n)}catch(t){let e;try{e=new s(Wt)}catch{throw t}g=Ht(g,e),g=jt(g,new Vt)}o&&(i?g=jt(g,new bt(t)):(y=new wt(t),g=jt(g,y))),Ft(p,g,()=>{let t;o&&!i&&(t=y.signature),o&&!i||!a||(t=v?m.signature:new l(d.value.buffer).getUint32(0)),p.signature=t})}}class Vt extends d{constructor(){let t,e=10,n=new o(0);super({transform(t,r){if(e){const n=s.min(e,t.length);if(e-=n,!(t=t.subarray(n)).length)return}const o=n.length+t.length;if(8>=o)return void(n=_(n,t));const c=o-8,i=s.min(c,n.length);r.enqueue(_(n.subarray(0,i),t.subarray(0,c-i))),n=_(n.subarray(i),t.subarray(c-i))},flush(){const e=T(n);t.signature=e.getUint32(0,!0),t.uncompressedSize=e.getUint32(4,!0)}}),t=this}}class Kt extends d{constructor(t,{chunkSize:e,DecompressionStreamZlib:n,DecompressionStream:s}){super({});const{zipCrypto:c,encrypted:i,checkCrc32:a,signature:f,compressed:w,useCompressionStream:h,deflate64:p,format:m,compressionMethod:g,rawBitFlag:S,outputSize:b}=t;let k,z,C=super.readable;if(i&&(c?C=jt(C,new vt(t)):(z=new ut(t),C=jt(C,z))),w){const t=m&&Bt(m);if(t)C=Ht(C,Lt(t.DecompressionStream,m,{chunkSize:e,compressionMethod:g,rawBitFlag:S,uncompressedSize:b}));else try{C=Ot(C,h,{chunkSize:e,deflate64:p},s,n)}catch(t){if(p||b===v)throw t;let e;try{e=new s(Wt)}catch{throw t}C=((t,e,n)=>{const s=new U;let c,i,a,f=0,l=!1;const w=new u((t,e)=>{i=t,a=e});w.catch(()=>{}),n||i();const h=new d({start(t){const e=new o(10);e.set(_t),t.enqueue(e)},transform(t,e){e.enqueue(t)},async flush(t){l=!0,y();try{await w}finally{m()}const e=new o(8),r=T(e);r.setUint32(0,s.get(),!0),r.setUint32(4,n,!0),t.enqueue(e)},cancel(t){a(t)}}),p=new d({transform(t,e){s.append(t),f+=t.length,n>f?l&&y():i(),e.enqueue(t)},cancel(t){a(t)}});return t=jt(t,h),jt(t=Ht(t,e),p);function y(){m(),c=setTimeout(()=>a(new r(Dt)),5e3)}function m(){clearTimeout(c)}})(C,e,b)}C=(t=>{const e=t.getReader();return new y({async pull(t){let n;try{n=await e.read()}catch(t){if(t&&t.message)throw t;const e=new r("Invalid compressed data");throw e.cause=t,e}const{value:s,done:o}=n;o?t.close():t.enqueue(s)},cancel:t=>e.cancel(t)})})(C)}a&&(k=new W,C=jt(C,k)),Ft(this,C,()=>{if(a){const t=new l(k.value.buffer);if(f!=t.getUint32(0,!1))throw new r(Rt)}})}}const Et=new f;function Ft(t,n,s){n=jt(n,new d({flush:s})),e.defineProperty(t,"readable",{get:()=>n})}function Lt(t,e,n){if(!t)throw new r("Compression method not supported");return new t(e,n)}function Ot(t,e,n,s,r){const o=e&&s?s:r||s,c=n.deflate64?"deflate64-raw":Ut;let i;try{i=new o(c,n)}catch(t){if(!e||!r||o==r)throw t;i=new r(c,n)}return Ht(t,i)}function jt(t,e){return(t=>{if(t instanceof y)return t;const e=t.getReader();return new y({async pull(t){const{value:n,done:s}=await e.read();s?t.close():t.enqueue(n)},cancel:t=>e.cancel(t)})})(t).pipeThrough(e)}function Ht(t,e){const n=e.writable.getWriter(),s=t.getReader();return(async()=>{try{for(;;){await n.ready;const t=await s.read();if(t.done){await n.close();break}await n.write(t.value)}}catch(t){await(async(t,e)=>{try{await t.abort(e)}catch{}})(n,t),await(async(t,e)=>{try{await t.cancel(e)}catch{}})(s,t)}})(),e.readable}const Zt="data",Nt="close",qt="deflate";class Gt extends d{constructor(t,n){super({});const s=this,{codecType:o}=t;let c;o.startsWith(qt)?c=Tt:o.startsWith("inflate")&&(c=Kt),s.outputSize=0;let i=0;const a=new c(t,n),f=super.readable,l=new d({transform(t,e){t&&t.length&&(i+=t.length,e.enqueue(t))},flush(){e.assign(s,{inputSize:i})}}),u=new d({transform(e,n){if(e&&e.length&&(n.enqueue(e),s.outputSize+=e.length,t.outputSize!==v&&s.outputSize>t.outputSize))throw new r(Dt)},flush(){const{signature:t}=a;e.assign(s,{signature:t,inputSize:i})}});e.defineProperty(s,"readable",{get:()=>f.pipeThrough(l).pipeThrough(a).pipeThrough(u)})}}class Jt extends d{constructor(t){const e=[];let s=0;function r(){const n=new o(t);let r=0;for(;t>r;){const s=e[0],o=t-r;s.length>o?(n.set(s.subarray(0,o),r),e[0]=s.subarray(o),r+=o):(n.set(s,r),r+=s.length,e.shift())}return s-=t,n}n.isFinite(t)&&t>=1||(t=65536),super({transform(n,o){for(e.push(n),s+=n.length;s>t;)o.enqueue(r())},flush(t){s&&t.enqueue(((t,e)=>{const n=new o(e);let s=0;for(const e of t)n.set(e,s),s+=e.length;return n})(e,s))}})}}let Qt=2;try{typeof navigator!=b&&navigator.hardwareConcurrency&&(Qt=navigator.hardwareConcurrency)}catch{}const Xt=new f,Yt=new f;let $t,te,ee,ne,se,re,oe=0;async function ce(t){let e,o;try{const{options:c,config:i}=t;if(c.format&&await(async(t,e)=>{!Pt.has(t)&&e&&((t,e)=>{const{CompressionStream:n,DecompressionStream:s}=e;if(typeof n!=k&&typeof s!=k)throw new r("Invalid codec module");Pt.set(t,{CompressionStream:n,DecompressionStream:s})})(t,await(import(e)))})(c.format,c.codecURI),i.CompressionStream=self.CompressionStream,i.DecompressionStream=self.DecompressionStream,c.compressed&&!c.format)if(c.useCompressionStream){if(!((t,e)=>{if(!t)return!1;let n=Et.get(t);n||(n=new f,Et.set(t,n));let s=n.get(e);if(s===v){try{new t(e),s=!0}catch{s=!1}n.set(e,s)}return s})(c.codecType.startsWith(qt)?i.CompressionStream:i.DecompressionStream,Ut))try{await self.initModule(t.config)}catch{}}else try{await self.initModule(t.config)}catch{c.useCompressionStream=!0}const a={highWaterMark:1},l=t.readable||new y({async pull(t){const e=new u(t=>Xt.set(oe,t));ie({type:"pull",messageId:oe}),oe=(oe+1)%n.MAX_SAFE_INTEGER;const{value:s,done:r}=await e;t.enqueue(s),r&&t.close()}},a);o=t.writable||new m({async write(t){let e;const s=new u(t=>e=t);Yt.set(oe,e),ie({type:Zt,value:t,messageId:oe}),oe=(oe+1)%n.MAX_SAFE_INTEGER,await s}},a),e=new Gt(c,i),$t=new AbortController;const{signal:w}=$t;await l.pipeThrough(e).pipeThrough(new Jt((t=>s.max(t.chunkSize,64))(i))).pipeTo(o,{signal:w,preventClose:!0,preventAbort:!0}),await o.getWriter().close();const{signature:h,inputSize:p,outputSize:d}=e;ie({type:Nt,result:{signature:h,inputSize:p,outputSize:d}})}catch(t){if(t.outputSize=e?e.outputSize:0,o&&!o.locked)try{await o.getWriter().close()}catch{}ae(t)}}function ie(t){const{value:e}=t;if(e)if(e.length)try{t.value=(n=e,n.byteOffset||n.byteLength!=n.buffer.byteLength?new o(n):n).buffer,p(t,[t.value])}catch{p(t)}else p(t);else p(t);var n}function ae(t=new r("Unknown error")){const{message:e,stack:n,code:s,name:o,outputSize:c,cause:i}=t,a={message:e,stack:n,code:s,name:o,outputSize:c};i&&(a.cause={name:i.name,message:i.message}),p({error:a})}function fe(t,e,n={}){if(!te){const t=new r("WASM module not loaded");throw t.cause=re,t}const c="number"==typeof n.level?n.level:-1,i="number"==typeof n.outBuffer?n.outBuffer:65536,a="number"==typeof n.inBufferSize?n.inBufferSize:65536;return new d({start(){try{let n;if(this.lt=ee(i),this.in=ee(a),this.inBufferSize=a,!this.lt||!this.in)throw new r("allocation failed");if(this.ut=new o(i),t?(this.wt=te.deflate_process,this.ht=te.deflate_last_consumed,this.yt=te.deflate_end,this.gt=te.deflate_new(),n="gzip"===e?te.deflate_init_gzip(this.gt,c):"deflate-raw"===e?te.deflate_init_raw(this.gt,c):te.deflate_init(this.gt,c)):"deflate64-raw"===e?(this.wt=te.inflate9_process,this.ht=te.inflate9_last_consumed,this.yt=te.inflate9_end,this.gt=te.inflate9_new(),n=te.inflate9_init_raw(this.gt)):(this.wt=te.inflate_process,this.ht=te.inflate_last_consumed,this.yt=te.inflate_end,this.gt=te.inflate_new(),n="deflate-raw"===e?te.inflate_init_raw(this.gt):"gzip"===e?te.inflate_init_gzip(this.gt):te.inflate_init(this.gt)),0!==n)throw new r("init failed:"+n)}catch(t){throw f(this),t}},transform(e,n){try{const c=e,a=new o(se.buffer),f=this.wt,l=this.ht,u=this.lt,w=this.ut;let h=0;for(;h<c.length;){const e=s.min(c.length-h,32768);if((!this.in||this.inBufferSize<e)&&(this.in&&ne&&(ne(this.in),this.in=0),this.in=ee(e),this.inBufferSize=e,!this.in))throw new r("allocation failed");a.set(c.subarray(h,h+e),this.in);const o=f(this.gt,this.in,e,u,i,0),p=16777215&o;if(p&&(w.set(a.subarray(u,u+p),0),n.enqueue(w.slice(0,p))),!t){const t=o>>24&255,e=128&t?t-256:t;if(0>e)throw new r("process error:"+e)}const d=l(this.gt);if(0===d)break;h+=d}}catch(t){f(this),n.error(t)}},flush(e){try{const n=new o(se.buffer),s=this.wt,c=this.lt,a=this.ut;for(;;){const o=s(this.gt,0,0,c,i,4),f=16777215&o,l=o>>24&255;if(!t){const t=128&l?l-256:l;if(0>t)throw new r("process error:"+t)}if(f&&(a.set(n.subarray(c,c+f),0),e.enqueue(a.slice(0,f))),1===l||0===f)break}}catch(t){e.error(t)}finally{const t=f(this);0!==t&&e.error(new r("end error:"+t))}},cancel(){f(this)}});function f(t){let e=0;return t.gt&&t.yt&&(e=t.yt(t.gt)),t.gt=0,t.in&&ne&&ne(t.in),t.in=0,t.lt&&ne&&ne(t.lt),t.lt=0,e}}addEventListener("message",({data:t})=>{const{type:e,messageId:n,value:s,done:r}=t;try{if("start"==e&&ce(t),e==Zt){const t=Xt.get(n);Xt.delete(n),t({value:s||new o,done:r})}if("ack"==e){const t=Yt.get(n);Yt.delete(n),t()}e==Nt&&$t.abort()}catch(t){ae(t)}}),p({type:"ready"});class le{constructor(t="deflate",e){return fe(!0,t,e)}}class ue{constructor(t="deflate",e){return fe(!1,t,e)}}le.St=!0,ue.St=!0;let we=!1;self.initModule=async t=>{const e=await(async(t,{baseURI:e})=>{if(!we)try{await(async(t,e)=>{let n,s;try{try{s=new URL(t,e)}catch{}const r=await fetch(s);n=await r.arrayBuffer()}catch(e){if(!t.startsWith("data:application/wasm;base64,"))throw e;n=(t=>{const e=t.split(",")[1],n=atob(e),s=n.length,r=new o(s);for(let t=0;s>t;++t)r[t]=n.charCodeAt(t);return r.buffer})(t)}(t=>{if(te=t,({malloc:ee,free:ne,memory:se}=te),"function"!=typeof ee||"function"!=typeof ne||!se)throw te=ee=ne=se=null,new r("Invalid WASM module")})((await WebAssembly.instantiate(n)).instance.exports)})(t,e),we=!0}catch(t){throw(t=>{re=t})(t),t}})(t.wasmURI,t);return t.CompressionStreamZlib=le,t.DecompressionStreamZlib=ue,e}});\n';t({workerURI:t=>{const n="text/javascript";if(t){const t=new Blob([e],{type:n});return URL.createObjectURL(t)}return "data:"+n+","+encodeURIComponent(e)}});}
|
|
222
222
|
|
|
223
223
|
/*
|
|
224
224
|
Copyright (c) 2025 Gildas Lormeau. All rights reserved.
|
|
@@ -1365,6 +1365,7 @@ const GET_RANDOM_VALUES_SUPPORTED = typeof crypto != UNDEFINED_TYPE && typeof cr
|
|
|
1365
1365
|
|
|
1366
1366
|
const ERR_INVALID_PASSWORD = "Invalid password";
|
|
1367
1367
|
const ERR_INVALID_SIGNATURE = "Invalid signature";
|
|
1368
|
+
const ERR_INVALID_AUTHENTICATION_CODE = ERR_INVALID_SIGNATURE;
|
|
1368
1369
|
const ERR_ABORT_CHECK_PASSWORD = "zipjs-abort-check-password";
|
|
1369
1370
|
const ERR_UNSUPPORTED_CRYPTO_API = "Crypto API not supported";
|
|
1370
1371
|
|
|
@@ -1431,7 +1432,7 @@ let DERIVE_BITS_SUPPORTED = CRYPTO_API_SUPPORTED && SUBTLE_API_SUPPORTED && type
|
|
|
1431
1432
|
|
|
1432
1433
|
class AESDecryptionStream extends TransformStream {
|
|
1433
1434
|
|
|
1434
|
-
constructor({ password, rawPassword, encryptionStrength, checkPasswordOnly }) {
|
|
1435
|
+
constructor({ password, rawPassword, encryptionStrength, checkPasswordOnly, checkAuthenticationCode = true }) {
|
|
1435
1436
|
super({
|
|
1436
1437
|
start() {
|
|
1437
1438
|
initAesCrypto(this, password, rawPassword, encryptionStrength);
|
|
@@ -1481,8 +1482,8 @@ class AESDecryptionStream extends TransformStream {
|
|
|
1481
1482
|
for (let indexSignature = 0; indexSignature < SIGNATURE_LENGTH; indexSignature++) {
|
|
1482
1483
|
invalidSignature |= signature[indexSignature] ^ originalSignature[indexSignature];
|
|
1483
1484
|
}
|
|
1484
|
-
if (invalidSignature) {
|
|
1485
|
-
throw new Error(
|
|
1485
|
+
if (invalidSignature && checkAuthenticationCode) {
|
|
1486
|
+
throw new Error(ERR_INVALID_AUTHENTICATION_CODE);
|
|
1486
1487
|
}
|
|
1487
1488
|
controller.enqueue(decryptedChunkArray);
|
|
1488
1489
|
}
|
|
@@ -1920,6 +1921,7 @@ function toCompatibleWritable(writable) {
|
|
|
1920
1921
|
|
|
1921
1922
|
const ERR_INVALID_UNCOMPRESSED_SIZE = "Invalid uncompressed size";
|
|
1922
1923
|
const ERR_INVALID_COMPRESSED_DATA = "Invalid compressed data";
|
|
1924
|
+
const ERR_INVALID_CRC32 = ERR_INVALID_SIGNATURE;
|
|
1923
1925
|
const ERR_UNSUPPORTED_COMPRESSION$2 = "Compression method not supported";
|
|
1924
1926
|
const FORMAT_DEFLATE_RAW = "deflate-raw";
|
|
1925
1927
|
const FORMAT_DEFLATE64_RAW = "deflate64-raw";
|
|
@@ -1927,19 +1929,20 @@ const FORMAT_GZIP = "gzip";
|
|
|
1927
1929
|
const GZIP_HEADER_LENGTH = 10;
|
|
1928
1930
|
const GZIP_TRAILER_LENGTH = 8;
|
|
1929
1931
|
const GZIP_HEADER_BYTES = [0x1f, 0x8b, 0x08];
|
|
1932
|
+
const GZIP_OUTPUT_STALL_TIMEOUT = 5000;
|
|
1930
1933
|
|
|
1931
1934
|
class DeflateStream extends TransformStream {
|
|
1932
1935
|
|
|
1933
1936
|
constructor(options, { chunkSize, CompressionStreamZlib, CompressionStream }) {
|
|
1934
1937
|
super({});
|
|
1935
|
-
const { compressed, encrypted, useCompressionStream, zipCrypto,
|
|
1938
|
+
const { compressed, encrypted, useCompressionStream, zipCrypto, computeCrc32, level, deflate64, format, compressionMethod } = options;
|
|
1936
1939
|
const stream = this;
|
|
1937
1940
|
let crc32Stream, encryptionStream, gzipCrc32Stream;
|
|
1938
1941
|
let readable = super.readable;
|
|
1939
1942
|
const codecStreams = format && getCodecStreams(format);
|
|
1940
|
-
const useGzipCrc32 =
|
|
1943
|
+
const useGzipCrc32 = computeCrc32 && compressed && !deflate64 && !codecStreams && (!encrypted || zipCrypto) &&
|
|
1941
1944
|
Boolean(useCompressionStream && CompressionStream);
|
|
1942
|
-
if ((!encrypted || zipCrypto) &&
|
|
1945
|
+
if ((!encrypted || zipCrypto) && computeCrc32 && !useGzipCrc32) {
|
|
1943
1946
|
crc32Stream = new Crc32Stream();
|
|
1944
1947
|
readable = pipeThrough(readable, crc32Stream);
|
|
1945
1948
|
}
|
|
@@ -1978,7 +1981,7 @@ class DeflateStream extends TransformStream {
|
|
|
1978
1981
|
if (encrypted && !zipCrypto) {
|
|
1979
1982
|
signature = encryptionStream.signature;
|
|
1980
1983
|
}
|
|
1981
|
-
if ((!encrypted || zipCrypto) &&
|
|
1984
|
+
if ((!encrypted || zipCrypto) && computeCrc32) {
|
|
1982
1985
|
signature = useGzipCrc32 ? gzipCrc32Stream.signature : new DataView(crc32Stream.value.buffer).getUint32(0);
|
|
1983
1986
|
}
|
|
1984
1987
|
stream.signature = signature;
|
|
@@ -2027,26 +2030,73 @@ class GzipToRawDeflateStream extends TransformStream {
|
|
|
2027
2030
|
}
|
|
2028
2031
|
}
|
|
2029
2032
|
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2033
|
+
function pipeThroughGzipDecompressionStream(readable, gzipStream, outputSize) {
|
|
2034
|
+
const crc32 = new Crc32();
|
|
2035
|
+
let outputLength = 0;
|
|
2036
|
+
let inputDone = false;
|
|
2037
|
+
let watchdogTimeout;
|
|
2038
|
+
let resolveTrailerReady, rejectTrailerReady;
|
|
2039
|
+
const trailerReady = new Promise((resolve, reject) => {
|
|
2040
|
+
resolveTrailerReady = resolve;
|
|
2041
|
+
rejectTrailerReady = reject;
|
|
2042
|
+
});
|
|
2043
|
+
trailerReady.catch(() => { });
|
|
2044
|
+
if (!outputSize) {
|
|
2045
|
+
resolveTrailerReady();
|
|
2046
|
+
}
|
|
2047
|
+
const gzipWrapStream = new TransformStream({
|
|
2048
|
+
start(controller) {
|
|
2049
|
+
const header = new Uint8Array(GZIP_HEADER_LENGTH);
|
|
2050
|
+
header.set(GZIP_HEADER_BYTES);
|
|
2051
|
+
controller.enqueue(header);
|
|
2052
|
+
},
|
|
2053
|
+
transform(chunk, controller) {
|
|
2054
|
+
controller.enqueue(chunk);
|
|
2055
|
+
},
|
|
2056
|
+
async flush(controller) {
|
|
2057
|
+
inputDone = true;
|
|
2058
|
+
startWatchdog();
|
|
2059
|
+
try {
|
|
2060
|
+
await trailerReady;
|
|
2061
|
+
} finally {
|
|
2062
|
+
stopWatchdog();
|
|
2048
2063
|
}
|
|
2049
|
-
|
|
2064
|
+
const trailer = new Uint8Array(GZIP_TRAILER_LENGTH);
|
|
2065
|
+
const dataView = getDataView(trailer);
|
|
2066
|
+
dataView.setUint32(0, crc32.get(), true);
|
|
2067
|
+
dataView.setUint32(4, outputSize, true);
|
|
2068
|
+
controller.enqueue(trailer);
|
|
2069
|
+
},
|
|
2070
|
+
cancel(reason) {
|
|
2071
|
+
rejectTrailerReady(reason);
|
|
2072
|
+
}
|
|
2073
|
+
});
|
|
2074
|
+
const outputStream = new TransformStream({
|
|
2075
|
+
transform(chunk, controller) {
|
|
2076
|
+
crc32.append(chunk);
|
|
2077
|
+
outputLength += chunk.length;
|
|
2078
|
+
if (outputLength >= outputSize) {
|
|
2079
|
+
resolveTrailerReady();
|
|
2080
|
+
} else if (inputDone) {
|
|
2081
|
+
startWatchdog();
|
|
2082
|
+
}
|
|
2083
|
+
controller.enqueue(chunk);
|
|
2084
|
+
},
|
|
2085
|
+
cancel(reason) {
|
|
2086
|
+
rejectTrailerReady(reason);
|
|
2087
|
+
}
|
|
2088
|
+
});
|
|
2089
|
+
readable = pipeThrough(readable, gzipWrapStream);
|
|
2090
|
+
readable = pipeThroughBackpressured(readable, gzipStream);
|
|
2091
|
+
return pipeThrough(readable, outputStream);
|
|
2092
|
+
|
|
2093
|
+
function startWatchdog() {
|
|
2094
|
+
stopWatchdog();
|
|
2095
|
+
watchdogTimeout = setTimeout(() => rejectTrailerReady(new Error(ERR_INVALID_UNCOMPRESSED_SIZE)), GZIP_OUTPUT_STALL_TIMEOUT);
|
|
2096
|
+
}
|
|
2097
|
+
|
|
2098
|
+
function stopWatchdog() {
|
|
2099
|
+
clearTimeout(watchdogTimeout);
|
|
2050
2100
|
}
|
|
2051
2101
|
}
|
|
2052
2102
|
|
|
@@ -2054,7 +2104,7 @@ class InflateStream extends TransformStream {
|
|
|
2054
2104
|
|
|
2055
2105
|
constructor(options, { chunkSize, DecompressionStreamZlib, DecompressionStream }) {
|
|
2056
2106
|
super({});
|
|
2057
|
-
const { zipCrypto, encrypted,
|
|
2107
|
+
const { zipCrypto, encrypted, checkCrc32, signature, compressed, useCompressionStream, deflate64, format, compressionMethod, rawBitFlag, outputSize } = options;
|
|
2058
2108
|
let crc32Stream, decryptionStream;
|
|
2059
2109
|
let readable = super.readable;
|
|
2060
2110
|
if (encrypted) {
|
|
@@ -2073,7 +2123,7 @@ class InflateStream extends TransformStream {
|
|
|
2073
2123
|
try {
|
|
2074
2124
|
readable = pipeThroughCompressionStream(readable, useCompressionStream, { chunkSize, deflate64 }, DecompressionStream, DecompressionStreamZlib);
|
|
2075
2125
|
} catch (error) {
|
|
2076
|
-
if (deflate64 ||
|
|
2126
|
+
if (deflate64 || outputSize === UNDEFINED_VALUE) {
|
|
2077
2127
|
throw error;
|
|
2078
2128
|
}
|
|
2079
2129
|
let gzipStream;
|
|
@@ -2082,46 +2132,58 @@ class InflateStream extends TransformStream {
|
|
|
2082
2132
|
} catch {
|
|
2083
2133
|
throw error;
|
|
2084
2134
|
}
|
|
2085
|
-
readable =
|
|
2086
|
-
readable = pipeThroughBackpressured(readable, gzipStream);
|
|
2135
|
+
readable = pipeThroughGzipDecompressionStream(readable, gzipStream, outputSize);
|
|
2087
2136
|
}
|
|
2088
2137
|
}
|
|
2089
2138
|
readable = mapInflateStreamError(readable);
|
|
2090
2139
|
}
|
|
2091
|
-
if (
|
|
2140
|
+
if (checkCrc32) {
|
|
2092
2141
|
crc32Stream = new Crc32Stream();
|
|
2093
2142
|
readable = pipeThrough(readable, crc32Stream);
|
|
2094
2143
|
}
|
|
2095
2144
|
setReadable(this, readable, () => {
|
|
2096
|
-
if (
|
|
2145
|
+
if (checkCrc32) {
|
|
2097
2146
|
const dataViewSignature = new DataView(crc32Stream.value.buffer);
|
|
2098
2147
|
if (signature != dataViewSignature.getUint32(0, false)) {
|
|
2099
|
-
throw new Error(
|
|
2148
|
+
throw new Error(ERR_INVALID_CRC32);
|
|
2100
2149
|
}
|
|
2101
2150
|
}
|
|
2102
2151
|
});
|
|
2103
2152
|
}
|
|
2104
2153
|
}
|
|
2105
2154
|
|
|
2106
|
-
const
|
|
2155
|
+
const formatSupportByStream = new Map();
|
|
2107
2156
|
|
|
2108
|
-
function
|
|
2157
|
+
function supportsFormat(StreamClass, format) {
|
|
2109
2158
|
if (!StreamClass) {
|
|
2110
2159
|
return false;
|
|
2111
2160
|
}
|
|
2112
|
-
let
|
|
2161
|
+
let supportByFormat = formatSupportByStream.get(StreamClass);
|
|
2162
|
+
if (!supportByFormat) {
|
|
2163
|
+
supportByFormat = new Map();
|
|
2164
|
+
formatSupportByStream.set(StreamClass, supportByFormat);
|
|
2165
|
+
}
|
|
2166
|
+
let supported = supportByFormat.get(format);
|
|
2113
2167
|
if (supported === UNDEFINED_VALUE) {
|
|
2114
2168
|
try {
|
|
2115
|
-
new StreamClass(
|
|
2169
|
+
new StreamClass(format);
|
|
2116
2170
|
supported = true;
|
|
2117
2171
|
} catch {
|
|
2118
2172
|
supported = false;
|
|
2119
2173
|
}
|
|
2120
|
-
|
|
2174
|
+
supportByFormat.set(format, supported);
|
|
2121
2175
|
}
|
|
2122
2176
|
return supported;
|
|
2123
2177
|
}
|
|
2124
2178
|
|
|
2179
|
+
function supportsDeflateRaw(StreamClass) {
|
|
2180
|
+
return supportsFormat(StreamClass, FORMAT_DEFLATE_RAW);
|
|
2181
|
+
}
|
|
2182
|
+
|
|
2183
|
+
function supportsGzip(StreamClass) {
|
|
2184
|
+
return supportsFormat(StreamClass, FORMAT_GZIP);
|
|
2185
|
+
}
|
|
2186
|
+
|
|
2125
2187
|
function setReadable(stream, readable, flush) {
|
|
2126
2188
|
readable = pipeThrough(readable, new TransformStream({ flush }));
|
|
2127
2189
|
Object.defineProperty(stream, "readable", {
|
|
@@ -2424,6 +2486,25 @@ function configureWorker({ initModule: initModuleFunction }) {
|
|
|
2424
2486
|
initModule$1 = initModuleFunction;
|
|
2425
2487
|
}
|
|
2426
2488
|
|
|
2489
|
+
async function supportsDeflate(config) {
|
|
2490
|
+
const { CompressionStream: NativeStream, CompressionStreamZlib: ZlibStream } = config;
|
|
2491
|
+
if (ZlibStream && !ZlibStream.requiresModule) {
|
|
2492
|
+
return true;
|
|
2493
|
+
}
|
|
2494
|
+
if (supportsDeflateRaw(NativeStream) || supportsGzip(NativeStream)) {
|
|
2495
|
+
return true;
|
|
2496
|
+
}
|
|
2497
|
+
if (ZlibStream) {
|
|
2498
|
+
try {
|
|
2499
|
+
await initModule$1(config);
|
|
2500
|
+
return true;
|
|
2501
|
+
} catch {
|
|
2502
|
+
return false;
|
|
2503
|
+
}
|
|
2504
|
+
}
|
|
2505
|
+
return false;
|
|
2506
|
+
}
|
|
2507
|
+
|
|
2427
2508
|
function resetWebWorkerSupport() {
|
|
2428
2509
|
webWorkerSupported = UNDEFINED_VALUE;
|
|
2429
2510
|
}
|
|
@@ -2959,7 +3040,7 @@ let indexWorker = 0;
|
|
|
2959
3040
|
|
|
2960
3041
|
async function runWorker(stream, workerOptions) {
|
|
2961
3042
|
const { options, config } = workerOptions;
|
|
2962
|
-
const { transferStreams, useWebWorkers, useCompressionStream, compressed,
|
|
3043
|
+
const { transferStreams, useWebWorkers, useCompressionStream, compressed, checkCrc32, computeCrc32, encrypted, format, codecURI } = options;
|
|
2963
3044
|
const { workerURI, maxWorkers } = config;
|
|
2964
3045
|
if (format) {
|
|
2965
3046
|
if (codecURI) {
|
|
@@ -2968,7 +3049,7 @@ async function runWorker(stream, workerOptions) {
|
|
|
2968
3049
|
await ensureCodecStreams(format, options.codecURI);
|
|
2969
3050
|
}
|
|
2970
3051
|
workerOptions.transferStreams = transferStreams || (transferStreams === UNDEFINED_VALUE && config.transferStreams);
|
|
2971
|
-
const streamCopy = !compressed && !
|
|
3052
|
+
const streamCopy = !compressed && !checkCrc32 && !computeCrc32 && !encrypted;
|
|
2972
3053
|
const workerSupported = format === UNDEFINED_VALUE || Boolean(options.codecURI);
|
|
2973
3054
|
workerOptions.useWebWorkers = !streamCopy && workerSupported && (useWebWorkers || (useWebWorkers === UNDEFINED_VALUE && config.useWebWorkers));
|
|
2974
3055
|
workerOptions.workerURI = workerOptions.useWebWorkers && workerURI ? workerURI : UNDEFINED_VALUE;
|
|
@@ -4192,6 +4273,7 @@ const PROPERTY_NAME_DIRECTORY = "directory";
|
|
|
4192
4273
|
const PROPERTY_NAME_EXECUTABLE = "executable";
|
|
4193
4274
|
const PROPERTY_NAME_COMPRESSION_METHOD = "compressionMethod";
|
|
4194
4275
|
const PROPERTY_NAME_SIGNATURE = "signature";
|
|
4276
|
+
const PROPERTY_NAME_CRC32 = "crc32";
|
|
4195
4277
|
const PROPERTY_NAME_EXTRA_FIELD = "extraField";
|
|
4196
4278
|
const PROPERTY_NAME_EXTRA_FIELD_INFOZIP = "extraFieldInfoZip";
|
|
4197
4279
|
const PROPERTY_NAME_EXTRA_FIELD_UNIX = "extraFieldUnix";
|
|
@@ -4240,6 +4322,7 @@ const PROPERTY_NAMES = [
|
|
|
4240
4322
|
PROPERTY_NAME_EXECUTABLE,
|
|
4241
4323
|
PROPERTY_NAME_COMPRESSION_METHOD,
|
|
4242
4324
|
PROPERTY_NAME_SIGNATURE,
|
|
4325
|
+
PROPERTY_NAME_CRC32,
|
|
4243
4326
|
PROPERTY_NAME_EXTRA_FIELD,
|
|
4244
4327
|
PROPERTY_NAME_EXTRA_FIELD_UNIX,
|
|
4245
4328
|
PROPERTY_NAME_EXTRA_FIELD_INFOZIP,
|
|
@@ -4311,6 +4394,8 @@ const OPTION_CHECK_OVERLAPPING_ENTRY_ONLY = "checkOverlappingEntryOnly";
|
|
|
4311
4394
|
const OPTION_CHECK_OVERLAPPING_ENTRY = "checkOverlappingEntry";
|
|
4312
4395
|
const OPTION_CHECK_AMBIGUITY = "checkAmbiguity";
|
|
4313
4396
|
const OPTION_CHECK_SIGNATURE = "checkSignature";
|
|
4397
|
+
const OPTION_CHECK_CRC32 = "checkCrc32";
|
|
4398
|
+
const OPTION_CHECK_AUTHENTICATION_CODE = "checkAuthenticationCode";
|
|
4314
4399
|
const OPTION_USE_WEB_WORKERS = "useWebWorkers";
|
|
4315
4400
|
const OPTION_USE_COMPRESSION_STREAM = "useCompressionStream";
|
|
4316
4401
|
const OPTION_TRANSFER_STREAMS = "transferStreams";
|
|
@@ -4382,6 +4467,7 @@ const CHARSET_UTF8 = "utf-8";
|
|
|
4382
4467
|
const PROPERTY_NAME_UTF8_SUFFIX = "UTF8";
|
|
4383
4468
|
const CHARSET_CP437 = "cp437";
|
|
4384
4469
|
const BITFLAG_AMBIGUITY_MASK = BITFLAG_ENCRYPTED | BITFLAG_DATA_DESCRIPTOR | BITFLAG_LANG_ENCODING_FLAG;
|
|
4470
|
+
const VENDOR_VERSION_AE_1 = 1;
|
|
4385
4471
|
const ZIP64_PROPERTIES = [
|
|
4386
4472
|
[PROPERTY_NAME_UNCOMPRESSED_SIZE, MAX_32_BITS],
|
|
4387
4473
|
[PROPERTY_NAME_COMPRESSED_SIZE, MAX_32_BITS],
|
|
@@ -4861,6 +4947,11 @@ let ZipEntry$1 = class ZipEntry {
|
|
|
4861
4947
|
if (deflate64) {
|
|
4862
4948
|
useCompressionStream = false;
|
|
4863
4949
|
}
|
|
4950
|
+
const checkCrc32Option = getOptionValue$1(zipEntry, options, OPTION_CHECK_CRC32);
|
|
4951
|
+
const checkCrc32 = (checkCrc32Option === UNDEFINED_VALUE ?
|
|
4952
|
+
getOptionValue$1(zipEntry, options, OPTION_CHECK_SIGNATURE) :
|
|
4953
|
+
checkCrc32Option) && !passThrough &&
|
|
4954
|
+
(!encrypted || zipCrypto || (extraFieldAES && extraFieldAES.vendorVersion == VENDOR_VERSION_AE_1));
|
|
4864
4955
|
const workerOptions = {
|
|
4865
4956
|
options: {
|
|
4866
4957
|
codecType: CODEC_INFLATE,
|
|
@@ -4868,7 +4959,8 @@ let ZipEntry$1 = class ZipEntry {
|
|
|
4868
4959
|
rawPassword,
|
|
4869
4960
|
zipCrypto,
|
|
4870
4961
|
encryptionStrength: extraFieldAES && extraFieldAES.strength,
|
|
4871
|
-
|
|
4962
|
+
checkCrc32,
|
|
4963
|
+
checkAuthenticationCode: getOptionValue$1(zipEntry, options, OPTION_CHECK_AUTHENTICATION_CODE),
|
|
4872
4964
|
passwordVerification: zipCrypto && (dataDescriptor ? ((rawLastModDate >>> 8) & MAX_8_BITS) : ((signature >>> 24) & MAX_8_BITS)),
|
|
4873
4965
|
outputSize: passThrough ? compressedSize : uncompressedSize,
|
|
4874
4966
|
signature,
|
|
@@ -4984,6 +5076,7 @@ function readCommonFooter(fileEntry, directory, dataView, offset, localDirectory
|
|
|
4984
5076
|
const compressionMethod = getUint16(dataView, offset + 4);
|
|
4985
5077
|
Object.assign(directory, {
|
|
4986
5078
|
signature: getUint32(dataView, offset + HEADER_OFFSET_SIGNATURE),
|
|
5079
|
+
crc32: getUint32(dataView, offset + HEADER_OFFSET_SIGNATURE),
|
|
4987
5080
|
compressedSize: getUint32(dataView, offset + HEADER_OFFSET_COMPRESSED_SIZE),
|
|
4988
5081
|
uncompressedSize: getUint32(dataView, offset + HEADER_OFFSET_UNCOMPRESSED_SIZE)
|
|
4989
5082
|
});
|
|
@@ -5085,6 +5178,9 @@ function readExtraFieldAES(extraFieldAES, directory, compressionMethod) {
|
|
|
5085
5178
|
compressionMethod: getUint16(extraFieldView, 5)
|
|
5086
5179
|
});
|
|
5087
5180
|
directory.compressionMethod = extraFieldAES.compressionMethod;
|
|
5181
|
+
if (extraFieldAES.vendorVersion != VENDOR_VERSION_AE_1) {
|
|
5182
|
+
directory.crc32 = UNDEFINED_VALUE;
|
|
5183
|
+
}
|
|
5088
5184
|
}
|
|
5089
5185
|
|
|
5090
5186
|
function readExtraFieldNTFS(extraFieldNTFS, directory) {
|
|
@@ -5103,26 +5199,22 @@ function readExtraFieldNTFS(extraFieldNTFS, directory) {
|
|
|
5103
5199
|
} catch {
|
|
5104
5200
|
// ignored
|
|
5105
5201
|
}
|
|
5106
|
-
|
|
5107
|
-
|
|
5108
|
-
|
|
5109
|
-
|
|
5110
|
-
|
|
5111
|
-
|
|
5112
|
-
|
|
5113
|
-
|
|
5114
|
-
|
|
5115
|
-
|
|
5116
|
-
|
|
5117
|
-
|
|
5118
|
-
|
|
5119
|
-
|
|
5120
|
-
|
|
5121
|
-
|
|
5122
|
-
Object.assign(directory, extraFieldData);
|
|
5123
|
-
}
|
|
5124
|
-
} catch {
|
|
5125
|
-
// ignored
|
|
5202
|
+
if (tag1Data && tag1Data.length == 24) {
|
|
5203
|
+
const tag1View = getDataView(tag1Data);
|
|
5204
|
+
const rawLastModDate = tag1View.getBigUint64(0, true);
|
|
5205
|
+
const rawLastAccessDate = tag1View.getBigUint64(8, true);
|
|
5206
|
+
const rawCreationDate = tag1View.getBigUint64(16, true);
|
|
5207
|
+
Object.assign(extraFieldNTFS, {
|
|
5208
|
+
rawLastModDate,
|
|
5209
|
+
rawLastAccessDate,
|
|
5210
|
+
rawCreationDate
|
|
5211
|
+
});
|
|
5212
|
+
const lastModDate = getDateNTFS(rawLastModDate);
|
|
5213
|
+
const lastAccessDate = getDateNTFS(rawLastAccessDate);
|
|
5214
|
+
const creationDate = getDateNTFS(rawCreationDate);
|
|
5215
|
+
const extraFieldData = { lastModDate, lastAccessDate, creationDate };
|
|
5216
|
+
Object.assign(extraFieldNTFS, extraFieldData);
|
|
5217
|
+
Object.assign(directory, extraFieldData);
|
|
5126
5218
|
}
|
|
5127
5219
|
}
|
|
5128
5220
|
|
|
@@ -5425,11 +5517,7 @@ function getOptionValue$1(zipReader, options, name) {
|
|
|
5425
5517
|
|
|
5426
5518
|
function getDate(timeRaw) {
|
|
5427
5519
|
const date = (timeRaw & 0xffff0000) >> 16, time = timeRaw & MAX_16_BITS;
|
|
5428
|
-
|
|
5429
|
-
return new Date(1980 + ((date & 0xFE00) >> 9), ((date & 0x01E0) >> 5) - 1, date & 0x001F, (time & 0xF800) >> 11, (time & 0x07E0) >> 5, (time & 0x001F) * 2, 0);
|
|
5430
|
-
} catch {
|
|
5431
|
-
// ignored
|
|
5432
|
-
}
|
|
5520
|
+
return new Date(1980 + ((date & 0xFE00) >> 9), ((date & 0x01E0) >> 5) - 1, date & 0x001F, (time & 0xF800) >> 11, (time & 0x07E0) >> 5, (time & 0x001F) * 2, 0);
|
|
5433
5521
|
}
|
|
5434
5522
|
|
|
5435
5523
|
function getDateNTFS(timeRaw) {
|
|
@@ -5462,7 +5550,9 @@ var zipReader = /*#__PURE__*/Object.freeze({
|
|
|
5462
5550
|
ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND: ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND,
|
|
5463
5551
|
ERR_EOCDR_NOT_FOUND: ERR_EOCDR_NOT_FOUND,
|
|
5464
5552
|
ERR_EXTRAFIELD_ZIP64_NOT_FOUND: ERR_EXTRAFIELD_ZIP64_NOT_FOUND,
|
|
5553
|
+
ERR_INVALID_AUTHENTICATION_CODE: ERR_INVALID_AUTHENTICATION_CODE,
|
|
5465
5554
|
ERR_INVALID_COMPRESSED_DATA: ERR_INVALID_COMPRESSED_DATA,
|
|
5555
|
+
ERR_INVALID_CRC32: ERR_INVALID_CRC32,
|
|
5466
5556
|
ERR_INVALID_PASSWORD: ERR_INVALID_PASSWORD,
|
|
5467
5557
|
ERR_INVALID_SIGNATURE: ERR_INVALID_SIGNATURE,
|
|
5468
5558
|
ERR_INVALID_UNCOMPRESSED_SIZE: ERR_INVALID_UNCOMPRESSED_SIZE,
|
|
@@ -5516,6 +5606,8 @@ const ERR_INVALID_EXTRAFIELD_DATA = "Extra field data exceeds 64KB";
|
|
|
5516
5606
|
const ERR_UNSUPPORTED_COMPRESSION = "Compression method not supported";
|
|
5517
5607
|
const MIN_UNIX_TIME = -2147483648;
|
|
5518
5608
|
const MAX_UNIX_TIME = 2147483647;
|
|
5609
|
+
const MIN_NTFS_TIME = BigInt(0);
|
|
5610
|
+
const MAX_NTFS_TIME = BigInt("0x7fffffffffffffff");
|
|
5519
5611
|
const ERR_UNSUPPORTED_FORMAT = "Zip64 is not supported (set the 'zip64' option to 'true')";
|
|
5520
5612
|
const ERR_UNDEFINED_UNCOMPRESSED_SIZE = "Undefined uncompressed size";
|
|
5521
5613
|
const ERR_UNDEFINED_READER = "Undefined reader";
|
|
@@ -5797,6 +5889,11 @@ async function addFile(zipWriter, name, reader, options) {
|
|
|
5797
5889
|
zipWriter.files.set(name, UNDEFINED_VALUE);
|
|
5798
5890
|
let fileEntry;
|
|
5799
5891
|
try {
|
|
5892
|
+
const { resolvedOptions } = metadataInfo;
|
|
5893
|
+
if (resolvedOptions.level != 0 && resolvedOptions.compressionMethod === UNDEFINED_VALUE &&
|
|
5894
|
+
!resolvedOptions.passThrough && !(await supportsDeflate(zipWriter.config))) {
|
|
5895
|
+
resolvedOptions.level = 0;
|
|
5896
|
+
}
|
|
5800
5897
|
const sizesInfo = await resolveSizes(zipWriter, reader, metadataInfo, options);
|
|
5801
5898
|
({ reader } = sizesInfo);
|
|
5802
5899
|
const diskOffset = getDiskOffset(zipWriter.writer);
|
|
@@ -6017,9 +6114,6 @@ function resolveMetadata(zipWriter, name, options) {
|
|
|
6017
6114
|
if (level !== UNDEFINED_VALUE && level != 6) {
|
|
6018
6115
|
useCompressionStream = false;
|
|
6019
6116
|
}
|
|
6020
|
-
if (!useCompressionStream && !registeredCodec && (zipWriter.config.CompressionStream === UNDEFINED_VALUE && zipWriter.config.CompressionStreamZlib === UNDEFINED_VALUE)) {
|
|
6021
|
-
level = 0;
|
|
6022
|
-
}
|
|
6023
6117
|
const zip64 = getOptionValue(zipWriter, options, PROPERTY_NAME_ZIP64);
|
|
6024
6118
|
if (!zipCrypto && (password !== UNDEFINED_VALUE || rawPassword !== UNDEFINED_VALUE) && !(encryptionStrength >= 1 && encryptionStrength <= 3)) {
|
|
6025
6119
|
throw new Error(ERR_INVALID_ENCRYPTION_STRENGTH);
|
|
@@ -6407,9 +6501,12 @@ async function createFileEntry(reader, writer, { diskNumberStart, lock }, entryI
|
|
|
6407
6501
|
msdosAttributes
|
|
6408
6502
|
};
|
|
6409
6503
|
let {
|
|
6410
|
-
signature,
|
|
6504
|
+
crc32: signature,
|
|
6411
6505
|
uncompressedSize
|
|
6412
6506
|
} = options;
|
|
6507
|
+
if (signature === UNDEFINED_VALUE) {
|
|
6508
|
+
({ signature } = options);
|
|
6509
|
+
}
|
|
6413
6510
|
let compressedSize = 0;
|
|
6414
6511
|
if (!passThrough) {
|
|
6415
6512
|
uncompressedSize = 0;
|
|
@@ -6427,7 +6524,7 @@ async function createFileEntry(reader, writer, { diskNumberStart, lock }, entryI
|
|
|
6427
6524
|
encryptionStrength,
|
|
6428
6525
|
zipCrypto: encrypted && zipCrypto,
|
|
6429
6526
|
passwordVerification: encrypted && zipCrypto && (rawLastModDate >> 8) & MAX_8_BITS,
|
|
6430
|
-
|
|
6527
|
+
computeCrc32: !passThrough,
|
|
6431
6528
|
compressed: compressed && !passThrough,
|
|
6432
6529
|
encrypted: encrypted && !passThrough,
|
|
6433
6530
|
useWebWorkers,
|
|
@@ -6446,7 +6543,9 @@ async function createFileEntry(reader, writer, { diskNumberStart, lock }, entryI
|
|
|
6446
6543
|
writer.size += compressedSize;
|
|
6447
6544
|
if (!passThrough) {
|
|
6448
6545
|
uncompressedSize = result.inputSize;
|
|
6449
|
-
|
|
6546
|
+
if (!encrypted || zipCrypto) {
|
|
6547
|
+
signature = result.signature;
|
|
6548
|
+
}
|
|
6450
6549
|
}
|
|
6451
6550
|
if ((!zip64CompressedSize && compressedSize >= MAX_32_BITS) ||
|
|
6452
6551
|
(!zip64UncompressedSize && uncompressedSize >= MAX_32_BITS)) {
|
|
@@ -6485,6 +6584,7 @@ async function createFileEntry(reader, writer, { diskNumberStart, lock }, entryI
|
|
|
6485
6584
|
headerArray,
|
|
6486
6585
|
headerView,
|
|
6487
6586
|
signature,
|
|
6587
|
+
crc32: encrypted && !zipCrypto ? UNDEFINED_VALUE : signature,
|
|
6488
6588
|
extraFieldExtendedTimestampFlag,
|
|
6489
6589
|
zip64UncompressedSize,
|
|
6490
6590
|
zip64CompressedSize
|
|
@@ -6585,8 +6685,8 @@ function getHeaderInfo(options) {
|
|
|
6585
6685
|
extraFieldNTFS.uint16(EXTRAFIELD_TYPE_NTFS_TAG1);
|
|
6586
6686
|
extraFieldNTFS.uint16(24);
|
|
6587
6687
|
extraFieldNTFS.uint64(lastModTimeNTFS);
|
|
6588
|
-
extraFieldNTFS.uint64(getTimeNTFS(lastAccessDate)
|
|
6589
|
-
extraFieldNTFS.uint64(getTimeNTFS(creationDate)
|
|
6688
|
+
extraFieldNTFS.uint64(lastAccessDate ? getTimeNTFS(lastAccessDate) : lastModTimeNTFS);
|
|
6689
|
+
extraFieldNTFS.uint64(creationDate ? getTimeNTFS(creationDate) : lastModTimeNTFS);
|
|
6590
6690
|
rawExtraFieldNTFS = extraFieldNTFS.array;
|
|
6591
6691
|
} catch {
|
|
6592
6692
|
rawExtraFieldNTFS = EMPTY_UINT8_ARRAY;
|
|
@@ -6646,7 +6746,7 @@ function getHeaderInfo(options) {
|
|
|
6646
6746
|
if (extraFieldLength > MAX_16_BITS) {
|
|
6647
6747
|
throw new Error(ERR_INVALID_EXTRAFIELD_DATA);
|
|
6648
6748
|
}
|
|
6649
|
-
const dosLastModDate = new Date(Math.ceil(lastModDate.getTime() /
|
|
6749
|
+
const dosLastModDate = new Date(Math.ceil(Math.floor(lastModDate.getTime() / 1000) / 2) * 2000);
|
|
6650
6750
|
const {
|
|
6651
6751
|
headerArray,
|
|
6652
6752
|
headerView,
|
|
@@ -7155,7 +7255,8 @@ async function flushBufferedData(readable, writer, signal, onChunkWritten) {
|
|
|
7155
7255
|
|
|
7156
7256
|
function getTimeNTFS(date) {
|
|
7157
7257
|
if (date) {
|
|
7158
|
-
|
|
7258
|
+
const timeNTFS = ((BigInt(date.getTime()) + BigInt(11644473600000)) * BigInt(10000));
|
|
7259
|
+
return timeNTFS < MIN_NTFS_TIME ? MIN_NTFS_TIME : timeNTFS > MAX_NTFS_TIME ? MAX_NTFS_TIME : timeNTFS;
|
|
7159
7260
|
}
|
|
7160
7261
|
}
|
|
7161
7262
|
|
|
@@ -10847,10 +10948,12 @@ exports.ERR_EOCDR_NOT_FOUND = ERR_EOCDR_NOT_FOUND;
|
|
|
10847
10948
|
exports.ERR_EXTRAFIELD_ZIP64_NOT_FOUND = ERR_EXTRAFIELD_ZIP64_NOT_FOUND;
|
|
10848
10949
|
exports.ERR_HTTP_RANGE = ERR_HTTP_RANGE;
|
|
10849
10950
|
exports.ERR_HTTP_RESOURCE_CHANGED = ERR_HTTP_RESOURCE_CHANGED;
|
|
10951
|
+
exports.ERR_INVALID_AUTHENTICATION_CODE = ERR_INVALID_AUTHENTICATION_CODE;
|
|
10850
10952
|
exports.ERR_INVALID_CODEC_DEFINITION = ERR_INVALID_CODEC_DEFINITION;
|
|
10851
10953
|
exports.ERR_INVALID_CODEC_MODULE = ERR_INVALID_CODEC_MODULE;
|
|
10852
10954
|
exports.ERR_INVALID_COMMENT = ERR_INVALID_COMMENT;
|
|
10853
10955
|
exports.ERR_INVALID_COMPRESSED_DATA = ERR_INVALID_COMPRESSED_DATA;
|
|
10956
|
+
exports.ERR_INVALID_CRC32 = ERR_INVALID_CRC32;
|
|
10854
10957
|
exports.ERR_INVALID_ENCRYPTION_STRENGTH = ERR_INVALID_ENCRYPTION_STRENGTH;
|
|
10855
10958
|
exports.ERR_INVALID_ENTRY_COMMENT = ERR_INVALID_ENTRY_COMMENT;
|
|
10856
10959
|
exports.ERR_INVALID_ENTRY_NAME = ERR_INVALID_ENTRY_NAME;
|