Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

unzipit

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

unzipit - npm Package Compare versions

Comparing version 1.1.5 to 1.2.0

2

dist/unzipit-worker.js

@@ -1,2 +0,2 @@

/* unzipit@1.1.5, license MIT */
/* unzipit@1.2.0, license MIT */
(function (factory) {

@@ -3,0 +3,0 @@ typeof define === 'function' && define.amd ? define(factory) :

@@ -1,2 +0,2 @@

/* unzipit@1.1.5, license MIT */
/* unzipit@1.2.0, license MIT */
'use strict';(function(w){"function"===typeof define&&define.amd?define(w):w()})(function(){function w(a,b){var c=a.length;if(b<=c)return a;b=new Uint8Array(Math.max(c<<1,b));b.set(a,0);return b}function aa(a,b,c,k){for(var e=0,d=0,m=k.length>>>1;d<c;){var p=a[d+b];k[d<<1]=0;k[(d<<1)+1]=p;p>e&&(e=p);d++}for(;d<m;)k[d<<1]=0,k[(d<<1)+1]=0,d++;return e}function z(a,b){var e=a.length,k,g;var d=c.bl_count;for(g=0;g<=b;g++)d[g]=0;for(g=1;g<e;g+=2)d[a[g]]++;g=c.next_code;var m=0;d[0]=0;for(k=1;k<=b;k++)m=

@@ -3,0 +3,0 @@ m+d[k-1]<<1,g[k]=m;for(b=0;b<e;b+=2)d=a[b+1],0!=d&&(a[b]=g[d],g[d]++)}function A(a,b,e){for(var k=a.length,g=c.rev15,d=0;d<k;d+=2)if(0!=a[d+1]){var m=a[d+1],p=d>>1<<4|m,t=b-m;m=a[d]<<t;for(t=m+(1<<t);m!=t;)e[g[m]>>>15-b]=p,m++}}function C(a,b){for(var e=c.rev15,k=15-b,g=0;g<a.length;g+=2)a[g]=e[a[g]<<b-a[g+1]]>>>k}function x(a,b,c){return(a[b>>>3]|a[(b>>>3)+1]<<8)>>>(b&7)&(1<<c)-1}function N(a,b,c){return(a[b>>>3]|a[(b>>>3)+1]<<8|a[(b>>>3)+2]<<16)>>>(b&7)&(1<<c)-1}function O(a,b){return(a[b>>>3]|

@@ -1,2 +0,2 @@

/* unzipit@1.1.5, license MIT */
/* unzipit@1.2.0, license MIT */
function inflate(data, buf) {

@@ -3,0 +3,0 @@ var u8=Uint8Array;

@@ -1,2 +0,2 @@

/* unzipit@1.1.5, license MIT */
/* unzipit@1.2.0, license MIT */
(function (global, factory) {

@@ -811,2 +811,3 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :

// 12 - Size of central directory (bytes)
const centralDirectorySize = getUint32LE(eocdr, 12);
// 16 - Offset of start of central directory, relative to start of archive

@@ -829,3 +830,3 @@ const centralDirectoryOffset = getUint32LE(eocdr, 16);

} else {
return await readEntries(reader, centralDirectoryOffset, entryCount, comment, commentBytes);
return await readEntries(reader, centralDirectoryOffset, centralDirectorySize, entryCount, comment, commentBytes);
}

@@ -870,6 +871,7 @@ }

// 40 - size of the central directory 8 bytes
const centralDirectorySize = getUint64LE(zip64Eocdr, 40);
// 48 - offset of start of central directory with respect to the starting disk number 8 bytes
const centralDirectoryOffset = getUint64LE(zip64Eocdr, 48);
// 56 - zip64 extensible data sector (variable size)
return readEntries(reader, centralDirectoryOffset, entryCount, comment, commentBytes);
return readEntries(reader, centralDirectoryOffset, centralDirectorySize, entryCount, comment, commentBytes);
}

@@ -879,8 +881,9 @@

async function readEntries(reader, centralDirectoryOffset, entryCount, comment, commentBytes) {
let readEntryCursor = centralDirectoryOffset;
async function readEntries(reader, centralDirectoryOffset, centralDirectorySize, entryCount, comment, commentBytes) {
let readEntryCursor = 0;
const allEntriesBuffer = await readAs(reader, centralDirectoryOffset, centralDirectorySize);
const entries = [];
for (let e = 0; e < entryCount; ++e) {
const buffer = await readAs(reader, readEntryCursor, 46);
const buffer = allEntriesBuffer.subarray(readEntryCursor, readEntryCursor + 46);
// 0 - Central directory file header signature

@@ -931,3 +934,3 @@ const signature = getUint32LE(buffer, 0);

const data = await readAs(reader, readEntryCursor, entry.fileNameLength + entry.extraFieldLength + entry.fileCommentLength);
const data = allEntriesBuffer.subarray(readEntryCursor, readEntryCursor + entry.fileNameLength + entry.extraFieldLength + entry.fileCommentLength);
entry.nameBytes = data.slice(0, entry.fileNameLength);

@@ -934,0 +937,0 @@ entry.name = decodeBuffer(entry.nameBytes);

@@ -1,30 +0,30 @@

/* unzipit@1.1.5, license MIT */
'use strict';(function(w,A){"object"===typeof exports&&"undefined"!==typeof module?A(exports):"function"===typeof define&&define.amd?define(["exports"],A):(w=w||self,A(w.unzipit={}))})(this,function(w){function A(a){return a.arrayBuffer?a.arrayBuffer():new Promise((b,c)=>{const f=new FileReader;f.addEventListener("loadend",()=>{b(f.result)});f.addEventListener("error",c);f.readAsArrayBuffer(a)})}async function ea(a){a=await A(a);return new Uint8Array(a)}function R(a){return"undefined"!==typeof Blob&&
a instanceof Blob}function D(a){return"undefined"!==typeof SharedArrayBuffer&&a instanceof SharedArrayBuffer}function L(a,b){var c=a.length;if(b<=c)return a;b=new Uint8Array(Math.max(c<<1,b));b.set(a,0);return b}function fa(a,b,c,f,e,g){for(var d=S,n=T,k=0;k<c;){var r=a[n(f,e)&b];e+=r&15;var l=r>>>4;if(15>=l)g[k]=l,k++;else{var t=r=0;16==l?(t=3+d(f,e,2),e+=2,r=g[k-1]):17==l?(t=3+d(f,e,3),e+=3):18==l&&(t=11+d(f,e,7),e+=7);for(l=k+t;k<l;)g[k]=r,k++}}return e}function U(a,b,c,f){for(var e=0,g=0,d=f.length>>>
1;g<c;){var h=a[g+b];f[g<<1]=0;f[(g<<1)+1]=h;h>e&&(e=h);g++}for(;g<d;)f[g<<1]=0,f[(g<<1)+1]=0,g++;return e}function E(a,b){var c=a.length,f,e;var n=g.bl_count;for(e=0;e<=b;e++)n[e]=0;for(e=1;e<c;e+=2)n[a[e]]++;e=g.next_code;var d=0;n[0]=0;for(f=1;f<=b;f++)d=d+n[f-1]<<1,e[f]=d;for(b=0;b<c;b+=2)n=a[b+1],0!=n&&(a[b]=e[n],e[n]++)}function F(a,b,c){for(var f=a.length,e=g.rev15,n=0;n<f;n+=2)if(0!=a[n+1]){var d=a[n+1],h=n>>1<<4|d,k=b-d;d=a[n]<<k;for(k=d+(1<<k);d!=k;)c[e[d]>>>15-b]=h,d++}}function V(a,b){for(var c=
g.rev15,f=15-b,e=0;e<a.length;e+=2)a[e]=c[a[e]<<b-a[e+1]]>>>f}function S(a,b,c){return(a[b>>>3]|a[(b>>>3)+1]<<8)>>>(b&7)&(1<<c)-1}function ha(a,b,c){return(a[b>>>3]|a[(b>>>3)+1]<<8|a[(b>>>3)+2]<<16)>>>(b&7)&(1<<c)-1}function T(a,b){return(a[b>>>3]|a[(b>>>3)+1]<<8|a[(b>>>3)+2]<<16)>>>(b&7)}function ia(a){y.push(a.target);M();const {id:b,error:c,data:f}=a.data;a=H.get(b);H.delete(b);c?a.reject(c):a.resolve(f)}function N(a){return new Promise((b,c)=>{const f=new Worker(a);f.onmessage=a=>{"start"===a.data?
(f.onerror=void 0,f.onmessage=void 0,b(f)):c(Error(`unexpected message: ${a.data}`))};f.onerror=c})}async function ja(){if(0===y.length&&O<u.numWorkers){++O;try{const a=await P.createWorker(u.workerURL);I.push(a);y.push(a);P.addEventListener(a,ia)}catch(a){J=!1}}return y.pop()}async function M(){if(0!==B.length){if(u.useWorkers&&J){var a=await ja();if(J){if(a){if(0===B.length){y.push(a);M();return}const {id:b,src:c,uncompressedSize:d,type:f,resolve:e,reject:g}=B.shift();H.set(b,{id:b,resolve:e,reject:g});
a.postMessage({type:"inflate",data:{id:b,type:f,src:c,uncompressedSize:d}},[])}return}}for(;B.length;){const {src:r,uncompressedSize:u,type:y,resolve:A}=B.shift();a=r;R(r)&&(a=await ea(r));{var b=a;a=y;var c=A;const r=new Uint8Array(u);var f=void 0,e=void 0,n,d=r,h=Uint8Array;if(3==b[0]&&0==b[1])d||new h(0);else{var k=ha,l=S,t=fa,w=T,K=null==d;K&&(d=new h(b.length>>>2<<3));for(var W=0,z=0,v=n=0,m=0;0==W;){W=k(b,m,1);var q=k(b,m+1,2);m+=3;if(0==q)0!=(m&7)&&(m+=8-(m&7)),m=(m>>>3)+4,q=b[m-4]|b[m-3]<<
8,K&&(d=L(d,v+q)),d.set(new h(b.buffer,b.byteOffset+m,q),v),m=m+q<<3,v+=q;else{K&&(d=L(d,v+131072));1==q&&(e=g.flmap,f=g.fdmap,z=511,n=31);if(2==q){q=l(b,m,5)+257;n=l(b,m+5,5)+1;f=l(b,m+10,4)+4;m+=14;for(e=0;38>e;e+=2)g.itree[e]=0,g.itree[e+1]=0;z=1;for(e=0;e<f;e++){var p=l(b,m+3*e,3);g.itree[(g.ordr[e]<<1)+1]=p;p>z&&(z=p)}m+=3*f;E(g.itree,z);F(g.itree,z,g.imap);e=g.lmap;f=g.dmap;m=t(g.imap,(1<<z)-1,q+n,b,m,g.ttree);p=U(g.ttree,0,q,g.ltree);z=(1<<p)-1;q=U(g.ttree,q,n,g.dtree);n=(1<<q)-1;E(g.ltree,
p);F(g.ltree,p,e);E(g.dtree,q);F(g.dtree,q,f)}for(;;)if(q=e[w(b,m)&z],m+=q&15,p=q>>>4,0==p>>>8)d[v++]=p;else if(256==p)break;else{q=v+p-254;264<p&&(p=g.ldef[p-257],q=v+(p>>>3)+l(b,m,p&7),m+=p&7);p=f[w(b,m)&n];m+=p&15;p=g.ddef[p>>>4];var x=(p>>>4)+k(b,m,p&15);m+=p&15;for(K&&(d=L(d,v+131072));v<q;)d[v]=d[v++-x],d[v]=d[v++-x],d[v]=d[v++-x],d[v]=d[v++-x];v=q}}}d.length==v||d.slice(0,v)}c(a?new Blob([r],{type:a}):r.buffer)}}}}function X(a,b,c){return new Promise((f,e)=>{B.push({src:a,uncompressedSize:b,
type:c,resolve:f,reject:e,id:ka++});M()})}async function la(){for(const a of I)await P.terminate(a);I.splice(0,I.length);y.splice(0,y.length);B.splice(0,B.length);H.clear();O=0;J=!0}async function x(a,b,c){return await a.read(b,c)}async function Q(a,b,c,f){return a.sliceAsBlob?await a.sliceAsBlob(b,c,f):await a.read(b,c)}function l(a,b){return a[b]+256*a[b+1]}function t(a,b){return a[b]+256*a[b+1]+65536*a[b+2]+16777216*a[b+3]}function C(a,b){return t(a,b)+4294967296*t(a,b+4)}function G(a,b){D(a.buffer)&&
(a=new Uint8Array(a));return ma.decode(a)}async function na(a,b){var c=Math.min(65557,b);b-=c;var f=await x(a,b,c);for(c-=22;0<=c;--c){if(101010256!==t(f,c))continue;var e=new Uint8Array(f.buffer,f.byteOffset+c,f.byteLength-c);f=l(e,4);if(0!==f)throw Error(`multi-volume zip files are not supported. This is volume: ${f}`);f=l(e,10);const d=t(e,16);var g=l(e,20);const h=e.length-22;if(g!==h)throw Error(`invalid comment length. expected: ${h}, actual: ${g}`);e=new Uint8Array(e.buffer,e.byteOffset+22,
g);g=G(e);return 65535===f||4294967295===d?await oa(a,b+c,g,e):await Y(a,d,f,g,e)}throw Error("could not find end of central directory. maybe not zip file");}async function oa(a,b,c,f){b=await x(a,b-20,20);if(117853008!==t(b,0))throw Error("invalid zip64 end of central directory locator signature");b=C(b,8);var e=x(a,b,56);if(101010256!==t(e,0))throw Error("invalid zip64 end of central directory record signature");b=C(e,32);e=C(e,48);return Y(a,e,b,c,f)}async function Y(a,b,c,f,e){const g=[];for(let f=
0;f<c;++f){var d=await x(a,b,46),h=t(d,0);if(33639248!==h)throw Error(`invalid central directory file header signature: 0x${h.toString(16)}`);d={versionMadeBy:l(d,4),versionNeededToExtract:l(d,6),generalPurposeBitFlag:l(d,8),compressionMethod:l(d,10),lastModFileTime:l(d,12),lastModFileDate:l(d,14),crc32:t(d,16),compressedSize:t(d,20),uncompressedSize:t(d,24),fileNameLength:l(d,28),extraFieldLength:l(d,30),fileCommentLength:l(d,32),internalFileAttributes:l(d,36),externalFileAttributes:t(d,38),relativeOffsetOfLocalHeader:t(d,
42)};if(d.generalPurposeBitFlag&64)throw Error("strong encryption is not supported");b+=46;h=await x(a,b,d.fileNameLength+d.extraFieldLength+d.fileCommentLength);d.nameBytes=h.slice(0,d.fileNameLength);d.name=G(d.nameBytes);var k=d.fileNameLength+d.extraFieldLength;const c=h.slice(d.fileNameLength,k);d.extraFields=[];for(var r=0;r<c.length-3;){const a=l(c,r+0);var u=l(c,r+2);r+=4;u=r+u;if(u>c.length)throw Error("extra field length exceeds extra field buffer size");d.extraFields.push({id:a,data:c.slice(r,
u)});r=u}d.commentBytes=h.slice(k,k+d.fileCommentLength);d.comment=G(d.commentBytes);b+=h.length;if(4294967295===d.uncompressedSize||4294967295===d.compressedSize||4294967295===d.relativeOffsetOfLocalHeader){h=d.extraFields.find(a=>1===a.id);if(!h)return Error("expected zip64 extended information extra field");h=h.data;k=0;if(4294967295===d.uncompressedSize){if(k+8>h.length)throw Error("zip64 extended information extra field does not include uncompressed size");d.uncompressedSize=C(h,k);k+=8}if(4294967295===
d.compressedSize){if(k+8>h.length)throw Error("zip64 extended information extra field does not include compressed size");d.compressedSize=C(h,k);k+=8}if(4294967295===d.relativeOffsetOfLocalHeader){if(k+8>h.length)throw Error("zip64 extended information extra field does not include relative header offset");d.relativeOffsetOfLocalHeader=C(h,k);k+=8}}if(h=d.extraFields.find(a=>28789===a.id&&6<=a.data.length&&1===a.data[0]&&t(a.data,1),pa.unsigned(d.nameBytes)))d.fileName=G(h.data.slice(5));if(0===d.compressionMethod&&
(h=d.uncompressedSize,0!==(d.generalPurposeBitFlag&1)&&(h+=12),d.compressedSize!==h))throw Error(`compressed/uncompressed size mismatch for stored file: ${d.compressedSize} != ${d.uncompressedSize}`);g.push(d)}return{zip:{comment:f,commentBytes:e},entries:g.map(b=>new qa(a,b))}}async function Z(a,b){var c=await x(a,b.relativeOffsetOfLocalHeader,30);a=await a.getLength();var f=t(c,0);if(67324752!==f)throw Error(`invalid local file header signature: 0x${f.toString(16)}`);f=l(c,26);var e=l(c,28);c=b.relativeOffsetOfLocalHeader+
c.length+f+e;if(0===b.compressionMethod)f=!1;else if(8===b.compressionMethod)f=!0;else throw Error(`unsupported compression method: ${b.compressionMethod}`);e=c+b.compressedSize;if(0!==b.compressedSize&&e>a)throw Error(`file data overflows file bounds: ${c} + ${b.compressedSize} > ${a}`);return{decompress:f,fileDataStart:c}}async function ra(a,b){const {decompress:c,fileDataStart:f}=await Z(a,b);if(!c)return b=await x(a,f,b.compressedSize),0===b.byteOffset&&b.byteLength===b.buffer.byteLength?b.buffer:
b.slice().buffer;a=await Q(a,f,b.compressedSize);return await X(a,b.uncompressedSize)}async function sa(a,b,c){const {decompress:f,fileDataStart:e}=await Z(a,b);if(!f)return b=await Q(a,e,b.compressedSize,c),R(b)?b:new Blob([D(b.buffer)?new Uint8Array(b):b],{type:c});a=await Q(a,e,b.compressedSize);return await X(a,b.uncompressedSize,c)}async function aa(a){if("undefined"!==typeof Blob&&a instanceof Blob)a=new ba(a);else if(a instanceof ArrayBuffer||a&&a.buffer&&a.buffer instanceof ArrayBuffer)a=
new ca(a);else if(D(a)||D(a.buffer))a=new ca(a);else if("string"===typeof a)a=await (await fetch(a)).blob(),a=new ba(a);else if("function"!==typeof a.getLength||"function"!==typeof a.read)throw Error("unsupported source type");const b=await a.getLength();if(b>Number.MAX_SAFE_INTEGER)throw Error(`file too large. size: ${b}. Only file sizes up 4503599627370496 bytes are supported`);return await na(a,b)}const ta="undefined"!==typeof process&&process.versions&&"undefined"!==typeof process.versions.node&&
"undefined"===typeof process.versions.electron;class ca{constructor(a){this.typedArray=a instanceof ArrayBuffer||D(a)?new Uint8Array(a):new Uint8Array(a.buffer,a.byteOffset,a.byteLength)}async getLength(){return this.typedArray.byteLength}async read(a,b){return new Uint8Array(this.typedArray.buffer,this.typedArray.byteOffset+a,b)}}class ba{constructor(a){this.blob=a}async getLength(){return this.blob.size}async read(a,b){a=this.blob.slice(a,a+b);a=await A(a);return new Uint8Array(a)}async sliceAsBlob(a,
b,c=""){return this.blob.slice(a,a+b,c)}}class ua{constructor(a){this.url=a}async getLength(){if(void 0===this.length){const a=await fetch(this.url,{method:"HEAD"});this.length=parseInt(a.headers.get("content-length"));if(Number.isNaN(this.length))throw Error("could not get length");}return this.length}async read(a,b){a=await (await fetch(this.url,{headers:{Range:`bytes=${a}-${a+b-1}`}})).arrayBuffer();return new Uint8Array(a)}}const g=function(){var a=Uint16Array,b=Uint32Array;return{next_code:new a(16),
bl_count:new a(16),ordr:[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],of0:[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,999,999,999],exb:[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0],ldef:new a(32),df0:[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,65535,65535],dxb:[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0],ddef:new b(32),flmap:new a(512),
fltree:[],fdmap:new a(32),fdtree:[],lmap:new a(32768),ltree:[],ttree:[],dmap:new a(32768),dtree:[],imap:new a(512),itree:[],rev15:new a(32768),lhst:new b(286),dhst:new b(30),ihst:new b(19),lits:new b(15E3),strt:new a(65536),prev:new a(32768)}}();(function(){function a(a,b,c){for(;0!=b--;)a.push(0,c)}for(var b=0;32768>b;b++){var c=b;c=(c&2863311530)>>>1|(c&1431655765)<<1;c=(c&3435973836)>>>2|(c&858993459)<<2;c=(c&4042322160)>>>4|(c&252645135)<<4;c=(c&4278255360)>>>8|(c&16711935)<<8;g.rev15[b]=(c>>>
16|c<<16)>>>17}for(b=0;32>b;b++)g.ldef[b]=g.of0[b]<<3|g.exb[b],g.ddef[b]=g.df0[b]<<4|g.dxb[b];a(g.fltree,144,8);a(g.fltree,112,9);a(g.fltree,24,7);a(g.fltree,8,8);E(g.fltree,9);F(g.fltree,9,g.flmap);V(g.fltree,9);a(g.fdtree,32,5);E(g.fdtree,5);F(g.fdtree,5,g.fdmap);V(g.fdtree,5);a(g.itree,19,0);a(g.ltree,286,0);a(g.dtree,30,0);a(g.ttree,320,0)})();const da={table:function(){for(var a=new Uint32Array(256),b=0;256>b;b++){for(var c=b,f=0;8>f;f++)c=c&1?3988292384^c>>>1:c>>>1;a[b]=c}return a}(),update:function(a,
b,c,f){for(var e=0;e<f;e++)a=da.table[(a^b[c+e])&255]^a>>>8;return a},crc:function(a,b,c){return da.update(4294967295,a,b,c)^4294967295}},u={numWorkers:1,workerURL:"",useWorkers:!1};let ka=0,O=0,J=!0;const I=[],y=[],B=[],H=new Map,P=function(){if(ta){const {Worker:a}=module.require("worker_threads");return{async createWorker(b){return new a(b)},addEventListener(a,c){a.on("message",b=>{c({target:a,data:b})})},async terminate(a){await a.terminate()}}}return{async createWorker(a){try{return await N(a)}catch(c){console.warn("could not load worker:",
a)}let b;try{b=await (await fetch(a,{mode:"cors"})).text();a=URL.createObjectURL(new Blob([b],{type:"application/javascript"}));const c=await N(a);u.workerURL=a;return c}catch(c){console.warn("could not load worker via fetch:",a)}if(void 0!==b)try{a=`data:application/javascript;base64,${btoa(b)}`;const c=await N(a);u.workerURL=a;return c}catch(c){console.warn("could not load worker via dataURI")}console.warn("workers will not be used");throw Error("can not start workers");},addEventListener(a,b){a.addEventListener("message",
b)},async terminate(a){a.terminate()}}}();class qa{constructor(a,b){this._reader=a;this._entry=b;this.name=b.name;this.nameBytes=b.nameBytes;this.size=b.uncompressedSize;this.compressedSize=b.compressedSize;this.comment=b.comment;this.commentBytes=b.commentBytes;this.compressionMethod=b.compressionMethod;a=b.lastModFileDate;var c=b.lastModFileTime;this.lastModDate=new Date((a>>9&127)+1980,(a>>5&15)-1,a&31,c>>11&31,c>>5&63,2*(c&31),0);this.isDirectory=0===b.uncompressedSize&&b.name.endsWith("/")}async blob(a=
"application/octet-stream"){return await sa(this._reader,this._entry,a)}async arrayBuffer(){return await ra(this._reader,this._entry)}async text(){const a=await this.arrayBuffer();return G(new Uint8Array(a))}async json(){const a=await this.text();return JSON.parse(a)}}const pa={unsigned(){return 0}},ma=new TextDecoder;w.HTTPRangeReader=ua;w.cleanup=function(){la()};w.setOptions=function(a){u.workerURL=a.workerURL||u.workerURL;a.workerURL&&(u.useWorkers=!0);u.useWorkers=void 0!==a.useWorkers?a.useWorkers:
u.useWorkers;u.numWorkers=a.numWorkers||u.numWorkers};w.unzip=async function(a){const {zip:b,entries:c}=await aa(a);return{zip:b,entries:Object.fromEntries(c.map(a=>[a.name,a]))}};w.unzipRaw=aa;Object.defineProperty(w,"__esModule",{value:!0})});
/* unzipit@1.2.0, license MIT */
'use strict';(function(v,B){"object"===typeof exports&&"undefined"!==typeof module?B(exports):"function"===typeof define&&define.amd?define(["exports"],B):(v=v||self,B(v.unzipit={}))})(this,function(v){function B(a){return a.arrayBuffer?a.arrayBuffer():new Promise((b,c)=>{const e=new FileReader;e.addEventListener("loadend",()=>{b(e.result)});e.addEventListener("error",c);e.readAsArrayBuffer(a)})}async function ea(a){a=await B(a);return new Uint8Array(a)}function R(a){return"undefined"!==typeof Blob&&
a instanceof Blob}function D(a){return"undefined"!==typeof SharedArrayBuffer&&a instanceof SharedArrayBuffer}function L(a,b){var c=a.length;if(b<=c)return a;b=new Uint8Array(Math.max(c<<1,b));b.set(a,0);return b}function fa(a,b,c,e,d,f){for(var k=S,g=T,h=0;h<c;){var n=a[g(e,d)&b];d+=n&15;var l=n>>>4;if(15>=l)f[h]=l,h++;else{var t=n=0;16==l?(t=3+k(e,d,2),d+=2,n=f[h-1]):17==l?(t=3+k(e,d,3),d+=3):18==l&&(t=11+k(e,d,7),d+=7);for(l=h+t;h<l;)f[h]=n,h++}}return d}function U(a,b,c,e){for(var d=0,f=0,k=e.length>>>
1;f<c;){var g=a[f+b];e[f<<1]=0;e[(f<<1)+1]=g;g>d&&(d=g);f++}for(;f<k;)e[f<<1]=0,e[(f<<1)+1]=0,f++;return d}function E(a,b){var c=a.length,e,d;var h=f.bl_count;for(d=0;d<=b;d++)h[d]=0;for(d=1;d<c;d+=2)h[a[d]]++;d=f.next_code;var k=0;h[0]=0;for(e=1;e<=b;e++)k=k+h[e-1]<<1,d[e]=k;for(b=0;b<c;b+=2)h=a[b+1],0!=h&&(a[b]=d[h],d[h]++)}function F(a,b,c){for(var e=a.length,d=f.rev15,h=0;h<e;h+=2)if(0!=a[h+1]){var k=a[h+1],g=h>>1<<4|k,z=b-k;k=a[h]<<z;for(z=k+(1<<z);k!=z;)c[d[k]>>>15-b]=g,k++}}function V(a,b){for(var c=
f.rev15,e=15-b,d=0;d<a.length;d+=2)a[d]=c[a[d]<<b-a[d+1]]>>>e}function S(a,b,c){return(a[b>>>3]|a[(b>>>3)+1]<<8)>>>(b&7)&(1<<c)-1}function ia(a,b,c){return(a[b>>>3]|a[(b>>>3)+1]<<8|a[(b>>>3)+2]<<16)>>>(b&7)&(1<<c)-1}function T(a,b){return(a[b>>>3]|a[(b>>>3)+1]<<8|a[(b>>>3)+2]<<16)>>>(b&7)}function ja(a){x.push(a.target);M();const {id:b,error:c,data:e}=a.data;a=H.get(b);H.delete(b);c?a.reject(c):a.resolve(e)}function N(a){return new Promise((b,c)=>{const e=new Worker(a);e.onmessage=a=>{"start"===a.data?
(e.onerror=void 0,e.onmessage=void 0,b(e)):c(Error(`unexpected message: ${a.data}`))};e.onerror=c})}async function ka(){if(0===x.length&&O<r.numWorkers){++O;try{const a=await P.createWorker(r.workerURL);I.push(a);x.push(a);P.addEventListener(a,ja)}catch(a){J=!1}}return x.pop()}async function M(){if(0!==A.length){if(r.useWorkers&&J){var a=await ka();if(J){if(a){if(0===A.length){x.push(a);M();return}const {id:b,src:c,uncompressedSize:d,type:e,resolve:g,reject:f}=A.shift();H.set(b,{id:b,resolve:g,reject:f});
a.postMessage({type:"inflate",data:{id:b,type:e,src:c,uncompressedSize:d}},[])}return}}for(;A.length;){const {src:n,uncompressedSize:r,type:ha,resolve:x}=A.shift();a=n;R(n)&&(a=await ea(n));{var b=a;a=ha;var c=x;const n=new Uint8Array(r);var e=void 0,d=void 0,h,k=n,g=Uint8Array;if(3==b[0]&&0==b[1])k||new g(0);else{var z=ia,l=S,t=fa,v=T,K=null==k;K&&(k=new g(b.length>>>2<<3));for(var W=0,y=0,u=h=0,m=0;0==W;){W=z(b,m,1);var q=z(b,m+1,2);m+=3;if(0==q)0!=(m&7)&&(m+=8-(m&7)),m=(m>>>3)+4,q=b[m-4]|b[m-3]<<
8,K&&(k=L(k,u+q)),k.set(new g(b.buffer,b.byteOffset+m,q),u),m=m+q<<3,u+=q;else{K&&(k=L(k,u+131072));1==q&&(d=f.flmap,e=f.fdmap,y=511,h=31);if(2==q){q=l(b,m,5)+257;h=l(b,m+5,5)+1;e=l(b,m+10,4)+4;m+=14;for(d=0;38>d;d+=2)f.itree[d]=0,f.itree[d+1]=0;y=1;for(d=0;d<e;d++){var p=l(b,m+3*d,3);f.itree[(f.ordr[d]<<1)+1]=p;p>y&&(y=p)}m+=3*e;E(f.itree,y);F(f.itree,y,f.imap);d=f.lmap;e=f.dmap;m=t(f.imap,(1<<y)-1,q+h,b,m,f.ttree);p=U(f.ttree,0,q,f.ltree);y=(1<<p)-1;q=U(f.ttree,q,h,f.dtree);h=(1<<q)-1;E(f.ltree,
p);F(f.ltree,p,d);E(f.dtree,q);F(f.dtree,q,e)}for(;;)if(q=d[v(b,m)&y],m+=q&15,p=q>>>4,0==p>>>8)k[u++]=p;else if(256==p)break;else{q=u+p-254;264<p&&(p=f.ldef[p-257],q=u+(p>>>3)+l(b,m,p&7),m+=p&7);p=e[v(b,m)&h];m+=p&15;p=f.ddef[p>>>4];var w=(p>>>4)+z(b,m,p&15);m+=p&15;for(K&&(k=L(k,u+131072));u<q;)k[u]=k[u++-w],k[u]=k[u++-w],k[u]=k[u++-w],k[u]=k[u++-w];u=q}}}k.length==u||k.slice(0,u)}c(a?new Blob([n],{type:a}):n.buffer)}}}}function X(a,b,c){return new Promise((e,d)=>{A.push({src:a,uncompressedSize:b,
type:c,resolve:e,reject:d,id:la++});M()})}async function ma(){for(const a of I)await P.terminate(a);I.splice(0,I.length);x.splice(0,x.length);A.splice(0,A.length);H.clear();O=0;J=!0}async function C(a,b,c){return await a.read(b,c)}async function Q(a,b,c,e){return a.sliceAsBlob?await a.sliceAsBlob(b,c,e):await a.read(b,c)}function l(a,b){return a[b]+256*a[b+1]}function t(a,b){return a[b]+256*a[b+1]+65536*a[b+2]+16777216*a[b+3]}function w(a,b){return t(a,b)+4294967296*t(a,b+4)}function G(a,b){D(a.buffer)&&
(a=new Uint8Array(a));return na.decode(a)}async function oa(a,b){var c=Math.min(65557,b);b-=c;var e=await C(a,b,c);for(c-=22;0<=c;--c){if(101010256!==t(e,c))continue;var d=new Uint8Array(e.buffer,e.byteOffset+c,e.byteLength-c);e=l(d,4);if(0!==e)throw Error(`multi-volume zip files are not supported. This is volume: ${e}`);e=l(d,10);const k=t(d,12),g=t(d,16);var f=l(d,20);const h=d.length-22;if(f!==h)throw Error(`invalid comment length. expected: ${h}, actual: ${f}`);d=new Uint8Array(d.buffer,d.byteOffset+
22,f);f=G(d);return 65535===e||4294967295===g?await pa(a,b+c,f,d):await Y(a,g,k,e,f,d)}throw Error("could not find end of central directory. maybe not zip file");}async function pa(a,b,c,e){b=await C(a,b-20,20);if(117853008!==t(b,0))throw Error("invalid zip64 end of central directory locator signature");b=w(b,8);var d=C(a,b,56);if(101010256!==t(d,0))throw Error("invalid zip64 end of central directory record signature");b=w(d,32);const f=w(d,40);d=w(d,48);return Y(a,d,f,b,c,e)}async function Y(a,b,
c,e,d,f){let k=0;b=await C(a,b,c);c=[];for(let a=0;a<e;++a){var g=b.subarray(k,k+46),h=t(g,0);if(33639248!==h)throw Error(`invalid central directory file header signature: 0x${h.toString(16)}`);g={versionMadeBy:l(g,4),versionNeededToExtract:l(g,6),generalPurposeBitFlag:l(g,8),compressionMethod:l(g,10),lastModFileTime:l(g,12),lastModFileDate:l(g,14),crc32:t(g,16),compressedSize:t(g,20),uncompressedSize:t(g,24),fileNameLength:l(g,28),extraFieldLength:l(g,30),fileCommentLength:l(g,32),internalFileAttributes:l(g,
36),externalFileAttributes:t(g,38),relativeOffsetOfLocalHeader:t(g,42)};if(g.generalPurposeBitFlag&64)throw Error("strong encryption is not supported");k+=46;h=b.subarray(k,k+g.fileNameLength+g.extraFieldLength+g.fileCommentLength);g.nameBytes=h.slice(0,g.fileNameLength);g.name=G(g.nameBytes);var n=g.fileNameLength+g.extraFieldLength;const a=h.slice(g.fileNameLength,n);g.extraFields=[];for(var r=0;r<a.length-3;){const b=l(a,r+0);var v=l(a,r+2);r+=4;v=r+v;if(v>a.length)throw Error("extra field length exceeds extra field buffer size");
g.extraFields.push({id:b,data:a.slice(r,v)});r=v}g.commentBytes=h.slice(n,n+g.fileCommentLength);g.comment=G(g.commentBytes);k+=h.length;if(4294967295===g.uncompressedSize||4294967295===g.compressedSize||4294967295===g.relativeOffsetOfLocalHeader){h=g.extraFields.find(a=>1===a.id);if(!h)return Error("expected zip64 extended information extra field");h=h.data;n=0;if(4294967295===g.uncompressedSize){if(n+8>h.length)throw Error("zip64 extended information extra field does not include uncompressed size");
g.uncompressedSize=w(h,n);n+=8}if(4294967295===g.compressedSize){if(n+8>h.length)throw Error("zip64 extended information extra field does not include compressed size");g.compressedSize=w(h,n);n+=8}if(4294967295===g.relativeOffsetOfLocalHeader){if(n+8>h.length)throw Error("zip64 extended information extra field does not include relative header offset");g.relativeOffsetOfLocalHeader=w(h,n);n+=8}}if(h=g.extraFields.find(a=>28789===a.id&&6<=a.data.length&&1===a.data[0]&&t(a.data,1),qa.unsigned(g.nameBytes)))g.fileName=
G(h.data.slice(5));if(0===g.compressionMethod&&(h=g.uncompressedSize,0!==(g.generalPurposeBitFlag&1)&&(h+=12),g.compressedSize!==h))throw Error(`compressed/uncompressed size mismatch for stored file: ${g.compressedSize} != ${g.uncompressedSize}`);c.push(g)}return{zip:{comment:d,commentBytes:f},entries:c.map(b=>new ra(a,b))}}async function Z(a,b){var c=await C(a,b.relativeOffsetOfLocalHeader,30);a=await a.getLength();var e=t(c,0);if(67324752!==e)throw Error(`invalid local file header signature: 0x${e.toString(16)}`);
e=l(c,26);var d=l(c,28);c=b.relativeOffsetOfLocalHeader+c.length+e+d;if(0===b.compressionMethod)e=!1;else if(8===b.compressionMethod)e=!0;else throw Error(`unsupported compression method: ${b.compressionMethod}`);d=c+b.compressedSize;if(0!==b.compressedSize&&d>a)throw Error(`file data overflows file bounds: ${c} + ${b.compressedSize} > ${a}`);return{decompress:e,fileDataStart:c}}async function sa(a,b){const {decompress:c,fileDataStart:e}=await Z(a,b);if(!c)return b=await C(a,e,b.compressedSize),
0===b.byteOffset&&b.byteLength===b.buffer.byteLength?b.buffer:b.slice().buffer;a=await Q(a,e,b.compressedSize);return await X(a,b.uncompressedSize)}async function ta(a,b,c){const {decompress:e,fileDataStart:d}=await Z(a,b);if(!e)return b=await Q(a,d,b.compressedSize,c),R(b)?b:new Blob([D(b.buffer)?new Uint8Array(b):b],{type:c});a=await Q(a,d,b.compressedSize);return await X(a,b.uncompressedSize,c)}async function aa(a){if("undefined"!==typeof Blob&&a instanceof Blob)a=new ba(a);else if(a instanceof
ArrayBuffer||a&&a.buffer&&a.buffer instanceof ArrayBuffer)a=new ca(a);else if(D(a)||D(a.buffer))a=new ca(a);else if("string"===typeof a)a=await (await fetch(a)).blob(),a=new ba(a);else if("function"!==typeof a.getLength||"function"!==typeof a.read)throw Error("unsupported source type");const b=await a.getLength();if(b>Number.MAX_SAFE_INTEGER)throw Error(`file too large. size: ${b}. Only file sizes up 4503599627370496 bytes are supported`);return await oa(a,b)}const ua="undefined"!==typeof process&&
process.versions&&"undefined"!==typeof process.versions.node&&"undefined"===typeof process.versions.electron;class ca{constructor(a){this.typedArray=a instanceof ArrayBuffer||D(a)?new Uint8Array(a):new Uint8Array(a.buffer,a.byteOffset,a.byteLength)}async getLength(){return this.typedArray.byteLength}async read(a,b){return new Uint8Array(this.typedArray.buffer,this.typedArray.byteOffset+a,b)}}class ba{constructor(a){this.blob=a}async getLength(){return this.blob.size}async read(a,b){a=this.blob.slice(a,
a+b);a=await B(a);return new Uint8Array(a)}async sliceAsBlob(a,b,c=""){return this.blob.slice(a,a+b,c)}}class va{constructor(a){this.url=a}async getLength(){if(void 0===this.length){const a=await fetch(this.url,{method:"HEAD"});this.length=parseInt(a.headers.get("content-length"));if(Number.isNaN(this.length))throw Error("could not get length");}return this.length}async read(a,b){a=await (await fetch(this.url,{headers:{Range:`bytes=${a}-${a+b-1}`}})).arrayBuffer();return new Uint8Array(a)}}const f=
function(){var a=Uint16Array,b=Uint32Array;return{next_code:new a(16),bl_count:new a(16),ordr:[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],of0:[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,999,999,999],exb:[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0],ldef:new a(32),df0:[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,65535,65535],dxb:[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,
7,8,8,9,9,10,10,11,11,12,12,13,13,0,0],ddef:new b(32),flmap:new a(512),fltree:[],fdmap:new a(32),fdtree:[],lmap:new a(32768),ltree:[],ttree:[],dmap:new a(32768),dtree:[],imap:new a(512),itree:[],rev15:new a(32768),lhst:new b(286),dhst:new b(30),ihst:new b(19),lits:new b(15E3),strt:new a(65536),prev:new a(32768)}}();(function(){function a(a,b,c){for(;0!=b--;)a.push(0,c)}for(var b=0;32768>b;b++){var c=b;c=(c&2863311530)>>>1|(c&1431655765)<<1;c=(c&3435973836)>>>2|(c&858993459)<<2;c=(c&4042322160)>>>
4|(c&252645135)<<4;c=(c&4278255360)>>>8|(c&16711935)<<8;f.rev15[b]=(c>>>16|c<<16)>>>17}for(b=0;32>b;b++)f.ldef[b]=f.of0[b]<<3|f.exb[b],f.ddef[b]=f.df0[b]<<4|f.dxb[b];a(f.fltree,144,8);a(f.fltree,112,9);a(f.fltree,24,7);a(f.fltree,8,8);E(f.fltree,9);F(f.fltree,9,f.flmap);V(f.fltree,9);a(f.fdtree,32,5);E(f.fdtree,5);F(f.fdtree,5,f.fdmap);V(f.fdtree,5);a(f.itree,19,0);a(f.ltree,286,0);a(f.dtree,30,0);a(f.ttree,320,0)})();const da={table:function(){for(var a=new Uint32Array(256),b=0;256>b;b++){for(var c=
b,e=0;8>e;e++)c=c&1?3988292384^c>>>1:c>>>1;a[b]=c}return a}(),update:function(a,b,c,e){for(var d=0;d<e;d++)a=da.table[(a^b[c+d])&255]^a>>>8;return a},crc:function(a,b,c){return da.update(4294967295,a,b,c)^4294967295}},r={numWorkers:1,workerURL:"",useWorkers:!1};let la=0,O=0,J=!0;const I=[],x=[],A=[],H=new Map,P=function(){if(ua){const {Worker:a}=module.require("worker_threads");return{async createWorker(b){return new a(b)},addEventListener(a,c){a.on("message",b=>{c({target:a,data:b})})},async terminate(a){await a.terminate()}}}return{async createWorker(a){try{return await N(a)}catch(c){console.warn("could not load worker:",
a)}let b;try{b=await (await fetch(a,{mode:"cors"})).text();a=URL.createObjectURL(new Blob([b],{type:"application/javascript"}));const c=await N(a);r.workerURL=a;return c}catch(c){console.warn("could not load worker via fetch:",a)}if(void 0!==b)try{a=`data:application/javascript;base64,${btoa(b)}`;const c=await N(a);r.workerURL=a;return c}catch(c){console.warn("could not load worker via dataURI")}console.warn("workers will not be used");throw Error("can not start workers");},addEventListener(a,b){a.addEventListener("message",
b)},async terminate(a){a.terminate()}}}();class ra{constructor(a,b){this._reader=a;this._entry=b;this.name=b.name;this.nameBytes=b.nameBytes;this.size=b.uncompressedSize;this.compressedSize=b.compressedSize;this.comment=b.comment;this.commentBytes=b.commentBytes;this.compressionMethod=b.compressionMethod;a=b.lastModFileDate;var c=b.lastModFileTime;this.lastModDate=new Date((a>>9&127)+1980,(a>>5&15)-1,a&31,c>>11&31,c>>5&63,2*(c&31),0);this.isDirectory=0===b.uncompressedSize&&b.name.endsWith("/")}async blob(a=
"application/octet-stream"){return await ta(this._reader,this._entry,a)}async arrayBuffer(){return await sa(this._reader,this._entry)}async text(){const a=await this.arrayBuffer();return G(new Uint8Array(a))}async json(){const a=await this.text();return JSON.parse(a)}}const qa={unsigned(){return 0}},na=new TextDecoder;v.HTTPRangeReader=va;v.cleanup=function(){ma()};v.setOptions=function(a){r.workerURL=a.workerURL||r.workerURL;a.workerURL&&(r.useWorkers=!0);r.useWorkers=void 0!==a.useWorkers?a.useWorkers:
r.useWorkers;r.numWorkers=a.numWorkers||r.numWorkers};v.unzip=async function(a){const {zip:b,entries:c}=await aa(a);return{zip:b,entries:Object.fromEntries(c.map(a=>[a.name,a]))}};v.unzipRaw=aa;Object.defineProperty(v,"__esModule",{value:!0})});

@@ -1,2 +0,2 @@

/* unzipit@1.1.5, license MIT */
/* unzipit@1.2.0, license MIT */
/* global SharedArrayBuffer, process */

@@ -805,2 +805,3 @@

// 12 - Size of central directory (bytes)
const centralDirectorySize = getUint32LE(eocdr, 12);
// 16 - Offset of start of central directory, relative to start of archive

@@ -823,3 +824,3 @@ const centralDirectoryOffset = getUint32LE(eocdr, 16);

} else {
return await readEntries(reader, centralDirectoryOffset, entryCount, comment, commentBytes);
return await readEntries(reader, centralDirectoryOffset, centralDirectorySize, entryCount, comment, commentBytes);
}

@@ -864,6 +865,7 @@ }

// 40 - size of the central directory 8 bytes
const centralDirectorySize = getUint64LE(zip64Eocdr, 40);
// 48 - offset of start of central directory with respect to the starting disk number 8 bytes
const centralDirectoryOffset = getUint64LE(zip64Eocdr, 48);
// 56 - zip64 extensible data sector (variable size)
return readEntries(reader, centralDirectoryOffset, entryCount, comment, commentBytes);
return readEntries(reader, centralDirectoryOffset, centralDirectorySize, entryCount, comment, commentBytes);
}

@@ -873,8 +875,9 @@

async function readEntries(reader, centralDirectoryOffset, entryCount, comment, commentBytes) {
let readEntryCursor = centralDirectoryOffset;
async function readEntries(reader, centralDirectoryOffset, centralDirectorySize, entryCount, comment, commentBytes) {
let readEntryCursor = 0;
const allEntriesBuffer = await readAs(reader, centralDirectoryOffset, centralDirectorySize);
const entries = [];
for (let e = 0; e < entryCount; ++e) {
const buffer = await readAs(reader, readEntryCursor, 46);
const buffer = allEntriesBuffer.subarray(readEntryCursor, readEntryCursor + 46);
// 0 - Central directory file header signature

@@ -925,3 +928,3 @@ const signature = getUint32LE(buffer, 0);

const data = await readAs(reader, readEntryCursor, entry.fileNameLength + entry.extraFieldLength + entry.fileCommentLength);
const data = allEntriesBuffer.subarray(readEntryCursor, readEntryCursor + entry.fileNameLength + entry.extraFieldLength + entry.fileCommentLength);
entry.nameBytes = data.slice(0, entry.fileNameLength);

@@ -928,0 +931,0 @@ entry.name = decodeBuffer(entry.nameBytes);

{
"name": "unzipit",
"version": "1.1.5",
"version": "1.2.0",
"description": "random access unzip library for JavaScript",

@@ -5,0 +5,0 @@ "main": "dist/unzipit.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc