12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075 |
- /*!
- Copyright (C) 2016-2018 Timofey Kachalov <[email protected]>
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
- require("source-map-support").install();
- module.exports =
- /******/ (function(modules) { // webpackBootstrap
- /******/ // The module cache
- /******/ var installedModules = {};
- /******/
- /******/ // The require function
- /******/ function __webpack_require__(moduleId) {
- /******/
- /******/ // Check if module is in cache
- /******/ if(installedModules[moduleId]) {
- /******/ return installedModules[moduleId].exports;
- /******/ }
- /******/ // Create a new module (and put it into the cache)
- /******/ var module = installedModules[moduleId] = {
- /******/ i: moduleId,
- /******/ l: false,
- /******/ exports: {}
- /******/ };
- /******/
- /******/ // Execute the module function
- /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
- /******/
- /******/ // Flag the module as loaded
- /******/ module.l = true;
- /******/
- /******/ // Return the exports of the module
- /******/ return module.exports;
- /******/ }
- /******/
- /******/
- /******/ // expose the modules object (__webpack_modules__)
- /******/ __webpack_require__.m = modules;
- /******/
- /******/ // expose the module cache
- /******/ __webpack_require__.c = installedModules;
- /******/
- /******/ // define getter function for harmony exports
- /******/ __webpack_require__.d = function(exports, name, getter) {
- /******/ if(!__webpack_require__.o(exports, name)) {
- /******/ Object.defineProperty(exports, name, {
- /******/ configurable: false,
- /******/ enumerable: true,
- /******/ get: getter
- /******/ });
- /******/ }
- /******/ };
- /******/
- /******/ // getDefaultExport function for compatibility with non-harmony modules
- /******/ __webpack_require__.n = function(module) {
- /******/ var getter = module && module.__esModule ?
- /******/ function getDefault() { return module['default']; } :
- /******/ function getModuleExports() { return module; };
- /******/ __webpack_require__.d(getter, 'a', getter);
- /******/ return getter;
- /******/ };
- /******/
- /******/ // Object.prototype.hasOwnProperty.call
- /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
- /******/
- /******/ // __webpack_public_path__
- /******/ __webpack_require__.p = "";
- /******/
- /******/ // Load entry module and return exports
- /******/ return __webpack_require__(__webpack_require__.s = 50);
- /******/ })
- /************************************************************************/
- /******/ ([
- /* 0 */
- /***/ (function(module, exports) {
- module.exports = require("inversify");
- /***/ }),
- /* 1 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- var ServiceIdentifiers;
- (function (ServiceIdentifiers) {
- ServiceIdentifiers["Factory__ICalleeDataExtractor"] = "Factory<ICalleeDataExtractor>";
- ServiceIdentifiers["Factory__IControlFlowCustomNode"] = "Factory<IControlFlowCustomNode>";
- ServiceIdentifiers["Factory__IControlFlowReplacer"] = "Factory<IControlFlowReplacer>";
- ServiceIdentifiers["Factory__ICustomNode"] = "Factory<ICustomNode>";
- ServiceIdentifiers["Factory__ICustomNodeGroup"] = "Factory<ICustomNodeGroup>";
- ServiceIdentifiers["Factory__IDeadCodeInjectionCustomNode"] = "Factory<IDeadCodeInjectionCustomNode>";
- ServiceIdentifiers["Factory__IIdentifierNamesGenerator"] = "Factory<IIdentifierNamesGenerator>";
- ServiceIdentifiers["Factory__IIdentifierObfuscatingReplacer"] = "Factory<IIdentifierObfuscatingReplacer>";
- ServiceIdentifiers["Factory__INodeGuard"] = "Factory<INodeGuard>";
- ServiceIdentifiers["Factory__INodeTransformer"] = "Factory<INodeTransformer[]>";
- ServiceIdentifiers["Factory__IObfuscationResult"] = "Factory<IObfuscationResult>";
- ServiceIdentifiers["Factory__IObfuscatingReplacer"] = "Factory<IObfuscatingReplacer>";
- ServiceIdentifiers["Factory__TControlFlowStorage"] = "Factory<TControlFlowStorage>";
- ServiceIdentifiers["IArrayUtils"] = "IArrayUtils";
- ServiceIdentifiers["ICalleeDataExtractor"] = "ICalleeDataExtractor";
- ServiceIdentifiers["ICryptUtils"] = "ICryptUtils";
- ServiceIdentifiers["ICustomNode"] = "ICustomNode";
- ServiceIdentifiers["ICustomNodeGroup"] = "ICustomNodeGroup";
- ServiceIdentifiers["IControlFlowReplacer"] = "IControlFlowReplacer";
- ServiceIdentifiers["IEscapeSequenceEncoder"] = "IEscapeSequenceEncoder";
- ServiceIdentifiers["IIdentifierNamesGenerator"] = "IIdentifierNamesGenerator";
- ServiceIdentifiers["IIdentifierObfuscatingReplacer"] = "IIdentifierObfuscatingReplacer";
- ServiceIdentifiers["IJavaScriptObfuscator"] = "IJavaScriptObfuscator";
- ServiceIdentifiers["ILogger"] = "ILogger";
- ServiceIdentifiers["INodeGuard"] = "INodeGuard";
- ServiceIdentifiers["INodeTransformer"] = "INodeTransformer";
- ServiceIdentifiers["IObfuscationEventEmitter"] = "IObfuscationEventEmitter";
- ServiceIdentifiers["IObfuscationResult"] = "IObfuscationResult";
- ServiceIdentifiers["IOptions"] = "IOptions";
- ServiceIdentifiers["IOptionsNormalizer"] = "IOptionsNormalizer";
- ServiceIdentifiers["IObfuscatingReplacer"] = "IObfuscatingReplacer";
- ServiceIdentifiers["IRandomGenerator"] = "IRandomGenerator";
- ServiceIdentifiers["ISourceCode"] = "ISourceCode";
- ServiceIdentifiers["ISourceMapCorrector"] = "ISourceMapCorrector";
- ServiceIdentifiers["IStackTraceAnalyzer"] = "IStackTraceAnalyzer";
- ServiceIdentifiers["ITransformersRunner"] = "ITransformersRunner";
- ServiceIdentifiers["Newable__ICustomNode"] = "Newable<ICustomNode>";
- ServiceIdentifiers["Newable__TControlFlowStorage"] = "Newable<TControlFlowStorage>";
- ServiceIdentifiers["TCustomNodeGroupStorage"] = "TCustomNodeGroupStorage";
- ServiceIdentifiers["TInputOptions"] = "TInputOptions";
- ServiceIdentifiers["TStringArrayStorage"] = "TStringArrayStorage";
- })(ServiceIdentifiers = exports.ServiceIdentifiers || (exports.ServiceIdentifiers = {}));
- /***/ }),
- /* 2 */
- /***/ (function(module, exports) {
- module.exports = require("tslib");
- /***/ }),
- /* 3 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- Object.defineProperty(exports, "__esModule", { value: true });
- var NodeType_1 = __webpack_require__(11);
- var NodeGuards = function () {
- function NodeGuards() {
- _classCallCheck(this, NodeGuards);
- }
- _createClass(NodeGuards, null, [{
- key: "isArrayPatternNode",
- value: function isArrayPatternNode(node) {
- return node.type === NodeType_1.NodeType.ArrayPattern;
- }
- }, {
- key: "isArrowFunctionExpressionNode",
- value: function isArrowFunctionExpressionNode(node) {
- return node.type === NodeType_1.NodeType.ArrowFunctionExpression;
- }
- }, {
- key: "isAssignmentPatternNode",
- value: function isAssignmentPatternNode(node) {
- return node.type === NodeType_1.NodeType.AssignmentPattern;
- }
- }, {
- key: "isAwaitExpressionNode",
- value: function isAwaitExpressionNode(node) {
- return node.type === NodeType_1.NodeType.AwaitExpression;
- }
- }, {
- key: "isBlockStatementNode",
- value: function isBlockStatementNode(node) {
- return node.type === NodeType_1.NodeType.BlockStatement;
- }
- }, {
- key: "isBreakStatementNode",
- value: function isBreakStatementNode(node) {
- return node.type === NodeType_1.NodeType.BreakStatement;
- }
- }, {
- key: "isCallExpressionNode",
- value: function isCallExpressionNode(node) {
- return node.type === NodeType_1.NodeType.CallExpression;
- }
- }, {
- key: "isCatchClauseNode",
- value: function isCatchClauseNode(node) {
- return node.type === NodeType_1.NodeType.CatchClause;
- }
- }, {
- key: "isClassDeclarationNode",
- value: function isClassDeclarationNode(node) {
- return node.type === NodeType_1.NodeType.ClassDeclaration;
- }
- }, {
- key: "isContinueStatementNode",
- value: function isContinueStatementNode(node) {
- return node.type === NodeType_1.NodeType.ContinueStatement;
- }
- }, {
- key: "isExpressionStatementNode",
- value: function isExpressionStatementNode(node) {
- return node.type === NodeType_1.NodeType.ExpressionStatement;
- }
- }, {
- key: "isFunctionDeclarationNode",
- value: function isFunctionDeclarationNode(node) {
- return node.type === NodeType_1.NodeType.FunctionDeclaration;
- }
- }, {
- key: "isFunctionExpressionNode",
- value: function isFunctionExpressionNode(node) {
- return node.type === NodeType_1.NodeType.FunctionExpression;
- }
- }, {
- key: "isIdentifierNode",
- value: function isIdentifierNode(node) {
- return node.type === NodeType_1.NodeType.Identifier;
- }
- }, {
- key: "isIfStatementNode",
- value: function isIfStatementNode(node) {
- return node.type === NodeType_1.NodeType.IfStatement;
- }
- }, {
- key: "isLabelIdentifierNode",
- value: function isLabelIdentifierNode(node, parentNode) {
- var parentNodeIsLabeledStatementNode = NodeGuards.isLabeledStatementNode(parentNode) && parentNode.label === node;
- var parentNodeIsContinueStatementNode = NodeGuards.isContinueStatementNode(parentNode) && parentNode.label === node;
- var parentNodeIsBreakStatementNode = NodeGuards.isBreakStatementNode(parentNode) && parentNode.label === node;
- return parentNodeIsLabeledStatementNode || parentNodeIsContinueStatementNode || parentNodeIsBreakStatementNode;
- }
- }, {
- key: "isLabeledStatementNode",
- value: function isLabeledStatementNode(node) {
- return node.type === NodeType_1.NodeType.LabeledStatement;
- }
- }, {
- key: "isLiteralNode",
- value: function isLiteralNode(node) {
- return node.type === NodeType_1.NodeType.Literal;
- }
- }, {
- key: "isMemberExpressionNode",
- value: function isMemberExpressionNode(node) {
- return node.type === NodeType_1.NodeType.MemberExpression;
- }
- }, {
- key: "isMethodDefinitionNode",
- value: function isMethodDefinitionNode(node) {
- return node.type === NodeType_1.NodeType.MethodDefinition;
- }
- }, {
- key: "isNode",
- value: function isNode(object) {
- return object && !object.type !== undefined;
- }
- }, {
- key: "isNodeHasBlockScope",
- value: function isNodeHasBlockScope(node, parentNode) {
- return NodeGuards.isProgramNode(node) || NodeGuards.isBlockStatementNode(node) && NodeGuards.nodesWithBlockScope.indexOf(parentNode.type) !== -1;
- }
- }, {
- key: "isNodeHasScope",
- value: function isNodeHasScope(node) {
- return NodeGuards.isProgramNode(node) || NodeGuards.isBlockStatementNode(node) || NodeGuards.isSwitchCaseNode(node);
- }
- }, {
- key: "isNodeWithComments",
- value: function isNodeWithComments(node) {
- return Boolean(node.leadingComments) || Boolean(node.trailingComments);
- }
- }, {
- key: "isObjectPatternNode",
- value: function isObjectPatternNode(node) {
- return node.type === NodeType_1.NodeType.ObjectPattern;
- }
- }, {
- key: "isObjectExpressionNode",
- value: function isObjectExpressionNode(node) {
- return node.type === NodeType_1.NodeType.ObjectExpression;
- }
- }, {
- key: "isProgramNode",
- value: function isProgramNode(node) {
- return node.type === NodeType_1.NodeType.Program;
- }
- }, {
- key: "isPropertyNode",
- value: function isPropertyNode(node) {
- return node.type === NodeType_1.NodeType.Property;
- }
- }, {
- key: "isReplaceableIdentifierNode",
- value: function isReplaceableIdentifierNode(node, parentNode) {
- if (!NodeGuards.isIdentifierNode(node)) {
- return false;
- }
- var parentNodeIsPropertyNode = NodeGuards.isPropertyNode(parentNode) && !parentNode.computed && parentNode.key === node;
- var parentNodeIsMemberExpressionNode = NodeGuards.isMemberExpressionNode(parentNode) && !parentNode.computed && parentNode.property === node;
- var parentNodeIsMethodDefinitionNode = NodeGuards.isMethodDefinitionNode(parentNode) && !parentNode.computed;
- var isLabelIdentifierNode = NodeGuards.isLabelIdentifierNode(node, parentNode);
- return !parentNodeIsPropertyNode && !parentNodeIsMemberExpressionNode && !parentNodeIsMethodDefinitionNode && !isLabelIdentifierNode;
- }
- }, {
- key: "isRestElementNode",
- value: function isRestElementNode(node) {
- return node.type === NodeType_1.NodeType.RestElement;
- }
- }, {
- key: "isReturnStatementNode",
- value: function isReturnStatementNode(node) {
- return node.type === NodeType_1.NodeType.ReturnStatement;
- }
- }, {
- key: "isSuperNode",
- value: function isSuperNode(node) {
- return node.type === NodeType_1.NodeType.Super;
- }
- }, {
- key: "isSwitchCaseNode",
- value: function isSwitchCaseNode(node) {
- return node.type === NodeType_1.NodeType.SwitchCase;
- }
- }, {
- key: "isTemplateLiteralNode",
- value: function isTemplateLiteralNode(node) {
- return node.type === NodeType_1.NodeType.TemplateLiteral;
- }
- }, {
- key: "isUnaryExpressionNode",
- value: function isUnaryExpressionNode(node) {
- return node.type === NodeType_1.NodeType.UnaryExpression;
- }
- }, {
- key: "isUseStrictOperator",
- value: function isUseStrictOperator(node) {
- return node.type === NodeType_1.NodeType.ExpressionStatement && node.directive === 'use strict';
- }
- }, {
- key: "isVariableDeclarationNode",
- value: function isVariableDeclarationNode(node) {
- return node.type === NodeType_1.NodeType.VariableDeclaration;
- }
- }, {
- key: "isVariableDeclaratorNode",
- value: function isVariableDeclaratorNode(node) {
- return node.type === NodeType_1.NodeType.VariableDeclarator;
- }
- }, {
- key: "isWhileStatementNode",
- value: function isWhileStatementNode(node) {
- return node.type === NodeType_1.NodeType.WhileStatement;
- }
- }]);
- return NodeGuards;
- }();
- NodeGuards.nodesWithBlockScope = [NodeType_1.NodeType.ArrowFunctionExpression, NodeType_1.NodeType.FunctionDeclaration, NodeType_1.NodeType.FunctionExpression, NodeType_1.NodeType.MethodDefinition];
- exports.NodeGuards = NodeGuards;
- /***/ }),
- /* 4 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- Object.defineProperty(exports, "__esModule", { value: true });
- var escodegen = __importStar(__webpack_require__(30));
- var esprima = __importStar(__webpack_require__(37));
- var estraverse = __importStar(__webpack_require__(10));
- var NodeGuards_1 = __webpack_require__(3);
- var NodeUtils = function () {
- function NodeUtils() {
- _classCallCheck(this, NodeUtils);
- }
- _createClass(NodeUtils, null, [{
- key: "addXVerbatimPropertyToLiterals",
- value: function addXVerbatimPropertyToLiterals(astTree) {
- estraverse.replace(astTree, {
- leave: function leave(node) {
- if (NodeGuards_1.NodeGuards.isLiteralNode(node)) {
- node['x-verbatim-property'] = {
- content: node.raw,
- precedence: escodegen.Precedence.Primary
- };
- }
- }
- });
- return astTree;
- }
- }, {
- key: "clone",
- value: function clone(astTree) {
- return NodeUtils.parentize(NodeUtils.cloneRecursive(astTree));
- }
- }, {
- key: "convertCodeToStructure",
- value: function convertCodeToStructure(code) {
- var structure = esprima.parseScript(code);
- structure = NodeUtils.addXVerbatimPropertyToLiterals(structure);
- structure = NodeUtils.parentize(structure);
- return structure.body;
- }
- }, {
- key: "convertStructureToCode",
- value: function convertStructureToCode(structure) {
- return structure.reduce(function (code, node) {
- return code + escodegen.generate(node, {
- sourceMapWithCode: true
- }).code;
- }, '');
- }
- }, {
- key: "getBlockScopesOfNode",
- value: function getBlockScopesOfNode(targetNode) {
- return NodeUtils.getBlockScopesOfNodeRecursive(targetNode);
- }
- }, {
- key: "getScopeOfNode",
- value: function getScopeOfNode(node) {
- var parentNode = node.parentNode;
- if (!parentNode) {
- throw new ReferenceError('`parentNode` property of given node is `undefined`');
- }
- if (!NodeGuards_1.NodeGuards.isNodeHasScope(parentNode)) {
- return NodeUtils.getScopeOfNode(parentNode);
- }
- return parentNode;
- }
- }, {
- key: "getUnaryExpressionArgumentNode",
- value: function getUnaryExpressionArgumentNode(unaryExpressionNode) {
- if (NodeGuards_1.NodeGuards.isUnaryExpressionNode(unaryExpressionNode.argument)) {
- return NodeUtils.getUnaryExpressionArgumentNode(unaryExpressionNode.argument);
- }
- return unaryExpressionNode.argument;
- }
- }, {
- key: "parentize",
- value: function parentize(astTree) {
- estraverse.replace(astTree, {
- enter: NodeUtils.parentizeNode
- });
- return astTree;
- }
- }, {
- key: "parentizeNode",
- value: function parentizeNode(node, parentNode) {
- node.parentNode = parentNode || node;
- node.obfuscatedNode = false;
- return node;
- }
- }, {
- key: "cloneRecursive",
- value: function cloneRecursive(node) {
- if (node === null) {
- return node;
- }
- var copy = {};
- for (var property in node) {
- if (!node.hasOwnProperty(property) || property === 'parentNode') {
- continue;
- }
- var value = node[property];
- var clonedValue = void 0;
- if (value === null || value instanceof RegExp) {
- clonedValue = value;
- } else if (Array.isArray(value)) {
- clonedValue = value.map(NodeUtils.cloneRecursive);
- } else if ((typeof value === "undefined" ? "undefined" : _typeof(value)) === 'object') {
- clonedValue = NodeUtils.cloneRecursive(value);
- } else {
- clonedValue = value;
- }
- copy[property] = clonedValue;
- }
- return copy;
- }
- }, {
- key: "getBlockScopesOfNodeRecursive",
- value: function getBlockScopesOfNodeRecursive(node) {
- var blockScopes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
- var depth = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
- var parentNode = node.parentNode;
- if (!parentNode) {
- throw new ReferenceError('`parentNode` property of given node is `undefined`');
- }
- if (NodeGuards_1.NodeGuards.isBlockStatementNode(node) && parentNode === node) {
- blockScopes.push(node);
- }
- if (NodeGuards_1.NodeGuards.isProgramNode(node) || depth && NodeGuards_1.NodeGuards.isNodeHasBlockScope(node, parentNode)) {
- blockScopes.push(node);
- }
- if (node !== parentNode) {
- return NodeUtils.getBlockScopesOfNodeRecursive(parentNode, blockScopes, ++depth);
- }
- return blockScopes;
- }
- }]);
- return NodeUtils;
- }();
- exports.NodeUtils = NodeUtils;
- /***/ }),
- /* 5 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- var defaultDescriptor = {
- configurable: true,
- enumerable: true
- };
- var initializedTargetMetadataKey = '_initialized';
- var initializablePropertiesSetMetadataKey = '_initializablePropertiesSet';
- var wrappedMethodsSetMetadataKey = '_wrappedMethodsSet';
- var constructorMethodName = 'constructor';
- function initializable() {
- var initializeMethodName = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'initialize';
- var decoratorName = Object.keys(this)[0];
- return function (target, propertyKey) {
- var initializeMethod = target[initializeMethodName];
- if (!initializeMethod || typeof initializeMethod !== 'function') {
- throw new Error("`" + initializeMethodName + "` method with initialization logic not " + ("found. `@" + decoratorName + "` decorator requires `" + initializeMethodName + "` method"));
- }
- initializeTargetMetadata(initializedTargetMetadataKey, false, target);
- initializeTargetMetadata(initializablePropertiesSetMetadataKey, new Set(), target);
- initializeTargetMetadata(wrappedMethodsSetMetadataKey, new Set(), target);
- wrapTargetMethodsInInitializedCheck(target, initializeMethodName);
- wrapInitializeMethodInInitializeCheck(target, initializeMethodName, propertyKey);
- return wrapInitializableProperty(target, propertyKey);
- };
- }
- exports.initializable = initializable;
- function initializeTargetMetadata(metadataKey, metadataValue, target) {
- var hasInitializedMetadata = Reflect.hasMetadata(metadataKey, target);
- if (!hasInitializedMetadata) {
- Reflect.defineMetadata(metadataKey, metadataValue, target);
- }
- }
- function wrapTargetMethodsInInitializedCheck(target, initializeMethodName) {
- var ownPropertyNames = Object.getOwnPropertyNames(target);
- var prohibitedPropertyNames = [initializeMethodName, constructorMethodName];
- ownPropertyNames.forEach(function (propertyName) {
- var initializablePropertiesSet = Reflect.getMetadata(initializablePropertiesSetMetadataKey, target);
- var wrappedMethodsSet = Reflect.getMetadata(wrappedMethodsSetMetadataKey, target);
- var isProhibitedPropertyName = prohibitedPropertyNames.indexOf(propertyName) !== -1 || initializablePropertiesSet.has(propertyName) || wrappedMethodsSet.has(propertyName);
- if (isProhibitedPropertyName) {
- return;
- }
- var targetProperty = target[propertyName];
- if (typeof targetProperty !== 'function') {
- return;
- }
- var methodDescriptor = Object.getOwnPropertyDescriptor(target, propertyName) || defaultDescriptor;
- var originalMethod = methodDescriptor.value;
- Object.defineProperty(target, propertyName, Object.assign({}, methodDescriptor, { value: function value() {
- if (!Reflect.getMetadata(initializedTargetMetadataKey, this)) {
- throw new Error("Class should be initialized with `" + initializeMethodName + "()` method");
- }
- return originalMethod.apply(this, arguments);
- } }));
- wrappedMethodsSet.add(propertyName);
- });
- }
- function wrapInitializeMethodInInitializeCheck(target, initializeMethodName, propertyKey) {
- var methodDescriptor = Object.getOwnPropertyDescriptor(target, initializeMethodName) || defaultDescriptor;
- var originalMethod = methodDescriptor.value;
- Object.defineProperty(target, initializeMethodName, Object.assign({}, methodDescriptor, { value: function value() {
- Reflect.defineMetadata(initializedTargetMetadataKey, true, this);
- var result = originalMethod.apply(this, arguments);
- if (this[propertyKey]) {}
- return result;
- } }));
- }
- function wrapInitializableProperty(target, propertyKey) {
- var initializablePropertiesSet = Reflect.getMetadata(initializablePropertiesSetMetadataKey, target);
- initializablePropertiesSet.add(propertyKey);
- var initializablePropertyMetadataKey = "_" + propertyKey;
- var propertyDescriptor = Object.getOwnPropertyDescriptor(target, initializablePropertyMetadataKey) || defaultDescriptor;
- Object.defineProperty(target, propertyKey, Object.assign({}, propertyDescriptor, { get: function get() {
- if (this[initializablePropertyMetadataKey] === undefined) {
- throw new Error("Property `" + propertyKey + "` is not initialized! Initialize it first!");
- }
- return this[initializablePropertyMetadataKey];
- }, set: function set(newVal) {
- this[initializablePropertyMetadataKey] = newVal;
- } }));
- return propertyDescriptor;
- }
- /***/ }),
- /* 6 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- var TransformationStage;
- (function (TransformationStage) {
- TransformationStage["Preparing"] = "Preparing";
- TransformationStage["DeadCodeInjection"] = "DeadCodeInjection";
- TransformationStage["ControlFlowFlattening"] = "ControlFlowFlattening";
- TransformationStage["Converting"] = "Converting";
- TransformationStage["Obfuscating"] = "Obfuscating";
- TransformationStage["Finalizing"] = "Finalizing";
- })(TransformationStage = exports.TransformationStage || (exports.TransformationStage = {}));
- /***/ }),
- /* 7 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var Initializable_1 = __webpack_require__(5);
- var AbstractNodeTransformer = function () {
- function AbstractNodeTransformer(randomGenerator, options) {
- _classCallCheck(this, AbstractNodeTransformer);
- this.randomGenerator = randomGenerator;
- this.options = options;
- }
- _createClass(AbstractNodeTransformer, [{
- key: "initialize",
- value: function initialize() {
- this.nodeIdentifier = this.randomGenerator.getRandomInteger(0, 10000);
- }
- }]);
- return AbstractNodeTransformer;
- }();
- tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", Number)], AbstractNodeTransformer.prototype, "nodeIdentifier", void 0);
- tslib_1.__decorate([inversify_1.postConstruct(), tslib_1.__metadata("design:type", Function), tslib_1.__metadata("design:paramtypes", []), tslib_1.__metadata("design:returntype", void 0)], AbstractNodeTransformer.prototype, "initialize", null);
- AbstractNodeTransformer = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Object, Object])], AbstractNodeTransformer);
- exports.AbstractNodeTransformer = AbstractNodeTransformer;
- /***/ }),
- /* 8 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var GlobalVariableTemplate1_1 = __webpack_require__(77);
- var GlobalVariableTemplate2_1 = __webpack_require__(78);
- var AbstractCustomNode = AbstractCustomNode_1 = function () {
- function AbstractCustomNode(identifierNamesGeneratorFactory, randomGenerator, options) {
- _classCallCheck(this, AbstractCustomNode);
- this.cachedNode = null;
- this.identifierNamesGenerator = identifierNamesGeneratorFactory(options);
- this.randomGenerator = randomGenerator;
- this.options = options;
- }
- _createClass(AbstractCustomNode, [{
- key: "getNode",
- value: function getNode() {
- if (!this.cachedNode) {
- this.cachedNode = this.getNodeStructure();
- }
- return this.cachedNode;
- }
- }, {
- key: "getGlobalVariableTemplate",
- value: function getGlobalVariableTemplate() {
- return this.randomGenerator.getRandomGenerator().pickone(AbstractCustomNode_1.globalVariableTemplateFunctions);
- }
- }]);
- return AbstractCustomNode;
- }();
- AbstractCustomNode.globalVariableTemplateFunctions = [GlobalVariableTemplate1_1.GlobalVariableTemplate1(), GlobalVariableTemplate2_1.GlobalVariableTemplate2()];
- AbstractCustomNode = AbstractCustomNode_1 = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IIdentifierNamesGenerator)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object, Object])], AbstractCustomNode);
- exports.AbstractCustomNode = AbstractCustomNode;
- var AbstractCustomNode_1;
- /***/ }),
- /* 9 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- Object.defineProperty(exports, "__esModule", { value: true });
- var escodegen = __importStar(__webpack_require__(30));
- var NodeType_1 = __webpack_require__(11);
- var Nodes = function () {
- function Nodes() {
- _classCallCheck(this, Nodes);
- }
- _createClass(Nodes, null, [{
- key: "getProgramNode",
- value: function getProgramNode() {
- var body = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
- return {
- type: NodeType_1.NodeType.Program,
- body: body,
- sourceType: 'script',
- obfuscatedNode: false
- };
- }
- }, {
- key: "getArrayExpressionNode",
- value: function getArrayExpressionNode() {
- var elements = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
- return {
- type: NodeType_1.NodeType.ArrayExpression,
- elements: elements
- };
- }
- }, {
- key: "getAssignmentExpressionNode",
- value: function getAssignmentExpressionNode(operator, left, right) {
- return {
- type: NodeType_1.NodeType.AssignmentExpression,
- operator: operator,
- left: left,
- right: right,
- obfuscatedNode: false
- };
- }
- }, {
- key: "getBinaryExpressionNode",
- value: function getBinaryExpressionNode(operator, left, right) {
- return {
- type: NodeType_1.NodeType.BinaryExpression,
- operator: operator,
- left: left,
- right: right,
- obfuscatedNode: false
- };
- }
- }, {
- key: "getBlockStatementNode",
- value: function getBlockStatementNode() {
- var body = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
- return {
- type: NodeType_1.NodeType.BlockStatement,
- body: body,
- obfuscatedNode: false
- };
- }
- }, {
- key: "getBreakStatement",
- value: function getBreakStatement(label) {
- var breakStatementNode = {
- type: NodeType_1.NodeType.BreakStatement,
- obfuscatedNode: false
- };
- if (label) {
- breakStatementNode.label = label;
- }
- return breakStatementNode;
- }
- }, {
- key: "getCallExpressionNode",
- value: function getCallExpressionNode(callee) {
- var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
- return {
- type: NodeType_1.NodeType.CallExpression,
- callee: callee,
- arguments: args,
- obfuscatedNode: false
- };
- }
- }, {
- key: "getContinueStatement",
- value: function getContinueStatement(label) {
- var continueStatementNode = {
- type: NodeType_1.NodeType.ContinueStatement,
- obfuscatedNode: false
- };
- if (label) {
- continueStatementNode.label = label;
- }
- return continueStatementNode;
- }
- }, {
- key: "getExpressionStatementNode",
- value: function getExpressionStatementNode(expression) {
- return {
- type: NodeType_1.NodeType.ExpressionStatement,
- expression: expression,
- obfuscatedNode: false
- };
- }
- }, {
- key: "getFunctionDeclarationNode",
- value: function getFunctionDeclarationNode(functionName, params, body) {
- return {
- type: NodeType_1.NodeType.FunctionDeclaration,
- id: Nodes.getIdentifierNode(functionName),
- params: params,
- body: body,
- generator: false,
- obfuscatedNode: false
- };
- }
- }, {
- key: "getFunctionExpressionNode",
- value: function getFunctionExpressionNode(params, body) {
- return {
- type: NodeType_1.NodeType.FunctionExpression,
- params: params,
- body: body,
- generator: false,
- obfuscatedNode: false
- };
- }
- }, {
- key: "getIfStatementNode",
- value: function getIfStatementNode(test, consequent, alternate) {
- return Object.assign({ type: NodeType_1.NodeType.IfStatement, test: test,
- consequent: consequent }, alternate && { alternate: alternate }, { obfuscatedNode: false });
- }
- }, {
- key: "getIdentifierNode",
- value: function getIdentifierNode(name) {
- return {
- type: NodeType_1.NodeType.Identifier,
- name: name,
- obfuscatedNode: false
- };
- }
- }, {
- key: "getLiteralNode",
- value: function getLiteralNode(value, raw) {
- raw = raw !== undefined ? raw : "'" + value + "'";
- return {
- type: NodeType_1.NodeType.Literal,
- value: value,
- raw: raw,
- 'x-verbatim-property': {
- content: raw,
- precedence: escodegen.Precedence.Primary
- },
- obfuscatedNode: false
- };
- }
- }, {
- key: "getLogicalExpressionNode",
- value: function getLogicalExpressionNode(operator, left, right) {
- return {
- type: NodeType_1.NodeType.LogicalExpression,
- operator: operator,
- left: left,
- right: right,
- obfuscatedNode: false
- };
- }
- }, {
- key: "getMemberExpressionNode",
- value: function getMemberExpressionNode(object, property) {
- var computed = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
- return {
- type: NodeType_1.NodeType.MemberExpression,
- computed: computed,
- object: object,
- property: property,
- obfuscatedNode: false
- };
- }
- }, {
- key: "getMethodDefinitionNode",
- value: function getMethodDefinitionNode(key, value, kind, computed) {
- return {
- type: NodeType_1.NodeType.MethodDefinition,
- key: key,
- value: value,
- kind: kind,
- computed: computed,
- static: false,
- obfuscatedNode: false
- };
- }
- }, {
- key: "getObjectExpressionNode",
- value: function getObjectExpressionNode(properties) {
- return {
- type: NodeType_1.NodeType.ObjectExpression,
- properties: properties,
- obfuscatedNode: false
- };
- }
- }, {
- key: "getPropertyNode",
- value: function getPropertyNode(key, value) {
- var computed = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
- return {
- type: NodeType_1.NodeType.Property,
- key: key,
- value: value,
- kind: 'init',
- method: false,
- shorthand: false,
- computed: computed,
- obfuscatedNode: false
- };
- }
- }, {
- key: "getUnaryExpressionNode",
- value: function getUnaryExpressionNode(operator, argument) {
- var prefix = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
- return {
- type: NodeType_1.NodeType.UnaryExpression,
- operator: operator,
- argument: argument,
- prefix: prefix,
- obfuscatedNode: false
- };
- }
- }, {
- key: "getReturnStatementNode",
- value: function getReturnStatementNode(argument) {
- return {
- type: NodeType_1.NodeType.ReturnStatement,
- argument: argument,
- obfuscatedNode: false
- };
- }
- }, {
- key: "getSwitchStatementNode",
- value: function getSwitchStatementNode(discriminant, cases) {
- return {
- type: NodeType_1.NodeType.SwitchStatement,
- discriminant: discriminant,
- cases: cases,
- obfuscatedNode: false
- };
- }
- }, {
- key: "getSwitchCaseNode",
- value: function getSwitchCaseNode(test, consequent) {
- return {
- type: NodeType_1.NodeType.SwitchCase,
- test: test,
- consequent: consequent,
- obfuscatedNode: false
- };
- }
- }, {
- key: "getUpdateExpressionNode",
- value: function getUpdateExpressionNode(operator, argumentExpr) {
- return {
- type: NodeType_1.NodeType.UpdateExpression,
- operator: operator,
- argument: argumentExpr,
- prefix: false,
- obfuscatedNode: false
- };
- }
- }, {
- key: "getVariableDeclarationNode",
- value: function getVariableDeclarationNode() {
- var declarations = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
- var kind = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'var';
- return {
- type: NodeType_1.NodeType.VariableDeclaration,
- declarations: declarations,
- kind: kind,
- obfuscatedNode: false
- };
- }
- }, {
- key: "getVariableDeclaratorNode",
- value: function getVariableDeclaratorNode(id, init) {
- return {
- type: NodeType_1.NodeType.VariableDeclarator,
- id: id,
- init: init,
- obfuscatedNode: false
- };
- }
- }, {
- key: "getWhileStatementNode",
- value: function getWhileStatementNode(test, body) {
- return {
- type: NodeType_1.NodeType.WhileStatement,
- test: test,
- body: body,
- obfuscatedNode: false
- };
- }
- }]);
- return Nodes;
- }();
- exports.Nodes = Nodes;
- /***/ }),
- /* 10 */
- /***/ (function(module, exports) {
- module.exports = require("estraverse");
- /***/ }),
- /* 11 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- var NodeType;
- (function (NodeType) {
- NodeType["ArrayExpression"] = "ArrayExpression";
- NodeType["ArrayPattern"] = "ArrayPattern";
- NodeType["ArrowFunctionExpression"] = "ArrowFunctionExpression";
- NodeType["AssignmentExpression"] = "AssignmentExpression";
- NodeType["AssignmentPattern"] = "AssignmentPattern";
- NodeType["AwaitExpression"] = "AwaitExpression";
- NodeType["BinaryExpression"] = "BinaryExpression";
- NodeType["BlockStatement"] = "BlockStatement";
- NodeType["BreakStatement"] = "BreakStatement";
- NodeType["CallExpression"] = "CallExpression";
- NodeType["CatchClause"] = "CatchClause";
- NodeType["ClassDeclaration"] = "ClassDeclaration";
- NodeType["ContinueStatement"] = "ContinueStatement";
- NodeType["ExpressionStatement"] = "ExpressionStatement";
- NodeType["FunctionDeclaration"] = "FunctionDeclaration";
- NodeType["FunctionExpression"] = "FunctionExpression";
- NodeType["Identifier"] = "Identifier";
- NodeType["IfStatement"] = "IfStatement";
- NodeType["LabeledStatement"] = "LabeledStatement";
- NodeType["Literal"] = "Literal";
- NodeType["LogicalExpression"] = "LogicalExpression";
- NodeType["MemberExpression"] = "MemberExpression";
- NodeType["MethodDefinition"] = "MethodDefinition";
- NodeType["ObjectExpression"] = "ObjectExpression";
- NodeType["ObjectPattern"] = "ObjectPattern";
- NodeType["Program"] = "Program";
- NodeType["Property"] = "Property";
- NodeType["RestElement"] = "RestElement";
- NodeType["ReturnStatement"] = "ReturnStatement";
- NodeType["Super"] = "Super";
- NodeType["SwitchCase"] = "SwitchCase";
- NodeType["SwitchStatement"] = "SwitchStatement";
- NodeType["TemplateLiteral"] = "TemplateLiteral";
- NodeType["TryStatement"] = "TryStatement";
- NodeType["UnaryExpression"] = "UnaryExpression";
- NodeType["UpdateExpression"] = "UpdateExpression";
- NodeType["VariableDeclaration"] = "VariableDeclaration";
- NodeType["VariableDeclarator"] = "VariableDeclarator";
- NodeType["WhileStatement"] = "WhileStatement";
- })(NodeType = exports.NodeType || (exports.NodeType = {}));
- /***/ }),
- /* 12 */
- /***/ (function(module, exports) {
- module.exports = require("string-template");
- /***/ }),
- /* 13 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- var ControlFlowCustomNode;
- (function (ControlFlowCustomNode) {
- ControlFlowCustomNode["BinaryExpressionFunctionNode"] = "BinaryExpressionFunctionNode";
- ControlFlowCustomNode["BlockStatementControlFlowFlatteningNode"] = "BlockStatementControlFlowFlatteningNode";
- ControlFlowCustomNode["CallExpressionControlFlowStorageCallNode"] = "CallExpressionControlFlowStorageCallNode";
- ControlFlowCustomNode["CallExpressionFunctionNode"] = "CallExpressionFunctionNode";
- ControlFlowCustomNode["ControlFlowStorageNode"] = "ControlFlowStorageNode";
- ControlFlowCustomNode["ExpressionWithOperatorControlFlowStorageCallNode"] = "ExpressionWithOperatorControlFlowStorageCallNode";
- ControlFlowCustomNode["LogicalExpressionFunctionNode"] = "LogicalExpressionFunctionNode";
- ControlFlowCustomNode["StringLiteralControlFlowStorageCallNode"] = "StringLiteralControlFlowStorageCallNode";
- ControlFlowCustomNode["StringLiteralNode"] = "StringLiteralNode";
- })(ControlFlowCustomNode = exports.ControlFlowCustomNode || (exports.ControlFlowCustomNode = {}));
- /***/ }),
- /* 14 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- var ObfuscationTarget;
- (function (ObfuscationTarget) {
- ObfuscationTarget["Browser"] = "browser";
- ObfuscationTarget["Extension"] = "extension";
- ObfuscationTarget["Node"] = "node";
- })(ObfuscationTarget = exports.ObfuscationTarget || (exports.ObfuscationTarget = {}));
- /***/ }),
- /* 15 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- Object.defineProperty(exports, "__esModule", { value: true });
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var AnalyzersModule_1 = __webpack_require__(52);
- var ControlFlowTransformersModule_1 = __webpack_require__(57);
- var ConvertingTransformersModule_1 = __webpack_require__(65);
- var CustomNodesModule_1 = __webpack_require__(70);
- var FinalizingTransformersModule_1 = __webpack_require__(117);
- var GeneratorsModule_1 = __webpack_require__(118);
- var NodeTransformersModule_1 = __webpack_require__(121);
- var ObfuscatingTransformersModule_1 = __webpack_require__(122);
- var OptionsModule_1 = __webpack_require__(135);
- var PreparingTransformersModule_1 = __webpack_require__(150);
- var StoragesModule_1 = __webpack_require__(159);
- var UtilsModule_1 = __webpack_require__(164);
- var JavaScriptObfuscator_1 = __webpack_require__(170);
- var Logger_1 = __webpack_require__(173);
- var ObfuscationEventEmitter_1 = __webpack_require__(174);
- var ObfuscationResult_1 = __webpack_require__(176);
- var SourceCode_1 = __webpack_require__(177);
- var SourceMapCorrector_1 = __webpack_require__(178);
- var TransformersRunner_1 = __webpack_require__(179);
- var InversifyContainerFacade = function () {
- function InversifyContainerFacade() {
- _classCallCheck(this, InversifyContainerFacade);
- this.container = new inversify_1.Container();
- }
- _createClass(InversifyContainerFacade, [{
- key: "get",
- value: function get(serviceIdentifier) {
- return this.container.get(serviceIdentifier);
- }
- }, {
- key: "getNamed",
- value: function getNamed(serviceIdentifier, named) {
- return this.container.getNamed(serviceIdentifier, named);
- }
- }, {
- key: "load",
- value: function load(sourceCode, options) {
- this.container.bind(ServiceIdentifiers_1.ServiceIdentifiers.ISourceCode).toDynamicValue(function () {
- return new SourceCode_1.SourceCode(sourceCode);
- }).inSingletonScope();
- this.container.bind(ServiceIdentifiers_1.ServiceIdentifiers.TInputOptions).toDynamicValue(function () {
- return options;
- }).inSingletonScope();
- this.container.bind(ServiceIdentifiers_1.ServiceIdentifiers.ILogger).to(Logger_1.Logger).inSingletonScope();
- this.container.bind(ServiceIdentifiers_1.ServiceIdentifiers.IJavaScriptObfuscator).to(JavaScriptObfuscator_1.JavaScriptObfuscator).inSingletonScope();
- this.container.bind(ServiceIdentifiers_1.ServiceIdentifiers.ITransformersRunner).to(TransformersRunner_1.TransformersRunner).inSingletonScope();
- this.container.bind(ServiceIdentifiers_1.ServiceIdentifiers.IObfuscationResult).to(ObfuscationResult_1.ObfuscationResult).inSingletonScope();
- this.container.bind(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IObfuscationResult).toFactory(function (context) {
- return function (obfuscatedCode, sourceMap) {
- var obfuscationResult = context.container.get(ServiceIdentifiers_1.ServiceIdentifiers.IObfuscationResult);
- obfuscationResult.initialize(obfuscatedCode, sourceMap);
- return obfuscationResult;
- };
- });
- this.container.bind(ServiceIdentifiers_1.ServiceIdentifiers.ISourceMapCorrector).to(SourceMapCorrector_1.SourceMapCorrector).inSingletonScope();
- this.container.bind(ServiceIdentifiers_1.ServiceIdentifiers.IObfuscationEventEmitter).to(ObfuscationEventEmitter_1.ObfuscationEventEmitter).inSingletonScope();
- this.container.load(AnalyzersModule_1.analyzersModule);
- this.container.load(ControlFlowTransformersModule_1.controlFlowTransformersModule);
- this.container.load(ConvertingTransformersModule_1.convertingTransformersModule);
- this.container.load(CustomNodesModule_1.customNodesModule);
- this.container.load(FinalizingTransformersModule_1.finalizingTransformersModule);
- this.container.load(GeneratorsModule_1.generatorsModule);
- this.container.load(NodeTransformersModule_1.nodeTransformersModule);
- this.container.load(ObfuscatingTransformersModule_1.obfuscatingTransformersModule);
- this.container.load(OptionsModule_1.optionsModule);
- this.container.load(PreparingTransformersModule_1.preparingTransformersModule);
- this.container.load(StoragesModule_1.storagesModule);
- this.container.load(UtilsModule_1.utilsModule);
- }
- }, {
- key: "unload",
- value: function unload() {
- this.container.unbindAll();
- }
- }], [{
- key: "getFactory",
- value: function getFactory(serviceIdentifier) {
- return function (context) {
- return function (bindingName) {
- return context.container.getNamed(serviceIdentifier, bindingName);
- };
- };
- }
- }, {
- key: "getCacheFactory",
- value: function getCacheFactory(serviceIdentifier) {
- return function (context) {
- var cache = new Map();
- return function (bindingName) {
- if (cache.has(bindingName)) {
- return cache.get(bindingName);
- }
- var object = context.container.getNamed(serviceIdentifier, bindingName);
- cache.set(bindingName, object);
- return object;
- };
- };
- }
- }, {
- key: "getConstructorFactory",
- value: function getConstructorFactory(serviceIdentifier) {
- for (var _len = arguments.length, dependencies = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
- dependencies[_key - 1] = arguments[_key];
- }
- return function (context) {
- var cache = new Map();
- var cachedDependencies = [];
- return function (bindingName) {
- dependencies.forEach(function (dependency, index) {
- if (!cachedDependencies[index]) {
- cachedDependencies[index] = context.container.get(dependency);
- }
- });
- if (cache.has(bindingName)) {
- return new (Function.prototype.bind.apply(cache.get(bindingName), [null].concat(cachedDependencies)))();
- }
- var constructor = context.container.getNamed(serviceIdentifier, bindingName);
- cache.set(bindingName, constructor);
- return new (Function.prototype.bind.apply(constructor, [null].concat(cachedDependencies)))();
- };
- };
- }
- }]);
- return InversifyContainerFacade;
- }();
- exports.InversifyContainerFacade = InversifyContainerFacade;
- /***/ }),
- /* 16 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- Object.defineProperty(exports, "__esModule", { value: true });
- var NodeGuards_1 = __webpack_require__(3);
- var NodeAppender = function () {
- function NodeAppender() {
- _classCallCheck(this, NodeAppender);
- }
- _createClass(NodeAppender, null, [{
- key: "appendNode",
- value: function appendNode(scopeNode, scopeStatements) {
- scopeStatements = NodeAppender.parentizeScopeStatementsBeforeAppend(scopeNode, scopeStatements);
- NodeAppender.setScopeNodeStatements(scopeNode, [].concat(_toConsumableArray(NodeAppender.getScopeNodeStatements(scopeNode)), _toConsumableArray(scopeStatements)));
- }
- }, {
- key: "appendNodeToOptimalBlockScope",
- value: function appendNodeToOptimalBlockScope(blockScopeStackTraceData, blockScopeNode, nodeBodyStatements) {
- var index = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
- var targetBlockScope = void 0;
- if (!blockScopeStackTraceData.length) {
- targetBlockScope = blockScopeNode;
- } else {
- targetBlockScope = NodeAppender.getOptimalBlockScope(blockScopeStackTraceData, index);
- }
- NodeAppender.prependNode(targetBlockScope, nodeBodyStatements);
- }
- }, {
- key: "getOptimalBlockScope",
- value: function getOptimalBlockScope(blockScopeTraceData, index) {
- var deep = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : Infinity;
- var firstCall = blockScopeTraceData[index];
- if (deep <= 0) {
- throw new Error("Invalid `deep` argument value. Value should be bigger then 0.");
- }
- if (deep > 1 && firstCall.stackTrace.length) {
- return NodeAppender.getOptimalBlockScope(firstCall.stackTrace, 0, --deep);
- } else {
- return firstCall.callee;
- }
- }
- }, {
- key: "insertNodeAfter",
- value: function insertNodeAfter(scopeNode, scopeStatements, targetStatement) {
- var indexInScopeStatement = NodeAppender.getScopeNodeStatements(scopeNode).indexOf(targetStatement);
- NodeAppender.insertNodeAtIndex(scopeNode, scopeStatements, indexInScopeStatement + 1);
- }
- }, {
- key: "insertNodeAtIndex",
- value: function insertNodeAtIndex(scopeNode, scopeStatements, index) {
- scopeStatements = NodeAppender.parentizeScopeStatementsBeforeAppend(scopeNode, scopeStatements);
- NodeAppender.setScopeNodeStatements(scopeNode, [].concat(_toConsumableArray(NodeAppender.getScopeNodeStatements(scopeNode).slice(0, index)), _toConsumableArray(scopeStatements), _toConsumableArray(NodeAppender.getScopeNodeStatements(scopeNode).slice(index))));
- }
- }, {
- key: "prependNode",
- value: function prependNode(scopeNode, scopeStatements) {
- scopeStatements = NodeAppender.parentizeScopeStatementsBeforeAppend(scopeNode, scopeStatements);
- NodeAppender.setScopeNodeStatements(scopeNode, [].concat(_toConsumableArray(scopeStatements), _toConsumableArray(NodeAppender.getScopeNodeStatements(scopeNode))));
- }
- }, {
- key: "getScopeNodeStatements",
- value: function getScopeNodeStatements(scopeNode) {
- if (NodeGuards_1.NodeGuards.isSwitchCaseNode(scopeNode)) {
- return scopeNode.consequent;
- }
- return scopeNode.body;
- }
- }, {
- key: "parentizeScopeStatementsBeforeAppend",
- value: function parentizeScopeStatementsBeforeAppend(scopeNode, scopeStatements) {
- scopeStatements.forEach(function (statement) {
- statement.parentNode = scopeNode;
- });
- return scopeStatements;
- }
- }, {
- key: "setScopeNodeStatements",
- value: function setScopeNodeStatements(scopeNode, statements) {
- if (NodeGuards_1.NodeGuards.isSwitchCaseNode(scopeNode)) {
- scopeNode.consequent = statements;
- return;
- }
- scopeNode.body = statements;
- }
- }]);
- return NodeAppender;
- }();
- exports.NodeAppender = NodeAppender;
- /***/ }),
- /* 17 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- var ObfuscationEvent;
- (function (ObfuscationEvent) {
- ObfuscationEvent["AfterObfuscation"] = "afterObfuscation";
- ObfuscationEvent["BeforeObfuscation"] = "beforeObfuscation";
- })(ObfuscationEvent = exports.ObfuscationEvent || (exports.ObfuscationEvent = {}));
- /***/ }),
- /* 18 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- var IdentifierObfuscatingReplacer;
- (function (IdentifierObfuscatingReplacer) {
- IdentifierObfuscatingReplacer["BaseIdentifierObfuscatingReplacer"] = "BaseIdentifierObfuscatingReplacer";
- })(IdentifierObfuscatingReplacer = exports.IdentifierObfuscatingReplacer || (exports.IdentifierObfuscatingReplacer = {}));
- /***/ }),
- /* 19 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- Object.defineProperty(exports, "__esModule", { value: true });
- __webpack_require__(51);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var InversifyContainerFacade_1 = __webpack_require__(15);
- var JavaScriptObfuscatorCLI_1 = __webpack_require__(34);
- var JavaScriptObfuscatorFacade = function () {
- function JavaScriptObfuscatorFacade() {
- _classCallCheck(this, JavaScriptObfuscatorFacade);
- }
- _createClass(JavaScriptObfuscatorFacade, null, [{
- key: "obfuscate",
- value: function obfuscate(sourceCode) {
- var inputOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
- var inversifyContainerFacade = new InversifyContainerFacade_1.InversifyContainerFacade();
- inversifyContainerFacade.load(sourceCode, inputOptions);
- var javaScriptObfuscator = inversifyContainerFacade.get(ServiceIdentifiers_1.ServiceIdentifiers.IJavaScriptObfuscator);
- var obfuscationResult = javaScriptObfuscator.obfuscate(sourceCode);
- inversifyContainerFacade.unload();
- return obfuscationResult;
- }
- }, {
- key: "runCLI",
- value: function runCLI(argv) {
- var javaScriptObfuscatorCLI = new JavaScriptObfuscatorCLI_1.JavaScriptObfuscatorCLI(argv);
- javaScriptObfuscatorCLI.initialize();
- javaScriptObfuscatorCLI.run();
- }
- }]);
- return JavaScriptObfuscatorFacade;
- }();
- exports.JavaScriptObfuscator = JavaScriptObfuscatorFacade;
- /***/ }),
- /* 20 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- var NodeTransformer;
- (function (NodeTransformer) {
- NodeTransformer["BlockStatementControlFlowTransformer"] = "BlockStatementControlFlowTransformer";
- NodeTransformer["ClassDeclarationTransformer"] = "ClassDeclarationTransformer";
- NodeTransformer["CommentsTransformer"] = "CommentsTransformer";
- NodeTransformer["CustomNodesTransformer"] = "CustomNodesTransformer";
- NodeTransformer["DeadCodeInjectionTransformer"] = "DeadCodeInjectionTransformer";
- NodeTransformer["EvalCallExpressionTransformer"] = "EvalCallExpressionTransformer";
- NodeTransformer["FunctionControlFlowTransformer"] = "FunctionControlFlowTransformer";
- NodeTransformer["CatchClauseTransformer"] = "CatchClauseTransformer";
- NodeTransformer["FunctionDeclarationTransformer"] = "FunctionDeclarationTransformer";
- NodeTransformer["FunctionTransformer"] = "FunctionTransformer";
- NodeTransformer["LabeledStatementTransformer"] = "LabeledStatementTransformer";
- NodeTransformer["LiteralTransformer"] = "LiteralTransformer";
- NodeTransformer["MemberExpressionTransformer"] = "MemberExpressionTransformer";
- NodeTransformer["MethodDefinitionTransformer"] = "MethodDefinitionTransformer";
- NodeTransformer["ObfuscatingGuardsTransformer"] = "ObfuscatingGuardsTransformer";
- NodeTransformer["ObjectExpressionKeysTransformer"] = "ObjectExpressionKeysTransformer";
- NodeTransformer["ObjectExpressionTransformer"] = "ObjectExpressionTransformer";
- NodeTransformer["ParentificationTransformer"] = "ParentificationTransformer";
- NodeTransformer["TemplateLiteralTransformer"] = "TemplateLiteralTransformer";
- NodeTransformer["VariableDeclarationTransformer"] = "VariableDeclarationTransformer";
- })(NodeTransformer = exports.NodeTransformer || (exports.NodeTransformer = {}));
- /***/ }),
- /* 21 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- var CustomNode;
- (function (CustomNode) {
- CustomNode["ConsoleOutputDisableExpressionNode"] = "ConsoleOutputDisableExpressionNode";
- CustomNode["DebugProtectionFunctionCallNode"] = "DebugProtectionFunctionCallNode";
- CustomNode["DebugProtectionFunctionIntervalNode"] = "DebugProtectionFunctionIntervalNode";
- CustomNode["DebugProtectionFunctionNode"] = "DebugProtectionFunctionNode";
- CustomNode["DomainLockNode"] = "DomainLockNode";
- CustomNode["NodeCallsControllerFunctionNode"] = "NodeCallsControllerFunctionNode";
- CustomNode["SelfDefendingUnicodeNode"] = "SelfDefendingUnicodeNode";
- CustomNode["StringArrayCallsWrapper"] = "StringArrayCallsWrapper";
- CustomNode["StringArrayNode"] = "StringArrayNode";
- CustomNode["StringArrayRotateFunctionNode"] = "StringArrayRotateFunctionNode";
- })(CustomNode = exports.CustomNode || (exports.CustomNode = {}));
- /***/ }),
- /* 22 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- Object.defineProperty(exports, "__esModule", { value: true });
- var JSFuck_1 = __webpack_require__(114);
- var Utils = function () {
- function Utils() {
- _classCallCheck(this, Utils);
- }
- _createClass(Utils, null, [{
- key: "decToHex",
- value: function decToHex(dec) {
- var radix = 16;
- return dec.toString(radix);
- }
- }, {
- key: "extractDomainFromUrl",
- value: function extractDomainFromUrl(url) {
- var domain = void 0;
- if (url.indexOf('://') > -1 || url.indexOf('//') === 0) {
- domain = url.split('/')[2];
- } else {
- domain = url.split('/')[0];
- }
- domain = domain.split(':')[0];
- return domain;
- }
- }, {
- key: "isCeilNumber",
- value: function isCeilNumber(number) {
- return number % 1 === 0;
- }
- }, {
- key: "stringRotate",
- value: function stringRotate(string, times) {
- if (!string) {
- throw new ReferenceError("Cannot rotate empty string.");
- }
- for (var i = 0; i < times; i++) {
- string = string[string.length - 1] + string.substring(0, string.length - 1);
- }
- return string;
- }
- }, {
- key: "stringToJSFuck",
- value: function stringToJSFuck(string) {
- return Array.from(string).map(function (character) {
- return JSFuck_1.JSFuck[character] || character;
- }).join(' + ');
- }
- }]);
- return Utils;
- }();
- Utils.hexadecimalPrefix = '0x';
- exports.Utils = Utils;
- /***/ }),
- /* 23 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var AbstractCustomNodeGroup = function () {
- function AbstractCustomNodeGroup(identifierNamesGeneratorFactory, randomGenerator, options) {
- _classCallCheck(this, AbstractCustomNodeGroup);
- this.identifierNamesGenerator = identifierNamesGeneratorFactory(options);
- this.randomGenerator = randomGenerator;
- this.options = options;
- }
- _createClass(AbstractCustomNodeGroup, [{
- key: "getAppendEvent",
- value: function getAppendEvent() {
- return this.appendEvent;
- }
- }, {
- key: "getCustomNodes",
- value: function getCustomNodes() {
- return this.customNodes;
- }
- }, {
- key: "appendCustomNodeIfExist",
- value: function appendCustomNodeIfExist(customNodeName, callback) {
- var customNode = this.customNodes.get(customNodeName);
- if (!customNode) {
- return;
- }
- callback(customNode);
- }
- }, {
- key: "getRandomStackTraceIndex",
- value: function getRandomStackTraceIndex(stackTraceLength) {
- return this.randomGenerator.getRandomInteger(0, Math.max(0, Math.round(stackTraceLength - 1)));
- }
- }]);
- return AbstractCustomNodeGroup;
- }();
- AbstractCustomNodeGroup = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IIdentifierNamesGenerator)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object, Object])], AbstractCustomNodeGroup);
- exports.AbstractCustomNodeGroup = AbstractCustomNodeGroup;
- /***/ }),
- /* 24 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- var IdentifierNamesGenerator;
- (function (IdentifierNamesGenerator) {
- IdentifierNamesGenerator["HexadecimalIdentifierNamesGenerator"] = "hexadecimal";
- IdentifierNamesGenerator["MangledIdentifierNamesGenerator"] = "mangled";
- })(IdentifierNamesGenerator = exports.IdentifierNamesGenerator || (exports.IdentifierNamesGenerator = {}));
- /***/ }),
- /* 25 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- var SourceMapMode;
- (function (SourceMapMode) {
- SourceMapMode["Inline"] = "inline";
- SourceMapMode["Separate"] = "separate";
- })(SourceMapMode = exports.SourceMapMode || (exports.SourceMapMode = {}));
- /***/ }),
- /* 26 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- var StringArrayEncoding;
- (function (StringArrayEncoding) {
- StringArrayEncoding["Base64"] = "base64";
- StringArrayEncoding["Rc4"] = "rc4";
- })(StringArrayEncoding = exports.StringArrayEncoding || (exports.StringArrayEncoding = {}));
- /***/ }),
- /* 27 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- var IdentifierNamesGenerator_1 = __webpack_require__(24);
- var ObfuscationTarget_1 = __webpack_require__(14);
- var SourceMapMode_1 = __webpack_require__(25);
- exports.NO_ADDITIONAL_NODES_PRESET = Object.freeze({
- compact: true,
- controlFlowFlattening: false,
- controlFlowFlatteningThreshold: 0,
- deadCodeInjection: false,
- deadCodeInjectionThreshold: 0,
- debugProtection: false,
- debugProtectionInterval: false,
- disableConsoleOutput: false,
- domainLock: [],
- identifierNamesGenerator: IdentifierNamesGenerator_1.IdentifierNamesGenerator.HexadecimalIdentifierNamesGenerator,
- identifiersPrefix: '',
- log: false,
- renameGlobals: false,
- reservedNames: [],
- rotateStringArray: false,
- seed: 0,
- selfDefending: false,
- sourceMap: false,
- sourceMapBaseUrl: '',
- sourceMapFileName: '',
- sourceMapMode: SourceMapMode_1.SourceMapMode.Separate,
- stringArray: false,
- stringArrayEncoding: false,
- stringArrayThreshold: 0,
- target: ObfuscationTarget_1.ObfuscationTarget.Browser,
- transformObjectKeys: false,
- unicodeEscapeSequence: false
- });
- /***/ }),
- /* 28 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var AbstractObfuscatingReplacer = function AbstractObfuscatingReplacer(options) {
- _classCallCheck(this, AbstractObfuscatingReplacer);
- this.options = options;
- };
- AbstractObfuscatingReplacer = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Object])], AbstractObfuscatingReplacer);
- exports.AbstractObfuscatingReplacer = AbstractObfuscatingReplacer;
- /***/ }),
- /* 29 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var AbstractCalleeDataExtractor = function AbstractCalleeDataExtractor() {
- _classCallCheck(this, AbstractCalleeDataExtractor);
- };
- AbstractCalleeDataExtractor = tslib_1.__decorate([inversify_1.injectable()], AbstractCalleeDataExtractor);
- exports.AbstractCalleeDataExtractor = AbstractCalleeDataExtractor;
- /***/ }),
- /* 30 */
- /***/ (function(module, exports) {
- module.exports = require("escodegen-wallaby");
- /***/ }),
- /* 31 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var AbstractControlFlowReplacer = AbstractControlFlowReplacer_1 = function () {
- function AbstractControlFlowReplacer(controlFlowCustomNodeFactory, randomGenerator, options) {
- _classCallCheck(this, AbstractControlFlowReplacer);
- this.replacerDataByControlFlowStorageId = new Map();
- this.controlFlowCustomNodeFactory = controlFlowCustomNodeFactory;
- this.randomGenerator = randomGenerator;
- this.options = options;
- }
- _createClass(AbstractControlFlowReplacer, [{
- key: "insertCustomNodeToControlFlowStorage",
- value: function insertCustomNodeToControlFlowStorage(customNode, controlFlowStorage, replacerId, usingExistingIdentifierChance) {
- var _this = this;
- var controlFlowStorageId = controlFlowStorage.getStorageId();
- var storageKeysById = AbstractControlFlowReplacer_1.getStorageKeysByIdForCurrentStorage(this.replacerDataByControlFlowStorageId, controlFlowStorageId);
- var storageKeysForCurrentId = storageKeysById.get(replacerId);
- if (this.randomGenerator.getMathRandom() < usingExistingIdentifierChance && storageKeysForCurrentId && storageKeysForCurrentId.length) {
- return this.randomGenerator.getRandomGenerator().pickone(storageKeysForCurrentId);
- }
- var generateStorageKey = function generateStorageKey(length) {
- var key = _this.randomGenerator.getRandomString(length);
- if (controlFlowStorage.getStorage().has(key)) {
- return generateStorageKey(length);
- }
- return key;
- };
- var storageKey = generateStorageKey(5);
- storageKeysById.set(replacerId, [storageKey]);
- this.replacerDataByControlFlowStorageId.set(controlFlowStorageId, storageKeysById);
- controlFlowStorage.set(storageKey, customNode);
- return storageKey;
- }
- }], [{
- key: "getStorageKeysByIdForCurrentStorage",
- value: function getStorageKeysByIdForCurrentStorage(identifierDataByControlFlowStorageId, controlFlowStorageId) {
- var storageKeysById = void 0;
- if (identifierDataByControlFlowStorageId.has(controlFlowStorageId)) {
- storageKeysById = identifierDataByControlFlowStorageId.get(controlFlowStorageId);
- } else {
- storageKeysById = new Map();
- }
- return storageKeysById;
- }
- }]);
- return AbstractControlFlowReplacer;
- }();
- AbstractControlFlowReplacer = AbstractControlFlowReplacer_1 = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IControlFlowCustomNode)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object, Object])], AbstractControlFlowReplacer);
- exports.AbstractControlFlowReplacer = AbstractControlFlowReplacer;
- var AbstractControlFlowReplacer_1;
- /***/ }),
- /* 32 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- function GlobalVariableNoEvalTemplate() {
- return "\n var that = (typeof window !== 'undefined'\n ? window\n : (typeof process === 'object' &&\n typeof require === 'function' &&\n typeof global === 'object')\n ? global\n : this);\n ";
- }
- exports.GlobalVariableNoEvalTemplate = GlobalVariableNoEvalTemplate;
- /***/ }),
- /* 33 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- var IdentifierNamesGenerator_1 = __webpack_require__(24);
- var ObfuscationTarget_1 = __webpack_require__(14);
- var SourceMapMode_1 = __webpack_require__(25);
- exports.DEFAULT_PRESET = Object.freeze({
- compact: true,
- config: '',
- controlFlowFlattening: false,
- controlFlowFlatteningThreshold: 0.75,
- deadCodeInjection: false,
- deadCodeInjectionThreshold: 0.4,
- debugProtection: false,
- debugProtectionInterval: false,
- disableConsoleOutput: false,
- domainLock: [],
- identifierNamesGenerator: IdentifierNamesGenerator_1.IdentifierNamesGenerator.HexadecimalIdentifierNamesGenerator,
- identifiersPrefix: '',
- log: false,
- renameGlobals: false,
- reservedNames: [],
- rotateStringArray: true,
- seed: 0,
- selfDefending: false,
- sourceMap: false,
- sourceMapBaseUrl: '',
- sourceMapFileName: '',
- sourceMapMode: SourceMapMode_1.SourceMapMode.Separate,
- stringArray: true,
- stringArrayEncoding: false,
- stringArrayThreshold: 0.75,
- target: ObfuscationTarget_1.ObfuscationTarget.Browser,
- transformObjectKeys: false,
- unicodeEscapeSequence: false
- });
- /***/ }),
- /* 34 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var commander = tslib_1.__importStar(__webpack_require__(181));
- var packageJson = tslib_1.__importStar(__webpack_require__(47));
- var path = tslib_1.__importStar(__webpack_require__(35));
- var Initializable_1 = __webpack_require__(5);
- var Default_1 = __webpack_require__(33);
- var ArraySanitizer_1 = __webpack_require__(182);
- var BooleanSanitizer_1 = __webpack_require__(183);
- var IdentifierNamesGeneratorSanitizer_1 = __webpack_require__(184);
- var ObfuscatingTargetSanitizer_1 = __webpack_require__(185);
- var SourceMapModeSanitizer_1 = __webpack_require__(186);
- var StringArrayEncodingSanitizer_1 = __webpack_require__(187);
- var CLIUtils_1 = __webpack_require__(188);
- var JavaScriptObfuscatorFacade_1 = __webpack_require__(19);
- var SourceCodeReader_1 = __webpack_require__(191);
- var JavaScriptObfuscatorCLI = function () {
- function JavaScriptObfuscatorCLI(argv) {
- _classCallCheck(this, JavaScriptObfuscatorCLI);
- this.rawArguments = argv;
- this.arguments = argv.slice(2);
- }
- _createClass(JavaScriptObfuscatorCLI, [{
- key: "initialize",
- value: function initialize() {
- this.inputPath = path.normalize(this.arguments[0] || '');
- this.commands = new commander.Command();
- this.configureCommands();
- this.configureHelp();
- this.inputCLIOptions = this.commands.opts();
- }
- }, {
- key: "run",
- value: function run() {
- var canShowHelp = !this.arguments.length || this.arguments.indexOf('--help') !== -1;
- if (canShowHelp) {
- return this.commands.outputHelp();
- }
- var sourceCodeData = SourceCodeReader_1.SourceCodeReader.readSourceCode(this.inputPath);
- this.processSourceCodeData(sourceCodeData);
- }
- }, {
- key: "buildOptions",
- value: function buildOptions() {
- var inputCLIOptions = JavaScriptObfuscatorCLI.filterOptions(this.inputCLIOptions);
- var configFilePath = this.inputCLIOptions.config;
- var configFileLocation = configFilePath ? path.resolve(configFilePath, '.') : '';
- var configFileOptions = configFileLocation ? CLIUtils_1.CLIUtils.getUserConfig(configFileLocation) : {};
- return Object.assign({}, Default_1.DEFAULT_PRESET, configFileOptions, inputCLIOptions);
- }
- }, {
- key: "configureCommands",
- value: function configureCommands() {
- this.commands.usage('<inputPath> [options]').version(packageJson.version, '-v, --version').option('-o, --output <path>', 'Output path for obfuscated code').option('--compact <boolean>', 'Disable one line output code compacting', BooleanSanitizer_1.BooleanSanitizer).option('--config <boolean>', 'Name of js / json config file').option('--control-flow-flattening <boolean>', 'Enables control flow flattening', BooleanSanitizer_1.BooleanSanitizer).option('--control-flow-flattening-threshold <number>', 'The probability that the control flow flattening transformation will be applied to the node', parseFloat).option('--dead-code-injection <boolean>', 'Enables dead code injection', BooleanSanitizer_1.BooleanSanitizer).option('--dead-code-injection-threshold <number>', 'The probability that the dead code injection transformation will be applied to the node', parseFloat).option('--debug-protection <boolean>', 'Disable browser Debug panel (can cause DevTools enabled browser freeze)', BooleanSanitizer_1.BooleanSanitizer).option('--debug-protection-interval <boolean>', 'Disable browser Debug panel even after page was loaded (can cause DevTools enabled browser freeze)', BooleanSanitizer_1.BooleanSanitizer).option('--disable-console-output <boolean>', 'Allow console.log, console.info, console.error and console.warn messages output into browser console', BooleanSanitizer_1.BooleanSanitizer).option('--domain-lock <list> (comma separated, without whitespaces)', 'Blocks the execution of the code in domains that do not match the passed RegExp patterns (comma separated)', ArraySanitizer_1.ArraySanitizer).option('--identifier-names-generator <string> [hexadecimal, mangled]', 'Sets identifier names generator (Default: hexadecimal)', IdentifierNamesGeneratorSanitizer_1.IdentifierNamesGeneratorSanitizer).option('--identifiers-prefix <string>', 'Sets prefix for all global generated identifiers.').option('--log <boolean>', 'Enables logging of the information to the console', BooleanSanitizer_1.BooleanSanitizer).option('--reserved-names <list> (comma separated, without whitespaces)', 'Disable obfuscation of variable names, function names and names of function parameters that match the passed RegExp patterns (comma separated)', ArraySanitizer_1.ArraySanitizer).option('--rename-globals <boolean>', 'Allows to enable obfuscation of global variable and function names with declaration.', BooleanSanitizer_1.BooleanSanitizer).option('--rotate-string-array <boolean>', 'Disable rotation of unicode array values during obfuscation', BooleanSanitizer_1.BooleanSanitizer).option('--seed <number>', 'Sets seed for random generator. This is useful for creating repeatable results.', parseFloat).option('--self-defending <boolean>', 'Disables self-defending for obfuscated code', BooleanSanitizer_1.BooleanSanitizer).option('--source-map <boolean>', 'Enables source map generation', BooleanSanitizer_1.BooleanSanitizer).option('--source-map-base-url <string>', 'Sets base url to the source map import url when `--source-map-mode=separate`').option('--source-map-file-name <string>', 'Sets file name for output source map when `--source-map-mode=separate`').option('--source-map-mode <string> [inline, separate]', 'Specify source map output mode', SourceMapModeSanitizer_1.SourceMapModeSanitizer).option('--string-array <boolean>', 'Disables gathering of all literal strings into an array and replacing every literal string with an array call', BooleanSanitizer_1.BooleanSanitizer).option('--string-array-encoding <string|boolean> [true, false, base64, rc4]', 'Encodes all strings in strings array using base64 or rc4 (this option can slow down your code speed', StringArrayEncodingSanitizer_1.StringArrayEncodingSanitizer).option('--string-array-threshold <number>', 'The probability that the literal string will be inserted into stringArray (Default: 0.8, Min: 0, Max: 1)', parseFloat).option('--target <string>', 'Allows to set target environment for obfuscated code.', ObfuscatingTargetSanitizer_1.ObfuscationTargetSanitizer).option('--transform-object-keys <boolean>', 'Enables transformation of object keys', BooleanSanitizer_1.BooleanSanitizer).option('--unicode-escape-sequence <boolean>', 'Allows to enable/disable string conversion to unicode escape sequence', BooleanSanitizer_1.BooleanSanitizer).parse(this.rawArguments);
- }
- }, {
- key: "configureHelp",
- value: function configureHelp() {
- this.commands.on('--help', function () {
- console.log(' Examples:\n');
- console.log(' %> javascript-obfuscator input_file_name.js --compact true --self-defending false');
- console.log(' %> javascript-obfuscator input_file_name.js --output output_file_name.js --compact true --self-defending false');
- console.log(' %> javascript-obfuscator input_directory_name --compact true --self-defending false');
- console.log('');
- });
- }
- }, {
- key: "processSourceCodeData",
- value: function processSourceCodeData(sourceCodeData) {
- var _this = this;
- var outputPath = this.inputCLIOptions.output ? path.normalize(this.inputCLIOptions.output) : '';
- if (!Array.isArray(sourceCodeData)) {
- var outputCodePath = outputPath || CLIUtils_1.CLIUtils.getOutputCodePath(this.inputPath);
- this.processSourceCode(sourceCodeData, outputCodePath, null);
- } else {
- sourceCodeData.forEach(function (_ref, index) {
- var filePath = _ref.filePath,
- content = _ref.content;
- var outputCodePath = outputPath ? path.join(outputPath, filePath) : CLIUtils_1.CLIUtils.getOutputCodePath(filePath);
- _this.processSourceCode(content, outputCodePath, index);
- });
- }
- }
- }, {
- key: "processSourceCode",
- value: function processSourceCode(sourceCode, outputCodePath, sourceCodeIndex) {
- var options = this.buildOptions();
- if (sourceCodeIndex !== null) {
- var baseIdentifiersPrefix = this.inputCLIOptions.identifiersPrefix || JavaScriptObfuscatorCLI.baseIdentifiersPrefix;
- var identifiersPrefix = "" + baseIdentifiersPrefix + sourceCodeIndex;
- options = Object.assign({}, options, { identifiersPrefix: identifiersPrefix });
- }
- if (options.sourceMap) {
- JavaScriptObfuscatorCLI.processSourceCodeWithSourceMap(sourceCode, outputCodePath, options);
- } else {
- JavaScriptObfuscatorCLI.processSourceCodeWithoutSourceMap(sourceCode, outputCodePath, options);
- }
- }
- }], [{
- key: "filterOptions",
- value: function filterOptions(options) {
- var filteredOptions = {};
- for (var option in options) {
- if (!options.hasOwnProperty(option) || options[option] === undefined) {
- continue;
- }
- filteredOptions[option] = options[option];
- }
- return filteredOptions;
- }
- }, {
- key: "processSourceCodeWithoutSourceMap",
- value: function processSourceCodeWithoutSourceMap(sourceCode, outputCodePath, options) {
- var obfuscatedCode = JavaScriptObfuscatorFacade_1.JavaScriptObfuscator.obfuscate(sourceCode, options).getObfuscatedCode();
- CLIUtils_1.CLIUtils.writeFile(outputCodePath, obfuscatedCode);
- }
- }, {
- key: "processSourceCodeWithSourceMap",
- value: function processSourceCodeWithSourceMap(sourceCode, outputCodePath, options) {
- var outputSourceMapPath = CLIUtils_1.CLIUtils.getOutputSourceMapPath(outputCodePath, options.sourceMapFileName || '');
- options = Object.assign({}, options, { sourceMapFileName: path.basename(outputSourceMapPath) });
- var obfuscationResult = JavaScriptObfuscatorFacade_1.JavaScriptObfuscator.obfuscate(sourceCode, options);
- CLIUtils_1.CLIUtils.writeFile(outputCodePath, obfuscationResult.getObfuscatedCode());
- if (options.sourceMapMode === 'separate' && obfuscationResult.getSourceMap()) {
- CLIUtils_1.CLIUtils.writeFile(outputSourceMapPath, obfuscationResult.getSourceMap());
- }
- }
- }]);
- return JavaScriptObfuscatorCLI;
- }();
- JavaScriptObfuscatorCLI.availableInputExtensions = ['.js'];
- JavaScriptObfuscatorCLI.encoding = 'utf8';
- JavaScriptObfuscatorCLI.obfuscatedFilePrefix = '-obfuscated';
- JavaScriptObfuscatorCLI.baseIdentifiersPrefix = 'a';
- tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", Object)], JavaScriptObfuscatorCLI.prototype, "commands", void 0);
- tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", Object)], JavaScriptObfuscatorCLI.prototype, "inputCLIOptions", void 0);
- tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", String)], JavaScriptObfuscatorCLI.prototype, "inputPath", void 0);
- exports.JavaScriptObfuscatorCLI = JavaScriptObfuscatorCLI;
- /***/ }),
- /* 35 */
- /***/ (function(module, exports) {
- module.exports = require("path");
- /***/ }),
- /* 36 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- var CalleeDataExtractor;
- (function (CalleeDataExtractor) {
- CalleeDataExtractor["FunctionDeclarationCalleeDataExtractor"] = "FunctionDeclarationCalleeDataExtractor";
- CalleeDataExtractor["FunctionExpressionCalleeDataExtractor"] = "FunctionExpressionCalleeDataExtractor";
- CalleeDataExtractor["ObjectExpressionCalleeDataExtractor"] = "ObjectExpressionCalleeDataExtractor";
- })(CalleeDataExtractor = exports.CalleeDataExtractor || (exports.CalleeDataExtractor = {}));
- /***/ }),
- /* 37 */
- /***/ (function(module, exports) {
- module.exports = require("esprima");
- /***/ }),
- /* 38 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- var ControlFlowReplacer;
- (function (ControlFlowReplacer) {
- ControlFlowReplacer["BinaryExpressionControlFlowReplacer"] = "BinaryExpressionControlFlowReplacer";
- ControlFlowReplacer["CallExpressionControlFlowReplacer"] = "CallExpressionControlFlowReplacer";
- ControlFlowReplacer["LogicalExpressionControlFlowReplacer"] = "LogicalExpressionControlFlowReplacer";
- ControlFlowReplacer["StringLiteralControlFlowReplacer"] = "StringLiteralControlFlowReplacer";
- })(ControlFlowReplacer = exports.ControlFlowReplacer || (exports.ControlFlowReplacer = {}));
- /***/ }),
- /* 39 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var ControlFlowCustomNode_1 = __webpack_require__(13);
- var AbstractControlFlowReplacer_1 = __webpack_require__(31);
- var NodeGuards_1 = __webpack_require__(3);
- var ExpressionWithOperatorControlFlowReplacer = function (_AbstractControlFlowR) {
- _inherits(ExpressionWithOperatorControlFlowReplacer, _AbstractControlFlowR);
- function ExpressionWithOperatorControlFlowReplacer(controlFlowCustomNodeFactory, randomGenerator, options) {
- _classCallCheck(this, ExpressionWithOperatorControlFlowReplacer);
- return _possibleConstructorReturn(this, (ExpressionWithOperatorControlFlowReplacer.__proto__ || Object.getPrototypeOf(ExpressionWithOperatorControlFlowReplacer)).call(this, controlFlowCustomNodeFactory, randomGenerator, options));
- }
- _createClass(ExpressionWithOperatorControlFlowReplacer, [{
- key: "getControlFlowStorageCallNode",
- value: function getControlFlowStorageCallNode(controlFlowStorageId, storageKey, leftExpression, rightExpression) {
- var controlFlowStorageCallCustomNode = this.controlFlowCustomNodeFactory(ControlFlowCustomNode_1.ControlFlowCustomNode.ExpressionWithOperatorControlFlowStorageCallNode);
- controlFlowStorageCallCustomNode.initialize(controlFlowStorageId, storageKey, leftExpression, rightExpression);
- var statementNode = controlFlowStorageCallCustomNode.getNode()[0];
- if (!statementNode || !NodeGuards_1.NodeGuards.isExpressionStatementNode(statementNode)) {
- throw new Error("`controlFlowStorageCallCustomNode.getNode()[0]` should returns array with `ExpressionStatement` node");
- }
- return statementNode.expression;
- }
- }]);
- return ExpressionWithOperatorControlFlowReplacer;
- }(AbstractControlFlowReplacer_1.AbstractControlFlowReplacer);
- ExpressionWithOperatorControlFlowReplacer = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IControlFlowCustomNode)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object, Object])], ExpressionWithOperatorControlFlowReplacer);
- exports.ExpressionWithOperatorControlFlowReplacer = ExpressionWithOperatorControlFlowReplacer;
- /***/ }),
- /* 40 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- var DeadCodeInjectionCustomNode;
- (function (DeadCodeInjectionCustomNode) {
- DeadCodeInjectionCustomNode["BlockStatementDeadCodeInjectionNode"] = "BlockStatementDeadCodeInjectionNode";
- })(DeadCodeInjectionCustomNode = exports.DeadCodeInjectionCustomNode || (exports.DeadCodeInjectionCustomNode = {}));
- /***/ }),
- /* 41 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- var CustomNodeGroup;
- (function (CustomNodeGroup) {
- CustomNodeGroup["ConsoleOutputCustomNodeGroup"] = "ConsoleOutputCustomNodeGroup";
- CustomNodeGroup["DebugProtectionCustomNodeGroup"] = "DebugProtectionCustomNodeGroup";
- CustomNodeGroup["DomainLockCustomNodeGroup"] = "DomainLockCustomNodeGroup";
- CustomNodeGroup["SelfDefendingCustomNodeGroup"] = "SelfDefendingCustomNodeGroup";
- CustomNodeGroup["StringArrayCustomNodeGroup"] = "StringArrayCustomNodeGroup";
- })(CustomNodeGroup = exports.CustomNodeGroup || (exports.CustomNodeGroup = {}));
- /***/ }),
- /* 42 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var AbstractIdentifierNamesGenerator = function AbstractIdentifierNamesGenerator(randomGenerator, options) {
- _classCallCheck(this, AbstractIdentifierNamesGenerator);
- this.randomGenerator = randomGenerator;
- this.options = options;
- };
- AbstractIdentifierNamesGenerator = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Object, Object])], AbstractIdentifierNamesGenerator);
- exports.AbstractIdentifierNamesGenerator = AbstractIdentifierNamesGenerator;
- /***/ }),
- /* 43 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- var LiteralObfuscatingReplacer;
- (function (LiteralObfuscatingReplacer) {
- LiteralObfuscatingReplacer["BooleanLiteralObfuscatingReplacer"] = "BooleanLiteralObfuscatingReplacer";
- LiteralObfuscatingReplacer["NumberLiteralObfuscatingReplacer"] = "NumberLiteralObfuscatingReplacer";
- LiteralObfuscatingReplacer["StringLiteralObfuscatingReplacer"] = "StringLiteralObfuscatingReplacer";
- })(LiteralObfuscatingReplacer = exports.LiteralObfuscatingReplacer || (exports.LiteralObfuscatingReplacer = {}));
- /***/ }),
- /* 44 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- var ObfuscatingGuard;
- (function (ObfuscatingGuard) {
- ObfuscatingGuard["BlackListNodeGuard"] = "BlackListNodeGuard";
- ObfuscatingGuard["ConditionalCommentNodeGuard"] = "ConditionalCommentNodeGuard";
- })(ObfuscatingGuard = exports.ObfuscatingGuard || (exports.ObfuscatingGuard = {}));
- /***/ }),
- /* 45 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _slicedToArray = (function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; })();
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var Initializable_1 = __webpack_require__(5);
- var MapStorage = function () {
- function MapStorage(randomGenerator, options) {
- _classCallCheck(this, MapStorage);
- this.randomGenerator = randomGenerator;
- this.options = options;
- }
- _createClass(MapStorage, [{
- key: "initialize",
- value: function initialize() {
- this.storage = new Map();
- this.storageId = this.randomGenerator.getRandomString(6);
- }
- }, {
- key: "get",
- value: function get(key) {
- var value = this.storage.get(key);
- if (!value) {
- throw new Error("No value found in map storage with key `" + key + "`");
- }
- return value;
- }
- }, {
- key: "getKeyOf",
- value: function getKeyOf(value) {
- var _iteratorNormalCompletion = true;
- var _didIteratorError = false;
- var _iteratorError = undefined;
- try {
- for (var _iterator = this.storage[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
- var _step$value = _slicedToArray(_step.value, 2),
- key = _step$value[0],
- storageValue = _step$value[1];
- if (value === storageValue) {
- return key;
- }
- }
- } catch (err) {
- _didIteratorError = true;
- _iteratorError = err;
- } finally {
- try {
- if (!_iteratorNormalCompletion && _iterator.return) {
- _iterator.return();
- }
- } finally {
- if (_didIteratorError) {
- throw _iteratorError;
- }
- }
- }
- return null;
- }
- }, {
- key: "getLength",
- value: function getLength() {
- return this.storage.size;
- }
- }, {
- key: "getStorage",
- value: function getStorage() {
- return this.storage;
- }
- }, {
- key: "getStorageId",
- value: function getStorageId() {
- return this.storageId;
- }
- }, {
- key: "mergeWith",
- value: function mergeWith(storage) {
- var mergeId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
- this.storage = new Map([].concat(_toConsumableArray(this.storage), _toConsumableArray(storage.getStorage())));
- if (mergeId) {
- this.storageId = storage.getStorageId();
- }
- }
- }, {
- key: "set",
- value: function set(key, value) {
- this.storage.set(key, value);
- }
- }]);
- return MapStorage;
- }();
- tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", String)], MapStorage.prototype, "storageId", void 0);
- tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", Map)], MapStorage.prototype, "storage", void 0);
- tslib_1.__decorate([inversify_1.postConstruct(), tslib_1.__metadata("design:type", Function), tslib_1.__metadata("design:paramtypes", []), tslib_1.__metadata("design:returntype", void 0)], MapStorage.prototype, "initialize", null);
- MapStorage = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Object, Object])], MapStorage);
- exports.MapStorage = MapStorage;
- /***/ }),
- /* 46 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var md5_1 = tslib_1.__importDefault(__webpack_require__(167));
- var chance_1 = __webpack_require__(168);
- var Initializable_1 = __webpack_require__(5);
- var RandomGenerator = RandomGenerator_1 = function () {
- function RandomGenerator(sourceCode, options) {
- _classCallCheck(this, RandomGenerator);
- this.sourceCode = sourceCode;
- this.options = options;
- }
- _createClass(RandomGenerator, [{
- key: "initialize",
- value: function initialize() {
- var _this = this;
- var getRandomInteger = function getRandomInteger(min, max) {
- return Math.floor(Math.random() * (max - min + 1) + min);
- };
- var getSeed = function getSeed() {
- var md5Hash = md5_1.default(_this.sourceCode.getSourceCode());
- return _this.seed + Number(md5Hash.replace(/\D/g, ''));
- };
- this.seed = this.options.seed !== 0 ? this.options.seed : getRandomInteger(0, 999999999);
- this.randomGenerator = new chance_1.Chance(getSeed());
- }
- }, {
- key: "getMathRandom",
- value: function getMathRandom() {
- return this.getRandomInteger(0, 99999) / 100000;
- }
- }, {
- key: "getRandomFloat",
- value: function getRandomFloat(min, max) {
- return this.getRandomGenerator().floating({
- min: min,
- max: max,
- fixed: 7
- });
- }
- }, {
- key: "getRandomGenerator",
- value: function getRandomGenerator() {
- return this.randomGenerator;
- }
- }, {
- key: "getRandomInteger",
- value: function getRandomInteger(min, max) {
- return this.getRandomGenerator().integer({
- min: min,
- max: max
- });
- }
- }, {
- key: "getRandomString",
- value: function getRandomString(length) {
- var pool = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : RandomGenerator_1.randomGeneratorPool;
- return this.getRandomGenerator().string({ length: length, pool: pool });
- }
- }, {
- key: "getSeed",
- value: function getSeed() {
- return this.seed;
- }
- }]);
- return RandomGenerator;
- }();
- RandomGenerator.randomGeneratorPool = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
- tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", Object)], RandomGenerator.prototype, "randomGenerator", void 0);
- tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", Number)], RandomGenerator.prototype, "seed", void 0);
- tslib_1.__decorate([inversify_1.postConstruct(), tslib_1.__metadata("design:type", Function), tslib_1.__metadata("design:paramtypes", []), tslib_1.__metadata("design:returntype", void 0)], RandomGenerator.prototype, "initialize", null);
- RandomGenerator = RandomGenerator_1 = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.ISourceCode)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Object, Object])], RandomGenerator);
- exports.RandomGenerator = RandomGenerator;
- var RandomGenerator_1;
- /***/ }),
- /* 47 */
- /***/ (function(module, exports) {
- module.exports = require("pjson");
- /***/ }),
- /* 48 */
- /***/ (function(module, exports) {
- module.exports = require("chalk");
- /***/ }),
- /* 49 */
- /***/ (function(module, exports) {
- module.exports = require("fs");
- /***/ }),
- /* 50 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- var JavaScriptObfuscatorFacade_1 = __webpack_require__(19);
- module.exports = JavaScriptObfuscatorFacade_1.JavaScriptObfuscator;
- /***/ }),
- /* 51 */
- /***/ (function(module, exports) {
- module.exports = require("reflect-metadata");
- /***/ }),
- /* 52 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- var InversifyContainerFacade_1 = __webpack_require__(15);
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var CalleeDataExtractor_1 = __webpack_require__(36);
- var FunctionDeclarationCalleeDataExtractor_1 = __webpack_require__(53);
- var FunctionExpressionCalleeDataExtractor_1 = __webpack_require__(54);
- var ObjectExpressionCalleeDataExtractor_1 = __webpack_require__(55);
- var StackTraceAnalyzer_1 = __webpack_require__(56);
- exports.analyzersModule = new inversify_1.ContainerModule(function (bind) {
- bind(ServiceIdentifiers_1.ServiceIdentifiers.IStackTraceAnalyzer).to(StackTraceAnalyzer_1.StackTraceAnalyzer).inSingletonScope();
- bind(ServiceIdentifiers_1.ServiceIdentifiers.ICalleeDataExtractor).to(FunctionDeclarationCalleeDataExtractor_1.FunctionDeclarationCalleeDataExtractor).whenTargetNamed(CalleeDataExtractor_1.CalleeDataExtractor.FunctionDeclarationCalleeDataExtractor);
- bind(ServiceIdentifiers_1.ServiceIdentifiers.ICalleeDataExtractor).to(FunctionExpressionCalleeDataExtractor_1.FunctionExpressionCalleeDataExtractor).whenTargetNamed(CalleeDataExtractor_1.CalleeDataExtractor.FunctionExpressionCalleeDataExtractor);
- bind(ServiceIdentifiers_1.ServiceIdentifiers.ICalleeDataExtractor).to(ObjectExpressionCalleeDataExtractor_1.ObjectExpressionCalleeDataExtractor).whenTargetNamed(CalleeDataExtractor_1.CalleeDataExtractor.ObjectExpressionCalleeDataExtractor);
- bind(ServiceIdentifiers_1.ServiceIdentifiers.Factory__ICalleeDataExtractor).toFactory(InversifyContainerFacade_1.InversifyContainerFacade.getCacheFactory(ServiceIdentifiers_1.ServiceIdentifiers.ICalleeDataExtractor));
- });
- /***/ }),
- /* 53 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var estraverse = tslib_1.__importStar(__webpack_require__(10));
- var AbstractCalleeDataExtractor_1 = __webpack_require__(29);
- var NodeGuards_1 = __webpack_require__(3);
- var NodeUtils_1 = __webpack_require__(4);
- var FunctionDeclarationCalleeDataExtractor = function (_AbstractCalleeDataEx) {
- _inherits(FunctionDeclarationCalleeDataExtractor, _AbstractCalleeDataEx);
- function FunctionDeclarationCalleeDataExtractor() {
- _classCallCheck(this, FunctionDeclarationCalleeDataExtractor);
- return _possibleConstructorReturn(this, (FunctionDeclarationCalleeDataExtractor.__proto__ || Object.getPrototypeOf(FunctionDeclarationCalleeDataExtractor)).apply(this, arguments));
- }
- _createClass(FunctionDeclarationCalleeDataExtractor, [{
- key: "extract",
- value: function extract(blockScopeBody, callee) {
- if (!NodeGuards_1.NodeGuards.isIdentifierNode(callee)) {
- return null;
- }
- var calleeBlockStatement = this.getCalleeBlockStatement(NodeUtils_1.NodeUtils.getBlockScopesOfNode(blockScopeBody[0])[0], callee.name);
- if (!calleeBlockStatement) {
- return null;
- }
- return {
- callee: calleeBlockStatement,
- name: callee.name
- };
- }
- }, {
- key: "getCalleeBlockStatement",
- value: function getCalleeBlockStatement(targetNode, name) {
- var calleeBlockStatement = null;
- estraverse.traverse(targetNode, {
- enter: function enter(node) {
- if (NodeGuards_1.NodeGuards.isFunctionDeclarationNode(node) && node.id.name === name) {
- calleeBlockStatement = node.body;
- return estraverse.VisitorOption.Break;
- }
- }
- });
- return calleeBlockStatement;
- }
- }]);
- return FunctionDeclarationCalleeDataExtractor;
- }(AbstractCalleeDataExtractor_1.AbstractCalleeDataExtractor);
- FunctionDeclarationCalleeDataExtractor = tslib_1.__decorate([inversify_1.injectable()], FunctionDeclarationCalleeDataExtractor);
- exports.FunctionDeclarationCalleeDataExtractor = FunctionDeclarationCalleeDataExtractor;
- /***/ }),
- /* 54 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var estraverse = tslib_1.__importStar(__webpack_require__(10));
- var AbstractCalleeDataExtractor_1 = __webpack_require__(29);
- var NodeGuards_1 = __webpack_require__(3);
- var NodeUtils_1 = __webpack_require__(4);
- var FunctionExpressionCalleeDataExtractor = function (_AbstractCalleeDataEx) {
- _inherits(FunctionExpressionCalleeDataExtractor, _AbstractCalleeDataEx);
- function FunctionExpressionCalleeDataExtractor() {
- _classCallCheck(this, FunctionExpressionCalleeDataExtractor);
- return _possibleConstructorReturn(this, (FunctionExpressionCalleeDataExtractor.__proto__ || Object.getPrototypeOf(FunctionExpressionCalleeDataExtractor)).apply(this, arguments));
- }
- _createClass(FunctionExpressionCalleeDataExtractor, [{
- key: "extract",
- value: function extract(blockScopeBody, callee) {
- var calleeBlockStatement = null;
- if (NodeGuards_1.NodeGuards.isIdentifierNode(callee)) {
- calleeBlockStatement = this.getCalleeBlockStatement(NodeUtils_1.NodeUtils.getBlockScopesOfNode(blockScopeBody[0])[0], callee.name);
- }
- if (NodeGuards_1.NodeGuards.isFunctionExpressionNode(callee)) {
- calleeBlockStatement = callee.body;
- }
- if (!calleeBlockStatement) {
- return null;
- }
- return {
- callee: calleeBlockStatement,
- name: callee.name || null
- };
- }
- }, {
- key: "getCalleeBlockStatement",
- value: function getCalleeBlockStatement(targetNode, name) {
- var calleeBlockStatement = null;
- estraverse.traverse(targetNode, {
- enter: function enter(node, parentNode) {
- if (NodeGuards_1.NodeGuards.isFunctionExpressionNode(node) && parentNode && NodeGuards_1.NodeGuards.isVariableDeclaratorNode(parentNode) && NodeGuards_1.NodeGuards.isIdentifierNode(parentNode.id) && parentNode.id.name === name) {
- calleeBlockStatement = node.body;
- return estraverse.VisitorOption.Break;
- }
- }
- });
- return calleeBlockStatement;
- }
- }]);
- return FunctionExpressionCalleeDataExtractor;
- }(AbstractCalleeDataExtractor_1.AbstractCalleeDataExtractor);
- FunctionExpressionCalleeDataExtractor = tslib_1.__decorate([inversify_1.injectable()], FunctionExpressionCalleeDataExtractor);
- exports.FunctionExpressionCalleeDataExtractor = FunctionExpressionCalleeDataExtractor;
- /***/ }),
- /* 55 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var estraverse = tslib_1.__importStar(__webpack_require__(10));
- var AbstractCalleeDataExtractor_1 = __webpack_require__(29);
- var NodeGuards_1 = __webpack_require__(3);
- var NodeUtils_1 = __webpack_require__(4);
- var ObjectExpressionCalleeDataExtractor = function (_AbstractCalleeDataEx) {
- _inherits(ObjectExpressionCalleeDataExtractor, _AbstractCalleeDataEx);
- function ObjectExpressionCalleeDataExtractor() {
- _classCallCheck(this, ObjectExpressionCalleeDataExtractor);
- return _possibleConstructorReturn(this, (ObjectExpressionCalleeDataExtractor.__proto__ || Object.getPrototypeOf(ObjectExpressionCalleeDataExtractor)).apply(this, arguments));
- }
- _createClass(ObjectExpressionCalleeDataExtractor, [{
- key: "extract",
- value: function extract(blockScopeBody, callee) {
- if (!NodeGuards_1.NodeGuards.isMemberExpressionNode(callee)) {
- return null;
- }
- var objectMembersCallsChain = this.createObjectMembersCallsChain([], callee);
- if (!objectMembersCallsChain.length) {
- return null;
- }
- var functionExpressionName = objectMembersCallsChain[objectMembersCallsChain.length - 1];
- var calleeBlockStatement = this.getCalleeBlockStatement(NodeUtils_1.NodeUtils.getBlockScopesOfNode(blockScopeBody[0])[0], objectMembersCallsChain);
- if (!calleeBlockStatement) {
- return null;
- }
- return {
- callee: calleeBlockStatement,
- name: functionExpressionName
- };
- }
- }, {
- key: "createObjectMembersCallsChain",
- value: function createObjectMembersCallsChain(currentChain, memberExpression) {
- if (NodeGuards_1.NodeGuards.isIdentifierNode(memberExpression.property) && memberExpression.computed === false) {
- currentChain.unshift(memberExpression.property.name);
- } else if (NodeGuards_1.NodeGuards.isLiteralNode(memberExpression.property) && (typeof memberExpression.property.value === 'string' || typeof memberExpression.property.value === 'number')) {
- currentChain.unshift(memberExpression.property.value);
- } else {
- return currentChain;
- }
- if (NodeGuards_1.NodeGuards.isMemberExpressionNode(memberExpression.object)) {
- return this.createObjectMembersCallsChain(currentChain, memberExpression.object);
- } else if (NodeGuards_1.NodeGuards.isIdentifierNode(memberExpression.object)) {
- currentChain.unshift(memberExpression.object.name);
- }
- return currentChain;
- }
- }, {
- key: "getCalleeBlockStatement",
- value: function getCalleeBlockStatement(targetNode, objectMembersCallsChain) {
- var _this2 = this;
- var objectName = objectMembersCallsChain.shift();
- if (!objectName) {
- return null;
- }
- var calleeBlockStatement = null;
- estraverse.traverse(targetNode, {
- enter: function enter(node) {
- if (NodeGuards_1.NodeGuards.isVariableDeclaratorNode(node) && NodeGuards_1.NodeGuards.isIdentifierNode(node.id) && node.init && NodeGuards_1.NodeGuards.isObjectExpressionNode(node.init) && node.id.name === objectName) {
- calleeBlockStatement = _this2.findCalleeBlockStatement(node.init.properties, objectMembersCallsChain);
- return estraverse.VisitorOption.Break;
- }
- }
- });
- return calleeBlockStatement;
- }
- }, {
- key: "findCalleeBlockStatement",
- value: function findCalleeBlockStatement(objectExpressionProperties, objectMembersCallsChain) {
- var nextItemInCallsChain = objectMembersCallsChain.shift();
- if (!nextItemInCallsChain) {
- return null;
- }
- var _iteratorNormalCompletion = true;
- var _didIteratorError = false;
- var _iteratorError = undefined;
- try {
- for (var _iterator = objectExpressionProperties[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
- var propertyNode = _step.value;
- var isTargetPropertyNodeWithIdentifierKey = NodeGuards_1.NodeGuards.isIdentifierNode(propertyNode.key) && propertyNode.key.name === nextItemInCallsChain;
- var isTargetPropertyNodeWithLiteralKey = NodeGuards_1.NodeGuards.isLiteralNode(propertyNode.key) && Boolean(propertyNode.key.value) && propertyNode.key.value === nextItemInCallsChain;
- if (!isTargetPropertyNodeWithIdentifierKey && !isTargetPropertyNodeWithLiteralKey) {
- continue;
- }
- if (NodeGuards_1.NodeGuards.isObjectExpressionNode(propertyNode.value)) {
- return this.findCalleeBlockStatement(propertyNode.value.properties, objectMembersCallsChain);
- }
- if (NodeGuards_1.NodeGuards.isFunctionExpressionNode(propertyNode.value)) {
- return propertyNode.value.body;
- }
- }
- } catch (err) {
- _didIteratorError = true;
- _iteratorError = err;
- } finally {
- try {
- if (!_iteratorNormalCompletion && _iterator.return) {
- _iterator.return();
- }
- } finally {
- if (_didIteratorError) {
- throw _iteratorError;
- }
- }
- }
- return null;
- }
- }]);
- return ObjectExpressionCalleeDataExtractor;
- }(AbstractCalleeDataExtractor_1.AbstractCalleeDataExtractor);
- ObjectExpressionCalleeDataExtractor = tslib_1.__decorate([inversify_1.injectable()], ObjectExpressionCalleeDataExtractor);
- exports.ObjectExpressionCalleeDataExtractor = ObjectExpressionCalleeDataExtractor;
- /***/ }),
- /* 56 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var estraverse = tslib_1.__importStar(__webpack_require__(10));
- var CalleeDataExtractor_1 = __webpack_require__(36);
- var NodeGuards_1 = __webpack_require__(3);
- var NodeUtils_1 = __webpack_require__(4);
- var StackTraceAnalyzer = StackTraceAnalyzer_1 = function () {
- function StackTraceAnalyzer(calleeDataExtractorFactory) {
- _classCallCheck(this, StackTraceAnalyzer);
- this.calleeDataExtractorFactory = calleeDataExtractorFactory;
- }
- _createClass(StackTraceAnalyzer, [{
- key: "analyze",
- value: function analyze(astTree) {
- return this.analyzeRecursive(astTree.body);
- }
- }, {
- key: "analyzeRecursive",
- value: function analyzeRecursive(blockScopeBody) {
- var _this = this;
- var limitIndex = StackTraceAnalyzer_1.getLimitIndex(blockScopeBody.length);
- var stackTraceData = [];
- var blockScopeBodyLength = blockScopeBody.length;
- var _loop = function _loop(index) {
- if (index > limitIndex) {
- return "break";
- }
- var blockScopeBodyNode = blockScopeBody[index];
- estraverse.traverse(blockScopeBodyNode, {
- enter: function enter(node) {
- if (!NodeGuards_1.NodeGuards.isCallExpressionNode(node)) {
- return;
- }
- if (blockScopeBodyNode.parentNode !== NodeUtils_1.NodeUtils.getBlockScopesOfNode(node)[0]) {
- return estraverse.VisitorOption.Skip;
- }
- _this.analyzeCallExpressionNode(stackTraceData, blockScopeBody, node);
- }
- });
- };
- for (var index = 0; index < blockScopeBodyLength; index++) {
- var _ret = _loop(index);
- if (_ret === "break") break;
- }
- return stackTraceData;
- }
- }, {
- key: "analyzeCallExpressionNode",
- value: function analyzeCallExpressionNode(stackTraceData, blockScopeBody, callExpressionNode) {
- var _this2 = this;
- StackTraceAnalyzer_1.calleeDataExtractorsList.forEach(function (calleeDataExtractorName) {
- var calleeData = _this2.calleeDataExtractorFactory(calleeDataExtractorName).extract(blockScopeBody, callExpressionNode.callee);
- if (!calleeData) {
- return;
- }
- stackTraceData.push(Object.assign({}, calleeData, { stackTrace: _this2.analyzeRecursive(calleeData.callee.body) }));
- });
- }
- }], [{
- key: "getLimitIndex",
- value: function getLimitIndex(blockScopeBodyLength) {
- var lastIndex = blockScopeBodyLength - 1;
- var limitThresholdActivationIndex = StackTraceAnalyzer_1.limitThresholdActivationLength - 1;
- var limitIndex = lastIndex;
- if (lastIndex > limitThresholdActivationIndex) {
- limitIndex = Math.round(limitThresholdActivationIndex + lastIndex * StackTraceAnalyzer_1.limitThreshold);
- if (limitIndex > lastIndex) {
- limitIndex = lastIndex;
- }
- }
- return limitIndex;
- }
- }]);
- return StackTraceAnalyzer;
- }();
- StackTraceAnalyzer.calleeDataExtractorsList = [CalleeDataExtractor_1.CalleeDataExtractor.FunctionDeclarationCalleeDataExtractor, CalleeDataExtractor_1.CalleeDataExtractor.FunctionExpressionCalleeDataExtractor, CalleeDataExtractor_1.CalleeDataExtractor.ObjectExpressionCalleeDataExtractor];
- StackTraceAnalyzer.limitThresholdActivationLength = 25;
- StackTraceAnalyzer.limitThreshold = 0.002;
- StackTraceAnalyzer = StackTraceAnalyzer_1 = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__ICalleeDataExtractor)), tslib_1.__metadata("design:paramtypes", [Function])], StackTraceAnalyzer);
- exports.StackTraceAnalyzer = StackTraceAnalyzer;
- var StackTraceAnalyzer_1;
- /***/ }),
- /* 57 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- var InversifyContainerFacade_1 = __webpack_require__(15);
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var ControlFlowReplacer_1 = __webpack_require__(38);
- var NodeTransformer_1 = __webpack_require__(20);
- var BinaryExpressionControlFlowReplacer_1 = __webpack_require__(58);
- var BlockStatementControlFlowTransformer_1 = __webpack_require__(59);
- var CallExpressionControlFlowReplacer_1 = __webpack_require__(60);
- var DeadCodeInjectionTransformer_1 = __webpack_require__(61);
- var FunctionControlFlowTransformer_1 = __webpack_require__(62);
- var LogicalExpressionControlFlowReplacer_1 = __webpack_require__(63);
- var StringLiteralControlFlowReplacer_1 = __webpack_require__(64);
- exports.controlFlowTransformersModule = new inversify_1.ContainerModule(function (bind) {
- bind(ServiceIdentifiers_1.ServiceIdentifiers.INodeTransformer).to(BlockStatementControlFlowTransformer_1.BlockStatementControlFlowTransformer).whenTargetNamed(NodeTransformer_1.NodeTransformer.BlockStatementControlFlowTransformer);
- bind(ServiceIdentifiers_1.ServiceIdentifiers.INodeTransformer).to(DeadCodeInjectionTransformer_1.DeadCodeInjectionTransformer).whenTargetNamed(NodeTransformer_1.NodeTransformer.DeadCodeInjectionTransformer);
- bind(ServiceIdentifiers_1.ServiceIdentifiers.INodeTransformer).to(FunctionControlFlowTransformer_1.FunctionControlFlowTransformer).whenTargetNamed(NodeTransformer_1.NodeTransformer.FunctionControlFlowTransformer);
- bind(ServiceIdentifiers_1.ServiceIdentifiers.IControlFlowReplacer).to(BinaryExpressionControlFlowReplacer_1.BinaryExpressionControlFlowReplacer).whenTargetNamed(ControlFlowReplacer_1.ControlFlowReplacer.BinaryExpressionControlFlowReplacer);
- bind(ServiceIdentifiers_1.ServiceIdentifiers.IControlFlowReplacer).to(CallExpressionControlFlowReplacer_1.CallExpressionControlFlowReplacer).whenTargetNamed(ControlFlowReplacer_1.ControlFlowReplacer.CallExpressionControlFlowReplacer);
- bind(ServiceIdentifiers_1.ServiceIdentifiers.IControlFlowReplacer).to(LogicalExpressionControlFlowReplacer_1.LogicalExpressionControlFlowReplacer).whenTargetNamed(ControlFlowReplacer_1.ControlFlowReplacer.LogicalExpressionControlFlowReplacer);
- bind(ServiceIdentifiers_1.ServiceIdentifiers.IControlFlowReplacer).to(StringLiteralControlFlowReplacer_1.StringLiteralControlFlowReplacer).whenTargetNamed(ControlFlowReplacer_1.ControlFlowReplacer.StringLiteralControlFlowReplacer);
- bind(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IControlFlowReplacer).toFactory(InversifyContainerFacade_1.InversifyContainerFacade.getCacheFactory(ServiceIdentifiers_1.ServiceIdentifiers.IControlFlowReplacer));
- });
- /***/ }),
- /* 58 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var ControlFlowCustomNode_1 = __webpack_require__(13);
- var ExpressionWithOperatorControlFlowReplacer_1 = __webpack_require__(39);
- var BinaryExpressionControlFlowReplacer = BinaryExpressionControlFlowReplacer_1 = function (_ExpressionWithOperat) {
- _inherits(BinaryExpressionControlFlowReplacer, _ExpressionWithOperat);
- function BinaryExpressionControlFlowReplacer(controlFlowCustomNodeFactory, randomGenerator, options) {
- _classCallCheck(this, BinaryExpressionControlFlowReplacer);
- return _possibleConstructorReturn(this, (BinaryExpressionControlFlowReplacer.__proto__ || Object.getPrototypeOf(BinaryExpressionControlFlowReplacer)).call(this, controlFlowCustomNodeFactory, randomGenerator, options));
- }
- _createClass(BinaryExpressionControlFlowReplacer, [{
- key: "replace",
- value: function replace(binaryExpressionNode, parentNode, controlFlowStorage) {
- var replacerId = binaryExpressionNode.operator;
- var binaryExpressionFunctionCustomNode = this.controlFlowCustomNodeFactory(ControlFlowCustomNode_1.ControlFlowCustomNode.BinaryExpressionFunctionNode);
- binaryExpressionFunctionCustomNode.initialize(replacerId);
- var storageKey = this.insertCustomNodeToControlFlowStorage(binaryExpressionFunctionCustomNode, controlFlowStorage, replacerId, BinaryExpressionControlFlowReplacer_1.usingExistingIdentifierChance);
- return this.getControlFlowStorageCallNode(controlFlowStorage.getStorageId(), storageKey, binaryExpressionNode.left, binaryExpressionNode.right);
- }
- }]);
- return BinaryExpressionControlFlowReplacer;
- }(ExpressionWithOperatorControlFlowReplacer_1.ExpressionWithOperatorControlFlowReplacer);
- BinaryExpressionControlFlowReplacer.usingExistingIdentifierChance = 0.5;
- BinaryExpressionControlFlowReplacer = BinaryExpressionControlFlowReplacer_1 = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IControlFlowCustomNode)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object, Object])], BinaryExpressionControlFlowReplacer);
- exports.BinaryExpressionControlFlowReplacer = BinaryExpressionControlFlowReplacer;
- var BinaryExpressionControlFlowReplacer_1;
- /***/ }),
- /* 59 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var estraverse = tslib_1.__importStar(__webpack_require__(10));
- var ControlFlowCustomNode_1 = __webpack_require__(13);
- var TransformationStage_1 = __webpack_require__(6);
- var AbstractNodeTransformer_1 = __webpack_require__(7);
- var NodeGuards_1 = __webpack_require__(3);
- var NodeUtils_1 = __webpack_require__(4);
- var BlockStatementControlFlowTransformer = BlockStatementControlFlowTransformer_1 = function (_AbstractNodeTransfor) {
- _inherits(BlockStatementControlFlowTransformer, _AbstractNodeTransfor);
- function BlockStatementControlFlowTransformer(controlFlowCustomNodeFactory, arrayUtils, randomGenerator, options) {
- _classCallCheck(this, BlockStatementControlFlowTransformer);
- var _this = _possibleConstructorReturn(this, (BlockStatementControlFlowTransformer.__proto__ || Object.getPrototypeOf(BlockStatementControlFlowTransformer)).call(this, randomGenerator, options));
- _this.controlFlowCustomNodeFactory = controlFlowCustomNodeFactory;
- _this.arrayUtils = arrayUtils;
- return _this;
- }
- _createClass(BlockStatementControlFlowTransformer, [{
- key: "getVisitor",
- value: function getVisitor(transformationStage) {
- var _this2 = this;
- switch (transformationStage) {
- case TransformationStage_1.TransformationStage.ControlFlowFlattening:
- return {
- leave: function leave(node, parentNode) {
- if (parentNode && NodeGuards_1.NodeGuards.isBlockStatementNode(node)) {
- return _this2.transformNode(node, parentNode);
- }
- }
- };
- default:
- return null;
- }
- }
- }, {
- key: "transformNode",
- value: function transformNode(blockStatementNode, parentNode) {
- if (this.randomGenerator.getMathRandom() > this.options.controlFlowFlatteningThreshold || !BlockStatementControlFlowTransformer_1.canTransformBlockStatementNode(blockStatementNode)) {
- return blockStatementNode;
- }
- var blockStatementBody = blockStatementNode.body;
- var originalKeys = this.arrayUtils.arrayRange(blockStatementBody.length);
- var shuffledKeys = this.arrayUtils.arrayShuffle(originalKeys);
- var originalKeysIndexesInShuffledArray = originalKeys.map(function (key) {
- return shuffledKeys.indexOf(key);
- });
- var blockStatementControlFlowFlatteningCustomNode = this.controlFlowCustomNodeFactory(ControlFlowCustomNode_1.ControlFlowCustomNode.BlockStatementControlFlowFlatteningNode);
- blockStatementControlFlowFlatteningCustomNode.initialize(blockStatementBody, shuffledKeys, originalKeysIndexesInShuffledArray);
- var newBlockStatementNode = blockStatementControlFlowFlatteningCustomNode.getNode()[0];
- NodeUtils_1.NodeUtils.parentizeNode(newBlockStatementNode, parentNode);
- return newBlockStatementNode;
- }
- }], [{
- key: "blockStatementHasProhibitedStatements",
- value: function blockStatementHasProhibitedStatements(blockStatementNode) {
- return blockStatementNode.body.some(function (statement) {
- var isBreakOrContinueStatement = NodeGuards_1.NodeGuards.isBreakStatementNode(statement) || NodeGuards_1.NodeGuards.isContinueStatementNode(statement);
- var isVariableDeclarationWithLetOrConstKind = NodeGuards_1.NodeGuards.isVariableDeclarationNode(statement) && (statement.kind === 'const' || statement.kind === 'let');
- var isClassDeclaration = NodeGuards_1.NodeGuards.isClassDeclarationNode(statement);
- return NodeGuards_1.NodeGuards.isFunctionDeclarationNode(statement) || isBreakOrContinueStatement || isVariableDeclarationWithLetOrConstKind || isClassDeclaration;
- });
- }
- }, {
- key: "canTransformBlockStatementNode",
- value: function canTransformBlockStatementNode(blockStatementNode) {
- var canTransform = true;
- estraverse.traverse(blockStatementNode, {
- enter: function enter(node) {
- if (NodeGuards_1.NodeGuards.isWhileStatementNode(node)) {
- return estraverse.VisitorOption.Skip;
- }
- if (NodeGuards_1.NodeGuards.isBlockStatementNode(node) && BlockStatementControlFlowTransformer_1.blockStatementHasProhibitedStatements(node)) {
- canTransform = false;
- }
- }
- });
- if (blockStatementNode.body.length <= 4) {
- canTransform = false;
- }
- return canTransform;
- }
- }]);
- return BlockStatementControlFlowTransformer;
- }(AbstractNodeTransformer_1.AbstractNodeTransformer);
- BlockStatementControlFlowTransformer = BlockStatementControlFlowTransformer_1 = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IControlFlowCustomNode)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IArrayUtils)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(3, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object, Object, Object])], BlockStatementControlFlowTransformer);
- exports.BlockStatementControlFlowTransformer = BlockStatementControlFlowTransformer;
- var BlockStatementControlFlowTransformer_1;
- /***/ }),
- /* 60 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var ControlFlowCustomNode_1 = __webpack_require__(13);
- var AbstractControlFlowReplacer_1 = __webpack_require__(31);
- var NodeGuards_1 = __webpack_require__(3);
- var CallExpressionControlFlowReplacer = CallExpressionControlFlowReplacer_1 = function (_AbstractControlFlowR) {
- _inherits(CallExpressionControlFlowReplacer, _AbstractControlFlowR);
- function CallExpressionControlFlowReplacer(controlFlowCustomNodeFactory, randomGenerator, options) {
- _classCallCheck(this, CallExpressionControlFlowReplacer);
- return _possibleConstructorReturn(this, (CallExpressionControlFlowReplacer.__proto__ || Object.getPrototypeOf(CallExpressionControlFlowReplacer)).call(this, controlFlowCustomNodeFactory, randomGenerator, options));
- }
- _createClass(CallExpressionControlFlowReplacer, [{
- key: "replace",
- value: function replace(callExpressionNode, parentNode, controlFlowStorage) {
- var callee = callExpressionNode.callee;
- if (!NodeGuards_1.NodeGuards.isIdentifierNode(callee)) {
- return callExpressionNode;
- }
- var replacerId = String(callExpressionNode.arguments.length);
- var callExpressionFunctionCustomNode = this.controlFlowCustomNodeFactory(ControlFlowCustomNode_1.ControlFlowCustomNode.CallExpressionFunctionNode);
- var expressionArguments = callExpressionNode.arguments;
- callExpressionFunctionCustomNode.initialize(expressionArguments);
- var storageKey = this.insertCustomNodeToControlFlowStorage(callExpressionFunctionCustomNode, controlFlowStorage, replacerId, CallExpressionControlFlowReplacer_1.usingExistingIdentifierChance);
- return this.getControlFlowStorageCallNode(controlFlowStorage.getStorageId(), storageKey, callee, expressionArguments);
- }
- }, {
- key: "getControlFlowStorageCallNode",
- value: function getControlFlowStorageCallNode(controlFlowStorageId, storageKey, callee, expressionArguments) {
- var controlFlowStorageCallCustomNode = this.controlFlowCustomNodeFactory(ControlFlowCustomNode_1.ControlFlowCustomNode.CallExpressionControlFlowStorageCallNode);
- controlFlowStorageCallCustomNode.initialize(controlFlowStorageId, storageKey, callee, expressionArguments);
- var statementNode = controlFlowStorageCallCustomNode.getNode()[0];
- if (!statementNode || !NodeGuards_1.NodeGuards.isExpressionStatementNode(statementNode)) {
- throw new Error("`controlFlowStorageCallCustomNode.getNode()[0]` should returns array with `ExpressionStatement` node");
- }
- return statementNode.expression;
- }
- }]);
- return CallExpressionControlFlowReplacer;
- }(AbstractControlFlowReplacer_1.AbstractControlFlowReplacer);
- CallExpressionControlFlowReplacer.usingExistingIdentifierChance = 0.5;
- CallExpressionControlFlowReplacer = CallExpressionControlFlowReplacer_1 = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IControlFlowCustomNode)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object, Object])], CallExpressionControlFlowReplacer);
- exports.CallExpressionControlFlowReplacer = CallExpressionControlFlowReplacer;
- var CallExpressionControlFlowReplacer_1;
- /***/ }),
- /* 61 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var estraverse = tslib_1.__importStar(__webpack_require__(10));
- var DeadCodeInjectionCustomNode_1 = __webpack_require__(40);
- var NodeTransformer_1 = __webpack_require__(20);
- var NodeType_1 = __webpack_require__(11);
- var TransformationStage_1 = __webpack_require__(6);
- var AbstractNodeTransformer_1 = __webpack_require__(7);
- var NodeGuards_1 = __webpack_require__(3);
- var Nodes_1 = __webpack_require__(9);
- var NodeUtils_1 = __webpack_require__(4);
- var DeadCodeInjectionTransformer = DeadCodeInjectionTransformer_1 = function (_AbstractNodeTransfor) {
- _inherits(DeadCodeInjectionTransformer, _AbstractNodeTransfor);
- function DeadCodeInjectionTransformer(deadCodeInjectionCustomNodeFactory, transformersRunner, randomGenerator, options) {
- _classCallCheck(this, DeadCodeInjectionTransformer);
- var _this = _possibleConstructorReturn(this, (DeadCodeInjectionTransformer.__proto__ || Object.getPrototypeOf(DeadCodeInjectionTransformer)).call(this, randomGenerator, options));
- _this.deadCodeInjectionRootAstHostNodeSet = new Set();
- _this.collectedBlockStatements = [];
- _this.collectedBlockStatementsTotalLength = 0;
- _this.deadCodeInjectionCustomNodeFactory = deadCodeInjectionCustomNodeFactory;
- _this.transformersRunner = transformersRunner;
- return _this;
- }
- _createClass(DeadCodeInjectionTransformer, [{
- key: "getVisitor",
- value: function getVisitor(transformationStage) {
- var _this2 = this;
- switch (transformationStage) {
- case TransformationStage_1.TransformationStage.DeadCodeInjection:
- return {
- enter: function enter(node, parentNode) {
- if (parentNode && NodeGuards_1.NodeGuards.isProgramNode(node)) {
- _this2.analyzeNode(node, parentNode);
- return node;
- }
- },
- leave: function leave(node, parentNode) {
- if (parentNode && NodeGuards_1.NodeGuards.isBlockStatementNode(node)) {
- return _this2.transformNode(node, parentNode);
- }
- }
- };
- case TransformationStage_1.TransformationStage.Finalizing:
- if (!this.deadCodeInjectionRootAstHostNodeSet.size) {
- return null;
- }
- return {
- enter: function enter(node, parentNode) {
- if (parentNode && _this2.isDeadCodeInjectionRootAstHostNode(node)) {
- return _this2.restoreNode(node, parentNode);
- }
- }
- };
- default:
- return null;
- }
- }
- }, {
- key: "analyzeNode",
- value: function analyzeNode(programNode, parentNode) {
- var _this3 = this;
- estraverse.traverse(programNode, {
- enter: function enter(node) {
- if (!NodeGuards_1.NodeGuards.isBlockStatementNode(node)) {
- return;
- }
- var clonedBlockStatementNode = NodeUtils_1.NodeUtils.clone(node);
- if (!DeadCodeInjectionTransformer_1.isValidBlockStatementNode(clonedBlockStatementNode)) {
- return;
- }
- NodeUtils_1.NodeUtils.parentizeNode(clonedBlockStatementNode, clonedBlockStatementNode);
- clonedBlockStatementNode = _this3.transformersRunner.transform(clonedBlockStatementNode, DeadCodeInjectionTransformer_1.transformersToRenameBlockScopeIdentifiers, TransformationStage_1.TransformationStage.Obfuscating);
- _this3.collectedBlockStatements.push(clonedBlockStatementNode);
- }
- });
- this.collectedBlockStatementsTotalLength = this.collectedBlockStatements.length;
- }
- }, {
- key: "transformNode",
- value: function transformNode(blockStatementNode, parentNode) {
- if (this.collectedBlockStatementsTotalLength < DeadCodeInjectionTransformer_1.minCollectedBlockStatementsCount) {
- return estraverse.VisitorOption.Break;
- }
- if (!this.collectedBlockStatements.length) {
- return estraverse.VisitorOption.Break;
- }
- if (this.randomGenerator.getMathRandom() > this.options.deadCodeInjectionThreshold) {
- return blockStatementNode;
- }
- var blockScopeOfBlockStatementNode = NodeUtils_1.NodeUtils.getBlockScopesOfNode(blockStatementNode)[0];
- if (blockScopeOfBlockStatementNode.type === NodeType_1.NodeType.Program) {
- return blockStatementNode;
- }
- var minInteger = 0;
- var maxInteger = this.collectedBlockStatements.length - 1;
- var randomIndex = this.randomGenerator.getRandomInteger(minInteger, maxInteger);
- var randomBlockStatementNode = this.collectedBlockStatements.splice(randomIndex, 1)[0];
- if (randomBlockStatementNode === blockStatementNode) {
- return blockStatementNode;
- }
- return this.replaceBlockStatementNode(blockStatementNode, randomBlockStatementNode, parentNode);
- }
- }, {
- key: "restoreNode",
- value: function restoreNode(deadCodeInjectionRootAstHostNode, parentNode) {
- var hostNodeFirstStatement = deadCodeInjectionRootAstHostNode.body[0];
- if (!NodeGuards_1.NodeGuards.isFunctionDeclarationNode(hostNodeFirstStatement)) {
- throw new Error('Wrong dead code injection root AST host node. Host node should contain `FunctionDeclaration` node');
- }
- return hostNodeFirstStatement.body;
- }
- }, {
- key: "isDeadCodeInjectionRootAstHostNode",
- value: function isDeadCodeInjectionRootAstHostNode(node) {
- return NodeGuards_1.NodeGuards.isBlockStatementNode(node) && this.deadCodeInjectionRootAstHostNodeSet.has(node);
- }
- }, {
- key: "replaceBlockStatementNode",
- value: function replaceBlockStatementNode(blockStatementNode, randomBlockStatementNode, parentNode) {
- var deadCodeInjectionRootAstHostNode = Nodes_1.Nodes.getBlockStatementNode([Nodes_1.Nodes.getFunctionDeclarationNode(DeadCodeInjectionTransformer_1.deadCodeInjectionRootAstHostNodeName, [], randomBlockStatementNode)]);
- this.deadCodeInjectionRootAstHostNodeSet.add(deadCodeInjectionRootAstHostNode);
- var blockStatementDeadCodeInjectionCustomNode = this.deadCodeInjectionCustomNodeFactory(DeadCodeInjectionCustomNode_1.DeadCodeInjectionCustomNode.BlockStatementDeadCodeInjectionNode);
- blockStatementDeadCodeInjectionCustomNode.initialize(blockStatementNode, deadCodeInjectionRootAstHostNode);
- var newBlockStatementNode = blockStatementDeadCodeInjectionCustomNode.getNode()[0];
- NodeUtils_1.NodeUtils.parentizeNode(newBlockStatementNode, parentNode);
- return newBlockStatementNode;
- }
- }], [{
- key: "isValidBlockStatementNode",
- value: function isValidBlockStatementNode(blockStatementNode) {
- var isProhibitedNode = function isProhibitedNode(node) {
- return NodeGuards_1.NodeGuards.isBreakStatementNode(node) || NodeGuards_1.NodeGuards.isContinueStatementNode(node) || NodeGuards_1.NodeGuards.isAwaitExpressionNode(node) || NodeGuards_1.NodeGuards.isSuperNode(node);
- };
- var nestedBlockStatementsCount = 0;
- var isValidBlockStatementNode = true;
- estraverse.traverse(blockStatementNode, {
- enter: function enter(node) {
- if (NodeGuards_1.NodeGuards.isBlockStatementNode(node)) {
- nestedBlockStatementsCount++;
- }
- if (nestedBlockStatementsCount > DeadCodeInjectionTransformer_1.maxNestedBlockStatementsCount || isProhibitedNode(node)) {
- isValidBlockStatementNode = false;
- return estraverse.VisitorOption.Break;
- }
- }
- });
- return isValidBlockStatementNode;
- }
- }]);
- return DeadCodeInjectionTransformer;
- }(AbstractNodeTransformer_1.AbstractNodeTransformer);
- DeadCodeInjectionTransformer.deadCodeInjectionRootAstHostNodeName = 'deadCodeInjectionRootAstHostNode';
- DeadCodeInjectionTransformer.maxNestedBlockStatementsCount = 4;
- DeadCodeInjectionTransformer.minCollectedBlockStatementsCount = 5;
- DeadCodeInjectionTransformer.transformersToRenameBlockScopeIdentifiers = [NodeTransformer_1.NodeTransformer.CatchClauseTransformer, NodeTransformer_1.NodeTransformer.ClassDeclarationTransformer, NodeTransformer_1.NodeTransformer.FunctionDeclarationTransformer, NodeTransformer_1.NodeTransformer.FunctionTransformer, NodeTransformer_1.NodeTransformer.LabeledStatementTransformer, NodeTransformer_1.NodeTransformer.VariableDeclarationTransformer];
- DeadCodeInjectionTransformer = DeadCodeInjectionTransformer_1 = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IDeadCodeInjectionCustomNode)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.ITransformersRunner)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(3, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object, Object, Object])], DeadCodeInjectionTransformer);
- exports.DeadCodeInjectionTransformer = DeadCodeInjectionTransformer;
- var DeadCodeInjectionTransformer_1;
- /***/ }),
- /* 62 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var estraverse = tslib_1.__importStar(__webpack_require__(10));
- var ControlFlowCustomNode_1 = __webpack_require__(13);
- var ControlFlowReplacer_1 = __webpack_require__(38);
- var NodeType_1 = __webpack_require__(11);
- var TransformationStage_1 = __webpack_require__(6);
- var AbstractNodeTransformer_1 = __webpack_require__(7);
- var NodeGuards_1 = __webpack_require__(3);
- var NodeAppender_1 = __webpack_require__(16);
- var NodeUtils_1 = __webpack_require__(4);
- var FunctionControlFlowTransformer = FunctionControlFlowTransformer_1 = function (_AbstractNodeTransfor) {
- _inherits(FunctionControlFlowTransformer, _AbstractNodeTransfor);
- function FunctionControlFlowTransformer(controlFlowStorageFactory, controlFlowReplacerFactory, controlFlowCustomNodeFactory, randomGenerator, options) {
- _classCallCheck(this, FunctionControlFlowTransformer);
- var _this = _possibleConstructorReturn(this, (FunctionControlFlowTransformer.__proto__ || Object.getPrototypeOf(FunctionControlFlowTransformer)).call(this, randomGenerator, options));
- _this.controlFlowData = new Map();
- _this.visitedFunctionNodes = new Set();
- _this.hostNodesWithControlFlowNode = new Set();
- _this.controlFlowStorageFactory = controlFlowStorageFactory;
- _this.controlFlowReplacerFactory = controlFlowReplacerFactory;
- _this.controlFlowCustomNodeFactory = controlFlowCustomNodeFactory;
- return _this;
- }
- _createClass(FunctionControlFlowTransformer, [{
- key: "getVisitor",
- value: function getVisitor(transformationStage) {
- var _this2 = this;
- switch (transformationStage) {
- case TransformationStage_1.TransformationStage.ControlFlowFlattening:
- return {
- leave: function leave(node, parentNode) {
- if (parentNode && (NodeGuards_1.NodeGuards.isFunctionDeclarationNode(node) || NodeGuards_1.NodeGuards.isFunctionExpressionNode(node) || NodeGuards_1.NodeGuards.isArrowFunctionExpressionNode(node))) {
- return _this2.transformNode(node, parentNode);
- }
- }
- };
- default:
- return null;
- }
- }
- }, {
- key: "transformNode",
- value: function transformNode(functionNode, parentNode) {
- this.visitedFunctionNodes.add(functionNode);
- if (!NodeGuards_1.NodeGuards.isBlockStatementNode(functionNode.body)) {
- return functionNode;
- }
- var hostNode = this.getHostNode(functionNode.body);
- var controlFlowStorage = this.getControlFlowStorage(hostNode);
- this.controlFlowData.set(hostNode, controlFlowStorage);
- this.transformFunctionBody(functionNode.body, controlFlowStorage);
- if (!controlFlowStorage.getLength()) {
- return functionNode;
- }
- var controlFlowStorageCustomNode = this.controlFlowCustomNodeFactory(ControlFlowCustomNode_1.ControlFlowCustomNode.ControlFlowStorageNode);
- controlFlowStorageCustomNode.initialize(controlFlowStorage);
- NodeAppender_1.NodeAppender.prependNode(hostNode, controlFlowStorageCustomNode.getNode());
- this.hostNodesWithControlFlowNode.add(hostNode);
- return functionNode;
- }
- }, {
- key: "getControlFlowStorage",
- value: function getControlFlowStorage(hostNode) {
- var controlFlowStorage = this.controlFlowStorageFactory();
- if (this.controlFlowData.has(hostNode)) {
- if (this.hostNodesWithControlFlowNode.has(hostNode)) {
- hostNode.body.shift();
- }
- var hostControlFlowStorage = this.controlFlowData.get(hostNode);
- controlFlowStorage.mergeWith(hostControlFlowStorage, true);
- }
- return controlFlowStorage;
- }
- }, {
- key: "getHostNode",
- value: function getHostNode(functionNodeBody) {
- var blockScopesOfNode = NodeUtils_1.NodeUtils.getBlockScopesOfNode(functionNodeBody);
- if (blockScopesOfNode.length === 1) {
- return functionNodeBody;
- } else {
- blockScopesOfNode.pop();
- }
- if (blockScopesOfNode.length > FunctionControlFlowTransformer_1.hostNodeSearchMinDepth) {
- blockScopesOfNode.splice(0, FunctionControlFlowTransformer_1.hostNodeSearchMinDepth);
- }
- if (blockScopesOfNode.length > FunctionControlFlowTransformer_1.hostNodeSearchMaxDepth) {
- blockScopesOfNode.length = FunctionControlFlowTransformer_1.hostNodeSearchMaxDepth;
- }
- return this.randomGenerator.getRandomGenerator().pickone(blockScopesOfNode);
- }
- }, {
- key: "isVisitedFunctionNode",
- value: function isVisitedFunctionNode(node) {
- return (NodeGuards_1.NodeGuards.isFunctionDeclarationNode(node) || NodeGuards_1.NodeGuards.isFunctionExpressionNode(node) || NodeGuards_1.NodeGuards.isArrowFunctionExpressionNode(node)) && this.visitedFunctionNodes.has(node);
- }
- }, {
- key: "transformFunctionBody",
- value: function transformFunctionBody(functionNodeBody, controlFlowStorage) {
- var _this3 = this;
- estraverse.replace(functionNodeBody, {
- enter: function enter(node, parentNode) {
- if (node.ignoredNode) {
- return estraverse.VisitorOption.Skip;
- }
- if (_this3.isVisitedFunctionNode(node) || !parentNode) {
- return estraverse.VisitorOption.Skip;
- }
- if (!FunctionControlFlowTransformer_1.controlFlowReplacersMap.has(node.type)) {
- return node;
- }
- if (_this3.randomGenerator.getMathRandom() > _this3.options.controlFlowFlatteningThreshold) {
- return node;
- }
- var controlFlowReplacerName = FunctionControlFlowTransformer_1.controlFlowReplacersMap.get(node.type);
- if (controlFlowReplacerName === undefined) {
- return node;
- }
- return Object.assign({}, _this3.controlFlowReplacerFactory(controlFlowReplacerName).replace(node, parentNode, controlFlowStorage), { parentNode: parentNode });
- }
- });
- }
- }]);
- return FunctionControlFlowTransformer;
- }(AbstractNodeTransformer_1.AbstractNodeTransformer);
- FunctionControlFlowTransformer.controlFlowReplacersMap = new Map([[NodeType_1.NodeType.BinaryExpression, ControlFlowReplacer_1.ControlFlowReplacer.BinaryExpressionControlFlowReplacer], [NodeType_1.NodeType.CallExpression, ControlFlowReplacer_1.ControlFlowReplacer.CallExpressionControlFlowReplacer], [NodeType_1.NodeType.LogicalExpression, ControlFlowReplacer_1.ControlFlowReplacer.LogicalExpressionControlFlowReplacer], [NodeType_1.NodeType.Literal, ControlFlowReplacer_1.ControlFlowReplacer.StringLiteralControlFlowReplacer]]);
- FunctionControlFlowTransformer.hostNodeSearchMinDepth = 0;
- FunctionControlFlowTransformer.hostNodeSearchMaxDepth = 2;
- FunctionControlFlowTransformer = FunctionControlFlowTransformer_1 = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__TControlFlowStorage)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IControlFlowReplacer)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IControlFlowCustomNode)), tslib_1.__param(3, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(4, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Function, Function, Object, Object])], FunctionControlFlowTransformer);
- exports.FunctionControlFlowTransformer = FunctionControlFlowTransformer;
- var FunctionControlFlowTransformer_1;
- /***/ }),
- /* 63 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var ControlFlowCustomNode_1 = __webpack_require__(13);
- var ExpressionWithOperatorControlFlowReplacer_1 = __webpack_require__(39);
- var NodeGuards_1 = __webpack_require__(3);
- var NodeUtils_1 = __webpack_require__(4);
- var LogicalExpressionControlFlowReplacer = LogicalExpressionControlFlowReplacer_1 = function (_ExpressionWithOperat) {
- _inherits(LogicalExpressionControlFlowReplacer, _ExpressionWithOperat);
- function LogicalExpressionControlFlowReplacer(controlFlowCustomNodeFactory, randomGenerator, options) {
- _classCallCheck(this, LogicalExpressionControlFlowReplacer);
- return _possibleConstructorReturn(this, (LogicalExpressionControlFlowReplacer.__proto__ || Object.getPrototypeOf(LogicalExpressionControlFlowReplacer)).call(this, controlFlowCustomNodeFactory, randomGenerator, options));
- }
- _createClass(LogicalExpressionControlFlowReplacer, [{
- key: "replace",
- value: function replace(logicalExpressionNode, parentNode, controlFlowStorage) {
- if (this.checkForProhibitedExpressions(logicalExpressionNode.left, logicalExpressionNode.right)) {
- return logicalExpressionNode;
- }
- var replacerId = logicalExpressionNode.operator;
- var logicalExpressionFunctionCustomNode = this.controlFlowCustomNodeFactory(ControlFlowCustomNode_1.ControlFlowCustomNode.LogicalExpressionFunctionNode);
- logicalExpressionFunctionCustomNode.initialize(replacerId);
- var storageKey = this.insertCustomNodeToControlFlowStorage(logicalExpressionFunctionCustomNode, controlFlowStorage, replacerId, LogicalExpressionControlFlowReplacer_1.usingExistingIdentifierChance);
- return this.getControlFlowStorageCallNode(controlFlowStorage.getStorageId(), storageKey, logicalExpressionNode.left, logicalExpressionNode.right);
- }
- }, {
- key: "checkForProhibitedExpressions",
- value: function checkForProhibitedExpressions(leftExpression, rightExpression) {
- return [leftExpression, rightExpression].some(function (expressionNode) {
- var nodeForCheck = void 0;
- if (!NodeGuards_1.NodeGuards.isUnaryExpressionNode(expressionNode)) {
- nodeForCheck = expressionNode;
- } else {
- nodeForCheck = NodeUtils_1.NodeUtils.getUnaryExpressionArgumentNode(expressionNode);
- }
- return !NodeGuards_1.NodeGuards.isLiteralNode(nodeForCheck) && !NodeGuards_1.NodeGuards.isIdentifierNode(nodeForCheck) && !NodeGuards_1.NodeGuards.isObjectExpressionNode(nodeForCheck) && !NodeGuards_1.NodeGuards.isExpressionStatementNode(nodeForCheck);
- });
- }
- }]);
- return LogicalExpressionControlFlowReplacer;
- }(ExpressionWithOperatorControlFlowReplacer_1.ExpressionWithOperatorControlFlowReplacer);
- LogicalExpressionControlFlowReplacer.usingExistingIdentifierChance = 0.5;
- LogicalExpressionControlFlowReplacer = LogicalExpressionControlFlowReplacer_1 = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IControlFlowCustomNode)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object, Object])], LogicalExpressionControlFlowReplacer);
- exports.LogicalExpressionControlFlowReplacer = LogicalExpressionControlFlowReplacer;
- var LogicalExpressionControlFlowReplacer_1;
- /***/ }),
- /* 64 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var ControlFlowCustomNode_1 = __webpack_require__(13);
- var AbstractControlFlowReplacer_1 = __webpack_require__(31);
- var NodeGuards_1 = __webpack_require__(3);
- var StringLiteralControlFlowReplacer = StringLiteralControlFlowReplacer_1 = function (_AbstractControlFlowR) {
- _inherits(StringLiteralControlFlowReplacer, _AbstractControlFlowR);
- function StringLiteralControlFlowReplacer(controlFlowCustomNodeFactory, randomGenerator, options) {
- _classCallCheck(this, StringLiteralControlFlowReplacer);
- return _possibleConstructorReturn(this, (StringLiteralControlFlowReplacer.__proto__ || Object.getPrototypeOf(StringLiteralControlFlowReplacer)).call(this, controlFlowCustomNodeFactory, randomGenerator, options));
- }
- _createClass(StringLiteralControlFlowReplacer, [{
- key: "replace",
- value: function replace(literalNode, parentNode, controlFlowStorage) {
- if (NodeGuards_1.NodeGuards.isPropertyNode(parentNode) && parentNode.key === literalNode) {
- return literalNode;
- }
- if (typeof literalNode.value !== 'string' || literalNode.value.length < 3) {
- return literalNode;
- }
- var replacerId = String(literalNode.value);
- var literalFunctionCustomNode = this.controlFlowCustomNodeFactory(ControlFlowCustomNode_1.ControlFlowCustomNode.StringLiteralNode);
- literalFunctionCustomNode.initialize(literalNode.value);
- var storageKey = this.insertCustomNodeToControlFlowStorage(literalFunctionCustomNode, controlFlowStorage, replacerId, StringLiteralControlFlowReplacer_1.usingExistingIdentifierChance);
- return this.getControlFlowStorageCallNode(controlFlowStorage.getStorageId(), storageKey);
- }
- }, {
- key: "getControlFlowStorageCallNode",
- value: function getControlFlowStorageCallNode(controlFlowStorageId, storageKey) {
- var controlFlowStorageCallCustomNode = this.controlFlowCustomNodeFactory(ControlFlowCustomNode_1.ControlFlowCustomNode.StringLiteralControlFlowStorageCallNode);
- controlFlowStorageCallCustomNode.initialize(controlFlowStorageId, storageKey);
- var statementNode = controlFlowStorageCallCustomNode.getNode()[0];
- if (!statementNode || !NodeGuards_1.NodeGuards.isExpressionStatementNode(statementNode)) {
- throw new Error("`controlFlowStorageCallCustomNode.getNode()[0]` should returns array with `ExpressionStatement` node");
- }
- return statementNode.expression;
- }
- }]);
- return StringLiteralControlFlowReplacer;
- }(AbstractControlFlowReplacer_1.AbstractControlFlowReplacer);
- StringLiteralControlFlowReplacer.usingExistingIdentifierChance = 1;
- StringLiteralControlFlowReplacer = StringLiteralControlFlowReplacer_1 = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IControlFlowCustomNode)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object, Object])], StringLiteralControlFlowReplacer);
- exports.StringLiteralControlFlowReplacer = StringLiteralControlFlowReplacer;
- var StringLiteralControlFlowReplacer_1;
- /***/ }),
- /* 65 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var NodeTransformer_1 = __webpack_require__(20);
- var MemberExpressionTransformer_1 = __webpack_require__(66);
- var MethodDefinitionTransformer_1 = __webpack_require__(67);
- var ObjectExpressionKeysTransformer_1 = __webpack_require__(68);
- var TemplateLiteralTransformer_1 = __webpack_require__(69);
- exports.convertingTransformersModule = new inversify_1.ContainerModule(function (bind) {
- bind(ServiceIdentifiers_1.ServiceIdentifiers.INodeTransformer).to(MemberExpressionTransformer_1.MemberExpressionTransformer).whenTargetNamed(NodeTransformer_1.NodeTransformer.MemberExpressionTransformer);
- bind(ServiceIdentifiers_1.ServiceIdentifiers.INodeTransformer).to(MethodDefinitionTransformer_1.MethodDefinitionTransformer).whenTargetNamed(NodeTransformer_1.NodeTransformer.MethodDefinitionTransformer);
- bind(ServiceIdentifiers_1.ServiceIdentifiers.INodeTransformer).to(ObjectExpressionKeysTransformer_1.ObjectExpressionKeysTransformer).whenTargetNamed(NodeTransformer_1.NodeTransformer.ObjectExpressionKeysTransformer);
- bind(ServiceIdentifiers_1.ServiceIdentifiers.INodeTransformer).to(TemplateLiteralTransformer_1.TemplateLiteralTransformer).whenTargetNamed(NodeTransformer_1.NodeTransformer.TemplateLiteralTransformer);
- });
- /***/ }),
- /* 66 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var NodeType_1 = __webpack_require__(11);
- var TransformationStage_1 = __webpack_require__(6);
- var AbstractNodeTransformer_1 = __webpack_require__(7);
- var NodeGuards_1 = __webpack_require__(3);
- var MemberExpressionTransformer = function (_AbstractNodeTransfor) {
- _inherits(MemberExpressionTransformer, _AbstractNodeTransfor);
- function MemberExpressionTransformer(randomGenerator, options) {
- _classCallCheck(this, MemberExpressionTransformer);
- return _possibleConstructorReturn(this, (MemberExpressionTransformer.__proto__ || Object.getPrototypeOf(MemberExpressionTransformer)).call(this, randomGenerator, options));
- }
- _createClass(MemberExpressionTransformer, [{
- key: "getVisitor",
- value: function getVisitor(transformationStage) {
- var _this2 = this;
- switch (transformationStage) {
- case TransformationStage_1.TransformationStage.Converting:
- return {
- enter: function enter(node, parentNode) {
- if (parentNode && NodeGuards_1.NodeGuards.isMemberExpressionNode(node)) {
- return _this2.transformNode(node, parentNode);
- }
- }
- };
- default:
- return null;
- }
- }
- }, {
- key: "transformNode",
- value: function transformNode(memberExpressionNode, parentNode) {
- if (NodeGuards_1.NodeGuards.isIdentifierNode(memberExpressionNode.property)) {
- if (memberExpressionNode.computed) {
- return memberExpressionNode;
- }
- memberExpressionNode.computed = true;
- memberExpressionNode.property = {
- type: NodeType_1.NodeType.Literal,
- value: memberExpressionNode.property.name,
- raw: "'" + memberExpressionNode.property.name + "'"
- };
- }
- return memberExpressionNode;
- }
- }]);
- return MemberExpressionTransformer;
- }(AbstractNodeTransformer_1.AbstractNodeTransformer);
- MemberExpressionTransformer = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Object, Object])], MemberExpressionTransformer);
- exports.MemberExpressionTransformer = MemberExpressionTransformer;
- /***/ }),
- /* 67 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var NodeType_1 = __webpack_require__(11);
- var TransformationStage_1 = __webpack_require__(6);
- var AbstractNodeTransformer_1 = __webpack_require__(7);
- var NodeGuards_1 = __webpack_require__(3);
- var MethodDefinitionTransformer = MethodDefinitionTransformer_1 = function (_AbstractNodeTransfor) {
- _inherits(MethodDefinitionTransformer, _AbstractNodeTransfor);
- function MethodDefinitionTransformer(randomGenerator, options) {
- _classCallCheck(this, MethodDefinitionTransformer);
- return _possibleConstructorReturn(this, (MethodDefinitionTransformer.__proto__ || Object.getPrototypeOf(MethodDefinitionTransformer)).call(this, randomGenerator, options));
- }
- _createClass(MethodDefinitionTransformer, [{
- key: "getVisitor",
- value: function getVisitor(transformationStage) {
- var _this2 = this;
- switch (transformationStage) {
- case TransformationStage_1.TransformationStage.Converting:
- return {
- enter: function enter(node, parentNode) {
- if (parentNode && NodeGuards_1.NodeGuards.isMethodDefinitionNode(node)) {
- return _this2.transformNode(node, parentNode);
- }
- }
- };
- default:
- return null;
- }
- }
- }, {
- key: "transformNode",
- value: function transformNode(methodDefinitionNode, parentNode) {
- if (NodeGuards_1.NodeGuards.isIdentifierNode(methodDefinitionNode.key) && !(MethodDefinitionTransformer_1.ignoredNames.indexOf(methodDefinitionNode.key.name) !== -1) && methodDefinitionNode.computed === false) {
- methodDefinitionNode.computed = true;
- methodDefinitionNode.key = {
- type: NodeType_1.NodeType.Literal,
- value: methodDefinitionNode.key.name,
- raw: "'" + methodDefinitionNode.key.name + "'"
- };
- }
- return methodDefinitionNode;
- }
- }]);
- return MethodDefinitionTransformer;
- }(AbstractNodeTransformer_1.AbstractNodeTransformer);
- MethodDefinitionTransformer.ignoredNames = ['constructor'];
- MethodDefinitionTransformer = MethodDefinitionTransformer_1 = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Object, Object])], MethodDefinitionTransformer);
- exports.MethodDefinitionTransformer = MethodDefinitionTransformer;
- var MethodDefinitionTransformer_1;
- /***/ }),
- /* 68 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _slicedToArray = (function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; })();
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var TransformationStage_1 = __webpack_require__(6);
- var AbstractNodeTransformer_1 = __webpack_require__(7);
- var NodeAppender_1 = __webpack_require__(16);
- var NodeGuards_1 = __webpack_require__(3);
- var Nodes_1 = __webpack_require__(9);
- var NodeUtils_1 = __webpack_require__(4);
- var ObjectExpressionKeysTransformer = ObjectExpressionKeysTransformer_1 = function (_AbstractNodeTransfor) {
- _inherits(ObjectExpressionKeysTransformer, _AbstractNodeTransfor);
- function ObjectExpressionKeysTransformer(randomGenerator, options) {
- _classCallCheck(this, ObjectExpressionKeysTransformer);
- var _this = _possibleConstructorReturn(this, (ObjectExpressionKeysTransformer.__proto__ || Object.getPrototypeOf(ObjectExpressionKeysTransformer)).call(this, randomGenerator, options));
- _this.cachedScopeNodesMap = new Map();
- return _this;
- }
- _createClass(ObjectExpressionKeysTransformer, [{
- key: "getVisitor",
- value: function getVisitor(transformationStage) {
- var _this2 = this;
- switch (transformationStage) {
- case TransformationStage_1.TransformationStage.Converting:
- return {
- enter: function enter(node, parentNode) {
- if (_this2.options.transformObjectKeys && parentNode && NodeGuards_1.NodeGuards.isObjectExpressionNode(node) && NodeGuards_1.NodeGuards.isVariableDeclaratorNode(parentNode)) {
- return _this2.transformNode(node, parentNode);
- }
- }
- };
- default:
- return null;
- }
- }
- }, {
- key: "transformNode",
- value: function transformNode(objectExpressionNode, variableDeclarator) {
- if (!NodeGuards_1.NodeGuards.isIdentifierNode(variableDeclarator.id)) {
- return objectExpressionNode;
- }
- var scopeNode = NodeUtils_1.NodeUtils.getScopeOfNode(variableDeclarator);
- if (!scopeNode || !NodeGuards_1.NodeGuards.isNodeHasScope(scopeNode)) {
- return objectExpressionNode;
- }
- this.cachedScopeNodesMap.set(variableDeclarator, scopeNode);
- return this.transformObjectExpressionNode(objectExpressionNode, variableDeclarator.id, variableDeclarator);
- }
- }, {
- key: "extractPropertiesToExpressionStatements",
- value: function extractPropertiesToExpressionStatements(properties, memberExpressionObject, variableDeclarator) {
- var propertiesLength = properties.length;
- var expressionStatements = [];
- var removablePropertyIds = [];
- for (var i = 0; i < propertiesLength; i++) {
- var property = properties[i];
- var propertyValue = property.value;
- if (!ObjectExpressionKeysTransformer_1.isValidPropertyValueNode(propertyValue)) {
- continue;
- }
- var propertyKeyName = ObjectExpressionKeysTransformer_1.getPropertyNodeKeyName(property);
- if (!propertyKeyName) {
- continue;
- }
- var shouldCreateLiteralNode = !property.computed || property.computed && NodeGuards_1.NodeGuards.isLiteralNode(property.key);
- var memberExpressionProperty = shouldCreateLiteralNode ? Nodes_1.Nodes.getLiteralNode(propertyKeyName) : Nodes_1.Nodes.getIdentifierNode(propertyKeyName);
- var memberExpressionNode = Nodes_1.Nodes.getMemberExpressionNode(memberExpressionObject, memberExpressionProperty, true);
- var expressionStatementNode = Nodes_1.Nodes.getExpressionStatementNode(Nodes_1.Nodes.getAssignmentExpressionNode('=', memberExpressionNode, propertyValue));
- if (NodeGuards_1.NodeGuards.isObjectExpressionNode(property.value)) {
- this.transformObjectExpressionNode(property.value, memberExpressionNode, variableDeclarator);
- }
- expressionStatements.push(expressionStatementNode);
- removablePropertyIds.push(i);
- }
- return [expressionStatements, removablePropertyIds];
- }
- }, {
- key: "transformObjectExpressionNode",
- value: function transformObjectExpressionNode(objectExpressionNode, memberExpressionObjectNode, variableDeclarator) {
- var properties = objectExpressionNode.properties;
- if (!properties.length) {
- return objectExpressionNode;
- }
- var scopeNode = this.cachedScopeNodesMap.get(variableDeclarator);
- if (!scopeNode) {
- return objectExpressionNode;
- }
- var _extractPropertiesToE = this.extractPropertiesToExpressionStatements(properties, memberExpressionObjectNode, variableDeclarator),
- _extractPropertiesToE2 = _slicedToArray(_extractPropertiesToE, 2),
- expressionStatements = _extractPropertiesToE2[0],
- removablePropertyIds = _extractPropertiesToE2[1];
- objectExpressionNode.properties = ObjectExpressionKeysTransformer_1.filterObjectExpressionProperties(properties, removablePropertyIds);
- ObjectExpressionKeysTransformer_1.appendExpressionStatements(scopeNode, expressionStatements, variableDeclarator);
- return objectExpressionNode;
- }
- }], [{
- key: "appendExpressionStatements",
- value: function appendExpressionStatements(scopeNode, expressionStatements, variableDeclarator) {
- var variableDeclaration = variableDeclarator.parentNode;
- if (!variableDeclaration || !NodeGuards_1.NodeGuards.isVariableDeclarationNode(variableDeclaration)) {
- throw new Error('Cannot find variable declaration for variable declarator');
- }
- NodeAppender_1.NodeAppender.insertNodeAfter(scopeNode, expressionStatements, variableDeclaration);
- }
- }, {
- key: "filterObjectExpressionProperties",
- value: function filterObjectExpressionProperties(properties, removablePropertyIds) {
- return properties.filter(function (property, index) {
- return !(removablePropertyIds.indexOf(index) !== -1);
- });
- }
- }, {
- key: "getPropertyNodeKeyName",
- value: function getPropertyNodeKeyName(propertyNode) {
- var propertyKeyNode = propertyNode.key;
- if (NodeGuards_1.NodeGuards.isLiteralNode(propertyKeyNode) && typeof propertyKeyNode.value === 'string') {
- return propertyKeyNode.value;
- } else if (NodeGuards_1.NodeGuards.isIdentifierNode(propertyKeyNode)) {
- return propertyKeyNode.name;
- }
- return null;
- }
- }, {
- key: "isValidPropertyValueNode",
- value: function isValidPropertyValueNode(propertyValueNode) {
- return !NodeGuards_1.NodeGuards.isObjectPatternNode(propertyValueNode) && !NodeGuards_1.NodeGuards.isArrayPatternNode(propertyValueNode) && !NodeGuards_1.NodeGuards.isAssignmentPatternNode(propertyValueNode) && !NodeGuards_1.NodeGuards.isRestElementNode(propertyValueNode);
- }
- }]);
- return ObjectExpressionKeysTransformer;
- }(AbstractNodeTransformer_1.AbstractNodeTransformer);
- ObjectExpressionKeysTransformer = ObjectExpressionKeysTransformer_1 = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Object, Object])], ObjectExpressionKeysTransformer);
- exports.ObjectExpressionKeysTransformer = ObjectExpressionKeysTransformer;
- var ObjectExpressionKeysTransformer_1;
- /***/ }),
- /* 69 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var TransformationStage_1 = __webpack_require__(6);
- var AbstractNodeTransformer_1 = __webpack_require__(7);
- var NodeGuards_1 = __webpack_require__(3);
- var Nodes_1 = __webpack_require__(9);
- var TemplateLiteralTransformer = TemplateLiteralTransformer_1 = function (_AbstractNodeTransfor) {
- _inherits(TemplateLiteralTransformer, _AbstractNodeTransfor);
- function TemplateLiteralTransformer(randomGenerator, options) {
- _classCallCheck(this, TemplateLiteralTransformer);
- return _possibleConstructorReturn(this, (TemplateLiteralTransformer.__proto__ || Object.getPrototypeOf(TemplateLiteralTransformer)).call(this, randomGenerator, options));
- }
- _createClass(TemplateLiteralTransformer, [{
- key: "getVisitor",
- value: function getVisitor(transformationStage) {
- var _this2 = this;
- switch (transformationStage) {
- case TransformationStage_1.TransformationStage.Converting:
- return {
- enter: function enter(node, parentNode) {
- if (parentNode && NodeGuards_1.NodeGuards.isTemplateLiteralNode(node)) {
- return _this2.transformNode(node, parentNode);
- }
- }
- };
- default:
- return null;
- }
- }
- }, {
- key: "transformNode",
- value: function transformNode(templateLiteralNode, parentNode) {
- var templateLiteralExpressions = templateLiteralNode.expressions;
- var nodes = [];
- templateLiteralNode.quasis.forEach(function (templateElement) {
- nodes.push(Nodes_1.Nodes.getLiteralNode(templateElement.value.cooked));
- var expression = templateLiteralExpressions.shift();
- if (!expression) {
- return;
- }
- nodes.push(expression);
- });
- nodes = nodes.filter(function (node) {
- return !(NodeGuards_1.NodeGuards.isLiteralNode(node) && node.value === '');
- });
- if (!TemplateLiteralTransformer_1.isLiteralNodeWithStringValue(nodes[0]) && !TemplateLiteralTransformer_1.isLiteralNodeWithStringValue(nodes[1])) {
- nodes.unshift(Nodes_1.Nodes.getLiteralNode(''));
- }
- if (nodes.length > 1) {
- var root = Nodes_1.Nodes.getBinaryExpressionNode('+', nodes.shift(), nodes.shift());
- nodes.forEach(function (node) {
- root = Nodes_1.Nodes.getBinaryExpressionNode('+', root, node);
- });
- return root;
- }
- return nodes[0];
- }
- }], [{
- key: "isLiteralNodeWithStringValue",
- value: function isLiteralNodeWithStringValue(node) {
- return node && NodeGuards_1.NodeGuards.isLiteralNode(node) && typeof node.value === 'string';
- }
- }]);
- return TemplateLiteralTransformer;
- }(AbstractNodeTransformer_1.AbstractNodeTransformer);
- TemplateLiteralTransformer = TemplateLiteralTransformer_1 = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Object, Object])], TemplateLiteralTransformer);
- exports.TemplateLiteralTransformer = TemplateLiteralTransformer;
- var TemplateLiteralTransformer_1;
- /***/ }),
- /* 70 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- var InversifyContainerFacade_1 = __webpack_require__(15);
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var ControlFlowCustomNode_1 = __webpack_require__(13);
- var CustomNode_1 = __webpack_require__(21);
- var CustomNodeGroup_1 = __webpack_require__(41);
- var DeadCodeInjectionCustomNode_1 = __webpack_require__(40);
- var ConsoleOutputCustomNodeGroup_1 = __webpack_require__(71);
- var DebugProtectionCustomNodeGroup_1 = __webpack_require__(72);
- var DomainLockCustomNodeGroup_1 = __webpack_require__(73);
- var SelfDefendingCustomNodeGroup_1 = __webpack_require__(74);
- var StringArrayCustomNodeGroup_1 = __webpack_require__(75);
- var BinaryExpressionFunctionNode_1 = __webpack_require__(76);
- var BlockStatementControlFlowFlatteningNode_1 = __webpack_require__(79);
- var BlockStatementDeadCodeInjectionNode_1 = __webpack_require__(80);
- var CallExpressionControlFlowStorageCallNode_1 = __webpack_require__(81);
- var CallExpressionFunctionNode_1 = __webpack_require__(82);
- var ControlFlowStorageNode_1 = __webpack_require__(83);
- var ConsoleOutputDisableExpressionNode_1 = __webpack_require__(84);
- var DebugProtectionFunctionCallNode_1 = __webpack_require__(86);
- var DebugProtectionFunctionIntervalNode_1 = __webpack_require__(88);
- var DebugProtectionFunctionNode_1 = __webpack_require__(90);
- var DomainLockNode_1 = __webpack_require__(94);
- var ExpressionWithOperatorControlFlowStorageCallNode_1 = __webpack_require__(96);
- var LogicalExpressionFunctionNode_1 = __webpack_require__(97);
- var NodeCallsControllerFunctionNode_1 = __webpack_require__(98);
- var SelfDefendingUnicodeNode_1 = __webpack_require__(100);
- var StringArrayCallsWrapper_1 = __webpack_require__(102);
- var StringArrayNode_1 = __webpack_require__(109);
- var StringArrayRotateFunctionNode_1 = __webpack_require__(111);
- var StringLiteralControlFlowStorageCallNode_1 = __webpack_require__(115);
- var StringLiteralNode_1 = __webpack_require__(116);
- exports.customNodesModule = new inversify_1.ContainerModule(function (bind) {
- bind(ServiceIdentifiers_1.ServiceIdentifiers.ICustomNode).to(ConsoleOutputDisableExpressionNode_1.ConsoleOutputDisableExpressionNode).whenTargetNamed(CustomNode_1.CustomNode.ConsoleOutputDisableExpressionNode);
- bind(ServiceIdentifiers_1.ServiceIdentifiers.ICustomNode).to(DebugProtectionFunctionCallNode_1.DebugProtectionFunctionCallNode).whenTargetNamed(CustomNode_1.CustomNode.DebugProtectionFunctionCallNode);
- bind(ServiceIdentifiers_1.ServiceIdentifiers.ICustomNode).to(DebugProtectionFunctionIntervalNode_1.DebugProtectionFunctionIntervalNode).whenTargetNamed(CustomNode_1.CustomNode.DebugProtectionFunctionIntervalNode);
- bind(ServiceIdentifiers_1.ServiceIdentifiers.ICustomNode).to(DebugProtectionFunctionNode_1.DebugProtectionFunctionNode).whenTargetNamed(CustomNode_1.CustomNode.DebugProtectionFunctionNode);
- bind(ServiceIdentifiers_1.ServiceIdentifiers.ICustomNode).to(DomainLockNode_1.DomainLockNode).whenTargetNamed(CustomNode_1.CustomNode.DomainLockNode);
- bind(ServiceIdentifiers_1.ServiceIdentifiers.ICustomNode).to(NodeCallsControllerFunctionNode_1.NodeCallsControllerFunctionNode).whenTargetNamed(CustomNode_1.CustomNode.NodeCallsControllerFunctionNode);
- bind(ServiceIdentifiers_1.ServiceIdentifiers.ICustomNode).to(SelfDefendingUnicodeNode_1.SelfDefendingUnicodeNode).whenTargetNamed(CustomNode_1.CustomNode.SelfDefendingUnicodeNode);
- bind(ServiceIdentifiers_1.ServiceIdentifiers.ICustomNode).to(StringArrayCallsWrapper_1.StringArrayCallsWrapper).whenTargetNamed(CustomNode_1.CustomNode.StringArrayCallsWrapper);
- bind(ServiceIdentifiers_1.ServiceIdentifiers.ICustomNode).to(StringArrayNode_1.StringArrayNode).whenTargetNamed(CustomNode_1.CustomNode.StringArrayNode);
- bind(ServiceIdentifiers_1.ServiceIdentifiers.ICustomNode).to(StringArrayRotateFunctionNode_1.StringArrayRotateFunctionNode).whenTargetNamed(CustomNode_1.CustomNode.StringArrayRotateFunctionNode);
- bind(ServiceIdentifiers_1.ServiceIdentifiers.Newable__ICustomNode).toConstructor(BinaryExpressionFunctionNode_1.BinaryExpressionFunctionNode).whenTargetNamed(ControlFlowCustomNode_1.ControlFlowCustomNode.BinaryExpressionFunctionNode);
- bind(ServiceIdentifiers_1.ServiceIdentifiers.Newable__ICustomNode).toConstructor(BlockStatementControlFlowFlatteningNode_1.BlockStatementControlFlowFlatteningNode).whenTargetNamed(ControlFlowCustomNode_1.ControlFlowCustomNode.BlockStatementControlFlowFlatteningNode);
- bind(ServiceIdentifiers_1.ServiceIdentifiers.Newable__ICustomNode).toConstructor(CallExpressionControlFlowStorageCallNode_1.CallExpressionControlFlowStorageCallNode).whenTargetNamed(ControlFlowCustomNode_1.ControlFlowCustomNode.CallExpressionControlFlowStorageCallNode);
- bind(ServiceIdentifiers_1.ServiceIdentifiers.Newable__ICustomNode).toConstructor(CallExpressionFunctionNode_1.CallExpressionFunctionNode).whenTargetNamed(ControlFlowCustomNode_1.ControlFlowCustomNode.CallExpressionFunctionNode);
- bind(ServiceIdentifiers_1.ServiceIdentifiers.Newable__ICustomNode).toConstructor(ControlFlowStorageNode_1.ControlFlowStorageNode).whenTargetNamed(ControlFlowCustomNode_1.ControlFlowCustomNode.ControlFlowStorageNode);
- bind(ServiceIdentifiers_1.ServiceIdentifiers.Newable__ICustomNode).toConstructor(ExpressionWithOperatorControlFlowStorageCallNode_1.ExpressionWithOperatorControlFlowStorageCallNode).whenTargetNamed(ControlFlowCustomNode_1.ControlFlowCustomNode.ExpressionWithOperatorControlFlowStorageCallNode);
- bind(ServiceIdentifiers_1.ServiceIdentifiers.Newable__ICustomNode).toConstructor(LogicalExpressionFunctionNode_1.LogicalExpressionFunctionNode).whenTargetNamed(ControlFlowCustomNode_1.ControlFlowCustomNode.LogicalExpressionFunctionNode);
- bind(ServiceIdentifiers_1.ServiceIdentifiers.Newable__ICustomNode).toConstructor(StringLiteralNode_1.StringLiteralNode).whenTargetNamed(ControlFlowCustomNode_1.ControlFlowCustomNode.StringLiteralNode);
- bind(ServiceIdentifiers_1.ServiceIdentifiers.Newable__ICustomNode).toConstructor(StringLiteralControlFlowStorageCallNode_1.StringLiteralControlFlowStorageCallNode).whenTargetNamed(ControlFlowCustomNode_1.ControlFlowCustomNode.StringLiteralControlFlowStorageCallNode);
- bind(ServiceIdentifiers_1.ServiceIdentifiers.Newable__ICustomNode).toConstructor(BlockStatementDeadCodeInjectionNode_1.BlockStatementDeadCodeInjectionNode).whenTargetNamed(DeadCodeInjectionCustomNode_1.DeadCodeInjectionCustomNode.BlockStatementDeadCodeInjectionNode);
- bind(ServiceIdentifiers_1.ServiceIdentifiers.ICustomNodeGroup).to(ConsoleOutputCustomNodeGroup_1.ConsoleOutputCustomNodeGroup).whenTargetNamed(CustomNodeGroup_1.CustomNodeGroup.ConsoleOutputCustomNodeGroup);
- bind(ServiceIdentifiers_1.ServiceIdentifiers.ICustomNodeGroup).to(DebugProtectionCustomNodeGroup_1.DebugProtectionCustomNodeGroup).whenTargetNamed(CustomNodeGroup_1.CustomNodeGroup.DebugProtectionCustomNodeGroup);
- bind(ServiceIdentifiers_1.ServiceIdentifiers.ICustomNodeGroup).to(DomainLockCustomNodeGroup_1.DomainLockCustomNodeGroup).whenTargetNamed(CustomNodeGroup_1.CustomNodeGroup.DomainLockCustomNodeGroup);
- bind(ServiceIdentifiers_1.ServiceIdentifiers.ICustomNodeGroup).to(SelfDefendingCustomNodeGroup_1.SelfDefendingCustomNodeGroup).whenTargetNamed(CustomNodeGroup_1.CustomNodeGroup.SelfDefendingCustomNodeGroup);
- bind(ServiceIdentifiers_1.ServiceIdentifiers.ICustomNodeGroup).to(StringArrayCustomNodeGroup_1.StringArrayCustomNodeGroup).whenTargetNamed(CustomNodeGroup_1.CustomNodeGroup.StringArrayCustomNodeGroup);
- bind(ServiceIdentifiers_1.ServiceIdentifiers.Factory__ICustomNode).toFactory(InversifyContainerFacade_1.InversifyContainerFacade.getFactory(ServiceIdentifiers_1.ServiceIdentifiers.ICustomNode));
- bind(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IControlFlowCustomNode).toFactory(InversifyContainerFacade_1.InversifyContainerFacade.getConstructorFactory(ServiceIdentifiers_1.ServiceIdentifiers.Newable__ICustomNode, ServiceIdentifiers_1.ServiceIdentifiers.Factory__IIdentifierNamesGenerator, ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator, ServiceIdentifiers_1.ServiceIdentifiers.IOptions));
- bind(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IDeadCodeInjectionCustomNode).toFactory(InversifyContainerFacade_1.InversifyContainerFacade.getConstructorFactory(ServiceIdentifiers_1.ServiceIdentifiers.Newable__ICustomNode, ServiceIdentifiers_1.ServiceIdentifiers.Factory__IIdentifierNamesGenerator, ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator, ServiceIdentifiers_1.ServiceIdentifiers.IOptions));
- bind(ServiceIdentifiers_1.ServiceIdentifiers.Factory__ICustomNodeGroup).toFactory(InversifyContainerFacade_1.InversifyContainerFacade.getFactory(ServiceIdentifiers_1.ServiceIdentifiers.ICustomNodeGroup));
- });
- /***/ }),
- /* 71 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var Initializable_1 = __webpack_require__(5);
- var CustomNode_1 = __webpack_require__(21);
- var ObfuscationEvent_1 = __webpack_require__(17);
- var AbstractCustomNodeGroup_1 = __webpack_require__(23);
- var NodeAppender_1 = __webpack_require__(16);
- var ConsoleOutputCustomNodeGroup = function (_AbstractCustomNodeGr) {
- _inherits(ConsoleOutputCustomNodeGroup, _AbstractCustomNodeGr);
- function ConsoleOutputCustomNodeGroup(customNodeFactory, identifierNamesGeneratorFactory, randomGenerator, options) {
- _classCallCheck(this, ConsoleOutputCustomNodeGroup);
- var _this = _possibleConstructorReturn(this, (ConsoleOutputCustomNodeGroup.__proto__ || Object.getPrototypeOf(ConsoleOutputCustomNodeGroup)).call(this, identifierNamesGeneratorFactory, randomGenerator, options));
- _this.appendEvent = ObfuscationEvent_1.ObfuscationEvent.BeforeObfuscation;
- _this.customNodeFactory = customNodeFactory;
- return _this;
- }
- _createClass(ConsoleOutputCustomNodeGroup, [{
- key: "appendCustomNodes",
- value: function appendCustomNodes(blockScopeNode, stackTraceData) {
- var randomStackTraceIndex = this.getRandomStackTraceIndex(stackTraceData.length);
- this.appendCustomNodeIfExist(CustomNode_1.CustomNode.ConsoleOutputDisableExpressionNode, function (customNode) {
- NodeAppender_1.NodeAppender.appendNodeToOptimalBlockScope(stackTraceData, blockScopeNode, customNode.getNode(), randomStackTraceIndex);
- });
- this.appendCustomNodeIfExist(CustomNode_1.CustomNode.NodeCallsControllerFunctionNode, function (customNode) {
- var targetBlockScope = void 0;
- if (stackTraceData.length) {
- targetBlockScope = NodeAppender_1.NodeAppender.getOptimalBlockScope(stackTraceData, randomStackTraceIndex, 1);
- } else {
- targetBlockScope = blockScopeNode;
- }
- NodeAppender_1.NodeAppender.prependNode(targetBlockScope, customNode.getNode());
- });
- }
- }, {
- key: "initialize",
- value: function initialize() {
- this.customNodes = new Map();
- if (!this.options.disableConsoleOutput) {
- return;
- }
- var callsControllerFunctionName = this.identifierNamesGenerator.generate();
- var consoleOutputDisableExpressionNode = this.customNodeFactory(CustomNode_1.CustomNode.ConsoleOutputDisableExpressionNode);
- var nodeCallsControllerFunctionNode = this.customNodeFactory(CustomNode_1.CustomNode.NodeCallsControllerFunctionNode);
- consoleOutputDisableExpressionNode.initialize(callsControllerFunctionName);
- nodeCallsControllerFunctionNode.initialize(this.appendEvent, callsControllerFunctionName);
- this.customNodes.set(CustomNode_1.CustomNode.ConsoleOutputDisableExpressionNode, consoleOutputDisableExpressionNode);
- this.customNodes.set(CustomNode_1.CustomNode.NodeCallsControllerFunctionNode, nodeCallsControllerFunctionNode);
- }
- }]);
- return ConsoleOutputCustomNodeGroup;
- }(AbstractCustomNodeGroup_1.AbstractCustomNodeGroup);
- tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", Map)], ConsoleOutputCustomNodeGroup.prototype, "customNodes", void 0);
- ConsoleOutputCustomNodeGroup = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__ICustomNode)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IIdentifierNamesGenerator)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(3, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Function, Object, Object])], ConsoleOutputCustomNodeGroup);
- exports.ConsoleOutputCustomNodeGroup = ConsoleOutputCustomNodeGroup;
- /***/ }),
- /* 72 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var Initializable_1 = __webpack_require__(5);
- var CustomNode_1 = __webpack_require__(21);
- var ObfuscationEvent_1 = __webpack_require__(17);
- var AbstractCustomNodeGroup_1 = __webpack_require__(23);
- var NodeAppender_1 = __webpack_require__(16);
- var DebugProtectionCustomNodeGroup = function (_AbstractCustomNodeGr) {
- _inherits(DebugProtectionCustomNodeGroup, _AbstractCustomNodeGr);
- function DebugProtectionCustomNodeGroup(customNodeFactory, identifierNamesGeneratorFactory, randomGenerator, options) {
- _classCallCheck(this, DebugProtectionCustomNodeGroup);
- var _this = _possibleConstructorReturn(this, (DebugProtectionCustomNodeGroup.__proto__ || Object.getPrototypeOf(DebugProtectionCustomNodeGroup)).call(this, identifierNamesGeneratorFactory, randomGenerator, options));
- _this.appendEvent = ObfuscationEvent_1.ObfuscationEvent.BeforeObfuscation;
- _this.customNodeFactory = customNodeFactory;
- return _this;
- }
- _createClass(DebugProtectionCustomNodeGroup, [{
- key: "appendCustomNodes",
- value: function appendCustomNodes(blockScopeNode, stackTraceData) {
- var _this2 = this;
- var randomStackTraceIndex = this.getRandomStackTraceIndex(stackTraceData.length);
- this.appendCustomNodeIfExist(CustomNode_1.CustomNode.DebugProtectionFunctionCallNode, function (customNode) {
- NodeAppender_1.NodeAppender.appendNodeToOptimalBlockScope(stackTraceData, blockScopeNode, customNode.getNode(), randomStackTraceIndex);
- });
- this.appendCustomNodeIfExist(CustomNode_1.CustomNode.DebugProtectionFunctionNode, function (customNode) {
- NodeAppender_1.NodeAppender.appendNode(blockScopeNode, customNode.getNode());
- });
- this.appendCustomNodeIfExist(CustomNode_1.CustomNode.DebugProtectionFunctionIntervalNode, function (customNode) {
- var programBodyLength = blockScopeNode.body.length;
- var randomIndex = _this2.randomGenerator.getRandomInteger(0, programBodyLength);
- NodeAppender_1.NodeAppender.insertNodeAtIndex(blockScopeNode, customNode.getNode(), randomIndex);
- });
- this.appendCustomNodeIfExist(CustomNode_1.CustomNode.NodeCallsControllerFunctionNode, function (customNode) {
- var targetBlockScope = void 0;
- if (stackTraceData.length) {
- targetBlockScope = NodeAppender_1.NodeAppender.getOptimalBlockScope(stackTraceData, randomStackTraceIndex, 1);
- } else {
- targetBlockScope = blockScopeNode;
- }
- NodeAppender_1.NodeAppender.prependNode(targetBlockScope, customNode.getNode());
- });
- }
- }, {
- key: "initialize",
- value: function initialize() {
- this.customNodes = new Map();
- if (!this.options.debugProtection) {
- return;
- }
- var debugProtectionFunctionName = this.identifierNamesGenerator.generate();
- var callsControllerFunctionName = this.identifierNamesGenerator.generate();
- var debugProtectionFunctionNode = this.customNodeFactory(CustomNode_1.CustomNode.DebugProtectionFunctionNode);
- var debugProtectionFunctionCallNode = this.customNodeFactory(CustomNode_1.CustomNode.DebugProtectionFunctionCallNode);
- var debugProtectionFunctionIntervalNode = this.customNodeFactory(CustomNode_1.CustomNode.DebugProtectionFunctionIntervalNode);
- var nodeCallsControllerFunctionNode = this.customNodeFactory(CustomNode_1.CustomNode.NodeCallsControllerFunctionNode);
- debugProtectionFunctionNode.initialize(debugProtectionFunctionName);
- debugProtectionFunctionCallNode.initialize(debugProtectionFunctionName, callsControllerFunctionName);
- debugProtectionFunctionIntervalNode.initialize(debugProtectionFunctionName);
- nodeCallsControllerFunctionNode.initialize(this.appendEvent, callsControllerFunctionName);
- this.customNodes.set(CustomNode_1.CustomNode.DebugProtectionFunctionNode, debugProtectionFunctionNode);
- this.customNodes.set(CustomNode_1.CustomNode.DebugProtectionFunctionCallNode, debugProtectionFunctionCallNode);
- if (this.options.debugProtectionInterval) {
- this.customNodes.set(CustomNode_1.CustomNode.DebugProtectionFunctionIntervalNode, debugProtectionFunctionIntervalNode);
- }
- this.customNodes.set(CustomNode_1.CustomNode.NodeCallsControllerFunctionNode, nodeCallsControllerFunctionNode);
- }
- }]);
- return DebugProtectionCustomNodeGroup;
- }(AbstractCustomNodeGroup_1.AbstractCustomNodeGroup);
- tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", Map)], DebugProtectionCustomNodeGroup.prototype, "customNodes", void 0);
- DebugProtectionCustomNodeGroup = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__ICustomNode)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IIdentifierNamesGenerator)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(3, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Function, Object, Object])], DebugProtectionCustomNodeGroup);
- exports.DebugProtectionCustomNodeGroup = DebugProtectionCustomNodeGroup;
- /***/ }),
- /* 73 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var Initializable_1 = __webpack_require__(5);
- var CustomNode_1 = __webpack_require__(21);
- var ObfuscationEvent_1 = __webpack_require__(17);
- var AbstractCustomNodeGroup_1 = __webpack_require__(23);
- var NodeAppender_1 = __webpack_require__(16);
- var DomainLockCustomNodeGroup = function (_AbstractCustomNodeGr) {
- _inherits(DomainLockCustomNodeGroup, _AbstractCustomNodeGr);
- function DomainLockCustomNodeGroup(customNodeFactory, identifierNamesGeneratorFactory, randomGenerator, options) {
- _classCallCheck(this, DomainLockCustomNodeGroup);
- var _this = _possibleConstructorReturn(this, (DomainLockCustomNodeGroup.__proto__ || Object.getPrototypeOf(DomainLockCustomNodeGroup)).call(this, identifierNamesGeneratorFactory, randomGenerator, options));
- _this.appendEvent = ObfuscationEvent_1.ObfuscationEvent.BeforeObfuscation;
- _this.customNodeFactory = customNodeFactory;
- return _this;
- }
- _createClass(DomainLockCustomNodeGroup, [{
- key: "appendCustomNodes",
- value: function appendCustomNodes(blockScopeNode, stackTraceData) {
- var randomStackTraceIndex = this.getRandomStackTraceIndex(stackTraceData.length);
- this.appendCustomNodeIfExist(CustomNode_1.CustomNode.DomainLockNode, function (customNode) {
- NodeAppender_1.NodeAppender.appendNodeToOptimalBlockScope(stackTraceData, blockScopeNode, customNode.getNode(), randomStackTraceIndex);
- });
- this.appendCustomNodeIfExist(CustomNode_1.CustomNode.NodeCallsControllerFunctionNode, function (customNode) {
- var targetBlockScope = void 0;
- if (stackTraceData.length) {
- targetBlockScope = NodeAppender_1.NodeAppender.getOptimalBlockScope(stackTraceData, randomStackTraceIndex, 1);
- } else {
- targetBlockScope = blockScopeNode;
- }
- NodeAppender_1.NodeAppender.prependNode(targetBlockScope, customNode.getNode());
- });
- }
- }, {
- key: "initialize",
- value: function initialize() {
- this.customNodes = new Map();
- if (!this.options.domainLock.length) {
- return;
- }
- var callsControllerFunctionName = this.identifierNamesGenerator.generate();
- var domainLockNode = this.customNodeFactory(CustomNode_1.CustomNode.DomainLockNode);
- var nodeCallsControllerFunctionNode = this.customNodeFactory(CustomNode_1.CustomNode.NodeCallsControllerFunctionNode);
- domainLockNode.initialize(callsControllerFunctionName);
- nodeCallsControllerFunctionNode.initialize(this.appendEvent, callsControllerFunctionName);
- this.customNodes.set(CustomNode_1.CustomNode.DomainLockNode, domainLockNode);
- this.customNodes.set(CustomNode_1.CustomNode.NodeCallsControllerFunctionNode, nodeCallsControllerFunctionNode);
- }
- }]);
- return DomainLockCustomNodeGroup;
- }(AbstractCustomNodeGroup_1.AbstractCustomNodeGroup);
- tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", Map)], DomainLockCustomNodeGroup.prototype, "customNodes", void 0);
- DomainLockCustomNodeGroup = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__ICustomNode)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IIdentifierNamesGenerator)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(3, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Function, Object, Object])], DomainLockCustomNodeGroup);
- exports.DomainLockCustomNodeGroup = DomainLockCustomNodeGroup;
- /***/ }),
- /* 74 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var Initializable_1 = __webpack_require__(5);
- var CustomNode_1 = __webpack_require__(21);
- var ObfuscationEvent_1 = __webpack_require__(17);
- var AbstractCustomNodeGroup_1 = __webpack_require__(23);
- var NodeAppender_1 = __webpack_require__(16);
- var SelfDefendingCustomNodeGroup = function (_AbstractCustomNodeGr) {
- _inherits(SelfDefendingCustomNodeGroup, _AbstractCustomNodeGr);
- function SelfDefendingCustomNodeGroup(customNodeFactory, identifierNamesGeneratorFactory, randomGenerator, options) {
- _classCallCheck(this, SelfDefendingCustomNodeGroup);
- var _this = _possibleConstructorReturn(this, (SelfDefendingCustomNodeGroup.__proto__ || Object.getPrototypeOf(SelfDefendingCustomNodeGroup)).call(this, identifierNamesGeneratorFactory, randomGenerator, options));
- _this.appendEvent = ObfuscationEvent_1.ObfuscationEvent.AfterObfuscation;
- _this.customNodeFactory = customNodeFactory;
- return _this;
- }
- _createClass(SelfDefendingCustomNodeGroup, [{
- key: "appendCustomNodes",
- value: function appendCustomNodes(blockScopeNode, stackTraceData) {
- var randomStackTraceIndex = this.getRandomStackTraceIndex(stackTraceData.length);
- this.appendCustomNodeIfExist(CustomNode_1.CustomNode.SelfDefendingUnicodeNode, function (customNode) {
- NodeAppender_1.NodeAppender.appendNodeToOptimalBlockScope(stackTraceData, blockScopeNode, customNode.getNode(), randomStackTraceIndex);
- });
- this.appendCustomNodeIfExist(CustomNode_1.CustomNode.NodeCallsControllerFunctionNode, function (customNode) {
- var targetBlockScope = void 0;
- if (stackTraceData.length) {
- targetBlockScope = NodeAppender_1.NodeAppender.getOptimalBlockScope(stackTraceData, randomStackTraceIndex, 1);
- } else {
- targetBlockScope = blockScopeNode;
- }
- NodeAppender_1.NodeAppender.prependNode(targetBlockScope, customNode.getNode());
- });
- }
- }, {
- key: "initialize",
- value: function initialize() {
- this.customNodes = new Map();
- if (!this.options.selfDefending) {
- return;
- }
- var callsControllerFunctionName = this.identifierNamesGenerator.generate();
- var selfDefendingUnicodeNode = this.customNodeFactory(CustomNode_1.CustomNode.SelfDefendingUnicodeNode);
- var nodeCallsControllerFunctionNode = this.customNodeFactory(CustomNode_1.CustomNode.NodeCallsControllerFunctionNode);
- selfDefendingUnicodeNode.initialize(callsControllerFunctionName);
- nodeCallsControllerFunctionNode.initialize(this.appendEvent, callsControllerFunctionName);
- this.customNodes.set(CustomNode_1.CustomNode.SelfDefendingUnicodeNode, selfDefendingUnicodeNode);
- this.customNodes.set(CustomNode_1.CustomNode.NodeCallsControllerFunctionNode, nodeCallsControllerFunctionNode);
- }
- }]);
- return SelfDefendingCustomNodeGroup;
- }(AbstractCustomNodeGroup_1.AbstractCustomNodeGroup);
- tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", Map)], SelfDefendingCustomNodeGroup.prototype, "customNodes", void 0);
- SelfDefendingCustomNodeGroup = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__ICustomNode)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IIdentifierNamesGenerator)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(3, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Function, Object, Object])], SelfDefendingCustomNodeGroup);
- exports.SelfDefendingCustomNodeGroup = SelfDefendingCustomNodeGroup;
- /***/ }),
- /* 75 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _slicedToArray = (function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; })();
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var Initializable_1 = __webpack_require__(5);
- var CustomNode_1 = __webpack_require__(21);
- var ObfuscationEvent_1 = __webpack_require__(17);
- var AbstractCustomNodeGroup_1 = __webpack_require__(23);
- var NodeAppender_1 = __webpack_require__(16);
- var StringArrayCustomNodeGroup = function (_AbstractCustomNodeGr) {
- _inherits(StringArrayCustomNodeGroup, _AbstractCustomNodeGr);
- function StringArrayCustomNodeGroup(customNodeFactory, stringArrayStorage, identifierNamesGeneratorFactory, randomGenerator, options) {
- _classCallCheck(this, StringArrayCustomNodeGroup);
- var _this = _possibleConstructorReturn(this, (StringArrayCustomNodeGroup.__proto__ || Object.getPrototypeOf(StringArrayCustomNodeGroup)).call(this, identifierNamesGeneratorFactory, randomGenerator, options));
- _this.appendEvent = ObfuscationEvent_1.ObfuscationEvent.AfterObfuscation;
- _this.customNodeFactory = customNodeFactory;
- _this.stringArrayStorage = stringArrayStorage;
- return _this;
- }
- _createClass(StringArrayCustomNodeGroup, [{
- key: "appendCustomNodes",
- value: function appendCustomNodes(blockScopeNode, stackTraceData) {
- if (!this.stringArrayStorage.getLength()) {
- return;
- }
- this.appendCustomNodeIfExist(CustomNode_1.CustomNode.StringArrayNode, function (customNode) {
- NodeAppender_1.NodeAppender.prependNode(blockScopeNode, customNode.getNode());
- });
- this.appendCustomNodeIfExist(CustomNode_1.CustomNode.StringArrayCallsWrapper, function (customNode) {
- NodeAppender_1.NodeAppender.insertNodeAtIndex(blockScopeNode, customNode.getNode(), 1);
- });
- this.appendCustomNodeIfExist(CustomNode_1.CustomNode.StringArrayRotateFunctionNode, function (customNode) {
- NodeAppender_1.NodeAppender.insertNodeAtIndex(blockScopeNode, customNode.getNode(), 1);
- });
- }
- }, {
- key: "initialize",
- value: function initialize() {
- this.customNodes = new Map();
- if (!this.options.stringArray) {
- return;
- }
- var stringArrayNode = this.customNodeFactory(CustomNode_1.CustomNode.StringArrayNode);
- var stringArrayCallsWrapper = this.customNodeFactory(CustomNode_1.CustomNode.StringArrayCallsWrapper);
- var stringArrayRotateFunctionNode = this.customNodeFactory(CustomNode_1.CustomNode.StringArrayRotateFunctionNode);
- var stringArrayStorageId = this.stringArrayStorage.getStorageId();
- var _stringArrayStorageId = stringArrayStorageId.split('|'),
- _stringArrayStorageId2 = _slicedToArray(_stringArrayStorageId, 2),
- stringArrayName = _stringArrayStorageId2[0],
- stringArrayCallsWrapperName = _stringArrayStorageId2[1];
- var stringArrayRotateValue = void 0;
- if (this.options.rotateStringArray) {
- stringArrayRotateValue = this.randomGenerator.getRandomInteger(100, 500);
- } else {
- stringArrayRotateValue = 0;
- }
- stringArrayNode.initialize(this.stringArrayStorage, stringArrayName, stringArrayRotateValue);
- stringArrayCallsWrapper.initialize(stringArrayName, stringArrayCallsWrapperName);
- stringArrayRotateFunctionNode.initialize(stringArrayName, stringArrayRotateValue);
- this.customNodes.set(CustomNode_1.CustomNode.StringArrayNode, stringArrayNode);
- this.customNodes.set(CustomNode_1.CustomNode.StringArrayCallsWrapper, stringArrayCallsWrapper);
- if (this.options.rotateStringArray) {
- this.customNodes.set(CustomNode_1.CustomNode.StringArrayRotateFunctionNode, stringArrayRotateFunctionNode);
- }
- }
- }]);
- return StringArrayCustomNodeGroup;
- }(AbstractCustomNodeGroup_1.AbstractCustomNodeGroup);
- tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", Map)], StringArrayCustomNodeGroup.prototype, "customNodes", void 0);
- StringArrayCustomNodeGroup = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__ICustomNode)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.TStringArrayStorage)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IIdentifierNamesGenerator)), tslib_1.__param(3, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(4, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object, Function, Object, Object])], StringArrayCustomNodeGroup);
- exports.StringArrayCustomNodeGroup = StringArrayCustomNodeGroup;
- /***/ }),
- /* 76 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var Initializable_1 = __webpack_require__(5);
- var AbstractCustomNode_1 = __webpack_require__(8);
- var Nodes_1 = __webpack_require__(9);
- var NodeUtils_1 = __webpack_require__(4);
- var BinaryExpressionFunctionNode = function (_AbstractCustomNode_) {
- _inherits(BinaryExpressionFunctionNode, _AbstractCustomNode_);
- function BinaryExpressionFunctionNode(identifierNamesGeneratorFactory, randomGenerator, options) {
- _classCallCheck(this, BinaryExpressionFunctionNode);
- return _possibleConstructorReturn(this, (BinaryExpressionFunctionNode.__proto__ || Object.getPrototypeOf(BinaryExpressionFunctionNode)).call(this, identifierNamesGeneratorFactory, randomGenerator, options));
- }
- _createClass(BinaryExpressionFunctionNode, [{
- key: "initialize",
- value: function initialize(operator) {
- this.operator = operator;
- }
- }, {
- key: "getNodeStructure",
- value: function getNodeStructure() {
- var structure = Nodes_1.Nodes.getExpressionStatementNode(Nodes_1.Nodes.getFunctionExpressionNode([Nodes_1.Nodes.getIdentifierNode('x'), Nodes_1.Nodes.getIdentifierNode('y')], Nodes_1.Nodes.getBlockStatementNode([Nodes_1.Nodes.getReturnStatementNode(Nodes_1.Nodes.getBinaryExpressionNode(this.operator, Nodes_1.Nodes.getIdentifierNode('x'), Nodes_1.Nodes.getIdentifierNode('y')))])));
- NodeUtils_1.NodeUtils.parentize(structure);
- return [structure];
- }
- }]);
- return BinaryExpressionFunctionNode;
- }(AbstractCustomNode_1.AbstractCustomNode);
- tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", String)], BinaryExpressionFunctionNode.prototype, "operator", void 0);
- BinaryExpressionFunctionNode = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IIdentifierNamesGenerator)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object, Object])], BinaryExpressionFunctionNode);
- exports.BinaryExpressionFunctionNode = BinaryExpressionFunctionNode;
- /***/ }),
- /* 77 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- function GlobalVariableTemplate1() {
- return "\n var that;\n \n try {\n var getGlobal = Function('return (function() ' + '{}.constructor(\"return this\")( )' + ');');\n \n that = getGlobal();\n } catch (e) {\n that = window;\n }\n ";
- }
- exports.GlobalVariableTemplate1 = GlobalVariableTemplate1;
- /***/ }),
- /* 78 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- function GlobalVariableTemplate2() {
- return "\n var getGlobal = function () {\n var globalObject;\n \n try {\n globalObject = Function('return (function() ' + '{}.constructor(\"return this\")( )' + ');')();\n } catch (e) {\n globalObject = window;\n }\n \n return globalObject;\n };\n var that = getGlobal();\n ";
- }
- exports.GlobalVariableTemplate2 = GlobalVariableTemplate2;
- /***/ }),
- /* 79 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var Initializable_1 = __webpack_require__(5);
- var AbstractCustomNode_1 = __webpack_require__(8);
- var NodeGuards_1 = __webpack_require__(3);
- var Nodes_1 = __webpack_require__(9);
- var NodeUtils_1 = __webpack_require__(4);
- var BlockStatementControlFlowFlatteningNode = function (_AbstractCustomNode_) {
- _inherits(BlockStatementControlFlowFlatteningNode, _AbstractCustomNode_);
- function BlockStatementControlFlowFlatteningNode(identifierNamesGeneratorFactory, randomGenerator, options) {
- _classCallCheck(this, BlockStatementControlFlowFlatteningNode);
- return _possibleConstructorReturn(this, (BlockStatementControlFlowFlatteningNode.__proto__ || Object.getPrototypeOf(BlockStatementControlFlowFlatteningNode)).call(this, identifierNamesGeneratorFactory, randomGenerator, options));
- }
- _createClass(BlockStatementControlFlowFlatteningNode, [{
- key: "initialize",
- value: function initialize(blockStatementBody, shuffledKeys, originalKeysIndexesInShuffledArray) {
- this.blockStatementBody = blockStatementBody;
- this.shuffledKeys = shuffledKeys;
- this.originalKeysIndexesInShuffledArray = originalKeysIndexesInShuffledArray;
- }
- }, {
- key: "getNodeStructure",
- value: function getNodeStructure() {
- var _this2 = this;
- var controllerIdentifierName = this.randomGenerator.getRandomString(6);
- var indexIdentifierName = this.randomGenerator.getRandomString(6);
- var structure = Nodes_1.Nodes.getBlockStatementNode([Nodes_1.Nodes.getVariableDeclarationNode([Nodes_1.Nodes.getVariableDeclaratorNode(Nodes_1.Nodes.getIdentifierNode(controllerIdentifierName), Nodes_1.Nodes.getCallExpressionNode(Nodes_1.Nodes.getMemberExpressionNode(Nodes_1.Nodes.getLiteralNode(this.originalKeysIndexesInShuffledArray.join('|')), Nodes_1.Nodes.getIdentifierNode('split')), [Nodes_1.Nodes.getLiteralNode('|')])), Nodes_1.Nodes.getVariableDeclaratorNode(Nodes_1.Nodes.getIdentifierNode(indexIdentifierName), Nodes_1.Nodes.getLiteralNode(0))]), Nodes_1.Nodes.getWhileStatementNode(Nodes_1.Nodes.getLiteralNode(true), Nodes_1.Nodes.getBlockStatementNode([Nodes_1.Nodes.getSwitchStatementNode(Nodes_1.Nodes.getMemberExpressionNode(Nodes_1.Nodes.getIdentifierNode(controllerIdentifierName), Nodes_1.Nodes.getUpdateExpressionNode('++', Nodes_1.Nodes.getIdentifierNode(indexIdentifierName)), true), this.shuffledKeys.map(function (key, index) {
- var statement = _this2.blockStatementBody[key];
- var consequent = [statement];
- if (!NodeGuards_1.NodeGuards.isReturnStatementNode(statement)) {
- consequent.push(Nodes_1.Nodes.getContinueStatement());
- }
- return Nodes_1.Nodes.getSwitchCaseNode(Nodes_1.Nodes.getLiteralNode(String(index)), consequent);
- })), Nodes_1.Nodes.getBreakStatement()]))]);
- NodeUtils_1.NodeUtils.parentize(structure);
- return [structure];
- }
- }]);
- return BlockStatementControlFlowFlatteningNode;
- }(AbstractCustomNode_1.AbstractCustomNode);
- tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", Array)], BlockStatementControlFlowFlatteningNode.prototype, "blockStatementBody", void 0);
- tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", Array)], BlockStatementControlFlowFlatteningNode.prototype, "originalKeysIndexesInShuffledArray", void 0);
- tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", Array)], BlockStatementControlFlowFlatteningNode.prototype, "shuffledKeys", void 0);
- BlockStatementControlFlowFlatteningNode = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IIdentifierNamesGenerator)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object, Object])], BlockStatementControlFlowFlatteningNode);
- exports.BlockStatementControlFlowFlatteningNode = BlockStatementControlFlowFlatteningNode;
- /***/ }),
- /* 80 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _slicedToArray = (function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; })();
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var Initializable_1 = __webpack_require__(5);
- var AbstractCustomNode_1 = __webpack_require__(8);
- var Nodes_1 = __webpack_require__(9);
- var NodeUtils_1 = __webpack_require__(4);
- var BlockStatementDeadCodeInjectionNode = function (_AbstractCustomNode_) {
- _inherits(BlockStatementDeadCodeInjectionNode, _AbstractCustomNode_);
- function BlockStatementDeadCodeInjectionNode(identifierNamesGeneratorFactory, randomGenerator, options) {
- _classCallCheck(this, BlockStatementDeadCodeInjectionNode);
- return _possibleConstructorReturn(this, (BlockStatementDeadCodeInjectionNode.__proto__ || Object.getPrototypeOf(BlockStatementDeadCodeInjectionNode)).call(this, identifierNamesGeneratorFactory, randomGenerator, options));
- }
- _createClass(BlockStatementDeadCodeInjectionNode, [{
- key: "initialize",
- value: function initialize(blockStatementNode, deadCodeInjectionRootAstHostNode) {
- this.blockStatementNode = blockStatementNode;
- this.deadCodeInjectionRootAstHostNode = deadCodeInjectionRootAstHostNode;
- }
- }, {
- key: "getNodeStructure",
- value: function getNodeStructure() {
- var random1 = this.randomGenerator.getMathRandom() > 0.5;
- var random2 = this.randomGenerator.getMathRandom() > 0.5;
- var operator = random1 ? '===' : '!==';
- var leftString = this.randomGenerator.getRandomString(5);
- var rightString = random2 ? leftString : this.randomGenerator.getRandomString(5);
- var _ref = random1 === random2 ? [this.blockStatementNode, this.deadCodeInjectionRootAstHostNode] : [this.deadCodeInjectionRootAstHostNode, this.blockStatementNode],
- _ref2 = _slicedToArray(_ref, 2),
- consequent = _ref2[0],
- alternate = _ref2[1];
- var structure = Nodes_1.Nodes.getBlockStatementNode([Nodes_1.Nodes.getIfStatementNode(Nodes_1.Nodes.getBinaryExpressionNode(operator, Nodes_1.Nodes.getLiteralNode(leftString), Nodes_1.Nodes.getLiteralNode(rightString)), consequent, alternate)]);
- NodeUtils_1.NodeUtils.parentize(structure);
- return [structure];
- }
- }]);
- return BlockStatementDeadCodeInjectionNode;
- }(AbstractCustomNode_1.AbstractCustomNode);
- tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", Object)], BlockStatementDeadCodeInjectionNode.prototype, "blockStatementNode", void 0);
- tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", Object)], BlockStatementDeadCodeInjectionNode.prototype, "deadCodeInjectionRootAstHostNode", void 0);
- BlockStatementDeadCodeInjectionNode = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IIdentifierNamesGenerator)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object, Object])], BlockStatementDeadCodeInjectionNode);
- exports.BlockStatementDeadCodeInjectionNode = BlockStatementDeadCodeInjectionNode;
- /***/ }),
- /* 81 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var Initializable_1 = __webpack_require__(5);
- var AbstractCustomNode_1 = __webpack_require__(8);
- var Nodes_1 = __webpack_require__(9);
- var NodeUtils_1 = __webpack_require__(4);
- var CallExpressionControlFlowStorageCallNode = function (_AbstractCustomNode_) {
- _inherits(CallExpressionControlFlowStorageCallNode, _AbstractCustomNode_);
- function CallExpressionControlFlowStorageCallNode(identifierNamesGeneratorFactory, randomGenerator, options) {
- _classCallCheck(this, CallExpressionControlFlowStorageCallNode);
- return _possibleConstructorReturn(this, (CallExpressionControlFlowStorageCallNode.__proto__ || Object.getPrototypeOf(CallExpressionControlFlowStorageCallNode)).call(this, identifierNamesGeneratorFactory, randomGenerator, options));
- }
- _createClass(CallExpressionControlFlowStorageCallNode, [{
- key: "initialize",
- value: function initialize(controlFlowStorageName, controlFlowStorageKey, callee, expressionArguments) {
- this.controlFlowStorageName = controlFlowStorageName;
- this.controlFlowStorageKey = controlFlowStorageKey;
- this.callee = callee;
- this.expressionArguments = expressionArguments;
- }
- }, {
- key: "getNodeStructure",
- value: function getNodeStructure() {
- var structure = Nodes_1.Nodes.getExpressionStatementNode(Nodes_1.Nodes.getCallExpressionNode(Nodes_1.Nodes.getMemberExpressionNode(Nodes_1.Nodes.getIdentifierNode(this.controlFlowStorageName), Nodes_1.Nodes.getIdentifierNode(this.controlFlowStorageKey)), [this.callee].concat(_toConsumableArray(this.expressionArguments))));
- NodeUtils_1.NodeUtils.parentize(structure);
- return [structure];
- }
- }]);
- return CallExpressionControlFlowStorageCallNode;
- }(AbstractCustomNode_1.AbstractCustomNode);
- tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", Object)], CallExpressionControlFlowStorageCallNode.prototype, "callee", void 0);
- tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", String)], CallExpressionControlFlowStorageCallNode.prototype, "controlFlowStorageKey", void 0);
- tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", String)], CallExpressionControlFlowStorageCallNode.prototype, "controlFlowStorageName", void 0);
- tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", Array)], CallExpressionControlFlowStorageCallNode.prototype, "expressionArguments", void 0);
- CallExpressionControlFlowStorageCallNode = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IIdentifierNamesGenerator)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object, Object])], CallExpressionControlFlowStorageCallNode);
- exports.CallExpressionControlFlowStorageCallNode = CallExpressionControlFlowStorageCallNode;
- /***/ }),
- /* 82 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var Initializable_1 = __webpack_require__(5);
- var AbstractCustomNode_1 = __webpack_require__(8);
- var Nodes_1 = __webpack_require__(9);
- var NodeUtils_1 = __webpack_require__(4);
- var CallExpressionFunctionNode = function (_AbstractCustomNode_) {
- _inherits(CallExpressionFunctionNode, _AbstractCustomNode_);
- function CallExpressionFunctionNode(identifierNamesGeneratorFactory, randomGenerator, options) {
- _classCallCheck(this, CallExpressionFunctionNode);
- return _possibleConstructorReturn(this, (CallExpressionFunctionNode.__proto__ || Object.getPrototypeOf(CallExpressionFunctionNode)).call(this, identifierNamesGeneratorFactory, randomGenerator, options));
- }
- _createClass(CallExpressionFunctionNode, [{
- key: "initialize",
- value: function initialize(expressionArguments) {
- this.expressionArguments = expressionArguments;
- }
- }, {
- key: "getNodeStructure",
- value: function getNodeStructure() {
- var calleeIdentifier = Nodes_1.Nodes.getIdentifierNode('callee');
- var params = [];
- var argumentsLength = this.expressionArguments.length;
- for (var i = 0; i < argumentsLength; i++) {
- params.push(Nodes_1.Nodes.getIdentifierNode("param" + (i + 1)));
- }
- var structure = Nodes_1.Nodes.getExpressionStatementNode(Nodes_1.Nodes.getFunctionExpressionNode([calleeIdentifier].concat(params), Nodes_1.Nodes.getBlockStatementNode([Nodes_1.Nodes.getReturnStatementNode(Nodes_1.Nodes.getCallExpressionNode(calleeIdentifier, params))])));
- NodeUtils_1.NodeUtils.parentize(structure);
- return [structure];
- }
- }]);
- return CallExpressionFunctionNode;
- }(AbstractCustomNode_1.AbstractCustomNode);
- tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", Array)], CallExpressionFunctionNode.prototype, "expressionArguments", void 0);
- CallExpressionFunctionNode = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IIdentifierNamesGenerator)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object, Object])], CallExpressionFunctionNode);
- exports.CallExpressionFunctionNode = CallExpressionFunctionNode;
- /***/ }),
- /* 83 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _slicedToArray = (function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; })();
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var Initializable_1 = __webpack_require__(5);
- var AbstractCustomNode_1 = __webpack_require__(8);
- var NodeGuards_1 = __webpack_require__(3);
- var Nodes_1 = __webpack_require__(9);
- var NodeUtils_1 = __webpack_require__(4);
- var ControlFlowStorageNode = function (_AbstractCustomNode_) {
- _inherits(ControlFlowStorageNode, _AbstractCustomNode_);
- function ControlFlowStorageNode(identifierNamesGeneratorFactory, randomGenerator, options) {
- _classCallCheck(this, ControlFlowStorageNode);
- return _possibleConstructorReturn(this, (ControlFlowStorageNode.__proto__ || Object.getPrototypeOf(ControlFlowStorageNode)).call(this, identifierNamesGeneratorFactory, randomGenerator, options));
- }
- _createClass(ControlFlowStorageNode, [{
- key: "initialize",
- value: function initialize(controlFlowStorage) {
- this.controlFlowStorage = controlFlowStorage;
- }
- }, {
- key: "getNodeStructure",
- value: function getNodeStructure() {
- var propertyNodes = Array.from(this.controlFlowStorage.getStorage()).map(function (_ref) {
- var _ref2 = _slicedToArray(_ref, 2),
- key = _ref2[0],
- value = _ref2[1];
- var node = value.getNode()[0];
- if (!NodeGuards_1.NodeGuards.isExpressionStatementNode(node)) {
- throw new Error('Function node for control flow storage object should be passed inside the `ExpressionStatement` node!');
- }
- return Nodes_1.Nodes.getPropertyNode(Nodes_1.Nodes.getIdentifierNode(key), node.expression);
- });
- var structure = Nodes_1.Nodes.getVariableDeclarationNode([Nodes_1.Nodes.getVariableDeclaratorNode(Nodes_1.Nodes.getIdentifierNode(this.controlFlowStorage.getStorageId()), Nodes_1.Nodes.getObjectExpressionNode(propertyNodes))]);
- structure = NodeUtils_1.NodeUtils.parentize(structure);
- return [structure];
- }
- }]);
- return ControlFlowStorageNode;
- }(AbstractCustomNode_1.AbstractCustomNode);
- tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", Object)], ControlFlowStorageNode.prototype, "controlFlowStorage", void 0);
- ControlFlowStorageNode = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IIdentifierNamesGenerator)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object, Object])], ControlFlowStorageNode);
- exports.ControlFlowStorageNode = ControlFlowStorageNode;
- /***/ }),
- /* 84 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var string_template_1 = tslib_1.__importDefault(__webpack_require__(12));
- var ObfuscationTarget_1 = __webpack_require__(14);
- var ConsoleOutputDisableExpressionTemplate_1 = __webpack_require__(85);
- var GlobalVariableNoEvalTemplate_1 = __webpack_require__(32);
- var Initializable_1 = __webpack_require__(5);
- var AbstractCustomNode_1 = __webpack_require__(8);
- var NodeUtils_1 = __webpack_require__(4);
- var ConsoleOutputDisableExpressionNode = function (_AbstractCustomNode_) {
- _inherits(ConsoleOutputDisableExpressionNode, _AbstractCustomNode_);
- function ConsoleOutputDisableExpressionNode(identifierNamesGeneratorFactory, randomGenerator, options) {
- _classCallCheck(this, ConsoleOutputDisableExpressionNode);
- return _possibleConstructorReturn(this, (ConsoleOutputDisableExpressionNode.__proto__ || Object.getPrototypeOf(ConsoleOutputDisableExpressionNode)).call(this, identifierNamesGeneratorFactory, randomGenerator, options));
- }
- _createClass(ConsoleOutputDisableExpressionNode, [{
- key: "initialize",
- value: function initialize(callsControllerFunctionName) {
- this.callsControllerFunctionName = callsControllerFunctionName;
- }
- }, {
- key: "getNodeStructure",
- value: function getNodeStructure() {
- return NodeUtils_1.NodeUtils.convertCodeToStructure(this.getTemplate());
- }
- }, {
- key: "getTemplate",
- value: function getTemplate() {
- var globalVariableTemplate = this.options.target !== ObfuscationTarget_1.ObfuscationTarget.Extension ? this.getGlobalVariableTemplate() : GlobalVariableNoEvalTemplate_1.GlobalVariableNoEvalTemplate();
- return string_template_1.default(ConsoleOutputDisableExpressionTemplate_1.ConsoleOutputDisableExpressionTemplate(), {
- consoleLogDisableFunctionName: this.identifierNamesGenerator.generate(),
- globalVariableTemplate: globalVariableTemplate,
- singleNodeCallControllerFunctionName: this.callsControllerFunctionName
- });
- }
- }]);
- return ConsoleOutputDisableExpressionNode;
- }(AbstractCustomNode_1.AbstractCustomNode);
- tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", String)], ConsoleOutputDisableExpressionNode.prototype, "callsControllerFunctionName", void 0);
- ConsoleOutputDisableExpressionNode = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IIdentifierNamesGenerator)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object, Object])], ConsoleOutputDisableExpressionNode);
- exports.ConsoleOutputDisableExpressionNode = ConsoleOutputDisableExpressionNode;
- /***/ }),
- /* 85 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- function ConsoleOutputDisableExpressionTemplate() {
- return "\n var {consoleLogDisableFunctionName} = {singleNodeCallControllerFunctionName}(this, function () {\n var func = function () {};\n \n {globalVariableTemplate}\n \n if (!that.console) {\n that.console = (function (func){\n var c = {};\n \n c.log = func;\n c.warn = func;\n c.debug = func;\n c.info = func;\n c.error = func;\n c.exception = func;\n c.trace = func;\n \n return c;\n })(func);\n } else {\n that.console.log = func;\n that.console.warn = func;\n that.console.debug = func;\n that.console.info = func;\n that.console.error = func;\n that.console.exception = func;\n that.console.trace = func;\n }\n });\n \n {consoleLogDisableFunctionName}();\n ";
- }
- exports.ConsoleOutputDisableExpressionTemplate = ConsoleOutputDisableExpressionTemplate;
- /***/ }),
- /* 86 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var string_template_1 = tslib_1.__importDefault(__webpack_require__(12));
- var Initializable_1 = __webpack_require__(5);
- var DebugProtectionFunctionCallTemplate_1 = __webpack_require__(87);
- var AbstractCustomNode_1 = __webpack_require__(8);
- var NodeUtils_1 = __webpack_require__(4);
- var DebugProtectionFunctionCallNode = function (_AbstractCustomNode_) {
- _inherits(DebugProtectionFunctionCallNode, _AbstractCustomNode_);
- function DebugProtectionFunctionCallNode(identifierNamesGeneratorFactory, randomGenerator, options) {
- _classCallCheck(this, DebugProtectionFunctionCallNode);
- return _possibleConstructorReturn(this, (DebugProtectionFunctionCallNode.__proto__ || Object.getPrototypeOf(DebugProtectionFunctionCallNode)).call(this, identifierNamesGeneratorFactory, randomGenerator, options));
- }
- _createClass(DebugProtectionFunctionCallNode, [{
- key: "initialize",
- value: function initialize(debugProtectionFunctionName, callsControllerFunctionName) {
- this.debugProtectionFunctionName = debugProtectionFunctionName;
- this.callsControllerFunctionName = callsControllerFunctionName;
- }
- }, {
- key: "getNodeStructure",
- value: function getNodeStructure() {
- return NodeUtils_1.NodeUtils.convertCodeToStructure(this.getTemplate());
- }
- }, {
- key: "getTemplate",
- value: function getTemplate() {
- return string_template_1.default(DebugProtectionFunctionCallTemplate_1.DebugProtectionFunctionCallTemplate(), {
- debugProtectionFunctionName: this.debugProtectionFunctionName,
- singleNodeCallControllerFunctionName: this.callsControllerFunctionName
- });
- }
- }]);
- return DebugProtectionFunctionCallNode;
- }(AbstractCustomNode_1.AbstractCustomNode);
- tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", String)], DebugProtectionFunctionCallNode.prototype, "callsControllerFunctionName", void 0);
- tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", String)], DebugProtectionFunctionCallNode.prototype, "debugProtectionFunctionName", void 0);
- DebugProtectionFunctionCallNode = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IIdentifierNamesGenerator)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object, Object])], DebugProtectionFunctionCallNode);
- exports.DebugProtectionFunctionCallNode = DebugProtectionFunctionCallNode;
- /***/ }),
- /* 87 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- function DebugProtectionFunctionCallTemplate() {
- return "\n (function () {\n {singleNodeCallControllerFunctionName}(this, function () {\n var regExp1 = new RegExp('function *\\\\( *\\\\)');\n var regExp2 = new RegExp('\\\\+\\\\+ *\\(?:_0x(?:[a-f0-9]){4,6}|(?:\\\\b|\\\\d)[a-z0-9]{1,4}(?:\\\\b|\\\\d)\\)', 'i');\n \n var result = {debugProtectionFunctionName}('init');\n \n if (!regExp1.test(result + 'chain') || !regExp2.test(result + 'input')) {\n result('0');\n } else {\n {debugProtectionFunctionName}();\n }\n })();\n })();\n ";
- }
- exports.DebugProtectionFunctionCallTemplate = DebugProtectionFunctionCallTemplate;
- /***/ }),
- /* 88 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var string_template_1 = tslib_1.__importDefault(__webpack_require__(12));
- var Initializable_1 = __webpack_require__(5);
- var DebugProtectionFunctionIntervalTemplate_1 = __webpack_require__(89);
- var AbstractCustomNode_1 = __webpack_require__(8);
- var NodeUtils_1 = __webpack_require__(4);
- var DebugProtectionFunctionIntervalNode = function (_AbstractCustomNode_) {
- _inherits(DebugProtectionFunctionIntervalNode, _AbstractCustomNode_);
- function DebugProtectionFunctionIntervalNode(identifierNamesGeneratorFactory, randomGenerator, options) {
- _classCallCheck(this, DebugProtectionFunctionIntervalNode);
- return _possibleConstructorReturn(this, (DebugProtectionFunctionIntervalNode.__proto__ || Object.getPrototypeOf(DebugProtectionFunctionIntervalNode)).call(this, identifierNamesGeneratorFactory, randomGenerator, options));
- }
- _createClass(DebugProtectionFunctionIntervalNode, [{
- key: "initialize",
- value: function initialize(debugProtectionFunctionName) {
- this.debugProtectionFunctionName = debugProtectionFunctionName;
- }
- }, {
- key: "getNodeStructure",
- value: function getNodeStructure() {
- return NodeUtils_1.NodeUtils.convertCodeToStructure(this.getTemplate());
- }
- }, {
- key: "getTemplate",
- value: function getTemplate() {
- return string_template_1.default(DebugProtectionFunctionIntervalTemplate_1.DebugProtectionFunctionIntervalTemplate(), {
- debugProtectionFunctionName: this.debugProtectionFunctionName
- });
- }
- }]);
- return DebugProtectionFunctionIntervalNode;
- }(AbstractCustomNode_1.AbstractCustomNode);
- tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", String)], DebugProtectionFunctionIntervalNode.prototype, "debugProtectionFunctionName", void 0);
- DebugProtectionFunctionIntervalNode = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IIdentifierNamesGenerator)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object, Object])], DebugProtectionFunctionIntervalNode);
- exports.DebugProtectionFunctionIntervalNode = DebugProtectionFunctionIntervalNode;
- /***/ }),
- /* 89 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- function DebugProtectionFunctionIntervalTemplate() {
- return "\n setInterval(function () {\n {debugProtectionFunctionName}();\n }, 4000);\n ";
- }
- exports.DebugProtectionFunctionIntervalTemplate = DebugProtectionFunctionIntervalTemplate;
- /***/ }),
- /* 90 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var string_template_1 = tslib_1.__importDefault(__webpack_require__(12));
- var ObfuscationTarget_1 = __webpack_require__(14);
- var Initializable_1 = __webpack_require__(5);
- var DebuggerTemplate_1 = __webpack_require__(91);
- var DebuggerTemplateNoEval_1 = __webpack_require__(92);
- var DebugProtectionFunctionTemplate_1 = __webpack_require__(93);
- var AbstractCustomNode_1 = __webpack_require__(8);
- var NodeUtils_1 = __webpack_require__(4);
- var DebugProtectionFunctionNode = function (_AbstractCustomNode_) {
- _inherits(DebugProtectionFunctionNode, _AbstractCustomNode_);
- function DebugProtectionFunctionNode(identifierNamesGeneratorFactory, randomGenerator, options) {
- _classCallCheck(this, DebugProtectionFunctionNode);
- return _possibleConstructorReturn(this, (DebugProtectionFunctionNode.__proto__ || Object.getPrototypeOf(DebugProtectionFunctionNode)).call(this, identifierNamesGeneratorFactory, randomGenerator, options));
- }
- _createClass(DebugProtectionFunctionNode, [{
- key: "initialize",
- value: function initialize(debugProtectionFunctionName) {
- this.debugProtectionFunctionName = debugProtectionFunctionName;
- }
- }, {
- key: "getNodeStructure",
- value: function getNodeStructure() {
- return NodeUtils_1.NodeUtils.convertCodeToStructure(this.getTemplate());
- }
- }, {
- key: "getTemplate",
- value: function getTemplate() {
- var debuggerTemplate = this.options.target !== ObfuscationTarget_1.ObfuscationTarget.Extension ? DebuggerTemplate_1.DebuggerTemplate() : DebuggerTemplateNoEval_1.DebuggerTemplateNoEval();
- return string_template_1.default(DebugProtectionFunctionTemplate_1.DebugProtectionFunctionTemplate(), {
- debuggerTemplate: debuggerTemplate,
- debugProtectionFunctionName: this.debugProtectionFunctionName
- });
- }
- }]);
- return DebugProtectionFunctionNode;
- }(AbstractCustomNode_1.AbstractCustomNode);
- tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", String)], DebugProtectionFunctionNode.prototype, "debugProtectionFunctionName", void 0);
- DebugProtectionFunctionNode = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IIdentifierNamesGenerator)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object, Object])], DebugProtectionFunctionNode);
- exports.DebugProtectionFunctionNode = DebugProtectionFunctionNode;
- /***/ }),
- /* 91 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- function DebuggerTemplate() {
- return "\n if (typeof counter === 'string') {\n return (function (arg) {}.constructor('while (true) {}').apply('counter'));\n } else {\n if (('' + counter / counter)['length'] !== 1 || counter % 20 === 0) {\n (function () {return true;}.constructor('debu' + 'gger').call('action'));\n } else {\n (function () {return false;}.constructor('debu' + 'gger').apply('stateObject'));\n }\n \n }\n ";
- }
- exports.DebuggerTemplate = DebuggerTemplate;
- /***/ }),
- /* 92 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- function DebuggerTemplateNoEval() {
- return "\n if (typeof counter === 'string') {\n var func = function () {\n while (true) {}\n };\n \n return func();\n } else {\n if (('' + counter / counter)['length'] !== 1 || counter % 20 === 0) {\n debugger;\n } else {\n debugger;\n }\n \n }\n ";
- }
- exports.DebuggerTemplateNoEval = DebuggerTemplateNoEval;
- /***/ }),
- /* 93 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- function DebugProtectionFunctionTemplate() {
- return "\n function {debugProtectionFunctionName} (ret) {\n function debuggerProtection (counter) {\n \n {debuggerTemplate}\n \n debuggerProtection(++counter);\n }\n \n try {\n if (ret) {\n return debuggerProtection;\n } else {\n debuggerProtection(0);\n }\n } catch (y) {}\n }\n ";
- }
- exports.DebugProtectionFunctionTemplate = DebugProtectionFunctionTemplate;
- /***/ }),
- /* 94 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _slicedToArray = (function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; })();
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var string_template_1 = tslib_1.__importDefault(__webpack_require__(12));
- var ObfuscationTarget_1 = __webpack_require__(14);
- var Initializable_1 = __webpack_require__(5);
- var DomainLockNodeTemplate_1 = __webpack_require__(95);
- var GlobalVariableNoEvalTemplate_1 = __webpack_require__(32);
- var AbstractCustomNode_1 = __webpack_require__(8);
- var NodeUtils_1 = __webpack_require__(4);
- var DomainLockNode = function (_AbstractCustomNode_) {
- _inherits(DomainLockNode, _AbstractCustomNode_);
- function DomainLockNode(identifierNamesGeneratorFactory, randomGenerator, cryptUtils, options) {
- _classCallCheck(this, DomainLockNode);
- var _this = _possibleConstructorReturn(this, (DomainLockNode.__proto__ || Object.getPrototypeOf(DomainLockNode)).call(this, identifierNamesGeneratorFactory, randomGenerator, options));
- _this.cryptUtils = cryptUtils;
- return _this;
- }
- _createClass(DomainLockNode, [{
- key: "initialize",
- value: function initialize(callsControllerFunctionName) {
- this.callsControllerFunctionName = callsControllerFunctionName;
- }
- }, {
- key: "getNodeStructure",
- value: function getNodeStructure() {
- return NodeUtils_1.NodeUtils.convertCodeToStructure(this.getTemplate());
- }
- }, {
- key: "getTemplate",
- value: function getTemplate() {
- var domainsString = this.options.domainLock.join(';');
- var _cryptUtils$hideStrin = this.cryptUtils.hideString(domainsString, domainsString.length * 3),
- _cryptUtils$hideStrin2 = _slicedToArray(_cryptUtils$hideStrin, 2),
- hiddenDomainsString = _cryptUtils$hideStrin2[0],
- diff = _cryptUtils$hideStrin2[1];
- var globalVariableTemplate = this.options.target !== ObfuscationTarget_1.ObfuscationTarget.Extension ? this.getGlobalVariableTemplate() : GlobalVariableNoEvalTemplate_1.GlobalVariableNoEvalTemplate();
- return string_template_1.default(DomainLockNodeTemplate_1.DomainLockNodeTemplate(), {
- domainLockFunctionName: this.identifierNamesGenerator.generate(),
- diff: diff,
- domains: hiddenDomainsString,
- globalVariableTemplate: globalVariableTemplate,
- singleNodeCallControllerFunctionName: this.callsControllerFunctionName
- });
- }
- }]);
- return DomainLockNode;
- }(AbstractCustomNode_1.AbstractCustomNode);
- tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", String)], DomainLockNode.prototype, "callsControllerFunctionName", void 0);
- DomainLockNode = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IIdentifierNamesGenerator)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.ICryptUtils)), tslib_1.__param(3, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object, Object, Object])], DomainLockNode);
- exports.DomainLockNode = DomainLockNode;
- /***/ }),
- /* 95 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- function DomainLockNodeTemplate() {
- return "\n var {domainLockFunctionName} = {singleNodeCallControllerFunctionName}(this, function () {\n \n {globalVariableTemplate}\n \n var func = function () {\n return {\n key: 'item',\n value: 'attribute',\n getAttribute: function () {\n for (var i = 0; i < 1000; i--) {\n var isPositive = i > 0;\n \n switch (isPositive) {\n case true:\n return this.item + '_' + this.value + '_' + i;\n default:\n this.item + '_' + this.value;\n }\n }\n }()\n };\n };\n \n var regExp = new RegExp(\"[{diff}]\", \"g\");\n var domains = \"{domains}\".replace(regExp, \"\").split(\";\");\n var document;\n var domain;\n \n for (var d in that) {\n if (d.length == 8 && d.charCodeAt(7) == 116 && d.charCodeAt(5) == 101 && d.charCodeAt(3) == 117 && d.charCodeAt(0) == 100) {\n document = d;\n \n break;\n }\n }\n\n for (var d1 in that[document]) {\n if (d1.length == 6 && d1.charCodeAt(5) == 110 && d1.charCodeAt(0) == 100) {\n domain = d1;\n \n break;\n }\n }\n \n if ((!document && !domain) || (!that[document] && !that[document][domain])) {\n return;\n }\n \n var currentDomain = that[document][domain];\n\n var ok = false;\n \n for (var i = 0; i < domains.length; i++) {\n var domain = domains[i];\n var position = currentDomain.length - domain.length;\n var lastIndex = currentDomain.indexOf(domain, position);\n var endsWith = lastIndex !== -1 && lastIndex === position;\n \n if (endsWith) {\n if (currentDomain.length == domain.length || domain.indexOf(\".\") === 0) {\n ok = true;\n }\n \n break;\n }\n }\n \n if (!ok) {\n data;\n } else {\n return;\n }\n \n func();\n });\n\n {domainLockFunctionName}();\n ";
- }
- exports.DomainLockNodeTemplate = DomainLockNodeTemplate;
- /***/ }),
- /* 96 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var Initializable_1 = __webpack_require__(5);
- var AbstractCustomNode_1 = __webpack_require__(8);
- var Nodes_1 = __webpack_require__(9);
- var NodeUtils_1 = __webpack_require__(4);
- var ExpressionWithOperatorControlFlowStorageCallNode = function (_AbstractCustomNode_) {
- _inherits(ExpressionWithOperatorControlFlowStorageCallNode, _AbstractCustomNode_);
- function ExpressionWithOperatorControlFlowStorageCallNode(identifierNamesGeneratorFactory, randomGenerator, options) {
- _classCallCheck(this, ExpressionWithOperatorControlFlowStorageCallNode);
- return _possibleConstructorReturn(this, (ExpressionWithOperatorControlFlowStorageCallNode.__proto__ || Object.getPrototypeOf(ExpressionWithOperatorControlFlowStorageCallNode)).call(this, identifierNamesGeneratorFactory, randomGenerator, options));
- }
- _createClass(ExpressionWithOperatorControlFlowStorageCallNode, [{
- key: "initialize",
- value: function initialize(controlFlowStorageName, controlFlowStorageKey, leftValue, rightValue) {
- this.controlFlowStorageName = controlFlowStorageName;
- this.controlFlowStorageKey = controlFlowStorageKey;
- this.leftValue = leftValue;
- this.rightValue = rightValue;
- }
- }, {
- key: "getNodeStructure",
- value: function getNodeStructure() {
- var structure = Nodes_1.Nodes.getExpressionStatementNode(Nodes_1.Nodes.getCallExpressionNode(Nodes_1.Nodes.getMemberExpressionNode(Nodes_1.Nodes.getIdentifierNode(this.controlFlowStorageName), Nodes_1.Nodes.getIdentifierNode(this.controlFlowStorageKey)), [this.leftValue, this.rightValue]));
- NodeUtils_1.NodeUtils.parentize(structure);
- return [structure];
- }
- }]);
- return ExpressionWithOperatorControlFlowStorageCallNode;
- }(AbstractCustomNode_1.AbstractCustomNode);
- tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", String)], ExpressionWithOperatorControlFlowStorageCallNode.prototype, "controlFlowStorageKey", void 0);
- tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", String)], ExpressionWithOperatorControlFlowStorageCallNode.prototype, "controlFlowStorageName", void 0);
- tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", Object)], ExpressionWithOperatorControlFlowStorageCallNode.prototype, "leftValue", void 0);
- tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", Object)], ExpressionWithOperatorControlFlowStorageCallNode.prototype, "rightValue", void 0);
- ExpressionWithOperatorControlFlowStorageCallNode = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IIdentifierNamesGenerator)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object, Object])], ExpressionWithOperatorControlFlowStorageCallNode);
- exports.ExpressionWithOperatorControlFlowStorageCallNode = ExpressionWithOperatorControlFlowStorageCallNode;
- /***/ }),
- /* 97 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var Initializable_1 = __webpack_require__(5);
- var AbstractCustomNode_1 = __webpack_require__(8);
- var Nodes_1 = __webpack_require__(9);
- var NodeUtils_1 = __webpack_require__(4);
- var LogicalExpressionFunctionNode = function (_AbstractCustomNode_) {
- _inherits(LogicalExpressionFunctionNode, _AbstractCustomNode_);
- function LogicalExpressionFunctionNode(identifierNamesGeneratorFactory, randomGenerator, options) {
- _classCallCheck(this, LogicalExpressionFunctionNode);
- return _possibleConstructorReturn(this, (LogicalExpressionFunctionNode.__proto__ || Object.getPrototypeOf(LogicalExpressionFunctionNode)).call(this, identifierNamesGeneratorFactory, randomGenerator, options));
- }
- _createClass(LogicalExpressionFunctionNode, [{
- key: "initialize",
- value: function initialize(operator) {
- this.operator = operator;
- }
- }, {
- key: "getNodeStructure",
- value: function getNodeStructure() {
- var structure = Nodes_1.Nodes.getExpressionStatementNode(Nodes_1.Nodes.getFunctionExpressionNode([Nodes_1.Nodes.getIdentifierNode('x'), Nodes_1.Nodes.getIdentifierNode('y')], Nodes_1.Nodes.getBlockStatementNode([Nodes_1.Nodes.getReturnStatementNode(Nodes_1.Nodes.getLogicalExpressionNode(this.operator, Nodes_1.Nodes.getIdentifierNode('x'), Nodes_1.Nodes.getIdentifierNode('y')))])));
- NodeUtils_1.NodeUtils.parentize(structure);
- return [structure];
- }
- }]);
- return LogicalExpressionFunctionNode;
- }(AbstractCustomNode_1.AbstractCustomNode);
- tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", String)], LogicalExpressionFunctionNode.prototype, "operator", void 0);
- LogicalExpressionFunctionNode = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IIdentifierNamesGenerator)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object, Object])], LogicalExpressionFunctionNode);
- exports.LogicalExpressionFunctionNode = LogicalExpressionFunctionNode;
- /***/ }),
- /* 98 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var string_template_1 = tslib_1.__importDefault(__webpack_require__(12));
- var ObfuscationEvent_1 = __webpack_require__(17);
- var Initializable_1 = __webpack_require__(5);
- var SingleNodeCallControllerTemplate_1 = __webpack_require__(99);
- var NoCustomNodes_1 = __webpack_require__(27);
- var AbstractCustomNode_1 = __webpack_require__(8);
- var JavaScriptObfuscatorFacade_1 = __webpack_require__(19);
- var NodeUtils_1 = __webpack_require__(4);
- var NodeCallsControllerFunctionNode = function (_AbstractCustomNode_) {
- _inherits(NodeCallsControllerFunctionNode, _AbstractCustomNode_);
- function NodeCallsControllerFunctionNode(identifierNamesGeneratorFactory, randomGenerator, options) {
- _classCallCheck(this, NodeCallsControllerFunctionNode);
- return _possibleConstructorReturn(this, (NodeCallsControllerFunctionNode.__proto__ || Object.getPrototypeOf(NodeCallsControllerFunctionNode)).call(this, identifierNamesGeneratorFactory, randomGenerator, options));
- }
- _createClass(NodeCallsControllerFunctionNode, [{
- key: "initialize",
- value: function initialize(appendEvent, callsControllerFunctionName) {
- this.appendEvent = appendEvent;
- this.callsControllerFunctionName = callsControllerFunctionName;
- }
- }, {
- key: "getNodeStructure",
- value: function getNodeStructure() {
- return NodeUtils_1.NodeUtils.convertCodeToStructure(this.getTemplate());
- }
- }, {
- key: "getTemplate",
- value: function getTemplate() {
- if (this.appendEvent === ObfuscationEvent_1.ObfuscationEvent.AfterObfuscation) {
- return JavaScriptObfuscatorFacade_1.JavaScriptObfuscator.obfuscate(string_template_1.default(SingleNodeCallControllerTemplate_1.SingleNodeCallControllerTemplate(), {
- singleNodeCallControllerFunctionName: this.callsControllerFunctionName
- }), Object.assign({}, NoCustomNodes_1.NO_ADDITIONAL_NODES_PRESET, { identifierNamesGenerator: this.options.identifierNamesGenerator, seed: this.options.seed })).getObfuscatedCode();
- }
- return string_template_1.default(SingleNodeCallControllerTemplate_1.SingleNodeCallControllerTemplate(), {
- singleNodeCallControllerFunctionName: this.callsControllerFunctionName
- });
- }
- }]);
- return NodeCallsControllerFunctionNode;
- }(AbstractCustomNode_1.AbstractCustomNode);
- tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", String)], NodeCallsControllerFunctionNode.prototype, "callsControllerFunctionName", void 0);
- tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", String)], NodeCallsControllerFunctionNode.prototype, "appendEvent", void 0);
- NodeCallsControllerFunctionNode = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IIdentifierNamesGenerator)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object, Object])], NodeCallsControllerFunctionNode);
- exports.NodeCallsControllerFunctionNode = NodeCallsControllerFunctionNode;
- /***/ }),
- /* 99 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- function SingleNodeCallControllerTemplate() {
- return "\n var {singleNodeCallControllerFunctionName} = (function(){\n var firstCall = true;\n \n return function (context, fn){\n var rfn = firstCall ? function(){\n if(fn){\n var res = fn.apply(context, arguments);\n fn = null;\n return res;\n }\n } : function(){}\n \n firstCall = false;\n \n return rfn;\n }\n })();\n ";
- }
- exports.SingleNodeCallControllerTemplate = SingleNodeCallControllerTemplate;
- /***/ }),
- /* 100 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var string_template_1 = tslib_1.__importDefault(__webpack_require__(12));
- var Initializable_1 = __webpack_require__(5);
- var NoCustomNodes_1 = __webpack_require__(27);
- var SelfDefendingTemplate_1 = __webpack_require__(101);
- var AbstractCustomNode_1 = __webpack_require__(8);
- var JavaScriptObfuscatorFacade_1 = __webpack_require__(19);
- var NodeUtils_1 = __webpack_require__(4);
- var SelfDefendingUnicodeNode = function (_AbstractCustomNode_) {
- _inherits(SelfDefendingUnicodeNode, _AbstractCustomNode_);
- function SelfDefendingUnicodeNode(identifierNamesGeneratorFactory, randomGenerator, escapeSequenceEncoder, options) {
- _classCallCheck(this, SelfDefendingUnicodeNode);
- var _this = _possibleConstructorReturn(this, (SelfDefendingUnicodeNode.__proto__ || Object.getPrototypeOf(SelfDefendingUnicodeNode)).call(this, identifierNamesGeneratorFactory, randomGenerator, options));
- _this.escapeSequenceEncoder = escapeSequenceEncoder;
- return _this;
- }
- _createClass(SelfDefendingUnicodeNode, [{
- key: "initialize",
- value: function initialize(callsControllerFunctionName) {
- this.callsControllerFunctionName = callsControllerFunctionName;
- }
- }, {
- key: "getNodeStructure",
- value: function getNodeStructure() {
- return NodeUtils_1.NodeUtils.convertCodeToStructure(this.getTemplate());
- }
- }, {
- key: "getTemplate",
- value: function getTemplate() {
- return JavaScriptObfuscatorFacade_1.JavaScriptObfuscator.obfuscate(string_template_1.default(SelfDefendingTemplate_1.SelfDefendingTemplate(this.escapeSequenceEncoder), {
- selfDefendingFunctionName: this.identifierNamesGenerator.generate(),
- singleNodeCallControllerFunctionName: this.callsControllerFunctionName
- }), Object.assign({}, NoCustomNodes_1.NO_ADDITIONAL_NODES_PRESET, { identifierNamesGenerator: this.options.identifierNamesGenerator, seed: this.options.seed, unicodeEscapeSequence: true })).getObfuscatedCode();
- }
- }]);
- return SelfDefendingUnicodeNode;
- }(AbstractCustomNode_1.AbstractCustomNode);
- tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", String)], SelfDefendingUnicodeNode.prototype, "callsControllerFunctionName", void 0);
- SelfDefendingUnicodeNode = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IIdentifierNamesGenerator)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IEscapeSequenceEncoder)), tslib_1.__param(3, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object, Object, Object])], SelfDefendingUnicodeNode);
- exports.SelfDefendingUnicodeNode = SelfDefendingUnicodeNode;
- /***/ }),
- /* 101 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- function SelfDefendingTemplate(escapeSequenceEncoder) {
- return "\n var {selfDefendingFunctionName} = {singleNodeCallControllerFunctionName}(this, function () {\n var func1 = function(){return 'dev';},\n func2 = function () {\n return 'window';\n };\n \n var test1 = function () {\n var regExp = new RegExp('" + escapeSequenceEncoder.encode("\\w+ *\\(\\) *{\\w+ *['|\"].+['|\"];? *}", true) + "');\n \n return !regExp.test(func1.toString());\n };\n \n var test2 = function () {\n var regExp = new RegExp('" + escapeSequenceEncoder.encode("(\\\\[x|u](\\w){2,4})+", true) + "');\n \n return regExp.test(func2.toString());\n };\n \n var recursiveFunc1 = function (string) {\n var i = ~-1 >> 1 + 255 % 0;\n \n if (string.indexOf('i' === i)) {\n recursiveFunc2(string)\n }\n };\n \n var recursiveFunc2 = function (string) {\n var i = ~-4 >> 1 + 255 % 0;\n \n if (string.indexOf((true+\"\")[3]) !== i) {\n recursiveFunc1(string)\n }\n };\n \n if (!test1()) {\n if (!test2()) {\n recursiveFunc1('ind\u0435xOf');\n } else {\n recursiveFunc1('indexOf');\n }\n } else {\n recursiveFunc1('ind\u0435xOf');\n }\n })\n \n {selfDefendingFunctionName}();\n ";
- }
- exports.SelfDefendingTemplate = SelfDefendingTemplate;
- /***/ }),
- /* 102 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var string_template_1 = tslib_1.__importDefault(__webpack_require__(12));
- var ObfuscationTarget_1 = __webpack_require__(14);
- var StringArrayEncoding_1 = __webpack_require__(26);
- var Initializable_1 = __webpack_require__(5);
- var NoCustomNodes_1 = __webpack_require__(27);
- var AtobTemplate_1 = __webpack_require__(103);
- var GlobalVariableNoEvalTemplate_1 = __webpack_require__(32);
- var Rc4Template_1 = __webpack_require__(104);
- var SelfDefendingTemplate_1 = __webpack_require__(105);
- var StringArrayBase64DecodeNodeTemplate_1 = __webpack_require__(106);
- var StringArrayCallsWrapperTemplate_1 = __webpack_require__(107);
- var StringArrayRC4DecodeNodeTemplate_1 = __webpack_require__(108);
- var AbstractCustomNode_1 = __webpack_require__(8);
- var JavaScriptObfuscatorFacade_1 = __webpack_require__(19);
- var NodeUtils_1 = __webpack_require__(4);
- var StringArrayCallsWrapper = function (_AbstractCustomNode_) {
- _inherits(StringArrayCallsWrapper, _AbstractCustomNode_);
- function StringArrayCallsWrapper(identifierNamesGeneratorFactory, randomGenerator, escapeSequenceEncoder, options) {
- _classCallCheck(this, StringArrayCallsWrapper);
- var _this = _possibleConstructorReturn(this, (StringArrayCallsWrapper.__proto__ || Object.getPrototypeOf(StringArrayCallsWrapper)).call(this, identifierNamesGeneratorFactory, randomGenerator, options));
- _this.escapeSequenceEncoder = escapeSequenceEncoder;
- return _this;
- }
- _createClass(StringArrayCallsWrapper, [{
- key: "initialize",
- value: function initialize(stringArrayName, stringArrayCallsWrapperName) {
- this.stringArrayName = stringArrayName;
- this.stringArrayCallsWrapperName = stringArrayCallsWrapperName;
- }
- }, {
- key: "getNodeStructure",
- value: function getNodeStructure() {
- return NodeUtils_1.NodeUtils.convertCodeToStructure(this.getTemplate());
- }
- }, {
- key: "getTemplate",
- value: function getTemplate() {
- var decodeNodeTemplate = this.getDecodeStringArrayTemplate();
- return JavaScriptObfuscatorFacade_1.JavaScriptObfuscator.obfuscate(string_template_1.default(StringArrayCallsWrapperTemplate_1.StringArrayCallsWrapperTemplate(), {
- decodeNodeTemplate: decodeNodeTemplate,
- stringArrayCallsWrapperName: this.stringArrayCallsWrapperName,
- stringArrayName: this.stringArrayName
- }), Object.assign({}, NoCustomNodes_1.NO_ADDITIONAL_NODES_PRESET, { identifierNamesGenerator: this.options.identifierNamesGenerator, seed: this.options.seed })).getObfuscatedCode();
- }
- }, {
- key: "getDecodeStringArrayTemplate",
- value: function getDecodeStringArrayTemplate() {
- var globalVariableTemplate = this.options.target !== ObfuscationTarget_1.ObfuscationTarget.Extension ? this.getGlobalVariableTemplate() : GlobalVariableNoEvalTemplate_1.GlobalVariableNoEvalTemplate();
- var atobPolyfill = string_template_1.default(AtobTemplate_1.AtobTemplate(), { globalVariableTemplate: globalVariableTemplate });
- var decodeStringArrayTemplate = '';
- var selfDefendingCode = '';
- if (this.options.selfDefending) {
- selfDefendingCode = string_template_1.default(SelfDefendingTemplate_1.SelfDefendingTemplate(this.randomGenerator, this.escapeSequenceEncoder), {
- stringArrayCallsWrapperName: this.stringArrayCallsWrapperName,
- stringArrayName: this.stringArrayName
- });
- }
- switch (this.options.stringArrayEncoding) {
- case StringArrayEncoding_1.StringArrayEncoding.Rc4:
- decodeStringArrayTemplate = string_template_1.default(StringArrayRC4DecodeNodeTemplate_1.StringArrayRc4DecodeNodeTemplate(this.randomGenerator), {
- atobPolyfill: atobPolyfill,
- rc4Polyfill: Rc4Template_1.Rc4Template(),
- selfDefendingCode: selfDefendingCode,
- stringArrayCallsWrapperName: this.stringArrayCallsWrapperName
- });
- break;
- case StringArrayEncoding_1.StringArrayEncoding.Base64:
- decodeStringArrayTemplate = string_template_1.default(StringArrayBase64DecodeNodeTemplate_1.StringArrayBase64DecodeNodeTemplate(this.randomGenerator), {
- atobPolyfill: atobPolyfill,
- selfDefendingCode: selfDefendingCode,
- stringArrayCallsWrapperName: this.stringArrayCallsWrapperName
- });
- break;
- }
- return decodeStringArrayTemplate;
- }
- }]);
- return StringArrayCallsWrapper;
- }(AbstractCustomNode_1.AbstractCustomNode);
- tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", String)], StringArrayCallsWrapper.prototype, "stringArrayName", void 0);
- tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", String)], StringArrayCallsWrapper.prototype, "stringArrayCallsWrapperName", void 0);
- StringArrayCallsWrapper = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IIdentifierNamesGenerator)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IEscapeSequenceEncoder)), tslib_1.__param(3, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object, Object, Object])], StringArrayCallsWrapper);
- exports.StringArrayCallsWrapper = StringArrayCallsWrapper;
- /***/ }),
- /* 103 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- function AtobTemplate() {
- return "\n (function () {\n {globalVariableTemplate}\n \n var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';\n\n that.atob || (\n that.atob = function(input) {\n var str = String(input).replace(/=+$/, '');\n for (\n var bc = 0, bs, buffer, idx = 0, output = '';\n buffer = str.charAt(idx++);\n ~buffer && (bs = bc % 4 ? bs * 64 + buffer : buffer,\n bc++ % 4) ? output += String.fromCharCode(255 & bs >> (-2 * bc & 6)) : 0\n ) {\n buffer = chars.indexOf(buffer);\n }\n return output;\n });\n })();\n ";
- }
- exports.AtobTemplate = AtobTemplate;
- /***/ }),
- /* 104 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- function Rc4Template() {
- return "\n var rc4 = function (str, key) {\n var s = [], j = 0, x, res = '', newStr = '';\n \n str = atob(str);\n \n for (var k = 0, length = str.length; k < length; k++) {\n newStr += '%' + ('00' + str.charCodeAt(k).toString(16)).slice(-2);\n }\n \n str = decodeURIComponent(newStr);\n \t \n\t for (var i = 0; i < 256; i++) {\n s[i] = i;\n }\n \n for (i = 0; i < 256; i++) {\n j = (j + s[i] + key.charCodeAt(i % key.length)) % 256;\n x = s[i];\n s[i] = s[j];\n s[j] = x;\n }\n \n i = 0;\n j = 0;\n \n for (var y = 0; y < str.length; y++) {\n i = (i + 1) % 256;\n j = (j + s[i]) % 256;\n x = s[i];\n s[i] = s[j];\n s[j] = x;\n res += String.fromCharCode(str.charCodeAt(y) ^ s[(s[i] + s[j]) % 256]);\n }\n \n return res;\n }\n ";
- }
- exports.Rc4Template = Rc4Template;
- /***/ }),
- /* 105 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- function SelfDefendingTemplate(randomGenerator, escapeSequenceEncoder) {
- var identifierLength = 6;
- var rc4BytesIdentifier = randomGenerator.getRandomString(identifierLength);
- var statesIdentifier = randomGenerator.getRandomString(identifierLength);
- var newStateIdentifier = randomGenerator.getRandomString(identifierLength);
- var firstStateIdentifier = randomGenerator.getRandomString(identifierLength);
- var secondStateIdentifier = randomGenerator.getRandomString(identifierLength);
- var checkStateIdentifier = randomGenerator.getRandomString(identifierLength);
- var runStateIdentifier = randomGenerator.getRandomString(identifierLength);
- var getStateIdentifier = randomGenerator.getRandomString(identifierLength);
- var stateResultIdentifier = randomGenerator.getRandomString(identifierLength);
- return "\n var StatesClass = function (" + rc4BytesIdentifier + ") {\n this." + rc4BytesIdentifier + " = " + rc4BytesIdentifier + ";\n this." + statesIdentifier + " = [1, 0, 0];\n this." + newStateIdentifier + " = function(){return 'newState';};\n this." + firstStateIdentifier + " = '" + escapeSequenceEncoder.encode("\\w+ *\\(\\) *{\\w+ *", true) + "';\n this." + secondStateIdentifier + " = '" + escapeSequenceEncoder.encode("['|\"].+['|\"];? *}", true) + "';\n };\n \n StatesClass.prototype." + checkStateIdentifier + " = function () {\n var regExp = new RegExp(this." + firstStateIdentifier + " + this." + secondStateIdentifier + ");\n var expression = regExp.test(this." + newStateIdentifier + ".toString())\n ? --this." + statesIdentifier + "[1]\n : --this." + statesIdentifier + "[0];\n \n return this." + runStateIdentifier + "(expression);\n };\n \n StatesClass.prototype." + runStateIdentifier + " = function (" + stateResultIdentifier + ") {\n if (!Boolean(~" + stateResultIdentifier + ")) {\n return " + stateResultIdentifier + ";\n }\n \n return this." + getStateIdentifier + "(this." + rc4BytesIdentifier + ");\n };\n\n StatesClass.prototype." + getStateIdentifier + " = function (" + rc4BytesIdentifier + ") {\n for (var i = 0, len = this." + statesIdentifier + ".length; i < len; i++) {\n this." + statesIdentifier + ".push(Math.round(Math.random()));\n len = this." + statesIdentifier + ".length;\n }\n \n return " + rc4BytesIdentifier + "(this." + statesIdentifier + "[0]);\n };\n\n new StatesClass({stringArrayCallsWrapperName})." + checkStateIdentifier + "();\n ";
- }
- exports.SelfDefendingTemplate = SelfDefendingTemplate;
- /***/ }),
- /* 106 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- function StringArrayBase64DecodeNodeTemplate(randomGenerator) {
- var identifierLength = 6;
- var initializedIdentifier = randomGenerator.getRandomString(identifierLength);
- var base64DecodeFunctionIdentifier = randomGenerator.getRandomString(identifierLength);
- var dataIdentifier = randomGenerator.getRandomString(identifierLength);
- return "\n if ({stringArrayCallsWrapperName}." + initializedIdentifier + " === undefined) {\n {atobPolyfill}\n \n {stringArrayCallsWrapperName}." + base64DecodeFunctionIdentifier + " = function (str) {\n var string = atob(str);\n var newStringChars = [];\n \n for (var i = 0, length = string.length; i < length; i++) {\n newStringChars += '%' + ('00' + string.charCodeAt(i).toString(16)).slice(-2);\n }\n \n return decodeURIComponent(newStringChars);\n };\n \n {stringArrayCallsWrapperName}." + dataIdentifier + " = {};\n \n {stringArrayCallsWrapperName}." + initializedIdentifier + " = true;\n }\n \n var cachedValue = {stringArrayCallsWrapperName}." + dataIdentifier + "[index];\n \n if (cachedValue === undefined) {\n {selfDefendingCode}\n \n value = {stringArrayCallsWrapperName}." + base64DecodeFunctionIdentifier + "(value);\n {stringArrayCallsWrapperName}." + dataIdentifier + "[index] = value;\n } else {\n value = cachedValue;\n }\n ";
- }
- exports.StringArrayBase64DecodeNodeTemplate = StringArrayBase64DecodeNodeTemplate;
- /***/ }),
- /* 107 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- function StringArrayCallsWrapperTemplate() {
- return "\n var {stringArrayCallsWrapperName} = function (index, key) {\n index = index - 0;\n \n var value = {stringArrayName}[index];\n \n {decodeNodeTemplate}\n \n return value;\n };\n ";
- }
- exports.StringArrayCallsWrapperTemplate = StringArrayCallsWrapperTemplate;
- /***/ }),
- /* 108 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- function StringArrayRc4DecodeNodeTemplate(randomGenerator) {
- var identifierLength = 6;
- var initializedIdentifier = randomGenerator.getRandomString(identifierLength);
- var rc4Identifier = randomGenerator.getRandomString(identifierLength);
- var dataIdentifier = randomGenerator.getRandomString(identifierLength);
- var onceIdentifier = randomGenerator.getRandomString(identifierLength);
- return "\n if ({stringArrayCallsWrapperName}." + initializedIdentifier + " === undefined) {\n {atobPolyfill}\n \n {rc4Polyfill}\n {stringArrayCallsWrapperName}." + rc4Identifier + " = rc4;\n \n {stringArrayCallsWrapperName}." + dataIdentifier + " = {};\n \n {stringArrayCallsWrapperName}." + initializedIdentifier + " = true;\n }\n \n var cachedValue = {stringArrayCallsWrapperName}." + dataIdentifier + "[index];\n\n if (cachedValue === undefined) {\n if ({stringArrayCallsWrapperName}." + onceIdentifier + " === undefined) {\n {selfDefendingCode}\n \n {stringArrayCallsWrapperName}." + onceIdentifier + " = true;\n }\n \n value = {stringArrayCallsWrapperName}." + rc4Identifier + "(value, key);\n {stringArrayCallsWrapperName}." + dataIdentifier + "[index] = value;\n } else {\n value = cachedValue;\n }\n ";
- }
- exports.StringArrayRc4DecodeNodeTemplate = StringArrayRc4DecodeNodeTemplate;
- /***/ }),
- /* 109 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- var _get = (function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } });
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var string_template_1 = tslib_1.__importDefault(__webpack_require__(12));
- var Initializable_1 = __webpack_require__(5);
- var StringArrayTemplate_1 = __webpack_require__(110);
- var AbstractCustomNode_1 = __webpack_require__(8);
- var NodeUtils_1 = __webpack_require__(4);
- var StringArrayNode = function (_AbstractCustomNode_) {
- _inherits(StringArrayNode, _AbstractCustomNode_);
- function StringArrayNode(identifierNamesGeneratorFactory, randomGenerator, options) {
- _classCallCheck(this, StringArrayNode);
- return _possibleConstructorReturn(this, (StringArrayNode.__proto__ || Object.getPrototypeOf(StringArrayNode)).call(this, identifierNamesGeneratorFactory, randomGenerator, options));
- }
- _createClass(StringArrayNode, [{
- key: "initialize",
- value: function initialize(stringArrayStorage, stringArrayName, stringArrayRotateValue) {
- this.stringArrayStorage = stringArrayStorage;
- this.stringArrayName = stringArrayName;
- this.stringArrayRotateValue = stringArrayRotateValue;
- }
- }, {
- key: "getNode",
- value: function getNode() {
- this.stringArrayStorage.rotateArray(this.stringArrayRotateValue);
- return _get(StringArrayNode.prototype.__proto__ || Object.getPrototypeOf(StringArrayNode.prototype), "getNode", this).call(this);
- }
- }, {
- key: "getNodeStructure",
- value: function getNodeStructure() {
- return NodeUtils_1.NodeUtils.convertCodeToStructure(this.getTemplate());
- }
- }, {
- key: "getTemplate",
- value: function getTemplate() {
- return string_template_1.default(StringArrayTemplate_1.StringArrayTemplate(), {
- stringArrayName: this.stringArrayName,
- stringArray: this.stringArrayStorage.toString()
- });
- }
- }]);
- return StringArrayNode;
- }(AbstractCustomNode_1.AbstractCustomNode);
- tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", Object)], StringArrayNode.prototype, "stringArrayStorage", void 0);
- tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", String)], StringArrayNode.prototype, "stringArrayName", void 0);
- tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", Number)], StringArrayNode.prototype, "stringArrayRotateValue", void 0);
- StringArrayNode = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IIdentifierNamesGenerator)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object, Object])], StringArrayNode);
- exports.StringArrayNode = StringArrayNode;
- /***/ }),
- /* 110 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- function StringArrayTemplate() {
- return "\n var {stringArrayName} = [{stringArray}];\n ";
- }
- exports.StringArrayTemplate = StringArrayTemplate;
- /***/ }),
- /* 111 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var string_template_1 = tslib_1.__importDefault(__webpack_require__(12));
- var Initializable_1 = __webpack_require__(5);
- var NoCustomNodes_1 = __webpack_require__(27);
- var SelfDefendingTemplate_1 = __webpack_require__(112);
- var StringArrayRotateFunctionTemplate_1 = __webpack_require__(113);
- var AbstractCustomNode_1 = __webpack_require__(8);
- var JavaScriptObfuscatorFacade_1 = __webpack_require__(19);
- var NodeUtils_1 = __webpack_require__(4);
- var Utils_1 = __webpack_require__(22);
- var StringArrayRotateFunctionNode = function (_AbstractCustomNode_) {
- _inherits(StringArrayRotateFunctionNode, _AbstractCustomNode_);
- function StringArrayRotateFunctionNode(identifierNamesGeneratorFactory, randomGenerator, escapeSequenceEncoder, options) {
- _classCallCheck(this, StringArrayRotateFunctionNode);
- var _this = _possibleConstructorReturn(this, (StringArrayRotateFunctionNode.__proto__ || Object.getPrototypeOf(StringArrayRotateFunctionNode)).call(this, identifierNamesGeneratorFactory, randomGenerator, options));
- _this.escapeSequenceEncoder = escapeSequenceEncoder;
- return _this;
- }
- _createClass(StringArrayRotateFunctionNode, [{
- key: "initialize",
- value: function initialize(stringArrayName, stringArrayRotateValue) {
- this.stringArrayName = stringArrayName;
- this.stringArrayRotateValue = stringArrayRotateValue;
- }
- }, {
- key: "getNodeStructure",
- value: function getNodeStructure() {
- return NodeUtils_1.NodeUtils.convertCodeToStructure(this.getTemplate());
- }
- }, {
- key: "getTemplate",
- value: function getTemplate() {
- var timesName = this.identifierNamesGenerator.generate();
- var whileFunctionName = this.identifierNamesGenerator.generate();
- var code = '';
- if (this.options.selfDefending) {
- code = string_template_1.default(SelfDefendingTemplate_1.SelfDefendingTemplate(this.escapeSequenceEncoder), {
- timesName: timesName,
- whileFunctionName: whileFunctionName
- });
- } else {
- code = whileFunctionName + "(++" + timesName + ")";
- }
- return JavaScriptObfuscatorFacade_1.JavaScriptObfuscator.obfuscate(string_template_1.default(StringArrayRotateFunctionTemplate_1.StringArrayRotateFunctionTemplate(), {
- code: code,
- timesName: timesName,
- stringArrayName: this.stringArrayName,
- stringArrayRotateValue: Utils_1.Utils.decToHex(this.stringArrayRotateValue),
- whileFunctionName: whileFunctionName
- }), Object.assign({}, NoCustomNodes_1.NO_ADDITIONAL_NODES_PRESET, { identifierNamesGenerator: this.options.identifierNamesGenerator, seed: this.options.seed })).getObfuscatedCode();
- }
- }]);
- return StringArrayRotateFunctionNode;
- }(AbstractCustomNode_1.AbstractCustomNode);
- tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", String)], StringArrayRotateFunctionNode.prototype, "stringArrayName", void 0);
- tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", Number)], StringArrayRotateFunctionNode.prototype, "stringArrayRotateValue", void 0);
- StringArrayRotateFunctionNode = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IIdentifierNamesGenerator)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IEscapeSequenceEncoder)), tslib_1.__param(3, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object, Object, Object])], StringArrayRotateFunctionNode);
- exports.StringArrayRotateFunctionNode = StringArrayRotateFunctionNode;
- /***/ }),
- /* 112 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- function SelfDefendingTemplate(escapeSequenceEncoder) {
- return "\n var selfDefendingFunc = function () {\n var object = {\n data: {\n key: 'cookie',\n value: 'timeout'\n },\n setCookie: function (options, name, value, document) {\n document = document || {};\n \n var updatedCookie = name + \"=\" + value;\n\n var i = 0;\n \n for (var i = 0, len = options.length; i < len; i++) {\n var propName = options[i];\n \n updatedCookie += \"; \" + propName;\n \n var propValue = options[propName];\n \n options.push(propValue);\n len = options.length;\n \n if (propValue !== true) {\n updatedCookie += \"=\" + propValue;\n }\n }\n\n document['cookie'] = updatedCookie;\n },\n removeCookie: function(){return 'dev';},\n getCookie: function (document, name) {\n document = document || function (value) { return value };\n var matches = document(new RegExp(\n \"(?:^|; )\" + name.replace(/([.$?*|{}()[]\\/+^])/g, '\\$1') + \"=([^;]*)\"\n ));\n \n var func = function (param1, param2) {\n param1(++param2);\n };\n \n func({whileFunctionName}, {timesName});\n \n return matches ? decodeURIComponent(matches[1]) : undefined;\n }\n };\n \n var test1 = function () {\n var regExp = new RegExp('" + escapeSequenceEncoder.encode("\\w+ *\\(\\) *{\\w+ *['|\"].+['|\"];? *}", true) + "');\n \n return regExp.test(object.removeCookie.toString());\n };\n \n object['updateCookie'] = test1;\n \n var cookie = '';\n var result = object['updateCookie']();\n \n if (!result) {\n object['setCookie'](['*'], 'counter', 1);\n } else if (result) {\n cookie = object['getCookie'](null, 'counter');\n } else {\n object['removeCookie']();\n }\n };\n \n selfDefendingFunc();\n ";
- }
- exports.SelfDefendingTemplate = SelfDefendingTemplate;
- /***/ }),
- /* 113 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- function StringArrayRotateFunctionTemplate() {
- return "\n (function (array, {timesName}) {\n var {whileFunctionName} = function (times) {\n while (--times) {\n array['push'](array['shift']());\n }\n };\n \n {code}\n })({stringArrayName}, 0x{stringArrayRotateValue});\n ";
- }
- exports.StringArrayRotateFunctionTemplate = StringArrayRotateFunctionTemplate;
- /***/ }),
- /* 114 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- var JSFuck;
- (function (JSFuck) {
- JSFuck["False"] = "![]";
- JSFuck["True"] = "!![]";
- JSFuck["a"] = "(false+\"\")[1]";
- JSFuck["b"] = "([][\"entries\"]()+\"\")[2]";
- JSFuck["c"] = "([][\"fill\"]+\"\")[3]";
- JSFuck["d"] = "(undefined+\"\")[2]";
- JSFuck["e"] = "(true+\"\")[3]";
- JSFuck["f"] = "(false+\"\")[0]";
- JSFuck["g"] = "(false+[0]+String)[20]";
- JSFuck["h"] = "(+(101))[\"toString\"](21)[1]";
- JSFuck["i"] = "([false]+undefined)[10]";
- JSFuck["j"] = "([][\"entries\"]()+\"\")[3]";
- JSFuck["k"] = "(+(20))[\"toString\"](21)";
- JSFuck["l"] = "(false+\"\")[2]";
- JSFuck["m"] = "(Number+\"\")[11]";
- JSFuck["n"] = "(undefined+\"\")[1]";
- JSFuck["o"] = "(true+[][\"fill\"])[10]";
- JSFuck["p"] = "(+(211))[\"toString\"](31)[1]";
- JSFuck["q"] = "(+(212))[\"toString\"](31)[1]";
- JSFuck["r"] = "(true+\"\")[1]";
- JSFuck["s"] = "(false+\"\")[3]";
- JSFuck["t"] = "(true+\"\")[0]";
- JSFuck["u"] = "(undefined+\"\")[0]";
- JSFuck["v"] = "(+(31))[\"toString\"](32)";
- JSFuck["w"] = "(+(32))[\"toString\"](33)";
- JSFuck["x"] = "(+(101))[\"toString\"](34)[1]";
- JSFuck["y"] = "(NaN+[Infinity])[10]";
- JSFuck["z"] = "(+(35))[\"toString\"](36)";
- JSFuck["A"] = "(+[]+Array)[10]";
- JSFuck["B"] = "(+[]+Boolean)[10]";
- JSFuck["C"] = "Function(\"return escape\")()((\"\")[\"italics\"]())[2]";
- JSFuck["D"] = "Function(\"return escape\")()([][\"fill\"])[\"slice\"](\"-1\")";
- JSFuck["E"] = "(RegExp+\"\")[12]";
- JSFuck["F"] = "(+[]+Function)[10]";
- JSFuck["G"] = "(false+Function(\"return Date\")()())[30]";
- JSFuck["H"] = "'H'";
- JSFuck["I"] = "(Infinity+\"\")[0]";
- JSFuck["J"] = "'J'";
- JSFuck["K"] = "'K'";
- JSFuck["L"] = "'L'";
- JSFuck["M"] = "(true+Function(\"return Date\")()())[30]";
- JSFuck["N"] = "(NaN+\"\")[0]";
- JSFuck["O"] = "(NaN+Function(\"return{}\")())[11]";
- JSFuck["P"] = "'P'";
- JSFuck["Q"] = "'Q'";
- JSFuck["R"] = "(+[]+RegExp)[10]";
- JSFuck["S"] = "(+[]+String)[10]";
- JSFuck["T"] = "(NaN+Function(\"return Date\")()())[30]";
- JSFuck["U"] = "(NaN+Function(\"return{}\")()[\"toString\"][\"call\"]())[11]";
- JSFuck["V"] = "'V'";
- JSFuck["W"] = "'W'";
- JSFuck["X"] = "'X'";
- JSFuck["Y"] = "'Y'";
- JSFuck["Z"] = "'Z'";
- })(JSFuck = exports.JSFuck || (exports.JSFuck = {}));
- /***/ }),
- /* 115 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var Initializable_1 = __webpack_require__(5);
- var AbstractCustomNode_1 = __webpack_require__(8);
- var Nodes_1 = __webpack_require__(9);
- var NodeUtils_1 = __webpack_require__(4);
- var StringLiteralControlFlowStorageCallNode = function (_AbstractCustomNode_) {
- _inherits(StringLiteralControlFlowStorageCallNode, _AbstractCustomNode_);
- function StringLiteralControlFlowStorageCallNode(identifierNamesGeneratorFactory, randomGenerator, options) {
- _classCallCheck(this, StringLiteralControlFlowStorageCallNode);
- return _possibleConstructorReturn(this, (StringLiteralControlFlowStorageCallNode.__proto__ || Object.getPrototypeOf(StringLiteralControlFlowStorageCallNode)).call(this, identifierNamesGeneratorFactory, randomGenerator, options));
- }
- _createClass(StringLiteralControlFlowStorageCallNode, [{
- key: "initialize",
- value: function initialize(controlFlowStorageName, controlFlowStorageKey) {
- this.controlFlowStorageName = controlFlowStorageName;
- this.controlFlowStorageKey = controlFlowStorageKey;
- }
- }, {
- key: "getNodeStructure",
- value: function getNodeStructure() {
- var structure = Nodes_1.Nodes.getExpressionStatementNode(Nodes_1.Nodes.getMemberExpressionNode(Nodes_1.Nodes.getIdentifierNode(this.controlFlowStorageName), Nodes_1.Nodes.getIdentifierNode(this.controlFlowStorageKey)));
- NodeUtils_1.NodeUtils.parentize(structure);
- return [structure];
- }
- }]);
- return StringLiteralControlFlowStorageCallNode;
- }(AbstractCustomNode_1.AbstractCustomNode);
- tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", String)], StringLiteralControlFlowStorageCallNode.prototype, "controlFlowStorageKey", void 0);
- tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", String)], StringLiteralControlFlowStorageCallNode.prototype, "controlFlowStorageName", void 0);
- StringLiteralControlFlowStorageCallNode = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IIdentifierNamesGenerator)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object, Object])], StringLiteralControlFlowStorageCallNode);
- exports.StringLiteralControlFlowStorageCallNode = StringLiteralControlFlowStorageCallNode;
- /***/ }),
- /* 116 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var Initializable_1 = __webpack_require__(5);
- var AbstractCustomNode_1 = __webpack_require__(8);
- var Nodes_1 = __webpack_require__(9);
- var StringLiteralNode = function (_AbstractCustomNode_) {
- _inherits(StringLiteralNode, _AbstractCustomNode_);
- function StringLiteralNode(identifierNamesGeneratorFactory, randomGenerator, options) {
- _classCallCheck(this, StringLiteralNode);
- return _possibleConstructorReturn(this, (StringLiteralNode.__proto__ || Object.getPrototypeOf(StringLiteralNode)).call(this, identifierNamesGeneratorFactory, randomGenerator, options));
- }
- _createClass(StringLiteralNode, [{
- key: "initialize",
- value: function initialize(literalValue) {
- this.literalValue = literalValue;
- }
- }, {
- key: "getNodeStructure",
- value: function getNodeStructure() {
- var structure = Nodes_1.Nodes.getExpressionStatementNode(Nodes_1.Nodes.getLiteralNode(this.literalValue));
- return [structure];
- }
- }]);
- return StringLiteralNode;
- }(AbstractCustomNode_1.AbstractCustomNode);
- tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", String)], StringLiteralNode.prototype, "literalValue", void 0);
- StringLiteralNode = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IIdentifierNamesGenerator)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object, Object])], StringLiteralNode);
- exports.StringLiteralNode = StringLiteralNode;
- /***/ }),
- /* 117 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- var inversify_1 = __webpack_require__(0);
- exports.finalizingTransformersModule = new inversify_1.ContainerModule(function (bind) {});
- /***/ }),
- /* 118 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var IdentifierNamesGenerator_1 = __webpack_require__(24);
- var HexadecimalIdentifierNamesGenerator_1 = __webpack_require__(119);
- var MangledIdentifierNamesGenerator_1 = __webpack_require__(120);
- exports.generatorsModule = new inversify_1.ContainerModule(function (bind) {
- bind(ServiceIdentifiers_1.ServiceIdentifiers.IIdentifierNamesGenerator).to(HexadecimalIdentifierNamesGenerator_1.HexadecimalIdentifierNamesGenerator).inSingletonScope().whenTargetNamed(IdentifierNamesGenerator_1.IdentifierNamesGenerator.HexadecimalIdentifierNamesGenerator);
- bind(ServiceIdentifiers_1.ServiceIdentifiers.IIdentifierNamesGenerator).to(MangledIdentifierNamesGenerator_1.MangledIdentifierNamesGenerator).inSingletonScope().whenTargetNamed(IdentifierNamesGenerator_1.IdentifierNamesGenerator.MangledIdentifierNamesGenerator);
- bind(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IIdentifierNamesGenerator).toFactory(function (context) {
- var cachedIdentifierNamesGenerator = null;
- return function (options) {
- if (cachedIdentifierNamesGenerator) {
- return cachedIdentifierNamesGenerator;
- }
- var identifierNamesGenerator = void 0;
- switch (options.identifierNamesGenerator) {
- case IdentifierNamesGenerator_1.IdentifierNamesGenerator.MangledIdentifierNamesGenerator:
- identifierNamesGenerator = context.container.getNamed(ServiceIdentifiers_1.ServiceIdentifiers.IIdentifierNamesGenerator, IdentifierNamesGenerator_1.IdentifierNamesGenerator.MangledIdentifierNamesGenerator);
- break;
- case IdentifierNamesGenerator_1.IdentifierNamesGenerator.HexadecimalIdentifierNamesGenerator:
- default:
- identifierNamesGenerator = context.container.getNamed(ServiceIdentifiers_1.ServiceIdentifiers.IIdentifierNamesGenerator, IdentifierNamesGenerator_1.IdentifierNamesGenerator.HexadecimalIdentifierNamesGenerator);
- }
- cachedIdentifierNamesGenerator = identifierNamesGenerator;
- return identifierNamesGenerator;
- };
- });
- });
- /***/ }),
- /* 119 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var AbstractIdentifierNamesGenerator_1 = __webpack_require__(42);
- var Utils_1 = __webpack_require__(22);
- var HexadecimalIdentifierNamesGenerator = HexadecimalIdentifierNamesGenerator_1 = function (_AbstractIdentifierNa) {
- _inherits(HexadecimalIdentifierNamesGenerator, _AbstractIdentifierNa);
- function HexadecimalIdentifierNamesGenerator(randomGenerator, options) {
- _classCallCheck(this, HexadecimalIdentifierNamesGenerator);
- var _this = _possibleConstructorReturn(this, (HexadecimalIdentifierNamesGenerator.__proto__ || Object.getPrototypeOf(HexadecimalIdentifierNamesGenerator)).call(this, randomGenerator, options));
- _this.randomVariableNameSet = new Set();
- return _this;
- }
- _createClass(HexadecimalIdentifierNamesGenerator, [{
- key: "generate",
- value: function generate() {
- var rangeMinInteger = 10000;
- var rangeMaxInteger = 99999999;
- var randomInteger = this.randomGenerator.getRandomInteger(rangeMinInteger, rangeMaxInteger);
- var hexadecimalNumber = Utils_1.Utils.decToHex(randomInteger);
- var baseIdentifierName = hexadecimalNumber.substr(0, HexadecimalIdentifierNamesGenerator_1.baseIdentifierNameLength);
- var identifierName = "_" + Utils_1.Utils.hexadecimalPrefix + baseIdentifierName;
- if (this.randomVariableNameSet.has(identifierName)) {
- return this.generate();
- }
- this.randomVariableNameSet.add(identifierName);
- return identifierName;
- }
- }, {
- key: "generateWithPrefix",
- value: function generateWithPrefix() {
- var identifierName = this.generate();
- return ("" + this.options.identifiersPrefix + identifierName).replace('__', '_');
- }
- }]);
- return HexadecimalIdentifierNamesGenerator;
- }(AbstractIdentifierNamesGenerator_1.AbstractIdentifierNamesGenerator);
- HexadecimalIdentifierNamesGenerator.baseIdentifierNameLength = 6;
- HexadecimalIdentifierNamesGenerator = HexadecimalIdentifierNamesGenerator_1 = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Object, Object])], HexadecimalIdentifierNamesGenerator);
- exports.HexadecimalIdentifierNamesGenerator = HexadecimalIdentifierNamesGenerator;
- var HexadecimalIdentifierNamesGenerator_1;
- /***/ }),
- /* 120 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var AbstractIdentifierNamesGenerator_1 = __webpack_require__(42);
- var MangledIdentifierNamesGenerator = MangledIdentifierNamesGenerator_1 = function (_AbstractIdentifierNa) {
- _inherits(MangledIdentifierNamesGenerator, _AbstractIdentifierNa);
- function MangledIdentifierNamesGenerator(randomGenerator, options) {
- _classCallCheck(this, MangledIdentifierNamesGenerator);
- var _this = _possibleConstructorReturn(this, (MangledIdentifierNamesGenerator.__proto__ || Object.getPrototypeOf(MangledIdentifierNamesGenerator)).call(this, randomGenerator, options));
- _this.previousMangledName = MangledIdentifierNamesGenerator_1.initMangledNameCharacter;
- return _this;
- }
- _createClass(MangledIdentifierNamesGenerator, [{
- key: "generate",
- value: function generate() {
- var identifierName = MangledIdentifierNamesGenerator_1.generateNewMangledName(this.previousMangledName);
- this.previousMangledName = identifierName;
- return identifierName;
- }
- }, {
- key: "generateWithPrefix",
- value: function generateWithPrefix() {
- var prefix = this.options.identifiersPrefix ? this.options.identifiersPrefix + "_" : '';
- var identifierName = this.generate();
- return "" + prefix + identifierName;
- }
- }], [{
- key: "generateNewMangledName",
- value: function generateNewMangledName(previousMangledName) {
- var generateNewMangledName = function generateNewMangledName(name) {
- var nameSequence = MangledIdentifierNamesGenerator_1.nameSequence;
- var nameLength = name.length;
- var zeroSequence = function zeroSequence(num) {
- return '0'.repeat(num);
- };
- var index = nameLength - 1;
- do {
- var character = name.charAt(index);
- var indexInSequence = nameSequence.indexOf(character);
- var lastNameSequenceIndex = nameSequence.length - 1;
- if (indexInSequence !== lastNameSequenceIndex) {
- var previousNamePart = name.substring(0, index);
- var nextCharacter = nameSequence[indexInSequence + 1];
- var zeroSequenceLength = nameLength - (index + 1);
- var zeroSequenceCharacters = zeroSequence(zeroSequenceLength);
- return previousNamePart + nextCharacter + zeroSequenceCharacters;
- }
- --index;
- } while (index >= 0);
- return "a" + zeroSequence(nameLength);
- };
- var newMangledName = generateNewMangledName(previousMangledName);
- if (!MangledIdentifierNamesGenerator_1.validateMangledName(newMangledName)) {
- newMangledName = MangledIdentifierNamesGenerator_1.generateNewMangledName(newMangledName);
- }
- return newMangledName;
- }
- }, {
- key: "validateMangledName",
- value: function validateMangledName(mangledName) {
- return !(MangledIdentifierNamesGenerator_1.reservedNames.indexOf(mangledName) !== -1);
- }
- }]);
- return MangledIdentifierNamesGenerator;
- }(AbstractIdentifierNamesGenerator_1.AbstractIdentifierNamesGenerator);
- MangledIdentifierNamesGenerator.initMangledNameCharacter = '9';
- MangledIdentifierNamesGenerator.nameSequence = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('');
- MangledIdentifierNamesGenerator.reservedNames = ['byte', 'case', 'char', 'do', 'else', 'enum', 'eval', 'for', 'goto', 'if', 'in', 'int', 'let', 'long', 'new', 'null', 'this', 'true', 'try', 'var', 'void', 'with'];
- MangledIdentifierNamesGenerator = MangledIdentifierNamesGenerator_1 = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Object, Object])], MangledIdentifierNamesGenerator);
- exports.MangledIdentifierNamesGenerator = MangledIdentifierNamesGenerator;
- var MangledIdentifierNamesGenerator_1;
- /***/ }),
- /* 121 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- var InversifyContainerFacade_1 = __webpack_require__(15);
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- exports.nodeTransformersModule = new inversify_1.ContainerModule(function (bind) {
- bind(ServiceIdentifiers_1.ServiceIdentifiers.Factory__INodeTransformer).toFactory(InversifyContainerFacade_1.InversifyContainerFacade.getCacheFactory(ServiceIdentifiers_1.ServiceIdentifiers.INodeTransformer));
- });
- /***/ }),
- /* 122 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- var InversifyContainerFacade_1 = __webpack_require__(15);
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var IdentifierObfuscatingReplacer_1 = __webpack_require__(18);
- var LiteralObfuscatingReplacer_1 = __webpack_require__(43);
- var NodeTransformer_1 = __webpack_require__(20);
- var BaseIdentifierObfuscatingReplacer_1 = __webpack_require__(123);
- var BooleanLiteralObfuscatingReplacer_1 = __webpack_require__(124);
- var CatchClauseTransformer_1 = __webpack_require__(125);
- var ClassDeclarationTransformer_1 = __webpack_require__(126);
- var FunctionDeclarationTransformer_1 = __webpack_require__(127);
- var FunctionTransformer_1 = __webpack_require__(128);
- var LabeledStatementTransformer_1 = __webpack_require__(129);
- var LiteralTransformer_1 = __webpack_require__(130);
- var NumberLiteralObfuscatingReplacer_1 = __webpack_require__(131);
- var ObjectExpressionTransformer_1 = __webpack_require__(132);
- var StringLiteralObfuscatingReplacer_1 = __webpack_require__(133);
- var VariableDeclarationTransformer_1 = __webpack_require__(134);
- exports.obfuscatingTransformersModule = new inversify_1.ContainerModule(function (bind) {
- bind(ServiceIdentifiers_1.ServiceIdentifiers.INodeTransformer).to(CatchClauseTransformer_1.CatchClauseTransformer).whenTargetNamed(NodeTransformer_1.NodeTransformer.CatchClauseTransformer);
- bind(ServiceIdentifiers_1.ServiceIdentifiers.INodeTransformer).to(ClassDeclarationTransformer_1.ClassDeclarationTransformer).whenTargetNamed(NodeTransformer_1.NodeTransformer.ClassDeclarationTransformer);
- bind(ServiceIdentifiers_1.ServiceIdentifiers.INodeTransformer).to(FunctionDeclarationTransformer_1.FunctionDeclarationTransformer).whenTargetNamed(NodeTransformer_1.NodeTransformer.FunctionDeclarationTransformer);
- bind(ServiceIdentifiers_1.ServiceIdentifiers.INodeTransformer).to(FunctionTransformer_1.FunctionTransformer).whenTargetNamed(NodeTransformer_1.NodeTransformer.FunctionTransformer);
- bind(ServiceIdentifiers_1.ServiceIdentifiers.INodeTransformer).to(LabeledStatementTransformer_1.LabeledStatementTransformer).whenTargetNamed(NodeTransformer_1.NodeTransformer.LabeledStatementTransformer);
- bind(ServiceIdentifiers_1.ServiceIdentifiers.INodeTransformer).to(LiteralTransformer_1.LiteralTransformer).whenTargetNamed(NodeTransformer_1.NodeTransformer.LiteralTransformer);
- bind(ServiceIdentifiers_1.ServiceIdentifiers.INodeTransformer).to(ObjectExpressionTransformer_1.ObjectExpressionTransformer).whenTargetNamed(NodeTransformer_1.NodeTransformer.ObjectExpressionTransformer);
- bind(ServiceIdentifiers_1.ServiceIdentifiers.INodeTransformer).to(VariableDeclarationTransformer_1.VariableDeclarationTransformer).whenTargetNamed(NodeTransformer_1.NodeTransformer.VariableDeclarationTransformer);
- bind(ServiceIdentifiers_1.ServiceIdentifiers.IObfuscatingReplacer).to(BooleanLiteralObfuscatingReplacer_1.BooleanLiteralObfuscatingReplacer).whenTargetNamed(LiteralObfuscatingReplacer_1.LiteralObfuscatingReplacer.BooleanLiteralObfuscatingReplacer);
- bind(ServiceIdentifiers_1.ServiceIdentifiers.IObfuscatingReplacer).to(NumberLiteralObfuscatingReplacer_1.NumberLiteralObfuscatingReplacer).whenTargetNamed(LiteralObfuscatingReplacer_1.LiteralObfuscatingReplacer.NumberLiteralObfuscatingReplacer);
- bind(ServiceIdentifiers_1.ServiceIdentifiers.IObfuscatingReplacer).to(StringLiteralObfuscatingReplacer_1.StringLiteralObfuscatingReplacer).whenTargetNamed(LiteralObfuscatingReplacer_1.LiteralObfuscatingReplacer.StringLiteralObfuscatingReplacer);
- bind(ServiceIdentifiers_1.ServiceIdentifiers.IIdentifierObfuscatingReplacer).to(BaseIdentifierObfuscatingReplacer_1.BaseIdentifierObfuscatingReplacer).whenTargetNamed(IdentifierObfuscatingReplacer_1.IdentifierObfuscatingReplacer.BaseIdentifierObfuscatingReplacer);
- bind(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IObfuscatingReplacer).toFactory(InversifyContainerFacade_1.InversifyContainerFacade.getCacheFactory(ServiceIdentifiers_1.ServiceIdentifiers.IObfuscatingReplacer));
- bind(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IIdentifierObfuscatingReplacer).toFactory(InversifyContainerFacade_1.InversifyContainerFacade.getCacheFactory(ServiceIdentifiers_1.ServiceIdentifiers.IIdentifierObfuscatingReplacer));
- });
- /***/ }),
- /* 123 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var AbstractObfuscatingReplacer_1 = __webpack_require__(28);
- var Nodes_1 = __webpack_require__(9);
- var BaseIdentifierObfuscatingReplacer = function (_AbstractObfuscatingR) {
- _inherits(BaseIdentifierObfuscatingReplacer, _AbstractObfuscatingR);
- function BaseIdentifierObfuscatingReplacer(identifierNamesGeneratorFactory, options) {
- _classCallCheck(this, BaseIdentifierObfuscatingReplacer);
- var _this = _possibleConstructorReturn(this, (BaseIdentifierObfuscatingReplacer.__proto__ || Object.getPrototypeOf(BaseIdentifierObfuscatingReplacer)).call(this, options));
- _this.namesMap = new Map();
- _this.identifierNamesGenerator = identifierNamesGeneratorFactory(options);
- return _this;
- }
- _createClass(BaseIdentifierObfuscatingReplacer, [{
- key: "replace",
- value: function replace(nodeValue, nodeIdentifier) {
- var mapKey = nodeValue + "-" + String(nodeIdentifier);
- if (this.namesMap.has(mapKey)) {
- nodeValue = this.namesMap.get(mapKey);
- }
- return Nodes_1.Nodes.getIdentifierNode(nodeValue);
- }
- }, {
- key: "storeGlobalName",
- value: function storeGlobalName(nodeName, nodeIdentifier) {
- if (this.isReservedName(nodeName)) {
- return;
- }
- var identifierName = this.identifierNamesGenerator.generateWithPrefix();
- this.namesMap.set(nodeName + "-" + String(nodeIdentifier), identifierName);
- }
- }, {
- key: "storeLocalName",
- value: function storeLocalName(nodeName, nodeIdentifier) {
- if (this.isReservedName(nodeName)) {
- return;
- }
- var identifierName = this.identifierNamesGenerator.generate();
- this.namesMap.set(nodeName + "-" + String(nodeIdentifier), identifierName);
- }
- }, {
- key: "isReservedName",
- value: function isReservedName(name) {
- return this.options.reservedNames.some(function (reservedName) {
- return new RegExp(reservedName, 'g').exec(name) !== null;
- });
- }
- }]);
- return BaseIdentifierObfuscatingReplacer;
- }(AbstractObfuscatingReplacer_1.AbstractObfuscatingReplacer);
- BaseIdentifierObfuscatingReplacer = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IIdentifierNamesGenerator)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object])], BaseIdentifierObfuscatingReplacer);
- exports.BaseIdentifierObfuscatingReplacer = BaseIdentifierObfuscatingReplacer;
- /***/ }),
- /* 124 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var AbstractObfuscatingReplacer_1 = __webpack_require__(28);
- var Nodes_1 = __webpack_require__(9);
- var BooleanLiteralObfuscatingReplacer = BooleanLiteralObfuscatingReplacer_1 = function (_AbstractObfuscatingR) {
- _inherits(BooleanLiteralObfuscatingReplacer, _AbstractObfuscatingR);
- function BooleanLiteralObfuscatingReplacer(options) {
- _classCallCheck(this, BooleanLiteralObfuscatingReplacer);
- return _possibleConstructorReturn(this, (BooleanLiteralObfuscatingReplacer.__proto__ || Object.getPrototypeOf(BooleanLiteralObfuscatingReplacer)).call(this, options));
- }
- _createClass(BooleanLiteralObfuscatingReplacer, [{
- key: "replace",
- value: function replace(nodeValue) {
- return nodeValue ? BooleanLiteralObfuscatingReplacer_1.getTrueUnaryExpressionNode() : BooleanLiteralObfuscatingReplacer_1.getFalseUnaryExpressionNode();
- }
- }], [{
- key: "getTrueUnaryExpressionNode",
- value: function getTrueUnaryExpressionNode() {
- return Nodes_1.Nodes.getUnaryExpressionNode('!', BooleanLiteralObfuscatingReplacer_1.getFalseUnaryExpressionNode());
- }
- }, {
- key: "getFalseUnaryExpressionNode",
- value: function getFalseUnaryExpressionNode() {
- return Nodes_1.Nodes.getUnaryExpressionNode('!', Nodes_1.Nodes.getArrayExpressionNode());
- }
- }]);
- return BooleanLiteralObfuscatingReplacer;
- }(AbstractObfuscatingReplacer_1.AbstractObfuscatingReplacer);
- BooleanLiteralObfuscatingReplacer = BooleanLiteralObfuscatingReplacer_1 = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Object])], BooleanLiteralObfuscatingReplacer);
- exports.BooleanLiteralObfuscatingReplacer = BooleanLiteralObfuscatingReplacer;
- var BooleanLiteralObfuscatingReplacer_1;
- /***/ }),
- /* 125 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var estraverse = tslib_1.__importStar(__webpack_require__(10));
- var IdentifierObfuscatingReplacer_1 = __webpack_require__(18);
- var TransformationStage_1 = __webpack_require__(6);
- var AbstractNodeTransformer_1 = __webpack_require__(7);
- var NodeGuards_1 = __webpack_require__(3);
- var CatchClauseTransformer = function (_AbstractNodeTransfor) {
- _inherits(CatchClauseTransformer, _AbstractNodeTransfor);
- function CatchClauseTransformer(identifierObfuscatingReplacerFactory, randomGenerator, options) {
- _classCallCheck(this, CatchClauseTransformer);
- var _this = _possibleConstructorReturn(this, (CatchClauseTransformer.__proto__ || Object.getPrototypeOf(CatchClauseTransformer)).call(this, randomGenerator, options));
- _this.identifierObfuscatingReplacer = identifierObfuscatingReplacerFactory(IdentifierObfuscatingReplacer_1.IdentifierObfuscatingReplacer.BaseIdentifierObfuscatingReplacer);
- return _this;
- }
- _createClass(CatchClauseTransformer, [{
- key: "getVisitor",
- value: function getVisitor(transformationStage) {
- var _this2 = this;
- switch (transformationStage) {
- case TransformationStage_1.TransformationStage.Obfuscating:
- return {
- enter: function enter(node, parentNode) {
- if (parentNode && NodeGuards_1.NodeGuards.isCatchClauseNode(node)) {
- return _this2.transformNode(node, parentNode);
- }
- }
- };
- default:
- return null;
- }
- }
- }, {
- key: "transformNode",
- value: function transformNode(catchClauseNode, parentNode) {
- var nodeIdentifier = this.nodeIdentifier++;
- this.storeCatchClauseParam(catchClauseNode, nodeIdentifier);
- this.replaceCatchClauseParam(catchClauseNode, nodeIdentifier);
- return catchClauseNode;
- }
- }, {
- key: "storeCatchClauseParam",
- value: function storeCatchClauseParam(catchClauseNode, nodeIdentifier) {
- if (NodeGuards_1.NodeGuards.isIdentifierNode(catchClauseNode.param)) {
- this.identifierObfuscatingReplacer.storeLocalName(catchClauseNode.param.name, nodeIdentifier);
- }
- }
- }, {
- key: "replaceCatchClauseParam",
- value: function replaceCatchClauseParam(catchClauseNode, nodeIdentifier) {
- var _this3 = this;
- estraverse.replace(catchClauseNode, {
- enter: function enter(node, parentNode) {
- if (parentNode && NodeGuards_1.NodeGuards.isReplaceableIdentifierNode(node, parentNode)) {
- var newIdentifier = _this3.identifierObfuscatingReplacer.replace(node.name, nodeIdentifier);
- var newIdentifierName = newIdentifier.name;
- if (node.name !== newIdentifierName) {
- node.name = newIdentifierName;
- node.obfuscatedNode = true;
- }
- }
- }
- });
- }
- }]);
- return CatchClauseTransformer;
- }(AbstractNodeTransformer_1.AbstractNodeTransformer);
- CatchClauseTransformer = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IIdentifierObfuscatingReplacer)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object, Object])], CatchClauseTransformer);
- exports.CatchClauseTransformer = CatchClauseTransformer;
- /***/ }),
- /* 126 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var estraverse = tslib_1.__importStar(__webpack_require__(10));
- var IdentifierObfuscatingReplacer_1 = __webpack_require__(18);
- var NodeType_1 = __webpack_require__(11);
- var TransformationStage_1 = __webpack_require__(6);
- var AbstractNodeTransformer_1 = __webpack_require__(7);
- var NodeGuards_1 = __webpack_require__(3);
- var NodeUtils_1 = __webpack_require__(4);
- var ClassDeclarationTransformer = function (_AbstractNodeTransfor) {
- _inherits(ClassDeclarationTransformer, _AbstractNodeTransfor);
- function ClassDeclarationTransformer(identifierObfuscatingReplacerFactory, randomGenerator, options) {
- _classCallCheck(this, ClassDeclarationTransformer);
- var _this = _possibleConstructorReturn(this, (ClassDeclarationTransformer.__proto__ || Object.getPrototypeOf(ClassDeclarationTransformer)).call(this, randomGenerator, options));
- _this.replaceableIdentifiers = new Map();
- _this.identifierObfuscatingReplacer = identifierObfuscatingReplacerFactory(IdentifierObfuscatingReplacer_1.IdentifierObfuscatingReplacer.BaseIdentifierObfuscatingReplacer);
- return _this;
- }
- _createClass(ClassDeclarationTransformer, [{
- key: "getVisitor",
- value: function getVisitor(transformationStage) {
- var _this2 = this;
- switch (transformationStage) {
- case TransformationStage_1.TransformationStage.Obfuscating:
- return {
- enter: function enter(node, parentNode) {
- if (parentNode && NodeGuards_1.NodeGuards.isClassDeclarationNode(node)) {
- return _this2.transformNode(node, parentNode);
- }
- }
- };
- default:
- return null;
- }
- }
- }, {
- key: "transformNode",
- value: function transformNode(classDeclarationNode, parentNode) {
- var nodeIdentifier = this.nodeIdentifier++;
- var blockScopeNode = NodeUtils_1.NodeUtils.getBlockScopesOfNode(classDeclarationNode)[0];
- var isGlobalDeclaration = blockScopeNode.type === NodeType_1.NodeType.Program;
- if (!this.options.renameGlobals && isGlobalDeclaration) {
- return classDeclarationNode;
- }
- this.storeClassName(classDeclarationNode, isGlobalDeclaration, nodeIdentifier);
- if (this.replaceableIdentifiers.has(blockScopeNode)) {
- this.replaceScopeCachedIdentifiers(blockScopeNode, nodeIdentifier);
- } else {
- this.replaceScopeIdentifiers(blockScopeNode, nodeIdentifier);
- }
- return classDeclarationNode;
- }
- }, {
- key: "storeClassName",
- value: function storeClassName(classDeclarationNode, isGlobalDeclaration, nodeIdentifier) {
- if (isGlobalDeclaration) {
- this.identifierObfuscatingReplacer.storeGlobalName(classDeclarationNode.id.name, nodeIdentifier);
- } else {
- this.identifierObfuscatingReplacer.storeLocalName(classDeclarationNode.id.name, nodeIdentifier);
- }
- }
- }, {
- key: "replaceScopeCachedIdentifiers",
- value: function replaceScopeCachedIdentifiers(blockScopeNode, nodeIdentifier) {
- var _this3 = this;
- var cachedReplaceableIdentifiers = this.replaceableIdentifiers.get(blockScopeNode);
- cachedReplaceableIdentifiers.forEach(function (replaceableIdentifier) {
- var newReplaceableIdentifier = _this3.identifierObfuscatingReplacer.replace(replaceableIdentifier.name, nodeIdentifier);
- replaceableIdentifier.name = newReplaceableIdentifier.name;
- });
- }
- }, {
- key: "replaceScopeIdentifiers",
- value: function replaceScopeIdentifiers(blockScopeNode, nodeIdentifier) {
- var _this4 = this;
- var storedReplaceableIdentifiers = [];
- estraverse.replace(blockScopeNode, {
- enter: function enter(node, parentNode) {
- if (parentNode && NodeGuards_1.NodeGuards.isReplaceableIdentifierNode(node, parentNode)) {
- var newIdentifier = _this4.identifierObfuscatingReplacer.replace(node.name, nodeIdentifier);
- var newIdentifierName = newIdentifier.name;
- if (node.name !== newIdentifierName) {
- node.name = newIdentifierName;
- } else {
- storedReplaceableIdentifiers.push(node);
- }
- }
- }
- });
- this.replaceableIdentifiers.set(blockScopeNode, storedReplaceableIdentifiers);
- }
- }]);
- return ClassDeclarationTransformer;
- }(AbstractNodeTransformer_1.AbstractNodeTransformer);
- ClassDeclarationTransformer = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IIdentifierObfuscatingReplacer)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object, Object])], ClassDeclarationTransformer);
- exports.ClassDeclarationTransformer = ClassDeclarationTransformer;
- /***/ }),
- /* 127 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var estraverse = tslib_1.__importStar(__webpack_require__(10));
- var IdentifierObfuscatingReplacer_1 = __webpack_require__(18);
- var NodeType_1 = __webpack_require__(11);
- var TransformationStage_1 = __webpack_require__(6);
- var AbstractNodeTransformer_1 = __webpack_require__(7);
- var NodeGuards_1 = __webpack_require__(3);
- var NodeUtils_1 = __webpack_require__(4);
- var FunctionDeclarationTransformer = function (_AbstractNodeTransfor) {
- _inherits(FunctionDeclarationTransformer, _AbstractNodeTransfor);
- function FunctionDeclarationTransformer(identifierObfuscatingReplacerFactory, randomGenerator, options) {
- _classCallCheck(this, FunctionDeclarationTransformer);
- var _this = _possibleConstructorReturn(this, (FunctionDeclarationTransformer.__proto__ || Object.getPrototypeOf(FunctionDeclarationTransformer)).call(this, randomGenerator, options));
- _this.replaceableIdentifiers = new Map();
- _this.identifierObfuscatingReplacer = identifierObfuscatingReplacerFactory(IdentifierObfuscatingReplacer_1.IdentifierObfuscatingReplacer.BaseIdentifierObfuscatingReplacer);
- return _this;
- }
- _createClass(FunctionDeclarationTransformer, [{
- key: "getVisitor",
- value: function getVisitor(transformationStage) {
- var _this2 = this;
- switch (transformationStage) {
- case TransformationStage_1.TransformationStage.Obfuscating:
- return {
- enter: function enter(node, parentNode) {
- if (parentNode && NodeGuards_1.NodeGuards.isFunctionDeclarationNode(node)) {
- return _this2.transformNode(node, parentNode);
- }
- }
- };
- default:
- return null;
- }
- }
- }, {
- key: "transformNode",
- value: function transformNode(functionDeclarationNode, parentNode) {
- var nodeIdentifier = this.nodeIdentifier++;
- var blockScopeNode = NodeUtils_1.NodeUtils.getBlockScopesOfNode(functionDeclarationNode)[0];
- var isGlobalDeclaration = blockScopeNode.type === NodeType_1.NodeType.Program;
- if (!this.options.renameGlobals && isGlobalDeclaration) {
- return functionDeclarationNode;
- }
- this.storeFunctionName(functionDeclarationNode, isGlobalDeclaration, nodeIdentifier);
- if (this.replaceableIdentifiers.has(blockScopeNode)) {
- this.replaceScopeCachedIdentifiers(functionDeclarationNode, blockScopeNode, nodeIdentifier);
- } else {
- this.replaceScopeIdentifiers(blockScopeNode, nodeIdentifier);
- }
- return functionDeclarationNode;
- }
- }, {
- key: "storeFunctionName",
- value: function storeFunctionName(functionDeclarationNode, isGlobalDeclaration, nodeIdentifier) {
- if (isGlobalDeclaration) {
- this.identifierObfuscatingReplacer.storeGlobalName(functionDeclarationNode.id.name, nodeIdentifier);
- } else {
- this.identifierObfuscatingReplacer.storeLocalName(functionDeclarationNode.id.name, nodeIdentifier);
- }
- }
- }, {
- key: "replaceScopeCachedIdentifiers",
- value: function replaceScopeCachedIdentifiers(functionDeclarationNode, blockScopeNode, nodeIdentifier) {
- var cachedReplaceableIdentifiersNamesMap = this.replaceableIdentifiers.get(blockScopeNode);
- if (!cachedReplaceableIdentifiersNamesMap) {
- return;
- }
- var cachedReplaceableIdentifiers = cachedReplaceableIdentifiersNamesMap.get(functionDeclarationNode.id.name);
- if (!cachedReplaceableIdentifiers) {
- return;
- }
- var cachedReplaceableIdentifierLength = cachedReplaceableIdentifiers.length;
- for (var i = 0; i < cachedReplaceableIdentifierLength; i++) {
- var replaceableIdentifier = cachedReplaceableIdentifiers[i];
- var newReplaceableIdentifier = this.identifierObfuscatingReplacer.replace(replaceableIdentifier.name, nodeIdentifier);
- replaceableIdentifier.name = newReplaceableIdentifier.name;
- }
- }
- }, {
- key: "replaceScopeIdentifiers",
- value: function replaceScopeIdentifiers(blockScopeNode, nodeIdentifier) {
- var _this3 = this;
- var storedReplaceableIdentifiersNamesMap = new Map();
- estraverse.replace(blockScopeNode, {
- enter: function enter(node, parentNode) {
- if (parentNode && NodeGuards_1.NodeGuards.isReplaceableIdentifierNode(node, parentNode)) {
- var newIdentifier = _this3.identifierObfuscatingReplacer.replace(node.name, nodeIdentifier);
- var newIdentifierName = newIdentifier.name;
- if (node.name !== newIdentifierName) {
- node.name = newIdentifierName;
- } else {
- var storedReplaceableIdentifiers = storedReplaceableIdentifiersNamesMap.get(node.name) || [];
- storedReplaceableIdentifiers.push(node);
- storedReplaceableIdentifiersNamesMap.set(node.name, storedReplaceableIdentifiers);
- }
- }
- }
- });
- this.replaceableIdentifiers.set(blockScopeNode, storedReplaceableIdentifiersNamesMap);
- }
- }]);
- return FunctionDeclarationTransformer;
- }(AbstractNodeTransformer_1.AbstractNodeTransformer);
- FunctionDeclarationTransformer = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IIdentifierObfuscatingReplacer)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object, Object])], FunctionDeclarationTransformer);
- exports.FunctionDeclarationTransformer = FunctionDeclarationTransformer;
- /***/ }),
- /* 128 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var estraverse = tslib_1.__importStar(__webpack_require__(10));
- var IdentifierObfuscatingReplacer_1 = __webpack_require__(18);
- var TransformationStage_1 = __webpack_require__(6);
- var AbstractNodeTransformer_1 = __webpack_require__(7);
- var NodeGuards_1 = __webpack_require__(3);
- var FunctionTransformer = function (_AbstractNodeTransfor) {
- _inherits(FunctionTransformer, _AbstractNodeTransfor);
- function FunctionTransformer(identifierObfuscatingReplacerFactory, randomGenerator, options) {
- _classCallCheck(this, FunctionTransformer);
- var _this = _possibleConstructorReturn(this, (FunctionTransformer.__proto__ || Object.getPrototypeOf(FunctionTransformer)).call(this, randomGenerator, options));
- _this.identifierObfuscatingReplacer = identifierObfuscatingReplacerFactory(IdentifierObfuscatingReplacer_1.IdentifierObfuscatingReplacer.BaseIdentifierObfuscatingReplacer);
- return _this;
- }
- _createClass(FunctionTransformer, [{
- key: "getVisitor",
- value: function getVisitor(transformationStage) {
- var _this2 = this;
- switch (transformationStage) {
- case TransformationStage_1.TransformationStage.Obfuscating:
- return {
- enter: function enter(node, parentNode) {
- if (parentNode && (NodeGuards_1.NodeGuards.isFunctionDeclarationNode(node) || NodeGuards_1.NodeGuards.isFunctionExpressionNode(node) || NodeGuards_1.NodeGuards.isArrowFunctionExpressionNode(node))) {
- return _this2.transformNode(node, parentNode);
- }
- }
- };
- default:
- return null;
- }
- }
- }, {
- key: "transformNode",
- value: function transformNode(functionNode, parentNode) {
- var nodeIdentifier = this.nodeIdentifier++;
- this.storeFunctionParams(functionNode, nodeIdentifier);
- this.replaceFunctionParams(functionNode, nodeIdentifier);
- return functionNode;
- }
- }, {
- key: "storeFunctionParams",
- value: function storeFunctionParams(functionNode, nodeIdentifier) {
- var _this3 = this;
- functionNode.params.forEach(function (paramsNode) {
- if (NodeGuards_1.NodeGuards.isObjectPatternNode(paramsNode)) {
- return estraverse.VisitorOption.Skip;
- }
- estraverse.traverse(paramsNode, {
- enter: function enter(node) {
- if (NodeGuards_1.NodeGuards.isAssignmentPatternNode(node) && NodeGuards_1.NodeGuards.isIdentifierNode(node.left)) {
- _this3.identifierObfuscatingReplacer.storeLocalName(node.left.name, nodeIdentifier);
- return estraverse.VisitorOption.Skip;
- }
- if (NodeGuards_1.NodeGuards.isIdentifierNode(node)) {
- _this3.identifierObfuscatingReplacer.storeLocalName(node.name, nodeIdentifier);
- }
- }
- });
- });
- }
- }, {
- key: "addIdentifiersToIgnoredIdentifierNamesSet",
- value: function addIdentifiersToIgnoredIdentifierNamesSet(properties, ignoredIdentifierNamesSet) {
- properties.forEach(function (property) {
- if (!NodeGuards_1.NodeGuards.isIdentifierNode(property.key)) {
- return;
- }
- ignoredIdentifierNamesSet.add(property.key.name);
- });
- }
- }, {
- key: "replaceFunctionParams",
- value: function replaceFunctionParams(functionNode, nodeIdentifier) {
- var _this4 = this;
- var ignoredIdentifierNamesSet = new Set();
- var replaceVisitor = {
- enter: function enter(node, parentNode) {
- if (NodeGuards_1.NodeGuards.isObjectPatternNode(node)) {
- _this4.addIdentifiersToIgnoredIdentifierNamesSet(node.properties, ignoredIdentifierNamesSet);
- }
- if (parentNode && NodeGuards_1.NodeGuards.isReplaceableIdentifierNode(node, parentNode) && !ignoredIdentifierNamesSet.has(node.name)) {
- var newIdentifier = _this4.identifierObfuscatingReplacer.replace(node.name, nodeIdentifier);
- var newIdentifierName = newIdentifier.name;
- if (node.name !== newIdentifierName) {
- node.name = newIdentifierName;
- node.obfuscatedNode = true;
- }
- }
- }
- };
- functionNode.params.forEach(function (paramsNode) {
- return estraverse.replace(paramsNode, replaceVisitor);
- });
- estraverse.replace(functionNode.body, replaceVisitor);
- }
- }]);
- return FunctionTransformer;
- }(AbstractNodeTransformer_1.AbstractNodeTransformer);
- FunctionTransformer = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IIdentifierObfuscatingReplacer)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object, Object])], FunctionTransformer);
- exports.FunctionTransformer = FunctionTransformer;
- /***/ }),
- /* 129 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var estraverse = tslib_1.__importStar(__webpack_require__(10));
- var IdentifierObfuscatingReplacer_1 = __webpack_require__(18);
- var TransformationStage_1 = __webpack_require__(6);
- var AbstractNodeTransformer_1 = __webpack_require__(7);
- var NodeGuards_1 = __webpack_require__(3);
- var LabeledStatementTransformer = function (_AbstractNodeTransfor) {
- _inherits(LabeledStatementTransformer, _AbstractNodeTransfor);
- function LabeledStatementTransformer(identifierObfuscatingReplacerFactory, randomGenerator, options) {
- _classCallCheck(this, LabeledStatementTransformer);
- var _this = _possibleConstructorReturn(this, (LabeledStatementTransformer.__proto__ || Object.getPrototypeOf(LabeledStatementTransformer)).call(this, randomGenerator, options));
- _this.identifierObfuscatingReplacer = identifierObfuscatingReplacerFactory(IdentifierObfuscatingReplacer_1.IdentifierObfuscatingReplacer.BaseIdentifierObfuscatingReplacer);
- return _this;
- }
- _createClass(LabeledStatementTransformer, [{
- key: "getVisitor",
- value: function getVisitor(transformationStage) {
- var _this2 = this;
- switch (transformationStage) {
- case TransformationStage_1.TransformationStage.Obfuscating:
- return {
- enter: function enter(node, parentNode) {
- if (parentNode && NodeGuards_1.NodeGuards.isLabeledStatementNode(node)) {
- return _this2.transformNode(node, parentNode);
- }
- }
- };
- default:
- return null;
- }
- }
- }, {
- key: "transformNode",
- value: function transformNode(labeledStatementNode, parentNode) {
- var nodeIdentifier = this.nodeIdentifier++;
- this.storeLabeledStatementName(labeledStatementNode, nodeIdentifier);
- this.replaceLabeledStatementName(labeledStatementNode, nodeIdentifier);
- return labeledStatementNode;
- }
- }, {
- key: "storeLabeledStatementName",
- value: function storeLabeledStatementName(labeledStatementNode, nodeIdentifier) {
- this.identifierObfuscatingReplacer.storeLocalName(labeledStatementNode.label.name, nodeIdentifier);
- }
- }, {
- key: "replaceLabeledStatementName",
- value: function replaceLabeledStatementName(labeledStatementNode, nodeIdentifier) {
- var _this3 = this;
- estraverse.replace(labeledStatementNode, {
- enter: function enter(node, parentNode) {
- if (parentNode && NodeGuards_1.NodeGuards.isLabelIdentifierNode(node, parentNode)) {
- var newIdentifier = _this3.identifierObfuscatingReplacer.replace(node.name, nodeIdentifier);
- node.name = newIdentifier.name;
- }
- }
- });
- }
- }]);
- return LabeledStatementTransformer;
- }(AbstractNodeTransformer_1.AbstractNodeTransformer);
- LabeledStatementTransformer = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IIdentifierObfuscatingReplacer)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object, Object])], LabeledStatementTransformer);
- exports.LabeledStatementTransformer = LabeledStatementTransformer;
- /***/ }),
- /* 130 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var LiteralObfuscatingReplacer_1 = __webpack_require__(43);
- var TransformationStage_1 = __webpack_require__(6);
- var AbstractNodeTransformer_1 = __webpack_require__(7);
- var NodeGuards_1 = __webpack_require__(3);
- var LiteralTransformer = function (_AbstractNodeTransfor) {
- _inherits(LiteralTransformer, _AbstractNodeTransfor);
- function LiteralTransformer(literalObfuscatingReplacerFactory, randomGenerator, options) {
- _classCallCheck(this, LiteralTransformer);
- var _this = _possibleConstructorReturn(this, (LiteralTransformer.__proto__ || Object.getPrototypeOf(LiteralTransformer)).call(this, randomGenerator, options));
- _this.literalObfuscatingReplacerFactory = literalObfuscatingReplacerFactory;
- return _this;
- }
- _createClass(LiteralTransformer, [{
- key: "getVisitor",
- value: function getVisitor(transformationStage) {
- var _this2 = this;
- switch (transformationStage) {
- case TransformationStage_1.TransformationStage.Obfuscating:
- return {
- enter: function enter(node, parentNode) {
- if (parentNode && NodeGuards_1.NodeGuards.isLiteralNode(node) && !node.obfuscatedNode) {
- return _this2.transformNode(node, parentNode);
- }
- }
- };
- default:
- return null;
- }
- }
- }, {
- key: "transformNode",
- value: function transformNode(literalNode, parentNode) {
- if (parentNode && NodeGuards_1.NodeGuards.isPropertyNode(parentNode) && parentNode.key === literalNode) {
- return literalNode;
- }
- switch (_typeof(literalNode.value)) {
- case 'boolean':
- return this.literalObfuscatingReplacerFactory(LiteralObfuscatingReplacer_1.LiteralObfuscatingReplacer.BooleanLiteralObfuscatingReplacer).replace(literalNode.value);
- case 'number':
- return this.literalObfuscatingReplacerFactory(LiteralObfuscatingReplacer_1.LiteralObfuscatingReplacer.NumberLiteralObfuscatingReplacer).replace(literalNode.value);
- case 'string':
- return this.literalObfuscatingReplacerFactory(LiteralObfuscatingReplacer_1.LiteralObfuscatingReplacer.StringLiteralObfuscatingReplacer).replace(literalNode.value);
- default:
- return literalNode;
- }
- }
- }]);
- return LiteralTransformer;
- }(AbstractNodeTransformer_1.AbstractNodeTransformer);
- LiteralTransformer = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IObfuscatingReplacer)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object, Object])], LiteralTransformer);
- exports.LiteralTransformer = LiteralTransformer;
- /***/ }),
- /* 131 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var AbstractObfuscatingReplacer_1 = __webpack_require__(28);
- var Nodes_1 = __webpack_require__(9);
- var Utils_1 = __webpack_require__(22);
- var NumberLiteralObfuscatingReplacer = function (_AbstractObfuscatingR) {
- _inherits(NumberLiteralObfuscatingReplacer, _AbstractObfuscatingR);
- function NumberLiteralObfuscatingReplacer(options) {
- _classCallCheck(this, NumberLiteralObfuscatingReplacer);
- var _this = _possibleConstructorReturn(this, (NumberLiteralObfuscatingReplacer.__proto__ || Object.getPrototypeOf(NumberLiteralObfuscatingReplacer)).call(this, options));
- _this.numberLiteralCache = new Map();
- return _this;
- }
- _createClass(NumberLiteralObfuscatingReplacer, [{
- key: "replace",
- value: function replace(nodeValue) {
- var rawValue = void 0;
- if (this.numberLiteralCache.has(nodeValue)) {
- rawValue = this.numberLiteralCache.get(nodeValue);
- } else {
- if (!Utils_1.Utils.isCeilNumber(nodeValue)) {
- rawValue = String(nodeValue);
- } else {
- rawValue = "" + Utils_1.Utils.hexadecimalPrefix + Utils_1.Utils.decToHex(nodeValue);
- }
- this.numberLiteralCache.set(nodeValue, rawValue);
- }
- return Nodes_1.Nodes.getLiteralNode(nodeValue, rawValue);
- }
- }]);
- return NumberLiteralObfuscatingReplacer;
- }(AbstractObfuscatingReplacer_1.AbstractObfuscatingReplacer);
- NumberLiteralObfuscatingReplacer = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Object])], NumberLiteralObfuscatingReplacer);
- exports.NumberLiteralObfuscatingReplacer = NumberLiteralObfuscatingReplacer;
- /***/ }),
- /* 132 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var NodeType_1 = __webpack_require__(11);
- var TransformationStage_1 = __webpack_require__(6);
- var AbstractNodeTransformer_1 = __webpack_require__(7);
- var NodeGuards_1 = __webpack_require__(3);
- var ObjectExpressionTransformer = ObjectExpressionTransformer_1 = function (_AbstractNodeTransfor) {
- _inherits(ObjectExpressionTransformer, _AbstractNodeTransfor);
- function ObjectExpressionTransformer(randomGenerator, options) {
- _classCallCheck(this, ObjectExpressionTransformer);
- return _possibleConstructorReturn(this, (ObjectExpressionTransformer.__proto__ || Object.getPrototypeOf(ObjectExpressionTransformer)).call(this, randomGenerator, options));
- }
- _createClass(ObjectExpressionTransformer, [{
- key: "getVisitor",
- value: function getVisitor(transformationStage) {
- var _this2 = this;
- switch (transformationStage) {
- case TransformationStage_1.TransformationStage.Obfuscating:
- return {
- enter: function enter(node, parentNode) {
- if (parentNode && NodeGuards_1.NodeGuards.isObjectExpressionNode(node)) {
- return _this2.transformNode(node, parentNode);
- }
- }
- };
- default:
- return null;
- }
- }
- }, {
- key: "transformNode",
- value: function transformNode(objectExpressionNode, parentNode) {
- objectExpressionNode.properties.forEach(function (property) {
- if (property.computed) {
- return;
- }
- if (property.shorthand) {
- property.shorthand = false;
- }
- if (NodeGuards_1.NodeGuards.isIdentifierNode(property.key)) {
- property.key = ObjectExpressionTransformer_1.transformIdentifierPropertyKey(property.key);
- }
- });
- return objectExpressionNode;
- }
- }], [{
- key: "transformIdentifierPropertyKey",
- value: function transformIdentifierPropertyKey(node) {
- return {
- type: NodeType_1.NodeType.Literal,
- value: node.name,
- raw: "'" + node.name + "'"
- };
- }
- }]);
- return ObjectExpressionTransformer;
- }(AbstractNodeTransformer_1.AbstractNodeTransformer);
- ObjectExpressionTransformer = ObjectExpressionTransformer_1 = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Object, Object])], ObjectExpressionTransformer);
- exports.ObjectExpressionTransformer = ObjectExpressionTransformer;
- var ObjectExpressionTransformer_1;
- /***/ }),
- /* 133 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var StringArrayEncoding_1 = __webpack_require__(26);
- var AbstractObfuscatingReplacer_1 = __webpack_require__(28);
- var Nodes_1 = __webpack_require__(9);
- var Utils_1 = __webpack_require__(22);
- var StringLiteralObfuscatingReplacer = StringLiteralObfuscatingReplacer_1 = function (_AbstractObfuscatingR) {
- _inherits(StringLiteralObfuscatingReplacer, _AbstractObfuscatingR);
- function StringLiteralObfuscatingReplacer(stringArrayStorage, escapeSequenceEncoder, randomGenerator, cryptUtils, options) {
- _classCallCheck(this, StringLiteralObfuscatingReplacer);
- var _this = _possibleConstructorReturn(this, (StringLiteralObfuscatingReplacer.__proto__ || Object.getPrototypeOf(StringLiteralObfuscatingReplacer)).call(this, options));
- _this.nodesCache = new Map();
- _this.stringLiteralHexadecimalIndexCache = new Map();
- _this.stringArrayStorage = stringArrayStorage;
- _this.escapeSequenceEncoder = escapeSequenceEncoder;
- _this.randomGenerator = randomGenerator;
- _this.cryptUtils = cryptUtils;
- _this.rc4Keys = _this.randomGenerator.getRandomGenerator().n(function () {
- return _this.randomGenerator.getRandomGenerator().string({
- length: StringLiteralObfuscatingReplacer_1.rc4KeyLength
- });
- }, StringLiteralObfuscatingReplacer_1.rc4KeysCount);
- return _this;
- }
- _createClass(StringLiteralObfuscatingReplacer, [{
- key: "replace",
- value: function replace(nodeValue) {
- var useStringArray = this.canUseStringArray(nodeValue);
- var cacheKey = nodeValue + "-" + String(useStringArray);
- var useCacheValue = this.nodesCache.has(cacheKey) && this.options.stringArrayEncoding !== StringArrayEncoding_1.StringArrayEncoding.Rc4;
- if (useCacheValue) {
- return this.nodesCache.get(cacheKey);
- }
- var resultNode = useStringArray ? this.replaceWithStringArrayCallNode(nodeValue) : this.replaceWithLiteralNode(nodeValue);
- this.nodesCache.set(cacheKey, resultNode);
- return resultNode;
- }
- }, {
- key: "canUseStringArray",
- value: function canUseStringArray(nodeValue) {
- return this.options.stringArray && nodeValue.length >= StringLiteralObfuscatingReplacer_1.minimumLengthForStringArray && this.randomGenerator.getMathRandom() <= this.options.stringArrayThreshold;
- }
- }, {
- key: "getStringArrayHexadecimalIndex",
- value: function getStringArrayHexadecimalIndex(value, stringArrayStorageLength) {
- if (this.stringLiteralHexadecimalIndexCache.has(value)) {
- return {
- fromCache: true,
- index: this.stringLiteralHexadecimalIndexCache.get(value)
- };
- }
- var hexadecimalRawIndex = Utils_1.Utils.decToHex(stringArrayStorageLength);
- var hexadecimalIndex = "" + Utils_1.Utils.hexadecimalPrefix + hexadecimalRawIndex;
- this.stringLiteralHexadecimalIndexCache.set(value, hexadecimalIndex);
- return {
- fromCache: false,
- index: hexadecimalIndex
- };
- }
- }, {
- key: "getEncodedValue",
- value: function getEncodedValue(value) {
- var encodedValue = void 0;
- var key = null;
- switch (this.options.stringArrayEncoding) {
- case StringArrayEncoding_1.StringArrayEncoding.Rc4:
- key = this.randomGenerator.getRandomGenerator().pickone(this.rc4Keys);
- encodedValue = this.cryptUtils.btoa(this.cryptUtils.rc4(value, key));
- break;
- case StringArrayEncoding_1.StringArrayEncoding.Base64:
- encodedValue = this.cryptUtils.btoa(value);
- break;
- default:
- encodedValue = value;
- }
- return { encodedValue: encodedValue, key: key };
- }
- }, {
- key: "replaceWithLiteralNode",
- value: function replaceWithLiteralNode(value) {
- return Nodes_1.Nodes.getLiteralNode(this.escapeSequenceEncoder.encode(value, this.options.unicodeEscapeSequence));
- }
- }, {
- key: "replaceWithStringArrayCallNode",
- value: function replaceWithStringArrayCallNode(value) {
- var _getEncodedValue = this.getEncodedValue(value),
- encodedValue = _getEncodedValue.encodedValue,
- key = _getEncodedValue.key;
- var escapedValue = this.escapeSequenceEncoder.encode(encodedValue, this.options.unicodeEscapeSequence);
- var stringArrayStorageLength = this.stringArrayStorage.getLength();
- var stringArrayStorageCallsWrapperName = this.stringArrayStorage.getStorageId().split('|')[1];
- var _getStringArrayHexade = this.getStringArrayHexadecimalIndex(escapedValue, stringArrayStorageLength),
- fromCache = _getStringArrayHexade.fromCache,
- index = _getStringArrayHexade.index;
- if (!fromCache) {
- this.stringArrayStorage.set(stringArrayStorageLength, escapedValue);
- }
- var callExpressionArgs = [StringLiteralObfuscatingReplacer_1.getHexadecimalLiteralNode(index)];
- if (key) {
- callExpressionArgs.push(StringLiteralObfuscatingReplacer_1.getRc4KeyLiteralNode(this.escapeSequenceEncoder.encode(key, this.options.unicodeEscapeSequence)));
- }
- var stringArrayIdentifierNode = Nodes_1.Nodes.getIdentifierNode(stringArrayStorageCallsWrapperName);
- stringArrayIdentifierNode.obfuscatedNode = true;
- return Nodes_1.Nodes.getCallExpressionNode(stringArrayIdentifierNode, callExpressionArgs);
- }
- }], [{
- key: "getHexadecimalLiteralNode",
- value: function getHexadecimalLiteralNode(hexadecimalIndex) {
- var hexadecimalLiteralNode = Nodes_1.Nodes.getLiteralNode(hexadecimalIndex);
- hexadecimalLiteralNode.obfuscatedNode = true;
- return hexadecimalLiteralNode;
- }
- }, {
- key: "getRc4KeyLiteralNode",
- value: function getRc4KeyLiteralNode(literalValue) {
- var rc4KeyLiteralNode = Nodes_1.Nodes.getLiteralNode(literalValue);
- rc4KeyLiteralNode.obfuscatedNode = true;
- return rc4KeyLiteralNode;
- }
- }]);
- return StringLiteralObfuscatingReplacer;
- }(AbstractObfuscatingReplacer_1.AbstractObfuscatingReplacer);
- StringLiteralObfuscatingReplacer.minimumLengthForStringArray = 3;
- StringLiteralObfuscatingReplacer.rc4KeyLength = 4;
- StringLiteralObfuscatingReplacer.rc4KeysCount = 50;
- StringLiteralObfuscatingReplacer = StringLiteralObfuscatingReplacer_1 = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.TStringArrayStorage)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IEscapeSequenceEncoder)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(3, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.ICryptUtils)), tslib_1.__param(4, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Object, Object, Object, Object, Object])], StringLiteralObfuscatingReplacer);
- exports.StringLiteralObfuscatingReplacer = StringLiteralObfuscatingReplacer;
- var StringLiteralObfuscatingReplacer_1;
- /***/ }),
- /* 134 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var estraverse = tslib_1.__importStar(__webpack_require__(10));
- var IdentifierObfuscatingReplacer_1 = __webpack_require__(18);
- var NodeType_1 = __webpack_require__(11);
- var TransformationStage_1 = __webpack_require__(6);
- var AbstractNodeTransformer_1 = __webpack_require__(7);
- var NodeGuards_1 = __webpack_require__(3);
- var NodeUtils_1 = __webpack_require__(4);
- var VariableDeclarationTransformer = function (_AbstractNodeTransfor) {
- _inherits(VariableDeclarationTransformer, _AbstractNodeTransfor);
- function VariableDeclarationTransformer(identifierObfuscatingReplacerFactory, randomGenerator, options) {
- _classCallCheck(this, VariableDeclarationTransformer);
- var _this = _possibleConstructorReturn(this, (VariableDeclarationTransformer.__proto__ || Object.getPrototypeOf(VariableDeclarationTransformer)).call(this, randomGenerator, options));
- _this.replaceableIdentifiers = new Map();
- _this.identifierObfuscatingReplacer = identifierObfuscatingReplacerFactory(IdentifierObfuscatingReplacer_1.IdentifierObfuscatingReplacer.BaseIdentifierObfuscatingReplacer);
- return _this;
- }
- _createClass(VariableDeclarationTransformer, [{
- key: "getVisitor",
- value: function getVisitor(transformationStage) {
- var _this2 = this;
- switch (transformationStage) {
- case TransformationStage_1.TransformationStage.Obfuscating:
- return {
- enter: function enter(node, parentNode) {
- if (parentNode && NodeGuards_1.NodeGuards.isVariableDeclarationNode(node)) {
- return _this2.transformNode(node, parentNode);
- }
- }
- };
- default:
- return null;
- }
- }
- }, {
- key: "transformNode",
- value: function transformNode(variableDeclarationNode, parentNode) {
- var blockScopeNode = NodeUtils_1.NodeUtils.getBlockScopesOfNode(variableDeclarationNode)[0];
- var isGlobalDeclaration = blockScopeNode.type === NodeType_1.NodeType.Program;
- if (!this.options.renameGlobals && isGlobalDeclaration) {
- return variableDeclarationNode;
- }
- var nodeIdentifier = this.nodeIdentifier++;
- var scopeNode = variableDeclarationNode.kind === 'var' ? blockScopeNode : parentNode;
- this.storeVariableNames(variableDeclarationNode, isGlobalDeclaration, nodeIdentifier);
- if (this.replaceableIdentifiers.has(scopeNode)) {
- this.replaceScopeCachedIdentifiers(variableDeclarationNode, scopeNode, nodeIdentifier);
- } else {
- this.replaceScopeIdentifiers(scopeNode, nodeIdentifier);
- }
- return variableDeclarationNode;
- }
- }, {
- key: "storeVariableNames",
- value: function storeVariableNames(variableDeclarationNode, isGlobalDeclaration, nodeIdentifier) {
- var _this3 = this;
- this.traverseDeclarationIdentifiers(variableDeclarationNode, function (identifierNode) {
- if (isGlobalDeclaration) {
- _this3.identifierObfuscatingReplacer.storeGlobalName(identifierNode.name, nodeIdentifier);
- } else {
- _this3.identifierObfuscatingReplacer.storeLocalName(identifierNode.name, nodeIdentifier);
- }
- });
- }
- }, {
- key: "replaceScopeCachedIdentifiers",
- value: function replaceScopeCachedIdentifiers(variableDeclarationNode, scopeNode, nodeIdentifier) {
- var _this4 = this;
- var cachedReplaceableIdentifiersNamesMap = this.replaceableIdentifiers.get(scopeNode);
- if (!cachedReplaceableIdentifiersNamesMap) {
- return;
- }
- var identifierNames = [];
- this.traverseDeclarationIdentifiers(variableDeclarationNode, function (identifierNode) {
- identifierNames.push(identifierNode.name);
- });
- identifierNames.forEach(function (identifierName) {
- var cachedReplaceableIdentifiers = cachedReplaceableIdentifiersNamesMap.get(identifierName);
- if (!cachedReplaceableIdentifiers) {
- return;
- }
- var cachedReplaceableIdentifierLength = cachedReplaceableIdentifiers.length;
- for (var i = 0; i < cachedReplaceableIdentifierLength; i++) {
- var replaceableIdentifier = cachedReplaceableIdentifiers[i];
- if (identifierName !== replaceableIdentifier.name) {
- continue;
- }
- var newReplaceableIdentifier = _this4.identifierObfuscatingReplacer.replace(replaceableIdentifier.name, nodeIdentifier);
- replaceableIdentifier.name = newReplaceableIdentifier.name;
- }
- });
- }
- }, {
- key: "replaceScopeIdentifiers",
- value: function replaceScopeIdentifiers(blockScopeNode, nodeIdentifier) {
- var _this5 = this;
- var storedReplaceableIdentifiersNamesMap = new Map();
- estraverse.replace(blockScopeNode, {
- enter: function enter(node, parentNode) {
- if (parentNode && !node.obfuscatedNode && NodeGuards_1.NodeGuards.isReplaceableIdentifierNode(node, parentNode)) {
- var newIdentifier = _this5.identifierObfuscatingReplacer.replace(node.name, nodeIdentifier);
- var newIdentifierName = newIdentifier.name;
- if (node.name !== newIdentifierName) {
- node.name = newIdentifierName;
- } else {
- var storedReplaceableIdentifiers = storedReplaceableIdentifiersNamesMap.get(node.name) || [];
- storedReplaceableIdentifiers.push(node);
- storedReplaceableIdentifiersNamesMap.set(node.name, storedReplaceableIdentifiers);
- }
- }
- }
- });
- this.replaceableIdentifiers.set(blockScopeNode, storedReplaceableIdentifiersNamesMap);
- }
- }, {
- key: "traverseDeclarationIdentifiers",
- value: function traverseDeclarationIdentifiers(variableDeclarationNode, callback) {
- variableDeclarationNode.declarations.forEach(function (declarationNode) {
- if (NodeGuards_1.NodeGuards.isObjectPatternNode(declarationNode.id)) {
- return estraverse.VisitorOption.Skip;
- }
- estraverse.traverse(declarationNode.id, {
- enter: function enter(node) {
- if (NodeGuards_1.NodeGuards.isIdentifierNode(node)) {
- callback(node);
- }
- }
- });
- });
- }
- }]);
- return VariableDeclarationTransformer;
- }(AbstractNodeTransformer_1.AbstractNodeTransformer);
- VariableDeclarationTransformer = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IIdentifierObfuscatingReplacer)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object, Object])], VariableDeclarationTransformer);
- exports.VariableDeclarationTransformer = VariableDeclarationTransformer;
- /***/ }),
- /* 135 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var Options_1 = __webpack_require__(136);
- var OptionsNormalizer_1 = __webpack_require__(139);
- exports.optionsModule = new inversify_1.ContainerModule(function (bind) {
- bind(ServiceIdentifiers_1.ServiceIdentifiers.IOptions).to(Options_1.Options).inSingletonScope();
- bind(ServiceIdentifiers_1.ServiceIdentifiers.IOptionsNormalizer).to(OptionsNormalizer_1.OptionsNormalizer).inSingletonScope();
- });
- /***/ }),
- /* 136 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var class_validator_1 = __webpack_require__(137);
- var IdentifierNamesGenerator_1 = __webpack_require__(24);
- var ObfuscationTarget_1 = __webpack_require__(14);
- var SourceMapMode_1 = __webpack_require__(25);
- var StringArrayEncoding_1 = __webpack_require__(26);
- var Default_1 = __webpack_require__(33);
- var ValidationErrorsFormatter_1 = __webpack_require__(138);
- var Options = Options_1 = function Options(inputOptions, optionsNormalizer) {
- _classCallCheck(this, Options);
- Object.assign(this, Default_1.DEFAULT_PRESET, inputOptions);
- var errors = class_validator_1.validateSync(this, Options_1.validatorOptions);
- if (errors.length) {
- throw new ReferenceError("Validation failed. errors:\n" + ValidationErrorsFormatter_1.ValidationErrorsFormatter.format(errors));
- }
- Object.assign(this, optionsNormalizer.normalize(this));
- };
- Options.validatorOptions = {
- validationError: {
- target: false
- }
- };
- tslib_1.__decorate([class_validator_1.IsBoolean(), tslib_1.__metadata("design:type", Boolean)], Options.prototype, "compact", void 0);
- tslib_1.__decorate([class_validator_1.IsBoolean(), tslib_1.__metadata("design:type", Boolean)], Options.prototype, "controlFlowFlattening", void 0);
- tslib_1.__decorate([class_validator_1.IsNumber(), class_validator_1.Min(0), class_validator_1.Max(1), tslib_1.__metadata("design:type", Number)], Options.prototype, "controlFlowFlatteningThreshold", void 0);
- tslib_1.__decorate([class_validator_1.IsBoolean(), tslib_1.__metadata("design:type", Boolean)], Options.prototype, "deadCodeInjection", void 0);
- tslib_1.__decorate([class_validator_1.IsNumber(), tslib_1.__metadata("design:type", Number)], Options.prototype, "deadCodeInjectionThreshold", void 0);
- tslib_1.__decorate([class_validator_1.IsBoolean(), tslib_1.__metadata("design:type", Boolean)], Options.prototype, "debugProtection", void 0);
- tslib_1.__decorate([class_validator_1.IsBoolean(), tslib_1.__metadata("design:type", Boolean)], Options.prototype, "debugProtectionInterval", void 0);
- tslib_1.__decorate([class_validator_1.IsBoolean(), tslib_1.__metadata("design:type", Boolean)], Options.prototype, "disableConsoleOutput", void 0);
- tslib_1.__decorate([class_validator_1.IsArray(), class_validator_1.ArrayUnique(), class_validator_1.IsString({
- each: true
- }), tslib_1.__metadata("design:type", Array)], Options.prototype, "domainLock", void 0);
- tslib_1.__decorate([class_validator_1.IsIn([IdentifierNamesGenerator_1.IdentifierNamesGenerator.HexadecimalIdentifierNamesGenerator, IdentifierNamesGenerator_1.IdentifierNamesGenerator.MangledIdentifierNamesGenerator]), tslib_1.__metadata("design:type", String)], Options.prototype, "identifierNamesGenerator", void 0);
- tslib_1.__decorate([class_validator_1.IsString(), tslib_1.__metadata("design:type", String)], Options.prototype, "identifiersPrefix", void 0);
- tslib_1.__decorate([class_validator_1.IsBoolean(), tslib_1.__metadata("design:type", Boolean)], Options.prototype, "log", void 0);
- tslib_1.__decorate([class_validator_1.IsBoolean(), tslib_1.__metadata("design:type", Boolean)], Options.prototype, "renameGlobals", void 0);
- tslib_1.__decorate([class_validator_1.IsArray(), class_validator_1.ArrayUnique(), class_validator_1.IsString({
- each: true
- }), tslib_1.__metadata("design:type", Array)], Options.prototype, "reservedNames", void 0);
- tslib_1.__decorate([class_validator_1.IsBoolean(), tslib_1.__metadata("design:type", Boolean)], Options.prototype, "rotateStringArray", void 0);
- tslib_1.__decorate([class_validator_1.IsNumber(), tslib_1.__metadata("design:type", Number)], Options.prototype, "seed", void 0);
- tslib_1.__decorate([class_validator_1.IsBoolean(), tslib_1.__metadata("design:type", Boolean)], Options.prototype, "selfDefending", void 0);
- tslib_1.__decorate([class_validator_1.IsBoolean(), tslib_1.__metadata("design:type", Boolean)], Options.prototype, "sourceMap", void 0);
- tslib_1.__decorate([class_validator_1.IsString(), class_validator_1.ValidateIf(function (options) {
- return Boolean(options.sourceMapBaseUrl);
- }), class_validator_1.IsUrl({
- require_protocol: true,
- require_tld: false,
- require_valid_protocol: true
- }), tslib_1.__metadata("design:type", String)], Options.prototype, "sourceMapBaseUrl", void 0);
- tslib_1.__decorate([class_validator_1.IsString(), tslib_1.__metadata("design:type", String)], Options.prototype, "sourceMapFileName", void 0);
- tslib_1.__decorate([class_validator_1.IsIn([SourceMapMode_1.SourceMapMode.Inline, SourceMapMode_1.SourceMapMode.Separate]), tslib_1.__metadata("design:type", String)], Options.prototype, "sourceMapMode", void 0);
- tslib_1.__decorate([class_validator_1.IsBoolean(), tslib_1.__metadata("design:type", Boolean)], Options.prototype, "stringArray", void 0);
- tslib_1.__decorate([class_validator_1.IsIn([true, false, StringArrayEncoding_1.StringArrayEncoding.Base64, StringArrayEncoding_1.StringArrayEncoding.Rc4]), tslib_1.__metadata("design:type", Object)], Options.prototype, "stringArrayEncoding", void 0);
- tslib_1.__decorate([class_validator_1.IsNumber(), class_validator_1.Min(0), class_validator_1.Max(1), tslib_1.__metadata("design:type", Number)], Options.prototype, "stringArrayThreshold", void 0);
- tslib_1.__decorate([class_validator_1.IsIn([ObfuscationTarget_1.ObfuscationTarget.Browser, ObfuscationTarget_1.ObfuscationTarget.Extension, ObfuscationTarget_1.ObfuscationTarget.Node]), tslib_1.__metadata("design:type", String)], Options.prototype, "target", void 0);
- tslib_1.__decorate([class_validator_1.IsBoolean(), tslib_1.__metadata("design:type", Boolean)], Options.prototype, "transformObjectKeys", void 0);
- tslib_1.__decorate([class_validator_1.IsBoolean(), tslib_1.__metadata("design:type", Boolean)], Options.prototype, "unicodeEscapeSequence", void 0);
- Options = Options_1 = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.TInputOptions)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptionsNormalizer)), tslib_1.__metadata("design:paramtypes", [Object, Object])], Options);
- exports.Options = Options;
- var Options_1;
- /***/ }),
- /* 137 */
- /***/ (function(module, exports) {
- module.exports = require("class-validator");
- /***/ }),
- /* 138 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- Object.defineProperty(exports, "__esModule", { value: true });
- var ValidationErrorsFormatter = function () {
- function ValidationErrorsFormatter() {
- _classCallCheck(this, ValidationErrorsFormatter);
- }
- _createClass(ValidationErrorsFormatter, null, [{
- key: "format",
- value: function format(validationErrors) {
- var errorsArray = [];
- var _iteratorNormalCompletion = true;
- var _didIteratorError = false;
- var _iteratorError = undefined;
- try {
- for (var _iterator = validationErrors[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
- var error = _step.value;
- errorsArray.push(ValidationErrorsFormatter.formatError(error));
- }
- } catch (err) {
- _didIteratorError = true;
- _iteratorError = err;
- } finally {
- try {
- if (!_iteratorNormalCompletion && _iterator.return) {
- _iterator.return();
- }
- } finally {
- if (_didIteratorError) {
- throw _iteratorError;
- }
- }
- }
- return errorsArray.join('\n');
- }
- }, {
- key: "formatError",
- value: function formatError(validationError) {
- var constraints = validationError.constraints;
- var errorString = "`" + validationError.property + "` errors:\n";
- for (var constraint in constraints) {
- if (!constraints.hasOwnProperty(constraint)) {
- continue;
- }
- errorString += " - " + constraints[constraint] + "\n";
- }
- return errorString;
- }
- }]);
- return ValidationErrorsFormatter;
- }();
- exports.ValidationErrorsFormatter = ValidationErrorsFormatter;
- /***/ }),
- /* 139 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var ControlFlowFlatteningThresholdRule_1 = __webpack_require__(140);
- var DeadCodeInjectionRule_1 = __webpack_require__(141);
- var DeadCodeInjectionThresholdRule_1 = __webpack_require__(142);
- var DomainLockRule_1 = __webpack_require__(143);
- var SelfDefendingRule_1 = __webpack_require__(144);
- var SourceMapBaseUrlRule_1 = __webpack_require__(145);
- var SourceMapFileNameRule_1 = __webpack_require__(146);
- var StringArrayRule_1 = __webpack_require__(147);
- var StringArrayEncodingRule_1 = __webpack_require__(148);
- var StringArrayThresholdRule_1 = __webpack_require__(149);
- var OptionsNormalizer = OptionsNormalizer_1 = function () {
- function OptionsNormalizer() {
- _classCallCheck(this, OptionsNormalizer);
- }
- _createClass(OptionsNormalizer, [{
- key: "normalize",
- value: function normalize(options) {
- var normalizedOptions = Object.assign({}, options);
- var _iteratorNormalCompletion = true;
- var _didIteratorError = false;
- var _iteratorError = undefined;
- try {
- for (var _iterator = OptionsNormalizer_1.normalizerRules[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
- var normalizerRule = _step.value;
- normalizedOptions = normalizerRule(normalizedOptions);
- }
- } catch (err) {
- _didIteratorError = true;
- _iteratorError = err;
- } finally {
- try {
- if (!_iteratorNormalCompletion && _iterator.return) {
- _iterator.return();
- }
- } finally {
- if (_didIteratorError) {
- throw _iteratorError;
- }
- }
- }
- return normalizedOptions;
- }
- }]);
- return OptionsNormalizer;
- }();
- OptionsNormalizer.normalizerRules = [ControlFlowFlatteningThresholdRule_1.ControlFlowFlatteningThresholdRule, DeadCodeInjectionRule_1.DeadCodeInjectionRule, DeadCodeInjectionThresholdRule_1.DeadCodeInjectionThresholdRule, DomainLockRule_1.DomainLockRule, SelfDefendingRule_1.SelfDefendingRule, SourceMapBaseUrlRule_1.SourceMapBaseUrlRule, SourceMapFileNameRule_1.SourceMapFileNameRule, StringArrayRule_1.StringArrayRule, StringArrayEncodingRule_1.StringArrayEncodingRule, StringArrayThresholdRule_1.StringArrayThresholdRule];
- OptionsNormalizer = OptionsNormalizer_1 = tslib_1.__decorate([inversify_1.injectable()], OptionsNormalizer);
- exports.OptionsNormalizer = OptionsNormalizer;
- var OptionsNormalizer_1;
- /***/ }),
- /* 140 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.ControlFlowFlatteningThresholdRule = function (options) {
- if (options.controlFlowFlatteningThreshold === 0) {
- options = Object.assign({}, options, { controlFlowFlattening: false, controlFlowFlatteningThreshold: 0 });
- }
- return options;
- };
- /***/ }),
- /* 141 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- var Default_1 = __webpack_require__(33);
- exports.DeadCodeInjectionRule = function (options) {
- if (options.deadCodeInjection) {
- options = Object.assign({}, options, { deadCodeInjection: true, stringArray: true });
- if (!options.stringArrayThreshold) {
- options = Object.assign({}, options, { stringArray: true, stringArrayThreshold: Default_1.DEFAULT_PRESET.stringArrayThreshold });
- }
- }
- return options;
- };
- /***/ }),
- /* 142 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.DeadCodeInjectionThresholdRule = function (options) {
- if (options.deadCodeInjectionThreshold === 0) {
- options = Object.assign({}, options, { deadCodeInjection: false, deadCodeInjectionThreshold: 0 });
- }
- return options;
- };
- /***/ }),
- /* 143 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- var Utils_1 = __webpack_require__(22);
- exports.DomainLockRule = function (options) {
- if (options.domainLock.length) {
- var normalizedDomains = [];
- var _iteratorNormalCompletion = true;
- var _didIteratorError = false;
- var _iteratorError = undefined;
- try {
- for (var _iterator = options.domainLock[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
- var domain = _step.value;
- normalizedDomains.push(Utils_1.Utils.extractDomainFromUrl(domain));
- }
- } catch (err) {
- _didIteratorError = true;
- _iteratorError = err;
- } finally {
- try {
- if (!_iteratorNormalCompletion && _iterator.return) {
- _iterator.return();
- }
- } finally {
- if (_didIteratorError) {
- throw _iteratorError;
- }
- }
- }
- options = Object.assign({}, options, { domainLock: normalizedDomains });
- }
- return options;
- };
- /***/ }),
- /* 144 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.SelfDefendingRule = function (options) {
- if (options.selfDefending) {
- options = Object.assign({}, options, { compact: true, selfDefending: true });
- }
- return options;
- };
- /***/ }),
- /* 145 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.SourceMapBaseUrlRule = function (options) {
- var _options = options,
- sourceMapBaseUrl = _options.sourceMapBaseUrl;
- if (!options.sourceMapFileName) {
- options = Object.assign({}, options, { sourceMapBaseUrl: '' });
- return options;
- }
- if (sourceMapBaseUrl && !sourceMapBaseUrl.endsWith('/')) {
- options = Object.assign({}, options, { sourceMapBaseUrl: sourceMapBaseUrl + "/" });
- }
- return options;
- };
- /***/ }),
- /* 146 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.SourceMapFileNameRule = function (options) {
- var _options = options,
- sourceMapFileName = _options.sourceMapFileName;
- if (sourceMapFileName) {
- sourceMapFileName = sourceMapFileName.replace(/^\/+/, '').split('.')[0];
- options = Object.assign({}, options, { sourceMapFileName: sourceMapFileName + ".js.map" });
- }
- return options;
- };
- /***/ }),
- /* 147 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.StringArrayRule = function (options) {
- if (!options.stringArray) {
- options = Object.assign({}, options, { rotateStringArray: false, stringArray: false, stringArrayEncoding: false, stringArrayThreshold: 0 });
- }
- return options;
- };
- /***/ }),
- /* 148 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- var StringArrayEncoding_1 = __webpack_require__(26);
- exports.StringArrayEncodingRule = function (options) {
- if (options.stringArrayEncoding === true) {
- options = Object.assign({}, options, { stringArrayEncoding: StringArrayEncoding_1.StringArrayEncoding.Base64 });
- }
- return options;
- };
- /***/ }),
- /* 149 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.StringArrayThresholdRule = function (options) {
- if (options.stringArrayThreshold === 0) {
- options = Object.assign({}, options, { rotateStringArray: false, stringArray: false, stringArrayEncoding: false, stringArrayThreshold: 0 });
- }
- return options;
- };
- /***/ }),
- /* 150 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- var InversifyContainerFacade_1 = __webpack_require__(15);
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var NodeTransformer_1 = __webpack_require__(20);
- var ObfuscatingGuard_1 = __webpack_require__(44);
- var BlackListObfuscatingGuard_1 = __webpack_require__(151);
- var CommentsTransformer_1 = __webpack_require__(152);
- var ConditionalCommentObfuscatingGuard_1 = __webpack_require__(153);
- var CustomNodesTransformer_1 = __webpack_require__(154);
- var EvaCallExpressionTransformer_1 = __webpack_require__(155);
- var ObfuscatingGuardsTransformer_1 = __webpack_require__(157);
- var ParentificationTransformer_1 = __webpack_require__(158);
- exports.preparingTransformersModule = new inversify_1.ContainerModule(function (bind) {
- bind(ServiceIdentifiers_1.ServiceIdentifiers.INodeTransformer).to(CommentsTransformer_1.CommentsTransformer).whenTargetNamed(NodeTransformer_1.NodeTransformer.CommentsTransformer);
- bind(ServiceIdentifiers_1.ServiceIdentifiers.INodeTransformer).to(CustomNodesTransformer_1.CustomNodesTransformer).whenTargetNamed(NodeTransformer_1.NodeTransformer.CustomNodesTransformer);
- bind(ServiceIdentifiers_1.ServiceIdentifiers.INodeTransformer).to(EvaCallExpressionTransformer_1.EvalCallExpressionTransformer).whenTargetNamed(NodeTransformer_1.NodeTransformer.EvalCallExpressionTransformer);
- bind(ServiceIdentifiers_1.ServiceIdentifiers.INodeTransformer).to(ObfuscatingGuardsTransformer_1.ObfuscatingGuardsTransformer).whenTargetNamed(NodeTransformer_1.NodeTransformer.ObfuscatingGuardsTransformer);
- bind(ServiceIdentifiers_1.ServiceIdentifiers.INodeTransformer).to(ParentificationTransformer_1.ParentificationTransformer).whenTargetNamed(NodeTransformer_1.NodeTransformer.ParentificationTransformer);
- bind(ServiceIdentifiers_1.ServiceIdentifiers.INodeGuard).to(BlackListObfuscatingGuard_1.BlackListObfuscatingGuard).inSingletonScope().whenTargetNamed(ObfuscatingGuard_1.ObfuscatingGuard.BlackListNodeGuard);
- bind(ServiceIdentifiers_1.ServiceIdentifiers.INodeGuard).to(ConditionalCommentObfuscatingGuard_1.ConditionalCommentObfuscatingGuard).inSingletonScope().whenTargetNamed(ObfuscatingGuard_1.ObfuscatingGuard.ConditionalCommentNodeGuard);
- bind(ServiceIdentifiers_1.ServiceIdentifiers.Factory__INodeGuard).toFactory(InversifyContainerFacade_1.InversifyContainerFacade.getCacheFactory(ServiceIdentifiers_1.ServiceIdentifiers.INodeGuard));
- });
- /***/ }),
- /* 151 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var NodeGuards_1 = __webpack_require__(3);
- var BlackListObfuscatingGuard = BlackListObfuscatingGuard_1 = function () {
- function BlackListObfuscatingGuard() {
- _classCallCheck(this, BlackListObfuscatingGuard);
- this.blackListGuardsLength = BlackListObfuscatingGuard_1.blackListGuards.length;
- }
- _createClass(BlackListObfuscatingGuard, [{
- key: "check",
- value: function check(node) {
- for (var i = 0; i < this.blackListGuardsLength; i++) {
- if (BlackListObfuscatingGuard_1.blackListGuards[i](node)) {
- return false;
- }
- }
- return true;
- }
- }]);
- return BlackListObfuscatingGuard;
- }();
- BlackListObfuscatingGuard.blackListGuards = [NodeGuards_1.NodeGuards.isUseStrictOperator];
- BlackListObfuscatingGuard = BlackListObfuscatingGuard_1 = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__metadata("design:paramtypes", [])], BlackListObfuscatingGuard);
- exports.BlackListObfuscatingGuard = BlackListObfuscatingGuard;
- var BlackListObfuscatingGuard_1;
- /***/ }),
- /* 152 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var TransformationStage_1 = __webpack_require__(6);
- var AbstractNodeTransformer_1 = __webpack_require__(7);
- var NodeGuards_1 = __webpack_require__(3);
- var CommentsTransformer = CommentsTransformer_1 = function (_AbstractNodeTransfor) {
- _inherits(CommentsTransformer, _AbstractNodeTransfor);
- function CommentsTransformer(randomGenerator, options) {
- _classCallCheck(this, CommentsTransformer);
- return _possibleConstructorReturn(this, (CommentsTransformer.__proto__ || Object.getPrototypeOf(CommentsTransformer)).call(this, randomGenerator, options));
- }
- _createClass(CommentsTransformer, [{
- key: "getVisitor",
- value: function getVisitor(transformationStage) {
- var _this2 = this;
- switch (transformationStage) {
- case TransformationStage_1.TransformationStage.Preparing:
- return {
- leave: function leave(node, parentNode) {
- if (parentNode && NodeGuards_1.NodeGuards.isNodeWithComments(node)) {
- return _this2.transformNode(node, parentNode);
- }
- }
- };
- default:
- return null;
- }
- }
- }, {
- key: "transformNode",
- value: function transformNode(node, parentNode) {
- if (node.leadingComments) {
- node.leadingComments = this.transformComments(node.leadingComments);
- }
- if (node.trailingComments) {
- node.trailingComments = this.transformComments(node.trailingComments);
- }
- return node;
- }
- }, {
- key: "transformComments",
- value: function transformComments(comments) {
- return comments.filter(function (comment) {
- return CommentsTransformer_1.preservedWords.some(function (availableWord) {
- return comment.value.indexOf(availableWord) !== -1;
- });
- });
- }
- }]);
- return CommentsTransformer;
- }(AbstractNodeTransformer_1.AbstractNodeTransformer);
- CommentsTransformer.preservedWords = ['@license', '@preserve'];
- CommentsTransformer = CommentsTransformer_1 = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Object, Object])], CommentsTransformer);
- exports.CommentsTransformer = CommentsTransformer;
- var CommentsTransformer_1;
- /***/ }),
- /* 153 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var NodeGuards_1 = __webpack_require__(3);
- var ConditionalCommentObfuscatingGuard = ConditionalCommentObfuscatingGuard_1 = function () {
- function ConditionalCommentObfuscatingGuard() {
- _classCallCheck(this, ConditionalCommentObfuscatingGuard);
- this.obfuscationAllowedForCurrentNode = true;
- this.obfuscationAllowedForNextNode = null;
- }
- _createClass(ConditionalCommentObfuscatingGuard, [{
- key: "check",
- value: function check(node) {
- if (this.obfuscationAllowedForNextNode) {
- this.obfuscationAllowedForCurrentNode = this.obfuscationAllowedForNextNode;
- this.obfuscationAllowedForNextNode = null;
- }
- if (!NodeGuards_1.NodeGuards.isNodeWithComments(node)) {
- return this.obfuscationAllowedForCurrentNode;
- }
- var leadingComments = node.leadingComments;
- var trailingComments = node.trailingComments;
- if (leadingComments) {
- this.obfuscationAllowedForCurrentNode = this.checkComments(leadingComments);
- }
- if (trailingComments) {
- this.obfuscationAllowedForNextNode = this.checkComments(trailingComments);
- }
- return this.obfuscationAllowedForCurrentNode;
- }
- }, {
- key: "checkComments",
- value: function checkComments(comments) {
- var commentsLength = comments.length;
- var obfuscationAllowed = this.obfuscationAllowedForCurrentNode;
- for (var i = 0; i < commentsLength; i++) {
- var comment = comments[i];
- if (ConditionalCommentObfuscatingGuard_1.obfuscationEnableCommentRegExp.test(comment.value)) {
- obfuscationAllowed = true;
- continue;
- }
- if (ConditionalCommentObfuscatingGuard_1.obfuscationDisableCommentRegExp.test(comment.value)) {
- obfuscationAllowed = false;
- }
- }
- return obfuscationAllowed;
- }
- }]);
- return ConditionalCommentObfuscatingGuard;
- }();
- ConditionalCommentObfuscatingGuard.obfuscationEnableCommentRegExp = new RegExp('javascript-obfuscator *: *enable');
- ConditionalCommentObfuscatingGuard.obfuscationDisableCommentRegExp = new RegExp('javascript-obfuscator *: *disable');
- ConditionalCommentObfuscatingGuard = ConditionalCommentObfuscatingGuard_1 = tslib_1.__decorate([inversify_1.injectable()], ConditionalCommentObfuscatingGuard);
- exports.ConditionalCommentObfuscatingGuard = ConditionalCommentObfuscatingGuard;
- var ConditionalCommentObfuscatingGuard_1;
- /***/ }),
- /* 154 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var ObfuscationEvent_1 = __webpack_require__(17);
- var TransformationStage_1 = __webpack_require__(6);
- var AbstractNodeTransformer_1 = __webpack_require__(7);
- var NodeGuards_1 = __webpack_require__(3);
- var CustomNodesTransformer = function (_AbstractNodeTransfor) {
- _inherits(CustomNodesTransformer, _AbstractNodeTransfor);
- function CustomNodesTransformer(stackTraceAnalyzer, obfuscationEventEmitter, customNodeGroupStorage, randomGenerator, options) {
- _classCallCheck(this, CustomNodesTransformer);
- var _this = _possibleConstructorReturn(this, (CustomNodesTransformer.__proto__ || Object.getPrototypeOf(CustomNodesTransformer)).call(this, randomGenerator, options));
- _this.stackTraceData = [];
- _this.stackTraceAnalyzer = stackTraceAnalyzer;
- _this.obfuscationEventEmitter = obfuscationEventEmitter;
- _this.customNodeGroupStorage = customNodeGroupStorage;
- return _this;
- }
- _createClass(CustomNodesTransformer, [{
- key: "getVisitor",
- value: function getVisitor(transformationStage) {
- var _this2 = this;
- switch (transformationStage) {
- case TransformationStage_1.TransformationStage.Preparing:
- return {
- leave: function leave(node, parentNode) {
- if (NodeGuards_1.NodeGuards.isProgramNode(node)) {
- _this2.analyzeNode(node, parentNode);
- _this2.appendCustomNodesBeforeObfuscation(node, parentNode);
- return _this2.transformNode(node, parentNode);
- }
- }
- };
- case TransformationStage_1.TransformationStage.Finalizing:
- return {
- leave: function leave(node, parentNode) {
- if (NodeGuards_1.NodeGuards.isProgramNode(node)) {
- _this2.appendCustomNodesAfterObfuscation(node, parentNode);
- }
- }
- };
- default:
- return null;
- }
- }
- }, {
- key: "analyzeNode",
- value: function analyzeNode(node, parentNode) {
- this.stackTraceData = this.stackTraceAnalyzer.analyze(node);
- }
- }, {
- key: "transformNode",
- value: function transformNode(node, parentNode) {
- return node;
- }
- }, {
- key: "appendCustomNodesBeforeObfuscation",
- value: function appendCustomNodesBeforeObfuscation(node, parentNode) {
- var _this3 = this;
- this.customNodeGroupStorage.getStorage().forEach(function (customNodeGroup) {
- customNodeGroup.initialize();
- _this3.obfuscationEventEmitter.once(customNodeGroup.getAppendEvent(), customNodeGroup.appendCustomNodes.bind(customNodeGroup));
- });
- this.obfuscationEventEmitter.emit(ObfuscationEvent_1.ObfuscationEvent.BeforeObfuscation, node, this.stackTraceData);
- }
- }, {
- key: "appendCustomNodesAfterObfuscation",
- value: function appendCustomNodesAfterObfuscation(node, parentNode) {
- this.obfuscationEventEmitter.emit(ObfuscationEvent_1.ObfuscationEvent.AfterObfuscation, node, this.stackTraceData);
- }
- }]);
- return CustomNodesTransformer;
- }(AbstractNodeTransformer_1.AbstractNodeTransformer);
- CustomNodesTransformer = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IStackTraceAnalyzer)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IObfuscationEventEmitter)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.TCustomNodeGroupStorage)), tslib_1.__param(3, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(4, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Object, Object, Object, Object, Object])], CustomNodesTransformer);
- exports.CustomNodesTransformer = CustomNodesTransformer;
- /***/ }),
- /* 155 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var js_string_escape_1 = tslib_1.__importDefault(__webpack_require__(156));
- var TransformationStage_1 = __webpack_require__(6);
- var AbstractNodeTransformer_1 = __webpack_require__(7);
- var NodeGuards_1 = __webpack_require__(3);
- var Nodes_1 = __webpack_require__(9);
- var NodeUtils_1 = __webpack_require__(4);
- var EvalCallExpressionTransformer = EvalCallExpressionTransformer_1 = function (_AbstractNodeTransfor) {
- _inherits(EvalCallExpressionTransformer, _AbstractNodeTransfor);
- function EvalCallExpressionTransformer(randomGenerator, options) {
- _classCallCheck(this, EvalCallExpressionTransformer);
- var _this = _possibleConstructorReturn(this, (EvalCallExpressionTransformer.__proto__ || Object.getPrototypeOf(EvalCallExpressionTransformer)).call(this, randomGenerator, options));
- _this.evalRootAstHostNodeSet = new Set();
- return _this;
- }
- _createClass(EvalCallExpressionTransformer, [{
- key: "getVisitor",
- value: function getVisitor(transformationStage) {
- var _this2 = this;
- switch (transformationStage) {
- case TransformationStage_1.TransformationStage.Preparing:
- return {
- enter: function enter(node, parentNode) {
- if (parentNode && NodeGuards_1.NodeGuards.isCallExpressionNode(node) && NodeGuards_1.NodeGuards.isIdentifierNode(node.callee) && node.callee.name === 'eval') {
- return _this2.transformNode(node, parentNode);
- }
- }
- };
- case TransformationStage_1.TransformationStage.Finalizing:
- if (!this.evalRootAstHostNodeSet.size) {
- return null;
- }
- return {
- leave: function leave(node, parentNode) {
- if (parentNode && _this2.isEvalRootAstHostNode(node)) {
- return _this2.restoreNode(node, parentNode);
- }
- }
- };
- default:
- return null;
- }
- }
- }, {
- key: "transformNode",
- value: function transformNode(callExpressionNode, parentNode) {
- var callExpressionFirstArgument = callExpressionNode.arguments[0];
- if (!callExpressionFirstArgument) {
- return callExpressionNode;
- }
- var evalString = EvalCallExpressionTransformer_1.extractEvalStringFromCallExpressionArgument(callExpressionFirstArgument);
- if (!evalString) {
- return callExpressionNode;
- }
- var ast = void 0;
- try {
- ast = NodeUtils_1.NodeUtils.convertCodeToStructure(evalString);
- } catch (e) {
- return callExpressionNode;
- }
- var evalRootAstHostNode = Nodes_1.Nodes.getFunctionExpressionNode([], Nodes_1.Nodes.getBlockStatementNode(ast));
- this.evalRootAstHostNodeSet.add(evalRootAstHostNode);
- return evalRootAstHostNode;
- }
- }, {
- key: "restoreNode",
- value: function restoreNode(evalRootAstHostNode, parentNode) {
- var targetAst = evalRootAstHostNode.body.body;
- var obfuscatedCode = NodeUtils_1.NodeUtils.convertStructureToCode(targetAst);
- return Nodes_1.Nodes.getCallExpressionNode(Nodes_1.Nodes.getIdentifierNode('eval'), [Nodes_1.Nodes.getLiteralNode(js_string_escape_1.default(obfuscatedCode))]);
- }
- }, {
- key: "isEvalRootAstHostNode",
- value: function isEvalRootAstHostNode(node) {
- return NodeGuards_1.NodeGuards.isFunctionExpressionNode(node) && this.evalRootAstHostNodeSet.has(node);
- }
- }], [{
- key: "extractEvalStringFromCallExpressionArgument",
- value: function extractEvalStringFromCallExpressionArgument(node) {
- if (NodeGuards_1.NodeGuards.isLiteralNode(node)) {
- return EvalCallExpressionTransformer_1.extractEvalStringFromLiteralNode(node);
- }
- if (NodeGuards_1.NodeGuards.isTemplateLiteralNode(node)) {
- return EvalCallExpressionTransformer_1.extractEvalStringFromTemplateLiteralNode(node);
- }
- return null;
- }
- }, {
- key: "extractEvalStringFromLiteralNode",
- value: function extractEvalStringFromLiteralNode(node) {
- return typeof node.value === 'string' ? node.value : null;
- }
- }, {
- key: "extractEvalStringFromTemplateLiteralNode",
- value: function extractEvalStringFromTemplateLiteralNode(node) {
- var quasis = node.quasis;
- var allowedQuasisLength = 1;
- if (quasis.length !== allowedQuasisLength || node.expressions.length) {
- return null;
- }
- return quasis[0].value.cooked;
- }
- }]);
- return EvalCallExpressionTransformer;
- }(AbstractNodeTransformer_1.AbstractNodeTransformer);
- EvalCallExpressionTransformer = EvalCallExpressionTransformer_1 = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Object, Object])], EvalCallExpressionTransformer);
- exports.EvalCallExpressionTransformer = EvalCallExpressionTransformer;
- var EvalCallExpressionTransformer_1;
- /***/ }),
- /* 156 */
- /***/ (function(module, exports) {
- module.exports = require("js-string-escape");
- /***/ }),
- /* 157 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var ObfuscatingGuard_1 = __webpack_require__(44);
- var TransformationStage_1 = __webpack_require__(6);
- var AbstractNodeTransformer_1 = __webpack_require__(7);
- var ObfuscatingGuardsTransformer = ObfuscatingGuardsTransformer_1 = function (_AbstractNodeTransfor) {
- _inherits(ObfuscatingGuardsTransformer, _AbstractNodeTransfor);
- function ObfuscatingGuardsTransformer(obfuscatingGuardFactory, randomGenerator, options) {
- _classCallCheck(this, ObfuscatingGuardsTransformer);
- var _this = _possibleConstructorReturn(this, (ObfuscatingGuardsTransformer.__proto__ || Object.getPrototypeOf(ObfuscatingGuardsTransformer)).call(this, randomGenerator, options));
- _this.obfuscatingGuards = ObfuscatingGuardsTransformer_1.obfuscatingGuardsList.map(obfuscatingGuardFactory);
- return _this;
- }
- _createClass(ObfuscatingGuardsTransformer, [{
- key: "getVisitor",
- value: function getVisitor(transformationStage) {
- var _this2 = this;
- switch (transformationStage) {
- case TransformationStage_1.TransformationStage.Preparing:
- return {
- enter: function enter(node, parentNode) {
- return _this2.transformNode(node, parentNode);
- }
- };
- default:
- return null;
- }
- }
- }, {
- key: "transformNode",
- value: function transformNode(node, parentNode) {
- var obfuscationAllowed = this.obfuscatingGuards.every(function (nodeGuard) {
- return nodeGuard.check(node);
- });
- node.ignoredNode = !obfuscationAllowed;
- return node;
- }
- }]);
- return ObfuscatingGuardsTransformer;
- }(AbstractNodeTransformer_1.AbstractNodeTransformer);
- ObfuscatingGuardsTransformer.obfuscatingGuardsList = [ObfuscatingGuard_1.ObfuscatingGuard.BlackListNodeGuard, ObfuscatingGuard_1.ObfuscatingGuard.ConditionalCommentNodeGuard];
- ObfuscatingGuardsTransformer = ObfuscatingGuardsTransformer_1 = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__INodeGuard)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object, Object])], ObfuscatingGuardsTransformer);
- exports.ObfuscatingGuardsTransformer = ObfuscatingGuardsTransformer;
- var ObfuscatingGuardsTransformer_1;
- /***/ }),
- /* 158 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var TransformationStage_1 = __webpack_require__(6);
- var AbstractNodeTransformer_1 = __webpack_require__(7);
- var NodeUtils_1 = __webpack_require__(4);
- var ParentificationTransformer = function (_AbstractNodeTransfor) {
- _inherits(ParentificationTransformer, _AbstractNodeTransfor);
- function ParentificationTransformer(randomGenerator, options) {
- _classCallCheck(this, ParentificationTransformer);
- return _possibleConstructorReturn(this, (ParentificationTransformer.__proto__ || Object.getPrototypeOf(ParentificationTransformer)).call(this, randomGenerator, options));
- }
- _createClass(ParentificationTransformer, [{
- key: "getVisitor",
- value: function getVisitor(transformationStage) {
- var _this2 = this;
- switch (transformationStage) {
- case TransformationStage_1.TransformationStage.Preparing:
- return {
- enter: function enter(node, parentNode) {
- return _this2.transformNode(node, parentNode);
- }
- };
- default:
- return null;
- }
- }
- }, {
- key: "transformNode",
- value: function transformNode(node, parentNode) {
- return NodeUtils_1.NodeUtils.parentizeNode(node, parentNode);
- }
- }]);
- return ParentificationTransformer;
- }(AbstractNodeTransformer_1.AbstractNodeTransformer);
- ParentificationTransformer = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Object, Object])], ParentificationTransformer);
- exports.ParentificationTransformer = ParentificationTransformer;
- /***/ }),
- /* 159 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var ControlFlowStorage_1 = __webpack_require__(160);
- var CustomNodeGroupStorage_1 = __webpack_require__(161);
- var StringArrayStorage_1 = __webpack_require__(162);
- exports.storagesModule = new inversify_1.ContainerModule(function (bind) {
- bind(ServiceIdentifiers_1.ServiceIdentifiers.TCustomNodeGroupStorage).to(CustomNodeGroupStorage_1.CustomNodeGroupStorage).inSingletonScope();
- bind(ServiceIdentifiers_1.ServiceIdentifiers.TStringArrayStorage).to(StringArrayStorage_1.StringArrayStorage).inSingletonScope();
- bind(ServiceIdentifiers_1.ServiceIdentifiers.Newable__TControlFlowStorage).toConstructor(ControlFlowStorage_1.ControlFlowStorage);
- bind(ServiceIdentifiers_1.ServiceIdentifiers.Factory__TControlFlowStorage).toFactory(function (context) {
- return function () {
- var constructor = context.container.get(ServiceIdentifiers_1.ServiceIdentifiers.Newable__TControlFlowStorage);
- var randomGenerator = context.container.get(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator);
- var options = context.container.get(ServiceIdentifiers_1.ServiceIdentifiers.IOptions);
- var storage = new constructor(randomGenerator, options);
- storage.initialize();
- return storage;
- };
- });
- });
- /***/ }),
- /* 160 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var MapStorage_1 = __webpack_require__(45);
- var ControlFlowStorage = function (_MapStorage_1$MapStor) {
- _inherits(ControlFlowStorage, _MapStorage_1$MapStor);
- function ControlFlowStorage(randomGenerator, options) {
- _classCallCheck(this, ControlFlowStorage);
- return _possibleConstructorReturn(this, (ControlFlowStorage.__proto__ || Object.getPrototypeOf(ControlFlowStorage)).call(this, randomGenerator, options));
- }
- return ControlFlowStorage;
- }(MapStorage_1.MapStorage);
- ControlFlowStorage = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Object, Object])], ControlFlowStorage);
- exports.ControlFlowStorage = ControlFlowStorage;
- /***/ }),
- /* 161 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- var _get = (function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } });
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var CustomNodeGroup_1 = __webpack_require__(41);
- var MapStorage_1 = __webpack_require__(45);
- var CustomNodeGroupStorage = CustomNodeGroupStorage_1 = function (_MapStorage_1$MapStor) {
- _inherits(CustomNodeGroupStorage, _MapStorage_1$MapStor);
- function CustomNodeGroupStorage(customNodeGroupFactory, randomGenerator, options) {
- _classCallCheck(this, CustomNodeGroupStorage);
- var _this = _possibleConstructorReturn(this, (CustomNodeGroupStorage.__proto__ || Object.getPrototypeOf(CustomNodeGroupStorage)).call(this, randomGenerator, options));
- _this.customNodeGroupFactory = customNodeGroupFactory;
- return _this;
- }
- _createClass(CustomNodeGroupStorage, [{
- key: "initialize",
- value: function initialize() {
- var _this2 = this;
- _get(CustomNodeGroupStorage.prototype.__proto__ || Object.getPrototypeOf(CustomNodeGroupStorage.prototype), "initialize", this).call(this);
- CustomNodeGroupStorage_1.customNodeGroupsList.forEach(function (customNodeGroupName) {
- var customNodeGroup = _this2.customNodeGroupFactory(customNodeGroupName);
- if (!customNodeGroup) {
- return;
- }
- _this2.storage.set(customNodeGroupName, customNodeGroup);
- });
- }
- }]);
- return CustomNodeGroupStorage;
- }(MapStorage_1.MapStorage);
- CustomNodeGroupStorage.customNodeGroupsList = [CustomNodeGroup_1.CustomNodeGroup.ConsoleOutputCustomNodeGroup, CustomNodeGroup_1.CustomNodeGroup.DebugProtectionCustomNodeGroup, CustomNodeGroup_1.CustomNodeGroup.DomainLockCustomNodeGroup, CustomNodeGroup_1.CustomNodeGroup.SelfDefendingCustomNodeGroup, CustomNodeGroup_1.CustomNodeGroup.StringArrayCustomNodeGroup];
- tslib_1.__decorate([inversify_1.postConstruct(), tslib_1.__metadata("design:type", Function), tslib_1.__metadata("design:paramtypes", []), tslib_1.__metadata("design:returntype", void 0)], CustomNodeGroupStorage.prototype, "initialize", null);
- CustomNodeGroupStorage = CustomNodeGroupStorage_1 = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__ICustomNodeGroup)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object, Object])], CustomNodeGroupStorage);
- exports.CustomNodeGroupStorage = CustomNodeGroupStorage;
- var CustomNodeGroupStorage_1;
- /***/ }),
- /* 162 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- var _get = (function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } });
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var ArrayStorage_1 = __webpack_require__(163);
- var StringArrayStorage = StringArrayStorage_1 = function (_ArrayStorage_1$Array) {
- _inherits(StringArrayStorage, _ArrayStorage_1$Array);
- function StringArrayStorage(identifierNamesGeneratorFactory, arrayUtils, randomGenerator, options) {
- _classCallCheck(this, StringArrayStorage);
- var _this = _possibleConstructorReturn(this, (StringArrayStorage.__proto__ || Object.getPrototypeOf(StringArrayStorage)).call(this, randomGenerator, options));
- _this.identifierNamesGenerator = identifierNamesGeneratorFactory(options);
- _this.arrayUtils = arrayUtils;
- return _this;
- }
- _createClass(StringArrayStorage, [{
- key: "initialize",
- value: function initialize() {
- _get(StringArrayStorage.prototype.__proto__ || Object.getPrototypeOf(StringArrayStorage.prototype), "initialize", this).call(this);
- var baseStringArrayName = this.identifierNamesGenerator.generate().slice(0, StringArrayStorage_1.stringArrayNameLength);
- var baseStringArrayCallsWrapperName = this.identifierNamesGenerator.generate().slice(0, StringArrayStorage_1.stringArrayNameLength);
- var stringArrayName = "" + this.options.identifiersPrefix + baseStringArrayName;
- var stringArrayCallsWrapperName = "" + this.options.identifiersPrefix + baseStringArrayCallsWrapperName;
- this.storageId = stringArrayName + "|" + stringArrayCallsWrapperName;
- }
- }, {
- key: "rotateArray",
- value: function rotateArray(rotationValue) {
- this.storage = this.arrayUtils.arrayRotate(this.storage, rotationValue);
- }
- }, {
- key: "toString",
- value: function toString() {
- return this.storage.map(function (value) {
- return "'" + value + "'";
- }).toString();
- }
- }]);
- return StringArrayStorage;
- }(ArrayStorage_1.ArrayStorage);
- StringArrayStorage.stringArrayNameLength = 7;
- tslib_1.__decorate([inversify_1.postConstruct(), tslib_1.__metadata("design:type", Function), tslib_1.__metadata("design:paramtypes", []), tslib_1.__metadata("design:returntype", void 0)], StringArrayStorage.prototype, "initialize", null);
- StringArrayStorage = StringArrayStorage_1 = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IIdentifierNamesGenerator)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IArrayUtils)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(3, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object, Object, Object])], StringArrayStorage);
- exports.StringArrayStorage = StringArrayStorage;
- var StringArrayStorage_1;
- /***/ }),
- /* 163 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var Initializable_1 = __webpack_require__(5);
- var ArrayStorage = function () {
- function ArrayStorage(randomGenerator, options) {
- _classCallCheck(this, ArrayStorage);
- this.storageLength = 0;
- this.randomGenerator = randomGenerator;
- this.options = options;
- }
- _createClass(ArrayStorage, [{
- key: "initialize",
- value: function initialize() {
- this.storage = [];
- this.storageId = this.randomGenerator.getRandomString(6);
- }
- }, {
- key: "get",
- value: function get(key) {
- var value = this.storage[key];
- if (!value) {
- throw new Error("No value found in array storage with key `" + key + "`");
- }
- return value;
- }
- }, {
- key: "getKeyOf",
- value: function getKeyOf(value) {
- var key = this.storage.indexOf(value);
- return key >= 0 ? key : null;
- }
- }, {
- key: "getLength",
- value: function getLength() {
- return this.storageLength;
- }
- }, {
- key: "getStorage",
- value: function getStorage() {
- return this.storage;
- }
- }, {
- key: "getStorageId",
- value: function getStorageId() {
- return this.storageId;
- }
- }, {
- key: "mergeWith",
- value: function mergeWith(storage) {
- var mergeId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
- this.storage = [].concat(_toConsumableArray(this.storage), _toConsumableArray(storage.getStorage()));
- if (mergeId) {
- this.storageId = storage.getStorageId();
- }
- }
- }, {
- key: "set",
- value: function set(key, value) {
- if (key === this.storageLength) {
- this.storage.push(value);
- } else {
- this.storage.splice(key, 0, value);
- }
- this.storageLength++;
- }
- }]);
- return ArrayStorage;
- }();
- tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", Array)], ArrayStorage.prototype, "storage", void 0);
- tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", String)], ArrayStorage.prototype, "storageId", void 0);
- tslib_1.__decorate([inversify_1.postConstruct(), tslib_1.__metadata("design:type", Function), tslib_1.__metadata("design:paramtypes", []), tslib_1.__metadata("design:returntype", void 0)], ArrayStorage.prototype, "initialize", null);
- ArrayStorage = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Object, Object])], ArrayStorage);
- exports.ArrayStorage = ArrayStorage;
- /***/ }),
- /* 164 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var ArrayUtils_1 = __webpack_require__(165);
- var CryptUtils_1 = __webpack_require__(166);
- var EscapeSequenceEncoder_1 = __webpack_require__(169);
- var RandomGenerator_1 = __webpack_require__(46);
- exports.utilsModule = new inversify_1.ContainerModule(function (bind) {
- bind(ServiceIdentifiers_1.ServiceIdentifiers.IArrayUtils).to(ArrayUtils_1.ArrayUtils).inSingletonScope();
- bind(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator).to(RandomGenerator_1.RandomGenerator).inSingletonScope();
- bind(ServiceIdentifiers_1.ServiceIdentifiers.ICryptUtils).to(CryptUtils_1.CryptUtils).inSingletonScope();
- bind(ServiceIdentifiers_1.ServiceIdentifiers.IEscapeSequenceEncoder).to(EscapeSequenceEncoder_1.EscapeSequenceEncoder).inSingletonScope();
- });
- /***/ }),
- /* 165 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var ArrayUtils = function () {
- function ArrayUtils(randomGenerator) {
- _classCallCheck(this, ArrayUtils);
- this.randomGenerator = randomGenerator;
- }
- _createClass(ArrayUtils, [{
- key: "arrayRange",
- value: function arrayRange(length) {
- var range = [];
- for (var i = 0; i < length; i++) {
- range.push(i);
- }
- return range;
- }
- }, {
- key: "arrayRotate",
- value: function arrayRotate(array, times) {
- if (!array.length) {
- throw new ReferenceError("Cannot rotate empty array.");
- }
- if (times <= 0) {
- return array;
- }
- var newArray = array;
- var temp = void 0;
- while (times--) {
- temp = newArray.pop();
- newArray.unshift(temp);
- }
- return newArray;
- }
- }, {
- key: "arrayShuffle",
- value: function arrayShuffle(array) {
- var shuffledArray = [].concat(_toConsumableArray(array));
- for (var i = shuffledArray.length; i; i--) {
- var j = Math.floor(this.randomGenerator.getMathRandom() * i);
- var _ref = [shuffledArray[j], shuffledArray[i - 1]];
- shuffledArray[i - 1] = _ref[0];
- shuffledArray[j] = _ref[1];
- }
- return shuffledArray;
- }
- }]);
- return ArrayUtils;
- }();
- ArrayUtils = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__metadata("design:paramtypes", [Object])], ArrayUtils);
- exports.ArrayUtils = ArrayUtils;
- /***/ }),
- /* 166 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var RandomGenerator_1 = __webpack_require__(46);
- var Utils_1 = __webpack_require__(22);
- var CryptUtils = function () {
- function CryptUtils(randomGenerator) {
- _classCallCheck(this, CryptUtils);
- this.randomGenerator = randomGenerator;
- }
- _createClass(CryptUtils, [{
- key: "btoa",
- value: function btoa(string) {
- var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
- var output = '';
- string = encodeURIComponent(string).replace(/%([0-9A-F]{2})/g, function (match, p1) {
- return String.fromCharCode(parseInt("" + Utils_1.Utils.hexadecimalPrefix + p1));
- });
- for (var block, charCode, idx = 0, map = chars; string.charAt(idx | 0) || (map = '=', idx % 1); output += map.charAt(63 & block >> 8 - idx % 1 * 8)) {
- charCode = string.charCodeAt(idx += 3 / 4);
- if (charCode > 0xFF) {
- throw new Error("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.");
- }
- block = block << 8 | charCode;
- }
- return output;
- }
- }, {
- key: "hideString",
- value: function hideString(str, length) {
- var _this = this;
- var escapeRegExp = function escapeRegExp(s) {
- return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
- };
- var randomMerge = function randomMerge(s1, s2) {
- var i1 = -1;
- var i2 = -1;
- var result = '';
- while (i1 < s1.length || i2 < s2.length) {
- if (_this.randomGenerator.getMathRandom() < 0.5 && i2 < s2.length) {
- result += s2.charAt(++i2);
- } else {
- result += s1.charAt(++i1);
- }
- }
- return result;
- };
- var randomString = this.randomGenerator.getRandomGenerator().string({
- length: length,
- pool: RandomGenerator_1.RandomGenerator.randomGeneratorPool
- });
- var randomStringDiff = randomString.replace(new RegExp("[" + escapeRegExp(str) + "]", 'g'), '');
- var randomStringDiffArray = randomStringDiff.split('');
- this.randomGenerator.getRandomGenerator().shuffle(randomStringDiffArray);
- randomStringDiff = randomStringDiffArray.join('');
- return [randomMerge(str, randomStringDiff), randomStringDiff];
- }
- }, {
- key: "rc4",
- value: function rc4(string, key) {
- var s = [],
- j = 0,
- x = void 0,
- result = '';
- for (var i = 0; i < 256; i++) {
- s[i] = i;
- }
- for (i = 0; i < 256; i++) {
- j = (j + s[i] + key.charCodeAt(i % key.length)) % 256;
- x = s[i];
- s[i] = s[j];
- s[j] = x;
- }
- i = 0;
- j = 0;
- for (var y = 0; y < string.length; y++) {
- i = (i + 1) % 256;
- j = (j + s[i]) % 256;
- x = s[i];
- s[i] = s[j];
- s[j] = x;
- result += String.fromCharCode(string.charCodeAt(y) ^ s[(s[i] + s[j]) % 256]);
- }
- return result;
- }
- }]);
- return CryptUtils;
- }();
- CryptUtils = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__metadata("design:paramtypes", [Object])], CryptUtils);
- exports.CryptUtils = CryptUtils;
- /***/ }),
- /* 167 */
- /***/ (function(module, exports) {
- module.exports = require("md5");
- /***/ }),
- /* 168 */
- /***/ (function(module, exports) {
- module.exports = require("chance");
- /***/ }),
- /* 169 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var EscapeSequenceEncoder = function () {
- function EscapeSequenceEncoder() {
- _classCallCheck(this, EscapeSequenceEncoder);
- this.stringsCache = new Map();
- }
- _createClass(EscapeSequenceEncoder, [{
- key: "encode",
- value: function encode(string, encodeAllSymbols) {
- var cacheKey = string + "-" + String(encodeAllSymbols);
- if (this.stringsCache.has(cacheKey)) {
- return this.stringsCache.get(cacheKey);
- }
- var radix = 16;
- var replaceRegExp = new RegExp('[\\s\\S]', 'g');
- var escapeSequenceRegExp = new RegExp('[\'\"\\\\\\s]');
- var regExp = new RegExp('[\\x00-\\x7F]');
- var prefix = void 0;
- var template = void 0;
- var result = string.replace(replaceRegExp, function (character) {
- if (!encodeAllSymbols && !escapeSequenceRegExp.exec(character)) {
- return character;
- }
- if (regExp.exec(character)) {
- prefix = '\\x';
- template = '00';
- } else {
- prefix = "\\u";
- template = '0000';
- }
- return "" + prefix + (template + character.charCodeAt(0).toString(radix)).slice(-template.length);
- });
- this.stringsCache.set(cacheKey, result);
- return result;
- }
- }]);
- return EscapeSequenceEncoder;
- }();
- EscapeSequenceEncoder = tslib_1.__decorate([inversify_1.injectable()], EscapeSequenceEncoder);
- exports.EscapeSequenceEncoder = EscapeSequenceEncoder;
- /***/ }),
- /* 170 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var escodegen = tslib_1.__importStar(__webpack_require__(30));
- var packageJson = tslib_1.__importStar(__webpack_require__(47));
- var LoggingMessage_1 = __webpack_require__(171);
- var NodeTransformer_1 = __webpack_require__(20);
- var TransformationStage_1 = __webpack_require__(6);
- var EsprimaFacade_1 = __webpack_require__(172);
- var NodeGuards_1 = __webpack_require__(3);
- var JavaScriptObfuscator = JavaScriptObfuscator_1 = function () {
- function JavaScriptObfuscator(transformersRunner, sourceMapCorrector, randomGenerator, logger, options) {
- _classCallCheck(this, JavaScriptObfuscator);
- this.transformersRunner = transformersRunner;
- this.sourceMapCorrector = sourceMapCorrector;
- this.randomGenerator = randomGenerator;
- this.logger = logger;
- this.options = options;
- }
- _createClass(JavaScriptObfuscator, [{
- key: "obfuscate",
- value: function obfuscate(sourceCode) {
- var timeStart = Date.now();
- this.logger.info(LoggingMessage_1.LoggingMessage.Version, packageJson.version);
- this.logger.info(LoggingMessage_1.LoggingMessage.ObfuscationStarted);
- this.logger.info(LoggingMessage_1.LoggingMessage.RandomGeneratorSeed, this.randomGenerator.getSeed());
- var astTree = this.parseCode(sourceCode);
- var obfuscatedAstTree = this.transformAstTree(astTree);
- var generatorOutput = this.generateCode(sourceCode, obfuscatedAstTree);
- var obfuscationTime = (Date.now() - timeStart) / 1000;
- this.logger.success(LoggingMessage_1.LoggingMessage.ObfuscationCompleted, obfuscationTime);
- return this.getObfuscationResult(generatorOutput);
- }
- }, {
- key: "parseCode",
- value: function parseCode(sourceCode) {
- return EsprimaFacade_1.EsprimaFacade.parseScript(sourceCode, {
- attachComment: true,
- loc: this.options.sourceMap
- });
- }
- }, {
- key: "transformAstTree",
- value: function transformAstTree(astTree) {
- var isEmptyAstTree = NodeGuards_1.NodeGuards.isProgramNode(astTree) && !astTree.body.length && !astTree.leadingComments;
- if (isEmptyAstTree) {
- this.logger.warn(LoggingMessage_1.LoggingMessage.EmptySourceCode);
- return astTree;
- }
- astTree = this.runTransformationStage(astTree, TransformationStage_1.TransformationStage.Preparing);
- if (this.options.deadCodeInjection) {
- astTree = this.runTransformationStage(astTree, TransformationStage_1.TransformationStage.DeadCodeInjection);
- }
- if (this.options.controlFlowFlattening) {
- astTree = this.runTransformationStage(astTree, TransformationStage_1.TransformationStage.ControlFlowFlattening);
- }
- astTree = this.runTransformationStage(astTree, TransformationStage_1.TransformationStage.Converting);
- astTree = this.runTransformationStage(astTree, TransformationStage_1.TransformationStage.Obfuscating);
- astTree = this.runTransformationStage(astTree, TransformationStage_1.TransformationStage.Finalizing);
- return astTree;
- }
- }, {
- key: "generateCode",
- value: function generateCode(sourceCode, astTree) {
- var escodegenParams = Object.assign({}, JavaScriptObfuscator_1.escodegenParams);
- if (this.options.sourceMap) {
- escodegenParams.sourceMap = 'sourceMap';
- escodegenParams.sourceContent = sourceCode;
- }
- var generatorOutput = escodegen.generate(astTree, Object.assign({}, escodegenParams, { format: {
- compact: this.options.compact
- } }));
- generatorOutput.map = generatorOutput.map ? generatorOutput.map.toString() : '';
- return generatorOutput;
- }
- }, {
- key: "getObfuscationResult",
- value: function getObfuscationResult(generatorOutput) {
- return this.sourceMapCorrector.correct(generatorOutput.code, generatorOutput.map);
- }
- }, {
- key: "runTransformationStage",
- value: function runTransformationStage(astTree, transformationStage) {
- this.logger.info(LoggingMessage_1.LoggingMessage.TransformationStage, transformationStage);
- return this.transformersRunner.transform(astTree, JavaScriptObfuscator_1.transformersList, transformationStage);
- }
- }]);
- return JavaScriptObfuscator;
- }();
- JavaScriptObfuscator.escodegenParams = {
- comment: true,
- verbatim: 'x-verbatim-property',
- sourceMapWithCode: true
- };
- JavaScriptObfuscator.transformersList = [NodeTransformer_1.NodeTransformer.BlockStatementControlFlowTransformer, NodeTransformer_1.NodeTransformer.ClassDeclarationTransformer, NodeTransformer_1.NodeTransformer.CommentsTransformer, NodeTransformer_1.NodeTransformer.CustomNodesTransformer, NodeTransformer_1.NodeTransformer.DeadCodeInjectionTransformer, NodeTransformer_1.NodeTransformer.EvalCallExpressionTransformer, NodeTransformer_1.NodeTransformer.FunctionControlFlowTransformer, NodeTransformer_1.NodeTransformer.CatchClauseTransformer, NodeTransformer_1.NodeTransformer.FunctionDeclarationTransformer, NodeTransformer_1.NodeTransformer.FunctionTransformer, NodeTransformer_1.NodeTransformer.LabeledStatementTransformer, NodeTransformer_1.NodeTransformer.LiteralTransformer, NodeTransformer_1.NodeTransformer.MemberExpressionTransformer, NodeTransformer_1.NodeTransformer.MethodDefinitionTransformer, NodeTransformer_1.NodeTransformer.ObfuscatingGuardsTransformer, NodeTransformer_1.NodeTransformer.ObjectExpressionKeysTransformer, NodeTransformer_1.NodeTransformer.ObjectExpressionTransformer, NodeTransformer_1.NodeTransformer.ParentificationTransformer, NodeTransformer_1.NodeTransformer.TemplateLiteralTransformer, NodeTransformer_1.NodeTransformer.VariableDeclarationTransformer];
- JavaScriptObfuscator = JavaScriptObfuscator_1 = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.ITransformersRunner)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.ISourceMapCorrector)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IRandomGenerator)), tslib_1.__param(3, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.ILogger)), tslib_1.__param(4, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Object, Object, Object, Object, Object])], JavaScriptObfuscator);
- exports.JavaScriptObfuscator = JavaScriptObfuscator;
- var JavaScriptObfuscator_1;
- /***/ }),
- /* 171 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- var LoggingMessage;
- (function (LoggingMessage) {
- LoggingMessage["EmptySourceCode"] = "Empty source code. Obfuscation canceled...";
- LoggingMessage["ObfuscationCompleted"] = "Obfuscation completed. Total time: %s sec.";
- LoggingMessage["ObfuscationStarted"] = "Obfuscation started...";
- LoggingMessage["RandomGeneratorSeed"] = "Random generator seed: %s...";
- LoggingMessage["TransformationStage"] = "Transformation stage: %s...";
- LoggingMessage["Version"] = "Version: %s";
- })(LoggingMessage = exports.LoggingMessage || (exports.LoggingMessage = {}));
- /***/ }),
- /* 172 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- Object.defineProperty(exports, "__esModule", { value: true });
- var esprima = __importStar(__webpack_require__(37));
- var chalk_1 = __importDefault(__webpack_require__(48));
- var EsprimaFacade = function () {
- function EsprimaFacade() {
- _classCallCheck(this, EsprimaFacade);
- }
- _createClass(EsprimaFacade, null, [{
- key: "parseScript",
- value: function parseScript(input, config) {
- var lastMeta = null;
- try {
- return esprima.parseScript(input, config, function (node, meta) {
- return lastMeta = meta;
- });
- } catch (error) {
- return this.processParsingError(input, error.message, lastMeta);
- }
- }
- }, {
- key: "processParsingError",
- value: function processParsingError(sourceCode, errorMessage, meta) {
- if (!meta || !meta.start || !meta.end || !meta.start.column || !meta.end.column) {
- throw new Error(errorMessage);
- }
- var lineNumberMatch = errorMessage.match(/Line *(\d)/);
- if (!lineNumberMatch) {
- throw new Error(errorMessage);
- }
- var lineNumber = parseInt(lineNumberMatch[1], 10);
- var sourceCodeLines = sourceCode.split(/\r?\n/);
- var errorLine = sourceCodeLines[lineNumber - 1];
- if (!errorLine) {
- throw new Error(errorMessage);
- }
- var startErrorIndex = Math.max(0, meta.start.column - EsprimaFacade.nearestSymbolsCount);
- var endErrorIndex = Math.min(errorLine.length, meta.end.column + EsprimaFacade.nearestSymbolsCount);
- var formattedPointer = EsprimaFacade.colorError('>');
- var formattedCodeSlice = "..." + errorLine.substring(startErrorIndex, endErrorIndex).replace(/^\s+/, '') + "...";
- throw new Error(errorMessage + "\n" + formattedPointer + " " + formattedCodeSlice);
- }
- }]);
- return EsprimaFacade;
- }();
- EsprimaFacade.colorError = chalk_1.default.red;
- EsprimaFacade.nearestSymbolsCount = 10;
- exports.EsprimaFacade = EsprimaFacade;
- /***/ }),
- /* 173 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var chalk_1 = tslib_1.__importDefault(__webpack_require__(48));
- var Initializable_1 = __webpack_require__(5);
- var Logger = Logger_1 = function () {
- function Logger(options) {
- _classCallCheck(this, Logger);
- this.options = options;
- }
- _createClass(Logger, [{
- key: "initialize",
- value: function initialize() {
- this.colorInfo = chalk_1.default.cyan;
- this.colorSuccess = chalk_1.default.green;
- this.colorWarn = chalk_1.default.yellow;
- }
- }, {
- key: "info",
- value: function info(loggingMessage, value) {
- this.log(this.colorInfo, loggingMessage, value);
- }
- }, {
- key: "success",
- value: function success(loggingMessage, value) {
- this.log(this.colorSuccess, loggingMessage, value);
- }
- }, {
- key: "warn",
- value: function warn(loggingMessage, value) {
- this.log(this.colorWarn, loggingMessage, value);
- }
- }, {
- key: "log",
- value: function log(loggingLevelColor, loggingMessage, value) {
- if (!this.options.log) {
- return;
- }
- var processedMessage = loggingLevelColor("\n" + Logger_1.loggingPrefix + " " + loggingMessage);
- !value ? console.log(processedMessage) : console.log(processedMessage, value);
- }
- }]);
- return Logger;
- }();
- Logger.loggingPrefix = '[javascript-obfuscator]';
- tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", Function)], Logger.prototype, "colorInfo", void 0);
- tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", Function)], Logger.prototype, "colorSuccess", void 0);
- tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", Function)], Logger.prototype, "colorWarn", void 0);
- tslib_1.__decorate([inversify_1.postConstruct(), tslib_1.__metadata("design:type", Function), tslib_1.__metadata("design:paramtypes", []), tslib_1.__metadata("design:returntype", void 0)], Logger.prototype, "initialize", null);
- Logger = Logger_1 = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Object])], Logger);
- exports.Logger = Logger;
- var Logger_1;
- /***/ }),
- /* 174 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var events_1 = __webpack_require__(175);
- inversify_1.decorate(inversify_1.injectable(), events_1.EventEmitter);
- var ObfuscationEventEmitter = function (_events_1$EventEmitte) {
- _inherits(ObfuscationEventEmitter, _events_1$EventEmitte);
- function ObfuscationEventEmitter() {
- _classCallCheck(this, ObfuscationEventEmitter);
- return _possibleConstructorReturn(this, (ObfuscationEventEmitter.__proto__ || Object.getPrototypeOf(ObfuscationEventEmitter)).apply(this, arguments));
- }
- return ObfuscationEventEmitter;
- }(events_1.EventEmitter);
- ObfuscationEventEmitter = tslib_1.__decorate([inversify_1.injectable()], ObfuscationEventEmitter);
- exports.ObfuscationEventEmitter = ObfuscationEventEmitter;
- /***/ }),
- /* 175 */
- /***/ (function(module, exports) {
- module.exports = require("events");
- /***/ }),
- /* 176 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var Initializable_1 = __webpack_require__(5);
- var ObfuscationResult = function () {
- function ObfuscationResult() {
- _classCallCheck(this, ObfuscationResult);
- }
- _createClass(ObfuscationResult, [{
- key: "initialize",
- value: function initialize(obfuscatedCode, sourceMap) {
- this.obfuscatedCode = obfuscatedCode;
- this.sourceMap = sourceMap;
- }
- }, {
- key: "getObfuscatedCode",
- value: function getObfuscatedCode() {
- return this.obfuscatedCode;
- }
- }, {
- key: "getSourceMap",
- value: function getSourceMap() {
- return this.sourceMap;
- }
- }, {
- key: "toString",
- value: function toString() {
- return this.obfuscatedCode;
- }
- }]);
- return ObfuscationResult;
- }();
- tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", String)], ObfuscationResult.prototype, "obfuscatedCode", void 0);
- tslib_1.__decorate([Initializable_1.initializable(), tslib_1.__metadata("design:type", String)], ObfuscationResult.prototype, "sourceMap", void 0);
- ObfuscationResult = tslib_1.__decorate([inversify_1.injectable()], ObfuscationResult);
- exports.ObfuscationResult = ObfuscationResult;
- /***/ }),
- /* 177 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- Object.defineProperty(exports, "__esModule", { value: true });
- var SourceCode = function () {
- function SourceCode(sourceCode) {
- _classCallCheck(this, SourceCode);
- this.sourceCode = sourceCode;
- }
- _createClass(SourceCode, [{
- key: "getSourceCode",
- value: function getSourceCode() {
- return this.sourceCode;
- }
- }]);
- return SourceCode;
- }();
- exports.SourceCode = SourceCode;
- /***/ }),
- /* 178 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var SourceMapMode_1 = __webpack_require__(25);
- var SourceMapCorrector = function () {
- function SourceMapCorrector(obfuscationResultFactory, cryptUtils, options) {
- _classCallCheck(this, SourceMapCorrector);
- this.obfuscationResultFactory = obfuscationResultFactory;
- this.cryptUtils = cryptUtils;
- this.options = options;
- }
- _createClass(SourceMapCorrector, [{
- key: "correct",
- value: function correct(obfuscatedCode, sourceMap) {
- return this.obfuscationResultFactory(this.correctObfuscatedCode(obfuscatedCode, sourceMap), sourceMap);
- }
- }, {
- key: "correctObfuscatedCode",
- value: function correctObfuscatedCode(obfuscatedCode, sourceMap) {
- if (!sourceMap) {
- return obfuscatedCode;
- }
- var sourceMapUrl = this.options.sourceMapBaseUrl + this.options.sourceMapFileName;
- var sourceMappingUrl = '//# sourceMappingURL=';
- switch (this.options.sourceMapMode) {
- case SourceMapMode_1.SourceMapMode.Inline:
- sourceMappingUrl += "data:application/json;base64," + this.cryptUtils.btoa(sourceMap);
- break;
- case SourceMapMode_1.SourceMapMode.Separate:
- default:
- if (!sourceMapUrl) {
- return obfuscatedCode;
- }
- sourceMappingUrl += sourceMapUrl;
- break;
- }
- return obfuscatedCode + "\n" + sourceMappingUrl;
- }
- }]);
- return SourceMapCorrector;
- }();
- SourceMapCorrector = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__IObfuscationResult)), tslib_1.__param(1, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.ICryptUtils)), tslib_1.__param(2, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.IOptions)), tslib_1.__metadata("design:paramtypes", [Function, Object, Object])], SourceMapCorrector);
- exports.SourceMapCorrector = SourceMapCorrector;
- /***/ }),
- /* 179 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- Object.defineProperty(exports, "__esModule", { value: true });
- var tslib_1 = __webpack_require__(2);
- var inversify_1 = __webpack_require__(0);
- var ServiceIdentifiers_1 = __webpack_require__(1);
- var estraverse = tslib_1.__importStar(__webpack_require__(10));
- var VisitorDirection_1 = __webpack_require__(180);
- var NodeGuards_1 = __webpack_require__(3);
- var TransformersRunner = function () {
- function TransformersRunner(nodeTransformerFactory) {
- _classCallCheck(this, TransformersRunner);
- this.nodeTransformerFactory = nodeTransformerFactory;
- }
- _createClass(TransformersRunner, [{
- key: "transform",
- value: function transform(astTree, nodeTransformers, transformationStage) {
- if (!nodeTransformers.length) {
- return astTree;
- }
- var enterVisitors = [];
- var leaveVisitors = [];
- var nodeTransformersLength = nodeTransformers.length;
- var visitor = void 0;
- for (var i = 0; i < nodeTransformersLength; i++) {
- visitor = this.nodeTransformerFactory(nodeTransformers[i]).getVisitor(transformationStage);
- if (!visitor) {
- continue;
- }
- if (visitor.enter) {
- enterVisitors.push({ enter: visitor.enter });
- }
- if (visitor.leave) {
- leaveVisitors.push({ leave: visitor.leave });
- }
- }
- if (!enterVisitors.length && !leaveVisitors.length) {
- return astTree;
- }
- estraverse.replace(astTree, {
- enter: this.mergeVisitorsForDirection(enterVisitors, VisitorDirection_1.VisitorDirection.Enter),
- leave: this.mergeVisitorsForDirection(leaveVisitors, VisitorDirection_1.VisitorDirection.Leave)
- });
- return astTree;
- }
- }, {
- key: "mergeVisitorsForDirection",
- value: function mergeVisitorsForDirection(visitors, direction) {
- var visitorsLength = visitors.length;
- if (!visitorsLength) {
- return function (node, parentNode) {
- return node;
- };
- }
- return function (node, parentNode) {
- if (node.ignoredNode) {
- return estraverse.VisitorOption.Skip;
- }
- for (var i = 0; i < visitorsLength; i++) {
- var visitorFunction = visitors[i][direction];
- if (!visitorFunction) {
- continue;
- }
- var visitorResult = visitorFunction(node, parentNode);
- if (!visitorResult || !NodeGuards_1.NodeGuards.isNode(visitorResult)) {
- continue;
- }
- node = visitorResult;
- }
- return node;
- };
- }
- }]);
- return TransformersRunner;
- }();
- TransformersRunner = tslib_1.__decorate([inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(ServiceIdentifiers_1.ServiceIdentifiers.Factory__INodeTransformer)), tslib_1.__metadata("design:paramtypes", [Function])], TransformersRunner);
- exports.TransformersRunner = TransformersRunner;
- /***/ }),
- /* 180 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- var VisitorDirection;
- (function (VisitorDirection) {
- VisitorDirection["Enter"] = "enter";
- VisitorDirection["Leave"] = "leave";
- })(VisitorDirection = exports.VisitorDirection || (exports.VisitorDirection = {}));
- /***/ }),
- /* 181 */
- /***/ (function(module, exports) {
- module.exports = require("commander");
- /***/ }),
- /* 182 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.ArraySanitizer = function (value) {
- if (/,$/.test(value)) {
- throw new SyntaxError("Multiple <list> values should be wrapped inside quotes: --option-name 'value1, value2'");
- }
- return value.split(',').map(function (string) {
- return string.trim();
- });
- };
- /***/ }),
- /* 183 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.BooleanSanitizer = function (value) {
- return value === 'true' || value === '1';
- };
- /***/ }),
- /* 184 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- var IdentifierNamesGenerator_1 = __webpack_require__(24);
- exports.IdentifierNamesGeneratorSanitizer = function (value) {
- var isCorrectIdentifierNamesGenerator = Object.keys(IdentifierNamesGenerator_1.IdentifierNamesGenerator).some(function (key) {
- return IdentifierNamesGenerator_1.IdentifierNamesGenerator[key] === value;
- });
- if (!isCorrectIdentifierNamesGenerator) {
- throw new ReferenceError('Invalid value of `--identifier-names-generator` option');
- }
- return value;
- };
- /***/ }),
- /* 185 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- var ObfuscationTarget_1 = __webpack_require__(14);
- exports.ObfuscationTargetSanitizer = function (value) {
- var isCorrectTarget = Object.keys(ObfuscationTarget_1.ObfuscationTarget).some(function (key) {
- return ObfuscationTarget_1.ObfuscationTarget[key] === value;
- });
- if (!isCorrectTarget) {
- throw new ReferenceError('Invalid value of `--target` option');
- }
- return value;
- };
- /***/ }),
- /* 186 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- var SourceMapMode_1 = __webpack_require__(25);
- exports.SourceMapModeSanitizer = function (value) {
- var isCorrectSourceMapMode = Object.keys(SourceMapMode_1.SourceMapMode).some(function (key) {
- return SourceMapMode_1.SourceMapMode[key] === value;
- });
- if (!isCorrectSourceMapMode) {
- throw new ReferenceError('Invalid value of `--source-map-mode` option');
- }
- return value;
- };
- /***/ }),
- /* 187 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- var StringArrayEncoding_1 = __webpack_require__(26);
- exports.StringArrayEncodingSanitizer = function (value) {
- switch (value) {
- case 'true':
- case '1':
- case StringArrayEncoding_1.StringArrayEncoding.Base64:
- return true;
- case StringArrayEncoding_1.StringArrayEncoding.Rc4:
- return StringArrayEncoding_1.StringArrayEncoding.Rc4;
- default:
- return false;
- }
- };
- /***/ }),
- /* 188 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- Object.defineProperty(exports, "__esModule", { value: true });
- var fs = __importStar(__webpack_require__(49));
- var mkdirp = __importStar(__webpack_require__(189));
- var path = __importStar(__webpack_require__(35));
- var JavaScriptObfuscatorCLI_1 = __webpack_require__(34);
- var CLIUtils = function () {
- function CLIUtils() {
- _classCallCheck(this, CLIUtils);
- }
- _createClass(CLIUtils, null, [{
- key: "getOutputCodePath",
- value: function getOutputCodePath(inputPath) {
- return path.normalize(inputPath).split('.').map(function (value, index) {
- return index === 0 ? "" + value + JavaScriptObfuscatorCLI_1.JavaScriptObfuscatorCLI.obfuscatedFilePrefix : value;
- }).join('.');
- }
- }, {
- key: "getOutputSourceMapPath",
- value: function getOutputSourceMapPath(outputCodePath) {
- var sourceMapFileName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
- if (sourceMapFileName) {
- outputCodePath = outputCodePath.substring(0, outputCodePath.lastIndexOf('/')) + "/" + sourceMapFileName;
- }
- if (!/\.js\.map$/.test(outputCodePath)) {
- outputCodePath = outputCodePath.split('.')[0] + ".js.map";
- } else if (/\.js$/.test(outputCodePath)) {
- outputCodePath += '.map';
- }
- return outputCodePath;
- }
- }, {
- key: "getUserConfig",
- value: function getUserConfig(configPath) {
- var config = void 0;
- try {
- config = !(function webpackMissingModule() { var e = new Error("Cannot find module \".\""); e.code = 'MODULE_NOT_FOUND'; throw e; }());
- } catch (e) {
- try {
- config = require(configPath);
- } catch (e) {
- throw new ReferenceError('Given config path must be a valid path of `.js` or `.json` file');
- }
- }
- return config;
- }
- }, {
- key: "writeFile",
- value: function writeFile(outputPath, data) {
- mkdirp.sync(path.dirname(outputPath));
- fs.writeFileSync(outputPath, data, {
- encoding: JavaScriptObfuscatorCLI_1.JavaScriptObfuscatorCLI.encoding
- });
- }
- }]);
- return CLIUtils;
- }();
- exports.CLIUtils = CLIUtils;
- /***/ }),
- /* 189 */
- /***/ (function(module, exports) {
- module.exports = require("mkdirp");
- /***/ }),
- /* 190 */
- /***/ (function(module, exports) {
- function webpackEmptyContext(req) {
- throw new Error("Cannot find module '" + req + "'.");
- }
- webpackEmptyContext.keys = function() { return []; };
- webpackEmptyContext.resolve = webpackEmptyContext;
- module.exports = webpackEmptyContext;
- webpackEmptyContext.id = 190;
- /***/ }),
- /* 191 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
- function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- Object.defineProperty(exports, "__esModule", { value: true });
- var fs = __importStar(__webpack_require__(49));
- var path = __importStar(__webpack_require__(35));
- var JavaScriptObfuscatorCLI_1 = __webpack_require__(34);
- var SourceCodeReader = function () {
- function SourceCodeReader() {
- _classCallCheck(this, SourceCodeReader);
- }
- _createClass(SourceCodeReader, null, [{
- key: "readSourceCode",
- value: function readSourceCode(inputPath) {
- if (SourceCodeReader.isFilePath(inputPath)) {
- return SourceCodeReader.readFile(inputPath);
- }
- if (SourceCodeReader.isDirectoryPath(inputPath)) {
- return SourceCodeReader.readDirectoryRecursive(inputPath);
- }
- throw new ReferenceError("Given input path must be a valid source code file or directory path");
- }
- }, {
- key: "isDirectoryPath",
- value: function isDirectoryPath(filePath) {
- try {
- return fs.statSync(filePath).isDirectory();
- } catch (e) {
- return false;
- }
- }
- }, {
- key: "isFilePath",
- value: function isFilePath(filePath) {
- try {
- return fs.statSync(filePath).isFile();
- } catch (e) {
- return false;
- }
- }
- }, {
- key: "readDirectoryRecursive",
- value: function readDirectoryRecursive(directoryPath) {
- var fileData = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
- fs.readdirSync(directoryPath, JavaScriptObfuscatorCLI_1.JavaScriptObfuscatorCLI.encoding).forEach(function (fileName) {
- var filePath = directoryPath + "/" + fileName;
- if (SourceCodeReader.isDirectoryPath(filePath)) {
- fileData.push.apply(fileData, _toConsumableArray(SourceCodeReader.readDirectoryRecursive(filePath)));
- } else if (SourceCodeReader.isFilePath(filePath) && SourceCodeReader.isValidFile(fileName)) {
- var content = fs.readFileSync(filePath, JavaScriptObfuscatorCLI_1.JavaScriptObfuscatorCLI.encoding);
- fileData.push({ filePath: filePath, content: content });
- }
- });
- return fileData;
- }
- }, {
- key: "readFile",
- value: function readFile(filePath) {
- if (!SourceCodeReader.isValidFile(filePath)) {
- throw new ReferenceError("Input file must have .js extension");
- }
- return fs.readFileSync(filePath, JavaScriptObfuscatorCLI_1.JavaScriptObfuscatorCLI.encoding);
- }
- }, {
- key: "isValidFile",
- value: function isValidFile(filePath) {
- return JavaScriptObfuscatorCLI_1.JavaScriptObfuscatorCLI.availableInputExtensions.indexOf(path.extname(filePath)) !== -1 && !(filePath.indexOf(JavaScriptObfuscatorCLI_1.JavaScriptObfuscatorCLI.obfuscatedFilePrefix) !== -1);
- }
- }]);
- return SourceCodeReader;
- }();
- exports.SourceCodeReader = SourceCodeReader;
- /***/ })
- /******/ ]);
- //# sourceMappingURL=index.js.map
|