@zip.js/zip.js 2.8.44 → 2.8.45

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.
Files changed (51) hide show
  1. package/deno.json +21 -1
  2. package/dist/zip-core-external.js +138 -123
  3. package/dist/zip-core-external.min.js +1 -1
  4. package/dist/zip-core.js +137 -96
  5. package/dist/zip-core.min.js +1 -1
  6. package/dist/zip-fs-core-external.js +190 -131
  7. package/dist/zip-fs-core-external.min.js +1 -1
  8. package/dist/zip-fs-core.js +189 -104
  9. package/dist/zip-fs-core.min.js +1 -1
  10. package/dist/zip-fs-external.js +211 -1725
  11. package/dist/zip-fs-external.min.js +1 -1
  12. package/dist/zip-fs-native.js +212 -1700
  13. package/dist/zip-fs-native.min.js +1 -1
  14. package/dist/zip-fs.js +211 -1699
  15. package/dist/zip-fs.min.js +1 -1
  16. package/dist/zip-legacy.js +139 -98
  17. package/dist/zip-legacy.min.js +1 -1
  18. package/dist/zip-native.js +139 -98
  19. package/dist/zip-native.min.js +1 -1
  20. package/dist/zip-web-worker-native.js +1 -1
  21. package/dist/zip-web-worker.js +1 -1
  22. package/dist/zip.js +138 -97
  23. package/dist/zip.min.js +1 -1
  24. package/eslint.config.mjs +31 -2
  25. package/index-native.cjs +212 -1700
  26. package/index-native.min.js +1 -1
  27. package/index.cjs +211 -1699
  28. package/index.d.cts +49 -1
  29. package/index.d.ts +49 -1
  30. package/index.min.js +1 -1
  31. package/lib/core/codec-worker.js +2 -2
  32. package/lib/core/constants.js +4 -0
  33. package/lib/core/options.js +2 -0
  34. package/lib/core/streams/aes-crypto-stream.js +15 -18
  35. package/lib/core/streams/codec-stream.js +2 -2
  36. package/lib/core/streams/zip-entry-stream.js +5 -10
  37. package/lib/core/util/mime-type-data.js +3 -0
  38. package/lib/core/util/mime-type.js +23 -1596
  39. package/lib/core/web-worker-base.js +2 -2
  40. package/lib/core/web-worker-inline-native.js +1 -1
  41. package/lib/core/web-worker-inline-wasm.js +1 -1
  42. package/lib/core/zip-entry.js +8 -1
  43. package/lib/core/zip-fs.js +62 -5
  44. package/lib/core/zip-reader.js +45 -17
  45. package/lib/core/zip-writer.js +58 -44
  46. package/lib/zip-core-external.js +2 -0
  47. package/lib/zip-fs-core-external.js +2 -0
  48. package/lib/zip-fs-external.js +2 -0
  49. package/lib/zip-mime-types.js +2 -0
  50. package/package.json +9 -3
  51. package/worker-message-property-names.js +1 -1
package/dist/zip.js CHANGED
@@ -71,6 +71,8 @@
71
71
  const EXTRAFIELD_TYPE_USDZ = 0x1986;
72
72
  const EXTRAFIELD_TYPE_INFOZIP = 0x7875;
73
73
  const EXTRAFIELD_TYPE_UNIX = 0x7855;
74
+ const EXTRAFIELD_TYPE_UNIX_TYPE1 = 0x5855;
75
+ const EXTRAFIELD_TYPE_PKWARE_UNIX = 0x000d;
74
76
 
75
77
  const BITFLAG_ENCRYPTED = 0b1;
76
78
  const BITFLAG_LEVEL = 0b0110;
@@ -224,7 +226,7 @@
224
226
  Object.assign(config, DEFAULT_CONFIGURATION);
225
227
  }
226
228
 
