1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817618186181961820618216182261823618246182561826618276182861829618306183161832618336183461835618366183761838618396184061841618426184361844618456184661847618486184961850618516185261853618546185561856618576185861859618606186161862618636186461865618666186761868618696187061871618726187361874618756187661877618786187961880618816188261883618846188561886618876188861889618906189161892618936189461895618966189761898618996190061901619026190361904619056190661907619086190961910619116191261913619146191561916619176191861919619206192161922619236192461925619266192761928619296193061931619326193361934619356193661937619386193961940619416194261943619446194561946619476194861949619506195161952619536195461955619566195761958619596196061961619626196361964619656196661967619686196961970619716197261973619746197561976619776197861979619806198161982619836198461985619866198761988619896199061991619926199361994619956199661997619986199962000620016200262003620046200562006620076200862009620106201162012620136201462015620166201762018620196202062021620226202362024620256202662027620286202962030620316203262033620346203562036620376203862039620406204162042620436204462045620466204762048620496205062051620526205362054620556205662057620586205962060620616206262063620646206562066620676206862069620706207162072620736207462075620766207762078620796208062081620826208362084620856208662087620886208962090620916209262093620946209562096620976209862099621006210162102621036210462105621066210762108621096211062111621126211362114621156211662117621186211962120621216212262123621246212562126621276212862129621306213162132621336213462135621366213762138621396214062141621426214362144621456214662147621486214962150621516215262153621546215562156621576215862159621606216162162621636216462165621666216762168621696217062171621726217362174621756217662177621786217962180621816218262183621846218562186621876218862189621906219162192621936219462195621966219762198621996220062201622026220362204622056220662207622086220962210622116221262213622146221562216622176221862219622206222162222622236222462225622266222762228622296223062231622326223362234622356223662237622386223962240622416224262243622446224562246622476224862249622506225162252622536225462255622566225762258622596226062261622626226362264622656226662267622686226962270622716227262273622746227562276622776227862279622806228162282622836228462285622866228762288622896229062291622926229362294622956229662297622986229962300623016230262303623046230562306623076230862309623106231162312623136231462315623166231762318623196232062321623226232362324623256232662327623286232962330623316233262333623346233562336623376233862339623406234162342623436234462345623466234762348623496235062351623526235362354623556235662357623586235962360623616236262363623646236562366623676236862369623706237162372623736237462375623766237762378623796238062381623826238362384623856238662387623886238962390623916239262393623946239562396623976239862399624006240162402624036240462405624066240762408624096241062411624126241362414624156241662417624186241962420624216242262423624246242562426624276242862429624306243162432624336243462435624366243762438624396244062441624426244362444624456244662447624486244962450624516245262453624546245562456624576245862459624606246162462624636246462465624666246762468624696247062471624726247362474624756247662477624786247962480624816248262483624846248562486624876248862489624906249162492624936249462495624966249762498624996250062501625026250362504625056250662507625086250962510625116251262513625146251562516625176251862519625206252162522625236252462525625266252762528625296253062531625326253362534625356253662537625386253962540625416254262543625446254562546625476254862549625506255162552625536255462555625566255762558625596256062561625626256362564625656256662567625686256962570625716257262573625746257562576625776257862579625806258162582625836258462585625866258762588625896259062591625926259362594625956259662597625986259962600626016260262603626046260562606626076260862609626106261162612626136261462615626166261762618626196262062621626226262362624626256262662627626286262962630626316263262633626346263562636626376263862639626406264162642626436264462645626466264762648626496265062651626526265362654626556265662657626586265962660626616266262663626646266562666626676266862669626706267162672626736267462675626766267762678626796268062681626826268362684626856268662687626886268962690626916269262693626946269562696626976269862699627006270162702627036270462705627066270762708627096271062711627126271362714627156271662717627186271962720627216272262723627246272562726627276272862729627306273162732627336273462735627366273762738627396274062741627426274362744627456274662747627486274962750627516275262753627546275562756627576275862759627606276162762627636276462765627666276762768627696277062771627726277362774627756277662777627786277962780627816278262783627846278562786627876278862789627906279162792627936279462795627966279762798627996280062801628026280362804628056280662807628086280962810628116281262813628146281562816628176281862819628206282162822628236282462825628266282762828628296283062831628326283362834628356283662837628386283962840628416284262843628446284562846628476284862849628506285162852628536285462855628566285762858628596286062861628626286362864628656286662867628686286962870628716287262873628746287562876628776287862879628806288162882628836288462885628866288762888628896289062891628926289362894628956289662897628986289962900629016290262903629046290562906629076290862909629106291162912629136291462915629166291762918629196292062921629226292362924629256292662927629286292962930629316293262933629346293562936629376293862939629406294162942629436294462945629466294762948629496295062951629526295362954629556295662957629586295962960629616296262963629646296562966629676296862969629706297162972629736297462975629766297762978629796298062981629826298362984629856298662987629886298962990629916299262993629946299562996629976299862999630006300163002630036300463005630066300763008630096301063011630126301363014630156301663017630186301963020630216302263023630246302563026630276302863029630306303163032630336303463035630366303763038630396304063041630426304363044630456304663047630486304963050630516305263053630546305563056630576305863059630606306163062630636306463065630666306763068630696307063071630726307363074630756307663077630786307963080630816308263083630846308563086630876308863089630906309163092630936309463095630966309763098630996310063101631026310363104631056310663107631086310963110631116311263113631146311563116631176311863119631206312163122631236312463125631266312763128631296313063131631326313363134631356313663137631386313963140631416314263143631446314563146631476314863149631506315163152631536315463155631566315763158631596316063161631626316363164631656316663167631686316963170631716317263173631746317563176631776317863179631806318163182631836318463185631866318763188631896319063191631926319363194631956319663197631986319963200632016320263203632046320563206632076320863209632106321163212632136321463215632166321763218632196322063221632226322363224632256322663227632286322963230632316323263233632346323563236632376323863239632406324163242632436324463245632466324763248632496325063251632526325363254632556325663257632586325963260632616326263263632646326563266632676326863269632706327163272632736327463275632766327763278632796328063281632826328363284632856328663287632886328963290632916329263293632946329563296632976329863299633006330163302633036330463305633066330763308633096331063311633126331363314633156331663317633186331963320633216332263323633246332563326633276332863329633306333163332633336333463335633366333763338633396334063341633426334363344633456334663347633486334963350633516335263353633546335563356633576335863359633606336163362633636336463365633666336763368633696337063371633726337363374633756337663377633786337963380633816338263383633846338563386633876338863389633906339163392633936339463395633966339763398633996340063401634026340363404634056340663407634086340963410634116341263413634146341563416634176341863419634206342163422634236342463425634266342763428634296343063431634326343363434634356343663437634386343963440634416344263443634446344563446634476344863449634506345163452634536345463455634566345763458634596346063461634626346363464634656346663467634686346963470634716347263473634746347563476634776347863479634806348163482634836348463485634866348763488634896349063491634926349363494634956349663497634986349963500635016350263503635046350563506635076350863509635106351163512635136351463515635166351763518635196352063521635226352363524635256352663527635286352963530635316353263533635346353563536635376353863539635406354163542635436354463545635466354763548635496355063551635526355363554635556355663557635586355963560635616356263563635646356563566635676356863569635706357163572635736357463575635766357763578635796358063581635826358363584635856358663587635886358963590635916359263593635946359563596635976359863599636006360163602636036360463605636066360763608636096361063611636126361363614636156361663617636186361963620636216362263623636246362563626636276362863629636306363163632636336363463635636366363763638636396364063641636426364363644636456364663647636486364963650636516365263653636546365563656636576365863659636606366163662636636366463665636666366763668636696367063671636726367363674636756367663677636786367963680636816368263683636846368563686636876368863689636906369163692636936369463695636966369763698636996370063701637026370363704637056370663707637086370963710637116371263713637146371563716637176371863719637206372163722637236372463725637266372763728637296373063731637326373363734637356373663737637386373963740637416374263743637446374563746637476374863749637506375163752637536375463755637566375763758637596376063761637626376363764637656376663767637686376963770637716377263773637746377563776637776377863779637806378163782637836378463785637866378763788637896379063791637926379363794637956379663797637986379963800638016380263803638046380563806638076380863809638106381163812638136381463815638166381763818638196382063821638226382363824638256382663827638286382963830638316383263833638346383563836638376383863839638406384163842638436384463845638466384763848638496385063851638526385363854638556385663857638586385963860638616386263863638646386563866638676386863869638706387163872638736387463875638766387763878638796388063881638826388363884638856388663887638886388963890638916389263893638946389563896638976389863899639006390163902639036390463905639066390763908639096391063911639126391363914639156391663917639186391963920639216392263923639246392563926639276392863929639306393163932639336393463935639366393763938639396394063941639426394363944639456394663947639486394963950639516395263953639546395563956639576395863959639606396163962639636396463965639666396763968639696397063971639726397363974639756397663977639786397963980639816398263983639846398563986639876398863989639906399163992639936399463995639966399763998639996400064001640026400364004640056400664007640086400964010640116401264013640146401564016640176401864019640206402164022640236402464025640266402764028640296403064031640326403364034640356403664037640386403964040640416404264043640446404564046640476404864049640506405164052640536405464055640566405764058640596406064061640626406364064640656406664067640686406964070640716407264073640746407564076640776407864079640806408164082640836408464085640866408764088640896409064091640926409364094640956409664097640986409964100641016410264103641046410564106641076410864109641106411164112641136411464115641166411764118641196412064121641226412364124641256412664127641286412964130641316413264133641346413564136641376413864139641406414164142641436414464145641466414764148641496415064151641526415364154641556415664157641586415964160641616416264163641646416564166641676416864169641706417164172641736417464175641766417764178641796418064181641826418364184641856418664187641886418964190641916419264193641946419564196641976419864199642006420164202642036420464205642066420764208642096421064211642126421364214642156421664217642186421964220642216422264223642246422564226642276422864229642306423164232642336423464235642366423764238642396424064241642426424364244642456424664247642486424964250642516425264253642546425564256642576425864259642606426164262642636426464265642666426764268642696427064271642726427364274642756427664277642786427964280642816428264283642846428564286642876428864289642906429164292642936429464295642966429764298642996430064301643026430364304643056430664307643086430964310643116431264313643146431564316643176431864319643206432164322643236432464325643266432764328643296433064331643326433364334643356433664337643386433964340643416434264343643446434564346643476434864349643506435164352643536435464355643566435764358643596436064361643626436364364643656436664367643686436964370643716437264373643746437564376643776437864379643806438164382643836438464385643866438764388643896439064391643926439364394643956439664397643986439964400644016440264403644046440564406644076440864409644106441164412644136441464415644166441764418644196442064421644226442364424644256442664427644286442964430644316443264433644346443564436644376443864439644406444164442644436444464445644466444764448644496445064451644526445364454644556445664457644586445964460644616446264463644646446564466644676446864469644706447164472644736447464475644766447764478644796448064481644826448364484644856448664487644886448964490644916449264493644946449564496644976449864499645006450164502645036450464505645066450764508645096451064511645126451364514645156451664517645186451964520645216452264523645246452564526645276452864529645306453164532645336453464535645366453764538645396454064541645426454364544645456454664547645486454964550645516455264553645546455564556645576455864559645606456164562645636456464565645666456764568645696457064571645726457364574645756457664577645786457964580645816458264583645846458564586645876458864589645906459164592645936459464595645966459764598645996460064601646026460364604646056460664607646086460964610646116461264613646146461564616646176461864619646206462164622646236462464625646266462764628646296463064631646326463364634646356463664637646386463964640646416464264643646446464564646646476464864649646506465164652646536465464655646566465764658646596466064661646626466364664646656466664667646686466964670646716467264673646746467564676646776467864679646806468164682646836468464685646866468764688646896469064691646926469364694646956469664697646986469964700647016470264703647046470564706647076470864709647106471164712647136471464715647166471764718647196472064721647226472364724647256472664727647286472964730647316473264733647346473564736647376473864739647406474164742647436474464745647466474764748647496475064751647526475364754647556475664757647586475964760647616476264763647646476564766647676476864769647706477164772647736477464775647766477764778647796478064781647826478364784647856478664787647886478964790647916479264793647946479564796647976479864799648006480164802648036480464805648066480764808648096481064811648126481364814648156481664817648186481964820648216482264823648246482564826648276482864829648306483164832648336483464835648366483764838648396484064841648426484364844648456484664847648486484964850648516485264853648546485564856648576485864859648606486164862648636486464865648666486764868648696487064871648726487364874648756487664877648786487964880648816488264883648846488564886648876488864889648906489164892648936489464895648966489764898648996490064901649026490364904649056490664907649086490964910649116491264913649146491564916649176491864919649206492164922649236492464925649266492764928649296493064931649326493364934649356493664937649386493964940649416494264943649446494564946649476494864949649506495164952649536495464955649566495764958649596496064961649626496364964649656496664967649686496964970649716497264973649746497564976649776497864979649806498164982649836498464985649866498764988649896499064991649926499364994649956499664997649986499965000650016500265003650046500565006650076500865009650106501165012650136501465015650166501765018650196502065021650226502365024650256502665027650286502965030650316503265033650346503565036650376503865039650406504165042650436504465045650466504765048650496505065051650526505365054650556505665057650586505965060650616506265063650646506565066650676506865069650706507165072650736507465075650766507765078650796508065081650826508365084650856508665087650886508965090650916509265093650946509565096650976509865099651006510165102651036510465105651066510765108651096511065111651126511365114651156511665117651186511965120651216512265123651246512565126651276512865129651306513165132651336513465135651366513765138651396514065141651426514365144651456514665147651486514965150651516515265153651546515565156651576515865159651606516165162651636516465165651666516765168651696517065171651726517365174651756517665177651786517965180651816518265183651846518565186651876518865189651906519165192651936519465195651966519765198651996520065201652026520365204652056520665207652086520965210652116521265213652146521565216652176521865219652206522165222652236522465225652266522765228652296523065231652326523365234652356523665237652386523965240652416524265243652446524565246652476524865249652506525165252652536525465255652566525765258652596526065261652626526365264652656526665267652686526965270652716527265273652746527565276652776527865279652806528165282652836528465285652866528765288652896529065291652926529365294652956529665297652986529965300653016530265303653046530565306653076530865309653106531165312653136531465315653166531765318653196532065321653226532365324653256532665327653286532965330653316533265333653346533565336653376533865339653406534165342653436534465345653466534765348653496535065351653526535365354653556535665357653586535965360653616536265363653646536565366653676536865369653706537165372653736537465375653766537765378653796538065381653826538365384653856538665387653886538965390653916539265393653946539565396653976539865399654006540165402654036540465405654066540765408654096541065411654126541365414654156541665417654186541965420654216542265423654246542565426654276542865429654306543165432654336543465435654366543765438654396544065441654426544365444654456544665447654486544965450654516545265453654546545565456654576545865459654606546165462654636546465465654666546765468654696547065471654726547365474654756547665477654786547965480654816548265483654846548565486654876548865489654906549165492654936549465495654966549765498654996550065501655026550365504655056550665507655086550965510655116551265513655146551565516655176551865519655206552165522655236552465525655266552765528655296553065531655326553365534655356553665537655386553965540655416554265543655446554565546655476554865549655506555165552655536555465555655566555765558655596556065561655626556365564655656556665567655686556965570655716557265573655746557565576655776557865579655806558165582655836558465585655866558765588655896559065591655926559365594655956559665597655986559965600656016560265603656046560565606656076560865609656106561165612656136561465615656166561765618656196562065621656226562365624656256562665627656286562965630656316563265633656346563565636656376563865639656406564165642656436564465645656466564765648656496565065651656526565365654656556565665657656586565965660656616566265663656646566565666656676566865669656706567165672656736567465675656766567765678656796568065681656826568365684656856568665687656886568965690656916569265693656946569565696656976569865699657006570165702657036570465705657066570765708657096571065711657126571365714657156571665717657186571965720657216572265723657246572565726657276572865729657306573165732657336573465735657366573765738657396574065741657426574365744657456574665747657486574965750657516575265753657546575565756657576575865759657606576165762657636576465765657666576765768657696577065771657726577365774657756577665777657786577965780657816578265783657846578565786657876578865789657906579165792657936579465795657966579765798657996580065801658026580365804658056580665807658086580965810658116581265813658146581565816658176581865819658206582165822658236582465825658266582765828658296583065831658326583365834658356583665837658386583965840658416584265843658446584565846658476584865849658506585165852658536585465855658566585765858658596586065861658626586365864658656586665867658686586965870658716587265873658746587565876658776587865879658806588165882658836588465885658866588765888658896589065891658926589365894658956589665897658986589965900659016590265903659046590565906659076590865909659106591165912659136591465915659166591765918659196592065921659226592365924659256592665927659286592965930659316593265933659346593565936659376593865939659406594165942659436594465945659466594765948659496595065951659526595365954659556595665957659586595965960659616596265963659646596565966659676596865969659706597165972659736597465975659766597765978659796598065981659826598365984659856598665987659886598965990659916599265993659946599565996659976599865999660006600166002660036600466005660066600766008660096601066011660126601366014660156601666017660186601966020660216602266023660246602566026660276602866029660306603166032660336603466035660366603766038660396604066041660426604366044660456604666047660486604966050660516605266053660546605566056660576605866059660606606166062660636606466065660666606766068660696607066071660726607366074660756607666077660786607966080660816608266083660846608566086660876608866089660906609166092660936609466095660966609766098660996610066101661026610366104661056610666107661086610966110661116611266113661146611566116661176611866119661206612166122661236612466125661266612766128661296613066131661326613366134661356613666137661386613966140661416614266143661446614566146661476614866149661506615166152661536615466155661566615766158661596616066161661626616366164661656616666167661686616966170661716617266173661746617566176661776617866179661806618166182661836618466185661866618766188661896619066191661926619366194661956619666197661986619966200662016620266203662046620566206662076620866209662106621166212662136621466215662166621766218662196622066221662226622366224662256622666227662286622966230662316623266233662346623566236662376623866239662406624166242662436624466245662466624766248662496625066251662526625366254662556625666257662586625966260662616626266263662646626566266662676626866269662706627166272662736627466275662766627766278662796628066281662826628366284662856628666287662886628966290662916629266293662946629566296662976629866299663006630166302663036630466305663066630766308663096631066311663126631366314663156631666317663186631966320663216632266323663246632566326663276632866329663306633166332663336633466335663366633766338663396634066341663426634366344663456634666347663486634966350663516635266353663546635566356663576635866359663606636166362663636636466365663666636766368663696637066371663726637366374663756637666377663786637966380663816638266383663846638566386663876638866389663906639166392663936639466395663966639766398663996640066401664026640366404664056640666407664086640966410664116641266413664146641566416664176641866419664206642166422664236642466425664266642766428664296643066431664326643366434664356643666437664386643966440664416644266443664446644566446664476644866449664506645166452664536645466455664566645766458664596646066461664626646366464664656646666467664686646966470664716647266473664746647566476664776647866479664806648166482664836648466485664866648766488664896649066491664926649366494664956649666497664986649966500665016650266503665046650566506665076650866509665106651166512665136651466515665166651766518665196652066521665226652366524665256652666527665286652966530665316653266533665346653566536665376653866539665406654166542665436654466545665466654766548665496655066551665526655366554665556655666557665586655966560665616656266563665646656566566665676656866569665706657166572665736657466575665766657766578665796658066581665826658366584665856658666587665886658966590665916659266593665946659566596665976659866599666006660166602666036660466605666066660766608666096661066611666126661366614666156661666617666186661966620666216662266623666246662566626666276662866629666306663166632666336663466635666366663766638666396664066641666426664366644666456664666647666486664966650666516665266653666546665566656666576665866659666606666166662666636666466665666666666766668666696667066671666726667366674666756667666677666786667966680666816668266683666846668566686666876668866689666906669166692666936669466695666966669766698666996670066701667026670366704667056670666707667086670966710667116671266713667146671566716667176671866719667206672166722667236672466725667266672766728667296673066731667326673366734667356673666737667386673966740667416674266743667446674566746667476674866749667506675166752667536675466755667566675766758667596676066761667626676366764667656676666767667686676966770667716677266773667746677566776667776677866779667806678166782667836678466785667866678766788667896679066791667926679366794667956679666797667986679966800668016680266803668046680566806668076680866809668106681166812668136681466815668166681766818668196682066821668226682366824668256682666827668286682966830668316683266833668346683566836668376683866839668406684166842668436684466845668466684766848668496685066851668526685366854668556685666857668586685966860668616686266863668646686566866668676686866869668706687166872668736687466875668766687766878668796688066881668826688366884668856688666887668886688966890668916689266893668946689566896668976689866899669006690166902669036690466905669066690766908669096691066911669126691366914669156691666917669186691966920669216692266923669246692566926669276692866929669306693166932669336693466935669366693766938669396694066941669426694366944669456694666947669486694966950669516695266953669546695566956669576695866959669606696166962669636696466965669666696766968669696697066971669726697366974669756697666977669786697966980669816698266983669846698566986669876698866989669906699166992669936699466995669966699766998669996700067001670026700367004670056700667007670086700967010670116701267013670146701567016670176701867019670206702167022670236702467025670266702767028670296703067031670326703367034670356703667037670386703967040670416704267043670446704567046670476704867049670506705167052670536705467055670566705767058670596706067061670626706367064670656706667067670686706967070670716707267073670746707567076670776707867079670806708167082670836708467085670866708767088670896709067091670926709367094670956709667097670986709967100671016710267103671046710567106671076710867109671106711167112671136711467115671166711767118671196712067121671226712367124671256712667127671286712967130671316713267133671346713567136671376713867139671406714167142671436714467145671466714767148671496715067151671526715367154671556715667157671586715967160671616716267163671646716567166671676716867169671706717167172671736717467175671766717767178671796718067181671826718367184671856718667187671886718967190671916719267193671946719567196671976719867199672006720167202672036720467205672066720767208672096721067211672126721367214672156721667217672186721967220672216722267223672246722567226672276722867229672306723167232672336723467235672366723767238672396724067241672426724367244672456724667247672486724967250672516725267253672546725567256672576725867259672606726167262672636726467265672666726767268672696727067271672726727367274672756727667277672786727967280672816728267283672846728567286672876728867289672906729167292672936729467295672966729767298672996730067301673026730367304673056730667307673086730967310673116731267313673146731567316673176731867319673206732167322673236732467325673266732767328673296733067331673326733367334673356733667337673386733967340673416734267343673446734567346673476734867349673506735167352673536735467355673566735767358673596736067361673626736367364673656736667367673686736967370673716737267373673746737567376673776737867379673806738167382673836738467385673866738767388673896739067391673926739367394673956739667397673986739967400674016740267403674046740567406674076740867409674106741167412674136741467415674166741767418674196742067421674226742367424674256742667427674286742967430674316743267433674346743567436674376743867439674406744167442674436744467445674466744767448674496745067451674526745367454674556745667457674586745967460674616746267463674646746567466674676746867469674706747167472674736747467475674766747767478674796748067481674826748367484674856748667487674886748967490674916749267493674946749567496674976749867499675006750167502675036750467505675066750767508675096751067511675126751367514675156751667517675186751967520675216752267523675246752567526675276752867529675306753167532675336753467535675366753767538675396754067541675426754367544675456754667547675486754967550675516755267553675546755567556675576755867559675606756167562675636756467565675666756767568675696757067571675726757367574675756757667577675786757967580675816758267583675846758567586675876758867589675906759167592675936759467595675966759767598675996760067601676026760367604676056760667607676086760967610676116761267613676146761567616676176761867619676206762167622676236762467625676266762767628676296763067631676326763367634676356763667637676386763967640676416764267643676446764567646676476764867649676506765167652676536765467655676566765767658676596766067661676626766367664676656766667667676686766967670676716767267673676746767567676676776767867679676806768167682676836768467685676866768767688676896769067691676926769367694676956769667697676986769967700677016770267703677046770567706677076770867709677106771167712677136771467715677166771767718677196772067721677226772367724677256772667727677286772967730677316773267733677346773567736677376773867739677406774167742677436774467745677466774767748677496775067751677526775367754677556775667757677586775967760677616776267763677646776567766677676776867769677706777167772677736777467775677766777767778677796778067781677826778367784677856778667787677886778967790677916779267793677946779567796677976779867799678006780167802678036780467805678066780767808678096781067811678126781367814678156781667817678186781967820678216782267823678246782567826678276782867829678306783167832678336783467835678366783767838678396784067841678426784367844678456784667847678486784967850678516785267853678546785567856678576785867859678606786167862678636786467865678666786767868678696787067871678726787367874678756787667877678786787967880678816788267883678846788567886678876788867889678906789167892678936789467895678966789767898678996790067901679026790367904679056790667907679086790967910679116791267913679146791567916679176791867919679206792167922679236792467925679266792767928679296793067931679326793367934679356793667937679386793967940679416794267943679446794567946679476794867949679506795167952679536795467955679566795767958679596796067961679626796367964679656796667967679686796967970679716797267973679746797567976679776797867979679806798167982679836798467985679866798767988679896799067991679926799367994679956799667997679986799968000680016800268003680046800568006680076800868009680106801168012680136801468015680166801768018680196802068021680226802368024680256802668027680286802968030680316803268033680346803568036680376803868039680406804168042680436804468045680466804768048680496805068051680526805368054680556805668057680586805968060680616806268063680646806568066680676806868069680706807168072680736807468075680766807768078680796808068081680826808368084680856808668087680886808968090680916809268093680946809568096680976809868099681006810168102681036810468105681066810768108681096811068111681126811368114681156811668117681186811968120681216812268123681246812568126681276812868129681306813168132681336813468135681366813768138681396814068141681426814368144681456814668147681486814968150681516815268153681546815568156681576815868159681606816168162681636816468165681666816768168681696817068171681726817368174681756817668177681786817968180681816818268183681846818568186681876818868189681906819168192681936819468195681966819768198681996820068201682026820368204682056820668207682086820968210682116821268213682146821568216682176821868219682206822168222682236822468225682266822768228682296823068231682326823368234682356823668237682386823968240682416824268243682446824568246682476824868249682506825168252682536825468255682566825768258682596826068261682626826368264682656826668267682686826968270682716827268273682746827568276682776827868279682806828168282682836828468285682866828768288682896829068291682926829368294682956829668297682986829968300683016830268303683046830568306683076830868309683106831168312683136831468315683166831768318683196832068321683226832368324683256832668327683286832968330683316833268333683346833568336683376833868339683406834168342683436834468345683466834768348683496835068351683526835368354683556835668357683586835968360683616836268363683646836568366683676836868369683706837168372683736837468375683766837768378683796838068381683826838368384683856838668387683886838968390683916839268393683946839568396683976839868399684006840168402684036840468405684066840768408684096841068411684126841368414684156841668417684186841968420684216842268423684246842568426684276842868429684306843168432684336843468435684366843768438684396844068441684426844368444684456844668447684486844968450684516845268453684546845568456684576845868459684606846168462684636846468465684666846768468684696847068471684726847368474684756847668477684786847968480684816848268483684846848568486684876848868489684906849168492684936849468495684966849768498684996850068501685026850368504685056850668507685086850968510685116851268513685146851568516685176851868519685206852168522685236852468525685266852768528685296853068531685326853368534685356853668537685386853968540685416854268543685446854568546685476854868549685506855168552685536855468555685566855768558685596856068561685626856368564685656856668567685686856968570685716857268573685746857568576685776857868579685806858168582685836858468585685866858768588685896859068591685926859368594685956859668597685986859968600686016860268603686046860568606686076860868609686106861168612686136861468615686166861768618686196862068621686226862368624686256862668627686286862968630686316863268633686346863568636686376863868639686406864168642686436864468645686466864768648686496865068651686526865368654686556865668657686586865968660686616866268663686646866568666686676866868669686706867168672686736867468675686766867768678686796868068681686826868368684686856868668687686886868968690686916869268693686946869568696686976869868699687006870168702687036870468705687066870768708687096871068711687126871368714687156871668717687186871968720687216872268723687246872568726687276872868729687306873168732687336873468735687366873768738687396874068741687426874368744687456874668747687486874968750687516875268753687546875568756687576875868759687606876168762687636876468765687666876768768687696877068771687726877368774687756877668777687786877968780687816878268783687846878568786687876878868789687906879168792687936879468795687966879768798687996880068801688026880368804688056880668807688086880968810688116881268813688146881568816688176881868819688206882168822688236882468825688266882768828688296883068831688326883368834688356883668837688386883968840688416884268843688446884568846688476884868849688506885168852688536885468855688566885768858688596886068861688626886368864688656886668867688686886968870688716887268873688746887568876688776887868879688806888168882688836888468885688866888768888688896889068891688926889368894688956889668897688986889968900689016890268903689046890568906689076890868909689106891168912689136891468915689166891768918689196892068921689226892368924689256892668927689286892968930689316893268933689346893568936689376893868939689406894168942689436894468945689466894768948689496895068951689526895368954689556895668957689586895968960689616896268963689646896568966689676896868969689706897168972689736897468975689766897768978689796898068981689826898368984689856898668987689886898968990689916899268993689946899568996689976899868999690006900169002690036900469005690066900769008690096901069011690126901369014690156901669017690186901969020690216902269023690246902569026690276902869029690306903169032690336903469035690366903769038690396904069041690426904369044690456904669047690486904969050690516905269053690546905569056690576905869059690606906169062690636906469065690666906769068690696907069071690726907369074690756907669077690786907969080690816908269083690846908569086690876908869089690906909169092690936909469095690966909769098690996910069101691026910369104691056910669107691086910969110691116911269113691146911569116691176911869119691206912169122691236912469125691266912769128691296913069131691326913369134691356913669137691386913969140691416914269143691446914569146691476914869149691506915169152691536915469155691566915769158691596916069161691626916369164691656916669167691686916969170691716917269173691746917569176691776917869179691806918169182691836918469185691866918769188691896919069191691926919369194691956919669197691986919969200692016920269203692046920569206692076920869209692106921169212692136921469215692166921769218692196922069221692226922369224692256922669227692286922969230692316923269233692346923569236692376923869239692406924169242692436924469245692466924769248692496925069251692526925369254692556925669257692586925969260692616926269263692646926569266692676926869269692706927169272692736927469275692766927769278692796928069281692826928369284692856928669287692886928969290692916929269293692946929569296692976929869299693006930169302693036930469305693066930769308693096931069311693126931369314693156931669317693186931969320693216932269323693246932569326693276932869329693306933169332693336933469335693366933769338693396934069341693426934369344693456934669347693486934969350693516935269353693546935569356693576935869359693606936169362693636936469365693666936769368693696937069371693726937369374693756937669377693786937969380693816938269383693846938569386693876938869389693906939169392693936939469395693966939769398693996940069401694026940369404694056940669407694086940969410694116941269413694146941569416694176941869419694206942169422694236942469425694266942769428694296943069431694326943369434694356943669437694386943969440694416944269443694446944569446694476944869449694506945169452694536945469455694566945769458694596946069461694626946369464694656946669467694686946969470694716947269473694746947569476694776947869479694806948169482694836948469485694866948769488694896949069491694926949369494694956949669497694986949969500695016950269503695046950569506695076950869509695106951169512695136951469515695166951769518695196952069521695226952369524695256952669527695286952969530695316953269533695346953569536695376953869539695406954169542695436954469545695466954769548695496955069551695526955369554695556955669557695586955969560695616956269563695646956569566695676956869569695706957169572695736957469575695766957769578695796958069581695826958369584695856958669587695886958969590695916959269593695946959569596695976959869599696006960169602696036960469605696066960769608696096961069611696126961369614696156961669617696186961969620696216962269623696246962569626696276962869629696306963169632696336963469635696366963769638696396964069641696426964369644696456964669647696486964969650696516965269653696546965569656696576965869659696606966169662696636966469665696666966769668696696967069671696726967369674696756967669677696786967969680696816968269683696846968569686696876968869689696906969169692696936969469695696966969769698696996970069701697026970369704697056970669707697086970969710697116971269713697146971569716697176971869719697206972169722697236972469725697266972769728697296973069731697326973369734697356973669737697386973969740697416974269743697446974569746697476974869749697506975169752697536975469755697566975769758697596976069761697626976369764697656976669767697686976969770697716977269773697746977569776697776977869779697806978169782697836978469785697866978769788697896979069791697926979369794697956979669797697986979969800698016980269803698046980569806698076980869809698106981169812698136981469815698166981769818698196982069821698226982369824698256982669827698286982969830698316983269833698346983569836698376983869839698406984169842698436984469845698466984769848698496985069851698526985369854698556985669857698586985969860698616986269863698646986569866698676986869869698706987169872698736987469875698766987769878698796988069881698826988369884698856988669887698886988969890698916989269893698946989569896698976989869899699006990169902699036990469905699066990769908699096991069911699126991369914699156991669917699186991969920699216992269923699246992569926699276992869929699306993169932699336993469935699366993769938699396994069941699426994369944699456994669947699486994969950699516995269953699546995569956699576995869959699606996169962699636996469965699666996769968699696997069971699726997369974699756997669977699786997969980699816998269983699846998569986699876998869989699906999169992699936999469995699966999769998699997000070001700027000370004700057000670007700087000970010700117001270013700147001570016700177001870019700207002170022700237002470025700267002770028700297003070031700327003370034700357003670037700387003970040700417004270043700447004570046700477004870049700507005170052700537005470055700567005770058700597006070061700627006370064700657006670067700687006970070700717007270073700747007570076700777007870079700807008170082700837008470085700867008770088700897009070091700927009370094700957009670097700987009970100701017010270103701047010570106701077010870109701107011170112701137011470115701167011770118701197012070121701227012370124701257012670127701287012970130701317013270133701347013570136701377013870139701407014170142701437014470145701467014770148701497015070151701527015370154701557015670157701587015970160701617016270163701647016570166701677016870169701707017170172701737017470175701767017770178701797018070181701827018370184701857018670187701887018970190701917019270193701947019570196701977019870199702007020170202702037020470205702067020770208702097021070211702127021370214702157021670217702187021970220702217022270223702247022570226702277022870229702307023170232702337023470235702367023770238702397024070241702427024370244702457024670247702487024970250702517025270253702547025570256702577025870259702607026170262702637026470265702667026770268702697027070271702727027370274702757027670277702787027970280702817028270283702847028570286702877028870289702907029170292702937029470295702967029770298702997030070301703027030370304703057030670307703087030970310703117031270313703147031570316703177031870319703207032170322703237032470325703267032770328703297033070331703327033370334703357033670337703387033970340703417034270343703447034570346703477034870349703507035170352703537035470355703567035770358703597036070361703627036370364703657036670367703687036970370703717037270373703747037570376703777037870379703807038170382703837038470385703867038770388703897039070391703927039370394703957039670397703987039970400704017040270403704047040570406704077040870409704107041170412704137041470415704167041770418704197042070421704227042370424704257042670427704287042970430704317043270433704347043570436704377043870439704407044170442704437044470445704467044770448704497045070451704527045370454704557045670457704587045970460704617046270463704647046570466704677046870469704707047170472704737047470475704767047770478704797048070481704827048370484704857048670487704887048970490704917049270493704947049570496704977049870499705007050170502705037050470505705067050770508705097051070511705127051370514705157051670517705187051970520705217052270523705247052570526705277052870529705307053170532705337053470535705367053770538705397054070541705427054370544705457054670547705487054970550705517055270553705547055570556705577055870559705607056170562705637056470565705667056770568705697057070571705727057370574705757057670577705787057970580705817058270583705847058570586705877058870589705907059170592705937059470595705967059770598705997060070601706027060370604706057060670607706087060970610706117061270613706147061570616706177061870619706207062170622706237062470625706267062770628706297063070631706327063370634706357063670637706387063970640706417064270643706447064570646706477064870649706507065170652706537065470655706567065770658706597066070661706627066370664706657066670667706687066970670706717067270673706747067570676706777067870679706807068170682706837068470685706867068770688706897069070691706927069370694706957069670697706987069970700707017070270703707047070570706707077070870709707107071170712707137071470715707167071770718707197072070721707227072370724707257072670727707287072970730707317073270733707347073570736707377073870739707407074170742707437074470745707467074770748707497075070751707527075370754707557075670757707587075970760707617076270763707647076570766707677076870769707707077170772707737077470775707767077770778707797078070781707827078370784707857078670787707887078970790707917079270793707947079570796707977079870799708007080170802708037080470805708067080770808708097081070811708127081370814708157081670817708187081970820708217082270823708247082570826708277082870829708307083170832708337083470835708367083770838708397084070841708427084370844708457084670847708487084970850708517085270853708547085570856708577085870859708607086170862708637086470865708667086770868708697087070871708727087370874708757087670877708787087970880708817088270883708847088570886708877088870889708907089170892708937089470895708967089770898708997090070901709027090370904709057090670907709087090970910709117091270913709147091570916709177091870919709207092170922709237092470925709267092770928709297093070931709327093370934709357093670937709387093970940709417094270943709447094570946709477094870949709507095170952709537095470955709567095770958709597096070961709627096370964709657096670967709687096970970709717097270973709747097570976709777097870979709807098170982709837098470985709867098770988709897099070991709927099370994709957099670997709987099971000710017100271003710047100571006710077100871009710107101171012710137101471015710167101771018710197102071021710227102371024710257102671027710287102971030710317103271033710347103571036710377103871039710407104171042710437104471045710467104771048710497105071051710527105371054710557105671057710587105971060710617106271063710647106571066710677106871069710707107171072710737107471075710767107771078710797108071081710827108371084710857108671087710887108971090710917109271093710947109571096710977109871099711007110171102711037110471105711067110771108711097111071111711127111371114711157111671117711187111971120711217112271123711247112571126711277112871129711307113171132711337113471135711367113771138711397114071141711427114371144711457114671147711487114971150711517115271153711547115571156711577115871159711607116171162711637116471165711667116771168711697117071171711727117371174711757117671177711787117971180711817118271183711847118571186711877118871189711907119171192711937119471195711967119771198711997120071201712027120371204712057120671207712087120971210712117121271213712147121571216712177121871219712207122171222712237122471225712267122771228712297123071231712327123371234712357123671237712387123971240712417124271243712447124571246712477124871249712507125171252712537125471255712567125771258712597126071261712627126371264712657126671267712687126971270712717127271273712747127571276712777127871279712807128171282712837128471285712867128771288712897129071291712927129371294712957129671297712987129971300713017130271303713047130571306713077130871309713107131171312713137131471315713167131771318713197132071321713227132371324713257132671327713287132971330713317133271333713347133571336713377133871339713407134171342713437134471345713467134771348713497135071351713527135371354713557135671357713587135971360713617136271363713647136571366713677136871369713707137171372713737137471375713767137771378713797138071381713827138371384713857138671387713887138971390713917139271393713947139571396713977139871399714007140171402714037140471405714067140771408714097141071411714127141371414714157141671417714187141971420714217142271423714247142571426714277142871429714307143171432714337143471435714367143771438714397144071441714427144371444714457144671447714487144971450714517145271453714547145571456714577145871459714607146171462714637146471465714667146771468714697147071471714727147371474714757147671477714787147971480714817148271483714847148571486714877148871489714907149171492714937149471495714967149771498714997150071501715027150371504715057150671507715087150971510715117151271513715147151571516715177151871519715207152171522715237152471525715267152771528715297153071531715327153371534715357153671537715387153971540715417154271543715447154571546715477154871549715507155171552715537155471555715567155771558715597156071561715627156371564715657156671567715687156971570715717157271573715747157571576715777157871579715807158171582715837158471585715867158771588715897159071591715927159371594715957159671597715987159971600716017160271603716047160571606716077160871609716107161171612716137161471615716167161771618716197162071621716227162371624716257162671627716287162971630716317163271633716347163571636716377163871639716407164171642716437164471645716467164771648716497165071651716527165371654716557165671657716587165971660716617166271663716647166571666716677166871669716707167171672716737167471675716767167771678716797168071681716827168371684716857168671687716887168971690716917169271693716947169571696716977169871699717007170171702717037170471705717067170771708717097171071711717127171371714717157171671717717187171971720717217172271723717247172571726717277172871729717307173171732717337173471735717367173771738717397174071741717427174371744717457174671747717487174971750717517175271753717547175571756717577175871759717607176171762717637176471765717667176771768717697177071771717727177371774717757177671777717787177971780717817178271783717847178571786717877178871789717907179171792717937179471795717967179771798717997180071801718027180371804718057180671807718087180971810718117181271813718147181571816718177181871819718207182171822718237182471825718267182771828718297183071831718327183371834718357183671837718387183971840718417184271843718447184571846718477184871849718507185171852718537185471855718567185771858718597186071861718627186371864718657186671867718687186971870718717187271873718747187571876718777187871879718807188171882718837188471885718867188771888718897189071891718927189371894718957189671897718987189971900719017190271903719047190571906719077190871909719107191171912719137191471915719167191771918719197192071921719227192371924719257192671927719287192971930719317193271933719347193571936719377193871939719407194171942719437194471945719467194771948719497195071951719527195371954719557195671957719587195971960719617196271963719647196571966719677196871969719707197171972719737197471975719767197771978719797198071981719827198371984719857198671987719887198971990719917199271993719947199571996719977199871999720007200172002720037200472005720067200772008720097201072011720127201372014720157201672017720187201972020720217202272023720247202572026720277202872029720307203172032720337203472035720367203772038720397204072041720427204372044720457204672047720487204972050720517205272053720547205572056720577205872059720607206172062720637206472065720667206772068720697207072071720727207372074720757207672077720787207972080720817208272083720847208572086720877208872089720907209172092720937209472095720967209772098720997210072101721027210372104721057210672107721087210972110721117211272113721147211572116721177211872119721207212172122721237212472125721267212772128721297213072131721327213372134721357213672137721387213972140721417214272143721447214572146721477214872149721507215172152721537215472155721567215772158721597216072161721627216372164721657216672167721687216972170721717217272173721747217572176721777217872179721807218172182721837218472185721867218772188721897219072191721927219372194721957219672197721987219972200722017220272203722047220572206722077220872209722107221172212722137221472215722167221772218722197222072221722227222372224722257222672227722287222972230722317223272233722347223572236722377223872239722407224172242722437224472245722467224772248722497225072251722527225372254722557225672257722587225972260722617226272263722647226572266722677226872269722707227172272722737227472275722767227772278722797228072281722827228372284722857228672287722887228972290722917229272293722947229572296722977229872299723007230172302723037230472305723067230772308723097231072311723127231372314723157231672317723187231972320723217232272323723247232572326723277232872329723307233172332723337233472335723367233772338723397234072341723427234372344723457234672347723487234972350723517235272353723547235572356723577235872359723607236172362723637236472365723667236772368723697237072371723727237372374723757237672377723787237972380723817238272383723847238572386723877238872389723907239172392723937239472395723967239772398723997240072401724027240372404724057240672407724087240972410724117241272413724147241572416724177241872419724207242172422724237242472425724267242772428724297243072431724327243372434724357243672437724387243972440724417244272443724447244572446724477244872449724507245172452724537245472455724567245772458724597246072461724627246372464724657246672467724687246972470724717247272473724747247572476724777247872479724807248172482724837248472485724867248772488724897249072491724927249372494724957249672497724987249972500725017250272503725047250572506725077250872509725107251172512725137251472515725167251772518725197252072521725227252372524725257252672527725287252972530725317253272533725347253572536725377253872539725407254172542725437254472545725467254772548725497255072551725527255372554725557255672557725587255972560725617256272563725647256572566725677256872569725707257172572725737257472575725767257772578725797258072581725827258372584725857258672587725887258972590725917259272593725947259572596725977259872599726007260172602726037260472605726067260772608726097261072611726127261372614726157261672617726187261972620726217262272623726247262572626726277262872629726307263172632726337263472635726367263772638726397264072641726427264372644726457264672647726487264972650726517265272653726547265572656726577265872659726607266172662726637266472665726667266772668726697267072671726727267372674726757267672677726787267972680726817268272683726847268572686726877268872689726907269172692726937269472695726967269772698726997270072701727027270372704727057270672707727087270972710727117271272713727147271572716727177271872719727207272172722727237272472725727267272772728727297273072731727327273372734727357273672737727387273972740727417274272743727447274572746727477274872749727507275172752727537275472755727567275772758727597276072761727627276372764727657276672767727687276972770727717277272773727747277572776727777277872779727807278172782727837278472785727867278772788727897279072791727927279372794727957279672797727987279972800728017280272803728047280572806728077280872809728107281172812728137281472815728167281772818728197282072821728227282372824728257282672827728287282972830728317283272833728347283572836728377283872839728407284172842728437284472845728467284772848728497285072851728527285372854728557285672857728587285972860728617286272863728647286572866728677286872869728707287172872728737287472875728767287772878728797288072881728827288372884728857288672887728887288972890728917289272893728947289572896728977289872899729007290172902729037290472905729067290772908729097291072911729127291372914729157291672917729187291972920729217292272923729247292572926729277292872929729307293172932729337293472935729367293772938729397294072941729427294372944729457294672947729487294972950729517295272953729547295572956729577295872959729607296172962729637296472965729667296772968729697297072971729727297372974729757297672977729787297972980729817298272983729847298572986729877298872989729907299172992729937299472995729967299772998729997300073001730027300373004730057300673007730087300973010730117301273013730147301573016730177301873019730207302173022730237302473025730267302773028730297303073031730327303373034730357303673037730387303973040730417304273043730447304573046730477304873049730507305173052730537305473055730567305773058730597306073061730627306373064730657306673067730687306973070730717307273073730747307573076730777307873079730807308173082730837308473085730867308773088730897309073091730927309373094730957309673097730987309973100731017310273103731047310573106731077310873109731107311173112731137311473115731167311773118731197312073121731227312373124731257312673127731287312973130731317313273133731347313573136731377313873139731407314173142731437314473145731467314773148731497315073151731527315373154731557315673157731587315973160731617316273163731647316573166731677316873169731707317173172731737317473175731767317773178731797318073181731827318373184731857318673187731887318973190731917319273193731947319573196731977319873199732007320173202732037320473205732067320773208732097321073211732127321373214732157321673217732187321973220732217322273223732247322573226732277322873229732307323173232732337323473235732367323773238732397324073241732427324373244732457324673247732487324973250732517325273253732547325573256732577325873259732607326173262732637326473265732667326773268732697327073271732727327373274732757327673277732787327973280732817328273283732847328573286732877328873289732907329173292732937329473295732967329773298732997330073301733027330373304733057330673307733087330973310733117331273313733147331573316733177331873319733207332173322733237332473325733267332773328733297333073331733327333373334733357333673337733387333973340733417334273343733447334573346733477334873349733507335173352733537335473355733567335773358733597336073361733627336373364733657336673367733687336973370733717337273373733747337573376733777337873379733807338173382733837338473385733867338773388733897339073391733927339373394733957339673397733987339973400734017340273403734047340573406734077340873409734107341173412734137341473415734167341773418734197342073421734227342373424734257342673427734287342973430734317343273433734347343573436734377343873439734407344173442734437344473445734467344773448734497345073451734527345373454734557345673457734587345973460734617346273463734647346573466734677346873469734707347173472734737347473475734767347773478734797348073481734827348373484734857348673487734887348973490734917349273493734947349573496734977349873499735007350173502735037350473505735067350773508735097351073511735127351373514735157351673517735187351973520735217352273523735247352573526735277352873529735307353173532735337353473535735367353773538735397354073541735427354373544735457354673547735487354973550735517355273553735547355573556735577355873559735607356173562735637356473565735667356773568735697357073571735727357373574735757357673577735787357973580735817358273583735847358573586735877358873589735907359173592735937359473595735967359773598735997360073601736027360373604736057360673607736087360973610736117361273613736147361573616736177361873619736207362173622736237362473625736267362773628736297363073631736327363373634736357363673637736387363973640736417364273643736447364573646736477364873649736507365173652736537365473655736567365773658736597366073661736627366373664736657366673667736687366973670736717367273673736747367573676736777367873679736807368173682736837368473685736867368773688736897369073691736927369373694736957369673697736987369973700737017370273703737047370573706737077370873709737107371173712737137371473715737167371773718737197372073721737227372373724737257372673727737287372973730737317373273733737347373573736737377373873739737407374173742737437374473745737467374773748737497375073751737527375373754737557375673757737587375973760737617376273763737647376573766737677376873769737707377173772737737377473775737767377773778737797378073781737827378373784737857378673787737887378973790737917379273793737947379573796737977379873799738007380173802738037380473805738067380773808738097381073811738127381373814738157381673817738187381973820738217382273823738247382573826738277382873829738307383173832738337383473835738367383773838738397384073841738427384373844738457384673847738487384973850738517385273853738547385573856738577385873859738607386173862738637386473865738667386773868738697387073871738727387373874738757387673877738787387973880738817388273883738847388573886738877388873889738907389173892738937389473895738967389773898738997390073901739027390373904739057390673907739087390973910739117391273913739147391573916739177391873919739207392173922739237392473925739267392773928739297393073931739327393373934739357393673937739387393973940739417394273943739447394573946739477394873949739507395173952739537395473955739567395773958739597396073961739627396373964739657396673967739687396973970739717397273973739747397573976739777397873979739807398173982739837398473985739867398773988739897399073991739927399373994739957399673997739987399974000740017400274003740047400574006740077400874009740107401174012740137401474015740167401774018740197402074021740227402374024740257402674027740287402974030740317403274033740347403574036740377403874039740407404174042740437404474045740467404774048740497405074051740527405374054740557405674057740587405974060740617406274063740647406574066740677406874069740707407174072740737407474075740767407774078740797408074081740827408374084740857408674087740887408974090740917409274093740947409574096740977409874099741007410174102741037410474105741067410774108741097411074111741127411374114741157411674117741187411974120741217412274123741247412574126741277412874129741307413174132741337413474135741367413774138741397414074141741427414374144741457414674147741487414974150741517415274153741547415574156741577415874159741607416174162741637416474165741667416774168741697417074171741727417374174741757417674177741787417974180741817418274183741847418574186741877418874189741907419174192741937419474195741967419774198741997420074201742027420374204742057420674207742087420974210742117421274213742147421574216742177421874219742207422174222742237422474225742267422774228742297423074231742327423374234742357423674237742387423974240742417424274243742447424574246742477424874249742507425174252742537425474255742567425774258742597426074261742627426374264742657426674267742687426974270742717427274273742747427574276742777427874279742807428174282742837428474285742867428774288742897429074291742927429374294742957429674297742987429974300743017430274303743047430574306743077430874309743107431174312743137431474315743167431774318743197432074321743227432374324743257432674327743287432974330743317433274333743347433574336743377433874339743407434174342743437434474345743467434774348743497435074351743527435374354743557435674357743587435974360743617436274363743647436574366743677436874369743707437174372743737437474375743767437774378743797438074381743827438374384743857438674387743887438974390743917439274393743947439574396743977439874399744007440174402744037440474405744067440774408744097441074411744127441374414744157441674417744187441974420744217442274423744247442574426744277442874429744307443174432744337443474435744367443774438744397444074441744427444374444744457444674447744487444974450744517445274453744547445574456744577445874459744607446174462744637446474465744667446774468744697447074471744727447374474744757447674477744787447974480744817448274483744847448574486744877448874489744907449174492744937449474495744967449774498744997450074501745027450374504745057450674507745087450974510745117451274513745147451574516745177451874519745207452174522745237452474525745267452774528745297453074531745327453374534745357453674537745387453974540745417454274543745447454574546745477454874549745507455174552745537455474555745567455774558745597456074561745627456374564745657456674567745687456974570745717457274573745747457574576745777457874579745807458174582745837458474585745867458774588745897459074591745927459374594745957459674597745987459974600746017460274603746047460574606746077460874609746107461174612746137461474615746167461774618746197462074621746227462374624746257462674627746287462974630746317463274633746347463574636746377463874639746407464174642746437464474645746467464774648746497465074651746527465374654746557465674657746587465974660746617466274663746647466574666746677466874669746707467174672746737467474675746767467774678746797468074681746827468374684746857468674687746887468974690746917469274693746947469574696746977469874699747007470174702747037470474705747067470774708747097471074711747127471374714747157471674717747187471974720747217472274723747247472574726747277472874729747307473174732747337473474735747367473774738747397474074741747427474374744747457474674747747487474974750747517475274753747547475574756747577475874759747607476174762747637476474765747667476774768747697477074771747727477374774747757477674777747787477974780747817478274783747847478574786747877478874789747907479174792747937479474795747967479774798747997480074801748027480374804748057480674807748087480974810748117481274813748147481574816748177481874819748207482174822748237482474825748267482774828748297483074831748327483374834748357483674837748387483974840748417484274843748447484574846748477484874849748507485174852748537485474855748567485774858748597486074861748627486374864748657486674867748687486974870748717487274873748747487574876748777487874879748807488174882748837488474885748867488774888748897489074891748927489374894748957489674897748987489974900749017490274903749047490574906749077490874909749107491174912749137491474915749167491774918749197492074921749227492374924749257492674927749287492974930749317493274933749347493574936749377493874939749407494174942749437494474945749467494774948749497495074951749527495374954749557495674957749587495974960749617496274963749647496574966749677496874969749707497174972749737497474975749767497774978749797498074981749827498374984749857498674987749887498974990749917499274993749947499574996749977499874999750007500175002750037500475005750067500775008750097501075011750127501375014750157501675017750187501975020750217502275023750247502575026750277502875029750307503175032750337503475035750367503775038750397504075041750427504375044750457504675047750487504975050750517505275053750547505575056750577505875059750607506175062750637506475065750667506775068750697507075071750727507375074750757507675077750787507975080750817508275083750847508575086750877508875089750907509175092750937509475095750967509775098750997510075101751027510375104751057510675107751087510975110751117511275113751147511575116751177511875119751207512175122751237512475125751267512775128751297513075131751327513375134751357513675137751387513975140751417514275143751447514575146751477514875149751507515175152751537515475155751567515775158751597516075161751627516375164751657516675167751687516975170751717517275173751747517575176751777517875179751807518175182751837518475185751867518775188751897519075191751927519375194751957519675197751987519975200752017520275203752047520575206752077520875209752107521175212752137521475215752167521775218752197522075221752227522375224752257522675227752287522975230752317523275233752347523575236752377523875239752407524175242752437524475245752467524775248752497525075251752527525375254752557525675257752587525975260752617526275263752647526575266752677526875269752707527175272752737527475275752767527775278752797528075281752827528375284752857528675287752887528975290752917529275293752947529575296752977529875299753007530175302753037530475305753067530775308753097531075311753127531375314753157531675317753187531975320753217532275323753247532575326753277532875329753307533175332753337533475335753367533775338753397534075341753427534375344753457534675347753487534975350753517535275353753547535575356753577535875359753607536175362753637536475365753667536775368753697537075371753727537375374753757537675377753787537975380753817538275383753847538575386753877538875389753907539175392753937539475395753967539775398753997540075401754027540375404754057540675407754087540975410754117541275413754147541575416754177541875419754207542175422754237542475425754267542775428754297543075431754327543375434754357543675437754387543975440754417544275443754447544575446754477544875449754507545175452754537545475455754567545775458754597546075461754627546375464754657546675467754687546975470754717547275473754747547575476754777547875479754807548175482754837548475485754867548775488754897549075491754927549375494754957549675497754987549975500755017550275503755047550575506755077550875509755107551175512755137551475515755167551775518755197552075521755227552375524755257552675527755287552975530755317553275533755347553575536755377553875539755407554175542755437554475545755467554775548755497555075551755527555375554755557555675557755587555975560755617556275563755647556575566755677556875569755707557175572755737557475575755767557775578755797558075581755827558375584755857558675587755887558975590755917559275593755947559575596755977559875599756007560175602756037560475605756067560775608756097561075611756127561375614756157561675617756187561975620756217562275623756247562575626756277562875629756307563175632756337563475635756367563775638756397564075641756427564375644756457564675647756487564975650756517565275653756547565575656756577565875659756607566175662756637566475665756667566775668756697567075671756727567375674756757567675677756787567975680756817568275683756847568575686756877568875689756907569175692756937569475695756967569775698756997570075701757027570375704757057570675707757087570975710757117571275713757147571575716757177571875719757207572175722757237572475725757267572775728757297573075731757327573375734757357573675737757387573975740757417574275743757447574575746757477574875749757507575175752757537575475755757567575775758757597576075761757627576375764757657576675767757687576975770757717577275773757747577575776757777577875779757807578175782757837578475785757867578775788757897579075791757927579375794757957579675797757987579975800758017580275803758047580575806758077580875809758107581175812758137581475815758167581775818758197582075821758227582375824758257582675827758287582975830758317583275833758347583575836758377583875839758407584175842758437584475845758467584775848758497585075851758527585375854758557585675857758587585975860758617586275863758647586575866758677586875869758707587175872758737587475875758767587775878758797588075881758827588375884758857588675887758887588975890758917589275893758947589575896758977589875899759007590175902759037590475905759067590775908759097591075911759127591375914759157591675917759187591975920759217592275923759247592575926759277592875929759307593175932759337593475935759367593775938759397594075941759427594375944759457594675947759487594975950759517595275953759547595575956759577595875959759607596175962759637596475965759667596775968759697597075971759727597375974759757597675977759787597975980759817598275983759847598575986759877598875989759907599175992759937599475995759967599775998759997600076001760027600376004760057600676007760087600976010760117601276013760147601576016760177601876019760207602176022760237602476025760267602776028760297603076031760327603376034760357603676037760387603976040760417604276043760447604576046760477604876049760507605176052760537605476055760567605776058760597606076061760627606376064760657606676067760687606976070760717607276073760747607576076760777607876079760807608176082760837608476085760867608776088760897609076091760927609376094760957609676097760987609976100761017610276103761047610576106761077610876109761107611176112761137611476115761167611776118761197612076121761227612376124761257612676127761287612976130761317613276133761347613576136761377613876139761407614176142761437614476145761467614776148761497615076151761527615376154761557615676157761587615976160761617616276163761647616576166761677616876169761707617176172761737617476175761767617776178761797618076181761827618376184761857618676187761887618976190761917619276193761947619576196761977619876199762007620176202762037620476205762067620776208762097621076211762127621376214762157621676217762187621976220762217622276223762247622576226762277622876229762307623176232762337623476235762367623776238762397624076241762427624376244762457624676247762487624976250762517625276253762547625576256762577625876259762607626176262762637626476265762667626776268762697627076271762727627376274762757627676277762787627976280762817628276283762847628576286762877628876289762907629176292762937629476295762967629776298762997630076301763027630376304763057630676307763087630976310763117631276313763147631576316763177631876319763207632176322763237632476325763267632776328763297633076331763327633376334763357633676337763387633976340763417634276343763447634576346763477634876349763507635176352763537635476355763567635776358763597636076361763627636376364763657636676367763687636976370763717637276373763747637576376763777637876379763807638176382763837638476385763867638776388763897639076391763927639376394763957639676397763987639976400764017640276403764047640576406764077640876409764107641176412764137641476415764167641776418764197642076421764227642376424764257642676427764287642976430764317643276433764347643576436764377643876439764407644176442764437644476445764467644776448764497645076451764527645376454764557645676457764587645976460764617646276463764647646576466764677646876469764707647176472764737647476475764767647776478764797648076481764827648376484764857648676487764887648976490764917649276493764947649576496764977649876499765007650176502765037650476505765067650776508765097651076511765127651376514765157651676517765187651976520765217652276523765247652576526765277652876529765307653176532765337653476535765367653776538765397654076541765427654376544765457654676547765487654976550765517655276553765547655576556765577655876559765607656176562765637656476565765667656776568765697657076571765727657376574765757657676577765787657976580765817658276583765847658576586765877658876589765907659176592765937659476595765967659776598765997660076601766027660376604766057660676607766087660976610766117661276613766147661576616766177661876619766207662176622766237662476625766267662776628766297663076631766327663376634766357663676637766387663976640766417664276643766447664576646766477664876649766507665176652766537665476655766567665776658766597666076661766627666376664766657666676667766687666976670766717667276673766747667576676766777667876679766807668176682766837668476685766867668776688766897669076691766927669376694766957669676697766987669976700767017670276703767047670576706767077670876709767107671176712767137671476715767167671776718767197672076721767227672376724767257672676727767287672976730767317673276733767347673576736767377673876739767407674176742767437674476745767467674776748767497675076751767527675376754767557675676757767587675976760767617676276763767647676576766767677676876769767707677176772767737677476775767767677776778767797678076781767827678376784767857678676787767887678976790767917679276793767947679576796767977679876799768007680176802768037680476805768067680776808768097681076811768127681376814768157681676817768187681976820768217682276823 |
- /**
- * Moralis JavaScript SDK v1.5.9
- *
- * The source tree of this library can be found at
- * https://github.com/MoralisWeb3/Moralis-JS-SDK
- */
- (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Moralis = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(_dereq_,module,exports){
- "use strict";
- var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
- var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
- _Object$defineProperty(exports, "__esModule", {
- value: true
- });
- exports.track = track;
- var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
- /**
- * Copyright (c) 2015-present, Parse, LLC.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- *
- * @flow
- */
- /**
- * Parse.Analytics provides an interface to Parse's logging and analytics
- * backend.
- *
- * @class Parse.Analytics
- * @static
- * @hideconstructor
- */
- /**
- * Tracks the occurrence of a custom event with additional dimensions.
- * Parse will store a data point at the time of invocation with the given
- * event name.
- *
- * Dimensions will allow segmentation of the occurrences of this custom
- * event. Keys and values should be {@code String}s, and will throw
- * otherwise.
- *
- * To track a user signup along with additional metadata, consider the
- * following:
- * <pre>
- * var dimensions = {
- * gender: 'm',
- * source: 'web',
- * dayType: 'weekend'
- * };
- * Parse.Analytics.track('signup', dimensions);
- * </pre>
- *
- * There is a default limit of 8 dimensions per event tracked.
- *
- * @function track
- * @name Parse.Analytics.track
- * @param {string} name The name of the custom event to report to Parse as
- * having happened.
- * @param {object} dimensions The dictionary of information by which to
- * segment this event.
- * @returns {Promise} A promise that is resolved when the round-trip
- * to the server completes.
- */
- function track(name
- /*: string*/
- , dimensions
- /*: { [key: string]: string }*/
- )
- /*: Promise*/
- {
- name = name || '';
- name = name.replace(/^\s*/, '');
- name = name.replace(/\s*$/, '');
- if (name.length === 0) {
- throw new TypeError('A name for the custom event must be provided');
- }
- for (var _key in dimensions) {
- if (typeof _key !== 'string' || typeof dimensions[_key] !== 'string') {
- throw new TypeError('track() dimensions expects keys and values of type "string".');
- }
- }
- return _CoreManager.default.getAnalyticsController().track(name, dimensions);
- }
- var DefaultController = {
- track: function (name, dimensions) {
- var path = "events/".concat(name);
- var RESTController = _CoreManager.default.getRESTController();
- return RESTController.request('POST', path, {
- dimensions: dimensions
- });
- }
- };
- _CoreManager.default.setAnalyticsController(DefaultController);
- },{"./CoreManager":5,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/helpers/interopRequireDefault":152}],2:[function(_dereq_,module,exports){
- "use strict";
- var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
- var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
- _Object$defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = void 0;
- var _ParseUser = _interopRequireDefault(_dereq_("./ParseUser"));
- /**
- * Copyright (c) 2015-present, Parse, LLC.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- *
- * @flow-weak
- */
- var _require = _dereq_('uuid'),
- uuidv4 = _require.v4;
- var registered = false;
- /**
- * Provides utility functions for working with Anonymously logged-in users. <br />
- * Anonymous users have some unique characteristics:
- * <ul>
- * <li>Anonymous users don't need a user name or password.</li>
- * <ul>
- * <li>Once logged out, an anonymous user cannot be recovered.</li>
- * </ul>
- * <li>signUp converts an anonymous user to a standard user with the given username and password.</li>
- * <ul>
- * <li>Data associated with the anonymous user is retained.</li>
- * </ul>
- * <li>logIn switches users without converting the anonymous user.</li>
- * <ul>
- * <li>Data associated with the anonymous user will be lost.</li>
- * </ul>
- * <li>Service logIn (e.g. Facebook, Twitter) will attempt to convert
- * the anonymous user into a standard user by linking it to the service.</li>
- * <ul>
- * <li>If a user already exists that is linked to the service, it will instead switch to the existing user.</li>
- * </ul>
- * <li>Service linking (e.g. Facebook, Twitter) will convert the anonymous user
- * into a standard user by linking it to the service.</li>
- * </ul>
- *
- * @class Parse.AnonymousUtils
- * @static
- */
- var AnonymousUtils = {
- /**
- * Gets whether the user has their account linked to anonymous user.
- *
- * @function isLinked
- * @name Parse.AnonymousUtils.isLinked
- * @param {Parse.User} user User to check for.
- * The user must be logged in on this device.
- * @returns {boolean} <code>true</code> if the user has their account
- * linked to an anonymous user.
- * @static
- */
- isLinked: function (user
- /*: ParseUser*/
- ) {
- var provider = this._getAuthProvider();
- return user._isLinked(provider.getAuthType());
- },
- /**
- * Logs in a user Anonymously.
- *
- * @function logIn
- * @name Parse.AnonymousUtils.logIn
- * @param {object} options MasterKey / SessionToken.
- * @returns {Promise} Logged in user
- * @static
- */
- logIn: function (options
- /*:: ?: RequestOptions*/
- )
- /*: Promise<ParseUser>*/
- {
- var provider = this._getAuthProvider();
- return _ParseUser.default.logInWith(provider.getAuthType(), provider.getAuthData(), options);
- },
- /**
- * Links Anonymous User to an existing PFUser.
- *
- * @function link
- * @name Parse.AnonymousUtils.link
- * @param {Parse.User} user User to link. This must be the current user.
- * @param {object} options MasterKey / SessionToken.
- * @returns {Promise} Linked with User
- * @static
- */
- link: function (user
- /*: ParseUser*/
- , options
- /*:: ?: RequestOptions*/
- )
- /*: Promise<ParseUser>*/
- {
- var provider = this._getAuthProvider();
- return user.linkWith(provider.getAuthType(), provider.getAuthData(), options);
- },
- _getAuthProvider: function () {
- var provider = {
- restoreAuthentication: function () {
- return true;
- },
- getAuthType: function () {
- return 'anonymous';
- },
- getAuthData: function () {
- return {
- authData: {
- id: uuidv4()
- }
- };
- }
- };
- if (!registered) {
- _ParseUser.default._registerAuthenticationProvider(provider);
- registered = true;
- }
- return provider;
- }
- };
- var _default = AnonymousUtils;
- exports.default = _default;
- },{"./ParseUser":44,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"uuid":797}],3:[function(_dereq_,module,exports){
- "use strict";
- var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
- _Object$defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = void 0;
- var Chains = {
- ETH_MAINENT: '0x1',
- ETH_ROPSTEN: '0x3',
- ETH_GOERLI: '0x5',
- ETH_KOVAN: '0x2a',
- ETH_RINKBEY: '0x4',
- ETH_LOCALDEVCHAIN: '0x539',
- POLYGON_MAINNET: '0x89',
- POLYGON_MUMBAI: '0x13881',
- BSC_MAINNET: '0x38',
- BSC_TESTNET: '0x61',
- AVAX_MAINNET: '0xa86a',
- AVAX_TESTNET: '0xa869',
- FANTOM_MAINNET: '0xfa'
- };
- var _default = Chains;
- exports.default = _default;
- },{"@babel/runtime-corejs3/core-js-stable/object/define-property":105}],4:[function(_dereq_,module,exports){
- "use strict";
- var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
- var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
- _Object$defineProperty(exports, "__esModule", {
- value: true
- });
- exports.getJobStatus = getJobStatus;
- exports.getJobsData = getJobsData;
- exports.run = run;
- exports.startJob = startJob;
- var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/keys"));
- var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
- var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
- var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
- var _decode = _interopRequireDefault(_dereq_("./decode"));
- var _encode = _interopRequireDefault(_dereq_("./encode"));
- var _ParseError = _interopRequireDefault(_dereq_("./ParseError"));
- var _ParseQuery = _interopRequireDefault(_dereq_("./ParseQuery"));
- var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
- /**
- * Copyright (c) 2015-present, Parse, LLC.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- *
- * @flow
- */
- /**
- * Contains functions for calling and declaring
- * <a href="/docs/cloud_code_guide#functions">cloud functions</a>.
- * <p><strong><em>
- * Some functions are only available from Cloud Code.
- * </em></strong></p>
- *
- * @class Parse.Cloud
- * @static
- * @hideconstructor
- */
- /**
- * Makes a call to a cloud function.
- *
- * @function run
- * @name Parse.Cloud.run
- * @param {string} name The function name.
- * @param {object} data The parameters to send to the cloud function.
- * @param {object} options
- * @returns {Promise} A promise that will be resolved with the result
- * of the function.
- */
- function run(name
- /*: string*/
- , data
- /*: mixed*/
- , options
- /*: RequestOptions*/
- )
- /*: Promise<mixed>*/
- {
- options = options || {};
- if (typeof name !== 'string' || name.length === 0) {
- throw new TypeError('Cloud function name must be a string.');
- }
- var requestOptions = {};
- if (options.useMasterKey) {
- requestOptions.useMasterKey = options.useMasterKey;
- }
- if (options.sessionToken) {
- requestOptions.sessionToken = options.sessionToken;
- }
- if (options.context && (0, _typeof2.default)(options.context) === 'object') {
- requestOptions.context = options.context;
- }
- return _CoreManager.default.getCloudController().run(name, data, requestOptions);
- }
- /**
- * Gets data for the current set of cloud jobs.
- *
- * @function getJobsData
- * @name Parse.Cloud.getJobsData
- * @returns {Promise} A promise that will be resolved with the result
- * of the function.
- */
- function getJobsData()
- /*: Promise<Object>*/
- {
- return _CoreManager.default.getCloudController().getJobsData({
- useMasterKey: true
- });
- }
- /**
- * Starts a given cloud job, which will process asynchronously.
- *
- * @function startJob
- * @name Parse.Cloud.startJob
- * @param {string} name The function name.
- * @param {object} data The parameters to send to the cloud function.
- * @returns {Promise} A promise that will be resolved with the jobStatusId
- * of the job.
- */
- function startJob(name
- /*: string*/
- , data
- /*: mixed*/
- )
- /*: Promise<string>*/
- {
- if (typeof name !== 'string' || name.length === 0) {
- throw new TypeError('Cloud job name must be a string.');
- }
- return _CoreManager.default.getCloudController().startJob(name, data, {
- useMasterKey: true
- });
- }
- /**
- * Gets job status by Id
- *
- * @function getJobStatus
- * @name Parse.Cloud.getJobStatus
- * @param {string} jobStatusId The Id of Job Status.
- * @returns {Parse.Object} Status of Job.
- */
- function getJobStatus(jobStatusId
- /*: string*/
- )
- /*: Promise<ParseObject>*/
- {
- var query = new _ParseQuery.default('_JobStatus');
- return query.get(jobStatusId, {
- useMasterKey: true
- });
- }
- var DefaultController = {
- run: function (name, data, options
- /*: RequestOptions*/
- ) {
- var RESTController = _CoreManager.default.getRESTController();
- var payload = (0, _encode.default)(data, true);
- var request = RESTController.request('POST', "functions/".concat(name), payload, options);
- return request.then(function (res) {
- if ((0, _typeof2.default)(res) === 'object' && (0, _keys.default)(res).length > 0 && !res.hasOwnProperty('result')) {
- throw new _ParseError.default(_ParseError.default.INVALID_JSON, 'The server returned an invalid response.');
- }
- var decoded = (0, _decode.default)(res);
- if (decoded && decoded.hasOwnProperty('result')) {
- return _promise.default.resolve(decoded.result);
- }
- return _promise.default.resolve(undefined);
- });
- },
- getJobsData: function (options
- /*: RequestOptions*/
- ) {
- var RESTController = _CoreManager.default.getRESTController();
- return RESTController.request('GET', 'cloud_code/jobs/data', null, options);
- },
- startJob: function (name, data, options
- /*: RequestOptions*/
- ) {
- var RESTController = _CoreManager.default.getRESTController();
- var payload = (0, _encode.default)(data, true);
- return RESTController.request('POST', "jobs/".concat(name), payload, options);
- }
- };
- _CoreManager.default.setCloudController(DefaultController);
- },{"./CoreManager":5,"./ParseError":29,"./ParseObject":36,"./ParseQuery":39,"./decode":65,"./encode":66,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/core-js-stable/object/keys":112,"@babel/runtime-corejs3/core-js-stable/promise":115,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/helpers/typeof":164}],5:[function(_dereq_,module,exports){
- (function (process){(function (){
- "use strict";
- var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
- var _forEach = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
- var _concat = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/concat"));
- /*
- * Copyright (c) 2015-present, Parse, LLC.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- *
- * @flow
- */
- /*:: import type { AttributeMap, ObjectCache, OpsMap, State } from './ObjectStateMutations';*/
- /*:: import type ParseFile from './ParseFile';*/
- /*:: import type { FileSource } from './ParseFile';*/
- /*:: import type { Op } from './ParseOp';*/
- /*:: import type ParseObject from './ParseObject';*/
- /*:: import type { QueryJSON } from './ParseQuery';*/
- /*:: import type ParseUser from './ParseUser';*/
- /*:: import type { AuthData } from './ParseUser';*/
- /*:: import type { PushData } from './Push';*/
- /*:: import type { RequestOptions, FullOptions } from './RESTController';*/
- /*:: type AnalyticsController = {
- track: (name: string, dimensions: { [key: string]: string }) => Promise,
- };*/
- /*:: type CloudController = {
- run: (name: string, data: mixed, options: RequestOptions) => Promise,
- getJobsData: (options: RequestOptions) => Promise,
- startJob: (name: string, data: mixed, options: RequestOptions) => Promise,
- };*/
- /*:: type ConfigController = {
- current: () => Promise,
- get: () => Promise,
- save: (attrs: { [key: string]: any }) => Promise,
- };*/
- /*:: type CryptoController = {
- encrypt: (obj: any, secretKey: string) => string,
- decrypt: (encryptedText: string, secretKey: any) => string,
- };*/
- /*:: type FileController = {
- saveFile: (name: string, source: FileSource, options: FullOptions) => Promise,
- saveBase64: (name: string, source: FileSource, options: FullOptions) => Promise,
- download: (uri: string) => Promise,
- };*/
- /*:: type InstallationController = {
- currentInstallationId: () => Promise,
- };*/
- /*:: type ObjectController = {
- fetch: (
- object: ParseObject | Array<ParseObject>,
- forceFetch: boolean,
- options: RequestOptions
- ) => Promise,
- save: (object: ParseObject | Array<ParseObject | ParseFile>, options: RequestOptions) => Promise,
- destroy: (object: ParseObject | Array<ParseObject>, options: RequestOptions) => Promise,
- };*/
- /*:: type ObjectStateController = {
- getState: (obj: any) => ?State,
- initializeState: (obj: any, initial?: State) => State,
- removeState: (obj: any) => ?State,
- getServerData: (obj: any) => AttributeMap,
- setServerData: (obj: any, attributes: AttributeMap) => void,
- getPendingOps: (obj: any) => Array<OpsMap>,
- setPendingOp: (obj: any, attr: string, op: ?Op) => void,
- pushPendingState: (obj: any) => void,
- popPendingState: (obj: any) => OpsMap,
- mergeFirstPendingState: (obj: any) => void,
- getObjectCache: (obj: any) => ObjectCache,
- estimateAttribute: (obj: any, attr: string) => mixed,
- estimateAttributes: (obj: any) => AttributeMap,
- commitServerChanges: (obj: any, changes: AttributeMap) => void,
- enqueueTask: (obj: any, task: () => Promise) => Promise,
- clearAllState: () => void,
- duplicateState: (source: any, dest: any) => void,
- };*/
- /*:: type PushController = {
- send: (data: PushData) => Promise,
- };*/
- /*:: type QueryController = {
- find: (className: string, params: QueryJSON, options: RequestOptions) => Promise,
- aggregate: (className: string, params: any, options: RequestOptions) => Promise,
- };*/
- /*:: type RESTController = {
- request: (method: string, path: string, data: mixed, options: RequestOptions) => Promise,
- ajax: (method: string, url: string, data: any, headers?: any, options: FullOptions) => Promise,
- };*/
- /*:: type SchemaController = {
- purge: (className: string) => Promise,
- get: (className: string, options: RequestOptions) => Promise,
- delete: (className: string, options: RequestOptions) => Promise,
- create: (className: string, params: any, options: RequestOptions) => Promise,
- update: (className: string, params: any, options: RequestOptions) => Promise,
- send(className: string, method: string, params: any, options: RequestOptions): Promise,
- };*/
- /*:: type SessionController = {
- getSession: (token: RequestOptions) => Promise,
- };*/
- /*:: type StorageController =
- | {
- async: 0,
- getItem: (path: string) => ?string,
- setItem: (path: string, value: string) => void,
- removeItem: (path: string) => void,
- getItemAsync?: (path: string) => Promise,
- setItemAsync?: (path: string, value: string) => Promise,
- removeItemAsync?: (path: string) => Promise,
- clear: () => void,
- }
- | {
- async: 1,
- getItem?: (path: string) => ?string,
- setItem?: (path: string, value: string) => void,
- removeItem?: (path: string) => void,
- getItemAsync: (path: string) => Promise,
- setItemAsync: (path: string, value: string) => Promise,
- removeItemAsync: (path: string) => Promise,
- clear: () => void,
- };*/
- /*:: type LocalDatastoreController = {
- fromPinWithName: (name: string) => ?any,
- pinWithName: (name: string, objects: any) => void,
- unPinWithName: (name: string) => void,
- getAllContents: () => ?any,
- clear: () => void,
- };*/
- /*:: type UserController = {
- setCurrentUser: (user: ParseUser) => Promise,
- currentUser: () => ?ParseUser,
- currentUserAsync: () => Promise,
- signUp: (user: ParseUser, attrs: AttributeMap, options: RequestOptions) => Promise,
- logIn: (user: ParseUser, options: RequestOptions) => Promise,
- become: (options: RequestOptions) => Promise,
- hydrate: (userJSON: AttributeMap) => Promise,
- logOut: (options: RequestOptions) => Promise,
- me: (options: RequestOptions) => Promise,
- requestPasswordReset: (email: string, options: RequestOptions) => Promise,
- updateUserOnDisk: (user: ParseUser) => Promise,
- upgradeToRevocableSession: (user: ParseUser, options: RequestOptions) => Promise,
- linkWith: (user: ParseUser, authData: AuthData) => Promise,
- removeUserFromDisk: () => Promise,
- verifyPassword: (username: string, password: string, options: RequestOptions) => Promise,
- requestEmailVerification: (email: string, options: RequestOptions) => Promise,
- };*/
- /*:: type HooksController = {
- get: (type: string, functionName?: string, triggerName?: string) => Promise,
- create: (hook: mixed) => Promise,
- delete: (hook: mixed) => Promise,
- update: (hook: mixed) => Promise,
- send: (method: string, path: string, body?: mixed) => Promise,
- };*/
- /*:: type WebSocketController = {
- onopen: () => void,
- onmessage: (message: any) => void,
- onclose: () => void,
- onerror: (error: any) => void,
- send: (data: any) => void,
- close: () => void,
- };*/
- /*:: type Config = {
- AnalyticsController?: AnalyticsController,
- CloudController?: CloudController,
- ConfigController?: ConfigController,
- FileController?: FileController,
- InstallationController?: InstallationController,
- ObjectController?: ObjectController,
- ObjectStateController?: ObjectStateController,
- PushController?: PushController,
- QueryController?: QueryController,
- RESTController?: RESTController,
- SchemaController?: SchemaController,
- SessionController?: SessionController,
- StorageController?: StorageController,
- LocalDatastoreController?: LocalDatastoreController,
- UserController?: UserController,
- HooksController?: HooksController,
- WebSocketController?: WebSocketController,
- };*/
- var config
- /*: Config & { [key: string]: mixed }*/
- = {
- // Defaults
- IS_NODE: typeof process !== 'undefined' && !!process.versions && !!process.versions.node && !process.versions.electron,
- REQUEST_ATTEMPT_LIMIT: 5,
- REQUEST_BATCH_SIZE: 20,
- REQUEST_HEADERS: {},
- SERVER_URL: 'https://api.parse.com/1',
- SERVER_AUTH_TYPE: null,
- SERVER_AUTH_TOKEN: null,
- LIVEQUERY_SERVER_URL: null,
- ENCRYPTED_KEY: null,
- VERSION: "js".concat("1.5.9"),
- APPLICATION_ID: null,
- JAVASCRIPT_KEY: null,
- MASTER_KEY: null,
- USE_MASTER_KEY: false,
- PERFORM_USER_REWRITE: true,
- FORCE_REVOCABLE_SESSION: false,
- ENCRYPTED_USER: false,
- IDEMPOTENCY: false
- };
- function requireMethods(name
- /*: string*/
- , methods
- /*: Array<string>*/
- , controller
- /*: any*/
- ) {
- (0, _forEach.default)(methods).call(methods, function (func) {
- if (typeof controller[func] !== 'function') {
- var _context;
- throw new Error((0, _concat.default)(_context = "".concat(name, " must implement ")).call(_context, func, "()"));
- }
- });
- }
- module.exports = {
- get: function (key
- /*: string*/
- )
- /*: any*/
- {
- if (config.hasOwnProperty(key)) {
- return config[key];
- }
- throw new Error("Configuration key not found: ".concat(key));
- },
- set: function (key
- /*: string*/
- , value
- /*: any*/
- )
- /*: void*/
- {
- config[key] = value;
- },
- /* Specialized Controller Setters/Getters */
- setAnalyticsController: function (controller
- /*: AnalyticsController*/
- ) {
- requireMethods('AnalyticsController', ['track'], controller);
- config.AnalyticsController = controller;
- },
- getAnalyticsController: function ()
- /*: AnalyticsController*/
- {
- return config.AnalyticsController;
- },
- setCloudController: function (controller
- /*: CloudController*/
- ) {
- requireMethods('CloudController', ['run', 'getJobsData', 'startJob'], controller);
- config.CloudController = controller;
- },
- getCloudController: function ()
- /*: CloudController*/
- {
- return config.CloudController;
- },
- setConfigController: function (controller
- /*: ConfigController*/
- ) {
- requireMethods('ConfigController', ['current', 'get', 'save'], controller);
- config.ConfigController = controller;
- },
- getConfigController: function ()
- /*: ConfigController*/
- {
- return config.ConfigController;
- },
- setCryptoController: function (controller
- /*: CryptoController*/
- ) {
- requireMethods('CryptoController', ['encrypt', 'decrypt'], controller);
- config.CryptoController = controller;
- },
- getCryptoController: function ()
- /*: CryptoController*/
- {
- return config.CryptoController;
- },
- setFileController: function (controller
- /*: FileController*/
- ) {
- requireMethods('FileController', ['saveFile', 'saveBase64'], controller);
- config.FileController = controller;
- },
- getFileController: function ()
- /*: FileController*/
- {
- return config.FileController;
- },
- setInstallationController: function (controller
- /*: InstallationController*/
- ) {
- requireMethods('InstallationController', ['currentInstallationId'], controller);
- config.InstallationController = controller;
- },
- getInstallationController: function ()
- /*: InstallationController*/
- {
- return config.InstallationController;
- },
- setObjectController: function (controller
- /*: ObjectController*/
- ) {
- requireMethods('ObjectController', ['save', 'fetch', 'destroy'], controller);
- config.ObjectController = controller;
- },
- getObjectController: function ()
- /*: ObjectController*/
- {
- return config.ObjectController;
- },
- setObjectStateController: function (controller
- /*: ObjectStateController*/
- ) {
- requireMethods('ObjectStateController', ['getState', 'initializeState', 'removeState', 'getServerData', 'setServerData', 'getPendingOps', 'setPendingOp', 'pushPendingState', 'popPendingState', 'mergeFirstPendingState', 'getObjectCache', 'estimateAttribute', 'estimateAttributes', 'commitServerChanges', 'enqueueTask', 'clearAllState'], controller);
- config.ObjectStateController = controller;
- },
- getObjectStateController: function ()
- /*: ObjectStateController*/
- {
- return config.ObjectStateController;
- },
- setPushController: function (controller
- /*: PushController*/
- ) {
- requireMethods('PushController', ['send'], controller);
- config.PushController = controller;
- },
- getPushController: function ()
- /*: PushController*/
- {
- return config.PushController;
- },
- setQueryController: function (controller
- /*: QueryController*/
- ) {
- requireMethods('QueryController', ['find', 'aggregate'], controller);
- config.QueryController = controller;
- },
- getQueryController: function ()
- /*: QueryController*/
- {
- return config.QueryController;
- },
- setRESTController: function (controller
- /*: RESTController*/
- ) {
- requireMethods('RESTController', ['request', 'ajax'], controller);
- config.RESTController = controller;
- },
- getRESTController: function ()
- /*: RESTController*/
- {
- return config.RESTController;
- },
- setSchemaController: function (controller
- /*: SchemaController*/
- ) {
- requireMethods('SchemaController', ['get', 'create', 'update', 'delete', 'send', 'purge'], controller);
- config.SchemaController = controller;
- },
- getSchemaController: function ()
- /*: SchemaController*/
- {
- return config.SchemaController;
- },
- setSessionController: function (controller
- /*: SessionController*/
- ) {
- requireMethods('SessionController', ['getSession'], controller);
- config.SessionController = controller;
- },
- getSessionController: function ()
- /*: SessionController*/
- {
- return config.SessionController;
- },
- setStorageController: function (controller
- /*: StorageController*/
- ) {
- if (controller.async) {
- requireMethods('An async StorageController', ['getItemAsync', 'setItemAsync', 'removeItemAsync', 'getAllKeysAsync'], controller);
- } else {
- requireMethods('A synchronous StorageController', ['getItem', 'setItem', 'removeItem', 'getAllKeys'], controller);
- }
- config.StorageController = controller;
- },
- setLocalDatastoreController: function (controller
- /*: LocalDatastoreController*/
- ) {
- requireMethods('LocalDatastoreController', ['pinWithName', 'fromPinWithName', 'unPinWithName', 'getAllContents', 'clear'], controller);
- config.LocalDatastoreController = controller;
- },
- getLocalDatastoreController: function ()
- /*: LocalDatastoreController*/
- {
- return config.LocalDatastoreController;
- },
- setLocalDatastore: function (store
- /*: any*/
- ) {
- config.LocalDatastore = store;
- },
- getLocalDatastore: function () {
- return config.LocalDatastore;
- },
- getStorageController: function ()
- /*: StorageController*/
- {
- return config.StorageController;
- },
- setAsyncStorage: function (storage
- /*: any*/
- ) {
- config.AsyncStorage = storage;
- },
- getAsyncStorage: function () {
- return config.AsyncStorage;
- },
- setWebSocketController: function (controller
- /*: WebSocketController*/
- ) {
- config.WebSocketController = controller;
- },
- getWebSocketController: function ()
- /*: WebSocketController*/
- {
- return config.WebSocketController;
- },
- setUserController: function (controller
- /*: UserController*/
- ) {
- requireMethods('UserController', ['setCurrentUser', 'currentUser', 'currentUserAsync', 'signUp', 'logIn', 'become', 'logOut', 'me', 'requestPasswordReset', 'upgradeToRevocableSession', 'requestEmailVerification', 'verifyPassword', 'linkWith'], controller);
- config.UserController = controller;
- },
- getUserController: function ()
- /*: UserController*/
- {
- return config.UserController;
- },
- setLiveQueryController: function (controller
- /*: any*/
- ) {
- requireMethods('LiveQueryController', ['setDefaultLiveQueryClient', 'getDefaultLiveQueryClient', '_clearCachedDefaultClient'], controller);
- config.LiveQueryController = controller;
- },
- getLiveQueryController: function ()
- /*: any*/
- {
- return config.LiveQueryController;
- },
- setHooksController: function (controller
- /*: HooksController*/
- ) {
- requireMethods('HooksController', ['create', 'get', 'update', 'remove'], controller);
- config.HooksController = controller;
- },
- getHooksController: function ()
- /*: HooksController*/
- {
- return config.HooksController;
- }
- };
- }).call(this)}).call(this,_dereq_('_process'))
- },{"@babel/runtime-corejs3/core-js-stable/instance/concat":81,"@babel/runtime-corejs3/core-js-stable/instance/for-each":86,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"_process":323}],6:[function(_dereq_,module,exports){
- "use strict";
- var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
- var _stringify = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/json/stringify"));
- var AES;
- var ENC;
- AES = _dereq_('crypto-js/aes');
- ENC = _dereq_('crypto-js/enc-utf8');
- var CryptoJS;
- var CryptoController = {
- encrypt: function (obj
- /*: any*/
- , secretKey
- /*: string*/
- )
- /*: ?string*/
- {
- var encrypted = AES.encrypt((0, _stringify.default)(obj), secretKey);
- return encrypted.toString();
- },
- decrypt: function (encryptedText
- /*: string*/
- , secretKey
- /*: string*/
- )
- /*: ?string*/
- {
- var decryptedStr = AES.decrypt(encryptedText, secretKey).toString(ENC);
- return decryptedStr;
- }
- };
- module.exports = CryptoController;
- },{"@babel/runtime-corejs3/core-js-stable/json/stringify":99,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"crypto-js/aes":745,"crypto-js/enc-utf8":749}],7:[function(_dereq_,module,exports){
- "use strict";
- /**
- * Copyright (c) 2015-present, Parse, LLC.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- *
- * This is a simple wrapper to unify EventEmitter implementations across platforms.
- */
- module.exports = _dereq_('events').EventEmitter;
- var EventEmitter;
- },{"events":775}],8:[function(_dereq_,module,exports){
- "use strict";
- var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
- var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
- _Object$defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = void 0;
- var _ParseUser = _interopRequireDefault(_dereq_("./ParseUser"));
- /**
- * Copyright (c) 2015-present, Parse, LLC.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- *
- * @flow-weak
- */
- /* global FB */
- var initialized = false;
- var requestedPermissions;
- var initOptions;
- var provider = {
- authenticate: function (options) {
- var _this = this;
- if (typeof FB === 'undefined') {
- options.error(this, 'Facebook SDK not found.');
- }
- FB.login(function (response) {
- if (response.authResponse) {
- if (options.success) {
- options.success(_this, {
- id: response.authResponse.userID,
- access_token: response.authResponse.accessToken,
- expiration_date: new Date(response.authResponse.expiresIn * 1000 + new Date().getTime()).toJSON()
- });
- }
- } else {
- if (options.error) {
- options.error(_this, response);
- }
- }
- }, {
- scope: requestedPermissions
- });
- },
- restoreAuthentication: function (authData) {
- if (authData) {
- var newOptions = {};
- if (initOptions) {
- for (var key in initOptions) {
- newOptions[key] = initOptions[key];
- }
- } // Suppress checks for login status from the browser.
- newOptions.status = false; // If the user doesn't match the one known by the FB SDK, log out.
- // Most of the time, the users will match -- it's only in cases where
- // the FB SDK knows of a different user than the one being restored
- // from a Parse User that logged in with username/password.
- var existingResponse = FB.getAuthResponse();
- if (existingResponse && existingResponse.userID !== authData.id) {
- FB.logout();
- }
- FB.init(newOptions);
- }
- return true;
- },
- getAuthType: function () {
- return 'facebook';
- },
- deauthenticate: function () {
- this.restoreAuthentication(null);
- }
- };
- /**
- * Provides a set of utilities for using Parse with Facebook.
- *
- * @class Parse.FacebookUtils
- * @static
- * @hideconstructor
- */
- var FacebookUtils = {
- /**
- * Initializes Parse Facebook integration. Call this function after you
- * have loaded the Facebook Javascript SDK with the same parameters
- * as you would pass to<code>
- * <a href=
- * "https://developers.facebook.com/docs/reference/javascript/FB.init/">
- * FB.init()</a></code>. Parse.FacebookUtils will invoke FB.init() for you
- * with these arguments.
- *
- * @function init
- * @name Parse.FacebookUtils.init
- * @param {object} options Facebook options argument as described here:
- * <a href=
- * "https://developers.facebook.com/docs/reference/javascript/FB.init/">
- * FB.init()</a>. The status flag will be coerced to 'false' because it
- * interferes with Parse Facebook integration. Call FB.getLoginStatus()
- * explicitly if this behavior is required by your application.
- */
- init: function (options) {
- if (typeof FB === 'undefined') {
- throw new Error('The Facebook JavaScript SDK must be loaded before calling init.');
- }
- initOptions = {};
- if (options) {
- for (var key in options) {
- initOptions[key] = options[key];
- }
- }
- if (initOptions.status && typeof console !== 'undefined') {
- var warn = console.warn || console.log || function () {}; // eslint-disable-line no-console
- warn.call(console, 'The "status" flag passed into' + ' FB.init, when set to true, can interfere with Parse Facebook' + ' integration, so it has been suppressed. Please call' + ' FB.getLoginStatus() explicitly if you require this behavior.');
- }
- initOptions.status = false;
- FB.init(initOptions);
- _ParseUser.default._registerAuthenticationProvider(provider);
- initialized = true;
- },
- /**
- * Gets whether the user has their account linked to Facebook.
- *
- * @function isLinked
- * @name Parse.FacebookUtils.isLinked
- * @param {Parse.User} user User to check for a facebook link.
- * The user must be logged in on this device.
- * @returns {boolean} <code>true</code> if the user has their account
- * linked to Facebook.
- */
- isLinked: function (user) {
- return user._isLinked('facebook');
- },
- /**
- * Logs in a user using Facebook. This method delegates to the Facebook
- * SDK to authenticate the user, and then automatically logs in (or
- * creates, in the case where it is a new user) a Parse.User.
- *
- * Standard API:
- *
- * <code>logIn(permission: string, authData: Object);</code>
- *
- * Advanced API: Used for handling your own oAuth tokens
- * {@link https://docs.parseplatform.org/rest/guide/#linking-users}
- *
- * <code>logIn(authData: Object, options?: Object);</code>
- *
- * @function logIn
- * @name Parse.FacebookUtils.logIn
- * @param {(string | object)} permissions The permissions required for Facebook
- * log in. This is a comma-separated string of permissions.
- * Alternatively, supply a Facebook authData object as described in our
- * REST API docs if you want to handle getting facebook auth tokens
- * yourself.
- * @param {object} options MasterKey / SessionToken. Alternatively can be used for authData if permissions is a string
- * @returns {Promise}
- */
- logIn: function (permissions, options) {
- if (!permissions || typeof permissions === 'string') {
- if (!initialized) {
- throw new Error('You must initialize FacebookUtils before calling logIn.');
- }
- requestedPermissions = permissions;
- return _ParseUser.default.logInWith('facebook', options);
- }
- return _ParseUser.default.logInWith('facebook', {
- authData: permissions
- }, options);
- },
- /**
- * Links Facebook to an existing PFUser. This method delegates to the
- * Facebook SDK to authenticate the user, and then automatically links
- * the account to the Parse.User.
- *
- * Standard API:
- *
- * <code>link(user: Parse.User, permission: string, authData?: Object);</code>
- *
- * Advanced API: Used for handling your own oAuth tokens
- * {@link https://docs.parseplatform.org/rest/guide/#linking-users}
- *
- * <code>link(user: Parse.User, authData: Object, options?: FullOptions);</code>
- *
- * @function link
- * @name Parse.FacebookUtils.link
- * @param {Parse.User} user User to link to Facebook. This must be the
- * current user.
- * @param {(string | object)} permissions The permissions required for Facebook
- * log in. This is a comma-separated string of permissions.
- * Alternatively, supply a Facebook authData object as described in our
- * REST API docs if you want to handle getting facebook auth tokens
- * yourself.
- * @param {object} options MasterKey / SessionToken. Alternatively can be used for authData if permissions is a string
- * @returns {Promise}
- */
- link: function (user, permissions, options) {
- if (!permissions || typeof permissions === 'string') {
- if (!initialized) {
- throw new Error('You must initialize FacebookUtils before calling link.');
- }
- requestedPermissions = permissions;
- return user.linkWith('facebook', options);
- }
- return user.linkWith('facebook', {
- authData: permissions
- }, options);
- },
- /**
- * Unlinks the Parse.User from a Facebook account.
- *
- * @function unlink
- * @name Parse.FacebookUtils.unlink
- * @param {Parse.User} user User to unlink from Facebook. This must be the
- * current user.
- * @param {object} options Standard options object with success and error
- * callbacks.
- * @returns {Promise}
- */
- unlink: function (user, options) {
- if (!initialized) {
- throw new Error('You must initialize FacebookUtils before calling unlink.');
- }
- return user._unlinkFrom('facebook', options);
- },
- // Used for testing purposes
- _getAuthProvider: function () {
- return provider;
- }
- };
- var _default = FacebookUtils;
- exports.default = _default;
- },{"./ParseUser":44,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/helpers/interopRequireDefault":152}],9:[function(_dereq_,module,exports){
- "use strict";
- var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
- var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
- var _Storage = _interopRequireDefault(_dereq_("./Storage"));
- /**
- * Copyright (c) 2015-present, Parse, LLC.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- *
- * @flow
- */
- var _require = _dereq_('uuid'),
- uuidv4 = _require.v4;
- var iidCache = null;
- var InstallationController = {
- currentInstallationId: function ()
- /*: Promise<string>*/
- {
- if (typeof iidCache === 'string') {
- return _promise.default.resolve(iidCache);
- }
- var path = _Storage.default.generatePath('installationId');
- return _Storage.default.getItemAsync(path).then(function (iid) {
- if (!iid) {
- iid = uuidv4();
- return _Storage.default.setItemAsync(path, iid).then(function () {
- iidCache = iid;
- return iid;
- });
- }
- iidCache = iid;
- return iid;
- });
- },
- _clearCache: function () {
- iidCache = null;
- },
- _setInstallationIdCache: function (iid
- /*: string*/
- ) {
- iidCache = iid;
- }
- };
- module.exports = InstallationController;
- },{"./Storage":48,"@babel/runtime-corejs3/core-js-stable/promise":115,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"uuid":797}],10:[function(_dereq_,module,exports){
- "use strict";
- var _Reflect$construct = _dereq_("@babel/runtime-corejs3/core-js-stable/reflect/construct");
- var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
- var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
- _Object$defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = exports.InternalWeb3Events = void 0;
- var _regenerator = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/regenerator"));
- var _asyncToGenerator2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/asyncToGenerator"));
- var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
- var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
- var _assertThisInitialized2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/assertThisInitialized"));
- var _inherits2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/inherits"));
- var _possibleConstructorReturn2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/possibleConstructorReturn"));
- var _getPrototypeOf2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/getPrototypeOf"));
- var _freeze = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/freeze"));
- var _bind = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/bind"));
- var _events = _interopRequireDefault(_dereq_("events"));
- var _events2 = _dereq_("./Web3Connector/events");
- var _ethers = _dereq_("ethers");
- var _convert = _dereq_("./utils/convert");
- function _createSuper(Derived) {
- var hasNativeReflectConstruct = _isNativeReflectConstruct();
- return function () {
- var Super = (0, _getPrototypeOf2.default)(Derived),
- result;
- if (hasNativeReflectConstruct) {
- var NewTarget = (0, _getPrototypeOf2.default)(this).constructor;
- result = _Reflect$construct(Super, arguments, NewTarget);
- } else {
- result = Super.apply(this, arguments);
- }
- return (0, _possibleConstructorReturn2.default)(this, result);
- };
- }
- function _isNativeReflectConstruct() {
- if (typeof Reflect === "undefined" || !_Reflect$construct) return false;
- if (_Reflect$construct.sham) return false;
- if (typeof Proxy === "function") return true;
- try {
- Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {}));
- return true;
- } catch (e) {
- return false;
- }
- } // Events emitted by Moralis
- var InternalWeb3Events = (0, _freeze.default)({
- ACCOUNT_CHANGED: 'accountChanged',
- CHAIN_CHANGED: 'chainChanged',
- PROVIDER_CONNECT: 'provider-connect',
- PROVIDER_DISCONNECT: 'provider-disconnect',
- WEB3_ENABLED: 'web3Enabled',
- WEB3_DEACTIVATED: 'web3Deactivated'
- });
- /**
- * Wrapper for the internal web3 provider,
- * responsible for syncing data when connector connects/deactivates
- * Gives access to ethers functionalities, initialized by the connector
- */
- exports.InternalWeb3Events = InternalWeb3Events;
- var InternalWeb3Provider = /*#__PURE__*/function (_EventEmitter) {
- (0, _inherits2.default)(InternalWeb3Provider, _EventEmitter);
- var _super = _createSuper(InternalWeb3Provider);
- function InternalWeb3Provider(connector) {
- var _context, _context2, _context3, _context4;
- var _this;
- var anyNetwork = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
- var privateKey = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
- (0, _classCallCheck2.default)(this, InternalWeb3Provider);
- _this = _super.call(this);
- if (!connector) {
- throw new Error('Cannot initialize InternalWeb3Provider without a connector');
- }
- _this.connector = connector;
- _this.anyNetwork = anyNetwork;
- _this.privateKey = privateKey;
- _this.handleAccountChanged = (0, _bind.default)(_context = _this.handleAccountChanged).call(_context, (0, _assertThisInitialized2.default)(_this));
- _this.handleChainChanged = (0, _bind.default)(_context2 = _this.handleChainChanged).call(_context2, (0, _assertThisInitialized2.default)(_this));
- _this.handleConnect = (0, _bind.default)(_context3 = _this.handleConnect).call(_context3, (0, _assertThisInitialized2.default)(_this));
- _this.handleDisconnect = (0, _bind.default)(_context4 = _this.handleDisconnect).call(_context4, (0, _assertThisInitialized2.default)(_this));
- return _this;
- }
- (0, _createClass2.default)(InternalWeb3Provider, [{
- key: "activate",
- value: function () {
- var _activate = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(options) {
- var _yield$this$connector, provider, chainId, account, network;
- return _regenerator.default.wrap(function (_context5) {
- while (1) {
- switch (_context5.prev = _context5.next) {
- case 0:
- if (this.connector) {
- _context5.next = 2;
- break;
- }
- throw new Error('Cannot acticate InternalWeb3Provider without a connector');
- case 2:
- _context5.next = 4;
- return this.connector.activate(options);
- case 4:
- _yield$this$connector = _context5.sent;
- provider = _yield$this$connector.provider;
- chainId = _yield$this$connector.chainId;
- account = _yield$this$connector.account;
- this.provider = provider;
- this.chainId = chainId;
- this.account = account;
- network = this.anyNetwork ? 'any' : (0, _convert.fromHexToDecimal)(chainId);
- this.web3 = new _ethers.ethers.providers.Web3Provider(provider, network);
- if (this.connector.on) {
- this.connector.on(_events2.ConnectorEvents.ACCOUNT_CHANGED, this.handleAccountChanged);
- this.connector.on(_events2.ConnectorEvents.CHAIN_CHANGED, this.handleChainChanged);
- this.connector.on(_events2.ConnectorEvents.CONNECT, this.handleConnect);
- this.connector.on(_events2.ConnectorEvents.DISCONNECT, this.handleDisconnect);
- }
- return _context5.abrupt("return", {
- provider: provider,
- chainId: chainId,
- account: account,
- web3: this.web3
- });
- case 15:
- case "end":
- return _context5.stop();
- }
- }
- }, _callee, this);
- }));
- return function () {
- return _activate.apply(this, arguments);
- };
- }() // Returns a provider (or wallet if a privateKey is provided) that can sign messages (throws if not possible, ie. the account cannot sign)
- }, {
- key: "signer",
- get: function () {
- return this.privateKey != null ? new _ethers.ethers.Wallet(this.privateKey, this.web3) : this.web3.getSigner(this.account);
- } // Returns a provider (or wallet if a privateKey is provided) that can sign messages or the normal web3 provider as fallback
- }, {
- key: "signerOrProvider",
- get: function () {
- try {
- if (this.account) {
- return this.privateKey != null ? new _ethers.ethers.Wallet(this.privateKey, this.web3) : this.web3.getSigner(this.account);
- }
- return this.web3;
- } catch (error) {
- return this.web3;
- }
- }
- }, {
- key: "handleChainChanged",
- value: function (chainId) {
- this.chainId = chainId;
- this.web3 = new _ethers.ethers.providers.Web3Provider(this.provider, (0, _convert.fromHexToDecimal)(chainId));
- this.emit(InternalWeb3Events.CHAIN_CHANGED, chainId);
- }
- }, {
- key: "handleAccountChanged",
- value: function (account) {
- this.account = account;
- this.emit(InternalWeb3Events.ACCOUNT_CHANGED, account);
- } // Handle Connect events fired from connectors
- }, {
- key: "handleConnect",
- value: function (connectInfo) {
- this.emit(InternalWeb3Events.PROVIDER_CONNECT, connectInfo);
- } // Handle Disconnect events fired from connectors
- }, {
- key: "handleDisconnect",
- value: function (error) {
- this.emit(InternalWeb3Events.PROVIDER_DISCONNECT, error);
- }
- }, {
- key: "deactivate",
- value: function () {
- var _deactivate = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
- return _regenerator.default.wrap(function (_context6) {
- while (1) {
- switch (_context6.prev = _context6.next) {
- case 0:
- this.account = null;
- this.chianId = null;
- this.web3 = null;
- this.provider = null;
- this.privateKey = null;
- if (!this.connector) {
- _context6.next = 10;
- break;
- }
- if (this.connector.removeListener) {
- this.connector.removeListener(InternalWeb3Events.CHAIN_CHANGED, this.handleChainChanged);
- this.connector.removeListener(InternalWeb3Events.ACCOUNT_CHANGED, this.handleAccountChanged);
- this.connector.removeListener(InternalWeb3Events.PROVIDER_CONNECT, this.handleConnect);
- this.connector.removeListener(InternalWeb3Events.PROVIDER_DISCONNECT, this.handleDisconnect);
- }
- if (!this.connector.deactivate) {
- _context6.next = 10;
- break;
- }
- _context6.next = 10;
- return this.connector.deactivate();
- case 10:
- this.connector = null;
- case 11:
- case "end":
- return _context6.stop();
- }
- }
- }, _callee2, this);
- }));
- return function () {
- return _deactivate.apply(this, arguments);
- };
- }()
- }]);
- return InternalWeb3Provider;
- }(_events.default);
- var _default = InternalWeb3Provider;
- exports.default = _default;
- },{"./Web3Connector/events":61,"./utils/convert":76,"@babel/runtime-corejs3/core-js-stable/instance/bind":80,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/core-js-stable/object/freeze":107,"@babel/runtime-corejs3/core-js-stable/reflect/construct":116,"@babel/runtime-corejs3/helpers/assertThisInitialized":143,"@babel/runtime-corejs3/helpers/asyncToGenerator":144,"@babel/runtime-corejs3/helpers/classCallCheck":145,"@babel/runtime-corejs3/helpers/createClass":147,"@babel/runtime-corejs3/helpers/getPrototypeOf":150,"@babel/runtime-corejs3/helpers/inherits":151,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/helpers/possibleConstructorReturn":159,"@babel/runtime-corejs3/regenerator":167,"ethers":773,"events":775}],11:[function(_dereq_,module,exports){
- "use strict";
- var _Reflect$construct = _dereq_("@babel/runtime-corejs3/core-js-stable/reflect/construct");
- var _sliceInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/slice");
- var _Array$from = _dereq_("@babel/runtime-corejs3/core-js-stable/array/from");
- var _Symbol = _dereq_("@babel/runtime-corejs3/core-js-stable/symbol");
- var _getIteratorMethod = _dereq_("@babel/runtime-corejs3/core-js/get-iterator-method");
- var _Array$isArray = _dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array");
- var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
- var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
- _Object$defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = void 0;
- var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
- var _map = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/map"));
- var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/keys"));
- var _stringify = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/json/stringify"));
- var _forEach = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
- var _values = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/values"));
- var _setTimeout2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/set-timeout"));
- var _bind = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/bind"));
- var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
- var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
- var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
- var _assertThisInitialized2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/assertThisInitialized"));
- var _inherits2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/inherits"));
- var _possibleConstructorReturn2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/possibleConstructorReturn"));
- var _getPrototypeOf2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/getPrototypeOf"));
- var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
- var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
- var _EventEmitter2 = _interopRequireDefault(_dereq_("./EventEmitter"));
- var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
- var _LiveQuerySubscription = _interopRequireDefault(_dereq_("./LiveQuerySubscription"));
- var _promiseUtils = _dereq_("./promiseUtils");
- function _createForOfIteratorHelper(o, allowArrayLike) {
- var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"];
- if (!it) {
- if (_Array$isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
- if (it) o = it;
- var i = 0;
- var F = function () {};
- return {
- s: F,
- n: function () {
- if (i >= o.length) return {
- done: true
- };
- return {
- done: false,
- value: o[i++]
- };
- },
- e: function (_e) {
- throw _e;
- },
- f: F
- };
- }
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
- }
- var normalCompletion = true,
- didErr = false,
- err;
- return {
- s: function () {
- it = it.call(o);
- },
- n: function () {
- var step = it.next();
- normalCompletion = step.done;
- return step;
- },
- e: function (_e2) {
- didErr = true;
- err = _e2;
- },
- f: function () {
- try {
- if (!normalCompletion && it.return != null) it.return();
- } finally {
- if (didErr) throw err;
- }
- }
- };
- }
- function _unsupportedIterableToArray(o, minLen) {
- var _context6;
- if (!o) return;
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
- var n = _sliceInstanceProperty(_context6 = Object.prototype.toString.call(o)).call(_context6, 8, -1);
- if (n === "Object" && o.constructor) n = o.constructor.name;
- if (n === "Map" || n === "Set") return _Array$from(o);
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
- }
- function _arrayLikeToArray(arr, len) {
- if (len == null || len > arr.length) len = arr.length;
- for (var i = 0, arr2 = new Array(len); i < len; i++) {
- arr2[i] = arr[i];
- }
- return arr2;
- }
- function _createSuper(Derived) {
- var hasNativeReflectConstruct = _isNativeReflectConstruct();
- return function () {
- var Super = (0, _getPrototypeOf2.default)(Derived),
- result;
- if (hasNativeReflectConstruct) {
- var NewTarget = (0, _getPrototypeOf2.default)(this).constructor;
- result = _Reflect$construct(Super, arguments, NewTarget);
- } else {
- result = Super.apply(this, arguments);
- }
- return (0, _possibleConstructorReturn2.default)(this, result);
- };
- }
- function _isNativeReflectConstruct() {
- if (typeof Reflect === "undefined" || !_Reflect$construct) return false;
- if (_Reflect$construct.sham) return false;
- if (typeof Proxy === "function") return true;
- try {
- Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {}));
- return true;
- } catch (e) {
- return false;
- }
- } // The LiveQuery client inner state
- var CLIENT_STATE = {
- INITIALIZED: 'initialized',
- CONNECTING: 'connecting',
- CONNECTED: 'connected',
- CLOSED: 'closed',
- RECONNECTING: 'reconnecting',
- DISCONNECTED: 'disconnected'
- }; // The event type the LiveQuery client should sent to server
- var OP_TYPES = {
- CONNECT: 'connect',
- SUBSCRIBE: 'subscribe',
- UNSUBSCRIBE: 'unsubscribe',
- ERROR: 'error'
- }; // The event we get back from LiveQuery server
- var OP_EVENTS = {
- CONNECTED: 'connected',
- SUBSCRIBED: 'subscribed',
- UNSUBSCRIBED: 'unsubscribed',
- ERROR: 'error',
- CREATE: 'create',
- UPDATE: 'update',
- ENTER: 'enter',
- LEAVE: 'leave',
- DELETE: 'delete'
- }; // The event the LiveQuery client should emit
- var CLIENT_EMMITER_TYPES = {
- CLOSE: 'close',
- ERROR: 'error',
- OPEN: 'open'
- }; // The event the LiveQuery subscription should emit
- var SUBSCRIPTION_EMMITER_TYPES = {
- OPEN: 'open',
- CLOSE: 'close',
- ERROR: 'error',
- CREATE: 'create',
- UPDATE: 'update',
- ENTER: 'enter',
- LEAVE: 'leave',
- DELETE: 'delete'
- };
- var generateInterval = function (k) {
- return Math.random() * Math.min(30, Math.pow(2, k) - 1) * 1000;
- };
- /**
- * Creates a new LiveQueryClient.
- * Extends events.EventEmitter
- * <a href="https://nodejs.org/api/events.html#events_class_eventemitter">cloud functions</a>.
- *
- * A wrapper of a standard WebSocket client. We add several useful methods to
- * help you connect/disconnect to LiveQueryServer, subscribe/unsubscribe a ParseQuery easily.
- *
- * javascriptKey and masterKey are used for verifying the LiveQueryClient when it tries
- * to connect to the LiveQuery server
- *
- * We expose three events to help you monitor the status of the LiveQueryClient.
- *
- * <pre>
- * let Parse = require('parse/node');
- * let LiveQueryClient = Parse.LiveQueryClient;
- * let client = new LiveQueryClient({
- * applicationId: '',
- * serverURL: '',
- * javascriptKey: '',
- * masterKey: ''
- * });
- * </pre>
- *
- * Open - When we establish the WebSocket connection to the LiveQuery server, you'll get this event.
- * <pre>
- * client.on('open', () => {
- *
- * });</pre>
- *
- * Close - When we lose the WebSocket connection to the LiveQuery server, you'll get this event.
- * <pre>
- * client.on('close', () => {
- *
- * });</pre>
- *
- * Error - When some network error or LiveQuery server error happens, you'll get this event.
- * <pre>
- * client.on('error', (error) => {
- *
- * });</pre>
- *
- * @alias Parse.LiveQueryClient
- */
- var LiveQueryClient = /*#__PURE__*/function (_EventEmitter) {
- (0, _inherits2.default)(LiveQueryClient, _EventEmitter);
- var _super = _createSuper(LiveQueryClient);
- /**
- * @param {object} options
- * @param {string} options.applicationId - applicationId of your Parse app
- * @param {string} options.serverURL - <b>the URL of your LiveQuery server</b>
- * @param {string} options.javascriptKey (optional)
- * @param {string} options.masterKey (optional) Your Parse Master Key. (Node.js only!)
- * @param {string} options.sessionToken (optional)
- * @param {string} options.installationId (optional)
- */
- function LiveQueryClient(_ref) {
- var _this;
- var applicationId = _ref.applicationId,
- serverURL = _ref.serverURL,
- javascriptKey = _ref.javascriptKey,
- masterKey = _ref.masterKey,
- sessionToken = _ref.sessionToken,
- installationId = _ref.installationId;
- (0, _classCallCheck2.default)(this, LiveQueryClient);
- _this = _super.call(this);
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "attempts", void 0);
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "id", void 0);
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "requestId", void 0);
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "applicationId", void 0);
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "serverURL", void 0);
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "javascriptKey", void 0);
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "masterKey", void 0);
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "sessionToken", void 0);
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "installationId", void 0);
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "additionalProperties", void 0);
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "connectPromise", void 0);
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "subscriptions", void 0);
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "socket", void 0);
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "state", void 0);
- if (!serverURL || (0, _indexOf.default)(serverURL).call(serverURL, 'ws') !== 0) {
- throw new Error('You need to set a proper Parse LiveQuery server url before using LiveQueryClient');
- }
- _this.reconnectHandle = null;
- _this.attempts = 1;
- _this.id = 0;
- _this.requestId = 1;
- _this.serverURL = serverURL;
- _this.applicationId = applicationId;
- _this.javascriptKey = javascriptKey || undefined;
- _this.masterKey = masterKey || undefined;
- _this.sessionToken = sessionToken || undefined;
- _this.installationId = installationId || undefined;
- _this.additionalProperties = true;
- _this.connectPromise = (0, _promiseUtils.resolvingPromise)();
- _this.subscriptions = new _map.default();
- _this.state = CLIENT_STATE.INITIALIZED; // adding listener so process does not crash
- // best practice is for developer to register their own listener
- _this.on('error', function () {});
- return _this;
- }
- (0, _createClass2.default)(LiveQueryClient, [{
- key: "shouldOpen",
- value: function ()
- /*: any*/
- {
- return this.state === CLIENT_STATE.INITIALIZED || this.state === CLIENT_STATE.DISCONNECTED;
- }
- /**
- * Subscribes to a ParseQuery
- *
- * If you provide the sessionToken, when the LiveQuery server gets ParseObject's
- * updates from parse server, it'll try to check whether the sessionToken fulfills
- * the ParseObject's ACL. The LiveQuery server will only send updates to clients whose
- * sessionToken is fit for the ParseObject's ACL. You can check the LiveQuery protocol
- * <a href="https://github.com/parse-community/parse-server/wiki/Parse-LiveQuery-Protocol-Specification">here</a> for more details. The subscription you get is the same subscription you get
- * from our Standard API.
- *
- * @param {object} query - the ParseQuery you want to subscribe to
- * @param {string} sessionToken (optional)
- * @returns {LiveQuerySubscription} subscription
- */
- }, {
- key: "subscribe",
- value: function (query
- /*: Object*/
- , sessionToken
- /*: ?string*/
- )
- /*: LiveQuerySubscription*/
- {
- var _this2 = this;
- if (!query) {
- return;
- }
- var className = query.className;
- var queryJSON = query.toJSON();
- var where = queryJSON.where;
- var fields = (0, _keys.default)(queryJSON) ? (0, _keys.default)(queryJSON).split(',') : undefined;
- var subscribeRequest = {
- op: OP_TYPES.SUBSCRIBE,
- requestId: this.requestId,
- query: {
- className: className,
- where: where,
- fields: fields
- }
- };
- if (sessionToken) {
- subscribeRequest.sessionToken = sessionToken;
- }
- var subscription = new _LiveQuerySubscription.default(this.requestId, query, sessionToken);
- this.subscriptions.set(this.requestId, subscription);
- this.requestId += 1;
- this.connectPromise.then(function () {
- _this2.socket.send((0, _stringify.default)(subscribeRequest));
- });
- return subscription;
- }
- /**
- * After calling unsubscribe you'll stop receiving events from the subscription object.
- *
- * @param {object} subscription - subscription you would like to unsubscribe from.
- */
- }, {
- key: "unsubscribe",
- value: function (subscription
- /*: Object*/
- ) {
- var _this3 = this;
- if (!subscription) {
- return;
- }
- this.subscriptions.delete(subscription.id);
- var unsubscribeRequest = {
- op: OP_TYPES.UNSUBSCRIBE,
- requestId: subscription.id
- };
- this.connectPromise.then(function () {
- _this3.socket.send((0, _stringify.default)(unsubscribeRequest));
- });
- }
- /**
- * After open is called, the LiveQueryClient will try to send a connect request
- * to the LiveQuery server.
- *
- */
- }, {
- key: "open",
- value: function () {
- var _this4 = this;
- var WebSocketImplementation = _CoreManager.default.getWebSocketController();
- if (!WebSocketImplementation) {
- this.emit(CLIENT_EMMITER_TYPES.ERROR, 'Can not find WebSocket implementation');
- return;
- }
- if (this.state !== CLIENT_STATE.RECONNECTING) {
- this.state = CLIENT_STATE.CONNECTING;
- }
- this.socket = new WebSocketImplementation(this.serverURL); // Bind WebSocket callbacks
- this.socket.onopen = function () {
- _this4._handleWebSocketOpen();
- };
- this.socket.onmessage = function (event) {
- _this4._handleWebSocketMessage(event);
- };
- this.socket.onclose = function () {
- _this4._handleWebSocketClose();
- };
- this.socket.onerror = function (error) {
- _this4._handleWebSocketError(error);
- };
- }
- }, {
- key: "resubscribe",
- value: function () {
- var _context,
- _this5 = this;
- (0, _forEach.default)(_context = this.subscriptions).call(_context, function (subscription, requestId) {
- var query = subscription.query;
- var queryJSON = query.toJSON();
- var where = queryJSON.where;
- var fields = (0, _keys.default)(queryJSON) ? (0, _keys.default)(queryJSON).split(',') : undefined;
- var className = query.className;
- var sessionToken = subscription.sessionToken;
- var subscribeRequest = {
- op: OP_TYPES.SUBSCRIBE,
- requestId: requestId,
- query: {
- className: className,
- where: where,
- fields: fields
- }
- };
- if (sessionToken) {
- subscribeRequest.sessionToken = sessionToken;
- }
- _this5.connectPromise.then(function () {
- _this5.socket.send((0, _stringify.default)(subscribeRequest));
- });
- });
- }
- /**
- * This method will close the WebSocket connection to this LiveQueryClient,
- * cancel the auto reconnect and unsubscribe all subscriptions based on it.
- *
- */
- }, {
- key: "close",
- value: function () {
- var _context2;
- if (this.state === CLIENT_STATE.INITIALIZED || this.state === CLIENT_STATE.DISCONNECTED) {
- return;
- }
- this.state = CLIENT_STATE.DISCONNECTED;
- this.socket.close(); // Notify each subscription about the close
- var _iterator = _createForOfIteratorHelper((0, _values.default)(_context2 = this.subscriptions).call(_context2)),
- _step;
- try {
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
- var subscription = _step.value;
- subscription.subscribed = false;
- subscription.emit(SUBSCRIPTION_EMMITER_TYPES.CLOSE);
- }
- } catch (err) {
- _iterator.e(err);
- } finally {
- _iterator.f();
- }
- this._handleReset();
- this.emit(CLIENT_EMMITER_TYPES.CLOSE);
- } // ensure we start with valid state if connect is called again after close
- }, {
- key: "_handleReset",
- value: function () {
- this.attempts = 1;
- this.id = 0;
- this.requestId = 1;
- this.connectPromise = (0, _promiseUtils.resolvingPromise)();
- this.subscriptions = new _map.default();
- }
- }, {
- key: "_handleWebSocketOpen",
- value: function () {
- this.attempts = 1;
- var connectRequest = {
- op: OP_TYPES.CONNECT,
- applicationId: this.applicationId,
- javascriptKey: this.javascriptKey,
- masterKey: this.masterKey,
- sessionToken: this.sessionToken
- };
- if (this.additionalProperties) {
- connectRequest.installationId = this.installationId;
- }
- this.socket.send((0, _stringify.default)(connectRequest));
- }
- }, {
- key: "_handleWebSocketMessage",
- value: function (event
- /*: any*/
- ) {
- var data = event.data;
- if (typeof data === 'string') {
- data = JSON.parse(data);
- }
- var subscription = null;
- if (data.requestId) {
- subscription = this.subscriptions.get(data.requestId);
- }
- var response = {
- clientId: data.clientId,
- installationId: data.installationId
- };
- switch (data.op) {
- case OP_EVENTS.CONNECTED:
- if (this.state === CLIENT_STATE.RECONNECTING) {
- this.resubscribe();
- }
- this.emit(CLIENT_EMMITER_TYPES.OPEN);
- this.id = data.clientId;
- this.connectPromise.resolve();
- this.state = CLIENT_STATE.CONNECTED;
- break;
- case OP_EVENTS.SUBSCRIBED:
- if (subscription) {
- subscription.subscribed = true;
- subscription.subscribePromise.resolve();
- (0, _setTimeout2.default)(function () {
- return subscription.emit(SUBSCRIPTION_EMMITER_TYPES.OPEN, response);
- }, 200);
- }
- break;
- case OP_EVENTS.ERROR:
- if (data.requestId) {
- if (subscription) {
- subscription.subscribePromise.resolve();
- (0, _setTimeout2.default)(function () {
- return subscription.emit(SUBSCRIPTION_EMMITER_TYPES.ERROR, data.error);
- }, 200);
- }
- } else {
- this.emit(CLIENT_EMMITER_TYPES.ERROR, data.error);
- }
- if (data.error === 'Additional properties not allowed') {
- this.additionalProperties = false;
- }
- if (data.reconnect) {
- this._handleReconnect();
- }
- break;
- case OP_EVENTS.UNSUBSCRIBED:
- // We have already deleted subscription in unsubscribe(), do nothing here
- break;
- default:
- {
- // create, update, enter, leave, delete cases
- if (!subscription) {
- break;
- }
- var override = false;
- if (data.original) {
- override = true;
- delete data.original.__type; // Check for removed fields
- for (var field in data.original) {
- if (!(field in data.object)) {
- data.object[field] = undefined;
- }
- }
- data.original = _ParseObject.default.fromJSON(data.original, false);
- }
- delete data.object.__type;
- var parseObject = _ParseObject.default.fromJSON(data.object, override);
- if (data.original) {
- subscription.emit(data.op, parseObject, data.original, response);
- } else {
- subscription.emit(data.op, parseObject, response);
- }
- var localDatastore = _CoreManager.default.getLocalDatastore();
- if (override && localDatastore.isEnabled) {
- localDatastore._updateObjectIfPinned(parseObject).then(function () {});
- }
- }
- }
- }
- }, {
- key: "_handleWebSocketClose",
- value: function () {
- var _context3;
- if (this.state === CLIENT_STATE.DISCONNECTED) {
- return;
- }
- this.state = CLIENT_STATE.CLOSED;
- this.emit(CLIENT_EMMITER_TYPES.CLOSE); // Notify each subscription about the close
- var _iterator2 = _createForOfIteratorHelper((0, _values.default)(_context3 = this.subscriptions).call(_context3)),
- _step2;
- try {
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
- var subscription = _step2.value;
- subscription.emit(SUBSCRIPTION_EMMITER_TYPES.CLOSE);
- }
- } catch (err) {
- _iterator2.e(err);
- } finally {
- _iterator2.f();
- }
- this._handleReconnect();
- }
- }, {
- key: "_handleWebSocketError",
- value: function (error
- /*: any*/
- ) {
- var _context4;
- this.emit(CLIENT_EMMITER_TYPES.ERROR, error);
- var _iterator3 = _createForOfIteratorHelper((0, _values.default)(_context4 = this.subscriptions).call(_context4)),
- _step3;
- try {
- for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
- var subscription = _step3.value;
- subscription.emit(SUBSCRIPTION_EMMITER_TYPES.ERROR, error);
- }
- } catch (err) {
- _iterator3.e(err);
- } finally {
- _iterator3.f();
- }
- this._handleReconnect();
- }
- }, {
- key: "_handleReconnect",
- value: function () {
- var _context5,
- _this6 = this; // if closed or currently reconnecting we stop attempting to reconnect
- if (this.state === CLIENT_STATE.DISCONNECTED) {
- return;
- }
- this.state = CLIENT_STATE.RECONNECTING;
- var time = generateInterval(this.attempts); // handle case when both close/error occur at frequent rates we ensure we do not reconnect unnecessarily.
- // we're unable to distinguish different between close/error when we're unable to reconnect therefore
- // we try to reconnect in both cases
- // server side ws and browser WebSocket behave differently in when close/error get triggered
- if (this.reconnectHandle) {
- clearTimeout(this.reconnectHandle);
- }
- this.reconnectHandle = (0, _setTimeout2.default)((0, _bind.default)(_context5 = function () {
- _this6.attempts++;
- _this6.connectPromise = (0, _promiseUtils.resolvingPromise)();
- _this6.open();
- }).call(_context5, this), time);
- }
- }]);
- return LiveQueryClient;
- }(_EventEmitter2.default);
- _CoreManager.default.setWebSocketController(typeof WebSocket === 'function' || (typeof WebSocket === "undefined" ? "undefined" : (0, _typeof2.default)(WebSocket)) === 'object' ? WebSocket : null);
- var _default = LiveQueryClient;
- exports.default = _default;
- },{"./CoreManager":5,"./EventEmitter":7,"./LiveQuerySubscription":12,"./ParseObject":36,"./promiseUtils":72,"@babel/runtime-corejs3/core-js-stable/array/from":78,"@babel/runtime-corejs3/core-js-stable/array/is-array":79,"@babel/runtime-corejs3/core-js-stable/instance/bind":80,"@babel/runtime-corejs3/core-js-stable/instance/for-each":86,"@babel/runtime-corejs3/core-js-stable/instance/index-of":88,"@babel/runtime-corejs3/core-js-stable/instance/keys":89,"@babel/runtime-corejs3/core-js-stable/instance/slice":93,"@babel/runtime-corejs3/core-js-stable/instance/values":98,"@babel/runtime-corejs3/core-js-stable/json/stringify":99,"@babel/runtime-corejs3/core-js-stable/map":100,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/core-js-stable/reflect/construct":116,"@babel/runtime-corejs3/core-js-stable/set-timeout":117,"@babel/runtime-corejs3/core-js-stable/symbol":119,"@babel/runtime-corejs3/core-js/get-iterator-method":125,"@babel/runtime-corejs3/helpers/assertThisInitialized":143,"@babel/runtime-corejs3/helpers/classCallCheck":145,"@babel/runtime-corejs3/helpers/createClass":147,"@babel/runtime-corejs3/helpers/defineProperty":148,"@babel/runtime-corejs3/helpers/getPrototypeOf":150,"@babel/runtime-corejs3/helpers/inherits":151,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/helpers/possibleConstructorReturn":159,"@babel/runtime-corejs3/helpers/typeof":164}],12:[function(_dereq_,module,exports){
- "use strict";
- var _Reflect$construct = _dereq_("@babel/runtime-corejs3/core-js-stable/reflect/construct");
- var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
- var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
- _Object$defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = void 0;
- var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
- var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
- var _inherits2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/inherits"));
- var _possibleConstructorReturn2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/possibleConstructorReturn"));
- var _getPrototypeOf2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/getPrototypeOf"));
- var _EventEmitter2 = _interopRequireDefault(_dereq_("./EventEmitter"));
- var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
- var _promiseUtils = _dereq_("./promiseUtils");
- function _createSuper(Derived) {
- var hasNativeReflectConstruct = _isNativeReflectConstruct();
- return function () {
- var Super = (0, _getPrototypeOf2.default)(Derived),
- result;
- if (hasNativeReflectConstruct) {
- var NewTarget = (0, _getPrototypeOf2.default)(this).constructor;
- result = _Reflect$construct(Super, arguments, NewTarget);
- } else {
- result = Super.apply(this, arguments);
- }
- return (0, _possibleConstructorReturn2.default)(this, result);
- };
- }
- function _isNativeReflectConstruct() {
- if (typeof Reflect === "undefined" || !_Reflect$construct) return false;
- if (_Reflect$construct.sham) return false;
- if (typeof Proxy === "function") return true;
- try {
- Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {}));
- return true;
- } catch (e) {
- return false;
- }
- }
- /**
- * Creates a new LiveQuery Subscription.
- * Extends events.EventEmitter
- * <a href="https://nodejs.org/api/events.html#events_class_eventemitter">cloud functions</a>.
- *
- * <p>Response Object - Contains data from the client that made the request
- * <ul>
- * <li>clientId</li>
- * <li>installationId - requires Parse Server 4.0.0+</li>
- * </ul>
- * </p>
- *
- * <p>Open Event - When you call query.subscribe(), we send a subscribe request to
- * the LiveQuery server, when we get the confirmation from the LiveQuery server,
- * this event will be emitted. When the client loses WebSocket connection to the
- * LiveQuery server, we will try to auto reconnect the LiveQuery server. If we
- * reconnect the LiveQuery server and successfully resubscribe the ParseQuery,
- * you'll also get this event.
- *
- * <pre>
- * subscription.on('open', (response) => {
- *
- * });</pre></p>
- *
- * <p>Create Event - When a new ParseObject is created and it fulfills the ParseQuery you subscribe,
- * you'll get this event. The object is the ParseObject which is created.
- *
- * <pre>
- * subscription.on('create', (object, response) => {
- *
- * });</pre></p>
- *
- * <p>Update Event - When an existing ParseObject (original) which fulfills the ParseQuery you subscribe
- * is updated (The ParseObject fulfills the ParseQuery before and after changes),
- * you'll get this event. The object is the ParseObject which is updated.
- * Its content is the latest value of the ParseObject.
- *
- * Parse-Server 3.1.3+ Required for original object parameter
- *
- * <pre>
- * subscription.on('update', (object, original, response) => {
- *
- * });</pre></p>
- *
- * <p>Enter Event - When an existing ParseObject's (original) old value doesn't fulfill the ParseQuery
- * but its new value fulfills the ParseQuery, you'll get this event. The object is the
- * ParseObject which enters the ParseQuery. Its content is the latest value of the ParseObject.
- *
- * Parse-Server 3.1.3+ Required for original object parameter
- *
- * <pre>
- * subscription.on('enter', (object, original, response) => {
- *
- * });</pre></p>
- *
- *
- * <p>Update Event - When an existing ParseObject's old value fulfills the ParseQuery but its new value
- * doesn't fulfill the ParseQuery, you'll get this event. The object is the ParseObject
- * which leaves the ParseQuery. Its content is the latest value of the ParseObject.
- *
- * <pre>
- * subscription.on('leave', (object, response) => {
- *
- * });</pre></p>
- *
- *
- * <p>Delete Event - When an existing ParseObject which fulfills the ParseQuery is deleted, you'll
- * get this event. The object is the ParseObject which is deleted.
- *
- * <pre>
- * subscription.on('delete', (object, response) => {
- *
- * });</pre></p>
- *
- *
- * <p>Close Event - When the client loses the WebSocket connection to the LiveQuery
- * server and we stop receiving events, you'll get this event.
- *
- * <pre>
- * subscription.on('close', () => {
- *
- * });</pre></p>
- *
- * @alias Parse.LiveQuerySubscription
- */
- var Subscription = /*#__PURE__*/function (_EventEmitter) {
- (0, _inherits2.default)(Subscription, _EventEmitter);
- var _super = _createSuper(Subscription);
- /*
- * @param {string} id - subscription id
- * @param {string} query - query to subscribe to
- * @param {string} sessionToken - optional session token
- */
- function Subscription(id, query, sessionToken) {
- var _this;
- (0, _classCallCheck2.default)(this, Subscription);
- _this = _super.call(this);
- _this.id = id;
- _this.query = query;
- _this.sessionToken = sessionToken;
- _this.subscribePromise = (0, _promiseUtils.resolvingPromise)();
- _this.subscribed = false; // adding listener so process does not crash
- // best practice is for developer to register their own listener
- _this.on('error', function () {});
- return _this;
- }
- /**
- * Close the subscription
- *
- * @returns {Promise}
- */
- (0, _createClass2.default)(Subscription, [{
- key: "unsubscribe",
- value: function ()
- /*: Promise*/
- {
- var _this2 = this;
- return _CoreManager.default.getLiveQueryController().getDefaultLiveQueryClient().then(function (liveQueryClient) {
- liveQueryClient.unsubscribe(_this2);
- _this2.emit('close');
- });
- }
- }]);
- return Subscription;
- }(_EventEmitter2.default);
- var _default = Subscription;
- exports.default = _default;
- },{"./CoreManager":5,"./EventEmitter":7,"./promiseUtils":72,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/core-js-stable/reflect/construct":116,"@babel/runtime-corejs3/helpers/classCallCheck":145,"@babel/runtime-corejs3/helpers/createClass":147,"@babel/runtime-corejs3/helpers/getPrototypeOf":150,"@babel/runtime-corejs3/helpers/inherits":151,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/helpers/possibleConstructorReturn":159}],13:[function(_dereq_,module,exports){
- "use strict";
- var _sliceInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/slice");
- var _Array$from2 = _dereq_("@babel/runtime-corejs3/core-js-stable/array/from");
- var _Symbol = _dereq_("@babel/runtime-corejs3/core-js-stable/symbol");
- var _getIteratorMethod = _dereq_("@babel/runtime-corejs3/core-js/get-iterator-method");
- var _Array$isArray2 = _dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array");
- var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
- var _regenerator = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/regenerator"));
- var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
- var _set = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/set"));
- var _concat = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/concat"));
- var _filter = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/filter"));
- var _includes = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/includes"));
- var _keys2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/keys"));
- var _startsWith = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/starts-with"));
- var _keys3 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/keys"));
- var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
- var _map = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/map"));
- var _from = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/from"));
- var _find = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/find"));
- var _toConsumableArray2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/toConsumableArray"));
- var _slicedToArray2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/slicedToArray"));
- var _asyncToGenerator2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/asyncToGenerator"));
- var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
- var _ParseQuery = _interopRequireDefault(_dereq_("./ParseQuery"));
- var _LocalDatastoreUtils = _dereq_("./LocalDatastoreUtils");
- function _createForOfIteratorHelper(o, allowArrayLike) {
- var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"];
- if (!it) {
- if (_Array$isArray2(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
- if (it) o = it;
- var i = 0;
- var F = function () {};
- return {
- s: F,
- n: function () {
- if (i >= o.length) return {
- done: true
- };
- return {
- done: false,
- value: o[i++]
- };
- },
- e: function (_e) {
- throw _e;
- },
- f: F
- };
- }
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
- }
- var normalCompletion = true,
- didErr = false,
- err;
- return {
- s: function () {
- it = it.call(o);
- },
- n: function () {
- var step = it.next();
- normalCompletion = step.done;
- return step;
- },
- e: function (_e2) {
- didErr = true;
- err = _e2;
- },
- f: function () {
- try {
- if (!normalCompletion && it.return != null) it.return();
- } finally {
- if (didErr) throw err;
- }
- }
- };
- }
- function _unsupportedIterableToArray(o, minLen) {
- var _context16;
- if (!o) return;
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
- var n = _sliceInstanceProperty(_context16 = Object.prototype.toString.call(o)).call(_context16, 8, -1);
- if (n === "Object" && o.constructor) n = o.constructor.name;
- if (n === "Map" || n === "Set") return _Array$from2(o);
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
- }
- function _arrayLikeToArray(arr, len) {
- if (len == null || len > arr.length) len = arr.length;
- for (var i = 0, arr2 = new Array(len); i < len; i++) {
- arr2[i] = arr[i];
- }
- return arr2;
- }
- /**
- * Provides a local datastore which can be used to store and retrieve <code>Parse.Object</code>. <br />
- * To enable this functionality, call <code>Parse.enableLocalDatastore()</code>.
- *
- * Pin object to add to local datastore
- *
- * <pre>await object.pin();</pre>
- * <pre>await object.pinWithName('pinName');</pre>
- *
- * Query pinned objects
- *
- * <pre>query.fromLocalDatastore();</pre>
- * <pre>query.fromPin();</pre>
- * <pre>query.fromPinWithName();</pre>
- *
- * <pre>const localObjects = await query.find();</pre>
- *
- * @class Parse.LocalDatastore
- * @static
- */
- var LocalDatastore = {
- isEnabled: false,
- isSyncing: false,
- fromPinWithName: function (name
- /*: string*/
- )
- /*: Promise<Array<Object>>*/
- {
- var controller = _CoreManager.default.getLocalDatastoreController();
- return controller.fromPinWithName(name);
- },
- pinWithName: function (name
- /*: string*/
- , value
- /*: any*/
- )
- /*: Promise<void>*/
- {
- var controller = _CoreManager.default.getLocalDatastoreController();
- return controller.pinWithName(name, value);
- },
- unPinWithName: function (name
- /*: string*/
- )
- /*: Promise<void>*/
- {
- var controller = _CoreManager.default.getLocalDatastoreController();
- return controller.unPinWithName(name);
- },
- _getAllContents: function ()
- /*: Promise<Object>*/
- {
- var controller = _CoreManager.default.getLocalDatastoreController();
- return controller.getAllContents();
- },
- // Use for testing
- _getRawStorage: function ()
- /*: Promise<Object>*/
- {
- var controller = _CoreManager.default.getLocalDatastoreController();
- return controller.getRawStorage();
- },
- _clear: function ()
- /*: Promise<void>*/
- {
- var controller = _CoreManager.default.getLocalDatastoreController();
- return controller.clear();
- },
- // Pin the object and children recursively
- // Saves the object and children key to Pin Name
- _handlePinAllWithName: function (name
- /*: string*/
- , objects
- /*: Array<ParseObject>*/
- )
- /*: Promise<void>*/
- {
- var _this = this;
- return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
- var _context;
- var pinName, toPinPromises, objectKeys, _iterator, _step, parent, children, parentKey, json, objectKey, fromPinPromise, _yield$Promise$all, _yield$Promise$all2, pinned, toPin;
- return _regenerator.default.wrap(function (_context2) {
- while (1) {
- switch (_context2.prev = _context2.next) {
- case 0:
- pinName = _this.getPinName(name);
- toPinPromises = [];
- objectKeys = [];
- _iterator = _createForOfIteratorHelper(objects);
- try {
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
- parent = _step.value;
- children = _this._getChildren(parent);
- parentKey = _this.getKeyForObject(parent);
- json = parent._toFullJSON(undefined, true);
- if (parent._localId) {
- json._localId = parent._localId;
- }
- children[parentKey] = json;
- for (objectKey in children) {
- objectKeys.push(objectKey);
- toPinPromises.push(_this.pinWithName(objectKey, [children[objectKey]]));
- }
- }
- } catch (err) {
- _iterator.e(err);
- } finally {
- _iterator.f();
- }
- fromPinPromise = _this.fromPinWithName(pinName);
- _context2.next = 8;
- return _promise.default.all([fromPinPromise, toPinPromises]);
- case 8:
- _yield$Promise$all = _context2.sent;
- _yield$Promise$all2 = (0, _slicedToArray2.default)(_yield$Promise$all, 1);
- pinned = _yield$Promise$all2[0];
- toPin = (0, _toConsumableArray2.default)(new _set.default((0, _concat.default)(_context = []).call(_context, (0, _toConsumableArray2.default)(pinned || []), objectKeys)));
- return _context2.abrupt("return", _this.pinWithName(pinName, toPin));
- case 13:
- case "end":
- return _context2.stop();
- }
- }
- }, _callee);
- }))();
- },
- // Removes object and children keys from pin name
- // Keeps the object and children pinned
- _handleUnPinAllWithName: function (name
- /*: string*/
- , objects
- /*: Array<ParseObject>*/
- ) {
- var _this2 = this;
- return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
- var localDatastore, pinName, promises, objectKeys, _iterator2, _step2, _objectKeys, _context3, parent, children, parentKey, pinned, _iterator3, _step3, objectKey, hasReference, key, pinnedObjects;
- return _regenerator.default.wrap(function (_context4) {
- while (1) {
- switch (_context4.prev = _context4.next) {
- case 0:
- _context4.next = 2;
- return _this2._getAllContents();
- case 2:
- localDatastore = _context4.sent;
- pinName = _this2.getPinName(name);
- promises = [];
- objectKeys = [];
- _iterator2 = _createForOfIteratorHelper(objects);
- try {
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
- parent = _step2.value;
- children = _this2._getChildren(parent);
- parentKey = _this2.getKeyForObject(parent);
- (_objectKeys = objectKeys).push.apply(_objectKeys, (0, _concat.default)(_context3 = [parentKey]).call(_context3, (0, _toConsumableArray2.default)((0, _keys2.default)(children))));
- }
- } catch (err) {
- _iterator2.e(err);
- } finally {
- _iterator2.f();
- }
- objectKeys = (0, _toConsumableArray2.default)(new _set.default(objectKeys));
- pinned = localDatastore[pinName] || [];
- pinned = (0, _filter.default)(pinned).call(pinned, function (item) {
- return !(0, _includes.default)(objectKeys).call(objectKeys, item);
- });
- if (pinned.length === 0) {
- promises.push(_this2.unPinWithName(pinName));
- delete localDatastore[pinName];
- } else {
- promises.push(_this2.pinWithName(pinName, pinned));
- localDatastore[pinName] = pinned;
- }
- _iterator3 = _createForOfIteratorHelper(objectKeys);
- _context4.prev = 13;
- _iterator3.s();
- case 15:
- if ((_step3 = _iterator3.n()).done) {
- _context4.next = 31;
- break;
- }
- objectKey = _step3.value;
- hasReference = false;
- _context4.t0 = (0, _keys3.default)(_regenerator.default).call(_regenerator.default, localDatastore);
- case 19:
- if ((_context4.t1 = _context4.t0()).done) {
- _context4.next = 28;
- break;
- }
- key = _context4.t1.value;
- if (!(key === _LocalDatastoreUtils.DEFAULT_PIN || (0, _startsWith.default)(key).call(key, _LocalDatastoreUtils.PIN_PREFIX))) {
- _context4.next = 26;
- break;
- }
- pinnedObjects = localDatastore[key] || [];
- if (!(0, _includes.default)(pinnedObjects).call(pinnedObjects, objectKey)) {
- _context4.next = 26;
- break;
- }
- hasReference = true;
- return _context4.abrupt("break", 28);
- case 26:
- _context4.next = 19;
- break;
- case 28:
- if (!hasReference) {
- promises.push(_this2.unPinWithName(objectKey));
- }
- case 29:
- _context4.next = 15;
- break;
- case 31:
- _context4.next = 36;
- break;
- case 33:
- _context4.prev = 33;
- _context4.t2 = _context4["catch"](13);
- _iterator3.e(_context4.t2);
- case 36:
- _context4.prev = 36;
- _iterator3.f();
- return _context4.finish(36);
- case 39:
- return _context4.abrupt("return", _promise.default.all(promises));
- case 40:
- case "end":
- return _context4.stop();
- }
- }
- }, _callee2, null, [[13, 33, 36, 39]]);
- }))();
- },
- // Retrieve all pointer fields from object recursively
- _getChildren: function (object
- /*: ParseObject*/
- ) {
- var encountered = {};
- var json = object._toFullJSON(undefined, true);
- for (var key in json) {
- if (json[key] && json[key].__type && json[key].__type === 'Object') {
- this._traverse(json[key], encountered);
- }
- }
- return encountered;
- },
- _traverse: function (object
- /*: any*/
- , encountered
- /*: any*/
- ) {
- if (!object.objectId) {
- return;
- }
- var objectKey = this.getKeyForObject(object);
- if (encountered[objectKey]) {
- return;
- }
- encountered[objectKey] = object;
- for (var key in object) {
- var json = object[key];
- if (!object[key]) {
- json = object;
- }
- if (json.__type && json.__type === 'Object') {
- this._traverse(json, encountered);
- }
- }
- },
- // Transform keys in pin name to objects
- _serializeObjectsFromPinName: function (name
- /*: string*/
- ) {
- var _this3 = this;
- return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
- var _ref;
- var localDatastore, allObjects, key, pinName, pinned, promises, objects;
- return _regenerator.default.wrap(function (_context5) {
- while (1) {
- switch (_context5.prev = _context5.next) {
- case 0:
- _context5.next = 2;
- return _this3._getAllContents();
- case 2:
- localDatastore = _context5.sent;
- allObjects = [];
- for (key in localDatastore) {
- if ((0, _startsWith.default)(key).call(key, _LocalDatastoreUtils.OBJECT_PREFIX)) {
- allObjects.push(localDatastore[key][0]);
- }
- }
- if (name) {
- _context5.next = 7;
- break;
- }
- return _context5.abrupt("return", allObjects);
- case 7:
- pinName = _this3.getPinName(name);
- pinned = localDatastore[pinName];
- if ((0, _isArray.default)(pinned)) {
- _context5.next = 11;
- break;
- }
- return _context5.abrupt("return", []);
- case 11:
- promises = (0, _map.default)(pinned).call(pinned, function (objectKey) {
- return _this3.fromPinWithName(objectKey);
- });
- _context5.next = 14;
- return _promise.default.all(promises);
- case 14:
- objects = _context5.sent;
- objects = (0, _concat.default)(_ref = []).apply(_ref, (0, _toConsumableArray2.default)(objects));
- return _context5.abrupt("return", (0, _filter.default)(objects).call(objects, function (object) {
- return object != null;
- }));
- case 17:
- case "end":
- return _context5.stop();
- }
- }
- }, _callee3);
- }))();
- },
- // Replaces object pointers with pinned pointers
- // The object pointers may contain old data
- // Uses Breadth First Search Algorithm
- _serializeObject: function (objectKey
- /*: string*/
- , localDatastore
- /*: any*/
- ) {
- var _this4 = this;
- return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() {
- var LDS, root, queue, meta, uniqueId, nodeId, subTreeRoot, field, value, key, pointer;
- return _regenerator.default.wrap(function (_context6) {
- while (1) {
- switch (_context6.prev = _context6.next) {
- case 0:
- LDS = localDatastore;
- if (LDS) {
- _context6.next = 5;
- break;
- }
- _context6.next = 4;
- return _this4._getAllContents();
- case 4:
- LDS = _context6.sent;
- case 5:
- if (!(!LDS[objectKey] || LDS[objectKey].length === 0)) {
- _context6.next = 7;
- break;
- }
- return _context6.abrupt("return", null);
- case 7:
- root = LDS[objectKey][0];
- queue = [];
- meta = {};
- uniqueId = 0;
- meta[uniqueId] = root;
- queue.push(uniqueId);
- while (queue.length !== 0) {
- nodeId = queue.shift();
- subTreeRoot = meta[nodeId];
- for (field in subTreeRoot) {
- value = subTreeRoot[field];
- if (value.__type && value.__type === 'Object') {
- key = _this4.getKeyForObject(value);
- if (LDS[key] && LDS[key].length > 0) {
- pointer = LDS[key][0];
- uniqueId++;
- meta[uniqueId] = pointer;
- subTreeRoot[field] = pointer;
- queue.push(uniqueId);
- }
- }
- }
- }
- return _context6.abrupt("return", root);
- case 15:
- case "end":
- return _context6.stop();
- }
- }
- }, _callee4);
- }))();
- },
- // Called when an object is save / fetched
- // Update object pin value
- _updateObjectIfPinned: function (object
- /*: ParseObject*/
- )
- /*: Promise<void>*/
- {
- var _this5 = this;
- return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
- var objectKey, pinned;
- return _regenerator.default.wrap(function (_context7) {
- while (1) {
- switch (_context7.prev = _context7.next) {
- case 0:
- if (_this5.isEnabled) {
- _context7.next = 2;
- break;
- }
- return _context7.abrupt("return");
- case 2:
- objectKey = _this5.getKeyForObject(object);
- _context7.next = 5;
- return _this5.fromPinWithName(objectKey);
- case 5:
- pinned = _context7.sent;
- if (!(!pinned || pinned.length === 0)) {
- _context7.next = 8;
- break;
- }
- return _context7.abrupt("return");
- case 8:
- return _context7.abrupt("return", _this5.pinWithName(objectKey, [object._toFullJSON()]));
- case 9:
- case "end":
- return _context7.stop();
- }
- }
- }, _callee5);
- }))();
- },
- // Called when object is destroyed
- // Unpin object and remove all references from pin names
- // TODO: Destroy children?
- _destroyObjectIfPinned: function (object
- /*: ParseObject*/
- ) {
- var _this6 = this;
- return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6() {
- var localDatastore, objectKey, pin, promises, key, pinned;
- return _regenerator.default.wrap(function (_context8) {
- while (1) {
- switch (_context8.prev = _context8.next) {
- case 0:
- if (_this6.isEnabled) {
- _context8.next = 2;
- break;
- }
- return _context8.abrupt("return");
- case 2:
- _context8.next = 4;
- return _this6._getAllContents();
- case 4:
- localDatastore = _context8.sent;
- objectKey = _this6.getKeyForObject(object);
- pin = localDatastore[objectKey];
- if (pin) {
- _context8.next = 9;
- break;
- }
- return _context8.abrupt("return");
- case 9:
- promises = [_this6.unPinWithName(objectKey)];
- delete localDatastore[objectKey];
- for (key in localDatastore) {
- if (key === _LocalDatastoreUtils.DEFAULT_PIN || (0, _startsWith.default)(key).call(key, _LocalDatastoreUtils.PIN_PREFIX)) {
- pinned = localDatastore[key] || [];
- if ((0, _includes.default)(pinned).call(pinned, objectKey)) {
- pinned = (0, _filter.default)(pinned).call(pinned, function (item) {
- return item !== objectKey;
- });
- if (pinned.length === 0) {
- promises.push(_this6.unPinWithName(key));
- delete localDatastore[key];
- } else {
- promises.push(_this6.pinWithName(key, pinned));
- localDatastore[key] = pinned;
- }
- }
- }
- }
- return _context8.abrupt("return", _promise.default.all(promises));
- case 13:
- case "end":
- return _context8.stop();
- }
- }
- }, _callee6);
- }))();
- },
- // Update pin and references of the unsaved object
- _updateLocalIdForObject: function (localId
- /*: string*/
- , object
- /*: ParseObject*/
- ) {
- var _this7 = this;
- return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7() {
- var _context9, _context10;
- var localKey, objectKey, unsaved, promises, localDatastore, key, pinned;
- return _regenerator.default.wrap(function (_context11) {
- while (1) {
- switch (_context11.prev = _context11.next) {
- case 0:
- if (_this7.isEnabled) {
- _context11.next = 2;
- break;
- }
- return _context11.abrupt("return");
- case 2:
- localKey = (0, _concat.default)(_context9 = (0, _concat.default)(_context10 = "".concat(_LocalDatastoreUtils.OBJECT_PREFIX)).call(_context10, object.className, "_")).call(_context9, localId);
- objectKey = _this7.getKeyForObject(object);
- _context11.next = 6;
- return _this7.fromPinWithName(localKey);
- case 6:
- unsaved = _context11.sent;
- if (!(!unsaved || unsaved.length === 0)) {
- _context11.next = 9;
- break;
- }
- return _context11.abrupt("return");
- case 9:
- promises = [_this7.unPinWithName(localKey), _this7.pinWithName(objectKey, unsaved)];
- _context11.next = 12;
- return _this7._getAllContents();
- case 12:
- localDatastore = _context11.sent;
- for (key in localDatastore) {
- if (key === _LocalDatastoreUtils.DEFAULT_PIN || (0, _startsWith.default)(key).call(key, _LocalDatastoreUtils.PIN_PREFIX)) {
- pinned = localDatastore[key] || [];
- if ((0, _includes.default)(pinned).call(pinned, localKey)) {
- pinned = (0, _filter.default)(pinned).call(pinned, function (item) {
- return item !== localKey;
- });
- pinned.push(objectKey);
- promises.push(_this7.pinWithName(key, pinned));
- localDatastore[key] = pinned;
- }
- }
- }
- return _context11.abrupt("return", _promise.default.all(promises));
- case 15:
- case "end":
- return _context11.stop();
- }
- }
- }, _callee7);
- }))();
- },
- /**
- * Updates Local Datastore from Server
- *
- * <pre>
- * await Parse.LocalDatastore.updateFromServer();
- * </pre>
- *
- * @function updateFromServer
- * @name Parse.LocalDatastore.updateFromServer
- * @static
- */
- updateFromServer: function () {
- var _this8 = this;
- return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8() {
- var _context12;
- var localDatastore, keys, key, pointersHash, _i, _keys, _key, _key$split, _key$split2, className, objectId, queryPromises, responses, objects, pinPromises;
- return _regenerator.default.wrap(function (_context13) {
- while (1) {
- switch (_context13.prev = _context13.next) {
- case 0:
- if (!(!_this8.checkIfEnabled() || _this8.isSyncing)) {
- _context13.next = 2;
- break;
- }
- return _context13.abrupt("return");
- case 2:
- _context13.next = 4;
- return _this8._getAllContents();
- case 4:
- localDatastore = _context13.sent;
- keys = [];
- for (key in localDatastore) {
- if ((0, _startsWith.default)(key).call(key, _LocalDatastoreUtils.OBJECT_PREFIX)) {
- keys.push(key);
- }
- }
- if (!(keys.length === 0)) {
- _context13.next = 9;
- break;
- }
- return _context13.abrupt("return");
- case 9:
- _this8.isSyncing = true;
- pointersHash = {};
- _i = 0, _keys = keys;
- case 12:
- if (!(_i < _keys.length)) {
- _context13.next = 23;
- break;
- }
- _key = _keys[_i]; // Ignore the OBJECT_PREFIX
- _key$split = _key.split('_'), _key$split2 = (0, _slicedToArray2.default)(_key$split, 4), className = _key$split2[2], objectId = _key$split2[3]; // User key is split into [ 'Parse', 'LDS', '', 'User', 'objectId' ]
- if (_key.split('_').length === 5 && _key.split('_')[3] === 'User') {
- className = '_User';
- objectId = _key.split('_')[4];
- }
- if (!(0, _startsWith.default)(objectId).call(objectId, 'local')) {
- _context13.next = 18;
- break;
- }
- return _context13.abrupt("continue", 20);
- case 18:
- if (!(className in pointersHash)) {
- pointersHash[className] = new _set.default();
- }
- pointersHash[className].add(objectId);
- case 20:
- _i++;
- _context13.next = 12;
- break;
- case 23:
- queryPromises = (0, _map.default)(_context12 = (0, _keys2.default)(pointersHash)).call(_context12, function (className) {
- var objectIds = (0, _from.default)(pointersHash[className]);
- var query = new _ParseQuery.default(className);
- query.limit(objectIds.length);
- if (objectIds.length === 1) {
- query.equalTo('objectId', objectIds[0]);
- } else {
- query.containedIn('objectId', objectIds);
- }
- return (0, _find.default)(query).call(query);
- });
- _context13.prev = 24;
- _context13.next = 27;
- return _promise.default.all(queryPromises);
- case 27:
- responses = _context13.sent;
- objects = (0, _concat.default)([]).apply([], responses);
- pinPromises = (0, _map.default)(objects).call(objects, function (object) {
- var objectKey = _this8.getKeyForObject(object);
- return _this8.pinWithName(objectKey, object._toFullJSON());
- });
- _context13.next = 32;
- return _promise.default.all(pinPromises);
- case 32:
- _this8.isSyncing = false;
- _context13.next = 39;
- break;
- case 35:
- _context13.prev = 35;
- _context13.t0 = _context13["catch"](24); // eslint-disable-next-line no-console
- console.error('Error syncing LocalDatastore: ', _context13.t0);
- _this8.isSyncing = false;
- case 39:
- case "end":
- return _context13.stop();
- }
- }
- }, _callee8, null, [[24, 35]]);
- }))();
- },
- getKeyForObject: function (object
- /*: any*/
- ) {
- var _context14, _context15;
- var objectId = object.objectId || object._getId();
- return (0, _concat.default)(_context14 = (0, _concat.default)(_context15 = "".concat(_LocalDatastoreUtils.OBJECT_PREFIX)).call(_context15, object.className, "_")).call(_context14, objectId);
- },
- getPinName: function (pinName
- /*: ?string*/
- ) {
- if (!pinName || pinName === _LocalDatastoreUtils.DEFAULT_PIN) {
- return _LocalDatastoreUtils.DEFAULT_PIN;
- }
- return _LocalDatastoreUtils.PIN_PREFIX + pinName;
- },
- checkIfEnabled: function () {
- if (!this.isEnabled) {
- // eslint-disable-next-line no-console
- console.error('Parse.enableLocalDatastore() must be called first');
- }
- return this.isEnabled;
- }
- };
- module.exports = LocalDatastore;
- _CoreManager.default.setLocalDatastoreController(_dereq_('./LocalDatastoreController'));
- _CoreManager.default.setLocalDatastore(LocalDatastore);
- },{"./CoreManager":5,"./LocalDatastoreController":14,"./LocalDatastoreUtils":15,"./ParseQuery":39,"@babel/runtime-corejs3/core-js-stable/array/from":78,"@babel/runtime-corejs3/core-js-stable/array/is-array":79,"@babel/runtime-corejs3/core-js-stable/instance/concat":81,"@babel/runtime-corejs3/core-js-stable/instance/filter":84,"@babel/runtime-corejs3/core-js-stable/instance/find":85,"@babel/runtime-corejs3/core-js-stable/instance/includes":87,"@babel/runtime-corejs3/core-js-stable/instance/keys":89,"@babel/runtime-corejs3/core-js-stable/instance/map":90,"@babel/runtime-corejs3/core-js-stable/instance/slice":93,"@babel/runtime-corejs3/core-js-stable/instance/starts-with":96,"@babel/runtime-corejs3/core-js-stable/object/keys":112,"@babel/runtime-corejs3/core-js-stable/promise":115,"@babel/runtime-corejs3/core-js-stable/set":118,"@babel/runtime-corejs3/core-js-stable/symbol":119,"@babel/runtime-corejs3/core-js/get-iterator-method":125,"@babel/runtime-corejs3/helpers/asyncToGenerator":144,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/helpers/slicedToArray":161,"@babel/runtime-corejs3/helpers/toConsumableArray":163,"@babel/runtime-corejs3/regenerator":167}],14:[function(_dereq_,module,exports){
- "use strict";
- var _sliceInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/slice");
- var _Array$from = _dereq_("@babel/runtime-corejs3/core-js-stable/array/from");
- var _Symbol = _dereq_("@babel/runtime-corejs3/core-js-stable/symbol");
- var _getIteratorMethod = _dereq_("@babel/runtime-corejs3/core-js/get-iterator-method");
- var _Array$isArray = _dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array");
- var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
- var _stringify = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/json/stringify"));
- var _reduce = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/reduce"));
- var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
- var _map = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/map"));
- var _regenerator = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/regenerator"));
- var _asyncToGenerator2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/asyncToGenerator"));
- var _LocalDatastoreUtils = _dereq_("./LocalDatastoreUtils");
- var _Storage = _interopRequireDefault(_dereq_("./Storage"));
- function _createForOfIteratorHelper(o, allowArrayLike) {
- var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"];
- if (!it) {
- if (_Array$isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
- if (it) o = it;
- var i = 0;
- var F = function () {};
- return {
- s: F,
- n: function () {
- if (i >= o.length) return {
- done: true
- };
- return {
- done: false,
- value: o[i++]
- };
- },
- e: function (_e) {
- throw _e;
- },
- f: F
- };
- }
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
- }
- var normalCompletion = true,
- didErr = false,
- err;
- return {
- s: function () {
- it = it.call(o);
- },
- n: function () {
- var step = it.next();
- normalCompletion = step.done;
- return step;
- },
- e: function (_e2) {
- didErr = true;
- err = _e2;
- },
- f: function () {
- try {
- if (!normalCompletion && it.return != null) it.return();
- } finally {
- if (didErr) throw err;
- }
- }
- };
- }
- function _unsupportedIterableToArray(o, minLen) {
- var _context7;
- if (!o) return;
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
- var n = _sliceInstanceProperty(_context7 = Object.prototype.toString.call(o)).call(_context7, 8, -1);
- if (n === "Object" && o.constructor) n = o.constructor.name;
- if (n === "Map" || n === "Set") return _Array$from(o);
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
- }
- function _arrayLikeToArray(arr, len) {
- if (len == null || len > arr.length) len = arr.length;
- for (var i = 0, arr2 = new Array(len); i < len; i++) {
- arr2[i] = arr[i];
- }
- return arr2;
- }
- var LocalDatastoreController = {
- fromPinWithName: function (name
- /*: string*/
- )
- /*: Array<Object>*/
- {
- return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
- var values, objects;
- return _regenerator.default.wrap(function (_context) {
- while (1) {
- switch (_context.prev = _context.next) {
- case 0:
- _context.next = 2;
- return _Storage.default.getItemAsync(name);
- case 2:
- values = _context.sent;
- if (values) {
- _context.next = 5;
- break;
- }
- return _context.abrupt("return", []);
- case 5:
- objects = JSON.parse(values);
- return _context.abrupt("return", objects);
- case 7:
- case "end":
- return _context.stop();
- }
- }
- }, _callee);
- }))();
- },
- pinWithName: function (name
- /*: string*/
- , value
- /*: any*/
- ) {
- var values = (0, _stringify.default)(value);
- return _Storage.default.setItemAsync(name, values);
- },
- unPinWithName: function (name
- /*: string*/
- ) {
- return _Storage.default.removeItemAsync(name);
- },
- getAllContents: function ()
- /*: Object*/
- {
- return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
- var keys;
- return _regenerator.default.wrap(function (_context3) {
- while (1) {
- switch (_context3.prev = _context3.next) {
- case 0:
- _context3.next = 2;
- return _Storage.default.getAllKeysAsync();
- case 2:
- keys = _context3.sent;
- return _context3.abrupt("return", (0, _reduce.default)(keys).call(keys, /*#__PURE__*/function () {
- var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(previousPromise, key) {
- var LDS, value;
- return _regenerator.default.wrap(function (_context2) {
- while (1) {
- switch (_context2.prev = _context2.next) {
- case 0:
- _context2.next = 2;
- return previousPromise;
- case 2:
- LDS = _context2.sent;
- if (!(0, _LocalDatastoreUtils.isLocalDatastoreKey)(key)) {
- _context2.next = 8;
- break;
- }
- _context2.next = 6;
- return _Storage.default.getItemAsync(key);
- case 6:
- value = _context2.sent;
- try {
- LDS[key] = JSON.parse(value);
- } catch (error) {
- // eslint-disable-next-line no-console
- console.error('Error getAllContents: ', error);
- }
- case 8:
- return _context2.abrupt("return", LDS);
- case 9:
- case "end":
- return _context2.stop();
- }
- }
- }, _callee2);
- }));
- return function () {
- return _ref.apply(this, arguments);
- };
- }(), _promise.default.resolve({})));
- case 4:
- case "end":
- return _context3.stop();
- }
- }
- }, _callee3);
- }))();
- },
- // Used for testing
- getRawStorage: function ()
- /*: Object*/
- {
- return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
- var keys;
- return _regenerator.default.wrap(function (_context5) {
- while (1) {
- switch (_context5.prev = _context5.next) {
- case 0:
- _context5.next = 2;
- return _Storage.default.getAllKeysAsync();
- case 2:
- keys = _context5.sent;
- return _context5.abrupt("return", (0, _reduce.default)(keys).call(keys, /*#__PURE__*/function () {
- var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(previousPromise, key) {
- var LDS, value;
- return _regenerator.default.wrap(function (_context4) {
- while (1) {
- switch (_context4.prev = _context4.next) {
- case 0:
- _context4.next = 2;
- return previousPromise;
- case 2:
- LDS = _context4.sent;
- _context4.next = 5;
- return _Storage.default.getItemAsync(key);
- case 5:
- value = _context4.sent;
- LDS[key] = value;
- return _context4.abrupt("return", LDS);
- case 8:
- case "end":
- return _context4.stop();
- }
- }
- }, _callee4);
- }));
- return function () {
- return _ref2.apply(this, arguments);
- };
- }(), _promise.default.resolve({})));
- case 4:
- case "end":
- return _context5.stop();
- }
- }
- }, _callee5);
- }))();
- },
- clear: function ()
- /*: Promise*/
- {
- var _this = this;
- return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6() {
- var keys, toRemove, _iterator, _step, key, promises;
- return _regenerator.default.wrap(function (_context6) {
- while (1) {
- switch (_context6.prev = _context6.next) {
- case 0:
- _context6.next = 2;
- return _Storage.default.getAllKeysAsync();
- case 2:
- keys = _context6.sent;
- toRemove = [];
- _iterator = _createForOfIteratorHelper(keys);
- try {
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
- key = _step.value;
- if ((0, _LocalDatastoreUtils.isLocalDatastoreKey)(key)) {
- toRemove.push(key);
- }
- }
- } catch (err) {
- _iterator.e(err);
- } finally {
- _iterator.f();
- }
- promises = (0, _map.default)(toRemove).call(toRemove, _this.unPinWithName);
- return _context6.abrupt("return", _promise.default.all(promises));
- case 8:
- case "end":
- return _context6.stop();
- }
- }
- }, _callee6);
- }))();
- }
- };
- module.exports = LocalDatastoreController;
- },{"./LocalDatastoreUtils":15,"./Storage":48,"@babel/runtime-corejs3/core-js-stable/array/from":78,"@babel/runtime-corejs3/core-js-stable/array/is-array":79,"@babel/runtime-corejs3/core-js-stable/instance/map":90,"@babel/runtime-corejs3/core-js-stable/instance/reduce":92,"@babel/runtime-corejs3/core-js-stable/instance/slice":93,"@babel/runtime-corejs3/core-js-stable/json/stringify":99,"@babel/runtime-corejs3/core-js-stable/promise":115,"@babel/runtime-corejs3/core-js-stable/symbol":119,"@babel/runtime-corejs3/core-js/get-iterator-method":125,"@babel/runtime-corejs3/helpers/asyncToGenerator":144,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/regenerator":167}],15:[function(_dereq_,module,exports){
- "use strict";
- var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
- var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
- _Object$defineProperty(exports, "__esModule", {
- value: true
- });
- exports.PIN_PREFIX = exports.OBJECT_PREFIX = exports.DEFAULT_PIN = void 0;
- exports.isLocalDatastoreKey = isLocalDatastoreKey;
- var _startsWith = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/starts-with"));
- /**
- * Copyright (c) 2015-present, Parse, LLC.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- *
- * @flow
- * @private
- */
- var DEFAULT_PIN = '_default';
- exports.DEFAULT_PIN = DEFAULT_PIN;
- var PIN_PREFIX = 'parsePin_';
- exports.PIN_PREFIX = PIN_PREFIX;
- var OBJECT_PREFIX = 'Parse_LDS_';
- exports.OBJECT_PREFIX = OBJECT_PREFIX;
- function isLocalDatastoreKey(key
- /*: string*/
- )
- /*: boolean*/
- {
- return !!(key && (key === DEFAULT_PIN || (0, _startsWith.default)(key).call(key, PIN_PREFIX) || (0, _startsWith.default)(key).call(key, OBJECT_PREFIX)));
- }
- },{"@babel/runtime-corejs3/core-js-stable/instance/starts-with":96,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/helpers/interopRequireDefault":152}],16:[function(_dereq_,module,exports){
- "use strict";
- var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
- var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
- _Object$defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = void 0;
- var _regenerator = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/regenerator"));
- var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/keys"));
- var _filter = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/filter"));
- var _from = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/from"));
- var _slice = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/slice"));
- var _asyncToGenerator2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/asyncToGenerator"));
- var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
- var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
- var _ParseUser = _interopRequireDefault(_dereq_("./ParseUser"));
- var _ParseQuery = _interopRequireDefault(_dereq_("./ParseQuery"));
- var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
- var _ParseACL = _interopRequireDefault(_dereq_("./ParseACL"));
- var _createSigningData = _interopRequireDefault(_dereq_("./createSigningData"));
- /* global window */
- var web3EnablePromise = null;
- var MoralisDot = /*#__PURE__*/function () {
- function MoralisDot() {
- (0, _classCallCheck2.default)(this, MoralisDot);
- }
- (0, _createClass2.default)(MoralisDot, null, [{
- key: "web3IsInjected",
- value: function () {
- return (0, _keys.default)(window.injectedWeb3).length !== 0;
- }
- }, {
- key: "enable",
- value: function () {
- var _enable = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(opts) {
- var _window$injectedWeb, _window$injectedWeb$t;
- var type,
- _args = arguments;
- return _regenerator.default.wrap(function (_context) {
- while (1) {
- switch (_context.prev = _context.next) {
- case 0:
- type = _args.length > 1 && _args[1] !== undefined ? _args[1] : 'polkadot-js';
- if (!web3EnablePromise) {
- _context.next = 3;
- break;
- }
- return _context.abrupt("return", web3EnablePromise);
- case 3:
- web3EnablePromise = (_window$injectedWeb = window.injectedWeb3) === null || _window$injectedWeb === void 0 ? void 0 : (_window$injectedWeb$t = _window$injectedWeb[type]) === null || _window$injectedWeb$t === void 0 ? void 0 : _window$injectedWeb$t.enable(opts);
- return _context.abrupt("return", web3EnablePromise);
- case 5:
- case "end":
- return _context.stop();
- }
- }
- }, _callee);
- }));
- return function () {
- return _enable.apply(this, arguments);
- };
- }()
- }, {
- key: "authenticate",
- value: function () {
- var _authenticate = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(opts) {
- var _opts$name;
- var allAccounts, account, address, dotAddress, accounts, message, data, signature, authData, user;
- return _regenerator.default.wrap(function (_context2) {
- while (1) {
- switch (_context2.prev = _context2.next) {
- case 0:
- _context2.next = 2;
- return MoralisDot.enable((_opts$name = opts === null || opts === void 0 ? void 0 : opts.name) !== null && _opts$name !== void 0 ? _opts$name : 'Moralis');
- case 2:
- MoralisDot.web3 = _context2.sent;
- _context2.next = 5;
- return MoralisDot.web3.accounts.get();
- case 5:
- allAccounts = _context2.sent;
- account = allAccounts[0];
- address = account === null || account === void 0 ? void 0 : account.address;
- if (address) {
- _context2.next = 10;
- break;
- }
- throw new Error('Address not found');
- case 10:
- dotAddress = address;
- accounts = [dotAddress];
- message = MoralisDot.getSigningData();
- _context2.next = 15;
- return (0, _createSigningData.default)(message);
- case 15:
- data = _context2.sent;
- _context2.next = 18;
- return MoralisDot.sign(address, data);
- case 18:
- signature = _context2.sent;
- authData = {
- id: dotAddress,
- signature: signature,
- data: data
- };
- _context2.next = 22;
- return _ParseUser.default.logInWith('moralisDot', {
- authData: authData
- });
- case 22:
- user = _context2.sent;
- if (user) {
- _context2.next = 25;
- break;
- }
- throw new Error('Could not get user');
- case 25:
- _context2.next = 27;
- return user.setACL(new _ParseACL.default(user));
- case 27:
- user.addAllUnique('dotAccounts', accounts);
- user.set('dotAddress', dotAddress);
- _context2.next = 31;
- return user.save();
- case 31:
- return _context2.abrupt("return", user);
- case 32:
- case "end":
- return _context2.stop();
- }
- }
- }, _callee2);
- }));
- return function () {
- return _authenticate.apply(this, arguments);
- };
- }()
- }, {
- key: "link",
- value: function () {
- var _link = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(account, options) {
- var message, user, dotAddress, DotAddress, query, dotAddressRecord, data, signature, authData;
- return _regenerator.default.wrap(function (_context3) {
- while (1) {
- switch (_context3.prev = _context3.next) {
- case 0:
- message = (options === null || options === void 0 ? void 0 : options.signingMessage) || MoralisDot.getSigningData();
- _context3.next = 3;
- return _ParseUser.default.current();
- case 3:
- user = _context3.sent;
- dotAddress = account;
- DotAddress = _ParseObject.default.extend('_DotAddress');
- query = new _ParseQuery.default(DotAddress);
- _context3.next = 9;
- return query.get(dotAddress).catch(function () {
- return null;
- });
- case 9:
- dotAddressRecord = _context3.sent;
- if (dotAddressRecord) {
- _context3.next = 20;
- break;
- }
- _context3.next = 13;
- return (0, _createSigningData.default)(message);
- case 13:
- data = _context3.sent;
- _context3.next = 16;
- return MoralisDot.sign(dotAddress, data);
- case 16:
- signature = _context3.sent;
- authData = {
- id: dotAddress,
- signature: signature,
- data: data
- };
- _context3.next = 20;
- return user.linkWith('moralisDot', {
- authData: authData
- });
- case 20:
- user.addAllUnique('dotAccounts', [dotAddress]);
- user.set('dotAddress', dotAddress);
- _context3.next = 24;
- return user.save();
- case 24:
- return _context3.abrupt("return", user);
- case 25:
- case "end":
- return _context3.stop();
- }
- }
- }, _callee3);
- }));
- return function () {
- return _link.apply(this, arguments);
- };
- }()
- }, {
- key: "unlink",
- value: function () {
- var _unlink = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(account) {
- var _user$get;
- var accountsLower, DotAddress, query, dotAddressRecord, user, accounts, nextAccounts;
- return _regenerator.default.wrap(function (_context4) {
- while (1) {
- switch (_context4.prev = _context4.next) {
- case 0:
- accountsLower = account;
- DotAddress = _ParseObject.default.extend('_DotAddress');
- query = new _ParseQuery.default(DotAddress);
- _context4.next = 5;
- return query.get(accountsLower);
- case 5:
- dotAddressRecord = _context4.sent;
- _context4.next = 8;
- return dotAddressRecord.destroy();
- case 8:
- _context4.next = 10;
- return _ParseUser.default.current();
- case 10:
- user = _context4.sent;
- accounts = (_user$get = user.get('dotAccounts')) !== null && _user$get !== void 0 ? _user$get : [];
- nextAccounts = (0, _filter.default)(accounts).call(accounts, function (v) {
- return v !== accountsLower;
- });
- user.set('dotAccounts', nextAccounts);
- user.set('dotAddress', nextAccounts[0]);
- _context4.next = 17;
- return user._unlinkFrom('moralisDot');
- case 17:
- _context4.next = 19;
- return user.save();
- case 19:
- return _context4.abrupt("return", user);
- case 20:
- case "end":
- return _context4.stop();
- }
- }
- }, _callee4);
- }));
- return function () {
- return _unlink.apply(this, arguments);
- };
- }()
- }, {
- key: "sign",
- value: function () {
- var _sign = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(address, data) {
- var web3, _yield$web3$signer$si, signature;
- return _regenerator.default.wrap(function (_context5) {
- while (1) {
- switch (_context5.prev = _context5.next) {
- case 0:
- if (web3EnablePromise) {
- _context5.next = 2;
- break;
- }
- throw new Error('Must enable MoralisDot');
- case 2:
- _context5.next = 4;
- return web3EnablePromise;
- case 4:
- web3 = _context5.sent;
- if (web3.signer) {
- _context5.next = 7;
- break;
- }
- throw new Error('No signer found');
- case 7:
- _context5.next = 9;
- return web3.signer.signRaw({
- address: address,
- data: stringToHex(data),
- type: 'bytes'
- });
- case 9:
- _yield$web3$signer$si = _context5.sent;
- signature = _yield$web3$signer$si.signature;
- return _context5.abrupt("return", signature);
- case 12:
- case "end":
- return _context5.stop();
- }
- }
- }, _callee5);
- }));
- return function () {
- return _sign.apply(this, arguments);
- };
- }()
- }, {
- key: "getSigningData",
- value: function () {
- return 'Moralis Authentication';
- }
- }]);
- return MoralisDot;
- }();
- var _default = MoralisDot;
- exports.default = _default;
- function stringToHex(value) {
- return toHexString(stringToU8a(value));
- }
- function stringToU8a(value) {
- var u8a = new Uint8Array(value.length);
- for (var i = 0; i < value.length; i++) {
- u8a[i] = value.charCodeAt(i);
- }
- return u8a;
- }
- function toHexString(byteArray) {
- return "0x".concat((0, _from.default)(byteArray, function (byte) {
- var _context6; // eslint-disable-next-line no-bitwise
- return (0, _slice.default)(_context6 = "0".concat((byte & 0xff).toString(16))).call(_context6, -2);
- }).join(''));
- }
- },{"./ParseACL":26,"./ParseObject":36,"./ParseQuery":39,"./ParseUser":44,"./createSigningData":64,"@babel/runtime-corejs3/core-js-stable/array/from":78,"@babel/runtime-corejs3/core-js-stable/instance/filter":84,"@babel/runtime-corejs3/core-js-stable/instance/slice":93,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/core-js-stable/object/keys":112,"@babel/runtime-corejs3/helpers/asyncToGenerator":144,"@babel/runtime-corejs3/helpers/classCallCheck":145,"@babel/runtime-corejs3/helpers/createClass":147,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/regenerator":167}],17:[function(_dereq_,module,exports){
- "use strict";
- var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
- var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
- _Object$defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = void 0;
- var _filter = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/filter"));
- var _regenerator = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/regenerator"));
- var _asyncToGenerator2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/asyncToGenerator"));
- var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
- var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
- var _ParseUser = _interopRequireDefault(_dereq_("./ParseUser"));
- var _ParseQuery = _interopRequireDefault(_dereq_("./ParseQuery"));
- var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
- var _ParseACL = _interopRequireDefault(_dereq_("./ParseACL"));
- var _createSigningData = _interopRequireDefault(_dereq_("./createSigningData"));
- /* global window */
- var INIT_ERROR = 'Could not initialise ledger app, make sure Elrond app is open';
- function getErdJs() {
- return MoralisErd.getErdJs();
- }
- var MoralisErd = /*#__PURE__*/function () {
- function MoralisErd() {
- (0, _classCallCheck2.default)(this, MoralisErd);
- }
- (0, _createClass2.default)(MoralisErd, null, [{
- key: "getErdJs",
- value: function () {
- if (typeof window !== 'undefined' && window.erdjs) return window.erdjs;
- throw new Error('Please add erdjs scripts');
- }
- }, {
- key: "gatewayAddress",
- value: function () {
- return 'https://gateway.elrond.com';
- }
- }, {
- key: "hwProxy",
- value: function () {
- var _hwProxy = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
- var _getErdJs, ProxyProvider, proxy;
- return _regenerator.default.wrap(function (_context) {
- while (1) {
- switch (_context.prev = _context.next) {
- case 0:
- if (!MoralisErd._proxy) {
- _context.next = 2;
- break;
- }
- return _context.abrupt("return", MoralisErd._proxy);
- case 2:
- _getErdJs = getErdJs(), ProxyProvider = _getErdJs.ProxyProvider;
- proxy = new ProxyProvider(MoralisErd.gatewayAddress());
- MoralisErd._proxy = proxy;
- return _context.abrupt("return", MoralisErd._proxy);
- case 6:
- case "end":
- return _context.stop();
- }
- }
- }, _callee);
- }));
- return function () {
- return _hwProxy.apply(this, arguments);
- };
- }()
- }, {
- key: "hwProvider",
- value: function () {
- return MoralisErd._hw;
- }
- }, {
- key: "enable",
- value: function () {
- var _enable = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
- var _getErdJs2, HWProvider, proxy, hw, success;
- return _regenerator.default.wrap(function (_context2) {
- while (1) {
- switch (_context2.prev = _context2.next) {
- case 0:
- _getErdJs2 = getErdJs(), HWProvider = _getErdJs2.HWProvider;
- _context2.next = 3;
- return MoralisErd.hwProxy();
- case 3:
- proxy = _context2.sent;
- hw = new HWProvider(proxy);
- _context2.next = 7;
- return hw.init();
- case 7:
- success = _context2.sent;
- if (success) {
- _context2.next = 10;
- break;
- }
- throw new Error(INIT_ERROR);
- case 10:
- MoralisErd._hw = hw;
- return _context2.abrupt("return", hw);
- case 12:
- case "end":
- return _context2.stop();
- }
- }
- }, _callee2);
- }));
- return function () {
- return _enable.apply(this, arguments);
- };
- }()
- }, {
- key: "authenticate",
- value: function () {
- var _authenticate = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
- var hw, address, erdAddress, accounts, message, data, signature, authData, user;
- return _regenerator.default.wrap(function (_context3) {
- while (1) {
- switch (_context3.prev = _context3.next) {
- case 0:
- _context3.next = 2;
- return MoralisErd.enable();
- case 2:
- hw = _context3.sent;
- _context3.next = 5;
- return hw.login();
- case 5:
- address = _context3.sent; // const account = await proxy.getAccount(address);
- erdAddress = address.toLowerCase();
- accounts = [erdAddress];
- message = MoralisErd.getSigningData();
- _context3.next = 11;
- return (0, _createSigningData.default)(message);
- case 11:
- data = _context3.sent;
- _context3.next = 14;
- return MoralisErd.sign(data);
- case 14:
- signature = _context3.sent;
- authData = {
- id: erdAddress,
- signature: signature,
- data: data
- };
- _context3.next = 18;
- return _ParseUser.default.logInWith('moralisErd', {
- authData: authData
- });
- case 18:
- user = _context3.sent;
- if (user) {
- _context3.next = 21;
- break;
- }
- throw new Error('Could not get user');
- case 21:
- _context3.next = 23;
- return user.setACL(new _ParseACL.default(user));
- case 23:
- user.addAllUnique('erdAccounts', accounts);
- user.set('erdAddress', erdAddress);
- _context3.next = 27;
- return user.save();
- case 27:
- return _context3.abrupt("return", user);
- case 28:
- case "end":
- return _context3.stop();
- }
- }
- }, _callee3);
- }));
- return function () {
- return _authenticate.apply(this, arguments);
- };
- }()
- }, {
- key: "link",
- value: function () {
- var _link = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(account, options) {
- var message, user, erdAddress, ErdAddress, query, erdAddressRecord, data, signature, authData;
- return _regenerator.default.wrap(function (_context4) {
- while (1) {
- switch (_context4.prev = _context4.next) {
- case 0:
- message = (options === null || options === void 0 ? void 0 : options.signingMessage) || MoralisErd.getSigningData();
- _context4.next = 3;
- return _ParseUser.default.current();
- case 3:
- user = _context4.sent;
- erdAddress = account.toLowerCase();
- ErdAddress = _ParseObject.default.extend('_ErdAddress');
- query = new _ParseQuery.default(ErdAddress);
- _context4.next = 9;
- return query.get(erdAddress).catch(function () {
- return null;
- });
- case 9:
- erdAddressRecord = _context4.sent;
- if (erdAddressRecord) {
- _context4.next = 20;
- break;
- }
- _context4.next = 13;
- return (0, _createSigningData.default)(message);
- case 13:
- data = _context4.sent;
- _context4.next = 16;
- return MoralisErd.sign(data);
- case 16:
- signature = _context4.sent;
- authData = {
- id: erdAddress,
- signature: signature,
- data: data
- };
- _context4.next = 20;
- return user.linkWith('moralisErd', {
- authData: authData
- });
- case 20:
- user.addAllUnique('erdAccounts', [erdAddress]);
- user.set('erdAddress', erdAddress);
- _context4.next = 24;
- return user.save();
- case 24:
- return _context4.abrupt("return", user);
- case 25:
- case "end":
- return _context4.stop();
- }
- }
- }, _callee4);
- }));
- return function () {
- return _link.apply(this, arguments);
- };
- }()
- }, {
- key: "unlink",
- value: function () {
- var _unlink = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(account) {
- var _user$get;
- var accountsLower, ErdAddress, query, erdAddressRecord, user, accounts, nextAccounts;
- return _regenerator.default.wrap(function (_context5) {
- while (1) {
- switch (_context5.prev = _context5.next) {
- case 0:
- accountsLower = account.toLowerCase();
- ErdAddress = _ParseObject.default.extend('_ErdAddress');
- query = new _ParseQuery.default(ErdAddress);
- _context5.next = 5;
- return query.get(accountsLower);
- case 5:
- erdAddressRecord = _context5.sent;
- _context5.next = 8;
- return erdAddressRecord.destroy();
- case 8:
- _context5.next = 10;
- return _ParseUser.default.current();
- case 10:
- user = _context5.sent;
- accounts = (_user$get = user.get('erdAccounts')) !== null && _user$get !== void 0 ? _user$get : [];
- nextAccounts = (0, _filter.default)(accounts).call(accounts, function (v) {
- return v !== accountsLower;
- });
- user.set('erdAccounts', nextAccounts);
- user.set('erdAddress', nextAccounts[0]);
- _context5.next = 17;
- return user._unlinkFrom('moralisErd');
- case 17:
- _context5.next = 19;
- return user.save();
- case 19:
- return _context5.abrupt("return", user);
- case 20:
- case "end":
- return _context5.stop();
- }
- }
- }, _callee5);
- }));
- return function () {
- return _unlink.apply(this, arguments);
- };
- }()
- }, {
- key: "sign",
- value: function () {
- var _sign = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6(data) {
- return _regenerator.default.wrap(function (_context6) {
- while (1) {
- switch (_context6.prev = _context6.next) {
- case 0:
- return _context6.abrupt("return", data);
- case 1:
- case "end":
- return _context6.stop();
- }
- }
- }, _callee6);
- }));
- return function () {
- return _sign.apply(this, arguments);
- };
- }()
- }, {
- key: "getSigningData",
- value: function () {
- return 'Moralis Authentication';
- }
- }]);
- return MoralisErd;
- }();
- var _default = MoralisErd;
- exports.default = _default;
- },{"./ParseACL":26,"./ParseObject":36,"./ParseQuery":39,"./ParseUser":44,"./createSigningData":64,"@babel/runtime-corejs3/core-js-stable/instance/filter":84,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/helpers/asyncToGenerator":144,"@babel/runtime-corejs3/helpers/classCallCheck":145,"@babel/runtime-corejs3/helpers/createClass":147,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/regenerator":167}],18:[function(_dereq_,module,exports){
- "use strict";
- var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
- var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
- _Object$defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = void 0;
- var _regenerator = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/regenerator"));
- var _concat = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/concat"));
- var _filter = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/filter"));
- var _reduce = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/reduce"));
- var _padStart = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/pad-start"));
- var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
- var _asyncToGenerator2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/asyncToGenerator"));
- var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
- var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
- var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
- var _toConsumableArray2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/toConsumableArray"));
- var _createSigningData = _interopRequireDefault(_dereq_("./createSigningData"));
- var _ParseUser = _interopRequireDefault(_dereq_("./ParseUser"));
- var _ParseQuery = _interopRequireDefault(_dereq_("./ParseQuery"));
- var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
- var _ParseACL = _interopRequireDefault(_dereq_("./ParseACL"));
- /* global window */
- /* global solanaWeb3 */
- var base64 = {
- decode: function (s) {
- return Uint8Array.from(atob(s), function (c) {
- return c.charCodeAt(0);
- });
- },
- encode: function (b) {
- return btoa(String.fromCharCode.apply(String, (0, _toConsumableArray2.default)(new Uint8Array(b))));
- }
- };
- var MoralisSol = /*#__PURE__*/function () {
- function MoralisSol() {
- (0, _classCallCheck2.default)(this, MoralisSol);
- }
- (0, _createClass2.default)(MoralisSol, null, [{
- key: "authenticate",
- value: function () {
- var _authenticate = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(options) {
- var _context, _user$get;
- var phantom, solAddress, accounts, message, data, signature, authData, user;
- return _regenerator.default.wrap(function (_context2) {
- while (1) {
- switch (_context2.prev = _context2.next) {
- case 0:
- _context2.next = 2;
- return MoralisSol.enable();
- case 2:
- phantom = _context2.sent;
- if (phantom) {
- _context2.next = 5;
- break;
- }
- throw new Error('Phantom wallet not available');
- case 5:
- solAddress = phantom.publicKey.toString();
- if (solAddress) {
- _context2.next = 8;
- break;
- }
- throw new Error('Address not found');
- case 8:
- accounts = [solAddress];
- message = (options === null || options === void 0 ? void 0 : options.signingMessage) || MoralisSol.getSigningData();
- _context2.next = 12;
- return (0, _createSigningData.default)(message);
- case 12:
- data = _context2.sent;
- _context2.next = 15;
- return MoralisSol.sign(data);
- case 15:
- signature = _context2.sent;
- authData = {
- id: solAddress,
- signature: signature,
- data: data
- };
- _context2.next = 19;
- return _ParseUser.default.logInWith('moralisSol', {
- authData: authData
- });
- case 19:
- user = _context2.sent;
- _context2.next = 22;
- return user.setACL(new _ParseACL.default(user));
- case 22:
- if (user) {
- _context2.next = 24;
- break;
- }
- throw new Error('Could not get user');
- case 24:
- user.set('solAccounts', uniq((0, _concat.default)(_context = []).call(_context, accounts, (_user$get = user.get('solAccounts')) !== null && _user$get !== void 0 ? _user$get : [])));
- user.set('solAddress', solAddress);
- _context2.next = 28;
- return user.save();
- case 28:
- return _context2.abrupt("return", user);
- case 29:
- case "end":
- return _context2.stop();
- }
- }
- }, _callee);
- }));
- return function () {
- return _authenticate.apply(this, arguments);
- };
- }()
- }, {
- key: "link",
- value: function () {
- var _link = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(account, options) {
- var _context3, _user$get2;
- var message, user, solAddress, SolAddress, query, solAddressRecord, data, signature, authData;
- return _regenerator.default.wrap(function (_context4) {
- while (1) {
- switch (_context4.prev = _context4.next) {
- case 0:
- message = (options === null || options === void 0 ? void 0 : options.signingMessage) || MoralisSol.getSigningData();
- _context4.next = 3;
- return _ParseUser.default.current();
- case 3:
- user = _context4.sent;
- solAddress = account;
- SolAddress = _ParseObject.default.extend('_SolAddress');
- query = new _ParseQuery.default(SolAddress);
- _context4.next = 9;
- return query.get(solAddress).catch(function () {
- return null;
- });
- case 9:
- solAddressRecord = _context4.sent;
- if (solAddressRecord) {
- _context4.next = 20;
- break;
- }
- _context4.next = 13;
- return (0, _createSigningData.default)(message);
- case 13:
- data = _context4.sent;
- _context4.next = 16;
- return MoralisSol.sign(solAddress, data);
- case 16:
- signature = _context4.sent;
- authData = {
- id: solAddress,
- signature: signature,
- data: data
- };
- _context4.next = 20;
- return user.linkWith('moralisSol', {
- authData: authData
- });
- case 20:
- user.set('SolAccounts', uniq((0, _concat.default)(_context3 = [solAddress]).call(_context3, (_user$get2 = user.get('SolAccounts')) !== null && _user$get2 !== void 0 ? _user$get2 : [])));
- user.set('solAddress', solAddress);
- _context4.next = 24;
- return user.save();
- case 24:
- return _context4.abrupt("return", user);
- case 25:
- case "end":
- return _context4.stop();
- }
- }
- }, _callee2);
- }));
- return function () {
- return _link.apply(this, arguments);
- };
- }()
- }, {
- key: "unlink",
- value: function () {
- var _unlink = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(account) {
- var _user$get3;
- var accountsLower, SolAddress, query, solAddressRecord, user, accounts, nextAccounts;
- return _regenerator.default.wrap(function (_context5) {
- while (1) {
- switch (_context5.prev = _context5.next) {
- case 0:
- accountsLower = account;
- SolAddress = _ParseObject.default.extend('_SolAddress');
- query = new _ParseQuery.default(SolAddress);
- _context5.next = 5;
- return query.get(accountsLower);
- case 5:
- solAddressRecord = _context5.sent;
- _context5.next = 8;
- return solAddressRecord.destroy();
- case 8:
- _context5.next = 10;
- return _ParseUser.default.current();
- case 10:
- user = _context5.sent;
- accounts = (_user$get3 = user.get('solAccounts')) !== null && _user$get3 !== void 0 ? _user$get3 : [];
- nextAccounts = (0, _filter.default)(accounts).call(accounts, function (v) {
- return v !== accountsLower;
- });
- user.set('solAccounts', nextAccounts);
- user.set('solAddress', nextAccounts[0]);
- _context5.next = 17;
- return user._unlinkFrom('moralisSol');
- case 17:
- _context5.next = 19;
- return user.save();
- case 19:
- return _context5.abrupt("return", user);
- case 20:
- case "end":
- return _context5.stop();
- }
- }
- }, _callee3);
- }));
- return function () {
- return _unlink.apply(this, arguments);
- };
- }()
- }, {
- key: "sign",
- value: function () {
- var _sign = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(message) {
- var phantom, encodedMessage, signedMessage;
- return _regenerator.default.wrap(function (_context6) {
- while (1) {
- switch (_context6.prev = _context6.next) {
- case 0:
- _context6.next = 2;
- return MoralisSol.enable();
- case 2:
- phantom = _context6.sent;
- encodedMessage = new TextEncoder().encode(message);
- _context6.next = 6;
- return phantom.signMessage(encodedMessage, 'utf8');
- case 6:
- signedMessage = _context6.sent;
- return _context6.abrupt("return", base64.encode(signedMessage.signature));
- case 8:
- case "end":
- return _context6.stop();
- }
- }
- }, _callee4);
- }));
- return function () {
- return _sign.apply(this, arguments);
- };
- }()
- }, {
- key: "getSigningData",
- value: function () {
- return 'Moralis Authentication';
- }
- }]);
- return MoralisSol;
- }();
- (0, _defineProperty2.default)(MoralisSol, "enable", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
- var provider;
- return _regenerator.default.wrap(function (_context8) {
- while (1) {
- switch (_context8.prev = _context8.next) {
- case 0:
- if (!(window && 'solana' in window)) {
- _context8.next = 17;
- break;
- }
- provider = window.solana;
- if (!provider.isPhantom) {
- _context8.next = 17;
- break;
- }
- _context8.prev = 3;
- _context8.next = 6;
- return provider.connect({
- onlyIfTrusted: true
- });
- case 6:
- _context8.next = 16;
- break;
- case 8:
- _context8.prev = 8;
- _context8.t0 = _context8["catch"](3);
- if (!(_context8.t0.message === 'User rejected the request.')) {
- _context8.next = 15;
- break;
- }
- _context8.next = 13;
- return provider.connect();
- case 13:
- _context8.next = 16;
- break;
- case 15:
- throw _context8.t0;
- case 16:
- return _context8.abrupt("return", provider);
- case 17:
- throw new Error('Phantom wallet not available');
- case 18:
- case "end":
- return _context8.stop();
- }
- }
- }, _callee5, null, [[3, 8]]);
- })));
- function toHexString(buffer
- /*: Buffer*/
- ) {
- return (0, _reduce.default)(buffer).call(buffer, function (str, byte) {
- var _context7;
- return str + (0, _padStart.default)(_context7 = byte.toString(16)).call(_context7, 2, '0');
- }, '');
- }
- function uniq(arr) {
- return (0, _filter.default)(arr).call(arr, function (v, i) {
- return (0, _indexOf.default)(arr).call(arr, v) === i;
- });
- }
- var _default = MoralisSol;
- exports.default = _default;
- },{"./ParseACL":26,"./ParseObject":36,"./ParseQuery":39,"./ParseUser":44,"./createSigningData":64,"@babel/runtime-corejs3/core-js-stable/instance/concat":81,"@babel/runtime-corejs3/core-js-stable/instance/filter":84,"@babel/runtime-corejs3/core-js-stable/instance/index-of":88,"@babel/runtime-corejs3/core-js-stable/instance/pad-start":91,"@babel/runtime-corejs3/core-js-stable/instance/reduce":92,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/helpers/asyncToGenerator":144,"@babel/runtime-corejs3/helpers/classCallCheck":145,"@babel/runtime-corejs3/helpers/createClass":147,"@babel/runtime-corejs3/helpers/defineProperty":148,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/helpers/toConsumableArray":163,"@babel/runtime-corejs3/regenerator":167}],19:[function(_dereq_,module,exports){
- "use strict";
- var _Object$keys2 = _dereq_("@babel/runtime-corejs3/core-js-stable/object/keys");
- var _Object$getOwnPropertySymbols = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols");
- var _filterInstanceProperty2 = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/filter");
- var _Object$getOwnPropertyDescriptor = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
- var _forEachInstanceProperty2 = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each");
- var _Object$getOwnPropertyDescriptors = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors");
- var _Object$defineProperties = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-properties");
- var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
- var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
- _Object$defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = void 0;
- var _regenerator = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/regenerator"));
- var _forEach = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
- var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/keys"));
- var _filter = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/filter"));
- var _includes = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/includes"));
- var _stringify = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/json/stringify"));
- var _asyncToGenerator2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/asyncToGenerator"));
- var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
- var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
- var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
- function ownKeys(object, enumerableOnly) {
- var keys = _Object$keys2(object);
- if (_Object$getOwnPropertySymbols) {
- var symbols = _Object$getOwnPropertySymbols(object);
- enumerableOnly && (symbols = _filterInstanceProperty2(symbols).call(symbols, function (sym) {
- return _Object$getOwnPropertyDescriptor(object, sym).enumerable;
- })), keys.push.apply(keys, symbols);
- }
- return keys;
- }
- function _objectSpread(target) {
- for (var i = 1; i < arguments.length; i++) {
- var _context10, _context11;
- var source = null != arguments[i] ? arguments[i] : {};
- i % 2 ? _forEachInstanceProperty2(_context10 = ownKeys(Object(source), !0)).call(_context10, function (key) {
- (0, _defineProperty2.default)(target, key, source[key]);
- }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty2(_context11 = ownKeys(Object(source))).call(_context11, function (key) {
- _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key));
- });
- }
- return target;
- }
- /**
- * Automatically generated code, via genSolanaAPI.js
- * Do not modify manually
- */
- var axios = _dereq_('axios');
- var SolanaApi = /*#__PURE__*/function () {
- function SolanaApi() {
- (0, _classCallCheck2.default)(this, SolanaApi);
- }
- (0, _createClass2.default)(SolanaApi, null, [{
- key: "initialize",
- value: // URL will be changed when api is deployed
- function (_ref) {
- var apiKey = _ref.apiKey,
- serverUrl = _ref.serverUrl,
- _ref$Moralis = _ref.Moralis,
- Moralis = _ref$Moralis === void 0 ? null : _ref$Moralis;
- if (!serverUrl && !apiKey) {
- throw new Error('SolanaApi.initialize failed: initialize with apiKey or serverUrl');
- }
- if (apiKey) this.apiKey = apiKey;
- if (serverUrl) this.serverUrl = serverUrl;
- this.Moralis = Moralis;
- }
- }, {
- key: "getBody",
- value: function (params, bodyParams) {
- var _this = this;
- if (!params || !bodyParams || !bodyParams.length) {
- return undefined;
- }
- var body = {};
- (0, _forEach.default)(bodyParams).call(bodyParams, function (_ref2) {
- var key = _ref2.key,
- type = _ref2.type,
- required = _ref2.required;
- if (params[key] === undefined) {
- if (required) throw new Error("param ".concat(key, " is required!"));
- } else if (type === _this.BodyParamTypes.setBody) {
- body = params[key];
- } else {
- body[key] = params[key];
- } // remove the param so it doesn't also get added as a query param
- delete params[key];
- });
- return body;
- }
- }, {
- key: "getParameterizedUrl",
- value: function (url, params) {
- var _context;
- if (!(0, _keys.default)(params).length) return url; // find url params, they start with :
- var requiredParams = (0, _filter.default)(_context = url.split('/')).call(_context, function (s) {
- return s && (0, _includes.default)(s).call(s, ':');
- });
- if (!requiredParams.length) return url;
- var parameterizedUrl = url;
- (0, _forEach.default)(requiredParams).call(requiredParams, function (p) {
- // strip the : and replace with param value
- var key = p.substr(1);
- var value = params[key];
- if (!value) {
- throw new Error("required param ".concat(key, " not provided"));
- }
- parameterizedUrl = parameterizedUrl.replace(p, value); // remove required param from param list
- // so it doesn't become part of the query params
- delete params[key];
- });
- return parameterizedUrl;
- }
- }, {
- key: "getApiRateLimitInfo",
- value: function (headers) {
- return {
- 'x-rate-limit-limit': headers['x-rate-limit-limit'],
- 'x-rate-limit-remaining-ttl': headers['x-rate-limit-remaining-ttl'],
- 'x-rate-limit-used': headers['x-rate-limit-used'],
- 'x-rate-limit-remaining-ip-ttl': headers['x-rate-limit-remaining-ip-ttl'],
- 'x-rate-limit-ip-used': headers['x-rate-limit-ip-used']
- };
- }
- }, {
- key: "getErrorMessage",
- value: function (error, url) {
- var _error$response, _error$response$data;
- return (error === null || error === void 0 ? void 0 : (_error$response = error.response) === null || _error$response === void 0 ? void 0 : (_error$response$data = _error$response.data) === null || _error$response$data === void 0 ? void 0 : _error$response$data.message) || (error === null || error === void 0 ? void 0 : error.message) || (error === null || error === void 0 ? void 0 : error.toString()) || "Solana API error while calling ".concat(url);
- }
- }, {
- key: "fetch",
- value: function () {
- var _fetch = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(_ref3) {
- var endpoint, providedParams, params, User, user;
- return _regenerator.default.wrap(function (_context2) {
- while (1) {
- switch (_context2.prev = _context2.next) {
- case 0:
- endpoint = _ref3.endpoint, providedParams = _ref3.params; // Make a shallow copy to prevent modification of original params
- params = _objectSpread({}, providedParams);
- if (this.Moralis) {
- User = this.Moralis.User;
- user = User.current();
- if (!params.address) {
- if (user) {
- params.address = user.get('solAddress');
- }
- }
- }
- if (!params.network) params.network = 'mainnet';
- if (!params.responseType) params.responseType = 'native';
- if (this.apiKey) {
- _context2.next = 7;
- break;
- }
- return _context2.abrupt("return", this.fetchFromServer(endpoint.name, params));
- case 7:
- return _context2.abrupt("return", this.fetchFromApi(endpoint, params));
- case 8:
- case "end":
- return _context2.stop();
- }
- }
- }, _callee, this);
- }));
- return function () {
- return _fetch.apply(this, arguments);
- };
- }()
- }, {
- key: "fetchFromApi",
- value: function () {
- var _fetchFromApi = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(endpoint, params) {
- var _endpoint$method, method, url, bodyParams, parameterizedUrl, body, response, _error$response2, status, headers, data, msg;
- return _regenerator.default.wrap(function (_context3) {
- while (1) {
- switch (_context3.prev = _context3.next) {
- case 0:
- _endpoint$method = endpoint.method, method = _endpoint$method === void 0 ? 'GET' : _endpoint$method, url = endpoint.url, bodyParams = endpoint.bodyParams;
- _context3.prev = 1;
- parameterizedUrl = this.getParameterizedUrl(url, params);
- body = this.getBody(params, bodyParams);
- _context3.next = 6;
- return axios(this.baseURL + parameterizedUrl, {
- params: params,
- method: method,
- body: body,
- headers: {
- Accept: 'application/json',
- 'Content-Type': 'application/json',
- 'x-api-key': this.apiKey
- }
- });
- case 6:
- response = _context3.sent;
- return _context3.abrupt("return", response.data);
- case 10:
- _context3.prev = 10;
- _context3.t0 = _context3["catch"](1);
- _error$response2 = _context3.t0.response, status = _error$response2.status, headers = _error$response2.headers, data = _error$response2.data;
- if (status === 429) {
- msg = "This Moralis Server is rate-limited because of the plan restrictions. See the details about the current rate and throttle limits: ".concat((0, _stringify.default)(this.getApiRateLimitInfo(headers)));
- } else {
- msg = this.getApiErrorMessage(_context3.t0, url);
- }
- throw new Error(msg);
- case 15:
- case "end":
- return _context3.stop();
- }
- }
- }, _callee2, this, [[1, 10]]);
- }));
- return function () {
- return _fetchFromApi.apply(this, arguments);
- };
- }()
- }, {
- key: "fetchFromServer",
- value: function () {
- var _fetchFromServer = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(name, options) {
- var http, user, response, _error$response3, _error$response3$data;
- return _regenerator.default.wrap(function (_context4) {
- while (1) {
- switch (_context4.prev = _context4.next) {
- case 0:
- if (this.serverUrl) {
- _context4.next = 2;
- break;
- }
- throw new Error('SolanaAPI not initialized, run Moralis.start() first');
- case 2:
- _context4.prev = 2;
- http = axios.create({
- baseURL: this.serverUrl
- });
- user = this.Moralis.User.current();
- if (user) {
- options._SessionToken = user.attributes.sessionToken;
- options._ApplicationId = this.Moralis.applicationId;
- }
- _context4.next = 8;
- return http.post("/functions/sol-".concat(name), options, {
- headers: {
- Accept: 'application/json',
- 'Content-Type': 'application/json'
- }
- });
- case 8:
- response = _context4.sent;
- return _context4.abrupt("return", response.data.result);
- case 12:
- _context4.prev = 12;
- _context4.t0 = _context4["catch"](2);
- if (!((_error$response3 = _context4.t0.response) !== null && _error$response3 !== void 0 && (_error$response3$data = _error$response3.data) !== null && _error$response3$data !== void 0 && _error$response3$data.error)) {
- _context4.next = 16;
- break;
- }
- throw new Error(_context4.t0.response.data.error);
- case 16:
- throw _context4.t0;
- case 17:
- case "end":
- return _context4.stop();
- }
- }
- }, _callee3, this, [[2, 12]]);
- }));
- return function () {
- return _fetchFromServer.apply(this, arguments);
- };
- }()
- }]);
- return SolanaApi;
- }();
- (0, _defineProperty2.default)(SolanaApi, "baseURL", 'https://solana-gateway.moralis.io');
- (0, _defineProperty2.default)(SolanaApi, "BodyParamTypes", {
- setBody: 'set body',
- property: 'property'
- });
- (0, _defineProperty2.default)(SolanaApi, "account", {
- balance: function () {
- var _balance = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() {
- var options,
- _args4 = arguments;
- return _regenerator.default.wrap(function (_context5) {
- while (1) {
- switch (_context5.prev = _context5.next) {
- case 0:
- options = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : {};
- return _context5.abrupt("return", SolanaApi.fetch({
- endpoint: {
- "method": "GET",
- "group": "account",
- "name": "balance",
- "url": "/account/:network/:address/balance"
- },
- params: options
- }));
- case 2:
- case "end":
- return _context5.stop();
- }
- }
- }, _callee4);
- }));
- return function () {
- return _balance.apply(this, arguments);
- };
- }(),
- getSPL: function () {
- var _getSPL = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
- var options,
- _args5 = arguments;
- return _regenerator.default.wrap(function (_context6) {
- while (1) {
- switch (_context6.prev = _context6.next) {
- case 0:
- options = _args5.length > 0 && _args5[0] !== undefined ? _args5[0] : {};
- return _context6.abrupt("return", SolanaApi.fetch({
- endpoint: {
- "method": "GET",
- "group": "account",
- "name": "getSPL",
- "url": "/account/:network/:address/tokens"
- },
- params: options
- }));
- case 2:
- case "end":
- return _context6.stop();
- }
- }
- }, _callee5);
- }));
- return function () {
- return _getSPL.apply(this, arguments);
- };
- }(),
- getNFTs: function () {
- var _getNFTs = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6() {
- var options,
- _args6 = arguments;
- return _regenerator.default.wrap(function (_context7) {
- while (1) {
- switch (_context7.prev = _context7.next) {
- case 0:
- options = _args6.length > 0 && _args6[0] !== undefined ? _args6[0] : {};
- return _context7.abrupt("return", SolanaApi.fetch({
- endpoint: {
- "method": "GET",
- "group": "account",
- "name": "getNFTs",
- "url": "/account/:network/:address/nft"
- },
- params: options
- }));
- case 2:
- case "end":
- return _context7.stop();
- }
- }
- }, _callee6);
- }));
- return function () {
- return _getNFTs.apply(this, arguments);
- };
- }(),
- getPortfolio: function () {
- var _getPortfolio = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7() {
- var options,
- _args7 = arguments;
- return _regenerator.default.wrap(function (_context8) {
- while (1) {
- switch (_context8.prev = _context8.next) {
- case 0:
- options = _args7.length > 0 && _args7[0] !== undefined ? _args7[0] : {};
- return _context8.abrupt("return", SolanaApi.fetch({
- endpoint: {
- "method": "GET",
- "group": "account",
- "name": "getPortfolio",
- "url": "/account/:network/:address/portfolio"
- },
- params: options
- }));
- case 2:
- case "end":
- return _context8.stop();
- }
- }
- }, _callee7);
- }));
- return function () {
- return _getPortfolio.apply(this, arguments);
- };
- }()
- });
- (0, _defineProperty2.default)(SolanaApi, "nft", {
- getNFTMetadata: function () {
- var _getNFTMetadata = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8() {
- var options,
- _args8 = arguments;
- return _regenerator.default.wrap(function (_context9) {
- while (1) {
- switch (_context9.prev = _context9.next) {
- case 0:
- options = _args8.length > 0 && _args8[0] !== undefined ? _args8[0] : {};
- return _context9.abrupt("return", SolanaApi.fetch({
- endpoint: {
- "method": "GET",
- "group": "nft",
- "name": "getNFTMetadata",
- "url": "/nft/:network/:address/metadata"
- },
- params: options
- }));
- case 2:
- case "end":
- return _context9.stop();
- }
- }
- }, _callee8);
- }));
- return function () {
- return _getNFTMetadata.apply(this, arguments);
- };
- }()
- });
- var _default = SolanaApi;
- exports.default = _default;
- },{"@babel/runtime-corejs3/core-js-stable/instance/filter":84,"@babel/runtime-corejs3/core-js-stable/instance/for-each":86,"@babel/runtime-corejs3/core-js-stable/instance/includes":87,"@babel/runtime-corejs3/core-js-stable/json/stringify":99,"@babel/runtime-corejs3/core-js-stable/object/define-properties":104,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor":108,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors":109,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols":110,"@babel/runtime-corejs3/core-js-stable/object/keys":112,"@babel/runtime-corejs3/helpers/asyncToGenerator":144,"@babel/runtime-corejs3/helpers/classCallCheck":145,"@babel/runtime-corejs3/helpers/createClass":147,"@babel/runtime-corejs3/helpers/defineProperty":148,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/regenerator":167,"axios":291}],20:[function(_dereq_,module,exports){
- "use strict";
- var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
- var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
- _Object$defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = void 0;
- var _regenerator = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/regenerator"));
- var _asyncToGenerator2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/asyncToGenerator"));
- var MoralisUI = {
- openPrompt: function () {
- return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
- return _regenerator.default.wrap(function (_context) {
- while (1) {
- switch (_context.prev = _context.next) {
- case 0:
- // eslint-disable-next-line no-console
- console.warn('No prompt supplied');
- case 1:
- case "end":
- return _context.stop();
- }
- }
- }, _callee);
- }))();
- }
- };
- var _default = MoralisUI;
- exports.default = _default;
- },{"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/helpers/asyncToGenerator":144,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/regenerator":167}],21:[function(_dereq_,module,exports){
- "use strict";
- var _typeof3 = _dereq_("@babel/runtime-corejs3/helpers/typeof");
- var _sliceInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/slice");
- var _Array$from = _dereq_("@babel/runtime-corejs3/core-js-stable/array/from");
- var _Symbol = _dereq_("@babel/runtime-corejs3/core-js-stable/symbol");
- var _getIteratorMethod = _dereq_("@babel/runtime-corejs3/core-js/get-iterator-method");
- var _Array$isArray = _dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array");
- var _WeakMap = _dereq_("@babel/runtime-corejs3/core-js-stable/weak-map");
- var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
- var _Object$getOwnPropertyDescriptor = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
- var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
- _Object$defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = void 0;
- var _filter = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/filter"));
- var _forEach = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
- var _concat = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/concat"));
- var _stringify = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/json/stringify"));
- var _map = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/map"));
- var _trim = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/trim"));
- var _find = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/find"));
- var _every = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/every"));
- var _values = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/values"));
- var _bind = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/bind"));
- var _regenerator = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/regenerator"));
- var _toConsumableArray2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/toConsumableArray"));
- var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
- var _asyncToGenerator2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/asyncToGenerator"));
- var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
- var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
- var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
- var _ethers = _dereq_("ethers");
- var _events = _interopRequireDefault(_dereq_("events"));
- var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
- var _ParseQuery = _interopRequireDefault(_dereq_("./ParseQuery"));
- var _ParseUser = _interopRequireDefault(_dereq_("./ParseUser"));
- var _ParseACL = _interopRequireDefault(_dereq_("./ParseACL"));
- var _MoralisErd = _interopRequireDefault(_dereq_("./MoralisErd"));
- var _MoralisDot = _interopRequireDefault(_dereq_("./MoralisDot"));
- var _MoralisSol = _interopRequireDefault(_dereq_("./MoralisSol"));
- var _TransferUtils = _interopRequireDefault(_dereq_("./TransferUtils"));
- var _Cloud = _dereq_("./Cloud");
- var _createSigningData = _interopRequireDefault(_dereq_("./createSigningData"));
- var _WalletConnectWeb3Connector = _interopRequireDefault(_dereq_("./Web3Connector/WalletConnectWeb3Connector"));
- var _InjectedWeb3Connector = _interopRequireDefault(_dereq_("./Web3Connector/InjectedWeb3Connector"));
- var _NetworkWeb3Connector = _interopRequireDefault(_dereq_("./Web3Connector/NetworkWeb3Connector"));
- var _ParseError = _interopRequireDefault(_dereq_("./ParseError"));
- var _InternalWeb3Provider = _interopRequireWildcard(_dereq_("./InternalWeb3Provider"));
- var _detectProvider = _interopRequireDefault(_dereq_("@metamask/detect-provider"));
- var _MagicWeb3Connector = _interopRequireDefault(_dereq_("./Web3Connector/MagicWeb3Connector"));
- var _Web3AuthConnector = _dereq_("./Web3Connector/Web3AuthConnector");
- var _context30, _context31, _context32, _context33, _context34, _context35;
- function _getRequireWildcardCache(nodeInterop) {
- if (typeof _WeakMap !== "function") return null;
- var cacheBabelInterop = new _WeakMap();
- var cacheNodeInterop = new _WeakMap();
- return (_getRequireWildcardCache = function (nodeInterop) {
- return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
- })(nodeInterop);
- }
- function _interopRequireWildcard(obj, nodeInterop) {
- if (!nodeInterop && obj && obj.__esModule) {
- return obj;
- }
- if (obj === null || _typeof3(obj) !== "object" && typeof obj !== "function") {
- return {
- default: obj
- };
- }
- var cache = _getRequireWildcardCache(nodeInterop);
- if (cache && cache.has(obj)) {
- return cache.get(obj);
- }
- var newObj = {};
- for (var key in obj) {
- if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
- var desc = _Object$defineProperty && _Object$getOwnPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null;
- if (desc && (desc.get || desc.set)) {
- _Object$defineProperty(newObj, key, desc);
- } else {
- newObj[key] = obj[key];
- }
- }
- }
- newObj.default = obj;
- if (cache) {
- cache.set(obj, newObj);
- }
- return newObj;
- }
- function _createForOfIteratorHelper(o, allowArrayLike) {
- var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"];
- if (!it) {
- if (_Array$isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
- if (it) o = it;
- var i = 0;
- var F = function () {};
- return {
- s: F,
- n: function () {
- if (i >= o.length) return {
- done: true
- };
- return {
- done: false,
- value: o[i++]
- };
- },
- e: function (_e) {
- throw _e;
- },
- f: F
- };
- }
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
- }
- var normalCompletion = true,
- didErr = false,
- err;
- return {
- s: function () {
- it = it.call(o);
- },
- n: function () {
- var step = it.next();
- normalCompletion = step.done;
- return step;
- },
- e: function (_e2) {
- didErr = true;
- err = _e2;
- },
- f: function () {
- try {
- if (!normalCompletion && it.return != null) it.return();
- } finally {
- if (didErr) throw err;
- }
- }
- };
- }
- function _unsupportedIterableToArray(o, minLen) {
- var _context36;
- if (!o) return;
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
- var n = _sliceInstanceProperty(_context36 = Object.prototype.toString.call(o)).call(_context36, 8, -1);
- if (n === "Object" && o.constructor) n = o.constructor.name;
- if (n === "Map" || n === "Set") return _Array$from(o);
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
- }
- function _arrayLikeToArray(arr, len) {
- if (len == null || len > arr.length) len = arr.length;
- for (var i = 0, arr2 = new Array(len); i < len; i++) {
- arr2[i] = arr[i];
- }
- return arr2;
- }
- var MoralisEmitter = new _events.default();
- var WARNING = 'Non ethereum enabled browser';
- var ERROR_WEB3_MISSING = 'Missing web3 instance, make sure to call Moralis.enableWeb3() or Moralis.authenticate()';
- var MoralisWeb3 = /*#__PURE__*/function () {
- function MoralisWeb3() {
- (0, _classCallCheck2.default)(this, MoralisWeb3);
- }
- (0, _createClass2.default)(MoralisWeb3, null, [{
- key: "addListener",
- value: // Ethers.js instance that will be set after calling enableWeb3
- // Internal web3 provider, containing the Ethers.js Web3 library for internal usage for handling transactions, contracts etc.
- function (eventName, listener) {
- MoralisEmitter.on(eventName, listener);
- return function () {
- return MoralisEmitter.removeListener(eventName, listener);
- };
- }
- }, {
- key: "on",
- value: function (eventName, listener) {
- MoralisEmitter.on(eventName, listener);
- return function () {
- return MoralisEmitter.removeListener(eventName, listener);
- };
- }
- }, {
- key: "once",
- value: function (eventName, listener) {
- MoralisEmitter.once(eventName, listener);
- return function () {
- return MoralisEmitter.removeListener(eventName, listener);
- };
- }
- }, {
- key: "removeListener",
- value: function (eventName, listener) {
- return MoralisEmitter.removeListener(eventName, listener);
- }
- }, {
- key: "off",
- value: function (eventName, listener) {
- return MoralisEmitter.off(eventName, listener);
- }
- }, {
- key: "removeAllListeners",
- value: function (eventName, listener) {
- return MoralisEmitter.removeAllListeners(eventName, listener);
- }
- }, {
- key: "isWeb3Enabled",
- value: function () {
- return this.ensureWeb3IsInstalled();
- }
- }, {
- key: "handleWeb3AccountChanged",
- value: function (account) {
- MoralisEmitter.emit(_InternalWeb3Provider.InternalWeb3Events.ACCOUNT_CHANGED, account);
- }
- }, {
- key: "handleWeb3ChainChanged",
- value: function (chainId) {
- var _this$internalWeb3Pro;
- this.web3 = (_this$internalWeb3Pro = this.internalWeb3Provider) === null || _this$internalWeb3Pro === void 0 ? void 0 : _this$internalWeb3Pro.web3;
- MoralisEmitter.emit(_InternalWeb3Provider.InternalWeb3Events.CHAIN_CHANGED, chainId);
- }
- }, {
- key: "handleWeb3Connect",
- value: function (connectInfo) {
- MoralisEmitter.emit(_InternalWeb3Provider.InternalWeb3Events.PROVIDER_CONNECT, connectInfo);
- }
- }, {
- key: "handleWeb3Disconnect",
- value: function (error) {
- if ((error === null || error === void 0 ? void 0 : error.message) === 'MetaMask: Disconnected from chain. Attempting to connect.') {
- return;
- }
- this.cleanup();
- MoralisEmitter.emit(_InternalWeb3Provider.InternalWeb3Events.PROVIDER_DISCONNECT, error);
- }
- }, {
- key: "enableWeb3",
- value: function () {
- var _enableWeb = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
- var _this = this;
- var options,
- _options$connector,
- Connector,
- connector,
- anyNetwork,
- provider,
- chainId,
- account,
- internalWeb3,
- _yield$this$internalW,
- web3,
- _args = arguments;
- return _regenerator.default.wrap(function (_context) {
- while (1) {
- switch (_context.prev = _context.next) {
- case 0:
- options = _args.length > 0 && _args[0] !== undefined ? _args[0] : {};
- if (!this.isEnablingWeb3) {
- _context.next = 3;
- break;
- }
- throw new Error('Cannot execute Moralis.enableWeb3(), as Moralis Moralis.enableWeb3() already has been called, but is not finished yet ');
- case 3:
- _context.prev = 3;
- this.isEnablingWeb3 = true;
- if (this.speedyNodeApiKey) {
- options.speedyNodeApiKey = this.speedyNodeApiKey;
- options.provider = 'network';
- }
- Connector = (_options$connector = options === null || options === void 0 ? void 0 : options.connector) !== null && _options$connector !== void 0 ? _options$connector : MoralisWeb3.getWeb3Connector(options === null || options === void 0 ? void 0 : options.provider);
- connector = new Connector(options);
- anyNetwork = (options === null || options === void 0 ? void 0 : options.anyNetwork) === true ? true : false;
- this.internalWeb3Provider = new _InternalWeb3Provider.default(connector, anyNetwork, options.privateKey);
- this.internalWeb3Provider.on(_InternalWeb3Provider.InternalWeb3Events.ACCOUNT_CHANGED, function (args) {
- return _this.handleWeb3AccountChanged(args);
- });
- this.internalWeb3Provider.on(_InternalWeb3Provider.InternalWeb3Events.CHAIN_CHANGED, function (args) {
- return _this.handleWeb3ChainChanged(args);
- });
- this.internalWeb3Provider.on(_InternalWeb3Provider.InternalWeb3Events.PROVIDER_CONNECT, function (args) {
- return _this.handleWeb3Connect(args);
- });
- this.internalWeb3Provider.on(_InternalWeb3Provider.InternalWeb3Events.PROVIDER_DISCONNECT, function (args) {
- return _this.handleWeb3Disconnect(args);
- });
- _context.prev = 14;
- _context.next = 17;
- return this.internalWeb3Provider.activate(options);
- case 17:
- _yield$this$internalW = _context.sent;
- provider = _yield$this$internalW.provider;
- chainId = _yield$this$internalW.chainId;
- account = _yield$this$internalW.account;
- internalWeb3 = _yield$this$internalW.web3;
- if (provider) {
- _context.next = 24;
- break;
- }
- throw new Error('Failed to activate, no provider returned');
- case 24:
- _context.next = 31;
- break;
- case 26:
- _context.prev = 26;
- _context.t0 = _context["catch"](14);
- _context.next = 30;
- return this.cleanup();
- case 30:
- throw _context.t0;
- case 31:
- web3 = internalWeb3;
- this.web3 = internalWeb3;
- MoralisEmitter.emit(_InternalWeb3Provider.InternalWeb3Events.WEB3_ENABLED, {
- chainId: chainId,
- account: account,
- connector: connector,
- provider: provider,
- web3: web3
- });
- return _context.abrupt("return", web3);
- case 37:
- _context.prev = 37;
- _context.t1 = _context["catch"](3);
- throw _context.t1;
- case 40:
- _context.prev = 40;
- this.isEnablingWeb3 = false;
- return _context.finish(40);
- case 43:
- case "end":
- return _context.stop();
- }
- }
- }, _callee, this, [[3, 37, 40, 43], [14, 26]]);
- }));
- return function () {
- return _enableWeb.apply(this, arguments);
- };
- }()
- }, {
- key: "isDotAuth",
- value: function (options) {
- switch (options === null || options === void 0 ? void 0 : options.type) {
- case 'dot':
- case 'polkadot':
- case 'kusama':
- return true;
- default:
- return false;
- }
- }
- }, {
- key: "isElrondAuth",
- value: function (options) {
- switch (options === null || options === void 0 ? void 0 : options.type) {
- case 'erd':
- case 'elrond':
- return true;
- default:
- return false;
- }
- }
- }, {
- key: "isSolAuth",
- value: function (options) {
- switch (options === null || options === void 0 ? void 0 : options.type) {
- case 'sol':
- return true;
- default:
- return false;
- }
- }
- }, {
- key: "getWeb3Connector",
- value: function (provider) {
- switch (provider) {
- case 'walletconnect':
- case 'walletConnect':
- case 'wc':
- return _WalletConnectWeb3Connector.default;
- case 'network':
- return _NetworkWeb3Connector.default;
- case 'magicLink':
- return _MagicWeb3Connector.default;
- case 'web3Auth':
- return _Web3AuthConnector.Web3Auth;
- default:
- return _InjectedWeb3Connector.default;
- }
- }
- }, {
- key: "deactivateWeb3",
- value: function () {
- var _deactivateWeb = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
- return _regenerator.default.wrap(function (_context2) {
- while (1) {
- switch (_context2.prev = _context2.next) {
- case 0:
- return _context2.abrupt("return", this.cleanup());
- case 1:
- case "end":
- return _context2.stop();
- }
- }
- }, _callee2, this);
- }));
- return function () {
- return _deactivateWeb.apply(this, arguments);
- };
- }()
- /**
- * Cleanup previously established provider
- */
- }, {
- key: "cleanup",
- value: function () {
- var _cleanup = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
- return _regenerator.default.wrap(function (_context3) {
- while (1) {
- switch (_context3.prev = _context3.next) {
- case 0:
- if (!this.isEnablingWeb3) {
- _context3.next = 2;
- break;
- }
- return _context3.abrupt("return");
- case 2:
- if (this.web3 && this.internalWeb3Provider) {
- MoralisEmitter.emit(_InternalWeb3Provider.InternalWeb3Events.WEB3_DEACTIVATED, {
- connector: this.internalWeb3Provider.connector,
- provider: this.internalWeb3Provider.provider
- });
- }
- if (!this.internalWeb3Provider) {
- _context3.next = 15;
- break;
- }
- this.internalWeb3Provider.removeListener(_InternalWeb3Provider.InternalWeb3Events.ACCOUNT_CHANGED, this.handleWeb3AccountChanged);
- this.internalWeb3Provider.removeListener(_InternalWeb3Provider.InternalWeb3Events.CHAIN_CHANGED, this.handleWeb3ChainChanged);
- this.internalWeb3Provider.removeListener(_InternalWeb3Provider.InternalWeb3Events.PROVIDER_CONNECT, this.handleWeb3Connect);
- this.internalWeb3Provider.removeListener(_InternalWeb3Provider.InternalWeb3Events.PROVIDER_DISCONNECT, this.handleWeb3Disconnect); // For example, if walletconnect has been enabled, then later on metamask, then wc is not the internalProvider, but still has an active connection
- _context3.prev = 8;
- _context3.next = 11;
- return this.internalWeb3Provider.deactivate();
- case 11:
- _context3.next = 15;
- break;
- case 13:
- _context3.prev = 13;
- _context3.t0 = _context3["catch"](8);
- case 15:
- this.internalWeb3Provider = null;
- this.web3 = null;
- case 17:
- case "end":
- return _context3.stop();
- }
- }
- }, _callee3, this, [[8, 13]]);
- }));
- return function () {
- return _cleanup.apply(this, arguments);
- };
- }()
- }, {
- key: "authenticate",
- value: function () {
- var _authenticate = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(options) {
- var isLoggedIn, _this$getInternalWeb, account, internalWeb3, signer, message, data, ethAddress, signature, authData, user;
- return _regenerator.default.wrap(function (_context4) {
- while (1) {
- switch (_context4.prev = _context4.next) {
- case 0:
- _context4.next = 2;
- return _ParseUser.default.currentAsync();
- case 2:
- isLoggedIn = _context4.sent;
- if (!isLoggedIn) {
- _context4.next = 6;
- break;
- }
- _context4.next = 6;
- return _ParseUser.default.logOut();
- case 6:
- if (!MoralisWeb3.isDotAuth(options)) {
- _context4.next = 8;
- break;
- }
- return _context4.abrupt("return", _MoralisDot.default.authenticate(options));
- case 8:
- if (!MoralisWeb3.isElrondAuth(options)) {
- _context4.next = 10;
- break;
- }
- return _context4.abrupt("return", _MoralisErd.default.authenticate(options));
- case 10:
- if (!MoralisWeb3.isSolAuth(options)) {
- _context4.next = 12;
- break;
- }
- return _context4.abrupt("return", _MoralisSol.default.authenticate(options));
- case 12:
- _context4.next = 14;
- return this.enableWeb3(options);
- case 14:
- _this$getInternalWeb = this.getInternalWeb3Provider(), account = _this$getInternalWeb.account, internalWeb3 = _this$getInternalWeb.web3, signer = _this$getInternalWeb.signer;
- if (account) {
- _context4.next = 17;
- break;
- }
- throw new Error('Cannot authenticate, no account returned from provider');
- case 17:
- message = (options === null || options === void 0 ? void 0 : options.signingMessage) || MoralisWeb3.getSigningData();
- _context4.next = 20;
- return (0, _createSigningData.default)(message);
- case 20:
- data = _context4.sent;
- ethAddress = account.toLowerCase();
- if (ethAddress) {
- _context4.next = 24;
- break;
- }
- throw new Error('Address not found');
- case 24:
- _context4.next = 26;
- return signer.signMessage(data);
- case 26:
- signature = _context4.sent;
- if (signature) {
- _context4.next = 29;
- break;
- }
- throw new Error('Data not signed');
- case 29:
- authData = {
- id: ethAddress,
- signature: signature,
- data: data
- };
- _context4.next = 32;
- return _ParseUser.default.logInWith('moralisEth', {
- authData: authData
- });
- case 32:
- user = _context4.sent;
- if (user) {
- _context4.next = 35;
- break;
- }
- throw new Error('Could not get user');
- case 35:
- _context4.next = 37;
- return user.setACL(new _ParseACL.default(user));
- case 37:
- user.addAllUnique('accounts', [ethAddress]);
- user.set('ethAddress', ethAddress);
- _context4.next = 41;
- return user.save(null, options);
- case 41:
- return _context4.abrupt("return", user);
- case 42:
- case "end":
- return _context4.stop();
- }
- }
- }, _callee4, this);
- }));
- return function () {
- return _authenticate.apply(this, arguments);
- };
- }()
- }, {
- key: "link",
- value: function () {
- var _link = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(account, options) {
- var _this$getInternalWeb2, signer, message, user, ethAddress, EthAddress, query, ethAddressRecord, data, signature, authData;
- return _regenerator.default.wrap(function (_context5) {
- while (1) {
- switch (_context5.prev = _context5.next) {
- case 0:
- _this$getInternalWeb2 = this.getInternalWeb3Provider(), signer = _this$getInternalWeb2.signer;
- message = (options === null || options === void 0 ? void 0 : options.signingMessage) || MoralisWeb3.getSigningData();
- _context5.next = 4;
- return _ParseUser.default.currentAsync();
- case 4:
- user = _context5.sent;
- ethAddress = account.toLowerCase();
- EthAddress = _ParseObject.default.extend('_EthAddress');
- query = new _ParseQuery.default(EthAddress);
- _context5.next = 10;
- return query.get(ethAddress).catch(function () {
- return null;
- });
- case 10:
- ethAddressRecord = _context5.sent;
- if (ethAddressRecord) {
- _context5.next = 23;
- break;
- }
- _context5.next = 14;
- return (0, _createSigningData.default)(message);
- case 14:
- data = _context5.sent;
- _context5.next = 17;
- return signer.signMessage(data);
- case 17:
- signature = _context5.sent;
- if (signature) {
- _context5.next = 20;
- break;
- }
- throw new Error('Data not signed');
- case 20:
- authData = {
- id: ethAddress,
- signature: signature,
- data: data
- };
- _context5.next = 23;
- return user.linkWith('moralisEth', {
- authData: authData
- });
- case 23:
- user.addAllUnique('accounts', [ethAddress]);
- user.set('ethAddress', ethAddress);
- _context5.next = 27;
- return user.save(null, options);
- case 27:
- return _context5.abrupt("return", user);
- case 28:
- case "end":
- return _context5.stop();
- }
- }
- }, _callee5, this);
- }));
- return function () {
- return _link.apply(this, arguments);
- };
- }()
- }, {
- key: "unlink",
- value: function () {
- var _unlink = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6(account) {
- var _user$get;
- var accountsLower, EthAddress, query, ethAddressRecord, user, accounts, nextAccounts;
- return _regenerator.default.wrap(function (_context6) {
- while (1) {
- switch (_context6.prev = _context6.next) {
- case 0:
- accountsLower = account.toLowerCase();
- EthAddress = _ParseObject.default.extend('_EthAddress');
- query = new _ParseQuery.default(EthAddress);
- _context6.next = 5;
- return query.get(accountsLower);
- case 5:
- ethAddressRecord = _context6.sent;
- _context6.next = 8;
- return ethAddressRecord.destroy();
- case 8:
- _context6.next = 10;
- return _ParseUser.default.currentAsync();
- case 10:
- user = _context6.sent;
- accounts = (_user$get = user.get('accounts')) !== null && _user$get !== void 0 ? _user$get : [];
- nextAccounts = (0, _filter.default)(accounts).call(accounts, function (v) {
- return v !== accountsLower;
- });
- user.set('accounts', nextAccounts);
- user.set('ethAddress', nextAccounts[0]);
- _context6.next = 17;
- return user._unlinkFrom('moralisEth');
- case 17:
- _context6.next = 19;
- return user.save();
- case 19:
- return _context6.abrupt("return", user);
- case 20:
- case "end":
- return _context6.stop();
- }
- }
- }, _callee6);
- }));
- return function () {
- return _unlink.apply(this, arguments);
- };
- }()
- }, {
- key: "initPlugins",
- value: function () {
- var _initPlugins = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8(installedPlugins) {
- var _this2 = this;
- var specs, allPlugins;
- return _regenerator.default.wrap(function (_context10) {
- while (1) {
- switch (_context10.prev = _context10.next) {
- case 0:
- _context10.t0 = installedPlugins;
- if (_context10.t0) {
- _context10.next = 5;
- break;
- }
- _context10.next = 4;
- return (0, _Cloud.run)('getPluginSpecs');
- case 4:
- _context10.t0 = _context10.sent;
- case 5:
- specs = _context10.t0;
- if (!this.Plugins) this.Plugins = {};
- if (specs) {
- _context10.next = 9;
- break;
- }
- return _context10.abrupt("return");
- case 9:
- allPlugins = this.Plugins;
- (0, _forEach.default)(specs).call(specs, function (plugin) {
- var _context7;
- allPlugins[plugin.name] = {};
- (0, _forEach.default)(_context7 = plugin.functions).call(_context7, function (f) {
- allPlugins[plugin.name][f] = /*#__PURE__*/function () {
- var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7(params, options) {
- var _context8;
- var response, error, triggerReturn;
- return _regenerator.default.wrap(function (_context9) {
- while (1) {
- switch (_context9.prev = _context9.next) {
- case 0:
- if (!options) options = {};
- _context9.next = 3;
- return (0, _Cloud.run)((0, _concat.default)(_context8 = "".concat(plugin.name, "_")).call(_context8, f), params);
- case 3:
- response = _context9.sent;
- if (response.data.success) {
- _context9.next = 7;
- break;
- }
- error = (0, _stringify.default)(response.data.data, null, 2);
- throw new Error("Something went wrong\n".concat(error));
- case 7:
- if (!(options.disableTriggers !== true)) {
- _context9.next = 13;
- break;
- }
- _context9.next = 10;
- return _this2.handleTriggers(response.data.result.triggers, response.data.result.data);
- case 10:
- triggerReturn = _context9.sent;
- if (!triggerReturn) {
- _context9.next = 13;
- break;
- }
- return _context9.abrupt("return", triggerReturn);
- case 13:
- return _context9.abrupt("return", response.data.result);
- case 14:
- case "end":
- return _context9.stop();
- }
- }
- }, _callee7);
- }));
- return function () {
- return _ref.apply(this, arguments);
- };
- }();
- });
- });
- this.Plugins = allPlugins;
- case 12:
- case "end":
- return _context10.stop();
- }
- }
- }, _callee8, this);
- }));
- return function () {
- return _initPlugins.apply(this, arguments);
- };
- }()
- }, {
- key: "handleTriggers",
- value: function () {
- var _handleTriggers = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee9(triggersArray, payload) {
- var _this3 = this;
- var _loop, i, _ret;
- return _regenerator.default.wrap(function (_context14) {
- while (1) {
- switch (_context14.prev = _context14.next) {
- case 0:
- if (triggersArray) {
- _context14.next = 2;
- break;
- }
- return _context14.abrupt("return");
- case 2:
- _loop = /*#__PURE__*/_regenerator.default.mark(function _loop(i) {
- var _triggersArray$i, _triggersArray$i$data, _triggersArray$i2, _triggersArray$i2$dat, _triggersArray$i$data2, _triggersArray$i3, _triggersArray$i3$dat, _triggersArray$i4, _triggersArray$i4$dat, _triggersArray$i5, _triggersArray$i6, _triggersArray$i7, _triggersArray$i8, _triggersArray$i9, _triggersArray$i10, _triggersArray$i11, _triggersArray$i12, _triggersArray$i13, _triggersArray$i14, _triggersArray$i15, _triggersArray$i16, _triggersArray$i17, _triggersArray$i18, _triggersArray$i20, _triggersArray$i22, _triggersArray$i23, _triggersArray$i24;
- var message, _response, _context11, _context12, _triggersArray$i19, _JSON$parse, domain, types, _message, signature, result, _JSON$parse2, _domain, _types, _message2;
- return _regenerator.default.wrap(function (_context13) {
- while (1) {
- switch (_context13.prev = _context13.next) {
- case 0:
- _context13.t0 = triggersArray[i].name;
- _context13.next = _context13.t0 === 'openUrl' ? 3 : _context13.t0 === 'web3Transaction' ? 5 : _context13.t0 === 'web3Sign' ? 18 : _context13.t0 === 'callPluginEndpoint' ? 33 : _context13.t0 === 'web3SignV4' ? 55 : 80;
- break;
- case 3:
- if (triggersArray[i].newTab) window.open(triggersArray[i].url);else window.open(triggersArray[i].url, '_self');
- return _context13.abrupt("break", 81);
- case 5:
- _context13.next = 7;
- return _this3.getInternalWeb3Provider().signer.sendTransaction({
- from: (_triggersArray$i = triggersArray[i]) === null || _triggersArray$i === void 0 ? void 0 : (_triggersArray$i$data = _triggersArray$i.data) === null || _triggersArray$i$data === void 0 ? void 0 : _triggersArray$i$data.from,
- to: (_triggersArray$i2 = triggersArray[i]) === null || _triggersArray$i2 === void 0 ? void 0 : (_triggersArray$i2$dat = _triggersArray$i2.data) === null || _triggersArray$i2$dat === void 0 ? void 0 : _triggersArray$i2$dat.to,
- value: _ethers.ethers.BigNumber.from((_triggersArray$i$data2 = (_triggersArray$i3 = triggersArray[i]) === null || _triggersArray$i3 === void 0 ? void 0 : (_triggersArray$i3$dat = _triggersArray$i3.data) === null || _triggersArray$i3$dat === void 0 ? void 0 : _triggersArray$i3$dat.value) !== null && _triggersArray$i$data2 !== void 0 ? _triggersArray$i$data2 : 0),
- data: (_triggersArray$i4 = triggersArray[i]) === null || _triggersArray$i4 === void 0 ? void 0 : (_triggersArray$i4$dat = _triggersArray$i4.data) === null || _triggersArray$i4$dat === void 0 ? void 0 : _triggersArray$i4$dat.data
- });
- case 7:
- _response = _context13.sent;
- if (!(((_triggersArray$i5 = triggersArray[i]) === null || _triggersArray$i5 === void 0 ? void 0 : _triggersArray$i5.shouldAwait) === true)) {
- _context13.next = 12;
- break;
- }
- _context13.next = 11;
- return _response.wait();
- case 11:
- _response = _context13.sent;
- case 12:
- // Save the response returned by the web3 trasanction
- if (((_triggersArray$i6 = triggersArray[i]) === null || _triggersArray$i6 === void 0 ? void 0 : _triggersArray$i6.saveResponse) === true) _this3.memoryCard.save(_response); // Return payload and response
- if (!(((_triggersArray$i7 = triggersArray[i]) === null || _triggersArray$i7 === void 0 ? void 0 : _triggersArray$i7.shouldReturnPayload) === true)) {
- _context13.next = 15;
- break;
- }
- return _context13.abrupt("return", {
- v: {
- payload: payload,
- response: _response
- }
- });
- case 15:
- if (!(((_triggersArray$i8 = triggersArray[i]) === null || _triggersArray$i8 === void 0 ? void 0 : _triggersArray$i8.shouldReturnResponse) === true)) {
- _context13.next = 17;
- break;
- }
- return _context13.abrupt("return", {
- v: _response
- });
- case 17:
- return _context13.abrupt("break", 81);
- case 18:
- if (triggersArray[i].message) {
- _context13.next = 20;
- break;
- }
- throw new Error('web3Sign trigger does not have a message to sign');
- case 20:
- if (triggersArray[i].signer) {
- _context13.next = 22;
- break;
- }
- throw new Error('web3Sign trigger signer address missing or invalid');
- case 22:
- // eslint-disable-next-line no-case-declarations
- message = JSON.parse(triggersArray[i].message);
- delete message.types.EIP712Domain; // eslint-disable-next-line no-case-declarations
- _context13.next = 26;
- return _this3.getInternalWeb3Provider().signer._signTypedData(message.domain, message.types, message.message);
- case 26:
- _response = _context13.sent; // Save response
- if (((_triggersArray$i9 = triggersArray[i]) === null || _triggersArray$i9 === void 0 ? void 0 : _triggersArray$i9.saveResponse) === true) _this3.memoryCard.save(_response); // Return payload and response
- if (!(((_triggersArray$i10 = triggersArray[i]) === null || _triggersArray$i10 === void 0 ? void 0 : _triggersArray$i10.shouldReturnPayload) === true)) {
- _context13.next = 30;
- break;
- }
- return _context13.abrupt("return", {
- v: {
- payload: payload,
- response: _response
- }
- });
- case 30:
- if (!(((_triggersArray$i11 = triggersArray[i]) === null || _triggersArray$i11 === void 0 ? void 0 : _triggersArray$i11.shouldReturnResponse) === true)) {
- _context13.next = 32;
- break;
- }
- return _context13.abrupt("return", {
- v: _response
- });
- case 32:
- return _context13.abrupt("break", 81);
- case 33:
- if (triggersArray[i].pluginName) {
- _context13.next = 35;
- break;
- }
- throw new Error('callPluginEndpoint trigger does not have an plugin name to call');
- case 35:
- if (triggersArray[i].endpoint) {
- _context13.next = 37;
- break;
- }
- throw new Error('callPluginEndpoint trigger does not have an endpoint to call');
- case 37:
- if (!(((_triggersArray$i12 = triggersArray[i]) === null || _triggersArray$i12 === void 0 ? void 0 : _triggersArray$i12.shouldAwait) === true)) {
- _context13.next = 42;
- break;
- } // Check if a saved response has to be used to fill a parameter needed by the plugin
- if (triggersArray[i].useSavedResponse === true) {
- triggersArray[i].params[triggersArray[i].savedResponseAs] = _this3.memoryCard.get(triggersArray[i].savedResponseAt);
- } // Call the endpoint
- _context13.next = 41;
- return (0, _Cloud.run)((0, _concat.default)(_context11 = "".concat(triggersArray[i].pluginName, "_")).call(_context11, triggersArray[i].endpoint), triggersArray[i].params);
- case 41:
- _response = _context13.sent;
- case 42:
- // Call a plugin endpoint (does NOT await)
- if (((_triggersArray$i13 = triggersArray[i]) === null || _triggersArray$i13 === void 0 ? void 0 : _triggersArray$i13.shouldAwait) === false) {
- // Check if a saved response has to be used to fill a parameter needed by the plugin
- if (triggersArray[i].useSavedResponse === true) {
- triggersArray[i].params[triggersArray[i].savedResponseAs] = _this3.memoryCard.get(triggersArray[i].savedResponseAt);
- } // Call the endpoint
- _response = (0, _Cloud.run)((0, _concat.default)(_context12 = "".concat(triggersArray[i].pluginName, "_")).call(_context12, triggersArray[i].endpoint), triggersArray[i].params);
- } // If the response contains a trigger, run it
- if (!(triggersArray[i].runResponseTrigger === true)) {
- _context13.next = 47;
- break;
- }
- _context13.next = 46;
- return _this3.handleTriggers(_response.data.result.triggers, _response.data.result.data);
- case 46:
- _response = _context13.sent;
- case 47:
- // Save response
- if (((_triggersArray$i14 = triggersArray[i]) === null || _triggersArray$i14 === void 0 ? void 0 : _triggersArray$i14.saveResponse) === true) _this3.memoryCard.save(_response); // If should not run the response trigger, continues the loop and does not return (to avoid breaking the loop execution and run other pending triggers)
- if (!(((_triggersArray$i15 = triggersArray[i]) === null || _triggersArray$i15 === void 0 ? void 0 : _triggersArray$i15.runResponseTrigger) === false)) {
- _context13.next = 50;
- break;
- }
- return _context13.abrupt("return", "continue");
- case 50:
- if (!(((_triggersArray$i16 = triggersArray[i]) === null || _triggersArray$i16 === void 0 ? void 0 : _triggersArray$i16.shouldReturnPayload) === true)) {
- _context13.next = 52;
- break;
- }
- return _context13.abrupt("return", {
- v: {
- payload: 'payload',
- response: _response
- }
- });
- case 52:
- if (!(((_triggersArray$i17 = triggersArray[i]) === null || _triggersArray$i17 === void 0 ? void 0 : _triggersArray$i17.shouldReturnResponse) === true)) {
- _context13.next = 54;
- break;
- }
- return _context13.abrupt("return", {
- v: _response
- });
- case 54:
- return _context13.abrupt("break", 81);
- case 55:
- if (triggersArray[i].parameters) {
- _context13.next = 57;
- break;
- }
- throw new Error('web3SignV4 trigger does not have `parameters` to sign');
- case 57:
- if (triggersArray[i].from) {
- _context13.next = 59;
- break;
- }
- throw new Error('web3SignV4 trigger does not have a `from` address');
- case 59:
- if (!(((_triggersArray$i18 = triggersArray[i]) === null || _triggersArray$i18 === void 0 ? void 0 : _triggersArray$i18.shouldAwait) === true)) {
- _context13.next = 74;
- break;
- }
- _context13.prev = 60;
- _JSON$parse = JSON.parse(triggersArray[i].parameters[1]), domain = _JSON$parse.domain, types = _JSON$parse.types, _message = _JSON$parse.message;
- if (types.EIP712Domain) {
- // Ethers.js will compute this automatically
- delete types.EIP712Domain;
- }
- _context13.next = 65;
- return _this3.getInternalWeb3Provider().signer._signTypedData(domain, types, _message);
- case 65:
- signature = _context13.sent;
- result = {
- result: signature
- };
- if (((_triggersArray$i19 = triggersArray[i]) === null || _triggersArray$i19 === void 0 ? void 0 : _triggersArray$i19.saveResponse) === true) _this3.memoryCard.save(result);
- _response = result;
- _context13.next = 74;
- break;
- case 71:
- _context13.prev = 71;
- _context13.t1 = _context13["catch"](60);
- throw new Error(_context13.t1.message || _context13.t1);
- case 74:
- if (((_triggersArray$i20 = triggersArray[i]) === null || _triggersArray$i20 === void 0 ? void 0 : _triggersArray$i20.shouldAwait) === false) {
- _JSON$parse2 = JSON.parse(triggersArray[i].parameters[1]), _domain = _JSON$parse2.domain, _types = _JSON$parse2.types, _message2 = _JSON$parse2.message;
- if (_types.EIP712Domain) {
- // Ethers.js will compute this automatically
- delete _types.EIP712Domain;
- }
- _this3.getInternalWeb3Provider().signer._signTypedData(_domain, _types, _message2) // eslint-disable-next-line no-loop-func
- .then(function (signature) {
- var _triggersArray$i21;
- var result = {
- result: signature
- };
- if (((_triggersArray$i21 = triggersArray[i]) === null || _triggersArray$i21 === void 0 ? void 0 : _triggersArray$i21.saveResponse) === true) _this3.memoryCard.save(result);
- _response = result;
- }).catch(function (error) {
- throw new Error(error.message || error);
- });
- } // Return payload and response
- if (!(((_triggersArray$i22 = triggersArray[i]) === null || _triggersArray$i22 === void 0 ? void 0 : _triggersArray$i22.shouldReturnPayload) === true)) {
- _context13.next = 77;
- break;
- }
- return _context13.abrupt("return", {
- v: {
- payload: payload,
- response: _response
- }
- });
- case 77:
- if (!(((_triggersArray$i23 = triggersArray[i]) === null || _triggersArray$i23 === void 0 ? void 0 : _triggersArray$i23.shouldReturnResponse) === true)) {
- _context13.next = 79;
- break;
- }
- return _context13.abrupt("return", {
- v: _response
- });
- case 79:
- return _context13.abrupt("break", 81);
- case 80:
- throw new Error("Unknown trigger: \"".concat((_triggersArray$i24 = triggersArray[i]) === null || _triggersArray$i24 === void 0 ? void 0 : _triggersArray$i24.name, "\""));
- case 81:
- case "end":
- return _context13.stop();
- }
- }
- }, _loop, null, [[60, 71]]);
- });
- i = 0;
- case 4:
- if (!(i < triggersArray.length)) {
- _context14.next = 14;
- break;
- }
- return _context14.delegateYield(_loop(i), "t0", 6);
- case 6:
- _ret = _context14.t0;
- if (!(_ret === "continue")) {
- _context14.next = 9;
- break;
- }
- return _context14.abrupt("continue", 11);
- case 9:
- if (!((0, _typeof2.default)(_ret) === "object")) {
- _context14.next = 11;
- break;
- }
- return _context14.abrupt("return", _ret.v);
- case 11:
- i++;
- _context14.next = 4;
- break;
- case 14:
- // Delete all saved data
- this.memoryCard.deleteSaved();
- case 15:
- case "end":
- return _context14.stop();
- }
- }
- }, _callee9, this);
- }));
- return function () {
- return _handleTriggers.apply(this, arguments);
- };
- }()
- }, {
- key: "getAllERC20",
- value: function () {
- var _getAllERC = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee10() {
- var _ref2,
- chain,
- address,
- result,
- _args11 = arguments;
- return _regenerator.default.wrap(function (_context15) {
- while (1) {
- switch (_context15.prev = _context15.next) {
- case 0:
- _ref2 = _args11.length > 0 && _args11[0] !== undefined ? _args11[0] : {}, chain = _ref2.chain, address = _ref2.address;
- _context15.next = 3;
- return (0, _Cloud.run)('getAllERC20', {
- chain: chain,
- address: address
- });
- case 3:
- result = _context15.sent;
- return _context15.abrupt("return", result);
- case 5:
- case "end":
- return _context15.stop();
- }
- }
- }, _callee10);
- }));
- return function () {
- return _getAllERC.apply(this, arguments);
- };
- }()
- }, {
- key: "getERC20",
- value: function () {
- var _getERC = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee11() {
- var _ref3,
- chain,
- address,
- symbol,
- tokenAddress,
- result,
- _args12 = arguments;
- return _regenerator.default.wrap(function (_context16) {
- while (1) {
- switch (_context16.prev = _context16.next) {
- case 0:
- _ref3 = _args12.length > 0 && _args12[0] !== undefined ? _args12[0] : {}, chain = _ref3.chain, address = _ref3.address, symbol = _ref3.symbol, tokenAddress = _ref3.tokenAddress;
- result = (0, _Cloud.run)('getERC20', {
- chain: chain,
- address: address,
- symbol: symbol,
- tokenAddress: tokenAddress
- });
- return _context16.abrupt("return", result);
- case 3:
- case "end":
- return _context16.stop();
- }
- }
- }, _callee11);
- }));
- return function () {
- return _getERC.apply(this, arguments);
- };
- }()
- }, {
- key: "getNFTs",
- value: function () {
- var _ref4 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
- _ref4$chain = _ref4.chain,
- chain = _ref4$chain === void 0 ? 'Eth' : _ref4$chain,
- _ref4$address = _ref4.address,
- address = _ref4$address === void 0 ? '' : _ref4$address;
- return (0, _Cloud.run)('getNFTs_old', {
- chain: chain,
- address: address
- });
- }
- }, {
- key: "getNFTsCount",
- value: function () {
- var _ref5 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
- _ref5$chain = _ref5.chain,
- chain = _ref5$chain === void 0 ? 'Eth' : _ref5$chain,
- _ref5$address = _ref5.address,
- address = _ref5$address === void 0 ? '' : _ref5$address;
- return (0, _Cloud.run)('getNFTsCount_old', {
- chain: chain,
- address: address
- });
- }
- }, {
- key: "getTransactions",
- value: function () {
- var _ref6 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
- _ref6$chain = _ref6.chain,
- chain = _ref6$chain === void 0 ? 'Eth' : _ref6$chain,
- _ref6$address = _ref6.address,
- address = _ref6$address === void 0 ? '' : _ref6$address,
- _ref6$order = _ref6.order,
- order = _ref6$order === void 0 ? 'desc' : _ref6$order;
- return (0, _Cloud.run)('getTransactions', {
- chain: chain,
- address: address,
- order: order
- });
- }
- }, {
- key: "getTransactionsCount",
- value: function () {
- var _ref7 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
- _ref7$chain = _ref7.chain,
- chain = _ref7$chain === void 0 ? 'Eth' : _ref7$chain,
- _ref7$address = _ref7.address,
- address = _ref7$address === void 0 ? '' : _ref7$address;
- return (0, _Cloud.run)('getTransactionsCount', {
- chain: chain,
- address: address
- });
- }
- }, {
- key: "transfer",
- value: function () {
- var _transfer = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee12() {
- var _ref8,
- _ref8$type,
- type,
- _ref8$receiver,
- receiver,
- _ref8$contractAddress,
- contractAddress,
- contract_address,
- _ref8$amount,
- amount,
- _ref8$tokenId,
- tokenId,
- token_id,
- _ref8$system,
- system,
- options,
- _this$getInternalWeb3,
- internalWeb3,
- sender,
- signer,
- transferOperation,
- customToken,
- result,
- _args13 = arguments;
- return _regenerator.default.wrap(function (_context17) {
- while (1) {
- switch (_context17.prev = _context17.next) {
- case 0:
- _ref8 = _args13.length > 0 && _args13[0] !== undefined ? _args13[0] : {}, _ref8$type = _ref8.type, type = _ref8$type === void 0 ? 'native' : _ref8$type, _ref8$receiver = _ref8.receiver, receiver = _ref8$receiver === void 0 ? '' : _ref8$receiver, _ref8$contractAddress = _ref8.contractAddress, contractAddress = _ref8$contractAddress === void 0 ? '' : _ref8$contractAddress, contract_address = _ref8.contract_address, _ref8$amount = _ref8.amount, amount = _ref8$amount === void 0 ? '' : _ref8$amount, _ref8$tokenId = _ref8.tokenId, tokenId = _ref8$tokenId === void 0 ? '' : _ref8$tokenId, token_id = _ref8.token_id, _ref8$system = _ref8.system, system = _ref8$system === void 0 ? 'evm' : _ref8$system; // Allow snake-case for backwards compatibility
- // eslint-disable-next-line camelcase
- contractAddress = contractAddress || contract_address; // eslint-disable-next-line camelcase
- tokenId = tokenId || token_id;
- options = {
- receiver: receiver,
- contractAddress: contractAddress,
- amount: amount,
- tokenId: tokenId,
- system: system
- };
- _TransferUtils.default.isSupportedType(type);
- _TransferUtils.default.validateInput(type, options);
- _this$getInternalWeb3 = this.getInternalWeb3Provider(), internalWeb3 = _this$getInternalWeb3.web3, sender = _this$getInternalWeb3.account, signer = _this$getInternalWeb3.signer;
- if (sender) {
- _context17.next = 9;
- break;
- }
- throw new Error('Sender address not found');
- case 9:
- if (tokenId) _TransferUtils.default.isUint256(tokenId);
- if (type !== 'native') {
- customToken = new _ethers.ethers.Contract(contractAddress, _TransferUtils.default.abi[type], signer);
- }
- _context17.t0 = type;
- _context17.next = _context17.t0 === 'native' ? 14 : _context17.t0 === 'erc20' ? 16 : _context17.t0 === 'erc721' ? 18 : _context17.t0 === 'erc1155' ? 20 : 22;
- break;
- case 14:
- transferOperation = signer.sendTransaction({
- to: receiver,
- value: _ethers.ethers.BigNumber.from(amount)
- });
- return _context17.abrupt("break", 23);
- case 16:
- transferOperation = customToken.transfer(receiver, amount, {
- from: sender
- });
- return _context17.abrupt("break", 23);
- case 18:
- transferOperation = customToken.safeTransferFrom(sender, receiver, "".concat(tokenId), {
- from: sender
- });
- return _context17.abrupt("break", 23);
- case 20:
- transferOperation = customToken.safeTransferFrom(sender, receiver, "".concat(tokenId), amount, '0x', {
- from: sender
- });
- return _context17.abrupt("break", 23);
- case 22:
- throw new Error("Unknown transfer type: \"".concat(type, "\""));
- case 23:
- _context17.next = 25;
- return transferOperation;
- case 25:
- result = _context17.sent;
- return _context17.abrupt("return", result);
- case 27:
- case "end":
- return _context17.stop();
- }
- }
- }, _callee12, this);
- }));
- return function () {
- return _transfer.apply(this, arguments);
- };
- }()
- }, {
- key: "executeFunction",
- value: function () {
- var _executeFunction = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee13() {
- var _functionData, _context25, _context26;
- var _ref9,
- contractAddress,
- abi,
- functionName,
- msgValue,
- _ref9$params,
- params,
- _ref9$overrides,
- overrides,
- contractOptions,
- _this$getInternalWeb4,
- account,
- internalWeb3,
- provider,
- signerOrProvider,
- overloadedFunction,
- functionData,
- _context18,
- _context19,
- nameWithoutTopics,
- topics,
- functionDataArray,
- possibleTopics,
- _functionDataArray,
- _possibleTopics,
- stateMutability,
- isReadFunction,
- currentAddress,
- errors,
- _iterator,
- _step,
- input,
- value,
- parsedInputs,
- contract,
- contractMethod,
- response,
- _args14 = arguments;
- return _regenerator.default.wrap(function (_context27) {
- while (1) {
- switch (_context27.prev = _context27.next) {
- case 0:
- _ref9 = _args14.length > 0 && _args14[0] !== undefined ? _args14[0] : {}, contractAddress = _ref9.contractAddress, abi = _ref9.abi, functionName = _ref9.functionName, msgValue = _ref9.msgValue, _ref9$params = _ref9.params, params = _ref9$params === void 0 ? {} : _ref9$params, _ref9$overrides = _ref9.overrides, overrides = _ref9$overrides === void 0 ? {} : _ref9$overrides;
- contractOptions = {};
- _this$getInternalWeb4 = this.getInternalWeb3Provider(), account = _this$getInternalWeb4.account, internalWeb3 = _this$getInternalWeb4.web3, provider = _this$getInternalWeb4.provider, signerOrProvider = _this$getInternalWeb4.signerOrProvider; // Check if function is an overloaded function definition. ex "getMessage(string)", or "getMessage()"
- overloadedFunction = functionName.match(/^(.+)\((.*)\)$/);
- if (!overloadedFunction) {
- _context27.next = 16;
- break;
- } // Get functiondata from overloaded function
- nameWithoutTopics = overloadedFunction[1];
- topics = (0, _filter.default)(_context18 = (0, _map.default)(_context19 = overloadedFunction[2].split(',')).call(_context19, function (topic) {
- return (0, _trim.default)(topic).call(topic);
- })).call(_context18, function (topic) {
- return !!topic;
- });
- functionDataArray = (0, _filter.default)(abi).call(abi, function (x) {
- return x.name === nameWithoutTopics;
- });
- if (!(functionDataArray.length === 0)) {
- _context27.next = 10;
- break;
- }
- throw new Error('Function does not exist in abi');
- case 10:
- functionData = (0, _find.default)(functionDataArray).call(functionDataArray, function (data) {
- var _data$inputs$length, _context20;
- return ((_data$inputs$length = data === null || data === void 0 ? void 0 : data.inputs.length) !== null && _data$inputs$length !== void 0 ? _data$inputs$length : 0) === topics.length && (0, _every.default)(_context20 = data.inputs).call(_context20, function (input, index) {
- return input.type === topics[index];
- });
- });
- if (functionData) {
- _context27.next = 14;
- break;
- }
- possibleTopics = (0, _map.default)(functionDataArray).call(functionDataArray, function (data) {
- var _context21, _context22;
- return (0, _concat.default)(_context21 = "".concat(data.name, "(")).call(_context21, (0, _map.default)(_context22 = data.inputs).call(_context22, function (input) {
- return input.type;
- }).join(','), ")");
- });
- throw new Error("Function with the provided topic does not exist in abi. Possible funcationNames: ".concat(possibleTopics.join(' ,')));
- case 14:
- _context27.next = 23;
- break;
- case 16:
- // Get functiondata from 'normal' function
- _functionDataArray = (0, _filter.default)(abi).call(abi, function (x) {
- return x.name === functionName;
- });
- if (!(_functionDataArray.length === 0)) {
- _context27.next = 19;
- break;
- }
- throw new Error('Function does not exist in abi');
- case 19:
- if (!(_functionDataArray.length > 1)) {
- _context27.next = 22;
- break;
- }
- _possibleTopics = (0, _map.default)(_functionDataArray).call(_functionDataArray, function (data) {
- var _context23, _context24;
- return (0, _concat.default)(_context23 = "".concat(data.name, "(")).call(_context23, (0, _map.default)(_context24 = data.inputs).call(_context24, function (input) {
- return input.type;
- }).join(','), ")");
- });
- throw new Error("Multiple function definitions found in the abi. Please include the topic in the functionName. Possible funcationNames: ".concat(_possibleTopics.join(' ,')));
- case 22:
- functionData = _functionDataArray[0];
- case 23:
- stateMutability = (_functionData = functionData) === null || _functionData === void 0 ? void 0 : _functionData.stateMutability;
- isReadFunction = stateMutability === 'view' || stateMutability === 'pure';
- if (isReadFunction) {
- _context27.next = 31;
- break;
- }
- if (params.from) {
- _context27.next = 31;
- break;
- }
- currentAddress = account;
- if (currentAddress) {
- _context27.next = 30;
- break;
- }
- throw new Error('From address is required');
- case 30:
- contractOptions.from = currentAddress;
- case 31:
- errors = [];
- _iterator = _createForOfIteratorHelper(functionData.inputs);
- try {
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
- input = _step.value;
- value = params[input.name];
- if (!value && typeof value !== 'number' && typeof value !== 'boolean' && input.name !== '') {
- errors.push("".concat(input.name, " is required"));
- }
- }
- } catch (err) {
- _iterator.e(err);
- } finally {
- _iterator.f();
- }
- if (!(errors.length > 0)) {
- _context27.next = 36;
- break;
- }
- throw errors;
- case 36:
- parsedInputs = (0, _map.default)(_context25 = functionData.inputs).call(_context25, function (x) {
- return params[x.name];
- });
- contract = new _ethers.ethers.Contract(contractAddress, abi, signerOrProvider);
- contractMethod = contract[functionName];
- if (contractMethod) {
- _context27.next = 41;
- break;
- }
- throw new Error("Cannot find function \"".concat(functionName, "\" on the contract"));
- case 41:
- _context27.next = 43;
- return contractMethod.apply(void 0, (0, _concat.default)(_context26 = (0, _toConsumableArray2.default)((0, _values.default)(parsedInputs))).call(_context26, [msgValue ? {
- value: _ethers.ethers.BigNumber.from("".concat(msgValue))
- } : {}]));
- case 43:
- response = _context27.sent;
- return _context27.abrupt("return", response);
- case 45:
- case "end":
- return _context27.stop();
- }
- }
- }, _callee13, this);
- }));
- return function () {
- return _executeFunction.apply(this, arguments);
- };
- }()
- }, {
- key: "getSigningData",
- value: function () {
- return "Moralis Authentication";
- }
- }, {
- key: "ensureWeb3IsInstalled",
- value: function () {
- return this.internalWeb3Provider && this.internalWeb3Provider.web3 ? true : false;
- }
- /**
- * Gets the internalWeb3Provider with validation to make sure it has been instansiated with 'enableWeb3()'
- */
- }, {
- key: "getInternalWeb3Provider",
- value: function () {
- if (!this.ensureWeb3IsInstalled()) throw new Error(ERROR_WEB3_MISSING);
- return this.internalWeb3Provider;
- }
- /**
- * Gets web3 from the internalWeb3Provider with validation to make sure it has been instansiated with 'enableWeb3()'
- */
- }, {
- key: "getInternalWeb3",
- value: function () {
- return this.getInternalWeb3Provider().web3;
- }
- }, {
- key: "provider",
- get: function () {
- var _this$internalWeb3Pro2, _this$internalWeb3Pro3;
- return (_this$internalWeb3Pro2 = (_this$internalWeb3Pro3 = this.internalWeb3Provider) === null || _this$internalWeb3Pro3 === void 0 ? void 0 : _this$internalWeb3Pro3.provider) !== null && _this$internalWeb3Pro2 !== void 0 ? _this$internalWeb3Pro2 : null;
- }
- }, {
- key: "connector",
- get: function () {
- var _this$internalWeb3Pro4, _this$internalWeb3Pro5;
- return (_this$internalWeb3Pro4 = (_this$internalWeb3Pro5 = this.internalWeb3Provider) === null || _this$internalWeb3Pro5 === void 0 ? void 0 : _this$internalWeb3Pro5.connector) !== null && _this$internalWeb3Pro4 !== void 0 ? _this$internalWeb3Pro4 : null;
- }
- }, {
- key: "connectorType",
- get: function () {
- var _this$connector$type, _this$connector;
- return (_this$connector$type = (_this$connector = this.connector) === null || _this$connector === void 0 ? void 0 : _this$connector.type) !== null && _this$connector$type !== void 0 ? _this$connector$type : null;
- }
- }, {
- key: "network",
- get: function () {
- var _this$connector$netwo, _this$connector2;
- return (_this$connector$netwo = (_this$connector2 = this.connector) === null || _this$connector2 === void 0 ? void 0 : _this$connector2.network) !== null && _this$connector$netwo !== void 0 ? _this$connector$netwo : null;
- }
- }, {
- key: "account",
- get: function () {
- var _this$internalWeb3Pro6, _this$internalWeb3Pro7;
- return (_this$internalWeb3Pro6 = (_this$internalWeb3Pro7 = this.internalWeb3Provider) === null || _this$internalWeb3Pro7 === void 0 ? void 0 : _this$internalWeb3Pro7.account) !== null && _this$internalWeb3Pro6 !== void 0 ? _this$internalWeb3Pro6 : null;
- }
- }, {
- key: "chainId",
- get: function () {
- var _this$internalWeb3Pro8, _this$internalWeb3Pro9;
- return (_this$internalWeb3Pro8 = (_this$internalWeb3Pro9 = this.internalWeb3Provider) === null || _this$internalWeb3Pro9 === void 0 ? void 0 : _this$internalWeb3Pro9.chainId) !== null && _this$internalWeb3Pro8 !== void 0 ? _this$internalWeb3Pro8 : null;
- }
- }, {
- key: "getChainId",
- value: function () {
- return this.chainId;
- }
- }, {
- key: "web3Library",
- get: function () {
- return _ethers.ethers;
- }
- }, {
- key: "_forwardToConnector",
- value: function (methodName, args) {
- var _this$getInternalWeb5 = this.getInternalWeb3Provider(),
- connector = _this$getInternalWeb5.connector;
- var hasMethod = Boolean(connector[methodName]);
- if (!hasMethod) {
- var _context28;
- throw new Error((0, _concat.default)(_context28 = "Cannot call ".concat(methodName, ", as it does not exist on connector type \"")).call(_context28, connector.type, "\""));
- }
- return connector[methodName].apply(connector, (0, _toConsumableArray2.default)(args));
- }
- }, {
- key: "switchNetwork",
- value: function () {
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
- args[_key] = arguments[_key];
- }
- return this._forwardToConnector('switchNetwork', args);
- }
- }, {
- key: "addNetwork",
- value: function () {
- for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
- args[_key2] = arguments[_key2];
- }
- return this._forwardToConnector('addNetwork', args);
- }
- }, {
- key: "isMetaMaskInstalled",
- value: function () {
- var _isMetaMaskInstalled = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee14() {
- return _regenerator.default.wrap(function (_context29) {
- while (1) {
- switch (_context29.prev = _context29.next) {
- case 0:
- _context29.next = 2;
- return (0, _detectProvider.default)();
- case 2:
- if (!_context29.sent) {
- _context29.next = 6;
- break;
- }
- _context29.t0 = true;
- _context29.next = 7;
- break;
- case 6:
- _context29.t0 = false;
- case 7:
- return _context29.abrupt("return", _context29.t0);
- case 8:
- case "end":
- return _context29.stop();
- }
- }
- }, _callee14);
- }));
- return function () {
- return _isMetaMaskInstalled.apply(this, arguments);
- };
- }()
- }]);
- return MoralisWeb3;
- }();
- (0, _defineProperty2.default)(MoralisWeb3, "speedyNodeApiKey", void 0);
- (0, _defineProperty2.default)(MoralisWeb3, "web3", null);
- (0, _defineProperty2.default)(MoralisWeb3, "internalWeb3Provider", null);
- (0, _defineProperty2.default)(MoralisWeb3, "Plugins", {});
- (0, _defineProperty2.default)(MoralisWeb3, "isEnablingWeb3", false);
- (0, _defineProperty2.default)(MoralisWeb3, "memoryCard", {
- save: function (what) {
- this.saved = what;
- },
- get: function (where) {
- if (!this.saved) throw new Error('Nothing saved to memory card'); // In case the saved data is not an object but a simple string or number
- if (where.length === 0) return this.getSaved();
- var tmp;
- var savedTmp = this.saved;
- for (var i = 0; i < where.length; i++) {
- tmp = savedTmp[where[i]];
- savedTmp = tmp;
- }
- return savedTmp;
- },
- getSaved: function () {
- return this.saved;
- },
- deleteSaved: function () {
- this.saved = undefined;
- }
- });
- MoralisWeb3.onConnect = (0, _bind.default)(_context30 = MoralisWeb3.on).call(_context30, MoralisWeb3, _InternalWeb3Provider.InternalWeb3Events.PROVIDER_CONNECT);
- MoralisWeb3.onDisconnect = (0, _bind.default)(_context31 = MoralisWeb3.on).call(_context31, MoralisWeb3, _InternalWeb3Provider.InternalWeb3Events.PROVIDER_DISCONNECT);
- MoralisWeb3.onWeb3Enabled = (0, _bind.default)(_context32 = MoralisWeb3.on).call(_context32, MoralisWeb3, _InternalWeb3Provider.InternalWeb3Events.WEB3_ENABLED);
- MoralisWeb3.onWeb3Deactivated = (0, _bind.default)(_context33 = MoralisWeb3.on).call(_context33, MoralisWeb3, _InternalWeb3Provider.InternalWeb3Events.WEB3_DEACTIVATED);
- MoralisWeb3.onChainChanged = (0, _bind.default)(_context34 = MoralisWeb3.on).call(_context34, MoralisWeb3, _InternalWeb3Provider.InternalWeb3Events.CHAIN_CHANGED);
- MoralisWeb3.onAccountChanged = (0, _bind.default)(_context35 = MoralisWeb3.on).call(_context35, MoralisWeb3, _InternalWeb3Provider.InternalWeb3Events.ACCOUNT_CHANGED);
- var _default = MoralisWeb3;
- exports.default = _default;
- },{"./Cloud":4,"./InternalWeb3Provider":10,"./MoralisDot":16,"./MoralisErd":17,"./MoralisSol":18,"./ParseACL":26,"./ParseError":29,"./ParseObject":36,"./ParseQuery":39,"./ParseUser":44,"./TransferUtils":51,"./Web3Connector/InjectedWeb3Connector":55,"./Web3Connector/MagicWeb3Connector":56,"./Web3Connector/NetworkWeb3Connector":58,"./Web3Connector/WalletConnectWeb3Connector":59,"./Web3Connector/Web3AuthConnector":60,"./createSigningData":64,"@babel/runtime-corejs3/core-js-stable/array/from":78,"@babel/runtime-corejs3/core-js-stable/array/is-array":79,"@babel/runtime-corejs3/core-js-stable/instance/bind":80,"@babel/runtime-corejs3/core-js-stable/instance/concat":81,"@babel/runtime-corejs3/core-js-stable/instance/every":83,"@babel/runtime-corejs3/core-js-stable/instance/filter":84,"@babel/runtime-corejs3/core-js-stable/instance/find":85,"@babel/runtime-corejs3/core-js-stable/instance/for-each":86,"@babel/runtime-corejs3/core-js-stable/instance/map":90,"@babel/runtime-corejs3/core-js-stable/instance/slice":93,"@babel/runtime-corejs3/core-js-stable/instance/trim":97,"@babel/runtime-corejs3/core-js-stable/json/stringify":99,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor":108,"@babel/runtime-corejs3/core-js-stable/object/values":113,"@babel/runtime-corejs3/core-js-stable/symbol":119,"@babel/runtime-corejs3/core-js-stable/weak-map":122,"@babel/runtime-corejs3/core-js/get-iterator-method":125,"@babel/runtime-corejs3/helpers/asyncToGenerator":144,"@babel/runtime-corejs3/helpers/classCallCheck":145,"@babel/runtime-corejs3/helpers/createClass":147,"@babel/runtime-corejs3/helpers/defineProperty":148,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/helpers/toConsumableArray":163,"@babel/runtime-corejs3/helpers/typeof":164,"@babel/runtime-corejs3/regenerator":167,"@metamask/detect-provider":289,"ethers":773,"events":775}],22:[function(_dereq_,module,exports){
- "use strict";
- var _Object$keys2 = _dereq_("@babel/runtime-corejs3/core-js-stable/object/keys");
- var _Object$getOwnPropertySymbols = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols");
- var _filterInstanceProperty2 = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/filter");
- var _Object$getOwnPropertyDescriptor = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
- var _forEachInstanceProperty2 = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each");
- var _Object$getOwnPropertyDescriptors = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors");
- var _Object$defineProperties = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-properties");
- var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
- var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
- _Object$defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = void 0;
- var _regenerator = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/regenerator"));
- var _forEach = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
- var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/keys"));
- var _filter = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/filter"));
- var _includes = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/includes"));
- var _stringify = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/json/stringify"));
- var _asyncToGenerator2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/asyncToGenerator"));
- var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
- var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
- var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
- function ownKeys(object, enumerableOnly) {
- var keys = _Object$keys2(object);
- if (_Object$getOwnPropertySymbols) {
- var symbols = _Object$getOwnPropertySymbols(object);
- enumerableOnly && (symbols = _filterInstanceProperty2(symbols).call(symbols, function (sym) {
- return _Object$getOwnPropertyDescriptor(object, sym).enumerable;
- })), keys.push.apply(keys, symbols);
- }
- return keys;
- }
- function _objectSpread(target) {
- for (var i = 1; i < arguments.length; i++) {
- var _context44, _context45;
- var source = null != arguments[i] ? arguments[i] : {};
- i % 2 ? _forEachInstanceProperty2(_context44 = ownKeys(Object(source), !0)).call(_context44, function (key) {
- (0, _defineProperty2.default)(target, key, source[key]);
- }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty2(_context45 = ownKeys(Object(source))).call(_context45, function (key) {
- _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key));
- });
- }
- return target;
- }
- /**
- * Automatically generated code, via genWeb3API.js
- * Do not modify manually
- */
- var axios = _dereq_('axios');
- var Web3Api = /*#__PURE__*/function () {
- function Web3Api() {
- (0, _classCallCheck2.default)(this, Web3Api);
- }
- (0, _createClass2.default)(Web3Api, null, [{
- key: "initialize",
- value: function (_ref) {
- var apiKey = _ref.apiKey,
- serverUrl = _ref.serverUrl,
- _ref$Moralis = _ref.Moralis,
- Moralis = _ref$Moralis === void 0 ? null : _ref$Moralis;
- if (!serverUrl && !apiKey) {
- throw new Error('Web3Api.initialize failed: initialize with apiKey or serverUrl');
- }
- if (apiKey) this.apiKey = apiKey;
- if (serverUrl) this.serverUrl = serverUrl;
- this.Moralis = Moralis;
- }
- }, {
- key: "getBody",
- value: function (params, bodyParams) {
- var _this = this;
- if (!params || !bodyParams || !bodyParams.length) {
- return undefined;
- }
- var body = {};
- (0, _forEach.default)(bodyParams).call(bodyParams, function (_ref2) {
- var key = _ref2.key,
- type = _ref2.type,
- required = _ref2.required;
- if (params[key] === undefined) {
- if (required) throw new Error("param ".concat(key, " is required!"));
- } else if (type === _this.BodyParamTypes.setBody) {
- body = params[key];
- } else {
- body[key] = params[key];
- } // remove the param so it doesn't also get added as a query param
- delete params[key];
- });
- return body;
- }
- }, {
- key: "getParameterizedUrl",
- value: function (url, params) {
- var _context;
- if (!(0, _keys.default)(params).length) return url; // find url params, they start with :
- var requiredParams = (0, _filter.default)(_context = url.split('/')).call(_context, function (s) {
- return s && (0, _includes.default)(s).call(s, ':');
- });
- if (!requiredParams.length) return url;
- var parameterizedUrl = url;
- (0, _forEach.default)(requiredParams).call(requiredParams, function (p) {
- // strip the : and replace with param value
- var key = p.substr(1);
- var value = params[key];
- if (!value) {
- throw new Error("required param ".concat(key, " not provided"));
- }
- parameterizedUrl = parameterizedUrl.replace(p, value); // remove required param from param list
- // so it doesn't become part of the query params
- delete params[key];
- });
- return parameterizedUrl;
- }
- }, {
- key: "getApiRateLimitInfo",
- value: function (headers) {
- return {
- 'x-rate-limit-limit': headers['x-rate-limit-limit'],
- 'x-rate-limit-remaining-ttl': headers['x-rate-limit-remaining-ttl'],
- 'x-rate-limit-used': headers['x-rate-limit-used'],
- 'x-rate-limit-remaining-ip-ttl': headers['x-rate-limit-remaining-ip-ttl'],
- 'x-rate-limit-ip-used': headers['x-rate-limit-ip-used']
- };
- }
- }, {
- key: "getApiErrorMessage",
- value: function (error, url) {
- var _error$response, _error$response$data;
- return (error === null || error === void 0 ? void 0 : (_error$response = error.response) === null || _error$response === void 0 ? void 0 : (_error$response$data = _error$response.data) === null || _error$response$data === void 0 ? void 0 : _error$response$data.message) || (error === null || error === void 0 ? void 0 : error.message) || (error === null || error === void 0 ? void 0 : error.toString()) || "Web3 API error while calling ".concat(url);
- }
- }, {
- key: "fetch",
- value: function () {
- var _fetch = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(_ref3) {
- var endpoint, providedParams, params, _this$Moralis, User, account, user;
- return _regenerator.default.wrap(function (_context2) {
- while (1) {
- switch (_context2.prev = _context2.next) {
- case 0:
- endpoint = _ref3.endpoint, providedParams = _ref3.params; // Make a shallow copy to prevent modification of original params
- params = _objectSpread({}, providedParams);
- if (this.Moralis) {
- _this$Moralis = this.Moralis, User = _this$Moralis.User, account = _this$Moralis.account;
- user = User.current();
- if (!params.address) {
- if (user) {
- params.address = user.get('ethAddress');
- } else if (account) {
- params.address = account;
- }
- }
- }
- if (this.apiKey) {
- _context2.next = 5;
- break;
- }
- return _context2.abrupt("return", this.fetchFromServer(endpoint.name, params));
- case 5:
- return _context2.abrupt("return", this.fetchFromApi(endpoint, params));
- case 6:
- case "end":
- return _context2.stop();
- }
- }
- }, _callee, this);
- }));
- return function () {
- return _fetch.apply(this, arguments);
- };
- }()
- }, {
- key: "fetchFromApi",
- value: function () {
- var _fetchFromApi = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(endpoint, params) {
- var _endpoint$method, method, url, bodyParams, parameterizedUrl, body, response, _error$response2, status, headers, data, msg;
- return _regenerator.default.wrap(function (_context3) {
- while (1) {
- switch (_context3.prev = _context3.next) {
- case 0:
- _endpoint$method = endpoint.method, method = _endpoint$method === void 0 ? 'GET' : _endpoint$method, url = endpoint.url, bodyParams = endpoint.bodyParams;
- _context3.prev = 1;
- parameterizedUrl = this.getParameterizedUrl(url, params);
- body = this.getBody(params, bodyParams);
- _context3.next = 6;
- return axios(this.baseURL + parameterizedUrl, {
- params: params,
- method: method,
- body: body,
- headers: {
- Accept: 'application/json',
- 'Content-Type': 'application/json',
- 'x-api-key': this.apiKey
- }
- });
- case 6:
- response = _context3.sent;
- return _context3.abrupt("return", response.data);
- case 10:
- _context3.prev = 10;
- _context3.t0 = _context3["catch"](1);
- _error$response2 = _context3.t0.response, status = _error$response2.status, headers = _error$response2.headers, data = _error$response2.data;
- if (status === 429) {
- msg = "This Moralis Server is rate-limited because of the plan restrictions. See the details about the current rate and throttle limits: ".concat((0, _stringify.default)(this.getApiRateLimitInfo(headers)));
- } else {
- msg = this.getApiErrorMessage(_context3.t0, url);
- }
- throw new Error(msg);
- case 15:
- case "end":
- return _context3.stop();
- }
- }
- }, _callee2, this, [[1, 10]]);
- }));
- return function () {
- return _fetchFromApi.apply(this, arguments);
- };
- }()
- }, {
- key: "fetchFromServer",
- value: function () {
- var _fetchFromServer = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(name, options) {
- var http, user, response, _error$response3, _error$response3$data;
- return _regenerator.default.wrap(function (_context4) {
- while (1) {
- switch (_context4.prev = _context4.next) {
- case 0:
- if (this.serverUrl) {
- _context4.next = 2;
- break;
- }
- throw new Error('Web3Api not initialized, run Moralis.start() first');
- case 2:
- _context4.prev = 2;
- http = axios.create({
- baseURL: this.serverUrl
- });
- if (!options.chain) options.chain = 'eth';
- user = this.Moralis.User.current();
- if (user) {
- options._SessionToken = user.attributes.sessionToken;
- options._ApplicationId = this.Moralis.applicationId;
- }
- _context4.next = 9;
- return http.post("/functions/".concat(name), options, {
- headers: {
- Accept: 'application/json',
- 'Content-Type': 'application/json'
- }
- });
- case 9:
- response = _context4.sent;
- return _context4.abrupt("return", response.data.result);
- case 13:
- _context4.prev = 13;
- _context4.t0 = _context4["catch"](2);
- if (!((_error$response3 = _context4.t0.response) !== null && _error$response3 !== void 0 && (_error$response3$data = _error$response3.data) !== null && _error$response3$data !== void 0 && _error$response3$data.error)) {
- _context4.next = 17;
- break;
- }
- throw new Error(_context4.t0.response.data.error);
- case 17:
- throw _context4.t0;
- case 18:
- case "end":
- return _context4.stop();
- }
- }
- }, _callee3, this, [[2, 13]]);
- }));
- return function () {
- return _fetchFromServer.apply(this, arguments);
- };
- }()
- }]);
- return Web3Api;
- }();
- (0, _defineProperty2.default)(Web3Api, "baseURL", 'https://deep-index.moralis.io/api/v2');
- (0, _defineProperty2.default)(Web3Api, "BodyParamTypes", {
- setBody: 'set body',
- property: 'property'
- });
- (0, _defineProperty2.default)(Web3Api, "native", {
- getBlock: function () {
- var _getBlock = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() {
- var options,
- _args4 = arguments;
- return _regenerator.default.wrap(function (_context5) {
- while (1) {
- switch (_context5.prev = _context5.next) {
- case 0:
- options = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : {};
- return _context5.abrupt("return", Web3Api.fetch({
- endpoint: {
- "method": "GET",
- "group": "native",
- "name": "getBlock",
- "url": "/block/:block_number_or_hash"
- },
- params: options
- }));
- case 2:
- case "end":
- return _context5.stop();
- }
- }
- }, _callee4);
- }));
- return function () {
- return _getBlock.apply(this, arguments);
- };
- }(),
- getDateToBlock: function () {
- var _getDateToBlock = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
- var options,
- _args5 = arguments;
- return _regenerator.default.wrap(function (_context6) {
- while (1) {
- switch (_context6.prev = _context6.next) {
- case 0:
- options = _args5.length > 0 && _args5[0] !== undefined ? _args5[0] : {};
- return _context6.abrupt("return", Web3Api.fetch({
- endpoint: {
- "method": "GET",
- "group": "native",
- "name": "getDateToBlock",
- "url": "/dateToBlock"
- },
- params: options
- }));
- case 2:
- case "end":
- return _context6.stop();
- }
- }
- }, _callee5);
- }));
- return function () {
- return _getDateToBlock.apply(this, arguments);
- };
- }(),
- getLogsByAddress: function () {
- var _getLogsByAddress = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6() {
- var options,
- _args6 = arguments;
- return _regenerator.default.wrap(function (_context7) {
- while (1) {
- switch (_context7.prev = _context7.next) {
- case 0:
- options = _args6.length > 0 && _args6[0] !== undefined ? _args6[0] : {};
- return _context7.abrupt("return", Web3Api.fetch({
- endpoint: {
- "method": "GET",
- "group": "native",
- "name": "getLogsByAddress",
- "url": "/:address/logs"
- },
- params: options
- }));
- case 2:
- case "end":
- return _context7.stop();
- }
- }
- }, _callee6);
- }));
- return function () {
- return _getLogsByAddress.apply(this, arguments);
- };
- }(),
- getNFTTransfersByBlock: function () {
- var _getNFTTransfersByBlock = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7() {
- var options,
- _args7 = arguments;
- return _regenerator.default.wrap(function (_context8) {
- while (1) {
- switch (_context8.prev = _context8.next) {
- case 0:
- options = _args7.length > 0 && _args7[0] !== undefined ? _args7[0] : {};
- return _context8.abrupt("return", Web3Api.fetch({
- endpoint: {
- "method": "GET",
- "group": "native",
- "name": "getNFTTransfersByBlock",
- "url": "/block/:block_number_or_hash/nft/transfers"
- },
- params: options
- }));
- case 2:
- case "end":
- return _context8.stop();
- }
- }
- }, _callee7);
- }));
- return function () {
- return _getNFTTransfersByBlock.apply(this, arguments);
- };
- }(),
- getTransaction: function () {
- var _getTransaction = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8() {
- var options,
- _args8 = arguments;
- return _regenerator.default.wrap(function (_context9) {
- while (1) {
- switch (_context9.prev = _context9.next) {
- case 0:
- options = _args8.length > 0 && _args8[0] !== undefined ? _args8[0] : {};
- return _context9.abrupt("return", Web3Api.fetch({
- endpoint: {
- "method": "GET",
- "group": "native",
- "name": "getTransaction",
- "url": "/transaction/:transaction_hash"
- },
- params: options
- }));
- case 2:
- case "end":
- return _context9.stop();
- }
- }
- }, _callee8);
- }));
- return function () {
- return _getTransaction.apply(this, arguments);
- };
- }(),
- getContractEvents: function () {
- var _getContractEvents = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee9() {
- var options,
- _args9 = arguments;
- return _regenerator.default.wrap(function (_context10) {
- while (1) {
- switch (_context10.prev = _context10.next) {
- case 0:
- options = _args9.length > 0 && _args9[0] !== undefined ? _args9[0] : {};
- return _context10.abrupt("return", Web3Api.fetch({
- endpoint: {
- "method": "POST",
- "group": "native",
- "name": "getContractEvents",
- "url": "/:address/events",
- "bodyParams": [{
- "key": "data",
- "type": "set body",
- "required": false
- }]
- },
- params: options
- }));
- case 2:
- case "end":
- return _context10.stop();
- }
- }
- }, _callee9);
- }));
- return function () {
- return _getContractEvents.apply(this, arguments);
- };
- }(),
- runContractFunction: function () {
- var _runContractFunction = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee10() {
- var options,
- _args10 = arguments;
- return _regenerator.default.wrap(function (_context11) {
- while (1) {
- switch (_context11.prev = _context11.next) {
- case 0:
- options = _args10.length > 0 && _args10[0] !== undefined ? _args10[0] : {};
- return _context11.abrupt("return", Web3Api.fetch({
- endpoint: {
- "method": "POST",
- "group": "native",
- "name": "runContractFunction",
- "url": "/:address/function",
- "bodyParams": [{
- "key": "abi",
- "type": "property",
- "required": true
- }, {
- "key": "params",
- "type": "property",
- "required": false
- }]
- },
- params: options
- }));
- case 2:
- case "end":
- return _context11.stop();
- }
- }
- }, _callee10);
- }));
- return function () {
- return _runContractFunction.apply(this, arguments);
- };
- }()
- });
- (0, _defineProperty2.default)(Web3Api, "account", {
- getTransactions: function () {
- var _getTransactions = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee11() {
- var options,
- _args11 = arguments;
- return _regenerator.default.wrap(function (_context12) {
- while (1) {
- switch (_context12.prev = _context12.next) {
- case 0:
- options = _args11.length > 0 && _args11[0] !== undefined ? _args11[0] : {};
- return _context12.abrupt("return", Web3Api.fetch({
- endpoint: {
- "method": "GET",
- "group": "account",
- "name": "getTransactions",
- "url": "/:address"
- },
- params: options
- }));
- case 2:
- case "end":
- return _context12.stop();
- }
- }
- }, _callee11);
- }));
- return function () {
- return _getTransactions.apply(this, arguments);
- };
- }(),
- getNativeBalance: function () {
- var _getNativeBalance = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee12() {
- var options,
- _args12 = arguments;
- return _regenerator.default.wrap(function (_context13) {
- while (1) {
- switch (_context13.prev = _context13.next) {
- case 0:
- options = _args12.length > 0 && _args12[0] !== undefined ? _args12[0] : {};
- return _context13.abrupt("return", Web3Api.fetch({
- endpoint: {
- "method": "GET",
- "group": "account",
- "name": "getNativeBalance",
- "url": "/:address/balance"
- },
- params: options
- }));
- case 2:
- case "end":
- return _context13.stop();
- }
- }
- }, _callee12);
- }));
- return function () {
- return _getNativeBalance.apply(this, arguments);
- };
- }(),
- getTokenBalances: function () {
- var _getTokenBalances = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee13() {
- var options,
- _args13 = arguments;
- return _regenerator.default.wrap(function (_context14) {
- while (1) {
- switch (_context14.prev = _context14.next) {
- case 0:
- options = _args13.length > 0 && _args13[0] !== undefined ? _args13[0] : {};
- return _context14.abrupt("return", Web3Api.fetch({
- endpoint: {
- "method": "GET",
- "group": "account",
- "name": "getTokenBalances",
- "url": "/:address/erc20"
- },
- params: options
- }));
- case 2:
- case "end":
- return _context14.stop();
- }
- }
- }, _callee13);
- }));
- return function () {
- return _getTokenBalances.apply(this, arguments);
- };
- }(),
- getTokenTransfers: function () {
- var _getTokenTransfers = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee14() {
- var options,
- _args14 = arguments;
- return _regenerator.default.wrap(function (_context15) {
- while (1) {
- switch (_context15.prev = _context15.next) {
- case 0:
- options = _args14.length > 0 && _args14[0] !== undefined ? _args14[0] : {};
- return _context15.abrupt("return", Web3Api.fetch({
- endpoint: {
- "method": "GET",
- "group": "account",
- "name": "getTokenTransfers",
- "url": "/:address/erc20/transfers"
- },
- params: options
- }));
- case 2:
- case "end":
- return _context15.stop();
- }
- }
- }, _callee14);
- }));
- return function () {
- return _getTokenTransfers.apply(this, arguments);
- };
- }(),
- getNFTs: function () {
- var _getNFTs = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee15() {
- var options,
- _args15 = arguments;
- return _regenerator.default.wrap(function (_context16) {
- while (1) {
- switch (_context16.prev = _context16.next) {
- case 0:
- options = _args15.length > 0 && _args15[0] !== undefined ? _args15[0] : {};
- return _context16.abrupt("return", Web3Api.fetch({
- endpoint: {
- "method": "GET",
- "group": "account",
- "name": "getNFTs",
- "url": "/:address/nft"
- },
- params: options
- }));
- case 2:
- case "end":
- return _context16.stop();
- }
- }
- }, _callee15);
- }));
- return function () {
- return _getNFTs.apply(this, arguments);
- };
- }(),
- getNFTTransfers: function () {
- var _getNFTTransfers = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee16() {
- var options,
- _args16 = arguments;
- return _regenerator.default.wrap(function (_context17) {
- while (1) {
- switch (_context17.prev = _context17.next) {
- case 0:
- options = _args16.length > 0 && _args16[0] !== undefined ? _args16[0] : {};
- return _context17.abrupt("return", Web3Api.fetch({
- endpoint: {
- "method": "GET",
- "group": "account",
- "name": "getNFTTransfers",
- "url": "/:address/nft/transfers"
- },
- params: options
- }));
- case 2:
- case "end":
- return _context17.stop();
- }
- }
- }, _callee16);
- }));
- return function () {
- return _getNFTTransfers.apply(this, arguments);
- };
- }(),
- getNFTsForContract: function () {
- var _getNFTsForContract = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee17() {
- var options,
- _args17 = arguments;
- return _regenerator.default.wrap(function (_context18) {
- while (1) {
- switch (_context18.prev = _context18.next) {
- case 0:
- options = _args17.length > 0 && _args17[0] !== undefined ? _args17[0] : {};
- return _context18.abrupt("return", Web3Api.fetch({
- endpoint: {
- "method": "GET",
- "group": "account",
- "name": "getNFTsForContract",
- "url": "/:address/nft/:token_address"
- },
- params: options
- }));
- case 2:
- case "end":
- return _context18.stop();
- }
- }
- }, _callee17);
- }));
- return function () {
- return _getNFTsForContract.apply(this, arguments);
- };
- }()
- });
- (0, _defineProperty2.default)(Web3Api, "token", {
- getTokenMetadata: function () {
- var _getTokenMetadata = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee18() {
- var options,
- _args18 = arguments;
- return _regenerator.default.wrap(function (_context19) {
- while (1) {
- switch (_context19.prev = _context19.next) {
- case 0:
- options = _args18.length > 0 && _args18[0] !== undefined ? _args18[0] : {};
- return _context19.abrupt("return", Web3Api.fetch({
- endpoint: {
- "method": "GET",
- "group": "token",
- "name": "getTokenMetadata",
- "url": "/erc20/metadata"
- },
- params: options
- }));
- case 2:
- case "end":
- return _context19.stop();
- }
- }
- }, _callee18);
- }));
- return function () {
- return _getTokenMetadata.apply(this, arguments);
- };
- }(),
- getNFTTrades: function () {
- var _getNFTTrades = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee19() {
- var options,
- _args19 = arguments;
- return _regenerator.default.wrap(function (_context20) {
- while (1) {
- switch (_context20.prev = _context20.next) {
- case 0:
- options = _args19.length > 0 && _args19[0] !== undefined ? _args19[0] : {};
- return _context20.abrupt("return", Web3Api.fetch({
- endpoint: {
- "method": "GET",
- "group": "token",
- "name": "getNFTTrades",
- "url": "/nft/:address/trades"
- },
- params: options
- }));
- case 2:
- case "end":
- return _context20.stop();
- }
- }
- }, _callee19);
- }));
- return function () {
- return _getNFTTrades.apply(this, arguments);
- };
- }(),
- getNFTLowestPrice: function () {
- var _getNFTLowestPrice = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee20() {
- var options,
- _args20 = arguments;
- return _regenerator.default.wrap(function (_context21) {
- while (1) {
- switch (_context21.prev = _context21.next) {
- case 0:
- options = _args20.length > 0 && _args20[0] !== undefined ? _args20[0] : {};
- return _context21.abrupt("return", Web3Api.fetch({
- endpoint: {
- "method": "GET",
- "group": "token",
- "name": "getNFTLowestPrice",
- "url": "/nft/:address/lowestprice"
- },
- params: options
- }));
- case 2:
- case "end":
- return _context21.stop();
- }
- }
- }, _callee20);
- }));
- return function () {
- return _getNFTLowestPrice.apply(this, arguments);
- };
- }(),
- getTokenMetadataBySymbol: function () {
- var _getTokenMetadataBySymbol = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee21() {
- var options,
- _args21 = arguments;
- return _regenerator.default.wrap(function (_context22) {
- while (1) {
- switch (_context22.prev = _context22.next) {
- case 0:
- options = _args21.length > 0 && _args21[0] !== undefined ? _args21[0] : {};
- return _context22.abrupt("return", Web3Api.fetch({
- endpoint: {
- "method": "GET",
- "group": "token",
- "name": "getTokenMetadataBySymbol",
- "url": "/erc20/metadata/symbols"
- },
- params: options
- }));
- case 2:
- case "end":
- return _context22.stop();
- }
- }
- }, _callee21);
- }));
- return function () {
- return _getTokenMetadataBySymbol.apply(this, arguments);
- };
- }(),
- getTokenPrice: function () {
- var _getTokenPrice = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee22() {
- var options,
- _args22 = arguments;
- return _regenerator.default.wrap(function (_context23) {
- while (1) {
- switch (_context23.prev = _context23.next) {
- case 0:
- options = _args22.length > 0 && _args22[0] !== undefined ? _args22[0] : {};
- return _context23.abrupt("return", Web3Api.fetch({
- endpoint: {
- "method": "GET",
- "group": "token",
- "name": "getTokenPrice",
- "url": "/erc20/:address/price"
- },
- params: options
- }));
- case 2:
- case "end":
- return _context23.stop();
- }
- }
- }, _callee22);
- }));
- return function () {
- return _getTokenPrice.apply(this, arguments);
- };
- }(),
- getTokenAddressTransfers: function () {
- var _getTokenAddressTransfers = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee23() {
- var options,
- _args23 = arguments;
- return _regenerator.default.wrap(function (_context24) {
- while (1) {
- switch (_context24.prev = _context24.next) {
- case 0:
- options = _args23.length > 0 && _args23[0] !== undefined ? _args23[0] : {};
- return _context24.abrupt("return", Web3Api.fetch({
- endpoint: {
- "method": "GET",
- "group": "token",
- "name": "getTokenAddressTransfers",
- "url": "/erc20/:address/transfers"
- },
- params: options
- }));
- case 2:
- case "end":
- return _context24.stop();
- }
- }
- }, _callee23);
- }));
- return function () {
- return _getTokenAddressTransfers.apply(this, arguments);
- };
- }(),
- getTokenAllowance: function () {
- var _getTokenAllowance = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee24() {
- var options,
- _args24 = arguments;
- return _regenerator.default.wrap(function (_context25) {
- while (1) {
- switch (_context25.prev = _context25.next) {
- case 0:
- options = _args24.length > 0 && _args24[0] !== undefined ? _args24[0] : {};
- return _context25.abrupt("return", Web3Api.fetch({
- endpoint: {
- "method": "GET",
- "group": "token",
- "name": "getTokenAllowance",
- "url": "/erc20/:address/allowance"
- },
- params: options
- }));
- case 2:
- case "end":
- return _context25.stop();
- }
- }
- }, _callee24);
- }));
- return function () {
- return _getTokenAllowance.apply(this, arguments);
- };
- }(),
- searchNFTs: function () {
- var _searchNFTs = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee25() {
- var options,
- _args25 = arguments;
- return _regenerator.default.wrap(function (_context26) {
- while (1) {
- switch (_context26.prev = _context26.next) {
- case 0:
- options = _args25.length > 0 && _args25[0] !== undefined ? _args25[0] : {};
- return _context26.abrupt("return", Web3Api.fetch({
- endpoint: {
- "method": "GET",
- "group": "token",
- "name": "searchNFTs",
- "url": "/nft/search"
- },
- params: options
- }));
- case 2:
- case "end":
- return _context26.stop();
- }
- }
- }, _callee25);
- }));
- return function () {
- return _searchNFTs.apply(this, arguments);
- };
- }(),
- getNftTransfersFromToBlock: function () {
- var _getNftTransfersFromToBlock = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee26() {
- var options,
- _args26 = arguments;
- return _regenerator.default.wrap(function (_context27) {
- while (1) {
- switch (_context27.prev = _context27.next) {
- case 0:
- options = _args26.length > 0 && _args26[0] !== undefined ? _args26[0] : {};
- return _context27.abrupt("return", Web3Api.fetch({
- endpoint: {
- "method": "GET",
- "group": "token",
- "name": "getNftTransfersFromToBlock",
- "url": "/nft/transfers"
- },
- params: options
- }));
- case 2:
- case "end":
- return _context27.stop();
- }
- }
- }, _callee26);
- }));
- return function () {
- return _getNftTransfersFromToBlock.apply(this, arguments);
- };
- }(),
- getAllTokenIds: function () {
- var _getAllTokenIds = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee27() {
- var options,
- _args27 = arguments;
- return _regenerator.default.wrap(function (_context28) {
- while (1) {
- switch (_context28.prev = _context28.next) {
- case 0:
- options = _args27.length > 0 && _args27[0] !== undefined ? _args27[0] : {};
- return _context28.abrupt("return", Web3Api.fetch({
- endpoint: {
- "method": "GET",
- "group": "token",
- "name": "getAllTokenIds",
- "url": "/nft/:address"
- },
- params: options
- }));
- case 2:
- case "end":
- return _context28.stop();
- }
- }
- }, _callee27);
- }));
- return function () {
- return _getAllTokenIds.apply(this, arguments);
- };
- }(),
- getContractNFTTransfers: function () {
- var _getContractNFTTransfers = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee28() {
- var options,
- _args28 = arguments;
- return _regenerator.default.wrap(function (_context29) {
- while (1) {
- switch (_context29.prev = _context29.next) {
- case 0:
- options = _args28.length > 0 && _args28[0] !== undefined ? _args28[0] : {};
- return _context29.abrupt("return", Web3Api.fetch({
- endpoint: {
- "method": "GET",
- "group": "token",
- "name": "getContractNFTTransfers",
- "url": "/nft/:address/transfers"
- },
- params: options
- }));
- case 2:
- case "end":
- return _context29.stop();
- }
- }
- }, _callee28);
- }));
- return function () {
- return _getContractNFTTransfers.apply(this, arguments);
- };
- }(),
- getNFTOwners: function () {
- var _getNFTOwners = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee29() {
- var options,
- _args29 = arguments;
- return _regenerator.default.wrap(function (_context30) {
- while (1) {
- switch (_context30.prev = _context30.next) {
- case 0:
- options = _args29.length > 0 && _args29[0] !== undefined ? _args29[0] : {};
- return _context30.abrupt("return", Web3Api.fetch({
- endpoint: {
- "method": "GET",
- "group": "token",
- "name": "getNFTOwners",
- "url": "/nft/:address/owners"
- },
- params: options
- }));
- case 2:
- case "end":
- return _context30.stop();
- }
- }
- }, _callee29);
- }));
- return function () {
- return _getNFTOwners.apply(this, arguments);
- };
- }(),
- getNFTMetadata: function () {
- var _getNFTMetadata = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee30() {
- var options,
- _args30 = arguments;
- return _regenerator.default.wrap(function (_context31) {
- while (1) {
- switch (_context31.prev = _context31.next) {
- case 0:
- options = _args30.length > 0 && _args30[0] !== undefined ? _args30[0] : {};
- return _context31.abrupt("return", Web3Api.fetch({
- endpoint: {
- "method": "GET",
- "group": "token",
- "name": "getNFTMetadata",
- "url": "/nft/:address/metadata"
- },
- params: options
- }));
- case 2:
- case "end":
- return _context31.stop();
- }
- }
- }, _callee30);
- }));
- return function () {
- return _getNFTMetadata.apply(this, arguments);
- };
- }(),
- reSyncMetadata: function () {
- var _reSyncMetadata = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee31() {
- var options,
- _args31 = arguments;
- return _regenerator.default.wrap(function (_context32) {
- while (1) {
- switch (_context32.prev = _context32.next) {
- case 0:
- options = _args31.length > 0 && _args31[0] !== undefined ? _args31[0] : {};
- return _context32.abrupt("return", Web3Api.fetch({
- endpoint: {
- "method": "GET",
- "group": "token",
- "name": "reSyncMetadata",
- "url": "/nft/:address/:token_id/metadata/resync"
- },
- params: options
- }));
- case 2:
- case "end":
- return _context32.stop();
- }
- }
- }, _callee31);
- }));
- return function () {
- return _reSyncMetadata.apply(this, arguments);
- };
- }(),
- syncNFTContract: function () {
- var _syncNFTContract = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee32() {
- var options,
- _args32 = arguments;
- return _regenerator.default.wrap(function (_context33) {
- while (1) {
- switch (_context33.prev = _context33.next) {
- case 0:
- options = _args32.length > 0 && _args32[0] !== undefined ? _args32[0] : {};
- return _context33.abrupt("return", Web3Api.fetch({
- endpoint: {
- "method": "PUT",
- "group": "token",
- "name": "syncNFTContract",
- "url": "/nft/:address/sync"
- },
- params: options
- }));
- case 2:
- case "end":
- return _context33.stop();
- }
- }
- }, _callee32);
- }));
- return function () {
- return _syncNFTContract.apply(this, arguments);
- };
- }(),
- getTokenIdMetadata: function () {
- var _getTokenIdMetadata = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee33() {
- var options,
- _args33 = arguments;
- return _regenerator.default.wrap(function (_context34) {
- while (1) {
- switch (_context34.prev = _context34.next) {
- case 0:
- options = _args33.length > 0 && _args33[0] !== undefined ? _args33[0] : {};
- return _context34.abrupt("return", Web3Api.fetch({
- endpoint: {
- "method": "GET",
- "group": "token",
- "name": "getTokenIdMetadata",
- "url": "/nft/:address/:token_id"
- },
- params: options
- }));
- case 2:
- case "end":
- return _context34.stop();
- }
- }
- }, _callee33);
- }));
- return function () {
- return _getTokenIdMetadata.apply(this, arguments);
- };
- }(),
- getTokenIdOwners: function () {
- var _getTokenIdOwners = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee34() {
- var options,
- _args34 = arguments;
- return _regenerator.default.wrap(function (_context35) {
- while (1) {
- switch (_context35.prev = _context35.next) {
- case 0:
- options = _args34.length > 0 && _args34[0] !== undefined ? _args34[0] : {};
- return _context35.abrupt("return", Web3Api.fetch({
- endpoint: {
- "method": "GET",
- "group": "token",
- "name": "getTokenIdOwners",
- "url": "/nft/:address/:token_id/owners"
- },
- params: options
- }));
- case 2:
- case "end":
- return _context35.stop();
- }
- }
- }, _callee34);
- }));
- return function () {
- return _getTokenIdOwners.apply(this, arguments);
- };
- }(),
- getWalletTokenIdTransfers: function () {
- var _getWalletTokenIdTransfers = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee35() {
- var options,
- _args35 = arguments;
- return _regenerator.default.wrap(function (_context36) {
- while (1) {
- switch (_context36.prev = _context36.next) {
- case 0:
- options = _args35.length > 0 && _args35[0] !== undefined ? _args35[0] : {};
- return _context36.abrupt("return", Web3Api.fetch({
- endpoint: {
- "method": "GET",
- "group": "token",
- "name": "getWalletTokenIdTransfers",
- "url": "/nft/:address/:token_id/transfers"
- },
- params: options
- }));
- case 2:
- case "end":
- return _context36.stop();
- }
- }
- }, _callee35);
- }));
- return function () {
- return _getWalletTokenIdTransfers.apply(this, arguments);
- };
- }()
- });
- (0, _defineProperty2.default)(Web3Api, "resolve", {
- resolveDomain: function () {
- var _resolveDomain = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee36() {
- var options,
- _args36 = arguments;
- return _regenerator.default.wrap(function (_context37) {
- while (1) {
- switch (_context37.prev = _context37.next) {
- case 0:
- options = _args36.length > 0 && _args36[0] !== undefined ? _args36[0] : {};
- return _context37.abrupt("return", Web3Api.fetch({
- endpoint: {
- "method": "GET",
- "group": "resolve",
- "name": "resolveDomain",
- "url": "/resolve/:domain"
- },
- params: options
- }));
- case 2:
- case "end":
- return _context37.stop();
- }
- }
- }, _callee36);
- }));
- return function () {
- return _resolveDomain.apply(this, arguments);
- };
- }(),
- resolveAddress: function () {
- var _resolveAddress = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee37() {
- var options,
- _args37 = arguments;
- return _regenerator.default.wrap(function (_context38) {
- while (1) {
- switch (_context38.prev = _context38.next) {
- case 0:
- options = _args37.length > 0 && _args37[0] !== undefined ? _args37[0] : {};
- return _context38.abrupt("return", Web3Api.fetch({
- endpoint: {
- "method": "GET",
- "group": "resolve",
- "name": "resolveAddress",
- "url": "/resolve/:address/reverse"
- },
- params: options
- }));
- case 2:
- case "end":
- return _context38.stop();
- }
- }
- }, _callee37);
- }));
- return function () {
- return _resolveAddress.apply(this, arguments);
- };
- }()
- });
- (0, _defineProperty2.default)(Web3Api, "defi", {
- getPairReserves: function () {
- var _getPairReserves = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee38() {
- var options,
- _args38 = arguments;
- return _regenerator.default.wrap(function (_context39) {
- while (1) {
- switch (_context39.prev = _context39.next) {
- case 0:
- options = _args38.length > 0 && _args38[0] !== undefined ? _args38[0] : {};
- return _context39.abrupt("return", Web3Api.fetch({
- endpoint: {
- "method": "GET",
- "group": "defi",
- "name": "getPairReserves",
- "url": "/:pair_address/reserves"
- },
- params: options
- }));
- case 2:
- case "end":
- return _context39.stop();
- }
- }
- }, _callee38);
- }));
- return function () {
- return _getPairReserves.apply(this, arguments);
- };
- }(),
- getPairAddress: function () {
- var _getPairAddress = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee39() {
- var options,
- _args39 = arguments;
- return _regenerator.default.wrap(function (_context40) {
- while (1) {
- switch (_context40.prev = _context40.next) {
- case 0:
- options = _args39.length > 0 && _args39[0] !== undefined ? _args39[0] : {};
- return _context40.abrupt("return", Web3Api.fetch({
- endpoint: {
- "method": "GET",
- "group": "defi",
- "name": "getPairAddress",
- "url": "/:token0_address/:token1_address/pairAddress"
- },
- params: options
- }));
- case 2:
- case "end":
- return _context40.stop();
- }
- }
- }, _callee39);
- }));
- return function () {
- return _getPairAddress.apply(this, arguments);
- };
- }()
- });
- (0, _defineProperty2.default)(Web3Api, "storage", {
- uploadFolder: function () {
- var _uploadFolder = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee40() {
- var options,
- _args40 = arguments;
- return _regenerator.default.wrap(function (_context41) {
- while (1) {
- switch (_context41.prev = _context41.next) {
- case 0:
- options = _args40.length > 0 && _args40[0] !== undefined ? _args40[0] : {};
- return _context41.abrupt("return", Web3Api.fetch({
- endpoint: {
- "method": "POST",
- "group": "storage",
- "name": "uploadFolder",
- "url": "/ipfs/uploadFolder",
- "bodyParams": [{
- "key": "data",
- "type": "set body",
- "required": false
- }]
- },
- params: options
- }));
- case 2:
- case "end":
- return _context41.stop();
- }
- }
- }, _callee40);
- }));
- return function () {
- return _uploadFolder.apply(this, arguments);
- };
- }()
- });
- (0, _defineProperty2.default)(Web3Api, "info", {
- web3ApiVersion: function () {
- var _web3ApiVersion = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee41() {
- var options,
- _args41 = arguments;
- return _regenerator.default.wrap(function (_context42) {
- while (1) {
- switch (_context42.prev = _context42.next) {
- case 0:
- options = _args41.length > 0 && _args41[0] !== undefined ? _args41[0] : {};
- return _context42.abrupt("return", Web3Api.fetch({
- endpoint: {
- "method": "GET",
- "group": "info",
- "name": "web3ApiVersion",
- "url": "/web3/version"
- },
- params: options
- }));
- case 2:
- case "end":
- return _context42.stop();
- }
- }
- }, _callee41);
- }));
- return function () {
- return _web3ApiVersion.apply(this, arguments);
- };
- }(),
- endpointWeights: function () {
- var _endpointWeights = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee42() {
- var options,
- _args42 = arguments;
- return _regenerator.default.wrap(function (_context43) {
- while (1) {
- switch (_context43.prev = _context43.next) {
- case 0:
- options = _args42.length > 0 && _args42[0] !== undefined ? _args42[0] : {};
- return _context43.abrupt("return", Web3Api.fetch({
- endpoint: {
- "method": "GET",
- "group": "info",
- "name": "endpointWeights",
- "url": "/info/endpointWeights"
- },
- params: options
- }));
- case 2:
- case "end":
- return _context43.stop();
- }
- }
- }, _callee42);
- }));
- return function () {
- return _endpointWeights.apply(this, arguments);
- };
- }()
- });
- var _default = Web3Api;
- exports.default = _default;
- },{"@babel/runtime-corejs3/core-js-stable/instance/filter":84,"@babel/runtime-corejs3/core-js-stable/instance/for-each":86,"@babel/runtime-corejs3/core-js-stable/instance/includes":87,"@babel/runtime-corejs3/core-js-stable/json/stringify":99,"@babel/runtime-corejs3/core-js-stable/object/define-properties":104,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor":108,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors":109,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols":110,"@babel/runtime-corejs3/core-js-stable/object/keys":112,"@babel/runtime-corejs3/helpers/asyncToGenerator":144,"@babel/runtime-corejs3/helpers/classCallCheck":145,"@babel/runtime-corejs3/helpers/createClass":147,"@babel/runtime-corejs3/helpers/defineProperty":148,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/regenerator":167,"axios":291}],23:[function(_dereq_,module,exports){
- "use strict";
- var _Object$keys = _dereq_("@babel/runtime-corejs3/core-js-stable/object/keys");
- var _Object$getOwnPropertySymbols = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols");
- var _filterInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/filter");
- var _Object$getOwnPropertyDescriptor = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
- var _forEachInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each");
- var _Object$getOwnPropertyDescriptors = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors");
- var _Object$defineProperties = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-properties");
- var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
- var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
- _Object$defineProperty(exports, "__esModule", {
- value: true
- });
- exports.commitServerChanges = commitServerChanges;
- exports.defaultState = defaultState;
- exports.estimateAttribute = estimateAttribute;
- exports.estimateAttributes = estimateAttributes;
- exports.mergeFirstPendingState = mergeFirstPendingState;
- exports.popPendingState = popPendingState;
- exports.pushPendingState = pushPendingState;
- exports.setPendingOp = setPendingOp;
- exports.setServerData = setServerData;
- var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
- var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
- var _includes = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/includes"));
- var _stringify = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/json/stringify"));
- var _encode = _interopRequireDefault(_dereq_("./encode"));
- var _ParseFile = _interopRequireDefault(_dereq_("./ParseFile"));
- var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
- var _ParseRelation = _interopRequireDefault(_dereq_("./ParseRelation"));
- var _TaskQueue = _interopRequireDefault(_dereq_("./TaskQueue"));
- var _ParseOp = _dereq_("./ParseOp");
- function ownKeys(object, enumerableOnly) {
- var keys = _Object$keys(object);
- if (_Object$getOwnPropertySymbols) {
- var symbols = _Object$getOwnPropertySymbols(object);
- enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) {
- return _Object$getOwnPropertyDescriptor(object, sym).enumerable;
- })), keys.push.apply(keys, symbols);
- }
- return keys;
- }
- function _objectSpread(target) {
- for (var i = 1; i < arguments.length; i++) {
- var _context, _context2;
- var source = null != arguments[i] ? arguments[i] : {};
- i % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(source), !0)).call(_context, function (key) {
- (0, _defineProperty2.default)(target, key, source[key]);
- }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) {
- _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key));
- });
- }
- return target;
- }
- function defaultState()
- /*: State*/
- {
- return {
- serverData: {},
- pendingOps: [{}],
- objectCache: {},
- tasks: new _TaskQueue.default(),
- existed: false
- };
- }
- function setServerData(serverData
- /*: AttributeMap*/
- , attributes
- /*: AttributeMap*/
- ) {
- for (var _attr in attributes) {
- if (typeof attributes[_attr] !== 'undefined') {
- serverData[_attr] = attributes[_attr];
- } else {
- delete serverData[_attr];
- }
- }
- }
- function setPendingOp(pendingOps
- /*: Array<OpsMap>*/
- , attr
- /*: string*/
- , op
- /*: ?Op*/
- ) {
- var last = pendingOps.length - 1;
- if (op) {
- pendingOps[last][attr] = op;
- } else {
- delete pendingOps[last][attr];
- }
- }
- function pushPendingState(pendingOps
- /*: Array<OpsMap>*/
- ) {
- pendingOps.push({});
- }
- function popPendingState(pendingOps
- /*: Array<OpsMap>*/
- )
- /*: OpsMap*/
- {
- var first = pendingOps.shift();
- if (!pendingOps.length) {
- pendingOps[0] = {};
- }
- return first;
- }
- function mergeFirstPendingState(pendingOps
- /*: Array<OpsMap>*/
- ) {
- var first = popPendingState(pendingOps);
- var next = pendingOps[0];
- for (var _attr2 in first) {
- if (next[_attr2] && first[_attr2]) {
- var merged = next[_attr2].mergeWith(first[_attr2]);
- if (merged) {
- next[_attr2] = merged;
- }
- } else {
- next[_attr2] = first[_attr2];
- }
- }
- }
- function estimateAttribute(serverData
- /*: AttributeMap*/
- , pendingOps
- /*: Array<OpsMap>*/
- , className
- /*: string*/
- , id
- /*: ?string*/
- , attr
- /*: string*/
- )
- /*: mixed*/
- {
- var value = serverData[attr];
- for (var i = 0; i < pendingOps.length; i++) {
- if (pendingOps[i][attr]) {
- if (pendingOps[i][attr] instanceof _ParseOp.RelationOp) {
- if (id) {
- value = pendingOps[i][attr].applyTo(value, {
- className: className,
- id: id
- }, attr);
- }
- } else {
- value = pendingOps[i][attr].applyTo(value);
- }
- }
- }
- return value;
- }
- function estimateAttributes(serverData
- /*: AttributeMap*/
- , pendingOps
- /*: Array<OpsMap>*/
- , className
- /*: string*/
- , id
- /*: ?string*/
- )
- /*: AttributeMap*/
- {
- var data = {};
- for (var attr in serverData) {
- data[attr] = serverData[attr];
- }
- for (var i = 0; i < pendingOps.length; i++) {
- for (attr in pendingOps[i]) {
- if (pendingOps[i][attr] instanceof _ParseOp.RelationOp) {
- if (id) {
- data[attr] = pendingOps[i][attr].applyTo(data[attr], {
- className: className,
- id: id
- }, attr);
- }
- } else {
- if ((0, _includes.default)(attr).call(attr, '.')) {
- // convert a.b.c into { a: { b: { c: value } } }
- var fields = attr.split('.');
- var first = fields[0];
- var last = fields[fields.length - 1];
- data[first] = _objectSpread({}, serverData[first]);
- var object = _objectSpread({}, data);
- for (var _i = 0; _i < fields.length - 1; _i++) {
- object = object[fields[_i]];
- }
- object[last] = pendingOps[i][attr].applyTo(object[last]);
- } else {
- data[attr] = pendingOps[i][attr].applyTo(data[attr]);
- }
- }
- }
- }
- return data;
- }
- function commitServerChanges(serverData
- /*: AttributeMap*/
- , objectCache
- /*: ObjectCache*/
- , changes
- /*: AttributeMap*/
- ) {
- for (var _attr3 in changes) {
- var val = changes[_attr3];
- serverData[_attr3] = val;
- if (val && (0, _typeof2.default)(val) === 'object' && !(val instanceof _ParseObject.default) && !(val instanceof _ParseFile.default) && !(val instanceof _ParseRelation.default)) {
- var json = (0, _encode.default)(val, false, true);
- objectCache[_attr3] = (0, _stringify.default)(json);
- }
- }
- }
- },{"./ParseFile":30,"./ParseObject":36,"./ParseOp":37,"./ParseRelation":40,"./TaskQueue":50,"./encode":66,"@babel/runtime-corejs3/core-js-stable/instance/filter":84,"@babel/runtime-corejs3/core-js-stable/instance/for-each":86,"@babel/runtime-corejs3/core-js-stable/instance/includes":87,"@babel/runtime-corejs3/core-js-stable/json/stringify":99,"@babel/runtime-corejs3/core-js-stable/object/define-properties":104,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor":108,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors":109,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols":110,"@babel/runtime-corejs3/core-js-stable/object/keys":112,"@babel/runtime-corejs3/helpers/defineProperty":148,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/helpers/typeof":164}],24:[function(_dereq_,module,exports){
- "use strict";
- var _sliceInstanceProperty2 = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/slice");
- var _Array$from = _dereq_("@babel/runtime-corejs3/core-js-stable/array/from");
- var _Symbol = _dereq_("@babel/runtime-corejs3/core-js-stable/symbol");
- var _getIteratorMethod = _dereq_("@babel/runtime-corejs3/core-js/get-iterator-method");
- var _Array$isArray2 = _dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array");
- var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
- var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
- var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
- var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
- var _slice = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/slice"));
- var _filter = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/filter"));
- var _map = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/map"));
- var _forEach = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
- var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/keys"));
- function _createForOfIteratorHelper(o, allowArrayLike) {
- var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"];
- if (!it) {
- if (_Array$isArray2(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
- if (it) o = it;
- var i = 0;
- var F = function () {};
- return {
- s: F,
- n: function () {
- if (i >= o.length) return {
- done: true
- };
- return {
- done: false,
- value: o[i++]
- };
- },
- e: function (_e) {
- throw _e;
- },
- f: F
- };
- }
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
- }
- var normalCompletion = true,
- didErr = false,
- err;
- return {
- s: function () {
- it = it.call(o);
- },
- n: function () {
- var step = it.next();
- normalCompletion = step.done;
- return step;
- },
- e: function (_e2) {
- didErr = true;
- err = _e2;
- },
- f: function () {
- try {
- if (!normalCompletion && it.return != null) it.return();
- } finally {
- if (didErr) throw err;
- }
- }
- };
- }
- function _unsupportedIterableToArray(o, minLen) {
- var _context5;
- if (!o) return;
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
- var n = _sliceInstanceProperty2(_context5 = Object.prototype.toString.call(o)).call(_context5, 8, -1);
- if (n === "Object" && o.constructor) n = o.constructor.name;
- if (n === "Map" || n === "Set") return _Array$from(o);
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
- }
- function _arrayLikeToArray(arr, len) {
- if (len == null || len > arr.length) len = arr.length;
- for (var i = 0, arr2 = new Array(len); i < len; i++) {
- arr2[i] = arr[i];
- }
- return arr2;
- }
- /* eslint-disable no-loop-func */
- var equalObjects = _dereq_('./equals').default;
- var decode = _dereq_('./decode').default;
- var ParseError = _dereq_('./ParseError').default;
- var ParsePolygon = _dereq_('./ParsePolygon').default;
- var ParseGeoPoint = _dereq_('./ParseGeoPoint').default;
- /**
- * contains -- Determines if an object is contained in a list with special handling for Parse pointers.
- *
- * @param haystack
- * @param needle
- * @private
- * @returns {boolean}
- */
- function contains(haystack, needle) {
- if (needle && needle.__type && (needle.__type === 'Pointer' || needle.__type === 'Object')) {
- for (var i in haystack) {
- var ptr = haystack[i];
- if (typeof ptr === 'string' && ptr === needle.objectId) {
- return true;
- }
- if (ptr.className === needle.className && ptr.objectId === needle.objectId) {
- return true;
- }
- }
- return false;
- }
- return (0, _indexOf.default)(haystack).call(haystack, needle) > -1;
- }
- function transformObject(object) {
- if (object._toFullJSON) {
- return object._toFullJSON();
- }
- return object;
- }
- /**
- * matchesQuery -- Determines if an object would be returned by a Parse Query
- * It's a lightweight, where-clause only implementation of a full query engine.
- * Since we find queries that match objects, rather than objects that match
- * queries, we can avoid building a full-blown query tool.
- *
- * @param className
- * @param object
- * @param objects
- * @param query
- * @private
- * @returns {boolean}
- */
- function matchesQuery(className, object, objects, query) {
- if (object.className !== className) {
- return false;
- }
- var obj = object;
- var q = query;
- if (object.toJSON) {
- obj = object.toJSON();
- }
- if (query.toJSON) {
- q = query.toJSON().where;
- }
- obj.className = className;
- for (var field in q) {
- if (!matchesKeyConstraints(className, obj, objects, field, q[field])) {
- return false;
- }
- }
- return true;
- }
- function equalObjectsGeneric(obj, compareTo, eqlFn) {
- if ((0, _isArray.default)(obj)) {
- for (var i = 0; i < obj.length; i++) {
- if (eqlFn(obj[i], compareTo)) {
- return true;
- }
- }
- return false;
- }
- return eqlFn(obj, compareTo);
- }
- /**
- * Determines whether an object matches a single key's constraints
- *
- * @param className
- * @param object
- * @param objects
- * @param key
- * @param constraints
- * @private
- * @returns {boolean}
- */
- function matchesKeyConstraints(className, object, objects, key, constraints) {
- if (constraints === null) {
- return false;
- }
- if ((0, _indexOf.default)(key).call(key, '.') >= 0) {
- // Key references a subobject
- var keyComponents = key.split('.');
- var subObjectKey = keyComponents[0];
- var keyRemainder = (0, _slice.default)(keyComponents).call(keyComponents, 1).join('.');
- return matchesKeyConstraints(className, object[subObjectKey] || {}, objects, keyRemainder, constraints);
- }
- var i;
- if (key === '$or') {
- for (i = 0; i < constraints.length; i++) {
- if (matchesQuery(className, object, objects, constraints[i])) {
- return true;
- }
- }
- return false;
- }
- if (key === '$and') {
- for (i = 0; i < constraints.length; i++) {
- if (!matchesQuery(className, object, objects, constraints[i])) {
- return false;
- }
- }
- return true;
- }
- if (key === '$nor') {
- for (i = 0; i < constraints.length; i++) {
- if (matchesQuery(className, object, objects, constraints[i])) {
- return false;
- }
- }
- return true;
- }
- if (key === '$relatedTo') {
- // Bail! We can't handle relational queries locally
- return false;
- }
- if (!/^[A-Za-z][0-9A-Za-z_]*$/.test(key)) {
- throw new ParseError(ParseError.INVALID_KEY_NAME, "Invalid Key: ".concat(key));
- } // Equality (or Array contains) cases
- if ((0, _typeof2.default)(constraints) !== 'object') {
- if ((0, _isArray.default)(object[key])) {
- var _context;
- return (0, _indexOf.default)(_context = object[key]).call(_context, constraints) > -1;
- }
- return object[key] === constraints;
- }
- var compareTo;
- if (constraints.__type) {
- if (constraints.__type === 'Pointer') {
- return equalObjectsGeneric(object[key], constraints, function (obj, ptr) {
- return typeof obj !== 'undefined' && ptr.className === obj.className && ptr.objectId === obj.objectId;
- });
- }
- return equalObjectsGeneric(decode(object[key]), decode(constraints), equalObjects);
- } // More complex cases
- for (var condition in constraints) {
- compareTo = constraints[condition];
- if (compareTo.__type) {
- compareTo = decode(compareTo);
- } // Compare Date Object or Date String
- if (toString.call(compareTo) === '[object Date]' || typeof compareTo === 'string' && new Date(compareTo) !== 'Invalid Date' && !isNaN(new Date(compareTo))) {
- object[key] = new Date(object[key].iso ? object[key].iso : object[key]);
- }
- switch (condition) {
- case '$lt':
- if (object[key] >= compareTo) {
- return false;
- }
- break;
- case '$lte':
- if (object[key] > compareTo) {
- return false;
- }
- break;
- case '$gt':
- if (object[key] <= compareTo) {
- return false;
- }
- break;
- case '$gte':
- if (object[key] < compareTo) {
- return false;
- }
- break;
- case '$ne':
- if (equalObjects(object[key], compareTo)) {
- return false;
- }
- break;
- case '$in':
- if (!contains(compareTo, object[key])) {
- return false;
- }
- break;
- case '$nin':
- if (contains(compareTo, object[key])) {
- return false;
- }
- break;
- case '$all':
- for (i = 0; i < compareTo.length; i++) {
- var _context2;
- if ((0, _indexOf.default)(_context2 = object[key]).call(_context2, compareTo[i]) < 0) {
- return false;
- }
- }
- break;
- case '$exists':
- {
- var propertyExists = typeof object[key] !== 'undefined';
- var existenceIsRequired = constraints.$exists;
- if (typeof constraints.$exists !== 'boolean') {
- // The SDK will never submit a non-boolean for $exists, but if someone
- // tries to submit a non-boolean for $exits outside the SDKs, just ignore it.
- break;
- }
- if (!propertyExists && existenceIsRequired || propertyExists && !existenceIsRequired) {
- return false;
- }
- break;
- }
- case '$regex':
- {
- if ((0, _typeof2.default)(compareTo) === 'object') {
- return compareTo.test(object[key]);
- } // JS doesn't support perl-style escaping
- var expString = '';
- var escapeEnd = -2;
- var escapeStart = (0, _indexOf.default)(compareTo).call(compareTo, '\\Q');
- while (escapeStart > -1) {
- // Add the unescaped portion
- expString += compareTo.substring(escapeEnd + 2, escapeStart);
- escapeEnd = (0, _indexOf.default)(compareTo).call(compareTo, '\\E', escapeStart);
- if (escapeEnd > -1) {
- expString += compareTo.substring(escapeStart + 2, escapeEnd).replace(/\\\\\\\\E/g, '\\E').replace(/\W/g, '\\$&');
- }
- escapeStart = (0, _indexOf.default)(compareTo).call(compareTo, '\\Q', escapeEnd);
- }
- expString += compareTo.substring(Math.max(escapeStart, escapeEnd + 2));
- var modifiers = constraints.$options || '';
- modifiers = modifiers.replace('x', '').replace('s', ''); // Parse Server / Mongo support x and s modifiers but JS RegExp doesn't
- var exp = new RegExp(expString, modifiers);
- if (!exp.test(object[key])) {
- return false;
- }
- break;
- }
- case '$nearSphere':
- {
- if (!compareTo || !object[key]) {
- return false;
- }
- var distance = compareTo.radiansTo(object[key]);
- var max = constraints.$maxDistance || Infinity;
- return distance <= max;
- }
- case '$within':
- {
- if (!compareTo || !object[key]) {
- return false;
- }
- var southWest = compareTo.$box[0];
- var northEast = compareTo.$box[1];
- if (southWest.latitude > northEast.latitude || southWest.longitude > northEast.longitude) {
- // Invalid box, crosses the date line
- return false;
- }
- return object[key].latitude > southWest.latitude && object[key].latitude < northEast.latitude && object[key].longitude > southWest.longitude && object[key].longitude < northEast.longitude;
- }
- case '$options':
- // Not a query type, but a way to add options to $regex. Ignore and
- // avoid the default
- break;
- case '$maxDistance':
- // Not a query type, but a way to add a cap to $nearSphere. Ignore and
- // avoid the default
- break;
- case '$select':
- {
- var subQueryObjects = (0, _filter.default)(objects).call(objects, function (obj, index, arr) {
- return matchesQuery(compareTo.query.className, obj, arr, compareTo.query.where);
- });
- for (var _i = 0; _i < subQueryObjects.length; _i += 1) {
- var subObject = transformObject(subQueryObjects[_i]);
- return equalObjects(object[key], subObject[compareTo.key]);
- }
- return false;
- }
- case '$dontSelect':
- {
- var _subQueryObjects = (0, _filter.default)(objects).call(objects, function (obj, index, arr) {
- return matchesQuery(compareTo.query.className, obj, arr, compareTo.query.where);
- });
- for (var _i2 = 0; _i2 < _subQueryObjects.length; _i2 += 1) {
- var _subObject = transformObject(_subQueryObjects[_i2]);
- return !equalObjects(object[key], _subObject[compareTo.key]);
- }
- return false;
- }
- case '$inQuery':
- {
- var _subQueryObjects2 = (0, _filter.default)(objects).call(objects, function (obj, index, arr) {
- return matchesQuery(compareTo.className, obj, arr, compareTo.where);
- });
- for (var _i3 = 0; _i3 < _subQueryObjects2.length; _i3 += 1) {
- var _subObject2 = transformObject(_subQueryObjects2[_i3]);
- if (object[key].className === _subObject2.className && object[key].objectId === _subObject2.objectId) {
- return true;
- }
- }
- return false;
- }
- case '$notInQuery':
- {
- var _subQueryObjects3 = (0, _filter.default)(objects).call(objects, function (obj, index, arr) {
- return matchesQuery(compareTo.className, obj, arr, compareTo.where);
- });
- for (var _i4 = 0; _i4 < _subQueryObjects3.length; _i4 += 1) {
- var _subObject3 = transformObject(_subQueryObjects3[_i4]);
- if (object[key].className === _subObject3.className && object[key].objectId === _subObject3.objectId) {
- return false;
- }
- }
- return true;
- }
- case '$containedBy':
- {
- var _iterator = _createForOfIteratorHelper(object[key]),
- _step;
- try {
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
- var value = _step.value;
- if (!contains(compareTo, value)) {
- return false;
- }
- }
- } catch (err) {
- _iterator.e(err);
- } finally {
- _iterator.f();
- }
- return true;
- }
- case '$geoWithin':
- {
- var _context3;
- var points = (0, _map.default)(_context3 = compareTo.$polygon).call(_context3, function (geoPoint) {
- return [geoPoint.latitude, geoPoint.longitude];
- });
- var polygon = new ParsePolygon(points);
- return polygon.containsPoint(object[key]);
- }
- case '$geoIntersects':
- {
- var _polygon = new ParsePolygon(object[key].coordinates);
- var point = new ParseGeoPoint(compareTo.$point);
- return _polygon.containsPoint(point);
- }
- default:
- return false;
- }
- }
- return true;
- }
- function validateQuery(query
- /*: any*/
- ) {
- var _context4;
- var q = query;
- if (query.toJSON) {
- q = query.toJSON().where;
- }
- var specialQuerykeys = ['$and', '$or', '$nor', '_rperm', '_wperm', '_perishable_token', '_email_verify_token', '_email_verify_token_expires_at', '_account_lockout_expires_at', '_failed_login_count'];
- (0, _forEach.default)(_context4 = (0, _keys.default)(q)).call(_context4, function (key) {
- if (q && q[key] && q[key].$regex) {
- if (typeof q[key].$options === 'string') {
- if (!q[key].$options.match(/^[imxs]+$/)) {
- throw new ParseError(ParseError.INVALID_QUERY, "Bad $options value for query: ".concat(q[key].$options));
- }
- }
- }
- if ((0, _indexOf.default)(specialQuerykeys).call(specialQuerykeys, key) < 0 && !key.match(/^[a-zA-Z][a-zA-Z0-9_.]*$/)) {
- throw new ParseError(ParseError.INVALID_KEY_NAME, "Invalid key name: ".concat(key));
- }
- });
- }
- var OfflineQuery = {
- matchesQuery: matchesQuery,
- validateQuery: validateQuery
- };
- module.exports = OfflineQuery;
- },{"./ParseError":29,"./ParseGeoPoint":33,"./ParsePolygon":38,"./decode":65,"./equals":67,"@babel/runtime-corejs3/core-js-stable/array/from":78,"@babel/runtime-corejs3/core-js-stable/array/is-array":79,"@babel/runtime-corejs3/core-js-stable/instance/filter":84,"@babel/runtime-corejs3/core-js-stable/instance/for-each":86,"@babel/runtime-corejs3/core-js-stable/instance/index-of":88,"@babel/runtime-corejs3/core-js-stable/instance/map":90,"@babel/runtime-corejs3/core-js-stable/instance/slice":93,"@babel/runtime-corejs3/core-js-stable/object/keys":112,"@babel/runtime-corejs3/core-js-stable/symbol":119,"@babel/runtime-corejs3/core-js/get-iterator-method":125,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/helpers/typeof":164}],25:[function(_dereq_,module,exports){
- (function (process){(function (){
- "use strict";
- var _typeof = _dereq_("@babel/runtime-corejs3/helpers/typeof");
- var _Reflect$construct = _dereq_("@babel/runtime-corejs3/core-js-stable/reflect/construct");
- var _WeakMap = _dereq_("@babel/runtime-corejs3/core-js-stable/weak-map");
- var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
- var _Object$getOwnPropertyDescriptor = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
- var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
- var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
- var _regenerator = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/regenerator"));
- var _asyncToGenerator2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/asyncToGenerator"));
- var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
- var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
- var _inherits2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/inherits"));
- var _possibleConstructorReturn2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/possibleConstructorReturn"));
- var _getPrototypeOf2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/getPrototypeOf"));
- var _decode = _interopRequireDefault(_dereq_("./decode"));
- var _encode = _interopRequireDefault(_dereq_("./encode"));
- var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
- var _CryptoController = _interopRequireDefault(_dereq_("./CryptoController"));
- var _InstallationController = _interopRequireDefault(_dereq_("./InstallationController"));
- var ParseOp = _interopRequireWildcard(_dereq_("./ParseOp"));
- var _RESTController2 = _interopRequireDefault(_dereq_("./RESTController"));
- var _MoralisWeb2 = _interopRequireDefault(_dereq_("./MoralisWeb3"));
- var _ethers = _dereq_("ethers");
- var _filterConsole = _dereq_("./filterConsole");
- function _getRequireWildcardCache(nodeInterop) {
- if (typeof _WeakMap !== "function") return null;
- var cacheBabelInterop = new _WeakMap();
- var cacheNodeInterop = new _WeakMap();
- return (_getRequireWildcardCache = function (nodeInterop) {
- return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
- })(nodeInterop);
- }
- function _interopRequireWildcard(obj, nodeInterop) {
- if (!nodeInterop && obj && obj.__esModule) {
- return obj;
- }
- if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") {
- return {
- default: obj
- };
- }
- var cache = _getRequireWildcardCache(nodeInterop);
- if (cache && cache.has(obj)) {
- return cache.get(obj);
- }
- var newObj = {};
- for (var key in obj) {
- if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
- var desc = _Object$defineProperty && _Object$getOwnPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null;
- if (desc && (desc.get || desc.set)) {
- _Object$defineProperty(newObj, key, desc);
- } else {
- newObj[key] = obj[key];
- }
- }
- }
- newObj.default = obj;
- if (cache) {
- cache.set(obj, newObj);
- }
- return newObj;
- }
- function _createSuper(Derived) {
- var hasNativeReflectConstruct = _isNativeReflectConstruct();
- return function () {
- var Super = (0, _getPrototypeOf2.default)(Derived),
- result;
- if (hasNativeReflectConstruct) {
- var NewTarget = (0, _getPrototypeOf2.default)(this).constructor;
- result = _Reflect$construct(Super, arguments, NewTarget);
- } else {
- result = Super.apply(this, arguments);
- }
- return (0, _possibleConstructorReturn2.default)(this, result);
- };
- }
- function _isNativeReflectConstruct() {
- if (typeof Reflect === "undefined" || !_Reflect$construct) return false;
- if (_Reflect$construct.sham) return false;
- if (typeof Proxy === "function") return true;
- try {
- Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {}));
- return true;
- } catch (e) {
- return false;
- }
- }
- var _require = _dereq_('./utils'),
- checkForSdkUpdates = _require.checkForSdkUpdates,
- trackEvent = _require.trackEvent,
- TrackingEventName = _require.TrackingEventName,
- getSubdomain = _require.getSubdomain;
- /**
- * Contains all Moralis API classes and functions.
- *
- * @static
- * @global
- * @class
- * @hideconstructor
- */
- var Moralis = /*#__PURE__*/function (_MoralisWeb) {
- (0, _inherits2.default)(Moralis, _MoralisWeb);
- var _super = _createSuper(Moralis);
- function Moralis() {
- (0, _classCallCheck2.default)(this, Moralis);
- return _super.apply(this, arguments);
- }
- (0, _createClass2.default)(Moralis, null, [{
- key: "start",
- value:
- /**
- * Call this method to initialize all moralis instances (Moralis, Web3Api, plugins).
- *
- * @param {object} options Your Moralis Application ID and Server URL. Moralis.start({serverUrl,appId})
- * @static
- */
- function () {
- var _start = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(options) {
- var appId, serverUrl, plugins, javascriptKey, masterKey, moralisSecret, apiKey, trackOptions, _yield$this$getApiKey, web3ApiKey, speedyNodeApiKey;
- return _regenerator.default.wrap(function (_context) {
- while (1) {
- switch (_context.prev = _context.next) {
- case 0:
- appId = options.appId, serverUrl = options.serverUrl, plugins = options.plugins, javascriptKey = options.javascriptKey, masterKey = options.masterKey, moralisSecret = options.moralisSecret;
- if (serverUrl) {
- _context.next = 4;
- break;
- }
- throw new Error("Moralis.start failed: serverUrl is required");
- case 4:
- if (appId) {
- _context.next = 6;
- break;
- }
- throw new Error("Moralis.start failed: appId is required");
- case 6:
- if (moralisSecret) {
- console.warn('Moralis.start warning: Using moralisSecret on the browser enviroment reveals critical information.');
- }
- _context.next = 18;
- break;
- case 9:
- if (!moralisSecret) {
- _context.next = 18;
- break;
- }
- this.moralisSecret = moralisSecret;
- _context.next = 13;
- return this.getApiKeys(moralisSecret);
- case 13:
- _yield$this$getApiKey = _context.sent;
- web3ApiKey = _yield$this$getApiKey.web3ApiKey;
- speedyNodeApiKey = _yield$this$getApiKey.speedyNodeApiKey;
- apiKey = web3ApiKey;
- this.speedyNodeApiKey = speedyNodeApiKey;
- case 18:
- this.initialize(appId, javascriptKey, masterKey);
- this.serverURL = serverUrl;
- this.Web3API.initialize({
- serverUrl: serverUrl,
- apiKey: apiKey,
- Moralis: Moralis
- });
- this.SolanaAPI.initialize({
- serverUrl: serverUrl,
- apiKey: apiKey,
- Moralis: Moralis
- });
- if (!(appId && serverUrl)) {
- _context.next = 28;
- break;
- }
- trackOptions = {
- subdomain: getSubdomain(serverUrl),
- sdk_type: 'javascript',
- sdk_version: "1.5.9",
- sdk_enviroment: "browser",
- appId: appId
- };
- _context.next = 26;
- return this.initPlugins(plugins);
- case 26:
- _context.next = 29;
- break;
- case 28:
- trackOptions = {
- sdk_type: 'javascript',
- sdk_version: "1.5.9",
- sdk_enviroment: "browser"
- };
- case 29:
- // Check if SDK is updated
- checkForSdkUpdates(); // Track start function call
- trackEvent(TrackingEventName.START_FUNCTION, serverUrl ? getSubdomain(serverUrl) : null, trackOptions);
- case 31:
- case "end":
- return _context.stop();
- }
- }
- }, _callee, this);
- }));
- return function () {
- return _start.apply(this, arguments);
- };
- }()
- /**
- * Call this method to get apiKeys using moralis secret.
- *
- * @param {string} moralisSecret Your MoralisSecret
- * @static
- */
- }, {
- key: "getApiKeys",
- value: function () {
- var _getApiKeys = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(moralisSecret) {
- var _RESTController, response;
- return _regenerator.default.wrap(function (_context2) {
- while (1) {
- switch (_context2.prev = _context2.next) {
- case 0:
- _context2.prev = 0;
- _RESTController = _CoreManager.default.getRESTController();
- _context2.next = 4;
- return _RESTController.ajax('GET', 'https://admin.moralis.io/api/publics/apiKeys', null, {
- 'moralis-secret': moralisSecret,
- Accept: 'application/json',
- 'Content-Type': 'application/json'
- });
- case 4:
- response = _context2.sent;
- return _context2.abrupt("return", response.response.result);
- case 8:
- _context2.prev = 8;
- _context2.t0 = _context2["catch"](0);
- throw new Error("Could not fetch keys with moralisSecret");
- case 11:
- case "end":
- return _context2.stop();
- }
- }
- }, _callee2, null, [[0, 8]]);
- }));
- return function () {
- return _getApiKeys.apply(this, arguments);
- };
- }()
- /**
- * Call this method first to set up your authentication tokens for Moralis.
- *
- * @param {string} applicationId Your Moralis Application ID.
- * @param {string} [javaScriptKey] Your Moralis JavaScript Key (Not needed for moralis-server)
- * @param {string} [masterKey] Your Moralis Master Key. (Node.js only!)
- * @static
- */
- }, {
- key: "initialize",
- value: function (applicationId
- /*: string*/
- , javaScriptKey
- /*: string*/
- ) {
- if ("browser" === 'browser' && _CoreManager.default.get('IS_NODE') && !process.env.SERVER_RENDERING) {
- /* eslint-disable no-console */
- console.log("It looks like you're using the browser version of the SDK in a " + "node.js environment. You should require('parse/node') instead.");
- /* eslint-enable no-console */
- }
- Moralis._initialize(applicationId, javaScriptKey);
- }
- }, {
- key: "_initialize",
- value: function (applicationId
- /*: string*/
- , javaScriptKey
- /*: string*/
- , masterKey
- /*: string*/
- ) {
- _CoreManager.default.set('APPLICATION_ID', applicationId);
- _CoreManager.default.set('JAVASCRIPT_KEY', javaScriptKey);
- _CoreManager.default.set('MASTER_KEY', masterKey);
- _CoreManager.default.set('USE_MASTER_KEY', false);
- }
- /**
- * Call this method to set your AsyncStorage engine
- * Starting Parse@1.11, the ParseSDK do not provide a React AsyncStorage as the ReactNative module
- * is not provided at a stable path and changes over versions.
- *
- * @param {AsyncStorage} storage a react native async storage.
- * @static
- */
- }, {
- key: "setAsyncStorage",
- value: function (storage
- /*: any*/
- ) {
- _CoreManager.default.setAsyncStorage(storage);
- }
- /**
- * Call this method to set your LocalDatastoreStorage engine
- * If using React-Native use {@link Moralis.setAsyncStorage Moralis.setAsyncStorage()}
- *
- * @param {LocalDatastoreController} controller a data storage.
- * @static
- */
- }, {
- key: "setLocalDatastoreController",
- value: function (controller
- /*: any*/
- ) {
- _CoreManager.default.setLocalDatastoreController(controller);
- }
- /**
- * @member {string} Moralis.applicationId
- * @static
- */
- }, {
- key: "applicationId",
- get: function () {
- return _CoreManager.default.get('APPLICATION_ID');
- }
- /**
- * @member {string} Moralis.javaScriptKey
- * @static
- */
- ,
- set: function (value) {
- _CoreManager.default.set('APPLICATION_ID', value);
- }
- }, {
- key: "javaScriptKey",
- get: function () {
- return _CoreManager.default.get('JAVASCRIPT_KEY');
- }
- /**
- * @member {string} Moralis.masterKey
- * @static
- */
- ,
- set: function (value) {
- _CoreManager.default.set('JAVASCRIPT_KEY', value);
- }
- }, {
- key: "masterKey",
- get: function () {
- return _CoreManager.default.get('MASTER_KEY');
- }
- /**
- * @member {string} Moralis.serverURL
- * @static
- */
- ,
- set: function (value) {
- _CoreManager.default.set('MASTER_KEY', value);
- }
- }, {
- key: "serverURL",
- get: function () {
- return _CoreManager.default.get('SERVER_URL');
- }
- /**
- * @member {string} Moralis.serverAuthToken
- * @static
- */
- ,
- set: function (value) {
- _CoreManager.default.set('SERVER_URL', value);
- }
- }, {
- key: "serverAuthToken",
- get: function () {
- return _CoreManager.default.get('SERVER_AUTH_TOKEN');
- }
- /**
- * @member {string} Moralis.serverAuthType
- * @static
- */
- ,
- set: function (value) {
- _CoreManager.default.set('SERVER_AUTH_TOKEN', value);
- }
- }, {
- key: "serverAuthType",
- get: function () {
- return _CoreManager.default.get('SERVER_AUTH_TYPE');
- }
- /**
- * @member {string} Moralis.liveQueryServerURL
- * @static
- */
- ,
- set: function (value) {
- _CoreManager.default.set('SERVER_AUTH_TYPE', value);
- }
- }, {
- key: "liveQueryServerURL",
- get: function () {
- return _CoreManager.default.get('LIVEQUERY_SERVER_URL');
- }
- /**
- * @member {string} Moralis.encryptedUser
- * @static
- */
- ,
- set: function (value) {
- _CoreManager.default.set('LIVEQUERY_SERVER_URL', value);
- }
- }, {
- key: "encryptedUser",
- get: function () {
- return _CoreManager.default.get('ENCRYPTED_USER');
- }
- /**
- * @member {string} Moralis.secret
- * @static
- */
- ,
- set: function (value) {
- _CoreManager.default.set('ENCRYPTED_USER', value);
- }
- }, {
- key: "secret",
- get: function () {
- return _CoreManager.default.get('ENCRYPTED_KEY');
- }
- /**
- * @member {boolean} Moralis.idempotency
- * @static
- */
- ,
- set: function (value) {
- _CoreManager.default.set('ENCRYPTED_KEY', value);
- }
- }, {
- key: "idempotency",
- get: function () {
- return _CoreManager.default.get('IDEMPOTENCY');
- },
- set: function (value) {
- _CoreManager.default.set('IDEMPOTENCY', value);
- }
- }]);
- return Moralis;
- }(_MoralisWeb2.default);
- Moralis.ACL = _dereq_('./ParseACL').default;
- Moralis.Analytics = _dereq_('./Analytics');
- Moralis.AnonymousUtils = _dereq_('./AnonymousUtils').default;
- Moralis.Cloud = _dereq_('./Cloud');
- Moralis.CLP = _dereq_('./ParseCLP').default;
- Moralis.CoreManager = _dereq_('./CoreManager');
- Moralis.Config = _dereq_('./ParseConfig').default;
- Moralis.Error = _dereq_('./ParseError').default;
- Moralis.FacebookUtils = _dereq_('./FacebookUtils').default;
- Moralis.File = _dereq_('./ParseFile').default;
- Moralis.GeoPoint = _dereq_('./ParseGeoPoint').default;
- Moralis.Polygon = _dereq_('./ParsePolygon').default;
- Moralis.Installation = _dereq_('./ParseInstallation').default;
- Moralis.LocalDatastore = _dereq_('./LocalDatastore');
- Moralis.Object = _dereq_('./ParseObject').default;
- Moralis.Op = {
- Set: ParseOp.SetOp,
- Unset: ParseOp.UnsetOp,
- Increment: ParseOp.IncrementOp,
- Add: ParseOp.AddOp,
- Remove: ParseOp.RemoveOp,
- AddUnique: ParseOp.AddUniqueOp,
- Relation: ParseOp.RelationOp
- };
- Moralis.Web3API = _dereq_('./MoralisWeb3Api').default;
- Moralis.SolanaAPI = _dereq_('./MoralisSolanaApi').default;
- Moralis.Push = _dereq_('./Push');
- Moralis.Query = _dereq_('./ParseQuery').default;
- Moralis.Relation = _dereq_('./ParseRelation').default;
- Moralis.Role = _dereq_('./ParseRole').default;
- Moralis.Schema = _dereq_('./ParseSchema').default;
- Moralis.Session = _dereq_('./ParseSession').default;
- Moralis.Storage = _dereq_('./Storage');
- Moralis.User = _dereq_('./ParseUser').default;
- Moralis.LiveQuery = _dereq_('./ParseLiveQuery').default;
- Moralis.LiveQueryClient = _dereq_('./LiveQueryClient').default;
- Moralis.Web3 = Moralis;
- Moralis.Units = _dereq_('./UnitConvert'); // Moralis.Web3 = require('./MoralisWeb3').default;
- Moralis.Elrond = _dereq_('./MoralisErd').default;
- Moralis.Erd = Moralis.Elrond;
- Moralis.Dot = _dereq_('./MoralisDot').default;
- Moralis.UI = _dereq_('./MoralisUI').default;
- Moralis.Chains = _dereq_('./Chains').default;
- Moralis.AbstractWeb3Connector = _dereq_('./Web3Connector/AbstractWeb3Connector').default;
- (0, _filterConsole.filterConsole)();
- Moralis._request = function () {
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
- args[_key] = arguments[_key];
- }
- return _CoreManager.default.getRESTController().request.apply(null, args);
- };
- Moralis._ajax = function () {
- for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
- args[_key2] = arguments[_key2];
- }
- return _CoreManager.default.getRESTController().ajax.apply(null, args);
- }; // We attempt to match the signatures of the legacy versions of these methods
- Moralis._decode = function (_, value) {
- return (0, _decode.default)(value);
- };
- Moralis._encode = function (value, _, disallowObjects) {
- return (0, _encode.default)(value, disallowObjects);
- };
- Moralis._getInstallationId = function () {
- return _CoreManager.default.getInstallationController().currentInstallationId();
- };
- /**
- * Enable pinning in your application.
- * This must be called before your application can use pinning.
- *
- * @static
- */
- Moralis.enableLocalDatastore = function () {
- Moralis.LocalDatastore.isEnabled = true;
- };
- /**
- * Flag that indicates whether Local Datastore is enabled.
- *
- * @static
- * @returns {boolean}
- */
- Moralis.isLocalDatastoreEnabled = function () {
- return Moralis.LocalDatastore.isEnabled;
- };
- /**
- * Gets all contents from Local Datastore
- *
- * <pre>
- * await Moralis.dumpLocalDatastore();
- * </pre>
- *
- * @static
- * @returns {object}
- */
- Moralis.dumpLocalDatastore = function () {
- if (!Moralis.LocalDatastore.isEnabled) {
- console.log('Moralis.enableLocalDatastore() must be called first'); // eslint-disable-line no-console
- return _promise.default.resolve({});
- }
- return Moralis.LocalDatastore._getAllContents();
- };
- /**
- * Enable the current user encryption.
- * This must be called before login any user.
- *
- * @static
- */
- Moralis.enableEncryptedUser = function () {
- Moralis.encryptedUser = true;
- };
- /**
- * Flag that indicates whether Encrypted User is enabled.
- *
- * @static
- * @returns {boolean}
- */
- Moralis.isEncryptedUserEnabled = function () {
- return Moralis.encryptedUser;
- };
- _CoreManager.default.setCryptoController(_CryptoController.default);
- _CoreManager.default.setInstallationController(_InstallationController.default);
- _CoreManager.default.setRESTController(_RESTController2.default);
- // For legacy requires, of the form `var Moralis = require('moralis').Moralis`
- Moralis.Moralis = Moralis;
- module.exports = Moralis;
- }).call(this)}).call(this,_dereq_('_process'))
- },{"./Analytics":1,"./AnonymousUtils":2,"./Chains":3,"./Cloud":4,"./CoreManager":5,"./CryptoController":6,"./FacebookUtils":8,"./InstallationController":9,"./LiveQueryClient":11,"./LocalDatastore":13,"./MoralisDot":16,"./MoralisErd":17,"./MoralisSolanaApi":19,"./MoralisUI":20,"./MoralisWeb3":21,"./MoralisWeb3Api":22,"./ParseACL":26,"./ParseCLP":27,"./ParseConfig":28,"./ParseError":29,"./ParseFile":30,"./ParseGeoPoint":33,"./ParseInstallation":34,"./ParseLiveQuery":35,"./ParseObject":36,"./ParseOp":37,"./ParsePolygon":38,"./ParseQuery":39,"./ParseRelation":40,"./ParseRole":41,"./ParseSchema":42,"./ParseSession":43,"./ParseUser":44,"./Push":45,"./RESTController":46,"./Storage":48,"./UnitConvert":53,"./Web3Connector/AbstractWeb3Connector":54,"./decode":65,"./encode":66,"./filterConsole":69,"./utils":75,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor":108,"@babel/runtime-corejs3/core-js-stable/promise":115,"@babel/runtime-corejs3/core-js-stable/reflect/construct":116,"@babel/runtime-corejs3/core-js-stable/weak-map":122,"@babel/runtime-corejs3/helpers/asyncToGenerator":144,"@babel/runtime-corejs3/helpers/classCallCheck":145,"@babel/runtime-corejs3/helpers/createClass":147,"@babel/runtime-corejs3/helpers/getPrototypeOf":150,"@babel/runtime-corejs3/helpers/inherits":151,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/helpers/possibleConstructorReturn":159,"@babel/runtime-corejs3/helpers/typeof":164,"@babel/runtime-corejs3/regenerator":167,"_process":323,"ethers":773}],26:[function(_dereq_,module,exports){
- "use strict";
- var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
- var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
- _Object$defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = void 0;
- var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/keys"));
- var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
- var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
- var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
- var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
- var _ParseRole = _interopRequireDefault(_dereq_("./ParseRole"));
- var _ParseUser = _interopRequireDefault(_dereq_("./ParseUser"));
- /**
- * Copyright (c) 2015-present, Parse, LLC.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- *
- * @flow
- */
- var PUBLIC_KEY = '*';
- /**
- * Creates a new ACL.
- * If no argument is given, the ACL has no permissions for anyone.
- * If the argument is a Parse.User, the ACL will have read and write
- * permission for only that user.
- * If the argument is any other JSON object, that object will be interpretted
- * as a serialized ACL created with toJSON().
- *
- * <p>An ACL, or Access Control List can be added to any
- * <code>Parse.Object</code> to restrict access to only a subset of users
- * of your application.</p>
- *
- * @alias Parse.ACL
- */
- var ParseACL = /*#__PURE__*/function () {
- /**
- * @param {(Parse.User | object)} arg1 The user to initialize the ACL for
- */
- function ParseACL(arg1
- /*: ParseUser | ByIdMap*/
- ) {
- (0, _classCallCheck2.default)(this, ParseACL);
- (0, _defineProperty2.default)(this, "permissionsById", void 0);
- this.permissionsById = {};
- if (arg1 && (0, _typeof2.default)(arg1) === 'object') {
- if (arg1 instanceof _ParseUser.default) {
- this.setReadAccess(arg1, true);
- this.setWriteAccess(arg1, true);
- } else {
- for (var _userId in arg1) {
- var accessList = arg1[_userId];
- this.permissionsById[_userId] = {};
- for (var _permission in accessList) {
- var allowed = accessList[_permission];
- if (_permission !== 'read' && _permission !== 'write') {
- throw new TypeError('Tried to create an ACL with an invalid permission type.');
- }
- if (typeof allowed !== 'boolean') {
- throw new TypeError('Tried to create an ACL with an invalid permission value.');
- }
- this.permissionsById[_userId][_permission] = allowed;
- }
- }
- }
- } else if (typeof arg1 === 'function') {
- throw new TypeError('ParseACL constructed with a function. Did you forget ()?');
- }
- }
- /**
- * Returns a JSON-encoded version of the ACL.
- *
- * @returns {object}
- */
- (0, _createClass2.default)(ParseACL, [{
- key: "toJSON",
- value: function ()
- /*: ByIdMap*/
- {
- var permissions = {};
- for (var p in this.permissionsById) {
- permissions[p] = this.permissionsById[p];
- }
- return permissions;
- }
- /**
- * Returns whether this ACL is equal to another object
- *
- * @param {ParseACL} other The other object's ACL to compare to
- * @returns {boolean}
- */
- }, {
- key: "equals",
- value: function (other
- /*: ParseACL*/
- )
- /*: boolean*/
- {
- if (!(other instanceof ParseACL)) {
- return false;
- }
- var users = (0, _keys.default)(this.permissionsById);
- var otherUsers = (0, _keys.default)(other.permissionsById);
- if (users.length !== otherUsers.length) {
- return false;
- }
- for (var u in this.permissionsById) {
- if (!other.permissionsById[u]) {
- return false;
- }
- if (this.permissionsById[u].read !== other.permissionsById[u].read) {
- return false;
- }
- if (this.permissionsById[u].write !== other.permissionsById[u].write) {
- return false;
- }
- }
- return true;
- }
- }, {
- key: "_setAccess",
- value: function (accessType
- /*: string*/
- , userId
- /*: ParseUser | ParseRole | string*/
- , allowed
- /*: boolean*/
- ) {
- if (userId instanceof _ParseUser.default) {
- userId = userId.id;
- } else if (userId instanceof _ParseRole.default) {
- var name = userId.getName();
- if (!name) {
- throw new TypeError('Role must have a name');
- }
- userId = "role:".concat(name);
- }
- if (typeof userId !== 'string') {
- throw new TypeError('userId must be a string.');
- }
- if (typeof allowed !== 'boolean') {
- throw new TypeError('allowed must be either true or false.');
- }
- var permissions = this.permissionsById[userId];
- if (!permissions) {
- if (!allowed) {
- // The user already doesn't have this permission, so no action is needed
- return;
- }
- permissions = {};
- this.permissionsById[userId] = permissions;
- }
- if (allowed) {
- this.permissionsById[userId][accessType] = true;
- } else {
- delete permissions[accessType];
- if ((0, _keys.default)(permissions).length === 0) {
- delete this.permissionsById[userId];
- }
- }
- }
- }, {
- key: "_getAccess",
- value: function (accessType
- /*: string*/
- , userId
- /*: ParseUser | ParseRole | string*/
- )
- /*: boolean*/
- {
- if (userId instanceof _ParseUser.default) {
- userId = userId.id;
- if (!userId) {
- throw new Error('Cannot get access for a ParseUser without an ID');
- }
- } else if (userId instanceof _ParseRole.default) {
- var name = userId.getName();
- if (!name) {
- throw new TypeError('Role must have a name');
- }
- userId = "role:".concat(name);
- }
- var permissions = this.permissionsById[userId];
- if (!permissions) {
- return false;
- }
- return !!permissions[accessType];
- }
- /**
- * Sets whether the given user is allowed to read this object.
- *
- * @param userId An instance of Parse.User or its objectId.
- * @param {boolean} allowed Whether that user should have read access.
- */
- }, {
- key: "setReadAccess",
- value: function (userId
- /*: ParseUser | ParseRole | string*/
- , allowed
- /*: boolean*/
- ) {
- this._setAccess('read', userId, allowed);
- }
- /**
- * Get whether the given user id is *explicitly* allowed to read this object.
- * Even if this returns false, the user may still be able to access it if
- * getPublicReadAccess returns true or a role that the user belongs to has
- * write access.
- *
- * @param userId An instance of Parse.User or its objectId, or a Parse.Role.
- * @returns {boolean}
- */
- }, {
- key: "getReadAccess",
- value: function (userId
- /*: ParseUser | ParseRole | string*/
- )
- /*: boolean*/
- {
- return this._getAccess('read', userId);
- }
- /**
- * Sets whether the given user id is allowed to write this object.
- *
- * @param userId An instance of Parse.User or its objectId, or a Parse.Role..
- * @param {boolean} allowed Whether that user should have write access.
- */
- }, {
- key: "setWriteAccess",
- value: function (userId
- /*: ParseUser | ParseRole | string*/
- , allowed
- /*: boolean*/
- ) {
- this._setAccess('write', userId, allowed);
- }
- /**
- * Gets whether the given user id is *explicitly* allowed to write this object.
- * Even if this returns false, the user may still be able to write it if
- * getPublicWriteAccess returns true or a role that the user belongs to has
- * write access.
- *
- * @param userId An instance of Parse.User or its objectId, or a Parse.Role.
- * @returns {boolean}
- */
- }, {
- key: "getWriteAccess",
- value: function (userId
- /*: ParseUser | ParseRole | string*/
- )
- /*: boolean*/
- {
- return this._getAccess('write', userId);
- }
- /**
- * Sets whether the public is allowed to read this object.
- *
- * @param {boolean} allowed
- */
- }, {
- key: "setPublicReadAccess",
- value: function (allowed
- /*: boolean*/
- ) {
- this.setReadAccess(PUBLIC_KEY, allowed);
- }
- /**
- * Gets whether the public is allowed to read this object.
- *
- * @returns {boolean}
- */
- }, {
- key: "getPublicReadAccess",
- value: function ()
- /*: boolean*/
- {
- return this.getReadAccess(PUBLIC_KEY);
- }
- /**
- * Sets whether the public is allowed to write this object.
- *
- * @param {boolean} allowed
- */
- }, {
- key: "setPublicWriteAccess",
- value: function (allowed
- /*: boolean*/
- ) {
- this.setWriteAccess(PUBLIC_KEY, allowed);
- }
- /**
- * Gets whether the public is allowed to write this object.
- *
- * @returns {boolean}
- */
- }, {
- key: "getPublicWriteAccess",
- value: function ()
- /*: boolean*/
- {
- return this.getWriteAccess(PUBLIC_KEY);
- }
- /**
- * Gets whether users belonging to the given role are allowed
- * to read this object. Even if this returns false, the role may
- * still be able to write it if a parent role has read access.
- *
- * @param role The name of the role, or a Parse.Role object.
- * @returns {boolean} true if the role has read access. false otherwise.
- * @throws {TypeError} If role is neither a Parse.Role nor a String.
- */
- }, {
- key: "getRoleReadAccess",
- value: function (role
- /*: ParseRole | string*/
- )
- /*: boolean*/
- {
- if (role instanceof _ParseRole.default) {
- // Normalize to the String name
- role = role.getName();
- }
- if (typeof role !== 'string') {
- throw new TypeError('role must be a ParseRole or a String');
- }
- return this.getReadAccess("role:".concat(role));
- }
- /**
- * Gets whether users belonging to the given role are allowed
- * to write this object. Even if this returns false, the role may
- * still be able to write it if a parent role has write access.
- *
- * @param role The name of the role, or a Parse.Role object.
- * @returns {boolean} true if the role has write access. false otherwise.
- * @throws {TypeError} If role is neither a Parse.Role nor a String.
- */
- }, {
- key: "getRoleWriteAccess",
- value: function (role
- /*: ParseRole | string*/
- )
- /*: boolean*/
- {
- if (role instanceof _ParseRole.default) {
- // Normalize to the String name
- role = role.getName();
- }
- if (typeof role !== 'string') {
- throw new TypeError('role must be a ParseRole or a String');
- }
- return this.getWriteAccess("role:".concat(role));
- }
- /**
- * Sets whether users belonging to the given role are allowed
- * to read this object.
- *
- * @param role The name of the role, or a Parse.Role object.
- * @param {boolean} allowed Whether the given role can read this object.
- * @throws {TypeError} If role is neither a Parse.Role nor a String.
- */
- }, {
- key: "setRoleReadAccess",
- value: function (role
- /*: ParseRole | string*/
- , allowed
- /*: boolean*/
- ) {
- if (role instanceof _ParseRole.default) {
- // Normalize to the String name
- role = role.getName();
- }
- if (typeof role !== 'string') {
- throw new TypeError('role must be a ParseRole or a String');
- }
- this.setReadAccess("role:".concat(role), allowed);
- }
- /**
- * Sets whether users belonging to the given role are allowed
- * to write this object.
- *
- * @param role The name of the role, or a Parse.Role object.
- * @param {boolean} allowed Whether the given role can write this object.
- * @throws {TypeError} If role is neither a Parse.Role nor a String.
- */
- }, {
- key: "setRoleWriteAccess",
- value: function (role
- /*: ParseRole | string*/
- , allowed
- /*: boolean*/
- ) {
- if (role instanceof _ParseRole.default) {
- // Normalize to the String name
- role = role.getName();
- }
- if (typeof role !== 'string') {
- throw new TypeError('role must be a ParseRole or a String');
- }
- this.setWriteAccess("role:".concat(role), allowed);
- }
- }]);
- return ParseACL;
- }();
- var _default = ParseACL;
- exports.default = _default;
- },{"./ParseRole":41,"./ParseUser":44,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/core-js-stable/object/keys":112,"@babel/runtime-corejs3/helpers/classCallCheck":145,"@babel/runtime-corejs3/helpers/createClass":147,"@babel/runtime-corejs3/helpers/defineProperty":148,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/helpers/typeof":164}],27:[function(_dereq_,module,exports){
- "use strict";
- var _sliceInstanceProperty2 = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/slice");
- var _Array$from = _dereq_("@babel/runtime-corejs3/core-js-stable/array/from");
- var _Symbol = _dereq_("@babel/runtime-corejs3/core-js-stable/symbol");
- var _getIteratorMethod = _dereq_("@babel/runtime-corejs3/core-js/get-iterator-method");
- var _Array$isArray2 = _dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array");
- var _Object$keys2 = _dereq_("@babel/runtime-corejs3/core-js-stable/object/keys");
- var _Object$getOwnPropertySymbols = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols");
- var _filterInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/filter");
- var _Object$getOwnPropertyDescriptor = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
- var _forEachInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each");
- var _Object$getOwnPropertyDescriptors = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors");
- var _Object$defineProperties = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-properties");
- var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
- var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
- _Object$defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = void 0;
- var _slicedToArray2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/slicedToArray"));
- var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
- var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
- var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
- var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
- var _map = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/map"));
- var _includes = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/includes"));
- var _every = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/every"));
- var _entries = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/entries"));
- var _slice = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/slice"));
- var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/keys"));
- var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
- var _ParseRole = _interopRequireDefault(_dereq_("./ParseRole"));
- var _ParseUser = _interopRequireDefault(_dereq_("./ParseUser"));
- function ownKeys(object, enumerableOnly) {
- var keys = _Object$keys2(object);
- if (_Object$getOwnPropertySymbols) {
- var symbols = _Object$getOwnPropertySymbols(object);
- enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) {
- return _Object$getOwnPropertyDescriptor(object, sym).enumerable;
- })), keys.push.apply(keys, symbols);
- }
- return keys;
- }
- function _objectSpread(target) {
- for (var i = 1; i < arguments.length; i++) {
- var _context3, _context4;
- var source = null != arguments[i] ? arguments[i] : {};
- i % 2 ? _forEachInstanceProperty(_context3 = ownKeys(Object(source), !0)).call(_context3, function (key) {
- (0, _defineProperty2.default)(target, key, source[key]);
- }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context4 = ownKeys(Object(source))).call(_context4, function (key) {
- _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key));
- });
- }
- return target;
- }
- function _createForOfIteratorHelper(o, allowArrayLike) {
- var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"];
- if (!it) {
- if (_Array$isArray2(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
- if (it) o = it;
- var i = 0;
- var F = function () {};
- return {
- s: F,
- n: function () {
- if (i >= o.length) return {
- done: true
- };
- return {
- done: false,
- value: o[i++]
- };
- },
- e: function (_e) {
- throw _e;
- },
- f: F
- };
- }
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
- }
- var normalCompletion = true,
- didErr = false,
- err;
- return {
- s: function () {
- it = it.call(o);
- },
- n: function () {
- var step = it.next();
- normalCompletion = step.done;
- return step;
- },
- e: function (_e2) {
- didErr = true;
- err = _e2;
- },
- f: function () {
- try {
- if (!normalCompletion && it.return != null) it.return();
- } finally {
- if (didErr) throw err;
- }
- }
- };
- }
- function _unsupportedIterableToArray(o, minLen) {
- var _context2;
- if (!o) return;
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
- var n = _sliceInstanceProperty2(_context2 = Object.prototype.toString.call(o)).call(_context2, 8, -1);
- if (n === "Object" && o.constructor) n = o.constructor.name;
- if (n === "Map" || n === "Set") return _Array$from(o);
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
- }
- function _arrayLikeToArray(arr, len) {
- if (len == null || len > arr.length) len = arr.length;
- for (var i = 0, arr2 = new Array(len); i < len; i++) {
- arr2[i] = arr[i];
- }
- return arr2;
- }
- var PUBLIC_KEY = '*';
- var VALID_PERMISSIONS
- /*: Map<string, UsersMap>*/
- = new _map.default();
- VALID_PERMISSIONS.set('get', {});
- VALID_PERMISSIONS.set('find', {});
- VALID_PERMISSIONS.set('count', {});
- VALID_PERMISSIONS.set('create', {});
- VALID_PERMISSIONS.set('update', {});
- VALID_PERMISSIONS.set('delete', {});
- VALID_PERMISSIONS.set('addField', {});
- var VALID_PERMISSIONS_EXTENDED
- /*: Map<string, UsersMap>*/
- = new _map.default();
- VALID_PERMISSIONS_EXTENDED.set('protectedFields', {});
- /**
- * Creates a new CLP.
- * If no argument is given, the CLP has no permissions for anyone.
- * If the argument is a Parse.User or Parse.Role, the CLP will have read and write
- * permission for only that user or role.
- * If the argument is any other JSON object, that object will be interpretted
- * as a serialized CLP created with toJSON().
- *
- * <p>A CLP, or Class Level Permissions can be added to any
- * <code>Parse.Schema</code> to restrict access to only a subset of users
- * of your application.</p>
- *
- * <p>
- * For get/count/find/create/update/delete/addField using the following functions:
- *
- * Entity is type Parse.User or Parse.Role or string
- * Role is type Parse.Role or Name of Parse.Role
- *
- * getGetRequiresAuthentication()
- * setGetRequiresAuthentication(allowed: boolean)
- * getGetPointerFields()
- * setGetPointerFields(pointerFields: string[])
- * getGetAccess(entity: Entity)
- * setGetAccess(entity: Entity, allowed: boolean)
- * getPublicGetAccess()
- * setPublicGetAccess(allowed: boolean)
- * getRoleGetAccess(role: Role)
- * setRoleGetAccess(role: Role, allowed: boolean)
- * getFindRequiresAuthentication()
- * setFindRequiresAuthentication(allowed: boolean)
- * getFindPointerFields()
- * setFindPointerFields(pointerFields: string[])
- * getFindAccess(entity: Entity)
- * setFindAccess(entity: Entity, allowed: boolean)
- * getPublicFindAccess()
- * setPublicFindAccess(allowed: boolean)
- * getRoleFindAccess(role: Role)
- * setRoleFindAccess(role: Role, allowed: boolean)
- * getCountRequiresAuthentication()
- * setCountRequiresAuthentication(allowed: boolean)
- * getCountPointerFields()
- * setCountPointerFields(pointerFields: string[])
- * getCountAccess(entity: Entity)
- * setCountAccess(entity: Entity, allowed: boolean)
- * getPublicCountAccess()
- * setPublicCountAccess(allowed: boolean)
- * getRoleCountAccess(role: Role)
- * setRoleCountAccess(role: Role, allowed: boolean)
- * getCreateRequiresAuthentication()
- * setCreateRequiresAuthentication(allowed: boolean)
- * getCreatePointerFields()
- * setCreatePointerFields(pointerFields: string[])
- * getCreateAccess(entity: Entity)
- * setCreateAccess(entity: Entity, allowed: boolean)
- * getPublicCreateAccess()
- * setPublicCreateAccess(allowed: Boolean)
- * getRoleCreateAccess(role: Role)
- * setRoleCreateAccess(role: Role, allowed: boolean)
- * getUpdateRequiresAuthentication()
- * setUpdateRequiresAuthentication(allowed: boolean)
- * getUpdatePointerFields()
- * setUpdatePointerFields(pointerFields: string[])
- * getUpdateAccess(entity: Entity)
- * setUpdateAccess(entity: Entity, allowed: boolean)
- * getPublicUpdateAccess()
- * setPublicUpdateAccess(allowed: boolean)
- * getRoleUpdateAccess(role: Role)
- * setRoleUpdateAccess(role: Role, allowed: boolean)
- * getDeleteRequiresAuthentication()
- * setDeleteRequiresAuthentication(allowed: boolean)
- * getDeletePointerFields()
- * setDeletePointerFields(pointerFields: string[])
- * getDeleteAccess(entity: Entity)
- * setDeleteAccess(entity: Entity, allowed: boolean)
- * getPublicDeleteAccess()
- * setPublicDeleteAccess(allowed: boolean)
- * getRoleDeleteAccess(role: Role)
- * setRoleDeleteAccess(role: Role, allowed: boolean)
- * getAddFieldRequiresAuthentication()
- * setAddFieldRequiresAuthentication(allowed: boolean)
- * getAddFieldPointerFields()
- * setAddFieldPointerFields(pointerFields: string[])
- * getAddFieldAccess(entity: Entity)
- * setAddFieldAccess(entity: Entity, allowed: boolean)
- * getPublicAddFieldAccess()
- * setPublicAddFieldAccess(allowed: boolean)
- * getRoleAddFieldAccess(role: Role)
- * setRoleAddFieldAccess(role: Role, allowed: boolean)
- * </p>
- *
- * @alias Parse.CLP
- */
- var ParseCLP = /*#__PURE__*/function () {
- /**
- * @param {(Parse.User | Parse.Role | object)} userId The user to initialize the CLP for
- */
- function ParseCLP(userId
- /*: ParseUser | ParseRole | PermissionsMap*/
- ) {
- var _this = this;
- (0, _classCallCheck2.default)(this, ParseCLP);
- (0, _defineProperty2.default)(this, "permissionsMap", void 0);
- this.permissionsMap = {}; // Initialize permissions Map with default permissions
- var _iterator = _createForOfIteratorHelper((0, _entries.default)(VALID_PERMISSIONS).call(VALID_PERMISSIONS)),
- _step;
- try {
- var _loop = function () {
- var _step$value = (0, _slicedToArray2.default)(_step.value, 2),
- operation = _step$value[0],
- group = _step$value[1];
- _this.permissionsMap[operation] = _objectSpread({}, group);
- var action = operation.charAt(0).toUpperCase() + (0, _slice.default)(operation).call(operation, 1);
- _this["get".concat(action, "RequiresAuthentication")] = function () {
- return this._getAccess(operation, 'requiresAuthentication');
- };
- _this["set".concat(action, "RequiresAuthentication")] = function (allowed) {
- this._setAccess(operation, 'requiresAuthentication', allowed);
- };
- _this["get".concat(action, "PointerFields")] = function () {
- return this._getAccess(operation, 'pointerFields', false);
- };
- _this["set".concat(action, "PointerFields")] = function (pointerFields) {
- this._setArrayAccess(operation, 'pointerFields', pointerFields);
- };
- _this["get".concat(action, "Access")] = function (entity) {
- return this._getAccess(operation, entity);
- };
- _this["set".concat(action, "Access")] = function (entity, allowed) {
- this._setAccess(operation, entity, allowed);
- };
- _this["getPublic".concat(action, "Access")] = function () {
- return this["get".concat(action, "Access")](PUBLIC_KEY);
- };
- _this["setPublic".concat(action, "Access")] = function (allowed) {
- this["set".concat(action, "Access")](PUBLIC_KEY, allowed);
- };
- _this["getRole".concat(action, "Access")] = function (role) {
- return this["get".concat(action, "Access")](this._getRoleName(role));
- };
- _this["setRole".concat(action, "Access")] = function (role, allowed) {
- this["set".concat(action, "Access")](this._getRoleName(role), allowed);
- };
- };
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
- _loop();
- } // Initialize permissions Map with default extended permissions
- } catch (err) {
- _iterator.e(err);
- } finally {
- _iterator.f();
- }
- var _iterator2 = _createForOfIteratorHelper((0, _entries.default)(VALID_PERMISSIONS_EXTENDED).call(VALID_PERMISSIONS_EXTENDED)),
- _step2;
- try {
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
- var _step2$value = (0, _slicedToArray2.default)(_step2.value, 2),
- operation = _step2$value[0],
- group = _step2$value[1];
- this.permissionsMap[operation] = _objectSpread({}, group);
- }
- } catch (err) {
- _iterator2.e(err);
- } finally {
- _iterator2.f();
- }
- if (userId && (0, _typeof2.default)(userId) === 'object') {
- if (userId instanceof _ParseUser.default) {
- this.setReadAccess(userId, true);
- this.setWriteAccess(userId, true);
- } else if (userId instanceof _ParseRole.default) {
- this.setRoleReadAccess(userId, true);
- this.setRoleWriteAccess(userId, true);
- } else {
- for (var _permission in userId) {
- var _context;
- var users = userId[_permission];
- var isValidPermission = !!VALID_PERMISSIONS.get(_permission);
- var isValidPermissionExtended = !!VALID_PERMISSIONS_EXTENDED.get(_permission);
- var isValidGroupPermission = (0, _includes.default)(_context = ['readUserFields', 'writeUserFields']).call(_context, _permission);
- if (typeof _permission !== 'string' || !(isValidPermission || isValidPermissionExtended || isValidGroupPermission)) {
- throw new TypeError('Tried to create an CLP with an invalid permission type.');
- }
- if (isValidGroupPermission) {
- if ((0, _every.default)(users).call(users, function (pointer) {
- return typeof pointer === 'string';
- })) {
- this.permissionsMap[_permission] = users;
- continue;
- } else {
- throw new TypeError('Tried to create an CLP with an invalid permission value.');
- }
- }
- for (var user in users) {
- var allowed = users[user];
- if (typeof allowed !== 'boolean' && !isValidPermissionExtended && user !== 'pointerFields') {
- throw new TypeError('Tried to create an CLP with an invalid permission value.');
- }
- this.permissionsMap[_permission][user] = allowed;
- }
- }
- }
- } else if (typeof userId === 'function') {
- throw new TypeError('ParseCLP constructed with a function. Did you forget ()?');
- }
- }
- /**
- * Returns a JSON-encoded version of the CLP.
- *
- * @returns {object}
- */
- (0, _createClass2.default)(ParseCLP, [{
- key: "toJSON",
- value: function ()
- /*: PermissionsMap*/
- {
- return _objectSpread({}, this.permissionsMap);
- }
- /**
- * Returns whether this CLP is equal to another object
- *
- * @param other The other object to compare to
- * @returns {boolean}
- */
- }, {
- key: "equals",
- value: function (other
- /*: ParseCLP*/
- )
- /*: boolean*/
- {
- if (!(other instanceof ParseCLP)) {
- return false;
- }
- var permissions = (0, _keys.default)(this.permissionsMap);
- var otherPermissions = (0, _keys.default)(other.permissionsMap);
- if (permissions.length !== otherPermissions.length) {
- return false;
- }
- for (var _permission2 in this.permissionsMap) {
- if (!other.permissionsMap[_permission2]) {
- return false;
- }
- var users = (0, _keys.default)(this.permissionsMap[_permission2]);
- var otherUsers = (0, _keys.default)(other.permissionsMap[_permission2]);
- if (users.length !== otherUsers.length) {
- return false;
- }
- for (var user in this.permissionsMap[_permission2]) {
- if (!other.permissionsMap[_permission2][user]) {
- return false;
- }
- if (this.permissionsMap[_permission2][user] !== other.permissionsMap[_permission2][user]) {
- return false;
- }
- }
- }
- return true;
- }
- }, {
- key: "_getRoleName",
- value: function (role
- /*: ParseRole | string*/
- )
- /*: string*/
- {
- var name = role;
- if (role instanceof _ParseRole.default) {
- // Normalize to the String name
- name = role.getName();
- }
- if (typeof name !== 'string') {
- throw new TypeError('role must be a Parse.Role or a String');
- }
- return "role:".concat(name);
- }
- }, {
- key: "_parseEntity",
- value: function (entity
- /*: Entity*/
- ) {
- var userId = entity;
- if (userId instanceof _ParseUser.default) {
- userId = userId.id;
- if (!userId) {
- throw new Error('Cannot get access for a Parse.User without an id.');
- }
- } else if (userId instanceof _ParseRole.default) {
- userId = this._getRoleName(userId);
- }
- if (typeof userId !== 'string') {
- throw new TypeError('userId must be a string.');
- }
- return userId;
- }
- }, {
- key: "_setAccess",
- value: function (permission
- /*: string*/
- , userId
- /*: Entity*/
- , allowed
- /*: boolean*/
- ) {
- userId = this._parseEntity(userId);
- if (typeof allowed !== 'boolean') {
- throw new TypeError('allowed must be either true or false.');
- }
- var permissions = this.permissionsMap[permission][userId];
- if (!permissions) {
- if (!allowed) {
- // The user already doesn't have this permission, so no action is needed
- return;
- }
- this.permissionsMap[permission][userId] = {};
- }
- if (allowed) {
- this.permissionsMap[permission][userId] = true;
- } else {
- delete this.permissionsMap[permission][userId];
- }
- }
- }, {
- key: "_getAccess",
- value: function (permission
- /*: string*/
- , userId
- /*: Entity*/
- )
- /*: boolean | string[]*/
- {
- var returnBoolean = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
- userId = this._parseEntity(userId);
- var permissions = this.permissionsMap[permission][userId];
- if (returnBoolean) {
- if (!permissions) {
- return false;
- }
- return !!this.permissionsMap[permission][userId];
- }
- return permissions;
- }
- }, {
- key: "_setArrayAccess",
- value: function (permission
- /*: string*/
- , userId
- /*: Entity*/
- , fields
- /*: string*/
- ) {
- userId = this._parseEntity(userId);
- var permissions = this.permissionsMap[permission][userId];
- if (!permissions) {
- this.permissionsMap[permission][userId] = [];
- }
- if (!fields || (0, _isArray.default)(fields) && fields.length === 0) {
- delete this.permissionsMap[permission][userId];
- } else if ((0, _isArray.default)(fields) && (0, _every.default)(fields).call(fields, function (field) {
- return typeof field === 'string';
- })) {
- this.permissionsMap[permission][userId] = fields;
- } else {
- throw new TypeError('fields must be an array of strings or undefined.');
- }
- }
- }, {
- key: "_setGroupPointerPermission",
- value: function (operation
- /*: string*/
- , pointerFields
- /*: string[]*/
- ) {
- var fields = this.permissionsMap[operation];
- if (!fields) {
- this.permissionsMap[operation] = [];
- }
- if (!pointerFields || (0, _isArray.default)(pointerFields) && pointerFields.length === 0) {
- delete this.permissionsMap[operation];
- } else if ((0, _isArray.default)(pointerFields) && (0, _every.default)(pointerFields).call(pointerFields, function (field) {
- return typeof field === 'string';
- })) {
- this.permissionsMap[operation] = pointerFields;
- } else {
- throw new TypeError("".concat(operation, ".pointerFields must be an array of strings or undefined."));
- }
- }
- }, {
- key: "_getGroupPointerPermissions",
- value: function (operation
- /*: string*/
- )
- /*: string[]*/
- {
- return this.permissionsMap[operation];
- }
- /**
- * Sets user pointer fields to allow permission for get/count/find operations.
- *
- * @param {string[]} pointerFields User pointer fields
- */
- }, {
- key: "setReadUserFields",
- value: function (pointerFields
- /*: string[]*/
- ) {
- this._setGroupPointerPermission('readUserFields', pointerFields);
- }
- /**
- * @returns {string[]} User pointer fields
- */
- }, {
- key: "getReadUserFields",
- value: function ()
- /*: string[]*/
- {
- return this._getGroupPointerPermissions('readUserFields');
- }
- /**
- * Sets user pointer fields to allow permission for create/delete/update/addField operations
- *
- * @param {string[]} pointerFields User pointer fields
- */
- }, {
- key: "setWriteUserFields",
- value: function (pointerFields
- /*: string[]*/
- ) {
- this._setGroupPointerPermission('writeUserFields', pointerFields);
- }
- /**
- * @returns {string[]} User pointer fields
- */
- }, {
- key: "getWriteUserFields",
- value: function ()
- /*: string[]*/
- {
- return this._getGroupPointerPermissions('writeUserFields');
- }
- /**
- * Sets whether the given user is allowed to retrieve fields from this class.
- *
- * @param userId An instance of Parse.User or its objectId.
- * @param {string[]} fields fields to be protected
- */
- }, {
- key: "setProtectedFields",
- value: function (userId
- /*: Entity*/
- , fields
- /*: string[]*/
- ) {
- this._setArrayAccess('protectedFields', userId, fields);
- }
- /**
- * Returns array of fields are accessable to this user.
- *
- * @param userId An instance of Parse.User or its objectId, or a Parse.Role.
- * @returns {string[]}
- */
- }, {
- key: "getProtectedFields",
- value: function (userId
- /*: Entity*/
- )
- /*: string[]*/
- {
- return this._getAccess('protectedFields', userId, false);
- }
- /**
- * Sets whether the given user is allowed to read from this class.
- *
- * @param userId An instance of Parse.User or its objectId.
- * @param {boolean} allowed whether that user should have read access.
- */
- }, {
- key: "setReadAccess",
- value: function (userId
- /*: Entity*/
- , allowed
- /*: boolean*/
- ) {
- this._setAccess('find', userId, allowed);
- this._setAccess('get', userId, allowed);
- this._setAccess('count', userId, allowed);
- }
- /**
- * Get whether the given user id is *explicitly* allowed to read from this class.
- * Even if this returns false, the user may still be able to access it if
- * getPublicReadAccess returns true or a role that the user belongs to has
- * write access.
- *
- * @param userId An instance of Parse.User or its objectId, or a Parse.Role.
- * @returns {boolean}
- */
- }, {
- key: "getReadAccess",
- value: function (userId
- /*: Entity*/
- )
- /*: boolean*/
- {
- return this._getAccess('find', userId) && this._getAccess('get', userId) && this._getAccess('count', userId);
- }
- /**
- * Sets whether the given user id is allowed to write to this class.
- *
- * @param userId An instance of Parse.User or its objectId, or a Parse.Role..
- * @param {boolean} allowed Whether that user should have write access.
- */
- }, {
- key: "setWriteAccess",
- value: function (userId
- /*: Entity*/
- , allowed
- /*: boolean*/
- ) {
- this._setAccess('create', userId, allowed);
- this._setAccess('update', userId, allowed);
- this._setAccess('delete', userId, allowed);
- this._setAccess('addField', userId, allowed);
- }
- /**
- * Gets whether the given user id is *explicitly* allowed to write to this class.
- * Even if this returns false, the user may still be able to write it if
- * getPublicWriteAccess returns true or a role that the user belongs to has
- * write access.
- *
- * @param userId An instance of Parse.User or its objectId, or a Parse.Role.
- * @returns {boolean}
- */
- }, {
- key: "getWriteAccess",
- value: function (userId
- /*: Entity*/
- )
- /*: boolean*/
- {
- return this._getAccess('create', userId) && this._getAccess('update', userId) && this._getAccess('delete', userId) && this._getAccess('addField', userId);
- }
- /**
- * Sets whether the public is allowed to read from this class.
- *
- * @param {boolean} allowed
- */
- }, {
- key: "setPublicReadAccess",
- value: function (allowed
- /*: boolean*/
- ) {
- this.setReadAccess(PUBLIC_KEY, allowed);
- }
- /**
- * Gets whether the public is allowed to read from this class.
- *
- * @returns {boolean}
- */
- }, {
- key: "getPublicReadAccess",
- value: function ()
- /*: boolean*/
- {
- return this.getReadAccess(PUBLIC_KEY);
- }
- /**
- * Sets whether the public is allowed to write to this class.
- *
- * @param {boolean} allowed
- */
- }, {
- key: "setPublicWriteAccess",
- value: function (allowed
- /*: boolean*/
- ) {
- this.setWriteAccess(PUBLIC_KEY, allowed);
- }
- /**
- * Gets whether the public is allowed to write to this class.
- *
- * @returns {boolean}
- */
- }, {
- key: "getPublicWriteAccess",
- value: function ()
- /*: boolean*/
- {
- return this.getWriteAccess(PUBLIC_KEY);
- }
- /**
- * Sets whether the public is allowed to protect fields in this class.
- *
- * @param {string[]} fields
- */
- }, {
- key: "setPublicProtectedFields",
- value: function (fields
- /*: string[]*/
- ) {
- this.setProtectedFields(PUBLIC_KEY, fields);
- }
- /**
- * Gets whether the public is allowed to read fields from this class.
- *
- * @returns {string[]}
- */
- }, {
- key: "getPublicProtectedFields",
- value: function ()
- /*: string[]*/
- {
- return this.getProtectedFields(PUBLIC_KEY);
- }
- /**
- * Gets whether users belonging to the given role are allowed
- * to read from this class. Even if this returns false, the role may
- * still be able to write it if a parent role has read access.
- *
- * @param role The name of the role, or a Parse.Role object.
- * @returns {boolean} true if the role has read access. false otherwise.
- * @throws {TypeError} If role is neither a Parse.Role nor a String.
- */
- }, {
- key: "getRoleReadAccess",
- value: function (role
- /*: ParseRole | string*/
- )
- /*: boolean*/
- {
- return this.getReadAccess(this._getRoleName(role));
- }
- /**
- * Gets whether users belonging to the given role are allowed
- * to write to this user. Even if this returns false, the role may
- * still be able to write it if a parent role has write access.
- *
- * @param role The name of the role, or a Parse.Role object.
- * @returns {boolean} true if the role has write access. false otherwise.
- * @throws {TypeError} If role is neither a Parse.Role nor a String.
- */
- }, {
- key: "getRoleWriteAccess",
- value: function (role
- /*: ParseRole | string*/
- )
- /*: boolean*/
- {
- return this.getWriteAccess(this._getRoleName(role));
- }
- /**
- * Sets whether users belonging to the given role are allowed
- * to read from this class.
- *
- * @param role The name of the role, or a Parse.Role object.
- * @param {boolean} allowed Whether the given role can read this object.
- * @throws {TypeError} If role is neither a Parse.Role nor a String.
- */
- }, {
- key: "setRoleReadAccess",
- value: function (role
- /*: ParseRole | string*/
- , allowed
- /*: boolean*/
- ) {
- this.setReadAccess(this._getRoleName(role), allowed);
- }
- /**
- * Sets whether users belonging to the given role are allowed
- * to write to this class.
- *
- * @param role The name of the role, or a Parse.Role object.
- * @param {boolean} allowed Whether the given role can write this object.
- * @throws {TypeError} If role is neither a Parse.Role nor a String.
- */
- }, {
- key: "setRoleWriteAccess",
- value: function (role
- /*: ParseRole | string*/
- , allowed
- /*: boolean*/
- ) {
- this.setWriteAccess(this._getRoleName(role), allowed);
- }
- /**
- * Gets whether users belonging to the given role are allowed
- * to count to this user. Even if this returns false, the role may
- * still be able to count it if a parent role has count access.
- *
- * @param role The name of the role, or a Parse.Role object.
- * @returns {string[]}
- * @throws {TypeError} If role is neither a Parse.Role nor a String.
- */
- }, {
- key: "getRoleProtectedFields",
- value: function (role
- /*: ParseRole | string*/
- )
- /*: string[]*/
- {
- return this.getProtectedFields(this._getRoleName(role));
- }
- /**
- * Sets whether users belonging to the given role are allowed
- * to set access field in this class.
- *
- * @param role The name of the role, or a Parse.Role object.
- * @param {string[]} fields Fields to be protected by Role.
- * @throws {TypeError} If role is neither a Parse.Role nor a String.
- */
- }, {
- key: "setRoleProtectedFields",
- value: function (role
- /*: ParseRole | string*/
- , fields
- /*: string[]*/
- ) {
- this.setProtectedFields(this._getRoleName(role), fields);
- }
- }]);
- return ParseCLP;
- }();
- var _default = ParseCLP;
- exports.default = _default;
- },{"./ParseRole":41,"./ParseUser":44,"@babel/runtime-corejs3/core-js-stable/array/from":78,"@babel/runtime-corejs3/core-js-stable/array/is-array":79,"@babel/runtime-corejs3/core-js-stable/instance/entries":82,"@babel/runtime-corejs3/core-js-stable/instance/every":83,"@babel/runtime-corejs3/core-js-stable/instance/filter":84,"@babel/runtime-corejs3/core-js-stable/instance/for-each":86,"@babel/runtime-corejs3/core-js-stable/instance/includes":87,"@babel/runtime-corejs3/core-js-stable/instance/slice":93,"@babel/runtime-corejs3/core-js-stable/map":100,"@babel/runtime-corejs3/core-js-stable/object/define-properties":104,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor":108,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors":109,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols":110,"@babel/runtime-corejs3/core-js-stable/object/keys":112,"@babel/runtime-corejs3/core-js-stable/symbol":119,"@babel/runtime-corejs3/core-js/get-iterator-method":125,"@babel/runtime-corejs3/helpers/classCallCheck":145,"@babel/runtime-corejs3/helpers/createClass":147,"@babel/runtime-corejs3/helpers/defineProperty":148,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/helpers/slicedToArray":161,"@babel/runtime-corejs3/helpers/typeof":164}],28:[function(_dereq_,module,exports){
- "use strict";
- var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
- var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
- _Object$defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = void 0;
- var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
- var _stringify = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/json/stringify"));
- var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
- var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
- var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
- var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
- var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
- var _decode = _interopRequireDefault(_dereq_("./decode"));
- var _encode = _interopRequireDefault(_dereq_("./encode"));
- var _escape2 = _interopRequireDefault(_dereq_("./escape"));
- var _ParseError = _interopRequireDefault(_dereq_("./ParseError"));
- var _Storage = _interopRequireDefault(_dereq_("./Storage"));
- /**
- * Copyright (c) 2015-present, Parse, LLC.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- *
- * @flow
- */
- /**
- * Parse.Config is a local representation of configuration data that
- * can be set from the Parse dashboard.
- *
- * @alias Parse.Config
- */
- var ParseConfig = /*#__PURE__*/function () {
- function ParseConfig() {
- (0, _classCallCheck2.default)(this, ParseConfig);
- (0, _defineProperty2.default)(this, "attributes", void 0);
- (0, _defineProperty2.default)(this, "_escapedAttributes", void 0);
- this.attributes = {};
- this._escapedAttributes = {};
- }
- /**
- * Gets the value of an attribute.
- *
- * @param {string} attr The name of an attribute.
- * @returns {*}
- */
- (0, _createClass2.default)(ParseConfig, [{
- key: "get",
- value: function (attr
- /*: string*/
- )
- /*: any*/
- {
- return this.attributes[attr];
- }
- /**
- * Gets the HTML-escaped value of an attribute.
- *
- * @param {string} attr The name of an attribute.
- * @returns {string}
- */
- }, {
- key: "escape",
- value: function (attr
- /*: string*/
- )
- /*: string*/
- {
- var html = this._escapedAttributes[attr];
- if (html) {
- return html;
- }
- var val = this.attributes[attr];
- var escaped = '';
- if (val != null) {
- escaped = (0, _escape2.default)(val.toString());
- }
- this._escapedAttributes[attr] = escaped;
- return escaped;
- }
- /**
- * Retrieves the most recently-fetched configuration object, either from
- * memory or from local storage if necessary.
- *
- * @static
- * @returns {Parse.Config} The most recently-fetched Parse.Config if it
- * exists, else an empty Parse.Config.
- */
- }], [{
- key: "current",
- value: function () {
- var controller = _CoreManager.default.getConfigController();
- return controller.current();
- }
- /**
- * Gets a new configuration object from the server.
- *
- * @static
- * @param {object} options
- * Valid options are:<ul>
- * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
- * be used for this request.
- * </ul>
- * @returns {Promise} A promise that is resolved with a newly-created
- * configuration object when the get completes.
- */
- }, {
- key: "get",
- value: function () {
- var options
- /*: RequestOptions*/
- = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
- var controller = _CoreManager.default.getConfigController();
- return controller.get(options);
- }
- /**
- * Save value keys to the server.
- *
- * @static
- * @param {object} attrs The config parameters and values.
- * @param {object} masterKeyOnlyFlags The flags that define whether config parameters listed
- * in `attrs` should be retrievable only by using the master key.
- * For example: `param1: true` makes `param1` only retrievable by using the master key.
- * If a parameter is not provided or set to `false`, it can be retrieved without
- * using the master key.
- * @returns {Promise} A promise that is resolved with a newly-created
- * configuration object or with the current with the update.
- */
- }, {
- key: "save",
- value: function (attrs
- /*: { [key: string]: any }*/
- , masterKeyOnlyFlags
- /*: { [key: string]: any }*/
- ) {
- var controller = _CoreManager.default.getConfigController(); // To avoid a mismatch with the local and the cloud config we get a new version
- return controller.save(attrs, masterKeyOnlyFlags).then(function () {
- return controller.get({
- useMasterKey: true
- });
- }, function (error) {
- return _promise.default.reject(error);
- });
- }
- /**
- * Used for testing
- *
- * @private
- */
- }, {
- key: "_clearCache",
- value: function () {
- currentConfig = null;
- }
- }]);
- return ParseConfig;
- }();
- var currentConfig = null;
- var CURRENT_CONFIG_KEY = 'currentConfig';
- function decodePayload(data) {
- try {
- var json = JSON.parse(data);
- if (json && (0, _typeof2.default)(json) === 'object') {
- return (0, _decode.default)(json);
- }
- } catch (e) {
- return null;
- }
- }
- var DefaultController = {
- current: function () {
- if (currentConfig) {
- return currentConfig;
- }
- var config = new ParseConfig();
- var storagePath = _Storage.default.generatePath(CURRENT_CONFIG_KEY);
- if (!_Storage.default.async()) {
- var configData = _Storage.default.getItem(storagePath);
- if (configData) {
- var attributes = decodePayload(configData);
- if (attributes) {
- config.attributes = attributes;
- currentConfig = config;
- }
- }
- return config;
- } // Return a promise for async storage controllers
- return _Storage.default.getItemAsync(storagePath).then(function (configData) {
- if (configData) {
- var _attributes = decodePayload(configData);
- if (_attributes) {
- config.attributes = _attributes;
- currentConfig = config;
- }
- }
- return config;
- });
- },
- get: function () {
- var options
- /*: RequestOptions*/
- = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
- var RESTController = _CoreManager.default.getRESTController();
- return RESTController.request('GET', 'config', {}, options).then(function (response) {
- if (!response || !response.params) {
- var error = new _ParseError.default(_ParseError.default.INVALID_JSON, 'Config JSON response invalid.');
- return _promise.default.reject(error);
- }
- var config = new ParseConfig();
- config.attributes = {};
- for (var attr in response.params) {
- config.attributes[attr] = (0, _decode.default)(response.params[attr]);
- }
- currentConfig = config;
- return _Storage.default.setItemAsync(_Storage.default.generatePath(CURRENT_CONFIG_KEY), (0, _stringify.default)(response.params)).then(function () {
- return config;
- });
- });
- },
- save: function (attrs
- /*: { [key: string]: any }*/
- , masterKeyOnlyFlags
- /*: { [key: string]: any }*/
- ) {
- var RESTController = _CoreManager.default.getRESTController();
- var encodedAttrs = {};
- for (var _key in attrs) {
- encodedAttrs[_key] = (0, _encode.default)(attrs[_key]);
- }
- return RESTController.request('PUT', 'config', {
- params: encodedAttrs,
- masterKeyOnly: masterKeyOnlyFlags
- }, {
- useMasterKey: true
- }).then(function (response) {
- if (response && response.result) {
- return _promise.default.resolve();
- }
- var error = new _ParseError.default(_ParseError.default.INTERNAL_SERVER_ERROR, 'Error occured updating Config.');
- return _promise.default.reject(error);
- });
- }
- };
- _CoreManager.default.setConfigController(DefaultController);
- var _default = ParseConfig;
- exports.default = _default;
- },{"./CoreManager":5,"./ParseError":29,"./Storage":48,"./decode":65,"./encode":66,"./escape":68,"@babel/runtime-corejs3/core-js-stable/json/stringify":99,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/core-js-stable/promise":115,"@babel/runtime-corejs3/helpers/classCallCheck":145,"@babel/runtime-corejs3/helpers/createClass":147,"@babel/runtime-corejs3/helpers/defineProperty":148,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/helpers/typeof":164}],29:[function(_dereq_,module,exports){
- "use strict";
- var _Reflect$construct = _dereq_("@babel/runtime-corejs3/core-js-stable/reflect/construct");
- var _Object$defineProperty2 = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
- var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
- _Object$defineProperty2(exports, "__esModule", {
- value: true
- });
- exports.default = void 0;
- var _defineProperty = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property"));
- var _concat = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/concat"));
- var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
- var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
- var _assertThisInitialized2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/assertThisInitialized"));
- var _inherits2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/inherits"));
- var _possibleConstructorReturn2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/possibleConstructorReturn"));
- var _getPrototypeOf2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/getPrototypeOf"));
- var _wrapNativeSuper2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/wrapNativeSuper"));
- function _createSuper(Derived) {
- var hasNativeReflectConstruct = _isNativeReflectConstruct();
- return function () {
- var Super = (0, _getPrototypeOf2.default)(Derived),
- result;
- if (hasNativeReflectConstruct) {
- var NewTarget = (0, _getPrototypeOf2.default)(this).constructor;
- result = _Reflect$construct(Super, arguments, NewTarget);
- } else {
- result = Super.apply(this, arguments);
- }
- return (0, _possibleConstructorReturn2.default)(this, result);
- };
- }
- function _isNativeReflectConstruct() {
- if (typeof Reflect === "undefined" || !_Reflect$construct) return false;
- if (_Reflect$construct.sham) return false;
- if (typeof Proxy === "function") return true;
- try {
- Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {}));
- return true;
- } catch (e) {
- return false;
- }
- }
- /**
- * Copyright (c) 2015-present, Parse, LLC.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
- /**
- * Constructs a new Parse.Error object with the given code and message.
- *
- * @alias Parse.Error
- */
- var ParseError = /*#__PURE__*/function (_Error) {
- (0, _inherits2.default)(ParseError, _Error);
- var _super = _createSuper(ParseError);
- /**
- * @param {number} code An error code constant from <code>Parse.Error</code>.
- * @param {string} message A detailed description of the error.
- */
- function ParseError(code, message) {
- var _this;
- (0, _classCallCheck2.default)(this, ParseError);
- _this = _super.call(this, message);
- _this.code = code;
- (0, _defineProperty.default)((0, _assertThisInitialized2.default)(_this), 'message', {
- enumerable: true,
- value: message
- });
- return _this;
- }
- (0, _createClass2.default)(ParseError, [{
- key: "toString",
- value: function () {
- var _context;
- return (0, _concat.default)(_context = "ParseError: ".concat(this.code, " ")).call(_context, this.message);
- }
- }]);
- return ParseError;
- }( /*#__PURE__*/(0, _wrapNativeSuper2.default)(Error));
- /**
- * Error code indicating some error other than those enumerated here.
- *
- * @property {number} OTHER_CAUSE
- * @static
- */
- ParseError.OTHER_CAUSE = -1;
- /**
- * Error code indicating that something has gone wrong with the server.
- *
- * @property {number} INTERNAL_SERVER_ERROR
- * @static
- */
- ParseError.INTERNAL_SERVER_ERROR = 1;
- /**
- * Error code indicating the connection to the Parse servers failed.
- *
- * @property {number} CONNECTION_FAILED
- * @static
- */
- ParseError.CONNECTION_FAILED = 100;
- /**
- * Error code indicating the specified object doesn't exist.
- *
- * @property {number} OBJECT_NOT_FOUND
- * @static
- */
- ParseError.OBJECT_NOT_FOUND = 101;
- /**
- * Error code indicating you tried to query with a datatype that doesn't
- * support it, like exact matching an array or object.
- *
- * @property {number} INVALID_QUERY
- * @static
- */
- ParseError.INVALID_QUERY = 102;
- /**
- * Error code indicating a missing or invalid classname. Classnames are
- * case-sensitive. They must start with a letter, and a-zA-Z0-9_ are the
- * only valid characters.
- *
- * @property {number} INVALID_CLASS_NAME
- * @static
- */
- ParseError.INVALID_CLASS_NAME = 103;
- /**
- * Error code indicating an unspecified object id.
- *
- * @property {number} MISSING_OBJECT_ID
- * @static
- */
- ParseError.MISSING_OBJECT_ID = 104;
- /**
- * Error code indicating an invalid key name. Keys are case-sensitive. They
- * must start with a letter, and a-zA-Z0-9_ are the only valid characters.
- *
- * @property {number} INVALID_KEY_NAME
- * @static
- */
- ParseError.INVALID_KEY_NAME = 105;
- /**
- * Error code indicating a malformed pointer. You should not see this unless
- * you have been mucking about changing internal Parse code.
- *
- * @property {number} INVALID_POINTER
- * @static
- */
- ParseError.INVALID_POINTER = 106;
- /**
- * Error code indicating that badly formed JSON was received upstream. This
- * either indicates you have done something unusual with modifying how
- * things encode to JSON, or the network is failing badly.
- *
- * @property {number} INVALID_JSON
- * @static
- */
- ParseError.INVALID_JSON = 107;
- /**
- * Error code indicating that the feature you tried to access is only
- * available internally for testing purposes.
- *
- * @property {number} COMMAND_UNAVAILABLE
- * @static
- */
- ParseError.COMMAND_UNAVAILABLE = 108;
- /**
- * You must call Parse.initialize before using the Parse library.
- *
- * @property {number} NOT_INITIALIZED
- * @static
- */
- ParseError.NOT_INITIALIZED = 109;
- /**
- * Error code indicating that a field was set to an inconsistent type.
- *
- * @property {number} INCORRECT_TYPE
- * @static
- */
- ParseError.INCORRECT_TYPE = 111;
- /**
- * Error code indicating an invalid channel name. A channel name is either
- * an empty string (the broadcast channel) or contains only a-zA-Z0-9_
- * characters and starts with a letter.
- *
- * @property {number} INVALID_CHANNEL_NAME
- * @static
- */
- ParseError.INVALID_CHANNEL_NAME = 112;
- /**
- * Error code indicating that push is misconfigured.
- *
- * @property {number} PUSH_MISCONFIGURED
- * @static
- */
- ParseError.PUSH_MISCONFIGURED = 115;
- /**
- * Error code indicating that the object is too large.
- *
- * @property {number} OBJECT_TOO_LARGE
- * @static
- */
- ParseError.OBJECT_TOO_LARGE = 116;
- /**
- * Error code indicating that the operation isn't allowed for clients.
- *
- * @property {number} OPERATION_FORBIDDEN
- * @static
- */
- ParseError.OPERATION_FORBIDDEN = 119;
- /**
- * Error code indicating the result was not found in the cache.
- *
- * @property {number} CACHE_MISS
- * @static
- */
- ParseError.CACHE_MISS = 120;
- /**
- * Error code indicating that an invalid key was used in a nested
- * JSONObject.
- *
- * @property {number} INVALID_NESTED_KEY
- * @static
- */
- ParseError.INVALID_NESTED_KEY = 121;
- /**
- * Error code indicating that an invalid filename was used for ParseFile.
- * A valid file name contains only a-zA-Z0-9_. characters and is between 1
- * and 128 characters.
- *
- * @property {number} INVALID_FILE_NAME
- * @static
- */
- ParseError.INVALID_FILE_NAME = 122;
- /**
- * Error code indicating an invalid ACL was provided.
- *
- * @property {number} INVALID_ACL
- * @static
- */
- ParseError.INVALID_ACL = 123;
- /**
- * Error code indicating that the request timed out on the server. Typically
- * this indicates that the request is too expensive to run.
- *
- * @property {number} TIMEOUT
- * @static
- */
- ParseError.TIMEOUT = 124;
- /**
- * Error code indicating that the email address was invalid.
- *
- * @property {number} INVALID_EMAIL_ADDRESS
- * @static
- */
- ParseError.INVALID_EMAIL_ADDRESS = 125;
- /**
- * Error code indicating a missing content type.
- *
- * @property {number} MISSING_CONTENT_TYPE
- * @static
- */
- ParseError.MISSING_CONTENT_TYPE = 126;
- /**
- * Error code indicating a missing content length.
- *
- * @property {number} MISSING_CONTENT_LENGTH
- * @static
- */
- ParseError.MISSING_CONTENT_LENGTH = 127;
- /**
- * Error code indicating an invalid content length.
- *
- * @property {number} INVALID_CONTENT_LENGTH
- * @static
- */
- ParseError.INVALID_CONTENT_LENGTH = 128;
- /**
- * Error code indicating a file that was too large.
- *
- * @property {number} FILE_TOO_LARGE
- * @static
- */
- ParseError.FILE_TOO_LARGE = 129;
- /**
- * Error code indicating an error saving a file.
- *
- * @property {number} FILE_SAVE_ERROR
- * @static
- */
- ParseError.FILE_SAVE_ERROR = 130;
- /**
- * Error code indicating that a unique field was given a value that is
- * already taken.
- *
- * @property {number} DUPLICATE_VALUE
- * @static
- */
- ParseError.DUPLICATE_VALUE = 137;
- /**
- * Error code indicating that a role's name is invalid.
- *
- * @property {number} INVALID_ROLE_NAME
- * @static
- */
- ParseError.INVALID_ROLE_NAME = 139;
- /**
- * Error code indicating that an application quota was exceeded. Upgrade to
- * resolve.
- *
- * @property {number} EXCEEDED_QUOTA
- * @static
- */
- ParseError.EXCEEDED_QUOTA = 140;
- /**
- * Error code indicating that a Cloud Code script failed.
- *
- * @property {number} SCRIPT_FAILED
- * @static
- */
- ParseError.SCRIPT_FAILED = 141;
- /**
- * Error code indicating that a Cloud Code validation failed.
- *
- * @property {number} VALIDATION_ERROR
- * @static
- */
- ParseError.VALIDATION_ERROR = 142;
- /**
- * Error code indicating that invalid image data was provided.
- *
- * @property {number} INVALID_IMAGE_DATA
- * @static
- */
- ParseError.INVALID_IMAGE_DATA = 143;
- /**
- * Error code indicating an unsaved file.
- *
- * @property {number} UNSAVED_FILE_ERROR
- * @static
- */
- ParseError.UNSAVED_FILE_ERROR = 151;
- /**
- * Error code indicating an invalid push time.
- *
- * @property {number} INVALID_PUSH_TIME_ERROR
- * @static
- */
- ParseError.INVALID_PUSH_TIME_ERROR = 152;
- /**
- * Error code indicating an error deleting a file.
- *
- * @property {number} FILE_DELETE_ERROR
- * @static
- */
- ParseError.FILE_DELETE_ERROR = 153;
- /**
- * Error code indicating an error deleting an unnamed file.
- *
- * @property {number} FILE_DELETE_UNNAMED_ERROR
- * @static
- */
- ParseError.FILE_DELETE_UNNAMED_ERROR = 161;
- /**
- * Error code indicating that the application has exceeded its request
- * limit.
- *
- * @property {number} REQUEST_LIMIT_EXCEEDED
- * @static
- */
- ParseError.REQUEST_LIMIT_EXCEEDED = 155;
- /**
- * Error code indicating that the request was a duplicate and has been discarded due to
- * idempotency rules.
- *
- * @property {number} DUPLICATE_REQUEST
- * @static
- */
- ParseError.DUPLICATE_REQUEST = 159;
- /**
- * Error code indicating an invalid event name.
- *
- * @property {number} INVALID_EVENT_NAME
- * @static
- */
- ParseError.INVALID_EVENT_NAME = 160;
- /**
- * Error code indicating that the username is missing or empty.
- *
- * @property {number} USERNAME_MISSING
- * @static
- */
- ParseError.USERNAME_MISSING = 200;
- /**
- * Error code indicating that the password is missing or empty.
- *
- * @property {number} PASSWORD_MISSING
- * @static
- */
- ParseError.PASSWORD_MISSING = 201;
- /**
- * Error code indicating that the username has already been taken.
- *
- * @property {number} USERNAME_TAKEN
- * @static
- */
- ParseError.USERNAME_TAKEN = 202;
- /**
- * Error code indicating that the email has already been taken.
- *
- * @property {number} EMAIL_TAKEN
- * @static
- */
- ParseError.EMAIL_TAKEN = 203;
- /**
- * Error code indicating that the email is missing, but must be specified.
- *
- * @property {number} EMAIL_MISSING
- * @static
- */
- ParseError.EMAIL_MISSING = 204;
- /**
- * Error code indicating that a user with the specified email was not found.
- *
- * @property {number} EMAIL_NOT_FOUND
- * @static
- */
- ParseError.EMAIL_NOT_FOUND = 205;
- /**
- * Error code indicating that a user object without a valid session could
- * not be altered.
- *
- * @property {number} SESSION_MISSING
- * @static
- */
- ParseError.SESSION_MISSING = 206;
- /**
- * Error code indicating that a user can only be created through signup.
- *
- * @property {number} MUST_CREATE_USER_THROUGH_SIGNUP
- * @static
- */
- ParseError.MUST_CREATE_USER_THROUGH_SIGNUP = 207;
- /**
- * Error code indicating that an an account being linked is already linked
- * to another user.
- *
- * @property {number} ACCOUNT_ALREADY_LINKED
- * @static
- */
- ParseError.ACCOUNT_ALREADY_LINKED = 208;
- /**
- * Error code indicating that the current session token is invalid.
- *
- * @property {number} INVALID_SESSION_TOKEN
- * @static
- */
- ParseError.INVALID_SESSION_TOKEN = 209;
- /**
- * Error code indicating an error enabling or verifying MFA
- *
- * @property {number} MFA_ERROR
- * @static
- */
- ParseError.MFA_ERROR = 210;
- /**
- * Error code indicating that a valid MFA token must be provided
- *
- * @property {number} MFA_TOKEN_REQUIRED
- * @static
- */
- ParseError.MFA_TOKEN_REQUIRED = 211;
- /**
- * Error code indicating that a user cannot be linked to an account because
- * that account's id could not be found.
- *
- * @property {number} LINKED_ID_MISSING
- * @static
- */
- ParseError.LINKED_ID_MISSING = 250;
- /**
- * Error code indicating that a user with a linked (e.g. Facebook) account
- * has an invalid session.
- *
- * @property {number} INVALID_LINKED_SESSION
- * @static
- */
- ParseError.INVALID_LINKED_SESSION = 251;
- /**
- * Error code indicating that a service being linked (e.g. Facebook or
- * Twitter) is unsupported.
- *
- * @property {number} UNSUPPORTED_SERVICE
- * @static
- */
- ParseError.UNSUPPORTED_SERVICE = 252;
- /**
- * Error code indicating an invalid operation occured on schema
- *
- * @property {number} INVALID_SCHEMA_OPERATION
- * @static
- */
- ParseError.INVALID_SCHEMA_OPERATION = 255;
- /**
- * Error code indicating that there were multiple errors. Aggregate errors
- * have an "errors" property, which is an array of error objects with more
- * detail about each error that occurred.
- *
- * @property {number} AGGREGATE_ERROR
- * @static
- */
- ParseError.AGGREGATE_ERROR = 600;
- /**
- * Error code indicating the client was unable to read an input file.
- *
- * @property {number} FILE_READ_ERROR
- * @static
- */
- ParseError.FILE_READ_ERROR = 601;
- /**
- * Error code indicating a real error code is unavailable because
- * we had to use an XDomainRequest object to allow CORS requests in
- * Internet Explorer, which strips the body from HTTP responses that have
- * a non-2XX status code.
- *
- * @property {number} X_DOMAIN_REQUEST
- * @static
- */
- ParseError.X_DOMAIN_REQUEST = 602;
- var _default = ParseError;
- exports.default = _default;
- },{"@babel/runtime-corejs3/core-js-stable/instance/concat":81,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/core-js-stable/reflect/construct":116,"@babel/runtime-corejs3/helpers/assertThisInitialized":143,"@babel/runtime-corejs3/helpers/classCallCheck":145,"@babel/runtime-corejs3/helpers/createClass":147,"@babel/runtime-corejs3/helpers/getPrototypeOf":150,"@babel/runtime-corejs3/helpers/inherits":151,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/helpers/possibleConstructorReturn":159,"@babel/runtime-corejs3/helpers/wrapNativeSuper":166}],30:[function(_dereq_,module,exports){
- "use strict";
- var _Object$keys2 = _dereq_("@babel/runtime-corejs3/core-js-stable/object/keys");
- var _Object$getOwnPropertySymbols = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols");
- var _filterInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/filter");
- var _Object$getOwnPropertyDescriptor = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
- var _forEachInstanceProperty2 = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each");
- var _Object$getOwnPropertyDescriptors = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors");
- var _Object$defineProperties = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-properties");
- var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
- var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
- _Object$defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = void 0;
- var _regenerator = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/regenerator"));
- var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
- var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
- var _slice = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/slice"));
- var _forEach = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
- var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/keys"));
- var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
- var _asyncToGenerator2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/asyncToGenerator"));
- var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
- var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
- var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
- var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
- var _ParseFileEncode = _dereq_("./ParseFileEncode");
- function ownKeys(object, enumerableOnly) {
- var keys = _Object$keys2(object);
- if (_Object$getOwnPropertySymbols) {
- var symbols = _Object$getOwnPropertySymbols(object);
- enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) {
- return _Object$getOwnPropertyDescriptor(object, sym).enumerable;
- })), keys.push.apply(keys, symbols);
- }
- return keys;
- }
- function _objectSpread(target) {
- for (var i = 1; i < arguments.length; i++) {
- var _context4, _context5;
- var source = null != arguments[i] ? arguments[i] : {};
- i % 2 ? _forEachInstanceProperty2(_context4 = ownKeys(Object(source), !0)).call(_context4, function (key) {
- (0, _defineProperty2.default)(target, key, source[key]);
- }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty2(_context5 = ownKeys(Object(source))).call(_context5, function (key) {
- _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key));
- });
- }
- return target;
- }
- var ParseError = _dereq_('./ParseError').default;
- /*:: type Base64 = { base64: string };*/
- /*:: type Uri = { uri: string };*/
- /*:: type FileData = Array<number> | Base64 | Blob | Uri;*/
- /*:: export type FileSource =
- | {
- format: 'file',
- file: Blob,
- type: string,
- }
- | {
- format: 'base64',
- base64: string,
- type: string,
- }
- | {
- format: 'uri',
- uri: string,
- type: string,
- };*/
- var dataUriRegexp = /^data:([a-zA-Z]+\/[-a-zA-Z0-9+.]+)(;charset=[a-zA-Z0-9\-/]*)?;base64,/;
- /**
- * A Parse.File is a local representation of a file that is saved to the Parse
- * cloud.
- *
- * @alias Parse.File
- */
- var ParseFile = /*#__PURE__*/function () {
- /**
- * @param name {String} The file's name. This will be prefixed by a unique
- * value once the file has finished saving. The file name must begin with
- * an alphanumeric character, and consist of alphanumeric characters,
- * periods, spaces, underscores, or dashes.
- * @param data {Array} The data for the file, as either:
- * 1. an Array of byte value Numbers, or
- * 2. an Object like { base64: "..." } with a base64-encoded String.
- * 3. an Object like { uri: "..." } with a uri String.
- * 4. a File object selected with a file upload control. (3) only works
- * in Firefox 3.6+, Safari 6.0.2+, Chrome 7+, and IE 10+.
- * For example:
- * <pre>
- * var fileUploadControl = $("#profilePhotoFileUpload")[0];
- * if (fileUploadControl.files.length > 0) {
- * var file = fileUploadControl.files[0];
- * var name = "photo.jpg";
- * var parseFile = new Parse.File(name, file);
- * parseFile.save().then(function() {
- * // The file has been saved to Parse.
- * }, function(error) {
- * // The file either could not be read, or could not be saved to Parse.
- * });
- * }</pre>
- * @param type {String} Optional Content-Type header to use for the file. If
- * this is omitted, the content type will be inferred from the name's
- * extension.
- * @param metadata {Object} Optional key value pairs to be stored with file object
- * @param tags {Object} Optional key value pairs to be stored with file object
- */
- function ParseFile(name
- /*: string*/
- , data
- /*:: ?: FileData*/
- , type
- /*:: ?: string*/
- , metadata
- /*:: ?: Object*/
- , tags
- /*:: ?: Object*/
- ) {
- (0, _classCallCheck2.default)(this, ParseFile);
- (0, _defineProperty2.default)(this, "_name", void 0);
- (0, _defineProperty2.default)(this, "_url", void 0);
- (0, _defineProperty2.default)(this, "_hash", void 0);
- (0, _defineProperty2.default)(this, "_ipfs", void 0);
- (0, _defineProperty2.default)(this, "_source", void 0);
- (0, _defineProperty2.default)(this, "_previousSave", void 0);
- (0, _defineProperty2.default)(this, "_data", void 0);
- (0, _defineProperty2.default)(this, "_requestTask", void 0);
- (0, _defineProperty2.default)(this, "_metadata", void 0);
- (0, _defineProperty2.default)(this, "_tags", void 0);
- var specifiedType = type || '';
- this._name = name;
- this._metadata = metadata || {};
- this._tags = tags || {};
- if (data !== undefined) {
- if ((0, _isArray.default)(data)) {
- this._data = ParseFile.encodeBase64(data);
- this._source = {
- format: 'base64',
- base64: this._data,
- type: specifiedType
- };
- } else if (typeof Blob !== 'undefined' && data instanceof Blob) {
- this._source = {
- format: 'file',
- file: data,
- type: specifiedType
- };
- } else if (data && typeof data.uri === 'string' && data.uri !== undefined) {
- this._source = {
- format: 'uri',
- uri: data.uri,
- type: specifiedType
- };
- } else if (data && typeof data.base64 === 'string') {
- var base64 = data.base64;
- var commaIndex = (0, _indexOf.default)(base64).call(base64, ',');
- if (commaIndex !== -1) {
- var matches = dataUriRegexp.exec((0, _slice.default)(base64).call(base64, 0, commaIndex + 1)); // if data URI with type and charset, there will be 4 matches.
- this._data = (0, _slice.default)(base64).call(base64, commaIndex + 1);
- this._source = {
- format: 'base64',
- base64: this._data,
- type: matches[1]
- };
- } else {
- this._data = base64;
- this._source = {
- format: 'base64',
- base64: base64,
- type: specifiedType
- };
- }
- } else {
- throw new TypeError('Cannot create a Parse.File with that data.');
- }
- }
- }
- /**
- * Return the data for the file, downloading it if not already present.
- * Data is present if initialized with Byte Array, Base64 or Saved with Uri.
- * Data is cleared if saved with File object selected with a file upload control
- *
- * @returns {Promise} Promise that is resolve with base64 data
- */
- (0, _createClass2.default)(ParseFile, [{
- key: "getData",
- value: function () {
- var _getData = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
- var _this = this;
- var options, controller, result;
- return _regenerator.default.wrap(function (_context) {
- while (1) {
- switch (_context.prev = _context.next) {
- case 0:
- if (!this._data) {
- _context.next = 2;
- break;
- }
- return _context.abrupt("return", this._data);
- case 2:
- if (this._url) {
- _context.next = 4;
- break;
- }
- throw new Error('Cannot retrieve data for unsaved ParseFile.');
- case 4:
- options = {
- requestTask: function (task) {
- return _this._requestTask = task;
- }
- };
- controller = _CoreManager.default.getFileController();
- _context.next = 8;
- return controller.download(this._url, options);
- case 8:
- result = _context.sent;
- this._data = result.base64;
- return _context.abrupt("return", this._data);
- case 11:
- case "end":
- return _context.stop();
- }
- }
- }, _callee, this);
- }));
- return function () {
- return _getData.apply(this, arguments);
- };
- }()
- /**
- * Gets the name of the file. Before save is called, this is the filename
- * given by the user. After save is called, that name gets prefixed with a
- * unique identifier.
- *
- * @returns {string}
- */
- }, {
- key: "name",
- value: function ()
- /*: string*/
- {
- return this._name;
- }
- /**
- * Gets the url of the file. It is only available after you save the file or
- * after you get the file from a Parse.Object.
- *
- * @param {object} options An object to specify url options
- * @returns {string}
- */
- }, {
- key: "url",
- value: function (options
- /*:: ?: { forceSecure?: boolean }*/
- )
- /*: ?string*/
- {
- options = options || {};
- if (!this._url) {
- return;
- }
- if (options.forceSecure) {
- return this._url.replace(/^http:\/\//i, 'https://');
- }
- return this._url;
- }
- }, {
- key: "ipfs",
- value: function () {
- return this._ipfs;
- }
- }, {
- key: "hash",
- value: function () {
- return this._hash;
- }
- /**
- * Gets the metadata of the file.
- *
- * @returns {object}
- */
- }, {
- key: "metadata",
- value: function ()
- /*: Object*/
- {
- return this._metadata;
- }
- /**
- * Gets the tags of the file.
- *
- * @returns {object}
- */
- }, {
- key: "tags",
- value: function ()
- /*: Object*/
- {
- return this._tags;
- }
- /**
- * Saves the file to the Parse cloud.
- *
- * @param {object} options
- * * Valid options are:<ul>
- * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
- * be used for this request.
- * <li>sessionToken: A valid session token, used for making a request on
- * behalf of a specific user.
- * <li>progress: In Browser only, callback for upload progress. For example:
- * <pre>
- * let parseFile = new Parse.File(name, file);
- * parseFile.save({
- * progress: (progressValue, loaded, total, { type }) => {
- * if (type === "upload" && progressValue !== null) {
- * // Update the UI using progressValue
- * }
- * }
- * });
- * </pre>
- * </ul>
- * @returns {Promise} Promise that is resolved when the save finishes.
- */
- }, {
- key: "save",
- value: function (options
- /*:: ?: FullOptions*/
- ) {
- var _this2 = this;
- options = options || {};
- options.requestTask = function (task) {
- return _this2._requestTask = task;
- };
- options.metadata = this._metadata;
- options.tags = this._tags;
- var controller = _CoreManager.default.getFileController();
- if (!this._previousSave) {
- if (this._source.format === 'file') {
- this._previousSave = controller.saveFile(this._name, this._source, options).then(function (res) {
- _this2._name = res.name;
- _this2._url = res.url;
- _this2._hash = res.hash;
- _this2._ipfs = res.ipfs;
- _this2._data = null;
- _this2._requestTask = null;
- return _this2;
- });
- } else if (this._source.format === 'uri') {
- this._previousSave = controller.download(this._source.uri, options).then(function (result) {
- if (!(result && result.base64)) {
- return {};
- }
- var newSource = {
- format: 'base64',
- base64: result.base64,
- type: result.contentType
- };
- _this2._data = result.base64;
- _this2._requestTask = null;
- return controller.saveBase64(_this2._name, newSource, options);
- }).then(function (res) {
- _this2._name = res.name;
- _this2._url = res.url;
- _this2._hash = res.hash;
- _this2._ipfs = res.ipfs;
- _this2._requestTask = null;
- return _this2;
- });
- } else {
- this._previousSave = controller.saveBase64(this._name, this._source, options).then(function (res) {
- _this2._name = res.name;
- _this2._url = res.url;
- _this2._hash = res.hash;
- _this2._ipfs = res.ipfs;
- _this2._requestTask = null;
- return _this2;
- });
- }
- }
- if (this._previousSave) {
- return this._previousSave;
- }
- }
- }, {
- key: "saveIPFS",
- value: function (options
- /*:: ?: FullOptions*/
- ) {
- return this.save(_objectSpread(_objectSpread({}, options), {}, {
- ipfs: true
- }));
- }
- /**
- * Aborts the request if it has already been sent.
- */
- }, {
- key: "cancel",
- value: function () {
- if (this._requestTask && typeof this._requestTask.abort === 'function') {
- this._requestTask.abort();
- }
- this._requestTask = null;
- }
- /**
- * Deletes the file from the Parse cloud.
- * In Cloud Code and Node only with Master Key.
- *
- * @param {object} options
- * * Valid options are:<ul>
- * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
- * be used for this request.
- * <pre>
- * @returns {Promise} Promise that is resolved when the delete finishes.
- */
- }, {
- key: "destroy",
- value: function () {
- var _this3 = this;
- var options
- /*:: ?: FullOptions*/
- = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
- if (!this._name) {
- throw new ParseError(ParseError.FILE_DELETE_UNNAMED_ERROR, 'Cannot delete an unnamed file.');
- }
- var destroyOptions = {
- useMasterKey: true
- };
- if (options.hasOwnProperty('useMasterKey')) {
- destroyOptions.useMasterKey = options.useMasterKey;
- }
- var controller = _CoreManager.default.getFileController();
- return controller.deleteFile(this._name, destroyOptions).then(function () {
- _this3._data = null;
- _this3._requestTask = null;
- return _this3;
- });
- }
- }, {
- key: "toJSON",
- value: function ()
- /*: { name: ?string, url: ?string }*/
- {
- return {
- __type: 'File',
- name: this._name,
- url: this._url,
- ipfs: this._ipfs,
- hash: this._hash
- };
- }
- }, {
- key: "equals",
- value: function (other
- /*: mixed*/
- )
- /*: boolean*/
- {
- if (this === other) {
- return true;
- } // Unsaved Files are never equal, since they will be saved to different URLs
- return other instanceof ParseFile && this.name() === other.name() && this.url() === other.url() && typeof this.url() !== 'undefined';
- }
- /**
- * Sets metadata to be saved with file object. Overwrites existing metadata
- *
- * @param {object} metadata Key value pairs to be stored with file object
- */
- }, {
- key: "setMetadata",
- value: function (metadata
- /*: any*/
- ) {
- var _this4 = this;
- if (metadata && (0, _typeof2.default)(metadata) === 'object') {
- var _context2;
- (0, _forEach.default)(_context2 = (0, _keys.default)(metadata)).call(_context2, function (key) {
- _this4.addMetadata(key, metadata[key]);
- });
- }
- }
- /**
- * Sets metadata to be saved with file object. Adds to existing metadata.
- *
- * @param {string} key key to store the metadata
- * @param {*} value metadata
- */
- }, {
- key: "addMetadata",
- value: function (key
- /*: string*/
- , value
- /*: any*/
- ) {
- if (typeof key === 'string') {
- this._metadata[key] = value;
- }
- }
- /**
- * Sets tags to be saved with file object. Overwrites existing tags
- *
- * @param {object} tags Key value pairs to be stored with file object
- */
- }, {
- key: "setTags",
- value: function (tags
- /*: any*/
- ) {
- var _this5 = this;
- if (tags && (0, _typeof2.default)(tags) === 'object') {
- var _context3;
- (0, _forEach.default)(_context3 = (0, _keys.default)(tags)).call(_context3, function (key) {
- _this5.addTag(key, tags[key]);
- });
- }
- }
- /**
- * Sets tags to be saved with file object. Adds to existing tags.
- *
- * @param {string} key key to store tags
- * @param {*} value tag
- */
- }, {
- key: "addTag",
- value: function (key
- /*: string*/
- , value
- /*: string*/
- ) {
- if (typeof key === 'string') {
- this._tags[key] = value;
- }
- }
- }], [{
- key: "fromJSON",
- value: function (obj)
- /*: ParseFile*/
- {
- if (obj.__type !== 'File') {
- throw new TypeError('JSON object does not represent a ParseFile');
- }
- var file = new ParseFile(obj.name);
- file._url = obj.url;
- file._hash = obj.hash;
- file._ipfs = obj.ipfs;
- return file;
- }
- }, {
- key: "encodeBase64",
- value: function (bytes
- /*: Array<number>*/
- )
- /*: string*/
- {
- return (0, _ParseFileEncode.encodeBase64)(bytes);
- }
- }]);
- return ParseFile;
- }();
- _CoreManager.default.setFileController(_dereq_('./ParseFileController.default'));
- var _default = ParseFile;
- exports.default = _default;
- exports.b64Digit = _ParseFileEncode.b64Digit;
- },{"./CoreManager":5,"./ParseError":29,"./ParseFileController.default":31,"./ParseFileEncode":32,"@babel/runtime-corejs3/core-js-stable/array/is-array":79,"@babel/runtime-corejs3/core-js-stable/instance/filter":84,"@babel/runtime-corejs3/core-js-stable/instance/for-each":86,"@babel/runtime-corejs3/core-js-stable/instance/index-of":88,"@babel/runtime-corejs3/core-js-stable/instance/slice":93,"@babel/runtime-corejs3/core-js-stable/object/define-properties":104,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor":108,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors":109,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols":110,"@babel/runtime-corejs3/core-js-stable/object/keys":112,"@babel/runtime-corejs3/helpers/asyncToGenerator":144,"@babel/runtime-corejs3/helpers/classCallCheck":145,"@babel/runtime-corejs3/helpers/createClass":147,"@babel/runtime-corejs3/helpers/defineProperty":148,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/helpers/typeof":164,"@babel/runtime-corejs3/regenerator":167}],31:[function(_dereq_,module,exports){
- "use strict";
- var _Object$keys = _dereq_("@babel/runtime-corejs3/core-js-stable/object/keys");
- var _Object$getOwnPropertySymbols = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols");
- var _filterInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/filter");
- var _Object$getOwnPropertyDescriptor = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
- var _forEachInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each");
- var _Object$getOwnPropertyDescriptors = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors");
- var _Object$defineProperties = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-properties");
- var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
- var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
- var _regenerator = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/regenerator"));
- var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
- var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
- var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
- var _slicedToArray2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/slicedToArray"));
- var _asyncToGenerator2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/asyncToGenerator"));
- var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
- var _ParseFileEncode = _dereq_("./ParseFileEncode");
- function ownKeys(object, enumerableOnly) {
- var keys = _Object$keys(object);
- if (_Object$getOwnPropertySymbols) {
- var symbols = _Object$getOwnPropertySymbols(object);
- enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) {
- return _Object$getOwnPropertyDescriptor(object, sym).enumerable;
- })), keys.push.apply(keys, symbols);
- }
- return keys;
- }
- function _objectSpread(target) {
- for (var i = 1; i < arguments.length; i++) {
- var _context2, _context3;
- var source = null != arguments[i] ? arguments[i] : {};
- i % 2 ? _forEachInstanceProperty(_context2 = ownKeys(Object(source), !0)).call(_context2, function (key) {
- (0, _defineProperty2.default)(target, key, source[key]);
- }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context3 = ownKeys(Object(source))).call(_context3, function (key) {
- _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key));
- });
- }
- return target;
- }
- var XHR = null;
- if (typeof XMLHttpRequest !== 'undefined') {
- XHR = XMLHttpRequest;
- }
- var DefaultController = {
- saveFile: function () {
- var _saveFile = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(name
- /*: string*/
- , source
- /*: FileSource*/
- , options
- /*:: ?: FullOptions*/
- ) {
- var base64Data, _base64Data$split, _base64Data$split2, first, second, data, newSource;
- return _regenerator.default.wrap(function (_context) {
- while (1) {
- switch (_context.prev = _context.next) {
- case 0:
- if (!(source.format !== 'file')) {
- _context.next = 2;
- break;
- }
- throw new Error('saveFile can only be used with File-type sources.');
- case 2:
- _context.next = 4;
- return new _promise.default(function (res, rej) {
- // eslint-disable-next-line no-undef
- var reader = new FileReader();
- reader.onload = function () {
- return res(reader.result);
- };
- reader.onerror = function (error) {
- return rej(error);
- };
- reader.readAsDataURL(source.file);
- });
- case 4:
- base64Data = _context.sent; // we only want the data after the comma
- // For example: "data:application/pdf;base64,JVBERi0xLjQKJ..." we would only want "JVBERi0xLjQKJ..."
- _base64Data$split = base64Data.split(','), _base64Data$split2 = (0, _slicedToArray2.default)(_base64Data$split, 2), first = _base64Data$split2[0], second = _base64Data$split2[1]; // in the event there is no 'data:application/pdf;base64,' at the beginning of the base64 string
- // use the entire string instead
- data = second ? second : first;
- newSource = {
- format: 'base64',
- base64: data,
- type: source.type || (source.file ? source.file.type : null)
- };
- _context.next = 10;
- return DefaultController.saveBase64(name, newSource, options);
- case 10:
- return _context.abrupt("return", _context.sent);
- case 11:
- case "end":
- return _context.stop();
- }
- }
- }, _callee);
- }));
- return function () {
- return _saveFile.apply(this, arguments);
- };
- }(),
- saveBase64: function (name
- /*: string*/
- , source
- /*: FileSource*/
- , options
- /*:: ?: FullOptions*/
- ) {
- if (source.format !== 'base64') {
- throw new Error('saveBase64 can only be used with Base64-type sources.');
- }
- var data
- /*: { base64: any, _ContentType?: any, fileData: Object }*/
- = {
- base64: source.base64,
- fileData: {
- ipfs: options.ipfs,
- metadata: _objectSpread({}, options.metadata),
- tags: _objectSpread({}, options.tags)
- }
- };
- delete options.metadata;
- delete options.tags;
- if (source.type) {
- data._ContentType = source.type;
- }
- var path = "files/".concat(name);
- return _CoreManager.default.getRESTController().request('POST', path, data, options);
- },
- download: function (uri, options) {
- if (XHR) {
- return this.downloadAjax(uri, options);
- }
- return _promise.default.reject('Cannot make a request: No definition of XMLHttpRequest was found.');
- },
- downloadAjax: function (uri, options) {
- return new _promise.default(function (resolve, reject) {
- var xhr = new XHR();
- xhr.open('GET', uri, true);
- xhr.responseType = 'arraybuffer';
- xhr.onerror = function (e) {
- reject(e);
- };
- xhr.onreadystatechange = function () {
- if (xhr.readyState !== xhr.DONE) {
- return;
- }
- if (!this.response) {
- return resolve({});
- }
- var bytes = new Uint8Array(this.response);
- resolve({
- base64: (0, _ParseFileEncode.encodeBase64)(bytes),
- contentType: xhr.getResponseHeader('content-type')
- });
- };
- options.requestTask(xhr);
- xhr.send();
- });
- },
- deleteFile: function (name
- /*: string*/
- , options
- /*:: ?: FullOptions*/
- ) {
- var headers = {
- 'X-Parse-Application-ID': _CoreManager.default.get('APPLICATION_ID')
- };
- if (options.useMasterKey) {
- headers['X-Parse-Master-Key'] = _CoreManager.default.get('MASTER_KEY');
- }
- var url = _CoreManager.default.get('SERVER_URL');
- if (url[url.length - 1] !== '/') {
- url += '/';
- }
- url += "files/".concat(name);
- return _CoreManager.default.getRESTController().ajax('DELETE', url, '', headers).catch(function (response) {
- // TODO: return JSON object in server
- if (!response || response === 'SyntaxError: Unexpected end of JSON input') {
- return _promise.default.resolve();
- }
- return _CoreManager.default.getRESTController().handleError(response);
- });
- },
- _setXHR: function (xhr
- /*: any*/
- ) {
- XHR = xhr;
- },
- _getXHR: function () {
- return XHR;
- }
- };
- module.exports = DefaultController;
- },{"./CoreManager":5,"./ParseFileEncode":32,"@babel/runtime-corejs3/core-js-stable/instance/filter":84,"@babel/runtime-corejs3/core-js-stable/instance/for-each":86,"@babel/runtime-corejs3/core-js-stable/instance/index-of":88,"@babel/runtime-corejs3/core-js-stable/object/define-properties":104,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor":108,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors":109,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols":110,"@babel/runtime-corejs3/core-js-stable/object/keys":112,"@babel/runtime-corejs3/core-js-stable/promise":115,"@babel/runtime-corejs3/helpers/asyncToGenerator":144,"@babel/runtime-corejs3/helpers/defineProperty":148,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/helpers/slicedToArray":161,"@babel/runtime-corejs3/regenerator":167}],32:[function(_dereq_,module,exports){
- "use strict";
- /* eslint-disable no-bitwise */
- function b64Digit(number
- /*: number*/
- )
- /*: string*/
- {
- if (number < 26) {
- return String.fromCharCode(65 + number);
- }
- if (number < 52) {
- return String.fromCharCode(97 + (number - 26));
- }
- if (number < 62) {
- return String.fromCharCode(48 + (number - 52));
- }
- if (number === 62) {
- return '+';
- }
- if (number === 63) {
- return '/';
- }
- throw new TypeError("Tried to encode large digit ".concat(number, " in base64."));
- }
- function encodeBase64(bytes
- /*: Array<number>*/
- )
- /*: string*/
- {
- var chunks = [];
- chunks.length = Math.ceil(bytes.length / 3);
- for (var i = 0; i < chunks.length; i++) {
- var b1 = bytes[i * 3];
- var b2 = bytes[i * 3 + 1] || 0;
- var b3 = bytes[i * 3 + 2] || 0;
- var has2 = i * 3 + 1 < bytes.length;
- var has3 = i * 3 + 2 < bytes.length;
- chunks[i] = [b64Digit(b1 >> 2 & 0x3f), b64Digit(b1 << 4 & 0x30 | b2 >> 4 & 0x0f), has2 ? b64Digit(b2 << 2 & 0x3c | b3 >> 6 & 0x03) : '=', has3 ? b64Digit(b3 & 0x3f) : '='].join('');
- }
- return chunks.join('');
- }
- module.exports = {
- encodeBase64: encodeBase64,
- b64Digit: b64Digit
- };
- },{}],33:[function(_dereq_,module,exports){
- "use strict";
- var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
- var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
- _Object$defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = void 0;
- var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
- var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
- var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
- var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
- var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
- /**
- * Copyright (c) 2015-present, Parse, LLC.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- *
- * @flow
- */
- /**
- * Creates a new GeoPoint with any of the following forms:<br>
- * <pre>
- * new GeoPoint(otherGeoPoint)
- * new GeoPoint(30, 30)
- * new GeoPoint([30, 30])
- * new GeoPoint({latitude: 30, longitude: 30})
- * new GeoPoint() // defaults to (0, 0)
- * </pre>
- * <p>Represents a latitude / longitude point that may be associated
- * with a key in a ParseObject or used as a reference point for geo queries.
- * This allows proximity-based queries on the key.</p>
- *
- * <p>Only one key in a class may contain a GeoPoint.</p>
- *
- * <p>Example:<pre>
- * var point = new Parse.GeoPoint(30.0, -20.0);
- * var object = new Parse.Object("PlaceObject");
- * object.set("location", point);
- * object.save();</pre></p>
- *
- * @alias Parse.GeoPoint
- */
- /* global navigator */
- var ParseGeoPoint = /*#__PURE__*/function () {
- /**
- * @param {(number[] | object | number)} arg1 Either a list of coordinate pairs, an object with `latitude`, `longitude`, or the latitude or the point.
- * @param {number} arg2 The longitude of the GeoPoint
- */
- function ParseGeoPoint(arg1
- /*: Array<number> | { latitude: number, longitude: number } | number*/
- , arg2
- /*:: ?: number*/
- ) {
- (0, _classCallCheck2.default)(this, ParseGeoPoint);
- (0, _defineProperty2.default)(this, "_latitude", void 0);
- (0, _defineProperty2.default)(this, "_longitude", void 0);
- if ((0, _isArray.default)(arg1)) {
- ParseGeoPoint._validate(arg1[0], arg1[1]);
- this._latitude = arg1[0];
- this._longitude = arg1[1];
- } else if ((0, _typeof2.default)(arg1) === 'object') {
- ParseGeoPoint._validate(arg1.latitude, arg1.longitude);
- this._latitude = arg1.latitude;
- this._longitude = arg1.longitude;
- } else if (arg1 !== undefined && arg2 !== undefined) {
- ParseGeoPoint._validate(arg1, arg2);
- this._latitude = arg1;
- this._longitude = arg2;
- } else {
- this._latitude = 0;
- this._longitude = 0;
- }
- }
- /**
- * North-south portion of the coordinate, in range [-90, 90].
- * Throws an exception if set out of range in a modern browser.
- *
- * @property {number} latitude
- * @returns {number}
- */
- (0, _createClass2.default)(ParseGeoPoint, [{
- key: "latitude",
- get: function ()
- /*: number*/
- {
- return this._latitude;
- },
- set: function (val
- /*: number*/
- ) {
- ParseGeoPoint._validate(val, this.longitude);
- this._latitude = val;
- }
- /**
- * East-west portion of the coordinate, in range [-180, 180].
- * Throws if set out of range in a modern browser.
- *
- * @property {number} longitude
- * @returns {number}
- */
- }, {
- key: "longitude",
- get: function ()
- /*: number*/
- {
- return this._longitude;
- },
- set: function (val
- /*: number*/
- ) {
- ParseGeoPoint._validate(this.latitude, val);
- this._longitude = val;
- }
- /**
- * Returns a JSON representation of the GeoPoint, suitable for Parse.
- *
- * @returns {object}
- */
- }, {
- key: "toJSON",
- value: function ()
- /*: { __type: string, latitude: number, longitude: number }*/
- {
- ParseGeoPoint._validate(this._latitude, this._longitude);
- return {
- __type: 'GeoPoint',
- latitude: this._latitude,
- longitude: this._longitude
- };
- }
- }, {
- key: "equals",
- value: function (other
- /*: mixed*/
- )
- /*: boolean*/
- {
- return other instanceof ParseGeoPoint && this.latitude === other.latitude && this.longitude === other.longitude;
- }
- /**
- * Returns the distance from this GeoPoint to another in radians.
- *
- * @param {Parse.GeoPoint} point the other Parse.GeoPoint.
- * @returns {number}
- */
- }, {
- key: "radiansTo",
- value: function (point
- /*: ParseGeoPoint*/
- )
- /*: number*/
- {
- var d2r = Math.PI / 180.0;
- var lat1rad = this.latitude * d2r;
- var long1rad = this.longitude * d2r;
- var lat2rad = point.latitude * d2r;
- var long2rad = point.longitude * d2r;
- var sinDeltaLatDiv2 = Math.sin((lat1rad - lat2rad) / 2);
- var sinDeltaLongDiv2 = Math.sin((long1rad - long2rad) / 2); // Square of half the straight line chord distance between both points.
- var a = sinDeltaLatDiv2 * sinDeltaLatDiv2 + Math.cos(lat1rad) * Math.cos(lat2rad) * sinDeltaLongDiv2 * sinDeltaLongDiv2;
- a = Math.min(1.0, a);
- return 2 * Math.asin(Math.sqrt(a));
- }
- /**
- * Returns the distance from this GeoPoint to another in kilometers.
- *
- * @param {Parse.GeoPoint} point the other Parse.GeoPoint.
- * @returns {number}
- */
- }, {
- key: "kilometersTo",
- value: function (point
- /*: ParseGeoPoint*/
- )
- /*: number*/
- {
- return this.radiansTo(point) * 6371.0;
- }
- /**
- * Returns the distance from this GeoPoint to another in miles.
- *
- * @param {Parse.GeoPoint} point the other Parse.GeoPoint.
- * @returns {number}
- */
- }, {
- key: "milesTo",
- value: function (point
- /*: ParseGeoPoint*/
- )
- /*: number*/
- {
- return this.radiansTo(point) * 3958.8;
- }
- /*
- * Throws an exception if the given lat-long is out of bounds.
- */
- }], [{
- key: "_validate",
- value: function (latitude
- /*: number*/
- , longitude
- /*: number*/
- ) {
- if (isNaN(latitude) || isNaN(longitude) || typeof latitude !== 'number' || typeof longitude !== 'number') {
- throw new TypeError('GeoPoint latitude and longitude must be valid numbers');
- }
- if (latitude < -90.0) {
- throw new TypeError("GeoPoint latitude out of bounds: ".concat(latitude, " < -90.0."));
- }
- if (latitude > 90.0) {
- throw new TypeError("GeoPoint latitude out of bounds: ".concat(latitude, " > 90.0."));
- }
- if (longitude < -180.0) {
- throw new TypeError("GeoPoint longitude out of bounds: ".concat(longitude, " < -180.0."));
- }
- if (longitude > 180.0) {
- throw new TypeError("GeoPoint longitude out of bounds: ".concat(longitude, " > 180.0."));
- }
- }
- /**
- * Creates a GeoPoint with the user's current location, if available.
- *
- * @static
- * @returns {Parse.GeoPoint} User's current location
- */
- }, {
- key: "current",
- value: function () {
- return navigator.geolocation.getCurrentPosition(function (location) {
- return new ParseGeoPoint(location.coords.latitude, location.coords.longitude);
- });
- }
- }]);
- return ParseGeoPoint;
- }();
- var _default = ParseGeoPoint;
- exports.default = _default;
- },{"@babel/runtime-corejs3/core-js-stable/array/is-array":79,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/helpers/classCallCheck":145,"@babel/runtime-corejs3/helpers/createClass":147,"@babel/runtime-corejs3/helpers/defineProperty":148,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/helpers/typeof":164}],34:[function(_dereq_,module,exports){
- "use strict";
- var _Reflect$construct = _dereq_("@babel/runtime-corejs3/core-js-stable/reflect/construct");
- var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
- var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
- _Object$defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = void 0;
- var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
- var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
- var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
- var _inherits2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/inherits"));
- var _possibleConstructorReturn2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/possibleConstructorReturn"));
- var _getPrototypeOf2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/getPrototypeOf"));
- var _ParseObject2 = _interopRequireDefault(_dereq_("./ParseObject"));
- function _createSuper(Derived) {
- var hasNativeReflectConstruct = _isNativeReflectConstruct();
- return function () {
- var Super = (0, _getPrototypeOf2.default)(Derived),
- result;
- if (hasNativeReflectConstruct) {
- var NewTarget = (0, _getPrototypeOf2.default)(this).constructor;
- result = _Reflect$construct(Super, arguments, NewTarget);
- } else {
- result = Super.apply(this, arguments);
- }
- return (0, _possibleConstructorReturn2.default)(this, result);
- };
- }
- function _isNativeReflectConstruct() {
- if (typeof Reflect === "undefined" || !_Reflect$construct) return false;
- if (_Reflect$construct.sham) return false;
- if (typeof Proxy === "function") return true;
- try {
- Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {}));
- return true;
- } catch (e) {
- return false;
- }
- }
- var Installation = /*#__PURE__*/function (_ParseObject) {
- (0, _inherits2.default)(Installation, _ParseObject);
- var _super = _createSuper(Installation);
- function Installation(attributes
- /*: ?AttributeMap*/
- ) {
- var _this;
- (0, _classCallCheck2.default)(this, Installation);
- _this = _super.call(this, '_Installation');
- if (attributes && (0, _typeof2.default)(attributes) === 'object') {
- if (!_this.set(attributes || {})) {
- throw new Error("Can't create an invalid Installation");
- }
- }
- return _this;
- }
- return (0, _createClass2.default)(Installation);
- }(_ParseObject2.default);
- exports.default = Installation;
- _ParseObject2.default.registerSubclass('_Installation', Installation);
- },{"./ParseObject":36,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/core-js-stable/reflect/construct":116,"@babel/runtime-corejs3/helpers/classCallCheck":145,"@babel/runtime-corejs3/helpers/createClass":147,"@babel/runtime-corejs3/helpers/getPrototypeOf":150,"@babel/runtime-corejs3/helpers/inherits":151,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/helpers/possibleConstructorReturn":159,"@babel/runtime-corejs3/helpers/typeof":164}],35:[function(_dereq_,module,exports){
- "use strict";
- var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
- var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
- _Object$defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = void 0;
- var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
- var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
- var _regenerator = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/regenerator"));
- var _slicedToArray2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/slicedToArray"));
- var _asyncToGenerator2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/asyncToGenerator"));
- var _EventEmitter = _interopRequireDefault(_dereq_("./EventEmitter"));
- var _LiveQueryClient = _interopRequireDefault(_dereq_("./LiveQueryClient"));
- var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
- /**
- * Copyright (c) 2015-present, Parse, LLC.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- *
- * @flow
- */
- function getLiveQueryClient()
- /*: LiveQueryClient*/
- {
- return _CoreManager.default.getLiveQueryController().getDefaultLiveQueryClient();
- }
- /**
- * We expose three events to help you monitor the status of the WebSocket connection:
- *
- * <p>Open - When we establish the WebSocket connection to the LiveQuery server, you'll get this event.
- *
- * <pre>
- * Parse.LiveQuery.on('open', () => {
- *
- * });</pre></p>
- *
- * <p>Close - When we lose the WebSocket connection to the LiveQuery server, you'll get this event.
- *
- * <pre>
- * Parse.LiveQuery.on('close', () => {
- *
- * });</pre></p>
- *
- * <p>Error - When some network error or LiveQuery server error happens, you'll get this event.
- *
- * <pre>
- * Parse.LiveQuery.on('error', (error) => {
- *
- * });</pre></p>
- *
- * @class Parse.LiveQuery
- * @static
- */
- var LiveQuery = new _EventEmitter.default();
- /**
- * After open is called, the LiveQuery will try to send a connect request
- * to the LiveQuery server.
- */
- LiveQuery.open = /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
- var liveQueryClient;
- return _regenerator.default.wrap(function (_context) {
- while (1) {
- switch (_context.prev = _context.next) {
- case 0:
- _context.next = 2;
- return getLiveQueryClient();
- case 2:
- liveQueryClient = _context.sent;
- liveQueryClient.open();
- case 4:
- case "end":
- return _context.stop();
- }
- }
- }, _callee);
- }));
- /**
- * When you're done using LiveQuery, you can call Parse.LiveQuery.close().
- * This function will close the WebSocket connection to the LiveQuery server,
- * cancel the auto reconnect, and unsubscribe all subscriptions based on it.
- * If you call query.subscribe() after this, we'll create a new WebSocket
- * connection to the LiveQuery server.
- */
- LiveQuery.close = /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
- var liveQueryClient;
- return _regenerator.default.wrap(function (_context2) {
- while (1) {
- switch (_context2.prev = _context2.next) {
- case 0:
- _context2.next = 2;
- return getLiveQueryClient();
- case 2:
- liveQueryClient = _context2.sent;
- liveQueryClient.close();
- case 4:
- case "end":
- return _context2.stop();
- }
- }
- }, _callee2);
- })); // Register a default onError callback to make sure we do not crash on error
- LiveQuery.on('error', function () {});
- var _default = LiveQuery;
- exports.default = _default;
- var defaultLiveQueryClient;
- var DefaultLiveQueryController = {
- setDefaultLiveQueryClient: function (liveQueryClient
- /*: LiveQueryClient*/
- ) {
- defaultLiveQueryClient = liveQueryClient;
- },
- getDefaultLiveQueryClient: function ()
- /*: Promise<LiveQueryClient>*/
- {
- return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
- var _yield$Promise$all, _yield$Promise$all2, currentUser, installationId, sessionToken, liveQueryServerURL, serverURL, protocol, host, applicationId, javascriptKey, masterKey;
- return _regenerator.default.wrap(function (_context3) {
- while (1) {
- switch (_context3.prev = _context3.next) {
- case 0:
- if (!defaultLiveQueryClient) {
- _context3.next = 2;
- break;
- }
- return _context3.abrupt("return", defaultLiveQueryClient);
- case 2:
- _context3.next = 4;
- return _promise.default.all([_CoreManager.default.getUserController().currentUserAsync(), _CoreManager.default.getInstallationController().currentInstallationId()]);
- case 4:
- _yield$Promise$all = _context3.sent;
- _yield$Promise$all2 = (0, _slicedToArray2.default)(_yield$Promise$all, 2);
- currentUser = _yield$Promise$all2[0];
- installationId = _yield$Promise$all2[1];
- sessionToken = currentUser ? currentUser.getSessionToken() : undefined;
- liveQueryServerURL = _CoreManager.default.get('LIVEQUERY_SERVER_URL');
- if (!(liveQueryServerURL && (0, _indexOf.default)(liveQueryServerURL).call(liveQueryServerURL, 'ws') !== 0)) {
- _context3.next = 12;
- break;
- }
- throw new Error('You need to set a proper Parse LiveQuery server url before using LiveQueryClient');
- case 12:
- // If we can not find Parse.liveQueryServerURL, we try to extract it from Parse.serverURL
- if (!liveQueryServerURL) {
- serverURL = _CoreManager.default.get('SERVER_URL');
- protocol = (0, _indexOf.default)(serverURL).call(serverURL, 'https') === 0 ? 'wss://' : 'ws://';
- host = serverURL.replace(/^https?:\/\//, '');
- liveQueryServerURL = protocol + host;
- _CoreManager.default.set('LIVEQUERY_SERVER_URL', liveQueryServerURL);
- }
- applicationId = _CoreManager.default.get('APPLICATION_ID');
- javascriptKey = _CoreManager.default.get('JAVASCRIPT_KEY');
- masterKey = _CoreManager.default.get('MASTER_KEY');
- defaultLiveQueryClient = new _LiveQueryClient.default({
- applicationId: applicationId,
- serverURL: liveQueryServerURL,
- javascriptKey: javascriptKey,
- masterKey: masterKey,
- sessionToken: sessionToken,
- installationId: installationId
- });
- defaultLiveQueryClient.on('error', function (error) {
- LiveQuery.emit('error', error);
- });
- defaultLiveQueryClient.on('open', function () {
- LiveQuery.emit('open');
- });
- defaultLiveQueryClient.on('close', function () {
- LiveQuery.emit('close');
- });
- return _context3.abrupt("return", defaultLiveQueryClient);
- case 21:
- case "end":
- return _context3.stop();
- }
- }
- }, _callee3);
- }))();
- },
- _clearCachedDefaultClient: function () {
- defaultLiveQueryClient = null;
- }
- };
- _CoreManager.default.setLiveQueryController(DefaultLiveQueryController);
- },{"./CoreManager":5,"./EventEmitter":7,"./LiveQueryClient":11,"@babel/runtime-corejs3/core-js-stable/instance/index-of":88,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/core-js-stable/promise":115,"@babel/runtime-corejs3/helpers/asyncToGenerator":144,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/helpers/slicedToArray":161,"@babel/runtime-corejs3/regenerator":167}],36:[function(_dereq_,module,exports){
- "use strict";
- var _typeof3 = _dereq_("@babel/runtime-corejs3/helpers/typeof");
- var _Object$keys2 = _dereq_("@babel/runtime-corejs3/core-js-stable/object/keys");
- var _Object$getOwnPropertySymbols = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols");
- var _filterInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/filter");
- var _Object$getOwnPropertyDescriptor = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
- var _forEachInstanceProperty2 = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each");
- var _Object$getOwnPropertyDescriptors = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors");
- var _Object$defineProperties = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-properties");
- var _Object$defineProperty2 = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
- var _sliceInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/slice");
- var _Array$from = _dereq_("@babel/runtime-corejs3/core-js-stable/array/from");
- var _Symbol = _dereq_("@babel/runtime-corejs3/core-js-stable/symbol");
- var _getIteratorMethod = _dereq_("@babel/runtime-corejs3/core-js/get-iterator-method");
- var _Array$isArray2 = _dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array");
- var _WeakMap = _dereq_("@babel/runtime-corejs3/core-js-stable/weak-map");
- var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
- _Object$defineProperty2(exports, "__esModule", {
- value: true
- });
- exports.default = void 0;
- var _regenerator = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/regenerator"));
- var _asyncToGenerator2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/asyncToGenerator"));
- var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
- var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
- var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
- var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
- var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
- var _freeze = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/freeze"));
- var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/keys"));
- var _forEach = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
- var _stringify = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/json/stringify"));
- var _includes = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/includes"));
- var _getPrototypeOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/get-prototype-of"));
- var _concat = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/concat"));
- var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
- var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
- var _create = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/create"));
- var _defineProperty3 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property"));
- var _find = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/find"));
- var _map = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/map"));
- var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
- var _canBeSerialized = _interopRequireDefault(_dereq_("./canBeSerialized"));
- var _decode = _interopRequireDefault(_dereq_("./decode"));
- var _encode = _interopRequireDefault(_dereq_("./encode"));
- var _escape2 = _interopRequireDefault(_dereq_("./escape"));
- var _ParseACL = _interopRequireDefault(_dereq_("./ParseACL"));
- var _parseDate = _interopRequireDefault(_dereq_("./parseDate"));
- var _ParseError = _interopRequireDefault(_dereq_("./ParseError"));
- var _ParseFile = _interopRequireDefault(_dereq_("./ParseFile"));
- var _promiseUtils = _dereq_("./promiseUtils");
- var _LocalDatastoreUtils = _dereq_("./LocalDatastoreUtils");
- var _ParseOp = _dereq_("./ParseOp");
- var _ParseQuery = _interopRequireDefault(_dereq_("./ParseQuery"));
- var _ParseRelation = _interopRequireDefault(_dereq_("./ParseRelation"));
- var SingleInstanceStateController = _interopRequireWildcard(_dereq_("./SingleInstanceStateController"));
- var _unique = _interopRequireDefault(_dereq_("./unique"));
- var UniqueInstanceStateController = _interopRequireWildcard(_dereq_("./UniqueInstanceStateController"));
- var _unsavedChildren = _interopRequireDefault(_dereq_("./unsavedChildren"));
- function _getRequireWildcardCache(nodeInterop) {
- if (typeof _WeakMap !== "function") return null;
- var cacheBabelInterop = new _WeakMap();
- var cacheNodeInterop = new _WeakMap();
- return (_getRequireWildcardCache = function (nodeInterop) {
- return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
- })(nodeInterop);
- }
- function _interopRequireWildcard(obj, nodeInterop) {
- if (!nodeInterop && obj && obj.__esModule) {
- return obj;
- }
- if (obj === null || _typeof3(obj) !== "object" && typeof obj !== "function") {
- return {
- default: obj
- };
- }
- var cache = _getRequireWildcardCache(nodeInterop);
- if (cache && cache.has(obj)) {
- return cache.get(obj);
- }
- var newObj = {};
- for (var key in obj) {
- if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
- var desc = _Object$defineProperty2 && _Object$getOwnPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null;
- if (desc && (desc.get || desc.set)) {
- _Object$defineProperty2(newObj, key, desc);
- } else {
- newObj[key] = obj[key];
- }
- }
- }
- newObj.default = obj;
- if (cache) {
- cache.set(obj, newObj);
- }
- return newObj;
- }
- function _createForOfIteratorHelper(o, allowArrayLike) {
- var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"];
- if (!it) {
- if (_Array$isArray2(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
- if (it) o = it;
- var i = 0;
- var F = function () {};
- return {
- s: F,
- n: function () {
- if (i >= o.length) return {
- done: true
- };
- return {
- done: false,
- value: o[i++]
- };
- },
- e: function (_e) {
- throw _e;
- },
- f: F
- };
- }
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
- }
- var normalCompletion = true,
- didErr = false,
- err;
- return {
- s: function () {
- it = it.call(o);
- },
- n: function () {
- var step = it.next();
- normalCompletion = step.done;
- return step;
- },
- e: function (_e2) {
- didErr = true;
- err = _e2;
- },
- f: function () {
- try {
- if (!normalCompletion && it.return != null) it.return();
- } finally {
- if (didErr) throw err;
- }
- }
- };
- }
- function _unsupportedIterableToArray(o, minLen) {
- var _context21;
- if (!o) return;
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
- var n = _sliceInstanceProperty(_context21 = Object.prototype.toString.call(o)).call(_context21, 8, -1);
- if (n === "Object" && o.constructor) n = o.constructor.name;
- if (n === "Map" || n === "Set") return _Array$from(o);
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
- }
- function _arrayLikeToArray(arr, len) {
- if (len == null || len > arr.length) len = arr.length;
- for (var i = 0, arr2 = new Array(len); i < len; i++) {
- arr2[i] = arr[i];
- }
- return arr2;
- }
- function ownKeys(object, enumerableOnly) {
- var keys = _Object$keys2(object);
- if (_Object$getOwnPropertySymbols) {
- var symbols = _Object$getOwnPropertySymbols(object);
- enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) {
- return _Object$getOwnPropertyDescriptor(object, sym).enumerable;
- })), keys.push.apply(keys, symbols);
- }
- return keys;
- }
- function _objectSpread(target) {
- for (var i = 1; i < arguments.length; i++) {
- var _context19, _context20;
- var source = null != arguments[i] ? arguments[i] : {};
- i % 2 ? _forEachInstanceProperty2(_context19 = ownKeys(Object(source), !0)).call(_context19, function (key) {
- (0, _defineProperty2.default)(target, key, source[key]);
- }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty2(_context20 = ownKeys(Object(source))).call(_context20, function (key) {
- _Object$defineProperty2(target, key, _Object$getOwnPropertyDescriptor(source, key));
- });
- }
- return target;
- }
- var _require = _dereq_('uuid'),
- uuidv4 = _require.v4;
- /*:: export type Pointer = {
- __type: string,
- className: string,
- objectId: string,
- };*/
- /*:: type SaveParams = {
- method: string,
- path: string,
- body: AttributeMap,
- };*/
- /*:: type SaveOptions = FullOptions & {
- cascadeSave?: boolean,
- context?: AttributeMap,
- };*/
- // Mapping of class names to constructors, so we can populate objects from the
- // server with appropriate subclasses of ParseObject
- var classMap = {}; // Global counter for generating unique Ids for non-single-instance objects
- var objectCount = 0; // On web clients, objects are single-instance: any two objects with the same Id
- // will have the same attributes. However, this may be dangerous default
- // behavior in a server scenario
- var singleInstance = !_CoreManager.default.get('IS_NODE');
- if (singleInstance) {
- _CoreManager.default.setObjectStateController(SingleInstanceStateController);
- } else {
- _CoreManager.default.setObjectStateController(UniqueInstanceStateController);
- }
- function getServerUrlPath() {
- var serverUrl = _CoreManager.default.get('SERVER_URL');
- if (serverUrl[serverUrl.length - 1] !== '/') {
- serverUrl += '/';
- }
- var url = serverUrl.replace(/https?:\/\//, '');
- return url.substr((0, _indexOf.default)(url).call(url, '/'));
- }
- /**
- * Creates a new model with defined attributes.
- *
- * <p>You won't normally call this method directly. It is recommended that
- * you use a subclass of <code>Parse.Object</code> instead, created by calling
- * <code>extend</code>.</p>
- *
- * <p>However, if you don't want to use a subclass, or aren't sure which
- * subclass is appropriate, you can use this form:<pre>
- * var object = new Parse.Object("ClassName");
- * </pre>
- * That is basically equivalent to:<pre>
- * var MyClass = Parse.Object.extend("ClassName");
- * var object = new MyClass();
- * </pre></p>
- *
- * @alias Parse.Object
- */
- var ParseObject = /*#__PURE__*/function () {
- /**
- * @param {string} className The class name for the object
- * @param {object} attributes The initial set of data to store in the object.
- * @param {object} options The options for this object instance.
- */
- function ParseObject(className
- /*: ?string | { className: string, [attr: string]: mixed }*/
- , attributes
- /*:: ?: { [attr: string]: mixed }*/
- , options
- /*:: ?: { ignoreValidation: boolean }*/
- ) {
- (0, _classCallCheck2.default)(this, ParseObject);
- (0, _defineProperty2.default)(this, "id", void 0);
- (0, _defineProperty2.default)(this, "_localId", void 0);
- (0, _defineProperty2.default)(this, "_objCount", void 0);
- (0, _defineProperty2.default)(this, "className", void 0); // Enable legacy initializers
- if (typeof this.initialize === 'function') {
- this.initialize.apply(this, arguments);
- }
- var toSet = null;
- this._objCount = objectCount++;
- if (typeof className === 'string') {
- this.className = className;
- if (attributes && (0, _typeof2.default)(attributes) === 'object') {
- toSet = attributes;
- }
- } else if (className && (0, _typeof2.default)(className) === 'object') {
- this.className = className.className;
- toSet = {};
- for (var _attr in className) {
- if (_attr !== 'className') {
- toSet[_attr] = className[_attr];
- }
- }
- if (attributes && (0, _typeof2.default)(attributes) === 'object') {
- options = attributes;
- }
- }
- if (toSet && !this.set(toSet, options)) {
- throw new Error("Can't create an invalid Parse Object");
- }
- }
- /**
- * The ID of this object, unique within its class.
- *
- * @property {string} id
- */
- (0, _createClass2.default)(ParseObject, [{
- key: "attributes",
- get:
- /** Prototype getters / setters * */
- function ()
- /*: AttributeMap*/
- {
- var stateController = _CoreManager.default.getObjectStateController();
- return (0, _freeze.default)(stateController.estimateAttributes(this._getStateIdentifier()));
- }
- /**
- * The first time this object was saved on the server.
- *
- * @property {Date} createdAt
- * @returns {Date}
- */
- }, {
- key: "createdAt",
- get: function ()
- /*: ?Date*/
- {
- return this._getServerData().createdAt;
- }
- /**
- * The last time this object was updated on the server.
- *
- * @property {Date} updatedAt
- * @returns {Date}
- */
- }, {
- key: "updatedAt",
- get: function ()
- /*: ?Date*/
- {
- return this._getServerData().updatedAt;
- }
- /** Private methods * */
- /**
- * Returns a local or server Id used uniquely identify this object
- *
- * @returns {string}
- */
- }, {
- key: "_getId",
- value: function ()
- /*: string*/
- {
- if (typeof this.id === 'string') {
- return this.id;
- }
- if (typeof this._localId === 'string') {
- return this._localId;
- }
- var localId = "local".concat(uuidv4());
- this._localId = localId;
- return localId;
- }
- /**
- * Returns a unique identifier used to pull data from the State Controller.
- *
- * @returns {Parse.Object|object}
- */
- }, {
- key: "_getStateIdentifier",
- value: function ()
- /*: ParseObject | { id: string, className: string }*/
- {
- if (singleInstance) {
- var id = this.id;
- if (!id) {
- id = this._getId();
- }
- return {
- id: id,
- className: this.className
- };
- }
- return this;
- }
- }, {
- key: "_getServerData",
- value: function ()
- /*: AttributeMap*/
- {
- var stateController = _CoreManager.default.getObjectStateController();
- return stateController.getServerData(this._getStateIdentifier());
- }
- }, {
- key: "_clearServerData",
- value: function () {
- var serverData = this._getServerData();
- var unset = {};
- for (var _attr2 in serverData) {
- unset[_attr2] = undefined;
- }
- var stateController = _CoreManager.default.getObjectStateController();
- stateController.setServerData(this._getStateIdentifier(), unset);
- }
- }, {
- key: "_getPendingOps",
- value: function ()
- /*: Array<OpsMap>*/
- {
- var stateController = _CoreManager.default.getObjectStateController();
- return stateController.getPendingOps(this._getStateIdentifier());
- }
- /**
- * @param {Array<string>} [keysToClear] - if specified, only ops matching
- * these fields will be cleared
- */
- }, {
- key: "_clearPendingOps",
- value: function (keysToClear
- /*:: ?: Array<string>*/
- ) {
- var pending = this._getPendingOps();
- var latest = pending[pending.length - 1];
- var keys = keysToClear || (0, _keys.default)(latest);
- (0, _forEach.default)(keys).call(keys, function (key) {
- delete latest[key];
- });
- }
- }, {
- key: "_getDirtyObjectAttributes",
- value: function ()
- /*: AttributeMap*/
- {
- var attributes = this.attributes;
- var stateController = _CoreManager.default.getObjectStateController();
- var objectCache = stateController.getObjectCache(this._getStateIdentifier());
- var dirty = {};
- for (var _attr3 in attributes) {
- var val = attributes[_attr3];
- if (val && (0, _typeof2.default)(val) === 'object' && !(val instanceof ParseObject) && !(val instanceof _ParseFile.default) && !(val instanceof _ParseRelation.default)) {
- // Due to the way browsers construct maps, the key order will not change
- // unless the object is changed
- try {
- var json = (0, _encode.default)(val, false, true);
- var stringified = (0, _stringify.default)(json);
- if (objectCache[_attr3] !== stringified) {
- dirty[_attr3] = val;
- }
- } catch (e) {
- // Error occurred, possibly by a nested unsaved pointer in a mutable container
- // No matter how it happened, it indicates a change in the attribute
- dirty[_attr3] = val;
- }
- }
- }
- return dirty;
- }
- }, {
- key: "_toFullJSON",
- value: function (seen
- /*:: ?: Array<any>*/
- , offline
- /*:: ?: boolean*/
- )
- /*: AttributeMap*/
- {
- var json
- /*: { [key: string]: mixed }*/
- = this.toJSON(seen, offline);
- json.__type = 'Object';
- json.className = this.className;
- return json;
- }
- }, {
- key: "_getSaveJSON",
- value: function ()
- /*: AttributeMap*/
- {
- var pending = this._getPendingOps();
- var dirtyObjects = this._getDirtyObjectAttributes();
- var json = {};
- for (var attr in dirtyObjects) {
- var isDotNotation = false;
- for (var i = 0; i < pending.length; i += 1) {
- for (var field in pending[i]) {
- // Dot notation operations are handled later
- if ((0, _includes.default)(field).call(field, '.')) {
- var fieldName = field.split('.')[0];
- if (fieldName === attr) {
- isDotNotation = true;
- break;
- }
- }
- }
- }
- if (!isDotNotation) {
- json[attr] = new _ParseOp.SetOp(dirtyObjects[attr]).toJSON();
- }
- }
- for (attr in pending[0]) {
- json[attr] = pending[0][attr].toJSON();
- }
- return json;
- }
- }, {
- key: "_getSaveParams",
- value: function ()
- /*: SaveParams*/
- {
- var method = this.id ? 'PUT' : 'POST';
- var body = this._getSaveJSON();
- var path = "classes/".concat(this.className);
- if (this.id) {
- path += "/".concat(this.id);
- } else if (this.className === '_User') {
- path = 'users';
- }
- return {
- method: method,
- body: body,
- path: path
- };
- }
- }, {
- key: "_finishFetch",
- value: function (serverData
- /*: AttributeMap*/
- ) {
- if (!this.id && serverData.objectId) {
- this.id = serverData.objectId;
- }
- var stateController = _CoreManager.default.getObjectStateController();
- stateController.initializeState(this._getStateIdentifier());
- var decoded = {};
- for (var _attr4 in serverData) {
- if (_attr4 === 'ACL') {
- decoded[_attr4] = new _ParseACL.default(serverData[_attr4]);
- } else if (_attr4 !== 'objectId') {
- decoded[_attr4] = (0, _decode.default)(serverData[_attr4]);
- if (decoded[_attr4] instanceof _ParseRelation.default) {
- decoded[_attr4]._ensureParentAndKey(this, _attr4);
- }
- }
- }
- if (decoded.createdAt && typeof decoded.createdAt === 'string') {
- decoded.createdAt = (0, _parseDate.default)(decoded.createdAt);
- }
- if (decoded.updatedAt && typeof decoded.updatedAt === 'string') {
- decoded.updatedAt = (0, _parseDate.default)(decoded.updatedAt);
- }
- if (!decoded.updatedAt && decoded.createdAt) {
- decoded.updatedAt = decoded.createdAt;
- }
- stateController.commitServerChanges(this._getStateIdentifier(), decoded);
- }
- }, {
- key: "_setExisted",
- value: function (existed
- /*: boolean*/
- ) {
- var stateController = _CoreManager.default.getObjectStateController();
- var state = stateController.getState(this._getStateIdentifier());
- if (state) {
- state.existed = existed;
- }
- }
- }, {
- key: "_migrateId",
- value: function (serverId
- /*: string*/
- ) {
- if (this._localId && serverId) {
- if (singleInstance) {
- var stateController = _CoreManager.default.getObjectStateController();
- var oldState = stateController.removeState(this._getStateIdentifier());
- this.id = serverId;
- delete this._localId;
- if (oldState) {
- stateController.initializeState(this._getStateIdentifier(), oldState);
- }
- } else {
- this.id = serverId;
- delete this._localId;
- }
- }
- }
- }, {
- key: "_handleSaveResponse",
- value: function (response
- /*: AttributeMap*/
- , status
- /*: number*/
- ) {
- var changes = {};
- var stateController = _CoreManager.default.getObjectStateController();
- var pending = stateController.popPendingState(this._getStateIdentifier());
- for (var attr in pending) {
- if (pending[attr] instanceof _ParseOp.RelationOp) {
- changes[attr] = pending[attr].applyTo(undefined, this, attr);
- } else if (!(attr in response) && !(0, _includes.default)(attr).call(attr, '.')) {
- // Only SetOps and UnsetOps should not come back with results
- changes[attr] = pending[attr].applyTo(undefined);
- }
- }
- for (attr in response) {
- if ((attr === 'createdAt' || attr === 'updatedAt') && typeof response[attr] === 'string') {
- changes[attr] = (0, _parseDate.default)(response[attr]);
- } else if (attr === 'ACL') {
- changes[attr] = new _ParseACL.default(response[attr]);
- } else if (attr !== 'objectId') {
- var val = (0, _decode.default)(response[attr]);
- if (val && (0, _getPrototypeOf.default)(val) === Object.prototype) {
- changes[attr] = _objectSpread(_objectSpread({}, this.attributes[attr]), val);
- } else {
- changes[attr] = val;
- }
- if (changes[attr] instanceof _ParseOp.UnsetOp) {
- changes[attr] = undefined;
- }
- }
- }
- if (changes.createdAt && !changes.updatedAt) {
- changes.updatedAt = changes.createdAt;
- }
- this._migrateId(response.objectId);
- if (status !== 201) {
- this._setExisted(true);
- }
- stateController.commitServerChanges(this._getStateIdentifier(), changes);
- }
- }, {
- key: "_handleSaveError",
- value: function () {
- var stateController = _CoreManager.default.getObjectStateController();
- stateController.mergeFirstPendingState(this._getStateIdentifier());
- }
- /** Public methods * */
- }, {
- key: "initialize",
- value: function () {// NOOP
- }
- /**
- * Returns a JSON version of the object suitable for saving to Parse.
- *
- * @param seen
- * @param offline
- * @returns {object}
- */
- }, {
- key: "toJSON",
- value: function (seen
- /*: Array<any> | void*/
- , offline
- /*:: ?: boolean*/
- )
- /*: AttributeMap*/
- {
- var _context;
- var seenEntry = this.id ? (0, _concat.default)(_context = "".concat(this.className, ":")).call(_context, this.id) : this;
- seen = seen || [seenEntry];
- var json = {};
- var attrs = this.attributes;
- for (var _attr5 in attrs) {
- if ((_attr5 === 'createdAt' || _attr5 === 'updatedAt') && attrs[_attr5].toJSON) {
- json[_attr5] = attrs[_attr5].toJSON();
- } else {
- json[_attr5] = (0, _encode.default)(attrs[_attr5], false, false, seen, offline);
- }
- }
- var pending = this._getPendingOps();
- for (var _attr6 in pending[0]) {
- json[_attr6] = pending[0][_attr6].toJSON(offline);
- }
- if (this.id) {
- json.objectId = this.id;
- }
- return json;
- }
- /**
- * Determines whether this ParseObject is equal to another ParseObject
- *
- * @param {object} other - An other object ot compare
- * @returns {boolean}
- */
- }, {
- key: "equals",
- value: function (other
- /*: mixed*/
- )
- /*: boolean*/
- {
- if (this === other) {
- return true;
- }
- return other instanceof ParseObject && this.className === other.className && this.id === other.id && typeof this.id !== 'undefined';
- }
- /**
- * Returns true if this object has been modified since its last
- * save/refresh. If an attribute is specified, it returns true only if that
- * particular attribute has been modified since the last save/refresh.
- *
- * @param {string} attr An attribute name (optional).
- * @returns {boolean}
- */
- }, {
- key: "dirty",
- value: function (attr
- /*:: ?: string*/
- )
- /*: boolean*/
- {
- if (!this.id) {
- return true;
- }
- var pendingOps = this._getPendingOps();
- var dirtyObjects = this._getDirtyObjectAttributes();
- if (attr) {
- if (dirtyObjects.hasOwnProperty(attr)) {
- return true;
- }
- for (var i = 0; i < pendingOps.length; i++) {
- if (pendingOps[i].hasOwnProperty(attr)) {
- return true;
- }
- }
- return false;
- }
- if ((0, _keys.default)(pendingOps[0]).length !== 0) {
- return true;
- }
- if ((0, _keys.default)(dirtyObjects).length !== 0) {
- return true;
- }
- return false;
- }
- /**
- * Returns an array of keys that have been modified since last save/refresh
- *
- * @returns {string[]}
- */
- }, {
- key: "dirtyKeys",
- value: function ()
- /*: Array<string>*/
- {
- var pendingOps = this._getPendingOps();
- var keys = {};
- for (var i = 0; i < pendingOps.length; i++) {
- for (var _attr7 in pendingOps[i]) {
- keys[_attr7] = true;
- }
- }
- var dirtyObjects = this._getDirtyObjectAttributes();
- for (var _attr8 in dirtyObjects) {
- keys[_attr8] = true;
- }
- return (0, _keys.default)(keys);
- }
- /**
- * Returns true if the object has been fetched.
- *
- * @returns {boolean}
- */
- }, {
- key: "isDataAvailable",
- value: function ()
- /*: boolean*/
- {
- var serverData = this._getServerData();
- return !!(0, _keys.default)(serverData).length;
- }
- /**
- * Gets a Pointer referencing this Object.
- *
- * @returns {Pointer}
- */
- }, {
- key: "toPointer",
- value: function ()
- /*: Pointer*/
- {
- if (!this.id) {
- throw new Error('Cannot create a pointer to an unsaved ParseObject');
- }
- return {
- __type: 'Pointer',
- className: this.className,
- objectId: this.id
- };
- }
- /**
- * Gets a Pointer referencing this Object.
- *
- * @returns {Pointer}
- */
- }, {
- key: "toOfflinePointer",
- value: function ()
- /*: Pointer*/
- {
- if (!this._localId) {
- throw new Error('Cannot create a offline pointer to a saved ParseObject');
- }
- return {
- __type: 'Object',
- className: this.className,
- _localId: this._localId
- };
- }
- /**
- * Gets the value of an attribute.
- *
- * @param {string} attr The string name of an attribute.
- * @returns {*}
- */
- }, {
- key: "get",
- value: function (attr
- /*: string*/
- )
- /*: mixed*/
- {
- return this.attributes[attr];
- }
- /**
- * Gets a relation on the given class for the attribute.
- *
- * @param {string} attr The attribute to get the relation for.
- * @returns {Parse.Relation}
- */
- }, {
- key: "relation",
- value: function (attr
- /*: string*/
- )
- /*: ParseRelation*/
- {
- var value = this.get(attr);
- if (value) {
- if (!(value instanceof _ParseRelation.default)) {
- throw new Error("Called relation() on non-relation field ".concat(attr));
- }
- value._ensureParentAndKey(this, attr);
- return value;
- }
- return new _ParseRelation.default(this, attr);
- }
- /**
- * Gets the HTML-escaped value of an attribute.
- *
- * @param {string} attr The string name of an attribute.
- * @returns {string}
- */
- }, {
- key: "escape",
- value: function (attr
- /*: string*/
- )
- /*: string*/
- {
- var val = this.attributes[attr];
- if (val == null) {
- return '';
- }
- if (typeof val !== 'string') {
- if (typeof val.toString !== 'function') {
- return '';
- }
- val = val.toString();
- }
- return (0, _escape2.default)(val);
- }
- /**
- * Returns <code>true</code> if the attribute contains a value that is not
- * null or undefined.
- *
- * @param {string} attr The string name of the attribute.
- * @returns {boolean}
- */
- }, {
- key: "has",
- value: function (attr
- /*: string*/
- )
- /*: boolean*/
- {
- var attributes = this.attributes;
- if (attributes.hasOwnProperty(attr)) {
- return attributes[attr] != null;
- }
- return false;
- }
- /**
- * Sets a hash of model attributes on the object.
- *
- * <p>You can call it with an object containing keys and values, with one
- * key and value, or dot notation. For example:<pre>
- * gameTurn.set({
- * player: player1,
- * diceRoll: 2
- * }, {
- * error: function(gameTurnAgain, error) {
- * // The set failed validation.
- * }
- * });
- *
- * game.set("currentPlayer", player2, {
- * error: function(gameTurnAgain, error) {
- * // The set failed validation.
- * }
- * });
- *
- * game.set("finished", true);</pre></p>
- *
- * game.set("player.score", 10);</pre></p>
- *
- * @param {(string|object)} key The key to set.
- * @param {(string|object)} value The value to give it.
- * @param {object} options A set of options for the set.
- * The only supported option is <code>error</code>.
- * @returns {(ParseObject|boolean)} true if the set succeeded.
- */
- }, {
- key: "set",
- value: function (key
- /*: mixed*/
- , value
- /*: mixed*/
- , options
- /*:: ?: mixed*/
- )
- /*: ParseObject | boolean*/
- {
- var changes = {};
- var newOps = {};
- if (key && (0, _typeof2.default)(key) === 'object') {
- changes = key;
- options = value;
- } else if (typeof key === 'string') {
- changes[key] = value;
- } else {
- return this;
- }
- options = options || {};
- var readonly = [];
- if (typeof this.constructor.readOnlyAttributes === 'function') {
- readonly = (0, _concat.default)(readonly).call(readonly, this.constructor.readOnlyAttributes());
- }
- for (var k in changes) {
- if (k === 'createdAt' || k === 'updatedAt') {
- // This property is read-only, but for legacy reasons we silently
- // ignore it
- continue;
- }
- if ((0, _indexOf.default)(readonly).call(readonly, k) > -1) {
- throw new Error("Cannot modify readonly attribute: ".concat(k));
- }
- if (options.unset) {
- newOps[k] = new _ParseOp.UnsetOp();
- } else if (changes[k] instanceof _ParseOp.Op) {
- newOps[k] = changes[k];
- } else if (changes[k] && (0, _typeof2.default)(changes[k]) === 'object' && typeof changes[k].__op === 'string') {
- newOps[k] = (0, _ParseOp.opFromJSON)(changes[k]);
- } else if (k === 'objectId' || k === 'id') {
- if (typeof changes[k] === 'string') {
- this.id = changes[k];
- }
- } else if (k === 'ACL' && (0, _typeof2.default)(changes[k]) === 'object' && !(changes[k] instanceof _ParseACL.default)) {
- newOps[k] = new _ParseOp.SetOp(new _ParseACL.default(changes[k]));
- } else if (changes[k] instanceof _ParseRelation.default) {
- var relation = new _ParseRelation.default(this, k);
- relation.targetClassName = changes[k].targetClassName;
- newOps[k] = new _ParseOp.SetOp(relation);
- } else {
- newOps[k] = new _ParseOp.SetOp(changes[k]);
- }
- }
- var currentAttributes = this.attributes; // Only set nested fields if exists
- var serverData = this._getServerData();
- if (typeof key === 'string' && (0, _includes.default)(key).call(key, '.')) {
- var field = key.split('.')[0];
- if (!serverData[field]) {
- return this;
- }
- } // Calculate new values
- var newValues = {};
- for (var _attr9 in newOps) {
- if (newOps[_attr9] instanceof _ParseOp.RelationOp) {
- newValues[_attr9] = newOps[_attr9].applyTo(currentAttributes[_attr9], this, _attr9);
- } else if (!(newOps[_attr9] instanceof _ParseOp.UnsetOp)) {
- newValues[_attr9] = newOps[_attr9].applyTo(currentAttributes[_attr9]);
- }
- } // Validate changes
- if (!options.ignoreValidation) {
- var validation = this.validate(newValues);
- if (validation) {
- if (typeof options.error === 'function') {
- options.error(this, validation);
- }
- return false;
- }
- } // Consolidate Ops
- var pendingOps = this._getPendingOps();
- var last = pendingOps.length - 1;
- var stateController = _CoreManager.default.getObjectStateController();
- for (var _attr10 in newOps) {
- var nextOp = newOps[_attr10].mergeWith(pendingOps[last][_attr10]);
- stateController.setPendingOp(this._getStateIdentifier(), _attr10, nextOp);
- }
- return this;
- }
- /**
- * Remove an attribute from the model. This is a noop if the attribute doesn't
- * exist.
- *
- * @param {string} attr The string name of an attribute.
- * @param options
- * @returns {(ParseObject | boolean)}
- */
- }, {
- key: "unset",
- value: function (attr
- /*: string*/
- , options
- /*:: ?: { [opt: string]: mixed }*/
- )
- /*: ParseObject | boolean*/
- {
- options = options || {};
- options.unset = true;
- return this.set(attr, null, options);
- }
- /**
- * Atomically increments the value of the given attribute the next time the
- * object is saved. If no amount is specified, 1 is used by default.
- *
- * @param attr {String} The key.
- * @param amount {Number} The amount to increment by (optional).
- * @returns {(ParseObject|boolean)}
- */
- }, {
- key: "increment",
- value: function (attr
- /*: string*/
- , amount
- /*:: ?: number*/
- )
- /*: ParseObject | boolean*/
- {
- if (typeof amount === 'undefined') {
- amount = 1;
- }
- if (typeof amount !== 'number') {
- throw new Error('Cannot increment by a non-numeric amount.');
- }
- return this.set(attr, new _ParseOp.IncrementOp(amount));
- }
- /**
- * Atomically decrements the value of the given attribute the next time the
- * object is saved. If no amount is specified, 1 is used by default.
- *
- * @param attr {String} The key.
- * @param amount {Number} The amount to decrement by (optional).
- * @returns {(ParseObject | boolean)}
- */
- }, {
- key: "decrement",
- value: function (attr
- /*: string*/
- , amount
- /*:: ?: number*/
- )
- /*: ParseObject | boolean*/
- {
- if (typeof amount === 'undefined') {
- amount = 1;
- }
- if (typeof amount !== 'number') {
- throw new Error('Cannot decrement by a non-numeric amount.');
- }
- return this.set(attr, new _ParseOp.IncrementOp(amount * -1));
- }
- /**
- * Atomically add an object to the end of the array associated with a given
- * key.
- *
- * @param attr {String} The key.
- * @param item {} The item to add.
- * @returns {(ParseObject | boolean)}
- */
- }, {
- key: "add",
- value: function (attr
- /*: string*/
- , item
- /*: mixed*/
- )
- /*: ParseObject | boolean*/
- {
- return this.set(attr, new _ParseOp.AddOp([item]));
- }
- /**
- * Atomically add the objects to the end of the array associated with a given
- * key.
- *
- * @param attr {String} The key.
- * @param items {Object[]} The items to add.
- * @returns {(ParseObject | boolean)}
- */
- }, {
- key: "addAll",
- value: function (attr
- /*: string*/
- , items
- /*: Array<mixed>*/
- )
- /*: ParseObject | boolean*/
- {
- return this.set(attr, new _ParseOp.AddOp(items));
- }
- /**
- * Atomically add an object to the array associated with a given key, only
- * if it is not already present in the array. The position of the insert is
- * not guaranteed.
- *
- * @param attr {String} The key.
- * @param item {} The object to add.
- * @returns {(ParseObject | boolean)}
- */
- }, {
- key: "addUnique",
- value: function (attr
- /*: string*/
- , item
- /*: mixed*/
- )
- /*: ParseObject | boolean*/
- {
- return this.set(attr, new _ParseOp.AddUniqueOp([item]));
- }
- /**
- * Atomically add the objects to the array associated with a given key, only
- * if it is not already present in the array. The position of the insert is
- * not guaranteed.
- *
- * @param attr {String} The key.
- * @param items {Object[]} The objects to add.
- * @returns {(ParseObject | boolean)}
- */
- }, {
- key: "addAllUnique",
- value: function (attr
- /*: string*/
- , items
- /*: Array<mixed>*/
- )
- /*: ParseObject | boolean*/
- {
- return this.set(attr, new _ParseOp.AddUniqueOp(items));
- }
- /**
- * Atomically remove all instances of an object from the array associated
- * with a given key.
- *
- * @param attr {String} The key.
- * @param item {} The object to remove.
- * @returns {(ParseObject | boolean)}
- */
- }, {
- key: "remove",
- value: function (attr
- /*: string*/
- , item
- /*: mixed*/
- )
- /*: ParseObject | boolean*/
- {
- return this.set(attr, new _ParseOp.RemoveOp([item]));
- }
- /**
- * Atomically remove all instances of the objects from the array associated
- * with a given key.
- *
- * @param attr {String} The key.
- * @param items {Object[]} The object to remove.
- * @returns {(ParseObject | boolean)}
- */
- }, {
- key: "removeAll",
- value: function (attr
- /*: string*/
- , items
- /*: Array<mixed>*/
- )
- /*: ParseObject | boolean*/
- {
- return this.set(attr, new _ParseOp.RemoveOp(items));
- }
- /**
- * Returns an instance of a subclass of Parse.Op describing what kind of
- * modification has been performed on this field since the last time it was
- * saved. For example, after calling object.increment("x"), calling
- * object.op("x") would return an instance of Parse.Op.Increment.
- *
- * @param attr {String} The key.
- * @returns {Parse.Op} The operation, or undefined if none.
- */
- }, {
- key: "op",
- value: function (attr
- /*: string*/
- )
- /*: ?Op*/
- {
- var pending = this._getPendingOps();
- for (var i = pending.length; i--;) {
- if (pending[i][attr]) {
- return pending[i][attr];
- }
- }
- }
- /**
- * Creates a new model with identical attributes to this one.
- *
- * @returns {Parse.Object}
- */
- }, {
- key: "clone",
- value: function clone()
- /*: any*/
- {
- var clone = new this.constructor();
- if (!clone.className) {
- clone.className = this.className;
- }
- var attributes = this.attributes;
- if (typeof this.constructor.readOnlyAttributes === 'function') {
- var readonly = this.constructor.readOnlyAttributes() || []; // Attributes are frozen, so we have to rebuild an object,
- // rather than delete readonly keys
- var copy = {};
- for (var a in attributes) {
- if ((0, _indexOf.default)(readonly).call(readonly, a) < 0) {
- copy[a] = attributes[a];
- }
- }
- attributes = copy;
- }
- if (clone.set) {
- clone.set(attributes);
- }
- return clone;
- }
- /**
- * Creates a new instance of this object. Not to be confused with clone()
- *
- * @returns {Parse.Object}
- */
- }, {
- key: "newInstance",
- value: function ()
- /*: any*/
- {
- var clone = new this.constructor();
- if (!clone.className) {
- clone.className = this.className;
- }
- clone.id = this.id;
- if (singleInstance) {
- // Just return an object with the right id
- return clone;
- }
- var stateController = _CoreManager.default.getObjectStateController();
- if (stateController) {
- stateController.duplicateState(this._getStateIdentifier(), clone._getStateIdentifier());
- }
- return clone;
- }
- /**
- * Returns true if this object has never been saved to Parse.
- *
- * @returns {boolean}
- */
- }, {
- key: "isNew",
- value: function ()
- /*: boolean*/
- {
- return !this.id;
- }
- /**
- * Returns true if this object was created by the Parse server when the
- * object might have already been there (e.g. in the case of a Facebook
- * login)
- *
- * @returns {boolean}
- */
- }, {
- key: "existed",
- value: function ()
- /*: boolean*/
- {
- if (!this.id) {
- return false;
- }
- var stateController = _CoreManager.default.getObjectStateController();
- var state = stateController.getState(this._getStateIdentifier());
- if (state) {
- return state.existed;
- }
- return false;
- }
- /**
- * Returns true if this object exists on the Server
- *
- * @param {object} options
- * Valid options are:<ul>
- * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
- * be used for this request.
- * <li>sessionToken: A valid session token, used for making a request on
- * behalf of a specific user.
- * </ul>
- * @returns {Promise<boolean>} A boolean promise that is fulfilled if object exists.
- */
- }, {
- key: "exists",
- value: function () {
- var _exists = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(options
- /*:: ?: RequestOptions*/
- ) {
- var query;
- return _regenerator.default.wrap(function (_context2) {
- while (1) {
- switch (_context2.prev = _context2.next) {
- case 0:
- if (this.id) {
- _context2.next = 2;
- break;
- }
- return _context2.abrupt("return", false);
- case 2:
- _context2.prev = 2;
- query = new _ParseQuery.default(this.className);
- _context2.next = 6;
- return query.get(this.id, options);
- case 6:
- return _context2.abrupt("return", true);
- case 9:
- _context2.prev = 9;
- _context2.t0 = _context2["catch"](2);
- if (!(_context2.t0.code === _ParseError.default.OBJECT_NOT_FOUND)) {
- _context2.next = 13;
- break;
- }
- return _context2.abrupt("return", false);
- case 13:
- throw _context2.t0;
- case 14:
- case "end":
- return _context2.stop();
- }
- }
- }, _callee, this, [[2, 9]]);
- }));
- return function () {
- return _exists.apply(this, arguments);
- };
- }()
- /**
- * Checks if the model is currently in a valid state.
- *
- * @returns {boolean}
- */
- }, {
- key: "isValid",
- value: function ()
- /*: boolean*/
- {
- return !this.validate(this.attributes);
- }
- /**
- * You should not call this function directly unless you subclass
- * <code>Parse.Object</code>, in which case you can override this method
- * to provide additional validation on <code>set</code> and
- * <code>save</code>. Your implementation should return
- *
- * @param {object} attrs The current data to validate.
- * @returns {Parse.Error|boolean} False if the data is valid. An error object otherwise.
- * @see Parse.Object#set
- */
- }, {
- key: "validate",
- value: function (attrs
- /*: AttributeMap*/
- )
- /*: ParseError | boolean*/
- {
- if (attrs.hasOwnProperty('ACL') && !(attrs.ACL instanceof _ParseACL.default)) {
- return new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'ACL must be a Parse ACL.');
- }
- for (var _key in attrs) {
- if (!/^[A-Za-z][0-9A-Za-z_.]*$/.test(_key)) {
- return new _ParseError.default(_ParseError.default.INVALID_KEY_NAME);
- }
- }
- return false;
- }
- /**
- * Returns the ACL for this object.
- *
- * @returns {Parse.ACL} An instance of Parse.ACL.
- * @see Parse.Object#get
- */
- }, {
- key: "getACL",
- value: function ()
- /*: ?ParseACL*/
- {
- var acl = this.get('ACL');
- if (acl instanceof _ParseACL.default) {
- return acl;
- }
- return null;
- }
- /**
- * Sets the ACL to be used for this object.
- *
- * @param {Parse.ACL} acl An instance of Parse.ACL.
- * @param {object} options
- * @returns {(ParseObject | boolean)} Whether the set passed validation.
- * @see Parse.Object#set
- */
- }, {
- key: "setACL",
- value: function (acl
- /*: ParseACL*/
- , options
- /*:: ?: mixed*/
- )
- /*: ParseObject | boolean*/
- {
- return this.set('ACL', acl, options);
- }
- /**
- * Clears any (or specific) changes to this object made since the last call to save()
- *
- * @param {string} [keys] - specify which fields to revert
- */
- }, {
- key: "revert",
- value: function ()
- /*: void*/
- {
- var keysToRevert;
- for (var _len = arguments.length, keys = new Array(_len), _key2 = 0; _key2 < _len; _key2++) {
- keys[_key2] = arguments[_key2];
- }
- if (keys.length) {
- keysToRevert = [];
- var _iterator = _createForOfIteratorHelper(keys),
- _step;
- try {
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
- var _key3 = _step.value;
- if (typeof _key3 === 'string') {
- keysToRevert.push(_key3);
- } else {
- throw new Error('Parse.Object#revert expects either no, or a list of string, arguments.');
- }
- }
- } catch (err) {
- _iterator.e(err);
- } finally {
- _iterator.f();
- }
- }
- this._clearPendingOps(keysToRevert);
- }
- /**
- * Clears all attributes on a model
- *
- * @returns {(ParseObject | boolean)}
- */
- }, {
- key: "clear",
- value: function ()
- /*: ParseObject | boolean*/
- {
- var attributes = this.attributes;
- var erasable = {};
- var readonly = ['createdAt', 'updatedAt'];
- if (typeof this.constructor.readOnlyAttributes === 'function') {
- readonly = (0, _concat.default)(readonly).call(readonly, this.constructor.readOnlyAttributes());
- }
- for (var _attr11 in attributes) {
- if ((0, _indexOf.default)(readonly).call(readonly, _attr11) < 0) {
- erasable[_attr11] = true;
- }
- }
- return this.set(erasable, {
- unset: true
- });
- }
- /**
- * Fetch the model from the server. If the server's representation of the
- * model differs from its current attributes, they will be overriden.
- *
- * @param {object} options
- * Valid options are:<ul>
- * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
- * be used for this request.
- * <li>sessionToken: A valid session token, used for making a request on
- * behalf of a specific user.
- * <li>include: The name(s) of the key(s) to include. Can be a string, an array of strings,
- * or an array of array of strings.
- * <li>context: A dictionary that is accessible in Cloud Code `beforeFind` trigger.
- * </ul>
- * @returns {Promise} A promise that is fulfilled when the fetch
- * completes.
- */
- }, {
- key: "fetch",
- value: function (options
- /*: RequestOptions*/
- )
- /*: Promise*/
- {
- options = options || {};
- var fetchOptions = {};
- if (options.hasOwnProperty('useMasterKey')) {
- fetchOptions.useMasterKey = options.useMasterKey;
- }
- if (options.hasOwnProperty('sessionToken')) {
- fetchOptions.sessionToken = options.sessionToken;
- }
- if (options.hasOwnProperty('context') && (0, _typeof2.default)(options.context) === 'object') {
- fetchOptions.context = options.context;
- }
- if (options.hasOwnProperty('include')) {
- fetchOptions.include = [];
- if ((0, _isArray.default)(options.include)) {
- var _context3;
- (0, _forEach.default)(_context3 = options.include).call(_context3, function (key) {
- if ((0, _isArray.default)(key)) {
- var _context4;
- fetchOptions.include = (0, _concat.default)(_context4 = fetchOptions.include).call(_context4, key);
- } else {
- fetchOptions.include.push(key);
- }
- });
- } else {
- fetchOptions.include.push(options.include);
- }
- }
- var controller = _CoreManager.default.getObjectController();
- return controller.fetch(this, true, fetchOptions);
- }
- /**
- * Fetch the model from the server. If the server's representation of the
- * model differs from its current attributes, they will be overriden.
- *
- * Includes nested Parse.Objects for the provided key. You can use dot
- * notation to specify which fields in the included object are also fetched.
- *
- * @param {string | Array<string | Array<string>>} keys The name(s) of the key(s) to include.
- * @param {object} options
- * Valid options are:<ul>
- * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
- * be used for this request.
- * <li>sessionToken: A valid session token, used for making a request on
- * behalf of a specific user.
- * </ul>
- * @returns {Promise} A promise that is fulfilled when the fetch
- * completes.
- */
- }, {
- key: "fetchWithInclude",
- value: function (keys
- /*: String | Array<string | Array<string>>*/
- , options
- /*: RequestOptions*/
- )
- /*: Promise*/
- {
- options = options || {};
- options.include = keys;
- return this.fetch(options);
- }
- /**
- * Set a hash of model attributes, and save the model to the server.
- * updatedAt will be updated when the request returns.
- * You can either call it as:<pre>
- * object.save();</pre>
- * or<pre>
- * object.save(attrs);</pre>
- * or<pre>
- * object.save(null, options);</pre>
- * or<pre>
- * object.save(attrs, options);</pre>
- * or<pre>
- * object.save(key, value, options);</pre>
- *
- * For example, <pre>
- * gameTurn.save({
- * player: "Jake Cutter",
- * diceRoll: 2
- * }).then(function(gameTurnAgain) {
- * // The save was successful.
- * }, function(error) {
- * // The save failed. Error is an instance of Parse.Error.
- * });</pre>
- *
- * @param {string | object | null} [arg1]
- * Valid options are:<ul>
- * <li>`Object` - Key/value pairs to update on the object.</li>
- * <li>`String` Key - Key of attribute to update (requires arg2 to also be string)</li>
- * <li>`null` - Passing null for arg1 allows you to save the object with options passed in arg2.</li>
- * </ul>
- * @param {string | object} [arg2]
- * <ul>
- * <li>`String` Value - If arg1 was passed as a key, arg2 is the value that should be set on that key.</li>
- * <li>`Object` Options - Valid options are:
- * <ul>
- * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
- * be used for this request.
- * <li>sessionToken: A valid session token, used for making a request on
- * behalf of a specific user.
- * <li>cascadeSave: If `false`, nested objects will not be saved (default is `true`).
- * <li>context: A dictionary that is accessible in Cloud Code `beforeSave` and `afterSave` triggers.
- * </ul>
- * </li>
- * </ul>
- * @param {object} [arg3]
- * Used to pass option parameters to method if arg1 and arg2 were both passed as strings.
- * Valid options are:
- * <ul>
- * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
- * be used for this request.
- * <li>sessionToken: A valid session token, used for making a request on
- * behalf of a specific user.
- * <li>cascadeSave: If `false`, nested objects will not be saved (default is `true`).
- * <li>context: A dictionary that is accessible in Cloud Code `beforeSave` and `afterSave` triggers.
- * </ul>
- * @returns {Promise} A promise that is fulfilled when the save
- * completes.
- */
- }, {
- key: "save",
- value: function (arg1
- /*: ?string | { [attr: string]: mixed }*/
- , arg2
- /*: SaveOptions | mixed*/
- , arg3
- /*:: ?: SaveOptions*/
- )
- /*: Promise*/
- {
- var _this = this;
- var attrs;
- var options;
- if ((0, _typeof2.default)(arg1) === 'object' || typeof arg1 === 'undefined') {
- attrs = arg1;
- if ((0, _typeof2.default)(arg2) === 'object') {
- options = arg2;
- }
- } else {
- attrs = {};
- attrs[arg1] = arg2;
- options = arg3;
- }
- if (attrs) {
- var validation = this.validate(attrs);
- if (validation) {
- return _promise.default.reject(validation);
- }
- this.set(attrs, options);
- }
- options = options || {};
- var saveOptions = {};
- if (options.hasOwnProperty('useMasterKey')) {
- saveOptions.useMasterKey = !!options.useMasterKey;
- }
- if (options.hasOwnProperty('sessionToken') && typeof options.sessionToken === 'string') {
- saveOptions.sessionToken = options.sessionToken;
- }
- if (options.hasOwnProperty('installationId') && typeof options.installationId === 'string') {
- saveOptions.installationId = options.installationId;
- }
- if (options.hasOwnProperty('context') && (0, _typeof2.default)(options.context) === 'object') {
- saveOptions.context = options.context;
- }
- var controller = _CoreManager.default.getObjectController();
- var unsaved = options.cascadeSave !== false ? (0, _unsavedChildren.default)(this) : null;
- return controller.save(unsaved, saveOptions).then(function () {
- return controller.save(_this, saveOptions);
- });
- }
- /**
- * Destroy this model on the server if it was already persisted.
- *
- * @param {object} options
- * Valid options are:<ul>
- * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
- * be used for this request.
- * <li>sessionToken: A valid session token, used for making a request on
- * behalf of a specific user.
- * <li>context: A dictionary that is accessible in Cloud Code `beforeDelete` and `afterDelete` triggers.
- * </ul>
- * @returns {Promise} A promise that is fulfilled when the destroy
- * completes.
- */
- }, {
- key: "destroy",
- value: function (options
- /*: RequestOptions*/
- )
- /*: Promise*/
- {
- options = options || {};
- var destroyOptions = {};
- if (options.hasOwnProperty('useMasterKey')) {
- destroyOptions.useMasterKey = options.useMasterKey;
- }
- if (options.hasOwnProperty('sessionToken')) {
- destroyOptions.sessionToken = options.sessionToken;
- }
- if (options.hasOwnProperty('context') && (0, _typeof2.default)(options.context) === 'object') {
- destroyOptions.context = options.context;
- }
- if (!this.id) {
- return _promise.default.resolve();
- }
- return _CoreManager.default.getObjectController().destroy(this, destroyOptions);
- }
- /**
- * Asynchronously stores the object and every object it points to in the local datastore,
- * recursively, using a default pin name: _default.
- *
- * If those other objects have not been fetched from Parse, they will not be stored.
- * However, if they have changed data, all the changes will be retained.
- *
- * <pre>
- * await object.pin();
- * </pre>
- *
- * To retrieve object:
- * <code>query.fromLocalDatastore()</code> or <code>query.fromPin()</code>
- *
- * @returns {Promise} A promise that is fulfilled when the pin completes.
- */
- }, {
- key: "pin",
- value: function ()
- /*: Promise<void>*/
- {
- return ParseObject.pinAllWithName(_LocalDatastoreUtils.DEFAULT_PIN, [this]);
- }
- /**
- * Asynchronously removes the object and every object it points to in the local datastore,
- * recursively, using a default pin name: _default.
- *
- * <pre>
- * await object.unPin();
- * </pre>
- *
- * @returns {Promise} A promise that is fulfilled when the unPin completes.
- */
- }, {
- key: "unPin",
- value: function ()
- /*: Promise<void>*/
- {
- return ParseObject.unPinAllWithName(_LocalDatastoreUtils.DEFAULT_PIN, [this]);
- }
- /**
- * Asynchronously returns if the object is pinned
- *
- * <pre>
- * const isPinned = await object.isPinned();
- * </pre>
- *
- * @returns {Promise<boolean>} A boolean promise that is fulfilled if object is pinned.
- */
- }, {
- key: "isPinned",
- value: function () {
- var _isPinned = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
- var localDatastore, objectKey, pin;
- return _regenerator.default.wrap(function (_context5) {
- while (1) {
- switch (_context5.prev = _context5.next) {
- case 0:
- localDatastore = _CoreManager.default.getLocalDatastore();
- if (localDatastore.isEnabled) {
- _context5.next = 3;
- break;
- }
- return _context5.abrupt("return", _promise.default.reject('Parse.enableLocalDatastore() must be called first'));
- case 3:
- objectKey = localDatastore.getKeyForObject(this);
- _context5.next = 6;
- return localDatastore.fromPinWithName(objectKey);
- case 6:
- pin = _context5.sent;
- return _context5.abrupt("return", pin.length > 0);
- case 8:
- case "end":
- return _context5.stop();
- }
- }
- }, _callee2, this);
- }));
- return function () {
- return _isPinned.apply(this, arguments);
- };
- }()
- /**
- * Asynchronously stores the objects and every object they point to in the local datastore, recursively.
- *
- * If those other objects have not been fetched from Parse, they will not be stored.
- * However, if they have changed data, all the changes will be retained.
- *
- * <pre>
- * await object.pinWithName(name);
- * </pre>
- *
- * To retrieve object:
- * <code>query.fromLocalDatastore()</code> or <code>query.fromPinWithName(name)</code>
- *
- * @param {string} name Name of Pin.
- * @returns {Promise} A promise that is fulfilled when the pin completes.
- */
- }, {
- key: "pinWithName",
- value: function (name
- /*: string*/
- )
- /*: Promise<void>*/
- {
- return ParseObject.pinAllWithName(name, [this]);
- }
- /**
- * Asynchronously removes the object and every object it points to in the local datastore, recursively.
- *
- * <pre>
- * await object.unPinWithName(name);
- * </pre>
- *
- * @param {string} name Name of Pin.
- * @returns {Promise} A promise that is fulfilled when the unPin completes.
- */
- }, {
- key: "unPinWithName",
- value: function (name
- /*: string*/
- )
- /*: Promise<void>*/
- {
- return ParseObject.unPinAllWithName(name, [this]);
- }
- /**
- * Asynchronously loads data from the local datastore into this object.
- *
- * <pre>
- * await object.fetchFromLocalDatastore();
- * </pre>
- *
- * You can create an unfetched pointer with <code>Parse.Object.createWithoutData()</code>
- * and then call <code>fetchFromLocalDatastore()</code> on it.
- *
- * @returns {Promise} A promise that is fulfilled when the fetch completes.
- */
- }, {
- key: "fetchFromLocalDatastore",
- value: function () {
- var _fetchFromLocalDatastore = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
- var localDatastore, objectKey, pinned, result;
- return _regenerator.default.wrap(function (_context6) {
- while (1) {
- switch (_context6.prev = _context6.next) {
- case 0:
- localDatastore = _CoreManager.default.getLocalDatastore();
- if (localDatastore.isEnabled) {
- _context6.next = 3;
- break;
- }
- throw new Error('Parse.enableLocalDatastore() must be called first');
- case 3:
- objectKey = localDatastore.getKeyForObject(this);
- _context6.next = 6;
- return localDatastore._serializeObject(objectKey);
- case 6:
- pinned = _context6.sent;
- if (pinned) {
- _context6.next = 9;
- break;
- }
- throw new Error('Cannot fetch an unsaved ParseObject');
- case 9:
- result = ParseObject.fromJSON(pinned);
- this._finishFetch(result.toJSON());
- return _context6.abrupt("return", this);
- case 12:
- case "end":
- return _context6.stop();
- }
- }
- }, _callee3, this);
- }));
- return function () {
- return _fetchFromLocalDatastore.apply(this, arguments);
- };
- }()
- /** Static methods * */
- }], [{
- key: "_clearAllState",
- value: function () {
- var stateController = _CoreManager.default.getObjectStateController();
- stateController.clearAllState();
- }
- /**
- * Fetches the given list of Parse.Object.
- * If any error is encountered, stops and calls the error handler.
- *
- * <pre>
- * Parse.Object.fetchAll([object1, object2, ...])
- * .then((list) => {
- * // All the objects were fetched.
- * }, (error) => {
- * // An error occurred while fetching one of the objects.
- * });
- * </pre>
- *
- * @param {Array} list A list of <code>Parse.Object</code>.
- * @param {object} options
- * Valid options are:<ul>
- * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
- * be used for this request.
- * <li>sessionToken: A valid session token, used for making a request on
- * behalf of a specific user.
- * <li>include: The name(s) of the key(s) to include. Can be a string, an array of strings,
- * or an array of array of strings.
- * </ul>
- * @static
- * @returns {Parse.Object[]}
- */
- }, {
- key: "fetchAll",
- value: function (list
- /*: Array<ParseObject>*/
- ) {
- var options
- /*: RequestOptions*/
- = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
- var queryOptions = {};
- if (options.hasOwnProperty('useMasterKey')) {
- queryOptions.useMasterKey = options.useMasterKey;
- }
- if (options.hasOwnProperty('sessionToken')) {
- queryOptions.sessionToken = options.sessionToken;
- }
- if (options.hasOwnProperty('include')) {
- queryOptions.include = ParseObject.handleIncludeOptions(options);
- }
- return _CoreManager.default.getObjectController().fetch(list, true, queryOptions);
- }
- /**
- * Fetches the given list of Parse.Object.
- *
- * Includes nested Parse.Objects for the provided key. You can use dot
- * notation to specify which fields in the included object are also fetched.
- *
- * If any error is encountered, stops and calls the error handler.
- *
- * <pre>
- * Parse.Object.fetchAllWithInclude([object1, object2, ...], [pointer1, pointer2, ...])
- * .then((list) => {
- * // All the objects were fetched.
- * }, (error) => {
- * // An error occurred while fetching one of the objects.
- * });
- * </pre>
- *
- * @param {Array} list A list of <code>Parse.Object</code>.
- * @param {string | Array<string | Array<string>>} keys The name(s) of the key(s) to include.
- * @param {object} options
- * Valid options are:<ul>
- * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
- * be used for this request.
- * <li>sessionToken: A valid session token, used for making a request on
- * behalf of a specific user.
- * </ul>
- * @static
- * @returns {Parse.Object[]}
- */
- }, {
- key: "fetchAllWithInclude",
- value: function (list
- /*: Array<ParseObject>*/
- , keys
- /*: String | Array<string | Array<string>>*/
- , options
- /*: RequestOptions*/
- ) {
- options = options || {};
- options.include = keys;
- return ParseObject.fetchAll(list, options);
- }
- /**
- * Fetches the given list of Parse.Object if needed.
- * If any error is encountered, stops and calls the error handler.
- *
- * Includes nested Parse.Objects for the provided key. You can use dot
- * notation to specify which fields in the included object are also fetched.
- *
- * If any error is encountered, stops and calls the error handler.
- *
- * <pre>
- * Parse.Object.fetchAllIfNeededWithInclude([object1, object2, ...], [pointer1, pointer2, ...])
- * .then((list) => {
- * // All the objects were fetched.
- * }, (error) => {
- * // An error occurred while fetching one of the objects.
- * });
- * </pre>
- *
- * @param {Array} list A list of <code>Parse.Object</code>.
- * @param {string | Array<string | Array<string>>} keys The name(s) of the key(s) to include.
- * @param {object} options
- * Valid options are:<ul>
- * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
- * be used for this request.
- * <li>sessionToken: A valid session token, used for making a request on
- * behalf of a specific user.
- * </ul>
- * @static
- * @returns {Parse.Object[]}
- */
- }, {
- key: "fetchAllIfNeededWithInclude",
- value: function (list
- /*: Array<ParseObject>*/
- , keys
- /*: String | Array<string | Array<string>>*/
- , options
- /*: RequestOptions*/
- ) {
- options = options || {};
- options.include = keys;
- return ParseObject.fetchAllIfNeeded(list, options);
- }
- /**
- * Fetches the given list of Parse.Object if needed.
- * If any error is encountered, stops and calls the error handler.
- *
- * <pre>
- * Parse.Object.fetchAllIfNeeded([object1, ...])
- * .then((list) => {
- * // Objects were fetched and updated.
- * }, (error) => {
- * // An error occurred while fetching one of the objects.
- * });
- * </pre>
- *
- * @param {Array} list A list of <code>Parse.Object</code>.
- * @param {object} options
- * @static
- * @returns {Parse.Object[]}
- */
- }, {
- key: "fetchAllIfNeeded",
- value: function (list
- /*: Array<ParseObject>*/
- , options) {
- options = options || {};
- var queryOptions = {};
- if (options.hasOwnProperty('useMasterKey')) {
- queryOptions.useMasterKey = options.useMasterKey;
- }
- if (options.hasOwnProperty('sessionToken')) {
- queryOptions.sessionToken = options.sessionToken;
- }
- if (options.hasOwnProperty('include')) {
- queryOptions.include = ParseObject.handleIncludeOptions(options);
- }
- return _CoreManager.default.getObjectController().fetch(list, false, queryOptions);
- }
- }, {
- key: "handleIncludeOptions",
- value: function (options) {
- var include = [];
- if ((0, _isArray.default)(options.include)) {
- var _context7;
- (0, _forEach.default)(_context7 = options.include).call(_context7, function (key) {
- if ((0, _isArray.default)(key)) {
- include = (0, _concat.default)(include).call(include, key);
- } else {
- include.push(key);
- }
- });
- } else {
- include.push(options.include);
- }
- return include;
- }
- /**
- * Destroy the given list of models on the server if it was already persisted.
- *
- * <p>Unlike saveAll, if an error occurs while deleting an individual model,
- * this method will continue trying to delete the rest of the models if
- * possible, except in the case of a fatal error like a connection error.
- *
- * <p>In particular, the Parse.Error object returned in the case of error may
- * be one of two types:
- *
- * <ul>
- * <li>A Parse.Error.AGGREGATE_ERROR. This object's "errors" property is an
- * array of other Parse.Error objects. Each error object in this array
- * has an "object" property that references the object that could not be
- * deleted (for instance, because that object could not be found).</li>
- * <li>A non-aggregate Parse.Error. This indicates a serious error that
- * caused the delete operation to be aborted partway through (for
- * instance, a connection failure in the middle of the delete).</li>
- * </ul>
- *
- * <pre>
- * Parse.Object.destroyAll([object1, object2, ...])
- * .then((list) => {
- * // All the objects were deleted.
- * }, (error) => {
- * // An error occurred while deleting one or more of the objects.
- * // If this is an aggregate error, then we can inspect each error
- * // object individually to determine the reason why a particular
- * // object was not deleted.
- * if (error.code === Parse.Error.AGGREGATE_ERROR) {
- * for (var i = 0; i < error.errors.length; i++) {
- * console.log("Couldn't delete " + error.errors[i].object.id +
- * "due to " + error.errors[i].message);
- * }
- * } else {
- * console.log("Delete aborted because of " + error.message);
- * }
- * });
- * </pre>
- *
- * @param {Array} list A list of <code>Parse.Object</code>.
- * @param {object} options
- * @static
- * @returns {Promise} A promise that is fulfilled when the destroyAll
- * completes.
- */
- }, {
- key: "destroyAll",
- value: function (list
- /*: Array<ParseObject>*/
- ) {
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
- var destroyOptions = {};
- if (options.hasOwnProperty('useMasterKey')) {
- destroyOptions.useMasterKey = options.useMasterKey;
- }
- if (options.hasOwnProperty('sessionToken')) {
- destroyOptions.sessionToken = options.sessionToken;
- }
- if (options.hasOwnProperty('batchSize') && typeof options.batchSize === 'number') {
- destroyOptions.batchSize = options.batchSize;
- }
- if (options.hasOwnProperty('context') && (0, _typeof2.default)(options.context) === 'object') {
- destroyOptions.context = options.context;
- }
- return _CoreManager.default.getObjectController().destroy(list, destroyOptions);
- }
- /**
- * Saves the given list of Parse.Object.
- * If any error is encountered, stops and calls the error handler.
- *
- * <pre>
- * Parse.Object.saveAll([object1, object2, ...])
- * .then((list) => {
- * // All the objects were saved.
- * }, (error) => {
- * // An error occurred while saving one of the objects.
- * });
- * </pre>
- *
- * @param {Array} list A list of <code>Parse.Object</code>.
- * @param {object} options
- * @static
- * @returns {Parse.Object[]}
- */
- }, {
- key: "saveAll",
- value: function (list
- /*: Array<ParseObject>*/
- ) {
- var options
- /*: RequestOptions*/
- = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
- var saveOptions = {};
- if (options.hasOwnProperty('useMasterKey')) {
- saveOptions.useMasterKey = options.useMasterKey;
- }
- if (options.hasOwnProperty('sessionToken')) {
- saveOptions.sessionToken = options.sessionToken;
- }
- if (options.hasOwnProperty('batchSize') && typeof options.batchSize === 'number') {
- saveOptions.batchSize = options.batchSize;
- }
- if (options.hasOwnProperty('context') && (0, _typeof2.default)(options.context) === 'object') {
- saveOptions.context = options.context;
- }
- return _CoreManager.default.getObjectController().save(list, saveOptions);
- }
- /**
- * Creates a reference to a subclass of Parse.Object with the given id. This
- * does not exist on Parse.Object, only on subclasses.
- *
- * <p>A shortcut for: <pre>
- * var Foo = Parse.Object.extend("Foo");
- * var pointerToFoo = new Foo();
- * pointerToFoo.id = "myObjectId";
- * </pre>
- *
- * @param {string} id The ID of the object to create a reference to.
- * @static
- * @returns {Parse.Object} A Parse.Object reference.
- */
- }, {
- key: "createWithoutData",
- value: function (id
- /*: string*/
- ) {
- var obj = new this();
- obj.id = id;
- return obj;
- }
- /**
- * Creates a new instance of a Parse Object from a JSON representation.
- *
- * @param {object} json The JSON map of the Object's data
- * @param {boolean} override In single instance mode, all old server data
- * is overwritten if this is set to true
- * @static
- * @returns {Parse.Object} A Parse.Object reference
- */
- }, {
- key: "fromJSON",
- value: function (json
- /*: any*/
- , override
- /*:: ?: boolean*/
- ) {
- if (!json.className) {
- throw new Error('Cannot create an object without a className');
- }
- var constructor = classMap[json.className];
- var o = constructor ? new constructor() : new ParseObject(json.className);
- var otherAttributes = {};
- for (var _attr12 in json) {
- if (_attr12 !== 'className' && _attr12 !== '__type') {
- otherAttributes[_attr12] = json[_attr12];
- }
- }
- if (override) {
- // id needs to be set before clearServerData can work
- if (otherAttributes.objectId) {
- o.id = otherAttributes.objectId;
- }
- var preserved = null;
- if (typeof o._preserveFieldsOnFetch === 'function') {
- preserved = o._preserveFieldsOnFetch();
- }
- o._clearServerData();
- if (preserved) {
- o._finishFetch(preserved);
- }
- }
- o._finishFetch(otherAttributes);
- if (json.objectId) {
- o._setExisted(true);
- }
- return o;
- }
- /**
- * Registers a subclass of Parse.Object with a specific class name.
- * When objects of that class are retrieved from a query, they will be
- * instantiated with this subclass.
- * This is only necessary when using ES6 subclassing.
- *
- * @param {string} className The class name of the subclass
- * @param {Function} constructor The subclass
- */
- }, {
- key: "registerSubclass",
- value: function (className
- /*: string*/
- , constructor
- /*: any*/
- ) {
- if (typeof className !== 'string') {
- throw new TypeError('The first argument must be a valid class name.');
- }
- if (typeof constructor === 'undefined') {
- throw new TypeError('You must supply a subclass constructor.');
- }
- if (typeof constructor !== 'function') {
- throw new TypeError('You must register the subclass constructor. ' + 'Did you attempt to register an instance of the subclass?');
- }
- classMap[className] = constructor;
- if (!constructor.className) {
- constructor.className = className;
- }
- }
- /**
- * Creates a new subclass of Parse.Object for the given Parse class name.
- *
- * <p>Every extension of a Parse class will inherit from the most recent
- * previous extension of that class. When a Parse.Object is automatically
- * created by parsing JSON, it will use the most recent extension of that
- * class.</p>
- *
- * <p>You should call either:<pre>
- * var MyClass = Parse.Object.extend("MyClass", {
- * <i>Instance methods</i>,
- * initialize: function(attrs, options) {
- * this.someInstanceProperty = [],
- * <i>Other instance properties</i>
- * }
- * }, {
- * <i>Class properties</i>
- * });</pre>
- * or, for Backbone compatibility:<pre>
- * var MyClass = Parse.Object.extend({
- * className: "MyClass",
- * <i>Instance methods</i>,
- * initialize: function(attrs, options) {
- * this.someInstanceProperty = [],
- * <i>Other instance properties</i>
- * }
- * }, {
- * <i>Class properties</i>
- * });</pre></p>
- *
- * @param {string} className The name of the Parse class backing this model.
- * @param {object} protoProps Instance properties to add to instances of the
- * class returned from this method.
- * @param {object} classProps Class properties to add the class returned from
- * this method.
- * @returns {Parse.Object} A new subclass of Parse.Object.
- */
- }, {
- key: "extend",
- value: function (className
- /*: any*/
- , protoProps
- /*: any*/
- , classProps
- /*: any*/
- ) {
- if (typeof className !== 'string') {
- if (className && typeof className.className === 'string') {
- return ParseObject.extend(className.className, className, protoProps);
- }
- throw new Error("Parse.Object.extend's first argument should be the className.");
- }
- var adjustedClassName = className;
- if (adjustedClassName === 'User' && _CoreManager.default.get('PERFORM_USER_REWRITE')) {
- adjustedClassName = '_User';
- }
- var parentProto = ParseObject.prototype;
- if (this.hasOwnProperty('__super__') && this.__super__) {
- parentProto = this.prototype;
- } else if (classMap[adjustedClassName]) {
- parentProto = classMap[adjustedClassName].prototype;
- }
- var ParseObjectSubclass = function (attributes, options) {
- this.className = adjustedClassName;
- this._objCount = objectCount++; // Enable legacy initializers
- if (typeof this.initialize === 'function') {
- this.initialize.apply(this, arguments);
- }
- if (attributes && (0, _typeof2.default)(attributes) === 'object') {
- if (!this.set(attributes || {}, options)) {
- throw new Error("Can't create an invalid Parse Object");
- }
- }
- };
- ParseObjectSubclass.className = adjustedClassName;
- ParseObjectSubclass.__super__ = parentProto;
- ParseObjectSubclass.prototype = (0, _create.default)(parentProto, {
- constructor: {
- value: ParseObjectSubclass,
- enumerable: false,
- writable: true,
- configurable: true
- }
- });
- if (protoProps) {
- for (var prop in protoProps) {
- if (prop !== 'className') {
- (0, _defineProperty3.default)(ParseObjectSubclass.prototype, prop, {
- value: protoProps[prop],
- enumerable: false,
- writable: true,
- configurable: true
- });
- }
- }
- }
- if (classProps) {
- for (var _prop in classProps) {
- if (_prop !== 'className') {
- (0, _defineProperty3.default)(ParseObjectSubclass, _prop, {
- value: classProps[_prop],
- enumerable: false,
- writable: true,
- configurable: true
- });
- }
- }
- }
- ParseObjectSubclass.extend = function (name, protoProps, classProps) {
- if (typeof name === 'string') {
- return ParseObject.extend.call(ParseObjectSubclass, name, protoProps, classProps);
- }
- return ParseObject.extend.call(ParseObjectSubclass, adjustedClassName, name, protoProps);
- };
- ParseObjectSubclass.createWithoutData = ParseObject.createWithoutData;
- classMap[adjustedClassName] = ParseObjectSubclass;
- return ParseObjectSubclass;
- }
- /**
- * Enable single instance objects, where any local objects with the same Id
- * share the same attributes, and stay synchronized with each other.
- * This is disabled by default in server environments, since it can lead to
- * security issues.
- *
- * @static
- */
- }, {
- key: "enableSingleInstance",
- value: function () {
- singleInstance = true;
- _CoreManager.default.setObjectStateController(SingleInstanceStateController);
- }
- /**
- * Disable single instance objects, where any local objects with the same Id
- * share the same attributes, and stay synchronized with each other.
- * When disabled, you can have two instances of the same object in memory
- * without them sharing attributes.
- *
- * @static
- */
- }, {
- key: "disableSingleInstance",
- value: function () {
- singleInstance = false;
- _CoreManager.default.setObjectStateController(UniqueInstanceStateController);
- }
- /**
- * Asynchronously stores the objects and every object they point to in the local datastore,
- * recursively, using a default pin name: _default.
- *
- * If those other objects have not been fetched from Parse, they will not be stored.
- * However, if they have changed data, all the changes will be retained.
- *
- * <pre>
- * await Parse.Object.pinAll([...]);
- * </pre>
- *
- * To retrieve object:
- * <code>query.fromLocalDatastore()</code> or <code>query.fromPin()</code>
- *
- * @param {Array} objects A list of <code>Parse.Object</code>.
- * @returns {Promise} A promise that is fulfilled when the pin completes.
- * @static
- */
- }, {
- key: "pinAll",
- value: function (objects
- /*: Array<ParseObject>*/
- )
- /*: Promise<void>*/
- {
- var localDatastore = _CoreManager.default.getLocalDatastore();
- if (!localDatastore.isEnabled) {
- return _promise.default.reject('Parse.enableLocalDatastore() must be called first');
- }
- return ParseObject.pinAllWithName(_LocalDatastoreUtils.DEFAULT_PIN, objects);
- }
- /**
- * Asynchronously stores the objects and every object they point to in the local datastore, recursively.
- *
- * If those other objects have not been fetched from Parse, they will not be stored.
- * However, if they have changed data, all the changes will be retained.
- *
- * <pre>
- * await Parse.Object.pinAllWithName(name, [obj1, obj2, ...]);
- * </pre>
- *
- * To retrieve object:
- * <code>query.fromLocalDatastore()</code> or <code>query.fromPinWithName(name)</code>
- *
- * @param {string} name Name of Pin.
- * @param {Array} objects A list of <code>Parse.Object</code>.
- * @returns {Promise} A promise that is fulfilled when the pin completes.
- * @static
- */
- }, {
- key: "pinAllWithName",
- value: function (name
- /*: string*/
- , objects
- /*: Array<ParseObject>*/
- )
- /*: Promise<void>*/
- {
- var localDatastore = _CoreManager.default.getLocalDatastore();
- if (!localDatastore.isEnabled) {
- return _promise.default.reject('Parse.enableLocalDatastore() must be called first');
- }
- return localDatastore._handlePinAllWithName(name, objects);
- }
- /**
- * Asynchronously removes the objects and every object they point to in the local datastore,
- * recursively, using a default pin name: _default.
- *
- * <pre>
- * await Parse.Object.unPinAll([...]);
- * </pre>
- *
- * @param {Array} objects A list of <code>Parse.Object</code>.
- * @returns {Promise} A promise that is fulfilled when the unPin completes.
- * @static
- */
- }, {
- key: "unPinAll",
- value: function (objects
- /*: Array<ParseObject>*/
- )
- /*: Promise<void>*/
- {
- var localDatastore = _CoreManager.default.getLocalDatastore();
- if (!localDatastore.isEnabled) {
- return _promise.default.reject('Parse.enableLocalDatastore() must be called first');
- }
- return ParseObject.unPinAllWithName(_LocalDatastoreUtils.DEFAULT_PIN, objects);
- }
- /**
- * Asynchronously removes the objects and every object they point to in the local datastore, recursively.
- *
- * <pre>
- * await Parse.Object.unPinAllWithName(name, [obj1, obj2, ...]);
- * </pre>
- *
- * @param {string} name Name of Pin.
- * @param {Array} objects A list of <code>Parse.Object</code>.
- * @returns {Promise} A promise that is fulfilled when the unPin completes.
- * @static
- */
- }, {
- key: "unPinAllWithName",
- value: function (name
- /*: string*/
- , objects
- /*: Array<ParseObject>*/
- )
- /*: Promise<void>*/
- {
- var localDatastore = _CoreManager.default.getLocalDatastore();
- if (!localDatastore.isEnabled) {
- return _promise.default.reject('Parse.enableLocalDatastore() must be called first');
- }
- return localDatastore._handleUnPinAllWithName(name, objects);
- }
- /**
- * Asynchronously removes all objects in the local datastore using a default pin name: _default.
- *
- * <pre>
- * await Parse.Object.unPinAllObjects();
- * </pre>
- *
- * @returns {Promise} A promise that is fulfilled when the unPin completes.
- * @static
- */
- }, {
- key: "unPinAllObjects",
- value: function ()
- /*: Promise<void>*/
- {
- var localDatastore = _CoreManager.default.getLocalDatastore();
- if (!localDatastore.isEnabled) {
- return _promise.default.reject('Parse.enableLocalDatastore() must be called first');
- }
- return localDatastore.unPinWithName(_LocalDatastoreUtils.DEFAULT_PIN);
- }
- /**
- * Asynchronously removes all objects with the specified pin name.
- * Deletes the pin name also.
- *
- * <pre>
- * await Parse.Object.unPinAllObjectsWithName(name);
- * </pre>
- *
- * @param {string} name Name of Pin.
- * @returns {Promise} A promise that is fulfilled when the unPin completes.
- * @static
- */
- }, {
- key: "unPinAllObjectsWithName",
- value: function (name
- /*: string*/
- )
- /*: Promise<void>*/
- {
- var localDatastore = _CoreManager.default.getLocalDatastore();
- if (!localDatastore.isEnabled) {
- return _promise.default.reject('Parse.enableLocalDatastore() must be called first');
- }
- return localDatastore.unPinWithName(_LocalDatastoreUtils.PIN_PREFIX + name);
- }
- }]);
- return ParseObject;
- }();
- var DefaultController = {
- fetch: function (target
- /*: ParseObject | Array<ParseObject>*/
- , forceFetch
- /*: boolean*/
- , options
- /*: RequestOptions*/
- )
- /*: Promise<Array<void> | ParseObject>*/
- {
- var localDatastore = _CoreManager.default.getLocalDatastore();
- if ((0, _isArray.default)(target)) {
- if (target.length < 1) {
- return _promise.default.resolve([]);
- }
- var objs = [];
- var ids = [];
- var className = null;
- var results = [];
- var error = null;
- (0, _forEach.default)(target).call(target, function (el) {
- if (error) {
- return;
- }
- if (!className) {
- // eslint-disable-next-line prefer-destructuring
- className = el.className;
- }
- if (className !== el.className) {
- error = new _ParseError.default(_ParseError.default.INVALID_CLASS_NAME, 'All objects should be of the same class');
- }
- if (!el.id) {
- error = new _ParseError.default(_ParseError.default.MISSING_OBJECT_ID, 'All objects must have an ID');
- }
- if (forceFetch || !el.isDataAvailable()) {
- ids.push(el.id);
- objs.push(el);
- }
- results.push(el);
- });
- if (error) {
- return _promise.default.reject(error);
- }
- var query = new _ParseQuery.default(className);
- query.containedIn('objectId', ids);
- if (options && options.include) {
- query.include(options.include);
- }
- query._limit = ids.length;
- return (0, _find.default)(query).call(query, options).then( /*#__PURE__*/function () {
- var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(objects) {
- var idMap, i, obj, _i, _obj, id, _iterator2, _step2, object;
- return _regenerator.default.wrap(function (_context8) {
- while (1) {
- switch (_context8.prev = _context8.next) {
- case 0:
- idMap = {};
- (0, _forEach.default)(objects).call(objects, function (o) {
- idMap[o.id] = o;
- });
- i = 0;
- case 3:
- if (!(i < objs.length)) {
- _context8.next = 11;
- break;
- }
- obj = objs[i];
- if (!(!obj || !obj.id || !idMap[obj.id])) {
- _context8.next = 8;
- break;
- }
- if (!forceFetch) {
- _context8.next = 8;
- break;
- }
- return _context8.abrupt("return", _promise.default.reject(new _ParseError.default(_ParseError.default.OBJECT_NOT_FOUND, 'All objects must exist on the server.')));
- case 8:
- i++;
- _context8.next = 3;
- break;
- case 11:
- if (!singleInstance) {
- // If single instance objects are disabled, we need to replace the
- for (_i = 0; _i < results.length; _i++) {
- _obj = results[_i];
- if (_obj && _obj.id && idMap[_obj.id]) {
- id = _obj.id;
- _obj._finishFetch(idMap[id].toJSON());
- results[_i] = idMap[id];
- }
- }
- }
- _iterator2 = _createForOfIteratorHelper(results);
- _context8.prev = 13;
- _iterator2.s();
- case 15:
- if ((_step2 = _iterator2.n()).done) {
- _context8.next = 21;
- break;
- }
- object = _step2.value;
- _context8.next = 19;
- return localDatastore._updateObjectIfPinned(object);
- case 19:
- _context8.next = 15;
- break;
- case 21:
- _context8.next = 26;
- break;
- case 23:
- _context8.prev = 23;
- _context8.t0 = _context8["catch"](13);
- _iterator2.e(_context8.t0);
- case 26:
- _context8.prev = 26;
- _iterator2.f();
- return _context8.finish(26);
- case 29:
- return _context8.abrupt("return", _promise.default.resolve(results));
- case 30:
- case "end":
- return _context8.stop();
- }
- }
- }, _callee4, null, [[13, 23, 26, 29]]);
- }));
- return function () {
- return _ref.apply(this, arguments);
- };
- }());
- }
- if (target instanceof ParseObject) {
- var _context9;
- if (!target.id) {
- return _promise.default.reject(new _ParseError.default(_ParseError.default.MISSING_OBJECT_ID, 'Object does not have an ID'));
- }
- var RESTController = _CoreManager.default.getRESTController();
- var params = {};
- if (options && options.include) {
- params.include = options.include.join();
- }
- return RESTController.request('GET', (0, _concat.default)(_context9 = "classes/".concat(target.className, "/")).call(_context9, target._getId()), params, options).then( /*#__PURE__*/function () {
- var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(response) {
- return _regenerator.default.wrap(function (_context10) {
- while (1) {
- switch (_context10.prev = _context10.next) {
- case 0:
- target._clearPendingOps();
- target._clearServerData();
- target._finishFetch(response);
- _context10.next = 5;
- return localDatastore._updateObjectIfPinned(target);
- case 5:
- return _context10.abrupt("return", target);
- case 6:
- case "end":
- return _context10.stop();
- }
- }
- }, _callee5);
- }));
- return function () {
- return _ref2.apply(this, arguments);
- };
- }());
- }
- return _promise.default.resolve();
- },
- destroy: function (target
- /*: ParseObject | Array<ParseObject>*/
- , options
- /*: RequestOptions*/
- )
- /*: Promise<Array<void> | ParseObject>*/
- {
- return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8() {
- var batchSize, localDatastore, RESTController, batches, deleteCompleted, errors, _context14;
- return _regenerator.default.wrap(function (_context16) {
- while (1) {
- switch (_context16.prev = _context16.next) {
- case 0:
- batchSize = options && options.batchSize ? options.batchSize : _CoreManager.default.get('REQUEST_BATCH_SIZE');
- localDatastore = _CoreManager.default.getLocalDatastore();
- RESTController = _CoreManager.default.getRESTController();
- if (!(0, _isArray.default)(target)) {
- _context16.next = 13;
- break;
- }
- if (!(target.length < 1)) {
- _context16.next = 6;
- break;
- }
- return _context16.abrupt("return", _promise.default.resolve([]));
- case 6:
- batches = [[]];
- (0, _forEach.default)(target).call(target, function (obj) {
- if (!obj.id) {
- return;
- }
- batches[batches.length - 1].push(obj);
- if (batches[batches.length - 1].length >= batchSize) {
- batches.push([]);
- }
- });
- if (batches[batches.length - 1].length === 0) {
- // If the last batch is empty, remove it
- batches.pop();
- }
- deleteCompleted = _promise.default.resolve();
- errors = [];
- (0, _forEach.default)(batches).call(batches, function (batch) {
- deleteCompleted = deleteCompleted.then(function () {
- return RESTController.request('POST', 'batch', {
- requests: (0, _map.default)(batch).call(batch, function (obj) {
- var _context11, _context12;
- return {
- method: 'DELETE',
- path: (0, _concat.default)(_context11 = (0, _concat.default)(_context12 = "".concat(getServerUrlPath(), "classes/")).call(_context12, obj.className, "/")).call(_context11, obj._getId()),
- body: {}
- };
- })
- }, options).then(function (results) {
- for (var i = 0; i < results.length; i++) {
- if (results[i] && results[i].hasOwnProperty('error')) {
- var err = new _ParseError.default(results[i].error.code, results[i].error.error);
- err.object = batch[i];
- errors.push(err);
- }
- }
- });
- });
- });
- return _context16.abrupt("return", deleteCompleted.then( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6() {
- var aggregate, _iterator3, _step3, object;
- return _regenerator.default.wrap(function (_context13) {
- while (1) {
- switch (_context13.prev = _context13.next) {
- case 0:
- if (!errors.length) {
- _context13.next = 4;
- break;
- }
- aggregate = new _ParseError.default(_ParseError.default.AGGREGATE_ERROR);
- aggregate.errors = errors;
- return _context13.abrupt("return", _promise.default.reject(aggregate));
- case 4:
- _iterator3 = _createForOfIteratorHelper(target);
- _context13.prev = 5;
- _iterator3.s();
- case 7:
- if ((_step3 = _iterator3.n()).done) {
- _context13.next = 13;
- break;
- }
- object = _step3.value;
- _context13.next = 11;
- return localDatastore._destroyObjectIfPinned(object);
- case 11:
- _context13.next = 7;
- break;
- case 13:
- _context13.next = 18;
- break;
- case 15:
- _context13.prev = 15;
- _context13.t0 = _context13["catch"](5);
- _iterator3.e(_context13.t0);
- case 18:
- _context13.prev = 18;
- _iterator3.f();
- return _context13.finish(18);
- case 21:
- return _context13.abrupt("return", _promise.default.resolve(target));
- case 22:
- case "end":
- return _context13.stop();
- }
- }
- }, _callee6, null, [[5, 15, 18, 21]]);
- }))));
- case 13:
- if (!(target instanceof ParseObject)) {
- _context16.next = 15;
- break;
- }
- return _context16.abrupt("return", RESTController.request('DELETE', (0, _concat.default)(_context14 = "classes/".concat(target.className, "/")).call(_context14, target._getId()), {}, options).then( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7() {
- return _regenerator.default.wrap(function (_context15) {
- while (1) {
- switch (_context15.prev = _context15.next) {
- case 0:
- _context15.next = 2;
- return localDatastore._destroyObjectIfPinned(target);
- case 2:
- return _context15.abrupt("return", _promise.default.resolve(target));
- case 3:
- case "end":
- return _context15.stop();
- }
- }
- }, _callee7);
- }))));
- case 15:
- return _context16.abrupt("return", _promise.default.resolve(target));
- case 16:
- case "end":
- return _context16.stop();
- }
- }
- }, _callee8);
- }))();
- },
- save: function (target
- /*: ParseObject | Array<ParseObject | ParseFile>*/
- , options
- /*: RequestOptions*/
- ) {
- var batchSize = options && options.batchSize ? options.batchSize : _CoreManager.default.get('REQUEST_BATCH_SIZE');
- var localDatastore = _CoreManager.default.getLocalDatastore();
- var mapIdForPin = {};
- var RESTController = _CoreManager.default.getRESTController();
- var stateController = _CoreManager.default.getObjectStateController();
- options = options || {};
- options.returnStatus = options.returnStatus || true;
- if ((0, _isArray.default)(target)) {
- if (target.length < 1) {
- return _promise.default.resolve([]);
- }
- var unsaved = (0, _concat.default)(target).call(target);
- for (var i = 0; i < target.length; i++) {
- if (target[i] instanceof ParseObject) {
- unsaved = (0, _concat.default)(unsaved).call(unsaved, (0, _unsavedChildren.default)(target[i], true));
- }
- }
- unsaved = (0, _unique.default)(unsaved);
- var filesSaved
- /*: Array<ParseFile>*/
- = [];
- var pending
- /*: Array<ParseObject>*/
- = [];
- (0, _forEach.default)(unsaved).call(unsaved, function (el) {
- if (el instanceof _ParseFile.default) {
- filesSaved.push(el.save(options));
- } else if (el instanceof ParseObject) {
- pending.push(el);
- }
- });
- return _promise.default.all(filesSaved).then(function () {
- var objectError = null;
- return (0, _promiseUtils.continueWhile)(function () {
- return pending.length > 0;
- }, function () {
- var batch = [];
- var nextPending = [];
- (0, _forEach.default)(pending).call(pending, function (el) {
- if (batch.length < batchSize && (0, _canBeSerialized.default)(el)) {
- batch.push(el);
- } else {
- nextPending.push(el);
- }
- });
- pending = nextPending;
- if (batch.length < 1) {
- return _promise.default.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Tried to save a batch with a cycle.'));
- } // Queue up tasks for each object in the batch.
- // When every task is ready, the API request will execute
- var batchReturned = new _promiseUtils.resolvingPromise();
- var batchReady = [];
- var batchTasks = [];
- (0, _forEach.default)(batch).call(batch, function (obj, index) {
- var ready = new _promiseUtils.resolvingPromise();
- batchReady.push(ready);
- stateController.pushPendingState(obj._getStateIdentifier());
- batchTasks.push(stateController.enqueueTask(obj._getStateIdentifier(), function () {
- ready.resolve();
- return batchReturned.then(function (responses) {
- if (responses[index].hasOwnProperty('success')) {
- var objectId = responses[index].success.objectId;
- var status = responses[index]._status;
- delete responses[index]._status;
- mapIdForPin[objectId] = obj._localId;
- obj._handleSaveResponse(responses[index].success, status);
- } else {
- if (!objectError && responses[index].hasOwnProperty('error')) {
- var serverError = responses[index].error;
- objectError = new _ParseError.default(serverError.code, serverError.error); // Cancel the rest of the save
- pending = [];
- }
- obj._handleSaveError();
- }
- });
- }));
- });
- (0, _promiseUtils.when)(batchReady).then(function () {
- // Kick off the batch request
- return RESTController.request('POST', 'batch', {
- requests: (0, _map.default)(batch).call(batch, function (obj) {
- var params = obj._getSaveParams();
- params.path = getServerUrlPath() + params.path;
- return params;
- })
- }, options);
- }).then(batchReturned.resolve, function (error) {
- batchReturned.reject(new _ParseError.default(_ParseError.default.INCORRECT_TYPE, error.message));
- });
- return (0, _promiseUtils.when)(batchTasks);
- }).then( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee9() {
- var _iterator4, _step4, object;
- return _regenerator.default.wrap(function (_context17) {
- while (1) {
- switch (_context17.prev = _context17.next) {
- case 0:
- if (!objectError) {
- _context17.next = 2;
- break;
- }
- return _context17.abrupt("return", _promise.default.reject(objectError));
- case 2:
- _iterator4 = _createForOfIteratorHelper(target);
- _context17.prev = 3;
- _iterator4.s();
- case 5:
- if ((_step4 = _iterator4.n()).done) {
- _context17.next = 13;
- break;
- }
- object = _step4.value;
- _context17.next = 9;
- return localDatastore._updateLocalIdForObject(mapIdForPin[object.id], object);
- case 9:
- _context17.next = 11;
- return localDatastore._updateObjectIfPinned(object);
- case 11:
- _context17.next = 5;
- break;
- case 13:
- _context17.next = 18;
- break;
- case 15:
- _context17.prev = 15;
- _context17.t0 = _context17["catch"](3);
- _iterator4.e(_context17.t0);
- case 18:
- _context17.prev = 18;
- _iterator4.f();
- return _context17.finish(18);
- case 21:
- return _context17.abrupt("return", _promise.default.resolve(target));
- case 22:
- case "end":
- return _context17.stop();
- }
- }
- }, _callee9, null, [[3, 15, 18, 21]]);
- })));
- });
- }
- if (target instanceof ParseObject) {
- // generate _localId in case if cascadeSave=false
- target._getId();
- var localId = target._localId; // copying target lets Flow guarantee the pointer isn't modified elsewhere
- var targetCopy = target;
- var task = function () {
- var params = targetCopy._getSaveParams();
- return RESTController.request(params.method, params.path, params.body, options).then(function (response) {
- var status = response._status;
- delete response._status;
- targetCopy._handleSaveResponse(response, status);
- }, function (error) {
- targetCopy._handleSaveError();
- return _promise.default.reject(error);
- });
- };
- stateController.pushPendingState(target._getStateIdentifier());
- return stateController.enqueueTask(target._getStateIdentifier(), task).then( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee10() {
- return _regenerator.default.wrap(function (_context18) {
- while (1) {
- switch (_context18.prev = _context18.next) {
- case 0:
- _context18.next = 2;
- return localDatastore._updateLocalIdForObject(localId, target);
- case 2:
- _context18.next = 4;
- return localDatastore._updateObjectIfPinned(target);
- case 4:
- return _context18.abrupt("return", target);
- case 5:
- case "end":
- return _context18.stop();
- }
- }
- }, _callee10);
- })), function (error) {
- return _promise.default.reject(error);
- });
- }
- return _promise.default.resolve();
- }
- };
- _CoreManager.default.setObjectController(DefaultController);
- var _default = ParseObject;
- exports.default = _default;
- },{"./CoreManager":5,"./LocalDatastoreUtils":15,"./ParseACL":26,"./ParseError":29,"./ParseFile":30,"./ParseOp":37,"./ParseQuery":39,"./ParseRelation":40,"./SingleInstanceStateController":47,"./UniqueInstanceStateController":52,"./canBeSerialized":63,"./decode":65,"./encode":66,"./escape":68,"./parseDate":71,"./promiseUtils":72,"./unique":73,"./unsavedChildren":74,"@babel/runtime-corejs3/core-js-stable/array/from":78,"@babel/runtime-corejs3/core-js-stable/array/is-array":79,"@babel/runtime-corejs3/core-js-stable/instance/concat":81,"@babel/runtime-corejs3/core-js-stable/instance/filter":84,"@babel/runtime-corejs3/core-js-stable/instance/find":85,"@babel/runtime-corejs3/core-js-stable/instance/for-each":86,"@babel/runtime-corejs3/core-js-stable/instance/includes":87,"@babel/runtime-corejs3/core-js-stable/instance/index-of":88,"@babel/runtime-corejs3/core-js-stable/instance/map":90,"@babel/runtime-corejs3/core-js-stable/instance/slice":93,"@babel/runtime-corejs3/core-js-stable/json/stringify":99,"@babel/runtime-corejs3/core-js-stable/object/create":103,"@babel/runtime-corejs3/core-js-stable/object/define-properties":104,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/core-js-stable/object/freeze":107,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor":108,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors":109,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols":110,"@babel/runtime-corejs3/core-js-stable/object/get-prototype-of":111,"@babel/runtime-corejs3/core-js-stable/object/keys":112,"@babel/runtime-corejs3/core-js-stable/promise":115,"@babel/runtime-corejs3/core-js-stable/symbol":119,"@babel/runtime-corejs3/core-js-stable/weak-map":122,"@babel/runtime-corejs3/core-js/get-iterator-method":125,"@babel/runtime-corejs3/helpers/asyncToGenerator":144,"@babel/runtime-corejs3/helpers/classCallCheck":145,"@babel/runtime-corejs3/helpers/createClass":147,"@babel/runtime-corejs3/helpers/defineProperty":148,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/helpers/typeof":164,"@babel/runtime-corejs3/regenerator":167,"uuid":797}],37:[function(_dereq_,module,exports){
- "use strict";
- var _Reflect$construct = _dereq_("@babel/runtime-corejs3/core-js-stable/reflect/construct");
- var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
- var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
- _Object$defineProperty(exports, "__esModule", {
- value: true
- });
- exports.UnsetOp = exports.SetOp = exports.RemoveOp = exports.RelationOp = exports.Op = exports.IncrementOp = exports.AddUniqueOp = exports.AddOp = void 0;
- exports.opFromJSON = opFromJSON;
- var _assertThisInitialized2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/assertThisInitialized"));
- var _inherits2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/inherits"));
- var _possibleConstructorReturn2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/possibleConstructorReturn"));
- var _getPrototypeOf2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/getPrototypeOf"));
- var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
- var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
- var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
- var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
- var _concat = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/concat"));
- var _forEach = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
- var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
- var _splice = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/splice"));
- var _map = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/map"));
- var _arrayContainsObject = _interopRequireDefault(_dereq_("./arrayContainsObject"));
- var _decode = _interopRequireDefault(_dereq_("./decode"));
- var _encode = _interopRequireDefault(_dereq_("./encode"));
- var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
- var _ParseRelation = _interopRequireDefault(_dereq_("./ParseRelation"));
- var _unique = _interopRequireDefault(_dereq_("./unique"));
- function _createSuper(Derived) {
- var hasNativeReflectConstruct = _isNativeReflectConstruct();
- return function () {
- var Super = (0, _getPrototypeOf2.default)(Derived),
- result;
- if (hasNativeReflectConstruct) {
- var NewTarget = (0, _getPrototypeOf2.default)(this).constructor;
- result = _Reflect$construct(Super, arguments, NewTarget);
- } else {
- result = Super.apply(this, arguments);
- }
- return (0, _possibleConstructorReturn2.default)(this, result);
- };
- }
- function _isNativeReflectConstruct() {
- if (typeof Reflect === "undefined" || !_Reflect$construct) return false;
- if (_Reflect$construct.sham) return false;
- if (typeof Proxy === "function") return true;
- try {
- Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {}));
- return true;
- } catch (e) {
- return false;
- }
- }
- function opFromJSON(json
- /*: { [key: string]: any }*/
- )
- /*: ?Op*/
- {
- if (!json || !json.__op) {
- return null;
- }
- switch (json.__op) {
- case 'Delete':
- return new UnsetOp();
- case 'Increment':
- return new IncrementOp(json.amount);
- case 'Add':
- return new AddOp((0, _decode.default)(json.objects));
- case 'AddUnique':
- return new AddUniqueOp((0, _decode.default)(json.objects));
- case 'Remove':
- return new RemoveOp((0, _decode.default)(json.objects));
- case 'AddRelation':
- {
- var toAdd = (0, _decode.default)(json.objects);
- if (!(0, _isArray.default)(toAdd)) {
- return new RelationOp([], []);
- }
- return new RelationOp(toAdd, []);
- }
- case 'RemoveRelation':
- {
- var toRemove = (0, _decode.default)(json.objects);
- if (!(0, _isArray.default)(toRemove)) {
- return new RelationOp([], []);
- }
- return new RelationOp([], toRemove);
- }
- case 'Batch':
- {
- var _toAdd = [];
- var _toRemove = [];
- for (var i = 0; i < json.ops.length; i++) {
- if (json.ops[i].__op === 'AddRelation') {
- _toAdd = (0, _concat.default)(_toAdd).call(_toAdd, (0, _decode.default)(json.ops[i].objects));
- } else if (json.ops[i].__op === 'RemoveRelation') {
- _toRemove = (0, _concat.default)(_toRemove).call(_toRemove, (0, _decode.default)(json.ops[i].objects));
- }
- }
- return new RelationOp(_toAdd, _toRemove);
- }
- default:
- return null;
- }
- }
- var Op = /*#__PURE__*/function () {
- function Op() {
- (0, _classCallCheck2.default)(this, Op);
- }
- (0, _createClass2.default)(Op, [{
- key: "applyTo",
- value: // Empty parent class
- function ()
- /*: mixed*/
- {}
- /* eslint-disable-line no-unused-vars */
- }, {
- key: "mergeWith",
- value: function ()
- /*: ?Op*/
- {}
- /* eslint-disable-line no-unused-vars */
- }, {
- key: "toJSON",
- value: function ()
- /*: mixed*/
- {}
- }]);
- return Op;
- }();
- exports.Op = Op;
- var SetOp = /*#__PURE__*/function (_Op) {
- (0, _inherits2.default)(SetOp, _Op);
- var _super = _createSuper(SetOp);
- function SetOp(value
- /*: mixed*/
- ) {
- var _this;
- (0, _classCallCheck2.default)(this, SetOp);
- _this = _super.call(this);
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "_value", void 0);
- _this._value = value;
- return _this;
- }
- (0, _createClass2.default)(SetOp, [{
- key: "applyTo",
- value: function ()
- /*: mixed*/
- {
- return this._value;
- }
- }, {
- key: "mergeWith",
- value: function ()
- /*: SetOp*/
- {
- return new SetOp(this._value);
- }
- }, {
- key: "toJSON",
- value: function (offline
- /*:: ?: boolean*/
- ) {
- return (0, _encode.default)(this._value, false, true, undefined, offline);
- }
- }]);
- return SetOp;
- }(Op);
- exports.SetOp = SetOp;
- var UnsetOp = /*#__PURE__*/function (_Op2) {
- (0, _inherits2.default)(UnsetOp, _Op2);
- var _super2 = _createSuper(UnsetOp);
- function UnsetOp() {
- (0, _classCallCheck2.default)(this, UnsetOp);
- return _super2.apply(this, arguments);
- }
- (0, _createClass2.default)(UnsetOp, [{
- key: "applyTo",
- value: function () {
- return undefined;
- }
- }, {
- key: "mergeWith",
- value: function ()
- /*: UnsetOp*/
- {
- return new UnsetOp();
- }
- }, {
- key: "toJSON",
- value: function ()
- /*: { __op: string }*/
- {
- return {
- __op: 'Delete'
- };
- }
- }]);
- return UnsetOp;
- }(Op);
- exports.UnsetOp = UnsetOp;
- var IncrementOp = /*#__PURE__*/function (_Op3) {
- (0, _inherits2.default)(IncrementOp, _Op3);
- var _super3 = _createSuper(IncrementOp);
- function IncrementOp(amount
- /*: number*/
- ) {
- var _this2;
- (0, _classCallCheck2.default)(this, IncrementOp);
- _this2 = _super3.call(this);
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this2), "_amount", void 0);
- if (typeof amount !== 'number') {
- throw new TypeError('Increment Op must be initialized with a numeric amount.');
- }
- _this2._amount = amount;
- return _this2;
- }
- (0, _createClass2.default)(IncrementOp, [{
- key: "applyTo",
- value: function (value
- /*: ?mixed*/
- )
- /*: number*/
- {
- if (typeof value === 'undefined') {
- return this._amount;
- }
- if (typeof value !== 'number') {
- throw new TypeError('Cannot increment a non-numeric value.');
- }
- return this._amount + value;
- }
- }, {
- key: "mergeWith",
- value: function (previous
- /*: Op*/
- )
- /*: Op*/
- {
- if (!previous) {
- return this;
- }
- if (previous instanceof SetOp) {
- return new SetOp(this.applyTo(previous._value));
- }
- if (previous instanceof UnsetOp) {
- return new SetOp(this._amount);
- }
- if (previous instanceof IncrementOp) {
- return new IncrementOp(this.applyTo(previous._amount));
- }
- throw new Error('Cannot merge Increment Op with the previous Op');
- }
- }, {
- key: "toJSON",
- value: function ()
- /*: { __op: string, amount: number }*/
- {
- return {
- __op: 'Increment',
- amount: this._amount
- };
- }
- }]);
- return IncrementOp;
- }(Op);
- exports.IncrementOp = IncrementOp;
- var AddOp = /*#__PURE__*/function (_Op4) {
- (0, _inherits2.default)(AddOp, _Op4);
- var _super4 = _createSuper(AddOp);
- function AddOp(value
- /*: mixed | Array<mixed>*/
- ) {
- var _this3;
- (0, _classCallCheck2.default)(this, AddOp);
- _this3 = _super4.call(this);
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this3), "_value", void 0);
- _this3._value = (0, _isArray.default)(value) ? value : [value];
- return _this3;
- }
- (0, _createClass2.default)(AddOp, [{
- key: "applyTo",
- value: function (value
- /*: mixed*/
- )
- /*: Array<mixed>*/
- {
- if (value == null) {
- return this._value;
- }
- if ((0, _isArray.default)(value)) {
- return (0, _concat.default)(value).call(value, this._value);
- }
- throw new Error('Cannot add elements to a non-array value');
- }
- }, {
- key: "mergeWith",
- value: function (previous
- /*: Op*/
- )
- /*: Op*/
- {
- if (!previous) {
- return this;
- }
- if (previous instanceof SetOp) {
- return new SetOp(this.applyTo(previous._value));
- }
- if (previous instanceof UnsetOp) {
- return new SetOp(this._value);
- }
- if (previous instanceof AddOp) {
- return new AddOp(this.applyTo(previous._value));
- }
- throw new Error('Cannot merge Add Op with the previous Op');
- }
- }, {
- key: "toJSON",
- value: function ()
- /*: { __op: string, objects: mixed }*/
- {
- return {
- __op: 'Add',
- objects: (0, _encode.default)(this._value, false, true)
- };
- }
- }]);
- return AddOp;
- }(Op);
- exports.AddOp = AddOp;
- var AddUniqueOp = /*#__PURE__*/function (_Op5) {
- (0, _inherits2.default)(AddUniqueOp, _Op5);
- var _super5 = _createSuper(AddUniqueOp);
- function AddUniqueOp(value
- /*: mixed | Array<mixed>*/
- ) {
- var _this4;
- (0, _classCallCheck2.default)(this, AddUniqueOp);
- _this4 = _super5.call(this);
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this4), "_value", void 0);
- _this4._value = (0, _unique.default)((0, _isArray.default)(value) ? value : [value]);
- return _this4;
- }
- (0, _createClass2.default)(AddUniqueOp, [{
- key: "applyTo",
- value: function (value
- /*: mixed | Array<mixed>*/
- )
- /*: Array<mixed>*/
- {
- if (value == null) {
- return this._value || [];
- }
- if ((0, _isArray.default)(value)) {
- var _context;
- var toAdd = [];
- (0, _forEach.default)(_context = this._value).call(_context, function (v) {
- if (v instanceof _ParseObject.default) {
- if (!(0, _arrayContainsObject.default)(value, v)) {
- toAdd.push(v);
- }
- } else {
- if ((0, _indexOf.default)(value).call(value, v) < 0) {
- toAdd.push(v);
- }
- }
- });
- return (0, _concat.default)(value).call(value, toAdd);
- }
- throw new Error('Cannot add elements to a non-array value');
- }
- }, {
- key: "mergeWith",
- value: function (previous
- /*: Op*/
- )
- /*: Op*/
- {
- if (!previous) {
- return this;
- }
- if (previous instanceof SetOp) {
- return new SetOp(this.applyTo(previous._value));
- }
- if (previous instanceof UnsetOp) {
- return new SetOp(this._value);
- }
- if (previous instanceof AddUniqueOp) {
- return new AddUniqueOp(this.applyTo(previous._value));
- }
- throw new Error('Cannot merge AddUnique Op with the previous Op');
- }
- }, {
- key: "toJSON",
- value: function ()
- /*: { __op: string, objects: mixed }*/
- {
- return {
- __op: 'AddUnique',
- objects: (0, _encode.default)(this._value, false, true)
- };
- }
- }]);
- return AddUniqueOp;
- }(Op);
- exports.AddUniqueOp = AddUniqueOp;
- var RemoveOp = /*#__PURE__*/function (_Op6) {
- (0, _inherits2.default)(RemoveOp, _Op6);
- var _super6 = _createSuper(RemoveOp);
- function RemoveOp(value
- /*: mixed | Array<mixed>*/
- ) {
- var _this5;
- (0, _classCallCheck2.default)(this, RemoveOp);
- _this5 = _super6.call(this);
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this5), "_value", void 0);
- _this5._value = (0, _unique.default)((0, _isArray.default)(value) ? value : [value]);
- return _this5;
- }
- (0, _createClass2.default)(RemoveOp, [{
- key: "applyTo",
- value: function (value
- /*: mixed | Array<mixed>*/
- )
- /*: Array<mixed>*/
- {
- if (value == null) {
- return [];
- }
- if ((0, _isArray.default)(value)) {
- // var i = value.indexOf(this._value);
- var removed = (0, _concat.default)(value).call(value, []);
- for (var i = 0; i < this._value.length; i++) {
- var index = (0, _indexOf.default)(removed).call(removed, this._value[i]);
- while (index > -1) {
- (0, _splice.default)(removed).call(removed, index, 1);
- index = (0, _indexOf.default)(removed).call(removed, this._value[i]);
- }
- if (this._value[i] instanceof _ParseObject.default && this._value[i].id) {
- for (var j = 0; j < removed.length; j++) {
- if (removed[j] instanceof _ParseObject.default && this._value[i].id === removed[j].id) {
- (0, _splice.default)(removed).call(removed, j, 1);
- j--;
- }
- }
- }
- }
- return removed;
- }
- throw new Error('Cannot remove elements from a non-array value');
- }
- }, {
- key: "mergeWith",
- value: function (previous
- /*: Op*/
- )
- /*: Op*/
- {
- if (!previous) {
- return this;
- }
- if (previous instanceof SetOp) {
- return new SetOp(this.applyTo(previous._value));
- }
- if (previous instanceof UnsetOp) {
- return new UnsetOp();
- }
- if (previous instanceof RemoveOp) {
- var _context2;
- var uniques = (0, _concat.default)(_context2 = previous._value).call(_context2, []);
- for (var i = 0; i < this._value.length; i++) {
- if (this._value[i] instanceof _ParseObject.default) {
- if (!(0, _arrayContainsObject.default)(uniques, this._value[i])) {
- uniques.push(this._value[i]);
- }
- } else {
- if ((0, _indexOf.default)(uniques).call(uniques, this._value[i]) < 0) {
- uniques.push(this._value[i]);
- }
- }
- }
- return new RemoveOp(uniques);
- }
- throw new Error('Cannot merge Remove Op with the previous Op');
- }
- }, {
- key: "toJSON",
- value: function ()
- /*: { __op: string, objects: mixed }*/
- {
- return {
- __op: 'Remove',
- objects: (0, _encode.default)(this._value, false, true)
- };
- }
- }]);
- return RemoveOp;
- }(Op);
- exports.RemoveOp = RemoveOp;
- var RelationOp = /*#__PURE__*/function (_Op7) {
- (0, _inherits2.default)(RelationOp, _Op7);
- var _super7 = _createSuper(RelationOp);
- function RelationOp(adds
- /*: Array<ParseObject | string>*/
- , removes
- /*: Array<ParseObject | string>*/
- ) {
- var _this6;
- (0, _classCallCheck2.default)(this, RelationOp);
- _this6 = _super7.call(this);
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this6), "_targetClassName", void 0);
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this6), "relationsToAdd", void 0);
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this6), "relationsToRemove", void 0);
- _this6._targetClassName = null;
- if ((0, _isArray.default)(adds)) {
- _this6.relationsToAdd = (0, _unique.default)((0, _map.default)(adds).call(adds, _this6._extractId, (0, _assertThisInitialized2.default)(_this6)));
- }
- if ((0, _isArray.default)(removes)) {
- _this6.relationsToRemove = (0, _unique.default)((0, _map.default)(removes).call(removes, _this6._extractId, (0, _assertThisInitialized2.default)(_this6)));
- }
- return _this6;
- }
- (0, _createClass2.default)(RelationOp, [{
- key: "_extractId",
- value: function (obj
- /*: string | ParseObject*/
- )
- /*: string*/
- {
- if (typeof obj === 'string') {
- return obj;
- }
- if (!obj.id) {
- throw new Error('You cannot add or remove an unsaved Parse Object from a relation');
- }
- if (!this._targetClassName) {
- this._targetClassName = obj.className;
- }
- if (this._targetClassName !== obj.className) {
- var _context3;
- throw new Error((0, _concat.default)(_context3 = "Tried to create a Relation with 2 different object types: ".concat(this._targetClassName, " and ")).call(_context3, obj.className, "."));
- }
- return obj.id;
- }
- }, {
- key: "applyTo",
- value: function (value
- /*: mixed*/
- , object
- /*:: ?: { className: string, id: ?string }*/
- , key
- /*:: ?: string*/
- )
- /*: ?ParseRelation*/
- {
- if (!value) {
- var _context4;
- if (!object || !key) {
- throw new Error('Cannot apply a RelationOp without either a previous value, or an object and a key');
- }
- var parent = new _ParseObject.default(object.className);
- if (object.id && (0, _indexOf.default)(_context4 = object.id).call(_context4, 'local') === 0) {
- parent._localId = object.id;
- } else if (object.id) {
- parent.id = object.id;
- }
- var relation = new _ParseRelation.default(parent, key);
- relation.targetClassName = this._targetClassName;
- return relation;
- }
- if (value instanceof _ParseRelation.default) {
- if (this._targetClassName) {
- if (value.targetClassName) {
- if (this._targetClassName !== value.targetClassName) {
- var _context5;
- throw new Error((0, _concat.default)(_context5 = "Related object must be a ".concat(value.targetClassName, ", but a ")).call(_context5, this._targetClassName, " was passed in."));
- }
- } else {
- value.targetClassName = this._targetClassName;
- }
- }
- return value;
- }
- throw new Error('Relation cannot be applied to a non-relation field');
- }
- }, {
- key: "mergeWith",
- value: function (previous
- /*: Op*/
- )
- /*: Op*/
- {
- if (!previous) {
- return this;
- }
- if (previous instanceof UnsetOp) {
- throw new Error('You cannot modify a relation after deleting it.');
- }
- if (previous instanceof SetOp && previous._value instanceof _ParseRelation.default) {
- return this;
- }
- if (previous instanceof RelationOp) {
- var _context7, _context8, _context9, _context10, _context11, _context12;
- if (previous._targetClassName && previous._targetClassName !== this._targetClassName) {
- var _context6;
- throw new Error((0, _concat.default)(_context6 = "Related object must be of class ".concat(previous._targetClassName, ", but ")).call(_context6, this._targetClassName || 'null', " was passed in."));
- }
- var newAdd = (0, _concat.default)(_context7 = previous.relationsToAdd).call(_context7, []);
- (0, _forEach.default)(_context8 = this.relationsToRemove).call(_context8, function (r) {
- var index = (0, _indexOf.default)(newAdd).call(newAdd, r);
- if (index > -1) {
- (0, _splice.default)(newAdd).call(newAdd, index, 1);
- }
- });
- (0, _forEach.default)(_context9 = this.relationsToAdd).call(_context9, function (r) {
- var index = (0, _indexOf.default)(newAdd).call(newAdd, r);
- if (index < 0) {
- newAdd.push(r);
- }
- });
- var newRemove = (0, _concat.default)(_context10 = previous.relationsToRemove).call(_context10, []);
- (0, _forEach.default)(_context11 = this.relationsToAdd).call(_context11, function (r) {
- var index = (0, _indexOf.default)(newRemove).call(newRemove, r);
- if (index > -1) {
- (0, _splice.default)(newRemove).call(newRemove, index, 1);
- }
- });
- (0, _forEach.default)(_context12 = this.relationsToRemove).call(_context12, function (r) {
- var index = (0, _indexOf.default)(newRemove).call(newRemove, r);
- if (index < 0) {
- newRemove.push(r);
- }
- });
- var newRelation = new RelationOp(newAdd, newRemove);
- newRelation._targetClassName = this._targetClassName;
- return newRelation;
- }
- throw new Error('Cannot merge Relation Op with the previous Op');
- }
- }, {
- key: "toJSON",
- value: function ()
- /*: { __op?: string, objects?: mixed, ops?: mixed }*/
- {
- var _this7 = this;
- var idToPointer = function (id) {
- return {
- __type: 'Pointer',
- className: _this7._targetClassName,
- objectId: id
- };
- };
- var adds = null;
- var removes = null;
- var pointers = null;
- if (this.relationsToAdd.length > 0) {
- var _context13;
- pointers = (0, _map.default)(_context13 = this.relationsToAdd).call(_context13, idToPointer);
- adds = {
- __op: 'AddRelation',
- objects: pointers
- };
- }
- if (this.relationsToRemove.length > 0) {
- var _context14;
- pointers = (0, _map.default)(_context14 = this.relationsToRemove).call(_context14, idToPointer);
- removes = {
- __op: 'RemoveRelation',
- objects: pointers
- };
- }
- if (adds && removes) {
- return {
- __op: 'Batch',
- ops: [adds, removes]
- };
- }
- return adds || removes || {};
- }
- }]);
- return RelationOp;
- }(Op);
- exports.RelationOp = RelationOp;
- },{"./ParseObject":36,"./ParseRelation":40,"./arrayContainsObject":62,"./decode":65,"./encode":66,"./unique":73,"@babel/runtime-corejs3/core-js-stable/array/is-array":79,"@babel/runtime-corejs3/core-js-stable/instance/concat":81,"@babel/runtime-corejs3/core-js-stable/instance/for-each":86,"@babel/runtime-corejs3/core-js-stable/instance/index-of":88,"@babel/runtime-corejs3/core-js-stable/instance/map":90,"@babel/runtime-corejs3/core-js-stable/instance/splice":95,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/core-js-stable/reflect/construct":116,"@babel/runtime-corejs3/helpers/assertThisInitialized":143,"@babel/runtime-corejs3/helpers/classCallCheck":145,"@babel/runtime-corejs3/helpers/createClass":147,"@babel/runtime-corejs3/helpers/defineProperty":148,"@babel/runtime-corejs3/helpers/getPrototypeOf":150,"@babel/runtime-corejs3/helpers/inherits":151,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/helpers/possibleConstructorReturn":159}],38:[function(_dereq_,module,exports){
- "use strict";
- var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
- var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
- _Object$defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = void 0;
- var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
- var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
- var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
- var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
- var _ParseGeoPoint = _interopRequireDefault(_dereq_("./ParseGeoPoint"));
- /**
- * Copyright (c) 2015-present, Parse, LLC.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- *
- * @flow
- */
- /**
- * Creates a new Polygon with any of the following forms:<br>
- * <pre>
- * new Polygon([[0,0],[0,1],[1,1],[1,0]])
- * new Polygon([GeoPoint, GeoPoint, GeoPoint])
- * </pre>
- *
- * <p>Represents a coordinates that may be associated
- * with a key in a ParseObject or used as a reference point for geo queries.
- * This allows proximity-based queries on the key.</p>
- *
- * <p>Example:<pre>
- * var polygon = new Parse.Polygon([[0,0],[0,1],[1,1],[1,0]]);
- * var object = new Parse.Object("PlaceObject");
- * object.set("area", polygon);
- * object.save();</pre></p>
- *
- * @alias Parse.Polygon
- */
- var ParsePolygon = /*#__PURE__*/function () {
- /**
- * @param {(number[][] | Parse.GeoPoint[])} coordinates An Array of coordinate pairs
- */
- function ParsePolygon(coordinates
- /*: Array<Array<number>> | Array<ParseGeoPoint>*/
- ) {
- (0, _classCallCheck2.default)(this, ParsePolygon);
- (0, _defineProperty2.default)(this, "_coordinates", void 0);
- this._coordinates = ParsePolygon._validate(coordinates);
- }
- /**
- * Coordinates value for this Polygon.
- * Throws an exception if not valid type.
- *
- * @property {(number[][] | Parse.GeoPoint[])} coordinates list of coordinates
- * @returns {number[][]}
- */
- (0, _createClass2.default)(ParsePolygon, [{
- key: "coordinates",
- get: function ()
- /*: Array<Array<number>>*/
- {
- return this._coordinates;
- },
- set: function (coords
- /*: Array<Array<number>> | Array<ParseGeoPoint>*/
- ) {
- this._coordinates = ParsePolygon._validate(coords);
- }
- /**
- * Returns a JSON representation of the Polygon, suitable for Parse.
- *
- * @returns {object}
- */
- }, {
- key: "toJSON",
- value: function ()
- /*: { __type: string, coordinates: Array<Array<number>> }*/
- {
- ParsePolygon._validate(this._coordinates);
- return {
- __type: 'Polygon',
- coordinates: this._coordinates
- };
- }
- /**
- * Checks if two polygons are equal
- *
- * @param {(Parse.Polygon | object)} other
- * @returns {boolean}
- */
- }, {
- key: "equals",
- value: function (other
- /*: mixed*/
- )
- /*: boolean*/
- {
- if (!(other instanceof ParsePolygon) || this.coordinates.length !== other.coordinates.length) {
- return false;
- }
- var isEqual = true;
- for (var i = 1; i < this._coordinates.length; i += 1) {
- if (this._coordinates[i][0] !== other.coordinates[i][0] || this._coordinates[i][1] !== other.coordinates[i][1]) {
- isEqual = false;
- break;
- }
- }
- return isEqual;
- }
- /**
- *
- * @param {Parse.GeoPoint} point
- * @returns {boolean} Returns if the point is contained in the polygon
- */
- }, {
- key: "containsPoint",
- value: function (point
- /*: ParseGeoPoint*/
- )
- /*: boolean*/
- {
- var minX = this._coordinates[0][0];
- var maxX = this._coordinates[0][0];
- var minY = this._coordinates[0][1];
- var maxY = this._coordinates[0][1];
- for (var i = 1; i < this._coordinates.length; i += 1) {
- var p = this._coordinates[i];
- minX = Math.min(p[0], minX);
- maxX = Math.max(p[0], maxX);
- minY = Math.min(p[1], minY);
- maxY = Math.max(p[1], maxY);
- }
- var outside = point.latitude < minX || point.latitude > maxX || point.longitude < minY || point.longitude > maxY;
- if (outside) {
- return false;
- }
- var inside = false;
- for (var _i = 0, j = this._coordinates.length - 1; _i < this._coordinates.length; j = _i++) {
- var startX = this._coordinates[_i][0];
- var startY = this._coordinates[_i][1];
- var endX = this._coordinates[j][0];
- var endY = this._coordinates[j][1];
- var intersect = startY > point.longitude !== endY > point.longitude && point.latitude < (endX - startX) * (point.longitude - startY) / (endY - startY) + startX;
- if (intersect) {
- inside = !inside;
- }
- }
- return inside;
- }
- /**
- * Validates that the list of coordinates can form a valid polygon
- *
- * @param {Array} coords the list of coordinates to validate as a polygon
- * @throws {TypeError}
- * @returns {number[][]} Array of coordinates if validated.
- */
- }], [{
- key: "_validate",
- value: function (coords
- /*: Array<Array<number>> | Array<ParseGeoPoint>*/
- )
- /*: Array<Array<number>>*/
- {
- if (!(0, _isArray.default)(coords)) {
- throw new TypeError('Coordinates must be an Array');
- }
- if (coords.length < 3) {
- throw new TypeError('Polygon must have at least 3 GeoPoints or Points');
- }
- var points = [];
- for (var i = 0; i < coords.length; i += 1) {
- var coord = coords[i];
- var geoPoint = void 0;
- if (coord instanceof _ParseGeoPoint.default) {
- geoPoint = coord;
- } else if ((0, _isArray.default)(coord) && coord.length === 2) {
- geoPoint = new _ParseGeoPoint.default(coord[0], coord[1]);
- } else {
- throw new TypeError('Coordinates must be an Array of GeoPoints or Points');
- }
- points.push([geoPoint.latitude, geoPoint.longitude]);
- }
- return points;
- }
- }]);
- return ParsePolygon;
- }();
- var _default = ParsePolygon;
- exports.default = _default;
- },{"./ParseGeoPoint":33,"@babel/runtime-corejs3/core-js-stable/array/is-array":79,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/helpers/classCallCheck":145,"@babel/runtime-corejs3/helpers/createClass":147,"@babel/runtime-corejs3/helpers/defineProperty":148,"@babel/runtime-corejs3/helpers/interopRequireDefault":152}],39:[function(_dereq_,module,exports){
- "use strict";
- var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
- var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
- _Object$defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = void 0;
- var _regenerator = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/regenerator"));
- var _slicedToArray2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/slicedToArray"));
- var _toConsumableArray2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/toConsumableArray"));
- var _asyncToGenerator2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/asyncToGenerator"));
- var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
- var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
- var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
- var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
- var _forEach = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
- var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
- var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/keys"));
- var _slice = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/slice"));
- var _map2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/map"));
- var _filter2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/filter"));
- var _keys2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/keys"));
- var _concat = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/concat"));
- var _includes = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/includes"));
- var _sort = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/sort"));
- var _splice = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/splice"));
- var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
- var _find = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/find"));
- var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
- var _entries = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/entries"));
- var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
- var _encode = _interopRequireDefault(_dereq_("./encode"));
- var _promiseUtils = _dereq_("./promiseUtils");
- var _ParseError = _interopRequireDefault(_dereq_("./ParseError"));
- var _ParseGeoPoint = _interopRequireDefault(_dereq_("./ParseGeoPoint"));
- var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
- var _OfflineQuery = _interopRequireDefault(_dereq_("./OfflineQuery"));
- var _LocalDatastoreUtils = _dereq_("./LocalDatastoreUtils");
- /*
- * Copyright (c) 2015-present, Parse, LLC.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- *
- * @flow
- */
- /**
- * Converts a string into a regex that matches it.
- * Surrounding with \Q .. \E does this, we just need to escape any \E's in
- * the text separately.
- *
- * @param s
- * @private
- * @returns {string}
- */
- function quote(s
- /*: string*/
- )
- /*: string*/
- {
- return "\\Q".concat(s.replace('\\E', '\\E\\\\E\\Q'), "\\E");
- }
- /**
- * Extracts the class name from queries. If not all queries have the same
- * class name an error will be thrown.
- *
- * @param queries
- * @private
- * @returns {string}
- */
- function _getClassNameFromQueries(queries
- /*: Array<ParseQuery>*/
- )
- /*: ?string*/
- {
- var className = null;
- (0, _forEach.default)(queries).call(queries, function (q) {
- if (!className) {
- // eslint-disable-next-line prefer-destructuring
- className = q.className;
- }
- if (className !== q.className) {
- throw new Error('All queries must be for the same class.');
- }
- });
- return className;
- }
- /*
- * Handles pre-populating the result data of a query with select fields,
- * making sure that the data object contains keys for all objects that have
- * been requested with a select, so that our cached state updates correctly.
- */
- function handleSelectResult(data
- /*: any*/
- , select
- /*: Array<string>*/
- ) {
- var serverDataMask = {};
- (0, _forEach.default)(select).call(select, function (field) {
- var hasSubObjectSelect = (0, _indexOf.default)(field).call(field, '.') !== -1;
- if (!hasSubObjectSelect && !data.hasOwnProperty(field)) {
- // this field was selected, but is missing from the retrieved data
- data[field] = undefined;
- } else if (hasSubObjectSelect) {
- // this field references a sub-object,
- // so we need to walk down the path components
- var pathComponents = field.split('.');
- var _obj = data;
- var serverMask = serverDataMask;
- (0, _forEach.default)(pathComponents).call(pathComponents, function (component, index, arr) {
- // add keys if the expected data is missing
- if (_obj && !_obj.hasOwnProperty(component)) {
- _obj[component] = undefined;
- }
- if (_obj && (0, _typeof2.default)(_obj) === 'object') {
- _obj = _obj[component];
- } // add this path component to the server mask so we can fill it in later if needed
- if (index < arr.length - 1) {
- if (!serverMask[component]) {
- serverMask[component] = {};
- }
- serverMask = serverMask[component];
- }
- });
- }
- });
- if ((0, _keys.default)(serverDataMask).length > 0) {
- // When selecting from sub-objects, we don't want to blow away the missing
- // information that we may have retrieved before. We've already added any
- // missing selected keys to sub-objects, but we still need to add in the
- // data for any previously retrieved sub-objects that were not selected.
- var serverData = _CoreManager.default.getObjectStateController().getServerData({
- id: data.objectId,
- className: data.className
- });
- copyMissingDataWithMask(serverData, data, serverDataMask, false);
- }
- }
- function copyMissingDataWithMask(src, dest, mask, copyThisLevel) {
- // copy missing elements at this level
- if (copyThisLevel) {
- for (var _key in src) {
- if (src.hasOwnProperty(_key) && !dest.hasOwnProperty(_key)) {
- dest[_key] = src[_key];
- }
- }
- }
- for (var _key2 in mask) {
- if (dest[_key2] !== undefined && dest[_key2] !== null && src !== undefined && src !== null) {
- // traverse into objects as needed
- copyMissingDataWithMask(src[_key2], dest[_key2], mask[_key2], true);
- }
- }
- }
- function handleOfflineSort(a, b, sorts) {
- var order = sorts[0];
- var operator = (0, _slice.default)(order).call(order, 0, 1);
- var isDescending = operator === '-';
- if (isDescending) {
- order = order.substring(1);
- }
- if (order === '_created_at') {
- order = 'createdAt';
- }
- if (order === '_updated_at') {
- order = 'updatedAt';
- }
- if (!/^[A-Za-z][0-9A-Za-z_]*$/.test(order) || order === 'password') {
- throw new _ParseError.default(_ParseError.default.INVALID_KEY_NAME, "Invalid Key: ".concat(order));
- }
- var field1 = a.get(order);
- var field2 = b.get(order);
- if (field1 < field2) {
- return isDescending ? 1 : -1;
- }
- if (field1 > field2) {
- return isDescending ? -1 : 1;
- }
- if (sorts.length > 1) {
- var remainingSorts = (0, _slice.default)(sorts).call(sorts, 1);
- return handleOfflineSort(a, b, remainingSorts);
- }
- return 0;
- }
- /**
- * Creates a new parse Parse.Query for the given Parse.Object subclass.
- *
- * <p>Parse.Query defines a query that is used to fetch Parse.Objects. The
- * most common use case is finding all objects that match a query through the
- * <code>find</code> method. for example, this sample code fetches all objects
- * of class <code>myclass</code>. it calls a different function depending on
- * whether the fetch succeeded or not.
- *
- * <pre>
- * var query = new Parse.Query(myclass);
- * query.find().then((results) => {
- * // results is an array of parse.object.
- * }).catch((error) => {
- * // error is an instance of parse.error.
- * });</pre></p>
- *
- * <p>a Parse.Query can also be used to retrieve a single object whose id is
- * known, through the get method. for example, this sample code fetches an
- * object of class <code>myclass</code> and id <code>myid</code>. it calls a
- * different function depending on whether the fetch succeeded or not.
- *
- * <pre>
- * var query = new Parse.Query(myclass);
- * query.get(myid).then((object) => {
- * // object is an instance of parse.object.
- * }).catch((error) => {
- * // error is an instance of parse.error.
- * });</pre></p>
- *
- * <p>a Parse.Query can also be used to count the number of objects that match
- * the query without retrieving all of those objects. for example, this
- * sample code counts the number of objects of the class <code>myclass</code>
- * <pre>
- * var query = new Parse.Query(myclass);
- * query.count().then((number) => {
- * // there are number instances of myclass.
- * }).catch((error) => {
- * // error is an instance of Parse.Error.
- * });</pre></p>
- *
- * @alias Parse.Query
- */
- var ParseQuery = /*#__PURE__*/function () {
- /**
- * @property {string} className
- */
- /**
- * @param {(string | Parse.Object)} objectClass An instance of a subclass of Parse.Object, or a Parse className string.
- */
- function ParseQuery(objectClass
- /*: string | ParseObject*/
- ) {
- (0, _classCallCheck2.default)(this, ParseQuery);
- (0, _defineProperty2.default)(this, "className", void 0);
- (0, _defineProperty2.default)(this, "_where", void 0);
- (0, _defineProperty2.default)(this, "_include", void 0);
- (0, _defineProperty2.default)(this, "_exclude", void 0);
- (0, _defineProperty2.default)(this, "_select", void 0);
- (0, _defineProperty2.default)(this, "_limit", void 0);
- (0, _defineProperty2.default)(this, "_skip", void 0);
- (0, _defineProperty2.default)(this, "_count", void 0);
- (0, _defineProperty2.default)(this, "_order", void 0);
- (0, _defineProperty2.default)(this, "_readPreference", void 0);
- (0, _defineProperty2.default)(this, "_includeReadPreference", void 0);
- (0, _defineProperty2.default)(this, "_subqueryReadPreference", void 0);
- (0, _defineProperty2.default)(this, "_queriesLocalDatastore", void 0);
- (0, _defineProperty2.default)(this, "_localDatastorePinName", void 0);
- (0, _defineProperty2.default)(this, "_extraOptions", void 0);
- (0, _defineProperty2.default)(this, "_hint", void 0);
- (0, _defineProperty2.default)(this, "_explain", void 0);
- (0, _defineProperty2.default)(this, "_xhrRequest", void 0);
- if (typeof objectClass === 'string') {
- if (objectClass === 'User' && _CoreManager.default.get('PERFORM_USER_REWRITE')) {
- this.className = '_User';
- } else {
- this.className = objectClass;
- }
- } else if (objectClass instanceof _ParseObject.default) {
- this.className = objectClass.className;
- } else if (typeof objectClass === 'function') {
- if (typeof objectClass.className === 'string') {
- this.className = objectClass.className;
- } else {
- var _obj2 = new objectClass();
- this.className = _obj2.className;
- }
- } else {
- throw new TypeError('A ParseQuery must be constructed with a ParseObject or class name.');
- }
- this._where = {};
- this._include = [];
- this._exclude = [];
- this._count = false; // negative limit is not sent in the server request
- this._limit = -1;
- this._skip = 0;
- this._readPreference = null;
- this._includeReadPreference = null;
- this._subqueryReadPreference = null;
- this._queriesLocalDatastore = false;
- this._localDatastorePinName = null;
- this._extraOptions = {};
- this._xhrRequest = {
- task: null,
- onchange: function () {}
- };
- }
- /**
- * Adds constraint that at least one of the passed in queries matches.
- *
- * @param {Array} queries
- * @returns {Parse.Query} Returns the query, so you can chain this call.
- */
- (0, _createClass2.default)(ParseQuery, [{
- key: "_orQuery",
- value: function (queries
- /*: Array<ParseQuery>*/
- )
- /*: ParseQuery*/
- {
- var queryJSON = (0, _map2.default)(queries).call(queries, function (q) {
- return q.toJSON().where;
- });
- this._where.$or = queryJSON;
- return this;
- }
- /**
- * Adds constraint that all of the passed in queries match.
- *
- * @param {Array} queries
- * @returns {Parse.Query} Returns the query, so you can chain this call.
- */
- }, {
- key: "_andQuery",
- value: function (queries
- /*: Array<ParseQuery>*/
- )
- /*: ParseQuery*/
- {
- var queryJSON = (0, _map2.default)(queries).call(queries, function (q) {
- return q.toJSON().where;
- });
- this._where.$and = queryJSON;
- return this;
- }
- /**
- * Adds constraint that none of the passed in queries match.
- *
- * @param {Array} queries
- * @returns {Parse.Query} Returns the query, so you can chain this call.
- */
- }, {
- key: "_norQuery",
- value: function (queries
- /*: Array<ParseQuery>*/
- )
- /*: ParseQuery*/
- {
- var queryJSON = (0, _map2.default)(queries).call(queries, function (q) {
- return q.toJSON().where;
- });
- this._where.$nor = queryJSON;
- return this;
- }
- /**
- * Helper for condition queries
- *
- * @param key
- * @param condition
- * @param value
- * @returns {Parse.Query}
- */
- }, {
- key: "_addCondition",
- value: function (key
- /*: string*/
- , condition
- /*: string*/
- , value
- /*: mixed*/
- )
- /*: ParseQuery*/
- {
- if (!this._where[key] || typeof this._where[key] === 'string') {
- this._where[key] = {};
- }
- this._where[key][condition] = (0, _encode.default)(value, false, true);
- return this;
- }
- /**
- * Converts string for regular expression at the beginning
- *
- * @param string
- * @returns {string}
- */
- }, {
- key: "_regexStartWith",
- value: function (string
- /*: string*/
- )
- /*: string*/
- {
- return "^".concat(quote(string));
- }
- }, {
- key: "_handleOfflineQuery",
- value: function () {
- var _handleOfflineQuery2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(params
- /*: any*/
- ) {
- var _context,
- _this2 = this;
- var localDatastore, objects, results, keys, alwaysSelectedKeys, sorts, count, limit;
- return _regenerator.default.wrap(function (_context3) {
- while (1) {
- switch (_context3.prev = _context3.next) {
- case 0:
- _OfflineQuery.default.validateQuery(this);
- localDatastore = _CoreManager.default.getLocalDatastore();
- _context3.next = 4;
- return localDatastore._serializeObjectsFromPinName(this._localDatastorePinName);
- case 4:
- objects = _context3.sent;
- results = (0, _filter2.default)(_context = (0, _map2.default)(objects).call(objects, function (json, index, arr) {
- var object = _ParseObject.default.fromJSON(json, false);
- if (json._localId && !json.objectId) {
- object._localId = json._localId;
- }
- if (!_OfflineQuery.default.matchesQuery(_this2.className, object, arr, _this2)) {
- return null;
- }
- return object;
- })).call(_context, function (object) {
- return object !== null;
- });
- if ((0, _keys2.default)(params)) {
- keys = (0, _keys2.default)(params).split(',');
- alwaysSelectedKeys = ['className', 'objectId', 'createdAt', 'updatedAt', 'ACL'];
- keys = (0, _concat.default)(keys).call(keys, alwaysSelectedKeys);
- results = (0, _map2.default)(results).call(results, function (object) {
- var _context2;
- var json = object._toFullJSON();
- (0, _forEach.default)(_context2 = (0, _keys.default)(json)).call(_context2, function (key) {
- if (!(0, _includes.default)(keys).call(keys, key)) {
- delete json[key];
- }
- });
- return _ParseObject.default.fromJSON(json, false);
- });
- }
- if (params.order) {
- sorts = params.order.split(',');
- (0, _sort.default)(results).call(results, function (a, b) {
- return handleOfflineSort(a, b, sorts);
- });
- } // count total before applying limit/skip
- if (params.count) {
- // total count from response
- count = results.length;
- }
- if (params.skip) {
- if (params.skip >= results.length) {
- results = [];
- } else {
- results = (0, _splice.default)(results).call(results, params.skip, results.length);
- }
- }
- limit = results.length;
- if (params.limit !== 0 && params.limit < results.length) {
- // eslint-disable-next-line prefer-destructuring
- limit = params.limit;
- }
- results = (0, _splice.default)(results).call(results, 0, limit);
- if (!(typeof count === 'number')) {
- _context3.next = 15;
- break;
- }
- return _context3.abrupt("return", {
- results: results,
- count: count
- });
- case 15:
- return _context3.abrupt("return", results);
- case 16:
- case "end":
- return _context3.stop();
- }
- }
- }, _callee, this);
- }));
- return function () {
- return _handleOfflineQuery2.apply(this, arguments);
- };
- }()
- /**
- * Returns a JSON representation of this query.
- *
- * @returns {object} The JSON representation of the query.
- */
- }, {
- key: "toJSON",
- value: function ()
- /*: QueryJSON*/
- {
- var params
- /*: QueryJSON*/
- = {
- where: this._where
- };
- if (this._include.length) {
- params.include = this._include.join(',');
- }
- if (this._exclude.length) {
- params.excludeKeys = this._exclude.join(',');
- }
- if (this._select) {
- params.keys = this._select.join(',');
- }
- if (this._count) {
- params.count = 1;
- }
- if (this._limit >= 0) {
- params.limit = this._limit;
- }
- if (this._skip > 0) {
- params.skip = this._skip;
- }
- if (this._order) {
- params.order = this._order.join(',');
- }
- if (this._readPreference) {
- params.readPreference = this._readPreference;
- }
- if (this._includeReadPreference) {
- params.includeReadPreference = this._includeReadPreference;
- }
- if (this._subqueryReadPreference) {
- params.subqueryReadPreference = this._subqueryReadPreference;
- }
- if (this._hint) {
- params.hint = this._hint;
- }
- if (this._explain) {
- params.explain = true;
- }
- for (var _key3 in this._extraOptions) {
- params[_key3] = this._extraOptions[_key3];
- }
- return params;
- }
- /**
- * Return a query with conditions from json, can be useful to send query from server side to client
- * Not static, all query conditions was set before calling this method will be deleted.
- * For example on the server side we have
- * var query = new Parse.Query("className");
- * query.equalTo(key: value);
- * query.limit(100);
- * ... (others queries)
- * Create JSON representation of Query Object
- * var jsonFromServer = query.fromJSON();
- *
- * On client side getting query:
- * var query = new Parse.Query("className");
- * query.fromJSON(jsonFromServer);
- *
- * and continue to query...
- * query.skip(100).find().then(...);
- *
- * @param {QueryJSON} json from Parse.Query.toJSON() method
- * @returns {Parse.Query} Returns the query, so you can chain this call.
- */
- }, {
- key: "withJSON",
- value: function (json
- /*: QueryJSON*/
- )
- /*: ParseQuery*/
- {
- if (json.where) {
- this._where = json.where;
- }
- if (json.include) {
- this._include = json.include.split(',');
- }
- if ((0, _keys2.default)(json)) {
- this._select = (0, _keys2.default)(json).split(',');
- }
- if (json.excludeKeys) {
- this._exclude = json.excludeKeys.split(',');
- }
- if (json.count) {
- this._count = json.count === 1;
- }
- if (json.limit) {
- this._limit = json.limit;
- }
- if (json.skip) {
- this._skip = json.skip;
- }
- if (json.order) {
- this._order = json.order.split(',');
- }
- if (json.readPreference) {
- this._readPreference = json.readPreference;
- }
- if (json.includeReadPreference) {
- this._includeReadPreference = json.includeReadPreference;
- }
- if (json.subqueryReadPreference) {
- this._subqueryReadPreference = json.subqueryReadPreference;
- }
- if (json.hint) {
- this._hint = json.hint;
- }
- if (json.explain) {
- this._explain = !!json.explain;
- }
- for (var _key4 in json) {
- if (json.hasOwnProperty(_key4)) {
- var _context4;
- if ((0, _indexOf.default)(_context4 = ['where', 'include', 'keys', 'count', 'limit', 'skip', 'order', 'readPreference', 'includeReadPreference', 'subqueryReadPreference', 'hint', 'explain']).call(_context4, _key4) === -1) {
- this._extraOptions[_key4] = json[_key4];
- }
- }
- }
- return this;
- }
- /**
- * Static method to restore Parse.Query by json representation
- * Internally calling Parse.Query.withJSON
- *
- * @param {string} className
- * @param {QueryJSON} json from Parse.Query.toJSON() method
- * @returns {Parse.Query} new created query
- */
- }, {
- key: "get",
- value:
- /**
- * Constructs a Parse.Object whose id is already known by fetching data from
- * the server. Unlike the <code>first</code> method, it never returns undefined.
- *
- * @param {string} objectId The id of the object to be fetched.
- * @param {object} options
- * Valid options are:<ul>
- * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
- * be used for this request.
- * <li>sessionToken: A valid session token, used for making a request on
- * behalf of a specific user.
- * <li>context: A dictionary that is accessible in Cloud Code `beforeFind` trigger.
- * </ul>
- *
- * @returns {Promise} A promise that is resolved with the result when
- * the query completes.
- */
- function (objectId
- /*: string*/
- , options
- /*:: ?: FullOptions*/
- )
- /*: Promise<ParseObject>*/
- {
- this.equalTo('objectId', objectId);
- var firstOptions = {};
- if (options && options.hasOwnProperty('useMasterKey')) {
- firstOptions.useMasterKey = options.useMasterKey;
- }
- if (options && options.hasOwnProperty('sessionToken')) {
- firstOptions.sessionToken = options.sessionToken;
- }
- if (options && options.hasOwnProperty('context') && (0, _typeof2.default)(options.context) === 'object') {
- firstOptions.context = options.context;
- }
- return this.first(firstOptions).then(function (response) {
- if (response) {
- return response;
- }
- var errorObject = new _ParseError.default(_ParseError.default.OBJECT_NOT_FOUND, 'Object not found.');
- return _promise.default.reject(errorObject);
- });
- }
- /**
- * Retrieves a list of ParseObjects that satisfy this query.
- *
- * @param {object} options Valid options
- * are:<ul>
- * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
- * be used for this request.
- * <li>sessionToken: A valid session token, used for making a request on
- * behalf of a specific user.
- * <li>context: A dictionary that is accessible in Cloud Code `beforeFind` trigger.
- * </ul>
- *
- * @returns {Promise} A promise that is resolved with the results when
- * the query completes.
- */
- }, {
- key: "find",
- value: function (options
- /*:: ?: FullOptions*/
- )
- /*: Promise<Array<ParseObject>>*/
- {
- var _this3 = this;
- options = options || {};
- var findOptions = {};
- if (options.hasOwnProperty('useMasterKey')) {
- findOptions.useMasterKey = options.useMasterKey;
- }
- if (options.hasOwnProperty('sessionToken')) {
- findOptions.sessionToken = options.sessionToken;
- }
- if (options.hasOwnProperty('context') && (0, _typeof2.default)(options.context) === 'object') {
- findOptions.context = options.context;
- }
- this._setRequestTask(findOptions);
- var controller = _CoreManager.default.getQueryController();
- var select = this._select;
- if (this._queriesLocalDatastore) {
- return this._handleOfflineQuery(this.toJSON());
- }
- return (0, _find.default)(controller).call(controller, this.className, this.toJSON(), findOptions).then(function (response) {
- var _context5; // Return generic object when explain is used
- if (_this3._explain) {
- return response.results;
- }
- var results = (0, _map2.default)(_context5 = response.results).call(_context5, function (data) {
- // In cases of relations, the server may send back a className
- // on the top level of the payload
- var override = response.className || _this3.className;
- if (!data.className) {
- data.className = override;
- } // Make sure the data object contains keys for all objects that
- // have been requested with a select, so that our cached state
- // updates correctly.
- if (select) {
- handleSelectResult(data, select);
- }
- return _ParseObject.default.fromJSON(data, !select);
- });
- var count = response.count;
- if (typeof count === 'number') {
- return {
- results: results,
- count: count
- };
- }
- return results;
- });
- }
- /**
- * Retrieves a complete list of ParseObjects that satisfy this query.
- * Using `eachBatch` under the hood to fetch all the valid objects.
- *
- * @param {object} options Valid options are:<ul>
- * <li>batchSize: How many objects to yield in each batch (default: 100)
- * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
- * be used for this request.
- * <li>sessionToken: A valid session token, used for making a request on
- * behalf of a specific user.
- * </ul>
- * @returns {Promise} A promise that is resolved with the results when
- * the query completes.
- */
- }, {
- key: "findAll",
- value: function () {
- var _findAll = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(options
- /*:: ?: BatchOptions*/
- ) {
- var result;
- return _regenerator.default.wrap(function (_context7) {
- while (1) {
- switch (_context7.prev = _context7.next) {
- case 0:
- result
- /*: ParseObject[]*/
- = [];
- _context7.next = 3;
- return this.eachBatch(function (objects
- /*: ParseObject[]*/
- ) {
- var _context6;
- result = (0, _concat.default)(_context6 = []).call(_context6, (0, _toConsumableArray2.default)(result), (0, _toConsumableArray2.default)(objects));
- }, options);
- case 3:
- return _context7.abrupt("return", result);
- case 4:
- case "end":
- return _context7.stop();
- }
- }
- }, _callee2, this);
- }));
- return function () {
- return _findAll.apply(this, arguments);
- };
- }()
- /**
- * Counts the number of objects that match this query.
- *
- * @param {object} options
- * Valid options are:<ul>
- * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
- * be used for this request.
- * <li>sessionToken: A valid session token, used for making a request on
- * behalf of a specific user.
- * </ul>
- *
- * @returns {Promise} A promise that is resolved with the count when
- * the query completes.
- */
- }, {
- key: "count",
- value: function (options
- /*:: ?: FullOptions*/
- )
- /*: Promise<number>*/
- {
- options = options || {};
- var findOptions = {};
- if (options.hasOwnProperty('useMasterKey')) {
- findOptions.useMasterKey = options.useMasterKey;
- }
- if (options.hasOwnProperty('sessionToken')) {
- findOptions.sessionToken = options.sessionToken;
- }
- this._setRequestTask(findOptions);
- var controller = _CoreManager.default.getQueryController();
- var params = this.toJSON();
- params.limit = 0;
- params.count = 1;
- return (0, _find.default)(controller).call(controller, this.className, params, findOptions).then(function (result) {
- return result.count;
- });
- }
- /**
- * Executes a distinct query and returns unique values
- *
- * @param {string} key A field to find distinct values
- * @param {object} options
- * Valid options are:<ul>
- * <li>sessionToken: A valid session token, used for making a request on
- * behalf of a specific user.
- * </ul>
- *
- * @returns {Promise} A promise that is resolved with the query completes.
- */
- }, {
- key: "distinct",
- value: function (key
- /*: string*/
- , options
- /*:: ?: FullOptions*/
- )
- /*: Promise<Array<mixed>>*/
- {
- options = options || {};
- var distinctOptions = {};
- distinctOptions.useMasterKey = true;
- if (options.hasOwnProperty('sessionToken')) {
- distinctOptions.sessionToken = options.sessionToken;
- }
- this._setRequestTask(distinctOptions);
- var controller = _CoreManager.default.getQueryController();
- var params = {
- distinct: key,
- where: this._where,
- hint: this._hint
- };
- return controller.aggregate(this.className, params, distinctOptions).then(function (results) {
- return results.results;
- });
- }
- /**
- * Executes an aggregate query and returns aggregate results
- *
- * @param {(Array|object)} pipeline Array or Object of stages to process query
- * @param {object} options Valid options are:<ul>
- * <li>sessionToken: A valid session token, used for making a request on
- * behalf of a specific user.
- * </ul>
- *
- * @returns {Promise} A promise that is resolved with the query completes.
- */
- }, {
- key: "aggregate",
- value: function (pipeline
- /*: mixed*/
- , options
- /*:: ?: FullOptions*/
- )
- /*: Promise<Array<mixed>>*/
- {
- options = options || {};
- var aggregateOptions = {};
- aggregateOptions.useMasterKey = true;
- if (options.hasOwnProperty('sessionToken')) {
- aggregateOptions.sessionToken = options.sessionToken;
- }
- this._setRequestTask(aggregateOptions);
- var controller = _CoreManager.default.getQueryController();
- if (!(0, _isArray.default)(pipeline) && (0, _typeof2.default)(pipeline) !== 'object') {
- throw new Error('Invalid pipeline must be Array or Object');
- }
- if ((0, _keys.default)(this._where || {}).length) {
- if (!(0, _isArray.default)(pipeline)) {
- pipeline = [pipeline];
- }
- pipeline.unshift({
- match: this._where
- });
- }
- var params = {
- pipeline: pipeline,
- hint: this._hint,
- explain: this._explain,
- readPreference: this._readPreference
- };
- return controller.aggregate(this.className, params, aggregateOptions).then(function (results) {
- return results.results;
- });
- }
- /**
- * Retrieves at most one Parse.Object that satisfies this query.
- *
- * Returns the object if there is one, otherwise undefined.
- *
- * @param {object} options Valid options are:<ul>
- * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
- * be used for this request.
- * <li>sessionToken: A valid session token, used for making a request on
- * behalf of a specific user.
- * <li>context: A dictionary that is accessible in Cloud Code `beforeFind` trigger.
- * </ul>
- *
- * @returns {Promise} A promise that is resolved with the object when
- * the query completes.
- */
- }, {
- key: "first",
- value: function (options
- /*:: ?: FullOptions*/
- )
- /*: Promise<ParseObject | void>*/
- {
- var _this4 = this;
- options = options || {};
- var findOptions = {};
- if (options.hasOwnProperty('useMasterKey')) {
- findOptions.useMasterKey = options.useMasterKey;
- }
- if (options.hasOwnProperty('sessionToken')) {
- findOptions.sessionToken = options.sessionToken;
- }
- if (options.hasOwnProperty('context') && (0, _typeof2.default)(options.context) === 'object') {
- findOptions.context = options.context;
- }
- this._setRequestTask(findOptions);
- var controller = _CoreManager.default.getQueryController();
- var params = this.toJSON();
- params.limit = 1;
- var select = this._select;
- if (this._queriesLocalDatastore) {
- return this._handleOfflineQuery(params).then(function (objects) {
- if (!objects[0]) {
- return undefined;
- }
- return objects[0];
- });
- }
- return (0, _find.default)(controller).call(controller, this.className, params, findOptions).then(function (response) {
- var objects = response.results;
- if (!objects[0]) {
- return undefined;
- }
- if (!objects[0].className) {
- objects[0].className = _this4.className;
- } // Make sure the data object contains keys for all objects that
- // have been requested with a select, so that our cached state
- // updates correctly.
- if (select) {
- handleSelectResult(objects[0], select);
- }
- return _ParseObject.default.fromJSON(objects[0], !select);
- });
- }
- /**
- * Iterates over objects matching a query, calling a callback for each batch.
- * If the callback returns a promise, the iteration will not continue until
- * that promise has been fulfilled. If the callback returns a rejected
- * promise, then iteration will stop with that error. The items are processed
- * in an unspecified order. The query may not have any sort order, and may
- * not use limit or skip.
- *
- * @param {Function} callback Callback that will be called with each result
- * of the query.
- * @param {object} options Valid options are:<ul>
- * <li>batchSize: How many objects to yield in each batch (default: 100)
- * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
- * be used for this request.
- * <li>sessionToken: A valid session token, used for making a request on
- * behalf of a specific user.
- * <li>context: A dictionary that is accessible in Cloud Code `beforeFind` trigger.
- * </ul>
- * @returns {Promise} A promise that will be fulfilled once the
- * iteration has completed.
- */
- }, {
- key: "eachBatch",
- value: function (callback
- /*: (objs: Array<ParseObject>) => Promise<*>*/
- , options
- /*:: ?: BatchOptions*/
- )
- /*: Promise<void>*/
- {
- var _context8;
- options = options || {};
- if (this._order || this._skip || this._limit >= 0) {
- return _promise.default.reject('Cannot iterate on a query with sort, skip, or limit.');
- }
- var query = new ParseQuery(this.className);
- query._limit = options.batchSize || 100;
- query._include = (0, _map2.default)(_context8 = this._include).call(_context8, function (i) {
- return i;
- });
- if (this._select) {
- var _context9;
- query._select = (0, _map2.default)(_context9 = this._select).call(_context9, function (s) {
- return s;
- });
- }
- query._hint = this._hint;
- query._where = {};
- for (var _attr in this._where) {
- var val = this._where[_attr];
- if ((0, _isArray.default)(val)) {
- query._where[_attr] = (0, _map2.default)(val).call(val, function (v) {
- return v;
- });
- } else if (val && (0, _typeof2.default)(val) === 'object') {
- var conditionMap = {};
- query._where[_attr] = conditionMap;
- for (var cond in val) {
- conditionMap[cond] = val[cond];
- }
- } else {
- query._where[_attr] = val;
- }
- }
- query.ascending('objectId');
- var findOptions = {};
- if (options.hasOwnProperty('useMasterKey')) {
- findOptions.useMasterKey = options.useMasterKey;
- }
- if (options.hasOwnProperty('sessionToken')) {
- findOptions.sessionToken = options.sessionToken;
- }
- if (options.hasOwnProperty('context') && (0, _typeof2.default)(options.context) === 'object') {
- findOptions.context = options.context;
- }
- var finished = false;
- var previousResults = [];
- return (0, _promiseUtils.continueWhile)(function () {
- return !finished;
- }, /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
- var _yield$Promise$all, _yield$Promise$all2, results;
- return _regenerator.default.wrap(function (_context10) {
- while (1) {
- switch (_context10.prev = _context10.next) {
- case 0:
- _context10.next = 2;
- return _promise.default.all([(0, _find.default)(query).call(query, findOptions), _promise.default.resolve(previousResults.length > 0 && callback(previousResults))]);
- case 2:
- _yield$Promise$all = _context10.sent;
- _yield$Promise$all2 = (0, _slicedToArray2.default)(_yield$Promise$all, 1);
- results = _yield$Promise$all2[0];
- if (!(results.length >= query._limit)) {
- _context10.next = 10;
- break;
- }
- query.greaterThan('objectId', results[results.length - 1].id);
- previousResults = results;
- _context10.next = 17;
- break;
- case 10:
- if (!(results.length > 0)) {
- _context10.next = 16;
- break;
- }
- _context10.next = 13;
- return _promise.default.resolve(callback(results));
- case 13:
- finished = true;
- _context10.next = 17;
- break;
- case 16:
- finished = true;
- case 17:
- case "end":
- return _context10.stop();
- }
- }
- }, _callee3);
- })));
- }
- /**
- * Iterates over each result of a query, calling a callback for each one. If
- * the callback returns a promise, the iteration will not continue until
- * that promise has been fulfilled. If the callback returns a rejected
- * promise, then iteration will stop with that error. The items are
- * processed in an unspecified order. The query may not have any sort order,
- * and may not use limit or skip.
- *
- * @param {Function} callback Callback that will be called with each result
- * of the query.
- * @param {object} options Valid options are:<ul>
- * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
- * be used for this request.
- * <li>sessionToken: A valid session token, used for making a request on
- * behalf of a specific user.
- * </ul>
- * @returns {Promise} A promise that will be fulfilled once the
- * iteration has completed.
- */
- }, {
- key: "each",
- value: function (callback
- /*: (obj: ParseObject) => any*/
- , options
- /*:: ?: BatchOptions*/
- )
- /*: Promise<void>*/
- {
- return this.eachBatch(function (results) {
- var callbacksDone = _promise.default.resolve();
- (0, _forEach.default)(results).call(results, function (result) {
- callbacksDone = callbacksDone.then(function () {
- return callback(result);
- });
- });
- return callbacksDone;
- }, options);
- }
- /**
- * Adds a hint to force index selection. (https://docs.mongodb.com/manual/reference/operator/meta/hint/)
- *
- * @param {(string|object)} value String or Object of index that should be used when executing query
- * @returns {Parse.Query} Returns the query, so you can chain this call.
- */
- }, {
- key: "hint",
- value: function (value
- /*: mixed*/
- )
- /*: ParseQuery*/
- {
- if (typeof value === 'undefined') {
- delete this._hint;
- }
- this._hint = value;
- return this;
- }
- /**
- * Investigates the query execution plan. Useful for optimizing queries. (https://docs.mongodb.com/manual/reference/operator/meta/explain/)
- *
- * @param {boolean} explain Used to toggle the information on the query plan.
- * @returns {Parse.Query} Returns the query, so you can chain this call.
- */
- }, {
- key: "explain",
- value: function ()
- /*: ParseQuery*/
- {
- var _explain
- /*: boolean*/
- = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
- if (typeof _explain !== 'boolean') {
- throw new Error('You can only set explain to a boolean value');
- }
- this._explain = _explain;
- return this;
- }
- /**
- * Iterates over each result of a query, calling a callback for each one. If
- * the callback returns a promise, the iteration will not continue until
- * that promise has been fulfilled. If the callback returns a rejected
- * promise, then iteration will stop with that error. The items are
- * processed in an unspecified order. The query may not have any sort order,
- * and may not use limit or skip.
- *
- * @param {Function} callback Callback <ul>
- * <li>currentObject: The current Parse.Object being processed in the array.</li>
- * <li>index: The index of the current Parse.Object being processed in the array.</li>
- * <li>query: The query map was called upon.</li>
- * </ul>
- *
- * @param {object} options Valid options are:<ul>
- * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
- * be used for this request.
- * <li>sessionToken: A valid session token, used for making a request on
- * behalf of a specific user.
- * </ul>
- * @returns {Promise} A promise that will be fulfilled once the
- * iteration has completed.
- */
- }, {
- key: "map",
- value: function () {
- var _map = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(callback
- /*: (currentObject: ParseObject, index: number, query: ParseQuery) => any*/
- , options
- /*:: ?: BatchOptions*/
- ) {
- var _this5 = this;
- var array, index;
- return _regenerator.default.wrap(function (_context11) {
- while (1) {
- switch (_context11.prev = _context11.next) {
- case 0:
- array = [];
- index = 0;
- _context11.next = 4;
- return this.each(function (object) {
- return _promise.default.resolve(callback(object, index, _this5)).then(function (result) {
- array.push(result);
- index += 1;
- });
- }, options);
- case 4:
- return _context11.abrupt("return", array);
- case 5:
- case "end":
- return _context11.stop();
- }
- }
- }, _callee4, this);
- }));
- return function () {
- return _map.apply(this, arguments);
- };
- }()
- /**
- * Iterates over each result of a query, calling a callback for each one. If
- * the callback returns a promise, the iteration will not continue until
- * that promise has been fulfilled. If the callback returns a rejected
- * promise, then iteration will stop with that error. The items are
- * processed in an unspecified order. The query may not have any sort order,
- * and may not use limit or skip.
- *
- * @param {Function} callback Callback <ul>
- * <li>accumulator: The accumulator accumulates the callback's return values. It is the accumulated value previously returned in the last invocation of the callback.</li>
- * <li>currentObject: The current Parse.Object being processed in the array.</li>
- * <li>index: The index of the current Parse.Object being processed in the array.</li>
- * </ul>
- * @param {*} initialValue A value to use as the first argument to the first call of the callback. If no initialValue is supplied, the first object in the query will be used and skipped.
- * @param {object} options Valid options are:<ul>
- * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
- * be used for this request.
- * <li>sessionToken: A valid session token, used for making a request on
- * behalf of a specific user.
- * </ul>
- * @returns {Promise} A promise that will be fulfilled once the
- * iteration has completed.
- */
- }, {
- key: "reduce",
- value: function () {
- var _reduce = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(callback
- /*: (accumulator: any, currentObject: ParseObject, index: number) => any*/
- , initialValue
- /*: any*/
- , options
- /*:: ?: BatchOptions*/
- ) {
- var accumulator, index;
- return _regenerator.default.wrap(function (_context12) {
- while (1) {
- switch (_context12.prev = _context12.next) {
- case 0:
- accumulator = initialValue;
- index = 0;
- _context12.next = 4;
- return this.each(function (object) {
- // If no initial value was given, we take the first object from the query
- // as the initial value and don't call the callback with it.
- if (index === 0 && initialValue === undefined) {
- accumulator = object;
- index += 1;
- return;
- }
- return _promise.default.resolve(callback(accumulator, object, index)).then(function (result) {
- accumulator = result;
- index += 1;
- });
- }, options);
- case 4:
- if (!(index === 0 && initialValue === undefined)) {
- _context12.next = 6;
- break;
- }
- throw new TypeError('Reducing empty query result set with no initial value');
- case 6:
- return _context12.abrupt("return", accumulator);
- case 7:
- case "end":
- return _context12.stop();
- }
- }
- }, _callee5, this);
- }));
- return function () {
- return _reduce.apply(this, arguments);
- };
- }()
- /**
- * Iterates over each result of a query, calling a callback for each one. If
- * the callback returns a promise, the iteration will not continue until
- * that promise has been fulfilled. If the callback returns a rejected
- * promise, then iteration will stop with that error. The items are
- * processed in an unspecified order. The query may not have any sort order,
- * and may not use limit or skip.
- *
- * @param {Function} callback Callback <ul>
- * <li>currentObject: The current Parse.Object being processed in the array.</li>
- * <li>index: The index of the current Parse.Object being processed in the array.</li>
- * <li>query: The query filter was called upon.</li>
- * </ul>
- *
- * @param {object} options Valid options are:<ul>
- * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
- * be used for this request.
- * <li>sessionToken: A valid session token, used for making a request on
- * behalf of a specific user.
- * </ul>
- * @returns {Promise} A promise that will be fulfilled once the
- * iteration has completed.
- */
- }, {
- key: "filter",
- value: function () {
- var _filter = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6(callback
- /*: (currentObject: ParseObject, index: number, query: ParseQuery) => boolean*/
- , options
- /*:: ?: BatchOptions*/
- ) {
- var _this6 = this;
- var array, index;
- return _regenerator.default.wrap(function (_context13) {
- while (1) {
- switch (_context13.prev = _context13.next) {
- case 0:
- array = [];
- index = 0;
- _context13.next = 4;
- return this.each(function (object) {
- return _promise.default.resolve(callback(object, index, _this6)).then(function (flag) {
- if (flag) {
- array.push(object);
- }
- index += 1;
- });
- }, options);
- case 4:
- return _context13.abrupt("return", array);
- case 5:
- case "end":
- return _context13.stop();
- }
- }
- }, _callee6, this);
- }));
- return function () {
- return _filter.apply(this, arguments);
- };
- }()
- /** Query Conditions * */
- /**
- * Adds a constraint to the query that requires a particular key's value to
- * be equal to the provided value.
- *
- * @param {string} key The key to check.
- * @param value The value that the Parse.Object must contain.
- * @returns {Parse.Query} Returns the query, so you can chain this call.
- */
- }, {
- key: "equalTo",
- value: function (key
- /*: string | { [key: string]: any }*/
- , value
- /*: ?mixed*/
- )
- /*: ParseQuery*/
- {
- var _this7 = this;
- if (key && (0, _typeof2.default)(key) === 'object') {
- var _context14;
- (0, _forEach.default)(_context14 = (0, _entries.default)(key)).call(_context14, function (_ref2) {
- var _ref3 = (0, _slicedToArray2.default)(_ref2, 2),
- k = _ref3[0],
- val = _ref3[1];
- return _this7.equalTo(k, val);
- });
- return this;
- }
- if (typeof value === 'undefined') {
- return this.doesNotExist(key);
- }
- this._where[key] = (0, _encode.default)(value, false, true);
- return this;
- }
- /**
- * Adds a constraint to the query that requires a particular key's value to
- * be not equal to the provided value.
- *
- * @param {string} key The key to check.
- * @param value The value that must not be equalled.
- * @returns {Parse.Query} Returns the query, so you can chain this call.
- */
- }, {
- key: "notEqualTo",
- value: function (key
- /*: string | { [key: string]: any }*/
- , value
- /*: ?mixed*/
- )
- /*: ParseQuery*/
- {
- var _this8 = this;
- if (key && (0, _typeof2.default)(key) === 'object') {
- var _context15;
- (0, _forEach.default)(_context15 = (0, _entries.default)(key)).call(_context15, function (_ref4) {
- var _ref5 = (0, _slicedToArray2.default)(_ref4, 2),
- k = _ref5[0],
- val = _ref5[1];
- return _this8.notEqualTo(k, val);
- });
- return this;
- }
- return this._addCondition(key, '$ne', value);
- }
- /**
- * Adds a constraint to the query that requires a particular key's value to
- * be less than the provided value.
- *
- * @param {string} key The key to check.
- * @param value The value that provides an upper bound.
- * @returns {Parse.Query} Returns the query, so you can chain this call.
- */
- }, {
- key: "lessThan",
- value: function (key
- /*: string*/
- , value
- /*: mixed*/
- )
- /*: ParseQuery*/
- {
- return this._addCondition(key, '$lt', value);
- }
- /**
- * Adds a constraint to the query that requires a particular key's value to
- * be greater than the provided value.
- *
- * @param {string} key The key to check.
- * @param value The value that provides an lower bound.
- * @returns {Parse.Query} Returns the query, so you can chain this call.
- */
- }, {
- key: "greaterThan",
- value: function (key
- /*: string*/
- , value
- /*: mixed*/
- )
- /*: ParseQuery*/
- {
- return this._addCondition(key, '$gt', value);
- }
- /**
- * Adds a constraint to the query that requires a particular key's value to
- * be less than or equal to the provided value.
- *
- * @param {string} key The key to check.
- * @param value The value that provides an upper bound.
- * @returns {Parse.Query} Returns the query, so you can chain this call.
- */
- }, {
- key: "lessThanOrEqualTo",
- value: function (key
- /*: string*/
- , value
- /*: mixed*/
- )
- /*: ParseQuery*/
- {
- return this._addCondition(key, '$lte', value);
- }
- /**
- * Adds a constraint to the query that requires a particular key's value to
- * be greater than or equal to the provided value.
- *
- * @param {string} key The key to check.
- * @param {*} value The value that provides an lower bound.
- * @returns {Parse.Query} Returns the query, so you can chain this call.
- */
- }, {
- key: "greaterThanOrEqualTo",
- value: function (key
- /*: string*/
- , value
- /*: mixed*/
- )
- /*: ParseQuery*/
- {
- return this._addCondition(key, '$gte', value);
- }
- /**
- * Adds a constraint to the query that requires a particular key's value to
- * be contained in the provided list of values.
- *
- * @param {string} key The key to check.
- * @param {*} value The values that will match.
- * @returns {Parse.Query} Returns the query, so you can chain this call.
- */
- }, {
- key: "containedIn",
- value: function (key
- /*: string*/
- , value
- /*: mixed*/
- )
- /*: ParseQuery*/
- {
- return this._addCondition(key, '$in', value);
- }
- /**
- * Adds a constraint to the query that requires a particular key's value to
- * not be contained in the provided list of values.
- *
- * @param {string} key The key to check.
- * @param {*} value The values that will not match.
- * @returns {Parse.Query} Returns the query, so you can chain this call.
- */
- }, {
- key: "notContainedIn",
- value: function (key
- /*: string*/
- , value
- /*: mixed*/
- )
- /*: ParseQuery*/
- {
- return this._addCondition(key, '$nin', value);
- }
- /**
- * Adds a constraint to the query that requires a particular key's value to
- * be contained by the provided list of values. Get objects where all array elements match.
- *
- * @param {string} key The key to check.
- * @param {Array} values The values that will match.
- * @returns {Parse.Query} Returns the query, so you can chain this call.
- */
- }, {
- key: "containedBy",
- value: function (key
- /*: string*/
- , values
- /*: Array<mixed>*/
- )
- /*: ParseQuery*/
- {
- return this._addCondition(key, '$containedBy', values);
- }
- /**
- * Adds a constraint to the query that requires a particular key's value to
- * contain each one of the provided list of values.
- *
- * @param {string} key The key to check. This key's value must be an array.
- * @param {Array} values The values that will match.
- * @returns {Parse.Query} Returns the query, so you can chain this call.
- */
- }, {
- key: "containsAll",
- value: function (key
- /*: string*/
- , values
- /*: Array<mixed>*/
- )
- /*: ParseQuery*/
- {
- return this._addCondition(key, '$all', values);
- }
- /**
- * Adds a constraint to the query that requires a particular key's value to
- * contain each one of the provided list of values starting with given strings.
- *
- * @param {string} key The key to check. This key's value must be an array.
- * @param {Array<string>} values The string values that will match as starting string.
- * @returns {Parse.Query} Returns the query, so you can chain this call.
- */
- }, {
- key: "containsAllStartingWith",
- value: function (key
- /*: string*/
- , values
- /*: Array<string>*/
- )
- /*: ParseQuery*/
- {
- var _this = this;
- if (!(0, _isArray.default)(values)) {
- values = [values];
- }
- var regexObject = (0, _map2.default)(values).call(values, function (value) {
- return {
- $regex: _this._regexStartWith(value)
- };
- });
- return this.containsAll(key, regexObject);
- }
- /**
- * Adds a constraint for finding objects that contain the given key.
- *
- * @param {string} key The key that should exist.
- * @returns {Parse.Query} Returns the query, so you can chain this call.
- */
- }, {
- key: "exists",
- value: function (key
- /*: string*/
- )
- /*: ParseQuery*/
- {
- return this._addCondition(key, '$exists', true);
- }
- /**
- * Adds a constraint for finding objects that do not contain a given key.
- *
- * @param {string} key The key that should not exist
- * @returns {Parse.Query} Returns the query, so you can chain this call.
- */
- }, {
- key: "doesNotExist",
- value: function (key
- /*: string*/
- )
- /*: ParseQuery*/
- {
- return this._addCondition(key, '$exists', false);
- }
- /**
- * Adds a regular expression constraint for finding string values that match
- * the provided regular expression.
- * This may be slow for large datasets.
- *
- * @param {string} key The key that the string to match is stored in.
- * @param {RegExp} regex The regular expression pattern to match.
- * @param {string} modifiers The regular expression mode.
- * @returns {Parse.Query} Returns the query, so you can chain this call.
- */
- }, {
- key: "matches",
- value: function (key
- /*: string*/
- , regex
- /*: RegExp*/
- , modifiers
- /*: string*/
- )
- /*: ParseQuery*/
- {
- this._addCondition(key, '$regex', regex);
- if (!modifiers) {
- modifiers = '';
- }
- if (regex.ignoreCase) {
- modifiers += 'i';
- }
- if (regex.multiline) {
- modifiers += 'm';
- }
- if (modifiers.length) {
- this._addCondition(key, '$options', modifiers);
- }
- return this;
- }
- /**
- * Adds a constraint that requires that a key's value matches a Parse.Query
- * constraint.
- *
- * @param {string} key The key that the contains the object to match the
- * query.
- * @param {Parse.Query} query The query that should match.
- * @returns {Parse.Query} Returns the query, so you can chain this call.
- */
- }, {
- key: "matchesQuery",
- value: function (key
- /*: string*/
- , query
- /*: ParseQuery*/
- )
- /*: ParseQuery*/
- {
- var queryJSON = query.toJSON();
- queryJSON.className = query.className;
- return this._addCondition(key, '$inQuery', queryJSON);
- }
- /**
- * Adds a constraint that requires that a key's value not matches a
- * Parse.Query constraint.
- *
- * @param {string} key The key that the contains the object to match the
- * query.
- * @param {Parse.Query} query The query that should not match.
- * @returns {Parse.Query} Returns the query, so you can chain this call.
- */
- }, {
- key: "doesNotMatchQuery",
- value: function (key
- /*: string*/
- , query
- /*: ParseQuery*/
- )
- /*: ParseQuery*/
- {
- var queryJSON = query.toJSON();
- queryJSON.className = query.className;
- return this._addCondition(key, '$notInQuery', queryJSON);
- }
- /**
- * Adds a constraint that requires that a key's value matches a value in
- * an object returned by a different Parse.Query.
- *
- * @param {string} key The key that contains the value that is being
- * matched.
- * @param {string} queryKey The key in the objects returned by the query to
- * match against.
- * @param {Parse.Query} query The query to run.
- * @returns {Parse.Query} Returns the query, so you can chain this call.
- */
- }, {
- key: "matchesKeyInQuery",
- value: function (key
- /*: string*/
- , queryKey
- /*: string*/
- , query
- /*: ParseQuery*/
- )
- /*: ParseQuery*/
- {
- var queryJSON = query.toJSON();
- queryJSON.className = query.className;
- return this._addCondition(key, '$select', {
- key: queryKey,
- query: queryJSON
- });
- }
- /**
- * Adds a constraint that requires that a key's value not match a value in
- * an object returned by a different Parse.Query.
- *
- * @param {string} key The key that contains the value that is being
- * excluded.
- * @param {string} queryKey The key in the objects returned by the query to
- * match against.
- * @param {Parse.Query} query The query to run.
- * @returns {Parse.Query} Returns the query, so you can chain this call.
- */
- }, {
- key: "doesNotMatchKeyInQuery",
- value: function (key
- /*: string*/
- , queryKey
- /*: string*/
- , query
- /*: ParseQuery*/
- )
- /*: ParseQuery*/
- {
- var queryJSON = query.toJSON();
- queryJSON.className = query.className;
- return this._addCondition(key, '$dontSelect', {
- key: queryKey,
- query: queryJSON
- });
- }
- /**
- * Adds a constraint for finding string values that contain a provided
- * string. This may be slow for large datasets.
- *
- * @param {string} key The key that the string to match is stored in.
- * @param {string} substring The substring that the value must contain.
- * @returns {Parse.Query} Returns the query, so you can chain this call.
- */
- }, {
- key: "contains",
- value: function (key
- /*: string*/
- , substring
- /*: string*/
- )
- /*: ParseQuery*/
- {
- if (typeof substring !== 'string') {
- throw new Error('The value being searched for must be a string.');
- }
- return this._addCondition(key, '$regex', quote(substring));
- }
- /**
- * Adds a constraint for finding string values that contain a provided
- * string. This may be slow for large datasets. Requires Parse-Server > 2.5.0
- *
- * In order to sort you must use select and ascending ($score is required)
- * <pre>
- * query.fullText('field', 'term');
- * query.ascending('$score');
- * query.select('$score');
- * </pre>
- *
- * To retrieve the weight / rank
- * <pre>
- * object->get('score');
- * </pre>
- *
- * You can define optionals by providing an object as a third parameter
- * <pre>
- * query.fullText('field', 'term', { language: 'es', diacriticSensitive: true });
- * </pre>
- *
- * @param {string} key The key that the string to match is stored in.
- * @param {string} value The string to search
- * @param {object} options (Optional)
- * @param {string} options.language The language that determines the list of stop words for the search and the rules for the stemmer and tokenizer.
- * @param {boolean} options.caseSensitive A boolean flag to enable or disable case sensitive search.
- * @param {boolean} options.diacriticSensitive A boolean flag to enable or disable diacritic sensitive search.
- * @returns {Parse.Query} Returns the query, so you can chain this call.
- */
- }, {
- key: "fullText",
- value: function (key
- /*: string*/
- , value
- /*: string*/
- , options
- /*: ?Object*/
- )
- /*: ParseQuery*/
- {
- options = options || {};
- if (!key) {
- throw new Error('A key is required.');
- }
- if (!value) {
- throw new Error('A search term is required');
- }
- if (typeof value !== 'string') {
- throw new Error('The value being searched for must be a string.');
- }
- var fullOptions = {};
- fullOptions.$term = value;
- for (var option in options) {
- switch (option) {
- case 'language':
- fullOptions.$language = options[option];
- break;
- case 'caseSensitive':
- fullOptions.$caseSensitive = options[option];
- break;
- case 'diacriticSensitive':
- fullOptions.$diacriticSensitive = options[option];
- break;
- default:
- throw new Error("Unknown option: ".concat(option));
- }
- }
- return this._addCondition(key, '$text', {
- $search: fullOptions
- });
- }
- /**
- * Method to sort the full text search by text score
- *
- * @returns {Parse.Query} Returns the query, so you can chain this call.
- */
- }, {
- key: "sortByTextScore",
- value: function () {
- this.ascending('$score');
- this.select(['$score']);
- return this;
- }
- /**
- * Adds a constraint for finding string values that start with a provided
- * string. This query will use the backend index, so it will be fast even
- * for large datasets.
- *
- * @param {string} key The key that the string to match is stored in.
- * @param {string} prefix The substring that the value must start with.
- * @returns {Parse.Query} Returns the query, so you can chain this call.
- */
- }, {
- key: "startsWith",
- value: function (key
- /*: string*/
- , prefix
- /*: string*/
- )
- /*: ParseQuery*/
- {
- if (typeof prefix !== 'string') {
- throw new Error('The value being searched for must be a string.');
- }
- return this._addCondition(key, '$regex', this._regexStartWith(prefix));
- }
- /**
- * Adds a constraint for finding string values that end with a provided
- * string. This will be slow for large datasets.
- *
- * @param {string} key The key that the string to match is stored in.
- * @param {string} suffix The substring that the value must end with.
- * @returns {Parse.Query} Returns the query, so you can chain this call.
- */
- }, {
- key: "endsWith",
- value: function (key
- /*: string*/
- , suffix
- /*: string*/
- )
- /*: ParseQuery*/
- {
- if (typeof suffix !== 'string') {
- throw new Error('The value being searched for must be a string.');
- }
- return this._addCondition(key, '$regex', "".concat(quote(suffix), "$"));
- }
- /**
- * Adds a proximity based constraint for finding objects with key point
- * values near the point given.
- *
- * @param {string} key The key that the Parse.GeoPoint is stored in.
- * @param {Parse.GeoPoint} point The reference Parse.GeoPoint that is used.
- * @returns {Parse.Query} Returns the query, so you can chain this call.
- */
- }, {
- key: "near",
- value: function (key
- /*: string*/
- , point
- /*: ParseGeoPoint*/
- )
- /*: ParseQuery*/
- {
- if (!(point instanceof _ParseGeoPoint.default)) {
- // Try to cast it as a GeoPoint
- point = new _ParseGeoPoint.default(point);
- }
- return this._addCondition(key, '$nearSphere', point);
- }
- /**
- * Adds a proximity based constraint for finding objects with key point
- * values near the point given and within the maximum distance given.
- *
- * @param {string} key The key that the Parse.GeoPoint is stored in.
- * @param {Parse.GeoPoint} point The reference Parse.GeoPoint that is used.
- * @param {number} maxDistance Maximum distance (in radians) of results to return.
- * @param {boolean} sorted A Bool value that is true if results should be
- * sorted by distance ascending, false is no sorting is required,
- * defaults to true.
- * @returns {Parse.Query} Returns the query, so you can chain this call.
- */
- }, {
- key: "withinRadians",
- value: function (key
- /*: string*/
- , point
- /*: ParseGeoPoint*/
- , maxDistance
- /*: number*/
- , sorted
- /*: boolean*/
- )
- /*: ParseQuery*/
- {
- if (sorted || sorted === undefined) {
- this.near(key, point);
- return this._addCondition(key, '$maxDistance', maxDistance);
- }
- return this._addCondition(key, '$geoWithin', {
- $centerSphere: [[point.longitude, point.latitude], maxDistance]
- });
- }
- /**
- * Adds a proximity based constraint for finding objects with key point
- * values near the point given and within the maximum distance given.
- * Radius of earth used is 3958.8 miles.
- *
- * @param {string} key The key that the Parse.GeoPoint is stored in.
- * @param {Parse.GeoPoint} point The reference Parse.GeoPoint that is used.
- * @param {number} maxDistance Maximum distance (in miles) of results to return.
- * @param {boolean} sorted A Bool value that is true if results should be
- * sorted by distance ascending, false is no sorting is required,
- * defaults to true.
- * @returns {Parse.Query} Returns the query, so you can chain this call.
- */
- }, {
- key: "withinMiles",
- value: function (key
- /*: string*/
- , point
- /*: ParseGeoPoint*/
- , maxDistance
- /*: number*/
- , sorted
- /*: boolean*/
- )
- /*: ParseQuery*/
- {
- return this.withinRadians(key, point, maxDistance / 3958.8, sorted);
- }
- /**
- * Adds a proximity based constraint for finding objects with key point
- * values near the point given and within the maximum distance given.
- * Radius of earth used is 6371.0 kilometers.
- *
- * @param {string} key The key that the Parse.GeoPoint is stored in.
- * @param {Parse.GeoPoint} point The reference Parse.GeoPoint that is used.
- * @param {number} maxDistance Maximum distance (in kilometers) of results to return.
- * @param {boolean} sorted A Bool value that is true if results should be
- * sorted by distance ascending, false is no sorting is required,
- * defaults to true.
- * @returns {Parse.Query} Returns the query, so you can chain this call.
- */
- }, {
- key: "withinKilometers",
- value: function (key
- /*: string*/
- , point
- /*: ParseGeoPoint*/
- , maxDistance
- /*: number*/
- , sorted
- /*: boolean*/
- )
- /*: ParseQuery*/
- {
- return this.withinRadians(key, point, maxDistance / 6371.0, sorted);
- }
- /**
- * Adds a constraint to the query that requires a particular key's
- * coordinates be contained within a given rectangular geographic bounding
- * box.
- *
- * @param {string} key The key to be constrained.
- * @param {Parse.GeoPoint} southwest
- * The lower-left inclusive corner of the box.
- * @param {Parse.GeoPoint} northeast
- * The upper-right inclusive corner of the box.
- * @returns {Parse.Query} Returns the query, so you can chain this call.
- */
- }, {
- key: "withinGeoBox",
- value: function (key
- /*: string*/
- , southwest
- /*: ParseGeoPoint*/
- , northeast
- /*: ParseGeoPoint*/
- )
- /*: ParseQuery*/
- {
- if (!(southwest instanceof _ParseGeoPoint.default)) {
- southwest = new _ParseGeoPoint.default(southwest);
- }
- if (!(northeast instanceof _ParseGeoPoint.default)) {
- northeast = new _ParseGeoPoint.default(northeast);
- }
- this._addCondition(key, '$within', {
- $box: [southwest, northeast]
- });
- return this;
- }
- /**
- * Adds a constraint to the query that requires a particular key's
- * coordinates be contained within and on the bounds of a given polygon.
- * Supports closed and open (last point is connected to first) paths
- *
- * Polygon must have at least 3 points
- *
- * @param {string} key The key to be constrained.
- * @param {Array} points Array of Coordinates / GeoPoints
- * @returns {Parse.Query} Returns the query, so you can chain this call.
- */
- }, {
- key: "withinPolygon",
- value: function (key
- /*: string*/
- , points
- /*: Array<Array<number>>*/
- )
- /*: ParseQuery*/
- {
- return this._addCondition(key, '$geoWithin', {
- $polygon: points
- });
- }
- /**
- * Add a constraint to the query that requires a particular key's
- * coordinates that contains a ParseGeoPoint
- *
- * @param {string} key The key to be constrained.
- * @param {Parse.GeoPoint} point
- * @returns {Parse.Query} Returns the query, so you can chain this call.
- */
- }, {
- key: "polygonContains",
- value: function (key
- /*: string*/
- , point
- /*: ParseGeoPoint*/
- )
- /*: ParseQuery*/
- {
- return this._addCondition(key, '$geoIntersects', {
- $point: point
- });
- }
- /** Query Orderings * */
- /**
- * Sorts the results in ascending order by the given key.
- *
- * @param {(string|string[])} keys The key to order by, which is a
- * string of comma separated values, or an Array of keys, or multiple keys.
- * @returns {Parse.Query} Returns the query, so you can chain this call.
- */
- }, {
- key: "ascending",
- value: function ()
- /*: ParseQuery*/
- {
- this._order = [];
- for (var _len = arguments.length, keys = new Array(_len), _key5 = 0; _key5 < _len; _key5++) {
- keys[_key5] = arguments[_key5];
- }
- return this.addAscending.apply(this, keys);
- }
- /**
- * Sorts the results in ascending order by the given key,
- * but can also add secondary sort descriptors without overwriting _order.
- *
- * @param {(string|string[])} keys The key to order by, which is a
- * string of comma separated values, or an Array of keys, or multiple keys.
- * @returns {Parse.Query} Returns the query, so you can chain this call.
- */
- }, {
- key: "addAscending",
- value: function ()
- /*: ParseQuery*/
- {
- var _this9 = this;
- if (!this._order) {
- this._order = [];
- }
- for (var _len2 = arguments.length, keys = new Array(_len2), _key6 = 0; _key6 < _len2; _key6++) {
- keys[_key6] = arguments[_key6];
- }
- (0, _forEach.default)(keys).call(keys, function (key) {
- var _context16;
- if ((0, _isArray.default)(key)) {
- key = key.join();
- }
- _this9._order = (0, _concat.default)(_context16 = _this9._order).call(_context16, key.replace(/\s/g, '').split(','));
- });
- return this;
- }
- /**
- * Sorts the results in descending order by the given key.
- *
- * @param {(string|string[])} keys The key to order by, which is a
- * string of comma separated values, or an Array of keys, or multiple keys.
- * @returns {Parse.Query} Returns the query, so you can chain this call.
- */
- }, {
- key: "descending",
- value: function ()
- /*: ParseQuery*/
- {
- this._order = [];
- for (var _len3 = arguments.length, keys = new Array(_len3), _key7 = 0; _key7 < _len3; _key7++) {
- keys[_key7] = arguments[_key7];
- }
- return this.addDescending.apply(this, keys);
- }
- /**
- * Sorts the results in descending order by the given key,
- * but can also add secondary sort descriptors without overwriting _order.
- *
- * @param {(string|string[])} keys The key to order by, which is a
- * string of comma separated values, or an Array of keys, or multiple keys.
- * @returns {Parse.Query} Returns the query, so you can chain this call.
- */
- }, {
- key: "addDescending",
- value: function ()
- /*: ParseQuery*/
- {
- var _this10 = this;
- if (!this._order) {
- this._order = [];
- }
- for (var _len4 = arguments.length, keys = new Array(_len4), _key8 = 0; _key8 < _len4; _key8++) {
- keys[_key8] = arguments[_key8];
- }
- (0, _forEach.default)(keys).call(keys, function (key) {
- var _context17, _context18;
- if ((0, _isArray.default)(key)) {
- key = key.join();
- }
- _this10._order = (0, _concat.default)(_context17 = _this10._order).call(_context17, (0, _map2.default)(_context18 = key.replace(/\s/g, '').split(',')).call(_context18, function (k) {
- return "-".concat(k);
- }));
- });
- return this;
- }
- /** Query Options * */
- /**
- * Sets the number of results to skip before returning any results.
- * This is useful for pagination.
- * Default is to skip zero results.
- *
- * @param {number} n the number of results to skip.
- * @returns {Parse.Query} Returns the query, so you can chain this call.
- */
- }, {
- key: "skip",
- value: function (n
- /*: number*/
- )
- /*: ParseQuery*/
- {
- if (typeof n !== 'number' || n < 0) {
- throw new Error('You can only skip by a positive number');
- }
- this._skip = n;
- return this;
- }
- /**
- * Sets the limit of the number of results to return. The default limit is 100.
- *
- * @param {number} n the number of results to limit to.
- * @returns {Parse.Query} Returns the query, so you can chain this call.
- */
- }, {
- key: "limit",
- value: function (n
- /*: number*/
- )
- /*: ParseQuery*/
- {
- if (typeof n !== 'number') {
- throw new Error('You can only set the limit to a numeric value');
- }
- this._limit = n;
- return this;
- }
- /**
- * Sets the flag to include with response the total number of objects satisfying this query,
- * despite limits/skip. Might be useful for pagination.
- * Note that result of this query will be wrapped as an object with
- * `results`: holding {ParseObject} array and `count`: integer holding total number
- *
- * @param {boolean} includeCount false - disable, true - enable.
- * @returns {Parse.Query} Returns the query, so you can chain this call.
- */
- }, {
- key: "withCount",
- value: function ()
- /*: ParseQuery*/
- {
- var includeCount
- /*: boolean*/
- = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
- if (typeof includeCount !== 'boolean') {
- throw new Error('You can only set withCount to a boolean value');
- }
- this._count = includeCount;
- return this;
- }
- /**
- * Includes nested Parse.Objects for the provided key. You can use dot
- * notation to specify which fields in the included object are also fetched.
- *
- * You can include all nested Parse.Objects by passing in '*'.
- * Requires Parse Server 3.0.0+
- * <pre>query.include('*');</pre>
- *
- * @param {...string|Array<string>} keys The name(s) of the key(s) to include.
- * @returns {Parse.Query} Returns the query, so you can chain this call.
- */
- }, {
- key: "include",
- value: function ()
- /*: ParseQuery*/
- {
- var _this11 = this;
- for (var _len5 = arguments.length, keys = new Array(_len5), _key9 = 0; _key9 < _len5; _key9++) {
- keys[_key9] = arguments[_key9];
- }
- (0, _forEach.default)(keys).call(keys, function (key) {
- if ((0, _isArray.default)(key)) {
- var _context19;
- _this11._include = (0, _concat.default)(_context19 = _this11._include).call(_context19, key);
- } else {
- _this11._include.push(key);
- }
- });
- return this;
- }
- /**
- * Includes all nested Parse.Objects.
- *
- * Requires Parse Server 3.0.0+
- *
- * @returns {Parse.Query} Returns the query, so you can chain this call.
- */
- }, {
- key: "includeAll",
- value: function ()
- /*: ParseQuery*/
- {
- return this.include('*');
- }
- /**
- * Restricts the fields of the returned Parse.Objects to include only the
- * provided keys. If this is called multiple times, then all of the keys
- * specified in each of the calls will be included.
- *
- * @param {...string|Array<string>} keys The name(s) of the key(s) to include.
- * @returns {Parse.Query} Returns the query, so you can chain this call.
- */
- }, {
- key: "select",
- value: function ()
- /*: ParseQuery*/
- {
- var _this12 = this;
- if (!this._select) {
- this._select = [];
- }
- for (var _len6 = arguments.length, keys = new Array(_len6), _key10 = 0; _key10 < _len6; _key10++) {
- keys[_key10] = arguments[_key10];
- }
- (0, _forEach.default)(keys).call(keys, function (key) {
- if ((0, _isArray.default)(key)) {
- var _context20;
- _this12._select = (0, _concat.default)(_context20 = _this12._select).call(_context20, key);
- } else {
- _this12._select.push(key);
- }
- });
- return this;
- }
- /**
- * Restricts the fields of the returned Parse.Objects to all keys except the
- * provided keys. Exclude takes precedence over select and include.
- *
- * Requires Parse Server 3.6.0+
- *
- * @param {...string|Array<string>} keys The name(s) of the key(s) to exclude.
- * @returns {Parse.Query} Returns the query, so you can chain this call.
- */
- }, {
- key: "exclude",
- value: function ()
- /*: ParseQuery*/
- {
- var _this13 = this;
- for (var _len7 = arguments.length, keys = new Array(_len7), _key11 = 0; _key11 < _len7; _key11++) {
- keys[_key11] = arguments[_key11];
- }
- (0, _forEach.default)(keys).call(keys, function (key) {
- if ((0, _isArray.default)(key)) {
- var _context21;
- _this13._exclude = (0, _concat.default)(_context21 = _this13._exclude).call(_context21, key);
- } else {
- _this13._exclude.push(key);
- }
- });
- return this;
- }
- /**
- * Changes the read preference that the backend will use when performing the query to the database.
- *
- * @param {string} readPreference The read preference for the main query.
- * @param {string} includeReadPreference The read preference for the queries to include pointers.
- * @param {string} subqueryReadPreference The read preference for the sub queries.
- * @returns {Parse.Query} Returns the query, so you can chain this call.
- */
- }, {
- key: "readPreference",
- value: function (_readPreference
- /*: string*/
- , includeReadPreference
- /*:: ?: string*/
- , subqueryReadPreference
- /*:: ?: string*/
- )
- /*: ParseQuery*/
- {
- this._readPreference = _readPreference;
- this._includeReadPreference = includeReadPreference;
- this._subqueryReadPreference = subqueryReadPreference;
- return this;
- }
- }, {
- key: "onChange",
- value: function (onUpdate
- /*: any*/
- , onError
- /*:: ?: any*/
- /*:: ?: string*/
- )
- /*: Promise<LiveQuerySubscription>*/
- {
- var sub = null;
- this.subscribe().then(function (subscription) {
- sub = subscription;
- subscription.on('create', function (object) {
- onUpdate(object);
- });
- subscription.on('update', function (object) {
- onUpdate(object);
- });
- subscription.on('error', function (err) {
- if (onError) {
- onError(err);
- } else {
- // eslint-disable-next-line no-console
- console.warn('Subscription error', err);
- }
- });
- }).catch(function (err) {
- if (onError) {
- onError(err);
- } else {
- // eslint-disable-next-line no-console
- console.warn('Subscription connection error', err);
- }
- });
- return function () {
- if (sub) {
- sub.unsubscribe();
- }
- };
- }
- /**
- * Subscribe this query to get liveQuery updates
- *
- * @param {string} sessionToken (optional) Defaults to the currentUser
- * @returns {Promise<LiveQuerySubscription>} Returns the liveQuerySubscription, it's an event emitter
- * which can be used to get liveQuery updates.
- */
- }, {
- key: "subscribe",
- value: function () {
- var _subscribe = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7(sessionToken
- /*:: ?: string*/
- ) {
- var currentUser, liveQueryClient, subscription;
- return _regenerator.default.wrap(function (_context22) {
- while (1) {
- switch (_context22.prev = _context22.next) {
- case 0:
- _context22.next = 2;
- return _CoreManager.default.getUserController().currentUserAsync();
- case 2:
- currentUser = _context22.sent;
- if (!sessionToken) {
- sessionToken = currentUser ? currentUser.getSessionToken() : undefined;
- }
- _context22.next = 6;
- return _CoreManager.default.getLiveQueryController().getDefaultLiveQueryClient();
- case 6:
- liveQueryClient = _context22.sent;
- if (liveQueryClient.shouldOpen()) {
- liveQueryClient.open();
- }
- subscription = liveQueryClient.subscribe(this, sessionToken);
- return _context22.abrupt("return", subscription.subscribePromise.then(function () {
- return subscription;
- }));
- case 10:
- case "end":
- return _context22.stop();
- }
- }
- }, _callee7, this);
- }));
- return function () {
- return _subscribe.apply(this, arguments);
- };
- }()
- /**
- * Constructs a Parse.Query that is the OR of the passed in queries. For
- * example:
- * <pre>var compoundQuery = Parse.Query.or(query1, query2, query3);</pre>
- *
- * will create a compoundQuery that is an or of the query1, query2, and
- * query3.
- *
- * @param {...Parse.Query} queries The list of queries to OR.
- * @static
- * @returns {Parse.Query} The query that is the OR of the passed in queries.
- */
- }, {
- key: "fromNetwork",
- value:
- /**
- * Change the source of this query to the server.
- *
- * @returns {Parse.Query} Returns the query, so you can chain this call.
- */
- function ()
- /*: ParseQuery*/
- {
- this._queriesLocalDatastore = false;
- this._localDatastorePinName = null;
- return this;
- }
- /**
- * Changes the source of this query to all pinned objects.
- *
- * @returns {Parse.Query} Returns the query, so you can chain this call.
- */
- }, {
- key: "fromLocalDatastore",
- value: function ()
- /*: ParseQuery*/
- {
- return this.fromPinWithName(null);
- }
- /**
- * Changes the source of this query to the default group of pinned objects.
- *
- * @returns {Parse.Query} Returns the query, so you can chain this call.
- */
- }, {
- key: "fromPin",
- value: function ()
- /*: ParseQuery*/
- {
- return this.fromPinWithName(_LocalDatastoreUtils.DEFAULT_PIN);
- }
- /**
- * Changes the source of this query to a specific group of pinned objects.
- *
- * @param {string} name The name of query source.
- * @returns {Parse.Query} Returns the query, so you can chain this call.
- */
- }, {
- key: "fromPinWithName",
- value: function (name
- /*:: ?: string*/
- )
- /*: ParseQuery*/
- {
- var localDatastore = _CoreManager.default.getLocalDatastore();
- if (localDatastore.checkIfEnabled()) {
- this._queriesLocalDatastore = true;
- this._localDatastorePinName = name;
- }
- return this;
- }
- /**
- * Cancels the current network request (if any is running).
- *
- * @returns {Parse.Query} Returns the query, so you can chain this call.
- */
- }, {
- key: "cancel",
- value: function ()
- /*: ParseQuery*/
- {
- var _this14 = this;
- if (this._xhrRequest.task && typeof this._xhrRequest.task.abort === 'function') {
- this._xhrRequest.task._aborted = true;
- this._xhrRequest.task.abort();
- this._xhrRequest.task = null;
- this._xhrRequest.onchange = function () {};
- return this;
- }
- return this._xhrRequest.onchange = function () {
- return _this14.cancel();
- };
- }
- }, {
- key: "_setRequestTask",
- value: function (options) {
- var _this15 = this;
- options.requestTask = function (task) {
- _this15._xhrRequest.task = task;
- _this15._xhrRequest.onchange();
- };
- }
- }], [{
- key: "fromJSON",
- value: function (className
- /*: string*/
- , json
- /*: QueryJSON*/
- )
- /*: ParseQuery*/
- {
- var query = new ParseQuery(className);
- return query.withJSON(json);
- }
- }, {
- key: "or",
- value: function ()
- /*: ParseQuery*/
- {
- for (var _len8 = arguments.length, queries = new Array(_len8), _key12 = 0; _key12 < _len8; _key12++) {
- queries[_key12] = arguments[_key12];
- }
- var className = _getClassNameFromQueries(queries);
- var query = new ParseQuery(className);
- query._orQuery(queries);
- return query;
- }
- /**
- * Constructs a Parse.Query that is the AND of the passed in queries. For
- * example:
- * <pre>var compoundQuery = Parse.Query.and(query1, query2, query3);</pre>
- *
- * will create a compoundQuery that is an and of the query1, query2, and
- * query3.
- *
- * @param {...Parse.Query} queries The list of queries to AND.
- * @static
- * @returns {Parse.Query} The query that is the AND of the passed in queries.
- */
- }, {
- key: "and",
- value: function ()
- /*: ParseQuery*/
- {
- for (var _len9 = arguments.length, queries = new Array(_len9), _key13 = 0; _key13 < _len9; _key13++) {
- queries[_key13] = arguments[_key13];
- }
- var className = _getClassNameFromQueries(queries);
- var query = new ParseQuery(className);
- query._andQuery(queries);
- return query;
- }
- /**
- * Constructs a Parse.Query that is the NOR of the passed in queries. For
- * example:
- * <pre>const compoundQuery = Parse.Query.nor(query1, query2, query3);</pre>
- *
- * will create a compoundQuery that is a nor of the query1, query2, and
- * query3.
- *
- * @param {...Parse.Query} queries The list of queries to NOR.
- * @static
- * @returns {Parse.Query} The query that is the NOR of the passed in queries.
- */
- }, {
- key: "nor",
- value: function ()
- /*: ParseQuery*/
- {
- for (var _len10 = arguments.length, queries = new Array(_len10), _key14 = 0; _key14 < _len10; _key14++) {
- queries[_key14] = arguments[_key14];
- }
- var className = _getClassNameFromQueries(queries);
- var query = new ParseQuery(className);
- query._norQuery(queries);
- return query;
- }
- }]);
- return ParseQuery;
- }();
- var DefaultController = {
- find: function (className
- /*: string*/
- , params
- /*: QueryJSON*/
- , options
- /*: RequestOptions*/
- )
- /*: Promise<Array<ParseObject>>*/
- {
- var RESTController = _CoreManager.default.getRESTController();
- return RESTController.request('GET', "classes/".concat(className), params, options);
- },
- aggregate: function (className
- /*: string*/
- , params
- /*: any*/
- , options
- /*: RequestOptions*/
- )
- /*: Promise<Array<mixed>>*/
- {
- var RESTController = _CoreManager.default.getRESTController();
- return RESTController.request('GET', "aggregate/".concat(className), params, options);
- }
- };
- _CoreManager.default.setQueryController(DefaultController);
- var _default = ParseQuery;
- exports.default = _default;
- },{"./CoreManager":5,"./LocalDatastoreUtils":15,"./OfflineQuery":24,"./ParseError":29,"./ParseGeoPoint":33,"./ParseObject":36,"./encode":66,"./promiseUtils":72,"@babel/runtime-corejs3/core-js-stable/array/is-array":79,"@babel/runtime-corejs3/core-js-stable/instance/concat":81,"@babel/runtime-corejs3/core-js-stable/instance/filter":84,"@babel/runtime-corejs3/core-js-stable/instance/find":85,"@babel/runtime-corejs3/core-js-stable/instance/for-each":86,"@babel/runtime-corejs3/core-js-stable/instance/includes":87,"@babel/runtime-corejs3/core-js-stable/instance/index-of":88,"@babel/runtime-corejs3/core-js-stable/instance/keys":89,"@babel/runtime-corejs3/core-js-stable/instance/map":90,"@babel/runtime-corejs3/core-js-stable/instance/slice":93,"@babel/runtime-corejs3/core-js-stable/instance/sort":94,"@babel/runtime-corejs3/core-js-stable/instance/splice":95,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/core-js-stable/object/entries":106,"@babel/runtime-corejs3/core-js-stable/object/keys":112,"@babel/runtime-corejs3/core-js-stable/promise":115,"@babel/runtime-corejs3/helpers/asyncToGenerator":144,"@babel/runtime-corejs3/helpers/classCallCheck":145,"@babel/runtime-corejs3/helpers/createClass":147,"@babel/runtime-corejs3/helpers/defineProperty":148,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/helpers/slicedToArray":161,"@babel/runtime-corejs3/helpers/toConsumableArray":163,"@babel/runtime-corejs3/helpers/typeof":164,"@babel/runtime-corejs3/regenerator":167}],40:[function(_dereq_,module,exports){
- "use strict";
- var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
- var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
- _Object$defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = void 0;
- var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
- var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
- var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
- var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
- var _ParseOp = _dereq_("./ParseOp");
- var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
- var _ParseQuery = _interopRequireDefault(_dereq_("./ParseQuery"));
- /**
- * Copyright (c) 2015-present, Parse, LLC.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- *
- * @flow
- */
- /**
- * Creates a new Relation for the given parent object and key. This
- * constructor should rarely be used directly, but rather created by
- * Parse.Object.relation.
- *
- * <p>
- * A class that is used to access all of the children of a many-to-many
- * relationship. Each instance of Parse.Relation is associated with a
- * particular parent object and key.
- * </p>
- *
- * @alias Parse.Relation
- */
- var ParseRelation = /*#__PURE__*/function () {
- /**
- * @param {Parse.Object} parent The parent of this relation.
- * @param {string} key The key for this relation on the parent.
- */
- function ParseRelation(parent
- /*: ?ParseObject*/
- , key
- /*: ?string*/
- ) {
- (0, _classCallCheck2.default)(this, ParseRelation);
- (0, _defineProperty2.default)(this, "parent", void 0);
- (0, _defineProperty2.default)(this, "key", void 0);
- (0, _defineProperty2.default)(this, "targetClassName", void 0);
- this.parent = parent;
- this.key = key;
- this.targetClassName = null;
- }
- /*
- * Makes sure that this relation has the right parent and key.
- */
- (0, _createClass2.default)(ParseRelation, [{
- key: "_ensureParentAndKey",
- value: function (parent
- /*: ParseObject*/
- , key
- /*: string*/
- ) {
- this.key = this.key || key;
- if (this.key !== key) {
- throw new Error('Internal Error. Relation retrieved from two different keys.');
- }
- if (this.parent) {
- if (this.parent.className !== parent.className) {
- throw new Error('Internal Error. Relation retrieved from two different Objects.');
- }
- if (this.parent.id) {
- if (this.parent.id !== parent.id) {
- throw new Error('Internal Error. Relation retrieved from two different Objects.');
- }
- } else if (parent.id) {
- this.parent = parent;
- }
- } else {
- this.parent = parent;
- }
- }
- /**
- * Adds a Parse.Object or an array of Parse.Objects to the relation.
- *
- * @param {(Parse.Object|Array)} objects The item or items to add.
- * @returns {Parse.Object} The parent of the relation.
- */
- }, {
- key: "add",
- value: function (objects
- /*: ParseObject | Array<ParseObject | string>*/
- )
- /*: ParseObject*/
- {
- if (!(0, _isArray.default)(objects)) {
- objects = [objects];
- }
- var change = new _ParseOp.RelationOp(objects, []);
- var parent = this.parent;
- if (!parent) {
- throw new Error('Cannot add to a Relation without a parent');
- }
- if (objects.length === 0) {
- return parent;
- }
- parent.set(this.key, change);
- this.targetClassName = change._targetClassName;
- return parent;
- }
- /**
- * Removes a Parse.Object or an array of Parse.Objects from this relation.
- *
- * @param {(Parse.Object|Array)} objects The item or items to remove.
- */
- }, {
- key: "remove",
- value: function (objects
- /*: ParseObject | Array<ParseObject | string>*/
- ) {
- if (!(0, _isArray.default)(objects)) {
- objects = [objects];
- }
- var change = new _ParseOp.RelationOp([], objects);
- if (!this.parent) {
- throw new Error('Cannot remove from a Relation without a parent');
- }
- if (objects.length === 0) {
- return;
- }
- this.parent.set(this.key, change);
- this.targetClassName = change._targetClassName;
- }
- /**
- * Returns a JSON version of the object suitable for saving to disk.
- *
- * @returns {object} JSON representation of Relation
- */
- }, {
- key: "toJSON",
- value: function ()
- /*: { __type: 'Relation', className: ?string }*/
- {
- return {
- __type: 'Relation',
- className: this.targetClassName
- };
- }
- /**
- * Returns a Parse.Query that is limited to objects in this
- * relation.
- *
- * @returns {Parse.Query} Relation Query
- */
- }, {
- key: "query",
- value: function query()
- /*: ParseQuery*/
- {
- var query;
- var parent = this.parent;
- if (!parent) {
- throw new Error('Cannot construct a query for a Relation without a parent');
- }
- if (!this.targetClassName) {
- query = new _ParseQuery.default(parent.className);
- query._extraOptions.redirectClassNameForKey = this.key;
- } else {
- query = new _ParseQuery.default(this.targetClassName);
- }
- query._addCondition('$relatedTo', 'object', {
- __type: 'Pointer',
- className: parent.className,
- objectId: parent.id
- });
- query._addCondition('$relatedTo', 'key', this.key);
- return query;
- }
- }]);
- return ParseRelation;
- }();
- var _default = ParseRelation;
- exports.default = _default;
- },{"./ParseObject":36,"./ParseOp":37,"./ParseQuery":39,"@babel/runtime-corejs3/core-js-stable/array/is-array":79,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/helpers/classCallCheck":145,"@babel/runtime-corejs3/helpers/createClass":147,"@babel/runtime-corejs3/helpers/defineProperty":148,"@babel/runtime-corejs3/helpers/interopRequireDefault":152}],41:[function(_dereq_,module,exports){
- "use strict";
- var _Reflect$construct = _dereq_("@babel/runtime-corejs3/core-js-stable/reflect/construct");
- var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
- var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
- _Object$defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = void 0;
- var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
- var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
- var _get2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/get"));
- var _inherits2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/inherits"));
- var _possibleConstructorReturn2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/possibleConstructorReturn"));
- var _getPrototypeOf2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/getPrototypeOf"));
- var _ParseACL = _interopRequireDefault(_dereq_("./ParseACL"));
- var _ParseError = _interopRequireDefault(_dereq_("./ParseError"));
- var _ParseObject2 = _interopRequireDefault(_dereq_("./ParseObject"));
- function _createSuper(Derived) {
- var hasNativeReflectConstruct = _isNativeReflectConstruct();
- return function () {
- var Super = (0, _getPrototypeOf2.default)(Derived),
- result;
- if (hasNativeReflectConstruct) {
- var NewTarget = (0, _getPrototypeOf2.default)(this).constructor;
- result = _Reflect$construct(Super, arguments, NewTarget);
- } else {
- result = Super.apply(this, arguments);
- }
- return (0, _possibleConstructorReturn2.default)(this, result);
- };
- }
- function _isNativeReflectConstruct() {
- if (typeof Reflect === "undefined" || !_Reflect$construct) return false;
- if (_Reflect$construct.sham) return false;
- if (typeof Proxy === "function") return true;
- try {
- Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {}));
- return true;
- } catch (e) {
- return false;
- }
- }
- /**
- * Represents a Role on the Parse server. Roles represent groupings of
- * Users for the purposes of granting permissions (e.g. specifying an ACL
- * for an Object). Roles are specified by their sets of child users and
- * child roles, all of which are granted any permissions that the parent
- * role has.
- *
- * <p>Roles must have a name (which cannot be changed after creation of the
- * role), and must specify an ACL.</p>
- *
- * @alias Parse.Role
- * @augments Parse.Object
- */
- var ParseRole = /*#__PURE__*/function (_ParseObject) {
- (0, _inherits2.default)(ParseRole, _ParseObject);
- var _super = _createSuper(ParseRole);
- /**
- * @param {string} name The name of the Role to create.
- * @param {Parse.ACL} acl The ACL for this role. Roles must have an ACL.
- * A Parse.Role is a local representation of a role persisted to the Parse
- * cloud.
- */
- function ParseRole(name
- /*: string*/
- , acl
- /*: ParseACL*/
- ) {
- var _this;
- (0, _classCallCheck2.default)(this, ParseRole);
- _this = _super.call(this, '_Role');
- if (typeof name === 'string' && acl instanceof _ParseACL.default) {
- _this.setName(name);
- _this.setACL(acl);
- }
- return _this;
- }
- /**
- * Gets the name of the role. You can alternatively call role.get("name")
- *
- * @returns {string} the name of the role.
- */
- (0, _createClass2.default)(ParseRole, [{
- key: "getName",
- value: function ()
- /*: ?string*/
- {
- var name = this.get('name');
- if (name == null || typeof name === 'string') {
- return name;
- }
- return '';
- }
- /**
- * Sets the name for a role. This value must be set before the role has
- * been saved to the server, and cannot be set once the role has been
- * saved.
- *
- * <p>
- * A role's name can only contain alphanumeric characters, _, -, and
- * spaces.
- * </p>
- *
- * <p>This is equivalent to calling role.set("name", name)</p>
- *
- * @param {string} name The name of the role.
- * @param {object} options Standard options object with success and error
- * callbacks.
- * @returns {(ParseObject|boolean)} true if the set succeeded.
- */
- }, {
- key: "setName",
- value: function (name
- /*: string*/
- , options
- /*:: ?: mixed*/
- )
- /*: ParseObject | boolean*/
- {
- return this.set('name', name, options);
- }
- /**
- * Gets the Parse.Relation for the Parse.Users that are direct
- * children of this role. These users are granted any privileges that this
- * role has been granted (e.g. read or write access through ACLs). You can
- * add or remove users from the role through this relation.
- *
- * <p>This is equivalent to calling role.relation("users")</p>
- *
- * @returns {Parse.Relation} the relation for the users belonging to this
- * role.
- */
- }, {
- key: "getUsers",
- value: function ()
- /*: ParseRelation*/
- {
- return this.relation('users');
- }
- /**
- * Gets the Parse.Relation for the Parse.Roles that are direct
- * children of this role. These roles' users are granted any privileges that
- * this role has been granted (e.g. read or write access through ACLs). You
- * can add or remove child roles from this role through this relation.
- *
- * <p>This is equivalent to calling role.relation("roles")</p>
- *
- * @returns {Parse.Relation} the relation for the roles belonging to this
- * role.
- */
- }, {
- key: "getRoles",
- value: function ()
- /*: ParseRelation*/
- {
- return this.relation('roles');
- }
- }, {
- key: "validate",
- value: function (attrs
- /*: AttributeMap*/
- , options
- /*:: ?: mixed*/
- )
- /*: ParseError | boolean*/
- {
- var isInvalid = (0, _get2.default)((0, _getPrototypeOf2.default)(ParseRole.prototype), "validate", this).call(this, attrs, options);
- if (isInvalid) {
- return isInvalid;
- }
- if ('name' in attrs && attrs.name !== this.getName()) {
- var newName = attrs.name;
- if (this.id && this.id !== attrs.objectId) {
- // Check to see if the objectId being set matches this.id
- // This happens during a fetch -- the id is set before calling fetch
- // Let the name be set in this case
- return new _ParseError.default(_ParseError.default.OTHER_CAUSE, "A role's name can only be set before it has been saved.");
- }
- if (typeof newName !== 'string') {
- return new _ParseError.default(_ParseError.default.OTHER_CAUSE, "A role's name must be a String.");
- }
- if (!/^[0-9a-zA-Z\-_ ]+$/.test(newName)) {
- return new _ParseError.default(_ParseError.default.OTHER_CAUSE, "A role's name can be only contain alphanumeric characters, _, -, and spaces.");
- }
- }
- return false;
- }
- }]);
- return ParseRole;
- }(_ParseObject2.default);
- _ParseObject2.default.registerSubclass('_Role', ParseRole);
- var _default = ParseRole;
- exports.default = _default;
- },{"./ParseACL":26,"./ParseError":29,"./ParseObject":36,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/core-js-stable/reflect/construct":116,"@babel/runtime-corejs3/helpers/classCallCheck":145,"@babel/runtime-corejs3/helpers/createClass":147,"@babel/runtime-corejs3/helpers/get":149,"@babel/runtime-corejs3/helpers/getPrototypeOf":150,"@babel/runtime-corejs3/helpers/inherits":151,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/helpers/possibleConstructorReturn":159}],42:[function(_dereq_,module,exports){
- "use strict";
- var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
- var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
- _Object$defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = void 0;
- var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
- var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
- var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
- var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
- var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
- var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
- var _ParseCLP = _interopRequireDefault(_dereq_("./ParseCLP"));
- /**
- * Copyright (c) 2015-present, Parse, LLC.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- *
- * @flow
- */
- var FIELD_TYPES = ['String', 'Number', 'Boolean', 'Date', 'File', 'GeoPoint', 'Polygon', 'Array', 'Object', 'Pointer', 'Relation'];
- /*:: type FieldOptions = {
- required: boolean,
- defaultValue: mixed,
- };*/
- /**
- * A Parse.Schema object is for handling schema data from Parse.
- * <p>All the schemas methods require MasterKey.
- *
- * When adding fields, you may set required and default values. (Requires Parse Server 3.7.0+)
- *
- * <pre>
- * const options = { required: true, defaultValue: 'hello world' };
- * const schema = new Parse.Schema('MyClass');
- * schema.addString('field', options);
- * schema.addIndex('index_name', { 'field': 1 });
- * schema.save();
- * </pre>
- * </p>
- *
- * @alias Parse.Schema
- */
- var ParseSchema = /*#__PURE__*/function () {
- /**
- * @param {string} className Parse Class string.
- */
- function ParseSchema(className
- /*: string*/
- ) {
- (0, _classCallCheck2.default)(this, ParseSchema);
- (0, _defineProperty2.default)(this, "className", void 0);
- (0, _defineProperty2.default)(this, "_fields", void 0);
- (0, _defineProperty2.default)(this, "_indexes", void 0);
- (0, _defineProperty2.default)(this, "_clp", void 0);
- if (typeof className === 'string') {
- if (className === 'User' && _CoreManager.default.get('PERFORM_USER_REWRITE')) {
- this.className = '_User';
- } else {
- this.className = className;
- }
- }
- this._fields = {};
- this._indexes = {};
- }
- /**
- * Static method to get all schemas
- *
- * @returns {Promise} A promise that is resolved with the result when
- * the query completes.
- */
- (0, _createClass2.default)(ParseSchema, [{
- key: "get",
- value:
- /**
- * Get the Schema from Parse
- *
- * @returns {Promise} A promise that is resolved with the result when
- * the query completes.
- */
- function () {
- this.assertClassName();
- var controller = _CoreManager.default.getSchemaController();
- return controller.get(this.className).then(function (response) {
- if (!response) {
- throw new Error('Schema not found.');
- }
- return response;
- });
- }
- /**
- * Create a new Schema on Parse
- *
- * @returns {Promise} A promise that is resolved with the result when
- * the query completes.
- */
- }, {
- key: "save",
- value: function () {
- this.assertClassName();
- var controller = _CoreManager.default.getSchemaController();
- var params = {
- className: this.className,
- fields: this._fields,
- indexes: this._indexes,
- classLevelPermissions: this._clp
- };
- return controller.create(this.className, params);
- }
- /**
- * Update a Schema on Parse
- *
- * @returns {Promise} A promise that is resolved with the result when
- * the query completes.
- */
- }, {
- key: "update",
- value: function () {
- this.assertClassName();
- var controller = _CoreManager.default.getSchemaController();
- var params = {
- className: this.className,
- fields: this._fields,
- indexes: this._indexes,
- classLevelPermissions: this._clp
- };
- this._fields = {};
- this._indexes = {};
- return controller.update(this.className, params);
- }
- /**
- * Removing a Schema from Parse
- * Can only be used on Schema without objects
- *
- * @returns {Promise} A promise that is resolved with the result when
- * the query completes.
- */
- }, {
- key: "delete",
- value: function () {
- this.assertClassName();
- var controller = _CoreManager.default.getSchemaController();
- return controller.delete(this.className);
- }
- /**
- * Removes all objects from a Schema (class) in Parse.
- * EXERCISE CAUTION, running this will delete all objects for this schema and cannot be reversed
- *
- * @returns {Promise} A promise that is resolved with the result when
- * the query completes.
- */
- }, {
- key: "purge",
- value: function () {
- this.assertClassName();
- var controller = _CoreManager.default.getSchemaController();
- return controller.purge(this.className);
- }
- /**
- * Assert if ClassName has been filled
- *
- * @private
- */
- }, {
- key: "assertClassName",
- value: function () {
- if (!this.className) {
- throw new Error('You must set a Class Name before making any request.');
- }
- }
- /**
- * Sets Class Level Permissions when creating / updating a Schema.
- * EXERCISE CAUTION, running this may override CLP for this schema and cannot be reversed
- *
- * @param {object | Parse.CLP} clp Class Level Permissions
- * @returns {Parse.Schema} Returns the schema, so you can chain this call.
- */
- }, {
- key: "setCLP",
- value: function (clp
- /*: PermissionsMap | ParseCLP*/
- ) {
- if (clp instanceof _ParseCLP.default) {
- this._clp = clp.toJSON();
- } else {
- this._clp = clp;
- }
- return this;
- }
- /**
- * Adding a Field to Create / Update a Schema
- *
- * @param {string} name Name of the field that will be created on Parse
- * @param {string} type Can be a (String|Number|Boolean|Date|Parse.File|Parse.GeoPoint|Array|Object|Pointer|Parse.Relation)
- * @param {object} options
- * Valid options are:<ul>
- * <li>required: If field is not set, save operation fails (Requires Parse Server 3.7.0+)
- * <li>defaultValue: If field is not set, a default value is selected (Requires Parse Server 3.7.0+)
- * </ul>
- * @returns {Parse.Schema} Returns the schema, so you can chain this call.
- */
- }, {
- key: "addField",
- value: function (name
- /*: string*/
- , type
- /*: string*/
- ) {
- var options
- /*: FieldOptions*/
- = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
- type = type || 'String';
- if (!name) {
- throw new Error('field name may not be null.');
- }
- if ((0, _indexOf.default)(FIELD_TYPES).call(FIELD_TYPES, type) === -1) {
- throw new Error("".concat(type, " is not a valid type."));
- }
- var fieldOptions = {
- type: type
- };
- if (typeof options.required === 'boolean') {
- fieldOptions.required = options.required;
- }
- if (options.defaultValue !== undefined) {
- fieldOptions.defaultValue = options.defaultValue;
- }
- this._fields[name] = fieldOptions;
- return this;
- }
- /**
- * Adding an Index to Create / Update a Schema
- *
- * @param {string} name Name of the index
- * @param {object} index { field: value }
- * @returns {Parse.Schema} Returns the schema, so you can chain this call.
- *
- * <pre>
- * schema.addIndex('index_name', { 'field': 1 });
- * </pre>
- */
- }, {
- key: "addIndex",
- value: function (name
- /*: string*/
- , index
- /*: any*/
- ) {
- if (!name) {
- throw new Error('index name may not be null.');
- }
- if (!index) {
- throw new Error('index may not be null.');
- }
- this._indexes[name] = index;
- return this;
- }
- /**
- * Adding String Field
- *
- * @param {string} name Name of the field that will be created on Parse
- * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
- * @returns {Parse.Schema} Returns the schema, so you can chain this call.
- */
- }, {
- key: "addString",
- value: function (name
- /*: string*/
- , options
- /*: FieldOptions*/
- ) {
- return this.addField(name, 'String', options);
- }
- /**
- * Adding Number Field
- *
- * @param {string} name Name of the field that will be created on Parse
- * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
- * @returns {Parse.Schema} Returns the schema, so you can chain this call.
- */
- }, {
- key: "addNumber",
- value: function (name
- /*: string*/
- , options
- /*: FieldOptions*/
- ) {
- return this.addField(name, 'Number', options);
- }
- /**
- * Adding Boolean Field
- *
- * @param {string} name Name of the field that will be created on Parse
- * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
- * @returns {Parse.Schema} Returns the schema, so you can chain this call.
- */
- }, {
- key: "addBoolean",
- value: function (name
- /*: string*/
- , options
- /*: FieldOptions*/
- ) {
- return this.addField(name, 'Boolean', options);
- }
- /**
- * Adding Date Field
- *
- * @param {string} name Name of the field that will be created on Parse
- * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
- * @returns {Parse.Schema} Returns the schema, so you can chain this call.
- */
- }, {
- key: "addDate",
- value: function (name
- /*: string*/
- , options
- /*: FieldOptions*/
- ) {
- if (options && options.defaultValue) {
- options.defaultValue = {
- __type: 'Date',
- iso: new Date(options.defaultValue)
- };
- }
- return this.addField(name, 'Date', options);
- }
- /**
- * Adding File Field
- *
- * @param {string} name Name of the field that will be created on Parse
- * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
- * @returns {Parse.Schema} Returns the schema, so you can chain this call.
- */
- }, {
- key: "addFile",
- value: function (name
- /*: string*/
- , options
- /*: FieldOptions*/
- ) {
- return this.addField(name, 'File', options);
- }
- /**
- * Adding GeoPoint Field
- *
- * @param {string} name Name of the field that will be created on Parse
- * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
- * @returns {Parse.Schema} Returns the schema, so you can chain this call.
- */
- }, {
- key: "addGeoPoint",
- value: function (name
- /*: string*/
- , options
- /*: FieldOptions*/
- ) {
- return this.addField(name, 'GeoPoint', options);
- }
- /**
- * Adding Polygon Field
- *
- * @param {string} name Name of the field that will be created on Parse
- * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
- * @returns {Parse.Schema} Returns the schema, so you can chain this call.
- */
- }, {
- key: "addPolygon",
- value: function (name
- /*: string*/
- , options
- /*: FieldOptions*/
- ) {
- return this.addField(name, 'Polygon', options);
- }
- /**
- * Adding Array Field
- *
- * @param {string} name Name of the field that will be created on Parse
- * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
- * @returns {Parse.Schema} Returns the schema, so you can chain this call.
- */
- }, {
- key: "addArray",
- value: function (name
- /*: string*/
- , options
- /*: FieldOptions*/
- ) {
- return this.addField(name, 'Array', options);
- }
- /**
- * Adding Object Field
- *
- * @param {string} name Name of the field that will be created on Parse
- * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
- * @returns {Parse.Schema} Returns the schema, so you can chain this call.
- */
- }, {
- key: "addObject",
- value: function (name
- /*: string*/
- , options
- /*: FieldOptions*/
- ) {
- return this.addField(name, 'Object', options);
- }
- /**
- * Adding Pointer Field
- *
- * @param {string} name Name of the field that will be created on Parse
- * @param {string} targetClass Name of the target Pointer Class
- * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
- * @returns {Parse.Schema} Returns the schema, so you can chain this call.
- */
- }, {
- key: "addPointer",
- value: function (name
- /*: string*/
- , targetClass
- /*: string*/
- ) {
- var options
- /*: FieldOptions*/
- = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
- if (!name) {
- throw new Error('field name may not be null.');
- }
- if (!targetClass) {
- throw new Error('You need to set the targetClass of the Pointer.');
- }
- var fieldOptions = {
- type: 'Pointer',
- targetClass: targetClass
- };
- if (typeof options.required === 'boolean') {
- fieldOptions.required = options.required;
- }
- if (options.defaultValue !== undefined) {
- fieldOptions.defaultValue = options.defaultValue;
- if (options.defaultValue instanceof _ParseObject.default) {
- fieldOptions.defaultValue = options.defaultValue.toPointer();
- }
- }
- this._fields[name] = fieldOptions;
- return this;
- }
- /**
- * Adding Relation Field
- *
- * @param {string} name Name of the field that will be created on Parse
- * @param {string} targetClass Name of the target Pointer Class
- * @returns {Parse.Schema} Returns the schema, so you can chain this call.
- */
- }, {
- key: "addRelation",
- value: function (name
- /*: string*/
- , targetClass
- /*: string*/
- ) {
- if (!name) {
- throw new Error('field name may not be null.');
- }
- if (!targetClass) {
- throw new Error('You need to set the targetClass of the Relation.');
- }
- this._fields[name] = {
- type: 'Relation',
- targetClass: targetClass
- };
- return this;
- }
- /**
- * Deleting a Field to Update on a Schema
- *
- * @param {string} name Name of the field
- * @returns {Parse.Schema} Returns the schema, so you can chain this call.
- */
- }, {
- key: "deleteField",
- value: function (name
- /*: string*/
- ) {
- this._fields[name] = {
- __op: 'Delete'
- };
- return this;
- }
- /**
- * Deleting an Index to Update on a Schema
- *
- * @param {string} name Name of the field
- * @returns {Parse.Schema} Returns the schema, so you can chain this call.
- */
- }, {
- key: "deleteIndex",
- value: function (name
- /*: string*/
- ) {
- this._indexes[name] = {
- __op: 'Delete'
- };
- return this;
- }
- }], [{
- key: "all",
- value: function () {
- var controller = _CoreManager.default.getSchemaController();
- return controller.get('').then(function (response) {
- if (response.results.length === 0) {
- throw new Error('Schema not found.');
- }
- return response.results;
- });
- }
- }]);
- return ParseSchema;
- }();
- var DefaultController = {
- send: function (className
- /*: string*/
- , method
- /*: string*/
- )
- /*: Promise*/
- {
- var params
- /*: any*/
- = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
- var RESTController = _CoreManager.default.getRESTController();
- return RESTController.request(method, "schemas/".concat(className), params, {
- useMasterKey: true
- });
- },
- get: function (className
- /*: string*/
- )
- /*: Promise*/
- {
- return this.send(className, 'GET');
- },
- create: function (className
- /*: string*/
- , params
- /*: any*/
- )
- /*: Promise*/
- {
- return this.send(className, 'POST', params);
- },
- update: function (className
- /*: string*/
- , params
- /*: any*/
- )
- /*: Promise*/
- {
- return this.send(className, 'PUT', params);
- },
- delete: function (className
- /*: string*/
- )
- /*: Promise*/
- {
- return this.send(className, 'DELETE');
- },
- purge: function (className
- /*: string*/
- )
- /*: Promise*/
- {
- var RESTController = _CoreManager.default.getRESTController();
- return RESTController.request('DELETE', "purge/".concat(className), {}, {
- useMasterKey: true
- });
- }
- };
- _CoreManager.default.setSchemaController(DefaultController);
- var _default = ParseSchema;
- exports.default = _default;
- },{"./CoreManager":5,"./ParseCLP":27,"./ParseObject":36,"@babel/runtime-corejs3/core-js-stable/instance/index-of":88,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/helpers/classCallCheck":145,"@babel/runtime-corejs3/helpers/createClass":147,"@babel/runtime-corejs3/helpers/defineProperty":148,"@babel/runtime-corejs3/helpers/interopRequireDefault":152}],43:[function(_dereq_,module,exports){
- "use strict";
- var _Reflect$construct = _dereq_("@babel/runtime-corejs3/core-js-stable/reflect/construct");
- var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
- var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
- _Object$defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = void 0;
- var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
- var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
- var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
- var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
- var _inherits2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/inherits"));
- var _possibleConstructorReturn2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/possibleConstructorReturn"));
- var _getPrototypeOf2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/getPrototypeOf"));
- var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
- var _isRevocableSession = _interopRequireDefault(_dereq_("./isRevocableSession"));
- var _ParseObject2 = _interopRequireDefault(_dereq_("./ParseObject"));
- var _ParseUser = _interopRequireDefault(_dereq_("./ParseUser"));
- function _createSuper(Derived) {
- var hasNativeReflectConstruct = _isNativeReflectConstruct();
- return function () {
- var Super = (0, _getPrototypeOf2.default)(Derived),
- result;
- if (hasNativeReflectConstruct) {
- var NewTarget = (0, _getPrototypeOf2.default)(this).constructor;
- result = _Reflect$construct(Super, arguments, NewTarget);
- } else {
- result = Super.apply(this, arguments);
- }
- return (0, _possibleConstructorReturn2.default)(this, result);
- };
- }
- function _isNativeReflectConstruct() {
- if (typeof Reflect === "undefined" || !_Reflect$construct) return false;
- if (_Reflect$construct.sham) return false;
- if (typeof Proxy === "function") return true;
- try {
- Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {}));
- return true;
- } catch (e) {
- return false;
- }
- }
- /**
- * <p>A Parse.Session object is a local representation of a revocable session.
- * This class is a subclass of a Parse.Object, and retains the same
- * functionality of a Parse.Object.</p>
- *
- * @alias Parse.Session
- * @augments Parse.Object
- */
- var ParseSession = /*#__PURE__*/function (_ParseObject) {
- (0, _inherits2.default)(ParseSession, _ParseObject);
- var _super = _createSuper(ParseSession);
- /**
- * @param {object} attributes The initial set of data to store in the user.
- */
- function ParseSession(attributes
- /*: ?AttributeMap*/
- ) {
- var _this;
- (0, _classCallCheck2.default)(this, ParseSession);
- _this = _super.call(this, '_Session');
- if (attributes && (0, _typeof2.default)(attributes) === 'object') {
- if (!_this.set(attributes || {})) {
- throw new Error("Can't create an invalid Session");
- }
- }
- return _this;
- }
- /**
- * Returns the session token string.
- *
- * @returns {string}
- */
- (0, _createClass2.default)(ParseSession, [{
- key: "getSessionToken",
- value: function ()
- /*: string*/
- {
- var token = this.get('sessionToken');
- if (typeof token === 'string') {
- return token;
- }
- return '';
- }
- }], [{
- key: "readOnlyAttributes",
- value: function () {
- return ['createdWith', 'expiresAt', 'installationId', 'restricted', 'sessionToken', 'user'];
- }
- /**
- * Retrieves the Session object for the currently logged in session.
- *
- * @param {object} options useMasterKey
- * @static
- * @returns {Promise} A promise that is resolved with the Parse.Session
- * object after it has been fetched. If there is no current user, the
- * promise will be rejected.
- */
- }, {
- key: "current",
- value: function (options
- /*: FullOptions*/
- ) {
- options = options || {};
- var controller = _CoreManager.default.getSessionController();
- var sessionOptions = {};
- if (options.hasOwnProperty('useMasterKey')) {
- sessionOptions.useMasterKey = options.useMasterKey;
- }
- return _ParseUser.default.currentAsync().then(function (user) {
- if (!user) {
- return _promise.default.reject('There is no current user.');
- }
- sessionOptions.sessionToken = user.getSessionToken();
- return controller.getSession(sessionOptions);
- });
- }
- /**
- * Determines whether the current session token is revocable.
- * This method is useful for migrating Express.js or Node.js web apps to
- * use revocable sessions. If you are migrating an app that uses the Parse
- * SDK in the browser only, please use Parse.User.enableRevocableSession()
- * instead, so that sessions can be automatically upgraded.
- *
- * @static
- * @returns {boolean}
- */
- }, {
- key: "isCurrentSessionRevocable",
- value: function ()
- /*: boolean*/
- {
- var currentUser = _ParseUser.default.current();
- if (currentUser) {
- return (0, _isRevocableSession.default)(currentUser.getSessionToken() || '');
- }
- return false;
- }
- }]);
- return ParseSession;
- }(_ParseObject2.default);
- _ParseObject2.default.registerSubclass('_Session', ParseSession);
- var DefaultController = {
- getSession: function (options
- /*: RequestOptions*/
- )
- /*: Promise<ParseSession>*/
- {
- var RESTController = _CoreManager.default.getRESTController();
- var session = new ParseSession();
- return RESTController.request('GET', 'sessions/me', {}, options).then(function (sessionData) {
- session._finishFetch(sessionData);
- session._setExisted(true);
- return session;
- });
- }
- };
- _CoreManager.default.setSessionController(DefaultController);
- var _default = ParseSession;
- exports.default = _default;
- },{"./CoreManager":5,"./ParseObject":36,"./ParseUser":44,"./isRevocableSession":70,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/core-js-stable/promise":115,"@babel/runtime-corejs3/core-js-stable/reflect/construct":116,"@babel/runtime-corejs3/helpers/classCallCheck":145,"@babel/runtime-corejs3/helpers/createClass":147,"@babel/runtime-corejs3/helpers/getPrototypeOf":150,"@babel/runtime-corejs3/helpers/inherits":151,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/helpers/possibleConstructorReturn":159,"@babel/runtime-corejs3/helpers/typeof":164}],44:[function(_dereq_,module,exports){
- "use strict";
- var _Reflect$construct = _dereq_("@babel/runtime-corejs3/core-js-stable/reflect/construct");
- var _Object$defineProperty2 = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
- var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
- _Object$defineProperty2(exports, "__esModule", {
- value: true
- });
- exports.default = void 0;
- var _regenerator = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/regenerator"));
- var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
- var _defineProperty = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property"));
- var _stringify = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/json/stringify"));
- var _asyncToGenerator2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/asyncToGenerator"));
- var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
- var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
- var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
- var _get2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/get"));
- var _inherits2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/inherits"));
- var _possibleConstructorReturn2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/possibleConstructorReturn"));
- var _getPrototypeOf2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/getPrototypeOf"));
- var _AnonymousUtils = _interopRequireDefault(_dereq_("./AnonymousUtils"));
- var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
- var _isRevocableSession = _interopRequireDefault(_dereq_("./isRevocableSession"));
- var _ParseError = _interopRequireDefault(_dereq_("./ParseError"));
- var _ParseObject2 = _interopRequireDefault(_dereq_("./ParseObject"));
- var _ParseSession = _interopRequireDefault(_dereq_("./ParseSession"));
- var _MoralisWeb = _interopRequireDefault(_dereq_("./MoralisWeb3"));
- var _Storage = _interopRequireDefault(_dereq_("./Storage"));
- function _createSuper(Derived) {
- var hasNativeReflectConstruct = _isNativeReflectConstruct();
- return function () {
- var Super = (0, _getPrototypeOf2.default)(Derived),
- result;
- if (hasNativeReflectConstruct) {
- var NewTarget = (0, _getPrototypeOf2.default)(this).constructor;
- result = _Reflect$construct(Super, arguments, NewTarget);
- } else {
- result = Super.apply(this, arguments);
- }
- return (0, _possibleConstructorReturn2.default)(this, result);
- };
- }
- function _isNativeReflectConstruct() {
- if (typeof Reflect === "undefined" || !_Reflect$construct) return false;
- if (_Reflect$construct.sham) return false;
- if (typeof Proxy === "function") return true;
- try {
- Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {}));
- return true;
- } catch (e) {
- return false;
- }
- }
- var CURRENT_USER_KEY = 'currentUser';
- var canUseCurrentUser = !_CoreManager.default.get('IS_NODE');
- var currentUserCacheMatchesDisk = false;
- var currentUserCache = null;
- var authProviders = {};
- /**
- * <p>A Parse.User object is a local representation of a user persisted to the
- * Parse cloud. This class is a subclass of a Parse.Object, and retains the
- * same functionality of a Parse.Object, but also extends it with various
- * user specific methods, like authentication, signing up, and validation of
- * uniqueness.</p>
- *
- * @alias Parse.User
- * @augments Parse.Object
- */
- var ParseUser = /*#__PURE__*/function (_ParseObject) {
- (0, _inherits2.default)(ParseUser, _ParseObject);
- var _super = _createSuper(ParseUser);
- /**
- * @param {object} attributes The initial set of data to store in the user.
- */
- function ParseUser(attributes
- /*: ?AttributeMap*/
- ) {
- var _this;
- (0, _classCallCheck2.default)(this, ParseUser);
- _this = _super.call(this, '_User');
- if (attributes && (0, _typeof2.default)(attributes) === 'object') {
- if (!_this.set(attributes || {})) {
- throw new Error("Can't create an invalid Parse User");
- }
- }
- return _this;
- }
- /**
- * Request a revocable session token to replace the older style of token.
- *
- * @param {object} options
- * @returns {Promise} A promise that is resolved when the replacement
- * token has been fetched.
- */
- (0, _createClass2.default)(ParseUser, [{
- key: "_upgradeToRevocableSession",
- value: function (options
- /*: RequestOptions*/
- )
- /*: Promise<void>*/
- {
- options = options || {};
- var upgradeOptions = {};
- if (options.hasOwnProperty('useMasterKey')) {
- upgradeOptions.useMasterKey = options.useMasterKey;
- }
- var controller = _CoreManager.default.getUserController();
- return controller.upgradeToRevocableSession(this, upgradeOptions);
- }
- /**
- * Parse allows you to link your users with {@link https://docs.parseplatform.org/parse-server/guide/#oauth-and-3rd-party-authentication 3rd party authentication}, enabling
- * your users to sign up or log into your application using their existing identities.
- * Since 2.9.0
- *
- * @see {@link https://docs.parseplatform.org/js/guide/#linking-users Linking Users}
- * @param {string | AuthProvider} provider Name of auth provider or {@link https://parseplatform.org/Parse-SDK-JS/api/master/AuthProvider.html AuthProvider}
- * @param {object} options
- * <ul>
- * <li>If provider is string, options is {@link http://docs.parseplatform.org/parse-server/guide/#supported-3rd-party-authentications authData}
- * <li>If provider is AuthProvider, options is saveOpts
- * </ul>
- * @param {object} saveOpts useMasterKey / sessionToken
- * @returns {Promise} A promise that is fulfilled with the user is linked
- */
- }, {
- key: "linkWith",
- value: function (provider
- /*: any*/
- , options
- /*: { authData?: AuthData }*/
- )
- /*: Promise<ParseUser>*/
- {
- var _this2 = this;
- var saveOpts
- /*:: ?: FullOptions*/
- = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
- saveOpts.sessionToken = saveOpts.sessionToken || this.getSessionToken() || '';
- var authType;
- if (typeof provider === 'string') {
- authType = provider;
- if (authProviders[provider]) {
- provider = authProviders[provider];
- } else {
- var authProvider = {
- restoreAuthentication: function () {
- return true;
- },
- getAuthType: function () {
- return authType;
- }
- };
- authProviders[authProvider.getAuthType()] = authProvider;
- provider = authProvider;
- }
- } else {
- authType = provider.getAuthType();
- }
- if (options && options.hasOwnProperty('authData')) {
- var authData = this.get('authData') || {};
- if ((0, _typeof2.default)(authData) !== 'object') {
- throw new Error('Invalid type: authData field should be an object');
- }
- authData[authType] = options.authData;
- var controller = _CoreManager.default.getUserController();
- return controller.linkWith(this, authData, saveOpts);
- }
- return new _promise.default(function (resolve, reject) {
- provider.authenticate({
- success: function (provider, result) {
- var opts = {};
- opts.authData = result;
- _this2.linkWith(provider, opts, saveOpts).then(function () {
- resolve(_this2);
- }, function (error) {
- reject(error);
- });
- },
- error: function (provider, _error) {
- reject(_error);
- }
- });
- });
- }
- /**
- * @param provider
- * @param options
- * @param saveOpts
- * @deprecated since 2.9.0 see {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.User.html#linkWith linkWith}
- * @returns {Promise}
- */
- }, {
- key: "_linkWith",
- value: function (provider
- /*: any*/
- , options
- /*: { authData?: AuthData }*/
- )
- /*: Promise<ParseUser>*/
- {
- var saveOpts
- /*:: ?: FullOptions*/
- = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
- return this.linkWith(provider, options, saveOpts);
- }
- /**
- * Synchronizes auth data for a provider (e.g. puts the access token in the
- * right place to be used by the Facebook SDK).
- *
- * @param provider
- */
- }, {
- key: "_synchronizeAuthData",
- value: function (provider
- /*: string*/
- ) {
- if (!this.isCurrent() || !provider) {
- return;
- }
- var authType;
- if (typeof provider === 'string') {
- authType = provider;
- provider = authProviders[authType];
- } else {
- authType = provider.getAuthType();
- }
- var authData = this.get('authData');
- if (!provider || !authData || (0, _typeof2.default)(authData) !== 'object') {
- return;
- }
- var success = provider.restoreAuthentication(authData[authType]);
- if (!success) {
- this._unlinkFrom(provider);
- }
- }
- /**
- * Synchronizes authData for all providers.
- */
- }, {
- key: "_synchronizeAllAuthData",
- value: function () {
- var authData = this.get('authData');
- if ((0, _typeof2.default)(authData) !== 'object') {
- return;
- }
- for (var _key in authData) {
- this._synchronizeAuthData(_key);
- }
- }
- /**
- * Removes null values from authData (which exist temporarily for unlinking)
- */
- }, {
- key: "_cleanupAuthData",
- value: function () {
- if (!this.isCurrent()) {
- return;
- }
- var authData = this.get('authData');
- if ((0, _typeof2.default)(authData) !== 'object') {
- return;
- }
- for (var _key2 in authData) {
- if (!authData[_key2]) {
- delete authData[_key2];
- }
- }
- }
- /**
- * Unlinks a user from a service.
- *
- * @param {string | AuthProvider} provider Name of auth provider or {@link https://parseplatform.org/Parse-SDK-JS/api/master/AuthProvider.html AuthProvider}
- * @param {object} options MasterKey / SessionToken
- * @returns {Promise} A promise that is fulfilled when the unlinking
- * finishes.
- */
- }, {
- key: "_unlinkFrom",
- value: function (provider
- /*: any*/
- , options
- /*:: ?: FullOptions*/
- )
- /*: Promise<ParseUser>*/
- {
- var _this3 = this;
- return this.linkWith(provider, {
- authData: null
- }, options).then(function () {
- _this3._synchronizeAuthData(provider);
- return _promise.default.resolve(_this3);
- });
- }
- /**
- * Checks whether a user is linked to a service.
- *
- * @param {object} provider service to link to
- * @returns {boolean} true if link was successful
- */
- }, {
- key: "_isLinked",
- value: function (provider
- /*: any*/
- )
- /*: boolean*/
- {
- var authType;
- if (typeof provider === 'string') {
- authType = provider;
- } else {
- authType = provider.getAuthType();
- }
- var authData = this.get('authData') || {};
- if ((0, _typeof2.default)(authData) !== 'object') {
- return false;
- }
- return !!authData[authType];
- }
- /**
- * Deauthenticates all providers.
- */
- }, {
- key: "_logOutWithAll",
- value: function () {
- var authData = this.get('authData');
- if ((0, _typeof2.default)(authData) !== 'object') {
- return;
- }
- for (var _key3 in authData) {
- this._logOutWith(_key3);
- }
- }
- /**
- * Deauthenticates a single provider (e.g. removing access tokens from the
- * Facebook SDK).
- *
- * @param {object} provider service to logout of
- */
- }, {
- key: "_logOutWith",
- value: function (provider
- /*: any*/
- ) {
- if (!this.isCurrent()) {
- return;
- }
- if (typeof provider === 'string') {
- provider = authProviders[provider];
- }
- if (provider && provider.deauthenticate) {
- provider.deauthenticate();
- }
- }
- /**
- * Class instance method used to maintain specific keys when a fetch occurs.
- * Used to ensure that the session token is not lost.
- *
- * @returns {object} sessionToken
- */
- }, {
- key: "_preserveFieldsOnFetch",
- value: function ()
- /*: AttributeMap*/
- {
- return {
- sessionToken: this.get('sessionToken')
- };
- }
- /**
- * Returns true if <code>current</code> would return this user.
- *
- * @returns {boolean} true if user is cached on disk
- */
- }, {
- key: "isCurrent",
- value: function ()
- /*: boolean*/
- {
- var current = ParseUser.current();
- return !!current && current.id === this.id;
- }
- /**
- * Returns get("username").
- *
- * @returns {string}
- */
- }, {
- key: "getUsername",
- value: function ()
- /*: ?string*/
- {
- var username = this.get('username');
- if (username == null || typeof username === 'string') {
- return username;
- }
- return '';
- }
- /**
- * Calls set("username", username, options) and returns the result.
- *
- * @param {string} username
- */
- }, {
- key: "setUsername",
- value: function (username
- /*: string*/
- ) {
- // Strip anonymity, even we do not support anonymous user in js SDK, we may
- // encounter anonymous user created by android/iOS in cloud code.
- var authData = this.get('authData');
- if (authData && (0, _typeof2.default)(authData) === 'object' && authData.hasOwnProperty('anonymous')) {
- // We need to set anonymous to null instead of deleting it in order to remove it from Parse.
- authData.anonymous = null;
- }
- this.set('username', username);
- }
- /**
- * Calls set("password", password, options) and returns the result.
- *
- * @param {string} password User's Password
- */
- }, {
- key: "setPassword",
- value: function (password
- /*: string*/
- ) {
- this.set('password', password);
- }
- /**
- * Returns get("email").
- *
- * @returns {string} User's Email
- */
- }, {
- key: "getEmail",
- value: function ()
- /*: ?string*/
- {
- var email = this.get('email');
- if (email == null || typeof email === 'string') {
- return email;
- }
- return '';
- }
- /**
- * Calls set("email", email) and returns the result.
- *
- * @param {string} email
- * @returns {boolean}
- */
- }, {
- key: "setEmail",
- value: function (email
- /*: string*/
- ) {
- return this.set('email', email);
- }
- /**
- * Returns the session token for this user, if the user has been logged in,
- * or if it is the result of a query with the master key. Otherwise, returns
- * undefined.
- *
- * @returns {string} the session token, or undefined
- */
- }, {
- key: "getSessionToken",
- value: function ()
- /*: ?string*/
- {
- var token = this.get('sessionToken');
- if (token == null || typeof token === 'string') {
- return token;
- }
- return '';
- }
- /**
- * Checks whether this user is the current user and has been authenticated.
- *
- * @returns {boolean} whether this user is the current user and is logged in.
- */
- }, {
- key: "authenticated",
- value: function ()
- /*: boolean*/
- {
- var current = ParseUser.current();
- return !!this.get('sessionToken') && !!current && current.id === this.id;
- }
- /**
- * Signs up a new user. You should call this instead of save for
- * new Parse.Users. This will create a new Parse.User on the server, and
- * also persist the session on disk so that you can access the user using
- * <code>current</code>.
- *
- * <p>A username and password must be set before calling signUp.</p>
- *
- * @param {object} attrs Extra fields to set on the new user, or null.
- * @param {object} options
- * @returns {Promise} A promise that is fulfilled when the signup
- * finishes.
- */
- }, {
- key: "signUp",
- value: function (attrs
- /*: AttributeMap*/
- , options
- /*:: ?: FullOptions*/
- )
- /*: Promise<ParseUser>*/
- {
- options = options || {};
- var signupOptions = {};
- if (options.hasOwnProperty('useMasterKey')) {
- signupOptions.useMasterKey = options.useMasterKey;
- }
- if (options.hasOwnProperty('installationId')) {
- signupOptions.installationId = options.installationId;
- }
- var controller = _CoreManager.default.getUserController();
- return controller.signUp(this, attrs, signupOptions);
- }
- /**
- * Logs in a Parse.User. On success, this saves the session to disk,
- * so you can retrieve the currently logged in user using
- * <code>current</code>.
- *
- * <p>A username and password must be set before calling logIn.</p>
- *
- * @param {object} options
- * @returns {Promise} A promise that is fulfilled with the user when
- * the login is complete.
- */
- }, {
- key: "logIn",
- value: function (options
- /*:: ?: FullOptions*/
- )
- /*: Promise<ParseUser>*/
- {
- options = options || {};
- var loginOptions = {
- usePost: true
- };
- if (options.hasOwnProperty('useMasterKey')) {
- loginOptions.useMasterKey = options.useMasterKey;
- }
- if (options.hasOwnProperty('installationId')) {
- loginOptions.installationId = options.installationId;
- }
- if (options.hasOwnProperty('usePost')) {
- loginOptions.usePost = options.usePost;
- }
- var controller = _CoreManager.default.getUserController();
- return controller.logIn(this, loginOptions);
- }
- /**
- * Wrap the default save behavior with functionality to save to local
- * storage if this is current user.
- *
- * @param {...any} args
- * @returns {Promise}
- */
- }, {
- key: "save",
- value: function ()
- /*: Promise<ParseUser>*/
- {
- var _this4 = this;
- for (var _len = arguments.length, args = new Array(_len), _key4 = 0; _key4 < _len; _key4++) {
- args[_key4] = arguments[_key4];
- }
- return (0, _get2.default)((0, _getPrototypeOf2.default)(ParseUser.prototype), "save", this).apply(this, args).then(function () {
- if (_this4.isCurrent()) {
- return _CoreManager.default.getUserController().updateUserOnDisk(_this4);
- }
- return _this4;
- });
- }
- /**
- * Wrap the default destroy behavior with functionality that logs out
- * the current user when it is destroyed
- *
- * @param {...any} args
- * @returns {Parse.User}
- */
- }, {
- key: "destroy",
- value: function ()
- /*: Promise<ParseUser>*/
- {
- var _this5 = this;
- for (var _len2 = arguments.length, args = new Array(_len2), _key5 = 0; _key5 < _len2; _key5++) {
- args[_key5] = arguments[_key5];
- }
- return (0, _get2.default)((0, _getPrototypeOf2.default)(ParseUser.prototype), "destroy", this).apply(this, args).then(function () {
- if (_this5.isCurrent()) {
- return _CoreManager.default.getUserController().removeUserFromDisk();
- }
- return _this5;
- });
- }
- /**
- * Wrap the default fetch behavior with functionality to save to local
- * storage if this is current user.
- *
- * @param {...any} args
- * @returns {Parse.User}
- */
- }, {
- key: "fetch",
- value: function ()
- /*: Promise<ParseUser>*/
- {
- var _this6 = this;
- for (var _len3 = arguments.length, args = new Array(_len3), _key6 = 0; _key6 < _len3; _key6++) {
- args[_key6] = arguments[_key6];
- }
- return (0, _get2.default)((0, _getPrototypeOf2.default)(ParseUser.prototype), "fetch", this).apply(this, args).then(function () {
- if (_this6.isCurrent()) {
- return _CoreManager.default.getUserController().updateUserOnDisk(_this6);
- }
- return _this6;
- });
- }
- /**
- * Wrap the default fetchWithInclude behavior with functionality to save to local
- * storage if this is current user.
- *
- * @param {...any} args
- * @returns {Parse.User}
- */
- }, {
- key: "fetchWithInclude",
- value: function ()
- /*: Promise<ParseUser>*/
- {
- var _this7 = this;
- for (var _len4 = arguments.length, args = new Array(_len4), _key7 = 0; _key7 < _len4; _key7++) {
- args[_key7] = arguments[_key7];
- }
- return (0, _get2.default)((0, _getPrototypeOf2.default)(ParseUser.prototype), "fetchWithInclude", this).apply(this, args).then(function () {
- if (_this7.isCurrent()) {
- return _CoreManager.default.getUserController().updateUserOnDisk(_this7);
- }
- return _this7;
- });
- }
- /**
- * Verify whether a given password is the password of the current user.
- *
- * @param {string} password A password to be verified
- * @param {object} options
- * @returns {Promise} A promise that is fulfilled with a user
- * when the password is correct.
- */
- }, {
- key: "verifyPassword",
- value: function (password
- /*: string*/
- , options
- /*:: ?: RequestOptions*/
- )
- /*: Promise<ParseUser>*/
- {
- var username = this.getUsername() || '';
- return ParseUser.verifyPassword(username, password, options);
- }
- }], [{
- key: "readOnlyAttributes",
- value: function () {
- return ['sessionToken'];
- }
- /**
- * Adds functionality to the existing Parse.User class.
- *
- * @param {object} protoProps A set of properties to add to the prototype
- * @param {object} classProps A set of static properties to add to the class
- * @static
- * @returns {Parse.User} The newly extended Parse.User class
- */
- }, {
- key: "extend",
- value: function (protoProps
- /*: { [prop: string]: any }*/
- , classProps
- /*: { [prop: string]: any }*/
- ) {
- if (protoProps) {
- for (var _prop in protoProps) {
- if (_prop !== 'className') {
- (0, _defineProperty.default)(ParseUser.prototype, _prop, {
- value: protoProps[_prop],
- enumerable: false,
- writable: true,
- configurable: true
- });
- }
- }
- }
- if (classProps) {
- for (var _prop2 in classProps) {
- if (_prop2 !== 'className') {
- (0, _defineProperty.default)(ParseUser, _prop2, {
- value: classProps[_prop2],
- enumerable: false,
- writable: true,
- configurable: true
- });
- }
- }
- }
- return ParseUser;
- }
- /**
- * Retrieves the currently logged in ParseUser with a valid session,
- * either from memory or localStorage, if necessary.
- *
- * @static
- * @returns {Parse.Object} The currently logged in Parse.User.
- */
- }, {
- key: "current",
- value: function ()
- /*: ?ParseUser*/
- {
- if (!canUseCurrentUser) {
- return null;
- }
- var controller = _CoreManager.default.getUserController();
- return controller.currentUser();
- }
- /**
- * Retrieves the currently logged in ParseUser from asynchronous Storage.
- *
- * @static
- * @returns {Promise} A Promise that is resolved with the currently
- * logged in Parse User
- */
- }, {
- key: "currentAsync",
- value: function ()
- /*: Promise<?ParseUser>*/
- {
- if (!canUseCurrentUser) {
- return _promise.default.resolve(null);
- }
- var controller = _CoreManager.default.getUserController();
- return controller.currentUserAsync();
- }
- /**
- * Signs up a new user with a username (or email) and password.
- * This will create a new Parse.User on the server, and also persist the
- * session in localStorage so that you can access the user using
- * {@link #current}.
- *
- * @param {string} username The username (or email) to sign up with.
- * @param {string} password The password to sign up with.
- * @param {object} attrs Extra fields to set on the new user.
- * @param {object} options
- * @static
- * @returns {Promise} A promise that is fulfilled with the user when
- * the signup completes.
- */
- }, {
- key: "signUp",
- value: function (username
- /*: string*/
- , password
- /*: string*/
- , attrs
- /*: AttributeMap*/
- , options
- /*:: ?: FullOptions*/
- ) {
- attrs = attrs || {};
- attrs.username = username;
- attrs.password = password;
- var user = new this(attrs);
- return user.signUp({}, options);
- }
- /**
- * Logs in a user with a username (or email) and password. On success, this
- * saves the session to disk, so you can retrieve the currently logged in
- * user using <code>current</code>.
- *
- * @param {string} username The username (or email) to log in with.
- * @param {string} password The password to log in with.
- * @param {object} options
- * @static
- * @returns {Promise} A promise that is fulfilled with the user when
- * the login completes.
- */
- }, {
- key: "logIn",
- value: function (username
- /*: string*/
- , password
- /*: string*/
- , options
- /*:: ?: FullOptions*/
- ) {
- if (typeof username !== 'string') {
- return _promise.default.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Username must be a string.'));
- }
- if (typeof password !== 'string') {
- return _promise.default.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Password must be a string.'));
- }
- var user = new this();
- user._finishFetch({
- username: username,
- password: password
- });
- return user.logIn(options);
- }
- }, {
- key: "loginOrSignup",
- value: function (username
- /*: string*/
- , password
- /*: string*/
- ) {
- var _this8 = this;
- return this.logIn(username, password).catch(function (err) {
- if (err.code === 101) {
- var newUser = new _this8();
- newUser.set('username', username);
- newUser.set('password', password);
- return newUser.signUp();
- }
- throw err;
- });
- }
- /**
- * Logs in a user with a session token. On success, this saves the session
- * to disk, so you can retrieve the currently logged in user using
- * <code>current</code>.
- *
- * @param {string} sessionToken The sessionToken to log in with.
- * @param {object} options
- * @static
- * @returns {Promise} A promise that is fulfilled with the user when
- * the login completes.
- */
- }, {
- key: "become",
- value: function (sessionToken
- /*: string*/
- , options
- /*:: ?: RequestOptions*/
- ) {
- if (!canUseCurrentUser) {
- throw new Error('It is not memory-safe to become a user in a server environment');
- }
- options = options || {};
- var becomeOptions
- /*: RequestOptions*/
- = {
- sessionToken: sessionToken
- };
- if (options.hasOwnProperty('useMasterKey')) {
- becomeOptions.useMasterKey = options.useMasterKey;
- }
- var controller = _CoreManager.default.getUserController();
- var user = new this();
- return controller.become(user, becomeOptions);
- }
- /**
- * Retrieves a user with a session token.
- *
- * @param {string} sessionToken The sessionToken to get user with.
- * @param {object} options
- * @static
- * @returns {Promise} A promise that is fulfilled with the user is fetched.
- */
- }, {
- key: "me",
- value: function (sessionToken
- /*: string*/
- ) {
- var options
- /*:: ?: RequestOptions*/
- = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
- var controller = _CoreManager.default.getUserController();
- var meOptions
- /*: RequestOptions*/
- = {
- sessionToken: sessionToken
- };
- if (options.useMasterKey) {
- meOptions.useMasterKey = options.useMasterKey;
- }
- var user = new this();
- return controller.me(user, meOptions);
- }
- /**
- * Logs in a user with a session token. On success, this saves the session
- * to disk, so you can retrieve the currently logged in user using
- * <code>current</code>. If there is no session token the user will not logged in.
- *
- * @param {object} userJSON The JSON map of the User's data
- * @static
- * @returns {Promise} A promise that is fulfilled with the user when
- * the login completes.
- */
- }, {
- key: "hydrate",
- value: function (userJSON
- /*: AttributeMap*/
- ) {
- var controller = _CoreManager.default.getUserController();
- var user = new this();
- return controller.hydrate(user, userJSON);
- }
- /**
- * Static version of {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.User.html#linkWith linkWith}
- *
- * @param provider
- * @param options
- * @param saveOpts
- * @static
- * @returns {Promise}
- */
- }, {
- key: "logInWith",
- value: function (provider
- /*: any*/
- , options
- /*: { authData?: AuthData }*/
- , saveOpts
- /*:: ?: FullOptions*/
- )
- /*: Promise<ParseUser>*/
- {
- var user = new this();
- return user.linkWith(provider, options, saveOpts);
- }
- /**
- * Logs out the currently logged in user session. This will remove the
- * session from disk, log out of linked services, and future calls to
- * <code>current</code> will return <code>null</code>.
- *
- * @param {object} options
- * @static
- * @returns {Promise} A promise that is resolved when the session is
- * destroyed on the server.
- */
- }, {
- key: "logOut",
- value: function () {
- var options
- /*: RequestOptions*/
- = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
- var controller = _CoreManager.default.getUserController();
- return controller.logOut(options);
- }
- /**
- * Requests a password reset email to be sent to the specified email address
- * associated with the user account. This email allows the user to securely
- * reset their password on the Parse site.
- *
- * @param {string} email The email address associated with the user that
- * forgot their password.
- * @param {object} options
- * @static
- * @returns {Promise}
- */
- }, {
- key: "requestPasswordReset",
- value: function (email
- /*: string*/
- , options
- /*:: ?: RequestOptions*/
- ) {
- options = options || {};
- var requestOptions = {};
- if (options.hasOwnProperty('useMasterKey')) {
- requestOptions.useMasterKey = options.useMasterKey;
- }
- var controller = _CoreManager.default.getUserController();
- return controller.requestPasswordReset(email, requestOptions);
- }
- /**
- * Request an email verification.
- *
- * @param {string} email The email address associated with the user that
- * forgot their password.
- * @param {object} options
- * @static
- * @returns {Promise}
- */
- }, {
- key: "requestEmailVerification",
- value: function (email
- /*: string*/
- , options
- /*:: ?: RequestOptions*/
- ) {
- options = options || {};
- var requestOptions = {};
- if (options.hasOwnProperty('useMasterKey')) {
- requestOptions.useMasterKey = options.useMasterKey;
- }
- var controller = _CoreManager.default.getUserController();
- return controller.requestEmailVerification(email, requestOptions);
- }
- /**
- * Verify whether a given password is the password of the current user.
- *
- * @param {string} username A username to be used for identificaiton
- * @param {string} password A password to be verified
- * @param {object} options
- * @static
- * @returns {Promise} A promise that is fulfilled with a user
- * when the password is correct.
- */
- }, {
- key: "verifyPassword",
- value: function (username
- /*: string*/
- , password
- /*: string*/
- , options
- /*:: ?: RequestOptions*/
- ) {
- if (typeof username !== 'string') {
- return _promise.default.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Username must be a string.'));
- }
- if (typeof password !== 'string') {
- return _promise.default.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Password must be a string.'));
- }
- options = options || {};
- var verificationOption = {};
- if (options.hasOwnProperty('useMasterKey')) {
- verificationOption.useMasterKey = options.useMasterKey;
- }
- var controller = _CoreManager.default.getUserController();
- return controller.verifyPassword(username, password, verificationOption);
- }
- /**
- * Allow someone to define a custom User class without className
- * being rewritten to _User. The default behavior is to rewrite
- * User to _User for legacy reasons. This allows developers to
- * override that behavior.
- *
- * @param {boolean} isAllowed Whether or not to allow custom User class
- * @static
- */
- }, {
- key: "allowCustomUserClass",
- value: function (isAllowed
- /*: boolean*/
- ) {
- _CoreManager.default.set('PERFORM_USER_REWRITE', !isAllowed);
- }
- /**
- * Allows a legacy application to start using revocable sessions. If the
- * current session token is not revocable, a request will be made for a new,
- * revocable session.
- * It is not necessary to call this method from cloud code unless you are
- * handling user signup or login from the server side. In a cloud code call,
- * this function will not attempt to upgrade the current token.
- *
- * @param {object} options
- * @static
- * @returns {Promise} A promise that is resolved when the process has
- * completed. If a replacement session token is requested, the promise
- * will be resolved after a new token has been fetched.
- */
- }, {
- key: "enableRevocableSession",
- value: function (options
- /*:: ?: RequestOptions*/
- ) {
- options = options || {};
- _CoreManager.default.set('FORCE_REVOCABLE_SESSION', true);
- if (canUseCurrentUser) {
- var current = ParseUser.current();
- if (current) {
- return current._upgradeToRevocableSession(options);
- }
- }
- return _promise.default.resolve();
- }
- /**
- * Enables the use of become or the current user in a server
- * environment. These features are disabled by default, since they depend on
- * global objects that are not memory-safe for most servers.
- *
- * @static
- */
- }, {
- key: "enableUnsafeCurrentUser",
- value: function () {
- canUseCurrentUser = true;
- }
- /**
- * Disables the use of become or the current user in any environment.
- * These features are disabled on servers by default, since they depend on
- * global objects that are not memory-safe for most servers.
- *
- * @static
- */
- }, {
- key: "disableUnsafeCurrentUser",
- value: function () {
- canUseCurrentUser = false;
- }
- /**
- * When registering users with {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.User.html#linkWith linkWith} a basic auth provider
- * is automatically created for you.
- *
- * For advanced authentication, you can register an Auth provider to
- * implement custom authentication, deauthentication.
- *
- * @param provider
- * @see {@link https://parseplatform.org/Parse-SDK-JS/api/master/AuthProvider.html AuthProvider}
- * @see {@link https://docs.parseplatform.org/js/guide/#custom-authentication-module Custom Authentication Module}
- * @static
- */
- }, {
- key: "_registerAuthenticationProvider",
- value: function (provider
- /*: any*/
- ) {
- authProviders[provider.getAuthType()] = provider; // Synchronize the current user with the auth provider.
- ParseUser.currentAsync().then(function (current) {
- if (current) {
- current._synchronizeAuthData(provider.getAuthType());
- }
- });
- }
- /**
- * @param provider
- * @param options
- * @param saveOpts
- * @deprecated since 2.9.0 see {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.User.html#logInWith logInWith}
- * @static
- * @returns {Promise}
- */
- }, {
- key: "_logInWith",
- value: function (provider
- /*: any*/
- , options
- /*: { authData?: AuthData }*/
- , saveOpts
- /*:: ?: FullOptions*/
- ) {
- var user = new this();
- return user.linkWith(provider, options, saveOpts);
- }
- }, {
- key: "_clearCache",
- value: function () {
- currentUserCache = null;
- currentUserCacheMatchesDisk = false;
- }
- }, {
- key: "_setCurrentUserCache",
- value: function (user
- /*: ParseUser*/
- ) {
- currentUserCache = user;
- }
- }]);
- return ParseUser;
- }(_ParseObject2.default);
- _ParseObject2.default.registerSubclass('_User', ParseUser);
- var DefaultController = {
- updateUserOnDisk: function (user) {
- var path = _Storage.default.generatePath(CURRENT_USER_KEY);
- var json = user.toJSON();
- delete json.password;
- json.className = '_User';
- var userData = (0, _stringify.default)(json);
- if (_CoreManager.default.get('ENCRYPTED_USER')) {
- var crypto = _CoreManager.default.getCryptoController();
- userData = crypto.encrypt(json, _CoreManager.default.get('ENCRYPTED_KEY'));
- }
- return _Storage.default.setItemAsync(path, userData).then(function () {
- return user;
- });
- },
- removeUserFromDisk: function () {
- var path = _Storage.default.generatePath(CURRENT_USER_KEY);
- currentUserCacheMatchesDisk = true;
- currentUserCache = null;
- return _Storage.default.removeItemAsync(path);
- },
- setCurrentUser: function (user) {
- var _this9 = this;
- return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
- var currentUser;
- return _regenerator.default.wrap(function (_context) {
- while (1) {
- switch (_context.prev = _context.next) {
- case 0:
- _context.next = 2;
- return _this9.currentUserAsync();
- case 2:
- currentUser = _context.sent;
- if (!(currentUser && !user.equals(currentUser) && _AnonymousUtils.default.isLinked(currentUser))) {
- _context.next = 6;
- break;
- }
- _context.next = 6;
- return currentUser.destroy({
- sessionToken: currentUser.getSessionToken()
- });
- case 6:
- currentUserCache = user;
- user._cleanupAuthData();
- user._synchronizeAllAuthData();
- return _context.abrupt("return", DefaultController.updateUserOnDisk(user));
- case 10:
- case "end":
- return _context.stop();
- }
- }
- }, _callee);
- }))();
- },
- currentUser: function ()
- /*: ?ParseUser*/
- {
- if (currentUserCache) {
- return currentUserCache;
- }
- if (currentUserCacheMatchesDisk) {
- return null;
- }
- if (_Storage.default.async()) {
- throw new Error('Cannot call currentUser() when using a platform with an async ' + 'storage system. Call currentUserAsync() instead.');
- }
- var path = _Storage.default.generatePath(CURRENT_USER_KEY);
- var userData = _Storage.default.getItem(path);
- currentUserCacheMatchesDisk = true;
- if (!userData) {
- currentUserCache = null;
- return null;
- }
- if (_CoreManager.default.get('ENCRYPTED_USER')) {
- var crypto = _CoreManager.default.getCryptoController();
- userData = crypto.decrypt(userData, _CoreManager.default.get('ENCRYPTED_KEY'));
- }
- userData = JSON.parse(userData);
- if (!userData.className) {
- userData.className = '_User';
- }
- if (userData._id) {
- if (userData.objectId !== userData._id) {
- userData.objectId = userData._id;
- }
- delete userData._id;
- }
- if (userData._sessionToken) {
- userData.sessionToken = userData._sessionToken;
- delete userData._sessionToken;
- }
- var current = _ParseObject2.default.fromJSON(userData);
- currentUserCache = current;
- current._synchronizeAllAuthData();
- return current;
- },
- currentUserAsync: function ()
- /*: Promise<?ParseUser>*/
- {
- if (currentUserCache) {
- return _promise.default.resolve(currentUserCache);
- }
- if (currentUserCacheMatchesDisk) {
- return _promise.default.resolve(null);
- }
- var path = _Storage.default.generatePath(CURRENT_USER_KEY);
- return _Storage.default.getItemAsync(path).then(function (userData) {
- currentUserCacheMatchesDisk = true;
- if (!userData) {
- currentUserCache = null;
- return _promise.default.resolve(null);
- }
- if (_CoreManager.default.get('ENCRYPTED_USER')) {
- var crypto = _CoreManager.default.getCryptoController();
- userData = crypto.decrypt(userData.toString(), _CoreManager.default.get('ENCRYPTED_KEY'));
- }
- userData = JSON.parse(userData);
- if (!userData.className) {
- userData.className = '_User';
- }
- if (userData._id) {
- if (userData.objectId !== userData._id) {
- userData.objectId = userData._id;
- }
- delete userData._id;
- }
- if (userData._sessionToken) {
- userData.sessionToken = userData._sessionToken;
- delete userData._sessionToken;
- }
- var current = _ParseObject2.default.fromJSON(userData);
- currentUserCache = current;
- current._synchronizeAllAuthData();
- return _promise.default.resolve(current);
- });
- },
- signUp: function (user
- /*: ParseUser*/
- , attrs
- /*: AttributeMap*/
- , options
- /*: RequestOptions*/
- )
- /*: Promise<ParseUser>*/
- {
- var username = attrs && attrs.username || user.get('username');
- var password = attrs && attrs.password || user.get('password');
- if (!username || !username.length) {
- return _promise.default.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Cannot sign up user with an empty username.'));
- }
- if (!password || !password.length) {
- return _promise.default.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Cannot sign up user with an empty password.'));
- }
- return user.save(attrs, options).then(function () {
- // Clear the password field
- user._finishFetch({
- password: undefined
- });
- if (canUseCurrentUser) {
- return DefaultController.setCurrentUser(user);
- }
- return user;
- });
- },
- logIn: function (user
- /*: ParseUser*/
- , options
- /*: RequestOptions*/
- )
- /*: Promise<ParseUser>*/
- {
- var RESTController = _CoreManager.default.getRESTController();
- var stateController = _CoreManager.default.getObjectStateController();
- var auth = {
- username: user.get('username'),
- password: user.get('password')
- };
- return RESTController.request(options.usePost ? 'POST' : 'GET', 'login', auth, options).then(function (response) {
- user._migrateId(response.objectId);
- user._setExisted(true);
- stateController.setPendingOp(user._getStateIdentifier(), 'username', undefined);
- stateController.setPendingOp(user._getStateIdentifier(), 'password', undefined);
- response.password = undefined;
- user._finishFetch(response);
- if (!canUseCurrentUser) {
- // We can't set the current user, so just return the one we logged in
- return _promise.default.resolve(user);
- }
- return DefaultController.setCurrentUser(user);
- });
- },
- become: function (user
- /*: ParseUser*/
- , options
- /*: RequestOptions*/
- )
- /*: Promise<ParseUser>*/
- {
- var RESTController = _CoreManager.default.getRESTController();
- return RESTController.request('GET', 'users/me', {}, options).then(function (response) {
- user._finishFetch(response);
- user._setExisted(true);
- return DefaultController.setCurrentUser(user);
- });
- },
- hydrate: function (user
- /*: ParseUser*/
- , userJSON
- /*: AttributeMap*/
- )
- /*: Promise<ParseUser>*/
- {
- user._finishFetch(userJSON);
- user._setExisted(true);
- if (userJSON.sessionToken && canUseCurrentUser) {
- return DefaultController.setCurrentUser(user);
- }
- return _promise.default.resolve(user);
- },
- me: function (user
- /*: ParseUser*/
- , options
- /*: RequestOptions*/
- )
- /*: Promise<ParseUser>*/
- {
- var RESTController = _CoreManager.default.getRESTController();
- return RESTController.request('GET', 'users/me', {}, options).then(function (response) {
- user._finishFetch(response);
- user._setExisted(true);
- return user;
- });
- },
- logOut: function (options
- /*: RequestOptions*/
- )
- /*: Promise<ParseUser>*/
- {
- var Moralis = _dereq_('./Parse');
- Moralis.cleanup();
- var RESTController = _CoreManager.default.getRESTController();
- if (options.sessionToken) {
- return RESTController.request('POST', 'logout', {}, options);
- }
- return DefaultController.currentUserAsync().then(function (currentUser) {
- var path = _Storage.default.generatePath(CURRENT_USER_KEY);
- var promise = _Storage.default.removeItemAsync(path);
- if (currentUser !== null) {
- var isAnonymous = _AnonymousUtils.default.isLinked(currentUser);
- var currentSession = currentUser.getSessionToken();
- if (currentSession && (0, _isRevocableSession.default)(currentSession)) {
- promise = promise.then(function () {
- if (isAnonymous) {
- return currentUser.destroy({
- sessionToken: currentSession
- });
- }
- }).then(function () {
- return RESTController.request('POST', 'logout', {}, {
- sessionToken: currentSession
- });
- });
- }
- currentUser._logOutWithAll();
- currentUser._finishFetch({
- sessionToken: undefined
- });
- currentUser._clearServerData();
- }
- currentUserCacheMatchesDisk = true;
- currentUserCache = null;
- return promise;
- });
- },
- requestPasswordReset: function (email
- /*: string*/
- , options
- /*: RequestOptions*/
- ) {
- var RESTController = _CoreManager.default.getRESTController();
- return RESTController.request('POST', 'requestPasswordReset', {
- email: email
- }, options);
- },
- upgradeToRevocableSession: function (user
- /*: ParseUser*/
- , options
- /*: RequestOptions*/
- ) {
- var token = user.getSessionToken();
- if (!token) {
- return _promise.default.reject(new _ParseError.default(_ParseError.default.SESSION_MISSING, 'Cannot upgrade a user with no session token'));
- }
- options.sessionToken = token;
- var RESTController = _CoreManager.default.getRESTController();
- return RESTController.request('POST', 'upgradeToRevocableSession', {}, options).then(function (result) {
- var session = new _ParseSession.default();
- session._finishFetch(result);
- user._finishFetch({
- sessionToken: session.getSessionToken()
- });
- if (user.isCurrent()) {
- return DefaultController.setCurrentUser(user);
- }
- return _promise.default.resolve(user);
- });
- },
- linkWith: function (user
- /*: ParseUser*/
- , authData
- /*: AuthData*/
- , options
- /*: FullOptions*/
- ) {
- return user.save({
- authData: authData
- }, options).then(function () {
- if (canUseCurrentUser) {
- return DefaultController.setCurrentUser(user);
- }
- return user;
- });
- },
- verifyPassword: function (username
- /*: string*/
- , password
- /*: string*/
- , options
- /*: RequestOptions*/
- ) {
- var RESTController = _CoreManager.default.getRESTController();
- return RESTController.request('GET', 'verifyPassword', {
- username: username,
- password: password
- }, options);
- },
- requestEmailVerification: function (email
- /*: string*/
- , options
- /*: RequestOptions*/
- ) {
- var RESTController = _CoreManager.default.getRESTController();
- return RESTController.request('POST', 'verificationEmailRequest', {
- email: email
- }, options);
- }
- };
- _CoreManager.default.setUserController(DefaultController);
- var _default = ParseUser;
- exports.default = _default;
- },{"./AnonymousUtils":2,"./CoreManager":5,"./MoralisWeb3":21,"./Parse":25,"./ParseError":29,"./ParseObject":36,"./ParseSession":43,"./Storage":48,"./isRevocableSession":70,"@babel/runtime-corejs3/core-js-stable/json/stringify":99,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/core-js-stable/promise":115,"@babel/runtime-corejs3/core-js-stable/reflect/construct":116,"@babel/runtime-corejs3/helpers/asyncToGenerator":144,"@babel/runtime-corejs3/helpers/classCallCheck":145,"@babel/runtime-corejs3/helpers/createClass":147,"@babel/runtime-corejs3/helpers/get":149,"@babel/runtime-corejs3/helpers/getPrototypeOf":150,"@babel/runtime-corejs3/helpers/inherits":151,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/helpers/possibleConstructorReturn":159,"@babel/runtime-corejs3/helpers/typeof":164,"@babel/runtime-corejs3/regenerator":167}],45:[function(_dereq_,module,exports){
- "use strict";
- var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
- var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
- _Object$defineProperty(exports, "__esModule", {
- value: true
- });
- exports.send = send;
- var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
- var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
- var _ParseQuery = _interopRequireDefault(_dereq_("./ParseQuery"));
- /**
- * Copyright (c) 2015-present, Parse, LLC.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- *
- * @flow
- */
- /**
- * Contains functions to deal with Push in Parse.
- *
- * @class Parse.Push
- * @static
- * @hideconstructor
- */
- /**
- * Sends a push notification.
- * **Available in Cloud Code only.**
- *
- * See {@link https://docs.parseplatform.org/js/guide/#push-notifications Push Notification Guide}
- *
- * @function send
- * @name Parse.Push.send
- * @param {object} data - The data of the push notification. Valid fields
- * are:
- * <ol>
- * <li>channels - An Array of channels to push to.</li>
- * <li>push_time - A Date object for when to send the push.</li>
- * <li>expiration_time - A Date object for when to expire
- * the push.</li>
- * <li>expiration_interval - The seconds from now to expire the push.</li>
- * <li>where - A Parse.Query over Parse.Installation that is used to match
- * a set of installations to push to.</li>
- * <li>data - The data to send as part of the push.</li>
- * <ol>
- * @returns {Promise} A promise that is fulfilled when the push request
- * completes.
- */
- function send(data
- /*: PushData*/
- )
- /*: Promise*/
- {
- if (data.where && data.where instanceof _ParseQuery.default) {
- data.where = data.where.toJSON().where;
- }
- if (data.push_time && (0, _typeof2.default)(data.push_time) === 'object') {
- data.push_time = data.push_time.toJSON();
- }
- if (data.expiration_time && (0, _typeof2.default)(data.expiration_time) === 'object') {
- data.expiration_time = data.expiration_time.toJSON();
- }
- if (data.expiration_time && data.expiration_interval) {
- throw new Error('expiration_time and expiration_interval cannot both be set.');
- }
- return _CoreManager.default.getPushController().send(data);
- }
- var DefaultController = {
- send: function (data
- /*: PushData*/
- ) {
- return _CoreManager.default.getRESTController().request('POST', 'push', data, {
- useMasterKey: true
- });
- }
- };
- _CoreManager.default.setPushController(DefaultController);
- },{"./CoreManager":5,"./ParseQuery":39,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/helpers/typeof":164}],46:[function(_dereq_,module,exports){
- (function (process){(function (){
- "use strict";
- var _Object$keys = _dereq_("@babel/runtime-corejs3/core-js-stable/object/keys");
- var _Object$getOwnPropertySymbols = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols");
- var _filterInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/filter");
- var _Object$getOwnPropertyDescriptor = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
- var _forEachInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each");
- var _Object$getOwnPropertyDescriptors = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors");
- var _Object$defineProperties = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-properties");
- var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
- var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
- var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
- var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
- var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
- var _stringify = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/json/stringify"));
- var _includes = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/includes"));
- var _setTimeout2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/set-timeout"));
- var _concat = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/concat"));
- var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
- var _ParseError = _interopRequireDefault(_dereq_("./ParseError"));
- var _promiseUtils = _dereq_("./promiseUtils");
- function ownKeys(object, enumerableOnly) {
- var keys = _Object$keys(object);
- if (_Object$getOwnPropertySymbols) {
- var symbols = _Object$getOwnPropertySymbols(object);
- enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) {
- return _Object$getOwnPropertyDescriptor(object, sym).enumerable;
- })), keys.push.apply(keys, symbols);
- }
- return keys;
- }
- function _objectSpread(target) {
- for (var i = 1; i < arguments.length; i++) {
- var _context5, _context6;
- var source = null != arguments[i] ? arguments[i] : {};
- i % 2 ? _forEachInstanceProperty(_context5 = ownKeys(Object(source), !0)).call(_context5, function (key) {
- (0, _defineProperty2.default)(target, key, source[key]);
- }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context6 = ownKeys(Object(source))).call(_context6, function (key) {
- _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key));
- });
- }
- return target;
- }
- /**
- * Copyright (c) 2015-present, Parse, LLC.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- *
- * @flow
- */
- /* global XMLHttpRequest, XDomainRequest */
- var _require = _dereq_('uuid'),
- uuidv4 = _require.v4;
- var XHR = null;
- if (typeof XMLHttpRequest !== 'undefined') {
- XHR = XMLHttpRequest;
- }
- var useXDomainRequest = false;
- if (typeof XDomainRequest !== 'undefined' && !('withCredentials' in new XMLHttpRequest())) {
- useXDomainRequest = true;
- }
- function ajaxIE9(method
- /*: string*/
- , url
- /*: string*/
- , data
- /*: any*/
- , headers
- /*:: ?: any*/
- , options
- /*:: ?: FullOptions*/
- ) {
- return new _promise.default(function (resolve, reject) {
- var xdr = new XDomainRequest();
- xdr.onload = function () {
- var response;
- try {
- response = JSON.parse(xdr.responseText);
- } catch (e) {
- reject(e);
- }
- if (response) {
- resolve({
- response: response
- });
- }
- };
- xdr.onerror = xdr.ontimeout = function () {
- // Let's fake a real error message.
- var fakeResponse = {
- responseText: (0, _stringify.default)({
- code: _ParseError.default.X_DOMAIN_REQUEST,
- error: "IE's XDomainRequest does not supply error info."
- })
- };
- reject(fakeResponse);
- };
- xdr.onprogress = function () {
- if (options && typeof options.progress === 'function') {
- options.progress(xdr.responseText);
- }
- };
- xdr.open(method, url);
- xdr.send(data);
- if (options && typeof options.requestTask === 'function') {
- options.requestTask(xdr);
- }
- });
- }
- var RESTController = {
- ajax: function (method
- /*: string*/
- , url
- /*: string*/
- , data
- /*: any*/
- , headers
- /*:: ?: any*/
- , options
- /*:: ?: FullOptions*/
- ) {
- var _context;
- if (useXDomainRequest) {
- return ajaxIE9(method, url, data, headers, options);
- }
- var promise = (0, _promiseUtils.resolvingPromise)();
- var isIdempotent = _CoreManager.default.get('IDEMPOTENCY') && (0, _includes.default)(_context = ['POST', 'PUT']).call(_context, method);
- var requestId = isIdempotent ? uuidv4() : '';
- var attempts = 0;
- var dispatch = function dispatch() {
- if (XHR == null) {
- throw new Error('Cannot make a request: No definition of XMLHttpRequest was found.');
- }
- var handled = false;
- var xhr = new XHR();
- xhr.onreadystatechange = function () {
- if (xhr.readyState !== 4 || handled || xhr._aborted) {
- return;
- }
- handled = true;
- if (xhr.status >= 200 && xhr.status < 300) {
- var response;
- try {
- response = JSON.parse(xhr.responseText);
- if (typeof xhr.getResponseHeader === 'function') {
- var _context2;
- if ((0, _includes.default)(_context2 = xhr.getAllResponseHeaders() || '').call(_context2, 'x-parse-job-status-id: ')) {
- response = xhr.getResponseHeader('x-parse-job-status-id');
- }
- }
- } catch (e) {
- promise.reject(e.toString());
- }
- if (response) {
- promise.resolve({
- response: response,
- status: xhr.status,
- xhr: xhr
- });
- }
- } else if (xhr.status >= 500 || xhr.status === 0) {
- // retry on 5XX or node-xmlhttprequest error
- if (++attempts < _CoreManager.default.get('REQUEST_ATTEMPT_LIMIT')) {
- // Exponentially-growing random delay
- var delay = Math.round(Math.random() * 125 * Math.pow(2, attempts));
- (0, _setTimeout2.default)(dispatch, delay);
- } else if (xhr.status === 0) {
- promise.reject('Unable to connect to the Parse API');
- } else {
- // After the retry limit is reached, fail
- promise.reject(xhr);
- }
- } else {
- promise.reject(xhr);
- }
- };
- headers = headers || {};
- if (typeof headers['Content-Type'] !== 'string') {
- // Avoid pre-flight
- headers['Content-Type'] = 'text/plain';
- }
- if (_CoreManager.default.get('IS_NODE')) {
- var _context3;
- headers['User-Agent'] = (0, _concat.default)(_context3 = "Parse/".concat(_CoreManager.default.get('VERSION'), " (NodeJS ")).call(_context3, process.versions.node, ")");
- }
- if (isIdempotent) {
- headers['X-Parse-Request-Id'] = requestId;
- }
- if (_CoreManager.default.get('SERVER_AUTH_TYPE') && _CoreManager.default.get('SERVER_AUTH_TOKEN')) {
- var _context4;
- headers.Authorization = (0, _concat.default)(_context4 = "".concat(_CoreManager.default.get('SERVER_AUTH_TYPE'), " ")).call(_context4, _CoreManager.default.get('SERVER_AUTH_TOKEN'));
- }
- var customHeaders = _CoreManager.default.get('REQUEST_HEADERS');
- for (var key in customHeaders) {
- headers[key] = customHeaders[key];
- }
- function handleProgress(type, event) {
- if (options && typeof options.progress === 'function') {
- if (event.lengthComputable) {
- options.progress(event.loaded / event.total, event.loaded, event.total, {
- type: type
- });
- } else {
- options.progress(null, null, null, {
- type: type
- });
- }
- }
- }
- xhr.onprogress = function (event) {
- handleProgress('download', event);
- };
- if (xhr.upload) {
- xhr.upload.onprogress = function (event) {
- handleProgress('upload', event);
- };
- }
- xhr.open(method, url, true);
- for (var h in headers) {
- xhr.setRequestHeader(h, headers[h]);
- }
- xhr.onabort = function () {
- promise.resolve({
- response: {
- results: []
- },
- status: 0,
- xhr: xhr
- });
- };
- xhr.send(data);
- if (options && typeof options.requestTask === 'function') {
- options.requestTask(xhr);
- }
- };
- dispatch();
- return promise;
- },
- request: function (method
- /*: string*/
- , path
- /*: string*/
- , data
- /*: mixed*/
- , options
- /*:: ?: RequestOptions*/
- ) {
- options = options || {};
- var url = _CoreManager.default.get('SERVER_URL');
- if (url[url.length - 1] !== '/') {
- url += '/';
- }
- url += path;
- var payload = {};
- if (data && (0, _typeof2.default)(data) === 'object') {
- for (var k in data) {
- payload[k] = data[k];
- }
- } // Add context
- var _options = options,
- context = _options.context;
- if (context !== undefined) {
- payload._context = context;
- }
- if (method !== 'POST') {
- payload._method = method;
- method = 'POST';
- }
- payload._ApplicationId = _CoreManager.default.get('APPLICATION_ID');
- var jsKey = _CoreManager.default.get('JAVASCRIPT_KEY');
- if (jsKey) {
- payload._JavaScriptKey = jsKey;
- }
- payload._ClientVersion = _CoreManager.default.get('VERSION');
- var _options2 = options,
- useMasterKey = _options2.useMasterKey;
- if (typeof useMasterKey === 'undefined') {
- useMasterKey = _CoreManager.default.get('USE_MASTER_KEY');
- }
- if (useMasterKey) {
- if (_CoreManager.default.get('MASTER_KEY')) {
- delete payload._JavaScriptKey;
- payload._MasterKey = _CoreManager.default.get('MASTER_KEY');
- }
- }
- if (_CoreManager.default.get('FORCE_REVOCABLE_SESSION')) {
- payload._RevocableSession = '1';
- }
- var _options3 = options,
- installationId = _options3.installationId;
- var installationIdPromise;
- if (installationId && typeof installationId === 'string') {
- installationIdPromise = _promise.default.resolve(installationId);
- } else {
- var installationController = _CoreManager.default.getInstallationController();
- installationIdPromise = installationController.currentInstallationId();
- }
- return installationIdPromise.then(function (iid) {
- payload._InstallationId = iid;
- var userController = _CoreManager.default.getUserController();
- if (options && typeof options.sessionToken === 'string') {
- return _promise.default.resolve(options.sessionToken);
- }
- if (userController) {
- return userController.currentUserAsync().then(function (user) {
- if (user) {
- return _promise.default.resolve(user.getSessionToken());
- }
- return _promise.default.resolve(null);
- });
- }
- return _promise.default.resolve(null);
- }).then(function (token) {
- if (token) {
- payload._SessionToken = token;
- }
- var payloadString = (0, _stringify.default)(payload);
- return RESTController.ajax(method, url, payloadString, {}, options).then(function (_ref) {
- var response = _ref.response,
- status = _ref.status;
- if (options.returnStatus) {
- return _objectSpread(_objectSpread({}, response), {}, {
- _status: status
- });
- }
- return response;
- });
- }).catch(RESTController.handleError);
- },
- handleError: function (response) {
- // Transform the error into an instance of ParseError by trying to parse
- // the error string as JSON
- var error;
- if (response && response.responseText) {
- try {
- var errorJSON = JSON.parse(response.responseText);
- error = new _ParseError.default(errorJSON.code, errorJSON.error);
- } catch (e) {
- // If we fail to parse the error text, that's okay.
- error = new _ParseError.default(_ParseError.default.INVALID_JSON, "Received an error with invalid JSON from Parse: ".concat(response.responseText));
- }
- } else {
- var message = response.message ? response.message : response;
- error = new _ParseError.default(_ParseError.default.CONNECTION_FAILED, "XMLHttpRequest failed: ".concat((0, _stringify.default)(message)));
- }
- return _promise.default.reject(error);
- },
- _setXHR: function (xhr
- /*: any*/
- ) {
- XHR = xhr;
- },
- _getXHR: function () {
- return XHR;
- }
- };
- module.exports = RESTController;
- }).call(this)}).call(this,_dereq_('_process'))
- },{"./CoreManager":5,"./ParseError":29,"./promiseUtils":72,"@babel/runtime-corejs3/core-js-stable/instance/concat":81,"@babel/runtime-corejs3/core-js-stable/instance/filter":84,"@babel/runtime-corejs3/core-js-stable/instance/for-each":86,"@babel/runtime-corejs3/core-js-stable/instance/includes":87,"@babel/runtime-corejs3/core-js-stable/json/stringify":99,"@babel/runtime-corejs3/core-js-stable/object/define-properties":104,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor":108,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors":109,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols":110,"@babel/runtime-corejs3/core-js-stable/object/keys":112,"@babel/runtime-corejs3/core-js-stable/promise":115,"@babel/runtime-corejs3/core-js-stable/set-timeout":117,"@babel/runtime-corejs3/helpers/defineProperty":148,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/helpers/typeof":164,"_process":323,"uuid":797}],47:[function(_dereq_,module,exports){
- "use strict";
- var _typeof = _dereq_("@babel/runtime-corejs3/helpers/typeof");
- var _WeakMap = _dereq_("@babel/runtime-corejs3/core-js-stable/weak-map");
- var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
- var _Object$getOwnPropertyDescriptor = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
- _Object$defineProperty(exports, "__esModule", {
- value: true
- });
- exports.clearAllState = clearAllState;
- exports.commitServerChanges = commitServerChanges;
- exports.duplicateState = duplicateState;
- exports.enqueueTask = enqueueTask;
- exports.estimateAttribute = estimateAttribute;
- exports.estimateAttributes = estimateAttributes;
- exports.getObjectCache = getObjectCache;
- exports.getPendingOps = getPendingOps;
- exports.getServerData = getServerData;
- exports.getState = getState;
- exports.initializeState = initializeState;
- exports.mergeFirstPendingState = mergeFirstPendingState;
- exports.popPendingState = popPendingState;
- exports.pushPendingState = pushPendingState;
- exports.removeState = removeState;
- exports.setPendingOp = setPendingOp;
- exports.setServerData = setServerData;
- var ObjectStateMutations = _interopRequireWildcard(_dereq_("./ObjectStateMutations"));
- function _getRequireWildcardCache(nodeInterop) {
- if (typeof _WeakMap !== "function") return null;
- var cacheBabelInterop = new _WeakMap();
- var cacheNodeInterop = new _WeakMap();
- return (_getRequireWildcardCache = function (nodeInterop) {
- return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
- })(nodeInterop);
- }
- function _interopRequireWildcard(obj, nodeInterop) {
- if (!nodeInterop && obj && obj.__esModule) {
- return obj;
- }
- if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") {
- return {
- default: obj
- };
- }
- var cache = _getRequireWildcardCache(nodeInterop);
- if (cache && cache.has(obj)) {
- return cache.get(obj);
- }
- var newObj = {};
- for (var key in obj) {
- if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
- var desc = _Object$defineProperty && _Object$getOwnPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null;
- if (desc && (desc.get || desc.set)) {
- _Object$defineProperty(newObj, key, desc);
- } else {
- newObj[key] = obj[key];
- }
- }
- }
- newObj.default = obj;
- if (cache) {
- cache.set(obj, newObj);
- }
- return newObj;
- }
- /**
- * Copyright (c) 2015-present, Parse, LLC.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- *
- * @flow
- */
- var objectState
- /*: {
- [className: string]: {
- [id: string]: State,
- },
- }*/
- = {};
- function getState(obj
- /*: ObjectIdentifier*/
- )
- /*: ?State*/
- {
- var classData = objectState[obj.className];
- if (classData) {
- return classData[obj.id] || null;
- }
- return null;
- }
- function initializeState(obj
- /*: ObjectIdentifier*/
- , initial
- /*:: ?: State*/
- )
- /*: State*/
- {
- var state = getState(obj);
- if (state) {
- return state;
- }
- if (!objectState[obj.className]) {
- objectState[obj.className] = {};
- }
- if (!initial) {
- initial = ObjectStateMutations.defaultState();
- }
- state = objectState[obj.className][obj.id] = initial;
- return state;
- }
- function removeState(obj
- /*: ObjectIdentifier*/
- )
- /*: ?State*/
- {
- var state = getState(obj);
- if (state === null) {
- return null;
- }
- delete objectState[obj.className][obj.id];
- return state;
- }
- function getServerData(obj
- /*: ObjectIdentifier*/
- )
- /*: AttributeMap*/
- {
- var state = getState(obj);
- if (state) {
- return state.serverData;
- }
- return {};
- }
- function setServerData(obj
- /*: ObjectIdentifier*/
- , attributes
- /*: AttributeMap*/
- ) {
- var _initializeState = initializeState(obj),
- serverData = _initializeState.serverData;
- ObjectStateMutations.setServerData(serverData, attributes);
- }
- function getPendingOps(obj
- /*: ObjectIdentifier*/
- )
- /*: Array<OpsMap>*/
- {
- var state = getState(obj);
- if (state) {
- return state.pendingOps;
- }
- return [{}];
- }
- function setPendingOp(obj
- /*: ObjectIdentifier*/
- , attr
- /*: string*/
- , op
- /*: ?Op*/
- ) {
- var _initializeState2 = initializeState(obj),
- pendingOps = _initializeState2.pendingOps;
- ObjectStateMutations.setPendingOp(pendingOps, attr, op);
- }
- function pushPendingState(obj
- /*: ObjectIdentifier*/
- ) {
- var _initializeState3 = initializeState(obj),
- pendingOps = _initializeState3.pendingOps;
- ObjectStateMutations.pushPendingState(pendingOps);
- }
- function popPendingState(obj
- /*: ObjectIdentifier*/
- )
- /*: OpsMap*/
- {
- var _initializeState4 = initializeState(obj),
- pendingOps = _initializeState4.pendingOps;
- return ObjectStateMutations.popPendingState(pendingOps);
- }
- function mergeFirstPendingState(obj
- /*: ObjectIdentifier*/
- ) {
- var pendingOps = getPendingOps(obj);
- ObjectStateMutations.mergeFirstPendingState(pendingOps);
- }
- function getObjectCache(obj
- /*: ObjectIdentifier*/
- )
- /*: ObjectCache*/
- {
- var state = getState(obj);
- if (state) {
- return state.objectCache;
- }
- return {};
- }
- function estimateAttribute(obj
- /*: ObjectIdentifier*/
- , attr
- /*: string*/
- )
- /*: mixed*/
- {
- var serverData = getServerData(obj);
- var pendingOps = getPendingOps(obj);
- return ObjectStateMutations.estimateAttribute(serverData, pendingOps, obj.className, obj.id, attr);
- }
- function estimateAttributes(obj
- /*: ObjectIdentifier*/
- )
- /*: AttributeMap*/
- {
- var serverData = getServerData(obj);
- var pendingOps = getPendingOps(obj);
- return ObjectStateMutations.estimateAttributes(serverData, pendingOps, obj.className, obj.id);
- }
- function commitServerChanges(obj
- /*: ObjectIdentifier*/
- , changes
- /*: AttributeMap*/
- ) {
- var state = initializeState(obj);
- ObjectStateMutations.commitServerChanges(state.serverData, state.objectCache, changes);
- }
- function enqueueTask(obj
- /*: ObjectIdentifier*/
- , task
- /*: () => Promise*/
- )
- /*: Promise*/
- {
- var state = initializeState(obj);
- return state.tasks.enqueue(task);
- }
- function clearAllState() {
- objectState = {};
- }
- function duplicateState(source
- /*: { id: string }*/
- , dest
- /*: { id: string }*/
- ) {
- dest.id = source.id;
- }
- },{"./ObjectStateMutations":23,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor":108,"@babel/runtime-corejs3/core-js-stable/weak-map":122,"@babel/runtime-corejs3/helpers/typeof":164}],48:[function(_dereq_,module,exports){
- "use strict";
- var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
- var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
- var _concat = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/concat"));
- var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
- /**
- * Copyright (c) 2015-present, Parse, LLC.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- *
- * @flow
- */
- var Storage = {
- async: function ()
- /*: boolean*/
- {
- var controller = _CoreManager.default.getStorageController();
- return !!controller.async;
- },
- getItem: function (path
- /*: string*/
- )
- /*: ?string*/
- {
- var controller = _CoreManager.default.getStorageController();
- if (controller.async === 1) {
- throw new Error('Synchronous storage is not supported by the current storage controller');
- }
- return controller.getItem(path);
- },
- getItemAsync: function (path
- /*: string*/
- )
- /*: Promise<string>*/
- {
- var controller = _CoreManager.default.getStorageController();
- if (controller.async === 1) {
- return controller.getItemAsync(path);
- }
- return _promise.default.resolve(controller.getItem(path));
- },
- setItem: function (path
- /*: string*/
- , value
- /*: string*/
- )
- /*: void*/
- {
- var controller = _CoreManager.default.getStorageController();
- if (controller.async === 1) {
- throw new Error('Synchronous storage is not supported by the current storage controller');
- }
- return controller.setItem(path, value);
- },
- setItemAsync: function (path
- /*: string*/
- , value
- /*: string*/
- )
- /*: Promise<void>*/
- {
- var controller = _CoreManager.default.getStorageController();
- if (controller.async === 1) {
- return controller.setItemAsync(path, value);
- }
- return _promise.default.resolve(controller.setItem(path, value));
- },
- removeItem: function (path
- /*: string*/
- )
- /*: void*/
- {
- var controller = _CoreManager.default.getStorageController();
- if (controller.async === 1) {
- throw new Error('Synchronous storage is not supported by the current storage controller');
- }
- return controller.removeItem(path);
- },
- removeItemAsync: function (path
- /*: string*/
- )
- /*: Promise<void>*/
- {
- var controller = _CoreManager.default.getStorageController();
- if (controller.async === 1) {
- return controller.removeItemAsync(path);
- }
- return _promise.default.resolve(controller.removeItem(path));
- },
- getAllKeys: function ()
- /*: Array<string>*/
- {
- var controller = _CoreManager.default.getStorageController();
- if (controller.async === 1) {
- throw new Error('Synchronous storage is not supported by the current storage controller');
- }
- return controller.getAllKeys();
- },
- getAllKeysAsync: function ()
- /*: Promise<Array<string>>*/
- {
- var controller = _CoreManager.default.getStorageController();
- if (controller.async === 1) {
- return controller.getAllKeysAsync();
- }
- return _promise.default.resolve(controller.getAllKeys());
- },
- generatePath: function (path
- /*: string*/
- )
- /*: string*/
- {
- var _context;
- if (!_CoreManager.default.get('APPLICATION_ID')) {
- throw new Error('You need to call Moralis.start with an applicationId before using Moralis.');
- }
- if (typeof path !== 'string') {
- throw new Error('Tried to get a Storage path that was not a String.');
- }
- if (path[0] === '/') {
- path = path.substr(1);
- }
- return (0, _concat.default)(_context = "Parse/".concat(_CoreManager.default.get('APPLICATION_ID'), "/")).call(_context, path);
- },
- _clear: function () {
- var controller = _CoreManager.default.getStorageController();
- if (controller.hasOwnProperty('clear')) {
- controller.clear();
- }
- }
- };
- module.exports = Storage;
- _CoreManager.default.setStorageController(_dereq_('./StorageController.browser'));
- },{"./CoreManager":5,"./StorageController.browser":49,"@babel/runtime-corejs3/core-js-stable/instance/concat":81,"@babel/runtime-corejs3/core-js-stable/promise":115,"@babel/runtime-corejs3/helpers/interopRequireDefault":152}],49:[function(_dereq_,module,exports){
- "use strict";
- /**
- * Copyright (c) 2015-present, Parse, LLC.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- *
- * @flow
- * @private
- */
- /* global localStorage */
- var StorageController = {
- async: 0,
- getItem: function (path
- /*: string*/
- )
- /*: ?string*/
- {
- return localStorage.getItem(path);
- },
- setItem: function (path
- /*: string*/
- , value
- /*: string*/
- ) {
- try {
- localStorage.setItem(path, value);
- } catch (e) {
- // Quota exceeded, possibly due to Safari Private Browsing mode
- // eslint-disable-next-line no-console
- console.log(e.message);
- }
- },
- removeItem: function (path
- /*: string*/
- ) {
- localStorage.removeItem(path);
- },
- getAllKeys: function () {
- var keys = [];
- for (var i = 0; i < localStorage.length; i += 1) {
- keys.push(localStorage.key(i));
- }
- return keys;
- },
- clear: function () {
- localStorage.clear();
- }
- };
- module.exports = StorageController;
- },{}],50:[function(_dereq_,module,exports){
- "use strict";
- var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
- var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
- var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
- var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
- var _promiseUtils = _dereq_("./promiseUtils");
- /**
- * Copyright (c) 2015-present, Parse, LLC.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- *
- * @flow
- */
- var TaskQueue = /*#__PURE__*/function () {
- function TaskQueue() {
- (0, _classCallCheck2.default)(this, TaskQueue);
- (0, _defineProperty2.default)(this, "queue", void 0);
- this.queue = [];
- }
- (0, _createClass2.default)(TaskQueue, [{
- key: "enqueue",
- value: function (task
- /*: () => Promise*/
- )
- /*: Promise*/
- {
- var _this = this;
- var taskComplete = new _promiseUtils.resolvingPromise();
- this.queue.push({
- task: task,
- _completion: taskComplete
- });
- if (this.queue.length === 1) {
- task().then(function () {
- _this._dequeue();
- taskComplete.resolve();
- }, function (error) {
- _this._dequeue();
- taskComplete.reject(error);
- });
- }
- return taskComplete;
- }
- }, {
- key: "_dequeue",
- value: function () {
- var _this2 = this;
- this.queue.shift();
- if (this.queue.length) {
- var next = this.queue[0];
- next.task().then(function () {
- _this2._dequeue();
- next._completion.resolve();
- }, function (error) {
- _this2._dequeue();
- next._completion.reject(error);
- });
- }
- }
- }]);
- return TaskQueue;
- }();
- module.exports = TaskQueue;
- },{"./promiseUtils":72,"@babel/runtime-corejs3/helpers/classCallCheck":145,"@babel/runtime-corejs3/helpers/createClass":147,"@babel/runtime-corejs3/helpers/defineProperty":148,"@babel/runtime-corejs3/helpers/interopRequireDefault":152}],51:[function(_dereq_,module,exports){
- "use strict";
- var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
- var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/keys"));
- var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
- var _isInteger = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/number/is-integer"));
- var supportedTypes = ['native', 'erc20', 'erc721', 'erc1155'];
- var ERC1155TransferABI = [{
- inputs: [{
- internalType: 'address',
- name: 'from',
- type: 'address'
- }, {
- internalType: 'address',
- name: 'to',
- type: 'address'
- }, {
- internalType: 'uint256',
- name: 'id',
- type: 'uint256'
- }, {
- internalType: 'uint256',
- name: 'value',
- type: 'uint256'
- }, {
- internalType: 'bytes',
- name: 'data',
- type: 'bytes'
- }],
- outputs: [{
- name: '',
- type: 'bool'
- }],
- name: 'safeTransferFrom',
- type: 'function',
- constant: false,
- payable: false
- }, {
- inputs: [{
- internalType: 'address',
- name: 'from',
- type: 'address'
- }, {
- internalType: 'address',
- name: 'to',
- type: 'address'
- }, {
- internalType: 'uint256',
- name: 'id',
- type: 'uint256'
- }, {
- internalType: 'uint256',
- name: 'value',
- type: 'uint256'
- }],
- outputs: [{
- name: '',
- type: 'bool'
- }],
- name: 'transferFrom',
- type: 'function',
- constant: false,
- payable: false
- }];
- var ERC721TransferABI = [{
- inputs: [{
- internalType: 'address',
- name: 'from',
- type: 'address'
- }, {
- internalType: 'address',
- name: 'to',
- type: 'address'
- }, {
- internalType: 'uint256',
- name: 'tokenId',
- type: 'uint256'
- }],
- outputs: [{
- name: '',
- type: 'bool'
- }],
- name: 'safeTransferFrom',
- type: 'function',
- constant: false,
- payable: false
- }, {
- inputs: [{
- internalType: 'address',
- name: 'from',
- type: 'address'
- }, {
- internalType: 'address',
- name: 'to',
- type: 'address'
- }, {
- internalType: 'uint256',
- name: 'tokenId',
- type: 'uint256'
- }],
- outputs: [{
- name: '',
- type: 'bool'
- }],
- name: 'transferFrom',
- type: 'function',
- constant: false,
- payable: false
- }];
- var ERC20TransferABI = [{
- constant: false,
- inputs: [{
- name: '_to',
- type: 'address'
- }, {
- name: '_value',
- type: 'uint256'
- }],
- name: 'transfer',
- outputs: [{
- name: '',
- type: 'bool'
- }],
- payable: false,
- stateMutability: 'nonpayable',
- type: 'function'
- }, {
- constant: true,
- inputs: [{
- name: '_owner',
- type: 'address'
- }],
- name: 'balanceOf',
- outputs: [{
- name: 'balance',
- type: 'uint256'
- }],
- payable: false,
- stateMutability: 'view',
- type: 'function'
- }];
- var tokenParams = {
- native: {
- receiver: '',
- amount: ''
- },
- erc20: {
- contractAddress: '',
- receiver: '',
- amount: ''
- },
- erc721: {
- contractAddress: '',
- receiver: '',
- tokenId: ''
- },
- erc1155: {
- contractAddress: '',
- receiver: '',
- tokenId: '',
- amount: ''
- }
- };
- var isNotEmpty = function (value) {
- return typeof value !== 'undefined' && value ? true : false;
- };
- var validateInput = function (type, payload) {
- var errors = [];
- var parameters = tokenParams[type];
- for (var _i = 0, _Object$keys = (0, _keys.default)(parameters); _i < _Object$keys.length; _i++) {
- var key = _Object$keys[_i];
- if (!isNotEmpty(payload[key])) {
- errors.push("".concat(key, " is required"));
- }
- }
- if (errors.length > 0) {
- throw errors;
- }
- };
- var isSupportedType = function (type) {
- if ((0, _indexOf.default)(supportedTypes).call(supportedTypes, type) === -1) throw 'Unsupported type';
- return true;
- };
- var isUint256 = function (tokenId) {
- if (!(0, _isInteger.default)(+tokenId) || +tokenId < 0) throw new Error('Invalid token Id');
- return true;
- };
- module.exports = {
- abi: {
- erc1155: ERC1155TransferABI,
- erc721: ERC721TransferABI,
- erc20: ERC20TransferABI
- },
- validateInput: validateInput,
- isSupportedType: isSupportedType,
- isNotEmpty: isNotEmpty,
- isUint256: isUint256
- };
- },{"@babel/runtime-corejs3/core-js-stable/instance/index-of":88,"@babel/runtime-corejs3/core-js-stable/number/is-integer":101,"@babel/runtime-corejs3/core-js-stable/object/keys":112,"@babel/runtime-corejs3/helpers/interopRequireDefault":152}],52:[function(_dereq_,module,exports){
- "use strict";
- var _typeof = _dereq_("@babel/runtime-corejs3/helpers/typeof");
- var _WeakMap2 = _dereq_("@babel/runtime-corejs3/core-js-stable/weak-map");
- var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
- var _Object$getOwnPropertyDescriptor = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
- var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
- _Object$defineProperty(exports, "__esModule", {
- value: true
- });
- exports.clearAllState = clearAllState;
- exports.commitServerChanges = commitServerChanges;
- exports.duplicateState = duplicateState;
- exports.enqueueTask = enqueueTask;
- exports.estimateAttribute = estimateAttribute;
- exports.estimateAttributes = estimateAttributes;
- exports.getObjectCache = getObjectCache;
- exports.getPendingOps = getPendingOps;
- exports.getServerData = getServerData;
- exports.getState = getState;
- exports.initializeState = initializeState;
- exports.mergeFirstPendingState = mergeFirstPendingState;
- exports.popPendingState = popPendingState;
- exports.pushPendingState = pushPendingState;
- exports.removeState = removeState;
- exports.setPendingOp = setPendingOp;
- exports.setServerData = setServerData;
- var _weakMap = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/weak-map"));
- var ObjectStateMutations = _interopRequireWildcard(_dereq_("./ObjectStateMutations"));
- var _TaskQueue = _interopRequireDefault(_dereq_("./TaskQueue"));
- function _getRequireWildcardCache(nodeInterop) {
- if (typeof _WeakMap2 !== "function") return null;
- var cacheBabelInterop = new _WeakMap2();
- var cacheNodeInterop = new _WeakMap2();
- return (_getRequireWildcardCache = function (nodeInterop) {
- return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
- })(nodeInterop);
- }
- function _interopRequireWildcard(obj, nodeInterop) {
- if (!nodeInterop && obj && obj.__esModule) {
- return obj;
- }
- if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") {
- return {
- default: obj
- };
- }
- var cache = _getRequireWildcardCache(nodeInterop);
- if (cache && cache.has(obj)) {
- return cache.get(obj);
- }
- var newObj = {};
- for (var key in obj) {
- if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
- var desc = _Object$defineProperty && _Object$getOwnPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null;
- if (desc && (desc.get || desc.set)) {
- _Object$defineProperty(newObj, key, desc);
- } else {
- newObj[key] = obj[key];
- }
- }
- }
- newObj.default = obj;
- if (cache) {
- cache.set(obj, newObj);
- }
- return newObj;
- }
- /**
- * Copyright (c) 2015-present, Parse, LLC.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- *
- * @flow
- */
- var objectState = new _weakMap.default();
- function getState(obj
- /*: ParseObject*/
- )
- /*: ?State*/
- {
- var classData = objectState.get(obj);
- return classData || null;
- }
- function initializeState(obj
- /*: ParseObject*/
- , initial
- /*:: ?: State*/
- )
- /*: State*/
- {
- var state = getState(obj);
- if (state) {
- return state;
- }
- if (!initial) {
- initial = {
- serverData: {},
- pendingOps: [{}],
- objectCache: {},
- tasks: new _TaskQueue.default(),
- existed: false
- };
- }
- state = initial;
- objectState.set(obj, state);
- return state;
- }
- function removeState(obj
- /*: ParseObject*/
- )
- /*: ?State*/
- {
- var state = getState(obj);
- if (state === null) {
- return null;
- }
- objectState.delete(obj);
- return state;
- }
- function getServerData(obj
- /*: ParseObject*/
- )
- /*: AttributeMap*/
- {
- var state = getState(obj);
- if (state) {
- return state.serverData;
- }
- return {};
- }
- function setServerData(obj
- /*: ParseObject*/
- , attributes
- /*: AttributeMap*/
- ) {
- var _initializeState = initializeState(obj),
- serverData = _initializeState.serverData;
- ObjectStateMutations.setServerData(serverData, attributes);
- }
- function getPendingOps(obj
- /*: ParseObject*/
- )
- /*: Array<OpsMap>*/
- {
- var state = getState(obj);
- if (state) {
- return state.pendingOps;
- }
- return [{}];
- }
- function setPendingOp(obj
- /*: ParseObject*/
- , attr
- /*: string*/
- , op
- /*: ?Op*/
- ) {
- var _initializeState2 = initializeState(obj),
- pendingOps = _initializeState2.pendingOps;
- ObjectStateMutations.setPendingOp(pendingOps, attr, op);
- }
- function pushPendingState(obj
- /*: ParseObject*/
- ) {
- var _initializeState3 = initializeState(obj),
- pendingOps = _initializeState3.pendingOps;
- ObjectStateMutations.pushPendingState(pendingOps);
- }
- function popPendingState(obj
- /*: ParseObject*/
- )
- /*: OpsMap*/
- {
- var _initializeState4 = initializeState(obj),
- pendingOps = _initializeState4.pendingOps;
- return ObjectStateMutations.popPendingState(pendingOps);
- }
- function mergeFirstPendingState(obj
- /*: ParseObject*/
- ) {
- var pendingOps = getPendingOps(obj);
- ObjectStateMutations.mergeFirstPendingState(pendingOps);
- }
- function getObjectCache(obj
- /*: ParseObject*/
- )
- /*: ObjectCache*/
- {
- var state = getState(obj);
- if (state) {
- return state.objectCache;
- }
- return {};
- }
- function estimateAttribute(obj
- /*: ParseObject*/
- , attr
- /*: string*/
- )
- /*: mixed*/
- {
- var serverData = getServerData(obj);
- var pendingOps = getPendingOps(obj);
- return ObjectStateMutations.estimateAttribute(serverData, pendingOps, obj.className, obj.id, attr);
- }
- function estimateAttributes(obj
- /*: ParseObject*/
- )
- /*: AttributeMap*/
- {
- var serverData = getServerData(obj);
- var pendingOps = getPendingOps(obj);
- return ObjectStateMutations.estimateAttributes(serverData, pendingOps, obj.className, obj.id);
- }
- function commitServerChanges(obj
- /*: ParseObject*/
- , changes
- /*: AttributeMap*/
- ) {
- var state = initializeState(obj);
- ObjectStateMutations.commitServerChanges(state.serverData, state.objectCache, changes);
- }
- function enqueueTask(obj
- /*: ParseObject*/
- , task
- /*: () => Promise*/
- )
- /*: Promise*/
- {
- var state = initializeState(obj);
- return state.tasks.enqueue(task);
- }
- function duplicateState(source
- /*: ParseObject*/
- , dest
- /*: ParseObject*/
- )
- /*: void*/
- {
- var oldState = initializeState(source);
- var newState = initializeState(dest);
- for (var key in oldState.serverData) {
- newState.serverData[key] = oldState.serverData[key];
- }
- for (var index = 0; index < oldState.pendingOps.length; index++) {
- for (var _key in oldState.pendingOps[index]) {
- newState.pendingOps[index][_key] = oldState.pendingOps[index][_key];
- }
- }
- for (var _key2 in oldState.objectCache) {
- newState.objectCache[_key2] = oldState.objectCache[_key2];
- }
- newState.existed = oldState.existed;
- }
- function clearAllState() {
- objectState = new _weakMap.default();
- }
- },{"./ObjectStateMutations":23,"./TaskQueue":50,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor":108,"@babel/runtime-corejs3/core-js-stable/weak-map":122,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/helpers/typeof":164}],53:[function(_dereq_,module,exports){
- "use strict";
- var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
- var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
- var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
- var _ethers = _dereq_("ethers");
- var UnitConverter = /*#__PURE__*/function () {
- function UnitConverter() {
- (0, _classCallCheck2.default)(this, UnitConverter);
- }
- (0, _createClass2.default)(UnitConverter, null, [{
- key: "ETH",
- value: function (value) {
- return _ethers.ethers.utils.parseEther("".concat(value)).toString();
- }
- }, {
- key: "Token",
- value: function (value) {
- var decimals = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 18;
- return _ethers.ethers.utils.parseUnits("".concat(value), +decimals).toString();
- }
- }, {
- key: "FromWei",
- value: function (value) {
- var decimals = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 18;
- var result = _ethers.ethers.utils.formatUnits(value, decimals); // formatUnits will always add a trailing 0, remove this as we want to return "1" instead of "1.0"
- var splitResult = result.split('.');
- if (splitResult[1] === '0') {
- return splitResult[0];
- }
- return result;
- }
- }]);
- return UnitConverter;
- }();
- module.exports = UnitConverter;
- },{"@babel/runtime-corejs3/helpers/classCallCheck":145,"@babel/runtime-corejs3/helpers/createClass":147,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"ethers":773}],54:[function(_dereq_,module,exports){
- "use strict";
- var _Reflect$construct = _dereq_("@babel/runtime-corejs3/core-js-stable/reflect/construct");
- var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
- var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
- _Object$defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = void 0;
- var _regenerator = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/regenerator"));
- var _bind = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/bind"));
- var _asyncToGenerator2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/asyncToGenerator"));
- var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
- var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
- var _assertThisInitialized2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/assertThisInitialized"));
- var _inherits2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/inherits"));
- var _possibleConstructorReturn2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/possibleConstructorReturn"));
- var _getPrototypeOf2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/getPrototypeOf"));
- var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
- var _events = _interopRequireDefault(_dereq_("events"));
- var _verifyChainId = _interopRequireDefault(_dereq_("../utils/verifyChainId"));
- var _events2 = _dereq_("./events");
- function _createSuper(Derived) {
- var hasNativeReflectConstruct = _isNativeReflectConstruct();
- return function () {
- var Super = (0, _getPrototypeOf2.default)(Derived),
- result;
- if (hasNativeReflectConstruct) {
- var NewTarget = (0, _getPrototypeOf2.default)(this).constructor;
- result = _Reflect$construct(Super, arguments, NewTarget);
- } else {
- result = Super.apply(this, arguments);
- }
- return (0, _possibleConstructorReturn2.default)(this, result);
- };
- }
- function _isNativeReflectConstruct() {
- if (typeof Reflect === "undefined" || !_Reflect$construct) return false;
- if (_Reflect$construct.sham) return false;
- if (typeof Proxy === "function") return true;
- try {
- Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {}));
- return true;
- } catch (e) {
- return false;
- }
- }
- /**
- * Abstract connector to connect EIP-1193 providers to Moralis
- *
- * It should implement at least:
- * - activate()
- * - Emit ConnectorEvent.CHAIN_CHANGED when the chain has changed (if possible)
- * - Emit ConnectorEvent.ACCOUNT_CHANGED when the account has changed (if possible)
- * - type: a name to identify
- * - network: the network type that is used (eg. 'evm')
- */
- var AbstractWeb3Connector = /*#__PURE__*/function (_EventEmitter) {
- (0, _inherits2.default)(AbstractWeb3Connector, _EventEmitter);
- var _super = _createSuper(AbstractWeb3Connector);
- function AbstractWeb3Connector() {
- var _context, _context2, _context3, _context4;
- var _this;
- (0, _classCallCheck2.default)(this, AbstractWeb3Connector);
- _this = _super.call(this);
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "type", 'abstract');
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "network", 'evm');
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "account", null);
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "chainId", null);
- _this.handleAccountsChanged = (0, _bind.default)(_context = _this.handleAccountsChanged).call(_context, (0, _assertThisInitialized2.default)(_this));
- _this.handleChainChanged = (0, _bind.default)(_context2 = _this.handleChainChanged).call(_context2, (0, _assertThisInitialized2.default)(_this));
- _this.handleConnect = (0, _bind.default)(_context3 = _this.handleConnect).call(_context3, (0, _assertThisInitialized2.default)(_this));
- _this.handleDisconnect = (0, _bind.default)(_context4 = _this.handleDisconnect).call(_context4, (0, _assertThisInitialized2.default)(_this));
- return _this;
- }
- (0, _createClass2.default)(AbstractWeb3Connector, [{
- key: "subscribeToEvents",
- value: function (provider) {
- if (provider && provider.on) {
- provider.on(_events2.EthereumEvents.CHAIN_CHANGED, this.handleChainChanged);
- provider.on(_events2.EthereumEvents.ACCOUNTS_CHANGED, this.handleAccountsChanged);
- provider.on(_events2.EthereumEvents.CONNECT, this.handleConnect);
- provider.on(_events2.EthereumEvents.DISCONNECT, this.handleDisconnect);
- }
- }
- }, {
- key: "unsubscribeToEvents",
- value: function (provider) {
- if (provider && provider.removeListener) {
- provider.removeListener(_events2.EthereumEvents.CHAIN_CHANGED, this.handleChainChanged);
- provider.removeListener(_events2.EthereumEvents.ACCOUNTS_CHANGED, this.handleAccountsChanged);
- provider.removeListener(_events2.EthereumEvents.CONNECT, this.handleConnect);
- provider.removeListener(_events2.EthereumEvents.DISCONNECT, this.handleDisconnect);
- }
- }
- /**
- * Activates the provider.
- * Should returns an object with:
- * - provider: A valid EIP-1193 provider
- * - chainId(optional): the chainId that has been connected to (in hex format)
- * - account(optional): the address that is connected to the provider
- */
- }, {
- key: "activate",
- value: function () {
- var _activate = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
- return _regenerator.default.wrap(function (_context5) {
- while (1) {
- switch (_context5.prev = _context5.next) {
- case 0:
- throw new Error('Not implemented: activate()');
- case 1:
- case "end":
- return _context5.stop();
- }
- }
- }, _callee);
- }));
- return function () {
- return _activate.apply(this, arguments);
- };
- }()
- /**
- * Updates account and emit event, on EIP-1193 accountsChanged events
- */
- }, {
- key: "handleAccountsChanged",
- value: function (accounts) {
- var account = accounts && accounts[0] ? accounts[0].toLowerCase() : null;
- this.account = account;
- this.emit(_events2.ConnectorEvents.ACCOUNT_CHANGED, account);
- }
- /**
- * Updates chainId and emit event, on EIP-1193 accountsChanged events
- */
- }, {
- key: "handleChainChanged",
- value: function (chainId) {
- var newChainId = (0, _verifyChainId.default)(chainId);
- this.chainId = newChainId;
- this.emit(_events2.ConnectorEvents.CHAIN_CHANGED, newChainId);
- }
- }, {
- key: "handleConnect",
- value: function (connectInfo) {
- this.emit(_events2.ConnectorEvents.CONNECT, connectInfo);
- }
- }, {
- key: "handleDisconnect",
- value: function (error) {
- this.emit(_events2.ConnectorEvents.DISCONNECT, error);
- }
- /**
- * Cleans all active listners, connections and stale references
- */
- }, {
- key: "deactivate",
- value: function () {
- var _deactivate = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
- return _regenerator.default.wrap(function (_context6) {
- while (1) {
- switch (_context6.prev = _context6.next) {
- case 0:
- this.unsubscribeToEvents(this.provider);
- this.account = null;
- this.chainId = null;
- case 3:
- case "end":
- return _context6.stop();
- }
- }
- }, _callee2, this);
- }));
- return function () {
- return _deactivate.apply(this, arguments);
- };
- }()
- }]);
- return AbstractWeb3Connector;
- }(_events.default);
- var _default = AbstractWeb3Connector;
- exports.default = _default;
- },{"../utils/verifyChainId":77,"./events":61,"@babel/runtime-corejs3/core-js-stable/instance/bind":80,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/core-js-stable/reflect/construct":116,"@babel/runtime-corejs3/helpers/assertThisInitialized":143,"@babel/runtime-corejs3/helpers/asyncToGenerator":144,"@babel/runtime-corejs3/helpers/classCallCheck":145,"@babel/runtime-corejs3/helpers/createClass":147,"@babel/runtime-corejs3/helpers/defineProperty":148,"@babel/runtime-corejs3/helpers/getPrototypeOf":150,"@babel/runtime-corejs3/helpers/inherits":151,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/helpers/possibleConstructorReturn":159,"@babel/runtime-corejs3/regenerator":167,"events":775}],55:[function(_dereq_,module,exports){
- "use strict";
- var _Reflect$construct = _dereq_("@babel/runtime-corejs3/core-js-stable/reflect/construct");
- var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
- var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
- _Object$defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = exports.InjectedEvents = void 0;
- var _regenerator = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/regenerator"));
- var _slicedToArray2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/slicedToArray"));
- var _asyncToGenerator2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/asyncToGenerator"));
- var _assertThisInitialized2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/assertThisInitialized"));
- var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
- var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
- var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
- var _inherits2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/inherits"));
- var _possibleConstructorReturn2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/possibleConstructorReturn"));
- var _getPrototypeOf2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/getPrototypeOf"));
- var _wrapNativeSuper2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/wrapNativeSuper"));
- var _freeze = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/freeze"));
- var _concat = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/concat"));
- var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
- var _AbstractWeb3Connector = _interopRequireDefault(_dereq_("./AbstractWeb3Connector"));
- var _events = _interopRequireDefault(_dereq_("events"));
- var _verifyChainId = _interopRequireDefault(_dereq_("../utils/verifyChainId"));
- function _createSuper(Derived) {
- var hasNativeReflectConstruct = _isNativeReflectConstruct();
- return function () {
- var Super = (0, _getPrototypeOf2.default)(Derived),
- result;
- if (hasNativeReflectConstruct) {
- var NewTarget = (0, _getPrototypeOf2.default)(this).constructor;
- result = _Reflect$construct(Super, arguments, NewTarget);
- } else {
- result = Super.apply(this, arguments);
- }
- return (0, _possibleConstructorReturn2.default)(this, result);
- };
- }
- function _isNativeReflectConstruct() {
- if (typeof Reflect === "undefined" || !_Reflect$construct) return false;
- if (_Reflect$construct.sham) return false;
- if (typeof Proxy === "function") return true;
- try {
- Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {}));
- return true;
- } catch (e) {
- return false;
- }
- }
- var InjectedEvents = (0, _freeze.default)({
- ACCOUNTS_CHANGED: 'accountsChanged',
- CHAIN_CHANGED: 'chainChanged',
- CONNECT: 'connect',
- DISCONNECT: 'disconnect'
- });
- exports.InjectedEvents = InjectedEvents;
- var NoEthereumProviderError = /*#__PURE__*/function (_Error) {
- (0, _inherits2.default)(NoEthereumProviderError, _Error);
- var _super = _createSuper(NoEthereumProviderError);
- function NoEthereumProviderError() {
- var _this;
- (0, _classCallCheck2.default)(this, NoEthereumProviderError);
- _this = _super.call(this);
- _this.message = 'Non ethereum enabled browser';
- return _this;
- }
- return (0, _createClass2.default)(NoEthereumProviderError);
- }( /*#__PURE__*/(0, _wrapNativeSuper2.default)(Error));
- /**
- * Connector to connect an injected provider (like Metamask) to Moralis
- * The provider should be injected in window.ethereum
- */
- var InjectedWeb3Connector = /*#__PURE__*/function (_AbstractWeb3Connecto) {
- (0, _inherits2.default)(InjectedWeb3Connector, _AbstractWeb3Connecto);
- var _super2 = _createSuper(InjectedWeb3Connector);
- function InjectedWeb3Connector() {
- var _context;
- var _this2;
- (0, _classCallCheck2.default)(this, InjectedWeb3Connector);
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
- args[_key] = arguments[_key];
- }
- _this2 = _super2.call.apply(_super2, (0, _concat.default)(_context = [this]).call(_context, args));
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this2), "type", 'injected');
- return _this2;
- }
- (0, _createClass2.default)(InjectedWeb3Connector, [{
- key: "verifyEthereumBrowser",
- value: function () {
- var _window;
- if (!((_window = window) !== null && _window !== void 0 && _window.ethereum)) {
- throw new NoEthereumProviderError();
- }
- }
- }, {
- key: "activate",
- value: function () {
- var _activate = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
- var _yield$Promise$all, _yield$Promise$all2, accounts, chainId, account, provider;
- return _regenerator.default.wrap(function (_context2) {
- while (1) {
- switch (_context2.prev = _context2.next) {
- case 0:
- this.verifyEthereumBrowser();
- _context2.next = 3;
- return _promise.default.all([window.ethereum.request({
- method: 'eth_requestAccounts'
- }), window.ethereum.request({
- method: 'eth_chainId'
- })]);
- case 3:
- _yield$Promise$all = _context2.sent;
- _yield$Promise$all2 = (0, _slicedToArray2.default)(_yield$Promise$all, 2);
- accounts = _yield$Promise$all2[0];
- chainId = _yield$Promise$all2[1];
- account = accounts[0] ? accounts[0].toLowerCase() : null;
- provider = window.ethereum;
- this.chainId = chainId;
- this.account = account;
- this.provider = provider;
- this.subscribeToEvents(provider);
- return _context2.abrupt("return", {
- provider: provider,
- chainId: chainId,
- account: account
- });
- case 14:
- case "end":
- return _context2.stop();
- }
- }
- }, _callee, this);
- }));
- return function () {
- return _activate.apply(this, arguments);
- };
- }()
- }, {
- key: "switchNetwork",
- value: function () {
- var _switchNetwork = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(chainId) {
- var currentNetwork;
- return _regenerator.default.wrap(function (_context3) {
- while (1) {
- switch (_context3.prev = _context3.next) {
- case 0:
- this.verifyEthereumBrowser();
- chainId = (0, _verifyChainId.default)(chainId);
- currentNetwork = this.chainId;
- if (!(currentNetwork === chainId)) {
- _context3.next = 5;
- break;
- }
- return _context3.abrupt("return");
- case 5:
- _context3.next = 7;
- return window.ethereum.request({
- method: 'wallet_switchEthereumChain',
- params: [{
- chainId: chainId
- }]
- });
- case 7:
- case "end":
- return _context3.stop();
- }
- }
- }, _callee2, this);
- }));
- return function () {
- return _switchNetwork.apply(this, arguments);
- };
- }()
- }, {
- key: "addNetwork",
- value: function () {
- var _addNetwork = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(chainId, chainName, currencyName, currencySymbol, rpcUrl, blockExplorerUrl) {
- var newchainId;
- return _regenerator.default.wrap(function (_context4) {
- while (1) {
- switch (_context4.prev = _context4.next) {
- case 0:
- this.verifyEthereumBrowser();
- newchainId = (0, _verifyChainId.default)(chainId);
- _context4.next = 4;
- return window.ethereum.request({
- method: 'wallet_addEthereumChain',
- params: [{
- chainId: newchainId,
- chainName: chainName,
- nativeCurrency: {
- name: currencyName,
- symbol: currencySymbol,
- decimals: 18
- },
- rpcUrls: [rpcUrl],
- blockExplorerUrls: blockExplorerUrl ? [blockExplorerUrl] : null
- }]
- });
- case 4:
- case "end":
- return _context4.stop();
- }
- }
- }, _callee3, this);
- }));
- return function () {
- return _addNetwork.apply(this, arguments);
- };
- }()
- }]);
- return InjectedWeb3Connector;
- }(_AbstractWeb3Connector.default);
- var _default = InjectedWeb3Connector;
- exports.default = _default;
- },{"../utils/verifyChainId":77,"./AbstractWeb3Connector":54,"@babel/runtime-corejs3/core-js-stable/instance/concat":81,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/core-js-stable/object/freeze":107,"@babel/runtime-corejs3/core-js-stable/promise":115,"@babel/runtime-corejs3/core-js-stable/reflect/construct":116,"@babel/runtime-corejs3/helpers/assertThisInitialized":143,"@babel/runtime-corejs3/helpers/asyncToGenerator":144,"@babel/runtime-corejs3/helpers/classCallCheck":145,"@babel/runtime-corejs3/helpers/createClass":147,"@babel/runtime-corejs3/helpers/defineProperty":148,"@babel/runtime-corejs3/helpers/getPrototypeOf":150,"@babel/runtime-corejs3/helpers/inherits":151,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/helpers/possibleConstructorReturn":159,"@babel/runtime-corejs3/helpers/slicedToArray":161,"@babel/runtime-corejs3/helpers/wrapNativeSuper":166,"@babel/runtime-corejs3/regenerator":167,"events":775}],56:[function(_dereq_,module,exports){
- "use strict";
- var _Reflect$construct = _dereq_("@babel/runtime-corejs3/core-js-stable/reflect/construct");
- var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
- var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
- _Object$defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = void 0;
- var _regenerator = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/regenerator"));
- var _concat = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/concat"));
- var _asyncToGenerator2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/asyncToGenerator"));
- var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
- var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
- var _assertThisInitialized2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/assertThisInitialized"));
- var _inherits2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/inherits"));
- var _possibleConstructorReturn2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/possibleConstructorReturn"));
- var _getPrototypeOf2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/getPrototypeOf"));
- var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
- var _ethers = _dereq_("ethers");
- var _AbstractWeb3Connector = _interopRequireDefault(_dereq_("./AbstractWeb3Connector"));
- function _createSuper(Derived) {
- var hasNativeReflectConstruct = _isNativeReflectConstruct();
- return function () {
- var Super = (0, _getPrototypeOf2.default)(Derived),
- result;
- if (hasNativeReflectConstruct) {
- var NewTarget = (0, _getPrototypeOf2.default)(this).constructor;
- result = _Reflect$construct(Super, arguments, NewTarget);
- } else {
- result = Super.apply(this, arguments);
- }
- return (0, _possibleConstructorReturn2.default)(this, result);
- };
- }
- function _isNativeReflectConstruct() {
- if (typeof Reflect === "undefined" || !_Reflect$construct) return false;
- if (_Reflect$construct.sham) return false;
- if (typeof Proxy === "function") return true;
- try {
- Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {}));
- return true;
- } catch (e) {
- return false;
- }
- }
- var MagicWeb3Connector = /*#__PURE__*/function (_AbstractWeb3Connecto) {
- (0, _inherits2.default)(MagicWeb3Connector, _AbstractWeb3Connecto);
- var _super = _createSuper(MagicWeb3Connector);
- function MagicWeb3Connector() {
- var _context;
- var _this;
- (0, _classCallCheck2.default)(this, MagicWeb3Connector);
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
- args[_key] = arguments[_key];
- }
- _this = _super.call.apply(_super, (0, _concat.default)(_context = [this]).call(_context, args));
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "type", 'MagicLink');
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "deactivate", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
- return _regenerator.default.wrap(function (_context2) {
- while (1) {
- switch (_context2.prev = _context2.next) {
- case 0:
- _this.unsubscribeToEvents(_this.provider);
- if (!_this.magicUser) {
- _context2.next = 4;
- break;
- }
- _context2.next = 4;
- return _this.magicUser.user.logout();
- case 4:
- _this.account = null;
- _this.chainId = null;
- _this.provider = null;
- case 7:
- case "end":
- return _context2.stop();
- }
- }
- }, _callee);
- })));
- return _this;
- }
- (0, _createClass2.default)(MagicWeb3Connector, [{
- key: "activate",
- value: function () {
- var _activate = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
- var _ref2,
- email,
- apiKey,
- network,
- newSession,
- magic,
- ether,
- Magic,
- _require,
- _window,
- _magic,
- _magic2,
- _magic2$user,
- loggedIn,
- signer,
- _yield$ether$getNetwo,
- chainId,
- address,
- _args2 = arguments;
- return _regenerator.default.wrap(function (_context3) {
- while (1) {
- switch (_context3.prev = _context3.next) {
- case 0:
- _ref2 = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {}, email = _ref2.email, apiKey = _ref2.apiKey, network = _ref2.network, newSession = _ref2.newSession;
- magic = null;
- ether = null;
- if (email) {
- _context3.next = 5;
- break;
- }
- throw new Error('"email" not provided, please provide Email');
- case 5:
- if (apiKey) {
- _context3.next = 7;
- break;
- }
- throw new Error('"apiKey" not provided, please provide Api Key');
- case 7:
- if (network) {
- _context3.next = 9;
- break;
- }
- throw new Error('"network" not provided, please provide network');
- case 9:
- try {
- Magic = (_require = _dereq_('magic-sdk')) === null || _require === void 0 ? void 0 : _require.Magic;
- } catch (error) {// Do nothing. User might not need walletconnect
- }
- if (!Magic) {
- Magic = (_window = window) === null || _window === void 0 ? void 0 : _window.Magic;
- }
- if (Magic) {
- _context3.next = 13;
- break;
- }
- throw new Error('Cannot enable via MagicLink: dependency "magic-sdk" is missing');
- case 13:
- _context3.prev = 13;
- magic = new Magic(apiKey, {
- network: network
- });
- if (!newSession) {
- _context3.next = 24;
- break;
- }
- if (!((_magic = magic) !== null && _magic !== void 0 && _magic.user)) {
- _context3.next = 24;
- break;
- }
- _context3.prev = 17;
- _context3.next = 20;
- return (_magic2 = magic) === null || _magic2 === void 0 ? void 0 : (_magic2$user = _magic2.user) === null || _magic2$user === void 0 ? void 0 : _magic2$user.logout();
- case 20:
- _context3.next = 24;
- break;
- case 22:
- _context3.prev = 22;
- _context3.t0 = _context3["catch"](17);
- case 24:
- ether = new _ethers.ethers.providers.Web3Provider(magic.rpcProvider);
- _context3.next = 27;
- return magic.auth.loginWithMagicLink({
- email: email
- });
- case 27:
- _context3.next = 32;
- break;
- case 29:
- _context3.prev = 29;
- _context3.t1 = _context3["catch"](13);
- throw new Error('Error during enable via MagicLink, please double check network and apikey');
- case 32:
- _context3.next = 34;
- return magic.user.isLoggedIn();
- case 34:
- loggedIn = _context3.sent;
- if (!loggedIn) {
- _context3.next = 50;
- break;
- }
- signer = ether.getSigner();
- _context3.next = 39;
- return ether.getNetwork();
- case 39:
- _yield$ether$getNetwo = _context3.sent;
- chainId = _yield$ether$getNetwo.chainId;
- _context3.next = 43;
- return signer.getAddress();
- case 43:
- address = _context3.sent.toLowerCase(); // Assign Constants
- this.account = address;
- this.provider = ether.provider;
- this.chainId = "0x".concat(chainId.toString(16)); // Assign magic user for deactivation
- this.magicUser = magic;
- this.subscribeToEvents(this.provider);
- return _context3.abrupt("return", {
- provider: this.provider,
- account: this.account,
- chainId: this.chainId
- });
- case 50:
- throw new Error('Error during enable via MagicLink, login to magic failed');
- case 51:
- case "end":
- return _context3.stop();
- }
- }
- }, _callee2, this, [[13, 29], [17, 22]]);
- }));
- return function () {
- return _activate.apply(this, arguments);
- };
- }()
- }]);
- return MagicWeb3Connector;
- }(_AbstractWeb3Connector.default);
- exports.default = MagicWeb3Connector;
- },{"./AbstractWeb3Connector":54,"@babel/runtime-corejs3/core-js-stable/instance/concat":81,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/core-js-stable/reflect/construct":116,"@babel/runtime-corejs3/helpers/assertThisInitialized":143,"@babel/runtime-corejs3/helpers/asyncToGenerator":144,"@babel/runtime-corejs3/helpers/classCallCheck":145,"@babel/runtime-corejs3/helpers/createClass":147,"@babel/runtime-corejs3/helpers/defineProperty":148,"@babel/runtime-corejs3/helpers/getPrototypeOf":150,"@babel/runtime-corejs3/helpers/inherits":151,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/helpers/possibleConstructorReturn":159,"@babel/runtime-corejs3/regenerator":167,"ethers":773,"magic-sdk":323}],57:[function(_dereq_,module,exports){
- "use strict";
- var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
- _Object$defineProperty(exports, "__esModule", {
- value: true
- });
- exports.getMoralisRpcs = void 0;
- var getMoralisRpcs = function (speedyNodeKey) {
- return {
- 1: "https://speedy-nodes-nyc.moralis.io/".concat(speedyNodeKey, "/eth/mainnet"),
- 3: "https://speedy-nodes-nyc.moralis.io/".concat(speedyNodeKey, "/eth/ropsten"),
- 4: "https://speedy-nodes-nyc.moralis.io/".concat(speedyNodeKey, "/eth/rinkeby"),
- 5: "https://speedy-nodes-nyc.moralis.io/".concat(speedyNodeKey, "/eth/goerli"),
- 42: "https://speedy-nodes-nyc.moralis.io/".concat(speedyNodeKey, "/eth/kovan"),
- 137: "https://speedy-nodes-nyc.moralis.io/".concat(speedyNodeKey, "/polygon/mainnet"),
- 80001: "https://speedy-nodes-nyc.moralis.io/".concat(speedyNodeKey, "/polygon/mumbai"),
- 56: "https://speedy-nodes-nyc.moralis.io/".concat(speedyNodeKey, "/bsc/mainnet"),
- 97: "https://speedy-nodes-nyc.moralis.io/".concat(speedyNodeKey, "/bsc/testnet"),
- 43114: "https://speedy-nodes-nyc.moralis.io/".concat(speedyNodeKey, "/avalanche/mainnet"),
- 43113: "https://speedy-nodes-nyc.moralis.io/".concat(speedyNodeKey, "/avalanche/testnet"),
- 250: "https://speedy-nodes-nyc.moralis.io/".concat(speedyNodeKey, "/fantom/mainnet")
- };
- };
- exports.getMoralisRpcs = getMoralisRpcs;
- },{"@babel/runtime-corejs3/core-js-stable/object/define-property":105}],58:[function(_dereq_,module,exports){
- "use strict";
- var _Reflect$construct = _dereq_("@babel/runtime-corejs3/core-js-stable/reflect/construct");
- var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
- var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
- _Object$defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = void 0;
- var _regenerator = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/regenerator"));
- var _stringify = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/json/stringify"));
- var _concat = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/concat"));
- var _url = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/url"));
- var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/keys"));
- var _reduce = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/reduce"));
- var _assertThisInitialized2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/assertThisInitialized"));
- var _inherits2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/inherits"));
- var _possibleConstructorReturn2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/possibleConstructorReturn"));
- var _getPrototypeOf2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/getPrototypeOf"));
- var _asyncToGenerator2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/asyncToGenerator"));
- var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
- var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
- var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
- var _CoreManager = _interopRequireDefault(_dereq_("../CoreManager"));
- var _convert = _dereq_("../utils/convert");
- var _verifyChainId = _interopRequireDefault(_dereq_("../utils/verifyChainId"));
- var _AbstractWeb3Connector = _interopRequireDefault(_dereq_("./AbstractWeb3Connector"));
- var _MoralisRpcs = _dereq_("./MoralisRpcs");
- var _ethers = _dereq_("ethers");
- function _createSuper(Derived) {
- var hasNativeReflectConstruct = _isNativeReflectConstruct();
- return function () {
- var Super = (0, _getPrototypeOf2.default)(Derived),
- result;
- if (hasNativeReflectConstruct) {
- var NewTarget = (0, _getPrototypeOf2.default)(this).constructor;
- result = _Reflect$construct(Super, arguments, NewTarget);
- } else {
- result = Super.apply(this, arguments);
- }
- return (0, _possibleConstructorReturn2.default)(this, result);
- };
- }
- function _isNativeReflectConstruct() {
- if (typeof Reflect === "undefined" || !_Reflect$construct) return false;
- if (_Reflect$construct.sham) return false;
- if (typeof Proxy === "function") return true;
- try {
- Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {}));
- return true;
- } catch (e) {
- return false;
- }
- }
- var MiniRpcProvider = /*#__PURE__*/(0, _createClass2.default)(function MiniRpcProvider(chainId, url) {
- var _this = this;
- (0, _classCallCheck2.default)(this, MiniRpcProvider);
- (0, _defineProperty2.default)(this, "request", /*#__PURE__*/function () {
- var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(method, params) {
- var RESTController, response, _context, body, _body$error, _body$error2, _body$error3, _context2;
- return _regenerator.default.wrap(function (_context3) {
- while (1) {
- switch (_context3.prev = _context3.next) {
- case 0:
- if (typeof method !== 'string') {
- // eslint-disable-next-line prefer-destructuring
- params = method.params; // eslint-disable-next-line prefer-destructuring
- method = method.method;
- }
- RESTController = _CoreManager.default.getRESTController();
- _context3.prev = 2;
- _context3.next = 5;
- return RESTController.ajax('POST', _this.url, (0, _stringify.default)({
- jsonrpc: '2.0',
- id: 1,
- method: method,
- params: params
- }), {
- 'Content-Type': 'application/json'
- });
- case 5:
- response = _context3.sent;
- if (response) {
- _context3.next = 8;
- break;
- }
- throw new Error('No response');
- case 8:
- if (!(!response.status || response.status > 400)) {
- _context3.next = 10;
- break;
- }
- throw new Error((0, _concat.default)(_context = "Error response [".concat(response.status, "] ")).call(_context, response.statusText));
- case 10:
- body = response.response;
- if (!('error' in body)) {
- _context3.next = 13;
- break;
- }
- throw new Error(body === null || body === void 0 ? void 0 : (_body$error = body.error) === null || _body$error === void 0 ? void 0 : _body$error.message, body === null || body === void 0 ? void 0 : (_body$error2 = body.error) === null || _body$error2 === void 0 ? void 0 : _body$error2.code, body === null || body === void 0 ? void 0 : (_body$error3 = body.error) === null || _body$error3 === void 0 ? void 0 : _body$error3.data);
- case 13:
- if ('result' in body) {
- _context3.next = 15;
- break;
- }
- throw new Error("Received unexpected JSON-RPC response");
- case 15:
- return _context3.abrupt("return", body.result);
- case 18:
- _context3.prev = 18;
- _context3.t0 = _context3["catch"](2);
- throw new Error((0, _concat.default)(_context2 = "Failed to make \"".concat(method, "\" request with networkConnector: \"")).call(_context2, _context3.t0.message, "\""));
- case 21:
- case "end":
- return _context3.stop();
- }
- }
- }, _callee, null, [[2, 18]]);
- }));
- return function () {
- return _ref.apply(this, arguments);
- };
- }());
- this.chainId = chainId;
- this.url = url;
- var parsed = new _url.default(url);
- this.host = parsed.host;
- this.path = parsed.pathname;
- });
- /**
- * Connect to web3 via a network url
- * Note: this has no knowledge of any user accounts
- */
- var NetworkWeb3Connector = /*#__PURE__*/function (_AbstractWeb3Connecto) {
- (0, _inherits2.default)(NetworkWeb3Connector, _AbstractWeb3Connecto);
- var _super = _createSuper(NetworkWeb3Connector);
- function NetworkWeb3Connector() {
- var _ref3, _context4;
- var _this2;
- var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
- urls = _ref2.urls,
- defaultChainId = _ref2.defaultChainId,
- chainId = _ref2.chainId,
- speedyNodeApiKey = _ref2.speedyNodeApiKey;
- (0, _classCallCheck2.default)(this, NetworkWeb3Connector);
- _this2 = _super.call(this);
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this2), "type", 'network');
- if (!urls && speedyNodeApiKey) {
- urls = (0, _MoralisRpcs.getMoralisRpcs)(speedyNodeApiKey);
- }
- if (!urls && !speedyNodeApiKey) {
- throw new Error('Cannot connect to rpc: No urls or speedyNodeApiKey provided for NetworkWeb3Connector.');
- }
- if ("browser" !== 'node' && speedyNodeApiKey) {
- // eslint-disable-next-line no-console
- console.warn('Using speedyNodeApiKey on the browser enviroment is not recommended, as it is publicly visible.');
- }
- _this2.chainId = (0, _verifyChainId.default)((_ref3 = chainId !== null && chainId !== void 0 ? chainId : defaultChainId) !== null && _ref3 !== void 0 ? _ref3 : Number((0, _keys.default)(urls)[0]));
- _this2.providers = (0, _reduce.default)(_context4 = (0, _keys.default)(urls)).call(_context4, function (accumulator, chainId) {
- accumulator[Number(chainId)] = new MiniRpcProvider(Number(chainId), urls[Number(chainId)]);
- return accumulator;
- }, {});
- return _this2;
- }
- (0, _createClass2.default)(NetworkWeb3Connector, [{
- key: "activate",
- value: function () {
- var _activate = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
- var _ref4,
- providedChainId,
- _ref4$privateKey,
- privateKey,
- provider,
- _args2 = arguments;
- return _regenerator.default.wrap(function (_context5) {
- while (1) {
- switch (_context5.prev = _context5.next) {
- case 0:
- _ref4 = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {}, providedChainId = _ref4.chainId, _ref4$privateKey = _ref4.privateKey, privateKey = _ref4$privateKey === void 0 ? null : _ref4$privateKey;
- if (providedChainId) {
- this.chainId = (0, _verifyChainId.default)(providedChainId);
- }
- provider = this.providers[(0, _convert.fromHexToDecimal)(this.chainId)];
- if (provider) {
- _context5.next = 5;
- break;
- }
- throw new Error("No rpc url provided for chainId ".concat(this.chainId));
- case 5:
- if (!(privateKey != null)) {
- _context5.next = 9;
- break;
- }
- _context5.next = 8;
- return new _ethers.ethers.Wallet(privateKey).getAddress();
- case 8:
- this.account = _context5.sent;
- case 9:
- return _context5.abrupt("return", {
- provider: provider,
- chainId: this.chainId,
- account: this.account
- });
- case 10:
- case "end":
- return _context5.stop();
- }
- }
- }, _callee2, this);
- }));
- return function () {
- return _activate.apply(this, arguments);
- };
- }()
- }]);
- return NetworkWeb3Connector;
- }(_AbstractWeb3Connector.default);
- var _default = NetworkWeb3Connector;
- exports.default = _default;
- },{"../CoreManager":5,"../utils/convert":76,"../utils/verifyChainId":77,"./AbstractWeb3Connector":54,"./MoralisRpcs":57,"@babel/runtime-corejs3/core-js-stable/instance/concat":81,"@babel/runtime-corejs3/core-js-stable/instance/reduce":92,"@babel/runtime-corejs3/core-js-stable/json/stringify":99,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/core-js-stable/object/keys":112,"@babel/runtime-corejs3/core-js-stable/reflect/construct":116,"@babel/runtime-corejs3/core-js-stable/url":121,"@babel/runtime-corejs3/helpers/assertThisInitialized":143,"@babel/runtime-corejs3/helpers/asyncToGenerator":144,"@babel/runtime-corejs3/helpers/classCallCheck":145,"@babel/runtime-corejs3/helpers/createClass":147,"@babel/runtime-corejs3/helpers/defineProperty":148,"@babel/runtime-corejs3/helpers/getPrototypeOf":150,"@babel/runtime-corejs3/helpers/inherits":151,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/helpers/possibleConstructorReturn":159,"@babel/runtime-corejs3/regenerator":167,"ethers":773}],59:[function(_dereq_,module,exports){
- "use strict";
- var _Reflect$construct = _dereq_("@babel/runtime-corejs3/core-js-stable/reflect/construct");
- var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
- var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
- _Object$defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = exports.WalletConnectEvent = void 0;
- var _regenerator = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/regenerator"));
- var _asyncToGenerator2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/asyncToGenerator"));
- var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
- var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
- var _assertThisInitialized2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/assertThisInitialized"));
- var _inherits2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/inherits"));
- var _possibleConstructorReturn2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/possibleConstructorReturn"));
- var _getPrototypeOf2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/getPrototypeOf"));
- var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
- var _freeze = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/freeze"));
- var _concat = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/concat"));
- var _verifyChainId = _interopRequireDefault(_dereq_("../utils/verifyChainId"));
- var _AbstractWeb3Connector = _interopRequireDefault(_dereq_("./AbstractWeb3Connector"));
- var _events = _dereq_("./events");
- var _MoralisRpcs = _dereq_("./MoralisRpcs");
- function _createSuper(Derived) {
- var hasNativeReflectConstruct = _isNativeReflectConstruct();
- return function () {
- var Super = (0, _getPrototypeOf2.default)(Derived),
- result;
- if (hasNativeReflectConstruct) {
- var NewTarget = (0, _getPrototypeOf2.default)(this).constructor;
- result = _Reflect$construct(Super, arguments, NewTarget);
- } else {
- result = Super.apply(this, arguments);
- }
- return (0, _possibleConstructorReturn2.default)(this, result);
- };
- }
- function _isNativeReflectConstruct() {
- if (typeof Reflect === "undefined" || !_Reflect$construct) return false;
- if (_Reflect$construct.sham) return false;
- if (typeof Proxy === "function") return true;
- try {
- Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {}));
- return true;
- } catch (e) {
- return false;
- }
- }
- var WalletConnectEvent = (0, _freeze.default)({
- ACCOUNTS_CHANGED: 'accountsChanged',
- CHAIN_CHANGED: 'chainChanged',
- DISCONNECT: 'disconnect'
- });
- /**
- * Connector to connect an WalletConenct provider to Moralis
- * Note: this assumes using WalletConnect v1
- * // TODO: support WalletConnect v2
- */
- exports.WalletConnectEvent = WalletConnectEvent;
- var WalletConnectWeb3Connector = /*#__PURE__*/function (_AbstractWeb3Connecto) {
- (0, _inherits2.default)(WalletConnectWeb3Connector, _AbstractWeb3Connecto);
- var _super = _createSuper(WalletConnectWeb3Connector);
- function WalletConnectWeb3Connector() {
- var _context;
- var _this;
- (0, _classCallCheck2.default)(this, WalletConnectWeb3Connector);
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
- args[_key] = arguments[_key];
- }
- _this = _super.call.apply(_super, (0, _concat.default)(_context = [this]).call(_context, args));
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "type", 'WalletConnect');
- return _this;
- }
- (0, _createClass2.default)(WalletConnectWeb3Connector, [{
- key: "activate",
- value: function () {
- var _activate = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
- var _ref,
- providedChainId,
- mobileLinks,
- newSession,
- WalletConnectProvider,
- config,
- _require,
- _window,
- _window$WalletConnect,
- accounts,
- account,
- chainId,
- verifiedChainId,
- _args = arguments;
- return _regenerator.default.wrap(function (_context2) {
- while (1) {
- switch (_context2.prev = _context2.next) {
- case 0:
- _ref = _args.length > 0 && _args[0] !== undefined ? _args[0] : {}, providedChainId = _ref.chainId, mobileLinks = _ref.mobileLinks, newSession = _ref.newSession; // Log out of any previous sessions
- if (newSession) {
- this.cleanup();
- }
- if (this.provider) {
- _context2.next = 9;
- break;
- }
- config = {
- rpc: (0, _MoralisRpcs.getMoralisRpcs)('WalletConnect'),
- chainId: providedChainId,
- qrcodeModalOptions: {
- mobileLinks: mobileLinks
- }
- };
- try {
- WalletConnectProvider = (_require = _dereq_('@walletconnect/web3-provider')) === null || _require === void 0 ? void 0 : _require.default;
- } catch (error) {// Do nothing. User might not need walletconnect
- }
- if (!WalletConnectProvider) {
- WalletConnectProvider = (_window = window) === null || _window === void 0 ? void 0 : (_window$WalletConnect = _window.WalletConnectProvider) === null || _window$WalletConnect === void 0 ? void 0 : _window$WalletConnect.default;
- }
- if (WalletConnectProvider) {
- _context2.next = 8;
- break;
- }
- throw new Error('Cannot enable via WalletConnect: dependency "@walletconnect/web3-provider" is missing');
- case 8:
- if (typeof WalletConnectProvider === 'function') {
- this.provider = new WalletConnectProvider(config);
- } else {
- this.provider = new window.WalletConnectProvider(config);
- }
- case 9:
- if (this.provider) {
- _context2.next = 11;
- break;
- }
- throw new Error('Could not connect via WalletConnect, error in connecting to provider');
- case 11:
- _context2.next = 13;
- return this.provider.enable();
- case 13:
- accounts = _context2.sent;
- account = accounts[0].toLowerCase();
- chainId = this.provider.chainId;
- verifiedChainId = (0, _verifyChainId.default)(chainId);
- this.account = account;
- this.chainId = verifiedChainId;
- this.subscribeToEvents(this.provider);
- return _context2.abrupt("return", {
- provider: this.provider,
- account: account,
- chainId: verifiedChainId
- });
- case 21:
- case "end":
- return _context2.stop();
- }
- }
- }, _callee, this);
- }));
- return function () {
- return _activate.apply(this, arguments);
- };
- }() // Cleanup old sessions
- }, {
- key: "cleanup",
- value: function () {
- try {
- if (window) {
- window.localStorage.removeItem('walletconnect');
- }
- } catch (error) {// Do nothing
- }
- }
- }, {
- key: "deactivate",
- value: function () {
- var _deactivate = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
- return _regenerator.default.wrap(function (_context3) {
- while (1) {
- switch (_context3.prev = _context3.next) {
- case 0:
- this.unsubscribeToEvents(this.provider);
- if (!this.provider) {
- _context3.next = 9;
- break;
- }
- _context3.prev = 2;
- _context3.next = 5;
- return this.provider.close();
- case 5:
- _context3.next = 9;
- break;
- case 7:
- _context3.prev = 7;
- _context3.t0 = _context3["catch"](2);
- case 9:
- this.account = null;
- this.chainId = null;
- this.provider = null;
- case 12:
- case "end":
- return _context3.stop();
- }
- }
- }, _callee2, this, [[2, 7]]);
- }));
- return function () {
- return _deactivate.apply(this, arguments);
- };
- }()
- }]);
- return WalletConnectWeb3Connector;
- }(_AbstractWeb3Connector.default);
- var _default = WalletConnectWeb3Connector;
- exports.default = _default;
- },{"../utils/verifyChainId":77,"./AbstractWeb3Connector":54,"./MoralisRpcs":57,"./events":61,"@babel/runtime-corejs3/core-js-stable/instance/concat":81,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/core-js-stable/object/freeze":107,"@babel/runtime-corejs3/core-js-stable/reflect/construct":116,"@babel/runtime-corejs3/helpers/assertThisInitialized":143,"@babel/runtime-corejs3/helpers/asyncToGenerator":144,"@babel/runtime-corejs3/helpers/classCallCheck":145,"@babel/runtime-corejs3/helpers/createClass":147,"@babel/runtime-corejs3/helpers/defineProperty":148,"@babel/runtime-corejs3/helpers/getPrototypeOf":150,"@babel/runtime-corejs3/helpers/inherits":151,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/helpers/possibleConstructorReturn":159,"@babel/runtime-corejs3/regenerator":167,"@walletconnect/web3-provider":323}],60:[function(_dereq_,module,exports){
- "use strict";
- var _Reflect$construct = _dereq_("@babel/runtime-corejs3/core-js-stable/reflect/construct");
- var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
- var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
- _Object$defineProperty(exports, "__esModule", {
- value: true
- });
- exports.Web3Auth = void 0;
- var _regenerator = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/regenerator"));
- var _concat = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/concat"));
- var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
- var _asyncToGenerator2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/asyncToGenerator"));
- var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
- var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
- var _assertThisInitialized2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/assertThisInitialized"));
- var _inherits2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/inherits"));
- var _possibleConstructorReturn2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/possibleConstructorReturn"));
- var _getPrototypeOf2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/getPrototypeOf"));
- var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
- var _ethers = _dereq_("ethers");
- var _verifyChainId = _interopRequireDefault(_dereq_("../utils/verifyChainId"));
- var _AbstractWeb3Connector = _interopRequireDefault(_dereq_("./AbstractWeb3Connector"));
- function _createSuper(Derived) {
- var hasNativeReflectConstruct = _isNativeReflectConstruct();
- return function () {
- var Super = (0, _getPrototypeOf2.default)(Derived),
- result;
- if (hasNativeReflectConstruct) {
- var NewTarget = (0, _getPrototypeOf2.default)(this).constructor;
- result = _Reflect$construct(Super, arguments, NewTarget);
- } else {
- result = Super.apply(this, arguments);
- }
- return (0, _possibleConstructorReturn2.default)(this, result);
- };
- }
- function _isNativeReflectConstruct() {
- if (typeof Reflect === "undefined" || !_Reflect$construct) return false;
- if (_Reflect$construct.sham) return false;
- if (typeof Proxy === "function") return true;
- try {
- Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {}));
- return true;
- } catch (e) {
- return false;
- }
- }
- var Web3Auth = /*#__PURE__*/function (_AbstractWeb3Connecto) {
- (0, _inherits2.default)(Web3Auth, _AbstractWeb3Connecto);
- var _super = _createSuper(Web3Auth);
- function Web3Auth() {
- var _context;
- var _this;
- (0, _classCallCheck2.default)(this, Web3Auth);
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
- args[_key] = arguments[_key];
- }
- _this = _super.call.apply(_super, (0, _concat.default)(_context = [this]).call(_context, args));
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "type", 'web3Auth');
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "activate", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
- var _ref2,
- _ref2$chainId,
- chainId,
- clientId,
- theme,
- appLogo,
- loginMethodsOrder,
- _Web3Auth,
- _require,
- _window,
- _window$Web3auth,
- ethChainConfig,
- web3auth,
- provider,
- _web3auth,
- _web3auth2,
- _web3auth3,
- isSocialLogin,
- ether,
- signer,
- values,
- providerChainId,
- _args = arguments;
- return _regenerator.default.wrap(function (_context2) {
- while (1) {
- switch (_context2.prev = _context2.next) {
- case 0:
- _ref2 = _args.length > 0 && _args[0] !== undefined ? _args[0] : {}, _ref2$chainId = _ref2.chainId, chainId = _ref2$chainId === void 0 ? '0x1' : _ref2$chainId, clientId = _ref2.clientId, theme = _ref2.theme, appLogo = _ref2.appLogo, loginMethodsOrder = _ref2.loginMethodsOrder;
- if (clientId) {
- _context2.next = 3;
- break;
- }
- throw new Error('"clientId" not provided, please provide clientId');
- case 3:
- try {
- _Web3Auth = (_require = _dereq_('@web3auth/web3auth')) === null || _require === void 0 ? void 0 : _require.Web3Auth;
- } catch (_unused) {// Do Nothing Individual Checks are done below
- } // Check if user is using CDN to import
- if (!_Web3Auth) {
- _Web3Auth = (_window = window) === null || _window === void 0 ? void 0 : (_window$Web3auth = _window.Web3auth) === null || _window$Web3auth === void 0 ? void 0 : _window$Web3auth.Web3Auth;
- } // Error checking for if library is not installed
- if (_Web3Auth) {
- _context2.next = 7;
- break;
- }
- throw new Error('"@web3auth/web3auth" not installed, please install');
- case 7:
- // Build config
- ethChainConfig = {
- chainNamespace: 'eip155',
- chainId: (0, _verifyChainId.default)(chainId)
- }; // Build Web3Auth
- try {
- web3auth = new _Web3Auth({
- chainConfig: ethChainConfig,
- uiConfig: {
- theme: theme !== null && theme !== void 0 ? theme : 'dark',
- appLogo: appLogo !== null && appLogo !== void 0 ? appLogo : 'https://moralis.io/wp-content/uploads/2021/05/moralisWhiteLogo.svg',
- loginMethodsOrder: loginMethodsOrder
- },
- clientId: clientId
- });
- } catch (_unused2) {// Do Nothing error checked below
- }
- if (web3auth) {
- _context2.next = 11;
- break;
- }
- throw new Error('Could not connect via Web3Auth, error during initializing Web3Auth');
- case 11:
- _context2.next = 13;
- return web3auth.initModal();
- case 13:
- provider = null;
- _context2.prev = 14;
- _context2.next = 17;
- return web3auth.connect();
- case 17:
- provider = _context2.sent;
- _context2.next = 22;
- break;
- case 20:
- _context2.prev = 20;
- _context2.t0 = _context2["catch"](14);
- case 22:
- if (provider) {
- _context2.next = 24;
- break;
- }
- throw new Error('Could not connect via Web3Auth, error in connecting to provider');
- case 24:
- _context2.prev = 24;
- isSocialLogin = (_web3auth = web3auth) !== null && _web3auth !== void 0 && _web3auth.provider ? false : true;
- ether = new _ethers.ethers.providers.Web3Provider((_web3auth2 = web3auth) !== null && _web3auth2 !== void 0 && _web3auth2.provider ? web3auth.provider : web3auth);
- signer = ether.getSigner();
- _context2.next = 30;
- return _promise.default.all([ether.getNetwork(), signer.getAddress()]);
- case 30:
- values = _context2.sent;
- providerChainId = values[0].chainId;
- _this.account = values[1].toLocaleLowerCase();
- _this.chainId = "0x".concat(providerChainId.toString(16));
- _this.provider = isSocialLogin ? ether : (_web3auth3 = web3auth) === null || _web3auth3 === void 0 ? void 0 : _web3auth3.provider;
- _this.web3Instance = web3auth;
- _this.subscribeToEvents(_this.provider);
- return _context2.abrupt("return", {
- chainId: _this.chainId,
- account: _this.account,
- provider: _this.provider
- });
- case 40:
- _context2.prev = 40;
- _context2.t1 = _context2["catch"](24);
- throw new Error('Could not connect via Web3Auth, error while authenticating');
- case 43:
- case "end":
- return _context2.stop();
- }
- }
- }, _callee, null, [[14, 20], [24, 40]]);
- })));
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "deactivate", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
- return _regenerator.default.wrap(function (_context3) {
- while (1) {
- switch (_context3.prev = _context3.next) {
- case 0:
- _this.unsubscribeToEvents(_this.provider);
- if (!_this.web3Instance) {
- _context3.next = 4;
- break;
- }
- _context3.next = 4;
- return _this.web3Instance.logout();
- case 4:
- _this.account = null;
- _this.chainId = null;
- _this.provider = null;
- case 7:
- case "end":
- return _context3.stop();
- }
- }
- }, _callee2);
- })));
- return _this;
- }
- return (0, _createClass2.default)(Web3Auth);
- }(_AbstractWeb3Connector.default);
- exports.Web3Auth = Web3Auth;
- },{"../utils/verifyChainId":77,"./AbstractWeb3Connector":54,"@babel/runtime-corejs3/core-js-stable/instance/concat":81,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/core-js-stable/promise":115,"@babel/runtime-corejs3/core-js-stable/reflect/construct":116,"@babel/runtime-corejs3/helpers/assertThisInitialized":143,"@babel/runtime-corejs3/helpers/asyncToGenerator":144,"@babel/runtime-corejs3/helpers/classCallCheck":145,"@babel/runtime-corejs3/helpers/createClass":147,"@babel/runtime-corejs3/helpers/defineProperty":148,"@babel/runtime-corejs3/helpers/getPrototypeOf":150,"@babel/runtime-corejs3/helpers/inherits":151,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/helpers/possibleConstructorReturn":159,"@babel/runtime-corejs3/regenerator":167,"@web3auth/web3auth":323,"ethers":773}],61:[function(_dereq_,module,exports){
- "use strict";
- var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
- var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
- _Object$defineProperty(exports, "__esModule", {
- value: true
- });
- exports.EthereumEvents = exports.ConnectorEvents = void 0;
- var _freeze = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/freeze")); // Events being emitted by an eip-1193 provider
- // See https://eips.ethereum.org/EIPS/eip-1193#events
- var EthereumEvents = (0, _freeze.default)({
- CONNECT: 'connect',
- DISCONNECT: 'disconnect',
- CHAIN_CHANGED: 'chainChanged',
- ACCOUNTS_CHANGED: 'accountsChanged'
- }); // Events emitted by the connectors,
- // The InternalWeb3Provider of Moralis will listen to these
- exports.EthereumEvents = EthereumEvents;
- var ConnectorEvents = (0, _freeze.default)({
- CONNECT: 'connect',
- DISCONNECT: 'disconnect',
- CHAIN_CHANGED: 'chainChanged',
- ACCOUNT_CHANGED: 'accountChanged'
- });
- exports.ConnectorEvents = ConnectorEvents;
- },{"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/core-js-stable/object/freeze":107,"@babel/runtime-corejs3/helpers/interopRequireDefault":152}],62:[function(_dereq_,module,exports){
- "use strict";
- var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
- var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
- _Object$defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = arrayContainsObject;
- var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
- var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
- /**
- * Copyright (c) 2015-present, Parse, LLC.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- *
- * @flow
- */
- function arrayContainsObject(array
- /*: Array<any>*/
- , object
- /*: ParseObject*/
- )
- /*: boolean*/
- {
- if ((0, _indexOf.default)(array).call(array, object) > -1) {
- return true;
- }
- for (var i = 0; i < array.length; i++) {
- if (array[i] instanceof _ParseObject.default && array[i].className === object.className && array[i]._getId() === object._getId()) {
- return true;
- }
- }
- return false;
- }
- },{"./ParseObject":36,"@babel/runtime-corejs3/core-js-stable/instance/index-of":88,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/helpers/interopRequireDefault":152}],63:[function(_dereq_,module,exports){
- "use strict";
- var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
- var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
- _Object$defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = canBeSerialized;
- var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
- var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
- var _ParseFile = _interopRequireDefault(_dereq_("./ParseFile"));
- var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
- var _ParseRelation = _interopRequireDefault(_dereq_("./ParseRelation"));
- /**
- * Copyright (c) 2015-present, Parse, LLC.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- *
- * @flow
- */
- function canBeSerialized(obj
- /*: ParseObject*/
- )
- /*: boolean*/
- {
- if (!(obj instanceof _ParseObject.default)) {
- return true;
- }
- var attributes = obj.attributes;
- for (var attr in attributes) {
- var val = attributes[attr];
- if (!canBeSerializedHelper(val)) {
- return false;
- }
- }
- return true;
- }
- function canBeSerializedHelper(value
- /*: any*/
- )
- /*: boolean*/
- {
- if ((0, _typeof2.default)(value) !== 'object') {
- return true;
- }
- if (value instanceof _ParseRelation.default) {
- return true;
- }
- if (value instanceof _ParseObject.default) {
- return !!value.id;
- }
- if (value instanceof _ParseFile.default) {
- if (value.url()) {
- return true;
- }
- return false;
- }
- if ((0, _isArray.default)(value)) {
- for (var i = 0; i < value.length; i++) {
- if (!canBeSerializedHelper(value[i])) {
- return false;
- }
- }
- return true;
- }
- for (var k in value) {
- if (!canBeSerializedHelper(value[k])) {
- return false;
- }
- }
- return true;
- }
- },{"./ParseFile":30,"./ParseObject":36,"./ParseRelation":40,"@babel/runtime-corejs3/core-js-stable/array/is-array":79,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/helpers/typeof":164}],64:[function(_dereq_,module,exports){
- "use strict";
- var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
- var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
- _Object$defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = createSigningData;
- var _regenerator = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/regenerator"));
- var _concat = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/concat"));
- var _asyncToGenerator2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/asyncToGenerator"));
- var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
- var _Cloud = _dereq_("./Cloud");
- /**
- * Creates the data for the authentication message by extending the message
- * with a unique string with applicationId and current time
- */
- function createSigningData() {
- return _createSigningData.apply(this, arguments);
- }
- function _createSigningData() {
- _createSigningData = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(message) {
- var data, _context, _context2, _yield$run, dateTime, applicationId;
- return _regenerator.default.wrap(function (_context3) {
- while (1) {
- switch (_context3.prev = _context3.next) {
- case 0:
- _context3.prev = 0;
- _context3.next = 3;
- return (0, _Cloud.run)('getServerTime');
- case 3:
- _yield$run = _context3.sent;
- dateTime = _yield$run.dateTime;
- applicationId = _CoreManager.default.get('APPLICATION_ID');
- data = (0, _concat.default)(_context = (0, _concat.default)(_context2 = "".concat(message, "\n\nId: ")).call(_context2, applicationId, ":")).call(_context, dateTime);
- _context3.next = 12;
- break;
- case 9:
- _context3.prev = 9;
- _context3.t0 = _context3["catch"](0);
- data = "".concat(message);
- case 12:
- return _context3.abrupt("return", data);
- case 13:
- case "end":
- return _context3.stop();
- }
- }
- }, _callee, null, [[0, 9]]);
- }));
- return _createSigningData.apply(this, arguments);
- }
- },{"./Cloud":4,"./CoreManager":5,"@babel/runtime-corejs3/core-js-stable/instance/concat":81,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/helpers/asyncToGenerator":144,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/regenerator":167}],65:[function(_dereq_,module,exports){
- "use strict";
- var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
- var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
- _Object$defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = decode;
- var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
- var _forEach = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
- var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
- var _ParseACL = _interopRequireDefault(_dereq_("./ParseACL"));
- var _ParseFile = _interopRequireDefault(_dereq_("./ParseFile"));
- var _ParseGeoPoint = _interopRequireDefault(_dereq_("./ParseGeoPoint"));
- var _ParsePolygon = _interopRequireDefault(_dereq_("./ParsePolygon"));
- var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
- var _ParseOp = _dereq_("./ParseOp");
- var _ParseRelation = _interopRequireDefault(_dereq_("./ParseRelation"));
- /**
- * Copyright (c) 2015-present, Parse, LLC.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- *
- * @flow
- */
- // eslint-disable-line no-unused-vars
- function decode(value
- /*: any*/
- )
- /*: any*/
- {
- if (value === null || (0, _typeof2.default)(value) !== 'object') {
- return value;
- }
- if ((0, _isArray.default)(value)) {
- var dup = [];
- (0, _forEach.default)(value).call(value, function (v, i) {
- dup[i] = decode(v);
- });
- return dup;
- }
- if (typeof value.__op === 'string') {
- return (0, _ParseOp.opFromJSON)(value);
- }
- if (value.__type === 'Pointer' && value.className) {
- return _ParseObject.default.fromJSON(value);
- }
- if (value.__type === 'Object' && value.className) {
- return _ParseObject.default.fromJSON(value);
- }
- if (value.__type === 'Relation') {
- // The parent and key fields will be populated by the parent
- var relation = new _ParseRelation.default(null, null);
- relation.targetClassName = value.className;
- return relation;
- }
- if (value.__type === 'Date') {
- return new Date(value.iso);
- }
- if (value.__type === 'File') {
- return _ParseFile.default.fromJSON(value);
- }
- if (value.__type === 'GeoPoint') {
- return new _ParseGeoPoint.default({
- latitude: value.latitude,
- longitude: value.longitude
- });
- }
- if (value.__type === 'Polygon') {
- return new _ParsePolygon.default(value.coordinates);
- }
- var copy = {};
- for (var k in value) {
- copy[k] = decode(value[k]);
- }
- return copy;
- }
- },{"./ParseACL":26,"./ParseFile":30,"./ParseGeoPoint":33,"./ParseObject":36,"./ParseOp":37,"./ParsePolygon":38,"./ParseRelation":40,"@babel/runtime-corejs3/core-js-stable/array/is-array":79,"@babel/runtime-corejs3/core-js-stable/instance/for-each":86,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/helpers/typeof":164}],66:[function(_dereq_,module,exports){
- "use strict";
- var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
- var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
- _Object$defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = _default;
- var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
- var _concat = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/concat"));
- var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
- var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/keys"));
- var _startsWith = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/starts-with"));
- var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
- var _map = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/map"));
- var _ParseACL = _interopRequireDefault(_dereq_("./ParseACL"));
- var _ParseFile = _interopRequireDefault(_dereq_("./ParseFile"));
- var _ParseGeoPoint = _interopRequireDefault(_dereq_("./ParseGeoPoint"));
- var _ParsePolygon = _interopRequireDefault(_dereq_("./ParsePolygon"));
- var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
- var _ParseOp = _dereq_("./ParseOp");
- var _ParseRelation = _interopRequireDefault(_dereq_("./ParseRelation"));
- /**
- * Copyright (c) 2015-present, Parse, LLC.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- *
- * @flow
- */
- function encode(value
- /*: mixed*/
- , disallowObjects
- /*: boolean*/
- , forcePointers
- /*: boolean*/
- , seen
- /*: Array<mixed>*/
- , offline
- /*: boolean*/
- )
- /*: any*/
- {
- if (value instanceof _ParseObject.default) {
- var _context;
- if (disallowObjects) {
- throw new Error('Parse Objects not allowed here');
- }
- var seenEntry = value.id ? (0, _concat.default)(_context = "".concat(value.className, ":")).call(_context, value.id) : value;
- if (forcePointers || !seen || (0, _indexOf.default)(seen).call(seen, seenEntry) > -1 || value.dirty() || (0, _keys.default)(value._getServerData()).length < 1) {
- var _context2;
- if (offline && (0, _startsWith.default)(_context2 = value._getId()).call(_context2, 'local')) {
- return value.toOfflinePointer();
- }
- return value.toPointer();
- }
- seen = (0, _concat.default)(seen).call(seen, seenEntry);
- return value._toFullJSON(seen, offline);
- }
- if (value instanceof _ParseOp.Op || value instanceof _ParseACL.default || value instanceof _ParseGeoPoint.default || value instanceof _ParsePolygon.default || value instanceof _ParseRelation.default) {
- return value.toJSON();
- }
- if (value instanceof _ParseFile.default) {
- if (!value.url()) {
- throw new Error('Tried to encode an unsaved file.');
- }
- return value.toJSON();
- }
- if (Object.prototype.toString.call(value) === '[object Date]') {
- if (isNaN(value)) {
- throw new Error('Tried to encode an invalid date.');
- }
- return {
- __type: 'Date',
- iso: value
- /*: any*/
- .toJSON()
- };
- }
- if (Object.prototype.toString.call(value) === '[object RegExp]' && typeof value.source === 'string') {
- return value.source;
- }
- if ((0, _isArray.default)(value)) {
- return (0, _map.default)(value).call(value, function (v) {
- return encode(v, disallowObjects, forcePointers, seen, offline);
- });
- }
- if (value && (0, _typeof2.default)(value) === 'object') {
- var output = {};
- for (var k in value) {
- output[k] = encode(value[k], disallowObjects, forcePointers, seen, offline);
- }
- return output;
- }
- return value;
- }
- function _default(value
- /*: mixed*/
- , disallowObjects
- /*:: ?: boolean*/
- , forcePointers
- /*:: ?: boolean*/
- , seen
- /*:: ?: Array<mixed>*/
- , offline
- /*:: ?: boolean*/
- )
- /*: any*/
- {
- return encode(value, !!disallowObjects, !!forcePointers, seen || [], offline);
- }
- },{"./ParseACL":26,"./ParseFile":30,"./ParseGeoPoint":33,"./ParseObject":36,"./ParseOp":37,"./ParsePolygon":38,"./ParseRelation":40,"@babel/runtime-corejs3/core-js-stable/array/is-array":79,"@babel/runtime-corejs3/core-js-stable/instance/concat":81,"@babel/runtime-corejs3/core-js-stable/instance/index-of":88,"@babel/runtime-corejs3/core-js-stable/instance/map":90,"@babel/runtime-corejs3/core-js-stable/instance/starts-with":96,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/core-js-stable/object/keys":112,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/helpers/typeof":164}],67:[function(_dereq_,module,exports){
- "use strict";
- var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
- var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
- _Object$defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = equals;
- var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
- var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/keys"));
- var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
- var _ParseACL = _interopRequireDefault(_dereq_("./ParseACL"));
- var _ParseFile = _interopRequireDefault(_dereq_("./ParseFile"));
- var _ParseGeoPoint = _interopRequireDefault(_dereq_("./ParseGeoPoint"));
- var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
- /**
- * Copyright (c) 2015-present, Parse, LLC.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
- function equals(a, b) {
- var toString = Object.prototype.toString;
- if (toString.call(a) === '[object Date]' || toString.call(b) === '[object Date]') {
- var dateA = new Date(a);
- var dateB = new Date(b);
- return +dateA === +dateB;
- }
- if ((0, _typeof2.default)(a) !== (0, _typeof2.default)(b)) {
- return false;
- }
- if (!a || (0, _typeof2.default)(a) !== 'object') {
- // a is a primitive
- return a === b;
- }
- if ((0, _isArray.default)(a) || (0, _isArray.default)(b)) {
- if (!(0, _isArray.default)(a) || !(0, _isArray.default)(b)) {
- return false;
- }
- if (a.length !== b.length) {
- return false;
- }
- for (var i = a.length; i--;) {
- if (!equals(a[i], b[i])) {
- return false;
- }
- }
- return true;
- }
- if (a instanceof _ParseACL.default || a instanceof _ParseFile.default || a instanceof _ParseGeoPoint.default || a instanceof _ParseObject.default) {
- return a.equals(b);
- }
- if (b instanceof _ParseObject.default) {
- if (a.__type === 'Object' || a.__type === 'Pointer') {
- return a.objectId === b.id && a.className === b.className;
- }
- }
- if ((0, _keys.default)(a).length !== (0, _keys.default)(b).length) {
- return false;
- }
- for (var k in a) {
- if (!equals(a[k], b[k])) {
- return false;
- }
- }
- return true;
- }
- },{"./ParseACL":26,"./ParseFile":30,"./ParseGeoPoint":33,"./ParseObject":36,"@babel/runtime-corejs3/core-js-stable/array/is-array":79,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/core-js-stable/object/keys":112,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/helpers/typeof":164}],68:[function(_dereq_,module,exports){
- "use strict";
- var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
- _Object$defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = escape;
- /*
- * Copyright (c) 2015-present, Parse, LLC.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- *
- * @flow
- */
- var encoded = {
- '&': '&',
- '<': '<',
- '>': '>',
- '/': '/',
- "'": ''',
- '"': '"'
- };
- function escape(str
- /*: string*/
- )
- /*: string*/
- {
- return str.replace(/[&<>/'"]/g, function (char) {
- return encoded[char];
- });
- }
- },{"@babel/runtime-corejs3/core-js-stable/object/define-property":105}],69:[function(_dereq_,module,exports){
- "use strict";
- var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
- var _filter = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/filter"));
- var _includes = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/includes"));
- /* eslint-disable no-console */
- /* global window */
- var filteredWarnings = [// Optional dependencies, where we handle the dependency check on run-time
- "Module not found: Can't resolve '@walletconnect/web3-provider'", "Module not found: Can't resolve 'magic-sdk'", "Module not found: Can't resolve '@web3auth/web3auth'"];
- /**
- * Filters console messages that include text from the blacklist
- */
- var filterConsole = function () {
- // Filter console.warn
- var preservedConsoleWarn = console.warn;
- console.warn = function () {
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
- args[_key] = arguments[_key];
- }
- var value = args ? args[0] : null; // For the current use-cases we only care about the first argument being string
- if (!value || typeof value !== 'string') {
- return preservedConsoleWarn.apply(console, args);
- } // Raplace all types of single quotes to one format
- value = value.replace('’', "'").replace('‘', "'").replace('’', "'"); // Filter out blacklisted strings
- if ((0, _filter.default)(filteredWarnings).call(filteredWarnings, function (filter) {
- return (0, _includes.default)(value).call(value, filter);
- }).length >= 1) {
- return;
- } // Otherwise return default function
- return preservedConsoleWarn.apply(console, args);
- };
- };
- module.exports = {
- filterConsole: filterConsole
- };
- },{"@babel/runtime-corejs3/core-js-stable/instance/filter":84,"@babel/runtime-corejs3/core-js-stable/instance/includes":87,"@babel/runtime-corejs3/helpers/interopRequireDefault":152}],70:[function(_dereq_,module,exports){
- "use strict";
- var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
- var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
- _Object$defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = isRevocableSession;
- var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
- /**
- * Copyright (c) 2015-present, Parse, LLC.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- *
- * @flow
- */
- function isRevocableSession(token
- /*: string*/
- )
- /*: boolean*/
- {
- return (0, _indexOf.default)(token).call(token, 'r:') > -1;
- }
- },{"@babel/runtime-corejs3/core-js-stable/instance/index-of":88,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/helpers/interopRequireDefault":152}],71:[function(_dereq_,module,exports){
- "use strict";
- var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
- var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
- _Object$defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = parseDate;
- var _parseInt2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/parse-int"));
- /**
- * Copyright (c) 2015-present, Parse, LLC.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- *
- * @flow
- */
- function parseDate(iso8601
- /*: string*/
- )
- /*: ?Date*/
- {
- var regexp = new RegExp('^([0-9]{1,4})-([0-9]{1,2})-([0-9]{1,2})' + 'T' + '([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})' + '(.([0-9]+))?' + 'Z$');
- var match = regexp.exec(iso8601);
- if (!match) {
- return null;
- }
- var year = (0, _parseInt2.default)(match[1]) || 0;
- var month = ((0, _parseInt2.default)(match[2]) || 1) - 1;
- var day = (0, _parseInt2.default)(match[3]) || 0;
- var hour = (0, _parseInt2.default)(match[4]) || 0;
- var minute = (0, _parseInt2.default)(match[5]) || 0;
- var second = (0, _parseInt2.default)(match[6]) || 0;
- var milli = (0, _parseInt2.default)(match[8]) || 0;
- return new Date(Date.UTC(year, month, day, hour, minute, second, milli));
- }
- },{"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/core-js-stable/parse-int":114,"@babel/runtime-corejs3/helpers/interopRequireDefault":152}],72:[function(_dereq_,module,exports){
- "use strict";
- var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
- var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
- _Object$defineProperty(exports, "__esModule", {
- value: true
- });
- exports.continueWhile = continueWhile;
- exports.resolvingPromise = resolvingPromise;
- exports.when = when;
- var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
- var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array")); // Create Deferred Promise
- function resolvingPromise() {
- var res;
- var rej;
- var promise = new _promise.default(function (resolve, reject) {
- res = resolve;
- rej = reject;
- });
- promise.resolve = res;
- promise.reject = rej;
- return promise;
- }
- function when(promises) {
- var objects;
- var arrayArgument = (0, _isArray.default)(promises);
- if (arrayArgument) {
- objects = promises;
- } else {
- objects = arguments;
- }
- var total = objects.length;
- var hadError = false;
- var results = [];
- var returnValue = arrayArgument ? [results] : results;
- var errors = [];
- results.length = objects.length;
- errors.length = objects.length;
- if (total === 0) {
- return _promise.default.resolve(returnValue);
- }
- var promise = new resolvingPromise();
- var resolveOne = function () {
- total--;
- if (total <= 0) {
- if (hadError) {
- promise.reject(errors);
- } else {
- promise.resolve(returnValue);
- }
- }
- };
- var chain = function (object, index) {
- if (object && typeof object.then === 'function') {
- object.then(function (result) {
- results[index] = result;
- resolveOne();
- }, function (error) {
- errors[index] = error;
- hadError = true;
- resolveOne();
- });
- } else {
- results[index] = object;
- resolveOne();
- }
- };
- for (var i = 0; i < objects.length; i++) {
- chain(objects[i], i);
- }
- return promise;
- }
- function continueWhile(test, emitter) {
- if (test()) {
- return emitter().then(function () {
- return continueWhile(test, emitter);
- });
- }
- return _promise.default.resolve();
- }
- },{"@babel/runtime-corejs3/core-js-stable/array/is-array":79,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/core-js-stable/promise":115,"@babel/runtime-corejs3/helpers/interopRequireDefault":152}],73:[function(_dereq_,module,exports){
- "use strict";
- var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
- var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
- _Object$defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = unique;
- var _forEach = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
- var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
- var _arrayContainsObject = _interopRequireDefault(_dereq_("./arrayContainsObject"));
- var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
- /**
- * Copyright (c) 2015-present, Parse, LLC.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- *
- * @flow
- */
- function unique
- /*:: <T>*/
- (arr
- /*: Array<T>*/
- )
- /*: Array<T>*/
- {
- var uniques = [];
- (0, _forEach.default)(arr).call(arr, function (value) {
- if (value instanceof _ParseObject.default) {
- if (!(0, _arrayContainsObject.default)(uniques, value)) {
- uniques.push(value);
- }
- } else {
- if ((0, _indexOf.default)(uniques).call(uniques, value) < 0) {
- uniques.push(value);
- }
- }
- });
- return uniques;
- }
- },{"./ParseObject":36,"./arrayContainsObject":62,"@babel/runtime-corejs3/core-js-stable/instance/for-each":86,"@babel/runtime-corejs3/core-js-stable/instance/index-of":88,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/helpers/interopRequireDefault":152}],74:[function(_dereq_,module,exports){
- "use strict";
- var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
- var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
- _Object$defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = unsavedChildren;
- var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
- var _concat = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/concat"));
- var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
- var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
- var _forEach = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
- var _ParseFile = _interopRequireDefault(_dereq_("./ParseFile"));
- var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
- var _ParseRelation = _interopRequireDefault(_dereq_("./ParseRelation"));
- /**
- * Copyright (c) 2015-present, Parse, LLC.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- *
- * @flow
- */
- /**
- * Return an array of unsaved children, which are either Parse Objects or Files.
- * If it encounters any dirty Objects without Ids, it will throw an exception.
- *
- * @param {Parse.Object} obj
- * @param {boolean} allowDeepUnsaved
- * @returns {Array}
- */
- function unsavedChildren(obj
- /*: ParseObject*/
- , allowDeepUnsaved
- /*:: ?: boolean*/
- )
- /*: Array<ParseFile | ParseObject>*/
- {
- var _context;
- var encountered = {
- objects: {},
- files: []
- };
- var identifier = (0, _concat.default)(_context = "".concat(obj.className, ":")).call(_context, obj._getId());
- encountered.objects[identifier] = obj.dirty() ? obj : true;
- var attributes = obj.attributes;
- for (var attr in attributes) {
- if ((0, _typeof2.default)(attributes[attr]) === 'object') {
- traverse(attributes[attr], encountered, false, !!allowDeepUnsaved);
- }
- }
- var unsaved = [];
- for (var id in encountered.objects) {
- if (id !== identifier && encountered.objects[id] !== true) {
- unsaved.push(encountered.objects[id]);
- }
- }
- return (0, _concat.default)(unsaved).call(unsaved, encountered.files);
- }
- function traverse(obj
- /*: ParseObject*/
- , encountered
- /*: EncounterMap*/
- , shouldThrow
- /*: boolean*/
- , allowDeepUnsaved
- /*: boolean*/
- ) {
- if (obj instanceof _ParseObject.default) {
- var _context2;
- if (!obj.id && shouldThrow) {
- throw new Error('Cannot create a pointer to an unsaved Object.');
- }
- var _identifier = (0, _concat.default)(_context2 = "".concat(obj.className, ":")).call(_context2, obj._getId());
- if (!encountered.objects[_identifier]) {
- encountered.objects[_identifier] = obj.dirty() ? obj : true;
- var attributes = obj.attributes;
- for (var attr in attributes) {
- if ((0, _typeof2.default)(attributes[attr]) === 'object') {
- traverse(attributes[attr], encountered, !allowDeepUnsaved, allowDeepUnsaved);
- }
- }
- }
- return;
- }
- if (obj instanceof _ParseFile.default) {
- var _context3;
- if (!obj.url() && (0, _indexOf.default)(_context3 = encountered.files).call(_context3, obj) < 0) {
- encountered.files.push(obj);
- }
- return;
- }
- if (obj instanceof _ParseRelation.default) {
- return;
- }
- if ((0, _isArray.default)(obj)) {
- (0, _forEach.default)(obj).call(obj, function (el) {
- if ((0, _typeof2.default)(el) === 'object') {
- traverse(el, encountered, shouldThrow, allowDeepUnsaved);
- }
- });
- }
- for (var k in obj) {
- if ((0, _typeof2.default)(obj[k]) === 'object') {
- traverse(obj[k], encountered, shouldThrow, allowDeepUnsaved);
- }
- }
- }
- },{"./ParseFile":30,"./ParseObject":36,"./ParseRelation":40,"@babel/runtime-corejs3/core-js-stable/array/is-array":79,"@babel/runtime-corejs3/core-js-stable/instance/concat":81,"@babel/runtime-corejs3/core-js-stable/instance/for-each":86,"@babel/runtime-corejs3/core-js-stable/instance/index-of":88,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/helpers/typeof":164}],75:[function(_dereq_,module,exports){
- "use strict";
- var _typeof = _dereq_("@babel/runtime-corejs3/helpers/typeof");
- var _WeakMap = _dereq_("@babel/runtime-corejs3/core-js-stable/weak-map");
- var _reduceInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/reduce");
- var _Object$keys2 = _dereq_("@babel/runtime-corejs3/core-js-stable/object/keys");
- var _Object$create = _dereq_("@babel/runtime-corejs3/core-js-stable/object/create");
- var _Symbol$replace = _dereq_("@babel/runtime-corejs3/core-js-stable/symbol/replace");
- var _sliceInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/slice");
- var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
- var _regenerator = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/regenerator"));
- var _inherits2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/inherits"));
- var _setPrototypeOf2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/setPrototypeOf"));
- var _slicedToArray2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/slicedToArray"));
- var _asyncToGenerator2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/asyncToGenerator"));
- var _freeze = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/freeze"));
- var _map = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/map"));
- var _entries = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/entries"));
- var _forEach = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
- var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/keys"));
- var _isNan = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/number/is-nan"));
- var _stringify = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/json/stringify"));
- var _RESTController = _interopRequireDefault(_dereq_("./RESTController"));
- function _wrapRegExp() {
- _wrapRegExp = function (re, groups) {
- return new BabelRegExp(re, void 0, groups);
- };
- var _super = RegExp.prototype,
- _groups = new _WeakMap();
- function BabelRegExp(re, flags, groups) {
- var _this = new RegExp(re, flags);
- return _groups.set(_this, groups || _groups.get(re)), (0, _setPrototypeOf2.default)(_this, BabelRegExp.prototype);
- }
- function buildGroups(result, re) {
- var _context10;
- var g = _groups.get(re);
- return _reduceInstanceProperty(_context10 = _Object$keys2(g)).call(_context10, function (groups, name) {
- return groups[name] = result[g[name]], groups;
- }, _Object$create(null));
- }
- return (0, _inherits2.default)(BabelRegExp, RegExp), BabelRegExp.prototype.exec = function (str) {
- var result = _super.exec.call(this, str);
- return result && (result.groups = buildGroups(result, this)), result;
- }, BabelRegExp.prototype[_Symbol$replace] = function (str, substitution) {
- if ("string" == typeof substitution) {
- var groups = _groups.get(this);
- return _super[_Symbol$replace].call(this, str, substitution.replace(/\$<([^>]+)>/g, function (_, name) {
- return "$" + groups[name];
- }));
- }
- if ("function" == typeof substitution) {
- var _this = this;
- return _super[_Symbol$replace].call(this, str, function () {
- var args = arguments;
- return "object" != _typeof(args[args.length - 1]) && (args = _sliceInstanceProperty([]).call(args)).push(buildGroups(args, _this)), substitution.apply(this, args);
- });
- }
- return _super[_Symbol$replace].call(this, str, substitution);
- }, _wrapRegExp.apply(this, arguments);
- }
- var DEEP_INDEX_API_HOST = 'deep-index.moralis.io';
- var DEEP_INDEX_SWAGGER_PATH = '/api-docs/v2/swagger.json';
- var TrackingEventName = (0, _freeze.default)({
- START_FUNCTION: 'Moralis SDK start'
- });
- var fetchSwaggerJson = /*#__PURE__*/function () {
- var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
- var _yield$RESTController, response;
- return _regenerator.default.wrap(function (_context) {
- while (1) {
- switch (_context.prev = _context.next) {
- case 0:
- _context.next = 2;
- return _RESTController.default.ajax('GET', "https://".concat(DEEP_INDEX_API_HOST).concat(DEEP_INDEX_SWAGGER_PATH));
- case 2:
- _yield$RESTController = _context.sent;
- response = _yield$RESTController.response;
- return _context.abrupt("return", response);
- case 5:
- case "end":
- return _context.stop();
- }
- }
- }, _callee);
- }));
- return function () {
- return _ref.apply(this, arguments);
- };
- }();
- var getPathByTag = function (swaggerJSON) {
- var _context2;
- var pathByTag = {};
- var pathDetails = {};
- (0, _map.default)(_context2 = (0, _entries.default)(swaggerJSON.paths)).call(_context2, function (_ref2) {
- var _context3;
- var _ref3 = (0, _slicedToArray2.default)(_ref2, 2),
- pathName = _ref3[0],
- requestData = _ref3[1];
- return (0, _forEach.default)(_context3 = (0, _entries.default)(requestData)).call(_context3, function (_ref4) {
- var _ref5 = (0, _slicedToArray2.default)(_ref4, 2),
- method = _ref5[0],
- data = _ref5[1];
- var tags = data.tags;
- if (tags.length > 0) {
- if (!pathByTag[tags[0]]) {
- pathByTag[tags[0]] = [];
- }
- pathByTag[tags[0]].push(data.operationId);
- pathDetails[data.operationId] = {
- method: method,
- pathName: pathName,
- data: data
- };
- }
- });
- });
- return {
- pathByTag: pathByTag,
- pathDetails: pathDetails
- };
- };
- var fetchEndpoints = /*#__PURE__*/function () {
- var _ref6 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
- var _context4;
- var swaggerJSON, _yield$getPathByTag, pathDetails, data;
- return _regenerator.default.wrap(function (_context5) {
- while (1) {
- switch (_context5.prev = _context5.next) {
- case 0:
- _context5.next = 2;
- return fetchSwaggerJson();
- case 2:
- swaggerJSON = _context5.sent;
- _context5.next = 5;
- return getPathByTag(swaggerJSON);
- case 5:
- _yield$getPathByTag = _context5.sent;
- pathDetails = _yield$getPathByTag.pathDetails;
- data = [];
- (0, _forEach.default)(_context4 = (0, _keys.default)(pathDetails)).call(_context4, function (x) {
- var item = pathDetails[x];
- var endpoint = {
- method: item.method.toUpperCase(),
- group: item.data.tags[0],
- name: x,
- url: item.pathName.split('{').join(':').split('}').join('')
- };
- data.push(endpoint);
- });
- return _context5.abrupt("return", data);
- case 10:
- case "end":
- return _context5.stop();
- }
- }
- }, _callee2);
- }));
- return function () {
- return _ref6.apply(this, arguments);
- };
- }();
- /**
- * Compares if the semantic version of version1 is larger than version2
- */
- var isSemanticVersionLarger = function (version1, version2) {
- var _context6, _context7;
- var _version1$split = version1.split('-'),
- _version1$split2 = (0, _slicedToArray2.default)(_version1$split, 2),
- version1Main = _version1$split2[0],
- version1Pre = _version1$split2[1];
- var version1Arr = (0, _map.default)(_context6 = version1Main.split('.')).call(_context6, function (s) {
- return Number(s);
- });
- var _version2$split = version2.split('-'),
- _version2$split2 = (0, _slicedToArray2.default)(_version2$split, 2),
- version2Main = _version2$split2[0],
- version2Pre = _version2$split2[1];
- var version2Arr = (0, _map.default)(_context7 = version2Main.split('.')).call(_context7, function (s) {
- return Number(s);
- });
- for (var index = 0; index < 3; index++) {
- var compare1 = version1Arr[index];
- var compare2 = version2Arr[index];
- if (compare1 > compare2) return true;
- if (compare1 < compare2) return false;
- if (!(0, _isNan.default)(compare1) && (0, _isNan.default)(compare2)) return true;
- if ((0, _isNan.default)(compare1) && !(0, _isNan.default)(compare2)) return false;
- } // Compare pre-releasees if main versions are the same
- if (version1Pre && version2Pre) {
- var _version1Pre$split$, _version2Pre$split$;
- var version1PreNumber = (_version1Pre$split$ = version1Pre.split('.')[1]) !== null && _version1Pre$split$ !== void 0 ? _version1Pre$split$ : 0;
- var version2PreNumber = (_version2Pre$split$ = version2Pre.split('.')[1]) !== null && _version2Pre$split$ !== void 0 ? _version2Pre$split$ : 0;
- return version1PreNumber > version2PreNumber;
- } // If version2 is a pre-release and version1 is not, then version 1 is newer
- if (version2Pre) {
- return true;
- }
- return false;
- };
- var checkForSdkUpdates = /*#__PURE__*/function () {
- var _ref7 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
- var _yield$RESTController2, response, latestVersion, installedVersion;
- return _regenerator.default.wrap(function (_context8) {
- while (1) {
- switch (_context8.prev = _context8.next) {
- case 0:
- _context8.prev = 0;
- _context8.next = 3;
- return _RESTController.default.ajax('GET', 'https://www.unpkg.com/moralis/package.json');
- case 3:
- _yield$RESTController2 = _context8.sent;
- response = _yield$RESTController2.response;
- latestVersion = response.version;
- installedVersion = "1.5.9";
- if (isSemanticVersionLarger(latestVersion, installedVersion)) // eslint-disable-next-line no-console
- console.warn("You are not using the latest version of the SDK. Please update it as soon as possible to enjoy the newest features. Most recent version: ".concat(latestVersion));
- _context8.next = 12;
- break;
- case 10:
- _context8.prev = 10;
- _context8.t0 = _context8["catch"](0);
- case 12:
- case "end":
- return _context8.stop();
- }
- }
- }, _callee3, null, [[0, 10]]);
- }));
- return function () {
- return _ref7.apply(this, arguments);
- };
- }();
- var trackEvent = /*#__PURE__*/function () {
- var _ref8 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(name, subdomain, options) {
- var _yield$RESTController3, response;
- return _regenerator.default.wrap(function (_context9) {
- while (1) {
- switch (_context9.prev = _context9.next) {
- case 0:
- _context9.prev = 0;
- _context9.next = 3;
- return _RESTController.default.ajax('POST', 'https://internal-api.moralis.io/api/functions/trackEvent', (0, _stringify.default)({
- subdomain: subdomain,
- event: name,
- options: options
- }), {
- Accept: 'application/json',
- 'Content-Type': 'application/json'
- });
- case 3:
- _yield$RESTController3 = _context9.sent;
- response = _yield$RESTController3.response;
- return _context9.abrupt("return", response.result);
- case 8:
- _context9.prev = 8;
- _context9.t0 = _context9["catch"](0);
- case 10:
- case "end":
- return _context9.stop();
- }
- }
- }, _callee4, null, [[0, 8]]);
- }));
- return function () {
- return _ref8.apply(this, arguments);
- };
- }();
- /**
- * Regex to validate serverUrl, for example: https://xxxxxxxxxxxx.yyyyyyyyyy.zzzzzz:1234/server
- * It's very generous and doesn't assume the value of domain, subdomain and port, it only checks if we can extract
- * a subddomain
- */
- var validServerUrlRegex = /*#__PURE__*/_wrapRegExp(/^https?:\/\/([0-9A-Z_a-z]+\.[0-9A-Z_a-z]+\.[0-9A-Z_a-z]+)(:[0-9]{4})?\/server\/?$/, {
- subdomain: 1
- });
- var validateServerUrl = function (serverUrl) {
- return validServerUrlRegex.test(serverUrl);
- };
- var getSubdomain = function (serverUrl) {
- var _match$groups$subdoma, _match$groups;
- var isValidServerUrl = validateServerUrl(serverUrl);
- if (!isValidServerUrl) {
- return null;
- }
- var match = validServerUrlRegex.exec(serverUrl);
- return (_match$groups$subdoma = match === null || match === void 0 ? void 0 : (_match$groups = match.groups) === null || _match$groups === void 0 ? void 0 : _match$groups.subdomain) !== null && _match$groups$subdoma !== void 0 ? _match$groups$subdoma : null;
- };
- module.exports = {
- fetchSwaggerJson: fetchSwaggerJson,
- getPathByTag: getPathByTag,
- fetchEndpoints: fetchEndpoints,
- checkForSdkUpdates: checkForSdkUpdates,
- trackEvent: trackEvent,
- TrackingEventName: TrackingEventName,
- getSubdomain: getSubdomain
- };
- },{"./RESTController":46,"@babel/runtime-corejs3/core-js-stable/instance/for-each":86,"@babel/runtime-corejs3/core-js-stable/instance/map":90,"@babel/runtime-corejs3/core-js-stable/instance/reduce":92,"@babel/runtime-corejs3/core-js-stable/instance/slice":93,"@babel/runtime-corejs3/core-js-stable/json/stringify":99,"@babel/runtime-corejs3/core-js-stable/number/is-nan":102,"@babel/runtime-corejs3/core-js-stable/object/create":103,"@babel/runtime-corejs3/core-js-stable/object/entries":106,"@babel/runtime-corejs3/core-js-stable/object/freeze":107,"@babel/runtime-corejs3/core-js-stable/object/keys":112,"@babel/runtime-corejs3/core-js-stable/symbol/replace":120,"@babel/runtime-corejs3/core-js-stable/weak-map":122,"@babel/runtime-corejs3/helpers/asyncToGenerator":144,"@babel/runtime-corejs3/helpers/inherits":151,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/helpers/setPrototypeOf":160,"@babel/runtime-corejs3/helpers/slicedToArray":161,"@babel/runtime-corejs3/helpers/typeof":164,"@babel/runtime-corejs3/regenerator":167}],76:[function(_dereq_,module,exports){
- "use strict";
- var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
- var _parseInt2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/parse-int"));
- function fromDecimalToHex(number) {
- if (typeof number !== 'number') throw 'The input provided should be a number';
- return "0x".concat(number.toString(16));
- }
- function fromHexToDecimal(hex) {
- if (typeof hex !== 'string') throw 'The input provided should be a string';
- return (0, _parseInt2.default)(hex, 16);
- }
- module.exports = {
- fromDecimalToHex: fromDecimalToHex,
- fromHexToDecimal: fromHexToDecimal
- };
- },{"@babel/runtime-corejs3/core-js-stable/parse-int":114,"@babel/runtime-corejs3/helpers/interopRequireDefault":152}],77:[function(_dereq_,module,exports){
- "use strict";
- var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
- _Object$defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = void 0;
- var _convert = _dereq_("./convert");
- /**
- * Converts chainId to a hex if it is a number
- */
- function verifyChainId(chainId) {
- if (typeof chainId === 'number') chainId = (0, _convert.fromDecimalToHex)(chainId);
- return chainId;
- }
- var _default = verifyChainId;
- exports.default = _default;
- },{"./convert":76,"@babel/runtime-corejs3/core-js-stable/object/define-property":105}],78:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/array/from");
- },{"core-js-pure/stable/array/from":691}],79:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/array/is-array");
- },{"core-js-pure/stable/array/is-array":692}],80:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/instance/bind");
- },{"core-js-pure/stable/instance/bind":698}],81:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/instance/concat");
- },{"core-js-pure/stable/instance/concat":699}],82:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/instance/entries");
- },{"core-js-pure/stable/instance/entries":700}],83:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/instance/every");
- },{"core-js-pure/stable/instance/every":701}],84:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/instance/filter");
- },{"core-js-pure/stable/instance/filter":702}],85:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/instance/find");
- },{"core-js-pure/stable/instance/find":703}],86:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/instance/for-each");
- },{"core-js-pure/stable/instance/for-each":704}],87:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/instance/includes");
- },{"core-js-pure/stable/instance/includes":705}],88:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/instance/index-of");
- },{"core-js-pure/stable/instance/index-of":706}],89:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/instance/keys");
- },{"core-js-pure/stable/instance/keys":707}],90:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/instance/map");
- },{"core-js-pure/stable/instance/map":708}],91:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/instance/pad-start");
- },{"core-js-pure/stable/instance/pad-start":709}],92:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/instance/reduce");
- },{"core-js-pure/stable/instance/reduce":710}],93:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/instance/slice");
- },{"core-js-pure/stable/instance/slice":711}],94:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/instance/sort");
- },{"core-js-pure/stable/instance/sort":712}],95:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/instance/splice");
- },{"core-js-pure/stable/instance/splice":713}],96:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/instance/starts-with");
- },{"core-js-pure/stable/instance/starts-with":714}],97:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/instance/trim");
- },{"core-js-pure/stable/instance/trim":715}],98:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/instance/values");
- },{"core-js-pure/stable/instance/values":716}],99:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/json/stringify");
- },{"core-js-pure/stable/json/stringify":717}],100:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/map");
- },{"core-js-pure/stable/map":718}],101:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/number/is-integer");
- },{"core-js-pure/stable/number/is-integer":719}],102:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/number/is-nan");
- },{"core-js-pure/stable/number/is-nan":720}],103:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/object/create");
- },{"core-js-pure/stable/object/create":721}],104:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/object/define-properties");
- },{"core-js-pure/stable/object/define-properties":722}],105:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/object/define-property");
- },{"core-js-pure/stable/object/define-property":723}],106:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/object/entries");
- },{"core-js-pure/stable/object/entries":724}],107:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/object/freeze");
- },{"core-js-pure/stable/object/freeze":725}],108:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/object/get-own-property-descriptor");
- },{"core-js-pure/stable/object/get-own-property-descriptor":726}],109:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/object/get-own-property-descriptors");
- },{"core-js-pure/stable/object/get-own-property-descriptors":727}],110:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/object/get-own-property-symbols");
- },{"core-js-pure/stable/object/get-own-property-symbols":728}],111:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/object/get-prototype-of");
- },{"core-js-pure/stable/object/get-prototype-of":729}],112:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/object/keys");
- },{"core-js-pure/stable/object/keys":730}],113:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/object/values");
- },{"core-js-pure/stable/object/values":732}],114:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/parse-int");
- },{"core-js-pure/stable/parse-int":733}],115:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/promise");
- },{"core-js-pure/stable/promise":734}],116:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/reflect/construct");
- },{"core-js-pure/stable/reflect/construct":735}],117:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/set-timeout");
- },{"core-js-pure/stable/set-timeout":737}],118:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/set");
- },{"core-js-pure/stable/set":738}],119:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/symbol");
- },{"core-js-pure/stable/symbol":739}],120:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/symbol/replace");
- },{"core-js-pure/stable/symbol/replace":741}],121:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/url");
- },{"core-js-pure/stable/url":742}],122:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/weak-map");
- },{"core-js-pure/stable/weak-map":743}],123:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/features/array/from");
- },{"core-js-pure/features/array/from":404}],124:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/features/array/is-array");
- },{"core-js-pure/features/array/is-array":405}],125:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/features/get-iterator-method");
- },{"core-js-pure/features/get-iterator-method":406}],126:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/features/instance/bind");
- },{"core-js-pure/features/instance/bind":407}],127:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/features/instance/index-of");
- },{"core-js-pure/features/instance/index-of":408}],128:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/features/instance/slice");
- },{"core-js-pure/features/instance/slice":409}],129:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/features/map");
- },{"core-js-pure/features/map":410}],130:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/features/object/create");
- },{"core-js-pure/features/object/create":411}],131:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/features/object/define-property");
- },{"core-js-pure/features/object/define-property":412}],132:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/features/object/get-own-property-descriptor");
- },{"core-js-pure/features/object/get-own-property-descriptor":413}],133:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/features/object/get-prototype-of");
- },{"core-js-pure/features/object/get-prototype-of":414}],134:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/features/object/set-prototype-of");
- },{"core-js-pure/features/object/set-prototype-of":415}],135:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/features/promise");
- },{"core-js-pure/features/promise":416}],136:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/features/reflect/construct");
- },{"core-js-pure/features/reflect/construct":417}],137:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/features/reflect/get");
- },{"core-js-pure/features/reflect/get":418}],138:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/features/symbol");
- },{"core-js-pure/features/symbol":419}],139:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/features/symbol/iterator");
- },{"core-js-pure/features/symbol/iterator":420}],140:[function(_dereq_,module,exports){
- function _arrayLikeToArray(arr, len) {
- if (len == null || len > arr.length) len = arr.length;
- for (var i = 0, arr2 = new Array(len); i < len; i++) {
- arr2[i] = arr[i];
- }
- return arr2;
- }
- module.exports = _arrayLikeToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
- },{}],141:[function(_dereq_,module,exports){
- var _Array$isArray = _dereq_("@babel/runtime-corejs3/core-js/array/is-array");
- function _arrayWithHoles(arr) {
- if (_Array$isArray(arr)) return arr;
- }
- module.exports = _arrayWithHoles, module.exports.__esModule = true, module.exports["default"] = module.exports;
- },{"@babel/runtime-corejs3/core-js/array/is-array":124}],142:[function(_dereq_,module,exports){
- var _Array$isArray = _dereq_("@babel/runtime-corejs3/core-js/array/is-array");
- var arrayLikeToArray = _dereq_("./arrayLikeToArray.js");
- function _arrayWithoutHoles(arr) {
- if (_Array$isArray(arr)) return arrayLikeToArray(arr);
- }
- module.exports = _arrayWithoutHoles, module.exports.__esModule = true, module.exports["default"] = module.exports;
- },{"./arrayLikeToArray.js":140,"@babel/runtime-corejs3/core-js/array/is-array":124}],143:[function(_dereq_,module,exports){
- function _assertThisInitialized(self) {
- if (self === void 0) {
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
- }
- return self;
- }
- module.exports = _assertThisInitialized, module.exports.__esModule = true, module.exports["default"] = module.exports;
- },{}],144:[function(_dereq_,module,exports){
- var _Promise = _dereq_("@babel/runtime-corejs3/core-js/promise");
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
- try {
- var info = gen[key](arg);
- var value = info.value;
- } catch (error) {
- reject(error);
- return;
- }
- if (info.done) {
- resolve(value);
- } else {
- _Promise.resolve(value).then(_next, _throw);
- }
- }
- function _asyncToGenerator(fn) {
- return function () {
- var self = this,
- args = arguments;
- return new _Promise(function (resolve, reject) {
- var gen = fn.apply(self, args);
- function _next(value) {
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
- }
- function _throw(err) {
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
- }
- _next(undefined);
- });
- };
- }
- module.exports = _asyncToGenerator, module.exports.__esModule = true, module.exports["default"] = module.exports;
- },{"@babel/runtime-corejs3/core-js/promise":135}],145:[function(_dereq_,module,exports){
- function _classCallCheck(instance, Constructor) {
- if (!(instance instanceof Constructor)) {
- throw new TypeError("Cannot call a class as a function");
- }
- }
- module.exports = _classCallCheck, module.exports.__esModule = true, module.exports["default"] = module.exports;
- },{}],146:[function(_dereq_,module,exports){
- var _Reflect$construct = _dereq_("@babel/runtime-corejs3/core-js/reflect/construct");
- var _bindInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js/instance/bind");
- var setPrototypeOf = _dereq_("./setPrototypeOf.js");
- var isNativeReflectConstruct = _dereq_("./isNativeReflectConstruct.js");
- function _construct(Parent, args, Class) {
- if (isNativeReflectConstruct()) {
- module.exports = _construct = _Reflect$construct, module.exports.__esModule = true, module.exports["default"] = module.exports;
- } else {
- module.exports = _construct = function _construct(Parent, args, Class) {
- var a = [null];
- a.push.apply(a, args);
- var Constructor = _bindInstanceProperty(Function).apply(Parent, a);
- var instance = new Constructor();
- if (Class) setPrototypeOf(instance, Class.prototype);
- return instance;
- }, module.exports.__esModule = true, module.exports["default"] = module.exports;
- }
- return _construct.apply(null, arguments);
- }
- module.exports = _construct, module.exports.__esModule = true, module.exports["default"] = module.exports;
- },{"./isNativeReflectConstruct.js":154,"./setPrototypeOf.js":160,"@babel/runtime-corejs3/core-js/instance/bind":126,"@babel/runtime-corejs3/core-js/reflect/construct":136}],147:[function(_dereq_,module,exports){
- var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js/object/define-property");
- 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);
- }
- }
- function _createClass(Constructor, protoProps, staticProps) {
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
- if (staticProps) _defineProperties(Constructor, staticProps);
- _Object$defineProperty(Constructor, "prototype", {
- writable: false
- });
- return Constructor;
- }
- module.exports = _createClass, module.exports.__esModule = true, module.exports["default"] = module.exports;
- },{"@babel/runtime-corejs3/core-js/object/define-property":131}],148:[function(_dereq_,module,exports){
- var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js/object/define-property");
- function _defineProperty(obj, key, value) {
- if (key in obj) {
- _Object$defineProperty(obj, key, {
- value: value,
- enumerable: true,
- configurable: true,
- writable: true
- });
- } else {
- obj[key] = value;
- }
- return obj;
- }
- module.exports = _defineProperty, module.exports.__esModule = true, module.exports["default"] = module.exports;
- },{"@babel/runtime-corejs3/core-js/object/define-property":131}],149:[function(_dereq_,module,exports){
- var _Reflect$get = _dereq_("@babel/runtime-corejs3/core-js/reflect/get");
- var _Object$getOwnPropertyDescriptor = _dereq_("@babel/runtime-corejs3/core-js/object/get-own-property-descriptor");
- var superPropBase = _dereq_("./superPropBase.js");
- function _get() {
- if (typeof Reflect !== "undefined" && _Reflect$get) {
- module.exports = _get = _Reflect$get, module.exports.__esModule = true, module.exports["default"] = module.exports;
- } else {
- module.exports = _get = function _get(target, property, receiver) {
- var base = superPropBase(target, property);
- if (!base) return;
- var desc = _Object$getOwnPropertyDescriptor(base, property);
- if (desc.get) {
- return desc.get.call(arguments.length < 3 ? target : receiver);
- }
- return desc.value;
- }, module.exports.__esModule = true, module.exports["default"] = module.exports;
- }
- return _get.apply(this, arguments);
- }
- module.exports = _get, module.exports.__esModule = true, module.exports["default"] = module.exports;
- },{"./superPropBase.js":162,"@babel/runtime-corejs3/core-js/object/get-own-property-descriptor":132,"@babel/runtime-corejs3/core-js/reflect/get":137}],150:[function(_dereq_,module,exports){
- var _Object$setPrototypeOf = _dereq_("@babel/runtime-corejs3/core-js/object/set-prototype-of");
- var _Object$getPrototypeOf = _dereq_("@babel/runtime-corejs3/core-js/object/get-prototype-of");
- function _getPrototypeOf(o) {
- module.exports = _getPrototypeOf = _Object$setPrototypeOf ? _Object$getPrototypeOf : function _getPrototypeOf(o) {
- return o.__proto__ || _Object$getPrototypeOf(o);
- }, module.exports.__esModule = true, module.exports["default"] = module.exports;
- return _getPrototypeOf(o);
- }
- module.exports = _getPrototypeOf, module.exports.__esModule = true, module.exports["default"] = module.exports;
- },{"@babel/runtime-corejs3/core-js/object/get-prototype-of":133,"@babel/runtime-corejs3/core-js/object/set-prototype-of":134}],151:[function(_dereq_,module,exports){
- var _Object$create = _dereq_("@babel/runtime-corejs3/core-js/object/create");
- var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js/object/define-property");
- var setPrototypeOf = _dereq_("./setPrototypeOf.js");
- function _inherits(subClass, superClass) {
- if (typeof superClass !== "function" && superClass !== null) {
- throw new TypeError("Super expression must either be null or a function");
- }
- subClass.prototype = _Object$create(superClass && superClass.prototype, {
- constructor: {
- value: subClass,
- writable: true,
- configurable: true
- }
- });
- _Object$defineProperty(subClass, "prototype", {
- writable: false
- });
- if (superClass) setPrototypeOf(subClass, superClass);
- }
- module.exports = _inherits, module.exports.__esModule = true, module.exports["default"] = module.exports;
- },{"./setPrototypeOf.js":160,"@babel/runtime-corejs3/core-js/object/create":130,"@babel/runtime-corejs3/core-js/object/define-property":131}],152:[function(_dereq_,module,exports){
- function _interopRequireDefault(obj) {
- return obj && obj.__esModule ? obj : {
- "default": obj
- };
- }
- module.exports = _interopRequireDefault, module.exports.__esModule = true, module.exports["default"] = module.exports;
- },{}],153:[function(_dereq_,module,exports){
- var _indexOfInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js/instance/index-of");
- function _isNativeFunction(fn) {
- var _context;
- return _indexOfInstanceProperty(_context = Function.toString.call(fn)).call(_context, "[native code]") !== -1;
- }
- module.exports = _isNativeFunction, module.exports.__esModule = true, module.exports["default"] = module.exports;
- },{"@babel/runtime-corejs3/core-js/instance/index-of":127}],154:[function(_dereq_,module,exports){
- var _Reflect$construct = _dereq_("@babel/runtime-corejs3/core-js/reflect/construct");
- function _isNativeReflectConstruct() {
- if (typeof Reflect === "undefined" || !_Reflect$construct) return false;
- if (_Reflect$construct.sham) return false;
- if (typeof Proxy === "function") return true;
- try {
- Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {}));
- return true;
- } catch (e) {
- return false;
- }
- }
- module.exports = _isNativeReflectConstruct, module.exports.__esModule = true, module.exports["default"] = module.exports;
- },{"@babel/runtime-corejs3/core-js/reflect/construct":136}],155:[function(_dereq_,module,exports){
- var _Symbol = _dereq_("@babel/runtime-corejs3/core-js/symbol");
- var _getIteratorMethod = _dereq_("@babel/runtime-corejs3/core-js/get-iterator-method");
- var _Array$from = _dereq_("@babel/runtime-corejs3/core-js/array/from");
- function _iterableToArray(iter) {
- if (typeof _Symbol !== "undefined" && _getIteratorMethod(iter) != null || iter["@@iterator"] != null) return _Array$from(iter);
- }
- module.exports = _iterableToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
- },{"@babel/runtime-corejs3/core-js/array/from":123,"@babel/runtime-corejs3/core-js/get-iterator-method":125,"@babel/runtime-corejs3/core-js/symbol":138}],156:[function(_dereq_,module,exports){
- var _Symbol = _dereq_("@babel/runtime-corejs3/core-js/symbol");
- var _getIteratorMethod = _dereq_("@babel/runtime-corejs3/core-js/get-iterator-method");
- function _iterableToArrayLimit(arr, i) {
- var _i = arr == null ? null : typeof _Symbol !== "undefined" && _getIteratorMethod(arr) || arr["@@iterator"];
- if (_i == null) return;
- var _arr = [];
- var _n = true;
- var _d = false;
- var _s, _e;
- try {
- for (_i = _i.call(arr); !(_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"] != null) _i["return"]();
- } finally {
- if (_d) throw _e;
- }
- }
- return _arr;
- }
- module.exports = _iterableToArrayLimit, module.exports.__esModule = true, module.exports["default"] = module.exports;
- },{"@babel/runtime-corejs3/core-js/get-iterator-method":125,"@babel/runtime-corejs3/core-js/symbol":138}],157:[function(_dereq_,module,exports){
- function _nonIterableRest() {
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
- }
- module.exports = _nonIterableRest, module.exports.__esModule = true, module.exports["default"] = module.exports;
- },{}],158:[function(_dereq_,module,exports){
- function _nonIterableSpread() {
- throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
- }
- module.exports = _nonIterableSpread, module.exports.__esModule = true, module.exports["default"] = module.exports;
- },{}],159:[function(_dereq_,module,exports){
- var _typeof = _dereq_("./typeof.js")["default"];
- var assertThisInitialized = _dereq_("./assertThisInitialized.js");
- function _possibleConstructorReturn(self, call) {
- if (call && (_typeof(call) === "object" || typeof call === "function")) {
- return call;
- } else if (call !== void 0) {
- throw new TypeError("Derived constructors may only return object or undefined");
- }
- return assertThisInitialized(self);
- }
- module.exports = _possibleConstructorReturn, module.exports.__esModule = true, module.exports["default"] = module.exports;
- },{"./assertThisInitialized.js":143,"./typeof.js":164}],160:[function(_dereq_,module,exports){
- var _Object$setPrototypeOf = _dereq_("@babel/runtime-corejs3/core-js/object/set-prototype-of");
- function _setPrototypeOf(o, p) {
- module.exports = _setPrototypeOf = _Object$setPrototypeOf || function _setPrototypeOf(o, p) {
- o.__proto__ = p;
- return o;
- }, module.exports.__esModule = true, module.exports["default"] = module.exports;
- return _setPrototypeOf(o, p);
- }
- module.exports = _setPrototypeOf, module.exports.__esModule = true, module.exports["default"] = module.exports;
- },{"@babel/runtime-corejs3/core-js/object/set-prototype-of":134}],161:[function(_dereq_,module,exports){
- var arrayWithHoles = _dereq_("./arrayWithHoles.js");
- var iterableToArrayLimit = _dereq_("./iterableToArrayLimit.js");
- var unsupportedIterableToArray = _dereq_("./unsupportedIterableToArray.js");
- var nonIterableRest = _dereq_("./nonIterableRest.js");
- function _slicedToArray(arr, i) {
- return arrayWithHoles(arr) || iterableToArrayLimit(arr, i) || unsupportedIterableToArray(arr, i) || nonIterableRest();
- }
- module.exports = _slicedToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
- },{"./arrayWithHoles.js":141,"./iterableToArrayLimit.js":156,"./nonIterableRest.js":157,"./unsupportedIterableToArray.js":165}],162:[function(_dereq_,module,exports){
- var getPrototypeOf = _dereq_("./getPrototypeOf.js");
- function _superPropBase(object, property) {
- while (!Object.prototype.hasOwnProperty.call(object, property)) {
- object = getPrototypeOf(object);
- if (object === null) break;
- }
- return object;
- }
- module.exports = _superPropBase, module.exports.__esModule = true, module.exports["default"] = module.exports;
- },{"./getPrototypeOf.js":150}],163:[function(_dereq_,module,exports){
- var arrayWithoutHoles = _dereq_("./arrayWithoutHoles.js");
- var iterableToArray = _dereq_("./iterableToArray.js");
- var unsupportedIterableToArray = _dereq_("./unsupportedIterableToArray.js");
- var nonIterableSpread = _dereq_("./nonIterableSpread.js");
- function _toConsumableArray(arr) {
- return arrayWithoutHoles(arr) || iterableToArray(arr) || unsupportedIterableToArray(arr) || nonIterableSpread();
- }
- module.exports = _toConsumableArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
- },{"./arrayWithoutHoles.js":142,"./iterableToArray.js":155,"./nonIterableSpread.js":158,"./unsupportedIterableToArray.js":165}],164:[function(_dereq_,module,exports){
- var _Symbol = _dereq_("@babel/runtime-corejs3/core-js/symbol");
- var _Symbol$iterator = _dereq_("@babel/runtime-corejs3/core-js/symbol/iterator");
- function _typeof(obj) {
- "@babel/helpers - typeof";
- return (module.exports = _typeof = "function" == typeof _Symbol && "symbol" == typeof _Symbol$iterator ? function (obj) {
- return typeof obj;
- } : function (obj) {
- return obj && "function" == typeof _Symbol && obj.constructor === _Symbol && obj !== _Symbol.prototype ? "symbol" : typeof obj;
- }, module.exports.__esModule = true, module.exports["default"] = module.exports), _typeof(obj);
- }
- module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
- },{"@babel/runtime-corejs3/core-js/symbol":138,"@babel/runtime-corejs3/core-js/symbol/iterator":139}],165:[function(_dereq_,module,exports){
- var _sliceInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js/instance/slice");
- var _Array$from = _dereq_("@babel/runtime-corejs3/core-js/array/from");
- var arrayLikeToArray = _dereq_("./arrayLikeToArray.js");
- function _unsupportedIterableToArray(o, minLen) {
- var _context;
- if (!o) return;
- if (typeof o === "string") return arrayLikeToArray(o, minLen);
- var n = _sliceInstanceProperty(_context = Object.prototype.toString.call(o)).call(_context, 8, -1);
- if (n === "Object" && o.constructor) n = o.constructor.name;
- if (n === "Map" || n === "Set") return _Array$from(o);
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return arrayLikeToArray(o, minLen);
- }
- module.exports = _unsupportedIterableToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
- },{"./arrayLikeToArray.js":140,"@babel/runtime-corejs3/core-js/array/from":123,"@babel/runtime-corejs3/core-js/instance/slice":128}],166:[function(_dereq_,module,exports){
- var _Map = _dereq_("@babel/runtime-corejs3/core-js/map");
- var _Object$create = _dereq_("@babel/runtime-corejs3/core-js/object/create");
- var getPrototypeOf = _dereq_("./getPrototypeOf.js");
- var setPrototypeOf = _dereq_("./setPrototypeOf.js");
- var isNativeFunction = _dereq_("./isNativeFunction.js");
- var construct = _dereq_("./construct.js");
- function _wrapNativeSuper(Class) {
- var _cache = typeof _Map === "function" ? new _Map() : undefined;
- module.exports = _wrapNativeSuper = function _wrapNativeSuper(Class) {
- if (Class === null || !isNativeFunction(Class)) return Class;
- if (typeof Class !== "function") {
- throw new TypeError("Super expression must either be null or a function");
- }
- if (typeof _cache !== "undefined") {
- if (_cache.has(Class)) return _cache.get(Class);
- _cache.set(Class, Wrapper);
- }
- function Wrapper() {
- return construct(Class, arguments, getPrototypeOf(this).constructor);
- }
- Wrapper.prototype = _Object$create(Class.prototype, {
- constructor: {
- value: Wrapper,
- enumerable: false,
- writable: true,
- configurable: true
- }
- });
- return setPrototypeOf(Wrapper, Class);
- }, module.exports.__esModule = true, module.exports["default"] = module.exports;
- return _wrapNativeSuper(Class);
- }
- module.exports = _wrapNativeSuper, module.exports.__esModule = true, module.exports["default"] = module.exports;
- },{"./construct.js":146,"./getPrototypeOf.js":150,"./isNativeFunction.js":153,"./setPrototypeOf.js":160,"@babel/runtime-corejs3/core-js/map":129,"@babel/runtime-corejs3/core-js/object/create":130}],167:[function(_dereq_,module,exports){
- module.exports = _dereq_("regenerator-runtime");
- },{"regenerator-runtime":794}],168:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.version = void 0;
- exports.version = "abi/5.6.0";
- },{}],169:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.defaultAbiCoder = exports.AbiCoder = void 0;
- // See: https://github.com/ethereum/wiki/wiki/Ethereum-Contract-ABI
- var bytes_1 = _dereq_("@ethersproject/bytes");
- var properties_1 = _dereq_("@ethersproject/properties");
- var logger_1 = _dereq_("@ethersproject/logger");
- var _version_1 = _dereq_("./_version");
- var logger = new logger_1.Logger(_version_1.version);
- var abstract_coder_1 = _dereq_("./coders/abstract-coder");
- var address_1 = _dereq_("./coders/address");
- var array_1 = _dereq_("./coders/array");
- var boolean_1 = _dereq_("./coders/boolean");
- var bytes_2 = _dereq_("./coders/bytes");
- var fixed_bytes_1 = _dereq_("./coders/fixed-bytes");
- var null_1 = _dereq_("./coders/null");
- var number_1 = _dereq_("./coders/number");
- var string_1 = _dereq_("./coders/string");
- var tuple_1 = _dereq_("./coders/tuple");
- var fragments_1 = _dereq_("./fragments");
- var paramTypeBytes = new RegExp(/^bytes([0-9]*)$/);
- var paramTypeNumber = new RegExp(/^(u?int)([0-9]*)$/);
- var AbiCoder = /** @class */ (function () {
- function AbiCoder(coerceFunc) {
- var _newTarget = this.constructor;
- logger.checkNew(_newTarget, AbiCoder);
- (0, properties_1.defineReadOnly)(this, "coerceFunc", coerceFunc || null);
- }
- AbiCoder.prototype._getCoder = function (param) {
- var _this = this;
- switch (param.baseType) {
- case "address":
- return new address_1.AddressCoder(param.name);
- case "bool":
- return new boolean_1.BooleanCoder(param.name);
- case "string":
- return new string_1.StringCoder(param.name);
- case "bytes":
- return new bytes_2.BytesCoder(param.name);
- case "array":
- return new array_1.ArrayCoder(this._getCoder(param.arrayChildren), param.arrayLength, param.name);
- case "tuple":
- return new tuple_1.TupleCoder((param.components || []).map(function (component) {
- return _this._getCoder(component);
- }), param.name);
- case "":
- return new null_1.NullCoder(param.name);
- }
- // u?int[0-9]*
- var match = param.type.match(paramTypeNumber);
- if (match) {
- var size = parseInt(match[2] || "256");
- if (size === 0 || size > 256 || (size % 8) !== 0) {
- logger.throwArgumentError("invalid " + match[1] + " bit length", "param", param);
- }
- return new number_1.NumberCoder(size / 8, (match[1] === "int"), param.name);
- }
- // bytes[0-9]+
- match = param.type.match(paramTypeBytes);
- if (match) {
- var size = parseInt(match[1]);
- if (size === 0 || size > 32) {
- logger.throwArgumentError("invalid bytes length", "param", param);
- }
- return new fixed_bytes_1.FixedBytesCoder(size, param.name);
- }
- return logger.throwArgumentError("invalid type", "type", param.type);
- };
- AbiCoder.prototype._getWordSize = function () { return 32; };
- AbiCoder.prototype._getReader = function (data, allowLoose) {
- return new abstract_coder_1.Reader(data, this._getWordSize(), this.coerceFunc, allowLoose);
- };
- AbiCoder.prototype._getWriter = function () {
- return new abstract_coder_1.Writer(this._getWordSize());
- };
- AbiCoder.prototype.getDefaultValue = function (types) {
- var _this = this;
- var coders = types.map(function (type) { return _this._getCoder(fragments_1.ParamType.from(type)); });
- var coder = new tuple_1.TupleCoder(coders, "_");
- return coder.defaultValue();
- };
- AbiCoder.prototype.encode = function (types, values) {
- var _this = this;
- if (types.length !== values.length) {
- logger.throwError("types/values length mismatch", logger_1.Logger.errors.INVALID_ARGUMENT, {
- count: { types: types.length, values: values.length },
- value: { types: types, values: values }
- });
- }
- var coders = types.map(function (type) { return _this._getCoder(fragments_1.ParamType.from(type)); });
- var coder = (new tuple_1.TupleCoder(coders, "_"));
- var writer = this._getWriter();
- coder.encode(writer, values);
- return writer.data;
- };
- AbiCoder.prototype.decode = function (types, data, loose) {
- var _this = this;
- var coders = types.map(function (type) { return _this._getCoder(fragments_1.ParamType.from(type)); });
- var coder = new tuple_1.TupleCoder(coders, "_");
- return coder.decode(this._getReader((0, bytes_1.arrayify)(data), loose));
- };
- return AbiCoder;
- }());
- exports.AbiCoder = AbiCoder;
- exports.defaultAbiCoder = new AbiCoder();
- },{"./_version":168,"./coders/abstract-coder":170,"./coders/address":171,"./coders/array":173,"./coders/boolean":174,"./coders/bytes":175,"./coders/fixed-bytes":176,"./coders/null":177,"./coders/number":178,"./coders/string":179,"./coders/tuple":180,"./fragments":181,"@ethersproject/bytes":199,"@ethersproject/logger":223,"@ethersproject/properties":229}],170:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.Reader = exports.Writer = exports.Coder = exports.checkResultErrors = void 0;
- var bytes_1 = _dereq_("@ethersproject/bytes");
- var bignumber_1 = _dereq_("@ethersproject/bignumber");
- var properties_1 = _dereq_("@ethersproject/properties");
- var logger_1 = _dereq_("@ethersproject/logger");
- var _version_1 = _dereq_("../_version");
- var logger = new logger_1.Logger(_version_1.version);
- function checkResultErrors(result) {
- // Find the first error (if any)
- var errors = [];
- var checkErrors = function (path, object) {
- if (!Array.isArray(object)) {
- return;
- }
- for (var key in object) {
- var childPath = path.slice();
- childPath.push(key);
- try {
- checkErrors(childPath, object[key]);
- }
- catch (error) {
- errors.push({ path: childPath, error: error });
- }
- }
- };
- checkErrors([], result);
- return errors;
- }
- exports.checkResultErrors = checkResultErrors;
- var Coder = /** @class */ (function () {
- function Coder(name, type, localName, dynamic) {
- // @TODO: defineReadOnly these
- this.name = name;
- this.type = type;
- this.localName = localName;
- this.dynamic = dynamic;
- }
- Coder.prototype._throwError = function (message, value) {
- logger.throwArgumentError(message, this.localName, value);
- };
- return Coder;
- }());
- exports.Coder = Coder;
- var Writer = /** @class */ (function () {
- function Writer(wordSize) {
- (0, properties_1.defineReadOnly)(this, "wordSize", wordSize || 32);
- this._data = [];
- this._dataLength = 0;
- this._padding = new Uint8Array(wordSize);
- }
- Object.defineProperty(Writer.prototype, "data", {
- get: function () {
- return (0, bytes_1.hexConcat)(this._data);
- },
- enumerable: false,
- configurable: true
- });
- Object.defineProperty(Writer.prototype, "length", {
- get: function () { return this._dataLength; },
- enumerable: false,
- configurable: true
- });
- Writer.prototype._writeData = function (data) {
- this._data.push(data);
- this._dataLength += data.length;
- return data.length;
- };
- Writer.prototype.appendWriter = function (writer) {
- return this._writeData((0, bytes_1.concat)(writer._data));
- };
- // Arrayish items; padded on the right to wordSize
- Writer.prototype.writeBytes = function (value) {
- var bytes = (0, bytes_1.arrayify)(value);
- var paddingOffset = bytes.length % this.wordSize;
- if (paddingOffset) {
- bytes = (0, bytes_1.concat)([bytes, this._padding.slice(paddingOffset)]);
- }
- return this._writeData(bytes);
- };
- Writer.prototype._getValue = function (value) {
- var bytes = (0, bytes_1.arrayify)(bignumber_1.BigNumber.from(value));
- if (bytes.length > this.wordSize) {
- logger.throwError("value out-of-bounds", logger_1.Logger.errors.BUFFER_OVERRUN, {
- length: this.wordSize,
- offset: bytes.length
- });
- }
- if (bytes.length % this.wordSize) {
- bytes = (0, bytes_1.concat)([this._padding.slice(bytes.length % this.wordSize), bytes]);
- }
- return bytes;
- };
- // BigNumberish items; padded on the left to wordSize
- Writer.prototype.writeValue = function (value) {
- return this._writeData(this._getValue(value));
- };
- Writer.prototype.writeUpdatableValue = function () {
- var _this = this;
- var offset = this._data.length;
- this._data.push(this._padding);
- this._dataLength += this.wordSize;
- return function (value) {
- _this._data[offset] = _this._getValue(value);
- };
- };
- return Writer;
- }());
- exports.Writer = Writer;
- var Reader = /** @class */ (function () {
- function Reader(data, wordSize, coerceFunc, allowLoose) {
- (0, properties_1.defineReadOnly)(this, "_data", (0, bytes_1.arrayify)(data));
- (0, properties_1.defineReadOnly)(this, "wordSize", wordSize || 32);
- (0, properties_1.defineReadOnly)(this, "_coerceFunc", coerceFunc);
- (0, properties_1.defineReadOnly)(this, "allowLoose", allowLoose);
- this._offset = 0;
- }
- Object.defineProperty(Reader.prototype, "data", {
- get: function () { return (0, bytes_1.hexlify)(this._data); },
- enumerable: false,
- configurable: true
- });
- Object.defineProperty(Reader.prototype, "consumed", {
- get: function () { return this._offset; },
- enumerable: false,
- configurable: true
- });
- // The default Coerce function
- Reader.coerce = function (name, value) {
- var match = name.match("^u?int([0-9]+)$");
- if (match && parseInt(match[1]) <= 48) {
- value = value.toNumber();
- }
- return value;
- };
- Reader.prototype.coerce = function (name, value) {
- if (this._coerceFunc) {
- return this._coerceFunc(name, value);
- }
- return Reader.coerce(name, value);
- };
- Reader.prototype._peekBytes = function (offset, length, loose) {
- var alignedLength = Math.ceil(length / this.wordSize) * this.wordSize;
- if (this._offset + alignedLength > this._data.length) {
- if (this.allowLoose && loose && this._offset + length <= this._data.length) {
- alignedLength = length;
- }
- else {
- logger.throwError("data out-of-bounds", logger_1.Logger.errors.BUFFER_OVERRUN, {
- length: this._data.length,
- offset: this._offset + alignedLength
- });
- }
- }
- return this._data.slice(this._offset, this._offset + alignedLength);
- };
- Reader.prototype.subReader = function (offset) {
- return new Reader(this._data.slice(this._offset + offset), this.wordSize, this._coerceFunc, this.allowLoose);
- };
- Reader.prototype.readBytes = function (length, loose) {
- var bytes = this._peekBytes(0, length, !!loose);
- this._offset += bytes.length;
- // @TODO: Make sure the length..end bytes are all 0?
- return bytes.slice(0, length);
- };
- Reader.prototype.readValue = function () {
- return bignumber_1.BigNumber.from(this.readBytes(this.wordSize));
- };
- return Reader;
- }());
- exports.Reader = Reader;
- },{"../_version":168,"@ethersproject/bignumber":196,"@ethersproject/bytes":199,"@ethersproject/logger":223,"@ethersproject/properties":229}],171:[function(_dereq_,module,exports){
- "use strict";
- var __extends = (this && this.__extends) || (function () {
- var extendStatics = function (d, b) {
- extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
- return extendStatics(d, b);
- };
- return function (d, b) {
- if (typeof b !== "function" && b !== null)
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.AddressCoder = void 0;
- var address_1 = _dereq_("@ethersproject/address");
- var bytes_1 = _dereq_("@ethersproject/bytes");
- var abstract_coder_1 = _dereq_("./abstract-coder");
- var AddressCoder = /** @class */ (function (_super) {
- __extends(AddressCoder, _super);
- function AddressCoder(localName) {
- return _super.call(this, "address", "address", localName, false) || this;
- }
- AddressCoder.prototype.defaultValue = function () {
- return "0x0000000000000000000000000000000000000000";
- };
- AddressCoder.prototype.encode = function (writer, value) {
- try {
- value = (0, address_1.getAddress)(value);
- }
- catch (error) {
- this._throwError(error.message, value);
- }
- return writer.writeValue(value);
- };
- AddressCoder.prototype.decode = function (reader) {
- return (0, address_1.getAddress)((0, bytes_1.hexZeroPad)(reader.readValue().toHexString(), 20));
- };
- return AddressCoder;
- }(abstract_coder_1.Coder));
- exports.AddressCoder = AddressCoder;
- },{"./abstract-coder":170,"@ethersproject/address":189,"@ethersproject/bytes":199}],172:[function(_dereq_,module,exports){
- "use strict";
- var __extends = (this && this.__extends) || (function () {
- var extendStatics = function (d, b) {
- extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
- return extendStatics(d, b);
- };
- return function (d, b) {
- if (typeof b !== "function" && b !== null)
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.AnonymousCoder = void 0;
- var abstract_coder_1 = _dereq_("./abstract-coder");
- // Clones the functionality of an existing Coder, but without a localName
- var AnonymousCoder = /** @class */ (function (_super) {
- __extends(AnonymousCoder, _super);
- function AnonymousCoder(coder) {
- var _this = _super.call(this, coder.name, coder.type, undefined, coder.dynamic) || this;
- _this.coder = coder;
- return _this;
- }
- AnonymousCoder.prototype.defaultValue = function () {
- return this.coder.defaultValue();
- };
- AnonymousCoder.prototype.encode = function (writer, value) {
- return this.coder.encode(writer, value);
- };
- AnonymousCoder.prototype.decode = function (reader) {
- return this.coder.decode(reader);
- };
- return AnonymousCoder;
- }(abstract_coder_1.Coder));
- exports.AnonymousCoder = AnonymousCoder;
- },{"./abstract-coder":170}],173:[function(_dereq_,module,exports){
- "use strict";
- var __extends = (this && this.__extends) || (function () {
- var extendStatics = function (d, b) {
- extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
- return extendStatics(d, b);
- };
- return function (d, b) {
- if (typeof b !== "function" && b !== null)
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.ArrayCoder = exports.unpack = exports.pack = void 0;
- var logger_1 = _dereq_("@ethersproject/logger");
- var _version_1 = _dereq_("../_version");
- var logger = new logger_1.Logger(_version_1.version);
- var abstract_coder_1 = _dereq_("./abstract-coder");
- var anonymous_1 = _dereq_("./anonymous");
- function pack(writer, coders, values) {
- var arrayValues = null;
- if (Array.isArray(values)) {
- arrayValues = values;
- }
- else if (values && typeof (values) === "object") {
- var unique_1 = {};
- arrayValues = coders.map(function (coder) {
- var name = coder.localName;
- if (!name) {
- logger.throwError("cannot encode object for signature with missing names", logger_1.Logger.errors.INVALID_ARGUMENT, {
- argument: "values",
- coder: coder,
- value: values
- });
- }
- if (unique_1[name]) {
- logger.throwError("cannot encode object for signature with duplicate names", logger_1.Logger.errors.INVALID_ARGUMENT, {
- argument: "values",
- coder: coder,
- value: values
- });
- }
- unique_1[name] = true;
- return values[name];
- });
- }
- else {
- logger.throwArgumentError("invalid tuple value", "tuple", values);
- }
- if (coders.length !== arrayValues.length) {
- logger.throwArgumentError("types/value length mismatch", "tuple", values);
- }
- var staticWriter = new abstract_coder_1.Writer(writer.wordSize);
- var dynamicWriter = new abstract_coder_1.Writer(writer.wordSize);
- var updateFuncs = [];
- coders.forEach(function (coder, index) {
- var value = arrayValues[index];
- if (coder.dynamic) {
- // Get current dynamic offset (for the future pointer)
- var dynamicOffset_1 = dynamicWriter.length;
- // Encode the dynamic value into the dynamicWriter
- coder.encode(dynamicWriter, value);
- // Prepare to populate the correct offset once we are done
- var updateFunc_1 = staticWriter.writeUpdatableValue();
- updateFuncs.push(function (baseOffset) {
- updateFunc_1(baseOffset + dynamicOffset_1);
- });
- }
- else {
- coder.encode(staticWriter, value);
- }
- });
- // Backfill all the dynamic offsets, now that we know the static length
- updateFuncs.forEach(function (func) { func(staticWriter.length); });
- var length = writer.appendWriter(staticWriter);
- length += writer.appendWriter(dynamicWriter);
- return length;
- }
- exports.pack = pack;
- function unpack(reader, coders) {
- var values = [];
- // A reader anchored to this base
- var baseReader = reader.subReader(0);
- coders.forEach(function (coder) {
- var value = null;
- if (coder.dynamic) {
- var offset = reader.readValue();
- var offsetReader = baseReader.subReader(offset.toNumber());
- try {
- value = coder.decode(offsetReader);
- }
- catch (error) {
- // Cannot recover from this
- if (error.code === logger_1.Logger.errors.BUFFER_OVERRUN) {
- throw error;
- }
- value = error;
- value.baseType = coder.name;
- value.name = coder.localName;
- value.type = coder.type;
- }
- }
- else {
- try {
- value = coder.decode(reader);
- }
- catch (error) {
- // Cannot recover from this
- if (error.code === logger_1.Logger.errors.BUFFER_OVERRUN) {
- throw error;
- }
- value = error;
- value.baseType = coder.name;
- value.name = coder.localName;
- value.type = coder.type;
- }
- }
- if (value != undefined) {
- values.push(value);
- }
- });
- // We only output named properties for uniquely named coders
- var uniqueNames = coders.reduce(function (accum, coder) {
- var name = coder.localName;
- if (name) {
- if (!accum[name]) {
- accum[name] = 0;
- }
- accum[name]++;
- }
- return accum;
- }, {});
- // Add any named parameters (i.e. tuples)
- coders.forEach(function (coder, index) {
- var name = coder.localName;
- if (!name || uniqueNames[name] !== 1) {
- return;
- }
- if (name === "length") {
- name = "_length";
- }
- if (values[name] != null) {
- return;
- }
- var value = values[index];
- if (value instanceof Error) {
- Object.defineProperty(values, name, {
- enumerable: true,
- get: function () { throw value; }
- });
- }
- else {
- values[name] = value;
- }
- });
- var _loop_1 = function (i) {
- var value = values[i];
- if (value instanceof Error) {
- Object.defineProperty(values, i, {
- enumerable: true,
- get: function () { throw value; }
- });
- }
- };
- for (var i = 0; i < values.length; i++) {
- _loop_1(i);
- }
- return Object.freeze(values);
- }
- exports.unpack = unpack;
- var ArrayCoder = /** @class */ (function (_super) {
- __extends(ArrayCoder, _super);
- function ArrayCoder(coder, length, localName) {
- var _this = this;
- var type = (coder.type + "[" + (length >= 0 ? length : "") + "]");
- var dynamic = (length === -1 || coder.dynamic);
- _this = _super.call(this, "array", type, localName, dynamic) || this;
- _this.coder = coder;
- _this.length = length;
- return _this;
- }
- ArrayCoder.prototype.defaultValue = function () {
- // Verifies the child coder is valid (even if the array is dynamic or 0-length)
- var defaultChild = this.coder.defaultValue();
- var result = [];
- for (var i = 0; i < this.length; i++) {
- result.push(defaultChild);
- }
- return result;
- };
- ArrayCoder.prototype.encode = function (writer, value) {
- if (!Array.isArray(value)) {
- this._throwError("expected array value", value);
- }
- var count = this.length;
- if (count === -1) {
- count = value.length;
- writer.writeValue(value.length);
- }
- logger.checkArgumentCount(value.length, count, "coder array" + (this.localName ? (" " + this.localName) : ""));
- var coders = [];
- for (var i = 0; i < value.length; i++) {
- coders.push(this.coder);
- }
- return pack(writer, coders, value);
- };
- ArrayCoder.prototype.decode = function (reader) {
- var count = this.length;
- if (count === -1) {
- count = reader.readValue().toNumber();
- // Check that there is *roughly* enough data to ensure
- // stray random data is not being read as a length. Each
- // slot requires at least 32 bytes for their value (or 32
- // bytes as a link to the data). This could use a much
- // tighter bound, but we are erroring on the side of safety.
- if (count * 32 > reader._data.length) {
- logger.throwError("insufficient data length", logger_1.Logger.errors.BUFFER_OVERRUN, {
- length: reader._data.length,
- count: count
- });
- }
- }
- var coders = [];
- for (var i = 0; i < count; i++) {
- coders.push(new anonymous_1.AnonymousCoder(this.coder));
- }
- return reader.coerce(this.name, unpack(reader, coders));
- };
- return ArrayCoder;
- }(abstract_coder_1.Coder));
- exports.ArrayCoder = ArrayCoder;
- },{"../_version":168,"./abstract-coder":170,"./anonymous":172,"@ethersproject/logger":223}],174:[function(_dereq_,module,exports){
- "use strict";
- var __extends = (this && this.__extends) || (function () {
- var extendStatics = function (d, b) {
- extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
- return extendStatics(d, b);
- };
- return function (d, b) {
- if (typeof b !== "function" && b !== null)
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.BooleanCoder = void 0;
- var abstract_coder_1 = _dereq_("./abstract-coder");
- var BooleanCoder = /** @class */ (function (_super) {
- __extends(BooleanCoder, _super);
- function BooleanCoder(localName) {
- return _super.call(this, "bool", "bool", localName, false) || this;
- }
- BooleanCoder.prototype.defaultValue = function () {
- return false;
- };
- BooleanCoder.prototype.encode = function (writer, value) {
- return writer.writeValue(value ? 1 : 0);
- };
- BooleanCoder.prototype.decode = function (reader) {
- return reader.coerce(this.type, !reader.readValue().isZero());
- };
- return BooleanCoder;
- }(abstract_coder_1.Coder));
- exports.BooleanCoder = BooleanCoder;
- },{"./abstract-coder":170}],175:[function(_dereq_,module,exports){
- "use strict";
- var __extends = (this && this.__extends) || (function () {
- var extendStatics = function (d, b) {
- extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
- return extendStatics(d, b);
- };
- return function (d, b) {
- if (typeof b !== "function" && b !== null)
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.BytesCoder = exports.DynamicBytesCoder = void 0;
- var bytes_1 = _dereq_("@ethersproject/bytes");
- var abstract_coder_1 = _dereq_("./abstract-coder");
- var DynamicBytesCoder = /** @class */ (function (_super) {
- __extends(DynamicBytesCoder, _super);
- function DynamicBytesCoder(type, localName) {
- return _super.call(this, type, type, localName, true) || this;
- }
- DynamicBytesCoder.prototype.defaultValue = function () {
- return "0x";
- };
- DynamicBytesCoder.prototype.encode = function (writer, value) {
- value = (0, bytes_1.arrayify)(value);
- var length = writer.writeValue(value.length);
- length += writer.writeBytes(value);
- return length;
- };
- DynamicBytesCoder.prototype.decode = function (reader) {
- return reader.readBytes(reader.readValue().toNumber(), true);
- };
- return DynamicBytesCoder;
- }(abstract_coder_1.Coder));
- exports.DynamicBytesCoder = DynamicBytesCoder;
- var BytesCoder = /** @class */ (function (_super) {
- __extends(BytesCoder, _super);
- function BytesCoder(localName) {
- return _super.call(this, "bytes", localName) || this;
- }
- BytesCoder.prototype.decode = function (reader) {
- return reader.coerce(this.name, (0, bytes_1.hexlify)(_super.prototype.decode.call(this, reader)));
- };
- return BytesCoder;
- }(DynamicBytesCoder));
- exports.BytesCoder = BytesCoder;
- },{"./abstract-coder":170,"@ethersproject/bytes":199}],176:[function(_dereq_,module,exports){
- "use strict";
- var __extends = (this && this.__extends) || (function () {
- var extendStatics = function (d, b) {
- extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
- return extendStatics(d, b);
- };
- return function (d, b) {
- if (typeof b !== "function" && b !== null)
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.FixedBytesCoder = void 0;
- var bytes_1 = _dereq_("@ethersproject/bytes");
- var abstract_coder_1 = _dereq_("./abstract-coder");
- // @TODO: Merge this with bytes
- var FixedBytesCoder = /** @class */ (function (_super) {
- __extends(FixedBytesCoder, _super);
- function FixedBytesCoder(size, localName) {
- var _this = this;
- var name = "bytes" + String(size);
- _this = _super.call(this, name, name, localName, false) || this;
- _this.size = size;
- return _this;
- }
- FixedBytesCoder.prototype.defaultValue = function () {
- return ("0x0000000000000000000000000000000000000000000000000000000000000000").substring(0, 2 + this.size * 2);
- };
- FixedBytesCoder.prototype.encode = function (writer, value) {
- var data = (0, bytes_1.arrayify)(value);
- if (data.length !== this.size) {
- this._throwError("incorrect data length", value);
- }
- return writer.writeBytes(data);
- };
- FixedBytesCoder.prototype.decode = function (reader) {
- return reader.coerce(this.name, (0, bytes_1.hexlify)(reader.readBytes(this.size)));
- };
- return FixedBytesCoder;
- }(abstract_coder_1.Coder));
- exports.FixedBytesCoder = FixedBytesCoder;
- },{"./abstract-coder":170,"@ethersproject/bytes":199}],177:[function(_dereq_,module,exports){
- "use strict";
- var __extends = (this && this.__extends) || (function () {
- var extendStatics = function (d, b) {
- extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
- return extendStatics(d, b);
- };
- return function (d, b) {
- if (typeof b !== "function" && b !== null)
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.NullCoder = void 0;
- var abstract_coder_1 = _dereq_("./abstract-coder");
- var NullCoder = /** @class */ (function (_super) {
- __extends(NullCoder, _super);
- function NullCoder(localName) {
- return _super.call(this, "null", "", localName, false) || this;
- }
- NullCoder.prototype.defaultValue = function () {
- return null;
- };
- NullCoder.prototype.encode = function (writer, value) {
- if (value != null) {
- this._throwError("not null", value);
- }
- return writer.writeBytes([]);
- };
- NullCoder.prototype.decode = function (reader) {
- reader.readBytes(0);
- return reader.coerce(this.name, null);
- };
- return NullCoder;
- }(abstract_coder_1.Coder));
- exports.NullCoder = NullCoder;
- },{"./abstract-coder":170}],178:[function(_dereq_,module,exports){
- "use strict";
- var __extends = (this && this.__extends) || (function () {
- var extendStatics = function (d, b) {
- extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
- return extendStatics(d, b);
- };
- return function (d, b) {
- if (typeof b !== "function" && b !== null)
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.NumberCoder = void 0;
- var bignumber_1 = _dereq_("@ethersproject/bignumber");
- var constants_1 = _dereq_("@ethersproject/constants");
- var abstract_coder_1 = _dereq_("./abstract-coder");
- var NumberCoder = /** @class */ (function (_super) {
- __extends(NumberCoder, _super);
- function NumberCoder(size, signed, localName) {
- var _this = this;
- var name = ((signed ? "int" : "uint") + (size * 8));
- _this = _super.call(this, name, name, localName, false) || this;
- _this.size = size;
- _this.signed = signed;
- return _this;
- }
- NumberCoder.prototype.defaultValue = function () {
- return 0;
- };
- NumberCoder.prototype.encode = function (writer, value) {
- var v = bignumber_1.BigNumber.from(value);
- // Check bounds are safe for encoding
- var maxUintValue = constants_1.MaxUint256.mask(writer.wordSize * 8);
- if (this.signed) {
- var bounds = maxUintValue.mask(this.size * 8 - 1);
- if (v.gt(bounds) || v.lt(bounds.add(constants_1.One).mul(constants_1.NegativeOne))) {
- this._throwError("value out-of-bounds", value);
- }
- }
- else if (v.lt(constants_1.Zero) || v.gt(maxUintValue.mask(this.size * 8))) {
- this._throwError("value out-of-bounds", value);
- }
- v = v.toTwos(this.size * 8).mask(this.size * 8);
- if (this.signed) {
- v = v.fromTwos(this.size * 8).toTwos(8 * writer.wordSize);
- }
- return writer.writeValue(v);
- };
- NumberCoder.prototype.decode = function (reader) {
- var value = reader.readValue().mask(this.size * 8);
- if (this.signed) {
- value = value.fromTwos(this.size * 8);
- }
- return reader.coerce(this.name, value);
- };
- return NumberCoder;
- }(abstract_coder_1.Coder));
- exports.NumberCoder = NumberCoder;
- },{"./abstract-coder":170,"@ethersproject/bignumber":196,"@ethersproject/constants":203}],179:[function(_dereq_,module,exports){
- "use strict";
- var __extends = (this && this.__extends) || (function () {
- var extendStatics = function (d, b) {
- extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
- return extendStatics(d, b);
- };
- return function (d, b) {
- if (typeof b !== "function" && b !== null)
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.StringCoder = void 0;
- var strings_1 = _dereq_("@ethersproject/strings");
- var bytes_1 = _dereq_("./bytes");
- var StringCoder = /** @class */ (function (_super) {
- __extends(StringCoder, _super);
- function StringCoder(localName) {
- return _super.call(this, "string", localName) || this;
- }
- StringCoder.prototype.defaultValue = function () {
- return "";
- };
- StringCoder.prototype.encode = function (writer, value) {
- return _super.prototype.encode.call(this, writer, (0, strings_1.toUtf8Bytes)(value));
- };
- StringCoder.prototype.decode = function (reader) {
- return (0, strings_1.toUtf8String)(_super.prototype.decode.call(this, reader));
- };
- return StringCoder;
- }(bytes_1.DynamicBytesCoder));
- exports.StringCoder = StringCoder;
- },{"./bytes":175,"@ethersproject/strings":266}],180:[function(_dereq_,module,exports){
- "use strict";
- var __extends = (this && this.__extends) || (function () {
- var extendStatics = function (d, b) {
- extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
- return extendStatics(d, b);
- };
- return function (d, b) {
- if (typeof b !== "function" && b !== null)
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.TupleCoder = void 0;
- var abstract_coder_1 = _dereq_("./abstract-coder");
- var array_1 = _dereq_("./array");
- var TupleCoder = /** @class */ (function (_super) {
- __extends(TupleCoder, _super);
- function TupleCoder(coders, localName) {
- var _this = this;
- var dynamic = false;
- var types = [];
- coders.forEach(function (coder) {
- if (coder.dynamic) {
- dynamic = true;
- }
- types.push(coder.type);
- });
- var type = ("tuple(" + types.join(",") + ")");
- _this = _super.call(this, "tuple", type, localName, dynamic) || this;
- _this.coders = coders;
- return _this;
- }
- TupleCoder.prototype.defaultValue = function () {
- var values = [];
- this.coders.forEach(function (coder) {
- values.push(coder.defaultValue());
- });
- // We only output named properties for uniquely named coders
- var uniqueNames = this.coders.reduce(function (accum, coder) {
- var name = coder.localName;
- if (name) {
- if (!accum[name]) {
- accum[name] = 0;
- }
- accum[name]++;
- }
- return accum;
- }, {});
- // Add named values
- this.coders.forEach(function (coder, index) {
- var name = coder.localName;
- if (!name || uniqueNames[name] !== 1) {
- return;
- }
- if (name === "length") {
- name = "_length";
- }
- if (values[name] != null) {
- return;
- }
- values[name] = values[index];
- });
- return Object.freeze(values);
- };
- TupleCoder.prototype.encode = function (writer, value) {
- return (0, array_1.pack)(writer, this.coders, value);
- };
- TupleCoder.prototype.decode = function (reader) {
- return reader.coerce(this.name, (0, array_1.unpack)(reader, this.coders));
- };
- return TupleCoder;
- }(abstract_coder_1.Coder));
- exports.TupleCoder = TupleCoder;
- },{"./abstract-coder":170,"./array":173}],181:[function(_dereq_,module,exports){
- "use strict";
- var __extends = (this && this.__extends) || (function () {
- var extendStatics = function (d, b) {
- extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
- return extendStatics(d, b);
- };
- return function (d, b) {
- if (typeof b !== "function" && b !== null)
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.ErrorFragment = exports.FunctionFragment = exports.ConstructorFragment = exports.EventFragment = exports.Fragment = exports.ParamType = exports.FormatTypes = void 0;
- var bignumber_1 = _dereq_("@ethersproject/bignumber");
- var properties_1 = _dereq_("@ethersproject/properties");
- var logger_1 = _dereq_("@ethersproject/logger");
- var _version_1 = _dereq_("./_version");
- var logger = new logger_1.Logger(_version_1.version);
- ;
- var _constructorGuard = {};
- var ModifiersBytes = { calldata: true, memory: true, storage: true };
- var ModifiersNest = { calldata: true, memory: true };
- function checkModifier(type, name) {
- if (type === "bytes" || type === "string") {
- if (ModifiersBytes[name]) {
- return true;
- }
- }
- else if (type === "address") {
- if (name === "payable") {
- return true;
- }
- }
- else if (type.indexOf("[") >= 0 || type === "tuple") {
- if (ModifiersNest[name]) {
- return true;
- }
- }
- if (ModifiersBytes[name] || name === "payable") {
- logger.throwArgumentError("invalid modifier", "name", name);
- }
- return false;
- }
- // @TODO: Make sure that children of an indexed tuple are marked with a null indexed
- function parseParamType(param, allowIndexed) {
- var originalParam = param;
- function throwError(i) {
- logger.throwArgumentError("unexpected character at position " + i, "param", param);
- }
- param = param.replace(/\s/g, " ");
- function newNode(parent) {
- var node = { type: "", name: "", parent: parent, state: { allowType: true } };
- if (allowIndexed) {
- node.indexed = false;
- }
- return node;
- }
- var parent = { type: "", name: "", state: { allowType: true } };
- var node = parent;
- for (var i = 0; i < param.length; i++) {
- var c = param[i];
- switch (c) {
- case "(":
- if (node.state.allowType && node.type === "") {
- node.type = "tuple";
- }
- else if (!node.state.allowParams) {
- throwError(i);
- }
- node.state.allowType = false;
- node.type = verifyType(node.type);
- node.components = [newNode(node)];
- node = node.components[0];
- break;
- case ")":
- delete node.state;
- if (node.name === "indexed") {
- if (!allowIndexed) {
- throwError(i);
- }
- node.indexed = true;
- node.name = "";
- }
- if (checkModifier(node.type, node.name)) {
- node.name = "";
- }
- node.type = verifyType(node.type);
- var child = node;
- node = node.parent;
- if (!node) {
- throwError(i);
- }
- delete child.parent;
- node.state.allowParams = false;
- node.state.allowName = true;
- node.state.allowArray = true;
- break;
- case ",":
- delete node.state;
- if (node.name === "indexed") {
- if (!allowIndexed) {
- throwError(i);
- }
- node.indexed = true;
- node.name = "";
- }
- if (checkModifier(node.type, node.name)) {
- node.name = "";
- }
- node.type = verifyType(node.type);
- var sibling = newNode(node.parent);
- //{ type: "", name: "", parent: node.parent, state: { allowType: true } };
- node.parent.components.push(sibling);
- delete node.parent;
- node = sibling;
- break;
- // Hit a space...
- case " ":
- // If reading type, the type is done and may read a param or name
- if (node.state.allowType) {
- if (node.type !== "") {
- node.type = verifyType(node.type);
- delete node.state.allowType;
- node.state.allowName = true;
- node.state.allowParams = true;
- }
- }
- // If reading name, the name is done
- if (node.state.allowName) {
- if (node.name !== "") {
- if (node.name === "indexed") {
- if (!allowIndexed) {
- throwError(i);
- }
- if (node.indexed) {
- throwError(i);
- }
- node.indexed = true;
- node.name = "";
- }
- else if (checkModifier(node.type, node.name)) {
- node.name = "";
- }
- else {
- node.state.allowName = false;
- }
- }
- }
- break;
- case "[":
- if (!node.state.allowArray) {
- throwError(i);
- }
- node.type += c;
- node.state.allowArray = false;
- node.state.allowName = false;
- node.state.readArray = true;
- break;
- case "]":
- if (!node.state.readArray) {
- throwError(i);
- }
- node.type += c;
- node.state.readArray = false;
- node.state.allowArray = true;
- node.state.allowName = true;
- break;
- default:
- if (node.state.allowType) {
- node.type += c;
- node.state.allowParams = true;
- node.state.allowArray = true;
- }
- else if (node.state.allowName) {
- node.name += c;
- delete node.state.allowArray;
- }
- else if (node.state.readArray) {
- node.type += c;
- }
- else {
- throwError(i);
- }
- }
- }
- if (node.parent) {
- logger.throwArgumentError("unexpected eof", "param", param);
- }
- delete parent.state;
- if (node.name === "indexed") {
- if (!allowIndexed) {
- throwError(originalParam.length - 7);
- }
- if (node.indexed) {
- throwError(originalParam.length - 7);
- }
- node.indexed = true;
- node.name = "";
- }
- else if (checkModifier(node.type, node.name)) {
- node.name = "";
- }
- parent.type = verifyType(parent.type);
- return parent;
- }
- function populate(object, params) {
- for (var key in params) {
- (0, properties_1.defineReadOnly)(object, key, params[key]);
- }
- }
- exports.FormatTypes = Object.freeze({
- // Bare formatting, as is needed for computing a sighash of an event or function
- sighash: "sighash",
- // Human-Readable with Minimal spacing and without names (compact human-readable)
- minimal: "minimal",
- // Human-Readable with nice spacing, including all names
- full: "full",
- // JSON-format a la Solidity
- json: "json"
- });
- var paramTypeArray = new RegExp(/^(.*)\[([0-9]*)\]$/);
- var ParamType = /** @class */ (function () {
- function ParamType(constructorGuard, params) {
- if (constructorGuard !== _constructorGuard) {
- logger.throwError("use fromString", logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
- operation: "new ParamType()"
- });
- }
- populate(this, params);
- var match = this.type.match(paramTypeArray);
- if (match) {
- populate(this, {
- arrayLength: parseInt(match[2] || "-1"),
- arrayChildren: ParamType.fromObject({
- type: match[1],
- components: this.components
- }),
- baseType: "array"
- });
- }
- else {
- populate(this, {
- arrayLength: null,
- arrayChildren: null,
- baseType: ((this.components != null) ? "tuple" : this.type)
- });
- }
- this._isParamType = true;
- Object.freeze(this);
- }
- // Format the parameter fragment
- // - sighash: "(uint256,address)"
- // - minimal: "tuple(uint256,address) indexed"
- // - full: "tuple(uint256 foo, address bar) indexed baz"
- ParamType.prototype.format = function (format) {
- if (!format) {
- format = exports.FormatTypes.sighash;
- }
- if (!exports.FormatTypes[format]) {
- logger.throwArgumentError("invalid format type", "format", format);
- }
- if (format === exports.FormatTypes.json) {
- var result_1 = {
- type: ((this.baseType === "tuple") ? "tuple" : this.type),
- name: (this.name || undefined)
- };
- if (typeof (this.indexed) === "boolean") {
- result_1.indexed = this.indexed;
- }
- if (this.components) {
- result_1.components = this.components.map(function (comp) { return JSON.parse(comp.format(format)); });
- }
- return JSON.stringify(result_1);
- }
- var result = "";
- // Array
- if (this.baseType === "array") {
- result += this.arrayChildren.format(format);
- result += "[" + (this.arrayLength < 0 ? "" : String(this.arrayLength)) + "]";
- }
- else {
- if (this.baseType === "tuple") {
- if (format !== exports.FormatTypes.sighash) {
- result += this.type;
- }
- result += "(" + this.components.map(function (comp) { return comp.format(format); }).join((format === exports.FormatTypes.full) ? ", " : ",") + ")";
- }
- else {
- result += this.type;
- }
- }
- if (format !== exports.FormatTypes.sighash) {
- if (this.indexed === true) {
- result += " indexed";
- }
- if (format === exports.FormatTypes.full && this.name) {
- result += " " + this.name;
- }
- }
- return result;
- };
- ParamType.from = function (value, allowIndexed) {
- if (typeof (value) === "string") {
- return ParamType.fromString(value, allowIndexed);
- }
- return ParamType.fromObject(value);
- };
- ParamType.fromObject = function (value) {
- if (ParamType.isParamType(value)) {
- return value;
- }
- return new ParamType(_constructorGuard, {
- name: (value.name || null),
- type: verifyType(value.type),
- indexed: ((value.indexed == null) ? null : !!value.indexed),
- components: (value.components ? value.components.map(ParamType.fromObject) : null)
- });
- };
- ParamType.fromString = function (value, allowIndexed) {
- function ParamTypify(node) {
- return ParamType.fromObject({
- name: node.name,
- type: node.type,
- indexed: node.indexed,
- components: node.components
- });
- }
- return ParamTypify(parseParamType(value, !!allowIndexed));
- };
- ParamType.isParamType = function (value) {
- return !!(value != null && value._isParamType);
- };
- return ParamType;
- }());
- exports.ParamType = ParamType;
- ;
- function parseParams(value, allowIndex) {
- return splitNesting(value).map(function (param) { return ParamType.fromString(param, allowIndex); });
- }
- var Fragment = /** @class */ (function () {
- function Fragment(constructorGuard, params) {
- if (constructorGuard !== _constructorGuard) {
- logger.throwError("use a static from method", logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
- operation: "new Fragment()"
- });
- }
- populate(this, params);
- this._isFragment = true;
- Object.freeze(this);
- }
- Fragment.from = function (value) {
- if (Fragment.isFragment(value)) {
- return value;
- }
- if (typeof (value) === "string") {
- return Fragment.fromString(value);
- }
- return Fragment.fromObject(value);
- };
- Fragment.fromObject = function (value) {
- if (Fragment.isFragment(value)) {
- return value;
- }
- switch (value.type) {
- case "function":
- return FunctionFragment.fromObject(value);
- case "event":
- return EventFragment.fromObject(value);
- case "constructor":
- return ConstructorFragment.fromObject(value);
- case "error":
- return ErrorFragment.fromObject(value);
- case "fallback":
- case "receive":
- // @TODO: Something? Maybe return a FunctionFragment? A custom DefaultFunctionFragment?
- return null;
- }
- return logger.throwArgumentError("invalid fragment object", "value", value);
- };
- Fragment.fromString = function (value) {
- // Make sure the "returns" is surrounded by a space and all whitespace is exactly one space
- value = value.replace(/\s/g, " ");
- value = value.replace(/\(/g, " (").replace(/\)/g, ") ").replace(/\s+/g, " ");
- value = value.trim();
- if (value.split(" ")[0] === "event") {
- return EventFragment.fromString(value.substring(5).trim());
- }
- else if (value.split(" ")[0] === "function") {
- return FunctionFragment.fromString(value.substring(8).trim());
- }
- else if (value.split("(")[0].trim() === "constructor") {
- return ConstructorFragment.fromString(value.trim());
- }
- else if (value.split(" ")[0] === "error") {
- return ErrorFragment.fromString(value.substring(5).trim());
- }
- return logger.throwArgumentError("unsupported fragment", "value", value);
- };
- Fragment.isFragment = function (value) {
- return !!(value && value._isFragment);
- };
- return Fragment;
- }());
- exports.Fragment = Fragment;
- var EventFragment = /** @class */ (function (_super) {
- __extends(EventFragment, _super);
- function EventFragment() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- EventFragment.prototype.format = function (format) {
- if (!format) {
- format = exports.FormatTypes.sighash;
- }
- if (!exports.FormatTypes[format]) {
- logger.throwArgumentError("invalid format type", "format", format);
- }
- if (format === exports.FormatTypes.json) {
- return JSON.stringify({
- type: "event",
- anonymous: this.anonymous,
- name: this.name,
- inputs: this.inputs.map(function (input) { return JSON.parse(input.format(format)); })
- });
- }
- var result = "";
- if (format !== exports.FormatTypes.sighash) {
- result += "event ";
- }
- result += this.name + "(" + this.inputs.map(function (input) { return input.format(format); }).join((format === exports.FormatTypes.full) ? ", " : ",") + ") ";
- if (format !== exports.FormatTypes.sighash) {
- if (this.anonymous) {
- result += "anonymous ";
- }
- }
- return result.trim();
- };
- EventFragment.from = function (value) {
- if (typeof (value) === "string") {
- return EventFragment.fromString(value);
- }
- return EventFragment.fromObject(value);
- };
- EventFragment.fromObject = function (value) {
- if (EventFragment.isEventFragment(value)) {
- return value;
- }
- if (value.type !== "event") {
- logger.throwArgumentError("invalid event object", "value", value);
- }
- var params = {
- name: verifyIdentifier(value.name),
- anonymous: value.anonymous,
- inputs: (value.inputs ? value.inputs.map(ParamType.fromObject) : []),
- type: "event"
- };
- return new EventFragment(_constructorGuard, params);
- };
- EventFragment.fromString = function (value) {
- var match = value.match(regexParen);
- if (!match) {
- logger.throwArgumentError("invalid event string", "value", value);
- }
- var anonymous = false;
- match[3].split(" ").forEach(function (modifier) {
- switch (modifier.trim()) {
- case "anonymous":
- anonymous = true;
- break;
- case "":
- break;
- default:
- logger.warn("unknown modifier: " + modifier);
- }
- });
- return EventFragment.fromObject({
- name: match[1].trim(),
- anonymous: anonymous,
- inputs: parseParams(match[2], true),
- type: "event"
- });
- };
- EventFragment.isEventFragment = function (value) {
- return (value && value._isFragment && value.type === "event");
- };
- return EventFragment;
- }(Fragment));
- exports.EventFragment = EventFragment;
- function parseGas(value, params) {
- params.gas = null;
- var comps = value.split("@");
- if (comps.length !== 1) {
- if (comps.length > 2) {
- logger.throwArgumentError("invalid human-readable ABI signature", "value", value);
- }
- if (!comps[1].match(/^[0-9]+$/)) {
- logger.throwArgumentError("invalid human-readable ABI signature gas", "value", value);
- }
- params.gas = bignumber_1.BigNumber.from(comps[1]);
- return comps[0];
- }
- return value;
- }
- function parseModifiers(value, params) {
- params.constant = false;
- params.payable = false;
- params.stateMutability = "nonpayable";
- value.split(" ").forEach(function (modifier) {
- switch (modifier.trim()) {
- case "constant":
- params.constant = true;
- break;
- case "payable":
- params.payable = true;
- params.stateMutability = "payable";
- break;
- case "nonpayable":
- params.payable = false;
- params.stateMutability = "nonpayable";
- break;
- case "pure":
- params.constant = true;
- params.stateMutability = "pure";
- break;
- case "view":
- params.constant = true;
- params.stateMutability = "view";
- break;
- case "external":
- case "public":
- case "":
- break;
- default:
- console.log("unknown modifier: " + modifier);
- }
- });
- }
- function verifyState(value) {
- var result = {
- constant: false,
- payable: true,
- stateMutability: "payable"
- };
- if (value.stateMutability != null) {
- result.stateMutability = value.stateMutability;
- // Set (and check things are consistent) the constant property
- result.constant = (result.stateMutability === "view" || result.stateMutability === "pure");
- if (value.constant != null) {
- if ((!!value.constant) !== result.constant) {
- logger.throwArgumentError("cannot have constant function with mutability " + result.stateMutability, "value", value);
- }
- }
- // Set (and check things are consistent) the payable property
- result.payable = (result.stateMutability === "payable");
- if (value.payable != null) {
- if ((!!value.payable) !== result.payable) {
- logger.throwArgumentError("cannot have payable function with mutability " + result.stateMutability, "value", value);
- }
- }
- }
- else if (value.payable != null) {
- result.payable = !!value.payable;
- // If payable we can assume non-constant; otherwise we can't assume
- if (value.constant == null && !result.payable && value.type !== "constructor") {
- logger.throwArgumentError("unable to determine stateMutability", "value", value);
- }
- result.constant = !!value.constant;
- if (result.constant) {
- result.stateMutability = "view";
- }
- else {
- result.stateMutability = (result.payable ? "payable" : "nonpayable");
- }
- if (result.payable && result.constant) {
- logger.throwArgumentError("cannot have constant payable function", "value", value);
- }
- }
- else if (value.constant != null) {
- result.constant = !!value.constant;
- result.payable = !result.constant;
- result.stateMutability = (result.constant ? "view" : "payable");
- }
- else if (value.type !== "constructor") {
- logger.throwArgumentError("unable to determine stateMutability", "value", value);
- }
- return result;
- }
- var ConstructorFragment = /** @class */ (function (_super) {
- __extends(ConstructorFragment, _super);
- function ConstructorFragment() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- ConstructorFragment.prototype.format = function (format) {
- if (!format) {
- format = exports.FormatTypes.sighash;
- }
- if (!exports.FormatTypes[format]) {
- logger.throwArgumentError("invalid format type", "format", format);
- }
- if (format === exports.FormatTypes.json) {
- return JSON.stringify({
- type: "constructor",
- stateMutability: ((this.stateMutability !== "nonpayable") ? this.stateMutability : undefined),
- payable: this.payable,
- gas: (this.gas ? this.gas.toNumber() : undefined),
- inputs: this.inputs.map(function (input) { return JSON.parse(input.format(format)); })
- });
- }
- if (format === exports.FormatTypes.sighash) {
- logger.throwError("cannot format a constructor for sighash", logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
- operation: "format(sighash)"
- });
- }
- var result = "constructor(" + this.inputs.map(function (input) { return input.format(format); }).join((format === exports.FormatTypes.full) ? ", " : ",") + ") ";
- if (this.stateMutability && this.stateMutability !== "nonpayable") {
- result += this.stateMutability + " ";
- }
- return result.trim();
- };
- ConstructorFragment.from = function (value) {
- if (typeof (value) === "string") {
- return ConstructorFragment.fromString(value);
- }
- return ConstructorFragment.fromObject(value);
- };
- ConstructorFragment.fromObject = function (value) {
- if (ConstructorFragment.isConstructorFragment(value)) {
- return value;
- }
- if (value.type !== "constructor") {
- logger.throwArgumentError("invalid constructor object", "value", value);
- }
- var state = verifyState(value);
- if (state.constant) {
- logger.throwArgumentError("constructor cannot be constant", "value", value);
- }
- var params = {
- name: null,
- type: value.type,
- inputs: (value.inputs ? value.inputs.map(ParamType.fromObject) : []),
- payable: state.payable,
- stateMutability: state.stateMutability,
- gas: (value.gas ? bignumber_1.BigNumber.from(value.gas) : null)
- };
- return new ConstructorFragment(_constructorGuard, params);
- };
- ConstructorFragment.fromString = function (value) {
- var params = { type: "constructor" };
- value = parseGas(value, params);
- var parens = value.match(regexParen);
- if (!parens || parens[1].trim() !== "constructor") {
- logger.throwArgumentError("invalid constructor string", "value", value);
- }
- params.inputs = parseParams(parens[2].trim(), false);
- parseModifiers(parens[3].trim(), params);
- return ConstructorFragment.fromObject(params);
- };
- ConstructorFragment.isConstructorFragment = function (value) {
- return (value && value._isFragment && value.type === "constructor");
- };
- return ConstructorFragment;
- }(Fragment));
- exports.ConstructorFragment = ConstructorFragment;
- var FunctionFragment = /** @class */ (function (_super) {
- __extends(FunctionFragment, _super);
- function FunctionFragment() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- FunctionFragment.prototype.format = function (format) {
- if (!format) {
- format = exports.FormatTypes.sighash;
- }
- if (!exports.FormatTypes[format]) {
- logger.throwArgumentError("invalid format type", "format", format);
- }
- if (format === exports.FormatTypes.json) {
- return JSON.stringify({
- type: "function",
- name: this.name,
- constant: this.constant,
- stateMutability: ((this.stateMutability !== "nonpayable") ? this.stateMutability : undefined),
- payable: this.payable,
- gas: (this.gas ? this.gas.toNumber() : undefined),
- inputs: this.inputs.map(function (input) { return JSON.parse(input.format(format)); }),
- outputs: this.outputs.map(function (output) { return JSON.parse(output.format(format)); }),
- });
- }
- var result = "";
- if (format !== exports.FormatTypes.sighash) {
- result += "function ";
- }
- result += this.name + "(" + this.inputs.map(function (input) { return input.format(format); }).join((format === exports.FormatTypes.full) ? ", " : ",") + ") ";
- if (format !== exports.FormatTypes.sighash) {
- if (this.stateMutability) {
- if (this.stateMutability !== "nonpayable") {
- result += (this.stateMutability + " ");
- }
- }
- else if (this.constant) {
- result += "view ";
- }
- if (this.outputs && this.outputs.length) {
- result += "returns (" + this.outputs.map(function (output) { return output.format(format); }).join(", ") + ") ";
- }
- if (this.gas != null) {
- result += "@" + this.gas.toString() + " ";
- }
- }
- return result.trim();
- };
- FunctionFragment.from = function (value) {
- if (typeof (value) === "string") {
- return FunctionFragment.fromString(value);
- }
- return FunctionFragment.fromObject(value);
- };
- FunctionFragment.fromObject = function (value) {
- if (FunctionFragment.isFunctionFragment(value)) {
- return value;
- }
- if (value.type !== "function") {
- logger.throwArgumentError("invalid function object", "value", value);
- }
- var state = verifyState(value);
- var params = {
- type: value.type,
- name: verifyIdentifier(value.name),
- constant: state.constant,
- inputs: (value.inputs ? value.inputs.map(ParamType.fromObject) : []),
- outputs: (value.outputs ? value.outputs.map(ParamType.fromObject) : []),
- payable: state.payable,
- stateMutability: state.stateMutability,
- gas: (value.gas ? bignumber_1.BigNumber.from(value.gas) : null)
- };
- return new FunctionFragment(_constructorGuard, params);
- };
- FunctionFragment.fromString = function (value) {
- var params = { type: "function" };
- value = parseGas(value, params);
- var comps = value.split(" returns ");
- if (comps.length > 2) {
- logger.throwArgumentError("invalid function string", "value", value);
- }
- var parens = comps[0].match(regexParen);
- if (!parens) {
- logger.throwArgumentError("invalid function signature", "value", value);
- }
- params.name = parens[1].trim();
- if (params.name) {
- verifyIdentifier(params.name);
- }
- params.inputs = parseParams(parens[2], false);
- parseModifiers(parens[3].trim(), params);
- // We have outputs
- if (comps.length > 1) {
- var returns = comps[1].match(regexParen);
- if (returns[1].trim() != "" || returns[3].trim() != "") {
- logger.throwArgumentError("unexpected tokens", "value", value);
- }
- params.outputs = parseParams(returns[2], false);
- }
- else {
- params.outputs = [];
- }
- return FunctionFragment.fromObject(params);
- };
- FunctionFragment.isFunctionFragment = function (value) {
- return (value && value._isFragment && value.type === "function");
- };
- return FunctionFragment;
- }(ConstructorFragment));
- exports.FunctionFragment = FunctionFragment;
- //export class StructFragment extends Fragment {
- //}
- function checkForbidden(fragment) {
- var sig = fragment.format();
- if (sig === "Error(string)" || sig === "Panic(uint256)") {
- logger.throwArgumentError("cannot specify user defined " + sig + " error", "fragment", fragment);
- }
- return fragment;
- }
- var ErrorFragment = /** @class */ (function (_super) {
- __extends(ErrorFragment, _super);
- function ErrorFragment() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- ErrorFragment.prototype.format = function (format) {
- if (!format) {
- format = exports.FormatTypes.sighash;
- }
- if (!exports.FormatTypes[format]) {
- logger.throwArgumentError("invalid format type", "format", format);
- }
- if (format === exports.FormatTypes.json) {
- return JSON.stringify({
- type: "error",
- name: this.name,
- inputs: this.inputs.map(function (input) { return JSON.parse(input.format(format)); }),
- });
- }
- var result = "";
- if (format !== exports.FormatTypes.sighash) {
- result += "error ";
- }
- result += this.name + "(" + this.inputs.map(function (input) { return input.format(format); }).join((format === exports.FormatTypes.full) ? ", " : ",") + ") ";
- return result.trim();
- };
- ErrorFragment.from = function (value) {
- if (typeof (value) === "string") {
- return ErrorFragment.fromString(value);
- }
- return ErrorFragment.fromObject(value);
- };
- ErrorFragment.fromObject = function (value) {
- if (ErrorFragment.isErrorFragment(value)) {
- return value;
- }
- if (value.type !== "error") {
- logger.throwArgumentError("invalid error object", "value", value);
- }
- var params = {
- type: value.type,
- name: verifyIdentifier(value.name),
- inputs: (value.inputs ? value.inputs.map(ParamType.fromObject) : [])
- };
- return checkForbidden(new ErrorFragment(_constructorGuard, params));
- };
- ErrorFragment.fromString = function (value) {
- var params = { type: "error" };
- var parens = value.match(regexParen);
- if (!parens) {
- logger.throwArgumentError("invalid error signature", "value", value);
- }
- params.name = parens[1].trim();
- if (params.name) {
- verifyIdentifier(params.name);
- }
- params.inputs = parseParams(parens[2], false);
- return checkForbidden(ErrorFragment.fromObject(params));
- };
- ErrorFragment.isErrorFragment = function (value) {
- return (value && value._isFragment && value.type === "error");
- };
- return ErrorFragment;
- }(Fragment));
- exports.ErrorFragment = ErrorFragment;
- function verifyType(type) {
- // These need to be transformed to their full description
- if (type.match(/^uint($|[^1-9])/)) {
- type = "uint256" + type.substring(4);
- }
- else if (type.match(/^int($|[^1-9])/)) {
- type = "int256" + type.substring(3);
- }
- // @TODO: more verification
- return type;
- }
- // See: https://github.com/ethereum/solidity/blob/1f8f1a3db93a548d0555e3e14cfc55a10e25b60e/docs/grammar/SolidityLexer.g4#L234
- var regexIdentifier = new RegExp("^[a-zA-Z$_][a-zA-Z0-9$_]*$");
- function verifyIdentifier(value) {
- if (!value || !value.match(regexIdentifier)) {
- logger.throwArgumentError("invalid identifier \"" + value + "\"", "value", value);
- }
- return value;
- }
- var regexParen = new RegExp("^([^)(]*)\\((.*)\\)([^)(]*)$");
- function splitNesting(value) {
- value = value.trim();
- var result = [];
- var accum = "";
- var depth = 0;
- for (var offset = 0; offset < value.length; offset++) {
- var c = value[offset];
- if (c === "," && depth === 0) {
- result.push(accum);
- accum = "";
- }
- else {
- accum += c;
- if (c === "(") {
- depth++;
- }
- else if (c === ")") {
- depth--;
- if (depth === -1) {
- logger.throwArgumentError("unbalanced parenthesis", "value", value);
- }
- }
- }
- }
- if (accum) {
- result.push(accum);
- }
- return result;
- }
- },{"./_version":168,"@ethersproject/bignumber":196,"@ethersproject/logger":223,"@ethersproject/properties":229}],182:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.TransactionDescription = exports.LogDescription = exports.checkResultErrors = exports.Indexed = exports.Interface = exports.defaultAbiCoder = exports.AbiCoder = exports.FormatTypes = exports.ParamType = exports.FunctionFragment = exports.Fragment = exports.EventFragment = exports.ErrorFragment = exports.ConstructorFragment = void 0;
- var fragments_1 = _dereq_("./fragments");
- Object.defineProperty(exports, "ConstructorFragment", { enumerable: true, get: function () { return fragments_1.ConstructorFragment; } });
- Object.defineProperty(exports, "ErrorFragment", { enumerable: true, get: function () { return fragments_1.ErrorFragment; } });
- Object.defineProperty(exports, "EventFragment", { enumerable: true, get: function () { return fragments_1.EventFragment; } });
- Object.defineProperty(exports, "FormatTypes", { enumerable: true, get: function () { return fragments_1.FormatTypes; } });
- Object.defineProperty(exports, "Fragment", { enumerable: true, get: function () { return fragments_1.Fragment; } });
- Object.defineProperty(exports, "FunctionFragment", { enumerable: true, get: function () { return fragments_1.FunctionFragment; } });
- Object.defineProperty(exports, "ParamType", { enumerable: true, get: function () { return fragments_1.ParamType; } });
- var abi_coder_1 = _dereq_("./abi-coder");
- Object.defineProperty(exports, "AbiCoder", { enumerable: true, get: function () { return abi_coder_1.AbiCoder; } });
- Object.defineProperty(exports, "defaultAbiCoder", { enumerable: true, get: function () { return abi_coder_1.defaultAbiCoder; } });
- var interface_1 = _dereq_("./interface");
- Object.defineProperty(exports, "checkResultErrors", { enumerable: true, get: function () { return interface_1.checkResultErrors; } });
- Object.defineProperty(exports, "Indexed", { enumerable: true, get: function () { return interface_1.Indexed; } });
- Object.defineProperty(exports, "Interface", { enumerable: true, get: function () { return interface_1.Interface; } });
- Object.defineProperty(exports, "LogDescription", { enumerable: true, get: function () { return interface_1.LogDescription; } });
- Object.defineProperty(exports, "TransactionDescription", { enumerable: true, get: function () { return interface_1.TransactionDescription; } });
- },{"./abi-coder":169,"./fragments":181,"./interface":183}],183:[function(_dereq_,module,exports){
- "use strict";
- var __extends = (this && this.__extends) || (function () {
- var extendStatics = function (d, b) {
- extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
- return extendStatics(d, b);
- };
- return function (d, b) {
- if (typeof b !== "function" && b !== null)
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.Interface = exports.Indexed = exports.ErrorDescription = exports.TransactionDescription = exports.LogDescription = exports.checkResultErrors = void 0;
- var address_1 = _dereq_("@ethersproject/address");
- var bignumber_1 = _dereq_("@ethersproject/bignumber");
- var bytes_1 = _dereq_("@ethersproject/bytes");
- var hash_1 = _dereq_("@ethersproject/hash");
- var keccak256_1 = _dereq_("@ethersproject/keccak256");
- var properties_1 = _dereq_("@ethersproject/properties");
- var abi_coder_1 = _dereq_("./abi-coder");
- var abstract_coder_1 = _dereq_("./coders/abstract-coder");
- Object.defineProperty(exports, "checkResultErrors", { enumerable: true, get: function () { return abstract_coder_1.checkResultErrors; } });
- var fragments_1 = _dereq_("./fragments");
- var logger_1 = _dereq_("@ethersproject/logger");
- var _version_1 = _dereq_("./_version");
- var logger = new logger_1.Logger(_version_1.version);
- var LogDescription = /** @class */ (function (_super) {
- __extends(LogDescription, _super);
- function LogDescription() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- return LogDescription;
- }(properties_1.Description));
- exports.LogDescription = LogDescription;
- var TransactionDescription = /** @class */ (function (_super) {
- __extends(TransactionDescription, _super);
- function TransactionDescription() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- return TransactionDescription;
- }(properties_1.Description));
- exports.TransactionDescription = TransactionDescription;
- var ErrorDescription = /** @class */ (function (_super) {
- __extends(ErrorDescription, _super);
- function ErrorDescription() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- return ErrorDescription;
- }(properties_1.Description));
- exports.ErrorDescription = ErrorDescription;
- var Indexed = /** @class */ (function (_super) {
- __extends(Indexed, _super);
- function Indexed() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- Indexed.isIndexed = function (value) {
- return !!(value && value._isIndexed);
- };
- return Indexed;
- }(properties_1.Description));
- exports.Indexed = Indexed;
- var BuiltinErrors = {
- "0x08c379a0": { signature: "Error(string)", name: "Error", inputs: ["string"], reason: true },
- "0x4e487b71": { signature: "Panic(uint256)", name: "Panic", inputs: ["uint256"] }
- };
- function wrapAccessError(property, error) {
- var wrap = new Error("deferred error during ABI decoding triggered accessing " + property);
- wrap.error = error;
- return wrap;
- }
- /*
- function checkNames(fragment: Fragment, type: "input" | "output", params: Array<ParamType>): void {
- params.reduce((accum, param) => {
- if (param.name) {
- if (accum[param.name]) {
- logger.throwArgumentError(`duplicate ${ type } parameter ${ JSON.stringify(param.name) } in ${ fragment.format("full") }`, "fragment", fragment);
- }
- accum[param.name] = true;
- }
- return accum;
- }, <{ [ name: string ]: boolean }>{ });
- }
- */
- var Interface = /** @class */ (function () {
- function Interface(fragments) {
- var _newTarget = this.constructor;
- var _this = this;
- logger.checkNew(_newTarget, Interface);
- var abi = [];
- if (typeof (fragments) === "string") {
- abi = JSON.parse(fragments);
- }
- else {
- abi = fragments;
- }
- (0, properties_1.defineReadOnly)(this, "fragments", abi.map(function (fragment) {
- return fragments_1.Fragment.from(fragment);
- }).filter(function (fragment) { return (fragment != null); }));
- (0, properties_1.defineReadOnly)(this, "_abiCoder", (0, properties_1.getStatic)(_newTarget, "getAbiCoder")());
- (0, properties_1.defineReadOnly)(this, "functions", {});
- (0, properties_1.defineReadOnly)(this, "errors", {});
- (0, properties_1.defineReadOnly)(this, "events", {});
- (0, properties_1.defineReadOnly)(this, "structs", {});
- // Add all fragments by their signature
- this.fragments.forEach(function (fragment) {
- var bucket = null;
- switch (fragment.type) {
- case "constructor":
- if (_this.deploy) {
- logger.warn("duplicate definition - constructor");
- return;
- }
- //checkNames(fragment, "input", fragment.inputs);
- (0, properties_1.defineReadOnly)(_this, "deploy", fragment);
- return;
- case "function":
- //checkNames(fragment, "input", fragment.inputs);
- //checkNames(fragment, "output", (<FunctionFragment>fragment).outputs);
- bucket = _this.functions;
- break;
- case "event":
- //checkNames(fragment, "input", fragment.inputs);
- bucket = _this.events;
- break;
- case "error":
- bucket = _this.errors;
- break;
- default:
- return;
- }
- var signature = fragment.format();
- if (bucket[signature]) {
- logger.warn("duplicate definition - " + signature);
- return;
- }
- bucket[signature] = fragment;
- });
- // If we do not have a constructor add a default
- if (!this.deploy) {
- (0, properties_1.defineReadOnly)(this, "deploy", fragments_1.ConstructorFragment.from({
- payable: false,
- type: "constructor"
- }));
- }
- (0, properties_1.defineReadOnly)(this, "_isInterface", true);
- }
- Interface.prototype.format = function (format) {
- if (!format) {
- format = fragments_1.FormatTypes.full;
- }
- if (format === fragments_1.FormatTypes.sighash) {
- logger.throwArgumentError("interface does not support formatting sighash", "format", format);
- }
- var abi = this.fragments.map(function (fragment) { return fragment.format(format); });
- // We need to re-bundle the JSON fragments a bit
- if (format === fragments_1.FormatTypes.json) {
- return JSON.stringify(abi.map(function (j) { return JSON.parse(j); }));
- }
- return abi;
- };
- // Sub-classes can override these to handle other blockchains
- Interface.getAbiCoder = function () {
- return abi_coder_1.defaultAbiCoder;
- };
- Interface.getAddress = function (address) {
- return (0, address_1.getAddress)(address);
- };
- Interface.getSighash = function (fragment) {
- return (0, bytes_1.hexDataSlice)((0, hash_1.id)(fragment.format()), 0, 4);
- };
- Interface.getEventTopic = function (eventFragment) {
- return (0, hash_1.id)(eventFragment.format());
- };
- // Find a function definition by any means necessary (unless it is ambiguous)
- Interface.prototype.getFunction = function (nameOrSignatureOrSighash) {
- if ((0, bytes_1.isHexString)(nameOrSignatureOrSighash)) {
- for (var name_1 in this.functions) {
- if (nameOrSignatureOrSighash === this.getSighash(name_1)) {
- return this.functions[name_1];
- }
- }
- logger.throwArgumentError("no matching function", "sighash", nameOrSignatureOrSighash);
- }
- // It is a bare name, look up the function (will return null if ambiguous)
- if (nameOrSignatureOrSighash.indexOf("(") === -1) {
- var name_2 = nameOrSignatureOrSighash.trim();
- var matching = Object.keys(this.functions).filter(function (f) { return (f.split("(" /* fix:) */)[0] === name_2); });
- if (matching.length === 0) {
- logger.throwArgumentError("no matching function", "name", name_2);
- }
- else if (matching.length > 1) {
- logger.throwArgumentError("multiple matching functions", "name", name_2);
- }
- return this.functions[matching[0]];
- }
- // Normalize the signature and lookup the function
- var result = this.functions[fragments_1.FunctionFragment.fromString(nameOrSignatureOrSighash).format()];
- if (!result) {
- logger.throwArgumentError("no matching function", "signature", nameOrSignatureOrSighash);
- }
- return result;
- };
- // Find an event definition by any means necessary (unless it is ambiguous)
- Interface.prototype.getEvent = function (nameOrSignatureOrTopic) {
- if ((0, bytes_1.isHexString)(nameOrSignatureOrTopic)) {
- var topichash = nameOrSignatureOrTopic.toLowerCase();
- for (var name_3 in this.events) {
- if (topichash === this.getEventTopic(name_3)) {
- return this.events[name_3];
- }
- }
- logger.throwArgumentError("no matching event", "topichash", topichash);
- }
- // It is a bare name, look up the function (will return null if ambiguous)
- if (nameOrSignatureOrTopic.indexOf("(") === -1) {
- var name_4 = nameOrSignatureOrTopic.trim();
- var matching = Object.keys(this.events).filter(function (f) { return (f.split("(" /* fix:) */)[0] === name_4); });
- if (matching.length === 0) {
- logger.throwArgumentError("no matching event", "name", name_4);
- }
- else if (matching.length > 1) {
- logger.throwArgumentError("multiple matching events", "name", name_4);
- }
- return this.events[matching[0]];
- }
- // Normalize the signature and lookup the function
- var result = this.events[fragments_1.EventFragment.fromString(nameOrSignatureOrTopic).format()];
- if (!result) {
- logger.throwArgumentError("no matching event", "signature", nameOrSignatureOrTopic);
- }
- return result;
- };
- // Find a function definition by any means necessary (unless it is ambiguous)
- Interface.prototype.getError = function (nameOrSignatureOrSighash) {
- if ((0, bytes_1.isHexString)(nameOrSignatureOrSighash)) {
- var getSighash = (0, properties_1.getStatic)(this.constructor, "getSighash");
- for (var name_5 in this.errors) {
- var error = this.errors[name_5];
- if (nameOrSignatureOrSighash === getSighash(error)) {
- return this.errors[name_5];
- }
- }
- logger.throwArgumentError("no matching error", "sighash", nameOrSignatureOrSighash);
- }
- // It is a bare name, look up the function (will return null if ambiguous)
- if (nameOrSignatureOrSighash.indexOf("(") === -1) {
- var name_6 = nameOrSignatureOrSighash.trim();
- var matching = Object.keys(this.errors).filter(function (f) { return (f.split("(" /* fix:) */)[0] === name_6); });
- if (matching.length === 0) {
- logger.throwArgumentError("no matching error", "name", name_6);
- }
- else if (matching.length > 1) {
- logger.throwArgumentError("multiple matching errors", "name", name_6);
- }
- return this.errors[matching[0]];
- }
- // Normalize the signature and lookup the function
- var result = this.errors[fragments_1.FunctionFragment.fromString(nameOrSignatureOrSighash).format()];
- if (!result) {
- logger.throwArgumentError("no matching error", "signature", nameOrSignatureOrSighash);
- }
- return result;
- };
- // Get the sighash (the bytes4 selector) used by Solidity to identify a function
- Interface.prototype.getSighash = function (fragment) {
- if (typeof (fragment) === "string") {
- try {
- fragment = this.getFunction(fragment);
- }
- catch (error) {
- try {
- fragment = this.getError(fragment);
- }
- catch (_) {
- throw error;
- }
- }
- }
- return (0, properties_1.getStatic)(this.constructor, "getSighash")(fragment);
- };
- // Get the topic (the bytes32 hash) used by Solidity to identify an event
- Interface.prototype.getEventTopic = function (eventFragment) {
- if (typeof (eventFragment) === "string") {
- eventFragment = this.getEvent(eventFragment);
- }
- return (0, properties_1.getStatic)(this.constructor, "getEventTopic")(eventFragment);
- };
- Interface.prototype._decodeParams = function (params, data) {
- return this._abiCoder.decode(params, data);
- };
- Interface.prototype._encodeParams = function (params, values) {
- return this._abiCoder.encode(params, values);
- };
- Interface.prototype.encodeDeploy = function (values) {
- return this._encodeParams(this.deploy.inputs, values || []);
- };
- Interface.prototype.decodeErrorResult = function (fragment, data) {
- if (typeof (fragment) === "string") {
- fragment = this.getError(fragment);
- }
- var bytes = (0, bytes_1.arrayify)(data);
- if ((0, bytes_1.hexlify)(bytes.slice(0, 4)) !== this.getSighash(fragment)) {
- logger.throwArgumentError("data signature does not match error " + fragment.name + ".", "data", (0, bytes_1.hexlify)(bytes));
- }
- return this._decodeParams(fragment.inputs, bytes.slice(4));
- };
- Interface.prototype.encodeErrorResult = function (fragment, values) {
- if (typeof (fragment) === "string") {
- fragment = this.getError(fragment);
- }
- return (0, bytes_1.hexlify)((0, bytes_1.concat)([
- this.getSighash(fragment),
- this._encodeParams(fragment.inputs, values || [])
- ]));
- };
- // Decode the data for a function call (e.g. tx.data)
- Interface.prototype.decodeFunctionData = function (functionFragment, data) {
- if (typeof (functionFragment) === "string") {
- functionFragment = this.getFunction(functionFragment);
- }
- var bytes = (0, bytes_1.arrayify)(data);
- if ((0, bytes_1.hexlify)(bytes.slice(0, 4)) !== this.getSighash(functionFragment)) {
- logger.throwArgumentError("data signature does not match function " + functionFragment.name + ".", "data", (0, bytes_1.hexlify)(bytes));
- }
- return this._decodeParams(functionFragment.inputs, bytes.slice(4));
- };
- // Encode the data for a function call (e.g. tx.data)
- Interface.prototype.encodeFunctionData = function (functionFragment, values) {
- if (typeof (functionFragment) === "string") {
- functionFragment = this.getFunction(functionFragment);
- }
- return (0, bytes_1.hexlify)((0, bytes_1.concat)([
- this.getSighash(functionFragment),
- this._encodeParams(functionFragment.inputs, values || [])
- ]));
- };
- // Decode the result from a function call (e.g. from eth_call)
- Interface.prototype.decodeFunctionResult = function (functionFragment, data) {
- if (typeof (functionFragment) === "string") {
- functionFragment = this.getFunction(functionFragment);
- }
- var bytes = (0, bytes_1.arrayify)(data);
- var reason = null;
- var errorArgs = null;
- var errorName = null;
- var errorSignature = null;
- switch (bytes.length % this._abiCoder._getWordSize()) {
- case 0:
- try {
- return this._abiCoder.decode(functionFragment.outputs, bytes);
- }
- catch (error) { }
- break;
- case 4: {
- var selector = (0, bytes_1.hexlify)(bytes.slice(0, 4));
- var builtin = BuiltinErrors[selector];
- if (builtin) {
- errorArgs = this._abiCoder.decode(builtin.inputs, bytes.slice(4));
- errorName = builtin.name;
- errorSignature = builtin.signature;
- if (builtin.reason) {
- reason = errorArgs[0];
- }
- }
- else {
- try {
- var error = this.getError(selector);
- errorArgs = this._abiCoder.decode(error.inputs, bytes.slice(4));
- errorName = error.name;
- errorSignature = error.format();
- }
- catch (error) { }
- }
- break;
- }
- }
- return logger.throwError("call revert exception", logger_1.Logger.errors.CALL_EXCEPTION, {
- method: functionFragment.format(),
- errorArgs: errorArgs,
- errorName: errorName,
- errorSignature: errorSignature,
- reason: reason
- });
- };
- // Encode the result for a function call (e.g. for eth_call)
- Interface.prototype.encodeFunctionResult = function (functionFragment, values) {
- if (typeof (functionFragment) === "string") {
- functionFragment = this.getFunction(functionFragment);
- }
- return (0, bytes_1.hexlify)(this._abiCoder.encode(functionFragment.outputs, values || []));
- };
- // Create the filter for the event with search criteria (e.g. for eth_filterLog)
- Interface.prototype.encodeFilterTopics = function (eventFragment, values) {
- var _this = this;
- if (typeof (eventFragment) === "string") {
- eventFragment = this.getEvent(eventFragment);
- }
- if (values.length > eventFragment.inputs.length) {
- logger.throwError("too many arguments for " + eventFragment.format(), logger_1.Logger.errors.UNEXPECTED_ARGUMENT, {
- argument: "values",
- value: values
- });
- }
- var topics = [];
- if (!eventFragment.anonymous) {
- topics.push(this.getEventTopic(eventFragment));
- }
- var encodeTopic = function (param, value) {
- if (param.type === "string") {
- return (0, hash_1.id)(value);
- }
- else if (param.type === "bytes") {
- return (0, keccak256_1.keccak256)((0, bytes_1.hexlify)(value));
- }
- // Check addresses are valid
- if (param.type === "address") {
- _this._abiCoder.encode(["address"], [value]);
- }
- return (0, bytes_1.hexZeroPad)((0, bytes_1.hexlify)(value), 32);
- };
- values.forEach(function (value, index) {
- var param = eventFragment.inputs[index];
- if (!param.indexed) {
- if (value != null) {
- logger.throwArgumentError("cannot filter non-indexed parameters; must be null", ("contract." + param.name), value);
- }
- return;
- }
- if (value == null) {
- topics.push(null);
- }
- else if (param.baseType === "array" || param.baseType === "tuple") {
- logger.throwArgumentError("filtering with tuples or arrays not supported", ("contract." + param.name), value);
- }
- else if (Array.isArray(value)) {
- topics.push(value.map(function (value) { return encodeTopic(param, value); }));
- }
- else {
- topics.push(encodeTopic(param, value));
- }
- });
- // Trim off trailing nulls
- while (topics.length && topics[topics.length - 1] === null) {
- topics.pop();
- }
- return topics;
- };
- Interface.prototype.encodeEventLog = function (eventFragment, values) {
- var _this = this;
- if (typeof (eventFragment) === "string") {
- eventFragment = this.getEvent(eventFragment);
- }
- var topics = [];
- var dataTypes = [];
- var dataValues = [];
- if (!eventFragment.anonymous) {
- topics.push(this.getEventTopic(eventFragment));
- }
- if (values.length !== eventFragment.inputs.length) {
- logger.throwArgumentError("event arguments/values mismatch", "values", values);
- }
- eventFragment.inputs.forEach(function (param, index) {
- var value = values[index];
- if (param.indexed) {
- if (param.type === "string") {
- topics.push((0, hash_1.id)(value));
- }
- else if (param.type === "bytes") {
- topics.push((0, keccak256_1.keccak256)(value));
- }
- else if (param.baseType === "tuple" || param.baseType === "array") {
- // @TODO
- throw new Error("not implemented");
- }
- else {
- topics.push(_this._abiCoder.encode([param.type], [value]));
- }
- }
- else {
- dataTypes.push(param);
- dataValues.push(value);
- }
- });
- return {
- data: this._abiCoder.encode(dataTypes, dataValues),
- topics: topics
- };
- };
- // Decode a filter for the event and the search criteria
- Interface.prototype.decodeEventLog = function (eventFragment, data, topics) {
- if (typeof (eventFragment) === "string") {
- eventFragment = this.getEvent(eventFragment);
- }
- if (topics != null && !eventFragment.anonymous) {
- var topicHash = this.getEventTopic(eventFragment);
- if (!(0, bytes_1.isHexString)(topics[0], 32) || topics[0].toLowerCase() !== topicHash) {
- logger.throwError("fragment/topic mismatch", logger_1.Logger.errors.INVALID_ARGUMENT, { argument: "topics[0]", expected: topicHash, value: topics[0] });
- }
- topics = topics.slice(1);
- }
- var indexed = [];
- var nonIndexed = [];
- var dynamic = [];
- eventFragment.inputs.forEach(function (param, index) {
- if (param.indexed) {
- if (param.type === "string" || param.type === "bytes" || param.baseType === "tuple" || param.baseType === "array") {
- indexed.push(fragments_1.ParamType.fromObject({ type: "bytes32", name: param.name }));
- dynamic.push(true);
- }
- else {
- indexed.push(param);
- dynamic.push(false);
- }
- }
- else {
- nonIndexed.push(param);
- dynamic.push(false);
- }
- });
- var resultIndexed = (topics != null) ? this._abiCoder.decode(indexed, (0, bytes_1.concat)(topics)) : null;
- var resultNonIndexed = this._abiCoder.decode(nonIndexed, data, true);
- var result = [];
- var nonIndexedIndex = 0, indexedIndex = 0;
- eventFragment.inputs.forEach(function (param, index) {
- if (param.indexed) {
- if (resultIndexed == null) {
- result[index] = new Indexed({ _isIndexed: true, hash: null });
- }
- else if (dynamic[index]) {
- result[index] = new Indexed({ _isIndexed: true, hash: resultIndexed[indexedIndex++] });
- }
- else {
- try {
- result[index] = resultIndexed[indexedIndex++];
- }
- catch (error) {
- result[index] = error;
- }
- }
- }
- else {
- try {
- result[index] = resultNonIndexed[nonIndexedIndex++];
- }
- catch (error) {
- result[index] = error;
- }
- }
- // Add the keyword argument if named and safe
- if (param.name && result[param.name] == null) {
- var value_1 = result[index];
- // Make error named values throw on access
- if (value_1 instanceof Error) {
- Object.defineProperty(result, param.name, {
- enumerable: true,
- get: function () { throw wrapAccessError("property " + JSON.stringify(param.name), value_1); }
- });
- }
- else {
- result[param.name] = value_1;
- }
- }
- });
- var _loop_1 = function (i) {
- var value = result[i];
- if (value instanceof Error) {
- Object.defineProperty(result, i, {
- enumerable: true,
- get: function () { throw wrapAccessError("index " + i, value); }
- });
- }
- };
- // Make all error indexed values throw on access
- for (var i = 0; i < result.length; i++) {
- _loop_1(i);
- }
- return Object.freeze(result);
- };
- // Given a transaction, find the matching function fragment (if any) and
- // determine all its properties and call parameters
- Interface.prototype.parseTransaction = function (tx) {
- var fragment = this.getFunction(tx.data.substring(0, 10).toLowerCase());
- if (!fragment) {
- return null;
- }
- return new TransactionDescription({
- args: this._abiCoder.decode(fragment.inputs, "0x" + tx.data.substring(10)),
- functionFragment: fragment,
- name: fragment.name,
- signature: fragment.format(),
- sighash: this.getSighash(fragment),
- value: bignumber_1.BigNumber.from(tx.value || "0"),
- });
- };
- // @TODO
- //parseCallResult(data: BytesLike): ??
- // Given an event log, find the matching event fragment (if any) and
- // determine all its properties and values
- Interface.prototype.parseLog = function (log) {
- var fragment = this.getEvent(log.topics[0]);
- if (!fragment || fragment.anonymous) {
- return null;
- }
- // @TODO: If anonymous, and the only method, and the input count matches, should we parse?
- // Probably not, because just because it is the only event in the ABI does
- // not mean we have the full ABI; maybe just a fragment?
- return new LogDescription({
- eventFragment: fragment,
- name: fragment.name,
- signature: fragment.format(),
- topic: this.getEventTopic(fragment),
- args: this.decodeEventLog(fragment, log.data, log.topics)
- });
- };
- Interface.prototype.parseError = function (data) {
- var hexData = (0, bytes_1.hexlify)(data);
- var fragment = this.getError(hexData.substring(0, 10).toLowerCase());
- if (!fragment) {
- return null;
- }
- return new ErrorDescription({
- args: this._abiCoder.decode(fragment.inputs, "0x" + hexData.substring(10)),
- errorFragment: fragment,
- name: fragment.name,
- signature: fragment.format(),
- sighash: this.getSighash(fragment),
- });
- };
- /*
- static from(value: Array<Fragment | string | JsonAbi> | string | Interface) {
- if (Interface.isInterface(value)) {
- return value;
- }
- if (typeof(value) === "string") {
- return new Interface(JSON.parse(value));
- }
- return new Interface(value);
- }
- */
- Interface.isInterface = function (value) {
- return !!(value && value._isInterface);
- };
- return Interface;
- }());
- exports.Interface = Interface;
- },{"./_version":168,"./abi-coder":169,"./coders/abstract-coder":170,"./fragments":181,"@ethersproject/address":189,"@ethersproject/bignumber":196,"@ethersproject/bytes":199,"@ethersproject/hash":209,"@ethersproject/keccak256":221,"@ethersproject/logger":223,"@ethersproject/properties":229}],184:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.version = void 0;
- exports.version = "abstract-provider/5.6.0";
- },{}],185:[function(_dereq_,module,exports){
- "use strict";
- var __extends = (this && this.__extends) || (function () {
- var extendStatics = function (d, b) {
- extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
- return extendStatics(d, b);
- };
- return function (d, b) {
- if (typeof b !== "function" && b !== null)
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
- return new (P || (P = Promise))(function (resolve, reject) {
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
- step((generator = generator.apply(thisArg, _arguments || [])).next());
- });
- };
- var __generator = (this && this.__generator) || function (thisArg, body) {
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
- function verb(n) { return function (v) { return step([n, v]); }; }
- function step(op) {
- if (f) throw new TypeError("Generator is already executing.");
- while (_) try {
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
- if (y = 0, t) op = [op[0] & 2, t.value];
- switch (op[0]) {
- case 0: case 1: t = op; break;
- case 4: _.label++; return { value: op[1], done: false };
- case 5: _.label++; y = op[1]; op = [0]; continue;
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
- default:
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
- if (t[2]) _.ops.pop();
- _.trys.pop(); continue;
- }
- op = body.call(thisArg, _);
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
- }
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.Provider = exports.TransactionOrderForkEvent = exports.TransactionForkEvent = exports.BlockForkEvent = exports.ForkEvent = void 0;
- var bignumber_1 = _dereq_("@ethersproject/bignumber");
- var bytes_1 = _dereq_("@ethersproject/bytes");
- var properties_1 = _dereq_("@ethersproject/properties");
- var logger_1 = _dereq_("@ethersproject/logger");
- var _version_1 = _dereq_("./_version");
- var logger = new logger_1.Logger(_version_1.version);
- ;
- ;
- //export type CallTransactionable = {
- // call(transaction: TransactionRequest): Promise<TransactionResponse>;
- //};
- var ForkEvent = /** @class */ (function (_super) {
- __extends(ForkEvent, _super);
- function ForkEvent() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- ForkEvent.isForkEvent = function (value) {
- return !!(value && value._isForkEvent);
- };
- return ForkEvent;
- }(properties_1.Description));
- exports.ForkEvent = ForkEvent;
- var BlockForkEvent = /** @class */ (function (_super) {
- __extends(BlockForkEvent, _super);
- function BlockForkEvent(blockHash, expiry) {
- var _this = this;
- if (!(0, bytes_1.isHexString)(blockHash, 32)) {
- logger.throwArgumentError("invalid blockHash", "blockHash", blockHash);
- }
- _this = _super.call(this, {
- _isForkEvent: true,
- _isBlockForkEvent: true,
- expiry: (expiry || 0),
- blockHash: blockHash
- }) || this;
- return _this;
- }
- return BlockForkEvent;
- }(ForkEvent));
- exports.BlockForkEvent = BlockForkEvent;
- var TransactionForkEvent = /** @class */ (function (_super) {
- __extends(TransactionForkEvent, _super);
- function TransactionForkEvent(hash, expiry) {
- var _this = this;
- if (!(0, bytes_1.isHexString)(hash, 32)) {
- logger.throwArgumentError("invalid transaction hash", "hash", hash);
- }
- _this = _super.call(this, {
- _isForkEvent: true,
- _isTransactionForkEvent: true,
- expiry: (expiry || 0),
- hash: hash
- }) || this;
- return _this;
- }
- return TransactionForkEvent;
- }(ForkEvent));
- exports.TransactionForkEvent = TransactionForkEvent;
- var TransactionOrderForkEvent = /** @class */ (function (_super) {
- __extends(TransactionOrderForkEvent, _super);
- function TransactionOrderForkEvent(beforeHash, afterHash, expiry) {
- var _this = this;
- if (!(0, bytes_1.isHexString)(beforeHash, 32)) {
- logger.throwArgumentError("invalid transaction hash", "beforeHash", beforeHash);
- }
- if (!(0, bytes_1.isHexString)(afterHash, 32)) {
- logger.throwArgumentError("invalid transaction hash", "afterHash", afterHash);
- }
- _this = _super.call(this, {
- _isForkEvent: true,
- _isTransactionOrderForkEvent: true,
- expiry: (expiry || 0),
- beforeHash: beforeHash,
- afterHash: afterHash
- }) || this;
- return _this;
- }
- return TransactionOrderForkEvent;
- }(ForkEvent));
- exports.TransactionOrderForkEvent = TransactionOrderForkEvent;
- ///////////////////////////////
- // Exported Abstracts
- var Provider = /** @class */ (function () {
- function Provider() {
- var _newTarget = this.constructor;
- logger.checkAbstract(_newTarget, Provider);
- (0, properties_1.defineReadOnly)(this, "_isProvider", true);
- }
- Provider.prototype.getFeeData = function () {
- return __awaiter(this, void 0, void 0, function () {
- var _a, block, gasPrice, maxFeePerGas, maxPriorityFeePerGas;
- return __generator(this, function (_b) {
- switch (_b.label) {
- case 0: return [4 /*yield*/, (0, properties_1.resolveProperties)({
- block: this.getBlock("latest"),
- gasPrice: this.getGasPrice().catch(function (error) {
- // @TODO: Why is this now failing on Calaveras?
- //console.log(error);
- return null;
- })
- })];
- case 1:
- _a = _b.sent(), block = _a.block, gasPrice = _a.gasPrice;
- maxFeePerGas = null, maxPriorityFeePerGas = null;
- if (block && block.baseFeePerGas) {
- // We may want to compute this more accurately in the future,
- // using the formula "check if the base fee is correct".
- // See: https://eips.ethereum.org/EIPS/eip-1559
- maxPriorityFeePerGas = bignumber_1.BigNumber.from("1500000000");
- maxFeePerGas = block.baseFeePerGas.mul(2).add(maxPriorityFeePerGas);
- }
- return [2 /*return*/, { maxFeePerGas: maxFeePerGas, maxPriorityFeePerGas: maxPriorityFeePerGas, gasPrice: gasPrice }];
- }
- });
- });
- };
- // Alias for "on"
- Provider.prototype.addListener = function (eventName, listener) {
- return this.on(eventName, listener);
- };
- // Alias for "off"
- Provider.prototype.removeListener = function (eventName, listener) {
- return this.off(eventName, listener);
- };
- Provider.isProvider = function (value) {
- return !!(value && value._isProvider);
- };
- return Provider;
- }());
- exports.Provider = Provider;
- },{"./_version":184,"@ethersproject/bignumber":196,"@ethersproject/bytes":199,"@ethersproject/logger":223,"@ethersproject/properties":229}],186:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.version = void 0;
- exports.version = "abstract-signer/5.6.0";
- },{}],187:[function(_dereq_,module,exports){
- "use strict";
- var __extends = (this && this.__extends) || (function () {
- var extendStatics = function (d, b) {
- extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
- return extendStatics(d, b);
- };
- return function (d, b) {
- if (typeof b !== "function" && b !== null)
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
- return new (P || (P = Promise))(function (resolve, reject) {
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
- step((generator = generator.apply(thisArg, _arguments || [])).next());
- });
- };
- var __generator = (this && this.__generator) || function (thisArg, body) {
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
- function verb(n) { return function (v) { return step([n, v]); }; }
- function step(op) {
- if (f) throw new TypeError("Generator is already executing.");
- while (_) try {
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
- if (y = 0, t) op = [op[0] & 2, t.value];
- switch (op[0]) {
- case 0: case 1: t = op; break;
- case 4: _.label++; return { value: op[1], done: false };
- case 5: _.label++; y = op[1]; op = [0]; continue;
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
- default:
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
- if (t[2]) _.ops.pop();
- _.trys.pop(); continue;
- }
- op = body.call(thisArg, _);
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
- }
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.VoidSigner = exports.Signer = void 0;
- var properties_1 = _dereq_("@ethersproject/properties");
- var logger_1 = _dereq_("@ethersproject/logger");
- var _version_1 = _dereq_("./_version");
- var logger = new logger_1.Logger(_version_1.version);
- var allowedTransactionKeys = [
- "accessList", "ccipReadEnabled", "chainId", "customData", "data", "from", "gasLimit", "gasPrice", "maxFeePerGas", "maxPriorityFeePerGas", "nonce", "to", "type", "value"
- ];
- var forwardErrors = [
- logger_1.Logger.errors.INSUFFICIENT_FUNDS,
- logger_1.Logger.errors.NONCE_EXPIRED,
- logger_1.Logger.errors.REPLACEMENT_UNDERPRICED,
- ];
- ;
- ;
- var Signer = /** @class */ (function () {
- ///////////////////
- // Sub-classes MUST call super
- function Signer() {
- var _newTarget = this.constructor;
- logger.checkAbstract(_newTarget, Signer);
- (0, properties_1.defineReadOnly)(this, "_isSigner", true);
- }
- ///////////////////
- // Sub-classes MAY override these
- Signer.prototype.getBalance = function (blockTag) {
- return __awaiter(this, void 0, void 0, function () {
- return __generator(this, function (_a) {
- switch (_a.label) {
- case 0:
- this._checkProvider("getBalance");
- return [4 /*yield*/, this.provider.getBalance(this.getAddress(), blockTag)];
- case 1: return [2 /*return*/, _a.sent()];
- }
- });
- });
- };
- Signer.prototype.getTransactionCount = function (blockTag) {
- return __awaiter(this, void 0, void 0, function () {
- return __generator(this, function (_a) {
- switch (_a.label) {
- case 0:
- this._checkProvider("getTransactionCount");
- return [4 /*yield*/, this.provider.getTransactionCount(this.getAddress(), blockTag)];
- case 1: return [2 /*return*/, _a.sent()];
- }
- });
- });
- };
- // Populates "from" if unspecified, and estimates the gas for the transaction
- Signer.prototype.estimateGas = function (transaction) {
- return __awaiter(this, void 0, void 0, function () {
- var tx;
- return __generator(this, function (_a) {
- switch (_a.label) {
- case 0:
- this._checkProvider("estimateGas");
- return [4 /*yield*/, (0, properties_1.resolveProperties)(this.checkTransaction(transaction))];
- case 1:
- tx = _a.sent();
- return [4 /*yield*/, this.provider.estimateGas(tx)];
- case 2: return [2 /*return*/, _a.sent()];
- }
- });
- });
- };
- // Populates "from" if unspecified, and calls with the transaction
- Signer.prototype.call = function (transaction, blockTag) {
- return __awaiter(this, void 0, void 0, function () {
- var tx;
- return __generator(this, function (_a) {
- switch (_a.label) {
- case 0:
- this._checkProvider("call");
- return [4 /*yield*/, (0, properties_1.resolveProperties)(this.checkTransaction(transaction))];
- case 1:
- tx = _a.sent();
- return [4 /*yield*/, this.provider.call(tx, blockTag)];
- case 2: return [2 /*return*/, _a.sent()];
- }
- });
- });
- };
- // Populates all fields in a transaction, signs it and sends it to the network
- Signer.prototype.sendTransaction = function (transaction) {
- return __awaiter(this, void 0, void 0, function () {
- var tx, signedTx;
- return __generator(this, function (_a) {
- switch (_a.label) {
- case 0:
- this._checkProvider("sendTransaction");
- return [4 /*yield*/, this.populateTransaction(transaction)];
- case 1:
- tx = _a.sent();
- return [4 /*yield*/, this.signTransaction(tx)];
- case 2:
- signedTx = _a.sent();
- return [4 /*yield*/, this.provider.sendTransaction(signedTx)];
- case 3: return [2 /*return*/, _a.sent()];
- }
- });
- });
- };
- Signer.prototype.getChainId = function () {
- return __awaiter(this, void 0, void 0, function () {
- var network;
- return __generator(this, function (_a) {
- switch (_a.label) {
- case 0:
- this._checkProvider("getChainId");
- return [4 /*yield*/, this.provider.getNetwork()];
- case 1:
- network = _a.sent();
- return [2 /*return*/, network.chainId];
- }
- });
- });
- };
- Signer.prototype.getGasPrice = function () {
- return __awaiter(this, void 0, void 0, function () {
- return __generator(this, function (_a) {
- switch (_a.label) {
- case 0:
- this._checkProvider("getGasPrice");
- return [4 /*yield*/, this.provider.getGasPrice()];
- case 1: return [2 /*return*/, _a.sent()];
- }
- });
- });
- };
- Signer.prototype.getFeeData = function () {
- return __awaiter(this, void 0, void 0, function () {
- return __generator(this, function (_a) {
- switch (_a.label) {
- case 0:
- this._checkProvider("getFeeData");
- return [4 /*yield*/, this.provider.getFeeData()];
- case 1: return [2 /*return*/, _a.sent()];
- }
- });
- });
- };
- Signer.prototype.resolveName = function (name) {
- return __awaiter(this, void 0, void 0, function () {
- return __generator(this, function (_a) {
- switch (_a.label) {
- case 0:
- this._checkProvider("resolveName");
- return [4 /*yield*/, this.provider.resolveName(name)];
- case 1: return [2 /*return*/, _a.sent()];
- }
- });
- });
- };
- // Checks a transaction does not contain invalid keys and if
- // no "from" is provided, populates it.
- // - does NOT require a provider
- // - adds "from" is not present
- // - returns a COPY (safe to mutate the result)
- // By default called from: (overriding these prevents it)
- // - call
- // - estimateGas
- // - populateTransaction (and therefor sendTransaction)
- Signer.prototype.checkTransaction = function (transaction) {
- for (var key in transaction) {
- if (allowedTransactionKeys.indexOf(key) === -1) {
- logger.throwArgumentError("invalid transaction key: " + key, "transaction", transaction);
- }
- }
- var tx = (0, properties_1.shallowCopy)(transaction);
- if (tx.from == null) {
- tx.from = this.getAddress();
- }
- else {
- // Make sure any provided address matches this signer
- tx.from = Promise.all([
- Promise.resolve(tx.from),
- this.getAddress()
- ]).then(function (result) {
- if (result[0].toLowerCase() !== result[1].toLowerCase()) {
- logger.throwArgumentError("from address mismatch", "transaction", transaction);
- }
- return result[0];
- });
- }
- return tx;
- };
- // Populates ALL keys for a transaction and checks that "from" matches
- // this Signer. Should be used by sendTransaction but NOT by signTransaction.
- // By default called from: (overriding these prevents it)
- // - sendTransaction
- //
- // Notes:
- // - We allow gasPrice for EIP-1559 as long as it matches maxFeePerGas
- Signer.prototype.populateTransaction = function (transaction) {
- return __awaiter(this, void 0, void 0, function () {
- var tx, hasEip1559, feeData, gasPrice;
- var _this = this;
- return __generator(this, function (_a) {
- switch (_a.label) {
- case 0: return [4 /*yield*/, (0, properties_1.resolveProperties)(this.checkTransaction(transaction))];
- case 1:
- tx = _a.sent();
- if (tx.to != null) {
- tx.to = Promise.resolve(tx.to).then(function (to) { return __awaiter(_this, void 0, void 0, function () {
- var address;
- return __generator(this, function (_a) {
- switch (_a.label) {
- case 0:
- if (to == null) {
- return [2 /*return*/, null];
- }
- return [4 /*yield*/, this.resolveName(to)];
- case 1:
- address = _a.sent();
- if (address == null) {
- logger.throwArgumentError("provided ENS name resolves to null", "tx.to", to);
- }
- return [2 /*return*/, address];
- }
- });
- }); });
- // Prevent this error from causing an UnhandledPromiseException
- tx.to.catch(function (error) { });
- }
- hasEip1559 = (tx.maxFeePerGas != null || tx.maxPriorityFeePerGas != null);
- if (tx.gasPrice != null && (tx.type === 2 || hasEip1559)) {
- logger.throwArgumentError("eip-1559 transaction do not support gasPrice", "transaction", transaction);
- }
- else if ((tx.type === 0 || tx.type === 1) && hasEip1559) {
- logger.throwArgumentError("pre-eip-1559 transaction do not support maxFeePerGas/maxPriorityFeePerGas", "transaction", transaction);
- }
- if (!((tx.type === 2 || tx.type == null) && (tx.maxFeePerGas != null && tx.maxPriorityFeePerGas != null))) return [3 /*break*/, 2];
- // Fully-formed EIP-1559 transaction (skip getFeeData)
- tx.type = 2;
- return [3 /*break*/, 5];
- case 2:
- if (!(tx.type === 0 || tx.type === 1)) return [3 /*break*/, 3];
- // Explicit Legacy or EIP-2930 transaction
- // Populate missing gasPrice
- if (tx.gasPrice == null) {
- tx.gasPrice = this.getGasPrice();
- }
- return [3 /*break*/, 5];
- case 3: return [4 /*yield*/, this.getFeeData()];
- case 4:
- feeData = _a.sent();
- if (tx.type == null) {
- // We need to auto-detect the intended type of this transaction...
- if (feeData.maxFeePerGas != null && feeData.maxPriorityFeePerGas != null) {
- // The network supports EIP-1559!
- // Upgrade transaction from null to eip-1559
- tx.type = 2;
- if (tx.gasPrice != null) {
- gasPrice = tx.gasPrice;
- delete tx.gasPrice;
- tx.maxFeePerGas = gasPrice;
- tx.maxPriorityFeePerGas = gasPrice;
- }
- else {
- // Populate missing fee data
- if (tx.maxFeePerGas == null) {
- tx.maxFeePerGas = feeData.maxFeePerGas;
- }
- if (tx.maxPriorityFeePerGas == null) {
- tx.maxPriorityFeePerGas = feeData.maxPriorityFeePerGas;
- }
- }
- }
- else if (feeData.gasPrice != null) {
- // Network doesn't support EIP-1559...
- // ...but they are trying to use EIP-1559 properties
- if (hasEip1559) {
- logger.throwError("network does not support EIP-1559", logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
- operation: "populateTransaction"
- });
- }
- // Populate missing fee data
- if (tx.gasPrice == null) {
- tx.gasPrice = feeData.gasPrice;
- }
- // Explicitly set untyped transaction to legacy
- tx.type = 0;
- }
- else {
- // getFeeData has failed us.
- logger.throwError("failed to get consistent fee data", logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
- operation: "signer.getFeeData"
- });
- }
- }
- else if (tx.type === 2) {
- // Explicitly using EIP-1559
- // Populate missing fee data
- if (tx.maxFeePerGas == null) {
- tx.maxFeePerGas = feeData.maxFeePerGas;
- }
- if (tx.maxPriorityFeePerGas == null) {
- tx.maxPriorityFeePerGas = feeData.maxPriorityFeePerGas;
- }
- }
- _a.label = 5;
- case 5:
- if (tx.nonce == null) {
- tx.nonce = this.getTransactionCount("pending");
- }
- if (tx.gasLimit == null) {
- tx.gasLimit = this.estimateGas(tx).catch(function (error) {
- if (forwardErrors.indexOf(error.code) >= 0) {
- throw error;
- }
- return logger.throwError("cannot estimate gas; transaction may fail or may require manual gas limit", logger_1.Logger.errors.UNPREDICTABLE_GAS_LIMIT, {
- error: error,
- tx: tx
- });
- });
- }
- if (tx.chainId == null) {
- tx.chainId = this.getChainId();
- }
- else {
- tx.chainId = Promise.all([
- Promise.resolve(tx.chainId),
- this.getChainId()
- ]).then(function (results) {
- if (results[1] !== 0 && results[0] !== results[1]) {
- logger.throwArgumentError("chainId address mismatch", "transaction", transaction);
- }
- return results[0];
- });
- }
- return [4 /*yield*/, (0, properties_1.resolveProperties)(tx)];
- case 6: return [2 /*return*/, _a.sent()];
- }
- });
- });
- };
- ///////////////////
- // Sub-classes SHOULD leave these alone
- Signer.prototype._checkProvider = function (operation) {
- if (!this.provider) {
- logger.throwError("missing provider", logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
- operation: (operation || "_checkProvider")
- });
- }
- };
- Signer.isSigner = function (value) {
- return !!(value && value._isSigner);
- };
- return Signer;
- }());
- exports.Signer = Signer;
- var VoidSigner = /** @class */ (function (_super) {
- __extends(VoidSigner, _super);
- function VoidSigner(address, provider) {
- var _newTarget = this.constructor;
- var _this = this;
- logger.checkNew(_newTarget, VoidSigner);
- _this = _super.call(this) || this;
- (0, properties_1.defineReadOnly)(_this, "address", address);
- (0, properties_1.defineReadOnly)(_this, "provider", provider || null);
- return _this;
- }
- VoidSigner.prototype.getAddress = function () {
- return Promise.resolve(this.address);
- };
- VoidSigner.prototype._fail = function (message, operation) {
- return Promise.resolve().then(function () {
- logger.throwError(message, logger_1.Logger.errors.UNSUPPORTED_OPERATION, { operation: operation });
- });
- };
- VoidSigner.prototype.signMessage = function (message) {
- return this._fail("VoidSigner cannot sign messages", "signMessage");
- };
- VoidSigner.prototype.signTransaction = function (transaction) {
- return this._fail("VoidSigner cannot sign transactions", "signTransaction");
- };
- VoidSigner.prototype._signTypedData = function (domain, types, value) {
- return this._fail("VoidSigner cannot sign typed data", "signTypedData");
- };
- VoidSigner.prototype.connect = function (provider) {
- return new VoidSigner(this.address, provider);
- };
- return VoidSigner;
- }(Signer));
- exports.VoidSigner = VoidSigner;
- },{"./_version":186,"@ethersproject/logger":223,"@ethersproject/properties":229}],188:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.version = void 0;
- exports.version = "address/5.6.0";
- },{}],189:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.getCreate2Address = exports.getContractAddress = exports.getIcapAddress = exports.isAddress = exports.getAddress = void 0;
- var bytes_1 = _dereq_("@ethersproject/bytes");
- var bignumber_1 = _dereq_("@ethersproject/bignumber");
- var keccak256_1 = _dereq_("@ethersproject/keccak256");
- var rlp_1 = _dereq_("@ethersproject/rlp");
- var logger_1 = _dereq_("@ethersproject/logger");
- var _version_1 = _dereq_("./_version");
- var logger = new logger_1.Logger(_version_1.version);
- function getChecksumAddress(address) {
- if (!(0, bytes_1.isHexString)(address, 20)) {
- logger.throwArgumentError("invalid address", "address", address);
- }
- address = address.toLowerCase();
- var chars = address.substring(2).split("");
- var expanded = new Uint8Array(40);
- for (var i = 0; i < 40; i++) {
- expanded[i] = chars[i].charCodeAt(0);
- }
- var hashed = (0, bytes_1.arrayify)((0, keccak256_1.keccak256)(expanded));
- for (var i = 0; i < 40; i += 2) {
- if ((hashed[i >> 1] >> 4) >= 8) {
- chars[i] = chars[i].toUpperCase();
- }
- if ((hashed[i >> 1] & 0x0f) >= 8) {
- chars[i + 1] = chars[i + 1].toUpperCase();
- }
- }
- return "0x" + chars.join("");
- }
- // Shims for environments that are missing some required constants and functions
- var MAX_SAFE_INTEGER = 0x1fffffffffffff;
- function log10(x) {
- if (Math.log10) {
- return Math.log10(x);
- }
- return Math.log(x) / Math.LN10;
- }
- // See: https://en.wikipedia.org/wiki/International_Bank_Account_Number
- // Create lookup table
- var ibanLookup = {};
- for (var i = 0; i < 10; i++) {
- ibanLookup[String(i)] = String(i);
- }
- for (var i = 0; i < 26; i++) {
- ibanLookup[String.fromCharCode(65 + i)] = String(10 + i);
- }
- // How many decimal digits can we process? (for 64-bit float, this is 15)
- var safeDigits = Math.floor(log10(MAX_SAFE_INTEGER));
- function ibanChecksum(address) {
- address = address.toUpperCase();
- address = address.substring(4) + address.substring(0, 2) + "00";
- var expanded = address.split("").map(function (c) { return ibanLookup[c]; }).join("");
- // Javascript can handle integers safely up to 15 (decimal) digits
- while (expanded.length >= safeDigits) {
- var block = expanded.substring(0, safeDigits);
- expanded = parseInt(block, 10) % 97 + expanded.substring(block.length);
- }
- var checksum = String(98 - (parseInt(expanded, 10) % 97));
- while (checksum.length < 2) {
- checksum = "0" + checksum;
- }
- return checksum;
- }
- ;
- function getAddress(address) {
- var result = null;
- if (typeof (address) !== "string") {
- logger.throwArgumentError("invalid address", "address", address);
- }
- if (address.match(/^(0x)?[0-9a-fA-F]{40}$/)) {
- // Missing the 0x prefix
- if (address.substring(0, 2) !== "0x") {
- address = "0x" + address;
- }
- result = getChecksumAddress(address);
- // It is a checksummed address with a bad checksum
- if (address.match(/([A-F].*[a-f])|([a-f].*[A-F])/) && result !== address) {
- logger.throwArgumentError("bad address checksum", "address", address);
- }
- // Maybe ICAP? (we only support direct mode)
- }
- else if (address.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)) {
- // It is an ICAP address with a bad checksum
- if (address.substring(2, 4) !== ibanChecksum(address)) {
- logger.throwArgumentError("bad icap checksum", "address", address);
- }
- result = (0, bignumber_1._base36To16)(address.substring(4));
- while (result.length < 40) {
- result = "0" + result;
- }
- result = getChecksumAddress("0x" + result);
- }
- else {
- logger.throwArgumentError("invalid address", "address", address);
- }
- return result;
- }
- exports.getAddress = getAddress;
- function isAddress(address) {
- try {
- getAddress(address);
- return true;
- }
- catch (error) { }
- return false;
- }
- exports.isAddress = isAddress;
- function getIcapAddress(address) {
- var base36 = (0, bignumber_1._base16To36)(getAddress(address).substring(2)).toUpperCase();
- while (base36.length < 30) {
- base36 = "0" + base36;
- }
- return "XE" + ibanChecksum("XE00" + base36) + base36;
- }
- exports.getIcapAddress = getIcapAddress;
- // http://ethereum.stackexchange.com/questions/760/how-is-the-address-of-an-ethereum-contract-computed
- function getContractAddress(transaction) {
- var from = null;
- try {
- from = getAddress(transaction.from);
- }
- catch (error) {
- logger.throwArgumentError("missing from address", "transaction", transaction);
- }
- var nonce = (0, bytes_1.stripZeros)((0, bytes_1.arrayify)(bignumber_1.BigNumber.from(transaction.nonce).toHexString()));
- return getAddress((0, bytes_1.hexDataSlice)((0, keccak256_1.keccak256)((0, rlp_1.encode)([from, nonce])), 12));
- }
- exports.getContractAddress = getContractAddress;
- function getCreate2Address(from, salt, initCodeHash) {
- if ((0, bytes_1.hexDataLength)(salt) !== 32) {
- logger.throwArgumentError("salt must be 32 bytes", "salt", salt);
- }
- if ((0, bytes_1.hexDataLength)(initCodeHash) !== 32) {
- logger.throwArgumentError("initCodeHash must be 32 bytes", "initCodeHash", initCodeHash);
- }
- return getAddress((0, bytes_1.hexDataSlice)((0, keccak256_1.keccak256)((0, bytes_1.concat)(["0xff", getAddress(from), salt, initCodeHash])), 12));
- }
- exports.getCreate2Address = getCreate2Address;
- },{"./_version":188,"@ethersproject/bignumber":196,"@ethersproject/bytes":199,"@ethersproject/keccak256":221,"@ethersproject/logger":223,"@ethersproject/rlp":253}],190:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.encode = exports.decode = void 0;
- var bytes_1 = _dereq_("@ethersproject/bytes");
- function decode(textData) {
- textData = atob(textData);
- var data = [];
- for (var i = 0; i < textData.length; i++) {
- data.push(textData.charCodeAt(i));
- }
- return (0, bytes_1.arrayify)(data);
- }
- exports.decode = decode;
- function encode(data) {
- data = (0, bytes_1.arrayify)(data);
- var textData = "";
- for (var i = 0; i < data.length; i++) {
- textData += String.fromCharCode(data[i]);
- }
- return btoa(textData);
- }
- exports.encode = encode;
- },{"@ethersproject/bytes":199}],191:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.encode = exports.decode = void 0;
- var base64_1 = _dereq_("./base64");
- Object.defineProperty(exports, "decode", { enumerable: true, get: function () { return base64_1.decode; } });
- Object.defineProperty(exports, "encode", { enumerable: true, get: function () { return base64_1.encode; } });
- },{"./base64":190}],192:[function(_dereq_,module,exports){
- "use strict";
- /**
- * var basex = require("base-x");
- *
- * This implementation is heavily based on base-x. The main reason to
- * deviate was to prevent the dependency of Buffer.
- *
- * Contributors:
- *
- * base-x encoding
- * Forked from https://github.com/cryptocoinjs/bs58
- * Originally written by Mike Hearn for BitcoinJ
- * Copyright (c) 2011 Google Inc
- * Ported to JavaScript by Stefan Thomas
- * Merged Buffer refactorings from base58-native by Stephen Pair
- * Copyright (c) 2013 BitPay Inc
- *
- * The MIT License (MIT)
- *
- * Copyright base-x contributors (c) 2016
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
- * IN THE SOFTWARE.
- *
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.Base58 = exports.Base32 = exports.BaseX = void 0;
- var bytes_1 = _dereq_("@ethersproject/bytes");
- var properties_1 = _dereq_("@ethersproject/properties");
- var BaseX = /** @class */ (function () {
- function BaseX(alphabet) {
- (0, properties_1.defineReadOnly)(this, "alphabet", alphabet);
- (0, properties_1.defineReadOnly)(this, "base", alphabet.length);
- (0, properties_1.defineReadOnly)(this, "_alphabetMap", {});
- (0, properties_1.defineReadOnly)(this, "_leader", alphabet.charAt(0));
- // pre-compute lookup table
- for (var i = 0; i < alphabet.length; i++) {
- this._alphabetMap[alphabet.charAt(i)] = i;
- }
- }
- BaseX.prototype.encode = function (value) {
- var source = (0, bytes_1.arrayify)(value);
- if (source.length === 0) {
- return "";
- }
- var digits = [0];
- for (var i = 0; i < source.length; ++i) {
- var carry = source[i];
- for (var j = 0; j < digits.length; ++j) {
- carry += digits[j] << 8;
- digits[j] = carry % this.base;
- carry = (carry / this.base) | 0;
- }
- while (carry > 0) {
- digits.push(carry % this.base);
- carry = (carry / this.base) | 0;
- }
- }
- var string = "";
- // deal with leading zeros
- for (var k = 0; source[k] === 0 && k < source.length - 1; ++k) {
- string += this._leader;
- }
- // convert digits to a string
- for (var q = digits.length - 1; q >= 0; --q) {
- string += this.alphabet[digits[q]];
- }
- return string;
- };
- BaseX.prototype.decode = function (value) {
- if (typeof (value) !== "string") {
- throw new TypeError("Expected String");
- }
- var bytes = [];
- if (value.length === 0) {
- return new Uint8Array(bytes);
- }
- bytes.push(0);
- for (var i = 0; i < value.length; i++) {
- var byte = this._alphabetMap[value[i]];
- if (byte === undefined) {
- throw new Error("Non-base" + this.base + " character");
- }
- var carry = byte;
- for (var j = 0; j < bytes.length; ++j) {
- carry += bytes[j] * this.base;
- bytes[j] = carry & 0xff;
- carry >>= 8;
- }
- while (carry > 0) {
- bytes.push(carry & 0xff);
- carry >>= 8;
- }
- }
- // deal with leading zeros
- for (var k = 0; value[k] === this._leader && k < value.length - 1; ++k) {
- bytes.push(0);
- }
- return (0, bytes_1.arrayify)(new Uint8Array(bytes.reverse()));
- };
- return BaseX;
- }());
- exports.BaseX = BaseX;
- var Base32 = new BaseX("abcdefghijklmnopqrstuvwxyz234567");
- exports.Base32 = Base32;
- var Base58 = new BaseX("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");
- exports.Base58 = Base58;
- //console.log(Base58.decode("Qmd2V777o5XvJbYMeMb8k2nU5f8d3ciUQ5YpYuWhzv8iDj"))
- //console.log(Base58.encode(Base58.decode("Qmd2V777o5XvJbYMeMb8k2nU5f8d3ciUQ5YpYuWhzv8iDj")))
- },{"@ethersproject/bytes":199,"@ethersproject/properties":229}],193:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.version = void 0;
- exports.version = "bignumber/5.6.0";
- },{}],194:[function(_dereq_,module,exports){
- "use strict";
- var __importDefault = (this && this.__importDefault) || function (mod) {
- return (mod && mod.__esModule) ? mod : { "default": mod };
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- exports._base16To36 = exports._base36To16 = exports.BigNumber = exports.isBigNumberish = void 0;
- /**
- * BigNumber
- *
- * A wrapper around the BN.js object. We use the BN.js library
- * because it is used by elliptic, so it is required regardless.
- *
- */
- var bn_js_1 = __importDefault(_dereq_("bn.js"));
- var BN = bn_js_1.default.BN;
- var bytes_1 = _dereq_("@ethersproject/bytes");
- var logger_1 = _dereq_("@ethersproject/logger");
- var _version_1 = _dereq_("./_version");
- var logger = new logger_1.Logger(_version_1.version);
- var _constructorGuard = {};
- var MAX_SAFE = 0x1fffffffffffff;
- function isBigNumberish(value) {
- return (value != null) && (BigNumber.isBigNumber(value) ||
- (typeof (value) === "number" && (value % 1) === 0) ||
- (typeof (value) === "string" && !!value.match(/^-?[0-9]+$/)) ||
- (0, bytes_1.isHexString)(value) ||
- (typeof (value) === "bigint") ||
- (0, bytes_1.isBytes)(value));
- }
- exports.isBigNumberish = isBigNumberish;
- // Only warn about passing 10 into radix once
- var _warnedToStringRadix = false;
- var BigNumber = /** @class */ (function () {
- function BigNumber(constructorGuard, hex) {
- var _newTarget = this.constructor;
- logger.checkNew(_newTarget, BigNumber);
- if (constructorGuard !== _constructorGuard) {
- logger.throwError("cannot call constructor directly; use BigNumber.from", logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
- operation: "new (BigNumber)"
- });
- }
- this._hex = hex;
- this._isBigNumber = true;
- Object.freeze(this);
- }
- BigNumber.prototype.fromTwos = function (value) {
- return toBigNumber(toBN(this).fromTwos(value));
- };
- BigNumber.prototype.toTwos = function (value) {
- return toBigNumber(toBN(this).toTwos(value));
- };
- BigNumber.prototype.abs = function () {
- if (this._hex[0] === "-") {
- return BigNumber.from(this._hex.substring(1));
- }
- return this;
- };
- BigNumber.prototype.add = function (other) {
- return toBigNumber(toBN(this).add(toBN(other)));
- };
- BigNumber.prototype.sub = function (other) {
- return toBigNumber(toBN(this).sub(toBN(other)));
- };
- BigNumber.prototype.div = function (other) {
- var o = BigNumber.from(other);
- if (o.isZero()) {
- throwFault("division-by-zero", "div");
- }
- return toBigNumber(toBN(this).div(toBN(other)));
- };
- BigNumber.prototype.mul = function (other) {
- return toBigNumber(toBN(this).mul(toBN(other)));
- };
- BigNumber.prototype.mod = function (other) {
- var value = toBN(other);
- if (value.isNeg()) {
- throwFault("division-by-zero", "mod");
- }
- return toBigNumber(toBN(this).umod(value));
- };
- BigNumber.prototype.pow = function (other) {
- var value = toBN(other);
- if (value.isNeg()) {
- throwFault("negative-power", "pow");
- }
- return toBigNumber(toBN(this).pow(value));
- };
- BigNumber.prototype.and = function (other) {
- var value = toBN(other);
- if (this.isNegative() || value.isNeg()) {
- throwFault("unbound-bitwise-result", "and");
- }
- return toBigNumber(toBN(this).and(value));
- };
- BigNumber.prototype.or = function (other) {
- var value = toBN(other);
- if (this.isNegative() || value.isNeg()) {
- throwFault("unbound-bitwise-result", "or");
- }
- return toBigNumber(toBN(this).or(value));
- };
- BigNumber.prototype.xor = function (other) {
- var value = toBN(other);
- if (this.isNegative() || value.isNeg()) {
- throwFault("unbound-bitwise-result", "xor");
- }
- return toBigNumber(toBN(this).xor(value));
- };
- BigNumber.prototype.mask = function (value) {
- if (this.isNegative() || value < 0) {
- throwFault("negative-width", "mask");
- }
- return toBigNumber(toBN(this).maskn(value));
- };
- BigNumber.prototype.shl = function (value) {
- if (this.isNegative() || value < 0) {
- throwFault("negative-width", "shl");
- }
- return toBigNumber(toBN(this).shln(value));
- };
- BigNumber.prototype.shr = function (value) {
- if (this.isNegative() || value < 0) {
- throwFault("negative-width", "shr");
- }
- return toBigNumber(toBN(this).shrn(value));
- };
- BigNumber.prototype.eq = function (other) {
- return toBN(this).eq(toBN(other));
- };
- BigNumber.prototype.lt = function (other) {
- return toBN(this).lt(toBN(other));
- };
- BigNumber.prototype.lte = function (other) {
- return toBN(this).lte(toBN(other));
- };
- BigNumber.prototype.gt = function (other) {
- return toBN(this).gt(toBN(other));
- };
- BigNumber.prototype.gte = function (other) {
- return toBN(this).gte(toBN(other));
- };
- BigNumber.prototype.isNegative = function () {
- return (this._hex[0] === "-");
- };
- BigNumber.prototype.isZero = function () {
- return toBN(this).isZero();
- };
- BigNumber.prototype.toNumber = function () {
- try {
- return toBN(this).toNumber();
- }
- catch (error) {
- throwFault("overflow", "toNumber", this.toString());
- }
- return null;
- };
- BigNumber.prototype.toBigInt = function () {
- try {
- return BigInt(this.toString());
- }
- catch (e) { }
- return logger.throwError("this platform does not support BigInt", logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
- value: this.toString()
- });
- };
- BigNumber.prototype.toString = function () {
- // Lots of people expect this, which we do not support, so check (See: #889)
- if (arguments.length > 0) {
- if (arguments[0] === 10) {
- if (!_warnedToStringRadix) {
- _warnedToStringRadix = true;
- logger.warn("BigNumber.toString does not accept any parameters; base-10 is assumed");
- }
- }
- else if (arguments[0] === 16) {
- logger.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()", logger_1.Logger.errors.UNEXPECTED_ARGUMENT, {});
- }
- else {
- logger.throwError("BigNumber.toString does not accept parameters", logger_1.Logger.errors.UNEXPECTED_ARGUMENT, {});
- }
- }
- return toBN(this).toString(10);
- };
- BigNumber.prototype.toHexString = function () {
- return this._hex;
- };
- BigNumber.prototype.toJSON = function (key) {
- return { type: "BigNumber", hex: this.toHexString() };
- };
- BigNumber.from = function (value) {
- if (value instanceof BigNumber) {
- return value;
- }
- if (typeof (value) === "string") {
- if (value.match(/^-?0x[0-9a-f]+$/i)) {
- return new BigNumber(_constructorGuard, toHex(value));
- }
- if (value.match(/^-?[0-9]+$/)) {
- return new BigNumber(_constructorGuard, toHex(new BN(value)));
- }
- return logger.throwArgumentError("invalid BigNumber string", "value", value);
- }
- if (typeof (value) === "number") {
- if (value % 1) {
- throwFault("underflow", "BigNumber.from", value);
- }
- if (value >= MAX_SAFE || value <= -MAX_SAFE) {
- throwFault("overflow", "BigNumber.from", value);
- }
- return BigNumber.from(String(value));
- }
- var anyValue = value;
- if (typeof (anyValue) === "bigint") {
- return BigNumber.from(anyValue.toString());
- }
- if ((0, bytes_1.isBytes)(anyValue)) {
- return BigNumber.from((0, bytes_1.hexlify)(anyValue));
- }
- if (anyValue) {
- // Hexable interface (takes priority)
- if (anyValue.toHexString) {
- var hex = anyValue.toHexString();
- if (typeof (hex) === "string") {
- return BigNumber.from(hex);
- }
- }
- else {
- // For now, handle legacy JSON-ified values (goes away in v6)
- var hex = anyValue._hex;
- // New-form JSON
- if (hex == null && anyValue.type === "BigNumber") {
- hex = anyValue.hex;
- }
- if (typeof (hex) === "string") {
- if ((0, bytes_1.isHexString)(hex) || (hex[0] === "-" && (0, bytes_1.isHexString)(hex.substring(1)))) {
- return BigNumber.from(hex);
- }
- }
- }
- }
- return logger.throwArgumentError("invalid BigNumber value", "value", value);
- };
- BigNumber.isBigNumber = function (value) {
- return !!(value && value._isBigNumber);
- };
- return BigNumber;
- }());
- exports.BigNumber = BigNumber;
- // Normalize the hex string
- function toHex(value) {
- // For BN, call on the hex string
- if (typeof (value) !== "string") {
- return toHex(value.toString(16));
- }
- // If negative, prepend the negative sign to the normalized positive value
- if (value[0] === "-") {
- // Strip off the negative sign
- value = value.substring(1);
- // Cannot have multiple negative signs (e.g. "--0x04")
- if (value[0] === "-") {
- logger.throwArgumentError("invalid hex", "value", value);
- }
- // Call toHex on the positive component
- value = toHex(value);
- // Do not allow "-0x00"
- if (value === "0x00") {
- return value;
- }
- // Negate the value
- return "-" + value;
- }
- // Add a "0x" prefix if missing
- if (value.substring(0, 2) !== "0x") {
- value = "0x" + value;
- }
- // Normalize zero
- if (value === "0x") {
- return "0x00";
- }
- // Make the string even length
- if (value.length % 2) {
- value = "0x0" + value.substring(2);
- }
- // Trim to smallest even-length string
- while (value.length > 4 && value.substring(0, 4) === "0x00") {
- value = "0x" + value.substring(4);
- }
- return value;
- }
- function toBigNumber(value) {
- return BigNumber.from(toHex(value));
- }
- function toBN(value) {
- var hex = BigNumber.from(value).toHexString();
- if (hex[0] === "-") {
- return (new BN("-" + hex.substring(3), 16));
- }
- return new BN(hex.substring(2), 16);
- }
- function throwFault(fault, operation, value) {
- var params = { fault: fault, operation: operation };
- if (value != null) {
- params.value = value;
- }
- return logger.throwError(fault, logger_1.Logger.errors.NUMERIC_FAULT, params);
- }
- // value should have no prefix
- function _base36To16(value) {
- return (new BN(value, 36)).toString(16);
- }
- exports._base36To16 = _base36To16;
- // value should have no prefix
- function _base16To36(value) {
- return (new BN(value, 16)).toString(36);
- }
- exports._base16To36 = _base16To36;
- },{"./_version":193,"@ethersproject/bytes":199,"@ethersproject/logger":223,"bn.js":197}],195:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.FixedNumber = exports.FixedFormat = exports.parseFixed = exports.formatFixed = void 0;
- var bytes_1 = _dereq_("@ethersproject/bytes");
- var logger_1 = _dereq_("@ethersproject/logger");
- var _version_1 = _dereq_("./_version");
- var logger = new logger_1.Logger(_version_1.version);
- var bignumber_1 = _dereq_("./bignumber");
- var _constructorGuard = {};
- var Zero = bignumber_1.BigNumber.from(0);
- var NegativeOne = bignumber_1.BigNumber.from(-1);
- function throwFault(message, fault, operation, value) {
- var params = { fault: fault, operation: operation };
- if (value !== undefined) {
- params.value = value;
- }
- return logger.throwError(message, logger_1.Logger.errors.NUMERIC_FAULT, params);
- }
- // Constant to pull zeros from for multipliers
- var zeros = "0";
- while (zeros.length < 256) {
- zeros += zeros;
- }
- // Returns a string "1" followed by decimal "0"s
- function getMultiplier(decimals) {
- if (typeof (decimals) !== "number") {
- try {
- decimals = bignumber_1.BigNumber.from(decimals).toNumber();
- }
- catch (e) { }
- }
- if (typeof (decimals) === "number" && decimals >= 0 && decimals <= 256 && !(decimals % 1)) {
- return ("1" + zeros.substring(0, decimals));
- }
- return logger.throwArgumentError("invalid decimal size", "decimals", decimals);
- }
- function formatFixed(value, decimals) {
- if (decimals == null) {
- decimals = 0;
- }
- var multiplier = getMultiplier(decimals);
- // Make sure wei is a big number (convert as necessary)
- value = bignumber_1.BigNumber.from(value);
- var negative = value.lt(Zero);
- if (negative) {
- value = value.mul(NegativeOne);
- }
- var fraction = value.mod(multiplier).toString();
- while (fraction.length < multiplier.length - 1) {
- fraction = "0" + fraction;
- }
- // Strip training 0
- fraction = fraction.match(/^([0-9]*[1-9]|0)(0*)/)[1];
- var whole = value.div(multiplier).toString();
- if (multiplier.length === 1) {
- value = whole;
- }
- else {
- value = whole + "." + fraction;
- }
- if (negative) {
- value = "-" + value;
- }
- return value;
- }
- exports.formatFixed = formatFixed;
- function parseFixed(value, decimals) {
- if (decimals == null) {
- decimals = 0;
- }
- var multiplier = getMultiplier(decimals);
- if (typeof (value) !== "string" || !value.match(/^-?[0-9.]+$/)) {
- logger.throwArgumentError("invalid decimal value", "value", value);
- }
- // Is it negative?
- var negative = (value.substring(0, 1) === "-");
- if (negative) {
- value = value.substring(1);
- }
- if (value === ".") {
- logger.throwArgumentError("missing value", "value", value);
- }
- // Split it into a whole and fractional part
- var comps = value.split(".");
- if (comps.length > 2) {
- logger.throwArgumentError("too many decimal points", "value", value);
- }
- var whole = comps[0], fraction = comps[1];
- if (!whole) {
- whole = "0";
- }
- if (!fraction) {
- fraction = "0";
- }
- // Trim trailing zeros
- while (fraction[fraction.length - 1] === "0") {
- fraction = fraction.substring(0, fraction.length - 1);
- }
- // Check the fraction doesn't exceed our decimals size
- if (fraction.length > multiplier.length - 1) {
- throwFault("fractional component exceeds decimals", "underflow", "parseFixed");
- }
- // If decimals is 0, we have an empty string for fraction
- if (fraction === "") {
- fraction = "0";
- }
- // Fully pad the string with zeros to get to wei
- while (fraction.length < multiplier.length - 1) {
- fraction += "0";
- }
- var wholeValue = bignumber_1.BigNumber.from(whole);
- var fractionValue = bignumber_1.BigNumber.from(fraction);
- var wei = (wholeValue.mul(multiplier)).add(fractionValue);
- if (negative) {
- wei = wei.mul(NegativeOne);
- }
- return wei;
- }
- exports.parseFixed = parseFixed;
- var FixedFormat = /** @class */ (function () {
- function FixedFormat(constructorGuard, signed, width, decimals) {
- if (constructorGuard !== _constructorGuard) {
- logger.throwError("cannot use FixedFormat constructor; use FixedFormat.from", logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
- operation: "new FixedFormat"
- });
- }
- this.signed = signed;
- this.width = width;
- this.decimals = decimals;
- this.name = (signed ? "" : "u") + "fixed" + String(width) + "x" + String(decimals);
- this._multiplier = getMultiplier(decimals);
- Object.freeze(this);
- }
- FixedFormat.from = function (value) {
- if (value instanceof FixedFormat) {
- return value;
- }
- if (typeof (value) === "number") {
- value = "fixed128x" + value;
- }
- var signed = true;
- var width = 128;
- var decimals = 18;
- if (typeof (value) === "string") {
- if (value === "fixed") {
- // defaults...
- }
- else if (value === "ufixed") {
- signed = false;
- }
- else {
- var match = value.match(/^(u?)fixed([0-9]+)x([0-9]+)$/);
- if (!match) {
- logger.throwArgumentError("invalid fixed format", "format", value);
- }
- signed = (match[1] !== "u");
- width = parseInt(match[2]);
- decimals = parseInt(match[3]);
- }
- }
- else if (value) {
- var check = function (key, type, defaultValue) {
- if (value[key] == null) {
- return defaultValue;
- }
- if (typeof (value[key]) !== type) {
- logger.throwArgumentError("invalid fixed format (" + key + " not " + type + ")", "format." + key, value[key]);
- }
- return value[key];
- };
- signed = check("signed", "boolean", signed);
- width = check("width", "number", width);
- decimals = check("decimals", "number", decimals);
- }
- if (width % 8) {
- logger.throwArgumentError("invalid fixed format width (not byte aligned)", "format.width", width);
- }
- if (decimals > 80) {
- logger.throwArgumentError("invalid fixed format (decimals too large)", "format.decimals", decimals);
- }
- return new FixedFormat(_constructorGuard, signed, width, decimals);
- };
- return FixedFormat;
- }());
- exports.FixedFormat = FixedFormat;
- var FixedNumber = /** @class */ (function () {
- function FixedNumber(constructorGuard, hex, value, format) {
- var _newTarget = this.constructor;
- logger.checkNew(_newTarget, FixedNumber);
- if (constructorGuard !== _constructorGuard) {
- logger.throwError("cannot use FixedNumber constructor; use FixedNumber.from", logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
- operation: "new FixedFormat"
- });
- }
- this.format = format;
- this._hex = hex;
- this._value = value;
- this._isFixedNumber = true;
- Object.freeze(this);
- }
- FixedNumber.prototype._checkFormat = function (other) {
- if (this.format.name !== other.format.name) {
- logger.throwArgumentError("incompatible format; use fixedNumber.toFormat", "other", other);
- }
- };
- FixedNumber.prototype.addUnsafe = function (other) {
- this._checkFormat(other);
- var a = parseFixed(this._value, this.format.decimals);
- var b = parseFixed(other._value, other.format.decimals);
- return FixedNumber.fromValue(a.add(b), this.format.decimals, this.format);
- };
- FixedNumber.prototype.subUnsafe = function (other) {
- this._checkFormat(other);
- var a = parseFixed(this._value, this.format.decimals);
- var b = parseFixed(other._value, other.format.decimals);
- return FixedNumber.fromValue(a.sub(b), this.format.decimals, this.format);
- };
- FixedNumber.prototype.mulUnsafe = function (other) {
- this._checkFormat(other);
- var a = parseFixed(this._value, this.format.decimals);
- var b = parseFixed(other._value, other.format.decimals);
- return FixedNumber.fromValue(a.mul(b).div(this.format._multiplier), this.format.decimals, this.format);
- };
- FixedNumber.prototype.divUnsafe = function (other) {
- this._checkFormat(other);
- var a = parseFixed(this._value, this.format.decimals);
- var b = parseFixed(other._value, other.format.decimals);
- return FixedNumber.fromValue(a.mul(this.format._multiplier).div(b), this.format.decimals, this.format);
- };
- FixedNumber.prototype.floor = function () {
- var comps = this.toString().split(".");
- if (comps.length === 1) {
- comps.push("0");
- }
- var result = FixedNumber.from(comps[0], this.format);
- var hasFraction = !comps[1].match(/^(0*)$/);
- if (this.isNegative() && hasFraction) {
- result = result.subUnsafe(ONE.toFormat(result.format));
- }
- return result;
- };
- FixedNumber.prototype.ceiling = function () {
- var comps = this.toString().split(".");
- if (comps.length === 1) {
- comps.push("0");
- }
- var result = FixedNumber.from(comps[0], this.format);
- var hasFraction = !comps[1].match(/^(0*)$/);
- if (!this.isNegative() && hasFraction) {
- result = result.addUnsafe(ONE.toFormat(result.format));
- }
- return result;
- };
- // @TODO: Support other rounding algorithms
- FixedNumber.prototype.round = function (decimals) {
- if (decimals == null) {
- decimals = 0;
- }
- // If we are already in range, we're done
- var comps = this.toString().split(".");
- if (comps.length === 1) {
- comps.push("0");
- }
- if (decimals < 0 || decimals > 80 || (decimals % 1)) {
- logger.throwArgumentError("invalid decimal count", "decimals", decimals);
- }
- if (comps[1].length <= decimals) {
- return this;
- }
- var factor = FixedNumber.from("1" + zeros.substring(0, decimals), this.format);
- var bump = BUMP.toFormat(this.format);
- return this.mulUnsafe(factor).addUnsafe(bump).floor().divUnsafe(factor);
- };
- FixedNumber.prototype.isZero = function () {
- return (this._value === "0.0" || this._value === "0");
- };
- FixedNumber.prototype.isNegative = function () {
- return (this._value[0] === "-");
- };
- FixedNumber.prototype.toString = function () { return this._value; };
- FixedNumber.prototype.toHexString = function (width) {
- if (width == null) {
- return this._hex;
- }
- if (width % 8) {
- logger.throwArgumentError("invalid byte width", "width", width);
- }
- var hex = bignumber_1.BigNumber.from(this._hex).fromTwos(this.format.width).toTwos(width).toHexString();
- return (0, bytes_1.hexZeroPad)(hex, width / 8);
- };
- FixedNumber.prototype.toUnsafeFloat = function () { return parseFloat(this.toString()); };
- FixedNumber.prototype.toFormat = function (format) {
- return FixedNumber.fromString(this._value, format);
- };
- FixedNumber.fromValue = function (value, decimals, format) {
- // If decimals looks more like a format, and there is no format, shift the parameters
- if (format == null && decimals != null && !(0, bignumber_1.isBigNumberish)(decimals)) {
- format = decimals;
- decimals = null;
- }
- if (decimals == null) {
- decimals = 0;
- }
- if (format == null) {
- format = "fixed";
- }
- return FixedNumber.fromString(formatFixed(value, decimals), FixedFormat.from(format));
- };
- FixedNumber.fromString = function (value, format) {
- if (format == null) {
- format = "fixed";
- }
- var fixedFormat = FixedFormat.from(format);
- var numeric = parseFixed(value, fixedFormat.decimals);
- if (!fixedFormat.signed && numeric.lt(Zero)) {
- throwFault("unsigned value cannot be negative", "overflow", "value", value);
- }
- var hex = null;
- if (fixedFormat.signed) {
- hex = numeric.toTwos(fixedFormat.width).toHexString();
- }
- else {
- hex = numeric.toHexString();
- hex = (0, bytes_1.hexZeroPad)(hex, fixedFormat.width / 8);
- }
- var decimal = formatFixed(numeric, fixedFormat.decimals);
- return new FixedNumber(_constructorGuard, hex, decimal, fixedFormat);
- };
- FixedNumber.fromBytes = function (value, format) {
- if (format == null) {
- format = "fixed";
- }
- var fixedFormat = FixedFormat.from(format);
- if ((0, bytes_1.arrayify)(value).length > fixedFormat.width / 8) {
- throw new Error("overflow");
- }
- var numeric = bignumber_1.BigNumber.from(value);
- if (fixedFormat.signed) {
- numeric = numeric.fromTwos(fixedFormat.width);
- }
- var hex = numeric.toTwos((fixedFormat.signed ? 0 : 1) + fixedFormat.width).toHexString();
- var decimal = formatFixed(numeric, fixedFormat.decimals);
- return new FixedNumber(_constructorGuard, hex, decimal, fixedFormat);
- };
- FixedNumber.from = function (value, format) {
- if (typeof (value) === "string") {
- return FixedNumber.fromString(value, format);
- }
- if ((0, bytes_1.isBytes)(value)) {
- return FixedNumber.fromBytes(value, format);
- }
- try {
- return FixedNumber.fromValue(value, 0, format);
- }
- catch (error) {
- // Allow NUMERIC_FAULT to bubble up
- if (error.code !== logger_1.Logger.errors.INVALID_ARGUMENT) {
- throw error;
- }
- }
- return logger.throwArgumentError("invalid FixedNumber value", "value", value);
- };
- FixedNumber.isFixedNumber = function (value) {
- return !!(value && value._isFixedNumber);
- };
- return FixedNumber;
- }());
- exports.FixedNumber = FixedNumber;
- var ONE = FixedNumber.from(1);
- var BUMP = FixedNumber.from("0.5");
- },{"./_version":193,"./bignumber":194,"@ethersproject/bytes":199,"@ethersproject/logger":223}],196:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports._base36To16 = exports._base16To36 = exports.parseFixed = exports.FixedNumber = exports.FixedFormat = exports.formatFixed = exports.BigNumber = void 0;
- var bignumber_1 = _dereq_("./bignumber");
- Object.defineProperty(exports, "BigNumber", { enumerable: true, get: function () { return bignumber_1.BigNumber; } });
- var fixednumber_1 = _dereq_("./fixednumber");
- Object.defineProperty(exports, "formatFixed", { enumerable: true, get: function () { return fixednumber_1.formatFixed; } });
- Object.defineProperty(exports, "FixedFormat", { enumerable: true, get: function () { return fixednumber_1.FixedFormat; } });
- Object.defineProperty(exports, "FixedNumber", { enumerable: true, get: function () { return fixednumber_1.FixedNumber; } });
- Object.defineProperty(exports, "parseFixed", { enumerable: true, get: function () { return fixednumber_1.parseFixed; } });
- // Internal methods used by address
- var bignumber_2 = _dereq_("./bignumber");
- Object.defineProperty(exports, "_base16To36", { enumerable: true, get: function () { return bignumber_2._base16To36; } });
- Object.defineProperty(exports, "_base36To16", { enumerable: true, get: function () { return bignumber_2._base36To16; } });
- },{"./bignumber":194,"./fixednumber":195}],197:[function(_dereq_,module,exports){
- (function (module, exports) {
- 'use strict';
- // Utils
- function assert (val, msg) {
- if (!val) throw new Error(msg || 'Assertion failed');
- }
- // Could use `inherits` module, but don't want to move from single file
- // architecture yet.
- function inherits (ctor, superCtor) {
- ctor.super_ = superCtor;
- var TempCtor = function () {};
- TempCtor.prototype = superCtor.prototype;
- ctor.prototype = new TempCtor();
- ctor.prototype.constructor = ctor;
- }
- // BN
- function BN (number, base, endian) {
- if (BN.isBN(number)) {
- return number;
- }
- this.negative = 0;
- this.words = null;
- this.length = 0;
- // Reduction context
- this.red = null;
- if (number !== null) {
- if (base === 'le' || base === 'be') {
- endian = base;
- base = 10;
- }
- this._init(number || 0, base || 10, endian || 'be');
- }
- }
- if (typeof module === 'object') {
- module.exports = BN;
- } else {
- exports.BN = BN;
- }
- BN.BN = BN;
- BN.wordSize = 26;
- var Buffer;
- try {
- if (typeof window !== 'undefined' && typeof window.Buffer !== 'undefined') {
- Buffer = window.Buffer;
- } else {
- Buffer = _dereq_('buffer').Buffer;
- }
- } catch (e) {
- }
- BN.isBN = function isBN (num) {
- if (num instanceof BN) {
- return true;
- }
- return num !== null && typeof num === 'object' &&
- num.constructor.wordSize === BN.wordSize && Array.isArray(num.words);
- };
- BN.max = function max (left, right) {
- if (left.cmp(right) > 0) return left;
- return right;
- };
- BN.min = function min (left, right) {
- if (left.cmp(right) < 0) return left;
- return right;
- };
- BN.prototype._init = function init (number, base, endian) {
- if (typeof number === 'number') {
- return this._initNumber(number, base, endian);
- }
- if (typeof number === 'object') {
- return this._initArray(number, base, endian);
- }
- if (base === 'hex') {
- base = 16;
- }
- assert(base === (base | 0) && base >= 2 && base <= 36);
- number = number.toString().replace(/\s+/g, '');
- var start = 0;
- if (number[0] === '-') {
- start++;
- this.negative = 1;
- }
- if (start < number.length) {
- if (base === 16) {
- this._parseHex(number, start, endian);
- } else {
- this._parseBase(number, base, start);
- if (endian === 'le') {
- this._initArray(this.toArray(), base, endian);
- }
- }
- }
- };
- BN.prototype._initNumber = function _initNumber (number, base, endian) {
- if (number < 0) {
- this.negative = 1;
- number = -number;
- }
- if (number < 0x4000000) {
- this.words = [ number & 0x3ffffff ];
- this.length = 1;
- } else if (number < 0x10000000000000) {
- this.words = [
- number & 0x3ffffff,
- (number / 0x4000000) & 0x3ffffff
- ];
- this.length = 2;
- } else {
- assert(number < 0x20000000000000); // 2 ^ 53 (unsafe)
- this.words = [
- number & 0x3ffffff,
- (number / 0x4000000) & 0x3ffffff,
- 1
- ];
- this.length = 3;
- }
- if (endian !== 'le') return;
- // Reverse the bytes
- this._initArray(this.toArray(), base, endian);
- };
- BN.prototype._initArray = function _initArray (number, base, endian) {
- // Perhaps a Uint8Array
- assert(typeof number.length === 'number');
- if (number.length <= 0) {
- this.words = [ 0 ];
- this.length = 1;
- return this;
- }
- this.length = Math.ceil(number.length / 3);
- this.words = new Array(this.length);
- for (var i = 0; i < this.length; i++) {
- this.words[i] = 0;
- }
- var j, w;
- var off = 0;
- if (endian === 'be') {
- for (i = number.length - 1, j = 0; i >= 0; i -= 3) {
- w = number[i] | (number[i - 1] << 8) | (number[i - 2] << 16);
- this.words[j] |= (w << off) & 0x3ffffff;
- this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff;
- off += 24;
- if (off >= 26) {
- off -= 26;
- j++;
- }
- }
- } else if (endian === 'le') {
- for (i = 0, j = 0; i < number.length; i += 3) {
- w = number[i] | (number[i + 1] << 8) | (number[i + 2] << 16);
- this.words[j] |= (w << off) & 0x3ffffff;
- this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff;
- off += 24;
- if (off >= 26) {
- off -= 26;
- j++;
- }
- }
- }
- return this.strip();
- };
- function parseHex4Bits (string, index) {
- var c = string.charCodeAt(index);
- // 'A' - 'F'
- if (c >= 65 && c <= 70) {
- return c - 55;
- // 'a' - 'f'
- } else if (c >= 97 && c <= 102) {
- return c - 87;
- // '0' - '9'
- } else {
- return (c - 48) & 0xf;
- }
- }
- function parseHexByte (string, lowerBound, index) {
- var r = parseHex4Bits(string, index);
- if (index - 1 >= lowerBound) {
- r |= parseHex4Bits(string, index - 1) << 4;
- }
- return r;
- }
- BN.prototype._parseHex = function _parseHex (number, start, endian) {
- // Create possibly bigger array to ensure that it fits the number
- this.length = Math.ceil((number.length - start) / 6);
- this.words = new Array(this.length);
- for (var i = 0; i < this.length; i++) {
- this.words[i] = 0;
- }
- // 24-bits chunks
- var off = 0;
- var j = 0;
- var w;
- if (endian === 'be') {
- for (i = number.length - 1; i >= start; i -= 2) {
- w = parseHexByte(number, start, i) << off;
- this.words[j] |= w & 0x3ffffff;
- if (off >= 18) {
- off -= 18;
- j += 1;
- this.words[j] |= w >>> 26;
- } else {
- off += 8;
- }
- }
- } else {
- var parseLength = number.length - start;
- for (i = parseLength % 2 === 0 ? start + 1 : start; i < number.length; i += 2) {
- w = parseHexByte(number, start, i) << off;
- this.words[j] |= w & 0x3ffffff;
- if (off >= 18) {
- off -= 18;
- j += 1;
- this.words[j] |= w >>> 26;
- } else {
- off += 8;
- }
- }
- }
- this.strip();
- };
- function parseBase (str, start, end, mul) {
- var r = 0;
- var len = Math.min(str.length, end);
- for (var i = start; i < len; i++) {
- var c = str.charCodeAt(i) - 48;
- r *= mul;
- // 'a'
- if (c >= 49) {
- r += c - 49 + 0xa;
- // 'A'
- } else if (c >= 17) {
- r += c - 17 + 0xa;
- // '0' - '9'
- } else {
- r += c;
- }
- }
- return r;
- }
- BN.prototype._parseBase = function _parseBase (number, base, start) {
- // Initialize as zero
- this.words = [ 0 ];
- this.length = 1;
- // Find length of limb in base
- for (var limbLen = 0, limbPow = 1; limbPow <= 0x3ffffff; limbPow *= base) {
- limbLen++;
- }
- limbLen--;
- limbPow = (limbPow / base) | 0;
- var total = number.length - start;
- var mod = total % limbLen;
- var end = Math.min(total, total - mod) + start;
- var word = 0;
- for (var i = start; i < end; i += limbLen) {
- word = parseBase(number, i, i + limbLen, base);
- this.imuln(limbPow);
- if (this.words[0] + word < 0x4000000) {
- this.words[0] += word;
- } else {
- this._iaddn(word);
- }
- }
- if (mod !== 0) {
- var pow = 1;
- word = parseBase(number, i, number.length, base);
- for (i = 0; i < mod; i++) {
- pow *= base;
- }
- this.imuln(pow);
- if (this.words[0] + word < 0x4000000) {
- this.words[0] += word;
- } else {
- this._iaddn(word);
- }
- }
- this.strip();
- };
- BN.prototype.copy = function copy (dest) {
- dest.words = new Array(this.length);
- for (var i = 0; i < this.length; i++) {
- dest.words[i] = this.words[i];
- }
- dest.length = this.length;
- dest.negative = this.negative;
- dest.red = this.red;
- };
- BN.prototype.clone = function clone () {
- var r = new BN(null);
- this.copy(r);
- return r;
- };
- BN.prototype._expand = function _expand (size) {
- while (this.length < size) {
- this.words[this.length++] = 0;
- }
- return this;
- };
- // Remove leading `0` from `this`
- BN.prototype.strip = function strip () {
- while (this.length > 1 && this.words[this.length - 1] === 0) {
- this.length--;
- }
- return this._normSign();
- };
- BN.prototype._normSign = function _normSign () {
- // -0 = 0
- if (this.length === 1 && this.words[0] === 0) {
- this.negative = 0;
- }
- return this;
- };
- BN.prototype.inspect = function inspect () {
- return (this.red ? '<BN-R: ' : '<BN: ') + this.toString(16) + '>';
- };
- /*
- var zeros = [];
- var groupSizes = [];
- var groupBases = [];
- var s = '';
- var i = -1;
- while (++i < BN.wordSize) {
- zeros[i] = s;
- s += '0';
- }
- groupSizes[0] = 0;
- groupSizes[1] = 0;
- groupBases[0] = 0;
- groupBases[1] = 0;
- var base = 2 - 1;
- while (++base < 36 + 1) {
- var groupSize = 0;
- var groupBase = 1;
- while (groupBase < (1 << BN.wordSize) / base) {
- groupBase *= base;
- groupSize += 1;
- }
- groupSizes[base] = groupSize;
- groupBases[base] = groupBase;
- }
- */
- var zeros = [
- '',
- '0',
- '00',
- '000',
- '0000',
- '00000',
- '000000',
- '0000000',
- '00000000',
- '000000000',
- '0000000000',
- '00000000000',
- '000000000000',
- '0000000000000',
- '00000000000000',
- '000000000000000',
- '0000000000000000',
- '00000000000000000',
- '000000000000000000',
- '0000000000000000000',
- '00000000000000000000',
- '000000000000000000000',
- '0000000000000000000000',
- '00000000000000000000000',
- '000000000000000000000000',
- '0000000000000000000000000'
- ];
- var groupSizes = [
- 0, 0,
- 25, 16, 12, 11, 10, 9, 8,
- 8, 7, 7, 7, 7, 6, 6,
- 6, 6, 6, 6, 6, 5, 5,
- 5, 5, 5, 5, 5, 5, 5,
- 5, 5, 5, 5, 5, 5, 5
- ];
- var groupBases = [
- 0, 0,
- 33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216,
- 43046721, 10000000, 19487171, 35831808, 62748517, 7529536, 11390625,
- 16777216, 24137569, 34012224, 47045881, 64000000, 4084101, 5153632,
- 6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149,
- 24300000, 28629151, 33554432, 39135393, 45435424, 52521875, 60466176
- ];
- BN.prototype.toString = function toString (base, padding) {
- base = base || 10;
- padding = padding | 0 || 1;
- var out;
- if (base === 16 || base === 'hex') {
- out = '';
- var off = 0;
- var carry = 0;
- for (var i = 0; i < this.length; i++) {
- var w = this.words[i];
- var word = (((w << off) | carry) & 0xffffff).toString(16);
- carry = (w >>> (24 - off)) & 0xffffff;
- if (carry !== 0 || i !== this.length - 1) {
- out = zeros[6 - word.length] + word + out;
- } else {
- out = word + out;
- }
- off += 2;
- if (off >= 26) {
- off -= 26;
- i--;
- }
- }
- if (carry !== 0) {
- out = carry.toString(16) + out;
- }
- while (out.length % padding !== 0) {
- out = '0' + out;
- }
- if (this.negative !== 0) {
- out = '-' + out;
- }
- return out;
- }
- if (base === (base | 0) && base >= 2 && base <= 36) {
- // var groupSize = Math.floor(BN.wordSize * Math.LN2 / Math.log(base));
- var groupSize = groupSizes[base];
- // var groupBase = Math.pow(base, groupSize);
- var groupBase = groupBases[base];
- out = '';
- var c = this.clone();
- c.negative = 0;
- while (!c.isZero()) {
- var r = c.modn(groupBase).toString(base);
- c = c.idivn(groupBase);
- if (!c.isZero()) {
- out = zeros[groupSize - r.length] + r + out;
- } else {
- out = r + out;
- }
- }
- if (this.isZero()) {
- out = '0' + out;
- }
- while (out.length % padding !== 0) {
- out = '0' + out;
- }
- if (this.negative !== 0) {
- out = '-' + out;
- }
- return out;
- }
- assert(false, 'Base should be between 2 and 36');
- };
- BN.prototype.toNumber = function toNumber () {
- var ret = this.words[0];
- if (this.length === 2) {
- ret += this.words[1] * 0x4000000;
- } else if (this.length === 3 && this.words[2] === 0x01) {
- // NOTE: at this stage it is known that the top bit is set
- ret += 0x10000000000000 + (this.words[1] * 0x4000000);
- } else if (this.length > 2) {
- assert(false, 'Number can only safely store up to 53 bits');
- }
- return (this.negative !== 0) ? -ret : ret;
- };
- BN.prototype.toJSON = function toJSON () {
- return this.toString(16);
- };
- BN.prototype.toBuffer = function toBuffer (endian, length) {
- assert(typeof Buffer !== 'undefined');
- return this.toArrayLike(Buffer, endian, length);
- };
- BN.prototype.toArray = function toArray (endian, length) {
- return this.toArrayLike(Array, endian, length);
- };
- BN.prototype.toArrayLike = function toArrayLike (ArrayType, endian, length) {
- var byteLength = this.byteLength();
- var reqLength = length || Math.max(1, byteLength);
- assert(byteLength <= reqLength, 'byte array longer than desired length');
- assert(reqLength > 0, 'Requested array length <= 0');
- this.strip();
- var littleEndian = endian === 'le';
- var res = new ArrayType(reqLength);
- var b, i;
- var q = this.clone();
- if (!littleEndian) {
- // Assume big-endian
- for (i = 0; i < reqLength - byteLength; i++) {
- res[i] = 0;
- }
- for (i = 0; !q.isZero(); i++) {
- b = q.andln(0xff);
- q.iushrn(8);
- res[reqLength - i - 1] = b;
- }
- } else {
- for (i = 0; !q.isZero(); i++) {
- b = q.andln(0xff);
- q.iushrn(8);
- res[i] = b;
- }
- for (; i < reqLength; i++) {
- res[i] = 0;
- }
- }
- return res;
- };
- if (Math.clz32) {
- BN.prototype._countBits = function _countBits (w) {
- return 32 - Math.clz32(w);
- };
- } else {
- BN.prototype._countBits = function _countBits (w) {
- var t = w;
- var r = 0;
- if (t >= 0x1000) {
- r += 13;
- t >>>= 13;
- }
- if (t >= 0x40) {
- r += 7;
- t >>>= 7;
- }
- if (t >= 0x8) {
- r += 4;
- t >>>= 4;
- }
- if (t >= 0x02) {
- r += 2;
- t >>>= 2;
- }
- return r + t;
- };
- }
- BN.prototype._zeroBits = function _zeroBits (w) {
- // Short-cut
- if (w === 0) return 26;
- var t = w;
- var r = 0;
- if ((t & 0x1fff) === 0) {
- r += 13;
- t >>>= 13;
- }
- if ((t & 0x7f) === 0) {
- r += 7;
- t >>>= 7;
- }
- if ((t & 0xf) === 0) {
- r += 4;
- t >>>= 4;
- }
- if ((t & 0x3) === 0) {
- r += 2;
- t >>>= 2;
- }
- if ((t & 0x1) === 0) {
- r++;
- }
- return r;
- };
- // Return number of used bits in a BN
- BN.prototype.bitLength = function bitLength () {
- var w = this.words[this.length - 1];
- var hi = this._countBits(w);
- return (this.length - 1) * 26 + hi;
- };
- function toBitArray (num) {
- var w = new Array(num.bitLength());
- for (var bit = 0; bit < w.length; bit++) {
- var off = (bit / 26) | 0;
- var wbit = bit % 26;
- w[bit] = (num.words[off] & (1 << wbit)) >>> wbit;
- }
- return w;
- }
- // Number of trailing zero bits
- BN.prototype.zeroBits = function zeroBits () {
- if (this.isZero()) return 0;
- var r = 0;
- for (var i = 0; i < this.length; i++) {
- var b = this._zeroBits(this.words[i]);
- r += b;
- if (b !== 26) break;
- }
- return r;
- };
- BN.prototype.byteLength = function byteLength () {
- return Math.ceil(this.bitLength() / 8);
- };
- BN.prototype.toTwos = function toTwos (width) {
- if (this.negative !== 0) {
- return this.abs().inotn(width).iaddn(1);
- }
- return this.clone();
- };
- BN.prototype.fromTwos = function fromTwos (width) {
- if (this.testn(width - 1)) {
- return this.notn(width).iaddn(1).ineg();
- }
- return this.clone();
- };
- BN.prototype.isNeg = function isNeg () {
- return this.negative !== 0;
- };
- // Return negative clone of `this`
- BN.prototype.neg = function neg () {
- return this.clone().ineg();
- };
- BN.prototype.ineg = function ineg () {
- if (!this.isZero()) {
- this.negative ^= 1;
- }
- return this;
- };
- // Or `num` with `this` in-place
- BN.prototype.iuor = function iuor (num) {
- while (this.length < num.length) {
- this.words[this.length++] = 0;
- }
- for (var i = 0; i < num.length; i++) {
- this.words[i] = this.words[i] | num.words[i];
- }
- return this.strip();
- };
- BN.prototype.ior = function ior (num) {
- assert((this.negative | num.negative) === 0);
- return this.iuor(num);
- };
- // Or `num` with `this`
- BN.prototype.or = function or (num) {
- if (this.length > num.length) return this.clone().ior(num);
- return num.clone().ior(this);
- };
- BN.prototype.uor = function uor (num) {
- if (this.length > num.length) return this.clone().iuor(num);
- return num.clone().iuor(this);
- };
- // And `num` with `this` in-place
- BN.prototype.iuand = function iuand (num) {
- // b = min-length(num, this)
- var b;
- if (this.length > num.length) {
- b = num;
- } else {
- b = this;
- }
- for (var i = 0; i < b.length; i++) {
- this.words[i] = this.words[i] & num.words[i];
- }
- this.length = b.length;
- return this.strip();
- };
- BN.prototype.iand = function iand (num) {
- assert((this.negative | num.negative) === 0);
- return this.iuand(num);
- };
- // And `num` with `this`
- BN.prototype.and = function and (num) {
- if (this.length > num.length) return this.clone().iand(num);
- return num.clone().iand(this);
- };
- BN.prototype.uand = function uand (num) {
- if (this.length > num.length) return this.clone().iuand(num);
- return num.clone().iuand(this);
- };
- // Xor `num` with `this` in-place
- BN.prototype.iuxor = function iuxor (num) {
- // a.length > b.length
- var a;
- var b;
- if (this.length > num.length) {
- a = this;
- b = num;
- } else {
- a = num;
- b = this;
- }
- for (var i = 0; i < b.length; i++) {
- this.words[i] = a.words[i] ^ b.words[i];
- }
- if (this !== a) {
- for (; i < a.length; i++) {
- this.words[i] = a.words[i];
- }
- }
- this.length = a.length;
- return this.strip();
- };
- BN.prototype.ixor = function ixor (num) {
- assert((this.negative | num.negative) === 0);
- return this.iuxor(num);
- };
- // Xor `num` with `this`
- BN.prototype.xor = function xor (num) {
- if (this.length > num.length) return this.clone().ixor(num);
- return num.clone().ixor(this);
- };
- BN.prototype.uxor = function uxor (num) {
- if (this.length > num.length) return this.clone().iuxor(num);
- return num.clone().iuxor(this);
- };
- // Not ``this`` with ``width`` bitwidth
- BN.prototype.inotn = function inotn (width) {
- assert(typeof width === 'number' && width >= 0);
- var bytesNeeded = Math.ceil(width / 26) | 0;
- var bitsLeft = width % 26;
- // Extend the buffer with leading zeroes
- this._expand(bytesNeeded);
- if (bitsLeft > 0) {
- bytesNeeded--;
- }
- // Handle complete words
- for (var i = 0; i < bytesNeeded; i++) {
- this.words[i] = ~this.words[i] & 0x3ffffff;
- }
- // Handle the residue
- if (bitsLeft > 0) {
- this.words[i] = ~this.words[i] & (0x3ffffff >> (26 - bitsLeft));
- }
- // And remove leading zeroes
- return this.strip();
- };
- BN.prototype.notn = function notn (width) {
- return this.clone().inotn(width);
- };
- // Set `bit` of `this`
- BN.prototype.setn = function setn (bit, val) {
- assert(typeof bit === 'number' && bit >= 0);
- var off = (bit / 26) | 0;
- var wbit = bit % 26;
- this._expand(off + 1);
- if (val) {
- this.words[off] = this.words[off] | (1 << wbit);
- } else {
- this.words[off] = this.words[off] & ~(1 << wbit);
- }
- return this.strip();
- };
- // Add `num` to `this` in-place
- BN.prototype.iadd = function iadd (num) {
- var r;
- // negative + positive
- if (this.negative !== 0 && num.negative === 0) {
- this.negative = 0;
- r = this.isub(num);
- this.negative ^= 1;
- return this._normSign();
- // positive + negative
- } else if (this.negative === 0 && num.negative !== 0) {
- num.negative = 0;
- r = this.isub(num);
- num.negative = 1;
- return r._normSign();
- }
- // a.length > b.length
- var a, b;
- if (this.length > num.length) {
- a = this;
- b = num;
- } else {
- a = num;
- b = this;
- }
- var carry = 0;
- for (var i = 0; i < b.length; i++) {
- r = (a.words[i] | 0) + (b.words[i] | 0) + carry;
- this.words[i] = r & 0x3ffffff;
- carry = r >>> 26;
- }
- for (; carry !== 0 && i < a.length; i++) {
- r = (a.words[i] | 0) + carry;
- this.words[i] = r & 0x3ffffff;
- carry = r >>> 26;
- }
- this.length = a.length;
- if (carry !== 0) {
- this.words[this.length] = carry;
- this.length++;
- // Copy the rest of the words
- } else if (a !== this) {
- for (; i < a.length; i++) {
- this.words[i] = a.words[i];
- }
- }
- return this;
- };
- // Add `num` to `this`
- BN.prototype.add = function add (num) {
- var res;
- if (num.negative !== 0 && this.negative === 0) {
- num.negative = 0;
- res = this.sub(num);
- num.negative ^= 1;
- return res;
- } else if (num.negative === 0 && this.negative !== 0) {
- this.negative = 0;
- res = num.sub(this);
- this.negative = 1;
- return res;
- }
- if (this.length > num.length) return this.clone().iadd(num);
- return num.clone().iadd(this);
- };
- // Subtract `num` from `this` in-place
- BN.prototype.isub = function isub (num) {
- // this - (-num) = this + num
- if (num.negative !== 0) {
- num.negative = 0;
- var r = this.iadd(num);
- num.negative = 1;
- return r._normSign();
- // -this - num = -(this + num)
- } else if (this.negative !== 0) {
- this.negative = 0;
- this.iadd(num);
- this.negative = 1;
- return this._normSign();
- }
- // At this point both numbers are positive
- var cmp = this.cmp(num);
- // Optimization - zeroify
- if (cmp === 0) {
- this.negative = 0;
- this.length = 1;
- this.words[0] = 0;
- return this;
- }
- // a > b
- var a, b;
- if (cmp > 0) {
- a = this;
- b = num;
- } else {
- a = num;
- b = this;
- }
- var carry = 0;
- for (var i = 0; i < b.length; i++) {
- r = (a.words[i] | 0) - (b.words[i] | 0) + carry;
- carry = r >> 26;
- this.words[i] = r & 0x3ffffff;
- }
- for (; carry !== 0 && i < a.length; i++) {
- r = (a.words[i] | 0) + carry;
- carry = r >> 26;
- this.words[i] = r & 0x3ffffff;
- }
- // Copy rest of the words
- if (carry === 0 && i < a.length && a !== this) {
- for (; i < a.length; i++) {
- this.words[i] = a.words[i];
- }
- }
- this.length = Math.max(this.length, i);
- if (a !== this) {
- this.negative = 1;
- }
- return this.strip();
- };
- // Subtract `num` from `this`
- BN.prototype.sub = function sub (num) {
- return this.clone().isub(num);
- };
- function smallMulTo (self, num, out) {
- out.negative = num.negative ^ self.negative;
- var len = (self.length + num.length) | 0;
- out.length = len;
- len = (len - 1) | 0;
- // Peel one iteration (compiler can't do it, because of code complexity)
- var a = self.words[0] | 0;
- var b = num.words[0] | 0;
- var r = a * b;
- var lo = r & 0x3ffffff;
- var carry = (r / 0x4000000) | 0;
- out.words[0] = lo;
- for (var k = 1; k < len; k++) {
- // Sum all words with the same `i + j = k` and accumulate `ncarry`,
- // note that ncarry could be >= 0x3ffffff
- var ncarry = carry >>> 26;
- var rword = carry & 0x3ffffff;
- var maxJ = Math.min(k, num.length - 1);
- for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) {
- var i = (k - j) | 0;
- a = self.words[i] | 0;
- b = num.words[j] | 0;
- r = a * b + rword;
- ncarry += (r / 0x4000000) | 0;
- rword = r & 0x3ffffff;
- }
- out.words[k] = rword | 0;
- carry = ncarry | 0;
- }
- if (carry !== 0) {
- out.words[k] = carry | 0;
- } else {
- out.length--;
- }
- return out.strip();
- }
- // TODO(indutny): it may be reasonable to omit it for users who don't need
- // to work with 256-bit numbers, otherwise it gives 20% improvement for 256-bit
- // multiplication (like elliptic secp256k1).
- var comb10MulTo = function comb10MulTo (self, num, out) {
- var a = self.words;
- var b = num.words;
- var o = out.words;
- var c = 0;
- var lo;
- var mid;
- var hi;
- var a0 = a[0] | 0;
- var al0 = a0 & 0x1fff;
- var ah0 = a0 >>> 13;
- var a1 = a[1] | 0;
- var al1 = a1 & 0x1fff;
- var ah1 = a1 >>> 13;
- var a2 = a[2] | 0;
- var al2 = a2 & 0x1fff;
- var ah2 = a2 >>> 13;
- var a3 = a[3] | 0;
- var al3 = a3 & 0x1fff;
- var ah3 = a3 >>> 13;
- var a4 = a[4] | 0;
- var al4 = a4 & 0x1fff;
- var ah4 = a4 >>> 13;
- var a5 = a[5] | 0;
- var al5 = a5 & 0x1fff;
- var ah5 = a5 >>> 13;
- var a6 = a[6] | 0;
- var al6 = a6 & 0x1fff;
- var ah6 = a6 >>> 13;
- var a7 = a[7] | 0;
- var al7 = a7 & 0x1fff;
- var ah7 = a7 >>> 13;
- var a8 = a[8] | 0;
- var al8 = a8 & 0x1fff;
- var ah8 = a8 >>> 13;
- var a9 = a[9] | 0;
- var al9 = a9 & 0x1fff;
- var ah9 = a9 >>> 13;
- var b0 = b[0] | 0;
- var bl0 = b0 & 0x1fff;
- var bh0 = b0 >>> 13;
- var b1 = b[1] | 0;
- var bl1 = b1 & 0x1fff;
- var bh1 = b1 >>> 13;
- var b2 = b[2] | 0;
- var bl2 = b2 & 0x1fff;
- var bh2 = b2 >>> 13;
- var b3 = b[3] | 0;
- var bl3 = b3 & 0x1fff;
- var bh3 = b3 >>> 13;
- var b4 = b[4] | 0;
- var bl4 = b4 & 0x1fff;
- var bh4 = b4 >>> 13;
- var b5 = b[5] | 0;
- var bl5 = b5 & 0x1fff;
- var bh5 = b5 >>> 13;
- var b6 = b[6] | 0;
- var bl6 = b6 & 0x1fff;
- var bh6 = b6 >>> 13;
- var b7 = b[7] | 0;
- var bl7 = b7 & 0x1fff;
- var bh7 = b7 >>> 13;
- var b8 = b[8] | 0;
- var bl8 = b8 & 0x1fff;
- var bh8 = b8 >>> 13;
- var b9 = b[9] | 0;
- var bl9 = b9 & 0x1fff;
- var bh9 = b9 >>> 13;
- out.negative = self.negative ^ num.negative;
- out.length = 19;
- /* k = 0 */
- lo = Math.imul(al0, bl0);
- mid = Math.imul(al0, bh0);
- mid = (mid + Math.imul(ah0, bl0)) | 0;
- hi = Math.imul(ah0, bh0);
- var w0 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
- c = (((hi + (mid >>> 13)) | 0) + (w0 >>> 26)) | 0;
- w0 &= 0x3ffffff;
- /* k = 1 */
- lo = Math.imul(al1, bl0);
- mid = Math.imul(al1, bh0);
- mid = (mid + Math.imul(ah1, bl0)) | 0;
- hi = Math.imul(ah1, bh0);
- lo = (lo + Math.imul(al0, bl1)) | 0;
- mid = (mid + Math.imul(al0, bh1)) | 0;
- mid = (mid + Math.imul(ah0, bl1)) | 0;
- hi = (hi + Math.imul(ah0, bh1)) | 0;
- var w1 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
- c = (((hi + (mid >>> 13)) | 0) + (w1 >>> 26)) | 0;
- w1 &= 0x3ffffff;
- /* k = 2 */
- lo = Math.imul(al2, bl0);
- mid = Math.imul(al2, bh0);
- mid = (mid + Math.imul(ah2, bl0)) | 0;
- hi = Math.imul(ah2, bh0);
- lo = (lo + Math.imul(al1, bl1)) | 0;
- mid = (mid + Math.imul(al1, bh1)) | 0;
- mid = (mid + Math.imul(ah1, bl1)) | 0;
- hi = (hi + Math.imul(ah1, bh1)) | 0;
- lo = (lo + Math.imul(al0, bl2)) | 0;
- mid = (mid + Math.imul(al0, bh2)) | 0;
- mid = (mid + Math.imul(ah0, bl2)) | 0;
- hi = (hi + Math.imul(ah0, bh2)) | 0;
- var w2 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
- c = (((hi + (mid >>> 13)) | 0) + (w2 >>> 26)) | 0;
- w2 &= 0x3ffffff;
- /* k = 3 */
- lo = Math.imul(al3, bl0);
- mid = Math.imul(al3, bh0);
- mid = (mid + Math.imul(ah3, bl0)) | 0;
- hi = Math.imul(ah3, bh0);
- lo = (lo + Math.imul(al2, bl1)) | 0;
- mid = (mid + Math.imul(al2, bh1)) | 0;
- mid = (mid + Math.imul(ah2, bl1)) | 0;
- hi = (hi + Math.imul(ah2, bh1)) | 0;
- lo = (lo + Math.imul(al1, bl2)) | 0;
- mid = (mid + Math.imul(al1, bh2)) | 0;
- mid = (mid + Math.imul(ah1, bl2)) | 0;
- hi = (hi + Math.imul(ah1, bh2)) | 0;
- lo = (lo + Math.imul(al0, bl3)) | 0;
- mid = (mid + Math.imul(al0, bh3)) | 0;
- mid = (mid + Math.imul(ah0, bl3)) | 0;
- hi = (hi + Math.imul(ah0, bh3)) | 0;
- var w3 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
- c = (((hi + (mid >>> 13)) | 0) + (w3 >>> 26)) | 0;
- w3 &= 0x3ffffff;
- /* k = 4 */
- lo = Math.imul(al4, bl0);
- mid = Math.imul(al4, bh0);
- mid = (mid + Math.imul(ah4, bl0)) | 0;
- hi = Math.imul(ah4, bh0);
- lo = (lo + Math.imul(al3, bl1)) | 0;
- mid = (mid + Math.imul(al3, bh1)) | 0;
- mid = (mid + Math.imul(ah3, bl1)) | 0;
- hi = (hi + Math.imul(ah3, bh1)) | 0;
- lo = (lo + Math.imul(al2, bl2)) | 0;
- mid = (mid + Math.imul(al2, bh2)) | 0;
- mid = (mid + Math.imul(ah2, bl2)) | 0;
- hi = (hi + Math.imul(ah2, bh2)) | 0;
- lo = (lo + Math.imul(al1, bl3)) | 0;
- mid = (mid + Math.imul(al1, bh3)) | 0;
- mid = (mid + Math.imul(ah1, bl3)) | 0;
- hi = (hi + Math.imul(ah1, bh3)) | 0;
- lo = (lo + Math.imul(al0, bl4)) | 0;
- mid = (mid + Math.imul(al0, bh4)) | 0;
- mid = (mid + Math.imul(ah0, bl4)) | 0;
- hi = (hi + Math.imul(ah0, bh4)) | 0;
- var w4 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
- c = (((hi + (mid >>> 13)) | 0) + (w4 >>> 26)) | 0;
- w4 &= 0x3ffffff;
- /* k = 5 */
- lo = Math.imul(al5, bl0);
- mid = Math.imul(al5, bh0);
- mid = (mid + Math.imul(ah5, bl0)) | 0;
- hi = Math.imul(ah5, bh0);
- lo = (lo + Math.imul(al4, bl1)) | 0;
- mid = (mid + Math.imul(al4, bh1)) | 0;
- mid = (mid + Math.imul(ah4, bl1)) | 0;
- hi = (hi + Math.imul(ah4, bh1)) | 0;
- lo = (lo + Math.imul(al3, bl2)) | 0;
- mid = (mid + Math.imul(al3, bh2)) | 0;
- mid = (mid + Math.imul(ah3, bl2)) | 0;
- hi = (hi + Math.imul(ah3, bh2)) | 0;
- lo = (lo + Math.imul(al2, bl3)) | 0;
- mid = (mid + Math.imul(al2, bh3)) | 0;
- mid = (mid + Math.imul(ah2, bl3)) | 0;
- hi = (hi + Math.imul(ah2, bh3)) | 0;
- lo = (lo + Math.imul(al1, bl4)) | 0;
- mid = (mid + Math.imul(al1, bh4)) | 0;
- mid = (mid + Math.imul(ah1, bl4)) | 0;
- hi = (hi + Math.imul(ah1, bh4)) | 0;
- lo = (lo + Math.imul(al0, bl5)) | 0;
- mid = (mid + Math.imul(al0, bh5)) | 0;
- mid = (mid + Math.imul(ah0, bl5)) | 0;
- hi = (hi + Math.imul(ah0, bh5)) | 0;
- var w5 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
- c = (((hi + (mid >>> 13)) | 0) + (w5 >>> 26)) | 0;
- w5 &= 0x3ffffff;
- /* k = 6 */
- lo = Math.imul(al6, bl0);
- mid = Math.imul(al6, bh0);
- mid = (mid + Math.imul(ah6, bl0)) | 0;
- hi = Math.imul(ah6, bh0);
- lo = (lo + Math.imul(al5, bl1)) | 0;
- mid = (mid + Math.imul(al5, bh1)) | 0;
- mid = (mid + Math.imul(ah5, bl1)) | 0;
- hi = (hi + Math.imul(ah5, bh1)) | 0;
- lo = (lo + Math.imul(al4, bl2)) | 0;
- mid = (mid + Math.imul(al4, bh2)) | 0;
- mid = (mid + Math.imul(ah4, bl2)) | 0;
- hi = (hi + Math.imul(ah4, bh2)) | 0;
- lo = (lo + Math.imul(al3, bl3)) | 0;
- mid = (mid + Math.imul(al3, bh3)) | 0;
- mid = (mid + Math.imul(ah3, bl3)) | 0;
- hi = (hi + Math.imul(ah3, bh3)) | 0;
- lo = (lo + Math.imul(al2, bl4)) | 0;
- mid = (mid + Math.imul(al2, bh4)) | 0;
- mid = (mid + Math.imul(ah2, bl4)) | 0;
- hi = (hi + Math.imul(ah2, bh4)) | 0;
- lo = (lo + Math.imul(al1, bl5)) | 0;
- mid = (mid + Math.imul(al1, bh5)) | 0;
- mid = (mid + Math.imul(ah1, bl5)) | 0;
- hi = (hi + Math.imul(ah1, bh5)) | 0;
- lo = (lo + Math.imul(al0, bl6)) | 0;
- mid = (mid + Math.imul(al0, bh6)) | 0;
- mid = (mid + Math.imul(ah0, bl6)) | 0;
- hi = (hi + Math.imul(ah0, bh6)) | 0;
- var w6 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
- c = (((hi + (mid >>> 13)) | 0) + (w6 >>> 26)) | 0;
- w6 &= 0x3ffffff;
- /* k = 7 */
- lo = Math.imul(al7, bl0);
- mid = Math.imul(al7, bh0);
- mid = (mid + Math.imul(ah7, bl0)) | 0;
- hi = Math.imul(ah7, bh0);
- lo = (lo + Math.imul(al6, bl1)) | 0;
- mid = (mid + Math.imul(al6, bh1)) | 0;
- mid = (mid + Math.imul(ah6, bl1)) | 0;
- hi = (hi + Math.imul(ah6, bh1)) | 0;
- lo = (lo + Math.imul(al5, bl2)) | 0;
- mid = (mid + Math.imul(al5, bh2)) | 0;
- mid = (mid + Math.imul(ah5, bl2)) | 0;
- hi = (hi + Math.imul(ah5, bh2)) | 0;
- lo = (lo + Math.imul(al4, bl3)) | 0;
- mid = (mid + Math.imul(al4, bh3)) | 0;
- mid = (mid + Math.imul(ah4, bl3)) | 0;
- hi = (hi + Math.imul(ah4, bh3)) | 0;
- lo = (lo + Math.imul(al3, bl4)) | 0;
- mid = (mid + Math.imul(al3, bh4)) | 0;
- mid = (mid + Math.imul(ah3, bl4)) | 0;
- hi = (hi + Math.imul(ah3, bh4)) | 0;
- lo = (lo + Math.imul(al2, bl5)) | 0;
- mid = (mid + Math.imul(al2, bh5)) | 0;
- mid = (mid + Math.imul(ah2, bl5)) | 0;
- hi = (hi + Math.imul(ah2, bh5)) | 0;
- lo = (lo + Math.imul(al1, bl6)) | 0;
- mid = (mid + Math.imul(al1, bh6)) | 0;
- mid = (mid + Math.imul(ah1, bl6)) | 0;
- hi = (hi + Math.imul(ah1, bh6)) | 0;
- lo = (lo + Math.imul(al0, bl7)) | 0;
- mid = (mid + Math.imul(al0, bh7)) | 0;
- mid = (mid + Math.imul(ah0, bl7)) | 0;
- hi = (hi + Math.imul(ah0, bh7)) | 0;
- var w7 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
- c = (((hi + (mid >>> 13)) | 0) + (w7 >>> 26)) | 0;
- w7 &= 0x3ffffff;
- /* k = 8 */
- lo = Math.imul(al8, bl0);
- mid = Math.imul(al8, bh0);
- mid = (mid + Math.imul(ah8, bl0)) | 0;
- hi = Math.imul(ah8, bh0);
- lo = (lo + Math.imul(al7, bl1)) | 0;
- mid = (mid + Math.imul(al7, bh1)) | 0;
- mid = (mid + Math.imul(ah7, bl1)) | 0;
- hi = (hi + Math.imul(ah7, bh1)) | 0;
- lo = (lo + Math.imul(al6, bl2)) | 0;
- mid = (mid + Math.imul(al6, bh2)) | 0;
- mid = (mid + Math.imul(ah6, bl2)) | 0;
- hi = (hi + Math.imul(ah6, bh2)) | 0;
- lo = (lo + Math.imul(al5, bl3)) | 0;
- mid = (mid + Math.imul(al5, bh3)) | 0;
- mid = (mid + Math.imul(ah5, bl3)) | 0;
- hi = (hi + Math.imul(ah5, bh3)) | 0;
- lo = (lo + Math.imul(al4, bl4)) | 0;
- mid = (mid + Math.imul(al4, bh4)) | 0;
- mid = (mid + Math.imul(ah4, bl4)) | 0;
- hi = (hi + Math.imul(ah4, bh4)) | 0;
- lo = (lo + Math.imul(al3, bl5)) | 0;
- mid = (mid + Math.imul(al3, bh5)) | 0;
- mid = (mid + Math.imul(ah3, bl5)) | 0;
- hi = (hi + Math.imul(ah3, bh5)) | 0;
- lo = (lo + Math.imul(al2, bl6)) | 0;
- mid = (mid + Math.imul(al2, bh6)) | 0;
- mid = (mid + Math.imul(ah2, bl6)) | 0;
- hi = (hi + Math.imul(ah2, bh6)) | 0;
- lo = (lo + Math.imul(al1, bl7)) | 0;
- mid = (mid + Math.imul(al1, bh7)) | 0;
- mid = (mid + Math.imul(ah1, bl7)) | 0;
- hi = (hi + Math.imul(ah1, bh7)) | 0;
- lo = (lo + Math.imul(al0, bl8)) | 0;
- mid = (mid + Math.imul(al0, bh8)) | 0;
- mid = (mid + Math.imul(ah0, bl8)) | 0;
- hi = (hi + Math.imul(ah0, bh8)) | 0;
- var w8 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
- c = (((hi + (mid >>> 13)) | 0) + (w8 >>> 26)) | 0;
- w8 &= 0x3ffffff;
- /* k = 9 */
- lo = Math.imul(al9, bl0);
- mid = Math.imul(al9, bh0);
- mid = (mid + Math.imul(ah9, bl0)) | 0;
- hi = Math.imul(ah9, bh0);
- lo = (lo + Math.imul(al8, bl1)) | 0;
- mid = (mid + Math.imul(al8, bh1)) | 0;
- mid = (mid + Math.imul(ah8, bl1)) | 0;
- hi = (hi + Math.imul(ah8, bh1)) | 0;
- lo = (lo + Math.imul(al7, bl2)) | 0;
- mid = (mid + Math.imul(al7, bh2)) | 0;
- mid = (mid + Math.imul(ah7, bl2)) | 0;
- hi = (hi + Math.imul(ah7, bh2)) | 0;
- lo = (lo + Math.imul(al6, bl3)) | 0;
- mid = (mid + Math.imul(al6, bh3)) | 0;
- mid = (mid + Math.imul(ah6, bl3)) | 0;
- hi = (hi + Math.imul(ah6, bh3)) | 0;
- lo = (lo + Math.imul(al5, bl4)) | 0;
- mid = (mid + Math.imul(al5, bh4)) | 0;
- mid = (mid + Math.imul(ah5, bl4)) | 0;
- hi = (hi + Math.imul(ah5, bh4)) | 0;
- lo = (lo + Math.imul(al4, bl5)) | 0;
- mid = (mid + Math.imul(al4, bh5)) | 0;
- mid = (mid + Math.imul(ah4, bl5)) | 0;
- hi = (hi + Math.imul(ah4, bh5)) | 0;
- lo = (lo + Math.imul(al3, bl6)) | 0;
- mid = (mid + Math.imul(al3, bh6)) | 0;
- mid = (mid + Math.imul(ah3, bl6)) | 0;
- hi = (hi + Math.imul(ah3, bh6)) | 0;
- lo = (lo + Math.imul(al2, bl7)) | 0;
- mid = (mid + Math.imul(al2, bh7)) | 0;
- mid = (mid + Math.imul(ah2, bl7)) | 0;
- hi = (hi + Math.imul(ah2, bh7)) | 0;
- lo = (lo + Math.imul(al1, bl8)) | 0;
- mid = (mid + Math.imul(al1, bh8)) | 0;
- mid = (mid + Math.imul(ah1, bl8)) | 0;
- hi = (hi + Math.imul(ah1, bh8)) | 0;
- lo = (lo + Math.imul(al0, bl9)) | 0;
- mid = (mid + Math.imul(al0, bh9)) | 0;
- mid = (mid + Math.imul(ah0, bl9)) | 0;
- hi = (hi + Math.imul(ah0, bh9)) | 0;
- var w9 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
- c = (((hi + (mid >>> 13)) | 0) + (w9 >>> 26)) | 0;
- w9 &= 0x3ffffff;
- /* k = 10 */
- lo = Math.imul(al9, bl1);
- mid = Math.imul(al9, bh1);
- mid = (mid + Math.imul(ah9, bl1)) | 0;
- hi = Math.imul(ah9, bh1);
- lo = (lo + Math.imul(al8, bl2)) | 0;
- mid = (mid + Math.imul(al8, bh2)) | 0;
- mid = (mid + Math.imul(ah8, bl2)) | 0;
- hi = (hi + Math.imul(ah8, bh2)) | 0;
- lo = (lo + Math.imul(al7, bl3)) | 0;
- mid = (mid + Math.imul(al7, bh3)) | 0;
- mid = (mid + Math.imul(ah7, bl3)) | 0;
- hi = (hi + Math.imul(ah7, bh3)) | 0;
- lo = (lo + Math.imul(al6, bl4)) | 0;
- mid = (mid + Math.imul(al6, bh4)) | 0;
- mid = (mid + Math.imul(ah6, bl4)) | 0;
- hi = (hi + Math.imul(ah6, bh4)) | 0;
- lo = (lo + Math.imul(al5, bl5)) | 0;
- mid = (mid + Math.imul(al5, bh5)) | 0;
- mid = (mid + Math.imul(ah5, bl5)) | 0;
- hi = (hi + Math.imul(ah5, bh5)) | 0;
- lo = (lo + Math.imul(al4, bl6)) | 0;
- mid = (mid + Math.imul(al4, bh6)) | 0;
- mid = (mid + Math.imul(ah4, bl6)) | 0;
- hi = (hi + Math.imul(ah4, bh6)) | 0;
- lo = (lo + Math.imul(al3, bl7)) | 0;
- mid = (mid + Math.imul(al3, bh7)) | 0;
- mid = (mid + Math.imul(ah3, bl7)) | 0;
- hi = (hi + Math.imul(ah3, bh7)) | 0;
- lo = (lo + Math.imul(al2, bl8)) | 0;
- mid = (mid + Math.imul(al2, bh8)) | 0;
- mid = (mid + Math.imul(ah2, bl8)) | 0;
- hi = (hi + Math.imul(ah2, bh8)) | 0;
- lo = (lo + Math.imul(al1, bl9)) | 0;
- mid = (mid + Math.imul(al1, bh9)) | 0;
- mid = (mid + Math.imul(ah1, bl9)) | 0;
- hi = (hi + Math.imul(ah1, bh9)) | 0;
- var w10 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
- c = (((hi + (mid >>> 13)) | 0) + (w10 >>> 26)) | 0;
- w10 &= 0x3ffffff;
- /* k = 11 */
- lo = Math.imul(al9, bl2);
- mid = Math.imul(al9, bh2);
- mid = (mid + Math.imul(ah9, bl2)) | 0;
- hi = Math.imul(ah9, bh2);
- lo = (lo + Math.imul(al8, bl3)) | 0;
- mid = (mid + Math.imul(al8, bh3)) | 0;
- mid = (mid + Math.imul(ah8, bl3)) | 0;
- hi = (hi + Math.imul(ah8, bh3)) | 0;
- lo = (lo + Math.imul(al7, bl4)) | 0;
- mid = (mid + Math.imul(al7, bh4)) | 0;
- mid = (mid + Math.imul(ah7, bl4)) | 0;
- hi = (hi + Math.imul(ah7, bh4)) | 0;
- lo = (lo + Math.imul(al6, bl5)) | 0;
- mid = (mid + Math.imul(al6, bh5)) | 0;
- mid = (mid + Math.imul(ah6, bl5)) | 0;
- hi = (hi + Math.imul(ah6, bh5)) | 0;
- lo = (lo + Math.imul(al5, bl6)) | 0;
- mid = (mid + Math.imul(al5, bh6)) | 0;
- mid = (mid + Math.imul(ah5, bl6)) | 0;
- hi = (hi + Math.imul(ah5, bh6)) | 0;
- lo = (lo + Math.imul(al4, bl7)) | 0;
- mid = (mid + Math.imul(al4, bh7)) | 0;
- mid = (mid + Math.imul(ah4, bl7)) | 0;
- hi = (hi + Math.imul(ah4, bh7)) | 0;
- lo = (lo + Math.imul(al3, bl8)) | 0;
- mid = (mid + Math.imul(al3, bh8)) | 0;
- mid = (mid + Math.imul(ah3, bl8)) | 0;
- hi = (hi + Math.imul(ah3, bh8)) | 0;
- lo = (lo + Math.imul(al2, bl9)) | 0;
- mid = (mid + Math.imul(al2, bh9)) | 0;
- mid = (mid + Math.imul(ah2, bl9)) | 0;
- hi = (hi + Math.imul(ah2, bh9)) | 0;
- var w11 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
- c = (((hi + (mid >>> 13)) | 0) + (w11 >>> 26)) | 0;
- w11 &= 0x3ffffff;
- /* k = 12 */
- lo = Math.imul(al9, bl3);
- mid = Math.imul(al9, bh3);
- mid = (mid + Math.imul(ah9, bl3)) | 0;
- hi = Math.imul(ah9, bh3);
- lo = (lo + Math.imul(al8, bl4)) | 0;
- mid = (mid + Math.imul(al8, bh4)) | 0;
- mid = (mid + Math.imul(ah8, bl4)) | 0;
- hi = (hi + Math.imul(ah8, bh4)) | 0;
- lo = (lo + Math.imul(al7, bl5)) | 0;
- mid = (mid + Math.imul(al7, bh5)) | 0;
- mid = (mid + Math.imul(ah7, bl5)) | 0;
- hi = (hi + Math.imul(ah7, bh5)) | 0;
- lo = (lo + Math.imul(al6, bl6)) | 0;
- mid = (mid + Math.imul(al6, bh6)) | 0;
- mid = (mid + Math.imul(ah6, bl6)) | 0;
- hi = (hi + Math.imul(ah6, bh6)) | 0;
- lo = (lo + Math.imul(al5, bl7)) | 0;
- mid = (mid + Math.imul(al5, bh7)) | 0;
- mid = (mid + Math.imul(ah5, bl7)) | 0;
- hi = (hi + Math.imul(ah5, bh7)) | 0;
- lo = (lo + Math.imul(al4, bl8)) | 0;
- mid = (mid + Math.imul(al4, bh8)) | 0;
- mid = (mid + Math.imul(ah4, bl8)) | 0;
- hi = (hi + Math.imul(ah4, bh8)) | 0;
- lo = (lo + Math.imul(al3, bl9)) | 0;
- mid = (mid + Math.imul(al3, bh9)) | 0;
- mid = (mid + Math.imul(ah3, bl9)) | 0;
- hi = (hi + Math.imul(ah3, bh9)) | 0;
- var w12 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
- c = (((hi + (mid >>> 13)) | 0) + (w12 >>> 26)) | 0;
- w12 &= 0x3ffffff;
- /* k = 13 */
- lo = Math.imul(al9, bl4);
- mid = Math.imul(al9, bh4);
- mid = (mid + Math.imul(ah9, bl4)) | 0;
- hi = Math.imul(ah9, bh4);
- lo = (lo + Math.imul(al8, bl5)) | 0;
- mid = (mid + Math.imul(al8, bh5)) | 0;
- mid = (mid + Math.imul(ah8, bl5)) | 0;
- hi = (hi + Math.imul(ah8, bh5)) | 0;
- lo = (lo + Math.imul(al7, bl6)) | 0;
- mid = (mid + Math.imul(al7, bh6)) | 0;
- mid = (mid + Math.imul(ah7, bl6)) | 0;
- hi = (hi + Math.imul(ah7, bh6)) | 0;
- lo = (lo + Math.imul(al6, bl7)) | 0;
- mid = (mid + Math.imul(al6, bh7)) | 0;
- mid = (mid + Math.imul(ah6, bl7)) | 0;
- hi = (hi + Math.imul(ah6, bh7)) | 0;
- lo = (lo + Math.imul(al5, bl8)) | 0;
- mid = (mid + Math.imul(al5, bh8)) | 0;
- mid = (mid + Math.imul(ah5, bl8)) | 0;
- hi = (hi + Math.imul(ah5, bh8)) | 0;
- lo = (lo + Math.imul(al4, bl9)) | 0;
- mid = (mid + Math.imul(al4, bh9)) | 0;
- mid = (mid + Math.imul(ah4, bl9)) | 0;
- hi = (hi + Math.imul(ah4, bh9)) | 0;
- var w13 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
- c = (((hi + (mid >>> 13)) | 0) + (w13 >>> 26)) | 0;
- w13 &= 0x3ffffff;
- /* k = 14 */
- lo = Math.imul(al9, bl5);
- mid = Math.imul(al9, bh5);
- mid = (mid + Math.imul(ah9, bl5)) | 0;
- hi = Math.imul(ah9, bh5);
- lo = (lo + Math.imul(al8, bl6)) | 0;
- mid = (mid + Math.imul(al8, bh6)) | 0;
- mid = (mid + Math.imul(ah8, bl6)) | 0;
- hi = (hi + Math.imul(ah8, bh6)) | 0;
- lo = (lo + Math.imul(al7, bl7)) | 0;
- mid = (mid + Math.imul(al7, bh7)) | 0;
- mid = (mid + Math.imul(ah7, bl7)) | 0;
- hi = (hi + Math.imul(ah7, bh7)) | 0;
- lo = (lo + Math.imul(al6, bl8)) | 0;
- mid = (mid + Math.imul(al6, bh8)) | 0;
- mid = (mid + Math.imul(ah6, bl8)) | 0;
- hi = (hi + Math.imul(ah6, bh8)) | 0;
- lo = (lo + Math.imul(al5, bl9)) | 0;
- mid = (mid + Math.imul(al5, bh9)) | 0;
- mid = (mid + Math.imul(ah5, bl9)) | 0;
- hi = (hi + Math.imul(ah5, bh9)) | 0;
- var w14 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
- c = (((hi + (mid >>> 13)) | 0) + (w14 >>> 26)) | 0;
- w14 &= 0x3ffffff;
- /* k = 15 */
- lo = Math.imul(al9, bl6);
- mid = Math.imul(al9, bh6);
- mid = (mid + Math.imul(ah9, bl6)) | 0;
- hi = Math.imul(ah9, bh6);
- lo = (lo + Math.imul(al8, bl7)) | 0;
- mid = (mid + Math.imul(al8, bh7)) | 0;
- mid = (mid + Math.imul(ah8, bl7)) | 0;
- hi = (hi + Math.imul(ah8, bh7)) | 0;
- lo = (lo + Math.imul(al7, bl8)) | 0;
- mid = (mid + Math.imul(al7, bh8)) | 0;
- mid = (mid + Math.imul(ah7, bl8)) | 0;
- hi = (hi + Math.imul(ah7, bh8)) | 0;
- lo = (lo + Math.imul(al6, bl9)) | 0;
- mid = (mid + Math.imul(al6, bh9)) | 0;
- mid = (mid + Math.imul(ah6, bl9)) | 0;
- hi = (hi + Math.imul(ah6, bh9)) | 0;
- var w15 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
- c = (((hi + (mid >>> 13)) | 0) + (w15 >>> 26)) | 0;
- w15 &= 0x3ffffff;
- /* k = 16 */
- lo = Math.imul(al9, bl7);
- mid = Math.imul(al9, bh7);
- mid = (mid + Math.imul(ah9, bl7)) | 0;
- hi = Math.imul(ah9, bh7);
- lo = (lo + Math.imul(al8, bl8)) | 0;
- mid = (mid + Math.imul(al8, bh8)) | 0;
- mid = (mid + Math.imul(ah8, bl8)) | 0;
- hi = (hi + Math.imul(ah8, bh8)) | 0;
- lo = (lo + Math.imul(al7, bl9)) | 0;
- mid = (mid + Math.imul(al7, bh9)) | 0;
- mid = (mid + Math.imul(ah7, bl9)) | 0;
- hi = (hi + Math.imul(ah7, bh9)) | 0;
- var w16 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
- c = (((hi + (mid >>> 13)) | 0) + (w16 >>> 26)) | 0;
- w16 &= 0x3ffffff;
- /* k = 17 */
- lo = Math.imul(al9, bl8);
- mid = Math.imul(al9, bh8);
- mid = (mid + Math.imul(ah9, bl8)) | 0;
- hi = Math.imul(ah9, bh8);
- lo = (lo + Math.imul(al8, bl9)) | 0;
- mid = (mid + Math.imul(al8, bh9)) | 0;
- mid = (mid + Math.imul(ah8, bl9)) | 0;
- hi = (hi + Math.imul(ah8, bh9)) | 0;
- var w17 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
- c = (((hi + (mid >>> 13)) | 0) + (w17 >>> 26)) | 0;
- w17 &= 0x3ffffff;
- /* k = 18 */
- lo = Math.imul(al9, bl9);
- mid = Math.imul(al9, bh9);
- mid = (mid + Math.imul(ah9, bl9)) | 0;
- hi = Math.imul(ah9, bh9);
- var w18 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
- c = (((hi + (mid >>> 13)) | 0) + (w18 >>> 26)) | 0;
- w18 &= 0x3ffffff;
- o[0] = w0;
- o[1] = w1;
- o[2] = w2;
- o[3] = w3;
- o[4] = w4;
- o[5] = w5;
- o[6] = w6;
- o[7] = w7;
- o[8] = w8;
- o[9] = w9;
- o[10] = w10;
- o[11] = w11;
- o[12] = w12;
- o[13] = w13;
- o[14] = w14;
- o[15] = w15;
- o[16] = w16;
- o[17] = w17;
- o[18] = w18;
- if (c !== 0) {
- o[19] = c;
- out.length++;
- }
- return out;
- };
- // Polyfill comb
- if (!Math.imul) {
- comb10MulTo = smallMulTo;
- }
- function bigMulTo (self, num, out) {
- out.negative = num.negative ^ self.negative;
- out.length = self.length + num.length;
- var carry = 0;
- var hncarry = 0;
- for (var k = 0; k < out.length - 1; k++) {
- // Sum all words with the same `i + j = k` and accumulate `ncarry`,
- // note that ncarry could be >= 0x3ffffff
- var ncarry = hncarry;
- hncarry = 0;
- var rword = carry & 0x3ffffff;
- var maxJ = Math.min(k, num.length - 1);
- for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) {
- var i = k - j;
- var a = self.words[i] | 0;
- var b = num.words[j] | 0;
- var r = a * b;
- var lo = r & 0x3ffffff;
- ncarry = (ncarry + ((r / 0x4000000) | 0)) | 0;
- lo = (lo + rword) | 0;
- rword = lo & 0x3ffffff;
- ncarry = (ncarry + (lo >>> 26)) | 0;
- hncarry += ncarry >>> 26;
- ncarry &= 0x3ffffff;
- }
- out.words[k] = rword;
- carry = ncarry;
- ncarry = hncarry;
- }
- if (carry !== 0) {
- out.words[k] = carry;
- } else {
- out.length--;
- }
- return out.strip();
- }
- function jumboMulTo (self, num, out) {
- var fftm = new FFTM();
- return fftm.mulp(self, num, out);
- }
- BN.prototype.mulTo = function mulTo (num, out) {
- var res;
- var len = this.length + num.length;
- if (this.length === 10 && num.length === 10) {
- res = comb10MulTo(this, num, out);
- } else if (len < 63) {
- res = smallMulTo(this, num, out);
- } else if (len < 1024) {
- res = bigMulTo(this, num, out);
- } else {
- res = jumboMulTo(this, num, out);
- }
- return res;
- };
- // Cooley-Tukey algorithm for FFT
- // slightly revisited to rely on looping instead of recursion
- function FFTM (x, y) {
- this.x = x;
- this.y = y;
- }
- FFTM.prototype.makeRBT = function makeRBT (N) {
- var t = new Array(N);
- var l = BN.prototype._countBits(N) - 1;
- for (var i = 0; i < N; i++) {
- t[i] = this.revBin(i, l, N);
- }
- return t;
- };
- // Returns binary-reversed representation of `x`
- FFTM.prototype.revBin = function revBin (x, l, N) {
- if (x === 0 || x === N - 1) return x;
- var rb = 0;
- for (var i = 0; i < l; i++) {
- rb |= (x & 1) << (l - i - 1);
- x >>= 1;
- }
- return rb;
- };
- // Performs "tweedling" phase, therefore 'emulating'
- // behaviour of the recursive algorithm
- FFTM.prototype.permute = function permute (rbt, rws, iws, rtws, itws, N) {
- for (var i = 0; i < N; i++) {
- rtws[i] = rws[rbt[i]];
- itws[i] = iws[rbt[i]];
- }
- };
- FFTM.prototype.transform = function transform (rws, iws, rtws, itws, N, rbt) {
- this.permute(rbt, rws, iws, rtws, itws, N);
- for (var s = 1; s < N; s <<= 1) {
- var l = s << 1;
- var rtwdf = Math.cos(2 * Math.PI / l);
- var itwdf = Math.sin(2 * Math.PI / l);
- for (var p = 0; p < N; p += l) {
- var rtwdf_ = rtwdf;
- var itwdf_ = itwdf;
- for (var j = 0; j < s; j++) {
- var re = rtws[p + j];
- var ie = itws[p + j];
- var ro = rtws[p + j + s];
- var io = itws[p + j + s];
- var rx = rtwdf_ * ro - itwdf_ * io;
- io = rtwdf_ * io + itwdf_ * ro;
- ro = rx;
- rtws[p + j] = re + ro;
- itws[p + j] = ie + io;
- rtws[p + j + s] = re - ro;
- itws[p + j + s] = ie - io;
- /* jshint maxdepth : false */
- if (j !== l) {
- rx = rtwdf * rtwdf_ - itwdf * itwdf_;
- itwdf_ = rtwdf * itwdf_ + itwdf * rtwdf_;
- rtwdf_ = rx;
- }
- }
- }
- }
- };
- FFTM.prototype.guessLen13b = function guessLen13b (n, m) {
- var N = Math.max(m, n) | 1;
- var odd = N & 1;
- var i = 0;
- for (N = N / 2 | 0; N; N = N >>> 1) {
- i++;
- }
- return 1 << i + 1 + odd;
- };
- FFTM.prototype.conjugate = function conjugate (rws, iws, N) {
- if (N <= 1) return;
- for (var i = 0; i < N / 2; i++) {
- var t = rws[i];
- rws[i] = rws[N - i - 1];
- rws[N - i - 1] = t;
- t = iws[i];
- iws[i] = -iws[N - i - 1];
- iws[N - i - 1] = -t;
- }
- };
- FFTM.prototype.normalize13b = function normalize13b (ws, N) {
- var carry = 0;
- for (var i = 0; i < N / 2; i++) {
- var w = Math.round(ws[2 * i + 1] / N) * 0x2000 +
- Math.round(ws[2 * i] / N) +
- carry;
- ws[i] = w & 0x3ffffff;
- if (w < 0x4000000) {
- carry = 0;
- } else {
- carry = w / 0x4000000 | 0;
- }
- }
- return ws;
- };
- FFTM.prototype.convert13b = function convert13b (ws, len, rws, N) {
- var carry = 0;
- for (var i = 0; i < len; i++) {
- carry = carry + (ws[i] | 0);
- rws[2 * i] = carry & 0x1fff; carry = carry >>> 13;
- rws[2 * i + 1] = carry & 0x1fff; carry = carry >>> 13;
- }
- // Pad with zeroes
- for (i = 2 * len; i < N; ++i) {
- rws[i] = 0;
- }
- assert(carry === 0);
- assert((carry & ~0x1fff) === 0);
- };
- FFTM.prototype.stub = function stub (N) {
- var ph = new Array(N);
- for (var i = 0; i < N; i++) {
- ph[i] = 0;
- }
- return ph;
- };
- FFTM.prototype.mulp = function mulp (x, y, out) {
- var N = 2 * this.guessLen13b(x.length, y.length);
- var rbt = this.makeRBT(N);
- var _ = this.stub(N);
- var rws = new Array(N);
- var rwst = new Array(N);
- var iwst = new Array(N);
- var nrws = new Array(N);
- var nrwst = new Array(N);
- var niwst = new Array(N);
- var rmws = out.words;
- rmws.length = N;
- this.convert13b(x.words, x.length, rws, N);
- this.convert13b(y.words, y.length, nrws, N);
- this.transform(rws, _, rwst, iwst, N, rbt);
- this.transform(nrws, _, nrwst, niwst, N, rbt);
- for (var i = 0; i < N; i++) {
- var rx = rwst[i] * nrwst[i] - iwst[i] * niwst[i];
- iwst[i] = rwst[i] * niwst[i] + iwst[i] * nrwst[i];
- rwst[i] = rx;
- }
- this.conjugate(rwst, iwst, N);
- this.transform(rwst, iwst, rmws, _, N, rbt);
- this.conjugate(rmws, _, N);
- this.normalize13b(rmws, N);
- out.negative = x.negative ^ y.negative;
- out.length = x.length + y.length;
- return out.strip();
- };
- // Multiply `this` by `num`
- BN.prototype.mul = function mul (num) {
- var out = new BN(null);
- out.words = new Array(this.length + num.length);
- return this.mulTo(num, out);
- };
- // Multiply employing FFT
- BN.prototype.mulf = function mulf (num) {
- var out = new BN(null);
- out.words = new Array(this.length + num.length);
- return jumboMulTo(this, num, out);
- };
- // In-place Multiplication
- BN.prototype.imul = function imul (num) {
- return this.clone().mulTo(num, this);
- };
- BN.prototype.imuln = function imuln (num) {
- assert(typeof num === 'number');
- assert(num < 0x4000000);
- // Carry
- var carry = 0;
- for (var i = 0; i < this.length; i++) {
- var w = (this.words[i] | 0) * num;
- var lo = (w & 0x3ffffff) + (carry & 0x3ffffff);
- carry >>= 26;
- carry += (w / 0x4000000) | 0;
- // NOTE: lo is 27bit maximum
- carry += lo >>> 26;
- this.words[i] = lo & 0x3ffffff;
- }
- if (carry !== 0) {
- this.words[i] = carry;
- this.length++;
- }
- return this;
- };
- BN.prototype.muln = function muln (num) {
- return this.clone().imuln(num);
- };
- // `this` * `this`
- BN.prototype.sqr = function sqr () {
- return this.mul(this);
- };
- // `this` * `this` in-place
- BN.prototype.isqr = function isqr () {
- return this.imul(this.clone());
- };
- // Math.pow(`this`, `num`)
- BN.prototype.pow = function pow (num) {
- var w = toBitArray(num);
- if (w.length === 0) return new BN(1);
- // Skip leading zeroes
- var res = this;
- for (var i = 0; i < w.length; i++, res = res.sqr()) {
- if (w[i] !== 0) break;
- }
- if (++i < w.length) {
- for (var q = res.sqr(); i < w.length; i++, q = q.sqr()) {
- if (w[i] === 0) continue;
- res = res.mul(q);
- }
- }
- return res;
- };
- // Shift-left in-place
- BN.prototype.iushln = function iushln (bits) {
- assert(typeof bits === 'number' && bits >= 0);
- var r = bits % 26;
- var s = (bits - r) / 26;
- var carryMask = (0x3ffffff >>> (26 - r)) << (26 - r);
- var i;
- if (r !== 0) {
- var carry = 0;
- for (i = 0; i < this.length; i++) {
- var newCarry = this.words[i] & carryMask;
- var c = ((this.words[i] | 0) - newCarry) << r;
- this.words[i] = c | carry;
- carry = newCarry >>> (26 - r);
- }
- if (carry) {
- this.words[i] = carry;
- this.length++;
- }
- }
- if (s !== 0) {
- for (i = this.length - 1; i >= 0; i--) {
- this.words[i + s] = this.words[i];
- }
- for (i = 0; i < s; i++) {
- this.words[i] = 0;
- }
- this.length += s;
- }
- return this.strip();
- };
- BN.prototype.ishln = function ishln (bits) {
- // TODO(indutny): implement me
- assert(this.negative === 0);
- return this.iushln(bits);
- };
- // Shift-right in-place
- // NOTE: `hint` is a lowest bit before trailing zeroes
- // NOTE: if `extended` is present - it will be filled with destroyed bits
- BN.prototype.iushrn = function iushrn (bits, hint, extended) {
- assert(typeof bits === 'number' && bits >= 0);
- var h;
- if (hint) {
- h = (hint - (hint % 26)) / 26;
- } else {
- h = 0;
- }
- var r = bits % 26;
- var s = Math.min((bits - r) / 26, this.length);
- var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r);
- var maskedWords = extended;
- h -= s;
- h = Math.max(0, h);
- // Extended mode, copy masked part
- if (maskedWords) {
- for (var i = 0; i < s; i++) {
- maskedWords.words[i] = this.words[i];
- }
- maskedWords.length = s;
- }
- if (s === 0) {
- // No-op, we should not move anything at all
- } else if (this.length > s) {
- this.length -= s;
- for (i = 0; i < this.length; i++) {
- this.words[i] = this.words[i + s];
- }
- } else {
- this.words[0] = 0;
- this.length = 1;
- }
- var carry = 0;
- for (i = this.length - 1; i >= 0 && (carry !== 0 || i >= h); i--) {
- var word = this.words[i] | 0;
- this.words[i] = (carry << (26 - r)) | (word >>> r);
- carry = word & mask;
- }
- // Push carried bits as a mask
- if (maskedWords && carry !== 0) {
- maskedWords.words[maskedWords.length++] = carry;
- }
- if (this.length === 0) {
- this.words[0] = 0;
- this.length = 1;
- }
- return this.strip();
- };
- BN.prototype.ishrn = function ishrn (bits, hint, extended) {
- // TODO(indutny): implement me
- assert(this.negative === 0);
- return this.iushrn(bits, hint, extended);
- };
- // Shift-left
- BN.prototype.shln = function shln (bits) {
- return this.clone().ishln(bits);
- };
- BN.prototype.ushln = function ushln (bits) {
- return this.clone().iushln(bits);
- };
- // Shift-right
- BN.prototype.shrn = function shrn (bits) {
- return this.clone().ishrn(bits);
- };
- BN.prototype.ushrn = function ushrn (bits) {
- return this.clone().iushrn(bits);
- };
- // Test if n bit is set
- BN.prototype.testn = function testn (bit) {
- assert(typeof bit === 'number' && bit >= 0);
- var r = bit % 26;
- var s = (bit - r) / 26;
- var q = 1 << r;
- // Fast case: bit is much higher than all existing words
- if (this.length <= s) return false;
- // Check bit and return
- var w = this.words[s];
- return !!(w & q);
- };
- // Return only lowers bits of number (in-place)
- BN.prototype.imaskn = function imaskn (bits) {
- assert(typeof bits === 'number' && bits >= 0);
- var r = bits % 26;
- var s = (bits - r) / 26;
- assert(this.negative === 0, 'imaskn works only with positive numbers');
- if (this.length <= s) {
- return this;
- }
- if (r !== 0) {
- s++;
- }
- this.length = Math.min(s, this.length);
- if (r !== 0) {
- var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r);
- this.words[this.length - 1] &= mask;
- }
- return this.strip();
- };
- // Return only lowers bits of number
- BN.prototype.maskn = function maskn (bits) {
- return this.clone().imaskn(bits);
- };
- // Add plain number `num` to `this`
- BN.prototype.iaddn = function iaddn (num) {
- assert(typeof num === 'number');
- assert(num < 0x4000000);
- if (num < 0) return this.isubn(-num);
- // Possible sign change
- if (this.negative !== 0) {
- if (this.length === 1 && (this.words[0] | 0) < num) {
- this.words[0] = num - (this.words[0] | 0);
- this.negative = 0;
- return this;
- }
- this.negative = 0;
- this.isubn(num);
- this.negative = 1;
- return this;
- }
- // Add without checks
- return this._iaddn(num);
- };
- BN.prototype._iaddn = function _iaddn (num) {
- this.words[0] += num;
- // Carry
- for (var i = 0; i < this.length && this.words[i] >= 0x4000000; i++) {
- this.words[i] -= 0x4000000;
- if (i === this.length - 1) {
- this.words[i + 1] = 1;
- } else {
- this.words[i + 1]++;
- }
- }
- this.length = Math.max(this.length, i + 1);
- return this;
- };
- // Subtract plain number `num` from `this`
- BN.prototype.isubn = function isubn (num) {
- assert(typeof num === 'number');
- assert(num < 0x4000000);
- if (num < 0) return this.iaddn(-num);
- if (this.negative !== 0) {
- this.negative = 0;
- this.iaddn(num);
- this.negative = 1;
- return this;
- }
- this.words[0] -= num;
- if (this.length === 1 && this.words[0] < 0) {
- this.words[0] = -this.words[0];
- this.negative = 1;
- } else {
- // Carry
- for (var i = 0; i < this.length && this.words[i] < 0; i++) {
- this.words[i] += 0x4000000;
- this.words[i + 1] -= 1;
- }
- }
- return this.strip();
- };
- BN.prototype.addn = function addn (num) {
- return this.clone().iaddn(num);
- };
- BN.prototype.subn = function subn (num) {
- return this.clone().isubn(num);
- };
- BN.prototype.iabs = function iabs () {
- this.negative = 0;
- return this;
- };
- BN.prototype.abs = function abs () {
- return this.clone().iabs();
- };
- BN.prototype._ishlnsubmul = function _ishlnsubmul (num, mul, shift) {
- var len = num.length + shift;
- var i;
- this._expand(len);
- var w;
- var carry = 0;
- for (i = 0; i < num.length; i++) {
- w = (this.words[i + shift] | 0) + carry;
- var right = (num.words[i] | 0) * mul;
- w -= right & 0x3ffffff;
- carry = (w >> 26) - ((right / 0x4000000) | 0);
- this.words[i + shift] = w & 0x3ffffff;
- }
- for (; i < this.length - shift; i++) {
- w = (this.words[i + shift] | 0) + carry;
- carry = w >> 26;
- this.words[i + shift] = w & 0x3ffffff;
- }
- if (carry === 0) return this.strip();
- // Subtraction overflow
- assert(carry === -1);
- carry = 0;
- for (i = 0; i < this.length; i++) {
- w = -(this.words[i] | 0) + carry;
- carry = w >> 26;
- this.words[i] = w & 0x3ffffff;
- }
- this.negative = 1;
- return this.strip();
- };
- BN.prototype._wordDiv = function _wordDiv (num, mode) {
- var shift = this.length - num.length;
- var a = this.clone();
- var b = num;
- // Normalize
- var bhi = b.words[b.length - 1] | 0;
- var bhiBits = this._countBits(bhi);
- shift = 26 - bhiBits;
- if (shift !== 0) {
- b = b.ushln(shift);
- a.iushln(shift);
- bhi = b.words[b.length - 1] | 0;
- }
- // Initialize quotient
- var m = a.length - b.length;
- var q;
- if (mode !== 'mod') {
- q = new BN(null);
- q.length = m + 1;
- q.words = new Array(q.length);
- for (var i = 0; i < q.length; i++) {
- q.words[i] = 0;
- }
- }
- var diff = a.clone()._ishlnsubmul(b, 1, m);
- if (diff.negative === 0) {
- a = diff;
- if (q) {
- q.words[m] = 1;
- }
- }
- for (var j = m - 1; j >= 0; j--) {
- var qj = (a.words[b.length + j] | 0) * 0x4000000 +
- (a.words[b.length + j - 1] | 0);
- // NOTE: (qj / bhi) is (0x3ffffff * 0x4000000 + 0x3ffffff) / 0x2000000 max
- // (0x7ffffff)
- qj = Math.min((qj / bhi) | 0, 0x3ffffff);
- a._ishlnsubmul(b, qj, j);
- while (a.negative !== 0) {
- qj--;
- a.negative = 0;
- a._ishlnsubmul(b, 1, j);
- if (!a.isZero()) {
- a.negative ^= 1;
- }
- }
- if (q) {
- q.words[j] = qj;
- }
- }
- if (q) {
- q.strip();
- }
- a.strip();
- // Denormalize
- if (mode !== 'div' && shift !== 0) {
- a.iushrn(shift);
- }
- return {
- div: q || null,
- mod: a
- };
- };
- // NOTE: 1) `mode` can be set to `mod` to request mod only,
- // to `div` to request div only, or be absent to
- // request both div & mod
- // 2) `positive` is true if unsigned mod is requested
- BN.prototype.divmod = function divmod (num, mode, positive) {
- assert(!num.isZero());
- if (this.isZero()) {
- return {
- div: new BN(0),
- mod: new BN(0)
- };
- }
- var div, mod, res;
- if (this.negative !== 0 && num.negative === 0) {
- res = this.neg().divmod(num, mode);
- if (mode !== 'mod') {
- div = res.div.neg();
- }
- if (mode !== 'div') {
- mod = res.mod.neg();
- if (positive && mod.negative !== 0) {
- mod.iadd(num);
- }
- }
- return {
- div: div,
- mod: mod
- };
- }
- if (this.negative === 0 && num.negative !== 0) {
- res = this.divmod(num.neg(), mode);
- if (mode !== 'mod') {
- div = res.div.neg();
- }
- return {
- div: div,
- mod: res.mod
- };
- }
- if ((this.negative & num.negative) !== 0) {
- res = this.neg().divmod(num.neg(), mode);
- if (mode !== 'div') {
- mod = res.mod.neg();
- if (positive && mod.negative !== 0) {
- mod.isub(num);
- }
- }
- return {
- div: res.div,
- mod: mod
- };
- }
- // Both numbers are positive at this point
- // Strip both numbers to approximate shift value
- if (num.length > this.length || this.cmp(num) < 0) {
- return {
- div: new BN(0),
- mod: this
- };
- }
- // Very short reduction
- if (num.length === 1) {
- if (mode === 'div') {
- return {
- div: this.divn(num.words[0]),
- mod: null
- };
- }
- if (mode === 'mod') {
- return {
- div: null,
- mod: new BN(this.modn(num.words[0]))
- };
- }
- return {
- div: this.divn(num.words[0]),
- mod: new BN(this.modn(num.words[0]))
- };
- }
- return this._wordDiv(num, mode);
- };
- // Find `this` / `num`
- BN.prototype.div = function div (num) {
- return this.divmod(num, 'div', false).div;
- };
- // Find `this` % `num`
- BN.prototype.mod = function mod (num) {
- return this.divmod(num, 'mod', false).mod;
- };
- BN.prototype.umod = function umod (num) {
- return this.divmod(num, 'mod', true).mod;
- };
- // Find Round(`this` / `num`)
- BN.prototype.divRound = function divRound (num) {
- var dm = this.divmod(num);
- // Fast case - exact division
- if (dm.mod.isZero()) return dm.div;
- var mod = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod;
- var half = num.ushrn(1);
- var r2 = num.andln(1);
- var cmp = mod.cmp(half);
- // Round down
- if (cmp < 0 || r2 === 1 && cmp === 0) return dm.div;
- // Round up
- return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1);
- };
- BN.prototype.modn = function modn (num) {
- assert(num <= 0x3ffffff);
- var p = (1 << 26) % num;
- var acc = 0;
- for (var i = this.length - 1; i >= 0; i--) {
- acc = (p * acc + (this.words[i] | 0)) % num;
- }
- return acc;
- };
- // In-place division by number
- BN.prototype.idivn = function idivn (num) {
- assert(num <= 0x3ffffff);
- var carry = 0;
- for (var i = this.length - 1; i >= 0; i--) {
- var w = (this.words[i] | 0) + carry * 0x4000000;
- this.words[i] = (w / num) | 0;
- carry = w % num;
- }
- return this.strip();
- };
- BN.prototype.divn = function divn (num) {
- return this.clone().idivn(num);
- };
- BN.prototype.egcd = function egcd (p) {
- assert(p.negative === 0);
- assert(!p.isZero());
- var x = this;
- var y = p.clone();
- if (x.negative !== 0) {
- x = x.umod(p);
- } else {
- x = x.clone();
- }
- // A * x + B * y = x
- var A = new BN(1);
- var B = new BN(0);
- // C * x + D * y = y
- var C = new BN(0);
- var D = new BN(1);
- var g = 0;
- while (x.isEven() && y.isEven()) {
- x.iushrn(1);
- y.iushrn(1);
- ++g;
- }
- var yp = y.clone();
- var xp = x.clone();
- while (!x.isZero()) {
- for (var i = 0, im = 1; (x.words[0] & im) === 0 && i < 26; ++i, im <<= 1);
- if (i > 0) {
- x.iushrn(i);
- while (i-- > 0) {
- if (A.isOdd() || B.isOdd()) {
- A.iadd(yp);
- B.isub(xp);
- }
- A.iushrn(1);
- B.iushrn(1);
- }
- }
- for (var j = 0, jm = 1; (y.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1);
- if (j > 0) {
- y.iushrn(j);
- while (j-- > 0) {
- if (C.isOdd() || D.isOdd()) {
- C.iadd(yp);
- D.isub(xp);
- }
- C.iushrn(1);
- D.iushrn(1);
- }
- }
- if (x.cmp(y) >= 0) {
- x.isub(y);
- A.isub(C);
- B.isub(D);
- } else {
- y.isub(x);
- C.isub(A);
- D.isub(B);
- }
- }
- return {
- a: C,
- b: D,
- gcd: y.iushln(g)
- };
- };
- // This is reduced incarnation of the binary EEA
- // above, designated to invert members of the
- // _prime_ fields F(p) at a maximal speed
- BN.prototype._invmp = function _invmp (p) {
- assert(p.negative === 0);
- assert(!p.isZero());
- var a = this;
- var b = p.clone();
- if (a.negative !== 0) {
- a = a.umod(p);
- } else {
- a = a.clone();
- }
- var x1 = new BN(1);
- var x2 = new BN(0);
- var delta = b.clone();
- while (a.cmpn(1) > 0 && b.cmpn(1) > 0) {
- for (var i = 0, im = 1; (a.words[0] & im) === 0 && i < 26; ++i, im <<= 1);
- if (i > 0) {
- a.iushrn(i);
- while (i-- > 0) {
- if (x1.isOdd()) {
- x1.iadd(delta);
- }
- x1.iushrn(1);
- }
- }
- for (var j = 0, jm = 1; (b.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1);
- if (j > 0) {
- b.iushrn(j);
- while (j-- > 0) {
- if (x2.isOdd()) {
- x2.iadd(delta);
- }
- x2.iushrn(1);
- }
- }
- if (a.cmp(b) >= 0) {
- a.isub(b);
- x1.isub(x2);
- } else {
- b.isub(a);
- x2.isub(x1);
- }
- }
- var res;
- if (a.cmpn(1) === 0) {
- res = x1;
- } else {
- res = x2;
- }
- if (res.cmpn(0) < 0) {
- res.iadd(p);
- }
- return res;
- };
- BN.prototype.gcd = function gcd (num) {
- if (this.isZero()) return num.abs();
- if (num.isZero()) return this.abs();
- var a = this.clone();
- var b = num.clone();
- a.negative = 0;
- b.negative = 0;
- // Remove common factor of two
- for (var shift = 0; a.isEven() && b.isEven(); shift++) {
- a.iushrn(1);
- b.iushrn(1);
- }
- do {
- while (a.isEven()) {
- a.iushrn(1);
- }
- while (b.isEven()) {
- b.iushrn(1);
- }
- var r = a.cmp(b);
- if (r < 0) {
- // Swap `a` and `b` to make `a` always bigger than `b`
- var t = a;
- a = b;
- b = t;
- } else if (r === 0 || b.cmpn(1) === 0) {
- break;
- }
- a.isub(b);
- } while (true);
- return b.iushln(shift);
- };
- // Invert number in the field F(num)
- BN.prototype.invm = function invm (num) {
- return this.egcd(num).a.umod(num);
- };
- BN.prototype.isEven = function isEven () {
- return (this.words[0] & 1) === 0;
- };
- BN.prototype.isOdd = function isOdd () {
- return (this.words[0] & 1) === 1;
- };
- // And first word and num
- BN.prototype.andln = function andln (num) {
- return this.words[0] & num;
- };
- // Increment at the bit position in-line
- BN.prototype.bincn = function bincn (bit) {
- assert(typeof bit === 'number');
- var r = bit % 26;
- var s = (bit - r) / 26;
- var q = 1 << r;
- // Fast case: bit is much higher than all existing words
- if (this.length <= s) {
- this._expand(s + 1);
- this.words[s] |= q;
- return this;
- }
- // Add bit and propagate, if needed
- var carry = q;
- for (var i = s; carry !== 0 && i < this.length; i++) {
- var w = this.words[i] | 0;
- w += carry;
- carry = w >>> 26;
- w &= 0x3ffffff;
- this.words[i] = w;
- }
- if (carry !== 0) {
- this.words[i] = carry;
- this.length++;
- }
- return this;
- };
- BN.prototype.isZero = function isZero () {
- return this.length === 1 && this.words[0] === 0;
- };
- BN.prototype.cmpn = function cmpn (num) {
- var negative = num < 0;
- if (this.negative !== 0 && !negative) return -1;
- if (this.negative === 0 && negative) return 1;
- this.strip();
- var res;
- if (this.length > 1) {
- res = 1;
- } else {
- if (negative) {
- num = -num;
- }
- assert(num <= 0x3ffffff, 'Number is too big');
- var w = this.words[0] | 0;
- res = w === num ? 0 : w < num ? -1 : 1;
- }
- if (this.negative !== 0) return -res | 0;
- return res;
- };
- // Compare two numbers and return:
- // 1 - if `this` > `num`
- // 0 - if `this` == `num`
- // -1 - if `this` < `num`
- BN.prototype.cmp = function cmp (num) {
- if (this.negative !== 0 && num.negative === 0) return -1;
- if (this.negative === 0 && num.negative !== 0) return 1;
- var res = this.ucmp(num);
- if (this.negative !== 0) return -res | 0;
- return res;
- };
- // Unsigned comparison
- BN.prototype.ucmp = function ucmp (num) {
- // At this point both numbers have the same sign
- if (this.length > num.length) return 1;
- if (this.length < num.length) return -1;
- var res = 0;
- for (var i = this.length - 1; i >= 0; i--) {
- var a = this.words[i] | 0;
- var b = num.words[i] | 0;
- if (a === b) continue;
- if (a < b) {
- res = -1;
- } else if (a > b) {
- res = 1;
- }
- break;
- }
- return res;
- };
- BN.prototype.gtn = function gtn (num) {
- return this.cmpn(num) === 1;
- };
- BN.prototype.gt = function gt (num) {
- return this.cmp(num) === 1;
- };
- BN.prototype.gten = function gten (num) {
- return this.cmpn(num) >= 0;
- };
- BN.prototype.gte = function gte (num) {
- return this.cmp(num) >= 0;
- };
- BN.prototype.ltn = function ltn (num) {
- return this.cmpn(num) === -1;
- };
- BN.prototype.lt = function lt (num) {
- return this.cmp(num) === -1;
- };
- BN.prototype.lten = function lten (num) {
- return this.cmpn(num) <= 0;
- };
- BN.prototype.lte = function lte (num) {
- return this.cmp(num) <= 0;
- };
- BN.prototype.eqn = function eqn (num) {
- return this.cmpn(num) === 0;
- };
- BN.prototype.eq = function eq (num) {
- return this.cmp(num) === 0;
- };
- //
- // A reduce context, could be using montgomery or something better, depending
- // on the `m` itself.
- //
- BN.red = function red (num) {
- return new Red(num);
- };
- BN.prototype.toRed = function toRed (ctx) {
- assert(!this.red, 'Already a number in reduction context');
- assert(this.negative === 0, 'red works only with positives');
- return ctx.convertTo(this)._forceRed(ctx);
- };
- BN.prototype.fromRed = function fromRed () {
- assert(this.red, 'fromRed works only with numbers in reduction context');
- return this.red.convertFrom(this);
- };
- BN.prototype._forceRed = function _forceRed (ctx) {
- this.red = ctx;
- return this;
- };
- BN.prototype.forceRed = function forceRed (ctx) {
- assert(!this.red, 'Already a number in reduction context');
- return this._forceRed(ctx);
- };
- BN.prototype.redAdd = function redAdd (num) {
- assert(this.red, 'redAdd works only with red numbers');
- return this.red.add(this, num);
- };
- BN.prototype.redIAdd = function redIAdd (num) {
- assert(this.red, 'redIAdd works only with red numbers');
- return this.red.iadd(this, num);
- };
- BN.prototype.redSub = function redSub (num) {
- assert(this.red, 'redSub works only with red numbers');
- return this.red.sub(this, num);
- };
- BN.prototype.redISub = function redISub (num) {
- assert(this.red, 'redISub works only with red numbers');
- return this.red.isub(this, num);
- };
- BN.prototype.redShl = function redShl (num) {
- assert(this.red, 'redShl works only with red numbers');
- return this.red.shl(this, num);
- };
- BN.prototype.redMul = function redMul (num) {
- assert(this.red, 'redMul works only with red numbers');
- this.red._verify2(this, num);
- return this.red.mul(this, num);
- };
- BN.prototype.redIMul = function redIMul (num) {
- assert(this.red, 'redMul works only with red numbers');
- this.red._verify2(this, num);
- return this.red.imul(this, num);
- };
- BN.prototype.redSqr = function redSqr () {
- assert(this.red, 'redSqr works only with red numbers');
- this.red._verify1(this);
- return this.red.sqr(this);
- };
- BN.prototype.redISqr = function redISqr () {
- assert(this.red, 'redISqr works only with red numbers');
- this.red._verify1(this);
- return this.red.isqr(this);
- };
- // Square root over p
- BN.prototype.redSqrt = function redSqrt () {
- assert(this.red, 'redSqrt works only with red numbers');
- this.red._verify1(this);
- return this.red.sqrt(this);
- };
- BN.prototype.redInvm = function redInvm () {
- assert(this.red, 'redInvm works only with red numbers');
- this.red._verify1(this);
- return this.red.invm(this);
- };
- // Return negative clone of `this` % `red modulo`
- BN.prototype.redNeg = function redNeg () {
- assert(this.red, 'redNeg works only with red numbers');
- this.red._verify1(this);
- return this.red.neg(this);
- };
- BN.prototype.redPow = function redPow (num) {
- assert(this.red && !num.red, 'redPow(normalNum)');
- this.red._verify1(this);
- return this.red.pow(this, num);
- };
- // Prime numbers with efficient reduction
- var primes = {
- k256: null,
- p224: null,
- p192: null,
- p25519: null
- };
- // Pseudo-Mersenne prime
- function MPrime (name, p) {
- // P = 2 ^ N - K
- this.name = name;
- this.p = new BN(p, 16);
- this.n = this.p.bitLength();
- this.k = new BN(1).iushln(this.n).isub(this.p);
- this.tmp = this._tmp();
- }
- MPrime.prototype._tmp = function _tmp () {
- var tmp = new BN(null);
- tmp.words = new Array(Math.ceil(this.n / 13));
- return tmp;
- };
- MPrime.prototype.ireduce = function ireduce (num) {
- // Assumes that `num` is less than `P^2`
- // num = HI * (2 ^ N - K) + HI * K + LO = HI * K + LO (mod P)
- var r = num;
- var rlen;
- do {
- this.split(r, this.tmp);
- r = this.imulK(r);
- r = r.iadd(this.tmp);
- rlen = r.bitLength();
- } while (rlen > this.n);
- var cmp = rlen < this.n ? -1 : r.ucmp(this.p);
- if (cmp === 0) {
- r.words[0] = 0;
- r.length = 1;
- } else if (cmp > 0) {
- r.isub(this.p);
- } else {
- if (r.strip !== undefined) {
- // r is BN v4 instance
- r.strip();
- } else {
- // r is BN v5 instance
- r._strip();
- }
- }
- return r;
- };
- MPrime.prototype.split = function split (input, out) {
- input.iushrn(this.n, 0, out);
- };
- MPrime.prototype.imulK = function imulK (num) {
- return num.imul(this.k);
- };
- function K256 () {
- MPrime.call(
- this,
- 'k256',
- 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f');
- }
- inherits(K256, MPrime);
- K256.prototype.split = function split (input, output) {
- // 256 = 9 * 26 + 22
- var mask = 0x3fffff;
- var outLen = Math.min(input.length, 9);
- for (var i = 0; i < outLen; i++) {
- output.words[i] = input.words[i];
- }
- output.length = outLen;
- if (input.length <= 9) {
- input.words[0] = 0;
- input.length = 1;
- return;
- }
- // Shift by 9 limbs
- var prev = input.words[9];
- output.words[output.length++] = prev & mask;
- for (i = 10; i < input.length; i++) {
- var next = input.words[i] | 0;
- input.words[i - 10] = ((next & mask) << 4) | (prev >>> 22);
- prev = next;
- }
- prev >>>= 22;
- input.words[i - 10] = prev;
- if (prev === 0 && input.length > 10) {
- input.length -= 10;
- } else {
- input.length -= 9;
- }
- };
- K256.prototype.imulK = function imulK (num) {
- // K = 0x1000003d1 = [ 0x40, 0x3d1 ]
- num.words[num.length] = 0;
- num.words[num.length + 1] = 0;
- num.length += 2;
- // bounded at: 0x40 * 0x3ffffff + 0x3d0 = 0x100000390
- var lo = 0;
- for (var i = 0; i < num.length; i++) {
- var w = num.words[i] | 0;
- lo += w * 0x3d1;
- num.words[i] = lo & 0x3ffffff;
- lo = w * 0x40 + ((lo / 0x4000000) | 0);
- }
- // Fast length reduction
- if (num.words[num.length - 1] === 0) {
- num.length--;
- if (num.words[num.length - 1] === 0) {
- num.length--;
- }
- }
- return num;
- };
- function P224 () {
- MPrime.call(
- this,
- 'p224',
- 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001');
- }
- inherits(P224, MPrime);
- function P192 () {
- MPrime.call(
- this,
- 'p192',
- 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff');
- }
- inherits(P192, MPrime);
- function P25519 () {
- // 2 ^ 255 - 19
- MPrime.call(
- this,
- '25519',
- '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed');
- }
- inherits(P25519, MPrime);
- P25519.prototype.imulK = function imulK (num) {
- // K = 0x13
- var carry = 0;
- for (var i = 0; i < num.length; i++) {
- var hi = (num.words[i] | 0) * 0x13 + carry;
- var lo = hi & 0x3ffffff;
- hi >>>= 26;
- num.words[i] = lo;
- carry = hi;
- }
- if (carry !== 0) {
- num.words[num.length++] = carry;
- }
- return num;
- };
- // Exported mostly for testing purposes, use plain name instead
- BN._prime = function prime (name) {
- // Cached version of prime
- if (primes[name]) return primes[name];
- var prime;
- if (name === 'k256') {
- prime = new K256();
- } else if (name === 'p224') {
- prime = new P224();
- } else if (name === 'p192') {
- prime = new P192();
- } else if (name === 'p25519') {
- prime = new P25519();
- } else {
- throw new Error('Unknown prime ' + name);
- }
- primes[name] = prime;
- return prime;
- };
- //
- // Base reduction engine
- //
- function Red (m) {
- if (typeof m === 'string') {
- var prime = BN._prime(m);
- this.m = prime.p;
- this.prime = prime;
- } else {
- assert(m.gtn(1), 'modulus must be greater than 1');
- this.m = m;
- this.prime = null;
- }
- }
- Red.prototype._verify1 = function _verify1 (a) {
- assert(a.negative === 0, 'red works only with positives');
- assert(a.red, 'red works only with red numbers');
- };
- Red.prototype._verify2 = function _verify2 (a, b) {
- assert((a.negative | b.negative) === 0, 'red works only with positives');
- assert(a.red && a.red === b.red,
- 'red works only with red numbers');
- };
- Red.prototype.imod = function imod (a) {
- if (this.prime) return this.prime.ireduce(a)._forceRed(this);
- return a.umod(this.m)._forceRed(this);
- };
- Red.prototype.neg = function neg (a) {
- if (a.isZero()) {
- return a.clone();
- }
- return this.m.sub(a)._forceRed(this);
- };
- Red.prototype.add = function add (a, b) {
- this._verify2(a, b);
- var res = a.add(b);
- if (res.cmp(this.m) >= 0) {
- res.isub(this.m);
- }
- return res._forceRed(this);
- };
- Red.prototype.iadd = function iadd (a, b) {
- this._verify2(a, b);
- var res = a.iadd(b);
- if (res.cmp(this.m) >= 0) {
- res.isub(this.m);
- }
- return res;
- };
- Red.prototype.sub = function sub (a, b) {
- this._verify2(a, b);
- var res = a.sub(b);
- if (res.cmpn(0) < 0) {
- res.iadd(this.m);
- }
- return res._forceRed(this);
- };
- Red.prototype.isub = function isub (a, b) {
- this._verify2(a, b);
- var res = a.isub(b);
- if (res.cmpn(0) < 0) {
- res.iadd(this.m);
- }
- return res;
- };
- Red.prototype.shl = function shl (a, num) {
- this._verify1(a);
- return this.imod(a.ushln(num));
- };
- Red.prototype.imul = function imul (a, b) {
- this._verify2(a, b);
- return this.imod(a.imul(b));
- };
- Red.prototype.mul = function mul (a, b) {
- this._verify2(a, b);
- return this.imod(a.mul(b));
- };
- Red.prototype.isqr = function isqr (a) {
- return this.imul(a, a.clone());
- };
- Red.prototype.sqr = function sqr (a) {
- return this.mul(a, a);
- };
- Red.prototype.sqrt = function sqrt (a) {
- if (a.isZero()) return a.clone();
- var mod3 = this.m.andln(3);
- assert(mod3 % 2 === 1);
- // Fast case
- if (mod3 === 3) {
- var pow = this.m.add(new BN(1)).iushrn(2);
- return this.pow(a, pow);
- }
- // Tonelli-Shanks algorithm (Totally unoptimized and slow)
- //
- // Find Q and S, that Q * 2 ^ S = (P - 1)
- var q = this.m.subn(1);
- var s = 0;
- while (!q.isZero() && q.andln(1) === 0) {
- s++;
- q.iushrn(1);
- }
- assert(!q.isZero());
- var one = new BN(1).toRed(this);
- var nOne = one.redNeg();
- // Find quadratic non-residue
- // NOTE: Max is such because of generalized Riemann hypothesis.
- var lpow = this.m.subn(1).iushrn(1);
- var z = this.m.bitLength();
- z = new BN(2 * z * z).toRed(this);
- while (this.pow(z, lpow).cmp(nOne) !== 0) {
- z.redIAdd(nOne);
- }
- var c = this.pow(z, q);
- var r = this.pow(a, q.addn(1).iushrn(1));
- var t = this.pow(a, q);
- var m = s;
- while (t.cmp(one) !== 0) {
- var tmp = t;
- for (var i = 0; tmp.cmp(one) !== 0; i++) {
- tmp = tmp.redSqr();
- }
- assert(i < m);
- var b = this.pow(c, new BN(1).iushln(m - i - 1));
- r = r.redMul(b);
- c = b.redSqr();
- t = t.redMul(c);
- m = i;
- }
- return r;
- };
- Red.prototype.invm = function invm (a) {
- var inv = a._invmp(this.m);
- if (inv.negative !== 0) {
- inv.negative = 0;
- return this.imod(inv).redNeg();
- } else {
- return this.imod(inv);
- }
- };
- Red.prototype.pow = function pow (a, num) {
- if (num.isZero()) return new BN(1).toRed(this);
- if (num.cmpn(1) === 0) return a.clone();
- var windowSize = 4;
- var wnd = new Array(1 << windowSize);
- wnd[0] = new BN(1).toRed(this);
- wnd[1] = a;
- for (var i = 2; i < wnd.length; i++) {
- wnd[i] = this.mul(wnd[i - 1], a);
- }
- var res = wnd[0];
- var current = 0;
- var currentLen = 0;
- var start = num.bitLength() % 26;
- if (start === 0) {
- start = 26;
- }
- for (i = num.length - 1; i >= 0; i--) {
- var word = num.words[i];
- for (var j = start - 1; j >= 0; j--) {
- var bit = (word >> j) & 1;
- if (res !== wnd[0]) {
- res = this.sqr(res);
- }
- if (bit === 0 && current === 0) {
- currentLen = 0;
- continue;
- }
- current <<= 1;
- current |= bit;
- currentLen++;
- if (currentLen !== windowSize && (i !== 0 || j !== 0)) continue;
- res = this.mul(res, wnd[current]);
- currentLen = 0;
- current = 0;
- }
- start = 26;
- }
- return res;
- };
- Red.prototype.convertTo = function convertTo (num) {
- var r = num.umod(this.m);
- return r === num ? r.clone() : r;
- };
- Red.prototype.convertFrom = function convertFrom (num) {
- var res = num.clone();
- res.red = null;
- return res;
- };
- //
- // Montgomery method engine
- //
- BN.mont = function mont (num) {
- return new Mont(num);
- };
- function Mont (m) {
- Red.call(this, m);
- this.shift = this.m.bitLength();
- if (this.shift % 26 !== 0) {
- this.shift += 26 - (this.shift % 26);
- }
- this.r = new BN(1).iushln(this.shift);
- this.r2 = this.imod(this.r.sqr());
- this.rinv = this.r._invmp(this.m);
- this.minv = this.rinv.mul(this.r).isubn(1).div(this.m);
- this.minv = this.minv.umod(this.r);
- this.minv = this.r.sub(this.minv);
- }
- inherits(Mont, Red);
- Mont.prototype.convertTo = function convertTo (num) {
- return this.imod(num.ushln(this.shift));
- };
- Mont.prototype.convertFrom = function convertFrom (num) {
- var r = this.imod(num.mul(this.rinv));
- r.red = null;
- return r;
- };
- Mont.prototype.imul = function imul (a, b) {
- if (a.isZero() || b.isZero()) {
- a.words[0] = 0;
- a.length = 1;
- return a;
- }
- var t = a.imul(b);
- var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);
- var u = t.isub(c).iushrn(this.shift);
- var res = u;
- if (u.cmp(this.m) >= 0) {
- res = u.isub(this.m);
- } else if (u.cmpn(0) < 0) {
- res = u.iadd(this.m);
- }
- return res._forceRed(this);
- };
- Mont.prototype.mul = function mul (a, b) {
- if (a.isZero() || b.isZero()) return new BN(0)._forceRed(this);
- var t = a.mul(b);
- var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);
- var u = t.isub(c).iushrn(this.shift);
- var res = u;
- if (u.cmp(this.m) >= 0) {
- res = u.isub(this.m);
- } else if (u.cmpn(0) < 0) {
- res = u.iadd(this.m);
- }
- return res._forceRed(this);
- };
- Mont.prototype.invm = function invm (a) {
- // (AR)^-1 * R^2 = (A^-1 * R^-1) * R^2 = A^-1 * R
- var res = this.imod(a._invmp(this.m).mul(this.r2));
- return res._forceRed(this);
- };
- })(typeof module === 'undefined' || module, this);
- },{"buffer":undefined}],198:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.version = void 0;
- exports.version = "bytes/5.6.0";
- },{}],199:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.joinSignature = exports.splitSignature = exports.hexZeroPad = exports.hexStripZeros = exports.hexValue = exports.hexConcat = exports.hexDataSlice = exports.hexDataLength = exports.hexlify = exports.isHexString = exports.zeroPad = exports.stripZeros = exports.concat = exports.arrayify = exports.isBytes = exports.isBytesLike = void 0;
- var logger_1 = _dereq_("@ethersproject/logger");
- var _version_1 = _dereq_("./_version");
- var logger = new logger_1.Logger(_version_1.version);
- ///////////////////////////////
- function isHexable(value) {
- return !!(value.toHexString);
- }
- function addSlice(array) {
- if (array.slice) {
- return array;
- }
- array.slice = function () {
- var args = Array.prototype.slice.call(arguments);
- return addSlice(new Uint8Array(Array.prototype.slice.apply(array, args)));
- };
- return array;
- }
- function isBytesLike(value) {
- return ((isHexString(value) && !(value.length % 2)) || isBytes(value));
- }
- exports.isBytesLike = isBytesLike;
- function isInteger(value) {
- return (typeof (value) === "number" && value == value && (value % 1) === 0);
- }
- function isBytes(value) {
- if (value == null) {
- return false;
- }
- if (value.constructor === Uint8Array) {
- return true;
- }
- if (typeof (value) === "string") {
- return false;
- }
- if (!isInteger(value.length) || value.length < 0) {
- return false;
- }
- for (var i = 0; i < value.length; i++) {
- var v = value[i];
- if (!isInteger(v) || v < 0 || v >= 256) {
- return false;
- }
- }
- return true;
- }
- exports.isBytes = isBytes;
- function arrayify(value, options) {
- if (!options) {
- options = {};
- }
- if (typeof (value) === "number") {
- logger.checkSafeUint53(value, "invalid arrayify value");
- var result = [];
- while (value) {
- result.unshift(value & 0xff);
- value = parseInt(String(value / 256));
- }
- if (result.length === 0) {
- result.push(0);
- }
- return addSlice(new Uint8Array(result));
- }
- if (options.allowMissingPrefix && typeof (value) === "string" && value.substring(0, 2) !== "0x") {
- value = "0x" + value;
- }
- if (isHexable(value)) {
- value = value.toHexString();
- }
- if (isHexString(value)) {
- var hex = value.substring(2);
- if (hex.length % 2) {
- if (options.hexPad === "left") {
- hex = "0x0" + hex.substring(2);
- }
- else if (options.hexPad === "right") {
- hex += "0";
- }
- else {
- logger.throwArgumentError("hex data is odd-length", "value", value);
- }
- }
- var result = [];
- for (var i = 0; i < hex.length; i += 2) {
- result.push(parseInt(hex.substring(i, i + 2), 16));
- }
- return addSlice(new Uint8Array(result));
- }
- if (isBytes(value)) {
- return addSlice(new Uint8Array(value));
- }
- return logger.throwArgumentError("invalid arrayify value", "value", value);
- }
- exports.arrayify = arrayify;
- function concat(items) {
- var objects = items.map(function (item) { return arrayify(item); });
- var length = objects.reduce(function (accum, item) { return (accum + item.length); }, 0);
- var result = new Uint8Array(length);
- objects.reduce(function (offset, object) {
- result.set(object, offset);
- return offset + object.length;
- }, 0);
- return addSlice(result);
- }
- exports.concat = concat;
- function stripZeros(value) {
- var result = arrayify(value);
- if (result.length === 0) {
- return result;
- }
- // Find the first non-zero entry
- var start = 0;
- while (start < result.length && result[start] === 0) {
- start++;
- }
- // If we started with zeros, strip them
- if (start) {
- result = result.slice(start);
- }
- return result;
- }
- exports.stripZeros = stripZeros;
- function zeroPad(value, length) {
- value = arrayify(value);
- if (value.length > length) {
- logger.throwArgumentError("value out of range", "value", arguments[0]);
- }
- var result = new Uint8Array(length);
- result.set(value, length - value.length);
- return addSlice(result);
- }
- exports.zeroPad = zeroPad;
- function isHexString(value, length) {
- if (typeof (value) !== "string" || !value.match(/^0x[0-9A-Fa-f]*$/)) {
- return false;
- }
- if (length && value.length !== 2 + 2 * length) {
- return false;
- }
- return true;
- }
- exports.isHexString = isHexString;
- var HexCharacters = "0123456789abcdef";
- function hexlify(value, options) {
- if (!options) {
- options = {};
- }
- if (typeof (value) === "number") {
- logger.checkSafeUint53(value, "invalid hexlify value");
- var hex = "";
- while (value) {
- hex = HexCharacters[value & 0xf] + hex;
- value = Math.floor(value / 16);
- }
- if (hex.length) {
- if (hex.length % 2) {
- hex = "0" + hex;
- }
- return "0x" + hex;
- }
- return "0x00";
- }
- if (typeof (value) === "bigint") {
- value = value.toString(16);
- if (value.length % 2) {
- return ("0x0" + value);
- }
- return "0x" + value;
- }
- if (options.allowMissingPrefix && typeof (value) === "string" && value.substring(0, 2) !== "0x") {
- value = "0x" + value;
- }
- if (isHexable(value)) {
- return value.toHexString();
- }
- if (isHexString(value)) {
- if (value.length % 2) {
- if (options.hexPad === "left") {
- value = "0x0" + value.substring(2);
- }
- else if (options.hexPad === "right") {
- value += "0";
- }
- else {
- logger.throwArgumentError("hex data is odd-length", "value", value);
- }
- }
- return value.toLowerCase();
- }
- if (isBytes(value)) {
- var result = "0x";
- for (var i = 0; i < value.length; i++) {
- var v = value[i];
- result += HexCharacters[(v & 0xf0) >> 4] + HexCharacters[v & 0x0f];
- }
- return result;
- }
- return logger.throwArgumentError("invalid hexlify value", "value", value);
- }
- exports.hexlify = hexlify;
- /*
- function unoddify(value: BytesLike | Hexable | number): BytesLike | Hexable | number {
- if (typeof(value) === "string" && value.length % 2 && value.substring(0, 2) === "0x") {
- return "0x0" + value.substring(2);
- }
- return value;
- }
- */
- function hexDataLength(data) {
- if (typeof (data) !== "string") {
- data = hexlify(data);
- }
- else if (!isHexString(data) || (data.length % 2)) {
- return null;
- }
- return (data.length - 2) / 2;
- }
- exports.hexDataLength = hexDataLength;
- function hexDataSlice(data, offset, endOffset) {
- if (typeof (data) !== "string") {
- data = hexlify(data);
- }
- else if (!isHexString(data) || (data.length % 2)) {
- logger.throwArgumentError("invalid hexData", "value", data);
- }
- offset = 2 + 2 * offset;
- if (endOffset != null) {
- return "0x" + data.substring(offset, 2 + 2 * endOffset);
- }
- return "0x" + data.substring(offset);
- }
- exports.hexDataSlice = hexDataSlice;
- function hexConcat(items) {
- var result = "0x";
- items.forEach(function (item) {
- result += hexlify(item).substring(2);
- });
- return result;
- }
- exports.hexConcat = hexConcat;
- function hexValue(value) {
- var trimmed = hexStripZeros(hexlify(value, { hexPad: "left" }));
- if (trimmed === "0x") {
- return "0x0";
- }
- return trimmed;
- }
- exports.hexValue = hexValue;
- function hexStripZeros(value) {
- if (typeof (value) !== "string") {
- value = hexlify(value);
- }
- if (!isHexString(value)) {
- logger.throwArgumentError("invalid hex string", "value", value);
- }
- value = value.substring(2);
- var offset = 0;
- while (offset < value.length && value[offset] === "0") {
- offset++;
- }
- return "0x" + value.substring(offset);
- }
- exports.hexStripZeros = hexStripZeros;
- function hexZeroPad(value, length) {
- if (typeof (value) !== "string") {
- value = hexlify(value);
- }
- else if (!isHexString(value)) {
- logger.throwArgumentError("invalid hex string", "value", value);
- }
- if (value.length > 2 * length + 2) {
- logger.throwArgumentError("value out of range", "value", arguments[1]);
- }
- while (value.length < 2 * length + 2) {
- value = "0x0" + value.substring(2);
- }
- return value;
- }
- exports.hexZeroPad = hexZeroPad;
- function splitSignature(signature) {
- var result = {
- r: "0x",
- s: "0x",
- _vs: "0x",
- recoveryParam: 0,
- v: 0,
- yParityAndS: "0x",
- compact: "0x"
- };
- if (isBytesLike(signature)) {
- var bytes = arrayify(signature);
- // Get the r, s and v
- if (bytes.length === 64) {
- // EIP-2098; pull the v from the top bit of s and clear it
- result.v = 27 + (bytes[32] >> 7);
- bytes[32] &= 0x7f;
- result.r = hexlify(bytes.slice(0, 32));
- result.s = hexlify(bytes.slice(32, 64));
- }
- else if (bytes.length === 65) {
- result.r = hexlify(bytes.slice(0, 32));
- result.s = hexlify(bytes.slice(32, 64));
- result.v = bytes[64];
- }
- else {
- logger.throwArgumentError("invalid signature string", "signature", signature);
- }
- // Allow a recid to be used as the v
- if (result.v < 27) {
- if (result.v === 0 || result.v === 1) {
- result.v += 27;
- }
- else {
- logger.throwArgumentError("signature invalid v byte", "signature", signature);
- }
- }
- // Compute recoveryParam from v
- result.recoveryParam = 1 - (result.v % 2);
- // Compute _vs from recoveryParam and s
- if (result.recoveryParam) {
- bytes[32] |= 0x80;
- }
- result._vs = hexlify(bytes.slice(32, 64));
- }
- else {
- result.r = signature.r;
- result.s = signature.s;
- result.v = signature.v;
- result.recoveryParam = signature.recoveryParam;
- result._vs = signature._vs;
- // If the _vs is available, use it to populate missing s, v and recoveryParam
- // and verify non-missing s, v and recoveryParam
- if (result._vs != null) {
- var vs_1 = zeroPad(arrayify(result._vs), 32);
- result._vs = hexlify(vs_1);
- // Set or check the recid
- var recoveryParam = ((vs_1[0] >= 128) ? 1 : 0);
- if (result.recoveryParam == null) {
- result.recoveryParam = recoveryParam;
- }
- else if (result.recoveryParam !== recoveryParam) {
- logger.throwArgumentError("signature recoveryParam mismatch _vs", "signature", signature);
- }
- // Set or check the s
- vs_1[0] &= 0x7f;
- var s = hexlify(vs_1);
- if (result.s == null) {
- result.s = s;
- }
- else if (result.s !== s) {
- logger.throwArgumentError("signature v mismatch _vs", "signature", signature);
- }
- }
- // Use recid and v to populate each other
- if (result.recoveryParam == null) {
- if (result.v == null) {
- logger.throwArgumentError("signature missing v and recoveryParam", "signature", signature);
- }
- else if (result.v === 0 || result.v === 1) {
- result.recoveryParam = result.v;
- }
- else {
- result.recoveryParam = 1 - (result.v % 2);
- }
- }
- else {
- if (result.v == null) {
- result.v = 27 + result.recoveryParam;
- }
- else {
- var recId = (result.v === 0 || result.v === 1) ? result.v : (1 - (result.v % 2));
- if (result.recoveryParam !== recId) {
- logger.throwArgumentError("signature recoveryParam mismatch v", "signature", signature);
- }
- }
- }
- if (result.r == null || !isHexString(result.r)) {
- logger.throwArgumentError("signature missing or invalid r", "signature", signature);
- }
- else {
- result.r = hexZeroPad(result.r, 32);
- }
- if (result.s == null || !isHexString(result.s)) {
- logger.throwArgumentError("signature missing or invalid s", "signature", signature);
- }
- else {
- result.s = hexZeroPad(result.s, 32);
- }
- var vs = arrayify(result.s);
- if (vs[0] >= 128) {
- logger.throwArgumentError("signature s out of range", "signature", signature);
- }
- if (result.recoveryParam) {
- vs[0] |= 0x80;
- }
- var _vs = hexlify(vs);
- if (result._vs) {
- if (!isHexString(result._vs)) {
- logger.throwArgumentError("signature invalid _vs", "signature", signature);
- }
- result._vs = hexZeroPad(result._vs, 32);
- }
- // Set or check the _vs
- if (result._vs == null) {
- result._vs = _vs;
- }
- else if (result._vs !== _vs) {
- logger.throwArgumentError("signature _vs mismatch v and s", "signature", signature);
- }
- }
- result.yParityAndS = result._vs;
- result.compact = result.r + result.yParityAndS.substring(2);
- return result;
- }
- exports.splitSignature = splitSignature;
- function joinSignature(signature) {
- signature = splitSignature(signature);
- return hexlify(concat([
- signature.r,
- signature.s,
- (signature.recoveryParam ? "0x1c" : "0x1b")
- ]));
- }
- exports.joinSignature = joinSignature;
- },{"./_version":198,"@ethersproject/logger":223}],200:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.AddressZero = void 0;
- exports.AddressZero = "0x0000000000000000000000000000000000000000";
- },{}],201:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.MaxInt256 = exports.MinInt256 = exports.MaxUint256 = exports.WeiPerEther = exports.Two = exports.One = exports.Zero = exports.NegativeOne = void 0;
- var bignumber_1 = _dereq_("@ethersproject/bignumber");
- var NegativeOne = ( /*#__PURE__*/bignumber_1.BigNumber.from(-1));
- exports.NegativeOne = NegativeOne;
- var Zero = ( /*#__PURE__*/bignumber_1.BigNumber.from(0));
- exports.Zero = Zero;
- var One = ( /*#__PURE__*/bignumber_1.BigNumber.from(1));
- exports.One = One;
- var Two = ( /*#__PURE__*/bignumber_1.BigNumber.from(2));
- exports.Two = Two;
- var WeiPerEther = ( /*#__PURE__*/bignumber_1.BigNumber.from("1000000000000000000"));
- exports.WeiPerEther = WeiPerEther;
- var MaxUint256 = ( /*#__PURE__*/bignumber_1.BigNumber.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"));
- exports.MaxUint256 = MaxUint256;
- var MinInt256 = ( /*#__PURE__*/bignumber_1.BigNumber.from("-0x8000000000000000000000000000000000000000000000000000000000000000"));
- exports.MinInt256 = MinInt256;
- var MaxInt256 = ( /*#__PURE__*/bignumber_1.BigNumber.from("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"));
- exports.MaxInt256 = MaxInt256;
- },{"@ethersproject/bignumber":196}],202:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.HashZero = void 0;
- exports.HashZero = "0x0000000000000000000000000000000000000000000000000000000000000000";
- },{}],203:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.EtherSymbol = exports.HashZero = exports.MaxInt256 = exports.MinInt256 = exports.MaxUint256 = exports.WeiPerEther = exports.Two = exports.One = exports.Zero = exports.NegativeOne = exports.AddressZero = void 0;
- var addresses_1 = _dereq_("./addresses");
- Object.defineProperty(exports, "AddressZero", { enumerable: true, get: function () { return addresses_1.AddressZero; } });
- var bignumbers_1 = _dereq_("./bignumbers");
- Object.defineProperty(exports, "NegativeOne", { enumerable: true, get: function () { return bignumbers_1.NegativeOne; } });
- Object.defineProperty(exports, "Zero", { enumerable: true, get: function () { return bignumbers_1.Zero; } });
- Object.defineProperty(exports, "One", { enumerable: true, get: function () { return bignumbers_1.One; } });
- Object.defineProperty(exports, "Two", { enumerable: true, get: function () { return bignumbers_1.Two; } });
- Object.defineProperty(exports, "WeiPerEther", { enumerable: true, get: function () { return bignumbers_1.WeiPerEther; } });
- Object.defineProperty(exports, "MaxUint256", { enumerable: true, get: function () { return bignumbers_1.MaxUint256; } });
- Object.defineProperty(exports, "MinInt256", { enumerable: true, get: function () { return bignumbers_1.MinInt256; } });
- Object.defineProperty(exports, "MaxInt256", { enumerable: true, get: function () { return bignumbers_1.MaxInt256; } });
- var hashes_1 = _dereq_("./hashes");
- Object.defineProperty(exports, "HashZero", { enumerable: true, get: function () { return hashes_1.HashZero; } });
- var strings_1 = _dereq_("./strings");
- Object.defineProperty(exports, "EtherSymbol", { enumerable: true, get: function () { return strings_1.EtherSymbol; } });
- },{"./addresses":200,"./bignumbers":201,"./hashes":202,"./strings":204}],204:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.EtherSymbol = void 0;
- // NFKC (composed) // (decomposed)
- exports.EtherSymbol = "\u039e"; // "\uD835\uDF63";
- },{}],205:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.version = void 0;
- exports.version = "contracts/5.6.0";
- },{}],206:[function(_dereq_,module,exports){
- "use strict";
- var __extends = (this && this.__extends) || (function () {
- var extendStatics = function (d, b) {
- extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
- return extendStatics(d, b);
- };
- return function (d, b) {
- if (typeof b !== "function" && b !== null)
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
- return new (P || (P = Promise))(function (resolve, reject) {
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
- step((generator = generator.apply(thisArg, _arguments || [])).next());
- });
- };
- var __generator = (this && this.__generator) || function (thisArg, body) {
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
- function verb(n) { return function (v) { return step([n, v]); }; }
- function step(op) {
- if (f) throw new TypeError("Generator is already executing.");
- while (_) try {
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
- if (y = 0, t) op = [op[0] & 2, t.value];
- switch (op[0]) {
- case 0: case 1: t = op; break;
- case 4: _.label++; return { value: op[1], done: false };
- case 5: _.label++; y = op[1]; op = [0]; continue;
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
- default:
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
- if (t[2]) _.ops.pop();
- _.trys.pop(); continue;
- }
- op = body.call(thisArg, _);
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
- }
- };
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
- if (ar || !(i in from)) {
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
- ar[i] = from[i];
- }
- }
- return to.concat(ar || Array.prototype.slice.call(from));
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.ContractFactory = exports.Contract = exports.BaseContract = void 0;
- var abi_1 = _dereq_("@ethersproject/abi");
- var abstract_provider_1 = _dereq_("@ethersproject/abstract-provider");
- var abstract_signer_1 = _dereq_("@ethersproject/abstract-signer");
- var address_1 = _dereq_("@ethersproject/address");
- var bignumber_1 = _dereq_("@ethersproject/bignumber");
- var bytes_1 = _dereq_("@ethersproject/bytes");
- var properties_1 = _dereq_("@ethersproject/properties");
- var transactions_1 = _dereq_("@ethersproject/transactions");
- var logger_1 = _dereq_("@ethersproject/logger");
- var _version_1 = _dereq_("./_version");
- var logger = new logger_1.Logger(_version_1.version);
- ;
- ;
- ///////////////////////////////
- var allowedTransactionKeys = {
- chainId: true, data: true, from: true, gasLimit: true, gasPrice: true, nonce: true, to: true, value: true,
- type: true, accessList: true,
- maxFeePerGas: true, maxPriorityFeePerGas: true,
- customData: true,
- ccipReadEnabled: true
- };
- function resolveName(resolver, nameOrPromise) {
- return __awaiter(this, void 0, void 0, function () {
- var name, address;
- return __generator(this, function (_a) {
- switch (_a.label) {
- case 0: return [4 /*yield*/, nameOrPromise];
- case 1:
- name = _a.sent();
- if (typeof (name) !== "string") {
- logger.throwArgumentError("invalid address or ENS name", "name", name);
- }
- // If it is already an address, just use it (after adding checksum)
- try {
- return [2 /*return*/, (0, address_1.getAddress)(name)];
- }
- catch (error) { }
- if (!resolver) {
- logger.throwError("a provider or signer is needed to resolve ENS names", logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
- operation: "resolveName"
- });
- }
- return [4 /*yield*/, resolver.resolveName(name)];
- case 2:
- address = _a.sent();
- if (address == null) {
- logger.throwArgumentError("resolver or addr is not configured for ENS name", "name", name);
- }
- return [2 /*return*/, address];
- }
- });
- });
- }
- // Recursively replaces ENS names with promises to resolve the name and resolves all properties
- function resolveAddresses(resolver, value, paramType) {
- return __awaiter(this, void 0, void 0, function () {
- return __generator(this, function (_a) {
- switch (_a.label) {
- case 0:
- if (!Array.isArray(paramType)) return [3 /*break*/, 2];
- return [4 /*yield*/, Promise.all(paramType.map(function (paramType, index) {
- return resolveAddresses(resolver, ((Array.isArray(value)) ? value[index] : value[paramType.name]), paramType);
- }))];
- case 1: return [2 /*return*/, _a.sent()];
- case 2:
- if (!(paramType.type === "address")) return [3 /*break*/, 4];
- return [4 /*yield*/, resolveName(resolver, value)];
- case 3: return [2 /*return*/, _a.sent()];
- case 4:
- if (!(paramType.type === "tuple")) return [3 /*break*/, 6];
- return [4 /*yield*/, resolveAddresses(resolver, value, paramType.components)];
- case 5: return [2 /*return*/, _a.sent()];
- case 6:
- if (!(paramType.baseType === "array")) return [3 /*break*/, 8];
- if (!Array.isArray(value)) {
- return [2 /*return*/, Promise.reject(logger.makeError("invalid value for array", logger_1.Logger.errors.INVALID_ARGUMENT, {
- argument: "value",
- value: value
- }))];
- }
- return [4 /*yield*/, Promise.all(value.map(function (v) { return resolveAddresses(resolver, v, paramType.arrayChildren); }))];
- case 7: return [2 /*return*/, _a.sent()];
- case 8: return [2 /*return*/, value];
- }
- });
- });
- }
- function populateTransaction(contract, fragment, args) {
- return __awaiter(this, void 0, void 0, function () {
- var overrides, resolved, data, tx, ro, intrinsic, bytes, i, roValue, leftovers;
- var _this = this;
- return __generator(this, function (_a) {
- switch (_a.label) {
- case 0:
- overrides = {};
- if (args.length === fragment.inputs.length + 1 && typeof (args[args.length - 1]) === "object") {
- overrides = (0, properties_1.shallowCopy)(args.pop());
- }
- // Make sure the parameter count matches
- logger.checkArgumentCount(args.length, fragment.inputs.length, "passed to contract");
- // Populate "from" override (allow promises)
- if (contract.signer) {
- if (overrides.from) {
- // Contracts with a Signer are from the Signer's frame-of-reference;
- // but we allow overriding "from" if it matches the signer
- overrides.from = (0, properties_1.resolveProperties)({
- override: resolveName(contract.signer, overrides.from),
- signer: contract.signer.getAddress()
- }).then(function (check) { return __awaiter(_this, void 0, void 0, function () {
- return __generator(this, function (_a) {
- if ((0, address_1.getAddress)(check.signer) !== check.override) {
- logger.throwError("Contract with a Signer cannot override from", logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
- operation: "overrides.from"
- });
- }
- return [2 /*return*/, check.override];
- });
- }); });
- }
- else {
- overrides.from = contract.signer.getAddress();
- }
- }
- else if (overrides.from) {
- overrides.from = resolveName(contract.provider, overrides.from);
- //} else {
- // Contracts without a signer can override "from", and if
- // unspecified the zero address is used
- //overrides.from = AddressZero;
- }
- return [4 /*yield*/, (0, properties_1.resolveProperties)({
- args: resolveAddresses(contract.signer || contract.provider, args, fragment.inputs),
- address: contract.resolvedAddress,
- overrides: ((0, properties_1.resolveProperties)(overrides) || {})
- })];
- case 1:
- resolved = _a.sent();
- data = contract.interface.encodeFunctionData(fragment, resolved.args);
- tx = {
- data: data,
- to: resolved.address
- };
- ro = resolved.overrides;
- // Populate simple overrides
- if (ro.nonce != null) {
- tx.nonce = bignumber_1.BigNumber.from(ro.nonce).toNumber();
- }
- if (ro.gasLimit != null) {
- tx.gasLimit = bignumber_1.BigNumber.from(ro.gasLimit);
- }
- if (ro.gasPrice != null) {
- tx.gasPrice = bignumber_1.BigNumber.from(ro.gasPrice);
- }
- if (ro.maxFeePerGas != null) {
- tx.maxFeePerGas = bignumber_1.BigNumber.from(ro.maxFeePerGas);
- }
- if (ro.maxPriorityFeePerGas != null) {
- tx.maxPriorityFeePerGas = bignumber_1.BigNumber.from(ro.maxPriorityFeePerGas);
- }
- if (ro.from != null) {
- tx.from = ro.from;
- }
- if (ro.type != null) {
- tx.type = ro.type;
- }
- if (ro.accessList != null) {
- tx.accessList = (0, transactions_1.accessListify)(ro.accessList);
- }
- // If there was no "gasLimit" override, but the ABI specifies a default, use it
- if (tx.gasLimit == null && fragment.gas != null) {
- intrinsic = 21000;
- bytes = (0, bytes_1.arrayify)(data);
- for (i = 0; i < bytes.length; i++) {
- intrinsic += 4;
- if (bytes[i]) {
- intrinsic += 64;
- }
- }
- tx.gasLimit = bignumber_1.BigNumber.from(fragment.gas).add(intrinsic);
- }
- // Populate "value" override
- if (ro.value) {
- roValue = bignumber_1.BigNumber.from(ro.value);
- if (!roValue.isZero() && !fragment.payable) {
- logger.throwError("non-payable method cannot override value", logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
- operation: "overrides.value",
- value: overrides.value
- });
- }
- tx.value = roValue;
- }
- if (ro.customData) {
- tx.customData = (0, properties_1.shallowCopy)(ro.customData);
- }
- if (ro.ccipReadEnabled) {
- tx.ccipReadEnabled = !!ro.ccipReadEnabled;
- }
- // Remove the overrides
- delete overrides.nonce;
- delete overrides.gasLimit;
- delete overrides.gasPrice;
- delete overrides.from;
- delete overrides.value;
- delete overrides.type;
- delete overrides.accessList;
- delete overrides.maxFeePerGas;
- delete overrides.maxPriorityFeePerGas;
- delete overrides.customData;
- delete overrides.ccipReadEnabled;
- leftovers = Object.keys(overrides).filter(function (key) { return (overrides[key] != null); });
- if (leftovers.length) {
- logger.throwError("cannot override " + leftovers.map(function (l) { return JSON.stringify(l); }).join(","), logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
- operation: "overrides",
- overrides: leftovers
- });
- }
- return [2 /*return*/, tx];
- }
- });
- });
- }
- function buildPopulate(contract, fragment) {
- return function () {
- var args = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- args[_i] = arguments[_i];
- }
- return populateTransaction(contract, fragment, args);
- };
- }
- function buildEstimate(contract, fragment) {
- var signerOrProvider = (contract.signer || contract.provider);
- return function () {
- var args = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- args[_i] = arguments[_i];
- }
- return __awaiter(this, void 0, void 0, function () {
- var tx;
- return __generator(this, function (_a) {
- switch (_a.label) {
- case 0:
- if (!signerOrProvider) {
- logger.throwError("estimate require a provider or signer", logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
- operation: "estimateGas"
- });
- }
- return [4 /*yield*/, populateTransaction(contract, fragment, args)];
- case 1:
- tx = _a.sent();
- return [4 /*yield*/, signerOrProvider.estimateGas(tx)];
- case 2: return [2 /*return*/, _a.sent()];
- }
- });
- });
- };
- }
- function addContractWait(contract, tx) {
- var wait = tx.wait.bind(tx);
- tx.wait = function (confirmations) {
- return wait(confirmations).then(function (receipt) {
- receipt.events = receipt.logs.map(function (log) {
- var event = (0, properties_1.deepCopy)(log);
- var parsed = null;
- try {
- parsed = contract.interface.parseLog(log);
- }
- catch (e) { }
- // Successfully parsed the event log; include it
- if (parsed) {
- event.args = parsed.args;
- event.decode = function (data, topics) {
- return contract.interface.decodeEventLog(parsed.eventFragment, data, topics);
- };
- event.event = parsed.name;
- event.eventSignature = parsed.signature;
- }
- // Useful operations
- event.removeListener = function () { return contract.provider; };
- event.getBlock = function () {
- return contract.provider.getBlock(receipt.blockHash);
- };
- event.getTransaction = function () {
- return contract.provider.getTransaction(receipt.transactionHash);
- };
- event.getTransactionReceipt = function () {
- return Promise.resolve(receipt);
- };
- return event;
- });
- return receipt;
- });
- };
- }
- function buildCall(contract, fragment, collapseSimple) {
- var signerOrProvider = (contract.signer || contract.provider);
- return function () {
- var args = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- args[_i] = arguments[_i];
- }
- return __awaiter(this, void 0, void 0, function () {
- var blockTag, overrides, tx, result, value;
- return __generator(this, function (_a) {
- switch (_a.label) {
- case 0:
- blockTag = undefined;
- if (!(args.length === fragment.inputs.length + 1 && typeof (args[args.length - 1]) === "object")) return [3 /*break*/, 3];
- overrides = (0, properties_1.shallowCopy)(args.pop());
- if (!(overrides.blockTag != null)) return [3 /*break*/, 2];
- return [4 /*yield*/, overrides.blockTag];
- case 1:
- blockTag = _a.sent();
- _a.label = 2;
- case 2:
- delete overrides.blockTag;
- args.push(overrides);
- _a.label = 3;
- case 3:
- if (!(contract.deployTransaction != null)) return [3 /*break*/, 5];
- return [4 /*yield*/, contract._deployed(blockTag)];
- case 4:
- _a.sent();
- _a.label = 5;
- case 5: return [4 /*yield*/, populateTransaction(contract, fragment, args)];
- case 6:
- tx = _a.sent();
- return [4 /*yield*/, signerOrProvider.call(tx, blockTag)];
- case 7:
- result = _a.sent();
- try {
- value = contract.interface.decodeFunctionResult(fragment, result);
- if (collapseSimple && fragment.outputs.length === 1) {
- value = value[0];
- }
- return [2 /*return*/, value];
- }
- catch (error) {
- if (error.code === logger_1.Logger.errors.CALL_EXCEPTION) {
- error.address = contract.address;
- error.args = args;
- error.transaction = tx;
- }
- throw error;
- }
- return [2 /*return*/];
- }
- });
- });
- };
- }
- function buildSend(contract, fragment) {
- return function () {
- var args = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- args[_i] = arguments[_i];
- }
- return __awaiter(this, void 0, void 0, function () {
- var txRequest, tx;
- return __generator(this, function (_a) {
- switch (_a.label) {
- case 0:
- if (!contract.signer) {
- logger.throwError("sending a transaction requires a signer", logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
- operation: "sendTransaction"
- });
- }
- if (!(contract.deployTransaction != null)) return [3 /*break*/, 2];
- return [4 /*yield*/, contract._deployed()];
- case 1:
- _a.sent();
- _a.label = 2;
- case 2: return [4 /*yield*/, populateTransaction(contract, fragment, args)];
- case 3:
- txRequest = _a.sent();
- return [4 /*yield*/, contract.signer.sendTransaction(txRequest)];
- case 4:
- tx = _a.sent();
- // Tweak the tx.wait so the receipt has extra properties
- addContractWait(contract, tx);
- return [2 /*return*/, tx];
- }
- });
- });
- };
- }
- function buildDefault(contract, fragment, collapseSimple) {
- if (fragment.constant) {
- return buildCall(contract, fragment, collapseSimple);
- }
- return buildSend(contract, fragment);
- }
- function getEventTag(filter) {
- if (filter.address && (filter.topics == null || filter.topics.length === 0)) {
- return "*";
- }
- return (filter.address || "*") + "@" + (filter.topics ? filter.topics.map(function (topic) {
- if (Array.isArray(topic)) {
- return topic.join("|");
- }
- return topic;
- }).join(":") : "");
- }
- var RunningEvent = /** @class */ (function () {
- function RunningEvent(tag, filter) {
- (0, properties_1.defineReadOnly)(this, "tag", tag);
- (0, properties_1.defineReadOnly)(this, "filter", filter);
- this._listeners = [];
- }
- RunningEvent.prototype.addListener = function (listener, once) {
- this._listeners.push({ listener: listener, once: once });
- };
- RunningEvent.prototype.removeListener = function (listener) {
- var done = false;
- this._listeners = this._listeners.filter(function (item) {
- if (done || item.listener !== listener) {
- return true;
- }
- done = true;
- return false;
- });
- };
- RunningEvent.prototype.removeAllListeners = function () {
- this._listeners = [];
- };
- RunningEvent.prototype.listeners = function () {
- return this._listeners.map(function (i) { return i.listener; });
- };
- RunningEvent.prototype.listenerCount = function () {
- return this._listeners.length;
- };
- RunningEvent.prototype.run = function (args) {
- var _this = this;
- var listenerCount = this.listenerCount();
- this._listeners = this._listeners.filter(function (item) {
- var argsCopy = args.slice();
- // Call the callback in the next event loop
- setTimeout(function () {
- item.listener.apply(_this, argsCopy);
- }, 0);
- // Reschedule it if it not "once"
- return !(item.once);
- });
- return listenerCount;
- };
- RunningEvent.prototype.prepareEvent = function (event) {
- };
- // Returns the array that will be applied to an emit
- RunningEvent.prototype.getEmit = function (event) {
- return [event];
- };
- return RunningEvent;
- }());
- var ErrorRunningEvent = /** @class */ (function (_super) {
- __extends(ErrorRunningEvent, _super);
- function ErrorRunningEvent() {
- return _super.call(this, "error", null) || this;
- }
- return ErrorRunningEvent;
- }(RunningEvent));
- // @TODO Fragment should inherit Wildcard? and just override getEmit?
- // or have a common abstract super class, with enough constructor
- // options to configure both.
- // A Fragment Event will populate all the properties that Wildcard
- // will, and additionally dereference the arguments when emitting
- var FragmentRunningEvent = /** @class */ (function (_super) {
- __extends(FragmentRunningEvent, _super);
- function FragmentRunningEvent(address, contractInterface, fragment, topics) {
- var _this = this;
- var filter = {
- address: address
- };
- var topic = contractInterface.getEventTopic(fragment);
- if (topics) {
- if (topic !== topics[0]) {
- logger.throwArgumentError("topic mismatch", "topics", topics);
- }
- filter.topics = topics.slice();
- }
- else {
- filter.topics = [topic];
- }
- _this = _super.call(this, getEventTag(filter), filter) || this;
- (0, properties_1.defineReadOnly)(_this, "address", address);
- (0, properties_1.defineReadOnly)(_this, "interface", contractInterface);
- (0, properties_1.defineReadOnly)(_this, "fragment", fragment);
- return _this;
- }
- FragmentRunningEvent.prototype.prepareEvent = function (event) {
- var _this = this;
- _super.prototype.prepareEvent.call(this, event);
- event.event = this.fragment.name;
- event.eventSignature = this.fragment.format();
- event.decode = function (data, topics) {
- return _this.interface.decodeEventLog(_this.fragment, data, topics);
- };
- try {
- event.args = this.interface.decodeEventLog(this.fragment, event.data, event.topics);
- }
- catch (error) {
- event.args = null;
- event.decodeError = error;
- }
- };
- FragmentRunningEvent.prototype.getEmit = function (event) {
- var errors = (0, abi_1.checkResultErrors)(event.args);
- if (errors.length) {
- throw errors[0].error;
- }
- var args = (event.args || []).slice();
- args.push(event);
- return args;
- };
- return FragmentRunningEvent;
- }(RunningEvent));
- // A Wildcard Event will attempt to populate:
- // - event The name of the event name
- // - eventSignature The full signature of the event
- // - decode A function to decode data and topics
- // - args The decoded data and topics
- var WildcardRunningEvent = /** @class */ (function (_super) {
- __extends(WildcardRunningEvent, _super);
- function WildcardRunningEvent(address, contractInterface) {
- var _this = _super.call(this, "*", { address: address }) || this;
- (0, properties_1.defineReadOnly)(_this, "address", address);
- (0, properties_1.defineReadOnly)(_this, "interface", contractInterface);
- return _this;
- }
- WildcardRunningEvent.prototype.prepareEvent = function (event) {
- var _this = this;
- _super.prototype.prepareEvent.call(this, event);
- try {
- var parsed_1 = this.interface.parseLog(event);
- event.event = parsed_1.name;
- event.eventSignature = parsed_1.signature;
- event.decode = function (data, topics) {
- return _this.interface.decodeEventLog(parsed_1.eventFragment, data, topics);
- };
- event.args = parsed_1.args;
- }
- catch (error) {
- // No matching event
- }
- };
- return WildcardRunningEvent;
- }(RunningEvent));
- var BaseContract = /** @class */ (function () {
- function BaseContract(addressOrName, contractInterface, signerOrProvider) {
- var _newTarget = this.constructor;
- var _this = this;
- logger.checkNew(_newTarget, Contract);
- // @TODO: Maybe still check the addressOrName looks like a valid address or name?
- //address = getAddress(address);
- (0, properties_1.defineReadOnly)(this, "interface", (0, properties_1.getStatic)(_newTarget, "getInterface")(contractInterface));
- if (signerOrProvider == null) {
- (0, properties_1.defineReadOnly)(this, "provider", null);
- (0, properties_1.defineReadOnly)(this, "signer", null);
- }
- else if (abstract_signer_1.Signer.isSigner(signerOrProvider)) {
- (0, properties_1.defineReadOnly)(this, "provider", signerOrProvider.provider || null);
- (0, properties_1.defineReadOnly)(this, "signer", signerOrProvider);
- }
- else if (abstract_provider_1.Provider.isProvider(signerOrProvider)) {
- (0, properties_1.defineReadOnly)(this, "provider", signerOrProvider);
- (0, properties_1.defineReadOnly)(this, "signer", null);
- }
- else {
- logger.throwArgumentError("invalid signer or provider", "signerOrProvider", signerOrProvider);
- }
- (0, properties_1.defineReadOnly)(this, "callStatic", {});
- (0, properties_1.defineReadOnly)(this, "estimateGas", {});
- (0, properties_1.defineReadOnly)(this, "functions", {});
- (0, properties_1.defineReadOnly)(this, "populateTransaction", {});
- (0, properties_1.defineReadOnly)(this, "filters", {});
- {
- var uniqueFilters_1 = {};
- Object.keys(this.interface.events).forEach(function (eventSignature) {
- var event = _this.interface.events[eventSignature];
- (0, properties_1.defineReadOnly)(_this.filters, eventSignature, function () {
- var args = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- args[_i] = arguments[_i];
- }
- return {
- address: _this.address,
- topics: _this.interface.encodeFilterTopics(event, args)
- };
- });
- if (!uniqueFilters_1[event.name]) {
- uniqueFilters_1[event.name] = [];
- }
- uniqueFilters_1[event.name].push(eventSignature);
- });
- Object.keys(uniqueFilters_1).forEach(function (name) {
- var filters = uniqueFilters_1[name];
- if (filters.length === 1) {
- (0, properties_1.defineReadOnly)(_this.filters, name, _this.filters[filters[0]]);
- }
- else {
- logger.warn("Duplicate definition of " + name + " (" + filters.join(", ") + ")");
- }
- });
- }
- (0, properties_1.defineReadOnly)(this, "_runningEvents", {});
- (0, properties_1.defineReadOnly)(this, "_wrappedEmits", {});
- if (addressOrName == null) {
- logger.throwArgumentError("invalid contract address or ENS name", "addressOrName", addressOrName);
- }
- (0, properties_1.defineReadOnly)(this, "address", addressOrName);
- if (this.provider) {
- (0, properties_1.defineReadOnly)(this, "resolvedAddress", resolveName(this.provider, addressOrName));
- }
- else {
- try {
- (0, properties_1.defineReadOnly)(this, "resolvedAddress", Promise.resolve((0, address_1.getAddress)(addressOrName)));
- }
- catch (error) {
- // Without a provider, we cannot use ENS names
- logger.throwError("provider is required to use ENS name as contract address", logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
- operation: "new Contract"
- });
- }
- }
- // Swallow bad ENS names to prevent Unhandled Exceptions
- this.resolvedAddress.catch(function (e) { });
- var uniqueNames = {};
- var uniqueSignatures = {};
- Object.keys(this.interface.functions).forEach(function (signature) {
- var fragment = _this.interface.functions[signature];
- // Check that the signature is unique; if not the ABI generation has
- // not been cleaned or may be incorrectly generated
- if (uniqueSignatures[signature]) {
- logger.warn("Duplicate ABI entry for " + JSON.stringify(signature));
- return;
- }
- uniqueSignatures[signature] = true;
- // Track unique names; we only expose bare named functions if they
- // are ambiguous
- {
- var name_1 = fragment.name;
- if (!uniqueNames["%" + name_1]) {
- uniqueNames["%" + name_1] = [];
- }
- uniqueNames["%" + name_1].push(signature);
- }
- if (_this[signature] == null) {
- (0, properties_1.defineReadOnly)(_this, signature, buildDefault(_this, fragment, true));
- }
- // We do not collapse simple calls on this bucket, which allows
- // frameworks to safely use this without introspection as well as
- // allows decoding error recovery.
- if (_this.functions[signature] == null) {
- (0, properties_1.defineReadOnly)(_this.functions, signature, buildDefault(_this, fragment, false));
- }
- if (_this.callStatic[signature] == null) {
- (0, properties_1.defineReadOnly)(_this.callStatic, signature, buildCall(_this, fragment, true));
- }
- if (_this.populateTransaction[signature] == null) {
- (0, properties_1.defineReadOnly)(_this.populateTransaction, signature, buildPopulate(_this, fragment));
- }
- if (_this.estimateGas[signature] == null) {
- (0, properties_1.defineReadOnly)(_this.estimateGas, signature, buildEstimate(_this, fragment));
- }
- });
- Object.keys(uniqueNames).forEach(function (name) {
- // Ambiguous names to not get attached as bare names
- var signatures = uniqueNames[name];
- if (signatures.length > 1) {
- return;
- }
- // Strip off the leading "%" used for prototype protection
- name = name.substring(1);
- var signature = signatures[0];
- // If overwriting a member property that is null, swallow the error
- try {
- if (_this[name] == null) {
- (0, properties_1.defineReadOnly)(_this, name, _this[signature]);
- }
- }
- catch (e) { }
- if (_this.functions[name] == null) {
- (0, properties_1.defineReadOnly)(_this.functions, name, _this.functions[signature]);
- }
- if (_this.callStatic[name] == null) {
- (0, properties_1.defineReadOnly)(_this.callStatic, name, _this.callStatic[signature]);
- }
- if (_this.populateTransaction[name] == null) {
- (0, properties_1.defineReadOnly)(_this.populateTransaction, name, _this.populateTransaction[signature]);
- }
- if (_this.estimateGas[name] == null) {
- (0, properties_1.defineReadOnly)(_this.estimateGas, name, _this.estimateGas[signature]);
- }
- });
- }
- BaseContract.getContractAddress = function (transaction) {
- return (0, address_1.getContractAddress)(transaction);
- };
- BaseContract.getInterface = function (contractInterface) {
- if (abi_1.Interface.isInterface(contractInterface)) {
- return contractInterface;
- }
- return new abi_1.Interface(contractInterface);
- };
- // @TODO: Allow timeout?
- BaseContract.prototype.deployed = function () {
- return this._deployed();
- };
- BaseContract.prototype._deployed = function (blockTag) {
- var _this = this;
- if (!this._deployedPromise) {
- // If we were just deployed, we know the transaction we should occur in
- if (this.deployTransaction) {
- this._deployedPromise = this.deployTransaction.wait().then(function () {
- return _this;
- });
- }
- else {
- // @TODO: Once we allow a timeout to be passed in, we will wait
- // up to that many blocks for getCode
- // Otherwise, poll for our code to be deployed
- this._deployedPromise = this.provider.getCode(this.address, blockTag).then(function (code) {
- if (code === "0x") {
- logger.throwError("contract not deployed", logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
- contractAddress: _this.address,
- operation: "getDeployed"
- });
- }
- return _this;
- });
- }
- }
- return this._deployedPromise;
- };
- // @TODO:
- // estimateFallback(overrides?: TransactionRequest): Promise<BigNumber>
- // @TODO:
- // estimateDeploy(bytecode: string, ...args): Promise<BigNumber>
- BaseContract.prototype.fallback = function (overrides) {
- var _this = this;
- if (!this.signer) {
- logger.throwError("sending a transactions require a signer", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { operation: "sendTransaction(fallback)" });
- }
- var tx = (0, properties_1.shallowCopy)(overrides || {});
- ["from", "to"].forEach(function (key) {
- if (tx[key] == null) {
- return;
- }
- logger.throwError("cannot override " + key, logger_1.Logger.errors.UNSUPPORTED_OPERATION, { operation: key });
- });
- tx.to = this.resolvedAddress;
- return this.deployed().then(function () {
- return _this.signer.sendTransaction(tx);
- });
- };
- // Reconnect to a different signer or provider
- BaseContract.prototype.connect = function (signerOrProvider) {
- if (typeof (signerOrProvider) === "string") {
- signerOrProvider = new abstract_signer_1.VoidSigner(signerOrProvider, this.provider);
- }
- var contract = new (this.constructor)(this.address, this.interface, signerOrProvider);
- if (this.deployTransaction) {
- (0, properties_1.defineReadOnly)(contract, "deployTransaction", this.deployTransaction);
- }
- return contract;
- };
- // Re-attach to a different on-chain instance of this contract
- BaseContract.prototype.attach = function (addressOrName) {
- return new (this.constructor)(addressOrName, this.interface, this.signer || this.provider);
- };
- BaseContract.isIndexed = function (value) {
- return abi_1.Indexed.isIndexed(value);
- };
- BaseContract.prototype._normalizeRunningEvent = function (runningEvent) {
- // Already have an instance of this event running; we can re-use it
- if (this._runningEvents[runningEvent.tag]) {
- return this._runningEvents[runningEvent.tag];
- }
- return runningEvent;
- };
- BaseContract.prototype._getRunningEvent = function (eventName) {
- if (typeof (eventName) === "string") {
- // Listen for "error" events (if your contract has an error event, include
- // the full signature to bypass this special event keyword)
- if (eventName === "error") {
- return this._normalizeRunningEvent(new ErrorRunningEvent());
- }
- // Listen for any event that is registered
- if (eventName === "event") {
- return this._normalizeRunningEvent(new RunningEvent("event", null));
- }
- // Listen for any event
- if (eventName === "*") {
- return this._normalizeRunningEvent(new WildcardRunningEvent(this.address, this.interface));
- }
- // Get the event Fragment (throws if ambiguous/unknown event)
- var fragment = this.interface.getEvent(eventName);
- return this._normalizeRunningEvent(new FragmentRunningEvent(this.address, this.interface, fragment));
- }
- // We have topics to filter by...
- if (eventName.topics && eventName.topics.length > 0) {
- // Is it a known topichash? (throws if no matching topichash)
- try {
- var topic = eventName.topics[0];
- if (typeof (topic) !== "string") {
- throw new Error("invalid topic"); // @TODO: May happen for anonymous events
- }
- var fragment = this.interface.getEvent(topic);
- return this._normalizeRunningEvent(new FragmentRunningEvent(this.address, this.interface, fragment, eventName.topics));
- }
- catch (error) { }
- // Filter by the unknown topichash
- var filter = {
- address: this.address,
- topics: eventName.topics
- };
- return this._normalizeRunningEvent(new RunningEvent(getEventTag(filter), filter));
- }
- return this._normalizeRunningEvent(new WildcardRunningEvent(this.address, this.interface));
- };
- BaseContract.prototype._checkRunningEvents = function (runningEvent) {
- if (runningEvent.listenerCount() === 0) {
- delete this._runningEvents[runningEvent.tag];
- // If we have a poller for this, remove it
- var emit = this._wrappedEmits[runningEvent.tag];
- if (emit && runningEvent.filter) {
- this.provider.off(runningEvent.filter, emit);
- delete this._wrappedEmits[runningEvent.tag];
- }
- }
- };
- // Subclasses can override this to gracefully recover
- // from parse errors if they wish
- BaseContract.prototype._wrapEvent = function (runningEvent, log, listener) {
- var _this = this;
- var event = (0, properties_1.deepCopy)(log);
- event.removeListener = function () {
- if (!listener) {
- return;
- }
- runningEvent.removeListener(listener);
- _this._checkRunningEvents(runningEvent);
- };
- event.getBlock = function () { return _this.provider.getBlock(log.blockHash); };
- event.getTransaction = function () { return _this.provider.getTransaction(log.transactionHash); };
- event.getTransactionReceipt = function () { return _this.provider.getTransactionReceipt(log.transactionHash); };
- // This may throw if the topics and data mismatch the signature
- runningEvent.prepareEvent(event);
- return event;
- };
- BaseContract.prototype._addEventListener = function (runningEvent, listener, once) {
- var _this = this;
- if (!this.provider) {
- logger.throwError("events require a provider or a signer with a provider", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { operation: "once" });
- }
- runningEvent.addListener(listener, once);
- // Track this running event and its listeners (may already be there; but no hard in updating)
- this._runningEvents[runningEvent.tag] = runningEvent;
- // If we are not polling the provider, start polling
- if (!this._wrappedEmits[runningEvent.tag]) {
- var wrappedEmit = function (log) {
- var event = _this._wrapEvent(runningEvent, log, listener);
- // Try to emit the result for the parameterized event...
- if (event.decodeError == null) {
- try {
- var args = runningEvent.getEmit(event);
- _this.emit.apply(_this, __spreadArray([runningEvent.filter], args, false));
- }
- catch (error) {
- event.decodeError = error.error;
- }
- }
- // Always emit "event" for fragment-base events
- if (runningEvent.filter != null) {
- _this.emit("event", event);
- }
- // Emit "error" if there was an error
- if (event.decodeError != null) {
- _this.emit("error", event.decodeError, event);
- }
- };
- this._wrappedEmits[runningEvent.tag] = wrappedEmit;
- // Special events, like "error" do not have a filter
- if (runningEvent.filter != null) {
- this.provider.on(runningEvent.filter, wrappedEmit);
- }
- }
- };
- BaseContract.prototype.queryFilter = function (event, fromBlockOrBlockhash, toBlock) {
- var _this = this;
- var runningEvent = this._getRunningEvent(event);
- var filter = (0, properties_1.shallowCopy)(runningEvent.filter);
- if (typeof (fromBlockOrBlockhash) === "string" && (0, bytes_1.isHexString)(fromBlockOrBlockhash, 32)) {
- if (toBlock != null) {
- logger.throwArgumentError("cannot specify toBlock with blockhash", "toBlock", toBlock);
- }
- filter.blockHash = fromBlockOrBlockhash;
- }
- else {
- filter.fromBlock = ((fromBlockOrBlockhash != null) ? fromBlockOrBlockhash : 0);
- filter.toBlock = ((toBlock != null) ? toBlock : "latest");
- }
- return this.provider.getLogs(filter).then(function (logs) {
- return logs.map(function (log) { return _this._wrapEvent(runningEvent, log, null); });
- });
- };
- BaseContract.prototype.on = function (event, listener) {
- this._addEventListener(this._getRunningEvent(event), listener, false);
- return this;
- };
- BaseContract.prototype.once = function (event, listener) {
- this._addEventListener(this._getRunningEvent(event), listener, true);
- return this;
- };
- BaseContract.prototype.emit = function (eventName) {
- var args = [];
- for (var _i = 1; _i < arguments.length; _i++) {
- args[_i - 1] = arguments[_i];
- }
- if (!this.provider) {
- return false;
- }
- var runningEvent = this._getRunningEvent(eventName);
- var result = (runningEvent.run(args) > 0);
- // May have drained all the "once" events; check for living events
- this._checkRunningEvents(runningEvent);
- return result;
- };
- BaseContract.prototype.listenerCount = function (eventName) {
- var _this = this;
- if (!this.provider) {
- return 0;
- }
- if (eventName == null) {
- return Object.keys(this._runningEvents).reduce(function (accum, key) {
- return accum + _this._runningEvents[key].listenerCount();
- }, 0);
- }
- return this._getRunningEvent(eventName).listenerCount();
- };
- BaseContract.prototype.listeners = function (eventName) {
- if (!this.provider) {
- return [];
- }
- if (eventName == null) {
- var result_1 = [];
- for (var tag in this._runningEvents) {
- this._runningEvents[tag].listeners().forEach(function (listener) {
- result_1.push(listener);
- });
- }
- return result_1;
- }
- return this._getRunningEvent(eventName).listeners();
- };
- BaseContract.prototype.removeAllListeners = function (eventName) {
- if (!this.provider) {
- return this;
- }
- if (eventName == null) {
- for (var tag in this._runningEvents) {
- var runningEvent_1 = this._runningEvents[tag];
- runningEvent_1.removeAllListeners();
- this._checkRunningEvents(runningEvent_1);
- }
- return this;
- }
- // Delete any listeners
- var runningEvent = this._getRunningEvent(eventName);
- runningEvent.removeAllListeners();
- this._checkRunningEvents(runningEvent);
- return this;
- };
- BaseContract.prototype.off = function (eventName, listener) {
- if (!this.provider) {
- return this;
- }
- var runningEvent = this._getRunningEvent(eventName);
- runningEvent.removeListener(listener);
- this._checkRunningEvents(runningEvent);
- return this;
- };
- BaseContract.prototype.removeListener = function (eventName, listener) {
- return this.off(eventName, listener);
- };
- return BaseContract;
- }());
- exports.BaseContract = BaseContract;
- var Contract = /** @class */ (function (_super) {
- __extends(Contract, _super);
- function Contract() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- return Contract;
- }(BaseContract));
- exports.Contract = Contract;
- var ContractFactory = /** @class */ (function () {
- function ContractFactory(contractInterface, bytecode, signer) {
- var _newTarget = this.constructor;
- var bytecodeHex = null;
- if (typeof (bytecode) === "string") {
- bytecodeHex = bytecode;
- }
- else if ((0, bytes_1.isBytes)(bytecode)) {
- bytecodeHex = (0, bytes_1.hexlify)(bytecode);
- }
- else if (bytecode && typeof (bytecode.object) === "string") {
- // Allow the bytecode object from the Solidity compiler
- bytecodeHex = bytecode.object;
- }
- else {
- // Crash in the next verification step
- bytecodeHex = "!";
- }
- // Make sure it is 0x prefixed
- if (bytecodeHex.substring(0, 2) !== "0x") {
- bytecodeHex = "0x" + bytecodeHex;
- }
- // Make sure the final result is valid bytecode
- if (!(0, bytes_1.isHexString)(bytecodeHex) || (bytecodeHex.length % 2)) {
- logger.throwArgumentError("invalid bytecode", "bytecode", bytecode);
- }
- // If we have a signer, make sure it is valid
- if (signer && !abstract_signer_1.Signer.isSigner(signer)) {
- logger.throwArgumentError("invalid signer", "signer", signer);
- }
- (0, properties_1.defineReadOnly)(this, "bytecode", bytecodeHex);
- (0, properties_1.defineReadOnly)(this, "interface", (0, properties_1.getStatic)(_newTarget, "getInterface")(contractInterface));
- (0, properties_1.defineReadOnly)(this, "signer", signer || null);
- }
- // @TODO: Future; rename to populateTransaction?
- ContractFactory.prototype.getDeployTransaction = function () {
- var args = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- args[_i] = arguments[_i];
- }
- var tx = {};
- // If we have 1 additional argument, we allow transaction overrides
- if (args.length === this.interface.deploy.inputs.length + 1 && typeof (args[args.length - 1]) === "object") {
- tx = (0, properties_1.shallowCopy)(args.pop());
- for (var key in tx) {
- if (!allowedTransactionKeys[key]) {
- throw new Error("unknown transaction override " + key);
- }
- }
- }
- // Do not allow these to be overridden in a deployment transaction
- ["data", "from", "to"].forEach(function (key) {
- if (tx[key] == null) {
- return;
- }
- logger.throwError("cannot override " + key, logger_1.Logger.errors.UNSUPPORTED_OPERATION, { operation: key });
- });
- if (tx.value) {
- var value = bignumber_1.BigNumber.from(tx.value);
- if (!value.isZero() && !this.interface.deploy.payable) {
- logger.throwError("non-payable constructor cannot override value", logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
- operation: "overrides.value",
- value: tx.value
- });
- }
- }
- // Make sure the call matches the constructor signature
- logger.checkArgumentCount(args.length, this.interface.deploy.inputs.length, " in Contract constructor");
- // Set the data to the bytecode + the encoded constructor arguments
- tx.data = (0, bytes_1.hexlify)((0, bytes_1.concat)([
- this.bytecode,
- this.interface.encodeDeploy(args)
- ]));
- return tx;
- };
- ContractFactory.prototype.deploy = function () {
- var args = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- args[_i] = arguments[_i];
- }
- return __awaiter(this, void 0, void 0, function () {
- var overrides, params, unsignedTx, tx, address, contract;
- return __generator(this, function (_a) {
- switch (_a.label) {
- case 0:
- overrides = {};
- // If 1 extra parameter was passed in, it contains overrides
- if (args.length === this.interface.deploy.inputs.length + 1) {
- overrides = args.pop();
- }
- // Make sure the call matches the constructor signature
- logger.checkArgumentCount(args.length, this.interface.deploy.inputs.length, " in Contract constructor");
- return [4 /*yield*/, resolveAddresses(this.signer, args, this.interface.deploy.inputs)];
- case 1:
- params = _a.sent();
- params.push(overrides);
- unsignedTx = this.getDeployTransaction.apply(this, params);
- return [4 /*yield*/, this.signer.sendTransaction(unsignedTx)];
- case 2:
- tx = _a.sent();
- address = (0, properties_1.getStatic)(this.constructor, "getContractAddress")(tx);
- contract = (0, properties_1.getStatic)(this.constructor, "getContract")(address, this.interface, this.signer);
- // Add the modified wait that wraps events
- addContractWait(contract, tx);
- (0, properties_1.defineReadOnly)(contract, "deployTransaction", tx);
- return [2 /*return*/, contract];
- }
- });
- });
- };
- ContractFactory.prototype.attach = function (address) {
- return (this.constructor).getContract(address, this.interface, this.signer);
- };
- ContractFactory.prototype.connect = function (signer) {
- return new (this.constructor)(this.interface, this.bytecode, signer);
- };
- ContractFactory.fromSolidity = function (compilerOutput, signer) {
- if (compilerOutput == null) {
- logger.throwError("missing compiler output", logger_1.Logger.errors.MISSING_ARGUMENT, { argument: "compilerOutput" });
- }
- if (typeof (compilerOutput) === "string") {
- compilerOutput = JSON.parse(compilerOutput);
- }
- var abi = compilerOutput.abi;
- var bytecode = null;
- if (compilerOutput.bytecode) {
- bytecode = compilerOutput.bytecode;
- }
- else if (compilerOutput.evm && compilerOutput.evm.bytecode) {
- bytecode = compilerOutput.evm.bytecode;
- }
- return new this(abi, bytecode, signer);
- };
- ContractFactory.getInterface = function (contractInterface) {
- return Contract.getInterface(contractInterface);
- };
- ContractFactory.getContractAddress = function (tx) {
- return (0, address_1.getContractAddress)(tx);
- };
- ContractFactory.getContract = function (address, contractInterface, signer) {
- return new Contract(address, contractInterface, signer);
- };
- return ContractFactory;
- }());
- exports.ContractFactory = ContractFactory;
- },{"./_version":205,"@ethersproject/abi":182,"@ethersproject/abstract-provider":185,"@ethersproject/abstract-signer":187,"@ethersproject/address":189,"@ethersproject/bignumber":196,"@ethersproject/bytes":199,"@ethersproject/logger":223,"@ethersproject/properties":229,"@ethersproject/transactions":269}],207:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.version = void 0;
- exports.version = "hash/5.6.0";
- },{}],208:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.id = void 0;
- var keccak256_1 = _dereq_("@ethersproject/keccak256");
- var strings_1 = _dereq_("@ethersproject/strings");
- function id(text) {
- return (0, keccak256_1.keccak256)((0, strings_1.toUtf8Bytes)(text));
- }
- exports.id = id;
- },{"@ethersproject/keccak256":221,"@ethersproject/strings":266}],209:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports._TypedDataEncoder = exports.hashMessage = exports.messagePrefix = exports.isValidName = exports.namehash = exports.dnsEncode = exports.id = void 0;
- var id_1 = _dereq_("./id");
- Object.defineProperty(exports, "id", { enumerable: true, get: function () { return id_1.id; } });
- var namehash_1 = _dereq_("./namehash");
- Object.defineProperty(exports, "dnsEncode", { enumerable: true, get: function () { return namehash_1.dnsEncode; } });
- Object.defineProperty(exports, "isValidName", { enumerable: true, get: function () { return namehash_1.isValidName; } });
- Object.defineProperty(exports, "namehash", { enumerable: true, get: function () { return namehash_1.namehash; } });
- var message_1 = _dereq_("./message");
- Object.defineProperty(exports, "hashMessage", { enumerable: true, get: function () { return message_1.hashMessage; } });
- Object.defineProperty(exports, "messagePrefix", { enumerable: true, get: function () { return message_1.messagePrefix; } });
- var typed_data_1 = _dereq_("./typed-data");
- Object.defineProperty(exports, "_TypedDataEncoder", { enumerable: true, get: function () { return typed_data_1.TypedDataEncoder; } });
- },{"./id":208,"./message":210,"./namehash":211,"./typed-data":212}],210:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.hashMessage = exports.messagePrefix = void 0;
- var bytes_1 = _dereq_("@ethersproject/bytes");
- var keccak256_1 = _dereq_("@ethersproject/keccak256");
- var strings_1 = _dereq_("@ethersproject/strings");
- exports.messagePrefix = "\x19Ethereum Signed Message:\n";
- function hashMessage(message) {
- if (typeof (message) === "string") {
- message = (0, strings_1.toUtf8Bytes)(message);
- }
- return (0, keccak256_1.keccak256)((0, bytes_1.concat)([
- (0, strings_1.toUtf8Bytes)(exports.messagePrefix),
- (0, strings_1.toUtf8Bytes)(String(message.length)),
- message
- ]));
- }
- exports.hashMessage = hashMessage;
- },{"@ethersproject/bytes":199,"@ethersproject/keccak256":221,"@ethersproject/strings":266}],211:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.dnsEncode = exports.namehash = exports.isValidName = void 0;
- var bytes_1 = _dereq_("@ethersproject/bytes");
- var strings_1 = _dereq_("@ethersproject/strings");
- var keccak256_1 = _dereq_("@ethersproject/keccak256");
- var logger_1 = _dereq_("@ethersproject/logger");
- var _version_1 = _dereq_("./_version");
- var logger = new logger_1.Logger(_version_1.version);
- var Zeros = new Uint8Array(32);
- Zeros.fill(0);
- var Partition = new RegExp("^((.*)\\.)?([^.]+)$");
- function isValidName(name) {
- try {
- var comps = name.split(".");
- for (var i = 0; i < comps.length; i++) {
- if ((0, strings_1.nameprep)(comps[i]).length === 0) {
- throw new Error("empty");
- }
- }
- return true;
- }
- catch (error) { }
- return false;
- }
- exports.isValidName = isValidName;
- function namehash(name) {
- /* istanbul ignore if */
- if (typeof (name) !== "string") {
- logger.throwArgumentError("invalid ENS name; not a string", "name", name);
- }
- var current = name;
- var result = Zeros;
- while (current.length) {
- var partition = current.match(Partition);
- if (partition == null || partition[2] === "") {
- logger.throwArgumentError("invalid ENS address; missing component", "name", name);
- }
- var label = (0, strings_1.toUtf8Bytes)((0, strings_1.nameprep)(partition[3]));
- result = (0, keccak256_1.keccak256)((0, bytes_1.concat)([result, (0, keccak256_1.keccak256)(label)]));
- current = partition[2] || "";
- }
- return (0, bytes_1.hexlify)(result);
- }
- exports.namehash = namehash;
- function dnsEncode(name) {
- return (0, bytes_1.hexlify)((0, bytes_1.concat)(name.split(".").map(function (comp) {
- // We jam in an _ prefix to fill in with the length later
- // Note: Nameprep throws if the component is over 63 bytes
- var bytes = (0, strings_1.toUtf8Bytes)("_" + (0, strings_1.nameprep)(comp));
- bytes[0] = bytes.length - 1;
- return bytes;
- }))) + "00";
- }
- exports.dnsEncode = dnsEncode;
- },{"./_version":207,"@ethersproject/bytes":199,"@ethersproject/keccak256":221,"@ethersproject/logger":223,"@ethersproject/strings":266}],212:[function(_dereq_,module,exports){
- "use strict";
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
- return new (P || (P = Promise))(function (resolve, reject) {
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
- step((generator = generator.apply(thisArg, _arguments || [])).next());
- });
- };
- var __generator = (this && this.__generator) || function (thisArg, body) {
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
- function verb(n) { return function (v) { return step([n, v]); }; }
- function step(op) {
- if (f) throw new TypeError("Generator is already executing.");
- while (_) try {
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
- if (y = 0, t) op = [op[0] & 2, t.value];
- switch (op[0]) {
- case 0: case 1: t = op; break;
- case 4: _.label++; return { value: op[1], done: false };
- case 5: _.label++; y = op[1]; op = [0]; continue;
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
- default:
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
- if (t[2]) _.ops.pop();
- _.trys.pop(); continue;
- }
- op = body.call(thisArg, _);
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
- }
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.TypedDataEncoder = void 0;
- var address_1 = _dereq_("@ethersproject/address");
- var bignumber_1 = _dereq_("@ethersproject/bignumber");
- var bytes_1 = _dereq_("@ethersproject/bytes");
- var keccak256_1 = _dereq_("@ethersproject/keccak256");
- var properties_1 = _dereq_("@ethersproject/properties");
- var logger_1 = _dereq_("@ethersproject/logger");
- var _version_1 = _dereq_("./_version");
- var logger = new logger_1.Logger(_version_1.version);
- var id_1 = _dereq_("./id");
- var padding = new Uint8Array(32);
- padding.fill(0);
- var NegativeOne = bignumber_1.BigNumber.from(-1);
- var Zero = bignumber_1.BigNumber.from(0);
- var One = bignumber_1.BigNumber.from(1);
- var MaxUint256 = bignumber_1.BigNumber.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
- function hexPadRight(value) {
- var bytes = (0, bytes_1.arrayify)(value);
- var padOffset = bytes.length % 32;
- if (padOffset) {
- return (0, bytes_1.hexConcat)([bytes, padding.slice(padOffset)]);
- }
- return (0, bytes_1.hexlify)(bytes);
- }
- var hexTrue = (0, bytes_1.hexZeroPad)(One.toHexString(), 32);
- var hexFalse = (0, bytes_1.hexZeroPad)(Zero.toHexString(), 32);
- var domainFieldTypes = {
- name: "string",
- version: "string",
- chainId: "uint256",
- verifyingContract: "address",
- salt: "bytes32"
- };
- var domainFieldNames = [
- "name", "version", "chainId", "verifyingContract", "salt"
- ];
- function checkString(key) {
- return function (value) {
- if (typeof (value) !== "string") {
- logger.throwArgumentError("invalid domain value for " + JSON.stringify(key), "domain." + key, value);
- }
- return value;
- };
- }
- var domainChecks = {
- name: checkString("name"),
- version: checkString("version"),
- chainId: function (value) {
- try {
- return bignumber_1.BigNumber.from(value).toString();
- }
- catch (error) { }
- return logger.throwArgumentError("invalid domain value for \"chainId\"", "domain.chainId", value);
- },
- verifyingContract: function (value) {
- try {
- return (0, address_1.getAddress)(value).toLowerCase();
- }
- catch (error) { }
- return logger.throwArgumentError("invalid domain value \"verifyingContract\"", "domain.verifyingContract", value);
- },
- salt: function (value) {
- try {
- var bytes = (0, bytes_1.arrayify)(value);
- if (bytes.length !== 32) {
- throw new Error("bad length");
- }
- return (0, bytes_1.hexlify)(bytes);
- }
- catch (error) { }
- return logger.throwArgumentError("invalid domain value \"salt\"", "domain.salt", value);
- }
- };
- function getBaseEncoder(type) {
- // intXX and uintXX
- {
- var match = type.match(/^(u?)int(\d*)$/);
- if (match) {
- var signed = (match[1] === "");
- var width = parseInt(match[2] || "256");
- if (width % 8 !== 0 || width > 256 || (match[2] && match[2] !== String(width))) {
- logger.throwArgumentError("invalid numeric width", "type", type);
- }
- var boundsUpper_1 = MaxUint256.mask(signed ? (width - 1) : width);
- var boundsLower_1 = signed ? boundsUpper_1.add(One).mul(NegativeOne) : Zero;
- return function (value) {
- var v = bignumber_1.BigNumber.from(value);
- if (v.lt(boundsLower_1) || v.gt(boundsUpper_1)) {
- logger.throwArgumentError("value out-of-bounds for " + type, "value", value);
- }
- return (0, bytes_1.hexZeroPad)(v.toTwos(256).toHexString(), 32);
- };
- }
- }
- // bytesXX
- {
- var match = type.match(/^bytes(\d+)$/);
- if (match) {
- var width_1 = parseInt(match[1]);
- if (width_1 === 0 || width_1 > 32 || match[1] !== String(width_1)) {
- logger.throwArgumentError("invalid bytes width", "type", type);
- }
- return function (value) {
- var bytes = (0, bytes_1.arrayify)(value);
- if (bytes.length !== width_1) {
- logger.throwArgumentError("invalid length for " + type, "value", value);
- }
- return hexPadRight(value);
- };
- }
- }
- switch (type) {
- case "address": return function (value) {
- return (0, bytes_1.hexZeroPad)((0, address_1.getAddress)(value), 32);
- };
- case "bool": return function (value) {
- return ((!value) ? hexFalse : hexTrue);
- };
- case "bytes": return function (value) {
- return (0, keccak256_1.keccak256)(value);
- };
- case "string": return function (value) {
- return (0, id_1.id)(value);
- };
- }
- return null;
- }
- function encodeType(name, fields) {
- return name + "(" + fields.map(function (_a) {
- var name = _a.name, type = _a.type;
- return (type + " " + name);
- }).join(",") + ")";
- }
- var TypedDataEncoder = /** @class */ (function () {
- function TypedDataEncoder(types) {
- (0, properties_1.defineReadOnly)(this, "types", Object.freeze((0, properties_1.deepCopy)(types)));
- (0, properties_1.defineReadOnly)(this, "_encoderCache", {});
- (0, properties_1.defineReadOnly)(this, "_types", {});
- // Link struct types to their direct child structs
- var links = {};
- // Link structs to structs which contain them as a child
- var parents = {};
- // Link all subtypes within a given struct
- var subtypes = {};
- Object.keys(types).forEach(function (type) {
- links[type] = {};
- parents[type] = [];
- subtypes[type] = {};
- });
- var _loop_1 = function (name_1) {
- var uniqueNames = {};
- types[name_1].forEach(function (field) {
- // Check each field has a unique name
- if (uniqueNames[field.name]) {
- logger.throwArgumentError("duplicate variable name " + JSON.stringify(field.name) + " in " + JSON.stringify(name_1), "types", types);
- }
- uniqueNames[field.name] = true;
- // Get the base type (drop any array specifiers)
- var baseType = field.type.match(/^([^\x5b]*)(\x5b|$)/)[1];
- if (baseType === name_1) {
- logger.throwArgumentError("circular type reference to " + JSON.stringify(baseType), "types", types);
- }
- // Is this a base encoding type?
- var encoder = getBaseEncoder(baseType);
- if (encoder) {
- return;
- }
- if (!parents[baseType]) {
- logger.throwArgumentError("unknown type " + JSON.stringify(baseType), "types", types);
- }
- // Add linkage
- parents[baseType].push(name_1);
- links[name_1][baseType] = true;
- });
- };
- for (var name_1 in types) {
- _loop_1(name_1);
- }
- // Deduce the primary type
- var primaryTypes = Object.keys(parents).filter(function (n) { return (parents[n].length === 0); });
- if (primaryTypes.length === 0) {
- logger.throwArgumentError("missing primary type", "types", types);
- }
- else if (primaryTypes.length > 1) {
- logger.throwArgumentError("ambiguous primary types or unused types: " + primaryTypes.map(function (t) { return (JSON.stringify(t)); }).join(", "), "types", types);
- }
- (0, properties_1.defineReadOnly)(this, "primaryType", primaryTypes[0]);
- // Check for circular type references
- function checkCircular(type, found) {
- if (found[type]) {
- logger.throwArgumentError("circular type reference to " + JSON.stringify(type), "types", types);
- }
- found[type] = true;
- Object.keys(links[type]).forEach(function (child) {
- if (!parents[child]) {
- return;
- }
- // Recursively check children
- checkCircular(child, found);
- // Mark all ancestors as having this decendant
- Object.keys(found).forEach(function (subtype) {
- subtypes[subtype][child] = true;
- });
- });
- delete found[type];
- }
- checkCircular(this.primaryType, {});
- // Compute each fully describe type
- for (var name_2 in subtypes) {
- var st = Object.keys(subtypes[name_2]);
- st.sort();
- this._types[name_2] = encodeType(name_2, types[name_2]) + st.map(function (t) { return encodeType(t, types[t]); }).join("");
- }
- }
- TypedDataEncoder.prototype.getEncoder = function (type) {
- var encoder = this._encoderCache[type];
- if (!encoder) {
- encoder = this._encoderCache[type] = this._getEncoder(type);
- }
- return encoder;
- };
- TypedDataEncoder.prototype._getEncoder = function (type) {
- var _this = this;
- // Basic encoder type (address, bool, uint256, etc)
- {
- var encoder = getBaseEncoder(type);
- if (encoder) {
- return encoder;
- }
- }
- // Array
- var match = type.match(/^(.*)(\x5b(\d*)\x5d)$/);
- if (match) {
- var subtype_1 = match[1];
- var subEncoder_1 = this.getEncoder(subtype_1);
- var length_1 = parseInt(match[3]);
- return function (value) {
- if (length_1 >= 0 && value.length !== length_1) {
- logger.throwArgumentError("array length mismatch; expected length ${ arrayLength }", "value", value);
- }
- var result = value.map(subEncoder_1);
- if (_this._types[subtype_1]) {
- result = result.map(keccak256_1.keccak256);
- }
- return (0, keccak256_1.keccak256)((0, bytes_1.hexConcat)(result));
- };
- }
- // Struct
- var fields = this.types[type];
- if (fields) {
- var encodedType_1 = (0, id_1.id)(this._types[type]);
- return function (value) {
- var values = fields.map(function (_a) {
- var name = _a.name, type = _a.type;
- var result = _this.getEncoder(type)(value[name]);
- if (_this._types[type]) {
- return (0, keccak256_1.keccak256)(result);
- }
- return result;
- });
- values.unshift(encodedType_1);
- return (0, bytes_1.hexConcat)(values);
- };
- }
- return logger.throwArgumentError("unknown type: " + type, "type", type);
- };
- TypedDataEncoder.prototype.encodeType = function (name) {
- var result = this._types[name];
- if (!result) {
- logger.throwArgumentError("unknown type: " + JSON.stringify(name), "name", name);
- }
- return result;
- };
- TypedDataEncoder.prototype.encodeData = function (type, value) {
- return this.getEncoder(type)(value);
- };
- TypedDataEncoder.prototype.hashStruct = function (name, value) {
- return (0, keccak256_1.keccak256)(this.encodeData(name, value));
- };
- TypedDataEncoder.prototype.encode = function (value) {
- return this.encodeData(this.primaryType, value);
- };
- TypedDataEncoder.prototype.hash = function (value) {
- return this.hashStruct(this.primaryType, value);
- };
- TypedDataEncoder.prototype._visit = function (type, value, callback) {
- var _this = this;
- // Basic encoder type (address, bool, uint256, etc)
- {
- var encoder = getBaseEncoder(type);
- if (encoder) {
- return callback(type, value);
- }
- }
- // Array
- var match = type.match(/^(.*)(\x5b(\d*)\x5d)$/);
- if (match) {
- var subtype_2 = match[1];
- var length_2 = parseInt(match[3]);
- if (length_2 >= 0 && value.length !== length_2) {
- logger.throwArgumentError("array length mismatch; expected length ${ arrayLength }", "value", value);
- }
- return value.map(function (v) { return _this._visit(subtype_2, v, callback); });
- }
- // Struct
- var fields = this.types[type];
- if (fields) {
- return fields.reduce(function (accum, _a) {
- var name = _a.name, type = _a.type;
- accum[name] = _this._visit(type, value[name], callback);
- return accum;
- }, {});
- }
- return logger.throwArgumentError("unknown type: " + type, "type", type);
- };
- TypedDataEncoder.prototype.visit = function (value, callback) {
- return this._visit(this.primaryType, value, callback);
- };
- TypedDataEncoder.from = function (types) {
- return new TypedDataEncoder(types);
- };
- TypedDataEncoder.getPrimaryType = function (types) {
- return TypedDataEncoder.from(types).primaryType;
- };
- TypedDataEncoder.hashStruct = function (name, types, value) {
- return TypedDataEncoder.from(types).hashStruct(name, value);
- };
- TypedDataEncoder.hashDomain = function (domain) {
- var domainFields = [];
- for (var name_3 in domain) {
- var type = domainFieldTypes[name_3];
- if (!type) {
- logger.throwArgumentError("invalid typed-data domain key: " + JSON.stringify(name_3), "domain", domain);
- }
- domainFields.push({ name: name_3, type: type });
- }
- domainFields.sort(function (a, b) {
- return domainFieldNames.indexOf(a.name) - domainFieldNames.indexOf(b.name);
- });
- return TypedDataEncoder.hashStruct("EIP712Domain", { EIP712Domain: domainFields }, domain);
- };
- TypedDataEncoder.encode = function (domain, types, value) {
- return (0, bytes_1.hexConcat)([
- "0x1901",
- TypedDataEncoder.hashDomain(domain),
- TypedDataEncoder.from(types).hash(value)
- ]);
- };
- TypedDataEncoder.hash = function (domain, types, value) {
- return (0, keccak256_1.keccak256)(TypedDataEncoder.encode(domain, types, value));
- };
- // Replaces all address types with ENS names with their looked up address
- TypedDataEncoder.resolveNames = function (domain, types, value, resolveName) {
- return __awaiter(this, void 0, void 0, function () {
- var ensCache, encoder, _a, _b, _i, name_4, _c, _d;
- return __generator(this, function (_e) {
- switch (_e.label) {
- case 0:
- // Make a copy to isolate it from the object passed in
- domain = (0, properties_1.shallowCopy)(domain);
- ensCache = {};
- // Do we need to look up the domain's verifyingContract?
- if (domain.verifyingContract && !(0, bytes_1.isHexString)(domain.verifyingContract, 20)) {
- ensCache[domain.verifyingContract] = "0x";
- }
- encoder = TypedDataEncoder.from(types);
- // Get a list of all the addresses
- encoder.visit(value, function (type, value) {
- if (type === "address" && !(0, bytes_1.isHexString)(value, 20)) {
- ensCache[value] = "0x";
- }
- return value;
- });
- _a = [];
- for (_b in ensCache)
- _a.push(_b);
- _i = 0;
- _e.label = 1;
- case 1:
- if (!(_i < _a.length)) return [3 /*break*/, 4];
- name_4 = _a[_i];
- _c = ensCache;
- _d = name_4;
- return [4 /*yield*/, resolveName(name_4)];
- case 2:
- _c[_d] = _e.sent();
- _e.label = 3;
- case 3:
- _i++;
- return [3 /*break*/, 1];
- case 4:
- // Replace the domain verifyingContract if needed
- if (domain.verifyingContract && ensCache[domain.verifyingContract]) {
- domain.verifyingContract = ensCache[domain.verifyingContract];
- }
- // Replace all ENS names with their address
- value = encoder.visit(value, function (type, value) {
- if (type === "address" && ensCache[value]) {
- return ensCache[value];
- }
- return value;
- });
- return [2 /*return*/, { domain: domain, value: value }];
- }
- });
- });
- };
- TypedDataEncoder.getPayload = function (domain, types, value) {
- // Validate the domain fields
- TypedDataEncoder.hashDomain(domain);
- // Derive the EIP712Domain Struct reference type
- var domainValues = {};
- var domainTypes = [];
- domainFieldNames.forEach(function (name) {
- var value = domain[name];
- if (value == null) {
- return;
- }
- domainValues[name] = domainChecks[name](value);
- domainTypes.push({ name: name, type: domainFieldTypes[name] });
- });
- var encoder = TypedDataEncoder.from(types);
- var typesWithDomain = (0, properties_1.shallowCopy)(types);
- if (typesWithDomain.EIP712Domain) {
- logger.throwArgumentError("types must not contain EIP712Domain type", "types.EIP712Domain", types);
- }
- else {
- typesWithDomain.EIP712Domain = domainTypes;
- }
- // Validate the data structures and types
- encoder.encode(value);
- return {
- types: typesWithDomain,
- domain: domainValues,
- primaryType: encoder.primaryType,
- message: encoder.visit(value, function (type, value) {
- // bytes
- if (type.match(/^bytes(\d*)/)) {
- return (0, bytes_1.hexlify)((0, bytes_1.arrayify)(value));
- }
- // uint or int
- if (type.match(/^u?int/)) {
- return bignumber_1.BigNumber.from(value).toString();
- }
- switch (type) {
- case "address":
- return value.toLowerCase();
- case "bool":
- return !!value;
- case "string":
- if (typeof (value) !== "string") {
- logger.throwArgumentError("invalid string", "value", value);
- }
- return value;
- }
- return logger.throwArgumentError("unsupported type", "type", type);
- })
- };
- };
- return TypedDataEncoder;
- }());
- exports.TypedDataEncoder = TypedDataEncoder;
- },{"./_version":207,"./id":208,"@ethersproject/address":189,"@ethersproject/bignumber":196,"@ethersproject/bytes":199,"@ethersproject/keccak256":221,"@ethersproject/logger":223,"@ethersproject/properties":229}],213:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.version = void 0;
- exports.version = "hdnode/5.6.0";
- },{}],214:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.getAccountPath = exports.isValidMnemonic = exports.entropyToMnemonic = exports.mnemonicToEntropy = exports.mnemonicToSeed = exports.HDNode = exports.defaultPath = void 0;
- var basex_1 = _dereq_("@ethersproject/basex");
- var bytes_1 = _dereq_("@ethersproject/bytes");
- var bignumber_1 = _dereq_("@ethersproject/bignumber");
- var strings_1 = _dereq_("@ethersproject/strings");
- var pbkdf2_1 = _dereq_("@ethersproject/pbkdf2");
- var properties_1 = _dereq_("@ethersproject/properties");
- var signing_key_1 = _dereq_("@ethersproject/signing-key");
- var sha2_1 = _dereq_("@ethersproject/sha2");
- var transactions_1 = _dereq_("@ethersproject/transactions");
- var wordlists_1 = _dereq_("@ethersproject/wordlists");
- var logger_1 = _dereq_("@ethersproject/logger");
- var _version_1 = _dereq_("./_version");
- var logger = new logger_1.Logger(_version_1.version);
- var N = bignumber_1.BigNumber.from("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141");
- // "Bitcoin seed"
- var MasterSecret = (0, strings_1.toUtf8Bytes)("Bitcoin seed");
- var HardenedBit = 0x80000000;
- // Returns a byte with the MSB bits set
- function getUpperMask(bits) {
- return ((1 << bits) - 1) << (8 - bits);
- }
- // Returns a byte with the LSB bits set
- function getLowerMask(bits) {
- return (1 << bits) - 1;
- }
- function bytes32(value) {
- return (0, bytes_1.hexZeroPad)((0, bytes_1.hexlify)(value), 32);
- }
- function base58check(data) {
- return basex_1.Base58.encode((0, bytes_1.concat)([data, (0, bytes_1.hexDataSlice)((0, sha2_1.sha256)((0, sha2_1.sha256)(data)), 0, 4)]));
- }
- function getWordlist(wordlist) {
- if (wordlist == null) {
- return wordlists_1.wordlists["en"];
- }
- if (typeof (wordlist) === "string") {
- var words = wordlists_1.wordlists[wordlist];
- if (words == null) {
- logger.throwArgumentError("unknown locale", "wordlist", wordlist);
- }
- return words;
- }
- return wordlist;
- }
- var _constructorGuard = {};
- exports.defaultPath = "m/44'/60'/0'/0/0";
- ;
- var HDNode = /** @class */ (function () {
- /**
- * This constructor should not be called directly.
- *
- * Please use:
- * - fromMnemonic
- * - fromSeed
- */
- function HDNode(constructorGuard, privateKey, publicKey, parentFingerprint, chainCode, index, depth, mnemonicOrPath) {
- var _newTarget = this.constructor;
- logger.checkNew(_newTarget, HDNode);
- /* istanbul ignore if */
- if (constructorGuard !== _constructorGuard) {
- throw new Error("HDNode constructor cannot be called directly");
- }
- if (privateKey) {
- var signingKey = new signing_key_1.SigningKey(privateKey);
- (0, properties_1.defineReadOnly)(this, "privateKey", signingKey.privateKey);
- (0, properties_1.defineReadOnly)(this, "publicKey", signingKey.compressedPublicKey);
- }
- else {
- (0, properties_1.defineReadOnly)(this, "privateKey", null);
- (0, properties_1.defineReadOnly)(this, "publicKey", (0, bytes_1.hexlify)(publicKey));
- }
- (0, properties_1.defineReadOnly)(this, "parentFingerprint", parentFingerprint);
- (0, properties_1.defineReadOnly)(this, "fingerprint", (0, bytes_1.hexDataSlice)((0, sha2_1.ripemd160)((0, sha2_1.sha256)(this.publicKey)), 0, 4));
- (0, properties_1.defineReadOnly)(this, "address", (0, transactions_1.computeAddress)(this.publicKey));
- (0, properties_1.defineReadOnly)(this, "chainCode", chainCode);
- (0, properties_1.defineReadOnly)(this, "index", index);
- (0, properties_1.defineReadOnly)(this, "depth", depth);
- if (mnemonicOrPath == null) {
- // From a source that does not preserve the path (e.g. extended keys)
- (0, properties_1.defineReadOnly)(this, "mnemonic", null);
- (0, properties_1.defineReadOnly)(this, "path", null);
- }
- else if (typeof (mnemonicOrPath) === "string") {
- // From a source that does not preserve the mnemonic (e.g. neutered)
- (0, properties_1.defineReadOnly)(this, "mnemonic", null);
- (0, properties_1.defineReadOnly)(this, "path", mnemonicOrPath);
- }
- else {
- // From a fully qualified source
- (0, properties_1.defineReadOnly)(this, "mnemonic", mnemonicOrPath);
- (0, properties_1.defineReadOnly)(this, "path", mnemonicOrPath.path);
- }
- }
- Object.defineProperty(HDNode.prototype, "extendedKey", {
- get: function () {
- // We only support the mainnet values for now, but if anyone needs
- // testnet values, let me know. I believe current sentiment is that
- // we should always use mainnet, and use BIP-44 to derive the network
- // - Mainnet: public=0x0488B21E, private=0x0488ADE4
- // - Testnet: public=0x043587CF, private=0x04358394
- if (this.depth >= 256) {
- throw new Error("Depth too large!");
- }
- return base58check((0, bytes_1.concat)([
- ((this.privateKey != null) ? "0x0488ADE4" : "0x0488B21E"),
- (0, bytes_1.hexlify)(this.depth),
- this.parentFingerprint,
- (0, bytes_1.hexZeroPad)((0, bytes_1.hexlify)(this.index), 4),
- this.chainCode,
- ((this.privateKey != null) ? (0, bytes_1.concat)(["0x00", this.privateKey]) : this.publicKey),
- ]));
- },
- enumerable: false,
- configurable: true
- });
- HDNode.prototype.neuter = function () {
- return new HDNode(_constructorGuard, null, this.publicKey, this.parentFingerprint, this.chainCode, this.index, this.depth, this.path);
- };
- HDNode.prototype._derive = function (index) {
- if (index > 0xffffffff) {
- throw new Error("invalid index - " + String(index));
- }
- // Base path
- var path = this.path;
- if (path) {
- path += "/" + (index & ~HardenedBit);
- }
- var data = new Uint8Array(37);
- if (index & HardenedBit) {
- if (!this.privateKey) {
- throw new Error("cannot derive child of neutered node");
- }
- // Data = 0x00 || ser_256(k_par)
- data.set((0, bytes_1.arrayify)(this.privateKey), 1);
- // Hardened path
- if (path) {
- path += "'";
- }
- }
- else {
- // Data = ser_p(point(k_par))
- data.set((0, bytes_1.arrayify)(this.publicKey));
- }
- // Data += ser_32(i)
- for (var i = 24; i >= 0; i -= 8) {
- data[33 + (i >> 3)] = ((index >> (24 - i)) & 0xff);
- }
- var I = (0, bytes_1.arrayify)((0, sha2_1.computeHmac)(sha2_1.SupportedAlgorithm.sha512, this.chainCode, data));
- var IL = I.slice(0, 32);
- var IR = I.slice(32);
- // The private key
- var ki = null;
- // The public key
- var Ki = null;
- if (this.privateKey) {
- ki = bytes32(bignumber_1.BigNumber.from(IL).add(this.privateKey).mod(N));
- }
- else {
- var ek = new signing_key_1.SigningKey((0, bytes_1.hexlify)(IL));
- Ki = ek._addPoint(this.publicKey);
- }
- var mnemonicOrPath = path;
- var srcMnemonic = this.mnemonic;
- if (srcMnemonic) {
- mnemonicOrPath = Object.freeze({
- phrase: srcMnemonic.phrase,
- path: path,
- locale: (srcMnemonic.locale || "en")
- });
- }
- return new HDNode(_constructorGuard, ki, Ki, this.fingerprint, bytes32(IR), index, this.depth + 1, mnemonicOrPath);
- };
- HDNode.prototype.derivePath = function (path) {
- var components = path.split("/");
- if (components.length === 0 || (components[0] === "m" && this.depth !== 0)) {
- throw new Error("invalid path - " + path);
- }
- if (components[0] === "m") {
- components.shift();
- }
- var result = this;
- for (var i = 0; i < components.length; i++) {
- var component = components[i];
- if (component.match(/^[0-9]+'$/)) {
- var index = parseInt(component.substring(0, component.length - 1));
- if (index >= HardenedBit) {
- throw new Error("invalid path index - " + component);
- }
- result = result._derive(HardenedBit + index);
- }
- else if (component.match(/^[0-9]+$/)) {
- var index = parseInt(component);
- if (index >= HardenedBit) {
- throw new Error("invalid path index - " + component);
- }
- result = result._derive(index);
- }
- else {
- throw new Error("invalid path component - " + component);
- }
- }
- return result;
- };
- HDNode._fromSeed = function (seed, mnemonic) {
- var seedArray = (0, bytes_1.arrayify)(seed);
- if (seedArray.length < 16 || seedArray.length > 64) {
- throw new Error("invalid seed");
- }
- var I = (0, bytes_1.arrayify)((0, sha2_1.computeHmac)(sha2_1.SupportedAlgorithm.sha512, MasterSecret, seedArray));
- return new HDNode(_constructorGuard, bytes32(I.slice(0, 32)), null, "0x00000000", bytes32(I.slice(32)), 0, 0, mnemonic);
- };
- HDNode.fromMnemonic = function (mnemonic, password, wordlist) {
- // If a locale name was passed in, find the associated wordlist
- wordlist = getWordlist(wordlist);
- // Normalize the case and spacing in the mnemonic (throws if the mnemonic is invalid)
- mnemonic = entropyToMnemonic(mnemonicToEntropy(mnemonic, wordlist), wordlist);
- return HDNode._fromSeed(mnemonicToSeed(mnemonic, password), {
- phrase: mnemonic,
- path: "m",
- locale: wordlist.locale
- });
- };
- HDNode.fromSeed = function (seed) {
- return HDNode._fromSeed(seed, null);
- };
- HDNode.fromExtendedKey = function (extendedKey) {
- var bytes = basex_1.Base58.decode(extendedKey);
- if (bytes.length !== 82 || base58check(bytes.slice(0, 78)) !== extendedKey) {
- logger.throwArgumentError("invalid extended key", "extendedKey", "[REDACTED]");
- }
- var depth = bytes[4];
- var parentFingerprint = (0, bytes_1.hexlify)(bytes.slice(5, 9));
- var index = parseInt((0, bytes_1.hexlify)(bytes.slice(9, 13)).substring(2), 16);
- var chainCode = (0, bytes_1.hexlify)(bytes.slice(13, 45));
- var key = bytes.slice(45, 78);
- switch ((0, bytes_1.hexlify)(bytes.slice(0, 4))) {
- // Public Key
- case "0x0488b21e":
- case "0x043587cf":
- return new HDNode(_constructorGuard, null, (0, bytes_1.hexlify)(key), parentFingerprint, chainCode, index, depth, null);
- // Private Key
- case "0x0488ade4":
- case "0x04358394 ":
- if (key[0] !== 0) {
- break;
- }
- return new HDNode(_constructorGuard, (0, bytes_1.hexlify)(key.slice(1)), null, parentFingerprint, chainCode, index, depth, null);
- }
- return logger.throwArgumentError("invalid extended key", "extendedKey", "[REDACTED]");
- };
- return HDNode;
- }());
- exports.HDNode = HDNode;
- function mnemonicToSeed(mnemonic, password) {
- if (!password) {
- password = "";
- }
- var salt = (0, strings_1.toUtf8Bytes)("mnemonic" + password, strings_1.UnicodeNormalizationForm.NFKD);
- return (0, pbkdf2_1.pbkdf2)((0, strings_1.toUtf8Bytes)(mnemonic, strings_1.UnicodeNormalizationForm.NFKD), salt, 2048, 64, "sha512");
- }
- exports.mnemonicToSeed = mnemonicToSeed;
- function mnemonicToEntropy(mnemonic, wordlist) {
- wordlist = getWordlist(wordlist);
- logger.checkNormalize();
- var words = wordlist.split(mnemonic);
- if ((words.length % 3) !== 0) {
- throw new Error("invalid mnemonic");
- }
- var entropy = (0, bytes_1.arrayify)(new Uint8Array(Math.ceil(11 * words.length / 8)));
- var offset = 0;
- for (var i = 0; i < words.length; i++) {
- var index = wordlist.getWordIndex(words[i].normalize("NFKD"));
- if (index === -1) {
- throw new Error("invalid mnemonic");
- }
- for (var bit = 0; bit < 11; bit++) {
- if (index & (1 << (10 - bit))) {
- entropy[offset >> 3] |= (1 << (7 - (offset % 8)));
- }
- offset++;
- }
- }
- var entropyBits = 32 * words.length / 3;
- var checksumBits = words.length / 3;
- var checksumMask = getUpperMask(checksumBits);
- var checksum = (0, bytes_1.arrayify)((0, sha2_1.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
- if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
- throw new Error("invalid checksum");
- }
- return (0, bytes_1.hexlify)(entropy.slice(0, entropyBits / 8));
- }
- exports.mnemonicToEntropy = mnemonicToEntropy;
- function entropyToMnemonic(entropy, wordlist) {
- wordlist = getWordlist(wordlist);
- entropy = (0, bytes_1.arrayify)(entropy);
- if ((entropy.length % 4) !== 0 || entropy.length < 16 || entropy.length > 32) {
- throw new Error("invalid entropy");
- }
- var indices = [0];
- var remainingBits = 11;
- for (var i = 0; i < entropy.length; i++) {
- // Consume the whole byte (with still more to go)
- if (remainingBits > 8) {
- indices[indices.length - 1] <<= 8;
- indices[indices.length - 1] |= entropy[i];
- remainingBits -= 8;
- // This byte will complete an 11-bit index
- }
- else {
- indices[indices.length - 1] <<= remainingBits;
- indices[indices.length - 1] |= entropy[i] >> (8 - remainingBits);
- // Start the next word
- indices.push(entropy[i] & getLowerMask(8 - remainingBits));
- remainingBits += 3;
- }
- }
- // Compute the checksum bits
- var checksumBits = entropy.length / 4;
- var checksum = (0, bytes_1.arrayify)((0, sha2_1.sha256)(entropy))[0] & getUpperMask(checksumBits);
- // Shift the checksum into the word indices
- indices[indices.length - 1] <<= checksumBits;
- indices[indices.length - 1] |= (checksum >> (8 - checksumBits));
- return wordlist.join(indices.map(function (index) { return wordlist.getWord(index); }));
- }
- exports.entropyToMnemonic = entropyToMnemonic;
- function isValidMnemonic(mnemonic, wordlist) {
- try {
- mnemonicToEntropy(mnemonic, wordlist);
- return true;
- }
- catch (error) { }
- return false;
- }
- exports.isValidMnemonic = isValidMnemonic;
- function getAccountPath(index) {
- if (typeof (index) !== "number" || index < 0 || index >= HardenedBit || index % 1) {
- logger.throwArgumentError("invalid account index", "index", index);
- }
- return "m/44'/60'/" + index + "'/0/0";
- }
- exports.getAccountPath = getAccountPath;
- },{"./_version":213,"@ethersproject/basex":192,"@ethersproject/bignumber":196,"@ethersproject/bytes":199,"@ethersproject/logger":223,"@ethersproject/pbkdf2":227,"@ethersproject/properties":229,"@ethersproject/sha2":256,"@ethersproject/signing-key":260,"@ethersproject/strings":266,"@ethersproject/transactions":269,"@ethersproject/wordlists":278}],215:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.version = void 0;
- exports.version = "json-wallets/5.6.0";
- },{}],216:[function(_dereq_,module,exports){
- "use strict";
- var __extends = (this && this.__extends) || (function () {
- var extendStatics = function (d, b) {
- extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
- return extendStatics(d, b);
- };
- return function (d, b) {
- if (typeof b !== "function" && b !== null)
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- var __importDefault = (this && this.__importDefault) || function (mod) {
- return (mod && mod.__esModule) ? mod : { "default": mod };
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.decrypt = exports.CrowdsaleAccount = void 0;
- var aes_js_1 = __importDefault(_dereq_("aes-js"));
- var address_1 = _dereq_("@ethersproject/address");
- var bytes_1 = _dereq_("@ethersproject/bytes");
- var keccak256_1 = _dereq_("@ethersproject/keccak256");
- var pbkdf2_1 = _dereq_("@ethersproject/pbkdf2");
- var strings_1 = _dereq_("@ethersproject/strings");
- var properties_1 = _dereq_("@ethersproject/properties");
- var logger_1 = _dereq_("@ethersproject/logger");
- var _version_1 = _dereq_("./_version");
- var logger = new logger_1.Logger(_version_1.version);
- var utils_1 = _dereq_("./utils");
- var CrowdsaleAccount = /** @class */ (function (_super) {
- __extends(CrowdsaleAccount, _super);
- function CrowdsaleAccount() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- CrowdsaleAccount.prototype.isCrowdsaleAccount = function (value) {
- return !!(value && value._isCrowdsaleAccount);
- };
- return CrowdsaleAccount;
- }(properties_1.Description));
- exports.CrowdsaleAccount = CrowdsaleAccount;
- // See: https://github.com/ethereum/pyethsaletool
- function decrypt(json, password) {
- var data = JSON.parse(json);
- password = (0, utils_1.getPassword)(password);
- // Ethereum Address
- var ethaddr = (0, address_1.getAddress)((0, utils_1.searchPath)(data, "ethaddr"));
- // Encrypted Seed
- var encseed = (0, utils_1.looseArrayify)((0, utils_1.searchPath)(data, "encseed"));
- if (!encseed || (encseed.length % 16) !== 0) {
- logger.throwArgumentError("invalid encseed", "json", json);
- }
- var key = (0, bytes_1.arrayify)((0, pbkdf2_1.pbkdf2)(password, password, 2000, 32, "sha256")).slice(0, 16);
- var iv = encseed.slice(0, 16);
- var encryptedSeed = encseed.slice(16);
- // Decrypt the seed
- var aesCbc = new aes_js_1.default.ModeOfOperation.cbc(key, iv);
- var seed = aes_js_1.default.padding.pkcs7.strip((0, bytes_1.arrayify)(aesCbc.decrypt(encryptedSeed)));
- // This wallet format is weird... Convert the binary encoded hex to a string.
- var seedHex = "";
- for (var i = 0; i < seed.length; i++) {
- seedHex += String.fromCharCode(seed[i]);
- }
- var seedHexBytes = (0, strings_1.toUtf8Bytes)(seedHex);
- var privateKey = (0, keccak256_1.keccak256)(seedHexBytes);
- return new CrowdsaleAccount({
- _isCrowdsaleAccount: true,
- address: ethaddr,
- privateKey: privateKey
- });
- }
- exports.decrypt = decrypt;
- },{"./_version":215,"./utils":220,"@ethersproject/address":189,"@ethersproject/bytes":199,"@ethersproject/keccak256":221,"@ethersproject/logger":223,"@ethersproject/pbkdf2":227,"@ethersproject/properties":229,"@ethersproject/strings":266,"aes-js":290}],217:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.decryptJsonWalletSync = exports.decryptJsonWallet = exports.getJsonWalletAddress = exports.isKeystoreWallet = exports.isCrowdsaleWallet = exports.encryptKeystore = exports.decryptKeystoreSync = exports.decryptKeystore = exports.decryptCrowdsale = void 0;
- var crowdsale_1 = _dereq_("./crowdsale");
- Object.defineProperty(exports, "decryptCrowdsale", { enumerable: true, get: function () { return crowdsale_1.decrypt; } });
- var inspect_1 = _dereq_("./inspect");
- Object.defineProperty(exports, "getJsonWalletAddress", { enumerable: true, get: function () { return inspect_1.getJsonWalletAddress; } });
- Object.defineProperty(exports, "isCrowdsaleWallet", { enumerable: true, get: function () { return inspect_1.isCrowdsaleWallet; } });
- Object.defineProperty(exports, "isKeystoreWallet", { enumerable: true, get: function () { return inspect_1.isKeystoreWallet; } });
- var keystore_1 = _dereq_("./keystore");
- Object.defineProperty(exports, "decryptKeystore", { enumerable: true, get: function () { return keystore_1.decrypt; } });
- Object.defineProperty(exports, "decryptKeystoreSync", { enumerable: true, get: function () { return keystore_1.decryptSync; } });
- Object.defineProperty(exports, "encryptKeystore", { enumerable: true, get: function () { return keystore_1.encrypt; } });
- function decryptJsonWallet(json, password, progressCallback) {
- if ((0, inspect_1.isCrowdsaleWallet)(json)) {
- if (progressCallback) {
- progressCallback(0);
- }
- var account = (0, crowdsale_1.decrypt)(json, password);
- if (progressCallback) {
- progressCallback(1);
- }
- return Promise.resolve(account);
- }
- if ((0, inspect_1.isKeystoreWallet)(json)) {
- return (0, keystore_1.decrypt)(json, password, progressCallback);
- }
- return Promise.reject(new Error("invalid JSON wallet"));
- }
- exports.decryptJsonWallet = decryptJsonWallet;
- function decryptJsonWalletSync(json, password) {
- if ((0, inspect_1.isCrowdsaleWallet)(json)) {
- return (0, crowdsale_1.decrypt)(json, password);
- }
- if ((0, inspect_1.isKeystoreWallet)(json)) {
- return (0, keystore_1.decryptSync)(json, password);
- }
- throw new Error("invalid JSON wallet");
- }
- exports.decryptJsonWalletSync = decryptJsonWalletSync;
- },{"./crowdsale":216,"./inspect":218,"./keystore":219}],218:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.getJsonWalletAddress = exports.isKeystoreWallet = exports.isCrowdsaleWallet = void 0;
- var address_1 = _dereq_("@ethersproject/address");
- function isCrowdsaleWallet(json) {
- var data = null;
- try {
- data = JSON.parse(json);
- }
- catch (error) {
- return false;
- }
- return (data.encseed && data.ethaddr);
- }
- exports.isCrowdsaleWallet = isCrowdsaleWallet;
- function isKeystoreWallet(json) {
- var data = null;
- try {
- data = JSON.parse(json);
- }
- catch (error) {
- return false;
- }
- if (!data.version || parseInt(data.version) !== data.version || parseInt(data.version) !== 3) {
- return false;
- }
- // @TODO: Put more checks to make sure it has kdf, iv and all that good stuff
- return true;
- }
- exports.isKeystoreWallet = isKeystoreWallet;
- //export function isJsonWallet(json: string): boolean {
- // return (isSecretStorageWallet(json) || isCrowdsaleWallet(json));
- //}
- function getJsonWalletAddress(json) {
- if (isCrowdsaleWallet(json)) {
- try {
- return (0, address_1.getAddress)(JSON.parse(json).ethaddr);
- }
- catch (error) {
- return null;
- }
- }
- if (isKeystoreWallet(json)) {
- try {
- return (0, address_1.getAddress)(JSON.parse(json).address);
- }
- catch (error) {
- return null;
- }
- }
- return null;
- }
- exports.getJsonWalletAddress = getJsonWalletAddress;
- },{"@ethersproject/address":189}],219:[function(_dereq_,module,exports){
- "use strict";
- var __extends = (this && this.__extends) || (function () {
- var extendStatics = function (d, b) {
- extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
- return extendStatics(d, b);
- };
- return function (d, b) {
- if (typeof b !== "function" && b !== null)
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
- return new (P || (P = Promise))(function (resolve, reject) {
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
- step((generator = generator.apply(thisArg, _arguments || [])).next());
- });
- };
- var __generator = (this && this.__generator) || function (thisArg, body) {
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
- function verb(n) { return function (v) { return step([n, v]); }; }
- function step(op) {
- if (f) throw new TypeError("Generator is already executing.");
- while (_) try {
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
- if (y = 0, t) op = [op[0] & 2, t.value];
- switch (op[0]) {
- case 0: case 1: t = op; break;
- case 4: _.label++; return { value: op[1], done: false };
- case 5: _.label++; y = op[1]; op = [0]; continue;
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
- default:
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
- if (t[2]) _.ops.pop();
- _.trys.pop(); continue;
- }
- op = body.call(thisArg, _);
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
- }
- };
- var __importDefault = (this && this.__importDefault) || function (mod) {
- return (mod && mod.__esModule) ? mod : { "default": mod };
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.encrypt = exports.decrypt = exports.decryptSync = exports.KeystoreAccount = void 0;
- var aes_js_1 = __importDefault(_dereq_("aes-js"));
- var scrypt_js_1 = __importDefault(_dereq_("scrypt-js"));
- var address_1 = _dereq_("@ethersproject/address");
- var bytes_1 = _dereq_("@ethersproject/bytes");
- var hdnode_1 = _dereq_("@ethersproject/hdnode");
- var keccak256_1 = _dereq_("@ethersproject/keccak256");
- var pbkdf2_1 = _dereq_("@ethersproject/pbkdf2");
- var random_1 = _dereq_("@ethersproject/random");
- var properties_1 = _dereq_("@ethersproject/properties");
- var transactions_1 = _dereq_("@ethersproject/transactions");
- var utils_1 = _dereq_("./utils");
- var logger_1 = _dereq_("@ethersproject/logger");
- var _version_1 = _dereq_("./_version");
- var logger = new logger_1.Logger(_version_1.version);
- // Exported Types
- function hasMnemonic(value) {
- return (value != null && value.mnemonic && value.mnemonic.phrase);
- }
- var KeystoreAccount = /** @class */ (function (_super) {
- __extends(KeystoreAccount, _super);
- function KeystoreAccount() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- KeystoreAccount.prototype.isKeystoreAccount = function (value) {
- return !!(value && value._isKeystoreAccount);
- };
- return KeystoreAccount;
- }(properties_1.Description));
- exports.KeystoreAccount = KeystoreAccount;
- function _decrypt(data, key, ciphertext) {
- var cipher = (0, utils_1.searchPath)(data, "crypto/cipher");
- if (cipher === "aes-128-ctr") {
- var iv = (0, utils_1.looseArrayify)((0, utils_1.searchPath)(data, "crypto/cipherparams/iv"));
- var counter = new aes_js_1.default.Counter(iv);
- var aesCtr = new aes_js_1.default.ModeOfOperation.ctr(key, counter);
- return (0, bytes_1.arrayify)(aesCtr.decrypt(ciphertext));
- }
- return null;
- }
- function _getAccount(data, key) {
- var ciphertext = (0, utils_1.looseArrayify)((0, utils_1.searchPath)(data, "crypto/ciphertext"));
- var computedMAC = (0, bytes_1.hexlify)((0, keccak256_1.keccak256)((0, bytes_1.concat)([key.slice(16, 32), ciphertext]))).substring(2);
- if (computedMAC !== (0, utils_1.searchPath)(data, "crypto/mac").toLowerCase()) {
- throw new Error("invalid password");
- }
- var privateKey = _decrypt(data, key.slice(0, 16), ciphertext);
- if (!privateKey) {
- logger.throwError("unsupported cipher", logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
- operation: "decrypt"
- });
- }
- var mnemonicKey = key.slice(32, 64);
- var address = (0, transactions_1.computeAddress)(privateKey);
- if (data.address) {
- var check = data.address.toLowerCase();
- if (check.substring(0, 2) !== "0x") {
- check = "0x" + check;
- }
- if ((0, address_1.getAddress)(check) !== address) {
- throw new Error("address mismatch");
- }
- }
- var account = {
- _isKeystoreAccount: true,
- address: address,
- privateKey: (0, bytes_1.hexlify)(privateKey)
- };
- // Version 0.1 x-ethers metadata must contain an encrypted mnemonic phrase
- if ((0, utils_1.searchPath)(data, "x-ethers/version") === "0.1") {
- var mnemonicCiphertext = (0, utils_1.looseArrayify)((0, utils_1.searchPath)(data, "x-ethers/mnemonicCiphertext"));
- var mnemonicIv = (0, utils_1.looseArrayify)((0, utils_1.searchPath)(data, "x-ethers/mnemonicCounter"));
- var mnemonicCounter = new aes_js_1.default.Counter(mnemonicIv);
- var mnemonicAesCtr = new aes_js_1.default.ModeOfOperation.ctr(mnemonicKey, mnemonicCounter);
- var path = (0, utils_1.searchPath)(data, "x-ethers/path") || hdnode_1.defaultPath;
- var locale = (0, utils_1.searchPath)(data, "x-ethers/locale") || "en";
- var entropy = (0, bytes_1.arrayify)(mnemonicAesCtr.decrypt(mnemonicCiphertext));
- try {
- var mnemonic = (0, hdnode_1.entropyToMnemonic)(entropy, locale);
- var node = hdnode_1.HDNode.fromMnemonic(mnemonic, null, locale).derivePath(path);
- if (node.privateKey != account.privateKey) {
- throw new Error("mnemonic mismatch");
- }
- account.mnemonic = node.mnemonic;
- }
- catch (error) {
- // If we don't have the locale wordlist installed to
- // read this mnemonic, just bail and don't set the
- // mnemonic
- if (error.code !== logger_1.Logger.errors.INVALID_ARGUMENT || error.argument !== "wordlist") {
- throw error;
- }
- }
- }
- return new KeystoreAccount(account);
- }
- function pbkdf2Sync(passwordBytes, salt, count, dkLen, prfFunc) {
- return (0, bytes_1.arrayify)((0, pbkdf2_1.pbkdf2)(passwordBytes, salt, count, dkLen, prfFunc));
- }
- function pbkdf2(passwordBytes, salt, count, dkLen, prfFunc) {
- return Promise.resolve(pbkdf2Sync(passwordBytes, salt, count, dkLen, prfFunc));
- }
- function _computeKdfKey(data, password, pbkdf2Func, scryptFunc, progressCallback) {
- var passwordBytes = (0, utils_1.getPassword)(password);
- var kdf = (0, utils_1.searchPath)(data, "crypto/kdf");
- if (kdf && typeof (kdf) === "string") {
- var throwError = function (name, value) {
- return logger.throwArgumentError("invalid key-derivation function parameters", name, value);
- };
- if (kdf.toLowerCase() === "scrypt") {
- var salt = (0, utils_1.looseArrayify)((0, utils_1.searchPath)(data, "crypto/kdfparams/salt"));
- var N = parseInt((0, utils_1.searchPath)(data, "crypto/kdfparams/n"));
- var r = parseInt((0, utils_1.searchPath)(data, "crypto/kdfparams/r"));
- var p = parseInt((0, utils_1.searchPath)(data, "crypto/kdfparams/p"));
- // Check for all required parameters
- if (!N || !r || !p) {
- throwError("kdf", kdf);
- }
- // Make sure N is a power of 2
- if ((N & (N - 1)) !== 0) {
- throwError("N", N);
- }
- var dkLen = parseInt((0, utils_1.searchPath)(data, "crypto/kdfparams/dklen"));
- if (dkLen !== 32) {
- throwError("dklen", dkLen);
- }
- return scryptFunc(passwordBytes, salt, N, r, p, 64, progressCallback);
- }
- else if (kdf.toLowerCase() === "pbkdf2") {
- var salt = (0, utils_1.looseArrayify)((0, utils_1.searchPath)(data, "crypto/kdfparams/salt"));
- var prfFunc = null;
- var prf = (0, utils_1.searchPath)(data, "crypto/kdfparams/prf");
- if (prf === "hmac-sha256") {
- prfFunc = "sha256";
- }
- else if (prf === "hmac-sha512") {
- prfFunc = "sha512";
- }
- else {
- throwError("prf", prf);
- }
- var count = parseInt((0, utils_1.searchPath)(data, "crypto/kdfparams/c"));
- var dkLen = parseInt((0, utils_1.searchPath)(data, "crypto/kdfparams/dklen"));
- if (dkLen !== 32) {
- throwError("dklen", dkLen);
- }
- return pbkdf2Func(passwordBytes, salt, count, dkLen, prfFunc);
- }
- }
- return logger.throwArgumentError("unsupported key-derivation function", "kdf", kdf);
- }
- function decryptSync(json, password) {
- var data = JSON.parse(json);
- var key = _computeKdfKey(data, password, pbkdf2Sync, scrypt_js_1.default.syncScrypt);
- return _getAccount(data, key);
- }
- exports.decryptSync = decryptSync;
- function decrypt(json, password, progressCallback) {
- return __awaiter(this, void 0, void 0, function () {
- var data, key;
- return __generator(this, function (_a) {
- switch (_a.label) {
- case 0:
- data = JSON.parse(json);
- return [4 /*yield*/, _computeKdfKey(data, password, pbkdf2, scrypt_js_1.default.scrypt, progressCallback)];
- case 1:
- key = _a.sent();
- return [2 /*return*/, _getAccount(data, key)];
- }
- });
- });
- }
- exports.decrypt = decrypt;
- function encrypt(account, password, options, progressCallback) {
- try {
- // Check the address matches the private key
- if ((0, address_1.getAddress)(account.address) !== (0, transactions_1.computeAddress)(account.privateKey)) {
- throw new Error("address/privateKey mismatch");
- }
- // Check the mnemonic (if any) matches the private key
- if (hasMnemonic(account)) {
- var mnemonic = account.mnemonic;
- var node = hdnode_1.HDNode.fromMnemonic(mnemonic.phrase, null, mnemonic.locale).derivePath(mnemonic.path || hdnode_1.defaultPath);
- if (node.privateKey != account.privateKey) {
- throw new Error("mnemonic mismatch");
- }
- }
- }
- catch (e) {
- return Promise.reject(e);
- }
- // The options are optional, so adjust the call as needed
- if (typeof (options) === "function" && !progressCallback) {
- progressCallback = options;
- options = {};
- }
- if (!options) {
- options = {};
- }
- var privateKey = (0, bytes_1.arrayify)(account.privateKey);
- var passwordBytes = (0, utils_1.getPassword)(password);
- var entropy = null;
- var path = null;
- var locale = null;
- if (hasMnemonic(account)) {
- var srcMnemonic = account.mnemonic;
- entropy = (0, bytes_1.arrayify)((0, hdnode_1.mnemonicToEntropy)(srcMnemonic.phrase, srcMnemonic.locale || "en"));
- path = srcMnemonic.path || hdnode_1.defaultPath;
- locale = srcMnemonic.locale || "en";
- }
- var client = options.client;
- if (!client) {
- client = "ethers.js";
- }
- // Check/generate the salt
- var salt = null;
- if (options.salt) {
- salt = (0, bytes_1.arrayify)(options.salt);
- }
- else {
- salt = (0, random_1.randomBytes)(32);
- ;
- }
- // Override initialization vector
- var iv = null;
- if (options.iv) {
- iv = (0, bytes_1.arrayify)(options.iv);
- if (iv.length !== 16) {
- throw new Error("invalid iv");
- }
- }
- else {
- iv = (0, random_1.randomBytes)(16);
- }
- // Override the uuid
- var uuidRandom = null;
- if (options.uuid) {
- uuidRandom = (0, bytes_1.arrayify)(options.uuid);
- if (uuidRandom.length !== 16) {
- throw new Error("invalid uuid");
- }
- }
- else {
- uuidRandom = (0, random_1.randomBytes)(16);
- }
- // Override the scrypt password-based key derivation function parameters
- var N = (1 << 17), r = 8, p = 1;
- if (options.scrypt) {
- if (options.scrypt.N) {
- N = options.scrypt.N;
- }
- if (options.scrypt.r) {
- r = options.scrypt.r;
- }
- if (options.scrypt.p) {
- p = options.scrypt.p;
- }
- }
- // We take 64 bytes:
- // - 32 bytes As normal for the Web3 secret storage (derivedKey, macPrefix)
- // - 32 bytes AES key to encrypt mnemonic with (required here to be Ethers Wallet)
- return scrypt_js_1.default.scrypt(passwordBytes, salt, N, r, p, 64, progressCallback).then(function (key) {
- key = (0, bytes_1.arrayify)(key);
- // This will be used to encrypt the wallet (as per Web3 secret storage)
- var derivedKey = key.slice(0, 16);
- var macPrefix = key.slice(16, 32);
- // This will be used to encrypt the mnemonic phrase (if any)
- var mnemonicKey = key.slice(32, 64);
- // Encrypt the private key
- var counter = new aes_js_1.default.Counter(iv);
- var aesCtr = new aes_js_1.default.ModeOfOperation.ctr(derivedKey, counter);
- var ciphertext = (0, bytes_1.arrayify)(aesCtr.encrypt(privateKey));
- // Compute the message authentication code, used to check the password
- var mac = (0, keccak256_1.keccak256)((0, bytes_1.concat)([macPrefix, ciphertext]));
- // See: https://github.com/ethereum/wiki/wiki/Web3-Secret-Storage-Definition
- var data = {
- address: account.address.substring(2).toLowerCase(),
- id: (0, utils_1.uuidV4)(uuidRandom),
- version: 3,
- Crypto: {
- cipher: "aes-128-ctr",
- cipherparams: {
- iv: (0, bytes_1.hexlify)(iv).substring(2),
- },
- ciphertext: (0, bytes_1.hexlify)(ciphertext).substring(2),
- kdf: "scrypt",
- kdfparams: {
- salt: (0, bytes_1.hexlify)(salt).substring(2),
- n: N,
- dklen: 32,
- p: p,
- r: r
- },
- mac: mac.substring(2)
- }
- };
- // If we have a mnemonic, encrypt it into the JSON wallet
- if (entropy) {
- var mnemonicIv = (0, random_1.randomBytes)(16);
- var mnemonicCounter = new aes_js_1.default.Counter(mnemonicIv);
- var mnemonicAesCtr = new aes_js_1.default.ModeOfOperation.ctr(mnemonicKey, mnemonicCounter);
- var mnemonicCiphertext = (0, bytes_1.arrayify)(mnemonicAesCtr.encrypt(entropy));
- var now = new Date();
- var timestamp = (now.getUTCFullYear() + "-" +
- (0, utils_1.zpad)(now.getUTCMonth() + 1, 2) + "-" +
- (0, utils_1.zpad)(now.getUTCDate(), 2) + "T" +
- (0, utils_1.zpad)(now.getUTCHours(), 2) + "-" +
- (0, utils_1.zpad)(now.getUTCMinutes(), 2) + "-" +
- (0, utils_1.zpad)(now.getUTCSeconds(), 2) + ".0Z");
- data["x-ethers"] = {
- client: client,
- gethFilename: ("UTC--" + timestamp + "--" + data.address),
- mnemonicCounter: (0, bytes_1.hexlify)(mnemonicIv).substring(2),
- mnemonicCiphertext: (0, bytes_1.hexlify)(mnemonicCiphertext).substring(2),
- path: path,
- locale: locale,
- version: "0.1"
- };
- }
- return JSON.stringify(data);
- });
- }
- exports.encrypt = encrypt;
- },{"./_version":215,"./utils":220,"@ethersproject/address":189,"@ethersproject/bytes":199,"@ethersproject/hdnode":214,"@ethersproject/keccak256":221,"@ethersproject/logger":223,"@ethersproject/pbkdf2":227,"@ethersproject/properties":229,"@ethersproject/random":250,"@ethersproject/transactions":269,"aes-js":290,"scrypt-js":795}],220:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.uuidV4 = exports.searchPath = exports.getPassword = exports.zpad = exports.looseArrayify = void 0;
- var bytes_1 = _dereq_("@ethersproject/bytes");
- var strings_1 = _dereq_("@ethersproject/strings");
- function looseArrayify(hexString) {
- if (typeof (hexString) === 'string' && hexString.substring(0, 2) !== '0x') {
- hexString = '0x' + hexString;
- }
- return (0, bytes_1.arrayify)(hexString);
- }
- exports.looseArrayify = looseArrayify;
- function zpad(value, length) {
- value = String(value);
- while (value.length < length) {
- value = '0' + value;
- }
- return value;
- }
- exports.zpad = zpad;
- function getPassword(password) {
- if (typeof (password) === 'string') {
- return (0, strings_1.toUtf8Bytes)(password, strings_1.UnicodeNormalizationForm.NFKC);
- }
- return (0, bytes_1.arrayify)(password);
- }
- exports.getPassword = getPassword;
- function searchPath(object, path) {
- var currentChild = object;
- var comps = path.toLowerCase().split('/');
- for (var i = 0; i < comps.length; i++) {
- // Search for a child object with a case-insensitive matching key
- var matchingChild = null;
- for (var key in currentChild) {
- if (key.toLowerCase() === comps[i]) {
- matchingChild = currentChild[key];
- break;
- }
- }
- // Didn't find one. :'(
- if (matchingChild === null) {
- return null;
- }
- // Now check this child...
- currentChild = matchingChild;
- }
- return currentChild;
- }
- exports.searchPath = searchPath;
- // See: https://www.ietf.org/rfc/rfc4122.txt (Section 4.4)
- function uuidV4(randomBytes) {
- var bytes = (0, bytes_1.arrayify)(randomBytes);
- // Section: 4.1.3:
- // - time_hi_and_version[12:16] = 0b0100
- bytes[6] = (bytes[6] & 0x0f) | 0x40;
- // Section 4.4
- // - clock_seq_hi_and_reserved[6] = 0b0
- // - clock_seq_hi_and_reserved[7] = 0b1
- bytes[8] = (bytes[8] & 0x3f) | 0x80;
- var value = (0, bytes_1.hexlify)(bytes);
- return [
- value.substring(2, 10),
- value.substring(10, 14),
- value.substring(14, 18),
- value.substring(18, 22),
- value.substring(22, 34),
- ].join("-");
- }
- exports.uuidV4 = uuidV4;
- },{"@ethersproject/bytes":199,"@ethersproject/strings":266}],221:[function(_dereq_,module,exports){
- "use strict";
- var __importDefault = (this && this.__importDefault) || function (mod) {
- return (mod && mod.__esModule) ? mod : { "default": mod };
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.keccak256 = void 0;
- var js_sha3_1 = __importDefault(_dereq_("js-sha3"));
- var bytes_1 = _dereq_("@ethersproject/bytes");
- function keccak256(data) {
- return '0x' + js_sha3_1.default.keccak_256((0, bytes_1.arrayify)(data));
- }
- exports.keccak256 = keccak256;
- },{"@ethersproject/bytes":199,"js-sha3":790}],222:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.version = void 0;
- exports.version = "logger/5.6.0";
- },{}],223:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.Logger = exports.ErrorCode = exports.LogLevel = void 0;
- var _permanentCensorErrors = false;
- var _censorErrors = false;
- var LogLevels = { debug: 1, "default": 2, info: 2, warning: 3, error: 4, off: 5 };
- var _logLevel = LogLevels["default"];
- var _version_1 = _dereq_("./_version");
- var _globalLogger = null;
- function _checkNormalize() {
- try {
- var missing_1 = [];
- // Make sure all forms of normalization are supported
- ["NFD", "NFC", "NFKD", "NFKC"].forEach(function (form) {
- try {
- if ("test".normalize(form) !== "test") {
- throw new Error("bad normalize");
- }
- ;
- }
- catch (error) {
- missing_1.push(form);
- }
- });
- if (missing_1.length) {
- throw new Error("missing " + missing_1.join(", "));
- }
- if (String.fromCharCode(0xe9).normalize("NFD") !== String.fromCharCode(0x65, 0x0301)) {
- throw new Error("broken implementation");
- }
- }
- catch (error) {
- return error.message;
- }
- return null;
- }
- var _normalizeError = _checkNormalize();
- var LogLevel;
- (function (LogLevel) {
- LogLevel["DEBUG"] = "DEBUG";
- LogLevel["INFO"] = "INFO";
- LogLevel["WARNING"] = "WARNING";
- LogLevel["ERROR"] = "ERROR";
- LogLevel["OFF"] = "OFF";
- })(LogLevel = exports.LogLevel || (exports.LogLevel = {}));
- var ErrorCode;
- (function (ErrorCode) {
- ///////////////////
- // Generic Errors
- // Unknown Error
- ErrorCode["UNKNOWN_ERROR"] = "UNKNOWN_ERROR";
- // Not Implemented
- ErrorCode["NOT_IMPLEMENTED"] = "NOT_IMPLEMENTED";
- // Unsupported Operation
- // - operation
- ErrorCode["UNSUPPORTED_OPERATION"] = "UNSUPPORTED_OPERATION";
- // Network Error (i.e. Ethereum Network, such as an invalid chain ID)
- // - event ("noNetwork" is not re-thrown in provider.ready; otherwise thrown)
- ErrorCode["NETWORK_ERROR"] = "NETWORK_ERROR";
- // Some sort of bad response from the server
- ErrorCode["SERVER_ERROR"] = "SERVER_ERROR";
- // Timeout
- ErrorCode["TIMEOUT"] = "TIMEOUT";
- ///////////////////
- // Operational Errors
- // Buffer Overrun
- ErrorCode["BUFFER_OVERRUN"] = "BUFFER_OVERRUN";
- // Numeric Fault
- // - operation: the operation being executed
- // - fault: the reason this faulted
- ErrorCode["NUMERIC_FAULT"] = "NUMERIC_FAULT";
- ///////////////////
- // Argument Errors
- // Missing new operator to an object
- // - name: The name of the class
- ErrorCode["MISSING_NEW"] = "MISSING_NEW";
- // Invalid argument (e.g. value is incompatible with type) to a function:
- // - argument: The argument name that was invalid
- // - value: The value of the argument
- ErrorCode["INVALID_ARGUMENT"] = "INVALID_ARGUMENT";
- // Missing argument to a function:
- // - count: The number of arguments received
- // - expectedCount: The number of arguments expected
- ErrorCode["MISSING_ARGUMENT"] = "MISSING_ARGUMENT";
- // Too many arguments
- // - count: The number of arguments received
- // - expectedCount: The number of arguments expected
- ErrorCode["UNEXPECTED_ARGUMENT"] = "UNEXPECTED_ARGUMENT";
- ///////////////////
- // Blockchain Errors
- // Call exception
- // - transaction: the transaction
- // - address?: the contract address
- // - args?: The arguments passed into the function
- // - method?: The Solidity method signature
- // - errorSignature?: The EIP848 error signature
- // - errorArgs?: The EIP848 error parameters
- // - reason: The reason (only for EIP848 "Error(string)")
- ErrorCode["CALL_EXCEPTION"] = "CALL_EXCEPTION";
- // Insufficient funds (< value + gasLimit * gasPrice)
- // - transaction: the transaction attempted
- ErrorCode["INSUFFICIENT_FUNDS"] = "INSUFFICIENT_FUNDS";
- // Nonce has already been used
- // - transaction: the transaction attempted
- ErrorCode["NONCE_EXPIRED"] = "NONCE_EXPIRED";
- // The replacement fee for the transaction is too low
- // - transaction: the transaction attempted
- ErrorCode["REPLACEMENT_UNDERPRICED"] = "REPLACEMENT_UNDERPRICED";
- // The gas limit could not be estimated
- // - transaction: the transaction passed to estimateGas
- ErrorCode["UNPREDICTABLE_GAS_LIMIT"] = "UNPREDICTABLE_GAS_LIMIT";
- // The transaction was replaced by one with a higher gas price
- // - reason: "cancelled", "replaced" or "repriced"
- // - cancelled: true if reason == "cancelled" or reason == "replaced")
- // - hash: original transaction hash
- // - replacement: the full TransactionsResponse for the replacement
- // - receipt: the receipt of the replacement
- ErrorCode["TRANSACTION_REPLACED"] = "TRANSACTION_REPLACED";
- })(ErrorCode = exports.ErrorCode || (exports.ErrorCode = {}));
- ;
- var HEX = "0123456789abcdef";
- var Logger = /** @class */ (function () {
- function Logger(version) {
- Object.defineProperty(this, "version", {
- enumerable: true,
- value: version,
- writable: false
- });
- }
- Logger.prototype._log = function (logLevel, args) {
- var level = logLevel.toLowerCase();
- if (LogLevels[level] == null) {
- this.throwArgumentError("invalid log level name", "logLevel", logLevel);
- }
- if (_logLevel > LogLevels[level]) {
- return;
- }
- console.log.apply(console, args);
- };
- Logger.prototype.debug = function () {
- var args = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- args[_i] = arguments[_i];
- }
- this._log(Logger.levels.DEBUG, args);
- };
- Logger.prototype.info = function () {
- var args = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- args[_i] = arguments[_i];
- }
- this._log(Logger.levels.INFO, args);
- };
- Logger.prototype.warn = function () {
- var args = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- args[_i] = arguments[_i];
- }
- this._log(Logger.levels.WARNING, args);
- };
- Logger.prototype.makeError = function (message, code, params) {
- // Errors are being censored
- if (_censorErrors) {
- return this.makeError("censored error", code, {});
- }
- if (!code) {
- code = Logger.errors.UNKNOWN_ERROR;
- }
- if (!params) {
- params = {};
- }
- var messageDetails = [];
- Object.keys(params).forEach(function (key) {
- var value = params[key];
- try {
- if (value instanceof Uint8Array) {
- var hex = "";
- for (var i = 0; i < value.length; i++) {
- hex += HEX[value[i] >> 4];
- hex += HEX[value[i] & 0x0f];
- }
- messageDetails.push(key + "=Uint8Array(0x" + hex + ")");
- }
- else {
- messageDetails.push(key + "=" + JSON.stringify(value));
- }
- }
- catch (error) {
- messageDetails.push(key + "=" + JSON.stringify(params[key].toString()));
- }
- });
- messageDetails.push("code=" + code);
- messageDetails.push("version=" + this.version);
- var reason = message;
- var url = "";
- switch (code) {
- case ErrorCode.NUMERIC_FAULT: {
- url = "NUMERIC_FAULT";
- var fault = message;
- switch (fault) {
- case "overflow":
- case "underflow":
- case "division-by-zero":
- url += "-" + fault;
- break;
- case "negative-power":
- case "negative-width":
- url += "-unsupported";
- break;
- case "unbound-bitwise-result":
- url += "-unbound-result";
- break;
- }
- break;
- }
- case ErrorCode.CALL_EXCEPTION:
- case ErrorCode.INSUFFICIENT_FUNDS:
- case ErrorCode.MISSING_NEW:
- case ErrorCode.NONCE_EXPIRED:
- case ErrorCode.REPLACEMENT_UNDERPRICED:
- case ErrorCode.TRANSACTION_REPLACED:
- case ErrorCode.UNPREDICTABLE_GAS_LIMIT:
- url = code;
- break;
- }
- if (url) {
- message += " [ See: https:/\/links.ethers.org/v5-errors-" + url + " ]";
- }
- if (messageDetails.length) {
- message += " (" + messageDetails.join(", ") + ")";
- }
- // @TODO: Any??
- var error = new Error(message);
- error.reason = reason;
- error.code = code;
- Object.keys(params).forEach(function (key) {
- error[key] = params[key];
- });
- return error;
- };
- Logger.prototype.throwError = function (message, code, params) {
- throw this.makeError(message, code, params);
- };
- Logger.prototype.throwArgumentError = function (message, name, value) {
- return this.throwError(message, Logger.errors.INVALID_ARGUMENT, {
- argument: name,
- value: value
- });
- };
- Logger.prototype.assert = function (condition, message, code, params) {
- if (!!condition) {
- return;
- }
- this.throwError(message, code, params);
- };
- Logger.prototype.assertArgument = function (condition, message, name, value) {
- if (!!condition) {
- return;
- }
- this.throwArgumentError(message, name, value);
- };
- Logger.prototype.checkNormalize = function (message) {
- if (message == null) {
- message = "platform missing String.prototype.normalize";
- }
- if (_normalizeError) {
- this.throwError("platform missing String.prototype.normalize", Logger.errors.UNSUPPORTED_OPERATION, {
- operation: "String.prototype.normalize", form: _normalizeError
- });
- }
- };
- Logger.prototype.checkSafeUint53 = function (value, message) {
- if (typeof (value) !== "number") {
- return;
- }
- if (message == null) {
- message = "value not safe";
- }
- if (value < 0 || value >= 0x1fffffffffffff) {
- this.throwError(message, Logger.errors.NUMERIC_FAULT, {
- operation: "checkSafeInteger",
- fault: "out-of-safe-range",
- value: value
- });
- }
- if (value % 1) {
- this.throwError(message, Logger.errors.NUMERIC_FAULT, {
- operation: "checkSafeInteger",
- fault: "non-integer",
- value: value
- });
- }
- };
- Logger.prototype.checkArgumentCount = function (count, expectedCount, message) {
- if (message) {
- message = ": " + message;
- }
- else {
- message = "";
- }
- if (count < expectedCount) {
- this.throwError("missing argument" + message, Logger.errors.MISSING_ARGUMENT, {
- count: count,
- expectedCount: expectedCount
- });
- }
- if (count > expectedCount) {
- this.throwError("too many arguments" + message, Logger.errors.UNEXPECTED_ARGUMENT, {
- count: count,
- expectedCount: expectedCount
- });
- }
- };
- Logger.prototype.checkNew = function (target, kind) {
- if (target === Object || target == null) {
- this.throwError("missing new", Logger.errors.MISSING_NEW, { name: kind.name });
- }
- };
- Logger.prototype.checkAbstract = function (target, kind) {
- if (target === kind) {
- this.throwError("cannot instantiate abstract class " + JSON.stringify(kind.name) + " directly; use a sub-class", Logger.errors.UNSUPPORTED_OPERATION, { name: target.name, operation: "new" });
- }
- else if (target === Object || target == null) {
- this.throwError("missing new", Logger.errors.MISSING_NEW, { name: kind.name });
- }
- };
- Logger.globalLogger = function () {
- if (!_globalLogger) {
- _globalLogger = new Logger(_version_1.version);
- }
- return _globalLogger;
- };
- Logger.setCensorship = function (censorship, permanent) {
- if (!censorship && permanent) {
- this.globalLogger().throwError("cannot permanently disable censorship", Logger.errors.UNSUPPORTED_OPERATION, {
- operation: "setCensorship"
- });
- }
- if (_permanentCensorErrors) {
- if (!censorship) {
- return;
- }
- this.globalLogger().throwError("error censorship permanent", Logger.errors.UNSUPPORTED_OPERATION, {
- operation: "setCensorship"
- });
- }
- _censorErrors = !!censorship;
- _permanentCensorErrors = !!permanent;
- };
- Logger.setLogLevel = function (logLevel) {
- var level = LogLevels[logLevel.toLowerCase()];
- if (level == null) {
- Logger.globalLogger().warn("invalid log level - " + logLevel);
- return;
- }
- _logLevel = level;
- };
- Logger.from = function (version) {
- return new Logger(version);
- };
- Logger.errors = ErrorCode;
- Logger.levels = LogLevel;
- return Logger;
- }());
- exports.Logger = Logger;
- },{"./_version":222}],224:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.version = void 0;
- exports.version = "networks/5.6.0";
- },{}],225:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.getNetwork = void 0;
- var logger_1 = _dereq_("@ethersproject/logger");
- var _version_1 = _dereq_("./_version");
- var logger = new logger_1.Logger(_version_1.version);
- ;
- function isRenetworkable(value) {
- return (value && typeof (value.renetwork) === "function");
- }
- function ethDefaultProvider(network) {
- var func = function (providers, options) {
- if (options == null) {
- options = {};
- }
- var providerList = [];
- if (providers.InfuraProvider && options.infura !== "-") {
- try {
- providerList.push(new providers.InfuraProvider(network, options.infura));
- }
- catch (error) { }
- }
- if (providers.EtherscanProvider && options.etherscan !== "-") {
- try {
- providerList.push(new providers.EtherscanProvider(network, options.etherscan));
- }
- catch (error) { }
- }
- if (providers.AlchemyProvider && options.alchemy !== "-") {
- try {
- providerList.push(new providers.AlchemyProvider(network, options.alchemy));
- }
- catch (error) { }
- }
- if (providers.PocketProvider && options.pocket !== "-") {
- // These networks are currently faulty on Pocket as their
- // network does not handle the Berlin hardfork, which is
- // live on these ones.
- // @TODO: This goes away once Pocket has upgraded their nodes
- var skip = ["goerli", "ropsten", "rinkeby"];
- try {
- var provider = new providers.PocketProvider(network);
- if (provider.network && skip.indexOf(provider.network.name) === -1) {
- providerList.push(provider);
- }
- }
- catch (error) { }
- }
- if (providers.CloudflareProvider && options.cloudflare !== "-") {
- try {
- providerList.push(new providers.CloudflareProvider(network));
- }
- catch (error) { }
- }
- if (providerList.length === 0) {
- return null;
- }
- if (providers.FallbackProvider) {
- var quorum = 1;
- if (options.quorum != null) {
- quorum = options.quorum;
- }
- else if (network === "homestead") {
- quorum = 2;
- }
- return new providers.FallbackProvider(providerList, quorum);
- }
- return providerList[0];
- };
- func.renetwork = function (network) {
- return ethDefaultProvider(network);
- };
- return func;
- }
- function etcDefaultProvider(url, network) {
- var func = function (providers, options) {
- if (providers.JsonRpcProvider) {
- return new providers.JsonRpcProvider(url, network);
- }
- return null;
- };
- func.renetwork = function (network) {
- return etcDefaultProvider(url, network);
- };
- return func;
- }
- var homestead = {
- chainId: 1,
- ensAddress: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",
- name: "homestead",
- _defaultProvider: ethDefaultProvider("homestead")
- };
- var ropsten = {
- chainId: 3,
- ensAddress: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",
- name: "ropsten",
- _defaultProvider: ethDefaultProvider("ropsten")
- };
- var classicMordor = {
- chainId: 63,
- name: "classicMordor",
- _defaultProvider: etcDefaultProvider("https://www.ethercluster.com/mordor", "classicMordor")
- };
- // See: https://chainlist.org
- var networks = {
- unspecified: { chainId: 0, name: "unspecified" },
- homestead: homestead,
- mainnet: homestead,
- morden: { chainId: 2, name: "morden" },
- ropsten: ropsten,
- testnet: ropsten,
- rinkeby: {
- chainId: 4,
- ensAddress: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",
- name: "rinkeby",
- _defaultProvider: ethDefaultProvider("rinkeby")
- },
- kovan: {
- chainId: 42,
- name: "kovan",
- _defaultProvider: ethDefaultProvider("kovan")
- },
- goerli: {
- chainId: 5,
- ensAddress: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",
- name: "goerli",
- _defaultProvider: ethDefaultProvider("goerli")
- },
- kintsugi: { chainId: 1337702, name: "kintsugi" },
- // ETC (See: #351)
- classic: {
- chainId: 61,
- name: "classic",
- _defaultProvider: etcDefaultProvider("https:/\/www.ethercluster.com/etc", "classic")
- },
- classicMorden: { chainId: 62, name: "classicMorden" },
- classicMordor: classicMordor,
- classicTestnet: classicMordor,
- classicKotti: {
- chainId: 6,
- name: "classicKotti",
- _defaultProvider: etcDefaultProvider("https:/\/www.ethercluster.com/kotti", "classicKotti")
- },
- xdai: { chainId: 100, name: "xdai" },
- matic: { chainId: 137, name: "matic" },
- maticmum: { chainId: 80001, name: "maticmum" },
- optimism: { chainId: 10, name: "optimism" },
- "optimism-kovan": { chainId: 69, name: "optimism-kovan" },
- "optimism-goerli": { chainId: 420, name: "optimism-goerli" },
- arbitrum: { chainId: 42161, name: "arbitrum" },
- "arbitrum-rinkeby": { chainId: 421611, name: "arbitrum-rinkeby" },
- bnb: { chainId: 56, name: "bnb" },
- bnbt: { chainId: 97, name: "bnbt" },
- };
- /**
- * getNetwork
- *
- * Converts a named common networks or chain ID (network ID) to a Network
- * and verifies a network is a valid Network..
- */
- function getNetwork(network) {
- // No network (null)
- if (network == null) {
- return null;
- }
- if (typeof (network) === "number") {
- for (var name_1 in networks) {
- var standard_1 = networks[name_1];
- if (standard_1.chainId === network) {
- return {
- name: standard_1.name,
- chainId: standard_1.chainId,
- ensAddress: (standard_1.ensAddress || null),
- _defaultProvider: (standard_1._defaultProvider || null)
- };
- }
- }
- return {
- chainId: network,
- name: "unknown"
- };
- }
- if (typeof (network) === "string") {
- var standard_2 = networks[network];
- if (standard_2 == null) {
- return null;
- }
- return {
- name: standard_2.name,
- chainId: standard_2.chainId,
- ensAddress: standard_2.ensAddress,
- _defaultProvider: (standard_2._defaultProvider || null)
- };
- }
- var standard = networks[network.name];
- // Not a standard network; check that it is a valid network in general
- if (!standard) {
- if (typeof (network.chainId) !== "number") {
- logger.throwArgumentError("invalid network chainId", "network", network);
- }
- return network;
- }
- // Make sure the chainId matches the expected network chainId (or is 0; disable EIP-155)
- if (network.chainId !== 0 && network.chainId !== standard.chainId) {
- logger.throwArgumentError("network chainId mismatch", "network", network);
- }
- // @TODO: In the next major version add an attach function to a defaultProvider
- // class and move the _defaultProvider internal to this file (extend Network)
- var defaultProvider = network._defaultProvider || null;
- if (defaultProvider == null && standard._defaultProvider) {
- if (isRenetworkable(standard._defaultProvider)) {
- defaultProvider = standard._defaultProvider.renetwork(network);
- }
- else {
- defaultProvider = standard._defaultProvider;
- }
- }
- // Standard Network (allow overriding the ENS address)
- return {
- name: network.name,
- chainId: standard.chainId,
- ensAddress: (network.ensAddress || standard.ensAddress || null),
- _defaultProvider: defaultProvider
- };
- }
- exports.getNetwork = getNetwork;
- },{"./_version":224,"@ethersproject/logger":223}],226:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.pbkdf2 = void 0;
- var bytes_1 = _dereq_("@ethersproject/bytes");
- var sha2_1 = _dereq_("@ethersproject/sha2");
- function pbkdf2(password, salt, iterations, keylen, hashAlgorithm) {
- password = (0, bytes_1.arrayify)(password);
- salt = (0, bytes_1.arrayify)(salt);
- var hLen;
- var l = 1;
- var DK = new Uint8Array(keylen);
- var block1 = new Uint8Array(salt.length + 4);
- block1.set(salt);
- //salt.copy(block1, 0, 0, salt.length)
- var r;
- var T;
- for (var i = 1; i <= l; i++) {
- //block1.writeUInt32BE(i, salt.length)
- block1[salt.length] = (i >> 24) & 0xff;
- block1[salt.length + 1] = (i >> 16) & 0xff;
- block1[salt.length + 2] = (i >> 8) & 0xff;
- block1[salt.length + 3] = i & 0xff;
- //let U = createHmac(password).update(block1).digest();
- var U = (0, bytes_1.arrayify)((0, sha2_1.computeHmac)(hashAlgorithm, password, block1));
- if (!hLen) {
- hLen = U.length;
- T = new Uint8Array(hLen);
- l = Math.ceil(keylen / hLen);
- r = keylen - (l - 1) * hLen;
- }
- //U.copy(T, 0, 0, hLen)
- T.set(U);
- for (var j = 1; j < iterations; j++) {
- //U = createHmac(password).update(U).digest();
- U = (0, bytes_1.arrayify)((0, sha2_1.computeHmac)(hashAlgorithm, password, U));
- for (var k = 0; k < hLen; k++)
- T[k] ^= U[k];
- }
- var destPos = (i - 1) * hLen;
- var len = (i === l ? r : hLen);
- //T.copy(DK, destPos, 0, len)
- DK.set((0, bytes_1.arrayify)(T).slice(0, len), destPos);
- }
- return (0, bytes_1.hexlify)(DK);
- }
- exports.pbkdf2 = pbkdf2;
- },{"@ethersproject/bytes":199,"@ethersproject/sha2":256}],227:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.pbkdf2 = void 0;
- var pbkdf2_1 = _dereq_("./pbkdf2");
- Object.defineProperty(exports, "pbkdf2", { enumerable: true, get: function () { return pbkdf2_1.pbkdf2; } });
- },{"./pbkdf2":226}],228:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.version = void 0;
- exports.version = "properties/5.6.0";
- },{}],229:[function(_dereq_,module,exports){
- "use strict";
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
- return new (P || (P = Promise))(function (resolve, reject) {
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
- step((generator = generator.apply(thisArg, _arguments || [])).next());
- });
- };
- var __generator = (this && this.__generator) || function (thisArg, body) {
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
- function verb(n) { return function (v) { return step([n, v]); }; }
- function step(op) {
- if (f) throw new TypeError("Generator is already executing.");
- while (_) try {
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
- if (y = 0, t) op = [op[0] & 2, t.value];
- switch (op[0]) {
- case 0: case 1: t = op; break;
- case 4: _.label++; return { value: op[1], done: false };
- case 5: _.label++; y = op[1]; op = [0]; continue;
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
- default:
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
- if (t[2]) _.ops.pop();
- _.trys.pop(); continue;
- }
- op = body.call(thisArg, _);
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
- }
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.Description = exports.deepCopy = exports.shallowCopy = exports.checkProperties = exports.resolveProperties = exports.getStatic = exports.defineReadOnly = void 0;
- var logger_1 = _dereq_("@ethersproject/logger");
- var _version_1 = _dereq_("./_version");
- var logger = new logger_1.Logger(_version_1.version);
- function defineReadOnly(object, name, value) {
- Object.defineProperty(object, name, {
- enumerable: true,
- value: value,
- writable: false,
- });
- }
- exports.defineReadOnly = defineReadOnly;
- // Crawl up the constructor chain to find a static method
- function getStatic(ctor, key) {
- for (var i = 0; i < 32; i++) {
- if (ctor[key]) {
- return ctor[key];
- }
- if (!ctor.prototype || typeof (ctor.prototype) !== "object") {
- break;
- }
- ctor = Object.getPrototypeOf(ctor.prototype).constructor;
- }
- return null;
- }
- exports.getStatic = getStatic;
- function resolveProperties(object) {
- return __awaiter(this, void 0, void 0, function () {
- var promises, results;
- return __generator(this, function (_a) {
- switch (_a.label) {
- case 0:
- promises = Object.keys(object).map(function (key) {
- var value = object[key];
- return Promise.resolve(value).then(function (v) { return ({ key: key, value: v }); });
- });
- return [4 /*yield*/, Promise.all(promises)];
- case 1:
- results = _a.sent();
- return [2 /*return*/, results.reduce(function (accum, result) {
- accum[(result.key)] = result.value;
- return accum;
- }, {})];
- }
- });
- });
- }
- exports.resolveProperties = resolveProperties;
- function checkProperties(object, properties) {
- if (!object || typeof (object) !== "object") {
- logger.throwArgumentError("invalid object", "object", object);
- }
- Object.keys(object).forEach(function (key) {
- if (!properties[key]) {
- logger.throwArgumentError("invalid object key - " + key, "transaction:" + key, object);
- }
- });
- }
- exports.checkProperties = checkProperties;
- function shallowCopy(object) {
- var result = {};
- for (var key in object) {
- result[key] = object[key];
- }
- return result;
- }
- exports.shallowCopy = shallowCopy;
- var opaque = { bigint: true, boolean: true, "function": true, number: true, string: true };
- function _isFrozen(object) {
- // Opaque objects are not mutable, so safe to copy by assignment
- if (object === undefined || object === null || opaque[typeof (object)]) {
- return true;
- }
- if (Array.isArray(object) || typeof (object) === "object") {
- if (!Object.isFrozen(object)) {
- return false;
- }
- var keys = Object.keys(object);
- for (var i = 0; i < keys.length; i++) {
- var value = null;
- try {
- value = object[keys[i]];
- }
- catch (error) {
- // If accessing a value triggers an error, it is a getter
- // designed to do so (e.g. Result) and is therefore "frozen"
- continue;
- }
- if (!_isFrozen(value)) {
- return false;
- }
- }
- return true;
- }
- return logger.throwArgumentError("Cannot deepCopy " + typeof (object), "object", object);
- }
- // Returns a new copy of object, such that no properties may be replaced.
- // New properties may be added only to objects.
- function _deepCopy(object) {
- if (_isFrozen(object)) {
- return object;
- }
- // Arrays are mutable, so we need to create a copy
- if (Array.isArray(object)) {
- return Object.freeze(object.map(function (item) { return deepCopy(item); }));
- }
- if (typeof (object) === "object") {
- var result = {};
- for (var key in object) {
- var value = object[key];
- if (value === undefined) {
- continue;
- }
- defineReadOnly(result, key, deepCopy(value));
- }
- return result;
- }
- return logger.throwArgumentError("Cannot deepCopy " + typeof (object), "object", object);
- }
- function deepCopy(object) {
- return _deepCopy(object);
- }
- exports.deepCopy = deepCopy;
- var Description = /** @class */ (function () {
- function Description(info) {
- for (var key in info) {
- this[key] = deepCopy(info[key]);
- }
- }
- return Description;
- }());
- exports.Description = Description;
- },{"./_version":228,"@ethersproject/logger":223}],230:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.version = void 0;
- exports.version = "providers/5.6.0";
- },{}],231:[function(_dereq_,module,exports){
- "use strict";
- var __extends = (this && this.__extends) || (function () {
- var extendStatics = function (d, b) {
- extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
- return extendStatics(d, b);
- };
- return function (d, b) {
- if (typeof b !== "function" && b !== null)
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.AlchemyProvider = exports.AlchemyWebSocketProvider = void 0;
- var properties_1 = _dereq_("@ethersproject/properties");
- var formatter_1 = _dereq_("./formatter");
- var websocket_provider_1 = _dereq_("./websocket-provider");
- var logger_1 = _dereq_("@ethersproject/logger");
- var _version_1 = _dereq_("./_version");
- var logger = new logger_1.Logger(_version_1.version);
- var url_json_rpc_provider_1 = _dereq_("./url-json-rpc-provider");
- // This key was provided to ethers.js by Alchemy to be used by the
- // default provider, but it is recommended that for your own
- // production environments, that you acquire your own API key at:
- // https://dashboard.alchemyapi.io
- var defaultApiKey = "_gg7wSSi0KMBsdKnGVfHDueq6xMB9EkC";
- var AlchemyWebSocketProvider = /** @class */ (function (_super) {
- __extends(AlchemyWebSocketProvider, _super);
- function AlchemyWebSocketProvider(network, apiKey) {
- var _this = this;
- var provider = new AlchemyProvider(network, apiKey);
- var url = provider.connection.url.replace(/^http/i, "ws")
- .replace(".alchemyapi.", ".ws.alchemyapi.");
- _this = _super.call(this, url, provider.network) || this;
- (0, properties_1.defineReadOnly)(_this, "apiKey", provider.apiKey);
- return _this;
- }
- AlchemyWebSocketProvider.prototype.isCommunityResource = function () {
- return (this.apiKey === defaultApiKey);
- };
- return AlchemyWebSocketProvider;
- }(websocket_provider_1.WebSocketProvider));
- exports.AlchemyWebSocketProvider = AlchemyWebSocketProvider;
- var AlchemyProvider = /** @class */ (function (_super) {
- __extends(AlchemyProvider, _super);
- function AlchemyProvider() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- AlchemyProvider.getWebSocketProvider = function (network, apiKey) {
- return new AlchemyWebSocketProvider(network, apiKey);
- };
- AlchemyProvider.getApiKey = function (apiKey) {
- if (apiKey == null) {
- return defaultApiKey;
- }
- if (apiKey && typeof (apiKey) !== "string") {
- logger.throwArgumentError("invalid apiKey", "apiKey", apiKey);
- }
- return apiKey;
- };
- AlchemyProvider.getUrl = function (network, apiKey) {
- var host = null;
- switch (network.name) {
- case "homestead":
- host = "eth-mainnet.alchemyapi.io/v2/";
- break;
- case "ropsten":
- host = "eth-ropsten.alchemyapi.io/v2/";
- break;
- case "rinkeby":
- host = "eth-rinkeby.alchemyapi.io/v2/";
- break;
- case "goerli":
- host = "eth-goerli.alchemyapi.io/v2/";
- break;
- case "kovan":
- host = "eth-kovan.alchemyapi.io/v2/";
- break;
- case "matic":
- host = "polygon-mainnet.g.alchemy.com/v2/";
- break;
- case "maticmum":
- host = "polygon-mumbai.g.alchemy.com/v2/";
- break;
- case "arbitrum":
- host = "arb-mainnet.g.alchemy.com/v2/";
- break;
- case "arbitrum-rinkeby":
- host = "arb-rinkeby.g.alchemy.com/v2/";
- break;
- case "optimism":
- host = "opt-mainnet.g.alchemy.com/v2/";
- break;
- case "optimism-kovan":
- host = "opt-kovan.g.alchemy.com/v2/";
- break;
- default:
- logger.throwArgumentError("unsupported network", "network", arguments[0]);
- }
- return {
- allowGzip: true,
- url: ("https:/" + "/" + host + apiKey),
- throttleCallback: function (attempt, url) {
- if (apiKey === defaultApiKey) {
- (0, formatter_1.showThrottleMessage)();
- }
- return Promise.resolve(true);
- }
- };
- };
- AlchemyProvider.prototype.isCommunityResource = function () {
- return (this.apiKey === defaultApiKey);
- };
- return AlchemyProvider;
- }(url_json_rpc_provider_1.UrlJsonRpcProvider));
- exports.AlchemyProvider = AlchemyProvider;
- },{"./_version":230,"./formatter":238,"./url-json-rpc-provider":245,"./websocket-provider":247,"@ethersproject/logger":223,"@ethersproject/properties":229}],232:[function(_dereq_,module,exports){
- "use strict";
- var __extends = (this && this.__extends) || (function () {
- var extendStatics = function (d, b) {
- extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
- return extendStatics(d, b);
- };
- return function (d, b) {
- if (typeof b !== "function" && b !== null)
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
- return new (P || (P = Promise))(function (resolve, reject) {
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
- step((generator = generator.apply(thisArg, _arguments || [])).next());
- });
- };
- var __generator = (this && this.__generator) || function (thisArg, body) {
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
- function verb(n) { return function (v) { return step([n, v]); }; }
- function step(op) {
- if (f) throw new TypeError("Generator is already executing.");
- while (_) try {
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
- if (y = 0, t) op = [op[0] & 2, t.value];
- switch (op[0]) {
- case 0: case 1: t = op; break;
- case 4: _.label++; return { value: op[1], done: false };
- case 5: _.label++; y = op[1]; op = [0]; continue;
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
- default:
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
- if (t[2]) _.ops.pop();
- _.trys.pop(); continue;
- }
- op = body.call(thisArg, _);
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
- }
- };
- var __importDefault = (this && this.__importDefault) || function (mod) {
- return (mod && mod.__esModule) ? mod : { "default": mod };
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.BaseProvider = exports.Resolver = exports.Event = void 0;
- var abstract_provider_1 = _dereq_("@ethersproject/abstract-provider");
- var basex_1 = _dereq_("@ethersproject/basex");
- var bignumber_1 = _dereq_("@ethersproject/bignumber");
- var bytes_1 = _dereq_("@ethersproject/bytes");
- var constants_1 = _dereq_("@ethersproject/constants");
- var hash_1 = _dereq_("@ethersproject/hash");
- var networks_1 = _dereq_("@ethersproject/networks");
- var properties_1 = _dereq_("@ethersproject/properties");
- var sha2_1 = _dereq_("@ethersproject/sha2");
- var strings_1 = _dereq_("@ethersproject/strings");
- var web_1 = _dereq_("@ethersproject/web");
- var bech32_1 = __importDefault(_dereq_("bech32"));
- var logger_1 = _dereq_("@ethersproject/logger");
- var _version_1 = _dereq_("./_version");
- var logger = new logger_1.Logger(_version_1.version);
- var formatter_1 = _dereq_("./formatter");
- var MAX_CCIP_REDIRECTS = 10;
- //////////////////////////////
- // Event Serializeing
- function checkTopic(topic) {
- if (topic == null) {
- return "null";
- }
- if ((0, bytes_1.hexDataLength)(topic) !== 32) {
- logger.throwArgumentError("invalid topic", "topic", topic);
- }
- return topic.toLowerCase();
- }
- function serializeTopics(topics) {
- // Remove trailing null AND-topics; they are redundant
- topics = topics.slice();
- while (topics.length > 0 && topics[topics.length - 1] == null) {
- topics.pop();
- }
- return topics.map(function (topic) {
- if (Array.isArray(topic)) {
- // Only track unique OR-topics
- var unique_1 = {};
- topic.forEach(function (topic) {
- unique_1[checkTopic(topic)] = true;
- });
- // The order of OR-topics does not matter
- var sorted = Object.keys(unique_1);
- sorted.sort();
- return sorted.join("|");
- }
- else {
- return checkTopic(topic);
- }
- }).join("&");
- }
- function deserializeTopics(data) {
- if (data === "") {
- return [];
- }
- return data.split(/&/g).map(function (topic) {
- if (topic === "") {
- return [];
- }
- var comps = topic.split("|").map(function (topic) {
- return ((topic === "null") ? null : topic);
- });
- return ((comps.length === 1) ? comps[0] : comps);
- });
- }
- function getEventTag(eventName) {
- if (typeof (eventName) === "string") {
- eventName = eventName.toLowerCase();
- if ((0, bytes_1.hexDataLength)(eventName) === 32) {
- return "tx:" + eventName;
- }
- if (eventName.indexOf(":") === -1) {
- return eventName;
- }
- }
- else if (Array.isArray(eventName)) {
- return "filter:*:" + serializeTopics(eventName);
- }
- else if (abstract_provider_1.ForkEvent.isForkEvent(eventName)) {
- logger.warn("not implemented");
- throw new Error("not implemented");
- }
- else if (eventName && typeof (eventName) === "object") {
- return "filter:" + (eventName.address || "*") + ":" + serializeTopics(eventName.topics || []);
- }
- throw new Error("invalid event - " + eventName);
- }
- //////////////////////////////
- // Helper Object
- function getTime() {
- return (new Date()).getTime();
- }
- function stall(duration) {
- return new Promise(function (resolve) {
- setTimeout(resolve, duration);
- });
- }
- //////////////////////////////
- // Provider Object
- /**
- * EventType
- * - "block"
- * - "poll"
- * - "didPoll"
- * - "pending"
- * - "error"
- * - "network"
- * - filter
- * - topics array
- * - transaction hash
- */
- var PollableEvents = ["block", "network", "pending", "poll"];
- var Event = /** @class */ (function () {
- function Event(tag, listener, once) {
- (0, properties_1.defineReadOnly)(this, "tag", tag);
- (0, properties_1.defineReadOnly)(this, "listener", listener);
- (0, properties_1.defineReadOnly)(this, "once", once);
- this._lastBlockNumber = -2;
- this._inflight = false;
- }
- Object.defineProperty(Event.prototype, "event", {
- get: function () {
- switch (this.type) {
- case "tx":
- return this.hash;
- case "filter":
- return this.filter;
- }
- return this.tag;
- },
- enumerable: false,
- configurable: true
- });
- Object.defineProperty(Event.prototype, "type", {
- get: function () {
- return this.tag.split(":")[0];
- },
- enumerable: false,
- configurable: true
- });
- Object.defineProperty(Event.prototype, "hash", {
- get: function () {
- var comps = this.tag.split(":");
- if (comps[0] !== "tx") {
- return null;
- }
- return comps[1];
- },
- enumerable: false,
- configurable: true
- });
- Object.defineProperty(Event.prototype, "filter", {
- get: function () {
- var comps = this.tag.split(":");
- if (comps[0] !== "filter") {
- return null;
- }
- var address = comps[1];
- var topics = deserializeTopics(comps[2]);
- var filter = {};
- if (topics.length > 0) {
- filter.topics = topics;
- }
- if (address && address !== "*") {
- filter.address = address;
- }
- return filter;
- },
- enumerable: false,
- configurable: true
- });
- Event.prototype.pollable = function () {
- return (this.tag.indexOf(":") >= 0 || PollableEvents.indexOf(this.tag) >= 0);
- };
- return Event;
- }());
- exports.Event = Event;
- ;
- // https://github.com/satoshilabs/slips/blob/master/slip-0044.md
- var coinInfos = {
- "0": { symbol: "btc", p2pkh: 0x00, p2sh: 0x05, prefix: "bc" },
- "2": { symbol: "ltc", p2pkh: 0x30, p2sh: 0x32, prefix: "ltc" },
- "3": { symbol: "doge", p2pkh: 0x1e, p2sh: 0x16 },
- "60": { symbol: "eth", ilk: "eth" },
- "61": { symbol: "etc", ilk: "eth" },
- "700": { symbol: "xdai", ilk: "eth" },
- };
- function bytes32ify(value) {
- return (0, bytes_1.hexZeroPad)(bignumber_1.BigNumber.from(value).toHexString(), 32);
- }
- // Compute the Base58Check encoded data (checksum is first 4 bytes of sha256d)
- function base58Encode(data) {
- return basex_1.Base58.encode((0, bytes_1.concat)([data, (0, bytes_1.hexDataSlice)((0, sha2_1.sha256)((0, sha2_1.sha256)(data)), 0, 4)]));
- }
- var matcherIpfs = new RegExp("^(ipfs):/\/(.*)$", "i");
- var matchers = [
- new RegExp("^(https):/\/(.*)$", "i"),
- new RegExp("^(data):(.*)$", "i"),
- matcherIpfs,
- new RegExp("^eip155:[0-9]+/(erc[0-9]+):(.*)$", "i"),
- ];
- function _parseString(result, start) {
- try {
- return (0, strings_1.toUtf8String)(_parseBytes(result, start));
- }
- catch (error) { }
- return null;
- }
- function _parseBytes(result, start) {
- if (result === "0x") {
- return null;
- }
- var offset = bignumber_1.BigNumber.from((0, bytes_1.hexDataSlice)(result, start, start + 32)).toNumber();
- var length = bignumber_1.BigNumber.from((0, bytes_1.hexDataSlice)(result, offset, offset + 32)).toNumber();
- return (0, bytes_1.hexDataSlice)(result, offset + 32, offset + 32 + length);
- }
- // Trim off the ipfs:// prefix and return the default gateway URL
- function getIpfsLink(link) {
- if (link.match(/^ipfs:\/\/ipfs\//i)) {
- link = link.substring(12);
- }
- else if (link.match(/^ipfs:\/\//i)) {
- link = link.substring(7);
- }
- else {
- logger.throwArgumentError("unsupported IPFS format", "link", link);
- }
- return "https://gateway.ipfs.io/ipfs/" + link;
- }
- function numPad(value) {
- var result = (0, bytes_1.arrayify)(value);
- if (result.length > 32) {
- throw new Error("internal; should not happen");
- }
- var padded = new Uint8Array(32);
- padded.set(result, 32 - result.length);
- return padded;
- }
- function bytesPad(value) {
- if ((value.length % 32) === 0) {
- return value;
- }
- var result = new Uint8Array(Math.ceil(value.length / 32) * 32);
- result.set(value);
- return result;
- }
- // ABI Encodes a series of (bytes, bytes, ...)
- function encodeBytes(datas) {
- var result = [];
- var byteCount = 0;
- // Add place-holders for pointers as we add items
- for (var i = 0; i < datas.length; i++) {
- result.push(null);
- byteCount += 32;
- }
- for (var i = 0; i < datas.length; i++) {
- var data = (0, bytes_1.arrayify)(datas[i]);
- // Update the bytes offset
- result[i] = numPad(byteCount);
- // The length and padded value of data
- result.push(numPad(data.length));
- result.push(bytesPad(data));
- byteCount += 32 + Math.ceil(data.length / 32) * 32;
- }
- return (0, bytes_1.hexConcat)(result);
- }
- var Resolver = /** @class */ (function () {
- // The resolvedAddress is only for creating a ReverseLookup resolver
- function Resolver(provider, address, name, resolvedAddress) {
- (0, properties_1.defineReadOnly)(this, "provider", provider);
- (0, properties_1.defineReadOnly)(this, "name", name);
- (0, properties_1.defineReadOnly)(this, "address", provider.formatter.address(address));
- (0, properties_1.defineReadOnly)(this, "_resolvedAddress", resolvedAddress);
- }
- Resolver.prototype.supportsWildcard = function () {
- var _this = this;
- if (!this._supportsEip2544) {
- // supportsInterface(bytes4 = selector("resolve(bytes,bytes)"))
- this._supportsEip2544 = this.provider.call({
- to: this.address,
- data: "0x01ffc9a79061b92300000000000000000000000000000000000000000000000000000000"
- }).then(function (result) {
- return bignumber_1.BigNumber.from(result).eq(1);
- }).catch(function (error) {
- if (error.code === logger_1.Logger.errors.CALL_EXCEPTION) {
- return false;
- }
- // Rethrow the error: link is down, etc. Let future attempts retry.
- _this._supportsEip2544 = null;
- throw error;
- });
- }
- return this._supportsEip2544;
- };
- Resolver.prototype._fetch = function (selector, parameters) {
- return __awaiter(this, void 0, void 0, function () {
- var tx, parseBytes, result, error_1;
- return __generator(this, function (_a) {
- switch (_a.label) {
- case 0:
- tx = {
- to: this.address,
- ccipReadEnabled: true,
- data: (0, bytes_1.hexConcat)([selector, (0, hash_1.namehash)(this.name), (parameters || "0x")])
- };
- parseBytes = false;
- return [4 /*yield*/, this.supportsWildcard()];
- case 1:
- if (_a.sent()) {
- parseBytes = true;
- // selector("resolve(bytes,bytes)")
- tx.data = (0, bytes_1.hexConcat)(["0x9061b923", encodeBytes([(0, hash_1.dnsEncode)(this.name), tx.data])]);
- }
- _a.label = 2;
- case 2:
- _a.trys.push([2, 4, , 5]);
- return [4 /*yield*/, this.provider.call(tx)];
- case 3:
- result = _a.sent();
- if (((0, bytes_1.arrayify)(result).length % 32) === 4) {
- logger.throwError("resolver threw error", logger_1.Logger.errors.CALL_EXCEPTION, {
- transaction: tx, data: result
- });
- }
- if (parseBytes) {
- result = _parseBytes(result, 0);
- }
- return [2 /*return*/, result];
- case 4:
- error_1 = _a.sent();
- if (error_1.code === logger_1.Logger.errors.CALL_EXCEPTION) {
- return [2 /*return*/, null];
- }
- throw error_1;
- case 5: return [2 /*return*/];
- }
- });
- });
- };
- Resolver.prototype._fetchBytes = function (selector, parameters) {
- return __awaiter(this, void 0, void 0, function () {
- var result;
- return __generator(this, function (_a) {
- switch (_a.label) {
- case 0: return [4 /*yield*/, this._fetch(selector, parameters)];
- case 1:
- result = _a.sent();
- if (result != null) {
- return [2 /*return*/, _parseBytes(result, 0)];
- }
- return [2 /*return*/, null];
- }
- });
- });
- };
- Resolver.prototype._getAddress = function (coinType, hexBytes) {
- var coinInfo = coinInfos[String(coinType)];
- if (coinInfo == null) {
- logger.throwError("unsupported coin type: " + coinType, logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
- operation: "getAddress(" + coinType + ")"
- });
- }
- if (coinInfo.ilk === "eth") {
- return this.provider.formatter.address(hexBytes);
- }
- var bytes = (0, bytes_1.arrayify)(hexBytes);
- // P2PKH: OP_DUP OP_HASH160 <pubKeyHash> OP_EQUALVERIFY OP_CHECKSIG
- if (coinInfo.p2pkh != null) {
- var p2pkh = hexBytes.match(/^0x76a9([0-9a-f][0-9a-f])([0-9a-f]*)88ac$/);
- if (p2pkh) {
- var length_1 = parseInt(p2pkh[1], 16);
- if (p2pkh[2].length === length_1 * 2 && length_1 >= 1 && length_1 <= 75) {
- return base58Encode((0, bytes_1.concat)([[coinInfo.p2pkh], ("0x" + p2pkh[2])]));
- }
- }
- }
- // P2SH: OP_HASH160 <scriptHash> OP_EQUAL
- if (coinInfo.p2sh != null) {
- var p2sh = hexBytes.match(/^0xa9([0-9a-f][0-9a-f])([0-9a-f]*)87$/);
- if (p2sh) {
- var length_2 = parseInt(p2sh[1], 16);
- if (p2sh[2].length === length_2 * 2 && length_2 >= 1 && length_2 <= 75) {
- return base58Encode((0, bytes_1.concat)([[coinInfo.p2sh], ("0x" + p2sh[2])]));
- }
- }
- }
- // Bech32
- if (coinInfo.prefix != null) {
- var length_3 = bytes[1];
- // https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki#witness-program
- var version_1 = bytes[0];
- if (version_1 === 0x00) {
- if (length_3 !== 20 && length_3 !== 32) {
- version_1 = -1;
- }
- }
- else {
- version_1 = -1;
- }
- if (version_1 >= 0 && bytes.length === 2 + length_3 && length_3 >= 1 && length_3 <= 75) {
- var words = bech32_1.default.toWords(bytes.slice(2));
- words.unshift(version_1);
- return bech32_1.default.encode(coinInfo.prefix, words);
- }
- }
- return null;
- };
- Resolver.prototype.getAddress = function (coinType) {
- return __awaiter(this, void 0, void 0, function () {
- var result, error_2, hexBytes, address;
- return __generator(this, function (_a) {
- switch (_a.label) {
- case 0:
- if (coinType == null) {
- coinType = 60;
- }
- if (!(coinType === 60)) return [3 /*break*/, 4];
- _a.label = 1;
- case 1:
- _a.trys.push([1, 3, , 4]);
- return [4 /*yield*/, this._fetch("0x3b3b57de")];
- case 2:
- result = _a.sent();
- // No address
- if (result === "0x" || result === constants_1.HashZero) {
- return [2 /*return*/, null];
- }
- return [2 /*return*/, this.provider.formatter.callAddress(result)];
- case 3:
- error_2 = _a.sent();
- if (error_2.code === logger_1.Logger.errors.CALL_EXCEPTION) {
- return [2 /*return*/, null];
- }
- throw error_2;
- case 4: return [4 /*yield*/, this._fetchBytes("0xf1cb7e06", bytes32ify(coinType))];
- case 5:
- hexBytes = _a.sent();
- // No address
- if (hexBytes == null || hexBytes === "0x") {
- return [2 /*return*/, null];
- }
- address = this._getAddress(coinType, hexBytes);
- if (address == null) {
- logger.throwError("invalid or unsupported coin data", logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
- operation: "getAddress(" + coinType + ")",
- coinType: coinType,
- data: hexBytes
- });
- }
- return [2 /*return*/, address];
- }
- });
- });
- };
- Resolver.prototype.getAvatar = function () {
- return __awaiter(this, void 0, void 0, function () {
- var linkage, avatar, i, match, scheme, _a, selector, owner, _b, comps, addr, tokenId, tokenOwner, _c, _d, balance, _e, _f, tx, metadataUrl, _g, metadata, imageUrl, ipfs, error_3;
- return __generator(this, function (_h) {
- switch (_h.label) {
- case 0:
- linkage = [{ type: "name", content: this.name }];
- _h.label = 1;
- case 1:
- _h.trys.push([1, 19, , 20]);
- return [4 /*yield*/, this.getText("avatar")];
- case 2:
- avatar = _h.sent();
- if (avatar == null) {
- return [2 /*return*/, null];
- }
- i = 0;
- _h.label = 3;
- case 3:
- if (!(i < matchers.length)) return [3 /*break*/, 18];
- match = avatar.match(matchers[i]);
- if (match == null) {
- return [3 /*break*/, 17];
- }
- scheme = match[1].toLowerCase();
- _a = scheme;
- switch (_a) {
- case "https": return [3 /*break*/, 4];
- case "data": return [3 /*break*/, 5];
- case "ipfs": return [3 /*break*/, 6];
- case "erc721": return [3 /*break*/, 7];
- case "erc1155": return [3 /*break*/, 7];
- }
- return [3 /*break*/, 17];
- case 4:
- linkage.push({ type: "url", content: avatar });
- return [2 /*return*/, { linkage: linkage, url: avatar }];
- case 5:
- linkage.push({ type: "data", content: avatar });
- return [2 /*return*/, { linkage: linkage, url: avatar }];
- case 6:
- linkage.push({ type: "ipfs", content: avatar });
- return [2 /*return*/, { linkage: linkage, url: getIpfsLink(avatar) }];
- case 7:
- selector = (scheme === "erc721") ? "0xc87b56dd" : "0x0e89341c";
- linkage.push({ type: scheme, content: avatar });
- _b = this._resolvedAddress;
- if (_b) return [3 /*break*/, 9];
- return [4 /*yield*/, this.getAddress()];
- case 8:
- _b = (_h.sent());
- _h.label = 9;
- case 9:
- owner = (_b);
- comps = (match[2] || "").split("/");
- if (comps.length !== 2) {
- return [2 /*return*/, null];
- }
- return [4 /*yield*/, this.provider.formatter.address(comps[0])];
- case 10:
- addr = _h.sent();
- tokenId = (0, bytes_1.hexZeroPad)(bignumber_1.BigNumber.from(comps[1]).toHexString(), 32);
- if (!(scheme === "erc721")) return [3 /*break*/, 12];
- _d = (_c = this.provider.formatter).callAddress;
- return [4 /*yield*/, this.provider.call({
- to: addr, data: (0, bytes_1.hexConcat)(["0x6352211e", tokenId])
- })];
- case 11:
- tokenOwner = _d.apply(_c, [_h.sent()]);
- if (owner !== tokenOwner) {
- return [2 /*return*/, null];
- }
- linkage.push({ type: "owner", content: tokenOwner });
- return [3 /*break*/, 14];
- case 12:
- if (!(scheme === "erc1155")) return [3 /*break*/, 14];
- _f = (_e = bignumber_1.BigNumber).from;
- return [4 /*yield*/, this.provider.call({
- to: addr, data: (0, bytes_1.hexConcat)(["0x00fdd58e", (0, bytes_1.hexZeroPad)(owner, 32), tokenId])
- })];
- case 13:
- balance = _f.apply(_e, [_h.sent()]);
- if (balance.isZero()) {
- return [2 /*return*/, null];
- }
- linkage.push({ type: "balance", content: balance.toString() });
- _h.label = 14;
- case 14:
- tx = {
- to: this.provider.formatter.address(comps[0]),
- data: (0, bytes_1.hexConcat)([selector, tokenId])
- };
- _g = _parseString;
- return [4 /*yield*/, this.provider.call(tx)];
- case 15:
- metadataUrl = _g.apply(void 0, [_h.sent(), 0]);
- if (metadataUrl == null) {
- return [2 /*return*/, null];
- }
- linkage.push({ type: "metadata-url-base", content: metadataUrl });
- // ERC-1155 allows a generic {id} in the URL
- if (scheme === "erc1155") {
- metadataUrl = metadataUrl.replace("{id}", tokenId.substring(2));
- linkage.push({ type: "metadata-url-expanded", content: metadataUrl });
- }
- // Transform IPFS metadata links
- if (metadataUrl.match(/^ipfs:/i)) {
- metadataUrl = getIpfsLink(metadataUrl);
- }
- linkage.push({ type: "metadata-url", content: metadataUrl });
- return [4 /*yield*/, (0, web_1.fetchJson)(metadataUrl)];
- case 16:
- metadata = _h.sent();
- if (!metadata) {
- return [2 /*return*/, null];
- }
- linkage.push({ type: "metadata", content: JSON.stringify(metadata) });
- imageUrl = metadata.image;
- if (typeof (imageUrl) !== "string") {
- return [2 /*return*/, null];
- }
- if (imageUrl.match(/^(https:\/\/|data:)/i)) {
- // Allow
- }
- else {
- ipfs = imageUrl.match(matcherIpfs);
- if (ipfs == null) {
- return [2 /*return*/, null];
- }
- linkage.push({ type: "url-ipfs", content: imageUrl });
- imageUrl = getIpfsLink(imageUrl);
- }
- linkage.push({ type: "url", content: imageUrl });
- return [2 /*return*/, { linkage: linkage, url: imageUrl }];
- case 17:
- i++;
- return [3 /*break*/, 3];
- case 18: return [3 /*break*/, 20];
- case 19:
- error_3 = _h.sent();
- return [3 /*break*/, 20];
- case 20: return [2 /*return*/, null];
- }
- });
- });
- };
- Resolver.prototype.getContentHash = function () {
- return __awaiter(this, void 0, void 0, function () {
- var hexBytes, ipfs, length_4, swarm;
- return __generator(this, function (_a) {
- switch (_a.label) {
- case 0: return [4 /*yield*/, this._fetchBytes("0xbc1c58d1")];
- case 1:
- hexBytes = _a.sent();
- // No contenthash
- if (hexBytes == null || hexBytes === "0x") {
- return [2 /*return*/, null];
- }
- ipfs = hexBytes.match(/^0xe3010170(([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f]*))$/);
- if (ipfs) {
- length_4 = parseInt(ipfs[3], 16);
- if (ipfs[4].length === length_4 * 2) {
- return [2 /*return*/, "ipfs:/\/" + basex_1.Base58.encode("0x" + ipfs[1])];
- }
- }
- swarm = hexBytes.match(/^0xe40101fa011b20([0-9a-f]*)$/);
- if (swarm) {
- if (swarm[1].length === (32 * 2)) {
- return [2 /*return*/, "bzz:/\/" + swarm[1]];
- }
- }
- return [2 /*return*/, logger.throwError("invalid or unsupported content hash data", logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
- operation: "getContentHash()",
- data: hexBytes
- })];
- }
- });
- });
- };
- Resolver.prototype.getText = function (key) {
- return __awaiter(this, void 0, void 0, function () {
- var keyBytes, hexBytes;
- return __generator(this, function (_a) {
- switch (_a.label) {
- case 0:
- keyBytes = (0, strings_1.toUtf8Bytes)(key);
- // The nodehash consumes the first slot, so the string pointer targets
- // offset 64, with the length at offset 64 and data starting at offset 96
- keyBytes = (0, bytes_1.concat)([bytes32ify(64), bytes32ify(keyBytes.length), keyBytes]);
- // Pad to word-size (32 bytes)
- if ((keyBytes.length % 32) !== 0) {
- keyBytes = (0, bytes_1.concat)([keyBytes, (0, bytes_1.hexZeroPad)("0x", 32 - (key.length % 32))]);
- }
- return [4 /*yield*/, this._fetchBytes("0x59d1d43c", (0, bytes_1.hexlify)(keyBytes))];
- case 1:
- hexBytes = _a.sent();
- if (hexBytes == null || hexBytes === "0x") {
- return [2 /*return*/, null];
- }
- return [2 /*return*/, (0, strings_1.toUtf8String)(hexBytes)];
- }
- });
- });
- };
- return Resolver;
- }());
- exports.Resolver = Resolver;
- var defaultFormatter = null;
- var nextPollId = 1;
- var BaseProvider = /** @class */ (function (_super) {
- __extends(BaseProvider, _super);
- /**
- * ready
- *
- * A Promise<Network> that resolves only once the provider is ready.
- *
- * Sub-classes that call the super with a network without a chainId
- * MUST set this. Standard named networks have a known chainId.
- *
- */
- function BaseProvider(network) {
- var _newTarget = this.constructor;
- var _this = this;
- logger.checkNew(_newTarget, abstract_provider_1.Provider);
- _this = _super.call(this) || this;
- // Events being listened to
- _this._events = [];
- _this._emitted = { block: -2 };
- _this.disableCcipRead = false;
- _this.formatter = _newTarget.getFormatter();
- // If network is any, this Provider allows the underlying
- // network to change dynamically, and we auto-detect the
- // current network
- (0, properties_1.defineReadOnly)(_this, "anyNetwork", (network === "any"));
- if (_this.anyNetwork) {
- network = _this.detectNetwork();
- }
- if (network instanceof Promise) {
- _this._networkPromise = network;
- // Squash any "unhandled promise" errors; that do not need to be handled
- network.catch(function (error) { });
- // Trigger initial network setting (async)
- _this._ready().catch(function (error) { });
- }
- else {
- var knownNetwork = (0, properties_1.getStatic)(_newTarget, "getNetwork")(network);
- if (knownNetwork) {
- (0, properties_1.defineReadOnly)(_this, "_network", knownNetwork);
- _this.emit("network", knownNetwork, null);
- }
- else {
- logger.throwArgumentError("invalid network", "network", network);
- }
- }
- _this._maxInternalBlockNumber = -1024;
- _this._lastBlockNumber = -2;
- _this._maxFilterBlockRange = 10;
- _this._pollingInterval = 4000;
- _this._fastQueryDate = 0;
- return _this;
- }
- BaseProvider.prototype._ready = function () {
- return __awaiter(this, void 0, void 0, function () {
- var network, error_4;
- return __generator(this, function (_a) {
- switch (_a.label) {
- case 0:
- if (!(this._network == null)) return [3 /*break*/, 7];
- network = null;
- if (!this._networkPromise) return [3 /*break*/, 4];
- _a.label = 1;
- case 1:
- _a.trys.push([1, 3, , 4]);
- return [4 /*yield*/, this._networkPromise];
- case 2:
- network = _a.sent();
- return [3 /*break*/, 4];
- case 3:
- error_4 = _a.sent();
- return [3 /*break*/, 4];
- case 4:
- if (!(network == null)) return [3 /*break*/, 6];
- return [4 /*yield*/, this.detectNetwork()];
- case 5:
- network = _a.sent();
- _a.label = 6;
- case 6:
- // This should never happen; every Provider sub-class should have
- // suggested a network by here (or have thrown).
- if (!network) {
- logger.throwError("no network detected", logger_1.Logger.errors.UNKNOWN_ERROR, {});
- }
- // Possible this call stacked so do not call defineReadOnly again
- if (this._network == null) {
- if (this.anyNetwork) {
- this._network = network;
- }
- else {
- (0, properties_1.defineReadOnly)(this, "_network", network);
- }
- this.emit("network", network, null);
- }
- _a.label = 7;
- case 7: return [2 /*return*/, this._network];
- }
- });
- });
- };
- Object.defineProperty(BaseProvider.prototype, "ready", {
- // This will always return the most recently established network.
- // For "any", this can change (a "network" event is emitted before
- // any change is reflected); otherwise this cannot change
- get: function () {
- var _this = this;
- return (0, web_1.poll)(function () {
- return _this._ready().then(function (network) {
- return network;
- }, function (error) {
- // If the network isn't running yet, we will wait
- if (error.code === logger_1.Logger.errors.NETWORK_ERROR && error.event === "noNetwork") {
- return undefined;
- }
- throw error;
- });
- });
- },
- enumerable: false,
- configurable: true
- });
- // @TODO: Remove this and just create a singleton formatter
- BaseProvider.getFormatter = function () {
- if (defaultFormatter == null) {
- defaultFormatter = new formatter_1.Formatter();
- }
- return defaultFormatter;
- };
- // @TODO: Remove this and just use getNetwork
- BaseProvider.getNetwork = function (network) {
- return (0, networks_1.getNetwork)((network == null) ? "homestead" : network);
- };
- BaseProvider.prototype.ccipReadFetch = function (tx, calldata, urls) {
- return __awaiter(this, void 0, void 0, function () {
- var sender, data, errorMessages, i, url, href, json, result, errorMessage;
- return __generator(this, function (_a) {
- switch (_a.label) {
- case 0:
- if (this.disableCcipRead || urls.length === 0) {
- return [2 /*return*/, null];
- }
- sender = (tx.from || "0x0000000000000000000000000000000000000000").toLowerCase();
- data = calldata.toLowerCase();
- errorMessages = [];
- i = 0;
- _a.label = 1;
- case 1:
- if (!(i < urls.length)) return [3 /*break*/, 4];
- url = urls[i];
- href = url.replace("{sender}", sender).replace("{data}", data);
- json = (url.indexOf("{data}") >= 0) ? null : JSON.stringify({ data: data, sender: sender });
- return [4 /*yield*/, (0, web_1.fetchJson)({ url: href, errorPassThrough: true }, json, function (value, response) {
- value.status = response.statusCode;
- return value;
- })];
- case 2:
- result = _a.sent();
- if (result.data) {
- return [2 /*return*/, result.data];
- }
- errorMessage = (result.message || "unknown error");
- // 4xx indicates the result is not present; stop
- if (result.status >= 400 && result.status < 500) {
- return [2 /*return*/, logger.throwError("response not found during CCIP fetch: " + errorMessage, logger_1.Logger.errors.SERVER_ERROR, { url: url, errorMessage: errorMessage })];
- }
- // 5xx indicates server issue; try the next url
- errorMessages.push(errorMessage);
- _a.label = 3;
- case 3:
- i++;
- return [3 /*break*/, 1];
- case 4: return [2 /*return*/, logger.throwError("error encountered during CCIP fetch: " + errorMessages.map(function (m) { return JSON.stringify(m); }).join(", "), logger_1.Logger.errors.SERVER_ERROR, {
- urls: urls,
- errorMessages: errorMessages
- })];
- }
- });
- });
- };
- // Fetches the blockNumber, but will reuse any result that is less
- // than maxAge old or has been requested since the last request
- BaseProvider.prototype._getInternalBlockNumber = function (maxAge) {
- return __awaiter(this, void 0, void 0, function () {
- var internalBlockNumber, result, error_5, reqTime, checkInternalBlockNumber;
- var _this = this;
- return __generator(this, function (_a) {
- switch (_a.label) {
- case 0: return [4 /*yield*/, this._ready()];
- case 1:
- _a.sent();
- if (!(maxAge > 0)) return [3 /*break*/, 7];
- _a.label = 2;
- case 2:
- if (!this._internalBlockNumber) return [3 /*break*/, 7];
- internalBlockNumber = this._internalBlockNumber;
- _a.label = 3;
- case 3:
- _a.trys.push([3, 5, , 6]);
- return [4 /*yield*/, internalBlockNumber];
- case 4:
- result = _a.sent();
- if ((getTime() - result.respTime) <= maxAge) {
- return [2 /*return*/, result.blockNumber];
- }
- // Too old; fetch a new value
- return [3 /*break*/, 7];
- case 5:
- error_5 = _a.sent();
- // The fetch rejected; if we are the first to get the
- // rejection, drop through so we replace it with a new
- // fetch; all others blocked will then get that fetch
- // which won't match the one they "remembered" and loop
- if (this._internalBlockNumber === internalBlockNumber) {
- return [3 /*break*/, 7];
- }
- return [3 /*break*/, 6];
- case 6: return [3 /*break*/, 2];
- case 7:
- reqTime = getTime();
- checkInternalBlockNumber = (0, properties_1.resolveProperties)({
- blockNumber: this.perform("getBlockNumber", {}),
- networkError: this.getNetwork().then(function (network) { return (null); }, function (error) { return (error); })
- }).then(function (_a) {
- var blockNumber = _a.blockNumber, networkError = _a.networkError;
- if (networkError) {
- // Unremember this bad internal block number
- if (_this._internalBlockNumber === checkInternalBlockNumber) {
- _this._internalBlockNumber = null;
- }
- throw networkError;
- }
- var respTime = getTime();
- blockNumber = bignumber_1.BigNumber.from(blockNumber).toNumber();
- if (blockNumber < _this._maxInternalBlockNumber) {
- blockNumber = _this._maxInternalBlockNumber;
- }
- _this._maxInternalBlockNumber = blockNumber;
- _this._setFastBlockNumber(blockNumber); // @TODO: Still need this?
- return { blockNumber: blockNumber, reqTime: reqTime, respTime: respTime };
- });
- this._internalBlockNumber = checkInternalBlockNumber;
- // Swallow unhandled exceptions; if needed they are handled else where
- checkInternalBlockNumber.catch(function (error) {
- // Don't null the dead (rejected) fetch, if it has already been updated
- if (_this._internalBlockNumber === checkInternalBlockNumber) {
- _this._internalBlockNumber = null;
- }
- });
- return [4 /*yield*/, checkInternalBlockNumber];
- case 8: return [2 /*return*/, (_a.sent()).blockNumber];
- }
- });
- });
- };
- BaseProvider.prototype.poll = function () {
- return __awaiter(this, void 0, void 0, function () {
- var pollId, runners, blockNumber, error_6, i;
- var _this = this;
- return __generator(this, function (_a) {
- switch (_a.label) {
- case 0:
- pollId = nextPollId++;
- runners = [];
- blockNumber = null;
- _a.label = 1;
- case 1:
- _a.trys.push([1, 3, , 4]);
- return [4 /*yield*/, this._getInternalBlockNumber(100 + this.pollingInterval / 2)];
- case 2:
- blockNumber = _a.sent();
- return [3 /*break*/, 4];
- case 3:
- error_6 = _a.sent();
- this.emit("error", error_6);
- return [2 /*return*/];
- case 4:
- this._setFastBlockNumber(blockNumber);
- // Emit a poll event after we have the latest (fast) block number
- this.emit("poll", pollId, blockNumber);
- // If the block has not changed, meh.
- if (blockNumber === this._lastBlockNumber) {
- this.emit("didPoll", pollId);
- return [2 /*return*/];
- }
- // First polling cycle, trigger a "block" events
- if (this._emitted.block === -2) {
- this._emitted.block = blockNumber - 1;
- }
- if (Math.abs((this._emitted.block) - blockNumber) > 1000) {
- logger.warn("network block skew detected; skipping block events (emitted=" + this._emitted.block + " blockNumber" + blockNumber + ")");
- this.emit("error", logger.makeError("network block skew detected", logger_1.Logger.errors.NETWORK_ERROR, {
- blockNumber: blockNumber,
- event: "blockSkew",
- previousBlockNumber: this._emitted.block
- }));
- this.emit("block", blockNumber);
- }
- else {
- // Notify all listener for each block that has passed
- for (i = this._emitted.block + 1; i <= blockNumber; i++) {
- this.emit("block", i);
- }
- }
- // The emitted block was updated, check for obsolete events
- if (this._emitted.block !== blockNumber) {
- this._emitted.block = blockNumber;
- Object.keys(this._emitted).forEach(function (key) {
- // The block event does not expire
- if (key === "block") {
- return;
- }
- // The block we were at when we emitted this event
- var eventBlockNumber = _this._emitted[key];
- // We cannot garbage collect pending transactions or blocks here
- // They should be garbage collected by the Provider when setting
- // "pending" events
- if (eventBlockNumber === "pending") {
- return;
- }
- // Evict any transaction hashes or block hashes over 12 blocks
- // old, since they should not return null anyways
- if (blockNumber - eventBlockNumber > 12) {
- delete _this._emitted[key];
- }
- });
- }
- // First polling cycle
- if (this._lastBlockNumber === -2) {
- this._lastBlockNumber = blockNumber - 1;
- }
- // Find all transaction hashes we are waiting on
- this._events.forEach(function (event) {
- switch (event.type) {
- case "tx": {
- var hash_2 = event.hash;
- var runner = _this.getTransactionReceipt(hash_2).then(function (receipt) {
- if (!receipt || receipt.blockNumber == null) {
- return null;
- }
- _this._emitted["t:" + hash_2] = receipt.blockNumber;
- _this.emit(hash_2, receipt);
- return null;
- }).catch(function (error) { _this.emit("error", error); });
- runners.push(runner);
- break;
- }
- case "filter": {
- // We only allow a single getLogs to be in-flight at a time
- if (!event._inflight) {
- event._inflight = true;
- // Filter from the last known event; due to load-balancing
- // and some nodes returning updated block numbers before
- // indexing events, a logs result with 0 entries cannot be
- // trusted and we must retry a range which includes it again
- var filter_1 = event.filter;
- filter_1.fromBlock = event._lastBlockNumber + 1;
- filter_1.toBlock = blockNumber;
- // Prevent fitler ranges from growing too wild
- if (filter_1.toBlock - _this._maxFilterBlockRange > filter_1.fromBlock) {
- filter_1.fromBlock = filter_1.toBlock - _this._maxFilterBlockRange;
- }
- var runner = _this.getLogs(filter_1).then(function (logs) {
- // Allow the next getLogs
- event._inflight = false;
- if (logs.length === 0) {
- return;
- }
- logs.forEach(function (log) {
- // Only when we get an event for a given block number
- // can we trust the events are indexed
- if (log.blockNumber > event._lastBlockNumber) {
- event._lastBlockNumber = log.blockNumber;
- }
- // Make sure we stall requests to fetch blocks and txs
- _this._emitted["b:" + log.blockHash] = log.blockNumber;
- _this._emitted["t:" + log.transactionHash] = log.blockNumber;
- _this.emit(filter_1, log);
- });
- }).catch(function (error) {
- _this.emit("error", error);
- // Allow another getLogs (the range was not updated)
- event._inflight = false;
- });
- runners.push(runner);
- }
- break;
- }
- }
- });
- this._lastBlockNumber = blockNumber;
- // Once all events for this loop have been processed, emit "didPoll"
- Promise.all(runners).then(function () {
- _this.emit("didPoll", pollId);
- }).catch(function (error) { _this.emit("error", error); });
- return [2 /*return*/];
- }
- });
- });
- };
- // Deprecated; do not use this
- BaseProvider.prototype.resetEventsBlock = function (blockNumber) {
- this._lastBlockNumber = blockNumber - 1;
- if (this.polling) {
- this.poll();
- }
- };
- Object.defineProperty(BaseProvider.prototype, "network", {
- get: function () {
- return this._network;
- },
- enumerable: false,
- configurable: true
- });
- // This method should query the network if the underlying network
- // can change, such as when connected to a JSON-RPC backend
- BaseProvider.prototype.detectNetwork = function () {
- return __awaiter(this, void 0, void 0, function () {
- return __generator(this, function (_a) {
- return [2 /*return*/, logger.throwError("provider does not support network detection", logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
- operation: "provider.detectNetwork"
- })];
- });
- });
- };
- BaseProvider.prototype.getNetwork = function () {
- return __awaiter(this, void 0, void 0, function () {
- var network, currentNetwork, error;
- return __generator(this, function (_a) {
- switch (_a.label) {
- case 0: return [4 /*yield*/, this._ready()];
- case 1:
- network = _a.sent();
- return [4 /*yield*/, this.detectNetwork()];
- case 2:
- currentNetwork = _a.sent();
- if (!(network.chainId !== currentNetwork.chainId)) return [3 /*break*/, 5];
- if (!this.anyNetwork) return [3 /*break*/, 4];
- this._network = currentNetwork;
- // Reset all internal block number guards and caches
- this._lastBlockNumber = -2;
- this._fastBlockNumber = null;
- this._fastBlockNumberPromise = null;
- this._fastQueryDate = 0;
- this._emitted.block = -2;
- this._maxInternalBlockNumber = -1024;
- this._internalBlockNumber = null;
- // The "network" event MUST happen before this method resolves
- // so any events have a chance to unregister, so we stall an
- // additional event loop before returning from /this/ call
- this.emit("network", currentNetwork, network);
- return [4 /*yield*/, stall(0)];
- case 3:
- _a.sent();
- return [2 /*return*/, this._network];
- case 4:
- error = logger.makeError("underlying network changed", logger_1.Logger.errors.NETWORK_ERROR, {
- event: "changed",
- network: network,
- detectedNetwork: currentNetwork
- });
- this.emit("error", error);
- throw error;
- case 5: return [2 /*return*/, network];
- }
- });
- });
- };
- Object.defineProperty(BaseProvider.prototype, "blockNumber", {
- get: function () {
- var _this = this;
- this._getInternalBlockNumber(100 + this.pollingInterval / 2).then(function (blockNumber) {
- _this._setFastBlockNumber(blockNumber);
- }, function (error) { });
- return (this._fastBlockNumber != null) ? this._fastBlockNumber : -1;
- },
- enumerable: false,
- configurable: true
- });
- Object.defineProperty(BaseProvider.prototype, "polling", {
- get: function () {
- return (this._poller != null);
- },
- set: function (value) {
- var _this = this;
- if (value && !this._poller) {
- this._poller = setInterval(function () { _this.poll(); }, this.pollingInterval);
- if (!this._bootstrapPoll) {
- this._bootstrapPoll = setTimeout(function () {
- _this.poll();
- // We block additional polls until the polling interval
- // is done, to prevent overwhelming the poll function
- _this._bootstrapPoll = setTimeout(function () {
- // If polling was disabled, something may require a poke
- // since starting the bootstrap poll and it was disabled
- if (!_this._poller) {
- _this.poll();
- }
- // Clear out the bootstrap so we can do another
- _this._bootstrapPoll = null;
- }, _this.pollingInterval);
- }, 0);
- }
- }
- else if (!value && this._poller) {
- clearInterval(this._poller);
- this._poller = null;
- }
- },
- enumerable: false,
- configurable: true
- });
- Object.defineProperty(BaseProvider.prototype, "pollingInterval", {
- get: function () {
- return this._pollingInterval;
- },
- set: function (value) {
- var _this = this;
- if (typeof (value) !== "number" || value <= 0 || parseInt(String(value)) != value) {
- throw new Error("invalid polling interval");
- }
- this._pollingInterval = value;
- if (this._poller) {
- clearInterval(this._poller);
- this._poller = setInterval(function () { _this.poll(); }, this._pollingInterval);
- }
- },
- enumerable: false,
- configurable: true
- });
- BaseProvider.prototype._getFastBlockNumber = function () {
- var _this = this;
- var now = getTime();
- // Stale block number, request a newer value
- if ((now - this._fastQueryDate) > 2 * this._pollingInterval) {
- this._fastQueryDate = now;
- this._fastBlockNumberPromise = this.getBlockNumber().then(function (blockNumber) {
- if (_this._fastBlockNumber == null || blockNumber > _this._fastBlockNumber) {
- _this._fastBlockNumber = blockNumber;
- }
- return _this._fastBlockNumber;
- });
- }
- return this._fastBlockNumberPromise;
- };
- BaseProvider.prototype._setFastBlockNumber = function (blockNumber) {
- // Older block, maybe a stale request
- if (this._fastBlockNumber != null && blockNumber < this._fastBlockNumber) {
- return;
- }
- // Update the time we updated the blocknumber
- this._fastQueryDate = getTime();
- // Newer block number, use it
- if (this._fastBlockNumber == null || blockNumber > this._fastBlockNumber) {
- this._fastBlockNumber = blockNumber;
- this._fastBlockNumberPromise = Promise.resolve(blockNumber);
- }
- };
- BaseProvider.prototype.waitForTransaction = function (transactionHash, confirmations, timeout) {
- return __awaiter(this, void 0, void 0, function () {
- return __generator(this, function (_a) {
- return [2 /*return*/, this._waitForTransaction(transactionHash, (confirmations == null) ? 1 : confirmations, timeout || 0, null)];
- });
- });
- };
- BaseProvider.prototype._waitForTransaction = function (transactionHash, confirmations, timeout, replaceable) {
- return __awaiter(this, void 0, void 0, function () {
- var receipt;
- var _this = this;
- return __generator(this, function (_a) {
- switch (_a.label) {
- case 0: return [4 /*yield*/, this.getTransactionReceipt(transactionHash)];
- case 1:
- receipt = _a.sent();
- // Receipt is already good
- if ((receipt ? receipt.confirmations : 0) >= confirmations) {
- return [2 /*return*/, receipt];
- }
- // Poll until the receipt is good...
- return [2 /*return*/, new Promise(function (resolve, reject) {
- var cancelFuncs = [];
- var done = false;
- var alreadyDone = function () {
- if (done) {
- return true;
- }
- done = true;
- cancelFuncs.forEach(function (func) { func(); });
- return false;
- };
- var minedHandler = function (receipt) {
- if (receipt.confirmations < confirmations) {
- return;
- }
- if (alreadyDone()) {
- return;
- }
- resolve(receipt);
- };
- _this.on(transactionHash, minedHandler);
- cancelFuncs.push(function () { _this.removeListener(transactionHash, minedHandler); });
- if (replaceable) {
- var lastBlockNumber_1 = replaceable.startBlock;
- var scannedBlock_1 = null;
- var replaceHandler_1 = function (blockNumber) { return __awaiter(_this, void 0, void 0, function () {
- var _this = this;
- return __generator(this, function (_a) {
- switch (_a.label) {
- case 0:
- if (done) {
- return [2 /*return*/];
- }
- // Wait 1 second; this is only used in the case of a fault, so
- // we will trade off a little bit of latency for more consistent
- // results and fewer JSON-RPC calls
- return [4 /*yield*/, stall(1000)];
- case 1:
- // Wait 1 second; this is only used in the case of a fault, so
- // we will trade off a little bit of latency for more consistent
- // results and fewer JSON-RPC calls
- _a.sent();
- this.getTransactionCount(replaceable.from).then(function (nonce) { return __awaiter(_this, void 0, void 0, function () {
- var mined, block, ti, tx, receipt_1, reason;
- return __generator(this, function (_a) {
- switch (_a.label) {
- case 0:
- if (done) {
- return [2 /*return*/];
- }
- if (!(nonce <= replaceable.nonce)) return [3 /*break*/, 1];
- lastBlockNumber_1 = blockNumber;
- return [3 /*break*/, 9];
- case 1: return [4 /*yield*/, this.getTransaction(transactionHash)];
- case 2:
- mined = _a.sent();
- if (mined && mined.blockNumber != null) {
- return [2 /*return*/];
- }
- // First time scanning. We start a little earlier for some
- // wiggle room here to handle the eventually consistent nature
- // of blockchain (e.g. the getTransactionCount was for a
- // different block)
- if (scannedBlock_1 == null) {
- scannedBlock_1 = lastBlockNumber_1 - 3;
- if (scannedBlock_1 < replaceable.startBlock) {
- scannedBlock_1 = replaceable.startBlock;
- }
- }
- _a.label = 3;
- case 3:
- if (!(scannedBlock_1 <= blockNumber)) return [3 /*break*/, 9];
- if (done) {
- return [2 /*return*/];
- }
- return [4 /*yield*/, this.getBlockWithTransactions(scannedBlock_1)];
- case 4:
- block = _a.sent();
- ti = 0;
- _a.label = 5;
- case 5:
- if (!(ti < block.transactions.length)) return [3 /*break*/, 8];
- tx = block.transactions[ti];
- // Successfully mined!
- if (tx.hash === transactionHash) {
- return [2 /*return*/];
- }
- if (!(tx.from === replaceable.from && tx.nonce === replaceable.nonce)) return [3 /*break*/, 7];
- if (done) {
- return [2 /*return*/];
- }
- return [4 /*yield*/, this.waitForTransaction(tx.hash, confirmations)];
- case 6:
- receipt_1 = _a.sent();
- // Already resolved or rejected (prolly a timeout)
- if (alreadyDone()) {
- return [2 /*return*/];
- }
- reason = "replaced";
- if (tx.data === replaceable.data && tx.to === replaceable.to && tx.value.eq(replaceable.value)) {
- reason = "repriced";
- }
- else if (tx.data === "0x" && tx.from === tx.to && tx.value.isZero()) {
- reason = "cancelled";
- }
- // Explain why we were replaced
- reject(logger.makeError("transaction was replaced", logger_1.Logger.errors.TRANSACTION_REPLACED, {
- cancelled: (reason === "replaced" || reason === "cancelled"),
- reason: reason,
- replacement: this._wrapTransaction(tx),
- hash: transactionHash,
- receipt: receipt_1
- }));
- return [2 /*return*/];
- case 7:
- ti++;
- return [3 /*break*/, 5];
- case 8:
- scannedBlock_1++;
- return [3 /*break*/, 3];
- case 9:
- if (done) {
- return [2 /*return*/];
- }
- this.once("block", replaceHandler_1);
- return [2 /*return*/];
- }
- });
- }); }, function (error) {
- if (done) {
- return;
- }
- _this.once("block", replaceHandler_1);
- });
- return [2 /*return*/];
- }
- });
- }); };
- if (done) {
- return;
- }
- _this.once("block", replaceHandler_1);
- cancelFuncs.push(function () {
- _this.removeListener("block", replaceHandler_1);
- });
- }
- if (typeof (timeout) === "number" && timeout > 0) {
- var timer_1 = setTimeout(function () {
- if (alreadyDone()) {
- return;
- }
- reject(logger.makeError("timeout exceeded", logger_1.Logger.errors.TIMEOUT, { timeout: timeout }));
- }, timeout);
- if (timer_1.unref) {
- timer_1.unref();
- }
- cancelFuncs.push(function () { clearTimeout(timer_1); });
- }
- })];
- }
- });
- });
- };
- BaseProvider.prototype.getBlockNumber = function () {
- return __awaiter(this, void 0, void 0, function () {
- return __generator(this, function (_a) {
- return [2 /*return*/, this._getInternalBlockNumber(0)];
- });
- });
- };
- BaseProvider.prototype.getGasPrice = function () {
- return __awaiter(this, void 0, void 0, function () {
- var result;
- return __generator(this, function (_a) {
- switch (_a.label) {
- case 0: return [4 /*yield*/, this.getNetwork()];
- case 1:
- _a.sent();
- return [4 /*yield*/, this.perform("getGasPrice", {})];
- case 2:
- result = _a.sent();
- try {
- return [2 /*return*/, bignumber_1.BigNumber.from(result)];
- }
- catch (error) {
- return [2 /*return*/, logger.throwError("bad result from backend", logger_1.Logger.errors.SERVER_ERROR, {
- method: "getGasPrice",
- result: result,
- error: error
- })];
- }
- return [2 /*return*/];
- }
- });
- });
- };
- BaseProvider.prototype.getBalance = function (addressOrName, blockTag) {
- return __awaiter(this, void 0, void 0, function () {
- var params, result;
- return __generator(this, function (_a) {
- switch (_a.label) {
- case 0: return [4 /*yield*/, this.getNetwork()];
- case 1:
- _a.sent();
- return [4 /*yield*/, (0, properties_1.resolveProperties)({
- address: this._getAddress(addressOrName),
- blockTag: this._getBlockTag(blockTag)
- })];
- case 2:
- params = _a.sent();
- return [4 /*yield*/, this.perform("getBalance", params)];
- case 3:
- result = _a.sent();
- try {
- return [2 /*return*/, bignumber_1.BigNumber.from(result)];
- }
- catch (error) {
- return [2 /*return*/, logger.throwError("bad result from backend", logger_1.Logger.errors.SERVER_ERROR, {
- method: "getBalance",
- params: params,
- result: result,
- error: error
- })];
- }
- return [2 /*return*/];
- }
- });
- });
- };
- BaseProvider.prototype.getTransactionCount = function (addressOrName, blockTag) {
- return __awaiter(this, void 0, void 0, function () {
- var params, result;
- return __generator(this, function (_a) {
- switch (_a.label) {
- case 0: return [4 /*yield*/, this.getNetwork()];
- case 1:
- _a.sent();
- return [4 /*yield*/, (0, properties_1.resolveProperties)({
- address: this._getAddress(addressOrName),
- blockTag: this._getBlockTag(blockTag)
- })];
- case 2:
- params = _a.sent();
- return [4 /*yield*/, this.perform("getTransactionCount", params)];
- case 3:
- result = _a.sent();
- try {
- return [2 /*return*/, bignumber_1.BigNumber.from(result).toNumber()];
- }
- catch (error) {
- return [2 /*return*/, logger.throwError("bad result from backend", logger_1.Logger.errors.SERVER_ERROR, {
- method: "getTransactionCount",
- params: params,
- result: result,
- error: error
- })];
- }
- return [2 /*return*/];
- }
- });
- });
- };
- BaseProvider.prototype.getCode = function (addressOrName, blockTag) {
- return __awaiter(this, void 0, void 0, function () {
- var params, result;
- return __generator(this, function (_a) {
- switch (_a.label) {
- case 0: return [4 /*yield*/, this.getNetwork()];
- case 1:
- _a.sent();
- return [4 /*yield*/, (0, properties_1.resolveProperties)({
- address: this._getAddress(addressOrName),
- blockTag: this._getBlockTag(blockTag)
- })];
- case 2:
- params = _a.sent();
- return [4 /*yield*/, this.perform("getCode", params)];
- case 3:
- result = _a.sent();
- try {
- return [2 /*return*/, (0, bytes_1.hexlify)(result)];
- }
- catch (error) {
- return [2 /*return*/, logger.throwError("bad result from backend", logger_1.Logger.errors.SERVER_ERROR, {
- method: "getCode",
- params: params,
- result: result,
- error: error
- })];
- }
- return [2 /*return*/];
- }
- });
- });
- };
- BaseProvider.prototype.getStorageAt = function (addressOrName, position, blockTag) {
- return __awaiter(this, void 0, void 0, function () {
- var params, result;
- return __generator(this, function (_a) {
- switch (_a.label) {
- case 0: return [4 /*yield*/, this.getNetwork()];
- case 1:
- _a.sent();
- return [4 /*yield*/, (0, properties_1.resolveProperties)({
- address: this._getAddress(addressOrName),
- blockTag: this._getBlockTag(blockTag),
- position: Promise.resolve(position).then(function (p) { return (0, bytes_1.hexValue)(p); })
- })];
- case 2:
- params = _a.sent();
- return [4 /*yield*/, this.perform("getStorageAt", params)];
- case 3:
- result = _a.sent();
- try {
- return [2 /*return*/, (0, bytes_1.hexlify)(result)];
- }
- catch (error) {
- return [2 /*return*/, logger.throwError("bad result from backend", logger_1.Logger.errors.SERVER_ERROR, {
- method: "getStorageAt",
- params: params,
- result: result,
- error: error
- })];
- }
- return [2 /*return*/];
- }
- });
- });
- };
- // This should be called by any subclass wrapping a TransactionResponse
- BaseProvider.prototype._wrapTransaction = function (tx, hash, startBlock) {
- var _this = this;
- if (hash != null && (0, bytes_1.hexDataLength)(hash) !== 32) {
- throw new Error("invalid response - sendTransaction");
- }
- var result = tx;
- // Check the hash we expect is the same as the hash the server reported
- if (hash != null && tx.hash !== hash) {
- logger.throwError("Transaction hash mismatch from Provider.sendTransaction.", logger_1.Logger.errors.UNKNOWN_ERROR, { expectedHash: tx.hash, returnedHash: hash });
- }
- result.wait = function (confirms, timeout) { return __awaiter(_this, void 0, void 0, function () {
- var replacement, receipt;
- return __generator(this, function (_a) {
- switch (_a.label) {
- case 0:
- if (confirms == null) {
- confirms = 1;
- }
- if (timeout == null) {
- timeout = 0;
- }
- replacement = undefined;
- if (confirms !== 0 && startBlock != null) {
- replacement = {
- data: tx.data,
- from: tx.from,
- nonce: tx.nonce,
- to: tx.to,
- value: tx.value,
- startBlock: startBlock
- };
- }
- return [4 /*yield*/, this._waitForTransaction(tx.hash, confirms, timeout, replacement)];
- case 1:
- receipt = _a.sent();
- if (receipt == null && confirms === 0) {
- return [2 /*return*/, null];
- }
- // No longer pending, allow the polling loop to garbage collect this
- this._emitted["t:" + tx.hash] = receipt.blockNumber;
- if (receipt.status === 0) {
- logger.throwError("transaction failed", logger_1.Logger.errors.CALL_EXCEPTION, {
- transactionHash: tx.hash,
- transaction: tx,
- receipt: receipt
- });
- }
- return [2 /*return*/, receipt];
- }
- });
- }); };
- return result;
- };
- BaseProvider.prototype.sendTransaction = function (signedTransaction) {
- return __awaiter(this, void 0, void 0, function () {
- var hexTx, tx, blockNumber, hash, error_7;
- return __generator(this, function (_a) {
- switch (_a.label) {
- case 0: return [4 /*yield*/, this.getNetwork()];
- case 1:
- _a.sent();
- return [4 /*yield*/, Promise.resolve(signedTransaction).then(function (t) { return (0, bytes_1.hexlify)(t); })];
- case 2:
- hexTx = _a.sent();
- tx = this.formatter.transaction(signedTransaction);
- if (tx.confirmations == null) {
- tx.confirmations = 0;
- }
- return [4 /*yield*/, this._getInternalBlockNumber(100 + 2 * this.pollingInterval)];
- case 3:
- blockNumber = _a.sent();
- _a.label = 4;
- case 4:
- _a.trys.push([4, 6, , 7]);
- return [4 /*yield*/, this.perform("sendTransaction", { signedTransaction: hexTx })];
- case 5:
- hash = _a.sent();
- return [2 /*return*/, this._wrapTransaction(tx, hash, blockNumber)];
- case 6:
- error_7 = _a.sent();
- error_7.transaction = tx;
- error_7.transactionHash = tx.hash;
- throw error_7;
- case 7: return [2 /*return*/];
- }
- });
- });
- };
- BaseProvider.prototype._getTransactionRequest = function (transaction) {
- return __awaiter(this, void 0, void 0, function () {
- var values, tx, _a, _b;
- var _this = this;
- return __generator(this, function (_c) {
- switch (_c.label) {
- case 0: return [4 /*yield*/, transaction];
- case 1:
- values = _c.sent();
- tx = {};
- ["from", "to"].forEach(function (key) {
- if (values[key] == null) {
- return;
- }
- tx[key] = Promise.resolve(values[key]).then(function (v) { return (v ? _this._getAddress(v) : null); });
- });
- ["gasLimit", "gasPrice", "maxFeePerGas", "maxPriorityFeePerGas", "value"].forEach(function (key) {
- if (values[key] == null) {
- return;
- }
- tx[key] = Promise.resolve(values[key]).then(function (v) { return (v ? bignumber_1.BigNumber.from(v) : null); });
- });
- ["type"].forEach(function (key) {
- if (values[key] == null) {
- return;
- }
- tx[key] = Promise.resolve(values[key]).then(function (v) { return ((v != null) ? v : null); });
- });
- if (values.accessList) {
- tx.accessList = this.formatter.accessList(values.accessList);
- }
- ["data"].forEach(function (key) {
- if (values[key] == null) {
- return;
- }
- tx[key] = Promise.resolve(values[key]).then(function (v) { return (v ? (0, bytes_1.hexlify)(v) : null); });
- });
- _b = (_a = this.formatter).transactionRequest;
- return [4 /*yield*/, (0, properties_1.resolveProperties)(tx)];
- case 2: return [2 /*return*/, _b.apply(_a, [_c.sent()])];
- }
- });
- });
- };
- BaseProvider.prototype._getFilter = function (filter) {
- return __awaiter(this, void 0, void 0, function () {
- var result, _a, _b;
- var _this = this;
- return __generator(this, function (_c) {
- switch (_c.label) {
- case 0: return [4 /*yield*/, filter];
- case 1:
- filter = _c.sent();
- result = {};
- if (filter.address != null) {
- result.address = this._getAddress(filter.address);
- }
- ["blockHash", "topics"].forEach(function (key) {
- if (filter[key] == null) {
- return;
- }
- result[key] = filter[key];
- });
- ["fromBlock", "toBlock"].forEach(function (key) {
- if (filter[key] == null) {
- return;
- }
- result[key] = _this._getBlockTag(filter[key]);
- });
- _b = (_a = this.formatter).filter;
- return [4 /*yield*/, (0, properties_1.resolveProperties)(result)];
- case 2: return [2 /*return*/, _b.apply(_a, [_c.sent()])];
- }
- });
- });
- };
- BaseProvider.prototype._call = function (transaction, blockTag, attempt) {
- return __awaiter(this, void 0, void 0, function () {
- var txSender, result, data, sender, urls, urlsOffset, urlsLength, urlsData, u, url, calldata, callbackSelector, extraData, ccipResult, tx, error_8;
- return __generator(this, function (_a) {
- switch (_a.label) {
- case 0:
- if (attempt >= MAX_CCIP_REDIRECTS) {
- logger.throwError("CCIP read exceeded maximum redirections", logger_1.Logger.errors.SERVER_ERROR, {
- redirects: attempt,
- transaction: transaction
- });
- }
- txSender = transaction.to;
- return [4 /*yield*/, this.perform("call", { transaction: transaction, blockTag: blockTag })];
- case 1:
- result = _a.sent();
- if (!(attempt >= 0 && blockTag === "latest" && txSender != null && result.substring(0, 10) === "0x556f1830" && ((0, bytes_1.hexDataLength)(result) % 32 === 4))) return [3 /*break*/, 5];
- _a.label = 2;
- case 2:
- _a.trys.push([2, 4, , 5]);
- data = (0, bytes_1.hexDataSlice)(result, 4);
- sender = (0, bytes_1.hexDataSlice)(data, 0, 32);
- if (!bignumber_1.BigNumber.from(sender).eq(txSender)) {
- logger.throwError("CCIP Read sender did not match", logger_1.Logger.errors.CALL_EXCEPTION, {
- name: "OffchainLookup",
- signature: "OffchainLookup(address,string[],bytes,bytes4,bytes)",
- transaction: transaction,
- data: result
- });
- }
- urls = [];
- urlsOffset = bignumber_1.BigNumber.from((0, bytes_1.hexDataSlice)(data, 32, 64)).toNumber();
- urlsLength = bignumber_1.BigNumber.from((0, bytes_1.hexDataSlice)(data, urlsOffset, urlsOffset + 32)).toNumber();
- urlsData = (0, bytes_1.hexDataSlice)(data, urlsOffset + 32);
- for (u = 0; u < urlsLength; u++) {
- url = _parseString(urlsData, u * 32);
- if (url == null) {
- logger.throwError("CCIP Read contained corrupt URL string", logger_1.Logger.errors.CALL_EXCEPTION, {
- name: "OffchainLookup",
- signature: "OffchainLookup(address,string[],bytes,bytes4,bytes)",
- transaction: transaction,
- data: result
- });
- }
- urls.push(url);
- }
- calldata = _parseBytes(data, 64);
- // Get the callbackSelector (bytes4)
- if (!bignumber_1.BigNumber.from((0, bytes_1.hexDataSlice)(data, 100, 128)).isZero()) {
- logger.throwError("CCIP Read callback selector included junk", logger_1.Logger.errors.CALL_EXCEPTION, {
- name: "OffchainLookup",
- signature: "OffchainLookup(address,string[],bytes,bytes4,bytes)",
- transaction: transaction,
- data: result
- });
- }
- callbackSelector = (0, bytes_1.hexDataSlice)(data, 96, 100);
- extraData = _parseBytes(data, 128);
- return [4 /*yield*/, this.ccipReadFetch(transaction, calldata, urls)];
- case 3:
- ccipResult = _a.sent();
- if (ccipResult == null) {
- logger.throwError("CCIP Read disabled or provided no URLs", logger_1.Logger.errors.CALL_EXCEPTION, {
- name: "OffchainLookup",
- signature: "OffchainLookup(address,string[],bytes,bytes4,bytes)",
- transaction: transaction,
- data: result
- });
- }
- tx = {
- to: txSender,
- data: (0, bytes_1.hexConcat)([callbackSelector, encodeBytes([ccipResult, extraData])])
- };
- return [2 /*return*/, this._call(tx, blockTag, attempt + 1)];
- case 4:
- error_8 = _a.sent();
- if (error_8.code === logger_1.Logger.errors.SERVER_ERROR) {
- throw error_8;
- }
- return [3 /*break*/, 5];
- case 5:
- try {
- return [2 /*return*/, (0, bytes_1.hexlify)(result)];
- }
- catch (error) {
- return [2 /*return*/, logger.throwError("bad result from backend", logger_1.Logger.errors.SERVER_ERROR, {
- method: "call",
- params: { transaction: transaction, blockTag: blockTag },
- result: result,
- error: error
- })];
- }
- return [2 /*return*/];
- }
- });
- });
- };
- BaseProvider.prototype.call = function (transaction, blockTag) {
- return __awaiter(this, void 0, void 0, function () {
- var resolved;
- return __generator(this, function (_a) {
- switch (_a.label) {
- case 0: return [4 /*yield*/, this.getNetwork()];
- case 1:
- _a.sent();
- return [4 /*yield*/, (0, properties_1.resolveProperties)({
- transaction: this._getTransactionRequest(transaction),
- blockTag: this._getBlockTag(blockTag),
- ccipReadEnabled: Promise.resolve(transaction.ccipReadEnabled)
- })];
- case 2:
- resolved = _a.sent();
- return [2 /*return*/, this._call(resolved.transaction, resolved.blockTag, resolved.ccipReadEnabled ? 0 : -1)];
- }
- });
- });
- };
- BaseProvider.prototype.estimateGas = function (transaction) {
- return __awaiter(this, void 0, void 0, function () {
- var params, result;
- return __generator(this, function (_a) {
- switch (_a.label) {
- case 0: return [4 /*yield*/, this.getNetwork()];
- case 1:
- _a.sent();
- return [4 /*yield*/, (0, properties_1.resolveProperties)({
- transaction: this._getTransactionRequest(transaction)
- })];
- case 2:
- params = _a.sent();
- return [4 /*yield*/, this.perform("estimateGas", params)];
- case 3:
- result = _a.sent();
- try {
- return [2 /*return*/, bignumber_1.BigNumber.from(result)];
- }
- catch (error) {
- return [2 /*return*/, logger.throwError("bad result from backend", logger_1.Logger.errors.SERVER_ERROR, {
- method: "estimateGas",
- params: params,
- result: result,
- error: error
- })];
- }
- return [2 /*return*/];
- }
- });
- });
- };
- BaseProvider.prototype._getAddress = function (addressOrName) {
- return __awaiter(this, void 0, void 0, function () {
- var address;
- return __generator(this, function (_a) {
- switch (_a.label) {
- case 0: return [4 /*yield*/, addressOrName];
- case 1:
- addressOrName = _a.sent();
- if (typeof (addressOrName) !== "string") {
- logger.throwArgumentError("invalid address or ENS name", "name", addressOrName);
- }
- return [4 /*yield*/, this.resolveName(addressOrName)];
- case 2:
- address = _a.sent();
- if (address == null) {
- logger.throwError("ENS name not configured", logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
- operation: "resolveName(" + JSON.stringify(addressOrName) + ")"
- });
- }
- return [2 /*return*/, address];
- }
- });
- });
- };
- BaseProvider.prototype._getBlock = function (blockHashOrBlockTag, includeTransactions) {
- return __awaiter(this, void 0, void 0, function () {
- var blockNumber, params, _a, error_9;
- var _this = this;
- return __generator(this, function (_b) {
- switch (_b.label) {
- case 0: return [4 /*yield*/, this.getNetwork()];
- case 1:
- _b.sent();
- return [4 /*yield*/, blockHashOrBlockTag];
- case 2:
- blockHashOrBlockTag = _b.sent();
- blockNumber = -128;
- params = {
- includeTransactions: !!includeTransactions
- };
- if (!(0, bytes_1.isHexString)(blockHashOrBlockTag, 32)) return [3 /*break*/, 3];
- params.blockHash = blockHashOrBlockTag;
- return [3 /*break*/, 6];
- case 3:
- _b.trys.push([3, 5, , 6]);
- _a = params;
- return [4 /*yield*/, this._getBlockTag(blockHashOrBlockTag)];
- case 4:
- _a.blockTag = _b.sent();
- if ((0, bytes_1.isHexString)(params.blockTag)) {
- blockNumber = parseInt(params.blockTag.substring(2), 16);
- }
- return [3 /*break*/, 6];
- case 5:
- error_9 = _b.sent();
- logger.throwArgumentError("invalid block hash or block tag", "blockHashOrBlockTag", blockHashOrBlockTag);
- return [3 /*break*/, 6];
- case 6: return [2 /*return*/, (0, web_1.poll)(function () { return __awaiter(_this, void 0, void 0, function () {
- var block, blockNumber_1, i, tx, confirmations, blockWithTxs;
- var _this = this;
- return __generator(this, function (_a) {
- switch (_a.label) {
- case 0: return [4 /*yield*/, this.perform("getBlock", params)];
- case 1:
- block = _a.sent();
- // Block was not found
- if (block == null) {
- // For blockhashes, if we didn't say it existed, that blockhash may
- // not exist. If we did see it though, perhaps from a log, we know
- // it exists, and this node is just not caught up yet.
- if (params.blockHash != null) {
- if (this._emitted["b:" + params.blockHash] == null) {
- return [2 /*return*/, null];
- }
- }
- // For block tags, if we are asking for a future block, we return null
- if (params.blockTag != null) {
- if (blockNumber > this._emitted.block) {
- return [2 /*return*/, null];
- }
- }
- // Retry on the next block
- return [2 /*return*/, undefined];
- }
- if (!includeTransactions) return [3 /*break*/, 8];
- blockNumber_1 = null;
- i = 0;
- _a.label = 2;
- case 2:
- if (!(i < block.transactions.length)) return [3 /*break*/, 7];
- tx = block.transactions[i];
- if (!(tx.blockNumber == null)) return [3 /*break*/, 3];
- tx.confirmations = 0;
- return [3 /*break*/, 6];
- case 3:
- if (!(tx.confirmations == null)) return [3 /*break*/, 6];
- if (!(blockNumber_1 == null)) return [3 /*break*/, 5];
- return [4 /*yield*/, this._getInternalBlockNumber(100 + 2 * this.pollingInterval)];
- case 4:
- blockNumber_1 = _a.sent();
- _a.label = 5;
- case 5:
- confirmations = (blockNumber_1 - tx.blockNumber) + 1;
- if (confirmations <= 0) {
- confirmations = 1;
- }
- tx.confirmations = confirmations;
- _a.label = 6;
- case 6:
- i++;
- return [3 /*break*/, 2];
- case 7:
- blockWithTxs = this.formatter.blockWithTransactions(block);
- blockWithTxs.transactions = blockWithTxs.transactions.map(function (tx) { return _this._wrapTransaction(tx); });
- return [2 /*return*/, blockWithTxs];
- case 8: return [2 /*return*/, this.formatter.block(block)];
- }
- });
- }); }, { oncePoll: this })];
- }
- });
- });
- };
- BaseProvider.prototype.getBlock = function (blockHashOrBlockTag) {
- return (this._getBlock(blockHashOrBlockTag, false));
- };
- BaseProvider.prototype.getBlockWithTransactions = function (blockHashOrBlockTag) {
- return (this._getBlock(blockHashOrBlockTag, true));
- };
- BaseProvider.prototype.getTransaction = function (transactionHash) {
- return __awaiter(this, void 0, void 0, function () {
- var params;
- var _this = this;
- return __generator(this, function (_a) {
- switch (_a.label) {
- case 0: return [4 /*yield*/, this.getNetwork()];
- case 1:
- _a.sent();
- return [4 /*yield*/, transactionHash];
- case 2:
- transactionHash = _a.sent();
- params = { transactionHash: this.formatter.hash(transactionHash, true) };
- return [2 /*return*/, (0, web_1.poll)(function () { return __awaiter(_this, void 0, void 0, function () {
- var result, tx, blockNumber, confirmations;
- return __generator(this, function (_a) {
- switch (_a.label) {
- case 0: return [4 /*yield*/, this.perform("getTransaction", params)];
- case 1:
- result = _a.sent();
- if (result == null) {
- if (this._emitted["t:" + transactionHash] == null) {
- return [2 /*return*/, null];
- }
- return [2 /*return*/, undefined];
- }
- tx = this.formatter.transactionResponse(result);
- if (!(tx.blockNumber == null)) return [3 /*break*/, 2];
- tx.confirmations = 0;
- return [3 /*break*/, 4];
- case 2:
- if (!(tx.confirmations == null)) return [3 /*break*/, 4];
- return [4 /*yield*/, this._getInternalBlockNumber(100 + 2 * this.pollingInterval)];
- case 3:
- blockNumber = _a.sent();
- confirmations = (blockNumber - tx.blockNumber) + 1;
- if (confirmations <= 0) {
- confirmations = 1;
- }
- tx.confirmations = confirmations;
- _a.label = 4;
- case 4: return [2 /*return*/, this._wrapTransaction(tx)];
- }
- });
- }); }, { oncePoll: this })];
- }
- });
- });
- };
- BaseProvider.prototype.getTransactionReceipt = function (transactionHash) {
- return __awaiter(this, void 0, void 0, function () {
- var params;
- var _this = this;
- return __generator(this, function (_a) {
- switch (_a.label) {
- case 0: return [4 /*yield*/, this.getNetwork()];
- case 1:
- _a.sent();
- return [4 /*yield*/, transactionHash];
- case 2:
- transactionHash = _a.sent();
- params = { transactionHash: this.formatter.hash(transactionHash, true) };
- return [2 /*return*/, (0, web_1.poll)(function () { return __awaiter(_this, void 0, void 0, function () {
- var result, receipt, blockNumber, confirmations;
- return __generator(this, function (_a) {
- switch (_a.label) {
- case 0: return [4 /*yield*/, this.perform("getTransactionReceipt", params)];
- case 1:
- result = _a.sent();
- if (result == null) {
- if (this._emitted["t:" + transactionHash] == null) {
- return [2 /*return*/, null];
- }
- return [2 /*return*/, undefined];
- }
- // "geth-etc" returns receipts before they are ready
- if (result.blockHash == null) {
- return [2 /*return*/, undefined];
- }
- receipt = this.formatter.receipt(result);
- if (!(receipt.blockNumber == null)) return [3 /*break*/, 2];
- receipt.confirmations = 0;
- return [3 /*break*/, 4];
- case 2:
- if (!(receipt.confirmations == null)) return [3 /*break*/, 4];
- return [4 /*yield*/, this._getInternalBlockNumber(100 + 2 * this.pollingInterval)];
- case 3:
- blockNumber = _a.sent();
- confirmations = (blockNumber - receipt.blockNumber) + 1;
- if (confirmations <= 0) {
- confirmations = 1;
- }
- receipt.confirmations = confirmations;
- _a.label = 4;
- case 4: return [2 /*return*/, receipt];
- }
- });
- }); }, { oncePoll: this })];
- }
- });
- });
- };
- BaseProvider.prototype.getLogs = function (filter) {
- return __awaiter(this, void 0, void 0, function () {
- var params, logs;
- return __generator(this, function (_a) {
- switch (_a.label) {
- case 0: return [4 /*yield*/, this.getNetwork()];
- case 1:
- _a.sent();
- return [4 /*yield*/, (0, properties_1.resolveProperties)({ filter: this._getFilter(filter) })];
- case 2:
- params = _a.sent();
- return [4 /*yield*/, this.perform("getLogs", params)];
- case 3:
- logs = _a.sent();
- logs.forEach(function (log) {
- if (log.removed == null) {
- log.removed = false;
- }
- });
- return [2 /*return*/, formatter_1.Formatter.arrayOf(this.formatter.filterLog.bind(this.formatter))(logs)];
- }
- });
- });
- };
- BaseProvider.prototype.getEtherPrice = function () {
- return __awaiter(this, void 0, void 0, function () {
- return __generator(this, function (_a) {
- switch (_a.label) {
- case 0: return [4 /*yield*/, this.getNetwork()];
- case 1:
- _a.sent();
- return [2 /*return*/, this.perform("getEtherPrice", {})];
- }
- });
- });
- };
- BaseProvider.prototype._getBlockTag = function (blockTag) {
- return __awaiter(this, void 0, void 0, function () {
- var blockNumber;
- return __generator(this, function (_a) {
- switch (_a.label) {
- case 0: return [4 /*yield*/, blockTag];
- case 1:
- blockTag = _a.sent();
- if (!(typeof (blockTag) === "number" && blockTag < 0)) return [3 /*break*/, 3];
- if (blockTag % 1) {
- logger.throwArgumentError("invalid BlockTag", "blockTag", blockTag);
- }
- return [4 /*yield*/, this._getInternalBlockNumber(100 + 2 * this.pollingInterval)];
- case 2:
- blockNumber = _a.sent();
- blockNumber += blockTag;
- if (blockNumber < 0) {
- blockNumber = 0;
- }
- return [2 /*return*/, this.formatter.blockTag(blockNumber)];
- case 3: return [2 /*return*/, this.formatter.blockTag(blockTag)];
- }
- });
- });
- };
- BaseProvider.prototype.getResolver = function (name) {
- return __awaiter(this, void 0, void 0, function () {
- var currentName, addr, resolver, _a;
- return __generator(this, function (_b) {
- switch (_b.label) {
- case 0:
- currentName = name;
- _b.label = 1;
- case 1:
- if (!true) return [3 /*break*/, 6];
- if (currentName === "" || currentName === ".") {
- return [2 /*return*/, null];
- }
- // Optimization since the eth node cannot change and does
- // not have a wildcar resolver
- if (name !== "eth" && currentName === "eth") {
- return [2 /*return*/, null];
- }
- return [4 /*yield*/, this._getResolver(currentName, "getResolver")];
- case 2:
- addr = _b.sent();
- if (!(addr != null)) return [3 /*break*/, 5];
- resolver = new Resolver(this, addr, name);
- _a = currentName !== name;
- if (!_a) return [3 /*break*/, 4];
- return [4 /*yield*/, resolver.supportsWildcard()];
- case 3:
- _a = !(_b.sent());
- _b.label = 4;
- case 4:
- // Legacy resolver found, using EIP-2544 so it isn't safe to use
- if (_a) {
- return [2 /*return*/, null];
- }
- return [2 /*return*/, resolver];
- case 5:
- // Get the parent node
- currentName = currentName.split(".").slice(1).join(".");
- return [3 /*break*/, 1];
- case 6: return [2 /*return*/];
- }
- });
- });
- };
- BaseProvider.prototype._getResolver = function (name, operation) {
- return __awaiter(this, void 0, void 0, function () {
- var network, addrData, error_10;
- return __generator(this, function (_a) {
- switch (_a.label) {
- case 0:
- if (operation == null) {
- operation = "ENS";
- }
- return [4 /*yield*/, this.getNetwork()];
- case 1:
- network = _a.sent();
- // No ENS...
- if (!network.ensAddress) {
- logger.throwError("network does not support ENS", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { operation: operation, network: network.name });
- }
- _a.label = 2;
- case 2:
- _a.trys.push([2, 4, , 5]);
- return [4 /*yield*/, this.call({
- to: network.ensAddress,
- data: ("0x0178b8bf" + (0, hash_1.namehash)(name).substring(2))
- })];
- case 3:
- addrData = _a.sent();
- return [2 /*return*/, this.formatter.callAddress(addrData)];
- case 4:
- error_10 = _a.sent();
- return [3 /*break*/, 5];
- case 5: return [2 /*return*/, null];
- }
- });
- });
- };
- BaseProvider.prototype.resolveName = function (name) {
- return __awaiter(this, void 0, void 0, function () {
- var resolver;
- return __generator(this, function (_a) {
- switch (_a.label) {
- case 0: return [4 /*yield*/, name];
- case 1:
- name = _a.sent();
- // If it is already an address, nothing to resolve
- try {
- return [2 /*return*/, Promise.resolve(this.formatter.address(name))];
- }
- catch (error) {
- // If is is a hexstring, the address is bad (See #694)
- if ((0, bytes_1.isHexString)(name)) {
- throw error;
- }
- }
- if (typeof (name) !== "string") {
- logger.throwArgumentError("invalid ENS name", "name", name);
- }
- return [4 /*yield*/, this.getResolver(name)];
- case 2:
- resolver = _a.sent();
- if (!resolver) {
- return [2 /*return*/, null];
- }
- return [4 /*yield*/, resolver.getAddress()];
- case 3: return [2 /*return*/, _a.sent()];
- }
- });
- });
- };
- BaseProvider.prototype.lookupAddress = function (address) {
- return __awaiter(this, void 0, void 0, function () {
- var node, resolverAddr, name, _a, addr;
- return __generator(this, function (_b) {
- switch (_b.label) {
- case 0: return [4 /*yield*/, address];
- case 1:
- address = _b.sent();
- address = this.formatter.address(address);
- node = address.substring(2).toLowerCase() + ".addr.reverse";
- return [4 /*yield*/, this._getResolver(node, "lookupAddress")];
- case 2:
- resolverAddr = _b.sent();
- if (resolverAddr == null) {
- return [2 /*return*/, null];
- }
- _a = _parseString;
- return [4 /*yield*/, this.call({
- to: resolverAddr,
- data: ("0x691f3431" + (0, hash_1.namehash)(node).substring(2))
- })];
- case 3:
- name = _a.apply(void 0, [_b.sent(), 0]);
- return [4 /*yield*/, this.resolveName(name)];
- case 4:
- addr = _b.sent();
- if (addr != address) {
- return [2 /*return*/, null];
- }
- return [2 /*return*/, name];
- }
- });
- });
- };
- BaseProvider.prototype.getAvatar = function (nameOrAddress) {
- return __awaiter(this, void 0, void 0, function () {
- var resolver, address, node, resolverAddress, avatar_1, error_11, name_1, _a, error_12, avatar;
- return __generator(this, function (_b) {
- switch (_b.label) {
- case 0:
- resolver = null;
- if (!(0, bytes_1.isHexString)(nameOrAddress)) return [3 /*break*/, 10];
- address = this.formatter.address(nameOrAddress);
- node = address.substring(2).toLowerCase() + ".addr.reverse";
- return [4 /*yield*/, this._getResolver(node, "getAvatar")];
- case 1:
- resolverAddress = _b.sent();
- if (!resolverAddress) {
- return [2 /*return*/, null];
- }
- // Try resolving the avatar against the addr.reverse resolver
- resolver = new Resolver(this, resolverAddress, node);
- _b.label = 2;
- case 2:
- _b.trys.push([2, 4, , 5]);
- return [4 /*yield*/, resolver.getAvatar()];
- case 3:
- avatar_1 = _b.sent();
- if (avatar_1) {
- return [2 /*return*/, avatar_1.url];
- }
- return [3 /*break*/, 5];
- case 4:
- error_11 = _b.sent();
- if (error_11.code !== logger_1.Logger.errors.CALL_EXCEPTION) {
- throw error_11;
- }
- return [3 /*break*/, 5];
- case 5:
- _b.trys.push([5, 8, , 9]);
- _a = _parseString;
- return [4 /*yield*/, this.call({
- to: resolverAddress,
- data: ("0x691f3431" + (0, hash_1.namehash)(node).substring(2))
- })];
- case 6:
- name_1 = _a.apply(void 0, [_b.sent(), 0]);
- return [4 /*yield*/, this.getResolver(name_1)];
- case 7:
- resolver = _b.sent();
- return [3 /*break*/, 9];
- case 8:
- error_12 = _b.sent();
- if (error_12.code !== logger_1.Logger.errors.CALL_EXCEPTION) {
- throw error_12;
- }
- return [2 /*return*/, null];
- case 9: return [3 /*break*/, 12];
- case 10: return [4 /*yield*/, this.getResolver(nameOrAddress)];
- case 11:
- // ENS name; forward lookup with wildcard
- resolver = _b.sent();
- if (!resolver) {
- return [2 /*return*/, null];
- }
- _b.label = 12;
- case 12: return [4 /*yield*/, resolver.getAvatar()];
- case 13:
- avatar = _b.sent();
- if (avatar == null) {
- return [2 /*return*/, null];
- }
- return [2 /*return*/, avatar.url];
- }
- });
- });
- };
- BaseProvider.prototype.perform = function (method, params) {
- return logger.throwError(method + " not implemented", logger_1.Logger.errors.NOT_IMPLEMENTED, { operation: method });
- };
- BaseProvider.prototype._startEvent = function (event) {
- this.polling = (this._events.filter(function (e) { return e.pollable(); }).length > 0);
- };
- BaseProvider.prototype._stopEvent = function (event) {
- this.polling = (this._events.filter(function (e) { return e.pollable(); }).length > 0);
- };
- BaseProvider.prototype._addEventListener = function (eventName, listener, once) {
- var event = new Event(getEventTag(eventName), listener, once);
- this._events.push(event);
- this._startEvent(event);
- return this;
- };
- BaseProvider.prototype.on = function (eventName, listener) {
- return this._addEventListener(eventName, listener, false);
- };
- BaseProvider.prototype.once = function (eventName, listener) {
- return this._addEventListener(eventName, listener, true);
- };
- BaseProvider.prototype.emit = function (eventName) {
- var _this = this;
- var args = [];
- for (var _i = 1; _i < arguments.length; _i++) {
- args[_i - 1] = arguments[_i];
- }
- var result = false;
- var stopped = [];
- var eventTag = getEventTag(eventName);
- this._events = this._events.filter(function (event) {
- if (event.tag !== eventTag) {
- return true;
- }
- setTimeout(function () {
- event.listener.apply(_this, args);
- }, 0);
- result = true;
- if (event.once) {
- stopped.push(event);
- return false;
- }
- return true;
- });
- stopped.forEach(function (event) { _this._stopEvent(event); });
- return result;
- };
- BaseProvider.prototype.listenerCount = function (eventName) {
- if (!eventName) {
- return this._events.length;
- }
- var eventTag = getEventTag(eventName);
- return this._events.filter(function (event) {
- return (event.tag === eventTag);
- }).length;
- };
- BaseProvider.prototype.listeners = function (eventName) {
- if (eventName == null) {
- return this._events.map(function (event) { return event.listener; });
- }
- var eventTag = getEventTag(eventName);
- return this._events
- .filter(function (event) { return (event.tag === eventTag); })
- .map(function (event) { return event.listener; });
- };
- BaseProvider.prototype.off = function (eventName, listener) {
- var _this = this;
- if (listener == null) {
- return this.removeAllListeners(eventName);
- }
- var stopped = [];
- var found = false;
- var eventTag = getEventTag(eventName);
- this._events = this._events.filter(function (event) {
- if (event.tag !== eventTag || event.listener != listener) {
- return true;
- }
- if (found) {
- return true;
- }
- found = true;
- stopped.push(event);
- return false;
- });
- stopped.forEach(function (event) { _this._stopEvent(event); });
- return this;
- };
- BaseProvider.prototype.removeAllListeners = function (eventName) {
- var _this = this;
- var stopped = [];
- if (eventName == null) {
- stopped = this._events;
- this._events = [];
- }
- else {
- var eventTag_1 = getEventTag(eventName);
- this._events = this._events.filter(function (event) {
- if (event.tag !== eventTag_1) {
- return true;
- }
- stopped.push(event);
- return false;
- });
- }
- stopped.forEach(function (event) { _this._stopEvent(event); });
- return this;
- };
- return BaseProvider;
- }(abstract_provider_1.Provider));
- exports.BaseProvider = BaseProvider;
- },{"./_version":230,"./formatter":238,"@ethersproject/abstract-provider":185,"@ethersproject/basex":192,"@ethersproject/bignumber":196,"@ethersproject/bytes":199,"@ethersproject/constants":203,"@ethersproject/hash":209,"@ethersproject/logger":223,"@ethersproject/networks":225,"@ethersproject/properties":229,"@ethersproject/sha2":256,"@ethersproject/strings":266,"@ethersproject/web":276,"bech32":321}],233:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.IpcProvider = void 0;
- var IpcProvider = null;
- exports.IpcProvider = IpcProvider;
- },{}],234:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.WebSocket = void 0;
- var logger_1 = _dereq_("@ethersproject/logger");
- var _version_1 = _dereq_("./_version");
- var WS = null;
- exports.WebSocket = WS;
- try {
- exports.WebSocket = WS = WebSocket;
- if (WS == null) {
- throw new Error("inject please");
- }
- }
- catch (error) {
- var logger_2 = new logger_1.Logger(_version_1.version);
- exports.WebSocket = WS = function () {
- logger_2.throwError("WebSockets not supported in this environment", logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
- operation: "new WebSocket()"
- });
- };
- }
- },{"./_version":230,"@ethersproject/logger":223}],235:[function(_dereq_,module,exports){
- "use strict";
- var __extends = (this && this.__extends) || (function () {
- var extendStatics = function (d, b) {
- extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
- return extendStatics(d, b);
- };
- return function (d, b) {
- if (typeof b !== "function" && b !== null)
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
- return new (P || (P = Promise))(function (resolve, reject) {
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
- step((generator = generator.apply(thisArg, _arguments || [])).next());
- });
- };
- var __generator = (this && this.__generator) || function (thisArg, body) {
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
- function verb(n) { return function (v) { return step([n, v]); }; }
- function step(op) {
- if (f) throw new TypeError("Generator is already executing.");
- while (_) try {
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
- if (y = 0, t) op = [op[0] & 2, t.value];
- switch (op[0]) {
- case 0: case 1: t = op; break;
- case 4: _.label++; return { value: op[1], done: false };
- case 5: _.label++; y = op[1]; op = [0]; continue;
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
- default:
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
- if (t[2]) _.ops.pop();
- _.trys.pop(); continue;
- }
- op = body.call(thisArg, _);
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
- }
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.CloudflareProvider = void 0;
- var url_json_rpc_provider_1 = _dereq_("./url-json-rpc-provider");
- var logger_1 = _dereq_("@ethersproject/logger");
- var _version_1 = _dereq_("./_version");
- var logger = new logger_1.Logger(_version_1.version);
- var CloudflareProvider = /** @class */ (function (_super) {
- __extends(CloudflareProvider, _super);
- function CloudflareProvider() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- CloudflareProvider.getApiKey = function (apiKey) {
- if (apiKey != null) {
- logger.throwArgumentError("apiKey not supported for cloudflare", "apiKey", apiKey);
- }
- return null;
- };
- CloudflareProvider.getUrl = function (network, apiKey) {
- var host = null;
- switch (network.name) {
- case "homestead":
- host = "https://cloudflare-eth.com/";
- break;
- default:
- logger.throwArgumentError("unsupported network", "network", arguments[0]);
- }
- return host;
- };
- CloudflareProvider.prototype.perform = function (method, params) {
- return __awaiter(this, void 0, void 0, function () {
- var block;
- return __generator(this, function (_a) {
- switch (_a.label) {
- case 0:
- if (!(method === "getBlockNumber")) return [3 /*break*/, 2];
- return [4 /*yield*/, _super.prototype.perform.call(this, "getBlock", { blockTag: "latest" })];
- case 1:
- block = _a.sent();
- return [2 /*return*/, block.number];
- case 2: return [2 /*return*/, _super.prototype.perform.call(this, method, params)];
- }
- });
- });
- };
- return CloudflareProvider;
- }(url_json_rpc_provider_1.UrlJsonRpcProvider));
- exports.CloudflareProvider = CloudflareProvider;
- },{"./_version":230,"./url-json-rpc-provider":245,"@ethersproject/logger":223}],236:[function(_dereq_,module,exports){
- "use strict";
- var __extends = (this && this.__extends) || (function () {
- var extendStatics = function (d, b) {
- extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
- return extendStatics(d, b);
- };
- return function (d, b) {
- if (typeof b !== "function" && b !== null)
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
- return new (P || (P = Promise))(function (resolve, reject) {
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
- step((generator = generator.apply(thisArg, _arguments || [])).next());
- });
- };
- var __generator = (this && this.__generator) || function (thisArg, body) {
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
- function verb(n) { return function (v) { return step([n, v]); }; }
- function step(op) {
- if (f) throw new TypeError("Generator is already executing.");
- while (_) try {
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
- if (y = 0, t) op = [op[0] & 2, t.value];
- switch (op[0]) {
- case 0: case 1: t = op; break;
- case 4: _.label++; return { value: op[1], done: false };
- case 5: _.label++; y = op[1]; op = [0]; continue;
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
- default:
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
- if (t[2]) _.ops.pop();
- _.trys.pop(); continue;
- }
- op = body.call(thisArg, _);
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
- }
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.EtherscanProvider = void 0;
- var bytes_1 = _dereq_("@ethersproject/bytes");
- var properties_1 = _dereq_("@ethersproject/properties");
- var transactions_1 = _dereq_("@ethersproject/transactions");
- var web_1 = _dereq_("@ethersproject/web");
- var formatter_1 = _dereq_("./formatter");
- var logger_1 = _dereq_("@ethersproject/logger");
- var _version_1 = _dereq_("./_version");
- var logger = new logger_1.Logger(_version_1.version);
- var base_provider_1 = _dereq_("./base-provider");
- // The transaction has already been sanitized by the calls in Provider
- function getTransactionPostData(transaction) {
- var result = {};
- for (var key in transaction) {
- if (transaction[key] == null) {
- continue;
- }
- var value = transaction[key];
- if (key === "type" && value === 0) {
- continue;
- }
- // Quantity-types require no leading zero, unless 0
- if ({ type: true, gasLimit: true, gasPrice: true, maxFeePerGs: true, maxPriorityFeePerGas: true, nonce: true, value: true }[key]) {
- value = (0, bytes_1.hexValue)((0, bytes_1.hexlify)(value));
- }
- else if (key === "accessList") {
- value = "[" + (0, transactions_1.accessListify)(value).map(function (set) {
- return "{address:\"" + set.address + "\",storageKeys:[\"" + set.storageKeys.join('","') + "\"]}";
- }).join(",") + "]";
- }
- else {
- value = (0, bytes_1.hexlify)(value);
- }
- result[key] = value;
- }
- return result;
- }
- function getResult(result) {
- // getLogs, getHistory have weird success responses
- if (result.status == 0 && (result.message === "No records found" || result.message === "No transactions found")) {
- return result.result;
- }
- if (result.status != 1 || result.message != "OK") {
- var error = new Error("invalid response");
- error.result = JSON.stringify(result);
- if ((result.result || "").toLowerCase().indexOf("rate limit") >= 0) {
- error.throttleRetry = true;
- }
- throw error;
- }
- return result.result;
- }
- function getJsonResult(result) {
- // This response indicates we are being throttled
- if (result && result.status == 0 && result.message == "NOTOK" && (result.result || "").toLowerCase().indexOf("rate limit") >= 0) {
- var error = new Error("throttled response");
- error.result = JSON.stringify(result);
- error.throttleRetry = true;
- throw error;
- }
- if (result.jsonrpc != "2.0") {
- // @TODO: not any
- var error = new Error("invalid response");
- error.result = JSON.stringify(result);
- throw error;
- }
- if (result.error) {
- // @TODO: not any
- var error = new Error(result.error.message || "unknown error");
- if (result.error.code) {
- error.code = result.error.code;
- }
- if (result.error.data) {
- error.data = result.error.data;
- }
- throw error;
- }
- return result.result;
- }
- // The blockTag was normalized as a string by the Provider pre-perform operations
- function checkLogTag(blockTag) {
- if (blockTag === "pending") {
- throw new Error("pending not supported");
- }
- if (blockTag === "latest") {
- return blockTag;
- }
- return parseInt(blockTag.substring(2), 16);
- }
- var defaultApiKey = "9D13ZE7XSBTJ94N9BNJ2MA33VMAY2YPIRB";
- function checkError(method, error, transaction) {
- // Undo the "convenience" some nodes are attempting to prevent backwards
- // incompatibility; maybe for v6 consider forwarding reverts as errors
- if (method === "call" && error.code === logger_1.Logger.errors.SERVER_ERROR) {
- var e = error.error;
- // Etherscan keeps changing their string
- if (e && (e.message.match(/reverted/i) || e.message.match(/VM execution error/i))) {
- // Etherscan prefixes the data like "Reverted 0x1234"
- var data = e.data;
- if (data) {
- data = "0x" + data.replace(/^.*0x/i, "");
- }
- if ((0, bytes_1.isHexString)(data)) {
- return data;
- }
- logger.throwError("missing revert data in call exception", logger_1.Logger.errors.CALL_EXCEPTION, {
- error: error,
- data: "0x"
- });
- }
- }
- // Get the message from any nested error structure
- var message = error.message;
- if (error.code === logger_1.Logger.errors.SERVER_ERROR) {
- if (error.error && typeof (error.error.message) === "string") {
- message = error.error.message;
- }
- else if (typeof (error.body) === "string") {
- message = error.body;
- }
- else if (typeof (error.responseText) === "string") {
- message = error.responseText;
- }
- }
- message = (message || "").toLowerCase();
- // "Insufficient funds. The account you tried to send transaction from does not have enough funds. Required 21464000000000 and got: 0"
- if (message.match(/insufficient funds/)) {
- logger.throwError("insufficient funds for intrinsic transaction cost", logger_1.Logger.errors.INSUFFICIENT_FUNDS, {
- error: error,
- method: method,
- transaction: transaction
- });
- }
- // "Transaction with the same hash was already imported."
- if (message.match(/same hash was already imported|transaction nonce is too low|nonce too low/)) {
- logger.throwError("nonce has already been used", logger_1.Logger.errors.NONCE_EXPIRED, {
- error: error,
- method: method,
- transaction: transaction
- });
- }
- // "Transaction gas price is too low. There is another transaction with same nonce in the queue. Try increasing the gas price or incrementing the nonce."
- if (message.match(/another transaction with same nonce/)) {
- logger.throwError("replacement fee too low", logger_1.Logger.errors.REPLACEMENT_UNDERPRICED, {
- error: error,
- method: method,
- transaction: transaction
- });
- }
- if (message.match(/execution failed due to an exception|execution reverted/)) {
- logger.throwError("cannot estimate gas; transaction may fail or may require manual gas limit", logger_1.Logger.errors.UNPREDICTABLE_GAS_LIMIT, {
- error: error,
- method: method,
- transaction: transaction
- });
- }
- throw error;
- }
- var EtherscanProvider = /** @class */ (function (_super) {
- __extends(EtherscanProvider, _super);
- function EtherscanProvider(network, apiKey) {
- var _newTarget = this.constructor;
- var _this = this;
- logger.checkNew(_newTarget, EtherscanProvider);
- _this = _super.call(this, network) || this;
- (0, properties_1.defineReadOnly)(_this, "baseUrl", _this.getBaseUrl());
- (0, properties_1.defineReadOnly)(_this, "apiKey", apiKey || defaultApiKey);
- return _this;
- }
- EtherscanProvider.prototype.getBaseUrl = function () {
- switch (this.network ? this.network.name : "invalid") {
- case "homestead":
- return "https:/\/api.etherscan.io";
- case "ropsten":
- return "https:/\/api-ropsten.etherscan.io";
- case "rinkeby":
- return "https:/\/api-rinkeby.etherscan.io";
- case "kovan":
- return "https:/\/api-kovan.etherscan.io";
- case "goerli":
- return "https:/\/api-goerli.etherscan.io";
- default:
- }
- return logger.throwArgumentError("unsupported network", "network", name);
- };
- EtherscanProvider.prototype.getUrl = function (module, params) {
- var query = Object.keys(params).reduce(function (accum, key) {
- var value = params[key];
- if (value != null) {
- accum += "&" + key + "=" + value;
- }
- return accum;
- }, "");
- var apiKey = ((this.apiKey) ? "&apikey=" + this.apiKey : "");
- return this.baseUrl + "/api?module=" + module + query + apiKey;
- };
- EtherscanProvider.prototype.getPostUrl = function () {
- return this.baseUrl + "/api";
- };
- EtherscanProvider.prototype.getPostData = function (module, params) {
- params.module = module;
- params.apikey = this.apiKey;
- return params;
- };
- EtherscanProvider.prototype.fetch = function (module, params, post) {
- return __awaiter(this, void 0, void 0, function () {
- var url, payload, procFunc, connection, payloadStr, result;
- var _this = this;
- return __generator(this, function (_a) {
- switch (_a.label) {
- case 0:
- url = (post ? this.getPostUrl() : this.getUrl(module, params));
- payload = (post ? this.getPostData(module, params) : null);
- procFunc = (module === "proxy") ? getJsonResult : getResult;
- this.emit("debug", {
- action: "request",
- request: url,
- provider: this
- });
- connection = {
- url: url,
- throttleSlotInterval: 1000,
- throttleCallback: function (attempt, url) {
- if (_this.isCommunityResource()) {
- (0, formatter_1.showThrottleMessage)();
- }
- return Promise.resolve(true);
- }
- };
- payloadStr = null;
- if (payload) {
- connection.headers = { "content-type": "application/x-www-form-urlencoded; charset=UTF-8" };
- payloadStr = Object.keys(payload).map(function (key) {
- return key + "=" + payload[key];
- }).join("&");
- }
- return [4 /*yield*/, (0, web_1.fetchJson)(connection, payloadStr, procFunc || getJsonResult)];
- case 1:
- result = _a.sent();
- this.emit("debug", {
- action: "response",
- request: url,
- response: (0, properties_1.deepCopy)(result),
- provider: this
- });
- return [2 /*return*/, result];
- }
- });
- });
- };
- EtherscanProvider.prototype.detectNetwork = function () {
- return __awaiter(this, void 0, void 0, function () {
- return __generator(this, function (_a) {
- return [2 /*return*/, this.network];
- });
- });
- };
- EtherscanProvider.prototype.perform = function (method, params) {
- return __awaiter(this, void 0, void 0, function () {
- var _a, postData, error_1, postData, error_2, args, topic0, logs, blocks, i, log, block, _b;
- return __generator(this, function (_c) {
- switch (_c.label) {
- case 0:
- _a = method;
- switch (_a) {
- case "getBlockNumber": return [3 /*break*/, 1];
- case "getGasPrice": return [3 /*break*/, 2];
- case "getBalance": return [3 /*break*/, 3];
- case "getTransactionCount": return [3 /*break*/, 4];
- case "getCode": return [3 /*break*/, 5];
- case "getStorageAt": return [3 /*break*/, 6];
- case "sendTransaction": return [3 /*break*/, 7];
- case "getBlock": return [3 /*break*/, 8];
- case "getTransaction": return [3 /*break*/, 9];
- case "getTransactionReceipt": return [3 /*break*/, 10];
- case "call": return [3 /*break*/, 11];
- case "estimateGas": return [3 /*break*/, 15];
- case "getLogs": return [3 /*break*/, 19];
- case "getEtherPrice": return [3 /*break*/, 26];
- }
- return [3 /*break*/, 28];
- case 1: return [2 /*return*/, this.fetch("proxy", { action: "eth_blockNumber" })];
- case 2: return [2 /*return*/, this.fetch("proxy", { action: "eth_gasPrice" })];
- case 3:
- // Returns base-10 result
- return [2 /*return*/, this.fetch("account", {
- action: "balance",
- address: params.address,
- tag: params.blockTag
- })];
- case 4: return [2 /*return*/, this.fetch("proxy", {
- action: "eth_getTransactionCount",
- address: params.address,
- tag: params.blockTag
- })];
- case 5: return [2 /*return*/, this.fetch("proxy", {
- action: "eth_getCode",
- address: params.address,
- tag: params.blockTag
- })];
- case 6: return [2 /*return*/, this.fetch("proxy", {
- action: "eth_getStorageAt",
- address: params.address,
- position: params.position,
- tag: params.blockTag
- })];
- case 7: return [2 /*return*/, this.fetch("proxy", {
- action: "eth_sendRawTransaction",
- hex: params.signedTransaction
- }, true).catch(function (error) {
- return checkError("sendTransaction", error, params.signedTransaction);
- })];
- case 8:
- if (params.blockTag) {
- return [2 /*return*/, this.fetch("proxy", {
- action: "eth_getBlockByNumber",
- tag: params.blockTag,
- boolean: (params.includeTransactions ? "true" : "false")
- })];
- }
- throw new Error("getBlock by blockHash not implemented");
- case 9: return [2 /*return*/, this.fetch("proxy", {
- action: "eth_getTransactionByHash",
- txhash: params.transactionHash
- })];
- case 10: return [2 /*return*/, this.fetch("proxy", {
- action: "eth_getTransactionReceipt",
- txhash: params.transactionHash
- })];
- case 11:
- if (params.blockTag !== "latest") {
- throw new Error("EtherscanProvider does not support blockTag for call");
- }
- postData = getTransactionPostData(params.transaction);
- postData.module = "proxy";
- postData.action = "eth_call";
- _c.label = 12;
- case 12:
- _c.trys.push([12, 14, , 15]);
- return [4 /*yield*/, this.fetch("proxy", postData, true)];
- case 13: return [2 /*return*/, _c.sent()];
- case 14:
- error_1 = _c.sent();
- return [2 /*return*/, checkError("call", error_1, params.transaction)];
- case 15:
- postData = getTransactionPostData(params.transaction);
- postData.module = "proxy";
- postData.action = "eth_estimateGas";
- _c.label = 16;
- case 16:
- _c.trys.push([16, 18, , 19]);
- return [4 /*yield*/, this.fetch("proxy", postData, true)];
- case 17: return [2 /*return*/, _c.sent()];
- case 18:
- error_2 = _c.sent();
- return [2 /*return*/, checkError("estimateGas", error_2, params.transaction)];
- case 19:
- args = { action: "getLogs" };
- if (params.filter.fromBlock) {
- args.fromBlock = checkLogTag(params.filter.fromBlock);
- }
- if (params.filter.toBlock) {
- args.toBlock = checkLogTag(params.filter.toBlock);
- }
- if (params.filter.address) {
- args.address = params.filter.address;
- }
- // @TODO: We can handle slightly more complicated logs using the logs API
- if (params.filter.topics && params.filter.topics.length > 0) {
- if (params.filter.topics.length > 1) {
- logger.throwError("unsupported topic count", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { topics: params.filter.topics });
- }
- if (params.filter.topics.length === 1) {
- topic0 = params.filter.topics[0];
- if (typeof (topic0) !== "string" || topic0.length !== 66) {
- logger.throwError("unsupported topic format", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { topic0: topic0 });
- }
- args.topic0 = topic0;
- }
- }
- return [4 /*yield*/, this.fetch("logs", args)];
- case 20:
- logs = _c.sent();
- blocks = {};
- i = 0;
- _c.label = 21;
- case 21:
- if (!(i < logs.length)) return [3 /*break*/, 25];
- log = logs[i];
- if (log.blockHash != null) {
- return [3 /*break*/, 24];
- }
- if (!(blocks[log.blockNumber] == null)) return [3 /*break*/, 23];
- return [4 /*yield*/, this.getBlock(log.blockNumber)];
- case 22:
- block = _c.sent();
- if (block) {
- blocks[log.blockNumber] = block.hash;
- }
- _c.label = 23;
- case 23:
- log.blockHash = blocks[log.blockNumber];
- _c.label = 24;
- case 24:
- i++;
- return [3 /*break*/, 21];
- case 25: return [2 /*return*/, logs];
- case 26:
- if (this.network.name !== "homestead") {
- return [2 /*return*/, 0.0];
- }
- _b = parseFloat;
- return [4 /*yield*/, this.fetch("stats", { action: "ethprice" })];
- case 27: return [2 /*return*/, _b.apply(void 0, [(_c.sent()).ethusd])];
- case 28: return [3 /*break*/, 29];
- case 29: return [2 /*return*/, _super.prototype.perform.call(this, method, params)];
- }
- });
- });
- };
- // Note: The `page` page parameter only allows pagination within the
- // 10,000 window available without a page and offset parameter
- // Error: Result window is too large, PageNo x Offset size must
- // be less than or equal to 10000
- EtherscanProvider.prototype.getHistory = function (addressOrName, startBlock, endBlock) {
- return __awaiter(this, void 0, void 0, function () {
- var params, result;
- var _a;
- var _this = this;
- return __generator(this, function (_b) {
- switch (_b.label) {
- case 0:
- _a = {
- action: "txlist"
- };
- return [4 /*yield*/, this.resolveName(addressOrName)];
- case 1:
- params = (_a.address = (_b.sent()),
- _a.startblock = ((startBlock == null) ? 0 : startBlock),
- _a.endblock = ((endBlock == null) ? 99999999 : endBlock),
- _a.sort = "asc",
- _a);
- return [4 /*yield*/, this.fetch("account", params)];
- case 2:
- result = _b.sent();
- return [2 /*return*/, result.map(function (tx) {
- ["contractAddress", "to"].forEach(function (key) {
- if (tx[key] == "") {
- delete tx[key];
- }
- });
- if (tx.creates == null && tx.contractAddress != null) {
- tx.creates = tx.contractAddress;
- }
- var item = _this.formatter.transactionResponse(tx);
- if (tx.timeStamp) {
- item.timestamp = parseInt(tx.timeStamp);
- }
- return item;
- })];
- }
- });
- });
- };
- EtherscanProvider.prototype.isCommunityResource = function () {
- return (this.apiKey === defaultApiKey);
- };
- return EtherscanProvider;
- }(base_provider_1.BaseProvider));
- exports.EtherscanProvider = EtherscanProvider;
- },{"./_version":230,"./base-provider":232,"./formatter":238,"@ethersproject/bytes":199,"@ethersproject/logger":223,"@ethersproject/properties":229,"@ethersproject/transactions":269,"@ethersproject/web":276}],237:[function(_dereq_,module,exports){
- "use strict";
- var __extends = (this && this.__extends) || (function () {
- var extendStatics = function (d, b) {
- extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
- return extendStatics(d, b);
- };
- return function (d, b) {
- if (typeof b !== "function" && b !== null)
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
- return new (P || (P = Promise))(function (resolve, reject) {
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
- step((generator = generator.apply(thisArg, _arguments || [])).next());
- });
- };
- var __generator = (this && this.__generator) || function (thisArg, body) {
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
- function verb(n) { return function (v) { return step([n, v]); }; }
- function step(op) {
- if (f) throw new TypeError("Generator is already executing.");
- while (_) try {
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
- if (y = 0, t) op = [op[0] & 2, t.value];
- switch (op[0]) {
- case 0: case 1: t = op; break;
- case 4: _.label++; return { value: op[1], done: false };
- case 5: _.label++; y = op[1]; op = [0]; continue;
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
- default:
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
- if (t[2]) _.ops.pop();
- _.trys.pop(); continue;
- }
- op = body.call(thisArg, _);
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
- }
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.FallbackProvider = void 0;
- var abstract_provider_1 = _dereq_("@ethersproject/abstract-provider");
- var bignumber_1 = _dereq_("@ethersproject/bignumber");
- var bytes_1 = _dereq_("@ethersproject/bytes");
- var properties_1 = _dereq_("@ethersproject/properties");
- var random_1 = _dereq_("@ethersproject/random");
- var web_1 = _dereq_("@ethersproject/web");
- var base_provider_1 = _dereq_("./base-provider");
- var formatter_1 = _dereq_("./formatter");
- var logger_1 = _dereq_("@ethersproject/logger");
- var _version_1 = _dereq_("./_version");
- var logger = new logger_1.Logger(_version_1.version);
- function now() { return (new Date()).getTime(); }
- // Returns to network as long as all agree, or null if any is null.
- // Throws an error if any two networks do not match.
- function checkNetworks(networks) {
- var result = null;
- for (var i = 0; i < networks.length; i++) {
- var network = networks[i];
- // Null! We do not know our network; bail.
- if (network == null) {
- return null;
- }
- if (result) {
- // Make sure the network matches the previous networks
- if (!(result.name === network.name && result.chainId === network.chainId &&
- ((result.ensAddress === network.ensAddress) || (result.ensAddress == null && network.ensAddress == null)))) {
- logger.throwArgumentError("provider mismatch", "networks", networks);
- }
- }
- else {
- result = network;
- }
- }
- return result;
- }
- function median(values, maxDelta) {
- values = values.slice().sort();
- var middle = Math.floor(values.length / 2);
- // Odd length; take the middle
- if (values.length % 2) {
- return values[middle];
- }
- // Even length; take the average of the two middle
- var a = values[middle - 1], b = values[middle];
- if (maxDelta != null && Math.abs(a - b) > maxDelta) {
- return null;
- }
- return (a + b) / 2;
- }
- function serialize(value) {
- if (value === null) {
- return "null";
- }
- else if (typeof (value) === "number" || typeof (value) === "boolean") {
- return JSON.stringify(value);
- }
- else if (typeof (value) === "string") {
- return value;
- }
- else if (bignumber_1.BigNumber.isBigNumber(value)) {
- return value.toString();
- }
- else if (Array.isArray(value)) {
- return JSON.stringify(value.map(function (i) { return serialize(i); }));
- }
- else if (typeof (value) === "object") {
- var keys = Object.keys(value);
- keys.sort();
- return "{" + keys.map(function (key) {
- var v = value[key];
- if (typeof (v) === "function") {
- v = "[function]";
- }
- else {
- v = serialize(v);
- }
- return JSON.stringify(key) + ":" + v;
- }).join(",") + "}";
- }
- throw new Error("unknown value type: " + typeof (value));
- }
- // Next request ID to use for emitting debug info
- var nextRid = 1;
- ;
- function stall(duration) {
- var cancel = null;
- var timer = null;
- var promise = (new Promise(function (resolve) {
- cancel = function () {
- if (timer) {
- clearTimeout(timer);
- timer = null;
- }
- resolve();
- };
- timer = setTimeout(cancel, duration);
- }));
- var wait = function (func) {
- promise = promise.then(func);
- return promise;
- };
- function getPromise() {
- return promise;
- }
- return { cancel: cancel, getPromise: getPromise, wait: wait };
- }
- var ForwardErrors = [
- logger_1.Logger.errors.CALL_EXCEPTION,
- logger_1.Logger.errors.INSUFFICIENT_FUNDS,
- logger_1.Logger.errors.NONCE_EXPIRED,
- logger_1.Logger.errors.REPLACEMENT_UNDERPRICED,
- logger_1.Logger.errors.UNPREDICTABLE_GAS_LIMIT
- ];
- var ForwardProperties = [
- "address",
- "args",
- "errorArgs",
- "errorSignature",
- "method",
- "transaction",
- ];
- ;
- function exposeDebugConfig(config, now) {
- var result = {
- weight: config.weight
- };
- Object.defineProperty(result, "provider", { get: function () { return config.provider; } });
- if (config.start) {
- result.start = config.start;
- }
- if (now) {
- result.duration = (now - config.start);
- }
- if (config.done) {
- if (config.error) {
- result.error = config.error;
- }
- else {
- result.result = config.result || null;
- }
- }
- return result;
- }
- function normalizedTally(normalize, quorum) {
- return function (configs) {
- // Count the votes for each result
- var tally = {};
- configs.forEach(function (c) {
- var value = normalize(c.result);
- if (!tally[value]) {
- tally[value] = { count: 0, result: c.result };
- }
- tally[value].count++;
- });
- // Check for a quorum on any given result
- var keys = Object.keys(tally);
- for (var i = 0; i < keys.length; i++) {
- var check = tally[keys[i]];
- if (check.count >= quorum) {
- return check.result;
- }
- }
- // No quroum
- return undefined;
- };
- }
- function getProcessFunc(provider, method, params) {
- var normalize = serialize;
- switch (method) {
- case "getBlockNumber":
- // Return the median value, unless there is (median + 1) is also
- // present, in which case that is probably true and the median
- // is going to be stale soon. In the event of a malicious node,
- // the lie will be true soon enough.
- return function (configs) {
- var values = configs.map(function (c) { return c.result; });
- // Get the median block number
- var blockNumber = median(configs.map(function (c) { return c.result; }), 2);
- if (blockNumber == null) {
- return undefined;
- }
- blockNumber = Math.ceil(blockNumber);
- // If the next block height is present, its prolly safe to use
- if (values.indexOf(blockNumber + 1) >= 0) {
- blockNumber++;
- }
- // Don't ever roll back the blockNumber
- if (blockNumber >= provider._highestBlockNumber) {
- provider._highestBlockNumber = blockNumber;
- }
- return provider._highestBlockNumber;
- };
- case "getGasPrice":
- // Return the middle (round index up) value, similar to median
- // but do not average even entries and choose the higher.
- // Malicious actors must compromise 50% of the nodes to lie.
- return function (configs) {
- var values = configs.map(function (c) { return c.result; });
- values.sort();
- return values[Math.floor(values.length / 2)];
- };
- case "getEtherPrice":
- // Returns the median price. Malicious actors must compromise at
- // least 50% of the nodes to lie (in a meaningful way).
- return function (configs) {
- return median(configs.map(function (c) { return c.result; }));
- };
- // No additional normalizing required; serialize is enough
- case "getBalance":
- case "getTransactionCount":
- case "getCode":
- case "getStorageAt":
- case "call":
- case "estimateGas":
- case "getLogs":
- break;
- // We drop the confirmations from transactions as it is approximate
- case "getTransaction":
- case "getTransactionReceipt":
- normalize = function (tx) {
- if (tx == null) {
- return null;
- }
- tx = (0, properties_1.shallowCopy)(tx);
- tx.confirmations = -1;
- return serialize(tx);
- };
- break;
- // We drop the confirmations from transactions as it is approximate
- case "getBlock":
- // We drop the confirmations from transactions as it is approximate
- if (params.includeTransactions) {
- normalize = function (block) {
- if (block == null) {
- return null;
- }
- block = (0, properties_1.shallowCopy)(block);
- block.transactions = block.transactions.map(function (tx) {
- tx = (0, properties_1.shallowCopy)(tx);
- tx.confirmations = -1;
- return tx;
- });
- return serialize(block);
- };
- }
- else {
- normalize = function (block) {
- if (block == null) {
- return null;
- }
- return serialize(block);
- };
- }
- break;
- default:
- throw new Error("unknown method: " + method);
- }
- // Return the result if and only if the expected quorum is
- // satisfied and agreed upon for the final result.
- return normalizedTally(normalize, provider.quorum);
- }
- // If we are doing a blockTag query, we need to make sure the backend is
- // caught up to the FallbackProvider, before sending a request to it.
- function waitForSync(config, blockNumber) {
- return __awaiter(this, void 0, void 0, function () {
- var provider;
- return __generator(this, function (_a) {
- provider = (config.provider);
- if ((provider.blockNumber != null && provider.blockNumber >= blockNumber) || blockNumber === -1) {
- return [2 /*return*/, provider];
- }
- return [2 /*return*/, (0, web_1.poll)(function () {
- return new Promise(function (resolve, reject) {
- setTimeout(function () {
- // We are synced
- if (provider.blockNumber >= blockNumber) {
- return resolve(provider);
- }
- // We're done; just quit
- if (config.cancelled) {
- return resolve(null);
- }
- // Try again, next block
- return resolve(undefined);
- }, 0);
- });
- }, { oncePoll: provider })];
- });
- });
- }
- function getRunner(config, currentBlockNumber, method, params) {
- return __awaiter(this, void 0, void 0, function () {
- var provider, _a, filter;
- return __generator(this, function (_b) {
- switch (_b.label) {
- case 0:
- provider = config.provider;
- _a = method;
- switch (_a) {
- case "getBlockNumber": return [3 /*break*/, 1];
- case "getGasPrice": return [3 /*break*/, 1];
- case "getEtherPrice": return [3 /*break*/, 2];
- case "getBalance": return [3 /*break*/, 3];
- case "getTransactionCount": return [3 /*break*/, 3];
- case "getCode": return [3 /*break*/, 3];
- case "getStorageAt": return [3 /*break*/, 6];
- case "getBlock": return [3 /*break*/, 9];
- case "call": return [3 /*break*/, 12];
- case "estimateGas": return [3 /*break*/, 12];
- case "getTransaction": return [3 /*break*/, 15];
- case "getTransactionReceipt": return [3 /*break*/, 15];
- case "getLogs": return [3 /*break*/, 16];
- }
- return [3 /*break*/, 19];
- case 1: return [2 /*return*/, provider[method]()];
- case 2:
- if (provider.getEtherPrice) {
- return [2 /*return*/, provider.getEtherPrice()];
- }
- return [3 /*break*/, 19];
- case 3:
- if (!(params.blockTag && (0, bytes_1.isHexString)(params.blockTag))) return [3 /*break*/, 5];
- return [4 /*yield*/, waitForSync(config, currentBlockNumber)];
- case 4:
- provider = _b.sent();
- _b.label = 5;
- case 5: return [2 /*return*/, provider[method](params.address, params.blockTag || "latest")];
- case 6:
- if (!(params.blockTag && (0, bytes_1.isHexString)(params.blockTag))) return [3 /*break*/, 8];
- return [4 /*yield*/, waitForSync(config, currentBlockNumber)];
- case 7:
- provider = _b.sent();
- _b.label = 8;
- case 8: return [2 /*return*/, provider.getStorageAt(params.address, params.position, params.blockTag || "latest")];
- case 9:
- if (!(params.blockTag && (0, bytes_1.isHexString)(params.blockTag))) return [3 /*break*/, 11];
- return [4 /*yield*/, waitForSync(config, currentBlockNumber)];
- case 10:
- provider = _b.sent();
- _b.label = 11;
- case 11: return [2 /*return*/, provider[(params.includeTransactions ? "getBlockWithTransactions" : "getBlock")](params.blockTag || params.blockHash)];
- case 12:
- if (!(params.blockTag && (0, bytes_1.isHexString)(params.blockTag))) return [3 /*break*/, 14];
- return [4 /*yield*/, waitForSync(config, currentBlockNumber)];
- case 13:
- provider = _b.sent();
- _b.label = 14;
- case 14: return [2 /*return*/, provider[method](params.transaction)];
- case 15: return [2 /*return*/, provider[method](params.transactionHash)];
- case 16:
- filter = params.filter;
- if (!((filter.fromBlock && (0, bytes_1.isHexString)(filter.fromBlock)) || (filter.toBlock && (0, bytes_1.isHexString)(filter.toBlock)))) return [3 /*break*/, 18];
- return [4 /*yield*/, waitForSync(config, currentBlockNumber)];
- case 17:
- provider = _b.sent();
- _b.label = 18;
- case 18: return [2 /*return*/, provider.getLogs(filter)];
- case 19: return [2 /*return*/, logger.throwError("unknown method error", logger_1.Logger.errors.UNKNOWN_ERROR, {
- method: method,
- params: params
- })];
- }
- });
- });
- }
- var FallbackProvider = /** @class */ (function (_super) {
- __extends(FallbackProvider, _super);
- function FallbackProvider(providers, quorum) {
- var _newTarget = this.constructor;
- var _this = this;
- logger.checkNew(_newTarget, FallbackProvider);
- if (providers.length === 0) {
- logger.throwArgumentError("missing providers", "providers", providers);
- }
- var providerConfigs = providers.map(function (configOrProvider, index) {
- if (abstract_provider_1.Provider.isProvider(configOrProvider)) {
- var stallTimeout = (0, formatter_1.isCommunityResource)(configOrProvider) ? 2000 : 750;
- var priority = 1;
- return Object.freeze({ provider: configOrProvider, weight: 1, stallTimeout: stallTimeout, priority: priority });
- }
- var config = (0, properties_1.shallowCopy)(configOrProvider);
- if (config.priority == null) {
- config.priority = 1;
- }
- if (config.stallTimeout == null) {
- config.stallTimeout = (0, formatter_1.isCommunityResource)(configOrProvider) ? 2000 : 750;
- }
- if (config.weight == null) {
- config.weight = 1;
- }
- var weight = config.weight;
- if (weight % 1 || weight > 512 || weight < 1) {
- logger.throwArgumentError("invalid weight; must be integer in [1, 512]", "providers[" + index + "].weight", weight);
- }
- return Object.freeze(config);
- });
- var total = providerConfigs.reduce(function (accum, c) { return (accum + c.weight); }, 0);
- if (quorum == null) {
- quorum = total / 2;
- }
- else if (quorum > total) {
- logger.throwArgumentError("quorum will always fail; larger than total weight", "quorum", quorum);
- }
- // Are all providers' networks are known
- var networkOrReady = checkNetworks(providerConfigs.map(function (c) { return (c.provider).network; }));
- // Not all networks are known; we must stall
- if (networkOrReady == null) {
- networkOrReady = new Promise(function (resolve, reject) {
- setTimeout(function () {
- _this.detectNetwork().then(resolve, reject);
- }, 0);
- });
- }
- _this = _super.call(this, networkOrReady) || this;
- // Preserve a copy, so we do not get mutated
- (0, properties_1.defineReadOnly)(_this, "providerConfigs", Object.freeze(providerConfigs));
- (0, properties_1.defineReadOnly)(_this, "quorum", quorum);
- _this._highestBlockNumber = -1;
- return _this;
- }
- FallbackProvider.prototype.detectNetwork = function () {
- return __awaiter(this, void 0, void 0, function () {
- var networks;
- return __generator(this, function (_a) {
- switch (_a.label) {
- case 0: return [4 /*yield*/, Promise.all(this.providerConfigs.map(function (c) { return c.provider.getNetwork(); }))];
- case 1:
- networks = _a.sent();
- return [2 /*return*/, checkNetworks(networks)];
- }
- });
- });
- };
- FallbackProvider.prototype.perform = function (method, params) {
- return __awaiter(this, void 0, void 0, function () {
- var results, i_1, result, processFunc, configs, currentBlockNumber, i, first, _loop_1, this_1, state_1;
- var _this = this;
- return __generator(this, function (_a) {
- switch (_a.label) {
- case 0:
- if (!(method === "sendTransaction")) return [3 /*break*/, 2];
- return [4 /*yield*/, Promise.all(this.providerConfigs.map(function (c) {
- return c.provider.sendTransaction(params.signedTransaction).then(function (result) {
- return result.hash;
- }, function (error) {
- return error;
- });
- }))];
- case 1:
- results = _a.sent();
- // Any success is good enough (other errors are likely "already seen" errors
- for (i_1 = 0; i_1 < results.length; i_1++) {
- result = results[i_1];
- if (typeof (result) === "string") {
- return [2 /*return*/, result];
- }
- }
- // They were all an error; pick the first error
- throw results[0];
- case 2:
- if (!(this._highestBlockNumber === -1 && method !== "getBlockNumber")) return [3 /*break*/, 4];
- return [4 /*yield*/, this.getBlockNumber()];
- case 3:
- _a.sent();
- _a.label = 4;
- case 4:
- processFunc = getProcessFunc(this, method, params);
- configs = (0, random_1.shuffled)(this.providerConfigs.map(properties_1.shallowCopy));
- configs.sort(function (a, b) { return (a.priority - b.priority); });
- currentBlockNumber = this._highestBlockNumber;
- i = 0;
- first = true;
- _loop_1 = function () {
- var t0, inflightWeight, _loop_2, waiting, results, result, errors;
- return __generator(this, function (_b) {
- switch (_b.label) {
- case 0:
- t0 = now();
- inflightWeight = configs.filter(function (c) { return (c.runner && ((t0 - c.start) < c.stallTimeout)); })
- .reduce(function (accum, c) { return (accum + c.weight); }, 0);
- _loop_2 = function () {
- var config = configs[i++];
- var rid = nextRid++;
- config.start = now();
- config.staller = stall(config.stallTimeout);
- config.staller.wait(function () { config.staller = null; });
- config.runner = getRunner(config, currentBlockNumber, method, params).then(function (result) {
- config.done = true;
- config.result = result;
- if (_this.listenerCount("debug")) {
- _this.emit("debug", {
- action: "request",
- rid: rid,
- backend: exposeDebugConfig(config, now()),
- request: { method: method, params: (0, properties_1.deepCopy)(params) },
- provider: _this
- });
- }
- }, function (error) {
- config.done = true;
- config.error = error;
- if (_this.listenerCount("debug")) {
- _this.emit("debug", {
- action: "request",
- rid: rid,
- backend: exposeDebugConfig(config, now()),
- request: { method: method, params: (0, properties_1.deepCopy)(params) },
- provider: _this
- });
- }
- });
- if (this_1.listenerCount("debug")) {
- this_1.emit("debug", {
- action: "request",
- rid: rid,
- backend: exposeDebugConfig(config, null),
- request: { method: method, params: (0, properties_1.deepCopy)(params) },
- provider: this_1
- });
- }
- inflightWeight += config.weight;
- };
- // Start running enough to meet quorum
- while (inflightWeight < this_1.quorum && i < configs.length) {
- _loop_2();
- }
- waiting = [];
- configs.forEach(function (c) {
- if (c.done || !c.runner) {
- return;
- }
- waiting.push(c.runner);
- if (c.staller) {
- waiting.push(c.staller.getPromise());
- }
- });
- if (!waiting.length) return [3 /*break*/, 2];
- return [4 /*yield*/, Promise.race(waiting)];
- case 1:
- _b.sent();
- _b.label = 2;
- case 2:
- results = configs.filter(function (c) { return (c.done && c.error == null); });
- if (!(results.length >= this_1.quorum)) return [3 /*break*/, 5];
- result = processFunc(results);
- if (result !== undefined) {
- // Shut down any stallers
- configs.forEach(function (c) {
- if (c.staller) {
- c.staller.cancel();
- }
- c.cancelled = true;
- });
- return [2 /*return*/, { value: result }];
- }
- if (!!first) return [3 /*break*/, 4];
- return [4 /*yield*/, stall(100).getPromise()];
- case 3:
- _b.sent();
- _b.label = 4;
- case 4:
- first = false;
- _b.label = 5;
- case 5:
- errors = configs.reduce(function (accum, c) {
- if (!c.done || c.error == null) {
- return accum;
- }
- var code = (c.error).code;
- if (ForwardErrors.indexOf(code) >= 0) {
- if (!accum[code]) {
- accum[code] = { error: c.error, weight: 0 };
- }
- accum[code].weight += c.weight;
- }
- return accum;
- }, ({}));
- Object.keys(errors).forEach(function (errorCode) {
- var tally = errors[errorCode];
- if (tally.weight < _this.quorum) {
- return;
- }
- // Shut down any stallers
- configs.forEach(function (c) {
- if (c.staller) {
- c.staller.cancel();
- }
- c.cancelled = true;
- });
- var e = (tally.error);
- var props = {};
- ForwardProperties.forEach(function (name) {
- if (e[name] == null) {
- return;
- }
- props[name] = e[name];
- });
- logger.throwError(e.reason || e.message, errorCode, props);
- });
- // All configs have run to completion; we will never get more data
- if (configs.filter(function (c) { return !c.done; }).length === 0) {
- return [2 /*return*/, "break"];
- }
- return [2 /*return*/];
- }
- });
- };
- this_1 = this;
- _a.label = 5;
- case 5:
- if (!true) return [3 /*break*/, 7];
- return [5 /*yield**/, _loop_1()];
- case 6:
- state_1 = _a.sent();
- if (typeof state_1 === "object")
- return [2 /*return*/, state_1.value];
- if (state_1 === "break")
- return [3 /*break*/, 7];
- return [3 /*break*/, 5];
- case 7:
- // Shut down any stallers; shouldn't be any
- configs.forEach(function (c) {
- if (c.staller) {
- c.staller.cancel();
- }
- c.cancelled = true;
- });
- return [2 /*return*/, logger.throwError("failed to meet quorum", logger_1.Logger.errors.SERVER_ERROR, {
- method: method,
- params: params,
- //results: configs.map((c) => c.result),
- //errors: configs.map((c) => c.error),
- results: configs.map(function (c) { return exposeDebugConfig(c); }),
- provider: this
- })];
- }
- });
- });
- };
- return FallbackProvider;
- }(base_provider_1.BaseProvider));
- exports.FallbackProvider = FallbackProvider;
- },{"./_version":230,"./base-provider":232,"./formatter":238,"@ethersproject/abstract-provider":185,"@ethersproject/bignumber":196,"@ethersproject/bytes":199,"@ethersproject/logger":223,"@ethersproject/properties":229,"@ethersproject/random":250,"@ethersproject/web":276}],238:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.showThrottleMessage = exports.isCommunityResource = exports.isCommunityResourcable = exports.Formatter = void 0;
- var address_1 = _dereq_("@ethersproject/address");
- var bignumber_1 = _dereq_("@ethersproject/bignumber");
- var bytes_1 = _dereq_("@ethersproject/bytes");
- var constants_1 = _dereq_("@ethersproject/constants");
- var properties_1 = _dereq_("@ethersproject/properties");
- var transactions_1 = _dereq_("@ethersproject/transactions");
- var logger_1 = _dereq_("@ethersproject/logger");
- var _version_1 = _dereq_("./_version");
- var logger = new logger_1.Logger(_version_1.version);
- var Formatter = /** @class */ (function () {
- function Formatter() {
- var _newTarget = this.constructor;
- logger.checkNew(_newTarget, Formatter);
- this.formats = this.getDefaultFormats();
- }
- Formatter.prototype.getDefaultFormats = function () {
- var _this = this;
- var formats = ({});
- var address = this.address.bind(this);
- var bigNumber = this.bigNumber.bind(this);
- var blockTag = this.blockTag.bind(this);
- var data = this.data.bind(this);
- var hash = this.hash.bind(this);
- var hex = this.hex.bind(this);
- var number = this.number.bind(this);
- var type = this.type.bind(this);
- var strictData = function (v) { return _this.data(v, true); };
- formats.transaction = {
- hash: hash,
- type: type,
- accessList: Formatter.allowNull(this.accessList.bind(this), null),
- blockHash: Formatter.allowNull(hash, null),
- blockNumber: Formatter.allowNull(number, null),
- transactionIndex: Formatter.allowNull(number, null),
- confirmations: Formatter.allowNull(number, null),
- from: address,
- // either (gasPrice) or (maxPriorityFeePerGas + maxFeePerGas)
- // must be set
- gasPrice: Formatter.allowNull(bigNumber),
- maxPriorityFeePerGas: Formatter.allowNull(bigNumber),
- maxFeePerGas: Formatter.allowNull(bigNumber),
- gasLimit: bigNumber,
- to: Formatter.allowNull(address, null),
- value: bigNumber,
- nonce: number,
- data: data,
- r: Formatter.allowNull(this.uint256),
- s: Formatter.allowNull(this.uint256),
- v: Formatter.allowNull(number),
- creates: Formatter.allowNull(address, null),
- raw: Formatter.allowNull(data),
- };
- formats.transactionRequest = {
- from: Formatter.allowNull(address),
- nonce: Formatter.allowNull(number),
- gasLimit: Formatter.allowNull(bigNumber),
- gasPrice: Formatter.allowNull(bigNumber),
- maxPriorityFeePerGas: Formatter.allowNull(bigNumber),
- maxFeePerGas: Formatter.allowNull(bigNumber),
- to: Formatter.allowNull(address),
- value: Formatter.allowNull(bigNumber),
- data: Formatter.allowNull(strictData),
- type: Formatter.allowNull(number),
- accessList: Formatter.allowNull(this.accessList.bind(this), null),
- };
- formats.receiptLog = {
- transactionIndex: number,
- blockNumber: number,
- transactionHash: hash,
- address: address,
- topics: Formatter.arrayOf(hash),
- data: data,
- logIndex: number,
- blockHash: hash,
- };
- formats.receipt = {
- to: Formatter.allowNull(this.address, null),
- from: Formatter.allowNull(this.address, null),
- contractAddress: Formatter.allowNull(address, null),
- transactionIndex: number,
- // should be allowNull(hash), but broken-EIP-658 support is handled in receipt
- root: Formatter.allowNull(hex),
- gasUsed: bigNumber,
- logsBloom: Formatter.allowNull(data),
- blockHash: hash,
- transactionHash: hash,
- logs: Formatter.arrayOf(this.receiptLog.bind(this)),
- blockNumber: number,
- confirmations: Formatter.allowNull(number, null),
- cumulativeGasUsed: bigNumber,
- effectiveGasPrice: Formatter.allowNull(bigNumber),
- status: Formatter.allowNull(number),
- type: type
- };
- formats.block = {
- hash: Formatter.allowNull(hash),
- parentHash: hash,
- number: number,
- timestamp: number,
- nonce: Formatter.allowNull(hex),
- difficulty: this.difficulty.bind(this),
- gasLimit: bigNumber,
- gasUsed: bigNumber,
- miner: Formatter.allowNull(address),
- extraData: data,
- transactions: Formatter.allowNull(Formatter.arrayOf(hash)),
- baseFeePerGas: Formatter.allowNull(bigNumber)
- };
- formats.blockWithTransactions = (0, properties_1.shallowCopy)(formats.block);
- formats.blockWithTransactions.transactions = Formatter.allowNull(Formatter.arrayOf(this.transactionResponse.bind(this)));
- formats.filter = {
- fromBlock: Formatter.allowNull(blockTag, undefined),
- toBlock: Formatter.allowNull(blockTag, undefined),
- blockHash: Formatter.allowNull(hash, undefined),
- address: Formatter.allowNull(address, undefined),
- topics: Formatter.allowNull(this.topics.bind(this), undefined),
- };
- formats.filterLog = {
- blockNumber: Formatter.allowNull(number),
- blockHash: Formatter.allowNull(hash),
- transactionIndex: number,
- removed: Formatter.allowNull(this.boolean.bind(this)),
- address: address,
- data: Formatter.allowFalsish(data, "0x"),
- topics: Formatter.arrayOf(hash),
- transactionHash: hash,
- logIndex: number,
- };
- return formats;
- };
- Formatter.prototype.accessList = function (accessList) {
- return (0, transactions_1.accessListify)(accessList || []);
- };
- // Requires a BigNumberish that is within the IEEE754 safe integer range; returns a number
- // Strict! Used on input.
- Formatter.prototype.number = function (number) {
- if (number === "0x") {
- return 0;
- }
- return bignumber_1.BigNumber.from(number).toNumber();
- };
- Formatter.prototype.type = function (number) {
- if (number === "0x" || number == null) {
- return 0;
- }
- return bignumber_1.BigNumber.from(number).toNumber();
- };
- // Strict! Used on input.
- Formatter.prototype.bigNumber = function (value) {
- return bignumber_1.BigNumber.from(value);
- };
- // Requires a boolean, "true" or "false"; returns a boolean
- Formatter.prototype.boolean = function (value) {
- if (typeof (value) === "boolean") {
- return value;
- }
- if (typeof (value) === "string") {
- value = value.toLowerCase();
- if (value === "true") {
- return true;
- }
- if (value === "false") {
- return false;
- }
- }
- throw new Error("invalid boolean - " + value);
- };
- Formatter.prototype.hex = function (value, strict) {
- if (typeof (value) === "string") {
- if (!strict && value.substring(0, 2) !== "0x") {
- value = "0x" + value;
- }
- if ((0, bytes_1.isHexString)(value)) {
- return value.toLowerCase();
- }
- }
- return logger.throwArgumentError("invalid hash", "value", value);
- };
- Formatter.prototype.data = function (value, strict) {
- var result = this.hex(value, strict);
- if ((result.length % 2) !== 0) {
- throw new Error("invalid data; odd-length - " + value);
- }
- return result;
- };
- // Requires an address
- // Strict! Used on input.
- Formatter.prototype.address = function (value) {
- return (0, address_1.getAddress)(value);
- };
- Formatter.prototype.callAddress = function (value) {
- if (!(0, bytes_1.isHexString)(value, 32)) {
- return null;
- }
- var address = (0, address_1.getAddress)((0, bytes_1.hexDataSlice)(value, 12));
- return (address === constants_1.AddressZero) ? null : address;
- };
- Formatter.prototype.contractAddress = function (value) {
- return (0, address_1.getContractAddress)(value);
- };
- // Strict! Used on input.
- Formatter.prototype.blockTag = function (blockTag) {
- if (blockTag == null) {
- return "latest";
- }
- if (blockTag === "earliest") {
- return "0x0";
- }
- if (blockTag === "latest" || blockTag === "pending") {
- return blockTag;
- }
- if (typeof (blockTag) === "number" || (0, bytes_1.isHexString)(blockTag)) {
- return (0, bytes_1.hexValue)(blockTag);
- }
- throw new Error("invalid blockTag");
- };
- // Requires a hash, optionally requires 0x prefix; returns prefixed lowercase hash.
- Formatter.prototype.hash = function (value, strict) {
- var result = this.hex(value, strict);
- if ((0, bytes_1.hexDataLength)(result) !== 32) {
- return logger.throwArgumentError("invalid hash", "value", value);
- }
- return result;
- };
- // Returns the difficulty as a number, or if too large (i.e. PoA network) null
- Formatter.prototype.difficulty = function (value) {
- if (value == null) {
- return null;
- }
- var v = bignumber_1.BigNumber.from(value);
- try {
- return v.toNumber();
- }
- catch (error) { }
- return null;
- };
- Formatter.prototype.uint256 = function (value) {
- if (!(0, bytes_1.isHexString)(value)) {
- throw new Error("invalid uint256");
- }
- return (0, bytes_1.hexZeroPad)(value, 32);
- };
- Formatter.prototype._block = function (value, format) {
- if (value.author != null && value.miner == null) {
- value.miner = value.author;
- }
- // The difficulty may need to come from _difficulty in recursed blocks
- var difficulty = (value._difficulty != null) ? value._difficulty : value.difficulty;
- var result = Formatter.check(format, value);
- result._difficulty = ((difficulty == null) ? null : bignumber_1.BigNumber.from(difficulty));
- return result;
- };
- Formatter.prototype.block = function (value) {
- return this._block(value, this.formats.block);
- };
- Formatter.prototype.blockWithTransactions = function (value) {
- return this._block(value, this.formats.blockWithTransactions);
- };
- // Strict! Used on input.
- Formatter.prototype.transactionRequest = function (value) {
- return Formatter.check(this.formats.transactionRequest, value);
- };
- Formatter.prototype.transactionResponse = function (transaction) {
- // Rename gas to gasLimit
- if (transaction.gas != null && transaction.gasLimit == null) {
- transaction.gasLimit = transaction.gas;
- }
- // Some clients (TestRPC) do strange things like return 0x0 for the
- // 0 address; correct this to be a real address
- if (transaction.to && bignumber_1.BigNumber.from(transaction.to).isZero()) {
- transaction.to = "0x0000000000000000000000000000000000000000";
- }
- // Rename input to data
- if (transaction.input != null && transaction.data == null) {
- transaction.data = transaction.input;
- }
- // If to and creates are empty, populate the creates from the transaction
- if (transaction.to == null && transaction.creates == null) {
- transaction.creates = this.contractAddress(transaction);
- }
- if ((transaction.type === 1 || transaction.type === 2) && transaction.accessList == null) {
- transaction.accessList = [];
- }
- var result = Formatter.check(this.formats.transaction, transaction);
- if (transaction.chainId != null) {
- var chainId = transaction.chainId;
- if ((0, bytes_1.isHexString)(chainId)) {
- chainId = bignumber_1.BigNumber.from(chainId).toNumber();
- }
- result.chainId = chainId;
- }
- else {
- var chainId = transaction.networkId;
- // geth-etc returns chainId
- if (chainId == null && result.v == null) {
- chainId = transaction.chainId;
- }
- if ((0, bytes_1.isHexString)(chainId)) {
- chainId = bignumber_1.BigNumber.from(chainId).toNumber();
- }
- if (typeof (chainId) !== "number" && result.v != null) {
- chainId = (result.v - 35) / 2;
- if (chainId < 0) {
- chainId = 0;
- }
- chainId = parseInt(chainId);
- }
- if (typeof (chainId) !== "number") {
- chainId = 0;
- }
- result.chainId = chainId;
- }
- // 0x0000... should actually be null
- if (result.blockHash && result.blockHash.replace(/0/g, "") === "x") {
- result.blockHash = null;
- }
- return result;
- };
- Formatter.prototype.transaction = function (value) {
- return (0, transactions_1.parse)(value);
- };
- Formatter.prototype.receiptLog = function (value) {
- return Formatter.check(this.formats.receiptLog, value);
- };
- Formatter.prototype.receipt = function (value) {
- var result = Formatter.check(this.formats.receipt, value);
- // RSK incorrectly implemented EIP-658, so we munge things a bit here for it
- if (result.root != null) {
- if (result.root.length <= 4) {
- // Could be 0x00, 0x0, 0x01 or 0x1
- var value_1 = bignumber_1.BigNumber.from(result.root).toNumber();
- if (value_1 === 0 || value_1 === 1) {
- // Make sure if both are specified, they match
- if (result.status != null && (result.status !== value_1)) {
- logger.throwArgumentError("alt-root-status/status mismatch", "value", { root: result.root, status: result.status });
- }
- result.status = value_1;
- delete result.root;
- }
- else {
- logger.throwArgumentError("invalid alt-root-status", "value.root", result.root);
- }
- }
- else if (result.root.length !== 66) {
- // Must be a valid bytes32
- logger.throwArgumentError("invalid root hash", "value.root", result.root);
- }
- }
- if (result.status != null) {
- result.byzantium = true;
- }
- return result;
- };
- Formatter.prototype.topics = function (value) {
- var _this = this;
- if (Array.isArray(value)) {
- return value.map(function (v) { return _this.topics(v); });
- }
- else if (value != null) {
- return this.hash(value, true);
- }
- return null;
- };
- Formatter.prototype.filter = function (value) {
- return Formatter.check(this.formats.filter, value);
- };
- Formatter.prototype.filterLog = function (value) {
- return Formatter.check(this.formats.filterLog, value);
- };
- Formatter.check = function (format, object) {
- var result = {};
- for (var key in format) {
- try {
- var value = format[key](object[key]);
- if (value !== undefined) {
- result[key] = value;
- }
- }
- catch (error) {
- error.checkKey = key;
- error.checkValue = object[key];
- throw error;
- }
- }
- return result;
- };
- // if value is null-ish, nullValue is returned
- Formatter.allowNull = function (format, nullValue) {
- return (function (value) {
- if (value == null) {
- return nullValue;
- }
- return format(value);
- });
- };
- // If value is false-ish, replaceValue is returned
- Formatter.allowFalsish = function (format, replaceValue) {
- return (function (value) {
- if (!value) {
- return replaceValue;
- }
- return format(value);
- });
- };
- // Requires an Array satisfying check
- Formatter.arrayOf = function (format) {
- return (function (array) {
- if (!Array.isArray(array)) {
- throw new Error("not an array");
- }
- var result = [];
- array.forEach(function (value) {
- result.push(format(value));
- });
- return result;
- });
- };
- return Formatter;
- }());
- exports.Formatter = Formatter;
- function isCommunityResourcable(value) {
- return (value && typeof (value.isCommunityResource) === "function");
- }
- exports.isCommunityResourcable = isCommunityResourcable;
- function isCommunityResource(value) {
- return (isCommunityResourcable(value) && value.isCommunityResource());
- }
- exports.isCommunityResource = isCommunityResource;
- // Show the throttle message only once
- var throttleMessage = false;
- function showThrottleMessage() {
- if (throttleMessage) {
- return;
- }
- throttleMessage = true;
- console.log("========= NOTICE =========");
- console.log("Request-Rate Exceeded (this message will not be repeated)");
- console.log("");
- console.log("The default API keys for each service are provided as a highly-throttled,");
- console.log("community resource for low-traffic projects and early prototyping.");
- console.log("");
- console.log("While your application will continue to function, we highly recommended");
- console.log("signing up for your own API keys to improve performance, increase your");
- console.log("request rate/limit and enable other perks, such as metrics and advanced APIs.");
- console.log("");
- console.log("For more details: https:/\/docs.ethers.io/api-keys/");
- console.log("==========================");
- }
- exports.showThrottleMessage = showThrottleMessage;
- },{"./_version":230,"@ethersproject/address":189,"@ethersproject/bignumber":196,"@ethersproject/bytes":199,"@ethersproject/constants":203,"@ethersproject/logger":223,"@ethersproject/properties":229,"@ethersproject/transactions":269}],239:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.Formatter = exports.showThrottleMessage = exports.isCommunityResourcable = exports.isCommunityResource = exports.getNetwork = exports.getDefaultProvider = exports.JsonRpcSigner = exports.IpcProvider = exports.WebSocketProvider = exports.Web3Provider = exports.StaticJsonRpcProvider = exports.PocketProvider = exports.NodesmithProvider = exports.JsonRpcBatchProvider = exports.JsonRpcProvider = exports.InfuraWebSocketProvider = exports.InfuraProvider = exports.EtherscanProvider = exports.CloudflareProvider = exports.AlchemyWebSocketProvider = exports.AlchemyProvider = exports.FallbackProvider = exports.UrlJsonRpcProvider = exports.Resolver = exports.BaseProvider = exports.Provider = void 0;
- var abstract_provider_1 = _dereq_("@ethersproject/abstract-provider");
- Object.defineProperty(exports, "Provider", { enumerable: true, get: function () { return abstract_provider_1.Provider; } });
- var networks_1 = _dereq_("@ethersproject/networks");
- Object.defineProperty(exports, "getNetwork", { enumerable: true, get: function () { return networks_1.getNetwork; } });
- var base_provider_1 = _dereq_("./base-provider");
- Object.defineProperty(exports, "BaseProvider", { enumerable: true, get: function () { return base_provider_1.BaseProvider; } });
- Object.defineProperty(exports, "Resolver", { enumerable: true, get: function () { return base_provider_1.Resolver; } });
- var alchemy_provider_1 = _dereq_("./alchemy-provider");
- Object.defineProperty(exports, "AlchemyProvider", { enumerable: true, get: function () { return alchemy_provider_1.AlchemyProvider; } });
- Object.defineProperty(exports, "AlchemyWebSocketProvider", { enumerable: true, get: function () { return alchemy_provider_1.AlchemyWebSocketProvider; } });
- var cloudflare_provider_1 = _dereq_("./cloudflare-provider");
- Object.defineProperty(exports, "CloudflareProvider", { enumerable: true, get: function () { return cloudflare_provider_1.CloudflareProvider; } });
- var etherscan_provider_1 = _dereq_("./etherscan-provider");
- Object.defineProperty(exports, "EtherscanProvider", { enumerable: true, get: function () { return etherscan_provider_1.EtherscanProvider; } });
- var fallback_provider_1 = _dereq_("./fallback-provider");
- Object.defineProperty(exports, "FallbackProvider", { enumerable: true, get: function () { return fallback_provider_1.FallbackProvider; } });
- var ipc_provider_1 = _dereq_("./ipc-provider");
- Object.defineProperty(exports, "IpcProvider", { enumerable: true, get: function () { return ipc_provider_1.IpcProvider; } });
- var infura_provider_1 = _dereq_("./infura-provider");
- Object.defineProperty(exports, "InfuraProvider", { enumerable: true, get: function () { return infura_provider_1.InfuraProvider; } });
- Object.defineProperty(exports, "InfuraWebSocketProvider", { enumerable: true, get: function () { return infura_provider_1.InfuraWebSocketProvider; } });
- var json_rpc_provider_1 = _dereq_("./json-rpc-provider");
- Object.defineProperty(exports, "JsonRpcProvider", { enumerable: true, get: function () { return json_rpc_provider_1.JsonRpcProvider; } });
- Object.defineProperty(exports, "JsonRpcSigner", { enumerable: true, get: function () { return json_rpc_provider_1.JsonRpcSigner; } });
- var json_rpc_batch_provider_1 = _dereq_("./json-rpc-batch-provider");
- Object.defineProperty(exports, "JsonRpcBatchProvider", { enumerable: true, get: function () { return json_rpc_batch_provider_1.JsonRpcBatchProvider; } });
- var nodesmith_provider_1 = _dereq_("./nodesmith-provider");
- Object.defineProperty(exports, "NodesmithProvider", { enumerable: true, get: function () { return nodesmith_provider_1.NodesmithProvider; } });
- var pocket_provider_1 = _dereq_("./pocket-provider");
- Object.defineProperty(exports, "PocketProvider", { enumerable: true, get: function () { return pocket_provider_1.PocketProvider; } });
- var url_json_rpc_provider_1 = _dereq_("./url-json-rpc-provider");
- Object.defineProperty(exports, "StaticJsonRpcProvider", { enumerable: true, get: function () { return url_json_rpc_provider_1.StaticJsonRpcProvider; } });
- Object.defineProperty(exports, "UrlJsonRpcProvider", { enumerable: true, get: function () { return url_json_rpc_provider_1.UrlJsonRpcProvider; } });
- var web3_provider_1 = _dereq_("./web3-provider");
- Object.defineProperty(exports, "Web3Provider", { enumerable: true, get: function () { return web3_provider_1.Web3Provider; } });
- var websocket_provider_1 = _dereq_("./websocket-provider");
- Object.defineProperty(exports, "WebSocketProvider", { enumerable: true, get: function () { return websocket_provider_1.WebSocketProvider; } });
- var formatter_1 = _dereq_("./formatter");
- Object.defineProperty(exports, "Formatter", { enumerable: true, get: function () { return formatter_1.Formatter; } });
- Object.defineProperty(exports, "isCommunityResourcable", { enumerable: true, get: function () { return formatter_1.isCommunityResourcable; } });
- Object.defineProperty(exports, "isCommunityResource", { enumerable: true, get: function () { return formatter_1.isCommunityResource; } });
- Object.defineProperty(exports, "showThrottleMessage", { enumerable: true, get: function () { return formatter_1.showThrottleMessage; } });
- var logger_1 = _dereq_("@ethersproject/logger");
- var _version_1 = _dereq_("./_version");
- var logger = new logger_1.Logger(_version_1.version);
- ////////////////////////
- // Helper Functions
- function getDefaultProvider(network, options) {
- if (network == null) {
- network = "homestead";
- }
- // If passed a URL, figure out the right type of provider based on the scheme
- if (typeof (network) === "string") {
- // @TODO: Add support for IpcProvider; maybe if it ends in ".ipc"?
- // Handle http and ws (and their secure variants)
- var match = network.match(/^(ws|http)s?:/i);
- if (match) {
- switch (match[1]) {
- case "http":
- return new json_rpc_provider_1.JsonRpcProvider(network);
- case "ws":
- return new websocket_provider_1.WebSocketProvider(network);
- default:
- logger.throwArgumentError("unsupported URL scheme", "network", network);
- }
- }
- }
- var n = (0, networks_1.getNetwork)(network);
- if (!n || !n._defaultProvider) {
- logger.throwError("unsupported getDefaultProvider network", logger_1.Logger.errors.NETWORK_ERROR, {
- operation: "getDefaultProvider",
- network: network
- });
- }
- return n._defaultProvider({
- FallbackProvider: fallback_provider_1.FallbackProvider,
- AlchemyProvider: alchemy_provider_1.AlchemyProvider,
- CloudflareProvider: cloudflare_provider_1.CloudflareProvider,
- EtherscanProvider: etherscan_provider_1.EtherscanProvider,
- InfuraProvider: infura_provider_1.InfuraProvider,
- JsonRpcProvider: json_rpc_provider_1.JsonRpcProvider,
- NodesmithProvider: nodesmith_provider_1.NodesmithProvider,
- PocketProvider: pocket_provider_1.PocketProvider,
- Web3Provider: web3_provider_1.Web3Provider,
- IpcProvider: ipc_provider_1.IpcProvider,
- }, options);
- }
- exports.getDefaultProvider = getDefaultProvider;
- },{"./_version":230,"./alchemy-provider":231,"./base-provider":232,"./cloudflare-provider":235,"./etherscan-provider":236,"./fallback-provider":237,"./formatter":238,"./infura-provider":240,"./ipc-provider":233,"./json-rpc-batch-provider":241,"./json-rpc-provider":242,"./nodesmith-provider":243,"./pocket-provider":244,"./url-json-rpc-provider":245,"./web3-provider":246,"./websocket-provider":247,"@ethersproject/abstract-provider":185,"@ethersproject/logger":223,"@ethersproject/networks":225}],240:[function(_dereq_,module,exports){
- "use strict";
- var __extends = (this && this.__extends) || (function () {
- var extendStatics = function (d, b) {
- extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
- return extendStatics(d, b);
- };
- return function (d, b) {
- if (typeof b !== "function" && b !== null)
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.InfuraProvider = exports.InfuraWebSocketProvider = void 0;
- var properties_1 = _dereq_("@ethersproject/properties");
- var websocket_provider_1 = _dereq_("./websocket-provider");
- var formatter_1 = _dereq_("./formatter");
- var logger_1 = _dereq_("@ethersproject/logger");
- var _version_1 = _dereq_("./_version");
- var logger = new logger_1.Logger(_version_1.version);
- var url_json_rpc_provider_1 = _dereq_("./url-json-rpc-provider");
- var defaultProjectId = "84842078b09946638c03157f83405213";
- var InfuraWebSocketProvider = /** @class */ (function (_super) {
- __extends(InfuraWebSocketProvider, _super);
- function InfuraWebSocketProvider(network, apiKey) {
- var _this = this;
- var provider = new InfuraProvider(network, apiKey);
- var connection = provider.connection;
- if (connection.password) {
- logger.throwError("INFURA WebSocket project secrets unsupported", logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
- operation: "InfuraProvider.getWebSocketProvider()"
- });
- }
- var url = connection.url.replace(/^http/i, "ws").replace("/v3/", "/ws/v3/");
- _this = _super.call(this, url, network) || this;
- (0, properties_1.defineReadOnly)(_this, "apiKey", provider.projectId);
- (0, properties_1.defineReadOnly)(_this, "projectId", provider.projectId);
- (0, properties_1.defineReadOnly)(_this, "projectSecret", provider.projectSecret);
- return _this;
- }
- InfuraWebSocketProvider.prototype.isCommunityResource = function () {
- return (this.projectId === defaultProjectId);
- };
- return InfuraWebSocketProvider;
- }(websocket_provider_1.WebSocketProvider));
- exports.InfuraWebSocketProvider = InfuraWebSocketProvider;
- var InfuraProvider = /** @class */ (function (_super) {
- __extends(InfuraProvider, _super);
- function InfuraProvider() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- InfuraProvider.getWebSocketProvider = function (network, apiKey) {
- return new InfuraWebSocketProvider(network, apiKey);
- };
- InfuraProvider.getApiKey = function (apiKey) {
- var apiKeyObj = {
- apiKey: defaultProjectId,
- projectId: defaultProjectId,
- projectSecret: null
- };
- if (apiKey == null) {
- return apiKeyObj;
- }
- if (typeof (apiKey) === "string") {
- apiKeyObj.projectId = apiKey;
- }
- else if (apiKey.projectSecret != null) {
- logger.assertArgument((typeof (apiKey.projectId) === "string"), "projectSecret requires a projectId", "projectId", apiKey.projectId);
- logger.assertArgument((typeof (apiKey.projectSecret) === "string"), "invalid projectSecret", "projectSecret", "[REDACTED]");
- apiKeyObj.projectId = apiKey.projectId;
- apiKeyObj.projectSecret = apiKey.projectSecret;
- }
- else if (apiKey.projectId) {
- apiKeyObj.projectId = apiKey.projectId;
- }
- apiKeyObj.apiKey = apiKeyObj.projectId;
- return apiKeyObj;
- };
- InfuraProvider.getUrl = function (network, apiKey) {
- var host = null;
- switch (network ? network.name : "unknown") {
- case "homestead":
- host = "mainnet.infura.io";
- break;
- case "ropsten":
- host = "ropsten.infura.io";
- break;
- case "rinkeby":
- host = "rinkeby.infura.io";
- break;
- case "kovan":
- host = "kovan.infura.io";
- break;
- case "goerli":
- host = "goerli.infura.io";
- break;
- case "matic":
- host = "polygon-mainnet.infura.io";
- break;
- case "maticmum":
- host = "polygon-mumbai.infura.io";
- break;
- case "optimism":
- host = "optimism-mainnet.infura.io";
- break;
- case "optimism-kovan":
- host = "optimism-kovan.infura.io";
- break;
- case "arbitrum":
- host = "arbitrum-mainnet.infura.io";
- break;
- case "arbitrum-rinkeby":
- host = "arbitrum-rinkeby.infura.io";
- break;
- default:
- logger.throwError("unsupported network", logger_1.Logger.errors.INVALID_ARGUMENT, {
- argument: "network",
- value: network
- });
- }
- var connection = {
- allowGzip: true,
- url: ("https:/" + "/" + host + "/v3/" + apiKey.projectId),
- throttleCallback: function (attempt, url) {
- if (apiKey.projectId === defaultProjectId) {
- (0, formatter_1.showThrottleMessage)();
- }
- return Promise.resolve(true);
- }
- };
- if (apiKey.projectSecret != null) {
- connection.user = "";
- connection.password = apiKey.projectSecret;
- }
- return connection;
- };
- InfuraProvider.prototype.isCommunityResource = function () {
- return (this.projectId === defaultProjectId);
- };
- return InfuraProvider;
- }(url_json_rpc_provider_1.UrlJsonRpcProvider));
- exports.InfuraProvider = InfuraProvider;
- },{"./_version":230,"./formatter":238,"./url-json-rpc-provider":245,"./websocket-provider":247,"@ethersproject/logger":223,"@ethersproject/properties":229}],241:[function(_dereq_,module,exports){
- "use strict";
- var __extends = (this && this.__extends) || (function () {
- var extendStatics = function (d, b) {
- extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
- return extendStatics(d, b);
- };
- return function (d, b) {
- if (typeof b !== "function" && b !== null)
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.JsonRpcBatchProvider = void 0;
- var properties_1 = _dereq_("@ethersproject/properties");
- var web_1 = _dereq_("@ethersproject/web");
- var json_rpc_provider_1 = _dereq_("./json-rpc-provider");
- // Experimental
- var JsonRpcBatchProvider = /** @class */ (function (_super) {
- __extends(JsonRpcBatchProvider, _super);
- function JsonRpcBatchProvider() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- JsonRpcBatchProvider.prototype.send = function (method, params) {
- var _this = this;
- var request = {
- method: method,
- params: params,
- id: (this._nextId++),
- jsonrpc: "2.0"
- };
- if (this._pendingBatch == null) {
- this._pendingBatch = [];
- }
- var inflightRequest = { request: request, resolve: null, reject: null };
- var promise = new Promise(function (resolve, reject) {
- inflightRequest.resolve = resolve;
- inflightRequest.reject = reject;
- });
- this._pendingBatch.push(inflightRequest);
- if (!this._pendingBatchAggregator) {
- // Schedule batch for next event loop + short duration
- this._pendingBatchAggregator = setTimeout(function () {
- // Get teh current batch and clear it, so new requests
- // go into the next batch
- var batch = _this._pendingBatch;
- _this._pendingBatch = null;
- _this._pendingBatchAggregator = null;
- // Get the request as an array of requests
- var request = batch.map(function (inflight) { return inflight.request; });
- _this.emit("debug", {
- action: "requestBatch",
- request: (0, properties_1.deepCopy)(request),
- provider: _this
- });
- return (0, web_1.fetchJson)(_this.connection, JSON.stringify(request)).then(function (result) {
- _this.emit("debug", {
- action: "response",
- request: request,
- response: result,
- provider: _this
- });
- // For each result, feed it to the correct Promise, depending
- // on whether it was a success or error
- batch.forEach(function (inflightRequest, index) {
- var payload = result[index];
- if (payload.error) {
- var error = new Error(payload.error.message);
- error.code = payload.error.code;
- error.data = payload.error.data;
- inflightRequest.reject(error);
- }
- else {
- inflightRequest.resolve(payload.result);
- }
- });
- }, function (error) {
- _this.emit("debug", {
- action: "response",
- error: error,
- request: request,
- provider: _this
- });
- batch.forEach(function (inflightRequest) {
- inflightRequest.reject(error);
- });
- });
- }, 10);
- }
- return promise;
- };
- return JsonRpcBatchProvider;
- }(json_rpc_provider_1.JsonRpcProvider));
- exports.JsonRpcBatchProvider = JsonRpcBatchProvider;
- },{"./json-rpc-provider":242,"@ethersproject/properties":229,"@ethersproject/web":276}],242:[function(_dereq_,module,exports){
- "use strict";
- var __extends = (this && this.__extends) || (function () {
- var extendStatics = function (d, b) {
- extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
- return extendStatics(d, b);
- };
- return function (d, b) {
- if (typeof b !== "function" && b !== null)
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
- return new (P || (P = Promise))(function (resolve, reject) {
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
- step((generator = generator.apply(thisArg, _arguments || [])).next());
- });
- };
- var __generator = (this && this.__generator) || function (thisArg, body) {
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
- function verb(n) { return function (v) { return step([n, v]); }; }
- function step(op) {
- if (f) throw new TypeError("Generator is already executing.");
- while (_) try {
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
- if (y = 0, t) op = [op[0] & 2, t.value];
- switch (op[0]) {
- case 0: case 1: t = op; break;
- case 4: _.label++; return { value: op[1], done: false };
- case 5: _.label++; y = op[1]; op = [0]; continue;
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
- default:
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
- if (t[2]) _.ops.pop();
- _.trys.pop(); continue;
- }
- op = body.call(thisArg, _);
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
- }
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.JsonRpcProvider = exports.JsonRpcSigner = void 0;
- var abstract_signer_1 = _dereq_("@ethersproject/abstract-signer");
- var bignumber_1 = _dereq_("@ethersproject/bignumber");
- var bytes_1 = _dereq_("@ethersproject/bytes");
- var hash_1 = _dereq_("@ethersproject/hash");
- var properties_1 = _dereq_("@ethersproject/properties");
- var strings_1 = _dereq_("@ethersproject/strings");
- var transactions_1 = _dereq_("@ethersproject/transactions");
- var web_1 = _dereq_("@ethersproject/web");
- var logger_1 = _dereq_("@ethersproject/logger");
- var _version_1 = _dereq_("./_version");
- var logger = new logger_1.Logger(_version_1.version);
- var base_provider_1 = _dereq_("./base-provider");
- var errorGas = ["call", "estimateGas"];
- function checkError(method, error, params) {
- // Undo the "convenience" some nodes are attempting to prevent backwards
- // incompatibility; maybe for v6 consider forwarding reverts as errors
- if (method === "call" && error.code === logger_1.Logger.errors.SERVER_ERROR) {
- var e = error.error;
- if (e && e.message.match("reverted") && (0, bytes_1.isHexString)(e.data)) {
- return e.data;
- }
- logger.throwError("missing revert data in call exception", logger_1.Logger.errors.CALL_EXCEPTION, {
- error: error,
- data: "0x"
- });
- }
- var message = error.message;
- if (error.code === logger_1.Logger.errors.SERVER_ERROR && error.error && typeof (error.error.message) === "string") {
- message = error.error.message;
- }
- else if (typeof (error.body) === "string") {
- message = error.body;
- }
- else if (typeof (error.responseText) === "string") {
- message = error.responseText;
- }
- message = (message || "").toLowerCase();
- var transaction = params.transaction || params.signedTransaction;
- // "insufficient funds for gas * price + value + cost(data)"
- if (message.match(/insufficient funds|base fee exceeds gas limit/)) {
- logger.throwError("insufficient funds for intrinsic transaction cost", logger_1.Logger.errors.INSUFFICIENT_FUNDS, {
- error: error,
- method: method,
- transaction: transaction
- });
- }
- // "nonce too low"
- if (message.match(/nonce too low/)) {
- logger.throwError("nonce has already been used", logger_1.Logger.errors.NONCE_EXPIRED, {
- error: error,
- method: method,
- transaction: transaction
- });
- }
- // "replacement transaction underpriced"
- if (message.match(/replacement transaction underpriced/)) {
- logger.throwError("replacement fee too low", logger_1.Logger.errors.REPLACEMENT_UNDERPRICED, {
- error: error,
- method: method,
- transaction: transaction
- });
- }
- // "replacement transaction underpriced"
- if (message.match(/only replay-protected/)) {
- logger.throwError("legacy pre-eip-155 transactions not supported", logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
- error: error,
- method: method,
- transaction: transaction
- });
- }
- if (errorGas.indexOf(method) >= 0 && message.match(/gas required exceeds allowance|always failing transaction|execution reverted/)) {
- logger.throwError("cannot estimate gas; transaction may fail or may require manual gas limit", logger_1.Logger.errors.UNPREDICTABLE_GAS_LIMIT, {
- error: error,
- method: method,
- transaction: transaction
- });
- }
- throw error;
- }
- function timer(timeout) {
- return new Promise(function (resolve) {
- setTimeout(resolve, timeout);
- });
- }
- function getResult(payload) {
- if (payload.error) {
- // @TODO: not any
- var error = new Error(payload.error.message);
- error.code = payload.error.code;
- error.data = payload.error.data;
- throw error;
- }
- return payload.result;
- }
- function getLowerCase(value) {
- if (value) {
- return value.toLowerCase();
- }
- return value;
- }
- var _constructorGuard = {};
- var JsonRpcSigner = /** @class */ (function (_super) {
- __extends(JsonRpcSigner, _super);
- function JsonRpcSigner(constructorGuard, provider, addressOrIndex) {
- var _newTarget = this.constructor;
- var _this = this;
- logger.checkNew(_newTarget, JsonRpcSigner);
- _this = _super.call(this) || this;
- if (constructorGuard !== _constructorGuard) {
- throw new Error("do not call the JsonRpcSigner constructor directly; use provider.getSigner");
- }
- (0, properties_1.defineReadOnly)(_this, "provider", provider);
- if (addressOrIndex == null) {
- addressOrIndex = 0;
- }
- if (typeof (addressOrIndex) === "string") {
- (0, properties_1.defineReadOnly)(_this, "_address", _this.provider.formatter.address(addressOrIndex));
- (0, properties_1.defineReadOnly)(_this, "_index", null);
- }
- else if (typeof (addressOrIndex) === "number") {
- (0, properties_1.defineReadOnly)(_this, "_index", addressOrIndex);
- (0, properties_1.defineReadOnly)(_this, "_address", null);
- }
- else {
- logger.throwArgumentError("invalid address or index", "addressOrIndex", addressOrIndex);
- }
- return _this;
- }
- JsonRpcSigner.prototype.connect = function (provider) {
- return logger.throwError("cannot alter JSON-RPC Signer connection", logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
- operation: "connect"
- });
- };
- JsonRpcSigner.prototype.connectUnchecked = function () {
- return new UncheckedJsonRpcSigner(_constructorGuard, this.provider, this._address || this._index);
- };
- JsonRpcSigner.prototype.getAddress = function () {
- var _this = this;
- if (this._address) {
- return Promise.resolve(this._address);
- }
- return this.provider.send("eth_accounts", []).then(function (accounts) {
- if (accounts.length <= _this._index) {
- logger.throwError("unknown account #" + _this._index, logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
- operation: "getAddress"
- });
- }
- return _this.provider.formatter.address(accounts[_this._index]);
- });
- };
- JsonRpcSigner.prototype.sendUncheckedTransaction = function (transaction) {
- var _this = this;
- transaction = (0, properties_1.shallowCopy)(transaction);
- var fromAddress = this.getAddress().then(function (address) {
- if (address) {
- address = address.toLowerCase();
- }
- return address;
- });
- // The JSON-RPC for eth_sendTransaction uses 90000 gas; if the user
- // wishes to use this, it is easy to specify explicitly, otherwise
- // we look it up for them.
- if (transaction.gasLimit == null) {
- var estimate = (0, properties_1.shallowCopy)(transaction);
- estimate.from = fromAddress;
- transaction.gasLimit = this.provider.estimateGas(estimate);
- }
- if (transaction.to != null) {
- transaction.to = Promise.resolve(transaction.to).then(function (to) { return __awaiter(_this, void 0, void 0, function () {
- var address;
- return __generator(this, function (_a) {
- switch (_a.label) {
- case 0:
- if (to == null) {
- return [2 /*return*/, null];
- }
- return [4 /*yield*/, this.provider.resolveName(to)];
- case 1:
- address = _a.sent();
- if (address == null) {
- logger.throwArgumentError("provided ENS name resolves to null", "tx.to", to);
- }
- return [2 /*return*/, address];
- }
- });
- }); });
- }
- return (0, properties_1.resolveProperties)({
- tx: (0, properties_1.resolveProperties)(transaction),
- sender: fromAddress
- }).then(function (_a) {
- var tx = _a.tx, sender = _a.sender;
- if (tx.from != null) {
- if (tx.from.toLowerCase() !== sender) {
- logger.throwArgumentError("from address mismatch", "transaction", transaction);
- }
- }
- else {
- tx.from = sender;
- }
- var hexTx = _this.provider.constructor.hexlifyTransaction(tx, { from: true });
- return _this.provider.send("eth_sendTransaction", [hexTx]).then(function (hash) {
- return hash;
- }, function (error) {
- return checkError("sendTransaction", error, hexTx);
- });
- });
- };
- JsonRpcSigner.prototype.signTransaction = function (transaction) {
- return logger.throwError("signing transactions is unsupported", logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
- operation: "signTransaction"
- });
- };
- JsonRpcSigner.prototype.sendTransaction = function (transaction) {
- return __awaiter(this, void 0, void 0, function () {
- var blockNumber, hash, error_1;
- var _this = this;
- return __generator(this, function (_a) {
- switch (_a.label) {
- case 0: return [4 /*yield*/, this.provider._getInternalBlockNumber(100 + 2 * this.provider.pollingInterval)];
- case 1:
- blockNumber = _a.sent();
- return [4 /*yield*/, this.sendUncheckedTransaction(transaction)];
- case 2:
- hash = _a.sent();
- _a.label = 3;
- case 3:
- _a.trys.push([3, 5, , 6]);
- return [4 /*yield*/, (0, web_1.poll)(function () { return __awaiter(_this, void 0, void 0, function () {
- var tx;
- return __generator(this, function (_a) {
- switch (_a.label) {
- case 0: return [4 /*yield*/, this.provider.getTransaction(hash)];
- case 1:
- tx = _a.sent();
- if (tx === null) {
- return [2 /*return*/, undefined];
- }
- return [2 /*return*/, this.provider._wrapTransaction(tx, hash, blockNumber)];
- }
- });
- }); }, { oncePoll: this.provider })];
- case 4:
- // Unfortunately, JSON-RPC only provides and opaque transaction hash
- // for a response, and we need the actual transaction, so we poll
- // for it; it should show up very quickly
- return [2 /*return*/, _a.sent()];
- case 5:
- error_1 = _a.sent();
- error_1.transactionHash = hash;
- throw error_1;
- case 6: return [2 /*return*/];
- }
- });
- });
- };
- JsonRpcSigner.prototype.signMessage = function (message) {
- return __awaiter(this, void 0, void 0, function () {
- var data, address;
- return __generator(this, function (_a) {
- switch (_a.label) {
- case 0:
- data = ((typeof (message) === "string") ? (0, strings_1.toUtf8Bytes)(message) : message);
- return [4 /*yield*/, this.getAddress()];
- case 1:
- address = _a.sent();
- return [4 /*yield*/, this.provider.send("personal_sign", [(0, bytes_1.hexlify)(data), address.toLowerCase()])];
- case 2: return [2 /*return*/, _a.sent()];
- }
- });
- });
- };
- JsonRpcSigner.prototype._legacySignMessage = function (message) {
- return __awaiter(this, void 0, void 0, function () {
- var data, address;
- return __generator(this, function (_a) {
- switch (_a.label) {
- case 0:
- data = ((typeof (message) === "string") ? (0, strings_1.toUtf8Bytes)(message) : message);
- return [4 /*yield*/, this.getAddress()];
- case 1:
- address = _a.sent();
- return [4 /*yield*/, this.provider.send("eth_sign", [address.toLowerCase(), (0, bytes_1.hexlify)(data)])];
- case 2:
- // https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_sign
- return [2 /*return*/, _a.sent()];
- }
- });
- });
- };
- JsonRpcSigner.prototype._signTypedData = function (domain, types, value) {
- return __awaiter(this, void 0, void 0, function () {
- var populated, address;
- var _this = this;
- return __generator(this, function (_a) {
- switch (_a.label) {
- case 0: return [4 /*yield*/, hash_1._TypedDataEncoder.resolveNames(domain, types, value, function (name) {
- return _this.provider.resolveName(name);
- })];
- case 1:
- populated = _a.sent();
- return [4 /*yield*/, this.getAddress()];
- case 2:
- address = _a.sent();
- return [4 /*yield*/, this.provider.send("eth_signTypedData_v4", [
- address.toLowerCase(),
- JSON.stringify(hash_1._TypedDataEncoder.getPayload(populated.domain, types, populated.value))
- ])];
- case 3: return [2 /*return*/, _a.sent()];
- }
- });
- });
- };
- JsonRpcSigner.prototype.unlock = function (password) {
- return __awaiter(this, void 0, void 0, function () {
- var provider, address;
- return __generator(this, function (_a) {
- switch (_a.label) {
- case 0:
- provider = this.provider;
- return [4 /*yield*/, this.getAddress()];
- case 1:
- address = _a.sent();
- return [2 /*return*/, provider.send("personal_unlockAccount", [address.toLowerCase(), password, null])];
- }
- });
- });
- };
- return JsonRpcSigner;
- }(abstract_signer_1.Signer));
- exports.JsonRpcSigner = JsonRpcSigner;
- var UncheckedJsonRpcSigner = /** @class */ (function (_super) {
- __extends(UncheckedJsonRpcSigner, _super);
- function UncheckedJsonRpcSigner() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- UncheckedJsonRpcSigner.prototype.sendTransaction = function (transaction) {
- var _this = this;
- return this.sendUncheckedTransaction(transaction).then(function (hash) {
- return {
- hash: hash,
- nonce: null,
- gasLimit: null,
- gasPrice: null,
- data: null,
- value: null,
- chainId: null,
- confirmations: 0,
- from: null,
- wait: function (confirmations) { return _this.provider.waitForTransaction(hash, confirmations); }
- };
- });
- };
- return UncheckedJsonRpcSigner;
- }(JsonRpcSigner));
- var allowedTransactionKeys = {
- chainId: true, data: true, gasLimit: true, gasPrice: true, nonce: true, to: true, value: true,
- type: true, accessList: true,
- maxFeePerGas: true, maxPriorityFeePerGas: true
- };
- var JsonRpcProvider = /** @class */ (function (_super) {
- __extends(JsonRpcProvider, _super);
- function JsonRpcProvider(url, network) {
- var _newTarget = this.constructor;
- var _this = this;
- logger.checkNew(_newTarget, JsonRpcProvider);
- var networkOrReady = network;
- // The network is unknown, query the JSON-RPC for it
- if (networkOrReady == null) {
- networkOrReady = new Promise(function (resolve, reject) {
- setTimeout(function () {
- _this.detectNetwork().then(function (network) {
- resolve(network);
- }, function (error) {
- reject(error);
- });
- }, 0);
- });
- }
- _this = _super.call(this, networkOrReady) || this;
- // Default URL
- if (!url) {
- url = (0, properties_1.getStatic)(_this.constructor, "defaultUrl")();
- }
- if (typeof (url) === "string") {
- (0, properties_1.defineReadOnly)(_this, "connection", Object.freeze({
- url: url
- }));
- }
- else {
- (0, properties_1.defineReadOnly)(_this, "connection", Object.freeze((0, properties_1.shallowCopy)(url)));
- }
- _this._nextId = 42;
- return _this;
- }
- Object.defineProperty(JsonRpcProvider.prototype, "_cache", {
- get: function () {
- if (this._eventLoopCache == null) {
- this._eventLoopCache = {};
- }
- return this._eventLoopCache;
- },
- enumerable: false,
- configurable: true
- });
- JsonRpcProvider.defaultUrl = function () {
- return "http:/\/localhost:8545";
- };
- JsonRpcProvider.prototype.detectNetwork = function () {
- var _this = this;
- if (!this._cache["detectNetwork"]) {
- this._cache["detectNetwork"] = this._uncachedDetectNetwork();
- // Clear this cache at the beginning of the next event loop
- setTimeout(function () {
- _this._cache["detectNetwork"] = null;
- }, 0);
- }
- return this._cache["detectNetwork"];
- };
- JsonRpcProvider.prototype._uncachedDetectNetwork = function () {
- return __awaiter(this, void 0, void 0, function () {
- var chainId, error_2, error_3, getNetwork;
- return __generator(this, function (_a) {
- switch (_a.label) {
- case 0: return [4 /*yield*/, timer(0)];
- case 1:
- _a.sent();
- chainId = null;
- _a.label = 2;
- case 2:
- _a.trys.push([2, 4, , 9]);
- return [4 /*yield*/, this.send("eth_chainId", [])];
- case 3:
- chainId = _a.sent();
- return [3 /*break*/, 9];
- case 4:
- error_2 = _a.sent();
- _a.label = 5;
- case 5:
- _a.trys.push([5, 7, , 8]);
- return [4 /*yield*/, this.send("net_version", [])];
- case 6:
- chainId = _a.sent();
- return [3 /*break*/, 8];
- case 7:
- error_3 = _a.sent();
- return [3 /*break*/, 8];
- case 8: return [3 /*break*/, 9];
- case 9:
- if (chainId != null) {
- getNetwork = (0, properties_1.getStatic)(this.constructor, "getNetwork");
- try {
- return [2 /*return*/, getNetwork(bignumber_1.BigNumber.from(chainId).toNumber())];
- }
- catch (error) {
- return [2 /*return*/, logger.throwError("could not detect network", logger_1.Logger.errors.NETWORK_ERROR, {
- chainId: chainId,
- event: "invalidNetwork",
- serverError: error
- })];
- }
- }
- return [2 /*return*/, logger.throwError("could not detect network", logger_1.Logger.errors.NETWORK_ERROR, {
- event: "noNetwork"
- })];
- }
- });
- });
- };
- JsonRpcProvider.prototype.getSigner = function (addressOrIndex) {
- return new JsonRpcSigner(_constructorGuard, this, addressOrIndex);
- };
- JsonRpcProvider.prototype.getUncheckedSigner = function (addressOrIndex) {
- return this.getSigner(addressOrIndex).connectUnchecked();
- };
- JsonRpcProvider.prototype.listAccounts = function () {
- var _this = this;
- return this.send("eth_accounts", []).then(function (accounts) {
- return accounts.map(function (a) { return _this.formatter.address(a); });
- });
- };
- JsonRpcProvider.prototype.send = function (method, params) {
- var _this = this;
- var request = {
- method: method,
- params: params,
- id: (this._nextId++),
- jsonrpc: "2.0"
- };
- this.emit("debug", {
- action: "request",
- request: (0, properties_1.deepCopy)(request),
- provider: this
- });
- // We can expand this in the future to any call, but for now these
- // are the biggest wins and do not require any serializing parameters.
- var cache = (["eth_chainId", "eth_blockNumber"].indexOf(method) >= 0);
- if (cache && this._cache[method]) {
- return this._cache[method];
- }
- var result = (0, web_1.fetchJson)(this.connection, JSON.stringify(request), getResult).then(function (result) {
- _this.emit("debug", {
- action: "response",
- request: request,
- response: result,
- provider: _this
- });
- return result;
- }, function (error) {
- _this.emit("debug", {
- action: "response",
- error: error,
- request: request,
- provider: _this
- });
- throw error;
- });
- // Cache the fetch, but clear it on the next event loop
- if (cache) {
- this._cache[method] = result;
- setTimeout(function () {
- _this._cache[method] = null;
- }, 0);
- }
- return result;
- };
- JsonRpcProvider.prototype.prepareRequest = function (method, params) {
- switch (method) {
- case "getBlockNumber":
- return ["eth_blockNumber", []];
- case "getGasPrice":
- return ["eth_gasPrice", []];
- case "getBalance":
- return ["eth_getBalance", [getLowerCase(params.address), params.blockTag]];
- case "getTransactionCount":
- return ["eth_getTransactionCount", [getLowerCase(params.address), params.blockTag]];
- case "getCode":
- return ["eth_getCode", [getLowerCase(params.address), params.blockTag]];
- case "getStorageAt":
- return ["eth_getStorageAt", [getLowerCase(params.address), params.position, params.blockTag]];
- case "sendTransaction":
- return ["eth_sendRawTransaction", [params.signedTransaction]];
- case "getBlock":
- if (params.blockTag) {
- return ["eth_getBlockByNumber", [params.blockTag, !!params.includeTransactions]];
- }
- else if (params.blockHash) {
- return ["eth_getBlockByHash", [params.blockHash, !!params.includeTransactions]];
- }
- return null;
- case "getTransaction":
- return ["eth_getTransactionByHash", [params.transactionHash]];
- case "getTransactionReceipt":
- return ["eth_getTransactionReceipt", [params.transactionHash]];
- case "call": {
- var hexlifyTransaction = (0, properties_1.getStatic)(this.constructor, "hexlifyTransaction");
- return ["eth_call", [hexlifyTransaction(params.transaction, { from: true }), params.blockTag]];
- }
- case "estimateGas": {
- var hexlifyTransaction = (0, properties_1.getStatic)(this.constructor, "hexlifyTransaction");
- return ["eth_estimateGas", [hexlifyTransaction(params.transaction, { from: true })]];
- }
- case "getLogs":
- if (params.filter && params.filter.address != null) {
- params.filter.address = getLowerCase(params.filter.address);
- }
- return ["eth_getLogs", [params.filter]];
- default:
- break;
- }
- return null;
- };
- JsonRpcProvider.prototype.perform = function (method, params) {
- return __awaiter(this, void 0, void 0, function () {
- var tx, feeData, args, error_4;
- return __generator(this, function (_a) {
- switch (_a.label) {
- case 0:
- if (!(method === "call" || method === "estimateGas")) return [3 /*break*/, 2];
- tx = params.transaction;
- if (!(tx && tx.type != null && bignumber_1.BigNumber.from(tx.type).isZero())) return [3 /*break*/, 2];
- if (!(tx.maxFeePerGas == null && tx.maxPriorityFeePerGas == null)) return [3 /*break*/, 2];
- return [4 /*yield*/, this.getFeeData()];
- case 1:
- feeData = _a.sent();
- if (feeData.maxFeePerGas == null && feeData.maxPriorityFeePerGas == null) {
- // Network doesn't know about EIP-1559 (and hence type)
- params = (0, properties_1.shallowCopy)(params);
- params.transaction = (0, properties_1.shallowCopy)(tx);
- delete params.transaction.type;
- }
- _a.label = 2;
- case 2:
- args = this.prepareRequest(method, params);
- if (args == null) {
- logger.throwError(method + " not implemented", logger_1.Logger.errors.NOT_IMPLEMENTED, { operation: method });
- }
- _a.label = 3;
- case 3:
- _a.trys.push([3, 5, , 6]);
- return [4 /*yield*/, this.send(args[0], args[1])];
- case 4: return [2 /*return*/, _a.sent()];
- case 5:
- error_4 = _a.sent();
- return [2 /*return*/, checkError(method, error_4, params)];
- case 6: return [2 /*return*/];
- }
- });
- });
- };
- JsonRpcProvider.prototype._startEvent = function (event) {
- if (event.tag === "pending") {
- this._startPending();
- }
- _super.prototype._startEvent.call(this, event);
- };
- JsonRpcProvider.prototype._startPending = function () {
- if (this._pendingFilter != null) {
- return;
- }
- var self = this;
- var pendingFilter = this.send("eth_newPendingTransactionFilter", []);
- this._pendingFilter = pendingFilter;
- pendingFilter.then(function (filterId) {
- function poll() {
- self.send("eth_getFilterChanges", [filterId]).then(function (hashes) {
- if (self._pendingFilter != pendingFilter) {
- return null;
- }
- var seq = Promise.resolve();
- hashes.forEach(function (hash) {
- // @TODO: This should be garbage collected at some point... How? When?
- self._emitted["t:" + hash.toLowerCase()] = "pending";
- seq = seq.then(function () {
- return self.getTransaction(hash).then(function (tx) {
- self.emit("pending", tx);
- return null;
- });
- });
- });
- return seq.then(function () {
- return timer(1000);
- });
- }).then(function () {
- if (self._pendingFilter != pendingFilter) {
- self.send("eth_uninstallFilter", [filterId]);
- return;
- }
- setTimeout(function () { poll(); }, 0);
- return null;
- }).catch(function (error) { });
- }
- poll();
- return filterId;
- }).catch(function (error) { });
- };
- JsonRpcProvider.prototype._stopEvent = function (event) {
- if (event.tag === "pending" && this.listenerCount("pending") === 0) {
- this._pendingFilter = null;
- }
- _super.prototype._stopEvent.call(this, event);
- };
- // Convert an ethers.js transaction into a JSON-RPC transaction
- // - gasLimit => gas
- // - All values hexlified
- // - All numeric values zero-striped
- // - All addresses are lowercased
- // NOTE: This allows a TransactionRequest, but all values should be resolved
- // before this is called
- // @TODO: This will likely be removed in future versions and prepareRequest
- // will be the preferred method for this.
- JsonRpcProvider.hexlifyTransaction = function (transaction, allowExtra) {
- // Check only allowed properties are given
- var allowed = (0, properties_1.shallowCopy)(allowedTransactionKeys);
- if (allowExtra) {
- for (var key in allowExtra) {
- if (allowExtra[key]) {
- allowed[key] = true;
- }
- }
- }
- (0, properties_1.checkProperties)(transaction, allowed);
- var result = {};
- // JSON-RPC now requires numeric values to be "quantity" values
- ["chainId", "gasLimit", "gasPrice", "type", "maxFeePerGas", "maxPriorityFeePerGas", "nonce", "value"].forEach(function (key) {
- if (transaction[key] == null) {
- return;
- }
- var value = (0, bytes_1.hexValue)(transaction[key]);
- if (key === "gasLimit") {
- key = "gas";
- }
- result[key] = value;
- });
- ["from", "to", "data"].forEach(function (key) {
- if (transaction[key] == null) {
- return;
- }
- result[key] = (0, bytes_1.hexlify)(transaction[key]);
- });
- if (transaction.accessList) {
- result["accessList"] = (0, transactions_1.accessListify)(transaction.accessList);
- }
- return result;
- };
- return JsonRpcProvider;
- }(base_provider_1.BaseProvider));
- exports.JsonRpcProvider = JsonRpcProvider;
- },{"./_version":230,"./base-provider":232,"@ethersproject/abstract-signer":187,"@ethersproject/bignumber":196,"@ethersproject/bytes":199,"@ethersproject/hash":209,"@ethersproject/logger":223,"@ethersproject/properties":229,"@ethersproject/strings":266,"@ethersproject/transactions":269,"@ethersproject/web":276}],243:[function(_dereq_,module,exports){
- /* istanbul ignore file */
- "use strict";
- var __extends = (this && this.__extends) || (function () {
- var extendStatics = function (d, b) {
- extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
- return extendStatics(d, b);
- };
- return function (d, b) {
- if (typeof b !== "function" && b !== null)
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.NodesmithProvider = void 0;
- var url_json_rpc_provider_1 = _dereq_("./url-json-rpc-provider");
- var logger_1 = _dereq_("@ethersproject/logger");
- var _version_1 = _dereq_("./_version");
- var logger = new logger_1.Logger(_version_1.version);
- // Special API key provided by Nodesmith for ethers.js
- var defaultApiKey = "ETHERS_JS_SHARED";
- var NodesmithProvider = /** @class */ (function (_super) {
- __extends(NodesmithProvider, _super);
- function NodesmithProvider() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- NodesmithProvider.getApiKey = function (apiKey) {
- if (apiKey && typeof (apiKey) !== "string") {
- logger.throwArgumentError("invalid apiKey", "apiKey", apiKey);
- }
- return apiKey || defaultApiKey;
- };
- NodesmithProvider.getUrl = function (network, apiKey) {
- logger.warn("NodeSmith will be discontinued on 2019-12-20; please migrate to another platform.");
- var host = null;
- switch (network.name) {
- case "homestead":
- host = "https://ethereum.api.nodesmith.io/v1/mainnet/jsonrpc";
- break;
- case "ropsten":
- host = "https://ethereum.api.nodesmith.io/v1/ropsten/jsonrpc";
- break;
- case "rinkeby":
- host = "https://ethereum.api.nodesmith.io/v1/rinkeby/jsonrpc";
- break;
- case "goerli":
- host = "https://ethereum.api.nodesmith.io/v1/goerli/jsonrpc";
- break;
- case "kovan":
- host = "https://ethereum.api.nodesmith.io/v1/kovan/jsonrpc";
- break;
- default:
- logger.throwArgumentError("unsupported network", "network", arguments[0]);
- }
- return (host + "?apiKey=" + apiKey);
- };
- return NodesmithProvider;
- }(url_json_rpc_provider_1.UrlJsonRpcProvider));
- exports.NodesmithProvider = NodesmithProvider;
- },{"./_version":230,"./url-json-rpc-provider":245,"@ethersproject/logger":223}],244:[function(_dereq_,module,exports){
- "use strict";
- var __extends = (this && this.__extends) || (function () {
- var extendStatics = function (d, b) {
- extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
- return extendStatics(d, b);
- };
- return function (d, b) {
- if (typeof b !== "function" && b !== null)
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.PocketProvider = void 0;
- var properties_1 = _dereq_("@ethersproject/properties");
- var logger_1 = _dereq_("@ethersproject/logger");
- var _version_1 = _dereq_("./_version");
- var logger = new logger_1.Logger(_version_1.version);
- var url_json_rpc_provider_1 = _dereq_("./url-json-rpc-provider");
- // These are load-balancer-based application IDs
- var defaultApplicationIds = {
- homestead: "6004bcd10040261633ade990",
- ropsten: "6004bd4d0040261633ade991",
- rinkeby: "6004bda20040261633ade994",
- goerli: "6004bd860040261633ade992",
- };
- var PocketProvider = /** @class */ (function (_super) {
- __extends(PocketProvider, _super);
- function PocketProvider(network, apiKey) {
- // We need a bit of creativity in the constructor because
- // Pocket uses different default API keys based on the network
- var _newTarget = this.constructor;
- var _this = this;
- if (apiKey == null) {
- var n = (0, properties_1.getStatic)(_newTarget, "getNetwork")(network);
- if (n) {
- var applicationId = defaultApplicationIds[n.name];
- if (applicationId) {
- apiKey = {
- applicationId: applicationId,
- loadBalancer: true
- };
- }
- }
- // If there was any issue above, we don't know this network
- if (apiKey == null) {
- logger.throwError("unsupported network", logger_1.Logger.errors.INVALID_ARGUMENT, {
- argument: "network",
- value: network
- });
- }
- }
- _this = _super.call(this, network, apiKey) || this;
- return _this;
- }
- PocketProvider.getApiKey = function (apiKey) {
- // Most API Providers allow null to get the default configuration, but
- // Pocket requires the network to decide the default provider, so we
- // rely on hijacking the constructor to add a sensible default for us
- if (apiKey == null) {
- logger.throwArgumentError("PocketProvider.getApiKey does not support null apiKey", "apiKey", apiKey);
- }
- var apiKeyObj = {
- applicationId: null,
- loadBalancer: false,
- applicationSecretKey: null
- };
- // Parse applicationId and applicationSecretKey
- if (typeof (apiKey) === "string") {
- apiKeyObj.applicationId = apiKey;
- }
- else if (apiKey.applicationSecretKey != null) {
- logger.assertArgument((typeof (apiKey.applicationId) === "string"), "applicationSecretKey requires an applicationId", "applicationId", apiKey.applicationId);
- logger.assertArgument((typeof (apiKey.applicationSecretKey) === "string"), "invalid applicationSecretKey", "applicationSecretKey", "[REDACTED]");
- apiKeyObj.applicationId = apiKey.applicationId;
- apiKeyObj.applicationSecretKey = apiKey.applicationSecretKey;
- apiKeyObj.loadBalancer = !!apiKey.loadBalancer;
- }
- else if (apiKey.applicationId) {
- logger.assertArgument((typeof (apiKey.applicationId) === "string"), "apiKey.applicationId must be a string", "apiKey.applicationId", apiKey.applicationId);
- apiKeyObj.applicationId = apiKey.applicationId;
- apiKeyObj.loadBalancer = !!apiKey.loadBalancer;
- }
- else {
- logger.throwArgumentError("unsupported PocketProvider apiKey", "apiKey", apiKey);
- }
- return apiKeyObj;
- };
- PocketProvider.getUrl = function (network, apiKey) {
- var host = null;
- switch (network ? network.name : "unknown") {
- case "homestead":
- host = "eth-mainnet.gateway.pokt.network";
- break;
- case "ropsten":
- host = "eth-ropsten.gateway.pokt.network";
- break;
- case "rinkeby":
- host = "eth-rinkeby.gateway.pokt.network";
- break;
- case "goerli":
- host = "eth-goerli.gateway.pokt.network";
- break;
- default:
- logger.throwError("unsupported network", logger_1.Logger.errors.INVALID_ARGUMENT, {
- argument: "network",
- value: network
- });
- }
- var url = null;
- if (apiKey.loadBalancer) {
- url = "https://" + host + "/v1/lb/" + apiKey.applicationId;
- }
- else {
- url = "https://" + host + "/v1/" + apiKey.applicationId;
- }
- var connection = { url: url };
- // Initialize empty headers
- connection.headers = {};
- // Apply application secret key
- if (apiKey.applicationSecretKey != null) {
- connection.user = "";
- connection.password = apiKey.applicationSecretKey;
- }
- return connection;
- };
- PocketProvider.prototype.isCommunityResource = function () {
- return (this.applicationId === defaultApplicationIds[this.network.name]);
- };
- return PocketProvider;
- }(url_json_rpc_provider_1.UrlJsonRpcProvider));
- exports.PocketProvider = PocketProvider;
- },{"./_version":230,"./url-json-rpc-provider":245,"@ethersproject/logger":223,"@ethersproject/properties":229}],245:[function(_dereq_,module,exports){
- "use strict";
- var __extends = (this && this.__extends) || (function () {
- var extendStatics = function (d, b) {
- extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
- return extendStatics(d, b);
- };
- return function (d, b) {
- if (typeof b !== "function" && b !== null)
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
- return new (P || (P = Promise))(function (resolve, reject) {
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
- step((generator = generator.apply(thisArg, _arguments || [])).next());
- });
- };
- var __generator = (this && this.__generator) || function (thisArg, body) {
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
- function verb(n) { return function (v) { return step([n, v]); }; }
- function step(op) {
- if (f) throw new TypeError("Generator is already executing.");
- while (_) try {
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
- if (y = 0, t) op = [op[0] & 2, t.value];
- switch (op[0]) {
- case 0: case 1: t = op; break;
- case 4: _.label++; return { value: op[1], done: false };
- case 5: _.label++; y = op[1]; op = [0]; continue;
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
- default:
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
- if (t[2]) _.ops.pop();
- _.trys.pop(); continue;
- }
- op = body.call(thisArg, _);
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
- }
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.UrlJsonRpcProvider = exports.StaticJsonRpcProvider = void 0;
- var properties_1 = _dereq_("@ethersproject/properties");
- var logger_1 = _dereq_("@ethersproject/logger");
- var _version_1 = _dereq_("./_version");
- var logger = new logger_1.Logger(_version_1.version);
- var json_rpc_provider_1 = _dereq_("./json-rpc-provider");
- // A StaticJsonRpcProvider is useful when you *know* for certain that
- // the backend will never change, as it never calls eth_chainId to
- // verify its backend. However, if the backend does change, the effects
- // are undefined and may include:
- // - inconsistent results
- // - locking up the UI
- // - block skew warnings
- // - wrong results
- // If the network is not explicit (i.e. auto-detection is expected), the
- // node MUST be running and available to respond to requests BEFORE this
- // is instantiated.
- var StaticJsonRpcProvider = /** @class */ (function (_super) {
- __extends(StaticJsonRpcProvider, _super);
- function StaticJsonRpcProvider() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- StaticJsonRpcProvider.prototype.detectNetwork = function () {
- return __awaiter(this, void 0, void 0, function () {
- var network;
- return __generator(this, function (_a) {
- switch (_a.label) {
- case 0:
- network = this.network;
- if (!(network == null)) return [3 /*break*/, 2];
- return [4 /*yield*/, _super.prototype.detectNetwork.call(this)];
- case 1:
- network = _a.sent();
- if (!network) {
- logger.throwError("no network detected", logger_1.Logger.errors.UNKNOWN_ERROR, {});
- }
- // If still not set, set it
- if (this._network == null) {
- // A static network does not support "any"
- (0, properties_1.defineReadOnly)(this, "_network", network);
- this.emit("network", network, null);
- }
- _a.label = 2;
- case 2: return [2 /*return*/, network];
- }
- });
- });
- };
- return StaticJsonRpcProvider;
- }(json_rpc_provider_1.JsonRpcProvider));
- exports.StaticJsonRpcProvider = StaticJsonRpcProvider;
- var UrlJsonRpcProvider = /** @class */ (function (_super) {
- __extends(UrlJsonRpcProvider, _super);
- function UrlJsonRpcProvider(network, apiKey) {
- var _newTarget = this.constructor;
- var _this = this;
- logger.checkAbstract(_newTarget, UrlJsonRpcProvider);
- // Normalize the Network and API Key
- network = (0, properties_1.getStatic)(_newTarget, "getNetwork")(network);
- apiKey = (0, properties_1.getStatic)(_newTarget, "getApiKey")(apiKey);
- var connection = (0, properties_1.getStatic)(_newTarget, "getUrl")(network, apiKey);
- _this = _super.call(this, connection, network) || this;
- if (typeof (apiKey) === "string") {
- (0, properties_1.defineReadOnly)(_this, "apiKey", apiKey);
- }
- else if (apiKey != null) {
- Object.keys(apiKey).forEach(function (key) {
- (0, properties_1.defineReadOnly)(_this, key, apiKey[key]);
- });
- }
- return _this;
- }
- UrlJsonRpcProvider.prototype._startPending = function () {
- logger.warn("WARNING: API provider does not support pending filters");
- };
- UrlJsonRpcProvider.prototype.isCommunityResource = function () {
- return false;
- };
- UrlJsonRpcProvider.prototype.getSigner = function (address) {
- return logger.throwError("API provider does not support signing", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { operation: "getSigner" });
- };
- UrlJsonRpcProvider.prototype.listAccounts = function () {
- return Promise.resolve([]);
- };
- // Return a defaultApiKey if null, otherwise validate the API key
- UrlJsonRpcProvider.getApiKey = function (apiKey) {
- return apiKey;
- };
- // Returns the url or connection for the given network and API key. The
- // API key will have been sanitized by the getApiKey first, so any validation
- // or transformations can be done there.
- UrlJsonRpcProvider.getUrl = function (network, apiKey) {
- return logger.throwError("not implemented; sub-classes must override getUrl", logger_1.Logger.errors.NOT_IMPLEMENTED, {
- operation: "getUrl"
- });
- };
- return UrlJsonRpcProvider;
- }(StaticJsonRpcProvider));
- exports.UrlJsonRpcProvider = UrlJsonRpcProvider;
- },{"./_version":230,"./json-rpc-provider":242,"@ethersproject/logger":223,"@ethersproject/properties":229}],246:[function(_dereq_,module,exports){
- "use strict";
- var __extends = (this && this.__extends) || (function () {
- var extendStatics = function (d, b) {
- extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
- return extendStatics(d, b);
- };
- return function (d, b) {
- if (typeof b !== "function" && b !== null)
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.Web3Provider = void 0;
- var properties_1 = _dereq_("@ethersproject/properties");
- var logger_1 = _dereq_("@ethersproject/logger");
- var _version_1 = _dereq_("./_version");
- var logger = new logger_1.Logger(_version_1.version);
- var json_rpc_provider_1 = _dereq_("./json-rpc-provider");
- var _nextId = 1;
- function buildWeb3LegacyFetcher(provider, sendFunc) {
- var fetcher = "Web3LegacyFetcher";
- return function (method, params) {
- var _this = this;
- var request = {
- method: method,
- params: params,
- id: (_nextId++),
- jsonrpc: "2.0"
- };
- return new Promise(function (resolve, reject) {
- _this.emit("debug", {
- action: "request",
- fetcher: fetcher,
- request: (0, properties_1.deepCopy)(request),
- provider: _this
- });
- sendFunc(request, function (error, response) {
- if (error) {
- _this.emit("debug", {
- action: "response",
- fetcher: fetcher,
- error: error,
- request: request,
- provider: _this
- });
- return reject(error);
- }
- _this.emit("debug", {
- action: "response",
- fetcher: fetcher,
- request: request,
- response: response,
- provider: _this
- });
- if (response.error) {
- var error_1 = new Error(response.error.message);
- error_1.code = response.error.code;
- error_1.data = response.error.data;
- return reject(error_1);
- }
- resolve(response.result);
- });
- });
- };
- }
- function buildEip1193Fetcher(provider) {
- return function (method, params) {
- var _this = this;
- if (params == null) {
- params = [];
- }
- var request = { method: method, params: params };
- this.emit("debug", {
- action: "request",
- fetcher: "Eip1193Fetcher",
- request: (0, properties_1.deepCopy)(request),
- provider: this
- });
- return provider.request(request).then(function (response) {
- _this.emit("debug", {
- action: "response",
- fetcher: "Eip1193Fetcher",
- request: request,
- response: response,
- provider: _this
- });
- return response;
- }, function (error) {
- _this.emit("debug", {
- action: "response",
- fetcher: "Eip1193Fetcher",
- request: request,
- error: error,
- provider: _this
- });
- throw error;
- });
- };
- }
- var Web3Provider = /** @class */ (function (_super) {
- __extends(Web3Provider, _super);
- function Web3Provider(provider, network) {
- var _newTarget = this.constructor;
- var _this = this;
- logger.checkNew(_newTarget, Web3Provider);
- if (provider == null) {
- logger.throwArgumentError("missing provider", "provider", provider);
- }
- var path = null;
- var jsonRpcFetchFunc = null;
- var subprovider = null;
- if (typeof (provider) === "function") {
- path = "unknown:";
- jsonRpcFetchFunc = provider;
- }
- else {
- path = provider.host || provider.path || "";
- if (!path && provider.isMetaMask) {
- path = "metamask";
- }
- subprovider = provider;
- if (provider.request) {
- if (path === "") {
- path = "eip-1193:";
- }
- jsonRpcFetchFunc = buildEip1193Fetcher(provider);
- }
- else if (provider.sendAsync) {
- jsonRpcFetchFunc = buildWeb3LegacyFetcher(provider, provider.sendAsync.bind(provider));
- }
- else if (provider.send) {
- jsonRpcFetchFunc = buildWeb3LegacyFetcher(provider, provider.send.bind(provider));
- }
- else {
- logger.throwArgumentError("unsupported provider", "provider", provider);
- }
- if (!path) {
- path = "unknown:";
- }
- }
- _this = _super.call(this, path, network) || this;
- (0, properties_1.defineReadOnly)(_this, "jsonRpcFetchFunc", jsonRpcFetchFunc);
- (0, properties_1.defineReadOnly)(_this, "provider", subprovider);
- return _this;
- }
- Web3Provider.prototype.send = function (method, params) {
- return this.jsonRpcFetchFunc(method, params);
- };
- return Web3Provider;
- }(json_rpc_provider_1.JsonRpcProvider));
- exports.Web3Provider = Web3Provider;
- },{"./_version":230,"./json-rpc-provider":242,"@ethersproject/logger":223,"@ethersproject/properties":229}],247:[function(_dereq_,module,exports){
- "use strict";
- var __extends = (this && this.__extends) || (function () {
- var extendStatics = function (d, b) {
- extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
- return extendStatics(d, b);
- };
- return function (d, b) {
- if (typeof b !== "function" && b !== null)
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
- return new (P || (P = Promise))(function (resolve, reject) {
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
- step((generator = generator.apply(thisArg, _arguments || [])).next());
- });
- };
- var __generator = (this && this.__generator) || function (thisArg, body) {
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
- function verb(n) { return function (v) { return step([n, v]); }; }
- function step(op) {
- if (f) throw new TypeError("Generator is already executing.");
- while (_) try {
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
- if (y = 0, t) op = [op[0] & 2, t.value];
- switch (op[0]) {
- case 0: case 1: t = op; break;
- case 4: _.label++; return { value: op[1], done: false };
- case 5: _.label++; y = op[1]; op = [0]; continue;
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
- default:
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
- if (t[2]) _.ops.pop();
- _.trys.pop(); continue;
- }
- op = body.call(thisArg, _);
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
- }
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.WebSocketProvider = void 0;
- var bignumber_1 = _dereq_("@ethersproject/bignumber");
- var properties_1 = _dereq_("@ethersproject/properties");
- var json_rpc_provider_1 = _dereq_("./json-rpc-provider");
- var ws_1 = _dereq_("./ws");
- var logger_1 = _dereq_("@ethersproject/logger");
- var _version_1 = _dereq_("./_version");
- var logger = new logger_1.Logger(_version_1.version);
- /**
- * Notes:
- *
- * This provider differs a bit from the polling providers. One main
- * difference is how it handles consistency. The polling providers
- * will stall responses to ensure a consistent state, while this
- * WebSocket provider assumes the connected backend will manage this.
- *
- * For example, if a polling provider emits an event which indicates
- * the event occurred in blockhash XXX, a call to fetch that block by
- * its hash XXX, if not present will retry until it is present. This
- * can occur when querying a pool of nodes that are mildly out of sync
- * with each other.
- */
- var NextId = 1;
- // For more info about the Real-time Event API see:
- // https://geth.ethereum.org/docs/rpc/pubsub
- var WebSocketProvider = /** @class */ (function (_super) {
- __extends(WebSocketProvider, _super);
- function WebSocketProvider(url, network) {
- var _this = this;
- // This will be added in the future; please open an issue to expedite
- if (network === "any") {
- logger.throwError("WebSocketProvider does not support 'any' network yet", logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
- operation: "network:any"
- });
- }
- if (typeof (url) === "string") {
- _this = _super.call(this, url, network) || this;
- }
- else {
- _this = _super.call(this, "_websocket", network) || this;
- }
- _this._pollingInterval = -1;
- _this._wsReady = false;
- if (typeof (url) === "string") {
- (0, properties_1.defineReadOnly)(_this, "_websocket", new ws_1.WebSocket(_this.connection.url));
- }
- else {
- (0, properties_1.defineReadOnly)(_this, "_websocket", url);
- }
- (0, properties_1.defineReadOnly)(_this, "_requests", {});
- (0, properties_1.defineReadOnly)(_this, "_subs", {});
- (0, properties_1.defineReadOnly)(_this, "_subIds", {});
- (0, properties_1.defineReadOnly)(_this, "_detectNetwork", _super.prototype.detectNetwork.call(_this));
- // Stall sending requests until the socket is open...
- _this.websocket.onopen = function () {
- _this._wsReady = true;
- Object.keys(_this._requests).forEach(function (id) {
- _this.websocket.send(_this._requests[id].payload);
- });
- };
- _this.websocket.onmessage = function (messageEvent) {
- var data = messageEvent.data;
- var result = JSON.parse(data);
- if (result.id != null) {
- var id = String(result.id);
- var request = _this._requests[id];
- delete _this._requests[id];
- if (result.result !== undefined) {
- request.callback(null, result.result);
- _this.emit("debug", {
- action: "response",
- request: JSON.parse(request.payload),
- response: result.result,
- provider: _this
- });
- }
- else {
- var error = null;
- if (result.error) {
- error = new Error(result.error.message || "unknown error");
- (0, properties_1.defineReadOnly)(error, "code", result.error.code || null);
- (0, properties_1.defineReadOnly)(error, "response", data);
- }
- else {
- error = new Error("unknown error");
- }
- request.callback(error, undefined);
- _this.emit("debug", {
- action: "response",
- error: error,
- request: JSON.parse(request.payload),
- provider: _this
- });
- }
- }
- else if (result.method === "eth_subscription") {
- // Subscription...
- var sub = _this._subs[result.params.subscription];
- if (sub) {
- //this.emit.apply(this, );
- sub.processFunc(result.params.result);
- }
- }
- else {
- console.warn("this should not happen");
- }
- };
- // This Provider does not actually poll, but we want to trigger
- // poll events for things that depend on them (like stalling for
- // block and transaction lookups)
- var fauxPoll = setInterval(function () {
- _this.emit("poll");
- }, 1000);
- if (fauxPoll.unref) {
- fauxPoll.unref();
- }
- return _this;
- }
- Object.defineProperty(WebSocketProvider.prototype, "websocket", {
- // Cannot narrow the type of _websocket, as that is not backwards compatible
- // so we add a getter and let the WebSocket be a public API.
- get: function () { return this._websocket; },
- enumerable: false,
- configurable: true
- });
- WebSocketProvider.prototype.detectNetwork = function () {
- return this._detectNetwork;
- };
- Object.defineProperty(WebSocketProvider.prototype, "pollingInterval", {
- get: function () {
- return 0;
- },
- set: function (value) {
- logger.throwError("cannot set polling interval on WebSocketProvider", logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
- operation: "setPollingInterval"
- });
- },
- enumerable: false,
- configurable: true
- });
- WebSocketProvider.prototype.resetEventsBlock = function (blockNumber) {
- logger.throwError("cannot reset events block on WebSocketProvider", logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
- operation: "resetEventBlock"
- });
- };
- WebSocketProvider.prototype.poll = function () {
- return __awaiter(this, void 0, void 0, function () {
- return __generator(this, function (_a) {
- return [2 /*return*/, null];
- });
- });
- };
- Object.defineProperty(WebSocketProvider.prototype, "polling", {
- set: function (value) {
- if (!value) {
- return;
- }
- logger.throwError("cannot set polling on WebSocketProvider", logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
- operation: "setPolling"
- });
- },
- enumerable: false,
- configurable: true
- });
- WebSocketProvider.prototype.send = function (method, params) {
- var _this = this;
- var rid = NextId++;
- return new Promise(function (resolve, reject) {
- function callback(error, result) {
- if (error) {
- return reject(error);
- }
- return resolve(result);
- }
- var payload = JSON.stringify({
- method: method,
- params: params,
- id: rid,
- jsonrpc: "2.0"
- });
- _this.emit("debug", {
- action: "request",
- request: JSON.parse(payload),
- provider: _this
- });
- _this._requests[String(rid)] = { callback: callback, payload: payload };
- if (_this._wsReady) {
- _this.websocket.send(payload);
- }
- });
- };
- WebSocketProvider.defaultUrl = function () {
- return "ws:/\/localhost:8546";
- };
- WebSocketProvider.prototype._subscribe = function (tag, param, processFunc) {
- return __awaiter(this, void 0, void 0, function () {
- var subIdPromise, subId;
- var _this = this;
- return __generator(this, function (_a) {
- switch (_a.label) {
- case 0:
- subIdPromise = this._subIds[tag];
- if (subIdPromise == null) {
- subIdPromise = Promise.all(param).then(function (param) {
- return _this.send("eth_subscribe", param);
- });
- this._subIds[tag] = subIdPromise;
- }
- return [4 /*yield*/, subIdPromise];
- case 1:
- subId = _a.sent();
- this._subs[subId] = { tag: tag, processFunc: processFunc };
- return [2 /*return*/];
- }
- });
- });
- };
- WebSocketProvider.prototype._startEvent = function (event) {
- var _this = this;
- switch (event.type) {
- case "block":
- this._subscribe("block", ["newHeads"], function (result) {
- var blockNumber = bignumber_1.BigNumber.from(result.number).toNumber();
- _this._emitted.block = blockNumber;
- _this.emit("block", blockNumber);
- });
- break;
- case "pending":
- this._subscribe("pending", ["newPendingTransactions"], function (result) {
- _this.emit("pending", result);
- });
- break;
- case "filter":
- this._subscribe(event.tag, ["logs", this._getFilter(event.filter)], function (result) {
- if (result.removed == null) {
- result.removed = false;
- }
- _this.emit(event.filter, _this.formatter.filterLog(result));
- });
- break;
- case "tx": {
- var emitReceipt_1 = function (event) {
- var hash = event.hash;
- _this.getTransactionReceipt(hash).then(function (receipt) {
- if (!receipt) {
- return;
- }
- _this.emit(hash, receipt);
- });
- };
- // In case it is already mined
- emitReceipt_1(event);
- // To keep things simple, we start up a single newHeads subscription
- // to keep an eye out for transactions we are watching for.
- // Starting a subscription for an event (i.e. "tx") that is already
- // running is (basically) a nop.
- this._subscribe("tx", ["newHeads"], function (result) {
- _this._events.filter(function (e) { return (e.type === "tx"); }).forEach(emitReceipt_1);
- });
- break;
- }
- // Nothing is needed
- case "debug":
- case "poll":
- case "willPoll":
- case "didPoll":
- case "error":
- break;
- default:
- console.log("unhandled:", event);
- break;
- }
- };
- WebSocketProvider.prototype._stopEvent = function (event) {
- var _this = this;
- var tag = event.tag;
- if (event.type === "tx") {
- // There are remaining transaction event listeners
- if (this._events.filter(function (e) { return (e.type === "tx"); }).length) {
- return;
- }
- tag = "tx";
- }
- else if (this.listenerCount(event.event)) {
- // There are remaining event listeners
- return;
- }
- var subId = this._subIds[tag];
- if (!subId) {
- return;
- }
- delete this._subIds[tag];
- subId.then(function (subId) {
- if (!_this._subs[subId]) {
- return;
- }
- delete _this._subs[subId];
- _this.send("eth_unsubscribe", [subId]);
- });
- };
- WebSocketProvider.prototype.destroy = function () {
- return __awaiter(this, void 0, void 0, function () {
- var _this = this;
- return __generator(this, function (_a) {
- switch (_a.label) {
- case 0:
- if (!(this.websocket.readyState === ws_1.WebSocket.CONNECTING)) return [3 /*break*/, 2];
- return [4 /*yield*/, (new Promise(function (resolve) {
- _this.websocket.onopen = function () {
- resolve(true);
- };
- _this.websocket.onerror = function () {
- resolve(false);
- };
- }))];
- case 1:
- _a.sent();
- _a.label = 2;
- case 2:
- // Hangup
- // See: https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent#Status_codes
- this.websocket.close(1000);
- return [2 /*return*/];
- }
- });
- });
- };
- return WebSocketProvider;
- }(json_rpc_provider_1.JsonRpcProvider));
- exports.WebSocketProvider = WebSocketProvider;
- },{"./_version":230,"./json-rpc-provider":242,"./ws":234,"@ethersproject/bignumber":196,"@ethersproject/logger":223,"@ethersproject/properties":229}],248:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.version = void 0;
- exports.version = "random/5.6.0";
- },{}],249:[function(_dereq_,module,exports){
- (function (global){(function (){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.randomBytes = void 0;
- var bytes_1 = _dereq_("@ethersproject/bytes");
- var logger_1 = _dereq_("@ethersproject/logger");
- var _version_1 = _dereq_("./_version");
- var logger = new logger_1.Logger(_version_1.version);
- // Debugging line for testing browser lib in node
- //const window = { crypto: { getRandomValues: () => { } } };
- // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis
- function getGlobal() {
- if (typeof self !== 'undefined') {
- return self;
- }
- if (typeof window !== 'undefined') {
- return window;
- }
- if (typeof global !== 'undefined') {
- return global;
- }
- throw new Error('unable to locate global object');
- }
- ;
- var anyGlobal = getGlobal();
- var crypto = anyGlobal.crypto || anyGlobal.msCrypto;
- if (!crypto || !crypto.getRandomValues) {
- logger.warn("WARNING: Missing strong random number source");
- crypto = {
- getRandomValues: function (buffer) {
- return logger.throwError("no secure random source avaialble", logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
- operation: "crypto.getRandomValues"
- });
- }
- };
- }
- function randomBytes(length) {
- if (length <= 0 || length > 1024 || (length % 1) || length != length) {
- logger.throwArgumentError("invalid length", "length", length);
- }
- var result = new Uint8Array(length);
- crypto.getRandomValues(result);
- return (0, bytes_1.arrayify)(result);
- }
- exports.randomBytes = randomBytes;
- ;
- }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
- },{"./_version":248,"@ethersproject/bytes":199,"@ethersproject/logger":223}],250:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.shuffled = exports.randomBytes = void 0;
- var random_1 = _dereq_("./random");
- Object.defineProperty(exports, "randomBytes", { enumerable: true, get: function () { return random_1.randomBytes; } });
- var shuffle_1 = _dereq_("./shuffle");
- Object.defineProperty(exports, "shuffled", { enumerable: true, get: function () { return shuffle_1.shuffled; } });
- },{"./random":249,"./shuffle":251}],251:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.shuffled = void 0;
- function shuffled(array) {
- array = array.slice();
- for (var i = array.length - 1; i > 0; i--) {
- var j = Math.floor(Math.random() * (i + 1));
- var tmp = array[i];
- array[i] = array[j];
- array[j] = tmp;
- }
- return array;
- }
- exports.shuffled = shuffled;
- },{}],252:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.version = void 0;
- exports.version = "rlp/5.6.0";
- },{}],253:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.decode = exports.encode = void 0;
- //See: https://github.com/ethereum/wiki/wiki/RLP
- var bytes_1 = _dereq_("@ethersproject/bytes");
- var logger_1 = _dereq_("@ethersproject/logger");
- var _version_1 = _dereq_("./_version");
- var logger = new logger_1.Logger(_version_1.version);
- function arrayifyInteger(value) {
- var result = [];
- while (value) {
- result.unshift(value & 0xff);
- value >>= 8;
- }
- return result;
- }
- function unarrayifyInteger(data, offset, length) {
- var result = 0;
- for (var i = 0; i < length; i++) {
- result = (result * 256) + data[offset + i];
- }
- return result;
- }
- function _encode(object) {
- if (Array.isArray(object)) {
- var payload_1 = [];
- object.forEach(function (child) {
- payload_1 = payload_1.concat(_encode(child));
- });
- if (payload_1.length <= 55) {
- payload_1.unshift(0xc0 + payload_1.length);
- return payload_1;
- }
- var length_1 = arrayifyInteger(payload_1.length);
- length_1.unshift(0xf7 + length_1.length);
- return length_1.concat(payload_1);
- }
- if (!(0, bytes_1.isBytesLike)(object)) {
- logger.throwArgumentError("RLP object must be BytesLike", "object", object);
- }
- var data = Array.prototype.slice.call((0, bytes_1.arrayify)(object));
- if (data.length === 1 && data[0] <= 0x7f) {
- return data;
- }
- else if (data.length <= 55) {
- data.unshift(0x80 + data.length);
- return data;
- }
- var length = arrayifyInteger(data.length);
- length.unshift(0xb7 + length.length);
- return length.concat(data);
- }
- function encode(object) {
- return (0, bytes_1.hexlify)(_encode(object));
- }
- exports.encode = encode;
- function _decodeChildren(data, offset, childOffset, length) {
- var result = [];
- while (childOffset < offset + 1 + length) {
- var decoded = _decode(data, childOffset);
- result.push(decoded.result);
- childOffset += decoded.consumed;
- if (childOffset > offset + 1 + length) {
- logger.throwError("child data too short", logger_1.Logger.errors.BUFFER_OVERRUN, {});
- }
- }
- return { consumed: (1 + length), result: result };
- }
- // returns { consumed: number, result: Object }
- function _decode(data, offset) {
- if (data.length === 0) {
- logger.throwError("data too short", logger_1.Logger.errors.BUFFER_OVERRUN, {});
- }
- // Array with extra length prefix
- if (data[offset] >= 0xf8) {
- var lengthLength = data[offset] - 0xf7;
- if (offset + 1 + lengthLength > data.length) {
- logger.throwError("data short segment too short", logger_1.Logger.errors.BUFFER_OVERRUN, {});
- }
- var length_2 = unarrayifyInteger(data, offset + 1, lengthLength);
- if (offset + 1 + lengthLength + length_2 > data.length) {
- logger.throwError("data long segment too short", logger_1.Logger.errors.BUFFER_OVERRUN, {});
- }
- return _decodeChildren(data, offset, offset + 1 + lengthLength, lengthLength + length_2);
- }
- else if (data[offset] >= 0xc0) {
- var length_3 = data[offset] - 0xc0;
- if (offset + 1 + length_3 > data.length) {
- logger.throwError("data array too short", logger_1.Logger.errors.BUFFER_OVERRUN, {});
- }
- return _decodeChildren(data, offset, offset + 1, length_3);
- }
- else if (data[offset] >= 0xb8) {
- var lengthLength = data[offset] - 0xb7;
- if (offset + 1 + lengthLength > data.length) {
- logger.throwError("data array too short", logger_1.Logger.errors.BUFFER_OVERRUN, {});
- }
- var length_4 = unarrayifyInteger(data, offset + 1, lengthLength);
- if (offset + 1 + lengthLength + length_4 > data.length) {
- logger.throwError("data array too short", logger_1.Logger.errors.BUFFER_OVERRUN, {});
- }
- var result = (0, bytes_1.hexlify)(data.slice(offset + 1 + lengthLength, offset + 1 + lengthLength + length_4));
- return { consumed: (1 + lengthLength + length_4), result: result };
- }
- else if (data[offset] >= 0x80) {
- var length_5 = data[offset] - 0x80;
- if (offset + 1 + length_5 > data.length) {
- logger.throwError("data too short", logger_1.Logger.errors.BUFFER_OVERRUN, {});
- }
- var result = (0, bytes_1.hexlify)(data.slice(offset + 1, offset + 1 + length_5));
- return { consumed: (1 + length_5), result: result };
- }
- return { consumed: 1, result: (0, bytes_1.hexlify)(data[offset]) };
- }
- function decode(data) {
- var bytes = (0, bytes_1.arrayify)(data);
- var decoded = _decode(bytes, 0);
- if (decoded.consumed !== bytes.length) {
- logger.throwArgumentError("invalid rlp data", "data", data);
- }
- return decoded.result;
- }
- exports.decode = decode;
- },{"./_version":252,"@ethersproject/bytes":199,"@ethersproject/logger":223}],254:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.version = void 0;
- exports.version = "sha2/5.6.0";
- },{}],255:[function(_dereq_,module,exports){
- "use strict";
- var __importDefault = (this && this.__importDefault) || function (mod) {
- return (mod && mod.__esModule) ? mod : { "default": mod };
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.computeHmac = exports.sha512 = exports.sha256 = exports.ripemd160 = void 0;
- var hash_js_1 = __importDefault(_dereq_("hash.js"));
- //const _ripemd160 = _hash.ripemd160;
- var bytes_1 = _dereq_("@ethersproject/bytes");
- var types_1 = _dereq_("./types");
- var logger_1 = _dereq_("@ethersproject/logger");
- var _version_1 = _dereq_("./_version");
- var logger = new logger_1.Logger(_version_1.version);
- function ripemd160(data) {
- return "0x" + (hash_js_1.default.ripemd160().update((0, bytes_1.arrayify)(data)).digest("hex"));
- }
- exports.ripemd160 = ripemd160;
- function sha256(data) {
- return "0x" + (hash_js_1.default.sha256().update((0, bytes_1.arrayify)(data)).digest("hex"));
- }
- exports.sha256 = sha256;
- function sha512(data) {
- return "0x" + (hash_js_1.default.sha512().update((0, bytes_1.arrayify)(data)).digest("hex"));
- }
- exports.sha512 = sha512;
- function computeHmac(algorithm, key, data) {
- if (!types_1.SupportedAlgorithm[algorithm]) {
- logger.throwError("unsupported algorithm " + algorithm, logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
- operation: "hmac",
- algorithm: algorithm
- });
- }
- return "0x" + hash_js_1.default.hmac(hash_js_1.default[algorithm], (0, bytes_1.arrayify)(key)).update((0, bytes_1.arrayify)(data)).digest("hex");
- }
- exports.computeHmac = computeHmac;
- },{"./_version":254,"./types":257,"@ethersproject/bytes":199,"@ethersproject/logger":223,"hash.js":776}],256:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.SupportedAlgorithm = exports.sha512 = exports.sha256 = exports.ripemd160 = exports.computeHmac = void 0;
- var sha2_1 = _dereq_("./sha2");
- Object.defineProperty(exports, "computeHmac", { enumerable: true, get: function () { return sha2_1.computeHmac; } });
- Object.defineProperty(exports, "ripemd160", { enumerable: true, get: function () { return sha2_1.ripemd160; } });
- Object.defineProperty(exports, "sha256", { enumerable: true, get: function () { return sha2_1.sha256; } });
- Object.defineProperty(exports, "sha512", { enumerable: true, get: function () { return sha2_1.sha512; } });
- var types_1 = _dereq_("./types");
- Object.defineProperty(exports, "SupportedAlgorithm", { enumerable: true, get: function () { return types_1.SupportedAlgorithm; } });
- },{"./sha2":255,"./types":257}],257:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.SupportedAlgorithm = void 0;
- var SupportedAlgorithm;
- (function (SupportedAlgorithm) {
- SupportedAlgorithm["sha256"] = "sha256";
- SupportedAlgorithm["sha512"] = "sha512";
- })(SupportedAlgorithm = exports.SupportedAlgorithm || (exports.SupportedAlgorithm = {}));
- ;
- },{}],258:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.version = void 0;
- exports.version = "signing-key/5.6.0";
- },{}],259:[function(_dereq_,module,exports){
- "use strict";
- var __importDefault = (this && this.__importDefault) || function (mod) {
- return (mod && mod.__esModule) ? mod : { "default": mod };
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.EC = void 0;
- var elliptic_1 = __importDefault(_dereq_("elliptic"));
- var EC = elliptic_1.default.ec;
- exports.EC = EC;
- },{"elliptic":754}],260:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.computePublicKey = exports.recoverPublicKey = exports.SigningKey = void 0;
- var elliptic_1 = _dereq_("./elliptic");
- var bytes_1 = _dereq_("@ethersproject/bytes");
- var properties_1 = _dereq_("@ethersproject/properties");
- var logger_1 = _dereq_("@ethersproject/logger");
- var _version_1 = _dereq_("./_version");
- var logger = new logger_1.Logger(_version_1.version);
- var _curve = null;
- function getCurve() {
- if (!_curve) {
- _curve = new elliptic_1.EC("secp256k1");
- }
- return _curve;
- }
- var SigningKey = /** @class */ (function () {
- function SigningKey(privateKey) {
- (0, properties_1.defineReadOnly)(this, "curve", "secp256k1");
- (0, properties_1.defineReadOnly)(this, "privateKey", (0, bytes_1.hexlify)(privateKey));
- var keyPair = getCurve().keyFromPrivate((0, bytes_1.arrayify)(this.privateKey));
- (0, properties_1.defineReadOnly)(this, "publicKey", "0x" + keyPair.getPublic(false, "hex"));
- (0, properties_1.defineReadOnly)(this, "compressedPublicKey", "0x" + keyPair.getPublic(true, "hex"));
- (0, properties_1.defineReadOnly)(this, "_isSigningKey", true);
- }
- SigningKey.prototype._addPoint = function (other) {
- var p0 = getCurve().keyFromPublic((0, bytes_1.arrayify)(this.publicKey));
- var p1 = getCurve().keyFromPublic((0, bytes_1.arrayify)(other));
- return "0x" + p0.pub.add(p1.pub).encodeCompressed("hex");
- };
- SigningKey.prototype.signDigest = function (digest) {
- var keyPair = getCurve().keyFromPrivate((0, bytes_1.arrayify)(this.privateKey));
- var digestBytes = (0, bytes_1.arrayify)(digest);
- if (digestBytes.length !== 32) {
- logger.throwArgumentError("bad digest length", "digest", digest);
- }
- var signature = keyPair.sign(digestBytes, { canonical: true });
- return (0, bytes_1.splitSignature)({
- recoveryParam: signature.recoveryParam,
- r: (0, bytes_1.hexZeroPad)("0x" + signature.r.toString(16), 32),
- s: (0, bytes_1.hexZeroPad)("0x" + signature.s.toString(16), 32),
- });
- };
- SigningKey.prototype.computeSharedSecret = function (otherKey) {
- var keyPair = getCurve().keyFromPrivate((0, bytes_1.arrayify)(this.privateKey));
- var otherKeyPair = getCurve().keyFromPublic((0, bytes_1.arrayify)(computePublicKey(otherKey)));
- return (0, bytes_1.hexZeroPad)("0x" + keyPair.derive(otherKeyPair.getPublic()).toString(16), 32);
- };
- SigningKey.isSigningKey = function (value) {
- return !!(value && value._isSigningKey);
- };
- return SigningKey;
- }());
- exports.SigningKey = SigningKey;
- function recoverPublicKey(digest, signature) {
- var sig = (0, bytes_1.splitSignature)(signature);
- var rs = { r: (0, bytes_1.arrayify)(sig.r), s: (0, bytes_1.arrayify)(sig.s) };
- return "0x" + getCurve().recoverPubKey((0, bytes_1.arrayify)(digest), rs, sig.recoveryParam).encode("hex", false);
- }
- exports.recoverPublicKey = recoverPublicKey;
- function computePublicKey(key, compressed) {
- var bytes = (0, bytes_1.arrayify)(key);
- if (bytes.length === 32) {
- var signingKey = new SigningKey(bytes);
- if (compressed) {
- return "0x" + getCurve().keyFromPrivate(bytes).getPublic(true, "hex");
- }
- return signingKey.publicKey;
- }
- else if (bytes.length === 33) {
- if (compressed) {
- return (0, bytes_1.hexlify)(bytes);
- }
- return "0x" + getCurve().keyFromPublic(bytes).getPublic(false, "hex");
- }
- else if (bytes.length === 65) {
- if (!compressed) {
- return (0, bytes_1.hexlify)(bytes);
- }
- return "0x" + getCurve().keyFromPublic(bytes).getPublic(true, "hex");
- }
- return logger.throwArgumentError("invalid public or private key", "key", "[REDACTED]");
- }
- exports.computePublicKey = computePublicKey;
- },{"./_version":258,"./elliptic":259,"@ethersproject/bytes":199,"@ethersproject/logger":223,"@ethersproject/properties":229}],261:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.version = void 0;
- exports.version = "solidity/5.6.0";
- },{}],262:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.sha256 = exports.keccak256 = exports.pack = void 0;
- var bignumber_1 = _dereq_("@ethersproject/bignumber");
- var bytes_1 = _dereq_("@ethersproject/bytes");
- var keccak256_1 = _dereq_("@ethersproject/keccak256");
- var sha2_1 = _dereq_("@ethersproject/sha2");
- var strings_1 = _dereq_("@ethersproject/strings");
- var regexBytes = new RegExp("^bytes([0-9]+)$");
- var regexNumber = new RegExp("^(u?int)([0-9]*)$");
- var regexArray = new RegExp("^(.*)\\[([0-9]*)\\]$");
- var Zeros = "0000000000000000000000000000000000000000000000000000000000000000";
- var logger_1 = _dereq_("@ethersproject/logger");
- var _version_1 = _dereq_("./_version");
- var logger = new logger_1.Logger(_version_1.version);
- function _pack(type, value, isArray) {
- switch (type) {
- case "address":
- if (isArray) {
- return (0, bytes_1.zeroPad)(value, 32);
- }
- return (0, bytes_1.arrayify)(value);
- case "string":
- return (0, strings_1.toUtf8Bytes)(value);
- case "bytes":
- return (0, bytes_1.arrayify)(value);
- case "bool":
- value = (value ? "0x01" : "0x00");
- if (isArray) {
- return (0, bytes_1.zeroPad)(value, 32);
- }
- return (0, bytes_1.arrayify)(value);
- }
- var match = type.match(regexNumber);
- if (match) {
- //let signed = (match[1] === "int")
- var size = parseInt(match[2] || "256");
- if ((match[2] && String(size) !== match[2]) || (size % 8 !== 0) || size === 0 || size > 256) {
- logger.throwArgumentError("invalid number type", "type", type);
- }
- if (isArray) {
- size = 256;
- }
- value = bignumber_1.BigNumber.from(value).toTwos(size);
- return (0, bytes_1.zeroPad)(value, size / 8);
- }
- match = type.match(regexBytes);
- if (match) {
- var size = parseInt(match[1]);
- if (String(size) !== match[1] || size === 0 || size > 32) {
- logger.throwArgumentError("invalid bytes type", "type", type);
- }
- if ((0, bytes_1.arrayify)(value).byteLength !== size) {
- logger.throwArgumentError("invalid value for " + type, "value", value);
- }
- if (isArray) {
- return (0, bytes_1.arrayify)((value + Zeros).substring(0, 66));
- }
- return value;
- }
- match = type.match(regexArray);
- if (match && Array.isArray(value)) {
- var baseType_1 = match[1];
- var count = parseInt(match[2] || String(value.length));
- if (count != value.length) {
- logger.throwArgumentError("invalid array length for " + type, "value", value);
- }
- var result_1 = [];
- value.forEach(function (value) {
- result_1.push(_pack(baseType_1, value, true));
- });
- return (0, bytes_1.concat)(result_1);
- }
- return logger.throwArgumentError("invalid type", "type", type);
- }
- // @TODO: Array Enum
- function pack(types, values) {
- if (types.length != values.length) {
- logger.throwArgumentError("wrong number of values; expected ${ types.length }", "values", values);
- }
- var tight = [];
- types.forEach(function (type, index) {
- tight.push(_pack(type, values[index]));
- });
- return (0, bytes_1.hexlify)((0, bytes_1.concat)(tight));
- }
- exports.pack = pack;
- function keccak256(types, values) {
- return (0, keccak256_1.keccak256)(pack(types, values));
- }
- exports.keccak256 = keccak256;
- function sha256(types, values) {
- return (0, sha2_1.sha256)(pack(types, values));
- }
- exports.sha256 = sha256;
- },{"./_version":261,"@ethersproject/bignumber":196,"@ethersproject/bytes":199,"@ethersproject/keccak256":221,"@ethersproject/logger":223,"@ethersproject/sha2":256,"@ethersproject/strings":266}],263:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.version = void 0;
- exports.version = "strings/5.6.0";
- },{}],264:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.parseBytes32String = exports.formatBytes32String = void 0;
- var constants_1 = _dereq_("@ethersproject/constants");
- var bytes_1 = _dereq_("@ethersproject/bytes");
- var utf8_1 = _dereq_("./utf8");
- function formatBytes32String(text) {
- // Get the bytes
- var bytes = (0, utf8_1.toUtf8Bytes)(text);
- // Check we have room for null-termination
- if (bytes.length > 31) {
- throw new Error("bytes32 string must be less than 32 bytes");
- }
- // Zero-pad (implicitly null-terminates)
- return (0, bytes_1.hexlify)((0, bytes_1.concat)([bytes, constants_1.HashZero]).slice(0, 32));
- }
- exports.formatBytes32String = formatBytes32String;
- function parseBytes32String(bytes) {
- var data = (0, bytes_1.arrayify)(bytes);
- // Must be 32 bytes with a null-termination
- if (data.length !== 32) {
- throw new Error("invalid bytes32 - not 32 bytes long");
- }
- if (data[31] !== 0) {
- throw new Error("invalid bytes32 string - no null terminator");
- }
- // Find the null termination
- var length = 31;
- while (data[length - 1] === 0) {
- length--;
- }
- // Determine the string value
- return (0, utf8_1.toUtf8String)(data.slice(0, length));
- }
- exports.parseBytes32String = parseBytes32String;
- },{"./utf8":267,"@ethersproject/bytes":199,"@ethersproject/constants":203}],265:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.nameprep = exports._nameprepTableC = exports._nameprepTableB2 = exports._nameprepTableA1 = void 0;
- var utf8_1 = _dereq_("./utf8");
- function bytes2(data) {
- if ((data.length % 4) !== 0) {
- throw new Error("bad data");
- }
- var result = [];
- for (var i = 0; i < data.length; i += 4) {
- result.push(parseInt(data.substring(i, i + 4), 16));
- }
- return result;
- }
- function createTable(data, func) {
- if (!func) {
- func = function (value) { return [parseInt(value, 16)]; };
- }
- var lo = 0;
- var result = {};
- data.split(",").forEach(function (pair) {
- var comps = pair.split(":");
- lo += parseInt(comps[0], 16);
- result[lo] = func(comps[1]);
- });
- return result;
- }
- function createRangeTable(data) {
- var hi = 0;
- return data.split(",").map(function (v) {
- var comps = v.split("-");
- if (comps.length === 1) {
- comps[1] = "0";
- }
- else if (comps[1] === "") {
- comps[1] = "1";
- }
- var lo = hi + parseInt(comps[0], 16);
- hi = parseInt(comps[1], 16);
- return { l: lo, h: hi };
- });
- }
- function matchMap(value, ranges) {
- var lo = 0;
- for (var i = 0; i < ranges.length; i++) {
- var range = ranges[i];
- lo += range.l;
- if (value >= lo && value <= lo + range.h && ((value - lo) % (range.d || 1)) === 0) {
- if (range.e && range.e.indexOf(value - lo) !== -1) {
- continue;
- }
- return range;
- }
- }
- return null;
- }
- var Table_A_1_ranges = createRangeTable("221,13-1b,5f-,40-10,51-f,11-3,3-3,2-2,2-4,8,2,15,2d,28-8,88,48,27-,3-5,11-20,27-,8,28,3-5,12,18,b-a,1c-4,6-16,2-d,2-2,2,1b-4,17-9,8f-,10,f,1f-2,1c-34,33-14e,4,36-,13-,6-2,1a-f,4,9-,3-,17,8,2-2,5-,2,8-,3-,4-8,2-3,3,6-,16-6,2-,7-3,3-,17,8,3,3,3-,2,6-3,3-,4-a,5,2-6,10-b,4,8,2,4,17,8,3,6-,b,4,4-,2-e,2-4,b-10,4,9-,3-,17,8,3-,5-,9-2,3-,4-7,3-3,3,4-3,c-10,3,7-2,4,5-2,3,2,3-2,3-2,4-2,9,4-3,6-2,4,5-8,2-e,d-d,4,9,4,18,b,6-3,8,4,5-6,3-8,3-3,b-11,3,9,4,18,b,6-3,8,4,5-6,3-6,2,3-3,b-11,3,9,4,18,11-3,7-,4,5-8,2-7,3-3,b-11,3,13-2,19,a,2-,8-2,2-3,7,2,9-11,4-b,3b-3,1e-24,3,2-,3,2-,2-5,5,8,4,2,2-,3,e,4-,6,2,7-,b-,3-21,49,23-5,1c-3,9,25,10-,2-2f,23,6,3,8-2,5-5,1b-45,27-9,2a-,2-3,5b-4,45-4,53-5,8,40,2,5-,8,2,5-,28,2,5-,20,2,5-,8,2,5-,8,8,18,20,2,5-,8,28,14-5,1d-22,56-b,277-8,1e-2,52-e,e,8-a,18-8,15-b,e,4,3-b,5e-2,b-15,10,b-5,59-7,2b-555,9d-3,5b-5,17-,7-,27-,7-,9,2,2,2,20-,36,10,f-,7,14-,4,a,54-3,2-6,6-5,9-,1c-10,13-1d,1c-14,3c-,10-6,32-b,240-30,28-18,c-14,a0,115-,3,66-,b-76,5,5-,1d,24,2,5-2,2,8-,35-2,19,f-10,1d-3,311-37f,1b,5a-b,d7-19,d-3,41,57-,68-4,29-3,5f,29-37,2e-2,25-c,2c-2,4e-3,30,78-3,64-,20,19b7-49,51a7-59,48e-2,38-738,2ba5-5b,222f-,3c-94,8-b,6-4,1b,6,2,3,3,6d-20,16e-f,41-,37-7,2e-2,11-f,5-b,18-,b,14,5-3,6,88-,2,bf-2,7-,7-,7-,4-2,8,8-9,8-2ff,20,5-b,1c-b4,27-,27-cbb1,f7-9,28-2,b5-221,56,48,3-,2-,3-,5,d,2,5,3,42,5-,9,8,1d,5,6,2-2,8,153-3,123-3,33-27fd,a6da-5128,21f-5df,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3,2-1d,61-ff7d");
- // @TODO: Make this relative...
- var Table_B_1_flags = "ad,34f,1806,180b,180c,180d,200b,200c,200d,2060,feff".split(",").map(function (v) { return parseInt(v, 16); });
- var Table_B_2_ranges = [
- { h: 25, s: 32, l: 65 },
- { h: 30, s: 32, e: [23], l: 127 },
- { h: 54, s: 1, e: [48], l: 64, d: 2 },
- { h: 14, s: 1, l: 57, d: 2 },
- { h: 44, s: 1, l: 17, d: 2 },
- { h: 10, s: 1, e: [2, 6, 8], l: 61, d: 2 },
- { h: 16, s: 1, l: 68, d: 2 },
- { h: 84, s: 1, e: [18, 24, 66], l: 19, d: 2 },
- { h: 26, s: 32, e: [17], l: 435 },
- { h: 22, s: 1, l: 71, d: 2 },
- { h: 15, s: 80, l: 40 },
- { h: 31, s: 32, l: 16 },
- { h: 32, s: 1, l: 80, d: 2 },
- { h: 52, s: 1, l: 42, d: 2 },
- { h: 12, s: 1, l: 55, d: 2 },
- { h: 40, s: 1, e: [38], l: 15, d: 2 },
- { h: 14, s: 1, l: 48, d: 2 },
- { h: 37, s: 48, l: 49 },
- { h: 148, s: 1, l: 6351, d: 2 },
- { h: 88, s: 1, l: 160, d: 2 },
- { h: 15, s: 16, l: 704 },
- { h: 25, s: 26, l: 854 },
- { h: 25, s: 32, l: 55915 },
- { h: 37, s: 40, l: 1247 },
- { h: 25, s: -119711, l: 53248 },
- { h: 25, s: -119763, l: 52 },
- { h: 25, s: -119815, l: 52 },
- { h: 25, s: -119867, e: [1, 4, 5, 7, 8, 11, 12, 17], l: 52 },
- { h: 25, s: -119919, l: 52 },
- { h: 24, s: -119971, e: [2, 7, 8, 17], l: 52 },
- { h: 24, s: -120023, e: [2, 7, 13, 15, 16, 17], l: 52 },
- { h: 25, s: -120075, l: 52 },
- { h: 25, s: -120127, l: 52 },
- { h: 25, s: -120179, l: 52 },
- { h: 25, s: -120231, l: 52 },
- { h: 25, s: -120283, l: 52 },
- { h: 25, s: -120335, l: 52 },
- { h: 24, s: -119543, e: [17], l: 56 },
- { h: 24, s: -119601, e: [17], l: 58 },
- { h: 24, s: -119659, e: [17], l: 58 },
- { h: 24, s: -119717, e: [17], l: 58 },
- { h: 24, s: -119775, e: [17], l: 58 }
- ];
- var Table_B_2_lut_abs = createTable("b5:3bc,c3:ff,7:73,2:253,5:254,3:256,1:257,5:259,1:25b,3:260,1:263,2:269,1:268,5:26f,1:272,2:275,7:280,3:283,5:288,3:28a,1:28b,5:292,3f:195,1:1bf,29:19e,125:3b9,8b:3b2,1:3b8,1:3c5,3:3c6,1:3c0,1a:3ba,1:3c1,1:3c3,2:3b8,1:3b5,1bc9:3b9,1c:1f76,1:1f77,f:1f7a,1:1f7b,d:1f78,1:1f79,1:1f7c,1:1f7d,107:63,5:25b,4:68,1:68,1:68,3:69,1:69,1:6c,3:6e,4:70,1:71,1:72,1:72,1:72,7:7a,2:3c9,2:7a,2:6b,1:e5,1:62,1:63,3:65,1:66,2:6d,b:3b3,1:3c0,6:64,1b574:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3");
- var Table_B_2_lut_rel = createTable("179:1,2:1,2:1,5:1,2:1,a:4f,a:1,8:1,2:1,2:1,3:1,5:1,3:1,4:1,2:1,3:1,4:1,8:2,1:1,2:2,1:1,2:2,27:2,195:26,2:25,1:25,1:25,2:40,2:3f,1:3f,33:1,11:-6,1:-9,1ac7:-3a,6d:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,b:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,c:-8,2:-8,2:-8,2:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,49:-8,1:-8,1:-4a,1:-4a,d:-56,1:-56,1:-56,1:-56,d:-8,1:-8,f:-8,1:-8,3:-7");
- var Table_B_2_complex = createTable("df:00730073,51:00690307,19:02BC006E,a7:006A030C,18a:002003B9,16:03B903080301,20:03C503080301,1d7:05650582,190f:00680331,1:00740308,1:0077030A,1:0079030A,1:006102BE,b6:03C50313,2:03C503130300,2:03C503130301,2:03C503130342,2a:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,3:1F7003B9,1:03B103B9,1:03AC03B9,2:03B10342,1:03B1034203B9,5:03B103B9,6:1F7403B9,1:03B703B9,1:03AE03B9,2:03B70342,1:03B7034203B9,5:03B703B9,6:03B903080300,1:03B903080301,3:03B90342,1:03B903080342,b:03C503080300,1:03C503080301,1:03C10313,2:03C50342,1:03C503080342,b:1F7C03B9,1:03C903B9,1:03CE03B9,2:03C90342,1:03C9034203B9,5:03C903B9,ac:00720073,5b:00B00063,6:00B00066,d:006E006F,a:0073006D,1:00740065006C,1:0074006D,124f:006800700061,2:00610075,2:006F0076,b:00700061,1:006E0061,1:03BC0061,1:006D0061,1:006B0061,1:006B0062,1:006D0062,1:00670062,3:00700066,1:006E0066,1:03BC0066,4:0068007A,1:006B0068007A,1:006D0068007A,1:00670068007A,1:00740068007A,15:00700061,1:006B00700061,1:006D00700061,1:006700700061,8:00700076,1:006E0076,1:03BC0076,1:006D0076,1:006B0076,1:006D0076,1:00700077,1:006E0077,1:03BC0077,1:006D0077,1:006B0077,1:006D0077,1:006B03C9,1:006D03C9,2:00620071,3:00632215006B0067,1:0063006F002E,1:00640062,1:00670079,2:00680070,2:006B006B,1:006B006D,9:00700068,2:00700070006D,1:00700072,2:00730076,1:00770062,c723:00660066,1:00660069,1:0066006C,1:006600660069,1:00660066006C,1:00730074,1:00730074,d:05740576,1:05740565,1:0574056B,1:057E0576,1:0574056D", bytes2);
- var Table_C_ranges = createRangeTable("80-20,2a0-,39c,32,f71,18e,7f2-f,19-7,30-4,7-5,f81-b,5,a800-20ff,4d1-1f,110,fa-6,d174-7,2e84-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,2,1f-5f,ff7f-20001");
- function flatten(values) {
- return values.reduce(function (accum, value) {
- value.forEach(function (value) { accum.push(value); });
- return accum;
- }, []);
- }
- function _nameprepTableA1(codepoint) {
- return !!matchMap(codepoint, Table_A_1_ranges);
- }
- exports._nameprepTableA1 = _nameprepTableA1;
- function _nameprepTableB2(codepoint) {
- var range = matchMap(codepoint, Table_B_2_ranges);
- if (range) {
- return [codepoint + range.s];
- }
- var codes = Table_B_2_lut_abs[codepoint];
- if (codes) {
- return codes;
- }
- var shift = Table_B_2_lut_rel[codepoint];
- if (shift) {
- return [codepoint + shift[0]];
- }
- var complex = Table_B_2_complex[codepoint];
- if (complex) {
- return complex;
- }
- return null;
- }
- exports._nameprepTableB2 = _nameprepTableB2;
- function _nameprepTableC(codepoint) {
- return !!matchMap(codepoint, Table_C_ranges);
- }
- exports._nameprepTableC = _nameprepTableC;
- function nameprep(value) {
- // This allows platforms with incomplete normalize to bypass
- // it for very basic names which the built-in toLowerCase
- // will certainly handle correctly
- if (value.match(/^[a-z0-9-]*$/i) && value.length <= 59) {
- return value.toLowerCase();
- }
- // Get the code points (keeping the current normalization)
- var codes = (0, utf8_1.toUtf8CodePoints)(value);
- codes = flatten(codes.map(function (code) {
- // Substitute Table B.1 (Maps to Nothing)
- if (Table_B_1_flags.indexOf(code) >= 0) {
- return [];
- }
- if (code >= 0xfe00 && code <= 0xfe0f) {
- return [];
- }
- // Substitute Table B.2 (Case Folding)
- var codesTableB2 = _nameprepTableB2(code);
- if (codesTableB2) {
- return codesTableB2;
- }
- // No Substitution
- return [code];
- }));
- // Normalize using form KC
- codes = (0, utf8_1.toUtf8CodePoints)((0, utf8_1._toUtf8String)(codes), utf8_1.UnicodeNormalizationForm.NFKC);
- // Prohibit Tables C.1.2, C.2.2, C.3, C.4, C.5, C.6, C.7, C.8, C.9
- codes.forEach(function (code) {
- if (_nameprepTableC(code)) {
- throw new Error("STRINGPREP_CONTAINS_PROHIBITED");
- }
- });
- // Prohibit Unassigned Code Points (Table A.1)
- codes.forEach(function (code) {
- if (_nameprepTableA1(code)) {
- throw new Error("STRINGPREP_CONTAINS_UNASSIGNED");
- }
- });
- // IDNA extras
- var name = (0, utf8_1._toUtf8String)(codes);
- // IDNA: 4.2.3.1
- if (name.substring(0, 1) === "-" || name.substring(2, 4) === "--" || name.substring(name.length - 1) === "-") {
- throw new Error("invalid hyphen");
- }
- // IDNA: 4.2.4
- if (name.length > 63) {
- throw new Error("too long");
- }
- return name;
- }
- exports.nameprep = nameprep;
- },{"./utf8":267}],266:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.nameprep = exports.parseBytes32String = exports.formatBytes32String = exports.UnicodeNormalizationForm = exports.Utf8ErrorReason = exports.Utf8ErrorFuncs = exports.toUtf8String = exports.toUtf8CodePoints = exports.toUtf8Bytes = exports._toEscapedUtf8String = void 0;
- var bytes32_1 = _dereq_("./bytes32");
- Object.defineProperty(exports, "formatBytes32String", { enumerable: true, get: function () { return bytes32_1.formatBytes32String; } });
- Object.defineProperty(exports, "parseBytes32String", { enumerable: true, get: function () { return bytes32_1.parseBytes32String; } });
- var idna_1 = _dereq_("./idna");
- Object.defineProperty(exports, "nameprep", { enumerable: true, get: function () { return idna_1.nameprep; } });
- var utf8_1 = _dereq_("./utf8");
- Object.defineProperty(exports, "_toEscapedUtf8String", { enumerable: true, get: function () { return utf8_1._toEscapedUtf8String; } });
- Object.defineProperty(exports, "toUtf8Bytes", { enumerable: true, get: function () { return utf8_1.toUtf8Bytes; } });
- Object.defineProperty(exports, "toUtf8CodePoints", { enumerable: true, get: function () { return utf8_1.toUtf8CodePoints; } });
- Object.defineProperty(exports, "toUtf8String", { enumerable: true, get: function () { return utf8_1.toUtf8String; } });
- Object.defineProperty(exports, "UnicodeNormalizationForm", { enumerable: true, get: function () { return utf8_1.UnicodeNormalizationForm; } });
- Object.defineProperty(exports, "Utf8ErrorFuncs", { enumerable: true, get: function () { return utf8_1.Utf8ErrorFuncs; } });
- Object.defineProperty(exports, "Utf8ErrorReason", { enumerable: true, get: function () { return utf8_1.Utf8ErrorReason; } });
- },{"./bytes32":264,"./idna":265,"./utf8":267}],267:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.toUtf8CodePoints = exports.toUtf8String = exports._toUtf8String = exports._toEscapedUtf8String = exports.toUtf8Bytes = exports.Utf8ErrorFuncs = exports.Utf8ErrorReason = exports.UnicodeNormalizationForm = void 0;
- var bytes_1 = _dereq_("@ethersproject/bytes");
- var logger_1 = _dereq_("@ethersproject/logger");
- var _version_1 = _dereq_("./_version");
- var logger = new logger_1.Logger(_version_1.version);
- ///////////////////////////////
- var UnicodeNormalizationForm;
- (function (UnicodeNormalizationForm) {
- UnicodeNormalizationForm["current"] = "";
- UnicodeNormalizationForm["NFC"] = "NFC";
- UnicodeNormalizationForm["NFD"] = "NFD";
- UnicodeNormalizationForm["NFKC"] = "NFKC";
- UnicodeNormalizationForm["NFKD"] = "NFKD";
- })(UnicodeNormalizationForm = exports.UnicodeNormalizationForm || (exports.UnicodeNormalizationForm = {}));
- ;
- var Utf8ErrorReason;
- (function (Utf8ErrorReason) {
- // A continuation byte was present where there was nothing to continue
- // - offset = the index the codepoint began in
- Utf8ErrorReason["UNEXPECTED_CONTINUE"] = "unexpected continuation byte";
- // An invalid (non-continuation) byte to start a UTF-8 codepoint was found
- // - offset = the index the codepoint began in
- Utf8ErrorReason["BAD_PREFIX"] = "bad codepoint prefix";
- // The string is too short to process the expected codepoint
- // - offset = the index the codepoint began in
- Utf8ErrorReason["OVERRUN"] = "string overrun";
- // A missing continuation byte was expected but not found
- // - offset = the index the continuation byte was expected at
- Utf8ErrorReason["MISSING_CONTINUE"] = "missing continuation byte";
- // The computed code point is outside the range for UTF-8
- // - offset = start of this codepoint
- // - badCodepoint = the computed codepoint; outside the UTF-8 range
- Utf8ErrorReason["OUT_OF_RANGE"] = "out of UTF-8 range";
- // UTF-8 strings may not contain UTF-16 surrogate pairs
- // - offset = start of this codepoint
- // - badCodepoint = the computed codepoint; inside the UTF-16 surrogate range
- Utf8ErrorReason["UTF16_SURROGATE"] = "UTF-16 surrogate";
- // The string is an overlong representation
- // - offset = start of this codepoint
- // - badCodepoint = the computed codepoint; already bounds checked
- Utf8ErrorReason["OVERLONG"] = "overlong representation";
- })(Utf8ErrorReason = exports.Utf8ErrorReason || (exports.Utf8ErrorReason = {}));
- ;
- function errorFunc(reason, offset, bytes, output, badCodepoint) {
- return logger.throwArgumentError("invalid codepoint at offset " + offset + "; " + reason, "bytes", bytes);
- }
- function ignoreFunc(reason, offset, bytes, output, badCodepoint) {
- // If there is an invalid prefix (including stray continuation), skip any additional continuation bytes
- if (reason === Utf8ErrorReason.BAD_PREFIX || reason === Utf8ErrorReason.UNEXPECTED_CONTINUE) {
- var i = 0;
- for (var o = offset + 1; o < bytes.length; o++) {
- if (bytes[o] >> 6 !== 0x02) {
- break;
- }
- i++;
- }
- return i;
- }
- // This byte runs us past the end of the string, so just jump to the end
- // (but the first byte was read already read and therefore skipped)
- if (reason === Utf8ErrorReason.OVERRUN) {
- return bytes.length - offset - 1;
- }
- // Nothing to skip
- return 0;
- }
- function replaceFunc(reason, offset, bytes, output, badCodepoint) {
- // Overlong representations are otherwise "valid" code points; just non-deistingtished
- if (reason === Utf8ErrorReason.OVERLONG) {
- output.push(badCodepoint);
- return 0;
- }
- // Put the replacement character into the output
- output.push(0xfffd);
- // Otherwise, process as if ignoring errors
- return ignoreFunc(reason, offset, bytes, output, badCodepoint);
- }
- // Common error handing strategies
- exports.Utf8ErrorFuncs = Object.freeze({
- error: errorFunc,
- ignore: ignoreFunc,
- replace: replaceFunc
- });
- // http://stackoverflow.com/questions/13356493/decode-utf-8-with-javascript#13691499
- function getUtf8CodePoints(bytes, onError) {
- if (onError == null) {
- onError = exports.Utf8ErrorFuncs.error;
- }
- bytes = (0, bytes_1.arrayify)(bytes);
- var result = [];
- var i = 0;
- // Invalid bytes are ignored
- while (i < bytes.length) {
- var c = bytes[i++];
- // 0xxx xxxx
- if (c >> 7 === 0) {
- result.push(c);
- continue;
- }
- // Multibyte; how many bytes left for this character?
- var extraLength = null;
- var overlongMask = null;
- // 110x xxxx 10xx xxxx
- if ((c & 0xe0) === 0xc0) {
- extraLength = 1;
- overlongMask = 0x7f;
- // 1110 xxxx 10xx xxxx 10xx xxxx
- }
- else if ((c & 0xf0) === 0xe0) {
- extraLength = 2;
- overlongMask = 0x7ff;
- // 1111 0xxx 10xx xxxx 10xx xxxx 10xx xxxx
- }
- else if ((c & 0xf8) === 0xf0) {
- extraLength = 3;
- overlongMask = 0xffff;
- }
- else {
- if ((c & 0xc0) === 0x80) {
- i += onError(Utf8ErrorReason.UNEXPECTED_CONTINUE, i - 1, bytes, result);
- }
- else {
- i += onError(Utf8ErrorReason.BAD_PREFIX, i - 1, bytes, result);
- }
- continue;
- }
- // Do we have enough bytes in our data?
- if (i - 1 + extraLength >= bytes.length) {
- i += onError(Utf8ErrorReason.OVERRUN, i - 1, bytes, result);
- continue;
- }
- // Remove the length prefix from the char
- var res = c & ((1 << (8 - extraLength - 1)) - 1);
- for (var j = 0; j < extraLength; j++) {
- var nextChar = bytes[i];
- // Invalid continuation byte
- if ((nextChar & 0xc0) != 0x80) {
- i += onError(Utf8ErrorReason.MISSING_CONTINUE, i, bytes, result);
- res = null;
- break;
- }
- ;
- res = (res << 6) | (nextChar & 0x3f);
- i++;
- }
- // See above loop for invalid continuation byte
- if (res === null) {
- continue;
- }
- // Maximum code point
- if (res > 0x10ffff) {
- i += onError(Utf8ErrorReason.OUT_OF_RANGE, i - 1 - extraLength, bytes, result, res);
- continue;
- }
- // Reserved for UTF-16 surrogate halves
- if (res >= 0xd800 && res <= 0xdfff) {
- i += onError(Utf8ErrorReason.UTF16_SURROGATE, i - 1 - extraLength, bytes, result, res);
- continue;
- }
- // Check for overlong sequences (more bytes than needed)
- if (res <= overlongMask) {
- i += onError(Utf8ErrorReason.OVERLONG, i - 1 - extraLength, bytes, result, res);
- continue;
- }
- result.push(res);
- }
- return result;
- }
- // http://stackoverflow.com/questions/18729405/how-to-convert-utf8-string-to-byte-array
- function toUtf8Bytes(str, form) {
- if (form === void 0) { form = UnicodeNormalizationForm.current; }
- if (form != UnicodeNormalizationForm.current) {
- logger.checkNormalize();
- str = str.normalize(form);
- }
- var result = [];
- for (var i = 0; i < str.length; i++) {
- var c = str.charCodeAt(i);
- if (c < 0x80) {
- result.push(c);
- }
- else if (c < 0x800) {
- result.push((c >> 6) | 0xc0);
- result.push((c & 0x3f) | 0x80);
- }
- else if ((c & 0xfc00) == 0xd800) {
- i++;
- var c2 = str.charCodeAt(i);
- if (i >= str.length || (c2 & 0xfc00) !== 0xdc00) {
- throw new Error("invalid utf-8 string");
- }
- // Surrogate Pair
- var pair = 0x10000 + ((c & 0x03ff) << 10) + (c2 & 0x03ff);
- result.push((pair >> 18) | 0xf0);
- result.push(((pair >> 12) & 0x3f) | 0x80);
- result.push(((pair >> 6) & 0x3f) | 0x80);
- result.push((pair & 0x3f) | 0x80);
- }
- else {
- result.push((c >> 12) | 0xe0);
- result.push(((c >> 6) & 0x3f) | 0x80);
- result.push((c & 0x3f) | 0x80);
- }
- }
- return (0, bytes_1.arrayify)(result);
- }
- exports.toUtf8Bytes = toUtf8Bytes;
- ;
- function escapeChar(value) {
- var hex = ("0000" + value.toString(16));
- return "\\u" + hex.substring(hex.length - 4);
- }
- function _toEscapedUtf8String(bytes, onError) {
- return '"' + getUtf8CodePoints(bytes, onError).map(function (codePoint) {
- if (codePoint < 256) {
- switch (codePoint) {
- case 8: return "\\b";
- case 9: return "\\t";
- case 10: return "\\n";
- case 13: return "\\r";
- case 34: return "\\\"";
- case 92: return "\\\\";
- }
- if (codePoint >= 32 && codePoint < 127) {
- return String.fromCharCode(codePoint);
- }
- }
- if (codePoint <= 0xffff) {
- return escapeChar(codePoint);
- }
- codePoint -= 0x10000;
- return escapeChar(((codePoint >> 10) & 0x3ff) + 0xd800) + escapeChar((codePoint & 0x3ff) + 0xdc00);
- }).join("") + '"';
- }
- exports._toEscapedUtf8String = _toEscapedUtf8String;
- function _toUtf8String(codePoints) {
- return codePoints.map(function (codePoint) {
- if (codePoint <= 0xffff) {
- return String.fromCharCode(codePoint);
- }
- codePoint -= 0x10000;
- return String.fromCharCode((((codePoint >> 10) & 0x3ff) + 0xd800), ((codePoint & 0x3ff) + 0xdc00));
- }).join("");
- }
- exports._toUtf8String = _toUtf8String;
- function toUtf8String(bytes, onError) {
- return _toUtf8String(getUtf8CodePoints(bytes, onError));
- }
- exports.toUtf8String = toUtf8String;
- function toUtf8CodePoints(str, form) {
- if (form === void 0) { form = UnicodeNormalizationForm.current; }
- return getUtf8CodePoints(toUtf8Bytes(str, form));
- }
- exports.toUtf8CodePoints = toUtf8CodePoints;
- },{"./_version":263,"@ethersproject/bytes":199,"@ethersproject/logger":223}],268:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.version = void 0;
- exports.version = "transactions/5.6.0";
- },{}],269:[function(_dereq_,module,exports){
- "use strict";
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
- }) : (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- o[k2] = m[k];
- }));
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
- Object.defineProperty(o, "default", { enumerable: true, value: v });
- }) : function(o, v) {
- o["default"] = v;
- });
- var __importStar = (this && this.__importStar) || function (mod) {
- if (mod && mod.__esModule) return mod;
- var result = {};
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
- __setModuleDefault(result, mod);
- return result;
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.parse = exports.serialize = exports.accessListify = exports.recoverAddress = exports.computeAddress = exports.TransactionTypes = void 0;
- var address_1 = _dereq_("@ethersproject/address");
- var bignumber_1 = _dereq_("@ethersproject/bignumber");
- var bytes_1 = _dereq_("@ethersproject/bytes");
- var constants_1 = _dereq_("@ethersproject/constants");
- var keccak256_1 = _dereq_("@ethersproject/keccak256");
- var properties_1 = _dereq_("@ethersproject/properties");
- var RLP = __importStar(_dereq_("@ethersproject/rlp"));
- var signing_key_1 = _dereq_("@ethersproject/signing-key");
- var logger_1 = _dereq_("@ethersproject/logger");
- var _version_1 = _dereq_("./_version");
- var logger = new logger_1.Logger(_version_1.version);
- var TransactionTypes;
- (function (TransactionTypes) {
- TransactionTypes[TransactionTypes["legacy"] = 0] = "legacy";
- TransactionTypes[TransactionTypes["eip2930"] = 1] = "eip2930";
- TransactionTypes[TransactionTypes["eip1559"] = 2] = "eip1559";
- })(TransactionTypes = exports.TransactionTypes || (exports.TransactionTypes = {}));
- ;
- ///////////////////////////////
- function handleAddress(value) {
- if (value === "0x") {
- return null;
- }
- return (0, address_1.getAddress)(value);
- }
- function handleNumber(value) {
- if (value === "0x") {
- return constants_1.Zero;
- }
- return bignumber_1.BigNumber.from(value);
- }
- // Legacy Transaction Fields
- var transactionFields = [
- { name: "nonce", maxLength: 32, numeric: true },
- { name: "gasPrice", maxLength: 32, numeric: true },
- { name: "gasLimit", maxLength: 32, numeric: true },
- { name: "to", length: 20 },
- { name: "value", maxLength: 32, numeric: true },
- { name: "data" },
- ];
- var allowedTransactionKeys = {
- chainId: true, data: true, gasLimit: true, gasPrice: true, nonce: true, to: true, type: true, value: true
- };
- function computeAddress(key) {
- var publicKey = (0, signing_key_1.computePublicKey)(key);
- return (0, address_1.getAddress)((0, bytes_1.hexDataSlice)((0, keccak256_1.keccak256)((0, bytes_1.hexDataSlice)(publicKey, 1)), 12));
- }
- exports.computeAddress = computeAddress;
- function recoverAddress(digest, signature) {
- return computeAddress((0, signing_key_1.recoverPublicKey)((0, bytes_1.arrayify)(digest), signature));
- }
- exports.recoverAddress = recoverAddress;
- function formatNumber(value, name) {
- var result = (0, bytes_1.stripZeros)(bignumber_1.BigNumber.from(value).toHexString());
- if (result.length > 32) {
- logger.throwArgumentError("invalid length for " + name, ("transaction:" + name), value);
- }
- return result;
- }
- function accessSetify(addr, storageKeys) {
- return {
- address: (0, address_1.getAddress)(addr),
- storageKeys: (storageKeys || []).map(function (storageKey, index) {
- if ((0, bytes_1.hexDataLength)(storageKey) !== 32) {
- logger.throwArgumentError("invalid access list storageKey", "accessList[" + addr + ":" + index + "]", storageKey);
- }
- return storageKey.toLowerCase();
- })
- };
- }
- function accessListify(value) {
- if (Array.isArray(value)) {
- return value.map(function (set, index) {
- if (Array.isArray(set)) {
- if (set.length > 2) {
- logger.throwArgumentError("access list expected to be [ address, storageKeys[] ]", "value[" + index + "]", set);
- }
- return accessSetify(set[0], set[1]);
- }
- return accessSetify(set.address, set.storageKeys);
- });
- }
- var result = Object.keys(value).map(function (addr) {
- var storageKeys = value[addr].reduce(function (accum, storageKey) {
- accum[storageKey] = true;
- return accum;
- }, {});
- return accessSetify(addr, Object.keys(storageKeys).sort());
- });
- result.sort(function (a, b) { return (a.address.localeCompare(b.address)); });
- return result;
- }
- exports.accessListify = accessListify;
- function formatAccessList(value) {
- return accessListify(value).map(function (set) { return [set.address, set.storageKeys]; });
- }
- function _serializeEip1559(transaction, signature) {
- // If there is an explicit gasPrice, make sure it matches the
- // EIP-1559 fees; otherwise they may not understand what they
- // think they are setting in terms of fee.
- if (transaction.gasPrice != null) {
- var gasPrice = bignumber_1.BigNumber.from(transaction.gasPrice);
- var maxFeePerGas = bignumber_1.BigNumber.from(transaction.maxFeePerGas || 0);
- if (!gasPrice.eq(maxFeePerGas)) {
- logger.throwArgumentError("mismatch EIP-1559 gasPrice != maxFeePerGas", "tx", {
- gasPrice: gasPrice,
- maxFeePerGas: maxFeePerGas
- });
- }
- }
- var fields = [
- formatNumber(transaction.chainId || 0, "chainId"),
- formatNumber(transaction.nonce || 0, "nonce"),
- formatNumber(transaction.maxPriorityFeePerGas || 0, "maxPriorityFeePerGas"),
- formatNumber(transaction.maxFeePerGas || 0, "maxFeePerGas"),
- formatNumber(transaction.gasLimit || 0, "gasLimit"),
- ((transaction.to != null) ? (0, address_1.getAddress)(transaction.to) : "0x"),
- formatNumber(transaction.value || 0, "value"),
- (transaction.data || "0x"),
- (formatAccessList(transaction.accessList || []))
- ];
- if (signature) {
- var sig = (0, bytes_1.splitSignature)(signature);
- fields.push(formatNumber(sig.recoveryParam, "recoveryParam"));
- fields.push((0, bytes_1.stripZeros)(sig.r));
- fields.push((0, bytes_1.stripZeros)(sig.s));
- }
- return (0, bytes_1.hexConcat)(["0x02", RLP.encode(fields)]);
- }
- function _serializeEip2930(transaction, signature) {
- var fields = [
- formatNumber(transaction.chainId || 0, "chainId"),
- formatNumber(transaction.nonce || 0, "nonce"),
- formatNumber(transaction.gasPrice || 0, "gasPrice"),
- formatNumber(transaction.gasLimit || 0, "gasLimit"),
- ((transaction.to != null) ? (0, address_1.getAddress)(transaction.to) : "0x"),
- formatNumber(transaction.value || 0, "value"),
- (transaction.data || "0x"),
- (formatAccessList(transaction.accessList || []))
- ];
- if (signature) {
- var sig = (0, bytes_1.splitSignature)(signature);
- fields.push(formatNumber(sig.recoveryParam, "recoveryParam"));
- fields.push((0, bytes_1.stripZeros)(sig.r));
- fields.push((0, bytes_1.stripZeros)(sig.s));
- }
- return (0, bytes_1.hexConcat)(["0x01", RLP.encode(fields)]);
- }
- // Legacy Transactions and EIP-155
- function _serialize(transaction, signature) {
- (0, properties_1.checkProperties)(transaction, allowedTransactionKeys);
- var raw = [];
- transactionFields.forEach(function (fieldInfo) {
- var value = transaction[fieldInfo.name] || ([]);
- var options = {};
- if (fieldInfo.numeric) {
- options.hexPad = "left";
- }
- value = (0, bytes_1.arrayify)((0, bytes_1.hexlify)(value, options));
- // Fixed-width field
- if (fieldInfo.length && value.length !== fieldInfo.length && value.length > 0) {
- logger.throwArgumentError("invalid length for " + fieldInfo.name, ("transaction:" + fieldInfo.name), value);
- }
- // Variable-width (with a maximum)
- if (fieldInfo.maxLength) {
- value = (0, bytes_1.stripZeros)(value);
- if (value.length > fieldInfo.maxLength) {
- logger.throwArgumentError("invalid length for " + fieldInfo.name, ("transaction:" + fieldInfo.name), value);
- }
- }
- raw.push((0, bytes_1.hexlify)(value));
- });
- var chainId = 0;
- if (transaction.chainId != null) {
- // A chainId was provided; if non-zero we'll use EIP-155
- chainId = transaction.chainId;
- if (typeof (chainId) !== "number") {
- logger.throwArgumentError("invalid transaction.chainId", "transaction", transaction);
- }
- }
- else if (signature && !(0, bytes_1.isBytesLike)(signature) && signature.v > 28) {
- // No chainId provided, but the signature is signing with EIP-155; derive chainId
- chainId = Math.floor((signature.v - 35) / 2);
- }
- // We have an EIP-155 transaction (chainId was specified and non-zero)
- if (chainId !== 0) {
- raw.push((0, bytes_1.hexlify)(chainId)); // @TODO: hexValue?
- raw.push("0x");
- raw.push("0x");
- }
- // Requesting an unsigned transaction
- if (!signature) {
- return RLP.encode(raw);
- }
- // The splitSignature will ensure the transaction has a recoveryParam in the
- // case that the signTransaction function only adds a v.
- var sig = (0, bytes_1.splitSignature)(signature);
- // We pushed a chainId and null r, s on for hashing only; remove those
- var v = 27 + sig.recoveryParam;
- if (chainId !== 0) {
- raw.pop();
- raw.pop();
- raw.pop();
- v += chainId * 2 + 8;
- // If an EIP-155 v (directly or indirectly; maybe _vs) was provided, check it!
- if (sig.v > 28 && sig.v !== v) {
- logger.throwArgumentError("transaction.chainId/signature.v mismatch", "signature", signature);
- }
- }
- else if (sig.v !== v) {
- logger.throwArgumentError("transaction.chainId/signature.v mismatch", "signature", signature);
- }
- raw.push((0, bytes_1.hexlify)(v));
- raw.push((0, bytes_1.stripZeros)((0, bytes_1.arrayify)(sig.r)));
- raw.push((0, bytes_1.stripZeros)((0, bytes_1.arrayify)(sig.s)));
- return RLP.encode(raw);
- }
- function serialize(transaction, signature) {
- // Legacy and EIP-155 Transactions
- if (transaction.type == null || transaction.type === 0) {
- if (transaction.accessList != null) {
- logger.throwArgumentError("untyped transactions do not support accessList; include type: 1", "transaction", transaction);
- }
- return _serialize(transaction, signature);
- }
- // Typed Transactions (EIP-2718)
- switch (transaction.type) {
- case 1:
- return _serializeEip2930(transaction, signature);
- case 2:
- return _serializeEip1559(transaction, signature);
- default:
- break;
- }
- return logger.throwError("unsupported transaction type: " + transaction.type, logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
- operation: "serializeTransaction",
- transactionType: transaction.type
- });
- }
- exports.serialize = serialize;
- function _parseEipSignature(tx, fields, serialize) {
- try {
- var recid = handleNumber(fields[0]).toNumber();
- if (recid !== 0 && recid !== 1) {
- throw new Error("bad recid");
- }
- tx.v = recid;
- }
- catch (error) {
- logger.throwArgumentError("invalid v for transaction type: 1", "v", fields[0]);
- }
- tx.r = (0, bytes_1.hexZeroPad)(fields[1], 32);
- tx.s = (0, bytes_1.hexZeroPad)(fields[2], 32);
- try {
- var digest = (0, keccak256_1.keccak256)(serialize(tx));
- tx.from = recoverAddress(digest, { r: tx.r, s: tx.s, recoveryParam: tx.v });
- }
- catch (error) {
- console.log(error);
- }
- }
- function _parseEip1559(payload) {
- var transaction = RLP.decode(payload.slice(1));
- if (transaction.length !== 9 && transaction.length !== 12) {
- logger.throwArgumentError("invalid component count for transaction type: 2", "payload", (0, bytes_1.hexlify)(payload));
- }
- var maxPriorityFeePerGas = handleNumber(transaction[2]);
- var maxFeePerGas = handleNumber(transaction[3]);
- var tx = {
- type: 2,
- chainId: handleNumber(transaction[0]).toNumber(),
- nonce: handleNumber(transaction[1]).toNumber(),
- maxPriorityFeePerGas: maxPriorityFeePerGas,
- maxFeePerGas: maxFeePerGas,
- gasPrice: null,
- gasLimit: handleNumber(transaction[4]),
- to: handleAddress(transaction[5]),
- value: handleNumber(transaction[6]),
- data: transaction[7],
- accessList: accessListify(transaction[8]),
- };
- // Unsigned EIP-1559 Transaction
- if (transaction.length === 9) {
- return tx;
- }
- tx.hash = (0, keccak256_1.keccak256)(payload);
- _parseEipSignature(tx, transaction.slice(9), _serializeEip1559);
- return tx;
- }
- function _parseEip2930(payload) {
- var transaction = RLP.decode(payload.slice(1));
- if (transaction.length !== 8 && transaction.length !== 11) {
- logger.throwArgumentError("invalid component count for transaction type: 1", "payload", (0, bytes_1.hexlify)(payload));
- }
- var tx = {
- type: 1,
- chainId: handleNumber(transaction[0]).toNumber(),
- nonce: handleNumber(transaction[1]).toNumber(),
- gasPrice: handleNumber(transaction[2]),
- gasLimit: handleNumber(transaction[3]),
- to: handleAddress(transaction[4]),
- value: handleNumber(transaction[5]),
- data: transaction[6],
- accessList: accessListify(transaction[7])
- };
- // Unsigned EIP-2930 Transaction
- if (transaction.length === 8) {
- return tx;
- }
- tx.hash = (0, keccak256_1.keccak256)(payload);
- _parseEipSignature(tx, transaction.slice(8), _serializeEip2930);
- return tx;
- }
- // Legacy Transactions and EIP-155
- function _parse(rawTransaction) {
- var transaction = RLP.decode(rawTransaction);
- if (transaction.length !== 9 && transaction.length !== 6) {
- logger.throwArgumentError("invalid raw transaction", "rawTransaction", rawTransaction);
- }
- var tx = {
- nonce: handleNumber(transaction[0]).toNumber(),
- gasPrice: handleNumber(transaction[1]),
- gasLimit: handleNumber(transaction[2]),
- to: handleAddress(transaction[3]),
- value: handleNumber(transaction[4]),
- data: transaction[5],
- chainId: 0
- };
- // Legacy unsigned transaction
- if (transaction.length === 6) {
- return tx;
- }
- try {
- tx.v = bignumber_1.BigNumber.from(transaction[6]).toNumber();
- }
- catch (error) {
- console.log(error);
- return tx;
- }
- tx.r = (0, bytes_1.hexZeroPad)(transaction[7], 32);
- tx.s = (0, bytes_1.hexZeroPad)(transaction[8], 32);
- if (bignumber_1.BigNumber.from(tx.r).isZero() && bignumber_1.BigNumber.from(tx.s).isZero()) {
- // EIP-155 unsigned transaction
- tx.chainId = tx.v;
- tx.v = 0;
- }
- else {
- // Signed Transaction
- tx.chainId = Math.floor((tx.v - 35) / 2);
- if (tx.chainId < 0) {
- tx.chainId = 0;
- }
- var recoveryParam = tx.v - 27;
- var raw = transaction.slice(0, 6);
- if (tx.chainId !== 0) {
- raw.push((0, bytes_1.hexlify)(tx.chainId));
- raw.push("0x");
- raw.push("0x");
- recoveryParam -= tx.chainId * 2 + 8;
- }
- var digest = (0, keccak256_1.keccak256)(RLP.encode(raw));
- try {
- tx.from = recoverAddress(digest, { r: (0, bytes_1.hexlify)(tx.r), s: (0, bytes_1.hexlify)(tx.s), recoveryParam: recoveryParam });
- }
- catch (error) {
- console.log(error);
- }
- tx.hash = (0, keccak256_1.keccak256)(rawTransaction);
- }
- tx.type = null;
- return tx;
- }
- function parse(rawTransaction) {
- var payload = (0, bytes_1.arrayify)(rawTransaction);
- // Legacy and EIP-155 Transactions
- if (payload[0] > 0x7f) {
- return _parse(payload);
- }
- // Typed Transaction (EIP-2718)
- switch (payload[0]) {
- case 1:
- return _parseEip2930(payload);
- case 2:
- return _parseEip1559(payload);
- default:
- break;
- }
- return logger.throwError("unsupported transaction type: " + payload[0], logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
- operation: "parseTransaction",
- transactionType: payload[0]
- });
- }
- exports.parse = parse;
- },{"./_version":268,"@ethersproject/address":189,"@ethersproject/bignumber":196,"@ethersproject/bytes":199,"@ethersproject/constants":203,"@ethersproject/keccak256":221,"@ethersproject/logger":223,"@ethersproject/properties":229,"@ethersproject/rlp":253,"@ethersproject/signing-key":260}],270:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.version = void 0;
- exports.version = "units/5.6.0";
- },{}],271:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.parseEther = exports.formatEther = exports.parseUnits = exports.formatUnits = exports.commify = void 0;
- var bignumber_1 = _dereq_("@ethersproject/bignumber");
- var logger_1 = _dereq_("@ethersproject/logger");
- var _version_1 = _dereq_("./_version");
- var logger = new logger_1.Logger(_version_1.version);
- var names = [
- "wei",
- "kwei",
- "mwei",
- "gwei",
- "szabo",
- "finney",
- "ether",
- ];
- // Some environments have issues with RegEx that contain back-tracking, so we cannot
- // use them.
- function commify(value) {
- var comps = String(value).split(".");
- if (comps.length > 2 || !comps[0].match(/^-?[0-9]*$/) || (comps[1] && !comps[1].match(/^[0-9]*$/)) || value === "." || value === "-.") {
- logger.throwArgumentError("invalid value", "value", value);
- }
- // Make sure we have at least one whole digit (0 if none)
- var whole = comps[0];
- var negative = "";
- if (whole.substring(0, 1) === "-") {
- negative = "-";
- whole = whole.substring(1);
- }
- // Make sure we have at least 1 whole digit with no leading zeros
- while (whole.substring(0, 1) === "0") {
- whole = whole.substring(1);
- }
- if (whole === "") {
- whole = "0";
- }
- var suffix = "";
- if (comps.length === 2) {
- suffix = "." + (comps[1] || "0");
- }
- while (suffix.length > 2 && suffix[suffix.length - 1] === "0") {
- suffix = suffix.substring(0, suffix.length - 1);
- }
- var formatted = [];
- while (whole.length) {
- if (whole.length <= 3) {
- formatted.unshift(whole);
- break;
- }
- else {
- var index = whole.length - 3;
- formatted.unshift(whole.substring(index));
- whole = whole.substring(0, index);
- }
- }
- return negative + formatted.join(",") + suffix;
- }
- exports.commify = commify;
- function formatUnits(value, unitName) {
- if (typeof (unitName) === "string") {
- var index = names.indexOf(unitName);
- if (index !== -1) {
- unitName = 3 * index;
- }
- }
- return (0, bignumber_1.formatFixed)(value, (unitName != null) ? unitName : 18);
- }
- exports.formatUnits = formatUnits;
- function parseUnits(value, unitName) {
- if (typeof (value) !== "string") {
- logger.throwArgumentError("value must be a string", "value", value);
- }
- if (typeof (unitName) === "string") {
- var index = names.indexOf(unitName);
- if (index !== -1) {
- unitName = 3 * index;
- }
- }
- return (0, bignumber_1.parseFixed)(value, (unitName != null) ? unitName : 18);
- }
- exports.parseUnits = parseUnits;
- function formatEther(wei) {
- return formatUnits(wei, 18);
- }
- exports.formatEther = formatEther;
- function parseEther(ether) {
- return parseUnits(ether, 18);
- }
- exports.parseEther = parseEther;
- },{"./_version":270,"@ethersproject/bignumber":196,"@ethersproject/logger":223}],272:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.version = void 0;
- exports.version = "wallet/5.6.0";
- },{}],273:[function(_dereq_,module,exports){
- "use strict";
- var __extends = (this && this.__extends) || (function () {
- var extendStatics = function (d, b) {
- extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
- return extendStatics(d, b);
- };
- return function (d, b) {
- if (typeof b !== "function" && b !== null)
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
- return new (P || (P = Promise))(function (resolve, reject) {
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
- step((generator = generator.apply(thisArg, _arguments || [])).next());
- });
- };
- var __generator = (this && this.__generator) || function (thisArg, body) {
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
- function verb(n) { return function (v) { return step([n, v]); }; }
- function step(op) {
- if (f) throw new TypeError("Generator is already executing.");
- while (_) try {
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
- if (y = 0, t) op = [op[0] & 2, t.value];
- switch (op[0]) {
- case 0: case 1: t = op; break;
- case 4: _.label++; return { value: op[1], done: false };
- case 5: _.label++; y = op[1]; op = [0]; continue;
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
- default:
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
- if (t[2]) _.ops.pop();
- _.trys.pop(); continue;
- }
- op = body.call(thisArg, _);
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
- }
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.verifyTypedData = exports.verifyMessage = exports.Wallet = void 0;
- var address_1 = _dereq_("@ethersproject/address");
- var abstract_provider_1 = _dereq_("@ethersproject/abstract-provider");
- var abstract_signer_1 = _dereq_("@ethersproject/abstract-signer");
- var bytes_1 = _dereq_("@ethersproject/bytes");
- var hash_1 = _dereq_("@ethersproject/hash");
- var hdnode_1 = _dereq_("@ethersproject/hdnode");
- var keccak256_1 = _dereq_("@ethersproject/keccak256");
- var properties_1 = _dereq_("@ethersproject/properties");
- var random_1 = _dereq_("@ethersproject/random");
- var signing_key_1 = _dereq_("@ethersproject/signing-key");
- var json_wallets_1 = _dereq_("@ethersproject/json-wallets");
- var transactions_1 = _dereq_("@ethersproject/transactions");
- var logger_1 = _dereq_("@ethersproject/logger");
- var _version_1 = _dereq_("./_version");
- var logger = new logger_1.Logger(_version_1.version);
- function isAccount(value) {
- return (value != null && (0, bytes_1.isHexString)(value.privateKey, 32) && value.address != null);
- }
- function hasMnemonic(value) {
- var mnemonic = value.mnemonic;
- return (mnemonic && mnemonic.phrase);
- }
- var Wallet = /** @class */ (function (_super) {
- __extends(Wallet, _super);
- function Wallet(privateKey, provider) {
- var _newTarget = this.constructor;
- var _this = this;
- logger.checkNew(_newTarget, Wallet);
- _this = _super.call(this) || this;
- if (isAccount(privateKey)) {
- var signingKey_1 = new signing_key_1.SigningKey(privateKey.privateKey);
- (0, properties_1.defineReadOnly)(_this, "_signingKey", function () { return signingKey_1; });
- (0, properties_1.defineReadOnly)(_this, "address", (0, transactions_1.computeAddress)(_this.publicKey));
- if (_this.address !== (0, address_1.getAddress)(privateKey.address)) {
- logger.throwArgumentError("privateKey/address mismatch", "privateKey", "[REDACTED]");
- }
- if (hasMnemonic(privateKey)) {
- var srcMnemonic_1 = privateKey.mnemonic;
- (0, properties_1.defineReadOnly)(_this, "_mnemonic", function () { return ({
- phrase: srcMnemonic_1.phrase,
- path: srcMnemonic_1.path || hdnode_1.defaultPath,
- locale: srcMnemonic_1.locale || "en"
- }); });
- var mnemonic = _this.mnemonic;
- var node = hdnode_1.HDNode.fromMnemonic(mnemonic.phrase, null, mnemonic.locale).derivePath(mnemonic.path);
- if ((0, transactions_1.computeAddress)(node.privateKey) !== _this.address) {
- logger.throwArgumentError("mnemonic/address mismatch", "privateKey", "[REDACTED]");
- }
- }
- else {
- (0, properties_1.defineReadOnly)(_this, "_mnemonic", function () { return null; });
- }
- }
- else {
- if (signing_key_1.SigningKey.isSigningKey(privateKey)) {
- /* istanbul ignore if */
- if (privateKey.curve !== "secp256k1") {
- logger.throwArgumentError("unsupported curve; must be secp256k1", "privateKey", "[REDACTED]");
- }
- (0, properties_1.defineReadOnly)(_this, "_signingKey", function () { return privateKey; });
- }
- else {
- // A lot of common tools do not prefix private keys with a 0x (see: #1166)
- if (typeof (privateKey) === "string") {
- if (privateKey.match(/^[0-9a-f]*$/i) && privateKey.length === 64) {
- privateKey = "0x" + privateKey;
- }
- }
- var signingKey_2 = new signing_key_1.SigningKey(privateKey);
- (0, properties_1.defineReadOnly)(_this, "_signingKey", function () { return signingKey_2; });
- }
- (0, properties_1.defineReadOnly)(_this, "_mnemonic", function () { return null; });
- (0, properties_1.defineReadOnly)(_this, "address", (0, transactions_1.computeAddress)(_this.publicKey));
- }
- /* istanbul ignore if */
- if (provider && !abstract_provider_1.Provider.isProvider(provider)) {
- logger.throwArgumentError("invalid provider", "provider", provider);
- }
- (0, properties_1.defineReadOnly)(_this, "provider", provider || null);
- return _this;
- }
- Object.defineProperty(Wallet.prototype, "mnemonic", {
- get: function () { return this._mnemonic(); },
- enumerable: false,
- configurable: true
- });
- Object.defineProperty(Wallet.prototype, "privateKey", {
- get: function () { return this._signingKey().privateKey; },
- enumerable: false,
- configurable: true
- });
- Object.defineProperty(Wallet.prototype, "publicKey", {
- get: function () { return this._signingKey().publicKey; },
- enumerable: false,
- configurable: true
- });
- Wallet.prototype.getAddress = function () {
- return Promise.resolve(this.address);
- };
- Wallet.prototype.connect = function (provider) {
- return new Wallet(this, provider);
- };
- Wallet.prototype.signTransaction = function (transaction) {
- var _this = this;
- return (0, properties_1.resolveProperties)(transaction).then(function (tx) {
- if (tx.from != null) {
- if ((0, address_1.getAddress)(tx.from) !== _this.address) {
- logger.throwArgumentError("transaction from address mismatch", "transaction.from", transaction.from);
- }
- delete tx.from;
- }
- var signature = _this._signingKey().signDigest((0, keccak256_1.keccak256)((0, transactions_1.serialize)(tx)));
- return (0, transactions_1.serialize)(tx, signature);
- });
- };
- Wallet.prototype.signMessage = function (message) {
- return __awaiter(this, void 0, void 0, function () {
- return __generator(this, function (_a) {
- return [2 /*return*/, (0, bytes_1.joinSignature)(this._signingKey().signDigest((0, hash_1.hashMessage)(message)))];
- });
- });
- };
- Wallet.prototype._signTypedData = function (domain, types, value) {
- return __awaiter(this, void 0, void 0, function () {
- var populated;
- var _this = this;
- return __generator(this, function (_a) {
- switch (_a.label) {
- case 0: return [4 /*yield*/, hash_1._TypedDataEncoder.resolveNames(domain, types, value, function (name) {
- if (_this.provider == null) {
- logger.throwError("cannot resolve ENS names without a provider", logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
- operation: "resolveName",
- value: name
- });
- }
- return _this.provider.resolveName(name);
- })];
- case 1:
- populated = _a.sent();
- return [2 /*return*/, (0, bytes_1.joinSignature)(this._signingKey().signDigest(hash_1._TypedDataEncoder.hash(populated.domain, types, populated.value)))];
- }
- });
- });
- };
- Wallet.prototype.encrypt = function (password, options, progressCallback) {
- if (typeof (options) === "function" && !progressCallback) {
- progressCallback = options;
- options = {};
- }
- if (progressCallback && typeof (progressCallback) !== "function") {
- throw new Error("invalid callback");
- }
- if (!options) {
- options = {};
- }
- return (0, json_wallets_1.encryptKeystore)(this, password, options, progressCallback);
- };
- /**
- * Static methods to create Wallet instances.
- */
- Wallet.createRandom = function (options) {
- var entropy = (0, random_1.randomBytes)(16);
- if (!options) {
- options = {};
- }
- if (options.extraEntropy) {
- entropy = (0, bytes_1.arrayify)((0, bytes_1.hexDataSlice)((0, keccak256_1.keccak256)((0, bytes_1.concat)([entropy, options.extraEntropy])), 0, 16));
- }
- var mnemonic = (0, hdnode_1.entropyToMnemonic)(entropy, options.locale);
- return Wallet.fromMnemonic(mnemonic, options.path, options.locale);
- };
- Wallet.fromEncryptedJson = function (json, password, progressCallback) {
- return (0, json_wallets_1.decryptJsonWallet)(json, password, progressCallback).then(function (account) {
- return new Wallet(account);
- });
- };
- Wallet.fromEncryptedJsonSync = function (json, password) {
- return new Wallet((0, json_wallets_1.decryptJsonWalletSync)(json, password));
- };
- Wallet.fromMnemonic = function (mnemonic, path, wordlist) {
- if (!path) {
- path = hdnode_1.defaultPath;
- }
- return new Wallet(hdnode_1.HDNode.fromMnemonic(mnemonic, null, wordlist).derivePath(path));
- };
- return Wallet;
- }(abstract_signer_1.Signer));
- exports.Wallet = Wallet;
- function verifyMessage(message, signature) {
- return (0, transactions_1.recoverAddress)((0, hash_1.hashMessage)(message), signature);
- }
- exports.verifyMessage = verifyMessage;
- function verifyTypedData(domain, types, value, signature) {
- return (0, transactions_1.recoverAddress)(hash_1._TypedDataEncoder.hash(domain, types, value), signature);
- }
- exports.verifyTypedData = verifyTypedData;
- },{"./_version":272,"@ethersproject/abstract-provider":185,"@ethersproject/abstract-signer":187,"@ethersproject/address":189,"@ethersproject/bytes":199,"@ethersproject/hash":209,"@ethersproject/hdnode":214,"@ethersproject/json-wallets":217,"@ethersproject/keccak256":221,"@ethersproject/logger":223,"@ethersproject/properties":229,"@ethersproject/random":250,"@ethersproject/signing-key":260,"@ethersproject/transactions":269}],274:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.version = void 0;
- exports.version = "web/5.6.0";
- },{}],275:[function(_dereq_,module,exports){
- "use strict";
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
- return new (P || (P = Promise))(function (resolve, reject) {
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
- step((generator = generator.apply(thisArg, _arguments || [])).next());
- });
- };
- var __generator = (this && this.__generator) || function (thisArg, body) {
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
- function verb(n) { return function (v) { return step([n, v]); }; }
- function step(op) {
- if (f) throw new TypeError("Generator is already executing.");
- while (_) try {
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
- if (y = 0, t) op = [op[0] & 2, t.value];
- switch (op[0]) {
- case 0: case 1: t = op; break;
- case 4: _.label++; return { value: op[1], done: false };
- case 5: _.label++; y = op[1]; op = [0]; continue;
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
- default:
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
- if (t[2]) _.ops.pop();
- _.trys.pop(); continue;
- }
- op = body.call(thisArg, _);
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
- }
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.getUrl = void 0;
- var bytes_1 = _dereq_("@ethersproject/bytes");
- function getUrl(href, options) {
- return __awaiter(this, void 0, void 0, function () {
- var request, response, body, headers;
- return __generator(this, function (_a) {
- switch (_a.label) {
- case 0:
- if (options == null) {
- options = {};
- }
- request = {
- method: (options.method || "GET"),
- headers: (options.headers || {}),
- body: (options.body || undefined),
- };
- if (options.skipFetchSetup !== true) {
- request.mode = "cors"; // no-cors, cors, *same-origin
- request.cache = "no-cache"; // *default, no-cache, reload, force-cache, only-if-cached
- request.credentials = "same-origin"; // include, *same-origin, omit
- request.redirect = "follow"; // manual, *follow, error
- request.referrer = "client"; // no-referrer, *client
- }
- ;
- return [4 /*yield*/, fetch(href, request)];
- case 1:
- response = _a.sent();
- return [4 /*yield*/, response.arrayBuffer()];
- case 2:
- body = _a.sent();
- headers = {};
- if (response.headers.forEach) {
- response.headers.forEach(function (value, key) {
- headers[key.toLowerCase()] = value;
- });
- }
- else {
- ((response.headers).keys)().forEach(function (key) {
- headers[key.toLowerCase()] = response.headers.get(key);
- });
- }
- return [2 /*return*/, {
- headers: headers,
- statusCode: response.status,
- statusMessage: response.statusText,
- body: (0, bytes_1.arrayify)(new Uint8Array(body)),
- }];
- }
- });
- });
- }
- exports.getUrl = getUrl;
- },{"@ethersproject/bytes":199}],276:[function(_dereq_,module,exports){
- "use strict";
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
- return new (P || (P = Promise))(function (resolve, reject) {
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
- step((generator = generator.apply(thisArg, _arguments || [])).next());
- });
- };
- var __generator = (this && this.__generator) || function (thisArg, body) {
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
- function verb(n) { return function (v) { return step([n, v]); }; }
- function step(op) {
- if (f) throw new TypeError("Generator is already executing.");
- while (_) try {
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
- if (y = 0, t) op = [op[0] & 2, t.value];
- switch (op[0]) {
- case 0: case 1: t = op; break;
- case 4: _.label++; return { value: op[1], done: false };
- case 5: _.label++; y = op[1]; op = [0]; continue;
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
- default:
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
- if (t[2]) _.ops.pop();
- _.trys.pop(); continue;
- }
- op = body.call(thisArg, _);
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
- }
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.poll = exports.fetchJson = exports._fetchData = void 0;
- var base64_1 = _dereq_("@ethersproject/base64");
- var bytes_1 = _dereq_("@ethersproject/bytes");
- var properties_1 = _dereq_("@ethersproject/properties");
- var strings_1 = _dereq_("@ethersproject/strings");
- var logger_1 = _dereq_("@ethersproject/logger");
- var _version_1 = _dereq_("./_version");
- var logger = new logger_1.Logger(_version_1.version);
- var geturl_1 = _dereq_("./geturl");
- function staller(duration) {
- return new Promise(function (resolve) {
- setTimeout(resolve, duration);
- });
- }
- function bodyify(value, type) {
- if (value == null) {
- return null;
- }
- if (typeof (value) === "string") {
- return value;
- }
- if ((0, bytes_1.isBytesLike)(value)) {
- if (type && (type.split("/")[0] === "text" || type.split(";")[0].trim() === "application/json")) {
- try {
- return (0, strings_1.toUtf8String)(value);
- }
- catch (error) { }
- ;
- }
- return (0, bytes_1.hexlify)(value);
- }
- return value;
- }
- // This API is still a work in progress; the future changes will likely be:
- // - ConnectionInfo => FetchDataRequest<T = any>
- // - FetchDataRequest.body? = string | Uint8Array | { contentType: string, data: string | Uint8Array }
- // - If string => text/plain, Uint8Array => application/octet-stream (if content-type unspecified)
- // - FetchDataRequest.processFunc = (body: Uint8Array, response: FetchDataResponse) => T
- // For this reason, it should be considered internal until the API is finalized
- function _fetchData(connection, body, processFunc) {
- // How many times to retry in the event of a throttle
- var attemptLimit = (typeof (connection) === "object" && connection.throttleLimit != null) ? connection.throttleLimit : 12;
- logger.assertArgument((attemptLimit > 0 && (attemptLimit % 1) === 0), "invalid connection throttle limit", "connection.throttleLimit", attemptLimit);
- var throttleCallback = ((typeof (connection) === "object") ? connection.throttleCallback : null);
- var throttleSlotInterval = ((typeof (connection) === "object" && typeof (connection.throttleSlotInterval) === "number") ? connection.throttleSlotInterval : 100);
- logger.assertArgument((throttleSlotInterval > 0 && (throttleSlotInterval % 1) === 0), "invalid connection throttle slot interval", "connection.throttleSlotInterval", throttleSlotInterval);
- var errorPassThrough = ((typeof (connection) === "object") ? !!(connection.errorPassThrough) : false);
- var headers = {};
- var url = null;
- // @TODO: Allow ConnectionInfo to override some of these values
- var options = {
- method: "GET",
- };
- var allow304 = false;
- var timeout = 2 * 60 * 1000;
- if (typeof (connection) === "string") {
- url = connection;
- }
- else if (typeof (connection) === "object") {
- if (connection == null || connection.url == null) {
- logger.throwArgumentError("missing URL", "connection.url", connection);
- }
- url = connection.url;
- if (typeof (connection.timeout) === "number" && connection.timeout > 0) {
- timeout = connection.timeout;
- }
- if (connection.headers) {
- for (var key in connection.headers) {
- headers[key.toLowerCase()] = { key: key, value: String(connection.headers[key]) };
- if (["if-none-match", "if-modified-since"].indexOf(key.toLowerCase()) >= 0) {
- allow304 = true;
- }
- }
- }
- options.allowGzip = !!connection.allowGzip;
- if (connection.user != null && connection.password != null) {
- if (url.substring(0, 6) !== "https:" && connection.allowInsecureAuthentication !== true) {
- logger.throwError("basic authentication requires a secure https url", logger_1.Logger.errors.INVALID_ARGUMENT, { argument: "url", url: url, user: connection.user, password: "[REDACTED]" });
- }
- var authorization = connection.user + ":" + connection.password;
- headers["authorization"] = {
- key: "Authorization",
- value: "Basic " + (0, base64_1.encode)((0, strings_1.toUtf8Bytes)(authorization))
- };
- }
- if (connection.skipFetchSetup != null) {
- options.skipFetchSetup = !!connection.skipFetchSetup;
- }
- }
- var reData = new RegExp("^data:([a-z0-9-]+/[a-z0-9-]+);base64,(.*)$", "i");
- var dataMatch = ((url) ? url.match(reData) : null);
- if (dataMatch) {
- try {
- var response = {
- statusCode: 200,
- statusMessage: "OK",
- headers: { "content-type": dataMatch[1] },
- body: (0, base64_1.decode)(dataMatch[2])
- };
- var result = response.body;
- if (processFunc) {
- result = processFunc(response.body, response);
- }
- return Promise.resolve(result);
- }
- catch (error) {
- logger.throwError("processing response error", logger_1.Logger.errors.SERVER_ERROR, {
- body: bodyify(dataMatch[1], dataMatch[2]),
- error: error,
- requestBody: null,
- requestMethod: "GET",
- url: url
- });
- }
- }
- if (body) {
- options.method = "POST";
- options.body = body;
- if (headers["content-type"] == null) {
- headers["content-type"] = { key: "Content-Type", value: "application/octet-stream" };
- }
- if (headers["content-length"] == null) {
- headers["content-length"] = { key: "Content-Length", value: String(body.length) };
- }
- }
- var flatHeaders = {};
- Object.keys(headers).forEach(function (key) {
- var header = headers[key];
- flatHeaders[header.key] = header.value;
- });
- options.headers = flatHeaders;
- var runningTimeout = (function () {
- var timer = null;
- var promise = new Promise(function (resolve, reject) {
- if (timeout) {
- timer = setTimeout(function () {
- if (timer == null) {
- return;
- }
- timer = null;
- reject(logger.makeError("timeout", logger_1.Logger.errors.TIMEOUT, {
- requestBody: bodyify(options.body, flatHeaders["content-type"]),
- requestMethod: options.method,
- timeout: timeout,
- url: url
- }));
- }, timeout);
- }
- });
- var cancel = function () {
- if (timer == null) {
- return;
- }
- clearTimeout(timer);
- timer = null;
- };
- return { promise: promise, cancel: cancel };
- })();
- var runningFetch = (function () {
- return __awaiter(this, void 0, void 0, function () {
- var attempt, response, location_1, tryAgain, stall, retryAfter, error_1, body_1, result, error_2, tryAgain, timeout_1;
- return __generator(this, function (_a) {
- switch (_a.label) {
- case 0:
- attempt = 0;
- _a.label = 1;
- case 1:
- if (!(attempt < attemptLimit)) return [3 /*break*/, 20];
- response = null;
- _a.label = 2;
- case 2:
- _a.trys.push([2, 9, , 10]);
- return [4 /*yield*/, (0, geturl_1.getUrl)(url, options)];
- case 3:
- response = _a.sent();
- if (!(attempt < attemptLimit)) return [3 /*break*/, 8];
- if (!(response.statusCode === 301 || response.statusCode === 302)) return [3 /*break*/, 4];
- location_1 = response.headers.location || "";
- if (options.method === "GET" && location_1.match(/^https:/)) {
- url = response.headers.location;
- return [3 /*break*/, 19];
- }
- return [3 /*break*/, 8];
- case 4:
- if (!(response.statusCode === 429)) return [3 /*break*/, 8];
- tryAgain = true;
- if (!throttleCallback) return [3 /*break*/, 6];
- return [4 /*yield*/, throttleCallback(attempt, url)];
- case 5:
- tryAgain = _a.sent();
- _a.label = 6;
- case 6:
- if (!tryAgain) return [3 /*break*/, 8];
- stall = 0;
- retryAfter = response.headers["retry-after"];
- if (typeof (retryAfter) === "string" && retryAfter.match(/^[1-9][0-9]*$/)) {
- stall = parseInt(retryAfter) * 1000;
- }
- else {
- stall = throttleSlotInterval * parseInt(String(Math.random() * Math.pow(2, attempt)));
- }
- //console.log("Stalling 429");
- return [4 /*yield*/, staller(stall)];
- case 7:
- //console.log("Stalling 429");
- _a.sent();
- return [3 /*break*/, 19];
- case 8: return [3 /*break*/, 10];
- case 9:
- error_1 = _a.sent();
- response = error_1.response;
- if (response == null) {
- runningTimeout.cancel();
- logger.throwError("missing response", logger_1.Logger.errors.SERVER_ERROR, {
- requestBody: bodyify(options.body, flatHeaders["content-type"]),
- requestMethod: options.method,
- serverError: error_1,
- url: url
- });
- }
- return [3 /*break*/, 10];
- case 10:
- body_1 = response.body;
- if (allow304 && response.statusCode === 304) {
- body_1 = null;
- }
- else if (!errorPassThrough && (response.statusCode < 200 || response.statusCode >= 300)) {
- runningTimeout.cancel();
- logger.throwError("bad response", logger_1.Logger.errors.SERVER_ERROR, {
- status: response.statusCode,
- headers: response.headers,
- body: bodyify(body_1, ((response.headers) ? response.headers["content-type"] : null)),
- requestBody: bodyify(options.body, flatHeaders["content-type"]),
- requestMethod: options.method,
- url: url
- });
- }
- if (!processFunc) return [3 /*break*/, 18];
- _a.label = 11;
- case 11:
- _a.trys.push([11, 13, , 18]);
- return [4 /*yield*/, processFunc(body_1, response)];
- case 12:
- result = _a.sent();
- runningTimeout.cancel();
- return [2 /*return*/, result];
- case 13:
- error_2 = _a.sent();
- if (!(error_2.throttleRetry && attempt < attemptLimit)) return [3 /*break*/, 17];
- tryAgain = true;
- if (!throttleCallback) return [3 /*break*/, 15];
- return [4 /*yield*/, throttleCallback(attempt, url)];
- case 14:
- tryAgain = _a.sent();
- _a.label = 15;
- case 15:
- if (!tryAgain) return [3 /*break*/, 17];
- timeout_1 = throttleSlotInterval * parseInt(String(Math.random() * Math.pow(2, attempt)));
- //console.log("Stalling callback");
- return [4 /*yield*/, staller(timeout_1)];
- case 16:
- //console.log("Stalling callback");
- _a.sent();
- return [3 /*break*/, 19];
- case 17:
- runningTimeout.cancel();
- logger.throwError("processing response error", logger_1.Logger.errors.SERVER_ERROR, {
- body: bodyify(body_1, ((response.headers) ? response.headers["content-type"] : null)),
- error: error_2,
- requestBody: bodyify(options.body, flatHeaders["content-type"]),
- requestMethod: options.method,
- url: url
- });
- return [3 /*break*/, 18];
- case 18:
- runningTimeout.cancel();
- // If we had a processFunc, it either returned a T or threw above.
- // The "body" is now a Uint8Array.
- return [2 /*return*/, body_1];
- case 19:
- attempt++;
- return [3 /*break*/, 1];
- case 20: return [2 /*return*/, logger.throwError("failed response", logger_1.Logger.errors.SERVER_ERROR, {
- requestBody: bodyify(options.body, flatHeaders["content-type"]),
- requestMethod: options.method,
- url: url
- })];
- }
- });
- });
- })();
- return Promise.race([runningTimeout.promise, runningFetch]);
- }
- exports._fetchData = _fetchData;
- function fetchJson(connection, json, processFunc) {
- var processJsonFunc = function (value, response) {
- var result = null;
- if (value != null) {
- try {
- result = JSON.parse((0, strings_1.toUtf8String)(value));
- }
- catch (error) {
- logger.throwError("invalid JSON", logger_1.Logger.errors.SERVER_ERROR, {
- body: value,
- error: error
- });
- }
- }
- if (processFunc) {
- result = processFunc(result, response);
- }
- return result;
- };
- // If we have json to send, we must
- // - add content-type of application/json (unless already overridden)
- // - convert the json to bytes
- var body = null;
- if (json != null) {
- body = (0, strings_1.toUtf8Bytes)(json);
- // Create a connection with the content-type set for JSON
- var updated = (typeof (connection) === "string") ? ({ url: connection }) : (0, properties_1.shallowCopy)(connection);
- if (updated.headers) {
- var hasContentType = (Object.keys(updated.headers).filter(function (k) { return (k.toLowerCase() === "content-type"); }).length) !== 0;
- if (!hasContentType) {
- updated.headers = (0, properties_1.shallowCopy)(updated.headers);
- updated.headers["content-type"] = "application/json";
- }
- }
- else {
- updated.headers = { "content-type": "application/json" };
- }
- connection = updated;
- }
- return _fetchData(connection, body, processJsonFunc);
- }
- exports.fetchJson = fetchJson;
- function poll(func, options) {
- if (!options) {
- options = {};
- }
- options = (0, properties_1.shallowCopy)(options);
- if (options.floor == null) {
- options.floor = 0;
- }
- if (options.ceiling == null) {
- options.ceiling = 10000;
- }
- if (options.interval == null) {
- options.interval = 250;
- }
- return new Promise(function (resolve, reject) {
- var timer = null;
- var done = false;
- // Returns true if cancel was successful. Unsuccessful cancel means we're already done.
- var cancel = function () {
- if (done) {
- return false;
- }
- done = true;
- if (timer) {
- clearTimeout(timer);
- }
- return true;
- };
- if (options.timeout) {
- timer = setTimeout(function () {
- if (cancel()) {
- reject(new Error("timeout"));
- }
- }, options.timeout);
- }
- var retryLimit = options.retryLimit;
- var attempt = 0;
- function check() {
- return func().then(function (result) {
- // If we have a result, or are allowed null then we're done
- if (result !== undefined) {
- if (cancel()) {
- resolve(result);
- }
- }
- else if (options.oncePoll) {
- options.oncePoll.once("poll", check);
- }
- else if (options.onceBlock) {
- options.onceBlock.once("block", check);
- // Otherwise, exponential back-off (up to 10s) our next request
- }
- else if (!done) {
- attempt++;
- if (attempt > retryLimit) {
- if (cancel()) {
- reject(new Error("retry limit reached"));
- }
- return;
- }
- var timeout = options.interval * parseInt(String(Math.random() * Math.pow(2, attempt)));
- if (timeout < options.floor) {
- timeout = options.floor;
- }
- if (timeout > options.ceiling) {
- timeout = options.ceiling;
- }
- setTimeout(check, timeout);
- }
- return null;
- }, function (error) {
- if (cancel()) {
- reject(error);
- }
- });
- }
- check();
- });
- }
- exports.poll = poll;
- },{"./_version":274,"./geturl":275,"@ethersproject/base64":191,"@ethersproject/bytes":199,"@ethersproject/logger":223,"@ethersproject/properties":229,"@ethersproject/strings":266}],277:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.version = void 0;
- exports.version = "wordlists/5.6.0";
- },{}],278:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.wordlists = exports.Wordlist = exports.logger = void 0;
- // Wordlists
- // See: https://github.com/bitcoin/bips/blob/master/bip-0039/bip-0039-wordlists.md
- var wordlist_1 = _dereq_("./wordlist");
- Object.defineProperty(exports, "logger", { enumerable: true, get: function () { return wordlist_1.logger; } });
- Object.defineProperty(exports, "Wordlist", { enumerable: true, get: function () { return wordlist_1.Wordlist; } });
- var wordlists_1 = _dereq_("./wordlists");
- Object.defineProperty(exports, "wordlists", { enumerable: true, get: function () { return wordlists_1.wordlists; } });
- },{"./wordlist":287,"./wordlists":288}],279:[function(_dereq_,module,exports){
- "use strict";
- var __extends = (this && this.__extends) || (function () {
- var extendStatics = function (d, b) {
- extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
- return extendStatics(d, b);
- };
- return function (d, b) {
- if (typeof b !== "function" && b !== null)
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.langCz = void 0;
- var wordlist_1 = _dereq_("./wordlist");
- var words = "AbdikaceAbecedaAdresaAgreseAkceAktovkaAlejAlkoholAmputaceAnanasAndulkaAnekdotaAnketaAntikaAnulovatArchaAroganceAsfaltAsistentAspiraceAstmaAstronomAtlasAtletikaAtolAutobusAzylBabkaBachorBacilBaculkaBadatelBagetaBagrBahnoBakterieBaladaBaletkaBalkonBalonekBalvanBalzaBambusBankomatBarbarBaretBarmanBarokoBarvaBaterkaBatohBavlnaBazalkaBazilikaBazukaBednaBeranBesedaBestieBetonBezinkaBezmocBeztakBicyklBidloBiftekBikinyBilanceBiografBiologBitvaBizonBlahobytBlatouchBlechaBleduleBleskBlikatBliznaBlokovatBlouditBludBobekBobrBodlinaBodnoutBohatostBojkotBojovatBokorysBolestBorecBoroviceBotaBoubelBouchatBoudaBouleBouratBoxerBradavkaBramboraBrankaBratrBreptaBriketaBrkoBrlohBronzBroskevBrunetkaBrusinkaBrzdaBrzyBublinaBubnovatBuchtaBuditelBudkaBudovaBufetBujarostBukviceBuldokBulvaBundaBunkrBurzaButikBuvolBuzolaBydletBylinaBytovkaBzukotCapartCarevnaCedrCeduleCejchCejnCelaCelerCelkemCelniceCeninaCennostCenovkaCentrumCenzorCestopisCetkaChalupaChapadloCharitaChataChechtatChemieChichotChirurgChladChlebaChlubitChmelChmuraChobotChocholChodbaCholeraChomoutChopitChorobaChovChrapotChrlitChrtChrupChtivostChudinaChutnatChvatChvilkaChvostChybaChystatChytitCibuleCigaretaCihelnaCihlaCinkotCirkusCisternaCitaceCitrusCizinecCizostClonaCokolivCouvatCtitelCtnostCudnostCuketaCukrCupotCvaknoutCvalCvikCvrkotCyklistaDalekoDarebaDatelDatumDceraDebataDechovkaDecibelDeficitDeflaceDeklDekretDemokratDepreseDerbyDeskaDetektivDikobrazDiktovatDiodaDiplomDiskDisplejDivadloDivochDlahaDlouhoDluhopisDnesDobroDobytekDocentDochutitDodnesDohledDohodaDohraDojemDojniceDokladDokolaDoktorDokumentDolarDolevaDolinaDomaDominantDomluvitDomovDonutitDopadDopisDoplnitDoposudDoprovodDopustitDorazitDorostDortDosahDoslovDostatekDosudDosytaDotazDotekDotknoutDoufatDoutnatDovozceDozaduDoznatDozorceDrahotaDrakDramatikDravecDrazeDrdolDrobnostDrogerieDrozdDrsnostDrtitDrzostDubenDuchovnoDudekDuhaDuhovkaDusitDusnoDutostDvojiceDvorecDynamitEkologEkonomieElektronElipsaEmailEmiseEmoceEmpatieEpizodaEpochaEpopejEposEsejEsenceEskortaEskymoEtiketaEuforieEvoluceExekuceExkurzeExpediceExplozeExportExtraktFackaFajfkaFakultaFanatikFantazieFarmacieFavoritFazoleFederaceFejetonFenkaFialkaFigurantFilozofFiltrFinanceFintaFixaceFjordFlanelFlirtFlotilaFondFosforFotbalFotkaFotonFrakceFreskaFrontaFukarFunkceFyzikaGalejeGarantGenetikaGeologGilotinaGlazuraGlejtGolemGolfistaGotikaGrafGramofonGranuleGrepGrilGrogGroteskaGumaHadiceHadrHalaHalenkaHanbaHanopisHarfaHarpunaHavranHebkostHejkalHejnoHejtmanHektarHelmaHematomHerecHernaHesloHezkyHistorikHladovkaHlasivkyHlavaHledatHlenHlodavecHlohHloupostHltatHlubinaHluchotaHmatHmotaHmyzHnisHnojivoHnoutHoblinaHobojHochHodinyHodlatHodnotaHodovatHojnostHokejHolinkaHolkaHolubHomoleHonitbaHonoraceHoralHordaHorizontHorkoHorlivecHormonHorninaHoroskopHorstvoHospodaHostinaHotovostHoubaHoufHoupatHouskaHovorHradbaHraniceHravostHrazdaHrbolekHrdinaHrdloHrdostHrnekHrobkaHromadaHrotHroudaHrozenHrstkaHrubostHryzatHubenostHubnoutHudbaHukotHumrHusitaHustotaHvozdHybnostHydrantHygienaHymnaHysterikIdylkaIhnedIkonaIluzeImunitaInfekceInflaceInkasoInovaceInspekceInternetInvalidaInvestorInzerceIronieJablkoJachtaJahodaJakmileJakostJalovecJantarJarmarkJaroJasanJasnoJatkaJavorJazykJedinecJedleJednatelJehlanJekotJelenJelitoJemnostJenomJepiceJeseterJevitJezdecJezeroJinakJindyJinochJiskraJistotaJitrniceJizvaJmenovatJogurtJurtaKabaretKabelKabinetKachnaKadetKadidloKahanKajakKajutaKakaoKaktusKalamitaKalhotyKalibrKalnostKameraKamkolivKamnaKanibalKanoeKantorKapalinaKapelaKapitolaKapkaKapleKapotaKaprKapustaKapybaraKaramelKarotkaKartonKasaKatalogKatedraKauceKauzaKavalecKazajkaKazetaKazivostKdekolivKdesiKedlubenKempKeramikaKinoKlacekKladivoKlamKlapotKlasikaKlaunKlecKlenbaKlepatKlesnoutKlidKlimaKlisnaKloboukKlokanKlopaKloubKlubovnaKlusatKluzkostKmenKmitatKmotrKnihaKnotKoaliceKoberecKobkaKoblihaKobylaKocourKohoutKojenecKokosKoktejlKolapsKoledaKolizeKoloKomandoKometaKomikKomnataKomoraKompasKomunitaKonatKonceptKondiceKonecKonfeseKongresKoninaKonkursKontaktKonzervaKopanecKopieKopnoutKoprovkaKorbelKorektorKormidloKoroptevKorpusKorunaKorytoKorzetKosatecKostkaKotelKotletaKotoulKoukatKoupelnaKousekKouzloKovbojKozaKozorohKrabiceKrachKrajinaKralovatKrasopisKravataKreditKrejcarKresbaKrevetaKriketKritikKrizeKrkavecKrmelecKrmivoKrocanKrokKronikaKropitKroupaKrovkaKrtekKruhadloKrupiceKrutostKrvinkaKrychleKryptaKrystalKrytKudlankaKufrKujnostKuklaKulajdaKulichKulkaKulometKulturaKunaKupodivuKurtKurzorKutilKvalitaKvasinkaKvestorKynologKyselinaKytaraKyticeKytkaKytovecKyvadloLabradorLachtanLadnostLaikLakomecLamelaLampaLanovkaLasiceLasoLasturaLatinkaLavinaLebkaLeckdyLedenLedniceLedovkaLedvinaLegendaLegieLegraceLehceLehkostLehnoutLektvarLenochodLentilkaLepenkaLepidloLetadloLetecLetmoLetokruhLevhartLevitaceLevobokLibraLichotkaLidojedLidskostLihovinaLijavecLilekLimetkaLinieLinkaLinoleumListopadLitinaLitovatLobistaLodivodLogikaLogopedLokalitaLoketLomcovatLopataLopuchLordLososLotrLoudalLouhLoukaLouskatLovecLstivostLucernaLuciferLumpLuskLustraceLviceLyraLyrikaLysinaMadamMadloMagistrMahagonMajetekMajitelMajoritaMakakMakoviceMakrelaMalbaMalinaMalovatMalviceMaminkaMandleMankoMarnostMasakrMaskotMasopustMaticeMatrikaMaturitaMazanecMazivoMazlitMazurkaMdlobaMechanikMeditaceMedovinaMelasaMelounMentolkaMetlaMetodaMetrMezeraMigraceMihnoutMihuleMikinaMikrofonMilenecMilimetrMilostMimikaMincovnaMinibarMinometMinulostMiskaMistrMixovatMladostMlhaMlhovinaMlokMlsatMluvitMnichMnohemMobilMocnostModelkaModlitbaMohylaMokroMolekulaMomentkaMonarchaMonoklMonstrumMontovatMonzunMosazMoskytMostMotivaceMotorkaMotykaMouchaMoudrostMozaikaMozekMozolMramorMravenecMrkevMrtvolaMrzetMrzutostMstitelMudrcMuflonMulatMumieMuniceMusetMutaceMuzeumMuzikantMyslivecMzdaNabouratNachytatNadaceNadbytekNadhozNadobroNadpisNahlasNahnatNahodileNahraditNaivitaNajednouNajistoNajmoutNaklonitNakonecNakrmitNalevoNamazatNamluvitNanometrNaokoNaopakNaostroNapadatNapevnoNaplnitNapnoutNaposledNaprostoNaroditNarubyNarychloNasaditNasekatNaslepoNastatNatolikNavenekNavrchNavzdoryNazvatNebeNechatNeckyNedalekoNedbatNeduhNegaceNehetNehodaNejenNejprveNeklidNelibostNemilostNemocNeochotaNeonkaNepokojNerostNervNesmyslNesouladNetvorNeuronNevinaNezvykleNicotaNijakNikamNikdyNiklNikterakNitroNoclehNohaviceNominaceNoraNorekNositelNosnostNouzeNovinyNovotaNozdraNudaNudleNugetNutitNutnostNutrieNymfaObalObarvitObavaObdivObecObehnatObejmoutObezitaObhajobaObilniceObjasnitObjektObklopitOblastOblekOblibaOblohaObludaObnosObohatitObojekOboutObrazecObrnaObrubaObrysObsahObsluhaObstaratObuvObvazObvinitObvodObvykleObyvatelObzorOcasOcelOcenitOchladitOchotaOchranaOcitnoutOdbojOdbytOdchodOdcizitOdebratOdeslatOdevzdatOdezvaOdhadceOdhoditOdjetOdjinudOdkazOdkoupitOdlivOdlukaOdmlkaOdolnostOdpadOdpisOdploutOdporOdpustitOdpykatOdrazkaOdsouditOdstupOdsunOdtokOdtudOdvahaOdvetaOdvolatOdvracetOdznakOfinaOfsajdOhlasOhniskoOhradaOhrozitOhryzekOkapOkeniceOklikaOknoOkouzlitOkovyOkrasaOkresOkrsekOkruhOkupantOkurkaOkusitOlejninaOlizovatOmakOmeletaOmezitOmladinaOmlouvatOmluvaOmylOnehdyOpakovatOpasekOperaceOpiceOpilostOpisovatOporaOpoziceOpravduOprotiOrbitalOrchestrOrgieOrliceOrlojOrtelOsadaOschnoutOsikaOsivoOslavaOslepitOslnitOslovitOsnovaOsobaOsolitOspalecOstenOstrahaOstudaOstychOsvojitOteplitOtiskOtopOtrhatOtrlostOtrokOtrubyOtvorOvanoutOvarOvesOvlivnitOvoceOxidOzdobaPachatelPacientPadouchPahorekPaktPalandaPalecPalivoPalubaPamfletPamlsekPanenkaPanikaPannaPanovatPanstvoPantoflePaprikaParketaParodiePartaParukaParybaPasekaPasivitaPastelkaPatentPatronaPavoukPaznehtPazourekPeckaPedagogPejsekPekloPelotonPenaltaPendrekPenzePeriskopPeroPestrostPetardaPeticePetrolejPevninaPexesoPianistaPihaPijavicePiklePiknikPilinaPilnostPilulkaPinzetaPipetaPisatelPistolePitevnaPivnicePivovarPlacentaPlakatPlamenPlanetaPlastikaPlatitPlavidloPlazPlechPlemenoPlentaPlesPletivoPlevelPlivatPlnitPlnoPlochaPlodinaPlombaPloutPlukPlynPobavitPobytPochodPocitPoctivecPodatPodcenitPodepsatPodhledPodivitPodkladPodmanitPodnikPodobaPodporaPodrazPodstataPodvodPodzimPoeziePohankaPohnutkaPohovorPohromaPohybPointaPojistkaPojmoutPokazitPoklesPokojPokrokPokutaPokynPolednePolibekPolknoutPolohaPolynomPomaluPominoutPomlkaPomocPomstaPomysletPonechatPonorkaPonurostPopadatPopelPopisekPoplachPoprositPopsatPopudPoradcePorcePorodPoruchaPoryvPosaditPosedPosilaPoskokPoslanecPosouditPospoluPostavaPosudekPosypPotahPotkanPotleskPotomekPotravaPotupaPotvoraPoukazPoutoPouzdroPovahaPovidlaPovlakPovozPovrchPovstatPovykPovzdechPozdravPozemekPoznatekPozorPozvatPracovatPrahoryPraktikaPralesPraotecPraporekPrasePravdaPrincipPrknoProbuditProcentoProdejProfeseProhraProjektProlomitPromilePronikatPropadProrokProsbaProtonProutekProvazPrskavkaPrstenPrudkostPrutPrvekPrvohoryPsanecPsovodPstruhPtactvoPubertaPuchPudlPukavecPuklinaPukrlePultPumpaPuncPupenPusaPusinkaPustinaPutovatPutykaPyramidaPyskPytelRacekRachotRadiaceRadniceRadonRaftRagbyRaketaRakovinaRamenoRampouchRandeRarachRaritaRasovnaRastrRatolestRazanceRazidloReagovatReakceReceptRedaktorReferentReflexRejnokReklamaRekordRekrutRektorReputaceRevizeRevmaRevolverRezervaRiskovatRizikoRobotikaRodokmenRohovkaRokleRokokoRomanetoRopovodRopuchaRorejsRosolRostlinaRotmistrRotopedRotundaRoubenkaRouchoRoupRouraRovinaRovniceRozborRozchodRozdatRozeznatRozhodceRozinkaRozjezdRozkazRozlohaRozmarRozpadRozruchRozsahRoztokRozumRozvodRubrikaRuchadloRukaviceRukopisRybaRybolovRychlostRydloRypadloRytinaRyzostSadistaSahatSakoSamecSamizdatSamotaSanitkaSardinkaSasankaSatelitSazbaSazeniceSborSchovatSebrankaSeceseSedadloSedimentSedloSehnatSejmoutSekeraSektaSekundaSekvojeSemenoSenoServisSesaditSeshoraSeskokSeslatSestraSesuvSesypatSetbaSetinaSetkatSetnoutSetrvatSeverSeznamShodaShrnoutSifonSilniceSirkaSirotekSirupSituaceSkafandrSkaliskoSkanzenSkautSkeptikSkicaSkladbaSkleniceSkloSkluzSkobaSkokanSkoroSkriptaSkrzSkupinaSkvostSkvrnaSlabikaSladidloSlaninaSlastSlavnostSledovatSlepecSlevaSlezinaSlibSlinaSlizniceSlonSloupekSlovoSluchSluhaSlunceSlupkaSlzaSmaragdSmetanaSmilstvoSmlouvaSmogSmradSmrkSmrtkaSmutekSmyslSnadSnahaSnobSobotaSochaSodovkaSokolSopkaSotvaSoubojSoucitSoudceSouhlasSouladSoumrakSoupravaSousedSoutokSouvisetSpalovnaSpasitelSpisSplavSpodekSpojenecSpoluSponzorSpornostSpoustaSprchaSpustitSrandaSrazSrdceSrnaSrnecSrovnatSrpenSrstSrubStaniceStarostaStatikaStavbaStehnoStezkaStodolaStolekStopaStornoStoupatStrachStresStrhnoutStromStrunaStudnaStupniceStvolStykSubjektSubtropySucharSudostSuknoSundatSunoutSurikataSurovinaSvahSvalstvoSvetrSvatbaSvazekSvisleSvitekSvobodaSvodidloSvorkaSvrabSykavkaSykotSynekSynovecSypatSypkostSyrovostSyselSytostTabletkaTabuleTahounTajemnoTajfunTajgaTajitTajnostTaktikaTamhleTamponTancovatTanecTankerTapetaTaveninaTazatelTechnikaTehdyTekutinaTelefonTemnotaTendenceTenistaTenorTeplotaTepnaTeprveTerapieTermoskaTextilTichoTiskopisTitulekTkadlecTkaninaTlapkaTleskatTlukotTlupaTmelToaletaTopinkaTopolTorzoTouhaToulecTradiceTraktorTrampTrasaTraverzaTrefitTrestTrezorTrhavinaTrhlinaTrochuTrojiceTroskaTroubaTrpceTrpitelTrpkostTrubecTruchlitTruhliceTrusTrvatTudyTuhnoutTuhostTundraTuristaTurnajTuzemskoTvarohTvorbaTvrdostTvrzTygrTykevUbohostUbozeUbratUbrousekUbrusUbytovnaUchoUctivostUdivitUhraditUjednatUjistitUjmoutUkazatelUklidnitUklonitUkotvitUkrojitUliceUlitaUlovitUmyvadloUnavitUniformaUniknoutUpadnoutUplatnitUplynoutUpoutatUpravitUranUrazitUsednoutUsilovatUsmrtitUsnadnitUsnoutUsouditUstlatUstrnoutUtahovatUtkatUtlumitUtonoutUtopenecUtrousitUvalitUvolnitUvozovkaUzdravitUzelUzeninaUzlinaUznatVagonValchaValounVanaVandalVanilkaVaranVarhanyVarovatVcelkuVchodVdovaVedroVegetaceVejceVelbloudVeletrhVelitelVelmocVelrybaVenkovVerandaVerzeVeselkaVeskrzeVesniceVespoduVestaVeterinaVeverkaVibraceVichrVideohraVidinaVidleVilaViniceVisetVitalitaVizeVizitkaVjezdVkladVkusVlajkaVlakVlasecVlevoVlhkostVlivVlnovkaVloupatVnucovatVnukVodaVodivostVodoznakVodstvoVojenskyVojnaVojskoVolantVolbaVolitVolnoVoskovkaVozidloVozovnaVpravoVrabecVracetVrahVrataVrbaVrcholekVrhatVrstvaVrtuleVsaditVstoupitVstupVtipVybavitVybratVychovatVydatVydraVyfotitVyhledatVyhnoutVyhoditVyhraditVyhubitVyjasnitVyjetVyjmoutVyklopitVykonatVylekatVymazatVymezitVymizetVymysletVynechatVynikatVynutitVypadatVyplatitVypravitVypustitVyrazitVyrovnatVyrvatVyslovitVysokoVystavitVysunoutVysypatVytasitVytesatVytratitVyvinoutVyvolatVyvrhelVyzdobitVyznatVzaduVzbuditVzchopitVzdorVzduchVzdychatVzestupVzhledemVzkazVzlykatVznikVzorekVzpouraVztahVztekXylofonZabratZabydletZachovatZadarmoZadusitZafoukatZahltitZahoditZahradaZahynoutZajatecZajetZajistitZaklepatZakoupitZalepitZamezitZamotatZamysletZanechatZanikatZaplatitZapojitZapsatZarazitZastavitZasunoutZatajitZatemnitZatknoutZaujmoutZavalitZaveletZavinitZavolatZavrtatZazvonitZbavitZbrusuZbudovatZbytekZdalekaZdarmaZdatnostZdivoZdobitZdrojZdvihZdymadloZeleninaZemanZeminaZeptatZezaduZezdolaZhatitZhltnoutZhlubokaZhotovitZhrubaZimaZimniceZjemnitZklamatZkoumatZkratkaZkumavkaZlatoZlehkaZlobaZlomZlostZlozvykZmapovatZmarZmatekZmijeZmizetZmocnitZmodratZmrzlinaZmutovatZnakZnalostZnamenatZnovuZobrazitZotavitZoubekZoufaleZploditZpomalitZpravaZprostitZprudkaZprvuZradaZranitZrcadloZrnitostZrnoZrovnaZrychlitZrzavostZtichaZtratitZubovinaZubrZvednoutZvenkuZveselaZvonZvratZvukovodZvyk";
- var wordlist = null;
- function loadWords(lang) {
- if (wordlist != null) {
- return;
- }
- wordlist = words.replace(/([A-Z])/g, " $1").toLowerCase().substring(1).split(" ");
- // Verify the computed list matches the official list
- /* istanbul ignore if */
- if (wordlist_1.Wordlist.check(lang) !== "0x25f44555f4af25b51a711136e1c7d6e50ce9f8917d39d6b1f076b2bb4d2fac1a") {
- wordlist = null;
- throw new Error("BIP39 Wordlist for en (English) FAILED");
- }
- }
- var LangCz = /** @class */ (function (_super) {
- __extends(LangCz, _super);
- function LangCz() {
- return _super.call(this, "cz") || this;
- }
- LangCz.prototype.getWord = function (index) {
- loadWords(this);
- return wordlist[index];
- };
- LangCz.prototype.getWordIndex = function (word) {
- loadWords(this);
- return wordlist.indexOf(word);
- };
- return LangCz;
- }(wordlist_1.Wordlist));
- var langCz = new LangCz();
- exports.langCz = langCz;
- wordlist_1.Wordlist.register(langCz);
- },{"./wordlist":287}],280:[function(_dereq_,module,exports){
- "use strict";
- var __extends = (this && this.__extends) || (function () {
- var extendStatics = function (d, b) {
- extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
- return extendStatics(d, b);
- };
- return function (d, b) {
- if (typeof b !== "function" && b !== null)
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.langEn = void 0;
- var wordlist_1 = _dereq_("./wordlist");
- var words = "AbandonAbilityAbleAboutAboveAbsentAbsorbAbstractAbsurdAbuseAccessAccidentAccountAccuseAchieveAcidAcousticAcquireAcrossActActionActorActressActualAdaptAddAddictAddressAdjustAdmitAdultAdvanceAdviceAerobicAffairAffordAfraidAgainAgeAgentAgreeAheadAimAirAirportAisleAlarmAlbumAlcoholAlertAlienAllAlleyAllowAlmostAloneAlphaAlreadyAlsoAlterAlwaysAmateurAmazingAmongAmountAmusedAnalystAnchorAncientAngerAngleAngryAnimalAnkleAnnounceAnnualAnotherAnswerAntennaAntiqueAnxietyAnyApartApologyAppearAppleApproveAprilArchArcticAreaArenaArgueArmArmedArmorArmyAroundArrangeArrestArriveArrowArtArtefactArtistArtworkAskAspectAssaultAssetAssistAssumeAsthmaAthleteAtomAttackAttendAttitudeAttractAuctionAuditAugustAuntAuthorAutoAutumnAverageAvocadoAvoidAwakeAwareAwayAwesomeAwfulAwkwardAxisBabyBachelorBaconBadgeBagBalanceBalconyBallBambooBananaBannerBarBarelyBargainBarrelBaseBasicBasketBattleBeachBeanBeautyBecauseBecomeBeefBeforeBeginBehaveBehindBelieveBelowBeltBenchBenefitBestBetrayBetterBetweenBeyondBicycleBidBikeBindBiologyBirdBirthBitterBlackBladeBlameBlanketBlastBleakBlessBlindBloodBlossomBlouseBlueBlurBlushBoardBoatBodyBoilBombBoneBonusBookBoostBorderBoringBorrowBossBottomBounceBoxBoyBracketBrainBrandBrassBraveBreadBreezeBrickBridgeBriefBrightBringBriskBroccoliBrokenBronzeBroomBrotherBrownBrushBubbleBuddyBudgetBuffaloBuildBulbBulkBulletBundleBunkerBurdenBurgerBurstBusBusinessBusyButterBuyerBuzzCabbageCabinCableCactusCageCakeCallCalmCameraCampCanCanalCancelCandyCannonCanoeCanvasCanyonCapableCapitalCaptainCarCarbonCardCargoCarpetCarryCartCaseCashCasinoCastleCasualCatCatalogCatchCategoryCattleCaughtCauseCautionCaveCeilingCeleryCementCensusCenturyCerealCertainChairChalkChampionChangeChaosChapterChargeChaseChatCheapCheckCheeseChefCherryChestChickenChiefChildChimneyChoiceChooseChronicChuckleChunkChurnCigarCinnamonCircleCitizenCityCivilClaimClapClarifyClawClayCleanClerkCleverClickClientCliffClimbClinicClipClockClogCloseClothCloudClownClubClumpClusterClutchCoachCoastCoconutCodeCoffeeCoilCoinCollectColorColumnCombineComeComfortComicCommonCompanyConcertConductConfirmCongressConnectConsiderControlConvinceCookCoolCopperCopyCoralCoreCornCorrectCostCottonCouchCountryCoupleCourseCousinCoverCoyoteCrackCradleCraftCramCraneCrashCraterCrawlCrazyCreamCreditCreekCrewCricketCrimeCrispCriticCropCrossCrouchCrowdCrucialCruelCruiseCrumbleCrunchCrushCryCrystalCubeCultureCupCupboardCuriousCurrentCurtainCurveCushionCustomCuteCycleDadDamageDampDanceDangerDaringDashDaughterDawnDayDealDebateDebrisDecadeDecemberDecideDeclineDecorateDecreaseDeerDefenseDefineDefyDegreeDelayDeliverDemandDemiseDenialDentistDenyDepartDependDepositDepthDeputyDeriveDescribeDesertDesignDeskDespairDestroyDetailDetectDevelopDeviceDevoteDiagramDialDiamondDiaryDiceDieselDietDifferDigitalDignityDilemmaDinnerDinosaurDirectDirtDisagreeDiscoverDiseaseDishDismissDisorderDisplayDistanceDivertDivideDivorceDizzyDoctorDocumentDogDollDolphinDomainDonateDonkeyDonorDoorDoseDoubleDoveDraftDragonDramaDrasticDrawDreamDressDriftDrillDrinkDripDriveDropDrumDryDuckDumbDuneDuringDustDutchDutyDwarfDynamicEagerEagleEarlyEarnEarthEasilyEastEasyEchoEcologyEconomyEdgeEditEducateEffortEggEightEitherElbowElderElectricElegantElementElephantElevatorEliteElseEmbarkEmbodyEmbraceEmergeEmotionEmployEmpowerEmptyEnableEnactEndEndlessEndorseEnemyEnergyEnforceEngageEngineEnhanceEnjoyEnlistEnoughEnrichEnrollEnsureEnterEntireEntryEnvelopeEpisodeEqualEquipEraEraseErodeErosionErrorEruptEscapeEssayEssenceEstateEternalEthicsEvidenceEvilEvokeEvolveExactExampleExcessExchangeExciteExcludeExcuseExecuteExerciseExhaustExhibitExileExistExitExoticExpandExpectExpireExplainExposeExpressExtendExtraEyeEyebrowFabricFaceFacultyFadeFaintFaithFallFalseFameFamilyFamousFanFancyFantasyFarmFashionFatFatalFatherFatigueFaultFavoriteFeatureFebruaryFederalFeeFeedFeelFemaleFenceFestivalFetchFeverFewFiberFictionFieldFigureFileFilmFilterFinalFindFineFingerFinishFireFirmFirstFiscalFishFitFitnessFixFlagFlameFlashFlatFlavorFleeFlightFlipFloatFlockFloorFlowerFluidFlushFlyFoamFocusFogFoilFoldFollowFoodFootForceForestForgetForkFortuneForumForwardFossilFosterFoundFoxFragileFrameFrequentFreshFriendFringeFrogFrontFrostFrownFrozenFruitFuelFunFunnyFurnaceFuryFutureGadgetGainGalaxyGalleryGameGapGarageGarbageGardenGarlicGarmentGasGaspGateGatherGaugeGazeGeneralGeniusGenreGentleGenuineGestureGhostGiantGiftGiggleGingerGiraffeGirlGiveGladGlanceGlareGlassGlideGlimpseGlobeGloomGloryGloveGlowGlueGoatGoddessGoldGoodGooseGorillaGospelGossipGovernGownGrabGraceGrainGrantGrapeGrassGravityGreatGreenGridGriefGritGroceryGroupGrowGruntGuardGuessGuideGuiltGuitarGunGymHabitHairHalfHammerHamsterHandHappyHarborHardHarshHarvestHatHaveHawkHazardHeadHealthHeartHeavyHedgehogHeightHelloHelmetHelpHenHeroHiddenHighHillHintHipHireHistoryHobbyHockeyHoldHoleHolidayHollowHomeHoneyHoodHopeHornHorrorHorseHospitalHostHotelHourHoverHubHugeHumanHumbleHumorHundredHungryHuntHurdleHurryHurtHusbandHybridIceIconIdeaIdentifyIdleIgnoreIllIllegalIllnessImageImitateImmenseImmuneImpactImposeImproveImpulseInchIncludeIncomeIncreaseIndexIndicateIndoorIndustryInfantInflictInformInhaleInheritInitialInjectInjuryInmateInnerInnocentInputInquiryInsaneInsectInsideInspireInstallIntactInterestIntoInvestInviteInvolveIronIslandIsolateIssueItemIvoryJacketJaguarJarJazzJealousJeansJellyJewelJobJoinJokeJourneyJoyJudgeJuiceJumpJungleJuniorJunkJustKangarooKeenKeepKetchupKeyKickKidKidneyKindKingdomKissKitKitchenKiteKittenKiwiKneeKnifeKnockKnowLabLabelLaborLadderLadyLakeLampLanguageLaptopLargeLaterLatinLaughLaundryLavaLawLawnLawsuitLayerLazyLeaderLeafLearnLeaveLectureLeftLegLegalLegendLeisureLemonLendLengthLensLeopardLessonLetterLevelLiarLibertyLibraryLicenseLifeLiftLightLikeLimbLimitLinkLionLiquidListLittleLiveLizardLoadLoanLobsterLocalLockLogicLonelyLongLoopLotteryLoudLoungeLoveLoyalLuckyLuggageLumberLunarLunchLuxuryLyricsMachineMadMagicMagnetMaidMailMainMajorMakeMammalManManageMandateMangoMansionManualMapleMarbleMarchMarginMarineMarketMarriageMaskMassMasterMatchMaterialMathMatrixMatterMaximumMazeMeadowMeanMeasureMeatMechanicMedalMediaMelodyMeltMemberMemoryMentionMenuMercyMergeMeritMerryMeshMessageMetalMethodMiddleMidnightMilkMillionMimicMindMinimumMinorMinuteMiracleMirrorMiseryMissMistakeMixMixedMixtureMobileModelModifyMomMomentMonitorMonkeyMonsterMonthMoonMoralMoreMorningMosquitoMotherMotionMotorMountainMouseMoveMovieMuchMuffinMuleMultiplyMuscleMuseumMushroomMusicMustMutualMyselfMysteryMythNaiveNameNapkinNarrowNastyNationNatureNearNeckNeedNegativeNeglectNeitherNephewNerveNestNetNetworkNeutralNeverNewsNextNiceNightNobleNoiseNomineeNoodleNormalNorthNoseNotableNoteNothingNoticeNovelNowNuclearNumberNurseNutOakObeyObjectObligeObscureObserveObtainObviousOccurOceanOctoberOdorOffOfferOfficeOftenOilOkayOldOliveOlympicOmitOnceOneOnionOnlineOnlyOpenOperaOpinionOpposeOptionOrangeOrbitOrchardOrderOrdinaryOrganOrientOriginalOrphanOstrichOtherOutdoorOuterOutputOutsideOvalOvenOverOwnOwnerOxygenOysterOzonePactPaddlePagePairPalacePalmPandaPanelPanicPantherPaperParadeParentParkParrotPartyPassPatchPathPatientPatrolPatternPausePavePaymentPeacePeanutPearPeasantPelicanPenPenaltyPencilPeoplePepperPerfectPermitPersonPetPhonePhotoPhrasePhysicalPianoPicnicPicturePiecePigPigeonPillPilotPinkPioneerPipePistolPitchPizzaPlacePlanetPlasticPlatePlayPleasePledgePluckPlugPlungePoemPoetPointPolarPolePolicePondPonyPoolPopularPortionPositionPossiblePostPotatoPotteryPovertyPowderPowerPracticePraisePredictPreferPreparePresentPrettyPreventPricePridePrimaryPrintPriorityPrisonPrivatePrizeProblemProcessProduceProfitProgramProjectPromoteProofPropertyProsperProtectProudProvidePublicPuddingPullPulpPulsePumpkinPunchPupilPuppyPurchasePurityPurposePursePushPutPuzzlePyramidQualityQuantumQuarterQuestionQuickQuitQuizQuoteRabbitRaccoonRaceRackRadarRadioRailRainRaiseRallyRampRanchRandomRangeRapidRareRateRatherRavenRawRazorReadyRealReasonRebelRebuildRecallReceiveRecipeRecordRecycleReduceReflectReformRefuseRegionRegretRegularRejectRelaxReleaseReliefRelyRemainRememberRemindRemoveRenderRenewRentReopenRepairRepeatReplaceReportRequireRescueResembleResistResourceResponseResultRetireRetreatReturnReunionRevealReviewRewardRhythmRibRibbonRiceRichRideRidgeRifleRightRigidRingRiotRippleRiskRitualRivalRiverRoadRoastRobotRobustRocketRomanceRoofRookieRoomRoseRotateRoughRoundRouteRoyalRubberRudeRugRuleRunRunwayRuralSadSaddleSadnessSafeSailSaladSalmonSalonSaltSaluteSameSampleSandSatisfySatoshiSauceSausageSaveSayScaleScanScareScatterSceneSchemeSchoolScienceScissorsScorpionScoutScrapScreenScriptScrubSeaSearchSeasonSeatSecondSecretSectionSecuritySeedSeekSegmentSelectSellSeminarSeniorSenseSentenceSeriesServiceSessionSettleSetupSevenShadowShaftShallowShareShedShellSheriffShieldShiftShineShipShiverShockShoeShootShopShortShoulderShoveShrimpShrugShuffleShySiblingSickSideSiegeSightSignSilentSilkSillySilverSimilarSimpleSinceSingSirenSisterSituateSixSizeSkateSketchSkiSkillSkinSkirtSkullSlabSlamSleepSlenderSliceSlideSlightSlimSloganSlotSlowSlushSmallSmartSmileSmokeSmoothSnackSnakeSnapSniffSnowSoapSoccerSocialSockSodaSoftSolarSoldierSolidSolutionSolveSomeoneSongSoonSorrySortSoulSoundSoupSourceSouthSpaceSpareSpatialSpawnSpeakSpecialSpeedSpellSpendSphereSpiceSpiderSpikeSpinSpiritSplitSpoilSponsorSpoonSportSpotSpraySpreadSpringSpySquareSqueezeSquirrelStableStadiumStaffStageStairsStampStandStartStateStaySteakSteelStemStepStereoStickStillStingStockStomachStoneStoolStoryStoveStrategyStreetStrikeStrongStruggleStudentStuffStumbleStyleSubjectSubmitSubwaySuccessSuchSuddenSufferSugarSuggestSuitSummerSunSunnySunsetSuperSupplySupremeSureSurfaceSurgeSurpriseSurroundSurveySuspectSustainSwallowSwampSwapSwarmSwearSweetSwiftSwimSwingSwitchSwordSymbolSymptomSyrupSystemTableTackleTagTailTalentTalkTankTapeTargetTaskTasteTattooTaxiTeachTeamTellTenTenantTennisTentTermTestTextThankThatThemeThenTheoryThereTheyThingThisThoughtThreeThriveThrowThumbThunderTicketTideTigerTiltTimberTimeTinyTipTiredTissueTitleToastTobaccoTodayToddlerToeTogetherToiletTokenTomatoTomorrowToneTongueTonightToolToothTopTopicToppleTorchTornadoTortoiseTossTotalTouristTowardTowerTownToyTrackTradeTrafficTragicTrainTransferTrapTrashTravelTrayTreatTreeTrendTrialTribeTrickTriggerTrimTripTrophyTroubleTruckTrueTrulyTrumpetTrustTruthTryTubeTuitionTumbleTunaTunnelTurkeyTurnTurtleTwelveTwentyTwiceTwinTwistTwoTypeTypicalUglyUmbrellaUnableUnawareUncleUncoverUnderUndoUnfairUnfoldUnhappyUniformUniqueUnitUniverseUnknownUnlockUntilUnusualUnveilUpdateUpgradeUpholdUponUpperUpsetUrbanUrgeUsageUseUsedUsefulUselessUsualUtilityVacantVacuumVagueValidValleyValveVanVanishVaporVariousVastVaultVehicleVelvetVendorVentureVenueVerbVerifyVersionVeryVesselVeteranViableVibrantViciousVictoryVideoViewVillageVintageViolinVirtualVirusVisaVisitVisualVitalVividVocalVoiceVoidVolcanoVolumeVoteVoyageWageWagonWaitWalkWallWalnutWantWarfareWarmWarriorWashWaspWasteWaterWaveWayWealthWeaponWearWeaselWeatherWebWeddingWeekendWeirdWelcomeWestWetWhaleWhatWheatWheelWhenWhereWhipWhisperWideWidthWifeWildWillWinWindowWineWingWinkWinnerWinterWireWisdomWiseWishWitnessWolfWomanWonderWoodWoolWordWorkWorldWorryWorthWrapWreckWrestleWristWriteWrongYardYearYellowYouYoungYouthZebraZeroZoneZoo";
- var wordlist = null;
- function loadWords(lang) {
- if (wordlist != null) {
- return;
- }
- wordlist = words.replace(/([A-Z])/g, " $1").toLowerCase().substring(1).split(" ");
- // Verify the computed list matches the official list
- /* istanbul ignore if */
- if (wordlist_1.Wordlist.check(lang) !== "0x3c8acc1e7b08d8e76f9fda015ef48dc8c710a73cb7e0f77b2c18a9b5a7adde60") {
- wordlist = null;
- throw new Error("BIP39 Wordlist for en (English) FAILED");
- }
- }
- var LangEn = /** @class */ (function (_super) {
- __extends(LangEn, _super);
- function LangEn() {
- return _super.call(this, "en") || this;
- }
- LangEn.prototype.getWord = function (index) {
- loadWords(this);
- return wordlist[index];
- };
- LangEn.prototype.getWordIndex = function (word) {
- loadWords(this);
- return wordlist.indexOf(word);
- };
- return LangEn;
- }(wordlist_1.Wordlist));
- var langEn = new LangEn();
- exports.langEn = langEn;
- wordlist_1.Wordlist.register(langEn);
- },{"./wordlist":287}],281:[function(_dereq_,module,exports){
- "use strict";
- var __extends = (this && this.__extends) || (function () {
- var extendStatics = function (d, b) {
- extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
- return extendStatics(d, b);
- };
- return function (d, b) {
- if (typeof b !== "function" && b !== null)
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.langEs = void 0;
- var strings_1 = _dereq_("@ethersproject/strings");
- var wordlist_1 = _dereq_("./wordlist");
- var words = "A/bacoAbdomenAbejaAbiertoAbogadoAbonoAbortoAbrazoAbrirAbueloAbusoAcabarAcademiaAccesoAccio/nAceiteAcelgaAcentoAceptarA/cidoAclararAcne/AcogerAcosoActivoActoActrizActuarAcudirAcuerdoAcusarAdictoAdmitirAdoptarAdornoAduanaAdultoAe/reoAfectarAficio/nAfinarAfirmarA/gilAgitarAgoni/aAgostoAgotarAgregarAgrioAguaAgudoA/guilaAgujaAhogoAhorroAireAislarAjedrezAjenoAjusteAlacra/nAlambreAlarmaAlbaA/lbumAlcaldeAldeaAlegreAlejarAlertaAletaAlfilerAlgaAlgodo/nAliadoAlientoAlivioAlmaAlmejaAlmi/barAltarAltezaAltivoAltoAlturaAlumnoAlzarAmableAmanteAmapolaAmargoAmasarA/mbarA/mbitoAmenoAmigoAmistadAmorAmparoAmplioAnchoAncianoAnclaAndarAnde/nAnemiaA/nguloAnilloA/nimoAni/sAnotarAntenaAntiguoAntojoAnualAnularAnuncioA~adirA~ejoA~oApagarAparatoApetitoApioAplicarApodoAporteApoyoAprenderAprobarApuestaApuroAradoAra~aArarA/rbitroA/rbolArbustoArchivoArcoArderArdillaArduoA/reaA/ridoAriesArmoni/aArne/sAromaArpaArpo/nArregloArrozArrugaArteArtistaAsaAsadoAsaltoAscensoAsegurarAseoAsesorAsientoAsiloAsistirAsnoAsombroA/speroAstillaAstroAstutoAsumirAsuntoAtajoAtaqueAtarAtentoAteoA/ticoAtletaA/tomoAtraerAtrozAtu/nAudazAudioAugeAulaAumentoAusenteAutorAvalAvanceAvaroAveAvellanaAvenaAvestruzAvio/nAvisoAyerAyudaAyunoAzafra/nAzarAzoteAzu/carAzufreAzulBabaBaborBacheBahi/aBaileBajarBalanzaBalco/nBaldeBambu/BancoBandaBa~oBarbaBarcoBarnizBarroBa/sculaBasto/nBasuraBatallaBateri/aBatirBatutaBau/lBazarBebe/BebidaBelloBesarBesoBestiaBichoBienBingoBlancoBloqueBlusaBoaBobinaBoboBocaBocinaBodaBodegaBoinaBolaBoleroBolsaBombaBondadBonitoBonoBonsa/iBordeBorrarBosqueBoteBoti/nBo/vedaBozalBravoBrazoBrechaBreveBrilloBrincoBrisaBrocaBromaBronceBroteBrujaBruscoBrutoBuceoBucleBuenoBueyBufandaBufo/nBu/hoBuitreBultoBurbujaBurlaBurroBuscarButacaBuzo/nCaballoCabezaCabinaCabraCacaoCada/verCadenaCaerCafe/Cai/daCaima/nCajaCajo/nCalCalamarCalcioCaldoCalidadCalleCalmaCalorCalvoCamaCambioCamelloCaminoCampoCa/ncerCandilCanelaCanguroCanicaCantoCa~aCa~o/nCaobaCaosCapazCapita/nCapoteCaptarCapuchaCaraCarbo/nCa/rcelCaretaCargaCari~oCarneCarpetaCarroCartaCasaCascoCaseroCaspaCastorCatorceCatreCaudalCausaCazoCebollaCederCedroCeldaCe/lebreCelosoCe/lulaCementoCenizaCentroCercaCerdoCerezaCeroCerrarCertezaCe/spedCetroChacalChalecoChampu/ChanclaChapaCharlaChicoChisteChivoChoqueChozaChuletaChuparCiclo/nCiegoCieloCienCiertoCifraCigarroCimaCincoCineCintaCipre/sCircoCiruelaCisneCitaCiudadClamorClanClaroClaseClaveClienteClimaCli/nicaCobreCoccio/nCochinoCocinaCocoCo/digoCodoCofreCogerCoheteCoji/nCojoColaColchaColegioColgarColinaCollarColmoColumnaCombateComerComidaCo/modoCompraCondeConejoCongaConocerConsejoContarCopaCopiaCorazo/nCorbataCorchoCordo/nCoronaCorrerCoserCosmosCostaCra/neoCra/terCrearCrecerCrei/doCremaCri/aCrimenCriptaCrisisCromoCro/nicaCroquetaCrudoCruzCuadroCuartoCuatroCuboCubrirCucharaCuelloCuentoCuerdaCuestaCuevaCuidarCulebraCulpaCultoCumbreCumplirCunaCunetaCuotaCupo/nCu/pulaCurarCuriosoCursoCurvaCutisDamaDanzaDarDardoDa/tilDeberDe/bilDe/cadaDecirDedoDefensaDefinirDejarDelfi/nDelgadoDelitoDemoraDensoDentalDeporteDerechoDerrotaDesayunoDeseoDesfileDesnudoDestinoDesvi/oDetalleDetenerDeudaDi/aDiabloDiademaDiamanteDianaDiarioDibujoDictarDienteDietaDiezDifi/cilDignoDilemaDiluirDineroDirectoDirigirDiscoDise~oDisfrazDivaDivinoDobleDoceDolorDomingoDonDonarDoradoDormirDorsoDosDosisDrago/nDrogaDuchaDudaDueloDue~oDulceDu/oDuqueDurarDurezaDuroE/banoEbrioEcharEcoEcuadorEdadEdicio/nEdificioEditorEducarEfectoEficazEjeEjemploElefanteElegirElementoElevarElipseE/liteElixirElogioEludirEmbudoEmitirEmocio/nEmpateEmpe~oEmpleoEmpresaEnanoEncargoEnchufeEnci/aEnemigoEneroEnfadoEnfermoEnga~oEnigmaEnlaceEnormeEnredoEnsayoEnse~arEnteroEntrarEnvaseEnvi/oE/pocaEquipoErizoEscalaEscenaEscolarEscribirEscudoEsenciaEsferaEsfuerzoEspadaEspejoEspi/aEsposaEspumaEsqui/EstarEsteEstiloEstufaEtapaEternoE/ticaEtniaEvadirEvaluarEventoEvitarExactoExamenExcesoExcusaExentoExigirExilioExistirE/xitoExpertoExplicarExponerExtremoFa/bricaFa/bulaFachadaFa/cilFactorFaenaFajaFaldaFalloFalsoFaltarFamaFamiliaFamosoFarao/nFarmaciaFarolFarsaFaseFatigaFaunaFavorFaxFebreroFechaFelizFeoFeriaFerozFe/rtilFervorFesti/nFiableFianzaFiarFibraFiccio/nFichaFideoFiebreFielFieraFiestaFiguraFijarFijoFilaFileteFilialFiltroFinFincaFingirFinitoFirmaFlacoFlautaFlechaFlorFlotaFluirFlujoFlu/orFobiaFocaFogataFogo/nFolioFolletoFondoFormaForroFortunaForzarFosaFotoFracasoFra/gilFranjaFraseFraudeFrei/rFrenoFresaFri/oFritoFrutaFuegoFuenteFuerzaFugaFumarFuncio/nFundaFurgo/nFuriaFusilFu/tbolFuturoGacelaGafasGaitaGajoGalaGaleri/aGalloGambaGanarGanchoGangaGansoGarajeGarzaGasolinaGastarGatoGavila/nGemeloGemirGenGe/neroGenioGenteGeranioGerenteGermenGestoGiganteGimnasioGirarGiroGlaciarGloboGloriaGolGolfoGolosoGolpeGomaGordoGorilaGorraGotaGoteoGozarGradaGra/ficoGranoGrasaGratisGraveGrietaGrilloGripeGrisGritoGrosorGru/aGruesoGrumoGrupoGuanteGuapoGuardiaGuerraGui/aGui~oGuionGuisoGuitarraGusanoGustarHaberHa/bilHablarHacerHachaHadaHallarHamacaHarinaHazHaza~aHebillaHebraHechoHeladoHelioHembraHerirHermanoHe/roeHervirHieloHierroHi/gadoHigieneHijoHimnoHistoriaHocicoHogarHogueraHojaHombreHongoHonorHonraHoraHormigaHornoHostilHoyoHuecoHuelgaHuertaHuesoHuevoHuidaHuirHumanoHu/medoHumildeHumoHundirHuraca/nHurtoIconoIdealIdiomaI/doloIglesiaIglu/IgualIlegalIlusio/nImagenIma/nImitarImparImperioImponerImpulsoIncapazI/ndiceInerteInfielInformeIngenioInicioInmensoInmuneInnatoInsectoInstanteIntere/sI/ntimoIntuirInu/tilInviernoIraIrisIroni/aIslaIsloteJabali/Jabo/nJamo/nJarabeJardi/nJarraJaulaJazmi/nJefeJeringaJineteJornadaJorobaJovenJoyaJuergaJuevesJuezJugadorJugoJugueteJuicioJuncoJunglaJunioJuntarJu/piterJurarJustoJuvenilJuzgarKiloKoalaLabioLacioLacraLadoLadro/nLagartoLa/grimaLagunaLaicoLamerLa/minaLa/mparaLanaLanchaLangostaLanzaLa/pizLargoLarvaLa/stimaLataLa/texLatirLaurelLavarLazoLealLeccio/nLecheLectorLeerLegio/nLegumbreLejanoLenguaLentoLe~aLeo/nLeopardoLesio/nLetalLetraLeveLeyendaLibertadLibroLicorLi/derLidiarLienzoLigaLigeroLimaLi/miteLimo/nLimpioLinceLindoLi/neaLingoteLinoLinternaLi/quidoLisoListaLiteraLitioLitroLlagaLlamaLlantoLlaveLlegarLlenarLlevarLlorarLloverLluviaLoboLocio/nLocoLocuraLo/gicaLogroLombrizLomoLonjaLoteLuchaLucirLugarLujoLunaLunesLupaLustroLutoLuzMacetaMachoMaderaMadreMaduroMaestroMafiaMagiaMagoMai/zMaldadMaletaMallaMaloMama/MamboMamutMancoMandoManejarMangaManiqui/ManjarManoMansoMantaMa~anaMapaMa/quinaMarMarcoMareaMarfilMargenMaridoMa/rmolMarro/nMartesMarzoMasaMa/scaraMasivoMatarMateriaMatizMatrizMa/ximoMayorMazorcaMechaMedallaMedioMe/dulaMejillaMejorMelenaMelo/nMemoriaMenorMensajeMenteMenu/MercadoMerengueMe/ritoMesMeso/nMetaMeterMe/todoMetroMezclaMiedoMielMiembroMigaMilMilagroMilitarMillo/nMimoMinaMineroMi/nimoMinutoMiopeMirarMisaMiseriaMisilMismoMitadMitoMochilaMocio/nModaModeloMohoMojarMoldeMolerMolinoMomentoMomiaMonarcaMonedaMonjaMontoMo~oMoradaMorderMorenoMorirMorroMorsaMortalMoscaMostrarMotivoMoverMo/vilMozoMuchoMudarMuebleMuelaMuerteMuestraMugreMujerMulaMuletaMultaMundoMu~ecaMuralMuroMu/sculoMuseoMusgoMu/sicaMusloNa/carNacio/nNadarNaipeNaranjaNarizNarrarNasalNatalNativoNaturalNa/useaNavalNaveNavidadNecioNe/ctarNegarNegocioNegroNeo/nNervioNetoNeutroNevarNeveraNichoNidoNieblaNietoNi~ezNi~oNi/tidoNivelNoblezaNocheNo/minaNoriaNormaNorteNotaNoticiaNovatoNovelaNovioNubeNucaNu/cleoNudilloNudoNueraNueveNuezNuloNu/meroNutriaOasisObesoObispoObjetoObraObreroObservarObtenerObvioOcaOcasoOce/anoOchentaOchoOcioOcreOctavoOctubreOcultoOcuparOcurrirOdiarOdioOdiseaOesteOfensaOfertaOficioOfrecerOgroOi/doOi/rOjoOlaOleadaOlfatoOlivoOllaOlmoOlorOlvidoOmbligoOndaOnzaOpacoOpcio/nO/peraOpinarOponerOptarO/pticaOpuestoOracio/nOradorOralO/rbitaOrcaOrdenOrejaO/rganoOrgi/aOrgulloOrienteOrigenOrillaOroOrquestaOrugaOsadi/aOscuroOseznoOsoOstraOto~oOtroOvejaO/vuloO/xidoOxi/genoOyenteOzonoPactoPadrePaellaPa/ginaPagoPai/sPa/jaroPalabraPalcoPaletaPa/lidoPalmaPalomaPalparPanPanalPa/nicoPanteraPa~ueloPapa/PapelPapillaPaquetePararParcelaParedParirParoPa/rpadoParquePa/rrafoPartePasarPaseoPasio/nPasoPastaPataPatioPatriaPausaPautaPavoPayasoPeato/nPecadoPeceraPechoPedalPedirPegarPeinePelarPelda~oPeleaPeligroPellejoPeloPelucaPenaPensarPe~o/nPeo/nPeorPepinoPeque~oPeraPerchaPerderPerezaPerfilPericoPerlaPermisoPerroPersonaPesaPescaPe/simoPesta~aPe/taloPetro/leoPezPezu~aPicarPicho/nPiePiedraPiernaPiezaPijamaPilarPilotoPimientaPinoPintorPinzaPi~aPiojoPipaPirataPisarPiscinaPisoPistaPito/nPizcaPlacaPlanPlataPlayaPlazaPleitoPlenoPlomoPlumaPluralPobrePocoPoderPodioPoemaPoesi/aPoetaPolenPolici/aPolloPolvoPomadaPomeloPomoPompaPonerPorcio/nPortalPosadaPoseerPosiblePostePotenciaPotroPozoPradoPrecozPreguntaPremioPrensaPresoPrevioPrimoPri/ncipePrisio/nPrivarProaProbarProcesoProductoProezaProfesorProgramaProlePromesaProntoPropioPro/ximoPruebaPu/blicoPucheroPudorPuebloPuertaPuestoPulgaPulirPulmo/nPulpoPulsoPumaPuntoPu~alPu~oPupaPupilaPure/QuedarQuejaQuemarQuererQuesoQuietoQui/micaQuinceQuitarRa/banoRabiaRaboRacio/nRadicalRai/zRamaRampaRanchoRangoRapazRa/pidoRaptoRasgoRaspaRatoRayoRazaRazo/nReaccio/nRealidadReba~oReboteRecaerRecetaRechazoRecogerRecreoRectoRecursoRedRedondoReducirReflejoReformaRefra/nRefugioRegaloRegirReglaRegresoRehe/nReinoRei/rRejaRelatoRelevoRelieveRellenoRelojRemarRemedioRemoRencorRendirRentaRepartoRepetirReposoReptilResRescateResinaRespetoRestoResumenRetiroRetornoRetratoReunirReve/sRevistaReyRezarRicoRiegoRiendaRiesgoRifaRi/gidoRigorRinco/nRi~o/nRi/oRiquezaRisaRitmoRitoRizoRobleRoceRociarRodarRodeoRodillaRoerRojizoRojoRomeroRomperRonRoncoRondaRopaRoperoRosaRoscaRostroRotarRubi/RuborRudoRuedaRugirRuidoRuinaRuletaRuloRumboRumorRupturaRutaRutinaSa/badoSaberSabioSableSacarSagazSagradoSalaSaldoSaleroSalirSalmo/nSalo/nSalsaSaltoSaludSalvarSambaSancio/nSandi/aSanearSangreSanidadSanoSantoSapoSaqueSardinaSarte/nSastreSata/nSaunaSaxofo/nSeccio/nSecoSecretoSectaSedSeguirSeisSelloSelvaSemanaSemillaSendaSensorSe~alSe~orSepararSepiaSequi/aSerSerieSermo/nServirSesentaSesio/nSetaSetentaSeveroSexoSextoSidraSiestaSieteSigloSignoSi/labaSilbarSilencioSillaSi/mboloSimioSirenaSistemaSitioSituarSobreSocioSodioSolSolapaSoldadoSoledadSo/lidoSoltarSolucio/nSombraSondeoSonidoSonoroSonrisaSopaSoplarSoporteSordoSorpresaSorteoSoste/nSo/tanoSuaveSubirSucesoSudorSuegraSueloSue~oSuerteSufrirSujetoSulta/nSumarSuperarSuplirSuponerSupremoSurSurcoSure~oSurgirSustoSutilTabacoTabiqueTablaTabu/TacoTactoTajoTalarTalcoTalentoTallaTalo/nTama~oTamborTangoTanqueTapaTapeteTapiaTapo/nTaquillaTardeTareaTarifaTarjetaTarotTarroTartaTatuajeTauroTazaTazo/nTeatroTechoTeclaTe/cnicaTejadoTejerTejidoTelaTele/fonoTemaTemorTemploTenazTenderTenerTenisTensoTeori/aTerapiaTercoTe/rminoTernuraTerrorTesisTesoroTestigoTeteraTextoTezTibioTiburo/nTiempoTiendaTierraTiesoTigreTijeraTildeTimbreTi/midoTimoTintaTi/oTi/picoTipoTiraTiro/nTita/nTi/tereTi/tuloTizaToallaTobilloTocarTocinoTodoTogaToldoTomarTonoTontoToparTopeToqueTo/raxToreroTormentaTorneoToroTorpedoTorreTorsoTortugaTosToscoToserTo/xicoTrabajoTractorTraerTra/ficoTragoTrajeTramoTranceTratoTraumaTrazarTre/bolTreguaTreintaTrenTreparTresTribuTrigoTripaTristeTriunfoTrofeoTrompaTroncoTropaTroteTrozoTrucoTruenoTrufaTuberi/aTuboTuertoTumbaTumorTu/nelTu/nicaTurbinaTurismoTurnoTutorUbicarU/lceraUmbralUnidadUnirUniversoUnoUntarU~aUrbanoUrbeUrgenteUrnaUsarUsuarioU/tilUtopi/aUvaVacaVaci/oVacunaVagarVagoVainaVajillaValeVa/lidoValleValorVa/lvulaVampiroVaraVariarVaro/nVasoVecinoVectorVehi/culoVeinteVejezVelaVeleroVelozVenaVencerVendaVenenoVengarVenirVentaVenusVerVeranoVerboVerdeVeredaVerjaVersoVerterVi/aViajeVibrarVicioVi/ctimaVidaVi/deoVidrioViejoViernesVigorVilVillaVinagreVinoVi~edoVioli/nViralVirgoVirtudVisorVi/speraVistaVitaminaViudoVivazViveroVivirVivoVolca/nVolumenVolverVorazVotarVotoVozVueloVulgarYacerYateYeguaYemaYernoYesoYodoYogaYogurZafiroZanjaZapatoZarzaZonaZorroZumoZurdo";
- var lookup = {};
- var wordlist = null;
- function dropDiacritic(word) {
- wordlist_1.logger.checkNormalize();
- return (0, strings_1.toUtf8String)(Array.prototype.filter.call((0, strings_1.toUtf8Bytes)(word.normalize("NFD").toLowerCase()), function (c) {
- return ((c >= 65 && c <= 90) || (c >= 97 && c <= 123));
- }));
- }
- function expand(word) {
- var output = [];
- Array.prototype.forEach.call((0, strings_1.toUtf8Bytes)(word), function (c) {
- // Acute accent
- if (c === 47) {
- output.push(204);
- output.push(129);
- // n-tilde
- }
- else if (c === 126) {
- output.push(110);
- output.push(204);
- output.push(131);
- }
- else {
- output.push(c);
- }
- });
- return (0, strings_1.toUtf8String)(output);
- }
- function loadWords(lang) {
- if (wordlist != null) {
- return;
- }
- wordlist = words.replace(/([A-Z])/g, " $1").toLowerCase().substring(1).split(" ").map(function (w) { return expand(w); });
- wordlist.forEach(function (word, index) {
- lookup[dropDiacritic(word)] = index;
- });
- // Verify the computed list matches the official list
- /* istanbul ignore if */
- if (wordlist_1.Wordlist.check(lang) !== "0xf74fb7092aeacdfbf8959557de22098da512207fb9f109cb526994938cf40300") {
- wordlist = null;
- throw new Error("BIP39 Wordlist for es (Spanish) FAILED");
- }
- }
- var LangEs = /** @class */ (function (_super) {
- __extends(LangEs, _super);
- function LangEs() {
- return _super.call(this, "es") || this;
- }
- LangEs.prototype.getWord = function (index) {
- loadWords(this);
- return wordlist[index];
- };
- LangEs.prototype.getWordIndex = function (word) {
- loadWords(this);
- return lookup[dropDiacritic(word)];
- };
- return LangEs;
- }(wordlist_1.Wordlist));
- var langEs = new LangEs();
- exports.langEs = langEs;
- wordlist_1.Wordlist.register(langEs);
- },{"./wordlist":287,"@ethersproject/strings":266}],282:[function(_dereq_,module,exports){
- "use strict";
- var __extends = (this && this.__extends) || (function () {
- var extendStatics = function (d, b) {
- extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
- return extendStatics(d, b);
- };
- return function (d, b) {
- if (typeof b !== "function" && b !== null)
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.langFr = void 0;
- var strings_1 = _dereq_("@ethersproject/strings");
- var wordlist_1 = _dereq_("./wordlist");
- var words = "AbaisserAbandonAbdiquerAbeilleAbolirAborderAboutirAboyerAbrasifAbreuverAbriterAbrogerAbruptAbsenceAbsoluAbsurdeAbusifAbyssalAcade/mieAcajouAcarienAccablerAccepterAcclamerAccoladeAccrocheAccuserAcerbeAchatAcheterAcidulerAcierAcompteAcque/rirAcronymeActeurActifActuelAdepteAde/quatAdhe/sifAdjectifAdjugerAdmettreAdmirerAdopterAdorerAdoucirAdresseAdroitAdulteAdverbeAe/rerAe/ronefAffaireAffecterAfficheAffreuxAffublerAgacerAgencerAgileAgiterAgraferAgre/ableAgrumeAiderAiguilleAilierAimableAisanceAjouterAjusterAlarmerAlchimieAlerteAlge-breAlgueAlie/nerAlimentAlle/gerAlliageAllouerAllumerAlourdirAlpagaAltesseAlve/oleAmateurAmbiguAmbreAme/nagerAmertumeAmidonAmiralAmorcerAmourAmovibleAmphibieAmpleurAmusantAnalyseAnaphoreAnarchieAnatomieAncienAne/antirAngleAngoisseAnguleuxAnimalAnnexerAnnonceAnnuelAnodinAnomalieAnonymeAnormalAntenneAntidoteAnxieuxApaiserApe/ritifAplanirApologieAppareilAppelerApporterAppuyerAquariumAqueducArbitreArbusteArdeurArdoiseArgentArlequinArmatureArmementArmoireArmureArpenterArracherArriverArroserArsenicArte/rielArticleAspectAsphalteAspirerAssautAsservirAssietteAssocierAssurerAsticotAstreAstuceAtelierAtomeAtriumAtroceAttaqueAttentifAttirerAttraperAubaineAubergeAudaceAudibleAugurerAuroreAutomneAutrucheAvalerAvancerAvariceAvenirAverseAveugleAviateurAvideAvionAviserAvoineAvouerAvrilAxialAxiomeBadgeBafouerBagageBaguetteBaignadeBalancerBalconBaleineBalisageBambinBancaireBandageBanlieueBannie-reBanquierBarbierBarilBaronBarqueBarrageBassinBastionBatailleBateauBatterieBaudrierBavarderBeletteBe/lierBeloteBe/ne/ficeBerceauBergerBerlineBermudaBesaceBesogneBe/tailBeurreBiberonBicycleBiduleBijouBilanBilingueBillardBinaireBiologieBiopsieBiotypeBiscuitBisonBistouriBitumeBizarreBlafardBlagueBlanchirBlessantBlinderBlondBloquerBlousonBobardBobineBoireBoiserBolideBonbonBondirBonheurBonifierBonusBordureBorneBotteBoucleBoueuxBougieBoulonBouquinBourseBoussoleBoutiqueBoxeurBrancheBrasierBraveBrebisBre-cheBreuvageBricolerBrigadeBrillantBriocheBriqueBrochureBroderBronzerBrousseBroyeurBrumeBrusqueBrutalBruyantBuffleBuissonBulletinBureauBurinBustierButinerButoirBuvableBuvetteCabanonCabineCachetteCadeauCadreCafe/ineCaillouCaissonCalculerCalepinCalibreCalmerCalomnieCalvaireCamaradeCame/raCamionCampagneCanalCanetonCanonCantineCanularCapableCaporalCapriceCapsuleCapterCapucheCarabineCarboneCaresserCaribouCarnageCarotteCarreauCartonCascadeCasierCasqueCassureCauserCautionCavalierCaverneCaviarCe/dilleCeintureCe/lesteCelluleCendrierCensurerCentralCercleCe/re/bralCeriseCernerCerveauCesserChagrinChaiseChaleurChambreChanceChapitreCharbonChasseurChatonChaussonChavirerChemiseChenilleChe/quierChercherChevalChienChiffreChignonChime-reChiotChlorureChocolatChoisirChoseChouetteChromeChuteCigareCigogneCimenterCine/maCintrerCirculerCirerCirqueCiterneCitoyenCitronCivilClaironClameurClaquerClasseClavierClientClignerClimatClivageClocheClonageCloporteCobaltCobraCocasseCocotierCoderCodifierCoffreCognerCohe/sionCoifferCoincerCole-reColibriCollineColmaterColonelCombatCome/dieCommandeCompactConcertConduireConfierCongelerConnoterConsonneContactConvexeCopainCopieCorailCorbeauCordageCornicheCorpusCorrectCorte-geCosmiqueCostumeCotonCoudeCoupureCourageCouteauCouvrirCoyoteCrabeCrainteCravateCrayonCre/atureCre/diterCre/meuxCreuserCrevetteCriblerCrierCristalCrite-reCroireCroquerCrotaleCrucialCruelCrypterCubiqueCueillirCuille-reCuisineCuivreCulminerCultiverCumulerCupideCuratifCurseurCyanureCycleCylindreCyniqueDaignerDamierDangerDanseurDauphinDe/battreDe/biterDe/borderDe/briderDe/butantDe/calerDe/cembreDe/chirerDe/ciderDe/clarerDe/corerDe/crireDe/cuplerDe/daleDe/ductifDe/esseDe/fensifDe/filerDe/frayerDe/gagerDe/givrerDe/glutirDe/graferDe/jeunerDe/liceDe/logerDemanderDemeurerDe/molirDe/nicherDe/nouerDentelleDe/nuderDe/partDe/penserDe/phaserDe/placerDe/poserDe/rangerDe/roberDe/sastreDescenteDe/sertDe/signerDe/sobe/irDessinerDestrierDe/tacherDe/testerDe/tourerDe/tresseDevancerDevenirDevinerDevoirDiableDialogueDiamantDicterDiffe/rerDige/rerDigitalDigneDiluerDimancheDiminuerDioxydeDirectifDirigerDiscuterDisposerDissiperDistanceDivertirDiviserDocileDocteurDogmeDoigtDomaineDomicileDompterDonateurDonjonDonnerDopamineDortoirDorureDosageDoseurDossierDotationDouanierDoubleDouceurDouterDoyenDragonDraperDresserDribblerDroitureDuperieDuplexeDurableDurcirDynastieE/blouirE/carterE/charpeE/chelleE/clairerE/clipseE/cloreE/cluseE/coleE/conomieE/corceE/couterE/craserE/cre/merE/crivainE/crouE/cumeE/cureuilE/difierE/duquerEffacerEffectifEffigieEffortEffrayerEffusionE/galiserE/garerE/jecterE/laborerE/largirE/lectronE/le/gantE/le/phantE/le-veE/ligibleE/litismeE/logeE/luciderE/luderEmballerEmbellirEmbryonE/meraudeE/missionEmmenerE/motionE/mouvoirEmpereurEmployerEmporterEmpriseE/mulsionEncadrerEnche-reEnclaveEncocheEndiguerEndosserEndroitEnduireE/nergieEnfanceEnfermerEnfouirEngagerEnginEngloberE/nigmeEnjamberEnjeuEnleverEnnemiEnnuyeuxEnrichirEnrobageEnseigneEntasserEntendreEntierEntourerEntraverE/nume/rerEnvahirEnviableEnvoyerEnzymeE/olienE/paissirE/pargneE/patantE/pauleE/picerieE/pide/mieE/pierE/pilogueE/pineE/pisodeE/pitapheE/poqueE/preuveE/prouverE/puisantE/querreE/quipeE/rigerE/rosionErreurE/ruptionEscalierEspadonEspe-ceEspie-gleEspoirEspritEsquiverEssayerEssenceEssieuEssorerEstimeEstomacEstradeE/tage-reE/talerE/tancheE/tatiqueE/teindreE/tendoirE/ternelE/thanolE/thiqueEthnieE/tirerE/tofferE/toileE/tonnantE/tourdirE/trangeE/troitE/tudeEuphorieE/valuerE/vasionE/ventailE/videnceE/viterE/volutifE/voquerExactExage/rerExaucerExcellerExcitantExclusifExcuseExe/cuterExempleExercerExhalerExhorterExigenceExilerExisterExotiqueExpe/dierExplorerExposerExprimerExquisExtensifExtraireExulterFableFabuleuxFacetteFacileFactureFaiblirFalaiseFameuxFamilleFarceurFarfeluFarineFaroucheFascinerFatalFatigueFauconFautifFaveurFavoriFe/brileFe/conderFe/de/rerFe/linFemmeFe/murFendoirFe/odalFermerFe/roceFerveurFestivalFeuilleFeutreFe/vrierFiascoFicelerFictifFide-leFigureFilatureFiletageFilie-reFilleulFilmerFilouFiltrerFinancerFinirFioleFirmeFissureFixerFlairerFlammeFlasqueFlatteurFle/auFle-cheFleurFlexionFloconFloreFluctuerFluideFluvialFolieFonderieFongibleFontaineForcerForgeronFormulerFortuneFossileFoudreFouge-reFouillerFoulureFourmiFragileFraiseFranchirFrapperFrayeurFre/gateFreinerFrelonFre/mirFre/ne/sieFre-reFriableFrictionFrissonFrivoleFroidFromageFrontalFrotterFruitFugitifFuiteFureurFurieuxFurtifFusionFuturGagnerGalaxieGalerieGambaderGarantirGardienGarnirGarrigueGazelleGazonGe/antGe/latineGe/luleGendarmeGe/ne/ralGe/nieGenouGentilGe/ologieGe/ome-treGe/raniumGermeGestuelGeyserGibierGiclerGirafeGivreGlaceGlaiveGlisserGlobeGloireGlorieuxGolfeurGommeGonflerGorgeGorilleGoudronGouffreGoulotGoupilleGourmandGoutteGraduelGraffitiGraineGrandGrappinGratuitGravirGrenatGriffureGrillerGrimperGrognerGronderGrotteGroupeGrugerGrutierGruye-reGue/pardGuerrierGuideGuimauveGuitareGustatifGymnasteGyrostatHabitudeHachoirHalteHameauHangarHannetonHaricotHarmonieHarponHasardHe/liumHe/matomeHerbeHe/rissonHermineHe/ronHe/siterHeureuxHibernerHibouHilarantHistoireHiverHomardHommageHomoge-neHonneurHonorerHonteuxHordeHorizonHorlogeHormoneHorribleHouleuxHousseHublotHuileuxHumainHumbleHumideHumourHurlerHydromelHygie-neHymneHypnoseIdylleIgnorerIguaneIlliciteIllusionImageImbiberImiterImmenseImmobileImmuableImpactImpe/rialImplorerImposerImprimerImputerIncarnerIncendieIncidentInclinerIncoloreIndexerIndiceInductifIne/ditIneptieInexactInfiniInfligerInformerInfusionInge/rerInhalerInhiberInjecterInjureInnocentInoculerInonderInscrireInsecteInsigneInsoliteInspirerInstinctInsulterIntactIntenseIntimeIntrigueIntuitifInutileInvasionInventerInviterInvoquerIroniqueIrradierIrre/elIrriterIsolerIvoireIvresseJaguarJaillirJambeJanvierJardinJaugerJauneJavelotJetableJetonJeudiJeunesseJoindreJoncherJonglerJoueurJouissifJournalJovialJoyauJoyeuxJubilerJugementJuniorJuponJuristeJusticeJuteuxJuve/nileKayakKimonoKiosqueLabelLabialLabourerLace/rerLactoseLaguneLaineLaisserLaitierLambeauLamelleLampeLanceurLangageLanterneLapinLargeurLarmeLaurierLavaboLavoirLectureLe/galLe/gerLe/gumeLessiveLettreLevierLexiqueLe/zardLiasseLibe/rerLibreLicenceLicorneLie-geLie-vreLigatureLigoterLigueLimerLimiteLimonadeLimpideLine/aireLingotLionceauLiquideLisie-reListerLithiumLitigeLittoralLivreurLogiqueLointainLoisirLombricLoterieLouerLourdLoutreLouveLoyalLubieLucideLucratifLueurLugubreLuisantLumie-reLunaireLundiLuronLutterLuxueuxMachineMagasinMagentaMagiqueMaigreMaillonMaintienMairieMaisonMajorerMalaxerMale/ficeMalheurMaliceMalletteMammouthMandaterManiableManquantManteauManuelMarathonMarbreMarchandMardiMaritimeMarqueurMarronMartelerMascotteMassifMate/rielMatie-reMatraqueMaudireMaussadeMauveMaximalMe/chantMe/connuMe/dailleMe/decinMe/diterMe/duseMeilleurMe/langeMe/lodieMembreMe/moireMenacerMenerMenhirMensongeMentorMercrediMe/riteMerleMessagerMesureMe/talMe/te/oreMe/thodeMe/tierMeubleMiaulerMicrobeMietteMignonMigrerMilieuMillionMimiqueMinceMine/ralMinimalMinorerMinuteMiracleMiroiterMissileMixteMobileModerneMoelleuxMondialMoniteurMonnaieMonotoneMonstreMontagneMonumentMoqueurMorceauMorsureMortierMoteurMotifMoucheMoufleMoulinMoussonMoutonMouvantMultipleMunitionMurailleMure-neMurmureMuscleMuse/umMusicienMutationMuterMutuelMyriadeMyrtilleMyste-reMythiqueNageurNappeNarquoisNarrerNatationNationNatureNaufrageNautiqueNavireNe/buleuxNectarNe/fasteNe/gationNe/gligerNe/gocierNeigeNerveuxNettoyerNeuroneNeutronNeveuNicheNickelNitrateNiveauNobleNocifNocturneNoirceurNoisetteNomadeNombreuxNommerNormatifNotableNotifierNotoireNourrirNouveauNovateurNovembreNoviceNuageNuancerNuireNuisibleNume/roNuptialNuqueNutritifObe/irObjectifObligerObscurObserverObstacleObtenirObturerOccasionOccuperOce/anOctobreOctroyerOctuplerOculaireOdeurOdorantOffenserOfficierOffrirOgiveOiseauOisillonOlfactifOlivierOmbrageOmettreOnctueuxOndulerOne/reuxOniriqueOpaleOpaqueOpe/rerOpinionOpportunOpprimerOpterOptiqueOrageuxOrangeOrbiteOrdonnerOreilleOrganeOrgueilOrificeOrnementOrqueOrtieOscillerOsmoseOssatureOtarieOuraganOursonOutilOutragerOuvrageOvationOxydeOxyge-neOzonePaisiblePalacePalmare-sPalourdePalperPanachePandaPangolinPaniquerPanneauPanoramaPantalonPapayePapierPapoterPapyrusParadoxeParcelleParesseParfumerParlerParoleParrainParsemerPartagerParureParvenirPassionPaste-quePaternelPatiencePatronPavillonPavoiserPayerPaysagePeignePeintrePelagePe/licanPellePelousePeluchePendulePe/ne/trerPe/niblePensifPe/nuriePe/pitePe/plumPerdrixPerforerPe/riodePermuterPerplexePersilPertePeserPe/talePetitPe/trirPeuplePharaonPhobiePhoquePhotonPhrasePhysiquePianoPicturalPie-cePierrePieuvrePilotePinceauPipettePiquerPiroguePiscinePistonPivoterPixelPizzaPlacardPlafondPlaisirPlanerPlaquePlastronPlateauPleurerPlexusPliagePlombPlongerPluiePlumagePochettePoe/siePoe-tePointePoirierPoissonPoivrePolairePolicierPollenPolygonePommadePompierPonctuelPonde/rerPoneyPortiquePositionPosse/derPosturePotagerPoteauPotionPoucePoulainPoumonPourprePoussinPouvoirPrairiePratiquePre/cieuxPre/direPre/fixePre/ludePre/nomPre/sencePre/textePre/voirPrimitifPrincePrisonPriverProble-meProce/derProdigeProfondProgre-sProieProjeterProloguePromenerPropreProspe-reProte/gerProuesseProverbePrudencePruneauPsychosePublicPuceronPuiserPulpePulsarPunaisePunitifPupitrePurifierPuzzlePyramideQuasarQuerelleQuestionQuie/tudeQuitterQuotientRacineRaconterRadieuxRagondinRaideurRaisinRalentirRallongeRamasserRapideRasageRatisserRavagerRavinRayonnerRe/actifRe/agirRe/aliserRe/animerRecevoirRe/citerRe/clamerRe/colterRecruterReculerRecyclerRe/digerRedouterRefaireRe/flexeRe/formerRefrainRefugeRe/galienRe/gionRe/glageRe/gulierRe/ite/rerRejeterRejouerRelatifReleverReliefRemarqueReme-deRemiseRemonterRemplirRemuerRenardRenfortReniflerRenoncerRentrerRenvoiReplierReporterRepriseReptileRequinRe/serveRe/sineuxRe/soudreRespectResterRe/sultatRe/tablirRetenirRe/ticuleRetomberRetracerRe/unionRe/ussirRevancheRevivreRe/volteRe/vulsifRichesseRideauRieurRigideRigolerRincerRiposterRisibleRisqueRituelRivalRivie-reRocheuxRomanceRompreRonceRondinRoseauRosierRotatifRotorRotuleRougeRouilleRouleauRoutineRoyaumeRubanRubisRucheRuelleRugueuxRuinerRuisseauRuserRustiqueRythmeSablerSaboterSabreSacocheSafariSagesseSaisirSaladeSaliveSalonSaluerSamediSanctionSanglierSarcasmeSardineSaturerSaugrenuSaumonSauterSauvageSavantSavonnerScalpelScandaleSce/le/ratSce/narioSceptreSche/maScienceScinderScoreScrutinSculpterSe/anceSe/cableSe/cherSecouerSe/cre/terSe/datifSe/duireSeigneurSe/jourSe/lectifSemaineSemblerSemenceSe/minalSe/nateurSensibleSentenceSe/parerSe/quenceSereinSergentSe/rieuxSerrureSe/rumServiceSe/sameSe/virSevrageSextupleSide/ralSie-cleSie/gerSifflerSigleSignalSilenceSiliciumSimpleSince-reSinistreSiphonSiropSismiqueSituerSkierSocialSocleSodiumSoigneuxSoldatSoleilSolitudeSolubleSombreSommeilSomnolerSondeSongeurSonnetteSonoreSorcierSortirSosieSottiseSoucieuxSoudureSouffleSouleverSoupapeSourceSoutirerSouvenirSpacieuxSpatialSpe/cialSphe-reSpiralStableStationSternumStimulusStipulerStrictStudieuxStupeurStylisteSublimeSubstratSubtilSubvenirSucce-sSucreSuffixeSugge/rerSuiveurSulfateSuperbeSupplierSurfaceSuricateSurmenerSurpriseSursautSurvieSuspectSyllabeSymboleSyme/trieSynapseSyntaxeSyste-meTabacTablierTactileTaillerTalentTalismanTalonnerTambourTamiserTangibleTapisTaquinerTarderTarifTartineTasseTatamiTatouageTaupeTaureauTaxerTe/moinTemporelTenailleTendreTeneurTenirTensionTerminerTerneTerribleTe/tineTexteThe-meThe/orieThe/rapieThoraxTibiaTie-deTimideTirelireTiroirTissuTitaneTitreTituberTobogganTole/rantTomateToniqueTonneauToponymeTorcheTordreTornadeTorpilleTorrentTorseTortueTotemToucherTournageTousserToxineTractionTraficTragiqueTrahirTrainTrancherTravailTre-fleTremperTre/sorTreuilTriageTribunalTricoterTrilogieTriompheTriplerTriturerTrivialTromboneTroncTropicalTroupeauTuileTulipeTumulteTunnelTurbineTuteurTutoyerTuyauTympanTyphonTypiqueTyranUbuesqueUltimeUltrasonUnanimeUnifierUnionUniqueUnitaireUniversUraniumUrbainUrticantUsageUsineUsuelUsureUtileUtopieVacarmeVaccinVagabondVagueVaillantVaincreVaisseauValableValiseVallonValveVampireVanilleVapeurVarierVaseuxVassalVasteVecteurVedetteVe/ge/talVe/hiculeVeinardVe/loceVendrediVe/ne/rerVengerVenimeuxVentouseVerdureVe/rinVernirVerrouVerserVertuVestonVe/te/ranVe/tusteVexantVexerViaducViandeVictoireVidangeVide/oVignetteVigueurVilainVillageVinaigreViolonVipe-reVirementVirtuoseVirusVisageViseurVisionVisqueuxVisuelVitalVitesseViticoleVitrineVivaceVivipareVocationVoguerVoileVoisinVoitureVolailleVolcanVoltigerVolumeVoraceVortexVoterVouloirVoyageVoyelleWagonXe/nonYachtZe-breZe/nithZesteZoologie";
- var wordlist = null;
- var lookup = {};
- function dropDiacritic(word) {
- wordlist_1.logger.checkNormalize();
- return (0, strings_1.toUtf8String)(Array.prototype.filter.call((0, strings_1.toUtf8Bytes)(word.normalize("NFD").toLowerCase()), function (c) {
- return ((c >= 65 && c <= 90) || (c >= 97 && c <= 123));
- }));
- }
- function expand(word) {
- var output = [];
- Array.prototype.forEach.call((0, strings_1.toUtf8Bytes)(word), function (c) {
- // Acute accent
- if (c === 47) {
- output.push(204);
- output.push(129);
- // Grave accent
- }
- else if (c === 45) {
- output.push(204);
- output.push(128);
- }
- else {
- output.push(c);
- }
- });
- return (0, strings_1.toUtf8String)(output);
- }
- function loadWords(lang) {
- if (wordlist != null) {
- return;
- }
- wordlist = words.replace(/([A-Z])/g, " $1").toLowerCase().substring(1).split(" ").map(function (w) { return expand(w); });
- wordlist.forEach(function (word, index) {
- lookup[dropDiacritic(word)] = index;
- });
- // Verify the computed list matches the official list
- /* istanbul ignore if */
- if (wordlist_1.Wordlist.check(lang) !== "0x51deb7ae009149dc61a6bd18a918eb7ac78d2775726c68e598b92d002519b045") {
- wordlist = null;
- throw new Error("BIP39 Wordlist for fr (French) FAILED");
- }
- }
- var LangFr = /** @class */ (function (_super) {
- __extends(LangFr, _super);
- function LangFr() {
- return _super.call(this, "fr") || this;
- }
- LangFr.prototype.getWord = function (index) {
- loadWords(this);
- return wordlist[index];
- };
- LangFr.prototype.getWordIndex = function (word) {
- loadWords(this);
- return lookup[dropDiacritic(word)];
- };
- return LangFr;
- }(wordlist_1.Wordlist));
- var langFr = new LangFr();
- exports.langFr = langFr;
- wordlist_1.Wordlist.register(langFr);
- },{"./wordlist":287,"@ethersproject/strings":266}],283:[function(_dereq_,module,exports){
- "use strict";
- var __extends = (this && this.__extends) || (function () {
- var extendStatics = function (d, b) {
- extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
- return extendStatics(d, b);
- };
- return function (d, b) {
- if (typeof b !== "function" && b !== null)
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.langIt = void 0;
- var wordlist_1 = _dereq_("./wordlist");
- var words = "AbacoAbbaglioAbbinatoAbeteAbissoAbolireAbrasivoAbrogatoAccadereAccennoAccusatoAcetoneAchilleAcidoAcquaAcreAcrilicoAcrobataAcutoAdagioAddebitoAddomeAdeguatoAderireAdipeAdottareAdulareAffabileAffettoAffissoAffrantoAforismaAfosoAfricanoAgaveAgenteAgevoleAggancioAgireAgitareAgonismoAgricoloAgrumetoAguzzoAlabardaAlatoAlbatroAlberatoAlboAlbumeAlceAlcolicoAlettoneAlfaAlgebraAlianteAlibiAlimentoAllagatoAllegroAllievoAllodolaAllusivoAlmenoAlogenoAlpacaAlpestreAltalenaAlternoAlticcioAltroveAlunnoAlveoloAlzareAmalgamaAmanitaAmarenaAmbitoAmbratoAmebaAmericaAmetistaAmicoAmmassoAmmendaAmmirareAmmonitoAmoreAmpioAmpliareAmuletoAnacardoAnagrafeAnalistaAnarchiaAnatraAncaAncellaAncoraAndareAndreaAnelloAngeloAngolareAngustoAnimaAnnegareAnnidatoAnnoAnnuncioAnonimoAnticipoAnziApaticoAperturaApodeApparireAppetitoAppoggioApprodoAppuntoAprileArabicaArachideAragostaAraldicaArancioAraturaArazzoArbitroArchivioArditoArenileArgentoArgineArgutoAriaArmoniaArneseArredatoArringaArrostoArsenicoArsoArteficeArzilloAsciuttoAscoltoAsepsiAsetticoAsfaltoAsinoAsolaAspiratoAsproAssaggioAsseAssolutoAssurdoAstaAstenutoAsticeAstrattoAtavicoAteismoAtomicoAtonoAttesaAttivareAttornoAttritoAttualeAusilioAustriaAutistaAutonomoAutunnoAvanzatoAvereAvvenireAvvisoAvvolgereAzioneAzotoAzzimoAzzurroBabeleBaccanoBacinoBacoBadessaBadilataBagnatoBaitaBalconeBaldoBalenaBallataBalzanoBambinoBandireBaraondaBarbaroBarcaBaritonoBarlumeBaroccoBasilicoBassoBatostaBattutoBauleBavaBavosaBeccoBeffaBelgioBelvaBendaBenevoleBenignoBenzinaBereBerlinaBetaBibitaBiciBidoneBifidoBigaBilanciaBimboBinocoloBiologoBipedeBipolareBirbanteBirraBiscottoBisestoBisnonnoBisonteBisturiBizzarroBlandoBlattaBollitoBonificoBordoBoscoBotanicoBottinoBozzoloBraccioBradipoBramaBrancaBravuraBretellaBrevettoBrezzaBrigliaBrillanteBrindareBroccoloBrodoBronzinaBrulloBrunoBubboneBucaBudinoBuffoneBuioBulboBuonoBurloneBurrascaBussolaBustaCadettoCaducoCalamaroCalcoloCalesseCalibroCalmoCaloriaCambusaCamerataCamiciaCamminoCamolaCampaleCanapaCandelaCaneCaninoCanottoCantinaCapaceCapelloCapitoloCapogiroCapperoCapraCapsulaCarapaceCarcassaCardoCarismaCarovanaCarrettoCartolinaCasaccioCascataCasermaCasoCassoneCastelloCasualeCatastaCatenaCatrameCautoCavilloCedibileCedrataCefaloCelebreCellulareCenaCenoneCentesimoCeramicaCercareCertoCerumeCervelloCesoiaCespoCetoChelaChiaroChiccaChiedereChimeraChinaChirurgoChitarraCiaoCiclismoCifrareCignoCilindroCiottoloCircaCirrosiCitricoCittadinoCiuffoCivettaCivileClassicoClinicaCloroCoccoCodardoCodiceCoerenteCognomeCollareColmatoColoreColposoColtivatoColzaComaCometaCommandoComodoComputerComuneConcisoCondurreConfermaCongelareConiugeConnessoConoscereConsumoContinuoConvegnoCopertoCopioneCoppiaCopricapoCorazzaCordataCoricatoCorniceCorollaCorpoCorredoCorsiaCorteseCosmicoCostanteCotturaCovatoCratereCravattaCreatoCredereCremosoCrescitaCretaCricetoCrinaleCrisiCriticoCroceCronacaCrostataCrucialeCruscaCucireCuculoCuginoCullatoCupolaCuratoreCursoreCurvoCuscinoCustodeDadoDainoDalmataDamerinoDanielaDannosoDanzareDatatoDavantiDavveroDebuttoDecennioDecisoDeclinoDecolloDecretoDedicatoDefinitoDeformeDegnoDelegareDelfinoDelirioDeltaDemenzaDenotatoDentroDepositoDerapataDerivareDerogaDescrittoDesertoDesiderioDesumereDetersivoDevotoDiametroDicembreDiedroDifesoDiffusoDigerireDigitaleDiluvioDinamicoDinnanziDipintoDiplomaDipoloDiradareDireDirottoDirupoDisagioDiscretoDisfareDisgeloDispostoDistanzaDisumanoDitoDivanoDiveltoDividereDivoratoDobloneDocenteDoganaleDogmaDolceDomatoDomenicaDominareDondoloDonoDormireDoteDottoreDovutoDozzinaDragoDruidoDubbioDubitareDucaleDunaDuomoDupliceDuraturoEbanoEccessoEccoEclissiEconomiaEderaEdicolaEdileEditoriaEducareEgemoniaEgliEgoismoEgregioElaboratoElargireEleganteElencatoElettoElevareElficoElicaElmoElsaElusoEmanatoEmblemaEmessoEmiroEmotivoEmozioneEmpiricoEmuloEndemicoEnduroEnergiaEnfasiEnotecaEntrareEnzimaEpatiteEpilogoEpisodioEpocaleEppureEquatoreErarioErbaErbosoEredeEremitaErigereErmeticoEroeErosivoErranteEsagonoEsameEsanimeEsaudireEscaEsempioEsercitoEsibitoEsigenteEsistereEsitoEsofagoEsortatoEsosoEspansoEspressoEssenzaEssoEstesoEstimareEstoniaEstrosoEsultareEtilicoEtnicoEtruscoEttoEuclideoEuropaEvasoEvidenzaEvitatoEvolutoEvvivaFabbricaFaccendaFachiroFalcoFamigliaFanaleFanfaraFangoFantasmaFareFarfallaFarinosoFarmacoFasciaFastosoFasulloFaticareFatoFavolosoFebbreFecolaFedeFegatoFelpaFeltroFemminaFendereFenomenoFermentoFerroFertileFessuraFestivoFettaFeudoFiabaFiduciaFifaFiguratoFiloFinanzaFinestraFinireFioreFiscaleFisicoFiumeFlaconeFlamencoFleboFlemmaFloridoFluenteFluoroFobicoFocacciaFocosoFoderatoFoglioFolataFolcloreFolgoreFondenteFoneticoFoniaFontanaForbitoForchettaForestaFormicaFornaioForoFortezzaForzareFosfatoFossoFracassoFranaFrassinoFratelloFreccettaFrenataFrescoFrigoFrollinoFrondeFrugaleFruttaFucilataFucsiaFuggenteFulmineFulvoFumanteFumettoFumosoFuneFunzioneFuocoFurboFurgoneFuroreFusoFutileGabbianoGaffeGalateoGallinaGaloppoGamberoGammaGaranziaGarboGarofanoGarzoneGasdottoGasolioGastricoGattoGaudioGazeboGazzellaGecoGelatinaGelsoGemelloGemmatoGeneGenitoreGennaioGenotipoGergoGhepardoGhiaccioGhisaGialloGildaGineproGiocareGioielloGiornoGioveGiratoGironeGittataGiudizioGiuratoGiustoGlobuloGlutineGnomoGobbaGolfGomitoGommoneGonfioGonnaGovernoGracileGradoGraficoGrammoGrandeGrattareGravosoGraziaGrecaGreggeGrifoneGrigioGrinzaGrottaGruppoGuadagnoGuaioGuantoGuardareGufoGuidareIbernatoIconaIdenticoIdillioIdoloIdraIdricoIdrogenoIgieneIgnaroIgnoratoIlareIllesoIllogicoIlludereImballoImbevutoImboccoImbutoImmaneImmersoImmolatoImpaccoImpetoImpiegoImportoImprontaInalareInarcareInattivoIncantoIncendioInchinoIncisivoInclusoIncontroIncrocioIncuboIndagineIndiaIndoleIneditoInfattiInfilareInflittoIngaggioIngegnoIngleseIngordoIngrossoInnescoInodoreInoltrareInondatoInsanoInsettoInsiemeInsonniaInsulinaIntasatoInteroIntonacoIntuitoInumidireInvalidoInveceInvitoIperboleIpnoticoIpotesiIppicaIrideIrlandaIronicoIrrigatoIrrorareIsolatoIsotopoIstericoIstitutoIstriceItaliaIterareLabbroLabirintoLaccaLaceratoLacrimaLacunaLaddoveLagoLampoLancettaLanternaLardosoLargaLaringeLastraLatenzaLatinoLattugaLavagnaLavoroLegaleLeggeroLemboLentezzaLenzaLeoneLepreLesivoLessatoLestoLetteraleLevaLevigatoLiberoLidoLievitoLillaLimaturaLimitareLimpidoLineareLinguaLiquidoLiraLiricaLiscaLiteLitigioLivreaLocandaLodeLogicaLombareLondraLongevoLoquaceLorenzoLotoLotteriaLuceLucidatoLumacaLuminosoLungoLupoLuppoloLusingaLussoLuttoMacabroMacchinaMaceroMacinatoMadamaMagicoMagliaMagneteMagroMaiolicaMalafedeMalgradoMalintesoMalsanoMaltoMalumoreManaManciaMandorlaMangiareManifestoMannaroManovraMansardaMantideManubrioMappaMaratonaMarcireMarettaMarmoMarsupioMascheraMassaiaMastinoMaterassoMatricolaMattoneMaturoMazurcaMeandroMeccanicoMecenateMedesimoMeditareMegaMelassaMelisMelodiaMeningeMenoMensolaMercurioMerendaMerloMeschinoMeseMessereMestoloMetalloMetodoMettereMiagolareMicaMicelioMicheleMicroboMidolloMieleMiglioreMilanoMiliteMimosaMineraleMiniMinoreMirinoMirtilloMiscelaMissivaMistoMisurareMitezzaMitigareMitraMittenteMnemonicoModelloModificaModuloMoganoMogioMoleMolossoMonasteroMoncoMondinaMonetarioMonileMonotonoMonsoneMontatoMonvisoMoraMordereMorsicatoMostroMotivatoMotosegaMottoMovenzaMovimentoMozzoMuccaMucosaMuffaMughettoMugnaioMulattoMulinelloMultiploMummiaMuntoMuovereMuraleMusaMuscoloMusicaMutevoleMutoNababboNaftaNanometroNarcisoNariceNarratoNascereNastrareNaturaleNauticaNaviglioNebulosaNecrosiNegativoNegozioNemmenoNeofitaNerettoNervoNessunoNettunoNeutraleNeveNevroticoNicchiaNinfaNitidoNobileNocivoNodoNomeNominaNordicoNormaleNorvegeseNostranoNotareNotiziaNotturnoNovellaNucleoNullaNumeroNuovoNutrireNuvolaNuzialeOasiObbedireObbligoObeliscoOblioOboloObsoletoOccasioneOcchioOccidenteOccorrereOccultareOcraOculatoOdiernoOdorareOffertaOffrireOffuscatoOggettoOggiOgnunoOlandeseOlfattoOliatoOlivaOlogrammaOltreOmaggioOmbelicoOmbraOmegaOmissioneOndosoOnereOniceOnnivoroOnorevoleOntaOperatoOpinioneOppostoOracoloOrafoOrdineOrecchinoOreficeOrfanoOrganicoOrigineOrizzonteOrmaOrmeggioOrnativoOrologioOrrendoOrribileOrtensiaOrticaOrzataOrzoOsareOscurareOsmosiOspedaleOspiteOssaOssidareOstacoloOsteOtiteOtreOttagonoOttimoOttobreOvaleOvestOvinoOviparoOvocitoOvunqueOvviareOzioPacchettoPacePacificoPadellaPadronePaesePagaPaginaPalazzinaPalesarePallidoPaloPaludePandoroPannelloPaoloPaonazzoPapricaParabolaParcellaParerePargoloPariParlatoParolaPartireParvenzaParzialePassivoPasticcaPataccaPatologiaPattumePavonePeccatoPedalarePedonalePeggioPelosoPenarePendicePenisolaPennutoPenombraPensarePentolaPepePepitaPerbenePercorsoPerdonatoPerforarePergamenaPeriodoPermessoPernoPerplessoPersuasoPertugioPervasoPesatorePesistaPesoPestiferoPetaloPettinePetulantePezzoPiacerePiantaPiattinoPiccinoPicozzaPiegaPietraPifferoPigiamaPigolioPigroPilaPiliferoPillolaPilotaPimpantePinetaPinnaPinoloPioggiaPiomboPiramidePireticoPiritePirolisiPitonePizzicoPlaceboPlanarePlasmaPlatanoPlenarioPochezzaPoderosoPodismoPoesiaPoggiarePolentaPoligonoPollicePolmonitePolpettaPolsoPoltronaPolverePomicePomodoroPontePopolosoPorfidoPorosoPorporaPorrePortataPosaPositivoPossessoPostulatoPotassioPoterePranzoPrassiPraticaPreclusoPredicaPrefissoPregiatoPrelievoPremerePrenotarePreparatoPresenzaPretestoPrevalsoPrimaPrincipePrivatoProblemaProcuraProdurreProfumoProgettoProlungaPromessaPronomePropostaProrogaProtesoProvaPrudentePrugnaPruritoPsichePubblicoPudicaPugilatoPugnoPulcePulitoPulsantePuntarePupazzoPupillaPuroQuadroQualcosaQuasiQuerelaQuotaRaccoltoRaddoppioRadicaleRadunatoRafficaRagazzoRagioneRagnoRamarroRamingoRamoRandagioRantolareRapatoRapinaRappresoRasaturaRaschiatoRasenteRassegnaRastrelloRataRavvedutoRealeRecepireRecintoReclutaReconditoRecuperoRedditoRedimereRegalatoRegistroRegolaRegressoRelazioneRemareRemotoRennaReplicaReprimereReputareResaResidenteResponsoRestauroReteRetinaRetoricaRettificaRevocatoRiassuntoRibadireRibelleRibrezzoRicaricaRiccoRicevereRiciclatoRicordoRicredutoRidicoloRidurreRifasareRiflessoRiformaRifugioRigareRigettatoRighelloRilassatoRilevatoRimanereRimbalzoRimedioRimorchioRinascitaRincaroRinforzoRinnovoRinomatoRinsavitoRintoccoRinunciaRinvenireRiparatoRipetutoRipienoRiportareRipresaRipulireRisataRischioRiservaRisibileRisoRispettoRistoroRisultatoRisvoltoRitardoRitegnoRitmicoRitrovoRiunioneRivaRiversoRivincitaRivoltoRizomaRobaRoboticoRobustoRocciaRocoRodaggioRodereRoditoreRogitoRollioRomanticoRompereRonzioRosolareRospoRotanteRotondoRotulaRovescioRubizzoRubricaRugaRullinoRumineRumorosoRuoloRupeRussareRusticoSabatoSabbiareSabotatoSagomaSalassoSaldaturaSalgemmaSalivareSalmoneSaloneSaltareSalutoSalvoSapereSapidoSaporitoSaracenoSarcasmoSartoSassosoSatelliteSatiraSatolloSaturnoSavanaSavioSaziatoSbadiglioSbalzoSbancatoSbarraSbattereSbavareSbendareSbirciareSbloccatoSbocciatoSbrinareSbruffoneSbuffareScabrosoScadenzaScalaScambiareScandaloScapolaScarsoScatenareScavatoSceltoScenicoScettroSchedaSchienaSciarpaScienzaScindereScippoSciroppoScivoloSclerareScodellaScolpitoScompartoSconfortoScoprireScortaScossoneScozzeseScribaScrollareScrutinioScuderiaScultoreScuolaScuroScusareSdebitareSdoganareSeccaturaSecondoSedanoSeggiolaSegnalatoSegregatoSeguitoSelciatoSelettivoSellaSelvaggioSemaforoSembrareSemeSeminatoSempreSensoSentireSepoltoSequenzaSerataSerbatoSerenoSerioSerpenteSerraglioServireSestinaSetolaSettimanaSfaceloSfaldareSfamatoSfarzosoSfaticatoSferaSfidaSfilatoSfingeSfocatoSfoderareSfogoSfoltireSforzatoSfrattoSfruttatoSfuggitoSfumareSfusoSgabelloSgarbatoSgonfiareSgorbioSgrassatoSguardoSibiloSiccomeSierraSiglaSignoreSilenzioSillabaSimboloSimpaticoSimulatoSinfoniaSingoloSinistroSinoSintesiSinusoideSiparioSismaSistoleSituatoSlittaSlogaturaSlovenoSmarritoSmemoratoSmentitoSmeraldoSmilzoSmontareSmottatoSmussatoSnellireSnervatoSnodoSobbalzoSobrioSoccorsoSocialeSodaleSoffittoSognoSoldatoSolenneSolidoSollazzoSoloSolubileSolventeSomaticoSommaSondaSonettoSonniferoSopireSoppesoSopraSorgereSorpassoSorrisoSorsoSorteggioSorvolatoSospiroSostaSottileSpadaSpallaSpargereSpatolaSpaventoSpazzolaSpecieSpedireSpegnereSpelaturaSperanzaSpessoreSpettraleSpezzatoSpiaSpigolosoSpillatoSpinosoSpiraleSplendidoSportivoSposoSprangaSprecareSpronatoSpruzzoSpuntinoSquilloSradicareSrotolatoStabileStaccoStaffaStagnareStampatoStantioStarnutoStaseraStatutoSteloSteppaSterzoStilettoStimaStirpeStivaleStizzosoStonatoStoricoStrappoStregatoStriduloStrozzareStruttoStuccareStufoStupendoSubentroSuccosoSudoreSuggeritoSugoSultanoSuonareSuperboSupportoSurgelatoSurrogatoSussurroSuturaSvagareSvedeseSveglioSvelareSvenutoSveziaSviluppoSvistaSvizzeraSvoltaSvuotareTabaccoTabulatoTacciareTaciturnoTaleTalismanoTamponeTanninoTaraTardivoTargatoTariffaTarpareTartarugaTastoTatticoTavernaTavolataTazzaTecaTecnicoTelefonoTemerarioTempoTemutoTendoneTeneroTensioneTentacoloTeoremaTermeTerrazzoTerzettoTesiTesseratoTestatoTetroTettoiaTifareTigellaTimbroTintoTipicoTipografoTiraggioTiroTitanioTitoloTitubanteTizioTizzoneToccareTollerareToltoTombolaTomoTonfoTonsillaTopazioTopologiaToppaTorbaTornareTorroneTortoraToscanoTossireTostaturaTotanoTraboccoTracheaTrafilaTragediaTralcioTramontoTransitoTrapanoTrarreTraslocoTrattatoTraveTrecciaTremolioTrespoloTributoTrichecoTrifoglioTrilloTrinceaTrioTristezzaTrituratoTrivellaTrombaTronoTroppoTrottolaTrovareTruccatoTubaturaTuffatoTulipanoTumultoTunisiaTurbareTurchinoTutaTutelaUbicatoUccelloUccisoreUdireUditivoUffaUfficioUgualeUlisseUltimatoUmanoUmileUmorismoUncinettoUngereUnghereseUnicornoUnificatoUnisonoUnitarioUnteUovoUpupaUraganoUrgenzaUrloUsanzaUsatoUscitoUsignoloUsuraioUtensileUtilizzoUtopiaVacanteVaccinatoVagabondoVagliatoValangaValgoValicoVallettaValorosoValutareValvolaVampataVangareVanitosoVanoVantaggioVanveraVaporeVaranoVarcatoVarianteVascaVedettaVedovaVedutoVegetaleVeicoloVelcroVelinaVellutoVeloceVenatoVendemmiaVentoVeraceVerbaleVergognaVerificaVeroVerrucaVerticaleVescicaVessilloVestaleVeteranoVetrinaVetustoViandanteVibranteVicendaVichingoVicinanzaVidimareVigiliaVignetoVigoreVileVillanoViminiVincitoreViolaViperaVirgolaVirologoVirulentoViscosoVisioneVispoVissutoVisuraVitaVitelloVittimaVivandaVividoViziareVoceVogaVolatileVolereVolpeVoragineVulcanoZampognaZannaZappatoZatteraZavorraZefiroZelanteZeloZenzeroZerbinoZibettoZincoZirconeZittoZollaZoticoZuccheroZufoloZuluZuppa";
- var wordlist = null;
- function loadWords(lang) {
- if (wordlist != null) {
- return;
- }
- wordlist = words.replace(/([A-Z])/g, " $1").toLowerCase().substring(1).split(" ");
- // Verify the computed list matches the official list
- /* istanbul ignore if */
- if (wordlist_1.Wordlist.check(lang) !== "0x5c1362d88fd4cf614a96f3234941d29f7d37c08c5292fde03bf62c2db6ff7620") {
- wordlist = null;
- throw new Error("BIP39 Wordlist for it (Italian) FAILED");
- }
- }
- var LangIt = /** @class */ (function (_super) {
- __extends(LangIt, _super);
- function LangIt() {
- return _super.call(this, "it") || this;
- }
- LangIt.prototype.getWord = function (index) {
- loadWords(this);
- return wordlist[index];
- };
- LangIt.prototype.getWordIndex = function (word) {
- loadWords(this);
- return wordlist.indexOf(word);
- };
- return LangIt;
- }(wordlist_1.Wordlist));
- var langIt = new LangIt();
- exports.langIt = langIt;
- wordlist_1.Wordlist.register(langIt);
- },{"./wordlist":287}],284:[function(_dereq_,module,exports){
- "use strict";
- var __extends = (this && this.__extends) || (function () {
- var extendStatics = function (d, b) {
- extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
- return extendStatics(d, b);
- };
- return function (d, b) {
- if (typeof b !== "function" && b !== null)
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.langJa = void 0;
- var bytes_1 = _dereq_("@ethersproject/bytes");
- var strings_1 = _dereq_("@ethersproject/strings");
- var wordlist_1 = _dereq_("./wordlist");
- var data = [
- // 4-kana words
- "AQRASRAGBAGUAIRAHBAghAURAdBAdcAnoAMEAFBAFCBKFBQRBSFBCXBCDBCHBGFBEQBpBBpQBIkBHNBeOBgFBVCBhBBhNBmOBmRBiHBiFBUFBZDBvFBsXBkFBlcBjYBwDBMBBTBBTRBWBBWXXaQXaRXQWXSRXCFXYBXpHXOQXHRXhRXuRXmXXbRXlXXwDXTRXrCXWQXWGaBWaKcaYgasFadQalmaMBacAKaRKKBKKXKKjKQRKDRKCYKCRKIDKeVKHcKlXKjHKrYNAHNBWNaRNKcNIBNIONmXNsXNdXNnBNMBNRBNrXNWDNWMNFOQABQAHQBrQXBQXFQaRQKXQKDQKOQKFQNBQNDQQgQCXQCDQGBQGDQGdQYXQpBQpQQpHQLXQHuQgBQhBQhCQuFQmXQiDQUFQZDQsFQdRQkHQbRQlOQlmQPDQjDQwXQMBQMDQcFQTBQTHQrDDXQDNFDGBDGQDGRDpFDhFDmXDZXDbRDMYDRdDTRDrXSAhSBCSBrSGQSEQSHBSVRShYShkSyQSuFSiBSdcSoESocSlmSMBSFBSFKSFNSFdSFcCByCaRCKcCSBCSRCCrCGbCEHCYXCpBCpQCIBCIHCeNCgBCgFCVECVcCmkCmwCZXCZFCdRClOClmClFCjDCjdCnXCwBCwXCcRCFQCFjGXhGNhGDEGDMGCDGCHGIFGgBGVXGVEGVRGmXGsXGdYGoSGbRGnXGwXGwDGWRGFNGFLGFOGFdGFkEABEBDEBFEXOEaBEKSENBENDEYXEIgEIkEgBEgQEgHEhFEudEuFEiBEiHEiFEZDEvBEsXEsFEdXEdREkFEbBEbRElFEPCEfkEFNYAEYAhYBNYQdYDXYSRYCEYYoYgQYgRYuRYmCYZTYdBYbEYlXYjQYRbYWRpKXpQopQnpSFpCXpIBpISphNpdBpdRpbRpcZpFBpFNpFDpFopFrLADLBuLXQLXcLaFLCXLEhLpBLpFLHXLeVLhILdHLdRLoDLbRLrXIABIBQIBCIBsIBoIBMIBRIXaIaRIKYIKRINBINuICDIGBIIDIIkIgRIxFIyQIiHIdRIbYIbRIlHIwRIMYIcRIRVITRIFBIFNIFQOABOAFOBQOaFONBONMOQFOSFOCDOGBOEQOpBOLXOIBOIFOgQOgFOyQOycOmXOsXOdIOkHOMEOMkOWWHBNHXNHXWHNXHDuHDRHSuHSRHHoHhkHmRHdRHkQHlcHlRHwBHWcgAEgAggAkgBNgBQgBEgXOgYcgLXgHjgyQgiBgsFgdagMYgWSgFQgFEVBTVXEVKBVKNVKDVKYVKRVNBVNYVDBVDxVSBVSRVCjVGNVLXVIFVhBVhcVsXVdRVbRVlRhBYhKYhDYhGShxWhmNhdahdkhbRhjohMXhTRxAXxXSxKBxNBxEQxeNxeQxhXxsFxdbxlHxjcxFBxFNxFQxFOxFoyNYyYoybcyMYuBQuBRuBruDMuCouHBudQukkuoBulVuMXuFEmCYmCRmpRmeDmiMmjdmTFmFQiADiBOiaRiKRiNBiNRiSFiGkiGFiERipRiLFiIFihYibHijBijEiMXiWBiFBiFCUBQUXFUaRUNDUNcUNRUNFUDBUSHUCDUGBUGFUEqULNULoUIRUeEUeYUgBUhFUuRUiFUsXUdFUkHUbBUjSUjYUwXUMDUcHURdUTBUrBUrXUrQZAFZXZZaRZKFZNBZQFZCXZGBZYdZpBZLDZIFZHXZHNZeQZVRZVFZmXZiBZvFZdFZkFZbHZbFZwXZcCZcRZRBvBQvBGvBLvBWvCovMYsAFsBDsaRsKFsNFsDrsSHsSFsCXsCRsEBsEHsEfspBsLBsLDsIgsIRseGsbRsFBsFQsFSdNBdSRdCVdGHdYDdHcdVbdySduDdsXdlRdwXdWYdWcdWRkBMkXOkaRkNIkNFkSFkCFkYBkpRkeNkgBkhVkmXksFklVkMBkWDkFNoBNoaQoaFoNBoNXoNaoNEoSRoEroYXoYCoYbopRopFomXojkowXorFbBEbEIbdBbjYlaRlDElMXlFDjKjjSRjGBjYBjYkjpRjLXjIBjOFjeVjbRjwBnXQnSHnpFnLXnINnMBnTRwXBwXNwXYwNFwQFwSBwGFwLXwLDweNwgBwuHwjDwnXMBXMpFMIBMeNMTHcaQcNBcDHcSFcCXcpBcLXcLDcgFcuFcnXcwXccDcTQcrFTQErXNrCHrpFrgFrbFrTHrFcWNYWNbWEHWMXWTR",
- // 5-kana words
- "ABGHABIJAEAVAYJQALZJAIaRAHNXAHdcAHbRAZJMAZJRAZTRAdVJAklmAbcNAjdRAMnRAMWYAWpRAWgRAFgBAFhBAFdcBNJBBNJDBQKBBQhcBQlmBDEJBYJkBYJTBpNBBpJFBIJBBIJDBIcABOKXBOEJBOVJBOiJBOZJBepBBeLXBeIFBegBBgGJBVJXBuocBiJRBUJQBlXVBlITBwNFBMYVBcqXBTlmBWNFBWiJBWnRBFGHBFwXXKGJXNJBXNZJXDTTXSHSXSVRXSlHXCJDXGQJXEhXXYQJXYbRXOfXXeNcXVJFXhQJXhEJXdTRXjdXXMhBXcQTXRGBXTEBXTnQXFCXXFOFXFgFaBaFaBNJaBCJaBpBaBwXaNJKaNJDaQIBaDpRaEPDaHMFamDJalEJaMZJaFaFaFNBaFQJaFLDaFVHKBCYKBEBKBHDKXaFKXGdKXEJKXpHKXIBKXZDKXwXKKwLKNacKNYJKNJoKNWcKDGdKDTRKChXKGaRKGhBKGbRKEBTKEaRKEPTKLMDKLWRKOHDKVJcKdBcKlIBKlOPKFSBKFEPKFpFNBNJNJBQNBGHNBEPNBHXNBgFNBVXNBZDNBsXNBwXNNaRNNJDNNJENNJkNDCJNDVDNGJRNJiDNZJNNsCJNJFNNFSBNFCXNFEPNFLXNFIFQJBFQCaRQJEQQLJDQLJFQIaRQOqXQHaFQHHQQVJXQVJDQhNJQmEIQZJFQsJXQJrFQWbRDJABDBYJDXNFDXCXDXLXDXZDDXsJDQqXDSJFDJCXDEPkDEqXDYmQDpSJDOCkDOGQDHEIDVJDDuDuDWEBDJFgSBNDSBSFSBGHSBIBSBTQSKVYSJQNSJQiSJCXSEqXSJYVSIiJSOMYSHAHSHaQSeCFSepQSegBSHdHSHrFShSJSJuHSJUFSkNRSrSrSWEBSFaHSJFQSFCXSFGDSFYXSFODSFgBSFVXSFhBSFxFSFkFSFbBSFMFCADdCJXBCXaFCXKFCXNFCXCXCXGBCXEJCXYBCXLDCXIBCXOPCXHXCXgBCXhBCXiBCXlDCXcHCJNBCJNFCDCJCDGBCDVXCDhBCDiDCDJdCCmNCpJFCIaRCOqXCHCHCHZJCViJCuCuCmddCJiFCdNBCdHhClEJCnUJCreSCWlgCWTRCFBFCFNBCFYBCFVFCFhFCFdSCFTBCFWDGBNBGBQFGJBCGBEqGBpBGBgQGNBEGNJYGNkOGNJRGDUFGJpQGHaBGJeNGJeEGVBlGVKjGiJDGvJHGsVJGkEBGMIJGWjNGFBFGFCXGFGBGFYXGFpBGFMFEASJEAWpEJNFECJVEIXSEIQJEOqXEOcFEeNcEHEJEHlFEJgFEhlmEmDJEmZJEiMBEUqXEoSREPBFEPXFEPKFEPSFEPEFEPpFEPLXEPIBEJPdEPcFEPTBEJnXEqlHEMpREFCXEFODEFcFYASJYJAFYBaBYBVXYXpFYDhBYCJBYJGFYYbRYeNcYJeVYiIJYZJcYvJgYvJRYJsXYsJFYMYMYreVpBNHpBEJpBwXpQxFpYEJpeNDpJeDpeSFpeCHpHUJpHbBpHcHpmUJpiiJpUJrpsJuplITpFaBpFQqpFGBpFEfpFYBpFpBpFLJpFIDpFgBpFVXpFyQpFuFpFlFpFjDpFnXpFwXpJFMpFTBLXCJLXEFLXhFLXUJLXbFLalmLNJBLSJQLCLCLGJBLLDJLHaFLeNFLeSHLeCXLepFLhaRLZsJLsJDLsJrLocaLlLlLMdbLFNBLFSBLFEHLFkFIBBFIBXFIBaQIBKXIBSFIBpHIBLXIBgBIBhBIBuHIBmXIBiFIBZXIBvFIBbFIBjQIBwXIBWFIKTRIQUJIDGFICjQIYSRIINXIJeCIVaRImEkIZJFIvJRIsJXIdCJIJoRIbBQIjYBIcqXITFVIreVIFKFIFSFIFCJIFGFIFLDIFIBIJFOIFgBIFVXIJFhIFxFIFmXIFdHIFbBIJFrIJFWOBGBOQfXOOKjOUqXOfXBOqXEOcqXORVJOFIBOFlDHBIOHXiFHNTRHCJXHIaRHHJDHHEJHVbRHZJYHbIBHRsJHRkDHWlmgBKFgBSBgBCDgBGHgBpBgBIBgBVJgBuBgBvFgKDTgQVXgDUJgGSJgOqXgmUMgZIJgTUJgWIEgFBFgFNBgFDJgFSFgFGBgFYXgJFOgFgQgFVXgFhBgFbHgJFWVJABVQKcVDgFVOfXVeDFVhaRVmGdViJYVMaRVFNHhBNDhBCXhBEqhBpFhBLXhNJBhSJRheVXhhKEhxlmhZIJhdBQhkIJhbMNhMUJhMZJxNJgxQUJxDEkxDdFxSJRxplmxeSBxeCXxeGFxeYXxepQxegBxWVcxFEQxFLXxFIBxFgBxFxDxFZtxFdcxFbBxFwXyDJXyDlcuASJuDJpuDIBuCpJuGSJuIJFueEFuZIJusJXudWEuoIBuWGJuFBcuFKEuFNFuFQFuFDJuFGJuFVJuFUtuFdHuFTBmBYJmNJYmQhkmLJDmLJomIdXmiJYmvJRmsJRmklmmMBymMuCmclmmcnQiJABiJBNiJBDiBSFiBCJiBEFiBYBiBpFiBLXiBTHiJNciDEfiCZJiECJiJEqiOkHiHKFieNDiHJQieQcieDHieSFieCXieGFieEFieIHiegFihUJixNoioNXiFaBiFKFiFNDiFEPiFYXitFOitFHiFgBiFVEiFmXiFitiFbBiFMFiFrFUCXQUIoQUIJcUHQJUeCEUHwXUUJDUUqXUdWcUcqXUrnQUFNDUFSHUFCFUFEfUFLXUtFOZBXOZXSBZXpFZXVXZEQJZEJkZpDJZOqXZeNHZeCDZUqXZFBQZFEHZFLXvBAFvBKFvBCXvBEPvBpHvBIDvBgFvBuHvQNJvFNFvFGBvFIBvJFcsXCDsXLXsXsXsXlFsXcHsQqXsJQFsEqXseIFsFEHsFjDdBxOdNpRdNJRdEJbdpJRdhZJdnSJdrjNdFNJdFQHdFhNkNJDkYaRkHNRkHSRkVbRkuMRkjSJkcqDoSJFoEiJoYZJoOfXohEBoMGQocqXbBAFbBXFbBaFbBNDbBGBbBLXbBTBbBWDbGJYbIJHbFQqbFpQlDgQlOrFlVJRjGEBjZJRnXvJnXbBnEfHnOPDngJRnxfXnUJWwXEJwNpJwDpBwEfXwrEBMDCJMDGHMDIJMLJDcQGDcQpHcqXccqNFcqCXcFCJRBSBRBGBRBEJRBpQTBNFTBQJTBpBTBVXTFABTFSBTFCFTFGBTFMDrXCJrXLDrDNJrEfHrFQJrFitWNjdWNTR",
- // 6-kana words
- "AKLJMANOPFASNJIAEJWXAYJNRAIIbRAIcdaAeEfDAgidRAdjNYAMYEJAMIbRAFNJBAFpJFBBIJYBDZJFBSiJhBGdEBBEJfXBEJqXBEJWRBpaUJBLXrXBIYJMBOcfXBeEfFBestXBjNJRBcDJOBFEqXXNvJRXDMBhXCJNYXOAWpXONJWXHDEBXeIaRXhYJDXZJSJXMDJOXcASJXFVJXaBQqXaBZJFasXdQaFSJQaFEfXaFpJHaFOqXKBNSRKXvJBKQJhXKEJQJKEJGFKINJBKIJjNKgJNSKVElmKVhEBKiJGFKlBgJKjnUJKwsJYKMFIJKFNJDKFIJFKFOfXNJBSFNJBCXNBpJFNJBvQNJBMBNJLJXNJOqXNJeCXNJeGFNdsJCNbTKFNwXUJQNFEPQDiJcQDMSJQSFpBQGMQJQJeOcQyCJEQUJEBQJFBrQFEJqDXDJFDJXpBDJXIMDGiJhDIJGRDJeYcDHrDJDVXgFDkAWpDkIgRDjDEqDMvJRDJFNFDJFIBSKclmSJQOFSJQVHSJQjDSJGJBSJGJFSECJoSHEJqSJHTBSJVJDSViJYSZJNBSJsJDSFSJFSFEfXSJFLXCBUJVCJXSBCJXpBCXVJXCJXsXCJXdFCJNJHCLIJgCHiJFCVNJMChCJhCUHEJCsJTRCJdYcCoQJCCFEfXCFIJgCFUJxCFstFGJBaQGJBIDGQJqXGYJNRGJHKFGeQqDGHEJFGJeLXGHIiJGHdBlGUJEBGkIJTGFQPDGJFEqEAGegEJIJBEJVJXEhQJTEiJNcEJZJFEJoEqEjDEqEPDsXEPGJBEPOqXEPeQFEfDiDEJfEFEfepQEfMiJEqXNBEqDIDEqeSFEqVJXEMvJRYXNJDYXEJHYKVJcYYJEBYJeEcYJUqXYFpJFYFstXpAZJMpBSJFpNBNFpeQPDpHLJDpHIJFpHgJFpeitFpHZJFpJFADpFSJFpJFCJpFOqXpFitBpJFZJLXIJFLIJgRLVNJWLVHJMLwNpJLFGJBLFLJDLFOqXLJFUJIBDJXIBGJBIJBYQIJBIBIBOqXIBcqDIEGJFILNJTIIJEBIOiJhIJeNBIJeIBIhiJIIWoTRIJFAHIJFpBIJFuHIFUtFIJFTHOSBYJOEcqXOHEJqOvBpFOkVJrObBVJOncqDOcNJkHhNJRHuHJuHdMhBgBUqXgBsJXgONJBgHNJDgHHJQgJeitgHsJXgJyNagyDJBgZJDrgsVJQgkEJNgkjSJgJFAHgFCJDgFZtMVJXNFVXQfXVJXDJVXoQJVQVJQVDEfXVDvJHVEqNFVeQfXVHpJFVHxfXVVJSRVVmaRVlIJOhCXVJhHjYkhxCJVhWVUJhWiJcxBNJIxeEqDxfXBFxcFEPxFSJFxFYJXyBDQJydaUJyFOPDuYCJYuLvJRuHLJXuZJLDuFOPDuFZJHuFcqXmKHJdmCQJcmOsVJiJAGFitLCFieOfXiestXiZJMEikNJQirXzFiFQqXiFIJFiFZJFiFvtFUHpJFUteIcUteOcUVCJkUhdHcUbEJEUJqXQUMNJhURjYkUFitFZDGJHZJIxDZJVJXZJFDJZJFpQvBNJBvBSJFvJxBrseQqDsVFVJdFLJDkEJNBkmNJYkFLJDoQJOPoGsJRoEAHBoEJfFbBQqDbBZJHbFVJXlFIJBjYIrXjeitcjjCEBjWMNBwXQfXwXOaFwDsJXwCJTRwrCZJMDNJQcDDJFcqDOPRYiJFTBsJXTQIJBTFEfXTFLJDrXEJFrEJXMrFZJFWEJdEWYTlm",
- // 7-kana words
- "ABCDEFACNJTRAMBDJdAcNJVXBLNJEBXSIdWRXErNJkXYDJMBXZJCJaXMNJaYKKVJKcKDEJqXKDcNJhKVJrNYKbgJVXKFVJSBNBYBwDNJeQfXNJeEqXNhGJWENJFiJRQlIJbEQJfXxDQqXcfXQFNDEJQFwXUJDYcnUJDJIBgQDIUJTRDJFEqDSJQSJFSJQIJFSOPeZtSJFZJHCJXQfXCTDEqFGJBSJFGJBOfXGJBcqXGJHNJDGJRLiJEJfXEqEJFEJPEFpBEJYJBZJFYBwXUJYiJMEBYJZJyTYTONJXpQMFXFpeGIDdpJFstXpJFcPDLBVSJRLHQJqXLJFZJFIJBNJDIJBUqXIBkFDJIJEJPTIYJGWRIJeQPDIJeEfHIJFsJXOqGDSFHXEJqXgJCsJCgGQJqXgdQYJEgFMFNBgJFcqDVJwXUJVJFZJchIgJCCxOEJqXxOwXUJyDJBVRuscisciJBiJBieUtqXiJFDJkiFsJXQUGEZJcUJFsJXZtXIrXZDZJDrZJFNJDZJFstXvJFQqXvJFCJEsJXQJqkhkNGBbDJdTRbYJMEBlDwXUJMEFiJFcfXNJDRcNJWMTBLJXC",
- // 8-kana words
- "BraFUtHBFSJFdbNBLJXVJQoYJNEBSJBEJfHSJHwXUJCJdAZJMGjaFVJXEJPNJBlEJfFiJFpFbFEJqIJBVJCrIBdHiJhOPFChvJVJZJNJWxGFNIFLueIBQJqUHEJfUFstOZJDrlXEASJRlXVJXSFwVJNJWD",
- // 9-kana words
- "QJEJNNJDQJEJIBSFQJEJxegBQJEJfHEPSJBmXEJFSJCDEJqXLXNJFQqXIcQsFNJFIFEJqXUJgFsJXIJBUJEJfHNFvJxEqXNJnXUJFQqD",
- // 10-kana words
- "IJBEJqXZJ"
- ];
- // Maps each character into its kana value (the index)
- var mapping = "~~AzB~X~a~KN~Q~D~S~C~G~E~Y~p~L~I~O~eH~g~V~hxyumi~~U~~Z~~v~~s~~dkoblPjfnqwMcRTr~W~~~F~~~~~Jt";
- var wordlist = null;
- function hex(word) {
- return (0, bytes_1.hexlify)((0, strings_1.toUtf8Bytes)(word));
- }
- var KiYoKu = "0xe3818de38284e3818f";
- var KyoKu = "0xe3818de38283e3818f";
- function loadWords(lang) {
- if (wordlist !== null) {
- return;
- }
- wordlist = [];
- // Transforms for normalizing (sort is a not quite UTF-8)
- var transform = {};
- // Delete the diacritic marks
- transform[(0, strings_1.toUtf8String)([227, 130, 154])] = false;
- transform[(0, strings_1.toUtf8String)([227, 130, 153])] = false;
- // Some simple transforms that sort out most of the order
- transform[(0, strings_1.toUtf8String)([227, 130, 133])] = (0, strings_1.toUtf8String)([227, 130, 134]);
- transform[(0, strings_1.toUtf8String)([227, 129, 163])] = (0, strings_1.toUtf8String)([227, 129, 164]);
- transform[(0, strings_1.toUtf8String)([227, 130, 131])] = (0, strings_1.toUtf8String)([227, 130, 132]);
- transform[(0, strings_1.toUtf8String)([227, 130, 135])] = (0, strings_1.toUtf8String)([227, 130, 136]);
- // Normalize words using the transform
- function normalize(word) {
- var result = "";
- for (var i = 0; i < word.length; i++) {
- var kana = word[i];
- var target = transform[kana];
- if (target === false) {
- continue;
- }
- if (target) {
- kana = target;
- }
- result += kana;
- }
- return result;
- }
- // Sort how the Japanese list is sorted
- function sortJapanese(a, b) {
- a = normalize(a);
- b = normalize(b);
- if (a < b) {
- return -1;
- }
- if (a > b) {
- return 1;
- }
- return 0;
- }
- // Load all the words
- for (var length_1 = 3; length_1 <= 9; length_1++) {
- var d = data[length_1 - 3];
- for (var offset = 0; offset < d.length; offset += length_1) {
- var word = [];
- for (var i = 0; i < length_1; i++) {
- var k = mapping.indexOf(d[offset + i]);
- word.push(227);
- word.push((k & 0x40) ? 130 : 129);
- word.push((k & 0x3f) + 128);
- }
- wordlist.push((0, strings_1.toUtf8String)(word));
- }
- }
- wordlist.sort(sortJapanese);
- // For some reason kyoku and kiyoku are flipped in node (!!).
- // The order SHOULD be:
- // - kyoku
- // - kiyoku
- // This should ignore "if", but that doesn't work here??
- /* istanbul ignore next */
- if (hex(wordlist[442]) === KiYoKu && hex(wordlist[443]) === KyoKu) {
- var tmp = wordlist[442];
- wordlist[442] = wordlist[443];
- wordlist[443] = tmp;
- }
- // Verify the computed list matches the official list
- /* istanbul ignore if */
- if (wordlist_1.Wordlist.check(lang) !== "0xcb36b09e6baa935787fd762ce65e80b0c6a8dabdfbc3a7f86ac0e2c4fd111600") {
- wordlist = null;
- throw new Error("BIP39 Wordlist for ja (Japanese) FAILED");
- }
- }
- var LangJa = /** @class */ (function (_super) {
- __extends(LangJa, _super);
- function LangJa() {
- return _super.call(this, "ja") || this;
- }
- LangJa.prototype.getWord = function (index) {
- loadWords(this);
- return wordlist[index];
- };
- LangJa.prototype.getWordIndex = function (word) {
- loadWords(this);
- return wordlist.indexOf(word);
- };
- LangJa.prototype.split = function (mnemonic) {
- wordlist_1.logger.checkNormalize();
- return mnemonic.split(/(?:\u3000| )+/g);
- };
- LangJa.prototype.join = function (words) {
- return words.join("\u3000");
- };
- return LangJa;
- }(wordlist_1.Wordlist));
- var langJa = new LangJa();
- exports.langJa = langJa;
- wordlist_1.Wordlist.register(langJa);
- },{"./wordlist":287,"@ethersproject/bytes":199,"@ethersproject/strings":266}],285:[function(_dereq_,module,exports){
- "use strict";
- var __extends = (this && this.__extends) || (function () {
- var extendStatics = function (d, b) {
- extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
- return extendStatics(d, b);
- };
- return function (d, b) {
- if (typeof b !== "function" && b !== null)
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.langKo = void 0;
- var strings_1 = _dereq_("@ethersproject/strings");
- var wordlist_1 = _dereq_("./wordlist");
- var data = [
- "OYAa",
- "ATAZoATBl3ATCTrATCl8ATDloATGg3ATHT8ATJT8ATJl3ATLlvATLn4ATMT8ATMX8ATMboATMgoAToLbAToMTATrHgATvHnAT3AnAT3JbAT3MTAT8DbAT8JTAT8LmAT8MYAT8MbAT#LnAUHT8AUHZvAUJXrAUJX8AULnrAXJnvAXLUoAXLgvAXMn6AXRg3AXrMbAX3JTAX3QbAYLn3AZLgvAZrSUAZvAcAZ8AaAZ8AbAZ8AnAZ8HnAZ8LgAZ8MYAZ8MgAZ8OnAaAboAaDTrAaFTrAaJTrAaJboAaLVoAaMXvAaOl8AaSeoAbAUoAbAg8AbAl4AbGnrAbMT8AbMXrAbMn4AbQb8AbSV8AbvRlAb8AUAb8AnAb8HgAb8JTAb8NTAb8RbAcGboAcLnvAcMT8AcMX8AcSToAcrAaAcrFnAc8AbAc8MgAfGgrAfHboAfJnvAfLV8AfLkoAfMT8AfMnoAfQb8AfScrAfSgrAgAZ8AgFl3AgGX8AgHZvAgHgrAgJXoAgJX8AgJboAgLZoAgLn4AgOX8AgoATAgoAnAgoCUAgoJgAgoLXAgoMYAgoSeAgrDUAgrJTAhrFnAhrLjAhrQgAjAgoAjJnrAkMX8AkOnoAlCTvAlCV8AlClvAlFg4AlFl6AlFn3AloSnAlrAXAlrAfAlrFUAlrFbAlrGgAlrOXAlvKnAlvMTAl3AbAl3MnAnATrAnAcrAnCZ3AnCl8AnDg8AnFboAnFl3AnHX4AnHbrAnHgrAnIl3AnJgvAnLXoAnLX4AnLbrAnLgrAnLhrAnMXoAnMgrAnOn3AnSbrAnSeoAnvLnAn3OnCTGgvCTSlvCTvAUCTvKnCTvNTCT3CZCT3GUCT3MTCT8HnCUCZrCULf8CULnvCU3HnCU3JUCY6NUCbDb8CbFZoCbLnrCboOTCboScCbrFnCbvLnCb8AgCb8HgCb$LnCkLfoClBn3CloDUDTHT8DTLl3DTSU8DTrAaDTrLXDTrLjDTrOYDTrOgDTvFXDTvFnDT3HUDT3LfDUCT9DUDT4DUFVoDUFV8DUFkoDUGgrDUJnrDULl8DUMT8DUMXrDUMX4DUMg8DUOUoDUOgvDUOg8DUSToDUSZ8DbDXoDbDgoDbGT8DbJn3DbLg3DbLn4DbMXrDbMg8DbOToDboJXGTClvGTDT8GTFZrGTLVoGTLlvGTLl3GTMg8GTOTvGTSlrGToCUGTrDgGTrJYGTrScGTtLnGTvAnGTvQgGUCZrGUDTvGUFZoGUHXrGULnvGUMT8GUoMgGXoLnGXrMXGXrMnGXvFnGYLnvGZOnvGZvOnGZ8LaGZ8LmGbAl3GbDYvGbDlrGbHX3GbJl4GbLV8GbLn3GbMn4GboJTGboRfGbvFUGb3GUGb4JnGgDX3GgFl$GgJlrGgLX6GgLZoGgLf8GgOXoGgrAgGgrJXGgrMYGgrScGgvATGgvOYGnAgoGnJgvGnLZoGnLg3GnLnrGnQn8GnSbrGnrMgHTClvHTDToHTFT3HTQT8HToJTHToJgHTrDUHTrMnHTvFYHTvRfHT8MnHT8SUHUAZ8HUBb4HUDTvHUoMYHXFl6HXJX6HXQlrHXrAUHXrMnHXrSbHXvFYHXvKXHX3LjHX3MeHYvQlHZrScHZvDbHbAcrHbFT3HbFl3HbJT8HbLTrHbMT8HbMXrHbMbrHbQb8HbSX3HboDbHboJTHbrFUHbrHgHbrJTHb8JTHb8MnHb8QgHgAlrHgDT3HgGgrHgHgrHgJTrHgJT8HgLX@HgLnrHgMT8HgMX8HgMboHgOnrHgQToHgRg3HgoHgHgrCbHgrFnHgrLVHgvAcHgvAfHnAloHnCTrHnCnvHnGTrHnGZ8HnGnvHnJT8HnLf8HnLkvHnMg8HnRTrITvFUITvFnJTAXrJTCV8JTFT3JTFT8JTFn4JTGgvJTHT8JTJT8JTJXvJTJl3JTJnvJTLX4JTLf8JTLhvJTMT8JTMXrJTMnrJTObrJTQT8JTSlvJT8DUJT8FkJT8MTJT8OXJT8OgJT8QUJT8RfJUHZoJXFT4JXFlrJXGZ8JXGnrJXLV8JXLgvJXMXoJXMX3JXNboJXPlvJXoJTJXoLkJXrAXJXrHUJXrJgJXvJTJXvOnJX4KnJYAl3JYJT8JYLhvJYQToJYrQXJY6NUJbAl3JbCZrJbDloJbGT8JbGgrJbJXvJbJboJbLf8JbLhrJbLl3JbMnvJbRg8JbSZ8JboDbJbrCZJbrSUJb3KnJb8LnJfRn8JgAXrJgCZrJgDTrJgGZrJgGZ8JgHToJgJT8JgJXoJgJgvJgLX4JgLZ3JgLZ8JgLn4JgMgrJgMn4JgOgvJgPX6JgRnvJgSToJgoCZJgoJbJgoMYJgrJXJgrJgJgrLjJg6MTJlCn3JlGgvJlJl8Jl4AnJl8FnJl8HgJnAToJnATrJnAbvJnDUoJnGnrJnJXrJnJXvJnLhvJnLnrJnLnvJnMToJnMT8JnMXvJnMX3JnMg8JnMlrJnMn4JnOX8JnST4JnSX3JnoAgJnoAnJnoJTJnoObJnrAbJnrAkJnrHnJnrJTJnrJYJnrOYJnrScJnvCUJnvFaJnvJgJnvJnJnvOYJnvQUJnvRUJn3FnJn3JTKnFl3KnLT6LTDlvLTMnoLTOn3LTRl3LTSb4LTSlrLToAnLToJgLTrAULTrAcLTrCULTrHgLTrMgLT3JnLULnrLUMX8LUoJgLVATrLVDTrLVLb8LVoJgLV8MgLV8RTLXDg3LXFlrLXrCnLXrLXLX3GTLX4GgLX4OYLZAXrLZAcrLZAgrLZAhrLZDXyLZDlrLZFbrLZFl3LZJX6LZJX8LZLc8LZLnrLZSU8LZoJTLZoJnLZrAgLZrAnLZrJYLZrLULZrMgLZrSkLZvAnLZvGULZvJeLZvOTLZ3FZLZ4JXLZ8STLZ8ScLaAT3LaAl3LaHT8LaJTrLaJT8LaJXrLaJgvLaJl4LaLVoLaMXrLaMXvLaMX8LbClvLbFToLbHlrLbJn4LbLZ3LbLhvLbMXrLbMnoLbvSULcLnrLc8HnLc8MTLdrMnLeAgoLeOgvLeOn3LfAl3LfLnvLfMl3LfOX8Lf8AnLf8JXLf8LXLgJTrLgJXrLgJl8LgMX8LgRZrLhCToLhrAbLhrFULhrJXLhvJYLjHTrLjHX4LjJX8LjLhrLjSX3LjSZ4LkFX4LkGZ8LkGgvLkJTrLkMXoLkSToLkSU8LkSZ8LkoOYLl3FfLl3MgLmAZrLmCbrLmGgrLmHboLmJnoLmJn3LmLfoLmLhrLmSToLnAX6LnAb6LnCZ3LnCb3LnDTvLnDb8LnFl3LnGnrLnHZvLnHgvLnITvLnJT8LnJX8LnJlvLnLf8LnLg6LnLhvLnLnoLnMXrLnMg8LnQlvLnSbrLnrAgLnrAnLnrDbLnrFkLnrJdLnrMULnrOYLnrSTLnvAnLnvDULnvHgLnvOYLnvOnLn3GgLn4DULn4JTLn4JnMTAZoMTAloMTDb8MTFT8MTJnoMTJnrMTLZrMTLhrMTLkvMTMX8MTRTrMToATMTrDnMTrOnMT3JnMT4MnMT8FUMT8FaMT8FlMT8GTMT8GbMT8GnMT8HnMT8JTMT8JbMT8OTMUCl8MUJTrMUJU8MUMX8MURTrMUSToMXAX6MXAb6MXCZoMXFXrMXHXrMXLgvMXOgoMXrAUMXrAnMXrHgMXrJYMXrJnMXrMTMXrMgMXrOYMXrSZMXrSgMXvDUMXvOTMX3JgMX3OTMX4JnMX8DbMX8FnMX8HbMX8HgMX8HnMX8LbMX8MnMX8OnMYAb8MYGboMYHTvMYHX4MYLTrMYLnvMYMToMYOgvMYRg3MYSTrMbAToMbAXrMbAl3MbAn8MbGZ8MbJT8MbJXrMbMXvMbMX8MbMnoMbrMUMb8AfMb8FbMb8FkMcJXoMeLnrMgFl3MgGTvMgGXoMgGgrMgGnrMgHT8MgHZrMgJnoMgLnrMgLnvMgMT8MgQUoMgrHnMgvAnMg8HgMg8JYMg8LfMloJnMl8ATMl8AXMl8JYMnAToMnAT4MnAZ8MnAl3MnAl4MnCl8MnHT8MnHg8MnJnoMnLZoMnLhrMnMXoMnMX3MnMnrMnOgvMnrFbMnrFfMnrFnMnrNTMnvJXNTMl8OTCT3OTFV8OTFn3OTHZvOTJXrOTOl3OT3ATOT3JUOT3LZOT3LeOT3MbOT8ATOT8AbOT8AgOT8MbOUCXvOUMX3OXHXvOXLl3OXrMUOXvDbOX6NUOX8JbOYFZoOYLbrOYLkoOYMg8OYSX3ObHTrObHT4ObJgrObLhrObMX3ObOX8Ob8FnOeAlrOeJT8OeJXrOeJnrOeLToOeMb8OgJXoOgLXoOgMnrOgOXrOgOloOgoAgOgoJbOgoMYOgoSTOg8AbOjLX4OjMnoOjSV8OnLVoOnrAgOn3DUPXQlrPXvFXPbvFTPdAT3PlFn3PnvFbQTLn4QToAgQToMTQULV8QURg8QUoJnQXCXvQbFbrQb8AaQb8AcQb8FbQb8MYQb8ScQeAlrQeLhrQjAn3QlFXoQloJgQloSnRTLnvRTrGURTrJTRUJZrRUoJlRUrQnRZrLmRZrMnRZrSnRZ8ATRZ8JbRZ8ScRbMT8RbST3RfGZrRfMX8RfMgrRfSZrRnAbrRnGT8RnvJgRnvLfRnvMTRn8AaSTClvSTJgrSTOXrSTRg3STRnvSToAcSToAfSToAnSToHnSToLjSToMTSTrAaSTrEUST3BYST8AgST8LmSUAZvSUAgrSUDT4SUDT8SUGgvSUJXoSUJXvSULTrSU8JTSU8LjSV8AnSV8JgSXFToSXLf8SYvAnSZrDUSZrMUSZrMnSZ8HgSZ8JTSZ8JgSZ8MYSZ8QUSaQUoSbCT3SbHToSbQYvSbSl4SboJnSbvFbSb8HbSb8JgSb8OTScGZrScHgrScJTvScMT8ScSToScoHbScrMTScvAnSeAZrSeAcrSeHboSeJUoSeLhrSeMT8SeMXrSe6JgSgHTrSkJnoSkLnvSk8CUSlFl3SlrSnSl8GnSmAboSmGT8SmJU8",
- "ATLnDlATrAZoATrJX4ATrMT8ATrMX4ATrRTrATvDl8ATvJUoATvMl8AT3AToAT3MX8AT8CT3AT8DT8AT8HZrAT8HgoAUAgFnAUCTFnAXoMX8AXrAT8AXrGgvAXrJXvAXrOgoAXvLl3AZvAgoAZvFbrAZvJXoAZvJl8AZvJn3AZvMX8AZvSbrAZ8FZoAZ8LZ8AZ8MU8AZ8OTvAZ8SV8AZ8SX3AbAgFZAboJnoAbvGboAb8ATrAb8AZoAb8AgrAb8Al4Ab8Db8Ab8JnoAb8LX4Ab8LZrAb8LhrAb8MT8Ab8OUoAb8Qb8Ab8ST8AcrAUoAcrAc8AcrCZ3AcrFT3AcrFZrAcrJl4AcrJn3AcrMX3AcrOTvAc8AZ8Ac8MT8AfAcJXAgoFn4AgoGgvAgoGnrAgoLc8AgoMXoAgrLnrAkrSZ8AlFXCTAloHboAlrHbrAlrLhrAlrLkoAl3CZrAl3LUoAl3LZrAnrAl4AnrMT8An3HT4BT3IToBX4MnvBb!Ln$CTGXMnCToLZ4CTrHT8CT3JTrCT3RZrCT#GTvCU6GgvCU8Db8CU8GZrCU8HT8CboLl3CbrGgrCbrMU8Cb8DT3Cb8GnrCb8LX4Cb8MT8Cb8ObrCgrGgvCgrKX4Cl8FZoDTrAbvDTrDboDTrGT6DTrJgrDTrMX3DTrRZrDTrRg8DTvAVvDTvFZoDT3DT8DT3Ln3DT4HZrDT4MT8DT8AlrDT8MT8DUAkGbDUDbJnDYLnQlDbDUOYDbMTAnDbMXSnDboAT3DboFn4DboLnvDj6JTrGTCgFTGTGgFnGTJTMnGTLnPlGToJT8GTrCT3GTrLVoGTrLnvGTrMX3GTrMboGTvKl3GZClFnGZrDT3GZ8DTrGZ8FZ8GZ8MXvGZ8On8GZ8ST3GbCnQXGbMbFnGboFboGboJg3GboMXoGb3JTvGb3JboGb3Mn6Gb3Qb8GgDXLjGgMnAUGgrDloGgrHX4GgrSToGgvAXrGgvAZvGgvFbrGgvLl3GgvMnvGnDnLXGnrATrGnrMboGnuLl3HTATMnHTAgCnHTCTCTHTrGTvHTrHTvHTrJX8HTrLl8HTrMT8HTrMgoHTrOTrHTuOn3HTvAZrHTvDTvHTvGboHTvJU8HTvLl3HTvMXrHTvQb4HT4GT6HT4JT8HT4Jb#HT8Al3HT8GZrHT8GgrHT8HX4HT8Jb8HT8JnoHT8LTrHT8LgvHT8SToHT8SV8HUoJUoHUoJX8HUoLnrHXrLZoHXvAl3HX3LnrHX4FkvHX4LhrHX4MXoHX4OnoHZrAZ8HZrDb8HZrGZ8HZrJnrHZvGZ8HZvLnvHZ8JnvHZ8LhrHbCXJlHbMTAnHboJl4HbpLl3HbrJX8HbrLnrHbrMnvHbvRYrHgoSTrHgrFV8HgrGZ8HgrJXoHgrRnvHgvBb!HgvGTrHgvHX4HgvHn!HgvLTrHgvSU8HnDnLbHnFbJbHnvDn8Hn6GgvHn!BTvJTCTLnJTQgFnJTrAnvJTrLX4JTrOUoJTvFn3JTvLnrJTvNToJT3AgoJT3Jn4JT3LhvJT3ObrJT8AcrJT8Al3JT8JT8JT8JnoJT8LX4JT8LnrJT8MX3JT8Rg3JT8Sc8JUoBTvJU8AToJU8GZ8JU8GgvJU8JTrJU8JXrJU8JnrJU8LnvJU8ScvJXHnJlJXrGgvJXrJU8JXrLhrJXrMT8JXrMXrJXrQUoJXvCTvJXvGZ8JXvGgrJXvQT8JX8Ab8JX8DT8JX8GZ8JX8HZvJX8LnrJX8MT8JX8MXoJX8MnvJX8ST3JYGnCTJbAkGbJbCTAnJbLTAcJboDT3JboLb6JbrAnvJbrCn3JbrDl8JbrGboJbrIZoJbrJnvJbrMnvJbrQb4Jb8RZrJeAbAnJgJnFbJgScAnJgrATrJgvHZ8JgvMn4JlJlFbJlLiQXJlLjOnJlRbOlJlvNXoJlvRl3Jl4AcrJl8AUoJl8MnrJnFnMlJnHgGbJnoDT8JnoFV8JnoGgvJnoIT8JnoQToJnoRg3JnrCZ3JnrGgrJnrHTvJnrLf8JnrOX8JnvAT3JnvFZoJnvGT8JnvJl4JnvMT8JnvMX8JnvOXrJnvPX6JnvSX3JnvSZrJn3MT8Jn3MX8Jn3RTrLTATKnLTJnLTLTMXKnLTRTQlLToGb8LTrAZ8LTrCZ8LTrDb8LTrHT8LT3PX6LT4FZoLT$CTvLT$GgrLUvHX3LVoATrLVoAgoLVoJboLVoMX3LVoRg3LV8CZ3LV8FZoLV8GTvLXrDXoLXrFbrLXvAgvLXvFlrLXvLl3LXvRn6LX4Mb8LX8GT8LYCXMnLYrMnrLZoSTvLZrAZvLZrAloLZrFToLZrJXvLZrJboLZrJl4LZrLnrLZrMT8LZrOgvLZrRnvLZrST4LZvMX8LZvSlvLZ8AgoLZ8CT3LZ8JT8LZ8LV8LZ8LZoLZ8Lg8LZ8SV8LZ8SbrLZ$HT8LZ$Mn4La6CTvLbFbMnLbRYFTLbSnFZLboJT8LbrAT9LbrGb3LbrQb8LcrJX8LcrMXrLerHTvLerJbrLerNboLgrDb8LgrGZ8LgrHTrLgrMXrLgrSU8LgvJTrLgvLl3Lg6Ll3LhrLnrLhrMT8LhvAl4LiLnQXLkoAgrLkoJT8LkoJn4LlrSU8Ll3FZoLl3HTrLl3JX8Ll3JnoLl3LToLmLeFbLnDUFbLnLVAnLnrATrLnrAZoLnrAb8LnrAlrLnrGgvLnrJU8LnrLZrLnrLhrLnrMb8LnrOXrLnrSZ8LnvAb4LnvDTrLnvDl8LnvHTrLnvHbrLnvJT8LnvJU8LnvJbrLnvLhvLnvMX8LnvMb8LnvNnoLnvSU8Ln3Al3Ln4FZoLn4GT6Ln4JgvLn4LhrLn4MT8Ln4SToMToCZrMToJX8MToLX4MToLf8MToRg3MTrEloMTvGb6MT3BTrMT3Lb6MT8AcrMT8AgrMT8GZrMT8JnoMT8LnrMT8MX3MUOUAnMXAbFnMXoAloMXoJX8MXoLf8MXoLl8MXrAb8MXrDTvMXrGT8MXrGgrMXrHTrMXrLf8MXrMU8MXrOXvMXrQb8MXvGT8MXvHTrMXvLVoMX3AX3MX3Jn3MX3LhrMX3MX3MX4AlrMX4OboMX8GTvMX8GZrMX8GgrMX8JT8MX8JX8MX8LhrMX8MT8MYDUFbMYMgDbMbGnFfMbvLX4MbvLl3Mb8Mb8Mb8ST4MgGXCnMg8ATrMg8AgoMg8CZrMg8DTrMg8DboMg8HTrMg8JgrMg8LT8MloJXoMl8AhrMl8JT8MnLgAUMnoJXrMnoLX4MnoLhrMnoMT8MnrAl4MnrDb8MnrOTvMnrOgvMnrQb8MnrSU8MnvGgrMnvHZ8Mn3MToMn4DTrMn4LTrMn4Mg8NnBXAnOTFTFnOToAToOTrGgvOTrJX8OT3JXoOT6MTrOT8GgrOT8HTpOT8MToOUoHT8OUoJT8OUoLn3OXrAgoOXrDg8OXrMT8OXvSToOX6CTvOX8CZrOX8OgrOb6HgvOb8AToOb8MT8OcvLZ8OgvAlrOgvHTvOgvJTrOgvJnrOgvLZrOgvLn4OgvMT8OgvRTrOg8AZoOg8DbvOnrOXoOnvJn4OnvLhvOnvRTrOn3GgoOn3JnvOn6JbvOn8OTrPTGYFTPbBnFnPbGnDnPgDYQTPlrAnvPlrETvPlrLnvPlrMXvPlvFX4QTMTAnQTrJU8QYCnJlQYJlQlQbGTQbQb8JnrQb8LZoQb8LnvQb8MT8Qb8Ml8Qb8ST4QloAl4QloHZvQloJX8QloMn8QnJZOlRTrAZvRTrDTrRTvJn4RTvLhvRT4Jb8RZrAZrRZ8AkrRZ8JU8RZ8LV8RZ8LnvRbJlQXRg3GboRg3MnvRg8AZ8Rg8JboRg8Jl4RnLTCbRnvFl3RnvQb8SToAl4SToCZrSToFZoSToHXrSToJU8SToJgvSToJl4SToLhrSToMX3STrAlvSTrCT9STrCgrSTrGgrSTrHXrSTrHboSTrJnoSTrNboSTvLnrST4AZoST8Ab8ST8JT8SUoJn3SU6HZ#SU6JTvSU8Db8SU8HboSU8LgrSV8JT8SZrAcrSZrAl3SZrJT8SZrJnvSZrMT8SZvLUoSZ4FZoSZ8JnoSZ8RZrScoLnrScoMT8ScoMX8ScrAT4ScrAZ8ScrLZ8ScrLkvScvDb8ScvLf8ScvNToSgrFZrShvKnrSloHUoSloLnrSlrMXoSl8HgrSmrJUoSn3BX6",
- "ATFlOn3ATLgrDYAT4MTAnAT8LTMnAYJnRTrAbGgJnrAbLV8LnAbvNTAnAeFbLg3AgOYMXoAlQbFboAnDboAfAnJgoJTBToDgAnBUJbAl3BboDUAnCTDlvLnCTFTrSnCYoQTLnDTwAbAnDUDTrSnDUHgHgrDX8LXFnDbJXAcrETvLTLnGTFTQbrGTMnGToGT3DUFbGUJlPX3GbQg8LnGboJbFnGb3GgAYGgAg8ScGgMbAXrGgvAbAnGnJTLnvGnvATFgHTDT6ATHTrDlJnHYLnMn8HZrSbJTHZ8LTFnHbFTJUoHgSeMT8HgrLjAnHgvAbAnHlFUrDlHnDgvAnHnHTFT3HnQTGnrJTAaMXvJTGbCn3JTOgrAnJXvAXMnJbMg8SnJbMnRg3Jb8LTMnJnAl3OnJnGYrQlJnJlQY3LTDlCn3LTJjLg3LTLgvFXLTMg3GTLV8HUOgLXFZLg3LXNXrMnLX8QXFnLX9AlMYLYLXPXrLZAbJU8LZDUJU8LZMXrSnLZ$AgFnLaPXrDULbFYrMnLbMn8LXLboJgJgLeFbLg3LgLZrSnLgOYAgoLhrRnJlLkCTrSnLkOnLhrLnFX%AYLnFZoJXLnHTvJbLnLloAbMTATLf8MTHgJn3MTMXrAXMT3MTFnMUITvFnMXFX%AYMXMXvFbMXrFTDbMYAcMX3MbLf8SnMb8JbFnMgMXrMTMgvAXFnMgvGgCmMnAloSnMnFnJTrOXvMXSnOX8HTMnObJT8ScObLZFl3ObMXCZoPTLgrQXPUFnoQXPU3RXJlPX3RkQXPbrJXQlPlrJbFnQUAhrDbQXGnCXvQYLnHlvQbLfLnvRTOgvJbRXJYrQlRYLnrQlRbLnrQlRlFT8JlRlFnrQXSTClCn3STHTrAnSTLZQlrSTMnGTrSToHgGbSTrGTDnSTvGXCnST3HgFbSU3HXAXSbAnJn3SbFT8LnScLfLnv",
- "AT3JgJX8AT8FZoSnAT8JgFV8AT8LhrDbAZ8JT8DbAb8GgLhrAb8SkLnvAe8MT8SnAlMYJXLVAl3GYDTvAl3LfLnvBUDTvLl3CTOn3HTrCT3DUGgrCU8MT8AbCbFTrJUoCgrDb8MTDTLV8JX8DTLnLXQlDT8LZrSnDUQb8FZ8DUST4JnvDb8ScOUoDj6GbJl4GTLfCYMlGToAXvFnGboAXvLnGgAcrJn3GgvFnSToGnLf8JnvGn#HTDToHTLnFXJlHTvATFToHTvHTDToHTvMTAgoHT3STClvHT4AlFl6HT8HTDToHUoDgJTrHUoScMX3HbRZrMXoHboJg8LTHgDb8JTrHgMToLf8HgvLnLnoHnHn3HT4Hn6MgvAnJTJU8ScvJT3AaQT8JT8HTrAnJXrRg8AnJbAloMXoJbrATFToJbvMnoSnJgDb6GgvJgDb8MXoJgSX3JU8JguATFToJlPYLnQlJlQkDnLbJlQlFYJlJl8Lf8OTJnCTFnLbJnLTHXMnJnLXGXCnJnoFfRg3JnrMYRg3Jn3HgFl3KT8Dg8LnLTRlFnPTLTvPbLbvLVoSbrCZLXMY6HT3LXNU7DlrLXNXDTATLX8DX8LnLZDb8JU8LZMnoLhrLZSToJU8LZrLaLnrLZvJn3SnLZ8LhrSnLaJnoMT8LbFlrHTvLbrFTLnrLbvATLlvLb6OTFn3LcLnJZOlLeAT6Mn4LeJT3ObrLg6LXFlrLhrJg8LnLhvDlPX4LhvLfLnvLj6JTFT3LnFbrMXoLnQluCTvLnrQXCY6LnvLfLnvLnvMgLnvLnvSeLf8MTMbrJn3MT3JgST3MT8AnATrMT8LULnrMUMToCZrMUScvLf8MXoDT8SnMX6ATFToMX8AXMT8MX8FkMT8MX8HTrDUMX8ScoSnMYJT6CTvMgAcrMXoMg8SToAfMlvAXLg3MnFl3AnvOT3AnFl3OUoATHT8OU3RnLXrOXrOXrSnObPbvFn6Og8HgrSnOg8OX8DbPTvAgoJgPU3RYLnrPXrDnJZrPb8CTGgvPlrLTDlvPlvFUJnoQUvFXrQlQeMnoAl3QlrQlrSnRTFTrJUoSTDlLiLXSTFg6HT3STJgoMn4STrFTJTrSTrLZFl3ST4FnMXoSUrDlHUoScvHTvSnSfLkvMXo",
- "AUoAcrMXoAZ8HboAg8AbOg6ATFgAg8AloMXoAl3AT8JTrAl8MX8MXoCT3SToJU8Cl8Db8MXoDT8HgrATrDboOT8MXoGTOTrATMnGT8LhrAZ8GnvFnGnQXHToGgvAcrHTvAXvLl3HbrAZoMXoHgBlFXLg3HgMnFXrSnHgrSb8JUoHn6HT8LgvITvATrJUoJUoLZrRnvJU8HT8Jb8JXvFX8QT8JXvLToJTrJYrQnGnQXJgrJnoATrJnoJU8ScvJnvMnvMXoLTCTLgrJXLTJlRTvQlLbRnJlQYvLbrMb8LnvLbvFn3RnoLdCVSTGZrLeSTvGXCnLg3MnoLn3MToLlrETvMT8SToAl3MbrDU6GTvMb8LX4LhrPlrLXGXCnSToLf8Rg3STrDb8LTrSTvLTHXMnSb3RYLnMnSgOg6ATFg",
- "HUDlGnrQXrJTrHgLnrAcJYMb8DULc8LTvFgGnCk3Mg8JbAnLX4QYvFYHnMXrRUoJnGnvFnRlvFTJlQnoSTrBXHXrLYSUJgLfoMT8Se8DTrHbDb",
- "AbDl8SToJU8An3RbAb8ST8DUSTrGnrAgoLbFU6Db8LTrMg8AaHT8Jb8ObDl8SToJU8Pb3RlvFYoJl"
- ];
- var codes = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*";
- function getHangul(code) {
- if (code >= 40) {
- code = code + 168 - 40;
- }
- else if (code >= 19) {
- code = code + 97 - 19;
- }
- return (0, strings_1.toUtf8String)([225, (code >> 6) + 132, (code & 0x3f) + 128]);
- }
- var wordlist = null;
- function loadWords(lang) {
- if (wordlist != null) {
- return;
- }
- wordlist = [];
- data.forEach(function (data, length) {
- length += 4;
- for (var i = 0; i < data.length; i += length) {
- var word = "";
- for (var j = 0; j < length; j++) {
- word += getHangul(codes.indexOf(data[i + j]));
- }
- wordlist.push(word);
- }
- });
- wordlist.sort();
- // Verify the computed list matches the official list
- /* istanbul ignore if */
- if (wordlist_1.Wordlist.check(lang) !== "0xf9eddeace9c5d3da9c93cf7d3cd38f6a13ed3affb933259ae865714e8a3ae71a") {
- wordlist = null;
- throw new Error("BIP39 Wordlist for ko (Korean) FAILED");
- }
- }
- var LangKo = /** @class */ (function (_super) {
- __extends(LangKo, _super);
- function LangKo() {
- return _super.call(this, "ko") || this;
- }
- LangKo.prototype.getWord = function (index) {
- loadWords(this);
- return wordlist[index];
- };
- LangKo.prototype.getWordIndex = function (word) {
- loadWords(this);
- return wordlist.indexOf(word);
- };
- return LangKo;
- }(wordlist_1.Wordlist));
- var langKo = new LangKo();
- exports.langKo = langKo;
- wordlist_1.Wordlist.register(langKo);
- },{"./wordlist":287,"@ethersproject/strings":266}],286:[function(_dereq_,module,exports){
- "use strict";
- var __extends = (this && this.__extends) || (function () {
- var extendStatics = function (d, b) {
- extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
- return extendStatics(d, b);
- };
- return function (d, b) {
- if (typeof b !== "function" && b !== null)
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.langZhTw = exports.langZhCn = void 0;
- var strings_1 = _dereq_("@ethersproject/strings");
- var wordlist_1 = _dereq_("./wordlist");
- var data = "}aE#4A=Yv&co#4N#6G=cJ&SM#66|/Z#4t&kn~46#4K~4q%b9=IR#7l,mB#7W_X2*dl}Uo~7s}Uf&Iw#9c&cw~6O&H6&wx&IG%v5=IQ~8a&Pv#47$PR&50%Ko&QM&3l#5f,D9#4L|/H&tQ;v0~6n]nN<di,AM=W5%QO&ka&ua,hM^tm=zV=JA=wR&+X]7P&NB#4J#5L|/b[dA}tJ<Do&6m&u2[U1&Kb.HM&mC=w0&MW<rY,Hq#6M}QG,13&wP}Jp]Ow%ue&Kg<HP<D9~4k~9T&I2_c6$9T#9/[C5~7O~4a=cs&O7=KK=An&l9$6U$8A&uD&QI|/Y&bg}Ux&F2#6b}E2&JN&kW&kp=U/&bb=Xl<Cj}k+~5J#6L&5z&9i}b4&Fo,ho(X0_g3~4O$Fz&QE<HN=Ww]6/%GF-Vw=tj&/D&PN#9g=YO}cL&Of&PI~5I&Ip=vU=IW#9G;0o-wU}ss&QR<BT&R9=tk$PY_dh&Pq-yh]7T,nj.Xu=EP&76=cI&Fs*Xg}z7$Gb&+I=DF,AF=cA}rL#7j=Dz&3y<Aa$52=PQ}b0(iY$Fa}oL&xV#6U=ec=WZ,xh%RY<dp#9N&Fl&44=WH*A7=sh&TB&8P=07;u+&PK}uh}J5#72)V/=xC,AB$k0&f6;1E|+5=1B,3v]6n&wR%b+&xx]7f=Ol}fl;+D^wG]7E;nB;uh^Ir&l5=JL,nS=cf=g5;u6|/Q$Gc=MH%Hg#5d%M6^86=U+$Gz,l/,ir^5y&Ba&/F-IY&FI&be%IZ#77&PW_Nu$kE(Yf&NX]7Z,Jy&FJ(Xo&Nz#/d=y7&MX<Ag}Z+;nE]Dt(iG#4D=13&Pj~4c%v8&Zo%OL&/X#4W<HR&ie~6J_1O(Y2=y5=Ad*cv_eB#6k&PX:BU#7A;uk&Ft&Fx_dD=U2;vB=U5=4F}+O&GN.HH:9s=b0%NV(jO&IH=JT}Z9=VZ<Af,Kx^4m&uJ%c6,6r;9m#+L}cf%Kh&F3~4H=vP}bu,Hz|++,1w]nv}k6;uu$jw*Kl*WX&uM[x7&Fr[m7$NO&QN]hu=JN}nR^8g#/h(ps|KC;vd}xz=V0}p6&FD$G1#7K<bG_4p~8g&cf;u4=tl}+k%5/}fz;uw<cA=u1}gU}VM=LJ=eX&+L&Pr#4U}p2:nC,2K]7H:jF&9x}uX#9O=MB<fz~8X~5m&4D&kN&u5%E/(h7(ZF&VG<de(qM|/e-Wt=3x(a+,/R]f/&ND$Ro&nU}0g=KA%kH&NK$Ke<dS}cB&IX~5g$TN]6m=Uv,Is&Py=Ef%Kz#+/%bi&+A<F4$OG&4C&FL#9V<Zk=2I_eE&6c]nw&kq$HG}y+&A8$P3}OH=XP]70%IS(AJ_gH%GZ&tY&AZ=vb~6y&/r=VI=Wv<Zi=fl=xf&eL}c8}OL=MJ=g8$F7=YT}9u=0+^xC}JH&nL^N0~4T]K2,Cy%OC#6s;vG(AC^xe^cG&MF}Br#9P;wD-7h$O/&xA}Fn^PC]6i]7G&8V$Qs;vl(TB~73~4l<mW&6V=2y&uY&+3)aP}XF;LP&kx$wU=t7;uy<FN&lz)7E=Oo*Y+;wI}9q}le;J6&Ri&4t&Qr#8B=cb&vG=J5|Ql(h5<Yy~4+}QD,Lx=wn%K/&RK=dO&Pw,Q9=co%4u;9u}g0@6a^4I%b0=zo|/c&tX=dQ=OS#+b=yz_AB&wB&Pm=W9$HP_gR=62=AO=ti=hI,oA&jr&dH=tm&b6$P2(x8=zi;nG~7F;05]0n[Ix&3m}rg=Xp=cd&uz]7t;97=cN;vV<jf&FF&F1=6Q&Ik*Kk&P4,2z=fQ]7D&3u,H0=d/}Uw<ZN<7R}Kv;0f$H7,MD]7n$F0#88~9Z%da=by;+T#/u=VF&fO&kr^kf<AB]sU,I5$Ng&Pz;0i&QD&vM=Yl:BM;nJ_xJ]U7&Kf&30,3f|Z9*dC)je_jA&Q4&Kp$NH(Yz#6S&Id%Ib=KX,AD=KV%dP}tW&Pk^+E_Ni=cq,3R}VZ(Si=b+}rv;0j}rZ]uA,/w(Sx&Jv$w9&4d&wE,NJ$Gy=J/]Ls#7k<ZQ<Y/&uj]Ov$PM;v3,2F&+u:up=On&3e,Jv;90=J+&Qm]6q}bK#+d~8Y(h2]hA;99&AS=I/}qB&dQ}yJ-VM}Vl&ui,iB&G3|Dc]7d=eQ%dX%JC_1L~4d^NP;vJ&/1)ZI#7N]9X[bQ&PL=0L(UZ,Lm&kc&IR}n7(iR<AQ<dg=33=vN}ft}au]7I,Ba=x9=dR~6R&Tq=Xi,3d$Nr&Bc}DI&ku&vf]Dn,/F&iD,Ll&Nw=0y&I7=Ls=/A&tU=Qe}Ua&uk&+F=g4=gh=Vj#+1&Qn}Uy*44#5F,Pc&Rz*Xn=oh=5W;0n_Nf(iE<Y7=vr=Zu]oz#5Z%mI=kN=Bv_Jp(T2;vt_Ml<FS&uI=L/&6P]64$M7}86<bo%QX(SI%IY&VK=Al&Ux;vv;ut*E/%uh<ZE|O3,M2(yc]yu=Wk&tp:Ex}hr,Cl&WE)+Z=8U}I2_4Q,hA_si=iw=OM=tM=yZ%Ia=U7;wT}b+;uo=Za}yS!5x}HD}fb#5O_dA;Nv%uB(yB;01(Sf}Fk;v7}Pt#8v<mZ#7L,/r&Pl~4w&f5=Ph$Fw_LF&8m,bL=yJ&BH}p/*Jn}tU~5Q;wB(h6]Df]8p^+B;E4&Wc=d+;Ea&bw$8C&FN,DM=Yf}mP~5w=fT#6V=mC=Fi=AV}jB&AN}lW}aH#/D)dZ;hl;vE}/7,CJ;31&w8,hj%u9_Js=jJ&4M~8k=TN&eC}nL&uc-wi&lX}dj=Mv=e2#6u=cr$uq$6G]8W}Jb:nm=Yg<b3(UA;vX&6n&xF=KT,jC,De&R8&oY=Zv&oB]7/=Z2&Oa}bf,hh(4h^tZ&72&Nx;D2&xL~5h~40)ZG)h+=OJ&RA]Bv$yB=Oq=df,AQ%Jn}OJ;11,3z&Tl&tj;v+^Hv,Dh(id=s+]7N&N3)9Q~8f,S4=uW=w4&uX,LX&3d]CJ&yp&8x<b2_do&lP=y/<cy_dG=Oi=7R(VH(lt_1T,Iq_AA;12^6T%k6#8K[B1{oO<AU[Bt;1b$9S&Ps<8T=St{bY,jB(Zp&63&Uv$9V,PM]6v&Af}zW[bW_oq}sm}nB&Kq&gC&ff_eq_2m&5F&TI}rf}Gf;Zr_z9;ER&jk}iz_sn<BN~+n&vo=Vi%97|ZR=Wc,WE&6t]6z%85(ly#84=KY)6m_5/=aX,N3}Tm&he&6K]tR_B2-I3;u/&hU&lH<AP=iB&IA=XL;/5&Nh=wv<BH#79=vS=zl<AA=0X_RG}Bw&9p$NW,AX&kP_Lp&/Z(Tc]Mu}hs#6I}5B&cI<bq&H9#6m=K9}vH(Y1(Y0#4B&w6,/9&gG<bE,/O=zb}I4_l8<B/;wL%Qo<HO[Mq=XX}0v&BP&F4(mG}0i}nm,EC=9u{I3,xG&/9=JY*DK&hR)BX=EI=cx=b/{6k}yX%A+&wa}Xb=la;wi^lL;0t}jo&Qb=xg=XB}iO<qo{bR=NV&8f=a0&Jy;0v=uK)HK;vN#6h&jB(h/%ud&NI%wY.X7=Pt}Cu-uL&Gs_hl%mH,tm]78=Lb^Q0#7Y=1u<Bt&+Q=Co_RH,w3;1e}ux<aU;ui}U3&Q5%bt]63&UQ|0l&uL}O7&3o,AV&dm|Nj(Xt*5+(Uu&Hh(p7(UF=VR=Bp^Jl&Hd[ix)9/=Iq]C8<67]66}mB%6f}bb}JI]8T$HA}db=YM&pa=2J}tS&Y0=PS&y4=cX$6E,hX,XP&nR;04,FQ&l0&Vm_Dv#5Y~8Z=Bi%MA]6x=JO:+p,Az&9q,Hj~6/}SD=K1:EJ}nA;Qo#/E]9R,Ie&6X%W3]61&v4=xX_MC=0q;06(Xq=fs}IG}Dv=0l}o7$iZ;9v&LH&DP-7a&OY,SZ,Kz,Cv&dh=fx|Nh,F/~7q=XF&w+;9n&Gw;0h}Z7<7O&JK(S7&LS<AD<ac=wo<Dt&zw%4B=4v#8P;9o~6p*vV=Tm,Or&I6=1q}nY=P0=gq&Bl&Uu,Ch%yb}UY=zh}dh}rl(T4_xk(YA#8R*xH,IN}Jn]7V}C4&Ty}j3]7p=cL=3h&wW%Qv<Z3=f0&RI&+S(ic_zq}oN&/Y=z1;Td=LW=0e=OI(Vc,+b^ju(UL;0r:Za%8v=Rp=zw&58&73&wK}qX]6y&8E)a2}WR=wP^ur&nQ<cH}Re=Aq&wk}Q0&+q=PP,Gc|/d^k5,Fw]8Y}Pg]p3=ju=ed}r5_yf&Cs]7z$/G<Cm&Jp&54_1G_gP_Ll}JZ;0u]k8_7k(Sg]65{9i=LN&Sx&WK,iW&fD&Lk{9a}Em-9c#8N&io=sy]8d&nT&IK(lx#7/$lW(Td<s8~49,3o<7Y=MW(T+_Jr&Wd,iL}Ct=xh&5V;v4&8n%Kx=iF&l2_0B{B+,If(J0,Lv;u8=Kx-vB=HC&vS=Z6&fU&vE^xK;3D=4h=MR#45:Jw;0d}iw=LU}I5=I0]gB*im,K9}GU,1k_4U&Tt=Vs(iX&lU(TF#7y,ZO}oA&m5#5P}PN}Uz=hM<B1&FB<aG,e6~7T<tP(UQ_ZT=wu&F8)aQ]iN,1r_Lo&/g:CD}84{J1_Ki&Na&3n$jz&FE=dc;uv;va}in}ll=fv(h1&3h}fp=Cy}BM(+E~8m}lo%v7=hC(T6$cj=BQ=Bw(DR,2j=Ks,NS|F+;00=fU=70}Mb(YU;+G&m7&hr=Sk%Co]t+(X5_Jw}0r}gC(AS-IP&QK<Z2#8Q$WC]WX}T2&pG_Ka,HC=R4&/N;Z+;ch(C7,D4$3p_Mk&B2$8D=n9%Ky#5z(CT&QJ#7B]DC]gW}nf~5M;Iw#80}Tc_1F#4Z-aC}Hl=ph=fz,/3=aW}JM}nn;DG;vm}wn,4P}T3;wx&RG$u+}zK=0b;+J_Ek{re<aZ=AS}yY#5D]7q,Cp}xN=VP*2C}GZ}aG~+m_Cs=OY#6r]6g<GS}LC(UB=3A=Bo}Jy<c4}Is;1P<AG}Op<Z1}ld}nS=1Z,yM&95&98=CJ(4t:2L$Hk=Zo}Vc;+I}np&N1}9y=iv}CO*7p=jL)px]tb^zh&GS&Vl%v/;vR=14=zJ&49|/f]hF}WG;03=8P}o/&Gg&rp;DB,Kv}Ji&Pb;aA^ll(4j%yt}+K$Ht#4y&hY]7Y<F1,eN}bG(Uh%6Z]t5%G7;+F_RE;it}tL=LS&Da=Xx(S+(4f=8G=yI}cJ}WP=37=jS}pX}hd)fp<A8=Jt~+o$HJ=M6}iX=g9}CS=dv=Cj(mP%Kd,xq|+9&LD(4/=Xm&QP=Lc}LX&fL;+K=Op(lu=Qs.qC:+e&L+=Jj#8w;SL]7S(b+#4I=c1&nG_Lf&uH;+R)ZV<bV%B/,TE&0H&Jq&Ah%OF&Ss(p2,Wv&I3=Wl}Vq;1L&lJ#9b_1H=8r=b8=JH(SZ=hD=J2#7U,/U#/X~6P,FU<eL=jx,mG=hG=CE&PU=Se(qX&LY=X6=y4&tk&QQ&tf=4g&xI}W+&mZ=Dc#7w}Lg;DA;wQ_Kb(cJ=hR%yX&Yb,hw{bX_4X;EP;1W_2M}Uc=b5(YF,CM&Tp^OJ{DD]6s=vF=Yo~8q}XH}Fu%P5(SJ=Qt;MO]s8<F3&B3&8T(Ul-BS*dw&dR<87}/8]62$PZ]Lx<Au}9Q]7c=ja=KR,Go,Us&v6(qk}pG&G2=ev^GM%w4&H4]7F&dv]J6}Ew:9w=sj-ZL}Ym$+h(Ut(Um~4n=Xs(U7%eE=Qc_JR<CA#6t<Fv|/I,IS,EG<F2(Xy$/n<Fa(h9}+9_2o&N4#7X<Zq|+f_Dp=dt&na,Ca=NJ)jY=8C=YG=s6&Q+<DO}D3=xB&R1(lw;Qn<bF(Cu|/B}HV=SS&n7,10&u0]Dm%A6^4Q=WR(TD=Xo<GH,Rj(l8)bP&n/=LM&CF,F5&ml=PJ;0k=LG=tq,Rh,D6@4i=1p&+9=YC%er_Mh;nI;0q=Fw]80=xq=FM$Gv;v6&nc;wK%H2&Kj;vs,AA=YP,66}bI(qR~5U=6q~4b$Ni=K5.X3$So&Iu(p+]8G=Cf=RY(TS_O3(iH&57=fE=Dg_Do#9z#7H;FK{qd_2k%JR}en&gh_z8;Rx}9p<cN_Ne,DO;LN_7o~/p=NF=5Y}gN<ce<C1,QE]Wv=3u<BC}GK]yq}DY&u/_hj=II(pz&rC,jV&+Z}ut=NQ;Cg-SR_ZS,+o=u/;Oy_RK_QF(Fx&xP}Wr&TA,Uh&g1=yr{ax[VF$Pg(YB;Ox=Vy;+W(Sp}XV%dd&33(l/]l4#4Y}OE=6c=bw(A7&9t%wd&N/&mo,JH&Qe)fm=Ao}fu=tH";
- var deltaData = "FAZDC6BALcLZCA+GBARCW8wNCcDDZ8LVFBOqqDUiou+M42TFAyERXFb7EjhP+vmBFpFrUpfDV2F7eB+eCltCHJFWLFCED+pWTojEIHFXc3aFn4F68zqjEuKidS1QBVPDEhE7NA4mhMF7oThD49ot3FgtzHFCK0acW1x8DH1EmLoIlrWFBLE+y5+NA3Cx65wJHTaEZVaK1mWAmPGxgYCdxwOjTDIt/faOEhTl1vqNsKtJCOhJWuio2g07KLZEQsFBUpNtwEByBgxFslFheFbiEPvi61msDvApxCzB6rBCzox7joYA5UdDc+Cb4FSgIabpXFAj3bjkmFAxCZE+mD/SFf/0ELecYCt3nLoxC6WEZf2tKDB4oZvrEmqFkKk7BwILA7gtYBpsTq//D4jD0F0wEB9pyQ1BD5Ba0oYHDI+sbDFhvrHXdDHfgFEIJLi5r8qercNFBgFLC4bo5ERJtamWBDFy73KCEb6M8VpmEt330ygCTK58EIIFkYgF84gtGA9Uyh3m68iVrFbWFbcbqiCYHZ9J1jeRPbL8yswhMiDbhEhdNoSwFbZrLT740ABEqgCkO8J1BLd1VhKKR4sD1yUo0z+FF59Mvg71CFbyEhbHSFBKEIKyoQNgQppq9T0KAqePu0ZFGrXOHdKJqkoTFhYvpDNyuuznrN84thJbsCoO6Cu6Xlvntvy0QYuAExQEYtTUBf3CoCqwgGFZ4u1HJFzDVwEy3cjcpV4QvsPaBC3rCGyCF23o4K3pp2gberGgFEJEHo4nHICtyKH2ZqyxhN05KBBJIQlKh/Oujv/DH32VrlqFdIFC7Fz9Ct4kaqFME0UETLprnN9kfy+kFmtQBB0+5CFu0N9Ij8l/VvJDh2oq3hT6EzjTHKFN7ZjZwoTsAZ4Exsko6Fpa6WC+sduz8jyrLpegTv2h1EBeYpLpm2czQW0KoCcS0bCVXCmuWJDBjN1nQNLdF58SFJ0h7i3pC3oEOKy/FjBklL70XvBEEIWp2yZ04xObzAWDDJG7f+DbqBEA7LyiR95j7MDVdDViz2RE5vWlBMv5e4+VfhP3aXNPhvLSynb9O2x4uFBV+3jqu6d5pCG28/sETByvmu/+IJ0L3wb4rj9DNOLBF6XPIODr4L19U9RRofAG6Nxydi8Bki8BhGJbBAJKzbJxkZSlF9Q2Cu8oKqggB9hBArwLLqEBWEtFowy8XK8bEyw9snT+BeyFk1ZCSrdmgfEwFePTgCjELBEnIbjaDDPJm36rG9pztcEzT8dGk23SBhXBB1H4z+OWze0ooFzz8pDBYFvp9j9tvFByf9y4EFdVnz026CGR5qMr7fxMHN8UUdlyJAzlTBDRC28k+L4FB8078ljyD91tUj1ocnTs8vdEf7znbzm+GIjEZnoZE5rnLL700Xc7yHfz05nWxy03vBB9YGHYOWxgMQGBCR24CVYNE1hpfKxN0zKnfJDmmMgMmBWqNbjfSyFCBWSCGCgR8yFXiHyEj+VtD1FB3FpC1zI0kFbzifiKTLm9yq5zFmur+q8FHqjoOBWsBPiDbnCC2ErunV6cJ6TygXFYHYp7MKN9RUlSIS8/xBAGYLzeqUnBF4QbsTuUkUqGs6CaiDWKWjQK9EJkjpkTmNCPYXL";
- // @TODO: Load lazily
- var wordlist = {
- zh_cn: null,
- zh_tw: null
- };
- var Checks = {
- zh_cn: "0x17bcc4d8547e5a7135e365d1ab443aaae95e76d8230c2782c67305d4f21497a1",
- zh_tw: "0x51e720e90c7b87bec1d70eb6e74a21a449bd3ec9c020b01d3a40ed991b60ce5d"
- };
- var codes = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
- var style = "~!@#$%^&*_-=[]{}|;:,.()<>?";
- function loadWords(lang) {
- if (wordlist[lang.locale] !== null) {
- return;
- }
- wordlist[lang.locale] = [];
- var deltaOffset = 0;
- for (var i = 0; i < 2048; i++) {
- var s = style.indexOf(data[i * 3]);
- var bytes = [
- 228 + (s >> 2),
- 128 + codes.indexOf(data[i * 3 + 1]),
- 128 + codes.indexOf(data[i * 3 + 2]),
- ];
- if (lang.locale === "zh_tw") {
- var common = s % 4;
- for (var i_1 = common; i_1 < 3; i_1++) {
- bytes[i_1] = codes.indexOf(deltaData[deltaOffset++]) + ((i_1 == 0) ? 228 : 128);
- }
- }
- wordlist[lang.locale].push((0, strings_1.toUtf8String)(bytes));
- }
- // Verify the computed list matches the official list
- /* istanbul ignore if */
- if (wordlist_1.Wordlist.check(lang) !== Checks[lang.locale]) {
- wordlist[lang.locale] = null;
- throw new Error("BIP39 Wordlist for " + lang.locale + " (Chinese) FAILED");
- }
- }
- var LangZh = /** @class */ (function (_super) {
- __extends(LangZh, _super);
- function LangZh(country) {
- return _super.call(this, "zh_" + country) || this;
- }
- LangZh.prototype.getWord = function (index) {
- loadWords(this);
- return wordlist[this.locale][index];
- };
- LangZh.prototype.getWordIndex = function (word) {
- loadWords(this);
- return wordlist[this.locale].indexOf(word);
- };
- LangZh.prototype.split = function (mnemonic) {
- mnemonic = mnemonic.replace(/(?:\u3000| )+/g, "");
- return mnemonic.split("");
- };
- return LangZh;
- }(wordlist_1.Wordlist));
- var langZhCn = new LangZh("cn");
- exports.langZhCn = langZhCn;
- wordlist_1.Wordlist.register(langZhCn);
- wordlist_1.Wordlist.register(langZhCn, "zh");
- var langZhTw = new LangZh("tw");
- exports.langZhTw = langZhTw;
- wordlist_1.Wordlist.register(langZhTw);
- },{"./wordlist":287,"@ethersproject/strings":266}],287:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.Wordlist = exports.logger = void 0;
- // This gets overridden by rollup
- var exportWordlist = false;
- var hash_1 = _dereq_("@ethersproject/hash");
- var properties_1 = _dereq_("@ethersproject/properties");
- var logger_1 = _dereq_("@ethersproject/logger");
- var _version_1 = _dereq_("./_version");
- exports.logger = new logger_1.Logger(_version_1.version);
- var Wordlist = /** @class */ (function () {
- function Wordlist(locale) {
- var _newTarget = this.constructor;
- exports.logger.checkAbstract(_newTarget, Wordlist);
- (0, properties_1.defineReadOnly)(this, "locale", locale);
- }
- // Subclasses may override this
- Wordlist.prototype.split = function (mnemonic) {
- return mnemonic.toLowerCase().split(/ +/g);
- };
- // Subclasses may override this
- Wordlist.prototype.join = function (words) {
- return words.join(" ");
- };
- Wordlist.check = function (wordlist) {
- var words = [];
- for (var i = 0; i < 2048; i++) {
- var word = wordlist.getWord(i);
- /* istanbul ignore if */
- if (i !== wordlist.getWordIndex(word)) {
- return "0x";
- }
- words.push(word);
- }
- return (0, hash_1.id)(words.join("\n") + "\n");
- };
- Wordlist.register = function (lang, name) {
- if (!name) {
- name = lang.locale;
- }
- /* istanbul ignore if */
- if (exportWordlist) {
- try {
- var anyGlobal = window;
- if (anyGlobal._ethers && anyGlobal._ethers.wordlists) {
- if (!anyGlobal._ethers.wordlists[name]) {
- (0, properties_1.defineReadOnly)(anyGlobal._ethers.wordlists, name, lang);
- }
- }
- }
- catch (error) { }
- }
- };
- return Wordlist;
- }());
- exports.Wordlist = Wordlist;
- },{"./_version":277,"@ethersproject/hash":209,"@ethersproject/logger":223,"@ethersproject/properties":229}],288:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.wordlists = void 0;
- var lang_cz_1 = _dereq_("./lang-cz");
- var lang_en_1 = _dereq_("./lang-en");
- var lang_es_1 = _dereq_("./lang-es");
- var lang_fr_1 = _dereq_("./lang-fr");
- var lang_ja_1 = _dereq_("./lang-ja");
- var lang_ko_1 = _dereq_("./lang-ko");
- var lang_it_1 = _dereq_("./lang-it");
- var lang_zh_1 = _dereq_("./lang-zh");
- exports.wordlists = {
- cz: lang_cz_1.langCz,
- en: lang_en_1.langEn,
- es: lang_es_1.langEs,
- fr: lang_fr_1.langFr,
- it: lang_it_1.langIt,
- ja: lang_ja_1.langJa,
- ko: lang_ko_1.langKo,
- zh: lang_zh_1.langZhCn,
- zh_cn: lang_zh_1.langZhCn,
- zh_tw: lang_zh_1.langZhTw
- };
- },{"./lang-cz":279,"./lang-en":280,"./lang-es":281,"./lang-fr":282,"./lang-it":283,"./lang-ja":284,"./lang-ko":285,"./lang-zh":286}],289:[function(_dereq_,module,exports){
- "use strict";
- /**
- * Returns a Promise that resolves to the value of window.ethereum if it is
- * set within the given timeout, or null.
- * The Promise will not reject, but an error will be thrown if invalid options
- * are provided.
- *
- * @param options - Options bag.
- * @param options.mustBeMetaMask - Whether to only look for MetaMask providers.
- * Default: false
- * @param options.silent - Whether to silence console errors. Does not affect
- * thrown errors. Default: false
- * @param options.timeout - Milliseconds to wait for 'ethereum#initialized' to
- * be dispatched. Default: 3000
- * @returns A Promise that resolves with the Provider if it is detected within
- * given timeout, otherwise null.
- */
- function detectEthereumProvider({ mustBeMetaMask = false, silent = false, timeout = 3000, } = {}) {
- _validateInputs();
- let handled = false;
- return new Promise((resolve) => {
- if (window.ethereum) {
- handleEthereum();
- }
- else {
- window.addEventListener('ethereum#initialized', handleEthereum, { once: true });
- setTimeout(() => {
- handleEthereum();
- }, timeout);
- }
- function handleEthereum() {
- if (handled) {
- return;
- }
- handled = true;
- window.removeEventListener('ethereum#initialized', handleEthereum);
- const { ethereum } = window;
- if (ethereum && (!mustBeMetaMask || ethereum.isMetaMask)) {
- resolve(ethereum);
- }
- else {
- const message = mustBeMetaMask && ethereum
- ? 'Non-MetaMask window.ethereum detected.'
- : 'Unable to detect window.ethereum.';
- !silent && console.error('@metamask/detect-provider:', message);
- resolve(null);
- }
- }
- });
- function _validateInputs() {
- if (typeof mustBeMetaMask !== 'boolean') {
- throw new Error(`@metamask/detect-provider: Expected option 'mustBeMetaMask' to be a boolean.`);
- }
- if (typeof silent !== 'boolean') {
- throw new Error(`@metamask/detect-provider: Expected option 'silent' to be a boolean.`);
- }
- if (typeof timeout !== 'number') {
- throw new Error(`@metamask/detect-provider: Expected option 'timeout' to be a number.`);
- }
- }
- }
- module.exports = detectEthereumProvider;
- },{}],290:[function(_dereq_,module,exports){
- "use strict";
- (function(root) {
- function checkInt(value) {
- return (parseInt(value) === value);
- }
- function checkInts(arrayish) {
- if (!checkInt(arrayish.length)) { return false; }
- for (var i = 0; i < arrayish.length; i++) {
- if (!checkInt(arrayish[i]) || arrayish[i] < 0 || arrayish[i] > 255) {
- return false;
- }
- }
- return true;
- }
- function coerceArray(arg, copy) {
- // ArrayBuffer view
- if (arg.buffer && ArrayBuffer.isView(arg) && arg.name === 'Uint8Array') {
- if (copy) {
- if (arg.slice) {
- arg = arg.slice();
- } else {
- arg = Array.prototype.slice.call(arg);
- }
- }
- return arg;
- }
- // It's an array; check it is a valid representation of a byte
- if (Array.isArray(arg)) {
- if (!checkInts(arg)) {
- throw new Error('Array contains invalid value: ' + arg);
- }
- return new Uint8Array(arg);
- }
- // Something else, but behaves like an array (maybe a Buffer? Arguments?)
- if (checkInt(arg.length) && checkInts(arg)) {
- return new Uint8Array(arg);
- }
- throw new Error('unsupported array-like object');
- }
- function createArray(length) {
- return new Uint8Array(length);
- }
- function copyArray(sourceArray, targetArray, targetStart, sourceStart, sourceEnd) {
- if (sourceStart != null || sourceEnd != null) {
- if (sourceArray.slice) {
- sourceArray = sourceArray.slice(sourceStart, sourceEnd);
- } else {
- sourceArray = Array.prototype.slice.call(sourceArray, sourceStart, sourceEnd);
- }
- }
- targetArray.set(sourceArray, targetStart);
- }
- var convertUtf8 = (function() {
- function toBytes(text) {
- var result = [], i = 0;
- text = encodeURI(text);
- while (i < text.length) {
- var c = text.charCodeAt(i++);
- // if it is a % sign, encode the following 2 bytes as a hex value
- if (c === 37) {
- result.push(parseInt(text.substr(i, 2), 16))
- i += 2;
- // otherwise, just the actual byte
- } else {
- result.push(c)
- }
- }
- return coerceArray(result);
- }
- function fromBytes(bytes) {
- var result = [], i = 0;
- while (i < bytes.length) {
- var c = bytes[i];
- if (c < 128) {
- result.push(String.fromCharCode(c));
- i++;
- } else if (c > 191 && c < 224) {
- result.push(String.fromCharCode(((c & 0x1f) << 6) | (bytes[i + 1] & 0x3f)));
- i += 2;
- } else {
- result.push(String.fromCharCode(((c & 0x0f) << 12) | ((bytes[i + 1] & 0x3f) << 6) | (bytes[i + 2] & 0x3f)));
- i += 3;
- }
- }
- return result.join('');
- }
- return {
- toBytes: toBytes,
- fromBytes: fromBytes,
- }
- })();
- var convertHex = (function() {
- function toBytes(text) {
- var result = [];
- for (var i = 0; i < text.length; i += 2) {
- result.push(parseInt(text.substr(i, 2), 16));
- }
- return result;
- }
- // http://ixti.net/development/javascript/2011/11/11/base64-encodedecode-of-utf8-in-browser-with-js.html
- var Hex = '0123456789abcdef';
- function fromBytes(bytes) {
- var result = [];
- for (var i = 0; i < bytes.length; i++) {
- var v = bytes[i];
- result.push(Hex[(v & 0xf0) >> 4] + Hex[v & 0x0f]);
- }
- return result.join('');
- }
- return {
- toBytes: toBytes,
- fromBytes: fromBytes,
- }
- })();
- // Number of rounds by keysize
- var numberOfRounds = {16: 10, 24: 12, 32: 14}
- // Round constant words
- var rcon = [0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91];
- // S-box and Inverse S-box (S is for Substitution)
- var S = [0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76, 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0, 0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15, 0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75, 0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84, 0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf, 0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8, 0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2, 0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73, 0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb, 0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79, 0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08, 0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a, 0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e, 0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf, 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16];
- var Si =[0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38, 0xbf, 0x40, 0xa3, 0x9e, 0x81, 0xf3, 0xd7, 0xfb, 0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87, 0x34, 0x8e, 0x43, 0x44, 0xc4, 0xde, 0xe9, 0xcb, 0x54, 0x7b, 0x94, 0x32, 0xa6, 0xc2, 0x23, 0x3d, 0xee, 0x4c, 0x95, 0x0b, 0x42, 0xfa, 0xc3, 0x4e, 0x08, 0x2e, 0xa1, 0x66, 0x28, 0xd9, 0x24, 0xb2, 0x76, 0x5b, 0xa2, 0x49, 0x6d, 0x8b, 0xd1, 0x25, 0x72, 0xf8, 0xf6, 0x64, 0x86, 0x68, 0x98, 0x16, 0xd4, 0xa4, 0x5c, 0xcc, 0x5d, 0x65, 0xb6, 0x92, 0x6c, 0x70, 0x48, 0x50, 0xfd, 0xed, 0xb9, 0xda, 0x5e, 0x15, 0x46, 0x57, 0xa7, 0x8d, 0x9d, 0x84, 0x90, 0xd8, 0xab, 0x00, 0x8c, 0xbc, 0xd3, 0x0a, 0xf7, 0xe4, 0x58, 0x05, 0xb8, 0xb3, 0x45, 0x06, 0xd0, 0x2c, 0x1e, 0x8f, 0xca, 0x3f, 0x0f, 0x02, 0xc1, 0xaf, 0xbd, 0x03, 0x01, 0x13, 0x8a, 0x6b, 0x3a, 0x91, 0x11, 0x41, 0x4f, 0x67, 0xdc, 0xea, 0x97, 0xf2, 0xcf, 0xce, 0xf0, 0xb4, 0xe6, 0x73, 0x96, 0xac, 0x74, 0x22, 0xe7, 0xad, 0x35, 0x85, 0xe2, 0xf9, 0x37, 0xe8, 0x1c, 0x75, 0xdf, 0x6e, 0x47, 0xf1, 0x1a, 0x71, 0x1d, 0x29, 0xc5, 0x89, 0x6f, 0xb7, 0x62, 0x0e, 0xaa, 0x18, 0xbe, 0x1b, 0xfc, 0x56, 0x3e, 0x4b, 0xc6, 0xd2, 0x79, 0x20, 0x9a, 0xdb, 0xc0, 0xfe, 0x78, 0xcd, 0x5a, 0xf4, 0x1f, 0xdd, 0xa8, 0x33, 0x88, 0x07, 0xc7, 0x31, 0xb1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xec, 0x5f, 0x60, 0x51, 0x7f, 0xa9, 0x19, 0xb5, 0x4a, 0x0d, 0x2d, 0xe5, 0x7a, 0x9f, 0x93, 0xc9, 0x9c, 0xef, 0xa0, 0xe0, 0x3b, 0x4d, 0xae, 0x2a, 0xf5, 0xb0, 0xc8, 0xeb, 0xbb, 0x3c, 0x83, 0x53, 0x99, 0x61, 0x17, 0x2b, 0x04, 0x7e, 0xba, 0x77, 0xd6, 0x26, 0xe1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0c, 0x7d];
- // Transformations for encryption
- var T1 = [0xc66363a5, 0xf87c7c84, 0xee777799, 0xf67b7b8d, 0xfff2f20d, 0xd66b6bbd, 0xde6f6fb1, 0x91c5c554, 0x60303050, 0x02010103, 0xce6767a9, 0x562b2b7d, 0xe7fefe19, 0xb5d7d762, 0x4dababe6, 0xec76769a, 0x8fcaca45, 0x1f82829d, 0x89c9c940, 0xfa7d7d87, 0xeffafa15, 0xb25959eb, 0x8e4747c9, 0xfbf0f00b, 0x41adadec, 0xb3d4d467, 0x5fa2a2fd, 0x45afafea, 0x239c9cbf, 0x53a4a4f7, 0xe4727296, 0x9bc0c05b, 0x75b7b7c2, 0xe1fdfd1c, 0x3d9393ae, 0x4c26266a, 0x6c36365a, 0x7e3f3f41, 0xf5f7f702, 0x83cccc4f, 0x6834345c, 0x51a5a5f4, 0xd1e5e534, 0xf9f1f108, 0xe2717193, 0xabd8d873, 0x62313153, 0x2a15153f, 0x0804040c, 0x95c7c752, 0x46232365, 0x9dc3c35e, 0x30181828, 0x379696a1, 0x0a05050f, 0x2f9a9ab5, 0x0e070709, 0x24121236, 0x1b80809b, 0xdfe2e23d, 0xcdebeb26, 0x4e272769, 0x7fb2b2cd, 0xea75759f, 0x1209091b, 0x1d83839e, 0x582c2c74, 0x341a1a2e, 0x361b1b2d, 0xdc6e6eb2, 0xb45a5aee, 0x5ba0a0fb, 0xa45252f6, 0x763b3b4d, 0xb7d6d661, 0x7db3b3ce, 0x5229297b, 0xdde3e33e, 0x5e2f2f71, 0x13848497, 0xa65353f5, 0xb9d1d168, 0x00000000, 0xc1eded2c, 0x40202060, 0xe3fcfc1f, 0x79b1b1c8, 0xb65b5bed, 0xd46a6abe, 0x8dcbcb46, 0x67bebed9, 0x7239394b, 0x944a4ade, 0x984c4cd4, 0xb05858e8, 0x85cfcf4a, 0xbbd0d06b, 0xc5efef2a, 0x4faaaae5, 0xedfbfb16, 0x864343c5, 0x9a4d4dd7, 0x66333355, 0x11858594, 0x8a4545cf, 0xe9f9f910, 0x04020206, 0xfe7f7f81, 0xa05050f0, 0x783c3c44, 0x259f9fba, 0x4ba8a8e3, 0xa25151f3, 0x5da3a3fe, 0x804040c0, 0x058f8f8a, 0x3f9292ad, 0x219d9dbc, 0x70383848, 0xf1f5f504, 0x63bcbcdf, 0x77b6b6c1, 0xafdada75, 0x42212163, 0x20101030, 0xe5ffff1a, 0xfdf3f30e, 0xbfd2d26d, 0x81cdcd4c, 0x180c0c14, 0x26131335, 0xc3ecec2f, 0xbe5f5fe1, 0x359797a2, 0x884444cc, 0x2e171739, 0x93c4c457, 0x55a7a7f2, 0xfc7e7e82, 0x7a3d3d47, 0xc86464ac, 0xba5d5de7, 0x3219192b, 0xe6737395, 0xc06060a0, 0x19818198, 0x9e4f4fd1, 0xa3dcdc7f, 0x44222266, 0x542a2a7e, 0x3b9090ab, 0x0b888883, 0x8c4646ca, 0xc7eeee29, 0x6bb8b8d3, 0x2814143c, 0xa7dede79, 0xbc5e5ee2, 0x160b0b1d, 0xaddbdb76, 0xdbe0e03b, 0x64323256, 0x743a3a4e, 0x140a0a1e, 0x924949db, 0x0c06060a, 0x4824246c, 0xb85c5ce4, 0x9fc2c25d, 0xbdd3d36e, 0x43acacef, 0xc46262a6, 0x399191a8, 0x319595a4, 0xd3e4e437, 0xf279798b, 0xd5e7e732, 0x8bc8c843, 0x6e373759, 0xda6d6db7, 0x018d8d8c, 0xb1d5d564, 0x9c4e4ed2, 0x49a9a9e0, 0xd86c6cb4, 0xac5656fa, 0xf3f4f407, 0xcfeaea25, 0xca6565af, 0xf47a7a8e, 0x47aeaee9, 0x10080818, 0x6fbabad5, 0xf0787888, 0x4a25256f, 0x5c2e2e72, 0x381c1c24, 0x57a6a6f1, 0x73b4b4c7, 0x97c6c651, 0xcbe8e823, 0xa1dddd7c, 0xe874749c, 0x3e1f1f21, 0x964b4bdd, 0x61bdbddc, 0x0d8b8b86, 0x0f8a8a85, 0xe0707090, 0x7c3e3e42, 0x71b5b5c4, 0xcc6666aa, 0x904848d8, 0x06030305, 0xf7f6f601, 0x1c0e0e12, 0xc26161a3, 0x6a35355f, 0xae5757f9, 0x69b9b9d0, 0x17868691, 0x99c1c158, 0x3a1d1d27, 0x279e9eb9, 0xd9e1e138, 0xebf8f813, 0x2b9898b3, 0x22111133, 0xd26969bb, 0xa9d9d970, 0x078e8e89, 0x339494a7, 0x2d9b9bb6, 0x3c1e1e22, 0x15878792, 0xc9e9e920, 0x87cece49, 0xaa5555ff, 0x50282878, 0xa5dfdf7a, 0x038c8c8f, 0x59a1a1f8, 0x09898980, 0x1a0d0d17, 0x65bfbfda, 0xd7e6e631, 0x844242c6, 0xd06868b8, 0x824141c3, 0x299999b0, 0x5a2d2d77, 0x1e0f0f11, 0x7bb0b0cb, 0xa85454fc, 0x6dbbbbd6, 0x2c16163a];
- var T2 = [0xa5c66363, 0x84f87c7c, 0x99ee7777, 0x8df67b7b, 0x0dfff2f2, 0xbdd66b6b, 0xb1de6f6f, 0x5491c5c5, 0x50603030, 0x03020101, 0xa9ce6767, 0x7d562b2b, 0x19e7fefe, 0x62b5d7d7, 0xe64dabab, 0x9aec7676, 0x458fcaca, 0x9d1f8282, 0x4089c9c9, 0x87fa7d7d, 0x15effafa, 0xebb25959, 0xc98e4747, 0x0bfbf0f0, 0xec41adad, 0x67b3d4d4, 0xfd5fa2a2, 0xea45afaf, 0xbf239c9c, 0xf753a4a4, 0x96e47272, 0x5b9bc0c0, 0xc275b7b7, 0x1ce1fdfd, 0xae3d9393, 0x6a4c2626, 0x5a6c3636, 0x417e3f3f, 0x02f5f7f7, 0x4f83cccc, 0x5c683434, 0xf451a5a5, 0x34d1e5e5, 0x08f9f1f1, 0x93e27171, 0x73abd8d8, 0x53623131, 0x3f2a1515, 0x0c080404, 0x5295c7c7, 0x65462323, 0x5e9dc3c3, 0x28301818, 0xa1379696, 0x0f0a0505, 0xb52f9a9a, 0x090e0707, 0x36241212, 0x9b1b8080, 0x3ddfe2e2, 0x26cdebeb, 0x694e2727, 0xcd7fb2b2, 0x9fea7575, 0x1b120909, 0x9e1d8383, 0x74582c2c, 0x2e341a1a, 0x2d361b1b, 0xb2dc6e6e, 0xeeb45a5a, 0xfb5ba0a0, 0xf6a45252, 0x4d763b3b, 0x61b7d6d6, 0xce7db3b3, 0x7b522929, 0x3edde3e3, 0x715e2f2f, 0x97138484, 0xf5a65353, 0x68b9d1d1, 0x00000000, 0x2cc1eded, 0x60402020, 0x1fe3fcfc, 0xc879b1b1, 0xedb65b5b, 0xbed46a6a, 0x468dcbcb, 0xd967bebe, 0x4b723939, 0xde944a4a, 0xd4984c4c, 0xe8b05858, 0x4a85cfcf, 0x6bbbd0d0, 0x2ac5efef, 0xe54faaaa, 0x16edfbfb, 0xc5864343, 0xd79a4d4d, 0x55663333, 0x94118585, 0xcf8a4545, 0x10e9f9f9, 0x06040202, 0x81fe7f7f, 0xf0a05050, 0x44783c3c, 0xba259f9f, 0xe34ba8a8, 0xf3a25151, 0xfe5da3a3, 0xc0804040, 0x8a058f8f, 0xad3f9292, 0xbc219d9d, 0x48703838, 0x04f1f5f5, 0xdf63bcbc, 0xc177b6b6, 0x75afdada, 0x63422121, 0x30201010, 0x1ae5ffff, 0x0efdf3f3, 0x6dbfd2d2, 0x4c81cdcd, 0x14180c0c, 0x35261313, 0x2fc3ecec, 0xe1be5f5f, 0xa2359797, 0xcc884444, 0x392e1717, 0x5793c4c4, 0xf255a7a7, 0x82fc7e7e, 0x477a3d3d, 0xacc86464, 0xe7ba5d5d, 0x2b321919, 0x95e67373, 0xa0c06060, 0x98198181, 0xd19e4f4f, 0x7fa3dcdc, 0x66442222, 0x7e542a2a, 0xab3b9090, 0x830b8888, 0xca8c4646, 0x29c7eeee, 0xd36bb8b8, 0x3c281414, 0x79a7dede, 0xe2bc5e5e, 0x1d160b0b, 0x76addbdb, 0x3bdbe0e0, 0x56643232, 0x4e743a3a, 0x1e140a0a, 0xdb924949, 0x0a0c0606, 0x6c482424, 0xe4b85c5c, 0x5d9fc2c2, 0x6ebdd3d3, 0xef43acac, 0xa6c46262, 0xa8399191, 0xa4319595, 0x37d3e4e4, 0x8bf27979, 0x32d5e7e7, 0x438bc8c8, 0x596e3737, 0xb7da6d6d, 0x8c018d8d, 0x64b1d5d5, 0xd29c4e4e, 0xe049a9a9, 0xb4d86c6c, 0xfaac5656, 0x07f3f4f4, 0x25cfeaea, 0xafca6565, 0x8ef47a7a, 0xe947aeae, 0x18100808, 0xd56fbaba, 0x88f07878, 0x6f4a2525, 0x725c2e2e, 0x24381c1c, 0xf157a6a6, 0xc773b4b4, 0x5197c6c6, 0x23cbe8e8, 0x7ca1dddd, 0x9ce87474, 0x213e1f1f, 0xdd964b4b, 0xdc61bdbd, 0x860d8b8b, 0x850f8a8a, 0x90e07070, 0x427c3e3e, 0xc471b5b5, 0xaacc6666, 0xd8904848, 0x05060303, 0x01f7f6f6, 0x121c0e0e, 0xa3c26161, 0x5f6a3535, 0xf9ae5757, 0xd069b9b9, 0x91178686, 0x5899c1c1, 0x273a1d1d, 0xb9279e9e, 0x38d9e1e1, 0x13ebf8f8, 0xb32b9898, 0x33221111, 0xbbd26969, 0x70a9d9d9, 0x89078e8e, 0xa7339494, 0xb62d9b9b, 0x223c1e1e, 0x92158787, 0x20c9e9e9, 0x4987cece, 0xffaa5555, 0x78502828, 0x7aa5dfdf, 0x8f038c8c, 0xf859a1a1, 0x80098989, 0x171a0d0d, 0xda65bfbf, 0x31d7e6e6, 0xc6844242, 0xb8d06868, 0xc3824141, 0xb0299999, 0x775a2d2d, 0x111e0f0f, 0xcb7bb0b0, 0xfca85454, 0xd66dbbbb, 0x3a2c1616];
- var T3 = [0x63a5c663, 0x7c84f87c, 0x7799ee77, 0x7b8df67b, 0xf20dfff2, 0x6bbdd66b, 0x6fb1de6f, 0xc55491c5, 0x30506030, 0x01030201, 0x67a9ce67, 0x2b7d562b, 0xfe19e7fe, 0xd762b5d7, 0xabe64dab, 0x769aec76, 0xca458fca, 0x829d1f82, 0xc94089c9, 0x7d87fa7d, 0xfa15effa, 0x59ebb259, 0x47c98e47, 0xf00bfbf0, 0xadec41ad, 0xd467b3d4, 0xa2fd5fa2, 0xafea45af, 0x9cbf239c, 0xa4f753a4, 0x7296e472, 0xc05b9bc0, 0xb7c275b7, 0xfd1ce1fd, 0x93ae3d93, 0x266a4c26, 0x365a6c36, 0x3f417e3f, 0xf702f5f7, 0xcc4f83cc, 0x345c6834, 0xa5f451a5, 0xe534d1e5, 0xf108f9f1, 0x7193e271, 0xd873abd8, 0x31536231, 0x153f2a15, 0x040c0804, 0xc75295c7, 0x23654623, 0xc35e9dc3, 0x18283018, 0x96a13796, 0x050f0a05, 0x9ab52f9a, 0x07090e07, 0x12362412, 0x809b1b80, 0xe23ddfe2, 0xeb26cdeb, 0x27694e27, 0xb2cd7fb2, 0x759fea75, 0x091b1209, 0x839e1d83, 0x2c74582c, 0x1a2e341a, 0x1b2d361b, 0x6eb2dc6e, 0x5aeeb45a, 0xa0fb5ba0, 0x52f6a452, 0x3b4d763b, 0xd661b7d6, 0xb3ce7db3, 0x297b5229, 0xe33edde3, 0x2f715e2f, 0x84971384, 0x53f5a653, 0xd168b9d1, 0x00000000, 0xed2cc1ed, 0x20604020, 0xfc1fe3fc, 0xb1c879b1, 0x5bedb65b, 0x6abed46a, 0xcb468dcb, 0xbed967be, 0x394b7239, 0x4ade944a, 0x4cd4984c, 0x58e8b058, 0xcf4a85cf, 0xd06bbbd0, 0xef2ac5ef, 0xaae54faa, 0xfb16edfb, 0x43c58643, 0x4dd79a4d, 0x33556633, 0x85941185, 0x45cf8a45, 0xf910e9f9, 0x02060402, 0x7f81fe7f, 0x50f0a050, 0x3c44783c, 0x9fba259f, 0xa8e34ba8, 0x51f3a251, 0xa3fe5da3, 0x40c08040, 0x8f8a058f, 0x92ad3f92, 0x9dbc219d, 0x38487038, 0xf504f1f5, 0xbcdf63bc, 0xb6c177b6, 0xda75afda, 0x21634221, 0x10302010, 0xff1ae5ff, 0xf30efdf3, 0xd26dbfd2, 0xcd4c81cd, 0x0c14180c, 0x13352613, 0xec2fc3ec, 0x5fe1be5f, 0x97a23597, 0x44cc8844, 0x17392e17, 0xc45793c4, 0xa7f255a7, 0x7e82fc7e, 0x3d477a3d, 0x64acc864, 0x5de7ba5d, 0x192b3219, 0x7395e673, 0x60a0c060, 0x81981981, 0x4fd19e4f, 0xdc7fa3dc, 0x22664422, 0x2a7e542a, 0x90ab3b90, 0x88830b88, 0x46ca8c46, 0xee29c7ee, 0xb8d36bb8, 0x143c2814, 0xde79a7de, 0x5ee2bc5e, 0x0b1d160b, 0xdb76addb, 0xe03bdbe0, 0x32566432, 0x3a4e743a, 0x0a1e140a, 0x49db9249, 0x060a0c06, 0x246c4824, 0x5ce4b85c, 0xc25d9fc2, 0xd36ebdd3, 0xacef43ac, 0x62a6c462, 0x91a83991, 0x95a43195, 0xe437d3e4, 0x798bf279, 0xe732d5e7, 0xc8438bc8, 0x37596e37, 0x6db7da6d, 0x8d8c018d, 0xd564b1d5, 0x4ed29c4e, 0xa9e049a9, 0x6cb4d86c, 0x56faac56, 0xf407f3f4, 0xea25cfea, 0x65afca65, 0x7a8ef47a, 0xaee947ae, 0x08181008, 0xbad56fba, 0x7888f078, 0x256f4a25, 0x2e725c2e, 0x1c24381c, 0xa6f157a6, 0xb4c773b4, 0xc65197c6, 0xe823cbe8, 0xdd7ca1dd, 0x749ce874, 0x1f213e1f, 0x4bdd964b, 0xbddc61bd, 0x8b860d8b, 0x8a850f8a, 0x7090e070, 0x3e427c3e, 0xb5c471b5, 0x66aacc66, 0x48d89048, 0x03050603, 0xf601f7f6, 0x0e121c0e, 0x61a3c261, 0x355f6a35, 0x57f9ae57, 0xb9d069b9, 0x86911786, 0xc15899c1, 0x1d273a1d, 0x9eb9279e, 0xe138d9e1, 0xf813ebf8, 0x98b32b98, 0x11332211, 0x69bbd269, 0xd970a9d9, 0x8e89078e, 0x94a73394, 0x9bb62d9b, 0x1e223c1e, 0x87921587, 0xe920c9e9, 0xce4987ce, 0x55ffaa55, 0x28785028, 0xdf7aa5df, 0x8c8f038c, 0xa1f859a1, 0x89800989, 0x0d171a0d, 0xbfda65bf, 0xe631d7e6, 0x42c68442, 0x68b8d068, 0x41c38241, 0x99b02999, 0x2d775a2d, 0x0f111e0f, 0xb0cb7bb0, 0x54fca854, 0xbbd66dbb, 0x163a2c16];
- var T4 = [0x6363a5c6, 0x7c7c84f8, 0x777799ee, 0x7b7b8df6, 0xf2f20dff, 0x6b6bbdd6, 0x6f6fb1de, 0xc5c55491, 0x30305060, 0x01010302, 0x6767a9ce, 0x2b2b7d56, 0xfefe19e7, 0xd7d762b5, 0xababe64d, 0x76769aec, 0xcaca458f, 0x82829d1f, 0xc9c94089, 0x7d7d87fa, 0xfafa15ef, 0x5959ebb2, 0x4747c98e, 0xf0f00bfb, 0xadadec41, 0xd4d467b3, 0xa2a2fd5f, 0xafafea45, 0x9c9cbf23, 0xa4a4f753, 0x727296e4, 0xc0c05b9b, 0xb7b7c275, 0xfdfd1ce1, 0x9393ae3d, 0x26266a4c, 0x36365a6c, 0x3f3f417e, 0xf7f702f5, 0xcccc4f83, 0x34345c68, 0xa5a5f451, 0xe5e534d1, 0xf1f108f9, 0x717193e2, 0xd8d873ab, 0x31315362, 0x15153f2a, 0x04040c08, 0xc7c75295, 0x23236546, 0xc3c35e9d, 0x18182830, 0x9696a137, 0x05050f0a, 0x9a9ab52f, 0x0707090e, 0x12123624, 0x80809b1b, 0xe2e23ddf, 0xebeb26cd, 0x2727694e, 0xb2b2cd7f, 0x75759fea, 0x09091b12, 0x83839e1d, 0x2c2c7458, 0x1a1a2e34, 0x1b1b2d36, 0x6e6eb2dc, 0x5a5aeeb4, 0xa0a0fb5b, 0x5252f6a4, 0x3b3b4d76, 0xd6d661b7, 0xb3b3ce7d, 0x29297b52, 0xe3e33edd, 0x2f2f715e, 0x84849713, 0x5353f5a6, 0xd1d168b9, 0x00000000, 0xeded2cc1, 0x20206040, 0xfcfc1fe3, 0xb1b1c879, 0x5b5bedb6, 0x6a6abed4, 0xcbcb468d, 0xbebed967, 0x39394b72, 0x4a4ade94, 0x4c4cd498, 0x5858e8b0, 0xcfcf4a85, 0xd0d06bbb, 0xefef2ac5, 0xaaaae54f, 0xfbfb16ed, 0x4343c586, 0x4d4dd79a, 0x33335566, 0x85859411, 0x4545cf8a, 0xf9f910e9, 0x02020604, 0x7f7f81fe, 0x5050f0a0, 0x3c3c4478, 0x9f9fba25, 0xa8a8e34b, 0x5151f3a2, 0xa3a3fe5d, 0x4040c080, 0x8f8f8a05, 0x9292ad3f, 0x9d9dbc21, 0x38384870, 0xf5f504f1, 0xbcbcdf63, 0xb6b6c177, 0xdada75af, 0x21216342, 0x10103020, 0xffff1ae5, 0xf3f30efd, 0xd2d26dbf, 0xcdcd4c81, 0x0c0c1418, 0x13133526, 0xecec2fc3, 0x5f5fe1be, 0x9797a235, 0x4444cc88, 0x1717392e, 0xc4c45793, 0xa7a7f255, 0x7e7e82fc, 0x3d3d477a, 0x6464acc8, 0x5d5de7ba, 0x19192b32, 0x737395e6, 0x6060a0c0, 0x81819819, 0x4f4fd19e, 0xdcdc7fa3, 0x22226644, 0x2a2a7e54, 0x9090ab3b, 0x8888830b, 0x4646ca8c, 0xeeee29c7, 0xb8b8d36b, 0x14143c28, 0xdede79a7, 0x5e5ee2bc, 0x0b0b1d16, 0xdbdb76ad, 0xe0e03bdb, 0x32325664, 0x3a3a4e74, 0x0a0a1e14, 0x4949db92, 0x06060a0c, 0x24246c48, 0x5c5ce4b8, 0xc2c25d9f, 0xd3d36ebd, 0xacacef43, 0x6262a6c4, 0x9191a839, 0x9595a431, 0xe4e437d3, 0x79798bf2, 0xe7e732d5, 0xc8c8438b, 0x3737596e, 0x6d6db7da, 0x8d8d8c01, 0xd5d564b1, 0x4e4ed29c, 0xa9a9e049, 0x6c6cb4d8, 0x5656faac, 0xf4f407f3, 0xeaea25cf, 0x6565afca, 0x7a7a8ef4, 0xaeaee947, 0x08081810, 0xbabad56f, 0x787888f0, 0x25256f4a, 0x2e2e725c, 0x1c1c2438, 0xa6a6f157, 0xb4b4c773, 0xc6c65197, 0xe8e823cb, 0xdddd7ca1, 0x74749ce8, 0x1f1f213e, 0x4b4bdd96, 0xbdbddc61, 0x8b8b860d, 0x8a8a850f, 0x707090e0, 0x3e3e427c, 0xb5b5c471, 0x6666aacc, 0x4848d890, 0x03030506, 0xf6f601f7, 0x0e0e121c, 0x6161a3c2, 0x35355f6a, 0x5757f9ae, 0xb9b9d069, 0x86869117, 0xc1c15899, 0x1d1d273a, 0x9e9eb927, 0xe1e138d9, 0xf8f813eb, 0x9898b32b, 0x11113322, 0x6969bbd2, 0xd9d970a9, 0x8e8e8907, 0x9494a733, 0x9b9bb62d, 0x1e1e223c, 0x87879215, 0xe9e920c9, 0xcece4987, 0x5555ffaa, 0x28287850, 0xdfdf7aa5, 0x8c8c8f03, 0xa1a1f859, 0x89898009, 0x0d0d171a, 0xbfbfda65, 0xe6e631d7, 0x4242c684, 0x6868b8d0, 0x4141c382, 0x9999b029, 0x2d2d775a, 0x0f0f111e, 0xb0b0cb7b, 0x5454fca8, 0xbbbbd66d, 0x16163a2c];
- // Transformations for decryption
- var T5 = [0x51f4a750, 0x7e416553, 0x1a17a4c3, 0x3a275e96, 0x3bab6bcb, 0x1f9d45f1, 0xacfa58ab, 0x4be30393, 0x2030fa55, 0xad766df6, 0x88cc7691, 0xf5024c25, 0x4fe5d7fc, 0xc52acbd7, 0x26354480, 0xb562a38f, 0xdeb15a49, 0x25ba1b67, 0x45ea0e98, 0x5dfec0e1, 0xc32f7502, 0x814cf012, 0x8d4697a3, 0x6bd3f9c6, 0x038f5fe7, 0x15929c95, 0xbf6d7aeb, 0x955259da, 0xd4be832d, 0x587421d3, 0x49e06929, 0x8ec9c844, 0x75c2896a, 0xf48e7978, 0x99583e6b, 0x27b971dd, 0xbee14fb6, 0xf088ad17, 0xc920ac66, 0x7dce3ab4, 0x63df4a18, 0xe51a3182, 0x97513360, 0x62537f45, 0xb16477e0, 0xbb6bae84, 0xfe81a01c, 0xf9082b94, 0x70486858, 0x8f45fd19, 0x94de6c87, 0x527bf8b7, 0xab73d323, 0x724b02e2, 0xe31f8f57, 0x6655ab2a, 0xb2eb2807, 0x2fb5c203, 0x86c57b9a, 0xd33708a5, 0x302887f2, 0x23bfa5b2, 0x02036aba, 0xed16825c, 0x8acf1c2b, 0xa779b492, 0xf307f2f0, 0x4e69e2a1, 0x65daf4cd, 0x0605bed5, 0xd134621f, 0xc4a6fe8a, 0x342e539d, 0xa2f355a0, 0x058ae132, 0xa4f6eb75, 0x0b83ec39, 0x4060efaa, 0x5e719f06, 0xbd6e1051, 0x3e218af9, 0x96dd063d, 0xdd3e05ae, 0x4de6bd46, 0x91548db5, 0x71c45d05, 0x0406d46f, 0x605015ff, 0x1998fb24, 0xd6bde997, 0x894043cc, 0x67d99e77, 0xb0e842bd, 0x07898b88, 0xe7195b38, 0x79c8eedb, 0xa17c0a47, 0x7c420fe9, 0xf8841ec9, 0x00000000, 0x09808683, 0x322bed48, 0x1e1170ac, 0x6c5a724e, 0xfd0efffb, 0x0f853856, 0x3daed51e, 0x362d3927, 0x0a0fd964, 0x685ca621, 0x9b5b54d1, 0x24362e3a, 0x0c0a67b1, 0x9357e70f, 0xb4ee96d2, 0x1b9b919e, 0x80c0c54f, 0x61dc20a2, 0x5a774b69, 0x1c121a16, 0xe293ba0a, 0xc0a02ae5, 0x3c22e043, 0x121b171d, 0x0e090d0b, 0xf28bc7ad, 0x2db6a8b9, 0x141ea9c8, 0x57f11985, 0xaf75074c, 0xee99ddbb, 0xa37f60fd, 0xf701269f, 0x5c72f5bc, 0x44663bc5, 0x5bfb7e34, 0x8b432976, 0xcb23c6dc, 0xb6edfc68, 0xb8e4f163, 0xd731dcca, 0x42638510, 0x13972240, 0x84c61120, 0x854a247d, 0xd2bb3df8, 0xaef93211, 0xc729a16d, 0x1d9e2f4b, 0xdcb230f3, 0x0d8652ec, 0x77c1e3d0, 0x2bb3166c, 0xa970b999, 0x119448fa, 0x47e96422, 0xa8fc8cc4, 0xa0f03f1a, 0x567d2cd8, 0x223390ef, 0x87494ec7, 0xd938d1c1, 0x8ccaa2fe, 0x98d40b36, 0xa6f581cf, 0xa57ade28, 0xdab78e26, 0x3fadbfa4, 0x2c3a9de4, 0x5078920d, 0x6a5fcc9b, 0x547e4662, 0xf68d13c2, 0x90d8b8e8, 0x2e39f75e, 0x82c3aff5, 0x9f5d80be, 0x69d0937c, 0x6fd52da9, 0xcf2512b3, 0xc8ac993b, 0x10187da7, 0xe89c636e, 0xdb3bbb7b, 0xcd267809, 0x6e5918f4, 0xec9ab701, 0x834f9aa8, 0xe6956e65, 0xaaffe67e, 0x21bccf08, 0xef15e8e6, 0xbae79bd9, 0x4a6f36ce, 0xea9f09d4, 0x29b07cd6, 0x31a4b2af, 0x2a3f2331, 0xc6a59430, 0x35a266c0, 0x744ebc37, 0xfc82caa6, 0xe090d0b0, 0x33a7d815, 0xf104984a, 0x41ecdaf7, 0x7fcd500e, 0x1791f62f, 0x764dd68d, 0x43efb04d, 0xccaa4d54, 0xe49604df, 0x9ed1b5e3, 0x4c6a881b, 0xc12c1fb8, 0x4665517f, 0x9d5eea04, 0x018c355d, 0xfa877473, 0xfb0b412e, 0xb3671d5a, 0x92dbd252, 0xe9105633, 0x6dd64713, 0x9ad7618c, 0x37a10c7a, 0x59f8148e, 0xeb133c89, 0xcea927ee, 0xb761c935, 0xe11ce5ed, 0x7a47b13c, 0x9cd2df59, 0x55f2733f, 0x1814ce79, 0x73c737bf, 0x53f7cdea, 0x5ffdaa5b, 0xdf3d6f14, 0x7844db86, 0xcaaff381, 0xb968c43e, 0x3824342c, 0xc2a3405f, 0x161dc372, 0xbce2250c, 0x283c498b, 0xff0d9541, 0x39a80171, 0x080cb3de, 0xd8b4e49c, 0x6456c190, 0x7bcb8461, 0xd532b670, 0x486c5c74, 0xd0b85742];
- var T6 = [0x5051f4a7, 0x537e4165, 0xc31a17a4, 0x963a275e, 0xcb3bab6b, 0xf11f9d45, 0xabacfa58, 0x934be303, 0x552030fa, 0xf6ad766d, 0x9188cc76, 0x25f5024c, 0xfc4fe5d7, 0xd7c52acb, 0x80263544, 0x8fb562a3, 0x49deb15a, 0x6725ba1b, 0x9845ea0e, 0xe15dfec0, 0x02c32f75, 0x12814cf0, 0xa38d4697, 0xc66bd3f9, 0xe7038f5f, 0x9515929c, 0xebbf6d7a, 0xda955259, 0x2dd4be83, 0xd3587421, 0x2949e069, 0x448ec9c8, 0x6a75c289, 0x78f48e79, 0x6b99583e, 0xdd27b971, 0xb6bee14f, 0x17f088ad, 0x66c920ac, 0xb47dce3a, 0x1863df4a, 0x82e51a31, 0x60975133, 0x4562537f, 0xe0b16477, 0x84bb6bae, 0x1cfe81a0, 0x94f9082b, 0x58704868, 0x198f45fd, 0x8794de6c, 0xb7527bf8, 0x23ab73d3, 0xe2724b02, 0x57e31f8f, 0x2a6655ab, 0x07b2eb28, 0x032fb5c2, 0x9a86c57b, 0xa5d33708, 0xf2302887, 0xb223bfa5, 0xba02036a, 0x5ced1682, 0x2b8acf1c, 0x92a779b4, 0xf0f307f2, 0xa14e69e2, 0xcd65daf4, 0xd50605be, 0x1fd13462, 0x8ac4a6fe, 0x9d342e53, 0xa0a2f355, 0x32058ae1, 0x75a4f6eb, 0x390b83ec, 0xaa4060ef, 0x065e719f, 0x51bd6e10, 0xf93e218a, 0x3d96dd06, 0xaedd3e05, 0x464de6bd, 0xb591548d, 0x0571c45d, 0x6f0406d4, 0xff605015, 0x241998fb, 0x97d6bde9, 0xcc894043, 0x7767d99e, 0xbdb0e842, 0x8807898b, 0x38e7195b, 0xdb79c8ee, 0x47a17c0a, 0xe97c420f, 0xc9f8841e, 0x00000000, 0x83098086, 0x48322bed, 0xac1e1170, 0x4e6c5a72, 0xfbfd0eff, 0x560f8538, 0x1e3daed5, 0x27362d39, 0x640a0fd9, 0x21685ca6, 0xd19b5b54, 0x3a24362e, 0xb10c0a67, 0x0f9357e7, 0xd2b4ee96, 0x9e1b9b91, 0x4f80c0c5, 0xa261dc20, 0x695a774b, 0x161c121a, 0x0ae293ba, 0xe5c0a02a, 0x433c22e0, 0x1d121b17, 0x0b0e090d, 0xadf28bc7, 0xb92db6a8, 0xc8141ea9, 0x8557f119, 0x4caf7507, 0xbbee99dd, 0xfda37f60, 0x9ff70126, 0xbc5c72f5, 0xc544663b, 0x345bfb7e, 0x768b4329, 0xdccb23c6, 0x68b6edfc, 0x63b8e4f1, 0xcad731dc, 0x10426385, 0x40139722, 0x2084c611, 0x7d854a24, 0xf8d2bb3d, 0x11aef932, 0x6dc729a1, 0x4b1d9e2f, 0xf3dcb230, 0xec0d8652, 0xd077c1e3, 0x6c2bb316, 0x99a970b9, 0xfa119448, 0x2247e964, 0xc4a8fc8c, 0x1aa0f03f, 0xd8567d2c, 0xef223390, 0xc787494e, 0xc1d938d1, 0xfe8ccaa2, 0x3698d40b, 0xcfa6f581, 0x28a57ade, 0x26dab78e, 0xa43fadbf, 0xe42c3a9d, 0x0d507892, 0x9b6a5fcc, 0x62547e46, 0xc2f68d13, 0xe890d8b8, 0x5e2e39f7, 0xf582c3af, 0xbe9f5d80, 0x7c69d093, 0xa96fd52d, 0xb3cf2512, 0x3bc8ac99, 0xa710187d, 0x6ee89c63, 0x7bdb3bbb, 0x09cd2678, 0xf46e5918, 0x01ec9ab7, 0xa8834f9a, 0x65e6956e, 0x7eaaffe6, 0x0821bccf, 0xe6ef15e8, 0xd9bae79b, 0xce4a6f36, 0xd4ea9f09, 0xd629b07c, 0xaf31a4b2, 0x312a3f23, 0x30c6a594, 0xc035a266, 0x37744ebc, 0xa6fc82ca, 0xb0e090d0, 0x1533a7d8, 0x4af10498, 0xf741ecda, 0x0e7fcd50, 0x2f1791f6, 0x8d764dd6, 0x4d43efb0, 0x54ccaa4d, 0xdfe49604, 0xe39ed1b5, 0x1b4c6a88, 0xb8c12c1f, 0x7f466551, 0x049d5eea, 0x5d018c35, 0x73fa8774, 0x2efb0b41, 0x5ab3671d, 0x5292dbd2, 0x33e91056, 0x136dd647, 0x8c9ad761, 0x7a37a10c, 0x8e59f814, 0x89eb133c, 0xeecea927, 0x35b761c9, 0xede11ce5, 0x3c7a47b1, 0x599cd2df, 0x3f55f273, 0x791814ce, 0xbf73c737, 0xea53f7cd, 0x5b5ffdaa, 0x14df3d6f, 0x867844db, 0x81caaff3, 0x3eb968c4, 0x2c382434, 0x5fc2a340, 0x72161dc3, 0x0cbce225, 0x8b283c49, 0x41ff0d95, 0x7139a801, 0xde080cb3, 0x9cd8b4e4, 0x906456c1, 0x617bcb84, 0x70d532b6, 0x74486c5c, 0x42d0b857];
- var T7 = [0xa75051f4, 0x65537e41, 0xa4c31a17, 0x5e963a27, 0x6bcb3bab, 0x45f11f9d, 0x58abacfa, 0x03934be3, 0xfa552030, 0x6df6ad76, 0x769188cc, 0x4c25f502, 0xd7fc4fe5, 0xcbd7c52a, 0x44802635, 0xa38fb562, 0x5a49deb1, 0x1b6725ba, 0x0e9845ea, 0xc0e15dfe, 0x7502c32f, 0xf012814c, 0x97a38d46, 0xf9c66bd3, 0x5fe7038f, 0x9c951592, 0x7aebbf6d, 0x59da9552, 0x832dd4be, 0x21d35874, 0x692949e0, 0xc8448ec9, 0x896a75c2, 0x7978f48e, 0x3e6b9958, 0x71dd27b9, 0x4fb6bee1, 0xad17f088, 0xac66c920, 0x3ab47dce, 0x4a1863df, 0x3182e51a, 0x33609751, 0x7f456253, 0x77e0b164, 0xae84bb6b, 0xa01cfe81, 0x2b94f908, 0x68587048, 0xfd198f45, 0x6c8794de, 0xf8b7527b, 0xd323ab73, 0x02e2724b, 0x8f57e31f, 0xab2a6655, 0x2807b2eb, 0xc2032fb5, 0x7b9a86c5, 0x08a5d337, 0x87f23028, 0xa5b223bf, 0x6aba0203, 0x825ced16, 0x1c2b8acf, 0xb492a779, 0xf2f0f307, 0xe2a14e69, 0xf4cd65da, 0xbed50605, 0x621fd134, 0xfe8ac4a6, 0x539d342e, 0x55a0a2f3, 0xe132058a, 0xeb75a4f6, 0xec390b83, 0xefaa4060, 0x9f065e71, 0x1051bd6e, 0x8af93e21, 0x063d96dd, 0x05aedd3e, 0xbd464de6, 0x8db59154, 0x5d0571c4, 0xd46f0406, 0x15ff6050, 0xfb241998, 0xe997d6bd, 0x43cc8940, 0x9e7767d9, 0x42bdb0e8, 0x8b880789, 0x5b38e719, 0xeedb79c8, 0x0a47a17c, 0x0fe97c42, 0x1ec9f884, 0x00000000, 0x86830980, 0xed48322b, 0x70ac1e11, 0x724e6c5a, 0xfffbfd0e, 0x38560f85, 0xd51e3dae, 0x3927362d, 0xd9640a0f, 0xa621685c, 0x54d19b5b, 0x2e3a2436, 0x67b10c0a, 0xe70f9357, 0x96d2b4ee, 0x919e1b9b, 0xc54f80c0, 0x20a261dc, 0x4b695a77, 0x1a161c12, 0xba0ae293, 0x2ae5c0a0, 0xe0433c22, 0x171d121b, 0x0d0b0e09, 0xc7adf28b, 0xa8b92db6, 0xa9c8141e, 0x198557f1, 0x074caf75, 0xddbbee99, 0x60fda37f, 0x269ff701, 0xf5bc5c72, 0x3bc54466, 0x7e345bfb, 0x29768b43, 0xc6dccb23, 0xfc68b6ed, 0xf163b8e4, 0xdccad731, 0x85104263, 0x22401397, 0x112084c6, 0x247d854a, 0x3df8d2bb, 0x3211aef9, 0xa16dc729, 0x2f4b1d9e, 0x30f3dcb2, 0x52ec0d86, 0xe3d077c1, 0x166c2bb3, 0xb999a970, 0x48fa1194, 0x642247e9, 0x8cc4a8fc, 0x3f1aa0f0, 0x2cd8567d, 0x90ef2233, 0x4ec78749, 0xd1c1d938, 0xa2fe8cca, 0x0b3698d4, 0x81cfa6f5, 0xde28a57a, 0x8e26dab7, 0xbfa43fad, 0x9de42c3a, 0x920d5078, 0xcc9b6a5f, 0x4662547e, 0x13c2f68d, 0xb8e890d8, 0xf75e2e39, 0xaff582c3, 0x80be9f5d, 0x937c69d0, 0x2da96fd5, 0x12b3cf25, 0x993bc8ac, 0x7da71018, 0x636ee89c, 0xbb7bdb3b, 0x7809cd26, 0x18f46e59, 0xb701ec9a, 0x9aa8834f, 0x6e65e695, 0xe67eaaff, 0xcf0821bc, 0xe8e6ef15, 0x9bd9bae7, 0x36ce4a6f, 0x09d4ea9f, 0x7cd629b0, 0xb2af31a4, 0x23312a3f, 0x9430c6a5, 0x66c035a2, 0xbc37744e, 0xcaa6fc82, 0xd0b0e090, 0xd81533a7, 0x984af104, 0xdaf741ec, 0x500e7fcd, 0xf62f1791, 0xd68d764d, 0xb04d43ef, 0x4d54ccaa, 0x04dfe496, 0xb5e39ed1, 0x881b4c6a, 0x1fb8c12c, 0x517f4665, 0xea049d5e, 0x355d018c, 0x7473fa87, 0x412efb0b, 0x1d5ab367, 0xd25292db, 0x5633e910, 0x47136dd6, 0x618c9ad7, 0x0c7a37a1, 0x148e59f8, 0x3c89eb13, 0x27eecea9, 0xc935b761, 0xe5ede11c, 0xb13c7a47, 0xdf599cd2, 0x733f55f2, 0xce791814, 0x37bf73c7, 0xcdea53f7, 0xaa5b5ffd, 0x6f14df3d, 0xdb867844, 0xf381caaf, 0xc43eb968, 0x342c3824, 0x405fc2a3, 0xc372161d, 0x250cbce2, 0x498b283c, 0x9541ff0d, 0x017139a8, 0xb3de080c, 0xe49cd8b4, 0xc1906456, 0x84617bcb, 0xb670d532, 0x5c74486c, 0x5742d0b8];
- var T8 = [0xf4a75051, 0x4165537e, 0x17a4c31a, 0x275e963a, 0xab6bcb3b, 0x9d45f11f, 0xfa58abac, 0xe303934b, 0x30fa5520, 0x766df6ad, 0xcc769188, 0x024c25f5, 0xe5d7fc4f, 0x2acbd7c5, 0x35448026, 0x62a38fb5, 0xb15a49de, 0xba1b6725, 0xea0e9845, 0xfec0e15d, 0x2f7502c3, 0x4cf01281, 0x4697a38d, 0xd3f9c66b, 0x8f5fe703, 0x929c9515, 0x6d7aebbf, 0x5259da95, 0xbe832dd4, 0x7421d358, 0xe0692949, 0xc9c8448e, 0xc2896a75, 0x8e7978f4, 0x583e6b99, 0xb971dd27, 0xe14fb6be, 0x88ad17f0, 0x20ac66c9, 0xce3ab47d, 0xdf4a1863, 0x1a3182e5, 0x51336097, 0x537f4562, 0x6477e0b1, 0x6bae84bb, 0x81a01cfe, 0x082b94f9, 0x48685870, 0x45fd198f, 0xde6c8794, 0x7bf8b752, 0x73d323ab, 0x4b02e272, 0x1f8f57e3, 0x55ab2a66, 0xeb2807b2, 0xb5c2032f, 0xc57b9a86, 0x3708a5d3, 0x2887f230, 0xbfa5b223, 0x036aba02, 0x16825ced, 0xcf1c2b8a, 0x79b492a7, 0x07f2f0f3, 0x69e2a14e, 0xdaf4cd65, 0x05bed506, 0x34621fd1, 0xa6fe8ac4, 0x2e539d34, 0xf355a0a2, 0x8ae13205, 0xf6eb75a4, 0x83ec390b, 0x60efaa40, 0x719f065e, 0x6e1051bd, 0x218af93e, 0xdd063d96, 0x3e05aedd, 0xe6bd464d, 0x548db591, 0xc45d0571, 0x06d46f04, 0x5015ff60, 0x98fb2419, 0xbde997d6, 0x4043cc89, 0xd99e7767, 0xe842bdb0, 0x898b8807, 0x195b38e7, 0xc8eedb79, 0x7c0a47a1, 0x420fe97c, 0x841ec9f8, 0x00000000, 0x80868309, 0x2bed4832, 0x1170ac1e, 0x5a724e6c, 0x0efffbfd, 0x8538560f, 0xaed51e3d, 0x2d392736, 0x0fd9640a, 0x5ca62168, 0x5b54d19b, 0x362e3a24, 0x0a67b10c, 0x57e70f93, 0xee96d2b4, 0x9b919e1b, 0xc0c54f80, 0xdc20a261, 0x774b695a, 0x121a161c, 0x93ba0ae2, 0xa02ae5c0, 0x22e0433c, 0x1b171d12, 0x090d0b0e, 0x8bc7adf2, 0xb6a8b92d, 0x1ea9c814, 0xf1198557, 0x75074caf, 0x99ddbbee, 0x7f60fda3, 0x01269ff7, 0x72f5bc5c, 0x663bc544, 0xfb7e345b, 0x4329768b, 0x23c6dccb, 0xedfc68b6, 0xe4f163b8, 0x31dccad7, 0x63851042, 0x97224013, 0xc6112084, 0x4a247d85, 0xbb3df8d2, 0xf93211ae, 0x29a16dc7, 0x9e2f4b1d, 0xb230f3dc, 0x8652ec0d, 0xc1e3d077, 0xb3166c2b, 0x70b999a9, 0x9448fa11, 0xe9642247, 0xfc8cc4a8, 0xf03f1aa0, 0x7d2cd856, 0x3390ef22, 0x494ec787, 0x38d1c1d9, 0xcaa2fe8c, 0xd40b3698, 0xf581cfa6, 0x7ade28a5, 0xb78e26da, 0xadbfa43f, 0x3a9de42c, 0x78920d50, 0x5fcc9b6a, 0x7e466254, 0x8d13c2f6, 0xd8b8e890, 0x39f75e2e, 0xc3aff582, 0x5d80be9f, 0xd0937c69, 0xd52da96f, 0x2512b3cf, 0xac993bc8, 0x187da710, 0x9c636ee8, 0x3bbb7bdb, 0x267809cd, 0x5918f46e, 0x9ab701ec, 0x4f9aa883, 0x956e65e6, 0xffe67eaa, 0xbccf0821, 0x15e8e6ef, 0xe79bd9ba, 0x6f36ce4a, 0x9f09d4ea, 0xb07cd629, 0xa4b2af31, 0x3f23312a, 0xa59430c6, 0xa266c035, 0x4ebc3774, 0x82caa6fc, 0x90d0b0e0, 0xa7d81533, 0x04984af1, 0xecdaf741, 0xcd500e7f, 0x91f62f17, 0x4dd68d76, 0xefb04d43, 0xaa4d54cc, 0x9604dfe4, 0xd1b5e39e, 0x6a881b4c, 0x2c1fb8c1, 0x65517f46, 0x5eea049d, 0x8c355d01, 0x877473fa, 0x0b412efb, 0x671d5ab3, 0xdbd25292, 0x105633e9, 0xd647136d, 0xd7618c9a, 0xa10c7a37, 0xf8148e59, 0x133c89eb, 0xa927eece, 0x61c935b7, 0x1ce5ede1, 0x47b13c7a, 0xd2df599c, 0xf2733f55, 0x14ce7918, 0xc737bf73, 0xf7cdea53, 0xfdaa5b5f, 0x3d6f14df, 0x44db8678, 0xaff381ca, 0x68c43eb9, 0x24342c38, 0xa3405fc2, 0x1dc37216, 0xe2250cbc, 0x3c498b28, 0x0d9541ff, 0xa8017139, 0x0cb3de08, 0xb4e49cd8, 0x56c19064, 0xcb84617b, 0x32b670d5, 0x6c5c7448, 0xb85742d0];
- // Transformations for decryption key expansion
- var U1 = [0x00000000, 0x0e090d0b, 0x1c121a16, 0x121b171d, 0x3824342c, 0x362d3927, 0x24362e3a, 0x2a3f2331, 0x70486858, 0x7e416553, 0x6c5a724e, 0x62537f45, 0x486c5c74, 0x4665517f, 0x547e4662, 0x5a774b69, 0xe090d0b0, 0xee99ddbb, 0xfc82caa6, 0xf28bc7ad, 0xd8b4e49c, 0xd6bde997, 0xc4a6fe8a, 0xcaaff381, 0x90d8b8e8, 0x9ed1b5e3, 0x8ccaa2fe, 0x82c3aff5, 0xa8fc8cc4, 0xa6f581cf, 0xb4ee96d2, 0xbae79bd9, 0xdb3bbb7b, 0xd532b670, 0xc729a16d, 0xc920ac66, 0xe31f8f57, 0xed16825c, 0xff0d9541, 0xf104984a, 0xab73d323, 0xa57ade28, 0xb761c935, 0xb968c43e, 0x9357e70f, 0x9d5eea04, 0x8f45fd19, 0x814cf012, 0x3bab6bcb, 0x35a266c0, 0x27b971dd, 0x29b07cd6, 0x038f5fe7, 0x0d8652ec, 0x1f9d45f1, 0x119448fa, 0x4be30393, 0x45ea0e98, 0x57f11985, 0x59f8148e, 0x73c737bf, 0x7dce3ab4, 0x6fd52da9, 0x61dc20a2, 0xad766df6, 0xa37f60fd, 0xb16477e0, 0xbf6d7aeb, 0x955259da, 0x9b5b54d1, 0x894043cc, 0x87494ec7, 0xdd3e05ae, 0xd33708a5, 0xc12c1fb8, 0xcf2512b3, 0xe51a3182, 0xeb133c89, 0xf9082b94, 0xf701269f, 0x4de6bd46, 0x43efb04d, 0x51f4a750, 0x5ffdaa5b, 0x75c2896a, 0x7bcb8461, 0x69d0937c, 0x67d99e77, 0x3daed51e, 0x33a7d815, 0x21bccf08, 0x2fb5c203, 0x058ae132, 0x0b83ec39, 0x1998fb24, 0x1791f62f, 0x764dd68d, 0x7844db86, 0x6a5fcc9b, 0x6456c190, 0x4e69e2a1, 0x4060efaa, 0x527bf8b7, 0x5c72f5bc, 0x0605bed5, 0x080cb3de, 0x1a17a4c3, 0x141ea9c8, 0x3e218af9, 0x302887f2, 0x223390ef, 0x2c3a9de4, 0x96dd063d, 0x98d40b36, 0x8acf1c2b, 0x84c61120, 0xaef93211, 0xa0f03f1a, 0xb2eb2807, 0xbce2250c, 0xe6956e65, 0xe89c636e, 0xfa877473, 0xf48e7978, 0xdeb15a49, 0xd0b85742, 0xc2a3405f, 0xccaa4d54, 0x41ecdaf7, 0x4fe5d7fc, 0x5dfec0e1, 0x53f7cdea, 0x79c8eedb, 0x77c1e3d0, 0x65daf4cd, 0x6bd3f9c6, 0x31a4b2af, 0x3fadbfa4, 0x2db6a8b9, 0x23bfa5b2, 0x09808683, 0x07898b88, 0x15929c95, 0x1b9b919e, 0xa17c0a47, 0xaf75074c, 0xbd6e1051, 0xb3671d5a, 0x99583e6b, 0x97513360, 0x854a247d, 0x8b432976, 0xd134621f, 0xdf3d6f14, 0xcd267809, 0xc32f7502, 0xe9105633, 0xe7195b38, 0xf5024c25, 0xfb0b412e, 0x9ad7618c, 0x94de6c87, 0x86c57b9a, 0x88cc7691, 0xa2f355a0, 0xacfa58ab, 0xbee14fb6, 0xb0e842bd, 0xea9f09d4, 0xe49604df, 0xf68d13c2, 0xf8841ec9, 0xd2bb3df8, 0xdcb230f3, 0xcea927ee, 0xc0a02ae5, 0x7a47b13c, 0x744ebc37, 0x6655ab2a, 0x685ca621, 0x42638510, 0x4c6a881b, 0x5e719f06, 0x5078920d, 0x0a0fd964, 0x0406d46f, 0x161dc372, 0x1814ce79, 0x322bed48, 0x3c22e043, 0x2e39f75e, 0x2030fa55, 0xec9ab701, 0xe293ba0a, 0xf088ad17, 0xfe81a01c, 0xd4be832d, 0xdab78e26, 0xc8ac993b, 0xc6a59430, 0x9cd2df59, 0x92dbd252, 0x80c0c54f, 0x8ec9c844, 0xa4f6eb75, 0xaaffe67e, 0xb8e4f163, 0xb6edfc68, 0x0c0a67b1, 0x02036aba, 0x10187da7, 0x1e1170ac, 0x342e539d, 0x3a275e96, 0x283c498b, 0x26354480, 0x7c420fe9, 0x724b02e2, 0x605015ff, 0x6e5918f4, 0x44663bc5, 0x4a6f36ce, 0x587421d3, 0x567d2cd8, 0x37a10c7a, 0x39a80171, 0x2bb3166c, 0x25ba1b67, 0x0f853856, 0x018c355d, 0x13972240, 0x1d9e2f4b, 0x47e96422, 0x49e06929, 0x5bfb7e34, 0x55f2733f, 0x7fcd500e, 0x71c45d05, 0x63df4a18, 0x6dd64713, 0xd731dcca, 0xd938d1c1, 0xcb23c6dc, 0xc52acbd7, 0xef15e8e6, 0xe11ce5ed, 0xf307f2f0, 0xfd0efffb, 0xa779b492, 0xa970b999, 0xbb6bae84, 0xb562a38f, 0x9f5d80be, 0x91548db5, 0x834f9aa8, 0x8d4697a3];
- var U2 = [0x00000000, 0x0b0e090d, 0x161c121a, 0x1d121b17, 0x2c382434, 0x27362d39, 0x3a24362e, 0x312a3f23, 0x58704868, 0x537e4165, 0x4e6c5a72, 0x4562537f, 0x74486c5c, 0x7f466551, 0x62547e46, 0x695a774b, 0xb0e090d0, 0xbbee99dd, 0xa6fc82ca, 0xadf28bc7, 0x9cd8b4e4, 0x97d6bde9, 0x8ac4a6fe, 0x81caaff3, 0xe890d8b8, 0xe39ed1b5, 0xfe8ccaa2, 0xf582c3af, 0xc4a8fc8c, 0xcfa6f581, 0xd2b4ee96, 0xd9bae79b, 0x7bdb3bbb, 0x70d532b6, 0x6dc729a1, 0x66c920ac, 0x57e31f8f, 0x5ced1682, 0x41ff0d95, 0x4af10498, 0x23ab73d3, 0x28a57ade, 0x35b761c9, 0x3eb968c4, 0x0f9357e7, 0x049d5eea, 0x198f45fd, 0x12814cf0, 0xcb3bab6b, 0xc035a266, 0xdd27b971, 0xd629b07c, 0xe7038f5f, 0xec0d8652, 0xf11f9d45, 0xfa119448, 0x934be303, 0x9845ea0e, 0x8557f119, 0x8e59f814, 0xbf73c737, 0xb47dce3a, 0xa96fd52d, 0xa261dc20, 0xf6ad766d, 0xfda37f60, 0xe0b16477, 0xebbf6d7a, 0xda955259, 0xd19b5b54, 0xcc894043, 0xc787494e, 0xaedd3e05, 0xa5d33708, 0xb8c12c1f, 0xb3cf2512, 0x82e51a31, 0x89eb133c, 0x94f9082b, 0x9ff70126, 0x464de6bd, 0x4d43efb0, 0x5051f4a7, 0x5b5ffdaa, 0x6a75c289, 0x617bcb84, 0x7c69d093, 0x7767d99e, 0x1e3daed5, 0x1533a7d8, 0x0821bccf, 0x032fb5c2, 0x32058ae1, 0x390b83ec, 0x241998fb, 0x2f1791f6, 0x8d764dd6, 0x867844db, 0x9b6a5fcc, 0x906456c1, 0xa14e69e2, 0xaa4060ef, 0xb7527bf8, 0xbc5c72f5, 0xd50605be, 0xde080cb3, 0xc31a17a4, 0xc8141ea9, 0xf93e218a, 0xf2302887, 0xef223390, 0xe42c3a9d, 0x3d96dd06, 0x3698d40b, 0x2b8acf1c, 0x2084c611, 0x11aef932, 0x1aa0f03f, 0x07b2eb28, 0x0cbce225, 0x65e6956e, 0x6ee89c63, 0x73fa8774, 0x78f48e79, 0x49deb15a, 0x42d0b857, 0x5fc2a340, 0x54ccaa4d, 0xf741ecda, 0xfc4fe5d7, 0xe15dfec0, 0xea53f7cd, 0xdb79c8ee, 0xd077c1e3, 0xcd65daf4, 0xc66bd3f9, 0xaf31a4b2, 0xa43fadbf, 0xb92db6a8, 0xb223bfa5, 0x83098086, 0x8807898b, 0x9515929c, 0x9e1b9b91, 0x47a17c0a, 0x4caf7507, 0x51bd6e10, 0x5ab3671d, 0x6b99583e, 0x60975133, 0x7d854a24, 0x768b4329, 0x1fd13462, 0x14df3d6f, 0x09cd2678, 0x02c32f75, 0x33e91056, 0x38e7195b, 0x25f5024c, 0x2efb0b41, 0x8c9ad761, 0x8794de6c, 0x9a86c57b, 0x9188cc76, 0xa0a2f355, 0xabacfa58, 0xb6bee14f, 0xbdb0e842, 0xd4ea9f09, 0xdfe49604, 0xc2f68d13, 0xc9f8841e, 0xf8d2bb3d, 0xf3dcb230, 0xeecea927, 0xe5c0a02a, 0x3c7a47b1, 0x37744ebc, 0x2a6655ab, 0x21685ca6, 0x10426385, 0x1b4c6a88, 0x065e719f, 0x0d507892, 0x640a0fd9, 0x6f0406d4, 0x72161dc3, 0x791814ce, 0x48322bed, 0x433c22e0, 0x5e2e39f7, 0x552030fa, 0x01ec9ab7, 0x0ae293ba, 0x17f088ad, 0x1cfe81a0, 0x2dd4be83, 0x26dab78e, 0x3bc8ac99, 0x30c6a594, 0x599cd2df, 0x5292dbd2, 0x4f80c0c5, 0x448ec9c8, 0x75a4f6eb, 0x7eaaffe6, 0x63b8e4f1, 0x68b6edfc, 0xb10c0a67, 0xba02036a, 0xa710187d, 0xac1e1170, 0x9d342e53, 0x963a275e, 0x8b283c49, 0x80263544, 0xe97c420f, 0xe2724b02, 0xff605015, 0xf46e5918, 0xc544663b, 0xce4a6f36, 0xd3587421, 0xd8567d2c, 0x7a37a10c, 0x7139a801, 0x6c2bb316, 0x6725ba1b, 0x560f8538, 0x5d018c35, 0x40139722, 0x4b1d9e2f, 0x2247e964, 0x2949e069, 0x345bfb7e, 0x3f55f273, 0x0e7fcd50, 0x0571c45d, 0x1863df4a, 0x136dd647, 0xcad731dc, 0xc1d938d1, 0xdccb23c6, 0xd7c52acb, 0xe6ef15e8, 0xede11ce5, 0xf0f307f2, 0xfbfd0eff, 0x92a779b4, 0x99a970b9, 0x84bb6bae, 0x8fb562a3, 0xbe9f5d80, 0xb591548d, 0xa8834f9a, 0xa38d4697];
- var U3 = [0x00000000, 0x0d0b0e09, 0x1a161c12, 0x171d121b, 0x342c3824, 0x3927362d, 0x2e3a2436, 0x23312a3f, 0x68587048, 0x65537e41, 0x724e6c5a, 0x7f456253, 0x5c74486c, 0x517f4665, 0x4662547e, 0x4b695a77, 0xd0b0e090, 0xddbbee99, 0xcaa6fc82, 0xc7adf28b, 0xe49cd8b4, 0xe997d6bd, 0xfe8ac4a6, 0xf381caaf, 0xb8e890d8, 0xb5e39ed1, 0xa2fe8cca, 0xaff582c3, 0x8cc4a8fc, 0x81cfa6f5, 0x96d2b4ee, 0x9bd9bae7, 0xbb7bdb3b, 0xb670d532, 0xa16dc729, 0xac66c920, 0x8f57e31f, 0x825ced16, 0x9541ff0d, 0x984af104, 0xd323ab73, 0xde28a57a, 0xc935b761, 0xc43eb968, 0xe70f9357, 0xea049d5e, 0xfd198f45, 0xf012814c, 0x6bcb3bab, 0x66c035a2, 0x71dd27b9, 0x7cd629b0, 0x5fe7038f, 0x52ec0d86, 0x45f11f9d, 0x48fa1194, 0x03934be3, 0x0e9845ea, 0x198557f1, 0x148e59f8, 0x37bf73c7, 0x3ab47dce, 0x2da96fd5, 0x20a261dc, 0x6df6ad76, 0x60fda37f, 0x77e0b164, 0x7aebbf6d, 0x59da9552, 0x54d19b5b, 0x43cc8940, 0x4ec78749, 0x05aedd3e, 0x08a5d337, 0x1fb8c12c, 0x12b3cf25, 0x3182e51a, 0x3c89eb13, 0x2b94f908, 0x269ff701, 0xbd464de6, 0xb04d43ef, 0xa75051f4, 0xaa5b5ffd, 0x896a75c2, 0x84617bcb, 0x937c69d0, 0x9e7767d9, 0xd51e3dae, 0xd81533a7, 0xcf0821bc, 0xc2032fb5, 0xe132058a, 0xec390b83, 0xfb241998, 0xf62f1791, 0xd68d764d, 0xdb867844, 0xcc9b6a5f, 0xc1906456, 0xe2a14e69, 0xefaa4060, 0xf8b7527b, 0xf5bc5c72, 0xbed50605, 0xb3de080c, 0xa4c31a17, 0xa9c8141e, 0x8af93e21, 0x87f23028, 0x90ef2233, 0x9de42c3a, 0x063d96dd, 0x0b3698d4, 0x1c2b8acf, 0x112084c6, 0x3211aef9, 0x3f1aa0f0, 0x2807b2eb, 0x250cbce2, 0x6e65e695, 0x636ee89c, 0x7473fa87, 0x7978f48e, 0x5a49deb1, 0x5742d0b8, 0x405fc2a3, 0x4d54ccaa, 0xdaf741ec, 0xd7fc4fe5, 0xc0e15dfe, 0xcdea53f7, 0xeedb79c8, 0xe3d077c1, 0xf4cd65da, 0xf9c66bd3, 0xb2af31a4, 0xbfa43fad, 0xa8b92db6, 0xa5b223bf, 0x86830980, 0x8b880789, 0x9c951592, 0x919e1b9b, 0x0a47a17c, 0x074caf75, 0x1051bd6e, 0x1d5ab367, 0x3e6b9958, 0x33609751, 0x247d854a, 0x29768b43, 0x621fd134, 0x6f14df3d, 0x7809cd26, 0x7502c32f, 0x5633e910, 0x5b38e719, 0x4c25f502, 0x412efb0b, 0x618c9ad7, 0x6c8794de, 0x7b9a86c5, 0x769188cc, 0x55a0a2f3, 0x58abacfa, 0x4fb6bee1, 0x42bdb0e8, 0x09d4ea9f, 0x04dfe496, 0x13c2f68d, 0x1ec9f884, 0x3df8d2bb, 0x30f3dcb2, 0x27eecea9, 0x2ae5c0a0, 0xb13c7a47, 0xbc37744e, 0xab2a6655, 0xa621685c, 0x85104263, 0x881b4c6a, 0x9f065e71, 0x920d5078, 0xd9640a0f, 0xd46f0406, 0xc372161d, 0xce791814, 0xed48322b, 0xe0433c22, 0xf75e2e39, 0xfa552030, 0xb701ec9a, 0xba0ae293, 0xad17f088, 0xa01cfe81, 0x832dd4be, 0x8e26dab7, 0x993bc8ac, 0x9430c6a5, 0xdf599cd2, 0xd25292db, 0xc54f80c0, 0xc8448ec9, 0xeb75a4f6, 0xe67eaaff, 0xf163b8e4, 0xfc68b6ed, 0x67b10c0a, 0x6aba0203, 0x7da71018, 0x70ac1e11, 0x539d342e, 0x5e963a27, 0x498b283c, 0x44802635, 0x0fe97c42, 0x02e2724b, 0x15ff6050, 0x18f46e59, 0x3bc54466, 0x36ce4a6f, 0x21d35874, 0x2cd8567d, 0x0c7a37a1, 0x017139a8, 0x166c2bb3, 0x1b6725ba, 0x38560f85, 0x355d018c, 0x22401397, 0x2f4b1d9e, 0x642247e9, 0x692949e0, 0x7e345bfb, 0x733f55f2, 0x500e7fcd, 0x5d0571c4, 0x4a1863df, 0x47136dd6, 0xdccad731, 0xd1c1d938, 0xc6dccb23, 0xcbd7c52a, 0xe8e6ef15, 0xe5ede11c, 0xf2f0f307, 0xfffbfd0e, 0xb492a779, 0xb999a970, 0xae84bb6b, 0xa38fb562, 0x80be9f5d, 0x8db59154, 0x9aa8834f, 0x97a38d46];
- var U4 = [0x00000000, 0x090d0b0e, 0x121a161c, 0x1b171d12, 0x24342c38, 0x2d392736, 0x362e3a24, 0x3f23312a, 0x48685870, 0x4165537e, 0x5a724e6c, 0x537f4562, 0x6c5c7448, 0x65517f46, 0x7e466254, 0x774b695a, 0x90d0b0e0, 0x99ddbbee, 0x82caa6fc, 0x8bc7adf2, 0xb4e49cd8, 0xbde997d6, 0xa6fe8ac4, 0xaff381ca, 0xd8b8e890, 0xd1b5e39e, 0xcaa2fe8c, 0xc3aff582, 0xfc8cc4a8, 0xf581cfa6, 0xee96d2b4, 0xe79bd9ba, 0x3bbb7bdb, 0x32b670d5, 0x29a16dc7, 0x20ac66c9, 0x1f8f57e3, 0x16825ced, 0x0d9541ff, 0x04984af1, 0x73d323ab, 0x7ade28a5, 0x61c935b7, 0x68c43eb9, 0x57e70f93, 0x5eea049d, 0x45fd198f, 0x4cf01281, 0xab6bcb3b, 0xa266c035, 0xb971dd27, 0xb07cd629, 0x8f5fe703, 0x8652ec0d, 0x9d45f11f, 0x9448fa11, 0xe303934b, 0xea0e9845, 0xf1198557, 0xf8148e59, 0xc737bf73, 0xce3ab47d, 0xd52da96f, 0xdc20a261, 0x766df6ad, 0x7f60fda3, 0x6477e0b1, 0x6d7aebbf, 0x5259da95, 0x5b54d19b, 0x4043cc89, 0x494ec787, 0x3e05aedd, 0x3708a5d3, 0x2c1fb8c1, 0x2512b3cf, 0x1a3182e5, 0x133c89eb, 0x082b94f9, 0x01269ff7, 0xe6bd464d, 0xefb04d43, 0xf4a75051, 0xfdaa5b5f, 0xc2896a75, 0xcb84617b, 0xd0937c69, 0xd99e7767, 0xaed51e3d, 0xa7d81533, 0xbccf0821, 0xb5c2032f, 0x8ae13205, 0x83ec390b, 0x98fb2419, 0x91f62f17, 0x4dd68d76, 0x44db8678, 0x5fcc9b6a, 0x56c19064, 0x69e2a14e, 0x60efaa40, 0x7bf8b752, 0x72f5bc5c, 0x05bed506, 0x0cb3de08, 0x17a4c31a, 0x1ea9c814, 0x218af93e, 0x2887f230, 0x3390ef22, 0x3a9de42c, 0xdd063d96, 0xd40b3698, 0xcf1c2b8a, 0xc6112084, 0xf93211ae, 0xf03f1aa0, 0xeb2807b2, 0xe2250cbc, 0x956e65e6, 0x9c636ee8, 0x877473fa, 0x8e7978f4, 0xb15a49de, 0xb85742d0, 0xa3405fc2, 0xaa4d54cc, 0xecdaf741, 0xe5d7fc4f, 0xfec0e15d, 0xf7cdea53, 0xc8eedb79, 0xc1e3d077, 0xdaf4cd65, 0xd3f9c66b, 0xa4b2af31, 0xadbfa43f, 0xb6a8b92d, 0xbfa5b223, 0x80868309, 0x898b8807, 0x929c9515, 0x9b919e1b, 0x7c0a47a1, 0x75074caf, 0x6e1051bd, 0x671d5ab3, 0x583e6b99, 0x51336097, 0x4a247d85, 0x4329768b, 0x34621fd1, 0x3d6f14df, 0x267809cd, 0x2f7502c3, 0x105633e9, 0x195b38e7, 0x024c25f5, 0x0b412efb, 0xd7618c9a, 0xde6c8794, 0xc57b9a86, 0xcc769188, 0xf355a0a2, 0xfa58abac, 0xe14fb6be, 0xe842bdb0, 0x9f09d4ea, 0x9604dfe4, 0x8d13c2f6, 0x841ec9f8, 0xbb3df8d2, 0xb230f3dc, 0xa927eece, 0xa02ae5c0, 0x47b13c7a, 0x4ebc3774, 0x55ab2a66, 0x5ca62168, 0x63851042, 0x6a881b4c, 0x719f065e, 0x78920d50, 0x0fd9640a, 0x06d46f04, 0x1dc37216, 0x14ce7918, 0x2bed4832, 0x22e0433c, 0x39f75e2e, 0x30fa5520, 0x9ab701ec, 0x93ba0ae2, 0x88ad17f0, 0x81a01cfe, 0xbe832dd4, 0xb78e26da, 0xac993bc8, 0xa59430c6, 0xd2df599c, 0xdbd25292, 0xc0c54f80, 0xc9c8448e, 0xf6eb75a4, 0xffe67eaa, 0xe4f163b8, 0xedfc68b6, 0x0a67b10c, 0x036aba02, 0x187da710, 0x1170ac1e, 0x2e539d34, 0x275e963a, 0x3c498b28, 0x35448026, 0x420fe97c, 0x4b02e272, 0x5015ff60, 0x5918f46e, 0x663bc544, 0x6f36ce4a, 0x7421d358, 0x7d2cd856, 0xa10c7a37, 0xa8017139, 0xb3166c2b, 0xba1b6725, 0x8538560f, 0x8c355d01, 0x97224013, 0x9e2f4b1d, 0xe9642247, 0xe0692949, 0xfb7e345b, 0xf2733f55, 0xcd500e7f, 0xc45d0571, 0xdf4a1863, 0xd647136d, 0x31dccad7, 0x38d1c1d9, 0x23c6dccb, 0x2acbd7c5, 0x15e8e6ef, 0x1ce5ede1, 0x07f2f0f3, 0x0efffbfd, 0x79b492a7, 0x70b999a9, 0x6bae84bb, 0x62a38fb5, 0x5d80be9f, 0x548db591, 0x4f9aa883, 0x4697a38d];
- function convertToInt32(bytes) {
- var result = [];
- for (var i = 0; i < bytes.length; i += 4) {
- result.push(
- (bytes[i ] << 24) |
- (bytes[i + 1] << 16) |
- (bytes[i + 2] << 8) |
- bytes[i + 3]
- );
- }
- return result;
- }
- var AES = function(key) {
- if (!(this instanceof AES)) {
- throw Error('AES must be instanitated with `new`');
- }
- Object.defineProperty(this, 'key', {
- value: coerceArray(key, true)
- });
- this._prepare();
- }
- AES.prototype._prepare = function() {
- var rounds = numberOfRounds[this.key.length];
- if (rounds == null) {
- throw new Error('invalid key size (must be 16, 24 or 32 bytes)');
- }
- // encryption round keys
- this._Ke = [];
- // decryption round keys
- this._Kd = [];
- for (var i = 0; i <= rounds; i++) {
- this._Ke.push([0, 0, 0, 0]);
- this._Kd.push([0, 0, 0, 0]);
- }
- var roundKeyCount = (rounds + 1) * 4;
- var KC = this.key.length / 4;
- // convert the key into ints
- var tk = convertToInt32(this.key);
- // copy values into round key arrays
- var index;
- for (var i = 0; i < KC; i++) {
- index = i >> 2;
- this._Ke[index][i % 4] = tk[i];
- this._Kd[rounds - index][i % 4] = tk[i];
- }
- // key expansion (fips-197 section 5.2)
- var rconpointer = 0;
- var t = KC, tt;
- while (t < roundKeyCount) {
- tt = tk[KC - 1];
- tk[0] ^= ((S[(tt >> 16) & 0xFF] << 24) ^
- (S[(tt >> 8) & 0xFF] << 16) ^
- (S[ tt & 0xFF] << 8) ^
- S[(tt >> 24) & 0xFF] ^
- (rcon[rconpointer] << 24));
- rconpointer += 1;
- // key expansion (for non-256 bit)
- if (KC != 8) {
- for (var i = 1; i < KC; i++) {
- tk[i] ^= tk[i - 1];
- }
- // key expansion for 256-bit keys is "slightly different" (fips-197)
- } else {
- for (var i = 1; i < (KC / 2); i++) {
- tk[i] ^= tk[i - 1];
- }
- tt = tk[(KC / 2) - 1];
- tk[KC / 2] ^= (S[ tt & 0xFF] ^
- (S[(tt >> 8) & 0xFF] << 8) ^
- (S[(tt >> 16) & 0xFF] << 16) ^
- (S[(tt >> 24) & 0xFF] << 24));
- for (var i = (KC / 2) + 1; i < KC; i++) {
- tk[i] ^= tk[i - 1];
- }
- }
- // copy values into round key arrays
- var i = 0, r, c;
- while (i < KC && t < roundKeyCount) {
- r = t >> 2;
- c = t % 4;
- this._Ke[r][c] = tk[i];
- this._Kd[rounds - r][c] = tk[i++];
- t++;
- }
- }
- // inverse-cipher-ify the decryption round key (fips-197 section 5.3)
- for (var r = 1; r < rounds; r++) {
- for (var c = 0; c < 4; c++) {
- tt = this._Kd[r][c];
- this._Kd[r][c] = (U1[(tt >> 24) & 0xFF] ^
- U2[(tt >> 16) & 0xFF] ^
- U3[(tt >> 8) & 0xFF] ^
- U4[ tt & 0xFF]);
- }
- }
- }
- AES.prototype.encrypt = function(plaintext) {
- if (plaintext.length != 16) {
- throw new Error('invalid plaintext size (must be 16 bytes)');
- }
- var rounds = this._Ke.length - 1;
- var a = [0, 0, 0, 0];
- // convert plaintext to (ints ^ key)
- var t = convertToInt32(plaintext);
- for (var i = 0; i < 4; i++) {
- t[i] ^= this._Ke[0][i];
- }
- // apply round transforms
- for (var r = 1; r < rounds; r++) {
- for (var i = 0; i < 4; i++) {
- a[i] = (T1[(t[ i ] >> 24) & 0xff] ^
- T2[(t[(i + 1) % 4] >> 16) & 0xff] ^
- T3[(t[(i + 2) % 4] >> 8) & 0xff] ^
- T4[ t[(i + 3) % 4] & 0xff] ^
- this._Ke[r][i]);
- }
- t = a.slice();
- }
- // the last round is special
- var result = createArray(16), tt;
- for (var i = 0; i < 4; i++) {
- tt = this._Ke[rounds][i];
- result[4 * i ] = (S[(t[ i ] >> 24) & 0xff] ^ (tt >> 24)) & 0xff;
- result[4 * i + 1] = (S[(t[(i + 1) % 4] >> 16) & 0xff] ^ (tt >> 16)) & 0xff;
- result[4 * i + 2] = (S[(t[(i + 2) % 4] >> 8) & 0xff] ^ (tt >> 8)) & 0xff;
- result[4 * i + 3] = (S[ t[(i + 3) % 4] & 0xff] ^ tt ) & 0xff;
- }
- return result;
- }
- AES.prototype.decrypt = function(ciphertext) {
- if (ciphertext.length != 16) {
- throw new Error('invalid ciphertext size (must be 16 bytes)');
- }
- var rounds = this._Kd.length - 1;
- var a = [0, 0, 0, 0];
- // convert plaintext to (ints ^ key)
- var t = convertToInt32(ciphertext);
- for (var i = 0; i < 4; i++) {
- t[i] ^= this._Kd[0][i];
- }
- // apply round transforms
- for (var r = 1; r < rounds; r++) {
- for (var i = 0; i < 4; i++) {
- a[i] = (T5[(t[ i ] >> 24) & 0xff] ^
- T6[(t[(i + 3) % 4] >> 16) & 0xff] ^
- T7[(t[(i + 2) % 4] >> 8) & 0xff] ^
- T8[ t[(i + 1) % 4] & 0xff] ^
- this._Kd[r][i]);
- }
- t = a.slice();
- }
- // the last round is special
- var result = createArray(16), tt;
- for (var i = 0; i < 4; i++) {
- tt = this._Kd[rounds][i];
- result[4 * i ] = (Si[(t[ i ] >> 24) & 0xff] ^ (tt >> 24)) & 0xff;
- result[4 * i + 1] = (Si[(t[(i + 3) % 4] >> 16) & 0xff] ^ (tt >> 16)) & 0xff;
- result[4 * i + 2] = (Si[(t[(i + 2) % 4] >> 8) & 0xff] ^ (tt >> 8)) & 0xff;
- result[4 * i + 3] = (Si[ t[(i + 1) % 4] & 0xff] ^ tt ) & 0xff;
- }
- return result;
- }
- /**
- * Mode Of Operation - Electonic Codebook (ECB)
- */
- var ModeOfOperationECB = function(key) {
- if (!(this instanceof ModeOfOperationECB)) {
- throw Error('AES must be instanitated with `new`');
- }
- this.description = "Electronic Code Block";
- this.name = "ecb";
- this._aes = new AES(key);
- }
- ModeOfOperationECB.prototype.encrypt = function(plaintext) {
- plaintext = coerceArray(plaintext);
- if ((plaintext.length % 16) !== 0) {
- throw new Error('invalid plaintext size (must be multiple of 16 bytes)');
- }
- var ciphertext = createArray(plaintext.length);
- var block = createArray(16);
- for (var i = 0; i < plaintext.length; i += 16) {
- copyArray(plaintext, block, 0, i, i + 16);
- block = this._aes.encrypt(block);
- copyArray(block, ciphertext, i);
- }
- return ciphertext;
- }
- ModeOfOperationECB.prototype.decrypt = function(ciphertext) {
- ciphertext = coerceArray(ciphertext);
- if ((ciphertext.length % 16) !== 0) {
- throw new Error('invalid ciphertext size (must be multiple of 16 bytes)');
- }
- var plaintext = createArray(ciphertext.length);
- var block = createArray(16);
- for (var i = 0; i < ciphertext.length; i += 16) {
- copyArray(ciphertext, block, 0, i, i + 16);
- block = this._aes.decrypt(block);
- copyArray(block, plaintext, i);
- }
- return plaintext;
- }
- /**
- * Mode Of Operation - Cipher Block Chaining (CBC)
- */
- var ModeOfOperationCBC = function(key, iv) {
- if (!(this instanceof ModeOfOperationCBC)) {
- throw Error('AES must be instanitated with `new`');
- }
- this.description = "Cipher Block Chaining";
- this.name = "cbc";
- if (!iv) {
- iv = createArray(16);
- } else if (iv.length != 16) {
- throw new Error('invalid initialation vector size (must be 16 bytes)');
- }
- this._lastCipherblock = coerceArray(iv, true);
- this._aes = new AES(key);
- }
- ModeOfOperationCBC.prototype.encrypt = function(plaintext) {
- plaintext = coerceArray(plaintext);
- if ((plaintext.length % 16) !== 0) {
- throw new Error('invalid plaintext size (must be multiple of 16 bytes)');
- }
- var ciphertext = createArray(plaintext.length);
- var block = createArray(16);
- for (var i = 0; i < plaintext.length; i += 16) {
- copyArray(plaintext, block, 0, i, i + 16);
- for (var j = 0; j < 16; j++) {
- block[j] ^= this._lastCipherblock[j];
- }
- this._lastCipherblock = this._aes.encrypt(block);
- copyArray(this._lastCipherblock, ciphertext, i);
- }
- return ciphertext;
- }
- ModeOfOperationCBC.prototype.decrypt = function(ciphertext) {
- ciphertext = coerceArray(ciphertext);
- if ((ciphertext.length % 16) !== 0) {
- throw new Error('invalid ciphertext size (must be multiple of 16 bytes)');
- }
- var plaintext = createArray(ciphertext.length);
- var block = createArray(16);
- for (var i = 0; i < ciphertext.length; i += 16) {
- copyArray(ciphertext, block, 0, i, i + 16);
- block = this._aes.decrypt(block);
- for (var j = 0; j < 16; j++) {
- plaintext[i + j] = block[j] ^ this._lastCipherblock[j];
- }
- copyArray(ciphertext, this._lastCipherblock, 0, i, i + 16);
- }
- return plaintext;
- }
- /**
- * Mode Of Operation - Cipher Feedback (CFB)
- */
- var ModeOfOperationCFB = function(key, iv, segmentSize) {
- if (!(this instanceof ModeOfOperationCFB)) {
- throw Error('AES must be instanitated with `new`');
- }
- this.description = "Cipher Feedback";
- this.name = "cfb";
- if (!iv) {
- iv = createArray(16);
- } else if (iv.length != 16) {
- throw new Error('invalid initialation vector size (must be 16 size)');
- }
- if (!segmentSize) { segmentSize = 1; }
- this.segmentSize = segmentSize;
- this._shiftRegister = coerceArray(iv, true);
- this._aes = new AES(key);
- }
- ModeOfOperationCFB.prototype.encrypt = function(plaintext) {
- if ((plaintext.length % this.segmentSize) != 0) {
- throw new Error('invalid plaintext size (must be segmentSize bytes)');
- }
- var encrypted = coerceArray(plaintext, true);
- var xorSegment;
- for (var i = 0; i < encrypted.length; i += this.segmentSize) {
- xorSegment = this._aes.encrypt(this._shiftRegister);
- for (var j = 0; j < this.segmentSize; j++) {
- encrypted[i + j] ^= xorSegment[j];
- }
- // Shift the register
- copyArray(this._shiftRegister, this._shiftRegister, 0, this.segmentSize);
- copyArray(encrypted, this._shiftRegister, 16 - this.segmentSize, i, i + this.segmentSize);
- }
- return encrypted;
- }
- ModeOfOperationCFB.prototype.decrypt = function(ciphertext) {
- if ((ciphertext.length % this.segmentSize) != 0) {
- throw new Error('invalid ciphertext size (must be segmentSize bytes)');
- }
- var plaintext = coerceArray(ciphertext, true);
- var xorSegment;
- for (var i = 0; i < plaintext.length; i += this.segmentSize) {
- xorSegment = this._aes.encrypt(this._shiftRegister);
- for (var j = 0; j < this.segmentSize; j++) {
- plaintext[i + j] ^= xorSegment[j];
- }
- // Shift the register
- copyArray(this._shiftRegister, this._shiftRegister, 0, this.segmentSize);
- copyArray(ciphertext, this._shiftRegister, 16 - this.segmentSize, i, i + this.segmentSize);
- }
- return plaintext;
- }
- /**
- * Mode Of Operation - Output Feedback (OFB)
- */
- var ModeOfOperationOFB = function(key, iv) {
- if (!(this instanceof ModeOfOperationOFB)) {
- throw Error('AES must be instanitated with `new`');
- }
- this.description = "Output Feedback";
- this.name = "ofb";
- if (!iv) {
- iv = createArray(16);
- } else if (iv.length != 16) {
- throw new Error('invalid initialation vector size (must be 16 bytes)');
- }
- this._lastPrecipher = coerceArray(iv, true);
- this._lastPrecipherIndex = 16;
- this._aes = new AES(key);
- }
- ModeOfOperationOFB.prototype.encrypt = function(plaintext) {
- var encrypted = coerceArray(plaintext, true);
- for (var i = 0; i < encrypted.length; i++) {
- if (this._lastPrecipherIndex === 16) {
- this._lastPrecipher = this._aes.encrypt(this._lastPrecipher);
- this._lastPrecipherIndex = 0;
- }
- encrypted[i] ^= this._lastPrecipher[this._lastPrecipherIndex++];
- }
- return encrypted;
- }
- // Decryption is symetric
- ModeOfOperationOFB.prototype.decrypt = ModeOfOperationOFB.prototype.encrypt;
- /**
- * Counter object for CTR common mode of operation
- */
- var Counter = function(initialValue) {
- if (!(this instanceof Counter)) {
- throw Error('Counter must be instanitated with `new`');
- }
- // We allow 0, but anything false-ish uses the default 1
- if (initialValue !== 0 && !initialValue) { initialValue = 1; }
- if (typeof(initialValue) === 'number') {
- this._counter = createArray(16);
- this.setValue(initialValue);
- } else {
- this.setBytes(initialValue);
- }
- }
- Counter.prototype.setValue = function(value) {
- if (typeof(value) !== 'number' || parseInt(value) != value) {
- throw new Error('invalid counter value (must be an integer)');
- }
- for (var index = 15; index >= 0; --index) {
- this._counter[index] = value % 256;
- value = value >> 8;
- }
- }
- Counter.prototype.setBytes = function(bytes) {
- bytes = coerceArray(bytes, true);
- if (bytes.length != 16) {
- throw new Error('invalid counter bytes size (must be 16 bytes)');
- }
- this._counter = bytes;
- };
- Counter.prototype.increment = function() {
- for (var i = 15; i >= 0; i--) {
- if (this._counter[i] === 255) {
- this._counter[i] = 0;
- } else {
- this._counter[i]++;
- break;
- }
- }
- }
- /**
- * Mode Of Operation - Counter (CTR)
- */
- var ModeOfOperationCTR = function(key, counter) {
- if (!(this instanceof ModeOfOperationCTR)) {
- throw Error('AES must be instanitated with `new`');
- }
- this.description = "Counter";
- this.name = "ctr";
- if (!(counter instanceof Counter)) {
- counter = new Counter(counter)
- }
- this._counter = counter;
- this._remainingCounter = null;
- this._remainingCounterIndex = 16;
- this._aes = new AES(key);
- }
- ModeOfOperationCTR.prototype.encrypt = function(plaintext) {
- var encrypted = coerceArray(plaintext, true);
- for (var i = 0; i < encrypted.length; i++) {
- if (this._remainingCounterIndex === 16) {
- this._remainingCounter = this._aes.encrypt(this._counter._counter);
- this._remainingCounterIndex = 0;
- this._counter.increment();
- }
- encrypted[i] ^= this._remainingCounter[this._remainingCounterIndex++];
- }
- return encrypted;
- }
- // Decryption is symetric
- ModeOfOperationCTR.prototype.decrypt = ModeOfOperationCTR.prototype.encrypt;
- ///////////////////////
- // Padding
- // See:https://tools.ietf.org/html/rfc2315
- function pkcs7pad(data) {
- data = coerceArray(data, true);
- var padder = 16 - (data.length % 16);
- var result = createArray(data.length + padder);
- copyArray(data, result);
- for (var i = data.length; i < result.length; i++) {
- result[i] = padder;
- }
- return result;
- }
- function pkcs7strip(data) {
- data = coerceArray(data, true);
- if (data.length < 16) { throw new Error('PKCS#7 invalid length'); }
- var padder = data[data.length - 1];
- if (padder > 16) { throw new Error('PKCS#7 padding byte out of range'); }
- var length = data.length - padder;
- for (var i = 0; i < padder; i++) {
- if (data[length + i] !== padder) {
- throw new Error('PKCS#7 invalid padding byte');
- }
- }
- var result = createArray(length);
- copyArray(data, result, 0, 0, length);
- return result;
- }
- ///////////////////////
- // Exporting
- // The block cipher
- var aesjs = {
- AES: AES,
- Counter: Counter,
- ModeOfOperation: {
- ecb: ModeOfOperationECB,
- cbc: ModeOfOperationCBC,
- cfb: ModeOfOperationCFB,
- ofb: ModeOfOperationOFB,
- ctr: ModeOfOperationCTR
- },
- utils: {
- hex: convertHex,
- utf8: convertUtf8
- },
- padding: {
- pkcs7: {
- pad: pkcs7pad,
- strip: pkcs7strip
- }
- },
- _arrayTest: {
- coerceArray: coerceArray,
- createArray: createArray,
- copyArray: copyArray,
- }
- };
- // node.js
- if (typeof exports !== 'undefined') {
- module.exports = aesjs
- // RequireJS/AMD
- // http://www.requirejs.org/docs/api.html
- // https://github.com/amdjs/amdjs-api/wiki/AMD
- } else if (typeof(define) === 'function' && define.amd) {
- define(aesjs);
- // Web Browsers
- } else {
- // If there was an existing library at "aesjs" make sure it's still available
- if (root.aesjs) {
- aesjs._aesjs = root.aesjs;
- }
- root.aesjs = aesjs;
- }
- })(this);
- },{}],291:[function(_dereq_,module,exports){
- module.exports = _dereq_('./lib/axios');
- },{"./lib/axios":293}],292:[function(_dereq_,module,exports){
- 'use strict';
- var utils = _dereq_('./../utils');
- var settle = _dereq_('./../core/settle');
- var cookies = _dereq_('./../helpers/cookies');
- var buildURL = _dereq_('./../helpers/buildURL');
- var buildFullPath = _dereq_('../core/buildFullPath');
- var parseHeaders = _dereq_('./../helpers/parseHeaders');
- var isURLSameOrigin = _dereq_('./../helpers/isURLSameOrigin');
- var createError = _dereq_('../core/createError');
- var transitionalDefaults = _dereq_('../defaults/transitional');
- var Cancel = _dereq_('../cancel/Cancel');
- module.exports = function xhrAdapter(config) {
- return new Promise(function dispatchXhrRequest(resolve, reject) {
- var requestData = config.data;
- var requestHeaders = config.headers;
- var responseType = config.responseType;
- var onCanceled;
- function done() {
- if (config.cancelToken) {
- config.cancelToken.unsubscribe(onCanceled);
- }
- if (config.signal) {
- config.signal.removeEventListener('abort', onCanceled);
- }
- }
- if (utils.isFormData(requestData)) {
- delete requestHeaders['Content-Type']; // Let the browser set it
- }
- var request = new XMLHttpRequest();
- // HTTP basic authentication
- if (config.auth) {
- var username = config.auth.username || '';
- var password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : '';
- requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);
- }
- var fullPath = buildFullPath(config.baseURL, config.url);
- request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);
- // Set the request timeout in MS
- request.timeout = config.timeout;
- function onloadend() {
- if (!request) {
- return;
- }
- // Prepare the response
- var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null;
- var responseData = !responseType || responseType === 'text' || responseType === 'json' ?
- request.responseText : request.response;
- var response = {
- data: responseData,
- status: request.status,
- statusText: request.statusText,
- headers: responseHeaders,
- config: config,
- request: request
- };
- settle(function _resolve(value) {
- resolve(value);
- done();
- }, function _reject(err) {
- reject(err);
- done();
- }, response);
- // Clean up request
- request = null;
- }
- if ('onloadend' in request) {
- // Use onloadend if available
- request.onloadend = onloadend;
- } else {
- // Listen for ready state to emulate onloadend
- request.onreadystatechange = function handleLoad() {
- if (!request || request.readyState !== 4) {
- return;
- }
- // The request errored out and we didn't get a response, this will be
- // handled by onerror instead
- // With one exception: request that using file: protocol, most browsers
- // will return status as 0 even though it's a successful request
- if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
- return;
- }
- // readystate handler is calling before onerror or ontimeout handlers,
- // so we should call onloadend on the next 'tick'
- setTimeout(onloadend);
- };
- }
- // Handle browser request cancellation (as opposed to a manual cancellation)
- request.onabort = function handleAbort() {
- if (!request) {
- return;
- }
- reject(createError('Request aborted', config, 'ECONNABORTED', request));
- // Clean up request
- request = null;
- };
- // Handle low level network errors
- request.onerror = function handleError() {
- // Real errors are hidden from us by the browser
- // onerror should only fire if it's a network error
- reject(createError('Network Error', config, null, request));
- // Clean up request
- request = null;
- };
- // Handle timeout
- request.ontimeout = function handleTimeout() {
- var timeoutErrorMessage = config.timeout ? 'timeout of ' + config.timeout + 'ms exceeded' : 'timeout exceeded';
- var transitional = config.transitional || transitionalDefaults;
- if (config.timeoutErrorMessage) {
- timeoutErrorMessage = config.timeoutErrorMessage;
- }
- reject(createError(
- timeoutErrorMessage,
- config,
- transitional.clarifyTimeoutError ? 'ETIMEDOUT' : 'ECONNABORTED',
- request));
- // Clean up request
- request = null;
- };
- // Add xsrf header
- // This is only done if running in a standard browser environment.
- // Specifically not if we're in a web worker, or react-native.
- if (utils.isStandardBrowserEnv()) {
- // Add xsrf header
- var xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName ?
- cookies.read(config.xsrfCookieName) :
- undefined;
- if (xsrfValue) {
- requestHeaders[config.xsrfHeaderName] = xsrfValue;
- }
- }
- // Add headers to the request
- if ('setRequestHeader' in request) {
- utils.forEach(requestHeaders, function setRequestHeader(val, key) {
- if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') {
- // Remove Content-Type if data is undefined
- delete requestHeaders[key];
- } else {
- // Otherwise add header to the request
- request.setRequestHeader(key, val);
- }
- });
- }
- // Add withCredentials to request if needed
- if (!utils.isUndefined(config.withCredentials)) {
- request.withCredentials = !!config.withCredentials;
- }
- // Add responseType to request if needed
- if (responseType && responseType !== 'json') {
- request.responseType = config.responseType;
- }
- // Handle progress if needed
- if (typeof config.onDownloadProgress === 'function') {
- request.addEventListener('progress', config.onDownloadProgress);
- }
- // Not all browsers support upload events
- if (typeof config.onUploadProgress === 'function' && request.upload) {
- request.upload.addEventListener('progress', config.onUploadProgress);
- }
- if (config.cancelToken || config.signal) {
- // Handle cancellation
- // eslint-disable-next-line func-names
- onCanceled = function(cancel) {
- if (!request) {
- return;
- }
- reject(!cancel || (cancel && cancel.type) ? new Cancel('canceled') : cancel);
- request.abort();
- request = null;
- };
- config.cancelToken && config.cancelToken.subscribe(onCanceled);
- if (config.signal) {
- config.signal.aborted ? onCanceled() : config.signal.addEventListener('abort', onCanceled);
- }
- }
- if (!requestData) {
- requestData = null;
- }
- // Send the request
- request.send(requestData);
- });
- };
- },{"../cancel/Cancel":294,"../core/buildFullPath":299,"../core/createError":300,"../defaults/transitional":307,"./../core/settle":304,"./../helpers/buildURL":310,"./../helpers/cookies":312,"./../helpers/isURLSameOrigin":315,"./../helpers/parseHeaders":317,"./../utils":320}],293:[function(_dereq_,module,exports){
- 'use strict';
- var utils = _dereq_('./utils');
- var bind = _dereq_('./helpers/bind');
- var Axios = _dereq_('./core/Axios');
- var mergeConfig = _dereq_('./core/mergeConfig');
- var defaults = _dereq_('./defaults');
- /**
- * Create an instance of Axios
- *
- * @param {Object} defaultConfig The default config for the instance
- * @return {Axios} A new instance of Axios
- */
- function createInstance(defaultConfig) {
- var context = new Axios(defaultConfig);
- var instance = bind(Axios.prototype.request, context);
- // Copy axios.prototype to instance
- utils.extend(instance, Axios.prototype, context);
- // Copy context to instance
- utils.extend(instance, context);
- // Factory for creating new instances
- instance.create = function create(instanceConfig) {
- return createInstance(mergeConfig(defaultConfig, instanceConfig));
- };
- return instance;
- }
- // Create the default instance to be exported
- var axios = createInstance(defaults);
- // Expose Axios class to allow class inheritance
- axios.Axios = Axios;
- // Expose Cancel & CancelToken
- axios.Cancel = _dereq_('./cancel/Cancel');
- axios.CancelToken = _dereq_('./cancel/CancelToken');
- axios.isCancel = _dereq_('./cancel/isCancel');
- axios.VERSION = _dereq_('./env/data').version;
- // Expose all/spread
- axios.all = function all(promises) {
- return Promise.all(promises);
- };
- axios.spread = _dereq_('./helpers/spread');
- // Expose isAxiosError
- axios.isAxiosError = _dereq_('./helpers/isAxiosError');
- module.exports = axios;
- // Allow use of default import syntax in TypeScript
- module.exports.default = axios;
- },{"./cancel/Cancel":294,"./cancel/CancelToken":295,"./cancel/isCancel":296,"./core/Axios":297,"./core/mergeConfig":303,"./defaults":306,"./env/data":308,"./helpers/bind":309,"./helpers/isAxiosError":314,"./helpers/spread":318,"./utils":320}],294:[function(_dereq_,module,exports){
- 'use strict';
- /**
- * A `Cancel` is an object that is thrown when an operation is canceled.
- *
- * @class
- * @param {string=} message The message.
- */
- function Cancel(message) {
- this.message = message;
- }
- Cancel.prototype.toString = function toString() {
- return 'Cancel' + (this.message ? ': ' + this.message : '');
- };
- Cancel.prototype.__CANCEL__ = true;
- module.exports = Cancel;
- },{}],295:[function(_dereq_,module,exports){
- 'use strict';
- var Cancel = _dereq_('./Cancel');
- /**
- * A `CancelToken` is an object that can be used to request cancellation of an operation.
- *
- * @class
- * @param {Function} executor The executor function.
- */
- function CancelToken(executor) {
- if (typeof executor !== 'function') {
- throw new TypeError('executor must be a function.');
- }
- var resolvePromise;
- this.promise = new Promise(function promiseExecutor(resolve) {
- resolvePromise = resolve;
- });
- var token = this;
- // eslint-disable-next-line func-names
- this.promise.then(function(cancel) {
- if (!token._listeners) return;
- var i;
- var l = token._listeners.length;
- for (i = 0; i < l; i++) {
- token._listeners[i](cancel);
- }
- token._listeners = null;
- });
- // eslint-disable-next-line func-names
- this.promise.then = function(onfulfilled) {
- var _resolve;
- // eslint-disable-next-line func-names
- var promise = new Promise(function(resolve) {
- token.subscribe(resolve);
- _resolve = resolve;
- }).then(onfulfilled);
- promise.cancel = function reject() {
- token.unsubscribe(_resolve);
- };
- return promise;
- };
- executor(function cancel(message) {
- if (token.reason) {
- // Cancellation has already been requested
- return;
- }
- token.reason = new Cancel(message);
- resolvePromise(token.reason);
- });
- }
- /**
- * Throws a `Cancel` if cancellation has been requested.
- */
- CancelToken.prototype.throwIfRequested = function throwIfRequested() {
- if (this.reason) {
- throw this.reason;
- }
- };
- /**
- * Subscribe to the cancel signal
- */
- CancelToken.prototype.subscribe = function subscribe(listener) {
- if (this.reason) {
- listener(this.reason);
- return;
- }
- if (this._listeners) {
- this._listeners.push(listener);
- } else {
- this._listeners = [listener];
- }
- };
- /**
- * Unsubscribe from the cancel signal
- */
- CancelToken.prototype.unsubscribe = function unsubscribe(listener) {
- if (!this._listeners) {
- return;
- }
- var index = this._listeners.indexOf(listener);
- if (index !== -1) {
- this._listeners.splice(index, 1);
- }
- };
- /**
- * Returns an object that contains a new `CancelToken` and a function that, when called,
- * cancels the `CancelToken`.
- */
- CancelToken.source = function source() {
- var cancel;
- var token = new CancelToken(function executor(c) {
- cancel = c;
- });
- return {
- token: token,
- cancel: cancel
- };
- };
- module.exports = CancelToken;
- },{"./Cancel":294}],296:[function(_dereq_,module,exports){
- 'use strict';
- module.exports = function isCancel(value) {
- return !!(value && value.__CANCEL__);
- };
- },{}],297:[function(_dereq_,module,exports){
- 'use strict';
- var utils = _dereq_('./../utils');
- var buildURL = _dereq_('../helpers/buildURL');
- var InterceptorManager = _dereq_('./InterceptorManager');
- var dispatchRequest = _dereq_('./dispatchRequest');
- var mergeConfig = _dereq_('./mergeConfig');
- var validator = _dereq_('../helpers/validator');
- var validators = validator.validators;
- /**
- * Create a new instance of Axios
- *
- * @param {Object} instanceConfig The default config for the instance
- */
- function Axios(instanceConfig) {
- this.defaults = instanceConfig;
- this.interceptors = {
- request: new InterceptorManager(),
- response: new InterceptorManager()
- };
- }
- /**
- * Dispatch a request
- *
- * @param {Object} config The config specific for this request (merged with this.defaults)
- */
- Axios.prototype.request = function request(configOrUrl, config) {
- /*eslint no-param-reassign:0*/
- // Allow for axios('example/url'[, config]) a la fetch API
- if (typeof configOrUrl === 'string') {
- config = config || {};
- config.url = configOrUrl;
- } else {
- config = configOrUrl || {};
- }
- config = mergeConfig(this.defaults, config);
- // Set config.method
- if (config.method) {
- config.method = config.method.toLowerCase();
- } else if (this.defaults.method) {
- config.method = this.defaults.method.toLowerCase();
- } else {
- config.method = 'get';
- }
- var transitional = config.transitional;
- if (transitional !== undefined) {
- validator.assertOptions(transitional, {
- silentJSONParsing: validators.transitional(validators.boolean),
- forcedJSONParsing: validators.transitional(validators.boolean),
- clarifyTimeoutError: validators.transitional(validators.boolean)
- }, false);
- }
- // filter out skipped interceptors
- var requestInterceptorChain = [];
- var synchronousRequestInterceptors = true;
- this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
- if (typeof interceptor.runWhen === 'function' && interceptor.runWhen(config) === false) {
- return;
- }
- synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
- requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
- });
- var responseInterceptorChain = [];
- this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
- responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
- });
- var promise;
- if (!synchronousRequestInterceptors) {
- var chain = [dispatchRequest, undefined];
- Array.prototype.unshift.apply(chain, requestInterceptorChain);
- chain = chain.concat(responseInterceptorChain);
- promise = Promise.resolve(config);
- while (chain.length) {
- promise = promise.then(chain.shift(), chain.shift());
- }
- return promise;
- }
- var newConfig = config;
- while (requestInterceptorChain.length) {
- var onFulfilled = requestInterceptorChain.shift();
- var onRejected = requestInterceptorChain.shift();
- try {
- newConfig = onFulfilled(newConfig);
- } catch (error) {
- onRejected(error);
- break;
- }
- }
- try {
- promise = dispatchRequest(newConfig);
- } catch (error) {
- return Promise.reject(error);
- }
- while (responseInterceptorChain.length) {
- promise = promise.then(responseInterceptorChain.shift(), responseInterceptorChain.shift());
- }
- return promise;
- };
- Axios.prototype.getUri = function getUri(config) {
- config = mergeConfig(this.defaults, config);
- return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\?/, '');
- };
- // Provide aliases for supported request methods
- utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
- /*eslint func-names:0*/
- Axios.prototype[method] = function(url, config) {
- return this.request(mergeConfig(config || {}, {
- method: method,
- url: url,
- data: (config || {}).data
- }));
- };
- });
- utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
- /*eslint func-names:0*/
- Axios.prototype[method] = function(url, data, config) {
- return this.request(mergeConfig(config || {}, {
- method: method,
- url: url,
- data: data
- }));
- };
- });
- module.exports = Axios;
- },{"../helpers/buildURL":310,"../helpers/validator":319,"./../utils":320,"./InterceptorManager":298,"./dispatchRequest":301,"./mergeConfig":303}],298:[function(_dereq_,module,exports){
- 'use strict';
- var utils = _dereq_('./../utils');
- function InterceptorManager() {
- this.handlers = [];
- }
- /**
- * Add a new interceptor to the stack
- *
- * @param {Function} fulfilled The function to handle `then` for a `Promise`
- * @param {Function} rejected The function to handle `reject` for a `Promise`
- *
- * @return {Number} An ID used to remove interceptor later
- */
- InterceptorManager.prototype.use = function use(fulfilled, rejected, options) {
- this.handlers.push({
- fulfilled: fulfilled,
- rejected: rejected,
- synchronous: options ? options.synchronous : false,
- runWhen: options ? options.runWhen : null
- });
- return this.handlers.length - 1;
- };
- /**
- * Remove an interceptor from the stack
- *
- * @param {Number} id The ID that was returned by `use`
- */
- InterceptorManager.prototype.eject = function eject(id) {
- if (this.handlers[id]) {
- this.handlers[id] = null;
- }
- };
- /**
- * Iterate over all the registered interceptors
- *
- * This method is particularly useful for skipping over any
- * interceptors that may have become `null` calling `eject`.
- *
- * @param {Function} fn The function to call for each interceptor
- */
- InterceptorManager.prototype.forEach = function forEach(fn) {
- utils.forEach(this.handlers, function forEachHandler(h) {
- if (h !== null) {
- fn(h);
- }
- });
- };
- module.exports = InterceptorManager;
- },{"./../utils":320}],299:[function(_dereq_,module,exports){
- 'use strict';
- var isAbsoluteURL = _dereq_('../helpers/isAbsoluteURL');
- var combineURLs = _dereq_('../helpers/combineURLs');
- /**
- * Creates a new URL by combining the baseURL with the requestedURL,
- * only when the requestedURL is not already an absolute URL.
- * If the requestURL is absolute, this function returns the requestedURL untouched.
- *
- * @param {string} baseURL The base URL
- * @param {string} requestedURL Absolute or relative URL to combine
- * @returns {string} The combined full path
- */
- module.exports = function buildFullPath(baseURL, requestedURL) {
- if (baseURL && !isAbsoluteURL(requestedURL)) {
- return combineURLs(baseURL, requestedURL);
- }
- return requestedURL;
- };
- },{"../helpers/combineURLs":311,"../helpers/isAbsoluteURL":313}],300:[function(_dereq_,module,exports){
- 'use strict';
- var enhanceError = _dereq_('./enhanceError');
- /**
- * Create an Error with the specified message, config, error code, request and response.
- *
- * @param {string} message The error message.
- * @param {Object} config The config.
- * @param {string} [code] The error code (for example, 'ECONNABORTED').
- * @param {Object} [request] The request.
- * @param {Object} [response] The response.
- * @returns {Error} The created error.
- */
- module.exports = function createError(message, config, code, request, response) {
- var error = new Error(message);
- return enhanceError(error, config, code, request, response);
- };
- },{"./enhanceError":302}],301:[function(_dereq_,module,exports){
- 'use strict';
- var utils = _dereq_('./../utils');
- var transformData = _dereq_('./transformData');
- var isCancel = _dereq_('../cancel/isCancel');
- var defaults = _dereq_('../defaults');
- var Cancel = _dereq_('../cancel/Cancel');
- /**
- * Throws a `Cancel` if cancellation has been requested.
- */
- function throwIfCancellationRequested(config) {
- if (config.cancelToken) {
- config.cancelToken.throwIfRequested();
- }
- if (config.signal && config.signal.aborted) {
- throw new Cancel('canceled');
- }
- }
- /**
- * Dispatch a request to the server using the configured adapter.
- *
- * @param {object} config The config that is to be used for the request
- * @returns {Promise} The Promise to be fulfilled
- */
- module.exports = function dispatchRequest(config) {
- throwIfCancellationRequested(config);
- // Ensure headers exist
- config.headers = config.headers || {};
- // Transform request data
- config.data = transformData.call(
- config,
- config.data,
- config.headers,
- config.transformRequest
- );
- // Flatten headers
- config.headers = utils.merge(
- config.headers.common || {},
- config.headers[config.method] || {},
- config.headers
- );
- utils.forEach(
- ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
- function cleanHeaderConfig(method) {
- delete config.headers[method];
- }
- );
- var adapter = config.adapter || defaults.adapter;
- return adapter(config).then(function onAdapterResolution(response) {
- throwIfCancellationRequested(config);
- // Transform response data
- response.data = transformData.call(
- config,
- response.data,
- response.headers,
- config.transformResponse
- );
- return response;
- }, function onAdapterRejection(reason) {
- if (!isCancel(reason)) {
- throwIfCancellationRequested(config);
- // Transform response data
- if (reason && reason.response) {
- reason.response.data = transformData.call(
- config,
- reason.response.data,
- reason.response.headers,
- config.transformResponse
- );
- }
- }
- return Promise.reject(reason);
- });
- };
- },{"../cancel/Cancel":294,"../cancel/isCancel":296,"../defaults":306,"./../utils":320,"./transformData":305}],302:[function(_dereq_,module,exports){
- 'use strict';
- /**
- * Update an Error with the specified config, error code, and response.
- *
- * @param {Error} error The error to update.
- * @param {Object} config The config.
- * @param {string} [code] The error code (for example, 'ECONNABORTED').
- * @param {Object} [request] The request.
- * @param {Object} [response] The response.
- * @returns {Error} The error.
- */
- module.exports = function enhanceError(error, config, code, request, response) {
- error.config = config;
- if (code) {
- error.code = code;
- }
- error.request = request;
- error.response = response;
- error.isAxiosError = true;
- error.toJSON = function toJSON() {
- return {
- // Standard
- message: this.message,
- name: this.name,
- // Microsoft
- description: this.description,
- number: this.number,
- // Mozilla
- fileName: this.fileName,
- lineNumber: this.lineNumber,
- columnNumber: this.columnNumber,
- stack: this.stack,
- // Axios
- config: this.config,
- code: this.code,
- status: this.response && this.response.status ? this.response.status : null
- };
- };
- return error;
- };
- },{}],303:[function(_dereq_,module,exports){
- 'use strict';
- var utils = _dereq_('../utils');
- /**
- * Config-specific merge-function which creates a new config-object
- * by merging two configuration objects together.
- *
- * @param {Object} config1
- * @param {Object} config2
- * @returns {Object} New object resulting from merging config2 to config1
- */
- module.exports = function mergeConfig(config1, config2) {
- // eslint-disable-next-line no-param-reassign
- config2 = config2 || {};
- var config = {};
- function getMergedValue(target, source) {
- if (utils.isPlainObject(target) && utils.isPlainObject(source)) {
- return utils.merge(target, source);
- } else if (utils.isPlainObject(source)) {
- return utils.merge({}, source);
- } else if (utils.isArray(source)) {
- return source.slice();
- }
- return source;
- }
- // eslint-disable-next-line consistent-return
- function mergeDeepProperties(prop) {
- if (!utils.isUndefined(config2[prop])) {
- return getMergedValue(config1[prop], config2[prop]);
- } else if (!utils.isUndefined(config1[prop])) {
- return getMergedValue(undefined, config1[prop]);
- }
- }
- // eslint-disable-next-line consistent-return
- function valueFromConfig2(prop) {
- if (!utils.isUndefined(config2[prop])) {
- return getMergedValue(undefined, config2[prop]);
- }
- }
- // eslint-disable-next-line consistent-return
- function defaultToConfig2(prop) {
- if (!utils.isUndefined(config2[prop])) {
- return getMergedValue(undefined, config2[prop]);
- } else if (!utils.isUndefined(config1[prop])) {
- return getMergedValue(undefined, config1[prop]);
- }
- }
- // eslint-disable-next-line consistent-return
- function mergeDirectKeys(prop) {
- if (prop in config2) {
- return getMergedValue(config1[prop], config2[prop]);
- } else if (prop in config1) {
- return getMergedValue(undefined, config1[prop]);
- }
- }
- var mergeMap = {
- 'url': valueFromConfig2,
- 'method': valueFromConfig2,
- 'data': valueFromConfig2,
- 'baseURL': defaultToConfig2,
- 'transformRequest': defaultToConfig2,
- 'transformResponse': defaultToConfig2,
- 'paramsSerializer': defaultToConfig2,
- 'timeout': defaultToConfig2,
- 'timeoutMessage': defaultToConfig2,
- 'withCredentials': defaultToConfig2,
- 'adapter': defaultToConfig2,
- 'responseType': defaultToConfig2,
- 'xsrfCookieName': defaultToConfig2,
- 'xsrfHeaderName': defaultToConfig2,
- 'onUploadProgress': defaultToConfig2,
- 'onDownloadProgress': defaultToConfig2,
- 'decompress': defaultToConfig2,
- 'maxContentLength': defaultToConfig2,
- 'maxBodyLength': defaultToConfig2,
- 'transport': defaultToConfig2,
- 'httpAgent': defaultToConfig2,
- 'httpsAgent': defaultToConfig2,
- 'cancelToken': defaultToConfig2,
- 'socketPath': defaultToConfig2,
- 'responseEncoding': defaultToConfig2,
- 'validateStatus': mergeDirectKeys
- };
- utils.forEach(Object.keys(config1).concat(Object.keys(config2)), function computeConfigValue(prop) {
- var merge = mergeMap[prop] || mergeDeepProperties;
- var configValue = merge(prop);
- (utils.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
- });
- return config;
- };
- },{"../utils":320}],304:[function(_dereq_,module,exports){
- 'use strict';
- var createError = _dereq_('./createError');
- /**
- * Resolve or reject a Promise based on response status.
- *
- * @param {Function} resolve A function that resolves the promise.
- * @param {Function} reject A function that rejects the promise.
- * @param {object} response The response.
- */
- module.exports = function settle(resolve, reject, response) {
- var validateStatus = response.config.validateStatus;
- if (!response.status || !validateStatus || validateStatus(response.status)) {
- resolve(response);
- } else {
- reject(createError(
- 'Request failed with status code ' + response.status,
- response.config,
- null,
- response.request,
- response
- ));
- }
- };
- },{"./createError":300}],305:[function(_dereq_,module,exports){
- 'use strict';
- var utils = _dereq_('./../utils');
- var defaults = _dereq_('../defaults');
- /**
- * Transform the data for a request or a response
- *
- * @param {Object|String} data The data to be transformed
- * @param {Array} headers The headers for the request or response
- * @param {Array|Function} fns A single function or Array of functions
- * @returns {*} The resulting transformed data
- */
- module.exports = function transformData(data, headers, fns) {
- var context = this || defaults;
- /*eslint no-param-reassign:0*/
- utils.forEach(fns, function transform(fn) {
- data = fn.call(context, data, headers);
- });
- return data;
- };
- },{"../defaults":306,"./../utils":320}],306:[function(_dereq_,module,exports){
- (function (process){(function (){
- 'use strict';
- var utils = _dereq_('../utils');
- var normalizeHeaderName = _dereq_('../helpers/normalizeHeaderName');
- var enhanceError = _dereq_('../core/enhanceError');
- var transitionalDefaults = _dereq_('./transitional');
- var DEFAULT_CONTENT_TYPE = {
- 'Content-Type': 'application/x-www-form-urlencoded'
- };
- function setContentTypeIfUnset(headers, value) {
- if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) {
- headers['Content-Type'] = value;
- }
- }
- function getDefaultAdapter() {
- var adapter;
- if (typeof XMLHttpRequest !== 'undefined') {
- // For browsers use XHR adapter
- adapter = _dereq_('../adapters/xhr');
- } else if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') {
- // For node use HTTP adapter
- adapter = _dereq_('../adapters/http');
- }
- return adapter;
- }
- function stringifySafely(rawValue, parser, encoder) {
- if (utils.isString(rawValue)) {
- try {
- (parser || JSON.parse)(rawValue);
- return utils.trim(rawValue);
- } catch (e) {
- if (e.name !== 'SyntaxError') {
- throw e;
- }
- }
- }
- return (encoder || JSON.stringify)(rawValue);
- }
- var defaults = {
- transitional: transitionalDefaults,
- adapter: getDefaultAdapter(),
- transformRequest: [function transformRequest(data, headers) {
- normalizeHeaderName(headers, 'Accept');
- normalizeHeaderName(headers, 'Content-Type');
- if (utils.isFormData(data) ||
- utils.isArrayBuffer(data) ||
- utils.isBuffer(data) ||
- utils.isStream(data) ||
- utils.isFile(data) ||
- utils.isBlob(data)
- ) {
- return data;
- }
- if (utils.isArrayBufferView(data)) {
- return data.buffer;
- }
- if (utils.isURLSearchParams(data)) {
- setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');
- return data.toString();
- }
- if (utils.isObject(data) || (headers && headers['Content-Type'] === 'application/json')) {
- setContentTypeIfUnset(headers, 'application/json');
- return stringifySafely(data);
- }
- return data;
- }],
- transformResponse: [function transformResponse(data) {
- var transitional = this.transitional || defaults.transitional;
- var silentJSONParsing = transitional && transitional.silentJSONParsing;
- var forcedJSONParsing = transitional && transitional.forcedJSONParsing;
- var strictJSONParsing = !silentJSONParsing && this.responseType === 'json';
- if (strictJSONParsing || (forcedJSONParsing && utils.isString(data) && data.length)) {
- try {
- return JSON.parse(data);
- } catch (e) {
- if (strictJSONParsing) {
- if (e.name === 'SyntaxError') {
- throw enhanceError(e, this, 'E_JSON_PARSE');
- }
- throw e;
- }
- }
- }
- return data;
- }],
- /**
- * A timeout in milliseconds to abort a request. If set to 0 (default) a
- * timeout is not created.
- */
- timeout: 0,
- xsrfCookieName: 'XSRF-TOKEN',
- xsrfHeaderName: 'X-XSRF-TOKEN',
- maxContentLength: -1,
- maxBodyLength: -1,
- validateStatus: function validateStatus(status) {
- return status >= 200 && status < 300;
- },
- headers: {
- common: {
- 'Accept': 'application/json, text/plain, */*'
- }
- }
- };
- utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
- defaults.headers[method] = {};
- });
- utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
- defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
- });
- module.exports = defaults;
- }).call(this)}).call(this,_dereq_('_process'))
- },{"../adapters/http":292,"../adapters/xhr":292,"../core/enhanceError":302,"../helpers/normalizeHeaderName":316,"../utils":320,"./transitional":307,"_process":323}],307:[function(_dereq_,module,exports){
- 'use strict';
- module.exports = {
- silentJSONParsing: true,
- forcedJSONParsing: true,
- clarifyTimeoutError: false
- };
- },{}],308:[function(_dereq_,module,exports){
- module.exports = {
- "version": "0.26.1"
- };
- },{}],309:[function(_dereq_,module,exports){
- 'use strict';
- module.exports = function bind(fn, thisArg) {
- return function wrap() {
- var args = new Array(arguments.length);
- for (var i = 0; i < args.length; i++) {
- args[i] = arguments[i];
- }
- return fn.apply(thisArg, args);
- };
- };
- },{}],310:[function(_dereq_,module,exports){
- 'use strict';
- var utils = _dereq_('./../utils');
- function encode(val) {
- return encodeURIComponent(val).
- replace(/%3A/gi, ':').
- replace(/%24/g, '$').
- replace(/%2C/gi, ',').
- replace(/%20/g, '+').
- replace(/%5B/gi, '[').
- replace(/%5D/gi, ']');
- }
- /**
- * Build a URL by appending params to the end
- *
- * @param {string} url The base of the url (e.g., http://www.google.com)
- * @param {object} [params] The params to be appended
- * @returns {string} The formatted url
- */
- module.exports = function buildURL(url, params, paramsSerializer) {
- /*eslint no-param-reassign:0*/
- if (!params) {
- return url;
- }
- var serializedParams;
- if (paramsSerializer) {
- serializedParams = paramsSerializer(params);
- } else if (utils.isURLSearchParams(params)) {
- serializedParams = params.toString();
- } else {
- var parts = [];
- utils.forEach(params, function serialize(val, key) {
- if (val === null || typeof val === 'undefined') {
- return;
- }
- if (utils.isArray(val)) {
- key = key + '[]';
- } else {
- val = [val];
- }
- utils.forEach(val, function parseValue(v) {
- if (utils.isDate(v)) {
- v = v.toISOString();
- } else if (utils.isObject(v)) {
- v = JSON.stringify(v);
- }
- parts.push(encode(key) + '=' + encode(v));
- });
- });
- serializedParams = parts.join('&');
- }
- if (serializedParams) {
- var hashmarkIndex = url.indexOf('#');
- if (hashmarkIndex !== -1) {
- url = url.slice(0, hashmarkIndex);
- }
- url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
- }
- return url;
- };
- },{"./../utils":320}],311:[function(_dereq_,module,exports){
- 'use strict';
- /**
- * Creates a new URL by combining the specified URLs
- *
- * @param {string} baseURL The base URL
- * @param {string} relativeURL The relative URL
- * @returns {string} The combined URL
- */
- module.exports = function combineURLs(baseURL, relativeURL) {
- return relativeURL
- ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
- : baseURL;
- };
- },{}],312:[function(_dereq_,module,exports){
- 'use strict';
- var utils = _dereq_('./../utils');
- module.exports = (
- utils.isStandardBrowserEnv() ?
- // Standard browser envs support document.cookie
- (function standardBrowserEnv() {
- return {
- write: function write(name, value, expires, path, domain, secure) {
- var cookie = [];
- cookie.push(name + '=' + encodeURIComponent(value));
- if (utils.isNumber(expires)) {
- cookie.push('expires=' + new Date(expires).toGMTString());
- }
- if (utils.isString(path)) {
- cookie.push('path=' + path);
- }
- if (utils.isString(domain)) {
- cookie.push('domain=' + domain);
- }
- if (secure === true) {
- cookie.push('secure');
- }
- document.cookie = cookie.join('; ');
- },
- read: function read(name) {
- var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
- return (match ? decodeURIComponent(match[3]) : null);
- },
- remove: function remove(name) {
- this.write(name, '', Date.now() - 86400000);
- }
- };
- })() :
- // Non standard browser env (web workers, react-native) lack needed support.
- (function nonStandardBrowserEnv() {
- return {
- write: function write() {},
- read: function read() { return null; },
- remove: function remove() {}
- };
- })()
- );
- },{"./../utils":320}],313:[function(_dereq_,module,exports){
- 'use strict';
- /**
- * Determines whether the specified URL is absolute
- *
- * @param {string} url The URL to test
- * @returns {boolean} True if the specified URL is absolute, otherwise false
- */
- module.exports = function isAbsoluteURL(url) {
- // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
- // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
- // by any combination of letters, digits, plus, period, or hyphen.
- return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
- };
- },{}],314:[function(_dereq_,module,exports){
- 'use strict';
- var utils = _dereq_('./../utils');
- /**
- * Determines whether the payload is an error thrown by Axios
- *
- * @param {*} payload The value to test
- * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
- */
- module.exports = function isAxiosError(payload) {
- return utils.isObject(payload) && (payload.isAxiosError === true);
- };
- },{"./../utils":320}],315:[function(_dereq_,module,exports){
- 'use strict';
- var utils = _dereq_('./../utils');
- module.exports = (
- utils.isStandardBrowserEnv() ?
- // Standard browser envs have full support of the APIs needed to test
- // whether the request URL is of the same origin as current location.
- (function standardBrowserEnv() {
- var msie = /(msie|trident)/i.test(navigator.userAgent);
- var urlParsingNode = document.createElement('a');
- var originURL;
- /**
- * Parse a URL to discover it's components
- *
- * @param {String} url The URL to be parsed
- * @returns {Object}
- */
- function resolveURL(url) {
- var href = url;
- if (msie) {
- // IE needs attribute set twice to normalize properties
- urlParsingNode.setAttribute('href', href);
- href = urlParsingNode.href;
- }
- urlParsingNode.setAttribute('href', href);
- // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
- return {
- href: urlParsingNode.href,
- protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
- host: urlParsingNode.host,
- search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
- hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
- hostname: urlParsingNode.hostname,
- port: urlParsingNode.port,
- pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
- urlParsingNode.pathname :
- '/' + urlParsingNode.pathname
- };
- }
- originURL = resolveURL(window.location.href);
- /**
- * Determine if a URL shares the same origin as the current location
- *
- * @param {String} requestURL The URL to test
- * @returns {boolean} True if URL shares the same origin, otherwise false
- */
- return function isURLSameOrigin(requestURL) {
- var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
- return (parsed.protocol === originURL.protocol &&
- parsed.host === originURL.host);
- };
- })() :
- // Non standard browser envs (web workers, react-native) lack needed support.
- (function nonStandardBrowserEnv() {
- return function isURLSameOrigin() {
- return true;
- };
- })()
- );
- },{"./../utils":320}],316:[function(_dereq_,module,exports){
- 'use strict';
- var utils = _dereq_('../utils');
- module.exports = function normalizeHeaderName(headers, normalizedName) {
- utils.forEach(headers, function processHeader(value, name) {
- if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) {
- headers[normalizedName] = value;
- delete headers[name];
- }
- });
- };
- },{"../utils":320}],317:[function(_dereq_,module,exports){
- 'use strict';
- var utils = _dereq_('./../utils');
- // Headers whose duplicates are ignored by node
- // c.f. https://nodejs.org/api/http.html#http_message_headers
- var ignoreDuplicateOf = [
- 'age', 'authorization', 'content-length', 'content-type', 'etag',
- 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
- 'last-modified', 'location', 'max-forwards', 'proxy-authorization',
- 'referer', 'retry-after', 'user-agent'
- ];
- /**
- * Parse headers into an object
- *
- * ```
- * Date: Wed, 27 Aug 2014 08:58:49 GMT
- * Content-Type: application/json
- * Connection: keep-alive
- * Transfer-Encoding: chunked
- * ```
- *
- * @param {String} headers Headers needing to be parsed
- * @returns {Object} Headers parsed into an object
- */
- module.exports = function parseHeaders(headers) {
- var parsed = {};
- var key;
- var val;
- var i;
- if (!headers) { return parsed; }
- utils.forEach(headers.split('\n'), function parser(line) {
- i = line.indexOf(':');
- key = utils.trim(line.substr(0, i)).toLowerCase();
- val = utils.trim(line.substr(i + 1));
- if (key) {
- if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) {
- return;
- }
- if (key === 'set-cookie') {
- parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]);
- } else {
- parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
- }
- }
- });
- return parsed;
- };
- },{"./../utils":320}],318:[function(_dereq_,module,exports){
- 'use strict';
- /**
- * Syntactic sugar for invoking a function and expanding an array for arguments.
- *
- * Common use case would be to use `Function.prototype.apply`.
- *
- * ```js
- * function f(x, y, z) {}
- * var args = [1, 2, 3];
- * f.apply(null, args);
- * ```
- *
- * With `spread` this example can be re-written.
- *
- * ```js
- * spread(function(x, y, z) {})([1, 2, 3]);
- * ```
- *
- * @param {Function} callback
- * @returns {Function}
- */
- module.exports = function spread(callback) {
- return function wrap(arr) {
- return callback.apply(null, arr);
- };
- };
- },{}],319:[function(_dereq_,module,exports){
- 'use strict';
- var VERSION = _dereq_('../env/data').version;
- var validators = {};
- // eslint-disable-next-line func-names
- ['object', 'boolean', 'number', 'function', 'string', 'symbol'].forEach(function(type, i) {
- validators[type] = function validator(thing) {
- return typeof thing === type || 'a' + (i < 1 ? 'n ' : ' ') + type;
- };
- });
- var deprecatedWarnings = {};
- /**
- * Transitional option validator
- * @param {function|boolean?} validator - set to false if the transitional option has been removed
- * @param {string?} version - deprecated version / removed since version
- * @param {string?} message - some message with additional info
- * @returns {function}
- */
- validators.transitional = function transitional(validator, version, message) {
- function formatMessage(opt, desc) {
- return '[Axios v' + VERSION + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : '');
- }
- // eslint-disable-next-line func-names
- return function(value, opt, opts) {
- if (validator === false) {
- throw new Error(formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')));
- }
- if (version && !deprecatedWarnings[opt]) {
- deprecatedWarnings[opt] = true;
- // eslint-disable-next-line no-console
- console.warn(
- formatMessage(
- opt,
- ' has been deprecated since v' + version + ' and will be removed in the near future'
- )
- );
- }
- return validator ? validator(value, opt, opts) : true;
- };
- };
- /**
- * Assert object's properties type
- * @param {object} options
- * @param {object} schema
- * @param {boolean?} allowUnknown
- */
- function assertOptions(options, schema, allowUnknown) {
- if (typeof options !== 'object') {
- throw new TypeError('options must be an object');
- }
- var keys = Object.keys(options);
- var i = keys.length;
- while (i-- > 0) {
- var opt = keys[i];
- var validator = schema[opt];
- if (validator) {
- var value = options[opt];
- var result = value === undefined || validator(value, opt, options);
- if (result !== true) {
- throw new TypeError('option ' + opt + ' must be ' + result);
- }
- continue;
- }
- if (allowUnknown !== true) {
- throw Error('Unknown option ' + opt);
- }
- }
- }
- module.exports = {
- assertOptions: assertOptions,
- validators: validators
- };
- },{"../env/data":308}],320:[function(_dereq_,module,exports){
- 'use strict';
- var bind = _dereq_('./helpers/bind');
- // utils is a library of generic helper functions non-specific to axios
- var toString = Object.prototype.toString;
- /**
- * Determine if a value is an Array
- *
- * @param {Object} val The value to test
- * @returns {boolean} True if value is an Array, otherwise false
- */
- function isArray(val) {
- return Array.isArray(val);
- }
- /**
- * Determine if a value is undefined
- *
- * @param {Object} val The value to test
- * @returns {boolean} True if the value is undefined, otherwise false
- */
- function isUndefined(val) {
- return typeof val === 'undefined';
- }
- /**
- * Determine if a value is a Buffer
- *
- * @param {Object} val The value to test
- * @returns {boolean} True if value is a Buffer, otherwise false
- */
- function isBuffer(val) {
- return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)
- && typeof val.constructor.isBuffer === 'function' && val.constructor.isBuffer(val);
- }
- /**
- * Determine if a value is an ArrayBuffer
- *
- * @param {Object} val The value to test
- * @returns {boolean} True if value is an ArrayBuffer, otherwise false
- */
- function isArrayBuffer(val) {
- return toString.call(val) === '[object ArrayBuffer]';
- }
- /**
- * Determine if a value is a FormData
- *
- * @param {Object} val The value to test
- * @returns {boolean} True if value is an FormData, otherwise false
- */
- function isFormData(val) {
- return toString.call(val) === '[object FormData]';
- }
- /**
- * Determine if a value is a view on an ArrayBuffer
- *
- * @param {Object} val The value to test
- * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
- */
- function isArrayBufferView(val) {
- var result;
- if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
- result = ArrayBuffer.isView(val);
- } else {
- result = (val) && (val.buffer) && (isArrayBuffer(val.buffer));
- }
- return result;
- }
- /**
- * Determine if a value is a String
- *
- * @param {Object} val The value to test
- * @returns {boolean} True if value is a String, otherwise false
- */
- function isString(val) {
- return typeof val === 'string';
- }
- /**
- * Determine if a value is a Number
- *
- * @param {Object} val The value to test
- * @returns {boolean} True if value is a Number, otherwise false
- */
- function isNumber(val) {
- return typeof val === 'number';
- }
- /**
- * Determine if a value is an Object
- *
- * @param {Object} val The value to test
- * @returns {boolean} True if value is an Object, otherwise false
- */
- function isObject(val) {
- return val !== null && typeof val === 'object';
- }
- /**
- * Determine if a value is a plain Object
- *
- * @param {Object} val The value to test
- * @return {boolean} True if value is a plain Object, otherwise false
- */
- function isPlainObject(val) {
- if (toString.call(val) !== '[object Object]') {
- return false;
- }
- var prototype = Object.getPrototypeOf(val);
- return prototype === null || prototype === Object.prototype;
- }
- /**
- * Determine if a value is a Date
- *
- * @param {Object} val The value to test
- * @returns {boolean} True if value is a Date, otherwise false
- */
- function isDate(val) {
- return toString.call(val) === '[object Date]';
- }
- /**
- * Determine if a value is a File
- *
- * @param {Object} val The value to test
- * @returns {boolean} True if value is a File, otherwise false
- */
- function isFile(val) {
- return toString.call(val) === '[object File]';
- }
- /**
- * Determine if a value is a Blob
- *
- * @param {Object} val The value to test
- * @returns {boolean} True if value is a Blob, otherwise false
- */
- function isBlob(val) {
- return toString.call(val) === '[object Blob]';
- }
- /**
- * Determine if a value is a Function
- *
- * @param {Object} val The value to test
- * @returns {boolean} True if value is a Function, otherwise false
- */
- function isFunction(val) {
- return toString.call(val) === '[object Function]';
- }
- /**
- * Determine if a value is a Stream
- *
- * @param {Object} val The value to test
- * @returns {boolean} True if value is a Stream, otherwise false
- */
- function isStream(val) {
- return isObject(val) && isFunction(val.pipe);
- }
- /**
- * Determine if a value is a URLSearchParams object
- *
- * @param {Object} val The value to test
- * @returns {boolean} True if value is a URLSearchParams object, otherwise false
- */
- function isURLSearchParams(val) {
- return toString.call(val) === '[object URLSearchParams]';
- }
- /**
- * Trim excess whitespace off the beginning and end of a string
- *
- * @param {String} str The String to trim
- * @returns {String} The String freed of excess whitespace
- */
- function trim(str) {
- return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g, '');
- }
- /**
- * Determine if we're running in a standard browser environment
- *
- * This allows axios to run in a web worker, and react-native.
- * Both environments support XMLHttpRequest, but not fully standard globals.
- *
- * web workers:
- * typeof window -> undefined
- * typeof document -> undefined
- *
- * react-native:
- * navigator.product -> 'ReactNative'
- * nativescript
- * navigator.product -> 'NativeScript' or 'NS'
- */
- function isStandardBrowserEnv() {
- if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' ||
- navigator.product === 'NativeScript' ||
- navigator.product === 'NS')) {
- return false;
- }
- return (
- typeof window !== 'undefined' &&
- typeof document !== 'undefined'
- );
- }
- /**
- * Iterate over an Array or an Object invoking a function for each item.
- *
- * If `obj` is an Array callback will be called passing
- * the value, index, and complete array for each item.
- *
- * If 'obj' is an Object callback will be called passing
- * the value, key, and complete object for each property.
- *
- * @param {Object|Array} obj The object to iterate
- * @param {Function} fn The callback to invoke for each item
- */
- function forEach(obj, fn) {
- // Don't bother if no value provided
- if (obj === null || typeof obj === 'undefined') {
- return;
- }
- // Force an array if not already something iterable
- if (typeof obj !== 'object') {
- /*eslint no-param-reassign:0*/
- obj = [obj];
- }
- if (isArray(obj)) {
- // Iterate over array values
- for (var i = 0, l = obj.length; i < l; i++) {
- fn.call(null, obj[i], i, obj);
- }
- } else {
- // Iterate over object keys
- for (var key in obj) {
- if (Object.prototype.hasOwnProperty.call(obj, key)) {
- fn.call(null, obj[key], key, obj);
- }
- }
- }
- }
- /**
- * Accepts varargs expecting each argument to be an object, then
- * immutably merges the properties of each object and returns result.
- *
- * When multiple objects contain the same key the later object in
- * the arguments list will take precedence.
- *
- * Example:
- *
- * ```js
- * var result = merge({foo: 123}, {foo: 456});
- * console.log(result.foo); // outputs 456
- * ```
- *
- * @param {Object} obj1 Object to merge
- * @returns {Object} Result of all merge properties
- */
- function merge(/* obj1, obj2, obj3, ... */) {
- var result = {};
- function assignValue(val, key) {
- if (isPlainObject(result[key]) && isPlainObject(val)) {
- result[key] = merge(result[key], val);
- } else if (isPlainObject(val)) {
- result[key] = merge({}, val);
- } else if (isArray(val)) {
- result[key] = val.slice();
- } else {
- result[key] = val;
- }
- }
- for (var i = 0, l = arguments.length; i < l; i++) {
- forEach(arguments[i], assignValue);
- }
- return result;
- }
- /**
- * Extends object a by mutably adding to it the properties of object b.
- *
- * @param {Object} a The object to be extended
- * @param {Object} b The object to copy properties from
- * @param {Object} thisArg The object to bind function to
- * @return {Object} The resulting value of object a
- */
- function extend(a, b, thisArg) {
- forEach(b, function assignValue(val, key) {
- if (thisArg && typeof val === 'function') {
- a[key] = bind(val, thisArg);
- } else {
- a[key] = val;
- }
- });
- return a;
- }
- /**
- * Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)
- *
- * @param {string} content with BOM
- * @return {string} content value without BOM
- */
- function stripBOM(content) {
- if (content.charCodeAt(0) === 0xFEFF) {
- content = content.slice(1);
- }
- return content;
- }
- module.exports = {
- isArray: isArray,
- isArrayBuffer: isArrayBuffer,
- isBuffer: isBuffer,
- isFormData: isFormData,
- isArrayBufferView: isArrayBufferView,
- isString: isString,
- isNumber: isNumber,
- isObject: isObject,
- isPlainObject: isPlainObject,
- isUndefined: isUndefined,
- isDate: isDate,
- isFile: isFile,
- isBlob: isBlob,
- isFunction: isFunction,
- isStream: isStream,
- isURLSearchParams: isURLSearchParams,
- isStandardBrowserEnv: isStandardBrowserEnv,
- forEach: forEach,
- merge: merge,
- extend: extend,
- trim: trim,
- stripBOM: stripBOM
- };
- },{"./helpers/bind":309}],321:[function(_dereq_,module,exports){
- 'use strict'
- var ALPHABET = 'qpzry9x8gf2tvdw0s3jn54khce6mua7l'
- // pre-compute lookup table
- var ALPHABET_MAP = {}
- for (var z = 0; z < ALPHABET.length; z++) {
- var x = ALPHABET.charAt(z)
- if (ALPHABET_MAP[x] !== undefined) throw new TypeError(x + ' is ambiguous')
- ALPHABET_MAP[x] = z
- }
- function polymodStep (pre) {
- var b = pre >> 25
- return ((pre & 0x1FFFFFF) << 5) ^
- (-((b >> 0) & 1) & 0x3b6a57b2) ^
- (-((b >> 1) & 1) & 0x26508e6d) ^
- (-((b >> 2) & 1) & 0x1ea119fa) ^
- (-((b >> 3) & 1) & 0x3d4233dd) ^
- (-((b >> 4) & 1) & 0x2a1462b3)
- }
- function prefixChk (prefix) {
- var chk = 1
- for (var i = 0; i < prefix.length; ++i) {
- var c = prefix.charCodeAt(i)
- if (c < 33 || c > 126) return 'Invalid prefix (' + prefix + ')'
- chk = polymodStep(chk) ^ (c >> 5)
- }
- chk = polymodStep(chk)
- for (i = 0; i < prefix.length; ++i) {
- var v = prefix.charCodeAt(i)
- chk = polymodStep(chk) ^ (v & 0x1f)
- }
- return chk
- }
- function encode (prefix, words, LIMIT) {
- LIMIT = LIMIT || 90
- if ((prefix.length + 7 + words.length) > LIMIT) throw new TypeError('Exceeds length limit')
- prefix = prefix.toLowerCase()
- // determine chk mod
- var chk = prefixChk(prefix)
- if (typeof chk === 'string') throw new Error(chk)
- var result = prefix + '1'
- for (var i = 0; i < words.length; ++i) {
- var x = words[i]
- if ((x >> 5) !== 0) throw new Error('Non 5-bit word')
- chk = polymodStep(chk) ^ x
- result += ALPHABET.charAt(x)
- }
- for (i = 0; i < 6; ++i) {
- chk = polymodStep(chk)
- }
- chk ^= 1
- for (i = 0; i < 6; ++i) {
- var v = (chk >> ((5 - i) * 5)) & 0x1f
- result += ALPHABET.charAt(v)
- }
- return result
- }
- function __decode (str, LIMIT) {
- LIMIT = LIMIT || 90
- if (str.length < 8) return str + ' too short'
- if (str.length > LIMIT) return 'Exceeds length limit'
- // don't allow mixed case
- var lowered = str.toLowerCase()
- var uppered = str.toUpperCase()
- if (str !== lowered && str !== uppered) return 'Mixed-case string ' + str
- str = lowered
- var split = str.lastIndexOf('1')
- if (split === -1) return 'No separator character for ' + str
- if (split === 0) return 'Missing prefix for ' + str
- var prefix = str.slice(0, split)
- var wordChars = str.slice(split + 1)
- if (wordChars.length < 6) return 'Data too short'
- var chk = prefixChk(prefix)
- if (typeof chk === 'string') return chk
- var words = []
- for (var i = 0; i < wordChars.length; ++i) {
- var c = wordChars.charAt(i)
- var v = ALPHABET_MAP[c]
- if (v === undefined) return 'Unknown character ' + c
- chk = polymodStep(chk) ^ v
- // not in the checksum?
- if (i + 6 >= wordChars.length) continue
- words.push(v)
- }
- if (chk !== 1) return 'Invalid checksum for ' + str
- return { prefix: prefix, words: words }
- }
- function decodeUnsafe () {
- var res = __decode.apply(null, arguments)
- if (typeof res === 'object') return res
- }
- function decode (str) {
- var res = __decode.apply(null, arguments)
- if (typeof res === 'object') return res
- throw new Error(res)
- }
- function convert (data, inBits, outBits, pad) {
- var value = 0
- var bits = 0
- var maxV = (1 << outBits) - 1
- var result = []
- for (var i = 0; i < data.length; ++i) {
- value = (value << inBits) | data[i]
- bits += inBits
- while (bits >= outBits) {
- bits -= outBits
- result.push((value >> bits) & maxV)
- }
- }
- if (pad) {
- if (bits > 0) {
- result.push((value << (outBits - bits)) & maxV)
- }
- } else {
- if (bits >= inBits) return 'Excess padding'
- if ((value << (outBits - bits)) & maxV) return 'Non-zero padding'
- }
- return result
- }
- function toWordsUnsafe (bytes) {
- var res = convert(bytes, 8, 5, true)
- if (Array.isArray(res)) return res
- }
- function toWords (bytes) {
- var res = convert(bytes, 8, 5, true)
- if (Array.isArray(res)) return res
- throw new Error(res)
- }
- function fromWordsUnsafe (words) {
- var res = convert(words, 5, 8, false)
- if (Array.isArray(res)) return res
- }
- function fromWords (words) {
- var res = convert(words, 5, 8, false)
- if (Array.isArray(res)) return res
- throw new Error(res)
- }
- module.exports = {
- decodeUnsafe: decodeUnsafe,
- decode: decode,
- encode: encode,
- toWordsUnsafe: toWordsUnsafe,
- toWords: toWords,
- fromWordsUnsafe: fromWordsUnsafe,
- fromWords: fromWords
- }
- },{}],322:[function(_dereq_,module,exports){
- var r;
- module.exports = function rand(len) {
- if (!r)
- r = new Rand(null);
- return r.generate(len);
- };
- function Rand(rand) {
- this.rand = rand;
- }
- module.exports.Rand = Rand;
- Rand.prototype.generate = function generate(len) {
- return this._rand(len);
- };
- // Emulate crypto API using randy
- Rand.prototype._rand = function _rand(n) {
- if (this.rand.getBytes)
- return this.rand.getBytes(n);
- var res = new Uint8Array(n);
- for (var i = 0; i < res.length; i++)
- res[i] = this.rand.getByte();
- return res;
- };
- if (typeof self === 'object') {
- if (self.crypto && self.crypto.getRandomValues) {
- // Modern browsers
- Rand.prototype._rand = function _rand(n) {
- var arr = new Uint8Array(n);
- self.crypto.getRandomValues(arr);
- return arr;
- };
- } else if (self.msCrypto && self.msCrypto.getRandomValues) {
- // IE
- Rand.prototype._rand = function _rand(n) {
- var arr = new Uint8Array(n);
- self.msCrypto.getRandomValues(arr);
- return arr;
- };
- // Safari's WebWorkers do not have `crypto`
- } else if (typeof window === 'object') {
- // Old junk
- Rand.prototype._rand = function() {
- throw new Error('Not implemented yet');
- };
- }
- } else {
- // Node.js or Web worker with no crypto support
- try {
- var crypto = _dereq_('crypto');
- if (typeof crypto.randomBytes !== 'function')
- throw new Error('Not supported');
- Rand.prototype._rand = function _rand(n) {
- return crypto.randomBytes(n);
- };
- } catch (e) {
- }
- }
- },{"crypto":undefined}],323:[function(_dereq_,module,exports){
- },{}],324:[function(_dereq_,module,exports){
- var parent = _dereq_('../../stable/array/from');
- module.exports = parent;
- },{"../../stable/array/from":691}],325:[function(_dereq_,module,exports){
- var parent = _dereq_('../../stable/array/is-array');
- module.exports = parent;
- },{"../../stable/array/is-array":692}],326:[function(_dereq_,module,exports){
- var parent = _dereq_('../stable/get-iterator-method');
- module.exports = parent;
- },{"../stable/get-iterator-method":697}],327:[function(_dereq_,module,exports){
- var parent = _dereq_('../../stable/instance/bind');
- module.exports = parent;
- },{"../../stable/instance/bind":698}],328:[function(_dereq_,module,exports){
- var parent = _dereq_('../../stable/instance/index-of');
- module.exports = parent;
- },{"../../stable/instance/index-of":706}],329:[function(_dereq_,module,exports){
- var parent = _dereq_('../../stable/instance/slice');
- module.exports = parent;
- },{"../../stable/instance/slice":711}],330:[function(_dereq_,module,exports){
- var parent = _dereq_('../../stable/map');
- module.exports = parent;
- },{"../../stable/map":718}],331:[function(_dereq_,module,exports){
- var parent = _dereq_('../../stable/object/create');
- module.exports = parent;
- },{"../../stable/object/create":721}],332:[function(_dereq_,module,exports){
- var parent = _dereq_('../../stable/object/define-property');
- module.exports = parent;
- },{"../../stable/object/define-property":723}],333:[function(_dereq_,module,exports){
- var parent = _dereq_('../../stable/object/get-own-property-descriptor');
- module.exports = parent;
- },{"../../stable/object/get-own-property-descriptor":726}],334:[function(_dereq_,module,exports){
- var parent = _dereq_('../../stable/object/get-prototype-of');
- module.exports = parent;
- },{"../../stable/object/get-prototype-of":729}],335:[function(_dereq_,module,exports){
- var parent = _dereq_('../../stable/object/set-prototype-of');
- module.exports = parent;
- },{"../../stable/object/set-prototype-of":731}],336:[function(_dereq_,module,exports){
- var parent = _dereq_('../../stable/promise');
- module.exports = parent;
- },{"../../stable/promise":734}],337:[function(_dereq_,module,exports){
- var parent = _dereq_('../../stable/reflect/construct');
- module.exports = parent;
- },{"../../stable/reflect/construct":735}],338:[function(_dereq_,module,exports){
- var parent = _dereq_('../../stable/reflect/get');
- module.exports = parent;
- },{"../../stable/reflect/get":736}],339:[function(_dereq_,module,exports){
- var parent = _dereq_('../../stable/symbol');
- module.exports = parent;
- },{"../../stable/symbol":739}],340:[function(_dereq_,module,exports){
- var parent = _dereq_('../../stable/symbol/iterator');
- module.exports = parent;
- },{"../../stable/symbol/iterator":740}],341:[function(_dereq_,module,exports){
- _dereq_('../../modules/es.string.iterator');
- _dereq_('../../modules/es.array.from');
- var path = _dereq_('../../internals/path');
- module.exports = path.Array.from;
- },{"../../internals/path":548,"../../modules/es.array.from":594,"../../modules/es.string.iterator":634}],342:[function(_dereq_,module,exports){
- _dereq_('../../modules/es.array.is-array');
- var path = _dereq_('../../internals/path');
- module.exports = path.Array.isArray;
- },{"../../internals/path":548,"../../modules/es.array.is-array":597}],343:[function(_dereq_,module,exports){
- _dereq_('../../../modules/es.array.concat');
- var entryVirtual = _dereq_('../../../internals/entry-virtual');
- module.exports = entryVirtual('Array').concat;
- },{"../../../internals/entry-virtual":473,"../../../modules/es.array.concat":589}],344:[function(_dereq_,module,exports){
- _dereq_('../../../modules/es.array.iterator');
- _dereq_('../../../modules/es.object.to-string');
- var entryVirtual = _dereq_('../../../internals/entry-virtual');
- module.exports = entryVirtual('Array').entries;
- },{"../../../internals/entry-virtual":473,"../../../modules/es.array.iterator":598,"../../../modules/es.object.to-string":621}],345:[function(_dereq_,module,exports){
- _dereq_('../../../modules/es.array.every');
- var entryVirtual = _dereq_('../../../internals/entry-virtual');
- module.exports = entryVirtual('Array').every;
- },{"../../../internals/entry-virtual":473,"../../../modules/es.array.every":590}],346:[function(_dereq_,module,exports){
- _dereq_('../../../modules/es.array.filter');
- var entryVirtual = _dereq_('../../../internals/entry-virtual');
- module.exports = entryVirtual('Array').filter;
- },{"../../../internals/entry-virtual":473,"../../../modules/es.array.filter":591}],347:[function(_dereq_,module,exports){
- _dereq_('../../../modules/es.array.find');
- var entryVirtual = _dereq_('../../../internals/entry-virtual');
- module.exports = entryVirtual('Array').find;
- },{"../../../internals/entry-virtual":473,"../../../modules/es.array.find":592}],348:[function(_dereq_,module,exports){
- _dereq_('../../../modules/es.array.for-each');
- var entryVirtual = _dereq_('../../../internals/entry-virtual');
- module.exports = entryVirtual('Array').forEach;
- },{"../../../internals/entry-virtual":473,"../../../modules/es.array.for-each":593}],349:[function(_dereq_,module,exports){
- _dereq_('../../../modules/es.array.includes');
- var entryVirtual = _dereq_('../../../internals/entry-virtual');
- module.exports = entryVirtual('Array').includes;
- },{"../../../internals/entry-virtual":473,"../../../modules/es.array.includes":595}],350:[function(_dereq_,module,exports){
- _dereq_('../../../modules/es.array.index-of');
- var entryVirtual = _dereq_('../../../internals/entry-virtual');
- module.exports = entryVirtual('Array').indexOf;
- },{"../../../internals/entry-virtual":473,"../../../modules/es.array.index-of":596}],351:[function(_dereq_,module,exports){
- _dereq_('../../../modules/es.array.iterator');
- _dereq_('../../../modules/es.object.to-string');
- var entryVirtual = _dereq_('../../../internals/entry-virtual');
- module.exports = entryVirtual('Array').keys;
- },{"../../../internals/entry-virtual":473,"../../../modules/es.array.iterator":598,"../../../modules/es.object.to-string":621}],352:[function(_dereq_,module,exports){
- _dereq_('../../../modules/es.array.map');
- var entryVirtual = _dereq_('../../../internals/entry-virtual');
- module.exports = entryVirtual('Array').map;
- },{"../../../internals/entry-virtual":473,"../../../modules/es.array.map":599}],353:[function(_dereq_,module,exports){
- _dereq_('../../../modules/es.array.reduce');
- var entryVirtual = _dereq_('../../../internals/entry-virtual');
- module.exports = entryVirtual('Array').reduce;
- },{"../../../internals/entry-virtual":473,"../../../modules/es.array.reduce":600}],354:[function(_dereq_,module,exports){
- _dereq_('../../../modules/es.array.slice');
- var entryVirtual = _dereq_('../../../internals/entry-virtual');
- module.exports = entryVirtual('Array').slice;
- },{"../../../internals/entry-virtual":473,"../../../modules/es.array.slice":601}],355:[function(_dereq_,module,exports){
- _dereq_('../../../modules/es.array.sort');
- var entryVirtual = _dereq_('../../../internals/entry-virtual');
- module.exports = entryVirtual('Array').sort;
- },{"../../../internals/entry-virtual":473,"../../../modules/es.array.sort":602}],356:[function(_dereq_,module,exports){
- _dereq_('../../../modules/es.array.splice');
- var entryVirtual = _dereq_('../../../internals/entry-virtual');
- module.exports = entryVirtual('Array').splice;
- },{"../../../internals/entry-virtual":473,"../../../modules/es.array.splice":603}],357:[function(_dereq_,module,exports){
- _dereq_('../../../modules/es.array.iterator');
- _dereq_('../../../modules/es.object.to-string');
- var entryVirtual = _dereq_('../../../internals/entry-virtual');
- module.exports = entryVirtual('Array').values;
- },{"../../../internals/entry-virtual":473,"../../../modules/es.array.iterator":598,"../../../modules/es.object.to-string":621}],358:[function(_dereq_,module,exports){
- _dereq_('../../../modules/es.function.bind');
- var entryVirtual = _dereq_('../../../internals/entry-virtual');
- module.exports = entryVirtual('Function').bind;
- },{"../../../internals/entry-virtual":473,"../../../modules/es.function.bind":604}],359:[function(_dereq_,module,exports){
- _dereq_('../modules/es.array.iterator');
- _dereq_('../modules/es.string.iterator');
- var getIteratorMethod = _dereq_('../internals/get-iterator-method');
- module.exports = getIteratorMethod;
- },{"../internals/get-iterator-method":487,"../modules/es.array.iterator":598,"../modules/es.string.iterator":634}],360:[function(_dereq_,module,exports){
- var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
- var method = _dereq_('../function/virtual/bind');
- var FunctionPrototype = Function.prototype;
- module.exports = function (it) {
- var own = it.bind;
- return it === FunctionPrototype || (isPrototypeOf(FunctionPrototype, it) && own === FunctionPrototype.bind) ? method : own;
- };
- },{"../../internals/object-is-prototype-of":539,"../function/virtual/bind":358}],361:[function(_dereq_,module,exports){
- var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
- var method = _dereq_('../array/virtual/concat');
- var ArrayPrototype = Array.prototype;
- module.exports = function (it) {
- var own = it.concat;
- return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.concat) ? method : own;
- };
- },{"../../internals/object-is-prototype-of":539,"../array/virtual/concat":343}],362:[function(_dereq_,module,exports){
- var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
- var method = _dereq_('../array/virtual/every');
- var ArrayPrototype = Array.prototype;
- module.exports = function (it) {
- var own = it.every;
- return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.every) ? method : own;
- };
- },{"../../internals/object-is-prototype-of":539,"../array/virtual/every":345}],363:[function(_dereq_,module,exports){
- var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
- var method = _dereq_('../array/virtual/filter');
- var ArrayPrototype = Array.prototype;
- module.exports = function (it) {
- var own = it.filter;
- return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.filter) ? method : own;
- };
- },{"../../internals/object-is-prototype-of":539,"../array/virtual/filter":346}],364:[function(_dereq_,module,exports){
- var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
- var method = _dereq_('../array/virtual/find');
- var ArrayPrototype = Array.prototype;
- module.exports = function (it) {
- var own = it.find;
- return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.find) ? method : own;
- };
- },{"../../internals/object-is-prototype-of":539,"../array/virtual/find":347}],365:[function(_dereq_,module,exports){
- var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
- var arrayMethod = _dereq_('../array/virtual/includes');
- var stringMethod = _dereq_('../string/virtual/includes');
- var ArrayPrototype = Array.prototype;
- var StringPrototype = String.prototype;
- module.exports = function (it) {
- var own = it.includes;
- if (it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.includes)) return arrayMethod;
- if (typeof it == 'string' || it === StringPrototype || (isPrototypeOf(StringPrototype, it) && own === StringPrototype.includes)) {
- return stringMethod;
- } return own;
- };
- },{"../../internals/object-is-prototype-of":539,"../array/virtual/includes":349,"../string/virtual/includes":396}],366:[function(_dereq_,module,exports){
- var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
- var method = _dereq_('../array/virtual/index-of');
- var ArrayPrototype = Array.prototype;
- module.exports = function (it) {
- var own = it.indexOf;
- return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.indexOf) ? method : own;
- };
- },{"../../internals/object-is-prototype-of":539,"../array/virtual/index-of":350}],367:[function(_dereq_,module,exports){
- var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
- var method = _dereq_('../array/virtual/map');
- var ArrayPrototype = Array.prototype;
- module.exports = function (it) {
- var own = it.map;
- return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.map) ? method : own;
- };
- },{"../../internals/object-is-prototype-of":539,"../array/virtual/map":352}],368:[function(_dereq_,module,exports){
- var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
- var method = _dereq_('../string/virtual/pad-start');
- var StringPrototype = String.prototype;
- module.exports = function (it) {
- var own = it.padStart;
- return typeof it == 'string' || it === StringPrototype
- || (isPrototypeOf(StringPrototype, it) && own === StringPrototype.padStart) ? method : own;
- };
- },{"../../internals/object-is-prototype-of":539,"../string/virtual/pad-start":397}],369:[function(_dereq_,module,exports){
- var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
- var method = _dereq_('../array/virtual/reduce');
- var ArrayPrototype = Array.prototype;
- module.exports = function (it) {
- var own = it.reduce;
- return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.reduce) ? method : own;
- };
- },{"../../internals/object-is-prototype-of":539,"../array/virtual/reduce":353}],370:[function(_dereq_,module,exports){
- var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
- var method = _dereq_('../array/virtual/slice');
- var ArrayPrototype = Array.prototype;
- module.exports = function (it) {
- var own = it.slice;
- return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.slice) ? method : own;
- };
- },{"../../internals/object-is-prototype-of":539,"../array/virtual/slice":354}],371:[function(_dereq_,module,exports){
- var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
- var method = _dereq_('../array/virtual/sort');
- var ArrayPrototype = Array.prototype;
- module.exports = function (it) {
- var own = it.sort;
- return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.sort) ? method : own;
- };
- },{"../../internals/object-is-prototype-of":539,"../array/virtual/sort":355}],372:[function(_dereq_,module,exports){
- var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
- var method = _dereq_('../array/virtual/splice');
- var ArrayPrototype = Array.prototype;
- module.exports = function (it) {
- var own = it.splice;
- return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.splice) ? method : own;
- };
- },{"../../internals/object-is-prototype-of":539,"../array/virtual/splice":356}],373:[function(_dereq_,module,exports){
- var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
- var method = _dereq_('../string/virtual/starts-with');
- var StringPrototype = String.prototype;
- module.exports = function (it) {
- var own = it.startsWith;
- return typeof it == 'string' || it === StringPrototype
- || (isPrototypeOf(StringPrototype, it) && own === StringPrototype.startsWith) ? method : own;
- };
- },{"../../internals/object-is-prototype-of":539,"../string/virtual/starts-with":398}],374:[function(_dereq_,module,exports){
- var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
- var method = _dereq_('../string/virtual/trim');
- var StringPrototype = String.prototype;
- module.exports = function (it) {
- var own = it.trim;
- return typeof it == 'string' || it === StringPrototype
- || (isPrototypeOf(StringPrototype, it) && own === StringPrototype.trim) ? method : own;
- };
- },{"../../internals/object-is-prototype-of":539,"../string/virtual/trim":399}],375:[function(_dereq_,module,exports){
- _dereq_('../../modules/es.json.stringify');
- var path = _dereq_('../../internals/path');
- var apply = _dereq_('../../internals/function-apply');
- // eslint-disable-next-line es/no-json -- safe
- if (!path.JSON) path.JSON = { stringify: JSON.stringify };
- // eslint-disable-next-line no-unused-vars -- required for `.length`
- module.exports = function stringify(it, replacer, space) {
- return apply(path.JSON.stringify, null, arguments);
- };
- },{"../../internals/function-apply":479,"../../internals/path":548,"../../modules/es.json.stringify":605}],376:[function(_dereq_,module,exports){
- _dereq_('../../modules/es.array.iterator');
- _dereq_('../../modules/es.map');
- _dereq_('../../modules/es.object.to-string');
- _dereq_('../../modules/es.string.iterator');
- var path = _dereq_('../../internals/path');
- module.exports = path.Map;
- },{"../../internals/path":548,"../../modules/es.array.iterator":598,"../../modules/es.map":607,"../../modules/es.object.to-string":621,"../../modules/es.string.iterator":634}],377:[function(_dereq_,module,exports){
- _dereq_('../../modules/es.number.is-integer');
- var path = _dereq_('../../internals/path');
- module.exports = path.Number.isInteger;
- },{"../../internals/path":548,"../../modules/es.number.is-integer":609}],378:[function(_dereq_,module,exports){
- _dereq_('../../modules/es.number.is-nan');
- var path = _dereq_('../../internals/path');
- module.exports = path.Number.isNaN;
- },{"../../internals/path":548,"../../modules/es.number.is-nan":610}],379:[function(_dereq_,module,exports){
- _dereq_('../../modules/es.object.create');
- var path = _dereq_('../../internals/path');
- var Object = path.Object;
- module.exports = function create(P, D) {
- return Object.create(P, D);
- };
- },{"../../internals/path":548,"../../modules/es.object.create":611}],380:[function(_dereq_,module,exports){
- _dereq_('../../modules/es.object.define-properties');
- var path = _dereq_('../../internals/path');
- var Object = path.Object;
- var defineProperties = module.exports = function defineProperties(T, D) {
- return Object.defineProperties(T, D);
- };
- if (Object.defineProperties.sham) defineProperties.sham = true;
- },{"../../internals/path":548,"../../modules/es.object.define-properties":612}],381:[function(_dereq_,module,exports){
- _dereq_('../../modules/es.object.define-property');
- var path = _dereq_('../../internals/path');
- var Object = path.Object;
- var defineProperty = module.exports = function defineProperty(it, key, desc) {
- return Object.defineProperty(it, key, desc);
- };
- if (Object.defineProperty.sham) defineProperty.sham = true;
- },{"../../internals/path":548,"../../modules/es.object.define-property":613}],382:[function(_dereq_,module,exports){
- _dereq_('../../modules/es.object.entries');
- var path = _dereq_('../../internals/path');
- module.exports = path.Object.entries;
- },{"../../internals/path":548,"../../modules/es.object.entries":614}],383:[function(_dereq_,module,exports){
- _dereq_('../../modules/es.object.freeze');
- var path = _dereq_('../../internals/path');
- module.exports = path.Object.freeze;
- },{"../../internals/path":548,"../../modules/es.object.freeze":615}],384:[function(_dereq_,module,exports){
- _dereq_('../../modules/es.object.get-own-property-descriptor');
- var path = _dereq_('../../internals/path');
- var Object = path.Object;
- var getOwnPropertyDescriptor = module.exports = function getOwnPropertyDescriptor(it, key) {
- return Object.getOwnPropertyDescriptor(it, key);
- };
- if (Object.getOwnPropertyDescriptor.sham) getOwnPropertyDescriptor.sham = true;
- },{"../../internals/path":548,"../../modules/es.object.get-own-property-descriptor":616}],385:[function(_dereq_,module,exports){
- _dereq_('../../modules/es.object.get-own-property-descriptors');
- var path = _dereq_('../../internals/path');
- module.exports = path.Object.getOwnPropertyDescriptors;
- },{"../../internals/path":548,"../../modules/es.object.get-own-property-descriptors":617}],386:[function(_dereq_,module,exports){
- _dereq_('../../modules/es.symbol');
- var path = _dereq_('../../internals/path');
- module.exports = path.Object.getOwnPropertySymbols;
- },{"../../internals/path":548,"../../modules/es.symbol":644}],387:[function(_dereq_,module,exports){
- _dereq_('../../modules/es.object.get-prototype-of');
- var path = _dereq_('../../internals/path');
- module.exports = path.Object.getPrototypeOf;
- },{"../../internals/path":548,"../../modules/es.object.get-prototype-of":618}],388:[function(_dereq_,module,exports){
- _dereq_('../../modules/es.object.keys');
- var path = _dereq_('../../internals/path');
- module.exports = path.Object.keys;
- },{"../../internals/path":548,"../../modules/es.object.keys":619}],389:[function(_dereq_,module,exports){
- _dereq_('../../modules/es.object.set-prototype-of');
- var path = _dereq_('../../internals/path');
- module.exports = path.Object.setPrototypeOf;
- },{"../../internals/path":548,"../../modules/es.object.set-prototype-of":620}],390:[function(_dereq_,module,exports){
- _dereq_('../../modules/es.object.values');
- var path = _dereq_('../../internals/path');
- module.exports = path.Object.values;
- },{"../../internals/path":548,"../../modules/es.object.values":622}],391:[function(_dereq_,module,exports){
- _dereq_('../modules/es.parse-int');
- var path = _dereq_('../internals/path');
- module.exports = path.parseInt;
- },{"../internals/path":548,"../modules/es.parse-int":623}],392:[function(_dereq_,module,exports){
- _dereq_('../../modules/es.aggregate-error');
- _dereq_('../../modules/es.array.iterator');
- _dereq_('../../modules/es.object.to-string');
- _dereq_('../../modules/es.promise');
- _dereq_('../../modules/es.promise.all-settled');
- _dereq_('../../modules/es.promise.any');
- _dereq_('../../modules/es.promise.finally');
- _dereq_('../../modules/es.string.iterator');
- var path = _dereq_('../../internals/path');
- module.exports = path.Promise;
- },{"../../internals/path":548,"../../modules/es.aggregate-error":588,"../../modules/es.array.iterator":598,"../../modules/es.object.to-string":621,"../../modules/es.promise":627,"../../modules/es.promise.all-settled":624,"../../modules/es.promise.any":625,"../../modules/es.promise.finally":626,"../../modules/es.string.iterator":634}],393:[function(_dereq_,module,exports){
- _dereq_('../../modules/es.reflect.construct');
- var path = _dereq_('../../internals/path');
- module.exports = path.Reflect.construct;
- },{"../../internals/path":548,"../../modules/es.reflect.construct":628}],394:[function(_dereq_,module,exports){
- _dereq_('../../modules/es.reflect.get');
- var path = _dereq_('../../internals/path');
- module.exports = path.Reflect.get;
- },{"../../internals/path":548,"../../modules/es.reflect.get":629}],395:[function(_dereq_,module,exports){
- _dereq_('../../modules/es.array.iterator');
- _dereq_('../../modules/es.object.to-string');
- _dereq_('../../modules/es.set');
- _dereq_('../../modules/es.string.iterator');
- var path = _dereq_('../../internals/path');
- module.exports = path.Set;
- },{"../../internals/path":548,"../../modules/es.array.iterator":598,"../../modules/es.object.to-string":621,"../../modules/es.set":632,"../../modules/es.string.iterator":634}],396:[function(_dereq_,module,exports){
- _dereq_('../../../modules/es.string.includes');
- var entryVirtual = _dereq_('../../../internals/entry-virtual');
- module.exports = entryVirtual('String').includes;
- },{"../../../internals/entry-virtual":473,"../../../modules/es.string.includes":633}],397:[function(_dereq_,module,exports){
- _dereq_('../../../modules/es.string.pad-start');
- var entryVirtual = _dereq_('../../../internals/entry-virtual');
- module.exports = entryVirtual('String').padStart;
- },{"../../../internals/entry-virtual":473,"../../../modules/es.string.pad-start":635}],398:[function(_dereq_,module,exports){
- _dereq_('../../../modules/es.string.starts-with');
- var entryVirtual = _dereq_('../../../internals/entry-virtual');
- module.exports = entryVirtual('String').startsWith;
- },{"../../../internals/entry-virtual":473,"../../../modules/es.string.starts-with":637}],399:[function(_dereq_,module,exports){
- _dereq_('../../../modules/es.string.trim');
- var entryVirtual = _dereq_('../../../internals/entry-virtual');
- module.exports = entryVirtual('String').trim;
- },{"../../../internals/entry-virtual":473,"../../../modules/es.string.trim":638}],400:[function(_dereq_,module,exports){
- _dereq_('../../modules/es.array.concat');
- _dereq_('../../modules/es.object.to-string');
- _dereq_('../../modules/es.symbol');
- _dereq_('../../modules/es.symbol.async-iterator');
- _dereq_('../../modules/es.symbol.description');
- _dereq_('../../modules/es.symbol.has-instance');
- _dereq_('../../modules/es.symbol.is-concat-spreadable');
- _dereq_('../../modules/es.symbol.iterator');
- _dereq_('../../modules/es.symbol.match');
- _dereq_('../../modules/es.symbol.match-all');
- _dereq_('../../modules/es.symbol.replace');
- _dereq_('../../modules/es.symbol.search');
- _dereq_('../../modules/es.symbol.species');
- _dereq_('../../modules/es.symbol.split');
- _dereq_('../../modules/es.symbol.to-primitive');
- _dereq_('../../modules/es.symbol.to-string-tag');
- _dereq_('../../modules/es.symbol.unscopables');
- _dereq_('../../modules/es.json.to-string-tag');
- _dereq_('../../modules/es.math.to-string-tag');
- _dereq_('../../modules/es.reflect.to-string-tag');
- var path = _dereq_('../../internals/path');
- module.exports = path.Symbol;
- },{"../../internals/path":548,"../../modules/es.array.concat":589,"../../modules/es.json.to-string-tag":606,"../../modules/es.math.to-string-tag":608,"../../modules/es.object.to-string":621,"../../modules/es.reflect.to-string-tag":630,"../../modules/es.symbol":644,"../../modules/es.symbol.async-iterator":639,"../../modules/es.symbol.description":640,"../../modules/es.symbol.has-instance":641,"../../modules/es.symbol.is-concat-spreadable":642,"../../modules/es.symbol.iterator":643,"../../modules/es.symbol.match":646,"../../modules/es.symbol.match-all":645,"../../modules/es.symbol.replace":647,"../../modules/es.symbol.search":648,"../../modules/es.symbol.species":649,"../../modules/es.symbol.split":650,"../../modules/es.symbol.to-primitive":651,"../../modules/es.symbol.to-string-tag":652,"../../modules/es.symbol.unscopables":653}],401:[function(_dereq_,module,exports){
- _dereq_('../../modules/es.array.iterator');
- _dereq_('../../modules/es.object.to-string');
- _dereq_('../../modules/es.string.iterator');
- _dereq_('../../modules/es.symbol.iterator');
- var WrappedWellKnownSymbolModule = _dereq_('../../internals/well-known-symbol-wrapped');
- module.exports = WrappedWellKnownSymbolModule.f('iterator');
- },{"../../internals/well-known-symbol-wrapped":585,"../../modules/es.array.iterator":598,"../../modules/es.object.to-string":621,"../../modules/es.string.iterator":634,"../../modules/es.symbol.iterator":643}],402:[function(_dereq_,module,exports){
- _dereq_('../../modules/es.regexp.exec');
- _dereq_('../../modules/es.symbol.replace');
- _dereq_('../../modules/es.string.replace');
- var WrappedWellKnownSymbolModule = _dereq_('../../internals/well-known-symbol-wrapped');
- module.exports = WrappedWellKnownSymbolModule.f('replace');
- },{"../../internals/well-known-symbol-wrapped":585,"../../modules/es.regexp.exec":631,"../../modules/es.string.replace":636,"../../modules/es.symbol.replace":647}],403:[function(_dereq_,module,exports){
- _dereq_('../../modules/es.array.iterator');
- _dereq_('../../modules/es.object.to-string');
- _dereq_('../../modules/es.weak-map');
- var path = _dereq_('../../internals/path');
- module.exports = path.WeakMap;
- },{"../../internals/path":548,"../../modules/es.array.iterator":598,"../../modules/es.object.to-string":621,"../../modules/es.weak-map":654}],404:[function(_dereq_,module,exports){
- var parent = _dereq_('../../actual/array/from');
- module.exports = parent;
- },{"../../actual/array/from":324}],405:[function(_dereq_,module,exports){
- var parent = _dereq_('../../actual/array/is-array');
- module.exports = parent;
- },{"../../actual/array/is-array":325}],406:[function(_dereq_,module,exports){
- var parent = _dereq_('../actual/get-iterator-method');
- module.exports = parent;
- },{"../actual/get-iterator-method":326}],407:[function(_dereq_,module,exports){
- var parent = _dereq_('../../actual/instance/bind');
- module.exports = parent;
- },{"../../actual/instance/bind":327}],408:[function(_dereq_,module,exports){
- var parent = _dereq_('../../actual/instance/index-of');
- module.exports = parent;
- },{"../../actual/instance/index-of":328}],409:[function(_dereq_,module,exports){
- var parent = _dereq_('../../actual/instance/slice');
- module.exports = parent;
- },{"../../actual/instance/slice":329}],410:[function(_dereq_,module,exports){
- var parent = _dereq_('../../actual/map');
- _dereq_('../../modules/esnext.map.from');
- _dereq_('../../modules/esnext.map.of');
- _dereq_('../../modules/esnext.map.delete-all');
- _dereq_('../../modules/esnext.map.emplace');
- _dereq_('../../modules/esnext.map.every');
- _dereq_('../../modules/esnext.map.filter');
- _dereq_('../../modules/esnext.map.find');
- _dereq_('../../modules/esnext.map.find-key');
- _dereq_('../../modules/esnext.map.group-by');
- _dereq_('../../modules/esnext.map.includes');
- _dereq_('../../modules/esnext.map.key-by');
- _dereq_('../../modules/esnext.map.key-of');
- _dereq_('../../modules/esnext.map.map-keys');
- _dereq_('../../modules/esnext.map.map-values');
- _dereq_('../../modules/esnext.map.merge');
- _dereq_('../../modules/esnext.map.reduce');
- _dereq_('../../modules/esnext.map.some');
- _dereq_('../../modules/esnext.map.update');
- // TODO: remove from `core-js@4`
- _dereq_('../../modules/esnext.map.upsert');
- // TODO: remove from `core-js@4`
- _dereq_('../../modules/esnext.map.update-or-insert');
- module.exports = parent;
- },{"../../actual/map":330,"../../modules/esnext.map.delete-all":656,"../../modules/esnext.map.emplace":657,"../../modules/esnext.map.every":658,"../../modules/esnext.map.filter":659,"../../modules/esnext.map.find":661,"../../modules/esnext.map.find-key":660,"../../modules/esnext.map.from":662,"../../modules/esnext.map.group-by":663,"../../modules/esnext.map.includes":664,"../../modules/esnext.map.key-by":665,"../../modules/esnext.map.key-of":666,"../../modules/esnext.map.map-keys":667,"../../modules/esnext.map.map-values":668,"../../modules/esnext.map.merge":669,"../../modules/esnext.map.of":670,"../../modules/esnext.map.reduce":671,"../../modules/esnext.map.some":672,"../../modules/esnext.map.update":674,"../../modules/esnext.map.update-or-insert":673,"../../modules/esnext.map.upsert":675}],411:[function(_dereq_,module,exports){
- var parent = _dereq_('../../actual/object/create');
- module.exports = parent;
- },{"../../actual/object/create":331}],412:[function(_dereq_,module,exports){
- var parent = _dereq_('../../actual/object/define-property');
- module.exports = parent;
- },{"../../actual/object/define-property":332}],413:[function(_dereq_,module,exports){
- var parent = _dereq_('../../actual/object/get-own-property-descriptor');
- module.exports = parent;
- },{"../../actual/object/get-own-property-descriptor":333}],414:[function(_dereq_,module,exports){
- var parent = _dereq_('../../actual/object/get-prototype-of');
- module.exports = parent;
- },{"../../actual/object/get-prototype-of":334}],415:[function(_dereq_,module,exports){
- var parent = _dereq_('../../actual/object/set-prototype-of');
- module.exports = parent;
- },{"../../actual/object/set-prototype-of":335}],416:[function(_dereq_,module,exports){
- var parent = _dereq_('../../actual/promise');
- _dereq_('../../modules/esnext.aggregate-error');
- // TODO: Remove from `core-js@4`
- _dereq_('../../modules/esnext.promise.all-settled');
- _dereq_('../../modules/esnext.promise.try');
- _dereq_('../../modules/esnext.promise.any');
- module.exports = parent;
- },{"../../actual/promise":336,"../../modules/esnext.aggregate-error":655,"../../modules/esnext.promise.all-settled":676,"../../modules/esnext.promise.any":677,"../../modules/esnext.promise.try":678}],417:[function(_dereq_,module,exports){
- var parent = _dereq_('../../actual/reflect/construct');
- module.exports = parent;
- },{"../../actual/reflect/construct":337}],418:[function(_dereq_,module,exports){
- var parent = _dereq_('../../actual/reflect/get');
- module.exports = parent;
- },{"../../actual/reflect/get":338}],419:[function(_dereq_,module,exports){
- var parent = _dereq_('../../actual/symbol');
- _dereq_('../../modules/esnext.symbol.async-dispose');
- _dereq_('../../modules/esnext.symbol.dispose');
- _dereq_('../../modules/esnext.symbol.matcher');
- _dereq_('../../modules/esnext.symbol.metadata');
- _dereq_('../../modules/esnext.symbol.observable');
- // TODO: Remove from `core-js@4`
- _dereq_('../../modules/esnext.symbol.pattern-match');
- // TODO: Remove from `core-js@4`
- _dereq_('../../modules/esnext.symbol.replace-all');
- module.exports = parent;
- },{"../../actual/symbol":339,"../../modules/esnext.symbol.async-dispose":679,"../../modules/esnext.symbol.dispose":680,"../../modules/esnext.symbol.matcher":681,"../../modules/esnext.symbol.metadata":682,"../../modules/esnext.symbol.observable":683,"../../modules/esnext.symbol.pattern-match":684,"../../modules/esnext.symbol.replace-all":685}],420:[function(_dereq_,module,exports){
- var parent = _dereq_('../../actual/symbol/iterator');
- module.exports = parent;
- },{"../../actual/symbol/iterator":340}],421:[function(_dereq_,module,exports){
- var global = _dereq_('../internals/global');
- var isCallable = _dereq_('../internals/is-callable');
- var tryToString = _dereq_('../internals/try-to-string');
- var TypeError = global.TypeError;
- // `Assert: IsCallable(argument) is true`
- module.exports = function (argument) {
- if (isCallable(argument)) return argument;
- throw TypeError(tryToString(argument) + ' is not a function');
- };
- },{"../internals/global":491,"../internals/is-callable":504,"../internals/try-to-string":580}],422:[function(_dereq_,module,exports){
- var global = _dereq_('../internals/global');
- var isConstructor = _dereq_('../internals/is-constructor');
- var tryToString = _dereq_('../internals/try-to-string');
- var TypeError = global.TypeError;
- // `Assert: IsConstructor(argument) is true`
- module.exports = function (argument) {
- if (isConstructor(argument)) return argument;
- throw TypeError(tryToString(argument) + ' is not a constructor');
- };
- },{"../internals/global":491,"../internals/is-constructor":505,"../internals/try-to-string":580}],423:[function(_dereq_,module,exports){
- var global = _dereq_('../internals/global');
- var isCallable = _dereq_('../internals/is-callable');
- var String = global.String;
- var TypeError = global.TypeError;
- module.exports = function (argument) {
- if (typeof argument == 'object' || isCallable(argument)) return argument;
- throw TypeError("Can't set " + String(argument) + ' as a prototype');
- };
- },{"../internals/global":491,"../internals/is-callable":504}],424:[function(_dereq_,module,exports){
- module.exports = function () { /* empty */ };
- },{}],425:[function(_dereq_,module,exports){
- var global = _dereq_('../internals/global');
- var isPrototypeOf = _dereq_('../internals/object-is-prototype-of');
- var TypeError = global.TypeError;
- module.exports = function (it, Prototype) {
- if (isPrototypeOf(Prototype, it)) return it;
- throw TypeError('Incorrect invocation');
- };
- },{"../internals/global":491,"../internals/object-is-prototype-of":539}],426:[function(_dereq_,module,exports){
- var global = _dereq_('../internals/global');
- var isObject = _dereq_('../internals/is-object');
- var String = global.String;
- var TypeError = global.TypeError;
- // `Assert: Type(argument) is Object`
- module.exports = function (argument) {
- if (isObject(argument)) return argument;
- throw TypeError(String(argument) + ' is not an object');
- };
- },{"../internals/global":491,"../internals/is-object":509}],427:[function(_dereq_,module,exports){
- // FF26- bug: ArrayBuffers are non-extensible, but Object.isExtensible does not report it
- var fails = _dereq_('../internals/fails');
- module.exports = fails(function () {
- if (typeof ArrayBuffer == 'function') {
- var buffer = new ArrayBuffer(8);
- // eslint-disable-next-line es/no-object-isextensible, es/no-object-defineproperty -- safe
- if (Object.isExtensible(buffer)) Object.defineProperty(buffer, 'a', { value: 8 });
- }
- });
- },{"../internals/fails":477}],428:[function(_dereq_,module,exports){
- 'use strict';
- var $forEach = _dereq_('../internals/array-iteration').forEach;
- var arrayMethodIsStrict = _dereq_('../internals/array-method-is-strict');
- var STRICT_METHOD = arrayMethodIsStrict('forEach');
- // `Array.prototype.forEach` method implementation
- // https://tc39.es/ecma262/#sec-array.prototype.foreach
- module.exports = !STRICT_METHOD ? function forEach(callbackfn /* , thisArg */) {
- return $forEach(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
- // eslint-disable-next-line es/no-array-prototype-foreach -- safe
- } : [].forEach;
- },{"../internals/array-iteration":431,"../internals/array-method-is-strict":433}],429:[function(_dereq_,module,exports){
- 'use strict';
- var global = _dereq_('../internals/global');
- var bind = _dereq_('../internals/function-bind-context');
- var call = _dereq_('../internals/function-call');
- var toObject = _dereq_('../internals/to-object');
- var callWithSafeIterationClosing = _dereq_('../internals/call-with-safe-iteration-closing');
- var isArrayIteratorMethod = _dereq_('../internals/is-array-iterator-method');
- var isConstructor = _dereq_('../internals/is-constructor');
- var lengthOfArrayLike = _dereq_('../internals/length-of-array-like');
- var createProperty = _dereq_('../internals/create-property');
- var getIterator = _dereq_('../internals/get-iterator');
- var getIteratorMethod = _dereq_('../internals/get-iterator-method');
- var Array = global.Array;
- // `Array.from` method implementation
- // https://tc39.es/ecma262/#sec-array.from
- module.exports = function from(arrayLike /* , mapfn = undefined, thisArg = undefined */) {
- var O = toObject(arrayLike);
- var IS_CONSTRUCTOR = isConstructor(this);
- var argumentsLength = arguments.length;
- var mapfn = argumentsLength > 1 ? arguments[1] : undefined;
- var mapping = mapfn !== undefined;
- if (mapping) mapfn = bind(mapfn, argumentsLength > 2 ? arguments[2] : undefined);
- var iteratorMethod = getIteratorMethod(O);
- var index = 0;
- var length, result, step, iterator, next, value;
- // if the target is not iterable or it's an array with the default iterator - use a simple case
- if (iteratorMethod && !(this == Array && isArrayIteratorMethod(iteratorMethod))) {
- iterator = getIterator(O, iteratorMethod);
- next = iterator.next;
- result = IS_CONSTRUCTOR ? new this() : [];
- for (;!(step = call(next, iterator)).done; index++) {
- value = mapping ? callWithSafeIterationClosing(iterator, mapfn, [step.value, index], true) : step.value;
- createProperty(result, index, value);
- }
- } else {
- length = lengthOfArrayLike(O);
- result = IS_CONSTRUCTOR ? new this(length) : Array(length);
- for (;length > index; index++) {
- value = mapping ? mapfn(O[index], index) : O[index];
- createProperty(result, index, value);
- }
- }
- result.length = index;
- return result;
- };
- },{"../internals/call-with-safe-iteration-closing":440,"../internals/create-property":457,"../internals/function-bind-context":480,"../internals/function-call":483,"../internals/get-iterator":488,"../internals/get-iterator-method":487,"../internals/global":491,"../internals/is-array-iterator-method":502,"../internals/is-constructor":505,"../internals/length-of-array-like":517,"../internals/to-object":575}],430:[function(_dereq_,module,exports){
- var toIndexedObject = _dereq_('../internals/to-indexed-object');
- var toAbsoluteIndex = _dereq_('../internals/to-absolute-index');
- var lengthOfArrayLike = _dereq_('../internals/length-of-array-like');
- // `Array.prototype.{ indexOf, includes }` methods implementation
- var createMethod = function (IS_INCLUDES) {
- return function ($this, el, fromIndex) {
- var O = toIndexedObject($this);
- var length = lengthOfArrayLike(O);
- var index = toAbsoluteIndex(fromIndex, length);
- var value;
- // Array#includes uses SameValueZero equality algorithm
- // eslint-disable-next-line no-self-compare -- NaN check
- if (IS_INCLUDES && el != el) while (length > index) {
- value = O[index++];
- // eslint-disable-next-line no-self-compare -- NaN check
- if (value != value) return true;
- // Array#indexOf ignores holes, Array#includes - not
- } else for (;length > index; index++) {
- if ((IS_INCLUDES || index in O) && O[index] === el) return IS_INCLUDES || index || 0;
- } return !IS_INCLUDES && -1;
- };
- };
- module.exports = {
- // `Array.prototype.includes` method
- // https://tc39.es/ecma262/#sec-array.prototype.includes
- includes: createMethod(true),
- // `Array.prototype.indexOf` method
- // https://tc39.es/ecma262/#sec-array.prototype.indexof
- indexOf: createMethod(false)
- };
- },{"../internals/length-of-array-like":517,"../internals/to-absolute-index":571,"../internals/to-indexed-object":572}],431:[function(_dereq_,module,exports){
- var bind = _dereq_('../internals/function-bind-context');
- var uncurryThis = _dereq_('../internals/function-uncurry-this');
- var IndexedObject = _dereq_('../internals/indexed-object');
- var toObject = _dereq_('../internals/to-object');
- var lengthOfArrayLike = _dereq_('../internals/length-of-array-like');
- var arraySpeciesCreate = _dereq_('../internals/array-species-create');
- var push = uncurryThis([].push);
- // `Array.prototype.{ forEach, map, filter, some, every, find, findIndex, filterReject }` methods implementation
- var createMethod = function (TYPE) {
- var IS_MAP = TYPE == 1;
- var IS_FILTER = TYPE == 2;
- var IS_SOME = TYPE == 3;
- var IS_EVERY = TYPE == 4;
- var IS_FIND_INDEX = TYPE == 6;
- var IS_FILTER_REJECT = TYPE == 7;
- var NO_HOLES = TYPE == 5 || IS_FIND_INDEX;
- return function ($this, callbackfn, that, specificCreate) {
- var O = toObject($this);
- var self = IndexedObject(O);
- var boundFunction = bind(callbackfn, that);
- var length = lengthOfArrayLike(self);
- var index = 0;
- var create = specificCreate || arraySpeciesCreate;
- var target = IS_MAP ? create($this, length) : IS_FILTER || IS_FILTER_REJECT ? create($this, 0) : undefined;
- var value, result;
- for (;length > index; index++) if (NO_HOLES || index in self) {
- value = self[index];
- result = boundFunction(value, index, O);
- if (TYPE) {
- if (IS_MAP) target[index] = result; // map
- else if (result) switch (TYPE) {
- case 3: return true; // some
- case 5: return value; // find
- case 6: return index; // findIndex
- case 2: push(target, value); // filter
- } else switch (TYPE) {
- case 4: return false; // every
- case 7: push(target, value); // filterReject
- }
- }
- }
- return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : target;
- };
- };
- module.exports = {
- // `Array.prototype.forEach` method
- // https://tc39.es/ecma262/#sec-array.prototype.foreach
- forEach: createMethod(0),
- // `Array.prototype.map` method
- // https://tc39.es/ecma262/#sec-array.prototype.map
- map: createMethod(1),
- // `Array.prototype.filter` method
- // https://tc39.es/ecma262/#sec-array.prototype.filter
- filter: createMethod(2),
- // `Array.prototype.some` method
- // https://tc39.es/ecma262/#sec-array.prototype.some
- some: createMethod(3),
- // `Array.prototype.every` method
- // https://tc39.es/ecma262/#sec-array.prototype.every
- every: createMethod(4),
- // `Array.prototype.find` method
- // https://tc39.es/ecma262/#sec-array.prototype.find
- find: createMethod(5),
- // `Array.prototype.findIndex` method
- // https://tc39.es/ecma262/#sec-array.prototype.findIndex
- findIndex: createMethod(6),
- // `Array.prototype.filterReject` method
- // https://github.com/tc39/proposal-array-filtering
- filterReject: createMethod(7)
- };
- },{"../internals/array-species-create":439,"../internals/function-bind-context":480,"../internals/function-uncurry-this":485,"../internals/indexed-object":497,"../internals/length-of-array-like":517,"../internals/to-object":575}],432:[function(_dereq_,module,exports){
- var fails = _dereq_('../internals/fails');
- var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
- var V8_VERSION = _dereq_('../internals/engine-v8-version');
- var SPECIES = wellKnownSymbol('species');
- module.exports = function (METHOD_NAME) {
- // We can't use this feature detection in V8 since it causes
- // deoptimization and serious performance degradation
- // https://github.com/zloirock/core-js/issues/677
- return V8_VERSION >= 51 || !fails(function () {
- var array = [];
- var constructor = array.constructor = {};
- constructor[SPECIES] = function () {
- return { foo: 1 };
- };
- return array[METHOD_NAME](Boolean).foo !== 1;
- });
- };
- },{"../internals/engine-v8-version":471,"../internals/fails":477,"../internals/well-known-symbol":586}],433:[function(_dereq_,module,exports){
- 'use strict';
- var fails = _dereq_('../internals/fails');
- module.exports = function (METHOD_NAME, argument) {
- var method = [][METHOD_NAME];
- return !!method && fails(function () {
- // eslint-disable-next-line no-useless-call,no-throw-literal -- required for testing
- method.call(null, argument || function () { throw 1; }, 1);
- });
- };
- },{"../internals/fails":477}],434:[function(_dereq_,module,exports){
- var global = _dereq_('../internals/global');
- var aCallable = _dereq_('../internals/a-callable');
- var toObject = _dereq_('../internals/to-object');
- var IndexedObject = _dereq_('../internals/indexed-object');
- var lengthOfArrayLike = _dereq_('../internals/length-of-array-like');
- var TypeError = global.TypeError;
- // `Array.prototype.{ reduce, reduceRight }` methods implementation
- var createMethod = function (IS_RIGHT) {
- return function (that, callbackfn, argumentsLength, memo) {
- aCallable(callbackfn);
- var O = toObject(that);
- var self = IndexedObject(O);
- var length = lengthOfArrayLike(O);
- var index = IS_RIGHT ? length - 1 : 0;
- var i = IS_RIGHT ? -1 : 1;
- if (argumentsLength < 2) while (true) {
- if (index in self) {
- memo = self[index];
- index += i;
- break;
- }
- index += i;
- if (IS_RIGHT ? index < 0 : length <= index) {
- throw TypeError('Reduce of empty array with no initial value');
- }
- }
- for (;IS_RIGHT ? index >= 0 : length > index; index += i) if (index in self) {
- memo = callbackfn(memo, self[index], index, O);
- }
- return memo;
- };
- };
- module.exports = {
- // `Array.prototype.reduce` method
- // https://tc39.es/ecma262/#sec-array.prototype.reduce
- left: createMethod(false),
- // `Array.prototype.reduceRight` method
- // https://tc39.es/ecma262/#sec-array.prototype.reduceright
- right: createMethod(true)
- };
- },{"../internals/a-callable":421,"../internals/global":491,"../internals/indexed-object":497,"../internals/length-of-array-like":517,"../internals/to-object":575}],435:[function(_dereq_,module,exports){
- var global = _dereq_('../internals/global');
- var toAbsoluteIndex = _dereq_('../internals/to-absolute-index');
- var lengthOfArrayLike = _dereq_('../internals/length-of-array-like');
- var createProperty = _dereq_('../internals/create-property');
- var Array = global.Array;
- var max = Math.max;
- module.exports = function (O, start, end) {
- var length = lengthOfArrayLike(O);
- var k = toAbsoluteIndex(start, length);
- var fin = toAbsoluteIndex(end === undefined ? length : end, length);
- var result = Array(max(fin - k, 0));
- for (var n = 0; k < fin; k++, n++) createProperty(result, n, O[k]);
- result.length = n;
- return result;
- };
- },{"../internals/create-property":457,"../internals/global":491,"../internals/length-of-array-like":517,"../internals/to-absolute-index":571}],436:[function(_dereq_,module,exports){
- var uncurryThis = _dereq_('../internals/function-uncurry-this');
- module.exports = uncurryThis([].slice);
- },{"../internals/function-uncurry-this":485}],437:[function(_dereq_,module,exports){
- var arraySlice = _dereq_('../internals/array-slice-simple');
- var floor = Math.floor;
- var mergeSort = function (array, comparefn) {
- var length = array.length;
- var middle = floor(length / 2);
- return length < 8 ? insertionSort(array, comparefn) : merge(
- array,
- mergeSort(arraySlice(array, 0, middle), comparefn),
- mergeSort(arraySlice(array, middle), comparefn),
- comparefn
- );
- };
- var insertionSort = function (array, comparefn) {
- var length = array.length;
- var i = 1;
- var element, j;
- while (i < length) {
- j = i;
- element = array[i];
- while (j && comparefn(array[j - 1], element) > 0) {
- array[j] = array[--j];
- }
- if (j !== i++) array[j] = element;
- } return array;
- };
- var merge = function (array, left, right, comparefn) {
- var llength = left.length;
- var rlength = right.length;
- var lindex = 0;
- var rindex = 0;
- while (lindex < llength || rindex < rlength) {
- array[lindex + rindex] = (lindex < llength && rindex < rlength)
- ? comparefn(left[lindex], right[rindex]) <= 0 ? left[lindex++] : right[rindex++]
- : lindex < llength ? left[lindex++] : right[rindex++];
- } return array;
- };
- module.exports = mergeSort;
- },{"../internals/array-slice-simple":435}],438:[function(_dereq_,module,exports){
- var global = _dereq_('../internals/global');
- var isArray = _dereq_('../internals/is-array');
- var isConstructor = _dereq_('../internals/is-constructor');
- var isObject = _dereq_('../internals/is-object');
- var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
- var SPECIES = wellKnownSymbol('species');
- var Array = global.Array;
- // a part of `ArraySpeciesCreate` abstract operation
- // https://tc39.es/ecma262/#sec-arrayspeciescreate
- module.exports = function (originalArray) {
- var C;
- if (isArray(originalArray)) {
- C = originalArray.constructor;
- // cross-realm fallback
- if (isConstructor(C) && (C === Array || isArray(C.prototype))) C = undefined;
- else if (isObject(C)) {
- C = C[SPECIES];
- if (C === null) C = undefined;
- }
- } return C === undefined ? Array : C;
- };
- },{"../internals/global":491,"../internals/is-array":503,"../internals/is-constructor":505,"../internals/is-object":509,"../internals/well-known-symbol":586}],439:[function(_dereq_,module,exports){
- var arraySpeciesConstructor = _dereq_('../internals/array-species-constructor');
- // `ArraySpeciesCreate` abstract operation
- // https://tc39.es/ecma262/#sec-arrayspeciescreate
- module.exports = function (originalArray, length) {
- return new (arraySpeciesConstructor(originalArray))(length === 0 ? 0 : length);
- };
- },{"../internals/array-species-constructor":438}],440:[function(_dereq_,module,exports){
- var anObject = _dereq_('../internals/an-object');
- var iteratorClose = _dereq_('../internals/iterator-close');
- // call something on iterator step with safe closing on error
- module.exports = function (iterator, fn, value, ENTRIES) {
- try {
- return ENTRIES ? fn(anObject(value)[0], value[1]) : fn(value);
- } catch (error) {
- iteratorClose(iterator, 'throw', error);
- }
- };
- },{"../internals/an-object":426,"../internals/iterator-close":514}],441:[function(_dereq_,module,exports){
- var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
- var ITERATOR = wellKnownSymbol('iterator');
- var SAFE_CLOSING = false;
- try {
- var called = 0;
- var iteratorWithReturn = {
- next: function () {
- return { done: !!called++ };
- },
- 'return': function () {
- SAFE_CLOSING = true;
- }
- };
- iteratorWithReturn[ITERATOR] = function () {
- return this;
- };
- // eslint-disable-next-line es/no-array-from, no-throw-literal -- required for testing
- Array.from(iteratorWithReturn, function () { throw 2; });
- } catch (error) { /* empty */ }
- module.exports = function (exec, SKIP_CLOSING) {
- if (!SKIP_CLOSING && !SAFE_CLOSING) return false;
- var ITERATION_SUPPORT = false;
- try {
- var object = {};
- object[ITERATOR] = function () {
- return {
- next: function () {
- return { done: ITERATION_SUPPORT = true };
- }
- };
- };
- exec(object);
- } catch (error) { /* empty */ }
- return ITERATION_SUPPORT;
- };
- },{"../internals/well-known-symbol":586}],442:[function(_dereq_,module,exports){
- var uncurryThis = _dereq_('../internals/function-uncurry-this');
- var toString = uncurryThis({}.toString);
- var stringSlice = uncurryThis(''.slice);
- module.exports = function (it) {
- return stringSlice(toString(it), 8, -1);
- };
- },{"../internals/function-uncurry-this":485}],443:[function(_dereq_,module,exports){
- var global = _dereq_('../internals/global');
- var TO_STRING_TAG_SUPPORT = _dereq_('../internals/to-string-tag-support');
- var isCallable = _dereq_('../internals/is-callable');
- var classofRaw = _dereq_('../internals/classof-raw');
- var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
- var TO_STRING_TAG = wellKnownSymbol('toStringTag');
- var Object = global.Object;
- // ES3 wrong here
- var CORRECT_ARGUMENTS = classofRaw(function () { return arguments; }()) == 'Arguments';
- // fallback for IE11 Script Access Denied error
- var tryGet = function (it, key) {
- try {
- return it[key];
- } catch (error) { /* empty */ }
- };
- // getting tag from ES6+ `Object.prototype.toString`
- module.exports = TO_STRING_TAG_SUPPORT ? classofRaw : function (it) {
- var O, tag, result;
- return it === undefined ? 'Undefined' : it === null ? 'Null'
- // @@toStringTag case
- : typeof (tag = tryGet(O = Object(it), TO_STRING_TAG)) == 'string' ? tag
- // builtinTag case
- : CORRECT_ARGUMENTS ? classofRaw(O)
- // ES3 arguments fallback
- : (result = classofRaw(O)) == 'Object' && isCallable(O.callee) ? 'Arguments' : result;
- };
- },{"../internals/classof-raw":442,"../internals/global":491,"../internals/is-callable":504,"../internals/to-string-tag-support":578,"../internals/well-known-symbol":586}],444:[function(_dereq_,module,exports){
- var uncurryThis = _dereq_('../internals/function-uncurry-this');
- var replace = uncurryThis(''.replace);
- var TEST = (function (arg) { return String(Error(arg).stack); })('zxcasd');
- var V8_OR_CHAKRA_STACK_ENTRY = /\n\s*at [^:]*:[^\n]*/;
- var IS_V8_OR_CHAKRA_STACK = V8_OR_CHAKRA_STACK_ENTRY.test(TEST);
- module.exports = function (stack, dropEntries) {
- if (IS_V8_OR_CHAKRA_STACK && typeof stack == 'string') {
- while (dropEntries--) stack = replace(stack, V8_OR_CHAKRA_STACK_ENTRY, '');
- } return stack;
- };
- },{"../internals/function-uncurry-this":485}],445:[function(_dereq_,module,exports){
- 'use strict';
- var call = _dereq_('../internals/function-call');
- var aCallable = _dereq_('../internals/a-callable');
- var anObject = _dereq_('../internals/an-object');
- // https://github.com/tc39/collection-methods
- module.exports = function deleteAll(/* ...elements */) {
- var collection = anObject(this);
- var remover = aCallable(collection['delete']);
- var allDeleted = true;
- var wasDeleted;
- for (var k = 0, len = arguments.length; k < len; k++) {
- wasDeleted = call(remover, collection, arguments[k]);
- allDeleted = allDeleted && wasDeleted;
- }
- return !!allDeleted;
- };
- },{"../internals/a-callable":421,"../internals/an-object":426,"../internals/function-call":483}],446:[function(_dereq_,module,exports){
- 'use strict';
- // https://tc39.github.io/proposal-setmap-offrom/
- var bind = _dereq_('../internals/function-bind-context');
- var call = _dereq_('../internals/function-call');
- var aCallable = _dereq_('../internals/a-callable');
- var aConstructor = _dereq_('../internals/a-constructor');
- var iterate = _dereq_('../internals/iterate');
- var push = [].push;
- module.exports = function from(source /* , mapFn, thisArg */) {
- var length = arguments.length;
- var mapFn = length > 1 ? arguments[1] : undefined;
- var mapping, array, n, boundFunction;
- aConstructor(this);
- mapping = mapFn !== undefined;
- if (mapping) aCallable(mapFn);
- if (source == undefined) return new this();
- array = [];
- if (mapping) {
- n = 0;
- boundFunction = bind(mapFn, length > 2 ? arguments[2] : undefined);
- iterate(source, function (nextItem) {
- call(push, array, boundFunction(nextItem, n++));
- });
- } else {
- iterate(source, push, { that: array });
- }
- return new this(array);
- };
- },{"../internals/a-callable":421,"../internals/a-constructor":422,"../internals/function-bind-context":480,"../internals/function-call":483,"../internals/iterate":513}],447:[function(_dereq_,module,exports){
- 'use strict';
- var arraySlice = _dereq_('../internals/array-slice');
- // https://tc39.github.io/proposal-setmap-offrom/
- module.exports = function of() {
- return new this(arraySlice(arguments));
- };
- },{"../internals/array-slice":436}],448:[function(_dereq_,module,exports){
- 'use strict';
- var defineProperty = _dereq_('../internals/object-define-property').f;
- var create = _dereq_('../internals/object-create');
- var redefineAll = _dereq_('../internals/redefine-all');
- var bind = _dereq_('../internals/function-bind-context');
- var anInstance = _dereq_('../internals/an-instance');
- var iterate = _dereq_('../internals/iterate');
- var defineIterator = _dereq_('../internals/define-iterator');
- var setSpecies = _dereq_('../internals/set-species');
- var DESCRIPTORS = _dereq_('../internals/descriptors');
- var fastKey = _dereq_('../internals/internal-metadata').fastKey;
- var InternalStateModule = _dereq_('../internals/internal-state');
- var setInternalState = InternalStateModule.set;
- var internalStateGetterFor = InternalStateModule.getterFor;
- module.exports = {
- getConstructor: function (wrapper, CONSTRUCTOR_NAME, IS_MAP, ADDER) {
- var Constructor = wrapper(function (that, iterable) {
- anInstance(that, Prototype);
- setInternalState(that, {
- type: CONSTRUCTOR_NAME,
- index: create(null),
- first: undefined,
- last: undefined,
- size: 0
- });
- if (!DESCRIPTORS) that.size = 0;
- if (iterable != undefined) iterate(iterable, that[ADDER], { that: that, AS_ENTRIES: IS_MAP });
- });
- var Prototype = Constructor.prototype;
- var getInternalState = internalStateGetterFor(CONSTRUCTOR_NAME);
- var define = function (that, key, value) {
- var state = getInternalState(that);
- var entry = getEntry(that, key);
- var previous, index;
- // change existing entry
- if (entry) {
- entry.value = value;
- // create new entry
- } else {
- state.last = entry = {
- index: index = fastKey(key, true),
- key: key,
- value: value,
- previous: previous = state.last,
- next: undefined,
- removed: false
- };
- if (!state.first) state.first = entry;
- if (previous) previous.next = entry;
- if (DESCRIPTORS) state.size++;
- else that.size++;
- // add to index
- if (index !== 'F') state.index[index] = entry;
- } return that;
- };
- var getEntry = function (that, key) {
- var state = getInternalState(that);
- // fast case
- var index = fastKey(key);
- var entry;
- if (index !== 'F') return state.index[index];
- // frozen object case
- for (entry = state.first; entry; entry = entry.next) {
- if (entry.key == key) return entry;
- }
- };
- redefineAll(Prototype, {
- // `{ Map, Set }.prototype.clear()` methods
- // https://tc39.es/ecma262/#sec-map.prototype.clear
- // https://tc39.es/ecma262/#sec-set.prototype.clear
- clear: function clear() {
- var that = this;
- var state = getInternalState(that);
- var data = state.index;
- var entry = state.first;
- while (entry) {
- entry.removed = true;
- if (entry.previous) entry.previous = entry.previous.next = undefined;
- delete data[entry.index];
- entry = entry.next;
- }
- state.first = state.last = undefined;
- if (DESCRIPTORS) state.size = 0;
- else that.size = 0;
- },
- // `{ Map, Set }.prototype.delete(key)` methods
- // https://tc39.es/ecma262/#sec-map.prototype.delete
- // https://tc39.es/ecma262/#sec-set.prototype.delete
- 'delete': function (key) {
- var that = this;
- var state = getInternalState(that);
- var entry = getEntry(that, key);
- if (entry) {
- var next = entry.next;
- var prev = entry.previous;
- delete state.index[entry.index];
- entry.removed = true;
- if (prev) prev.next = next;
- if (next) next.previous = prev;
- if (state.first == entry) state.first = next;
- if (state.last == entry) state.last = prev;
- if (DESCRIPTORS) state.size--;
- else that.size--;
- } return !!entry;
- },
- // `{ Map, Set }.prototype.forEach(callbackfn, thisArg = undefined)` methods
- // https://tc39.es/ecma262/#sec-map.prototype.foreach
- // https://tc39.es/ecma262/#sec-set.prototype.foreach
- forEach: function forEach(callbackfn /* , that = undefined */) {
- var state = getInternalState(this);
- var boundFunction = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined);
- var entry;
- while (entry = entry ? entry.next : state.first) {
- boundFunction(entry.value, entry.key, this);
- // revert to the last existing entry
- while (entry && entry.removed) entry = entry.previous;
- }
- },
- // `{ Map, Set}.prototype.has(key)` methods
- // https://tc39.es/ecma262/#sec-map.prototype.has
- // https://tc39.es/ecma262/#sec-set.prototype.has
- has: function has(key) {
- return !!getEntry(this, key);
- }
- });
- redefineAll(Prototype, IS_MAP ? {
- // `Map.prototype.get(key)` method
- // https://tc39.es/ecma262/#sec-map.prototype.get
- get: function get(key) {
- var entry = getEntry(this, key);
- return entry && entry.value;
- },
- // `Map.prototype.set(key, value)` method
- // https://tc39.es/ecma262/#sec-map.prototype.set
- set: function set(key, value) {
- return define(this, key === 0 ? 0 : key, value);
- }
- } : {
- // `Set.prototype.add(value)` method
- // https://tc39.es/ecma262/#sec-set.prototype.add
- add: function add(value) {
- return define(this, value = value === 0 ? 0 : value, value);
- }
- });
- if (DESCRIPTORS) defineProperty(Prototype, 'size', {
- get: function () {
- return getInternalState(this).size;
- }
- });
- return Constructor;
- },
- setStrong: function (Constructor, CONSTRUCTOR_NAME, IS_MAP) {
- var ITERATOR_NAME = CONSTRUCTOR_NAME + ' Iterator';
- var getInternalCollectionState = internalStateGetterFor(CONSTRUCTOR_NAME);
- var getInternalIteratorState = internalStateGetterFor(ITERATOR_NAME);
- // `{ Map, Set }.prototype.{ keys, values, entries, @@iterator }()` methods
- // https://tc39.es/ecma262/#sec-map.prototype.entries
- // https://tc39.es/ecma262/#sec-map.prototype.keys
- // https://tc39.es/ecma262/#sec-map.prototype.values
- // https://tc39.es/ecma262/#sec-map.prototype-@@iterator
- // https://tc39.es/ecma262/#sec-set.prototype.entries
- // https://tc39.es/ecma262/#sec-set.prototype.keys
- // https://tc39.es/ecma262/#sec-set.prototype.values
- // https://tc39.es/ecma262/#sec-set.prototype-@@iterator
- defineIterator(Constructor, CONSTRUCTOR_NAME, function (iterated, kind) {
- setInternalState(this, {
- type: ITERATOR_NAME,
- target: iterated,
- state: getInternalCollectionState(iterated),
- kind: kind,
- last: undefined
- });
- }, function () {
- var state = getInternalIteratorState(this);
- var kind = state.kind;
- var entry = state.last;
- // revert to the last existing entry
- while (entry && entry.removed) entry = entry.previous;
- // get next entry
- if (!state.target || !(state.last = entry = entry ? entry.next : state.state.first)) {
- // or finish the iteration
- state.target = undefined;
- return { value: undefined, done: true };
- }
- // return step by kind
- if (kind == 'keys') return { value: entry.key, done: false };
- if (kind == 'values') return { value: entry.value, done: false };
- return { value: [entry.key, entry.value], done: false };
- }, IS_MAP ? 'entries' : 'values', !IS_MAP, true);
- // `{ Map, Set }.prototype[@@species]` accessors
- // https://tc39.es/ecma262/#sec-get-map-@@species
- // https://tc39.es/ecma262/#sec-get-set-@@species
- setSpecies(CONSTRUCTOR_NAME);
- }
- };
- },{"../internals/an-instance":425,"../internals/define-iterator":458,"../internals/descriptors":460,"../internals/function-bind-context":480,"../internals/internal-metadata":500,"../internals/internal-state":501,"../internals/iterate":513,"../internals/object-create":530,"../internals/object-define-property":532,"../internals/redefine-all":552,"../internals/set-species":557}],449:[function(_dereq_,module,exports){
- 'use strict';
- var uncurryThis = _dereq_('../internals/function-uncurry-this');
- var redefineAll = _dereq_('../internals/redefine-all');
- var getWeakData = _dereq_('../internals/internal-metadata').getWeakData;
- var anObject = _dereq_('../internals/an-object');
- var isObject = _dereq_('../internals/is-object');
- var anInstance = _dereq_('../internals/an-instance');
- var iterate = _dereq_('../internals/iterate');
- var ArrayIterationModule = _dereq_('../internals/array-iteration');
- var hasOwn = _dereq_('../internals/has-own-property');
- var InternalStateModule = _dereq_('../internals/internal-state');
- var setInternalState = InternalStateModule.set;
- var internalStateGetterFor = InternalStateModule.getterFor;
- var find = ArrayIterationModule.find;
- var findIndex = ArrayIterationModule.findIndex;
- var splice = uncurryThis([].splice);
- var id = 0;
- // fallback for uncaught frozen keys
- var uncaughtFrozenStore = function (store) {
- return store.frozen || (store.frozen = new UncaughtFrozenStore());
- };
- var UncaughtFrozenStore = function () {
- this.entries = [];
- };
- var findUncaughtFrozen = function (store, key) {
- return find(store.entries, function (it) {
- return it[0] === key;
- });
- };
- UncaughtFrozenStore.prototype = {
- get: function (key) {
- var entry = findUncaughtFrozen(this, key);
- if (entry) return entry[1];
- },
- has: function (key) {
- return !!findUncaughtFrozen(this, key);
- },
- set: function (key, value) {
- var entry = findUncaughtFrozen(this, key);
- if (entry) entry[1] = value;
- else this.entries.push([key, value]);
- },
- 'delete': function (key) {
- var index = findIndex(this.entries, function (it) {
- return it[0] === key;
- });
- if (~index) splice(this.entries, index, 1);
- return !!~index;
- }
- };
- module.exports = {
- getConstructor: function (wrapper, CONSTRUCTOR_NAME, IS_MAP, ADDER) {
- var Constructor = wrapper(function (that, iterable) {
- anInstance(that, Prototype);
- setInternalState(that, {
- type: CONSTRUCTOR_NAME,
- id: id++,
- frozen: undefined
- });
- if (iterable != undefined) iterate(iterable, that[ADDER], { that: that, AS_ENTRIES: IS_MAP });
- });
- var Prototype = Constructor.prototype;
- var getInternalState = internalStateGetterFor(CONSTRUCTOR_NAME);
- var define = function (that, key, value) {
- var state = getInternalState(that);
- var data = getWeakData(anObject(key), true);
- if (data === true) uncaughtFrozenStore(state).set(key, value);
- else data[state.id] = value;
- return that;
- };
- redefineAll(Prototype, {
- // `{ WeakMap, WeakSet }.prototype.delete(key)` methods
- // https://tc39.es/ecma262/#sec-weakmap.prototype.delete
- // https://tc39.es/ecma262/#sec-weakset.prototype.delete
- 'delete': function (key) {
- var state = getInternalState(this);
- if (!isObject(key)) return false;
- var data = getWeakData(key);
- if (data === true) return uncaughtFrozenStore(state)['delete'](key);
- return data && hasOwn(data, state.id) && delete data[state.id];
- },
- // `{ WeakMap, WeakSet }.prototype.has(key)` methods
- // https://tc39.es/ecma262/#sec-weakmap.prototype.has
- // https://tc39.es/ecma262/#sec-weakset.prototype.has
- has: function has(key) {
- var state = getInternalState(this);
- if (!isObject(key)) return false;
- var data = getWeakData(key);
- if (data === true) return uncaughtFrozenStore(state).has(key);
- return data && hasOwn(data, state.id);
- }
- });
- redefineAll(Prototype, IS_MAP ? {
- // `WeakMap.prototype.get(key)` method
- // https://tc39.es/ecma262/#sec-weakmap.prototype.get
- get: function get(key) {
- var state = getInternalState(this);
- if (isObject(key)) {
- var data = getWeakData(key);
- if (data === true) return uncaughtFrozenStore(state).get(key);
- return data ? data[state.id] : undefined;
- }
- },
- // `WeakMap.prototype.set(key, value)` method
- // https://tc39.es/ecma262/#sec-weakmap.prototype.set
- set: function set(key, value) {
- return define(this, key, value);
- }
- } : {
- // `WeakSet.prototype.add(value)` method
- // https://tc39.es/ecma262/#sec-weakset.prototype.add
- add: function add(value) {
- return define(this, value, true);
- }
- });
- return Constructor;
- }
- };
- },{"../internals/an-instance":425,"../internals/an-object":426,"../internals/array-iteration":431,"../internals/function-uncurry-this":485,"../internals/has-own-property":492,"../internals/internal-metadata":500,"../internals/internal-state":501,"../internals/is-object":509,"../internals/iterate":513,"../internals/redefine-all":552}],450:[function(_dereq_,module,exports){
- 'use strict';
- var $ = _dereq_('../internals/export');
- var global = _dereq_('../internals/global');
- var InternalMetadataModule = _dereq_('../internals/internal-metadata');
- var fails = _dereq_('../internals/fails');
- var createNonEnumerableProperty = _dereq_('../internals/create-non-enumerable-property');
- var iterate = _dereq_('../internals/iterate');
- var anInstance = _dereq_('../internals/an-instance');
- var isCallable = _dereq_('../internals/is-callable');
- var isObject = _dereq_('../internals/is-object');
- var setToStringTag = _dereq_('../internals/set-to-string-tag');
- var defineProperty = _dereq_('../internals/object-define-property').f;
- var forEach = _dereq_('../internals/array-iteration').forEach;
- var DESCRIPTORS = _dereq_('../internals/descriptors');
- var InternalStateModule = _dereq_('../internals/internal-state');
- var setInternalState = InternalStateModule.set;
- var internalStateGetterFor = InternalStateModule.getterFor;
- module.exports = function (CONSTRUCTOR_NAME, wrapper, common) {
- var IS_MAP = CONSTRUCTOR_NAME.indexOf('Map') !== -1;
- var IS_WEAK = CONSTRUCTOR_NAME.indexOf('Weak') !== -1;
- var ADDER = IS_MAP ? 'set' : 'add';
- var NativeConstructor = global[CONSTRUCTOR_NAME];
- var NativePrototype = NativeConstructor && NativeConstructor.prototype;
- var exported = {};
- var Constructor;
- if (!DESCRIPTORS || !isCallable(NativeConstructor)
- || !(IS_WEAK || NativePrototype.forEach && !fails(function () { new NativeConstructor().entries().next(); }))
- ) {
- // create collection constructor
- Constructor = common.getConstructor(wrapper, CONSTRUCTOR_NAME, IS_MAP, ADDER);
- InternalMetadataModule.enable();
- } else {
- Constructor = wrapper(function (target, iterable) {
- setInternalState(anInstance(target, Prototype), {
- type: CONSTRUCTOR_NAME,
- collection: new NativeConstructor()
- });
- if (iterable != undefined) iterate(iterable, target[ADDER], { that: target, AS_ENTRIES: IS_MAP });
- });
- var Prototype = Constructor.prototype;
- var getInternalState = internalStateGetterFor(CONSTRUCTOR_NAME);
- forEach(['add', 'clear', 'delete', 'forEach', 'get', 'has', 'set', 'keys', 'values', 'entries'], function (KEY) {
- var IS_ADDER = KEY == 'add' || KEY == 'set';
- if (KEY in NativePrototype && !(IS_WEAK && KEY == 'clear')) {
- createNonEnumerableProperty(Prototype, KEY, function (a, b) {
- var collection = getInternalState(this).collection;
- if (!IS_ADDER && IS_WEAK && !isObject(a)) return KEY == 'get' ? undefined : false;
- var result = collection[KEY](a === 0 ? 0 : a, b);
- return IS_ADDER ? this : result;
- });
- }
- });
- IS_WEAK || defineProperty(Prototype, 'size', {
- configurable: true,
- get: function () {
- return getInternalState(this).collection.size;
- }
- });
- }
- setToStringTag(Constructor, CONSTRUCTOR_NAME, false, true);
- exported[CONSTRUCTOR_NAME] = Constructor;
- $({ global: true, forced: true }, exported);
- if (!IS_WEAK) common.setStrong(Constructor, CONSTRUCTOR_NAME, IS_MAP);
- return Constructor;
- };
- },{"../internals/an-instance":425,"../internals/array-iteration":431,"../internals/create-non-enumerable-property":455,"../internals/descriptors":460,"../internals/export":476,"../internals/fails":477,"../internals/global":491,"../internals/internal-metadata":500,"../internals/internal-state":501,"../internals/is-callable":504,"../internals/is-object":509,"../internals/iterate":513,"../internals/object-define-property":532,"../internals/set-to-string-tag":558}],451:[function(_dereq_,module,exports){
- var hasOwn = _dereq_('../internals/has-own-property');
- var ownKeys = _dereq_('../internals/own-keys');
- var getOwnPropertyDescriptorModule = _dereq_('../internals/object-get-own-property-descriptor');
- var definePropertyModule = _dereq_('../internals/object-define-property');
- module.exports = function (target, source, exceptions) {
- var keys = ownKeys(source);
- var defineProperty = definePropertyModule.f;
- var getOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;
- for (var i = 0; i < keys.length; i++) {
- var key = keys[i];
- if (!hasOwn(target, key) && !(exceptions && hasOwn(exceptions, key))) {
- defineProperty(target, key, getOwnPropertyDescriptor(source, key));
- }
- }
- };
- },{"../internals/has-own-property":492,"../internals/object-define-property":532,"../internals/object-get-own-property-descriptor":533,"../internals/own-keys":547}],452:[function(_dereq_,module,exports){
- var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
- var MATCH = wellKnownSymbol('match');
- module.exports = function (METHOD_NAME) {
- var regexp = /./;
- try {
- '/./'[METHOD_NAME](regexp);
- } catch (error1) {
- try {
- regexp[MATCH] = false;
- return '/./'[METHOD_NAME](regexp);
- } catch (error2) { /* empty */ }
- } return false;
- };
- },{"../internals/well-known-symbol":586}],453:[function(_dereq_,module,exports){
- var fails = _dereq_('../internals/fails');
- module.exports = !fails(function () {
- function F() { /* empty */ }
- F.prototype.constructor = null;
- // eslint-disable-next-line es/no-object-getprototypeof -- required for testing
- return Object.getPrototypeOf(new F()) !== F.prototype;
- });
- },{"../internals/fails":477}],454:[function(_dereq_,module,exports){
- 'use strict';
- var IteratorPrototype = _dereq_('../internals/iterators-core').IteratorPrototype;
- var create = _dereq_('../internals/object-create');
- var createPropertyDescriptor = _dereq_('../internals/create-property-descriptor');
- var setToStringTag = _dereq_('../internals/set-to-string-tag');
- var Iterators = _dereq_('../internals/iterators');
- var returnThis = function () { return this; };
- module.exports = function (IteratorConstructor, NAME, next, ENUMERABLE_NEXT) {
- var TO_STRING_TAG = NAME + ' Iterator';
- IteratorConstructor.prototype = create(IteratorPrototype, { next: createPropertyDescriptor(+!ENUMERABLE_NEXT, next) });
- setToStringTag(IteratorConstructor, TO_STRING_TAG, false, true);
- Iterators[TO_STRING_TAG] = returnThis;
- return IteratorConstructor;
- };
- },{"../internals/create-property-descriptor":456,"../internals/iterators":516,"../internals/iterators-core":515,"../internals/object-create":530,"../internals/set-to-string-tag":558}],455:[function(_dereq_,module,exports){
- var DESCRIPTORS = _dereq_('../internals/descriptors');
- var definePropertyModule = _dereq_('../internals/object-define-property');
- var createPropertyDescriptor = _dereq_('../internals/create-property-descriptor');
- module.exports = DESCRIPTORS ? function (object, key, value) {
- return definePropertyModule.f(object, key, createPropertyDescriptor(1, value));
- } : function (object, key, value) {
- object[key] = value;
- return object;
- };
- },{"../internals/create-property-descriptor":456,"../internals/descriptors":460,"../internals/object-define-property":532}],456:[function(_dereq_,module,exports){
- module.exports = function (bitmap, value) {
- return {
- enumerable: !(bitmap & 1),
- configurable: !(bitmap & 2),
- writable: !(bitmap & 4),
- value: value
- };
- };
- },{}],457:[function(_dereq_,module,exports){
- 'use strict';
- var toPropertyKey = _dereq_('../internals/to-property-key');
- var definePropertyModule = _dereq_('../internals/object-define-property');
- var createPropertyDescriptor = _dereq_('../internals/create-property-descriptor');
- module.exports = function (object, key, value) {
- var propertyKey = toPropertyKey(key);
- if (propertyKey in object) definePropertyModule.f(object, propertyKey, createPropertyDescriptor(0, value));
- else object[propertyKey] = value;
- };
- },{"../internals/create-property-descriptor":456,"../internals/object-define-property":532,"../internals/to-property-key":577}],458:[function(_dereq_,module,exports){
- 'use strict';
- var $ = _dereq_('../internals/export');
- var call = _dereq_('../internals/function-call');
- var IS_PURE = _dereq_('../internals/is-pure');
- var FunctionName = _dereq_('../internals/function-name');
- var isCallable = _dereq_('../internals/is-callable');
- var createIteratorConstructor = _dereq_('../internals/create-iterator-constructor');
- var getPrototypeOf = _dereq_('../internals/object-get-prototype-of');
- var setPrototypeOf = _dereq_('../internals/object-set-prototype-of');
- var setToStringTag = _dereq_('../internals/set-to-string-tag');
- var createNonEnumerableProperty = _dereq_('../internals/create-non-enumerable-property');
- var redefine = _dereq_('../internals/redefine');
- var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
- var Iterators = _dereq_('../internals/iterators');
- var IteratorsCore = _dereq_('../internals/iterators-core');
- var PROPER_FUNCTION_NAME = FunctionName.PROPER;
- var CONFIGURABLE_FUNCTION_NAME = FunctionName.CONFIGURABLE;
- var IteratorPrototype = IteratorsCore.IteratorPrototype;
- var BUGGY_SAFARI_ITERATORS = IteratorsCore.BUGGY_SAFARI_ITERATORS;
- var ITERATOR = wellKnownSymbol('iterator');
- var KEYS = 'keys';
- var VALUES = 'values';
- var ENTRIES = 'entries';
- var returnThis = function () { return this; };
- module.exports = function (Iterable, NAME, IteratorConstructor, next, DEFAULT, IS_SET, FORCED) {
- createIteratorConstructor(IteratorConstructor, NAME, next);
- var getIterationMethod = function (KIND) {
- if (KIND === DEFAULT && defaultIterator) return defaultIterator;
- if (!BUGGY_SAFARI_ITERATORS && KIND in IterablePrototype) return IterablePrototype[KIND];
- switch (KIND) {
- case KEYS: return function keys() { return new IteratorConstructor(this, KIND); };
- case VALUES: return function values() { return new IteratorConstructor(this, KIND); };
- case ENTRIES: return function entries() { return new IteratorConstructor(this, KIND); };
- } return function () { return new IteratorConstructor(this); };
- };
- var TO_STRING_TAG = NAME + ' Iterator';
- var INCORRECT_VALUES_NAME = false;
- var IterablePrototype = Iterable.prototype;
- var nativeIterator = IterablePrototype[ITERATOR]
- || IterablePrototype['@@iterator']
- || DEFAULT && IterablePrototype[DEFAULT];
- var defaultIterator = !BUGGY_SAFARI_ITERATORS && nativeIterator || getIterationMethod(DEFAULT);
- var anyNativeIterator = NAME == 'Array' ? IterablePrototype.entries || nativeIterator : nativeIterator;
- var CurrentIteratorPrototype, methods, KEY;
- // fix native
- if (anyNativeIterator) {
- CurrentIteratorPrototype = getPrototypeOf(anyNativeIterator.call(new Iterable()));
- if (CurrentIteratorPrototype !== Object.prototype && CurrentIteratorPrototype.next) {
- if (!IS_PURE && getPrototypeOf(CurrentIteratorPrototype) !== IteratorPrototype) {
- if (setPrototypeOf) {
- setPrototypeOf(CurrentIteratorPrototype, IteratorPrototype);
- } else if (!isCallable(CurrentIteratorPrototype[ITERATOR])) {
- redefine(CurrentIteratorPrototype, ITERATOR, returnThis);
- }
- }
- // Set @@toStringTag to native iterators
- setToStringTag(CurrentIteratorPrototype, TO_STRING_TAG, true, true);
- if (IS_PURE) Iterators[TO_STRING_TAG] = returnThis;
- }
- }
- // fix Array.prototype.{ values, @@iterator }.name in V8 / FF
- if (PROPER_FUNCTION_NAME && DEFAULT == VALUES && nativeIterator && nativeIterator.name !== VALUES) {
- if (!IS_PURE && CONFIGURABLE_FUNCTION_NAME) {
- createNonEnumerableProperty(IterablePrototype, 'name', VALUES);
- } else {
- INCORRECT_VALUES_NAME = true;
- defaultIterator = function values() { return call(nativeIterator, this); };
- }
- }
- // export additional methods
- if (DEFAULT) {
- methods = {
- values: getIterationMethod(VALUES),
- keys: IS_SET ? defaultIterator : getIterationMethod(KEYS),
- entries: getIterationMethod(ENTRIES)
- };
- if (FORCED) for (KEY in methods) {
- if (BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME || !(KEY in IterablePrototype)) {
- redefine(IterablePrototype, KEY, methods[KEY]);
- }
- } else $({ target: NAME, proto: true, forced: BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME }, methods);
- }
- // define iterator
- if ((!IS_PURE || FORCED) && IterablePrototype[ITERATOR] !== defaultIterator) {
- redefine(IterablePrototype, ITERATOR, defaultIterator, { name: DEFAULT });
- }
- Iterators[NAME] = defaultIterator;
- return methods;
- };
- },{"../internals/create-iterator-constructor":454,"../internals/create-non-enumerable-property":455,"../internals/export":476,"../internals/function-call":483,"../internals/function-name":484,"../internals/is-callable":504,"../internals/is-pure":510,"../internals/iterators":516,"../internals/iterators-core":515,"../internals/object-get-prototype-of":537,"../internals/object-set-prototype-of":543,"../internals/redefine":553,"../internals/set-to-string-tag":558,"../internals/well-known-symbol":586}],459:[function(_dereq_,module,exports){
- var path = _dereq_('../internals/path');
- var hasOwn = _dereq_('../internals/has-own-property');
- var wrappedWellKnownSymbolModule = _dereq_('../internals/well-known-symbol-wrapped');
- var defineProperty = _dereq_('../internals/object-define-property').f;
- module.exports = function (NAME) {
- var Symbol = path.Symbol || (path.Symbol = {});
- if (!hasOwn(Symbol, NAME)) defineProperty(Symbol, NAME, {
- value: wrappedWellKnownSymbolModule.f(NAME)
- });
- };
- },{"../internals/has-own-property":492,"../internals/object-define-property":532,"../internals/path":548,"../internals/well-known-symbol-wrapped":585}],460:[function(_dereq_,module,exports){
- var fails = _dereq_('../internals/fails');
- // Detect IE8's incomplete defineProperty implementation
- module.exports = !fails(function () {
- // eslint-disable-next-line es/no-object-defineproperty -- required for testing
- return Object.defineProperty({}, 1, { get: function () { return 7; } })[1] != 7;
- });
- },{"../internals/fails":477}],461:[function(_dereq_,module,exports){
- var global = _dereq_('../internals/global');
- var isObject = _dereq_('../internals/is-object');
- var document = global.document;
- // typeof document.createElement is 'object' in old IE
- var EXISTS = isObject(document) && isObject(document.createElement);
- module.exports = function (it) {
- return EXISTS ? document.createElement(it) : {};
- };
- },{"../internals/global":491,"../internals/is-object":509}],462:[function(_dereq_,module,exports){
- // iterable DOM collections
- // flag - `iterable` interface - 'entries', 'keys', 'values', 'forEach' methods
- module.exports = {
- CSSRuleList: 0,
- CSSStyleDeclaration: 0,
- CSSValueList: 0,
- ClientRectList: 0,
- DOMRectList: 0,
- DOMStringList: 0,
- DOMTokenList: 1,
- DataTransferItemList: 0,
- FileList: 0,
- HTMLAllCollection: 0,
- HTMLCollection: 0,
- HTMLFormElement: 0,
- HTMLSelectElement: 0,
- MediaList: 0,
- MimeTypeArray: 0,
- NamedNodeMap: 0,
- NodeList: 1,
- PaintRequestList: 0,
- Plugin: 0,
- PluginArray: 0,
- SVGLengthList: 0,
- SVGNumberList: 0,
- SVGPathSegList: 0,
- SVGPointList: 0,
- SVGStringList: 0,
- SVGTransformList: 0,
- SourceBufferList: 0,
- StyleSheetList: 0,
- TextTrackCueList: 0,
- TextTrackList: 0,
- TouchList: 0
- };
- },{}],463:[function(_dereq_,module,exports){
- var userAgent = _dereq_('../internals/engine-user-agent');
- var firefox = userAgent.match(/firefox\/(\d+)/i);
- module.exports = !!firefox && +firefox[1];
- },{"../internals/engine-user-agent":470}],464:[function(_dereq_,module,exports){
- module.exports = typeof window == 'object';
- },{}],465:[function(_dereq_,module,exports){
- var UA = _dereq_('../internals/engine-user-agent');
- module.exports = /MSIE|Trident/.test(UA);
- },{"../internals/engine-user-agent":470}],466:[function(_dereq_,module,exports){
- var userAgent = _dereq_('../internals/engine-user-agent');
- var global = _dereq_('../internals/global');
- module.exports = /ipad|iphone|ipod/i.test(userAgent) && global.Pebble !== undefined;
- },{"../internals/engine-user-agent":470,"../internals/global":491}],467:[function(_dereq_,module,exports){
- var userAgent = _dereq_('../internals/engine-user-agent');
- module.exports = /(?:ipad|iphone|ipod).*applewebkit/i.test(userAgent);
- },{"../internals/engine-user-agent":470}],468:[function(_dereq_,module,exports){
- var classof = _dereq_('../internals/classof-raw');
- var global = _dereq_('../internals/global');
- module.exports = classof(global.process) == 'process';
- },{"../internals/classof-raw":442,"../internals/global":491}],469:[function(_dereq_,module,exports){
- var userAgent = _dereq_('../internals/engine-user-agent');
- module.exports = /web0s(?!.*chrome)/i.test(userAgent);
- },{"../internals/engine-user-agent":470}],470:[function(_dereq_,module,exports){
- var getBuiltIn = _dereq_('../internals/get-built-in');
- module.exports = getBuiltIn('navigator', 'userAgent') || '';
- },{"../internals/get-built-in":486}],471:[function(_dereq_,module,exports){
- var global = _dereq_('../internals/global');
- var userAgent = _dereq_('../internals/engine-user-agent');
- var process = global.process;
- var Deno = global.Deno;
- var versions = process && process.versions || Deno && Deno.version;
- var v8 = versions && versions.v8;
- var match, version;
- if (v8) {
- match = v8.split('.');
- // in old Chrome, versions of V8 isn't V8 = Chrome / 10
- // but their correct versions are not interesting for us
- version = match[0] > 0 && match[0] < 4 ? 1 : +(match[0] + match[1]);
- }
- // BrowserFS NodeJS `process` polyfill incorrectly set `.v8` to `0.0`
- // so check `userAgent` even if `.v8` exists, but 0
- if (!version && userAgent) {
- match = userAgent.match(/Edge\/(\d+)/);
- if (!match || match[1] >= 74) {
- match = userAgent.match(/Chrome\/(\d+)/);
- if (match) version = +match[1];
- }
- }
- module.exports = version;
- },{"../internals/engine-user-agent":470,"../internals/global":491}],472:[function(_dereq_,module,exports){
- var userAgent = _dereq_('../internals/engine-user-agent');
- var webkit = userAgent.match(/AppleWebKit\/(\d+)\./);
- module.exports = !!webkit && +webkit[1];
- },{"../internals/engine-user-agent":470}],473:[function(_dereq_,module,exports){
- var path = _dereq_('../internals/path');
- module.exports = function (CONSTRUCTOR) {
- return path[CONSTRUCTOR + 'Prototype'];
- };
- },{"../internals/path":548}],474:[function(_dereq_,module,exports){
- // IE8- don't enum bug keys
- module.exports = [
- 'constructor',
- 'hasOwnProperty',
- 'isPrototypeOf',
- 'propertyIsEnumerable',
- 'toLocaleString',
- 'toString',
- 'valueOf'
- ];
- },{}],475:[function(_dereq_,module,exports){
- var fails = _dereq_('../internals/fails');
- var createPropertyDescriptor = _dereq_('../internals/create-property-descriptor');
- module.exports = !fails(function () {
- var error = Error('a');
- if (!('stack' in error)) return true;
- // eslint-disable-next-line es/no-object-defineproperty -- safe
- Object.defineProperty(error, 'stack', createPropertyDescriptor(1, 7));
- return error.stack !== 7;
- });
- },{"../internals/create-property-descriptor":456,"../internals/fails":477}],476:[function(_dereq_,module,exports){
- 'use strict';
- var global = _dereq_('../internals/global');
- var apply = _dereq_('../internals/function-apply');
- var uncurryThis = _dereq_('../internals/function-uncurry-this');
- var isCallable = _dereq_('../internals/is-callable');
- var getOwnPropertyDescriptor = _dereq_('../internals/object-get-own-property-descriptor').f;
- var isForced = _dereq_('../internals/is-forced');
- var path = _dereq_('../internals/path');
- var bind = _dereq_('../internals/function-bind-context');
- var createNonEnumerableProperty = _dereq_('../internals/create-non-enumerable-property');
- var hasOwn = _dereq_('../internals/has-own-property');
- var wrapConstructor = function (NativeConstructor) {
- var Wrapper = function (a, b, c) {
- if (this instanceof Wrapper) {
- switch (arguments.length) {
- case 0: return new NativeConstructor();
- case 1: return new NativeConstructor(a);
- case 2: return new NativeConstructor(a, b);
- } return new NativeConstructor(a, b, c);
- } return apply(NativeConstructor, this, arguments);
- };
- Wrapper.prototype = NativeConstructor.prototype;
- return Wrapper;
- };
- /*
- options.target - name of the target object
- options.global - target is the global object
- options.stat - export as static methods of target
- options.proto - export as prototype methods of target
- options.real - real prototype method for the `pure` version
- options.forced - export even if the native feature is available
- options.bind - bind methods to the target, required for the `pure` version
- options.wrap - wrap constructors to preventing global pollution, required for the `pure` version
- options.unsafe - use the simple assignment of property instead of delete + defineProperty
- options.sham - add a flag to not completely full polyfills
- options.enumerable - export as enumerable property
- options.noTargetGet - prevent calling a getter on target
- options.name - the .name of the function if it does not match the key
- */
- module.exports = function (options, source) {
- var TARGET = options.target;
- var GLOBAL = options.global;
- var STATIC = options.stat;
- var PROTO = options.proto;
- var nativeSource = GLOBAL ? global : STATIC ? global[TARGET] : (global[TARGET] || {}).prototype;
- var target = GLOBAL ? path : path[TARGET] || createNonEnumerableProperty(path, TARGET, {})[TARGET];
- var targetPrototype = target.prototype;
- var FORCED, USE_NATIVE, VIRTUAL_PROTOTYPE;
- var key, sourceProperty, targetProperty, nativeProperty, resultProperty, descriptor;
- for (key in source) {
- FORCED = isForced(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced);
- // contains in native
- USE_NATIVE = !FORCED && nativeSource && hasOwn(nativeSource, key);
- targetProperty = target[key];
- if (USE_NATIVE) if (options.noTargetGet) {
- descriptor = getOwnPropertyDescriptor(nativeSource, key);
- nativeProperty = descriptor && descriptor.value;
- } else nativeProperty = nativeSource[key];
- // export native or implementation
- sourceProperty = (USE_NATIVE && nativeProperty) ? nativeProperty : source[key];
- if (USE_NATIVE && typeof targetProperty == typeof sourceProperty) continue;
- // bind timers to global for call from export context
- if (options.bind && USE_NATIVE) resultProperty = bind(sourceProperty, global);
- // wrap global constructors for prevent changs in this version
- else if (options.wrap && USE_NATIVE) resultProperty = wrapConstructor(sourceProperty);
- // make static versions for prototype methods
- else if (PROTO && isCallable(sourceProperty)) resultProperty = uncurryThis(sourceProperty);
- // default case
- else resultProperty = sourceProperty;
- // add a flag to not completely full polyfills
- if (options.sham || (sourceProperty && sourceProperty.sham) || (targetProperty && targetProperty.sham)) {
- createNonEnumerableProperty(resultProperty, 'sham', true);
- }
- createNonEnumerableProperty(target, key, resultProperty);
- if (PROTO) {
- VIRTUAL_PROTOTYPE = TARGET + 'Prototype';
- if (!hasOwn(path, VIRTUAL_PROTOTYPE)) {
- createNonEnumerableProperty(path, VIRTUAL_PROTOTYPE, {});
- }
- // export virtual prototype methods
- createNonEnumerableProperty(path[VIRTUAL_PROTOTYPE], key, sourceProperty);
- // export real prototype methods
- if (options.real && targetPrototype && !targetPrototype[key]) {
- createNonEnumerableProperty(targetPrototype, key, sourceProperty);
- }
- }
- }
- };
- },{"../internals/create-non-enumerable-property":455,"../internals/function-apply":479,"../internals/function-bind-context":480,"../internals/function-uncurry-this":485,"../internals/global":491,"../internals/has-own-property":492,"../internals/is-callable":504,"../internals/is-forced":507,"../internals/object-get-own-property-descriptor":533,"../internals/path":548}],477:[function(_dereq_,module,exports){
- module.exports = function (exec) {
- try {
- return !!exec();
- } catch (error) {
- return true;
- }
- };
- },{}],478:[function(_dereq_,module,exports){
- var fails = _dereq_('../internals/fails');
- module.exports = !fails(function () {
- // eslint-disable-next-line es/no-object-isextensible, es/no-object-preventextensions -- required for testing
- return Object.isExtensible(Object.preventExtensions({}));
- });
- },{"../internals/fails":477}],479:[function(_dereq_,module,exports){
- var NATIVE_BIND = _dereq_('../internals/function-bind-native');
- var FunctionPrototype = Function.prototype;
- var apply = FunctionPrototype.apply;
- var call = FunctionPrototype.call;
- // eslint-disable-next-line es/no-reflect -- safe
- module.exports = typeof Reflect == 'object' && Reflect.apply || (NATIVE_BIND ? call.bind(apply) : function () {
- return call.apply(apply, arguments);
- });
- },{"../internals/function-bind-native":481}],480:[function(_dereq_,module,exports){
- var uncurryThis = _dereq_('../internals/function-uncurry-this');
- var aCallable = _dereq_('../internals/a-callable');
- var NATIVE_BIND = _dereq_('../internals/function-bind-native');
- var bind = uncurryThis(uncurryThis.bind);
- // optional / simple context binding
- module.exports = function (fn, that) {
- aCallable(fn);
- return that === undefined ? fn : NATIVE_BIND ? bind(fn, that) : function (/* ...args */) {
- return fn.apply(that, arguments);
- };
- };
- },{"../internals/a-callable":421,"../internals/function-bind-native":481,"../internals/function-uncurry-this":485}],481:[function(_dereq_,module,exports){
- var fails = _dereq_('../internals/fails');
- module.exports = !fails(function () {
- var test = (function () { /* empty */ }).bind();
- // eslint-disable-next-line no-prototype-builtins -- safe
- return typeof test != 'function' || test.hasOwnProperty('prototype');
- });
- },{"../internals/fails":477}],482:[function(_dereq_,module,exports){
- 'use strict';
- var global = _dereq_('../internals/global');
- var uncurryThis = _dereq_('../internals/function-uncurry-this');
- var aCallable = _dereq_('../internals/a-callable');
- var isObject = _dereq_('../internals/is-object');
- var hasOwn = _dereq_('../internals/has-own-property');
- var arraySlice = _dereq_('../internals/array-slice');
- var NATIVE_BIND = _dereq_('../internals/function-bind-native');
- var Function = global.Function;
- var concat = uncurryThis([].concat);
- var join = uncurryThis([].join);
- var factories = {};
- var construct = function (C, argsLength, args) {
- if (!hasOwn(factories, argsLength)) {
- for (var list = [], i = 0; i < argsLength; i++) list[i] = 'a[' + i + ']';
- factories[argsLength] = Function('C,a', 'return new C(' + join(list, ',') + ')');
- } return factories[argsLength](C, args);
- };
- // `Function.prototype.bind` method implementation
- // https://tc39.es/ecma262/#sec-function.prototype.bind
- module.exports = NATIVE_BIND ? Function.bind : function bind(that /* , ...args */) {
- var F = aCallable(this);
- var Prototype = F.prototype;
- var partArgs = arraySlice(arguments, 1);
- var boundFunction = function bound(/* args... */) {
- var args = concat(partArgs, arraySlice(arguments));
- return this instanceof boundFunction ? construct(F, args.length, args) : F.apply(that, args);
- };
- if (isObject(Prototype)) boundFunction.prototype = Prototype;
- return boundFunction;
- };
- },{"../internals/a-callable":421,"../internals/array-slice":436,"../internals/function-bind-native":481,"../internals/function-uncurry-this":485,"../internals/global":491,"../internals/has-own-property":492,"../internals/is-object":509}],483:[function(_dereq_,module,exports){
- var NATIVE_BIND = _dereq_('../internals/function-bind-native');
- var call = Function.prototype.call;
- module.exports = NATIVE_BIND ? call.bind(call) : function () {
- return call.apply(call, arguments);
- };
- },{"../internals/function-bind-native":481}],484:[function(_dereq_,module,exports){
- var DESCRIPTORS = _dereq_('../internals/descriptors');
- var hasOwn = _dereq_('../internals/has-own-property');
- var FunctionPrototype = Function.prototype;
- // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
- var getDescriptor = DESCRIPTORS && Object.getOwnPropertyDescriptor;
- var EXISTS = hasOwn(FunctionPrototype, 'name');
- // additional protection from minified / mangled / dropped function names
- var PROPER = EXISTS && (function something() { /* empty */ }).name === 'something';
- var CONFIGURABLE = EXISTS && (!DESCRIPTORS || (DESCRIPTORS && getDescriptor(FunctionPrototype, 'name').configurable));
- module.exports = {
- EXISTS: EXISTS,
- PROPER: PROPER,
- CONFIGURABLE: CONFIGURABLE
- };
- },{"../internals/descriptors":460,"../internals/has-own-property":492}],485:[function(_dereq_,module,exports){
- var NATIVE_BIND = _dereq_('../internals/function-bind-native');
- var FunctionPrototype = Function.prototype;
- var bind = FunctionPrototype.bind;
- var call = FunctionPrototype.call;
- var uncurryThis = NATIVE_BIND && bind.bind(call, call);
- module.exports = NATIVE_BIND ? function (fn) {
- return fn && uncurryThis(fn);
- } : function (fn) {
- return fn && function () {
- return call.apply(fn, arguments);
- };
- };
- },{"../internals/function-bind-native":481}],486:[function(_dereq_,module,exports){
- var path = _dereq_('../internals/path');
- var global = _dereq_('../internals/global');
- var isCallable = _dereq_('../internals/is-callable');
- var aFunction = function (variable) {
- return isCallable(variable) ? variable : undefined;
- };
- module.exports = function (namespace, method) {
- return arguments.length < 2 ? aFunction(path[namespace]) || aFunction(global[namespace])
- : path[namespace] && path[namespace][method] || global[namespace] && global[namespace][method];
- };
- },{"../internals/global":491,"../internals/is-callable":504,"../internals/path":548}],487:[function(_dereq_,module,exports){
- var classof = _dereq_('../internals/classof');
- var getMethod = _dereq_('../internals/get-method');
- var Iterators = _dereq_('../internals/iterators');
- var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
- var ITERATOR = wellKnownSymbol('iterator');
- module.exports = function (it) {
- if (it != undefined) return getMethod(it, ITERATOR)
- || getMethod(it, '@@iterator')
- || Iterators[classof(it)];
- };
- },{"../internals/classof":443,"../internals/get-method":490,"../internals/iterators":516,"../internals/well-known-symbol":586}],488:[function(_dereq_,module,exports){
- var global = _dereq_('../internals/global');
- var call = _dereq_('../internals/function-call');
- var aCallable = _dereq_('../internals/a-callable');
- var anObject = _dereq_('../internals/an-object');
- var tryToString = _dereq_('../internals/try-to-string');
- var getIteratorMethod = _dereq_('../internals/get-iterator-method');
- var TypeError = global.TypeError;
- module.exports = function (argument, usingIterator) {
- var iteratorMethod = arguments.length < 2 ? getIteratorMethod(argument) : usingIterator;
- if (aCallable(iteratorMethod)) return anObject(call(iteratorMethod, argument));
- throw TypeError(tryToString(argument) + ' is not iterable');
- };
- },{"../internals/a-callable":421,"../internals/an-object":426,"../internals/function-call":483,"../internals/get-iterator-method":487,"../internals/global":491,"../internals/try-to-string":580}],489:[function(_dereq_,module,exports){
- var getIterator = _dereq_('../internals/get-iterator');
- module.exports = getIterator;
- },{"../internals/get-iterator":488}],490:[function(_dereq_,module,exports){
- var aCallable = _dereq_('../internals/a-callable');
- // `GetMethod` abstract operation
- // https://tc39.es/ecma262/#sec-getmethod
- module.exports = function (V, P) {
- var func = V[P];
- return func == null ? undefined : aCallable(func);
- };
- },{"../internals/a-callable":421}],491:[function(_dereq_,module,exports){
- (function (global){(function (){
- var check = function (it) {
- return it && it.Math == Math && it;
- };
- // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
- module.exports =
- // eslint-disable-next-line es/no-global-this -- safe
- check(typeof globalThis == 'object' && globalThis) ||
- check(typeof window == 'object' && window) ||
- // eslint-disable-next-line no-restricted-globals -- safe
- check(typeof self == 'object' && self) ||
- check(typeof global == 'object' && global) ||
- // eslint-disable-next-line no-new-func -- fallback
- (function () { return this; })() || Function('return this')();
- }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
- },{}],492:[function(_dereq_,module,exports){
- var uncurryThis = _dereq_('../internals/function-uncurry-this');
- var toObject = _dereq_('../internals/to-object');
- var hasOwnProperty = uncurryThis({}.hasOwnProperty);
- // `HasOwnProperty` abstract operation
- // https://tc39.es/ecma262/#sec-hasownproperty
- module.exports = Object.hasOwn || function hasOwn(it, key) {
- return hasOwnProperty(toObject(it), key);
- };
- },{"../internals/function-uncurry-this":485,"../internals/to-object":575}],493:[function(_dereq_,module,exports){
- module.exports = {};
- },{}],494:[function(_dereq_,module,exports){
- var global = _dereq_('../internals/global');
- module.exports = function (a, b) {
- var console = global.console;
- if (console && console.error) {
- arguments.length == 1 ? console.error(a) : console.error(a, b);
- }
- };
- },{"../internals/global":491}],495:[function(_dereq_,module,exports){
- var getBuiltIn = _dereq_('../internals/get-built-in');
- module.exports = getBuiltIn('document', 'documentElement');
- },{"../internals/get-built-in":486}],496:[function(_dereq_,module,exports){
- var DESCRIPTORS = _dereq_('../internals/descriptors');
- var fails = _dereq_('../internals/fails');
- var createElement = _dereq_('../internals/document-create-element');
- // Thanks to IE8 for its funny defineProperty
- module.exports = !DESCRIPTORS && !fails(function () {
- // eslint-disable-next-line es/no-object-defineproperty -- required for testing
- return Object.defineProperty(createElement('div'), 'a', {
- get: function () { return 7; }
- }).a != 7;
- });
- },{"../internals/descriptors":460,"../internals/document-create-element":461,"../internals/fails":477}],497:[function(_dereq_,module,exports){
- var global = _dereq_('../internals/global');
- var uncurryThis = _dereq_('../internals/function-uncurry-this');
- var fails = _dereq_('../internals/fails');
- var classof = _dereq_('../internals/classof-raw');
- var Object = global.Object;
- var split = uncurryThis(''.split);
- // fallback for non-array-like ES3 and non-enumerable old V8 strings
- module.exports = fails(function () {
- // throws an error in rhino, see https://github.com/mozilla/rhino/issues/346
- // eslint-disable-next-line no-prototype-builtins -- safe
- return !Object('z').propertyIsEnumerable(0);
- }) ? function (it) {
- return classof(it) == 'String' ? split(it, '') : Object(it);
- } : Object;
- },{"../internals/classof-raw":442,"../internals/fails":477,"../internals/function-uncurry-this":485,"../internals/global":491}],498:[function(_dereq_,module,exports){
- var uncurryThis = _dereq_('../internals/function-uncurry-this');
- var isCallable = _dereq_('../internals/is-callable');
- var store = _dereq_('../internals/shared-store');
- var functionToString = uncurryThis(Function.toString);
- // this helper broken in `core-js@3.4.1-3.4.4`, so we can't use `shared` helper
- if (!isCallable(store.inspectSource)) {
- store.inspectSource = function (it) {
- return functionToString(it);
- };
- }
- module.exports = store.inspectSource;
- },{"../internals/function-uncurry-this":485,"../internals/is-callable":504,"../internals/shared-store":560}],499:[function(_dereq_,module,exports){
- var isObject = _dereq_('../internals/is-object');
- var createNonEnumerableProperty = _dereq_('../internals/create-non-enumerable-property');
- // `InstallErrorCause` abstract operation
- // https://tc39.es/proposal-error-cause/#sec-errorobjects-install-error-cause
- module.exports = function (O, options) {
- if (isObject(options) && 'cause' in options) {
- createNonEnumerableProperty(O, 'cause', options.cause);
- }
- };
- },{"../internals/create-non-enumerable-property":455,"../internals/is-object":509}],500:[function(_dereq_,module,exports){
- var $ = _dereq_('../internals/export');
- var uncurryThis = _dereq_('../internals/function-uncurry-this');
- var hiddenKeys = _dereq_('../internals/hidden-keys');
- var isObject = _dereq_('../internals/is-object');
- var hasOwn = _dereq_('../internals/has-own-property');
- var defineProperty = _dereq_('../internals/object-define-property').f;
- var getOwnPropertyNamesModule = _dereq_('../internals/object-get-own-property-names');
- var getOwnPropertyNamesExternalModule = _dereq_('../internals/object-get-own-property-names-external');
- var isExtensible = _dereq_('../internals/object-is-extensible');
- var uid = _dereq_('../internals/uid');
- var FREEZING = _dereq_('../internals/freezing');
- var REQUIRED = false;
- var METADATA = uid('meta');
- var id = 0;
- var setMetadata = function (it) {
- defineProperty(it, METADATA, { value: {
- objectID: 'O' + id++, // object ID
- weakData: {} // weak collections IDs
- } });
- };
- var fastKey = function (it, create) {
- // return a primitive with prefix
- if (!isObject(it)) return typeof it == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it;
- if (!hasOwn(it, METADATA)) {
- // can't set metadata to uncaught frozen object
- if (!isExtensible(it)) return 'F';
- // not necessary to add metadata
- if (!create) return 'E';
- // add missing metadata
- setMetadata(it);
- // return object ID
- } return it[METADATA].objectID;
- };
- var getWeakData = function (it, create) {
- if (!hasOwn(it, METADATA)) {
- // can't set metadata to uncaught frozen object
- if (!isExtensible(it)) return true;
- // not necessary to add metadata
- if (!create) return false;
- // add missing metadata
- setMetadata(it);
- // return the store of weak collections IDs
- } return it[METADATA].weakData;
- };
- // add metadata on freeze-family methods calling
- var onFreeze = function (it) {
- if (FREEZING && REQUIRED && isExtensible(it) && !hasOwn(it, METADATA)) setMetadata(it);
- return it;
- };
- var enable = function () {
- meta.enable = function () { /* empty */ };
- REQUIRED = true;
- var getOwnPropertyNames = getOwnPropertyNamesModule.f;
- var splice = uncurryThis([].splice);
- var test = {};
- test[METADATA] = 1;
- // prevent exposing of metadata key
- if (getOwnPropertyNames(test).length) {
- getOwnPropertyNamesModule.f = function (it) {
- var result = getOwnPropertyNames(it);
- for (var i = 0, length = result.length; i < length; i++) {
- if (result[i] === METADATA) {
- splice(result, i, 1);
- break;
- }
- } return result;
- };
- $({ target: 'Object', stat: true, forced: true }, {
- getOwnPropertyNames: getOwnPropertyNamesExternalModule.f
- });
- }
- };
- var meta = module.exports = {
- enable: enable,
- fastKey: fastKey,
- getWeakData: getWeakData,
- onFreeze: onFreeze
- };
- hiddenKeys[METADATA] = true;
- },{"../internals/export":476,"../internals/freezing":478,"../internals/function-uncurry-this":485,"../internals/has-own-property":492,"../internals/hidden-keys":493,"../internals/is-object":509,"../internals/object-define-property":532,"../internals/object-get-own-property-names":535,"../internals/object-get-own-property-names-external":534,"../internals/object-is-extensible":538,"../internals/uid":581}],501:[function(_dereq_,module,exports){
- var NATIVE_WEAK_MAP = _dereq_('../internals/native-weak-map');
- var global = _dereq_('../internals/global');
- var uncurryThis = _dereq_('../internals/function-uncurry-this');
- var isObject = _dereq_('../internals/is-object');
- var createNonEnumerableProperty = _dereq_('../internals/create-non-enumerable-property');
- var hasOwn = _dereq_('../internals/has-own-property');
- var shared = _dereq_('../internals/shared-store');
- var sharedKey = _dereq_('../internals/shared-key');
- var hiddenKeys = _dereq_('../internals/hidden-keys');
- var OBJECT_ALREADY_INITIALIZED = 'Object already initialized';
- var TypeError = global.TypeError;
- var WeakMap = global.WeakMap;
- var set, get, has;
- var enforce = function (it) {
- return has(it) ? get(it) : set(it, {});
- };
- var getterFor = function (TYPE) {
- return function (it) {
- var state;
- if (!isObject(it) || (state = get(it)).type !== TYPE) {
- throw TypeError('Incompatible receiver, ' + TYPE + ' required');
- } return state;
- };
- };
- if (NATIVE_WEAK_MAP || shared.state) {
- var store = shared.state || (shared.state = new WeakMap());
- var wmget = uncurryThis(store.get);
- var wmhas = uncurryThis(store.has);
- var wmset = uncurryThis(store.set);
- set = function (it, metadata) {
- if (wmhas(store, it)) throw new TypeError(OBJECT_ALREADY_INITIALIZED);
- metadata.facade = it;
- wmset(store, it, metadata);
- return metadata;
- };
- get = function (it) {
- return wmget(store, it) || {};
- };
- has = function (it) {
- return wmhas(store, it);
- };
- } else {
- var STATE = sharedKey('state');
- hiddenKeys[STATE] = true;
- set = function (it, metadata) {
- if (hasOwn(it, STATE)) throw new TypeError(OBJECT_ALREADY_INITIALIZED);
- metadata.facade = it;
- createNonEnumerableProperty(it, STATE, metadata);
- return metadata;
- };
- get = function (it) {
- return hasOwn(it, STATE) ? it[STATE] : {};
- };
- has = function (it) {
- return hasOwn(it, STATE);
- };
- }
- module.exports = {
- set: set,
- get: get,
- has: has,
- enforce: enforce,
- getterFor: getterFor
- };
- },{"../internals/create-non-enumerable-property":455,"../internals/function-uncurry-this":485,"../internals/global":491,"../internals/has-own-property":492,"../internals/hidden-keys":493,"../internals/is-object":509,"../internals/native-weak-map":524,"../internals/shared-key":559,"../internals/shared-store":560}],502:[function(_dereq_,module,exports){
- var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
- var Iterators = _dereq_('../internals/iterators');
- var ITERATOR = wellKnownSymbol('iterator');
- var ArrayPrototype = Array.prototype;
- // check on default Array iterator
- module.exports = function (it) {
- return it !== undefined && (Iterators.Array === it || ArrayPrototype[ITERATOR] === it);
- };
- },{"../internals/iterators":516,"../internals/well-known-symbol":586}],503:[function(_dereq_,module,exports){
- var classof = _dereq_('../internals/classof-raw');
- // `IsArray` abstract operation
- // https://tc39.es/ecma262/#sec-isarray
- // eslint-disable-next-line es/no-array-isarray -- safe
- module.exports = Array.isArray || function isArray(argument) {
- return classof(argument) == 'Array';
- };
- },{"../internals/classof-raw":442}],504:[function(_dereq_,module,exports){
- // `IsCallable` abstract operation
- // https://tc39.es/ecma262/#sec-iscallable
- module.exports = function (argument) {
- return typeof argument == 'function';
- };
- },{}],505:[function(_dereq_,module,exports){
- var uncurryThis = _dereq_('../internals/function-uncurry-this');
- var fails = _dereq_('../internals/fails');
- var isCallable = _dereq_('../internals/is-callable');
- var classof = _dereq_('../internals/classof');
- var getBuiltIn = _dereq_('../internals/get-built-in');
- var inspectSource = _dereq_('../internals/inspect-source');
- var noop = function () { /* empty */ };
- var empty = [];
- var construct = getBuiltIn('Reflect', 'construct');
- var constructorRegExp = /^\s*(?:class|function)\b/;
- var exec = uncurryThis(constructorRegExp.exec);
- var INCORRECT_TO_STRING = !constructorRegExp.exec(noop);
- var isConstructorModern = function isConstructor(argument) {
- if (!isCallable(argument)) return false;
- try {
- construct(noop, empty, argument);
- return true;
- } catch (error) {
- return false;
- }
- };
- var isConstructorLegacy = function isConstructor(argument) {
- if (!isCallable(argument)) return false;
- switch (classof(argument)) {
- case 'AsyncFunction':
- case 'GeneratorFunction':
- case 'AsyncGeneratorFunction': return false;
- }
- try {
- // we can't check .prototype since constructors produced by .bind haven't it
- // `Function#toString` throws on some built-it function in some legacy engines
- // (for example, `DOMQuad` and similar in FF41-)
- return INCORRECT_TO_STRING || !!exec(constructorRegExp, inspectSource(argument));
- } catch (error) {
- return true;
- }
- };
- isConstructorLegacy.sham = true;
- // `IsConstructor` abstract operation
- // https://tc39.es/ecma262/#sec-isconstructor
- module.exports = !construct || fails(function () {
- var called;
- return isConstructorModern(isConstructorModern.call)
- || !isConstructorModern(Object)
- || !isConstructorModern(function () { called = true; })
- || called;
- }) ? isConstructorLegacy : isConstructorModern;
- },{"../internals/classof":443,"../internals/fails":477,"../internals/function-uncurry-this":485,"../internals/get-built-in":486,"../internals/inspect-source":498,"../internals/is-callable":504}],506:[function(_dereq_,module,exports){
- var hasOwn = _dereq_('../internals/has-own-property');
- module.exports = function (descriptor) {
- return descriptor !== undefined && (hasOwn(descriptor, 'value') || hasOwn(descriptor, 'writable'));
- };
- },{"../internals/has-own-property":492}],507:[function(_dereq_,module,exports){
- var fails = _dereq_('../internals/fails');
- var isCallable = _dereq_('../internals/is-callable');
- var replacement = /#|\.prototype\./;
- var isForced = function (feature, detection) {
- var value = data[normalize(feature)];
- return value == POLYFILL ? true
- : value == NATIVE ? false
- : isCallable(detection) ? fails(detection)
- : !!detection;
- };
- var normalize = isForced.normalize = function (string) {
- return String(string).replace(replacement, '.').toLowerCase();
- };
- var data = isForced.data = {};
- var NATIVE = isForced.NATIVE = 'N';
- var POLYFILL = isForced.POLYFILL = 'P';
- module.exports = isForced;
- },{"../internals/fails":477,"../internals/is-callable":504}],508:[function(_dereq_,module,exports){
- var isObject = _dereq_('../internals/is-object');
- var floor = Math.floor;
- // `IsIntegralNumber` abstract operation
- // https://tc39.es/ecma262/#sec-isintegralnumber
- // eslint-disable-next-line es/no-number-isinteger -- safe
- module.exports = Number.isInteger || function isInteger(it) {
- return !isObject(it) && isFinite(it) && floor(it) === it;
- };
- },{"../internals/is-object":509}],509:[function(_dereq_,module,exports){
- var isCallable = _dereq_('../internals/is-callable');
- module.exports = function (it) {
- return typeof it == 'object' ? it !== null : isCallable(it);
- };
- },{"../internals/is-callable":504}],510:[function(_dereq_,module,exports){
- module.exports = true;
- },{}],511:[function(_dereq_,module,exports){
- var isObject = _dereq_('../internals/is-object');
- var classof = _dereq_('../internals/classof-raw');
- var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
- var MATCH = wellKnownSymbol('match');
- // `IsRegExp` abstract operation
- // https://tc39.es/ecma262/#sec-isregexp
- module.exports = function (it) {
- var isRegExp;
- return isObject(it) && ((isRegExp = it[MATCH]) !== undefined ? !!isRegExp : classof(it) == 'RegExp');
- };
- },{"../internals/classof-raw":442,"../internals/is-object":509,"../internals/well-known-symbol":586}],512:[function(_dereq_,module,exports){
- var global = _dereq_('../internals/global');
- var getBuiltIn = _dereq_('../internals/get-built-in');
- var isCallable = _dereq_('../internals/is-callable');
- var isPrototypeOf = _dereq_('../internals/object-is-prototype-of');
- var USE_SYMBOL_AS_UID = _dereq_('../internals/use-symbol-as-uid');
- var Object = global.Object;
- module.exports = USE_SYMBOL_AS_UID ? function (it) {
- return typeof it == 'symbol';
- } : function (it) {
- var $Symbol = getBuiltIn('Symbol');
- return isCallable($Symbol) && isPrototypeOf($Symbol.prototype, Object(it));
- };
- },{"../internals/get-built-in":486,"../internals/global":491,"../internals/is-callable":504,"../internals/object-is-prototype-of":539,"../internals/use-symbol-as-uid":582}],513:[function(_dereq_,module,exports){
- var global = _dereq_('../internals/global');
- var bind = _dereq_('../internals/function-bind-context');
- var call = _dereq_('../internals/function-call');
- var anObject = _dereq_('../internals/an-object');
- var tryToString = _dereq_('../internals/try-to-string');
- var isArrayIteratorMethod = _dereq_('../internals/is-array-iterator-method');
- var lengthOfArrayLike = _dereq_('../internals/length-of-array-like');
- var isPrototypeOf = _dereq_('../internals/object-is-prototype-of');
- var getIterator = _dereq_('../internals/get-iterator');
- var getIteratorMethod = _dereq_('../internals/get-iterator-method');
- var iteratorClose = _dereq_('../internals/iterator-close');
- var TypeError = global.TypeError;
- var Result = function (stopped, result) {
- this.stopped = stopped;
- this.result = result;
- };
- var ResultPrototype = Result.prototype;
- module.exports = function (iterable, unboundFunction, options) {
- var that = options && options.that;
- var AS_ENTRIES = !!(options && options.AS_ENTRIES);
- var IS_ITERATOR = !!(options && options.IS_ITERATOR);
- var INTERRUPTED = !!(options && options.INTERRUPTED);
- var fn = bind(unboundFunction, that);
- var iterator, iterFn, index, length, result, next, step;
- var stop = function (condition) {
- if (iterator) iteratorClose(iterator, 'normal', condition);
- return new Result(true, condition);
- };
- var callFn = function (value) {
- if (AS_ENTRIES) {
- anObject(value);
- return INTERRUPTED ? fn(value[0], value[1], stop) : fn(value[0], value[1]);
- } return INTERRUPTED ? fn(value, stop) : fn(value);
- };
- if (IS_ITERATOR) {
- iterator = iterable;
- } else {
- iterFn = getIteratorMethod(iterable);
- if (!iterFn) throw TypeError(tryToString(iterable) + ' is not iterable');
- // optimisation for array iterators
- if (isArrayIteratorMethod(iterFn)) {
- for (index = 0, length = lengthOfArrayLike(iterable); length > index; index++) {
- result = callFn(iterable[index]);
- if (result && isPrototypeOf(ResultPrototype, result)) return result;
- } return new Result(false);
- }
- iterator = getIterator(iterable, iterFn);
- }
- next = iterator.next;
- while (!(step = call(next, iterator)).done) {
- try {
- result = callFn(step.value);
- } catch (error) {
- iteratorClose(iterator, 'throw', error);
- }
- if (typeof result == 'object' && result && isPrototypeOf(ResultPrototype, result)) return result;
- } return new Result(false);
- };
- },{"../internals/an-object":426,"../internals/function-bind-context":480,"../internals/function-call":483,"../internals/get-iterator":488,"../internals/get-iterator-method":487,"../internals/global":491,"../internals/is-array-iterator-method":502,"../internals/iterator-close":514,"../internals/length-of-array-like":517,"../internals/object-is-prototype-of":539,"../internals/try-to-string":580}],514:[function(_dereq_,module,exports){
- var call = _dereq_('../internals/function-call');
- var anObject = _dereq_('../internals/an-object');
- var getMethod = _dereq_('../internals/get-method');
- module.exports = function (iterator, kind, value) {
- var innerResult, innerError;
- anObject(iterator);
- try {
- innerResult = getMethod(iterator, 'return');
- if (!innerResult) {
- if (kind === 'throw') throw value;
- return value;
- }
- innerResult = call(innerResult, iterator);
- } catch (error) {
- innerError = true;
- innerResult = error;
- }
- if (kind === 'throw') throw value;
- if (innerError) throw innerResult;
- anObject(innerResult);
- return value;
- };
- },{"../internals/an-object":426,"../internals/function-call":483,"../internals/get-method":490}],515:[function(_dereq_,module,exports){
- 'use strict';
- var fails = _dereq_('../internals/fails');
- var isCallable = _dereq_('../internals/is-callable');
- var create = _dereq_('../internals/object-create');
- var getPrototypeOf = _dereq_('../internals/object-get-prototype-of');
- var redefine = _dereq_('../internals/redefine');
- var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
- var IS_PURE = _dereq_('../internals/is-pure');
- var ITERATOR = wellKnownSymbol('iterator');
- var BUGGY_SAFARI_ITERATORS = false;
- // `%IteratorPrototype%` object
- // https://tc39.es/ecma262/#sec-%iteratorprototype%-object
- var IteratorPrototype, PrototypeOfArrayIteratorPrototype, arrayIterator;
- /* eslint-disable es/no-array-prototype-keys -- safe */
- if ([].keys) {
- arrayIterator = [].keys();
- // Safari 8 has buggy iterators w/o `next`
- if (!('next' in arrayIterator)) BUGGY_SAFARI_ITERATORS = true;
- else {
- PrototypeOfArrayIteratorPrototype = getPrototypeOf(getPrototypeOf(arrayIterator));
- if (PrototypeOfArrayIteratorPrototype !== Object.prototype) IteratorPrototype = PrototypeOfArrayIteratorPrototype;
- }
- }
- var NEW_ITERATOR_PROTOTYPE = IteratorPrototype == undefined || fails(function () {
- var test = {};
- // FF44- legacy iterators case
- return IteratorPrototype[ITERATOR].call(test) !== test;
- });
- if (NEW_ITERATOR_PROTOTYPE) IteratorPrototype = {};
- else if (IS_PURE) IteratorPrototype = create(IteratorPrototype);
- // `%IteratorPrototype%[@@iterator]()` method
- // https://tc39.es/ecma262/#sec-%iteratorprototype%-@@iterator
- if (!isCallable(IteratorPrototype[ITERATOR])) {
- redefine(IteratorPrototype, ITERATOR, function () {
- return this;
- });
- }
- module.exports = {
- IteratorPrototype: IteratorPrototype,
- BUGGY_SAFARI_ITERATORS: BUGGY_SAFARI_ITERATORS
- };
- },{"../internals/fails":477,"../internals/is-callable":504,"../internals/is-pure":510,"../internals/object-create":530,"../internals/object-get-prototype-of":537,"../internals/redefine":553,"../internals/well-known-symbol":586}],516:[function(_dereq_,module,exports){
- arguments[4][493][0].apply(exports,arguments)
- },{"dup":493}],517:[function(_dereq_,module,exports){
- var toLength = _dereq_('../internals/to-length');
- // `LengthOfArrayLike` abstract operation
- // https://tc39.es/ecma262/#sec-lengthofarraylike
- module.exports = function (obj) {
- return toLength(obj.length);
- };
- },{"../internals/to-length":574}],518:[function(_dereq_,module,exports){
- 'use strict';
- var call = _dereq_('../internals/function-call');
- var aCallable = _dereq_('../internals/a-callable');
- var anObject = _dereq_('../internals/an-object');
- // `Map.prototype.emplace` method
- // https://github.com/thumbsupep/proposal-upsert
- module.exports = function emplace(key, handler) {
- var map = anObject(this);
- var get = aCallable(map.get);
- var has = aCallable(map.has);
- var set = aCallable(map.set);
- var value = (call(has, map, key) && 'update' in handler)
- ? handler.update(call(get, map, key), key, map)
- : handler.insert(key, map);
- call(set, map, key, value);
- return value;
- };
- },{"../internals/a-callable":421,"../internals/an-object":426,"../internals/function-call":483}],519:[function(_dereq_,module,exports){
- 'use strict';
- var global = _dereq_('../internals/global');
- var call = _dereq_('../internals/function-call');
- var aCallable = _dereq_('../internals/a-callable');
- var isCallable = _dereq_('../internals/is-callable');
- var anObject = _dereq_('../internals/an-object');
- var TypeError = global.TypeError;
- // `Map.prototype.upsert` method
- // https://github.com/thumbsupep/proposal-upsert
- module.exports = function upsert(key, updateFn /* , insertFn */) {
- var map = anObject(this);
- var get = aCallable(map.get);
- var has = aCallable(map.has);
- var set = aCallable(map.set);
- var insertFn = arguments.length > 2 ? arguments[2] : undefined;
- var value;
- if (!isCallable(updateFn) && !isCallable(insertFn)) {
- throw TypeError('At least one callback required');
- }
- if (call(has, map, key)) {
- value = call(get, map, key);
- if (isCallable(updateFn)) {
- value = updateFn(value);
- call(set, map, key, value);
- }
- } else if (isCallable(insertFn)) {
- value = insertFn();
- call(set, map, key, value);
- } return value;
- };
- },{"../internals/a-callable":421,"../internals/an-object":426,"../internals/function-call":483,"../internals/global":491,"../internals/is-callable":504}],520:[function(_dereq_,module,exports){
- var global = _dereq_('../internals/global');
- var bind = _dereq_('../internals/function-bind-context');
- var getOwnPropertyDescriptor = _dereq_('../internals/object-get-own-property-descriptor').f;
- var macrotask = _dereq_('../internals/task').set;
- var IS_IOS = _dereq_('../internals/engine-is-ios');
- var IS_IOS_PEBBLE = _dereq_('../internals/engine-is-ios-pebble');
- var IS_WEBOS_WEBKIT = _dereq_('../internals/engine-is-webos-webkit');
- var IS_NODE = _dereq_('../internals/engine-is-node');
- var MutationObserver = global.MutationObserver || global.WebKitMutationObserver;
- var document = global.document;
- var process = global.process;
- var Promise = global.Promise;
- // Node.js 11 shows ExperimentalWarning on getting `queueMicrotask`
- var queueMicrotaskDescriptor = getOwnPropertyDescriptor(global, 'queueMicrotask');
- var queueMicrotask = queueMicrotaskDescriptor && queueMicrotaskDescriptor.value;
- var flush, head, last, notify, toggle, node, promise, then;
- // modern engines have queueMicrotask method
- if (!queueMicrotask) {
- flush = function () {
- var parent, fn;
- if (IS_NODE && (parent = process.domain)) parent.exit();
- while (head) {
- fn = head.fn;
- head = head.next;
- try {
- fn();
- } catch (error) {
- if (head) notify();
- else last = undefined;
- throw error;
- }
- } last = undefined;
- if (parent) parent.enter();
- };
- // browsers with MutationObserver, except iOS - https://github.com/zloirock/core-js/issues/339
- // also except WebOS Webkit https://github.com/zloirock/core-js/issues/898
- if (!IS_IOS && !IS_NODE && !IS_WEBOS_WEBKIT && MutationObserver && document) {
- toggle = true;
- node = document.createTextNode('');
- new MutationObserver(flush).observe(node, { characterData: true });
- notify = function () {
- node.data = toggle = !toggle;
- };
- // environments with maybe non-completely correct, but existent Promise
- } else if (!IS_IOS_PEBBLE && Promise && Promise.resolve) {
- // Promise.resolve without an argument throws an error in LG WebOS 2
- promise = Promise.resolve(undefined);
- // workaround of WebKit ~ iOS Safari 10.1 bug
- promise.constructor = Promise;
- then = bind(promise.then, promise);
- notify = function () {
- then(flush);
- };
- // Node.js without promises
- } else if (IS_NODE) {
- notify = function () {
- process.nextTick(flush);
- };
- // for other environments - macrotask based on:
- // - setImmediate
- // - MessageChannel
- // - window.postMessag
- // - onreadystatechange
- // - setTimeout
- } else {
- // strange IE + webpack dev server bug - use .bind(global)
- macrotask = bind(macrotask, global);
- notify = function () {
- macrotask(flush);
- };
- }
- }
- module.exports = queueMicrotask || function (fn) {
- var task = { fn: fn, next: undefined };
- if (last) last.next = task;
- if (!head) {
- head = task;
- notify();
- } last = task;
- };
- },{"../internals/engine-is-ios":467,"../internals/engine-is-ios-pebble":466,"../internals/engine-is-node":468,"../internals/engine-is-webos-webkit":469,"../internals/function-bind-context":480,"../internals/global":491,"../internals/object-get-own-property-descriptor":533,"../internals/task":570}],521:[function(_dereq_,module,exports){
- var global = _dereq_('../internals/global');
- module.exports = global.Promise;
- },{"../internals/global":491}],522:[function(_dereq_,module,exports){
- /* eslint-disable es/no-symbol -- required for testing */
- var V8_VERSION = _dereq_('../internals/engine-v8-version');
- var fails = _dereq_('../internals/fails');
- // eslint-disable-next-line es/no-object-getownpropertysymbols -- required for testing
- module.exports = !!Object.getOwnPropertySymbols && !fails(function () {
- var symbol = Symbol();
- // Chrome 38 Symbol has incorrect toString conversion
- // `get-own-property-symbols` polyfill symbols converted to object are not Symbol instances
- return !String(symbol) || !(Object(symbol) instanceof Symbol) ||
- // Chrome 38-40 symbols are not inherited from DOM collections prototypes to instances
- !Symbol.sham && V8_VERSION && V8_VERSION < 41;
- });
- },{"../internals/engine-v8-version":471,"../internals/fails":477}],523:[function(_dereq_,module,exports){
- var fails = _dereq_('../internals/fails');
- var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
- var IS_PURE = _dereq_('../internals/is-pure');
- var ITERATOR = wellKnownSymbol('iterator');
- module.exports = !fails(function () {
- // eslint-disable-next-line unicorn/relative-url-style -- required for testing
- var url = new URL('b?a=1&b=2&c=3', 'http://a');
- var searchParams = url.searchParams;
- var result = '';
- url.pathname = 'c%20d';
- searchParams.forEach(function (value, key) {
- searchParams['delete']('b');
- result += key + value;
- });
- return (IS_PURE && !url.toJSON)
- || !searchParams.sort
- || url.href !== 'http://a/c%20d?a=1&c=3'
- || searchParams.get('c') !== '3'
- || String(new URLSearchParams('?a=1')) !== 'a=1'
- || !searchParams[ITERATOR]
- // throws in Edge
- || new URL('https://a@b').username !== 'a'
- || new URLSearchParams(new URLSearchParams('a=b')).get('a') !== 'b'
- // not punycoded in Edge
- || new URL('http://тест').host !== 'xn--e1aybc'
- // not escaped in Chrome 62-
- || new URL('http://a#б').hash !== '#%D0%B1'
- // fails in Chrome 66-
- || result !== 'a1c3'
- // throws in Safari
- || new URL('http://x', undefined).host !== 'x';
- });
- },{"../internals/fails":477,"../internals/is-pure":510,"../internals/well-known-symbol":586}],524:[function(_dereq_,module,exports){
- var global = _dereq_('../internals/global');
- var isCallable = _dereq_('../internals/is-callable');
- var inspectSource = _dereq_('../internals/inspect-source');
- var WeakMap = global.WeakMap;
- module.exports = isCallable(WeakMap) && /native code/.test(inspectSource(WeakMap));
- },{"../internals/global":491,"../internals/inspect-source":498,"../internals/is-callable":504}],525:[function(_dereq_,module,exports){
- 'use strict';
- var aCallable = _dereq_('../internals/a-callable');
- var PromiseCapability = function (C) {
- var resolve, reject;
- this.promise = new C(function ($$resolve, $$reject) {
- if (resolve !== undefined || reject !== undefined) throw TypeError('Bad Promise constructor');
- resolve = $$resolve;
- reject = $$reject;
- });
- this.resolve = aCallable(resolve);
- this.reject = aCallable(reject);
- };
- // `NewPromiseCapability` abstract operation
- // https://tc39.es/ecma262/#sec-newpromisecapability
- module.exports.f = function (C) {
- return new PromiseCapability(C);
- };
- },{"../internals/a-callable":421}],526:[function(_dereq_,module,exports){
- var toString = _dereq_('../internals/to-string');
- module.exports = function (argument, $default) {
- return argument === undefined ? arguments.length < 2 ? '' : $default : toString(argument);
- };
- },{"../internals/to-string":579}],527:[function(_dereq_,module,exports){
- var global = _dereq_('../internals/global');
- var isRegExp = _dereq_('../internals/is-regexp');
- var TypeError = global.TypeError;
- module.exports = function (it) {
- if (isRegExp(it)) {
- throw TypeError("The method doesn't accept regular expressions");
- } return it;
- };
- },{"../internals/global":491,"../internals/is-regexp":511}],528:[function(_dereq_,module,exports){
- var global = _dereq_('../internals/global');
- var fails = _dereq_('../internals/fails');
- var uncurryThis = _dereq_('../internals/function-uncurry-this');
- var toString = _dereq_('../internals/to-string');
- var trim = _dereq_('../internals/string-trim').trim;
- var whitespaces = _dereq_('../internals/whitespaces');
- var $parseInt = global.parseInt;
- var Symbol = global.Symbol;
- var ITERATOR = Symbol && Symbol.iterator;
- var hex = /^[+-]?0x/i;
- var exec = uncurryThis(hex.exec);
- var FORCED = $parseInt(whitespaces + '08') !== 8 || $parseInt(whitespaces + '0x16') !== 22
- // MS Edge 18- broken with boxed symbols
- || (ITERATOR && !fails(function () { $parseInt(Object(ITERATOR)); }));
- // `parseInt` method
- // https://tc39.es/ecma262/#sec-parseint-string-radix
- module.exports = FORCED ? function parseInt(string, radix) {
- var S = trim(toString(string));
- return $parseInt(S, (radix >>> 0) || (exec(hex, S) ? 16 : 10));
- } : $parseInt;
- },{"../internals/fails":477,"../internals/function-uncurry-this":485,"../internals/global":491,"../internals/string-trim":569,"../internals/to-string":579,"../internals/whitespaces":587}],529:[function(_dereq_,module,exports){
- 'use strict';
- var DESCRIPTORS = _dereq_('../internals/descriptors');
- var uncurryThis = _dereq_('../internals/function-uncurry-this');
- var call = _dereq_('../internals/function-call');
- var fails = _dereq_('../internals/fails');
- var objectKeys = _dereq_('../internals/object-keys');
- var getOwnPropertySymbolsModule = _dereq_('../internals/object-get-own-property-symbols');
- var propertyIsEnumerableModule = _dereq_('../internals/object-property-is-enumerable');
- var toObject = _dereq_('../internals/to-object');
- var IndexedObject = _dereq_('../internals/indexed-object');
- // eslint-disable-next-line es/no-object-assign -- safe
- var $assign = Object.assign;
- // eslint-disable-next-line es/no-object-defineproperty -- required for testing
- var defineProperty = Object.defineProperty;
- var concat = uncurryThis([].concat);
- // `Object.assign` method
- // https://tc39.es/ecma262/#sec-object.assign
- module.exports = !$assign || fails(function () {
- // should have correct order of operations (Edge bug)
- if (DESCRIPTORS && $assign({ b: 1 }, $assign(defineProperty({}, 'a', {
- enumerable: true,
- get: function () {
- defineProperty(this, 'b', {
- value: 3,
- enumerable: false
- });
- }
- }), { b: 2 })).b !== 1) return true;
- // should work with symbols and should have deterministic property order (V8 bug)
- var A = {};
- var B = {};
- // eslint-disable-next-line es/no-symbol -- safe
- var symbol = Symbol();
- var alphabet = 'abcdefghijklmnopqrst';
- A[symbol] = 7;
- alphabet.split('').forEach(function (chr) { B[chr] = chr; });
- return $assign({}, A)[symbol] != 7 || objectKeys($assign({}, B)).join('') != alphabet;
- }) ? function assign(target, source) { // eslint-disable-line no-unused-vars -- required for `.length`
- var T = toObject(target);
- var argumentsLength = arguments.length;
- var index = 1;
- var getOwnPropertySymbols = getOwnPropertySymbolsModule.f;
- var propertyIsEnumerable = propertyIsEnumerableModule.f;
- while (argumentsLength > index) {
- var S = IndexedObject(arguments[index++]);
- var keys = getOwnPropertySymbols ? concat(objectKeys(S), getOwnPropertySymbols(S)) : objectKeys(S);
- var length = keys.length;
- var j = 0;
- var key;
- while (length > j) {
- key = keys[j++];
- if (!DESCRIPTORS || call(propertyIsEnumerable, S, key)) T[key] = S[key];
- }
- } return T;
- } : $assign;
- },{"../internals/descriptors":460,"../internals/fails":477,"../internals/function-call":483,"../internals/function-uncurry-this":485,"../internals/indexed-object":497,"../internals/object-get-own-property-symbols":536,"../internals/object-keys":541,"../internals/object-property-is-enumerable":542,"../internals/to-object":575}],530:[function(_dereq_,module,exports){
- /* global ActiveXObject -- old IE, WSH */
- var anObject = _dereq_('../internals/an-object');
- var definePropertiesModule = _dereq_('../internals/object-define-properties');
- var enumBugKeys = _dereq_('../internals/enum-bug-keys');
- var hiddenKeys = _dereq_('../internals/hidden-keys');
- var html = _dereq_('../internals/html');
- var documentCreateElement = _dereq_('../internals/document-create-element');
- var sharedKey = _dereq_('../internals/shared-key');
- var GT = '>';
- var LT = '<';
- var PROTOTYPE = 'prototype';
- var SCRIPT = 'script';
- var IE_PROTO = sharedKey('IE_PROTO');
- var EmptyConstructor = function () { /* empty */ };
- var scriptTag = function (content) {
- return LT + SCRIPT + GT + content + LT + '/' + SCRIPT + GT;
- };
- // Create object with fake `null` prototype: use ActiveX Object with cleared prototype
- var NullProtoObjectViaActiveX = function (activeXDocument) {
- activeXDocument.write(scriptTag(''));
- activeXDocument.close();
- var temp = activeXDocument.parentWindow.Object;
- activeXDocument = null; // avoid memory leak
- return temp;
- };
- // Create object with fake `null` prototype: use iframe Object with cleared prototype
- var NullProtoObjectViaIFrame = function () {
- // Thrash, waste and sodomy: IE GC bug
- var iframe = documentCreateElement('iframe');
- var JS = 'java' + SCRIPT + ':';
- var iframeDocument;
- iframe.style.display = 'none';
- html.appendChild(iframe);
- // https://github.com/zloirock/core-js/issues/475
- iframe.src = String(JS);
- iframeDocument = iframe.contentWindow.document;
- iframeDocument.open();
- iframeDocument.write(scriptTag('document.F=Object'));
- iframeDocument.close();
- return iframeDocument.F;
- };
- // Check for document.domain and active x support
- // No need to use active x approach when document.domain is not set
- // see https://github.com/es-shims/es5-shim/issues/150
- // variation of https://github.com/kitcambridge/es5-shim/commit/4f738ac066346
- // avoid IE GC bug
- var activeXDocument;
- var NullProtoObject = function () {
- try {
- activeXDocument = new ActiveXObject('htmlfile');
- } catch (error) { /* ignore */ }
- NullProtoObject = typeof document != 'undefined'
- ? document.domain && activeXDocument
- ? NullProtoObjectViaActiveX(activeXDocument) // old IE
- : NullProtoObjectViaIFrame()
- : NullProtoObjectViaActiveX(activeXDocument); // WSH
- var length = enumBugKeys.length;
- while (length--) delete NullProtoObject[PROTOTYPE][enumBugKeys[length]];
- return NullProtoObject();
- };
- hiddenKeys[IE_PROTO] = true;
- // `Object.create` method
- // https://tc39.es/ecma262/#sec-object.create
- module.exports = Object.create || function create(O, Properties) {
- var result;
- if (O !== null) {
- EmptyConstructor[PROTOTYPE] = anObject(O);
- result = new EmptyConstructor();
- EmptyConstructor[PROTOTYPE] = null;
- // add "__proto__" for Object.getPrototypeOf polyfill
- result[IE_PROTO] = O;
- } else result = NullProtoObject();
- return Properties === undefined ? result : definePropertiesModule.f(result, Properties);
- };
- },{"../internals/an-object":426,"../internals/document-create-element":461,"../internals/enum-bug-keys":474,"../internals/hidden-keys":493,"../internals/html":495,"../internals/object-define-properties":531,"../internals/shared-key":559}],531:[function(_dereq_,module,exports){
- var DESCRIPTORS = _dereq_('../internals/descriptors');
- var V8_PROTOTYPE_DEFINE_BUG = _dereq_('../internals/v8-prototype-define-bug');
- var definePropertyModule = _dereq_('../internals/object-define-property');
- var anObject = _dereq_('../internals/an-object');
- var toIndexedObject = _dereq_('../internals/to-indexed-object');
- var objectKeys = _dereq_('../internals/object-keys');
- // `Object.defineProperties` method
- // https://tc39.es/ecma262/#sec-object.defineproperties
- // eslint-disable-next-line es/no-object-defineproperties -- safe
- exports.f = DESCRIPTORS && !V8_PROTOTYPE_DEFINE_BUG ? Object.defineProperties : function defineProperties(O, Properties) {
- anObject(O);
- var props = toIndexedObject(Properties);
- var keys = objectKeys(Properties);
- var length = keys.length;
- var index = 0;
- var key;
- while (length > index) definePropertyModule.f(O, key = keys[index++], props[key]);
- return O;
- };
- },{"../internals/an-object":426,"../internals/descriptors":460,"../internals/object-define-property":532,"../internals/object-keys":541,"../internals/to-indexed-object":572,"../internals/v8-prototype-define-bug":583}],532:[function(_dereq_,module,exports){
- var global = _dereq_('../internals/global');
- var DESCRIPTORS = _dereq_('../internals/descriptors');
- var IE8_DOM_DEFINE = _dereq_('../internals/ie8-dom-define');
- var V8_PROTOTYPE_DEFINE_BUG = _dereq_('../internals/v8-prototype-define-bug');
- var anObject = _dereq_('../internals/an-object');
- var toPropertyKey = _dereq_('../internals/to-property-key');
- var TypeError = global.TypeError;
- // eslint-disable-next-line es/no-object-defineproperty -- safe
- var $defineProperty = Object.defineProperty;
- // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
- var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
- var ENUMERABLE = 'enumerable';
- var CONFIGURABLE = 'configurable';
- var WRITABLE = 'writable';
- // `Object.defineProperty` method
- // https://tc39.es/ecma262/#sec-object.defineproperty
- exports.f = DESCRIPTORS ? V8_PROTOTYPE_DEFINE_BUG ? function defineProperty(O, P, Attributes) {
- anObject(O);
- P = toPropertyKey(P);
- anObject(Attributes);
- if (typeof O === 'function' && P === 'prototype' && 'value' in Attributes && WRITABLE in Attributes && !Attributes[WRITABLE]) {
- var current = $getOwnPropertyDescriptor(O, P);
- if (current && current[WRITABLE]) {
- O[P] = Attributes.value;
- Attributes = {
- configurable: CONFIGURABLE in Attributes ? Attributes[CONFIGURABLE] : current[CONFIGURABLE],
- enumerable: ENUMERABLE in Attributes ? Attributes[ENUMERABLE] : current[ENUMERABLE],
- writable: false
- };
- }
- } return $defineProperty(O, P, Attributes);
- } : $defineProperty : function defineProperty(O, P, Attributes) {
- anObject(O);
- P = toPropertyKey(P);
- anObject(Attributes);
- if (IE8_DOM_DEFINE) try {
- return $defineProperty(O, P, Attributes);
- } catch (error) { /* empty */ }
- if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported');
- if ('value' in Attributes) O[P] = Attributes.value;
- return O;
- };
- },{"../internals/an-object":426,"../internals/descriptors":460,"../internals/global":491,"../internals/ie8-dom-define":496,"../internals/to-property-key":577,"../internals/v8-prototype-define-bug":583}],533:[function(_dereq_,module,exports){
- var DESCRIPTORS = _dereq_('../internals/descriptors');
- var call = _dereq_('../internals/function-call');
- var propertyIsEnumerableModule = _dereq_('../internals/object-property-is-enumerable');
- var createPropertyDescriptor = _dereq_('../internals/create-property-descriptor');
- var toIndexedObject = _dereq_('../internals/to-indexed-object');
- var toPropertyKey = _dereq_('../internals/to-property-key');
- var hasOwn = _dereq_('../internals/has-own-property');
- var IE8_DOM_DEFINE = _dereq_('../internals/ie8-dom-define');
- // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
- var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
- // `Object.getOwnPropertyDescriptor` method
- // https://tc39.es/ecma262/#sec-object.getownpropertydescriptor
- exports.f = DESCRIPTORS ? $getOwnPropertyDescriptor : function getOwnPropertyDescriptor(O, P) {
- O = toIndexedObject(O);
- P = toPropertyKey(P);
- if (IE8_DOM_DEFINE) try {
- return $getOwnPropertyDescriptor(O, P);
- } catch (error) { /* empty */ }
- if (hasOwn(O, P)) return createPropertyDescriptor(!call(propertyIsEnumerableModule.f, O, P), O[P]);
- };
- },{"../internals/create-property-descriptor":456,"../internals/descriptors":460,"../internals/function-call":483,"../internals/has-own-property":492,"../internals/ie8-dom-define":496,"../internals/object-property-is-enumerable":542,"../internals/to-indexed-object":572,"../internals/to-property-key":577}],534:[function(_dereq_,module,exports){
- /* eslint-disable es/no-object-getownpropertynames -- safe */
- var classof = _dereq_('../internals/classof-raw');
- var toIndexedObject = _dereq_('../internals/to-indexed-object');
- var $getOwnPropertyNames = _dereq_('../internals/object-get-own-property-names').f;
- var arraySlice = _dereq_('../internals/array-slice-simple');
- var windowNames = typeof window == 'object' && window && Object.getOwnPropertyNames
- ? Object.getOwnPropertyNames(window) : [];
- var getWindowNames = function (it) {
- try {
- return $getOwnPropertyNames(it);
- } catch (error) {
- return arraySlice(windowNames);
- }
- };
- // fallback for IE11 buggy Object.getOwnPropertyNames with iframe and window
- module.exports.f = function getOwnPropertyNames(it) {
- return windowNames && classof(it) == 'Window'
- ? getWindowNames(it)
- : $getOwnPropertyNames(toIndexedObject(it));
- };
- },{"../internals/array-slice-simple":435,"../internals/classof-raw":442,"../internals/object-get-own-property-names":535,"../internals/to-indexed-object":572}],535:[function(_dereq_,module,exports){
- var internalObjectKeys = _dereq_('../internals/object-keys-internal');
- var enumBugKeys = _dereq_('../internals/enum-bug-keys');
- var hiddenKeys = enumBugKeys.concat('length', 'prototype');
- // `Object.getOwnPropertyNames` method
- // https://tc39.es/ecma262/#sec-object.getownpropertynames
- // eslint-disable-next-line es/no-object-getownpropertynames -- safe
- exports.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
- return internalObjectKeys(O, hiddenKeys);
- };
- },{"../internals/enum-bug-keys":474,"../internals/object-keys-internal":540}],536:[function(_dereq_,module,exports){
- // eslint-disable-next-line es/no-object-getownpropertysymbols -- safe
- exports.f = Object.getOwnPropertySymbols;
- },{}],537:[function(_dereq_,module,exports){
- var global = _dereq_('../internals/global');
- var hasOwn = _dereq_('../internals/has-own-property');
- var isCallable = _dereq_('../internals/is-callable');
- var toObject = _dereq_('../internals/to-object');
- var sharedKey = _dereq_('../internals/shared-key');
- var CORRECT_PROTOTYPE_GETTER = _dereq_('../internals/correct-prototype-getter');
- var IE_PROTO = sharedKey('IE_PROTO');
- var Object = global.Object;
- var ObjectPrototype = Object.prototype;
- // `Object.getPrototypeOf` method
- // https://tc39.es/ecma262/#sec-object.getprototypeof
- module.exports = CORRECT_PROTOTYPE_GETTER ? Object.getPrototypeOf : function (O) {
- var object = toObject(O);
- if (hasOwn(object, IE_PROTO)) return object[IE_PROTO];
- var constructor = object.constructor;
- if (isCallable(constructor) && object instanceof constructor) {
- return constructor.prototype;
- } return object instanceof Object ? ObjectPrototype : null;
- };
- },{"../internals/correct-prototype-getter":453,"../internals/global":491,"../internals/has-own-property":492,"../internals/is-callable":504,"../internals/shared-key":559,"../internals/to-object":575}],538:[function(_dereq_,module,exports){
- var fails = _dereq_('../internals/fails');
- var isObject = _dereq_('../internals/is-object');
- var classof = _dereq_('../internals/classof-raw');
- var ARRAY_BUFFER_NON_EXTENSIBLE = _dereq_('../internals/array-buffer-non-extensible');
- // eslint-disable-next-line es/no-object-isextensible -- safe
- var $isExtensible = Object.isExtensible;
- var FAILS_ON_PRIMITIVES = fails(function () { $isExtensible(1); });
- // `Object.isExtensible` method
- // https://tc39.es/ecma262/#sec-object.isextensible
- module.exports = (FAILS_ON_PRIMITIVES || ARRAY_BUFFER_NON_EXTENSIBLE) ? function isExtensible(it) {
- if (!isObject(it)) return false;
- if (ARRAY_BUFFER_NON_EXTENSIBLE && classof(it) == 'ArrayBuffer') return false;
- return $isExtensible ? $isExtensible(it) : true;
- } : $isExtensible;
- },{"../internals/array-buffer-non-extensible":427,"../internals/classof-raw":442,"../internals/fails":477,"../internals/is-object":509}],539:[function(_dereq_,module,exports){
- var uncurryThis = _dereq_('../internals/function-uncurry-this');
- module.exports = uncurryThis({}.isPrototypeOf);
- },{"../internals/function-uncurry-this":485}],540:[function(_dereq_,module,exports){
- var uncurryThis = _dereq_('../internals/function-uncurry-this');
- var hasOwn = _dereq_('../internals/has-own-property');
- var toIndexedObject = _dereq_('../internals/to-indexed-object');
- var indexOf = _dereq_('../internals/array-includes').indexOf;
- var hiddenKeys = _dereq_('../internals/hidden-keys');
- var push = uncurryThis([].push);
- module.exports = function (object, names) {
- var O = toIndexedObject(object);
- var i = 0;
- var result = [];
- var key;
- for (key in O) !hasOwn(hiddenKeys, key) && hasOwn(O, key) && push(result, key);
- // Don't enum bug & hidden keys
- while (names.length > i) if (hasOwn(O, key = names[i++])) {
- ~indexOf(result, key) || push(result, key);
- }
- return result;
- };
- },{"../internals/array-includes":430,"../internals/function-uncurry-this":485,"../internals/has-own-property":492,"../internals/hidden-keys":493,"../internals/to-indexed-object":572}],541:[function(_dereq_,module,exports){
- var internalObjectKeys = _dereq_('../internals/object-keys-internal');
- var enumBugKeys = _dereq_('../internals/enum-bug-keys');
- // `Object.keys` method
- // https://tc39.es/ecma262/#sec-object.keys
- // eslint-disable-next-line es/no-object-keys -- safe
- module.exports = Object.keys || function keys(O) {
- return internalObjectKeys(O, enumBugKeys);
- };
- },{"../internals/enum-bug-keys":474,"../internals/object-keys-internal":540}],542:[function(_dereq_,module,exports){
- 'use strict';
- var $propertyIsEnumerable = {}.propertyIsEnumerable;
- // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
- var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
- // Nashorn ~ JDK8 bug
- var NASHORN_BUG = getOwnPropertyDescriptor && !$propertyIsEnumerable.call({ 1: 2 }, 1);
- // `Object.prototype.propertyIsEnumerable` method implementation
- // https://tc39.es/ecma262/#sec-object.prototype.propertyisenumerable
- exports.f = NASHORN_BUG ? function propertyIsEnumerable(V) {
- var descriptor = getOwnPropertyDescriptor(this, V);
- return !!descriptor && descriptor.enumerable;
- } : $propertyIsEnumerable;
- },{}],543:[function(_dereq_,module,exports){
- /* eslint-disable no-proto -- safe */
- var uncurryThis = _dereq_('../internals/function-uncurry-this');
- var anObject = _dereq_('../internals/an-object');
- var aPossiblePrototype = _dereq_('../internals/a-possible-prototype');
- // `Object.setPrototypeOf` method
- // https://tc39.es/ecma262/#sec-object.setprototypeof
- // Works with __proto__ only. Old v8 can't work with null proto objects.
- // eslint-disable-next-line es/no-object-setprototypeof -- safe
- module.exports = Object.setPrototypeOf || ('__proto__' in {} ? function () {
- var CORRECT_SETTER = false;
- var test = {};
- var setter;
- try {
- // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
- setter = uncurryThis(Object.getOwnPropertyDescriptor(Object.prototype, '__proto__').set);
- setter(test, []);
- CORRECT_SETTER = test instanceof Array;
- } catch (error) { /* empty */ }
- return function setPrototypeOf(O, proto) {
- anObject(O);
- aPossiblePrototype(proto);
- if (CORRECT_SETTER) setter(O, proto);
- else O.__proto__ = proto;
- return O;
- };
- }() : undefined);
- },{"../internals/a-possible-prototype":423,"../internals/an-object":426,"../internals/function-uncurry-this":485}],544:[function(_dereq_,module,exports){
- var DESCRIPTORS = _dereq_('../internals/descriptors');
- var uncurryThis = _dereq_('../internals/function-uncurry-this');
- var objectKeys = _dereq_('../internals/object-keys');
- var toIndexedObject = _dereq_('../internals/to-indexed-object');
- var $propertyIsEnumerable = _dereq_('../internals/object-property-is-enumerable').f;
- var propertyIsEnumerable = uncurryThis($propertyIsEnumerable);
- var push = uncurryThis([].push);
- // `Object.{ entries, values }` methods implementation
- var createMethod = function (TO_ENTRIES) {
- return function (it) {
- var O = toIndexedObject(it);
- var keys = objectKeys(O);
- var length = keys.length;
- var i = 0;
- var result = [];
- var key;
- while (length > i) {
- key = keys[i++];
- if (!DESCRIPTORS || propertyIsEnumerable(O, key)) {
- push(result, TO_ENTRIES ? [key, O[key]] : O[key]);
- }
- }
- return result;
- };
- };
- module.exports = {
- // `Object.entries` method
- // https://tc39.es/ecma262/#sec-object.entries
- entries: createMethod(true),
- // `Object.values` method
- // https://tc39.es/ecma262/#sec-object.values
- values: createMethod(false)
- };
- },{"../internals/descriptors":460,"../internals/function-uncurry-this":485,"../internals/object-keys":541,"../internals/object-property-is-enumerable":542,"../internals/to-indexed-object":572}],545:[function(_dereq_,module,exports){
- 'use strict';
- var TO_STRING_TAG_SUPPORT = _dereq_('../internals/to-string-tag-support');
- var classof = _dereq_('../internals/classof');
- // `Object.prototype.toString` method implementation
- // https://tc39.es/ecma262/#sec-object.prototype.tostring
- module.exports = TO_STRING_TAG_SUPPORT ? {}.toString : function toString() {
- return '[object ' + classof(this) + ']';
- };
- },{"../internals/classof":443,"../internals/to-string-tag-support":578}],546:[function(_dereq_,module,exports){
- var global = _dereq_('../internals/global');
- var call = _dereq_('../internals/function-call');
- var isCallable = _dereq_('../internals/is-callable');
- var isObject = _dereq_('../internals/is-object');
- var TypeError = global.TypeError;
- // `OrdinaryToPrimitive` abstract operation
- // https://tc39.es/ecma262/#sec-ordinarytoprimitive
- module.exports = function (input, pref) {
- var fn, val;
- if (pref === 'string' && isCallable(fn = input.toString) && !isObject(val = call(fn, input))) return val;
- if (isCallable(fn = input.valueOf) && !isObject(val = call(fn, input))) return val;
- if (pref !== 'string' && isCallable(fn = input.toString) && !isObject(val = call(fn, input))) return val;
- throw TypeError("Can't convert object to primitive value");
- };
- },{"../internals/function-call":483,"../internals/global":491,"../internals/is-callable":504,"../internals/is-object":509}],547:[function(_dereq_,module,exports){
- var getBuiltIn = _dereq_('../internals/get-built-in');
- var uncurryThis = _dereq_('../internals/function-uncurry-this');
- var getOwnPropertyNamesModule = _dereq_('../internals/object-get-own-property-names');
- var getOwnPropertySymbolsModule = _dereq_('../internals/object-get-own-property-symbols');
- var anObject = _dereq_('../internals/an-object');
- var concat = uncurryThis([].concat);
- // all object keys, includes non-enumerable and symbols
- module.exports = getBuiltIn('Reflect', 'ownKeys') || function ownKeys(it) {
- var keys = getOwnPropertyNamesModule.f(anObject(it));
- var getOwnPropertySymbols = getOwnPropertySymbolsModule.f;
- return getOwnPropertySymbols ? concat(keys, getOwnPropertySymbols(it)) : keys;
- };
- },{"../internals/an-object":426,"../internals/function-uncurry-this":485,"../internals/get-built-in":486,"../internals/object-get-own-property-names":535,"../internals/object-get-own-property-symbols":536}],548:[function(_dereq_,module,exports){
- arguments[4][493][0].apply(exports,arguments)
- },{"dup":493}],549:[function(_dereq_,module,exports){
- module.exports = function (exec) {
- try {
- return { error: false, value: exec() };
- } catch (error) {
- return { error: true, value: error };
- }
- };
- },{}],550:[function(_dereq_,module,exports){
- var anObject = _dereq_('../internals/an-object');
- var isObject = _dereq_('../internals/is-object');
- var newPromiseCapability = _dereq_('../internals/new-promise-capability');
- module.exports = function (C, x) {
- anObject(C);
- if (isObject(x) && x.constructor === C) return x;
- var promiseCapability = newPromiseCapability.f(C);
- var resolve = promiseCapability.resolve;
- resolve(x);
- return promiseCapability.promise;
- };
- },{"../internals/an-object":426,"../internals/is-object":509,"../internals/new-promise-capability":525}],551:[function(_dereq_,module,exports){
- var Queue = function () {
- this.head = null;
- this.tail = null;
- };
- Queue.prototype = {
- add: function (item) {
- var entry = { item: item, next: null };
- if (this.head) this.tail.next = entry;
- else this.head = entry;
- this.tail = entry;
- },
- get: function () {
- var entry = this.head;
- if (entry) {
- this.head = entry.next;
- if (this.tail === entry) this.tail = null;
- return entry.item;
- }
- }
- };
- module.exports = Queue;
- },{}],552:[function(_dereq_,module,exports){
- var redefine = _dereq_('../internals/redefine');
- module.exports = function (target, src, options) {
- for (var key in src) {
- if (options && options.unsafe && target[key]) target[key] = src[key];
- else redefine(target, key, src[key], options);
- } return target;
- };
- },{"../internals/redefine":553}],553:[function(_dereq_,module,exports){
- var createNonEnumerableProperty = _dereq_('../internals/create-non-enumerable-property');
- module.exports = function (target, key, value, options) {
- if (options && options.enumerable) target[key] = value;
- else createNonEnumerableProperty(target, key, value);
- };
- },{"../internals/create-non-enumerable-property":455}],554:[function(_dereq_,module,exports){
- var global = _dereq_('../internals/global');
- var TypeError = global.TypeError;
- // `RequireObjectCoercible` abstract operation
- // https://tc39.es/ecma262/#sec-requireobjectcoercible
- module.exports = function (it) {
- if (it == undefined) throw TypeError("Can't call method on " + it);
- return it;
- };
- },{"../internals/global":491}],555:[function(_dereq_,module,exports){
- // `SameValueZero` abstract operation
- // https://tc39.es/ecma262/#sec-samevaluezero
- module.exports = function (x, y) {
- // eslint-disable-next-line no-self-compare -- NaN check
- return x === y || x != x && y != y;
- };
- },{}],556:[function(_dereq_,module,exports){
- var global = _dereq_('../internals/global');
- // eslint-disable-next-line es/no-object-defineproperty -- safe
- var defineProperty = Object.defineProperty;
- module.exports = function (key, value) {
- try {
- defineProperty(global, key, { value: value, configurable: true, writable: true });
- } catch (error) {
- global[key] = value;
- } return value;
- };
- },{"../internals/global":491}],557:[function(_dereq_,module,exports){
- 'use strict';
- var getBuiltIn = _dereq_('../internals/get-built-in');
- var definePropertyModule = _dereq_('../internals/object-define-property');
- var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
- var DESCRIPTORS = _dereq_('../internals/descriptors');
- var SPECIES = wellKnownSymbol('species');
- module.exports = function (CONSTRUCTOR_NAME) {
- var Constructor = getBuiltIn(CONSTRUCTOR_NAME);
- var defineProperty = definePropertyModule.f;
- if (DESCRIPTORS && Constructor && !Constructor[SPECIES]) {
- defineProperty(Constructor, SPECIES, {
- configurable: true,
- get: function () { return this; }
- });
- }
- };
- },{"../internals/descriptors":460,"../internals/get-built-in":486,"../internals/object-define-property":532,"../internals/well-known-symbol":586}],558:[function(_dereq_,module,exports){
- var TO_STRING_TAG_SUPPORT = _dereq_('../internals/to-string-tag-support');
- var defineProperty = _dereq_('../internals/object-define-property').f;
- var createNonEnumerableProperty = _dereq_('../internals/create-non-enumerable-property');
- var hasOwn = _dereq_('../internals/has-own-property');
- var toString = _dereq_('../internals/object-to-string');
- var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
- var TO_STRING_TAG = wellKnownSymbol('toStringTag');
- module.exports = function (it, TAG, STATIC, SET_METHOD) {
- if (it) {
- var target = STATIC ? it : it.prototype;
- if (!hasOwn(target, TO_STRING_TAG)) {
- defineProperty(target, TO_STRING_TAG, { configurable: true, value: TAG });
- }
- if (SET_METHOD && !TO_STRING_TAG_SUPPORT) {
- createNonEnumerableProperty(target, 'toString', toString);
- }
- }
- };
- },{"../internals/create-non-enumerable-property":455,"../internals/has-own-property":492,"../internals/object-define-property":532,"../internals/object-to-string":545,"../internals/to-string-tag-support":578,"../internals/well-known-symbol":586}],559:[function(_dereq_,module,exports){
- var shared = _dereq_('../internals/shared');
- var uid = _dereq_('../internals/uid');
- var keys = shared('keys');
- module.exports = function (key) {
- return keys[key] || (keys[key] = uid(key));
- };
- },{"../internals/shared":561,"../internals/uid":581}],560:[function(_dereq_,module,exports){
- var global = _dereq_('../internals/global');
- var setGlobal = _dereq_('../internals/set-global');
- var SHARED = '__core-js_shared__';
- var store = global[SHARED] || setGlobal(SHARED, {});
- module.exports = store;
- },{"../internals/global":491,"../internals/set-global":556}],561:[function(_dereq_,module,exports){
- var IS_PURE = _dereq_('../internals/is-pure');
- var store = _dereq_('../internals/shared-store');
- (module.exports = function (key, value) {
- return store[key] || (store[key] = value !== undefined ? value : {});
- })('versions', []).push({
- version: '3.20.3',
- mode: IS_PURE ? 'pure' : 'global',
- copyright: '© 2014-2022 Denis Pushkarev (zloirock.ru)',
- license: 'https://github.com/zloirock/core-js/blob/v3.20.3/LICENSE',
- source: 'https://github.com/zloirock/core-js'
- });
- },{"../internals/is-pure":510,"../internals/shared-store":560}],562:[function(_dereq_,module,exports){
- var anObject = _dereq_('../internals/an-object');
- var aConstructor = _dereq_('../internals/a-constructor');
- var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
- var SPECIES = wellKnownSymbol('species');
- // `SpeciesConstructor` abstract operation
- // https://tc39.es/ecma262/#sec-speciesconstructor
- module.exports = function (O, defaultConstructor) {
- var C = anObject(O).constructor;
- var S;
- return C === undefined || (S = anObject(C)[SPECIES]) == undefined ? defaultConstructor : aConstructor(S);
- };
- },{"../internals/a-constructor":422,"../internals/an-object":426,"../internals/well-known-symbol":586}],563:[function(_dereq_,module,exports){
- var uncurryThis = _dereq_('../internals/function-uncurry-this');
- var toIntegerOrInfinity = _dereq_('../internals/to-integer-or-infinity');
- var toString = _dereq_('../internals/to-string');
- var requireObjectCoercible = _dereq_('../internals/require-object-coercible');
- var charAt = uncurryThis(''.charAt);
- var charCodeAt = uncurryThis(''.charCodeAt);
- var stringSlice = uncurryThis(''.slice);
- var createMethod = function (CONVERT_TO_STRING) {
- return function ($this, pos) {
- var S = toString(requireObjectCoercible($this));
- var position = toIntegerOrInfinity(pos);
- var size = S.length;
- var first, second;
- if (position < 0 || position >= size) return CONVERT_TO_STRING ? '' : undefined;
- first = charCodeAt(S, position);
- return first < 0xD800 || first > 0xDBFF || position + 1 === size
- || (second = charCodeAt(S, position + 1)) < 0xDC00 || second > 0xDFFF
- ? CONVERT_TO_STRING
- ? charAt(S, position)
- : first
- : CONVERT_TO_STRING
- ? stringSlice(S, position, position + 2)
- : (first - 0xD800 << 10) + (second - 0xDC00) + 0x10000;
- };
- };
- module.exports = {
- // `String.prototype.codePointAt` method
- // https://tc39.es/ecma262/#sec-string.prototype.codepointat
- codeAt: createMethod(false),
- // `String.prototype.at` method
- // https://github.com/mathiasbynens/String.prototype.at
- charAt: createMethod(true)
- };
- },{"../internals/function-uncurry-this":485,"../internals/require-object-coercible":554,"../internals/to-integer-or-infinity":573,"../internals/to-string":579}],564:[function(_dereq_,module,exports){
- // https://github.com/zloirock/core-js/issues/280
- var userAgent = _dereq_('../internals/engine-user-agent');
- module.exports = /Version\/10(?:\.\d+){1,2}(?: [\w./]+)?(?: Mobile\/\w+)? Safari\//.test(userAgent);
- },{"../internals/engine-user-agent":470}],565:[function(_dereq_,module,exports){
- // https://github.com/tc39/proposal-string-pad-start-end
- var uncurryThis = _dereq_('../internals/function-uncurry-this');
- var toLength = _dereq_('../internals/to-length');
- var toString = _dereq_('../internals/to-string');
- var $repeat = _dereq_('../internals/string-repeat');
- var requireObjectCoercible = _dereq_('../internals/require-object-coercible');
- var repeat = uncurryThis($repeat);
- var stringSlice = uncurryThis(''.slice);
- var ceil = Math.ceil;
- // `String.prototype.{ padStart, padEnd }` methods implementation
- var createMethod = function (IS_END) {
- return function ($this, maxLength, fillString) {
- var S = toString(requireObjectCoercible($this));
- var intMaxLength = toLength(maxLength);
- var stringLength = S.length;
- var fillStr = fillString === undefined ? ' ' : toString(fillString);
- var fillLen, stringFiller;
- if (intMaxLength <= stringLength || fillStr == '') return S;
- fillLen = intMaxLength - stringLength;
- stringFiller = repeat(fillStr, ceil(fillLen / fillStr.length));
- if (stringFiller.length > fillLen) stringFiller = stringSlice(stringFiller, 0, fillLen);
- return IS_END ? S + stringFiller : stringFiller + S;
- };
- };
- module.exports = {
- // `String.prototype.padStart` method
- // https://tc39.es/ecma262/#sec-string.prototype.padstart
- start: createMethod(false),
- // `String.prototype.padEnd` method
- // https://tc39.es/ecma262/#sec-string.prototype.padend
- end: createMethod(true)
- };
- },{"../internals/function-uncurry-this":485,"../internals/require-object-coercible":554,"../internals/string-repeat":567,"../internals/to-length":574,"../internals/to-string":579}],566:[function(_dereq_,module,exports){
- 'use strict';
- // based on https://github.com/bestiejs/punycode.js/blob/master/punycode.js
- var global = _dereq_('../internals/global');
- var uncurryThis = _dereq_('../internals/function-uncurry-this');
- var maxInt = 2147483647; // aka. 0x7FFFFFFF or 2^31-1
- var base = 36;
- var tMin = 1;
- var tMax = 26;
- var skew = 38;
- var damp = 700;
- var initialBias = 72;
- var initialN = 128; // 0x80
- var delimiter = '-'; // '\x2D'
- var regexNonASCII = /[^\0-\u007E]/; // non-ASCII chars
- var regexSeparators = /[.\u3002\uFF0E\uFF61]/g; // RFC 3490 separators
- var OVERFLOW_ERROR = 'Overflow: input needs wider integers to process';
- var baseMinusTMin = base - tMin;
- var RangeError = global.RangeError;
- var exec = uncurryThis(regexSeparators.exec);
- var floor = Math.floor;
- var fromCharCode = String.fromCharCode;
- var charCodeAt = uncurryThis(''.charCodeAt);
- var join = uncurryThis([].join);
- var push = uncurryThis([].push);
- var replace = uncurryThis(''.replace);
- var split = uncurryThis(''.split);
- var toLowerCase = uncurryThis(''.toLowerCase);
- /**
- * Creates an array containing the numeric code points of each Unicode
- * character in the string. While JavaScript uses UCS-2 internally,
- * this function will convert a pair of surrogate halves (each of which
- * UCS-2 exposes as separate characters) into a single code point,
- * matching UTF-16.
- */
- var ucs2decode = function (string) {
- var output = [];
- var counter = 0;
- var length = string.length;
- while (counter < length) {
- var value = charCodeAt(string, counter++);
- if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
- // It's a high surrogate, and there is a next character.
- var extra = charCodeAt(string, counter++);
- if ((extra & 0xFC00) == 0xDC00) { // Low surrogate.
- push(output, ((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
- } else {
- // It's an unmatched surrogate; only append this code unit, in case the
- // next code unit is the high surrogate of a surrogate pair.
- push(output, value);
- counter--;
- }
- } else {
- push(output, value);
- }
- }
- return output;
- };
- /**
- * Converts a digit/integer into a basic code point.
- */
- var digitToBasic = function (digit) {
- // 0..25 map to ASCII a..z or A..Z
- // 26..35 map to ASCII 0..9
- return digit + 22 + 75 * (digit < 26);
- };
- /**
- * Bias adaptation function as per section 3.4 of RFC 3492.
- * https://tools.ietf.org/html/rfc3492#section-3.4
- */
- var adapt = function (delta, numPoints, firstTime) {
- var k = 0;
- delta = firstTime ? floor(delta / damp) : delta >> 1;
- delta += floor(delta / numPoints);
- while (delta > baseMinusTMin * tMax >> 1) {
- delta = floor(delta / baseMinusTMin);
- k += base;
- }
- return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));
- };
- /**
- * Converts a string of Unicode symbols (e.g. a domain name label) to a
- * Punycode string of ASCII-only symbols.
- */
- var encode = function (input) {
- var output = [];
- // Convert the input in UCS-2 to an array of Unicode code points.
- input = ucs2decode(input);
- // Cache the length.
- var inputLength = input.length;
- // Initialize the state.
- var n = initialN;
- var delta = 0;
- var bias = initialBias;
- var i, currentValue;
- // Handle the basic code points.
- for (i = 0; i < input.length; i++) {
- currentValue = input[i];
- if (currentValue < 0x80) {
- push(output, fromCharCode(currentValue));
- }
- }
- var basicLength = output.length; // number of basic code points.
- var handledCPCount = basicLength; // number of code points that have been handled;
- // Finish the basic string with a delimiter unless it's empty.
- if (basicLength) {
- push(output, delimiter);
- }
- // Main encoding loop:
- while (handledCPCount < inputLength) {
- // All non-basic code points < n have been handled already. Find the next larger one:
- var m = maxInt;
- for (i = 0; i < input.length; i++) {
- currentValue = input[i];
- if (currentValue >= n && currentValue < m) {
- m = currentValue;
- }
- }
- // Increase `delta` enough to advance the decoder's <n,i> state to <m,0>, but guard against overflow.
- var handledCPCountPlusOne = handledCPCount + 1;
- if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {
- throw RangeError(OVERFLOW_ERROR);
- }
- delta += (m - n) * handledCPCountPlusOne;
- n = m;
- for (i = 0; i < input.length; i++) {
- currentValue = input[i];
- if (currentValue < n && ++delta > maxInt) {
- throw RangeError(OVERFLOW_ERROR);
- }
- if (currentValue == n) {
- // Represent delta as a generalized variable-length integer.
- var q = delta;
- var k = base;
- while (true) {
- var t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
- if (q < t) break;
- var qMinusT = q - t;
- var baseMinusT = base - t;
- push(output, fromCharCode(digitToBasic(t + qMinusT % baseMinusT)));
- q = floor(qMinusT / baseMinusT);
- k += base;
- }
- push(output, fromCharCode(digitToBasic(q)));
- bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);
- delta = 0;
- handledCPCount++;
- }
- }
- delta++;
- n++;
- }
- return join(output, '');
- };
- module.exports = function (input) {
- var encoded = [];
- var labels = split(replace(toLowerCase(input), regexSeparators, '\u002E'), '.');
- var i, label;
- for (i = 0; i < labels.length; i++) {
- label = labels[i];
- push(encoded, exec(regexNonASCII, label) ? 'xn--' + encode(label) : label);
- }
- return join(encoded, '.');
- };
- },{"../internals/function-uncurry-this":485,"../internals/global":491}],567:[function(_dereq_,module,exports){
- 'use strict';
- var global = _dereq_('../internals/global');
- var toIntegerOrInfinity = _dereq_('../internals/to-integer-or-infinity');
- var toString = _dereq_('../internals/to-string');
- var requireObjectCoercible = _dereq_('../internals/require-object-coercible');
- var RangeError = global.RangeError;
- // `String.prototype.repeat` method implementation
- // https://tc39.es/ecma262/#sec-string.prototype.repeat
- module.exports = function repeat(count) {
- var str = toString(requireObjectCoercible(this));
- var result = '';
- var n = toIntegerOrInfinity(count);
- if (n < 0 || n == Infinity) throw RangeError('Wrong number of repetitions');
- for (;n > 0; (n >>>= 1) && (str += str)) if (n & 1) result += str;
- return result;
- };
- },{"../internals/global":491,"../internals/require-object-coercible":554,"../internals/to-integer-or-infinity":573,"../internals/to-string":579}],568:[function(_dereq_,module,exports){
- var PROPER_FUNCTION_NAME = _dereq_('../internals/function-name').PROPER;
- var fails = _dereq_('../internals/fails');
- var whitespaces = _dereq_('../internals/whitespaces');
- var non = '\u200B\u0085\u180E';
- // check that a method works with the correct list
- // of whitespaces and has a correct name
- module.exports = function (METHOD_NAME) {
- return fails(function () {
- return !!whitespaces[METHOD_NAME]()
- || non[METHOD_NAME]() !== non
- || (PROPER_FUNCTION_NAME && whitespaces[METHOD_NAME].name !== METHOD_NAME);
- });
- };
- },{"../internals/fails":477,"../internals/function-name":484,"../internals/whitespaces":587}],569:[function(_dereq_,module,exports){
- var uncurryThis = _dereq_('../internals/function-uncurry-this');
- var requireObjectCoercible = _dereq_('../internals/require-object-coercible');
- var toString = _dereq_('../internals/to-string');
- var whitespaces = _dereq_('../internals/whitespaces');
- var replace = uncurryThis(''.replace);
- var whitespace = '[' + whitespaces + ']';
- var ltrim = RegExp('^' + whitespace + whitespace + '*');
- var rtrim = RegExp(whitespace + whitespace + '*$');
- // `String.prototype.{ trim, trimStart, trimEnd, trimLeft, trimRight }` methods implementation
- var createMethod = function (TYPE) {
- return function ($this) {
- var string = toString(requireObjectCoercible($this));
- if (TYPE & 1) string = replace(string, ltrim, '');
- if (TYPE & 2) string = replace(string, rtrim, '');
- return string;
- };
- };
- module.exports = {
- // `String.prototype.{ trimLeft, trimStart }` methods
- // https://tc39.es/ecma262/#sec-string.prototype.trimstart
- start: createMethod(1),
- // `String.prototype.{ trimRight, trimEnd }` methods
- // https://tc39.es/ecma262/#sec-string.prototype.trimend
- end: createMethod(2),
- // `String.prototype.trim` method
- // https://tc39.es/ecma262/#sec-string.prototype.trim
- trim: createMethod(3)
- };
- },{"../internals/function-uncurry-this":485,"../internals/require-object-coercible":554,"../internals/to-string":579,"../internals/whitespaces":587}],570:[function(_dereq_,module,exports){
- var global = _dereq_('../internals/global');
- var apply = _dereq_('../internals/function-apply');
- var bind = _dereq_('../internals/function-bind-context');
- var isCallable = _dereq_('../internals/is-callable');
- var hasOwn = _dereq_('../internals/has-own-property');
- var fails = _dereq_('../internals/fails');
- var html = _dereq_('../internals/html');
- var arraySlice = _dereq_('../internals/array-slice');
- var createElement = _dereq_('../internals/document-create-element');
- var IS_IOS = _dereq_('../internals/engine-is-ios');
- var IS_NODE = _dereq_('../internals/engine-is-node');
- var set = global.setImmediate;
- var clear = global.clearImmediate;
- var process = global.process;
- var Dispatch = global.Dispatch;
- var Function = global.Function;
- var MessageChannel = global.MessageChannel;
- var String = global.String;
- var counter = 0;
- var queue = {};
- var ONREADYSTATECHANGE = 'onreadystatechange';
- var location, defer, channel, port;
- try {
- // Deno throws a ReferenceError on `location` access without `--location` flag
- location = global.location;
- } catch (error) { /* empty */ }
- var run = function (id) {
- if (hasOwn(queue, id)) {
- var fn = queue[id];
- delete queue[id];
- fn();
- }
- };
- var runner = function (id) {
- return function () {
- run(id);
- };
- };
- var listener = function (event) {
- run(event.data);
- };
- var post = function (id) {
- // old engines have not location.origin
- global.postMessage(String(id), location.protocol + '//' + location.host);
- };
- // Node.js 0.9+ & IE10+ has setImmediate, otherwise:
- if (!set || !clear) {
- set = function setImmediate(fn) {
- var args = arraySlice(arguments, 1);
- queue[++counter] = function () {
- apply(isCallable(fn) ? fn : Function(fn), undefined, args);
- };
- defer(counter);
- return counter;
- };
- clear = function clearImmediate(id) {
- delete queue[id];
- };
- // Node.js 0.8-
- if (IS_NODE) {
- defer = function (id) {
- process.nextTick(runner(id));
- };
- // Sphere (JS game engine) Dispatch API
- } else if (Dispatch && Dispatch.now) {
- defer = function (id) {
- Dispatch.now(runner(id));
- };
- // Browsers with MessageChannel, includes WebWorkers
- // except iOS - https://github.com/zloirock/core-js/issues/624
- } else if (MessageChannel && !IS_IOS) {
- channel = new MessageChannel();
- port = channel.port2;
- channel.port1.onmessage = listener;
- defer = bind(port.postMessage, port);
- // Browsers with postMessage, skip WebWorkers
- // IE8 has postMessage, but it's sync & typeof its postMessage is 'object'
- } else if (
- global.addEventListener &&
- isCallable(global.postMessage) &&
- !global.importScripts &&
- location && location.protocol !== 'file:' &&
- !fails(post)
- ) {
- defer = post;
- global.addEventListener('message', listener, false);
- // IE8-
- } else if (ONREADYSTATECHANGE in createElement('script')) {
- defer = function (id) {
- html.appendChild(createElement('script'))[ONREADYSTATECHANGE] = function () {
- html.removeChild(this);
- run(id);
- };
- };
- // Rest old browsers
- } else {
- defer = function (id) {
- setTimeout(runner(id), 0);
- };
- }
- }
- module.exports = {
- set: set,
- clear: clear
- };
- },{"../internals/array-slice":436,"../internals/document-create-element":461,"../internals/engine-is-ios":467,"../internals/engine-is-node":468,"../internals/fails":477,"../internals/function-apply":479,"../internals/function-bind-context":480,"../internals/global":491,"../internals/has-own-property":492,"../internals/html":495,"../internals/is-callable":504}],571:[function(_dereq_,module,exports){
- var toIntegerOrInfinity = _dereq_('../internals/to-integer-or-infinity');
- var max = Math.max;
- var min = Math.min;
- // Helper for a popular repeating case of the spec:
- // Let integer be ? ToInteger(index).
- // If integer < 0, let result be max((length + integer), 0); else let result be min(integer, length).
- module.exports = function (index, length) {
- var integer = toIntegerOrInfinity(index);
- return integer < 0 ? max(integer + length, 0) : min(integer, length);
- };
- },{"../internals/to-integer-or-infinity":573}],572:[function(_dereq_,module,exports){
- // toObject with fallback for non-array-like ES3 strings
- var IndexedObject = _dereq_('../internals/indexed-object');
- var requireObjectCoercible = _dereq_('../internals/require-object-coercible');
- module.exports = function (it) {
- return IndexedObject(requireObjectCoercible(it));
- };
- },{"../internals/indexed-object":497,"../internals/require-object-coercible":554}],573:[function(_dereq_,module,exports){
- var ceil = Math.ceil;
- var floor = Math.floor;
- // `ToIntegerOrInfinity` abstract operation
- // https://tc39.es/ecma262/#sec-tointegerorinfinity
- module.exports = function (argument) {
- var number = +argument;
- // eslint-disable-next-line no-self-compare -- safe
- return number !== number || number === 0 ? 0 : (number > 0 ? floor : ceil)(number);
- };
- },{}],574:[function(_dereq_,module,exports){
- var toIntegerOrInfinity = _dereq_('../internals/to-integer-or-infinity');
- var min = Math.min;
- // `ToLength` abstract operation
- // https://tc39.es/ecma262/#sec-tolength
- module.exports = function (argument) {
- return argument > 0 ? min(toIntegerOrInfinity(argument), 0x1FFFFFFFFFFFFF) : 0; // 2 ** 53 - 1 == 9007199254740991
- };
- },{"../internals/to-integer-or-infinity":573}],575:[function(_dereq_,module,exports){
- var global = _dereq_('../internals/global');
- var requireObjectCoercible = _dereq_('../internals/require-object-coercible');
- var Object = global.Object;
- // `ToObject` abstract operation
- // https://tc39.es/ecma262/#sec-toobject
- module.exports = function (argument) {
- return Object(requireObjectCoercible(argument));
- };
- },{"../internals/global":491,"../internals/require-object-coercible":554}],576:[function(_dereq_,module,exports){
- var global = _dereq_('../internals/global');
- var call = _dereq_('../internals/function-call');
- var isObject = _dereq_('../internals/is-object');
- var isSymbol = _dereq_('../internals/is-symbol');
- var getMethod = _dereq_('../internals/get-method');
- var ordinaryToPrimitive = _dereq_('../internals/ordinary-to-primitive');
- var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
- var TypeError = global.TypeError;
- var TO_PRIMITIVE = wellKnownSymbol('toPrimitive');
- // `ToPrimitive` abstract operation
- // https://tc39.es/ecma262/#sec-toprimitive
- module.exports = function (input, pref) {
- if (!isObject(input) || isSymbol(input)) return input;
- var exoticToPrim = getMethod(input, TO_PRIMITIVE);
- var result;
- if (exoticToPrim) {
- if (pref === undefined) pref = 'default';
- result = call(exoticToPrim, input, pref);
- if (!isObject(result) || isSymbol(result)) return result;
- throw TypeError("Can't convert object to primitive value");
- }
- if (pref === undefined) pref = 'number';
- return ordinaryToPrimitive(input, pref);
- };
- },{"../internals/function-call":483,"../internals/get-method":490,"../internals/global":491,"../internals/is-object":509,"../internals/is-symbol":512,"../internals/ordinary-to-primitive":546,"../internals/well-known-symbol":586}],577:[function(_dereq_,module,exports){
- var toPrimitive = _dereq_('../internals/to-primitive');
- var isSymbol = _dereq_('../internals/is-symbol');
- // `ToPropertyKey` abstract operation
- // https://tc39.es/ecma262/#sec-topropertykey
- module.exports = function (argument) {
- var key = toPrimitive(argument, 'string');
- return isSymbol(key) ? key : key + '';
- };
- },{"../internals/is-symbol":512,"../internals/to-primitive":576}],578:[function(_dereq_,module,exports){
- var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
- var TO_STRING_TAG = wellKnownSymbol('toStringTag');
- var test = {};
- test[TO_STRING_TAG] = 'z';
- module.exports = String(test) === '[object z]';
- },{"../internals/well-known-symbol":586}],579:[function(_dereq_,module,exports){
- var global = _dereq_('../internals/global');
- var classof = _dereq_('../internals/classof');
- var String = global.String;
- module.exports = function (argument) {
- if (classof(argument) === 'Symbol') throw TypeError('Cannot convert a Symbol value to a string');
- return String(argument);
- };
- },{"../internals/classof":443,"../internals/global":491}],580:[function(_dereq_,module,exports){
- var global = _dereq_('../internals/global');
- var String = global.String;
- module.exports = function (argument) {
- try {
- return String(argument);
- } catch (error) {
- return 'Object';
- }
- };
- },{"../internals/global":491}],581:[function(_dereq_,module,exports){
- var uncurryThis = _dereq_('../internals/function-uncurry-this');
- var id = 0;
- var postfix = Math.random();
- var toString = uncurryThis(1.0.toString);
- module.exports = function (key) {
- return 'Symbol(' + (key === undefined ? '' : key) + ')_' + toString(++id + postfix, 36);
- };
- },{"../internals/function-uncurry-this":485}],582:[function(_dereq_,module,exports){
- /* eslint-disable es/no-symbol -- required for testing */
- var NATIVE_SYMBOL = _dereq_('../internals/native-symbol');
- module.exports = NATIVE_SYMBOL
- && !Symbol.sham
- && typeof Symbol.iterator == 'symbol';
- },{"../internals/native-symbol":522}],583:[function(_dereq_,module,exports){
- var DESCRIPTORS = _dereq_('../internals/descriptors');
- var fails = _dereq_('../internals/fails');
- // V8 ~ Chrome 36-
- // https://bugs.chromium.org/p/v8/issues/detail?id=3334
- module.exports = DESCRIPTORS && fails(function () {
- // eslint-disable-next-line es/no-object-defineproperty -- required for testing
- return Object.defineProperty(function () { /* empty */ }, 'prototype', {
- value: 42,
- writable: false
- }).prototype != 42;
- });
- },{"../internals/descriptors":460,"../internals/fails":477}],584:[function(_dereq_,module,exports){
- var global = _dereq_('../internals/global');
- var TypeError = global.TypeError;
- module.exports = function (passed, required) {
- if (passed < required) throw TypeError('Not enough arguments');
- return passed;
- };
- },{"../internals/global":491}],585:[function(_dereq_,module,exports){
- var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
- exports.f = wellKnownSymbol;
- },{"../internals/well-known-symbol":586}],586:[function(_dereq_,module,exports){
- var global = _dereq_('../internals/global');
- var shared = _dereq_('../internals/shared');
- var hasOwn = _dereq_('../internals/has-own-property');
- var uid = _dereq_('../internals/uid');
- var NATIVE_SYMBOL = _dereq_('../internals/native-symbol');
- var USE_SYMBOL_AS_UID = _dereq_('../internals/use-symbol-as-uid');
- var WellKnownSymbolsStore = shared('wks');
- var Symbol = global.Symbol;
- var symbolFor = Symbol && Symbol['for'];
- var createWellKnownSymbol = USE_SYMBOL_AS_UID ? Symbol : Symbol && Symbol.withoutSetter || uid;
- module.exports = function (name) {
- if (!hasOwn(WellKnownSymbolsStore, name) || !(NATIVE_SYMBOL || typeof WellKnownSymbolsStore[name] == 'string')) {
- var description = 'Symbol.' + name;
- if (NATIVE_SYMBOL && hasOwn(Symbol, name)) {
- WellKnownSymbolsStore[name] = Symbol[name];
- } else if (USE_SYMBOL_AS_UID && symbolFor) {
- WellKnownSymbolsStore[name] = symbolFor(description);
- } else {
- WellKnownSymbolsStore[name] = createWellKnownSymbol(description);
- }
- } return WellKnownSymbolsStore[name];
- };
- },{"../internals/global":491,"../internals/has-own-property":492,"../internals/native-symbol":522,"../internals/shared":561,"../internals/uid":581,"../internals/use-symbol-as-uid":582}],587:[function(_dereq_,module,exports){
- // a string of all valid unicode whitespaces
- module.exports = '\u0009\u000A\u000B\u000C\u000D\u0020\u00A0\u1680\u2000\u2001\u2002' +
- '\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF';
- },{}],588:[function(_dereq_,module,exports){
- 'use strict';
- var $ = _dereq_('../internals/export');
- var global = _dereq_('../internals/global');
- var isPrototypeOf = _dereq_('../internals/object-is-prototype-of');
- var getPrototypeOf = _dereq_('../internals/object-get-prototype-of');
- var setPrototypeOf = _dereq_('../internals/object-set-prototype-of');
- var copyConstructorProperties = _dereq_('../internals/copy-constructor-properties');
- var create = _dereq_('../internals/object-create');
- var createNonEnumerableProperty = _dereq_('../internals/create-non-enumerable-property');
- var createPropertyDescriptor = _dereq_('../internals/create-property-descriptor');
- var clearErrorStack = _dereq_('../internals/clear-error-stack');
- var installErrorCause = _dereq_('../internals/install-error-cause');
- var iterate = _dereq_('../internals/iterate');
- var normalizeStringArgument = _dereq_('../internals/normalize-string-argument');
- var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
- var ERROR_STACK_INSTALLABLE = _dereq_('../internals/error-stack-installable');
- var TO_STRING_TAG = wellKnownSymbol('toStringTag');
- var Error = global.Error;
- var push = [].push;
- var $AggregateError = function AggregateError(errors, message /* , options */) {
- var options = arguments.length > 2 ? arguments[2] : undefined;
- var isInstance = isPrototypeOf(AggregateErrorPrototype, this);
- var that;
- if (setPrototypeOf) {
- that = setPrototypeOf(new Error(), isInstance ? getPrototypeOf(this) : AggregateErrorPrototype);
- } else {
- that = isInstance ? this : create(AggregateErrorPrototype);
- createNonEnumerableProperty(that, TO_STRING_TAG, 'Error');
- }
- if (message !== undefined) createNonEnumerableProperty(that, 'message', normalizeStringArgument(message));
- if (ERROR_STACK_INSTALLABLE) createNonEnumerableProperty(that, 'stack', clearErrorStack(that.stack, 1));
- installErrorCause(that, options);
- var errorsArray = [];
- iterate(errors, push, { that: errorsArray });
- createNonEnumerableProperty(that, 'errors', errorsArray);
- return that;
- };
- if (setPrototypeOf) setPrototypeOf($AggregateError, Error);
- else copyConstructorProperties($AggregateError, Error, { name: true });
- var AggregateErrorPrototype = $AggregateError.prototype = create(Error.prototype, {
- constructor: createPropertyDescriptor(1, $AggregateError),
- message: createPropertyDescriptor(1, ''),
- name: createPropertyDescriptor(1, 'AggregateError')
- });
- // `AggregateError` constructor
- // https://tc39.es/ecma262/#sec-aggregate-error-constructor
- $({ global: true }, {
- AggregateError: $AggregateError
- });
- },{"../internals/clear-error-stack":444,"../internals/copy-constructor-properties":451,"../internals/create-non-enumerable-property":455,"../internals/create-property-descriptor":456,"../internals/error-stack-installable":475,"../internals/export":476,"../internals/global":491,"../internals/install-error-cause":499,"../internals/iterate":513,"../internals/normalize-string-argument":526,"../internals/object-create":530,"../internals/object-get-prototype-of":537,"../internals/object-is-prototype-of":539,"../internals/object-set-prototype-of":543,"../internals/well-known-symbol":586}],589:[function(_dereq_,module,exports){
- 'use strict';
- var $ = _dereq_('../internals/export');
- var global = _dereq_('../internals/global');
- var fails = _dereq_('../internals/fails');
- var isArray = _dereq_('../internals/is-array');
- var isObject = _dereq_('../internals/is-object');
- var toObject = _dereq_('../internals/to-object');
- var lengthOfArrayLike = _dereq_('../internals/length-of-array-like');
- var createProperty = _dereq_('../internals/create-property');
- var arraySpeciesCreate = _dereq_('../internals/array-species-create');
- var arrayMethodHasSpeciesSupport = _dereq_('../internals/array-method-has-species-support');
- var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
- var V8_VERSION = _dereq_('../internals/engine-v8-version');
- var IS_CONCAT_SPREADABLE = wellKnownSymbol('isConcatSpreadable');
- var MAX_SAFE_INTEGER = 0x1FFFFFFFFFFFFF;
- var MAXIMUM_ALLOWED_INDEX_EXCEEDED = 'Maximum allowed index exceeded';
- var TypeError = global.TypeError;
- // We can't use this feature detection in V8 since it causes
- // deoptimization and serious performance degradation
- // https://github.com/zloirock/core-js/issues/679
- var IS_CONCAT_SPREADABLE_SUPPORT = V8_VERSION >= 51 || !fails(function () {
- var array = [];
- array[IS_CONCAT_SPREADABLE] = false;
- return array.concat()[0] !== array;
- });
- var SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('concat');
- var isConcatSpreadable = function (O) {
- if (!isObject(O)) return false;
- var spreadable = O[IS_CONCAT_SPREADABLE];
- return spreadable !== undefined ? !!spreadable : isArray(O);
- };
- var FORCED = !IS_CONCAT_SPREADABLE_SUPPORT || !SPECIES_SUPPORT;
- // `Array.prototype.concat` method
- // https://tc39.es/ecma262/#sec-array.prototype.concat
- // with adding support of @@isConcatSpreadable and @@species
- $({ target: 'Array', proto: true, forced: FORCED }, {
- // eslint-disable-next-line no-unused-vars -- required for `.length`
- concat: function concat(arg) {
- var O = toObject(this);
- var A = arraySpeciesCreate(O, 0);
- var n = 0;
- var i, k, length, len, E;
- for (i = -1, length = arguments.length; i < length; i++) {
- E = i === -1 ? O : arguments[i];
- if (isConcatSpreadable(E)) {
- len = lengthOfArrayLike(E);
- if (n + len > MAX_SAFE_INTEGER) throw TypeError(MAXIMUM_ALLOWED_INDEX_EXCEEDED);
- for (k = 0; k < len; k++, n++) if (k in E) createProperty(A, n, E[k]);
- } else {
- if (n >= MAX_SAFE_INTEGER) throw TypeError(MAXIMUM_ALLOWED_INDEX_EXCEEDED);
- createProperty(A, n++, E);
- }
- }
- A.length = n;
- return A;
- }
- });
- },{"../internals/array-method-has-species-support":432,"../internals/array-species-create":439,"../internals/create-property":457,"../internals/engine-v8-version":471,"../internals/export":476,"../internals/fails":477,"../internals/global":491,"../internals/is-array":503,"../internals/is-object":509,"../internals/length-of-array-like":517,"../internals/to-object":575,"../internals/well-known-symbol":586}],590:[function(_dereq_,module,exports){
- 'use strict';
- var $ = _dereq_('../internals/export');
- var $every = _dereq_('../internals/array-iteration').every;
- var arrayMethodIsStrict = _dereq_('../internals/array-method-is-strict');
- var STRICT_METHOD = arrayMethodIsStrict('every');
- // `Array.prototype.every` method
- // https://tc39.es/ecma262/#sec-array.prototype.every
- $({ target: 'Array', proto: true, forced: !STRICT_METHOD }, {
- every: function every(callbackfn /* , thisArg */) {
- return $every(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
- }
- });
- },{"../internals/array-iteration":431,"../internals/array-method-is-strict":433,"../internals/export":476}],591:[function(_dereq_,module,exports){
- 'use strict';
- var $ = _dereq_('../internals/export');
- var $filter = _dereq_('../internals/array-iteration').filter;
- var arrayMethodHasSpeciesSupport = _dereq_('../internals/array-method-has-species-support');
- var HAS_SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('filter');
- // `Array.prototype.filter` method
- // https://tc39.es/ecma262/#sec-array.prototype.filter
- // with adding support of @@species
- $({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT }, {
- filter: function filter(callbackfn /* , thisArg */) {
- return $filter(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
- }
- });
- },{"../internals/array-iteration":431,"../internals/array-method-has-species-support":432,"../internals/export":476}],592:[function(_dereq_,module,exports){
- 'use strict';
- var $ = _dereq_('../internals/export');
- var $find = _dereq_('../internals/array-iteration').find;
- var addToUnscopables = _dereq_('../internals/add-to-unscopables');
- var FIND = 'find';
- var SKIPS_HOLES = true;
- // Shouldn't skip holes
- if (FIND in []) Array(1)[FIND](function () { SKIPS_HOLES = false; });
- // `Array.prototype.find` method
- // https://tc39.es/ecma262/#sec-array.prototype.find
- $({ target: 'Array', proto: true, forced: SKIPS_HOLES }, {
- find: function find(callbackfn /* , that = undefined */) {
- return $find(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
- }
- });
- // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
- addToUnscopables(FIND);
- },{"../internals/add-to-unscopables":424,"../internals/array-iteration":431,"../internals/export":476}],593:[function(_dereq_,module,exports){
- 'use strict';
- var $ = _dereq_('../internals/export');
- var forEach = _dereq_('../internals/array-for-each');
- // `Array.prototype.forEach` method
- // https://tc39.es/ecma262/#sec-array.prototype.foreach
- // eslint-disable-next-line es/no-array-prototype-foreach -- safe
- $({ target: 'Array', proto: true, forced: [].forEach != forEach }, {
- forEach: forEach
- });
- },{"../internals/array-for-each":428,"../internals/export":476}],594:[function(_dereq_,module,exports){
- var $ = _dereq_('../internals/export');
- var from = _dereq_('../internals/array-from');
- var checkCorrectnessOfIteration = _dereq_('../internals/check-correctness-of-iteration');
- var INCORRECT_ITERATION = !checkCorrectnessOfIteration(function (iterable) {
- // eslint-disable-next-line es/no-array-from -- required for testing
- Array.from(iterable);
- });
- // `Array.from` method
- // https://tc39.es/ecma262/#sec-array.from
- $({ target: 'Array', stat: true, forced: INCORRECT_ITERATION }, {
- from: from
- });
- },{"../internals/array-from":429,"../internals/check-correctness-of-iteration":441,"../internals/export":476}],595:[function(_dereq_,module,exports){
- 'use strict';
- var $ = _dereq_('../internals/export');
- var $includes = _dereq_('../internals/array-includes').includes;
- var addToUnscopables = _dereq_('../internals/add-to-unscopables');
- // `Array.prototype.includes` method
- // https://tc39.es/ecma262/#sec-array.prototype.includes
- $({ target: 'Array', proto: true }, {
- includes: function includes(el /* , fromIndex = 0 */) {
- return $includes(this, el, arguments.length > 1 ? arguments[1] : undefined);
- }
- });
- // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
- addToUnscopables('includes');
- },{"../internals/add-to-unscopables":424,"../internals/array-includes":430,"../internals/export":476}],596:[function(_dereq_,module,exports){
- 'use strict';
- /* eslint-disable es/no-array-prototype-indexof -- required for testing */
- var $ = _dereq_('../internals/export');
- var uncurryThis = _dereq_('../internals/function-uncurry-this');
- var $IndexOf = _dereq_('../internals/array-includes').indexOf;
- var arrayMethodIsStrict = _dereq_('../internals/array-method-is-strict');
- var un$IndexOf = uncurryThis([].indexOf);
- var NEGATIVE_ZERO = !!un$IndexOf && 1 / un$IndexOf([1], 1, -0) < 0;
- var STRICT_METHOD = arrayMethodIsStrict('indexOf');
- // `Array.prototype.indexOf` method
- // https://tc39.es/ecma262/#sec-array.prototype.indexof
- $({ target: 'Array', proto: true, forced: NEGATIVE_ZERO || !STRICT_METHOD }, {
- indexOf: function indexOf(searchElement /* , fromIndex = 0 */) {
- var fromIndex = arguments.length > 1 ? arguments[1] : undefined;
- return NEGATIVE_ZERO
- // convert -0 to +0
- ? un$IndexOf(this, searchElement, fromIndex) || 0
- : $IndexOf(this, searchElement, fromIndex);
- }
- });
- },{"../internals/array-includes":430,"../internals/array-method-is-strict":433,"../internals/export":476,"../internals/function-uncurry-this":485}],597:[function(_dereq_,module,exports){
- var $ = _dereq_('../internals/export');
- var isArray = _dereq_('../internals/is-array');
- // `Array.isArray` method
- // https://tc39.es/ecma262/#sec-array.isarray
- $({ target: 'Array', stat: true }, {
- isArray: isArray
- });
- },{"../internals/export":476,"../internals/is-array":503}],598:[function(_dereq_,module,exports){
- 'use strict';
- var toIndexedObject = _dereq_('../internals/to-indexed-object');
- var addToUnscopables = _dereq_('../internals/add-to-unscopables');
- var Iterators = _dereq_('../internals/iterators');
- var InternalStateModule = _dereq_('../internals/internal-state');
- var defineProperty = _dereq_('../internals/object-define-property').f;
- var defineIterator = _dereq_('../internals/define-iterator');
- var IS_PURE = _dereq_('../internals/is-pure');
- var DESCRIPTORS = _dereq_('../internals/descriptors');
- var ARRAY_ITERATOR = 'Array Iterator';
- var setInternalState = InternalStateModule.set;
- var getInternalState = InternalStateModule.getterFor(ARRAY_ITERATOR);
- // `Array.prototype.entries` method
- // https://tc39.es/ecma262/#sec-array.prototype.entries
- // `Array.prototype.keys` method
- // https://tc39.es/ecma262/#sec-array.prototype.keys
- // `Array.prototype.values` method
- // https://tc39.es/ecma262/#sec-array.prototype.values
- // `Array.prototype[@@iterator]` method
- // https://tc39.es/ecma262/#sec-array.prototype-@@iterator
- // `CreateArrayIterator` internal method
- // https://tc39.es/ecma262/#sec-createarrayiterator
- module.exports = defineIterator(Array, 'Array', function (iterated, kind) {
- setInternalState(this, {
- type: ARRAY_ITERATOR,
- target: toIndexedObject(iterated), // target
- index: 0, // next index
- kind: kind // kind
- });
- // `%ArrayIteratorPrototype%.next` method
- // https://tc39.es/ecma262/#sec-%arrayiteratorprototype%.next
- }, function () {
- var state = getInternalState(this);
- var target = state.target;
- var kind = state.kind;
- var index = state.index++;
- if (!target || index >= target.length) {
- state.target = undefined;
- return { value: undefined, done: true };
- }
- if (kind == 'keys') return { value: index, done: false };
- if (kind == 'values') return { value: target[index], done: false };
- return { value: [index, target[index]], done: false };
- }, 'values');
- // argumentsList[@@iterator] is %ArrayProto_values%
- // https://tc39.es/ecma262/#sec-createunmappedargumentsobject
- // https://tc39.es/ecma262/#sec-createmappedargumentsobject
- var values = Iterators.Arguments = Iterators.Array;
- // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
- addToUnscopables('keys');
- addToUnscopables('values');
- addToUnscopables('entries');
- // V8 ~ Chrome 45- bug
- if (!IS_PURE && DESCRIPTORS && values.name !== 'values') try {
- defineProperty(values, 'name', { value: 'values' });
- } catch (error) { /* empty */ }
- },{"../internals/add-to-unscopables":424,"../internals/define-iterator":458,"../internals/descriptors":460,"../internals/internal-state":501,"../internals/is-pure":510,"../internals/iterators":516,"../internals/object-define-property":532,"../internals/to-indexed-object":572}],599:[function(_dereq_,module,exports){
- 'use strict';
- var $ = _dereq_('../internals/export');
- var $map = _dereq_('../internals/array-iteration').map;
- var arrayMethodHasSpeciesSupport = _dereq_('../internals/array-method-has-species-support');
- var HAS_SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('map');
- // `Array.prototype.map` method
- // https://tc39.es/ecma262/#sec-array.prototype.map
- // with adding support of @@species
- $({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT }, {
- map: function map(callbackfn /* , thisArg */) {
- return $map(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
- }
- });
- },{"../internals/array-iteration":431,"../internals/array-method-has-species-support":432,"../internals/export":476}],600:[function(_dereq_,module,exports){
- 'use strict';
- var $ = _dereq_('../internals/export');
- var $reduce = _dereq_('../internals/array-reduce').left;
- var arrayMethodIsStrict = _dereq_('../internals/array-method-is-strict');
- var CHROME_VERSION = _dereq_('../internals/engine-v8-version');
- var IS_NODE = _dereq_('../internals/engine-is-node');
- var STRICT_METHOD = arrayMethodIsStrict('reduce');
- // Chrome 80-82 has a critical bug
- // https://bugs.chromium.org/p/chromium/issues/detail?id=1049982
- var CHROME_BUG = !IS_NODE && CHROME_VERSION > 79 && CHROME_VERSION < 83;
- // `Array.prototype.reduce` method
- // https://tc39.es/ecma262/#sec-array.prototype.reduce
- $({ target: 'Array', proto: true, forced: !STRICT_METHOD || CHROME_BUG }, {
- reduce: function reduce(callbackfn /* , initialValue */) {
- var length = arguments.length;
- return $reduce(this, callbackfn, length, length > 1 ? arguments[1] : undefined);
- }
- });
- },{"../internals/array-method-is-strict":433,"../internals/array-reduce":434,"../internals/engine-is-node":468,"../internals/engine-v8-version":471,"../internals/export":476}],601:[function(_dereq_,module,exports){
- 'use strict';
- var $ = _dereq_('../internals/export');
- var global = _dereq_('../internals/global');
- var isArray = _dereq_('../internals/is-array');
- var isConstructor = _dereq_('../internals/is-constructor');
- var isObject = _dereq_('../internals/is-object');
- var toAbsoluteIndex = _dereq_('../internals/to-absolute-index');
- var lengthOfArrayLike = _dereq_('../internals/length-of-array-like');
- var toIndexedObject = _dereq_('../internals/to-indexed-object');
- var createProperty = _dereq_('../internals/create-property');
- var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
- var arrayMethodHasSpeciesSupport = _dereq_('../internals/array-method-has-species-support');
- var un$Slice = _dereq_('../internals/array-slice');
- var HAS_SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('slice');
- var SPECIES = wellKnownSymbol('species');
- var Array = global.Array;
- var max = Math.max;
- // `Array.prototype.slice` method
- // https://tc39.es/ecma262/#sec-array.prototype.slice
- // fallback for not array-like ES3 strings and DOM objects
- $({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT }, {
- slice: function slice(start, end) {
- var O = toIndexedObject(this);
- var length = lengthOfArrayLike(O);
- var k = toAbsoluteIndex(start, length);
- var fin = toAbsoluteIndex(end === undefined ? length : end, length);
- // inline `ArraySpeciesCreate` for usage native `Array#slice` where it's possible
- var Constructor, result, n;
- if (isArray(O)) {
- Constructor = O.constructor;
- // cross-realm fallback
- if (isConstructor(Constructor) && (Constructor === Array || isArray(Constructor.prototype))) {
- Constructor = undefined;
- } else if (isObject(Constructor)) {
- Constructor = Constructor[SPECIES];
- if (Constructor === null) Constructor = undefined;
- }
- if (Constructor === Array || Constructor === undefined) {
- return un$Slice(O, k, fin);
- }
- }
- result = new (Constructor === undefined ? Array : Constructor)(max(fin - k, 0));
- for (n = 0; k < fin; k++, n++) if (k in O) createProperty(result, n, O[k]);
- result.length = n;
- return result;
- }
- });
- },{"../internals/array-method-has-species-support":432,"../internals/array-slice":436,"../internals/create-property":457,"../internals/export":476,"../internals/global":491,"../internals/is-array":503,"../internals/is-constructor":505,"../internals/is-object":509,"../internals/length-of-array-like":517,"../internals/to-absolute-index":571,"../internals/to-indexed-object":572,"../internals/well-known-symbol":586}],602:[function(_dereq_,module,exports){
- 'use strict';
- var $ = _dereq_('../internals/export');
- var uncurryThis = _dereq_('../internals/function-uncurry-this');
- var aCallable = _dereq_('../internals/a-callable');
- var toObject = _dereq_('../internals/to-object');
- var lengthOfArrayLike = _dereq_('../internals/length-of-array-like');
- var toString = _dereq_('../internals/to-string');
- var fails = _dereq_('../internals/fails');
- var internalSort = _dereq_('../internals/array-sort');
- var arrayMethodIsStrict = _dereq_('../internals/array-method-is-strict');
- var FF = _dereq_('../internals/engine-ff-version');
- var IE_OR_EDGE = _dereq_('../internals/engine-is-ie-or-edge');
- var V8 = _dereq_('../internals/engine-v8-version');
- var WEBKIT = _dereq_('../internals/engine-webkit-version');
- var test = [];
- var un$Sort = uncurryThis(test.sort);
- var push = uncurryThis(test.push);
- // IE8-
- var FAILS_ON_UNDEFINED = fails(function () {
- test.sort(undefined);
- });
- // V8 bug
- var FAILS_ON_NULL = fails(function () {
- test.sort(null);
- });
- // Old WebKit
- var STRICT_METHOD = arrayMethodIsStrict('sort');
- var STABLE_SORT = !fails(function () {
- // feature detection can be too slow, so check engines versions
- if (V8) return V8 < 70;
- if (FF && FF > 3) return;
- if (IE_OR_EDGE) return true;
- if (WEBKIT) return WEBKIT < 603;
- var result = '';
- var code, chr, value, index;
- // generate an array with more 512 elements (Chakra and old V8 fails only in this case)
- for (code = 65; code < 76; code++) {
- chr = String.fromCharCode(code);
- switch (code) {
- case 66: case 69: case 70: case 72: value = 3; break;
- case 68: case 71: value = 4; break;
- default: value = 2;
- }
- for (index = 0; index < 47; index++) {
- test.push({ k: chr + index, v: value });
- }
- }
- test.sort(function (a, b) { return b.v - a.v; });
- for (index = 0; index < test.length; index++) {
- chr = test[index].k.charAt(0);
- if (result.charAt(result.length - 1) !== chr) result += chr;
- }
- return result !== 'DGBEFHACIJK';
- });
- var FORCED = FAILS_ON_UNDEFINED || !FAILS_ON_NULL || !STRICT_METHOD || !STABLE_SORT;
- var getSortCompare = function (comparefn) {
- return function (x, y) {
- if (y === undefined) return -1;
- if (x === undefined) return 1;
- if (comparefn !== undefined) return +comparefn(x, y) || 0;
- return toString(x) > toString(y) ? 1 : -1;
- };
- };
- // `Array.prototype.sort` method
- // https://tc39.es/ecma262/#sec-array.prototype.sort
- $({ target: 'Array', proto: true, forced: FORCED }, {
- sort: function sort(comparefn) {
- if (comparefn !== undefined) aCallable(comparefn);
- var array = toObject(this);
- if (STABLE_SORT) return comparefn === undefined ? un$Sort(array) : un$Sort(array, comparefn);
- var items = [];
- var arrayLength = lengthOfArrayLike(array);
- var itemsLength, index;
- for (index = 0; index < arrayLength; index++) {
- if (index in array) push(items, array[index]);
- }
- internalSort(items, getSortCompare(comparefn));
- itemsLength = items.length;
- index = 0;
- while (index < itemsLength) array[index] = items[index++];
- while (index < arrayLength) delete array[index++];
- return array;
- }
- });
- },{"../internals/a-callable":421,"../internals/array-method-is-strict":433,"../internals/array-sort":437,"../internals/engine-ff-version":463,"../internals/engine-is-ie-or-edge":465,"../internals/engine-v8-version":471,"../internals/engine-webkit-version":472,"../internals/export":476,"../internals/fails":477,"../internals/function-uncurry-this":485,"../internals/length-of-array-like":517,"../internals/to-object":575,"../internals/to-string":579}],603:[function(_dereq_,module,exports){
- 'use strict';
- var $ = _dereq_('../internals/export');
- var global = _dereq_('../internals/global');
- var toAbsoluteIndex = _dereq_('../internals/to-absolute-index');
- var toIntegerOrInfinity = _dereq_('../internals/to-integer-or-infinity');
- var lengthOfArrayLike = _dereq_('../internals/length-of-array-like');
- var toObject = _dereq_('../internals/to-object');
- var arraySpeciesCreate = _dereq_('../internals/array-species-create');
- var createProperty = _dereq_('../internals/create-property');
- var arrayMethodHasSpeciesSupport = _dereq_('../internals/array-method-has-species-support');
- var HAS_SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('splice');
- var TypeError = global.TypeError;
- var max = Math.max;
- var min = Math.min;
- var MAX_SAFE_INTEGER = 0x1FFFFFFFFFFFFF;
- var MAXIMUM_ALLOWED_LENGTH_EXCEEDED = 'Maximum allowed length exceeded';
- // `Array.prototype.splice` method
- // https://tc39.es/ecma262/#sec-array.prototype.splice
- // with adding support of @@species
- $({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT }, {
- splice: function splice(start, deleteCount /* , ...items */) {
- var O = toObject(this);
- var len = lengthOfArrayLike(O);
- var actualStart = toAbsoluteIndex(start, len);
- var argumentsLength = arguments.length;
- var insertCount, actualDeleteCount, A, k, from, to;
- if (argumentsLength === 0) {
- insertCount = actualDeleteCount = 0;
- } else if (argumentsLength === 1) {
- insertCount = 0;
- actualDeleteCount = len - actualStart;
- } else {
- insertCount = argumentsLength - 2;
- actualDeleteCount = min(max(toIntegerOrInfinity(deleteCount), 0), len - actualStart);
- }
- if (len + insertCount - actualDeleteCount > MAX_SAFE_INTEGER) {
- throw TypeError(MAXIMUM_ALLOWED_LENGTH_EXCEEDED);
- }
- A = arraySpeciesCreate(O, actualDeleteCount);
- for (k = 0; k < actualDeleteCount; k++) {
- from = actualStart + k;
- if (from in O) createProperty(A, k, O[from]);
- }
- A.length = actualDeleteCount;
- if (insertCount < actualDeleteCount) {
- for (k = actualStart; k < len - actualDeleteCount; k++) {
- from = k + actualDeleteCount;
- to = k + insertCount;
- if (from in O) O[to] = O[from];
- else delete O[to];
- }
- for (k = len; k > len - actualDeleteCount + insertCount; k--) delete O[k - 1];
- } else if (insertCount > actualDeleteCount) {
- for (k = len - actualDeleteCount; k > actualStart; k--) {
- from = k + actualDeleteCount - 1;
- to = k + insertCount - 1;
- if (from in O) O[to] = O[from];
- else delete O[to];
- }
- }
- for (k = 0; k < insertCount; k++) {
- O[k + actualStart] = arguments[k + 2];
- }
- O.length = len - actualDeleteCount + insertCount;
- return A;
- }
- });
- },{"../internals/array-method-has-species-support":432,"../internals/array-species-create":439,"../internals/create-property":457,"../internals/export":476,"../internals/global":491,"../internals/length-of-array-like":517,"../internals/to-absolute-index":571,"../internals/to-integer-or-infinity":573,"../internals/to-object":575}],604:[function(_dereq_,module,exports){
- var $ = _dereq_('../internals/export');
- var bind = _dereq_('../internals/function-bind');
- // `Function.prototype.bind` method
- // https://tc39.es/ecma262/#sec-function.prototype.bind
- $({ target: 'Function', proto: true, forced: Function.bind !== bind }, {
- bind: bind
- });
- },{"../internals/export":476,"../internals/function-bind":482}],605:[function(_dereq_,module,exports){
- var $ = _dereq_('../internals/export');
- var global = _dereq_('../internals/global');
- var getBuiltIn = _dereq_('../internals/get-built-in');
- var apply = _dereq_('../internals/function-apply');
- var uncurryThis = _dereq_('../internals/function-uncurry-this');
- var fails = _dereq_('../internals/fails');
- var Array = global.Array;
- var $stringify = getBuiltIn('JSON', 'stringify');
- var exec = uncurryThis(/./.exec);
- var charAt = uncurryThis(''.charAt);
- var charCodeAt = uncurryThis(''.charCodeAt);
- var replace = uncurryThis(''.replace);
- var numberToString = uncurryThis(1.0.toString);
- var tester = /[\uD800-\uDFFF]/g;
- var low = /^[\uD800-\uDBFF]$/;
- var hi = /^[\uDC00-\uDFFF]$/;
- var fix = function (match, offset, string) {
- var prev = charAt(string, offset - 1);
- var next = charAt(string, offset + 1);
- if ((exec(low, match) && !exec(hi, next)) || (exec(hi, match) && !exec(low, prev))) {
- return '\\u' + numberToString(charCodeAt(match, 0), 16);
- } return match;
- };
- var FORCED = fails(function () {
- return $stringify('\uDF06\uD834') !== '"\\udf06\\ud834"'
- || $stringify('\uDEAD') !== '"\\udead"';
- });
- if ($stringify) {
- // `JSON.stringify` method
- // https://tc39.es/ecma262/#sec-json.stringify
- // https://github.com/tc39/proposal-well-formed-stringify
- $({ target: 'JSON', stat: true, forced: FORCED }, {
- // eslint-disable-next-line no-unused-vars -- required for `.length`
- stringify: function stringify(it, replacer, space) {
- for (var i = 0, l = arguments.length, args = Array(l); i < l; i++) args[i] = arguments[i];
- var result = apply($stringify, null, args);
- return typeof result == 'string' ? replace(result, tester, fix) : result;
- }
- });
- }
- },{"../internals/export":476,"../internals/fails":477,"../internals/function-apply":479,"../internals/function-uncurry-this":485,"../internals/get-built-in":486,"../internals/global":491}],606:[function(_dereq_,module,exports){
- var global = _dereq_('../internals/global');
- var setToStringTag = _dereq_('../internals/set-to-string-tag');
- // JSON[@@toStringTag] property
- // https://tc39.es/ecma262/#sec-json-@@tostringtag
- setToStringTag(global.JSON, 'JSON', true);
- },{"../internals/global":491,"../internals/set-to-string-tag":558}],607:[function(_dereq_,module,exports){
- 'use strict';
- var collection = _dereq_('../internals/collection');
- var collectionStrong = _dereq_('../internals/collection-strong');
- // `Map` constructor
- // https://tc39.es/ecma262/#sec-map-objects
- collection('Map', function (init) {
- return function Map() { return init(this, arguments.length ? arguments[0] : undefined); };
- }, collectionStrong);
- },{"../internals/collection":450,"../internals/collection-strong":448}],608:[function(_dereq_,module,exports){
- // empty
- },{}],609:[function(_dereq_,module,exports){
- var $ = _dereq_('../internals/export');
- var isIntegralNumber = _dereq_('../internals/is-integral-number');
- // `Number.isInteger` method
- // https://tc39.es/ecma262/#sec-number.isinteger
- $({ target: 'Number', stat: true }, {
- isInteger: isIntegralNumber
- });
- },{"../internals/export":476,"../internals/is-integral-number":508}],610:[function(_dereq_,module,exports){
- var $ = _dereq_('../internals/export');
- // `Number.isNaN` method
- // https://tc39.es/ecma262/#sec-number.isnan
- $({ target: 'Number', stat: true }, {
- isNaN: function isNaN(number) {
- // eslint-disable-next-line no-self-compare -- NaN check
- return number != number;
- }
- });
- },{"../internals/export":476}],611:[function(_dereq_,module,exports){
- var $ = _dereq_('../internals/export');
- var DESCRIPTORS = _dereq_('../internals/descriptors');
- var create = _dereq_('../internals/object-create');
- // `Object.create` method
- // https://tc39.es/ecma262/#sec-object.create
- $({ target: 'Object', stat: true, sham: !DESCRIPTORS }, {
- create: create
- });
- },{"../internals/descriptors":460,"../internals/export":476,"../internals/object-create":530}],612:[function(_dereq_,module,exports){
- var $ = _dereq_('../internals/export');
- var DESCRIPTORS = _dereq_('../internals/descriptors');
- var defineProperties = _dereq_('../internals/object-define-properties').f;
- // `Object.defineProperties` method
- // https://tc39.es/ecma262/#sec-object.defineproperties
- // eslint-disable-next-line es/no-object-defineproperties -- safe
- $({ target: 'Object', stat: true, forced: Object.defineProperties !== defineProperties, sham: !DESCRIPTORS }, {
- defineProperties: defineProperties
- });
- },{"../internals/descriptors":460,"../internals/export":476,"../internals/object-define-properties":531}],613:[function(_dereq_,module,exports){
- var $ = _dereq_('../internals/export');
- var DESCRIPTORS = _dereq_('../internals/descriptors');
- var defineProperty = _dereq_('../internals/object-define-property').f;
- // `Object.defineProperty` method
- // https://tc39.es/ecma262/#sec-object.defineproperty
- // eslint-disable-next-line es/no-object-defineproperty -- safe
- $({ target: 'Object', stat: true, forced: Object.defineProperty !== defineProperty, sham: !DESCRIPTORS }, {
- defineProperty: defineProperty
- });
- },{"../internals/descriptors":460,"../internals/export":476,"../internals/object-define-property":532}],614:[function(_dereq_,module,exports){
- var $ = _dereq_('../internals/export');
- var $entries = _dereq_('../internals/object-to-array').entries;
- // `Object.entries` method
- // https://tc39.es/ecma262/#sec-object.entries
- $({ target: 'Object', stat: true }, {
- entries: function entries(O) {
- return $entries(O);
- }
- });
- },{"../internals/export":476,"../internals/object-to-array":544}],615:[function(_dereq_,module,exports){
- var $ = _dereq_('../internals/export');
- var FREEZING = _dereq_('../internals/freezing');
- var fails = _dereq_('../internals/fails');
- var isObject = _dereq_('../internals/is-object');
- var onFreeze = _dereq_('../internals/internal-metadata').onFreeze;
- // eslint-disable-next-line es/no-object-freeze -- safe
- var $freeze = Object.freeze;
- var FAILS_ON_PRIMITIVES = fails(function () { $freeze(1); });
- // `Object.freeze` method
- // https://tc39.es/ecma262/#sec-object.freeze
- $({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES, sham: !FREEZING }, {
- freeze: function freeze(it) {
- return $freeze && isObject(it) ? $freeze(onFreeze(it)) : it;
- }
- });
- },{"../internals/export":476,"../internals/fails":477,"../internals/freezing":478,"../internals/internal-metadata":500,"../internals/is-object":509}],616:[function(_dereq_,module,exports){
- var $ = _dereq_('../internals/export');
- var fails = _dereq_('../internals/fails');
- var toIndexedObject = _dereq_('../internals/to-indexed-object');
- var nativeGetOwnPropertyDescriptor = _dereq_('../internals/object-get-own-property-descriptor').f;
- var DESCRIPTORS = _dereq_('../internals/descriptors');
- var FAILS_ON_PRIMITIVES = fails(function () { nativeGetOwnPropertyDescriptor(1); });
- var FORCED = !DESCRIPTORS || FAILS_ON_PRIMITIVES;
- // `Object.getOwnPropertyDescriptor` method
- // https://tc39.es/ecma262/#sec-object.getownpropertydescriptor
- $({ target: 'Object', stat: true, forced: FORCED, sham: !DESCRIPTORS }, {
- getOwnPropertyDescriptor: function getOwnPropertyDescriptor(it, key) {
- return nativeGetOwnPropertyDescriptor(toIndexedObject(it), key);
- }
- });
- },{"../internals/descriptors":460,"../internals/export":476,"../internals/fails":477,"../internals/object-get-own-property-descriptor":533,"../internals/to-indexed-object":572}],617:[function(_dereq_,module,exports){
- var $ = _dereq_('../internals/export');
- var DESCRIPTORS = _dereq_('../internals/descriptors');
- var ownKeys = _dereq_('../internals/own-keys');
- var toIndexedObject = _dereq_('../internals/to-indexed-object');
- var getOwnPropertyDescriptorModule = _dereq_('../internals/object-get-own-property-descriptor');
- var createProperty = _dereq_('../internals/create-property');
- // `Object.getOwnPropertyDescriptors` method
- // https://tc39.es/ecma262/#sec-object.getownpropertydescriptors
- $({ target: 'Object', stat: true, sham: !DESCRIPTORS }, {
- getOwnPropertyDescriptors: function getOwnPropertyDescriptors(object) {
- var O = toIndexedObject(object);
- var getOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;
- var keys = ownKeys(O);
- var result = {};
- var index = 0;
- var key, descriptor;
- while (keys.length > index) {
- descriptor = getOwnPropertyDescriptor(O, key = keys[index++]);
- if (descriptor !== undefined) createProperty(result, key, descriptor);
- }
- return result;
- }
- });
- },{"../internals/create-property":457,"../internals/descriptors":460,"../internals/export":476,"../internals/object-get-own-property-descriptor":533,"../internals/own-keys":547,"../internals/to-indexed-object":572}],618:[function(_dereq_,module,exports){
- var $ = _dereq_('../internals/export');
- var fails = _dereq_('../internals/fails');
- var toObject = _dereq_('../internals/to-object');
- var nativeGetPrototypeOf = _dereq_('../internals/object-get-prototype-of');
- var CORRECT_PROTOTYPE_GETTER = _dereq_('../internals/correct-prototype-getter');
- var FAILS_ON_PRIMITIVES = fails(function () { nativeGetPrototypeOf(1); });
- // `Object.getPrototypeOf` method
- // https://tc39.es/ecma262/#sec-object.getprototypeof
- $({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES, sham: !CORRECT_PROTOTYPE_GETTER }, {
- getPrototypeOf: function getPrototypeOf(it) {
- return nativeGetPrototypeOf(toObject(it));
- }
- });
- },{"../internals/correct-prototype-getter":453,"../internals/export":476,"../internals/fails":477,"../internals/object-get-prototype-of":537,"../internals/to-object":575}],619:[function(_dereq_,module,exports){
- var $ = _dereq_('../internals/export');
- var toObject = _dereq_('../internals/to-object');
- var nativeKeys = _dereq_('../internals/object-keys');
- var fails = _dereq_('../internals/fails');
- var FAILS_ON_PRIMITIVES = fails(function () { nativeKeys(1); });
- // `Object.keys` method
- // https://tc39.es/ecma262/#sec-object.keys
- $({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES }, {
- keys: function keys(it) {
- return nativeKeys(toObject(it));
- }
- });
- },{"../internals/export":476,"../internals/fails":477,"../internals/object-keys":541,"../internals/to-object":575}],620:[function(_dereq_,module,exports){
- var $ = _dereq_('../internals/export');
- var setPrototypeOf = _dereq_('../internals/object-set-prototype-of');
- // `Object.setPrototypeOf` method
- // https://tc39.es/ecma262/#sec-object.setprototypeof
- $({ target: 'Object', stat: true }, {
- setPrototypeOf: setPrototypeOf
- });
- },{"../internals/export":476,"../internals/object-set-prototype-of":543}],621:[function(_dereq_,module,exports){
- arguments[4][608][0].apply(exports,arguments)
- },{"dup":608}],622:[function(_dereq_,module,exports){
- var $ = _dereq_('../internals/export');
- var $values = _dereq_('../internals/object-to-array').values;
- // `Object.values` method
- // https://tc39.es/ecma262/#sec-object.values
- $({ target: 'Object', stat: true }, {
- values: function values(O) {
- return $values(O);
- }
- });
- },{"../internals/export":476,"../internals/object-to-array":544}],623:[function(_dereq_,module,exports){
- var $ = _dereq_('../internals/export');
- var $parseInt = _dereq_('../internals/number-parse-int');
- // `parseInt` method
- // https://tc39.es/ecma262/#sec-parseint-string-radix
- $({ global: true, forced: parseInt != $parseInt }, {
- parseInt: $parseInt
- });
- },{"../internals/export":476,"../internals/number-parse-int":528}],624:[function(_dereq_,module,exports){
- 'use strict';
- var $ = _dereq_('../internals/export');
- var call = _dereq_('../internals/function-call');
- var aCallable = _dereq_('../internals/a-callable');
- var newPromiseCapabilityModule = _dereq_('../internals/new-promise-capability');
- var perform = _dereq_('../internals/perform');
- var iterate = _dereq_('../internals/iterate');
- // `Promise.allSettled` method
- // https://tc39.es/ecma262/#sec-promise.allsettled
- $({ target: 'Promise', stat: true }, {
- allSettled: function allSettled(iterable) {
- var C = this;
- var capability = newPromiseCapabilityModule.f(C);
- var resolve = capability.resolve;
- var reject = capability.reject;
- var result = perform(function () {
- var promiseResolve = aCallable(C.resolve);
- var values = [];
- var counter = 0;
- var remaining = 1;
- iterate(iterable, function (promise) {
- var index = counter++;
- var alreadyCalled = false;
- remaining++;
- call(promiseResolve, C, promise).then(function (value) {
- if (alreadyCalled) return;
- alreadyCalled = true;
- values[index] = { status: 'fulfilled', value: value };
- --remaining || resolve(values);
- }, function (error) {
- if (alreadyCalled) return;
- alreadyCalled = true;
- values[index] = { status: 'rejected', reason: error };
- --remaining || resolve(values);
- });
- });
- --remaining || resolve(values);
- });
- if (result.error) reject(result.value);
- return capability.promise;
- }
- });
- },{"../internals/a-callable":421,"../internals/export":476,"../internals/function-call":483,"../internals/iterate":513,"../internals/new-promise-capability":525,"../internals/perform":549}],625:[function(_dereq_,module,exports){
- 'use strict';
- var $ = _dereq_('../internals/export');
- var aCallable = _dereq_('../internals/a-callable');
- var getBuiltIn = _dereq_('../internals/get-built-in');
- var call = _dereq_('../internals/function-call');
- var newPromiseCapabilityModule = _dereq_('../internals/new-promise-capability');
- var perform = _dereq_('../internals/perform');
- var iterate = _dereq_('../internals/iterate');
- var PROMISE_ANY_ERROR = 'No one promise resolved';
- // `Promise.any` method
- // https://tc39.es/ecma262/#sec-promise.any
- $({ target: 'Promise', stat: true }, {
- any: function any(iterable) {
- var C = this;
- var AggregateError = getBuiltIn('AggregateError');
- var capability = newPromiseCapabilityModule.f(C);
- var resolve = capability.resolve;
- var reject = capability.reject;
- var result = perform(function () {
- var promiseResolve = aCallable(C.resolve);
- var errors = [];
- var counter = 0;
- var remaining = 1;
- var alreadyResolved = false;
- iterate(iterable, function (promise) {
- var index = counter++;
- var alreadyRejected = false;
- remaining++;
- call(promiseResolve, C, promise).then(function (value) {
- if (alreadyRejected || alreadyResolved) return;
- alreadyResolved = true;
- resolve(value);
- }, function (error) {
- if (alreadyRejected || alreadyResolved) return;
- alreadyRejected = true;
- errors[index] = error;
- --remaining || reject(new AggregateError(errors, PROMISE_ANY_ERROR));
- });
- });
- --remaining || reject(new AggregateError(errors, PROMISE_ANY_ERROR));
- });
- if (result.error) reject(result.value);
- return capability.promise;
- }
- });
- },{"../internals/a-callable":421,"../internals/export":476,"../internals/function-call":483,"../internals/get-built-in":486,"../internals/iterate":513,"../internals/new-promise-capability":525,"../internals/perform":549}],626:[function(_dereq_,module,exports){
- 'use strict';
- var $ = _dereq_('../internals/export');
- var IS_PURE = _dereq_('../internals/is-pure');
- var NativePromise = _dereq_('../internals/native-promise-constructor');
- var fails = _dereq_('../internals/fails');
- var getBuiltIn = _dereq_('../internals/get-built-in');
- var isCallable = _dereq_('../internals/is-callable');
- var speciesConstructor = _dereq_('../internals/species-constructor');
- var promiseResolve = _dereq_('../internals/promise-resolve');
- var redefine = _dereq_('../internals/redefine');
- // Safari bug https://bugs.webkit.org/show_bug.cgi?id=200829
- var NON_GENERIC = !!NativePromise && fails(function () {
- // eslint-disable-next-line unicorn/no-thenable -- required for testing
- NativePromise.prototype['finally'].call({ then: function () { /* empty */ } }, function () { /* empty */ });
- });
- // `Promise.prototype.finally` method
- // https://tc39.es/ecma262/#sec-promise.prototype.finally
- $({ target: 'Promise', proto: true, real: true, forced: NON_GENERIC }, {
- 'finally': function (onFinally) {
- var C = speciesConstructor(this, getBuiltIn('Promise'));
- var isFunction = isCallable(onFinally);
- return this.then(
- isFunction ? function (x) {
- return promiseResolve(C, onFinally()).then(function () { return x; });
- } : onFinally,
- isFunction ? function (e) {
- return promiseResolve(C, onFinally()).then(function () { throw e; });
- } : onFinally
- );
- }
- });
- // makes sure that native promise-based APIs `Promise#finally` properly works with patched `Promise#then`
- if (!IS_PURE && isCallable(NativePromise)) {
- var method = getBuiltIn('Promise').prototype['finally'];
- if (NativePromise.prototype['finally'] !== method) {
- redefine(NativePromise.prototype, 'finally', method, { unsafe: true });
- }
- }
- },{"../internals/export":476,"../internals/fails":477,"../internals/get-built-in":486,"../internals/is-callable":504,"../internals/is-pure":510,"../internals/native-promise-constructor":521,"../internals/promise-resolve":550,"../internals/redefine":553,"../internals/species-constructor":562}],627:[function(_dereq_,module,exports){
- 'use strict';
- var $ = _dereq_('../internals/export');
- var IS_PURE = _dereq_('../internals/is-pure');
- var global = _dereq_('../internals/global');
- var getBuiltIn = _dereq_('../internals/get-built-in');
- var call = _dereq_('../internals/function-call');
- var NativePromise = _dereq_('../internals/native-promise-constructor');
- var redefine = _dereq_('../internals/redefine');
- var redefineAll = _dereq_('../internals/redefine-all');
- var setPrototypeOf = _dereq_('../internals/object-set-prototype-of');
- var setToStringTag = _dereq_('../internals/set-to-string-tag');
- var setSpecies = _dereq_('../internals/set-species');
- var aCallable = _dereq_('../internals/a-callable');
- var isCallable = _dereq_('../internals/is-callable');
- var isObject = _dereq_('../internals/is-object');
- var anInstance = _dereq_('../internals/an-instance');
- var inspectSource = _dereq_('../internals/inspect-source');
- var iterate = _dereq_('../internals/iterate');
- var checkCorrectnessOfIteration = _dereq_('../internals/check-correctness-of-iteration');
- var speciesConstructor = _dereq_('../internals/species-constructor');
- var task = _dereq_('../internals/task').set;
- var microtask = _dereq_('../internals/microtask');
- var promiseResolve = _dereq_('../internals/promise-resolve');
- var hostReportErrors = _dereq_('../internals/host-report-errors');
- var newPromiseCapabilityModule = _dereq_('../internals/new-promise-capability');
- var perform = _dereq_('../internals/perform');
- var Queue = _dereq_('../internals/queue');
- var InternalStateModule = _dereq_('../internals/internal-state');
- var isForced = _dereq_('../internals/is-forced');
- var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
- var IS_BROWSER = _dereq_('../internals/engine-is-browser');
- var IS_NODE = _dereq_('../internals/engine-is-node');
- var V8_VERSION = _dereq_('../internals/engine-v8-version');
- var SPECIES = wellKnownSymbol('species');
- var PROMISE = 'Promise';
- var getInternalState = InternalStateModule.getterFor(PROMISE);
- var setInternalState = InternalStateModule.set;
- var getInternalPromiseState = InternalStateModule.getterFor(PROMISE);
- var NativePromisePrototype = NativePromise && NativePromise.prototype;
- var PromiseConstructor = NativePromise;
- var PromisePrototype = NativePromisePrototype;
- var TypeError = global.TypeError;
- var document = global.document;
- var process = global.process;
- var newPromiseCapability = newPromiseCapabilityModule.f;
- var newGenericPromiseCapability = newPromiseCapability;
- var DISPATCH_EVENT = !!(document && document.createEvent && global.dispatchEvent);
- var NATIVE_REJECTION_EVENT = isCallable(global.PromiseRejectionEvent);
- var UNHANDLED_REJECTION = 'unhandledrejection';
- var REJECTION_HANDLED = 'rejectionhandled';
- var PENDING = 0;
- var FULFILLED = 1;
- var REJECTED = 2;
- var HANDLED = 1;
- var UNHANDLED = 2;
- var SUBCLASSING = false;
- var Internal, OwnPromiseCapability, PromiseWrapper, nativeThen;
- var FORCED = isForced(PROMISE, function () {
- var PROMISE_CONSTRUCTOR_SOURCE = inspectSource(PromiseConstructor);
- var GLOBAL_CORE_JS_PROMISE = PROMISE_CONSTRUCTOR_SOURCE !== String(PromiseConstructor);
- // V8 6.6 (Node 10 and Chrome 66) have a bug with resolving custom thenables
- // https://bugs.chromium.org/p/chromium/issues/detail?id=830565
- // We can't detect it synchronously, so just check versions
- if (!GLOBAL_CORE_JS_PROMISE && V8_VERSION === 66) return true;
- // We need Promise#finally in the pure version for preventing prototype pollution
- if (IS_PURE && !PromisePrototype['finally']) return true;
- // We can't use @@species feature detection in V8 since it causes
- // deoptimization and performance degradation
- // https://github.com/zloirock/core-js/issues/679
- if (V8_VERSION >= 51 && /native code/.test(PROMISE_CONSTRUCTOR_SOURCE)) return false;
- // Detect correctness of subclassing with @@species support
- var promise = new PromiseConstructor(function (resolve) { resolve(1); });
- var FakePromise = function (exec) {
- exec(function () { /* empty */ }, function () { /* empty */ });
- };
- var constructor = promise.constructor = {};
- constructor[SPECIES] = FakePromise;
- SUBCLASSING = promise.then(function () { /* empty */ }) instanceof FakePromise;
- if (!SUBCLASSING) return true;
- // Unhandled rejections tracking support, NodeJS Promise without it fails @@species test
- return !GLOBAL_CORE_JS_PROMISE && IS_BROWSER && !NATIVE_REJECTION_EVENT;
- });
- var INCORRECT_ITERATION = FORCED || !checkCorrectnessOfIteration(function (iterable) {
- PromiseConstructor.all(iterable)['catch'](function () { /* empty */ });
- });
- // helpers
- var isThenable = function (it) {
- var then;
- return isObject(it) && isCallable(then = it.then) ? then : false;
- };
- var callReaction = function (reaction, state) {
- var value = state.value;
- var ok = state.state == FULFILLED;
- var handler = ok ? reaction.ok : reaction.fail;
- var resolve = reaction.resolve;
- var reject = reaction.reject;
- var domain = reaction.domain;
- var result, then, exited;
- try {
- if (handler) {
- if (!ok) {
- if (state.rejection === UNHANDLED) onHandleUnhandled(state);
- state.rejection = HANDLED;
- }
- if (handler === true) result = value;
- else {
- if (domain) domain.enter();
- result = handler(value); // can throw
- if (domain) {
- domain.exit();
- exited = true;
- }
- }
- if (result === reaction.promise) {
- reject(TypeError('Promise-chain cycle'));
- } else if (then = isThenable(result)) {
- call(then, result, resolve, reject);
- } else resolve(result);
- } else reject(value);
- } catch (error) {
- if (domain && !exited) domain.exit();
- reject(error);
- }
- };
- var notify = function (state, isReject) {
- if (state.notified) return;
- state.notified = true;
- microtask(function () {
- var reactions = state.reactions;
- var reaction;
- while (reaction = reactions.get()) {
- callReaction(reaction, state);
- }
- state.notified = false;
- if (isReject && !state.rejection) onUnhandled(state);
- });
- };
- var dispatchEvent = function (name, promise, reason) {
- var event, handler;
- if (DISPATCH_EVENT) {
- event = document.createEvent('Event');
- event.promise = promise;
- event.reason = reason;
- event.initEvent(name, false, true);
- global.dispatchEvent(event);
- } else event = { promise: promise, reason: reason };
- if (!NATIVE_REJECTION_EVENT && (handler = global['on' + name])) handler(event);
- else if (name === UNHANDLED_REJECTION) hostReportErrors('Unhandled promise rejection', reason);
- };
- var onUnhandled = function (state) {
- call(task, global, function () {
- var promise = state.facade;
- var value = state.value;
- var IS_UNHANDLED = isUnhandled(state);
- var result;
- if (IS_UNHANDLED) {
- result = perform(function () {
- if (IS_NODE) {
- process.emit('unhandledRejection', value, promise);
- } else dispatchEvent(UNHANDLED_REJECTION, promise, value);
- });
- // Browsers should not trigger `rejectionHandled` event if it was handled here, NodeJS - should
- state.rejection = IS_NODE || isUnhandled(state) ? UNHANDLED : HANDLED;
- if (result.error) throw result.value;
- }
- });
- };
- var isUnhandled = function (state) {
- return state.rejection !== HANDLED && !state.parent;
- };
- var onHandleUnhandled = function (state) {
- call(task, global, function () {
- var promise = state.facade;
- if (IS_NODE) {
- process.emit('rejectionHandled', promise);
- } else dispatchEvent(REJECTION_HANDLED, promise, state.value);
- });
- };
- var bind = function (fn, state, unwrap) {
- return function (value) {
- fn(state, value, unwrap);
- };
- };
- var internalReject = function (state, value, unwrap) {
- if (state.done) return;
- state.done = true;
- if (unwrap) state = unwrap;
- state.value = value;
- state.state = REJECTED;
- notify(state, true);
- };
- var internalResolve = function (state, value, unwrap) {
- if (state.done) return;
- state.done = true;
- if (unwrap) state = unwrap;
- try {
- if (state.facade === value) throw TypeError("Promise can't be resolved itself");
- var then = isThenable(value);
- if (then) {
- microtask(function () {
- var wrapper = { done: false };
- try {
- call(then, value,
- bind(internalResolve, wrapper, state),
- bind(internalReject, wrapper, state)
- );
- } catch (error) {
- internalReject(wrapper, error, state);
- }
- });
- } else {
- state.value = value;
- state.state = FULFILLED;
- notify(state, false);
- }
- } catch (error) {
- internalReject({ done: false }, error, state);
- }
- };
- // constructor polyfill
- if (FORCED) {
- // 25.4.3.1 Promise(executor)
- PromiseConstructor = function Promise(executor) {
- anInstance(this, PromisePrototype);
- aCallable(executor);
- call(Internal, this);
- var state = getInternalState(this);
- try {
- executor(bind(internalResolve, state), bind(internalReject, state));
- } catch (error) {
- internalReject(state, error);
- }
- };
- PromisePrototype = PromiseConstructor.prototype;
- // eslint-disable-next-line no-unused-vars -- required for `.length`
- Internal = function Promise(executor) {
- setInternalState(this, {
- type: PROMISE,
- done: false,
- notified: false,
- parent: false,
- reactions: new Queue(),
- rejection: false,
- state: PENDING,
- value: undefined
- });
- };
- Internal.prototype = redefineAll(PromisePrototype, {
- // `Promise.prototype.then` method
- // https://tc39.es/ecma262/#sec-promise.prototype.then
- // eslint-disable-next-line unicorn/no-thenable -- safe
- then: function then(onFulfilled, onRejected) {
- var state = getInternalPromiseState(this);
- var reaction = newPromiseCapability(speciesConstructor(this, PromiseConstructor));
- state.parent = true;
- reaction.ok = isCallable(onFulfilled) ? onFulfilled : true;
- reaction.fail = isCallable(onRejected) && onRejected;
- reaction.domain = IS_NODE ? process.domain : undefined;
- if (state.state == PENDING) state.reactions.add(reaction);
- else microtask(function () {
- callReaction(reaction, state);
- });
- return reaction.promise;
- },
- // `Promise.prototype.catch` method
- // https://tc39.es/ecma262/#sec-promise.prototype.catch
- 'catch': function (onRejected) {
- return this.then(undefined, onRejected);
- }
- });
- OwnPromiseCapability = function () {
- var promise = new Internal();
- var state = getInternalState(promise);
- this.promise = promise;
- this.resolve = bind(internalResolve, state);
- this.reject = bind(internalReject, state);
- };
- newPromiseCapabilityModule.f = newPromiseCapability = function (C) {
- return C === PromiseConstructor || C === PromiseWrapper
- ? new OwnPromiseCapability(C)
- : newGenericPromiseCapability(C);
- };
- if (!IS_PURE && isCallable(NativePromise) && NativePromisePrototype !== Object.prototype) {
- nativeThen = NativePromisePrototype.then;
- if (!SUBCLASSING) {
- // make `Promise#then` return a polyfilled `Promise` for native promise-based APIs
- redefine(NativePromisePrototype, 'then', function then(onFulfilled, onRejected) {
- var that = this;
- return new PromiseConstructor(function (resolve, reject) {
- call(nativeThen, that, resolve, reject);
- }).then(onFulfilled, onRejected);
- // https://github.com/zloirock/core-js/issues/640
- }, { unsafe: true });
- // makes sure that native promise-based APIs `Promise#catch` properly works with patched `Promise#then`
- redefine(NativePromisePrototype, 'catch', PromisePrototype['catch'], { unsafe: true });
- }
- // make `.constructor === Promise` work for native promise-based APIs
- try {
- delete NativePromisePrototype.constructor;
- } catch (error) { /* empty */ }
- // make `instanceof Promise` work for native promise-based APIs
- if (setPrototypeOf) {
- setPrototypeOf(NativePromisePrototype, PromisePrototype);
- }
- }
- }
- $({ global: true, wrap: true, forced: FORCED }, {
- Promise: PromiseConstructor
- });
- setToStringTag(PromiseConstructor, PROMISE, false, true);
- setSpecies(PROMISE);
- PromiseWrapper = getBuiltIn(PROMISE);
- // statics
- $({ target: PROMISE, stat: true, forced: FORCED }, {
- // `Promise.reject` method
- // https://tc39.es/ecma262/#sec-promise.reject
- reject: function reject(r) {
- var capability = newPromiseCapability(this);
- call(capability.reject, undefined, r);
- return capability.promise;
- }
- });
- $({ target: PROMISE, stat: true, forced: IS_PURE || FORCED }, {
- // `Promise.resolve` method
- // https://tc39.es/ecma262/#sec-promise.resolve
- resolve: function resolve(x) {
- return promiseResolve(IS_PURE && this === PromiseWrapper ? PromiseConstructor : this, x);
- }
- });
- $({ target: PROMISE, stat: true, forced: INCORRECT_ITERATION }, {
- // `Promise.all` method
- // https://tc39.es/ecma262/#sec-promise.all
- all: function all(iterable) {
- var C = this;
- var capability = newPromiseCapability(C);
- var resolve = capability.resolve;
- var reject = capability.reject;
- var result = perform(function () {
- var $promiseResolve = aCallable(C.resolve);
- var values = [];
- var counter = 0;
- var remaining = 1;
- iterate(iterable, function (promise) {
- var index = counter++;
- var alreadyCalled = false;
- remaining++;
- call($promiseResolve, C, promise).then(function (value) {
- if (alreadyCalled) return;
- alreadyCalled = true;
- values[index] = value;
- --remaining || resolve(values);
- }, reject);
- });
- --remaining || resolve(values);
- });
- if (result.error) reject(result.value);
- return capability.promise;
- },
- // `Promise.race` method
- // https://tc39.es/ecma262/#sec-promise.race
- race: function race(iterable) {
- var C = this;
- var capability = newPromiseCapability(C);
- var reject = capability.reject;
- var result = perform(function () {
- var $promiseResolve = aCallable(C.resolve);
- iterate(iterable, function (promise) {
- call($promiseResolve, C, promise).then(capability.resolve, reject);
- });
- });
- if (result.error) reject(result.value);
- return capability.promise;
- }
- });
- },{"../internals/a-callable":421,"../internals/an-instance":425,"../internals/check-correctness-of-iteration":441,"../internals/engine-is-browser":464,"../internals/engine-is-node":468,"../internals/engine-v8-version":471,"../internals/export":476,"../internals/function-call":483,"../internals/get-built-in":486,"../internals/global":491,"../internals/host-report-errors":494,"../internals/inspect-source":498,"../internals/internal-state":501,"../internals/is-callable":504,"../internals/is-forced":507,"../internals/is-object":509,"../internals/is-pure":510,"../internals/iterate":513,"../internals/microtask":520,"../internals/native-promise-constructor":521,"../internals/new-promise-capability":525,"../internals/object-set-prototype-of":543,"../internals/perform":549,"../internals/promise-resolve":550,"../internals/queue":551,"../internals/redefine":553,"../internals/redefine-all":552,"../internals/set-species":557,"../internals/set-to-string-tag":558,"../internals/species-constructor":562,"../internals/task":570,"../internals/well-known-symbol":586}],628:[function(_dereq_,module,exports){
- var $ = _dereq_('../internals/export');
- var getBuiltIn = _dereq_('../internals/get-built-in');
- var apply = _dereq_('../internals/function-apply');
- var bind = _dereq_('../internals/function-bind');
- var aConstructor = _dereq_('../internals/a-constructor');
- var anObject = _dereq_('../internals/an-object');
- var isObject = _dereq_('../internals/is-object');
- var create = _dereq_('../internals/object-create');
- var fails = _dereq_('../internals/fails');
- var nativeConstruct = getBuiltIn('Reflect', 'construct');
- var ObjectPrototype = Object.prototype;
- var push = [].push;
- // `Reflect.construct` method
- // https://tc39.es/ecma262/#sec-reflect.construct
- // MS Edge supports only 2 arguments and argumentsList argument is optional
- // FF Nightly sets third argument as `new.target`, but does not create `this` from it
- var NEW_TARGET_BUG = fails(function () {
- function F() { /* empty */ }
- return !(nativeConstruct(function () { /* empty */ }, [], F) instanceof F);
- });
- var ARGS_BUG = !fails(function () {
- nativeConstruct(function () { /* empty */ });
- });
- var FORCED = NEW_TARGET_BUG || ARGS_BUG;
- $({ target: 'Reflect', stat: true, forced: FORCED, sham: FORCED }, {
- construct: function construct(Target, args /* , newTarget */) {
- aConstructor(Target);
- anObject(args);
- var newTarget = arguments.length < 3 ? Target : aConstructor(arguments[2]);
- if (ARGS_BUG && !NEW_TARGET_BUG) return nativeConstruct(Target, args, newTarget);
- if (Target == newTarget) {
- // w/o altered newTarget, optimization for 0-4 arguments
- switch (args.length) {
- case 0: return new Target();
- case 1: return new Target(args[0]);
- case 2: return new Target(args[0], args[1]);
- case 3: return new Target(args[0], args[1], args[2]);
- case 4: return new Target(args[0], args[1], args[2], args[3]);
- }
- // w/o altered newTarget, lot of arguments case
- var $args = [null];
- apply(push, $args, args);
- return new (apply(bind, Target, $args))();
- }
- // with altered newTarget, not support built-in constructors
- var proto = newTarget.prototype;
- var instance = create(isObject(proto) ? proto : ObjectPrototype);
- var result = apply(Target, instance, args);
- return isObject(result) ? result : instance;
- }
- });
- },{"../internals/a-constructor":422,"../internals/an-object":426,"../internals/export":476,"../internals/fails":477,"../internals/function-apply":479,"../internals/function-bind":482,"../internals/get-built-in":486,"../internals/is-object":509,"../internals/object-create":530}],629:[function(_dereq_,module,exports){
- var $ = _dereq_('../internals/export');
- var call = _dereq_('../internals/function-call');
- var isObject = _dereq_('../internals/is-object');
- var anObject = _dereq_('../internals/an-object');
- var isDataDescriptor = _dereq_('../internals/is-data-descriptor');
- var getOwnPropertyDescriptorModule = _dereq_('../internals/object-get-own-property-descriptor');
- var getPrototypeOf = _dereq_('../internals/object-get-prototype-of');
- // `Reflect.get` method
- // https://tc39.es/ecma262/#sec-reflect.get
- function get(target, propertyKey /* , receiver */) {
- var receiver = arguments.length < 3 ? target : arguments[2];
- var descriptor, prototype;
- if (anObject(target) === receiver) return target[propertyKey];
- descriptor = getOwnPropertyDescriptorModule.f(target, propertyKey);
- if (descriptor) return isDataDescriptor(descriptor)
- ? descriptor.value
- : descriptor.get === undefined ? undefined : call(descriptor.get, receiver);
- if (isObject(prototype = getPrototypeOf(target))) return get(prototype, propertyKey, receiver);
- }
- $({ target: 'Reflect', stat: true }, {
- get: get
- });
- },{"../internals/an-object":426,"../internals/export":476,"../internals/function-call":483,"../internals/is-data-descriptor":506,"../internals/is-object":509,"../internals/object-get-own-property-descriptor":533,"../internals/object-get-prototype-of":537}],630:[function(_dereq_,module,exports){
- arguments[4][608][0].apply(exports,arguments)
- },{"dup":608}],631:[function(_dereq_,module,exports){
- arguments[4][608][0].apply(exports,arguments)
- },{"dup":608}],632:[function(_dereq_,module,exports){
- 'use strict';
- var collection = _dereq_('../internals/collection');
- var collectionStrong = _dereq_('../internals/collection-strong');
- // `Set` constructor
- // https://tc39.es/ecma262/#sec-set-objects
- collection('Set', function (init) {
- return function Set() { return init(this, arguments.length ? arguments[0] : undefined); };
- }, collectionStrong);
- },{"../internals/collection":450,"../internals/collection-strong":448}],633:[function(_dereq_,module,exports){
- 'use strict';
- var $ = _dereq_('../internals/export');
- var uncurryThis = _dereq_('../internals/function-uncurry-this');
- var notARegExp = _dereq_('../internals/not-a-regexp');
- var requireObjectCoercible = _dereq_('../internals/require-object-coercible');
- var toString = _dereq_('../internals/to-string');
- var correctIsRegExpLogic = _dereq_('../internals/correct-is-regexp-logic');
- var stringIndexOf = uncurryThis(''.indexOf);
- // `String.prototype.includes` method
- // https://tc39.es/ecma262/#sec-string.prototype.includes
- $({ target: 'String', proto: true, forced: !correctIsRegExpLogic('includes') }, {
- includes: function includes(searchString /* , position = 0 */) {
- return !!~stringIndexOf(
- toString(requireObjectCoercible(this)),
- toString(notARegExp(searchString)),
- arguments.length > 1 ? arguments[1] : undefined
- );
- }
- });
- },{"../internals/correct-is-regexp-logic":452,"../internals/export":476,"../internals/function-uncurry-this":485,"../internals/not-a-regexp":527,"../internals/require-object-coercible":554,"../internals/to-string":579}],634:[function(_dereq_,module,exports){
- 'use strict';
- var charAt = _dereq_('../internals/string-multibyte').charAt;
- var toString = _dereq_('../internals/to-string');
- var InternalStateModule = _dereq_('../internals/internal-state');
- var defineIterator = _dereq_('../internals/define-iterator');
- var STRING_ITERATOR = 'String Iterator';
- var setInternalState = InternalStateModule.set;
- var getInternalState = InternalStateModule.getterFor(STRING_ITERATOR);
- // `String.prototype[@@iterator]` method
- // https://tc39.es/ecma262/#sec-string.prototype-@@iterator
- defineIterator(String, 'String', function (iterated) {
- setInternalState(this, {
- type: STRING_ITERATOR,
- string: toString(iterated),
- index: 0
- });
- // `%StringIteratorPrototype%.next` method
- // https://tc39.es/ecma262/#sec-%stringiteratorprototype%.next
- }, function next() {
- var state = getInternalState(this);
- var string = state.string;
- var index = state.index;
- var point;
- if (index >= string.length) return { value: undefined, done: true };
- point = charAt(string, index);
- state.index += point.length;
- return { value: point, done: false };
- });
- },{"../internals/define-iterator":458,"../internals/internal-state":501,"../internals/string-multibyte":563,"../internals/to-string":579}],635:[function(_dereq_,module,exports){
- 'use strict';
- var $ = _dereq_('../internals/export');
- var $padStart = _dereq_('../internals/string-pad').start;
- var WEBKIT_BUG = _dereq_('../internals/string-pad-webkit-bug');
- // `String.prototype.padStart` method
- // https://tc39.es/ecma262/#sec-string.prototype.padstart
- $({ target: 'String', proto: true, forced: WEBKIT_BUG }, {
- padStart: function padStart(maxLength /* , fillString = ' ' */) {
- return $padStart(this, maxLength, arguments.length > 1 ? arguments[1] : undefined);
- }
- });
- },{"../internals/export":476,"../internals/string-pad":565,"../internals/string-pad-webkit-bug":564}],636:[function(_dereq_,module,exports){
- arguments[4][608][0].apply(exports,arguments)
- },{"dup":608}],637:[function(_dereq_,module,exports){
- 'use strict';
- var $ = _dereq_('../internals/export');
- var uncurryThis = _dereq_('../internals/function-uncurry-this');
- var getOwnPropertyDescriptor = _dereq_('../internals/object-get-own-property-descriptor').f;
- var toLength = _dereq_('../internals/to-length');
- var toString = _dereq_('../internals/to-string');
- var notARegExp = _dereq_('../internals/not-a-regexp');
- var requireObjectCoercible = _dereq_('../internals/require-object-coercible');
- var correctIsRegExpLogic = _dereq_('../internals/correct-is-regexp-logic');
- var IS_PURE = _dereq_('../internals/is-pure');
- // eslint-disable-next-line es/no-string-prototype-startswith -- safe
- var un$StartsWith = uncurryThis(''.startsWith);
- var stringSlice = uncurryThis(''.slice);
- var min = Math.min;
- var CORRECT_IS_REGEXP_LOGIC = correctIsRegExpLogic('startsWith');
- // https://github.com/zloirock/core-js/pull/702
- var MDN_POLYFILL_BUG = !IS_PURE && !CORRECT_IS_REGEXP_LOGIC && !!function () {
- var descriptor = getOwnPropertyDescriptor(String.prototype, 'startsWith');
- return descriptor && !descriptor.writable;
- }();
- // `String.prototype.startsWith` method
- // https://tc39.es/ecma262/#sec-string.prototype.startswith
- $({ target: 'String', proto: true, forced: !MDN_POLYFILL_BUG && !CORRECT_IS_REGEXP_LOGIC }, {
- startsWith: function startsWith(searchString /* , position = 0 */) {
- var that = toString(requireObjectCoercible(this));
- notARegExp(searchString);
- var index = toLength(min(arguments.length > 1 ? arguments[1] : undefined, that.length));
- var search = toString(searchString);
- return un$StartsWith
- ? un$StartsWith(that, search, index)
- : stringSlice(that, index, index + search.length) === search;
- }
- });
- },{"../internals/correct-is-regexp-logic":452,"../internals/export":476,"../internals/function-uncurry-this":485,"../internals/is-pure":510,"../internals/not-a-regexp":527,"../internals/object-get-own-property-descriptor":533,"../internals/require-object-coercible":554,"../internals/to-length":574,"../internals/to-string":579}],638:[function(_dereq_,module,exports){
- 'use strict';
- var $ = _dereq_('../internals/export');
- var $trim = _dereq_('../internals/string-trim').trim;
- var forcedStringTrimMethod = _dereq_('../internals/string-trim-forced');
- // `String.prototype.trim` method
- // https://tc39.es/ecma262/#sec-string.prototype.trim
- $({ target: 'String', proto: true, forced: forcedStringTrimMethod('trim') }, {
- trim: function trim() {
- return $trim(this);
- }
- });
- },{"../internals/export":476,"../internals/string-trim":569,"../internals/string-trim-forced":568}],639:[function(_dereq_,module,exports){
- var defineWellKnownSymbol = _dereq_('../internals/define-well-known-symbol');
- // `Symbol.asyncIterator` well-known symbol
- // https://tc39.es/ecma262/#sec-symbol.asynciterator
- defineWellKnownSymbol('asyncIterator');
- },{"../internals/define-well-known-symbol":459}],640:[function(_dereq_,module,exports){
- arguments[4][608][0].apply(exports,arguments)
- },{"dup":608}],641:[function(_dereq_,module,exports){
- var defineWellKnownSymbol = _dereq_('../internals/define-well-known-symbol');
- // `Symbol.hasInstance` well-known symbol
- // https://tc39.es/ecma262/#sec-symbol.hasinstance
- defineWellKnownSymbol('hasInstance');
- },{"../internals/define-well-known-symbol":459}],642:[function(_dereq_,module,exports){
- var defineWellKnownSymbol = _dereq_('../internals/define-well-known-symbol');
- // `Symbol.isConcatSpreadable` well-known symbol
- // https://tc39.es/ecma262/#sec-symbol.isconcatspreadable
- defineWellKnownSymbol('isConcatSpreadable');
- },{"../internals/define-well-known-symbol":459}],643:[function(_dereq_,module,exports){
- var defineWellKnownSymbol = _dereq_('../internals/define-well-known-symbol');
- // `Symbol.iterator` well-known symbol
- // https://tc39.es/ecma262/#sec-symbol.iterator
- defineWellKnownSymbol('iterator');
- },{"../internals/define-well-known-symbol":459}],644:[function(_dereq_,module,exports){
- 'use strict';
- var $ = _dereq_('../internals/export');
- var global = _dereq_('../internals/global');
- var getBuiltIn = _dereq_('../internals/get-built-in');
- var apply = _dereq_('../internals/function-apply');
- var call = _dereq_('../internals/function-call');
- var uncurryThis = _dereq_('../internals/function-uncurry-this');
- var IS_PURE = _dereq_('../internals/is-pure');
- var DESCRIPTORS = _dereq_('../internals/descriptors');
- var NATIVE_SYMBOL = _dereq_('../internals/native-symbol');
- var fails = _dereq_('../internals/fails');
- var hasOwn = _dereq_('../internals/has-own-property');
- var isArray = _dereq_('../internals/is-array');
- var isCallable = _dereq_('../internals/is-callable');
- var isObject = _dereq_('../internals/is-object');
- var isPrototypeOf = _dereq_('../internals/object-is-prototype-of');
- var isSymbol = _dereq_('../internals/is-symbol');
- var anObject = _dereq_('../internals/an-object');
- var toObject = _dereq_('../internals/to-object');
- var toIndexedObject = _dereq_('../internals/to-indexed-object');
- var toPropertyKey = _dereq_('../internals/to-property-key');
- var $toString = _dereq_('../internals/to-string');
- var createPropertyDescriptor = _dereq_('../internals/create-property-descriptor');
- var nativeObjectCreate = _dereq_('../internals/object-create');
- var objectKeys = _dereq_('../internals/object-keys');
- var getOwnPropertyNamesModule = _dereq_('../internals/object-get-own-property-names');
- var getOwnPropertyNamesExternal = _dereq_('../internals/object-get-own-property-names-external');
- var getOwnPropertySymbolsModule = _dereq_('../internals/object-get-own-property-symbols');
- var getOwnPropertyDescriptorModule = _dereq_('../internals/object-get-own-property-descriptor');
- var definePropertyModule = _dereq_('../internals/object-define-property');
- var definePropertiesModule = _dereq_('../internals/object-define-properties');
- var propertyIsEnumerableModule = _dereq_('../internals/object-property-is-enumerable');
- var arraySlice = _dereq_('../internals/array-slice');
- var redefine = _dereq_('../internals/redefine');
- var shared = _dereq_('../internals/shared');
- var sharedKey = _dereq_('../internals/shared-key');
- var hiddenKeys = _dereq_('../internals/hidden-keys');
- var uid = _dereq_('../internals/uid');
- var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
- var wrappedWellKnownSymbolModule = _dereq_('../internals/well-known-symbol-wrapped');
- var defineWellKnownSymbol = _dereq_('../internals/define-well-known-symbol');
- var setToStringTag = _dereq_('../internals/set-to-string-tag');
- var InternalStateModule = _dereq_('../internals/internal-state');
- var $forEach = _dereq_('../internals/array-iteration').forEach;
- var HIDDEN = sharedKey('hidden');
- var SYMBOL = 'Symbol';
- var PROTOTYPE = 'prototype';
- var TO_PRIMITIVE = wellKnownSymbol('toPrimitive');
- var setInternalState = InternalStateModule.set;
- var getInternalState = InternalStateModule.getterFor(SYMBOL);
- var ObjectPrototype = Object[PROTOTYPE];
- var $Symbol = global.Symbol;
- var SymbolPrototype = $Symbol && $Symbol[PROTOTYPE];
- var TypeError = global.TypeError;
- var QObject = global.QObject;
- var $stringify = getBuiltIn('JSON', 'stringify');
- var nativeGetOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;
- var nativeDefineProperty = definePropertyModule.f;
- var nativeGetOwnPropertyNames = getOwnPropertyNamesExternal.f;
- var nativePropertyIsEnumerable = propertyIsEnumerableModule.f;
- var push = uncurryThis([].push);
- var AllSymbols = shared('symbols');
- var ObjectPrototypeSymbols = shared('op-symbols');
- var StringToSymbolRegistry = shared('string-to-symbol-registry');
- var SymbolToStringRegistry = shared('symbol-to-string-registry');
- var WellKnownSymbolsStore = shared('wks');
- // Don't use setters in Qt Script, https://github.com/zloirock/core-js/issues/173
- var USE_SETTER = !QObject || !QObject[PROTOTYPE] || !QObject[PROTOTYPE].findChild;
- // fallback for old Android, https://code.google.com/p/v8/issues/detail?id=687
- var setSymbolDescriptor = DESCRIPTORS && fails(function () {
- return nativeObjectCreate(nativeDefineProperty({}, 'a', {
- get: function () { return nativeDefineProperty(this, 'a', { value: 7 }).a; }
- })).a != 7;
- }) ? function (O, P, Attributes) {
- var ObjectPrototypeDescriptor = nativeGetOwnPropertyDescriptor(ObjectPrototype, P);
- if (ObjectPrototypeDescriptor) delete ObjectPrototype[P];
- nativeDefineProperty(O, P, Attributes);
- if (ObjectPrototypeDescriptor && O !== ObjectPrototype) {
- nativeDefineProperty(ObjectPrototype, P, ObjectPrototypeDescriptor);
- }
- } : nativeDefineProperty;
- var wrap = function (tag, description) {
- var symbol = AllSymbols[tag] = nativeObjectCreate(SymbolPrototype);
- setInternalState(symbol, {
- type: SYMBOL,
- tag: tag,
- description: description
- });
- if (!DESCRIPTORS) symbol.description = description;
- return symbol;
- };
- var $defineProperty = function defineProperty(O, P, Attributes) {
- if (O === ObjectPrototype) $defineProperty(ObjectPrototypeSymbols, P, Attributes);
- anObject(O);
- var key = toPropertyKey(P);
- anObject(Attributes);
- if (hasOwn(AllSymbols, key)) {
- if (!Attributes.enumerable) {
- if (!hasOwn(O, HIDDEN)) nativeDefineProperty(O, HIDDEN, createPropertyDescriptor(1, {}));
- O[HIDDEN][key] = true;
- } else {
- if (hasOwn(O, HIDDEN) && O[HIDDEN][key]) O[HIDDEN][key] = false;
- Attributes = nativeObjectCreate(Attributes, { enumerable: createPropertyDescriptor(0, false) });
- } return setSymbolDescriptor(O, key, Attributes);
- } return nativeDefineProperty(O, key, Attributes);
- };
- var $defineProperties = function defineProperties(O, Properties) {
- anObject(O);
- var properties = toIndexedObject(Properties);
- var keys = objectKeys(properties).concat($getOwnPropertySymbols(properties));
- $forEach(keys, function (key) {
- if (!DESCRIPTORS || call($propertyIsEnumerable, properties, key)) $defineProperty(O, key, properties[key]);
- });
- return O;
- };
- var $create = function create(O, Properties) {
- return Properties === undefined ? nativeObjectCreate(O) : $defineProperties(nativeObjectCreate(O), Properties);
- };
- var $propertyIsEnumerable = function propertyIsEnumerable(V) {
- var P = toPropertyKey(V);
- var enumerable = call(nativePropertyIsEnumerable, this, P);
- if (this === ObjectPrototype && hasOwn(AllSymbols, P) && !hasOwn(ObjectPrototypeSymbols, P)) return false;
- return enumerable || !hasOwn(this, P) || !hasOwn(AllSymbols, P) || hasOwn(this, HIDDEN) && this[HIDDEN][P]
- ? enumerable : true;
- };
- var $getOwnPropertyDescriptor = function getOwnPropertyDescriptor(O, P) {
- var it = toIndexedObject(O);
- var key = toPropertyKey(P);
- if (it === ObjectPrototype && hasOwn(AllSymbols, key) && !hasOwn(ObjectPrototypeSymbols, key)) return;
- var descriptor = nativeGetOwnPropertyDescriptor(it, key);
- if (descriptor && hasOwn(AllSymbols, key) && !(hasOwn(it, HIDDEN) && it[HIDDEN][key])) {
- descriptor.enumerable = true;
- }
- return descriptor;
- };
- var $getOwnPropertyNames = function getOwnPropertyNames(O) {
- var names = nativeGetOwnPropertyNames(toIndexedObject(O));
- var result = [];
- $forEach(names, function (key) {
- if (!hasOwn(AllSymbols, key) && !hasOwn(hiddenKeys, key)) push(result, key);
- });
- return result;
- };
- var $getOwnPropertySymbols = function getOwnPropertySymbols(O) {
- var IS_OBJECT_PROTOTYPE = O === ObjectPrototype;
- var names = nativeGetOwnPropertyNames(IS_OBJECT_PROTOTYPE ? ObjectPrototypeSymbols : toIndexedObject(O));
- var result = [];
- $forEach(names, function (key) {
- if (hasOwn(AllSymbols, key) && (!IS_OBJECT_PROTOTYPE || hasOwn(ObjectPrototype, key))) {
- push(result, AllSymbols[key]);
- }
- });
- return result;
- };
- // `Symbol` constructor
- // https://tc39.es/ecma262/#sec-symbol-constructor
- if (!NATIVE_SYMBOL) {
- $Symbol = function Symbol() {
- if (isPrototypeOf(SymbolPrototype, this)) throw TypeError('Symbol is not a constructor');
- var description = !arguments.length || arguments[0] === undefined ? undefined : $toString(arguments[0]);
- var tag = uid(description);
- var setter = function (value) {
- if (this === ObjectPrototype) call(setter, ObjectPrototypeSymbols, value);
- if (hasOwn(this, HIDDEN) && hasOwn(this[HIDDEN], tag)) this[HIDDEN][tag] = false;
- setSymbolDescriptor(this, tag, createPropertyDescriptor(1, value));
- };
- if (DESCRIPTORS && USE_SETTER) setSymbolDescriptor(ObjectPrototype, tag, { configurable: true, set: setter });
- return wrap(tag, description);
- };
- SymbolPrototype = $Symbol[PROTOTYPE];
- redefine(SymbolPrototype, 'toString', function toString() {
- return getInternalState(this).tag;
- });
- redefine($Symbol, 'withoutSetter', function (description) {
- return wrap(uid(description), description);
- });
- propertyIsEnumerableModule.f = $propertyIsEnumerable;
- definePropertyModule.f = $defineProperty;
- definePropertiesModule.f = $defineProperties;
- getOwnPropertyDescriptorModule.f = $getOwnPropertyDescriptor;
- getOwnPropertyNamesModule.f = getOwnPropertyNamesExternal.f = $getOwnPropertyNames;
- getOwnPropertySymbolsModule.f = $getOwnPropertySymbols;
- wrappedWellKnownSymbolModule.f = function (name) {
- return wrap(wellKnownSymbol(name), name);
- };
- if (DESCRIPTORS) {
- // https://github.com/tc39/proposal-Symbol-description
- nativeDefineProperty(SymbolPrototype, 'description', {
- configurable: true,
- get: function description() {
- return getInternalState(this).description;
- }
- });
- if (!IS_PURE) {
- redefine(ObjectPrototype, 'propertyIsEnumerable', $propertyIsEnumerable, { unsafe: true });
- }
- }
- }
- $({ global: true, wrap: true, forced: !NATIVE_SYMBOL, sham: !NATIVE_SYMBOL }, {
- Symbol: $Symbol
- });
- $forEach(objectKeys(WellKnownSymbolsStore), function (name) {
- defineWellKnownSymbol(name);
- });
- $({ target: SYMBOL, stat: true, forced: !NATIVE_SYMBOL }, {
- // `Symbol.for` method
- // https://tc39.es/ecma262/#sec-symbol.for
- 'for': function (key) {
- var string = $toString(key);
- if (hasOwn(StringToSymbolRegistry, string)) return StringToSymbolRegistry[string];
- var symbol = $Symbol(string);
- StringToSymbolRegistry[string] = symbol;
- SymbolToStringRegistry[symbol] = string;
- return symbol;
- },
- // `Symbol.keyFor` method
- // https://tc39.es/ecma262/#sec-symbol.keyfor
- keyFor: function keyFor(sym) {
- if (!isSymbol(sym)) throw TypeError(sym + ' is not a symbol');
- if (hasOwn(SymbolToStringRegistry, sym)) return SymbolToStringRegistry[sym];
- },
- useSetter: function () { USE_SETTER = true; },
- useSimple: function () { USE_SETTER = false; }
- });
- $({ target: 'Object', stat: true, forced: !NATIVE_SYMBOL, sham: !DESCRIPTORS }, {
- // `Object.create` method
- // https://tc39.es/ecma262/#sec-object.create
- create: $create,
- // `Object.defineProperty` method
- // https://tc39.es/ecma262/#sec-object.defineproperty
- defineProperty: $defineProperty,
- // `Object.defineProperties` method
- // https://tc39.es/ecma262/#sec-object.defineproperties
- defineProperties: $defineProperties,
- // `Object.getOwnPropertyDescriptor` method
- // https://tc39.es/ecma262/#sec-object.getownpropertydescriptors
- getOwnPropertyDescriptor: $getOwnPropertyDescriptor
- });
- $({ target: 'Object', stat: true, forced: !NATIVE_SYMBOL }, {
- // `Object.getOwnPropertyNames` method
- // https://tc39.es/ecma262/#sec-object.getownpropertynames
- getOwnPropertyNames: $getOwnPropertyNames,
- // `Object.getOwnPropertySymbols` method
- // https://tc39.es/ecma262/#sec-object.getownpropertysymbols
- getOwnPropertySymbols: $getOwnPropertySymbols
- });
- // Chrome 38 and 39 `Object.getOwnPropertySymbols` fails on primitives
- // https://bugs.chromium.org/p/v8/issues/detail?id=3443
- $({ target: 'Object', stat: true, forced: fails(function () { getOwnPropertySymbolsModule.f(1); }) }, {
- getOwnPropertySymbols: function getOwnPropertySymbols(it) {
- return getOwnPropertySymbolsModule.f(toObject(it));
- }
- });
- // `JSON.stringify` method behavior with symbols
- // https://tc39.es/ecma262/#sec-json.stringify
- if ($stringify) {
- var FORCED_JSON_STRINGIFY = !NATIVE_SYMBOL || fails(function () {
- var symbol = $Symbol();
- // MS Edge converts symbol values to JSON as {}
- return $stringify([symbol]) != '[null]'
- // WebKit converts symbol values to JSON as null
- || $stringify({ a: symbol }) != '{}'
- // V8 throws on boxed symbols
- || $stringify(Object(symbol)) != '{}';
- });
- $({ target: 'JSON', stat: true, forced: FORCED_JSON_STRINGIFY }, {
- // eslint-disable-next-line no-unused-vars -- required for `.length`
- stringify: function stringify(it, replacer, space) {
- var args = arraySlice(arguments);
- var $replacer = replacer;
- if (!isObject(replacer) && it === undefined || isSymbol(it)) return; // IE8 returns string on undefined
- if (!isArray(replacer)) replacer = function (key, value) {
- if (isCallable($replacer)) value = call($replacer, this, key, value);
- if (!isSymbol(value)) return value;
- };
- args[1] = replacer;
- return apply($stringify, null, args);
- }
- });
- }
- // `Symbol.prototype[@@toPrimitive]` method
- // https://tc39.es/ecma262/#sec-symbol.prototype-@@toprimitive
- if (!SymbolPrototype[TO_PRIMITIVE]) {
- var valueOf = SymbolPrototype.valueOf;
- // eslint-disable-next-line no-unused-vars -- required for .length
- redefine(SymbolPrototype, TO_PRIMITIVE, function (hint) {
- // TODO: improve hint logic
- return call(valueOf, this);
- });
- }
- // `Symbol.prototype[@@toStringTag]` property
- // https://tc39.es/ecma262/#sec-symbol.prototype-@@tostringtag
- setToStringTag($Symbol, SYMBOL);
- hiddenKeys[HIDDEN] = true;
- },{"../internals/an-object":426,"../internals/array-iteration":431,"../internals/array-slice":436,"../internals/create-property-descriptor":456,"../internals/define-well-known-symbol":459,"../internals/descriptors":460,"../internals/export":476,"../internals/fails":477,"../internals/function-apply":479,"../internals/function-call":483,"../internals/function-uncurry-this":485,"../internals/get-built-in":486,"../internals/global":491,"../internals/has-own-property":492,"../internals/hidden-keys":493,"../internals/internal-state":501,"../internals/is-array":503,"../internals/is-callable":504,"../internals/is-object":509,"../internals/is-pure":510,"../internals/is-symbol":512,"../internals/native-symbol":522,"../internals/object-create":530,"../internals/object-define-properties":531,"../internals/object-define-property":532,"../internals/object-get-own-property-descriptor":533,"../internals/object-get-own-property-names":535,"../internals/object-get-own-property-names-external":534,"../internals/object-get-own-property-symbols":536,"../internals/object-is-prototype-of":539,"../internals/object-keys":541,"../internals/object-property-is-enumerable":542,"../internals/redefine":553,"../internals/set-to-string-tag":558,"../internals/shared":561,"../internals/shared-key":559,"../internals/to-indexed-object":572,"../internals/to-object":575,"../internals/to-property-key":577,"../internals/to-string":579,"../internals/uid":581,"../internals/well-known-symbol":586,"../internals/well-known-symbol-wrapped":585}],645:[function(_dereq_,module,exports){
- var defineWellKnownSymbol = _dereq_('../internals/define-well-known-symbol');
- // `Symbol.matchAll` well-known symbol
- // https://tc39.es/ecma262/#sec-symbol.matchall
- defineWellKnownSymbol('matchAll');
- },{"../internals/define-well-known-symbol":459}],646:[function(_dereq_,module,exports){
- var defineWellKnownSymbol = _dereq_('../internals/define-well-known-symbol');
- // `Symbol.match` well-known symbol
- // https://tc39.es/ecma262/#sec-symbol.match
- defineWellKnownSymbol('match');
- },{"../internals/define-well-known-symbol":459}],647:[function(_dereq_,module,exports){
- var defineWellKnownSymbol = _dereq_('../internals/define-well-known-symbol');
- // `Symbol.replace` well-known symbol
- // https://tc39.es/ecma262/#sec-symbol.replace
- defineWellKnownSymbol('replace');
- },{"../internals/define-well-known-symbol":459}],648:[function(_dereq_,module,exports){
- var defineWellKnownSymbol = _dereq_('../internals/define-well-known-symbol');
- // `Symbol.search` well-known symbol
- // https://tc39.es/ecma262/#sec-symbol.search
- defineWellKnownSymbol('search');
- },{"../internals/define-well-known-symbol":459}],649:[function(_dereq_,module,exports){
- var defineWellKnownSymbol = _dereq_('../internals/define-well-known-symbol');
- // `Symbol.species` well-known symbol
- // https://tc39.es/ecma262/#sec-symbol.species
- defineWellKnownSymbol('species');
- },{"../internals/define-well-known-symbol":459}],650:[function(_dereq_,module,exports){
- var defineWellKnownSymbol = _dereq_('../internals/define-well-known-symbol');
- // `Symbol.split` well-known symbol
- // https://tc39.es/ecma262/#sec-symbol.split
- defineWellKnownSymbol('split');
- },{"../internals/define-well-known-symbol":459}],651:[function(_dereq_,module,exports){
- var defineWellKnownSymbol = _dereq_('../internals/define-well-known-symbol');
- // `Symbol.toPrimitive` well-known symbol
- // https://tc39.es/ecma262/#sec-symbol.toprimitive
- defineWellKnownSymbol('toPrimitive');
- },{"../internals/define-well-known-symbol":459}],652:[function(_dereq_,module,exports){
- var defineWellKnownSymbol = _dereq_('../internals/define-well-known-symbol');
- // `Symbol.toStringTag` well-known symbol
- // https://tc39.es/ecma262/#sec-symbol.tostringtag
- defineWellKnownSymbol('toStringTag');
- },{"../internals/define-well-known-symbol":459}],653:[function(_dereq_,module,exports){
- var defineWellKnownSymbol = _dereq_('../internals/define-well-known-symbol');
- // `Symbol.unscopables` well-known symbol
- // https://tc39.es/ecma262/#sec-symbol.unscopables
- defineWellKnownSymbol('unscopables');
- },{"../internals/define-well-known-symbol":459}],654:[function(_dereq_,module,exports){
- 'use strict';
- var global = _dereq_('../internals/global');
- var uncurryThis = _dereq_('../internals/function-uncurry-this');
- var redefineAll = _dereq_('../internals/redefine-all');
- var InternalMetadataModule = _dereq_('../internals/internal-metadata');
- var collection = _dereq_('../internals/collection');
- var collectionWeak = _dereq_('../internals/collection-weak');
- var isObject = _dereq_('../internals/is-object');
- var isExtensible = _dereq_('../internals/object-is-extensible');
- var enforceInternalState = _dereq_('../internals/internal-state').enforce;
- var NATIVE_WEAK_MAP = _dereq_('../internals/native-weak-map');
- var IS_IE11 = !global.ActiveXObject && 'ActiveXObject' in global;
- var InternalWeakMap;
- var wrapper = function (init) {
- return function WeakMap() {
- return init(this, arguments.length ? arguments[0] : undefined);
- };
- };
- // `WeakMap` constructor
- // https://tc39.es/ecma262/#sec-weakmap-constructor
- var $WeakMap = collection('WeakMap', wrapper, collectionWeak);
- // IE11 WeakMap frozen keys fix
- // We can't use feature detection because it crash some old IE builds
- // https://github.com/zloirock/core-js/issues/485
- if (NATIVE_WEAK_MAP && IS_IE11) {
- InternalWeakMap = collectionWeak.getConstructor(wrapper, 'WeakMap', true);
- InternalMetadataModule.enable();
- var WeakMapPrototype = $WeakMap.prototype;
- var nativeDelete = uncurryThis(WeakMapPrototype['delete']);
- var nativeHas = uncurryThis(WeakMapPrototype.has);
- var nativeGet = uncurryThis(WeakMapPrototype.get);
- var nativeSet = uncurryThis(WeakMapPrototype.set);
- redefineAll(WeakMapPrototype, {
- 'delete': function (key) {
- if (isObject(key) && !isExtensible(key)) {
- var state = enforceInternalState(this);
- if (!state.frozen) state.frozen = new InternalWeakMap();
- return nativeDelete(this, key) || state.frozen['delete'](key);
- } return nativeDelete(this, key);
- },
- has: function has(key) {
- if (isObject(key) && !isExtensible(key)) {
- var state = enforceInternalState(this);
- if (!state.frozen) state.frozen = new InternalWeakMap();
- return nativeHas(this, key) || state.frozen.has(key);
- } return nativeHas(this, key);
- },
- get: function get(key) {
- if (isObject(key) && !isExtensible(key)) {
- var state = enforceInternalState(this);
- if (!state.frozen) state.frozen = new InternalWeakMap();
- return nativeHas(this, key) ? nativeGet(this, key) : state.frozen.get(key);
- } return nativeGet(this, key);
- },
- set: function set(key, value) {
- if (isObject(key) && !isExtensible(key)) {
- var state = enforceInternalState(this);
- if (!state.frozen) state.frozen = new InternalWeakMap();
- nativeHas(this, key) ? nativeSet(this, key, value) : state.frozen.set(key, value);
- } else nativeSet(this, key, value);
- return this;
- }
- });
- }
- },{"../internals/collection":450,"../internals/collection-weak":449,"../internals/function-uncurry-this":485,"../internals/global":491,"../internals/internal-metadata":500,"../internals/internal-state":501,"../internals/is-object":509,"../internals/native-weak-map":524,"../internals/object-is-extensible":538,"../internals/redefine-all":552}],655:[function(_dereq_,module,exports){
- // TODO: Remove from `core-js@4`
- _dereq_('../modules/es.aggregate-error');
- },{"../modules/es.aggregate-error":588}],656:[function(_dereq_,module,exports){
- 'use strict';
- var $ = _dereq_('../internals/export');
- var IS_PURE = _dereq_('../internals/is-pure');
- var deleteAll = _dereq_('../internals/collection-delete-all');
- // `Map.prototype.deleteAll` method
- // https://github.com/tc39/proposal-collection-methods
- $({ target: 'Map', proto: true, real: true, forced: IS_PURE }, {
- deleteAll: deleteAll
- });
- },{"../internals/collection-delete-all":445,"../internals/export":476,"../internals/is-pure":510}],657:[function(_dereq_,module,exports){
- 'use strict';
- var $ = _dereq_('../internals/export');
- var IS_PURE = _dereq_('../internals/is-pure');
- var emplace = _dereq_('../internals/map-emplace');
- // `Map.prototype.emplace` method
- // https://github.com/thumbsupep/proposal-upsert
- $({ target: 'Map', proto: true, real: true, forced: IS_PURE }, {
- emplace: emplace
- });
- },{"../internals/export":476,"../internals/is-pure":510,"../internals/map-emplace":518}],658:[function(_dereq_,module,exports){
- 'use strict';
- var $ = _dereq_('../internals/export');
- var IS_PURE = _dereq_('../internals/is-pure');
- var anObject = _dereq_('../internals/an-object');
- var bind = _dereq_('../internals/function-bind-context');
- var getMapIterator = _dereq_('../internals/get-map-iterator');
- var iterate = _dereq_('../internals/iterate');
- // `Map.prototype.every` method
- // https://github.com/tc39/proposal-collection-methods
- $({ target: 'Map', proto: true, real: true, forced: IS_PURE }, {
- every: function every(callbackfn /* , thisArg */) {
- var map = anObject(this);
- var iterator = getMapIterator(map);
- var boundFunction = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined);
- return !iterate(iterator, function (key, value, stop) {
- if (!boundFunction(value, key, map)) return stop();
- }, { AS_ENTRIES: true, IS_ITERATOR: true, INTERRUPTED: true }).stopped;
- }
- });
- },{"../internals/an-object":426,"../internals/export":476,"../internals/function-bind-context":480,"../internals/get-map-iterator":489,"../internals/is-pure":510,"../internals/iterate":513}],659:[function(_dereq_,module,exports){
- 'use strict';
- var IS_PURE = _dereq_('../internals/is-pure');
- var $ = _dereq_('../internals/export');
- var getBuiltIn = _dereq_('../internals/get-built-in');
- var bind = _dereq_('../internals/function-bind-context');
- var call = _dereq_('../internals/function-call');
- var aCallable = _dereq_('../internals/a-callable');
- var anObject = _dereq_('../internals/an-object');
- var speciesConstructor = _dereq_('../internals/species-constructor');
- var getMapIterator = _dereq_('../internals/get-map-iterator');
- var iterate = _dereq_('../internals/iterate');
- // `Map.prototype.filter` method
- // https://github.com/tc39/proposal-collection-methods
- $({ target: 'Map', proto: true, real: true, forced: IS_PURE }, {
- filter: function filter(callbackfn /* , thisArg */) {
- var map = anObject(this);
- var iterator = getMapIterator(map);
- var boundFunction = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined);
- var newMap = new (speciesConstructor(map, getBuiltIn('Map')))();
- var setter = aCallable(newMap.set);
- iterate(iterator, function (key, value) {
- if (boundFunction(value, key, map)) call(setter, newMap, key, value);
- }, { AS_ENTRIES: true, IS_ITERATOR: true });
- return newMap;
- }
- });
- },{"../internals/a-callable":421,"../internals/an-object":426,"../internals/export":476,"../internals/function-bind-context":480,"../internals/function-call":483,"../internals/get-built-in":486,"../internals/get-map-iterator":489,"../internals/is-pure":510,"../internals/iterate":513,"../internals/species-constructor":562}],660:[function(_dereq_,module,exports){
- 'use strict';
- var $ = _dereq_('../internals/export');
- var IS_PURE = _dereq_('../internals/is-pure');
- var anObject = _dereq_('../internals/an-object');
- var bind = _dereq_('../internals/function-bind-context');
- var getMapIterator = _dereq_('../internals/get-map-iterator');
- var iterate = _dereq_('../internals/iterate');
- // `Map.prototype.findKey` method
- // https://github.com/tc39/proposal-collection-methods
- $({ target: 'Map', proto: true, real: true, forced: IS_PURE }, {
- findKey: function findKey(callbackfn /* , thisArg */) {
- var map = anObject(this);
- var iterator = getMapIterator(map);
- var boundFunction = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined);
- return iterate(iterator, function (key, value, stop) {
- if (boundFunction(value, key, map)) return stop(key);
- }, { AS_ENTRIES: true, IS_ITERATOR: true, INTERRUPTED: true }).result;
- }
- });
- },{"../internals/an-object":426,"../internals/export":476,"../internals/function-bind-context":480,"../internals/get-map-iterator":489,"../internals/is-pure":510,"../internals/iterate":513}],661:[function(_dereq_,module,exports){
- 'use strict';
- var $ = _dereq_('../internals/export');
- var IS_PURE = _dereq_('../internals/is-pure');
- var anObject = _dereq_('../internals/an-object');
- var bind = _dereq_('../internals/function-bind-context');
- var getMapIterator = _dereq_('../internals/get-map-iterator');
- var iterate = _dereq_('../internals/iterate');
- // `Map.prototype.find` method
- // https://github.com/tc39/proposal-collection-methods
- $({ target: 'Map', proto: true, real: true, forced: IS_PURE }, {
- find: function find(callbackfn /* , thisArg */) {
- var map = anObject(this);
- var iterator = getMapIterator(map);
- var boundFunction = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined);
- return iterate(iterator, function (key, value, stop) {
- if (boundFunction(value, key, map)) return stop(value);
- }, { AS_ENTRIES: true, IS_ITERATOR: true, INTERRUPTED: true }).result;
- }
- });
- },{"../internals/an-object":426,"../internals/export":476,"../internals/function-bind-context":480,"../internals/get-map-iterator":489,"../internals/is-pure":510,"../internals/iterate":513}],662:[function(_dereq_,module,exports){
- var $ = _dereq_('../internals/export');
- var from = _dereq_('../internals/collection-from');
- // `Map.from` method
- // https://tc39.github.io/proposal-setmap-offrom/#sec-map.from
- $({ target: 'Map', stat: true }, {
- from: from
- });
- },{"../internals/collection-from":446,"../internals/export":476}],663:[function(_dereq_,module,exports){
- 'use strict';
- var $ = _dereq_('../internals/export');
- var call = _dereq_('../internals/function-call');
- var uncurryThis = _dereq_('../internals/function-uncurry-this');
- var aCallable = _dereq_('../internals/a-callable');
- var getIterator = _dereq_('../internals/get-iterator');
- var iterate = _dereq_('../internals/iterate');
- var push = uncurryThis([].push);
- // `Map.groupBy` method
- // https://github.com/tc39/proposal-collection-methods
- $({ target: 'Map', stat: true }, {
- groupBy: function groupBy(iterable, keyDerivative) {
- aCallable(keyDerivative);
- var iterator = getIterator(iterable);
- var newMap = new this();
- var has = aCallable(newMap.has);
- var get = aCallable(newMap.get);
- var set = aCallable(newMap.set);
- iterate(iterator, function (element) {
- var derivedKey = keyDerivative(element);
- if (!call(has, newMap, derivedKey)) call(set, newMap, derivedKey, [element]);
- else push(call(get, newMap, derivedKey), element);
- }, { IS_ITERATOR: true });
- return newMap;
- }
- });
- },{"../internals/a-callable":421,"../internals/export":476,"../internals/function-call":483,"../internals/function-uncurry-this":485,"../internals/get-iterator":488,"../internals/iterate":513}],664:[function(_dereq_,module,exports){
- 'use strict';
- var IS_PURE = _dereq_('../internals/is-pure');
- var $ = _dereq_('../internals/export');
- var anObject = _dereq_('../internals/an-object');
- var getMapIterator = _dereq_('../internals/get-map-iterator');
- var sameValueZero = _dereq_('../internals/same-value-zero');
- var iterate = _dereq_('../internals/iterate');
- // `Map.prototype.includes` method
- // https://github.com/tc39/proposal-collection-methods
- $({ target: 'Map', proto: true, real: true, forced: IS_PURE }, {
- includes: function includes(searchElement) {
- return iterate(getMapIterator(anObject(this)), function (key, value, stop) {
- if (sameValueZero(value, searchElement)) return stop();
- }, { AS_ENTRIES: true, IS_ITERATOR: true, INTERRUPTED: true }).stopped;
- }
- });
- },{"../internals/an-object":426,"../internals/export":476,"../internals/get-map-iterator":489,"../internals/is-pure":510,"../internals/iterate":513,"../internals/same-value-zero":555}],665:[function(_dereq_,module,exports){
- 'use strict';
- var $ = _dereq_('../internals/export');
- var call = _dereq_('../internals/function-call');
- var iterate = _dereq_('../internals/iterate');
- var aCallable = _dereq_('../internals/a-callable');
- // `Map.keyBy` method
- // https://github.com/tc39/proposal-collection-methods
- $({ target: 'Map', stat: true }, {
- keyBy: function keyBy(iterable, keyDerivative) {
- var newMap = new this();
- aCallable(keyDerivative);
- var setter = aCallable(newMap.set);
- iterate(iterable, function (element) {
- call(setter, newMap, keyDerivative(element), element);
- });
- return newMap;
- }
- });
- },{"../internals/a-callable":421,"../internals/export":476,"../internals/function-call":483,"../internals/iterate":513}],666:[function(_dereq_,module,exports){
- 'use strict';
- var $ = _dereq_('../internals/export');
- var IS_PURE = _dereq_('../internals/is-pure');
- var anObject = _dereq_('../internals/an-object');
- var getMapIterator = _dereq_('../internals/get-map-iterator');
- var iterate = _dereq_('../internals/iterate');
- // `Map.prototype.keyOf` method
- // https://github.com/tc39/proposal-collection-methods
- $({ target: 'Map', proto: true, real: true, forced: IS_PURE }, {
- keyOf: function keyOf(searchElement) {
- return iterate(getMapIterator(anObject(this)), function (key, value, stop) {
- if (value === searchElement) return stop(key);
- }, { AS_ENTRIES: true, IS_ITERATOR: true, INTERRUPTED: true }).result;
- }
- });
- },{"../internals/an-object":426,"../internals/export":476,"../internals/get-map-iterator":489,"../internals/is-pure":510,"../internals/iterate":513}],667:[function(_dereq_,module,exports){
- 'use strict';
- var IS_PURE = _dereq_('../internals/is-pure');
- var $ = _dereq_('../internals/export');
- var getBuiltIn = _dereq_('../internals/get-built-in');
- var bind = _dereq_('../internals/function-bind-context');
- var call = _dereq_('../internals/function-call');
- var aCallable = _dereq_('../internals/a-callable');
- var anObject = _dereq_('../internals/an-object');
- var speciesConstructor = _dereq_('../internals/species-constructor');
- var getMapIterator = _dereq_('../internals/get-map-iterator');
- var iterate = _dereq_('../internals/iterate');
- // `Map.prototype.mapKeys` method
- // https://github.com/tc39/proposal-collection-methods
- $({ target: 'Map', proto: true, real: true, forced: IS_PURE }, {
- mapKeys: function mapKeys(callbackfn /* , thisArg */) {
- var map = anObject(this);
- var iterator = getMapIterator(map);
- var boundFunction = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined);
- var newMap = new (speciesConstructor(map, getBuiltIn('Map')))();
- var setter = aCallable(newMap.set);
- iterate(iterator, function (key, value) {
- call(setter, newMap, boundFunction(value, key, map), value);
- }, { AS_ENTRIES: true, IS_ITERATOR: true });
- return newMap;
- }
- });
- },{"../internals/a-callable":421,"../internals/an-object":426,"../internals/export":476,"../internals/function-bind-context":480,"../internals/function-call":483,"../internals/get-built-in":486,"../internals/get-map-iterator":489,"../internals/is-pure":510,"../internals/iterate":513,"../internals/species-constructor":562}],668:[function(_dereq_,module,exports){
- 'use strict';
- var IS_PURE = _dereq_('../internals/is-pure');
- var $ = _dereq_('../internals/export');
- var getBuiltIn = _dereq_('../internals/get-built-in');
- var bind = _dereq_('../internals/function-bind-context');
- var call = _dereq_('../internals/function-call');
- var aCallable = _dereq_('../internals/a-callable');
- var anObject = _dereq_('../internals/an-object');
- var speciesConstructor = _dereq_('../internals/species-constructor');
- var getMapIterator = _dereq_('../internals/get-map-iterator');
- var iterate = _dereq_('../internals/iterate');
- // `Map.prototype.mapValues` method
- // https://github.com/tc39/proposal-collection-methods
- $({ target: 'Map', proto: true, real: true, forced: IS_PURE }, {
- mapValues: function mapValues(callbackfn /* , thisArg */) {
- var map = anObject(this);
- var iterator = getMapIterator(map);
- var boundFunction = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined);
- var newMap = new (speciesConstructor(map, getBuiltIn('Map')))();
- var setter = aCallable(newMap.set);
- iterate(iterator, function (key, value) {
- call(setter, newMap, key, boundFunction(value, key, map));
- }, { AS_ENTRIES: true, IS_ITERATOR: true });
- return newMap;
- }
- });
- },{"../internals/a-callable":421,"../internals/an-object":426,"../internals/export":476,"../internals/function-bind-context":480,"../internals/function-call":483,"../internals/get-built-in":486,"../internals/get-map-iterator":489,"../internals/is-pure":510,"../internals/iterate":513,"../internals/species-constructor":562}],669:[function(_dereq_,module,exports){
- 'use strict';
- var $ = _dereq_('../internals/export');
- var IS_PURE = _dereq_('../internals/is-pure');
- var aCallable = _dereq_('../internals/a-callable');
- var anObject = _dereq_('../internals/an-object');
- var iterate = _dereq_('../internals/iterate');
- // `Map.prototype.merge` method
- // https://github.com/tc39/proposal-collection-methods
- $({ target: 'Map', proto: true, real: true, forced: IS_PURE }, {
- // eslint-disable-next-line no-unused-vars -- required for `.length`
- merge: function merge(iterable /* ...iterables */) {
- var map = anObject(this);
- var setter = aCallable(map.set);
- var argumentsLength = arguments.length;
- var i = 0;
- while (i < argumentsLength) {
- iterate(arguments[i++], setter, { that: map, AS_ENTRIES: true });
- }
- return map;
- }
- });
- },{"../internals/a-callable":421,"../internals/an-object":426,"../internals/export":476,"../internals/is-pure":510,"../internals/iterate":513}],670:[function(_dereq_,module,exports){
- var $ = _dereq_('../internals/export');
- var of = _dereq_('../internals/collection-of');
- // `Map.of` method
- // https://tc39.github.io/proposal-setmap-offrom/#sec-map.of
- $({ target: 'Map', stat: true }, {
- of: of
- });
- },{"../internals/collection-of":447,"../internals/export":476}],671:[function(_dereq_,module,exports){
- 'use strict';
- var $ = _dereq_('../internals/export');
- var global = _dereq_('../internals/global');
- var IS_PURE = _dereq_('../internals/is-pure');
- var anObject = _dereq_('../internals/an-object');
- var aCallable = _dereq_('../internals/a-callable');
- var getMapIterator = _dereq_('../internals/get-map-iterator');
- var iterate = _dereq_('../internals/iterate');
- var TypeError = global.TypeError;
- // `Map.prototype.reduce` method
- // https://github.com/tc39/proposal-collection-methods
- $({ target: 'Map', proto: true, real: true, forced: IS_PURE }, {
- reduce: function reduce(callbackfn /* , initialValue */) {
- var map = anObject(this);
- var iterator = getMapIterator(map);
- var noInitial = arguments.length < 2;
- var accumulator = noInitial ? undefined : arguments[1];
- aCallable(callbackfn);
- iterate(iterator, function (key, value) {
- if (noInitial) {
- noInitial = false;
- accumulator = value;
- } else {
- accumulator = callbackfn(accumulator, value, key, map);
- }
- }, { AS_ENTRIES: true, IS_ITERATOR: true });
- if (noInitial) throw TypeError('Reduce of empty map with no initial value');
- return accumulator;
- }
- });
- },{"../internals/a-callable":421,"../internals/an-object":426,"../internals/export":476,"../internals/get-map-iterator":489,"../internals/global":491,"../internals/is-pure":510,"../internals/iterate":513}],672:[function(_dereq_,module,exports){
- 'use strict';
- var $ = _dereq_('../internals/export');
- var IS_PURE = _dereq_('../internals/is-pure');
- var anObject = _dereq_('../internals/an-object');
- var bind = _dereq_('../internals/function-bind-context');
- var getMapIterator = _dereq_('../internals/get-map-iterator');
- var iterate = _dereq_('../internals/iterate');
- // `Set.prototype.some` method
- // https://github.com/tc39/proposal-collection-methods
- $({ target: 'Map', proto: true, real: true, forced: IS_PURE }, {
- some: function some(callbackfn /* , thisArg */) {
- var map = anObject(this);
- var iterator = getMapIterator(map);
- var boundFunction = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined);
- return iterate(iterator, function (key, value, stop) {
- if (boundFunction(value, key, map)) return stop();
- }, { AS_ENTRIES: true, IS_ITERATOR: true, INTERRUPTED: true }).stopped;
- }
- });
- },{"../internals/an-object":426,"../internals/export":476,"../internals/function-bind-context":480,"../internals/get-map-iterator":489,"../internals/is-pure":510,"../internals/iterate":513}],673:[function(_dereq_,module,exports){
- 'use strict';
- // TODO: remove from `core-js@4`
- var $ = _dereq_('../internals/export');
- var IS_PURE = _dereq_('../internals/is-pure');
- var upsert = _dereq_('../internals/map-upsert');
- // `Map.prototype.updateOrInsert` method (replaced by `Map.prototype.emplace`)
- // https://github.com/thumbsupep/proposal-upsert
- $({ target: 'Map', proto: true, real: true, name: 'upsert', forced: IS_PURE }, {
- updateOrInsert: upsert
- });
- },{"../internals/export":476,"../internals/is-pure":510,"../internals/map-upsert":519}],674:[function(_dereq_,module,exports){
- 'use strict';
- var IS_PURE = _dereq_('../internals/is-pure');
- var $ = _dereq_('../internals/export');
- var global = _dereq_('../internals/global');
- var call = _dereq_('../internals/function-call');
- var anObject = _dereq_('../internals/an-object');
- var aCallable = _dereq_('../internals/a-callable');
- var TypeError = global.TypeError;
- // `Set.prototype.update` method
- // https://github.com/tc39/proposal-collection-methods
- $({ target: 'Map', proto: true, real: true, forced: IS_PURE }, {
- update: function update(key, callback /* , thunk */) {
- var map = anObject(this);
- var get = aCallable(map.get);
- var has = aCallable(map.has);
- var set = aCallable(map.set);
- var length = arguments.length;
- aCallable(callback);
- var isPresentInMap = call(has, map, key);
- if (!isPresentInMap && length < 3) {
- throw TypeError('Updating absent value');
- }
- var value = isPresentInMap ? call(get, map, key) : aCallable(length > 2 ? arguments[2] : undefined)(key, map);
- call(set, map, key, callback(value, key, map));
- return map;
- }
- });
- },{"../internals/a-callable":421,"../internals/an-object":426,"../internals/export":476,"../internals/function-call":483,"../internals/global":491,"../internals/is-pure":510}],675:[function(_dereq_,module,exports){
- 'use strict';
- // TODO: remove from `core-js@4`
- var $ = _dereq_('../internals/export');
- var IS_PURE = _dereq_('../internals/is-pure');
- var upsert = _dereq_('../internals/map-upsert');
- // `Map.prototype.upsert` method (replaced by `Map.prototype.emplace`)
- // https://github.com/thumbsupep/proposal-upsert
- $({ target: 'Map', proto: true, real: true, forced: IS_PURE }, {
- upsert: upsert
- });
- },{"../internals/export":476,"../internals/is-pure":510,"../internals/map-upsert":519}],676:[function(_dereq_,module,exports){
- // TODO: Remove from `core-js@4`
- _dereq_('../modules/es.promise.all-settled.js');
- },{"../modules/es.promise.all-settled.js":624}],677:[function(_dereq_,module,exports){
- // TODO: Remove from `core-js@4`
- _dereq_('../modules/es.promise.any');
- },{"../modules/es.promise.any":625}],678:[function(_dereq_,module,exports){
- 'use strict';
- var $ = _dereq_('../internals/export');
- var newPromiseCapabilityModule = _dereq_('../internals/new-promise-capability');
- var perform = _dereq_('../internals/perform');
- // `Promise.try` method
- // https://github.com/tc39/proposal-promise-try
- $({ target: 'Promise', stat: true }, {
- 'try': function (callbackfn) {
- var promiseCapability = newPromiseCapabilityModule.f(this);
- var result = perform(callbackfn);
- (result.error ? promiseCapability.reject : promiseCapability.resolve)(result.value);
- return promiseCapability.promise;
- }
- });
- },{"../internals/export":476,"../internals/new-promise-capability":525,"../internals/perform":549}],679:[function(_dereq_,module,exports){
- var defineWellKnownSymbol = _dereq_('../internals/define-well-known-symbol');
- // `Symbol.asyncDispose` well-known symbol
- // https://github.com/tc39/proposal-using-statement
- defineWellKnownSymbol('asyncDispose');
- },{"../internals/define-well-known-symbol":459}],680:[function(_dereq_,module,exports){
- var defineWellKnownSymbol = _dereq_('../internals/define-well-known-symbol');
- // `Symbol.dispose` well-known symbol
- // https://github.com/tc39/proposal-using-statement
- defineWellKnownSymbol('dispose');
- },{"../internals/define-well-known-symbol":459}],681:[function(_dereq_,module,exports){
- var defineWellKnownSymbol = _dereq_('../internals/define-well-known-symbol');
- // `Symbol.matcher` well-known symbol
- // https://github.com/tc39/proposal-pattern-matching
- defineWellKnownSymbol('matcher');
- },{"../internals/define-well-known-symbol":459}],682:[function(_dereq_,module,exports){
- var defineWellKnownSymbol = _dereq_('../internals/define-well-known-symbol');
- // `Symbol.metadata` well-known symbol
- // https://github.com/tc39/proposal-decorators
- defineWellKnownSymbol('metadata');
- },{"../internals/define-well-known-symbol":459}],683:[function(_dereq_,module,exports){
- var defineWellKnownSymbol = _dereq_('../internals/define-well-known-symbol');
- // `Symbol.observable` well-known symbol
- // https://github.com/tc39/proposal-observable
- defineWellKnownSymbol('observable');
- },{"../internals/define-well-known-symbol":459}],684:[function(_dereq_,module,exports){
- // TODO: remove from `core-js@4`
- var defineWellKnownSymbol = _dereq_('../internals/define-well-known-symbol');
- // `Symbol.patternMatch` well-known symbol
- // https://github.com/tc39/proposal-pattern-matching
- defineWellKnownSymbol('patternMatch');
- },{"../internals/define-well-known-symbol":459}],685:[function(_dereq_,module,exports){
- // TODO: remove from `core-js@4`
- var defineWellKnownSymbol = _dereq_('../internals/define-well-known-symbol');
- defineWellKnownSymbol('replaceAll');
- },{"../internals/define-well-known-symbol":459}],686:[function(_dereq_,module,exports){
- _dereq_('../modules/es.array.iterator');
- var DOMIterables = _dereq_('../internals/dom-iterables');
- var global = _dereq_('../internals/global');
- var classof = _dereq_('../internals/classof');
- var createNonEnumerableProperty = _dereq_('../internals/create-non-enumerable-property');
- var Iterators = _dereq_('../internals/iterators');
- var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
- var TO_STRING_TAG = wellKnownSymbol('toStringTag');
- for (var COLLECTION_NAME in DOMIterables) {
- var Collection = global[COLLECTION_NAME];
- var CollectionPrototype = Collection && Collection.prototype;
- if (CollectionPrototype && classof(CollectionPrototype) !== TO_STRING_TAG) {
- createNonEnumerableProperty(CollectionPrototype, TO_STRING_TAG, COLLECTION_NAME);
- }
- Iterators[COLLECTION_NAME] = Iterators.Array;
- }
- },{"../internals/classof":443,"../internals/create-non-enumerable-property":455,"../internals/dom-iterables":462,"../internals/global":491,"../internals/iterators":516,"../internals/well-known-symbol":586,"../modules/es.array.iterator":598}],687:[function(_dereq_,module,exports){
- var $ = _dereq_('../internals/export');
- var global = _dereq_('../internals/global');
- var apply = _dereq_('../internals/function-apply');
- var isCallable = _dereq_('../internals/is-callable');
- var userAgent = _dereq_('../internals/engine-user-agent');
- var arraySlice = _dereq_('../internals/array-slice');
- var MSIE = /MSIE .\./.test(userAgent); // <- dirty ie9- check
- var Function = global.Function;
- var wrap = function (scheduler) {
- return function (handler, timeout /* , ...arguments */) {
- var boundArgs = arguments.length > 2;
- var args = boundArgs ? arraySlice(arguments, 2) : undefined;
- return scheduler(boundArgs ? function () {
- apply(isCallable(handler) ? handler : Function(handler), this, args);
- } : handler, timeout);
- };
- };
- // ie9- setTimeout & setInterval additional parameters fix
- // https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#timers
- $({ global: true, bind: true, forced: MSIE }, {
- // `setTimeout` method
- // https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-settimeout
- setTimeout: wrap(global.setTimeout),
- // `setInterval` method
- // https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-setinterval
- setInterval: wrap(global.setInterval)
- });
- },{"../internals/array-slice":436,"../internals/engine-user-agent":470,"../internals/export":476,"../internals/function-apply":479,"../internals/global":491,"../internals/is-callable":504}],688:[function(_dereq_,module,exports){
- 'use strict';
- // TODO: in core-js@4, move /modules/ dependencies to public entries for better optimization by tools like `preset-env`
- _dereq_('../modules/es.array.iterator');
- var $ = _dereq_('../internals/export');
- var global = _dereq_('../internals/global');
- var getBuiltIn = _dereq_('../internals/get-built-in');
- var call = _dereq_('../internals/function-call');
- var uncurryThis = _dereq_('../internals/function-uncurry-this');
- var USE_NATIVE_URL = _dereq_('../internals/native-url');
- var redefine = _dereq_('../internals/redefine');
- var redefineAll = _dereq_('../internals/redefine-all');
- var setToStringTag = _dereq_('../internals/set-to-string-tag');
- var createIteratorConstructor = _dereq_('../internals/create-iterator-constructor');
- var InternalStateModule = _dereq_('../internals/internal-state');
- var anInstance = _dereq_('../internals/an-instance');
- var isCallable = _dereq_('../internals/is-callable');
- var hasOwn = _dereq_('../internals/has-own-property');
- var bind = _dereq_('../internals/function-bind-context');
- var classof = _dereq_('../internals/classof');
- var anObject = _dereq_('../internals/an-object');
- var isObject = _dereq_('../internals/is-object');
- var $toString = _dereq_('../internals/to-string');
- var create = _dereq_('../internals/object-create');
- var createPropertyDescriptor = _dereq_('../internals/create-property-descriptor');
- var getIterator = _dereq_('../internals/get-iterator');
- var getIteratorMethod = _dereq_('../internals/get-iterator-method');
- var validateArgumentsLength = _dereq_('../internals/validate-arguments-length');
- var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
- var arraySort = _dereq_('../internals/array-sort');
- var ITERATOR = wellKnownSymbol('iterator');
- var URL_SEARCH_PARAMS = 'URLSearchParams';
- var URL_SEARCH_PARAMS_ITERATOR = URL_SEARCH_PARAMS + 'Iterator';
- var setInternalState = InternalStateModule.set;
- var getInternalParamsState = InternalStateModule.getterFor(URL_SEARCH_PARAMS);
- var getInternalIteratorState = InternalStateModule.getterFor(URL_SEARCH_PARAMS_ITERATOR);
- var n$Fetch = getBuiltIn('fetch');
- var N$Request = getBuiltIn('Request');
- var Headers = getBuiltIn('Headers');
- var RequestPrototype = N$Request && N$Request.prototype;
- var HeadersPrototype = Headers && Headers.prototype;
- var RegExp = global.RegExp;
- var TypeError = global.TypeError;
- var decodeURIComponent = global.decodeURIComponent;
- var encodeURIComponent = global.encodeURIComponent;
- var charAt = uncurryThis(''.charAt);
- var join = uncurryThis([].join);
- var push = uncurryThis([].push);
- var replace = uncurryThis(''.replace);
- var shift = uncurryThis([].shift);
- var splice = uncurryThis([].splice);
- var split = uncurryThis(''.split);
- var stringSlice = uncurryThis(''.slice);
- var plus = /\+/g;
- var sequences = Array(4);
- var percentSequence = function (bytes) {
- return sequences[bytes - 1] || (sequences[bytes - 1] = RegExp('((?:%[\\da-f]{2}){' + bytes + '})', 'gi'));
- };
- var percentDecode = function (sequence) {
- try {
- return decodeURIComponent(sequence);
- } catch (error) {
- return sequence;
- }
- };
- var deserialize = function (it) {
- var result = replace(it, plus, ' ');
- var bytes = 4;
- try {
- return decodeURIComponent(result);
- } catch (error) {
- while (bytes) {
- result = replace(result, percentSequence(bytes--), percentDecode);
- }
- return result;
- }
- };
- var find = /[!'()~]|%20/g;
- var replacements = {
- '!': '%21',
- "'": '%27',
- '(': '%28',
- ')': '%29',
- '~': '%7E',
- '%20': '+'
- };
- var replacer = function (match) {
- return replacements[match];
- };
- var serialize = function (it) {
- return replace(encodeURIComponent(it), find, replacer);
- };
- var URLSearchParamsIterator = createIteratorConstructor(function Iterator(params, kind) {
- setInternalState(this, {
- type: URL_SEARCH_PARAMS_ITERATOR,
- iterator: getIterator(getInternalParamsState(params).entries),
- kind: kind
- });
- }, 'Iterator', function next() {
- var state = getInternalIteratorState(this);
- var kind = state.kind;
- var step = state.iterator.next();
- var entry = step.value;
- if (!step.done) {
- step.value = kind === 'keys' ? entry.key : kind === 'values' ? entry.value : [entry.key, entry.value];
- } return step;
- }, true);
- var URLSearchParamsState = function (init) {
- this.entries = [];
- this.url = null;
- if (init !== undefined) {
- if (isObject(init)) this.parseObject(init);
- else this.parseQuery(typeof init == 'string' ? charAt(init, 0) === '?' ? stringSlice(init, 1) : init : $toString(init));
- }
- };
- URLSearchParamsState.prototype = {
- type: URL_SEARCH_PARAMS,
- bindURL: function (url) {
- this.url = url;
- this.update();
- },
- parseObject: function (object) {
- var iteratorMethod = getIteratorMethod(object);
- var iterator, next, step, entryIterator, entryNext, first, second;
- if (iteratorMethod) {
- iterator = getIterator(object, iteratorMethod);
- next = iterator.next;
- while (!(step = call(next, iterator)).done) {
- entryIterator = getIterator(anObject(step.value));
- entryNext = entryIterator.next;
- if (
- (first = call(entryNext, entryIterator)).done ||
- (second = call(entryNext, entryIterator)).done ||
- !call(entryNext, entryIterator).done
- ) throw TypeError('Expected sequence with length 2');
- push(this.entries, { key: $toString(first.value), value: $toString(second.value) });
- }
- } else for (var key in object) if (hasOwn(object, key)) {
- push(this.entries, { key: key, value: $toString(object[key]) });
- }
- },
- parseQuery: function (query) {
- if (query) {
- var attributes = split(query, '&');
- var index = 0;
- var attribute, entry;
- while (index < attributes.length) {
- attribute = attributes[index++];
- if (attribute.length) {
- entry = split(attribute, '=');
- push(this.entries, {
- key: deserialize(shift(entry)),
- value: deserialize(join(entry, '='))
- });
- }
- }
- }
- },
- serialize: function () {
- var entries = this.entries;
- var result = [];
- var index = 0;
- var entry;
- while (index < entries.length) {
- entry = entries[index++];
- push(result, serialize(entry.key) + '=' + serialize(entry.value));
- } return join(result, '&');
- },
- update: function () {
- this.entries.length = 0;
- this.parseQuery(this.url.query);
- },
- updateURL: function () {
- if (this.url) this.url.update();
- }
- };
- // `URLSearchParams` constructor
- // https://url.spec.whatwg.org/#interface-urlsearchparams
- var URLSearchParamsConstructor = function URLSearchParams(/* init */) {
- anInstance(this, URLSearchParamsPrototype);
- var init = arguments.length > 0 ? arguments[0] : undefined;
- setInternalState(this, new URLSearchParamsState(init));
- };
- var URLSearchParamsPrototype = URLSearchParamsConstructor.prototype;
- redefineAll(URLSearchParamsPrototype, {
- // `URLSearchParams.prototype.append` method
- // https://url.spec.whatwg.org/#dom-urlsearchparams-append
- append: function append(name, value) {
- validateArgumentsLength(arguments.length, 2);
- var state = getInternalParamsState(this);
- push(state.entries, { key: $toString(name), value: $toString(value) });
- state.updateURL();
- },
- // `URLSearchParams.prototype.delete` method
- // https://url.spec.whatwg.org/#dom-urlsearchparams-delete
- 'delete': function (name) {
- validateArgumentsLength(arguments.length, 1);
- var state = getInternalParamsState(this);
- var entries = state.entries;
- var key = $toString(name);
- var index = 0;
- while (index < entries.length) {
- if (entries[index].key === key) splice(entries, index, 1);
- else index++;
- }
- state.updateURL();
- },
- // `URLSearchParams.prototype.get` method
- // https://url.spec.whatwg.org/#dom-urlsearchparams-get
- get: function get(name) {
- validateArgumentsLength(arguments.length, 1);
- var entries = getInternalParamsState(this).entries;
- var key = $toString(name);
- var index = 0;
- for (; index < entries.length; index++) {
- if (entries[index].key === key) return entries[index].value;
- }
- return null;
- },
- // `URLSearchParams.prototype.getAll` method
- // https://url.spec.whatwg.org/#dom-urlsearchparams-getall
- getAll: function getAll(name) {
- validateArgumentsLength(arguments.length, 1);
- var entries = getInternalParamsState(this).entries;
- var key = $toString(name);
- var result = [];
- var index = 0;
- for (; index < entries.length; index++) {
- if (entries[index].key === key) push(result, entries[index].value);
- }
- return result;
- },
- // `URLSearchParams.prototype.has` method
- // https://url.spec.whatwg.org/#dom-urlsearchparams-has
- has: function has(name) {
- validateArgumentsLength(arguments.length, 1);
- var entries = getInternalParamsState(this).entries;
- var key = $toString(name);
- var index = 0;
- while (index < entries.length) {
- if (entries[index++].key === key) return true;
- }
- return false;
- },
- // `URLSearchParams.prototype.set` method
- // https://url.spec.whatwg.org/#dom-urlsearchparams-set
- set: function set(name, value) {
- validateArgumentsLength(arguments.length, 1);
- var state = getInternalParamsState(this);
- var entries = state.entries;
- var found = false;
- var key = $toString(name);
- var val = $toString(value);
- var index = 0;
- var entry;
- for (; index < entries.length; index++) {
- entry = entries[index];
- if (entry.key === key) {
- if (found) splice(entries, index--, 1);
- else {
- found = true;
- entry.value = val;
- }
- }
- }
- if (!found) push(entries, { key: key, value: val });
- state.updateURL();
- },
- // `URLSearchParams.prototype.sort` method
- // https://url.spec.whatwg.org/#dom-urlsearchparams-sort
- sort: function sort() {
- var state = getInternalParamsState(this);
- arraySort(state.entries, function (a, b) {
- return a.key > b.key ? 1 : -1;
- });
- state.updateURL();
- },
- // `URLSearchParams.prototype.forEach` method
- forEach: function forEach(callback /* , thisArg */) {
- var entries = getInternalParamsState(this).entries;
- var boundFunction = bind(callback, arguments.length > 1 ? arguments[1] : undefined);
- var index = 0;
- var entry;
- while (index < entries.length) {
- entry = entries[index++];
- boundFunction(entry.value, entry.key, this);
- }
- },
- // `URLSearchParams.prototype.keys` method
- keys: function keys() {
- return new URLSearchParamsIterator(this, 'keys');
- },
- // `URLSearchParams.prototype.values` method
- values: function values() {
- return new URLSearchParamsIterator(this, 'values');
- },
- // `URLSearchParams.prototype.entries` method
- entries: function entries() {
- return new URLSearchParamsIterator(this, 'entries');
- }
- }, { enumerable: true });
- // `URLSearchParams.prototype[@@iterator]` method
- redefine(URLSearchParamsPrototype, ITERATOR, URLSearchParamsPrototype.entries, { name: 'entries' });
- // `URLSearchParams.prototype.toString` method
- // https://url.spec.whatwg.org/#urlsearchparams-stringification-behavior
- redefine(URLSearchParamsPrototype, 'toString', function toString() {
- return getInternalParamsState(this).serialize();
- }, { enumerable: true });
- setToStringTag(URLSearchParamsConstructor, URL_SEARCH_PARAMS);
- $({ global: true, forced: !USE_NATIVE_URL }, {
- URLSearchParams: URLSearchParamsConstructor
- });
- // Wrap `fetch` and `Request` for correct work with polyfilled `URLSearchParams`
- if (!USE_NATIVE_URL && isCallable(Headers)) {
- var headersHas = uncurryThis(HeadersPrototype.has);
- var headersSet = uncurryThis(HeadersPrototype.set);
- var wrapRequestOptions = function (init) {
- if (isObject(init)) {
- var body = init.body;
- var headers;
- if (classof(body) === URL_SEARCH_PARAMS) {
- headers = init.headers ? new Headers(init.headers) : new Headers();
- if (!headersHas(headers, 'content-type')) {
- headersSet(headers, 'content-type', 'application/x-www-form-urlencoded;charset=UTF-8');
- }
- return create(init, {
- body: createPropertyDescriptor(0, $toString(body)),
- headers: createPropertyDescriptor(0, headers)
- });
- }
- } return init;
- };
- if (isCallable(n$Fetch)) {
- $({ global: true, enumerable: true, forced: true }, {
- fetch: function fetch(input /* , init */) {
- return n$Fetch(input, arguments.length > 1 ? wrapRequestOptions(arguments[1]) : {});
- }
- });
- }
- if (isCallable(N$Request)) {
- var RequestConstructor = function Request(input /* , init */) {
- anInstance(this, RequestPrototype);
- return new N$Request(input, arguments.length > 1 ? wrapRequestOptions(arguments[1]) : {});
- };
- RequestPrototype.constructor = RequestConstructor;
- RequestConstructor.prototype = RequestPrototype;
- $({ global: true, forced: true }, {
- Request: RequestConstructor
- });
- }
- }
- module.exports = {
- URLSearchParams: URLSearchParamsConstructor,
- getState: getInternalParamsState
- };
- },{"../internals/an-instance":425,"../internals/an-object":426,"../internals/array-sort":437,"../internals/classof":443,"../internals/create-iterator-constructor":454,"../internals/create-property-descriptor":456,"../internals/export":476,"../internals/function-bind-context":480,"../internals/function-call":483,"../internals/function-uncurry-this":485,"../internals/get-built-in":486,"../internals/get-iterator":488,"../internals/get-iterator-method":487,"../internals/global":491,"../internals/has-own-property":492,"../internals/internal-state":501,"../internals/is-callable":504,"../internals/is-object":509,"../internals/native-url":523,"../internals/object-create":530,"../internals/redefine":553,"../internals/redefine-all":552,"../internals/set-to-string-tag":558,"../internals/to-string":579,"../internals/validate-arguments-length":584,"../internals/well-known-symbol":586,"../modules/es.array.iterator":598}],689:[function(_dereq_,module,exports){
- 'use strict';
- // TODO: in core-js@4, move /modules/ dependencies to public entries for better optimization by tools like `preset-env`
- _dereq_('../modules/es.string.iterator');
- var $ = _dereq_('../internals/export');
- var DESCRIPTORS = _dereq_('../internals/descriptors');
- var USE_NATIVE_URL = _dereq_('../internals/native-url');
- var global = _dereq_('../internals/global');
- var bind = _dereq_('../internals/function-bind-context');
- var uncurryThis = _dereq_('../internals/function-uncurry-this');
- var defineProperties = _dereq_('../internals/object-define-properties').f;
- var redefine = _dereq_('../internals/redefine');
- var anInstance = _dereq_('../internals/an-instance');
- var hasOwn = _dereq_('../internals/has-own-property');
- var assign = _dereq_('../internals/object-assign');
- var arrayFrom = _dereq_('../internals/array-from');
- var arraySlice = _dereq_('../internals/array-slice-simple');
- var codeAt = _dereq_('../internals/string-multibyte').codeAt;
- var toASCII = _dereq_('../internals/string-punycode-to-ascii');
- var $toString = _dereq_('../internals/to-string');
- var setToStringTag = _dereq_('../internals/set-to-string-tag');
- var URLSearchParamsModule = _dereq_('../modules/web.url-search-params');
- var InternalStateModule = _dereq_('../internals/internal-state');
- var setInternalState = InternalStateModule.set;
- var getInternalURLState = InternalStateModule.getterFor('URL');
- var URLSearchParams = URLSearchParamsModule.URLSearchParams;
- var getInternalSearchParamsState = URLSearchParamsModule.getState;
- var NativeURL = global.URL;
- var TypeError = global.TypeError;
- var parseInt = global.parseInt;
- var floor = Math.floor;
- var pow = Math.pow;
- var charAt = uncurryThis(''.charAt);
- var exec = uncurryThis(/./.exec);
- var join = uncurryThis([].join);
- var numberToString = uncurryThis(1.0.toString);
- var pop = uncurryThis([].pop);
- var push = uncurryThis([].push);
- var replace = uncurryThis(''.replace);
- var shift = uncurryThis([].shift);
- var split = uncurryThis(''.split);
- var stringSlice = uncurryThis(''.slice);
- var toLowerCase = uncurryThis(''.toLowerCase);
- var unshift = uncurryThis([].unshift);
- var INVALID_AUTHORITY = 'Invalid authority';
- var INVALID_SCHEME = 'Invalid scheme';
- var INVALID_HOST = 'Invalid host';
- var INVALID_PORT = 'Invalid port';
- var ALPHA = /[a-z]/i;
- // eslint-disable-next-line regexp/no-obscure-range -- safe
- var ALPHANUMERIC = /[\d+-.a-z]/i;
- var DIGIT = /\d/;
- var HEX_START = /^0x/i;
- var OCT = /^[0-7]+$/;
- var DEC = /^\d+$/;
- var HEX = /^[\da-f]+$/i;
- /* eslint-disable regexp/no-control-character -- safe */
- var FORBIDDEN_HOST_CODE_POINT = /[\0\t\n\r #%/:<>?@[\\\]^|]/;
- var FORBIDDEN_HOST_CODE_POINT_EXCLUDING_PERCENT = /[\0\t\n\r #/:<>?@[\\\]^|]/;
- var LEADING_AND_TRAILING_C0_CONTROL_OR_SPACE = /^[\u0000-\u0020]+|[\u0000-\u0020]+$/g;
- var TAB_AND_NEW_LINE = /[\t\n\r]/g;
- /* eslint-enable regexp/no-control-character -- safe */
- var EOF;
- // https://url.spec.whatwg.org/#ipv4-number-parser
- var parseIPv4 = function (input) {
- var parts = split(input, '.');
- var partsLength, numbers, index, part, radix, number, ipv4;
- if (parts.length && parts[parts.length - 1] == '') {
- parts.length--;
- }
- partsLength = parts.length;
- if (partsLength > 4) return input;
- numbers = [];
- for (index = 0; index < partsLength; index++) {
- part = parts[index];
- if (part == '') return input;
- radix = 10;
- if (part.length > 1 && charAt(part, 0) == '0') {
- radix = exec(HEX_START, part) ? 16 : 8;
- part = stringSlice(part, radix == 8 ? 1 : 2);
- }
- if (part === '') {
- number = 0;
- } else {
- if (!exec(radix == 10 ? DEC : radix == 8 ? OCT : HEX, part)) return input;
- number = parseInt(part, radix);
- }
- push(numbers, number);
- }
- for (index = 0; index < partsLength; index++) {
- number = numbers[index];
- if (index == partsLength - 1) {
- if (number >= pow(256, 5 - partsLength)) return null;
- } else if (number > 255) return null;
- }
- ipv4 = pop(numbers);
- for (index = 0; index < numbers.length; index++) {
- ipv4 += numbers[index] * pow(256, 3 - index);
- }
- return ipv4;
- };
- // https://url.spec.whatwg.org/#concept-ipv6-parser
- // eslint-disable-next-line max-statements -- TODO
- var parseIPv6 = function (input) {
- var address = [0, 0, 0, 0, 0, 0, 0, 0];
- var pieceIndex = 0;
- var compress = null;
- var pointer = 0;
- var value, length, numbersSeen, ipv4Piece, number, swaps, swap;
- var chr = function () {
- return charAt(input, pointer);
- };
- if (chr() == ':') {
- if (charAt(input, 1) != ':') return;
- pointer += 2;
- pieceIndex++;
- compress = pieceIndex;
- }
- while (chr()) {
- if (pieceIndex == 8) return;
- if (chr() == ':') {
- if (compress !== null) return;
- pointer++;
- pieceIndex++;
- compress = pieceIndex;
- continue;
- }
- value = length = 0;
- while (length < 4 && exec(HEX, chr())) {
- value = value * 16 + parseInt(chr(), 16);
- pointer++;
- length++;
- }
- if (chr() == '.') {
- if (length == 0) return;
- pointer -= length;
- if (pieceIndex > 6) return;
- numbersSeen = 0;
- while (chr()) {
- ipv4Piece = null;
- if (numbersSeen > 0) {
- if (chr() == '.' && numbersSeen < 4) pointer++;
- else return;
- }
- if (!exec(DIGIT, chr())) return;
- while (exec(DIGIT, chr())) {
- number = parseInt(chr(), 10);
- if (ipv4Piece === null) ipv4Piece = number;
- else if (ipv4Piece == 0) return;
- else ipv4Piece = ipv4Piece * 10 + number;
- if (ipv4Piece > 255) return;
- pointer++;
- }
- address[pieceIndex] = address[pieceIndex] * 256 + ipv4Piece;
- numbersSeen++;
- if (numbersSeen == 2 || numbersSeen == 4) pieceIndex++;
- }
- if (numbersSeen != 4) return;
- break;
- } else if (chr() == ':') {
- pointer++;
- if (!chr()) return;
- } else if (chr()) return;
- address[pieceIndex++] = value;
- }
- if (compress !== null) {
- swaps = pieceIndex - compress;
- pieceIndex = 7;
- while (pieceIndex != 0 && swaps > 0) {
- swap = address[pieceIndex];
- address[pieceIndex--] = address[compress + swaps - 1];
- address[compress + --swaps] = swap;
- }
- } else if (pieceIndex != 8) return;
- return address;
- };
- var findLongestZeroSequence = function (ipv6) {
- var maxIndex = null;
- var maxLength = 1;
- var currStart = null;
- var currLength = 0;
- var index = 0;
- for (; index < 8; index++) {
- if (ipv6[index] !== 0) {
- if (currLength > maxLength) {
- maxIndex = currStart;
- maxLength = currLength;
- }
- currStart = null;
- currLength = 0;
- } else {
- if (currStart === null) currStart = index;
- ++currLength;
- }
- }
- if (currLength > maxLength) {
- maxIndex = currStart;
- maxLength = currLength;
- }
- return maxIndex;
- };
- // https://url.spec.whatwg.org/#host-serializing
- var serializeHost = function (host) {
- var result, index, compress, ignore0;
- // ipv4
- if (typeof host == 'number') {
- result = [];
- for (index = 0; index < 4; index++) {
- unshift(result, host % 256);
- host = floor(host / 256);
- } return join(result, '.');
- // ipv6
- } else if (typeof host == 'object') {
- result = '';
- compress = findLongestZeroSequence(host);
- for (index = 0; index < 8; index++) {
- if (ignore0 && host[index] === 0) continue;
- if (ignore0) ignore0 = false;
- if (compress === index) {
- result += index ? ':' : '::';
- ignore0 = true;
- } else {
- result += numberToString(host[index], 16);
- if (index < 7) result += ':';
- }
- }
- return '[' + result + ']';
- } return host;
- };
- var C0ControlPercentEncodeSet = {};
- var fragmentPercentEncodeSet = assign({}, C0ControlPercentEncodeSet, {
- ' ': 1, '"': 1, '<': 1, '>': 1, '`': 1
- });
- var pathPercentEncodeSet = assign({}, fragmentPercentEncodeSet, {
- '#': 1, '?': 1, '{': 1, '}': 1
- });
- var userinfoPercentEncodeSet = assign({}, pathPercentEncodeSet, {
- '/': 1, ':': 1, ';': 1, '=': 1, '@': 1, '[': 1, '\\': 1, ']': 1, '^': 1, '|': 1
- });
- var percentEncode = function (chr, set) {
- var code = codeAt(chr, 0);
- return code > 0x20 && code < 0x7F && !hasOwn(set, chr) ? chr : encodeURIComponent(chr);
- };
- // https://url.spec.whatwg.org/#special-scheme
- var specialSchemes = {
- ftp: 21,
- file: null,
- http: 80,
- https: 443,
- ws: 80,
- wss: 443
- };
- // https://url.spec.whatwg.org/#windows-drive-letter
- var isWindowsDriveLetter = function (string, normalized) {
- var second;
- return string.length == 2 && exec(ALPHA, charAt(string, 0))
- && ((second = charAt(string, 1)) == ':' || (!normalized && second == '|'));
- };
- // https://url.spec.whatwg.org/#start-with-a-windows-drive-letter
- var startsWithWindowsDriveLetter = function (string) {
- var third;
- return string.length > 1 && isWindowsDriveLetter(stringSlice(string, 0, 2)) && (
- string.length == 2 ||
- ((third = charAt(string, 2)) === '/' || third === '\\' || third === '?' || third === '#')
- );
- };
- // https://url.spec.whatwg.org/#single-dot-path-segment
- var isSingleDot = function (segment) {
- return segment === '.' || toLowerCase(segment) === '%2e';
- };
- // https://url.spec.whatwg.org/#double-dot-path-segment
- var isDoubleDot = function (segment) {
- segment = toLowerCase(segment);
- return segment === '..' || segment === '%2e.' || segment === '.%2e' || segment === '%2e%2e';
- };
- // States:
- var SCHEME_START = {};
- var SCHEME = {};
- var NO_SCHEME = {};
- var SPECIAL_RELATIVE_OR_AUTHORITY = {};
- var PATH_OR_AUTHORITY = {};
- var RELATIVE = {};
- var RELATIVE_SLASH = {};
- var SPECIAL_AUTHORITY_SLASHES = {};
- var SPECIAL_AUTHORITY_IGNORE_SLASHES = {};
- var AUTHORITY = {};
- var HOST = {};
- var HOSTNAME = {};
- var PORT = {};
- var FILE = {};
- var FILE_SLASH = {};
- var FILE_HOST = {};
- var PATH_START = {};
- var PATH = {};
- var CANNOT_BE_A_BASE_URL_PATH = {};
- var QUERY = {};
- var FRAGMENT = {};
- var URLState = function (url, isBase, base) {
- var urlString = $toString(url);
- var baseState, failure, searchParams;
- if (isBase) {
- failure = this.parse(urlString);
- if (failure) throw TypeError(failure);
- this.searchParams = null;
- } else {
- if (base !== undefined) baseState = new URLState(base, true);
- failure = this.parse(urlString, null, baseState);
- if (failure) throw TypeError(failure);
- searchParams = getInternalSearchParamsState(new URLSearchParams());
- searchParams.bindURL(this);
- this.searchParams = searchParams;
- }
- };
- URLState.prototype = {
- type: 'URL',
- // https://url.spec.whatwg.org/#url-parsing
- // eslint-disable-next-line max-statements -- TODO
- parse: function (input, stateOverride, base) {
- var url = this;
- var state = stateOverride || SCHEME_START;
- var pointer = 0;
- var buffer = '';
- var seenAt = false;
- var seenBracket = false;
- var seenPasswordToken = false;
- var codePoints, chr, bufferCodePoints, failure;
- input = $toString(input);
- if (!stateOverride) {
- url.scheme = '';
- url.username = '';
- url.password = '';
- url.host = null;
- url.port = null;
- url.path = [];
- url.query = null;
- url.fragment = null;
- url.cannotBeABaseURL = false;
- input = replace(input, LEADING_AND_TRAILING_C0_CONTROL_OR_SPACE, '');
- }
- input = replace(input, TAB_AND_NEW_LINE, '');
- codePoints = arrayFrom(input);
- while (pointer <= codePoints.length) {
- chr = codePoints[pointer];
- switch (state) {
- case SCHEME_START:
- if (chr && exec(ALPHA, chr)) {
- buffer += toLowerCase(chr);
- state = SCHEME;
- } else if (!stateOverride) {
- state = NO_SCHEME;
- continue;
- } else return INVALID_SCHEME;
- break;
- case SCHEME:
- if (chr && (exec(ALPHANUMERIC, chr) || chr == '+' || chr == '-' || chr == '.')) {
- buffer += toLowerCase(chr);
- } else if (chr == ':') {
- if (stateOverride && (
- (url.isSpecial() != hasOwn(specialSchemes, buffer)) ||
- (buffer == 'file' && (url.includesCredentials() || url.port !== null)) ||
- (url.scheme == 'file' && !url.host)
- )) return;
- url.scheme = buffer;
- if (stateOverride) {
- if (url.isSpecial() && specialSchemes[url.scheme] == url.port) url.port = null;
- return;
- }
- buffer = '';
- if (url.scheme == 'file') {
- state = FILE;
- } else if (url.isSpecial() && base && base.scheme == url.scheme) {
- state = SPECIAL_RELATIVE_OR_AUTHORITY;
- } else if (url.isSpecial()) {
- state = SPECIAL_AUTHORITY_SLASHES;
- } else if (codePoints[pointer + 1] == '/') {
- state = PATH_OR_AUTHORITY;
- pointer++;
- } else {
- url.cannotBeABaseURL = true;
- push(url.path, '');
- state = CANNOT_BE_A_BASE_URL_PATH;
- }
- } else if (!stateOverride) {
- buffer = '';
- state = NO_SCHEME;
- pointer = 0;
- continue;
- } else return INVALID_SCHEME;
- break;
- case NO_SCHEME:
- if (!base || (base.cannotBeABaseURL && chr != '#')) return INVALID_SCHEME;
- if (base.cannotBeABaseURL && chr == '#') {
- url.scheme = base.scheme;
- url.path = arraySlice(base.path);
- url.query = base.query;
- url.fragment = '';
- url.cannotBeABaseURL = true;
- state = FRAGMENT;
- break;
- }
- state = base.scheme == 'file' ? FILE : RELATIVE;
- continue;
- case SPECIAL_RELATIVE_OR_AUTHORITY:
- if (chr == '/' && codePoints[pointer + 1] == '/') {
- state = SPECIAL_AUTHORITY_IGNORE_SLASHES;
- pointer++;
- } else {
- state = RELATIVE;
- continue;
- } break;
- case PATH_OR_AUTHORITY:
- if (chr == '/') {
- state = AUTHORITY;
- break;
- } else {
- state = PATH;
- continue;
- }
- case RELATIVE:
- url.scheme = base.scheme;
- if (chr == EOF) {
- url.username = base.username;
- url.password = base.password;
- url.host = base.host;
- url.port = base.port;
- url.path = arraySlice(base.path);
- url.query = base.query;
- } else if (chr == '/' || (chr == '\\' && url.isSpecial())) {
- state = RELATIVE_SLASH;
- } else if (chr == '?') {
- url.username = base.username;
- url.password = base.password;
- url.host = base.host;
- url.port = base.port;
- url.path = arraySlice(base.path);
- url.query = '';
- state = QUERY;
- } else if (chr == '#') {
- url.username = base.username;
- url.password = base.password;
- url.host = base.host;
- url.port = base.port;
- url.path = arraySlice(base.path);
- url.query = base.query;
- url.fragment = '';
- state = FRAGMENT;
- } else {
- url.username = base.username;
- url.password = base.password;
- url.host = base.host;
- url.port = base.port;
- url.path = arraySlice(base.path);
- url.path.length--;
- state = PATH;
- continue;
- } break;
- case RELATIVE_SLASH:
- if (url.isSpecial() && (chr == '/' || chr == '\\')) {
- state = SPECIAL_AUTHORITY_IGNORE_SLASHES;
- } else if (chr == '/') {
- state = AUTHORITY;
- } else {
- url.username = base.username;
- url.password = base.password;
- url.host = base.host;
- url.port = base.port;
- state = PATH;
- continue;
- } break;
- case SPECIAL_AUTHORITY_SLASHES:
- state = SPECIAL_AUTHORITY_IGNORE_SLASHES;
- if (chr != '/' || charAt(buffer, pointer + 1) != '/') continue;
- pointer++;
- break;
- case SPECIAL_AUTHORITY_IGNORE_SLASHES:
- if (chr != '/' && chr != '\\') {
- state = AUTHORITY;
- continue;
- } break;
- case AUTHORITY:
- if (chr == '@') {
- if (seenAt) buffer = '%40' + buffer;
- seenAt = true;
- bufferCodePoints = arrayFrom(buffer);
- for (var i = 0; i < bufferCodePoints.length; i++) {
- var codePoint = bufferCodePoints[i];
- if (codePoint == ':' && !seenPasswordToken) {
- seenPasswordToken = true;
- continue;
- }
- var encodedCodePoints = percentEncode(codePoint, userinfoPercentEncodeSet);
- if (seenPasswordToken) url.password += encodedCodePoints;
- else url.username += encodedCodePoints;
- }
- buffer = '';
- } else if (
- chr == EOF || chr == '/' || chr == '?' || chr == '#' ||
- (chr == '\\' && url.isSpecial())
- ) {
- if (seenAt && buffer == '') return INVALID_AUTHORITY;
- pointer -= arrayFrom(buffer).length + 1;
- buffer = '';
- state = HOST;
- } else buffer += chr;
- break;
- case HOST:
- case HOSTNAME:
- if (stateOverride && url.scheme == 'file') {
- state = FILE_HOST;
- continue;
- } else if (chr == ':' && !seenBracket) {
- if (buffer == '') return INVALID_HOST;
- failure = url.parseHost(buffer);
- if (failure) return failure;
- buffer = '';
- state = PORT;
- if (stateOverride == HOSTNAME) return;
- } else if (
- chr == EOF || chr == '/' || chr == '?' || chr == '#' ||
- (chr == '\\' && url.isSpecial())
- ) {
- if (url.isSpecial() && buffer == '') return INVALID_HOST;
- if (stateOverride && buffer == '' && (url.includesCredentials() || url.port !== null)) return;
- failure = url.parseHost(buffer);
- if (failure) return failure;
- buffer = '';
- state = PATH_START;
- if (stateOverride) return;
- continue;
- } else {
- if (chr == '[') seenBracket = true;
- else if (chr == ']') seenBracket = false;
- buffer += chr;
- } break;
- case PORT:
- if (exec(DIGIT, chr)) {
- buffer += chr;
- } else if (
- chr == EOF || chr == '/' || chr == '?' || chr == '#' ||
- (chr == '\\' && url.isSpecial()) ||
- stateOverride
- ) {
- if (buffer != '') {
- var port = parseInt(buffer, 10);
- if (port > 0xFFFF) return INVALID_PORT;
- url.port = (url.isSpecial() && port === specialSchemes[url.scheme]) ? null : port;
- buffer = '';
- }
- if (stateOverride) return;
- state = PATH_START;
- continue;
- } else return INVALID_PORT;
- break;
- case FILE:
- url.scheme = 'file';
- if (chr == '/' || chr == '\\') state = FILE_SLASH;
- else if (base && base.scheme == 'file') {
- if (chr == EOF) {
- url.host = base.host;
- url.path = arraySlice(base.path);
- url.query = base.query;
- } else if (chr == '?') {
- url.host = base.host;
- url.path = arraySlice(base.path);
- url.query = '';
- state = QUERY;
- } else if (chr == '#') {
- url.host = base.host;
- url.path = arraySlice(base.path);
- url.query = base.query;
- url.fragment = '';
- state = FRAGMENT;
- } else {
- if (!startsWithWindowsDriveLetter(join(arraySlice(codePoints, pointer), ''))) {
- url.host = base.host;
- url.path = arraySlice(base.path);
- url.shortenPath();
- }
- state = PATH;
- continue;
- }
- } else {
- state = PATH;
- continue;
- } break;
- case FILE_SLASH:
- if (chr == '/' || chr == '\\') {
- state = FILE_HOST;
- break;
- }
- if (base && base.scheme == 'file' && !startsWithWindowsDriveLetter(join(arraySlice(codePoints, pointer), ''))) {
- if (isWindowsDriveLetter(base.path[0], true)) push(url.path, base.path[0]);
- else url.host = base.host;
- }
- state = PATH;
- continue;
- case FILE_HOST:
- if (chr == EOF || chr == '/' || chr == '\\' || chr == '?' || chr == '#') {
- if (!stateOverride && isWindowsDriveLetter(buffer)) {
- state = PATH;
- } else if (buffer == '') {
- url.host = '';
- if (stateOverride) return;
- state = PATH_START;
- } else {
- failure = url.parseHost(buffer);
- if (failure) return failure;
- if (url.host == 'localhost') url.host = '';
- if (stateOverride) return;
- buffer = '';
- state = PATH_START;
- } continue;
- } else buffer += chr;
- break;
- case PATH_START:
- if (url.isSpecial()) {
- state = PATH;
- if (chr != '/' && chr != '\\') continue;
- } else if (!stateOverride && chr == '?') {
- url.query = '';
- state = QUERY;
- } else if (!stateOverride && chr == '#') {
- url.fragment = '';
- state = FRAGMENT;
- } else if (chr != EOF) {
- state = PATH;
- if (chr != '/') continue;
- } break;
- case PATH:
- if (
- chr == EOF || chr == '/' ||
- (chr == '\\' && url.isSpecial()) ||
- (!stateOverride && (chr == '?' || chr == '#'))
- ) {
- if (isDoubleDot(buffer)) {
- url.shortenPath();
- if (chr != '/' && !(chr == '\\' && url.isSpecial())) {
- push(url.path, '');
- }
- } else if (isSingleDot(buffer)) {
- if (chr != '/' && !(chr == '\\' && url.isSpecial())) {
- push(url.path, '');
- }
- } else {
- if (url.scheme == 'file' && !url.path.length && isWindowsDriveLetter(buffer)) {
- if (url.host) url.host = '';
- buffer = charAt(buffer, 0) + ':'; // normalize windows drive letter
- }
- push(url.path, buffer);
- }
- buffer = '';
- if (url.scheme == 'file' && (chr == EOF || chr == '?' || chr == '#')) {
- while (url.path.length > 1 && url.path[0] === '') {
- shift(url.path);
- }
- }
- if (chr == '?') {
- url.query = '';
- state = QUERY;
- } else if (chr == '#') {
- url.fragment = '';
- state = FRAGMENT;
- }
- } else {
- buffer += percentEncode(chr, pathPercentEncodeSet);
- } break;
- case CANNOT_BE_A_BASE_URL_PATH:
- if (chr == '?') {
- url.query = '';
- state = QUERY;
- } else if (chr == '#') {
- url.fragment = '';
- state = FRAGMENT;
- } else if (chr != EOF) {
- url.path[0] += percentEncode(chr, C0ControlPercentEncodeSet);
- } break;
- case QUERY:
- if (!stateOverride && chr == '#') {
- url.fragment = '';
- state = FRAGMENT;
- } else if (chr != EOF) {
- if (chr == "'" && url.isSpecial()) url.query += '%27';
- else if (chr == '#') url.query += '%23';
- else url.query += percentEncode(chr, C0ControlPercentEncodeSet);
- } break;
- case FRAGMENT:
- if (chr != EOF) url.fragment += percentEncode(chr, fragmentPercentEncodeSet);
- break;
- }
- pointer++;
- }
- },
- // https://url.spec.whatwg.org/#host-parsing
- parseHost: function (input) {
- var result, codePoints, index;
- if (charAt(input, 0) == '[') {
- if (charAt(input, input.length - 1) != ']') return INVALID_HOST;
- result = parseIPv6(stringSlice(input, 1, -1));
- if (!result) return INVALID_HOST;
- this.host = result;
- // opaque host
- } else if (!this.isSpecial()) {
- if (exec(FORBIDDEN_HOST_CODE_POINT_EXCLUDING_PERCENT, input)) return INVALID_HOST;
- result = '';
- codePoints = arrayFrom(input);
- for (index = 0; index < codePoints.length; index++) {
- result += percentEncode(codePoints[index], C0ControlPercentEncodeSet);
- }
- this.host = result;
- } else {
- input = toASCII(input);
- if (exec(FORBIDDEN_HOST_CODE_POINT, input)) return INVALID_HOST;
- result = parseIPv4(input);
- if (result === null) return INVALID_HOST;
- this.host = result;
- }
- },
- // https://url.spec.whatwg.org/#cannot-have-a-username-password-port
- cannotHaveUsernamePasswordPort: function () {
- return !this.host || this.cannotBeABaseURL || this.scheme == 'file';
- },
- // https://url.spec.whatwg.org/#include-credentials
- includesCredentials: function () {
- return this.username != '' || this.password != '';
- },
- // https://url.spec.whatwg.org/#is-special
- isSpecial: function () {
- return hasOwn(specialSchemes, this.scheme);
- },
- // https://url.spec.whatwg.org/#shorten-a-urls-path
- shortenPath: function () {
- var path = this.path;
- var pathSize = path.length;
- if (pathSize && (this.scheme != 'file' || pathSize != 1 || !isWindowsDriveLetter(path[0], true))) {
- path.length--;
- }
- },
- // https://url.spec.whatwg.org/#concept-url-serializer
- serialize: function () {
- var url = this;
- var scheme = url.scheme;
- var username = url.username;
- var password = url.password;
- var host = url.host;
- var port = url.port;
- var path = url.path;
- var query = url.query;
- var fragment = url.fragment;
- var output = scheme + ':';
- if (host !== null) {
- output += '//';
- if (url.includesCredentials()) {
- output += username + (password ? ':' + password : '') + '@';
- }
- output += serializeHost(host);
- if (port !== null) output += ':' + port;
- } else if (scheme == 'file') output += '//';
- output += url.cannotBeABaseURL ? path[0] : path.length ? '/' + join(path, '/') : '';
- if (query !== null) output += '?' + query;
- if (fragment !== null) output += '#' + fragment;
- return output;
- },
- // https://url.spec.whatwg.org/#dom-url-href
- setHref: function (href) {
- var failure = this.parse(href);
- if (failure) throw TypeError(failure);
- this.searchParams.update();
- },
- // https://url.spec.whatwg.org/#dom-url-origin
- getOrigin: function () {
- var scheme = this.scheme;
- var port = this.port;
- if (scheme == 'blob') try {
- return new URLConstructor(scheme.path[0]).origin;
- } catch (error) {
- return 'null';
- }
- if (scheme == 'file' || !this.isSpecial()) return 'null';
- return scheme + '://' + serializeHost(this.host) + (port !== null ? ':' + port : '');
- },
- // https://url.spec.whatwg.org/#dom-url-protocol
- getProtocol: function () {
- return this.scheme + ':';
- },
- setProtocol: function (protocol) {
- this.parse($toString(protocol) + ':', SCHEME_START);
- },
- // https://url.spec.whatwg.org/#dom-url-username
- getUsername: function () {
- return this.username;
- },
- setUsername: function (username) {
- var codePoints = arrayFrom($toString(username));
- if (this.cannotHaveUsernamePasswordPort()) return;
- this.username = '';
- for (var i = 0; i < codePoints.length; i++) {
- this.username += percentEncode(codePoints[i], userinfoPercentEncodeSet);
- }
- },
- // https://url.spec.whatwg.org/#dom-url-password
- getPassword: function () {
- return this.password;
- },
- setPassword: function (password) {
- var codePoints = arrayFrom($toString(password));
- if (this.cannotHaveUsernamePasswordPort()) return;
- this.password = '';
- for (var i = 0; i < codePoints.length; i++) {
- this.password += percentEncode(codePoints[i], userinfoPercentEncodeSet);
- }
- },
- // https://url.spec.whatwg.org/#dom-url-host
- getHost: function () {
- var host = this.host;
- var port = this.port;
- return host === null ? ''
- : port === null ? serializeHost(host)
- : serializeHost(host) + ':' + port;
- },
- setHost: function (host) {
- if (this.cannotBeABaseURL) return;
- this.parse(host, HOST);
- },
- // https://url.spec.whatwg.org/#dom-url-hostname
- getHostname: function () {
- var host = this.host;
- return host === null ? '' : serializeHost(host);
- },
- setHostname: function (hostname) {
- if (this.cannotBeABaseURL) return;
- this.parse(hostname, HOSTNAME);
- },
- // https://url.spec.whatwg.org/#dom-url-port
- getPort: function () {
- var port = this.port;
- return port === null ? '' : $toString(port);
- },
- setPort: function (port) {
- if (this.cannotHaveUsernamePasswordPort()) return;
- port = $toString(port);
- if (port == '') this.port = null;
- else this.parse(port, PORT);
- },
- // https://url.spec.whatwg.org/#dom-url-pathname
- getPathname: function () {
- var path = this.path;
- return this.cannotBeABaseURL ? path[0] : path.length ? '/' + join(path, '/') : '';
- },
- setPathname: function (pathname) {
- if (this.cannotBeABaseURL) return;
- this.path = [];
- this.parse(pathname, PATH_START);
- },
- // https://url.spec.whatwg.org/#dom-url-search
- getSearch: function () {
- var query = this.query;
- return query ? '?' + query : '';
- },
- setSearch: function (search) {
- search = $toString(search);
- if (search == '') {
- this.query = null;
- } else {
- if ('?' == charAt(search, 0)) search = stringSlice(search, 1);
- this.query = '';
- this.parse(search, QUERY);
- }
- this.searchParams.update();
- },
- // https://url.spec.whatwg.org/#dom-url-searchparams
- getSearchParams: function () {
- return this.searchParams.facade;
- },
- // https://url.spec.whatwg.org/#dom-url-hash
- getHash: function () {
- var fragment = this.fragment;
- return fragment ? '#' + fragment : '';
- },
- setHash: function (hash) {
- hash = $toString(hash);
- if (hash == '') {
- this.fragment = null;
- return;
- }
- if ('#' == charAt(hash, 0)) hash = stringSlice(hash, 1);
- this.fragment = '';
- this.parse(hash, FRAGMENT);
- },
- update: function () {
- this.query = this.searchParams.serialize() || null;
- }
- };
- // `URL` constructor
- // https://url.spec.whatwg.org/#url-class
- var URLConstructor = function URL(url /* , base */) {
- var that = anInstance(this, URLPrototype);
- var base = arguments.length > 1 ? arguments[1] : undefined;
- var state = setInternalState(that, new URLState(url, false, base));
- if (!DESCRIPTORS) {
- that.href = state.serialize();
- that.origin = state.getOrigin();
- that.protocol = state.getProtocol();
- that.username = state.getUsername();
- that.password = state.getPassword();
- that.host = state.getHost();
- that.hostname = state.getHostname();
- that.port = state.getPort();
- that.pathname = state.getPathname();
- that.search = state.getSearch();
- that.searchParams = state.getSearchParams();
- that.hash = state.getHash();
- }
- };
- var URLPrototype = URLConstructor.prototype;
- var accessorDescriptor = function (getter, setter) {
- return {
- get: function () {
- return getInternalURLState(this)[getter]();
- },
- set: setter && function (value) {
- return getInternalURLState(this)[setter](value);
- },
- configurable: true,
- enumerable: true
- };
- };
- if (DESCRIPTORS) {
- defineProperties(URLPrototype, {
- // `URL.prototype.href` accessors pair
- // https://url.spec.whatwg.org/#dom-url-href
- href: accessorDescriptor('serialize', 'setHref'),
- // `URL.prototype.origin` getter
- // https://url.spec.whatwg.org/#dom-url-origin
- origin: accessorDescriptor('getOrigin'),
- // `URL.prototype.protocol` accessors pair
- // https://url.spec.whatwg.org/#dom-url-protocol
- protocol: accessorDescriptor('getProtocol', 'setProtocol'),
- // `URL.prototype.username` accessors pair
- // https://url.spec.whatwg.org/#dom-url-username
- username: accessorDescriptor('getUsername', 'setUsername'),
- // `URL.prototype.password` accessors pair
- // https://url.spec.whatwg.org/#dom-url-password
- password: accessorDescriptor('getPassword', 'setPassword'),
- // `URL.prototype.host` accessors pair
- // https://url.spec.whatwg.org/#dom-url-host
- host: accessorDescriptor('getHost', 'setHost'),
- // `URL.prototype.hostname` accessors pair
- // https://url.spec.whatwg.org/#dom-url-hostname
- hostname: accessorDescriptor('getHostname', 'setHostname'),
- // `URL.prototype.port` accessors pair
- // https://url.spec.whatwg.org/#dom-url-port
- port: accessorDescriptor('getPort', 'setPort'),
- // `URL.prototype.pathname` accessors pair
- // https://url.spec.whatwg.org/#dom-url-pathname
- pathname: accessorDescriptor('getPathname', 'setPathname'),
- // `URL.prototype.search` accessors pair
- // https://url.spec.whatwg.org/#dom-url-search
- search: accessorDescriptor('getSearch', 'setSearch'),
- // `URL.prototype.searchParams` getter
- // https://url.spec.whatwg.org/#dom-url-searchparams
- searchParams: accessorDescriptor('getSearchParams'),
- // `URL.prototype.hash` accessors pair
- // https://url.spec.whatwg.org/#dom-url-hash
- hash: accessorDescriptor('getHash', 'setHash')
- });
- }
- // `URL.prototype.toJSON` method
- // https://url.spec.whatwg.org/#dom-url-tojson
- redefine(URLPrototype, 'toJSON', function toJSON() {
- return getInternalURLState(this).serialize();
- }, { enumerable: true });
- // `URL.prototype.toString` method
- // https://url.spec.whatwg.org/#URL-stringification-behavior
- redefine(URLPrototype, 'toString', function toString() {
- return getInternalURLState(this).serialize();
- }, { enumerable: true });
- if (NativeURL) {
- var nativeCreateObjectURL = NativeURL.createObjectURL;
- var nativeRevokeObjectURL = NativeURL.revokeObjectURL;
- // `URL.createObjectURL` method
- // https://developer.mozilla.org/en-US/docs/Web/API/URL/createObjectURL
- if (nativeCreateObjectURL) redefine(URLConstructor, 'createObjectURL', bind(nativeCreateObjectURL, NativeURL));
- // `URL.revokeObjectURL` method
- // https://developer.mozilla.org/en-US/docs/Web/API/URL/revokeObjectURL
- if (nativeRevokeObjectURL) redefine(URLConstructor, 'revokeObjectURL', bind(nativeRevokeObjectURL, NativeURL));
- }
- setToStringTag(URLConstructor, 'URL');
- $({ global: true, forced: !USE_NATIVE_URL, sham: !DESCRIPTORS }, {
- URL: URLConstructor
- });
- },{"../internals/an-instance":425,"../internals/array-from":429,"../internals/array-slice-simple":435,"../internals/descriptors":460,"../internals/export":476,"../internals/function-bind-context":480,"../internals/function-uncurry-this":485,"../internals/global":491,"../internals/has-own-property":492,"../internals/internal-state":501,"../internals/native-url":523,"../internals/object-assign":529,"../internals/object-define-properties":531,"../internals/redefine":553,"../internals/set-to-string-tag":558,"../internals/string-multibyte":563,"../internals/string-punycode-to-ascii":566,"../internals/to-string":579,"../modules/es.string.iterator":634,"../modules/web.url-search-params":688}],690:[function(_dereq_,module,exports){
- arguments[4][608][0].apply(exports,arguments)
- },{"dup":608}],691:[function(_dereq_,module,exports){
- var parent = _dereq_('../../es/array/from');
- module.exports = parent;
- },{"../../es/array/from":341}],692:[function(_dereq_,module,exports){
- var parent = _dereq_('../../es/array/is-array');
- module.exports = parent;
- },{"../../es/array/is-array":342}],693:[function(_dereq_,module,exports){
- var parent = _dereq_('../../../es/array/virtual/entries');
- module.exports = parent;
- },{"../../../es/array/virtual/entries":344}],694:[function(_dereq_,module,exports){
- var parent = _dereq_('../../../es/array/virtual/for-each');
- module.exports = parent;
- },{"../../../es/array/virtual/for-each":348}],695:[function(_dereq_,module,exports){
- var parent = _dereq_('../../../es/array/virtual/keys');
- module.exports = parent;
- },{"../../../es/array/virtual/keys":351}],696:[function(_dereq_,module,exports){
- var parent = _dereq_('../../../es/array/virtual/values');
- module.exports = parent;
- },{"../../../es/array/virtual/values":357}],697:[function(_dereq_,module,exports){
- var parent = _dereq_('../es/get-iterator-method');
- _dereq_('../modules/web.dom-collections.iterator');
- module.exports = parent;
- },{"../es/get-iterator-method":359,"../modules/web.dom-collections.iterator":686}],698:[function(_dereq_,module,exports){
- var parent = _dereq_('../../es/instance/bind');
- module.exports = parent;
- },{"../../es/instance/bind":360}],699:[function(_dereq_,module,exports){
- var parent = _dereq_('../../es/instance/concat');
- module.exports = parent;
- },{"../../es/instance/concat":361}],700:[function(_dereq_,module,exports){
- _dereq_('../../modules/web.dom-collections.iterator');
- var classof = _dereq_('../../internals/classof');
- var hasOwn = _dereq_('../../internals/has-own-property');
- var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
- var method = _dereq_('../array/virtual/entries');
- var ArrayPrototype = Array.prototype;
- var DOMIterables = {
- DOMTokenList: true,
- NodeList: true
- };
- module.exports = function (it) {
- var own = it.entries;
- return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.entries)
- || hasOwn(DOMIterables, classof(it)) ? method : own;
- };
- },{"../../internals/classof":443,"../../internals/has-own-property":492,"../../internals/object-is-prototype-of":539,"../../modules/web.dom-collections.iterator":686,"../array/virtual/entries":693}],701:[function(_dereq_,module,exports){
- var parent = _dereq_('../../es/instance/every');
- module.exports = parent;
- },{"../../es/instance/every":362}],702:[function(_dereq_,module,exports){
- var parent = _dereq_('../../es/instance/filter');
- module.exports = parent;
- },{"../../es/instance/filter":363}],703:[function(_dereq_,module,exports){
- var parent = _dereq_('../../es/instance/find');
- module.exports = parent;
- },{"../../es/instance/find":364}],704:[function(_dereq_,module,exports){
- _dereq_('../../modules/web.dom-collections.iterator');
- var classof = _dereq_('../../internals/classof');
- var hasOwn = _dereq_('../../internals/has-own-property');
- var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
- var method = _dereq_('../array/virtual/for-each');
- var ArrayPrototype = Array.prototype;
- var DOMIterables = {
- DOMTokenList: true,
- NodeList: true
- };
- module.exports = function (it) {
- var own = it.forEach;
- return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.forEach)
- || hasOwn(DOMIterables, classof(it)) ? method : own;
- };
- },{"../../internals/classof":443,"../../internals/has-own-property":492,"../../internals/object-is-prototype-of":539,"../../modules/web.dom-collections.iterator":686,"../array/virtual/for-each":694}],705:[function(_dereq_,module,exports){
- var parent = _dereq_('../../es/instance/includes');
- module.exports = parent;
- },{"../../es/instance/includes":365}],706:[function(_dereq_,module,exports){
- var parent = _dereq_('../../es/instance/index-of');
- module.exports = parent;
- },{"../../es/instance/index-of":366}],707:[function(_dereq_,module,exports){
- _dereq_('../../modules/web.dom-collections.iterator');
- var classof = _dereq_('../../internals/classof');
- var hasOwn = _dereq_('../../internals/has-own-property');
- var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
- var method = _dereq_('../array/virtual/keys');
- var ArrayPrototype = Array.prototype;
- var DOMIterables = {
- DOMTokenList: true,
- NodeList: true
- };
- module.exports = function (it) {
- var own = it.keys;
- return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.keys)
- || hasOwn(DOMIterables, classof(it)) ? method : own;
- };
- },{"../../internals/classof":443,"../../internals/has-own-property":492,"../../internals/object-is-prototype-of":539,"../../modules/web.dom-collections.iterator":686,"../array/virtual/keys":695}],708:[function(_dereq_,module,exports){
- var parent = _dereq_('../../es/instance/map');
- module.exports = parent;
- },{"../../es/instance/map":367}],709:[function(_dereq_,module,exports){
- var parent = _dereq_('../../es/instance/pad-start');
- module.exports = parent;
- },{"../../es/instance/pad-start":368}],710:[function(_dereq_,module,exports){
- var parent = _dereq_('../../es/instance/reduce');
- module.exports = parent;
- },{"../../es/instance/reduce":369}],711:[function(_dereq_,module,exports){
- var parent = _dereq_('../../es/instance/slice');
- module.exports = parent;
- },{"../../es/instance/slice":370}],712:[function(_dereq_,module,exports){
- var parent = _dereq_('../../es/instance/sort');
- module.exports = parent;
- },{"../../es/instance/sort":371}],713:[function(_dereq_,module,exports){
- var parent = _dereq_('../../es/instance/splice');
- module.exports = parent;
- },{"../../es/instance/splice":372}],714:[function(_dereq_,module,exports){
- var parent = _dereq_('../../es/instance/starts-with');
- module.exports = parent;
- },{"../../es/instance/starts-with":373}],715:[function(_dereq_,module,exports){
- var parent = _dereq_('../../es/instance/trim');
- module.exports = parent;
- },{"../../es/instance/trim":374}],716:[function(_dereq_,module,exports){
- _dereq_('../../modules/web.dom-collections.iterator');
- var classof = _dereq_('../../internals/classof');
- var hasOwn = _dereq_('../../internals/has-own-property');
- var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
- var method = _dereq_('../array/virtual/values');
- var ArrayPrototype = Array.prototype;
- var DOMIterables = {
- DOMTokenList: true,
- NodeList: true
- };
- module.exports = function (it) {
- var own = it.values;
- return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.values)
- || hasOwn(DOMIterables, classof(it)) ? method : own;
- };
- },{"../../internals/classof":443,"../../internals/has-own-property":492,"../../internals/object-is-prototype-of":539,"../../modules/web.dom-collections.iterator":686,"../array/virtual/values":696}],717:[function(_dereq_,module,exports){
- var parent = _dereq_('../../es/json/stringify');
- module.exports = parent;
- },{"../../es/json/stringify":375}],718:[function(_dereq_,module,exports){
- var parent = _dereq_('../../es/map');
- _dereq_('../../modules/web.dom-collections.iterator');
- module.exports = parent;
- },{"../../es/map":376,"../../modules/web.dom-collections.iterator":686}],719:[function(_dereq_,module,exports){
- var parent = _dereq_('../../es/number/is-integer');
- module.exports = parent;
- },{"../../es/number/is-integer":377}],720:[function(_dereq_,module,exports){
- var parent = _dereq_('../../es/number/is-nan');
- module.exports = parent;
- },{"../../es/number/is-nan":378}],721:[function(_dereq_,module,exports){
- var parent = _dereq_('../../es/object/create');
- module.exports = parent;
- },{"../../es/object/create":379}],722:[function(_dereq_,module,exports){
- var parent = _dereq_('../../es/object/define-properties');
- module.exports = parent;
- },{"../../es/object/define-properties":380}],723:[function(_dereq_,module,exports){
- var parent = _dereq_('../../es/object/define-property');
- module.exports = parent;
- },{"../../es/object/define-property":381}],724:[function(_dereq_,module,exports){
- var parent = _dereq_('../../es/object/entries');
- module.exports = parent;
- },{"../../es/object/entries":382}],725:[function(_dereq_,module,exports){
- var parent = _dereq_('../../es/object/freeze');
- module.exports = parent;
- },{"../../es/object/freeze":383}],726:[function(_dereq_,module,exports){
- var parent = _dereq_('../../es/object/get-own-property-descriptor');
- module.exports = parent;
- },{"../../es/object/get-own-property-descriptor":384}],727:[function(_dereq_,module,exports){
- var parent = _dereq_('../../es/object/get-own-property-descriptors');
- module.exports = parent;
- },{"../../es/object/get-own-property-descriptors":385}],728:[function(_dereq_,module,exports){
- var parent = _dereq_('../../es/object/get-own-property-symbols');
- module.exports = parent;
- },{"../../es/object/get-own-property-symbols":386}],729:[function(_dereq_,module,exports){
- var parent = _dereq_('../../es/object/get-prototype-of');
- module.exports = parent;
- },{"../../es/object/get-prototype-of":387}],730:[function(_dereq_,module,exports){
- var parent = _dereq_('../../es/object/keys');
- module.exports = parent;
- },{"../../es/object/keys":388}],731:[function(_dereq_,module,exports){
- var parent = _dereq_('../../es/object/set-prototype-of');
- module.exports = parent;
- },{"../../es/object/set-prototype-of":389}],732:[function(_dereq_,module,exports){
- var parent = _dereq_('../../es/object/values');
- module.exports = parent;
- },{"../../es/object/values":390}],733:[function(_dereq_,module,exports){
- var parent = _dereq_('../es/parse-int');
- module.exports = parent;
- },{"../es/parse-int":391}],734:[function(_dereq_,module,exports){
- var parent = _dereq_('../../es/promise');
- _dereq_('../../modules/web.dom-collections.iterator');
- module.exports = parent;
- },{"../../es/promise":392,"../../modules/web.dom-collections.iterator":686}],735:[function(_dereq_,module,exports){
- var parent = _dereq_('../../es/reflect/construct');
- module.exports = parent;
- },{"../../es/reflect/construct":393}],736:[function(_dereq_,module,exports){
- var parent = _dereq_('../../es/reflect/get');
- module.exports = parent;
- },{"../../es/reflect/get":394}],737:[function(_dereq_,module,exports){
- _dereq_('../modules/web.timers');
- var path = _dereq_('../internals/path');
- module.exports = path.setTimeout;
- },{"../internals/path":548,"../modules/web.timers":687}],738:[function(_dereq_,module,exports){
- var parent = _dereq_('../../es/set');
- _dereq_('../../modules/web.dom-collections.iterator');
- module.exports = parent;
- },{"../../es/set":395,"../../modules/web.dom-collections.iterator":686}],739:[function(_dereq_,module,exports){
- var parent = _dereq_('../../es/symbol');
- _dereq_('../../modules/web.dom-collections.iterator');
- module.exports = parent;
- },{"../../es/symbol":400,"../../modules/web.dom-collections.iterator":686}],740:[function(_dereq_,module,exports){
- var parent = _dereq_('../../es/symbol/iterator');
- _dereq_('../../modules/web.dom-collections.iterator');
- module.exports = parent;
- },{"../../es/symbol/iterator":401,"../../modules/web.dom-collections.iterator":686}],741:[function(_dereq_,module,exports){
- var parent = _dereq_('../../es/symbol/replace');
- module.exports = parent;
- },{"../../es/symbol/replace":402}],742:[function(_dereq_,module,exports){
- var parent = _dereq_('../../web/url');
- module.exports = parent;
- },{"../../web/url":744}],743:[function(_dereq_,module,exports){
- var parent = _dereq_('../../es/weak-map');
- _dereq_('../../modules/web.dom-collections.iterator');
- module.exports = parent;
- },{"../../es/weak-map":403,"../../modules/web.dom-collections.iterator":686}],744:[function(_dereq_,module,exports){
- _dereq_('../modules/web.url');
- _dereq_('../modules/web.url.to-json');
- _dereq_('../modules/web.url-search-params');
- var path = _dereq_('../internals/path');
- module.exports = path.URL;
- },{"../internals/path":548,"../modules/web.url":689,"../modules/web.url-search-params":688,"../modules/web.url.to-json":690}],745:[function(_dereq_,module,exports){
- ;(function (root, factory, undef) {
- if (typeof exports === "object") {
- // CommonJS
- module.exports = exports = factory(_dereq_("./core"), _dereq_("./enc-base64"), _dereq_("./md5"), _dereq_("./evpkdf"), _dereq_("./cipher-core"));
- }
- else if (typeof define === "function" && define.amd) {
- // AMD
- define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
- }
- else {
- // Global (browser)
- factory(root.CryptoJS);
- }
- }(this, function (CryptoJS) {
- (function () {
- // Shortcuts
- var C = CryptoJS;
- var C_lib = C.lib;
- var BlockCipher = C_lib.BlockCipher;
- var C_algo = C.algo;
- // Lookup tables
- var SBOX = [];
- var INV_SBOX = [];
- var SUB_MIX_0 = [];
- var SUB_MIX_1 = [];
- var SUB_MIX_2 = [];
- var SUB_MIX_3 = [];
- var INV_SUB_MIX_0 = [];
- var INV_SUB_MIX_1 = [];
- var INV_SUB_MIX_2 = [];
- var INV_SUB_MIX_3 = [];
- // Compute lookup tables
- (function () {
- // Compute double table
- var d = [];
- for (var i = 0; i < 256; i++) {
- if (i < 128) {
- d[i] = i << 1;
- } else {
- d[i] = (i << 1) ^ 0x11b;
- }
- }
- // Walk GF(2^8)
- var x = 0;
- var xi = 0;
- for (var i = 0; i < 256; i++) {
- // Compute sbox
- var sx = xi ^ (xi << 1) ^ (xi << 2) ^ (xi << 3) ^ (xi << 4);
- sx = (sx >>> 8) ^ (sx & 0xff) ^ 0x63;
- SBOX[x] = sx;
- INV_SBOX[sx] = x;
- // Compute multiplication
- var x2 = d[x];
- var x4 = d[x2];
- var x8 = d[x4];
- // Compute sub bytes, mix columns tables
- var t = (d[sx] * 0x101) ^ (sx * 0x1010100);
- SUB_MIX_0[x] = (t << 24) | (t >>> 8);
- SUB_MIX_1[x] = (t << 16) | (t >>> 16);
- SUB_MIX_2[x] = (t << 8) | (t >>> 24);
- SUB_MIX_3[x] = t;
- // Compute inv sub bytes, inv mix columns tables
- var t = (x8 * 0x1010101) ^ (x4 * 0x10001) ^ (x2 * 0x101) ^ (x * 0x1010100);
- INV_SUB_MIX_0[sx] = (t << 24) | (t >>> 8);
- INV_SUB_MIX_1[sx] = (t << 16) | (t >>> 16);
- INV_SUB_MIX_2[sx] = (t << 8) | (t >>> 24);
- INV_SUB_MIX_3[sx] = t;
- // Compute next counter
- if (!x) {
- x = xi = 1;
- } else {
- x = x2 ^ d[d[d[x8 ^ x2]]];
- xi ^= d[d[xi]];
- }
- }
- }());
- // Precomputed Rcon lookup
- var RCON = [0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36];
- /**
- * AES block cipher algorithm.
- */
- var AES = C_algo.AES = BlockCipher.extend({
- _doReset: function () {
- var t;
- // Skip reset of nRounds has been set before and key did not change
- if (this._nRounds && this._keyPriorReset === this._key) {
- return;
- }
- // Shortcuts
- var key = this._keyPriorReset = this._key;
- var keyWords = key.words;
- var keySize = key.sigBytes / 4;
- // Compute number of rounds
- var nRounds = this._nRounds = keySize + 6;
- // Compute number of key schedule rows
- var ksRows = (nRounds + 1) * 4;
- // Compute key schedule
- var keySchedule = this._keySchedule = [];
- for (var ksRow = 0; ksRow < ksRows; ksRow++) {
- if (ksRow < keySize) {
- keySchedule[ksRow] = keyWords[ksRow];
- } else {
- t = keySchedule[ksRow - 1];
- if (!(ksRow % keySize)) {
- // Rot word
- t = (t << 8) | (t >>> 24);
- // Sub word
- t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff];
- // Mix Rcon
- t ^= RCON[(ksRow / keySize) | 0] << 24;
- } else if (keySize > 6 && ksRow % keySize == 4) {
- // Sub word
- t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff];
- }
- keySchedule[ksRow] = keySchedule[ksRow - keySize] ^ t;
- }
- }
- // Compute inv key schedule
- var invKeySchedule = this._invKeySchedule = [];
- for (var invKsRow = 0; invKsRow < ksRows; invKsRow++) {
- var ksRow = ksRows - invKsRow;
- if (invKsRow % 4) {
- var t = keySchedule[ksRow];
- } else {
- var t = keySchedule[ksRow - 4];
- }
- if (invKsRow < 4 || ksRow <= 4) {
- invKeySchedule[invKsRow] = t;
- } else {
- invKeySchedule[invKsRow] = INV_SUB_MIX_0[SBOX[t >>> 24]] ^ INV_SUB_MIX_1[SBOX[(t >>> 16) & 0xff]] ^
- INV_SUB_MIX_2[SBOX[(t >>> 8) & 0xff]] ^ INV_SUB_MIX_3[SBOX[t & 0xff]];
- }
- }
- },
- encryptBlock: function (M, offset) {
- this._doCryptBlock(M, offset, this._keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX);
- },
- decryptBlock: function (M, offset) {
- // Swap 2nd and 4th rows
- var t = M[offset + 1];
- M[offset + 1] = M[offset + 3];
- M[offset + 3] = t;
- this._doCryptBlock(M, offset, this._invKeySchedule, INV_SUB_MIX_0, INV_SUB_MIX_1, INV_SUB_MIX_2, INV_SUB_MIX_3, INV_SBOX);
- // Inv swap 2nd and 4th rows
- var t = M[offset + 1];
- M[offset + 1] = M[offset + 3];
- M[offset + 3] = t;
- },
- _doCryptBlock: function (M, offset, keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX) {
- // Shortcut
- var nRounds = this._nRounds;
- // Get input, add round key
- var s0 = M[offset] ^ keySchedule[0];
- var s1 = M[offset + 1] ^ keySchedule[1];
- var s2 = M[offset + 2] ^ keySchedule[2];
- var s3 = M[offset + 3] ^ keySchedule[3];
- // Key schedule row counter
- var ksRow = 4;
- // Rounds
- for (var round = 1; round < nRounds; round++) {
- // Shift rows, sub bytes, mix columns, add round key
- var t0 = SUB_MIX_0[s0 >>> 24] ^ SUB_MIX_1[(s1 >>> 16) & 0xff] ^ SUB_MIX_2[(s2 >>> 8) & 0xff] ^ SUB_MIX_3[s3 & 0xff] ^ keySchedule[ksRow++];
- var t1 = SUB_MIX_0[s1 >>> 24] ^ SUB_MIX_1[(s2 >>> 16) & 0xff] ^ SUB_MIX_2[(s3 >>> 8) & 0xff] ^ SUB_MIX_3[s0 & 0xff] ^ keySchedule[ksRow++];
- var t2 = SUB_MIX_0[s2 >>> 24] ^ SUB_MIX_1[(s3 >>> 16) & 0xff] ^ SUB_MIX_2[(s0 >>> 8) & 0xff] ^ SUB_MIX_3[s1 & 0xff] ^ keySchedule[ksRow++];
- var t3 = SUB_MIX_0[s3 >>> 24] ^ SUB_MIX_1[(s0 >>> 16) & 0xff] ^ SUB_MIX_2[(s1 >>> 8) & 0xff] ^ SUB_MIX_3[s2 & 0xff] ^ keySchedule[ksRow++];
- // Update state
- s0 = t0;
- s1 = t1;
- s2 = t2;
- s3 = t3;
- }
- // Shift rows, sub bytes, add round key
- var t0 = ((SBOX[s0 >>> 24] << 24) | (SBOX[(s1 >>> 16) & 0xff] << 16) | (SBOX[(s2 >>> 8) & 0xff] << 8) | SBOX[s3 & 0xff]) ^ keySchedule[ksRow++];
- var t1 = ((SBOX[s1 >>> 24] << 24) | (SBOX[(s2 >>> 16) & 0xff] << 16) | (SBOX[(s3 >>> 8) & 0xff] << 8) | SBOX[s0 & 0xff]) ^ keySchedule[ksRow++];
- var t2 = ((SBOX[s2 >>> 24] << 24) | (SBOX[(s3 >>> 16) & 0xff] << 16) | (SBOX[(s0 >>> 8) & 0xff] << 8) | SBOX[s1 & 0xff]) ^ keySchedule[ksRow++];
- var t3 = ((SBOX[s3 >>> 24] << 24) | (SBOX[(s0 >>> 16) & 0xff] << 16) | (SBOX[(s1 >>> 8) & 0xff] << 8) | SBOX[s2 & 0xff]) ^ keySchedule[ksRow++];
- // Set output
- M[offset] = t0;
- M[offset + 1] = t1;
- M[offset + 2] = t2;
- M[offset + 3] = t3;
- },
- keySize: 256/32
- });
- /**
- * Shortcut functions to the cipher's object interface.
- *
- * @example
- *
- * var ciphertext = CryptoJS.AES.encrypt(message, key, cfg);
- * var plaintext = CryptoJS.AES.decrypt(ciphertext, key, cfg);
- */
- C.AES = BlockCipher._createHelper(AES);
- }());
- return CryptoJS.AES;
- }));
- },{"./cipher-core":746,"./core":747,"./enc-base64":748,"./evpkdf":750,"./md5":752}],746:[function(_dereq_,module,exports){
- ;(function (root, factory, undef) {
- if (typeof exports === "object") {
- // CommonJS
- module.exports = exports = factory(_dereq_("./core"), _dereq_("./evpkdf"));
- }
- else if (typeof define === "function" && define.amd) {
- // AMD
- define(["./core", "./evpkdf"], factory);
- }
- else {
- // Global (browser)
- factory(root.CryptoJS);
- }
- }(this, function (CryptoJS) {
- /**
- * Cipher core components.
- */
- CryptoJS.lib.Cipher || (function (undefined) {
- // Shortcuts
- var C = CryptoJS;
- var C_lib = C.lib;
- var Base = C_lib.Base;
- var WordArray = C_lib.WordArray;
- var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm;
- var C_enc = C.enc;
- var Utf8 = C_enc.Utf8;
- var Base64 = C_enc.Base64;
- var C_algo = C.algo;
- var EvpKDF = C_algo.EvpKDF;
- /**
- * Abstract base cipher template.
- *
- * @property {number} keySize This cipher's key size. Default: 4 (128 bits)
- * @property {number} ivSize This cipher's IV size. Default: 4 (128 bits)
- * @property {number} _ENC_XFORM_MODE A constant representing encryption mode.
- * @property {number} _DEC_XFORM_MODE A constant representing decryption mode.
- */
- var Cipher = C_lib.Cipher = BufferedBlockAlgorithm.extend({
- /**
- * Configuration options.
- *
- * @property {WordArray} iv The IV to use for this operation.
- */
- cfg: Base.extend(),
- /**
- * Creates this cipher in encryption mode.
- *
- * @param {WordArray} key The key.
- * @param {Object} cfg (Optional) The configuration options to use for this operation.
- *
- * @return {Cipher} A cipher instance.
- *
- * @static
- *
- * @example
- *
- * var cipher = CryptoJS.algo.AES.createEncryptor(keyWordArray, { iv: ivWordArray });
- */
- createEncryptor: function (key, cfg) {
- return this.create(this._ENC_XFORM_MODE, key, cfg);
- },
- /**
- * Creates this cipher in decryption mode.
- *
- * @param {WordArray} key The key.
- * @param {Object} cfg (Optional) The configuration options to use for this operation.
- *
- * @return {Cipher} A cipher instance.
- *
- * @static
- *
- * @example
- *
- * var cipher = CryptoJS.algo.AES.createDecryptor(keyWordArray, { iv: ivWordArray });
- */
- createDecryptor: function (key, cfg) {
- return this.create(this._DEC_XFORM_MODE, key, cfg);
- },
- /**
- * Initializes a newly created cipher.
- *
- * @param {number} xformMode Either the encryption or decryption transormation mode constant.
- * @param {WordArray} key The key.
- * @param {Object} cfg (Optional) The configuration options to use for this operation.
- *
- * @example
- *
- * var cipher = CryptoJS.algo.AES.create(CryptoJS.algo.AES._ENC_XFORM_MODE, keyWordArray, { iv: ivWordArray });
- */
- init: function (xformMode, key, cfg) {
- // Apply config defaults
- this.cfg = this.cfg.extend(cfg);
- // Store transform mode and key
- this._xformMode = xformMode;
- this._key = key;
- // Set initial values
- this.reset();
- },
- /**
- * Resets this cipher to its initial state.
- *
- * @example
- *
- * cipher.reset();
- */
- reset: function () {
- // Reset data buffer
- BufferedBlockAlgorithm.reset.call(this);
- // Perform concrete-cipher logic
- this._doReset();
- },
- /**
- * Adds data to be encrypted or decrypted.
- *
- * @param {WordArray|string} dataUpdate The data to encrypt or decrypt.
- *
- * @return {WordArray} The data after processing.
- *
- * @example
- *
- * var encrypted = cipher.process('data');
- * var encrypted = cipher.process(wordArray);
- */
- process: function (dataUpdate) {
- // Append
- this._append(dataUpdate);
- // Process available blocks
- return this._process();
- },
- /**
- * Finalizes the encryption or decryption process.
- * Note that the finalize operation is effectively a destructive, read-once operation.
- *
- * @param {WordArray|string} dataUpdate The final data to encrypt or decrypt.
- *
- * @return {WordArray} The data after final processing.
- *
- * @example
- *
- * var encrypted = cipher.finalize();
- * var encrypted = cipher.finalize('data');
- * var encrypted = cipher.finalize(wordArray);
- */
- finalize: function (dataUpdate) {
- // Final data update
- if (dataUpdate) {
- this._append(dataUpdate);
- }
- // Perform concrete-cipher logic
- var finalProcessedData = this._doFinalize();
- return finalProcessedData;
- },
- keySize: 128/32,
- ivSize: 128/32,
- _ENC_XFORM_MODE: 1,
- _DEC_XFORM_MODE: 2,
- /**
- * Creates shortcut functions to a cipher's object interface.
- *
- * @param {Cipher} cipher The cipher to create a helper for.
- *
- * @return {Object} An object with encrypt and decrypt shortcut functions.
- *
- * @static
- *
- * @example
- *
- * var AES = CryptoJS.lib.Cipher._createHelper(CryptoJS.algo.AES);
- */
- _createHelper: (function () {
- function selectCipherStrategy(key) {
- if (typeof key == 'string') {
- return PasswordBasedCipher;
- } else {
- return SerializableCipher;
- }
- }
- return function (cipher) {
- return {
- encrypt: function (message, key, cfg) {
- return selectCipherStrategy(key).encrypt(cipher, message, key, cfg);
- },
- decrypt: function (ciphertext, key, cfg) {
- return selectCipherStrategy(key).decrypt(cipher, ciphertext, key, cfg);
- }
- };
- };
- }())
- });
- /**
- * Abstract base stream cipher template.
- *
- * @property {number} blockSize The number of 32-bit words this cipher operates on. Default: 1 (32 bits)
- */
- var StreamCipher = C_lib.StreamCipher = Cipher.extend({
- _doFinalize: function () {
- // Process partial blocks
- var finalProcessedBlocks = this._process(!!'flush');
- return finalProcessedBlocks;
- },
- blockSize: 1
- });
- /**
- * Mode namespace.
- */
- var C_mode = C.mode = {};
- /**
- * Abstract base block cipher mode template.
- */
- var BlockCipherMode = C_lib.BlockCipherMode = Base.extend({
- /**
- * Creates this mode for encryption.
- *
- * @param {Cipher} cipher A block cipher instance.
- * @param {Array} iv The IV words.
- *
- * @static
- *
- * @example
- *
- * var mode = CryptoJS.mode.CBC.createEncryptor(cipher, iv.words);
- */
- createEncryptor: function (cipher, iv) {
- return this.Encryptor.create(cipher, iv);
- },
- /**
- * Creates this mode for decryption.
- *
- * @param {Cipher} cipher A block cipher instance.
- * @param {Array} iv The IV words.
- *
- * @static
- *
- * @example
- *
- * var mode = CryptoJS.mode.CBC.createDecryptor(cipher, iv.words);
- */
- createDecryptor: function (cipher, iv) {
- return this.Decryptor.create(cipher, iv);
- },
- /**
- * Initializes a newly created mode.
- *
- * @param {Cipher} cipher A block cipher instance.
- * @param {Array} iv The IV words.
- *
- * @example
- *
- * var mode = CryptoJS.mode.CBC.Encryptor.create(cipher, iv.words);
- */
- init: function (cipher, iv) {
- this._cipher = cipher;
- this._iv = iv;
- }
- });
- /**
- * Cipher Block Chaining mode.
- */
- var CBC = C_mode.CBC = (function () {
- /**
- * Abstract base CBC mode.
- */
- var CBC = BlockCipherMode.extend();
- /**
- * CBC encryptor.
- */
- CBC.Encryptor = CBC.extend({
- /**
- * Processes the data block at offset.
- *
- * @param {Array} words The data words to operate on.
- * @param {number} offset The offset where the block starts.
- *
- * @example
- *
- * mode.processBlock(data.words, offset);
- */
- processBlock: function (words, offset) {
- // Shortcuts
- var cipher = this._cipher;
- var blockSize = cipher.blockSize;
- // XOR and encrypt
- xorBlock.call(this, words, offset, blockSize);
- cipher.encryptBlock(words, offset);
- // Remember this block to use with next block
- this._prevBlock = words.slice(offset, offset + blockSize);
- }
- });
- /**
- * CBC decryptor.
- */
- CBC.Decryptor = CBC.extend({
- /**
- * Processes the data block at offset.
- *
- * @param {Array} words The data words to operate on.
- * @param {number} offset The offset where the block starts.
- *
- * @example
- *
- * mode.processBlock(data.words, offset);
- */
- processBlock: function (words, offset) {
- // Shortcuts
- var cipher = this._cipher;
- var blockSize = cipher.blockSize;
- // Remember this block to use with next block
- var thisBlock = words.slice(offset, offset + blockSize);
- // Decrypt and XOR
- cipher.decryptBlock(words, offset);
- xorBlock.call(this, words, offset, blockSize);
- // This block becomes the previous block
- this._prevBlock = thisBlock;
- }
- });
- function xorBlock(words, offset, blockSize) {
- var block;
- // Shortcut
- var iv = this._iv;
- // Choose mixing block
- if (iv) {
- block = iv;
- // Remove IV for subsequent blocks
- this._iv = undefined;
- } else {
- block = this._prevBlock;
- }
- // XOR blocks
- for (var i = 0; i < blockSize; i++) {
- words[offset + i] ^= block[i];
- }
- }
- return CBC;
- }());
- /**
- * Padding namespace.
- */
- var C_pad = C.pad = {};
- /**
- * PKCS #5/7 padding strategy.
- */
- var Pkcs7 = C_pad.Pkcs7 = {
- /**
- * Pads data using the algorithm defined in PKCS #5/7.
- *
- * @param {WordArray} data The data to pad.
- * @param {number} blockSize The multiple that the data should be padded to.
- *
- * @static
- *
- * @example
- *
- * CryptoJS.pad.Pkcs7.pad(wordArray, 4);
- */
- pad: function (data, blockSize) {
- // Shortcut
- var blockSizeBytes = blockSize * 4;
- // Count padding bytes
- var nPaddingBytes = blockSizeBytes - data.sigBytes % blockSizeBytes;
- // Create padding word
- var paddingWord = (nPaddingBytes << 24) | (nPaddingBytes << 16) | (nPaddingBytes << 8) | nPaddingBytes;
- // Create padding
- var paddingWords = [];
- for (var i = 0; i < nPaddingBytes; i += 4) {
- paddingWords.push(paddingWord);
- }
- var padding = WordArray.create(paddingWords, nPaddingBytes);
- // Add padding
- data.concat(padding);
- },
- /**
- * Unpads data that had been padded using the algorithm defined in PKCS #5/7.
- *
- * @param {WordArray} data The data to unpad.
- *
- * @static
- *
- * @example
- *
- * CryptoJS.pad.Pkcs7.unpad(wordArray);
- */
- unpad: function (data) {
- // Get number of padding bytes from last byte
- var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff;
- // Remove padding
- data.sigBytes -= nPaddingBytes;
- }
- };
- /**
- * Abstract base block cipher template.
- *
- * @property {number} blockSize The number of 32-bit words this cipher operates on. Default: 4 (128 bits)
- */
- var BlockCipher = C_lib.BlockCipher = Cipher.extend({
- /**
- * Configuration options.
- *
- * @property {Mode} mode The block mode to use. Default: CBC
- * @property {Padding} padding The padding strategy to use. Default: Pkcs7
- */
- cfg: Cipher.cfg.extend({
- mode: CBC,
- padding: Pkcs7
- }),
- reset: function () {
- var modeCreator;
- // Reset cipher
- Cipher.reset.call(this);
- // Shortcuts
- var cfg = this.cfg;
- var iv = cfg.iv;
- var mode = cfg.mode;
- // Reset block mode
- if (this._xformMode == this._ENC_XFORM_MODE) {
- modeCreator = mode.createEncryptor;
- } else /* if (this._xformMode == this._DEC_XFORM_MODE) */ {
- modeCreator = mode.createDecryptor;
- // Keep at least one block in the buffer for unpadding
- this._minBufferSize = 1;
- }
- if (this._mode && this._mode.__creator == modeCreator) {
- this._mode.init(this, iv && iv.words);
- } else {
- this._mode = modeCreator.call(mode, this, iv && iv.words);
- this._mode.__creator = modeCreator;
- }
- },
- _doProcessBlock: function (words, offset) {
- this._mode.processBlock(words, offset);
- },
- _doFinalize: function () {
- var finalProcessedBlocks;
- // Shortcut
- var padding = this.cfg.padding;
- // Finalize
- if (this._xformMode == this._ENC_XFORM_MODE) {
- // Pad data
- padding.pad(this._data, this.blockSize);
- // Process final blocks
- finalProcessedBlocks = this._process(!!'flush');
- } else /* if (this._xformMode == this._DEC_XFORM_MODE) */ {
- // Process final blocks
- finalProcessedBlocks = this._process(!!'flush');
- // Unpad data
- padding.unpad(finalProcessedBlocks);
- }
- return finalProcessedBlocks;
- },
- blockSize: 128/32
- });
- /**
- * A collection of cipher parameters.
- *
- * @property {WordArray} ciphertext The raw ciphertext.
- * @property {WordArray} key The key to this ciphertext.
- * @property {WordArray} iv The IV used in the ciphering operation.
- * @property {WordArray} salt The salt used with a key derivation function.
- * @property {Cipher} algorithm The cipher algorithm.
- * @property {Mode} mode The block mode used in the ciphering operation.
- * @property {Padding} padding The padding scheme used in the ciphering operation.
- * @property {number} blockSize The block size of the cipher.
- * @property {Format} formatter The default formatting strategy to convert this cipher params object to a string.
- */
- var CipherParams = C_lib.CipherParams = Base.extend({
- /**
- * Initializes a newly created cipher params object.
- *
- * @param {Object} cipherParams An object with any of the possible cipher parameters.
- *
- * @example
- *
- * var cipherParams = CryptoJS.lib.CipherParams.create({
- * ciphertext: ciphertextWordArray,
- * key: keyWordArray,
- * iv: ivWordArray,
- * salt: saltWordArray,
- * algorithm: CryptoJS.algo.AES,
- * mode: CryptoJS.mode.CBC,
- * padding: CryptoJS.pad.PKCS7,
- * blockSize: 4,
- * formatter: CryptoJS.format.OpenSSL
- * });
- */
- init: function (cipherParams) {
- this.mixIn(cipherParams);
- },
- /**
- * Converts this cipher params object to a string.
- *
- * @param {Format} formatter (Optional) The formatting strategy to use.
- *
- * @return {string} The stringified cipher params.
- *
- * @throws Error If neither the formatter nor the default formatter is set.
- *
- * @example
- *
- * var string = cipherParams + '';
- * var string = cipherParams.toString();
- * var string = cipherParams.toString(CryptoJS.format.OpenSSL);
- */
- toString: function (formatter) {
- return (formatter || this.formatter).stringify(this);
- }
- });
- /**
- * Format namespace.
- */
- var C_format = C.format = {};
- /**
- * OpenSSL formatting strategy.
- */
- var OpenSSLFormatter = C_format.OpenSSL = {
- /**
- * Converts a cipher params object to an OpenSSL-compatible string.
- *
- * @param {CipherParams} cipherParams The cipher params object.
- *
- * @return {string} The OpenSSL-compatible string.
- *
- * @static
- *
- * @example
- *
- * var openSSLString = CryptoJS.format.OpenSSL.stringify(cipherParams);
- */
- stringify: function (cipherParams) {
- var wordArray;
- // Shortcuts
- var ciphertext = cipherParams.ciphertext;
- var salt = cipherParams.salt;
- // Format
- if (salt) {
- wordArray = WordArray.create([0x53616c74, 0x65645f5f]).concat(salt).concat(ciphertext);
- } else {
- wordArray = ciphertext;
- }
- return wordArray.toString(Base64);
- },
- /**
- * Converts an OpenSSL-compatible string to a cipher params object.
- *
- * @param {string} openSSLStr The OpenSSL-compatible string.
- *
- * @return {CipherParams} The cipher params object.
- *
- * @static
- *
- * @example
- *
- * var cipherParams = CryptoJS.format.OpenSSL.parse(openSSLString);
- */
- parse: function (openSSLStr) {
- var salt;
- // Parse base64
- var ciphertext = Base64.parse(openSSLStr);
- // Shortcut
- var ciphertextWords = ciphertext.words;
- // Test for salt
- if (ciphertextWords[0] == 0x53616c74 && ciphertextWords[1] == 0x65645f5f) {
- // Extract salt
- salt = WordArray.create(ciphertextWords.slice(2, 4));
- // Remove salt from ciphertext
- ciphertextWords.splice(0, 4);
- ciphertext.sigBytes -= 16;
- }
- return CipherParams.create({ ciphertext: ciphertext, salt: salt });
- }
- };
- /**
- * A cipher wrapper that returns ciphertext as a serializable cipher params object.
- */
- var SerializableCipher = C_lib.SerializableCipher = Base.extend({
- /**
- * Configuration options.
- *
- * @property {Formatter} format The formatting strategy to convert cipher param objects to and from a string. Default: OpenSSL
- */
- cfg: Base.extend({
- format: OpenSSLFormatter
- }),
- /**
- * Encrypts a message.
- *
- * @param {Cipher} cipher The cipher algorithm to use.
- * @param {WordArray|string} message The message to encrypt.
- * @param {WordArray} key The key.
- * @param {Object} cfg (Optional) The configuration options to use for this operation.
- *
- * @return {CipherParams} A cipher params object.
- *
- * @static
- *
- * @example
- *
- * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key);
- * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv });
- * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv, format: CryptoJS.format.OpenSSL });
- */
- encrypt: function (cipher, message, key, cfg) {
- // Apply config defaults
- cfg = this.cfg.extend(cfg);
- // Encrypt
- var encryptor = cipher.createEncryptor(key, cfg);
- var ciphertext = encryptor.finalize(message);
- // Shortcut
- var cipherCfg = encryptor.cfg;
- // Create and return serializable cipher params
- return CipherParams.create({
- ciphertext: ciphertext,
- key: key,
- iv: cipherCfg.iv,
- algorithm: cipher,
- mode: cipherCfg.mode,
- padding: cipherCfg.padding,
- blockSize: cipher.blockSize,
- formatter: cfg.format
- });
- },
- /**
- * Decrypts serialized ciphertext.
- *
- * @param {Cipher} cipher The cipher algorithm to use.
- * @param {CipherParams|string} ciphertext The ciphertext to decrypt.
- * @param {WordArray} key The key.
- * @param {Object} cfg (Optional) The configuration options to use for this operation.
- *
- * @return {WordArray} The plaintext.
- *
- * @static
- *
- * @example
- *
- * var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, key, { iv: iv, format: CryptoJS.format.OpenSSL });
- * var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, key, { iv: iv, format: CryptoJS.format.OpenSSL });
- */
- decrypt: function (cipher, ciphertext, key, cfg) {
- // Apply config defaults
- cfg = this.cfg.extend(cfg);
- // Convert string to CipherParams
- ciphertext = this._parse(ciphertext, cfg.format);
- // Decrypt
- var plaintext = cipher.createDecryptor(key, cfg).finalize(ciphertext.ciphertext);
- return plaintext;
- },
- /**
- * Converts serialized ciphertext to CipherParams,
- * else assumed CipherParams already and returns ciphertext unchanged.
- *
- * @param {CipherParams|string} ciphertext The ciphertext.
- * @param {Formatter} format The formatting strategy to use to parse serialized ciphertext.
- *
- * @return {CipherParams} The unserialized ciphertext.
- *
- * @static
- *
- * @example
- *
- * var ciphertextParams = CryptoJS.lib.SerializableCipher._parse(ciphertextStringOrParams, format);
- */
- _parse: function (ciphertext, format) {
- if (typeof ciphertext == 'string') {
- return format.parse(ciphertext, this);
- } else {
- return ciphertext;
- }
- }
- });
- /**
- * Key derivation function namespace.
- */
- var C_kdf = C.kdf = {};
- /**
- * OpenSSL key derivation function.
- */
- var OpenSSLKdf = C_kdf.OpenSSL = {
- /**
- * Derives a key and IV from a password.
- *
- * @param {string} password The password to derive from.
- * @param {number} keySize The size in words of the key to generate.
- * @param {number} ivSize The size in words of the IV to generate.
- * @param {WordArray|string} salt (Optional) A 64-bit salt to use. If omitted, a salt will be generated randomly.
- *
- * @return {CipherParams} A cipher params object with the key, IV, and salt.
- *
- * @static
- *
- * @example
- *
- * var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32);
- * var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32, 'saltsalt');
- */
- execute: function (password, keySize, ivSize, salt) {
- // Generate random salt
- if (!salt) {
- salt = WordArray.random(64/8);
- }
- // Derive key and IV
- var key = EvpKDF.create({ keySize: keySize + ivSize }).compute(password, salt);
- // Separate key and IV
- var iv = WordArray.create(key.words.slice(keySize), ivSize * 4);
- key.sigBytes = keySize * 4;
- // Return params
- return CipherParams.create({ key: key, iv: iv, salt: salt });
- }
- };
- /**
- * A serializable cipher wrapper that derives the key from a password,
- * and returns ciphertext as a serializable cipher params object.
- */
- var PasswordBasedCipher = C_lib.PasswordBasedCipher = SerializableCipher.extend({
- /**
- * Configuration options.
- *
- * @property {KDF} kdf The key derivation function to use to generate a key and IV from a password. Default: OpenSSL
- */
- cfg: SerializableCipher.cfg.extend({
- kdf: OpenSSLKdf
- }),
- /**
- * Encrypts a message using a password.
- *
- * @param {Cipher} cipher The cipher algorithm to use.
- * @param {WordArray|string} message The message to encrypt.
- * @param {string} password The password.
- * @param {Object} cfg (Optional) The configuration options to use for this operation.
- *
- * @return {CipherParams} A cipher params object.
- *
- * @static
- *
- * @example
- *
- * var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password');
- * var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password', { format: CryptoJS.format.OpenSSL });
- */
- encrypt: function (cipher, message, password, cfg) {
- // Apply config defaults
- cfg = this.cfg.extend(cfg);
- // Derive key and other params
- var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize);
- // Add IV to config
- cfg.iv = derivedParams.iv;
- // Encrypt
- var ciphertext = SerializableCipher.encrypt.call(this, cipher, message, derivedParams.key, cfg);
- // Mix in derived params
- ciphertext.mixIn(derivedParams);
- return ciphertext;
- },
- /**
- * Decrypts serialized ciphertext using a password.
- *
- * @param {Cipher} cipher The cipher algorithm to use.
- * @param {CipherParams|string} ciphertext The ciphertext to decrypt.
- * @param {string} password The password.
- * @param {Object} cfg (Optional) The configuration options to use for this operation.
- *
- * @return {WordArray} The plaintext.
- *
- * @static
- *
- * @example
- *
- * var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, 'password', { format: CryptoJS.format.OpenSSL });
- * var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, 'password', { format: CryptoJS.format.OpenSSL });
- */
- decrypt: function (cipher, ciphertext, password, cfg) {
- // Apply config defaults
- cfg = this.cfg.extend(cfg);
- // Convert string to CipherParams
- ciphertext = this._parse(ciphertext, cfg.format);
- // Derive key and other params
- var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize, ciphertext.salt);
- // Add IV to config
- cfg.iv = derivedParams.iv;
- // Decrypt
- var plaintext = SerializableCipher.decrypt.call(this, cipher, ciphertext, derivedParams.key, cfg);
- return plaintext;
- }
- });
- }());
- }));
- },{"./core":747,"./evpkdf":750}],747:[function(_dereq_,module,exports){
- (function (global){(function (){
- ;(function (root, factory) {
- if (typeof exports === "object") {
- // CommonJS
- module.exports = exports = factory();
- }
- else if (typeof define === "function" && define.amd) {
- // AMD
- define([], factory);
- }
- else {
- // Global (browser)
- root.CryptoJS = factory();
- }
- }(this, function () {
- /*globals window, global, require*/
- /**
- * CryptoJS core components.
- */
- var CryptoJS = CryptoJS || (function (Math, undefined) {
- var crypto;
- // Native crypto from window (Browser)
- if (typeof window !== 'undefined' && window.crypto) {
- crypto = window.crypto;
- }
- // Native crypto in web worker (Browser)
- if (typeof self !== 'undefined' && self.crypto) {
- crypto = self.crypto;
- }
- // Native crypto from worker
- if (typeof globalThis !== 'undefined' && globalThis.crypto) {
- crypto = globalThis.crypto;
- }
- // Native (experimental IE 11) crypto from window (Browser)
- if (!crypto && typeof window !== 'undefined' && window.msCrypto) {
- crypto = window.msCrypto;
- }
- // Native crypto from global (NodeJS)
- if (!crypto && typeof global !== 'undefined' && global.crypto) {
- crypto = global.crypto;
- }
- // Native crypto import via require (NodeJS)
- if (!crypto && typeof _dereq_ === 'function') {
- try {
- crypto = _dereq_('crypto');
- } catch (err) {}
- }
- /*
- * Cryptographically secure pseudorandom number generator
- *
- * As Math.random() is cryptographically not safe to use
- */
- var cryptoSecureRandomInt = function () {
- if (crypto) {
- // Use getRandomValues method (Browser)
- if (typeof crypto.getRandomValues === 'function') {
- try {
- return crypto.getRandomValues(new Uint32Array(1))[0];
- } catch (err) {}
- }
- // Use randomBytes method (NodeJS)
- if (typeof crypto.randomBytes === 'function') {
- try {
- return crypto.randomBytes(4).readInt32LE();
- } catch (err) {}
- }
- }
- throw new Error('Native crypto module could not be used to get secure random number.');
- };
- /*
- * Local polyfill of Object.create
- */
- var create = Object.create || (function () {
- function F() {}
- return function (obj) {
- var subtype;
- F.prototype = obj;
- subtype = new F();
- F.prototype = null;
- return subtype;
- };
- }());
- /**
- * CryptoJS namespace.
- */
- var C = {};
- /**
- * Library namespace.
- */
- var C_lib = C.lib = {};
- /**
- * Base object for prototypal inheritance.
- */
- var Base = C_lib.Base = (function () {
- return {
- /**
- * Creates a new object that inherits from this object.
- *
- * @param {Object} overrides Properties to copy into the new object.
- *
- * @return {Object} The new object.
- *
- * @static
- *
- * @example
- *
- * var MyType = CryptoJS.lib.Base.extend({
- * field: 'value',
- *
- * method: function () {
- * }
- * });
- */
- extend: function (overrides) {
- // Spawn
- var subtype = create(this);
- // Augment
- if (overrides) {
- subtype.mixIn(overrides);
- }
- // Create default initializer
- if (!subtype.hasOwnProperty('init') || this.init === subtype.init) {
- subtype.init = function () {
- subtype.$super.init.apply(this, arguments);
- };
- }
- // Initializer's prototype is the subtype object
- subtype.init.prototype = subtype;
- // Reference supertype
- subtype.$super = this;
- return subtype;
- },
- /**
- * Extends this object and runs the init method.
- * Arguments to create() will be passed to init().
- *
- * @return {Object} The new object.
- *
- * @static
- *
- * @example
- *
- * var instance = MyType.create();
- */
- create: function () {
- var instance = this.extend();
- instance.init.apply(instance, arguments);
- return instance;
- },
- /**
- * Initializes a newly created object.
- * Override this method to add some logic when your objects are created.
- *
- * @example
- *
- * var MyType = CryptoJS.lib.Base.extend({
- * init: function () {
- * // ...
- * }
- * });
- */
- init: function () {
- },
- /**
- * Copies properties into this object.
- *
- * @param {Object} properties The properties to mix in.
- *
- * @example
- *
- * MyType.mixIn({
- * field: 'value'
- * });
- */
- mixIn: function (properties) {
- for (var propertyName in properties) {
- if (properties.hasOwnProperty(propertyName)) {
- this[propertyName] = properties[propertyName];
- }
- }
- // IE won't copy toString using the loop above
- if (properties.hasOwnProperty('toString')) {
- this.toString = properties.toString;
- }
- },
- /**
- * Creates a copy of this object.
- *
- * @return {Object} The clone.
- *
- * @example
- *
- * var clone = instance.clone();
- */
- clone: function () {
- return this.init.prototype.extend(this);
- }
- };
- }());
- /**
- * An array of 32-bit words.
- *
- * @property {Array} words The array of 32-bit words.
- * @property {number} sigBytes The number of significant bytes in this word array.
- */
- var WordArray = C_lib.WordArray = Base.extend({
- /**
- * Initializes a newly created word array.
- *
- * @param {Array} words (Optional) An array of 32-bit words.
- * @param {number} sigBytes (Optional) The number of significant bytes in the words.
- *
- * @example
- *
- * var wordArray = CryptoJS.lib.WordArray.create();
- * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607]);
- * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607], 6);
- */
- init: function (words, sigBytes) {
- words = this.words = words || [];
- if (sigBytes != undefined) {
- this.sigBytes = sigBytes;
- } else {
- this.sigBytes = words.length * 4;
- }
- },
- /**
- * Converts this word array to a string.
- *
- * @param {Encoder} encoder (Optional) The encoding strategy to use. Default: CryptoJS.enc.Hex
- *
- * @return {string} The stringified word array.
- *
- * @example
- *
- * var string = wordArray + '';
- * var string = wordArray.toString();
- * var string = wordArray.toString(CryptoJS.enc.Utf8);
- */
- toString: function (encoder) {
- return (encoder || Hex).stringify(this);
- },
- /**
- * Concatenates a word array to this word array.
- *
- * @param {WordArray} wordArray The word array to append.
- *
- * @return {WordArray} This word array.
- *
- * @example
- *
- * wordArray1.concat(wordArray2);
- */
- concat: function (wordArray) {
- // Shortcuts
- var thisWords = this.words;
- var thatWords = wordArray.words;
- var thisSigBytes = this.sigBytes;
- var thatSigBytes = wordArray.sigBytes;
- // Clamp excess bits
- this.clamp();
- // Concat
- if (thisSigBytes % 4) {
- // Copy one byte at a time
- for (var i = 0; i < thatSigBytes; i++) {
- var thatByte = (thatWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
- thisWords[(thisSigBytes + i) >>> 2] |= thatByte << (24 - ((thisSigBytes + i) % 4) * 8);
- }
- } else {
- // Copy one word at a time
- for (var j = 0; j < thatSigBytes; j += 4) {
- thisWords[(thisSigBytes + j) >>> 2] = thatWords[j >>> 2];
- }
- }
- this.sigBytes += thatSigBytes;
- // Chainable
- return this;
- },
- /**
- * Removes insignificant bits.
- *
- * @example
- *
- * wordArray.clamp();
- */
- clamp: function () {
- // Shortcuts
- var words = this.words;
- var sigBytes = this.sigBytes;
- // Clamp
- words[sigBytes >>> 2] &= 0xffffffff << (32 - (sigBytes % 4) * 8);
- words.length = Math.ceil(sigBytes / 4);
- },
- /**
- * Creates a copy of this word array.
- *
- * @return {WordArray} The clone.
- *
- * @example
- *
- * var clone = wordArray.clone();
- */
- clone: function () {
- var clone = Base.clone.call(this);
- clone.words = this.words.slice(0);
- return clone;
- },
- /**
- * Creates a word array filled with random bytes.
- *
- * @param {number} nBytes The number of random bytes to generate.
- *
- * @return {WordArray} The random word array.
- *
- * @static
- *
- * @example
- *
- * var wordArray = CryptoJS.lib.WordArray.random(16);
- */
- random: function (nBytes) {
- var words = [];
- for (var i = 0; i < nBytes; i += 4) {
- words.push(cryptoSecureRandomInt());
- }
- return new WordArray.init(words, nBytes);
- }
- });
- /**
- * Encoder namespace.
- */
- var C_enc = C.enc = {};
- /**
- * Hex encoding strategy.
- */
- var Hex = C_enc.Hex = {
- /**
- * Converts a word array to a hex string.
- *
- * @param {WordArray} wordArray The word array.
- *
- * @return {string} The hex string.
- *
- * @static
- *
- * @example
- *
- * var hexString = CryptoJS.enc.Hex.stringify(wordArray);
- */
- stringify: function (wordArray) {
- // Shortcuts
- var words = wordArray.words;
- var sigBytes = wordArray.sigBytes;
- // Convert
- var hexChars = [];
- for (var i = 0; i < sigBytes; i++) {
- var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
- hexChars.push((bite >>> 4).toString(16));
- hexChars.push((bite & 0x0f).toString(16));
- }
- return hexChars.join('');
- },
- /**
- * Converts a hex string to a word array.
- *
- * @param {string} hexStr The hex string.
- *
- * @return {WordArray} The word array.
- *
- * @static
- *
- * @example
- *
- * var wordArray = CryptoJS.enc.Hex.parse(hexString);
- */
- parse: function (hexStr) {
- // Shortcut
- var hexStrLength = hexStr.length;
- // Convert
- var words = [];
- for (var i = 0; i < hexStrLength; i += 2) {
- words[i >>> 3] |= parseInt(hexStr.substr(i, 2), 16) << (24 - (i % 8) * 4);
- }
- return new WordArray.init(words, hexStrLength / 2);
- }
- };
- /**
- * Latin1 encoding strategy.
- */
- var Latin1 = C_enc.Latin1 = {
- /**
- * Converts a word array to a Latin1 string.
- *
- * @param {WordArray} wordArray The word array.
- *
- * @return {string} The Latin1 string.
- *
- * @static
- *
- * @example
- *
- * var latin1String = CryptoJS.enc.Latin1.stringify(wordArray);
- */
- stringify: function (wordArray) {
- // Shortcuts
- var words = wordArray.words;
- var sigBytes = wordArray.sigBytes;
- // Convert
- var latin1Chars = [];
- for (var i = 0; i < sigBytes; i++) {
- var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
- latin1Chars.push(String.fromCharCode(bite));
- }
- return latin1Chars.join('');
- },
- /**
- * Converts a Latin1 string to a word array.
- *
- * @param {string} latin1Str The Latin1 string.
- *
- * @return {WordArray} The word array.
- *
- * @static
- *
- * @example
- *
- * var wordArray = CryptoJS.enc.Latin1.parse(latin1String);
- */
- parse: function (latin1Str) {
- // Shortcut
- var latin1StrLength = latin1Str.length;
- // Convert
- var words = [];
- for (var i = 0; i < latin1StrLength; i++) {
- words[i >>> 2] |= (latin1Str.charCodeAt(i) & 0xff) << (24 - (i % 4) * 8);
- }
- return new WordArray.init(words, latin1StrLength);
- }
- };
- /**
- * UTF-8 encoding strategy.
- */
- var Utf8 = C_enc.Utf8 = {
- /**
- * Converts a word array to a UTF-8 string.
- *
- * @param {WordArray} wordArray The word array.
- *
- * @return {string} The UTF-8 string.
- *
- * @static
- *
- * @example
- *
- * var utf8String = CryptoJS.enc.Utf8.stringify(wordArray);
- */
- stringify: function (wordArray) {
- try {
- return decodeURIComponent(escape(Latin1.stringify(wordArray)));
- } catch (e) {
- throw new Error('Malformed UTF-8 data');
- }
- },
- /**
- * Converts a UTF-8 string to a word array.
- *
- * @param {string} utf8Str The UTF-8 string.
- *
- * @return {WordArray} The word array.
- *
- * @static
- *
- * @example
- *
- * var wordArray = CryptoJS.enc.Utf8.parse(utf8String);
- */
- parse: function (utf8Str) {
- return Latin1.parse(unescape(encodeURIComponent(utf8Str)));
- }
- };
- /**
- * Abstract buffered block algorithm template.
- *
- * The property blockSize must be implemented in a concrete subtype.
- *
- * @property {number} _minBufferSize The number of blocks that should be kept unprocessed in the buffer. Default: 0
- */
- var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm = Base.extend({
- /**
- * Resets this block algorithm's data buffer to its initial state.
- *
- * @example
- *
- * bufferedBlockAlgorithm.reset();
- */
- reset: function () {
- // Initial values
- this._data = new WordArray.init();
- this._nDataBytes = 0;
- },
- /**
- * Adds new data to this block algorithm's buffer.
- *
- * @param {WordArray|string} data The data to append. Strings are converted to a WordArray using UTF-8.
- *
- * @example
- *
- * bufferedBlockAlgorithm._append('data');
- * bufferedBlockAlgorithm._append(wordArray);
- */
- _append: function (data) {
- // Convert string to WordArray, else assume WordArray already
- if (typeof data == 'string') {
- data = Utf8.parse(data);
- }
- // Append
- this._data.concat(data);
- this._nDataBytes += data.sigBytes;
- },
- /**
- * Processes available data blocks.
- *
- * This method invokes _doProcessBlock(offset), which must be implemented by a concrete subtype.
- *
- * @param {boolean} doFlush Whether all blocks and partial blocks should be processed.
- *
- * @return {WordArray} The processed data.
- *
- * @example
- *
- * var processedData = bufferedBlockAlgorithm._process();
- * var processedData = bufferedBlockAlgorithm._process(!!'flush');
- */
- _process: function (doFlush) {
- var processedWords;
- // Shortcuts
- var data = this._data;
- var dataWords = data.words;
- var dataSigBytes = data.sigBytes;
- var blockSize = this.blockSize;
- var blockSizeBytes = blockSize * 4;
- // Count blocks ready
- var nBlocksReady = dataSigBytes / blockSizeBytes;
- if (doFlush) {
- // Round up to include partial blocks
- nBlocksReady = Math.ceil(nBlocksReady);
- } else {
- // Round down to include only full blocks,
- // less the number of blocks that must remain in the buffer
- nBlocksReady = Math.max((nBlocksReady | 0) - this._minBufferSize, 0);
- }
- // Count words ready
- var nWordsReady = nBlocksReady * blockSize;
- // Count bytes ready
- var nBytesReady = Math.min(nWordsReady * 4, dataSigBytes);
- // Process blocks
- if (nWordsReady) {
- for (var offset = 0; offset < nWordsReady; offset += blockSize) {
- // Perform concrete-algorithm logic
- this._doProcessBlock(dataWords, offset);
- }
- // Remove processed words
- processedWords = dataWords.splice(0, nWordsReady);
- data.sigBytes -= nBytesReady;
- }
- // Return processed words
- return new WordArray.init(processedWords, nBytesReady);
- },
- /**
- * Creates a copy of this object.
- *
- * @return {Object} The clone.
- *
- * @example
- *
- * var clone = bufferedBlockAlgorithm.clone();
- */
- clone: function () {
- var clone = Base.clone.call(this);
- clone._data = this._data.clone();
- return clone;
- },
- _minBufferSize: 0
- });
- /**
- * Abstract hasher template.
- *
- * @property {number} blockSize The number of 32-bit words this hasher operates on. Default: 16 (512 bits)
- */
- var Hasher = C_lib.Hasher = BufferedBlockAlgorithm.extend({
- /**
- * Configuration options.
- */
- cfg: Base.extend(),
- /**
- * Initializes a newly created hasher.
- *
- * @param {Object} cfg (Optional) The configuration options to use for this hash computation.
- *
- * @example
- *
- * var hasher = CryptoJS.algo.SHA256.create();
- */
- init: function (cfg) {
- // Apply config defaults
- this.cfg = this.cfg.extend(cfg);
- // Set initial values
- this.reset();
- },
- /**
- * Resets this hasher to its initial state.
- *
- * @example
- *
- * hasher.reset();
- */
- reset: function () {
- // Reset data buffer
- BufferedBlockAlgorithm.reset.call(this);
- // Perform concrete-hasher logic
- this._doReset();
- },
- /**
- * Updates this hasher with a message.
- *
- * @param {WordArray|string} messageUpdate The message to append.
- *
- * @return {Hasher} This hasher.
- *
- * @example
- *
- * hasher.update('message');
- * hasher.update(wordArray);
- */
- update: function (messageUpdate) {
- // Append
- this._append(messageUpdate);
- // Update the hash
- this._process();
- // Chainable
- return this;
- },
- /**
- * Finalizes the hash computation.
- * Note that the finalize operation is effectively a destructive, read-once operation.
- *
- * @param {WordArray|string} messageUpdate (Optional) A final message update.
- *
- * @return {WordArray} The hash.
- *
- * @example
- *
- * var hash = hasher.finalize();
- * var hash = hasher.finalize('message');
- * var hash = hasher.finalize(wordArray);
- */
- finalize: function (messageUpdate) {
- // Final message update
- if (messageUpdate) {
- this._append(messageUpdate);
- }
- // Perform concrete-hasher logic
- var hash = this._doFinalize();
- return hash;
- },
- blockSize: 512/32,
- /**
- * Creates a shortcut function to a hasher's object interface.
- *
- * @param {Hasher} hasher The hasher to create a helper for.
- *
- * @return {Function} The shortcut function.
- *
- * @static
- *
- * @example
- *
- * var SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256);
- */
- _createHelper: function (hasher) {
- return function (message, cfg) {
- return new hasher.init(cfg).finalize(message);
- };
- },
- /**
- * Creates a shortcut function to the HMAC's object interface.
- *
- * @param {Hasher} hasher The hasher to use in this HMAC helper.
- *
- * @return {Function} The shortcut function.
- *
- * @static
- *
- * @example
- *
- * var HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256);
- */
- _createHmacHelper: function (hasher) {
- return function (message, key) {
- return new C_algo.HMAC.init(hasher, key).finalize(message);
- };
- }
- });
- /**
- * Algorithm namespace.
- */
- var C_algo = C.algo = {};
- return C;
- }(Math));
- return CryptoJS;
- }));
- }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
- },{"crypto":undefined}],748:[function(_dereq_,module,exports){
- ;(function (root, factory) {
- if (typeof exports === "object") {
- // CommonJS
- module.exports = exports = factory(_dereq_("./core"));
- }
- else if (typeof define === "function" && define.amd) {
- // AMD
- define(["./core"], factory);
- }
- else {
- // Global (browser)
- factory(root.CryptoJS);
- }
- }(this, function (CryptoJS) {
- (function () {
- // Shortcuts
- var C = CryptoJS;
- var C_lib = C.lib;
- var WordArray = C_lib.WordArray;
- var C_enc = C.enc;
- /**
- * Base64 encoding strategy.
- */
- var Base64 = C_enc.Base64 = {
- /**
- * Converts a word array to a Base64 string.
- *
- * @param {WordArray} wordArray The word array.
- *
- * @return {string} The Base64 string.
- *
- * @static
- *
- * @example
- *
- * var base64String = CryptoJS.enc.Base64.stringify(wordArray);
- */
- stringify: function (wordArray) {
- // Shortcuts
- var words = wordArray.words;
- var sigBytes = wordArray.sigBytes;
- var map = this._map;
- // Clamp excess bits
- wordArray.clamp();
- // Convert
- var base64Chars = [];
- for (var i = 0; i < sigBytes; i += 3) {
- var byte1 = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
- var byte2 = (words[(i + 1) >>> 2] >>> (24 - ((i + 1) % 4) * 8)) & 0xff;
- var byte3 = (words[(i + 2) >>> 2] >>> (24 - ((i + 2) % 4) * 8)) & 0xff;
- var triplet = (byte1 << 16) | (byte2 << 8) | byte3;
- for (var j = 0; (j < 4) && (i + j * 0.75 < sigBytes); j++) {
- base64Chars.push(map.charAt((triplet >>> (6 * (3 - j))) & 0x3f));
- }
- }
- // Add padding
- var paddingChar = map.charAt(64);
- if (paddingChar) {
- while (base64Chars.length % 4) {
- base64Chars.push(paddingChar);
- }
- }
- return base64Chars.join('');
- },
- /**
- * Converts a Base64 string to a word array.
- *
- * @param {string} base64Str The Base64 string.
- *
- * @return {WordArray} The word array.
- *
- * @static
- *
- * @example
- *
- * var wordArray = CryptoJS.enc.Base64.parse(base64String);
- */
- parse: function (base64Str) {
- // Shortcuts
- var base64StrLength = base64Str.length;
- var map = this._map;
- var reverseMap = this._reverseMap;
- if (!reverseMap) {
- reverseMap = this._reverseMap = [];
- for (var j = 0; j < map.length; j++) {
- reverseMap[map.charCodeAt(j)] = j;
- }
- }
- // Ignore padding
- var paddingChar = map.charAt(64);
- if (paddingChar) {
- var paddingIndex = base64Str.indexOf(paddingChar);
- if (paddingIndex !== -1) {
- base64StrLength = paddingIndex;
- }
- }
- // Convert
- return parseLoop(base64Str, base64StrLength, reverseMap);
- },
- _map: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='
- };
- function parseLoop(base64Str, base64StrLength, reverseMap) {
- var words = [];
- var nBytes = 0;
- for (var i = 0; i < base64StrLength; i++) {
- if (i % 4) {
- var bits1 = reverseMap[base64Str.charCodeAt(i - 1)] << ((i % 4) * 2);
- var bits2 = reverseMap[base64Str.charCodeAt(i)] >>> (6 - (i % 4) * 2);
- var bitsCombined = bits1 | bits2;
- words[nBytes >>> 2] |= bitsCombined << (24 - (nBytes % 4) * 8);
- nBytes++;
- }
- }
- return WordArray.create(words, nBytes);
- }
- }());
- return CryptoJS.enc.Base64;
- }));
- },{"./core":747}],749:[function(_dereq_,module,exports){
- ;(function (root, factory) {
- if (typeof exports === "object") {
- // CommonJS
- module.exports = exports = factory(_dereq_("./core"));
- }
- else if (typeof define === "function" && define.amd) {
- // AMD
- define(["./core"], factory);
- }
- else {
- // Global (browser)
- factory(root.CryptoJS);
- }
- }(this, function (CryptoJS) {
- return CryptoJS.enc.Utf8;
- }));
- },{"./core":747}],750:[function(_dereq_,module,exports){
- ;(function (root, factory, undef) {
- if (typeof exports === "object") {
- // CommonJS
- module.exports = exports = factory(_dereq_("./core"), _dereq_("./sha1"), _dereq_("./hmac"));
- }
- else if (typeof define === "function" && define.amd) {
- // AMD
- define(["./core", "./sha1", "./hmac"], factory);
- }
- else {
- // Global (browser)
- factory(root.CryptoJS);
- }
- }(this, function (CryptoJS) {
- (function () {
- // Shortcuts
- var C = CryptoJS;
- var C_lib = C.lib;
- var Base = C_lib.Base;
- var WordArray = C_lib.WordArray;
- var C_algo = C.algo;
- var MD5 = C_algo.MD5;
- /**
- * This key derivation function is meant to conform with EVP_BytesToKey.
- * www.openssl.org/docs/crypto/EVP_BytesToKey.html
- */
- var EvpKDF = C_algo.EvpKDF = Base.extend({
- /**
- * Configuration options.
- *
- * @property {number} keySize The key size in words to generate. Default: 4 (128 bits)
- * @property {Hasher} hasher The hash algorithm to use. Default: MD5
- * @property {number} iterations The number of iterations to perform. Default: 1
- */
- cfg: Base.extend({
- keySize: 128/32,
- hasher: MD5,
- iterations: 1
- }),
- /**
- * Initializes a newly created key derivation function.
- *
- * @param {Object} cfg (Optional) The configuration options to use for the derivation.
- *
- * @example
- *
- * var kdf = CryptoJS.algo.EvpKDF.create();
- * var kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8 });
- * var kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8, iterations: 1000 });
- */
- init: function (cfg) {
- this.cfg = this.cfg.extend(cfg);
- },
- /**
- * Derives a key from a password.
- *
- * @param {WordArray|string} password The password.
- * @param {WordArray|string} salt A salt.
- *
- * @return {WordArray} The derived key.
- *
- * @example
- *
- * var key = kdf.compute(password, salt);
- */
- compute: function (password, salt) {
- var block;
- // Shortcut
- var cfg = this.cfg;
- // Init hasher
- var hasher = cfg.hasher.create();
- // Initial values
- var derivedKey = WordArray.create();
- // Shortcuts
- var derivedKeyWords = derivedKey.words;
- var keySize = cfg.keySize;
- var iterations = cfg.iterations;
- // Generate key
- while (derivedKeyWords.length < keySize) {
- if (block) {
- hasher.update(block);
- }
- block = hasher.update(password).finalize(salt);
- hasher.reset();
- // Iterations
- for (var i = 1; i < iterations; i++) {
- block = hasher.finalize(block);
- hasher.reset();
- }
- derivedKey.concat(block);
- }
- derivedKey.sigBytes = keySize * 4;
- return derivedKey;
- }
- });
- /**
- * Derives a key from a password.
- *
- * @param {WordArray|string} password The password.
- * @param {WordArray|string} salt A salt.
- * @param {Object} cfg (Optional) The configuration options to use for this computation.
- *
- * @return {WordArray} The derived key.
- *
- * @static
- *
- * @example
- *
- * var key = CryptoJS.EvpKDF(password, salt);
- * var key = CryptoJS.EvpKDF(password, salt, { keySize: 8 });
- * var key = CryptoJS.EvpKDF(password, salt, { keySize: 8, iterations: 1000 });
- */
- C.EvpKDF = function (password, salt, cfg) {
- return EvpKDF.create(cfg).compute(password, salt);
- };
- }());
- return CryptoJS.EvpKDF;
- }));
- },{"./core":747,"./hmac":751,"./sha1":753}],751:[function(_dereq_,module,exports){
- ;(function (root, factory) {
- if (typeof exports === "object") {
- // CommonJS
- module.exports = exports = factory(_dereq_("./core"));
- }
- else if (typeof define === "function" && define.amd) {
- // AMD
- define(["./core"], factory);
- }
- else {
- // Global (browser)
- factory(root.CryptoJS);
- }
- }(this, function (CryptoJS) {
- (function () {
- // Shortcuts
- var C = CryptoJS;
- var C_lib = C.lib;
- var Base = C_lib.Base;
- var C_enc = C.enc;
- var Utf8 = C_enc.Utf8;
- var C_algo = C.algo;
- /**
- * HMAC algorithm.
- */
- var HMAC = C_algo.HMAC = Base.extend({
- /**
- * Initializes a newly created HMAC.
- *
- * @param {Hasher} hasher The hash algorithm to use.
- * @param {WordArray|string} key The secret key.
- *
- * @example
- *
- * var hmacHasher = CryptoJS.algo.HMAC.create(CryptoJS.algo.SHA256, key);
- */
- init: function (hasher, key) {
- // Init hasher
- hasher = this._hasher = new hasher.init();
- // Convert string to WordArray, else assume WordArray already
- if (typeof key == 'string') {
- key = Utf8.parse(key);
- }
- // Shortcuts
- var hasherBlockSize = hasher.blockSize;
- var hasherBlockSizeBytes = hasherBlockSize * 4;
- // Allow arbitrary length keys
- if (key.sigBytes > hasherBlockSizeBytes) {
- key = hasher.finalize(key);
- }
- // Clamp excess bits
- key.clamp();
- // Clone key for inner and outer pads
- var oKey = this._oKey = key.clone();
- var iKey = this._iKey = key.clone();
- // Shortcuts
- var oKeyWords = oKey.words;
- var iKeyWords = iKey.words;
- // XOR keys with pad constants
- for (var i = 0; i < hasherBlockSize; i++) {
- oKeyWords[i] ^= 0x5c5c5c5c;
- iKeyWords[i] ^= 0x36363636;
- }
- oKey.sigBytes = iKey.sigBytes = hasherBlockSizeBytes;
- // Set initial values
- this.reset();
- },
- /**
- * Resets this HMAC to its initial state.
- *
- * @example
- *
- * hmacHasher.reset();
- */
- reset: function () {
- // Shortcut
- var hasher = this._hasher;
- // Reset
- hasher.reset();
- hasher.update(this._iKey);
- },
- /**
- * Updates this HMAC with a message.
- *
- * @param {WordArray|string} messageUpdate The message to append.
- *
- * @return {HMAC} This HMAC instance.
- *
- * @example
- *
- * hmacHasher.update('message');
- * hmacHasher.update(wordArray);
- */
- update: function (messageUpdate) {
- this._hasher.update(messageUpdate);
- // Chainable
- return this;
- },
- /**
- * Finalizes the HMAC computation.
- * Note that the finalize operation is effectively a destructive, read-once operation.
- *
- * @param {WordArray|string} messageUpdate (Optional) A final message update.
- *
- * @return {WordArray} The HMAC.
- *
- * @example
- *
- * var hmac = hmacHasher.finalize();
- * var hmac = hmacHasher.finalize('message');
- * var hmac = hmacHasher.finalize(wordArray);
- */
- finalize: function (messageUpdate) {
- // Shortcut
- var hasher = this._hasher;
- // Compute HMAC
- var innerHash = hasher.finalize(messageUpdate);
- hasher.reset();
- var hmac = hasher.finalize(this._oKey.clone().concat(innerHash));
- return hmac;
- }
- });
- }());
- }));
- },{"./core":747}],752:[function(_dereq_,module,exports){
- ;(function (root, factory) {
- if (typeof exports === "object") {
- // CommonJS
- module.exports = exports = factory(_dereq_("./core"));
- }
- else if (typeof define === "function" && define.amd) {
- // AMD
- define(["./core"], factory);
- }
- else {
- // Global (browser)
- factory(root.CryptoJS);
- }
- }(this, function (CryptoJS) {
- (function (Math) {
- // Shortcuts
- var C = CryptoJS;
- var C_lib = C.lib;
- var WordArray = C_lib.WordArray;
- var Hasher = C_lib.Hasher;
- var C_algo = C.algo;
- // Constants table
- var T = [];
- // Compute constants
- (function () {
- for (var i = 0; i < 64; i++) {
- T[i] = (Math.abs(Math.sin(i + 1)) * 0x100000000) | 0;
- }
- }());
- /**
- * MD5 hash algorithm.
- */
- var MD5 = C_algo.MD5 = Hasher.extend({
- _doReset: function () {
- this._hash = new WordArray.init([
- 0x67452301, 0xefcdab89,
- 0x98badcfe, 0x10325476
- ]);
- },
- _doProcessBlock: function (M, offset) {
- // Swap endian
- for (var i = 0; i < 16; i++) {
- // Shortcuts
- var offset_i = offset + i;
- var M_offset_i = M[offset_i];
- M[offset_i] = (
- (((M_offset_i << 8) | (M_offset_i >>> 24)) & 0x00ff00ff) |
- (((M_offset_i << 24) | (M_offset_i >>> 8)) & 0xff00ff00)
- );
- }
- // Shortcuts
- var H = this._hash.words;
- var M_offset_0 = M[offset + 0];
- var M_offset_1 = M[offset + 1];
- var M_offset_2 = M[offset + 2];
- var M_offset_3 = M[offset + 3];
- var M_offset_4 = M[offset + 4];
- var M_offset_5 = M[offset + 5];
- var M_offset_6 = M[offset + 6];
- var M_offset_7 = M[offset + 7];
- var M_offset_8 = M[offset + 8];
- var M_offset_9 = M[offset + 9];
- var M_offset_10 = M[offset + 10];
- var M_offset_11 = M[offset + 11];
- var M_offset_12 = M[offset + 12];
- var M_offset_13 = M[offset + 13];
- var M_offset_14 = M[offset + 14];
- var M_offset_15 = M[offset + 15];
- // Working varialbes
- var a = H[0];
- var b = H[1];
- var c = H[2];
- var d = H[3];
- // Computation
- a = FF(a, b, c, d, M_offset_0, 7, T[0]);
- d = FF(d, a, b, c, M_offset_1, 12, T[1]);
- c = FF(c, d, a, b, M_offset_2, 17, T[2]);
- b = FF(b, c, d, a, M_offset_3, 22, T[3]);
- a = FF(a, b, c, d, M_offset_4, 7, T[4]);
- d = FF(d, a, b, c, M_offset_5, 12, T[5]);
- c = FF(c, d, a, b, M_offset_6, 17, T[6]);
- b = FF(b, c, d, a, M_offset_7, 22, T[7]);
- a = FF(a, b, c, d, M_offset_8, 7, T[8]);
- d = FF(d, a, b, c, M_offset_9, 12, T[9]);
- c = FF(c, d, a, b, M_offset_10, 17, T[10]);
- b = FF(b, c, d, a, M_offset_11, 22, T[11]);
- a = FF(a, b, c, d, M_offset_12, 7, T[12]);
- d = FF(d, a, b, c, M_offset_13, 12, T[13]);
- c = FF(c, d, a, b, M_offset_14, 17, T[14]);
- b = FF(b, c, d, a, M_offset_15, 22, T[15]);
- a = GG(a, b, c, d, M_offset_1, 5, T[16]);
- d = GG(d, a, b, c, M_offset_6, 9, T[17]);
- c = GG(c, d, a, b, M_offset_11, 14, T[18]);
- b = GG(b, c, d, a, M_offset_0, 20, T[19]);
- a = GG(a, b, c, d, M_offset_5, 5, T[20]);
- d = GG(d, a, b, c, M_offset_10, 9, T[21]);
- c = GG(c, d, a, b, M_offset_15, 14, T[22]);
- b = GG(b, c, d, a, M_offset_4, 20, T[23]);
- a = GG(a, b, c, d, M_offset_9, 5, T[24]);
- d = GG(d, a, b, c, M_offset_14, 9, T[25]);
- c = GG(c, d, a, b, M_offset_3, 14, T[26]);
- b = GG(b, c, d, a, M_offset_8, 20, T[27]);
- a = GG(a, b, c, d, M_offset_13, 5, T[28]);
- d = GG(d, a, b, c, M_offset_2, 9, T[29]);
- c = GG(c, d, a, b, M_offset_7, 14, T[30]);
- b = GG(b, c, d, a, M_offset_12, 20, T[31]);
- a = HH(a, b, c, d, M_offset_5, 4, T[32]);
- d = HH(d, a, b, c, M_offset_8, 11, T[33]);
- c = HH(c, d, a, b, M_offset_11, 16, T[34]);
- b = HH(b, c, d, a, M_offset_14, 23, T[35]);
- a = HH(a, b, c, d, M_offset_1, 4, T[36]);
- d = HH(d, a, b, c, M_offset_4, 11, T[37]);
- c = HH(c, d, a, b, M_offset_7, 16, T[38]);
- b = HH(b, c, d, a, M_offset_10, 23, T[39]);
- a = HH(a, b, c, d, M_offset_13, 4, T[40]);
- d = HH(d, a, b, c, M_offset_0, 11, T[41]);
- c = HH(c, d, a, b, M_offset_3, 16, T[42]);
- b = HH(b, c, d, a, M_offset_6, 23, T[43]);
- a = HH(a, b, c, d, M_offset_9, 4, T[44]);
- d = HH(d, a, b, c, M_offset_12, 11, T[45]);
- c = HH(c, d, a, b, M_offset_15, 16, T[46]);
- b = HH(b, c, d, a, M_offset_2, 23, T[47]);
- a = II(a, b, c, d, M_offset_0, 6, T[48]);
- d = II(d, a, b, c, M_offset_7, 10, T[49]);
- c = II(c, d, a, b, M_offset_14, 15, T[50]);
- b = II(b, c, d, a, M_offset_5, 21, T[51]);
- a = II(a, b, c, d, M_offset_12, 6, T[52]);
- d = II(d, a, b, c, M_offset_3, 10, T[53]);
- c = II(c, d, a, b, M_offset_10, 15, T[54]);
- b = II(b, c, d, a, M_offset_1, 21, T[55]);
- a = II(a, b, c, d, M_offset_8, 6, T[56]);
- d = II(d, a, b, c, M_offset_15, 10, T[57]);
- c = II(c, d, a, b, M_offset_6, 15, T[58]);
- b = II(b, c, d, a, M_offset_13, 21, T[59]);
- a = II(a, b, c, d, M_offset_4, 6, T[60]);
- d = II(d, a, b, c, M_offset_11, 10, T[61]);
- c = II(c, d, a, b, M_offset_2, 15, T[62]);
- b = II(b, c, d, a, M_offset_9, 21, T[63]);
- // Intermediate hash value
- H[0] = (H[0] + a) | 0;
- H[1] = (H[1] + b) | 0;
- H[2] = (H[2] + c) | 0;
- H[3] = (H[3] + d) | 0;
- },
- _doFinalize: function () {
- // Shortcuts
- var data = this._data;
- var dataWords = data.words;
- var nBitsTotal = this._nDataBytes * 8;
- var nBitsLeft = data.sigBytes * 8;
- // Add padding
- dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
- var nBitsTotalH = Math.floor(nBitsTotal / 0x100000000);
- var nBitsTotalL = nBitsTotal;
- dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = (
- (((nBitsTotalH << 8) | (nBitsTotalH >>> 24)) & 0x00ff00ff) |
- (((nBitsTotalH << 24) | (nBitsTotalH >>> 8)) & 0xff00ff00)
- );
- dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = (
- (((nBitsTotalL << 8) | (nBitsTotalL >>> 24)) & 0x00ff00ff) |
- (((nBitsTotalL << 24) | (nBitsTotalL >>> 8)) & 0xff00ff00)
- );
- data.sigBytes = (dataWords.length + 1) * 4;
- // Hash final blocks
- this._process();
- // Shortcuts
- var hash = this._hash;
- var H = hash.words;
- // Swap endian
- for (var i = 0; i < 4; i++) {
- // Shortcut
- var H_i = H[i];
- H[i] = (((H_i << 8) | (H_i >>> 24)) & 0x00ff00ff) |
- (((H_i << 24) | (H_i >>> 8)) & 0xff00ff00);
- }
- // Return final computed hash
- return hash;
- },
- clone: function () {
- var clone = Hasher.clone.call(this);
- clone._hash = this._hash.clone();
- return clone;
- }
- });
- function FF(a, b, c, d, x, s, t) {
- var n = a + ((b & c) | (~b & d)) + x + t;
- return ((n << s) | (n >>> (32 - s))) + b;
- }
- function GG(a, b, c, d, x, s, t) {
- var n = a + ((b & d) | (c & ~d)) + x + t;
- return ((n << s) | (n >>> (32 - s))) + b;
- }
- function HH(a, b, c, d, x, s, t) {
- var n = a + (b ^ c ^ d) + x + t;
- return ((n << s) | (n >>> (32 - s))) + b;
- }
- function II(a, b, c, d, x, s, t) {
- var n = a + (c ^ (b | ~d)) + x + t;
- return ((n << s) | (n >>> (32 - s))) + b;
- }
- /**
- * Shortcut function to the hasher's object interface.
- *
- * @param {WordArray|string} message The message to hash.
- *
- * @return {WordArray} The hash.
- *
- * @static
- *
- * @example
- *
- * var hash = CryptoJS.MD5('message');
- * var hash = CryptoJS.MD5(wordArray);
- */
- C.MD5 = Hasher._createHelper(MD5);
- /**
- * Shortcut function to the HMAC's object interface.
- *
- * @param {WordArray|string} message The message to hash.
- * @param {WordArray|string} key The secret key.
- *
- * @return {WordArray} The HMAC.
- *
- * @static
- *
- * @example
- *
- * var hmac = CryptoJS.HmacMD5(message, key);
- */
- C.HmacMD5 = Hasher._createHmacHelper(MD5);
- }(Math));
- return CryptoJS.MD5;
- }));
- },{"./core":747}],753:[function(_dereq_,module,exports){
- ;(function (root, factory) {
- if (typeof exports === "object") {
- // CommonJS
- module.exports = exports = factory(_dereq_("./core"));
- }
- else if (typeof define === "function" && define.amd) {
- // AMD
- define(["./core"], factory);
- }
- else {
- // Global (browser)
- factory(root.CryptoJS);
- }
- }(this, function (CryptoJS) {
- (function () {
- // Shortcuts
- var C = CryptoJS;
- var C_lib = C.lib;
- var WordArray = C_lib.WordArray;
- var Hasher = C_lib.Hasher;
- var C_algo = C.algo;
- // Reusable object
- var W = [];
- /**
- * SHA-1 hash algorithm.
- */
- var SHA1 = C_algo.SHA1 = Hasher.extend({
- _doReset: function () {
- this._hash = new WordArray.init([
- 0x67452301, 0xefcdab89,
- 0x98badcfe, 0x10325476,
- 0xc3d2e1f0
- ]);
- },
- _doProcessBlock: function (M, offset) {
- // Shortcut
- var H = this._hash.words;
- // Working variables
- var a = H[0];
- var b = H[1];
- var c = H[2];
- var d = H[3];
- var e = H[4];
- // Computation
- for (var i = 0; i < 80; i++) {
- if (i < 16) {
- W[i] = M[offset + i] | 0;
- } else {
- var n = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16];
- W[i] = (n << 1) | (n >>> 31);
- }
- var t = ((a << 5) | (a >>> 27)) + e + W[i];
- if (i < 20) {
- t += ((b & c) | (~b & d)) + 0x5a827999;
- } else if (i < 40) {
- t += (b ^ c ^ d) + 0x6ed9eba1;
- } else if (i < 60) {
- t += ((b & c) | (b & d) | (c & d)) - 0x70e44324;
- } else /* if (i < 80) */ {
- t += (b ^ c ^ d) - 0x359d3e2a;
- }
- e = d;
- d = c;
- c = (b << 30) | (b >>> 2);
- b = a;
- a = t;
- }
- // Intermediate hash value
- H[0] = (H[0] + a) | 0;
- H[1] = (H[1] + b) | 0;
- H[2] = (H[2] + c) | 0;
- H[3] = (H[3] + d) | 0;
- H[4] = (H[4] + e) | 0;
- },
- _doFinalize: function () {
- // Shortcuts
- var data = this._data;
- var dataWords = data.words;
- var nBitsTotal = this._nDataBytes * 8;
- var nBitsLeft = data.sigBytes * 8;
- // Add padding
- dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
- dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000);
- dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal;
- data.sigBytes = dataWords.length * 4;
- // Hash final blocks
- this._process();
- // Return final computed hash
- return this._hash;
- },
- clone: function () {
- var clone = Hasher.clone.call(this);
- clone._hash = this._hash.clone();
- return clone;
- }
- });
- /**
- * Shortcut function to the hasher's object interface.
- *
- * @param {WordArray|string} message The message to hash.
- *
- * @return {WordArray} The hash.
- *
- * @static
- *
- * @example
- *
- * var hash = CryptoJS.SHA1('message');
- * var hash = CryptoJS.SHA1(wordArray);
- */
- C.SHA1 = Hasher._createHelper(SHA1);
- /**
- * Shortcut function to the HMAC's object interface.
- *
- * @param {WordArray|string} message The message to hash.
- * @param {WordArray|string} key The secret key.
- *
- * @return {WordArray} The HMAC.
- *
- * @static
- *
- * @example
- *
- * var hmac = CryptoJS.HmacSHA1(message, key);
- */
- C.HmacSHA1 = Hasher._createHmacHelper(SHA1);
- }());
- return CryptoJS.SHA1;
- }));
- },{"./core":747}],754:[function(_dereq_,module,exports){
- 'use strict';
- var elliptic = exports;
- elliptic.version = _dereq_('../package.json').version;
- elliptic.utils = _dereq_('./elliptic/utils');
- elliptic.rand = _dereq_('brorand');
- elliptic.curve = _dereq_('./elliptic/curve');
- elliptic.curves = _dereq_('./elliptic/curves');
- // Protocols
- elliptic.ec = _dereq_('./elliptic/ec');
- elliptic.eddsa = _dereq_('./elliptic/eddsa');
- },{"../package.json":770,"./elliptic/curve":757,"./elliptic/curves":760,"./elliptic/ec":761,"./elliptic/eddsa":764,"./elliptic/utils":768,"brorand":322}],755:[function(_dereq_,module,exports){
- 'use strict';
- var BN = _dereq_('bn.js');
- var utils = _dereq_('../utils');
- var getNAF = utils.getNAF;
- var getJSF = utils.getJSF;
- var assert = utils.assert;
- function BaseCurve(type, conf) {
- this.type = type;
- this.p = new BN(conf.p, 16);
- // Use Montgomery, when there is no fast reduction for the prime
- this.red = conf.prime ? BN.red(conf.prime) : BN.mont(this.p);
- // Useful for many curves
- this.zero = new BN(0).toRed(this.red);
- this.one = new BN(1).toRed(this.red);
- this.two = new BN(2).toRed(this.red);
- // Curve configuration, optional
- this.n = conf.n && new BN(conf.n, 16);
- this.g = conf.g && this.pointFromJSON(conf.g, conf.gRed);
- // Temporary arrays
- this._wnafT1 = new Array(4);
- this._wnafT2 = new Array(4);
- this._wnafT3 = new Array(4);
- this._wnafT4 = new Array(4);
- this._bitLength = this.n ? this.n.bitLength() : 0;
- // Generalized Greg Maxwell's trick
- var adjustCount = this.n && this.p.div(this.n);
- if (!adjustCount || adjustCount.cmpn(100) > 0) {
- this.redN = null;
- } else {
- this._maxwellTrick = true;
- this.redN = this.n.toRed(this.red);
- }
- }
- module.exports = BaseCurve;
- BaseCurve.prototype.point = function point() {
- throw new Error('Not implemented');
- };
- BaseCurve.prototype.validate = function validate() {
- throw new Error('Not implemented');
- };
- BaseCurve.prototype._fixedNafMul = function _fixedNafMul(p, k) {
- assert(p.precomputed);
- var doubles = p._getDoubles();
- var naf = getNAF(k, 1, this._bitLength);
- var I = (1 << (doubles.step + 1)) - (doubles.step % 2 === 0 ? 2 : 1);
- I /= 3;
- // Translate into more windowed form
- var repr = [];
- var j;
- var nafW;
- for (j = 0; j < naf.length; j += doubles.step) {
- nafW = 0;
- for (var l = j + doubles.step - 1; l >= j; l--)
- nafW = (nafW << 1) + naf[l];
- repr.push(nafW);
- }
- var a = this.jpoint(null, null, null);
- var b = this.jpoint(null, null, null);
- for (var i = I; i > 0; i--) {
- for (j = 0; j < repr.length; j++) {
- nafW = repr[j];
- if (nafW === i)
- b = b.mixedAdd(doubles.points[j]);
- else if (nafW === -i)
- b = b.mixedAdd(doubles.points[j].neg());
- }
- a = a.add(b);
- }
- return a.toP();
- };
- BaseCurve.prototype._wnafMul = function _wnafMul(p, k) {
- var w = 4;
- // Precompute window
- var nafPoints = p._getNAFPoints(w);
- w = nafPoints.wnd;
- var wnd = nafPoints.points;
- // Get NAF form
- var naf = getNAF(k, w, this._bitLength);
- // Add `this`*(N+1) for every w-NAF index
- var acc = this.jpoint(null, null, null);
- for (var i = naf.length - 1; i >= 0; i--) {
- // Count zeroes
- for (var l = 0; i >= 0 && naf[i] === 0; i--)
- l++;
- if (i >= 0)
- l++;
- acc = acc.dblp(l);
- if (i < 0)
- break;
- var z = naf[i];
- assert(z !== 0);
- if (p.type === 'affine') {
- // J +- P
- if (z > 0)
- acc = acc.mixedAdd(wnd[(z - 1) >> 1]);
- else
- acc = acc.mixedAdd(wnd[(-z - 1) >> 1].neg());
- } else {
- // J +- J
- if (z > 0)
- acc = acc.add(wnd[(z - 1) >> 1]);
- else
- acc = acc.add(wnd[(-z - 1) >> 1].neg());
- }
- }
- return p.type === 'affine' ? acc.toP() : acc;
- };
- BaseCurve.prototype._wnafMulAdd = function _wnafMulAdd(defW,
- points,
- coeffs,
- len,
- jacobianResult) {
- var wndWidth = this._wnafT1;
- var wnd = this._wnafT2;
- var naf = this._wnafT3;
- // Fill all arrays
- var max = 0;
- var i;
- var j;
- var p;
- for (i = 0; i < len; i++) {
- p = points[i];
- var nafPoints = p._getNAFPoints(defW);
- wndWidth[i] = nafPoints.wnd;
- wnd[i] = nafPoints.points;
- }
- // Comb small window NAFs
- for (i = len - 1; i >= 1; i -= 2) {
- var a = i - 1;
- var b = i;
- if (wndWidth[a] !== 1 || wndWidth[b] !== 1) {
- naf[a] = getNAF(coeffs[a], wndWidth[a], this._bitLength);
- naf[b] = getNAF(coeffs[b], wndWidth[b], this._bitLength);
- max = Math.max(naf[a].length, max);
- max = Math.max(naf[b].length, max);
- continue;
- }
- var comb = [
- points[a], /* 1 */
- null, /* 3 */
- null, /* 5 */
- points[b], /* 7 */
- ];
- // Try to avoid Projective points, if possible
- if (points[a].y.cmp(points[b].y) === 0) {
- comb[1] = points[a].add(points[b]);
- comb[2] = points[a].toJ().mixedAdd(points[b].neg());
- } else if (points[a].y.cmp(points[b].y.redNeg()) === 0) {
- comb[1] = points[a].toJ().mixedAdd(points[b]);
- comb[2] = points[a].add(points[b].neg());
- } else {
- comb[1] = points[a].toJ().mixedAdd(points[b]);
- comb[2] = points[a].toJ().mixedAdd(points[b].neg());
- }
- var index = [
- -3, /* -1 -1 */
- -1, /* -1 0 */
- -5, /* -1 1 */
- -7, /* 0 -1 */
- 0, /* 0 0 */
- 7, /* 0 1 */
- 5, /* 1 -1 */
- 1, /* 1 0 */
- 3, /* 1 1 */
- ];
- var jsf = getJSF(coeffs[a], coeffs[b]);
- max = Math.max(jsf[0].length, max);
- naf[a] = new Array(max);
- naf[b] = new Array(max);
- for (j = 0; j < max; j++) {
- var ja = jsf[0][j] | 0;
- var jb = jsf[1][j] | 0;
- naf[a][j] = index[(ja + 1) * 3 + (jb + 1)];
- naf[b][j] = 0;
- wnd[a] = comb;
- }
- }
- var acc = this.jpoint(null, null, null);
- var tmp = this._wnafT4;
- for (i = max; i >= 0; i--) {
- var k = 0;
- while (i >= 0) {
- var zero = true;
- for (j = 0; j < len; j++) {
- tmp[j] = naf[j][i] | 0;
- if (tmp[j] !== 0)
- zero = false;
- }
- if (!zero)
- break;
- k++;
- i--;
- }
- if (i >= 0)
- k++;
- acc = acc.dblp(k);
- if (i < 0)
- break;
- for (j = 0; j < len; j++) {
- var z = tmp[j];
- p;
- if (z === 0)
- continue;
- else if (z > 0)
- p = wnd[j][(z - 1) >> 1];
- else if (z < 0)
- p = wnd[j][(-z - 1) >> 1].neg();
- if (p.type === 'affine')
- acc = acc.mixedAdd(p);
- else
- acc = acc.add(p);
- }
- }
- // Zeroify references
- for (i = 0; i < len; i++)
- wnd[i] = null;
- if (jacobianResult)
- return acc;
- else
- return acc.toP();
- };
- function BasePoint(curve, type) {
- this.curve = curve;
- this.type = type;
- this.precomputed = null;
- }
- BaseCurve.BasePoint = BasePoint;
- BasePoint.prototype.eq = function eq(/*other*/) {
- throw new Error('Not implemented');
- };
- BasePoint.prototype.validate = function validate() {
- return this.curve.validate(this);
- };
- BaseCurve.prototype.decodePoint = function decodePoint(bytes, enc) {
- bytes = utils.toArray(bytes, enc);
- var len = this.p.byteLength();
- // uncompressed, hybrid-odd, hybrid-even
- if ((bytes[0] === 0x04 || bytes[0] === 0x06 || bytes[0] === 0x07) &&
- bytes.length - 1 === 2 * len) {
- if (bytes[0] === 0x06)
- assert(bytes[bytes.length - 1] % 2 === 0);
- else if (bytes[0] === 0x07)
- assert(bytes[bytes.length - 1] % 2 === 1);
- var res = this.point(bytes.slice(1, 1 + len),
- bytes.slice(1 + len, 1 + 2 * len));
- return res;
- } else if ((bytes[0] === 0x02 || bytes[0] === 0x03) &&
- bytes.length - 1 === len) {
- return this.pointFromX(bytes.slice(1, 1 + len), bytes[0] === 0x03);
- }
- throw new Error('Unknown point format');
- };
- BasePoint.prototype.encodeCompressed = function encodeCompressed(enc) {
- return this.encode(enc, true);
- };
- BasePoint.prototype._encode = function _encode(compact) {
- var len = this.curve.p.byteLength();
- var x = this.getX().toArray('be', len);
- if (compact)
- return [ this.getY().isEven() ? 0x02 : 0x03 ].concat(x);
- return [ 0x04 ].concat(x, this.getY().toArray('be', len));
- };
- BasePoint.prototype.encode = function encode(enc, compact) {
- return utils.encode(this._encode(compact), enc);
- };
- BasePoint.prototype.precompute = function precompute(power) {
- if (this.precomputed)
- return this;
- var precomputed = {
- doubles: null,
- naf: null,
- beta: null,
- };
- precomputed.naf = this._getNAFPoints(8);
- precomputed.doubles = this._getDoubles(4, power);
- precomputed.beta = this._getBeta();
- this.precomputed = precomputed;
- return this;
- };
- BasePoint.prototype._hasDoubles = function _hasDoubles(k) {
- if (!this.precomputed)
- return false;
- var doubles = this.precomputed.doubles;
- if (!doubles)
- return false;
- return doubles.points.length >= Math.ceil((k.bitLength() + 1) / doubles.step);
- };
- BasePoint.prototype._getDoubles = function _getDoubles(step, power) {
- if (this.precomputed && this.precomputed.doubles)
- return this.precomputed.doubles;
- var doubles = [ this ];
- var acc = this;
- for (var i = 0; i < power; i += step) {
- for (var j = 0; j < step; j++)
- acc = acc.dbl();
- doubles.push(acc);
- }
- return {
- step: step,
- points: doubles,
- };
- };
- BasePoint.prototype._getNAFPoints = function _getNAFPoints(wnd) {
- if (this.precomputed && this.precomputed.naf)
- return this.precomputed.naf;
- var res = [ this ];
- var max = (1 << wnd) - 1;
- var dbl = max === 1 ? null : this.dbl();
- for (var i = 1; i < max; i++)
- res[i] = res[i - 1].add(dbl);
- return {
- wnd: wnd,
- points: res,
- };
- };
- BasePoint.prototype._getBeta = function _getBeta() {
- return null;
- };
- BasePoint.prototype.dblp = function dblp(k) {
- var r = this;
- for (var i = 0; i < k; i++)
- r = r.dbl();
- return r;
- };
- },{"../utils":768,"bn.js":769}],756:[function(_dereq_,module,exports){
- 'use strict';
- var utils = _dereq_('../utils');
- var BN = _dereq_('bn.js');
- var inherits = _dereq_('inherits');
- var Base = _dereq_('./base');
- var assert = utils.assert;
- function EdwardsCurve(conf) {
- // NOTE: Important as we are creating point in Base.call()
- this.twisted = (conf.a | 0) !== 1;
- this.mOneA = this.twisted && (conf.a | 0) === -1;
- this.extended = this.mOneA;
- Base.call(this, 'edwards', conf);
- this.a = new BN(conf.a, 16).umod(this.red.m);
- this.a = this.a.toRed(this.red);
- this.c = new BN(conf.c, 16).toRed(this.red);
- this.c2 = this.c.redSqr();
- this.d = new BN(conf.d, 16).toRed(this.red);
- this.dd = this.d.redAdd(this.d);
- assert(!this.twisted || this.c.fromRed().cmpn(1) === 0);
- this.oneC = (conf.c | 0) === 1;
- }
- inherits(EdwardsCurve, Base);
- module.exports = EdwardsCurve;
- EdwardsCurve.prototype._mulA = function _mulA(num) {
- if (this.mOneA)
- return num.redNeg();
- else
- return this.a.redMul(num);
- };
- EdwardsCurve.prototype._mulC = function _mulC(num) {
- if (this.oneC)
- return num;
- else
- return this.c.redMul(num);
- };
- // Just for compatibility with Short curve
- EdwardsCurve.prototype.jpoint = function jpoint(x, y, z, t) {
- return this.point(x, y, z, t);
- };
- EdwardsCurve.prototype.pointFromX = function pointFromX(x, odd) {
- x = new BN(x, 16);
- if (!x.red)
- x = x.toRed(this.red);
- var x2 = x.redSqr();
- var rhs = this.c2.redSub(this.a.redMul(x2));
- var lhs = this.one.redSub(this.c2.redMul(this.d).redMul(x2));
- var y2 = rhs.redMul(lhs.redInvm());
- var y = y2.redSqrt();
- if (y.redSqr().redSub(y2).cmp(this.zero) !== 0)
- throw new Error('invalid point');
- var isOdd = y.fromRed().isOdd();
- if (odd && !isOdd || !odd && isOdd)
- y = y.redNeg();
- return this.point(x, y);
- };
- EdwardsCurve.prototype.pointFromY = function pointFromY(y, odd) {
- y = new BN(y, 16);
- if (!y.red)
- y = y.toRed(this.red);
- // x^2 = (y^2 - c^2) / (c^2 d y^2 - a)
- var y2 = y.redSqr();
- var lhs = y2.redSub(this.c2);
- var rhs = y2.redMul(this.d).redMul(this.c2).redSub(this.a);
- var x2 = lhs.redMul(rhs.redInvm());
- if (x2.cmp(this.zero) === 0) {
- if (odd)
- throw new Error('invalid point');
- else
- return this.point(this.zero, y);
- }
- var x = x2.redSqrt();
- if (x.redSqr().redSub(x2).cmp(this.zero) !== 0)
- throw new Error('invalid point');
- if (x.fromRed().isOdd() !== odd)
- x = x.redNeg();
- return this.point(x, y);
- };
- EdwardsCurve.prototype.validate = function validate(point) {
- if (point.isInfinity())
- return true;
- // Curve: A * X^2 + Y^2 = C^2 * (1 + D * X^2 * Y^2)
- point.normalize();
- var x2 = point.x.redSqr();
- var y2 = point.y.redSqr();
- var lhs = x2.redMul(this.a).redAdd(y2);
- var rhs = this.c2.redMul(this.one.redAdd(this.d.redMul(x2).redMul(y2)));
- return lhs.cmp(rhs) === 0;
- };
- function Point(curve, x, y, z, t) {
- Base.BasePoint.call(this, curve, 'projective');
- if (x === null && y === null && z === null) {
- this.x = this.curve.zero;
- this.y = this.curve.one;
- this.z = this.curve.one;
- this.t = this.curve.zero;
- this.zOne = true;
- } else {
- this.x = new BN(x, 16);
- this.y = new BN(y, 16);
- this.z = z ? new BN(z, 16) : this.curve.one;
- this.t = t && new BN(t, 16);
- if (!this.x.red)
- this.x = this.x.toRed(this.curve.red);
- if (!this.y.red)
- this.y = this.y.toRed(this.curve.red);
- if (!this.z.red)
- this.z = this.z.toRed(this.curve.red);
- if (this.t && !this.t.red)
- this.t = this.t.toRed(this.curve.red);
- this.zOne = this.z === this.curve.one;
- // Use extended coordinates
- if (this.curve.extended && !this.t) {
- this.t = this.x.redMul(this.y);
- if (!this.zOne)
- this.t = this.t.redMul(this.z.redInvm());
- }
- }
- }
- inherits(Point, Base.BasePoint);
- EdwardsCurve.prototype.pointFromJSON = function pointFromJSON(obj) {
- return Point.fromJSON(this, obj);
- };
- EdwardsCurve.prototype.point = function point(x, y, z, t) {
- return new Point(this, x, y, z, t);
- };
- Point.fromJSON = function fromJSON(curve, obj) {
- return new Point(curve, obj[0], obj[1], obj[2]);
- };
- Point.prototype.inspect = function inspect() {
- if (this.isInfinity())
- return '<EC Point Infinity>';
- return '<EC Point x: ' + this.x.fromRed().toString(16, 2) +
- ' y: ' + this.y.fromRed().toString(16, 2) +
- ' z: ' + this.z.fromRed().toString(16, 2) + '>';
- };
- Point.prototype.isInfinity = function isInfinity() {
- // XXX This code assumes that zero is always zero in red
- return this.x.cmpn(0) === 0 &&
- (this.y.cmp(this.z) === 0 ||
- (this.zOne && this.y.cmp(this.curve.c) === 0));
- };
- Point.prototype._extDbl = function _extDbl() {
- // hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html
- // #doubling-dbl-2008-hwcd
- // 4M + 4S
- // A = X1^2
- var a = this.x.redSqr();
- // B = Y1^2
- var b = this.y.redSqr();
- // C = 2 * Z1^2
- var c = this.z.redSqr();
- c = c.redIAdd(c);
- // D = a * A
- var d = this.curve._mulA(a);
- // E = (X1 + Y1)^2 - A - B
- var e = this.x.redAdd(this.y).redSqr().redISub(a).redISub(b);
- // G = D + B
- var g = d.redAdd(b);
- // F = G - C
- var f = g.redSub(c);
- // H = D - B
- var h = d.redSub(b);
- // X3 = E * F
- var nx = e.redMul(f);
- // Y3 = G * H
- var ny = g.redMul(h);
- // T3 = E * H
- var nt = e.redMul(h);
- // Z3 = F * G
- var nz = f.redMul(g);
- return this.curve.point(nx, ny, nz, nt);
- };
- Point.prototype._projDbl = function _projDbl() {
- // hyperelliptic.org/EFD/g1p/auto-twisted-projective.html
- // #doubling-dbl-2008-bbjlp
- // #doubling-dbl-2007-bl
- // and others
- // Generally 3M + 4S or 2M + 4S
- // B = (X1 + Y1)^2
- var b = this.x.redAdd(this.y).redSqr();
- // C = X1^2
- var c = this.x.redSqr();
- // D = Y1^2
- var d = this.y.redSqr();
- var nx;
- var ny;
- var nz;
- var e;
- var h;
- var j;
- if (this.curve.twisted) {
- // E = a * C
- e = this.curve._mulA(c);
- // F = E + D
- var f = e.redAdd(d);
- if (this.zOne) {
- // X3 = (B - C - D) * (F - 2)
- nx = b.redSub(c).redSub(d).redMul(f.redSub(this.curve.two));
- // Y3 = F * (E - D)
- ny = f.redMul(e.redSub(d));
- // Z3 = F^2 - 2 * F
- nz = f.redSqr().redSub(f).redSub(f);
- } else {
- // H = Z1^2
- h = this.z.redSqr();
- // J = F - 2 * H
- j = f.redSub(h).redISub(h);
- // X3 = (B-C-D)*J
- nx = b.redSub(c).redISub(d).redMul(j);
- // Y3 = F * (E - D)
- ny = f.redMul(e.redSub(d));
- // Z3 = F * J
- nz = f.redMul(j);
- }
- } else {
- // E = C + D
- e = c.redAdd(d);
- // H = (c * Z1)^2
- h = this.curve._mulC(this.z).redSqr();
- // J = E - 2 * H
- j = e.redSub(h).redSub(h);
- // X3 = c * (B - E) * J
- nx = this.curve._mulC(b.redISub(e)).redMul(j);
- // Y3 = c * E * (C - D)
- ny = this.curve._mulC(e).redMul(c.redISub(d));
- // Z3 = E * J
- nz = e.redMul(j);
- }
- return this.curve.point(nx, ny, nz);
- };
- Point.prototype.dbl = function dbl() {
- if (this.isInfinity())
- return this;
- // Double in extended coordinates
- if (this.curve.extended)
- return this._extDbl();
- else
- return this._projDbl();
- };
- Point.prototype._extAdd = function _extAdd(p) {
- // hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html
- // #addition-add-2008-hwcd-3
- // 8M
- // A = (Y1 - X1) * (Y2 - X2)
- var a = this.y.redSub(this.x).redMul(p.y.redSub(p.x));
- // B = (Y1 + X1) * (Y2 + X2)
- var b = this.y.redAdd(this.x).redMul(p.y.redAdd(p.x));
- // C = T1 * k * T2
- var c = this.t.redMul(this.curve.dd).redMul(p.t);
- // D = Z1 * 2 * Z2
- var d = this.z.redMul(p.z.redAdd(p.z));
- // E = B - A
- var e = b.redSub(a);
- // F = D - C
- var f = d.redSub(c);
- // G = D + C
- var g = d.redAdd(c);
- // H = B + A
- var h = b.redAdd(a);
- // X3 = E * F
- var nx = e.redMul(f);
- // Y3 = G * H
- var ny = g.redMul(h);
- // T3 = E * H
- var nt = e.redMul(h);
- // Z3 = F * G
- var nz = f.redMul(g);
- return this.curve.point(nx, ny, nz, nt);
- };
- Point.prototype._projAdd = function _projAdd(p) {
- // hyperelliptic.org/EFD/g1p/auto-twisted-projective.html
- // #addition-add-2008-bbjlp
- // #addition-add-2007-bl
- // 10M + 1S
- // A = Z1 * Z2
- var a = this.z.redMul(p.z);
- // B = A^2
- var b = a.redSqr();
- // C = X1 * X2
- var c = this.x.redMul(p.x);
- // D = Y1 * Y2
- var d = this.y.redMul(p.y);
- // E = d * C * D
- var e = this.curve.d.redMul(c).redMul(d);
- // F = B - E
- var f = b.redSub(e);
- // G = B + E
- var g = b.redAdd(e);
- // X3 = A * F * ((X1 + Y1) * (X2 + Y2) - C - D)
- var tmp = this.x.redAdd(this.y).redMul(p.x.redAdd(p.y)).redISub(c).redISub(d);
- var nx = a.redMul(f).redMul(tmp);
- var ny;
- var nz;
- if (this.curve.twisted) {
- // Y3 = A * G * (D - a * C)
- ny = a.redMul(g).redMul(d.redSub(this.curve._mulA(c)));
- // Z3 = F * G
- nz = f.redMul(g);
- } else {
- // Y3 = A * G * (D - C)
- ny = a.redMul(g).redMul(d.redSub(c));
- // Z3 = c * F * G
- nz = this.curve._mulC(f).redMul(g);
- }
- return this.curve.point(nx, ny, nz);
- };
- Point.prototype.add = function add(p) {
- if (this.isInfinity())
- return p;
- if (p.isInfinity())
- return this;
- if (this.curve.extended)
- return this._extAdd(p);
- else
- return this._projAdd(p);
- };
- Point.prototype.mul = function mul(k) {
- if (this._hasDoubles(k))
- return this.curve._fixedNafMul(this, k);
- else
- return this.curve._wnafMul(this, k);
- };
- Point.prototype.mulAdd = function mulAdd(k1, p, k2) {
- return this.curve._wnafMulAdd(1, [ this, p ], [ k1, k2 ], 2, false);
- };
- Point.prototype.jmulAdd = function jmulAdd(k1, p, k2) {
- return this.curve._wnafMulAdd(1, [ this, p ], [ k1, k2 ], 2, true);
- };
- Point.prototype.normalize = function normalize() {
- if (this.zOne)
- return this;
- // Normalize coordinates
- var zi = this.z.redInvm();
- this.x = this.x.redMul(zi);
- this.y = this.y.redMul(zi);
- if (this.t)
- this.t = this.t.redMul(zi);
- this.z = this.curve.one;
- this.zOne = true;
- return this;
- };
- Point.prototype.neg = function neg() {
- return this.curve.point(this.x.redNeg(),
- this.y,
- this.z,
- this.t && this.t.redNeg());
- };
- Point.prototype.getX = function getX() {
- this.normalize();
- return this.x.fromRed();
- };
- Point.prototype.getY = function getY() {
- this.normalize();
- return this.y.fromRed();
- };
- Point.prototype.eq = function eq(other) {
- return this === other ||
- this.getX().cmp(other.getX()) === 0 &&
- this.getY().cmp(other.getY()) === 0;
- };
- Point.prototype.eqXToP = function eqXToP(x) {
- var rx = x.toRed(this.curve.red).redMul(this.z);
- if (this.x.cmp(rx) === 0)
- return true;
- var xc = x.clone();
- var t = this.curve.redN.redMul(this.z);
- for (;;) {
- xc.iadd(this.curve.n);
- if (xc.cmp(this.curve.p) >= 0)
- return false;
- rx.redIAdd(t);
- if (this.x.cmp(rx) === 0)
- return true;
- }
- };
- // Compatibility with BaseCurve
- Point.prototype.toP = Point.prototype.normalize;
- Point.prototype.mixedAdd = Point.prototype.add;
- },{"../utils":768,"./base":755,"bn.js":769,"inherits":789}],757:[function(_dereq_,module,exports){
- 'use strict';
- var curve = exports;
- curve.base = _dereq_('./base');
- curve.short = _dereq_('./short');
- curve.mont = _dereq_('./mont');
- curve.edwards = _dereq_('./edwards');
- },{"./base":755,"./edwards":756,"./mont":758,"./short":759}],758:[function(_dereq_,module,exports){
- 'use strict';
- var BN = _dereq_('bn.js');
- var inherits = _dereq_('inherits');
- var Base = _dereq_('./base');
- var utils = _dereq_('../utils');
- function MontCurve(conf) {
- Base.call(this, 'mont', conf);
- this.a = new BN(conf.a, 16).toRed(this.red);
- this.b = new BN(conf.b, 16).toRed(this.red);
- this.i4 = new BN(4).toRed(this.red).redInvm();
- this.two = new BN(2).toRed(this.red);
- this.a24 = this.i4.redMul(this.a.redAdd(this.two));
- }
- inherits(MontCurve, Base);
- module.exports = MontCurve;
- MontCurve.prototype.validate = function validate(point) {
- var x = point.normalize().x;
- var x2 = x.redSqr();
- var rhs = x2.redMul(x).redAdd(x2.redMul(this.a)).redAdd(x);
- var y = rhs.redSqrt();
- return y.redSqr().cmp(rhs) === 0;
- };
- function Point(curve, x, z) {
- Base.BasePoint.call(this, curve, 'projective');
- if (x === null && z === null) {
- this.x = this.curve.one;
- this.z = this.curve.zero;
- } else {
- this.x = new BN(x, 16);
- this.z = new BN(z, 16);
- if (!this.x.red)
- this.x = this.x.toRed(this.curve.red);
- if (!this.z.red)
- this.z = this.z.toRed(this.curve.red);
- }
- }
- inherits(Point, Base.BasePoint);
- MontCurve.prototype.decodePoint = function decodePoint(bytes, enc) {
- return this.point(utils.toArray(bytes, enc), 1);
- };
- MontCurve.prototype.point = function point(x, z) {
- return new Point(this, x, z);
- };
- MontCurve.prototype.pointFromJSON = function pointFromJSON(obj) {
- return Point.fromJSON(this, obj);
- };
- Point.prototype.precompute = function precompute() {
- // No-op
- };
- Point.prototype._encode = function _encode() {
- return this.getX().toArray('be', this.curve.p.byteLength());
- };
- Point.fromJSON = function fromJSON(curve, obj) {
- return new Point(curve, obj[0], obj[1] || curve.one);
- };
- Point.prototype.inspect = function inspect() {
- if (this.isInfinity())
- return '<EC Point Infinity>';
- return '<EC Point x: ' + this.x.fromRed().toString(16, 2) +
- ' z: ' + this.z.fromRed().toString(16, 2) + '>';
- };
- Point.prototype.isInfinity = function isInfinity() {
- // XXX This code assumes that zero is always zero in red
- return this.z.cmpn(0) === 0;
- };
- Point.prototype.dbl = function dbl() {
- // http://hyperelliptic.org/EFD/g1p/auto-montgom-xz.html#doubling-dbl-1987-m-3
- // 2M + 2S + 4A
- // A = X1 + Z1
- var a = this.x.redAdd(this.z);
- // AA = A^2
- var aa = a.redSqr();
- // B = X1 - Z1
- var b = this.x.redSub(this.z);
- // BB = B^2
- var bb = b.redSqr();
- // C = AA - BB
- var c = aa.redSub(bb);
- // X3 = AA * BB
- var nx = aa.redMul(bb);
- // Z3 = C * (BB + A24 * C)
- var nz = c.redMul(bb.redAdd(this.curve.a24.redMul(c)));
- return this.curve.point(nx, nz);
- };
- Point.prototype.add = function add() {
- throw new Error('Not supported on Montgomery curve');
- };
- Point.prototype.diffAdd = function diffAdd(p, diff) {
- // http://hyperelliptic.org/EFD/g1p/auto-montgom-xz.html#diffadd-dadd-1987-m-3
- // 4M + 2S + 6A
- // A = X2 + Z2
- var a = this.x.redAdd(this.z);
- // B = X2 - Z2
- var b = this.x.redSub(this.z);
- // C = X3 + Z3
- var c = p.x.redAdd(p.z);
- // D = X3 - Z3
- var d = p.x.redSub(p.z);
- // DA = D * A
- var da = d.redMul(a);
- // CB = C * B
- var cb = c.redMul(b);
- // X5 = Z1 * (DA + CB)^2
- var nx = diff.z.redMul(da.redAdd(cb).redSqr());
- // Z5 = X1 * (DA - CB)^2
- var nz = diff.x.redMul(da.redISub(cb).redSqr());
- return this.curve.point(nx, nz);
- };
- Point.prototype.mul = function mul(k) {
- var t = k.clone();
- var a = this; // (N / 2) * Q + Q
- var b = this.curve.point(null, null); // (N / 2) * Q
- var c = this; // Q
- for (var bits = []; t.cmpn(0) !== 0; t.iushrn(1))
- bits.push(t.andln(1));
- for (var i = bits.length - 1; i >= 0; i--) {
- if (bits[i] === 0) {
- // N * Q + Q = ((N / 2) * Q + Q)) + (N / 2) * Q
- a = a.diffAdd(b, c);
- // N * Q = 2 * ((N / 2) * Q + Q))
- b = b.dbl();
- } else {
- // N * Q = ((N / 2) * Q + Q) + ((N / 2) * Q)
- b = a.diffAdd(b, c);
- // N * Q + Q = 2 * ((N / 2) * Q + Q)
- a = a.dbl();
- }
- }
- return b;
- };
- Point.prototype.mulAdd = function mulAdd() {
- throw new Error('Not supported on Montgomery curve');
- };
- Point.prototype.jumlAdd = function jumlAdd() {
- throw new Error('Not supported on Montgomery curve');
- };
- Point.prototype.eq = function eq(other) {
- return this.getX().cmp(other.getX()) === 0;
- };
- Point.prototype.normalize = function normalize() {
- this.x = this.x.redMul(this.z.redInvm());
- this.z = this.curve.one;
- return this;
- };
- Point.prototype.getX = function getX() {
- // Normalize coordinates
- this.normalize();
- return this.x.fromRed();
- };
- },{"../utils":768,"./base":755,"bn.js":769,"inherits":789}],759:[function(_dereq_,module,exports){
- 'use strict';
- var utils = _dereq_('../utils');
- var BN = _dereq_('bn.js');
- var inherits = _dereq_('inherits');
- var Base = _dereq_('./base');
- var assert = utils.assert;
- function ShortCurve(conf) {
- Base.call(this, 'short', conf);
- this.a = new BN(conf.a, 16).toRed(this.red);
- this.b = new BN(conf.b, 16).toRed(this.red);
- this.tinv = this.two.redInvm();
- this.zeroA = this.a.fromRed().cmpn(0) === 0;
- this.threeA = this.a.fromRed().sub(this.p).cmpn(-3) === 0;
- // If the curve is endomorphic, precalculate beta and lambda
- this.endo = this._getEndomorphism(conf);
- this._endoWnafT1 = new Array(4);
- this._endoWnafT2 = new Array(4);
- }
- inherits(ShortCurve, Base);
- module.exports = ShortCurve;
- ShortCurve.prototype._getEndomorphism = function _getEndomorphism(conf) {
- // No efficient endomorphism
- if (!this.zeroA || !this.g || !this.n || this.p.modn(3) !== 1)
- return;
- // Compute beta and lambda, that lambda * P = (beta * Px; Py)
- var beta;
- var lambda;
- if (conf.beta) {
- beta = new BN(conf.beta, 16).toRed(this.red);
- } else {
- var betas = this._getEndoRoots(this.p);
- // Choose the smallest beta
- beta = betas[0].cmp(betas[1]) < 0 ? betas[0] : betas[1];
- beta = beta.toRed(this.red);
- }
- if (conf.lambda) {
- lambda = new BN(conf.lambda, 16);
- } else {
- // Choose the lambda that is matching selected beta
- var lambdas = this._getEndoRoots(this.n);
- if (this.g.mul(lambdas[0]).x.cmp(this.g.x.redMul(beta)) === 0) {
- lambda = lambdas[0];
- } else {
- lambda = lambdas[1];
- assert(this.g.mul(lambda).x.cmp(this.g.x.redMul(beta)) === 0);
- }
- }
- // Get basis vectors, used for balanced length-two representation
- var basis;
- if (conf.basis) {
- basis = conf.basis.map(function(vec) {
- return {
- a: new BN(vec.a, 16),
- b: new BN(vec.b, 16),
- };
- });
- } else {
- basis = this._getEndoBasis(lambda);
- }
- return {
- beta: beta,
- lambda: lambda,
- basis: basis,
- };
- };
- ShortCurve.prototype._getEndoRoots = function _getEndoRoots(num) {
- // Find roots of for x^2 + x + 1 in F
- // Root = (-1 +- Sqrt(-3)) / 2
- //
- var red = num === this.p ? this.red : BN.mont(num);
- var tinv = new BN(2).toRed(red).redInvm();
- var ntinv = tinv.redNeg();
- var s = new BN(3).toRed(red).redNeg().redSqrt().redMul(tinv);
- var l1 = ntinv.redAdd(s).fromRed();
- var l2 = ntinv.redSub(s).fromRed();
- return [ l1, l2 ];
- };
- ShortCurve.prototype._getEndoBasis = function _getEndoBasis(lambda) {
- // aprxSqrt >= sqrt(this.n)
- var aprxSqrt = this.n.ushrn(Math.floor(this.n.bitLength() / 2));
- // 3.74
- // Run EGCD, until r(L + 1) < aprxSqrt
- var u = lambda;
- var v = this.n.clone();
- var x1 = new BN(1);
- var y1 = new BN(0);
- var x2 = new BN(0);
- var y2 = new BN(1);
- // NOTE: all vectors are roots of: a + b * lambda = 0 (mod n)
- var a0;
- var b0;
- // First vector
- var a1;
- var b1;
- // Second vector
- var a2;
- var b2;
- var prevR;
- var i = 0;
- var r;
- var x;
- while (u.cmpn(0) !== 0) {
- var q = v.div(u);
- r = v.sub(q.mul(u));
- x = x2.sub(q.mul(x1));
- var y = y2.sub(q.mul(y1));
- if (!a1 && r.cmp(aprxSqrt) < 0) {
- a0 = prevR.neg();
- b0 = x1;
- a1 = r.neg();
- b1 = x;
- } else if (a1 && ++i === 2) {
- break;
- }
- prevR = r;
- v = u;
- u = r;
- x2 = x1;
- x1 = x;
- y2 = y1;
- y1 = y;
- }
- a2 = r.neg();
- b2 = x;
- var len1 = a1.sqr().add(b1.sqr());
- var len2 = a2.sqr().add(b2.sqr());
- if (len2.cmp(len1) >= 0) {
- a2 = a0;
- b2 = b0;
- }
- // Normalize signs
- if (a1.negative) {
- a1 = a1.neg();
- b1 = b1.neg();
- }
- if (a2.negative) {
- a2 = a2.neg();
- b2 = b2.neg();
- }
- return [
- { a: a1, b: b1 },
- { a: a2, b: b2 },
- ];
- };
- ShortCurve.prototype._endoSplit = function _endoSplit(k) {
- var basis = this.endo.basis;
- var v1 = basis[0];
- var v2 = basis[1];
- var c1 = v2.b.mul(k).divRound(this.n);
- var c2 = v1.b.neg().mul(k).divRound(this.n);
- var p1 = c1.mul(v1.a);
- var p2 = c2.mul(v2.a);
- var q1 = c1.mul(v1.b);
- var q2 = c2.mul(v2.b);
- // Calculate answer
- var k1 = k.sub(p1).sub(p2);
- var k2 = q1.add(q2).neg();
- return { k1: k1, k2: k2 };
- };
- ShortCurve.prototype.pointFromX = function pointFromX(x, odd) {
- x = new BN(x, 16);
- if (!x.red)
- x = x.toRed(this.red);
- var y2 = x.redSqr().redMul(x).redIAdd(x.redMul(this.a)).redIAdd(this.b);
- var y = y2.redSqrt();
- if (y.redSqr().redSub(y2).cmp(this.zero) !== 0)
- throw new Error('invalid point');
- // XXX Is there any way to tell if the number is odd without converting it
- // to non-red form?
- var isOdd = y.fromRed().isOdd();
- if (odd && !isOdd || !odd && isOdd)
- y = y.redNeg();
- return this.point(x, y);
- };
- ShortCurve.prototype.validate = function validate(point) {
- if (point.inf)
- return true;
- var x = point.x;
- var y = point.y;
- var ax = this.a.redMul(x);
- var rhs = x.redSqr().redMul(x).redIAdd(ax).redIAdd(this.b);
- return y.redSqr().redISub(rhs).cmpn(0) === 0;
- };
- ShortCurve.prototype._endoWnafMulAdd =
- function _endoWnafMulAdd(points, coeffs, jacobianResult) {
- var npoints = this._endoWnafT1;
- var ncoeffs = this._endoWnafT2;
- for (var i = 0; i < points.length; i++) {
- var split = this._endoSplit(coeffs[i]);
- var p = points[i];
- var beta = p._getBeta();
- if (split.k1.negative) {
- split.k1.ineg();
- p = p.neg(true);
- }
- if (split.k2.negative) {
- split.k2.ineg();
- beta = beta.neg(true);
- }
- npoints[i * 2] = p;
- npoints[i * 2 + 1] = beta;
- ncoeffs[i * 2] = split.k1;
- ncoeffs[i * 2 + 1] = split.k2;
- }
- var res = this._wnafMulAdd(1, npoints, ncoeffs, i * 2, jacobianResult);
- // Clean-up references to points and coefficients
- for (var j = 0; j < i * 2; j++) {
- npoints[j] = null;
- ncoeffs[j] = null;
- }
- return res;
- };
- function Point(curve, x, y, isRed) {
- Base.BasePoint.call(this, curve, 'affine');
- if (x === null && y === null) {
- this.x = null;
- this.y = null;
- this.inf = true;
- } else {
- this.x = new BN(x, 16);
- this.y = new BN(y, 16);
- // Force redgomery representation when loading from JSON
- if (isRed) {
- this.x.forceRed(this.curve.red);
- this.y.forceRed(this.curve.red);
- }
- if (!this.x.red)
- this.x = this.x.toRed(this.curve.red);
- if (!this.y.red)
- this.y = this.y.toRed(this.curve.red);
- this.inf = false;
- }
- }
- inherits(Point, Base.BasePoint);
- ShortCurve.prototype.point = function point(x, y, isRed) {
- return new Point(this, x, y, isRed);
- };
- ShortCurve.prototype.pointFromJSON = function pointFromJSON(obj, red) {
- return Point.fromJSON(this, obj, red);
- };
- Point.prototype._getBeta = function _getBeta() {
- if (!this.curve.endo)
- return;
- var pre = this.precomputed;
- if (pre && pre.beta)
- return pre.beta;
- var beta = this.curve.point(this.x.redMul(this.curve.endo.beta), this.y);
- if (pre) {
- var curve = this.curve;
- var endoMul = function(p) {
- return curve.point(p.x.redMul(curve.endo.beta), p.y);
- };
- pre.beta = beta;
- beta.precomputed = {
- beta: null,
- naf: pre.naf && {
- wnd: pre.naf.wnd,
- points: pre.naf.points.map(endoMul),
- },
- doubles: pre.doubles && {
- step: pre.doubles.step,
- points: pre.doubles.points.map(endoMul),
- },
- };
- }
- return beta;
- };
- Point.prototype.toJSON = function toJSON() {
- if (!this.precomputed)
- return [ this.x, this.y ];
- return [ this.x, this.y, this.precomputed && {
- doubles: this.precomputed.doubles && {
- step: this.precomputed.doubles.step,
- points: this.precomputed.doubles.points.slice(1),
- },
- naf: this.precomputed.naf && {
- wnd: this.precomputed.naf.wnd,
- points: this.precomputed.naf.points.slice(1),
- },
- } ];
- };
- Point.fromJSON = function fromJSON(curve, obj, red) {
- if (typeof obj === 'string')
- obj = JSON.parse(obj);
- var res = curve.point(obj[0], obj[1], red);
- if (!obj[2])
- return res;
- function obj2point(obj) {
- return curve.point(obj[0], obj[1], red);
- }
- var pre = obj[2];
- res.precomputed = {
- beta: null,
- doubles: pre.doubles && {
- step: pre.doubles.step,
- points: [ res ].concat(pre.doubles.points.map(obj2point)),
- },
- naf: pre.naf && {
- wnd: pre.naf.wnd,
- points: [ res ].concat(pre.naf.points.map(obj2point)),
- },
- };
- return res;
- };
- Point.prototype.inspect = function inspect() {
- if (this.isInfinity())
- return '<EC Point Infinity>';
- return '<EC Point x: ' + this.x.fromRed().toString(16, 2) +
- ' y: ' + this.y.fromRed().toString(16, 2) + '>';
- };
- Point.prototype.isInfinity = function isInfinity() {
- return this.inf;
- };
- Point.prototype.add = function add(p) {
- // O + P = P
- if (this.inf)
- return p;
- // P + O = P
- if (p.inf)
- return this;
- // P + P = 2P
- if (this.eq(p))
- return this.dbl();
- // P + (-P) = O
- if (this.neg().eq(p))
- return this.curve.point(null, null);
- // P + Q = O
- if (this.x.cmp(p.x) === 0)
- return this.curve.point(null, null);
- var c = this.y.redSub(p.y);
- if (c.cmpn(0) !== 0)
- c = c.redMul(this.x.redSub(p.x).redInvm());
- var nx = c.redSqr().redISub(this.x).redISub(p.x);
- var ny = c.redMul(this.x.redSub(nx)).redISub(this.y);
- return this.curve.point(nx, ny);
- };
- Point.prototype.dbl = function dbl() {
- if (this.inf)
- return this;
- // 2P = O
- var ys1 = this.y.redAdd(this.y);
- if (ys1.cmpn(0) === 0)
- return this.curve.point(null, null);
- var a = this.curve.a;
- var x2 = this.x.redSqr();
- var dyinv = ys1.redInvm();
- var c = x2.redAdd(x2).redIAdd(x2).redIAdd(a).redMul(dyinv);
- var nx = c.redSqr().redISub(this.x.redAdd(this.x));
- var ny = c.redMul(this.x.redSub(nx)).redISub(this.y);
- return this.curve.point(nx, ny);
- };
- Point.prototype.getX = function getX() {
- return this.x.fromRed();
- };
- Point.prototype.getY = function getY() {
- return this.y.fromRed();
- };
- Point.prototype.mul = function mul(k) {
- k = new BN(k, 16);
- if (this.isInfinity())
- return this;
- else if (this._hasDoubles(k))
- return this.curve._fixedNafMul(this, k);
- else if (this.curve.endo)
- return this.curve._endoWnafMulAdd([ this ], [ k ]);
- else
- return this.curve._wnafMul(this, k);
- };
- Point.prototype.mulAdd = function mulAdd(k1, p2, k2) {
- var points = [ this, p2 ];
- var coeffs = [ k1, k2 ];
- if (this.curve.endo)
- return this.curve._endoWnafMulAdd(points, coeffs);
- else
- return this.curve._wnafMulAdd(1, points, coeffs, 2);
- };
- Point.prototype.jmulAdd = function jmulAdd(k1, p2, k2) {
- var points = [ this, p2 ];
- var coeffs = [ k1, k2 ];
- if (this.curve.endo)
- return this.curve._endoWnafMulAdd(points, coeffs, true);
- else
- return this.curve._wnafMulAdd(1, points, coeffs, 2, true);
- };
- Point.prototype.eq = function eq(p) {
- return this === p ||
- this.inf === p.inf &&
- (this.inf || this.x.cmp(p.x) === 0 && this.y.cmp(p.y) === 0);
- };
- Point.prototype.neg = function neg(_precompute) {
- if (this.inf)
- return this;
- var res = this.curve.point(this.x, this.y.redNeg());
- if (_precompute && this.precomputed) {
- var pre = this.precomputed;
- var negate = function(p) {
- return p.neg();
- };
- res.precomputed = {
- naf: pre.naf && {
- wnd: pre.naf.wnd,
- points: pre.naf.points.map(negate),
- },
- doubles: pre.doubles && {
- step: pre.doubles.step,
- points: pre.doubles.points.map(negate),
- },
- };
- }
- return res;
- };
- Point.prototype.toJ = function toJ() {
- if (this.inf)
- return this.curve.jpoint(null, null, null);
- var res = this.curve.jpoint(this.x, this.y, this.curve.one);
- return res;
- };
- function JPoint(curve, x, y, z) {
- Base.BasePoint.call(this, curve, 'jacobian');
- if (x === null && y === null && z === null) {
- this.x = this.curve.one;
- this.y = this.curve.one;
- this.z = new BN(0);
- } else {
- this.x = new BN(x, 16);
- this.y = new BN(y, 16);
- this.z = new BN(z, 16);
- }
- if (!this.x.red)
- this.x = this.x.toRed(this.curve.red);
- if (!this.y.red)
- this.y = this.y.toRed(this.curve.red);
- if (!this.z.red)
- this.z = this.z.toRed(this.curve.red);
- this.zOne = this.z === this.curve.one;
- }
- inherits(JPoint, Base.BasePoint);
- ShortCurve.prototype.jpoint = function jpoint(x, y, z) {
- return new JPoint(this, x, y, z);
- };
- JPoint.prototype.toP = function toP() {
- if (this.isInfinity())
- return this.curve.point(null, null);
- var zinv = this.z.redInvm();
- var zinv2 = zinv.redSqr();
- var ax = this.x.redMul(zinv2);
- var ay = this.y.redMul(zinv2).redMul(zinv);
- return this.curve.point(ax, ay);
- };
- JPoint.prototype.neg = function neg() {
- return this.curve.jpoint(this.x, this.y.redNeg(), this.z);
- };
- JPoint.prototype.add = function add(p) {
- // O + P = P
- if (this.isInfinity())
- return p;
- // P + O = P
- if (p.isInfinity())
- return this;
- // 12M + 4S + 7A
- var pz2 = p.z.redSqr();
- var z2 = this.z.redSqr();
- var u1 = this.x.redMul(pz2);
- var u2 = p.x.redMul(z2);
- var s1 = this.y.redMul(pz2.redMul(p.z));
- var s2 = p.y.redMul(z2.redMul(this.z));
- var h = u1.redSub(u2);
- var r = s1.redSub(s2);
- if (h.cmpn(0) === 0) {
- if (r.cmpn(0) !== 0)
- return this.curve.jpoint(null, null, null);
- else
- return this.dbl();
- }
- var h2 = h.redSqr();
- var h3 = h2.redMul(h);
- var v = u1.redMul(h2);
- var nx = r.redSqr().redIAdd(h3).redISub(v).redISub(v);
- var ny = r.redMul(v.redISub(nx)).redISub(s1.redMul(h3));
- var nz = this.z.redMul(p.z).redMul(h);
- return this.curve.jpoint(nx, ny, nz);
- };
- JPoint.prototype.mixedAdd = function mixedAdd(p) {
- // O + P = P
- if (this.isInfinity())
- return p.toJ();
- // P + O = P
- if (p.isInfinity())
- return this;
- // 8M + 3S + 7A
- var z2 = this.z.redSqr();
- var u1 = this.x;
- var u2 = p.x.redMul(z2);
- var s1 = this.y;
- var s2 = p.y.redMul(z2).redMul(this.z);
- var h = u1.redSub(u2);
- var r = s1.redSub(s2);
- if (h.cmpn(0) === 0) {
- if (r.cmpn(0) !== 0)
- return this.curve.jpoint(null, null, null);
- else
- return this.dbl();
- }
- var h2 = h.redSqr();
- var h3 = h2.redMul(h);
- var v = u1.redMul(h2);
- var nx = r.redSqr().redIAdd(h3).redISub(v).redISub(v);
- var ny = r.redMul(v.redISub(nx)).redISub(s1.redMul(h3));
- var nz = this.z.redMul(h);
- return this.curve.jpoint(nx, ny, nz);
- };
- JPoint.prototype.dblp = function dblp(pow) {
- if (pow === 0)
- return this;
- if (this.isInfinity())
- return this;
- if (!pow)
- return this.dbl();
- var i;
- if (this.curve.zeroA || this.curve.threeA) {
- var r = this;
- for (i = 0; i < pow; i++)
- r = r.dbl();
- return r;
- }
- // 1M + 2S + 1A + N * (4S + 5M + 8A)
- // N = 1 => 6M + 6S + 9A
- var a = this.curve.a;
- var tinv = this.curve.tinv;
- var jx = this.x;
- var jy = this.y;
- var jz = this.z;
- var jz4 = jz.redSqr().redSqr();
- // Reuse results
- var jyd = jy.redAdd(jy);
- for (i = 0; i < pow; i++) {
- var jx2 = jx.redSqr();
- var jyd2 = jyd.redSqr();
- var jyd4 = jyd2.redSqr();
- var c = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4));
- var t1 = jx.redMul(jyd2);
- var nx = c.redSqr().redISub(t1.redAdd(t1));
- var t2 = t1.redISub(nx);
- var dny = c.redMul(t2);
- dny = dny.redIAdd(dny).redISub(jyd4);
- var nz = jyd.redMul(jz);
- if (i + 1 < pow)
- jz4 = jz4.redMul(jyd4);
- jx = nx;
- jz = nz;
- jyd = dny;
- }
- return this.curve.jpoint(jx, jyd.redMul(tinv), jz);
- };
- JPoint.prototype.dbl = function dbl() {
- if (this.isInfinity())
- return this;
- if (this.curve.zeroA)
- return this._zeroDbl();
- else if (this.curve.threeA)
- return this._threeDbl();
- else
- return this._dbl();
- };
- JPoint.prototype._zeroDbl = function _zeroDbl() {
- var nx;
- var ny;
- var nz;
- // Z = 1
- if (this.zOne) {
- // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html
- // #doubling-mdbl-2007-bl
- // 1M + 5S + 14A
- // XX = X1^2
- var xx = this.x.redSqr();
- // YY = Y1^2
- var yy = this.y.redSqr();
- // YYYY = YY^2
- var yyyy = yy.redSqr();
- // S = 2 * ((X1 + YY)^2 - XX - YYYY)
- var s = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy);
- s = s.redIAdd(s);
- // M = 3 * XX + a; a = 0
- var m = xx.redAdd(xx).redIAdd(xx);
- // T = M ^ 2 - 2*S
- var t = m.redSqr().redISub(s).redISub(s);
- // 8 * YYYY
- var yyyy8 = yyyy.redIAdd(yyyy);
- yyyy8 = yyyy8.redIAdd(yyyy8);
- yyyy8 = yyyy8.redIAdd(yyyy8);
- // X3 = T
- nx = t;
- // Y3 = M * (S - T) - 8 * YYYY
- ny = m.redMul(s.redISub(t)).redISub(yyyy8);
- // Z3 = 2*Y1
- nz = this.y.redAdd(this.y);
- } else {
- // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html
- // #doubling-dbl-2009-l
- // 2M + 5S + 13A
- // A = X1^2
- var a = this.x.redSqr();
- // B = Y1^2
- var b = this.y.redSqr();
- // C = B^2
- var c = b.redSqr();
- // D = 2 * ((X1 + B)^2 - A - C)
- var d = this.x.redAdd(b).redSqr().redISub(a).redISub(c);
- d = d.redIAdd(d);
- // E = 3 * A
- var e = a.redAdd(a).redIAdd(a);
- // F = E^2
- var f = e.redSqr();
- // 8 * C
- var c8 = c.redIAdd(c);
- c8 = c8.redIAdd(c8);
- c8 = c8.redIAdd(c8);
- // X3 = F - 2 * D
- nx = f.redISub(d).redISub(d);
- // Y3 = E * (D - X3) - 8 * C
- ny = e.redMul(d.redISub(nx)).redISub(c8);
- // Z3 = 2 * Y1 * Z1
- nz = this.y.redMul(this.z);
- nz = nz.redIAdd(nz);
- }
- return this.curve.jpoint(nx, ny, nz);
- };
- JPoint.prototype._threeDbl = function _threeDbl() {
- var nx;
- var ny;
- var nz;
- // Z = 1
- if (this.zOne) {
- // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html
- // #doubling-mdbl-2007-bl
- // 1M + 5S + 15A
- // XX = X1^2
- var xx = this.x.redSqr();
- // YY = Y1^2
- var yy = this.y.redSqr();
- // YYYY = YY^2
- var yyyy = yy.redSqr();
- // S = 2 * ((X1 + YY)^2 - XX - YYYY)
- var s = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy);
- s = s.redIAdd(s);
- // M = 3 * XX + a
- var m = xx.redAdd(xx).redIAdd(xx).redIAdd(this.curve.a);
- // T = M^2 - 2 * S
- var t = m.redSqr().redISub(s).redISub(s);
- // X3 = T
- nx = t;
- // Y3 = M * (S - T) - 8 * YYYY
- var yyyy8 = yyyy.redIAdd(yyyy);
- yyyy8 = yyyy8.redIAdd(yyyy8);
- yyyy8 = yyyy8.redIAdd(yyyy8);
- ny = m.redMul(s.redISub(t)).redISub(yyyy8);
- // Z3 = 2 * Y1
- nz = this.y.redAdd(this.y);
- } else {
- // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html#doubling-dbl-2001-b
- // 3M + 5S
- // delta = Z1^2
- var delta = this.z.redSqr();
- // gamma = Y1^2
- var gamma = this.y.redSqr();
- // beta = X1 * gamma
- var beta = this.x.redMul(gamma);
- // alpha = 3 * (X1 - delta) * (X1 + delta)
- var alpha = this.x.redSub(delta).redMul(this.x.redAdd(delta));
- alpha = alpha.redAdd(alpha).redIAdd(alpha);
- // X3 = alpha^2 - 8 * beta
- var beta4 = beta.redIAdd(beta);
- beta4 = beta4.redIAdd(beta4);
- var beta8 = beta4.redAdd(beta4);
- nx = alpha.redSqr().redISub(beta8);
- // Z3 = (Y1 + Z1)^2 - gamma - delta
- nz = this.y.redAdd(this.z).redSqr().redISub(gamma).redISub(delta);
- // Y3 = alpha * (4 * beta - X3) - 8 * gamma^2
- var ggamma8 = gamma.redSqr();
- ggamma8 = ggamma8.redIAdd(ggamma8);
- ggamma8 = ggamma8.redIAdd(ggamma8);
- ggamma8 = ggamma8.redIAdd(ggamma8);
- ny = alpha.redMul(beta4.redISub(nx)).redISub(ggamma8);
- }
- return this.curve.jpoint(nx, ny, nz);
- };
- JPoint.prototype._dbl = function _dbl() {
- var a = this.curve.a;
- // 4M + 6S + 10A
- var jx = this.x;
- var jy = this.y;
- var jz = this.z;
- var jz4 = jz.redSqr().redSqr();
- var jx2 = jx.redSqr();
- var jy2 = jy.redSqr();
- var c = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4));
- var jxd4 = jx.redAdd(jx);
- jxd4 = jxd4.redIAdd(jxd4);
- var t1 = jxd4.redMul(jy2);
- var nx = c.redSqr().redISub(t1.redAdd(t1));
- var t2 = t1.redISub(nx);
- var jyd8 = jy2.redSqr();
- jyd8 = jyd8.redIAdd(jyd8);
- jyd8 = jyd8.redIAdd(jyd8);
- jyd8 = jyd8.redIAdd(jyd8);
- var ny = c.redMul(t2).redISub(jyd8);
- var nz = jy.redAdd(jy).redMul(jz);
- return this.curve.jpoint(nx, ny, nz);
- };
- JPoint.prototype.trpl = function trpl() {
- if (!this.curve.zeroA)
- return this.dbl().add(this);
- // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html#tripling-tpl-2007-bl
- // 5M + 10S + ...
- // XX = X1^2
- var xx = this.x.redSqr();
- // YY = Y1^2
- var yy = this.y.redSqr();
- // ZZ = Z1^2
- var zz = this.z.redSqr();
- // YYYY = YY^2
- var yyyy = yy.redSqr();
- // M = 3 * XX + a * ZZ2; a = 0
- var m = xx.redAdd(xx).redIAdd(xx);
- // MM = M^2
- var mm = m.redSqr();
- // E = 6 * ((X1 + YY)^2 - XX - YYYY) - MM
- var e = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy);
- e = e.redIAdd(e);
- e = e.redAdd(e).redIAdd(e);
- e = e.redISub(mm);
- // EE = E^2
- var ee = e.redSqr();
- // T = 16*YYYY
- var t = yyyy.redIAdd(yyyy);
- t = t.redIAdd(t);
- t = t.redIAdd(t);
- t = t.redIAdd(t);
- // U = (M + E)^2 - MM - EE - T
- var u = m.redIAdd(e).redSqr().redISub(mm).redISub(ee).redISub(t);
- // X3 = 4 * (X1 * EE - 4 * YY * U)
- var yyu4 = yy.redMul(u);
- yyu4 = yyu4.redIAdd(yyu4);
- yyu4 = yyu4.redIAdd(yyu4);
- var nx = this.x.redMul(ee).redISub(yyu4);
- nx = nx.redIAdd(nx);
- nx = nx.redIAdd(nx);
- // Y3 = 8 * Y1 * (U * (T - U) - E * EE)
- var ny = this.y.redMul(u.redMul(t.redISub(u)).redISub(e.redMul(ee)));
- ny = ny.redIAdd(ny);
- ny = ny.redIAdd(ny);
- ny = ny.redIAdd(ny);
- // Z3 = (Z1 + E)^2 - ZZ - EE
- var nz = this.z.redAdd(e).redSqr().redISub(zz).redISub(ee);
- return this.curve.jpoint(nx, ny, nz);
- };
- JPoint.prototype.mul = function mul(k, kbase) {
- k = new BN(k, kbase);
- return this.curve._wnafMul(this, k);
- };
- JPoint.prototype.eq = function eq(p) {
- if (p.type === 'affine')
- return this.eq(p.toJ());
- if (this === p)
- return true;
- // x1 * z2^2 == x2 * z1^2
- var z2 = this.z.redSqr();
- var pz2 = p.z.redSqr();
- if (this.x.redMul(pz2).redISub(p.x.redMul(z2)).cmpn(0) !== 0)
- return false;
- // y1 * z2^3 == y2 * z1^3
- var z3 = z2.redMul(this.z);
- var pz3 = pz2.redMul(p.z);
- return this.y.redMul(pz3).redISub(p.y.redMul(z3)).cmpn(0) === 0;
- };
- JPoint.prototype.eqXToP = function eqXToP(x) {
- var zs = this.z.redSqr();
- var rx = x.toRed(this.curve.red).redMul(zs);
- if (this.x.cmp(rx) === 0)
- return true;
- var xc = x.clone();
- var t = this.curve.redN.redMul(zs);
- for (;;) {
- xc.iadd(this.curve.n);
- if (xc.cmp(this.curve.p) >= 0)
- return false;
- rx.redIAdd(t);
- if (this.x.cmp(rx) === 0)
- return true;
- }
- };
- JPoint.prototype.inspect = function inspect() {
- if (this.isInfinity())
- return '<EC JPoint Infinity>';
- return '<EC JPoint x: ' + this.x.toString(16, 2) +
- ' y: ' + this.y.toString(16, 2) +
- ' z: ' + this.z.toString(16, 2) + '>';
- };
- JPoint.prototype.isInfinity = function isInfinity() {
- // XXX This code assumes that zero is always zero in red
- return this.z.cmpn(0) === 0;
- };
- },{"../utils":768,"./base":755,"bn.js":769,"inherits":789}],760:[function(_dereq_,module,exports){
- 'use strict';
- var curves = exports;
- var hash = _dereq_('hash.js');
- var curve = _dereq_('./curve');
- var utils = _dereq_('./utils');
- var assert = utils.assert;
- function PresetCurve(options) {
- if (options.type === 'short')
- this.curve = new curve.short(options);
- else if (options.type === 'edwards')
- this.curve = new curve.edwards(options);
- else
- this.curve = new curve.mont(options);
- this.g = this.curve.g;
- this.n = this.curve.n;
- this.hash = options.hash;
- assert(this.g.validate(), 'Invalid curve');
- assert(this.g.mul(this.n).isInfinity(), 'Invalid curve, G*N != O');
- }
- curves.PresetCurve = PresetCurve;
- function defineCurve(name, options) {
- Object.defineProperty(curves, name, {
- configurable: true,
- enumerable: true,
- get: function() {
- var curve = new PresetCurve(options);
- Object.defineProperty(curves, name, {
- configurable: true,
- enumerable: true,
- value: curve,
- });
- return curve;
- },
- });
- }
- defineCurve('p192', {
- type: 'short',
- prime: 'p192',
- p: 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff',
- a: 'ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc',
- b: '64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1',
- n: 'ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831',
- hash: hash.sha256,
- gRed: false,
- g: [
- '188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012',
- '07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811',
- ],
- });
- defineCurve('p224', {
- type: 'short',
- prime: 'p224',
- p: 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001',
- a: 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe',
- b: 'b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4',
- n: 'ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d',
- hash: hash.sha256,
- gRed: false,
- g: [
- 'b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21',
- 'bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34',
- ],
- });
- defineCurve('p256', {
- type: 'short',
- prime: null,
- p: 'ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff',
- a: 'ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc',
- b: '5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b',
- n: 'ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551',
- hash: hash.sha256,
- gRed: false,
- g: [
- '6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296',
- '4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5',
- ],
- });
- defineCurve('p384', {
- type: 'short',
- prime: null,
- p: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
- 'fffffffe ffffffff 00000000 00000000 ffffffff',
- a: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
- 'fffffffe ffffffff 00000000 00000000 fffffffc',
- b: 'b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f ' +
- '5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef',
- n: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 ' +
- 'f4372ddf 581a0db2 48b0a77a ecec196a ccc52973',
- hash: hash.sha384,
- gRed: false,
- g: [
- 'aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 ' +
- '5502f25d bf55296c 3a545e38 72760ab7',
- '3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 ' +
- '0a60b1ce 1d7e819d 7a431d7c 90ea0e5f',
- ],
- });
- defineCurve('p521', {
- type: 'short',
- prime: null,
- p: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
- 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
- 'ffffffff ffffffff ffffffff ffffffff ffffffff',
- a: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
- 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
- 'ffffffff ffffffff ffffffff ffffffff fffffffc',
- b: '00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b ' +
- '99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd ' +
- '3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00',
- n: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
- 'ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 ' +
- 'f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409',
- hash: hash.sha512,
- gRed: false,
- g: [
- '000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 ' +
- '053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 ' +
- 'a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66',
- '00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 ' +
- '579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 ' +
- '3fad0761 353c7086 a272c240 88be9476 9fd16650',
- ],
- });
- defineCurve('curve25519', {
- type: 'mont',
- prime: 'p25519',
- p: '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed',
- a: '76d06',
- b: '1',
- n: '1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed',
- hash: hash.sha256,
- gRed: false,
- g: [
- '9',
- ],
- });
- defineCurve('ed25519', {
- type: 'edwards',
- prime: 'p25519',
- p: '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed',
- a: '-1',
- c: '1',
- // -121665 * (121666^(-1)) (mod P)
- d: '52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3',
- n: '1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed',
- hash: hash.sha256,
- gRed: false,
- g: [
- '216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a',
- // 4/5
- '6666666666666666666666666666666666666666666666666666666666666658',
- ],
- });
- var pre;
- try {
- pre = _dereq_('./precomputed/secp256k1');
- } catch (e) {
- pre = undefined;
- }
- defineCurve('secp256k1', {
- type: 'short',
- prime: 'k256',
- p: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f',
- a: '0',
- b: '7',
- n: 'ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141',
- h: '1',
- hash: hash.sha256,
- // Precomputed endomorphism
- beta: '7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee',
- lambda: '5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72',
- basis: [
- {
- a: '3086d221a7d46bcde86c90e49284eb15',
- b: '-e4437ed6010e88286f547fa90abfe4c3',
- },
- {
- a: '114ca50f7a8e2f3f657c1108d9d44cfd8',
- b: '3086d221a7d46bcde86c90e49284eb15',
- },
- ],
- gRed: false,
- g: [
- '79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798',
- '483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8',
- pre,
- ],
- });
- },{"./curve":757,"./precomputed/secp256k1":767,"./utils":768,"hash.js":776}],761:[function(_dereq_,module,exports){
- 'use strict';
- var BN = _dereq_('bn.js');
- var HmacDRBG = _dereq_('hmac-drbg');
- var utils = _dereq_('../utils');
- var curves = _dereq_('../curves');
- var rand = _dereq_('brorand');
- var assert = utils.assert;
- var KeyPair = _dereq_('./key');
- var Signature = _dereq_('./signature');
- function EC(options) {
- if (!(this instanceof EC))
- return new EC(options);
- // Shortcut `elliptic.ec(curve-name)`
- if (typeof options === 'string') {
- assert(Object.prototype.hasOwnProperty.call(curves, options),
- 'Unknown curve ' + options);
- options = curves[options];
- }
- // Shortcut for `elliptic.ec(elliptic.curves.curveName)`
- if (options instanceof curves.PresetCurve)
- options = { curve: options };
- this.curve = options.curve.curve;
- this.n = this.curve.n;
- this.nh = this.n.ushrn(1);
- this.g = this.curve.g;
- // Point on curve
- this.g = options.curve.g;
- this.g.precompute(options.curve.n.bitLength() + 1);
- // Hash for function for DRBG
- this.hash = options.hash || options.curve.hash;
- }
- module.exports = EC;
- EC.prototype.keyPair = function keyPair(options) {
- return new KeyPair(this, options);
- };
- EC.prototype.keyFromPrivate = function keyFromPrivate(priv, enc) {
- return KeyPair.fromPrivate(this, priv, enc);
- };
- EC.prototype.keyFromPublic = function keyFromPublic(pub, enc) {
- return KeyPair.fromPublic(this, pub, enc);
- };
- EC.prototype.genKeyPair = function genKeyPair(options) {
- if (!options)
- options = {};
- // Instantiate Hmac_DRBG
- var drbg = new HmacDRBG({
- hash: this.hash,
- pers: options.pers,
- persEnc: options.persEnc || 'utf8',
- entropy: options.entropy || rand(this.hash.hmacStrength),
- entropyEnc: options.entropy && options.entropyEnc || 'utf8',
- nonce: this.n.toArray(),
- });
- var bytes = this.n.byteLength();
- var ns2 = this.n.sub(new BN(2));
- for (;;) {
- var priv = new BN(drbg.generate(bytes));
- if (priv.cmp(ns2) > 0)
- continue;
- priv.iaddn(1);
- return this.keyFromPrivate(priv);
- }
- };
- EC.prototype._truncateToN = function _truncateToN(msg, truncOnly) {
- var delta = msg.byteLength() * 8 - this.n.bitLength();
- if (delta > 0)
- msg = msg.ushrn(delta);
- if (!truncOnly && msg.cmp(this.n) >= 0)
- return msg.sub(this.n);
- else
- return msg;
- };
- EC.prototype.sign = function sign(msg, key, enc, options) {
- if (typeof enc === 'object') {
- options = enc;
- enc = null;
- }
- if (!options)
- options = {};
- key = this.keyFromPrivate(key, enc);
- msg = this._truncateToN(new BN(msg, 16));
- // Zero-extend key to provide enough entropy
- var bytes = this.n.byteLength();
- var bkey = key.getPrivate().toArray('be', bytes);
- // Zero-extend nonce to have the same byte size as N
- var nonce = msg.toArray('be', bytes);
- // Instantiate Hmac_DRBG
- var drbg = new HmacDRBG({
- hash: this.hash,
- entropy: bkey,
- nonce: nonce,
- pers: options.pers,
- persEnc: options.persEnc || 'utf8',
- });
- // Number of bytes to generate
- var ns1 = this.n.sub(new BN(1));
- for (var iter = 0; ; iter++) {
- var k = options.k ?
- options.k(iter) :
- new BN(drbg.generate(this.n.byteLength()));
- k = this._truncateToN(k, true);
- if (k.cmpn(1) <= 0 || k.cmp(ns1) >= 0)
- continue;
- var kp = this.g.mul(k);
- if (kp.isInfinity())
- continue;
- var kpX = kp.getX();
- var r = kpX.umod(this.n);
- if (r.cmpn(0) === 0)
- continue;
- var s = k.invm(this.n).mul(r.mul(key.getPrivate()).iadd(msg));
- s = s.umod(this.n);
- if (s.cmpn(0) === 0)
- continue;
- var recoveryParam = (kp.getY().isOdd() ? 1 : 0) |
- (kpX.cmp(r) !== 0 ? 2 : 0);
- // Use complement of `s`, if it is > `n / 2`
- if (options.canonical && s.cmp(this.nh) > 0) {
- s = this.n.sub(s);
- recoveryParam ^= 1;
- }
- return new Signature({ r: r, s: s, recoveryParam: recoveryParam });
- }
- };
- EC.prototype.verify = function verify(msg, signature, key, enc) {
- msg = this._truncateToN(new BN(msg, 16));
- key = this.keyFromPublic(key, enc);
- signature = new Signature(signature, 'hex');
- // Perform primitive values validation
- var r = signature.r;
- var s = signature.s;
- if (r.cmpn(1) < 0 || r.cmp(this.n) >= 0)
- return false;
- if (s.cmpn(1) < 0 || s.cmp(this.n) >= 0)
- return false;
- // Validate signature
- var sinv = s.invm(this.n);
- var u1 = sinv.mul(msg).umod(this.n);
- var u2 = sinv.mul(r).umod(this.n);
- var p;
- if (!this.curve._maxwellTrick) {
- p = this.g.mulAdd(u1, key.getPublic(), u2);
- if (p.isInfinity())
- return false;
- return p.getX().umod(this.n).cmp(r) === 0;
- }
- // NOTE: Greg Maxwell's trick, inspired by:
- // https://git.io/vad3K
- p = this.g.jmulAdd(u1, key.getPublic(), u2);
- if (p.isInfinity())
- return false;
- // Compare `p.x` of Jacobian point with `r`,
- // this will do `p.x == r * p.z^2` instead of multiplying `p.x` by the
- // inverse of `p.z^2`
- return p.eqXToP(r);
- };
- EC.prototype.recoverPubKey = function(msg, signature, j, enc) {
- assert((3 & j) === j, 'The recovery param is more than two bits');
- signature = new Signature(signature, enc);
- var n = this.n;
- var e = new BN(msg);
- var r = signature.r;
- var s = signature.s;
- // A set LSB signifies that the y-coordinate is odd
- var isYOdd = j & 1;
- var isSecondKey = j >> 1;
- if (r.cmp(this.curve.p.umod(this.curve.n)) >= 0 && isSecondKey)
- throw new Error('Unable to find sencond key candinate');
- // 1.1. Let x = r + jn.
- if (isSecondKey)
- r = this.curve.pointFromX(r.add(this.curve.n), isYOdd);
- else
- r = this.curve.pointFromX(r, isYOdd);
- var rInv = signature.r.invm(n);
- var s1 = n.sub(e).mul(rInv).umod(n);
- var s2 = s.mul(rInv).umod(n);
- // 1.6.1 Compute Q = r^-1 (sR - eG)
- // Q = r^-1 (sR + -eG)
- return this.g.mulAdd(s1, r, s2);
- };
- EC.prototype.getKeyRecoveryParam = function(e, signature, Q, enc) {
- signature = new Signature(signature, enc);
- if (signature.recoveryParam !== null)
- return signature.recoveryParam;
- for (var i = 0; i < 4; i++) {
- var Qprime;
- try {
- Qprime = this.recoverPubKey(e, signature, i);
- } catch (e) {
- continue;
- }
- if (Qprime.eq(Q))
- return i;
- }
- throw new Error('Unable to find valid recovery factor');
- };
- },{"../curves":760,"../utils":768,"./key":762,"./signature":763,"bn.js":769,"brorand":322,"hmac-drbg":788}],762:[function(_dereq_,module,exports){
- 'use strict';
- var BN = _dereq_('bn.js');
- var utils = _dereq_('../utils');
- var assert = utils.assert;
- function KeyPair(ec, options) {
- this.ec = ec;
- this.priv = null;
- this.pub = null;
- // KeyPair(ec, { priv: ..., pub: ... })
- if (options.priv)
- this._importPrivate(options.priv, options.privEnc);
- if (options.pub)
- this._importPublic(options.pub, options.pubEnc);
- }
- module.exports = KeyPair;
- KeyPair.fromPublic = function fromPublic(ec, pub, enc) {
- if (pub instanceof KeyPair)
- return pub;
- return new KeyPair(ec, {
- pub: pub,
- pubEnc: enc,
- });
- };
- KeyPair.fromPrivate = function fromPrivate(ec, priv, enc) {
- if (priv instanceof KeyPair)
- return priv;
- return new KeyPair(ec, {
- priv: priv,
- privEnc: enc,
- });
- };
- KeyPair.prototype.validate = function validate() {
- var pub = this.getPublic();
- if (pub.isInfinity())
- return { result: false, reason: 'Invalid public key' };
- if (!pub.validate())
- return { result: false, reason: 'Public key is not a point' };
- if (!pub.mul(this.ec.curve.n).isInfinity())
- return { result: false, reason: 'Public key * N != O' };
- return { result: true, reason: null };
- };
- KeyPair.prototype.getPublic = function getPublic(compact, enc) {
- // compact is optional argument
- if (typeof compact === 'string') {
- enc = compact;
- compact = null;
- }
- if (!this.pub)
- this.pub = this.ec.g.mul(this.priv);
- if (!enc)
- return this.pub;
- return this.pub.encode(enc, compact);
- };
- KeyPair.prototype.getPrivate = function getPrivate(enc) {
- if (enc === 'hex')
- return this.priv.toString(16, 2);
- else
- return this.priv;
- };
- KeyPair.prototype._importPrivate = function _importPrivate(key, enc) {
- this.priv = new BN(key, enc || 16);
- // Ensure that the priv won't be bigger than n, otherwise we may fail
- // in fixed multiplication method
- this.priv = this.priv.umod(this.ec.curve.n);
- };
- KeyPair.prototype._importPublic = function _importPublic(key, enc) {
- if (key.x || key.y) {
- // Montgomery points only have an `x` coordinate.
- // Weierstrass/Edwards points on the other hand have both `x` and
- // `y` coordinates.
- if (this.ec.curve.type === 'mont') {
- assert(key.x, 'Need x coordinate');
- } else if (this.ec.curve.type === 'short' ||
- this.ec.curve.type === 'edwards') {
- assert(key.x && key.y, 'Need both x and y coordinate');
- }
- this.pub = this.ec.curve.point(key.x, key.y);
- return;
- }
- this.pub = this.ec.curve.decodePoint(key, enc);
- };
- // ECDH
- KeyPair.prototype.derive = function derive(pub) {
- if(!pub.validate()) {
- assert(pub.validate(), 'public point not validated');
- }
- return pub.mul(this.priv).getX();
- };
- // ECDSA
- KeyPair.prototype.sign = function sign(msg, enc, options) {
- return this.ec.sign(msg, this, enc, options);
- };
- KeyPair.prototype.verify = function verify(msg, signature) {
- return this.ec.verify(msg, signature, this);
- };
- KeyPair.prototype.inspect = function inspect() {
- return '<Key priv: ' + (this.priv && this.priv.toString(16, 2)) +
- ' pub: ' + (this.pub && this.pub.inspect()) + ' >';
- };
- },{"../utils":768,"bn.js":769}],763:[function(_dereq_,module,exports){
- 'use strict';
- var BN = _dereq_('bn.js');
- var utils = _dereq_('../utils');
- var assert = utils.assert;
- function Signature(options, enc) {
- if (options instanceof Signature)
- return options;
- if (this._importDER(options, enc))
- return;
- assert(options.r && options.s, 'Signature without r or s');
- this.r = new BN(options.r, 16);
- this.s = new BN(options.s, 16);
- if (options.recoveryParam === undefined)
- this.recoveryParam = null;
- else
- this.recoveryParam = options.recoveryParam;
- }
- module.exports = Signature;
- function Position() {
- this.place = 0;
- }
- function getLength(buf, p) {
- var initial = buf[p.place++];
- if (!(initial & 0x80)) {
- return initial;
- }
- var octetLen = initial & 0xf;
- // Indefinite length or overflow
- if (octetLen === 0 || octetLen > 4) {
- return false;
- }
- var val = 0;
- for (var i = 0, off = p.place; i < octetLen; i++, off++) {
- val <<= 8;
- val |= buf[off];
- val >>>= 0;
- }
- // Leading zeroes
- if (val <= 0x7f) {
- return false;
- }
- p.place = off;
- return val;
- }
- function rmPadding(buf) {
- var i = 0;
- var len = buf.length - 1;
- while (!buf[i] && !(buf[i + 1] & 0x80) && i < len) {
- i++;
- }
- if (i === 0) {
- return buf;
- }
- return buf.slice(i);
- }
- Signature.prototype._importDER = function _importDER(data, enc) {
- data = utils.toArray(data, enc);
- var p = new Position();
- if (data[p.place++] !== 0x30) {
- return false;
- }
- var len = getLength(data, p);
- if (len === false) {
- return false;
- }
- if ((len + p.place) !== data.length) {
- return false;
- }
- if (data[p.place++] !== 0x02) {
- return false;
- }
- var rlen = getLength(data, p);
- if (rlen === false) {
- return false;
- }
- var r = data.slice(p.place, rlen + p.place);
- p.place += rlen;
- if (data[p.place++] !== 0x02) {
- return false;
- }
- var slen = getLength(data, p);
- if (slen === false) {
- return false;
- }
- if (data.length !== slen + p.place) {
- return false;
- }
- var s = data.slice(p.place, slen + p.place);
- if (r[0] === 0) {
- if (r[1] & 0x80) {
- r = r.slice(1);
- } else {
- // Leading zeroes
- return false;
- }
- }
- if (s[0] === 0) {
- if (s[1] & 0x80) {
- s = s.slice(1);
- } else {
- // Leading zeroes
- return false;
- }
- }
- this.r = new BN(r);
- this.s = new BN(s);
- this.recoveryParam = null;
- return true;
- };
- function constructLength(arr, len) {
- if (len < 0x80) {
- arr.push(len);
- return;
- }
- var octets = 1 + (Math.log(len) / Math.LN2 >>> 3);
- arr.push(octets | 0x80);
- while (--octets) {
- arr.push((len >>> (octets << 3)) & 0xff);
- }
- arr.push(len);
- }
- Signature.prototype.toDER = function toDER(enc) {
- var r = this.r.toArray();
- var s = this.s.toArray();
- // Pad values
- if (r[0] & 0x80)
- r = [ 0 ].concat(r);
- // Pad values
- if (s[0] & 0x80)
- s = [ 0 ].concat(s);
- r = rmPadding(r);
- s = rmPadding(s);
- while (!s[0] && !(s[1] & 0x80)) {
- s = s.slice(1);
- }
- var arr = [ 0x02 ];
- constructLength(arr, r.length);
- arr = arr.concat(r);
- arr.push(0x02);
- constructLength(arr, s.length);
- var backHalf = arr.concat(s);
- var res = [ 0x30 ];
- constructLength(res, backHalf.length);
- res = res.concat(backHalf);
- return utils.encode(res, enc);
- };
- },{"../utils":768,"bn.js":769}],764:[function(_dereq_,module,exports){
- 'use strict';
- var hash = _dereq_('hash.js');
- var curves = _dereq_('../curves');
- var utils = _dereq_('../utils');
- var assert = utils.assert;
- var parseBytes = utils.parseBytes;
- var KeyPair = _dereq_('./key');
- var Signature = _dereq_('./signature');
- function EDDSA(curve) {
- assert(curve === 'ed25519', 'only tested with ed25519 so far');
- if (!(this instanceof EDDSA))
- return new EDDSA(curve);
- curve = curves[curve].curve;
- this.curve = curve;
- this.g = curve.g;
- this.g.precompute(curve.n.bitLength() + 1);
- this.pointClass = curve.point().constructor;
- this.encodingLength = Math.ceil(curve.n.bitLength() / 8);
- this.hash = hash.sha512;
- }
- module.exports = EDDSA;
- /**
- * @param {Array|String} message - message bytes
- * @param {Array|String|KeyPair} secret - secret bytes or a keypair
- * @returns {Signature} - signature
- */
- EDDSA.prototype.sign = function sign(message, secret) {
- message = parseBytes(message);
- var key = this.keyFromSecret(secret);
- var r = this.hashInt(key.messagePrefix(), message);
- var R = this.g.mul(r);
- var Rencoded = this.encodePoint(R);
- var s_ = this.hashInt(Rencoded, key.pubBytes(), message)
- .mul(key.priv());
- var S = r.add(s_).umod(this.curve.n);
- return this.makeSignature({ R: R, S: S, Rencoded: Rencoded });
- };
- /**
- * @param {Array} message - message bytes
- * @param {Array|String|Signature} sig - sig bytes
- * @param {Array|String|Point|KeyPair} pub - public key
- * @returns {Boolean} - true if public key matches sig of message
- */
- EDDSA.prototype.verify = function verify(message, sig, pub) {
- message = parseBytes(message);
- sig = this.makeSignature(sig);
- var key = this.keyFromPublic(pub);
- var h = this.hashInt(sig.Rencoded(), key.pubBytes(), message);
- var SG = this.g.mul(sig.S());
- var RplusAh = sig.R().add(key.pub().mul(h));
- return RplusAh.eq(SG);
- };
- EDDSA.prototype.hashInt = function hashInt() {
- var hash = this.hash();
- for (var i = 0; i < arguments.length; i++)
- hash.update(arguments[i]);
- return utils.intFromLE(hash.digest()).umod(this.curve.n);
- };
- EDDSA.prototype.keyFromPublic = function keyFromPublic(pub) {
- return KeyPair.fromPublic(this, pub);
- };
- EDDSA.prototype.keyFromSecret = function keyFromSecret(secret) {
- return KeyPair.fromSecret(this, secret);
- };
- EDDSA.prototype.makeSignature = function makeSignature(sig) {
- if (sig instanceof Signature)
- return sig;
- return new Signature(this, sig);
- };
- /**
- * * https://tools.ietf.org/html/draft-josefsson-eddsa-ed25519-03#section-5.2
- *
- * EDDSA defines methods for encoding and decoding points and integers. These are
- * helper convenience methods, that pass along to utility functions implied
- * parameters.
- *
- */
- EDDSA.prototype.encodePoint = function encodePoint(point) {
- var enc = point.getY().toArray('le', this.encodingLength);
- enc[this.encodingLength - 1] |= point.getX().isOdd() ? 0x80 : 0;
- return enc;
- };
- EDDSA.prototype.decodePoint = function decodePoint(bytes) {
- bytes = utils.parseBytes(bytes);
- var lastIx = bytes.length - 1;
- var normed = bytes.slice(0, lastIx).concat(bytes[lastIx] & ~0x80);
- var xIsOdd = (bytes[lastIx] & 0x80) !== 0;
- var y = utils.intFromLE(normed);
- return this.curve.pointFromY(y, xIsOdd);
- };
- EDDSA.prototype.encodeInt = function encodeInt(num) {
- return num.toArray('le', this.encodingLength);
- };
- EDDSA.prototype.decodeInt = function decodeInt(bytes) {
- return utils.intFromLE(bytes);
- };
- EDDSA.prototype.isPoint = function isPoint(val) {
- return val instanceof this.pointClass;
- };
- },{"../curves":760,"../utils":768,"./key":765,"./signature":766,"hash.js":776}],765:[function(_dereq_,module,exports){
- 'use strict';
- var utils = _dereq_('../utils');
- var assert = utils.assert;
- var parseBytes = utils.parseBytes;
- var cachedProperty = utils.cachedProperty;
- /**
- * @param {EDDSA} eddsa - instance
- * @param {Object} params - public/private key parameters
- *
- * @param {Array<Byte>} [params.secret] - secret seed bytes
- * @param {Point} [params.pub] - public key point (aka `A` in eddsa terms)
- * @param {Array<Byte>} [params.pub] - public key point encoded as bytes
- *
- */
- function KeyPair(eddsa, params) {
- this.eddsa = eddsa;
- this._secret = parseBytes(params.secret);
- if (eddsa.isPoint(params.pub))
- this._pub = params.pub;
- else
- this._pubBytes = parseBytes(params.pub);
- }
- KeyPair.fromPublic = function fromPublic(eddsa, pub) {
- if (pub instanceof KeyPair)
- return pub;
- return new KeyPair(eddsa, { pub: pub });
- };
- KeyPair.fromSecret = function fromSecret(eddsa, secret) {
- if (secret instanceof KeyPair)
- return secret;
- return new KeyPair(eddsa, { secret: secret });
- };
- KeyPair.prototype.secret = function secret() {
- return this._secret;
- };
- cachedProperty(KeyPair, 'pubBytes', function pubBytes() {
- return this.eddsa.encodePoint(this.pub());
- });
- cachedProperty(KeyPair, 'pub', function pub() {
- if (this._pubBytes)
- return this.eddsa.decodePoint(this._pubBytes);
- return this.eddsa.g.mul(this.priv());
- });
- cachedProperty(KeyPair, 'privBytes', function privBytes() {
- var eddsa = this.eddsa;
- var hash = this.hash();
- var lastIx = eddsa.encodingLength - 1;
- var a = hash.slice(0, eddsa.encodingLength);
- a[0] &= 248;
- a[lastIx] &= 127;
- a[lastIx] |= 64;
- return a;
- });
- cachedProperty(KeyPair, 'priv', function priv() {
- return this.eddsa.decodeInt(this.privBytes());
- });
- cachedProperty(KeyPair, 'hash', function hash() {
- return this.eddsa.hash().update(this.secret()).digest();
- });
- cachedProperty(KeyPair, 'messagePrefix', function messagePrefix() {
- return this.hash().slice(this.eddsa.encodingLength);
- });
- KeyPair.prototype.sign = function sign(message) {
- assert(this._secret, 'KeyPair can only verify');
- return this.eddsa.sign(message, this);
- };
- KeyPair.prototype.verify = function verify(message, sig) {
- return this.eddsa.verify(message, sig, this);
- };
- KeyPair.prototype.getSecret = function getSecret(enc) {
- assert(this._secret, 'KeyPair is public only');
- return utils.encode(this.secret(), enc);
- };
- KeyPair.prototype.getPublic = function getPublic(enc) {
- return utils.encode(this.pubBytes(), enc);
- };
- module.exports = KeyPair;
- },{"../utils":768}],766:[function(_dereq_,module,exports){
- 'use strict';
- var BN = _dereq_('bn.js');
- var utils = _dereq_('../utils');
- var assert = utils.assert;
- var cachedProperty = utils.cachedProperty;
- var parseBytes = utils.parseBytes;
- /**
- * @param {EDDSA} eddsa - eddsa instance
- * @param {Array<Bytes>|Object} sig -
- * @param {Array<Bytes>|Point} [sig.R] - R point as Point or bytes
- * @param {Array<Bytes>|bn} [sig.S] - S scalar as bn or bytes
- * @param {Array<Bytes>} [sig.Rencoded] - R point encoded
- * @param {Array<Bytes>} [sig.Sencoded] - S scalar encoded
- */
- function Signature(eddsa, sig) {
- this.eddsa = eddsa;
- if (typeof sig !== 'object')
- sig = parseBytes(sig);
- if (Array.isArray(sig)) {
- sig = {
- R: sig.slice(0, eddsa.encodingLength),
- S: sig.slice(eddsa.encodingLength),
- };
- }
- assert(sig.R && sig.S, 'Signature without R or S');
- if (eddsa.isPoint(sig.R))
- this._R = sig.R;
- if (sig.S instanceof BN)
- this._S = sig.S;
- this._Rencoded = Array.isArray(sig.R) ? sig.R : sig.Rencoded;
- this._Sencoded = Array.isArray(sig.S) ? sig.S : sig.Sencoded;
- }
- cachedProperty(Signature, 'S', function S() {
- return this.eddsa.decodeInt(this.Sencoded());
- });
- cachedProperty(Signature, 'R', function R() {
- return this.eddsa.decodePoint(this.Rencoded());
- });
- cachedProperty(Signature, 'Rencoded', function Rencoded() {
- return this.eddsa.encodePoint(this.R());
- });
- cachedProperty(Signature, 'Sencoded', function Sencoded() {
- return this.eddsa.encodeInt(this.S());
- });
- Signature.prototype.toBytes = function toBytes() {
- return this.Rencoded().concat(this.Sencoded());
- };
- Signature.prototype.toHex = function toHex() {
- return utils.encode(this.toBytes(), 'hex').toUpperCase();
- };
- module.exports = Signature;
- },{"../utils":768,"bn.js":769}],767:[function(_dereq_,module,exports){
- module.exports = {
- doubles: {
- step: 4,
- points: [
- [
- 'e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a',
- 'f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821',
- ],
- [
- '8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508',
- '11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf',
- ],
- [
- '175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739',
- 'd3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695',
- ],
- [
- '363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640',
- '4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9',
- ],
- [
- '8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c',
- '4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36',
- ],
- [
- '723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda',
- '96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f',
- ],
- [
- 'eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa',
- '5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999',
- ],
- [
- '100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0',
- 'cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09',
- ],
- [
- 'e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d',
- '9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d',
- ],
- [
- 'feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d',
- 'e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088',
- ],
- [
- 'da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1',
- '9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d',
- ],
- [
- '53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0',
- '5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8',
- ],
- [
- '8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047',
- '10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a',
- ],
- [
- '385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862',
- '283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453',
- ],
- [
- '6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7',
- '7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160',
- ],
- [
- '3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd',
- '56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0',
- ],
- [
- '85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83',
- '7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6',
- ],
- [
- '948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a',
- '53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589',
- ],
- [
- '6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8',
- 'bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17',
- ],
- [
- 'e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d',
- '4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda',
- ],
- [
- 'e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725',
- '7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd',
- ],
- [
- '213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754',
- '4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2',
- ],
- [
- '4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c',
- '17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6',
- ],
- [
- 'fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6',
- '6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f',
- ],
- [
- '76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39',
- 'c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01',
- ],
- [
- 'c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891',
- '893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3',
- ],
- [
- 'd895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b',
- 'febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f',
- ],
- [
- 'b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03',
- '2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7',
- ],
- [
- 'e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d',
- 'eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78',
- ],
- [
- 'a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070',
- '7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1',
- ],
- [
- '90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4',
- 'e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150',
- ],
- [
- '8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da',
- '662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82',
- ],
- [
- 'e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11',
- '1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc',
- ],
- [
- '8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e',
- 'efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b',
- ],
- [
- 'e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41',
- '2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51',
- ],
- [
- 'b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef',
- '67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45',
- ],
- [
- 'd68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8',
- 'db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120',
- ],
- [
- '324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d',
- '648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84',
- ],
- [
- '4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96',
- '35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d',
- ],
- [
- '9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd',
- 'ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d',
- ],
- [
- '6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5',
- '9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8',
- ],
- [
- 'a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266',
- '40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8',
- ],
- [
- '7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71',
- '34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac',
- ],
- [
- '928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac',
- 'c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f',
- ],
- [
- '85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751',
- '1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962',
- ],
- [
- 'ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e',
- '493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907',
- ],
- [
- '827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241',
- 'c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec',
- ],
- [
- 'eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3',
- 'be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d',
- ],
- [
- 'e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f',
- '4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414',
- ],
- [
- '1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19',
- 'aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd',
- ],
- [
- '146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be',
- 'b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0',
- ],
- [
- 'fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9',
- '6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811',
- ],
- [
- 'da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2',
- '8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1',
- ],
- [
- 'a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13',
- '7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c',
- ],
- [
- '174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c',
- 'ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73',
- ],
- [
- '959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba',
- '2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd',
- ],
- [
- 'd2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151',
- 'e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405',
- ],
- [
- '64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073',
- 'd99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589',
- ],
- [
- '8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458',
- '38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e',
- ],
- [
- '13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b',
- '69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27',
- ],
- [
- 'bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366',
- 'd3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1',
- ],
- [
- '8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa',
- '40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482',
- ],
- [
- '8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0',
- '620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945',
- ],
- [
- 'dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787',
- '7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573',
- ],
- [
- 'f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e',
- 'ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82',
- ],
- ],
- },
- naf: {
- wnd: 7,
- points: [
- [
- 'f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9',
- '388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672',
- ],
- [
- '2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4',
- 'd8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6',
- ],
- [
- '5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc',
- '6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da',
- ],
- [
- 'acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe',
- 'cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37',
- ],
- [
- '774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb',
- 'd984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b',
- ],
- [
- 'f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8',
- 'ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81',
- ],
- [
- 'd7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e',
- '581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58',
- ],
- [
- 'defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34',
- '4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77',
- ],
- [
- '2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c',
- '85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a',
- ],
- [
- '352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5',
- '321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c',
- ],
- [
- '2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f',
- '2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67',
- ],
- [
- '9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714',
- '73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402',
- ],
- [
- 'daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729',
- 'a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55',
- ],
- [
- 'c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db',
- '2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482',
- ],
- [
- '6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4',
- 'e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82',
- ],
- [
- '1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5',
- 'b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396',
- ],
- [
- '605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479',
- '2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49',
- ],
- [
- '62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d',
- '80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf',
- ],
- [
- '80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f',
- '1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a',
- ],
- [
- '7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb',
- 'd0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7',
- ],
- [
- 'd528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9',
- 'eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933',
- ],
- [
- '49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963',
- '758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a',
- ],
- [
- '77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74',
- '958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6',
- ],
- [
- 'f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530',
- 'e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37',
- ],
- [
- '463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b',
- '5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e',
- ],
- [
- 'f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247',
- 'cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6',
- ],
- [
- 'caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1',
- 'cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476',
- ],
- [
- '2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120',
- '4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40',
- ],
- [
- '7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435',
- '91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61',
- ],
- [
- '754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18',
- '673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683',
- ],
- [
- 'e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8',
- '59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5',
- ],
- [
- '186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb',
- '3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b',
- ],
- [
- 'df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f',
- '55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417',
- ],
- [
- '5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143',
- 'efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868',
- ],
- [
- '290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba',
- 'e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a',
- ],
- [
- 'af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45',
- 'f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6',
- ],
- [
- '766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a',
- '744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996',
- ],
- [
- '59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e',
- 'c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e',
- ],
- [
- 'f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8',
- 'e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d',
- ],
- [
- '7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c',
- '30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2',
- ],
- [
- '948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519',
- 'e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e',
- ],
- [
- '7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab',
- '100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437',
- ],
- [
- '3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca',
- 'ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311',
- ],
- [
- 'd3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf',
- '8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4',
- ],
- [
- '1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610',
- '68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575',
- ],
- [
- '733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4',
- 'f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d',
- ],
- [
- '15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c',
- 'd56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d',
- ],
- [
- 'a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940',
- 'edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629',
- ],
- [
- 'e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980',
- 'a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06',
- ],
- [
- '311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3',
- '66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374',
- ],
- [
- '34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf',
- '9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee',
- ],
- [
- 'f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63',
- '4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1',
- ],
- [
- 'd7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448',
- 'fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b',
- ],
- [
- '32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf',
- '5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661',
- ],
- [
- '7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5',
- '8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6',
- ],
- [
- 'ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6',
- '8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e',
- ],
- [
- '16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5',
- '5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d',
- ],
- [
- 'eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99',
- 'f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc',
- ],
- [
- '78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51',
- 'f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4',
- ],
- [
- '494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5',
- '42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c',
- ],
- [
- 'a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5',
- '204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b',
- ],
- [
- 'c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997',
- '4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913',
- ],
- [
- '841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881',
- '73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154',
- ],
- [
- '5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5',
- '39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865',
- ],
- [
- '36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66',
- 'd2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc',
- ],
- [
- '336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726',
- 'ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224',
- ],
- [
- '8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede',
- '6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e',
- ],
- [
- '1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94',
- '60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6',
- ],
- [
- '85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31',
- '3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511',
- ],
- [
- '29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51',
- 'b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b',
- ],
- [
- 'a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252',
- 'ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2',
- ],
- [
- '4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5',
- 'cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c',
- ],
- [
- 'd24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b',
- '6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3',
- ],
- [
- 'ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4',
- '322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d',
- ],
- [
- 'af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f',
- '6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700',
- ],
- [
- 'e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889',
- '2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4',
- ],
- [
- '591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246',
- 'b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196',
- ],
- [
- '11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984',
- '998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4',
- ],
- [
- '3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a',
- 'b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257',
- ],
- [
- 'cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030',
- 'bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13',
- ],
- [
- 'c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197',
- '6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096',
- ],
- [
- 'c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593',
- 'c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38',
- ],
- [
- 'a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef',
- '21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f',
- ],
- [
- '347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38',
- '60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448',
- ],
- [
- 'da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a',
- '49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a',
- ],
- [
- 'c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111',
- '5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4',
- ],
- [
- '4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502',
- '7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437',
- ],
- [
- '3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea',
- 'be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7',
- ],
- [
- 'cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26',
- '8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d',
- ],
- [
- 'b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986',
- '39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a',
- ],
- [
- 'd4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e',
- '62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54',
- ],
- [
- '48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4',
- '25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77',
- ],
- [
- 'dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda',
- 'ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517',
- ],
- [
- '6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859',
- 'cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10',
- ],
- [
- 'e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f',
- 'f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125',
- ],
- [
- 'eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c',
- '6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e',
- ],
- [
- '13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942',
- 'fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1',
- ],
- [
- 'ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a',
- '1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2',
- ],
- [
- 'b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80',
- '5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423',
- ],
- [
- 'ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d',
- '438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8',
- ],
- [
- '8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1',
- 'cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758',
- ],
- [
- '52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63',
- 'c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375',
- ],
- [
- 'e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352',
- '6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d',
- ],
- [
- '7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193',
- 'ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec',
- ],
- [
- '5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00',
- '9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0',
- ],
- [
- '32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58',
- 'ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c',
- ],
- [
- 'e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7',
- 'd3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4',
- ],
- [
- '8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8',
- 'c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f',
- ],
- [
- '4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e',
- '67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649',
- ],
- [
- '3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d',
- 'cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826',
- ],
- [
- '674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b',
- '299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5',
- ],
- [
- 'd32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f',
- 'f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87',
- ],
- [
- '30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6',
- '462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b',
- ],
- [
- 'be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297',
- '62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc',
- ],
- [
- '93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a',
- '7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c',
- ],
- [
- 'b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c',
- 'ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f',
- ],
- [
- 'd5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52',
- '4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a',
- ],
- [
- 'd3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb',
- 'bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46',
- ],
- [
- '463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065',
- 'bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f',
- ],
- [
- '7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917',
- '603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03',
- ],
- [
- '74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9',
- 'cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08',
- ],
- [
- '30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3',
- '553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8',
- ],
- [
- '9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57',
- '712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373',
- ],
- [
- '176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66',
- 'ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3',
- ],
- [
- '75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8',
- '9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8',
- ],
- [
- '809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721',
- '9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1',
- ],
- [
- '1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180',
- '4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9',
- ],
- ],
- },
- };
- },{}],768:[function(_dereq_,module,exports){
- 'use strict';
- var utils = exports;
- var BN = _dereq_('bn.js');
- var minAssert = _dereq_('minimalistic-assert');
- var minUtils = _dereq_('minimalistic-crypto-utils');
- utils.assert = minAssert;
- utils.toArray = minUtils.toArray;
- utils.zero2 = minUtils.zero2;
- utils.toHex = minUtils.toHex;
- utils.encode = minUtils.encode;
- // Represent num in a w-NAF form
- function getNAF(num, w, bits) {
- var naf = new Array(Math.max(num.bitLength(), bits) + 1);
- naf.fill(0);
- var ws = 1 << (w + 1);
- var k = num.clone();
- for (var i = 0; i < naf.length; i++) {
- var z;
- var mod = k.andln(ws - 1);
- if (k.isOdd()) {
- if (mod > (ws >> 1) - 1)
- z = (ws >> 1) - mod;
- else
- z = mod;
- k.isubn(z);
- } else {
- z = 0;
- }
- naf[i] = z;
- k.iushrn(1);
- }
- return naf;
- }
- utils.getNAF = getNAF;
- // Represent k1, k2 in a Joint Sparse Form
- function getJSF(k1, k2) {
- var jsf = [
- [],
- [],
- ];
- k1 = k1.clone();
- k2 = k2.clone();
- var d1 = 0;
- var d2 = 0;
- var m8;
- while (k1.cmpn(-d1) > 0 || k2.cmpn(-d2) > 0) {
- // First phase
- var m14 = (k1.andln(3) + d1) & 3;
- var m24 = (k2.andln(3) + d2) & 3;
- if (m14 === 3)
- m14 = -1;
- if (m24 === 3)
- m24 = -1;
- var u1;
- if ((m14 & 1) === 0) {
- u1 = 0;
- } else {
- m8 = (k1.andln(7) + d1) & 7;
- if ((m8 === 3 || m8 === 5) && m24 === 2)
- u1 = -m14;
- else
- u1 = m14;
- }
- jsf[0].push(u1);
- var u2;
- if ((m24 & 1) === 0) {
- u2 = 0;
- } else {
- m8 = (k2.andln(7) + d2) & 7;
- if ((m8 === 3 || m8 === 5) && m14 === 2)
- u2 = -m24;
- else
- u2 = m24;
- }
- jsf[1].push(u2);
- // Second phase
- if (2 * d1 === u1 + 1)
- d1 = 1 - d1;
- if (2 * d2 === u2 + 1)
- d2 = 1 - d2;
- k1.iushrn(1);
- k2.iushrn(1);
- }
- return jsf;
- }
- utils.getJSF = getJSF;
- function cachedProperty(obj, name, computer) {
- var key = '_' + name;
- obj.prototype[name] = function cachedProperty() {
- return this[key] !== undefined ? this[key] :
- this[key] = computer.call(this);
- };
- }
- utils.cachedProperty = cachedProperty;
- function parseBytes(bytes) {
- return typeof bytes === 'string' ? utils.toArray(bytes, 'hex') :
- bytes;
- }
- utils.parseBytes = parseBytes;
- function intFromLE(bytes) {
- return new BN(bytes, 'hex', 'le');
- }
- utils.intFromLE = intFromLE;
- },{"bn.js":769,"minimalistic-assert":791,"minimalistic-crypto-utils":792}],769:[function(_dereq_,module,exports){
- arguments[4][197][0].apply(exports,arguments)
- },{"buffer":undefined,"dup":197}],770:[function(_dereq_,module,exports){
- module.exports={
- "_args": [
- [
- "elliptic@6.5.4",
- "/home/gitlab-runner/Moralis-JS-SDK"
- ]
- ],
- "_from": "elliptic@6.5.4",
- "_id": "elliptic@6.5.4",
- "_inBundle": false,
- "_integrity": "sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==",
- "_location": "/elliptic",
- "_phantomChildren": {},
- "_requested": {
- "type": "version",
- "registry": true,
- "raw": "elliptic@6.5.4",
- "name": "elliptic",
- "escapedName": "elliptic",
- "rawSpec": "6.5.4",
- "saveSpec": null,
- "fetchSpec": "6.5.4"
- },
- "_requiredBy": [
- "/@ethersproject/signing-key",
- "/browserify-sign",
- "/create-ecdh"
- ],
- "_resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz",
- "_spec": "6.5.4",
- "_where": "/home/gitlab-runner/Moralis-JS-SDK",
- "author": {
- "name": "Fedor Indutny",
- "email": "fedor@indutny.com"
- },
- "bugs": {
- "url": "https://github.com/indutny/elliptic/issues"
- },
- "dependencies": {
- "bn.js": "^4.11.9",
- "brorand": "^1.1.0",
- "hash.js": "^1.0.0",
- "hmac-drbg": "^1.0.1",
- "inherits": "^2.0.4",
- "minimalistic-assert": "^1.0.1",
- "minimalistic-crypto-utils": "^1.0.1"
- },
- "description": "EC cryptography",
- "devDependencies": {
- "brfs": "^2.0.2",
- "coveralls": "^3.1.0",
- "eslint": "^7.6.0",
- "grunt": "^1.2.1",
- "grunt-browserify": "^5.3.0",
- "grunt-cli": "^1.3.2",
- "grunt-contrib-connect": "^3.0.0",
- "grunt-contrib-copy": "^1.0.0",
- "grunt-contrib-uglify": "^5.0.0",
- "grunt-mocha-istanbul": "^5.0.2",
- "grunt-saucelabs": "^9.0.1",
- "istanbul": "^0.4.5",
- "mocha": "^8.0.1"
- },
- "files": [
- "lib"
- ],
- "homepage": "https://github.com/indutny/elliptic",
- "keywords": [
- "EC",
- "Elliptic",
- "curve",
- "Cryptography"
- ],
- "license": "MIT",
- "main": "lib/elliptic.js",
- "name": "elliptic",
- "repository": {
- "type": "git",
- "url": "git+ssh://git@github.com/indutny/elliptic.git"
- },
- "scripts": {
- "lint": "eslint lib test",
- "lint:fix": "npm run lint -- --fix",
- "test": "npm run lint && npm run unit",
- "unit": "istanbul test _mocha --reporter=spec test/index.js",
- "version": "grunt dist && git add dist/"
- },
- "version": "6.5.4"
- }
- },{}],771:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.version = void 0;
- exports.version = "ethers/5.6.0";
- },{}],772:[function(_dereq_,module,exports){
- "use strict";
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
- }) : (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- o[k2] = m[k];
- }));
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
- Object.defineProperty(o, "default", { enumerable: true, value: v });
- }) : function(o, v) {
- o["default"] = v;
- });
- var __importStar = (this && this.__importStar) || function (mod) {
- if (mod && mod.__esModule) return mod;
- var result = {};
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
- __setModuleDefault(result, mod);
- return result;
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.Wordlist = exports.version = exports.wordlists = exports.utils = exports.logger = exports.errors = exports.constants = exports.FixedNumber = exports.BigNumber = exports.ContractFactory = exports.Contract = exports.BaseContract = exports.providers = exports.getDefaultProvider = exports.VoidSigner = exports.Wallet = exports.Signer = void 0;
- var contracts_1 = _dereq_("@ethersproject/contracts");
- Object.defineProperty(exports, "BaseContract", { enumerable: true, get: function () { return contracts_1.BaseContract; } });
- Object.defineProperty(exports, "Contract", { enumerable: true, get: function () { return contracts_1.Contract; } });
- Object.defineProperty(exports, "ContractFactory", { enumerable: true, get: function () { return contracts_1.ContractFactory; } });
- var bignumber_1 = _dereq_("@ethersproject/bignumber");
- Object.defineProperty(exports, "BigNumber", { enumerable: true, get: function () { return bignumber_1.BigNumber; } });
- Object.defineProperty(exports, "FixedNumber", { enumerable: true, get: function () { return bignumber_1.FixedNumber; } });
- var abstract_signer_1 = _dereq_("@ethersproject/abstract-signer");
- Object.defineProperty(exports, "Signer", { enumerable: true, get: function () { return abstract_signer_1.Signer; } });
- Object.defineProperty(exports, "VoidSigner", { enumerable: true, get: function () { return abstract_signer_1.VoidSigner; } });
- var wallet_1 = _dereq_("@ethersproject/wallet");
- Object.defineProperty(exports, "Wallet", { enumerable: true, get: function () { return wallet_1.Wallet; } });
- var constants = __importStar(_dereq_("@ethersproject/constants"));
- exports.constants = constants;
- var providers = __importStar(_dereq_("@ethersproject/providers"));
- exports.providers = providers;
- var providers_1 = _dereq_("@ethersproject/providers");
- Object.defineProperty(exports, "getDefaultProvider", { enumerable: true, get: function () { return providers_1.getDefaultProvider; } });
- var wordlists_1 = _dereq_("@ethersproject/wordlists");
- Object.defineProperty(exports, "Wordlist", { enumerable: true, get: function () { return wordlists_1.Wordlist; } });
- Object.defineProperty(exports, "wordlists", { enumerable: true, get: function () { return wordlists_1.wordlists; } });
- var utils = __importStar(_dereq_("./utils"));
- exports.utils = utils;
- var logger_1 = _dereq_("@ethersproject/logger");
- Object.defineProperty(exports, "errors", { enumerable: true, get: function () { return logger_1.ErrorCode; } });
- ////////////////////////
- // Compile-Time Constants
- // This is generated by "npm run dist"
- var _version_1 = _dereq_("./_version");
- Object.defineProperty(exports, "version", { enumerable: true, get: function () { return _version_1.version; } });
- var logger = new logger_1.Logger(_version_1.version);
- exports.logger = logger;
- },{"./_version":771,"./utils":774,"@ethersproject/abstract-signer":187,"@ethersproject/bignumber":196,"@ethersproject/constants":203,"@ethersproject/contracts":206,"@ethersproject/logger":223,"@ethersproject/providers":239,"@ethersproject/wallet":273,"@ethersproject/wordlists":278}],773:[function(_dereq_,module,exports){
- "use strict";
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
- }) : (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- o[k2] = m[k];
- }));
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
- Object.defineProperty(o, "default", { enumerable: true, value: v });
- }) : function(o, v) {
- o["default"] = v;
- });
- var __importStar = (this && this.__importStar) || function (mod) {
- if (mod && mod.__esModule) return mod;
- var result = {};
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
- __setModuleDefault(result, mod);
- return result;
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.Wordlist = exports.version = exports.wordlists = exports.utils = exports.logger = exports.errors = exports.constants = exports.FixedNumber = exports.BigNumber = exports.ContractFactory = exports.Contract = exports.BaseContract = exports.providers = exports.getDefaultProvider = exports.VoidSigner = exports.Wallet = exports.Signer = exports.ethers = void 0;
- // To modify this file, you must update ./misc/admin/lib/cmds/update-exports.js
- var ethers = __importStar(_dereq_("./ethers"));
- exports.ethers = ethers;
- try {
- var anyGlobal = window;
- if (anyGlobal._ethers == null) {
- anyGlobal._ethers = ethers;
- }
- }
- catch (error) { }
- var ethers_1 = _dereq_("./ethers");
- Object.defineProperty(exports, "Signer", { enumerable: true, get: function () { return ethers_1.Signer; } });
- Object.defineProperty(exports, "Wallet", { enumerable: true, get: function () { return ethers_1.Wallet; } });
- Object.defineProperty(exports, "VoidSigner", { enumerable: true, get: function () { return ethers_1.VoidSigner; } });
- Object.defineProperty(exports, "getDefaultProvider", { enumerable: true, get: function () { return ethers_1.getDefaultProvider; } });
- Object.defineProperty(exports, "providers", { enumerable: true, get: function () { return ethers_1.providers; } });
- Object.defineProperty(exports, "BaseContract", { enumerable: true, get: function () { return ethers_1.BaseContract; } });
- Object.defineProperty(exports, "Contract", { enumerable: true, get: function () { return ethers_1.Contract; } });
- Object.defineProperty(exports, "ContractFactory", { enumerable: true, get: function () { return ethers_1.ContractFactory; } });
- Object.defineProperty(exports, "BigNumber", { enumerable: true, get: function () { return ethers_1.BigNumber; } });
- Object.defineProperty(exports, "FixedNumber", { enumerable: true, get: function () { return ethers_1.FixedNumber; } });
- Object.defineProperty(exports, "constants", { enumerable: true, get: function () { return ethers_1.constants; } });
- Object.defineProperty(exports, "errors", { enumerable: true, get: function () { return ethers_1.errors; } });
- Object.defineProperty(exports, "logger", { enumerable: true, get: function () { return ethers_1.logger; } });
- Object.defineProperty(exports, "utils", { enumerable: true, get: function () { return ethers_1.utils; } });
- Object.defineProperty(exports, "wordlists", { enumerable: true, get: function () { return ethers_1.wordlists; } });
- ////////////////////////
- // Compile-Time Constants
- Object.defineProperty(exports, "version", { enumerable: true, get: function () { return ethers_1.version; } });
- Object.defineProperty(exports, "Wordlist", { enumerable: true, get: function () { return ethers_1.Wordlist; } });
- },{"./ethers":772}],774:[function(_dereq_,module,exports){
- "use strict";
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
- }) : (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- o[k2] = m[k];
- }));
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
- Object.defineProperty(o, "default", { enumerable: true, value: v });
- }) : function(o, v) {
- o["default"] = v;
- });
- var __importStar = (this && this.__importStar) || function (mod) {
- if (mod && mod.__esModule) return mod;
- var result = {};
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
- __setModuleDefault(result, mod);
- return result;
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.formatBytes32String = exports.Utf8ErrorFuncs = exports.toUtf8String = exports.toUtf8CodePoints = exports.toUtf8Bytes = exports._toEscapedUtf8String = exports.nameprep = exports.hexDataSlice = exports.hexDataLength = exports.hexZeroPad = exports.hexValue = exports.hexStripZeros = exports.hexConcat = exports.isHexString = exports.hexlify = exports.base64 = exports.base58 = exports.TransactionDescription = exports.LogDescription = exports.Interface = exports.SigningKey = exports.HDNode = exports.defaultPath = exports.isBytesLike = exports.isBytes = exports.zeroPad = exports.stripZeros = exports.concat = exports.arrayify = exports.shallowCopy = exports.resolveProperties = exports.getStatic = exports.defineReadOnly = exports.deepCopy = exports.checkProperties = exports.poll = exports.fetchJson = exports._fetchData = exports.RLP = exports.Logger = exports.checkResultErrors = exports.FormatTypes = exports.ParamType = exports.FunctionFragment = exports.EventFragment = exports.ErrorFragment = exports.ConstructorFragment = exports.Fragment = exports.defaultAbiCoder = exports.AbiCoder = void 0;
- exports.Indexed = exports.Utf8ErrorReason = exports.UnicodeNormalizationForm = exports.SupportedAlgorithm = exports.mnemonicToSeed = exports.isValidMnemonic = exports.entropyToMnemonic = exports.mnemonicToEntropy = exports.getAccountPath = exports.verifyTypedData = exports.verifyMessage = exports.recoverPublicKey = exports.computePublicKey = exports.recoverAddress = exports.computeAddress = exports.getJsonWalletAddress = exports.TransactionTypes = exports.serializeTransaction = exports.parseTransaction = exports.accessListify = exports.joinSignature = exports.splitSignature = exports.soliditySha256 = exports.solidityKeccak256 = exports.solidityPack = exports.shuffled = exports.randomBytes = exports.sha512 = exports.sha256 = exports.ripemd160 = exports.keccak256 = exports.computeHmac = exports.commify = exports.parseUnits = exports.formatUnits = exports.parseEther = exports.formatEther = exports.isAddress = exports.getCreate2Address = exports.getContractAddress = exports.getIcapAddress = exports.getAddress = exports._TypedDataEncoder = exports.id = exports.isValidName = exports.namehash = exports.hashMessage = exports.dnsEncode = exports.parseBytes32String = void 0;
- var abi_1 = _dereq_("@ethersproject/abi");
- Object.defineProperty(exports, "AbiCoder", { enumerable: true, get: function () { return abi_1.AbiCoder; } });
- Object.defineProperty(exports, "checkResultErrors", { enumerable: true, get: function () { return abi_1.checkResultErrors; } });
- Object.defineProperty(exports, "ConstructorFragment", { enumerable: true, get: function () { return abi_1.ConstructorFragment; } });
- Object.defineProperty(exports, "defaultAbiCoder", { enumerable: true, get: function () { return abi_1.defaultAbiCoder; } });
- Object.defineProperty(exports, "ErrorFragment", { enumerable: true, get: function () { return abi_1.ErrorFragment; } });
- Object.defineProperty(exports, "EventFragment", { enumerable: true, get: function () { return abi_1.EventFragment; } });
- Object.defineProperty(exports, "FormatTypes", { enumerable: true, get: function () { return abi_1.FormatTypes; } });
- Object.defineProperty(exports, "Fragment", { enumerable: true, get: function () { return abi_1.Fragment; } });
- Object.defineProperty(exports, "FunctionFragment", { enumerable: true, get: function () { return abi_1.FunctionFragment; } });
- Object.defineProperty(exports, "Indexed", { enumerable: true, get: function () { return abi_1.Indexed; } });
- Object.defineProperty(exports, "Interface", { enumerable: true, get: function () { return abi_1.Interface; } });
- Object.defineProperty(exports, "LogDescription", { enumerable: true, get: function () { return abi_1.LogDescription; } });
- Object.defineProperty(exports, "ParamType", { enumerable: true, get: function () { return abi_1.ParamType; } });
- Object.defineProperty(exports, "TransactionDescription", { enumerable: true, get: function () { return abi_1.TransactionDescription; } });
- var address_1 = _dereq_("@ethersproject/address");
- Object.defineProperty(exports, "getAddress", { enumerable: true, get: function () { return address_1.getAddress; } });
- Object.defineProperty(exports, "getCreate2Address", { enumerable: true, get: function () { return address_1.getCreate2Address; } });
- Object.defineProperty(exports, "getContractAddress", { enumerable: true, get: function () { return address_1.getContractAddress; } });
- Object.defineProperty(exports, "getIcapAddress", { enumerable: true, get: function () { return address_1.getIcapAddress; } });
- Object.defineProperty(exports, "isAddress", { enumerable: true, get: function () { return address_1.isAddress; } });
- var base64 = __importStar(_dereq_("@ethersproject/base64"));
- exports.base64 = base64;
- var basex_1 = _dereq_("@ethersproject/basex");
- Object.defineProperty(exports, "base58", { enumerable: true, get: function () { return basex_1.Base58; } });
- var bytes_1 = _dereq_("@ethersproject/bytes");
- Object.defineProperty(exports, "arrayify", { enumerable: true, get: function () { return bytes_1.arrayify; } });
- Object.defineProperty(exports, "concat", { enumerable: true, get: function () { return bytes_1.concat; } });
- Object.defineProperty(exports, "hexConcat", { enumerable: true, get: function () { return bytes_1.hexConcat; } });
- Object.defineProperty(exports, "hexDataSlice", { enumerable: true, get: function () { return bytes_1.hexDataSlice; } });
- Object.defineProperty(exports, "hexDataLength", { enumerable: true, get: function () { return bytes_1.hexDataLength; } });
- Object.defineProperty(exports, "hexlify", { enumerable: true, get: function () { return bytes_1.hexlify; } });
- Object.defineProperty(exports, "hexStripZeros", { enumerable: true, get: function () { return bytes_1.hexStripZeros; } });
- Object.defineProperty(exports, "hexValue", { enumerable: true, get: function () { return bytes_1.hexValue; } });
- Object.defineProperty(exports, "hexZeroPad", { enumerable: true, get: function () { return bytes_1.hexZeroPad; } });
- Object.defineProperty(exports, "isBytes", { enumerable: true, get: function () { return bytes_1.isBytes; } });
- Object.defineProperty(exports, "isBytesLike", { enumerable: true, get: function () { return bytes_1.isBytesLike; } });
- Object.defineProperty(exports, "isHexString", { enumerable: true, get: function () { return bytes_1.isHexString; } });
- Object.defineProperty(exports, "joinSignature", { enumerable: true, get: function () { return bytes_1.joinSignature; } });
- Object.defineProperty(exports, "zeroPad", { enumerable: true, get: function () { return bytes_1.zeroPad; } });
- Object.defineProperty(exports, "splitSignature", { enumerable: true, get: function () { return bytes_1.splitSignature; } });
- Object.defineProperty(exports, "stripZeros", { enumerable: true, get: function () { return bytes_1.stripZeros; } });
- var hash_1 = _dereq_("@ethersproject/hash");
- Object.defineProperty(exports, "_TypedDataEncoder", { enumerable: true, get: function () { return hash_1._TypedDataEncoder; } });
- Object.defineProperty(exports, "dnsEncode", { enumerable: true, get: function () { return hash_1.dnsEncode; } });
- Object.defineProperty(exports, "hashMessage", { enumerable: true, get: function () { return hash_1.hashMessage; } });
- Object.defineProperty(exports, "id", { enumerable: true, get: function () { return hash_1.id; } });
- Object.defineProperty(exports, "isValidName", { enumerable: true, get: function () { return hash_1.isValidName; } });
- Object.defineProperty(exports, "namehash", { enumerable: true, get: function () { return hash_1.namehash; } });
- var hdnode_1 = _dereq_("@ethersproject/hdnode");
- Object.defineProperty(exports, "defaultPath", { enumerable: true, get: function () { return hdnode_1.defaultPath; } });
- Object.defineProperty(exports, "entropyToMnemonic", { enumerable: true, get: function () { return hdnode_1.entropyToMnemonic; } });
- Object.defineProperty(exports, "getAccountPath", { enumerable: true, get: function () { return hdnode_1.getAccountPath; } });
- Object.defineProperty(exports, "HDNode", { enumerable: true, get: function () { return hdnode_1.HDNode; } });
- Object.defineProperty(exports, "isValidMnemonic", { enumerable: true, get: function () { return hdnode_1.isValidMnemonic; } });
- Object.defineProperty(exports, "mnemonicToEntropy", { enumerable: true, get: function () { return hdnode_1.mnemonicToEntropy; } });
- Object.defineProperty(exports, "mnemonicToSeed", { enumerable: true, get: function () { return hdnode_1.mnemonicToSeed; } });
- var json_wallets_1 = _dereq_("@ethersproject/json-wallets");
- Object.defineProperty(exports, "getJsonWalletAddress", { enumerable: true, get: function () { return json_wallets_1.getJsonWalletAddress; } });
- var keccak256_1 = _dereq_("@ethersproject/keccak256");
- Object.defineProperty(exports, "keccak256", { enumerable: true, get: function () { return keccak256_1.keccak256; } });
- var logger_1 = _dereq_("@ethersproject/logger");
- Object.defineProperty(exports, "Logger", { enumerable: true, get: function () { return logger_1.Logger; } });
- var sha2_1 = _dereq_("@ethersproject/sha2");
- Object.defineProperty(exports, "computeHmac", { enumerable: true, get: function () { return sha2_1.computeHmac; } });
- Object.defineProperty(exports, "ripemd160", { enumerable: true, get: function () { return sha2_1.ripemd160; } });
- Object.defineProperty(exports, "sha256", { enumerable: true, get: function () { return sha2_1.sha256; } });
- Object.defineProperty(exports, "sha512", { enumerable: true, get: function () { return sha2_1.sha512; } });
- var solidity_1 = _dereq_("@ethersproject/solidity");
- Object.defineProperty(exports, "solidityKeccak256", { enumerable: true, get: function () { return solidity_1.keccak256; } });
- Object.defineProperty(exports, "solidityPack", { enumerable: true, get: function () { return solidity_1.pack; } });
- Object.defineProperty(exports, "soliditySha256", { enumerable: true, get: function () { return solidity_1.sha256; } });
- var random_1 = _dereq_("@ethersproject/random");
- Object.defineProperty(exports, "randomBytes", { enumerable: true, get: function () { return random_1.randomBytes; } });
- Object.defineProperty(exports, "shuffled", { enumerable: true, get: function () { return random_1.shuffled; } });
- var properties_1 = _dereq_("@ethersproject/properties");
- Object.defineProperty(exports, "checkProperties", { enumerable: true, get: function () { return properties_1.checkProperties; } });
- Object.defineProperty(exports, "deepCopy", { enumerable: true, get: function () { return properties_1.deepCopy; } });
- Object.defineProperty(exports, "defineReadOnly", { enumerable: true, get: function () { return properties_1.defineReadOnly; } });
- Object.defineProperty(exports, "getStatic", { enumerable: true, get: function () { return properties_1.getStatic; } });
- Object.defineProperty(exports, "resolveProperties", { enumerable: true, get: function () { return properties_1.resolveProperties; } });
- Object.defineProperty(exports, "shallowCopy", { enumerable: true, get: function () { return properties_1.shallowCopy; } });
- var RLP = __importStar(_dereq_("@ethersproject/rlp"));
- exports.RLP = RLP;
- var signing_key_1 = _dereq_("@ethersproject/signing-key");
- Object.defineProperty(exports, "computePublicKey", { enumerable: true, get: function () { return signing_key_1.computePublicKey; } });
- Object.defineProperty(exports, "recoverPublicKey", { enumerable: true, get: function () { return signing_key_1.recoverPublicKey; } });
- Object.defineProperty(exports, "SigningKey", { enumerable: true, get: function () { return signing_key_1.SigningKey; } });
- var strings_1 = _dereq_("@ethersproject/strings");
- Object.defineProperty(exports, "formatBytes32String", { enumerable: true, get: function () { return strings_1.formatBytes32String; } });
- Object.defineProperty(exports, "nameprep", { enumerable: true, get: function () { return strings_1.nameprep; } });
- Object.defineProperty(exports, "parseBytes32String", { enumerable: true, get: function () { return strings_1.parseBytes32String; } });
- Object.defineProperty(exports, "_toEscapedUtf8String", { enumerable: true, get: function () { return strings_1._toEscapedUtf8String; } });
- Object.defineProperty(exports, "toUtf8Bytes", { enumerable: true, get: function () { return strings_1.toUtf8Bytes; } });
- Object.defineProperty(exports, "toUtf8CodePoints", { enumerable: true, get: function () { return strings_1.toUtf8CodePoints; } });
- Object.defineProperty(exports, "toUtf8String", { enumerable: true, get: function () { return strings_1.toUtf8String; } });
- Object.defineProperty(exports, "Utf8ErrorFuncs", { enumerable: true, get: function () { return strings_1.Utf8ErrorFuncs; } });
- var transactions_1 = _dereq_("@ethersproject/transactions");
- Object.defineProperty(exports, "accessListify", { enumerable: true, get: function () { return transactions_1.accessListify; } });
- Object.defineProperty(exports, "computeAddress", { enumerable: true, get: function () { return transactions_1.computeAddress; } });
- Object.defineProperty(exports, "parseTransaction", { enumerable: true, get: function () { return transactions_1.parse; } });
- Object.defineProperty(exports, "recoverAddress", { enumerable: true, get: function () { return transactions_1.recoverAddress; } });
- Object.defineProperty(exports, "serializeTransaction", { enumerable: true, get: function () { return transactions_1.serialize; } });
- Object.defineProperty(exports, "TransactionTypes", { enumerable: true, get: function () { return transactions_1.TransactionTypes; } });
- var units_1 = _dereq_("@ethersproject/units");
- Object.defineProperty(exports, "commify", { enumerable: true, get: function () { return units_1.commify; } });
- Object.defineProperty(exports, "formatEther", { enumerable: true, get: function () { return units_1.formatEther; } });
- Object.defineProperty(exports, "parseEther", { enumerable: true, get: function () { return units_1.parseEther; } });
- Object.defineProperty(exports, "formatUnits", { enumerable: true, get: function () { return units_1.formatUnits; } });
- Object.defineProperty(exports, "parseUnits", { enumerable: true, get: function () { return units_1.parseUnits; } });
- var wallet_1 = _dereq_("@ethersproject/wallet");
- Object.defineProperty(exports, "verifyMessage", { enumerable: true, get: function () { return wallet_1.verifyMessage; } });
- Object.defineProperty(exports, "verifyTypedData", { enumerable: true, get: function () { return wallet_1.verifyTypedData; } });
- var web_1 = _dereq_("@ethersproject/web");
- Object.defineProperty(exports, "_fetchData", { enumerable: true, get: function () { return web_1._fetchData; } });
- Object.defineProperty(exports, "fetchJson", { enumerable: true, get: function () { return web_1.fetchJson; } });
- Object.defineProperty(exports, "poll", { enumerable: true, get: function () { return web_1.poll; } });
- ////////////////////////
- // Enums
- var sha2_2 = _dereq_("@ethersproject/sha2");
- Object.defineProperty(exports, "SupportedAlgorithm", { enumerable: true, get: function () { return sha2_2.SupportedAlgorithm; } });
- var strings_2 = _dereq_("@ethersproject/strings");
- Object.defineProperty(exports, "UnicodeNormalizationForm", { enumerable: true, get: function () { return strings_2.UnicodeNormalizationForm; } });
- Object.defineProperty(exports, "Utf8ErrorReason", { enumerable: true, get: function () { return strings_2.Utf8ErrorReason; } });
- },{"@ethersproject/abi":182,"@ethersproject/address":189,"@ethersproject/base64":191,"@ethersproject/basex":192,"@ethersproject/bytes":199,"@ethersproject/hash":209,"@ethersproject/hdnode":214,"@ethersproject/json-wallets":217,"@ethersproject/keccak256":221,"@ethersproject/logger":223,"@ethersproject/properties":229,"@ethersproject/random":250,"@ethersproject/rlp":253,"@ethersproject/sha2":256,"@ethersproject/signing-key":260,"@ethersproject/solidity":262,"@ethersproject/strings":266,"@ethersproject/transactions":269,"@ethersproject/units":271,"@ethersproject/wallet":273,"@ethersproject/web":276}],775:[function(_dereq_,module,exports){
- // Copyright Joyent, Inc. and other Node contributors.
- //
- // Permission is hereby granted, free of charge, to any person obtaining a
- // copy of this software and associated documentation files (the
- // "Software"), to deal in the Software without restriction, including
- // without limitation the rights to use, copy, modify, merge, publish,
- // distribute, sublicense, and/or sell copies of the Software, and to permit
- // persons to whom the Software is furnished to do so, subject to the
- // following conditions:
- //
- // The above copyright notice and this permission notice shall be included
- // in all copies or substantial portions of the Software.
- //
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
- // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- // USE OR OTHER DEALINGS IN THE SOFTWARE.
- 'use strict';
- var R = typeof Reflect === 'object' ? Reflect : null
- var ReflectApply = R && typeof R.apply === 'function'
- ? R.apply
- : function ReflectApply(target, receiver, args) {
- return Function.prototype.apply.call(target, receiver, args);
- }
- var ReflectOwnKeys
- if (R && typeof R.ownKeys === 'function') {
- ReflectOwnKeys = R.ownKeys
- } else if (Object.getOwnPropertySymbols) {
- ReflectOwnKeys = function ReflectOwnKeys(target) {
- return Object.getOwnPropertyNames(target)
- .concat(Object.getOwnPropertySymbols(target));
- };
- } else {
- ReflectOwnKeys = function ReflectOwnKeys(target) {
- return Object.getOwnPropertyNames(target);
- };
- }
- function ProcessEmitWarning(warning) {
- if (console && console.warn) console.warn(warning);
- }
- var NumberIsNaN = Number.isNaN || function NumberIsNaN(value) {
- return value !== value;
- }
- function EventEmitter() {
- EventEmitter.init.call(this);
- }
- module.exports = EventEmitter;
- module.exports.once = once;
- // Backwards-compat with node 0.10.x
- EventEmitter.EventEmitter = EventEmitter;
- EventEmitter.prototype._events = undefined;
- EventEmitter.prototype._eventsCount = 0;
- EventEmitter.prototype._maxListeners = undefined;
- // By default EventEmitters will print a warning if more than 10 listeners are
- // added to it. This is a useful default which helps finding memory leaks.
- var defaultMaxListeners = 10;
- function checkListener(listener) {
- if (typeof listener !== 'function') {
- throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof listener);
- }
- }
- Object.defineProperty(EventEmitter, 'defaultMaxListeners', {
- enumerable: true,
- get: function() {
- return defaultMaxListeners;
- },
- set: function(arg) {
- if (typeof arg !== 'number' || arg < 0 || NumberIsNaN(arg)) {
- throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + arg + '.');
- }
- defaultMaxListeners = arg;
- }
- });
- EventEmitter.init = function() {
- if (this._events === undefined ||
- this._events === Object.getPrototypeOf(this)._events) {
- this._events = Object.create(null);
- this._eventsCount = 0;
- }
- this._maxListeners = this._maxListeners || undefined;
- };
- // Obviously not all Emitters should be limited to 10. This function allows
- // that to be increased. Set to zero for unlimited.
- EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {
- if (typeof n !== 'number' || n < 0 || NumberIsNaN(n)) {
- throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + n + '.');
- }
- this._maxListeners = n;
- return this;
- };
- function _getMaxListeners(that) {
- if (that._maxListeners === undefined)
- return EventEmitter.defaultMaxListeners;
- return that._maxListeners;
- }
- EventEmitter.prototype.getMaxListeners = function getMaxListeners() {
- return _getMaxListeners(this);
- };
- EventEmitter.prototype.emit = function emit(type) {
- var args = [];
- for (var i = 1; i < arguments.length; i++) args.push(arguments[i]);
- var doError = (type === 'error');
- var events = this._events;
- if (events !== undefined)
- doError = (doError && events.error === undefined);
- else if (!doError)
- return false;
- // If there is no 'error' event listener then throw.
- if (doError) {
- var er;
- if (args.length > 0)
- er = args[0];
- if (er instanceof Error) {
- // Note: The comments on the `throw` lines are intentional, they show
- // up in Node's output if this results in an unhandled exception.
- throw er; // Unhandled 'error' event
- }
- // At least give some kind of context to the user
- var err = new Error('Unhandled error.' + (er ? ' (' + er.message + ')' : ''));
- err.context = er;
- throw err; // Unhandled 'error' event
- }
- var handler = events[type];
- if (handler === undefined)
- return false;
- if (typeof handler === 'function') {
- ReflectApply(handler, this, args);
- } else {
- var len = handler.length;
- var listeners = arrayClone(handler, len);
- for (var i = 0; i < len; ++i)
- ReflectApply(listeners[i], this, args);
- }
- return true;
- };
- function _addListener(target, type, listener, prepend) {
- var m;
- var events;
- var existing;
- checkListener(listener);
- events = target._events;
- if (events === undefined) {
- events = target._events = Object.create(null);
- target._eventsCount = 0;
- } else {
- // To avoid recursion in the case that type === "newListener"! Before
- // adding it to the listeners, first emit "newListener".
- if (events.newListener !== undefined) {
- target.emit('newListener', type,
- listener.listener ? listener.listener : listener);
- // Re-assign `events` because a newListener handler could have caused the
- // this._events to be assigned to a new object
- events = target._events;
- }
- existing = events[type];
- }
- if (existing === undefined) {
- // Optimize the case of one listener. Don't need the extra array object.
- existing = events[type] = listener;
- ++target._eventsCount;
- } else {
- if (typeof existing === 'function') {
- // Adding the second element, need to change to array.
- existing = events[type] =
- prepend ? [listener, existing] : [existing, listener];
- // If we've already got an array, just append.
- } else if (prepend) {
- existing.unshift(listener);
- } else {
- existing.push(listener);
- }
- // Check for listener leak
- m = _getMaxListeners(target);
- if (m > 0 && existing.length > m && !existing.warned) {
- existing.warned = true;
- // No error code for this since it is a Warning
- // eslint-disable-next-line no-restricted-syntax
- var w = new Error('Possible EventEmitter memory leak detected. ' +
- existing.length + ' ' + String(type) + ' listeners ' +
- 'added. Use emitter.setMaxListeners() to ' +
- 'increase limit');
- w.name = 'MaxListenersExceededWarning';
- w.emitter = target;
- w.type = type;
- w.count = existing.length;
- ProcessEmitWarning(w);
- }
- }
- return target;
- }
- EventEmitter.prototype.addListener = function addListener(type, listener) {
- return _addListener(this, type, listener, false);
- };
- EventEmitter.prototype.on = EventEmitter.prototype.addListener;
- EventEmitter.prototype.prependListener =
- function prependListener(type, listener) {
- return _addListener(this, type, listener, true);
- };
- function onceWrapper() {
- if (!this.fired) {
- this.target.removeListener(this.type, this.wrapFn);
- this.fired = true;
- if (arguments.length === 0)
- return this.listener.call(this.target);
- return this.listener.apply(this.target, arguments);
- }
- }
- function _onceWrap(target, type, listener) {
- var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener };
- var wrapped = onceWrapper.bind(state);
- wrapped.listener = listener;
- state.wrapFn = wrapped;
- return wrapped;
- }
- EventEmitter.prototype.once = function once(type, listener) {
- checkListener(listener);
- this.on(type, _onceWrap(this, type, listener));
- return this;
- };
- EventEmitter.prototype.prependOnceListener =
- function prependOnceListener(type, listener) {
- checkListener(listener);
- this.prependListener(type, _onceWrap(this, type, listener));
- return this;
- };
- // Emits a 'removeListener' event if and only if the listener was removed.
- EventEmitter.prototype.removeListener =
- function removeListener(type, listener) {
- var list, events, position, i, originalListener;
- checkListener(listener);
- events = this._events;
- if (events === undefined)
- return this;
- list = events[type];
- if (list === undefined)
- return this;
- if (list === listener || list.listener === listener) {
- if (--this._eventsCount === 0)
- this._events = Object.create(null);
- else {
- delete events[type];
- if (events.removeListener)
- this.emit('removeListener', type, list.listener || listener);
- }
- } else if (typeof list !== 'function') {
- position = -1;
- for (i = list.length - 1; i >= 0; i--) {
- if (list[i] === listener || list[i].listener === listener) {
- originalListener = list[i].listener;
- position = i;
- break;
- }
- }
- if (position < 0)
- return this;
- if (position === 0)
- list.shift();
- else {
- spliceOne(list, position);
- }
- if (list.length === 1)
- events[type] = list[0];
- if (events.removeListener !== undefined)
- this.emit('removeListener', type, originalListener || listener);
- }
- return this;
- };
- EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
- EventEmitter.prototype.removeAllListeners =
- function removeAllListeners(type) {
- var listeners, events, i;
- events = this._events;
- if (events === undefined)
- return this;
- // not listening for removeListener, no need to emit
- if (events.removeListener === undefined) {
- if (arguments.length === 0) {
- this._events = Object.create(null);
- this._eventsCount = 0;
- } else if (events[type] !== undefined) {
- if (--this._eventsCount === 0)
- this._events = Object.create(null);
- else
- delete events[type];
- }
- return this;
- }
- // emit removeListener for all listeners on all events
- if (arguments.length === 0) {
- var keys = Object.keys(events);
- var key;
- for (i = 0; i < keys.length; ++i) {
- key = keys[i];
- if (key === 'removeListener') continue;
- this.removeAllListeners(key);
- }
- this.removeAllListeners('removeListener');
- this._events = Object.create(null);
- this._eventsCount = 0;
- return this;
- }
- listeners = events[type];
- if (typeof listeners === 'function') {
- this.removeListener(type, listeners);
- } else if (listeners !== undefined) {
- // LIFO order
- for (i = listeners.length - 1; i >= 0; i--) {
- this.removeListener(type, listeners[i]);
- }
- }
- return this;
- };
- function _listeners(target, type, unwrap) {
- var events = target._events;
- if (events === undefined)
- return [];
- var evlistener = events[type];
- if (evlistener === undefined)
- return [];
- if (typeof evlistener === 'function')
- return unwrap ? [evlistener.listener || evlistener] : [evlistener];
- return unwrap ?
- unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);
- }
- EventEmitter.prototype.listeners = function listeners(type) {
- return _listeners(this, type, true);
- };
- EventEmitter.prototype.rawListeners = function rawListeners(type) {
- return _listeners(this, type, false);
- };
- EventEmitter.listenerCount = function(emitter, type) {
- if (typeof emitter.listenerCount === 'function') {
- return emitter.listenerCount(type);
- } else {
- return listenerCount.call(emitter, type);
- }
- };
- EventEmitter.prototype.listenerCount = listenerCount;
- function listenerCount(type) {
- var events = this._events;
- if (events !== undefined) {
- var evlistener = events[type];
- if (typeof evlistener === 'function') {
- return 1;
- } else if (evlistener !== undefined) {
- return evlistener.length;
- }
- }
- return 0;
- }
- EventEmitter.prototype.eventNames = function eventNames() {
- return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : [];
- };
- function arrayClone(arr, n) {
- var copy = new Array(n);
- for (var i = 0; i < n; ++i)
- copy[i] = arr[i];
- return copy;
- }
- function spliceOne(list, index) {
- for (; index + 1 < list.length; index++)
- list[index] = list[index + 1];
- list.pop();
- }
- function unwrapListeners(arr) {
- var ret = new Array(arr.length);
- for (var i = 0; i < ret.length; ++i) {
- ret[i] = arr[i].listener || arr[i];
- }
- return ret;
- }
- function once(emitter, name) {
- return new Promise(function (resolve, reject) {
- function errorListener(err) {
- emitter.removeListener(name, resolver);
- reject(err);
- }
- function resolver() {
- if (typeof emitter.removeListener === 'function') {
- emitter.removeListener('error', errorListener);
- }
- resolve([].slice.call(arguments));
- };
- eventTargetAgnosticAddListener(emitter, name, resolver, { once: true });
- if (name !== 'error') {
- addErrorHandlerIfEventEmitter(emitter, errorListener, { once: true });
- }
- });
- }
- function addErrorHandlerIfEventEmitter(emitter, handler, flags) {
- if (typeof emitter.on === 'function') {
- eventTargetAgnosticAddListener(emitter, 'error', handler, flags);
- }
- }
- function eventTargetAgnosticAddListener(emitter, name, listener, flags) {
- if (typeof emitter.on === 'function') {
- if (flags.once) {
- emitter.once(name, listener);
- } else {
- emitter.on(name, listener);
- }
- } else if (typeof emitter.addEventListener === 'function') {
- // EventTarget does not have `error` event semantics like Node
- // EventEmitters, we do not listen for `error` events here.
- emitter.addEventListener(name, function wrapListener(arg) {
- // IE does not have builtin `{ once: true }` support so we
- // have to do it manually.
- if (flags.once) {
- emitter.removeEventListener(name, wrapListener);
- }
- listener(arg);
- });
- } else {
- throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type ' + typeof emitter);
- }
- }
- },{}],776:[function(_dereq_,module,exports){
- var hash = exports;
- hash.utils = _dereq_('./hash/utils');
- hash.common = _dereq_('./hash/common');
- hash.sha = _dereq_('./hash/sha');
- hash.ripemd = _dereq_('./hash/ripemd');
- hash.hmac = _dereq_('./hash/hmac');
- // Proxy hash functions to the main object
- hash.sha1 = hash.sha.sha1;
- hash.sha256 = hash.sha.sha256;
- hash.sha224 = hash.sha.sha224;
- hash.sha384 = hash.sha.sha384;
- hash.sha512 = hash.sha.sha512;
- hash.ripemd160 = hash.ripemd.ripemd160;
- },{"./hash/common":777,"./hash/hmac":778,"./hash/ripemd":779,"./hash/sha":780,"./hash/utils":787}],777:[function(_dereq_,module,exports){
- 'use strict';
- var utils = _dereq_('./utils');
- var assert = _dereq_('minimalistic-assert');
- function BlockHash() {
- this.pending = null;
- this.pendingTotal = 0;
- this.blockSize = this.constructor.blockSize;
- this.outSize = this.constructor.outSize;
- this.hmacStrength = this.constructor.hmacStrength;
- this.padLength = this.constructor.padLength / 8;
- this.endian = 'big';
- this._delta8 = this.blockSize / 8;
- this._delta32 = this.blockSize / 32;
- }
- exports.BlockHash = BlockHash;
- BlockHash.prototype.update = function update(msg, enc) {
- // Convert message to array, pad it, and join into 32bit blocks
- msg = utils.toArray(msg, enc);
- if (!this.pending)
- this.pending = msg;
- else
- this.pending = this.pending.concat(msg);
- this.pendingTotal += msg.length;
- // Enough data, try updating
- if (this.pending.length >= this._delta8) {
- msg = this.pending;
- // Process pending data in blocks
- var r = msg.length % this._delta8;
- this.pending = msg.slice(msg.length - r, msg.length);
- if (this.pending.length === 0)
- this.pending = null;
- msg = utils.join32(msg, 0, msg.length - r, this.endian);
- for (var i = 0; i < msg.length; i += this._delta32)
- this._update(msg, i, i + this._delta32);
- }
- return this;
- };
- BlockHash.prototype.digest = function digest(enc) {
- this.update(this._pad());
- assert(this.pending === null);
- return this._digest(enc);
- };
- BlockHash.prototype._pad = function pad() {
- var len = this.pendingTotal;
- var bytes = this._delta8;
- var k = bytes - ((len + this.padLength) % bytes);
- var res = new Array(k + this.padLength);
- res[0] = 0x80;
- for (var i = 1; i < k; i++)
- res[i] = 0;
- // Append length
- len <<= 3;
- if (this.endian === 'big') {
- for (var t = 8; t < this.padLength; t++)
- res[i++] = 0;
- res[i++] = 0;
- res[i++] = 0;
- res[i++] = 0;
- res[i++] = 0;
- res[i++] = (len >>> 24) & 0xff;
- res[i++] = (len >>> 16) & 0xff;
- res[i++] = (len >>> 8) & 0xff;
- res[i++] = len & 0xff;
- } else {
- res[i++] = len & 0xff;
- res[i++] = (len >>> 8) & 0xff;
- res[i++] = (len >>> 16) & 0xff;
- res[i++] = (len >>> 24) & 0xff;
- res[i++] = 0;
- res[i++] = 0;
- res[i++] = 0;
- res[i++] = 0;
- for (t = 8; t < this.padLength; t++)
- res[i++] = 0;
- }
- return res;
- };
- },{"./utils":787,"minimalistic-assert":791}],778:[function(_dereq_,module,exports){
- 'use strict';
- var utils = _dereq_('./utils');
- var assert = _dereq_('minimalistic-assert');
- function Hmac(hash, key, enc) {
- if (!(this instanceof Hmac))
- return new Hmac(hash, key, enc);
- this.Hash = hash;
- this.blockSize = hash.blockSize / 8;
- this.outSize = hash.outSize / 8;
- this.inner = null;
- this.outer = null;
- this._init(utils.toArray(key, enc));
- }
- module.exports = Hmac;
- Hmac.prototype._init = function init(key) {
- // Shorten key, if needed
- if (key.length > this.blockSize)
- key = new this.Hash().update(key).digest();
- assert(key.length <= this.blockSize);
- // Add padding to key
- for (var i = key.length; i < this.blockSize; i++)
- key.push(0);
- for (i = 0; i < key.length; i++)
- key[i] ^= 0x36;
- this.inner = new this.Hash().update(key);
- // 0x36 ^ 0x5c = 0x6a
- for (i = 0; i < key.length; i++)
- key[i] ^= 0x6a;
- this.outer = new this.Hash().update(key);
- };
- Hmac.prototype.update = function update(msg, enc) {
- this.inner.update(msg, enc);
- return this;
- };
- Hmac.prototype.digest = function digest(enc) {
- this.outer.update(this.inner.digest());
- return this.outer.digest(enc);
- };
- },{"./utils":787,"minimalistic-assert":791}],779:[function(_dereq_,module,exports){
- 'use strict';
- var utils = _dereq_('./utils');
- var common = _dereq_('./common');
- var rotl32 = utils.rotl32;
- var sum32 = utils.sum32;
- var sum32_3 = utils.sum32_3;
- var sum32_4 = utils.sum32_4;
- var BlockHash = common.BlockHash;
- function RIPEMD160() {
- if (!(this instanceof RIPEMD160))
- return new RIPEMD160();
- BlockHash.call(this);
- this.h = [ 0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0 ];
- this.endian = 'little';
- }
- utils.inherits(RIPEMD160, BlockHash);
- exports.ripemd160 = RIPEMD160;
- RIPEMD160.blockSize = 512;
- RIPEMD160.outSize = 160;
- RIPEMD160.hmacStrength = 192;
- RIPEMD160.padLength = 64;
- RIPEMD160.prototype._update = function update(msg, start) {
- var A = this.h[0];
- var B = this.h[1];
- var C = this.h[2];
- var D = this.h[3];
- var E = this.h[4];
- var Ah = A;
- var Bh = B;
- var Ch = C;
- var Dh = D;
- var Eh = E;
- for (var j = 0; j < 80; j++) {
- var T = sum32(
- rotl32(
- sum32_4(A, f(j, B, C, D), msg[r[j] + start], K(j)),
- s[j]),
- E);
- A = E;
- E = D;
- D = rotl32(C, 10);
- C = B;
- B = T;
- T = sum32(
- rotl32(
- sum32_4(Ah, f(79 - j, Bh, Ch, Dh), msg[rh[j] + start], Kh(j)),
- sh[j]),
- Eh);
- Ah = Eh;
- Eh = Dh;
- Dh = rotl32(Ch, 10);
- Ch = Bh;
- Bh = T;
- }
- T = sum32_3(this.h[1], C, Dh);
- this.h[1] = sum32_3(this.h[2], D, Eh);
- this.h[2] = sum32_3(this.h[3], E, Ah);
- this.h[3] = sum32_3(this.h[4], A, Bh);
- this.h[4] = sum32_3(this.h[0], B, Ch);
- this.h[0] = T;
- };
- RIPEMD160.prototype._digest = function digest(enc) {
- if (enc === 'hex')
- return utils.toHex32(this.h, 'little');
- else
- return utils.split32(this.h, 'little');
- };
- function f(j, x, y, z) {
- if (j <= 15)
- return x ^ y ^ z;
- else if (j <= 31)
- return (x & y) | ((~x) & z);
- else if (j <= 47)
- return (x | (~y)) ^ z;
- else if (j <= 63)
- return (x & z) | (y & (~z));
- else
- return x ^ (y | (~z));
- }
- function K(j) {
- if (j <= 15)
- return 0x00000000;
- else if (j <= 31)
- return 0x5a827999;
- else if (j <= 47)
- return 0x6ed9eba1;
- else if (j <= 63)
- return 0x8f1bbcdc;
- else
- return 0xa953fd4e;
- }
- function Kh(j) {
- if (j <= 15)
- return 0x50a28be6;
- else if (j <= 31)
- return 0x5c4dd124;
- else if (j <= 47)
- return 0x6d703ef3;
- else if (j <= 63)
- return 0x7a6d76e9;
- else
- return 0x00000000;
- }
- var r = [
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8,
- 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12,
- 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2,
- 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13
- ];
- var rh = [
- 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12,
- 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2,
- 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13,
- 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14,
- 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11
- ];
- var s = [
- 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8,
- 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12,
- 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5,
- 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12,
- 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6
- ];
- var sh = [
- 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6,
- 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11,
- 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5,
- 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8,
- 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11
- ];
- },{"./common":777,"./utils":787}],780:[function(_dereq_,module,exports){
- 'use strict';
- exports.sha1 = _dereq_('./sha/1');
- exports.sha224 = _dereq_('./sha/224');
- exports.sha256 = _dereq_('./sha/256');
- exports.sha384 = _dereq_('./sha/384');
- exports.sha512 = _dereq_('./sha/512');
- },{"./sha/1":781,"./sha/224":782,"./sha/256":783,"./sha/384":784,"./sha/512":785}],781:[function(_dereq_,module,exports){
- 'use strict';
- var utils = _dereq_('../utils');
- var common = _dereq_('../common');
- var shaCommon = _dereq_('./common');
- var rotl32 = utils.rotl32;
- var sum32 = utils.sum32;
- var sum32_5 = utils.sum32_5;
- var ft_1 = shaCommon.ft_1;
- var BlockHash = common.BlockHash;
- var sha1_K = [
- 0x5A827999, 0x6ED9EBA1,
- 0x8F1BBCDC, 0xCA62C1D6
- ];
- function SHA1() {
- if (!(this instanceof SHA1))
- return new SHA1();
- BlockHash.call(this);
- this.h = [
- 0x67452301, 0xefcdab89, 0x98badcfe,
- 0x10325476, 0xc3d2e1f0 ];
- this.W = new Array(80);
- }
- utils.inherits(SHA1, BlockHash);
- module.exports = SHA1;
- SHA1.blockSize = 512;
- SHA1.outSize = 160;
- SHA1.hmacStrength = 80;
- SHA1.padLength = 64;
- SHA1.prototype._update = function _update(msg, start) {
- var W = this.W;
- for (var i = 0; i < 16; i++)
- W[i] = msg[start + i];
- for(; i < W.length; i++)
- W[i] = rotl32(W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16], 1);
- var a = this.h[0];
- var b = this.h[1];
- var c = this.h[2];
- var d = this.h[3];
- var e = this.h[4];
- for (i = 0; i < W.length; i++) {
- var s = ~~(i / 20);
- var t = sum32_5(rotl32(a, 5), ft_1(s, b, c, d), e, W[i], sha1_K[s]);
- e = d;
- d = c;
- c = rotl32(b, 30);
- b = a;
- a = t;
- }
- this.h[0] = sum32(this.h[0], a);
- this.h[1] = sum32(this.h[1], b);
- this.h[2] = sum32(this.h[2], c);
- this.h[3] = sum32(this.h[3], d);
- this.h[4] = sum32(this.h[4], e);
- };
- SHA1.prototype._digest = function digest(enc) {
- if (enc === 'hex')
- return utils.toHex32(this.h, 'big');
- else
- return utils.split32(this.h, 'big');
- };
- },{"../common":777,"../utils":787,"./common":786}],782:[function(_dereq_,module,exports){
- 'use strict';
- var utils = _dereq_('../utils');
- var SHA256 = _dereq_('./256');
- function SHA224() {
- if (!(this instanceof SHA224))
- return new SHA224();
- SHA256.call(this);
- this.h = [
- 0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939,
- 0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4 ];
- }
- utils.inherits(SHA224, SHA256);
- module.exports = SHA224;
- SHA224.blockSize = 512;
- SHA224.outSize = 224;
- SHA224.hmacStrength = 192;
- SHA224.padLength = 64;
- SHA224.prototype._digest = function digest(enc) {
- // Just truncate output
- if (enc === 'hex')
- return utils.toHex32(this.h.slice(0, 7), 'big');
- else
- return utils.split32(this.h.slice(0, 7), 'big');
- };
- },{"../utils":787,"./256":783}],783:[function(_dereq_,module,exports){
- 'use strict';
- var utils = _dereq_('../utils');
- var common = _dereq_('../common');
- var shaCommon = _dereq_('./common');
- var assert = _dereq_('minimalistic-assert');
- var sum32 = utils.sum32;
- var sum32_4 = utils.sum32_4;
- var sum32_5 = utils.sum32_5;
- var ch32 = shaCommon.ch32;
- var maj32 = shaCommon.maj32;
- var s0_256 = shaCommon.s0_256;
- var s1_256 = shaCommon.s1_256;
- var g0_256 = shaCommon.g0_256;
- var g1_256 = shaCommon.g1_256;
- var BlockHash = common.BlockHash;
- var sha256_K = [
- 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
- 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
- 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
- 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
- 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,
- 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
- 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,
- 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
- 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
- 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
- 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3,
- 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
- 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5,
- 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
- 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
- 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
- ];
- function SHA256() {
- if (!(this instanceof SHA256))
- return new SHA256();
- BlockHash.call(this);
- this.h = [
- 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a,
- 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19
- ];
- this.k = sha256_K;
- this.W = new Array(64);
- }
- utils.inherits(SHA256, BlockHash);
- module.exports = SHA256;
- SHA256.blockSize = 512;
- SHA256.outSize = 256;
- SHA256.hmacStrength = 192;
- SHA256.padLength = 64;
- SHA256.prototype._update = function _update(msg, start) {
- var W = this.W;
- for (var i = 0; i < 16; i++)
- W[i] = msg[start + i];
- for (; i < W.length; i++)
- W[i] = sum32_4(g1_256(W[i - 2]), W[i - 7], g0_256(W[i - 15]), W[i - 16]);
- var a = this.h[0];
- var b = this.h[1];
- var c = this.h[2];
- var d = this.h[3];
- var e = this.h[4];
- var f = this.h[5];
- var g = this.h[6];
- var h = this.h[7];
- assert(this.k.length === W.length);
- for (i = 0; i < W.length; i++) {
- var T1 = sum32_5(h, s1_256(e), ch32(e, f, g), this.k[i], W[i]);
- var T2 = sum32(s0_256(a), maj32(a, b, c));
- h = g;
- g = f;
- f = e;
- e = sum32(d, T1);
- d = c;
- c = b;
- b = a;
- a = sum32(T1, T2);
- }
- this.h[0] = sum32(this.h[0], a);
- this.h[1] = sum32(this.h[1], b);
- this.h[2] = sum32(this.h[2], c);
- this.h[3] = sum32(this.h[3], d);
- this.h[4] = sum32(this.h[4], e);
- this.h[5] = sum32(this.h[5], f);
- this.h[6] = sum32(this.h[6], g);
- this.h[7] = sum32(this.h[7], h);
- };
- SHA256.prototype._digest = function digest(enc) {
- if (enc === 'hex')
- return utils.toHex32(this.h, 'big');
- else
- return utils.split32(this.h, 'big');
- };
- },{"../common":777,"../utils":787,"./common":786,"minimalistic-assert":791}],784:[function(_dereq_,module,exports){
- 'use strict';
- var utils = _dereq_('../utils');
- var SHA512 = _dereq_('./512');
- function SHA384() {
- if (!(this instanceof SHA384))
- return new SHA384();
- SHA512.call(this);
- this.h = [
- 0xcbbb9d5d, 0xc1059ed8,
- 0x629a292a, 0x367cd507,
- 0x9159015a, 0x3070dd17,
- 0x152fecd8, 0xf70e5939,
- 0x67332667, 0xffc00b31,
- 0x8eb44a87, 0x68581511,
- 0xdb0c2e0d, 0x64f98fa7,
- 0x47b5481d, 0xbefa4fa4 ];
- }
- utils.inherits(SHA384, SHA512);
- module.exports = SHA384;
- SHA384.blockSize = 1024;
- SHA384.outSize = 384;
- SHA384.hmacStrength = 192;
- SHA384.padLength = 128;
- SHA384.prototype._digest = function digest(enc) {
- if (enc === 'hex')
- return utils.toHex32(this.h.slice(0, 12), 'big');
- else
- return utils.split32(this.h.slice(0, 12), 'big');
- };
- },{"../utils":787,"./512":785}],785:[function(_dereq_,module,exports){
- 'use strict';
- var utils = _dereq_('../utils');
- var common = _dereq_('../common');
- var assert = _dereq_('minimalistic-assert');
- var rotr64_hi = utils.rotr64_hi;
- var rotr64_lo = utils.rotr64_lo;
- var shr64_hi = utils.shr64_hi;
- var shr64_lo = utils.shr64_lo;
- var sum64 = utils.sum64;
- var sum64_hi = utils.sum64_hi;
- var sum64_lo = utils.sum64_lo;
- var sum64_4_hi = utils.sum64_4_hi;
- var sum64_4_lo = utils.sum64_4_lo;
- var sum64_5_hi = utils.sum64_5_hi;
- var sum64_5_lo = utils.sum64_5_lo;
- var BlockHash = common.BlockHash;
- var sha512_K = [
- 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,
- 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,
- 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,
- 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,
- 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,
- 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,
- 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,
- 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,
- 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,
- 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,
- 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,
- 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,
- 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,
- 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,
- 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,
- 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,
- 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,
- 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,
- 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,
- 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,
- 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,
- 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,
- 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,
- 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,
- 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,
- 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,
- 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,
- 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,
- 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,
- 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,
- 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,
- 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,
- 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,
- 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,
- 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,
- 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,
- 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,
- 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,
- 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,
- 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817
- ];
- function SHA512() {
- if (!(this instanceof SHA512))
- return new SHA512();
- BlockHash.call(this);
- this.h = [
- 0x6a09e667, 0xf3bcc908,
- 0xbb67ae85, 0x84caa73b,
- 0x3c6ef372, 0xfe94f82b,
- 0xa54ff53a, 0x5f1d36f1,
- 0x510e527f, 0xade682d1,
- 0x9b05688c, 0x2b3e6c1f,
- 0x1f83d9ab, 0xfb41bd6b,
- 0x5be0cd19, 0x137e2179 ];
- this.k = sha512_K;
- this.W = new Array(160);
- }
- utils.inherits(SHA512, BlockHash);
- module.exports = SHA512;
- SHA512.blockSize = 1024;
- SHA512.outSize = 512;
- SHA512.hmacStrength = 192;
- SHA512.padLength = 128;
- SHA512.prototype._prepareBlock = function _prepareBlock(msg, start) {
- var W = this.W;
- // 32 x 32bit words
- for (var i = 0; i < 32; i++)
- W[i] = msg[start + i];
- for (; i < W.length; i += 2) {
- var c0_hi = g1_512_hi(W[i - 4], W[i - 3]); // i - 2
- var c0_lo = g1_512_lo(W[i - 4], W[i - 3]);
- var c1_hi = W[i - 14]; // i - 7
- var c1_lo = W[i - 13];
- var c2_hi = g0_512_hi(W[i - 30], W[i - 29]); // i - 15
- var c2_lo = g0_512_lo(W[i - 30], W[i - 29]);
- var c3_hi = W[i - 32]; // i - 16
- var c3_lo = W[i - 31];
- W[i] = sum64_4_hi(
- c0_hi, c0_lo,
- c1_hi, c1_lo,
- c2_hi, c2_lo,
- c3_hi, c3_lo);
- W[i + 1] = sum64_4_lo(
- c0_hi, c0_lo,
- c1_hi, c1_lo,
- c2_hi, c2_lo,
- c3_hi, c3_lo);
- }
- };
- SHA512.prototype._update = function _update(msg, start) {
- this._prepareBlock(msg, start);
- var W = this.W;
- var ah = this.h[0];
- var al = this.h[1];
- var bh = this.h[2];
- var bl = this.h[3];
- var ch = this.h[4];
- var cl = this.h[5];
- var dh = this.h[6];
- var dl = this.h[7];
- var eh = this.h[8];
- var el = this.h[9];
- var fh = this.h[10];
- var fl = this.h[11];
- var gh = this.h[12];
- var gl = this.h[13];
- var hh = this.h[14];
- var hl = this.h[15];
- assert(this.k.length === W.length);
- for (var i = 0; i < W.length; i += 2) {
- var c0_hi = hh;
- var c0_lo = hl;
- var c1_hi = s1_512_hi(eh, el);
- var c1_lo = s1_512_lo(eh, el);
- var c2_hi = ch64_hi(eh, el, fh, fl, gh, gl);
- var c2_lo = ch64_lo(eh, el, fh, fl, gh, gl);
- var c3_hi = this.k[i];
- var c3_lo = this.k[i + 1];
- var c4_hi = W[i];
- var c4_lo = W[i + 1];
- var T1_hi = sum64_5_hi(
- c0_hi, c0_lo,
- c1_hi, c1_lo,
- c2_hi, c2_lo,
- c3_hi, c3_lo,
- c4_hi, c4_lo);
- var T1_lo = sum64_5_lo(
- c0_hi, c0_lo,
- c1_hi, c1_lo,
- c2_hi, c2_lo,
- c3_hi, c3_lo,
- c4_hi, c4_lo);
- c0_hi = s0_512_hi(ah, al);
- c0_lo = s0_512_lo(ah, al);
- c1_hi = maj64_hi(ah, al, bh, bl, ch, cl);
- c1_lo = maj64_lo(ah, al, bh, bl, ch, cl);
- var T2_hi = sum64_hi(c0_hi, c0_lo, c1_hi, c1_lo);
- var T2_lo = sum64_lo(c0_hi, c0_lo, c1_hi, c1_lo);
- hh = gh;
- hl = gl;
- gh = fh;
- gl = fl;
- fh = eh;
- fl = el;
- eh = sum64_hi(dh, dl, T1_hi, T1_lo);
- el = sum64_lo(dl, dl, T1_hi, T1_lo);
- dh = ch;
- dl = cl;
- ch = bh;
- cl = bl;
- bh = ah;
- bl = al;
- ah = sum64_hi(T1_hi, T1_lo, T2_hi, T2_lo);
- al = sum64_lo(T1_hi, T1_lo, T2_hi, T2_lo);
- }
- sum64(this.h, 0, ah, al);
- sum64(this.h, 2, bh, bl);
- sum64(this.h, 4, ch, cl);
- sum64(this.h, 6, dh, dl);
- sum64(this.h, 8, eh, el);
- sum64(this.h, 10, fh, fl);
- sum64(this.h, 12, gh, gl);
- sum64(this.h, 14, hh, hl);
- };
- SHA512.prototype._digest = function digest(enc) {
- if (enc === 'hex')
- return utils.toHex32(this.h, 'big');
- else
- return utils.split32(this.h, 'big');
- };
- function ch64_hi(xh, xl, yh, yl, zh) {
- var r = (xh & yh) ^ ((~xh) & zh);
- if (r < 0)
- r += 0x100000000;
- return r;
- }
- function ch64_lo(xh, xl, yh, yl, zh, zl) {
- var r = (xl & yl) ^ ((~xl) & zl);
- if (r < 0)
- r += 0x100000000;
- return r;
- }
- function maj64_hi(xh, xl, yh, yl, zh) {
- var r = (xh & yh) ^ (xh & zh) ^ (yh & zh);
- if (r < 0)
- r += 0x100000000;
- return r;
- }
- function maj64_lo(xh, xl, yh, yl, zh, zl) {
- var r = (xl & yl) ^ (xl & zl) ^ (yl & zl);
- if (r < 0)
- r += 0x100000000;
- return r;
- }
- function s0_512_hi(xh, xl) {
- var c0_hi = rotr64_hi(xh, xl, 28);
- var c1_hi = rotr64_hi(xl, xh, 2); // 34
- var c2_hi = rotr64_hi(xl, xh, 7); // 39
- var r = c0_hi ^ c1_hi ^ c2_hi;
- if (r < 0)
- r += 0x100000000;
- return r;
- }
- function s0_512_lo(xh, xl) {
- var c0_lo = rotr64_lo(xh, xl, 28);
- var c1_lo = rotr64_lo(xl, xh, 2); // 34
- var c2_lo = rotr64_lo(xl, xh, 7); // 39
- var r = c0_lo ^ c1_lo ^ c2_lo;
- if (r < 0)
- r += 0x100000000;
- return r;
- }
- function s1_512_hi(xh, xl) {
- var c0_hi = rotr64_hi(xh, xl, 14);
- var c1_hi = rotr64_hi(xh, xl, 18);
- var c2_hi = rotr64_hi(xl, xh, 9); // 41
- var r = c0_hi ^ c1_hi ^ c2_hi;
- if (r < 0)
- r += 0x100000000;
- return r;
- }
- function s1_512_lo(xh, xl) {
- var c0_lo = rotr64_lo(xh, xl, 14);
- var c1_lo = rotr64_lo(xh, xl, 18);
- var c2_lo = rotr64_lo(xl, xh, 9); // 41
- var r = c0_lo ^ c1_lo ^ c2_lo;
- if (r < 0)
- r += 0x100000000;
- return r;
- }
- function g0_512_hi(xh, xl) {
- var c0_hi = rotr64_hi(xh, xl, 1);
- var c1_hi = rotr64_hi(xh, xl, 8);
- var c2_hi = shr64_hi(xh, xl, 7);
- var r = c0_hi ^ c1_hi ^ c2_hi;
- if (r < 0)
- r += 0x100000000;
- return r;
- }
- function g0_512_lo(xh, xl) {
- var c0_lo = rotr64_lo(xh, xl, 1);
- var c1_lo = rotr64_lo(xh, xl, 8);
- var c2_lo = shr64_lo(xh, xl, 7);
- var r = c0_lo ^ c1_lo ^ c2_lo;
- if (r < 0)
- r += 0x100000000;
- return r;
- }
- function g1_512_hi(xh, xl) {
- var c0_hi = rotr64_hi(xh, xl, 19);
- var c1_hi = rotr64_hi(xl, xh, 29); // 61
- var c2_hi = shr64_hi(xh, xl, 6);
- var r = c0_hi ^ c1_hi ^ c2_hi;
- if (r < 0)
- r += 0x100000000;
- return r;
- }
- function g1_512_lo(xh, xl) {
- var c0_lo = rotr64_lo(xh, xl, 19);
- var c1_lo = rotr64_lo(xl, xh, 29); // 61
- var c2_lo = shr64_lo(xh, xl, 6);
- var r = c0_lo ^ c1_lo ^ c2_lo;
- if (r < 0)
- r += 0x100000000;
- return r;
- }
- },{"../common":777,"../utils":787,"minimalistic-assert":791}],786:[function(_dereq_,module,exports){
- 'use strict';
- var utils = _dereq_('../utils');
- var rotr32 = utils.rotr32;
- function ft_1(s, x, y, z) {
- if (s === 0)
- return ch32(x, y, z);
- if (s === 1 || s === 3)
- return p32(x, y, z);
- if (s === 2)
- return maj32(x, y, z);
- }
- exports.ft_1 = ft_1;
- function ch32(x, y, z) {
- return (x & y) ^ ((~x) & z);
- }
- exports.ch32 = ch32;
- function maj32(x, y, z) {
- return (x & y) ^ (x & z) ^ (y & z);
- }
- exports.maj32 = maj32;
- function p32(x, y, z) {
- return x ^ y ^ z;
- }
- exports.p32 = p32;
- function s0_256(x) {
- return rotr32(x, 2) ^ rotr32(x, 13) ^ rotr32(x, 22);
- }
- exports.s0_256 = s0_256;
- function s1_256(x) {
- return rotr32(x, 6) ^ rotr32(x, 11) ^ rotr32(x, 25);
- }
- exports.s1_256 = s1_256;
- function g0_256(x) {
- return rotr32(x, 7) ^ rotr32(x, 18) ^ (x >>> 3);
- }
- exports.g0_256 = g0_256;
- function g1_256(x) {
- return rotr32(x, 17) ^ rotr32(x, 19) ^ (x >>> 10);
- }
- exports.g1_256 = g1_256;
- },{"../utils":787}],787:[function(_dereq_,module,exports){
- 'use strict';
- var assert = _dereq_('minimalistic-assert');
- var inherits = _dereq_('inherits');
- exports.inherits = inherits;
- function isSurrogatePair(msg, i) {
- if ((msg.charCodeAt(i) & 0xFC00) !== 0xD800) {
- return false;
- }
- if (i < 0 || i + 1 >= msg.length) {
- return false;
- }
- return (msg.charCodeAt(i + 1) & 0xFC00) === 0xDC00;
- }
- function toArray(msg, enc) {
- if (Array.isArray(msg))
- return msg.slice();
- if (!msg)
- return [];
- var res = [];
- if (typeof msg === 'string') {
- if (!enc) {
- // Inspired by stringToUtf8ByteArray() in closure-library by Google
- // https://github.com/google/closure-library/blob/8598d87242af59aac233270742c8984e2b2bdbe0/closure/goog/crypt/crypt.js#L117-L143
- // Apache License 2.0
- // https://github.com/google/closure-library/blob/master/LICENSE
- var p = 0;
- for (var i = 0; i < msg.length; i++) {
- var c = msg.charCodeAt(i);
- if (c < 128) {
- res[p++] = c;
- } else if (c < 2048) {
- res[p++] = (c >> 6) | 192;
- res[p++] = (c & 63) | 128;
- } else if (isSurrogatePair(msg, i)) {
- c = 0x10000 + ((c & 0x03FF) << 10) + (msg.charCodeAt(++i) & 0x03FF);
- res[p++] = (c >> 18) | 240;
- res[p++] = ((c >> 12) & 63) | 128;
- res[p++] = ((c >> 6) & 63) | 128;
- res[p++] = (c & 63) | 128;
- } else {
- res[p++] = (c >> 12) | 224;
- res[p++] = ((c >> 6) & 63) | 128;
- res[p++] = (c & 63) | 128;
- }
- }
- } else if (enc === 'hex') {
- msg = msg.replace(/[^a-z0-9]+/ig, '');
- if (msg.length % 2 !== 0)
- msg = '0' + msg;
- for (i = 0; i < msg.length; i += 2)
- res.push(parseInt(msg[i] + msg[i + 1], 16));
- }
- } else {
- for (i = 0; i < msg.length; i++)
- res[i] = msg[i] | 0;
- }
- return res;
- }
- exports.toArray = toArray;
- function toHex(msg) {
- var res = '';
- for (var i = 0; i < msg.length; i++)
- res += zero2(msg[i].toString(16));
- return res;
- }
- exports.toHex = toHex;
- function htonl(w) {
- var res = (w >>> 24) |
- ((w >>> 8) & 0xff00) |
- ((w << 8) & 0xff0000) |
- ((w & 0xff) << 24);
- return res >>> 0;
- }
- exports.htonl = htonl;
- function toHex32(msg, endian) {
- var res = '';
- for (var i = 0; i < msg.length; i++) {
- var w = msg[i];
- if (endian === 'little')
- w = htonl(w);
- res += zero8(w.toString(16));
- }
- return res;
- }
- exports.toHex32 = toHex32;
- function zero2(word) {
- if (word.length === 1)
- return '0' + word;
- else
- return word;
- }
- exports.zero2 = zero2;
- function zero8(word) {
- if (word.length === 7)
- return '0' + word;
- else if (word.length === 6)
- return '00' + word;
- else if (word.length === 5)
- return '000' + word;
- else if (word.length === 4)
- return '0000' + word;
- else if (word.length === 3)
- return '00000' + word;
- else if (word.length === 2)
- return '000000' + word;
- else if (word.length === 1)
- return '0000000' + word;
- else
- return word;
- }
- exports.zero8 = zero8;
- function join32(msg, start, end, endian) {
- var len = end - start;
- assert(len % 4 === 0);
- var res = new Array(len / 4);
- for (var i = 0, k = start; i < res.length; i++, k += 4) {
- var w;
- if (endian === 'big')
- w = (msg[k] << 24) | (msg[k + 1] << 16) | (msg[k + 2] << 8) | msg[k + 3];
- else
- w = (msg[k + 3] << 24) | (msg[k + 2] << 16) | (msg[k + 1] << 8) | msg[k];
- res[i] = w >>> 0;
- }
- return res;
- }
- exports.join32 = join32;
- function split32(msg, endian) {
- var res = new Array(msg.length * 4);
- for (var i = 0, k = 0; i < msg.length; i++, k += 4) {
- var m = msg[i];
- if (endian === 'big') {
- res[k] = m >>> 24;
- res[k + 1] = (m >>> 16) & 0xff;
- res[k + 2] = (m >>> 8) & 0xff;
- res[k + 3] = m & 0xff;
- } else {
- res[k + 3] = m >>> 24;
- res[k + 2] = (m >>> 16) & 0xff;
- res[k + 1] = (m >>> 8) & 0xff;
- res[k] = m & 0xff;
- }
- }
- return res;
- }
- exports.split32 = split32;
- function rotr32(w, b) {
- return (w >>> b) | (w << (32 - b));
- }
- exports.rotr32 = rotr32;
- function rotl32(w, b) {
- return (w << b) | (w >>> (32 - b));
- }
- exports.rotl32 = rotl32;
- function sum32(a, b) {
- return (a + b) >>> 0;
- }
- exports.sum32 = sum32;
- function sum32_3(a, b, c) {
- return (a + b + c) >>> 0;
- }
- exports.sum32_3 = sum32_3;
- function sum32_4(a, b, c, d) {
- return (a + b + c + d) >>> 0;
- }
- exports.sum32_4 = sum32_4;
- function sum32_5(a, b, c, d, e) {
- return (a + b + c + d + e) >>> 0;
- }
- exports.sum32_5 = sum32_5;
- function sum64(buf, pos, ah, al) {
- var bh = buf[pos];
- var bl = buf[pos + 1];
- var lo = (al + bl) >>> 0;
- var hi = (lo < al ? 1 : 0) + ah + bh;
- buf[pos] = hi >>> 0;
- buf[pos + 1] = lo;
- }
- exports.sum64 = sum64;
- function sum64_hi(ah, al, bh, bl) {
- var lo = (al + bl) >>> 0;
- var hi = (lo < al ? 1 : 0) + ah + bh;
- return hi >>> 0;
- }
- exports.sum64_hi = sum64_hi;
- function sum64_lo(ah, al, bh, bl) {
- var lo = al + bl;
- return lo >>> 0;
- }
- exports.sum64_lo = sum64_lo;
- function sum64_4_hi(ah, al, bh, bl, ch, cl, dh, dl) {
- var carry = 0;
- var lo = al;
- lo = (lo + bl) >>> 0;
- carry += lo < al ? 1 : 0;
- lo = (lo + cl) >>> 0;
- carry += lo < cl ? 1 : 0;
- lo = (lo + dl) >>> 0;
- carry += lo < dl ? 1 : 0;
- var hi = ah + bh + ch + dh + carry;
- return hi >>> 0;
- }
- exports.sum64_4_hi = sum64_4_hi;
- function sum64_4_lo(ah, al, bh, bl, ch, cl, dh, dl) {
- var lo = al + bl + cl + dl;
- return lo >>> 0;
- }
- exports.sum64_4_lo = sum64_4_lo;
- function sum64_5_hi(ah, al, bh, bl, ch, cl, dh, dl, eh, el) {
- var carry = 0;
- var lo = al;
- lo = (lo + bl) >>> 0;
- carry += lo < al ? 1 : 0;
- lo = (lo + cl) >>> 0;
- carry += lo < cl ? 1 : 0;
- lo = (lo + dl) >>> 0;
- carry += lo < dl ? 1 : 0;
- lo = (lo + el) >>> 0;
- carry += lo < el ? 1 : 0;
- var hi = ah + bh + ch + dh + eh + carry;
- return hi >>> 0;
- }
- exports.sum64_5_hi = sum64_5_hi;
- function sum64_5_lo(ah, al, bh, bl, ch, cl, dh, dl, eh, el) {
- var lo = al + bl + cl + dl + el;
- return lo >>> 0;
- }
- exports.sum64_5_lo = sum64_5_lo;
- function rotr64_hi(ah, al, num) {
- var r = (al << (32 - num)) | (ah >>> num);
- return r >>> 0;
- }
- exports.rotr64_hi = rotr64_hi;
- function rotr64_lo(ah, al, num) {
- var r = (ah << (32 - num)) | (al >>> num);
- return r >>> 0;
- }
- exports.rotr64_lo = rotr64_lo;
- function shr64_hi(ah, al, num) {
- return ah >>> num;
- }
- exports.shr64_hi = shr64_hi;
- function shr64_lo(ah, al, num) {
- var r = (ah << (32 - num)) | (al >>> num);
- return r >>> 0;
- }
- exports.shr64_lo = shr64_lo;
- },{"inherits":789,"minimalistic-assert":791}],788:[function(_dereq_,module,exports){
- 'use strict';
- var hash = _dereq_('hash.js');
- var utils = _dereq_('minimalistic-crypto-utils');
- var assert = _dereq_('minimalistic-assert');
- function HmacDRBG(options) {
- if (!(this instanceof HmacDRBG))
- return new HmacDRBG(options);
- this.hash = options.hash;
- this.predResist = !!options.predResist;
- this.outLen = this.hash.outSize;
- this.minEntropy = options.minEntropy || this.hash.hmacStrength;
- this._reseed = null;
- this.reseedInterval = null;
- this.K = null;
- this.V = null;
- var entropy = utils.toArray(options.entropy, options.entropyEnc || 'hex');
- var nonce = utils.toArray(options.nonce, options.nonceEnc || 'hex');
- var pers = utils.toArray(options.pers, options.persEnc || 'hex');
- assert(entropy.length >= (this.minEntropy / 8),
- 'Not enough entropy. Minimum is: ' + this.minEntropy + ' bits');
- this._init(entropy, nonce, pers);
- }
- module.exports = HmacDRBG;
- HmacDRBG.prototype._init = function init(entropy, nonce, pers) {
- var seed = entropy.concat(nonce).concat(pers);
- this.K = new Array(this.outLen / 8);
- this.V = new Array(this.outLen / 8);
- for (var i = 0; i < this.V.length; i++) {
- this.K[i] = 0x00;
- this.V[i] = 0x01;
- }
- this._update(seed);
- this._reseed = 1;
- this.reseedInterval = 0x1000000000000; // 2^48
- };
- HmacDRBG.prototype._hmac = function hmac() {
- return new hash.hmac(this.hash, this.K);
- };
- HmacDRBG.prototype._update = function update(seed) {
- var kmac = this._hmac()
- .update(this.V)
- .update([ 0x00 ]);
- if (seed)
- kmac = kmac.update(seed);
- this.K = kmac.digest();
- this.V = this._hmac().update(this.V).digest();
- if (!seed)
- return;
- this.K = this._hmac()
- .update(this.V)
- .update([ 0x01 ])
- .update(seed)
- .digest();
- this.V = this._hmac().update(this.V).digest();
- };
- HmacDRBG.prototype.reseed = function reseed(entropy, entropyEnc, add, addEnc) {
- // Optional entropy enc
- if (typeof entropyEnc !== 'string') {
- addEnc = add;
- add = entropyEnc;
- entropyEnc = null;
- }
- entropy = utils.toArray(entropy, entropyEnc);
- add = utils.toArray(add, addEnc);
- assert(entropy.length >= (this.minEntropy / 8),
- 'Not enough entropy. Minimum is: ' + this.minEntropy + ' bits');
- this._update(entropy.concat(add || []));
- this._reseed = 1;
- };
- HmacDRBG.prototype.generate = function generate(len, enc, add, addEnc) {
- if (this._reseed > this.reseedInterval)
- throw new Error('Reseed is required');
- // Optional encoding
- if (typeof enc !== 'string') {
- addEnc = add;
- add = enc;
- enc = null;
- }
- // Optional additional data
- if (add) {
- add = utils.toArray(add, addEnc || 'hex');
- this._update(add);
- }
- var temp = [];
- while (temp.length < len) {
- this.V = this._hmac().update(this.V).digest();
- temp = temp.concat(this.V);
- }
- var res = temp.slice(0, len);
- this._update(add);
- this._reseed++;
- return utils.encode(res, enc);
- };
- },{"hash.js":776,"minimalistic-assert":791,"minimalistic-crypto-utils":792}],789:[function(_dereq_,module,exports){
- if (typeof Object.create === 'function') {
- // implementation from standard node.js 'util' module
- module.exports = function inherits(ctor, superCtor) {
- if (superCtor) {
- ctor.super_ = superCtor
- ctor.prototype = Object.create(superCtor.prototype, {
- constructor: {
- value: ctor,
- enumerable: false,
- writable: true,
- configurable: true
- }
- })
- }
- };
- } else {
- // old school shim for old browsers
- module.exports = function inherits(ctor, superCtor) {
- if (superCtor) {
- ctor.super_ = superCtor
- var TempCtor = function () {}
- TempCtor.prototype = superCtor.prototype
- ctor.prototype = new TempCtor()
- ctor.prototype.constructor = ctor
- }
- }
- }
- },{}],790:[function(_dereq_,module,exports){
- (function (process,global){(function (){
- /**
- * [js-sha3]{@link https://github.com/emn178/js-sha3}
- *
- * @version 0.8.0
- * @author Chen, Yi-Cyuan [emn178@gmail.com]
- * @copyright Chen, Yi-Cyuan 2015-2018
- * @license MIT
- */
- /*jslint bitwise: true */
- (function () {
- 'use strict';
- var INPUT_ERROR = 'input is invalid type';
- var FINALIZE_ERROR = 'finalize already called';
- var WINDOW = typeof window === 'object';
- var root = WINDOW ? window : {};
- if (root.JS_SHA3_NO_WINDOW) {
- WINDOW = false;
- }
- var WEB_WORKER = !WINDOW && typeof self === 'object';
- var NODE_JS = !root.JS_SHA3_NO_NODE_JS && typeof process === 'object' && process.versions && process.versions.node;
- if (NODE_JS) {
- root = global;
- } else if (WEB_WORKER) {
- root = self;
- }
- var COMMON_JS = !root.JS_SHA3_NO_COMMON_JS && typeof module === 'object' && module.exports;
- var AMD = typeof define === 'function' && define.amd;
- var ARRAY_BUFFER = !root.JS_SHA3_NO_ARRAY_BUFFER && typeof ArrayBuffer !== 'undefined';
- var HEX_CHARS = '0123456789abcdef'.split('');
- var SHAKE_PADDING = [31, 7936, 2031616, 520093696];
- var CSHAKE_PADDING = [4, 1024, 262144, 67108864];
- var KECCAK_PADDING = [1, 256, 65536, 16777216];
- var PADDING = [6, 1536, 393216, 100663296];
- var SHIFT = [0, 8, 16, 24];
- var RC = [1, 0, 32898, 0, 32906, 2147483648, 2147516416, 2147483648, 32907, 0, 2147483649,
- 0, 2147516545, 2147483648, 32777, 2147483648, 138, 0, 136, 0, 2147516425, 0,
- 2147483658, 0, 2147516555, 0, 139, 2147483648, 32905, 2147483648, 32771,
- 2147483648, 32770, 2147483648, 128, 2147483648, 32778, 0, 2147483658, 2147483648,
- 2147516545, 2147483648, 32896, 2147483648, 2147483649, 0, 2147516424, 2147483648];
- var BITS = [224, 256, 384, 512];
- var SHAKE_BITS = [128, 256];
- var OUTPUT_TYPES = ['hex', 'buffer', 'arrayBuffer', 'array', 'digest'];
- var CSHAKE_BYTEPAD = {
- '128': 168,
- '256': 136
- };
- if (root.JS_SHA3_NO_NODE_JS || !Array.isArray) {
- Array.isArray = function (obj) {
- return Object.prototype.toString.call(obj) === '[object Array]';
- };
- }
- if (ARRAY_BUFFER && (root.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW || !ArrayBuffer.isView)) {
- ArrayBuffer.isView = function (obj) {
- return typeof obj === 'object' && obj.buffer && obj.buffer.constructor === ArrayBuffer;
- };
- }
- var createOutputMethod = function (bits, padding, outputType) {
- return function (message) {
- return new Keccak(bits, padding, bits).update(message)[outputType]();
- };
- };
- var createShakeOutputMethod = function (bits, padding, outputType) {
- return function (message, outputBits) {
- return new Keccak(bits, padding, outputBits).update(message)[outputType]();
- };
- };
- var createCshakeOutputMethod = function (bits, padding, outputType) {
- return function (message, outputBits, n, s) {
- return methods['cshake' + bits].update(message, outputBits, n, s)[outputType]();
- };
- };
- var createKmacOutputMethod = function (bits, padding, outputType) {
- return function (key, message, outputBits, s) {
- return methods['kmac' + bits].update(key, message, outputBits, s)[outputType]();
- };
- };
- var createOutputMethods = function (method, createMethod, bits, padding) {
- for (var i = 0; i < OUTPUT_TYPES.length; ++i) {
- var type = OUTPUT_TYPES[i];
- method[type] = createMethod(bits, padding, type);
- }
- return method;
- };
- var createMethod = function (bits, padding) {
- var method = createOutputMethod(bits, padding, 'hex');
- method.create = function () {
- return new Keccak(bits, padding, bits);
- };
- method.update = function (message) {
- return method.create().update(message);
- };
- return createOutputMethods(method, createOutputMethod, bits, padding);
- };
- var createShakeMethod = function (bits, padding) {
- var method = createShakeOutputMethod(bits, padding, 'hex');
- method.create = function (outputBits) {
- return new Keccak(bits, padding, outputBits);
- };
- method.update = function (message, outputBits) {
- return method.create(outputBits).update(message);
- };
- return createOutputMethods(method, createShakeOutputMethod, bits, padding);
- };
- var createCshakeMethod = function (bits, padding) {
- var w = CSHAKE_BYTEPAD[bits];
- var method = createCshakeOutputMethod(bits, padding, 'hex');
- method.create = function (outputBits, n, s) {
- if (!n && !s) {
- return methods['shake' + bits].create(outputBits);
- } else {
- return new Keccak(bits, padding, outputBits).bytepad([n, s], w);
- }
- };
- method.update = function (message, outputBits, n, s) {
- return method.create(outputBits, n, s).update(message);
- };
- return createOutputMethods(method, createCshakeOutputMethod, bits, padding);
- };
- var createKmacMethod = function (bits, padding) {
- var w = CSHAKE_BYTEPAD[bits];
- var method = createKmacOutputMethod(bits, padding, 'hex');
- method.create = function (key, outputBits, s) {
- return new Kmac(bits, padding, outputBits).bytepad(['KMAC', s], w).bytepad([key], w);
- };
- method.update = function (key, message, outputBits, s) {
- return method.create(key, outputBits, s).update(message);
- };
- return createOutputMethods(method, createKmacOutputMethod, bits, padding);
- };
- var algorithms = [
- { name: 'keccak', padding: KECCAK_PADDING, bits: BITS, createMethod: createMethod },
- { name: 'sha3', padding: PADDING, bits: BITS, createMethod: createMethod },
- { name: 'shake', padding: SHAKE_PADDING, bits: SHAKE_BITS, createMethod: createShakeMethod },
- { name: 'cshake', padding: CSHAKE_PADDING, bits: SHAKE_BITS, createMethod: createCshakeMethod },
- { name: 'kmac', padding: CSHAKE_PADDING, bits: SHAKE_BITS, createMethod: createKmacMethod }
- ];
- var methods = {}, methodNames = [];
- for (var i = 0; i < algorithms.length; ++i) {
- var algorithm = algorithms[i];
- var bits = algorithm.bits;
- for (var j = 0; j < bits.length; ++j) {
- var methodName = algorithm.name + '_' + bits[j];
- methodNames.push(methodName);
- methods[methodName] = algorithm.createMethod(bits[j], algorithm.padding);
- if (algorithm.name !== 'sha3') {
- var newMethodName = algorithm.name + bits[j];
- methodNames.push(newMethodName);
- methods[newMethodName] = methods[methodName];
- }
- }
- }
- function Keccak(bits, padding, outputBits) {
- this.blocks = [];
- this.s = [];
- this.padding = padding;
- this.outputBits = outputBits;
- this.reset = true;
- this.finalized = false;
- this.block = 0;
- this.start = 0;
- this.blockCount = (1600 - (bits << 1)) >> 5;
- this.byteCount = this.blockCount << 2;
- this.outputBlocks = outputBits >> 5;
- this.extraBytes = (outputBits & 31) >> 3;
- for (var i = 0; i < 50; ++i) {
- this.s[i] = 0;
- }
- }
- Keccak.prototype.update = function (message) {
- if (this.finalized) {
- throw new Error(FINALIZE_ERROR);
- }
- var notString, type = typeof message;
- if (type !== 'string') {
- if (type === 'object') {
- if (message === null) {
- throw new Error(INPUT_ERROR);
- } else if (ARRAY_BUFFER && message.constructor === ArrayBuffer) {
- message = new Uint8Array(message);
- } else if (!Array.isArray(message)) {
- if (!ARRAY_BUFFER || !ArrayBuffer.isView(message)) {
- throw new Error(INPUT_ERROR);
- }
- }
- } else {
- throw new Error(INPUT_ERROR);
- }
- notString = true;
- }
- var blocks = this.blocks, byteCount = this.byteCount, length = message.length,
- blockCount = this.blockCount, index = 0, s = this.s, i, code;
- while (index < length) {
- if (this.reset) {
- this.reset = false;
- blocks[0] = this.block;
- for (i = 1; i < blockCount + 1; ++i) {
- blocks[i] = 0;
- }
- }
- if (notString) {
- for (i = this.start; index < length && i < byteCount; ++index) {
- blocks[i >> 2] |= message[index] << SHIFT[i++ & 3];
- }
- } else {
- for (i = this.start; index < length && i < byteCount; ++index) {
- code = message.charCodeAt(index);
- if (code < 0x80) {
- blocks[i >> 2] |= code << SHIFT[i++ & 3];
- } else if (code < 0x800) {
- blocks[i >> 2] |= (0xc0 | (code >> 6)) << SHIFT[i++ & 3];
- blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
- } else if (code < 0xd800 || code >= 0xe000) {
- blocks[i >> 2] |= (0xe0 | (code >> 12)) << SHIFT[i++ & 3];
- blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3];
- blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
- } else {
- code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff));
- blocks[i >> 2] |= (0xf0 | (code >> 18)) << SHIFT[i++ & 3];
- blocks[i >> 2] |= (0x80 | ((code >> 12) & 0x3f)) << SHIFT[i++ & 3];
- blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3];
- blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
- }
- }
- }
- this.lastByteIndex = i;
- if (i >= byteCount) {
- this.start = i - byteCount;
- this.block = blocks[blockCount];
- for (i = 0; i < blockCount; ++i) {
- s[i] ^= blocks[i];
- }
- f(s);
- this.reset = true;
- } else {
- this.start = i;
- }
- }
- return this;
- };
- Keccak.prototype.encode = function (x, right) {
- var o = x & 255, n = 1;
- var bytes = [o];
- x = x >> 8;
- o = x & 255;
- while (o > 0) {
- bytes.unshift(o);
- x = x >> 8;
- o = x & 255;
- ++n;
- }
- if (right) {
- bytes.push(n);
- } else {
- bytes.unshift(n);
- }
- this.update(bytes);
- return bytes.length;
- };
- Keccak.prototype.encodeString = function (str) {
- var notString, type = typeof str;
- if (type !== 'string') {
- if (type === 'object') {
- if (str === null) {
- throw new Error(INPUT_ERROR);
- } else if (ARRAY_BUFFER && str.constructor === ArrayBuffer) {
- str = new Uint8Array(str);
- } else if (!Array.isArray(str)) {
- if (!ARRAY_BUFFER || !ArrayBuffer.isView(str)) {
- throw new Error(INPUT_ERROR);
- }
- }
- } else {
- throw new Error(INPUT_ERROR);
- }
- notString = true;
- }
- var bytes = 0, length = str.length;
- if (notString) {
- bytes = length;
- } else {
- for (var i = 0; i < str.length; ++i) {
- var code = str.charCodeAt(i);
- if (code < 0x80) {
- bytes += 1;
- } else if (code < 0x800) {
- bytes += 2;
- } else if (code < 0xd800 || code >= 0xe000) {
- bytes += 3;
- } else {
- code = 0x10000 + (((code & 0x3ff) << 10) | (str.charCodeAt(++i) & 0x3ff));
- bytes += 4;
- }
- }
- }
- bytes += this.encode(bytes * 8);
- this.update(str);
- return bytes;
- };
- Keccak.prototype.bytepad = function (strs, w) {
- var bytes = this.encode(w);
- for (var i = 0; i < strs.length; ++i) {
- bytes += this.encodeString(strs[i]);
- }
- var paddingBytes = w - bytes % w;
- var zeros = [];
- zeros.length = paddingBytes;
- this.update(zeros);
- return this;
- };
- Keccak.prototype.finalize = function () {
- if (this.finalized) {
- return;
- }
- this.finalized = true;
- var blocks = this.blocks, i = this.lastByteIndex, blockCount = this.blockCount, s = this.s;
- blocks[i >> 2] |= this.padding[i & 3];
- if (this.lastByteIndex === this.byteCount) {
- blocks[0] = blocks[blockCount];
- for (i = 1; i < blockCount + 1; ++i) {
- blocks[i] = 0;
- }
- }
- blocks[blockCount - 1] |= 0x80000000;
- for (i = 0; i < blockCount; ++i) {
- s[i] ^= blocks[i];
- }
- f(s);
- };
- Keccak.prototype.toString = Keccak.prototype.hex = function () {
- this.finalize();
- var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks,
- extraBytes = this.extraBytes, i = 0, j = 0;
- var hex = '', block;
- while (j < outputBlocks) {
- for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) {
- block = s[i];
- hex += HEX_CHARS[(block >> 4) & 0x0F] + HEX_CHARS[block & 0x0F] +
- HEX_CHARS[(block >> 12) & 0x0F] + HEX_CHARS[(block >> 8) & 0x0F] +
- HEX_CHARS[(block >> 20) & 0x0F] + HEX_CHARS[(block >> 16) & 0x0F] +
- HEX_CHARS[(block >> 28) & 0x0F] + HEX_CHARS[(block >> 24) & 0x0F];
- }
- if (j % blockCount === 0) {
- f(s);
- i = 0;
- }
- }
- if (extraBytes) {
- block = s[i];
- hex += HEX_CHARS[(block >> 4) & 0x0F] + HEX_CHARS[block & 0x0F];
- if (extraBytes > 1) {
- hex += HEX_CHARS[(block >> 12) & 0x0F] + HEX_CHARS[(block >> 8) & 0x0F];
- }
- if (extraBytes > 2) {
- hex += HEX_CHARS[(block >> 20) & 0x0F] + HEX_CHARS[(block >> 16) & 0x0F];
- }
- }
- return hex;
- };
- Keccak.prototype.arrayBuffer = function () {
- this.finalize();
- var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks,
- extraBytes = this.extraBytes, i = 0, j = 0;
- var bytes = this.outputBits >> 3;
- var buffer;
- if (extraBytes) {
- buffer = new ArrayBuffer((outputBlocks + 1) << 2);
- } else {
- buffer = new ArrayBuffer(bytes);
- }
- var array = new Uint32Array(buffer);
- while (j < outputBlocks) {
- for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) {
- array[j] = s[i];
- }
- if (j % blockCount === 0) {
- f(s);
- }
- }
- if (extraBytes) {
- array[i] = s[i];
- buffer = buffer.slice(0, bytes);
- }
- return buffer;
- };
- Keccak.prototype.buffer = Keccak.prototype.arrayBuffer;
- Keccak.prototype.digest = Keccak.prototype.array = function () {
- this.finalize();
- var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks,
- extraBytes = this.extraBytes, i = 0, j = 0;
- var array = [], offset, block;
- while (j < outputBlocks) {
- for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) {
- offset = j << 2;
- block = s[i];
- array[offset] = block & 0xFF;
- array[offset + 1] = (block >> 8) & 0xFF;
- array[offset + 2] = (block >> 16) & 0xFF;
- array[offset + 3] = (block >> 24) & 0xFF;
- }
- if (j % blockCount === 0) {
- f(s);
- }
- }
- if (extraBytes) {
- offset = j << 2;
- block = s[i];
- array[offset] = block & 0xFF;
- if (extraBytes > 1) {
- array[offset + 1] = (block >> 8) & 0xFF;
- }
- if (extraBytes > 2) {
- array[offset + 2] = (block >> 16) & 0xFF;
- }
- }
- return array;
- };
- function Kmac(bits, padding, outputBits) {
- Keccak.call(this, bits, padding, outputBits);
- }
- Kmac.prototype = new Keccak();
- Kmac.prototype.finalize = function () {
- this.encode(this.outputBits, true);
- return Keccak.prototype.finalize.call(this);
- };
- var f = function (s) {
- var h, l, n, c0, c1, c2, c3, c4, c5, c6, c7, c8, c9,
- b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15, b16, b17,
- b18, b19, b20, b21, b22, b23, b24, b25, b26, b27, b28, b29, b30, b31, b32, b33,
- b34, b35, b36, b37, b38, b39, b40, b41, b42, b43, b44, b45, b46, b47, b48, b49;
- for (n = 0; n < 48; n += 2) {
- c0 = s[0] ^ s[10] ^ s[20] ^ s[30] ^ s[40];
- c1 = s[1] ^ s[11] ^ s[21] ^ s[31] ^ s[41];
- c2 = s[2] ^ s[12] ^ s[22] ^ s[32] ^ s[42];
- c3 = s[3] ^ s[13] ^ s[23] ^ s[33] ^ s[43];
- c4 = s[4] ^ s[14] ^ s[24] ^ s[34] ^ s[44];
- c5 = s[5] ^ s[15] ^ s[25] ^ s[35] ^ s[45];
- c6 = s[6] ^ s[16] ^ s[26] ^ s[36] ^ s[46];
- c7 = s[7] ^ s[17] ^ s[27] ^ s[37] ^ s[47];
- c8 = s[8] ^ s[18] ^ s[28] ^ s[38] ^ s[48];
- c9 = s[9] ^ s[19] ^ s[29] ^ s[39] ^ s[49];
- h = c8 ^ ((c2 << 1) | (c3 >>> 31));
- l = c9 ^ ((c3 << 1) | (c2 >>> 31));
- s[0] ^= h;
- s[1] ^= l;
- s[10] ^= h;
- s[11] ^= l;
- s[20] ^= h;
- s[21] ^= l;
- s[30] ^= h;
- s[31] ^= l;
- s[40] ^= h;
- s[41] ^= l;
- h = c0 ^ ((c4 << 1) | (c5 >>> 31));
- l = c1 ^ ((c5 << 1) | (c4 >>> 31));
- s[2] ^= h;
- s[3] ^= l;
- s[12] ^= h;
- s[13] ^= l;
- s[22] ^= h;
- s[23] ^= l;
- s[32] ^= h;
- s[33] ^= l;
- s[42] ^= h;
- s[43] ^= l;
- h = c2 ^ ((c6 << 1) | (c7 >>> 31));
- l = c3 ^ ((c7 << 1) | (c6 >>> 31));
- s[4] ^= h;
- s[5] ^= l;
- s[14] ^= h;
- s[15] ^= l;
- s[24] ^= h;
- s[25] ^= l;
- s[34] ^= h;
- s[35] ^= l;
- s[44] ^= h;
- s[45] ^= l;
- h = c4 ^ ((c8 << 1) | (c9 >>> 31));
- l = c5 ^ ((c9 << 1) | (c8 >>> 31));
- s[6] ^= h;
- s[7] ^= l;
- s[16] ^= h;
- s[17] ^= l;
- s[26] ^= h;
- s[27] ^= l;
- s[36] ^= h;
- s[37] ^= l;
- s[46] ^= h;
- s[47] ^= l;
- h = c6 ^ ((c0 << 1) | (c1 >>> 31));
- l = c7 ^ ((c1 << 1) | (c0 >>> 31));
- s[8] ^= h;
- s[9] ^= l;
- s[18] ^= h;
- s[19] ^= l;
- s[28] ^= h;
- s[29] ^= l;
- s[38] ^= h;
- s[39] ^= l;
- s[48] ^= h;
- s[49] ^= l;
- b0 = s[0];
- b1 = s[1];
- b32 = (s[11] << 4) | (s[10] >>> 28);
- b33 = (s[10] << 4) | (s[11] >>> 28);
- b14 = (s[20] << 3) | (s[21] >>> 29);
- b15 = (s[21] << 3) | (s[20] >>> 29);
- b46 = (s[31] << 9) | (s[30] >>> 23);
- b47 = (s[30] << 9) | (s[31] >>> 23);
- b28 = (s[40] << 18) | (s[41] >>> 14);
- b29 = (s[41] << 18) | (s[40] >>> 14);
- b20 = (s[2] << 1) | (s[3] >>> 31);
- b21 = (s[3] << 1) | (s[2] >>> 31);
- b2 = (s[13] << 12) | (s[12] >>> 20);
- b3 = (s[12] << 12) | (s[13] >>> 20);
- b34 = (s[22] << 10) | (s[23] >>> 22);
- b35 = (s[23] << 10) | (s[22] >>> 22);
- b16 = (s[33] << 13) | (s[32] >>> 19);
- b17 = (s[32] << 13) | (s[33] >>> 19);
- b48 = (s[42] << 2) | (s[43] >>> 30);
- b49 = (s[43] << 2) | (s[42] >>> 30);
- b40 = (s[5] << 30) | (s[4] >>> 2);
- b41 = (s[4] << 30) | (s[5] >>> 2);
- b22 = (s[14] << 6) | (s[15] >>> 26);
- b23 = (s[15] << 6) | (s[14] >>> 26);
- b4 = (s[25] << 11) | (s[24] >>> 21);
- b5 = (s[24] << 11) | (s[25] >>> 21);
- b36 = (s[34] << 15) | (s[35] >>> 17);
- b37 = (s[35] << 15) | (s[34] >>> 17);
- b18 = (s[45] << 29) | (s[44] >>> 3);
- b19 = (s[44] << 29) | (s[45] >>> 3);
- b10 = (s[6] << 28) | (s[7] >>> 4);
- b11 = (s[7] << 28) | (s[6] >>> 4);
- b42 = (s[17] << 23) | (s[16] >>> 9);
- b43 = (s[16] << 23) | (s[17] >>> 9);
- b24 = (s[26] << 25) | (s[27] >>> 7);
- b25 = (s[27] << 25) | (s[26] >>> 7);
- b6 = (s[36] << 21) | (s[37] >>> 11);
- b7 = (s[37] << 21) | (s[36] >>> 11);
- b38 = (s[47] << 24) | (s[46] >>> 8);
- b39 = (s[46] << 24) | (s[47] >>> 8);
- b30 = (s[8] << 27) | (s[9] >>> 5);
- b31 = (s[9] << 27) | (s[8] >>> 5);
- b12 = (s[18] << 20) | (s[19] >>> 12);
- b13 = (s[19] << 20) | (s[18] >>> 12);
- b44 = (s[29] << 7) | (s[28] >>> 25);
- b45 = (s[28] << 7) | (s[29] >>> 25);
- b26 = (s[38] << 8) | (s[39] >>> 24);
- b27 = (s[39] << 8) | (s[38] >>> 24);
- b8 = (s[48] << 14) | (s[49] >>> 18);
- b9 = (s[49] << 14) | (s[48] >>> 18);
- s[0] = b0 ^ (~b2 & b4);
- s[1] = b1 ^ (~b3 & b5);
- s[10] = b10 ^ (~b12 & b14);
- s[11] = b11 ^ (~b13 & b15);
- s[20] = b20 ^ (~b22 & b24);
- s[21] = b21 ^ (~b23 & b25);
- s[30] = b30 ^ (~b32 & b34);
- s[31] = b31 ^ (~b33 & b35);
- s[40] = b40 ^ (~b42 & b44);
- s[41] = b41 ^ (~b43 & b45);
- s[2] = b2 ^ (~b4 & b6);
- s[3] = b3 ^ (~b5 & b7);
- s[12] = b12 ^ (~b14 & b16);
- s[13] = b13 ^ (~b15 & b17);
- s[22] = b22 ^ (~b24 & b26);
- s[23] = b23 ^ (~b25 & b27);
- s[32] = b32 ^ (~b34 & b36);
- s[33] = b33 ^ (~b35 & b37);
- s[42] = b42 ^ (~b44 & b46);
- s[43] = b43 ^ (~b45 & b47);
- s[4] = b4 ^ (~b6 & b8);
- s[5] = b5 ^ (~b7 & b9);
- s[14] = b14 ^ (~b16 & b18);
- s[15] = b15 ^ (~b17 & b19);
- s[24] = b24 ^ (~b26 & b28);
- s[25] = b25 ^ (~b27 & b29);
- s[34] = b34 ^ (~b36 & b38);
- s[35] = b35 ^ (~b37 & b39);
- s[44] = b44 ^ (~b46 & b48);
- s[45] = b45 ^ (~b47 & b49);
- s[6] = b6 ^ (~b8 & b0);
- s[7] = b7 ^ (~b9 & b1);
- s[16] = b16 ^ (~b18 & b10);
- s[17] = b17 ^ (~b19 & b11);
- s[26] = b26 ^ (~b28 & b20);
- s[27] = b27 ^ (~b29 & b21);
- s[36] = b36 ^ (~b38 & b30);
- s[37] = b37 ^ (~b39 & b31);
- s[46] = b46 ^ (~b48 & b40);
- s[47] = b47 ^ (~b49 & b41);
- s[8] = b8 ^ (~b0 & b2);
- s[9] = b9 ^ (~b1 & b3);
- s[18] = b18 ^ (~b10 & b12);
- s[19] = b19 ^ (~b11 & b13);
- s[28] = b28 ^ (~b20 & b22);
- s[29] = b29 ^ (~b21 & b23);
- s[38] = b38 ^ (~b30 & b32);
- s[39] = b39 ^ (~b31 & b33);
- s[48] = b48 ^ (~b40 & b42);
- s[49] = b49 ^ (~b41 & b43);
- s[0] ^= RC[n];
- s[1] ^= RC[n + 1];
- }
- };
- if (COMMON_JS) {
- module.exports = methods;
- } else {
- for (i = 0; i < methodNames.length; ++i) {
- root[methodNames[i]] = methods[methodNames[i]];
- }
- if (AMD) {
- define(function () {
- return methods;
- });
- }
- }
- })();
- }).call(this)}).call(this,_dereq_('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
- },{"_process":323}],791:[function(_dereq_,module,exports){
- module.exports = assert;
- function assert(val, msg) {
- if (!val)
- throw new Error(msg || 'Assertion failed');
- }
- assert.equal = function assertEqual(l, r, msg) {
- if (l != r)
- throw new Error(msg || ('Assertion failed: ' + l + ' != ' + r));
- };
- },{}],792:[function(_dereq_,module,exports){
- 'use strict';
- var utils = exports;
- function toArray(msg, enc) {
- if (Array.isArray(msg))
- return msg.slice();
- if (!msg)
- return [];
- var res = [];
- if (typeof msg !== 'string') {
- for (var i = 0; i < msg.length; i++)
- res[i] = msg[i] | 0;
- return res;
- }
- if (enc === 'hex') {
- msg = msg.replace(/[^a-z0-9]+/ig, '');
- if (msg.length % 2 !== 0)
- msg = '0' + msg;
- for (var i = 0; i < msg.length; i += 2)
- res.push(parseInt(msg[i] + msg[i + 1], 16));
- } else {
- for (var i = 0; i < msg.length; i++) {
- var c = msg.charCodeAt(i);
- var hi = c >> 8;
- var lo = c & 0xff;
- if (hi)
- res.push(hi, lo);
- else
- res.push(lo);
- }
- }
- return res;
- }
- utils.toArray = toArray;
- function zero2(word) {
- if (word.length === 1)
- return '0' + word;
- else
- return word;
- }
- utils.zero2 = zero2;
- function toHex(msg) {
- var res = '';
- for (var i = 0; i < msg.length; i++)
- res += zero2(msg[i].toString(16));
- return res;
- }
- utils.toHex = toHex;
- utils.encode = function encode(arr, enc) {
- if (enc === 'hex')
- return toHex(arr);
- else
- return arr;
- };
- },{}],793:[function(_dereq_,module,exports){
- // shim for using process in browser
- var process = module.exports = {};
- // cached from whatever global is present so that test runners that stub it
- // don't break things. But we need to wrap it in a try catch in case it is
- // wrapped in strict mode code which doesn't define any globals. It's inside a
- // function because try/catches deoptimize in certain engines.
- var cachedSetTimeout;
- var cachedClearTimeout;
- function defaultSetTimout() {
- throw new Error('setTimeout has not been defined');
- }
- function defaultClearTimeout () {
- throw new Error('clearTimeout has not been defined');
- }
- (function () {
- try {
- if (typeof setTimeout === 'function') {
- cachedSetTimeout = setTimeout;
- } else {
- cachedSetTimeout = defaultSetTimout;
- }
- } catch (e) {
- cachedSetTimeout = defaultSetTimout;
- }
- try {
- if (typeof clearTimeout === 'function') {
- cachedClearTimeout = clearTimeout;
- } else {
- cachedClearTimeout = defaultClearTimeout;
- }
- } catch (e) {
- cachedClearTimeout = defaultClearTimeout;
- }
- } ())
- function runTimeout(fun) {
- if (cachedSetTimeout === setTimeout) {
- //normal enviroments in sane situations
- return setTimeout(fun, 0);
- }
- // if setTimeout wasn't available but was latter defined
- if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
- cachedSetTimeout = setTimeout;
- return setTimeout(fun, 0);
- }
- try {
- // when when somebody has screwed with setTimeout but no I.E. maddness
- return cachedSetTimeout(fun, 0);
- } catch(e){
- try {
- // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
- return cachedSetTimeout.call(null, fun, 0);
- } catch(e){
- // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
- return cachedSetTimeout.call(this, fun, 0);
- }
- }
- }
- function runClearTimeout(marker) {
- if (cachedClearTimeout === clearTimeout) {
- //normal enviroments in sane situations
- return clearTimeout(marker);
- }
- // if clearTimeout wasn't available but was latter defined
- if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
- cachedClearTimeout = clearTimeout;
- return clearTimeout(marker);
- }
- try {
- // when when somebody has screwed with setTimeout but no I.E. maddness
- return cachedClearTimeout(marker);
- } catch (e){
- try {
- // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
- return cachedClearTimeout.call(null, marker);
- } catch (e){
- // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
- // Some versions of I.E. have different rules for clearTimeout vs setTimeout
- return cachedClearTimeout.call(this, marker);
- }
- }
- }
- var queue = [];
- var draining = false;
- var currentQueue;
- var queueIndex = -1;
- function cleanUpNextTick() {
- if (!draining || !currentQueue) {
- return;
- }
- draining = false;
- if (currentQueue.length) {
- queue = currentQueue.concat(queue);
- } else {
- queueIndex = -1;
- }
- if (queue.length) {
- drainQueue();
- }
- }
- function drainQueue() {
- if (draining) {
- return;
- }
- var timeout = runTimeout(cleanUpNextTick);
- draining = true;
- var len = queue.length;
- while(len) {
- currentQueue = queue;
- queue = [];
- while (++queueIndex < len) {
- if (currentQueue) {
- currentQueue[queueIndex].run();
- }
- }
- queueIndex = -1;
- len = queue.length;
- }
- currentQueue = null;
- draining = false;
- runClearTimeout(timeout);
- }
- process.nextTick = function (fun) {
- var args = new Array(arguments.length - 1);
- if (arguments.length > 1) {
- for (var i = 1; i < arguments.length; i++) {
- args[i - 1] = arguments[i];
- }
- }
- queue.push(new Item(fun, args));
- if (queue.length === 1 && !draining) {
- runTimeout(drainQueue);
- }
- };
- // v8 likes predictible objects
- function Item(fun, array) {
- this.fun = fun;
- this.array = array;
- }
- Item.prototype.run = function () {
- this.fun.apply(null, this.array);
- };
- process.title = 'browser';
- process.browser = true;
- process.env = {};
- process.argv = [];
- process.version = ''; // empty string to avoid regexp issues
- process.versions = {};
- function noop() {}
- process.on = noop;
- process.addListener = noop;
- process.once = noop;
- process.off = noop;
- process.removeListener = noop;
- process.removeAllListeners = noop;
- process.emit = noop;
- process.prependListener = noop;
- process.prependOnceListener = noop;
- process.listeners = function (name) { return [] }
- process.binding = function (name) {
- throw new Error('process.binding is not supported');
- };
- process.cwd = function () { return '/' };
- process.chdir = function (dir) {
- throw new Error('process.chdir is not supported');
- };
- process.umask = function() { return 0; };
- },{}],794:[function(_dereq_,module,exports){
- /**
- * Copyright (c) 2014-present, Facebook, Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- */
- var runtime = (function (exports) {
- "use strict";
- var Op = Object.prototype;
- var hasOwn = Op.hasOwnProperty;
- var undefined; // More compressible than void 0.
- var $Symbol = typeof Symbol === "function" ? Symbol : {};
- var iteratorSymbol = $Symbol.iterator || "@@iterator";
- var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
- var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
- function define(obj, key, value) {
- Object.defineProperty(obj, key, {
- value: value,
- enumerable: true,
- configurable: true,
- writable: true
- });
- return obj[key];
- }
- try {
- // IE 8 has a broken Object.defineProperty that only works on DOM objects.
- define({}, "");
- } catch (err) {
- define = function(obj, key, value) {
- return obj[key] = value;
- };
- }
- function wrap(innerFn, outerFn, self, tryLocsList) {
- // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
- var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
- var generator = Object.create(protoGenerator.prototype);
- var context = new Context(tryLocsList || []);
- // The ._invoke method unifies the implementations of the .next,
- // .throw, and .return methods.
- generator._invoke = makeInvokeMethod(innerFn, self, context);
- return generator;
- }
- exports.wrap = wrap;
- // Try/catch helper to minimize deoptimizations. Returns a completion
- // record like context.tryEntries[i].completion. This interface could
- // have been (and was previously) designed to take a closure to be
- // invoked without arguments, but in all the cases we care about we
- // already have an existing method we want to call, so there's no need
- // to create a new function object. We can even get away with assuming
- // the method takes exactly one argument, since that happens to be true
- // in every case, so we don't have to touch the arguments object. The
- // only additional allocation required is the completion record, which
- // has a stable shape and so hopefully should be cheap to allocate.
- function tryCatch(fn, obj, arg) {
- try {
- return { type: "normal", arg: fn.call(obj, arg) };
- } catch (err) {
- return { type: "throw", arg: err };
- }
- }
- var GenStateSuspendedStart = "suspendedStart";
- var GenStateSuspendedYield = "suspendedYield";
- var GenStateExecuting = "executing";
- var GenStateCompleted = "completed";
- // Returning this object from the innerFn has the same effect as
- // breaking out of the dispatch switch statement.
- var ContinueSentinel = {};
- // Dummy constructor functions that we use as the .constructor and
- // .constructor.prototype properties for functions that return Generator
- // objects. For full spec compliance, you may wish to configure your
- // minifier not to mangle the names of these two functions.
- function Generator() {}
- function GeneratorFunction() {}
- function GeneratorFunctionPrototype() {}
- // This is a polyfill for %IteratorPrototype% for environments that
- // don't natively support it.
- var IteratorPrototype = {};
- define(IteratorPrototype, iteratorSymbol, function () {
- return this;
- });
- var getProto = Object.getPrototypeOf;
- var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
- if (NativeIteratorPrototype &&
- NativeIteratorPrototype !== Op &&
- hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
- // This environment has a native %IteratorPrototype%; use it instead
- // of the polyfill.
- IteratorPrototype = NativeIteratorPrototype;
- }
- var Gp = GeneratorFunctionPrototype.prototype =
- Generator.prototype = Object.create(IteratorPrototype);
- GeneratorFunction.prototype = GeneratorFunctionPrototype;
- define(Gp, "constructor", GeneratorFunctionPrototype);
- define(GeneratorFunctionPrototype, "constructor", GeneratorFunction);
- GeneratorFunction.displayName = define(
- GeneratorFunctionPrototype,
- toStringTagSymbol,
- "GeneratorFunction"
- );
- // Helper for defining the .next, .throw, and .return methods of the
- // Iterator interface in terms of a single ._invoke method.
- function defineIteratorMethods(prototype) {
- ["next", "throw", "return"].forEach(function(method) {
- define(prototype, method, function(arg) {
- return this._invoke(method, arg);
- });
- });
- }
- exports.isGeneratorFunction = function(genFun) {
- var ctor = typeof genFun === "function" && genFun.constructor;
- return ctor
- ? ctor === GeneratorFunction ||
- // For the native GeneratorFunction constructor, the best we can
- // do is to check its .name property.
- (ctor.displayName || ctor.name) === "GeneratorFunction"
- : false;
- };
- exports.mark = function(genFun) {
- if (Object.setPrototypeOf) {
- Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
- } else {
- genFun.__proto__ = GeneratorFunctionPrototype;
- define(genFun, toStringTagSymbol, "GeneratorFunction");
- }
- genFun.prototype = Object.create(Gp);
- return genFun;
- };
- // Within the body of any async function, `await x` is transformed to
- // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
- // `hasOwn.call(value, "__await")` to determine if the yielded value is
- // meant to be awaited.
- exports.awrap = function(arg) {
- return { __await: arg };
- };
- function AsyncIterator(generator, PromiseImpl) {
- function invoke(method, arg, resolve, reject) {
- var record = tryCatch(generator[method], generator, arg);
- if (record.type === "throw") {
- reject(record.arg);
- } else {
- var result = record.arg;
- var value = result.value;
- if (value &&
- typeof value === "object" &&
- hasOwn.call(value, "__await")) {
- return PromiseImpl.resolve(value.__await).then(function(value) {
- invoke("next", value, resolve, reject);
- }, function(err) {
- invoke("throw", err, resolve, reject);
- });
- }
- return PromiseImpl.resolve(value).then(function(unwrapped) {
- // When a yielded Promise is resolved, its final value becomes
- // the .value of the Promise<{value,done}> result for the
- // current iteration.
- result.value = unwrapped;
- resolve(result);
- }, function(error) {
- // If a rejected Promise was yielded, throw the rejection back
- // into the async generator function so it can be handled there.
- return invoke("throw", error, resolve, reject);
- });
- }
- }
- var previousPromise;
- function enqueue(method, arg) {
- function callInvokeWithMethodAndArg() {
- return new PromiseImpl(function(resolve, reject) {
- invoke(method, arg, resolve, reject);
- });
- }
- return previousPromise =
- // If enqueue has been called before, then we want to wait until
- // all previous Promises have been resolved before calling invoke,
- // so that results are always delivered in the correct order. If
- // enqueue has not been called before, then it is important to
- // call invoke immediately, without waiting on a callback to fire,
- // so that the async generator function has the opportunity to do
- // any necessary setup in a predictable way. This predictability
- // is why the Promise constructor synchronously invokes its
- // executor callback, and why async functions synchronously
- // execute code before the first await. Since we implement simple
- // async functions in terms of async generators, it is especially
- // important to get this right, even though it requires care.
- previousPromise ? previousPromise.then(
- callInvokeWithMethodAndArg,
- // Avoid propagating failures to Promises returned by later
- // invocations of the iterator.
- callInvokeWithMethodAndArg
- ) : callInvokeWithMethodAndArg();
- }
- // Define the unified helper method that is used to implement .next,
- // .throw, and .return (see defineIteratorMethods).
- this._invoke = enqueue;
- }
- defineIteratorMethods(AsyncIterator.prototype);
- define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
- return this;
- });
- exports.AsyncIterator = AsyncIterator;
- // Note that simple async functions are implemented on top of
- // AsyncIterator objects; they just return a Promise for the value of
- // the final result produced by the iterator.
- exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) {
- if (PromiseImpl === void 0) PromiseImpl = Promise;
- var iter = new AsyncIterator(
- wrap(innerFn, outerFn, self, tryLocsList),
- PromiseImpl
- );
- return exports.isGeneratorFunction(outerFn)
- ? iter // If outerFn is a generator, return the full iterator.
- : iter.next().then(function(result) {
- return result.done ? result.value : iter.next();
- });
- };
- function makeInvokeMethod(innerFn, self, context) {
- var state = GenStateSuspendedStart;
- return function invoke(method, arg) {
- if (state === GenStateExecuting) {
- throw new Error("Generator is already running");
- }
- if (state === GenStateCompleted) {
- if (method === "throw") {
- throw arg;
- }
- // Be forgiving, per 25.3.3.3.3 of the spec:
- // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
- return doneResult();
- }
- context.method = method;
- context.arg = arg;
- while (true) {
- var delegate = context.delegate;
- if (delegate) {
- var delegateResult = maybeInvokeDelegate(delegate, context);
- if (delegateResult) {
- if (delegateResult === ContinueSentinel) continue;
- return delegateResult;
- }
- }
- if (context.method === "next") {
- // Setting context._sent for legacy support of Babel's
- // function.sent implementation.
- context.sent = context._sent = context.arg;
- } else if (context.method === "throw") {
- if (state === GenStateSuspendedStart) {
- state = GenStateCompleted;
- throw context.arg;
- }
- context.dispatchException(context.arg);
- } else if (context.method === "return") {
- context.abrupt("return", context.arg);
- }
- state = GenStateExecuting;
- var record = tryCatch(innerFn, self, context);
- if (record.type === "normal") {
- // If an exception is thrown from innerFn, we leave state ===
- // GenStateExecuting and loop back for another invocation.
- state = context.done
- ? GenStateCompleted
- : GenStateSuspendedYield;
- if (record.arg === ContinueSentinel) {
- continue;
- }
- return {
- value: record.arg,
- done: context.done
- };
- } else if (record.type === "throw") {
- state = GenStateCompleted;
- // Dispatch the exception by looping back around to the
- // context.dispatchException(context.arg) call above.
- context.method = "throw";
- context.arg = record.arg;
- }
- }
- };
- }
- // Call delegate.iterator[context.method](context.arg) and handle the
- // result, either by returning a { value, done } result from the
- // delegate iterator, or by modifying context.method and context.arg,
- // setting context.delegate to null, and returning the ContinueSentinel.
- function maybeInvokeDelegate(delegate, context) {
- var method = delegate.iterator[context.method];
- if (method === undefined) {
- // A .throw or .return when the delegate iterator has no .throw
- // method always terminates the yield* loop.
- context.delegate = null;
- if (context.method === "throw") {
- // Note: ["return"] must be used for ES3 parsing compatibility.
- if (delegate.iterator["return"]) {
- // If the delegate iterator has a return method, give it a
- // chance to clean up.
- context.method = "return";
- context.arg = undefined;
- maybeInvokeDelegate(delegate, context);
- if (context.method === "throw") {
- // If maybeInvokeDelegate(context) changed context.method from
- // "return" to "throw", let that override the TypeError below.
- return ContinueSentinel;
- }
- }
- context.method = "throw";
- context.arg = new TypeError(
- "The iterator does not provide a 'throw' method");
- }
- return ContinueSentinel;
- }
- var record = tryCatch(method, delegate.iterator, context.arg);
- if (record.type === "throw") {
- context.method = "throw";
- context.arg = record.arg;
- context.delegate = null;
- return ContinueSentinel;
- }
- var info = record.arg;
- if (! info) {
- context.method = "throw";
- context.arg = new TypeError("iterator result is not an object");
- context.delegate = null;
- return ContinueSentinel;
- }
- if (info.done) {
- // Assign the result of the finished delegate to the temporary
- // variable specified by delegate.resultName (see delegateYield).
- context[delegate.resultName] = info.value;
- // Resume execution at the desired location (see delegateYield).
- context.next = delegate.nextLoc;
- // If context.method was "throw" but the delegate handled the
- // exception, let the outer generator proceed normally. If
- // context.method was "next", forget context.arg since it has been
- // "consumed" by the delegate iterator. If context.method was
- // "return", allow the original .return call to continue in the
- // outer generator.
- if (context.method !== "return") {
- context.method = "next";
- context.arg = undefined;
- }
- } else {
- // Re-yield the result returned by the delegate method.
- return info;
- }
- // The delegate iterator is finished, so forget it and continue with
- // the outer generator.
- context.delegate = null;
- return ContinueSentinel;
- }
- // Define Generator.prototype.{next,throw,return} in terms of the
- // unified ._invoke helper method.
- defineIteratorMethods(Gp);
- define(Gp, toStringTagSymbol, "Generator");
- // A Generator should always return itself as the iterator object when the
- // @@iterator function is called on it. Some browsers' implementations of the
- // iterator prototype chain incorrectly implement this, causing the Generator
- // object to not be returned from this call. This ensures that doesn't happen.
- // See https://github.com/facebook/regenerator/issues/274 for more details.
- define(Gp, iteratorSymbol, function() {
- return this;
- });
- define(Gp, "toString", function() {
- return "[object Generator]";
- });
- function pushTryEntry(locs) {
- var entry = { tryLoc: locs[0] };
- if (1 in locs) {
- entry.catchLoc = locs[1];
- }
- if (2 in locs) {
- entry.finallyLoc = locs[2];
- entry.afterLoc = locs[3];
- }
- this.tryEntries.push(entry);
- }
- function resetTryEntry(entry) {
- var record = entry.completion || {};
- record.type = "normal";
- delete record.arg;
- entry.completion = record;
- }
- function Context(tryLocsList) {
- // The root entry object (effectively a try statement without a catch
- // or a finally block) gives us a place to store values thrown from
- // locations where there is no enclosing try statement.
- this.tryEntries = [{ tryLoc: "root" }];
- tryLocsList.forEach(pushTryEntry, this);
- this.reset(true);
- }
- exports.keys = function(object) {
- var keys = [];
- for (var key in object) {
- keys.push(key);
- }
- keys.reverse();
- // Rather than returning an object with a next method, we keep
- // things simple and return the next function itself.
- return function next() {
- while (keys.length) {
- var key = keys.pop();
- if (key in object) {
- next.value = key;
- next.done = false;
- return next;
- }
- }
- // To avoid creating an additional object, we just hang the .value
- // and .done properties off the next function object itself. This
- // also ensures that the minifier will not anonymize the function.
- next.done = true;
- return next;
- };
- };
- function values(iterable) {
- if (iterable) {
- var iteratorMethod = iterable[iteratorSymbol];
- if (iteratorMethod) {
- return iteratorMethod.call(iterable);
- }
- if (typeof iterable.next === "function") {
- return iterable;
- }
- if (!isNaN(iterable.length)) {
- var i = -1, next = function next() {
- while (++i < iterable.length) {
- if (hasOwn.call(iterable, i)) {
- next.value = iterable[i];
- next.done = false;
- return next;
- }
- }
- next.value = undefined;
- next.done = true;
- return next;
- };
- return next.next = next;
- }
- }
- // Return an iterator with no values.
- return { next: doneResult };
- }
- exports.values = values;
- function doneResult() {
- return { value: undefined, done: true };
- }
- Context.prototype = {
- constructor: Context,
- reset: function(skipTempReset) {
- this.prev = 0;
- this.next = 0;
- // Resetting context._sent for legacy support of Babel's
- // function.sent implementation.
- this.sent = this._sent = undefined;
- this.done = false;
- this.delegate = null;
- this.method = "next";
- this.arg = undefined;
- this.tryEntries.forEach(resetTryEntry);
- if (!skipTempReset) {
- for (var name in this) {
- // Not sure about the optimal order of these conditions:
- if (name.charAt(0) === "t" &&
- hasOwn.call(this, name) &&
- !isNaN(+name.slice(1))) {
- this[name] = undefined;
- }
- }
- }
- },
- stop: function() {
- this.done = true;
- var rootEntry = this.tryEntries[0];
- var rootRecord = rootEntry.completion;
- if (rootRecord.type === "throw") {
- throw rootRecord.arg;
- }
- return this.rval;
- },
- dispatchException: function(exception) {
- if (this.done) {
- throw exception;
- }
- var context = this;
- function handle(loc, caught) {
- record.type = "throw";
- record.arg = exception;
- context.next = loc;
- if (caught) {
- // If the dispatched exception was caught by a catch block,
- // then let that catch block handle the exception normally.
- context.method = "next";
- context.arg = undefined;
- }
- return !! caught;
- }
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
- var entry = this.tryEntries[i];
- var record = entry.completion;
- if (entry.tryLoc === "root") {
- // Exception thrown outside of any try block that could handle
- // it, so set the completion value of the entire function to
- // throw the exception.
- return handle("end");
- }
- if (entry.tryLoc <= this.prev) {
- var hasCatch = hasOwn.call(entry, "catchLoc");
- var hasFinally = hasOwn.call(entry, "finallyLoc");
- if (hasCatch && hasFinally) {
- if (this.prev < entry.catchLoc) {
- return handle(entry.catchLoc, true);
- } else if (this.prev < entry.finallyLoc) {
- return handle(entry.finallyLoc);
- }
- } else if (hasCatch) {
- if (this.prev < entry.catchLoc) {
- return handle(entry.catchLoc, true);
- }
- } else if (hasFinally) {
- if (this.prev < entry.finallyLoc) {
- return handle(entry.finallyLoc);
- }
- } else {
- throw new Error("try statement without catch or finally");
- }
- }
- }
- },
- abrupt: function(type, arg) {
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
- var entry = this.tryEntries[i];
- if (entry.tryLoc <= this.prev &&
- hasOwn.call(entry, "finallyLoc") &&
- this.prev < entry.finallyLoc) {
- var finallyEntry = entry;
- break;
- }
- }
- if (finallyEntry &&
- (type === "break" ||
- type === "continue") &&
- finallyEntry.tryLoc <= arg &&
- arg <= finallyEntry.finallyLoc) {
- // Ignore the finally entry if control is not jumping to a
- // location outside the try/catch block.
- finallyEntry = null;
- }
- var record = finallyEntry ? finallyEntry.completion : {};
- record.type = type;
- record.arg = arg;
- if (finallyEntry) {
- this.method = "next";
- this.next = finallyEntry.finallyLoc;
- return ContinueSentinel;
- }
- return this.complete(record);
- },
- complete: function(record, afterLoc) {
- if (record.type === "throw") {
- throw record.arg;
- }
- if (record.type === "break" ||
- record.type === "continue") {
- this.next = record.arg;
- } else if (record.type === "return") {
- this.rval = this.arg = record.arg;
- this.method = "return";
- this.next = "end";
- } else if (record.type === "normal" && afterLoc) {
- this.next = afterLoc;
- }
- return ContinueSentinel;
- },
- finish: function(finallyLoc) {
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
- var entry = this.tryEntries[i];
- if (entry.finallyLoc === finallyLoc) {
- this.complete(entry.completion, entry.afterLoc);
- resetTryEntry(entry);
- return ContinueSentinel;
- }
- }
- },
- "catch": function(tryLoc) {
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
- var entry = this.tryEntries[i];
- if (entry.tryLoc === tryLoc) {
- var record = entry.completion;
- if (record.type === "throw") {
- var thrown = record.arg;
- resetTryEntry(entry);
- }
- return thrown;
- }
- }
- // The context.catch method must only be called with a location
- // argument that corresponds to a known catch block.
- throw new Error("illegal catch attempt");
- },
- delegateYield: function(iterable, resultName, nextLoc) {
- this.delegate = {
- iterator: values(iterable),
- resultName: resultName,
- nextLoc: nextLoc
- };
- if (this.method === "next") {
- // Deliberately forget the last sent value so that we don't
- // accidentally pass it on to the delegate.
- this.arg = undefined;
- }
- return ContinueSentinel;
- }
- };
- // Regardless of whether this script is executing as a CommonJS module
- // or not, return the runtime object so that we can declare the variable
- // regeneratorRuntime in the outer scope, which allows this module to be
- // injected easily by `bin/regenerator --include-runtime script.js`.
- return exports;
- }(
- // If this script is executing as a CommonJS module, use module.exports
- // as the regeneratorRuntime namespace. Otherwise create a new empty
- // object. Either way, the resulting object will be used to initialize
- // the regeneratorRuntime variable at the top of this file.
- typeof module === "object" ? module.exports : {}
- ));
- try {
- regeneratorRuntime = runtime;
- } catch (accidentalStrictMode) {
- // This module should not be running in strict mode, so the above
- // assignment should always work unless something is misconfigured. Just
- // in case runtime.js accidentally runs in strict mode, in modern engines
- // we can explicitly access globalThis. In older engines we can escape
- // strict mode using a global Function call. This could conceivably fail
- // if a Content Security Policy forbids using Function, but in that case
- // the proper solution is to fix the accidental strict mode problem. If
- // you've misconfigured your bundler to force strict mode and applied a
- // CSP to forbid Function, and you're not willing to fix either of those
- // problems, please detail your unique predicament in a GitHub issue.
- if (typeof globalThis === "object") {
- globalThis.regeneratorRuntime = runtime;
- } else {
- Function("r", "regeneratorRuntime = r")(runtime);
- }
- }
- },{}],795:[function(_dereq_,module,exports){
- (function (setImmediate){(function (){
- "use strict";
- (function(root) {
- const MAX_VALUE = 0x7fffffff;
- // The SHA256 and PBKDF2 implementation are from scrypt-async-js:
- // See: https://github.com/dchest/scrypt-async-js
- function SHA256(m) {
- const K = new Uint32Array([
- 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b,
- 0x59f111f1, 0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01,
- 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7,
- 0xc19bf174, 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,
- 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, 0x983e5152,
- 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147,
- 0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc,
- 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
- 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819,
- 0xd6990624, 0xf40e3585, 0x106aa070, 0x19a4c116, 0x1e376c08,
- 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f,
- 0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
- 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
- ]);
- let h0 = 0x6a09e667, h1 = 0xbb67ae85, h2 = 0x3c6ef372, h3 = 0xa54ff53a;
- let h4 = 0x510e527f, h5 = 0x9b05688c, h6 = 0x1f83d9ab, h7 = 0x5be0cd19;
- const w = new Uint32Array(64);
- function blocks(p) {
- let off = 0, len = p.length;
- while (len >= 64) {
- let a = h0, b = h1, c = h2, d = h3, e = h4, f = h5, g = h6, h = h7, u, i, j, t1, t2;
- for (i = 0; i < 16; i++) {
- j = off + i*4;
- w[i] = ((p[j] & 0xff)<<24) | ((p[j+1] & 0xff)<<16) |
- ((p[j+2] & 0xff)<<8) | (p[j+3] & 0xff);
- }
- for (i = 16; i < 64; i++) {
- u = w[i-2];
- t1 = ((u>>>17) | (u<<(32-17))) ^ ((u>>>19) | (u<<(32-19))) ^ (u>>>10);
- u = w[i-15];
- t2 = ((u>>>7) | (u<<(32-7))) ^ ((u>>>18) | (u<<(32-18))) ^ (u>>>3);
- w[i] = (((t1 + w[i-7]) | 0) + ((t2 + w[i-16]) | 0)) | 0;
- }
- for (i = 0; i < 64; i++) {
- t1 = ((((((e>>>6) | (e<<(32-6))) ^ ((e>>>11) | (e<<(32-11))) ^
- ((e>>>25) | (e<<(32-25)))) + ((e & f) ^ (~e & g))) | 0) +
- ((h + ((K[i] + w[i]) | 0)) | 0)) | 0;
- t2 = ((((a>>>2) | (a<<(32-2))) ^ ((a>>>13) | (a<<(32-13))) ^
- ((a>>>22) | (a<<(32-22)))) + ((a & b) ^ (a & c) ^ (b & c))) | 0;
- h = g;
- g = f;
- f = e;
- e = (d + t1) | 0;
- d = c;
- c = b;
- b = a;
- a = (t1 + t2) | 0;
- }
- h0 = (h0 + a) | 0;
- h1 = (h1 + b) | 0;
- h2 = (h2 + c) | 0;
- h3 = (h3 + d) | 0;
- h4 = (h4 + e) | 0;
- h5 = (h5 + f) | 0;
- h6 = (h6 + g) | 0;
- h7 = (h7 + h) | 0;
- off += 64;
- len -= 64;
- }
- }
- blocks(m);
- let i, bytesLeft = m.length % 64,
- bitLenHi = (m.length / 0x20000000) | 0,
- bitLenLo = m.length << 3,
- numZeros = (bytesLeft < 56) ? 56 : 120,
- p = m.slice(m.length - bytesLeft, m.length);
- p.push(0x80);
- for (i = bytesLeft + 1; i < numZeros; i++) { p.push(0); }
- p.push((bitLenHi >>> 24) & 0xff);
- p.push((bitLenHi >>> 16) & 0xff);
- p.push((bitLenHi >>> 8) & 0xff);
- p.push((bitLenHi >>> 0) & 0xff);
- p.push((bitLenLo >>> 24) & 0xff);
- p.push((bitLenLo >>> 16) & 0xff);
- p.push((bitLenLo >>> 8) & 0xff);
- p.push((bitLenLo >>> 0) & 0xff);
- blocks(p);
- return [
- (h0 >>> 24) & 0xff, (h0 >>> 16) & 0xff, (h0 >>> 8) & 0xff, (h0 >>> 0) & 0xff,
- (h1 >>> 24) & 0xff, (h1 >>> 16) & 0xff, (h1 >>> 8) & 0xff, (h1 >>> 0) & 0xff,
- (h2 >>> 24) & 0xff, (h2 >>> 16) & 0xff, (h2 >>> 8) & 0xff, (h2 >>> 0) & 0xff,
- (h3 >>> 24) & 0xff, (h3 >>> 16) & 0xff, (h3 >>> 8) & 0xff, (h3 >>> 0) & 0xff,
- (h4 >>> 24) & 0xff, (h4 >>> 16) & 0xff, (h4 >>> 8) & 0xff, (h4 >>> 0) & 0xff,
- (h5 >>> 24) & 0xff, (h5 >>> 16) & 0xff, (h5 >>> 8) & 0xff, (h5 >>> 0) & 0xff,
- (h6 >>> 24) & 0xff, (h6 >>> 16) & 0xff, (h6 >>> 8) & 0xff, (h6 >>> 0) & 0xff,
- (h7 >>> 24) & 0xff, (h7 >>> 16) & 0xff, (h7 >>> 8) & 0xff, (h7 >>> 0) & 0xff
- ];
- }
- function PBKDF2_HMAC_SHA256_OneIter(password, salt, dkLen) {
- // compress password if it's longer than hash block length
- password = (password.length <= 64) ? password : SHA256(password);
- const innerLen = 64 + salt.length + 4;
- const inner = new Array(innerLen);
- const outerKey = new Array(64);
- let i;
- let dk = [];
- // inner = (password ^ ipad) || salt || counter
- for (i = 0; i < 64; i++) { inner[i] = 0x36; }
- for (i = 0; i < password.length; i++) { inner[i] ^= password[i]; }
- for (i = 0; i < salt.length; i++) { inner[64 + i] = salt[i]; }
- for (i = innerLen - 4; i < innerLen; i++) { inner[i] = 0; }
- // outerKey = password ^ opad
- for (i = 0; i < 64; i++) outerKey[i] = 0x5c;
- for (i = 0; i < password.length; i++) outerKey[i] ^= password[i];
- // increments counter inside inner
- function incrementCounter() {
- for (let i = innerLen - 1; i >= innerLen - 4; i--) {
- inner[i]++;
- if (inner[i] <= 0xff) return;
- inner[i] = 0;
- }
- }
- // output blocks = SHA256(outerKey || SHA256(inner)) ...
- while (dkLen >= 32) {
- incrementCounter();
- dk = dk.concat(SHA256(outerKey.concat(SHA256(inner))));
- dkLen -= 32;
- }
- if (dkLen > 0) {
- incrementCounter();
- dk = dk.concat(SHA256(outerKey.concat(SHA256(inner))).slice(0, dkLen));
- }
- return dk;
- }
- // The following is an adaptation of scryptsy
- // See: https://www.npmjs.com/package/scryptsy
- function blockmix_salsa8(BY, Yi, r, x, _X) {
- let i;
- arraycopy(BY, (2 * r - 1) * 16, _X, 0, 16);
- for (i = 0; i < 2 * r; i++) {
- blockxor(BY, i * 16, _X, 16);
- salsa20_8(_X, x);
- arraycopy(_X, 0, BY, Yi + (i * 16), 16);
- }
- for (i = 0; i < r; i++) {
- arraycopy(BY, Yi + (i * 2) * 16, BY, (i * 16), 16);
- }
- for (i = 0; i < r; i++) {
- arraycopy(BY, Yi + (i * 2 + 1) * 16, BY, (i + r) * 16, 16);
- }
- }
- function R(a, b) {
- return (a << b) | (a >>> (32 - b));
- }
- function salsa20_8(B, x) {
- arraycopy(B, 0, x, 0, 16);
- for (let i = 8; i > 0; i -= 2) {
- x[ 4] ^= R(x[ 0] + x[12], 7);
- x[ 8] ^= R(x[ 4] + x[ 0], 9);
- x[12] ^= R(x[ 8] + x[ 4], 13);
- x[ 0] ^= R(x[12] + x[ 8], 18);
- x[ 9] ^= R(x[ 5] + x[ 1], 7);
- x[13] ^= R(x[ 9] + x[ 5], 9);
- x[ 1] ^= R(x[13] + x[ 9], 13);
- x[ 5] ^= R(x[ 1] + x[13], 18);
- x[14] ^= R(x[10] + x[ 6], 7);
- x[ 2] ^= R(x[14] + x[10], 9);
- x[ 6] ^= R(x[ 2] + x[14], 13);
- x[10] ^= R(x[ 6] + x[ 2], 18);
- x[ 3] ^= R(x[15] + x[11], 7);
- x[ 7] ^= R(x[ 3] + x[15], 9);
- x[11] ^= R(x[ 7] + x[ 3], 13);
- x[15] ^= R(x[11] + x[ 7], 18);
- x[ 1] ^= R(x[ 0] + x[ 3], 7);
- x[ 2] ^= R(x[ 1] + x[ 0], 9);
- x[ 3] ^= R(x[ 2] + x[ 1], 13);
- x[ 0] ^= R(x[ 3] + x[ 2], 18);
- x[ 6] ^= R(x[ 5] + x[ 4], 7);
- x[ 7] ^= R(x[ 6] + x[ 5], 9);
- x[ 4] ^= R(x[ 7] + x[ 6], 13);
- x[ 5] ^= R(x[ 4] + x[ 7], 18);
- x[11] ^= R(x[10] + x[ 9], 7);
- x[ 8] ^= R(x[11] + x[10], 9);
- x[ 9] ^= R(x[ 8] + x[11], 13);
- x[10] ^= R(x[ 9] + x[ 8], 18);
- x[12] ^= R(x[15] + x[14], 7);
- x[13] ^= R(x[12] + x[15], 9);
- x[14] ^= R(x[13] + x[12], 13);
- x[15] ^= R(x[14] + x[13], 18);
- }
- for (let i = 0; i < 16; ++i) {
- B[i] += x[i];
- }
- }
- // naive approach... going back to loop unrolling may yield additional performance
- function blockxor(S, Si, D, len) {
- for (let i = 0; i < len; i++) {
- D[i] ^= S[Si + i]
- }
- }
- function arraycopy(src, srcPos, dest, destPos, length) {
- while (length--) {
- dest[destPos++] = src[srcPos++];
- }
- }
- function checkBufferish(o) {
- if (!o || typeof(o.length) !== 'number') { return false; }
- for (let i = 0; i < o.length; i++) {
- const v = o[i];
- if (typeof(v) !== 'number' || v % 1 || v < 0 || v >= 256) {
- return false;
- }
- }
- return true;
- }
- function ensureInteger(value, name) {
- if (typeof(value) !== "number" || (value % 1)) { throw new Error('invalid ' + name); }
- return value;
- }
- // N = Cpu cost, r = Memory cost, p = parallelization cost
- // callback(error, progress, key)
- function _scrypt(password, salt, N, r, p, dkLen, callback) {
- N = ensureInteger(N, 'N');
- r = ensureInteger(r, 'r');
- p = ensureInteger(p, 'p');
- dkLen = ensureInteger(dkLen, 'dkLen');
- if (N === 0 || (N & (N - 1)) !== 0) { throw new Error('N must be power of 2'); }
- if (N > MAX_VALUE / 128 / r) { throw new Error('N too large'); }
- if (r > MAX_VALUE / 128 / p) { throw new Error('r too large'); }
- if (!checkBufferish(password)) {
- throw new Error('password must be an array or buffer');
- }
- password = Array.prototype.slice.call(password);
- if (!checkBufferish(salt)) {
- throw new Error('salt must be an array or buffer');
- }
- salt = Array.prototype.slice.call(salt);
- let b = PBKDF2_HMAC_SHA256_OneIter(password, salt, p * 128 * r);
- const B = new Uint32Array(p * 32 * r)
- for (let i = 0; i < B.length; i++) {
- const j = i * 4;
- B[i] = ((b[j + 3] & 0xff) << 24) |
- ((b[j + 2] & 0xff) << 16) |
- ((b[j + 1] & 0xff) << 8) |
- ((b[j + 0] & 0xff) << 0);
- }
- const XY = new Uint32Array(64 * r);
- const V = new Uint32Array(32 * r * N);
- const Yi = 32 * r;
- // scratch space
- const x = new Uint32Array(16); // salsa20_8
- const _X = new Uint32Array(16); // blockmix_salsa8
- const totalOps = p * N * 2;
- let currentOp = 0;
- let lastPercent10 = null;
- // Set this to true to abandon the scrypt on the next step
- let stop = false;
- // State information
- let state = 0;
- let i0 = 0, i1;
- let Bi;
- // How many blockmix_salsa8 can we do per step?
- const limit = callback ? parseInt(1000 / r): 0xffffffff;
- // Trick from scrypt-async; if there is a setImmediate shim in place, use it
- const nextTick = (typeof(setImmediate) !== 'undefined') ? setImmediate : setTimeout;
- // This is really all I changed; making scryptsy a state machine so we occasionally
- // stop and give other evnts on the evnt loop a chance to run. ~RicMoo
- const incrementalSMix = function() {
- if (stop) {
- return callback(new Error('cancelled'), currentOp / totalOps);
- }
- let steps;
- switch (state) {
- case 0:
- // for (var i = 0; i < p; i++)...
- Bi = i0 * 32 * r;
- arraycopy(B, Bi, XY, 0, Yi); // ROMix - 1
- state = 1; // Move to ROMix 2
- i1 = 0;
- // Fall through
- case 1:
- // Run up to 1000 steps of the first inner smix loop
- steps = N - i1;
- if (steps > limit) { steps = limit; }
- for (let i = 0; i < steps; i++) { // ROMix - 2
- arraycopy(XY, 0, V, (i1 + i) * Yi, Yi) // ROMix - 3
- blockmix_salsa8(XY, Yi, r, x, _X); // ROMix - 4
- }
- // for (var i = 0; i < N; i++)
- i1 += steps;
- currentOp += steps;
- if (callback) {
- // Call the callback with the progress (optionally stopping us)
- const percent10 = parseInt(1000 * currentOp / totalOps);
- if (percent10 !== lastPercent10) {
- stop = callback(null, currentOp / totalOps);
- if (stop) { break; }
- lastPercent10 = percent10;
- }
- }
- if (i1 < N) { break; }
- i1 = 0; // Move to ROMix 6
- state = 2;
- // Fall through
- case 2:
- // Run up to 1000 steps of the second inner smix loop
- steps = N - i1;
- if (steps > limit) { steps = limit; }
- for (let i = 0; i < steps; i++) { // ROMix - 6
- const offset = (2 * r - 1) * 16; // ROMix - 7
- const j = XY[offset] & (N - 1);
- blockxor(V, j * Yi, XY, Yi); // ROMix - 8 (inner)
- blockmix_salsa8(XY, Yi, r, x, _X); // ROMix - 9 (outer)
- }
- // for (var i = 0; i < N; i++)...
- i1 += steps;
- currentOp += steps;
- // Call the callback with the progress (optionally stopping us)
- if (callback) {
- const percent10 = parseInt(1000 * currentOp / totalOps);
- if (percent10 !== lastPercent10) {
- stop = callback(null, currentOp / totalOps);
- if (stop) { break; }
- lastPercent10 = percent10;
- }
- }
- if (i1 < N) { break; }
- arraycopy(XY, 0, B, Bi, Yi); // ROMix - 10
- // for (var i = 0; i < p; i++)...
- i0++;
- if (i0 < p) {
- state = 0;
- break;
- }
- b = [];
- for (let i = 0; i < B.length; i++) {
- b.push((B[i] >> 0) & 0xff);
- b.push((B[i] >> 8) & 0xff);
- b.push((B[i] >> 16) & 0xff);
- b.push((B[i] >> 24) & 0xff);
- }
- const derivedKey = PBKDF2_HMAC_SHA256_OneIter(password, b, dkLen);
- // Send the result to the callback
- if (callback) { callback(null, 1.0, derivedKey); }
- // Done; don't break (which would reschedule)
- return derivedKey;
- }
- // Schedule the next steps
- if (callback) { nextTick(incrementalSMix); }
- }
- // Run the smix state machine until completion
- if (!callback) {
- while (true) {
- const derivedKey = incrementalSMix();
- if (derivedKey != undefined) { return derivedKey; }
- }
- }
- // Bootstrap the async incremental smix
- incrementalSMix();
- }
- const lib = {
- scrypt: function(password, salt, N, r, p, dkLen, progressCallback) {
- return new Promise(function(resolve, reject) {
- let lastProgress = 0;
- if (progressCallback) { progressCallback(0); }
- _scrypt(password, salt, N, r, p, dkLen, function(error, progress, key) {
- if (error) {
- reject(error);
- } else if (key) {
- if (progressCallback && lastProgress !== 1) {
- progressCallback(1);
- }
- resolve(new Uint8Array(key));
- } else if (progressCallback && progress !== lastProgress) {
- lastProgress = progress;
- return progressCallback(progress);
- }
- });
- });
- },
- syncScrypt: function(password, salt, N, r, p, dkLen) {
- return new Uint8Array(_scrypt(password, salt, N, r, p, dkLen));
- }
- };
- // node.js
- if (typeof(exports) !== 'undefined') {
- module.exports = lib;
- // RequireJS/AMD
- // http://www.requirejs.org/docs/api.html
- // https://github.com/amdjs/amdjs-api/wiki/AMD
- } else if (typeof(define) === 'function' && define.amd) {
- define(lib);
- // Web Browsers
- } else if (root) {
- // If there was an existing library "scrypt", make sure it is still available
- if (root.scrypt) {
- root._scrypt = root.scrypt;
- }
- root.scrypt = lib;
- }
- })(this);
- }).call(this)}).call(this,_dereq_("timers").setImmediate)
- },{"timers":796}],796:[function(_dereq_,module,exports){
- (function (setImmediate,clearImmediate){(function (){
- var nextTick = _dereq_('process/browser.js').nextTick;
- var apply = Function.prototype.apply;
- var slice = Array.prototype.slice;
- var immediateIds = {};
- var nextImmediateId = 0;
- // DOM APIs, for completeness
- exports.setTimeout = function() {
- return new Timeout(apply.call(setTimeout, window, arguments), clearTimeout);
- };
- exports.setInterval = function() {
- return new Timeout(apply.call(setInterval, window, arguments), clearInterval);
- };
- exports.clearTimeout =
- exports.clearInterval = function(timeout) { timeout.close(); };
- function Timeout(id, clearFn) {
- this._id = id;
- this._clearFn = clearFn;
- }
- Timeout.prototype.unref = Timeout.prototype.ref = function() {};
- Timeout.prototype.close = function() {
- this._clearFn.call(window, this._id);
- };
- // Does not start the time, just sets up the members needed.
- exports.enroll = function(item, msecs) {
- clearTimeout(item._idleTimeoutId);
- item._idleTimeout = msecs;
- };
- exports.unenroll = function(item) {
- clearTimeout(item._idleTimeoutId);
- item._idleTimeout = -1;
- };
- exports._unrefActive = exports.active = function(item) {
- clearTimeout(item._idleTimeoutId);
- var msecs = item._idleTimeout;
- if (msecs >= 0) {
- item._idleTimeoutId = setTimeout(function onTimeout() {
- if (item._onTimeout)
- item._onTimeout();
- }, msecs);
- }
- };
- // That's not how node.js implements it but the exposed api is the same.
- exports.setImmediate = typeof setImmediate === "function" ? setImmediate : function(fn) {
- var id = nextImmediateId++;
- var args = arguments.length < 2 ? false : slice.call(arguments, 1);
- immediateIds[id] = true;
- nextTick(function onNextTick() {
- if (immediateIds[id]) {
- // fn.call() is faster so we optimize for the common use-case
- // @see http://jsperf.com/call-apply-segu
- if (args) {
- fn.apply(null, args);
- } else {
- fn.call(null);
- }
- // Prevent ids from leaking
- exports.clearImmediate(id);
- }
- });
- return id;
- };
- exports.clearImmediate = typeof clearImmediate === "function" ? clearImmediate : function(id) {
- delete immediateIds[id];
- };
- }).call(this)}).call(this,_dereq_("timers").setImmediate,_dereq_("timers").clearImmediate)
- },{"process/browser.js":793,"timers":796}],797:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- Object.defineProperty(exports, "v1", {
- enumerable: true,
- get: function () {
- return _v.default;
- }
- });
- Object.defineProperty(exports, "v3", {
- enumerable: true,
- get: function () {
- return _v2.default;
- }
- });
- Object.defineProperty(exports, "v4", {
- enumerable: true,
- get: function () {
- return _v3.default;
- }
- });
- Object.defineProperty(exports, "v5", {
- enumerable: true,
- get: function () {
- return _v4.default;
- }
- });
- Object.defineProperty(exports, "NIL", {
- enumerable: true,
- get: function () {
- return _nil.default;
- }
- });
- Object.defineProperty(exports, "version", {
- enumerable: true,
- get: function () {
- return _version.default;
- }
- });
- Object.defineProperty(exports, "validate", {
- enumerable: true,
- get: function () {
- return _validate.default;
- }
- });
- Object.defineProperty(exports, "stringify", {
- enumerable: true,
- get: function () {
- return _stringify.default;
- }
- });
- Object.defineProperty(exports, "parse", {
- enumerable: true,
- get: function () {
- return _parse.default;
- }
- });
- var _v = _interopRequireDefault(_dereq_("./v1.js"));
- var _v2 = _interopRequireDefault(_dereq_("./v3.js"));
- var _v3 = _interopRequireDefault(_dereq_("./v4.js"));
- var _v4 = _interopRequireDefault(_dereq_("./v5.js"));
- var _nil = _interopRequireDefault(_dereq_("./nil.js"));
- var _version = _interopRequireDefault(_dereq_("./version.js"));
- var _validate = _interopRequireDefault(_dereq_("./validate.js"));
- var _stringify = _interopRequireDefault(_dereq_("./stringify.js"));
- var _parse = _interopRequireDefault(_dereq_("./parse.js"));
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
- },{"./nil.js":799,"./parse.js":800,"./stringify.js":804,"./v1.js":805,"./v3.js":806,"./v4.js":808,"./v5.js":809,"./validate.js":810,"./version.js":811}],798:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = void 0;
- /*
- * Browser-compatible JavaScript MD5
- *
- * Modification of JavaScript MD5
- * https://github.com/blueimp/JavaScript-MD5
- *
- * Copyright 2011, Sebastian Tschan
- * https://blueimp.net
- *
- * Licensed under the MIT license:
- * https://opensource.org/licenses/MIT
- *
- * Based on
- * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
- * Digest Algorithm, as defined in RFC 1321.
- * Version 2.2 Copyright (C) Paul Johnston 1999 - 2009
- * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
- * Distributed under the BSD License
- * See http://pajhome.org.uk/crypt/md5 for more info.
- */
- function md5(bytes) {
- if (typeof bytes === 'string') {
- const msg = unescape(encodeURIComponent(bytes)); // UTF8 escape
- bytes = new Uint8Array(msg.length);
- for (let i = 0; i < msg.length; ++i) {
- bytes[i] = msg.charCodeAt(i);
- }
- }
- return md5ToHexEncodedArray(wordsToMd5(bytesToWords(bytes), bytes.length * 8));
- }
- /*
- * Convert an array of little-endian words to an array of bytes
- */
- function md5ToHexEncodedArray(input) {
- const output = [];
- const length32 = input.length * 32;
- const hexTab = '0123456789abcdef';
- for (let i = 0; i < length32; i += 8) {
- const x = input[i >> 5] >>> i % 32 & 0xff;
- const hex = parseInt(hexTab.charAt(x >>> 4 & 0x0f) + hexTab.charAt(x & 0x0f), 16);
- output.push(hex);
- }
- return output;
- }
- /**
- * Calculate output length with padding and bit length
- */
- function getOutputLength(inputLength8) {
- return (inputLength8 + 64 >>> 9 << 4) + 14 + 1;
- }
- /*
- * Calculate the MD5 of an array of little-endian words, and a bit length.
- */
- function wordsToMd5(x, len) {
- /* append padding */
- x[len >> 5] |= 0x80 << len % 32;
- x[getOutputLength(len) - 1] = len;
- let a = 1732584193;
- let b = -271733879;
- let c = -1732584194;
- let d = 271733878;
- for (let i = 0; i < x.length; i += 16) {
- const olda = a;
- const oldb = b;
- const oldc = c;
- const oldd = d;
- a = md5ff(a, b, c, d, x[i], 7, -680876936);
- d = md5ff(d, a, b, c, x[i + 1], 12, -389564586);
- c = md5ff(c, d, a, b, x[i + 2], 17, 606105819);
- b = md5ff(b, c, d, a, x[i + 3], 22, -1044525330);
- a = md5ff(a, b, c, d, x[i + 4], 7, -176418897);
- d = md5ff(d, a, b, c, x[i + 5], 12, 1200080426);
- c = md5ff(c, d, a, b, x[i + 6], 17, -1473231341);
- b = md5ff(b, c, d, a, x[i + 7], 22, -45705983);
- a = md5ff(a, b, c, d, x[i + 8], 7, 1770035416);
- d = md5ff(d, a, b, c, x[i + 9], 12, -1958414417);
- c = md5ff(c, d, a, b, x[i + 10], 17, -42063);
- b = md5ff(b, c, d, a, x[i + 11], 22, -1990404162);
- a = md5ff(a, b, c, d, x[i + 12], 7, 1804603682);
- d = md5ff(d, a, b, c, x[i + 13], 12, -40341101);
- c = md5ff(c, d, a, b, x[i + 14], 17, -1502002290);
- b = md5ff(b, c, d, a, x[i + 15], 22, 1236535329);
- a = md5gg(a, b, c, d, x[i + 1], 5, -165796510);
- d = md5gg(d, a, b, c, x[i + 6], 9, -1069501632);
- c = md5gg(c, d, a, b, x[i + 11], 14, 643717713);
- b = md5gg(b, c, d, a, x[i], 20, -373897302);
- a = md5gg(a, b, c, d, x[i + 5], 5, -701558691);
- d = md5gg(d, a, b, c, x[i + 10], 9, 38016083);
- c = md5gg(c, d, a, b, x[i + 15], 14, -660478335);
- b = md5gg(b, c, d, a, x[i + 4], 20, -405537848);
- a = md5gg(a, b, c, d, x[i + 9], 5, 568446438);
- d = md5gg(d, a, b, c, x[i + 14], 9, -1019803690);
- c = md5gg(c, d, a, b, x[i + 3], 14, -187363961);
- b = md5gg(b, c, d, a, x[i + 8], 20, 1163531501);
- a = md5gg(a, b, c, d, x[i + 13], 5, -1444681467);
- d = md5gg(d, a, b, c, x[i + 2], 9, -51403784);
- c = md5gg(c, d, a, b, x[i + 7], 14, 1735328473);
- b = md5gg(b, c, d, a, x[i + 12], 20, -1926607734);
- a = md5hh(a, b, c, d, x[i + 5], 4, -378558);
- d = md5hh(d, a, b, c, x[i + 8], 11, -2022574463);
- c = md5hh(c, d, a, b, x[i + 11], 16, 1839030562);
- b = md5hh(b, c, d, a, x[i + 14], 23, -35309556);
- a = md5hh(a, b, c, d, x[i + 1], 4, -1530992060);
- d = md5hh(d, a, b, c, x[i + 4], 11, 1272893353);
- c = md5hh(c, d, a, b, x[i + 7], 16, -155497632);
- b = md5hh(b, c, d, a, x[i + 10], 23, -1094730640);
- a = md5hh(a, b, c, d, x[i + 13], 4, 681279174);
- d = md5hh(d, a, b, c, x[i], 11, -358537222);
- c = md5hh(c, d, a, b, x[i + 3], 16, -722521979);
- b = md5hh(b, c, d, a, x[i + 6], 23, 76029189);
- a = md5hh(a, b, c, d, x[i + 9], 4, -640364487);
- d = md5hh(d, a, b, c, x[i + 12], 11, -421815835);
- c = md5hh(c, d, a, b, x[i + 15], 16, 530742520);
- b = md5hh(b, c, d, a, x[i + 2], 23, -995338651);
- a = md5ii(a, b, c, d, x[i], 6, -198630844);
- d = md5ii(d, a, b, c, x[i + 7], 10, 1126891415);
- c = md5ii(c, d, a, b, x[i + 14], 15, -1416354905);
- b = md5ii(b, c, d, a, x[i + 5], 21, -57434055);
- a = md5ii(a, b, c, d, x[i + 12], 6, 1700485571);
- d = md5ii(d, a, b, c, x[i + 3], 10, -1894986606);
- c = md5ii(c, d, a, b, x[i + 10], 15, -1051523);
- b = md5ii(b, c, d, a, x[i + 1], 21, -2054922799);
- a = md5ii(a, b, c, d, x[i + 8], 6, 1873313359);
- d = md5ii(d, a, b, c, x[i + 15], 10, -30611744);
- c = md5ii(c, d, a, b, x[i + 6], 15, -1560198380);
- b = md5ii(b, c, d, a, x[i + 13], 21, 1309151649);
- a = md5ii(a, b, c, d, x[i + 4], 6, -145523070);
- d = md5ii(d, a, b, c, x[i + 11], 10, -1120210379);
- c = md5ii(c, d, a, b, x[i + 2], 15, 718787259);
- b = md5ii(b, c, d, a, x[i + 9], 21, -343485551);
- a = safeAdd(a, olda);
- b = safeAdd(b, oldb);
- c = safeAdd(c, oldc);
- d = safeAdd(d, oldd);
- }
- return [a, b, c, d];
- }
- /*
- * Convert an array bytes to an array of little-endian words
- * Characters >255 have their high-byte silently ignored.
- */
- function bytesToWords(input) {
- if (input.length === 0) {
- return [];
- }
- const length8 = input.length * 8;
- const output = new Uint32Array(getOutputLength(length8));
- for (let i = 0; i < length8; i += 8) {
- output[i >> 5] |= (input[i / 8] & 0xff) << i % 32;
- }
- return output;
- }
- /*
- * Add integers, wrapping at 2^32. This uses 16-bit operations internally
- * to work around bugs in some JS interpreters.
- */
- function safeAdd(x, y) {
- const lsw = (x & 0xffff) + (y & 0xffff);
- const msw = (x >> 16) + (y >> 16) + (lsw >> 16);
- return msw << 16 | lsw & 0xffff;
- }
- /*
- * Bitwise rotate a 32-bit number to the left.
- */
- function bitRotateLeft(num, cnt) {
- return num << cnt | num >>> 32 - cnt;
- }
- /*
- * These functions implement the four basic operations the algorithm uses.
- */
- function md5cmn(q, a, b, x, s, t) {
- return safeAdd(bitRotateLeft(safeAdd(safeAdd(a, q), safeAdd(x, t)), s), b);
- }
- function md5ff(a, b, c, d, x, s, t) {
- return md5cmn(b & c | ~b & d, a, b, x, s, t);
- }
- function md5gg(a, b, c, d, x, s, t) {
- return md5cmn(b & d | c & ~d, a, b, x, s, t);
- }
- function md5hh(a, b, c, d, x, s, t) {
- return md5cmn(b ^ c ^ d, a, b, x, s, t);
- }
- function md5ii(a, b, c, d, x, s, t) {
- return md5cmn(c ^ (b | ~d), a, b, x, s, t);
- }
- var _default = md5;
- exports.default = _default;
- },{}],799:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = void 0;
- var _default = '00000000-0000-0000-0000-000000000000';
- exports.default = _default;
- },{}],800:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = void 0;
- var _validate = _interopRequireDefault(_dereq_("./validate.js"));
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
- function parse(uuid) {
- if (!(0, _validate.default)(uuid)) {
- throw TypeError('Invalid UUID');
- }
- let v;
- const arr = new Uint8Array(16); // Parse ########-....-....-....-............
- arr[0] = (v = parseInt(uuid.slice(0, 8), 16)) >>> 24;
- arr[1] = v >>> 16 & 0xff;
- arr[2] = v >>> 8 & 0xff;
- arr[3] = v & 0xff; // Parse ........-####-....-....-............
- arr[4] = (v = parseInt(uuid.slice(9, 13), 16)) >>> 8;
- arr[5] = v & 0xff; // Parse ........-....-####-....-............
- arr[6] = (v = parseInt(uuid.slice(14, 18), 16)) >>> 8;
- arr[7] = v & 0xff; // Parse ........-....-....-####-............
- arr[8] = (v = parseInt(uuid.slice(19, 23), 16)) >>> 8;
- arr[9] = v & 0xff; // Parse ........-....-....-....-############
- // (Use "/" to avoid 32-bit truncation when bit-shifting high-order bytes)
- arr[10] = (v = parseInt(uuid.slice(24, 36), 16)) / 0x10000000000 & 0xff;
- arr[11] = v / 0x100000000 & 0xff;
- arr[12] = v >>> 24 & 0xff;
- arr[13] = v >>> 16 & 0xff;
- arr[14] = v >>> 8 & 0xff;
- arr[15] = v & 0xff;
- return arr;
- }
- var _default = parse;
- exports.default = _default;
- },{"./validate.js":810}],801:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = void 0;
- var _default = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;
- exports.default = _default;
- },{}],802:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = rng;
- // Unique ID creation requires a high quality random # generator. In the browser we therefore
- // require the crypto API and do not support built-in fallback to lower quality random number
- // generators (like Math.random()).
- let getRandomValues;
- const rnds8 = new Uint8Array(16);
- function rng() {
- // lazy load so that environments that need to polyfill have a chance to do so
- if (!getRandomValues) {
- // getRandomValues needs to be invoked in a context where "this" is a Crypto implementation. Also,
- // find the complete implementation of crypto (msCrypto) on IE11.
- getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto !== 'undefined' && typeof msCrypto.getRandomValues === 'function' && msCrypto.getRandomValues.bind(msCrypto);
- if (!getRandomValues) {
- throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
- }
- }
- return getRandomValues(rnds8);
- }
- },{}],803:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = void 0;
- // Adapted from Chris Veness' SHA1 code at
- // http://www.movable-type.co.uk/scripts/sha1.html
- function f(s, x, y, z) {
- switch (s) {
- case 0:
- return x & y ^ ~x & z;
- case 1:
- return x ^ y ^ z;
- case 2:
- return x & y ^ x & z ^ y & z;
- case 3:
- return x ^ y ^ z;
- }
- }
- function ROTL(x, n) {
- return x << n | x >>> 32 - n;
- }
- function sha1(bytes) {
- const K = [0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6];
- const H = [0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0];
- if (typeof bytes === 'string') {
- const msg = unescape(encodeURIComponent(bytes)); // UTF8 escape
- bytes = [];
- for (let i = 0; i < msg.length; ++i) {
- bytes.push(msg.charCodeAt(i));
- }
- } else if (!Array.isArray(bytes)) {
- // Convert Array-like to Array
- bytes = Array.prototype.slice.call(bytes);
- }
- bytes.push(0x80);
- const l = bytes.length / 4 + 2;
- const N = Math.ceil(l / 16);
- const M = new Array(N);
- for (let i = 0; i < N; ++i) {
- const arr = new Uint32Array(16);
- for (let j = 0; j < 16; ++j) {
- arr[j] = bytes[i * 64 + j * 4] << 24 | bytes[i * 64 + j * 4 + 1] << 16 | bytes[i * 64 + j * 4 + 2] << 8 | bytes[i * 64 + j * 4 + 3];
- }
- M[i] = arr;
- }
- M[N - 1][14] = (bytes.length - 1) * 8 / Math.pow(2, 32);
- M[N - 1][14] = Math.floor(M[N - 1][14]);
- M[N - 1][15] = (bytes.length - 1) * 8 & 0xffffffff;
- for (let i = 0; i < N; ++i) {
- const W = new Uint32Array(80);
- for (let t = 0; t < 16; ++t) {
- W[t] = M[i][t];
- }
- for (let t = 16; t < 80; ++t) {
- W[t] = ROTL(W[t - 3] ^ W[t - 8] ^ W[t - 14] ^ W[t - 16], 1);
- }
- let a = H[0];
- let b = H[1];
- let c = H[2];
- let d = H[3];
- let e = H[4];
- for (let t = 0; t < 80; ++t) {
- const s = Math.floor(t / 20);
- const T = ROTL(a, 5) + f(s, b, c, d) + e + K[s] + W[t] >>> 0;
- e = d;
- d = c;
- c = ROTL(b, 30) >>> 0;
- b = a;
- a = T;
- }
- H[0] = H[0] + a >>> 0;
- H[1] = H[1] + b >>> 0;
- H[2] = H[2] + c >>> 0;
- H[3] = H[3] + d >>> 0;
- H[4] = H[4] + e >>> 0;
- }
- return [H[0] >> 24 & 0xff, H[0] >> 16 & 0xff, H[0] >> 8 & 0xff, H[0] & 0xff, H[1] >> 24 & 0xff, H[1] >> 16 & 0xff, H[1] >> 8 & 0xff, H[1] & 0xff, H[2] >> 24 & 0xff, H[2] >> 16 & 0xff, H[2] >> 8 & 0xff, H[2] & 0xff, H[3] >> 24 & 0xff, H[3] >> 16 & 0xff, H[3] >> 8 & 0xff, H[3] & 0xff, H[4] >> 24 & 0xff, H[4] >> 16 & 0xff, H[4] >> 8 & 0xff, H[4] & 0xff];
- }
- var _default = sha1;
- exports.default = _default;
- },{}],804:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = void 0;
- var _validate = _interopRequireDefault(_dereq_("./validate.js"));
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
- /**
- * Convert array of 16 byte values to UUID string format of the form:
- * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
- */
- const byteToHex = [];
- for (let i = 0; i < 256; ++i) {
- byteToHex.push((i + 0x100).toString(16).substr(1));
- }
- function stringify(arr, offset = 0) {
- // Note: Be careful editing this code! It's been tuned for performance
- // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
- const uuid = (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase(); // Consistency check for valid UUID. If this throws, it's likely due to one
- // of the following:
- // - One or more input array values don't map to a hex octet (leading to
- // "undefined" in the uuid)
- // - Invalid input values for the RFC `version` or `variant` fields
- if (!(0, _validate.default)(uuid)) {
- throw TypeError('Stringified UUID is invalid');
- }
- return uuid;
- }
- var _default = stringify;
- exports.default = _default;
- },{"./validate.js":810}],805:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = void 0;
- var _rng = _interopRequireDefault(_dereq_("./rng.js"));
- var _stringify = _interopRequireDefault(_dereq_("./stringify.js"));
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
- // **`v1()` - Generate time-based UUID**
- //
- // Inspired by https://github.com/LiosK/UUID.js
- // and http://docs.python.org/library/uuid.html
- let _nodeId;
- let _clockseq; // Previous uuid creation time
- let _lastMSecs = 0;
- let _lastNSecs = 0; // See https://github.com/uuidjs/uuid for API details
- function v1(options, buf, offset) {
- let i = buf && offset || 0;
- const b = buf || new Array(16);
- options = options || {};
- let node = options.node || _nodeId;
- let clockseq = options.clockseq !== undefined ? options.clockseq : _clockseq; // node and clockseq need to be initialized to random values if they're not
- // specified. We do this lazily to minimize issues related to insufficient
- // system entropy. See #189
- if (node == null || clockseq == null) {
- const seedBytes = options.random || (options.rng || _rng.default)();
- if (node == null) {
- // Per 4.5, create and 48-bit node id, (47 random bits + multicast bit = 1)
- node = _nodeId = [seedBytes[0] | 0x01, seedBytes[1], seedBytes[2], seedBytes[3], seedBytes[4], seedBytes[5]];
- }
- if (clockseq == null) {
- // Per 4.2.2, randomize (14 bit) clockseq
- clockseq = _clockseq = (seedBytes[6] << 8 | seedBytes[7]) & 0x3fff;
- }
- } // UUID timestamps are 100 nano-second units since the Gregorian epoch,
- // (1582-10-15 00:00). JSNumbers aren't precise enough for this, so
- // time is handled internally as 'msecs' (integer milliseconds) and 'nsecs'
- // (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 00:00.
- let msecs = options.msecs !== undefined ? options.msecs : Date.now(); // Per 4.2.1.2, use count of uuid's generated during the current clock
- // cycle to simulate higher resolution clock
- let nsecs = options.nsecs !== undefined ? options.nsecs : _lastNSecs + 1; // Time since last uuid creation (in msecs)
- const dt = msecs - _lastMSecs + (nsecs - _lastNSecs) / 10000; // Per 4.2.1.2, Bump clockseq on clock regression
- if (dt < 0 && options.clockseq === undefined) {
- clockseq = clockseq + 1 & 0x3fff;
- } // Reset nsecs if clock regresses (new clockseq) or we've moved onto a new
- // time interval
- if ((dt < 0 || msecs > _lastMSecs) && options.nsecs === undefined) {
- nsecs = 0;
- } // Per 4.2.1.2 Throw error if too many uuids are requested
- if (nsecs >= 10000) {
- throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");
- }
- _lastMSecs = msecs;
- _lastNSecs = nsecs;
- _clockseq = clockseq; // Per 4.1.4 - Convert from unix epoch to Gregorian epoch
- msecs += 12219292800000; // `time_low`
- const tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000;
- b[i++] = tl >>> 24 & 0xff;
- b[i++] = tl >>> 16 & 0xff;
- b[i++] = tl >>> 8 & 0xff;
- b[i++] = tl & 0xff; // `time_mid`
- const tmh = msecs / 0x100000000 * 10000 & 0xfffffff;
- b[i++] = tmh >>> 8 & 0xff;
- b[i++] = tmh & 0xff; // `time_high_and_version`
- b[i++] = tmh >>> 24 & 0xf | 0x10; // include version
- b[i++] = tmh >>> 16 & 0xff; // `clock_seq_hi_and_reserved` (Per 4.2.2 - include variant)
- b[i++] = clockseq >>> 8 | 0x80; // `clock_seq_low`
- b[i++] = clockseq & 0xff; // `node`
- for (let n = 0; n < 6; ++n) {
- b[i + n] = node[n];
- }
- return buf || (0, _stringify.default)(b);
- }
- var _default = v1;
- exports.default = _default;
- },{"./rng.js":802,"./stringify.js":804}],806:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = void 0;
- var _v = _interopRequireDefault(_dereq_("./v35.js"));
- var _md = _interopRequireDefault(_dereq_("./md5.js"));
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
- const v3 = (0, _v.default)('v3', 0x30, _md.default);
- var _default = v3;
- exports.default = _default;
- },{"./md5.js":798,"./v35.js":807}],807:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = _default;
- exports.URL = exports.DNS = void 0;
- var _stringify = _interopRequireDefault(_dereq_("./stringify.js"));
- var _parse = _interopRequireDefault(_dereq_("./parse.js"));
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
- function stringToBytes(str) {
- str = unescape(encodeURIComponent(str)); // UTF8 escape
- const bytes = [];
- for (let i = 0; i < str.length; ++i) {
- bytes.push(str.charCodeAt(i));
- }
- return bytes;
- }
- const DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8';
- exports.DNS = DNS;
- const URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8';
- exports.URL = URL;
- function _default(name, version, hashfunc) {
- function generateUUID(value, namespace, buf, offset) {
- if (typeof value === 'string') {
- value = stringToBytes(value);
- }
- if (typeof namespace === 'string') {
- namespace = (0, _parse.default)(namespace);
- }
- if (namespace.length !== 16) {
- throw TypeError('Namespace must be array-like (16 iterable integer values, 0-255)');
- } // Compute hash of namespace and value, Per 4.3
- // Future: Use spread syntax when supported on all platforms, e.g. `bytes =
- // hashfunc([...namespace, ... value])`
- let bytes = new Uint8Array(16 + value.length);
- bytes.set(namespace);
- bytes.set(value, namespace.length);
- bytes = hashfunc(bytes);
- bytes[6] = bytes[6] & 0x0f | version;
- bytes[8] = bytes[8] & 0x3f | 0x80;
- if (buf) {
- offset = offset || 0;
- for (let i = 0; i < 16; ++i) {
- buf[offset + i] = bytes[i];
- }
- return buf;
- }
- return (0, _stringify.default)(bytes);
- } // Function#name is not settable on some platforms (#270)
- try {
- generateUUID.name = name; // eslint-disable-next-line no-empty
- } catch (err) {} // For CommonJS default export support
- generateUUID.DNS = DNS;
- generateUUID.URL = URL;
- return generateUUID;
- }
- },{"./parse.js":800,"./stringify.js":804}],808:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = void 0;
- var _rng = _interopRequireDefault(_dereq_("./rng.js"));
- var _stringify = _interopRequireDefault(_dereq_("./stringify.js"));
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
- function v4(options, buf, offset) {
- options = options || {};
- const rnds = options.random || (options.rng || _rng.default)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
- rnds[6] = rnds[6] & 0x0f | 0x40;
- rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
- if (buf) {
- offset = offset || 0;
- for (let i = 0; i < 16; ++i) {
- buf[offset + i] = rnds[i];
- }
- return buf;
- }
- return (0, _stringify.default)(rnds);
- }
- var _default = v4;
- exports.default = _default;
- },{"./rng.js":802,"./stringify.js":804}],809:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = void 0;
- var _v = _interopRequireDefault(_dereq_("./v35.js"));
- var _sha = _interopRequireDefault(_dereq_("./sha1.js"));
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
- const v5 = (0, _v.default)('v5', 0x50, _sha.default);
- var _default = v5;
- exports.default = _default;
- },{"./sha1.js":803,"./v35.js":807}],810:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = void 0;
- var _regex = _interopRequireDefault(_dereq_("./regex.js"));
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
- function validate(uuid) {
- return typeof uuid === 'string' && _regex.default.test(uuid);
- }
- var _default = validate;
- exports.default = _default;
- },{"./regex.js":801}],811:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = void 0;
- var _validate = _interopRequireDefault(_dereq_("./validate.js"));
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
- function version(uuid) {
- if (!(0, _validate.default)(uuid)) {
- throw TypeError('Invalid UUID');
- }
- return parseInt(uuid.substr(14, 1), 16);
- }
- var _default = version;
- exports.default = _default;
- },{"./validate.js":810}]},{},[25])(25)
- });
|