智慧水务管理系统 - 精河县供水工程综合管理平台

index.cjs 317KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882
  1. 'use strict';
  2. var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
  3. /*
  4. Copyright (c) 2022 Gildas Lormeau. All rights reserved.
  5. Redistribution and use in source and binary forms, with or without
  6. modification, are permitted provided that the following conditions are met:
  7. 1. Redistributions of source code must retain the above copyright notice,
  8. this list of conditions and the following disclaimer.
  9. 2. Redistributions in binary form must reproduce the above copyright
  10. notice, this list of conditions and the following disclaimer in
  11. the documentation and/or other materials provided with the distribution.
  12. 3. The names of the authors may not be used to endorse or promote products
  13. derived from this software without specific prior written permission.
  14. THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  15. INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  16. FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
  17. INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
  18. INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  19. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
  20. OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  21. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  22. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  23. EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24. */
  25. const MAX_32_BITS = 0xffffffff;
  26. const MAX_16_BITS = 0xffff;
  27. const MAX_8_BITS = 0xff;
  28. const COMPRESSION_METHOD_DEFLATE = 0x08;
  29. const COMPRESSION_METHOD_DEFLATE_64 = 0x09;
  30. const COMPRESSION_METHOD_STORE = 0x00;
  31. const COMPRESSION_METHOD_AES = 0x63;
  32. const LOCAL_FILE_HEADER_SIGNATURE = 0x04034b50;
  33. const SPLIT_ZIP_FILE_SIGNATURE = 0x08074b50;
  34. const DATA_DESCRIPTOR_RECORD_SIGNATURE = SPLIT_ZIP_FILE_SIGNATURE;
  35. const CENTRAL_FILE_HEADER_SIGNATURE = 0x02014b50;
  36. const END_OF_CENTRAL_DIR_SIGNATURE = 0x06054b50;
  37. const ZIP64_END_OF_CENTRAL_DIR_SIGNATURE = 0x06064b50;
  38. const ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIGNATURE = 0x07064b50;
  39. const END_OF_CENTRAL_DIR_LENGTH = 22;
  40. const ZIP64_END_OF_CENTRAL_DIR_LOCATOR_LENGTH = 20;
  41. const ZIP64_END_OF_CENTRAL_DIR_LENGTH = 56;
  42. const ZIP64_END_OF_CENTRAL_DIR_TOTAL_LENGTH = END_OF_CENTRAL_DIR_LENGTH + ZIP64_END_OF_CENTRAL_DIR_LOCATOR_LENGTH + ZIP64_END_OF_CENTRAL_DIR_LENGTH;
  43. const DATA_DESCRIPTOR_RECORD_LENGTH = 12;
  44. const DATA_DESCRIPTOR_RECORD_ZIP_64_LENGTH = 20;
  45. const DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH = 4;
  46. const EXTRAFIELD_TYPE_ZIP64 = 0x0001;
  47. const EXTRAFIELD_TYPE_AES = 0x9901;
  48. const EXTRAFIELD_TYPE_NTFS = 0x000a;
  49. const EXTRAFIELD_TYPE_NTFS_TAG1 = 0x0001;
  50. const EXTRAFIELD_TYPE_EXTENDED_TIMESTAMP = 0x5455;
  51. const EXTRAFIELD_TYPE_UNICODE_PATH = 0x7075;
  52. const EXTRAFIELD_TYPE_UNICODE_COMMENT = 0x6375;
  53. const EXTRAFIELD_TYPE_USDZ = 0x1986;
  54. const EXTRAFIELD_TYPE_INFOZIP = 0x7875;
  55. const EXTRAFIELD_TYPE_UNIX = 0x7855;
  56. const BITFLAG_ENCRYPTED = 0b1;
  57. const BITFLAG_LEVEL = 0b0110;
  58. const BITFLAG_LEVEL_MAX_MASK = 0b010;
  59. const BITFLAG_LEVEL_FAST_MASK = 0b100;
  60. const BITFLAG_LEVEL_SUPER_FAST_MASK = 0b110;
  61. const BITFLAG_DATA_DESCRIPTOR = 0b1000;
  62. const BITFLAG_LANG_ENCODING_FLAG = 0b100000000000;
  63. const FILE_ATTR_MSDOS_DIR_MASK = 0b10000;
  64. const FILE_ATTR_MSDOS_READONLY_MASK = 0x01;
  65. const FILE_ATTR_MSDOS_HIDDEN_MASK = 0x02;
  66. const FILE_ATTR_MSDOS_SYSTEM_MASK = 0x04;
  67. const FILE_ATTR_MSDOS_ARCHIVE_MASK = 0x20;
  68. const FILE_ATTR_UNIX_TYPE_MASK = 0o170000;
  69. const FILE_ATTR_UNIX_TYPE_DIR = 0o040000;
  70. const FILE_ATTR_UNIX_EXECUTABLE_MASK = 0o111;
  71. const FILE_ATTR_UNIX_DEFAULT_MASK = 0o644;
  72. const FILE_ATTR_UNIX_SETUID_MASK = 0o4000;
  73. const FILE_ATTR_UNIX_SETGID_MASK = 0o2000;
  74. const FILE_ATTR_UNIX_STICKY_MASK = 0o1000;
  75. const VERSION_DEFLATE = 0x14;
  76. const VERSION_ZIP64 = 0x2D;
  77. const VERSION_AES = 0x33;
  78. const DIRECTORY_SIGNATURE = "/";
  79. const HEADER_SIZE = 30;
  80. const HEADER_OFFSET_SIGNATURE = 10;
  81. const HEADER_OFFSET_COMPRESSED_SIZE = 14;
  82. const HEADER_OFFSET_UNCOMPRESSED_SIZE = 18;
  83. const MAX_DATE = new Date(2107, 11, 31);
  84. const MIN_DATE = new Date(1980, 0, 1);
  85. const UNDEFINED_VALUE = undefined;
  86. const INFINITY_VALUE = Infinity;
  87. const UNDEFINED_TYPE = "undefined";
  88. const FUNCTION_TYPE = "function";
  89. const OBJECT_TYPE = "object";
  90. /*
  91. Copyright (c) 2025 Gildas Lormeau. All rights reserved.
  92. Redistribution and use in source and binary forms, with or without
  93. modification, are permitted provided that the following conditions are met:
  94. 1. Redistributions of source code must retain the above copyright notice,
  95. this list of conditions and the following disclaimer.
  96. 2. Redistributions in binary form must reproduce the above copyright
  97. notice, this list of conditions and the following disclaimer in
  98. the documentation and/or other materials provided with the distribution.
  99. 3. The names of the authors may not be used to endorse or promote products
  100. derived from this software without specific prior written permission.
  101. THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  102. INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  103. FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
  104. INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
  105. INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  106. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
  107. OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  108. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  109. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  110. EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  111. */
  112. const MINIMUM_CHUNK_SIZE = 64;
  113. let maxWorkers = 2;
  114. try {
  115. if (typeof navigator != UNDEFINED_TYPE && navigator.hardwareConcurrency) {
  116. maxWorkers = navigator.hardwareConcurrency;
  117. }
  118. } catch {
  119. // ignored
  120. }
  121. const DEFAULT_CONFIGURATION = {
  122. workerURI: "./core/web-worker-wasm.js",
  123. wasmURI: "./core/streams/zlib-wasm/zlib-streams.wasm",
  124. chunkSize: 64 * 1024,
  125. maxWorkers,
  126. terminateWorkerTimeout: 5000,
  127. useWebWorkers: true,
  128. useCompressionStream: true,
  129. CompressionStream: typeof CompressionStream != UNDEFINED_TYPE && CompressionStream,
  130. DecompressionStream: typeof DecompressionStream != UNDEFINED_TYPE && DecompressionStream
  131. };
  132. const config = Object.assign({}, DEFAULT_CONFIGURATION);
  133. function getConfiguration() {
  134. return config;
  135. }
  136. function getChunkSize(config) {
  137. return Math.max(config.chunkSize, MINIMUM_CHUNK_SIZE);
  138. }
  139. function configure(configuration) {
  140. const {
  141. baseURI,
  142. chunkSize,
  143. maxWorkers,
  144. terminateWorkerTimeout,
  145. useCompressionStream,
  146. useWebWorkers,
  147. CompressionStream,
  148. DecompressionStream,
  149. CompressionStreamZlib,
  150. DecompressionStreamZlib,
  151. workerURI,
  152. wasmURI
  153. } = configuration;
  154. setIfDefined("baseURI", baseURI);
  155. setIfDefined("wasmURI", wasmURI);
  156. setIfDefined("workerURI", workerURI);
  157. setIfDefined("chunkSize", chunkSize);
  158. setIfDefined("maxWorkers", maxWorkers);
  159. setIfDefined("terminateWorkerTimeout", terminateWorkerTimeout);
  160. setIfDefined("useCompressionStream", useCompressionStream);
  161. setIfDefined("useWebWorkers", useWebWorkers);
  162. setIfDefined("CompressionStream", CompressionStream);
  163. setIfDefined("DecompressionStream", DecompressionStream);
  164. setIfDefined("CompressionStreamZlib", CompressionStreamZlib);
  165. setIfDefined("DecompressionStreamZlib", DecompressionStreamZlib);
  166. }
  167. function setIfDefined(propertyName, propertyValue) {
  168. if (propertyValue !== UNDEFINED_VALUE) {
  169. config[propertyName] = propertyValue;
  170. }
  171. }
  172. function t(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:i,Uint32Array:c,Int32Array:a,Map:h,DataView:f,Promise:l,TextEncoder:u,crypto:w,postMessage:p,TransformStream:d,ReadableStream:y,WritableStream:m,CompressionStream:g,DecompressionStream:S}=self,b=void 0,v="undefined",k="function",z=[];for(let t=0;256>t;t++){let e=t;for(let t=0;8>t;t++)1&e?e=e>>>1^3988292384:e>>>=1;z[t]=e}class C{constructor(t){this.t=t||-1}append(t){let e=0|this.t;for(let n=0,s=0|t.length;s>n;n++)e=e>>>8^z[255&(e^t[n])];this.t=e}get(){return~this.t}}class A extends d{constructor(){let t;const e=new C;super({transform(t,n){e.append(t),n.enqueue(t)},flush(){const n=new o(4);new f(n.buffer).setUint32(0,e.get()),t.value=n}}),t=this}}const x={concat(t,e){if(0===t.length||0===e.length)return t.concat(e);const n=t[t.length-1],s=x.o(n);return 32===s?t.concat(e):x.i(e,s,0|n,t.slice(0,t.length-1))},h(t){const e=t.length;if(0===e)return 0;const n=t[e-1];return 32*(e-1)+x.o(n)},l(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]=x.u(e,t[n-1]&2147483648>>e-1,1)),t},u:(t,e,n)=>32===t?e:(n?0|e:e<<32-t)+1099511627776*t,o:t=>s.round(t/1099511627776)||32,i(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=x.o(r);return s.push(x.u(e+o&31,e+o>32?n:s.pop(),1)),s}},I={bytes:{p(t){const e=x.h(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},m(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(x.u(8*(3&n),s)),e}}},R=class{constructor(t){const e=this;e.blockSize=512,e.S=[1732584193,4023233417,2562383102,271733878,3285377520],e.v=[1518500249,1859775393,2400959708,3395469782],t?(e.k=t.k.slice(0),e.C=t.C.slice(0),e.A=t.A):e.reset()}reset(){const t=this;return t.k=t.S.slice(0),t.C=[],t.A=0,t}update(t){const e=this;"string"==typeof t&&(t=I.I.m(t));const n=e.C=x.concat(e.C,t),s=e.A,o=e.A=s+x.h(t);if(o>9007199254740991)throw new r("Cannot hash more than 2^53 - 1 bits");const i=new c(n);let a=0;for(let t=e.blockSize+s-(e.blockSize+s&e.blockSize-1);o>=t;t+=e.blockSize)e.R(i.subarray(16*a,16*(a+1))),a+=1;return n.splice(0,16*a),e}P(){const t=this;let e=t.C;const n=t.k;e=x.concat(e,[x.u(1,1)]);for(let t=e.length+2;15&t;t++)e.push(0);for(e.push(s.floor(t.A/4294967296)),e.push(0|t.A);e.length;)t.R(e.splice(0,16));return t.reset(),n}U(t,e,n,s){return t>19?t>39?t>59?t>79?void 0:e^n^s:e&n|e&s|n&s:e^n^s:e&n|~e&s}V(t,e){return e<<t|e>>>32-t}R(e){const n=this,r=n.k,o=t(80);for(let t=0;16>t;t++)o[t]=e[t];let i=r[0],c=r[1],a=r[2],h=r[3],f=r[4];for(let t=0;79>=t;t++){16>t||(o[t]=n.V(1,o[t-3]^o[t-8]^o[t-14]^o[t-16]));const e=n.V(5,i)+n.U(t,c,a,h)+f+o[t]+n.v[s.floor(t/20)]|0;f=h,h=a,a=n.V(30,c),c=i,i=e}r[0]=r[0]+i|0,r[1]=r[1]+c|0,r[2]=r[2]+a|0,r[3]=r[3]+h|0,r[4]=r[4]+f|0}},P={getRandomValues(t){const e=new c(t.buffer),n=t=>{let e=987654321;const n=4294967295;return()=>(e=36969*(65535&e)+(e>>16)&n,(((e<<16)+(t=18e3*(65535&t)+(t>>16)&n)&n)/4294967296+.5)*(s.random()>.5?1:-1))};for(let r,o=0;o<t.length;o+=4){const t=n(4294967296*(r||s.random()));r=987654071*t(),e[o/4]=4294967296*t()|0}return t}},U={importKey:t=>new U.M(I.bytes.m(t)),_(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 i,c,a,h,l;const u=new ArrayBuffer(o),w=new f(u);let p=0;const d=x;for(e=I.bytes.m(e),l=1;(o||1)>p;l++){for(i=c=t.encrypt(d.concat(e,[l])),a=1;n>a;a++)for(c=t.encrypt(c),h=0;h<c.length;h++)i[h]^=c[h];for(a=0;(o||1)>p&&a<i.length;a++)w.setInt32(p,i[a]),p+=4}return u.slice(0,s/8)},M:class{constructor(t){const e=this,n=e.B=R,s=[[],[]];e.D=[new n,new n];const r=e.D[0].blockSize/32;t.length>r&&(t=(new n).update(t).P());for(let e=0;r>e;e++)s[0][e]=909522486^t[e],s[1][e]=1549556828^t[e];e.D[0].update(s[0]),e.D[1].update(s[1]),e.W=new n(e.D[0])}reset(){const t=this;t.W=new t.B(t.D[0]),t.K=!1}update(t){this.K=!0,this.W.update(t)}digest(){const t=this,e=t.W.P(),n=new t.B(t.D[1]).update(e).P();return t.reset(),n}encrypt(t){if(this.K)throw new r("encrypt on already updated hmac called!");return this.update(t),this.digest(t)}}},V=typeof w!=v&&typeof w.getRandomValues==k,M="Invalid password",_="Invalid signature",B="zipjs-abort-check-password";function D(t){return V?w.getRandomValues(t):P.getRandomValues(t)}const W=16,K={name:"PBKDF2"},E=e.assign({hash:{name:"HMAC"}},K),L=e.assign({iterations:1e3,hash:{name:"SHA-1"}},K),O=["deriveBits"],T=[8,12,16],j=[16,24,32],H=10,Z=[0,0,0,0],F=typeof w!=v,N=F&&w.subtle,q=F&&typeof N!=v,G=I.bytes,J=class{constructor(t){const e=this;e.L=[[[],[],[],[],[]],[[],[],[],[],[]]],e.L[0][0][0]||e.O();const n=e.L[0][4],s=e.L[1],o=t.length;let i,c,a,h=1;if(4!==o&&6!==o&&8!==o)throw new r("invalid aes key size");for(e.v=[c=t.slice(0),a=[]],i=o;4*o+28>i;i++){let t=c[i-1];(i%o===0||8===o&&i%o===4)&&(t=n[t>>>24]<<24^n[t>>16&255]<<16^n[t>>8&255]<<8^n[255&t],i%o===0&&(t=t<<8^t>>>24^h<<24,h=h<<1^283*(h>>7))),c[i]=c[i-o]^t}for(let t=0;i;t++,i--){const e=c[3&t?i:i-4];a[t]=4>=i||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.T(t,0)}decrypt(t){return this.T(t,1)}O(){const t=this.L[0],e=this.L[1],n=t[4],s=e[4],r=[],o=[];let i,c,a,h;for(let t=0;256>t;t++)o[(r[t]=t<<1^283*(t>>7))^t]=t;for(let f=i=0;!n[f];f^=c||1,i=o[i]||1){let o=i^i<<1^i<<2^i<<3^i<<4;o=o>>8^255&o^99,n[f]=o,s[o]=f,h=r[a=r[c=r[f]]];let l=16843009*h^65537*a^257*c^16843008*f,u=257*r[o]^16843008*o;for(let n=0;4>n;n++)t[n][f]=u=u<<24^u>>>8,e[n][o]=l=l<<24^l>>>8}for(let n=0;5>n;n++)t[n]=t[n].slice(0),e[n]=e[n].slice(0)}T(t,e){if(4!==t.length)throw new r("invalid aes block size");const n=this.v[e],s=n.length/4-2,o=[0,0,0,0],i=this.L[e],c=i[0],a=i[1],h=i[2],f=i[3],l=i[4];let u,w,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=c[d>>>24]^a[y>>16&255]^h[m>>8&255]^f[255&g]^n[S],w=c[y>>>24]^a[m>>16&255]^h[g>>8&255]^f[255&d]^n[S+1],p=c[m>>>24]^a[g>>16&255]^h[d>>8&255]^f[255&y]^n[S+2],g=c[g>>>24]^a[d>>16&255]^h[y>>8&255]^f[255&m]^n[S+3],S+=4,d=u,y=w,m=p;for(let t=0;4>t;t++)o[e?3&-t:t]=l[d>>>24]<<24^l[y>>16&255]<<16^l[m>>8&255]<<8^l[255&g]^n[S++],u=d,d=y,y=m,m=g,g=u;return o}},Q=class{constructor(t,e){this.j=t,this.H=e,this.Z=e}reset(){this.Z=this.H}update(t){return this.F(this.j,t,this.Z)}N(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}q(t){0===(t[0]=this.N(t[0]))&&(t[1]=this.N(t[1]))}F(t,e,n){let s;if(!(s=e.length))return[];const r=x.h(e);for(let r=0;s>r;r+=4){this.q(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 x.l(e,r)}},X=U.M;let Y=F&&q&&typeof N.importKey==k,$=F&&q&&typeof N.deriveBits==k;class tt extends d{constructor({password:t,rawPassword:n,signed:s,encryptionStrength:i,checkPasswordOnly:c}){super({start(){e.assign(this,{ready:new l(t=>this.G=t),password:rt(t,n),signed:s,J:i-1,pending:new o})},async transform(t,e){const n=this,{password:s,J:i,G:a,ready:h}=n;s?(await(async(t,e,n,s)=>{const o=await st(t,e,n,it(s,0,T[e])),i=it(s,T[e]);if(o[0]!=i[0]||o[1]!=i[1])throw new r(M)})(n,i,s,it(t,0,T[i]+2)),t=it(t,T[i]+2),c?e.error(new r(B)):a()):await h;const f=new o(t.length-H-(t.length-H)%W);e.enqueue(nt(n,t,f,0,H,!0))},async flush(t){const{signed:e,X:n,Y:s,pending:i,ready:c}=this;if(s&&n){await c;const a=it(i,0,i.length-H),h=it(i,i.length-H);let f=new o;if(a.length){const t=at(G,a);s.update(t);const e=n.update(t);f=ct(G,e)}if(e){const t=it(ct(G,s.digest()),0,H);for(let e=0;H>e;e++)if(t[e]!=h[e])throw new r(_)}t.enqueue(f)}}})}}class et extends d{constructor({password:t,rawPassword:n,encryptionStrength:s}){let r;super({start(){e.assign(this,{ready:new l(t=>this.G=t),password:rt(t,n),J:s-1,pending:new o})},async transform(t,e){const n=this,{password:s,J:r,G:i,ready:c}=n;let a=new o;s?(a=await(async(t,e,n)=>{const s=D(new o(T[e]));return ot(s,await st(t,e,n,s))})(n,r,s),i()):await c;const h=new o(a.length+t.length-t.length%W);h.set(a,0),e.enqueue(nt(n,t,h,a.length,0))},async flush(t){const{X:e,Y:n,pending:s,ready:i}=this;if(n&&e){await i;let c=new o;if(s.length){const t=e.update(at(G,s));n.update(t),c=ct(G,t)}r.signature=ct(G,n.digest()).slice(0,H),t.enqueue(ot(c,r.signature))}}}),r=this}}function nt(t,e,n,s,r,i){const{X:c,Y:a,pending:h}=t,f=e.length-r;let l;for(h.length&&(e=ot(h,e),n=((t,e)=>{if(e&&e>t.length){const n=t;(t=new o(e)).set(n,0)}return t})(n,f-f%W)),l=0;f-W>=l;l+=W){const t=at(G,it(e,l,l+W));i&&a.update(t);const r=c.update(t);i||a.update(r),n.set(ct(G,r),l+s)}return t.pending=it(e,l),n}async function st(n,s,r,i){n.password=null;const c=await(async(t,e,n,s,r)=>{if(!Y)return U.importKey(e);try{return await N.importKey("raw",e,n,!1,r)}catch{return Y=!1,U.importKey(e)}})(0,r,E,0,O),a=await(async(t,e,n)=>{if(!$)return U._(e,t.salt,L.iterations,n);try{return await N.deriveBits(t,e,n)}catch{return $=!1,U._(e,t.salt,L.iterations,n)}})(e.assign({salt:i},L),c,8*(2*j[s]+2)),h=new o(a),f=at(G,it(h,0,j[s])),l=at(G,it(h,j[s],2*j[s])),u=it(h,2*j[s]);return e.assign(n,{keys:{key:f,$:l,passwordVerification:u},X:new Q(new J(f),t.from(Z)),Y:new X(l)}),u}function rt(t,e){return e===b?(t=>{if(typeof u==v){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 ot(t,e){let n=t;return t.length+e.length&&(n=new o(t.length+e.length),n.set(t,0),n.set(e,t.length)),n}function it(t,e,n){return t.subarray(e,n)}function ct(t,e){return t.p(e)}function at(t,e){return t.m(e)}class ht extends d{constructor({password:t,passwordVerification:n,checkPasswordOnly:s}){super({start(){e.assign(this,{password:t,passwordVerification:n}),wt(this,t)},transform(t,e){const n=this;if(n.password){const e=lt(n,t.subarray(0,12));if(n.password=null,e.at(-1)!=n.passwordVerification)throw new r(M);t=t.subarray(12)}s?e.error(new r(B)):e.enqueue(lt(n,t))}})}}class ft extends d{constructor({password:t,passwordVerification:n}){super({start(){e.assign(this,{password:t,passwordVerification:n}),wt(this,t)},transform(t,e){const n=this;let s,r;if(n.password){n.password=null;const e=D(new o(12));e[11]=n.passwordVerification,s=new o(t.length+e.length),s.set(ut(n,e),0),r=12}else s=new o(t.length),r=0;s.set(ut(n,t),r),e.enqueue(s)}})}}function lt(t,e){const n=new o(e.length);for(let s=0;s<e.length;s++)n[s]=dt(t)^e[s],pt(t,n[s]);return n}function ut(t,e){const n=new o(e.length);for(let s=0;s<e.length;s++)n[s]=dt(t)^e[s],pt(t,e[s]);return n}function wt(t,n){const s=[305419896,591751049,878082192];e.assign(t,{keys:s,tt:new C(s[0]),et:new C(s[2])});for(let e=0;e<n.length;e++)pt(t,n.charCodeAt(e))}function pt(t,e){let[n,r,o]=t.keys;t.tt.append([e]),n=~t.tt.get(),r=mt(s.imul(mt(r+yt(n)),134775813)+1),t.et.append([r>>>24]),o=~t.et.get(),t.keys=[n,r,o]}function dt(t){const e=2|t.keys[2];return yt(s.imul(e,1^e)>>>8)}function yt(t){return 255&t}function mt(t){return 4294967295&t}class gt extends d{constructor(t,{chunkSize:e,nt:n,CompressionStream:s}){super({});const{compressed:r,encrypted:o,useCompressionStream:i,zipCrypto:c,signed:a,level:h}=t,l=this;let u,w,p=super.readable;o&&!c||!a||(u=new A,p=kt(p,u)),r&&(p=vt(p,i,{level:h,chunkSize:e},s,n,s)),o&&(c?p=kt(p,new ft(t)):(w=new et(t),p=kt(p,w))),bt(l,p,()=>{let t;o&&!c&&(t=w.signature),o&&!c||!a||(t=new f(u.value.buffer).getUint32(0)),l.signature=t})}}class St extends d{constructor(t,{chunkSize:e,st:n,DecompressionStream:s}){super({});const{zipCrypto:o,encrypted:i,signed:c,signature:a,compressed:h,useCompressionStream:l,rt:u}=t;let w,p,d=super.readable;i&&(o?d=kt(d,new ht(t)):(p=new tt(t),d=kt(d,p))),h&&(d=vt(d,l,{chunkSize:e,rt:u},s,n,s)),i&&!o||!c||(w=new A,d=kt(d,w)),bt(this,d,()=>{if((!i||o)&&c){const t=new f(w.value.buffer);if(a!=t.getUint32(0,!1))throw new r(_)}})}}function bt(t,n,s){n=kt(n,new d({flush:s})),e.defineProperty(t,"readable",{get:()=>n})}function vt(t,e,n,s,r,o){const i=e&&s?s:r||o,c=n.rt?"deflate64-raw":"deflate-raw";try{t=kt(t,new i(c,n))}catch(s){if(!e)throw s;if(r)t=kt(t,new r(c,n));else{if(!o)throw s;t=kt(t,new o(c,n))}}return t}function kt(t,e){return t.pipeThrough(e)}const zt="data",Ct="close";class At extends d{constructor(t,n){super({});const s=this,{codecType:o}=t;let i;o.startsWith("deflate")?i=gt:o.startsWith("inflate")&&(i=St),s.outputSize=0;let c=0;const a=new i(t,n),h=super.readable,f=new d({transform(t,e){t&&t.length&&(c+=t.length,e.enqueue(t))},flush(){e.assign(s,{inputSize:c})}}),l=new d({transform(e,n){if(e&&e.length&&(n.enqueue(e),s.outputSize+=e.length,t.outputSize!==b&&s.outputSize>t.outputSize))throw new r("Invalid uncompressed size")},flush(){const{signature:t}=a;e.assign(s,{signature:t,inputSize:c})}});e.defineProperty(s,"readable",{get:()=>h.pipeThrough(f).pipeThrough(a).pipeThrough(l)})}}class xt extends d{constructor(t){let e;super({transform:function n(s,r){if(e){const t=new o(e.length+s.length);t.set(e),t.set(s,e.length),s=t,e=null}s.length>t?(r.enqueue(s.slice(0,t)),n(s.slice(t),r)):e=s},flush(t){e&&e.length&&t.enqueue(e)}})}}const It=new h,Rt=new h;let Pt,Ut,Vt,Mt,_t,Bt=0;async function Dt(t){try{const{options:e,config:s}=t;if(!e.useCompressionStream)try{await self.initModule(t.config)}catch{e.useCompressionStream=!0}s.CompressionStream=self.CompressionStream,s.DecompressionStream=self.DecompressionStream;const r={highWaterMark:1},o=t.readable||new y({async pull(t){const e=new l(t=>It.set(Bt,t));Wt({type:"pull",messageId:Bt}),Bt=(Bt+1)%n.MAX_SAFE_INTEGER;const{value:s,done:r}=await e;t.enqueue(s),r&&t.close()}},r),i=t.writable||new m({async write(t){let e;const s=new l(t=>e=t);Rt.set(Bt,e),Wt({type:zt,value:t,messageId:Bt}),Bt=(Bt+1)%n.MAX_SAFE_INTEGER,await s}},r),c=new At(e,s);Pt=new AbortController;const{signal:a}=Pt;await o.pipeThrough(c).pipeThrough(new xt(s.chunkSize)).pipeTo(i,{signal:a,preventClose:!0,preventAbort:!0}),await i.getWriter().close();const{signature:h,inputSize:f,outputSize:u}=c;Wt({type:Ct,result:{signature:h,inputSize:f,outputSize:u}})}catch(t){t.outputSize=0,Kt(t)}}function Wt(t){let{value:e}=t;if(e)if(e.length)try{e=new o(e),t.value=e.buffer,p(t,[t.value])}catch{p(t)}else p(t);else p(t)}function Kt(t=new r("Unknown error")){const{message:e,stack:n,code:s,name:o,outputSize:i}=t;p({error:{message:e,stack:n,code:s,name:o,outputSize:i}})}function Et(t,e,n={}){const i="number"==typeof n.level?n.level:-1,c="number"==typeof n.ot?n.ot:65536,a="number"==typeof n.it?n.it:65536;return new d({start(){let n;if(this.ct=Vt(c),this.in=Vt(a),this.it=a,this.ht=new o(c),t?(this.ft=Ut.deflate_process,this.lt=Ut.deflate_last_consumed,this.ut=Ut.deflate_end,this.wt=Ut.deflate_new(),n="gzip"===e?Ut.deflate_init_gzip(this.wt,i):"deflate-raw"===e?Ut.deflate_init_raw(this.wt,i):Ut.deflate_init(this.wt,i)):"deflate64-raw"===e?(this.ft=Ut.inflate9_process,this.lt=Ut.inflate9_last_consumed,this.ut=Ut.inflate9_end,this.wt=Ut.inflate9_new(),n=Ut.inflate9_init_raw(this.wt)):(this.ft=Ut.inflate_process,this.lt=Ut.inflate_last_consumed,this.ut=Ut.inflate_end,this.wt=Ut.inflate_new(),n="deflate-raw"===e?Ut.inflate_init_raw(this.wt):"gzip"===e?Ut.inflate_init_gzip(this.wt):Ut.inflate_init(this.wt)),0!==n)throw new r("init failed:"+n)},transform(e,n){try{const i=e,a=new o(_t.buffer),h=this.ft,f=this.lt,l=this.ct,u=this.ht;let w=0;for(;w<i.length;){const e=s.min(i.length-w,32768);this.in&&this.it>=e||(this.in&&Mt&&Mt(this.in),this.in=Vt(e),this.it=e),a.set(i.subarray(w,w+e),this.in);const o=h(this.wt,this.in,e,l,c,0),p=16777215&o;if(p&&(u.set(a.subarray(l,l+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=f(this.wt);if(0===d)break;w+=d}}catch(t){this.ut&&this.wt&&this.ut(this.wt),this.in&&Mt&&Mt(this.in),this.ct&&Mt&&Mt(this.ct),n.error(t)}},flush(e){try{const n=new o(_t.buffer),s=this.ft,i=this.ct,a=this.ht;for(;;){const o=s(this.wt,0,0,i,c,4),h=16777215&o,f=o>>24&255;if(!t){const t=128&f?f-256:f;if(0>t)throw new r("process error:"+t)}if(h&&(a.set(n.subarray(i,i+h),0),e.enqueue(a.slice(0,h))),1===f||0===h)break}}catch(t){e.error(t)}finally{if(this.ut&&this.wt){const t=this.ut(this.wt);0!==t&&e.error(new r("end error:"+t))}this.in&&Mt&&Mt(this.in),this.ct&&Mt&&Mt(this.ct)}}})}addEventListener("message",({data:t})=>{const{type:e,messageId:n,value:s,done:r}=t;try{if("start"==e&&Dt(t),e==zt){const t=It.get(n);It.delete(n),t({value:new o(s),done:r})}if("ack"==e){const t=Rt.get(n);Rt.delete(n),t()}e==Ct&&Pt.abort()}catch(t){Kt(t)}});class Lt{constructor(t="deflate",e){return Et(!0,t,e)}}class Ot{constructor(t="deflate",e){return Et(!1,t,e)}}let Tt=!1;self.initModule=async t=>{try{const e=await(async(t,{baseURI:e})=>{if(!Tt){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(Ut=t,({malloc:Vt,free:Mt,memory:_t}=Ut),"function"!=typeof Vt||"function"!=typeof Mt||!_t)throw Ut=Vt=Mt=_t=null,new r("Invalid WASM module")})((await WebAssembly.instantiate(n)).instance.exports),Tt=!0}})(t.wasmURI,t);return t.nt=Lt,t.st=Ot,e}catch{}}});\n';t({workerURI:t=>{const n="text/javascript";if(t){const t=new Blob([e],{type:n});return URL.createObjectURL(t)}return "data:"+n+","+encodeURIComponent(e)}});}
  173. /*
  174. Copyright (c) 2022 Gildas Lormeau. All rights reserved.
  175. Redistribution and use in source and binary forms, with or without
  176. modification, are permitted provided that the following conditions are met:
  177. 1. Redistributions of source code must retain the above copyright notice,
  178. this list of conditions and the following disclaimer.
  179. 2. Redistributions in binary form must reproduce the above copyright
  180. notice, this list of conditions and the following disclaimer in
  181. the documentation and/or other materials provided with the distribution.
  182. 3. The names of the authors may not be used to endorse or promote products
  183. derived from this software without specific prior written permission.
  184. THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  185. INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  186. FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
  187. INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
  188. INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  189. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
  190. OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  191. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  192. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  193. EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  194. */
  195. const table$1 = [];
  196. for (let i = 0; i < 256; i++) {
  197. let t = i;
  198. for (let j = 0; j < 8; j++) {
  199. if (t & 1) {
  200. t = (t >>> 1) ^ 0xEDB88320;
  201. } else {
  202. t = t >>> 1;
  203. }
  204. }
  205. table$1[i] = t;
  206. }
  207. class Crc32 {
  208. constructor(crc) {
  209. this.crc = crc || -1;
  210. }
  211. append(data) {
  212. let crc = this.crc | 0;
  213. for (let offset = 0, length = data.length | 0; offset < length; offset++) {
  214. crc = (crc >>> 8) ^ table$1[(crc ^ data[offset]) & 0xFF];
  215. }
  216. this.crc = crc;
  217. }
  218. get() {
  219. return ~this.crc;
  220. }
  221. }
  222. /*
  223. Copyright (c) 2022 Gildas Lormeau. All rights reserved.
  224. Redistribution and use in source and binary forms, with or without
  225. modification, are permitted provided that the following conditions are met:
  226. 1. Redistributions of source code must retain the above copyright notice,
  227. this list of conditions and the following disclaimer.
  228. 2. Redistributions in binary form must reproduce the above copyright
  229. notice, this list of conditions and the following disclaimer in
  230. the documentation and/or other materials provided with the distribution.
  231. 3. The names of the authors may not be used to endorse or promote products
  232. derived from this software without specific prior written permission.
  233. THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  234. INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  235. FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
  236. INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
  237. INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  238. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
  239. OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  240. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  241. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  242. EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  243. */
  244. class Crc32Stream extends TransformStream {
  245. constructor() {
  246. // deno-lint-ignore prefer-const
  247. let stream;
  248. const crc32 = new Crc32();
  249. super({
  250. transform(chunk, controller) {
  251. crc32.append(chunk);
  252. controller.enqueue(chunk);
  253. },
  254. flush() {
  255. const value = new Uint8Array(4);
  256. const dataView = new DataView(value.buffer);
  257. dataView.setUint32(0, crc32.get());
  258. stream.value = value;
  259. }
  260. });
  261. stream = this;
  262. }
  263. }
  264. /*
  265. Copyright (c) 2022 Gildas Lormeau. All rights reserved.
  266. Redistribution and use in source and binary forms, with or without
  267. modification, are permitted provided that the following conditions are met:
  268. 1. Redistributions of source code must retain the above copyright notice,
  269. this list of conditions and the following disclaimer.
  270. 2. Redistributions in binary form must reproduce the above copyright
  271. notice, this list of conditions and the following disclaimer in
  272. the documentation and/or other materials provided with the distribution.
  273. 3. The names of the authors may not be used to endorse or promote products
  274. derived from this software without specific prior written permission.
  275. THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  276. INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  277. FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
  278. INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
  279. INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  280. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
  281. OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  282. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  283. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  284. EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  285. */
  286. function encodeText(value) {
  287. // deno-lint-ignore valid-typeof
  288. if (typeof TextEncoder == UNDEFINED_TYPE) {
  289. value = unescape(encodeURIComponent(value));
  290. const result = new Uint8Array(value.length);
  291. for (let i = 0; i < result.length; i++) {
  292. result[i] = value.charCodeAt(i);
  293. }
  294. return result;
  295. } else {
  296. return new TextEncoder().encode(value);
  297. }
  298. }
  299. // Derived from https://github.com/xqdoo00o/jszip/blob/master/lib/sjcl.js and https://github.com/bitwiseshiftleft/sjcl
  300. // deno-lint-ignore-file no-this-alias
  301. /*
  302. * SJCL is open. You can use, modify and redistribute it under a BSD
  303. * license or under the GNU GPL, version 2.0.
  304. */
  305. /** @fileOverview Javascript cryptography implementation.
  306. *
  307. * Crush to remove comments, shorten variable names and
  308. * generally reduce transmission size.
  309. *
  310. * @author Emily Stark
  311. * @author Mike Hamburg
  312. * @author Dan Boneh
  313. */
  314. /*jslint indent: 2, bitwise: false, nomen: false, plusplus: false, white: false, regexp: false */
  315. /** @fileOverview Arrays of bits, encoded as arrays of Numbers.
  316. *
  317. * @author Emily Stark
  318. * @author Mike Hamburg
  319. * @author Dan Boneh
  320. */
  321. /**
  322. * Arrays of bits, encoded as arrays of Numbers.
  323. * @namespace
  324. * @description
  325. * <p>
  326. * These objects are the currency accepted by SJCL's crypto functions.
  327. * </p>
  328. *
  329. * <p>
  330. * Most of our crypto primitives operate on arrays of 4-byte words internally,
  331. * but many of them can take arguments that are not a multiple of 4 bytes.
  332. * This library encodes arrays of bits (whose size need not be a multiple of 8
  333. * bits) as arrays of 32-bit words. The bits are packed, big-endian, into an
  334. * array of words, 32 bits at a time. Since the words are double-precision
  335. * floating point numbers, they fit some extra data. We use this (in a private,
  336. * possibly-changing manner) to encode the number of bits actually present
  337. * in the last word of the array.
  338. * </p>
  339. *
  340. * <p>
  341. * Because bitwise ops clear this out-of-band data, these arrays can be passed
  342. * to ciphers like AES which want arrays of words.
  343. * </p>
  344. */
  345. const bitArray = {
  346. /**
  347. * Concatenate two bit arrays.
  348. * @param {bitArray} a1 The first array.
  349. * @param {bitArray} a2 The second array.
  350. * @return {bitArray} The concatenation of a1 and a2.
  351. */
  352. concat(a1, a2) {
  353. if (a1.length === 0 || a2.length === 0) {
  354. return a1.concat(a2);
  355. }
  356. const last = a1[a1.length - 1], shift = bitArray.getPartial(last);
  357. if (shift === 32) {
  358. return a1.concat(a2);
  359. } else {
  360. return bitArray._shiftRight(a2, shift, last | 0, a1.slice(0, a1.length - 1));
  361. }
  362. },
  363. /**
  364. * Find the length of an array of bits.
  365. * @param {bitArray} a The array.
  366. * @return {Number} The length of a, in bits.
  367. */
  368. bitLength(a) {
  369. const l = a.length;
  370. if (l === 0) {
  371. return 0;
  372. }
  373. const x = a[l - 1];
  374. return (l - 1) * 32 + bitArray.getPartial(x);
  375. },
  376. /**
  377. * Truncate an array.
  378. * @param {bitArray} a The array.
  379. * @param {Number} len The length to truncate to, in bits.
  380. * @return {bitArray} A new array, truncated to len bits.
  381. */
  382. clamp(a, len) {
  383. if (a.length * 32 < len) {
  384. return a;
  385. }
  386. a = a.slice(0, Math.ceil(len / 32));
  387. const l = a.length;
  388. len = len & 31;
  389. if (l > 0 && len) {
  390. a[l - 1] = bitArray.partial(len, a[l - 1] & 0x80000000 >> (len - 1), 1);
  391. }
  392. return a;
  393. },
  394. /**
  395. * Make a partial word for a bit array.
  396. * @param {Number} len The number of bits in the word.
  397. * @param {Number} x The bits.
  398. * @param {Number} [_end=0] Pass 1 if x has already been shifted to the high side.
  399. * @return {Number} The partial word.
  400. */
  401. partial(len, x, _end) {
  402. if (len === 32) {
  403. return x;
  404. }
  405. return (_end ? x | 0 : x << (32 - len)) + len * 0x10000000000;
  406. },
  407. /**
  408. * Get the number of bits used by a partial word.
  409. * @param {Number} x The partial word.
  410. * @return {Number} The number of bits used by the partial word.
  411. */
  412. getPartial(x) {
  413. return Math.round(x / 0x10000000000) || 32;
  414. },
  415. /** Shift an array right.
  416. * @param {bitArray} a The array to shift.
  417. * @param {Number} shift The number of bits to shift.
  418. * @param {Number} [carry=0] A byte to carry in
  419. * @param {bitArray} [out=[]] An array to prepend to the output.
  420. * @private
  421. */
  422. _shiftRight(a, shift, carry, out) {
  423. if (out === undefined) {
  424. out = [];
  425. }
  426. for (; shift >= 32; shift -= 32) {
  427. out.push(carry);
  428. carry = 0;
  429. }
  430. if (shift === 0) {
  431. return out.concat(a);
  432. }
  433. for (let i = 0; i < a.length; i++) {
  434. out.push(carry | a[i] >>> shift);
  435. carry = a[i] << (32 - shift);
  436. }
  437. const last2 = a.length ? a[a.length - 1] : 0;
  438. const shift2 = bitArray.getPartial(last2);
  439. out.push(bitArray.partial(shift + shift2 & 31, (shift + shift2 > 32) ? carry : out.pop(), 1));
  440. return out;
  441. }
  442. };
  443. /** @fileOverview Bit array codec implementations.
  444. *
  445. * @author Emily Stark
  446. * @author Mike Hamburg
  447. * @author Dan Boneh
  448. */
  449. /**
  450. * Arrays of bytes
  451. * @namespace
  452. */
  453. const codec = {
  454. bytes: {
  455. /** Convert from a bitArray to an array of bytes. */
  456. fromBits(arr) {
  457. const bl = bitArray.bitLength(arr);
  458. const byteLength = bl / 8;
  459. const out = new Uint8Array(byteLength);
  460. let tmp;
  461. for (let i = 0; i < byteLength; i++) {
  462. if ((i & 3) === 0) {
  463. tmp = arr[i / 4];
  464. }
  465. out[i] = tmp >>> 24;
  466. tmp <<= 8;
  467. }
  468. return out;
  469. },
  470. /** Convert from an array of bytes to a bitArray. */
  471. toBits(bytes) {
  472. const out = [];
  473. let i;
  474. let tmp = 0;
  475. for (i = 0; i < bytes.length; i++) {
  476. tmp = tmp << 8 | bytes[i];
  477. if ((i & 3) === 3) {
  478. out.push(tmp);
  479. tmp = 0;
  480. }
  481. }
  482. if (i & 3) {
  483. out.push(bitArray.partial(8 * (i & 3), tmp));
  484. }
  485. return out;
  486. }
  487. }
  488. };
  489. const hash = {};
  490. /**
  491. * Context for a SHA-1 operation in progress.
  492. * @constructor
  493. */
  494. hash.sha1 = class {
  495. constructor(hash) {
  496. const sha1 = this;
  497. /**
  498. * The hash's block size, in bits.
  499. * @constant
  500. */
  501. sha1.blockSize = 512;
  502. /**
  503. * The SHA-1 initialization vector.
  504. * @private
  505. */
  506. sha1._init = [0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0];
  507. /**
  508. * The SHA-1 hash key.
  509. * @private
  510. */
  511. sha1._key = [0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xCA62C1D6];
  512. if (hash) {
  513. sha1._h = hash._h.slice(0);
  514. sha1._buffer = hash._buffer.slice(0);
  515. sha1._length = hash._length;
  516. } else {
  517. sha1.reset();
  518. }
  519. }
  520. /**
  521. * Reset the hash state.
  522. * @return this
  523. */
  524. reset() {
  525. const sha1 = this;
  526. sha1._h = sha1._init.slice(0);
  527. sha1._buffer = [];
  528. sha1._length = 0;
  529. return sha1;
  530. }
  531. /**
  532. * Input several words to the hash.
  533. * @param {bitArray|String} data the data to hash.
  534. * @return this
  535. */
  536. update(data) {
  537. const sha1 = this;
  538. if (typeof data === "string") {
  539. data = codec.utf8String.toBits(data);
  540. }
  541. const b = sha1._buffer = bitArray.concat(sha1._buffer, data);
  542. const ol = sha1._length;
  543. const nl = sha1._length = ol + bitArray.bitLength(data);
  544. if (nl > 9007199254740991) {
  545. throw new Error("Cannot hash more than 2^53 - 1 bits");
  546. }
  547. const c = new Uint32Array(b);
  548. let j = 0;
  549. for (let i = sha1.blockSize + ol - ((sha1.blockSize + ol) & (sha1.blockSize - 1)); i <= nl;
  550. i += sha1.blockSize) {
  551. sha1._block(c.subarray(16 * j, 16 * (j + 1)));
  552. j += 1;
  553. }
  554. b.splice(0, 16 * j);
  555. return sha1;
  556. }
  557. /**
  558. * Complete hashing and output the hash value.
  559. * @return {bitArray} The hash value, an array of 5 big-endian words. TODO
  560. */
  561. finalize() {
  562. const sha1 = this;
  563. let b = sha1._buffer;
  564. const h = sha1._h;
  565. // Round out and push the buffer
  566. b = bitArray.concat(b, [bitArray.partial(1, 1)]);
  567. // Round out the buffer to a multiple of 16 words, less the 2 length words.
  568. for (let i = b.length + 2; i & 15; i++) {
  569. b.push(0);
  570. }
  571. // append the length
  572. b.push(Math.floor(sha1._length / 0x100000000));
  573. b.push(sha1._length | 0);
  574. while (b.length) {
  575. sha1._block(b.splice(0, 16));
  576. }
  577. sha1.reset();
  578. return h;
  579. }
  580. /**
  581. * The SHA-1 logical functions f(0), f(1), ..., f(79).
  582. * @private
  583. */
  584. _f(t, b, c, d) {
  585. if (t <= 19) {
  586. return (b & c) | (~b & d);
  587. } else if (t <= 39) {
  588. return b ^ c ^ d;
  589. } else if (t <= 59) {
  590. return (b & c) | (b & d) | (c & d);
  591. } else if (t <= 79) {
  592. return b ^ c ^ d;
  593. }
  594. }
  595. /**
  596. * Circular left-shift operator.
  597. * @private
  598. */
  599. _S(n, x) {
  600. return (x << n) | (x >>> 32 - n);
  601. }
  602. /**
  603. * Perform one cycle of SHA-1.
  604. * @param {Uint32Array|bitArray} words one block of words.
  605. * @private
  606. */
  607. _block(words) {
  608. const sha1 = this;
  609. const h = sha1._h;
  610. // When words is passed to _block, it has 16 elements. SHA1 _block
  611. // function extends words with new elements (at the end there are 80 elements).
  612. // The problem is that if we use Uint32Array instead of Array,
  613. // the length of Uint32Array cannot be changed. Thus, we replace words with a
  614. // normal Array here.
  615. const w = Array(80); // do not use Uint32Array here as the instantiation is slower
  616. for (let j = 0; j < 16; j++) {
  617. w[j] = words[j];
  618. }
  619. let a = h[0];
  620. let b = h[1];
  621. let c = h[2];
  622. let d = h[3];
  623. let e = h[4];
  624. for (let t = 0; t <= 79; t++) {
  625. if (t >= 16) {
  626. w[t] = sha1._S(1, w[t - 3] ^ w[t - 8] ^ w[t - 14] ^ w[t - 16]);
  627. }
  628. const tmp = (sha1._S(5, a) + sha1._f(t, b, c, d) + e + w[t] +
  629. sha1._key[Math.floor(t / 20)]) | 0;
  630. e = d;
  631. d = c;
  632. c = sha1._S(30, b);
  633. b = a;
  634. a = tmp;
  635. }
  636. h[0] = (h[0] + a) | 0;
  637. h[1] = (h[1] + b) | 0;
  638. h[2] = (h[2] + c) | 0;
  639. h[3] = (h[3] + d) | 0;
  640. h[4] = (h[4] + e) | 0;
  641. }
  642. };
  643. /** @fileOverview Low-level AES implementation.
  644. *
  645. * This file contains a low-level implementation of AES, optimized for
  646. * size and for efficiency on several browsers. It is based on
  647. * OpenSSL's aes_core.c, a public-domain implementation by Vincent
  648. * Rijmen, Antoon Bosselaers and Paulo Barreto.
  649. *
  650. * An older version of this implementation is available in the public
  651. * domain, but this one is (c) Emily Stark, Mike Hamburg, Dan Boneh,
  652. * Stanford University 2008-2010 and BSD-licensed for liability
  653. * reasons.
  654. *
  655. * @author Emily Stark
  656. * @author Mike Hamburg
  657. * @author Dan Boneh
  658. */
  659. const cipher = {};
  660. /**
  661. * Schedule out an AES key for both encryption and decryption. This
  662. * is a low-level class. Use a cipher mode to do bulk encryption.
  663. *
  664. * @constructor
  665. * @param {Array} key The key as an array of 4, 6 or 8 words.
  666. */
  667. cipher.aes = class {
  668. constructor(key) {
  669. /**
  670. * The expanded S-box and inverse S-box tables. These will be computed
  671. * on the client so that we don't have to send them down the wire.
  672. *
  673. * There are two tables, _tables[0] is for encryption and
  674. * _tables[1] is for decryption.
  675. *
  676. * The first 4 sub-tables are the expanded S-box with MixColumns. The
  677. * last (_tables[01][4]) is the S-box itself.
  678. *
  679. * @private
  680. */
  681. const aes = this;
  682. aes._tables = [[[], [], [], [], []], [[], [], [], [], []]];
  683. if (!aes._tables[0][0][0]) {
  684. aes._precompute();
  685. }
  686. const sbox = aes._tables[0][4];
  687. const decTable = aes._tables[1];
  688. const keyLen = key.length;
  689. let i, encKey, decKey, rcon = 1;
  690. if (keyLen !== 4 && keyLen !== 6 && keyLen !== 8) {
  691. throw new Error("invalid aes key size");
  692. }
  693. aes._key = [encKey = key.slice(0), decKey = []];
  694. // schedule encryption keys
  695. for (i = keyLen; i < 4 * keyLen + 28; i++) {
  696. let tmp = encKey[i - 1];
  697. // apply sbox
  698. if (i % keyLen === 0 || (keyLen === 8 && i % keyLen === 4)) {
  699. tmp = sbox[tmp >>> 24] << 24 ^ sbox[tmp >> 16 & 255] << 16 ^ sbox[tmp >> 8 & 255] << 8 ^ sbox[tmp & 255];
  700. // shift rows and add rcon
  701. if (i % keyLen === 0) {
  702. tmp = tmp << 8 ^ tmp >>> 24 ^ rcon << 24;
  703. rcon = rcon << 1 ^ (rcon >> 7) * 283;
  704. }
  705. }
  706. encKey[i] = encKey[i - keyLen] ^ tmp;
  707. }
  708. // schedule decryption keys
  709. for (let j = 0; i; j++, i--) {
  710. const tmp = encKey[j & 3 ? i : i - 4];
  711. if (i <= 4 || j < 4) {
  712. decKey[j] = tmp;
  713. } else {
  714. decKey[j] = decTable[0][sbox[tmp >>> 24]] ^
  715. decTable[1][sbox[tmp >> 16 & 255]] ^
  716. decTable[2][sbox[tmp >> 8 & 255]] ^
  717. decTable[3][sbox[tmp & 255]];
  718. }
  719. }
  720. }
  721. // public
  722. /* Something like this might appear here eventually
  723. name: "AES",
  724. blockSize: 4,
  725. keySizes: [4,6,8],
  726. */
  727. /**
  728. * Encrypt an array of 4 big-endian words.
  729. * @param {Array} data The plaintext.
  730. * @return {Array} The ciphertext.
  731. */
  732. encrypt(data) {
  733. return this._crypt(data, 0);
  734. }
  735. /**
  736. * Decrypt an array of 4 big-endian words.
  737. * @param {Array} data The ciphertext.
  738. * @return {Array} The plaintext.
  739. */
  740. decrypt(data) {
  741. return this._crypt(data, 1);
  742. }
  743. /**
  744. * Expand the S-box tables.
  745. *
  746. * @private
  747. */
  748. _precompute() {
  749. const encTable = this._tables[0];
  750. const decTable = this._tables[1];
  751. const sbox = encTable[4];
  752. const sboxInv = decTable[4];
  753. const d = [];
  754. const th = [];
  755. let xInv, x2, x4, x8;
  756. // Compute double and third tables
  757. for (let i = 0; i < 256; i++) {
  758. th[(d[i] = i << 1 ^ (i >> 7) * 283) ^ i] = i;
  759. }
  760. for (let x = xInv = 0; !sbox[x]; x ^= x2 || 1, xInv = th[xInv] || 1) {
  761. // Compute sbox
  762. let s = xInv ^ xInv << 1 ^ xInv << 2 ^ xInv << 3 ^ xInv << 4;
  763. s = s >> 8 ^ s & 255 ^ 99;
  764. sbox[x] = s;
  765. sboxInv[s] = x;
  766. // Compute MixColumns
  767. x8 = d[x4 = d[x2 = d[x]]];
  768. let tDec = x8 * 0x1010101 ^ x4 * 0x10001 ^ x2 * 0x101 ^ x * 0x1010100;
  769. let tEnc = d[s] * 0x101 ^ s * 0x1010100;
  770. for (let i = 0; i < 4; i++) {
  771. encTable[i][x] = tEnc = tEnc << 24 ^ tEnc >>> 8;
  772. decTable[i][s] = tDec = tDec << 24 ^ tDec >>> 8;
  773. }
  774. }
  775. // Compactify. Considerable speedup on Firefox.
  776. for (let i = 0; i < 5; i++) {
  777. encTable[i] = encTable[i].slice(0);
  778. decTable[i] = decTable[i].slice(0);
  779. }
  780. }
  781. /**
  782. * Encryption and decryption core.
  783. * @param {Array} input Four words to be encrypted or decrypted.
  784. * @param dir The direction, 0 for encrypt and 1 for decrypt.
  785. * @return {Array} The four encrypted or decrypted words.
  786. * @private
  787. */
  788. _crypt(input, dir) {
  789. if (input.length !== 4) {
  790. throw new Error("invalid aes block size");
  791. }
  792. const key = this._key[dir];
  793. const nInnerRounds = key.length / 4 - 2;
  794. const out = [0, 0, 0, 0];
  795. const table = this._tables[dir];
  796. // load up the tables
  797. const t0 = table[0];
  798. const t1 = table[1];
  799. const t2 = table[2];
  800. const t3 = table[3];
  801. const sbox = table[4];
  802. // state variables a,b,c,d are loaded with pre-whitened data
  803. let a = input[0] ^ key[0];
  804. let b = input[dir ? 3 : 1] ^ key[1];
  805. let c = input[2] ^ key[2];
  806. let d = input[dir ? 1 : 3] ^ key[3];
  807. let kIndex = 4;
  808. let a2, b2, c2;
  809. // Inner rounds. Cribbed from OpenSSL.
  810. for (let i = 0; i < nInnerRounds; i++) {
  811. a2 = t0[a >>> 24] ^ t1[b >> 16 & 255] ^ t2[c >> 8 & 255] ^ t3[d & 255] ^ key[kIndex];
  812. b2 = t0[b >>> 24] ^ t1[c >> 16 & 255] ^ t2[d >> 8 & 255] ^ t3[a & 255] ^ key[kIndex + 1];
  813. c2 = t0[c >>> 24] ^ t1[d >> 16 & 255] ^ t2[a >> 8 & 255] ^ t3[b & 255] ^ key[kIndex + 2];
  814. d = t0[d >>> 24] ^ t1[a >> 16 & 255] ^ t2[b >> 8 & 255] ^ t3[c & 255] ^ key[kIndex + 3];
  815. kIndex += 4;
  816. a = a2; b = b2; c = c2;
  817. }
  818. // Last round.
  819. for (let i = 0; i < 4; i++) {
  820. out[dir ? 3 & -i : i] =
  821. sbox[a >>> 24] << 24 ^
  822. sbox[b >> 16 & 255] << 16 ^
  823. sbox[c >> 8 & 255] << 8 ^
  824. sbox[d & 255] ^
  825. key[kIndex++];
  826. a2 = a; a = b; b = c; c = d; d = a2;
  827. }
  828. return out;
  829. }
  830. };
  831. /**
  832. * Random values
  833. * @namespace
  834. */
  835. const random = {
  836. /**
  837. * Generate random words with pure js, cryptographically not as strong & safe as native implementation.
  838. * @param {TypedArray} typedArray The array to fill.
  839. * @return {TypedArray} The random values.
  840. */
  841. getRandomValues(typedArray) {
  842. const words = new Uint32Array(typedArray.buffer);
  843. const r = (m_w) => {
  844. let m_z = 0x3ade68b1;
  845. const mask = 0xffffffff;
  846. return function () {
  847. m_z = (0x9069 * (m_z & 0xFFFF) + (m_z >> 0x10)) & mask;
  848. m_w = (0x4650 * (m_w & 0xFFFF) + (m_w >> 0x10)) & mask;
  849. const result = ((((m_z << 0x10) + m_w) & mask) / 0x100000000) + .5;
  850. return result * (Math.random() > .5 ? 1 : -1);
  851. };
  852. };
  853. for (let i = 0, rcache; i < typedArray.length; i += 4) {
  854. const _r = r((rcache || Math.random()) * 0x100000000);
  855. rcache = _r() * 0x3ade67b7;
  856. words[i / 4] = (_r() * 0x100000000) | 0;
  857. }
  858. return typedArray;
  859. }
  860. };
  861. /** @fileOverview CTR mode implementation.
  862. *
  863. * Special thanks to Roy Nicholson for pointing out a bug in our
  864. * implementation.
  865. *
  866. * @author Emily Stark
  867. * @author Mike Hamburg
  868. * @author Dan Boneh
  869. */
  870. /** Brian Gladman's CTR Mode.
  871. * @constructor
  872. * @param {Object} _prf The aes instance to generate key.
  873. * @param {bitArray} _iv The iv for ctr mode, it must be 128 bits.
  874. */
  875. const mode = {};
  876. /**
  877. * Brian Gladman's CTR Mode.
  878. * @namespace
  879. */
  880. mode.ctrGladman = class {
  881. constructor(prf, iv) {
  882. this._prf = prf;
  883. this._initIv = iv;
  884. this._iv = iv;
  885. }
  886. reset() {
  887. this._iv = this._initIv;
  888. }
  889. /** Input some data to calculate.
  890. * @param {bitArray} data the data to process, it must be intergral multiple of 128 bits unless it's the last.
  891. */
  892. update(data) {
  893. return this.calculate(this._prf, data, this._iv);
  894. }
  895. incWord(word) {
  896. if (((word >> 24) & 0xff) === 0xff) { //overflow
  897. let b1 = (word >> 16) & 0xff;
  898. let b2 = (word >> 8) & 0xff;
  899. let b3 = word & 0xff;
  900. if (b1 === 0xff) { // overflow b1
  901. b1 = 0;
  902. if (b2 === 0xff) {
  903. b2 = 0;
  904. if (b3 === 0xff) {
  905. b3 = 0;
  906. } else {
  907. ++b3;
  908. }
  909. } else {
  910. ++b2;
  911. }
  912. } else {
  913. ++b1;
  914. }
  915. word = 0;
  916. word += (b1 << 16);
  917. word += (b2 << 8);
  918. word += b3;
  919. } else {
  920. word += (0x01 << 24);
  921. }
  922. return word;
  923. }
  924. incCounter(counter) {
  925. if ((counter[0] = this.incWord(counter[0])) === 0) {
  926. // encr_data in fileenc.c from Dr Brian Gladman's counts only with DWORD j < 8
  927. counter[1] = this.incWord(counter[1]);
  928. }
  929. }
  930. calculate(prf, data, iv) {
  931. let l;
  932. if (!(l = data.length)) {
  933. return [];
  934. }
  935. const bl = bitArray.bitLength(data);
  936. for (let i = 0; i < l; i += 4) {
  937. this.incCounter(iv);
  938. const e = prf.encrypt(iv);
  939. data[i] ^= e[0];
  940. data[i + 1] ^= e[1];
  941. data[i + 2] ^= e[2];
  942. data[i + 3] ^= e[3];
  943. }
  944. return bitArray.clamp(data, bl);
  945. }
  946. };
  947. const misc = {
  948. importKey(password) {
  949. return new misc.hmacSha1(codec.bytes.toBits(password));
  950. },
  951. pbkdf2(prf, salt, count, length) {
  952. count = count || 10000;
  953. if (length < 0 || count < 0) {
  954. throw new Error("invalid params to pbkdf2");
  955. }
  956. const byteLength = ((length >> 5) + 1) << 2;
  957. let u, ui, i, j, k;
  958. const arrayBuffer = new ArrayBuffer(byteLength);
  959. const out = new DataView(arrayBuffer);
  960. let outLength = 0;
  961. const b = bitArray;
  962. salt = codec.bytes.toBits(salt);
  963. for (k = 1; outLength < (byteLength || 1); k++) {
  964. u = ui = prf.encrypt(b.concat(salt, [k]));
  965. for (i = 1; i < count; i++) {
  966. ui = prf.encrypt(ui);
  967. for (j = 0; j < ui.length; j++) {
  968. u[j] ^= ui[j];
  969. }
  970. }
  971. for (i = 0; outLength < (byteLength || 1) && i < u.length; i++) {
  972. out.setInt32(outLength, u[i]);
  973. outLength += 4;
  974. }
  975. }
  976. return arrayBuffer.slice(0, length / 8);
  977. }
  978. };
  979. /** @fileOverview HMAC implementation.
  980. *
  981. * @author Emily Stark
  982. * @author Mike Hamburg
  983. * @author Dan Boneh
  984. */
  985. /** HMAC with the specified hash function.
  986. * @constructor
  987. * @param {bitArray} key the key for HMAC.
  988. * @param {Object} [Hash=hash.sha1] The hash function to use.
  989. */
  990. misc.hmacSha1 = class {
  991. constructor(key) {
  992. const hmac = this;
  993. const Hash = hmac._hash = hash.sha1;
  994. const exKey = [[], []];
  995. hmac._baseHash = [new Hash(), new Hash()];
  996. const bs = hmac._baseHash[0].blockSize / 32;
  997. if (key.length > bs) {
  998. key = new Hash().update(key).finalize();
  999. }
  1000. for (let i = 0; i < bs; i++) {
  1001. exKey[0][i] = key[i] ^ 0x36363636;
  1002. exKey[1][i] = key[i] ^ 0x5C5C5C5C;
  1003. }
  1004. hmac._baseHash[0].update(exKey[0]);
  1005. hmac._baseHash[1].update(exKey[1]);
  1006. hmac._resultHash = new Hash(hmac._baseHash[0]);
  1007. }
  1008. reset() {
  1009. const hmac = this;
  1010. hmac._resultHash = new hmac._hash(hmac._baseHash[0]);
  1011. hmac._updated = false;
  1012. }
  1013. update(data) {
  1014. const hmac = this;
  1015. hmac._updated = true;
  1016. hmac._resultHash.update(data);
  1017. }
  1018. digest() {
  1019. const hmac = this;
  1020. const w = hmac._resultHash.finalize();
  1021. const result = new (hmac._hash)(hmac._baseHash[1]).update(w).finalize();
  1022. hmac.reset();
  1023. return result;
  1024. }
  1025. encrypt(data) {
  1026. if (!this._updated) {
  1027. this.update(data);
  1028. return this.digest(data);
  1029. } else {
  1030. throw new Error("encrypt on already updated hmac called!");
  1031. }
  1032. }
  1033. };
  1034. /*
  1035. Copyright (c) 2022 Gildas Lormeau. All rights reserved.
  1036. Redistribution and use in source and binary forms, with or without
  1037. modification, are permitted provided that the following conditions are met:
  1038. 1. Redistributions of source code must retain the above copyright notice,
  1039. this list of conditions and the following disclaimer.
  1040. 2. Redistributions in binary form must reproduce the above copyright
  1041. notice, this list of conditions and the following disclaimer in
  1042. the documentation and/or other materials provided with the distribution.
  1043. 3. The names of the authors may not be used to endorse or promote products
  1044. derived from this software without specific prior written permission.
  1045. THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  1046. INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  1047. FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
  1048. INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
  1049. INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  1050. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
  1051. OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  1052. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  1053. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  1054. EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  1055. */
  1056. const GET_RANDOM_VALUES_SUPPORTED = typeof crypto != UNDEFINED_TYPE && typeof crypto.getRandomValues == FUNCTION_TYPE;
  1057. const ERR_INVALID_PASSWORD = "Invalid password";
  1058. const ERR_INVALID_SIGNATURE = "Invalid signature";
  1059. const ERR_ABORT_CHECK_PASSWORD = "zipjs-abort-check-password";
  1060. function getRandomValues(array) {
  1061. if (GET_RANDOM_VALUES_SUPPORTED) {
  1062. return crypto.getRandomValues(array);
  1063. } else {
  1064. return random.getRandomValues(array);
  1065. }
  1066. }
  1067. /*
  1068. Copyright (c) 2022 Gildas Lormeau. All rights reserved.
  1069. Redistribution and use in source and binary forms, with or without
  1070. modification, are permitted provided that the following conditions are met:
  1071. 1. Redistributions of source code must retain the above copyright notice,
  1072. this list of conditions and the following disclaimer.
  1073. 2. Redistributions in binary form must reproduce the above copyright
  1074. notice, this list of conditions and the following disclaimer in
  1075. the documentation and/or other materials provided with the distribution.
  1076. 3. The names of the authors may not be used to endorse or promote products
  1077. derived from this software without specific prior written permission.
  1078. THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  1079. INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  1080. FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
  1081. INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
  1082. INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  1083. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
  1084. OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  1085. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  1086. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  1087. EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  1088. */
  1089. const BLOCK_LENGTH = 16;
  1090. const RAW_FORMAT = "raw";
  1091. const PBKDF2_ALGORITHM = { name: "PBKDF2" };
  1092. const HASH_ALGORITHM = { name: "HMAC" };
  1093. const HASH_FUNCTION = "SHA-1";
  1094. const BASE_KEY_ALGORITHM = Object.assign({ hash: HASH_ALGORITHM }, PBKDF2_ALGORITHM);
  1095. const DERIVED_BITS_ALGORITHM = Object.assign({ iterations: 1000, hash: { name: HASH_FUNCTION } }, PBKDF2_ALGORITHM);
  1096. const DERIVED_BITS_USAGE = ["deriveBits"];
  1097. const SALT_LENGTH = [8, 12, 16];
  1098. const KEY_LENGTH = [16, 24, 32];
  1099. const SIGNATURE_LENGTH = 10;
  1100. const COUNTER_DEFAULT_VALUE = [0, 0, 0, 0];
  1101. // deno-lint-ignore valid-typeof
  1102. const CRYPTO_API_SUPPORTED = typeof crypto != UNDEFINED_TYPE;
  1103. const subtle = CRYPTO_API_SUPPORTED && crypto.subtle;
  1104. const SUBTLE_API_SUPPORTED = CRYPTO_API_SUPPORTED && typeof subtle != UNDEFINED_TYPE;
  1105. const codecBytes = codec.bytes;
  1106. const Aes = cipher.aes;
  1107. const CtrGladman = mode.ctrGladman;
  1108. const HmacSha1 = misc.hmacSha1;
  1109. let IMPORT_KEY_SUPPORTED = CRYPTO_API_SUPPORTED && SUBTLE_API_SUPPORTED && typeof subtle.importKey == FUNCTION_TYPE;
  1110. let DERIVE_BITS_SUPPORTED = CRYPTO_API_SUPPORTED && SUBTLE_API_SUPPORTED && typeof subtle.deriveBits == FUNCTION_TYPE;
  1111. class AESDecryptionStream extends TransformStream {
  1112. constructor({ password, rawPassword, signed, encryptionStrength, checkPasswordOnly }) {
  1113. super({
  1114. start() {
  1115. Object.assign(this, {
  1116. ready: new Promise(resolve => this.resolveReady = resolve),
  1117. password: encodePassword(password, rawPassword),
  1118. signed,
  1119. strength: encryptionStrength - 1,
  1120. pending: new Uint8Array()
  1121. });
  1122. },
  1123. async transform(chunk, controller) {
  1124. const aesCrypto = this;
  1125. const {
  1126. password,
  1127. strength,
  1128. resolveReady,
  1129. ready
  1130. } = aesCrypto;
  1131. if (password) {
  1132. await createDecryptionKeys(aesCrypto, strength, password, subarray(chunk, 0, SALT_LENGTH[strength] + 2));
  1133. chunk = subarray(chunk, SALT_LENGTH[strength] + 2);
  1134. if (checkPasswordOnly) {
  1135. controller.error(new Error(ERR_ABORT_CHECK_PASSWORD));
  1136. } else {
  1137. resolveReady();
  1138. }
  1139. } else {
  1140. await ready;
  1141. }
  1142. const output = new Uint8Array(chunk.length - SIGNATURE_LENGTH - ((chunk.length - SIGNATURE_LENGTH) % BLOCK_LENGTH));
  1143. controller.enqueue(append(aesCrypto, chunk, output, 0, SIGNATURE_LENGTH, true));
  1144. },
  1145. async flush(controller) {
  1146. const {
  1147. signed,
  1148. ctr,
  1149. hmac,
  1150. pending,
  1151. ready
  1152. } = this;
  1153. if (hmac && ctr) {
  1154. await ready;
  1155. const chunkToDecrypt = subarray(pending, 0, pending.length - SIGNATURE_LENGTH);
  1156. const originalSignature = subarray(pending, pending.length - SIGNATURE_LENGTH);
  1157. let decryptedChunkArray = new Uint8Array();
  1158. if (chunkToDecrypt.length) {
  1159. const encryptedChunk = toBits(codecBytes, chunkToDecrypt);
  1160. hmac.update(encryptedChunk);
  1161. const decryptedChunk = ctr.update(encryptedChunk);
  1162. decryptedChunkArray = fromBits(codecBytes, decryptedChunk);
  1163. }
  1164. if (signed) {
  1165. const signature = subarray(fromBits(codecBytes, hmac.digest()), 0, SIGNATURE_LENGTH);
  1166. for (let indexSignature = 0; indexSignature < SIGNATURE_LENGTH; indexSignature++) {
  1167. if (signature[indexSignature] != originalSignature[indexSignature]) {
  1168. throw new Error(ERR_INVALID_SIGNATURE);
  1169. }
  1170. }
  1171. }
  1172. controller.enqueue(decryptedChunkArray);
  1173. }
  1174. }
  1175. });
  1176. }
  1177. }
  1178. class AESEncryptionStream extends TransformStream {
  1179. constructor({ password, rawPassword, encryptionStrength }) {
  1180. // deno-lint-ignore prefer-const
  1181. let stream;
  1182. super({
  1183. start() {
  1184. Object.assign(this, {
  1185. ready: new Promise(resolve => this.resolveReady = resolve),
  1186. password: encodePassword(password, rawPassword),
  1187. strength: encryptionStrength - 1,
  1188. pending: new Uint8Array()
  1189. });
  1190. },
  1191. async transform(chunk, controller) {
  1192. const aesCrypto = this;
  1193. const {
  1194. password,
  1195. strength,
  1196. resolveReady,
  1197. ready
  1198. } = aesCrypto;
  1199. let preamble = new Uint8Array();
  1200. if (password) {
  1201. preamble = await createEncryptionKeys(aesCrypto, strength, password);
  1202. resolveReady();
  1203. } else {
  1204. await ready;
  1205. }
  1206. const output = new Uint8Array(preamble.length + chunk.length - (chunk.length % BLOCK_LENGTH));
  1207. output.set(preamble, 0);
  1208. controller.enqueue(append(aesCrypto, chunk, output, preamble.length, 0));
  1209. },
  1210. async flush(controller) {
  1211. const {
  1212. ctr,
  1213. hmac,
  1214. pending,
  1215. ready
  1216. } = this;
  1217. if (hmac && ctr) {
  1218. await ready;
  1219. let encryptedChunkArray = new Uint8Array();
  1220. if (pending.length) {
  1221. const encryptedChunk = ctr.update(toBits(codecBytes, pending));
  1222. hmac.update(encryptedChunk);
  1223. encryptedChunkArray = fromBits(codecBytes, encryptedChunk);
  1224. }
  1225. stream.signature = fromBits(codecBytes, hmac.digest()).slice(0, SIGNATURE_LENGTH);
  1226. controller.enqueue(concat(encryptedChunkArray, stream.signature));
  1227. }
  1228. }
  1229. });
  1230. stream = this;
  1231. }
  1232. }
  1233. function append(aesCrypto, input, output, paddingStart, paddingEnd, verifySignature) {
  1234. const {
  1235. ctr,
  1236. hmac,
  1237. pending
  1238. } = aesCrypto;
  1239. const inputLength = input.length - paddingEnd;
  1240. if (pending.length) {
  1241. input = concat(pending, input);
  1242. output = expand(output, inputLength - (inputLength % BLOCK_LENGTH));
  1243. }
  1244. let offset;
  1245. for (offset = 0; offset <= inputLength - BLOCK_LENGTH; offset += BLOCK_LENGTH) {
  1246. const inputChunk = toBits(codecBytes, subarray(input, offset, offset + BLOCK_LENGTH));
  1247. if (verifySignature) {
  1248. hmac.update(inputChunk);
  1249. }
  1250. const outputChunk = ctr.update(inputChunk);
  1251. if (!verifySignature) {
  1252. hmac.update(outputChunk);
  1253. }
  1254. output.set(fromBits(codecBytes, outputChunk), offset + paddingStart);
  1255. }
  1256. aesCrypto.pending = subarray(input, offset);
  1257. return output;
  1258. }
  1259. async function createDecryptionKeys(decrypt, strength, password, preamble) {
  1260. const passwordVerificationKey = await createKeys$1(decrypt, strength, password, subarray(preamble, 0, SALT_LENGTH[strength]));
  1261. const passwordVerification = subarray(preamble, SALT_LENGTH[strength]);
  1262. if (passwordVerificationKey[0] != passwordVerification[0] || passwordVerificationKey[1] != passwordVerification[1]) {
  1263. throw new Error(ERR_INVALID_PASSWORD);
  1264. }
  1265. }
  1266. async function createEncryptionKeys(encrypt, strength, password) {
  1267. const salt = getRandomValues(new Uint8Array(SALT_LENGTH[strength]));
  1268. const passwordVerification = await createKeys$1(encrypt, strength, password, salt);
  1269. return concat(salt, passwordVerification);
  1270. }
  1271. async function createKeys$1(aesCrypto, strength, password, salt) {
  1272. aesCrypto.password = null;
  1273. const baseKey = await importKey(RAW_FORMAT, password, BASE_KEY_ALGORITHM, false, DERIVED_BITS_USAGE);
  1274. const derivedBits = await deriveBits(Object.assign({ salt }, DERIVED_BITS_ALGORITHM), baseKey, 8 * ((KEY_LENGTH[strength] * 2) + 2));
  1275. const compositeKey = new Uint8Array(derivedBits);
  1276. const key = toBits(codecBytes, subarray(compositeKey, 0, KEY_LENGTH[strength]));
  1277. const authentication = toBits(codecBytes, subarray(compositeKey, KEY_LENGTH[strength], KEY_LENGTH[strength] * 2));
  1278. const passwordVerification = subarray(compositeKey, KEY_LENGTH[strength] * 2);
  1279. Object.assign(aesCrypto, {
  1280. keys: {
  1281. key,
  1282. authentication,
  1283. passwordVerification
  1284. },
  1285. ctr: new CtrGladman(new Aes(key), Array.from(COUNTER_DEFAULT_VALUE)),
  1286. hmac: new HmacSha1(authentication)
  1287. });
  1288. return passwordVerification;
  1289. }
  1290. async function importKey(format, password, algorithm, extractable, keyUsages) {
  1291. if (IMPORT_KEY_SUPPORTED) {
  1292. try {
  1293. return await subtle.importKey(format, password, algorithm, extractable, keyUsages);
  1294. } catch {
  1295. IMPORT_KEY_SUPPORTED = false;
  1296. return misc.importKey(password);
  1297. }
  1298. } else {
  1299. return misc.importKey(password);
  1300. }
  1301. }
  1302. async function deriveBits(algorithm, baseKey, length) {
  1303. if (DERIVE_BITS_SUPPORTED) {
  1304. try {
  1305. return await subtle.deriveBits(algorithm, baseKey, length);
  1306. } catch {
  1307. DERIVE_BITS_SUPPORTED = false;
  1308. return misc.pbkdf2(baseKey, algorithm.salt, DERIVED_BITS_ALGORITHM.iterations, length);
  1309. }
  1310. } else {
  1311. return misc.pbkdf2(baseKey, algorithm.salt, DERIVED_BITS_ALGORITHM.iterations, length);
  1312. }
  1313. }
  1314. function encodePassword(password, rawPassword) {
  1315. if (rawPassword === UNDEFINED_VALUE) {
  1316. return encodeText(password);
  1317. } else {
  1318. return rawPassword;
  1319. }
  1320. }
  1321. function concat(leftArray, rightArray) {
  1322. let array = leftArray;
  1323. if (leftArray.length + rightArray.length) {
  1324. array = new Uint8Array(leftArray.length + rightArray.length);
  1325. array.set(leftArray, 0);
  1326. array.set(rightArray, leftArray.length);
  1327. }
  1328. return array;
  1329. }
  1330. function expand(inputArray, length) {
  1331. if (length && length > inputArray.length) {
  1332. const array = inputArray;
  1333. inputArray = new Uint8Array(length);
  1334. inputArray.set(array, 0);
  1335. }
  1336. return inputArray;
  1337. }
  1338. function subarray(array, begin, end) {
  1339. return array.subarray(begin, end);
  1340. }
  1341. function fromBits(codecBytes, chunk) {
  1342. return codecBytes.fromBits(chunk);
  1343. }
  1344. function toBits(codecBytes, chunk) {
  1345. return codecBytes.toBits(chunk);
  1346. }
  1347. /*
  1348. Copyright (c) 2022 Gildas Lormeau. All rights reserved.
  1349. Redistribution and use in source and binary forms, with or without
  1350. modification, are permitted provided that the following conditions are met:
  1351. 1. Redistributions of source code must retain the above copyright notice,
  1352. this list of conditions and the following disclaimer.
  1353. 2. Redistributions in binary form must reproduce the above copyright
  1354. notice, this list of conditions and the following disclaimer in
  1355. the documentation and/or other materials provided with the distribution.
  1356. 3. The names of the authors may not be used to endorse or promote products
  1357. derived from this software without specific prior written permission.
  1358. THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  1359. INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  1360. FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
  1361. INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
  1362. INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  1363. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
  1364. OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  1365. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  1366. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  1367. EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  1368. */
  1369. const HEADER_LENGTH = 12;
  1370. class ZipCryptoDecryptionStream extends TransformStream {
  1371. constructor({ password, passwordVerification, checkPasswordOnly }) {
  1372. super({
  1373. start() {
  1374. Object.assign(this, {
  1375. password,
  1376. passwordVerification
  1377. });
  1378. createKeys(this, password);
  1379. },
  1380. transform(chunk, controller) {
  1381. const zipCrypto = this;
  1382. if (zipCrypto.password) {
  1383. const decryptedHeader = decrypt(zipCrypto, chunk.subarray(0, HEADER_LENGTH));
  1384. zipCrypto.password = null;
  1385. if (decryptedHeader.at(-1) != zipCrypto.passwordVerification) {
  1386. throw new Error(ERR_INVALID_PASSWORD);
  1387. }
  1388. chunk = chunk.subarray(HEADER_LENGTH);
  1389. }
  1390. if (checkPasswordOnly) {
  1391. controller.error(new Error(ERR_ABORT_CHECK_PASSWORD));
  1392. } else {
  1393. controller.enqueue(decrypt(zipCrypto, chunk));
  1394. }
  1395. }
  1396. });
  1397. }
  1398. }
  1399. class ZipCryptoEncryptionStream extends TransformStream {
  1400. constructor({ password, passwordVerification }) {
  1401. super({
  1402. start() {
  1403. Object.assign(this, {
  1404. password,
  1405. passwordVerification
  1406. });
  1407. createKeys(this, password);
  1408. },
  1409. transform(chunk, controller) {
  1410. const zipCrypto = this;
  1411. let output;
  1412. let offset;
  1413. if (zipCrypto.password) {
  1414. zipCrypto.password = null;
  1415. const header = getRandomValues(new Uint8Array(HEADER_LENGTH));
  1416. header[HEADER_LENGTH - 1] = zipCrypto.passwordVerification;
  1417. output = new Uint8Array(chunk.length + header.length);
  1418. output.set(encrypt(zipCrypto, header), 0);
  1419. offset = HEADER_LENGTH;
  1420. } else {
  1421. output = new Uint8Array(chunk.length);
  1422. offset = 0;
  1423. }
  1424. output.set(encrypt(zipCrypto, chunk), offset);
  1425. controller.enqueue(output);
  1426. }
  1427. });
  1428. }
  1429. }
  1430. function decrypt(target, input) {
  1431. const output = new Uint8Array(input.length);
  1432. for (let index = 0; index < input.length; index++) {
  1433. output[index] = getByte(target) ^ input[index];
  1434. updateKeys(target, output[index]);
  1435. }
  1436. return output;
  1437. }
  1438. function encrypt(target, input) {
  1439. const output = new Uint8Array(input.length);
  1440. for (let index = 0; index < input.length; index++) {
  1441. output[index] = getByte(target) ^ input[index];
  1442. updateKeys(target, input[index]);
  1443. }
  1444. return output;
  1445. }
  1446. function createKeys(target, password) {
  1447. const keys = [0x12345678, 0x23456789, 0x34567890];
  1448. Object.assign(target, {
  1449. keys,
  1450. crcKey0: new Crc32(keys[0]),
  1451. crcKey2: new Crc32(keys[2])
  1452. });
  1453. for (let index = 0; index < password.length; index++) {
  1454. updateKeys(target, password.charCodeAt(index));
  1455. }
  1456. }
  1457. function updateKeys(target, byte) {
  1458. let [key0, key1, key2] = target.keys;
  1459. target.crcKey0.append([byte]);
  1460. key0 = ~target.crcKey0.get();
  1461. key1 = getInt32(Math.imul(getInt32(key1 + getInt8(key0)), 134775813) + 1);
  1462. target.crcKey2.append([key1 >>> 24]);
  1463. key2 = ~target.crcKey2.get();
  1464. target.keys = [key0, key1, key2];
  1465. }
  1466. function getByte(target) {
  1467. const temp = target.keys[2] | 2;
  1468. return getInt8(Math.imul(temp, (temp ^ 1)) >>> 8);
  1469. }
  1470. function getInt8(number) {
  1471. return number & 0xFF;
  1472. }
  1473. function getInt32(number) {
  1474. return number & 0xFFFFFFFF;
  1475. }
  1476. /*
  1477. Copyright (c) 2025 Gildas Lormeau. All rights reserved.
  1478. Redistribution and use in source and binary forms, with or without
  1479. modification, are permitted provided that the following conditions are met:
  1480. 1. Redistributions of source code must retain the above copyright notice,
  1481. this list of conditions and the following disclaimer.
  1482. 2. Redistributions in binary form must reproduce the above copyright
  1483. notice, this list of conditions and the following disclaimer in
  1484. the documentation and/or other materials provided with the distribution.
  1485. 3. The names of the authors may not be used to endorse or promote products
  1486. derived from this software without specific prior written permission.
  1487. THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  1488. INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  1489. FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
  1490. INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
  1491. INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  1492. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
  1493. OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  1494. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  1495. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  1496. EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  1497. */
  1498. const ERR_INVALID_UNCOMPRESSED_SIZE = "Invalid uncompressed size";
  1499. const FORMAT_DEFLATE_RAW = "deflate-raw";
  1500. const FORMAT_DEFLATE64_RAW = "deflate64-raw";
  1501. class DeflateStream extends TransformStream {
  1502. constructor(options, { chunkSize, CompressionStreamZlib, CompressionStream }) {
  1503. super({});
  1504. const { compressed, encrypted, useCompressionStream, zipCrypto, signed, level } = options;
  1505. const stream = this;
  1506. let crc32Stream, encryptionStream;
  1507. let readable = super.readable;
  1508. if ((!encrypted || zipCrypto) && signed) {
  1509. crc32Stream = new Crc32Stream();
  1510. readable = pipeThrough(readable, crc32Stream);
  1511. }
  1512. if (compressed) {
  1513. readable = pipeThroughCommpressionStream(readable, useCompressionStream, { level, chunkSize }, CompressionStream, CompressionStreamZlib, CompressionStream);
  1514. }
  1515. if (encrypted) {
  1516. if (zipCrypto) {
  1517. readable = pipeThrough(readable, new ZipCryptoEncryptionStream(options));
  1518. } else {
  1519. encryptionStream = new AESEncryptionStream(options);
  1520. readable = pipeThrough(readable, encryptionStream);
  1521. }
  1522. }
  1523. setReadable(stream, readable, () => {
  1524. let signature;
  1525. if (encrypted && !zipCrypto) {
  1526. signature = encryptionStream.signature;
  1527. }
  1528. if ((!encrypted || zipCrypto) && signed) {
  1529. signature = new DataView(crc32Stream.value.buffer).getUint32(0);
  1530. }
  1531. stream.signature = signature;
  1532. });
  1533. }
  1534. }
  1535. class InflateStream extends TransformStream {
  1536. constructor(options, { chunkSize, DecompressionStreamZlib, DecompressionStream }) {
  1537. super({});
  1538. const { zipCrypto, encrypted, signed, signature, compressed, useCompressionStream, deflate64 } = options;
  1539. let crc32Stream, decryptionStream;
  1540. let readable = super.readable;
  1541. if (encrypted) {
  1542. if (zipCrypto) {
  1543. readable = pipeThrough(readable, new ZipCryptoDecryptionStream(options));
  1544. } else {
  1545. decryptionStream = new AESDecryptionStream(options);
  1546. readable = pipeThrough(readable, decryptionStream);
  1547. }
  1548. }
  1549. if (compressed) {
  1550. readable = pipeThroughCommpressionStream(readable, useCompressionStream, { chunkSize, deflate64 }, DecompressionStream, DecompressionStreamZlib, DecompressionStream);
  1551. }
  1552. if ((!encrypted || zipCrypto) && signed) {
  1553. crc32Stream = new Crc32Stream();
  1554. readable = pipeThrough(readable, crc32Stream);
  1555. }
  1556. setReadable(this, readable, () => {
  1557. if ((!encrypted || zipCrypto) && signed) {
  1558. const dataViewSignature = new DataView(crc32Stream.value.buffer);
  1559. if (signature != dataViewSignature.getUint32(0, false)) {
  1560. throw new Error(ERR_INVALID_SIGNATURE);
  1561. }
  1562. }
  1563. });
  1564. }
  1565. }
  1566. function setReadable(stream, readable, flush) {
  1567. readable = pipeThrough(readable, new TransformStream({ flush }));
  1568. Object.defineProperty(stream, "readable", {
  1569. get() {
  1570. return readable;
  1571. }
  1572. });
  1573. }
  1574. function pipeThroughCommpressionStream(readable, useCompressionStream, options, CompressionStreamNative, CompressionStreamZlib, CompressionStream) {
  1575. const Stream = useCompressionStream && CompressionStreamNative ? CompressionStreamNative : CompressionStreamZlib || CompressionStream;
  1576. const format = options.deflate64 ? FORMAT_DEFLATE64_RAW : FORMAT_DEFLATE_RAW;
  1577. try {
  1578. readable = pipeThrough(readable, new Stream(format, options));
  1579. } catch (error) {
  1580. if (useCompressionStream) {
  1581. if (CompressionStreamZlib) {
  1582. readable = pipeThrough(readable, new CompressionStreamZlib(format, options));
  1583. } else if (CompressionStream) {
  1584. readable = pipeThrough(readable, new CompressionStream(format, options));
  1585. } else {
  1586. throw error;
  1587. }
  1588. } else {
  1589. throw error;
  1590. }
  1591. }
  1592. return readable;
  1593. }
  1594. function pipeThrough(readable, transformStream) {
  1595. return readable.pipeThrough(transformStream);
  1596. }
  1597. /*
  1598. Copyright (c) 2022 Gildas Lormeau. All rights reserved.
  1599. Redistribution and use in source and binary forms, with or without
  1600. modification, are permitted provided that the following conditions are met:
  1601. 1. Redistributions of source code must retain the above copyright notice,
  1602. this list of conditions and the following disclaimer.
  1603. 2. Redistributions in binary form must reproduce the above copyright
  1604. notice, this list of conditions and the following disclaimer in
  1605. the documentation and/or other materials provided with the distribution.
  1606. 3. The names of the authors may not be used to endorse or promote products
  1607. derived from this software without specific prior written permission.
  1608. THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  1609. INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  1610. FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
  1611. INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
  1612. INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  1613. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
  1614. OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  1615. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  1616. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  1617. EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  1618. */
  1619. const MESSAGE_EVENT_TYPE = "message";
  1620. const MESSAGE_START = "start";
  1621. const MESSAGE_PULL = "pull";
  1622. const MESSAGE_DATA = "data";
  1623. const MESSAGE_ACK_DATA = "ack";
  1624. const MESSAGE_CLOSE = "close";
  1625. const CODEC_DEFLATE = "deflate";
  1626. const CODEC_INFLATE = "inflate";
  1627. class CodecStream extends TransformStream {
  1628. constructor(options, config) {
  1629. super({});
  1630. const codec = this;
  1631. const { codecType } = options;
  1632. let Stream;
  1633. if (codecType.startsWith(CODEC_DEFLATE)) {
  1634. Stream = DeflateStream;
  1635. } else if (codecType.startsWith(CODEC_INFLATE)) {
  1636. Stream = InflateStream;
  1637. }
  1638. codec.outputSize = 0;
  1639. let inputSize = 0;
  1640. const stream = new Stream(options, config);
  1641. const readable = super.readable;
  1642. const inputSizeStream = new TransformStream({
  1643. transform(chunk, controller) {
  1644. if (chunk && chunk.length) {
  1645. inputSize += chunk.length;
  1646. controller.enqueue(chunk);
  1647. }
  1648. },
  1649. flush() {
  1650. Object.assign(codec, {
  1651. inputSize
  1652. });
  1653. }
  1654. });
  1655. const outputSizeStream = new TransformStream({
  1656. transform(chunk, controller) {
  1657. if (chunk && chunk.length) {
  1658. controller.enqueue(chunk);
  1659. codec.outputSize += chunk.length;
  1660. if (options.outputSize !== UNDEFINED_VALUE && codec.outputSize > options.outputSize) {
  1661. throw new Error(ERR_INVALID_UNCOMPRESSED_SIZE);
  1662. }
  1663. }
  1664. },
  1665. flush() {
  1666. const { signature } = stream;
  1667. Object.assign(codec, {
  1668. signature,
  1669. inputSize
  1670. });
  1671. }
  1672. });
  1673. Object.defineProperty(codec, "readable", {
  1674. get() {
  1675. return readable.pipeThrough(inputSizeStream).pipeThrough(stream).pipeThrough(outputSizeStream);
  1676. }
  1677. });
  1678. }
  1679. }
  1680. class ChunkStream extends TransformStream {
  1681. constructor(chunkSize) {
  1682. let pendingChunk;
  1683. super({
  1684. transform,
  1685. flush(controller) {
  1686. if (pendingChunk && pendingChunk.length) {
  1687. controller.enqueue(pendingChunk);
  1688. }
  1689. }
  1690. });
  1691. function transform(chunk, controller) {
  1692. if (pendingChunk) {
  1693. const newChunk = new Uint8Array(pendingChunk.length + chunk.length);
  1694. newChunk.set(pendingChunk);
  1695. newChunk.set(chunk, pendingChunk.length);
  1696. chunk = newChunk;
  1697. pendingChunk = null;
  1698. }
  1699. if (chunk.length > chunkSize) {
  1700. controller.enqueue(chunk.slice(0, chunkSize));
  1701. transform(chunk.slice(chunkSize), controller);
  1702. } else {
  1703. pendingChunk = chunk;
  1704. }
  1705. }
  1706. }
  1707. }
  1708. /*
  1709. Copyright (c) 2025 Gildas Lormeau. All rights reserved.
  1710. Redistribution and use in source and binary forms, with or without
  1711. modification, are permitted provided that the following conditions are met:
  1712. 1. Redistributions of source code must retain the above copyright notice,
  1713. this list of conditions and the following disclaimer.
  1714. 2. Redistributions in binary form must reproduce the above copyright
  1715. notice, this list of conditions and the following disclaimer in
  1716. the documentation and/or other materials provided with the distribution.
  1717. 3. The names of the authors may not be used to endorse or promote products
  1718. derived from this software without specific prior written permission.
  1719. THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  1720. INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  1721. FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
  1722. INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
  1723. INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  1724. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
  1725. OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  1726. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  1727. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  1728. EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  1729. */
  1730. const MODULE_WORKER_OPTIONS = { type: "module" };
  1731. let webWorkerSupported, webWorkerURI, webWorkerOptions;
  1732. let transferStreamsSupported = true;
  1733. try {
  1734. transferStreamsSupported = typeof structuredClone == FUNCTION_TYPE && structuredClone(new DOMException("", "AbortError")).code !== UNDEFINED_VALUE;
  1735. } catch {
  1736. // ignored
  1737. }
  1738. let initModule$1 = () => { };
  1739. function configureWorker({ initModule: initModuleFunction }) {
  1740. initModule$1 = initModuleFunction;
  1741. }
  1742. class CodecWorker {
  1743. constructor(workerData, { readable, writable }, { options, config, streamOptions, useWebWorkers, transferStreams, workerURI }, onTaskFinished) {
  1744. const { signal } = streamOptions;
  1745. Object.assign(workerData, {
  1746. busy: true,
  1747. readable: readable
  1748. .pipeThrough(new ChunkStream(config.chunkSize))
  1749. .pipeThrough(new ProgressWatcherStream(streamOptions), { signal }),
  1750. writable,
  1751. options: Object.assign({}, options),
  1752. workerURI,
  1753. transferStreams,
  1754. terminate() {
  1755. return new Promise(resolve => {
  1756. const { worker, busy } = workerData;
  1757. if (worker) {
  1758. if (busy) {
  1759. workerData.resolveTerminated = resolve;
  1760. } else {
  1761. worker.terminate();
  1762. resolve();
  1763. }
  1764. workerData.interface = null;
  1765. } else {
  1766. resolve();
  1767. }
  1768. });
  1769. },
  1770. onTaskFinished() {
  1771. const { resolveTerminated } = workerData;
  1772. if (resolveTerminated) {
  1773. workerData.resolveTerminated = null;
  1774. workerData.terminated = true;
  1775. workerData.worker.terminate();
  1776. resolveTerminated();
  1777. }
  1778. workerData.busy = false;
  1779. onTaskFinished(workerData);
  1780. }
  1781. });
  1782. if (webWorkerSupported === UNDEFINED_VALUE) {
  1783. // deno-lint-ignore valid-typeof
  1784. webWorkerSupported = typeof Worker != UNDEFINED_TYPE;
  1785. }
  1786. return (useWebWorkers && webWorkerSupported ? createWebWorkerInterface : createWorkerInterface)(workerData, config);
  1787. }
  1788. }
  1789. class ProgressWatcherStream extends TransformStream {
  1790. constructor({ onstart, onprogress, size, onend }) {
  1791. let chunkOffset = 0;
  1792. super({
  1793. async start() {
  1794. if (onstart) {
  1795. await callHandler(onstart, size);
  1796. }
  1797. },
  1798. async transform(chunk, controller) {
  1799. chunkOffset += chunk.length;
  1800. if (onprogress) {
  1801. await callHandler(onprogress, chunkOffset, size);
  1802. }
  1803. controller.enqueue(chunk);
  1804. },
  1805. async flush() {
  1806. if (onend) {
  1807. await callHandler(onend, chunkOffset);
  1808. }
  1809. }
  1810. });
  1811. }
  1812. }
  1813. async function callHandler(handler, ...parameters) {
  1814. try {
  1815. await handler(...parameters);
  1816. } catch {
  1817. // ignored
  1818. }
  1819. }
  1820. function createWorkerInterface(workerData, config) {
  1821. return {
  1822. run: () => runWorker$1(workerData, config)
  1823. };
  1824. }
  1825. function createWebWorkerInterface(workerData, config) {
  1826. const { baseURI, chunkSize } = config;
  1827. let { wasmURI } = config;
  1828. if (!workerData.interface) {
  1829. // deno-lint-ignore valid-typeof
  1830. if (typeof wasmURI == FUNCTION_TYPE) {
  1831. wasmURI = wasmURI();
  1832. }
  1833. let worker;
  1834. try {
  1835. worker = getWebWorker(workerData.workerURI, baseURI, workerData);
  1836. } catch {
  1837. webWorkerSupported = false;
  1838. return createWorkerInterface(workerData, config);
  1839. }
  1840. Object.assign(workerData, {
  1841. worker,
  1842. interface: {
  1843. run: () => runWebWorker(workerData, { chunkSize, wasmURI, baseURI })
  1844. }
  1845. });
  1846. }
  1847. return workerData.interface;
  1848. }
  1849. async function runWorker$1({ options, readable, writable, onTaskFinished }, config) {
  1850. let codecStream;
  1851. try {
  1852. if (!options.useCompressionStream) {
  1853. try {
  1854. await initModule$1(config);
  1855. } catch {
  1856. options.useCompressionStream = true;
  1857. }
  1858. }
  1859. codecStream = new CodecStream(options, config);
  1860. await readable.pipeThrough(codecStream).pipeTo(writable, { preventClose: true, preventAbort: true });
  1861. const {
  1862. signature,
  1863. inputSize,
  1864. outputSize
  1865. } = codecStream;
  1866. return {
  1867. signature,
  1868. inputSize,
  1869. outputSize
  1870. };
  1871. } catch (error) {
  1872. if (codecStream) {
  1873. error.outputSize = codecStream.outputSize;
  1874. }
  1875. throw error;
  1876. } finally {
  1877. onTaskFinished();
  1878. }
  1879. }
  1880. async function runWebWorker(workerData, config) {
  1881. let resolveResult, rejectResult;
  1882. const result = new Promise((resolve, reject) => {
  1883. resolveResult = resolve;
  1884. rejectResult = reject;
  1885. });
  1886. Object.assign(workerData, {
  1887. reader: null,
  1888. writer: null,
  1889. resolveResult,
  1890. rejectResult,
  1891. result
  1892. });
  1893. const { readable, options } = workerData;
  1894. const { writable, closed } = watchClosedStream(workerData.writable);
  1895. const streamsTransferred = sendMessage({
  1896. type: MESSAGE_START,
  1897. options,
  1898. config,
  1899. readable,
  1900. writable
  1901. }, workerData);
  1902. if (!streamsTransferred) {
  1903. Object.assign(workerData, {
  1904. reader: readable.getReader(),
  1905. writer: writable.getWriter()
  1906. });
  1907. }
  1908. const resultValue = await result;
  1909. if (!streamsTransferred) {
  1910. await writable.getWriter().close();
  1911. }
  1912. await closed;
  1913. return resultValue;
  1914. }
  1915. function watchClosedStream(writableSource) {
  1916. const { writable, readable } = new TransformStream();
  1917. const closed = readable.pipeTo(writableSource, { preventClose: true });
  1918. return { writable, closed };
  1919. }
  1920. function getWebWorker(url, baseURI, workerData, isModuleType, useBlobURI = true) {
  1921. let worker, resolvedURI, resolvedOptions;
  1922. if (webWorkerURI === UNDEFINED_VALUE) {
  1923. // deno-lint-ignore valid-typeof
  1924. const isFunctionURI = typeof url == FUNCTION_TYPE;
  1925. if (isFunctionURI) {
  1926. resolvedURI = url(useBlobURI);
  1927. } else {
  1928. resolvedURI = url;
  1929. }
  1930. const isDataURI = resolvedURI.startsWith("data:");
  1931. const isBlobURI = resolvedURI.startsWith("blob:");
  1932. if (isDataURI || isBlobURI) {
  1933. if (isModuleType === UNDEFINED_VALUE) {
  1934. isModuleType = false;
  1935. }
  1936. if (isModuleType) {
  1937. resolvedOptions = MODULE_WORKER_OPTIONS;
  1938. }
  1939. try {
  1940. worker = new Worker(resolvedURI, resolvedOptions);
  1941. } catch (error) {
  1942. if (isBlobURI) {
  1943. try {
  1944. URL.revokeObjectURL(resolvedURI);
  1945. } catch {
  1946. // ignored
  1947. }
  1948. }
  1949. if (isFunctionURI && isBlobURI) {
  1950. return getWebWorker(url, baseURI, workerData, isModuleType, false);
  1951. } else if (!isModuleType) {
  1952. return getWebWorker(url, baseURI, workerData, true, false);
  1953. } else {
  1954. throw error;
  1955. }
  1956. }
  1957. } else {
  1958. if (isModuleType === UNDEFINED_VALUE) {
  1959. isModuleType = true;
  1960. }
  1961. if (isModuleType) {
  1962. resolvedOptions = MODULE_WORKER_OPTIONS;
  1963. }
  1964. try {
  1965. resolvedURI = new URL(resolvedURI, baseURI);
  1966. } catch {
  1967. // ignored
  1968. }
  1969. try {
  1970. worker = new Worker(resolvedURI, resolvedOptions);
  1971. } catch (error) {
  1972. if (!isModuleType) {
  1973. return getWebWorker(url, baseURI, workerData, false, useBlobURI);
  1974. } else {
  1975. throw error;
  1976. }
  1977. }
  1978. }
  1979. webWorkerURI = resolvedURI;
  1980. webWorkerOptions = resolvedOptions;
  1981. } else {
  1982. worker = new Worker(webWorkerURI, webWorkerOptions);
  1983. }
  1984. worker.addEventListener(MESSAGE_EVENT_TYPE, event => onMessage(event, workerData));
  1985. return worker;
  1986. }
  1987. function sendMessage(message, { worker, writer, onTaskFinished, transferStreams }) {
  1988. try {
  1989. const { value, readable, writable } = message;
  1990. const transferables = [];
  1991. if (value) {
  1992. message.value = value;
  1993. transferables.push(message.value.buffer);
  1994. }
  1995. if (transferStreams && transferStreamsSupported) {
  1996. if (readable) {
  1997. transferables.push(readable);
  1998. }
  1999. if (writable) {
  2000. transferables.push(writable);
  2001. }
  2002. } else {
  2003. message.readable = message.writable = null;
  2004. }
  2005. if (transferables.length) {
  2006. try {
  2007. worker.postMessage(message, transferables);
  2008. return true;
  2009. } catch {
  2010. transferStreamsSupported = false;
  2011. message.readable = message.writable = null;
  2012. worker.postMessage(message);
  2013. }
  2014. } else {
  2015. worker.postMessage(message);
  2016. }
  2017. } catch (error) {
  2018. if (writer) {
  2019. writer.releaseLock();
  2020. }
  2021. onTaskFinished();
  2022. throw error;
  2023. }
  2024. }
  2025. async function onMessage({ data }, workerData) {
  2026. const { type, value, messageId, result, error } = data;
  2027. const { reader, writer, resolveResult, rejectResult, onTaskFinished } = workerData;
  2028. try {
  2029. if (error) {
  2030. const { message, stack, code, name, outputSize } = error;
  2031. const responseError = new Error(message);
  2032. Object.assign(responseError, { stack, code, name, outputSize });
  2033. close(responseError);
  2034. } else {
  2035. if (type == MESSAGE_PULL) {
  2036. const { value, done } = await reader.read();
  2037. sendMessage({ type: MESSAGE_DATA, value, done, messageId }, workerData);
  2038. }
  2039. if (type == MESSAGE_DATA) {
  2040. await writer.ready;
  2041. await writer.write(new Uint8Array(value));
  2042. sendMessage({ type: MESSAGE_ACK_DATA, messageId }, workerData);
  2043. }
  2044. if (type == MESSAGE_CLOSE) {
  2045. close(null, result);
  2046. }
  2047. }
  2048. } catch (error) {
  2049. sendMessage({ type: MESSAGE_CLOSE, messageId }, workerData);
  2050. close(error);
  2051. }
  2052. function close(error, result) {
  2053. if (error) {
  2054. rejectResult(error);
  2055. } else {
  2056. resolveResult(result);
  2057. }
  2058. if (writer) {
  2059. writer.releaseLock();
  2060. }
  2061. onTaskFinished();
  2062. }
  2063. }
  2064. /*
  2065. Copyright (c) 2025 Gildas Lormeau. All rights reserved.
  2066. Redistribution and use in source and binary forms, with or without
  2067. modification, are permitted provided that the following conditions are met:
  2068. 1. Redistributions of source code must retain the above copyright notice,
  2069. this list of conditions and the following disclaimer.
  2070. 2. Redistributions in binary form must reproduce the above copyright
  2071. notice, this list of conditions and the following disclaimer in
  2072. the documentation and/or other materials provided with the distribution.
  2073. 3. The names of the authors may not be used to endorse or promote products
  2074. derived from this software without specific prior written permission.
  2075. THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  2076. INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  2077. FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
  2078. INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
  2079. INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  2080. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
  2081. OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  2082. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  2083. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  2084. EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  2085. */
  2086. let pool = [];
  2087. const pendingRequests = [];
  2088. let indexWorker = 0;
  2089. async function runWorker(stream, workerOptions) {
  2090. const { options, config } = workerOptions;
  2091. const { transferStreams, useWebWorkers, useCompressionStream, compressed, signed, encrypted } = options;
  2092. const { workerURI, maxWorkers } = config;
  2093. workerOptions.transferStreams = transferStreams || transferStreams === UNDEFINED_VALUE;
  2094. const streamCopy = !compressed && !signed && !encrypted && !workerOptions.transferStreams;
  2095. workerOptions.useWebWorkers = !streamCopy && (useWebWorkers || (useWebWorkers === UNDEFINED_VALUE && config.useWebWorkers));
  2096. workerOptions.workerURI = workerOptions.useWebWorkers && workerURI ? workerURI : UNDEFINED_VALUE;
  2097. options.useCompressionStream = useCompressionStream || (useCompressionStream === UNDEFINED_VALUE && config.useCompressionStream);
  2098. return (await getWorker()).run();
  2099. // deno-lint-ignore require-await
  2100. async function getWorker() {
  2101. const workerData = pool.find(workerData => !workerData.busy);
  2102. if (workerData) {
  2103. clearTerminateTimeout(workerData);
  2104. return new CodecWorker(workerData, stream, workerOptions, onTaskFinished);
  2105. } else if (pool.length < maxWorkers) {
  2106. const workerData = { indexWorker };
  2107. indexWorker++;
  2108. pool.push(workerData);
  2109. return new CodecWorker(workerData, stream, workerOptions, onTaskFinished);
  2110. } else {
  2111. return new Promise(resolve => pendingRequests.push({ resolve, stream, workerOptions }));
  2112. }
  2113. }
  2114. function onTaskFinished(workerData) {
  2115. if (pendingRequests.length) {
  2116. const [{ resolve, stream, workerOptions }] = pendingRequests.splice(0, 1);
  2117. resolve(new CodecWorker(workerData, stream, workerOptions, onTaskFinished));
  2118. } else if (workerData.worker) {
  2119. clearTerminateTimeout(workerData);
  2120. terminateWorker(workerData, workerOptions);
  2121. } else {
  2122. pool = pool.filter(data => data != workerData);
  2123. }
  2124. }
  2125. }
  2126. function terminateWorker(workerData, workerOptions) {
  2127. const { config } = workerOptions;
  2128. const { terminateWorkerTimeout } = config;
  2129. if (Number.isFinite(terminateWorkerTimeout) && terminateWorkerTimeout >= 0) {
  2130. if (workerData.terminated) {
  2131. workerData.terminated = false;
  2132. } else {
  2133. workerData.terminateTimeout = setTimeout(async () => {
  2134. pool = pool.filter(data => data != workerData);
  2135. try {
  2136. await workerData.terminate();
  2137. } catch {
  2138. // ignored
  2139. }
  2140. }, terminateWorkerTimeout);
  2141. }
  2142. }
  2143. }
  2144. function clearTerminateTimeout(workerData) {
  2145. const { terminateTimeout } = workerData;
  2146. if (terminateTimeout) {
  2147. clearTimeout(terminateTimeout);
  2148. workerData.terminateTimeout = null;
  2149. }
  2150. }
  2151. async function terminateWorkers() {
  2152. await Promise.allSettled(pool.map(workerData => {
  2153. clearTerminateTimeout(workerData);
  2154. return workerData.terminate();
  2155. }));
  2156. }
  2157. /*
  2158. Copyright (c) 2025 Gildas Lormeau. All rights reserved.
  2159. Redistribution and use in source and binary forms, with or without
  2160. modification, are permitted provided that the following conditions are met:
  2161. 1. Redistributions of source code must retain the above copyright notice,
  2162. this list of conditions and the following disclaimer.
  2163. 2. Redistributions in binary form must reproduce the above copyright
  2164. notice, this list of conditions and the following disclaimer in
  2165. the documentation and/or other materials provided with the distribution.
  2166. 3. The names of the authors may not be used to endorse or promote products
  2167. derived from this software without specific prior written permission.
  2168. THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  2169. INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  2170. FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
  2171. INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
  2172. INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  2173. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
  2174. OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  2175. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  2176. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  2177. EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  2178. */
  2179. const ERR_HTTP_STATUS = "HTTP error ";
  2180. const ERR_HTTP_RANGE = "HTTP Range not supported";
  2181. const ERR_ITERATOR_COMPLETED_TOO_SOON = "Writer iterator completed too soon";
  2182. const ERR_WRITER_NOT_INITIALIZED = "Writer not initialized";
  2183. const CONTENT_TYPE_TEXT_PLAIN = "text/plain";
  2184. const HTTP_HEADER_CONTENT_LENGTH = "Content-Length";
  2185. const HTTP_HEADER_CONTENT_RANGE = "Content-Range";
  2186. const HTTP_HEADER_ACCEPT_RANGES = "Accept-Ranges";
  2187. const HTTP_HEADER_RANGE = "Range";
  2188. const HTTP_HEADER_CONTENT_TYPE = "Content-Type";
  2189. const HTTP_METHOD_HEAD = "HEAD";
  2190. const HTTP_METHOD_GET = "GET";
  2191. const HTTP_RANGE_UNIT = "bytes";
  2192. const DEFAULT_CHUNK_SIZE = 64 * 1024;
  2193. const DEFAULT_BUFFER_SIZE = 256 * 1024;
  2194. const PROPERTY_NAME_WRITABLE = "writable";
  2195. class Stream {
  2196. constructor() {
  2197. this.size = 0;
  2198. }
  2199. init() {
  2200. this.initialized = true;
  2201. }
  2202. }
  2203. class Reader extends Stream {
  2204. get readable() {
  2205. const reader = this;
  2206. const { chunkSize = DEFAULT_CHUNK_SIZE } = reader;
  2207. const readable = new ReadableStream({
  2208. start() {
  2209. this.chunkOffset = 0;
  2210. },
  2211. async pull(controller) {
  2212. const { offset = 0, size, diskNumberStart } = readable;
  2213. const { chunkOffset } = this;
  2214. const dataSize = size === UNDEFINED_VALUE ? chunkSize : Math.min(chunkSize, size - chunkOffset);
  2215. const data = await readUint8Array(reader, offset + chunkOffset, dataSize, diskNumberStart);
  2216. controller.enqueue(data);
  2217. if ((chunkOffset + chunkSize > size) || (size === UNDEFINED_VALUE && !data.length && dataSize)) {
  2218. controller.close();
  2219. } else {
  2220. this.chunkOffset += chunkSize;
  2221. }
  2222. }
  2223. });
  2224. return readable;
  2225. }
  2226. }
  2227. class Writer extends Stream {
  2228. constructor() {
  2229. super();
  2230. const writer = this;
  2231. const writable = new WritableStream({
  2232. write(chunk) {
  2233. if (!writer.initialized) {
  2234. throw new Error(ERR_WRITER_NOT_INITIALIZED);
  2235. }
  2236. return writer.writeUint8Array(chunk);
  2237. }
  2238. });
  2239. Object.defineProperty(writer, PROPERTY_NAME_WRITABLE, {
  2240. get() {
  2241. return writable;
  2242. }
  2243. });
  2244. }
  2245. writeUint8Array() {
  2246. // abstract
  2247. }
  2248. }
  2249. class Data64URIReader extends Reader {
  2250. constructor(dataURI) {
  2251. super();
  2252. let dataEnd = dataURI.length;
  2253. while (dataURI.charAt(dataEnd - 1) == "=") {
  2254. dataEnd--;
  2255. }
  2256. const dataStart = dataURI.indexOf(",") + 1;
  2257. Object.assign(this, {
  2258. dataURI,
  2259. dataStart,
  2260. size: Math.floor((dataEnd - dataStart) * 0.75)
  2261. });
  2262. }
  2263. readUint8Array(offset, length) {
  2264. const {
  2265. dataStart,
  2266. dataURI
  2267. } = this;
  2268. const dataArray = new Uint8Array(length);
  2269. const start = Math.floor(offset / 3) * 4;
  2270. const bytes = atob(dataURI.substring(start + dataStart, Math.ceil((offset + length) / 3) * 4 + dataStart));
  2271. const delta = offset - Math.floor(start / 4) * 3;
  2272. let effectiveLength = 0;
  2273. for (let indexByte = delta; indexByte < delta + length && indexByte < bytes.length; indexByte++) {
  2274. dataArray[indexByte - delta] = bytes.charCodeAt(indexByte);
  2275. effectiveLength++;
  2276. }
  2277. if (effectiveLength < dataArray.length) {
  2278. return dataArray.subarray(0, effectiveLength);
  2279. } else {
  2280. return dataArray;
  2281. }
  2282. }
  2283. }
  2284. class Data64URIWriter extends Writer {
  2285. constructor(contentType) {
  2286. super();
  2287. Object.assign(this, {
  2288. data: "data:" + (contentType || "") + ";base64,",
  2289. pending: []
  2290. });
  2291. }
  2292. writeUint8Array(array) {
  2293. const writer = this;
  2294. let indexArray = 0;
  2295. let dataString = writer.pending;
  2296. const delta = writer.pending.length;
  2297. writer.pending = "";
  2298. for (indexArray = 0; indexArray < (Math.floor((delta + array.length) / 3) * 3) - delta; indexArray++) {
  2299. dataString += String.fromCharCode(array[indexArray]);
  2300. }
  2301. for (; indexArray < array.length; indexArray++) {
  2302. writer.pending += String.fromCharCode(array[indexArray]);
  2303. }
  2304. if (dataString.length) {
  2305. if (dataString.length > 2) {
  2306. writer.data += btoa(dataString);
  2307. } else {
  2308. writer.pending += dataString;
  2309. }
  2310. }
  2311. }
  2312. getData() {
  2313. return this.data + btoa(this.pending);
  2314. }
  2315. }
  2316. class BlobReader extends Reader {
  2317. constructor(blob) {
  2318. super();
  2319. Object.assign(this, {
  2320. blob,
  2321. size: blob.size
  2322. });
  2323. }
  2324. async readUint8Array(offset, length) {
  2325. const reader = this;
  2326. const offsetEnd = offset + length;
  2327. const blob = offset || offsetEnd < reader.size ? reader.blob.slice(offset, offsetEnd) : reader.blob;
  2328. let arrayBuffer = await blob.arrayBuffer();
  2329. if (arrayBuffer.byteLength > length) {
  2330. arrayBuffer = arrayBuffer.slice(offset, offsetEnd);
  2331. }
  2332. return new Uint8Array(arrayBuffer);
  2333. }
  2334. }
  2335. class BlobWriter extends Stream {
  2336. constructor(contentType) {
  2337. super();
  2338. const writer = this;
  2339. const transformStream = new TransformStream();
  2340. const headers = [];
  2341. if (contentType) {
  2342. headers.push([HTTP_HEADER_CONTENT_TYPE, contentType]);
  2343. }
  2344. Object.defineProperty(writer, PROPERTY_NAME_WRITABLE, {
  2345. get() {
  2346. return transformStream.writable;
  2347. }
  2348. });
  2349. writer.blob = new Response(transformStream.readable, { headers }).blob();
  2350. }
  2351. getData() {
  2352. return this.blob;
  2353. }
  2354. }
  2355. class TextReader extends BlobReader {
  2356. constructor(text) {
  2357. super(new Blob([text], { type: CONTENT_TYPE_TEXT_PLAIN }));
  2358. }
  2359. }
  2360. class TextWriter extends BlobWriter {
  2361. constructor(encoding) {
  2362. super(encoding);
  2363. Object.assign(this, {
  2364. encoding,
  2365. utf8: !encoding || encoding.toLowerCase() == "utf-8"
  2366. });
  2367. }
  2368. async getData() {
  2369. const {
  2370. encoding,
  2371. utf8
  2372. } = this;
  2373. const blob = await super.getData();
  2374. if (blob.text && utf8) {
  2375. return blob.text();
  2376. } else {
  2377. const reader = new FileReader();
  2378. return new Promise((resolve, reject) => {
  2379. Object.assign(reader, {
  2380. onload: ({ target }) => resolve(target.result),
  2381. onerror: () => reject(reader.error)
  2382. });
  2383. reader.readAsText(blob, encoding);
  2384. });
  2385. }
  2386. }
  2387. }
  2388. class FetchReader extends Reader {
  2389. constructor(url, options) {
  2390. super();
  2391. createHttpReader(this, url, options);
  2392. }
  2393. async init() {
  2394. await initHttpReader(this, sendFetchRequest, getFetchRequestData);
  2395. super.init();
  2396. }
  2397. readUint8Array(index, length) {
  2398. return readUint8ArrayHttpReader(this, index, length, sendFetchRequest, getFetchRequestData);
  2399. }
  2400. }
  2401. class XHRReader extends Reader {
  2402. constructor(url, options) {
  2403. super();
  2404. createHttpReader(this, url, options);
  2405. }
  2406. async init() {
  2407. await initHttpReader(this, sendXMLHttpRequest, getXMLHttpRequestData);
  2408. super.init();
  2409. }
  2410. readUint8Array(index, length) {
  2411. return readUint8ArrayHttpReader(this, index, length, sendXMLHttpRequest, getXMLHttpRequestData);
  2412. }
  2413. }
  2414. function createHttpReader(httpReader, url, options) {
  2415. const {
  2416. preventHeadRequest,
  2417. useRangeHeader,
  2418. forceRangeRequests,
  2419. combineSizeEocd
  2420. } = options;
  2421. options = Object.assign({}, options);
  2422. delete options.preventHeadRequest;
  2423. delete options.useRangeHeader;
  2424. delete options.forceRangeRequests;
  2425. delete options.combineSizeEocd;
  2426. delete options.useXHR;
  2427. Object.assign(httpReader, {
  2428. url,
  2429. options,
  2430. preventHeadRequest,
  2431. useRangeHeader,
  2432. forceRangeRequests,
  2433. combineSizeEocd
  2434. });
  2435. }
  2436. async function initHttpReader(httpReader, sendRequest, getRequestData) {
  2437. const {
  2438. url,
  2439. preventHeadRequest,
  2440. useRangeHeader,
  2441. forceRangeRequests,
  2442. combineSizeEocd
  2443. } = httpReader;
  2444. if (isHttpFamily(url) && (useRangeHeader || forceRangeRequests) && (typeof preventHeadRequest == "undefined" || preventHeadRequest)) {
  2445. const response = await sendRequest(HTTP_METHOD_GET, httpReader, getRangeHeaders(httpReader, combineSizeEocd ? -END_OF_CENTRAL_DIR_LENGTH : undefined));
  2446. const acceptRanges = response.headers.get(HTTP_HEADER_ACCEPT_RANGES);
  2447. if (!forceRangeRequests && (!acceptRanges || acceptRanges.toLowerCase() != HTTP_RANGE_UNIT)) {
  2448. throw new Error(ERR_HTTP_RANGE);
  2449. } else {
  2450. if (combineSizeEocd) {
  2451. httpReader.eocdCache = new Uint8Array(await response.arrayBuffer());
  2452. }
  2453. let contentSize;
  2454. const contentRangeHeader = response.headers.get(HTTP_HEADER_CONTENT_RANGE);
  2455. if (contentRangeHeader) {
  2456. const splitHeader = contentRangeHeader.trim().split(/\s*\/\s*/);
  2457. if (splitHeader.length) {
  2458. const headerValue = splitHeader[1];
  2459. if (headerValue && headerValue != "*") {
  2460. contentSize = Number(headerValue);
  2461. }
  2462. }
  2463. }
  2464. if (contentSize === UNDEFINED_VALUE) {
  2465. await getContentLength(httpReader, sendRequest, getRequestData);
  2466. } else {
  2467. httpReader.size = contentSize;
  2468. }
  2469. }
  2470. } else {
  2471. await getContentLength(httpReader, sendRequest, getRequestData);
  2472. }
  2473. }
  2474. async function readUint8ArrayHttpReader(httpReader, index, length, sendRequest, getRequestData) {
  2475. const {
  2476. useRangeHeader,
  2477. forceRangeRequests,
  2478. eocdCache,
  2479. size,
  2480. options
  2481. } = httpReader;
  2482. if (useRangeHeader || forceRangeRequests) {
  2483. if (eocdCache && index == size - END_OF_CENTRAL_DIR_LENGTH && length == END_OF_CENTRAL_DIR_LENGTH) {
  2484. return eocdCache;
  2485. }
  2486. if (index >= size || length === 0) {
  2487. return new Uint8Array();
  2488. } else {
  2489. if (index + length > size) {
  2490. length = size - index;
  2491. }
  2492. const response = await sendRequest(HTTP_METHOD_GET, httpReader, getRangeHeaders(httpReader, index, length));
  2493. if (response.status != 206) {
  2494. throw new Error(ERR_HTTP_RANGE);
  2495. }
  2496. return new Uint8Array(await response.arrayBuffer());
  2497. }
  2498. } else {
  2499. const { data } = httpReader;
  2500. if (!data) {
  2501. await getRequestData(httpReader, options);
  2502. }
  2503. return new Uint8Array(httpReader.data.subarray(index, index + length));
  2504. }
  2505. }
  2506. function getRangeHeaders(httpReader, index = 0, length = 1) {
  2507. return Object.assign({}, getHeaders(httpReader), { [HTTP_HEADER_RANGE]: HTTP_RANGE_UNIT + "=" + (index < 0 ? index : index + "-" + (index + length - 1)) });
  2508. }
  2509. function getHeaders({ options }) {
  2510. const { headers } = options;
  2511. if (headers) {
  2512. if (Symbol.iterator in headers) {
  2513. return Object.fromEntries(headers);
  2514. } else {
  2515. return headers;
  2516. }
  2517. }
  2518. }
  2519. async function getFetchRequestData(httpReader) {
  2520. await getRequestData(httpReader, sendFetchRequest);
  2521. }
  2522. async function getXMLHttpRequestData(httpReader) {
  2523. await getRequestData(httpReader, sendXMLHttpRequest);
  2524. }
  2525. async function getRequestData(httpReader, sendRequest) {
  2526. const response = await sendRequest(HTTP_METHOD_GET, httpReader, getHeaders(httpReader));
  2527. httpReader.data = new Uint8Array(await response.arrayBuffer());
  2528. if (!httpReader.size) {
  2529. httpReader.size = httpReader.data.length;
  2530. }
  2531. }
  2532. async function getContentLength(httpReader, sendRequest, getRequestData) {
  2533. if (httpReader.preventHeadRequest) {
  2534. await getRequestData(httpReader, httpReader.options);
  2535. } else {
  2536. const response = await sendRequest(HTTP_METHOD_HEAD, httpReader, getHeaders(httpReader));
  2537. const contentLength = response.headers.get(HTTP_HEADER_CONTENT_LENGTH);
  2538. if (contentLength) {
  2539. httpReader.size = Number(contentLength);
  2540. } else {
  2541. await getRequestData(httpReader, httpReader.options);
  2542. }
  2543. }
  2544. }
  2545. async function sendFetchRequest(method, { options, url }, headers) {
  2546. const response = await fetch(url, Object.assign({}, options, { method, headers }));
  2547. if (response.status < 400) {
  2548. return response;
  2549. } else {
  2550. throw response.status == 416 ? new Error(ERR_HTTP_RANGE) : new Error(ERR_HTTP_STATUS + (response.statusText || response.status));
  2551. }
  2552. }
  2553. function sendXMLHttpRequest(method, { url }, headers) {
  2554. return new Promise((resolve, reject) => {
  2555. const request = new XMLHttpRequest();
  2556. request.addEventListener("load", () => {
  2557. if (request.status < 400) {
  2558. const headers = [];
  2559. request.getAllResponseHeaders().trim().split(/[\r\n]+/).forEach(header => {
  2560. const splitHeader = header.trim().split(/\s*:\s*/);
  2561. splitHeader[0] = splitHeader[0].trim().replace(/^[a-z]|-[a-z]/g, value => value.toUpperCase());
  2562. headers.push(splitHeader);
  2563. });
  2564. resolve({
  2565. status: request.status,
  2566. arrayBuffer: () => request.response,
  2567. headers: new Map(headers)
  2568. });
  2569. } else {
  2570. reject(request.status == 416 ? new Error(ERR_HTTP_RANGE) : new Error(ERR_HTTP_STATUS + (request.statusText || request.status)));
  2571. }
  2572. }, false);
  2573. request.addEventListener("error", event => reject(event.detail ? event.detail.error : new Error("Network error")), false);
  2574. request.open(method, url);
  2575. if (headers) {
  2576. for (const entry of Object.entries(headers)) {
  2577. request.setRequestHeader(entry[0], entry[1]);
  2578. }
  2579. }
  2580. request.responseType = "arraybuffer";
  2581. request.send();
  2582. });
  2583. }
  2584. class HttpReader extends Reader {
  2585. constructor(url, options = {}) {
  2586. super();
  2587. Object.assign(this, {
  2588. url,
  2589. reader: options.useXHR ? new XHRReader(url, options) : new FetchReader(url, options)
  2590. });
  2591. }
  2592. set size(value) {
  2593. // ignored
  2594. }
  2595. get size() {
  2596. return this.reader.size;
  2597. }
  2598. async init() {
  2599. await this.reader.init();
  2600. super.init();
  2601. }
  2602. readUint8Array(index, length) {
  2603. return this.reader.readUint8Array(index, length);
  2604. }
  2605. }
  2606. class HttpRangeReader extends HttpReader {
  2607. constructor(url, options = {}) {
  2608. options.useRangeHeader = true;
  2609. super(url, options);
  2610. }
  2611. }
  2612. class Uint8ArrayReader extends Reader {
  2613. constructor(array) {
  2614. super();
  2615. array = new Uint8Array(array.buffer, array.byteOffset, array.byteLength);
  2616. Object.assign(this, {
  2617. array,
  2618. size: array.length
  2619. });
  2620. }
  2621. readUint8Array(index, length) {
  2622. return this.array.slice(index, index + length);
  2623. }
  2624. }
  2625. class Uint8ArrayWriter extends Writer {
  2626. constructor(defaultBufferSize) {
  2627. super();
  2628. this.defaultBufferSize = defaultBufferSize || DEFAULT_BUFFER_SIZE;
  2629. }
  2630. init(initSize = 0) {
  2631. Object.assign(this, {
  2632. offset: 0,
  2633. array: new Uint8Array(initSize > 0 ? initSize : this.defaultBufferSize)
  2634. });
  2635. super.init();
  2636. }
  2637. writeUint8Array(array) {
  2638. const writer = this;
  2639. const requiredLength = writer.offset + array.length;
  2640. if (requiredLength > writer.array.length) {
  2641. let newLength = writer.array.length ? writer.array.length * 2 : writer.defaultBufferSize;
  2642. while (newLength < requiredLength) {
  2643. newLength *= 2;
  2644. }
  2645. const previousArray = writer.array;
  2646. writer.array = new Uint8Array(newLength);
  2647. writer.array.set(previousArray);
  2648. }
  2649. writer.array.set(array, writer.offset);
  2650. writer.offset += array.length;
  2651. }
  2652. getData() {
  2653. if (this.offset === this.array.length) {
  2654. return this.array;
  2655. } else {
  2656. return this.array.slice(0, this.offset);
  2657. }
  2658. }
  2659. }
  2660. class SplitDataReader extends Reader {
  2661. constructor(readers) {
  2662. super();
  2663. this.readers = readers;
  2664. }
  2665. async init() {
  2666. const reader = this;
  2667. const { readers } = reader;
  2668. reader.lastDiskNumber = 0;
  2669. reader.lastDiskOffset = 0;
  2670. await Promise.all(readers.map(async (diskReader, indexDiskReader) => {
  2671. await diskReader.init();
  2672. if (indexDiskReader != readers.length - 1) {
  2673. reader.lastDiskOffset += diskReader.size;
  2674. }
  2675. reader.size += diskReader.size;
  2676. }));
  2677. super.init();
  2678. }
  2679. async readUint8Array(offset, length, diskNumber = 0) {
  2680. const reader = this;
  2681. const { readers } = this;
  2682. let result;
  2683. let currentDiskNumber = diskNumber;
  2684. if (currentDiskNumber == -1) {
  2685. currentDiskNumber = readers.length - 1;
  2686. }
  2687. let currentReaderOffset = offset;
  2688. while (readers[currentDiskNumber] && currentReaderOffset >= readers[currentDiskNumber].size) {
  2689. currentReaderOffset -= readers[currentDiskNumber].size;
  2690. currentDiskNumber++;
  2691. }
  2692. const currentReader = readers[currentDiskNumber];
  2693. if (currentReader) {
  2694. const currentReaderSize = currentReader.size;
  2695. if (currentReaderOffset + length <= currentReaderSize) {
  2696. result = await readUint8Array(currentReader, currentReaderOffset, length);
  2697. } else {
  2698. const chunkLength = currentReaderSize - currentReaderOffset;
  2699. result = new Uint8Array(length);
  2700. const firstPart = await readUint8Array(currentReader, currentReaderOffset, chunkLength);
  2701. result.set(firstPart, 0);
  2702. const secondPart = await reader.readUint8Array(offset + chunkLength, length - chunkLength, diskNumber);
  2703. result.set(secondPart, chunkLength);
  2704. if (firstPart.length + secondPart.length < length) {
  2705. result = result.subarray(0, firstPart.length + secondPart.length);
  2706. }
  2707. }
  2708. } else {
  2709. result = new Uint8Array();
  2710. }
  2711. reader.lastDiskNumber = Math.max(currentDiskNumber, reader.lastDiskNumber);
  2712. return result;
  2713. }
  2714. }
  2715. class SplitDataWriter extends Stream {
  2716. constructor(writerGenerator, maxSize = 4294967295) {
  2717. super();
  2718. const writer = this;
  2719. Object.assign(writer, {
  2720. diskNumber: 0,
  2721. diskOffset: 0,
  2722. size: 0,
  2723. maxSize,
  2724. availableSize: maxSize
  2725. });
  2726. let diskSourceWriter, diskWritable, diskWriter;
  2727. const writable = new WritableStream({
  2728. async write(chunk) {
  2729. const { availableSize } = writer;
  2730. if (!diskWriter) {
  2731. const { value, done } = await writerGenerator.next();
  2732. if (done && !value) {
  2733. throw new Error(ERR_ITERATOR_COMPLETED_TOO_SOON);
  2734. } else {
  2735. diskSourceWriter = value;
  2736. diskSourceWriter.size = 0;
  2737. if (diskSourceWriter.maxSize) {
  2738. writer.maxSize = diskSourceWriter.maxSize;
  2739. }
  2740. writer.availableSize = writer.maxSize;
  2741. await initStream(diskSourceWriter);
  2742. diskWritable = value.writable;
  2743. diskWriter = diskWritable.getWriter();
  2744. }
  2745. await this.write(chunk);
  2746. } else if (chunk.length >= availableSize) {
  2747. await writeChunk(chunk.subarray(0, availableSize));
  2748. await closeDisk();
  2749. writer.diskOffset += diskSourceWriter.size;
  2750. writer.diskNumber++;
  2751. diskWriter = null;
  2752. await this.write(chunk.subarray(availableSize));
  2753. } else {
  2754. await writeChunk(chunk);
  2755. }
  2756. },
  2757. async close() {
  2758. await diskWriter.ready;
  2759. await closeDisk();
  2760. }
  2761. });
  2762. Object.defineProperty(writer, PROPERTY_NAME_WRITABLE, {
  2763. get() {
  2764. return writable;
  2765. }
  2766. });
  2767. async function writeChunk(chunk) {
  2768. const chunkLength = chunk.length;
  2769. if (chunkLength) {
  2770. await diskWriter.ready;
  2771. await diskWriter.write(chunk);
  2772. diskSourceWriter.size += chunkLength;
  2773. writer.size += chunkLength;
  2774. writer.availableSize -= chunkLength;
  2775. }
  2776. }
  2777. async function closeDisk() {
  2778. await diskWriter.close();
  2779. }
  2780. }
  2781. }
  2782. class GenericReader {
  2783. constructor(reader) {
  2784. if (Array.isArray(reader)) {
  2785. reader = new SplitDataReader(reader);
  2786. }
  2787. if (reader instanceof ReadableStream) {
  2788. reader = {
  2789. readable: reader
  2790. };
  2791. }
  2792. return reader;
  2793. }
  2794. }
  2795. class GenericWriter {
  2796. constructor(writer) {
  2797. if (writer.writable === UNDEFINED_VALUE && typeof writer.next == FUNCTION_TYPE) {
  2798. writer = new SplitDataWriter(writer);
  2799. }
  2800. if (writer instanceof WritableStream) {
  2801. writer = {
  2802. writable: writer
  2803. };
  2804. }
  2805. if (writer.size === UNDEFINED_VALUE) {
  2806. writer.size = 0;
  2807. }
  2808. if (!(writer instanceof SplitDataWriter)) {
  2809. Object.assign(writer, {
  2810. diskNumber: 0,
  2811. diskOffset: 0,
  2812. availableSize: INFINITY_VALUE,
  2813. maxSize: INFINITY_VALUE
  2814. });
  2815. }
  2816. return writer;
  2817. }
  2818. }
  2819. function isHttpFamily(url) {
  2820. const { baseURI } = getConfiguration();
  2821. const { protocol } = new URL(url, baseURI);
  2822. return protocol == "http:" || protocol == "https:";
  2823. }
  2824. async function initStream(stream, initSize) {
  2825. if (stream.init && !stream.initialized) {
  2826. await stream.init(initSize);
  2827. } else {
  2828. return Promise.resolve();
  2829. }
  2830. }
  2831. function readUint8Array(reader, offset, size, diskNumber) {
  2832. return reader.readUint8Array(offset, size, diskNumber);
  2833. }
  2834. /*
  2835. Copyright (c) 2022 Gildas Lormeau. All rights reserved.
  2836. Redistribution and use in source and binary forms, with or without
  2837. modification, are permitted provided that the following conditions are met:
  2838. 1. Redistributions of source code must retain the above copyright notice,
  2839. this list of conditions and the following disclaimer.
  2840. 2. Redistributions in binary form must reproduce the above copyright
  2841. notice, this list of conditions and the following disclaimer in
  2842. the documentation and/or other materials provided with the distribution.
  2843. 3. The names of the authors may not be used to endorse or promote products
  2844. derived from this software without specific prior written permission.
  2845. THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  2846. INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  2847. FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
  2848. INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
  2849. INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  2850. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
  2851. OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  2852. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  2853. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  2854. EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  2855. */
  2856. /* global TextDecoder */
  2857. const CP437 = "\0☺☻♥♦♣♠•◘○◙♂♀♪♫☼►◄↕‼¶§▬↨↑↓→←∟↔▲▼ !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~⌂ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥₧ƒáíóúñѪº¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ ".split("");
  2858. const VALID_CP437 = CP437.length == 256;
  2859. function decodeCP437(stringValue) {
  2860. if (VALID_CP437) {
  2861. let result = "";
  2862. for (let indexCharacter = 0; indexCharacter < stringValue.length; indexCharacter++) {
  2863. result += CP437[stringValue[indexCharacter]];
  2864. }
  2865. return result;
  2866. } else {
  2867. return new TextDecoder().decode(stringValue);
  2868. }
  2869. }
  2870. /*
  2871. Copyright (c) 2022 Gildas Lormeau. All rights reserved.
  2872. Redistribution and use in source and binary forms, with or without
  2873. modification, are permitted provided that the following conditions are met:
  2874. 1. Redistributions of source code must retain the above copyright notice,
  2875. this list of conditions and the following disclaimer.
  2876. 2. Redistributions in binary form must reproduce the above copyright
  2877. notice, this list of conditions and the following disclaimer in
  2878. the documentation and/or other materials provided with the distribution.
  2879. 3. The names of the authors may not be used to endorse or promote products
  2880. derived from this software without specific prior written permission.
  2881. THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  2882. INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  2883. FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
  2884. INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
  2885. INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  2886. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
  2887. OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  2888. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  2889. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  2890. EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  2891. */
  2892. function decodeText(value, encoding) {
  2893. if (encoding && encoding.trim().toLowerCase() == "cp437") {
  2894. return decodeCP437(value);
  2895. } else {
  2896. return new TextDecoder(encoding).decode(value);
  2897. }
  2898. }
  2899. /*
  2900. Copyright (c) 2025 Gildas Lormeau. All rights reserved.
  2901. Redistribution and use in source and binary forms, with or without
  2902. modification, are permitted provided that the following conditions are met:
  2903. 1. Redistributions of source code must retain the above copyright notice,
  2904. this list of conditions and the following disclaimer.
  2905. 2. Redistributions in binary form must reproduce the above copyright
  2906. notice, this list of conditions and the following disclaimer in
  2907. the documentation and/or other materials provided with the distribution.
  2908. 3. The names of the authors may not be used to endorse or promote products
  2909. derived from this software without specific prior written permission.
  2910. THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  2911. INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  2912. FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
  2913. INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
  2914. INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  2915. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
  2916. OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  2917. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  2918. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  2919. EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  2920. */
  2921. const PROPERTY_NAME_FILENAME = "filename";
  2922. const PROPERTY_NAME_RAW_FILENAME = "rawFilename";
  2923. const PROPERTY_NAME_COMMENT = "comment";
  2924. const PROPERTY_NAME_RAW_COMMENT = "rawComment";
  2925. const PROPERTY_NAME_UNCOMPRESSED_SIZE = "uncompressedSize";
  2926. const PROPERTY_NAME_COMPRESSED_SIZE = "compressedSize";
  2927. const PROPERTY_NAME_OFFSET = "offset";
  2928. const PROPERTY_NAME_DISK_NUMBER_START = "diskNumberStart";
  2929. const PROPERTY_NAME_LAST_MODIFICATION_DATE = "lastModDate";
  2930. const PROPERTY_NAME_RAW_LAST_MODIFICATION_DATE = "rawLastModDate";
  2931. const PROPERTY_NAME_LAST_ACCESS_DATE = "lastAccessDate";
  2932. const PROPERTY_NAME_RAW_LAST_ACCESS_DATE = "rawLastAccessDate";
  2933. const PROPERTY_NAME_CREATION_DATE = "creationDate";
  2934. const PROPERTY_NAME_RAW_CREATION_DATE = "rawCreationDate";
  2935. const PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTES = "internalFileAttributes";
  2936. const PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTES = "externalFileAttributes";
  2937. const PROPERTY_NAME_MSDOS_ATTRIBUTES_RAW = "msdosAttributesRaw";
  2938. const PROPERTY_NAME_MSDOS_ATTRIBUTES = "msdosAttributes";
  2939. const PROPERTY_NAME_MS_DOS_COMPATIBLE = "msDosCompatible";
  2940. const PROPERTY_NAME_ZIP64 = "zip64";
  2941. const PROPERTY_NAME_ENCRYPTED = "encrypted";
  2942. const PROPERTY_NAME_VERSION = "version";
  2943. const PROPERTY_NAME_VERSION_MADE_BY = "versionMadeBy";
  2944. const PROPERTY_NAME_ZIPCRYPTO = "zipCrypto";
  2945. const PROPERTY_NAME_DIRECTORY = "directory";
  2946. const PROPERTY_NAME_EXECUTABLE = "executable";
  2947. const PROPERTY_NAME_COMPRESSION_METHOD = "compressionMethod";
  2948. const PROPERTY_NAME_SIGNATURE = "signature";
  2949. const PROPERTY_NAME_EXTRA_FIELD = "extraField";
  2950. const PROPERTY_NAME_EXTRA_FIELD_INFOZIP = "extraFieldInfoZip";
  2951. const PROPERTY_NAME_EXTRA_FIELD_UNIX = "extraFieldUnix";
  2952. const PROPERTY_NAME_UID = "uid";
  2953. const PROPERTY_NAME_GID = "gid";
  2954. const PROPERTY_NAME_UNIX_MODE = "unixMode";
  2955. const PROPERTY_NAME_SETUID = "setuid";
  2956. const PROPERTY_NAME_SETGID = "setgid";
  2957. const PROPERTY_NAME_STICKY = "sticky";
  2958. const PROPERTY_NAME_BITFLAG = "bitFlag";
  2959. const PROPERTY_NAME_FILENAME_UTF8 = "filenameUTF8";
  2960. const PROPERTY_NAME_COMMENT_UTF8 = "commentUTF8";
  2961. const PROPERTY_NAME_RAW_EXTRA_FIELD = "rawExtraField";
  2962. const PROPERTY_NAME_EXTRA_FIELD_ZIP64 = "extraFieldZip64";
  2963. const PROPERTY_NAME_EXTRA_FIELD_UNICODE_PATH = "extraFieldUnicodePath";
  2964. const PROPERTY_NAME_EXTRA_FIELD_UNICODE_COMMENT = "extraFieldUnicodeComment";
  2965. const PROPERTY_NAME_EXTRA_FIELD_AES = "extraFieldAES";
  2966. const PROPERTY_NAME_EXTRA_FIELD_NTFS = "extraFieldNTFS";
  2967. const PROPERTY_NAME_EXTRA_FIELD_EXTENDED_TIMESTAMP = "extraFieldExtendedTimestamp";
  2968. const PROPERTY_NAMES = [
  2969. PROPERTY_NAME_FILENAME,
  2970. PROPERTY_NAME_RAW_FILENAME,
  2971. PROPERTY_NAME_UNCOMPRESSED_SIZE,
  2972. PROPERTY_NAME_COMPRESSED_SIZE,
  2973. PROPERTY_NAME_LAST_MODIFICATION_DATE,
  2974. PROPERTY_NAME_RAW_LAST_MODIFICATION_DATE,
  2975. PROPERTY_NAME_COMMENT,
  2976. PROPERTY_NAME_RAW_COMMENT,
  2977. PROPERTY_NAME_LAST_ACCESS_DATE,
  2978. PROPERTY_NAME_CREATION_DATE,
  2979. PROPERTY_NAME_RAW_CREATION_DATE,
  2980. PROPERTY_NAME_OFFSET,
  2981. PROPERTY_NAME_DISK_NUMBER_START,
  2982. PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTES,
  2983. PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTES,
  2984. PROPERTY_NAME_MSDOS_ATTRIBUTES_RAW,
  2985. PROPERTY_NAME_MSDOS_ATTRIBUTES,
  2986. PROPERTY_NAME_MS_DOS_COMPATIBLE,
  2987. PROPERTY_NAME_ZIP64,
  2988. PROPERTY_NAME_ENCRYPTED,
  2989. PROPERTY_NAME_VERSION,
  2990. PROPERTY_NAME_VERSION_MADE_BY,
  2991. PROPERTY_NAME_ZIPCRYPTO,
  2992. PROPERTY_NAME_DIRECTORY,
  2993. PROPERTY_NAME_EXECUTABLE,
  2994. PROPERTY_NAME_COMPRESSION_METHOD,
  2995. PROPERTY_NAME_SIGNATURE,
  2996. PROPERTY_NAME_EXTRA_FIELD,
  2997. PROPERTY_NAME_EXTRA_FIELD_UNIX,
  2998. PROPERTY_NAME_EXTRA_FIELD_INFOZIP,
  2999. PROPERTY_NAME_UID,
  3000. PROPERTY_NAME_GID,
  3001. PROPERTY_NAME_UNIX_MODE,
  3002. PROPERTY_NAME_SETUID,
  3003. PROPERTY_NAME_SETGID,
  3004. PROPERTY_NAME_STICKY,
  3005. PROPERTY_NAME_BITFLAG,
  3006. PROPERTY_NAME_FILENAME_UTF8,
  3007. PROPERTY_NAME_COMMENT_UTF8,
  3008. PROPERTY_NAME_RAW_EXTRA_FIELD,
  3009. PROPERTY_NAME_EXTRA_FIELD_ZIP64,
  3010. PROPERTY_NAME_EXTRA_FIELD_UNICODE_PATH,
  3011. PROPERTY_NAME_EXTRA_FIELD_UNICODE_COMMENT,
  3012. PROPERTY_NAME_EXTRA_FIELD_AES,
  3013. PROPERTY_NAME_EXTRA_FIELD_NTFS,
  3014. PROPERTY_NAME_EXTRA_FIELD_EXTENDED_TIMESTAMP
  3015. ];
  3016. class Entry {
  3017. constructor(data) {
  3018. PROPERTY_NAMES.forEach(name => this[name] = data[name]);
  3019. }
  3020. }
  3021. /*
  3022. Copyright (c) 2022 Gildas Lormeau. All rights reserved.
  3023. Redistribution and use in source and binary forms, with or without
  3024. modification, are permitted provided that the following conditions are met:
  3025. 1. Redistributions of source code must retain the above copyright notice,
  3026. this list of conditions and the following disclaimer.
  3027. 2. Redistributions in binary form must reproduce the above copyright
  3028. notice, this list of conditions and the following disclaimer in
  3029. the documentation and/or other materials provided with the distribution.
  3030. 3. The names of the authors may not be used to endorse or promote products
  3031. derived from this software without specific prior written permission.
  3032. THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  3033. INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  3034. FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
  3035. INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
  3036. INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  3037. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
  3038. OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  3039. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  3040. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  3041. EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  3042. */
  3043. const OPTION_FILENAME_ENCODING = "filenameEncoding";
  3044. const OPTION_COMMENT_ENCODING = "commentEncoding";
  3045. const OPTION_DECODE_TEXT = "decodeText";
  3046. const OPTION_EXTRACT_PREPENDED_DATA = "extractPrependedData";
  3047. const OPTION_EXTRACT_APPENDED_DATA = "extractAppendedData";
  3048. const OPTION_PASSWORD = "password";
  3049. const OPTION_RAW_PASSWORD = "rawPassword";
  3050. const OPTION_PASS_THROUGH = "passThrough";
  3051. const OPTION_SIGNAL = "signal";
  3052. const OPTION_CHECK_PASSWORD_ONLY = "checkPasswordOnly";
  3053. const OPTION_CHECK_OVERLAPPING_ENTRY_ONLY = "checkOverlappingEntryOnly";
  3054. const OPTION_CHECK_OVERLAPPING_ENTRY = "checkOverlappingEntry";
  3055. const OPTION_CHECK_SIGNATURE = "checkSignature";
  3056. const OPTION_USE_WEB_WORKERS = "useWebWorkers";
  3057. const OPTION_USE_COMPRESSION_STREAM = "useCompressionStream";
  3058. const OPTION_TRANSFER_STREAMS = "transferStreams";
  3059. const OPTION_PREVENT_CLOSE = "preventClose";
  3060. const OPTION_ENCRYPTION_STRENGTH = "encryptionStrength";
  3061. const OPTION_EXTENDED_TIMESTAMP = "extendedTimestamp";
  3062. const OPTION_KEEP_ORDER = "keepOrder";
  3063. const OPTION_LEVEL = "level";
  3064. const OPTION_BUFFERED_WRITE = "bufferedWrite";
  3065. const OPTION_CREATE_TEMP_STREAM = "createTempStream";
  3066. const OPTION_DATA_DESCRIPTOR_SIGNATURE = "dataDescriptorSignature";
  3067. const OPTION_USE_UNICODE_FILE_NAMES = "useUnicodeFileNames";
  3068. const OPTION_DATA_DESCRIPTOR = "dataDescriptor";
  3069. const OPTION_SUPPORT_ZIP64_SPLIT_FILE = "supportZip64SplitFile";
  3070. const OPTION_ENCODE_TEXT = "encodeText";
  3071. const OPTION_OFFSET = "offset";
  3072. const OPTION_USDZ = "usdz";
  3073. const OPTION_UNIX_EXTRA_FIELD_TYPE = "unixExtraFieldType";
  3074. /*
  3075. Copyright (c) 2025 Gildas Lormeau. All rights reserved.
  3076. Redistribution and use in source and binary forms, with or without
  3077. modification, are permitted provided that the following conditions are met:
  3078. 1. Redistributions of source code must retain the above copyright notice,
  3079. this list of conditions and the following disclaimer.
  3080. 2. Redistributions in binary form must reproduce the above copyright
  3081. notice, this list of conditions and the following disclaimer in
  3082. the documentation and/or other materials provided with the distribution.
  3083. 3. The names of the authors may not be used to endorse or promote products
  3084. derived from this software without specific prior written permission.
  3085. THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  3086. INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  3087. FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
  3088. INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
  3089. INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  3090. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
  3091. OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  3092. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  3093. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  3094. EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  3095. */
  3096. const ERR_BAD_FORMAT = "File format is not recognized";
  3097. const ERR_EOCDR_NOT_FOUND = "End of central directory not found";
  3098. const ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND = "End of Zip64 central directory locator not found";
  3099. const ERR_CENTRAL_DIRECTORY_NOT_FOUND = "Central directory header not found";
  3100. const ERR_LOCAL_FILE_HEADER_NOT_FOUND = "Local file header not found";
  3101. const ERR_EXTRAFIELD_ZIP64_NOT_FOUND = "Zip64 extra field not found";
  3102. const ERR_ENCRYPTED = "File contains encrypted entry";
  3103. const ERR_UNSUPPORTED_ENCRYPTION = "Encryption method not supported";
  3104. const ERR_UNSUPPORTED_COMPRESSION = "Compression method not supported";
  3105. const ERR_SPLIT_ZIP_FILE = "Split zip file";
  3106. const ERR_OVERLAPPING_ENTRY = "Overlapping entry found";
  3107. const CHARSET_UTF8 = "utf-8";
  3108. const PROPERTY_NAME_UTF8_SUFFIX = "UTF8";
  3109. const CHARSET_CP437 = "cp437";
  3110. const ZIP64_PROPERTIES = [
  3111. [PROPERTY_NAME_UNCOMPRESSED_SIZE, MAX_32_BITS],
  3112. [PROPERTY_NAME_COMPRESSED_SIZE, MAX_32_BITS],
  3113. [PROPERTY_NAME_OFFSET, MAX_32_BITS],
  3114. [PROPERTY_NAME_DISK_NUMBER_START, MAX_16_BITS]
  3115. ];
  3116. const ZIP64_EXTRACTION = {
  3117. [MAX_16_BITS]: {
  3118. getValue: getUint32,
  3119. bytes: 4
  3120. },
  3121. [MAX_32_BITS]: {
  3122. getValue: getBigUint64,
  3123. bytes: 8
  3124. }
  3125. };
  3126. class ZipReader {
  3127. constructor(reader, options = {}) {
  3128. Object.assign(this, {
  3129. reader: new GenericReader(reader),
  3130. options,
  3131. config: getConfiguration(),
  3132. readRanges: []
  3133. });
  3134. }
  3135. async* getEntriesGenerator(options = {}) {
  3136. const zipReader = this;
  3137. let { reader } = zipReader;
  3138. const { config } = zipReader;
  3139. await initStream(reader);
  3140. if (reader.size === UNDEFINED_VALUE || !reader.readUint8Array) {
  3141. reader = new BlobReader(await new Response(reader.readable).blob());
  3142. await initStream(reader);
  3143. }
  3144. if (reader.size < END_OF_CENTRAL_DIR_LENGTH) {
  3145. throw new Error(ERR_BAD_FORMAT);
  3146. }
  3147. reader.chunkSize = getChunkSize(config);
  3148. const endOfDirectoryInfo = await seekSignature(reader, END_OF_CENTRAL_DIR_SIGNATURE, reader.size, END_OF_CENTRAL_DIR_LENGTH, MAX_16_BITS * 16);
  3149. if (!endOfDirectoryInfo) {
  3150. const signatureArray = await readUint8Array(reader, 0, 4);
  3151. const signatureView = getDataView$1(signatureArray);
  3152. if (getUint32(signatureView) == SPLIT_ZIP_FILE_SIGNATURE) {
  3153. throw new Error(ERR_SPLIT_ZIP_FILE);
  3154. } else {
  3155. throw new Error(ERR_EOCDR_NOT_FOUND);
  3156. }
  3157. }
  3158. const endOfDirectoryView = getDataView$1(endOfDirectoryInfo);
  3159. let directoryDataLength = getUint32(endOfDirectoryView, 12);
  3160. let directoryDataOffset = getUint32(endOfDirectoryView, 16);
  3161. const commentOffset = endOfDirectoryInfo.offset;
  3162. const commentLength = getUint16(endOfDirectoryView, 20);
  3163. const appendedDataOffset = commentOffset + END_OF_CENTRAL_DIR_LENGTH + commentLength;
  3164. let lastDiskNumber = getUint16(endOfDirectoryView, 4);
  3165. const expectedLastDiskNumber = reader.lastDiskNumber || 0;
  3166. let diskNumber = getUint16(endOfDirectoryView, 6);
  3167. let filesLength = getUint16(endOfDirectoryView, 8);
  3168. let prependedDataLength = 0;
  3169. let startOffset = 0;
  3170. if (directoryDataOffset == MAX_32_BITS || directoryDataLength == MAX_32_BITS || filesLength == MAX_16_BITS || diskNumber == MAX_16_BITS) {
  3171. const endOfDirectoryLocatorArray = await readUint8Array(reader, endOfDirectoryInfo.offset - ZIP64_END_OF_CENTRAL_DIR_LOCATOR_LENGTH, ZIP64_END_OF_CENTRAL_DIR_LOCATOR_LENGTH);
  3172. const endOfDirectoryLocatorView = getDataView$1(endOfDirectoryLocatorArray);
  3173. if (getUint32(endOfDirectoryLocatorView, 0) == ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIGNATURE) {
  3174. directoryDataOffset = getBigUint64(endOfDirectoryLocatorView, 8);
  3175. let endOfDirectoryArray = await readUint8Array(reader, directoryDataOffset, ZIP64_END_OF_CENTRAL_DIR_LENGTH, -1);
  3176. let endOfDirectoryView = getDataView$1(endOfDirectoryArray);
  3177. const expectedDirectoryDataOffset = endOfDirectoryInfo.offset - ZIP64_END_OF_CENTRAL_DIR_LOCATOR_LENGTH - ZIP64_END_OF_CENTRAL_DIR_LENGTH;
  3178. if (getUint32(endOfDirectoryView, 0) != ZIP64_END_OF_CENTRAL_DIR_SIGNATURE && directoryDataOffset != expectedDirectoryDataOffset) {
  3179. const originalDirectoryDataOffset = directoryDataOffset;
  3180. directoryDataOffset = expectedDirectoryDataOffset;
  3181. if (directoryDataOffset > originalDirectoryDataOffset) {
  3182. prependedDataLength = directoryDataOffset - originalDirectoryDataOffset;
  3183. }
  3184. endOfDirectoryArray = await readUint8Array(reader, directoryDataOffset, ZIP64_END_OF_CENTRAL_DIR_LENGTH, -1);
  3185. endOfDirectoryView = getDataView$1(endOfDirectoryArray);
  3186. }
  3187. if (getUint32(endOfDirectoryView, 0) != ZIP64_END_OF_CENTRAL_DIR_SIGNATURE) {
  3188. throw new Error(ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND);
  3189. }
  3190. if (lastDiskNumber == MAX_16_BITS) {
  3191. lastDiskNumber = getUint32(endOfDirectoryView, 16);
  3192. }
  3193. if (diskNumber == MAX_16_BITS) {
  3194. diskNumber = getUint32(endOfDirectoryView, 20);
  3195. }
  3196. if (filesLength == MAX_16_BITS) {
  3197. filesLength = getBigUint64(endOfDirectoryView, 32);
  3198. }
  3199. if (directoryDataLength == MAX_32_BITS) {
  3200. directoryDataLength = getBigUint64(endOfDirectoryView, 40);
  3201. }
  3202. directoryDataOffset -= directoryDataLength;
  3203. }
  3204. }
  3205. if (directoryDataOffset >= reader.size) {
  3206. prependedDataLength = reader.size - directoryDataOffset - directoryDataLength - END_OF_CENTRAL_DIR_LENGTH;
  3207. directoryDataOffset = reader.size - directoryDataLength - END_OF_CENTRAL_DIR_LENGTH;
  3208. }
  3209. if (expectedLastDiskNumber != lastDiskNumber) {
  3210. throw new Error(ERR_SPLIT_ZIP_FILE);
  3211. }
  3212. if (directoryDataOffset < 0) {
  3213. throw new Error(ERR_BAD_FORMAT);
  3214. }
  3215. let offset = 0;
  3216. let directoryArray = await readUint8Array(reader, directoryDataOffset, directoryDataLength, diskNumber);
  3217. let directoryView = getDataView$1(directoryArray);
  3218. if (directoryDataLength) {
  3219. const expectedDirectoryDataOffset = endOfDirectoryInfo.offset - directoryDataLength;
  3220. if (getUint32(directoryView, offset) != CENTRAL_FILE_HEADER_SIGNATURE && directoryDataOffset != expectedDirectoryDataOffset) {
  3221. const originalDirectoryDataOffset = directoryDataOffset;
  3222. directoryDataOffset = expectedDirectoryDataOffset;
  3223. if (directoryDataOffset > originalDirectoryDataOffset) {
  3224. prependedDataLength += directoryDataOffset - originalDirectoryDataOffset;
  3225. }
  3226. directoryArray = await readUint8Array(reader, directoryDataOffset, directoryDataLength, diskNumber);
  3227. directoryView = getDataView$1(directoryArray);
  3228. }
  3229. }
  3230. const expectedDirectoryDataLength = endOfDirectoryInfo.offset - directoryDataOffset - (reader.lastDiskOffset || 0);
  3231. if (directoryDataLength != expectedDirectoryDataLength && expectedDirectoryDataLength >= 0) {
  3232. directoryDataLength = expectedDirectoryDataLength;
  3233. directoryArray = await readUint8Array(reader, directoryDataOffset, directoryDataLength, diskNumber);
  3234. directoryView = getDataView$1(directoryArray);
  3235. }
  3236. if (directoryDataOffset < 0 || directoryDataOffset >= reader.size) {
  3237. throw new Error(ERR_BAD_FORMAT);
  3238. }
  3239. const filenameEncoding = getOptionValue$1(zipReader, options, OPTION_FILENAME_ENCODING);
  3240. const commentEncoding = getOptionValue$1(zipReader, options, OPTION_COMMENT_ENCODING);
  3241. for (let indexFile = 0; indexFile < filesLength; indexFile++) {
  3242. const fileEntry = new ZipEntry$1(reader, config, zipReader.options);
  3243. if (getUint32(directoryView, offset) != CENTRAL_FILE_HEADER_SIGNATURE) {
  3244. throw new Error(ERR_CENTRAL_DIRECTORY_NOT_FOUND);
  3245. }
  3246. readCommonHeader(fileEntry, directoryView, offset + 6);
  3247. const languageEncodingFlag = Boolean(fileEntry.bitFlag.languageEncodingFlag);
  3248. const filenameOffset = offset + 46;
  3249. const extraFieldOffset = filenameOffset + fileEntry.filenameLength;
  3250. const commentOffset = extraFieldOffset + fileEntry.extraFieldLength;
  3251. const versionMadeBy = getUint16(directoryView, offset + 4);
  3252. const msDosCompatible = versionMadeBy >> 8 == 0;
  3253. const unixCompatible = versionMadeBy >> 8 == 3;
  3254. const rawFilename = directoryArray.subarray(filenameOffset, extraFieldOffset);
  3255. const commentLength = getUint16(directoryView, offset + 32);
  3256. const endOffset = commentOffset + commentLength;
  3257. const rawComment = directoryArray.subarray(commentOffset, endOffset);
  3258. const filenameUTF8 = languageEncodingFlag;
  3259. const commentUTF8 = languageEncodingFlag;
  3260. const externalFileAttributes = getUint32(directoryView, offset + 38);
  3261. const msdosAttributesRaw = externalFileAttributes & MAX_8_BITS;
  3262. const msdosAttributes = {
  3263. readOnly: Boolean(msdosAttributesRaw & FILE_ATTR_MSDOS_READONLY_MASK),
  3264. hidden: Boolean(msdosAttributesRaw & FILE_ATTR_MSDOS_HIDDEN_MASK),
  3265. system: Boolean(msdosAttributesRaw & FILE_ATTR_MSDOS_SYSTEM_MASK),
  3266. directory: Boolean(msdosAttributesRaw & FILE_ATTR_MSDOS_DIR_MASK),
  3267. archive: Boolean(msdosAttributesRaw & FILE_ATTR_MSDOS_ARCHIVE_MASK)
  3268. };
  3269. const offsetFileEntry = getUint32(directoryView, offset + 42) + prependedDataLength;
  3270. const decode = getOptionValue$1(zipReader, options, OPTION_DECODE_TEXT) || decodeText;
  3271. const rawFilenameEncoding = filenameUTF8 ? CHARSET_UTF8 : filenameEncoding || CHARSET_CP437;
  3272. const rawCommentEncoding = commentUTF8 ? CHARSET_UTF8 : commentEncoding || CHARSET_CP437;
  3273. let filename = decode(rawFilename, rawFilenameEncoding);
  3274. if (filename === UNDEFINED_VALUE) {
  3275. filename = decodeText(rawFilename, rawFilenameEncoding);
  3276. }
  3277. let comment = decode(rawComment, rawCommentEncoding);
  3278. if (comment === UNDEFINED_VALUE) {
  3279. comment = decodeText(rawComment, rawCommentEncoding);
  3280. }
  3281. Object.assign(fileEntry, {
  3282. versionMadeBy,
  3283. msDosCompatible,
  3284. compressedSize: 0,
  3285. uncompressedSize: 0,
  3286. commentLength,
  3287. offset: offsetFileEntry,
  3288. diskNumberStart: getUint16(directoryView, offset + 34),
  3289. internalFileAttributes: getUint16(directoryView, offset + 36),
  3290. externalFileAttributes,
  3291. msdosAttributesRaw,
  3292. msdosAttributes,
  3293. rawFilename,
  3294. filenameUTF8,
  3295. commentUTF8,
  3296. rawExtraField: directoryArray.subarray(extraFieldOffset, commentOffset),
  3297. rawComment,
  3298. filename,
  3299. comment
  3300. });
  3301. startOffset = Math.max(offsetFileEntry, startOffset);
  3302. readCommonFooter(fileEntry, fileEntry, directoryView, offset + 6);
  3303. const unixExternalUpper = (fileEntry.externalFileAttributes >> 16) & MAX_16_BITS;
  3304. if (fileEntry.unixMode === UNDEFINED_VALUE && (unixExternalUpper & (FILE_ATTR_UNIX_DEFAULT_MASK | FILE_ATTR_UNIX_EXECUTABLE_MASK | FILE_ATTR_UNIX_TYPE_DIR)) != 0) {
  3305. fileEntry.unixMode = unixExternalUpper;
  3306. }
  3307. const setuid = Boolean(fileEntry.unixMode & FILE_ATTR_UNIX_SETUID_MASK);
  3308. const setgid = Boolean(fileEntry.unixMode & FILE_ATTR_UNIX_SETGID_MASK);
  3309. const sticky = Boolean(fileEntry.unixMode & FILE_ATTR_UNIX_STICKY_MASK);
  3310. const executable = (fileEntry.unixMode !== UNDEFINED_VALUE)
  3311. ? ((fileEntry.unixMode & FILE_ATTR_UNIX_EXECUTABLE_MASK) != 0)
  3312. : (unixCompatible && ((unixExternalUpper & FILE_ATTR_UNIX_EXECUTABLE_MASK) != 0));
  3313. const modeIsDir = fileEntry.unixMode !== UNDEFINED_VALUE && ((fileEntry.unixMode & FILE_ATTR_UNIX_TYPE_MASK) == FILE_ATTR_UNIX_TYPE_DIR);
  3314. const upperIsDir = ((unixExternalUpper & FILE_ATTR_UNIX_TYPE_MASK) == FILE_ATTR_UNIX_TYPE_DIR);
  3315. Object.assign(fileEntry, {
  3316. setuid,
  3317. setgid,
  3318. sticky,
  3319. unixExternalUpper,
  3320. internalFileAttribute: fileEntry.internalFileAttributes,
  3321. externalFileAttribute: fileEntry.externalFileAttributes,
  3322. executable,
  3323. directory: modeIsDir || upperIsDir || (msDosCompatible && msdosAttributes.directory) || (filename.endsWith(DIRECTORY_SIGNATURE) && !fileEntry.uncompressedSize),
  3324. zipCrypto: fileEntry.encrypted && !fileEntry.extraFieldAES
  3325. });
  3326. const entry = new Entry(fileEntry);
  3327. entry.getData = (writer, options) => fileEntry.getData(writer, entry, zipReader.readRanges, options);
  3328. entry.arrayBuffer = async options => {
  3329. const writer = new TransformStream();
  3330. const [arrayBuffer] = await Promise.all([
  3331. new Response(writer.readable).arrayBuffer(),
  3332. fileEntry.getData(writer, entry, zipReader.readRanges, options)]);
  3333. return arrayBuffer;
  3334. };
  3335. offset = endOffset;
  3336. const { onprogress } = options;
  3337. if (onprogress) {
  3338. try {
  3339. await onprogress(indexFile + 1, filesLength, new Entry(fileEntry));
  3340. } catch {
  3341. // ignored
  3342. }
  3343. }
  3344. yield entry;
  3345. }
  3346. const extractPrependedData = getOptionValue$1(zipReader, options, OPTION_EXTRACT_PREPENDED_DATA);
  3347. const extractAppendedData = getOptionValue$1(zipReader, options, OPTION_EXTRACT_APPENDED_DATA);
  3348. if (extractPrependedData) {
  3349. zipReader.prependedData = startOffset > 0 ? await readUint8Array(reader, 0, startOffset) : new Uint8Array();
  3350. }
  3351. zipReader.comment = commentLength ? await readUint8Array(reader, commentOffset + END_OF_CENTRAL_DIR_LENGTH, commentLength) : new Uint8Array();
  3352. if (extractAppendedData) {
  3353. zipReader.appendedData = appendedDataOffset < reader.size ? await readUint8Array(reader, appendedDataOffset, reader.size - appendedDataOffset) : new Uint8Array();
  3354. }
  3355. return true;
  3356. }
  3357. async getEntries(options = {}) {
  3358. const entries = [];
  3359. for await (const entry of this.getEntriesGenerator(options)) {
  3360. entries.push(entry);
  3361. }
  3362. return entries;
  3363. }
  3364. async close() {
  3365. }
  3366. }
  3367. class ZipReaderStream {
  3368. constructor(options = {}) {
  3369. const { readable, writable } = new TransformStream();
  3370. const gen = new ZipReader(readable, options).getEntriesGenerator();
  3371. this.readable = new ReadableStream({
  3372. async pull(controller) {
  3373. const { done, value } = await gen.next();
  3374. if (done)
  3375. return controller.close();
  3376. const chunk = {
  3377. ...value,
  3378. readable: (function () {
  3379. const { readable, writable } = new TransformStream();
  3380. if (value.getData) {
  3381. value.getData(writable);
  3382. return readable;
  3383. }
  3384. })()
  3385. };
  3386. delete chunk.getData;
  3387. controller.enqueue(chunk);
  3388. }
  3389. });
  3390. this.writable = writable;
  3391. }
  3392. }
  3393. let ZipEntry$1 = class ZipEntry {
  3394. constructor(reader, config, options) {
  3395. Object.assign(this, {
  3396. reader,
  3397. config,
  3398. options
  3399. });
  3400. }
  3401. async getData(writer, fileEntry, readRanges, options = {}) {
  3402. const zipEntry = this;
  3403. const {
  3404. reader,
  3405. offset,
  3406. diskNumberStart,
  3407. extraFieldAES,
  3408. extraFieldZip64,
  3409. compressionMethod,
  3410. config,
  3411. bitFlag,
  3412. signature,
  3413. rawLastModDate,
  3414. uncompressedSize,
  3415. compressedSize
  3416. } = zipEntry;
  3417. const {
  3418. dataDescriptor
  3419. } = bitFlag;
  3420. const localDirectory = fileEntry.localDirectory = {};
  3421. const dataArray = await readUint8Array(reader, offset, HEADER_SIZE, diskNumberStart);
  3422. const dataView = getDataView$1(dataArray);
  3423. let password = getOptionValue$1(zipEntry, options, OPTION_PASSWORD);
  3424. let rawPassword = getOptionValue$1(zipEntry, options, OPTION_RAW_PASSWORD);
  3425. const passThrough = getOptionValue$1(zipEntry, options, OPTION_PASS_THROUGH);
  3426. password = password && password.length && password;
  3427. rawPassword = rawPassword && rawPassword.length && rawPassword;
  3428. if (extraFieldAES) {
  3429. if (extraFieldAES.originalCompressionMethod != COMPRESSION_METHOD_AES) {
  3430. throw new Error(ERR_UNSUPPORTED_COMPRESSION);
  3431. }
  3432. }
  3433. if ((compressionMethod != COMPRESSION_METHOD_STORE && compressionMethod != COMPRESSION_METHOD_DEFLATE && compressionMethod != COMPRESSION_METHOD_DEFLATE_64) && !passThrough) {
  3434. throw new Error(ERR_UNSUPPORTED_COMPRESSION);
  3435. }
  3436. if (getUint32(dataView, 0) != LOCAL_FILE_HEADER_SIGNATURE) {
  3437. throw new Error(ERR_LOCAL_FILE_HEADER_NOT_FOUND);
  3438. }
  3439. readCommonHeader(localDirectory, dataView, 4);
  3440. const {
  3441. extraFieldLength,
  3442. filenameLength,
  3443. lastAccessDate,
  3444. creationDate
  3445. } = localDirectory;
  3446. localDirectory.rawExtraField = extraFieldLength ?
  3447. await readUint8Array(reader, offset + HEADER_SIZE + filenameLength, extraFieldLength, diskNumberStart) :
  3448. new Uint8Array();
  3449. readCommonFooter(zipEntry, localDirectory, dataView, 4, true);
  3450. Object.assign(fileEntry, { lastAccessDate, creationDate });
  3451. const encrypted = zipEntry.encrypted && localDirectory.encrypted && !passThrough;
  3452. const zipCrypto = encrypted && !extraFieldAES;
  3453. if (!passThrough) {
  3454. fileEntry.zipCrypto = zipCrypto;
  3455. }
  3456. if (encrypted) {
  3457. if (!zipCrypto && extraFieldAES.strength === UNDEFINED_VALUE) {
  3458. throw new Error(ERR_UNSUPPORTED_ENCRYPTION);
  3459. } else if (!password && !rawPassword) {
  3460. throw new Error(ERR_ENCRYPTED);
  3461. }
  3462. }
  3463. const dataOffset = offset + HEADER_SIZE + filenameLength + extraFieldLength;
  3464. const size = compressedSize;
  3465. const readable = reader.readable;
  3466. Object.assign(readable, {
  3467. diskNumberStart,
  3468. offset: dataOffset,
  3469. size
  3470. });
  3471. const signal = getOptionValue$1(zipEntry, options, OPTION_SIGNAL);
  3472. const checkPasswordOnly = getOptionValue$1(zipEntry, options, OPTION_CHECK_PASSWORD_ONLY);
  3473. let checkOverlappingEntry = getOptionValue$1(zipEntry, options, OPTION_CHECK_OVERLAPPING_ENTRY);
  3474. const checkOverlappingEntryOnly = getOptionValue$1(zipEntry, options, OPTION_CHECK_OVERLAPPING_ENTRY_ONLY);
  3475. if (checkOverlappingEntryOnly) {
  3476. checkOverlappingEntry = true;
  3477. }
  3478. const { onstart, onprogress, onend } = options;
  3479. const deflate64 = compressionMethod == COMPRESSION_METHOD_DEFLATE_64;
  3480. let useCompressionStream = getOptionValue$1(zipEntry, options, OPTION_USE_COMPRESSION_STREAM);
  3481. if (deflate64) {
  3482. useCompressionStream = false;
  3483. }
  3484. const workerOptions = {
  3485. options: {
  3486. codecType: CODEC_INFLATE,
  3487. password,
  3488. rawPassword,
  3489. zipCrypto,
  3490. encryptionStrength: extraFieldAES && extraFieldAES.strength,
  3491. signed: getOptionValue$1(zipEntry, options, OPTION_CHECK_SIGNATURE) && !passThrough,
  3492. passwordVerification: zipCrypto && (dataDescriptor ? ((rawLastModDate >>> 8) & MAX_8_BITS) : ((signature >>> 24) & MAX_8_BITS)),
  3493. outputSize: passThrough ? compressedSize : uncompressedSize,
  3494. signature,
  3495. compressed: compressionMethod != 0 && !passThrough,
  3496. encrypted: zipEntry.encrypted && !passThrough,
  3497. useWebWorkers: getOptionValue$1(zipEntry, options, OPTION_USE_WEB_WORKERS),
  3498. useCompressionStream,
  3499. transferStreams: getOptionValue$1(zipEntry, options, OPTION_TRANSFER_STREAMS),
  3500. deflate64,
  3501. checkPasswordOnly
  3502. },
  3503. config,
  3504. streamOptions: { signal, size, onstart, onprogress, onend }
  3505. };
  3506. if (checkOverlappingEntry) {
  3507. await detectOverlappingEntry({
  3508. reader,
  3509. fileEntry,
  3510. offset,
  3511. diskNumberStart,
  3512. signature,
  3513. compressedSize,
  3514. uncompressedSize,
  3515. dataOffset,
  3516. dataDescriptor: dataDescriptor || localDirectory.bitFlag.dataDescriptor,
  3517. extraFieldZip64: extraFieldZip64 || localDirectory.extraFieldZip64,
  3518. readRanges
  3519. });
  3520. }
  3521. let writable;
  3522. try {
  3523. if (!checkOverlappingEntryOnly) {
  3524. if (checkPasswordOnly) {
  3525. writer = new WritableStream();
  3526. }
  3527. writer = new GenericWriter(writer);
  3528. await initStream(writer, passThrough ? compressedSize : uncompressedSize);
  3529. ({ writable } = writer);
  3530. const { outputSize } = await runWorker({ readable, writable }, workerOptions);
  3531. writer.size += outputSize;
  3532. if (outputSize != (passThrough ? compressedSize : uncompressedSize)) {
  3533. throw new Error(ERR_INVALID_UNCOMPRESSED_SIZE);
  3534. }
  3535. }
  3536. } catch (error) {
  3537. if (error.outputSize !== UNDEFINED_VALUE) {
  3538. writer.size += error.outputSize;
  3539. }
  3540. if (!checkPasswordOnly || error.message != ERR_ABORT_CHECK_PASSWORD) {
  3541. throw error;
  3542. }
  3543. } finally {
  3544. const preventClose = getOptionValue$1(zipEntry, options, OPTION_PREVENT_CLOSE);
  3545. if (!preventClose && writable && !writable.locked) {
  3546. await writable.getWriter().close();
  3547. }
  3548. }
  3549. return checkPasswordOnly || checkOverlappingEntryOnly ? UNDEFINED_VALUE : writer.getData ? writer.getData() : writable;
  3550. }
  3551. };
  3552. function readCommonHeader(directory, dataView, offset) {
  3553. const rawBitFlag = directory.rawBitFlag = getUint16(dataView, offset + 2);
  3554. const encrypted = (rawBitFlag & BITFLAG_ENCRYPTED) == BITFLAG_ENCRYPTED;
  3555. const rawLastModDate = getUint32(dataView, offset + 6);
  3556. Object.assign(directory, {
  3557. encrypted,
  3558. version: getUint16(dataView, offset),
  3559. bitFlag: {
  3560. level: (rawBitFlag & BITFLAG_LEVEL) >> 1,
  3561. dataDescriptor: (rawBitFlag & BITFLAG_DATA_DESCRIPTOR) == BITFLAG_DATA_DESCRIPTOR,
  3562. languageEncodingFlag: (rawBitFlag & BITFLAG_LANG_ENCODING_FLAG) == BITFLAG_LANG_ENCODING_FLAG
  3563. },
  3564. rawLastModDate,
  3565. lastModDate: getDate(rawLastModDate),
  3566. filenameLength: getUint16(dataView, offset + 22),
  3567. extraFieldLength: getUint16(dataView, offset + 24)
  3568. });
  3569. }
  3570. function readCommonFooter(fileEntry, directory, dataView, offset, localDirectory) {
  3571. const { rawExtraField } = directory;
  3572. const extraField = directory.extraField = new Map();
  3573. const rawExtraFieldView = getDataView$1(new Uint8Array(rawExtraField));
  3574. let offsetExtraField = 0;
  3575. try {
  3576. while (offsetExtraField < rawExtraField.length) {
  3577. const type = getUint16(rawExtraFieldView, offsetExtraField);
  3578. const size = getUint16(rawExtraFieldView, offsetExtraField + 2);
  3579. extraField.set(type, {
  3580. type,
  3581. data: rawExtraField.slice(offsetExtraField + 4, offsetExtraField + 4 + size)
  3582. });
  3583. offsetExtraField += 4 + size;
  3584. }
  3585. } catch {
  3586. // ignored
  3587. }
  3588. const compressionMethod = getUint16(dataView, offset + 4);
  3589. Object.assign(directory, {
  3590. signature: getUint32(dataView, offset + HEADER_OFFSET_SIGNATURE),
  3591. compressedSize: getUint32(dataView, offset + HEADER_OFFSET_COMPRESSED_SIZE),
  3592. uncompressedSize: getUint32(dataView, offset + HEADER_OFFSET_UNCOMPRESSED_SIZE)
  3593. });
  3594. const extraFieldZip64 = extraField.get(EXTRAFIELD_TYPE_ZIP64);
  3595. if (extraFieldZip64) {
  3596. readExtraFieldZip64(extraFieldZip64, directory);
  3597. directory.extraFieldZip64 = extraFieldZip64;
  3598. }
  3599. const extraFieldUnicodePath = extraField.get(EXTRAFIELD_TYPE_UNICODE_PATH);
  3600. if (extraFieldUnicodePath) {
  3601. readExtraFieldUnicode(extraFieldUnicodePath, PROPERTY_NAME_FILENAME, PROPERTY_NAME_RAW_FILENAME, directory, fileEntry);
  3602. directory.extraFieldUnicodePath = extraFieldUnicodePath;
  3603. }
  3604. const extraFieldUnicodeComment = extraField.get(EXTRAFIELD_TYPE_UNICODE_COMMENT);
  3605. if (extraFieldUnicodeComment) {
  3606. readExtraFieldUnicode(extraFieldUnicodeComment, PROPERTY_NAME_COMMENT, PROPERTY_NAME_RAW_COMMENT, directory, fileEntry);
  3607. directory.extraFieldUnicodeComment = extraFieldUnicodeComment;
  3608. }
  3609. const extraFieldAES = extraField.get(EXTRAFIELD_TYPE_AES);
  3610. if (extraFieldAES) {
  3611. readExtraFieldAES(extraFieldAES, directory, compressionMethod);
  3612. directory.extraFieldAES = extraFieldAES;
  3613. } else {
  3614. directory.compressionMethod = compressionMethod;
  3615. }
  3616. const extraFieldNTFS = extraField.get(EXTRAFIELD_TYPE_NTFS);
  3617. if (extraFieldNTFS) {
  3618. readExtraFieldNTFS(extraFieldNTFS, directory);
  3619. directory.extraFieldNTFS = extraFieldNTFS;
  3620. }
  3621. const extraFieldUnix = extraField.get(EXTRAFIELD_TYPE_UNIX);
  3622. if (extraFieldUnix) {
  3623. readExtraFieldUnix(extraFieldUnix, directory, false);
  3624. directory.extraFieldUnix = extraFieldUnix;
  3625. } else {
  3626. const extraFieldInfoZip = extraField.get(EXTRAFIELD_TYPE_INFOZIP);
  3627. if (extraFieldInfoZip) {
  3628. readExtraFieldUnix(extraFieldInfoZip, directory, true);
  3629. directory.extraFieldInfoZip = extraFieldInfoZip;
  3630. }
  3631. }
  3632. const extraFieldExtendedTimestamp = extraField.get(EXTRAFIELD_TYPE_EXTENDED_TIMESTAMP);
  3633. if (extraFieldExtendedTimestamp) {
  3634. readExtraFieldExtendedTimestamp(extraFieldExtendedTimestamp, directory, localDirectory);
  3635. directory.extraFieldExtendedTimestamp = extraFieldExtendedTimestamp;
  3636. }
  3637. const extraFieldUSDZ = extraField.get(EXTRAFIELD_TYPE_USDZ);
  3638. if (extraFieldUSDZ) {
  3639. directory.extraFieldUSDZ = extraFieldUSDZ;
  3640. }
  3641. }
  3642. function readExtraFieldZip64(extraFieldZip64, directory) {
  3643. directory.zip64 = true;
  3644. const extraFieldView = getDataView$1(extraFieldZip64.data);
  3645. const missingProperties = ZIP64_PROPERTIES.filter(([propertyName, max]) => directory[propertyName] == max);
  3646. for (let indexMissingProperty = 0, offset = 0; indexMissingProperty < missingProperties.length; indexMissingProperty++) {
  3647. const [propertyName, max] = missingProperties[indexMissingProperty];
  3648. if (directory[propertyName] == max) {
  3649. const extraction = ZIP64_EXTRACTION[max];
  3650. directory[propertyName] = extraFieldZip64[propertyName] = extraction.getValue(extraFieldView, offset);
  3651. offset += extraction.bytes;
  3652. } else if (extraFieldZip64[propertyName]) {
  3653. throw new Error(ERR_EXTRAFIELD_ZIP64_NOT_FOUND);
  3654. }
  3655. }
  3656. }
  3657. function readExtraFieldUnicode(extraFieldUnicode, propertyName, rawPropertyName, directory, fileEntry) {
  3658. const extraFieldView = getDataView$1(extraFieldUnicode.data);
  3659. const crc32 = new Crc32();
  3660. crc32.append(fileEntry[rawPropertyName]);
  3661. const dataViewSignature = getDataView$1(new Uint8Array(4));
  3662. dataViewSignature.setUint32(0, crc32.get(), true);
  3663. const signature = getUint32(extraFieldView, 1);
  3664. Object.assign(extraFieldUnicode, {
  3665. version: getUint8(extraFieldView, 0),
  3666. [propertyName]: decodeText(extraFieldUnicode.data.subarray(5)),
  3667. valid: !fileEntry.bitFlag.languageEncodingFlag && signature == getUint32(dataViewSignature, 0)
  3668. });
  3669. if (extraFieldUnicode.valid) {
  3670. directory[propertyName] = extraFieldUnicode[propertyName];
  3671. directory[propertyName + PROPERTY_NAME_UTF8_SUFFIX] = true;
  3672. }
  3673. }
  3674. function readExtraFieldAES(extraFieldAES, directory, compressionMethod) {
  3675. const extraFieldView = getDataView$1(extraFieldAES.data);
  3676. const strength = getUint8(extraFieldView, 4);
  3677. Object.assign(extraFieldAES, {
  3678. vendorVersion: getUint8(extraFieldView, 0),
  3679. vendorId: getUint8(extraFieldView, 2),
  3680. strength,
  3681. originalCompressionMethod: compressionMethod,
  3682. compressionMethod: getUint16(extraFieldView, 5)
  3683. });
  3684. directory.compressionMethod = extraFieldAES.compressionMethod;
  3685. }
  3686. function readExtraFieldNTFS(extraFieldNTFS, directory) {
  3687. const extraFieldView = getDataView$1(extraFieldNTFS.data);
  3688. let offsetExtraField = 4;
  3689. let tag1Data;
  3690. try {
  3691. while (offsetExtraField < extraFieldNTFS.data.length && !tag1Data) {
  3692. const tagValue = getUint16(extraFieldView, offsetExtraField);
  3693. const attributeSize = getUint16(extraFieldView, offsetExtraField + 2);
  3694. if (tagValue == EXTRAFIELD_TYPE_NTFS_TAG1) {
  3695. tag1Data = extraFieldNTFS.data.slice(offsetExtraField + 4, offsetExtraField + 4 + attributeSize);
  3696. }
  3697. offsetExtraField += 4 + attributeSize;
  3698. }
  3699. } catch {
  3700. // ignored
  3701. }
  3702. try {
  3703. if (tag1Data && tag1Data.length == 24) {
  3704. const tag1View = getDataView$1(tag1Data);
  3705. const rawLastModDate = tag1View.getBigUint64(0, true);
  3706. const rawLastAccessDate = tag1View.getBigUint64(8, true);
  3707. const rawCreationDate = tag1View.getBigUint64(16, true);
  3708. Object.assign(extraFieldNTFS, {
  3709. rawLastModDate,
  3710. rawLastAccessDate,
  3711. rawCreationDate
  3712. });
  3713. const lastModDate = getDateNTFS(rawLastModDate);
  3714. const lastAccessDate = getDateNTFS(rawLastAccessDate);
  3715. const creationDate = getDateNTFS(rawCreationDate);
  3716. const extraFieldData = { lastModDate, lastAccessDate, creationDate };
  3717. Object.assign(extraFieldNTFS, extraFieldData);
  3718. Object.assign(directory, extraFieldData);
  3719. }
  3720. } catch {
  3721. // ignored
  3722. }
  3723. }
  3724. function readExtraFieldUnix(extraField, directory, isInfoZip) {
  3725. try {
  3726. const view = getDataView$1(new Uint8Array(extraField.data));
  3727. let offset = 0;
  3728. const version = getUint8(view, offset++);
  3729. const uidSize = getUint8(view, offset++);
  3730. const uidBytes = extraField.data.subarray(offset, offset + uidSize);
  3731. offset += uidSize;
  3732. const uid = unpackUnixId(uidBytes);
  3733. const gidSize = getUint8(view, offset++);
  3734. const gidBytes = extraField.data.subarray(offset, offset + gidSize);
  3735. offset += gidSize;
  3736. const gid = unpackUnixId(gidBytes);
  3737. let unixMode = UNDEFINED_VALUE;
  3738. if (!isInfoZip && offset + 2 <= extraField.data.length) {
  3739. const base = extraField.data;
  3740. const modeView = new DataView(base.buffer, base.byteOffset + offset, 2);
  3741. unixMode = modeView.getUint16(0, true);
  3742. }
  3743. Object.assign(extraField, { version, uid, gid, unixMode });
  3744. if (uid !== UNDEFINED_VALUE) {
  3745. directory.uid = uid;
  3746. }
  3747. if (gid !== UNDEFINED_VALUE) {
  3748. directory.gid = gid;
  3749. }
  3750. if (unixMode !== UNDEFINED_VALUE) {
  3751. directory.unixMode = unixMode;
  3752. }
  3753. } catch {
  3754. // ignored
  3755. }
  3756. }
  3757. function unpackUnixId(bytes) {
  3758. const buffer = new Uint8Array(4);
  3759. buffer.set(bytes, 0);
  3760. const view = new DataView(buffer.buffer, buffer.byteOffset, 4);
  3761. return view.getUint32(0, true);
  3762. }
  3763. function readExtraFieldExtendedTimestamp(extraFieldExtendedTimestamp, directory, localDirectory) {
  3764. const extraFieldView = getDataView$1(extraFieldExtendedTimestamp.data);
  3765. const flags = getUint8(extraFieldView, 0);
  3766. const timeProperties = [];
  3767. const timeRawProperties = [];
  3768. if (localDirectory) {
  3769. if ((flags & 0x1) == 0x1) {
  3770. timeProperties.push(PROPERTY_NAME_LAST_MODIFICATION_DATE);
  3771. timeRawProperties.push(PROPERTY_NAME_RAW_LAST_MODIFICATION_DATE);
  3772. }
  3773. if ((flags & 0x2) == 0x2) {
  3774. timeProperties.push(PROPERTY_NAME_LAST_ACCESS_DATE);
  3775. timeRawProperties.push(PROPERTY_NAME_RAW_LAST_ACCESS_DATE);
  3776. }
  3777. if ((flags & 0x4) == 0x4) {
  3778. timeProperties.push(PROPERTY_NAME_CREATION_DATE);
  3779. timeRawProperties.push(PROPERTY_NAME_RAW_CREATION_DATE);
  3780. }
  3781. } else if (extraFieldExtendedTimestamp.data.length >= 5) {
  3782. timeProperties.push(PROPERTY_NAME_LAST_MODIFICATION_DATE);
  3783. timeRawProperties.push(PROPERTY_NAME_RAW_LAST_MODIFICATION_DATE);
  3784. }
  3785. let offset = 1;
  3786. timeProperties.forEach((propertyName, indexProperty) => {
  3787. if (extraFieldExtendedTimestamp.data.length >= offset + 4) {
  3788. const time = getUint32(extraFieldView, offset);
  3789. directory[propertyName] = extraFieldExtendedTimestamp[propertyName] = new Date(time * 1000);
  3790. const rawPropertyName = timeRawProperties[indexProperty];
  3791. extraFieldExtendedTimestamp[rawPropertyName] = time;
  3792. }
  3793. offset += 4;
  3794. });
  3795. }
  3796. async function detectOverlappingEntry({
  3797. reader,
  3798. fileEntry,
  3799. offset,
  3800. diskNumberStart,
  3801. signature,
  3802. compressedSize,
  3803. uncompressedSize,
  3804. dataOffset,
  3805. dataDescriptor,
  3806. extraFieldZip64,
  3807. readRanges
  3808. }) {
  3809. let diskOffset = 0;
  3810. if (diskNumberStart) {
  3811. for (let indexReader = 0; indexReader < diskNumberStart; indexReader++) {
  3812. const diskReader = reader.readers[indexReader];
  3813. diskOffset += diskReader.size;
  3814. }
  3815. }
  3816. let dataDescriptorLength = 0;
  3817. if (dataDescriptor) {
  3818. if (extraFieldZip64) {
  3819. dataDescriptorLength = DATA_DESCRIPTOR_RECORD_ZIP_64_LENGTH;
  3820. } else {
  3821. dataDescriptorLength = DATA_DESCRIPTOR_RECORD_LENGTH;
  3822. }
  3823. }
  3824. if (dataDescriptorLength) {
  3825. const dataDescriptorArray = await readUint8Array(reader, dataOffset + compressedSize, dataDescriptorLength + DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH, diskNumberStart);
  3826. const dataDescriptorSignature = getUint32(getDataView$1(dataDescriptorArray), 0) == DATA_DESCRIPTOR_RECORD_SIGNATURE;
  3827. if (dataDescriptorSignature) {
  3828. const readSignature = getUint32(getDataView$1(dataDescriptorArray), 4);
  3829. let readCompressedSize;
  3830. let readUncompressedSize;
  3831. if (extraFieldZip64) {
  3832. readCompressedSize = getBigUint64(getDataView$1(dataDescriptorArray), 8);
  3833. readUncompressedSize = getBigUint64(getDataView$1(dataDescriptorArray), 16);
  3834. } else {
  3835. readCompressedSize = getUint32(getDataView$1(dataDescriptorArray), 8);
  3836. readUncompressedSize = getUint32(getDataView$1(dataDescriptorArray), 12);
  3837. }
  3838. const matchSignature = (fileEntry.encrypted && !fileEntry.zipCrypto) || readSignature == signature;
  3839. if (matchSignature &&
  3840. readCompressedSize == compressedSize &&
  3841. readUncompressedSize == uncompressedSize) {
  3842. dataDescriptorLength += DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH;
  3843. }
  3844. }
  3845. }
  3846. const range = {
  3847. start: diskOffset + offset,
  3848. end: diskOffset + dataOffset + compressedSize + dataDescriptorLength,
  3849. fileEntry
  3850. };
  3851. for (const otherRange of readRanges) {
  3852. if (otherRange.fileEntry != fileEntry && range.start >= otherRange.start && range.start < otherRange.end) {
  3853. const error = new Error(ERR_OVERLAPPING_ENTRY);
  3854. error.overlappingEntry = otherRange.fileEntry;
  3855. throw error;
  3856. }
  3857. }
  3858. readRanges.push(range);
  3859. }
  3860. async function seekSignature(reader, signature, startOffset, minimumBytes, maximumLength) {
  3861. const signatureArray = new Uint8Array(4);
  3862. const signatureView = getDataView$1(signatureArray);
  3863. setUint32$1(signatureView, 0, signature);
  3864. const maximumBytes = minimumBytes + maximumLength;
  3865. return (await seek(minimumBytes)) || await seek(Math.min(maximumBytes, startOffset));
  3866. async function seek(length) {
  3867. const offset = startOffset - length;
  3868. const bytes = await readUint8Array(reader, offset, length);
  3869. for (let indexByte = bytes.length - minimumBytes; indexByte >= 0; indexByte--) {
  3870. if (bytes[indexByte] == signatureArray[0] && bytes[indexByte + 1] == signatureArray[1] &&
  3871. bytes[indexByte + 2] == signatureArray[2] && bytes[indexByte + 3] == signatureArray[3]) {
  3872. return {
  3873. offset: offset + indexByte,
  3874. buffer: bytes.slice(indexByte, indexByte + minimumBytes).buffer
  3875. };
  3876. }
  3877. }
  3878. }
  3879. }
  3880. function getOptionValue$1(zipReader, options, name) {
  3881. return options[name] === UNDEFINED_VALUE ? zipReader.options[name] : options[name];
  3882. }
  3883. function getDate(timeRaw) {
  3884. const date = (timeRaw & 0xffff0000) >> 16, time = timeRaw & MAX_16_BITS;
  3885. try {
  3886. return new Date(1980 + ((date & 0xFE00) >> 9), ((date & 0x01E0) >> 5) - 1, date & 0x001F, (time & 0xF800) >> 11, (time & 0x07E0) >> 5, (time & 0x001F) * 2, 0);
  3887. } catch {
  3888. // ignored
  3889. }
  3890. }
  3891. function getDateNTFS(timeRaw) {
  3892. return new Date((Number((timeRaw / BigInt(10000)) - BigInt(11644473600000))));
  3893. }
  3894. function getUint8(view, offset) {
  3895. return view.getUint8(offset);
  3896. }
  3897. function getUint16(view, offset) {
  3898. return view.getUint16(offset, true);
  3899. }
  3900. function getUint32(view, offset) {
  3901. return view.getUint32(offset, true);
  3902. }
  3903. function getBigUint64(view, offset) {
  3904. return Number(view.getBigUint64(offset, true));
  3905. }
  3906. function setUint32$1(view, offset, value) {
  3907. view.setUint32(offset, value, true);
  3908. }
  3909. function getDataView$1(array) {
  3910. return new DataView(array.buffer);
  3911. }
  3912. /*
  3913. Copyright (c) 2025 Gildas Lormeau. All rights reserved.
  3914. Redistribution and use in source and binary forms, with or without
  3915. modification, are permitted provided that the following conditions are met:
  3916. 1. Redistributions of source code must retain the above copyright notice,
  3917. this list of conditions and the following disclaimer.
  3918. 2. Redistributions in binary form must reproduce the above copyright
  3919. notice, this list of conditions and the following disclaimer in
  3920. the documentation and/or other materials provided with the distribution.
  3921. 3. The names of the authors may not be used to endorse or promote products
  3922. derived from this software without specific prior written permission.
  3923. THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  3924. INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  3925. FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
  3926. INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
  3927. INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  3928. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
  3929. OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  3930. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  3931. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  3932. EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  3933. */
  3934. const ERR_DUPLICATED_NAME = "File already exists";
  3935. const ERR_INVALID_COMMENT = "Zip file comment exceeds 64KB";
  3936. const ERR_INVALID_ENTRY_COMMENT = "File entry comment exceeds 64KB";
  3937. const ERR_INVALID_ENTRY_NAME = "File entry name exceeds 64KB";
  3938. const ERR_INVALID_VERSION = "Version exceeds 65535";
  3939. const ERR_INVALID_ENCRYPTION_STRENGTH = "The strength must equal 1, 2, or 3";
  3940. const ERR_INVALID_EXTRAFIELD_TYPE = "Extra field type exceeds 65535";
  3941. const ERR_INVALID_EXTRAFIELD_DATA = "Extra field data exceeds 64KB";
  3942. const ERR_UNSUPPORTED_FORMAT = "Zip64 is not supported (set the 'zip64' option to 'true')";
  3943. const ERR_UNDEFINED_UNCOMPRESSED_SIZE = "Undefined uncompressed size";
  3944. const ERR_ZIP_NOT_EMPTY = "Zip file not empty";
  3945. const ERR_INVALID_UID = "Invalid uid (must be integer 0..2^32-1)";
  3946. const ERR_INVALID_GID = "Invalid gid (must be integer 0..2^32-1)";
  3947. const ERR_INVALID_UNIX_MODE = "Invalid UNIX mode (must be integer 0..65535)";
  3948. const ERR_INVALID_UNIX_EXTRA_FIELD_TYPE = "Invalid unixExtraFieldType (must be 'infozip' or 'unix')";
  3949. const ERR_INVALID_MSDOS_ATTRIBUTES = "Invalid msdosAttributesRaw (must be integer 0..255)";
  3950. const ERR_INVALID_MSDOS_DATA = "Invalid msdosAttributes (must be an object with boolean flags)";
  3951. const EXTRAFIELD_DATA_AES = new Uint8Array([0x07, 0x00, 0x02, 0x00, 0x41, 0x45, 0x03, 0x00, 0x00]);
  3952. const INFOZIP_EXTRA_FIELD_TYPE = "infozip";
  3953. const UNIX_EXTRA_FIELD_TYPE = "unix";
  3954. let workers = 0;
  3955. const pendingEntries = [];
  3956. class ZipWriter {
  3957. constructor(writer, options = {}) {
  3958. writer = new GenericWriter(writer);
  3959. const addSplitZipSignature =
  3960. writer.availableSize !== UNDEFINED_VALUE && writer.availableSize > 0 && writer.availableSize !== INFINITY_VALUE &&
  3961. writer.maxSize !== UNDEFINED_VALUE && writer.maxSize > 0 && writer.maxSize !== INFINITY_VALUE;
  3962. Object.assign(this, {
  3963. writer,
  3964. addSplitZipSignature,
  3965. options,
  3966. config: getConfiguration(),
  3967. files: new Map(),
  3968. filenames: new Set(),
  3969. offset: options[OPTION_OFFSET] === UNDEFINED_VALUE ? writer.size || writer.writable.size || 0 : options[OPTION_OFFSET],
  3970. pendingEntriesSize: 0,
  3971. pendingAddFileCalls: new Set(),
  3972. bufferedWrites: 0
  3973. });
  3974. }
  3975. async prependZip(reader) {
  3976. if (this.filenames.size) {
  3977. throw new Error(ERR_ZIP_NOT_EMPTY);
  3978. }
  3979. reader = new GenericReader(reader);
  3980. const zipReader = new ZipReader(reader.readable);
  3981. const entries = await zipReader.getEntries();
  3982. await zipReader.close();
  3983. await reader.readable.pipeTo(this.writer.writable, { preventClose: true, preventAbort: true });
  3984. this.writer.size = this.offset = reader.size;
  3985. this.filenames = new Set(entries.map(entry => entry.filename));
  3986. this.files = new Map(entries.map(entry => {
  3987. const {
  3988. version,
  3989. compressionMethod,
  3990. lastModDate,
  3991. lastAccessDate,
  3992. creationDate,
  3993. rawFilename,
  3994. bitFlag,
  3995. encrypted,
  3996. uncompressedSize,
  3997. compressedSize,
  3998. diskOffset,
  3999. diskNumber,
  4000. zip64
  4001. } = entry;
  4002. let {
  4003. rawExtraFieldZip64,
  4004. rawExtraFieldAES,
  4005. rawExtraFieldExtendedTimestamp,
  4006. rawExtraFieldNTFS,
  4007. rawExtraFieldUnix,
  4008. rawExtraField,
  4009. } = entry;
  4010. const { level, languageEncodingFlag, dataDescriptor } = bitFlag;
  4011. rawExtraFieldZip64 = rawExtraFieldZip64 || new Uint8Array();
  4012. rawExtraFieldAES = rawExtraFieldAES || new Uint8Array();
  4013. rawExtraFieldExtendedTimestamp = rawExtraFieldExtendedTimestamp || new Uint8Array();
  4014. rawExtraFieldNTFS = rawExtraFieldNTFS || new Uint8Array();
  4015. rawExtraFieldUnix = entry.rawExtraFieldUnix || new Uint8Array();
  4016. rawExtraField = rawExtraField || new Uint8Array();
  4017. const extraFieldLength = getLength(rawExtraFieldZip64, rawExtraFieldAES, rawExtraFieldExtendedTimestamp, rawExtraFieldNTFS, rawExtraFieldUnix, rawExtraField);
  4018. const zip64UncompressedSize = zip64 && uncompressedSize > MAX_32_BITS;
  4019. const zip64CompressedSize = zip64 && compressedSize > MAX_32_BITS;
  4020. const {
  4021. headerArray,
  4022. headerView
  4023. } = getHeaderArrayData({
  4024. version,
  4025. bitFlag: getBitFlag(level, languageEncodingFlag, dataDescriptor, encrypted, compressionMethod),
  4026. compressionMethod,
  4027. uncompressedSize,
  4028. compressedSize,
  4029. lastModDate,
  4030. rawFilename,
  4031. zip64CompressedSize,
  4032. zip64UncompressedSize,
  4033. extraFieldLength
  4034. });
  4035. Object.assign(entry, {
  4036. zip64UncompressedSize,
  4037. zip64CompressedSize,
  4038. zip64Offset: zip64 && this.offset - diskOffset > MAX_32_BITS,
  4039. zip64DiskNumberStart: zip64 && diskNumber > MAX_16_BITS,
  4040. rawExtraFieldZip64,
  4041. rawExtraFieldAES,
  4042. rawExtraFieldExtendedTimestamp,
  4043. rawExtraFieldNTFS,
  4044. rawExtraFieldUnix,
  4045. rawExtraField,
  4046. extendedTimestamp: rawExtraFieldExtendedTimestamp.length > 0 || rawExtraFieldNTFS.length > 0,
  4047. extraFieldExtendedTimestampFlag: 0x1 + (lastAccessDate ? 0x2 : 0) + (creationDate ? 0x4 : 0),
  4048. headerArray,
  4049. headerView
  4050. });
  4051. return [entry.filename, entry];
  4052. }));
  4053. }
  4054. async add(name = "", reader, options = {}) {
  4055. const zipWriter = this;
  4056. const {
  4057. pendingAddFileCalls,
  4058. config
  4059. } = zipWriter;
  4060. if (workers < config.maxWorkers) {
  4061. workers++;
  4062. } else {
  4063. await new Promise(resolve => pendingEntries.push(resolve));
  4064. }
  4065. let promiseAddFile;
  4066. try {
  4067. name = name.trim();
  4068. if (zipWriter.filenames.has(name)) {
  4069. throw new Error(ERR_DUPLICATED_NAME);
  4070. }
  4071. zipWriter.filenames.add(name);
  4072. promiseAddFile = addFile(zipWriter, name, reader, options);
  4073. pendingAddFileCalls.add(promiseAddFile);
  4074. return await promiseAddFile;
  4075. } catch (error) {
  4076. zipWriter.filenames.delete(name);
  4077. throw error;
  4078. } finally {
  4079. pendingAddFileCalls.delete(promiseAddFile);
  4080. const pendingEntry = pendingEntries.shift();
  4081. if (pendingEntry) {
  4082. pendingEntry();
  4083. } else {
  4084. workers--;
  4085. }
  4086. }
  4087. }
  4088. remove(entry) {
  4089. const { filenames, files } = this;
  4090. if (typeof entry == "string") {
  4091. entry = files.get(entry);
  4092. }
  4093. if (entry && entry.filename !== UNDEFINED_VALUE) {
  4094. const { filename } = entry;
  4095. if (filenames.has(filename) && files.has(filename)) {
  4096. filenames.delete(filename);
  4097. files.delete(filename);
  4098. return true;
  4099. }
  4100. }
  4101. return false;
  4102. }
  4103. async close(comment = new Uint8Array(), options = {}) {
  4104. const zipWriter = this;
  4105. const { pendingAddFileCalls, writer } = this;
  4106. const { writable } = writer;
  4107. while (pendingAddFileCalls.size) {
  4108. await Promise.allSettled(Array.from(pendingAddFileCalls));
  4109. }
  4110. await closeFile(zipWriter, comment, options);
  4111. const preventClose = getOptionValue(zipWriter, options, OPTION_PREVENT_CLOSE);
  4112. if (!preventClose) {
  4113. await writable.getWriter().close();
  4114. }
  4115. return writer.getData ? writer.getData() : writable;
  4116. }
  4117. }
  4118. class ZipWriterStream {
  4119. constructor(options = {}) {
  4120. const { readable, writable } = new TransformStream();
  4121. this.readable = readable;
  4122. this.zipWriter = new ZipWriter(writable, options);
  4123. }
  4124. transform(path) {
  4125. const { readable, writable } = new TransformStream({
  4126. flush: () => { this.zipWriter.close(); }
  4127. });
  4128. this.zipWriter.add(path, readable);
  4129. return { readable: this.readable, writable };
  4130. }
  4131. writable(path) {
  4132. const { readable, writable } = new TransformStream();
  4133. this.zipWriter.add(path, readable);
  4134. return writable;
  4135. }
  4136. close(comment = UNDEFINED_VALUE, options = {}) {
  4137. return this.zipWriter.close(comment, options);
  4138. }
  4139. }
  4140. async function addFile(zipWriter, name, reader, options) {
  4141. name = name.trim();
  4142. let msDosCompatible = getOptionValue(zipWriter, options, PROPERTY_NAME_MS_DOS_COMPATIBLE);
  4143. let versionMadeBy = getOptionValue(zipWriter, options, PROPERTY_NAME_VERSION_MADE_BY, msDosCompatible ? 20 : 768);
  4144. const executable = getOptionValue(zipWriter, options, PROPERTY_NAME_EXECUTABLE);
  4145. const uid = getOptionValue(zipWriter, options, PROPERTY_NAME_UID);
  4146. const gid = getOptionValue(zipWriter, options, PROPERTY_NAME_GID);
  4147. let unixMode = getOptionValue(zipWriter, options, PROPERTY_NAME_UNIX_MODE);
  4148. const unixExtraFieldType = getOptionValue(zipWriter, options, OPTION_UNIX_EXTRA_FIELD_TYPE);
  4149. let setuid = getOptionValue(zipWriter, options, PROPERTY_NAME_SETUID);
  4150. let setgid = getOptionValue(zipWriter, options, PROPERTY_NAME_SETGID);
  4151. let sticky = getOptionValue(zipWriter, options, PROPERTY_NAME_STICKY);
  4152. if (uid !== UNDEFINED_VALUE && (uid < 0 || uid > MAX_32_BITS)) {
  4153. throw new Error(ERR_INVALID_UID);
  4154. }
  4155. if (gid !== UNDEFINED_VALUE && (gid < 0 || gid > MAX_32_BITS)) {
  4156. throw new Error(ERR_INVALID_GID);
  4157. }
  4158. if (unixMode !== UNDEFINED_VALUE && (unixMode < 0 || unixMode > MAX_16_BITS)) {
  4159. throw new Error(ERR_INVALID_UNIX_MODE);
  4160. }
  4161. if (unixExtraFieldType !== UNDEFINED_VALUE && unixExtraFieldType !== INFOZIP_EXTRA_FIELD_TYPE && unixExtraFieldType !== UNIX_EXTRA_FIELD_TYPE) {
  4162. throw new Error(ERR_INVALID_UNIX_EXTRA_FIELD_TYPE);
  4163. }
  4164. let msdosAttributesRaw = getOptionValue(zipWriter, options, PROPERTY_NAME_MSDOS_ATTRIBUTES_RAW);
  4165. let msdosAttributes = getOptionValue(zipWriter, options, PROPERTY_NAME_MSDOS_ATTRIBUTES);
  4166. const hasUnixMetadata = uid !== UNDEFINED_VALUE || gid !== UNDEFINED_VALUE || unixMode !== UNDEFINED_VALUE || unixExtraFieldType;
  4167. const hasMsDosProvided = msdosAttributesRaw !== UNDEFINED_VALUE || msdosAttributes !== UNDEFINED_VALUE;
  4168. if (hasUnixMetadata) {
  4169. msDosCompatible = false;
  4170. versionMadeBy = (versionMadeBy & MAX_16_BITS) | (3 << 8);
  4171. } else if (hasMsDosProvided) {
  4172. msDosCompatible = true;
  4173. versionMadeBy = (versionMadeBy & MAX_8_BITS);
  4174. }
  4175. if (msdosAttributesRaw !== UNDEFINED_VALUE && (msdosAttributesRaw < 0 || msdosAttributesRaw > MAX_8_BITS)) {
  4176. throw new Error(ERR_INVALID_MSDOS_ATTRIBUTES);
  4177. }
  4178. if (msdosAttributes && typeof msdosAttributes !== OBJECT_TYPE) {
  4179. throw new Error(ERR_INVALID_MSDOS_DATA);
  4180. }
  4181. if (versionMadeBy > MAX_16_BITS) {
  4182. throw new Error(ERR_INVALID_VERSION);
  4183. }
  4184. let externalFileAttributes = getOptionValue(zipWriter, options, PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTES, 0);
  4185. if (!options[PROPERTY_NAME_DIRECTORY] && name.endsWith(DIRECTORY_SIGNATURE)) {
  4186. options[PROPERTY_NAME_DIRECTORY] = true;
  4187. }
  4188. const directory = getOptionValue(zipWriter, options, PROPERTY_NAME_DIRECTORY);
  4189. if (directory) {
  4190. if (!name.endsWith(DIRECTORY_SIGNATURE)) {
  4191. name += DIRECTORY_SIGNATURE;
  4192. }
  4193. if (externalFileAttributes === 0) {
  4194. externalFileAttributes = FILE_ATTR_MSDOS_DIR_MASK;
  4195. if (!msDosCompatible) {
  4196. externalFileAttributes |= (FILE_ATTR_UNIX_TYPE_DIR | FILE_ATTR_UNIX_EXECUTABLE_MASK | FILE_ATTR_UNIX_DEFAULT_MASK) << 16;
  4197. }
  4198. }
  4199. } else if (!msDosCompatible && externalFileAttributes === 0) {
  4200. if (executable) {
  4201. externalFileAttributes = (FILE_ATTR_UNIX_EXECUTABLE_MASK | FILE_ATTR_UNIX_DEFAULT_MASK) << 16;
  4202. } else {
  4203. externalFileAttributes = FILE_ATTR_UNIX_DEFAULT_MASK << 16;
  4204. }
  4205. }
  4206. let unixExternalUpper;
  4207. if (!msDosCompatible) {
  4208. unixExternalUpper = (externalFileAttributes >> 16) & MAX_16_BITS;
  4209. unixMode = unixMode === UNDEFINED_VALUE ? unixExternalUpper : (unixMode & MAX_16_BITS);
  4210. if (setuid) {
  4211. unixMode |= FILE_ATTR_UNIX_SETUID_MASK;
  4212. } else {
  4213. setuid = Boolean(unixMode & FILE_ATTR_UNIX_SETUID_MASK);
  4214. }
  4215. if (setgid) {
  4216. unixMode |= FILE_ATTR_UNIX_SETGID_MASK;
  4217. } else {
  4218. setgid = Boolean(unixMode & FILE_ATTR_UNIX_SETGID_MASK);
  4219. }
  4220. if (sticky) {
  4221. unixMode |= FILE_ATTR_UNIX_STICKY_MASK;
  4222. } else {
  4223. sticky = Boolean(unixMode & FILE_ATTR_UNIX_STICKY_MASK);
  4224. }
  4225. if (directory) {
  4226. unixMode |= FILE_ATTR_UNIX_TYPE_DIR;
  4227. }
  4228. externalFileAttributes = ((unixMode & MAX_16_BITS) << 16) | (externalFileAttributes & MAX_8_BITS);
  4229. }
  4230. ({ msdosAttributesRaw, msdosAttributes } = normalizeMsdosAttributes(msdosAttributesRaw, msdosAttributes));
  4231. if (hasMsDosProvided) {
  4232. externalFileAttributes = (externalFileAttributes & MAX_32_BITS) | (msdosAttributesRaw & MAX_8_BITS);
  4233. }
  4234. const encode = getOptionValue(zipWriter, options, OPTION_ENCODE_TEXT, encodeText);
  4235. let rawFilename = encode(name);
  4236. if (rawFilename === UNDEFINED_VALUE) {
  4237. rawFilename = encodeText(name);
  4238. }
  4239. if (getLength(rawFilename) > MAX_16_BITS) {
  4240. throw new Error(ERR_INVALID_ENTRY_NAME);
  4241. }
  4242. const comment = options[PROPERTY_NAME_COMMENT] || "";
  4243. let rawComment = encode(comment);
  4244. if (rawComment === UNDEFINED_VALUE) {
  4245. rawComment = encodeText(comment);
  4246. }
  4247. if (getLength(rawComment) > MAX_16_BITS) {
  4248. throw new Error(ERR_INVALID_ENTRY_COMMENT);
  4249. }
  4250. const version = getOptionValue(zipWriter, options, PROPERTY_NAME_VERSION, VERSION_DEFLATE);
  4251. if (version > MAX_16_BITS) {
  4252. throw new Error(ERR_INVALID_VERSION);
  4253. }
  4254. const lastModDate = getOptionValue(zipWriter, options, PROPERTY_NAME_LAST_MODIFICATION_DATE, new Date());
  4255. const lastAccessDate = getOptionValue(zipWriter, options, PROPERTY_NAME_LAST_ACCESS_DATE);
  4256. const creationDate = getOptionValue(zipWriter, options, PROPERTY_NAME_CREATION_DATE);
  4257. const internalFileAttributes = getOptionValue(zipWriter, options, PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTES, 0);
  4258. const passThrough = getOptionValue(zipWriter, options, OPTION_PASS_THROUGH);
  4259. let password, rawPassword;
  4260. if (!passThrough) {
  4261. password = getOptionValue(zipWriter, options, OPTION_PASSWORD);
  4262. rawPassword = getOptionValue(zipWriter, options, OPTION_RAW_PASSWORD);
  4263. }
  4264. const encryptionStrength = getOptionValue(zipWriter, options, OPTION_ENCRYPTION_STRENGTH, 3);
  4265. const zipCrypto = getOptionValue(zipWriter, options, PROPERTY_NAME_ZIPCRYPTO);
  4266. const extendedTimestamp = getOptionValue(zipWriter, options, OPTION_EXTENDED_TIMESTAMP, true);
  4267. const keepOrder = getOptionValue(zipWriter, options, OPTION_KEEP_ORDER, true);
  4268. const useWebWorkers = getOptionValue(zipWriter, options, OPTION_USE_WEB_WORKERS);
  4269. const transferStreams = getOptionValue(zipWriter, options, OPTION_TRANSFER_STREAMS, true);
  4270. const bufferedWrite = getOptionValue(zipWriter, options, OPTION_BUFFERED_WRITE);
  4271. const createTempStream = getOptionValue(zipWriter, options, OPTION_CREATE_TEMP_STREAM);
  4272. const dataDescriptorSignature = getOptionValue(zipWriter, options, OPTION_DATA_DESCRIPTOR_SIGNATURE, false);
  4273. const signal = getOptionValue(zipWriter, options, OPTION_SIGNAL);
  4274. const useUnicodeFileNames = getOptionValue(zipWriter, options, OPTION_USE_UNICODE_FILE_NAMES, true);
  4275. const compressionMethod = getOptionValue(zipWriter, options, PROPERTY_NAME_COMPRESSION_METHOD);
  4276. let level = getOptionValue(zipWriter, options, OPTION_LEVEL);
  4277. let useCompressionStream = getOptionValue(zipWriter, options, OPTION_USE_COMPRESSION_STREAM);
  4278. let dataDescriptor = getOptionValue(zipWriter, options, OPTION_DATA_DESCRIPTOR);
  4279. if (bufferedWrite && dataDescriptor === UNDEFINED_VALUE) {
  4280. dataDescriptor = false;
  4281. }
  4282. if (dataDescriptor === UNDEFINED_VALUE || zipCrypto) {
  4283. dataDescriptor = true;
  4284. }
  4285. if (level !== UNDEFINED_VALUE && level != 6) {
  4286. useCompressionStream = false;
  4287. }
  4288. if (!useCompressionStream && (zipWriter.config.CompressionStream === UNDEFINED_VALUE && zipWriter.config.CompressionStreamZlib === UNDEFINED_VALUE)) {
  4289. level = 0;
  4290. }
  4291. let zip64 = getOptionValue(zipWriter, options, PROPERTY_NAME_ZIP64);
  4292. if (!zipCrypto && (password !== UNDEFINED_VALUE || rawPassword !== UNDEFINED_VALUE) && !(encryptionStrength >= 1 && encryptionStrength <= 3)) {
  4293. throw new Error(ERR_INVALID_ENCRYPTION_STRENGTH);
  4294. }
  4295. let rawExtraField = new Uint8Array();
  4296. const extraField = options[PROPERTY_NAME_EXTRA_FIELD];
  4297. if (extraField) {
  4298. let extraFieldSize = 0;
  4299. let offset = 0;
  4300. extraField.forEach(data => extraFieldSize += 4 + getLength(data));
  4301. rawExtraField = new Uint8Array(extraFieldSize);
  4302. extraField.forEach((data, type) => {
  4303. if (type > MAX_16_BITS) {
  4304. throw new Error(ERR_INVALID_EXTRAFIELD_TYPE);
  4305. }
  4306. if (getLength(data) > MAX_16_BITS) {
  4307. throw new Error(ERR_INVALID_EXTRAFIELD_DATA);
  4308. }
  4309. arraySet(rawExtraField, new Uint16Array([type]), offset);
  4310. arraySet(rawExtraField, new Uint16Array([getLength(data)]), offset + 2);
  4311. arraySet(rawExtraField, data, offset + 4);
  4312. offset += 4 + getLength(data);
  4313. });
  4314. }
  4315. let maximumCompressedSize = 0;
  4316. let maximumEntrySize = 0;
  4317. let uncompressedSize = 0;
  4318. if (passThrough) {
  4319. uncompressedSize = options[PROPERTY_NAME_UNCOMPRESSED_SIZE];
  4320. if (uncompressedSize === UNDEFINED_VALUE) {
  4321. throw new Error(ERR_UNDEFINED_UNCOMPRESSED_SIZE);
  4322. }
  4323. }
  4324. const zip64Enabled = zip64 === true;
  4325. if (reader) {
  4326. reader = new GenericReader(reader);
  4327. await initStream(reader);
  4328. if (!passThrough) {
  4329. if (reader.size === UNDEFINED_VALUE) {
  4330. dataDescriptor = true;
  4331. if (zip64 || zip64 === UNDEFINED_VALUE) {
  4332. zip64 = true;
  4333. uncompressedSize = maximumCompressedSize = MAX_32_BITS + 1;
  4334. }
  4335. } else {
  4336. options.uncompressedSize = uncompressedSize = reader.size;
  4337. maximumCompressedSize = getMaximumCompressedSize(uncompressedSize);
  4338. }
  4339. } else {
  4340. options.uncompressedSize = uncompressedSize;
  4341. maximumCompressedSize = getMaximumCompressedSize(uncompressedSize);
  4342. }
  4343. }
  4344. const { diskOffset, diskNumber } = zipWriter.writer;
  4345. const zip64UncompressedSize = zip64Enabled || uncompressedSize > MAX_32_BITS;
  4346. const zip64CompressedSize = zip64Enabled || maximumCompressedSize > MAX_32_BITS;
  4347. if (zip64UncompressedSize || zip64CompressedSize) {
  4348. if (zip64 === false) {
  4349. throw new Error(ERR_UNSUPPORTED_FORMAT);
  4350. } else {
  4351. zip64 = true;
  4352. }
  4353. }
  4354. zip64 = zip64 || false;
  4355. const encrypted = getOptionValue(zipWriter, options, PROPERTY_NAME_ENCRYPTED);
  4356. options = Object.assign({}, options, {
  4357. rawFilename,
  4358. rawComment,
  4359. version,
  4360. versionMadeBy,
  4361. lastModDate,
  4362. lastAccessDate,
  4363. creationDate,
  4364. rawExtraField,
  4365. zip64,
  4366. zip64UncompressedSize,
  4367. zip64CompressedSize,
  4368. password,
  4369. rawPassword,
  4370. level,
  4371. useWebWorkers,
  4372. transferStreams,
  4373. encryptionStrength,
  4374. extendedTimestamp,
  4375. zipCrypto,
  4376. bufferedWrite,
  4377. createTempStream,
  4378. keepOrder,
  4379. useUnicodeFileNames,
  4380. dataDescriptor,
  4381. dataDescriptorSignature,
  4382. signal,
  4383. msDosCompatible,
  4384. internalFileAttribute: internalFileAttributes,
  4385. internalFileAttributes,
  4386. externalFileAttribute: externalFileAttributes,
  4387. externalFileAttributes,
  4388. useCompressionStream,
  4389. passThrough,
  4390. encrypted: Boolean((password && getLength(password)) || (rawPassword && getLength(rawPassword))) || (passThrough && encrypted),
  4391. signature: options[PROPERTY_NAME_SIGNATURE],
  4392. compressionMethod,
  4393. uncompressedSize,
  4394. offset: zipWriter.offset - diskOffset,
  4395. diskNumberStart: diskNumber,
  4396. uid,
  4397. gid,
  4398. setuid,
  4399. setgid,
  4400. sticky,
  4401. unixMode,
  4402. msdosAttributesRaw,
  4403. msdosAttributes,
  4404. unixExternalUpper
  4405. });
  4406. const headerInfo = getHeaderInfo(options);
  4407. const dataDescriptorInfo = getDataDescriptorInfo(options);
  4408. const metadataSize = getLength(headerInfo.localHeaderArray, dataDescriptorInfo.dataDescriptorArray);
  4409. maximumEntrySize = metadataSize + maximumCompressedSize;
  4410. if (zipWriter.options[OPTION_USDZ]) {
  4411. maximumEntrySize += maximumEntrySize + 64;
  4412. }
  4413. zipWriter.pendingEntriesSize += maximumEntrySize;
  4414. let fileEntry;
  4415. try {
  4416. fileEntry = await getFileEntry(zipWriter, name, reader, { headerInfo, dataDescriptorInfo, metadataSize }, options);
  4417. } finally {
  4418. zipWriter.pendingEntriesSize -= maximumEntrySize;
  4419. }
  4420. Object.assign(fileEntry, { name, comment, extraField });
  4421. return new Entry(fileEntry);
  4422. }
  4423. async function getFileEntry(zipWriter, name, reader, entryInfo, options) {
  4424. const {
  4425. files,
  4426. writer
  4427. } = zipWriter;
  4428. const {
  4429. keepOrder,
  4430. dataDescriptor,
  4431. signal
  4432. } = options;
  4433. const {
  4434. headerInfo
  4435. } = entryInfo;
  4436. const usdz = zipWriter.options[OPTION_USDZ];
  4437. const previousFileEntry = Array.from(files.values()).pop();
  4438. let fileEntry = {};
  4439. let bufferedWrite;
  4440. let releaseLockWriter;
  4441. let releaseLockCurrentFileEntry;
  4442. let writingBufferedEntryData;
  4443. let writingEntryData;
  4444. let fileWriter;
  4445. files.set(name, fileEntry);
  4446. try {
  4447. let lockPreviousFileEntry;
  4448. if (keepOrder) {
  4449. lockPreviousFileEntry = previousFileEntry && previousFileEntry.lock;
  4450. requestLockCurrentFileEntry();
  4451. }
  4452. if ((options.bufferedWrite || !keepOrder || zipWriter.writerLocked || zipWriter.bufferedWrites || !dataDescriptor) && !usdz) {
  4453. if (options.createTempStream) {
  4454. fileWriter = await options.createTempStream();
  4455. } else {
  4456. fileWriter = new TransformStream(UNDEFINED_VALUE, UNDEFINED_VALUE, { highWaterMark: INFINITY_VALUE });
  4457. }
  4458. fileWriter.size = 0;
  4459. bufferedWrite = true;
  4460. zipWriter.bufferedWrites++;
  4461. await initStream(writer);
  4462. } else {
  4463. fileWriter = writer;
  4464. await requestLockWriter();
  4465. }
  4466. await initStream(fileWriter);
  4467. const { writable, diskOffset } = writer;
  4468. if (zipWriter.addSplitZipSignature) {
  4469. delete zipWriter.addSplitZipSignature;
  4470. const signatureArray = new Uint8Array(4);
  4471. const signatureArrayView = getDataView(signatureArray);
  4472. setUint32(signatureArrayView, 0, SPLIT_ZIP_FILE_SIGNATURE);
  4473. await writeData(writer, signatureArray);
  4474. zipWriter.offset += 4;
  4475. }
  4476. if (usdz) {
  4477. appendExtraFieldUSDZ(entryInfo, zipWriter.offset - diskOffset);
  4478. }
  4479. const {
  4480. localHeaderView,
  4481. localHeaderArray
  4482. } = headerInfo;
  4483. if (!bufferedWrite) {
  4484. await lockPreviousFileEntry;
  4485. await skipDiskIfNeeded(writable);
  4486. }
  4487. const { diskNumber } = writer;
  4488. fileEntry.diskNumberStart = diskNumber;
  4489. if (!bufferedWrite) {
  4490. writingEntryData = true;
  4491. await writeData(fileWriter, localHeaderArray);
  4492. }
  4493. fileEntry = await createFileEntry(reader, fileWriter, fileEntry, entryInfo, zipWriter.config, options);
  4494. if (!bufferedWrite) {
  4495. writingEntryData = false;
  4496. }
  4497. files.set(name, fileEntry);
  4498. fileEntry.filename = name;
  4499. if (bufferedWrite) {
  4500. await Promise.all([fileWriter.writable.getWriter().close(), lockPreviousFileEntry]);
  4501. await requestLockWriter();
  4502. writingBufferedEntryData = true;
  4503. fileEntry.diskNumberStart = writer.diskNumber;
  4504. fileEntry.offset = zipWriter.offset - writer.diskOffset;
  4505. updateLocalHeader(fileEntry, localHeaderView, options);
  4506. await skipDiskIfNeeded(writable);
  4507. await writeData(writer, localHeaderArray);
  4508. await fileWriter.readable.pipeTo(writable, { preventClose: true, preventAbort: true, signal });
  4509. writer.size += fileWriter.size;
  4510. writingBufferedEntryData = false;
  4511. } else {
  4512. fileEntry.offset = zipWriter.offset - diskOffset;
  4513. }
  4514. zipWriter.offset += fileEntry.size;
  4515. return fileEntry;
  4516. } catch (error) {
  4517. if (writingBufferedEntryData || writingEntryData) {
  4518. zipWriter.hasCorruptedEntries = true;
  4519. if (error) {
  4520. try {
  4521. error.corruptedEntry = true;
  4522. } catch {
  4523. // ignored
  4524. }
  4525. }
  4526. if (bufferedWrite) {
  4527. zipWriter.offset += fileWriter.size;
  4528. } else {
  4529. zipWriter.offset = fileWriter.size;
  4530. }
  4531. }
  4532. files.delete(name);
  4533. throw error;
  4534. } finally {
  4535. if (bufferedWrite) {
  4536. zipWriter.bufferedWrites--;
  4537. }
  4538. if (releaseLockCurrentFileEntry) {
  4539. releaseLockCurrentFileEntry();
  4540. }
  4541. if (releaseLockWriter) {
  4542. releaseLockWriter();
  4543. }
  4544. }
  4545. function requestLockCurrentFileEntry() {
  4546. fileEntry.lock = new Promise(resolve => releaseLockCurrentFileEntry = resolve);
  4547. }
  4548. async function requestLockWriter() {
  4549. zipWriter.writerLocked = true;
  4550. const { lockWriter } = zipWriter;
  4551. zipWriter.lockWriter = new Promise(resolve => releaseLockWriter = () => {
  4552. zipWriter.writerLocked = false;
  4553. resolve();
  4554. });
  4555. await lockWriter;
  4556. }
  4557. async function skipDiskIfNeeded(writable) {
  4558. if (getLength(headerInfo.localHeaderArray) > writer.availableSize) {
  4559. writer.availableSize = 0;
  4560. await writeData(writable, new Uint8Array());
  4561. }
  4562. }
  4563. }
  4564. async function createFileEntry(reader, writer, { diskNumberStart, lock }, entryInfo, config, options) {
  4565. const {
  4566. headerInfo,
  4567. dataDescriptorInfo,
  4568. metadataSize
  4569. } = entryInfo;
  4570. const {
  4571. headerArray,
  4572. headerView,
  4573. lastModDate,
  4574. rawLastModDate,
  4575. encrypted,
  4576. compressed,
  4577. version,
  4578. compressionMethod,
  4579. rawExtraFieldZip64,
  4580. localExtraFieldZip64Length,
  4581. rawExtraFieldExtendedTimestamp,
  4582. extraFieldExtendedTimestampFlag,
  4583. rawExtraFieldNTFS,
  4584. rawExtraFieldUnix,
  4585. rawExtraFieldAES,
  4586. } = headerInfo;
  4587. const { dataDescriptorArray } = dataDescriptorInfo;
  4588. const {
  4589. rawFilename,
  4590. lastAccessDate,
  4591. creationDate,
  4592. password,
  4593. rawPassword,
  4594. level,
  4595. zip64,
  4596. zip64UncompressedSize,
  4597. zip64CompressedSize,
  4598. zipCrypto,
  4599. dataDescriptor,
  4600. directory,
  4601. executable,
  4602. versionMadeBy,
  4603. rawComment,
  4604. rawExtraField,
  4605. useWebWorkers,
  4606. transferStreams,
  4607. onstart,
  4608. onprogress,
  4609. onend,
  4610. signal,
  4611. encryptionStrength,
  4612. extendedTimestamp,
  4613. msDosCompatible,
  4614. internalFileAttributes,
  4615. externalFileAttributes,
  4616. uid,
  4617. gid,
  4618. unixMode,
  4619. setuid,
  4620. setgid,
  4621. sticky,
  4622. unixExternalUpper,
  4623. msdosAttributesRaw,
  4624. msdosAttributes,
  4625. useCompressionStream,
  4626. passThrough
  4627. } = options;
  4628. const fileEntry = {
  4629. lock,
  4630. versionMadeBy,
  4631. zip64,
  4632. directory: Boolean(directory),
  4633. executable: Boolean(executable),
  4634. filenameUTF8: true,
  4635. rawFilename,
  4636. commentUTF8: true,
  4637. rawComment,
  4638. rawExtraFieldZip64,
  4639. localExtraFieldZip64Length,
  4640. rawExtraFieldExtendedTimestamp,
  4641. rawExtraFieldNTFS,
  4642. rawExtraFieldUnix,
  4643. rawExtraFieldAES,
  4644. rawExtraField,
  4645. extendedTimestamp,
  4646. msDosCompatible,
  4647. internalFileAttributes,
  4648. externalFileAttributes,
  4649. diskNumberStart,
  4650. uid,
  4651. gid,
  4652. unixMode,
  4653. setuid,
  4654. setgid,
  4655. sticky,
  4656. unixExternalUpper,
  4657. msdosAttributesRaw,
  4658. msdosAttributes
  4659. };
  4660. let {
  4661. signature,
  4662. uncompressedSize
  4663. } = options;
  4664. let compressedSize = 0;
  4665. if (!passThrough) {
  4666. uncompressedSize = 0;
  4667. }
  4668. const { writable } = writer;
  4669. if (reader) {
  4670. reader.chunkSize = getChunkSize(config);
  4671. const readable = reader.readable;
  4672. const size = reader.size;
  4673. const workerOptions = {
  4674. options: {
  4675. codecType: CODEC_DEFLATE,
  4676. level,
  4677. rawPassword,
  4678. password,
  4679. encryptionStrength,
  4680. zipCrypto: encrypted && zipCrypto,
  4681. passwordVerification: encrypted && zipCrypto && (rawLastModDate >> 8) & MAX_8_BITS,
  4682. signed: !passThrough,
  4683. compressed: compressed && !passThrough,
  4684. encrypted: encrypted && !passThrough,
  4685. useWebWorkers,
  4686. useCompressionStream,
  4687. transferStreams
  4688. },
  4689. config,
  4690. streamOptions: { signal, size, onstart, onprogress, onend }
  4691. };
  4692. try {
  4693. const result = await runWorker({ readable, writable }, workerOptions);
  4694. compressedSize = result.outputSize;
  4695. writer.size += compressedSize;
  4696. if (!passThrough) {
  4697. uncompressedSize = result.inputSize;
  4698. signature = result.signature;
  4699. }
  4700. } catch (error) {
  4701. if (error.outputSize !== UNDEFINED_VALUE) {
  4702. writer.size += error.outputSize;
  4703. }
  4704. throw error;
  4705. }
  4706. }
  4707. setEntryInfo({
  4708. signature,
  4709. compressedSize,
  4710. uncompressedSize,
  4711. headerInfo,
  4712. dataDescriptorInfo
  4713. }, options);
  4714. if (dataDescriptor) {
  4715. await writeData(writer, dataDescriptorArray);
  4716. }
  4717. Object.assign(fileEntry, {
  4718. uncompressedSize,
  4719. compressedSize,
  4720. lastModDate,
  4721. rawLastModDate,
  4722. creationDate,
  4723. lastAccessDate,
  4724. encrypted,
  4725. zipCrypto,
  4726. size: metadataSize + compressedSize,
  4727. compressionMethod,
  4728. version,
  4729. headerArray,
  4730. headerView,
  4731. signature,
  4732. extraFieldExtendedTimestampFlag,
  4733. zip64UncompressedSize,
  4734. zip64CompressedSize
  4735. });
  4736. return fileEntry;
  4737. }
  4738. function getHeaderInfo(options) {
  4739. const {
  4740. rawFilename,
  4741. lastModDate,
  4742. lastAccessDate,
  4743. creationDate,
  4744. level,
  4745. zip64,
  4746. zipCrypto,
  4747. useUnicodeFileNames,
  4748. dataDescriptor,
  4749. directory,
  4750. rawExtraField,
  4751. encryptionStrength,
  4752. extendedTimestamp,
  4753. passThrough,
  4754. encrypted,
  4755. zip64UncompressedSize,
  4756. zip64CompressedSize,
  4757. uncompressedSize
  4758. } = options;
  4759. let { version, compressionMethod } = options;
  4760. const compressed = !directory && (level > 0 || (level === UNDEFINED_VALUE && compressionMethod !== 0));
  4761. let rawLocalExtraFieldZip64;
  4762. const uncompressedFile = passThrough || !compressed;
  4763. const zip64ExtraFieldComplete = zip64 && (options.bufferedWrite || ((!zip64UncompressedSize && !zip64CompressedSize) || uncompressedFile));
  4764. if (zip64) {
  4765. let rawLocalExtraFieldZip64Length = 4;
  4766. if (zip64UncompressedSize) {
  4767. rawLocalExtraFieldZip64Length += 8;
  4768. }
  4769. if (zip64CompressedSize) {
  4770. rawLocalExtraFieldZip64Length += 8;
  4771. }
  4772. rawLocalExtraFieldZip64 = new Uint8Array(rawLocalExtraFieldZip64Length);
  4773. const rawLocalExtraFieldZip64View = getDataView(rawLocalExtraFieldZip64);
  4774. setUint16(rawLocalExtraFieldZip64View, 0, EXTRAFIELD_TYPE_ZIP64);
  4775. setUint16(rawLocalExtraFieldZip64View, 2, getLength(rawLocalExtraFieldZip64) - 4);
  4776. if (zip64ExtraFieldComplete) {
  4777. const rawLocalExtraFieldZip64View = getDataView(rawLocalExtraFieldZip64);
  4778. let rawLocalExtraFieldZip64Offset = 4;
  4779. if (zip64UncompressedSize) {
  4780. setBigUint64(rawLocalExtraFieldZip64View, rawLocalExtraFieldZip64Offset, BigInt(uncompressedSize));
  4781. rawLocalExtraFieldZip64Offset += 8;
  4782. }
  4783. if (zip64CompressedSize && uncompressedFile) {
  4784. setBigUint64(rawLocalExtraFieldZip64View, rawLocalExtraFieldZip64Offset, BigInt(uncompressedSize));
  4785. rawLocalExtraFieldZip64Offset += 8;
  4786. }
  4787. if (rawLocalExtraFieldZip64Offset == 4) {
  4788. rawLocalExtraFieldZip64 = new Uint8Array();
  4789. }
  4790. }
  4791. } else {
  4792. rawLocalExtraFieldZip64 = new Uint8Array();
  4793. }
  4794. let rawExtraFieldAES;
  4795. if (encrypted && !zipCrypto) {
  4796. rawExtraFieldAES = new Uint8Array(getLength(EXTRAFIELD_DATA_AES) + 2);
  4797. const extraFieldAESView = getDataView(rawExtraFieldAES);
  4798. setUint16(extraFieldAESView, 0, EXTRAFIELD_TYPE_AES);
  4799. arraySet(rawExtraFieldAES, EXTRAFIELD_DATA_AES, 2);
  4800. setUint8(extraFieldAESView, 8, encryptionStrength);
  4801. } else {
  4802. rawExtraFieldAES = new Uint8Array();
  4803. }
  4804. let rawExtraFieldNTFS;
  4805. let rawExtraFieldExtendedTimestamp;
  4806. let extraFieldExtendedTimestampFlag;
  4807. if (extendedTimestamp) {
  4808. rawExtraFieldExtendedTimestamp = new Uint8Array(9 + (lastAccessDate ? 4 : 0) + (creationDate ? 4 : 0));
  4809. const extraFieldExtendedTimestampView = getDataView(rawExtraFieldExtendedTimestamp);
  4810. setUint16(extraFieldExtendedTimestampView, 0, EXTRAFIELD_TYPE_EXTENDED_TIMESTAMP);
  4811. setUint16(extraFieldExtendedTimestampView, 2, getLength(rawExtraFieldExtendedTimestamp) - 4);
  4812. extraFieldExtendedTimestampFlag = 0x1 + (lastAccessDate ? 0x2 : 0) + (creationDate ? 0x4 : 0);
  4813. setUint8(extraFieldExtendedTimestampView, 4, extraFieldExtendedTimestampFlag);
  4814. let offset = 5;
  4815. setUint32(extraFieldExtendedTimestampView, offset, Math.floor(lastModDate.getTime() / 1000));
  4816. offset += 4;
  4817. if (lastAccessDate) {
  4818. setUint32(extraFieldExtendedTimestampView, offset, Math.floor(lastAccessDate.getTime() / 1000));
  4819. offset += 4;
  4820. }
  4821. if (creationDate) {
  4822. setUint32(extraFieldExtendedTimestampView, offset, Math.floor(creationDate.getTime() / 1000));
  4823. }
  4824. try {
  4825. rawExtraFieldNTFS = new Uint8Array(36);
  4826. const extraFieldNTFSView = getDataView(rawExtraFieldNTFS);
  4827. const lastModTimeNTFS = getTimeNTFS(lastModDate);
  4828. setUint16(extraFieldNTFSView, 0, EXTRAFIELD_TYPE_NTFS);
  4829. setUint16(extraFieldNTFSView, 2, 32);
  4830. setUint16(extraFieldNTFSView, 8, EXTRAFIELD_TYPE_NTFS_TAG1);
  4831. setUint16(extraFieldNTFSView, 10, 24);
  4832. setBigUint64(extraFieldNTFSView, 12, lastModTimeNTFS);
  4833. setBigUint64(extraFieldNTFSView, 20, getTimeNTFS(lastAccessDate) || lastModTimeNTFS);
  4834. setBigUint64(extraFieldNTFSView, 28, getTimeNTFS(creationDate) || lastModTimeNTFS);
  4835. } catch {
  4836. rawExtraFieldNTFS = new Uint8Array();
  4837. }
  4838. } else {
  4839. rawExtraFieldNTFS = rawExtraFieldExtendedTimestamp = new Uint8Array();
  4840. }
  4841. let rawExtraFieldUnix;
  4842. try {
  4843. const { uid, gid, unixMode, setuid, setgid, sticky, unixExtraFieldType } = options;
  4844. if (unixExtraFieldType && (uid !== UNDEFINED_VALUE || gid !== UNDEFINED_VALUE || unixMode !== UNDEFINED_VALUE)) {
  4845. const uidBytes = packUnixId(uid);
  4846. const gidBytes = packUnixId(gid);
  4847. let modeArray = new Uint8Array();
  4848. if (unixExtraFieldType == UNIX_EXTRA_FIELD_TYPE && unixMode !== UNDEFINED_VALUE) {
  4849. let modeToWrite = unixMode & MAX_16_BITS;
  4850. if (setuid) {
  4851. modeToWrite |= FILE_ATTR_UNIX_SETUID_MASK;
  4852. }
  4853. if (setgid) {
  4854. modeToWrite |= FILE_ATTR_UNIX_SETGID_MASK;
  4855. }
  4856. if (sticky) {
  4857. modeToWrite |= FILE_ATTR_UNIX_STICKY_MASK;
  4858. }
  4859. modeArray = new Uint8Array(2);
  4860. const modeDataView = new DataView(modeArray.buffer);
  4861. modeDataView.setUint16(0, modeToWrite, true);
  4862. }
  4863. const payloadLength = 3 + uidBytes.length + gidBytes.length + modeArray.length;
  4864. rawExtraFieldUnix = new Uint8Array(4 + payloadLength);
  4865. const rawExtraFieldUnixView = getDataView(rawExtraFieldUnix);
  4866. setUint16(rawExtraFieldUnixView, 0, unixExtraFieldType == INFOZIP_EXTRA_FIELD_TYPE ? EXTRAFIELD_TYPE_INFOZIP : EXTRAFIELD_TYPE_UNIX);
  4867. setUint16(rawExtraFieldUnixView, 2, payloadLength);
  4868. setUint8(rawExtraFieldUnixView, 4, 1);
  4869. setUint8(rawExtraFieldUnixView, 5, uidBytes.length);
  4870. let offset = 6;
  4871. arraySet(rawExtraFieldUnix, uidBytes, offset);
  4872. offset += uidBytes.length;
  4873. setUint8(rawExtraFieldUnixView, offset, gidBytes.length);
  4874. offset++;
  4875. arraySet(rawExtraFieldUnix, gidBytes, offset);
  4876. offset += gidBytes.length;
  4877. arraySet(rawExtraFieldUnix, modeArray, offset);
  4878. } else {
  4879. rawExtraFieldUnix = new Uint8Array();
  4880. }
  4881. } catch {
  4882. rawExtraFieldUnix = new Uint8Array();
  4883. }
  4884. if (compressionMethod === UNDEFINED_VALUE) {
  4885. compressionMethod = compressed ? COMPRESSION_METHOD_DEFLATE : COMPRESSION_METHOD_STORE;
  4886. }
  4887. if (zip64) {
  4888. version = version > VERSION_ZIP64 ? version : VERSION_ZIP64;
  4889. }
  4890. if (encrypted && !zipCrypto) {
  4891. version = version > VERSION_AES ? version : VERSION_AES;
  4892. rawExtraFieldAES[9] = compressionMethod;
  4893. compressionMethod = COMPRESSION_METHOD_AES;
  4894. }
  4895. const localExtraFieldZip64Length = zip64ExtraFieldComplete ? getLength(rawLocalExtraFieldZip64) : 0;
  4896. const extraFieldLength = localExtraFieldZip64Length + getLength(rawExtraFieldAES, rawExtraFieldExtendedTimestamp, rawExtraFieldNTFS, rawExtraFieldUnix, rawExtraField);
  4897. const {
  4898. headerArray,
  4899. headerView,
  4900. rawLastModDate
  4901. } = getHeaderArrayData({
  4902. version,
  4903. bitFlag: getBitFlag(level, useUnicodeFileNames, dataDescriptor, encrypted, compressionMethod),
  4904. compressionMethod,
  4905. uncompressedSize,
  4906. lastModDate: lastModDate < MIN_DATE ? MIN_DATE : lastModDate > MAX_DATE ? MAX_DATE : lastModDate,
  4907. rawFilename,
  4908. zip64CompressedSize,
  4909. zip64UncompressedSize,
  4910. extraFieldLength
  4911. });
  4912. let localHeaderOffset = HEADER_SIZE;
  4913. const localHeaderArray = new Uint8Array(localHeaderOffset + getLength(rawFilename) + extraFieldLength);
  4914. const localHeaderView = getDataView(localHeaderArray);
  4915. setUint32(localHeaderView, 0, LOCAL_FILE_HEADER_SIGNATURE);
  4916. arraySet(localHeaderArray, headerArray, 4);
  4917. arraySet(localHeaderArray, rawFilename, localHeaderOffset);
  4918. localHeaderOffset += getLength(rawFilename);
  4919. if (zip64ExtraFieldComplete) {
  4920. arraySet(localHeaderArray, rawLocalExtraFieldZip64, localHeaderOffset);
  4921. }
  4922. localHeaderOffset += localExtraFieldZip64Length;
  4923. arraySet(localHeaderArray, rawExtraFieldAES, localHeaderOffset);
  4924. localHeaderOffset += getLength(rawExtraFieldAES);
  4925. arraySet(localHeaderArray, rawExtraFieldExtendedTimestamp, localHeaderOffset);
  4926. localHeaderOffset += getLength(rawExtraFieldExtendedTimestamp);
  4927. arraySet(localHeaderArray, rawExtraFieldNTFS, localHeaderOffset);
  4928. localHeaderOffset += getLength(rawExtraFieldNTFS);
  4929. arraySet(localHeaderArray, rawExtraFieldUnix, localHeaderOffset);
  4930. localHeaderOffset += getLength(rawExtraFieldUnix);
  4931. arraySet(localHeaderArray, rawExtraField, localHeaderOffset);
  4932. if (dataDescriptor) {
  4933. setUint32(localHeaderView, HEADER_OFFSET_COMPRESSED_SIZE + 4, 0);
  4934. setUint32(localHeaderView, HEADER_OFFSET_UNCOMPRESSED_SIZE + 4, 0);
  4935. }
  4936. return {
  4937. localHeaderArray,
  4938. localHeaderView,
  4939. headerArray,
  4940. headerView,
  4941. lastModDate,
  4942. rawLastModDate,
  4943. encrypted,
  4944. compressed,
  4945. version,
  4946. compressionMethod,
  4947. extraFieldExtendedTimestampFlag,
  4948. rawExtraFieldZip64: new Uint8Array(),
  4949. localExtraFieldZip64Length,
  4950. rawExtraFieldExtendedTimestamp,
  4951. rawExtraFieldNTFS,
  4952. rawExtraFieldUnix,
  4953. rawExtraFieldAES,
  4954. extraFieldLength
  4955. };
  4956. }
  4957. function appendExtraFieldUSDZ(entryInfo, zipWriterOffset) {
  4958. const { headerInfo } = entryInfo;
  4959. let { localHeaderArray, extraFieldLength } = headerInfo;
  4960. let localHeaderArrayView = getDataView(localHeaderArray);
  4961. let extraBytesLength = 64 - ((zipWriterOffset + getLength(localHeaderArray)) % 64);
  4962. if (extraBytesLength < 4) {
  4963. extraBytesLength += 64;
  4964. }
  4965. const rawExtraFieldUSDZ = new Uint8Array(extraBytesLength);
  4966. const extraFieldUSDZView = getDataView(rawExtraFieldUSDZ);
  4967. setUint16(extraFieldUSDZView, 0, EXTRAFIELD_TYPE_USDZ);
  4968. setUint16(extraFieldUSDZView, 2, extraBytesLength - 2);
  4969. const previousLocalHeaderArray = localHeaderArray;
  4970. headerInfo.localHeaderArray = localHeaderArray = new Uint8Array(getLength(previousLocalHeaderArray) + extraBytesLength);
  4971. arraySet(localHeaderArray, previousLocalHeaderArray);
  4972. arraySet(localHeaderArray, rawExtraFieldUSDZ, getLength(previousLocalHeaderArray));
  4973. localHeaderArrayView = getDataView(localHeaderArray);
  4974. setUint16(localHeaderArrayView, 28, extraFieldLength + extraBytesLength);
  4975. entryInfo.metadataSize += extraBytesLength;
  4976. }
  4977. function packUnixId(id) {
  4978. if (id === UNDEFINED_VALUE) {
  4979. return new Uint8Array();
  4980. } else {
  4981. const dataArray = new Uint8Array(4);
  4982. const dataView = getDataView(dataArray);
  4983. dataView.setUint32(0, id, true);
  4984. let length = 4;
  4985. while (length > 1 && dataArray[length - 1] === 0) {
  4986. length--;
  4987. }
  4988. return dataArray.subarray(0, length);
  4989. }
  4990. }
  4991. function normalizeMsdosAttributes(msdosAttributesRaw, msdosAttributes) {
  4992. if (msdosAttributesRaw !== UNDEFINED_VALUE) {
  4993. msdosAttributesRaw = msdosAttributesRaw & MAX_8_BITS;
  4994. } else if (msdosAttributes !== UNDEFINED_VALUE) {
  4995. const { readOnly, hidden, system, directory: msdDir, archive } = msdosAttributes;
  4996. let raw = 0;
  4997. if (readOnly) raw |= FILE_ATTR_MSDOS_READONLY_MASK;
  4998. if (hidden) raw |= FILE_ATTR_MSDOS_HIDDEN_MASK;
  4999. if (system) raw |= FILE_ATTR_MSDOS_SYSTEM_MASK;
  5000. if (msdDir) raw |= FILE_ATTR_MSDOS_DIR_MASK;
  5001. if (archive) raw |= FILE_ATTR_MSDOS_ARCHIVE_MASK;
  5002. msdosAttributesRaw = raw & MAX_8_BITS;
  5003. }
  5004. if (msdosAttributes === UNDEFINED_VALUE) {
  5005. msdosAttributes = {
  5006. readOnly: Boolean(msdosAttributesRaw & FILE_ATTR_MSDOS_READONLY_MASK),
  5007. hidden: Boolean(msdosAttributesRaw & FILE_ATTR_MSDOS_HIDDEN_MASK),
  5008. system: Boolean(msdosAttributesRaw & FILE_ATTR_MSDOS_SYSTEM_MASK),
  5009. directory: Boolean(msdosAttributesRaw & FILE_ATTR_MSDOS_DIR_MASK),
  5010. archive: Boolean(msdosAttributesRaw & FILE_ATTR_MSDOS_ARCHIVE_MASK)
  5011. };
  5012. }
  5013. return { msdosAttributesRaw, msdosAttributes };
  5014. }
  5015. function getDataDescriptorInfo({
  5016. zip64,
  5017. dataDescriptor,
  5018. dataDescriptorSignature
  5019. }) {
  5020. let dataDescriptorArray = new Uint8Array();
  5021. let dataDescriptorView, dataDescriptorOffset = 0;
  5022. let dataDescriptorLength = zip64 ? DATA_DESCRIPTOR_RECORD_ZIP_64_LENGTH : DATA_DESCRIPTOR_RECORD_LENGTH;
  5023. if (dataDescriptorSignature) {
  5024. dataDescriptorLength += DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH;
  5025. }
  5026. if (dataDescriptor) {
  5027. dataDescriptorArray = new Uint8Array(dataDescriptorLength);
  5028. dataDescriptorView = getDataView(dataDescriptorArray);
  5029. if (dataDescriptorSignature) {
  5030. dataDescriptorOffset = DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH;
  5031. setUint32(dataDescriptorView, 0, DATA_DESCRIPTOR_RECORD_SIGNATURE);
  5032. }
  5033. }
  5034. return {
  5035. dataDescriptorArray,
  5036. dataDescriptorView,
  5037. dataDescriptorOffset
  5038. };
  5039. }
  5040. function setEntryInfo({
  5041. signature,
  5042. compressedSize,
  5043. uncompressedSize,
  5044. headerInfo,
  5045. dataDescriptorInfo
  5046. }, {
  5047. zip64,
  5048. zipCrypto,
  5049. dataDescriptor
  5050. }) {
  5051. const {
  5052. headerView,
  5053. encrypted
  5054. } = headerInfo;
  5055. const {
  5056. dataDescriptorView,
  5057. dataDescriptorOffset
  5058. } = dataDescriptorInfo;
  5059. if ((!encrypted || zipCrypto) && signature !== UNDEFINED_VALUE) {
  5060. setUint32(headerView, HEADER_OFFSET_SIGNATURE, signature);
  5061. if (dataDescriptor) {
  5062. setUint32(dataDescriptorView, dataDescriptorOffset, signature);
  5063. }
  5064. }
  5065. if (zip64) {
  5066. if (dataDescriptor) {
  5067. setBigUint64(dataDescriptorView, dataDescriptorOffset + 4, BigInt(compressedSize));
  5068. setBigUint64(dataDescriptorView, dataDescriptorOffset + 12, BigInt(uncompressedSize));
  5069. }
  5070. } else {
  5071. setUint32(headerView, HEADER_OFFSET_COMPRESSED_SIZE, compressedSize);
  5072. setUint32(headerView, HEADER_OFFSET_UNCOMPRESSED_SIZE, uncompressedSize);
  5073. if (dataDescriptor) {
  5074. setUint32(dataDescriptorView, dataDescriptorOffset + 4, compressedSize);
  5075. setUint32(dataDescriptorView, dataDescriptorOffset + 8, uncompressedSize);
  5076. }
  5077. }
  5078. }
  5079. function updateLocalHeader({
  5080. rawFilename,
  5081. encrypted,
  5082. zip64,
  5083. localExtraFieldZip64Length,
  5084. signature,
  5085. compressedSize,
  5086. uncompressedSize,
  5087. zip64UncompressedSize,
  5088. zip64CompressedSize
  5089. }, localHeaderView, { dataDescriptor }) {
  5090. if (!dataDescriptor) {
  5091. if (!encrypted) {
  5092. setUint32(localHeaderView, HEADER_OFFSET_SIGNATURE + 4, signature);
  5093. }
  5094. if (!zip64CompressedSize) {
  5095. setUint32(localHeaderView, HEADER_OFFSET_COMPRESSED_SIZE + 4, compressedSize);
  5096. }
  5097. if (!zip64UncompressedSize) {
  5098. setUint32(localHeaderView, HEADER_OFFSET_UNCOMPRESSED_SIZE + 4, uncompressedSize);
  5099. }
  5100. }
  5101. if (zip64 && localExtraFieldZip64Length) {
  5102. let localHeaderOffset = HEADER_SIZE + getLength(rawFilename) + 4;
  5103. if (zip64UncompressedSize) {
  5104. setBigUint64(localHeaderView, localHeaderOffset, BigInt(uncompressedSize));
  5105. localHeaderOffset += 8;
  5106. }
  5107. if (zip64CompressedSize) {
  5108. setBigUint64(localHeaderView, localHeaderOffset, BigInt(compressedSize));
  5109. localHeaderOffset += 8;
  5110. }
  5111. }
  5112. }
  5113. async function closeFile(zipWriter, comment, options) {
  5114. const { files, writer } = zipWriter;
  5115. const { diskOffset } = writer;
  5116. let { diskNumber } = writer;
  5117. let offset = 0;
  5118. let directoryDataLength = 0;
  5119. let directoryOffset = zipWriter.offset - diskOffset;
  5120. let filesLength = files.size;
  5121. for (const [, fileEntry] of files) {
  5122. const {
  5123. rawFilename,
  5124. rawExtraFieldAES,
  5125. rawComment,
  5126. rawExtraFieldNTFS,
  5127. rawExtraFieldUnix,
  5128. rawExtraField,
  5129. extendedTimestamp,
  5130. extraFieldExtendedTimestampFlag,
  5131. lastModDate,
  5132. zip64UncompressedSize,
  5133. zip64CompressedSize,
  5134. uncompressedSize,
  5135. compressedSize
  5136. } = fileEntry;
  5137. const zip64Offset = fileEntry.offset > MAX_32_BITS;
  5138. const zip64DiskNumberStart = fileEntry.diskNumberStart > MAX_16_BITS;
  5139. let rawExtraFieldZip64;
  5140. if (zip64Offset || zip64DiskNumberStart || zip64UncompressedSize || zip64CompressedSize) {
  5141. let length = 4;
  5142. if (zip64UncompressedSize) length += 8;
  5143. if (zip64CompressedSize) length += 8;
  5144. if (zip64Offset) length += 8;
  5145. if (zip64DiskNumberStart) length += 4;
  5146. rawExtraFieldZip64 = new Uint8Array(length);
  5147. const zip64View = getDataView(rawExtraFieldZip64);
  5148. setUint16(zip64View, 0, EXTRAFIELD_TYPE_ZIP64);
  5149. setUint16(zip64View, 2, length - 4);
  5150. let zip64FieldOffset = 4;
  5151. if (zip64UncompressedSize) { setBigUint64(zip64View, zip64FieldOffset, BigInt(uncompressedSize)); zip64FieldOffset += 8; }
  5152. if (zip64CompressedSize) { setBigUint64(zip64View, zip64FieldOffset, BigInt(compressedSize)); zip64FieldOffset += 8; }
  5153. if (zip64Offset) { setBigUint64(zip64View, zip64FieldOffset, BigInt(fileEntry.offset)); zip64FieldOffset += 8; }
  5154. if (zip64DiskNumberStart) { setUint32(zip64View, zip64FieldOffset, fileEntry.diskNumberStart); }
  5155. } else {
  5156. rawExtraFieldZip64 = new Uint8Array();
  5157. }
  5158. fileEntry.rawExtraFieldZip64 = rawExtraFieldZip64;
  5159. fileEntry.zip64Offset = zip64Offset;
  5160. fileEntry.zip64DiskNumberStart = zip64DiskNumberStart;
  5161. let rawExtraFieldTimestamp;
  5162. if (extendedTimestamp) {
  5163. rawExtraFieldTimestamp = new Uint8Array(9);
  5164. const extraFieldExtendedTimestampView = getDataView(rawExtraFieldTimestamp);
  5165. setUint16(extraFieldExtendedTimestampView, 0, EXTRAFIELD_TYPE_EXTENDED_TIMESTAMP);
  5166. setUint16(extraFieldExtendedTimestampView, 2, 5);
  5167. setUint8(extraFieldExtendedTimestampView, 4, extraFieldExtendedTimestampFlag);
  5168. setUint32(extraFieldExtendedTimestampView, 5, Math.floor(lastModDate.getTime() / 1000));
  5169. } else {
  5170. rawExtraFieldTimestamp = new Uint8Array();
  5171. }
  5172. fileEntry.rawExtraFieldExtendedTimestamp = rawExtraFieldTimestamp;
  5173. directoryDataLength += 46 +
  5174. getLength(
  5175. rawFilename,
  5176. rawComment,
  5177. rawExtraFieldZip64,
  5178. rawExtraFieldAES,
  5179. rawExtraFieldNTFS,
  5180. rawExtraFieldUnix,
  5181. rawExtraFieldTimestamp,
  5182. rawExtraField);
  5183. }
  5184. const directoryArray = new Uint8Array(directoryDataLength);
  5185. const directoryView = getDataView(directoryArray);
  5186. await initStream(writer);
  5187. let directoryDiskOffset = 0;
  5188. for (const [indexFileEntry, fileEntry] of Array.from(files.values()).entries()) {
  5189. const {
  5190. offset: fileEntryOffset,
  5191. rawFilename,
  5192. rawExtraFieldZip64,
  5193. rawExtraFieldAES,
  5194. rawExtraFieldExtendedTimestamp,
  5195. rawExtraFieldNTFS,
  5196. rawExtraFieldUnix,
  5197. rawExtraField,
  5198. rawComment,
  5199. versionMadeBy,
  5200. headerArray,
  5201. headerView,
  5202. zip64UncompressedSize,
  5203. zip64CompressedSize,
  5204. zip64DiskNumberStart,
  5205. zip64Offset,
  5206. internalFileAttributes,
  5207. externalFileAttributes,
  5208. diskNumberStart,
  5209. uncompressedSize,
  5210. compressedSize
  5211. } = fileEntry;
  5212. const extraFieldLength = getLength(rawExtraFieldZip64, rawExtraFieldAES, rawExtraFieldExtendedTimestamp, rawExtraFieldNTFS, rawExtraFieldUnix, rawExtraField);
  5213. setUint32(directoryView, offset, CENTRAL_FILE_HEADER_SIGNATURE);
  5214. setUint16(directoryView, offset + 4, versionMadeBy);
  5215. if (!zip64UncompressedSize) {
  5216. setUint32(headerView, HEADER_OFFSET_UNCOMPRESSED_SIZE, uncompressedSize);
  5217. }
  5218. if (!zip64CompressedSize) {
  5219. setUint32(headerView, HEADER_OFFSET_COMPRESSED_SIZE, compressedSize);
  5220. }
  5221. arraySet(directoryArray, headerArray, offset + 6);
  5222. let directoryOffset = offset + HEADER_SIZE;
  5223. setUint16(directoryView, directoryOffset, extraFieldLength);
  5224. directoryOffset += 2;
  5225. setUint16(directoryView, directoryOffset, getLength(rawComment));
  5226. directoryOffset += 2;
  5227. setUint16(directoryView, directoryOffset, zip64DiskNumberStart ? MAX_16_BITS : diskNumberStart);
  5228. directoryOffset += 2;
  5229. setUint16(directoryView, directoryOffset, internalFileAttributes);
  5230. directoryOffset += 2;
  5231. if (externalFileAttributes) {
  5232. setUint32(directoryView, directoryOffset, externalFileAttributes);
  5233. }
  5234. directoryOffset += 4;
  5235. setUint32(directoryView, directoryOffset, zip64Offset ? MAX_32_BITS : fileEntryOffset);
  5236. directoryOffset += 4;
  5237. arraySet(directoryArray, rawFilename, directoryOffset);
  5238. directoryOffset += getLength(rawFilename);
  5239. arraySet(directoryArray, rawExtraFieldZip64, directoryOffset);
  5240. directoryOffset += getLength(rawExtraFieldZip64);
  5241. arraySet(directoryArray, rawExtraFieldAES, directoryOffset);
  5242. directoryOffset += getLength(rawExtraFieldAES);
  5243. arraySet(directoryArray, rawExtraFieldExtendedTimestamp, directoryOffset);
  5244. directoryOffset += getLength(rawExtraFieldExtendedTimestamp);
  5245. arraySet(directoryArray, rawExtraFieldNTFS, directoryOffset);
  5246. directoryOffset += getLength(rawExtraFieldNTFS);
  5247. arraySet(directoryArray, rawExtraFieldUnix, directoryOffset);
  5248. directoryOffset += getLength(rawExtraFieldUnix);
  5249. arraySet(directoryArray, rawExtraField, directoryOffset);
  5250. directoryOffset += getLength(rawExtraField);
  5251. arraySet(directoryArray, rawComment, directoryOffset);
  5252. directoryOffset += getLength(rawComment);
  5253. if (offset - directoryDiskOffset > writer.availableSize) {
  5254. writer.availableSize = 0;
  5255. await writeData(writer, directoryArray.slice(directoryDiskOffset, offset));
  5256. directoryDiskOffset = offset;
  5257. }
  5258. offset = directoryOffset;
  5259. if (options.onprogress) {
  5260. try {
  5261. await options.onprogress(indexFileEntry + 1, files.size, new Entry(fileEntry));
  5262. } catch {
  5263. // ignored
  5264. }
  5265. }
  5266. }
  5267. await writeData(writer, directoryDiskOffset ? directoryArray.slice(directoryDiskOffset) : directoryArray);
  5268. let lastDiskNumber = writer.diskNumber;
  5269. const { availableSize } = writer;
  5270. if (availableSize < END_OF_CENTRAL_DIR_LENGTH) {
  5271. lastDiskNumber++;
  5272. }
  5273. let zip64 = getOptionValue(zipWriter, options, PROPERTY_NAME_ZIP64);
  5274. if (directoryOffset > MAX_32_BITS || directoryDataLength > MAX_32_BITS || filesLength > MAX_16_BITS || lastDiskNumber > MAX_16_BITS) {
  5275. if (zip64 === false) {
  5276. throw new Error(ERR_UNSUPPORTED_FORMAT);
  5277. } else {
  5278. zip64 = true;
  5279. }
  5280. }
  5281. const endOfdirectoryArray = new Uint8Array(zip64 ? ZIP64_END_OF_CENTRAL_DIR_TOTAL_LENGTH : END_OF_CENTRAL_DIR_LENGTH);
  5282. const endOfdirectoryView = getDataView(endOfdirectoryArray);
  5283. offset = 0;
  5284. if (zip64) {
  5285. setUint32(endOfdirectoryView, 0, ZIP64_END_OF_CENTRAL_DIR_SIGNATURE);
  5286. setBigUint64(endOfdirectoryView, 4, BigInt(44));
  5287. setUint16(endOfdirectoryView, 12, 45);
  5288. setUint16(endOfdirectoryView, 14, 45);
  5289. setUint32(endOfdirectoryView, 16, lastDiskNumber);
  5290. setUint32(endOfdirectoryView, 20, diskNumber);
  5291. setBigUint64(endOfdirectoryView, 24, BigInt(filesLength));
  5292. setBigUint64(endOfdirectoryView, 32, BigInt(filesLength));
  5293. setBigUint64(endOfdirectoryView, 40, BigInt(directoryDataLength));
  5294. setBigUint64(endOfdirectoryView, 48, BigInt(directoryOffset));
  5295. setUint32(endOfdirectoryView, 56, ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIGNATURE);
  5296. setBigUint64(endOfdirectoryView, 64, BigInt(directoryOffset) + BigInt(directoryDataLength));
  5297. setUint32(endOfdirectoryView, 72, lastDiskNumber + 1);
  5298. const supportZip64SplitFile = getOptionValue(zipWriter, options, OPTION_SUPPORT_ZIP64_SPLIT_FILE, true);
  5299. if (supportZip64SplitFile) {
  5300. lastDiskNumber = MAX_16_BITS;
  5301. diskNumber = MAX_16_BITS;
  5302. }
  5303. filesLength = MAX_16_BITS;
  5304. directoryOffset = MAX_32_BITS;
  5305. directoryDataLength = MAX_32_BITS;
  5306. offset += ZIP64_END_OF_CENTRAL_DIR_LENGTH + ZIP64_END_OF_CENTRAL_DIR_LOCATOR_LENGTH;
  5307. }
  5308. setUint32(endOfdirectoryView, offset, END_OF_CENTRAL_DIR_SIGNATURE);
  5309. setUint16(endOfdirectoryView, offset + 4, lastDiskNumber);
  5310. setUint16(endOfdirectoryView, offset + 6, diskNumber);
  5311. setUint16(endOfdirectoryView, offset + 8, filesLength);
  5312. setUint16(endOfdirectoryView, offset + 10, filesLength);
  5313. setUint32(endOfdirectoryView, offset + 12, directoryDataLength);
  5314. setUint32(endOfdirectoryView, offset + 16, directoryOffset);
  5315. const commentLength = getLength(comment);
  5316. if (commentLength) {
  5317. if (commentLength <= MAX_16_BITS) {
  5318. setUint16(endOfdirectoryView, offset + 20, commentLength);
  5319. } else {
  5320. throw new Error(ERR_INVALID_COMMENT);
  5321. }
  5322. }
  5323. await writeData(writer, endOfdirectoryArray);
  5324. if (commentLength) {
  5325. await writeData(writer, comment);
  5326. }
  5327. }
  5328. async function writeData(writer, array) {
  5329. const { writable } = writer;
  5330. const streamWriter = writable.getWriter();
  5331. try {
  5332. await streamWriter.ready;
  5333. writer.size += getLength(array);
  5334. await streamWriter.write(array);
  5335. } finally {
  5336. streamWriter.releaseLock();
  5337. }
  5338. }
  5339. function getTimeNTFS(date) {
  5340. if (date) {
  5341. return ((BigInt(date.getTime()) + BigInt(11644473600000)) * BigInt(10000));
  5342. }
  5343. }
  5344. function getOptionValue(zipWriter, options, name, defaultValue) {
  5345. const result = options[name] === UNDEFINED_VALUE ? zipWriter.options[name] : options[name];
  5346. return result === UNDEFINED_VALUE ? defaultValue : result;
  5347. }
  5348. function getMaximumCompressedSize(uncompressedSize) {
  5349. return uncompressedSize + (5 * (Math.floor(uncompressedSize / 16383) + 1));
  5350. }
  5351. function setUint8(view, offset, value) {
  5352. view.setUint8(offset, value);
  5353. }
  5354. function setUint16(view, offset, value) {
  5355. view.setUint16(offset, value, true);
  5356. }
  5357. function setUint32(view, offset, value) {
  5358. view.setUint32(offset, value, true);
  5359. }
  5360. function setBigUint64(view, offset, value) {
  5361. view.setBigUint64(offset, value, true);
  5362. }
  5363. function arraySet(array, typedArray, offset) {
  5364. array.set(typedArray, offset);
  5365. }
  5366. function getDataView(array) {
  5367. return new DataView(array.buffer);
  5368. }
  5369. function getLength(...arrayLikes) {
  5370. let result = 0;
  5371. arrayLikes.forEach(arrayLike => arrayLike && (result += arrayLike.length));
  5372. return result;
  5373. }
  5374. function getHeaderArrayData({
  5375. version,
  5376. bitFlag,
  5377. compressionMethod,
  5378. uncompressedSize,
  5379. compressedSize,
  5380. lastModDate,
  5381. rawFilename,
  5382. zip64CompressedSize,
  5383. zip64UncompressedSize,
  5384. extraFieldLength
  5385. }) {
  5386. const headerArray = new Uint8Array(HEADER_SIZE - 4);
  5387. const headerView = getDataView(headerArray);
  5388. setUint16(headerView, 0, version);
  5389. setUint16(headerView, 2, bitFlag);
  5390. setUint16(headerView, 4, compressionMethod);
  5391. const dateArray = new Uint32Array(1);
  5392. const dateView = getDataView(dateArray);
  5393. setUint16(dateView, 0, (((lastModDate.getHours() << 6) | lastModDate.getMinutes()) << 5) | lastModDate.getSeconds() / 2);
  5394. setUint16(dateView, 2, ((((lastModDate.getFullYear() - 1980) << 4) | (lastModDate.getMonth() + 1)) << 5) | lastModDate.getDate());
  5395. const rawLastModDate = dateArray[0];
  5396. setUint32(headerView, 6, rawLastModDate);
  5397. if (zip64CompressedSize || compressedSize !== UNDEFINED_VALUE) {
  5398. setUint32(headerView, HEADER_OFFSET_COMPRESSED_SIZE, zip64CompressedSize ? MAX_32_BITS : compressedSize);
  5399. }
  5400. if (zip64UncompressedSize || uncompressedSize !== UNDEFINED_VALUE) {
  5401. setUint32(headerView, HEADER_OFFSET_UNCOMPRESSED_SIZE, zip64UncompressedSize ? MAX_32_BITS : uncompressedSize);
  5402. }
  5403. setUint16(headerView, 22, getLength(rawFilename));
  5404. setUint16(headerView, 24, extraFieldLength);
  5405. return {
  5406. headerArray,
  5407. headerView,
  5408. rawLastModDate
  5409. };
  5410. }
  5411. function getBitFlag(level, useUnicodeFileNames, dataDescriptor, encrypted, compressionMethod) {
  5412. let bitFlag = 0;
  5413. if (useUnicodeFileNames) {
  5414. bitFlag = bitFlag | BITFLAG_LANG_ENCODING_FLAG;
  5415. }
  5416. if (dataDescriptor) {
  5417. bitFlag = bitFlag | BITFLAG_DATA_DESCRIPTOR;
  5418. }
  5419. if (compressionMethod == COMPRESSION_METHOD_DEFLATE || compressionMethod == COMPRESSION_METHOD_DEFLATE_64) {
  5420. if (level >= 0 && level <= 3) {
  5421. bitFlag = bitFlag | BITFLAG_LEVEL_SUPER_FAST_MASK;
  5422. }
  5423. if (level > 3 && level <= 5) {
  5424. bitFlag = bitFlag | BITFLAG_LEVEL_FAST_MASK;
  5425. }
  5426. if (level == 9) {
  5427. bitFlag = bitFlag | BITFLAG_LEVEL_MAX_MASK;
  5428. }
  5429. }
  5430. if (encrypted) {
  5431. bitFlag = bitFlag | BITFLAG_ENCRYPTED;
  5432. }
  5433. return bitFlag;
  5434. }
  5435. /*
  5436. Copyright (c) 2022 Gildas Lormeau. All rights reserved.
  5437. Redistribution and use in source and binary forms, with or without
  5438. modification, are permitted provided that the following conditions are met:
  5439. 1. Redistributions of source code must retain the above copyright notice,
  5440. this list of conditions and the following disclaimer.
  5441. 2. Redistributions in binary form must reproduce the above copyright
  5442. notice, this list of conditions and the following disclaimer in
  5443. the documentation and/or other materials provided with the distribution.
  5444. 3. The names of the authors may not be used to endorse or promote products
  5445. derived from this software without specific prior written permission.
  5446. THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  5447. INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  5448. FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
  5449. INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
  5450. INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  5451. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
  5452. OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  5453. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  5454. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  5455. EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  5456. */
  5457. function getMimeType$1() {
  5458. return "application/octet-stream";
  5459. }
  5460. /*
  5461. Copyright (c) 2025 Gildas Lormeau. All rights reserved.
  5462. Redistribution and use in source and binary forms, with or without
  5463. modification, are permitted provided that the following conditions are met:
  5464. 1. Redistributions of source code must retain the above copyright notice,
  5465. this list of conditions and the following disclaimer.
  5466. 2. Redistributions in binary form must reproduce the above copyright
  5467. notice, this list of conditions and the following disclaimer in
  5468. the documentation and/or other materials provided with the distribution.
  5469. 3. The names of the authors may not be used to endorse or promote products
  5470. derived from this software without specific prior written permission.
  5471. THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  5472. INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  5473. FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
  5474. INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
  5475. INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  5476. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
  5477. OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  5478. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  5479. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  5480. EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  5481. */
  5482. try {
  5483. configure({ baseURI: (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)) });
  5484. } catch {
  5485. // ignored
  5486. }
  5487. const A="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function g(g){let B;g({wasmURI:()=>(B||(B="data:application/wasm;base64,"+(g=>{g=(g=>{const B=(g=(g+"").replace(/[^A-Za-z0-9+/=]/g,"")).length,E=[];for(let I=0;B>I;I+=4){const B=A.indexOf(g[I])<<18|A.indexOf(g[I+1])<<12|(63&A.indexOf(g[I+2]))<<6|63&A.indexOf(g[I+3]);E.push(B>>16&255),"="!==g[I+2]&&E.push(B>>8&255),"="!==g[I+3]&&E.push(255&B);}return new Uint8Array(E)})(g);let B=new Uint8Array(1024),E=0;for(let A=0;A<g.length;){const C=g[A++];if(128&C){const Q=3+(127&C),D=g[A++]<<8|g[A++],o=E-D;I(E+Q);for(let A=0;Q>A;A++)B[E++]=B[o+A];}else {const Q=C;I(E+Q);for(let I=0;Q>I&&A<g.length;I++)B[E++]=g[A++];}}return (g=>{let B="";const E=g.length;let I=0;for(;E>I+2;I+=3){const E=g[I]<<16|g[I+1]<<8|g[I+2];B+=A[E>>18&63]+A[E>>12&63]+A[E>>6&63]+A[63&E];}const C=E-I;if(1===C){const E=g[I]<<16;B+=A[E>>18&63]+A[E>>12&63]+"==";}else if(2===C){const E=g[I]<<16|g[I+1]<<8;B+=A[E>>18&63]+A[E>>12&63]+A[E>>6&63]+"=";}return B})(new Uint8Array(B.buffer.slice(0,E)));function I(A){if(B.length<A){let g=2*B.length;for(;A>g;)g*=2;const I=new Uint8Array(g);I.set(B.subarray(0,E)),B=I;}}})("FQBhc20BAAAAAUULYAF/AX9gAn9/AIEABYAACwIDf4IABwEBgAARAQaAAAuDAA6BABUDAGAAgAADgAANAQSBABUDAGAHgwAegAAfEgNCQQcABAEABAgIAAIABQIKAIAAB4EAAwEFgQAHAgICgQAHEAEDAAUGAAMDBQQJBAQJAQaAAAEeAAIEAwIEAgIBBAcDAwQFAXABDQ0FBgEBggKCAgYIgACYIkHQ1QQLB4oEHAZtZW1vcnkCAAxpbmZsYXRlOV9uZXcABw2GAA8HaW5pdAAIEYoAEAdfcmF3AAoQhgAUCXByb2Nlc3MAC4cARgZlbmQADhaGAA8QbGFzdF9jb25zdW1lZAARC4QAGYMAbYUANoMAbAEShQBYhwBrARSFAH+DABMHZ3ppcAAVD4UAFIUAfgEWhgBWgQB9AhgVhQAOjQB8AmRliQB8hQAOggB8AhoQiQAPggB8AhsRigATggB8AhwPhQAUhQB8AR2GAFaBAHwJHwRmcmVlAAIVhQAVjACD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BDIQABIAF24FHeQTgHQsjhQBfhQXLAhARgAVtBgcJBgoFC4A6uAQNAg4BgAclBJQeC2mFAJCFAIiFAICFAHiBAGiBAFyBBh8BEIAABAEUgAAEARiAAAQBHIAABAEggAAEASiAAAQBMIAABAE4gAAEAUCAAAQBUIAABIEGvQFwgAAEAYCAAAQBoIAABAHAgAAEAeCAAG8DHwtyjQBvgQBrgQBngQBjgQBfgQBbgQBXgQBTgQBPgQBLgQBHgQBDgQE8AYCvAEGAUc0CC22BAMcBBIAAAgEIgAAEgQEzgQJLARCAAA6DAAyBnqyAqmuEACSBB3OBAE8BCIAACIEAGIUADIEIt4MADAEggQCUgDKEgQBrAYCBCC8BBIMADIA/SAoBABAMAEGRIQv/gCUfgMDAgIKxBQgJCQoKgEk3gAABAQ2AAAEBDoAAAQEPgAABARCEAAEBEYQAAQEShAABAROEAAEBFIwAAQEVjAABARaMAAEBF4wAAQEYnAABARmcAAEBGpwAAQEbmwABARyBffsEBAQFBYHB1QEHgAABAQiEAAGAXSqCAAEBCowAAYAnsooAAYEBMJkAAYEBTJkAAYEBaLkAAYEBpLkAAYIDdYABzoUBvI0BqJ0BkLwBgAIbHLwAAQEdvAABgA9PgH05A9AqAQ==")),B)});}
  5488. /*
  5489. Copyright (c) 2025 Gildas Lormeau. All rights reserved.
  5490. Redistribution and use in source and binary forms, with or without
  5491. modification, are permitted provided that the following conditions are met:
  5492. 1. Redistributions of source code must retain the above copyright notice,
  5493. this list of conditions and the following disclaimer.
  5494. 2. Redistributions in binary form must reproduce the above copyright
  5495. notice, this list of conditions and the following disclaimer in
  5496. the documentation and/or other materials provided with the distribution.
  5497. 3. The names of the authors may not be used to endorse or promote products
  5498. derived from this software without specific prior written permission.
  5499. THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  5500. INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  5501. FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
  5502. INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
  5503. INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  5504. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
  5505. OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  5506. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  5507. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  5508. EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  5509. */
  5510. /* global TransformStream */
  5511. let wasm, malloc, free, memory;
  5512. function setWasmExports(wasmAPI) {
  5513. wasm = wasmAPI;
  5514. ({ malloc, free, memory } = wasm);
  5515. if (typeof malloc !== "function" || typeof free !== "function" || !memory) {
  5516. wasm = malloc = free = memory = null;
  5517. throw new Error("Invalid WASM module");
  5518. }
  5519. }
  5520. function _make(isCompress, type, options = {}) {
  5521. const level = (typeof options.level === "number") ? options.level : -1;
  5522. const outBufferSize = (typeof options.outBuffer === "number") ? options.outBuffer : 64 * 1024;
  5523. const inBufferSize = (typeof options.inBufferSize === "number") ? options.inBufferSize : 64 * 1024;
  5524. return new TransformStream({
  5525. start() {
  5526. let result;
  5527. this.out = malloc(outBufferSize);
  5528. this.in = malloc(inBufferSize);
  5529. this.inBufferSize = inBufferSize;
  5530. this._scratch = new Uint8Array(outBufferSize);
  5531. if (isCompress) {
  5532. this._process = wasm.deflate_process;
  5533. this._last_consumed = wasm.deflate_last_consumed;
  5534. this._end = wasm.deflate_end;
  5535. this.streamHandle = wasm.deflate_new();
  5536. if (type === "gzip") {
  5537. result = wasm.deflate_init_gzip(this.streamHandle, level);
  5538. } else if (type === "deflate-raw") {
  5539. result = wasm.deflate_init_raw(this.streamHandle, level);
  5540. } else {
  5541. result = wasm.deflate_init(this.streamHandle, level);
  5542. }
  5543. } else {
  5544. if (type === "deflate64-raw") {
  5545. this._process = wasm.inflate9_process;
  5546. this._last_consumed = wasm.inflate9_last_consumed;
  5547. this._end = wasm.inflate9_end;
  5548. this.streamHandle = wasm.inflate9_new();
  5549. result = wasm.inflate9_init_raw(this.streamHandle);
  5550. } else {
  5551. this._process = wasm.inflate_process;
  5552. this._last_consumed = wasm.inflate_last_consumed;
  5553. this._end = wasm.inflate_end;
  5554. this.streamHandle = wasm.inflate_new();
  5555. if (type === "deflate-raw") {
  5556. result = wasm.inflate_init_raw(this.streamHandle);
  5557. } else if (type === "gzip") {
  5558. result = wasm.inflate_init_gzip(this.streamHandle);
  5559. } else {
  5560. result = wasm.inflate_init(this.streamHandle);
  5561. }
  5562. }
  5563. }
  5564. if (result !== 0) {
  5565. throw new Error("init failed:" + result);
  5566. }
  5567. },
  5568. transform(chunk, controller) {
  5569. try {
  5570. const buffer = chunk;
  5571. const heap = new Uint8Array(memory.buffer);
  5572. const process = this._process;
  5573. const last_consumed = this._last_consumed;
  5574. const out = this.out;
  5575. const scratch = this._scratch;
  5576. let offset = 0;
  5577. while (offset < buffer.length) {
  5578. const toRead = Math.min(buffer.length - offset, 32 * 1024);
  5579. if (!this.in || this.inBufferSize < toRead) {
  5580. if (this.in && free) {
  5581. free(this.in);
  5582. }
  5583. this.in = malloc(toRead);
  5584. this.inBufferSize = toRead;
  5585. }
  5586. heap.set(buffer.subarray(offset, offset + toRead), this.in);
  5587. const result = process(this.streamHandle, this.in, toRead, out, outBufferSize, 0);
  5588. const prod = result & 0x00ffffff;
  5589. if (prod) {
  5590. scratch.set(heap.subarray(out, out + prod), 0);
  5591. controller.enqueue(scratch.slice(0, prod));
  5592. }
  5593. if (!isCompress) {
  5594. const code = (result >> 24) & 0xff;
  5595. const signedCode = (code & 0x80) ? code - 256 : code;
  5596. if (signedCode < 0) {
  5597. throw new Error("process error:" + signedCode);
  5598. }
  5599. }
  5600. const consumed = last_consumed(this.streamHandle);
  5601. if (consumed === 0) {
  5602. break;
  5603. }
  5604. offset += consumed;
  5605. }
  5606. } catch (error) {
  5607. if (this._end && this.streamHandle) {
  5608. this._end(this.streamHandle);
  5609. }
  5610. if (this.in && free) {
  5611. free(this.in);
  5612. }
  5613. if (this.out && free) {
  5614. free(this.out);
  5615. }
  5616. controller.error(error);
  5617. }
  5618. },
  5619. flush(controller) {
  5620. try {
  5621. const heap = new Uint8Array(memory.buffer);
  5622. const process = this._process;
  5623. const out = this.out;
  5624. const scratch = this._scratch;
  5625. while (true) {
  5626. const result = process(this.streamHandle, 0, 0, out, outBufferSize, 4);
  5627. const produced = result & 0x00ffffff;
  5628. const code = (result >> 24) & 0xff;
  5629. if (!isCompress) {
  5630. const signedCode = (code & 0x80) ? code - 256 : code;
  5631. if (signedCode < 0) {
  5632. throw new Error("process error:" + signedCode);
  5633. }
  5634. }
  5635. if (produced) {
  5636. scratch.set(heap.subarray(out, out + produced), 0);
  5637. controller.enqueue(scratch.slice(0, produced));
  5638. }
  5639. if (code === 1 || produced === 0) {
  5640. break;
  5641. }
  5642. }
  5643. } catch (error) {
  5644. controller.error(error);
  5645. } finally {
  5646. if (this._end && this.streamHandle) {
  5647. const result = this._end(this.streamHandle);
  5648. if (result !== 0) {
  5649. controller.error(new Error("end error:" + result));
  5650. }
  5651. }
  5652. if (this.in && free) {
  5653. free(this.in);
  5654. }
  5655. if (this.out && free) {
  5656. free(this.out);
  5657. }
  5658. }
  5659. }
  5660. });
  5661. }
  5662. class CompressionStreamZlib {
  5663. constructor(type = "deflate", options) {
  5664. return _make(true, type, options);
  5665. }
  5666. }
  5667. class DecompressionStreamZlib {
  5668. constructor(type = "deflate", options) {
  5669. return _make(false, type, options);
  5670. }
  5671. }
  5672. /*
  5673. Copyright (c) 2025 Gildas Lormeau. All rights reserved.
  5674. Redistribution and use in source and binary forms, with or without
  5675. modification, are permitted provided that the following conditions are met:
  5676. 1. Redistributions of source code must retain the above copyright notice,
  5677. this list of conditions and the following disclaimer.
  5678. 2. Redistributions in binary form must reproduce the above copyright
  5679. notice, this list of conditions and the following disclaimer in
  5680. the documentation and/or other materials provided with the distribution.
  5681. 3. The names of the authors may not be used to endorse or promote products
  5682. derived from this software without specific prior written permission.
  5683. THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  5684. INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  5685. FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
  5686. INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
  5687. INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  5688. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
  5689. OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  5690. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  5691. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  5692. EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  5693. */
  5694. let initializedModule = false;
  5695. async function initModule(wasmURI, { baseURI }) {
  5696. if (!initializedModule) {
  5697. let arrayBuffer, uri;
  5698. try {
  5699. try {
  5700. uri = new URL(wasmURI, baseURI);
  5701. } catch {
  5702. // ignored
  5703. }
  5704. const response = await fetch(uri);
  5705. arrayBuffer = await response.arrayBuffer();
  5706. } catch (error) {
  5707. if (wasmURI.startsWith("data:application/wasm;base64,")) {
  5708. arrayBuffer = arrayBufferFromDataURI(wasmURI);
  5709. } else {
  5710. throw error;
  5711. }
  5712. }
  5713. const wasmInstance = await WebAssembly.instantiate(arrayBuffer);
  5714. setWasmExports(wasmInstance.instance.exports);
  5715. initializedModule = true;
  5716. }
  5717. }
  5718. function resetWasmModule() {
  5719. initializedModule = false;
  5720. }
  5721. function arrayBufferFromDataURI(dataURI) {
  5722. const base64 = dataURI.split(",")[1];
  5723. const binary = atob(base64);
  5724. const len = binary.length;
  5725. const bytes = new Uint8Array(len);
  5726. for (let i = 0; i < len; ++i) {
  5727. bytes[i] = binary.charCodeAt(i);
  5728. }
  5729. return bytes.buffer;
  5730. }
  5731. /*
  5732. Copyright (c) 2025 Gildas Lormeau. All rights reserved.
  5733. Redistribution and use in source and binary forms, with or without
  5734. modification, are permitted provided that the following conditions are met:
  5735. 1. Redistributions of source code must retain the above copyright notice,
  5736. this list of conditions and the following disclaimer.
  5737. 2. Redistributions in binary form must reproduce the above copyright
  5738. notice, this list of conditions and the following disclaimer in
  5739. the documentation and/or other materials provided with the distribution.
  5740. 3. The names of the authors may not be used to endorse or promote products
  5741. derived from this software without specific prior written permission.
  5742. THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  5743. INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  5744. FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
  5745. INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
  5746. INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  5747. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
  5748. OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  5749. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  5750. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  5751. EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  5752. */
  5753. let modulePromise;
  5754. g(configure);
  5755. configureWorker({
  5756. initModule: config => {
  5757. if (!modulePromise) {
  5758. let { wasmURI } = config;
  5759. // deno-lint-ignore valid-typeof
  5760. if (typeof wasmURI == FUNCTION_TYPE) {
  5761. wasmURI = wasmURI();
  5762. }
  5763. modulePromise = initModule(wasmURI, config);
  5764. }
  5765. return modulePromise;
  5766. }
  5767. });
  5768. configure({
  5769. CompressionStreamZlib,
  5770. DecompressionStreamZlib
  5771. });
  5772. function terminateWorkersAndModule() {
  5773. modulePromise = null;
  5774. terminateWorkers();
  5775. resetWasmModule();
  5776. }
  5777. /*
  5778. Copyright (c) 2022 Gildas Lormeau. All rights reserved.
  5779. Redistribution and use in source and binary forms, with or without
  5780. modification, are permitted provided that the following conditions are met:
  5781. 1. Redistributions of source code must retain the above copyright notice,
  5782. this list of conditions and the following disclaimer.
  5783. 2. Redistributions in binary form must reproduce the above copyright
  5784. notice, this list of conditions and the following disclaimer in
  5785. the documentation and/or other materials provided with the distribution.
  5786. 3. The names of the authors may not be used to endorse or promote products
  5787. derived from this software without specific prior written permission.
  5788. THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  5789. INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  5790. FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
  5791. INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
  5792. INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  5793. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
  5794. OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  5795. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  5796. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  5797. EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  5798. */
  5799. class ZipEntry {
  5800. constructor(fs, name, params, parent) {
  5801. const zipEntry = this;
  5802. if (fs.root && parent && parent.getChildByName(name)) {
  5803. throw new Error("Entry filename already exists");
  5804. }
  5805. if (!params) {
  5806. params = {};
  5807. }
  5808. Object.assign(zipEntry, {
  5809. fs,
  5810. name,
  5811. data: params.data,
  5812. options: params.options,
  5813. id: fs.entries.length,
  5814. parent,
  5815. children: [],
  5816. uncompressedSize: params.uncompressedSize || 0,
  5817. passThrough: params.passThrough
  5818. });
  5819. fs.entries.push(zipEntry);
  5820. if (parent) {
  5821. zipEntry.parent.children.push(zipEntry);
  5822. }
  5823. }
  5824. moveTo(target) {
  5825. // deprecated
  5826. const zipEntry = this;
  5827. zipEntry.fs.move(zipEntry, target);
  5828. }
  5829. getFullname() {
  5830. return this.getRelativeName();
  5831. }
  5832. getRelativeName(ancestor = this.fs.root) {
  5833. const zipEntry = this;
  5834. let relativeName = zipEntry.name;
  5835. let entry = zipEntry.parent;
  5836. while (entry && entry != ancestor) {
  5837. relativeName = (entry.name ? entry.name + "/" : "") + relativeName;
  5838. entry = entry.parent;
  5839. }
  5840. return relativeName;
  5841. }
  5842. isDescendantOf(ancestor) {
  5843. let entry = this.parent;
  5844. while (entry && entry.id != ancestor.id) {
  5845. entry = entry.parent;
  5846. }
  5847. return Boolean(entry);
  5848. }
  5849. rename(name) {
  5850. const parent = this.parent;
  5851. if (parent && parent.getChildByName(name)) {
  5852. throw new Error("Entry filename already exists");
  5853. } else {
  5854. this.name = name;
  5855. }
  5856. }
  5857. }
  5858. class ZipFileEntry extends ZipEntry {
  5859. constructor(fs, name, params, parent) {
  5860. super(fs, name, params, parent);
  5861. const zipEntry = this;
  5862. zipEntry.Reader = params.Reader;
  5863. zipEntry.Writer = params.Writer;
  5864. if (params.getData) {
  5865. zipEntry.getData = params.getData;
  5866. }
  5867. }
  5868. clone() {
  5869. return new ZipFileEntry(this.fs, this.name, this);
  5870. }
  5871. async getData(writer, options = {}) {
  5872. const zipEntry = this;
  5873. if (!writer || (writer.constructor == zipEntry.Writer && zipEntry.data)) {
  5874. return zipEntry.data;
  5875. } else {
  5876. const reader = zipEntry.reader = new zipEntry.Reader(zipEntry.data, options);
  5877. const uncompressedSize = zipEntry.data ? zipEntry.data.uncompressedSize : reader.size;
  5878. await Promise.all([initStream(reader), initStream(writer, uncompressedSize)]);
  5879. const { readable } = reader;
  5880. zipEntry.uncompressedSize = reader.size;
  5881. await readable.pipeTo(writer.writable);
  5882. return writer.getData ? writer.getData() : writer.writable;
  5883. }
  5884. }
  5885. isPasswordProtected() {
  5886. return this.data.encrypted;
  5887. }
  5888. async checkPassword(password, options = {}) {
  5889. const zipEntry = this;
  5890. if (zipEntry.isPasswordProtected()) {
  5891. options.password = password;
  5892. options.checkPasswordOnly = true;
  5893. try {
  5894. await zipEntry.data.getData(null, options);
  5895. return true;
  5896. } catch (error) {
  5897. if (error.message == ERR_INVALID_PASSWORD) {
  5898. return false;
  5899. } else {
  5900. throw error;
  5901. }
  5902. }
  5903. } else {
  5904. return true;
  5905. }
  5906. }
  5907. getText(encoding, options) {
  5908. return this.getData(new TextWriter(encoding), options);
  5909. }
  5910. getBlob(mimeType, options) {
  5911. return this.getData(new BlobWriter(mimeType), options);
  5912. }
  5913. getData64URI(mimeType, options) {
  5914. return this.getData(new Data64URIWriter(mimeType), options);
  5915. }
  5916. getUint8Array(options) {
  5917. return this.getData(new Uint8ArrayWriter(), options);
  5918. }
  5919. getWritable(writable = new WritableStream(), options) {
  5920. return this.getData({ writable }, options);
  5921. }
  5922. getArrayBuffer(options) {
  5923. return this.data.arrayBuffer(options);
  5924. }
  5925. replaceBlob(blob) {
  5926. Object.assign(this, {
  5927. data: blob,
  5928. Reader: BlobReader,
  5929. Writer: BlobWriter,
  5930. reader: null
  5931. });
  5932. }
  5933. replaceText(text) {
  5934. Object.assign(this, {
  5935. data: text,
  5936. Reader: TextReader,
  5937. Writer: TextWriter,
  5938. reader: null
  5939. });
  5940. }
  5941. replaceData64URI(dataURI) {
  5942. Object.assign(this, {
  5943. data: dataURI,
  5944. Reader: Data64URIReader,
  5945. Writer: Data64URIWriter,
  5946. reader: null
  5947. });
  5948. }
  5949. replaceUint8Array(array) {
  5950. Object.assign(this, {
  5951. data: array,
  5952. Reader: Uint8ArrayReader,
  5953. Writer: Uint8ArrayWriter,
  5954. reader: null
  5955. });
  5956. }
  5957. replaceReadable(readable) {
  5958. Object.assign(this, {
  5959. data: null,
  5960. Reader: function () { return { readable }; },
  5961. Writer: null,
  5962. reader: null
  5963. });
  5964. }
  5965. }
  5966. class ZipDirectoryEntry extends ZipEntry {
  5967. constructor(fs, name, params, parent) {
  5968. super(fs, name, params, parent);
  5969. this.directory = true;
  5970. }
  5971. clone(deepClone) {
  5972. const zipEntry = this;
  5973. const clonedEntry = new ZipDirectoryEntry(zipEntry.fs, zipEntry.name);
  5974. if (deepClone) {
  5975. clonedEntry.children = zipEntry.children.map(child => {
  5976. const childClone = child.clone(deepClone);
  5977. childClone.parent = clonedEntry;
  5978. return childClone;
  5979. });
  5980. }
  5981. return clonedEntry;
  5982. }
  5983. addDirectory(name, options) {
  5984. return addChild(this, name, { options }, true);
  5985. }
  5986. addText(name, text, options = {}) {
  5987. return addChild(this, name, {
  5988. data: text,
  5989. Reader: TextReader,
  5990. Writer: TextWriter,
  5991. options,
  5992. uncompressedSize: text.length
  5993. });
  5994. }
  5995. addBlob(name, blob, options = {}) {
  5996. return addChild(this, name, {
  5997. data: blob,
  5998. Reader: BlobReader,
  5999. Writer: BlobWriter,
  6000. options,
  6001. uncompressedSize: blob.size
  6002. });
  6003. }
  6004. addData64URI(name, dataURI, options = {}) {
  6005. let dataEnd = dataURI.length;
  6006. while (dataURI.charAt(dataEnd - 1) == "=") {
  6007. dataEnd--;
  6008. }
  6009. const dataStart = dataURI.indexOf(",") + 1;
  6010. return addChild(this, name, {
  6011. data: dataURI,
  6012. Reader: Data64URIReader,
  6013. Writer: Data64URIWriter,
  6014. options,
  6015. uncompressedSize: Math.floor((dataEnd - dataStart) * 0.75)
  6016. });
  6017. }
  6018. addUint8Array(name, array, options = {}) {
  6019. return addChild(this, name, {
  6020. data: array,
  6021. Reader: Uint8ArrayReader,
  6022. Writer: Uint8ArrayWriter,
  6023. options,
  6024. uncompressedSize: array.length
  6025. });
  6026. }
  6027. addHttpContent(name, url, options = {}) {
  6028. return addChild(this, name, {
  6029. data: url,
  6030. Reader: class extends HttpReader {
  6031. constructor(url) {
  6032. super(url, options);
  6033. }
  6034. },
  6035. options
  6036. });
  6037. }
  6038. addReadable(name, readable, options = {}) {
  6039. return addChild(this, name, {
  6040. Reader: function () { return { readable }; },
  6041. options
  6042. });
  6043. }
  6044. addFileSystemEntry(fileSystemEntry, options = {}) {
  6045. return addFileSystemHandle(this, fileSystemEntry, options);
  6046. }
  6047. addFileSystemHandle(handle, options = {}) {
  6048. return addFileSystemHandle(this, handle, options);
  6049. }
  6050. addFile(file, options = {}) {
  6051. if (!options.lastModDate) {
  6052. options.lastModDate = new Date(file.lastModified);
  6053. }
  6054. return addChild(this, file.name, {
  6055. data: file,
  6056. Reader: function () {
  6057. const readable = file.stream();
  6058. const size = file.size;
  6059. return { readable, size };
  6060. },
  6061. options,
  6062. uncompressedSize: file.size
  6063. });
  6064. }
  6065. addData(name, params) {
  6066. return addChild(this, name, params);
  6067. }
  6068. importBlob(blob, options) {
  6069. return this.importZip(new BlobReader(blob), options);
  6070. }
  6071. importData64URI(dataURI, options) {
  6072. return this.importZip(new Data64URIReader(dataURI), options);
  6073. }
  6074. importUint8Array(array, options) {
  6075. return this.importZip(new Uint8ArrayReader(array), options);
  6076. }
  6077. importHttpContent(url, options) {
  6078. return this.importZip(new HttpReader(url, options), options);
  6079. }
  6080. importReadable(readable, options) {
  6081. return this.importZip({ readable }, options);
  6082. }
  6083. exportBlob(options = {}) {
  6084. return this.exportZip(new BlobWriter(options.mimeType || "application/zip"), options);
  6085. }
  6086. exportData64URI(options = {}) {
  6087. return this.exportZip(new Data64URIWriter(options.mimeType || "application/zip"), options);
  6088. }
  6089. exportUint8Array(options = {}) {
  6090. return this.exportZip(new Uint8ArrayWriter(), options);
  6091. }
  6092. async exportWritable(writable = new WritableStream(), options = {}) {
  6093. await this.exportZip({ writable }, options);
  6094. return writable;
  6095. }
  6096. async importZip(reader, options = {}) {
  6097. await initStream(reader);
  6098. const zipReader = new ZipReader(reader, options);
  6099. const importedEntries = [];
  6100. const entries = await zipReader.getEntries();
  6101. for (const entry of entries) {
  6102. let parent = this;
  6103. try {
  6104. const path = entry.filename.split("/");
  6105. const name = path.pop();
  6106. path.forEach((pathPart, pathIndex) => {
  6107. const previousParent = parent;
  6108. parent = parent.getChildByName(pathPart);
  6109. if (!parent) {
  6110. parent = new ZipDirectoryEntry(this.fs, pathPart, { data: pathIndex == path.length - 1 ? entry : null }, previousParent);
  6111. importedEntries.push(parent);
  6112. }
  6113. });
  6114. if (!entry.directory) {
  6115. importedEntries.push(addChild(parent, name, {
  6116. data: entry,
  6117. Reader: getZipBlobReader(Object.assign({}, options)),
  6118. uncompressedSize: entry.uncompressedSize,
  6119. passThrough: options.passThrough
  6120. }));
  6121. }
  6122. } catch (error) {
  6123. try {
  6124. error.cause = {
  6125. entry
  6126. };
  6127. } catch {
  6128. // ignored
  6129. }
  6130. throw error;
  6131. }
  6132. }
  6133. return importedEntries;
  6134. }
  6135. async exportZip(writer, options) {
  6136. const zipEntry = this;
  6137. if (options.bufferedWrite === UNDEFINED_VALUE) {
  6138. options.bufferedWrite = true;
  6139. }
  6140. await Promise.all([initReaders(zipEntry, options.readerOptions), initStream(writer)]);
  6141. const zipWriter = new ZipWriter(writer, options);
  6142. await exportZip(zipWriter, zipEntry, getTotalSize([zipEntry], "uncompressedSize"), options);
  6143. await zipWriter.close();
  6144. return writer.getData ? writer.getData() : writer.writable;
  6145. }
  6146. getChildByName(name) {
  6147. const children = this.children;
  6148. for (let childIndex = 0; childIndex < children.length; childIndex++) {
  6149. const child = children[childIndex];
  6150. if (child.name == name) {
  6151. return child;
  6152. }
  6153. }
  6154. }
  6155. isPasswordProtected() {
  6156. const children = this.children;
  6157. for (let childIndex = 0; childIndex < children.length; childIndex++) {
  6158. const child = children[childIndex];
  6159. if (child.isPasswordProtected()) {
  6160. return true;
  6161. }
  6162. }
  6163. return false;
  6164. }
  6165. async checkPassword(password, options = {}) {
  6166. const children = this.children;
  6167. const result = await Promise.all(children.map(child => child.checkPassword(password, options)));
  6168. return !result.includes(false);
  6169. }
  6170. }
  6171. class FS {
  6172. constructor() {
  6173. resetFS(this);
  6174. }
  6175. get children() {
  6176. return this.root.children;
  6177. }
  6178. remove(entry) {
  6179. detach(entry);
  6180. this.entries[entry.id] = null;
  6181. }
  6182. move(entry, destination) {
  6183. if (entry == this.root) {
  6184. throw new Error("Root directory cannot be moved");
  6185. } else {
  6186. if (destination.directory) {
  6187. if (!destination.isDescendantOf(entry)) {
  6188. if (entry != destination) {
  6189. if (destination.getChildByName(entry.name)) {
  6190. throw new Error("Entry filename already exists");
  6191. }
  6192. detach(entry);
  6193. entry.parent = destination;
  6194. destination.children.push(entry);
  6195. }
  6196. } else {
  6197. throw new Error("Entry is a ancestor of target entry");
  6198. }
  6199. } else {
  6200. throw new Error("Target entry is not a directory");
  6201. }
  6202. }
  6203. }
  6204. find(fullname) {
  6205. const path = fullname.split("/");
  6206. let node = this.root;
  6207. for (let index = 0; node && index < path.length; index++) {
  6208. node = node.getChildByName(path[index]);
  6209. }
  6210. return node;
  6211. }
  6212. getById(id) {
  6213. return this.entries[id];
  6214. }
  6215. getChildByName(name) {
  6216. return this.root.getChildByName(name);
  6217. }
  6218. addDirectory(name, options) {
  6219. return this.root.addDirectory(name, options);
  6220. }
  6221. addText(name, text, options) {
  6222. return this.root.addText(name, text, options);
  6223. }
  6224. addBlob(name, blob, options) {
  6225. return this.root.addBlob(name, blob, options);
  6226. }
  6227. addData64URI(name, dataURI, options) {
  6228. return this.root.addData64URI(name, dataURI, options);
  6229. }
  6230. addUint8Array(name, array, options) {
  6231. return this.root.addUint8Array(name, array, options);
  6232. }
  6233. addHttpContent(name, url, options) {
  6234. return this.root.addHttpContent(name, url, options);
  6235. }
  6236. addReadable(name, readable, options) {
  6237. return this.root.addReadable(name, readable, options);
  6238. }
  6239. addFileSystemEntry(fileSystemEntry, options) {
  6240. return this.root.addFileSystemEntry(fileSystemEntry, options);
  6241. }
  6242. addFileSystemHandle(handle, options) {
  6243. return this.root.addFileSystemHandle(handle, options);
  6244. }
  6245. addFile(file, options) {
  6246. return this.root.addFile(file, options);
  6247. }
  6248. addData(name, params) {
  6249. return this.root.addData(name, params);
  6250. }
  6251. importBlob(blob, options) {
  6252. resetFS(this);
  6253. return this.root.importBlob(blob, options);
  6254. }
  6255. importData64URI(dataURI, options) {
  6256. resetFS(this);
  6257. return this.root.importData64URI(dataURI, options);
  6258. }
  6259. importUint8Array(array, options) {
  6260. resetFS(this);
  6261. return this.root.importUint8Array(array, options);
  6262. }
  6263. importHttpContent(url, options) {
  6264. resetFS(this);
  6265. return this.root.importHttpContent(url, options);
  6266. }
  6267. importReadable(readable, options) {
  6268. resetFS(this);
  6269. return this.root.importReadable(readable, options);
  6270. }
  6271. importZip(reader, options) {
  6272. return this.root.importZip(reader, options);
  6273. }
  6274. exportBlob(options) {
  6275. return this.root.exportBlob(options);
  6276. }
  6277. exportData64URI(options) {
  6278. return this.root.exportData64URI(options);
  6279. }
  6280. exportUint8Array(options) {
  6281. return this.root.exportUint8Array(options);
  6282. }
  6283. exportWritable(writable, options) {
  6284. return this.root.exportWritable(writable, options);
  6285. }
  6286. isPasswordProtected() {
  6287. return this.root.isPasswordProtected();
  6288. }
  6289. checkPassword(password, options) {
  6290. return this.root.checkPassword(password, options);
  6291. }
  6292. }
  6293. const fs = { FS, ZipDirectoryEntry, ZipFileEntry };
  6294. function getTotalSize(entries, propertyName) {
  6295. let size = 0;
  6296. entries.forEach(process);
  6297. return size;
  6298. function process(entry) {
  6299. size += entry[propertyName];
  6300. if (entry.children) {
  6301. entry.children.forEach(process);
  6302. }
  6303. }
  6304. }
  6305. function getZipBlobReader(options) {
  6306. return class extends Reader {
  6307. constructor(entry, options = {}) {
  6308. super();
  6309. this.entry = entry;
  6310. this.options = options;
  6311. }
  6312. async init() {
  6313. const zipBlobReader = this;
  6314. zipBlobReader.size = zipBlobReader.entry.uncompressedSize;
  6315. const data = await zipBlobReader.entry.getData(new BlobWriter(), Object.assign({}, zipBlobReader.options, options));
  6316. zipBlobReader.data = data;
  6317. zipBlobReader.blobReader = new BlobReader(data);
  6318. super.init();
  6319. }
  6320. readUint8Array(index, length) {
  6321. return this.blobReader.readUint8Array(index, length);
  6322. }
  6323. };
  6324. }
  6325. async function initReaders(entry, options) {
  6326. if (entry.children.length) {
  6327. await Promise.all(entry.children.map(async child => {
  6328. if (child.directory) {
  6329. await initReaders(child, options);
  6330. } else {
  6331. const reader = child.reader = new child.Reader(child.data, options);
  6332. try {
  6333. await initStream(reader);
  6334. } catch (error) {
  6335. try {
  6336. error.entryId = child.id;
  6337. error.cause = {
  6338. entry: child
  6339. };
  6340. } catch {
  6341. // ignored
  6342. }
  6343. throw error;
  6344. }
  6345. child.uncompressedSize = reader.size;
  6346. }
  6347. }));
  6348. }
  6349. }
  6350. function detach(entry) {
  6351. if (entry.parent) {
  6352. const children = entry.parent.children;
  6353. children.forEach((child, index) => {
  6354. if (child.id == entry.id) {
  6355. children.splice(index, 1);
  6356. }
  6357. });
  6358. }
  6359. }
  6360. async function exportZip(zipWriter, entry, totalSize, options) {
  6361. const selectedEntry = entry;
  6362. const entryOffsets = new Map();
  6363. await process(zipWriter, entry);
  6364. async function process(zipWriter, entry) {
  6365. await exportChild();
  6366. async function exportChild() {
  6367. if (options.bufferedWrite) {
  6368. await Promise.allSettled(entry.children.map(processChild));
  6369. } else {
  6370. for (const child of entry.children) {
  6371. await processChild(child);
  6372. }
  6373. }
  6374. }
  6375. async function processChild(child) {
  6376. const name = options.relativePath ? child.getRelativeName(selectedEntry) : child.getFullname();
  6377. const childOptions = child.options || {};
  6378. let zipEntryOptions = {};
  6379. if (child.data instanceof Entry) {
  6380. const {
  6381. externalFileAttributes,
  6382. versionMadeBy,
  6383. comment,
  6384. lastModDate,
  6385. creationDate,
  6386. lastAccessDate,
  6387. uncompressedSize,
  6388. encrypted,
  6389. zipCrypto,
  6390. signature,
  6391. compressionMethod,
  6392. extraFieldAES
  6393. } = child.data;
  6394. zipEntryOptions = {
  6395. externalFileAttributes,
  6396. versionMadeBy,
  6397. comment,
  6398. lastModDate,
  6399. creationDate,
  6400. lastAccessDate
  6401. };
  6402. if (child.passThrough) {
  6403. let level, encryptionStrength;
  6404. if (compressionMethod === 0) {
  6405. level = 0;
  6406. }
  6407. if (extraFieldAES) {
  6408. encryptionStrength = extraFieldAES.strength;
  6409. }
  6410. zipEntryOptions = Object.assign(zipEntryOptions, {
  6411. passThrough: true,
  6412. encrypted,
  6413. zipCrypto,
  6414. signature,
  6415. uncompressedSize,
  6416. level,
  6417. encryptionStrength,
  6418. compressionMethod
  6419. });
  6420. }
  6421. }
  6422. await zipWriter.add(name, child.reader, Object.assign({}, options, zipEntryOptions, childOptions, {
  6423. directory: child.directory,
  6424. onprogress: async indexProgress => {
  6425. if (options.onprogress) {
  6426. entryOffsets.set(name, indexProgress);
  6427. try {
  6428. await options.onprogress(Array.from(entryOffsets.values()).reduce((previousValue, currentValue) => previousValue + currentValue), totalSize);
  6429. } catch {
  6430. // ignored
  6431. }
  6432. }
  6433. }
  6434. }));
  6435. await process(zipWriter, child);
  6436. }
  6437. }
  6438. }
  6439. function addFileSystemHandle(zipEntry, handle, options) {
  6440. return addFile(zipEntry, handle, []);
  6441. async function addFile(parentEntry, handle, addedEntries) {
  6442. if (handle) {
  6443. try {
  6444. if (handle.isFile || handle.isDirectory) {
  6445. handle = await transformToFileSystemhandle(handle);
  6446. }
  6447. if (handle.kind == "file") {
  6448. const file = await handle.getFile();
  6449. addedEntries.push(
  6450. parentEntry.addData(file.name, {
  6451. Reader: function () {
  6452. const readable = file.stream();
  6453. const size = file.size;
  6454. return { readable, size };
  6455. },
  6456. options: Object.assign({}, { lastModDate: new Date(file.lastModified) }, options),
  6457. uncompressedSize: file.size
  6458. })
  6459. );
  6460. } else if (handle.kind == "directory") {
  6461. const directoryEntry = parentEntry.addDirectory(handle.name);
  6462. addedEntries.push(directoryEntry);
  6463. for await (const childHandle of handle.values()) {
  6464. await addFile(directoryEntry, childHandle, addedEntries);
  6465. }
  6466. }
  6467. } catch (error) {
  6468. const message = error.message + (handle ? " (" + handle.name + ")" : "");
  6469. throw new Error(message);
  6470. }
  6471. }
  6472. return addedEntries;
  6473. }
  6474. }
  6475. async function transformToFileSystemhandle(entry) {
  6476. const handle = {
  6477. name: entry.name
  6478. };
  6479. if (entry.isFile) {
  6480. handle.kind = "file";
  6481. handle.getFile = () =>
  6482. new Promise((resolve, reject) => entry.file(resolve, reject));
  6483. }
  6484. if (entry.isDirectory) {
  6485. handle.kind = "directory";
  6486. const handles = await transformToFileSystemhandles(entry);
  6487. handle.values = () => handles;
  6488. }
  6489. return handle;
  6490. }
  6491. async function transformToFileSystemhandles(entry) {
  6492. const entries = [];
  6493. function readEntries(directoryReader, resolve, reject) {
  6494. directoryReader.readEntries(async (entriesPart) => {
  6495. if (!entriesPart.length) {
  6496. resolve(entries);
  6497. } else {
  6498. for (const entry of entriesPart) {
  6499. entries.push(await transformToFileSystemhandle(entry));
  6500. }
  6501. readEntries(directoryReader, resolve, reject);
  6502. }
  6503. }, reject);
  6504. }
  6505. await new Promise((resolve, reject) =>
  6506. readEntries(entry.createReader(), resolve, reject)
  6507. );
  6508. return {
  6509. [Symbol.iterator]() {
  6510. let entryIndex = 0;
  6511. return {
  6512. next() {
  6513. const result = {
  6514. value: entries[entryIndex],
  6515. done: entryIndex == entries.length
  6516. };
  6517. entryIndex++;
  6518. return result;
  6519. }
  6520. };
  6521. }
  6522. };
  6523. }
  6524. function resetFS(fs) {
  6525. fs.entries = [];
  6526. fs.root = new ZipDirectoryEntry(fs);
  6527. }
  6528. function addChild(parent, name, params, directory) {
  6529. if (parent.directory) {
  6530. return directory ? new ZipDirectoryEntry(parent.fs, name, params, parent) : new ZipFileEntry(parent.fs, name, params, parent);
  6531. } else {
  6532. throw new Error("Parent entry is not a directory");
  6533. }
  6534. }
  6535. /*
  6536. Copyright (c) 2022 Gildas Lormeau. All rights reserved.
  6537. Redistribution and use in source and binary forms, with or without
  6538. modification, are permitted provided that the following conditions are met:
  6539. 1. Redistributions of source code must retain the above copyright notice,
  6540. this list of conditions and the following disclaimer.
  6541. 2. Redistributions in binary form must reproduce the above copyright
  6542. notice, this list of conditions and the following disclaimer in
  6543. the documentation and/or other materials provided with the distribution.
  6544. 3. The names of the authors may not be used to endorse or promote products
  6545. derived from this software without specific prior written permission.
  6546. THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  6547. INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  6548. FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
  6549. INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
  6550. INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  6551. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
  6552. OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  6553. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  6554. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  6555. EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  6556. */
  6557. const table = {
  6558. "application": {
  6559. "andrew-inset": "ez",
  6560. "annodex": "anx",
  6561. "atom+xml": "atom",
  6562. "atomcat+xml": "atomcat",
  6563. "atomserv+xml": "atomsrv",
  6564. "bbolin": "lin",
  6565. "cu-seeme": "cu",
  6566. "davmount+xml": "davmount",
  6567. "dsptype": "tsp",
  6568. "ecmascript": [
  6569. "es",
  6570. "ecma"
  6571. ],
  6572. "futuresplash": "spl",
  6573. "hta": "hta",
  6574. "java-archive": "jar",
  6575. "java-serialized-object": "ser",
  6576. "java-vm": "class",
  6577. "m3g": "m3g",
  6578. "mac-binhex40": "hqx",
  6579. "mathematica": [
  6580. "nb",
  6581. "ma",
  6582. "mb"
  6583. ],
  6584. "msaccess": "mdb",
  6585. "msword": [
  6586. "doc",
  6587. "dot",
  6588. "wiz"
  6589. ],
  6590. "mxf": "mxf",
  6591. "oda": "oda",
  6592. "ogg": "ogx",
  6593. "pdf": "pdf",
  6594. "pgp-keys": "key",
  6595. "pgp-signature": [
  6596. "asc",
  6597. "sig"
  6598. ],
  6599. "pics-rules": "prf",
  6600. "postscript": [
  6601. "ps",
  6602. "ai",
  6603. "eps",
  6604. "epsi",
  6605. "epsf",
  6606. "eps2",
  6607. "eps3"
  6608. ],
  6609. "rar": "rar",
  6610. "rdf+xml": "rdf",
  6611. "rss+xml": "rss",
  6612. "rtf": "rtf",
  6613. "xhtml+xml": [
  6614. "xhtml",
  6615. "xht"
  6616. ],
  6617. "xml": [
  6618. "xml",
  6619. "xsl",
  6620. "xsd",
  6621. "xpdl"
  6622. ],
  6623. "xspf+xml": "xspf",
  6624. "zip": "zip",
  6625. "vnd.android.package-archive": "apk",
  6626. "vnd.cinderella": "cdy",
  6627. "vnd.google-earth.kml+xml": "kml",
  6628. "vnd.google-earth.kmz": "kmz",
  6629. "vnd.mozilla.xul+xml": "xul",
  6630. "vnd.ms-excel": [
  6631. "xls",
  6632. "xlb",
  6633. "xlt",
  6634. "xlm",
  6635. "xla",
  6636. "xlc",
  6637. "xlw"
  6638. ],
  6639. "vnd.ms-pki.seccat": "cat",
  6640. "vnd.ms-pki.stl": "stl",
  6641. "vnd.ms-powerpoint": [
  6642. "ppt",
  6643. "pps",
  6644. "pot",
  6645. "ppa",
  6646. "pwz"
  6647. ],
  6648. "vnd.oasis.opendocument.chart": "odc",
  6649. "vnd.oasis.opendocument.database": "odb",
  6650. "vnd.oasis.opendocument.formula": "odf",
  6651. "vnd.oasis.opendocument.graphics": "odg",
  6652. "vnd.oasis.opendocument.graphics-template": "otg",
  6653. "vnd.oasis.opendocument.image": "odi",
  6654. "vnd.oasis.opendocument.presentation": "odp",
  6655. "vnd.oasis.opendocument.presentation-template": "otp",
  6656. "vnd.oasis.opendocument.spreadsheet": "ods",
  6657. "vnd.oasis.opendocument.spreadsheet-template": "ots",
  6658. "vnd.oasis.opendocument.text": "odt",
  6659. "vnd.oasis.opendocument.text-master": [
  6660. "odm",
  6661. "otm"
  6662. ],
  6663. "vnd.oasis.opendocument.text-template": "ott",
  6664. "vnd.oasis.opendocument.text-web": "oth",
  6665. "vnd.openxmlformats-officedocument.spreadsheetml.sheet": "xlsx",
  6666. "vnd.openxmlformats-officedocument.spreadsheetml.template": "xltx",
  6667. "vnd.openxmlformats-officedocument.presentationml.presentation": "pptx",
  6668. "vnd.openxmlformats-officedocument.presentationml.slideshow": "ppsx",
  6669. "vnd.openxmlformats-officedocument.presentationml.template": "potx",
  6670. "vnd.openxmlformats-officedocument.wordprocessingml.document": "docx",
  6671. "vnd.openxmlformats-officedocument.wordprocessingml.template": "dotx",
  6672. "vnd.smaf": "mmf",
  6673. "vnd.stardivision.calc": "sdc",
  6674. "vnd.stardivision.chart": "sds",
  6675. "vnd.stardivision.draw": "sda",
  6676. "vnd.stardivision.impress": "sdd",
  6677. "vnd.stardivision.math": [
  6678. "sdf",
  6679. "smf"
  6680. ],
  6681. "vnd.stardivision.writer": [
  6682. "sdw",
  6683. "vor"
  6684. ],
  6685. "vnd.stardivision.writer-global": "sgl",
  6686. "vnd.sun.xml.calc": "sxc",
  6687. "vnd.sun.xml.calc.template": "stc",
  6688. "vnd.sun.xml.draw": "sxd",
  6689. "vnd.sun.xml.draw.template": "std",
  6690. "vnd.sun.xml.impress": "sxi",
  6691. "vnd.sun.xml.impress.template": "sti",
  6692. "vnd.sun.xml.math": "sxm",
  6693. "vnd.sun.xml.writer": "sxw",
  6694. "vnd.sun.xml.writer.global": "sxg",
  6695. "vnd.sun.xml.writer.template": "stw",
  6696. "vnd.symbian.install": [
  6697. "sis",
  6698. "sisx"
  6699. ],
  6700. "vnd.visio": [
  6701. "vsd",
  6702. "vst",
  6703. "vss",
  6704. "vsw",
  6705. "vsdx",
  6706. "vssx",
  6707. "vstx",
  6708. "vssm",
  6709. "vstm"
  6710. ],
  6711. "vnd.wap.wbxml": "wbxml",
  6712. "vnd.wap.wmlc": "wmlc",
  6713. "vnd.wap.wmlscriptc": "wmlsc",
  6714. "vnd.wordperfect": "wpd",
  6715. "vnd.wordperfect5.1": "wp5",
  6716. "x-123": "wk",
  6717. "x-7z-compressed": "7z",
  6718. "x-abiword": "abw",
  6719. "x-apple-diskimage": "dmg",
  6720. "x-bcpio": "bcpio",
  6721. "x-bittorrent": "torrent",
  6722. "x-cbr": [
  6723. "cbr",
  6724. "cba",
  6725. "cbt",
  6726. "cb7"
  6727. ],
  6728. "x-cbz": "cbz",
  6729. "x-cdf": [
  6730. "cdf",
  6731. "cda"
  6732. ],
  6733. "x-cdlink": "vcd",
  6734. "x-chess-pgn": "pgn",
  6735. "x-cpio": "cpio",
  6736. "x-csh": "csh",
  6737. "x-director": [
  6738. "dir",
  6739. "dxr",
  6740. "cst",
  6741. "cct",
  6742. "cxt",
  6743. "w3d",
  6744. "fgd",
  6745. "swa"
  6746. ],
  6747. "x-dms": "dms",
  6748. "x-doom": "wad",
  6749. "x-dvi": "dvi",
  6750. "x-httpd-eruby": "rhtml",
  6751. "x-font": "pcf.Z",
  6752. "x-freemind": "mm",
  6753. "x-gnumeric": "gnumeric",
  6754. "x-go-sgf": "sgf",
  6755. "x-graphing-calculator": "gcf",
  6756. "x-gtar": [
  6757. "gtar",
  6758. "taz"
  6759. ],
  6760. "x-hdf": "hdf",
  6761. "x-httpd-php": [
  6762. "phtml",
  6763. "pht",
  6764. "php"
  6765. ],
  6766. "x-httpd-php-source": "phps",
  6767. "x-httpd-php3": "php3",
  6768. "x-httpd-php3-preprocessed": "php3p",
  6769. "x-httpd-php4": "php4",
  6770. "x-httpd-php5": "php5",
  6771. "x-ica": "ica",
  6772. "x-info": "info",
  6773. "x-internet-signup": [
  6774. "ins",
  6775. "isp"
  6776. ],
  6777. "x-iphone": "iii",
  6778. "x-iso9660-image": "iso",
  6779. "x-java-jnlp-file": "jnlp",
  6780. "x-jmol": "jmz",
  6781. "x-killustrator": "kil",
  6782. "x-latex": "latex",
  6783. "x-lyx": "lyx",
  6784. "x-lzx": "lzx",
  6785. "x-maker": [
  6786. "frm",
  6787. "fb",
  6788. "fbdoc"
  6789. ],
  6790. "x-ms-wmd": "wmd",
  6791. "x-msdos-program": [
  6792. "com",
  6793. "exe",
  6794. "bat",
  6795. "dll"
  6796. ],
  6797. "x-netcdf": [
  6798. "nc"
  6799. ],
  6800. "x-ns-proxy-autoconfig": [
  6801. "pac",
  6802. "dat"
  6803. ],
  6804. "x-nwc": "nwc",
  6805. "x-object": "o",
  6806. "x-oz-application": "oza",
  6807. "x-pkcs7-certreqresp": "p7r",
  6808. "x-python-code": [
  6809. "pyc",
  6810. "pyo"
  6811. ],
  6812. "x-qgis": [
  6813. "qgs",
  6814. "shp",
  6815. "shx"
  6816. ],
  6817. "x-quicktimeplayer": "qtl",
  6818. "x-redhat-package-manager": [
  6819. "rpm",
  6820. "rpa"
  6821. ],
  6822. "x-ruby": "rb",
  6823. "x-sh": "sh",
  6824. "x-shar": "shar",
  6825. "x-shockwave-flash": [
  6826. "swf",
  6827. "swfl"
  6828. ],
  6829. "x-silverlight": "scr",
  6830. "x-stuffit": "sit",
  6831. "x-sv4cpio": "sv4cpio",
  6832. "x-sv4crc": "sv4crc",
  6833. "x-tar": "tar",
  6834. "x-tex-gf": "gf",
  6835. "x-tex-pk": "pk",
  6836. "x-texinfo": [
  6837. "texinfo",
  6838. "texi"
  6839. ],
  6840. "x-trash": [
  6841. "~",
  6842. "%",
  6843. "bak",
  6844. "old",
  6845. "sik"
  6846. ],
  6847. "x-ustar": "ustar",
  6848. "x-wais-source": "src",
  6849. "x-wingz": "wz",
  6850. "x-x509-ca-cert": [
  6851. "crt",
  6852. "der",
  6853. "cer"
  6854. ],
  6855. "x-xcf": "xcf",
  6856. "x-xfig": "fig",
  6857. "x-xpinstall": "xpi",
  6858. "applixware": "aw",
  6859. "atomsvc+xml": "atomsvc",
  6860. "ccxml+xml": "ccxml",
  6861. "cdmi-capability": "cdmia",
  6862. "cdmi-container": "cdmic",
  6863. "cdmi-domain": "cdmid",
  6864. "cdmi-object": "cdmio",
  6865. "cdmi-queue": "cdmiq",
  6866. "docbook+xml": "dbk",
  6867. "dssc+der": "dssc",
  6868. "dssc+xml": "xdssc",
  6869. "emma+xml": "emma",
  6870. "epub+zip": "epub",
  6871. "exi": "exi",
  6872. "font-tdpfr": "pfr",
  6873. "gml+xml": "gml",
  6874. "gpx+xml": "gpx",
  6875. "gxf": "gxf",
  6876. "hyperstudio": "stk",
  6877. "inkml+xml": [
  6878. "ink",
  6879. "inkml"
  6880. ],
  6881. "ipfix": "ipfix",
  6882. "jsonml+json": "jsonml",
  6883. "lost+xml": "lostxml",
  6884. "mads+xml": "mads",
  6885. "marc": "mrc",
  6886. "marcxml+xml": "mrcx",
  6887. "mathml+xml": [
  6888. "mathml",
  6889. "mml"
  6890. ],
  6891. "mbox": "mbox",
  6892. "mediaservercontrol+xml": "mscml",
  6893. "metalink+xml": "metalink",
  6894. "metalink4+xml": "meta4",
  6895. "mets+xml": "mets",
  6896. "mods+xml": "mods",
  6897. "mp21": [
  6898. "m21",
  6899. "mp21"
  6900. ],
  6901. "mp4": "mp4s",
  6902. "oebps-package+xml": "opf",
  6903. "omdoc+xml": "omdoc",
  6904. "onenote": [
  6905. "onetoc",
  6906. "onetoc2",
  6907. "onetmp",
  6908. "onepkg"
  6909. ],
  6910. "oxps": "oxps",
  6911. "patch-ops-error+xml": "xer",
  6912. "pgp-encrypted": "pgp",
  6913. "pkcs10": "p10",
  6914. "pkcs7-mime": [
  6915. "p7m",
  6916. "p7c"
  6917. ],
  6918. "pkcs7-signature": "p7s",
  6919. "pkcs8": "p8",
  6920. "pkix-attr-cert": "ac",
  6921. "pkix-crl": "crl",
  6922. "pkix-pkipath": "pkipath",
  6923. "pkixcmp": "pki",
  6924. "pls+xml": "pls",
  6925. "prs.cww": "cww",
  6926. "pskc+xml": "pskcxml",
  6927. "reginfo+xml": "rif",
  6928. "relax-ng-compact-syntax": "rnc",
  6929. "resource-lists+xml": "rl",
  6930. "resource-lists-diff+xml": "rld",
  6931. "rls-services+xml": "rs",
  6932. "rpki-ghostbusters": "gbr",
  6933. "rpki-manifest": "mft",
  6934. "rpki-roa": "roa",
  6935. "rsd+xml": "rsd",
  6936. "sbml+xml": "sbml",
  6937. "scvp-cv-request": "scq",
  6938. "scvp-cv-response": "scs",
  6939. "scvp-vp-request": "spq",
  6940. "scvp-vp-response": "spp",
  6941. "sdp": "sdp",
  6942. "set-payment-initiation": "setpay",
  6943. "set-registration-initiation": "setreg",
  6944. "shf+xml": "shf",
  6945. "sparql-query": "rq",
  6946. "sparql-results+xml": "srx",
  6947. "srgs": "gram",
  6948. "srgs+xml": "grxml",
  6949. "sru+xml": "sru",
  6950. "ssdl+xml": "ssdl",
  6951. "ssml+xml": "ssml",
  6952. "tei+xml": [
  6953. "tei",
  6954. "teicorpus"
  6955. ],
  6956. "thraud+xml": "tfi",
  6957. "timestamped-data": "tsd",
  6958. "vnd.3gpp.pic-bw-large": "plb",
  6959. "vnd.3gpp.pic-bw-small": "psb",
  6960. "vnd.3gpp.pic-bw-var": "pvb",
  6961. "vnd.3gpp2.tcap": "tcap",
  6962. "vnd.3m.post-it-notes": "pwn",
  6963. "vnd.accpac.simply.aso": "aso",
  6964. "vnd.accpac.simply.imp": "imp",
  6965. "vnd.acucobol": "acu",
  6966. "vnd.acucorp": [
  6967. "atc",
  6968. "acutc"
  6969. ],
  6970. "vnd.adobe.air-application-installer-package+zip": "air",
  6971. "vnd.adobe.formscentral.fcdt": "fcdt",
  6972. "vnd.adobe.fxp": [
  6973. "fxp",
  6974. "fxpl"
  6975. ],
  6976. "vnd.adobe.xdp+xml": "xdp",
  6977. "vnd.adobe.xfdf": "xfdf",
  6978. "vnd.ahead.space": "ahead",
  6979. "vnd.airzip.filesecure.azf": "azf",
  6980. "vnd.airzip.filesecure.azs": "azs",
  6981. "vnd.amazon.ebook": "azw",
  6982. "vnd.americandynamics.acc": "acc",
  6983. "vnd.amiga.ami": "ami",
  6984. "vnd.anser-web-certificate-issue-initiation": "cii",
  6985. "vnd.anser-web-funds-transfer-initiation": "fti",
  6986. "vnd.antix.game-component": "atx",
  6987. "vnd.apple.installer+xml": "mpkg",
  6988. "vnd.apple.mpegurl": "m3u8",
  6989. "vnd.aristanetworks.swi": "swi",
  6990. "vnd.astraea-software.iota": "iota",
  6991. "vnd.audiograph": "aep",
  6992. "vnd.blueice.multipass": "mpm",
  6993. "vnd.bmi": "bmi",
  6994. "vnd.businessobjects": "rep",
  6995. "vnd.chemdraw+xml": "cdxml",
  6996. "vnd.chipnuts.karaoke-mmd": "mmd",
  6997. "vnd.claymore": "cla",
  6998. "vnd.cloanto.rp9": "rp9",
  6999. "vnd.clonk.c4group": [
  7000. "c4g",
  7001. "c4d",
  7002. "c4f",
  7003. "c4p",
  7004. "c4u"
  7005. ],
  7006. "vnd.cluetrust.cartomobile-config": "c11amc",
  7007. "vnd.cluetrust.cartomobile-config-pkg": "c11amz",
  7008. "vnd.commonspace": "csp",
  7009. "vnd.contact.cmsg": "cdbcmsg",
  7010. "vnd.cosmocaller": "cmc",
  7011. "vnd.crick.clicker": "clkx",
  7012. "vnd.crick.clicker.keyboard": "clkk",
  7013. "vnd.crick.clicker.palette": "clkp",
  7014. "vnd.crick.clicker.template": "clkt",
  7015. "vnd.crick.clicker.wordbank": "clkw",
  7016. "vnd.criticaltools.wbs+xml": "wbs",
  7017. "vnd.ctc-posml": "pml",
  7018. "vnd.cups-ppd": "ppd",
  7019. "vnd.curl.car": "car",
  7020. "vnd.curl.pcurl": "pcurl",
  7021. "vnd.dart": "dart",
  7022. "vnd.data-vision.rdz": "rdz",
  7023. "vnd.dece.data": [
  7024. "uvf",
  7025. "uvvf",
  7026. "uvd",
  7027. "uvvd"
  7028. ],
  7029. "vnd.dece.ttml+xml": [
  7030. "uvt",
  7031. "uvvt"
  7032. ],
  7033. "vnd.dece.unspecified": [
  7034. "uvx",
  7035. "uvvx"
  7036. ],
  7037. "vnd.dece.zip": [
  7038. "uvz",
  7039. "uvvz"
  7040. ],
  7041. "vnd.denovo.fcselayout-link": "fe_launch",
  7042. "vnd.dna": "dna",
  7043. "vnd.dolby.mlp": "mlp",
  7044. "vnd.dpgraph": "dpg",
  7045. "vnd.dreamfactory": "dfac",
  7046. "vnd.ds-keypoint": "kpxx",
  7047. "vnd.dvb.ait": "ait",
  7048. "vnd.dvb.service": "svc",
  7049. "vnd.dynageo": "geo",
  7050. "vnd.ecowin.chart": "mag",
  7051. "vnd.enliven": "nml",
  7052. "vnd.epson.esf": "esf",
  7053. "vnd.epson.msf": "msf",
  7054. "vnd.epson.quickanime": "qam",
  7055. "vnd.epson.salt": "slt",
  7056. "vnd.epson.ssf": "ssf",
  7057. "vnd.eszigno3+xml": [
  7058. "es3",
  7059. "et3"
  7060. ],
  7061. "vnd.ezpix-album": "ez2",
  7062. "vnd.ezpix-package": "ez3",
  7063. "vnd.fdf": "fdf",
  7064. "vnd.fdsn.mseed": "mseed",
  7065. "vnd.fdsn.seed": [
  7066. "seed",
  7067. "dataless"
  7068. ],
  7069. "vnd.flographit": "gph",
  7070. "vnd.fluxtime.clip": "ftc",
  7071. "vnd.framemaker": [
  7072. "fm",
  7073. "frame",
  7074. "maker",
  7075. "book"
  7076. ],
  7077. "vnd.frogans.fnc": "fnc",
  7078. "vnd.frogans.ltf": "ltf",
  7079. "vnd.fsc.weblaunch": "fsc",
  7080. "vnd.fujitsu.oasys": "oas",
  7081. "vnd.fujitsu.oasys2": "oa2",
  7082. "vnd.fujitsu.oasys3": "oa3",
  7083. "vnd.fujitsu.oasysgp": "fg5",
  7084. "vnd.fujitsu.oasysprs": "bh2",
  7085. "vnd.fujixerox.ddd": "ddd",
  7086. "vnd.fujixerox.docuworks": "xdw",
  7087. "vnd.fujixerox.docuworks.binder": "xbd",
  7088. "vnd.fuzzysheet": "fzs",
  7089. "vnd.genomatix.tuxedo": "txd",
  7090. "vnd.geogebra.file": "ggb",
  7091. "vnd.geogebra.tool": "ggt",
  7092. "vnd.geometry-explorer": [
  7093. "gex",
  7094. "gre"
  7095. ],
  7096. "vnd.geonext": "gxt",
  7097. "vnd.geoplan": "g2w",
  7098. "vnd.geospace": "g3w",
  7099. "vnd.gmx": "gmx",
  7100. "vnd.grafeq": [
  7101. "gqf",
  7102. "gqs"
  7103. ],
  7104. "vnd.groove-account": "gac",
  7105. "vnd.groove-help": "ghf",
  7106. "vnd.groove-identity-message": "gim",
  7107. "vnd.groove-injector": "grv",
  7108. "vnd.groove-tool-message": "gtm",
  7109. "vnd.groove-tool-template": "tpl",
  7110. "vnd.groove-vcard": "vcg",
  7111. "vnd.hal+xml": "hal",
  7112. "vnd.handheld-entertainment+xml": "zmm",
  7113. "vnd.hbci": "hbci",
  7114. "vnd.hhe.lesson-player": "les",
  7115. "vnd.hp-hpgl": "hpgl",
  7116. "vnd.hp-hpid": "hpid",
  7117. "vnd.hp-hps": "hps",
  7118. "vnd.hp-jlyt": "jlt",
  7119. "vnd.hp-pcl": "pcl",
  7120. "vnd.hp-pclxl": "pclxl",
  7121. "vnd.hydrostatix.sof-data": "sfd-hdstx",
  7122. "vnd.ibm.minipay": "mpy",
  7123. "vnd.ibm.modcap": [
  7124. "afp",
  7125. "listafp",
  7126. "list3820"
  7127. ],
  7128. "vnd.ibm.rights-management": "irm",
  7129. "vnd.ibm.secure-container": "sc",
  7130. "vnd.iccprofile": [
  7131. "icc",
  7132. "icm"
  7133. ],
  7134. "vnd.igloader": "igl",
  7135. "vnd.immervision-ivp": "ivp",
  7136. "vnd.immervision-ivu": "ivu",
  7137. "vnd.insors.igm": "igm",
  7138. "vnd.intercon.formnet": [
  7139. "xpw",
  7140. "xpx"
  7141. ],
  7142. "vnd.intergeo": "i2g",
  7143. "vnd.intu.qbo": "qbo",
  7144. "vnd.intu.qfx": "qfx",
  7145. "vnd.ipunplugged.rcprofile": "rcprofile",
  7146. "vnd.irepository.package+xml": "irp",
  7147. "vnd.is-xpr": "xpr",
  7148. "vnd.isac.fcs": "fcs",
  7149. "vnd.jam": "jam",
  7150. "vnd.jcp.javame.midlet-rms": "rms",
  7151. "vnd.jisp": "jisp",
  7152. "vnd.joost.joda-archive": "joda",
  7153. "vnd.kahootz": [
  7154. "ktz",
  7155. "ktr"
  7156. ],
  7157. "vnd.kde.karbon": "karbon",
  7158. "vnd.kde.kchart": "chrt",
  7159. "vnd.kde.kformula": "kfo",
  7160. "vnd.kde.kivio": "flw",
  7161. "vnd.kde.kontour": "kon",
  7162. "vnd.kde.kpresenter": [
  7163. "kpr",
  7164. "kpt"
  7165. ],
  7166. "vnd.kde.kspread": "ksp",
  7167. "vnd.kde.kword": [
  7168. "kwd",
  7169. "kwt"
  7170. ],
  7171. "vnd.kenameaapp": "htke",
  7172. "vnd.kidspiration": "kia",
  7173. "vnd.kinar": [
  7174. "kne",
  7175. "knp"
  7176. ],
  7177. "vnd.koan": [
  7178. "skp",
  7179. "skd",
  7180. "skt",
  7181. "skm"
  7182. ],
  7183. "vnd.kodak-descriptor": "sse",
  7184. "vnd.las.las+xml": "lasxml",
  7185. "vnd.llamagraphics.life-balance.desktop": "lbd",
  7186. "vnd.llamagraphics.life-balance.exchange+xml": "lbe",
  7187. "vnd.lotus-1-2-3": "123",
  7188. "vnd.lotus-approach": "apr",
  7189. "vnd.lotus-freelance": "pre",
  7190. "vnd.lotus-notes": "nsf",
  7191. "vnd.lotus-organizer": "org",
  7192. "vnd.lotus-screencam": "scm",
  7193. "vnd.lotus-wordpro": "lwp",
  7194. "vnd.macports.portpkg": "portpkg",
  7195. "vnd.mcd": "mcd",
  7196. "vnd.medcalcdata": "mc1",
  7197. "vnd.mediastation.cdkey": "cdkey",
  7198. "vnd.mfer": "mwf",
  7199. "vnd.mfmp": "mfm",
  7200. "vnd.micrografx.flo": "flo",
  7201. "vnd.micrografx.igx": "igx",
  7202. "vnd.mif": "mif",
  7203. "vnd.mobius.daf": "daf",
  7204. "vnd.mobius.dis": "dis",
  7205. "vnd.mobius.mbk": "mbk",
  7206. "vnd.mobius.mqy": "mqy",
  7207. "vnd.mobius.msl": "msl",
  7208. "vnd.mobius.plc": "plc",
  7209. "vnd.mobius.txf": "txf",
  7210. "vnd.mophun.application": "mpn",
  7211. "vnd.mophun.certificate": "mpc",
  7212. "vnd.ms-artgalry": "cil",
  7213. "vnd.ms-cab-compressed": "cab",
  7214. "vnd.ms-excel.addin.macroenabled.12": "xlam",
  7215. "vnd.ms-excel.sheet.binary.macroenabled.12": "xlsb",
  7216. "vnd.ms-excel.sheet.macroenabled.12": "xlsm",
  7217. "vnd.ms-excel.template.macroenabled.12": "xltm",
  7218. "vnd.ms-fontobject": "eot",
  7219. "vnd.ms-htmlhelp": "chm",
  7220. "vnd.ms-ims": "ims",
  7221. "vnd.ms-lrm": "lrm",
  7222. "vnd.ms-officetheme": "thmx",
  7223. "vnd.ms-powerpoint.addin.macroenabled.12": "ppam",
  7224. "vnd.ms-powerpoint.presentation.macroenabled.12": "pptm",
  7225. "vnd.ms-powerpoint.slide.macroenabled.12": "sldm",
  7226. "vnd.ms-powerpoint.slideshow.macroenabled.12": "ppsm",
  7227. "vnd.ms-powerpoint.template.macroenabled.12": "potm",
  7228. "vnd.ms-project": [
  7229. "mpp",
  7230. "mpt"
  7231. ],
  7232. "vnd.ms-word.document.macroenabled.12": "docm",
  7233. "vnd.ms-word.template.macroenabled.12": "dotm",
  7234. "vnd.ms-works": [
  7235. "wps",
  7236. "wks",
  7237. "wcm",
  7238. "wdb"
  7239. ],
  7240. "vnd.ms-wpl": "wpl",
  7241. "vnd.ms-xpsdocument": "xps",
  7242. "vnd.mseq": "mseq",
  7243. "vnd.musician": "mus",
  7244. "vnd.muvee.style": "msty",
  7245. "vnd.mynfc": "taglet",
  7246. "vnd.neurolanguage.nlu": "nlu",
  7247. "vnd.nitf": [
  7248. "ntf",
  7249. "nitf"
  7250. ],
  7251. "vnd.noblenet-directory": "nnd",
  7252. "vnd.noblenet-sealer": "nns",
  7253. "vnd.noblenet-web": "nnw",
  7254. "vnd.nokia.n-gage.data": "ngdat",
  7255. "vnd.nokia.n-gage.symbian.install": "n-gage",
  7256. "vnd.nokia.radio-preset": "rpst",
  7257. "vnd.nokia.radio-presets": "rpss",
  7258. "vnd.novadigm.edm": "edm",
  7259. "vnd.novadigm.edx": "edx",
  7260. "vnd.novadigm.ext": "ext",
  7261. "vnd.oasis.opendocument.chart-template": "otc",
  7262. "vnd.oasis.opendocument.formula-template": "odft",
  7263. "vnd.oasis.opendocument.image-template": "oti",
  7264. "vnd.olpc-sugar": "xo",
  7265. "vnd.oma.dd2+xml": "dd2",
  7266. "vnd.openofficeorg.extension": "oxt",
  7267. "vnd.openxmlformats-officedocument.presentationml.slide": "sldx",
  7268. "vnd.osgeo.mapguide.package": "mgp",
  7269. "vnd.osgi.dp": "dp",
  7270. "vnd.osgi.subsystem": "esa",
  7271. "vnd.palm": [
  7272. "pdb",
  7273. "pqa",
  7274. "oprc"
  7275. ],
  7276. "vnd.pawaafile": "paw",
  7277. "vnd.pg.format": "str",
  7278. "vnd.pg.osasli": "ei6",
  7279. "vnd.picsel": "efif",
  7280. "vnd.pmi.widget": "wg",
  7281. "vnd.pocketlearn": "plf",
  7282. "vnd.powerbuilder6": "pbd",
  7283. "vnd.previewsystems.box": "box",
  7284. "vnd.proteus.magazine": "mgz",
  7285. "vnd.publishare-delta-tree": "qps",
  7286. "vnd.pvi.ptid1": "ptid",
  7287. "vnd.quark.quarkxpress": [
  7288. "qxd",
  7289. "qxt",
  7290. "qwd",
  7291. "qwt",
  7292. "qxl",
  7293. "qxb"
  7294. ],
  7295. "vnd.realvnc.bed": "bed",
  7296. "vnd.recordare.musicxml": "mxl",
  7297. "vnd.recordare.musicxml+xml": "musicxml",
  7298. "vnd.rig.cryptonote": "cryptonote",
  7299. "vnd.rn-realmedia": "rm",
  7300. "vnd.rn-realmedia-vbr": "rmvb",
  7301. "vnd.route66.link66+xml": "link66",
  7302. "vnd.sailingtracker.track": "st",
  7303. "vnd.seemail": "see",
  7304. "vnd.sema": "sema",
  7305. "vnd.semd": "semd",
  7306. "vnd.semf": "semf",
  7307. "vnd.shana.informed.formdata": "ifm",
  7308. "vnd.shana.informed.formtemplate": "itp",
  7309. "vnd.shana.informed.interchange": "iif",
  7310. "vnd.shana.informed.package": "ipk",
  7311. "vnd.simtech-mindmapper": [
  7312. "twd",
  7313. "twds"
  7314. ],
  7315. "vnd.smart.teacher": "teacher",
  7316. "vnd.solent.sdkm+xml": [
  7317. "sdkm",
  7318. "sdkd"
  7319. ],
  7320. "vnd.spotfire.dxp": "dxp",
  7321. "vnd.spotfire.sfs": "sfs",
  7322. "vnd.stepmania.package": "smzip",
  7323. "vnd.stepmania.stepchart": "sm",
  7324. "vnd.sus-calendar": [
  7325. "sus",
  7326. "susp"
  7327. ],
  7328. "vnd.svd": "svd",
  7329. "vnd.syncml+xml": "xsm",
  7330. "vnd.syncml.dm+wbxml": "bdm",
  7331. "vnd.syncml.dm+xml": "xdm",
  7332. "vnd.tao.intent-module-archive": "tao",
  7333. "vnd.tcpdump.pcap": [
  7334. "pcap",
  7335. "cap",
  7336. "dmp"
  7337. ],
  7338. "vnd.tmobile-livetv": "tmo",
  7339. "vnd.trid.tpt": "tpt",
  7340. "vnd.triscape.mxs": "mxs",
  7341. "vnd.trueapp": "tra",
  7342. "vnd.ufdl": [
  7343. "ufd",
  7344. "ufdl"
  7345. ],
  7346. "vnd.uiq.theme": "utz",
  7347. "vnd.umajin": "umj",
  7348. "vnd.unity": "unityweb",
  7349. "vnd.uoml+xml": "uoml",
  7350. "vnd.vcx": "vcx",
  7351. "vnd.visionary": "vis",
  7352. "vnd.vsf": "vsf",
  7353. "vnd.webturbo": "wtb",
  7354. "vnd.wolfram.player": "nbp",
  7355. "vnd.wqd": "wqd",
  7356. "vnd.wt.stf": "stf",
  7357. "vnd.xara": "xar",
  7358. "vnd.xfdl": "xfdl",
  7359. "vnd.yamaha.hv-dic": "hvd",
  7360. "vnd.yamaha.hv-script": "hvs",
  7361. "vnd.yamaha.hv-voice": "hvp",
  7362. "vnd.yamaha.openscoreformat": "osf",
  7363. "vnd.yamaha.openscoreformat.osfpvg+xml": "osfpvg",
  7364. "vnd.yamaha.smaf-audio": "saf",
  7365. "vnd.yamaha.smaf-phrase": "spf",
  7366. "vnd.yellowriver-custom-menu": "cmp",
  7367. "vnd.zul": [
  7368. "zir",
  7369. "zirz"
  7370. ],
  7371. "vnd.zzazz.deck+xml": "zaz",
  7372. "voicexml+xml": "vxml",
  7373. "widget": "wgt",
  7374. "winhlp": "hlp",
  7375. "wsdl+xml": "wsdl",
  7376. "wspolicy+xml": "wspolicy",
  7377. "x-ace-compressed": "ace",
  7378. "x-authorware-bin": [
  7379. "aab",
  7380. "x32",
  7381. "u32",
  7382. "vox"
  7383. ],
  7384. "x-authorware-map": "aam",
  7385. "x-authorware-seg": "aas",
  7386. "x-blorb": [
  7387. "blb",
  7388. "blorb"
  7389. ],
  7390. "x-bzip": "bz",
  7391. "x-bzip2": [
  7392. "bz2",
  7393. "boz"
  7394. ],
  7395. "x-cfs-compressed": "cfs",
  7396. "x-chat": "chat",
  7397. "x-conference": "nsc",
  7398. "x-dgc-compressed": "dgc",
  7399. "x-dtbncx+xml": "ncx",
  7400. "x-dtbook+xml": "dtb",
  7401. "x-dtbresource+xml": "res",
  7402. "x-eva": "eva",
  7403. "x-font-bdf": "bdf",
  7404. "x-font-ghostscript": "gsf",
  7405. "x-font-linux-psf": "psf",
  7406. "x-font-pcf": "pcf",
  7407. "x-font-snf": "snf",
  7408. "x-font-ttf": [
  7409. "ttf",
  7410. "ttc"
  7411. ],
  7412. "x-font-type1": [
  7413. "pfa",
  7414. "pfb",
  7415. "pfm",
  7416. "afm"
  7417. ],
  7418. "x-freearc": "arc",
  7419. "x-gca-compressed": "gca",
  7420. "x-glulx": "ulx",
  7421. "x-gramps-xml": "gramps",
  7422. "x-install-instructions": "install",
  7423. "x-lzh-compressed": [
  7424. "lzh",
  7425. "lha"
  7426. ],
  7427. "x-mie": "mie",
  7428. "x-mobipocket-ebook": [
  7429. "prc",
  7430. "mobi"
  7431. ],
  7432. "x-ms-application": "application",
  7433. "x-ms-shortcut": "lnk",
  7434. "x-ms-xbap": "xbap",
  7435. "x-msbinder": "obd",
  7436. "x-mscardfile": "crd",
  7437. "x-msclip": "clp",
  7438. "application/x-ms-installer": "msi",
  7439. "x-msmediaview": [
  7440. "mvb",
  7441. "m13",
  7442. "m14"
  7443. ],
  7444. "x-msmetafile": [
  7445. "wmf",
  7446. "wmz",
  7447. "emf",
  7448. "emz"
  7449. ],
  7450. "x-msmoney": "mny",
  7451. "x-mspublisher": "pub",
  7452. "x-msschedule": "scd",
  7453. "x-msterminal": "trm",
  7454. "x-mswrite": "wri",
  7455. "x-nzb": "nzb",
  7456. "x-pkcs12": [
  7457. "p12",
  7458. "pfx"
  7459. ],
  7460. "x-pkcs7-certificates": [
  7461. "p7b",
  7462. "spc"
  7463. ],
  7464. "x-research-info-systems": "ris",
  7465. "x-silverlight-app": "xap",
  7466. "x-sql": "sql",
  7467. "x-stuffitx": "sitx",
  7468. "x-subrip": "srt",
  7469. "x-t3vm-image": "t3",
  7470. "x-tex-tfm": "tfm",
  7471. "x-tgif": "obj",
  7472. "x-xliff+xml": "xlf",
  7473. "x-xz": "xz",
  7474. "x-zmachine": [
  7475. "z1",
  7476. "z2",
  7477. "z3",
  7478. "z4",
  7479. "z5",
  7480. "z6",
  7481. "z7",
  7482. "z8"
  7483. ],
  7484. "xaml+xml": "xaml",
  7485. "xcap-diff+xml": "xdf",
  7486. "xenc+xml": "xenc",
  7487. "xml-dtd": "dtd",
  7488. "xop+xml": "xop",
  7489. "xproc+xml": "xpl",
  7490. "xslt+xml": "xslt",
  7491. "xv+xml": [
  7492. "mxml",
  7493. "xhvml",
  7494. "xvml",
  7495. "xvm"
  7496. ],
  7497. "yang": "yang",
  7498. "yin+xml": "yin",
  7499. "envoy": "evy",
  7500. "fractals": "fif",
  7501. "internet-property-stream": "acx",
  7502. "olescript": "axs",
  7503. "vnd.ms-outlook": "msg",
  7504. "vnd.ms-pkicertstore": "sst",
  7505. "x-compress": "z",
  7506. "x-perfmon": [
  7507. "pma",
  7508. "pmc",
  7509. "pmr",
  7510. "pmw"
  7511. ],
  7512. "ynd.ms-pkipko": "pko",
  7513. "gzip": [
  7514. "gz",
  7515. "tgz"
  7516. ],
  7517. "smil+xml": [
  7518. "smi",
  7519. "smil"
  7520. ],
  7521. "vnd.debian.binary-package": [
  7522. "deb",
  7523. "udeb"
  7524. ],
  7525. "vnd.hzn-3d-crossword": "x3d",
  7526. "vnd.sqlite3": [
  7527. "db",
  7528. "sqlite",
  7529. "sqlite3",
  7530. "db-wal",
  7531. "sqlite-wal",
  7532. "db-shm",
  7533. "sqlite-shm"
  7534. ],
  7535. "vnd.wap.sic": "sic",
  7536. "vnd.wap.slc": "slc",
  7537. "x-krita": [
  7538. "kra",
  7539. "krz"
  7540. ],
  7541. "x-perl": [
  7542. "pm",
  7543. "pl"
  7544. ],
  7545. "yaml": [
  7546. "yaml",
  7547. "yml"
  7548. ]
  7549. },
  7550. "audio": {
  7551. "amr": "amr",
  7552. "amr-wb": "awb",
  7553. "annodex": "axa",
  7554. "basic": [
  7555. "au",
  7556. "snd"
  7557. ],
  7558. "flac": "flac",
  7559. "midi": [
  7560. "mid",
  7561. "midi",
  7562. "kar",
  7563. "rmi"
  7564. ],
  7565. "mpeg": [
  7566. "mpga",
  7567. "mpega",
  7568. "mp3",
  7569. "m4a",
  7570. "mp2a",
  7571. "m2a",
  7572. "m3a"
  7573. ],
  7574. "mpegurl": "m3u",
  7575. "ogg": [
  7576. "oga",
  7577. "ogg",
  7578. "spx"
  7579. ],
  7580. "prs.sid": "sid",
  7581. "x-aiff": "aifc",
  7582. "x-gsm": "gsm",
  7583. "x-ms-wma": "wma",
  7584. "x-ms-wax": "wax",
  7585. "x-pn-realaudio": "ram",
  7586. "x-realaudio": "ra",
  7587. "x-sd2": "sd2",
  7588. "adpcm": "adp",
  7589. "mp4": "mp4a",
  7590. "s3m": "s3m",
  7591. "silk": "sil",
  7592. "vnd.dece.audio": [
  7593. "uva",
  7594. "uvva"
  7595. ],
  7596. "vnd.digital-winds": "eol",
  7597. "vnd.dra": "dra",
  7598. "vnd.dts": "dts",
  7599. "vnd.dts.hd": "dtshd",
  7600. "vnd.lucent.voice": "lvp",
  7601. "vnd.ms-playready.media.pya": "pya",
  7602. "vnd.nuera.ecelp4800": "ecelp4800",
  7603. "vnd.nuera.ecelp7470": "ecelp7470",
  7604. "vnd.nuera.ecelp9600": "ecelp9600",
  7605. "vnd.rip": "rip",
  7606. "webm": "weba",
  7607. "x-caf": "caf",
  7608. "x-matroska": "mka",
  7609. "x-pn-realaudio-plugin": "rmp",
  7610. "xm": "xm",
  7611. "aac": "aac",
  7612. "aiff": [
  7613. "aiff",
  7614. "aif",
  7615. "aff"
  7616. ],
  7617. "opus": "opus",
  7618. "wav": "wav"
  7619. },
  7620. "chemical": {
  7621. "x-alchemy": "alc",
  7622. "x-cache": [
  7623. "cac",
  7624. "cache"
  7625. ],
  7626. "x-cache-csf": "csf",
  7627. "x-cactvs-binary": [
  7628. "cbin",
  7629. "cascii",
  7630. "ctab"
  7631. ],
  7632. "x-cdx": "cdx",
  7633. "x-chem3d": "c3d",
  7634. "x-cif": "cif",
  7635. "x-cmdf": "cmdf",
  7636. "x-cml": "cml",
  7637. "x-compass": "cpa",
  7638. "x-crossfire": "bsd",
  7639. "x-csml": [
  7640. "csml",
  7641. "csm"
  7642. ],
  7643. "x-ctx": "ctx",
  7644. "x-cxf": [
  7645. "cxf",
  7646. "cef"
  7647. ],
  7648. "x-embl-dl-nucleotide": [
  7649. "emb",
  7650. "embl"
  7651. ],
  7652. "x-gamess-input": [
  7653. "inp",
  7654. "gam",
  7655. "gamin"
  7656. ],
  7657. "x-gaussian-checkpoint": [
  7658. "fch",
  7659. "fchk"
  7660. ],
  7661. "x-gaussian-cube": "cub",
  7662. "x-gaussian-input": [
  7663. "gau",
  7664. "gjc",
  7665. "gjf"
  7666. ],
  7667. "x-gaussian-log": "gal",
  7668. "x-gcg8-sequence": "gcg",
  7669. "x-genbank": "gen",
  7670. "x-hin": "hin",
  7671. "x-isostar": [
  7672. "istr",
  7673. "ist"
  7674. ],
  7675. "x-jcamp-dx": [
  7676. "jdx",
  7677. "dx"
  7678. ],
  7679. "x-kinemage": "kin",
  7680. "x-macmolecule": "mcm",
  7681. "x-macromodel-input": "mmod",
  7682. "x-mdl-molfile": "mol",
  7683. "x-mdl-rdfile": "rd",
  7684. "x-mdl-rxnfile": "rxn",
  7685. "x-mdl-sdfile": "sd",
  7686. "x-mdl-tgf": "tgf",
  7687. "x-mmcif": "mcif",
  7688. "x-mol2": "mol2",
  7689. "x-molconn-Z": "b",
  7690. "x-mopac-graph": "gpt",
  7691. "x-mopac-input": [
  7692. "mop",
  7693. "mopcrt",
  7694. "zmt"
  7695. ],
  7696. "x-mopac-out": "moo",
  7697. "x-ncbi-asn1": "asn",
  7698. "x-ncbi-asn1-ascii": [
  7699. "prt",
  7700. "ent"
  7701. ],
  7702. "x-ncbi-asn1-binary": "val",
  7703. "x-rosdal": "ros",
  7704. "x-swissprot": "sw",
  7705. "x-vamas-iso14976": "vms",
  7706. "x-vmd": "vmd",
  7707. "x-xtel": "xtel",
  7708. "x-xyz": "xyz"
  7709. },
  7710. "font": {
  7711. "otf": "otf",
  7712. "woff": "woff",
  7713. "woff2": "woff2"
  7714. },
  7715. "image": {
  7716. "gif": "gif",
  7717. "ief": "ief",
  7718. "jpeg": [
  7719. "jpeg",
  7720. "jpg",
  7721. "jpe",
  7722. "jfif",
  7723. "jfif-tbnl",
  7724. "jif"
  7725. ],
  7726. "pcx": "pcx",
  7727. "png": "png",
  7728. "svg+xml": [
  7729. "svg",
  7730. "svgz"
  7731. ],
  7732. "tiff": [
  7733. "tiff",
  7734. "tif"
  7735. ],
  7736. "vnd.djvu": [
  7737. "djvu",
  7738. "djv"
  7739. ],
  7740. "vnd.wap.wbmp": "wbmp",
  7741. "x-canon-cr2": "cr2",
  7742. "x-canon-crw": "crw",
  7743. "x-cmu-raster": "ras",
  7744. "x-coreldraw": "cdr",
  7745. "x-coreldrawpattern": "pat",
  7746. "x-coreldrawtemplate": "cdt",
  7747. "x-corelphotopaint": "cpt",
  7748. "x-epson-erf": "erf",
  7749. "x-icon": "ico",
  7750. "x-jg": "art",
  7751. "x-jng": "jng",
  7752. "x-nikon-nef": "nef",
  7753. "x-olympus-orf": "orf",
  7754. "x-portable-anymap": "pnm",
  7755. "x-portable-bitmap": "pbm",
  7756. "x-portable-graymap": "pgm",
  7757. "x-portable-pixmap": "ppm",
  7758. "x-rgb": "rgb",
  7759. "x-xbitmap": "xbm",
  7760. "x-xpixmap": "xpm",
  7761. "x-xwindowdump": "xwd",
  7762. "bmp": "bmp",
  7763. "cgm": "cgm",
  7764. "g3fax": "g3",
  7765. "ktx": "ktx",
  7766. "prs.btif": "btif",
  7767. "sgi": "sgi",
  7768. "vnd.dece.graphic": [
  7769. "uvi",
  7770. "uvvi",
  7771. "uvg",
  7772. "uvvg"
  7773. ],
  7774. "vnd.dwg": "dwg",
  7775. "vnd.dxf": "dxf",
  7776. "vnd.fastbidsheet": "fbs",
  7777. "vnd.fpx": "fpx",
  7778. "vnd.fst": "fst",
  7779. "vnd.fujixerox.edmics-mmr": "mmr",
  7780. "vnd.fujixerox.edmics-rlc": "rlc",
  7781. "vnd.ms-modi": "mdi",
  7782. "vnd.ms-photo": "wdp",
  7783. "vnd.net-fpx": "npx",
  7784. "vnd.xiff": "xif",
  7785. "webp": "webp",
  7786. "x-3ds": "3ds",
  7787. "x-cmx": "cmx",
  7788. "x-freehand": [
  7789. "fh",
  7790. "fhc",
  7791. "fh4",
  7792. "fh5",
  7793. "fh7"
  7794. ],
  7795. "x-pict": [
  7796. "pic",
  7797. "pct"
  7798. ],
  7799. "x-tga": "tga",
  7800. "cis-cod": "cod",
  7801. "avif": "avifs",
  7802. "heic": [
  7803. "heif",
  7804. "heic"
  7805. ],
  7806. "pjpeg": [
  7807. "pjpg"
  7808. ],
  7809. "vnd.adobe.photoshop": "psd",
  7810. "x-adobe-dng": "dng",
  7811. "x-fuji-raf": "raf",
  7812. "x-icns": "icns",
  7813. "x-kodak-dcr": "dcr",
  7814. "x-kodak-k25": "k25",
  7815. "x-kodak-kdc": "kdc",
  7816. "x-minolta-mrw": "mrw",
  7817. "x-panasonic-raw": [
  7818. "raw",
  7819. "rw2",
  7820. "rwl"
  7821. ],
  7822. "x-pentax-pef": [
  7823. "pef",
  7824. "ptx"
  7825. ],
  7826. "x-sigma-x3f": "x3f",
  7827. "x-sony-arw": "arw",
  7828. "x-sony-sr2": "sr2",
  7829. "x-sony-srf": "srf"
  7830. },
  7831. "message": {
  7832. "rfc822": [
  7833. "eml",
  7834. "mime",
  7835. "mht",
  7836. "mhtml",
  7837. "nws"
  7838. ]
  7839. },
  7840. "model": {
  7841. "iges": [
  7842. "igs",
  7843. "iges"
  7844. ],
  7845. "mesh": [
  7846. "msh",
  7847. "mesh",
  7848. "silo"
  7849. ],
  7850. "vrml": [
  7851. "wrl",
  7852. "vrml"
  7853. ],
  7854. "x3d+vrml": [
  7855. "x3dv",
  7856. "x3dvz"
  7857. ],
  7858. "x3d+xml": "x3dz",
  7859. "x3d+binary": [
  7860. "x3db",
  7861. "x3dbz"
  7862. ],
  7863. "vnd.collada+xml": "dae",
  7864. "vnd.dwf": "dwf",
  7865. "vnd.gdl": "gdl",
  7866. "vnd.gtw": "gtw",
  7867. "vnd.mts": "mts",
  7868. "vnd.usdz+zip": "usdz",
  7869. "vnd.vtu": "vtu"
  7870. },
  7871. "text": {
  7872. "cache-manifest": [
  7873. "manifest",
  7874. "appcache"
  7875. ],
  7876. "calendar": [
  7877. "ics",
  7878. "icz",
  7879. "ifb"
  7880. ],
  7881. "css": "css",
  7882. "csv": "csv",
  7883. "h323": "323",
  7884. "html": [
  7885. "html",
  7886. "htm",
  7887. "shtml",
  7888. "stm"
  7889. ],
  7890. "iuls": "uls",
  7891. "plain": [
  7892. "txt",
  7893. "text",
  7894. "brf",
  7895. "conf",
  7896. "def",
  7897. "list",
  7898. "log",
  7899. "in",
  7900. "bas",
  7901. "diff",
  7902. "ksh"
  7903. ],
  7904. "richtext": "rtx",
  7905. "scriptlet": [
  7906. "sct",
  7907. "wsc"
  7908. ],
  7909. "texmacs": "tm",
  7910. "tab-separated-values": "tsv",
  7911. "vnd.sun.j2me.app-descriptor": "jad",
  7912. "vnd.wap.wml": "wml",
  7913. "vnd.wap.wmlscript": "wmls",
  7914. "x-bibtex": "bib",
  7915. "x-boo": "boo",
  7916. "x-c++hdr": [
  7917. "h++",
  7918. "hpp",
  7919. "hxx",
  7920. "hh"
  7921. ],
  7922. "x-c++src": [
  7923. "c++",
  7924. "cpp",
  7925. "cxx",
  7926. "cc"
  7927. ],
  7928. "x-component": "htc",
  7929. "x-dsrc": "d",
  7930. "x-diff": "patch",
  7931. "x-haskell": "hs",
  7932. "x-java": "java",
  7933. "x-literate-haskell": "lhs",
  7934. "x-moc": "moc",
  7935. "x-pascal": [
  7936. "p",
  7937. "pas",
  7938. "pp",
  7939. "inc"
  7940. ],
  7941. "x-pcs-gcd": "gcd",
  7942. "x-python": "py",
  7943. "x-scala": "scala",
  7944. "x-setext": "etx",
  7945. "x-tcl": [
  7946. "tcl",
  7947. "tk"
  7948. ],
  7949. "x-tex": [
  7950. "tex",
  7951. "ltx",
  7952. "sty",
  7953. "cls"
  7954. ],
  7955. "x-vcalendar": "vcs",
  7956. "x-vcard": "vcf",
  7957. "n3": "n3",
  7958. "prs.lines.tag": "dsc",
  7959. "sgml": [
  7960. "sgml",
  7961. "sgm"
  7962. ],
  7963. "troff": [
  7964. "t",
  7965. "tr",
  7966. "roff",
  7967. "man",
  7968. "me",
  7969. "ms"
  7970. ],
  7971. "turtle": "ttl",
  7972. "uri-list": [
  7973. "uri",
  7974. "uris",
  7975. "urls"
  7976. ],
  7977. "vcard": "vcard",
  7978. "vnd.curl": "curl",
  7979. "vnd.curl.dcurl": "dcurl",
  7980. "vnd.curl.scurl": "scurl",
  7981. "vnd.curl.mcurl": "mcurl",
  7982. "vnd.dvb.subtitle": "sub",
  7983. "vnd.fly": "fly",
  7984. "vnd.fmi.flexstor": "flx",
  7985. "vnd.graphviz": "gv",
  7986. "vnd.in3d.3dml": "3dml",
  7987. "vnd.in3d.spot": "spot",
  7988. "x-asm": [
  7989. "s",
  7990. "asm"
  7991. ],
  7992. "x-c": [
  7993. "c",
  7994. "h",
  7995. "dic"
  7996. ],
  7997. "x-fortran": [
  7998. "f",
  7999. "for",
  8000. "f77",
  8001. "f90"
  8002. ],
  8003. "x-opml": "opml",
  8004. "x-nfo": "nfo",
  8005. "x-sfv": "sfv",
  8006. "x-uuencode": "uu",
  8007. "webviewhtml": "htt",
  8008. "javascript": "js",
  8009. "json": "json",
  8010. "markdown": [
  8011. "md",
  8012. "markdown",
  8013. "mdown",
  8014. "markdn"
  8015. ],
  8016. "vnd.wap.si": "si",
  8017. "vnd.wap.sl": "sl"
  8018. },
  8019. "video": {
  8020. "avif": "avif",
  8021. "3gpp": "3gp",
  8022. "annodex": "axv",
  8023. "dl": "dl",
  8024. "dv": [
  8025. "dif",
  8026. "dv"
  8027. ],
  8028. "fli": "fli",
  8029. "gl": "gl",
  8030. "mpeg": [
  8031. "mpeg",
  8032. "mpg",
  8033. "mpe",
  8034. "m1v",
  8035. "m2v",
  8036. "mp2",
  8037. "mpa",
  8038. "mpv2"
  8039. ],
  8040. "mp4": [
  8041. "mp4",
  8042. "mp4v",
  8043. "mpg4"
  8044. ],
  8045. "quicktime": [
  8046. "qt",
  8047. "mov"
  8048. ],
  8049. "ogg": "ogv",
  8050. "vnd.mpegurl": [
  8051. "mxu",
  8052. "m4u"
  8053. ],
  8054. "x-flv": "flv",
  8055. "x-la-asf": [
  8056. "lsf",
  8057. "lsx"
  8058. ],
  8059. "x-mng": "mng",
  8060. "x-ms-asf": [
  8061. "asf",
  8062. "asx",
  8063. "asr"
  8064. ],
  8065. "x-ms-wm": "wm",
  8066. "x-ms-wmv": "wmv",
  8067. "x-ms-wmx": "wmx",
  8068. "x-ms-wvx": "wvx",
  8069. "x-msvideo": "avi",
  8070. "x-sgi-movie": "movie",
  8071. "x-matroska": [
  8072. "mpv",
  8073. "mkv",
  8074. "mk3d",
  8075. "mks"
  8076. ],
  8077. "3gpp2": "3g2",
  8078. "h261": "h261",
  8079. "h263": "h263",
  8080. "h264": "h264",
  8081. "jpeg": "jpgv",
  8082. "jpm": [
  8083. "jpm",
  8084. "jpgm"
  8085. ],
  8086. "mj2": [
  8087. "mj2",
  8088. "mjp2"
  8089. ],
  8090. "vnd.dece.hd": [
  8091. "uvh",
  8092. "uvvh"
  8093. ],
  8094. "vnd.dece.mobile": [
  8095. "uvm",
  8096. "uvvm"
  8097. ],
  8098. "vnd.dece.pd": [
  8099. "uvp",
  8100. "uvvp"
  8101. ],
  8102. "vnd.dece.sd": [
  8103. "uvs",
  8104. "uvvs"
  8105. ],
  8106. "vnd.dece.video": [
  8107. "uvv",
  8108. "uvvv"
  8109. ],
  8110. "vnd.dvb.file": "dvb",
  8111. "vnd.fvt": "fvt",
  8112. "vnd.ms-playready.media.pyv": "pyv",
  8113. "vnd.uvvu.mp4": [
  8114. "uvu",
  8115. "uvvu"
  8116. ],
  8117. "vnd.vivo": "viv",
  8118. "webm": "webm",
  8119. "x-f4v": "f4v",
  8120. "x-m4v": "m4v",
  8121. "x-ms-vob": "vob",
  8122. "x-smv": "smv",
  8123. "mp2t": "ts"
  8124. },
  8125. "x-conference": {
  8126. "x-cooltalk": "ice"
  8127. },
  8128. "x-world": {
  8129. "x-vrml": [
  8130. "vrm",
  8131. "flr",
  8132. "wrz",
  8133. "xaf",
  8134. "xof"
  8135. ]
  8136. }
  8137. };
  8138. const mimeTypes = (() => {
  8139. const mimeTypes = {};
  8140. for (const type of Object.keys(table)) {
  8141. for (const subtype of Object.keys(table[type])) {
  8142. const value = table[type][subtype];
  8143. if (typeof value == "string") {
  8144. mimeTypes[value] = type + "/" + subtype;
  8145. } else {
  8146. for (let indexMimeType = 0; indexMimeType < value.length; indexMimeType++) {
  8147. mimeTypes[value[indexMimeType]] = type + "/" + subtype;
  8148. }
  8149. }
  8150. }
  8151. }
  8152. return mimeTypes;
  8153. })();
  8154. function getMimeType(filename) {
  8155. return filename && mimeTypes[filename.split(".").pop().toLowerCase()] || getMimeType$1();
  8156. }
  8157. /*
  8158. Copyright (c) 2025 Gildas Lormeau. All rights reserved.
  8159. Redistribution and use in source and binary forms, with or without
  8160. modification, are permitted provided that the following conditions are met:
  8161. 1. Redistributions of source code must retain the above copyright notice,
  8162. this list of conditions and the following disclaimer.
  8163. 2. Redistributions in binary form must reproduce the above copyright
  8164. notice, this list of conditions and the following disclaimer in
  8165. the documentation and/or other materials provided with the distribution.
  8166. 3. The names of the authors may not be used to endorse or promote products
  8167. derived from this software without specific prior written permission.
  8168. THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  8169. INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  8170. FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
  8171. INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
  8172. INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  8173. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
  8174. OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  8175. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  8176. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  8177. EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  8178. */
  8179. t(configure);
  8180. exports.BlobReader = BlobReader;
  8181. exports.BlobWriter = BlobWriter;
  8182. exports.Data64URIReader = Data64URIReader;
  8183. exports.Data64URIWriter = Data64URIWriter;
  8184. exports.ERR_BAD_FORMAT = ERR_BAD_FORMAT;
  8185. exports.ERR_CENTRAL_DIRECTORY_NOT_FOUND = ERR_CENTRAL_DIRECTORY_NOT_FOUND;
  8186. exports.ERR_DUPLICATED_NAME = ERR_DUPLICATED_NAME;
  8187. exports.ERR_ENCRYPTED = ERR_ENCRYPTED;
  8188. exports.ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND = ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND;
  8189. exports.ERR_EOCDR_NOT_FOUND = ERR_EOCDR_NOT_FOUND;
  8190. exports.ERR_EXTRAFIELD_ZIP64_NOT_FOUND = ERR_EXTRAFIELD_ZIP64_NOT_FOUND;
  8191. exports.ERR_HTTP_RANGE = ERR_HTTP_RANGE;
  8192. exports.ERR_INVALID_COMMENT = ERR_INVALID_COMMENT;
  8193. exports.ERR_INVALID_ENCRYPTION_STRENGTH = ERR_INVALID_ENCRYPTION_STRENGTH;
  8194. exports.ERR_INVALID_ENTRY_COMMENT = ERR_INVALID_ENTRY_COMMENT;
  8195. exports.ERR_INVALID_ENTRY_NAME = ERR_INVALID_ENTRY_NAME;
  8196. exports.ERR_INVALID_EXTRAFIELD_DATA = ERR_INVALID_EXTRAFIELD_DATA;
  8197. exports.ERR_INVALID_EXTRAFIELD_TYPE = ERR_INVALID_EXTRAFIELD_TYPE;
  8198. exports.ERR_INVALID_PASSWORD = ERR_INVALID_PASSWORD;
  8199. exports.ERR_INVALID_SIGNATURE = ERR_INVALID_SIGNATURE;
  8200. exports.ERR_INVALID_UNCOMPRESSED_SIZE = ERR_INVALID_UNCOMPRESSED_SIZE;
  8201. exports.ERR_INVALID_VERSION = ERR_INVALID_VERSION;
  8202. exports.ERR_LOCAL_FILE_HEADER_NOT_FOUND = ERR_LOCAL_FILE_HEADER_NOT_FOUND;
  8203. exports.ERR_OVERLAPPING_ENTRY = ERR_OVERLAPPING_ENTRY;
  8204. exports.ERR_SPLIT_ZIP_FILE = ERR_SPLIT_ZIP_FILE;
  8205. exports.ERR_UNDEFINED_UNCOMPRESSED_SIZE = ERR_UNDEFINED_UNCOMPRESSED_SIZE;
  8206. exports.ERR_UNSUPPORTED_COMPRESSION = ERR_UNSUPPORTED_COMPRESSION;
  8207. exports.ERR_UNSUPPORTED_ENCRYPTION = ERR_UNSUPPORTED_ENCRYPTION;
  8208. exports.ERR_UNSUPPORTED_FORMAT = ERR_UNSUPPORTED_FORMAT;
  8209. exports.ERR_ZIP_NOT_EMPTY = ERR_ZIP_NOT_EMPTY;
  8210. exports.HttpRangeReader = HttpRangeReader;
  8211. exports.HttpReader = HttpReader;
  8212. exports.Reader = Reader;
  8213. exports.SplitDataReader = SplitDataReader;
  8214. exports.SplitDataWriter = SplitDataWriter;
  8215. exports.TextReader = TextReader;
  8216. exports.TextWriter = TextWriter;
  8217. exports.Uint8ArrayReader = Uint8ArrayReader;
  8218. exports.Uint8ArrayWriter = Uint8ArrayWriter;
  8219. exports.Writer = Writer;
  8220. exports.ZipReader = ZipReader;
  8221. exports.ZipReaderStream = ZipReaderStream;
  8222. exports.ZipWriter = ZipWriter;
  8223. exports.ZipWriterStream = ZipWriterStream;
  8224. exports.configure = configure;
  8225. exports.fs = fs;
  8226. exports.getMimeType = getMimeType;
  8227. exports.terminateWorkers = terminateWorkersAndModule;