227
- 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)}});}
229
+ 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:w,TextEncoder:u,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,w;const u=new ArrayBuffer(o),h=new l(u);let p=0;const d=V;for(e=K.bytes.A(e),w=1;(o||1)>p;w++){for(c=i=t.encrypt(d.concat(e,[w])),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 u.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 w=16843009*f^65537*a^257*i^16843008*l,u=257*r[o]^16843008*o;for(let n=0;4>n;n++)t[n][l]=u=u<<24^u>>>8,e[n][o]=w=w<<24^w>>>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],w=c[4];let u,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++)u=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=u,y=h,m=p;for(let t=0;4>t;t++)o[e?3&-t:t]=w[d>>>24]<<24^w[y>>16&255]<<16^w[m>>8&255]<<8^w[255&g]^n[S++],u=d,d=y,y=m,m=g,g=u;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 wt 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 w=s.length<tt?1:0;for(let t=0;tt>t;t++)w|=l[t]^a[t];if(w&&c)throw new r(H);t.enqueue(f)}}})}}class ut extends d{constructor({password:t,rawPassword:e,encryptionStrength:n}){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:s,ready:r}=this;if(n&&e){await r;let o=z;if(s.length){const t=e.update(St(ot,s));n.update(t),o=gt(ot,t)}const c=gt(ot,n.digest()).slice(0,tt);t.enqueue(_(o,c))}}})}}function ht(t,n,s,r){e.assign(t,{ready:new w(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 w;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)),w=0;l-q>=w;w+=q){const t=St(ot,mt(e,w,w+q));c&&a.update(t);const r=i.update(t);c||a.update(r),n.set(gt(ot,r),w+s)}return t.pending=mt(e,w),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])),w=St(ot,mt(f,$[s],2*$[s])),u=mt(f,2*$[s]);return e.assign(n,{keys:{key:l,ct:w,passwordVerification:u},st:new it(new ct(l),t.from(et)),ot:new at(w)}),u}function yt(t,e){return e===v?(t=>{if(typeof u==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 u).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:w,format:u,compressionMethod:h}=t,p=this;let d,y,m,g=super.readable;const S=u&&Bt(u),v=a&&r&&!w&&!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,u,{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 ut(t),g=jt(g,y))),Ft(p,g,()=>{o&&!i||!a||(p.crc32=v?m.crc32:new l(d.value.buffer).getUint32(0))})}}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.crc32=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,crc32:f,compressed:u,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 wt(t),C=jt(C,z))),u){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 u=new w((t,e)=>{i=t,a=e});u.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 u}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})}}),w=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{crc32:t}=a;e.assign(s,{crc32:t,inputSize:i})}});e.defineProperty(s,"readable",{get:()=>f.pipeThrough(l).pipeThrough(a).pipeThrough(w)})}}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 w(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 w(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:u}=$t;await l.pipeThrough(e).pipeThrough(new Jt((t=>s.max(t.chunkSize,64))(i))).pipeTo(o,{signal:u,preventClose:!0,preventAbort:!0}),await o.getWriter().close();const{crc32:h,inputSize:p,outputSize:d}=e;ie({type:Nt,result:{crc32: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.wt=new o(i),t?(this.ut=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.ut=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.ut=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.ut,l=this.ht,w=this.lt,u=this.wt;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,w,i,0),p=16777215&o;if(p&&(u.set(a.subarray(w,w+p),0),n.enqueue(u.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.ut,c=this.lt,a=this.wt;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 we{constructor(t="deflate",e){return fe(!1,t,e)}}le.St=!0,we.St=!0;let ue=!1;self.initModule=async t=>{const e=await(async(t,{baseURI:e})=>{if(!ue)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),ue=!0}catch(t){throw(t=>{re=t})(t),t}})(t.wasmURI,t);return t.CompressionStreamZlib=le,t.DecompressionStreamZlib=we,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)}});}
228
230
 
229
231
  /*
230
232
  Copyright (c) 2025 Gildas Lormeau. All rights reserved.
@@ -1422,7 +1424,7 @@
1422
1424
  const DERIVED_BITS_USAGE = ["deriveBits"];
1423
1425
  const SALT_LENGTH = [8, 12, 16];
1424
1426
  const KEY_LENGTH = [16, 24, 32];
1425
- const SIGNATURE_LENGTH = 10;
1427
+ const AUTHENTICATION_CODE_LENGTH = 10;
1426
1428
  const COUNTER_DEFAULT_VALUE = [0, 0, 0, 0];
1427
1429
  // deno-lint-ignore valid-typeof
1428
1430
  const CRYPTO_API_SUPPORTED = typeof crypto != UNDEFINED_TYPE;
@@ -1462,8 +1464,8 @@
1462
1464
  } else {
1463
1465
  await ready;
1464
1466
  }
1465
- const output = new Uint8Array(chunk.length - SIGNATURE_LENGTH - ((chunk.length - SIGNATURE_LENGTH) % BLOCK_LENGTH));
1466
- controller.enqueue(append(aesCrypto, chunk, output, 0, SIGNATURE_LENGTH, true));
1467
+ const output = new Uint8Array(chunk.length - AUTHENTICATION_CODE_LENGTH - ((chunk.length - AUTHENTICATION_CODE_LENGTH) % BLOCK_LENGTH));
1468
+ controller.enqueue(append(aesCrypto, chunk, output, 0, AUTHENTICATION_CODE_LENGTH, true));
1467
1469
  },
1468
1470
  async flush(controller) {
1469
1471
  const {
@@ -1474,8 +1476,8 @@
1474
1476
  } = this;
1475
1477
  if (hmac && ctr) {
1476
1478
  await ready;
1477
- const chunkToDecrypt = subarray(pending, 0, pending.length - SIGNATURE_LENGTH);
1478
- const originalSignature = subarray(pending, pending.length - SIGNATURE_LENGTH);
1479
+ const chunkToDecrypt = subarray(pending, 0, pending.length - AUTHENTICATION_CODE_LENGTH);
1480
+ const originalAuthenticationCode = subarray(pending, pending.length - AUTHENTICATION_CODE_LENGTH);
1479
1481
  let decryptedChunkArray = EMPTY_UINT8_ARRAY;
1480
1482
  if (chunkToDecrypt.length) {
1481
1483
  const encryptedChunk = toBits(codecBytes, chunkToDecrypt);
@@ -1483,12 +1485,12 @@
1483
1485
  const decryptedChunk = ctr.update(encryptedChunk);
1484
1486
  decryptedChunkArray = fromBits(codecBytes, decryptedChunk);
1485
1487
  }
1486
- const signature = subarray(fromBits(codecBytes, hmac.digest()), 0, SIGNATURE_LENGTH);
1487
- let invalidSignature = pending.length < SIGNATURE_LENGTH ? 1 : 0;
1488
- for (let indexSignature = 0; indexSignature < SIGNATURE_LENGTH; indexSignature++) {
1489
- invalidSignature |= signature[indexSignature] ^ originalSignature[indexSignature];
1488
+ const authenticationCode = subarray(fromBits(codecBytes, hmac.digest()), 0, AUTHENTICATION_CODE_LENGTH);
1489
+ let invalidAuthenticationCode = pending.length < AUTHENTICATION_CODE_LENGTH ? 1 : 0;
1490
+ for (let indexByte = 0; indexByte < AUTHENTICATION_CODE_LENGTH; indexByte++) {
1491
+ invalidAuthenticationCode |= authenticationCode[indexByte] ^ originalAuthenticationCode[indexByte];
1490
1492
  }
1491
- if (invalidSignature && checkAuthenticationCode) {
1493
+ if (invalidAuthenticationCode && checkAuthenticationCode) {
1492
1494
  throw new Error(ERR_INVALID_AUTHENTICATION_CODE);
1493
1495
  }
1494
1496
  controller.enqueue(decryptedChunkArray);
@@ -1501,8 +1503,6 @@
1501
1503
  class AESEncryptionStream extends TransformStream {
1502
1504
 
1503
1505
  constructor({ password, rawPassword, encryptionStrength }) {
1504
- // deno-lint-ignore prefer-const
1505
- let stream;
1506
1506
  super({
1507
1507
  start() {
1508
1508
  initAesCrypto(this, password, rawPassword, encryptionStrength);
@@ -1541,12 +1541,11 @@
1541
1541
  hmac.update(encryptedChunk);
1542
1542
  encryptedChunkArray = fromBits(codecBytes, encryptedChunk);
1543
1543
  }
1544
- stream.signature = fromBits(codecBytes, hmac.digest()).slice(0, SIGNATURE_LENGTH);
1545
- controller.enqueue(concat(encryptedChunkArray, stream.signature));
1544
+ const authenticationCode = fromBits(codecBytes, hmac.digest()).slice(0, AUTHENTICATION_CODE_LENGTH);
1545
+ controller.enqueue(concat(encryptedChunkArray, authenticationCode));
1546
1546
  }
1547
1547
  }
1548
1548
  });
1549
- stream = this;
1550
1549
  }
1551
1550
  }
1552
1551
 
@@ -1559,7 +1558,7 @@
1559
1558
  });
1560
1559
  }
1561
1560
 
1562
- function append(aesCrypto, input, output, paddingStart, paddingEnd, verifySignature) {
1561
+ function append(aesCrypto, input, output, paddingStart, paddingEnd, verifyAuthenticationCode) {
1563
1562
  const {
1564
1563
  ctr,
1565
1564
  hmac,
@@ -1573,11 +1572,11 @@
1573
1572
  let offset;
1574
1573
  for (offset = 0; offset <= inputLength - BLOCK_LENGTH; offset += BLOCK_LENGTH) {
1575
1574
  const inputChunk = toBits(codecBytes, subarray(input, offset, offset + BLOCK_LENGTH));
1576
- if (verifySignature) {
1575
+ if (verifyAuthenticationCode) {
1577
1576
  hmac.update(inputChunk);
1578
1577
  }
1579
1578
  const outputChunk = ctr.update(inputChunk);
1580
- if (!verifySignature) {
1579
+ if (!verifyAuthenticationCode) {
1581
1580
  hmac.update(outputChunk);
1582
1581
  }
1583
1582
  output.set(fromBits(codecBytes, outputChunk), offset + paddingStart);
@@ -1983,14 +1982,9 @@
1983
1982
  }
1984
1983
  }
1985
1984
  setReadable(stream, readable, () => {
1986
- let signature;
1987
- if (encrypted && !zipCrypto) {
1988
- signature = encryptionStream.signature;
1989
- }
1990
1985
  if ((!encrypted || zipCrypto) && computeCrc32) {
1991
- signature = useGzipCrc32 ? gzipCrc32Stream.signature : new DataView(crc32Stream.value.buffer).getUint32(0);
1986
+ stream.crc32 = useGzipCrc32 ? gzipCrc32Stream.crc32 : new DataView(crc32Stream.value.buffer).getUint32(0);
1992
1987
  }
1993
- stream.signature = signature;
1994
1988
  });
1995
1989
  }
1996
1990
  }
@@ -2028,7 +2022,7 @@
2028
2022
  },
2029
2023
  flush() {
2030
2024
  const dataView = getDataView(trailerCandidate);
2031
- stream.signature = dataView.getUint32(0, true);
2025
+ stream.crc32 = dataView.getUint32(0, true);
2032
2026
  stream.uncompressedSize = dataView.getUint32(4, true);
2033
2027
  }
2034
2028
  });
@@ -2110,7 +2104,7 @@
2110
2104
 
2111
2105
  constructor(options, { chunkSize, DecompressionStreamZlib, DecompressionStream }) {
2112
2106
  super({});
2113
- const { zipCrypto, encrypted, checkCrc32, signature, compressed, useCompressionStream, deflate64, format, compressionMethod, rawBitFlag, outputSize } = options;
2107
+ const { zipCrypto, encrypted, checkCrc32, crc32, compressed, useCompressionStream, deflate64, format, compressionMethod, rawBitFlag, outputSize } = options;
2114
2108
  let crc32Stream, decryptionStream;
2115
2109
  let readable = super.readable;
2116
2110
  if (encrypted) {
@@ -2149,8 +2143,8 @@
2149
2143
  }
2150
2144
  setReadable(this, readable, () => {
2151
2145
  if (checkCrc32) {
2152
- const dataViewSignature = new DataView(crc32Stream.value.buffer);
2153
- if (signature != dataViewSignature.getUint32(0, false)) {
2146
+ const computedCrc32View = new DataView(crc32Stream.value.buffer);
2147
+ if (crc32 != computedCrc32View.getUint32(0, false)) {
2154
2148
  throw new Error(ERR_INVALID_CRC32);
2155
2149
  }
2156
2150
  }
@@ -2375,9 +2369,9 @@
2375
2369
  }
2376
2370
  },
2377
2371
  flush() {
2378
- const { signature } = stream;
2372
+ const { crc32 } = stream;
2379
2373
  Object.assign(codec, {
2380
- signature,
2374
+ crc32,
2381
2375
  inputSize
2382
2376
  });
2383
2377
  }
@@ -2680,12 +2674,12 @@
2680
2674
  .pipeThrough(new ChunkStream(getChunkSize(config)))
2681
2675
  .pipeTo(writable, { preventClose: true, preventAbort: true });
2682
2676
  const {
2683
- signature,
2677
+ crc32,
2684
2678
  inputSize,
2685
2679
  outputSize
2686
2680
  } = codecStream;
2687
2681
  return {
2688
- signature,
2682
+ crc32,
2689
2683
  inputSize,
2690
2684
  outputSize
2691
2685
  };
@@ -4283,6 +4277,8 @@
4283
4277
  const PROPERTY_NAME_EXTRA_FIELD = "extraField";
4284
4278
  const PROPERTY_NAME_EXTRA_FIELD_INFOZIP = "extraFieldInfoZip";
4285
4279
  const PROPERTY_NAME_EXTRA_FIELD_UNIX = "extraFieldUnix";
4280
+ const PROPERTY_NAME_EXTRA_FIELD_UNIX_TYPE1 = "extraFieldUnixType1";
4281
+ const PROPERTY_NAME_EXTRA_FIELD_PKWARE_UNIX = "extraFieldPkwareUnix";
4286
4282
  const PROPERTY_NAME_UID = "uid";
4287
4283
  const PROPERTY_NAME_GID = "gid";
4288
4284
  const PROPERTY_NAME_UNIX_MODE = "unixMode";
@@ -4299,6 +4295,7 @@
4299
4295
  const PROPERTY_NAME_EXTRA_FIELD_AES = "extraFieldAES";
4300
4296
  const PROPERTY_NAME_EXTRA_FIELD_NTFS = "extraFieldNTFS";
4301
4297
  const PROPERTY_NAME_EXTRA_FIELD_EXTENDED_TIMESTAMP = "extraFieldExtendedTimestamp";
4298
+ const PROPERTY_NAME_EXTRA_FIELD_USDZ = "extraFieldUSDZ";
4302
4299
 
4303
4300
  const PROPERTY_NAMES = [
4304
4301
  PROPERTY_NAME_FILENAME,
@@ -4310,6 +4307,7 @@
4310
4307
  PROPERTY_NAME_COMMENT,
4311
4308
  PROPERTY_NAME_RAW_COMMENT,
4312
4309
  PROPERTY_NAME_LAST_ACCESS_DATE,
4310
+ PROPERTY_NAME_RAW_LAST_ACCESS_DATE,
4313
4311
  PROPERTY_NAME_CREATION_DATE,
4314
4312
  PROPERTY_NAME_RAW_CREATION_DATE,
4315
4313
  PROPERTY_NAME_OFFSET,
@@ -4332,6 +4330,8 @@
4332
4330
  PROPERTY_NAME_EXTRA_FIELD,
4333
4331
  PROPERTY_NAME_EXTRA_FIELD_UNIX,
4334
4332
  PROPERTY_NAME_EXTRA_FIELD_INFOZIP,
4333
+ PROPERTY_NAME_EXTRA_FIELD_UNIX_TYPE1,
4334
+ PROPERTY_NAME_EXTRA_FIELD_PKWARE_UNIX,
4335
4335
  PROPERTY_NAME_UID,
4336
4336
  PROPERTY_NAME_GID,
4337
4337
  PROPERTY_NAME_UNIX_MODE,
@@ -4347,7 +4347,8 @@
4347
4347
  PROPERTY_NAME_EXTRA_FIELD_UNICODE_COMMENT,
4348
4348
  PROPERTY_NAME_EXTRA_FIELD_AES,
4349
4349
  PROPERTY_NAME_EXTRA_FIELD_NTFS,
4350
- PROPERTY_NAME_EXTRA_FIELD_EXTENDED_TIMESTAMP
4350
+ PROPERTY_NAME_EXTRA_FIELD_EXTENDED_TIMESTAMP,
4351
+ PROPERTY_NAME_EXTRA_FIELD_USDZ
4351
4352
  ];
4352
4353
 
4353
4354
  class Entry {
@@ -4421,6 +4422,7 @@
4421
4422
  const OPTION_OFFSET = "offset";
4422
4423
  const OPTION_USDZ = "usdz";
4423
4424
  const OPTION_UNIX_EXTRA_FIELD_TYPE = "unixExtraFieldType";
4425
+ const OPTION_LOCAL_EXTRA_FIELD = "localExtraField";
4424
4426
  const OPTION_STRICTNESS = "strictness";
4425
4427
  const OPTION_MAX_APPENDED_DATA_SIZE = "maxAppendedDataSize";
4426
4428
  const STRICTNESS_STRICT = "strict";
@@ -4473,7 +4475,7 @@
4473
4475
  const PROPERTY_NAME_UTF8_SUFFIX = "UTF8";
4474
4476
  const CHARSET_CP437 = "cp437";
4475
4477
  const BITFLAG_AMBIGUITY_MASK = BITFLAG_ENCRYPTED | BITFLAG_DATA_DESCRIPTOR | BITFLAG_LANG_ENCODING_FLAG;
4476
- const VENDOR_VERSION_AE_1 = 1;
4478
+ const VENDOR_VERSION_AE_1$1 = 1;
4477
4479
  const ZIP64_PROPERTIES = [
4478
4480
  [PROPERTY_NAME_UNCOMPRESSED_SIZE, MAX_32_BITS],
4479
4481
  [PROPERTY_NAME_COMPRESSED_SIZE, MAX_32_BITS],
@@ -4866,7 +4868,7 @@
4866
4868
  config,
4867
4869
  bitFlag,
4868
4870
  rawBitFlag,
4869
- signature,
4871
+ crc32,
4870
4872
  rawLastModDate,
4871
4873
  uncompressedSize,
4872
4874
  compressedSize
@@ -4957,7 +4959,7 @@
4957
4959
  const checkCrc32 = (checkCrc32Option === UNDEFINED_VALUE ?
4958
4960
  getOptionValue$1(zipEntry, options, OPTION_CHECK_SIGNATURE) :
4959
4961
  checkCrc32Option) && !passThrough &&
4960
- (!encrypted || zipCrypto || (extraFieldAES && extraFieldAES.vendorVersion == VENDOR_VERSION_AE_1));
4962
+ (!encrypted || zipCrypto || (extraFieldAES && extraFieldAES.vendorVersion == VENDOR_VERSION_AE_1$1));
4961
4963
  const workerOptions = {
4962
4964
  options: {
4963
4965
  codecType: CODEC_INFLATE,
@@ -4967,9 +4969,9 @@
4967
4969
  encryptionStrength: extraFieldAES && extraFieldAES.strength,
4968
4970
  checkCrc32,
4969
4971
  checkAuthenticationCode: getOptionValue$1(zipEntry, options, OPTION_CHECK_AUTHENTICATION_CODE),
4970
- passwordVerification: zipCrypto && (dataDescriptor ? ((rawLastModDate >>> 8) & MAX_8_BITS) : ((signature >>> 24) & MAX_8_BITS)),
4972
+ passwordVerification: zipCrypto && (dataDescriptor ? ((rawLastModDate >>> 8) & MAX_8_BITS) : ((crc32 >>> 24) & MAX_8_BITS)),
4971
4973
  outputSize: passThrough ? compressedSize : uncompressedSize,
4972
- signature,
4974
+ crc32,
4973
4975
  compressed: compressionMethod != 0 && !passThrough,
4974
4976
  encrypted,
4975
4977
  useWebWorkers: getOptionValue$1(zipEntry, options, OPTION_USE_WEB_WORKERS),
@@ -4991,7 +4993,7 @@
4991
4993
  fileEntry,
4992
4994
  index,
4993
4995
  offset: localHeaderOffset,
4994
- signature,
4996
+ crc32,
4995
4997
  compressedSize,
4996
4998
  uncompressedSize,
4997
4999
  dataOffset,
@@ -5108,6 +5110,16 @@
5108
5110
  } else {
5109
5111
  directory.compressionMethod = compressionMethod;
5110
5112
  }
5113
+ const extraFieldPkwareUnix = extraField.get(EXTRAFIELD_TYPE_PKWARE_UNIX);
5114
+ if (extraFieldPkwareUnix) {
5115
+ readExtraFieldUnixDates(extraFieldPkwareUnix, directory);
5116
+ directory.extraFieldPkwareUnix = extraFieldPkwareUnix;
5117
+ }
5118
+ const extraFieldUnixType1 = extraField.get(EXTRAFIELD_TYPE_UNIX_TYPE1);
5119
+ if (extraFieldUnixType1) {
5120
+ readExtraFieldUnixDates(extraFieldUnixType1, directory);
5121
+ directory.extraFieldUnixType1 = extraFieldUnixType1;
5122
+ }
5111
5123
  const extraFieldNTFS = extraField.get(EXTRAFIELD_TYPE_NTFS);
5112
5124
  if (extraFieldNTFS) {
5113
5125
  readExtraFieldNTFS(extraFieldNTFS, directory);
@@ -5157,15 +5169,15 @@
5157
5169
  return;
5158
5170
  }
5159
5171
  const extraFieldView = getDataView(extraFieldUnicode.data);
5160
- const crc32 = new Crc32();
5161
- crc32.append(fileEntry[rawPropertyName]);
5162
- const dataViewSignature = getDataView(new Uint8Array(4));
5163
- dataViewSignature.setUint32(0, crc32.get(), true);
5164
- const signature = getUint32(extraFieldView, 1);
5172
+ const computedCrc32 = new Crc32();
5173
+ computedCrc32.append(fileEntry[rawPropertyName]);
5174
+ const computedCrc32View = getDataView(new Uint8Array(4));
5175
+ computedCrc32View.setUint32(0, computedCrc32.get(), true);
5176
+ const nameCrc32 = getUint32(extraFieldView, 1);
5165
5177
  Object.assign(extraFieldUnicode, {
5166
5178
  version: getUint8(extraFieldView, 0),
5167
5179
  [propertyName]: decodeText(extraFieldUnicode.data.subarray(5)),
5168
- valid: !fileEntry.bitFlag.languageEncodingFlag && signature == getUint32(dataViewSignature, 0)
5180
+ valid: !fileEntry.bitFlag.languageEncodingFlag && nameCrc32 == getUint32(computedCrc32View, 0)
5169
5181
  });
5170
5182
  if (extraFieldUnicode.valid) {
5171
5183
  directory[propertyName] = extraFieldUnicode[propertyName];
@@ -5184,7 +5196,7 @@
5184
5196
  compressionMethod: getUint16(extraFieldView, 5)
5185
5197
  });
5186
5198
  directory.compressionMethod = extraFieldAES.compressionMethod;
5187
- if (extraFieldAES.vendorVersion != VENDOR_VERSION_AE_1) {
5199
+ if (extraFieldAES.vendorVersion != VENDOR_VERSION_AE_1$1) {
5188
5200
  directory.crc32 = UNDEFINED_VALUE;
5189
5201
  }
5190
5202
  }
@@ -5224,6 +5236,22 @@
5224
5236
  }
5225
5237
  }
5226
5238
 
5239
+ function readExtraFieldUnixDates(extraField, directory) {
5240
+ if (extraField.data.length < 8) {
5241
+ return;
5242
+ }
5243
+ const extraFieldView = getDataView(extraField.data);
5244
+ const lastAccessDate = new Date(getUint32(extraFieldView, 0) * 1000);
5245
+ const lastModDate = new Date(getUint32(extraFieldView, 4) * 1000);
5246
+ const extraFieldData = { lastAccessDate, lastModDate };
5247
+ if (extraField.data.length >= 12) {
5248
+ extraFieldData.uid = getUint16(extraFieldView, 8);
5249
+ extraFieldData.gid = getUint16(extraFieldView, 10);
5250
+ }
5251
+ Object.assign(extraField, extraFieldData);
5252
+ Object.assign(directory, extraFieldData);
5253
+ }
5254
+
5227
5255
  function readExtraFieldUnix(extraField, directory, isInfoZip) {
5228
5256
  try {
5229
5257
  const view = getDataView(extraField.data);
@@ -5302,7 +5330,7 @@
5302
5330
  fileEntry,
5303
5331
  index,
5304
5332
  offset,
5305
- signature,
5333
+ crc32,
5306
5334
  compressedSize,
5307
5335
  uncompressedSize,
5308
5336
  dataOffset,
@@ -5323,7 +5351,7 @@
5323
5351
  const dataDescriptorSignature = dataDescriptorArray.length == dataDescriptorLength + DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH &&
5324
5352
  getUint32(getDataView(dataDescriptorArray), 0) == DATA_DESCRIPTOR_RECORD_SIGNATURE;
5325
5353
  if (dataDescriptorSignature) {
5326
- const readSignature = getUint32(getDataView(dataDescriptorArray), 4);
5354
+ const readCrc32 = getUint32(getDataView(dataDescriptorArray), 4);
5327
5355
  let readCompressedSize;
5328
5356
  let readUncompressedSize;
5329
5357
  if (extraFieldZip64) {
@@ -5333,8 +5361,8 @@
5333
5361
  readCompressedSize = getUint32(getDataView(dataDescriptorArray), 8);
5334
5362
  readUncompressedSize = getUint32(getDataView(dataDescriptorArray), 12);
5335
5363
  }
5336
- const matchSignature = (fileEntry.encrypted && !fileEntry.zipCrypto) || readSignature == signature;
5337
- if (matchSignature &&
5364
+ const matchCrc32 = (fileEntry.encrypted && !fileEntry.zipCrypto) || readCrc32 == crc32;
5365
+ if (matchCrc32 &&
5338
5366
  readCompressedSize == compressedSize &&
5339
5367
  readUncompressedSize == uncompressedSize) {
5340
5368
  dataDescriptorLength += DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH;
@@ -5503,11 +5531,11 @@
5503
5531
  throwAmbiguousArchive("mismatched local file header (compression method)");
5504
5532
  }
5505
5533
  if (!localDirectory.bitFlag.dataDescriptor &&
5506
- (localDirectory.signature || localDirectory.compressedSize || localDirectory.uncompressedSize) &&
5507
- (localDirectory.signature != zipEntry.signature ||
5534
+ (localDirectory.crc32 || localDirectory.compressedSize || localDirectory.uncompressedSize) &&
5535
+ (localDirectory.crc32 != zipEntry.crc32 ||
5508
5536
  localDirectory.compressedSize != zipEntry.compressedSize ||
5509
5537
  localDirectory.uncompressedSize != zipEntry.uncompressedSize)) {
5510
- throwAmbiguousArchive("mismatched local file header (signature or sizes)");
5538
+ throwAmbiguousArchive("mismatched local file header (crc32 or sizes)");
5511
5539
  }
5512
5540
  }
5513
5541
 
@@ -5627,6 +5655,8 @@
5627
5655
  const ERR_INVALID_MSDOS_DATA = "Invalid msdosAttributes (must be an object with boolean flags)";
5628
5656
 
5629
5657
  const EXTRAFIELD_DATA_AES = new Uint8Array([0x07, 0x00, 0x02, 0x00, 0x41, 0x45, 0x03, 0x00, 0x00]);
5658
+ const EXTRAFIELD_OFFSET_AES_VENDOR_VERSION = 4;
5659
+ const VENDOR_VERSION_AE_1 = 1;
5630
5660
  const INFOZIP_EXTRA_FIELD_TYPE = "infozip";
5631
5661
  const UNIX_EXTRA_FIELD_TYPE = "unix";
5632
5662
 
@@ -5721,9 +5751,9 @@
5721
5751
  zip64UncompressedSize,
5722
5752
  extraFieldLength
5723
5753
  });
5724
- const { signature } = entry;
5725
- if (signature !== UNDEFINED_VALUE) {
5726
- setUint32(headerView, HEADER_OFFSET_SIGNATURE, signature);
5754
+ const { crc32 } = entry;
5755
+ if (crc32 !== UNDEFINED_VALUE) {
5756
+ setUint32(headerView, HEADER_OFFSET_SIGNATURE, crc32);
5727
5757
  }
5728
5758
  Object.assign(entry, {
5729
5759
  zip64UncompressedSize,
@@ -5908,6 +5938,7 @@
5908
5938
  internalFileAttribute: metadataInfo.resolvedOptions.internalFileAttributes,
5909
5939
  externalFileAttribute: attributesInfo.resolvedOptions.externalFileAttributes,
5910
5940
  signature: options[PROPERTY_NAME_SIGNATURE],
5941
+ crc32: options.crc32 === UNDEFINED_VALUE ? options[PROPERTY_NAME_SIGNATURE] : options.crc32,
5911
5942
  offset: zipWriter.offset - diskOffset,
5912
5943
  diskNumberStart: diskNumber
5913
5944
  });
@@ -6124,27 +6155,8 @@
6124
6155
  if (!zipCrypto && (password !== UNDEFINED_VALUE || rawPassword !== UNDEFINED_VALUE) && !(encryptionStrength >= 1 && encryptionStrength <= 3)) {
6125
6156
  throw new Error(ERR_INVALID_ENCRYPTION_STRENGTH);
6126
6157
  }
6127
- let rawExtraField = EMPTY_UINT8_ARRAY;
6128
- const extraField = options[PROPERTY_NAME_EXTRA_FIELD];
6129
- if (extraField) {
6130
- let extraFieldSize = 0;
6131
- let offset = 0;
6132
- extraField.forEach(data => extraFieldSize += 4 + getLength(data));
6133
- rawExtraField = new Uint8Array(extraFieldSize);
6134
- const rawExtraFieldView = getDataView(rawExtraField);
6135
- extraField.forEach((data, type) => {
6136
- if (type > MAX_16_BITS) {
6137
- throw new Error(ERR_INVALID_EXTRAFIELD_TYPE);
6138
- }
6139
- if (getLength(data) > MAX_16_BITS) {
6140
- throw new Error(ERR_INVALID_EXTRAFIELD_DATA);
6141
- }
6142
- setUint16(rawExtraFieldView, offset, type);
6143
- setUint16(rawExtraFieldView, offset + 2, getLength(data));
6144
- arraySet(rawExtraField, data, offset + 4);
6145
- offset += 4 + getLength(data);
6146
- });
6147
- }
6158
+ const rawExtraField = serializeExtraField(options[PROPERTY_NAME_EXTRA_FIELD]);
6159
+ const rawLocalExtraField = serializeExtraField(options[OPTION_LOCAL_EXTRA_FIELD]);
6148
6160
  return {
6149
6161
  comment,
6150
6162
  resolvedOptions: {
@@ -6178,11 +6190,36 @@
6178
6190
  useCompressionStream,
6179
6191
  dataDescriptor,
6180
6192
  zip64,
6181
- rawExtraField
6193
+ rawExtraField,
6194
+ rawLocalExtraField
6182
6195
  }
6183
6196
  };
6184
6197
  }
6185
6198
 
6199
+ function serializeExtraField(extraField) {
6200
+ if (!extraField) {
6201
+ return EMPTY_UINT8_ARRAY;
6202
+ }
6203
+ let extraFieldSize = 0;
6204
+ let offset = 0;
6205
+ extraField.forEach(data => extraFieldSize += 4 + getLength(data));
6206
+ const rawExtraField = new Uint8Array(extraFieldSize);
6207
+ const rawExtraFieldView = getDataView(rawExtraField);
6208
+ extraField.forEach((data, type) => {
6209
+ if (type > MAX_16_BITS) {
6210
+ throw new Error(ERR_INVALID_EXTRAFIELD_TYPE);
6211
+ }
6212
+ if (getLength(data) > MAX_16_BITS) {
6213
+ throw new Error(ERR_INVALID_EXTRAFIELD_DATA);
6214
+ }
6215
+ setUint16(rawExtraFieldView, offset, type);
6216
+ setUint16(rawExtraFieldView, offset + 2, getLength(data));
6217
+ arraySet(rawExtraField, data, offset + 4);
6218
+ offset += 4 + getLength(data);
6219
+ });
6220
+ return rawExtraField;
6221
+ }
6222
+
6186
6223
  async function resolveSizes(zipWriter, reader, { resolvedOptions: metadata }, options) {
6187
6224
  const { passThrough, zipCrypto, password, rawPassword, encryptionStrength } = metadata;
6188
6225
  let { dataDescriptor, zip64, level, compressionMethod } = metadata;
@@ -6507,12 +6544,9 @@
6507
6544
  msdosAttributes
6508
6545
  };
6509
6546
  let {
6510
- crc32: signature,
6547
+ crc32,
6511
6548
  uncompressedSize
6512
6549
  } = options;
6513
- if (signature === UNDEFINED_VALUE) {
6514
- ({ signature } = options);
6515
- }
6516
6550
  let compressedSize = 0;
6517
6551
  if (!passThrough) {
6518
6552
  uncompressedSize = 0;
@@ -6550,7 +6584,7 @@
6550
6584
  if (!passThrough) {
6551
6585
  uncompressedSize = result.inputSize;
6552
6586
  if (!encrypted || zipCrypto) {
6553
- signature = result.signature;
6587
+ crc32 = result.crc32;
6554
6588
  }
6555
6589
  }
6556
6590
  if ((!zip64CompressedSize && compressedSize >= MAX_32_BITS) ||
@@ -6566,7 +6600,7 @@
6566
6600
 
6567
6601
  }
6568
6602
  setEntryInfo({
6569
- signature,
6603
+ crc32,
6570
6604
  compressedSize,
6571
6605
  uncompressedSize,
6572
6606
  headerInfo,
@@ -6589,8 +6623,8 @@
6589
6623
  version,
6590
6624
  headerArray,
6591
6625
  headerView,
6592
- signature,
6593
- crc32: encrypted && !zipCrypto ? UNDEFINED_VALUE : signature,
6626
+ signature: crc32,
6627
+ crc32: encrypted && !zipCrypto && !passThrough ? UNDEFINED_VALUE : crc32,
6594
6628
  extraFieldExtendedTimestampFlag,
6595
6629
  zip64UncompressedSize,
6596
6630
  zip64CompressedSize
@@ -6611,6 +6645,7 @@
6611
6645
  dataDescriptor,
6612
6646
  directory,
6613
6647
  rawExtraField,
6648
+ rawLocalExtraField,
6614
6649
  encryptionStrength,
6615
6650
  extendedTimestamp,
6616
6651
  ntfsTimestamp,
@@ -6618,7 +6653,8 @@
6618
6653
  encrypted,
6619
6654
  zip64UncompressedSize,
6620
6655
  zip64CompressedSize,
6621
- uncompressedSize
6656
+ uncompressedSize,
6657
+ crc32
6622
6658
  } = options;
6623
6659
  let { version, compressionMethod } = options;
6624
6660
  const compressed = !directory && (compressionMethod === UNDEFINED_VALUE
@@ -6744,11 +6780,14 @@
6744
6780
  }
6745
6781
  if (encrypted && !zipCrypto) {
6746
6782
  version = version > VERSION_AES ? version : VERSION_AES;
6783
+ if (passThrough && crc32 !== UNDEFINED_VALUE) {
6784
+ rawExtraFieldAES[EXTRAFIELD_OFFSET_AES_VENDOR_VERSION] = VENDOR_VERSION_AE_1;
6785
+ }
6747
6786
  rawExtraFieldAES[9] = compressionMethod;
6748
6787
  compressionMethod = COMPRESSION_METHOD_AES;
6749
6788
  }
6750
6789
  const localExtraFieldZip64Length = writeLocalExtraFieldZip64 ? getLength(rawLocalExtraFieldZip64) : 0;
6751
- const extraFieldLength = localExtraFieldZip64Length + getLength(rawExtraFieldAES, rawExtraFieldExtendedTimestamp, rawExtraFieldNTFS, rawExtraFieldUnix, rawExtraField);
6790
+ const extraFieldLength = localExtraFieldZip64Length + getLength(rawExtraFieldAES, rawExtraFieldExtendedTimestamp, rawExtraFieldNTFS, rawExtraFieldUnix, rawExtraField, rawLocalExtraField);
6752
6791
  if (extraFieldLength > MAX_16_BITS) {
6753
6792
  throw new Error(ERR_INVALID_EXTRAFIELD_DATA);
6754
6793
  }
@@ -6782,6 +6821,7 @@
6782
6821
  localHeader.bytes(rawExtraFieldNTFS);
6783
6822
  localHeader.bytes(rawExtraFieldUnix);
6784
6823
  localHeader.bytes(rawExtraField);
6824
+ localHeader.bytes(rawLocalExtraField);
6785
6825
  if (dataDescriptor) {
6786
6826
  if (!zip64CompressedSize) {
6787
6827
  setUint32(localHeaderView, HEADER_OFFSET_COMPRESSED_SIZE + LOCAL_HEADER_COMMON_OFFSET, 0);
@@ -6900,7 +6940,7 @@
6900
6940
  }
6901
6941
 
6902
6942
  function setEntryInfo({
6903
- signature,
6943
+ crc32,
6904
6944
  compressedSize,
6905
6945
  uncompressedSize,
6906
6946
  headerInfo,
@@ -6908,6 +6948,7 @@
6908
6948
  }, {
6909
6949
  zip64,
6910
6950
  zipCrypto,
6951
+ passThrough,
6911
6952
  dataDescriptor
6912
6953
  }) {
6913
6954
  const {
@@ -6918,10 +6959,10 @@
6918
6959
  dataDescriptorView,
6919
6960
  dataDescriptorOffset
6920
6961
  } = dataDescriptorInfo;
6921
- if ((!encrypted || zipCrypto) && signature !== UNDEFINED_VALUE) {
6922
- setUint32(headerView, HEADER_OFFSET_SIGNATURE, signature);
6962
+ if ((!encrypted || zipCrypto || passThrough) && crc32 !== UNDEFINED_VALUE) {
6963
+ setUint32(headerView, HEADER_OFFSET_SIGNATURE, crc32);
6923
6964
  if (dataDescriptor) {
6924
- setUint32(dataDescriptorView, dataDescriptorOffset, signature);
6965
+ setUint32(dataDescriptorView, dataDescriptorOffset, crc32);
6925
6966
  }
6926
6967
  }
6927
6968
  if (zip64) {
@@ -6944,15 +6985,15 @@
6944
6985
  encrypted,
6945
6986
  zip64,
6946
6987
  localExtraFieldZip64Length,
6947
- signature,
6988
+ crc32,
6948
6989
  compressedSize,
6949
6990
  uncompressedSize,
6950
6991
  zip64UncompressedSize,
6951
6992
  zip64CompressedSize
6952
- }, localHeaderView, { dataDescriptor }) {
6993
+ }, localHeaderView, { dataDescriptor, passThrough }) {
6953
6994
  if (!dataDescriptor) {
6954
- if (!encrypted) {
6955
- setUint32(localHeaderView, HEADER_OFFSET_SIGNATURE + LOCAL_HEADER_COMMON_OFFSET, signature);
6995
+ if (!encrypted || (passThrough && crc32 !== UNDEFINED_VALUE)) {
6996
+ setUint32(localHeaderView, HEADER_OFFSET_SIGNATURE + LOCAL_HEADER_COMMON_OFFSET, crc32);
6956
6997
  }
6957
6998
  if (!zip64CompressedSize) {
6958
6999
  setUint32(localHeaderView, HEADER_OFFSET_COMPRESSED_SIZE + LOCAL_HEADER_COMMON_OFFSET, compressedSize);