12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076690776907869079690806908169082690836908469085690866908769088690896909069091690926909369094690956909669097690986909969100691016910269103691046910569106691076910869109691106911169112691136911469115691166911769118691196912069121691226912369124691256912669127691286912969130691316913269133691346913569136691376913869139691406914169142691436914469145691466914769148691496915069151691526915369154691556915669157691586915969160691616916269163691646916569166691676916869169691706917169172691736917469175691766917769178691796918069181691826918369184691856918669187691886918969190691916919269193691946919569196691976919869199692006920169202692036920469205692066920769208692096921069211692126921369214692156921669217692186921969220692216922269223692246922569226692276922869229692306923169232692336923469235692366923769238692396924069241692426924369244692456924669247692486924969250692516925269253692546925569256692576925869259692606926169262692636926469265692666926769268692696927069271692726927369274692756927669277692786927969280692816928269283692846928569286692876928869289692906929169292692936929469295692966929769298692996930069301693026930369304693056930669307693086930969310693116931269313693146931569316693176931869319693206932169322693236932469325693266932769328693296933069331693326933369334693356933669337693386933969340693416934269343693446934569346693476934869349693506935169352693536935469355693566935769358693596936069361693626936369364693656936669367693686936969370693716937269373693746937569376693776937869379693806938169382693836938469385693866938769388693896939069391693926939369394693956939669397693986939969400694016940269403694046940569406694076940869409694106941169412694136941469415694166941769418694196942069421694226942369424694256942669427694286942969430694316943269433694346943569436694376943869439694406944169442694436944469445694466944769448694496945069451694526945369454694556945669457694586945969460694616946269463694646946569466694676946869469694706947169472694736947469475694766947769478694796948069481694826948369484694856948669487694886948969490694916949269493694946949569496694976949869499695006950169502695036950469505695066950769508695096951069511695126951369514695156951669517695186951969520695216952269523695246952569526695276952869529695306953169532695336953469535695366953769538695396954069541695426954369544695456954669547695486954969550695516955269553695546955569556695576955869559695606956169562695636956469565695666956769568695696957069571695726957369574695756957669577695786957969580695816958269583695846958569586695876958869589695906959169592695936959469595695966959769598695996960069601696026960369604696056960669607696086960969610696116961269613696146961569616696176961869619696206962169622696236962469625696266962769628696296963069631696326963369634696356963669637696386963969640696416964269643696446964569646696476964869649696506965169652696536965469655696566965769658696596966069661696626966369664696656966669667696686966969670696716967269673696746967569676696776967869679696806968169682696836968469685696866968769688696896969069691696926969369694696956969669697696986969969700697016970269703697046970569706697076970869709697106971169712697136971469715697166971769718697196972069721697226972369724697256972669727697286972969730697316973269733697346973569736697376973869739697406974169742697436974469745697466974769748697496975069751697526975369754697556975669757697586975969760697616976269763697646976569766697676976869769697706977169772697736977469775697766977769778697796978069781697826978369784697856978669787697886978969790697916979269793697946979569796697976979869799698006980169802698036980469805698066980769808698096981069811698126981369814698156981669817698186981969820698216982269823698246982569826698276982869829698306983169832698336983469835698366983769838698396984069841698426984369844698456984669847698486984969850698516985269853698546985569856698576985869859698606986169862698636986469865698666986769868698696987069871698726987369874698756987669877698786987969880698816988269883698846988569886698876988869889698906989169892698936989469895698966989769898698996990069901699026990369904699056990669907699086990969910699116991269913699146991569916699176991869919699206992169922699236992469925699266992769928699296993069931699326993369934699356993669937699386993969940699416994269943699446994569946699476994869949699506995169952699536995469955699566995769958699596996069961699626996369964699656996669967699686996969970699716997269973699746997569976699776997869979699806998169982699836998469985699866998769988699896999069991699926999369994699956999669997699986999970000700017000270003700047000570006700077000870009700107001170012700137001470015700167001770018700197002070021700227002370024700257002670027700287002970030700317003270033700347003570036700377003870039700407004170042700437004470045700467004770048700497005070051700527005370054700557005670057700587005970060700617006270063700647006570066700677006870069700707007170072700737007470075700767007770078700797008070081700827008370084700857008670087700887008970090700917009270093700947009570096700977009870099701007010170102701037010470105701067010770108701097011070111701127011370114701157011670117701187011970120701217012270123701247012570126701277012870129701307013170132701337013470135701367013770138701397014070141701427014370144701457014670147701487014970150701517015270153701547015570156701577015870159701607016170162701637016470165701667016770168701697017070171701727017370174701757017670177701787017970180701817018270183701847018570186701877018870189701907019170192701937019470195701967019770198701997020070201702027020370204702057020670207702087020970210702117021270213702147021570216702177021870219702207022170222702237022470225702267022770228702297023070231702327023370234702357023670237702387023970240702417024270243702447024570246702477024870249702507025170252702537025470255702567025770258702597026070261702627026370264702657026670267702687026970270702717027270273702747027570276702777027870279702807028170282702837028470285702867028770288702897029070291702927029370294702957029670297702987029970300703017030270303703047030570306703077030870309703107031170312703137031470315703167031770318703197032070321703227032370324703257032670327703287032970330703317033270333703347033570336703377033870339703407034170342703437034470345703467034770348703497035070351703527035370354703557035670357703587035970360703617036270363703647036570366703677036870369703707037170372703737037470375703767037770378703797038070381703827038370384703857038670387703887038970390703917039270393703947039570396703977039870399704007040170402704037040470405704067040770408704097041070411704127041370414704157041670417704187041970420704217042270423704247042570426704277042870429704307043170432704337043470435704367043770438704397044070441704427044370444704457044670447704487044970450704517045270453704547045570456704577045870459704607046170462704637046470465704667046770468704697047070471704727047370474704757047670477704787047970480704817048270483704847048570486704877048870489704907049170492704937049470495704967049770498704997050070501705027050370504705057050670507705087050970510705117051270513705147051570516705177051870519705207052170522705237052470525705267052770528705297053070531705327053370534705357053670537705387053970540705417054270543705447054570546705477054870549705507055170552705537055470555705567055770558705597056070561705627056370564705657056670567705687056970570705717057270573705747057570576705777057870579705807058170582705837058470585705867058770588705897059070591705927059370594705957059670597705987059970600706017060270603706047060570606706077060870609706107061170612706137061470615706167061770618706197062070621706227062370624706257062670627706287062970630706317063270633706347063570636706377063870639706407064170642706437064470645706467064770648706497065070651706527065370654706557065670657706587065970660706617066270663706647066570666706677066870669706707067170672706737067470675706767067770678706797068070681706827068370684706857068670687706887068970690706917069270693706947069570696706977069870699707007070170702707037070470705707067070770708707097071070711707127071370714707157071670717707187071970720707217072270723707247072570726707277072870729707307073170732707337073470735707367073770738707397074070741707427074370744707457074670747707487074970750707517075270753707547075570756707577075870759707607076170762707637076470765707667076770768707697077070771707727077370774707757077670777707787077970780707817078270783707847078570786707877078870789707907079170792707937079470795707967079770798707997080070801708027080370804708057080670807708087080970810708117081270813708147081570816708177081870819708207082170822708237082470825708267082770828708297083070831708327083370834708357083670837708387083970840708417084270843708447084570846708477084870849708507085170852708537085470855708567085770858708597086070861708627086370864708657086670867708687086970870708717087270873708747087570876708777087870879708807088170882708837088470885708867088770888708897089070891708927089370894708957089670897708987089970900709017090270903709047090570906709077090870909709107091170912709137091470915709167091770918709197092070921709227092370924709257092670927709287092970930709317093270933709347093570936709377093870939709407094170942709437094470945709467094770948709497095070951709527095370954709557095670957709587095970960709617096270963709647096570966709677096870969709707097170972709737097470975709767097770978709797098070981709827098370984709857098670987709887098970990709917099270993709947099570996709977099870999710007100171002710037100471005710067100771008710097101071011710127101371014710157101671017710187101971020710217102271023710247102571026710277102871029710307103171032710337103471035710367103771038710397104071041710427104371044710457104671047710487104971050710517105271053710547105571056710577105871059710607106171062710637106471065710667106771068710697107071071710727107371074710757107671077710787107971080710817108271083710847108571086710877108871089710907109171092710937109471095710967109771098710997110071101711027110371104711057110671107711087110971110711117111271113711147111571116711177111871119711207112171122711237112471125711267112771128711297113071131711327113371134711357113671137711387113971140711417114271143711447114571146711477114871149711507115171152711537115471155711567115771158711597116071161711627116371164711657116671167711687116971170711717117271173711747117571176711777117871179711807118171182711837118471185711867118771188711897119071191711927119371194711957119671197711987119971200712017120271203712047120571206712077120871209712107121171212712137121471215712167121771218712197122071221712227122371224712257122671227712287122971230712317123271233712347123571236712377123871239712407124171242712437124471245712467124771248712497125071251712527125371254712557125671257712587125971260712617126271263712647126571266712677126871269712707127171272712737127471275712767127771278712797128071281712827128371284712857128671287712887128971290712917129271293712947129571296712977129871299713007130171302713037130471305713067130771308713097131071311713127131371314713157131671317713187131971320713217132271323713247132571326713277132871329713307133171332713337133471335713367133771338713397134071341713427134371344713457134671347713487134971350713517135271353713547135571356713577135871359713607136171362713637136471365713667136771368713697137071371713727137371374713757137671377713787137971380713817138271383713847138571386713877138871389713907139171392713937139471395713967139771398713997140071401714027140371404714057140671407714087140971410714117141271413714147141571416714177141871419714207142171422714237142471425714267142771428714297143071431714327143371434714357143671437714387143971440714417144271443714447144571446714477144871449714507145171452714537145471455714567145771458714597146071461714627146371464714657146671467714687146971470714717147271473714747147571476714777147871479714807148171482714837148471485714867148771488714897149071491714927149371494714957149671497714987149971500715017150271503715047150571506715077150871509715107151171512715137151471515715167151771518715197152071521715227152371524715257152671527715287152971530715317153271533715347153571536715377153871539715407154171542715437154471545715467154771548715497155071551715527155371554715557155671557715587155971560715617156271563715647156571566715677156871569715707157171572715737157471575715767157771578715797158071581715827158371584715857158671587715887158971590715917159271593715947159571596715977159871599716007160171602716037160471605716067160771608716097161071611716127161371614716157161671617716187161971620716217162271623716247162571626716277162871629716307163171632716337163471635716367163771638716397164071641716427164371644716457164671647716487164971650716517165271653716547165571656716577165871659716607166171662716637166471665716667166771668716697167071671716727167371674716757167671677716787167971680716817168271683716847168571686716877168871689716907169171692716937169471695716967169771698716997170071701717027170371704717057170671707717087170971710717117171271713717147171571716717177171871719717207172171722717237172471725717267172771728717297173071731717327173371734717357173671737717387173971740717417174271743717447174571746717477174871749717507175171752717537175471755717567175771758717597176071761717627176371764717657176671767717687176971770717717177271773717747177571776717777177871779717807178171782717837178471785717867178771788717897179071791717927179371794717957179671797717987179971800718017180271803718047180571806718077180871809718107181171812718137181471815718167181771818718197182071821718227182371824718257182671827718287182971830718317183271833718347183571836718377183871839718407184171842718437184471845718467184771848718497185071851718527185371854718557185671857718587185971860718617186271863718647186571866718677186871869718707187171872718737187471875718767187771878718797188071881718827188371884718857188671887718887188971890718917189271893718947189571896718977189871899719007190171902719037190471905719067190771908719097191071911719127191371914719157191671917719187191971920719217192271923719247192571926719277192871929719307193171932719337193471935719367193771938719397194071941719427194371944719457194671947719487194971950719517195271953719547195571956719577195871959719607196171962719637196471965719667196771968719697197071971719727197371974719757197671977719787197971980719817198271983719847198571986719877198871989719907199171992719937199471995719967199771998719997200072001720027200372004720057200672007720087200972010720117201272013720147201572016720177201872019720207202172022720237202472025720267202772028720297203072031720327203372034720357203672037720387203972040720417204272043720447204572046720477204872049720507205172052720537205472055720567205772058720597206072061720627206372064720657206672067720687206972070720717207272073720747207572076720777207872079720807208172082720837208472085720867208772088720897209072091720927209372094720957209672097720987209972100721017210272103721047210572106721077210872109721107211172112721137211472115721167211772118721197212072121721227212372124721257212672127721287212972130721317213272133721347213572136721377213872139721407214172142721437214472145721467214772148721497215072151721527215372154721557215672157721587215972160721617216272163721647216572166721677216872169721707217172172721737217472175721767217772178721797218072181721827218372184721857218672187721887218972190721917219272193721947219572196721977219872199722007220172202722037220472205722067220772208722097221072211722127221372214722157221672217722187221972220722217222272223722247222572226722277222872229722307223172232722337223472235722367223772238722397224072241722427224372244722457224672247722487224972250722517225272253722547225572256722577225872259722607226172262722637226472265722667226772268722697227072271722727227372274722757227672277722787227972280722817228272283722847228572286722877228872289722907229172292722937229472295722967229772298722997230072301723027230372304723057230672307723087230972310723117231272313723147231572316723177231872319723207232172322723237232472325723267232772328723297233072331723327233372334723357233672337723387233972340723417234272343723447234572346723477234872349723507235172352723537235472355723567235772358723597236072361723627236372364723657236672367723687236972370723717237272373723747237572376723777237872379723807238172382723837238472385723867238772388723897239072391723927239372394723957239672397723987239972400724017240272403724047240572406724077240872409724107241172412724137241472415724167241772418724197242072421724227242372424724257242672427724287242972430724317243272433724347243572436724377243872439724407244172442724437244472445724467244772448724497245072451724527245372454724557245672457724587245972460724617246272463724647246572466724677246872469724707247172472724737247472475724767247772478724797248072481724827248372484724857248672487724887248972490724917249272493724947249572496724977249872499725007250172502725037250472505725067250772508725097251072511725127251372514725157251672517725187251972520725217252272523725247252572526725277252872529725307253172532725337253472535725367253772538725397254072541725427254372544725457254672547725487254972550725517255272553725547255572556725577255872559725607256172562725637256472565725667256772568725697257072571725727257372574725757257672577725787257972580725817258272583725847258572586725877258872589725907259172592725937259472595725967259772598725997260072601726027260372604726057260672607726087260972610726117261272613726147261572616726177261872619726207262172622726237262472625726267262772628726297263072631726327263372634726357263672637726387263972640726417264272643726447264572646726477264872649726507265172652726537265472655726567265772658726597266072661726627266372664726657266672667726687266972670726717267272673726747267572676726777267872679726807268172682726837268472685726867268772688726897269072691726927269372694726957269672697726987269972700727017270272703727047270572706727077270872709727107271172712727137271472715727167271772718727197272072721727227272372724727257272672727727287272972730727317273272733727347273572736727377273872739727407274172742727437274472745727467274772748727497275072751727527275372754727557275672757727587275972760727617276272763727647276572766727677276872769727707277172772727737277472775727767277772778727797278072781727827278372784727857278672787727887278972790727917279272793727947279572796727977279872799728007280172802728037280472805728067280772808728097281072811728127281372814728157281672817728187281972820728217282272823728247282572826728277282872829728307283172832728337283472835728367283772838728397284072841728427284372844728457284672847728487284972850728517285272853728547285572856728577285872859728607286172862728637286472865728667286772868728697287072871728727287372874728757287672877728787287972880728817288272883728847288572886728877288872889728907289172892728937289472895728967289772898728997290072901729027290372904729057290672907729087290972910729117291272913729147291572916729177291872919729207292172922729237292472925729267292772928729297293072931729327293372934729357293672937729387293972940729417294272943729447294572946729477294872949729507295172952729537295472955729567295772958729597296072961729627296372964729657296672967729687296972970729717297272973729747297572976729777297872979729807298172982729837298472985729867298772988729897299072991729927299372994729957299672997729987299973000730017300273003730047300573006730077300873009730107301173012730137301473015730167301773018730197302073021730227302373024730257302673027730287302973030730317303273033730347303573036730377303873039730407304173042730437304473045730467304773048730497305073051730527305373054730557305673057730587305973060730617306273063730647306573066730677306873069730707307173072730737307473075730767307773078730797308073081730827308373084730857308673087730887308973090730917309273093730947309573096730977309873099731007310173102731037310473105731067310773108731097311073111731127311373114731157311673117731187311973120731217312273123731247312573126731277312873129731307313173132731337313473135731367313773138731397314073141731427314373144731457314673147731487314973150731517315273153731547315573156731577315873159731607316173162731637316473165731667316773168731697317073171731727317373174731757317673177731787317973180731817318273183731847318573186731877318873189731907319173192731937319473195731967319773198731997320073201732027320373204732057320673207732087320973210732117321273213732147321573216732177321873219732207322173222732237322473225732267322773228732297323073231732327323373234732357323673237732387323973240732417324273243732447324573246732477324873249732507325173252732537325473255732567325773258732597326073261732627326373264732657326673267732687326973270732717327273273732747327573276732777327873279732807328173282732837328473285732867328773288732897329073291732927329373294732957329673297732987329973300733017330273303733047330573306733077330873309733107331173312733137331473315733167331773318733197332073321733227332373324733257332673327733287332973330733317333273333733347333573336733377333873339733407334173342733437334473345733467334773348733497335073351733527335373354733557335673357733587335973360733617336273363733647336573366733677336873369733707337173372733737337473375733767337773378733797338073381733827338373384733857338673387733887338973390733917339273393733947339573396733977339873399734007340173402734037340473405734067340773408734097341073411734127341373414734157341673417734187341973420734217342273423734247342573426734277342873429734307343173432734337343473435734367343773438734397344073441734427344373444734457344673447734487344973450734517345273453734547345573456734577345873459734607346173462734637346473465734667346773468734697347073471734727347373474734757347673477734787347973480734817348273483734847348573486734877348873489734907349173492734937349473495734967349773498734997350073501735027350373504735057350673507735087350973510735117351273513735147351573516735177351873519735207352173522735237352473525735267352773528735297353073531735327353373534735357353673537735387353973540735417354273543735447354573546735477354873549735507355173552735537355473555735567355773558735597356073561735627356373564735657356673567735687356973570735717357273573735747357573576735777357873579735807358173582735837358473585735867358773588735897359073591735927359373594735957359673597735987359973600736017360273603736047360573606736077360873609736107361173612736137361473615736167361773618736197362073621736227362373624736257362673627736287362973630736317363273633736347363573636736377363873639736407364173642736437364473645736467364773648736497365073651736527365373654736557365673657736587365973660736617366273663736647366573666736677366873669736707367173672736737367473675736767367773678736797368073681736827368373684736857368673687736887368973690736917369273693736947369573696736977369873699737007370173702737037370473705737067370773708737097371073711737127371373714737157371673717737187371973720737217372273723737247372573726737277372873729737307373173732737337373473735737367373773738737397374073741737427374373744737457374673747737487374973750737517375273753737547375573756737577375873759737607376173762737637376473765737667376773768737697377073771737727377373774737757377673777737787377973780737817378273783737847378573786737877378873789737907379173792737937379473795737967379773798737997380073801738027380373804738057380673807738087380973810738117381273813738147381573816738177381873819738207382173822738237382473825738267382773828738297383073831738327383373834738357383673837738387383973840738417384273843738447384573846738477384873849738507385173852738537385473855738567385773858738597386073861738627386373864738657386673867738687386973870738717387273873738747387573876738777387873879738807388173882738837388473885738867388773888738897389073891738927389373894738957389673897738987389973900739017390273903739047390573906739077390873909739107391173912739137391473915739167391773918739197392073921739227392373924739257392673927739287392973930739317393273933739347393573936739377393873939739407394173942739437394473945739467394773948739497395073951739527395373954739557395673957739587395973960739617396273963739647396573966739677396873969739707397173972739737397473975739767397773978739797398073981739827398373984739857398673987739887398973990739917399273993739947399573996739977399873999740007400174002740037400474005740067400774008740097401074011740127401374014740157401674017740187401974020740217402274023740247402574026740277402874029740307403174032740337403474035740367403774038740397404074041740427404374044740457404674047740487404974050740517405274053740547405574056740577405874059740607406174062740637406474065740667406774068740697407074071740727407374074740757407674077740787407974080740817408274083740847408574086740877408874089740907409174092740937409474095740967409774098740997410074101741027410374104741057410674107741087410974110741117411274113741147411574116741177411874119741207412174122741237412474125741267412774128741297413074131741327413374134741357413674137741387413974140741417414274143741447414574146741477414874149741507415174152741537415474155741567415774158741597416074161741627416374164741657416674167741687416974170741717417274173741747417574176741777417874179741807418174182741837418474185741867418774188741897419074191741927419374194741957419674197741987419974200742017420274203742047420574206742077420874209742107421174212742137421474215742167421774218742197422074221742227422374224742257422674227742287422974230742317423274233742347423574236742377423874239742407424174242742437424474245742467424774248742497425074251742527425374254742557425674257742587425974260742617426274263742647426574266742677426874269742707427174272742737427474275742767427774278742797428074281742827428374284742857428674287742887428974290742917429274293742947429574296742977429874299743007430174302743037430474305743067430774308743097431074311743127431374314743157431674317743187431974320743217432274323743247432574326743277432874329743307433174332743337433474335743367433774338743397434074341743427434374344743457434674347743487434974350743517435274353743547435574356743577435874359743607436174362743637436474365743667436774368743697437074371743727437374374743757437674377743787437974380743817438274383743847438574386743877438874389743907439174392743937439474395743967439774398743997440074401744027440374404744057440674407744087440974410744117441274413744147441574416744177441874419744207442174422744237442474425744267442774428744297443074431744327443374434744357443674437744387443974440744417444274443744447444574446744477444874449744507445174452744537445474455744567445774458744597446074461744627446374464744657446674467744687446974470744717447274473744747447574476744777447874479744807448174482744837448474485744867448774488744897449074491744927449374494744957449674497744987449974500745017450274503745047450574506745077450874509745107451174512745137451474515745167451774518745197452074521745227452374524745257452674527745287452974530745317453274533745347453574536745377453874539745407454174542745437454474545745467454774548745497455074551745527455374554745557455674557745587455974560745617456274563745647456574566745677456874569745707457174572745737457474575745767457774578745797458074581745827458374584745857458674587745887458974590745917459274593745947459574596745977459874599746007460174602746037460474605746067460774608746097461074611746127461374614746157461674617746187461974620746217462274623746247462574626746277462874629746307463174632746337463474635746367463774638746397464074641746427464374644746457464674647746487464974650746517465274653746547465574656746577465874659746607466174662746637466474665746667466774668746697467074671746727467374674746757467674677746787467974680746817468274683746847468574686746877468874689746907469174692746937469474695746967469774698746997470074701747027470374704747057470674707747087470974710747117471274713747147471574716747177471874719747207472174722747237472474725747267472774728747297473074731747327473374734747357473674737747387473974740747417474274743747447474574746747477474874749747507475174752747537475474755747567475774758747597476074761747627476374764747657476674767747687476974770747717477274773747747477574776747777477874779747807478174782747837478474785747867478774788747897479074791747927479374794747957479674797747987479974800748017480274803748047480574806748077480874809748107481174812748137481474815748167481774818748197482074821748227482374824748257482674827748287482974830748317483274833748347483574836748377483874839748407484174842748437484474845748467484774848748497485074851748527485374854748557485674857748587485974860748617486274863748647486574866748677486874869748707487174872748737487474875748767487774878748797488074881748827488374884748857488674887748887488974890748917489274893748947489574896748977489874899749007490174902749037490474905749067490774908749097491074911749127491374914749157491674917749187491974920749217492274923749247492574926749277492874929749307493174932749337493474935749367493774938749397494074941749427494374944749457494674947749487494974950749517495274953749547495574956749577495874959749607496174962749637496474965749667496774968749697497074971749727497374974749757497674977749787497974980749817498274983749847498574986749877498874989749907499174992749937499474995749967499774998749997500075001750027500375004750057500675007750087500975010750117501275013750147501575016750177501875019750207502175022750237502475025750267502775028750297503075031750327503375034750357503675037750387503975040750417504275043750447504575046750477504875049750507505175052750537505475055750567505775058750597506075061750627506375064750657506675067750687506975070750717507275073750747507575076750777507875079750807508175082750837508475085750867508775088750897509075091750927509375094750957509675097750987509975100751017510275103751047510575106751077510875109751107511175112751137511475115751167511775118751197512075121751227512375124751257512675127751287512975130751317513275133751347513575136751377513875139751407514175142751437514475145751467514775148751497515075151751527515375154751557515675157751587515975160751617516275163751647516575166751677516875169751707517175172751737517475175751767517775178751797518075181751827518375184751857518675187751887518975190751917519275193751947519575196751977519875199752007520175202752037520475205752067520775208752097521075211752127521375214752157521675217752187521975220752217522275223752247522575226752277522875229752307523175232752337523475235752367523775238752397524075241752427524375244752457524675247752487524975250752517525275253752547525575256752577525875259752607526175262752637526475265752667526775268752697527075271752727527375274752757527675277752787527975280752817528275283752847528575286752877528875289752907529175292752937529475295752967529775298752997530075301753027530375304753057530675307753087530975310753117531275313753147531575316753177531875319753207532175322753237532475325753267532775328753297533075331753327533375334753357533675337753387533975340753417534275343753447534575346753477534875349753507535175352753537535475355753567535775358753597536075361753627536375364753657536675367753687536975370753717537275373753747537575376753777537875379753807538175382753837538475385753867538775388753897539075391753927539375394753957539675397753987539975400754017540275403754047540575406754077540875409754107541175412754137541475415754167541775418754197542075421754227542375424754257542675427754287542975430754317543275433754347543575436754377543875439754407544175442754437544475445754467544775448754497545075451754527545375454754557545675457754587545975460754617546275463754647546575466754677546875469754707547175472754737547475475754767547775478754797548075481754827548375484754857548675487754887548975490754917549275493754947549575496754977549875499755007550175502755037550475505755067550775508755097551075511755127551375514755157551675517755187551975520755217552275523755247552575526755277552875529755307553175532755337553475535755367553775538755397554075541755427554375544755457554675547755487554975550755517555275553755547555575556755577555875559755607556175562755637556475565755667556775568755697557075571755727557375574755757557675577755787557975580755817558275583755847558575586755877558875589755907559175592755937559475595755967559775598755997560075601756027560375604756057560675607756087560975610756117561275613756147561575616756177561875619756207562175622756237562475625756267562775628756297563075631756327563375634756357563675637756387563975640756417564275643756447564575646756477564875649756507565175652756537565475655756567565775658756597566075661756627566375664756657566675667756687566975670756717567275673756747567575676756777567875679756807568175682756837568475685756867568775688756897569075691756927569375694756957569675697756987569975700757017570275703757047570575706757077570875709757107571175712757137571475715757167571775718757197572075721757227572375724757257572675727757287572975730757317573275733757347573575736757377573875739757407574175742757437574475745757467574775748757497575075751757527575375754757557575675757757587575975760757617576275763757647576575766757677576875769757707577175772757737577475775757767577775778757797578075781757827578375784757857578675787757887578975790757917579275793757947579575796757977579875799758007580175802758037580475805758067580775808758097581075811758127581375814758157581675817758187581975820758217582275823758247582575826758277582875829758307583175832758337583475835758367583775838758397584075841758427584375844758457584675847758487584975850758517585275853758547585575856758577585875859758607586175862758637586475865758667586775868758697587075871758727587375874758757587675877758787587975880758817588275883758847588575886758877588875889758907589175892758937589475895758967589775898758997590075901759027590375904759057590675907759087590975910759117591275913759147591575916759177591875919759207592175922759237592475925759267592775928759297593075931759327593375934759357593675937759387593975940759417594275943759447594575946759477594875949759507595175952759537595475955759567595775958759597596075961759627596375964759657596675967759687596975970759717597275973759747597575976759777597875979759807598175982759837598475985759867598775988759897599075991759927599375994759957599675997759987599976000760017600276003760047600576006760077600876009760107601176012760137601476015760167601776018760197602076021760227602376024760257602676027760287602976030760317603276033760347603576036760377603876039760407604176042760437604476045760467604776048760497605076051760527605376054760557605676057760587605976060760617606276063760647606576066760677606876069760707607176072760737607476075760767607776078760797608076081760827608376084760857608676087760887608976090760917609276093760947609576096760977609876099761007610176102761037610476105761067610776108761097611076111761127611376114761157611676117761187611976120761217612276123761247612576126761277612876129761307613176132761337613476135761367613776138761397614076141761427614376144761457614676147761487614976150761517615276153761547615576156761577615876159761607616176162761637616476165761667616776168761697617076171761727617376174761757617676177761787617976180761817618276183761847618576186761877618876189761907619176192761937619476195761967619776198761997620076201762027620376204762057620676207762087620976210762117621276213762147621576216762177621876219762207622176222762237622476225762267622776228762297623076231762327623376234762357623676237762387623976240762417624276243762447624576246762477624876249762507625176252762537625476255762567625776258762597626076261762627626376264762657626676267762687626976270762717627276273762747627576276762777627876279762807628176282762837628476285762867628776288762897629076291762927629376294762957629676297762987629976300763017630276303763047630576306763077630876309763107631176312763137631476315763167631776318763197632076321763227632376324763257632676327763287632976330763317633276333763347633576336763377633876339763407634176342763437634476345763467634776348763497635076351763527635376354763557635676357763587635976360763617636276363763647636576366763677636876369763707637176372763737637476375763767637776378763797638076381763827638376384763857638676387763887638976390763917639276393763947639576396763977639876399764007640176402764037640476405764067640776408764097641076411764127641376414764157641676417764187641976420764217642276423764247642576426764277642876429764307643176432764337643476435764367643776438764397644076441764427644376444764457644676447764487644976450764517645276453764547645576456764577645876459764607646176462764637646476465764667646776468764697647076471764727647376474764757647676477764787647976480764817648276483764847648576486764877648876489764907649176492764937649476495764967649776498764997650076501765027650376504765057650676507765087650976510765117651276513765147651576516765177651876519765207652176522765237652476525765267652776528765297653076531765327653376534765357653676537765387653976540765417654276543765447654576546765477654876549765507655176552765537655476555765567655776558765597656076561765627656376564765657656676567765687656976570765717657276573765747657576576765777657876579765807658176582765837658476585765867658776588765897659076591765927659376594765957659676597765987659976600766017660276603766047660576606766077660876609766107661176612766137661476615766167661776618766197662076621766227662376624766257662676627766287662976630766317663276633766347663576636766377663876639766407664176642766437664476645766467664776648766497665076651766527665376654766557665676657766587665976660766617666276663766647666576666766677666876669766707667176672766737667476675766767667776678766797668076681766827668376684766857668676687766887668976690766917669276693766947669576696766977669876699767007670176702767037670476705767067670776708767097671076711767127671376714767157671676717767187671976720767217672276723767247672576726767277672876729767307673176732767337673476735767367673776738767397674076741767427674376744767457674676747767487674976750767517675276753767547675576756767577675876759767607676176762767637676476765767667676776768767697677076771767727677376774767757677676777767787677976780767817678276783767847678576786767877678876789767907679176792767937679476795767967679776798767997680076801768027680376804768057680676807768087680976810768117681276813768147681576816768177681876819768207682176822768237682476825768267682776828768297683076831768327683376834768357683676837768387683976840768417684276843768447684576846768477684876849768507685176852768537685476855768567685776858768597686076861768627686376864768657686676867768687686976870768717687276873768747687576876768777687876879768807688176882768837688476885768867688776888768897689076891768927689376894768957689676897768987689976900769017690276903769047690576906769077690876909769107691176912769137691476915769167691776918769197692076921769227692376924769257692676927769287692976930769317693276933769347693576936769377693876939769407694176942769437694476945769467694776948769497695076951769527695376954769557695676957769587695976960769617696276963769647696576966769677696876969769707697176972769737697476975769767697776978769797698076981769827698376984769857698676987769887698976990 |
- /**
- * 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":107,"@babel/runtime-corejs3/helpers/interopRequireDefault":154}],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":107,"@babel/runtime-corejs3/helpers/interopRequireDefault":154,"uuid":799}],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":107}],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":67,"./encode":68,"@babel/runtime-corejs3/core-js-stable/object/define-property":107,"@babel/runtime-corejs3/core-js-stable/object/keys":114,"@babel/runtime-corejs3/core-js-stable/promise":117,"@babel/runtime-corejs3/helpers/interopRequireDefault":154,"@babel/runtime-corejs3/helpers/typeof":166}],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":83,"@babel/runtime-corejs3/core-js-stable/instance/for-each":88,"@babel/runtime-corejs3/helpers/interopRequireDefault":154,"_process":325}],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":101,"@babel/runtime-corejs3/helpers/interopRequireDefault":154,"crypto-js/aes":747,"crypto-js/enc-utf8":751}],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":777}],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":107,"@babel/runtime-corejs3/helpers/interopRequireDefault":154}],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":49,"@babel/runtime-corejs3/core-js-stable/promise":117,"@babel/runtime-corejs3/helpers/interopRequireDefault":154,"uuid":799}],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":62,"./utils/convert":78,"@babel/runtime-corejs3/core-js-stable/instance/bind":82,"@babel/runtime-corejs3/core-js-stable/object/define-property":107,"@babel/runtime-corejs3/core-js-stable/object/freeze":109,"@babel/runtime-corejs3/core-js-stable/reflect/construct":118,"@babel/runtime-corejs3/helpers/assertThisInitialized":145,"@babel/runtime-corejs3/helpers/asyncToGenerator":146,"@babel/runtime-corejs3/helpers/classCallCheck":147,"@babel/runtime-corejs3/helpers/createClass":149,"@babel/runtime-corejs3/helpers/getPrototypeOf":152,"@babel/runtime-corejs3/helpers/inherits":153,"@babel/runtime-corejs3/helpers/interopRequireDefault":154,"@babel/runtime-corejs3/helpers/possibleConstructorReturn":161,"@babel/runtime-corejs3/regenerator":169,"ethers":775,"events":777}],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(_dereq_('./Socket.weapp'));
- var _default = LiveQueryClient;
- exports.default = _default;
- },{"./CoreManager":5,"./EventEmitter":7,"./LiveQuerySubscription":12,"./ParseObject":36,"./Socket.weapp":48,"./promiseUtils":74,"@babel/runtime-corejs3/core-js-stable/array/from":80,"@babel/runtime-corejs3/core-js-stable/array/is-array":81,"@babel/runtime-corejs3/core-js-stable/instance/bind":82,"@babel/runtime-corejs3/core-js-stable/instance/for-each":88,"@babel/runtime-corejs3/core-js-stable/instance/index-of":90,"@babel/runtime-corejs3/core-js-stable/instance/keys":91,"@babel/runtime-corejs3/core-js-stable/instance/slice":95,"@babel/runtime-corejs3/core-js-stable/instance/values":100,"@babel/runtime-corejs3/core-js-stable/json/stringify":101,"@babel/runtime-corejs3/core-js-stable/map":102,"@babel/runtime-corejs3/core-js-stable/object/define-property":107,"@babel/runtime-corejs3/core-js-stable/reflect/construct":118,"@babel/runtime-corejs3/core-js-stable/set-timeout":119,"@babel/runtime-corejs3/core-js-stable/symbol":121,"@babel/runtime-corejs3/core-js/get-iterator-method":127,"@babel/runtime-corejs3/helpers/assertThisInitialized":145,"@babel/runtime-corejs3/helpers/classCallCheck":147,"@babel/runtime-corejs3/helpers/createClass":149,"@babel/runtime-corejs3/helpers/defineProperty":150,"@babel/runtime-corejs3/helpers/getPrototypeOf":152,"@babel/runtime-corejs3/helpers/inherits":153,"@babel/runtime-corejs3/helpers/interopRequireDefault":154,"@babel/runtime-corejs3/helpers/possibleConstructorReturn":161,"@babel/runtime-corejs3/helpers/typeof":166}],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":74,"@babel/runtime-corejs3/core-js-stable/object/define-property":107,"@babel/runtime-corejs3/core-js-stable/reflect/construct":118,"@babel/runtime-corejs3/helpers/classCallCheck":147,"@babel/runtime-corejs3/helpers/createClass":149,"@babel/runtime-corejs3/helpers/getPrototypeOf":152,"@babel/runtime-corejs3/helpers/inherits":153,"@babel/runtime-corejs3/helpers/interopRequireDefault":154,"@babel/runtime-corejs3/helpers/possibleConstructorReturn":161}],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":80,"@babel/runtime-corejs3/core-js-stable/array/is-array":81,"@babel/runtime-corejs3/core-js-stable/instance/concat":83,"@babel/runtime-corejs3/core-js-stable/instance/filter":86,"@babel/runtime-corejs3/core-js-stable/instance/find":87,"@babel/runtime-corejs3/core-js-stable/instance/includes":89,"@babel/runtime-corejs3/core-js-stable/instance/keys":91,"@babel/runtime-corejs3/core-js-stable/instance/map":92,"@babel/runtime-corejs3/core-js-stable/instance/slice":95,"@babel/runtime-corejs3/core-js-stable/instance/starts-with":98,"@babel/runtime-corejs3/core-js-stable/object/keys":114,"@babel/runtime-corejs3/core-js-stable/promise":117,"@babel/runtime-corejs3/core-js-stable/set":120,"@babel/runtime-corejs3/core-js-stable/symbol":121,"@babel/runtime-corejs3/core-js/get-iterator-method":127,"@babel/runtime-corejs3/helpers/asyncToGenerator":146,"@babel/runtime-corejs3/helpers/interopRequireDefault":154,"@babel/runtime-corejs3/helpers/slicedToArray":163,"@babel/runtime-corejs3/helpers/toConsumableArray":165,"@babel/runtime-corejs3/regenerator":169}],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":49,"@babel/runtime-corejs3/core-js-stable/array/from":80,"@babel/runtime-corejs3/core-js-stable/array/is-array":81,"@babel/runtime-corejs3/core-js-stable/instance/map":92,"@babel/runtime-corejs3/core-js-stable/instance/reduce":94,"@babel/runtime-corejs3/core-js-stable/instance/slice":95,"@babel/runtime-corejs3/core-js-stable/json/stringify":101,"@babel/runtime-corejs3/core-js-stable/promise":117,"@babel/runtime-corejs3/core-js-stable/symbol":121,"@babel/runtime-corejs3/core-js/get-iterator-method":127,"@babel/runtime-corejs3/helpers/asyncToGenerator":146,"@babel/runtime-corejs3/helpers/interopRequireDefault":154,"@babel/runtime-corejs3/regenerator":169}],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":98,"@babel/runtime-corejs3/core-js-stable/object/define-property":107,"@babel/runtime-corejs3/helpers/interopRequireDefault":154}],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":66,"@babel/runtime-corejs3/core-js-stable/array/from":80,"@babel/runtime-corejs3/core-js-stable/instance/filter":86,"@babel/runtime-corejs3/core-js-stable/instance/slice":95,"@babel/runtime-corejs3/core-js-stable/object/define-property":107,"@babel/runtime-corejs3/core-js-stable/object/keys":114,"@babel/runtime-corejs3/helpers/asyncToGenerator":146,"@babel/runtime-corejs3/helpers/classCallCheck":147,"@babel/runtime-corejs3/helpers/createClass":149,"@babel/runtime-corejs3/helpers/interopRequireDefault":154,"@babel/runtime-corejs3/regenerator":169}],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":66,"@babel/runtime-corejs3/core-js-stable/instance/filter":86,"@babel/runtime-corejs3/core-js-stable/object/define-property":107,"@babel/runtime-corejs3/helpers/asyncToGenerator":146,"@babel/runtime-corejs3/helpers/classCallCheck":147,"@babel/runtime-corejs3/helpers/createClass":149,"@babel/runtime-corejs3/helpers/interopRequireDefault":154,"@babel/runtime-corejs3/regenerator":169}],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":66,"@babel/runtime-corejs3/core-js-stable/instance/concat":83,"@babel/runtime-corejs3/core-js-stable/instance/filter":86,"@babel/runtime-corejs3/core-js-stable/instance/index-of":90,"@babel/runtime-corejs3/core-js-stable/instance/pad-start":93,"@babel/runtime-corejs3/core-js-stable/instance/reduce":94,"@babel/runtime-corejs3/core-js-stable/object/define-property":107,"@babel/runtime-corejs3/helpers/asyncToGenerator":146,"@babel/runtime-corejs3/helpers/classCallCheck":147,"@babel/runtime-corejs3/helpers/createClass":149,"@babel/runtime-corejs3/helpers/defineProperty":150,"@babel/runtime-corejs3/helpers/interopRequireDefault":154,"@babel/runtime-corejs3/helpers/toConsumableArray":165,"@babel/runtime-corejs3/regenerator":169}],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":86,"@babel/runtime-corejs3/core-js-stable/instance/for-each":88,"@babel/runtime-corejs3/core-js-stable/instance/includes":89,"@babel/runtime-corejs3/core-js-stable/json/stringify":101,"@babel/runtime-corejs3/core-js-stable/object/define-properties":106,"@babel/runtime-corejs3/core-js-stable/object/define-property":107,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor":110,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors":111,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols":112,"@babel/runtime-corejs3/core-js-stable/object/keys":114,"@babel/runtime-corejs3/helpers/asyncToGenerator":146,"@babel/runtime-corejs3/helpers/classCallCheck":147,"@babel/runtime-corejs3/helpers/createClass":149,"@babel/runtime-corejs3/helpers/defineProperty":150,"@babel/runtime-corejs3/helpers/interopRequireDefault":154,"@babel/runtime-corejs3/regenerator":169,"axios":293}],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":107,"@babel/runtime-corejs3/helpers/asyncToGenerator":146,"@babel/runtime-corejs3/helpers/interopRequireDefault":154,"@babel/runtime-corejs3/regenerator":169}],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":52,"./Web3Connector/InjectedWeb3Connector":56,"./Web3Connector/MagicWeb3Connector":57,"./Web3Connector/NetworkWeb3Connector":59,"./Web3Connector/WalletConnectWeb3Connector":60,"./Web3Connector/Web3AuthConnector":61,"./createSigningData":66,"@babel/runtime-corejs3/core-js-stable/array/from":80,"@babel/runtime-corejs3/core-js-stable/array/is-array":81,"@babel/runtime-corejs3/core-js-stable/instance/bind":82,"@babel/runtime-corejs3/core-js-stable/instance/concat":83,"@babel/runtime-corejs3/core-js-stable/instance/every":85,"@babel/runtime-corejs3/core-js-stable/instance/filter":86,"@babel/runtime-corejs3/core-js-stable/instance/find":87,"@babel/runtime-corejs3/core-js-stable/instance/for-each":88,"@babel/runtime-corejs3/core-js-stable/instance/map":92,"@babel/runtime-corejs3/core-js-stable/instance/slice":95,"@babel/runtime-corejs3/core-js-stable/instance/trim":99,"@babel/runtime-corejs3/core-js-stable/json/stringify":101,"@babel/runtime-corejs3/core-js-stable/object/define-property":107,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor":110,"@babel/runtime-corejs3/core-js-stable/object/values":115,"@babel/runtime-corejs3/core-js-stable/symbol":121,"@babel/runtime-corejs3/core-js-stable/weak-map":124,"@babel/runtime-corejs3/core-js/get-iterator-method":127,"@babel/runtime-corejs3/helpers/asyncToGenerator":146,"@babel/runtime-corejs3/helpers/classCallCheck":147,"@babel/runtime-corejs3/helpers/createClass":149,"@babel/runtime-corejs3/helpers/defineProperty":150,"@babel/runtime-corejs3/helpers/interopRequireDefault":154,"@babel/runtime-corejs3/helpers/toConsumableArray":165,"@babel/runtime-corejs3/helpers/typeof":166,"@babel/runtime-corejs3/regenerator":169,"@metamask/detect-provider":291,"ethers":775,"events":777}],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":86,"@babel/runtime-corejs3/core-js-stable/instance/for-each":88,"@babel/runtime-corejs3/core-js-stable/instance/includes":89,"@babel/runtime-corejs3/core-js-stable/json/stringify":101,"@babel/runtime-corejs3/core-js-stable/object/define-properties":106,"@babel/runtime-corejs3/core-js-stable/object/define-property":107,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor":110,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors":111,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols":112,"@babel/runtime-corejs3/core-js-stable/object/keys":114,"@babel/runtime-corejs3/helpers/asyncToGenerator":146,"@babel/runtime-corejs3/helpers/classCallCheck":147,"@babel/runtime-corejs3/helpers/createClass":149,"@babel/runtime-corejs3/helpers/defineProperty":150,"@babel/runtime-corejs3/helpers/interopRequireDefault":154,"@babel/runtime-corejs3/regenerator":169,"axios":293}],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":51,"./encode":68,"@babel/runtime-corejs3/core-js-stable/instance/filter":86,"@babel/runtime-corejs3/core-js-stable/instance/for-each":88,"@babel/runtime-corejs3/core-js-stable/instance/includes":89,"@babel/runtime-corejs3/core-js-stable/json/stringify":101,"@babel/runtime-corejs3/core-js-stable/object/define-properties":106,"@babel/runtime-corejs3/core-js-stable/object/define-property":107,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor":110,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors":111,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols":112,"@babel/runtime-corejs3/core-js-stable/object/keys":114,"@babel/runtime-corejs3/helpers/defineProperty":150,"@babel/runtime-corejs3/helpers/interopRequireDefault":154,"@babel/runtime-corejs3/helpers/typeof":166}],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":67,"./equals":69,"@babel/runtime-corejs3/core-js-stable/array/from":80,"@babel/runtime-corejs3/core-js-stable/array/is-array":81,"@babel/runtime-corejs3/core-js-stable/instance/filter":86,"@babel/runtime-corejs3/core-js-stable/instance/for-each":88,"@babel/runtime-corejs3/core-js-stable/instance/index-of":90,"@babel/runtime-corejs3/core-js-stable/instance/map":92,"@babel/runtime-corejs3/core-js-stable/instance/slice":95,"@babel/runtime-corejs3/core-js-stable/object/keys":114,"@babel/runtime-corejs3/core-js-stable/symbol":121,"@babel/runtime-corejs3/core-js/get-iterator-method":127,"@babel/runtime-corejs3/helpers/interopRequireDefault":154,"@babel/runtime-corejs3/helpers/typeof":166}],25:[function(_dereq_,module,exports){
- "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: "weapp",
- 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: "weapp"
- };
- 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*/
- ) {
- 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;
- },{"./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":49,"./UnitConvert":54,"./Web3Connector/AbstractWeb3Connector":55,"./decode":67,"./encode":68,"./filterConsole":71,"./utils":77,"@babel/runtime-corejs3/core-js-stable/object/define-property":107,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor":110,"@babel/runtime-corejs3/core-js-stable/promise":117,"@babel/runtime-corejs3/core-js-stable/reflect/construct":118,"@babel/runtime-corejs3/core-js-stable/weak-map":124,"@babel/runtime-corejs3/helpers/asyncToGenerator":146,"@babel/runtime-corejs3/helpers/classCallCheck":147,"@babel/runtime-corejs3/helpers/createClass":149,"@babel/runtime-corejs3/helpers/getPrototypeOf":152,"@babel/runtime-corejs3/helpers/inherits":153,"@babel/runtime-corejs3/helpers/interopRequireDefault":154,"@babel/runtime-corejs3/helpers/possibleConstructorReturn":161,"@babel/runtime-corejs3/helpers/typeof":166,"@babel/runtime-corejs3/regenerator":169,"ethers":775}],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":107,"@babel/runtime-corejs3/core-js-stable/object/keys":114,"@babel/runtime-corejs3/helpers/classCallCheck":147,"@babel/runtime-corejs3/helpers/createClass":149,"@babel/runtime-corejs3/helpers/defineProperty":150,"@babel/runtime-corejs3/helpers/interopRequireDefault":154,"@babel/runtime-corejs3/helpers/typeof":166}],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":80,"@babel/runtime-corejs3/core-js-stable/array/is-array":81,"@babel/runtime-corejs3/core-js-stable/instance/entries":84,"@babel/runtime-corejs3/core-js-stable/instance/every":85,"@babel/runtime-corejs3/core-js-stable/instance/filter":86,"@babel/runtime-corejs3/core-js-stable/instance/for-each":88,"@babel/runtime-corejs3/core-js-stable/instance/includes":89,"@babel/runtime-corejs3/core-js-stable/instance/slice":95,"@babel/runtime-corejs3/core-js-stable/map":102,"@babel/runtime-corejs3/core-js-stable/object/define-properties":106,"@babel/runtime-corejs3/core-js-stable/object/define-property":107,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor":110,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors":111,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols":112,"@babel/runtime-corejs3/core-js-stable/object/keys":114,"@babel/runtime-corejs3/core-js-stable/symbol":121,"@babel/runtime-corejs3/core-js/get-iterator-method":127,"@babel/runtime-corejs3/helpers/classCallCheck":147,"@babel/runtime-corejs3/helpers/createClass":149,"@babel/runtime-corejs3/helpers/defineProperty":150,"@babel/runtime-corejs3/helpers/interopRequireDefault":154,"@babel/runtime-corejs3/helpers/slicedToArray":163,"@babel/runtime-corejs3/helpers/typeof":166}],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":49,"./decode":67,"./encode":68,"./escape":70,"@babel/runtime-corejs3/core-js-stable/json/stringify":101,"@babel/runtime-corejs3/core-js-stable/object/define-property":107,"@babel/runtime-corejs3/core-js-stable/promise":117,"@babel/runtime-corejs3/helpers/classCallCheck":147,"@babel/runtime-corejs3/helpers/createClass":149,"@babel/runtime-corejs3/helpers/defineProperty":150,"@babel/runtime-corejs3/helpers/interopRequireDefault":154,"@babel/runtime-corejs3/helpers/typeof":166}],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":83,"@babel/runtime-corejs3/core-js-stable/object/define-property":107,"@babel/runtime-corejs3/core-js-stable/reflect/construct":118,"@babel/runtime-corejs3/helpers/assertThisInitialized":145,"@babel/runtime-corejs3/helpers/classCallCheck":147,"@babel/runtime-corejs3/helpers/createClass":149,"@babel/runtime-corejs3/helpers/getPrototypeOf":152,"@babel/runtime-corejs3/helpers/inherits":153,"@babel/runtime-corejs3/helpers/interopRequireDefault":154,"@babel/runtime-corejs3/helpers/possibleConstructorReturn":161,"@babel/runtime-corejs3/helpers/wrapNativeSuper":168}],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":81,"@babel/runtime-corejs3/core-js-stable/instance/filter":86,"@babel/runtime-corejs3/core-js-stable/instance/for-each":88,"@babel/runtime-corejs3/core-js-stable/instance/index-of":90,"@babel/runtime-corejs3/core-js-stable/instance/slice":95,"@babel/runtime-corejs3/core-js-stable/object/define-properties":106,"@babel/runtime-corejs3/core-js-stable/object/define-property":107,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor":110,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors":111,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols":112,"@babel/runtime-corejs3/core-js-stable/object/keys":114,"@babel/runtime-corejs3/helpers/asyncToGenerator":146,"@babel/runtime-corejs3/helpers/classCallCheck":147,"@babel/runtime-corejs3/helpers/createClass":149,"@babel/runtime-corejs3/helpers/defineProperty":150,"@babel/runtime-corejs3/helpers/interopRequireDefault":154,"@babel/runtime-corejs3/helpers/typeof":166,"@babel/runtime-corejs3/regenerator":169}],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;
- }
- XHR = _dereq_('./Xhr.weapp');
- 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,"./Xhr.weapp":63,"@babel/runtime-corejs3/core-js-stable/instance/filter":86,"@babel/runtime-corejs3/core-js-stable/instance/for-each":88,"@babel/runtime-corejs3/core-js-stable/instance/index-of":90,"@babel/runtime-corejs3/core-js-stable/object/define-properties":106,"@babel/runtime-corejs3/core-js-stable/object/define-property":107,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor":110,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors":111,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols":112,"@babel/runtime-corejs3/core-js-stable/object/keys":114,"@babel/runtime-corejs3/core-js-stable/promise":117,"@babel/runtime-corejs3/helpers/asyncToGenerator":146,"@babel/runtime-corejs3/helpers/defineProperty":150,"@babel/runtime-corejs3/helpers/interopRequireDefault":154,"@babel/runtime-corejs3/helpers/slicedToArray":163,"@babel/runtime-corejs3/regenerator":169}],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":81,"@babel/runtime-corejs3/core-js-stable/object/define-property":107,"@babel/runtime-corejs3/helpers/classCallCheck":147,"@babel/runtime-corejs3/helpers/createClass":149,"@babel/runtime-corejs3/helpers/defineProperty":150,"@babel/runtime-corejs3/helpers/interopRequireDefault":154,"@babel/runtime-corejs3/helpers/typeof":166}],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":107,"@babel/runtime-corejs3/core-js-stable/reflect/construct":118,"@babel/runtime-corejs3/helpers/classCallCheck":147,"@babel/runtime-corejs3/helpers/createClass":149,"@babel/runtime-corejs3/helpers/getPrototypeOf":152,"@babel/runtime-corejs3/helpers/inherits":153,"@babel/runtime-corejs3/helpers/interopRequireDefault":154,"@babel/runtime-corejs3/helpers/possibleConstructorReturn":161,"@babel/runtime-corejs3/helpers/typeof":166}],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":90,"@babel/runtime-corejs3/core-js-stable/object/define-property":107,"@babel/runtime-corejs3/core-js-stable/promise":117,"@babel/runtime-corejs3/helpers/asyncToGenerator":146,"@babel/runtime-corejs3/helpers/interopRequireDefault":154,"@babel/runtime-corejs3/helpers/slicedToArray":163,"@babel/runtime-corejs3/regenerator":169}],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":53,"./canBeSerialized":65,"./decode":67,"./encode":68,"./escape":70,"./parseDate":73,"./promiseUtils":74,"./unique":75,"./unsavedChildren":76,"@babel/runtime-corejs3/core-js-stable/array/from":80,"@babel/runtime-corejs3/core-js-stable/array/is-array":81,"@babel/runtime-corejs3/core-js-stable/instance/concat":83,"@babel/runtime-corejs3/core-js-stable/instance/filter":86,"@babel/runtime-corejs3/core-js-stable/instance/find":87,"@babel/runtime-corejs3/core-js-stable/instance/for-each":88,"@babel/runtime-corejs3/core-js-stable/instance/includes":89,"@babel/runtime-corejs3/core-js-stable/instance/index-of":90,"@babel/runtime-corejs3/core-js-stable/instance/map":92,"@babel/runtime-corejs3/core-js-stable/instance/slice":95,"@babel/runtime-corejs3/core-js-stable/json/stringify":101,"@babel/runtime-corejs3/core-js-stable/object/create":105,"@babel/runtime-corejs3/core-js-stable/object/define-properties":106,"@babel/runtime-corejs3/core-js-stable/object/define-property":107,"@babel/runtime-corejs3/core-js-stable/object/freeze":109,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor":110,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors":111,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols":112,"@babel/runtime-corejs3/core-js-stable/object/get-prototype-of":113,"@babel/runtime-corejs3/core-js-stable/object/keys":114,"@babel/runtime-corejs3/core-js-stable/promise":117,"@babel/runtime-corejs3/core-js-stable/symbol":121,"@babel/runtime-corejs3/core-js-stable/weak-map":124,"@babel/runtime-corejs3/core-js/get-iterator-method":127,"@babel/runtime-corejs3/helpers/asyncToGenerator":146,"@babel/runtime-corejs3/helpers/classCallCheck":147,"@babel/runtime-corejs3/helpers/createClass":149,"@babel/runtime-corejs3/helpers/defineProperty":150,"@babel/runtime-corejs3/helpers/interopRequireDefault":154,"@babel/runtime-corejs3/helpers/typeof":166,"@babel/runtime-corejs3/regenerator":169,"uuid":799}],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":64,"./decode":67,"./encode":68,"./unique":75,"@babel/runtime-corejs3/core-js-stable/array/is-array":81,"@babel/runtime-corejs3/core-js-stable/instance/concat":83,"@babel/runtime-corejs3/core-js-stable/instance/for-each":88,"@babel/runtime-corejs3/core-js-stable/instance/index-of":90,"@babel/runtime-corejs3/core-js-stable/instance/map":92,"@babel/runtime-corejs3/core-js-stable/instance/splice":97,"@babel/runtime-corejs3/core-js-stable/object/define-property":107,"@babel/runtime-corejs3/core-js-stable/reflect/construct":118,"@babel/runtime-corejs3/helpers/assertThisInitialized":145,"@babel/runtime-corejs3/helpers/classCallCheck":147,"@babel/runtime-corejs3/helpers/createClass":149,"@babel/runtime-corejs3/helpers/defineProperty":150,"@babel/runtime-corejs3/helpers/getPrototypeOf":152,"@babel/runtime-corejs3/helpers/inherits":153,"@babel/runtime-corejs3/helpers/interopRequireDefault":154,"@babel/runtime-corejs3/helpers/possibleConstructorReturn":161}],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":81,"@babel/runtime-corejs3/core-js-stable/object/define-property":107,"@babel/runtime-corejs3/helpers/classCallCheck":147,"@babel/runtime-corejs3/helpers/createClass":149,"@babel/runtime-corejs3/helpers/defineProperty":150,"@babel/runtime-corejs3/helpers/interopRequireDefault":154}],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":68,"./promiseUtils":74,"@babel/runtime-corejs3/core-js-stable/array/is-array":81,"@babel/runtime-corejs3/core-js-stable/instance/concat":83,"@babel/runtime-corejs3/core-js-stable/instance/filter":86,"@babel/runtime-corejs3/core-js-stable/instance/find":87,"@babel/runtime-corejs3/core-js-stable/instance/for-each":88,"@babel/runtime-corejs3/core-js-stable/instance/includes":89,"@babel/runtime-corejs3/core-js-stable/instance/index-of":90,"@babel/runtime-corejs3/core-js-stable/instance/keys":91,"@babel/runtime-corejs3/core-js-stable/instance/map":92,"@babel/runtime-corejs3/core-js-stable/instance/slice":95,"@babel/runtime-corejs3/core-js-stable/instance/sort":96,"@babel/runtime-corejs3/core-js-stable/instance/splice":97,"@babel/runtime-corejs3/core-js-stable/object/define-property":107,"@babel/runtime-corejs3/core-js-stable/object/entries":108,"@babel/runtime-corejs3/core-js-stable/object/keys":114,"@babel/runtime-corejs3/core-js-stable/promise":117,"@babel/runtime-corejs3/helpers/asyncToGenerator":146,"@babel/runtime-corejs3/helpers/classCallCheck":147,"@babel/runtime-corejs3/helpers/createClass":149,"@babel/runtime-corejs3/helpers/defineProperty":150,"@babel/runtime-corejs3/helpers/interopRequireDefault":154,"@babel/runtime-corejs3/helpers/slicedToArray":163,"@babel/runtime-corejs3/helpers/toConsumableArray":165,"@babel/runtime-corejs3/helpers/typeof":166,"@babel/runtime-corejs3/regenerator":169}],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":81,"@babel/runtime-corejs3/core-js-stable/object/define-property":107,"@babel/runtime-corejs3/helpers/classCallCheck":147,"@babel/runtime-corejs3/helpers/createClass":149,"@babel/runtime-corejs3/helpers/defineProperty":150,"@babel/runtime-corejs3/helpers/interopRequireDefault":154}],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":107,"@babel/runtime-corejs3/core-js-stable/reflect/construct":118,"@babel/runtime-corejs3/helpers/classCallCheck":147,"@babel/runtime-corejs3/helpers/createClass":149,"@babel/runtime-corejs3/helpers/get":151,"@babel/runtime-corejs3/helpers/getPrototypeOf":152,"@babel/runtime-corejs3/helpers/inherits":153,"@babel/runtime-corejs3/helpers/interopRequireDefault":154,"@babel/runtime-corejs3/helpers/possibleConstructorReturn":161}],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":90,"@babel/runtime-corejs3/core-js-stable/object/define-property":107,"@babel/runtime-corejs3/helpers/classCallCheck":147,"@babel/runtime-corejs3/helpers/createClass":149,"@babel/runtime-corejs3/helpers/defineProperty":150,"@babel/runtime-corejs3/helpers/interopRequireDefault":154}],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":72,"@babel/runtime-corejs3/core-js-stable/object/define-property":107,"@babel/runtime-corejs3/core-js-stable/promise":117,"@babel/runtime-corejs3/core-js-stable/reflect/construct":118,"@babel/runtime-corejs3/helpers/classCallCheck":147,"@babel/runtime-corejs3/helpers/createClass":149,"@babel/runtime-corejs3/helpers/getPrototypeOf":152,"@babel/runtime-corejs3/helpers/inherits":153,"@babel/runtime-corejs3/helpers/interopRequireDefault":154,"@babel/runtime-corejs3/helpers/possibleConstructorReturn":161,"@babel/runtime-corejs3/helpers/typeof":166}],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":49,"./isRevocableSession":72,"@babel/runtime-corejs3/core-js-stable/json/stringify":101,"@babel/runtime-corejs3/core-js-stable/object/define-property":107,"@babel/runtime-corejs3/core-js-stable/promise":117,"@babel/runtime-corejs3/core-js-stable/reflect/construct":118,"@babel/runtime-corejs3/helpers/asyncToGenerator":146,"@babel/runtime-corejs3/helpers/classCallCheck":147,"@babel/runtime-corejs3/helpers/createClass":149,"@babel/runtime-corejs3/helpers/get":151,"@babel/runtime-corejs3/helpers/getPrototypeOf":152,"@babel/runtime-corejs3/helpers/inherits":153,"@babel/runtime-corejs3/helpers/interopRequireDefault":154,"@babel/runtime-corejs3/helpers/possibleConstructorReturn":161,"@babel/runtime-corejs3/helpers/typeof":166,"@babel/runtime-corejs3/regenerator":169}],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":107,"@babel/runtime-corejs3/helpers/interopRequireDefault":154,"@babel/runtime-corejs3/helpers/typeof":166}],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;
- }
- XHR = _dereq_('./Xhr.weapp');
- 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,"./Xhr.weapp":63,"./promiseUtils":74,"@babel/runtime-corejs3/core-js-stable/instance/concat":83,"@babel/runtime-corejs3/core-js-stable/instance/filter":86,"@babel/runtime-corejs3/core-js-stable/instance/for-each":88,"@babel/runtime-corejs3/core-js-stable/instance/includes":89,"@babel/runtime-corejs3/core-js-stable/json/stringify":101,"@babel/runtime-corejs3/core-js-stable/object/define-properties":106,"@babel/runtime-corejs3/core-js-stable/object/define-property":107,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor":110,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors":111,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols":112,"@babel/runtime-corejs3/core-js-stable/object/keys":114,"@babel/runtime-corejs3/core-js-stable/promise":117,"@babel/runtime-corejs3/core-js-stable/set-timeout":119,"@babel/runtime-corejs3/helpers/defineProperty":150,"@babel/runtime-corejs3/helpers/interopRequireDefault":154,"@babel/runtime-corejs3/helpers/typeof":166,"_process":325,"uuid":799}],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":107,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor":110,"@babel/runtime-corejs3/core-js-stable/weak-map":124,"@babel/runtime-corejs3/helpers/typeof":166}],48:[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"));
- module.exports = /*#__PURE__*/function () {
- function SocketWeapp(serverURL) {
- var _this = this;
- (0, _classCallCheck2.default)(this, SocketWeapp);
- this.onopen = function () {};
- this.onmessage = function () {};
- this.onclose = function () {};
- this.onerror = function () {};
- wx.onSocketOpen(function () {
- _this.onopen();
- });
- wx.onSocketMessage(function (msg) {
- _this.onmessage(msg);
- });
- wx.onSocketClose(function () {
- _this.onclose();
- });
- wx.onSocketError(function (error) {
- _this.onerror(error);
- });
- wx.connectSocket({
- url: serverURL
- });
- }
- (0, _createClass2.default)(SocketWeapp, [{
- key: "send",
- value: function (data) {
- wx.sendSocketMessage({
- data: data
- });
- }
- }, {
- key: "close",
- value: function () {
- wx.closeSocket();
- }
- }]);
- return SocketWeapp;
- }();
- },{"@babel/runtime-corejs3/helpers/classCallCheck":147,"@babel/runtime-corejs3/helpers/createClass":149,"@babel/runtime-corejs3/helpers/interopRequireDefault":154}],49:[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.weapp'));
- },{"./CoreManager":5,"./StorageController.weapp":50,"@babel/runtime-corejs3/core-js-stable/instance/concat":83,"@babel/runtime-corejs3/core-js-stable/promise":117,"@babel/runtime-corejs3/helpers/interopRequireDefault":154}],50:[function(_dereq_,module,exports){
- "use strict";
- var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
- var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/keys"));
- /**
- * 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 StorageController = {
- async: 0,
- getItem: function (path
- /*: string*/
- )
- /*: ?string*/
- {
- return wx.getStorageSync(path);
- },
- setItem: function (path
- /*: string*/
- , value
- /*: string*/
- ) {
- try {
- wx.setStorageSync(path, value);
- } catch (e) {// Quota exceeded
- }
- },
- removeItem: function (path
- /*: string*/
- ) {
- wx.removeStorageSync(path);
- },
- getAllKeys: function () {
- var res = wx.getStorageInfoSync();
- return (0, _keys.default)(res);
- },
- clear: function () {
- wx.clearStorageSync();
- }
- };
- module.exports = StorageController;
- },{"@babel/runtime-corejs3/core-js-stable/instance/keys":91,"@babel/runtime-corejs3/helpers/interopRequireDefault":154}],51:[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":74,"@babel/runtime-corejs3/helpers/classCallCheck":147,"@babel/runtime-corejs3/helpers/createClass":149,"@babel/runtime-corejs3/helpers/defineProperty":150,"@babel/runtime-corejs3/helpers/interopRequireDefault":154}],52:[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":90,"@babel/runtime-corejs3/core-js-stable/number/is-integer":103,"@babel/runtime-corejs3/core-js-stable/object/keys":114,"@babel/runtime-corejs3/helpers/interopRequireDefault":154}],53:[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":51,"@babel/runtime-corejs3/core-js-stable/object/define-property":107,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor":110,"@babel/runtime-corejs3/core-js-stable/weak-map":124,"@babel/runtime-corejs3/helpers/interopRequireDefault":154,"@babel/runtime-corejs3/helpers/typeof":166}],54:[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":147,"@babel/runtime-corejs3/helpers/createClass":149,"@babel/runtime-corejs3/helpers/interopRequireDefault":154,"ethers":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 = 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":79,"./events":62,"@babel/runtime-corejs3/core-js-stable/instance/bind":82,"@babel/runtime-corejs3/core-js-stable/object/define-property":107,"@babel/runtime-corejs3/core-js-stable/reflect/construct":118,"@babel/runtime-corejs3/helpers/assertThisInitialized":145,"@babel/runtime-corejs3/helpers/asyncToGenerator":146,"@babel/runtime-corejs3/helpers/classCallCheck":147,"@babel/runtime-corejs3/helpers/createClass":149,"@babel/runtime-corejs3/helpers/defineProperty":150,"@babel/runtime-corejs3/helpers/getPrototypeOf":152,"@babel/runtime-corejs3/helpers/inherits":153,"@babel/runtime-corejs3/helpers/interopRequireDefault":154,"@babel/runtime-corejs3/helpers/possibleConstructorReturn":161,"@babel/runtime-corejs3/regenerator":169,"events":777}],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 = 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":79,"./AbstractWeb3Connector":55,"@babel/runtime-corejs3/core-js-stable/instance/concat":83,"@babel/runtime-corejs3/core-js-stable/object/define-property":107,"@babel/runtime-corejs3/core-js-stable/object/freeze":109,"@babel/runtime-corejs3/core-js-stable/promise":117,"@babel/runtime-corejs3/core-js-stable/reflect/construct":118,"@babel/runtime-corejs3/helpers/assertThisInitialized":145,"@babel/runtime-corejs3/helpers/asyncToGenerator":146,"@babel/runtime-corejs3/helpers/classCallCheck":147,"@babel/runtime-corejs3/helpers/createClass":149,"@babel/runtime-corejs3/helpers/defineProperty":150,"@babel/runtime-corejs3/helpers/getPrototypeOf":152,"@babel/runtime-corejs3/helpers/inherits":153,"@babel/runtime-corejs3/helpers/interopRequireDefault":154,"@babel/runtime-corejs3/helpers/possibleConstructorReturn":161,"@babel/runtime-corejs3/helpers/slicedToArray":163,"@babel/runtime-corejs3/helpers/wrapNativeSuper":168,"@babel/runtime-corejs3/regenerator":169,"events":777}],57:[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":55,"@babel/runtime-corejs3/core-js-stable/instance/concat":83,"@babel/runtime-corejs3/core-js-stable/object/define-property":107,"@babel/runtime-corejs3/core-js-stable/reflect/construct":118,"@babel/runtime-corejs3/helpers/assertThisInitialized":145,"@babel/runtime-corejs3/helpers/asyncToGenerator":146,"@babel/runtime-corejs3/helpers/classCallCheck":147,"@babel/runtime-corejs3/helpers/createClass":149,"@babel/runtime-corejs3/helpers/defineProperty":150,"@babel/runtime-corejs3/helpers/getPrototypeOf":152,"@babel/runtime-corejs3/helpers/inherits":153,"@babel/runtime-corejs3/helpers/interopRequireDefault":154,"@babel/runtime-corejs3/helpers/possibleConstructorReturn":161,"@babel/runtime-corejs3/regenerator":169,"ethers":775,"magic-sdk":325}],58:[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":107}],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 = 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 ("weapp" !== '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":78,"../utils/verifyChainId":79,"./AbstractWeb3Connector":55,"./MoralisRpcs":58,"@babel/runtime-corejs3/core-js-stable/instance/concat":83,"@babel/runtime-corejs3/core-js-stable/instance/reduce":94,"@babel/runtime-corejs3/core-js-stable/json/stringify":101,"@babel/runtime-corejs3/core-js-stable/object/define-property":107,"@babel/runtime-corejs3/core-js-stable/object/keys":114,"@babel/runtime-corejs3/core-js-stable/reflect/construct":118,"@babel/runtime-corejs3/core-js-stable/url":123,"@babel/runtime-corejs3/helpers/assertThisInitialized":145,"@babel/runtime-corejs3/helpers/asyncToGenerator":146,"@babel/runtime-corejs3/helpers/classCallCheck":147,"@babel/runtime-corejs3/helpers/createClass":149,"@babel/runtime-corejs3/helpers/defineProperty":150,"@babel/runtime-corejs3/helpers/getPrototypeOf":152,"@babel/runtime-corejs3/helpers/inherits":153,"@babel/runtime-corejs3/helpers/interopRequireDefault":154,"@babel/runtime-corejs3/helpers/possibleConstructorReturn":161,"@babel/runtime-corejs3/regenerator":169,"ethers":775}],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.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":79,"./AbstractWeb3Connector":55,"./MoralisRpcs":58,"./events":62,"@babel/runtime-corejs3/core-js-stable/instance/concat":83,"@babel/runtime-corejs3/core-js-stable/object/define-property":107,"@babel/runtime-corejs3/core-js-stable/object/freeze":109,"@babel/runtime-corejs3/core-js-stable/reflect/construct":118,"@babel/runtime-corejs3/helpers/assertThisInitialized":145,"@babel/runtime-corejs3/helpers/asyncToGenerator":146,"@babel/runtime-corejs3/helpers/classCallCheck":147,"@babel/runtime-corejs3/helpers/createClass":149,"@babel/runtime-corejs3/helpers/defineProperty":150,"@babel/runtime-corejs3/helpers/getPrototypeOf":152,"@babel/runtime-corejs3/helpers/inherits":153,"@babel/runtime-corejs3/helpers/interopRequireDefault":154,"@babel/runtime-corejs3/helpers/possibleConstructorReturn":161,"@babel/runtime-corejs3/regenerator":169,"@walletconnect/web3-provider":325}],61:[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":79,"./AbstractWeb3Connector":55,"@babel/runtime-corejs3/core-js-stable/instance/concat":83,"@babel/runtime-corejs3/core-js-stable/object/define-property":107,"@babel/runtime-corejs3/core-js-stable/promise":117,"@babel/runtime-corejs3/core-js-stable/reflect/construct":118,"@babel/runtime-corejs3/helpers/assertThisInitialized":145,"@babel/runtime-corejs3/helpers/asyncToGenerator":146,"@babel/runtime-corejs3/helpers/classCallCheck":147,"@babel/runtime-corejs3/helpers/createClass":149,"@babel/runtime-corejs3/helpers/defineProperty":150,"@babel/runtime-corejs3/helpers/getPrototypeOf":152,"@babel/runtime-corejs3/helpers/inherits":153,"@babel/runtime-corejs3/helpers/interopRequireDefault":154,"@babel/runtime-corejs3/helpers/possibleConstructorReturn":161,"@babel/runtime-corejs3/regenerator":169,"@web3auth/web3auth":325,"ethers":775}],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.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":107,"@babel/runtime-corejs3/core-js-stable/object/freeze":109,"@babel/runtime-corejs3/helpers/interopRequireDefault":154}],63:[function(_dereq_,module,exports){
- "use strict";
- var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
- 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 _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
- var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
- module.exports = /*#__PURE__*/function () {
- function XhrWeapp() {
- (0, _classCallCheck2.default)(this, XhrWeapp);
- this.UNSENT = 0;
- this.OPENED = 1;
- this.HEADERS_RECEIVED = 2;
- this.LOADING = 3;
- this.DONE = 4;
- this.header = {};
- this.readyState = this.DONE;
- this.status = 0;
- this.response = '';
- this.responseType = '';
- this.responseText = '';
- this.responseHeader = {};
- this.method = '';
- this.url = '';
- this.onabort = function () {};
- this.onprogress = function () {};
- this.onerror = function () {};
- this.onreadystatechange = function () {};
- this.requestTask = null;
- }
- (0, _createClass2.default)(XhrWeapp, [{
- key: "getAllResponseHeaders",
- value: function () {
- var header = '';
- for (var key in this.responseHeader) {
- var _context;
- header += (0, _concat.default)(_context = "".concat(key, ":")).call(_context, this.getResponseHeader(key), "\r\n");
- }
- return header;
- }
- }, {
- key: "getResponseHeader",
- value: function (key) {
- return this.responseHeader[key];
- }
- }, {
- key: "setRequestHeader",
- value: function (key, value) {
- this.header[key] = value;
- }
- }, {
- key: "open",
- value: function (method, url) {
- this.method = method;
- this.url = url;
- }
- }, {
- key: "abort",
- value: function () {
- if (!this.requestTask) {
- return;
- }
- this.requestTask.abort();
- this.status = 0;
- this.response = undefined;
- this.onabort();
- this.onreadystatechange();
- }
- }, {
- key: "send",
- value: function (data) {
- var _this = this;
- this.requestTask = wx.request({
- url: this.url,
- method: this.method,
- data: data,
- header: this.header,
- responseType: this.responseType,
- success: function (res) {
- _this.status = res.statusCode;
- _this.response = res.data;
- _this.responseHeader = res.header;
- _this.responseText = (0, _stringify.default)(res.data);
- _this.requestTask = null;
- _this.onreadystatechange();
- },
- fail: function (err) {
- _this.requestTask = null;
- _this.onerror(err);
- }
- });
- this.requestTask.onProgressUpdate(function (res) {
- var event = {
- lengthComputable: res.totalBytesExpectedToWrite !== 0,
- loaded: res.totalBytesWritten,
- total: res.totalBytesExpectedToWrite
- };
- _this.onprogress(event);
- });
- }
- }]);
- return XhrWeapp;
- }();
- },{"@babel/runtime-corejs3/core-js-stable/instance/concat":83,"@babel/runtime-corejs3/core-js-stable/json/stringify":101,"@babel/runtime-corejs3/helpers/classCallCheck":147,"@babel/runtime-corejs3/helpers/createClass":149,"@babel/runtime-corejs3/helpers/interopRequireDefault":154}],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 = 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":90,"@babel/runtime-corejs3/core-js-stable/object/define-property":107,"@babel/runtime-corejs3/helpers/interopRequireDefault":154}],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 = 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":81,"@babel/runtime-corejs3/core-js-stable/object/define-property":107,"@babel/runtime-corejs3/helpers/interopRequireDefault":154,"@babel/runtime-corejs3/helpers/typeof":166}],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 = 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":83,"@babel/runtime-corejs3/core-js-stable/object/define-property":107,"@babel/runtime-corejs3/helpers/asyncToGenerator":146,"@babel/runtime-corejs3/helpers/interopRequireDefault":154,"@babel/runtime-corejs3/regenerator":169}],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 = 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":81,"@babel/runtime-corejs3/core-js-stable/instance/for-each":88,"@babel/runtime-corejs3/core-js-stable/object/define-property":107,"@babel/runtime-corejs3/helpers/interopRequireDefault":154,"@babel/runtime-corejs3/helpers/typeof":166}],68:[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":81,"@babel/runtime-corejs3/core-js-stable/instance/concat":83,"@babel/runtime-corejs3/core-js-stable/instance/index-of":90,"@babel/runtime-corejs3/core-js-stable/instance/map":92,"@babel/runtime-corejs3/core-js-stable/instance/starts-with":98,"@babel/runtime-corejs3/core-js-stable/object/define-property":107,"@babel/runtime-corejs3/core-js-stable/object/keys":114,"@babel/runtime-corejs3/helpers/interopRequireDefault":154,"@babel/runtime-corejs3/helpers/typeof":166}],69:[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":81,"@babel/runtime-corejs3/core-js-stable/object/define-property":107,"@babel/runtime-corejs3/core-js-stable/object/keys":114,"@babel/runtime-corejs3/helpers/interopRequireDefault":154,"@babel/runtime-corejs3/helpers/typeof":166}],70:[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":107}],71:[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":86,"@babel/runtime-corejs3/core-js-stable/instance/includes":89,"@babel/runtime-corejs3/helpers/interopRequireDefault":154}],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.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":90,"@babel/runtime-corejs3/core-js-stable/object/define-property":107,"@babel/runtime-corejs3/helpers/interopRequireDefault":154}],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 = 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":107,"@babel/runtime-corejs3/core-js-stable/parse-int":116,"@babel/runtime-corejs3/helpers/interopRequireDefault":154}],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.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":81,"@babel/runtime-corejs3/core-js-stable/object/define-property":107,"@babel/runtime-corejs3/core-js-stable/promise":117,"@babel/runtime-corejs3/helpers/interopRequireDefault":154}],75:[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":64,"@babel/runtime-corejs3/core-js-stable/instance/for-each":88,"@babel/runtime-corejs3/core-js-stable/instance/index-of":90,"@babel/runtime-corejs3/core-js-stable/object/define-property":107,"@babel/runtime-corejs3/helpers/interopRequireDefault":154}],76:[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":81,"@babel/runtime-corejs3/core-js-stable/instance/concat":83,"@babel/runtime-corejs3/core-js-stable/instance/for-each":88,"@babel/runtime-corejs3/core-js-stable/instance/index-of":90,"@babel/runtime-corejs3/core-js-stable/object/define-property":107,"@babel/runtime-corejs3/helpers/interopRequireDefault":154,"@babel/runtime-corejs3/helpers/typeof":166}],77:[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":88,"@babel/runtime-corejs3/core-js-stable/instance/map":92,"@babel/runtime-corejs3/core-js-stable/instance/reduce":94,"@babel/runtime-corejs3/core-js-stable/instance/slice":95,"@babel/runtime-corejs3/core-js-stable/json/stringify":101,"@babel/runtime-corejs3/core-js-stable/number/is-nan":104,"@babel/runtime-corejs3/core-js-stable/object/create":105,"@babel/runtime-corejs3/core-js-stable/object/entries":108,"@babel/runtime-corejs3/core-js-stable/object/freeze":109,"@babel/runtime-corejs3/core-js-stable/object/keys":114,"@babel/runtime-corejs3/core-js-stable/symbol/replace":122,"@babel/runtime-corejs3/core-js-stable/weak-map":124,"@babel/runtime-corejs3/helpers/asyncToGenerator":146,"@babel/runtime-corejs3/helpers/inherits":153,"@babel/runtime-corejs3/helpers/interopRequireDefault":154,"@babel/runtime-corejs3/helpers/setPrototypeOf":162,"@babel/runtime-corejs3/helpers/slicedToArray":163,"@babel/runtime-corejs3/helpers/typeof":166,"@babel/runtime-corejs3/regenerator":169}],78:[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":116,"@babel/runtime-corejs3/helpers/interopRequireDefault":154}],79:[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":78,"@babel/runtime-corejs3/core-js-stable/object/define-property":107}],80:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/array/from");
- },{"core-js-pure/stable/array/from":693}],81:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/array/is-array");
- },{"core-js-pure/stable/array/is-array":694}],82:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/instance/bind");
- },{"core-js-pure/stable/instance/bind":700}],83:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/instance/concat");
- },{"core-js-pure/stable/instance/concat":701}],84:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/instance/entries");
- },{"core-js-pure/stable/instance/entries":702}],85:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/instance/every");
- },{"core-js-pure/stable/instance/every":703}],86:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/instance/filter");
- },{"core-js-pure/stable/instance/filter":704}],87:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/instance/find");
- },{"core-js-pure/stable/instance/find":705}],88:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/instance/for-each");
- },{"core-js-pure/stable/instance/for-each":706}],89:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/instance/includes");
- },{"core-js-pure/stable/instance/includes":707}],90:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/instance/index-of");
- },{"core-js-pure/stable/instance/index-of":708}],91:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/instance/keys");
- },{"core-js-pure/stable/instance/keys":709}],92:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/instance/map");
- },{"core-js-pure/stable/instance/map":710}],93:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/instance/pad-start");
- },{"core-js-pure/stable/instance/pad-start":711}],94:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/instance/reduce");
- },{"core-js-pure/stable/instance/reduce":712}],95:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/instance/slice");
- },{"core-js-pure/stable/instance/slice":713}],96:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/instance/sort");
- },{"core-js-pure/stable/instance/sort":714}],97:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/instance/splice");
- },{"core-js-pure/stable/instance/splice":715}],98:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/instance/starts-with");
- },{"core-js-pure/stable/instance/starts-with":716}],99:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/instance/trim");
- },{"core-js-pure/stable/instance/trim":717}],100:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/instance/values");
- },{"core-js-pure/stable/instance/values":718}],101:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/json/stringify");
- },{"core-js-pure/stable/json/stringify":719}],102:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/map");
- },{"core-js-pure/stable/map":720}],103:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/number/is-integer");
- },{"core-js-pure/stable/number/is-integer":721}],104:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/number/is-nan");
- },{"core-js-pure/stable/number/is-nan":722}],105:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/object/create");
- },{"core-js-pure/stable/object/create":723}],106:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/object/define-properties");
- },{"core-js-pure/stable/object/define-properties":724}],107:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/object/define-property");
- },{"core-js-pure/stable/object/define-property":725}],108:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/object/entries");
- },{"core-js-pure/stable/object/entries":726}],109:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/object/freeze");
- },{"core-js-pure/stable/object/freeze":727}],110:[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":728}],111:[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":729}],112:[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":730}],113:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/object/get-prototype-of");
- },{"core-js-pure/stable/object/get-prototype-of":731}],114:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/object/keys");
- },{"core-js-pure/stable/object/keys":732}],115:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/object/values");
- },{"core-js-pure/stable/object/values":734}],116:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/parse-int");
- },{"core-js-pure/stable/parse-int":735}],117:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/promise");
- },{"core-js-pure/stable/promise":736}],118:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/reflect/construct");
- },{"core-js-pure/stable/reflect/construct":737}],119:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/set-timeout");
- },{"core-js-pure/stable/set-timeout":739}],120:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/set");
- },{"core-js-pure/stable/set":740}],121:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/symbol");
- },{"core-js-pure/stable/symbol":741}],122:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/symbol/replace");
- },{"core-js-pure/stable/symbol/replace":743}],123:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/url");
- },{"core-js-pure/stable/url":744}],124:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/stable/weak-map");
- },{"core-js-pure/stable/weak-map":745}],125:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/features/array/from");
- },{"core-js-pure/features/array/from":406}],126:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/features/array/is-array");
- },{"core-js-pure/features/array/is-array":407}],127:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/features/get-iterator-method");
- },{"core-js-pure/features/get-iterator-method":408}],128:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/features/instance/bind");
- },{"core-js-pure/features/instance/bind":409}],129:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/features/instance/index-of");
- },{"core-js-pure/features/instance/index-of":410}],130:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/features/instance/slice");
- },{"core-js-pure/features/instance/slice":411}],131:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/features/map");
- },{"core-js-pure/features/map":412}],132:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/features/object/create");
- },{"core-js-pure/features/object/create":413}],133:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/features/object/define-property");
- },{"core-js-pure/features/object/define-property":414}],134:[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":415}],135:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/features/object/get-prototype-of");
- },{"core-js-pure/features/object/get-prototype-of":416}],136:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/features/object/set-prototype-of");
- },{"core-js-pure/features/object/set-prototype-of":417}],137:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/features/promise");
- },{"core-js-pure/features/promise":418}],138:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/features/reflect/construct");
- },{"core-js-pure/features/reflect/construct":419}],139:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/features/reflect/get");
- },{"core-js-pure/features/reflect/get":420}],140:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/features/symbol");
- },{"core-js-pure/features/symbol":421}],141:[function(_dereq_,module,exports){
- module.exports = _dereq_("core-js-pure/features/symbol/iterator");
- },{"core-js-pure/features/symbol/iterator":422}],142:[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;
- },{}],143:[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":126}],144:[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":142,"@babel/runtime-corejs3/core-js/array/is-array":126}],145:[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;
- },{}],146:[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":137}],147:[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;
- },{}],148:[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":156,"./setPrototypeOf.js":162,"@babel/runtime-corejs3/core-js/instance/bind":128,"@babel/runtime-corejs3/core-js/reflect/construct":138}],149:[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":133}],150:[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":133}],151:[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":164,"@babel/runtime-corejs3/core-js/object/get-own-property-descriptor":134,"@babel/runtime-corejs3/core-js/reflect/get":139}],152:[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":135,"@babel/runtime-corejs3/core-js/object/set-prototype-of":136}],153:[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":162,"@babel/runtime-corejs3/core-js/object/create":132,"@babel/runtime-corejs3/core-js/object/define-property":133}],154:[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;
- },{}],155:[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":129}],156:[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":138}],157:[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":125,"@babel/runtime-corejs3/core-js/get-iterator-method":127,"@babel/runtime-corejs3/core-js/symbol":140}],158:[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":127,"@babel/runtime-corejs3/core-js/symbol":140}],159:[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;
- },{}],160:[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;
- },{}],161:[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":145,"./typeof.js":166}],162:[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":136}],163:[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":143,"./iterableToArrayLimit.js":158,"./nonIterableRest.js":159,"./unsupportedIterableToArray.js":167}],164:[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":152}],165:[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":144,"./iterableToArray.js":157,"./nonIterableSpread.js":160,"./unsupportedIterableToArray.js":167}],166:[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":140,"@babel/runtime-corejs3/core-js/symbol/iterator":141}],167:[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":142,"@babel/runtime-corejs3/core-js/array/from":125,"@babel/runtime-corejs3/core-js/instance/slice":130}],168:[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":148,"./getPrototypeOf.js":152,"./isNativeFunction.js":155,"./setPrototypeOf.js":162,"@babel/runtime-corejs3/core-js/map":131,"@babel/runtime-corejs3/core-js/object/create":132}],169:[function(_dereq_,module,exports){
- module.exports = _dereq_("regenerator-runtime");
- },{"regenerator-runtime":796}],170:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.version = void 0;
- exports.version = "abi/5.6.0";
- },{}],171:[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":170,"./coders/abstract-coder":172,"./coders/address":173,"./coders/array":175,"./coders/boolean":176,"./coders/bytes":177,"./coders/fixed-bytes":178,"./coders/null":179,"./coders/number":180,"./coders/string":181,"./coders/tuple":182,"./fragments":183,"@ethersproject/bytes":201,"@ethersproject/logger":225,"@ethersproject/properties":231}],172:[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":170,"@ethersproject/bignumber":198,"@ethersproject/bytes":201,"@ethersproject/logger":225,"@ethersproject/properties":231}],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.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":172,"@ethersproject/address":191,"@ethersproject/bytes":201}],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.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":172}],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.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":170,"./abstract-coder":172,"./anonymous":174,"@ethersproject/logger":225}],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.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":172}],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.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":172,"@ethersproject/bytes":201}],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.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":172,"@ethersproject/bytes":201}],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.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":172}],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.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":172,"@ethersproject/bignumber":198,"@ethersproject/constants":205}],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.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":177,"@ethersproject/strings":268}],182:[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":172,"./array":175}],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.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":170,"@ethersproject/bignumber":198,"@ethersproject/logger":225,"@ethersproject/properties":231}],184:[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":171,"./fragments":183,"./interface":185}],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 __());
- };
- })();
- 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":170,"./abi-coder":171,"./coders/abstract-coder":172,"./fragments":183,"@ethersproject/address":191,"@ethersproject/bignumber":198,"@ethersproject/bytes":201,"@ethersproject/hash":211,"@ethersproject/keccak256":223,"@ethersproject/logger":225,"@ethersproject/properties":231}],186:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.version = void 0;
- exports.version = "abstract-provider/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.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":186,"@ethersproject/bignumber":198,"@ethersproject/bytes":201,"@ethersproject/logger":225,"@ethersproject/properties":231}],188:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.version = void 0;
- exports.version = "abstract-signer/5.6.0";
- },{}],189:[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":188,"@ethersproject/logger":225,"@ethersproject/properties":231}],190:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.version = void 0;
- exports.version = "address/5.6.0";
- },{}],191:[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":190,"@ethersproject/bignumber":198,"@ethersproject/bytes":201,"@ethersproject/keccak256":223,"@ethersproject/logger":225,"@ethersproject/rlp":255}],192:[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":201}],193:[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":192}],194:[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":201,"@ethersproject/properties":231}],195:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.version = void 0;
- exports.version = "bignumber/5.6.0";
- },{}],196:[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":195,"@ethersproject/bytes":201,"@ethersproject/logger":225,"bn.js":199}],197:[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":195,"./bignumber":196,"@ethersproject/bytes":201,"@ethersproject/logger":225}],198:[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":196,"./fixednumber":197}],199:[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}],200:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.version = void 0;
- exports.version = "bytes/5.6.0";
- },{}],201:[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":200,"@ethersproject/logger":225}],202:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.AddressZero = void 0;
- exports.AddressZero = "0x0000000000000000000000000000000000000000";
- },{}],203:[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":198}],204:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.HashZero = void 0;
- exports.HashZero = "0x0000000000000000000000000000000000000000000000000000000000000000";
- },{}],205:[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":202,"./bignumbers":203,"./hashes":204,"./strings":206}],206:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.EtherSymbol = void 0;
- // NFKC (composed) // (decomposed)
- exports.EtherSymbol = "\u039e"; // "\uD835\uDF63";
- },{}],207:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.version = void 0;
- exports.version = "contracts/5.6.0";
- },{}],208:[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":207,"@ethersproject/abi":184,"@ethersproject/abstract-provider":187,"@ethersproject/abstract-signer":189,"@ethersproject/address":191,"@ethersproject/bignumber":198,"@ethersproject/bytes":201,"@ethersproject/logger":225,"@ethersproject/properties":231,"@ethersproject/transactions":271}],209:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.version = void 0;
- exports.version = "hash/5.6.0";
- },{}],210:[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":223,"@ethersproject/strings":268}],211:[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":210,"./message":212,"./namehash":213,"./typed-data":214}],212:[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":201,"@ethersproject/keccak256":223,"@ethersproject/strings":268}],213:[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":209,"@ethersproject/bytes":201,"@ethersproject/keccak256":223,"@ethersproject/logger":225,"@ethersproject/strings":268}],214:[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":209,"./id":210,"@ethersproject/address":191,"@ethersproject/bignumber":198,"@ethersproject/bytes":201,"@ethersproject/keccak256":223,"@ethersproject/logger":225,"@ethersproject/properties":231}],215:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.version = void 0;
- exports.version = "hdnode/5.6.0";
- },{}],216:[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":215,"@ethersproject/basex":194,"@ethersproject/bignumber":198,"@ethersproject/bytes":201,"@ethersproject/logger":225,"@ethersproject/pbkdf2":229,"@ethersproject/properties":231,"@ethersproject/sha2":258,"@ethersproject/signing-key":262,"@ethersproject/strings":268,"@ethersproject/transactions":271,"@ethersproject/wordlists":280}],217:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.version = void 0;
- exports.version = "json-wallets/5.6.0";
- },{}],218:[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":217,"./utils":222,"@ethersproject/address":191,"@ethersproject/bytes":201,"@ethersproject/keccak256":223,"@ethersproject/logger":225,"@ethersproject/pbkdf2":229,"@ethersproject/properties":231,"@ethersproject/strings":268,"aes-js":292}],219:[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":218,"./inspect":220,"./keystore":221}],220:[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":191}],221:[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":217,"./utils":222,"@ethersproject/address":191,"@ethersproject/bytes":201,"@ethersproject/hdnode":216,"@ethersproject/keccak256":223,"@ethersproject/logger":225,"@ethersproject/pbkdf2":229,"@ethersproject/properties":231,"@ethersproject/random":252,"@ethersproject/transactions":271,"aes-js":292,"scrypt-js":797}],222:[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":201,"@ethersproject/strings":268}],223:[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":201,"js-sha3":792}],224:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.version = void 0;
- exports.version = "logger/5.6.0";
- },{}],225:[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":224}],226:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.version = void 0;
- exports.version = "networks/5.6.0";
- },{}],227:[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":226,"@ethersproject/logger":225}],228:[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":201,"@ethersproject/sha2":258}],229:[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":228}],230:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.version = void 0;
- exports.version = "properties/5.6.0";
- },{}],231:[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":230,"@ethersproject/logger":225}],232:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.version = void 0;
- exports.version = "providers/5.6.0";
- },{}],233:[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":232,"./formatter":240,"./url-json-rpc-provider":247,"./websocket-provider":249,"@ethersproject/logger":225,"@ethersproject/properties":231}],234:[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":232,"./formatter":240,"@ethersproject/abstract-provider":187,"@ethersproject/basex":194,"@ethersproject/bignumber":198,"@ethersproject/bytes":201,"@ethersproject/constants":205,"@ethersproject/hash":211,"@ethersproject/logger":225,"@ethersproject/networks":227,"@ethersproject/properties":231,"@ethersproject/sha2":258,"@ethersproject/strings":268,"@ethersproject/web":278,"bech32":323}],235:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.IpcProvider = void 0;
- var IpcProvider = null;
- exports.IpcProvider = IpcProvider;
- },{}],236:[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":232,"@ethersproject/logger":225}],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.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":232,"./url-json-rpc-provider":247,"@ethersproject/logger":225}],238:[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":232,"./base-provider":234,"./formatter":240,"@ethersproject/bytes":201,"@ethersproject/logger":225,"@ethersproject/properties":231,"@ethersproject/transactions":271,"@ethersproject/web":278}],239:[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":232,"./base-provider":234,"./formatter":240,"@ethersproject/abstract-provider":187,"@ethersproject/bignumber":198,"@ethersproject/bytes":201,"@ethersproject/logger":225,"@ethersproject/properties":231,"@ethersproject/random":252,"@ethersproject/web":278}],240:[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":232,"@ethersproject/address":191,"@ethersproject/bignumber":198,"@ethersproject/bytes":201,"@ethersproject/constants":205,"@ethersproject/logger":225,"@ethersproject/properties":231,"@ethersproject/transactions":271}],241:[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":232,"./alchemy-provider":233,"./base-provider":234,"./cloudflare-provider":237,"./etherscan-provider":238,"./fallback-provider":239,"./formatter":240,"./infura-provider":242,"./ipc-provider":235,"./json-rpc-batch-provider":243,"./json-rpc-provider":244,"./nodesmith-provider":245,"./pocket-provider":246,"./url-json-rpc-provider":247,"./web3-provider":248,"./websocket-provider":249,"@ethersproject/abstract-provider":187,"@ethersproject/logger":225,"@ethersproject/networks":227}],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 __());
- };
- })();
- 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":232,"./formatter":240,"./url-json-rpc-provider":247,"./websocket-provider":249,"@ethersproject/logger":225,"@ethersproject/properties":231}],243:[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":244,"@ethersproject/properties":231,"@ethersproject/web":278}],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 __());
- };
- })();
- 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":232,"./base-provider":234,"@ethersproject/abstract-signer":189,"@ethersproject/bignumber":198,"@ethersproject/bytes":201,"@ethersproject/hash":211,"@ethersproject/logger":225,"@ethersproject/properties":231,"@ethersproject/strings":268,"@ethersproject/transactions":271,"@ethersproject/web":278}],245:[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":232,"./url-json-rpc-provider":247,"@ethersproject/logger":225}],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.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":232,"./url-json-rpc-provider":247,"@ethersproject/logger":225,"@ethersproject/properties":231}],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.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":232,"./json-rpc-provider":244,"@ethersproject/logger":225,"@ethersproject/properties":231}],248:[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":232,"./json-rpc-provider":244,"@ethersproject/logger":225,"@ethersproject/properties":231}],249:[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":232,"./json-rpc-provider":244,"./ws":236,"@ethersproject/bignumber":198,"@ethersproject/logger":225,"@ethersproject/properties":231}],250:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.version = void 0;
- exports.version = "random/5.6.0";
- },{}],251:[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":250,"@ethersproject/bytes":201,"@ethersproject/logger":225}],252:[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":251,"./shuffle":253}],253:[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;
- },{}],254:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.version = void 0;
- exports.version = "rlp/5.6.0";
- },{}],255:[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":254,"@ethersproject/bytes":201,"@ethersproject/logger":225}],256:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.version = void 0;
- exports.version = "sha2/5.6.0";
- },{}],257:[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":256,"./types":259,"@ethersproject/bytes":201,"@ethersproject/logger":225,"hash.js":778}],258:[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":257,"./types":259}],259:[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 = {}));
- ;
- },{}],260:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.version = void 0;
- exports.version = "signing-key/5.6.0";
- },{}],261:[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":756}],262:[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":260,"./elliptic":261,"@ethersproject/bytes":201,"@ethersproject/logger":225,"@ethersproject/properties":231}],263:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.version = void 0;
- exports.version = "solidity/5.6.0";
- },{}],264:[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":263,"@ethersproject/bignumber":198,"@ethersproject/bytes":201,"@ethersproject/keccak256":223,"@ethersproject/logger":225,"@ethersproject/sha2":258,"@ethersproject/strings":268}],265:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.version = void 0;
- exports.version = "strings/5.6.0";
- },{}],266:[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":269,"@ethersproject/bytes":201,"@ethersproject/constants":205}],267:[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":269}],268:[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":266,"./idna":267,"./utf8":269}],269:[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":265,"@ethersproject/bytes":201,"@ethersproject/logger":225}],270:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.version = void 0;
- exports.version = "transactions/5.6.0";
- },{}],271:[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":270,"@ethersproject/address":191,"@ethersproject/bignumber":198,"@ethersproject/bytes":201,"@ethersproject/constants":205,"@ethersproject/keccak256":223,"@ethersproject/logger":225,"@ethersproject/properties":231,"@ethersproject/rlp":255,"@ethersproject/signing-key":262}],272:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.version = void 0;
- exports.version = "units/5.6.0";
- },{}],273:[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":272,"@ethersproject/bignumber":198,"@ethersproject/logger":225}],274:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.version = void 0;
- exports.version = "wallet/5.6.0";
- },{}],275:[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":274,"@ethersproject/abstract-provider":187,"@ethersproject/abstract-signer":189,"@ethersproject/address":191,"@ethersproject/bytes":201,"@ethersproject/hash":211,"@ethersproject/hdnode":216,"@ethersproject/json-wallets":219,"@ethersproject/keccak256":223,"@ethersproject/logger":225,"@ethersproject/properties":231,"@ethersproject/random":252,"@ethersproject/signing-key":262,"@ethersproject/transactions":271}],276:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.version = void 0;
- exports.version = "web/5.6.0";
- },{}],277:[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":201}],278:[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":276,"./geturl":277,"@ethersproject/base64":193,"@ethersproject/bytes":201,"@ethersproject/logger":225,"@ethersproject/properties":231,"@ethersproject/strings":268}],279:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.version = void 0;
- exports.version = "wordlists/5.6.0";
- },{}],280:[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":289,"./wordlists":290}],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.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":289}],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.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":289}],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.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":289,"@ethersproject/strings":268}],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.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":289,"@ethersproject/strings":268}],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.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":289}],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.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":289,"@ethersproject/bytes":201,"@ethersproject/strings":268}],287:[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":289,"@ethersproject/strings":268}],288:[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":289,"@ethersproject/strings":268}],289:[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":279,"@ethersproject/hash":211,"@ethersproject/logger":225,"@ethersproject/properties":231}],290:[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":281,"./lang-en":282,"./lang-es":283,"./lang-fr":284,"./lang-it":285,"./lang-ja":286,"./lang-ko":287,"./lang-zh":288}],291:[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;
- },{}],292:[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);
- },{}],293:[function(_dereq_,module,exports){
- module.exports = _dereq_('./lib/axios');
- },{"./lib/axios":295}],294:[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":296,"../core/buildFullPath":301,"../core/createError":302,"../defaults/transitional":309,"./../core/settle":306,"./../helpers/buildURL":312,"./../helpers/cookies":314,"./../helpers/isURLSameOrigin":317,"./../helpers/parseHeaders":319,"./../utils":322}],295:[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":296,"./cancel/CancelToken":297,"./cancel/isCancel":298,"./core/Axios":299,"./core/mergeConfig":305,"./defaults":308,"./env/data":310,"./helpers/bind":311,"./helpers/isAxiosError":316,"./helpers/spread":320,"./utils":322}],296:[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;
- },{}],297:[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":296}],298:[function(_dereq_,module,exports){
- 'use strict';
- module.exports = function isCancel(value) {
- return !!(value && value.__CANCEL__);
- };
- },{}],299:[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":312,"../helpers/validator":321,"./../utils":322,"./InterceptorManager":300,"./dispatchRequest":303,"./mergeConfig":305}],300:[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":322}],301:[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":313,"../helpers/isAbsoluteURL":315}],302:[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":304}],303:[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":296,"../cancel/isCancel":298,"../defaults":308,"./../utils":322,"./transformData":307}],304:[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;
- };
- },{}],305:[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":322}],306:[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":302}],307:[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":308,"./../utils":322}],308:[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":294,"../adapters/xhr":294,"../core/enhanceError":304,"../helpers/normalizeHeaderName":318,"../utils":322,"./transitional":309,"_process":325}],309:[function(_dereq_,module,exports){
- 'use strict';
- module.exports = {
- silentJSONParsing: true,
- forcedJSONParsing: true,
- clarifyTimeoutError: false
- };
- },{}],310:[function(_dereq_,module,exports){
- module.exports = {
- "version": "0.26.1"
- };
- },{}],311:[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);
- };
- };
- },{}],312:[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":322}],313:[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;
- };
- },{}],314:[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":322}],315:[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);
- };
- },{}],316:[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":322}],317:[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":322}],318:[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":322}],319:[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":322}],320:[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);
- };
- };
- },{}],321:[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":310}],322:[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":311}],323:[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
- }
- },{}],324:[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}],325:[function(_dereq_,module,exports){
- },{}],326:[function(_dereq_,module,exports){
- var parent = _dereq_('../../stable/array/from');
- module.exports = parent;
- },{"../../stable/array/from":693}],327:[function(_dereq_,module,exports){
- var parent = _dereq_('../../stable/array/is-array');
- module.exports = parent;
- },{"../../stable/array/is-array":694}],328:[function(_dereq_,module,exports){
- var parent = _dereq_('../stable/get-iterator-method');
- module.exports = parent;
- },{"../stable/get-iterator-method":699}],329:[function(_dereq_,module,exports){
- var parent = _dereq_('../../stable/instance/bind');
- module.exports = parent;
- },{"../../stable/instance/bind":700}],330:[function(_dereq_,module,exports){
- var parent = _dereq_('../../stable/instance/index-of');
- module.exports = parent;
- },{"../../stable/instance/index-of":708}],331:[function(_dereq_,module,exports){
- var parent = _dereq_('../../stable/instance/slice');
- module.exports = parent;
- },{"../../stable/instance/slice":713}],332:[function(_dereq_,module,exports){
- var parent = _dereq_('../../stable/map');
- module.exports = parent;
- },{"../../stable/map":720}],333:[function(_dereq_,module,exports){
- var parent = _dereq_('../../stable/object/create');
- module.exports = parent;
- },{"../../stable/object/create":723}],334:[function(_dereq_,module,exports){
- var parent = _dereq_('../../stable/object/define-property');
- module.exports = parent;
- },{"../../stable/object/define-property":725}],335:[function(_dereq_,module,exports){
- var parent = _dereq_('../../stable/object/get-own-property-descriptor');
- module.exports = parent;
- },{"../../stable/object/get-own-property-descriptor":728}],336:[function(_dereq_,module,exports){
- var parent = _dereq_('../../stable/object/get-prototype-of');
- module.exports = parent;
- },{"../../stable/object/get-prototype-of":731}],337:[function(_dereq_,module,exports){
- var parent = _dereq_('../../stable/object/set-prototype-of');
- module.exports = parent;
- },{"../../stable/object/set-prototype-of":733}],338:[function(_dereq_,module,exports){
- var parent = _dereq_('../../stable/promise');
- module.exports = parent;
- },{"../../stable/promise":736}],339:[function(_dereq_,module,exports){
- var parent = _dereq_('../../stable/reflect/construct');
- module.exports = parent;
- },{"../../stable/reflect/construct":737}],340:[function(_dereq_,module,exports){
- var parent = _dereq_('../../stable/reflect/get');
- module.exports = parent;
- },{"../../stable/reflect/get":738}],341:[function(_dereq_,module,exports){
- var parent = _dereq_('../../stable/symbol');
- module.exports = parent;
- },{"../../stable/symbol":741}],342:[function(_dereq_,module,exports){
- var parent = _dereq_('../../stable/symbol/iterator');
- module.exports = parent;
- },{"../../stable/symbol/iterator":742}],343:[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":550,"../../modules/es.array.from":596,"../../modules/es.string.iterator":636}],344:[function(_dereq_,module,exports){
- _dereq_('../../modules/es.array.is-array');
- var path = _dereq_('../../internals/path');
- module.exports = path.Array.isArray;
- },{"../../internals/path":550,"../../modules/es.array.is-array":599}],345:[function(_dereq_,module,exports){
- _dereq_('../../../modules/es.array.concat');
- var entryVirtual = _dereq_('../../../internals/entry-virtual');
- module.exports = entryVirtual('Array').concat;
- },{"../../../internals/entry-virtual":475,"../../../modules/es.array.concat":591}],346:[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":475,"../../../modules/es.array.iterator":600,"../../../modules/es.object.to-string":623}],347:[function(_dereq_,module,exports){
- _dereq_('../../../modules/es.array.every');
- var entryVirtual = _dereq_('../../../internals/entry-virtual');
- module.exports = entryVirtual('Array').every;
- },{"../../../internals/entry-virtual":475,"../../../modules/es.array.every":592}],348:[function(_dereq_,module,exports){
- _dereq_('../../../modules/es.array.filter');
- var entryVirtual = _dereq_('../../../internals/entry-virtual');
- module.exports = entryVirtual('Array').filter;
- },{"../../../internals/entry-virtual":475,"../../../modules/es.array.filter":593}],349:[function(_dereq_,module,exports){
- _dereq_('../../../modules/es.array.find');
- var entryVirtual = _dereq_('../../../internals/entry-virtual');
- module.exports = entryVirtual('Array').find;
- },{"../../../internals/entry-virtual":475,"../../../modules/es.array.find":594}],350:[function(_dereq_,module,exports){
- _dereq_('../../../modules/es.array.for-each');
- var entryVirtual = _dereq_('../../../internals/entry-virtual');
- module.exports = entryVirtual('Array').forEach;
- },{"../../../internals/entry-virtual":475,"../../../modules/es.array.for-each":595}],351:[function(_dereq_,module,exports){
- _dereq_('../../../modules/es.array.includes');
- var entryVirtual = _dereq_('../../../internals/entry-virtual');
- module.exports = entryVirtual('Array').includes;
- },{"../../../internals/entry-virtual":475,"../../../modules/es.array.includes":597}],352:[function(_dereq_,module,exports){
- _dereq_('../../../modules/es.array.index-of');
- var entryVirtual = _dereq_('../../../internals/entry-virtual');
- module.exports = entryVirtual('Array').indexOf;
- },{"../../../internals/entry-virtual":475,"../../../modules/es.array.index-of":598}],353:[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":475,"../../../modules/es.array.iterator":600,"../../../modules/es.object.to-string":623}],354:[function(_dereq_,module,exports){
- _dereq_('../../../modules/es.array.map');
- var entryVirtual = _dereq_('../../../internals/entry-virtual');
- module.exports = entryVirtual('Array').map;
- },{"../../../internals/entry-virtual":475,"../../../modules/es.array.map":601}],355:[function(_dereq_,module,exports){
- _dereq_('../../../modules/es.array.reduce');
- var entryVirtual = _dereq_('../../../internals/entry-virtual');
- module.exports = entryVirtual('Array').reduce;
- },{"../../../internals/entry-virtual":475,"../../../modules/es.array.reduce":602}],356:[function(_dereq_,module,exports){
- _dereq_('../../../modules/es.array.slice');
- var entryVirtual = _dereq_('../../../internals/entry-virtual');
- module.exports = entryVirtual('Array').slice;
- },{"../../../internals/entry-virtual":475,"../../../modules/es.array.slice":603}],357:[function(_dereq_,module,exports){
- _dereq_('../../../modules/es.array.sort');
- var entryVirtual = _dereq_('../../../internals/entry-virtual');
- module.exports = entryVirtual('Array').sort;
- },{"../../../internals/entry-virtual":475,"../../../modules/es.array.sort":604}],358:[function(_dereq_,module,exports){
- _dereq_('../../../modules/es.array.splice');
- var entryVirtual = _dereq_('../../../internals/entry-virtual');
- module.exports = entryVirtual('Array').splice;
- },{"../../../internals/entry-virtual":475,"../../../modules/es.array.splice":605}],359:[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":475,"../../../modules/es.array.iterator":600,"../../../modules/es.object.to-string":623}],360:[function(_dereq_,module,exports){
- _dereq_('../../../modules/es.function.bind');
- var entryVirtual = _dereq_('../../../internals/entry-virtual');
- module.exports = entryVirtual('Function').bind;
- },{"../../../internals/entry-virtual":475,"../../../modules/es.function.bind":606}],361:[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":489,"../modules/es.array.iterator":600,"../modules/es.string.iterator":636}],362:[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":541,"../function/virtual/bind":360}],363:[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":541,"../array/virtual/concat":345}],364:[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":541,"../array/virtual/every":347}],365:[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":541,"../array/virtual/filter":348}],366:[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":541,"../array/virtual/find":349}],367:[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":541,"../array/virtual/includes":351,"../string/virtual/includes":398}],368:[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":541,"../array/virtual/index-of":352}],369:[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":541,"../array/virtual/map":354}],370:[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":541,"../string/virtual/pad-start":399}],371:[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":541,"../array/virtual/reduce":355}],372:[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":541,"../array/virtual/slice":356}],373:[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":541,"../array/virtual/sort":357}],374:[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":541,"../array/virtual/splice":358}],375:[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":541,"../string/virtual/starts-with":400}],376:[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":541,"../string/virtual/trim":401}],377:[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":481,"../../internals/path":550,"../../modules/es.json.stringify":607}],378:[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":550,"../../modules/es.array.iterator":600,"../../modules/es.map":609,"../../modules/es.object.to-string":623,"../../modules/es.string.iterator":636}],379:[function(_dereq_,module,exports){
- _dereq_('../../modules/es.number.is-integer');
- var path = _dereq_('../../internals/path');
- module.exports = path.Number.isInteger;
- },{"../../internals/path":550,"../../modules/es.number.is-integer":611}],380:[function(_dereq_,module,exports){
- _dereq_('../../modules/es.number.is-nan');
- var path = _dereq_('../../internals/path');
- module.exports = path.Number.isNaN;
- },{"../../internals/path":550,"../../modules/es.number.is-nan":612}],381:[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":550,"../../modules/es.object.create":613}],382:[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":550,"../../modules/es.object.define-properties":614}],383:[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":550,"../../modules/es.object.define-property":615}],384:[function(_dereq_,module,exports){
- _dereq_('../../modules/es.object.entries');
- var path = _dereq_('../../internals/path');
- module.exports = path.Object.entries;
- },{"../../internals/path":550,"../../modules/es.object.entries":616}],385:[function(_dereq_,module,exports){
- _dereq_('../../modules/es.object.freeze');
- var path = _dereq_('../../internals/path');
- module.exports = path.Object.freeze;
- },{"../../internals/path":550,"../../modules/es.object.freeze":617}],386:[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":550,"../../modules/es.object.get-own-property-descriptor":618}],387:[function(_dereq_,module,exports){
- _dereq_('../../modules/es.object.get-own-property-descriptors');
- var path = _dereq_('../../internals/path');
- module.exports = path.Object.getOwnPropertyDescriptors;
- },{"../../internals/path":550,"../../modules/es.object.get-own-property-descriptors":619}],388:[function(_dereq_,module,exports){
- _dereq_('../../modules/es.symbol');
- var path = _dereq_('../../internals/path');
- module.exports = path.Object.getOwnPropertySymbols;
- },{"../../internals/path":550,"../../modules/es.symbol":646}],389:[function(_dereq_,module,exports){
- _dereq_('../../modules/es.object.get-prototype-of');
- var path = _dereq_('../../internals/path');
- module.exports = path.Object.getPrototypeOf;
- },{"../../internals/path":550,"../../modules/es.object.get-prototype-of":620}],390:[function(_dereq_,module,exports){
- _dereq_('../../modules/es.object.keys');
- var path = _dereq_('../../internals/path');
- module.exports = path.Object.keys;
- },{"../../internals/path":550,"../../modules/es.object.keys":621}],391:[function(_dereq_,module,exports){
- _dereq_('../../modules/es.object.set-prototype-of');
- var path = _dereq_('../../internals/path');
- module.exports = path.Object.setPrototypeOf;
- },{"../../internals/path":550,"../../modules/es.object.set-prototype-of":622}],392:[function(_dereq_,module,exports){
- _dereq_('../../modules/es.object.values');
- var path = _dereq_('../../internals/path');
- module.exports = path.Object.values;
- },{"../../internals/path":550,"../../modules/es.object.values":624}],393:[function(_dereq_,module,exports){
- _dereq_('../modules/es.parse-int');
- var path = _dereq_('../internals/path');
- module.exports = path.parseInt;
- },{"../internals/path":550,"../modules/es.parse-int":625}],394:[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":550,"../../modules/es.aggregate-error":590,"../../modules/es.array.iterator":600,"../../modules/es.object.to-string":623,"../../modules/es.promise":629,"../../modules/es.promise.all-settled":626,"../../modules/es.promise.any":627,"../../modules/es.promise.finally":628,"../../modules/es.string.iterator":636}],395:[function(_dereq_,module,exports){
- _dereq_('../../modules/es.reflect.construct');
- var path = _dereq_('../../internals/path');
- module.exports = path.Reflect.construct;
- },{"../../internals/path":550,"../../modules/es.reflect.construct":630}],396:[function(_dereq_,module,exports){
- _dereq_('../../modules/es.reflect.get');
- var path = _dereq_('../../internals/path');
- module.exports = path.Reflect.get;
- },{"../../internals/path":550,"../../modules/es.reflect.get":631}],397:[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":550,"../../modules/es.array.iterator":600,"../../modules/es.object.to-string":623,"../../modules/es.set":634,"../../modules/es.string.iterator":636}],398:[function(_dereq_,module,exports){
- _dereq_('../../../modules/es.string.includes');
- var entryVirtual = _dereq_('../../../internals/entry-virtual');
- module.exports = entryVirtual('String').includes;
- },{"../../../internals/entry-virtual":475,"../../../modules/es.string.includes":635}],399:[function(_dereq_,module,exports){
- _dereq_('../../../modules/es.string.pad-start');
- var entryVirtual = _dereq_('../../../internals/entry-virtual');
- module.exports = entryVirtual('String').padStart;
- },{"../../../internals/entry-virtual":475,"../../../modules/es.string.pad-start":637}],400:[function(_dereq_,module,exports){
- _dereq_('../../../modules/es.string.starts-with');
- var entryVirtual = _dereq_('../../../internals/entry-virtual');
- module.exports = entryVirtual('String').startsWith;
- },{"../../../internals/entry-virtual":475,"../../../modules/es.string.starts-with":639}],401:[function(_dereq_,module,exports){
- _dereq_('../../../modules/es.string.trim');
- var entryVirtual = _dereq_('../../../internals/entry-virtual');
- module.exports = entryVirtual('String').trim;
- },{"../../../internals/entry-virtual":475,"../../../modules/es.string.trim":640}],402:[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":550,"../../modules/es.array.concat":591,"../../modules/es.json.to-string-tag":608,"../../modules/es.math.to-string-tag":610,"../../modules/es.object.to-string":623,"../../modules/es.reflect.to-string-tag":632,"../../modules/es.symbol":646,"../../modules/es.symbol.async-iterator":641,"../../modules/es.symbol.description":642,"../../modules/es.symbol.has-instance":643,"../../modules/es.symbol.is-concat-spreadable":644,"../../modules/es.symbol.iterator":645,"../../modules/es.symbol.match":648,"../../modules/es.symbol.match-all":647,"../../modules/es.symbol.replace":649,"../../modules/es.symbol.search":650,"../../modules/es.symbol.species":651,"../../modules/es.symbol.split":652,"../../modules/es.symbol.to-primitive":653,"../../modules/es.symbol.to-string-tag":654,"../../modules/es.symbol.unscopables":655}],403:[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":587,"../../modules/es.array.iterator":600,"../../modules/es.object.to-string":623,"../../modules/es.string.iterator":636,"../../modules/es.symbol.iterator":645}],404:[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":587,"../../modules/es.regexp.exec":633,"../../modules/es.string.replace":638,"../../modules/es.symbol.replace":649}],405:[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":550,"../../modules/es.array.iterator":600,"../../modules/es.object.to-string":623,"../../modules/es.weak-map":656}],406:[function(_dereq_,module,exports){
- var parent = _dereq_('../../actual/array/from');
- module.exports = parent;
- },{"../../actual/array/from":326}],407:[function(_dereq_,module,exports){
- var parent = _dereq_('../../actual/array/is-array');
- module.exports = parent;
- },{"../../actual/array/is-array":327}],408:[function(_dereq_,module,exports){
- var parent = _dereq_('../actual/get-iterator-method');
- module.exports = parent;
- },{"../actual/get-iterator-method":328}],409:[function(_dereq_,module,exports){
- var parent = _dereq_('../../actual/instance/bind');
- module.exports = parent;
- },{"../../actual/instance/bind":329}],410:[function(_dereq_,module,exports){
- var parent = _dereq_('../../actual/instance/index-of');
- module.exports = parent;
- },{"../../actual/instance/index-of":330}],411:[function(_dereq_,module,exports){
- var parent = _dereq_('../../actual/instance/slice');
- module.exports = parent;
- },{"../../actual/instance/slice":331}],412:[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":332,"../../modules/esnext.map.delete-all":658,"../../modules/esnext.map.emplace":659,"../../modules/esnext.map.every":660,"../../modules/esnext.map.filter":661,"../../modules/esnext.map.find":663,"../../modules/esnext.map.find-key":662,"../../modules/esnext.map.from":664,"../../modules/esnext.map.group-by":665,"../../modules/esnext.map.includes":666,"../../modules/esnext.map.key-by":667,"../../modules/esnext.map.key-of":668,"../../modules/esnext.map.map-keys":669,"../../modules/esnext.map.map-values":670,"../../modules/esnext.map.merge":671,"../../modules/esnext.map.of":672,"../../modules/esnext.map.reduce":673,"../../modules/esnext.map.some":674,"../../modules/esnext.map.update":676,"../../modules/esnext.map.update-or-insert":675,"../../modules/esnext.map.upsert":677}],413:[function(_dereq_,module,exports){
- var parent = _dereq_('../../actual/object/create');
- module.exports = parent;
- },{"../../actual/object/create":333}],414:[function(_dereq_,module,exports){
- var parent = _dereq_('../../actual/object/define-property');
- module.exports = parent;
- },{"../../actual/object/define-property":334}],415:[function(_dereq_,module,exports){
- var parent = _dereq_('../../actual/object/get-own-property-descriptor');
- module.exports = parent;
- },{"../../actual/object/get-own-property-descriptor":335}],416:[function(_dereq_,module,exports){
- var parent = _dereq_('../../actual/object/get-prototype-of');
- module.exports = parent;
- },{"../../actual/object/get-prototype-of":336}],417:[function(_dereq_,module,exports){
- var parent = _dereq_('../../actual/object/set-prototype-of');
- module.exports = parent;
- },{"../../actual/object/set-prototype-of":337}],418:[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":338,"../../modules/esnext.aggregate-error":657,"../../modules/esnext.promise.all-settled":678,"../../modules/esnext.promise.any":679,"../../modules/esnext.promise.try":680}],419:[function(_dereq_,module,exports){
- var parent = _dereq_('../../actual/reflect/construct');
- module.exports = parent;
- },{"../../actual/reflect/construct":339}],420:[function(_dereq_,module,exports){
- var parent = _dereq_('../../actual/reflect/get');
- module.exports = parent;
- },{"../../actual/reflect/get":340}],421:[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":341,"../../modules/esnext.symbol.async-dispose":681,"../../modules/esnext.symbol.dispose":682,"../../modules/esnext.symbol.matcher":683,"../../modules/esnext.symbol.metadata":684,"../../modules/esnext.symbol.observable":685,"../../modules/esnext.symbol.pattern-match":686,"../../modules/esnext.symbol.replace-all":687}],422:[function(_dereq_,module,exports){
- var parent = _dereq_('../../actual/symbol/iterator');
- module.exports = parent;
- },{"../../actual/symbol/iterator":342}],423:[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":493,"../internals/is-callable":506,"../internals/try-to-string":582}],424:[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":493,"../internals/is-constructor":507,"../internals/try-to-string":582}],425:[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":493,"../internals/is-callable":506}],426:[function(_dereq_,module,exports){
- module.exports = function () { /* empty */ };
- },{}],427:[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":493,"../internals/object-is-prototype-of":541}],428:[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":493,"../internals/is-object":511}],429:[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":479}],430:[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":433,"../internals/array-method-is-strict":435}],431:[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":442,"../internals/create-property":459,"../internals/function-bind-context":482,"../internals/function-call":485,"../internals/get-iterator":490,"../internals/get-iterator-method":489,"../internals/global":493,"../internals/is-array-iterator-method":504,"../internals/is-constructor":507,"../internals/length-of-array-like":519,"../internals/to-object":577}],432:[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":519,"../internals/to-absolute-index":573,"../internals/to-indexed-object":574}],433:[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":441,"../internals/function-bind-context":482,"../internals/function-uncurry-this":487,"../internals/indexed-object":499,"../internals/length-of-array-like":519,"../internals/to-object":577}],434:[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":473,"../internals/fails":479,"../internals/well-known-symbol":588}],435:[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":479}],436:[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":423,"../internals/global":493,"../internals/indexed-object":499,"../internals/length-of-array-like":519,"../internals/to-object":577}],437:[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":459,"../internals/global":493,"../internals/length-of-array-like":519,"../internals/to-absolute-index":573}],438:[function(_dereq_,module,exports){
- var uncurryThis = _dereq_('../internals/function-uncurry-this');
- module.exports = uncurryThis([].slice);
- },{"../internals/function-uncurry-this":487}],439:[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":437}],440:[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":493,"../internals/is-array":505,"../internals/is-constructor":507,"../internals/is-object":511,"../internals/well-known-symbol":588}],441:[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":440}],442:[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":428,"../internals/iterator-close":516}],443:[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":588}],444:[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":487}],445:[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":444,"../internals/global":493,"../internals/is-callable":506,"../internals/to-string-tag-support":580,"../internals/well-known-symbol":588}],446:[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":487}],447:[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":423,"../internals/an-object":428,"../internals/function-call":485}],448:[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":423,"../internals/a-constructor":424,"../internals/function-bind-context":482,"../internals/function-call":485,"../internals/iterate":515}],449:[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":438}],450:[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":427,"../internals/define-iterator":460,"../internals/descriptors":462,"../internals/function-bind-context":482,"../internals/internal-metadata":502,"../internals/internal-state":503,"../internals/iterate":515,"../internals/object-create":532,"../internals/object-define-property":534,"../internals/redefine-all":554,"../internals/set-species":559}],451:[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":427,"../internals/an-object":428,"../internals/array-iteration":433,"../internals/function-uncurry-this":487,"../internals/has-own-property":494,"../internals/internal-metadata":502,"../internals/internal-state":503,"../internals/is-object":511,"../internals/iterate":515,"../internals/redefine-all":554}],452:[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":427,"../internals/array-iteration":433,"../internals/create-non-enumerable-property":457,"../internals/descriptors":462,"../internals/export":478,"../internals/fails":479,"../internals/global":493,"../internals/internal-metadata":502,"../internals/internal-state":503,"../internals/is-callable":506,"../internals/is-object":511,"../internals/iterate":515,"../internals/object-define-property":534,"../internals/set-to-string-tag":560}],453:[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":494,"../internals/object-define-property":534,"../internals/object-get-own-property-descriptor":535,"../internals/own-keys":549}],454:[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":588}],455:[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":479}],456:[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":458,"../internals/iterators":518,"../internals/iterators-core":517,"../internals/object-create":532,"../internals/set-to-string-tag":560}],457:[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":458,"../internals/descriptors":462,"../internals/object-define-property":534}],458:[function(_dereq_,module,exports){
- module.exports = function (bitmap, value) {
- return {
- enumerable: !(bitmap & 1),
- configurable: !(bitmap & 2),
- writable: !(bitmap & 4),
- value: value
- };
- };
- },{}],459:[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":458,"../internals/object-define-property":534,"../internals/to-property-key":579}],460:[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":456,"../internals/create-non-enumerable-property":457,"../internals/export":478,"../internals/function-call":485,"../internals/function-name":486,"../internals/is-callable":506,"../internals/is-pure":512,"../internals/iterators":518,"../internals/iterators-core":517,"../internals/object-get-prototype-of":539,"../internals/object-set-prototype-of":545,"../internals/redefine":555,"../internals/set-to-string-tag":560,"../internals/well-known-symbol":588}],461:[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":494,"../internals/object-define-property":534,"../internals/path":550,"../internals/well-known-symbol-wrapped":587}],462:[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":479}],463:[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":493,"../internals/is-object":511}],464:[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
- };
- },{}],465:[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":472}],466:[function(_dereq_,module,exports){
- module.exports = typeof window == 'object';
- },{}],467:[function(_dereq_,module,exports){
- var UA = _dereq_('../internals/engine-user-agent');
- module.exports = /MSIE|Trident/.test(UA);
- },{"../internals/engine-user-agent":472}],468:[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":472,"../internals/global":493}],469:[function(_dereq_,module,exports){
- var userAgent = _dereq_('../internals/engine-user-agent');
- module.exports = /(?:ipad|iphone|ipod).*applewebkit/i.test(userAgent);
- },{"../internals/engine-user-agent":472}],470:[function(_dereq_,module,exports){
- var classof = _dereq_('../internals/classof-raw');
- var global = _dereq_('../internals/global');
- module.exports = classof(global.process) == 'process';
- },{"../internals/classof-raw":444,"../internals/global":493}],471:[function(_dereq_,module,exports){
- var userAgent = _dereq_('../internals/engine-user-agent');
- module.exports = /web0s(?!.*chrome)/i.test(userAgent);
- },{"../internals/engine-user-agent":472}],472:[function(_dereq_,module,exports){
- var getBuiltIn = _dereq_('../internals/get-built-in');
- module.exports = getBuiltIn('navigator', 'userAgent') || '';
- },{"../internals/get-built-in":488}],473:[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":472,"../internals/global":493}],474:[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":472}],475:[function(_dereq_,module,exports){
- var path = _dereq_('../internals/path');
- module.exports = function (CONSTRUCTOR) {
- return path[CONSTRUCTOR + 'Prototype'];
- };
- },{"../internals/path":550}],476:[function(_dereq_,module,exports){
- // IE8- don't enum bug keys
- module.exports = [
- 'constructor',
- 'hasOwnProperty',
- 'isPrototypeOf',
- 'propertyIsEnumerable',
- 'toLocaleString',
- 'toString',
- 'valueOf'
- ];
- },{}],477:[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":458,"../internals/fails":479}],478:[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":457,"../internals/function-apply":481,"../internals/function-bind-context":482,"../internals/function-uncurry-this":487,"../internals/global":493,"../internals/has-own-property":494,"../internals/is-callable":506,"../internals/is-forced":509,"../internals/object-get-own-property-descriptor":535,"../internals/path":550}],479:[function(_dereq_,module,exports){
- module.exports = function (exec) {
- try {
- return !!exec();
- } catch (error) {
- return true;
- }
- };
- },{}],480:[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":479}],481:[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":483}],482:[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":423,"../internals/function-bind-native":483,"../internals/function-uncurry-this":487}],483:[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":479}],484:[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":423,"../internals/array-slice":438,"../internals/function-bind-native":483,"../internals/function-uncurry-this":487,"../internals/global":493,"../internals/has-own-property":494,"../internals/is-object":511}],485:[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":483}],486:[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":462,"../internals/has-own-property":494}],487:[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":483}],488:[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":493,"../internals/is-callable":506,"../internals/path":550}],489:[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":445,"../internals/get-method":492,"../internals/iterators":518,"../internals/well-known-symbol":588}],490:[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":423,"../internals/an-object":428,"../internals/function-call":485,"../internals/get-iterator-method":489,"../internals/global":493,"../internals/try-to-string":582}],491:[function(_dereq_,module,exports){
- var getIterator = _dereq_('../internals/get-iterator');
- module.exports = getIterator;
- },{"../internals/get-iterator":490}],492:[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":423}],493:[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 : {})
- },{}],494:[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":487,"../internals/to-object":577}],495:[function(_dereq_,module,exports){
- module.exports = {};
- },{}],496:[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":493}],497:[function(_dereq_,module,exports){
- var getBuiltIn = _dereq_('../internals/get-built-in');
- module.exports = getBuiltIn('document', 'documentElement');
- },{"../internals/get-built-in":488}],498:[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":462,"../internals/document-create-element":463,"../internals/fails":479}],499:[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":444,"../internals/fails":479,"../internals/function-uncurry-this":487,"../internals/global":493}],500:[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":487,"../internals/is-callable":506,"../internals/shared-store":562}],501:[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":457,"../internals/is-object":511}],502:[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":478,"../internals/freezing":480,"../internals/function-uncurry-this":487,"../internals/has-own-property":494,"../internals/hidden-keys":495,"../internals/is-object":511,"../internals/object-define-property":534,"../internals/object-get-own-property-names":537,"../internals/object-get-own-property-names-external":536,"../internals/object-is-extensible":540,"../internals/uid":583}],503:[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":457,"../internals/function-uncurry-this":487,"../internals/global":493,"../internals/has-own-property":494,"../internals/hidden-keys":495,"../internals/is-object":511,"../internals/native-weak-map":526,"../internals/shared-key":561,"../internals/shared-store":562}],504:[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":518,"../internals/well-known-symbol":588}],505:[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":444}],506:[function(_dereq_,module,exports){
- // `IsCallable` abstract operation
- // https://tc39.es/ecma262/#sec-iscallable
- module.exports = function (argument) {
- return typeof argument == 'function';
- };
- },{}],507:[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":445,"../internals/fails":479,"../internals/function-uncurry-this":487,"../internals/get-built-in":488,"../internals/inspect-source":500,"../internals/is-callable":506}],508:[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":494}],509:[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":479,"../internals/is-callable":506}],510:[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":511}],511:[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":506}],512:[function(_dereq_,module,exports){
- module.exports = true;
- },{}],513:[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":444,"../internals/is-object":511,"../internals/well-known-symbol":588}],514:[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":488,"../internals/global":493,"../internals/is-callable":506,"../internals/object-is-prototype-of":541,"../internals/use-symbol-as-uid":584}],515:[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":428,"../internals/function-bind-context":482,"../internals/function-call":485,"../internals/get-iterator":490,"../internals/get-iterator-method":489,"../internals/global":493,"../internals/is-array-iterator-method":504,"../internals/iterator-close":516,"../internals/length-of-array-like":519,"../internals/object-is-prototype-of":541,"../internals/try-to-string":582}],516:[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":428,"../internals/function-call":485,"../internals/get-method":492}],517:[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":479,"../internals/is-callable":506,"../internals/is-pure":512,"../internals/object-create":532,"../internals/object-get-prototype-of":539,"../internals/redefine":555,"../internals/well-known-symbol":588}],518:[function(_dereq_,module,exports){
- arguments[4][495][0].apply(exports,arguments)
- },{"dup":495}],519:[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":576}],520:[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":423,"../internals/an-object":428,"../internals/function-call":485}],521:[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":423,"../internals/an-object":428,"../internals/function-call":485,"../internals/global":493,"../internals/is-callable":506}],522:[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":469,"../internals/engine-is-ios-pebble":468,"../internals/engine-is-node":470,"../internals/engine-is-webos-webkit":471,"../internals/function-bind-context":482,"../internals/global":493,"../internals/object-get-own-property-descriptor":535,"../internals/task":572}],523:[function(_dereq_,module,exports){
- var global = _dereq_('../internals/global');
- module.exports = global.Promise;
- },{"../internals/global":493}],524:[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":473,"../internals/fails":479}],525:[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":479,"../internals/is-pure":512,"../internals/well-known-symbol":588}],526:[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":493,"../internals/inspect-source":500,"../internals/is-callable":506}],527:[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":423}],528:[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":581}],529:[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":493,"../internals/is-regexp":513}],530:[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":479,"../internals/function-uncurry-this":487,"../internals/global":493,"../internals/string-trim":571,"../internals/to-string":581,"../internals/whitespaces":589}],531:[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":462,"../internals/fails":479,"../internals/function-call":485,"../internals/function-uncurry-this":487,"../internals/indexed-object":499,"../internals/object-get-own-property-symbols":538,"../internals/object-keys":543,"../internals/object-property-is-enumerable":544,"../internals/to-object":577}],532:[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":428,"../internals/document-create-element":463,"../internals/enum-bug-keys":476,"../internals/hidden-keys":495,"../internals/html":497,"../internals/object-define-properties":533,"../internals/shared-key":561}],533:[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":428,"../internals/descriptors":462,"../internals/object-define-property":534,"../internals/object-keys":543,"../internals/to-indexed-object":574,"../internals/v8-prototype-define-bug":585}],534:[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":428,"../internals/descriptors":462,"../internals/global":493,"../internals/ie8-dom-define":498,"../internals/to-property-key":579,"../internals/v8-prototype-define-bug":585}],535:[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":458,"../internals/descriptors":462,"../internals/function-call":485,"../internals/has-own-property":494,"../internals/ie8-dom-define":498,"../internals/object-property-is-enumerable":544,"../internals/to-indexed-object":574,"../internals/to-property-key":579}],536:[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":437,"../internals/classof-raw":444,"../internals/object-get-own-property-names":537,"../internals/to-indexed-object":574}],537:[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":476,"../internals/object-keys-internal":542}],538:[function(_dereq_,module,exports){
- // eslint-disable-next-line es/no-object-getownpropertysymbols -- safe
- exports.f = Object.getOwnPropertySymbols;
- },{}],539:[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":455,"../internals/global":493,"../internals/has-own-property":494,"../internals/is-callable":506,"../internals/shared-key":561,"../internals/to-object":577}],540:[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":429,"../internals/classof-raw":444,"../internals/fails":479,"../internals/is-object":511}],541:[function(_dereq_,module,exports){
- var uncurryThis = _dereq_('../internals/function-uncurry-this');
- module.exports = uncurryThis({}.isPrototypeOf);
- },{"../internals/function-uncurry-this":487}],542:[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":432,"../internals/function-uncurry-this":487,"../internals/has-own-property":494,"../internals/hidden-keys":495,"../internals/to-indexed-object":574}],543:[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":476,"../internals/object-keys-internal":542}],544:[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;
- },{}],545:[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":425,"../internals/an-object":428,"../internals/function-uncurry-this":487}],546:[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":462,"../internals/function-uncurry-this":487,"../internals/object-keys":543,"../internals/object-property-is-enumerable":544,"../internals/to-indexed-object":574}],547:[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":445,"../internals/to-string-tag-support":580}],548:[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":485,"../internals/global":493,"../internals/is-callable":506,"../internals/is-object":511}],549:[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":428,"../internals/function-uncurry-this":487,"../internals/get-built-in":488,"../internals/object-get-own-property-names":537,"../internals/object-get-own-property-symbols":538}],550:[function(_dereq_,module,exports){
- arguments[4][495][0].apply(exports,arguments)
- },{"dup":495}],551:[function(_dereq_,module,exports){
- module.exports = function (exec) {
- try {
- return { error: false, value: exec() };
- } catch (error) {
- return { error: true, value: error };
- }
- };
- },{}],552:[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":428,"../internals/is-object":511,"../internals/new-promise-capability":527}],553:[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;
- },{}],554:[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":555}],555:[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":457}],556:[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":493}],557:[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;
- };
- },{}],558:[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":493}],559:[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":462,"../internals/get-built-in":488,"../internals/object-define-property":534,"../internals/well-known-symbol":588}],560:[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":457,"../internals/has-own-property":494,"../internals/object-define-property":534,"../internals/object-to-string":547,"../internals/to-string-tag-support":580,"../internals/well-known-symbol":588}],561:[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":563,"../internals/uid":583}],562:[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":493,"../internals/set-global":558}],563:[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":512,"../internals/shared-store":562}],564:[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":424,"../internals/an-object":428,"../internals/well-known-symbol":588}],565:[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":487,"../internals/require-object-coercible":556,"../internals/to-integer-or-infinity":575,"../internals/to-string":581}],566:[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":472}],567:[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":487,"../internals/require-object-coercible":556,"../internals/string-repeat":569,"../internals/to-length":576,"../internals/to-string":581}],568:[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":487,"../internals/global":493}],569:[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":493,"../internals/require-object-coercible":556,"../internals/to-integer-or-infinity":575,"../internals/to-string":581}],570:[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":479,"../internals/function-name":486,"../internals/whitespaces":589}],571:[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":487,"../internals/require-object-coercible":556,"../internals/to-string":581,"../internals/whitespaces":589}],572:[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":438,"../internals/document-create-element":463,"../internals/engine-is-ios":469,"../internals/engine-is-node":470,"../internals/fails":479,"../internals/function-apply":481,"../internals/function-bind-context":482,"../internals/global":493,"../internals/has-own-property":494,"../internals/html":497,"../internals/is-callable":506}],573:[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":575}],574:[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":499,"../internals/require-object-coercible":556}],575:[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);
- };
- },{}],576:[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":575}],577:[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":493,"../internals/require-object-coercible":556}],578:[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":485,"../internals/get-method":492,"../internals/global":493,"../internals/is-object":511,"../internals/is-symbol":514,"../internals/ordinary-to-primitive":548,"../internals/well-known-symbol":588}],579:[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":514,"../internals/to-primitive":578}],580:[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":588}],581:[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":445,"../internals/global":493}],582:[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":493}],583:[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":487}],584:[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":524}],585:[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":462,"../internals/fails":479}],586:[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":493}],587:[function(_dereq_,module,exports){
- var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
- exports.f = wellKnownSymbol;
- },{"../internals/well-known-symbol":588}],588:[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":493,"../internals/has-own-property":494,"../internals/native-symbol":524,"../internals/shared":563,"../internals/uid":583,"../internals/use-symbol-as-uid":584}],589:[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';
- },{}],590:[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":446,"../internals/copy-constructor-properties":453,"../internals/create-non-enumerable-property":457,"../internals/create-property-descriptor":458,"../internals/error-stack-installable":477,"../internals/export":478,"../internals/global":493,"../internals/install-error-cause":501,"../internals/iterate":515,"../internals/normalize-string-argument":528,"../internals/object-create":532,"../internals/object-get-prototype-of":539,"../internals/object-is-prototype-of":541,"../internals/object-set-prototype-of":545,"../internals/well-known-symbol":588}],591:[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":434,"../internals/array-species-create":441,"../internals/create-property":459,"../internals/engine-v8-version":473,"../internals/export":478,"../internals/fails":479,"../internals/global":493,"../internals/is-array":505,"../internals/is-object":511,"../internals/length-of-array-like":519,"../internals/to-object":577,"../internals/well-known-symbol":588}],592:[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":433,"../internals/array-method-is-strict":435,"../internals/export":478}],593:[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":433,"../internals/array-method-has-species-support":434,"../internals/export":478}],594:[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":426,"../internals/array-iteration":433,"../internals/export":478}],595:[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":430,"../internals/export":478}],596:[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":431,"../internals/check-correctness-of-iteration":443,"../internals/export":478}],597:[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":426,"../internals/array-includes":432,"../internals/export":478}],598:[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":432,"../internals/array-method-is-strict":435,"../internals/export":478,"../internals/function-uncurry-this":487}],599:[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":478,"../internals/is-array":505}],600:[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":426,"../internals/define-iterator":460,"../internals/descriptors":462,"../internals/internal-state":503,"../internals/is-pure":512,"../internals/iterators":518,"../internals/object-define-property":534,"../internals/to-indexed-object":574}],601:[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":433,"../internals/array-method-has-species-support":434,"../internals/export":478}],602:[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":435,"../internals/array-reduce":436,"../internals/engine-is-node":470,"../internals/engine-v8-version":473,"../internals/export":478}],603:[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":434,"../internals/array-slice":438,"../internals/create-property":459,"../internals/export":478,"../internals/global":493,"../internals/is-array":505,"../internals/is-constructor":507,"../internals/is-object":511,"../internals/length-of-array-like":519,"../internals/to-absolute-index":573,"../internals/to-indexed-object":574,"../internals/well-known-symbol":588}],604:[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":423,"../internals/array-method-is-strict":435,"../internals/array-sort":439,"../internals/engine-ff-version":465,"../internals/engine-is-ie-or-edge":467,"../internals/engine-v8-version":473,"../internals/engine-webkit-version":474,"../internals/export":478,"../internals/fails":479,"../internals/function-uncurry-this":487,"../internals/length-of-array-like":519,"../internals/to-object":577,"../internals/to-string":581}],605:[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":434,"../internals/array-species-create":441,"../internals/create-property":459,"../internals/export":478,"../internals/global":493,"../internals/length-of-array-like":519,"../internals/to-absolute-index":573,"../internals/to-integer-or-infinity":575,"../internals/to-object":577}],606:[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":478,"../internals/function-bind":484}],607:[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":478,"../internals/fails":479,"../internals/function-apply":481,"../internals/function-uncurry-this":487,"../internals/get-built-in":488,"../internals/global":493}],608:[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":493,"../internals/set-to-string-tag":560}],609:[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":452,"../internals/collection-strong":450}],610:[function(_dereq_,module,exports){
- // empty
- },{}],611:[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":478,"../internals/is-integral-number":510}],612:[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":478}],613:[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":462,"../internals/export":478,"../internals/object-create":532}],614:[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":462,"../internals/export":478,"../internals/object-define-properties":533}],615:[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":462,"../internals/export":478,"../internals/object-define-property":534}],616:[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":478,"../internals/object-to-array":546}],617:[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":478,"../internals/fails":479,"../internals/freezing":480,"../internals/internal-metadata":502,"../internals/is-object":511}],618:[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":462,"../internals/export":478,"../internals/fails":479,"../internals/object-get-own-property-descriptor":535,"../internals/to-indexed-object":574}],619:[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":459,"../internals/descriptors":462,"../internals/export":478,"../internals/object-get-own-property-descriptor":535,"../internals/own-keys":549,"../internals/to-indexed-object":574}],620:[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":455,"../internals/export":478,"../internals/fails":479,"../internals/object-get-prototype-of":539,"../internals/to-object":577}],621:[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":478,"../internals/fails":479,"../internals/object-keys":543,"../internals/to-object":577}],622:[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":478,"../internals/object-set-prototype-of":545}],623:[function(_dereq_,module,exports){
- arguments[4][610][0].apply(exports,arguments)
- },{"dup":610}],624:[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":478,"../internals/object-to-array":546}],625:[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":478,"../internals/number-parse-int":530}],626:[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":423,"../internals/export":478,"../internals/function-call":485,"../internals/iterate":515,"../internals/new-promise-capability":527,"../internals/perform":551}],627:[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":423,"../internals/export":478,"../internals/function-call":485,"../internals/get-built-in":488,"../internals/iterate":515,"../internals/new-promise-capability":527,"../internals/perform":551}],628:[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":478,"../internals/fails":479,"../internals/get-built-in":488,"../internals/is-callable":506,"../internals/is-pure":512,"../internals/native-promise-constructor":523,"../internals/promise-resolve":552,"../internals/redefine":555,"../internals/species-constructor":564}],629:[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":423,"../internals/an-instance":427,"../internals/check-correctness-of-iteration":443,"../internals/engine-is-browser":466,"../internals/engine-is-node":470,"../internals/engine-v8-version":473,"../internals/export":478,"../internals/function-call":485,"../internals/get-built-in":488,"../internals/global":493,"../internals/host-report-errors":496,"../internals/inspect-source":500,"../internals/internal-state":503,"../internals/is-callable":506,"../internals/is-forced":509,"../internals/is-object":511,"../internals/is-pure":512,"../internals/iterate":515,"../internals/microtask":522,"../internals/native-promise-constructor":523,"../internals/new-promise-capability":527,"../internals/object-set-prototype-of":545,"../internals/perform":551,"../internals/promise-resolve":552,"../internals/queue":553,"../internals/redefine":555,"../internals/redefine-all":554,"../internals/set-species":559,"../internals/set-to-string-tag":560,"../internals/species-constructor":564,"../internals/task":572,"../internals/well-known-symbol":588}],630:[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":424,"../internals/an-object":428,"../internals/export":478,"../internals/fails":479,"../internals/function-apply":481,"../internals/function-bind":484,"../internals/get-built-in":488,"../internals/is-object":511,"../internals/object-create":532}],631:[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":428,"../internals/export":478,"../internals/function-call":485,"../internals/is-data-descriptor":508,"../internals/is-object":511,"../internals/object-get-own-property-descriptor":535,"../internals/object-get-prototype-of":539}],632:[function(_dereq_,module,exports){
- arguments[4][610][0].apply(exports,arguments)
- },{"dup":610}],633:[function(_dereq_,module,exports){
- arguments[4][610][0].apply(exports,arguments)
- },{"dup":610}],634:[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":452,"../internals/collection-strong":450}],635:[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":454,"../internals/export":478,"../internals/function-uncurry-this":487,"../internals/not-a-regexp":529,"../internals/require-object-coercible":556,"../internals/to-string":581}],636:[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":460,"../internals/internal-state":503,"../internals/string-multibyte":565,"../internals/to-string":581}],637:[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":478,"../internals/string-pad":567,"../internals/string-pad-webkit-bug":566}],638:[function(_dereq_,module,exports){
- arguments[4][610][0].apply(exports,arguments)
- },{"dup":610}],639:[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":454,"../internals/export":478,"../internals/function-uncurry-this":487,"../internals/is-pure":512,"../internals/not-a-regexp":529,"../internals/object-get-own-property-descriptor":535,"../internals/require-object-coercible":556,"../internals/to-length":576,"../internals/to-string":581}],640:[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":478,"../internals/string-trim":571,"../internals/string-trim-forced":570}],641:[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":461}],642:[function(_dereq_,module,exports){
- arguments[4][610][0].apply(exports,arguments)
- },{"dup":610}],643:[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":461}],644:[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":461}],645:[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":461}],646:[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":428,"../internals/array-iteration":433,"../internals/array-slice":438,"../internals/create-property-descriptor":458,"../internals/define-well-known-symbol":461,"../internals/descriptors":462,"../internals/export":478,"../internals/fails":479,"../internals/function-apply":481,"../internals/function-call":485,"../internals/function-uncurry-this":487,"../internals/get-built-in":488,"../internals/global":493,"../internals/has-own-property":494,"../internals/hidden-keys":495,"../internals/internal-state":503,"../internals/is-array":505,"../internals/is-callable":506,"../internals/is-object":511,"../internals/is-pure":512,"../internals/is-symbol":514,"../internals/native-symbol":524,"../internals/object-create":532,"../internals/object-define-properties":533,"../internals/object-define-property":534,"../internals/object-get-own-property-descriptor":535,"../internals/object-get-own-property-names":537,"../internals/object-get-own-property-names-external":536,"../internals/object-get-own-property-symbols":538,"../internals/object-is-prototype-of":541,"../internals/object-keys":543,"../internals/object-property-is-enumerable":544,"../internals/redefine":555,"../internals/set-to-string-tag":560,"../internals/shared":563,"../internals/shared-key":561,"../internals/to-indexed-object":574,"../internals/to-object":577,"../internals/to-property-key":579,"../internals/to-string":581,"../internals/uid":583,"../internals/well-known-symbol":588,"../internals/well-known-symbol-wrapped":587}],647:[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":461}],648:[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":461}],649:[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":461}],650:[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":461}],651:[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":461}],652:[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":461}],653:[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":461}],654:[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":461}],655:[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":461}],656:[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":452,"../internals/collection-weak":451,"../internals/function-uncurry-this":487,"../internals/global":493,"../internals/internal-metadata":502,"../internals/internal-state":503,"../internals/is-object":511,"../internals/native-weak-map":526,"../internals/object-is-extensible":540,"../internals/redefine-all":554}],657:[function(_dereq_,module,exports){
- // TODO: Remove from `core-js@4`
- _dereq_('../modules/es.aggregate-error');
- },{"../modules/es.aggregate-error":590}],658:[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":447,"../internals/export":478,"../internals/is-pure":512}],659:[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":478,"../internals/is-pure":512,"../internals/map-emplace":520}],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.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":428,"../internals/export":478,"../internals/function-bind-context":482,"../internals/get-map-iterator":491,"../internals/is-pure":512,"../internals/iterate":515}],661:[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":423,"../internals/an-object":428,"../internals/export":478,"../internals/function-bind-context":482,"../internals/function-call":485,"../internals/get-built-in":488,"../internals/get-map-iterator":491,"../internals/is-pure":512,"../internals/iterate":515,"../internals/species-constructor":564}],662:[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":428,"../internals/export":478,"../internals/function-bind-context":482,"../internals/get-map-iterator":491,"../internals/is-pure":512,"../internals/iterate":515}],663:[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":428,"../internals/export":478,"../internals/function-bind-context":482,"../internals/get-map-iterator":491,"../internals/is-pure":512,"../internals/iterate":515}],664:[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":448,"../internals/export":478}],665:[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":423,"../internals/export":478,"../internals/function-call":485,"../internals/function-uncurry-this":487,"../internals/get-iterator":490,"../internals/iterate":515}],666:[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":428,"../internals/export":478,"../internals/get-map-iterator":491,"../internals/is-pure":512,"../internals/iterate":515,"../internals/same-value-zero":557}],667:[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":423,"../internals/export":478,"../internals/function-call":485,"../internals/iterate":515}],668:[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":428,"../internals/export":478,"../internals/get-map-iterator":491,"../internals/is-pure":512,"../internals/iterate":515}],669:[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":423,"../internals/an-object":428,"../internals/export":478,"../internals/function-bind-context":482,"../internals/function-call":485,"../internals/get-built-in":488,"../internals/get-map-iterator":491,"../internals/is-pure":512,"../internals/iterate":515,"../internals/species-constructor":564}],670:[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":423,"../internals/an-object":428,"../internals/export":478,"../internals/function-bind-context":482,"../internals/function-call":485,"../internals/get-built-in":488,"../internals/get-map-iterator":491,"../internals/is-pure":512,"../internals/iterate":515,"../internals/species-constructor":564}],671:[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":423,"../internals/an-object":428,"../internals/export":478,"../internals/is-pure":512,"../internals/iterate":515}],672:[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":449,"../internals/export":478}],673:[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":423,"../internals/an-object":428,"../internals/export":478,"../internals/get-map-iterator":491,"../internals/global":493,"../internals/is-pure":512,"../internals/iterate":515}],674:[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":428,"../internals/export":478,"../internals/function-bind-context":482,"../internals/get-map-iterator":491,"../internals/is-pure":512,"../internals/iterate":515}],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.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":478,"../internals/is-pure":512,"../internals/map-upsert":521}],676:[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":423,"../internals/an-object":428,"../internals/export":478,"../internals/function-call":485,"../internals/global":493,"../internals/is-pure":512}],677:[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":478,"../internals/is-pure":512,"../internals/map-upsert":521}],678:[function(_dereq_,module,exports){
- // TODO: Remove from `core-js@4`
- _dereq_('../modules/es.promise.all-settled.js');
- },{"../modules/es.promise.all-settled.js":626}],679:[function(_dereq_,module,exports){
- // TODO: Remove from `core-js@4`
- _dereq_('../modules/es.promise.any');
- },{"../modules/es.promise.any":627}],680:[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":478,"../internals/new-promise-capability":527,"../internals/perform":551}],681:[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":461}],682:[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":461}],683:[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":461}],684:[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":461}],685:[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":461}],686:[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":461}],687:[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":461}],688:[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":445,"../internals/create-non-enumerable-property":457,"../internals/dom-iterables":464,"../internals/global":493,"../internals/iterators":518,"../internals/well-known-symbol":588,"../modules/es.array.iterator":600}],689:[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":438,"../internals/engine-user-agent":472,"../internals/export":478,"../internals/function-apply":481,"../internals/global":493,"../internals/is-callable":506}],690:[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":427,"../internals/an-object":428,"../internals/array-sort":439,"../internals/classof":445,"../internals/create-iterator-constructor":456,"../internals/create-property-descriptor":458,"../internals/export":478,"../internals/function-bind-context":482,"../internals/function-call":485,"../internals/function-uncurry-this":487,"../internals/get-built-in":488,"../internals/get-iterator":490,"../internals/get-iterator-method":489,"../internals/global":493,"../internals/has-own-property":494,"../internals/internal-state":503,"../internals/is-callable":506,"../internals/is-object":511,"../internals/native-url":525,"../internals/object-create":532,"../internals/redefine":555,"../internals/redefine-all":554,"../internals/set-to-string-tag":560,"../internals/to-string":581,"../internals/validate-arguments-length":586,"../internals/well-known-symbol":588,"../modules/es.array.iterator":600}],691:[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":427,"../internals/array-from":431,"../internals/array-slice-simple":437,"../internals/descriptors":462,"../internals/export":478,"../internals/function-bind-context":482,"../internals/function-uncurry-this":487,"../internals/global":493,"../internals/has-own-property":494,"../internals/internal-state":503,"../internals/native-url":525,"../internals/object-assign":531,"../internals/object-define-properties":533,"../internals/redefine":555,"../internals/set-to-string-tag":560,"../internals/string-multibyte":565,"../internals/string-punycode-to-ascii":568,"../internals/to-string":581,"../modules/es.string.iterator":636,"../modules/web.url-search-params":690}],692:[function(_dereq_,module,exports){
- arguments[4][610][0].apply(exports,arguments)
- },{"dup":610}],693:[function(_dereq_,module,exports){
- var parent = _dereq_('../../es/array/from');
- module.exports = parent;
- },{"../../es/array/from":343}],694:[function(_dereq_,module,exports){
- var parent = _dereq_('../../es/array/is-array');
- module.exports = parent;
- },{"../../es/array/is-array":344}],695:[function(_dereq_,module,exports){
- var parent = _dereq_('../../../es/array/virtual/entries');
- module.exports = parent;
- },{"../../../es/array/virtual/entries":346}],696:[function(_dereq_,module,exports){
- var parent = _dereq_('../../../es/array/virtual/for-each');
- module.exports = parent;
- },{"../../../es/array/virtual/for-each":350}],697:[function(_dereq_,module,exports){
- var parent = _dereq_('../../../es/array/virtual/keys');
- module.exports = parent;
- },{"../../../es/array/virtual/keys":353}],698:[function(_dereq_,module,exports){
- var parent = _dereq_('../../../es/array/virtual/values');
- module.exports = parent;
- },{"../../../es/array/virtual/values":359}],699:[function(_dereq_,module,exports){
- var parent = _dereq_('../es/get-iterator-method');
- _dereq_('../modules/web.dom-collections.iterator');
- module.exports = parent;
- },{"../es/get-iterator-method":361,"../modules/web.dom-collections.iterator":688}],700:[function(_dereq_,module,exports){
- var parent = _dereq_('../../es/instance/bind');
- module.exports = parent;
- },{"../../es/instance/bind":362}],701:[function(_dereq_,module,exports){
- var parent = _dereq_('../../es/instance/concat');
- module.exports = parent;
- },{"../../es/instance/concat":363}],702:[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":445,"../../internals/has-own-property":494,"../../internals/object-is-prototype-of":541,"../../modules/web.dom-collections.iterator":688,"../array/virtual/entries":695}],703:[function(_dereq_,module,exports){
- var parent = _dereq_('../../es/instance/every');
- module.exports = parent;
- },{"../../es/instance/every":364}],704:[function(_dereq_,module,exports){
- var parent = _dereq_('../../es/instance/filter');
- module.exports = parent;
- },{"../../es/instance/filter":365}],705:[function(_dereq_,module,exports){
- var parent = _dereq_('../../es/instance/find');
- module.exports = parent;
- },{"../../es/instance/find":366}],706:[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":445,"../../internals/has-own-property":494,"../../internals/object-is-prototype-of":541,"../../modules/web.dom-collections.iterator":688,"../array/virtual/for-each":696}],707:[function(_dereq_,module,exports){
- var parent = _dereq_('../../es/instance/includes');
- module.exports = parent;
- },{"../../es/instance/includes":367}],708:[function(_dereq_,module,exports){
- var parent = _dereq_('../../es/instance/index-of');
- module.exports = parent;
- },{"../../es/instance/index-of":368}],709:[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":445,"../../internals/has-own-property":494,"../../internals/object-is-prototype-of":541,"../../modules/web.dom-collections.iterator":688,"../array/virtual/keys":697}],710:[function(_dereq_,module,exports){
- var parent = _dereq_('../../es/instance/map');
- module.exports = parent;
- },{"../../es/instance/map":369}],711:[function(_dereq_,module,exports){
- var parent = _dereq_('../../es/instance/pad-start');
- module.exports = parent;
- },{"../../es/instance/pad-start":370}],712:[function(_dereq_,module,exports){
- var parent = _dereq_('../../es/instance/reduce');
- module.exports = parent;
- },{"../../es/instance/reduce":371}],713:[function(_dereq_,module,exports){
- var parent = _dereq_('../../es/instance/slice');
- module.exports = parent;
- },{"../../es/instance/slice":372}],714:[function(_dereq_,module,exports){
- var parent = _dereq_('../../es/instance/sort');
- module.exports = parent;
- },{"../../es/instance/sort":373}],715:[function(_dereq_,module,exports){
- var parent = _dereq_('../../es/instance/splice');
- module.exports = parent;
- },{"../../es/instance/splice":374}],716:[function(_dereq_,module,exports){
- var parent = _dereq_('../../es/instance/starts-with');
- module.exports = parent;
- },{"../../es/instance/starts-with":375}],717:[function(_dereq_,module,exports){
- var parent = _dereq_('../../es/instance/trim');
- module.exports = parent;
- },{"../../es/instance/trim":376}],718:[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":445,"../../internals/has-own-property":494,"../../internals/object-is-prototype-of":541,"../../modules/web.dom-collections.iterator":688,"../array/virtual/values":698}],719:[function(_dereq_,module,exports){
- var parent = _dereq_('../../es/json/stringify');
- module.exports = parent;
- },{"../../es/json/stringify":377}],720:[function(_dereq_,module,exports){
- var parent = _dereq_('../../es/map');
- _dereq_('../../modules/web.dom-collections.iterator');
- module.exports = parent;
- },{"../../es/map":378,"../../modules/web.dom-collections.iterator":688}],721:[function(_dereq_,module,exports){
- var parent = _dereq_('../../es/number/is-integer');
- module.exports = parent;
- },{"../../es/number/is-integer":379}],722:[function(_dereq_,module,exports){
- var parent = _dereq_('../../es/number/is-nan');
- module.exports = parent;
- },{"../../es/number/is-nan":380}],723:[function(_dereq_,module,exports){
- var parent = _dereq_('../../es/object/create');
- module.exports = parent;
- },{"../../es/object/create":381}],724:[function(_dereq_,module,exports){
- var parent = _dereq_('../../es/object/define-properties');
- module.exports = parent;
- },{"../../es/object/define-properties":382}],725:[function(_dereq_,module,exports){
- var parent = _dereq_('../../es/object/define-property');
- module.exports = parent;
- },{"../../es/object/define-property":383}],726:[function(_dereq_,module,exports){
- var parent = _dereq_('../../es/object/entries');
- module.exports = parent;
- },{"../../es/object/entries":384}],727:[function(_dereq_,module,exports){
- var parent = _dereq_('../../es/object/freeze');
- module.exports = parent;
- },{"../../es/object/freeze":385}],728:[function(_dereq_,module,exports){
- var parent = _dereq_('../../es/object/get-own-property-descriptor');
- module.exports = parent;
- },{"../../es/object/get-own-property-descriptor":386}],729:[function(_dereq_,module,exports){
- var parent = _dereq_('../../es/object/get-own-property-descriptors');
- module.exports = parent;
- },{"../../es/object/get-own-property-descriptors":387}],730:[function(_dereq_,module,exports){
- var parent = _dereq_('../../es/object/get-own-property-symbols');
- module.exports = parent;
- },{"../../es/object/get-own-property-symbols":388}],731:[function(_dereq_,module,exports){
- var parent = _dereq_('../../es/object/get-prototype-of');
- module.exports = parent;
- },{"../../es/object/get-prototype-of":389}],732:[function(_dereq_,module,exports){
- var parent = _dereq_('../../es/object/keys');
- module.exports = parent;
- },{"../../es/object/keys":390}],733:[function(_dereq_,module,exports){
- var parent = _dereq_('../../es/object/set-prototype-of');
- module.exports = parent;
- },{"../../es/object/set-prototype-of":391}],734:[function(_dereq_,module,exports){
- var parent = _dereq_('../../es/object/values');
- module.exports = parent;
- },{"../../es/object/values":392}],735:[function(_dereq_,module,exports){
- var parent = _dereq_('../es/parse-int');
- module.exports = parent;
- },{"../es/parse-int":393}],736:[function(_dereq_,module,exports){
- var parent = _dereq_('../../es/promise');
- _dereq_('../../modules/web.dom-collections.iterator');
- module.exports = parent;
- },{"../../es/promise":394,"../../modules/web.dom-collections.iterator":688}],737:[function(_dereq_,module,exports){
- var parent = _dereq_('../../es/reflect/construct');
- module.exports = parent;
- },{"../../es/reflect/construct":395}],738:[function(_dereq_,module,exports){
- var parent = _dereq_('../../es/reflect/get');
- module.exports = parent;
- },{"../../es/reflect/get":396}],739:[function(_dereq_,module,exports){
- _dereq_('../modules/web.timers');
- var path = _dereq_('../internals/path');
- module.exports = path.setTimeout;
- },{"../internals/path":550,"../modules/web.timers":689}],740:[function(_dereq_,module,exports){
- var parent = _dereq_('../../es/set');
- _dereq_('../../modules/web.dom-collections.iterator');
- module.exports = parent;
- },{"../../es/set":397,"../../modules/web.dom-collections.iterator":688}],741:[function(_dereq_,module,exports){
- var parent = _dereq_('../../es/symbol');
- _dereq_('../../modules/web.dom-collections.iterator');
- module.exports = parent;
- },{"../../es/symbol":402,"../../modules/web.dom-collections.iterator":688}],742:[function(_dereq_,module,exports){
- var parent = _dereq_('../../es/symbol/iterator');
- _dereq_('../../modules/web.dom-collections.iterator');
- module.exports = parent;
- },{"../../es/symbol/iterator":403,"../../modules/web.dom-collections.iterator":688}],743:[function(_dereq_,module,exports){
- var parent = _dereq_('../../es/symbol/replace');
- module.exports = parent;
- },{"../../es/symbol/replace":404}],744:[function(_dereq_,module,exports){
- var parent = _dereq_('../../web/url');
- module.exports = parent;
- },{"../../web/url":746}],745:[function(_dereq_,module,exports){
- var parent = _dereq_('../../es/weak-map');
- _dereq_('../../modules/web.dom-collections.iterator');
- module.exports = parent;
- },{"../../es/weak-map":405,"../../modules/web.dom-collections.iterator":688}],746:[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":550,"../modules/web.url":691,"../modules/web.url-search-params":690,"../modules/web.url.to-json":692}],747:[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":748,"./core":749,"./enc-base64":750,"./evpkdf":752,"./md5":754}],748:[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":749,"./evpkdf":752}],749:[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}],750:[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":749}],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) {
- return CryptoJS.enc.Utf8;
- }));
- },{"./core":749}],752:[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":749,"./hmac":753,"./sha1":755}],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 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":749}],754:[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":749}],755:[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":749}],756:[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":772,"./elliptic/curve":759,"./elliptic/curves":762,"./elliptic/ec":763,"./elliptic/eddsa":766,"./elliptic/utils":770,"brorand":324}],757:[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":770,"bn.js":771}],758:[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":770,"./base":757,"bn.js":771,"inherits":791}],759:[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":757,"./edwards":758,"./mont":760,"./short":761}],760:[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":770,"./base":757,"bn.js":771,"inherits":791}],761:[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":770,"./base":757,"bn.js":771,"inherits":791}],762:[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":759,"./precomputed/secp256k1":769,"./utils":770,"hash.js":778}],763:[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":762,"../utils":770,"./key":764,"./signature":765,"bn.js":771,"brorand":324,"hmac-drbg":790}],764:[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":770,"bn.js":771}],765:[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":770,"bn.js":771}],766:[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":762,"../utils":770,"./key":767,"./signature":768,"hash.js":778}],767:[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":770}],768:[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":770,"bn.js":771}],769:[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',
- ],
- ],
- },
- };
- },{}],770:[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":771,"minimalistic-assert":793,"minimalistic-crypto-utils":794}],771:[function(_dereq_,module,exports){
- arguments[4][199][0].apply(exports,arguments)
- },{"buffer":undefined,"dup":199}],772:[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"
- }
- },{}],773:[function(_dereq_,module,exports){
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.version = void 0;
- exports.version = "ethers/5.6.0";
- },{}],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.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":773,"./utils":776,"@ethersproject/abstract-signer":189,"@ethersproject/bignumber":198,"@ethersproject/constants":205,"@ethersproject/contracts":208,"@ethersproject/logger":225,"@ethersproject/providers":241,"@ethersproject/wallet":275,"@ethersproject/wordlists":280}],775:[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":774}],776:[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":184,"@ethersproject/address":191,"@ethersproject/base64":193,"@ethersproject/basex":194,"@ethersproject/bytes":201,"@ethersproject/hash":211,"@ethersproject/hdnode":216,"@ethersproject/json-wallets":219,"@ethersproject/keccak256":223,"@ethersproject/logger":225,"@ethersproject/properties":231,"@ethersproject/random":252,"@ethersproject/rlp":255,"@ethersproject/sha2":258,"@ethersproject/signing-key":262,"@ethersproject/solidity":264,"@ethersproject/strings":268,"@ethersproject/transactions":271,"@ethersproject/units":273,"@ethersproject/wallet":275,"@ethersproject/web":278}],777:[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);
- }
- }
- },{}],778:[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":779,"./hash/hmac":780,"./hash/ripemd":781,"./hash/sha":782,"./hash/utils":789}],779:[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":789,"minimalistic-assert":793}],780:[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":789,"minimalistic-assert":793}],781:[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":779,"./utils":789}],782:[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":783,"./sha/224":784,"./sha/256":785,"./sha/384":786,"./sha/512":787}],783:[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":779,"../utils":789,"./common":788}],784:[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":789,"./256":785}],785:[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":779,"../utils":789,"./common":788,"minimalistic-assert":793}],786:[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":789,"./512":787}],787:[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":779,"../utils":789,"minimalistic-assert":793}],788:[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":789}],789:[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":791,"minimalistic-assert":793}],790:[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":778,"minimalistic-assert":793,"minimalistic-crypto-utils":794}],791:[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
- }
- }
- }
- },{}],792:[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":325}],793:[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));
- };
- },{}],794:[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;
- };
- },{}],795:[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; };
- },{}],796:[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);
- }
- }
- },{}],797:[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":798}],798:[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":795,"timers":798}],799:[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":801,"./parse.js":802,"./stringify.js":806,"./v1.js":807,"./v3.js":808,"./v4.js":810,"./v5.js":811,"./validate.js":812,"./version.js":813}],800:[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;
- },{}],801:[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;
- },{}],802:[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":812}],803:[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;
- },{}],804:[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);
- }
- },{}],805:[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;
- },{}],806:[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":812}],807:[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":804,"./stringify.js":806}],808:[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":800,"./v35.js":809}],809:[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":802,"./stringify.js":806}],810:[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":804,"./stringify.js":806}],811:[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":805,"./v35.js":809}],812:[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":803}],813:[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":812}]},{},[25])(25)
- });
|