仲裁视频会议H5

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327
  1. // Axios v1.6.2 Copyright (c) 2023 Matt Zabriskie and contributors
  2. 'use strict';
  3. const FormData$1 = require('form-data');
  4. const url = require('url');
  5. const proxyFromEnv = require('proxy-from-env');
  6. const http = require('http');
  7. const https = require('https');
  8. const util = require('util');
  9. const followRedirects = require('follow-redirects');
  10. const zlib = require('zlib');
  11. const stream = require('stream');
  12. const EventEmitter = require('events');
  13. function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
  14. const FormData__default = /*#__PURE__*/_interopDefaultLegacy(FormData$1);
  15. const url__default = /*#__PURE__*/_interopDefaultLegacy(url);
  16. const http__default = /*#__PURE__*/_interopDefaultLegacy(http);
  17. const https__default = /*#__PURE__*/_interopDefaultLegacy(https);
  18. const util__default = /*#__PURE__*/_interopDefaultLegacy(util);
  19. const followRedirects__default = /*#__PURE__*/_interopDefaultLegacy(followRedirects);
  20. const zlib__default = /*#__PURE__*/_interopDefaultLegacy(zlib);
  21. const stream__default = /*#__PURE__*/_interopDefaultLegacy(stream);
  22. const EventEmitter__default = /*#__PURE__*/_interopDefaultLegacy(EventEmitter);
  23. function bind(fn, thisArg) {
  24. return function wrap() {
  25. return fn.apply(thisArg, arguments);
  26. };
  27. }
  28. // utils is a library of generic helper functions non-specific to axios
  29. const {toString} = Object.prototype;
  30. const {getPrototypeOf} = Object;
  31. const kindOf = (cache => thing => {
  32. const str = toString.call(thing);
  33. return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
  34. })(Object.create(null));
  35. const kindOfTest = (type) => {
  36. type = type.toLowerCase();
  37. return (thing) => kindOf(thing) === type
  38. };
  39. const typeOfTest = type => thing => typeof thing === type;
  40. /**
  41. * Determine if a value is an Array
  42. *
  43. * @param {Object} val The value to test
  44. *
  45. * @returns {boolean} True if value is an Array, otherwise false
  46. */
  47. const {isArray} = Array;
  48. /**
  49. * Determine if a value is undefined
  50. *
  51. * @param {*} val The value to test
  52. *
  53. * @returns {boolean} True if the value is undefined, otherwise false
  54. */
  55. const isUndefined = typeOfTest('undefined');
  56. /**
  57. * Determine if a value is a Buffer
  58. *
  59. * @param {*} val The value to test
  60. *
  61. * @returns {boolean} True if value is a Buffer, otherwise false
  62. */
  63. function isBuffer(val) {
  64. return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)
  65. && isFunction(val.constructor.isBuffer) && val.constructor.isBuffer(val);
  66. }
  67. /**
  68. * Determine if a value is an ArrayBuffer
  69. *
  70. * @param {*} val The value to test
  71. *
  72. * @returns {boolean} True if value is an ArrayBuffer, otherwise false
  73. */
  74. const isArrayBuffer = kindOfTest('ArrayBuffer');
  75. /**
  76. * Determine if a value is a view on an ArrayBuffer
  77. *
  78. * @param {*} val The value to test
  79. *
  80. * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
  81. */
  82. function isArrayBufferView(val) {
  83. let result;
  84. if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
  85. result = ArrayBuffer.isView(val);
  86. } else {
  87. result = (val) && (val.buffer) && (isArrayBuffer(val.buffer));
  88. }
  89. return result;
  90. }
  91. /**
  92. * Determine if a value is a String
  93. *
  94. * @param {*} val The value to test
  95. *
  96. * @returns {boolean} True if value is a String, otherwise false
  97. */
  98. const isString = typeOfTest('string');
  99. /**
  100. * Determine if a value is a Function
  101. *
  102. * @param {*} val The value to test
  103. * @returns {boolean} True if value is a Function, otherwise false
  104. */
  105. const isFunction = typeOfTest('function');
  106. /**
  107. * Determine if a value is a Number
  108. *
  109. * @param {*} val The value to test
  110. *
  111. * @returns {boolean} True if value is a Number, otherwise false
  112. */
  113. const isNumber = typeOfTest('number');
  114. /**
  115. * Determine if a value is an Object
  116. *
  117. * @param {*} thing The value to test
  118. *
  119. * @returns {boolean} True if value is an Object, otherwise false
  120. */
  121. const isObject = (thing) => thing !== null && typeof thing === 'object';
  122. /**
  123. * Determine if a value is a Boolean
  124. *
  125. * @param {*} thing The value to test
  126. * @returns {boolean} True if value is a Boolean, otherwise false
  127. */
  128. const isBoolean = thing => thing === true || thing === false;
  129. /**
  130. * Determine if a value is a plain Object
  131. *
  132. * @param {*} val The value to test
  133. *
  134. * @returns {boolean} True if value is a plain Object, otherwise false
  135. */
  136. const isPlainObject = (val) => {
  137. if (kindOf(val) !== 'object') {
  138. return false;
  139. }
  140. const prototype = getPrototypeOf(val);
  141. return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in val) && !(Symbol.iterator in val);
  142. };
  143. /**
  144. * Determine if a value is a Date
  145. *
  146. * @param {*} val The value to test
  147. *
  148. * @returns {boolean} True if value is a Date, otherwise false
  149. */
  150. const isDate = kindOfTest('Date');
  151. /**
  152. * Determine if a value is a File
  153. *
  154. * @param {*} val The value to test
  155. *
  156. * @returns {boolean} True if value is a File, otherwise false
  157. */
  158. const isFile = kindOfTest('File');
  159. /**
  160. * Determine if a value is a Blob
  161. *
  162. * @param {*} val The value to test
  163. *
  164. * @returns {boolean} True if value is a Blob, otherwise false
  165. */
  166. const isBlob = kindOfTest('Blob');
  167. /**
  168. * Determine if a value is a FileList
  169. *
  170. * @param {*} val The value to test
  171. *
  172. * @returns {boolean} True if value is a File, otherwise false
  173. */
  174. const isFileList = kindOfTest('FileList');
  175. /**
  176. * Determine if a value is a Stream
  177. *
  178. * @param {*} val The value to test
  179. *
  180. * @returns {boolean} True if value is a Stream, otherwise false
  181. */
  182. const isStream = (val) => isObject(val) && isFunction(val.pipe);
  183. /**
  184. * Determine if a value is a FormData
  185. *
  186. * @param {*} thing The value to test
  187. *
  188. * @returns {boolean} True if value is an FormData, otherwise false
  189. */
  190. const isFormData = (thing) => {
  191. let kind;
  192. return thing && (
  193. (typeof FormData === 'function' && thing instanceof FormData) || (
  194. isFunction(thing.append) && (
  195. (kind = kindOf(thing)) === 'formdata' ||
  196. // detect form-data instance
  197. (kind === 'object' && isFunction(thing.toString) && thing.toString() === '[object FormData]')
  198. )
  199. )
  200. )
  201. };
  202. /**
  203. * Determine if a value is a URLSearchParams object
  204. *
  205. * @param {*} val The value to test
  206. *
  207. * @returns {boolean} True if value is a URLSearchParams object, otherwise false
  208. */
  209. const isURLSearchParams = kindOfTest('URLSearchParams');
  210. /**
  211. * Trim excess whitespace off the beginning and end of a string
  212. *
  213. * @param {String} str The String to trim
  214. *
  215. * @returns {String} The String freed of excess whitespace
  216. */
  217. const trim = (str) => str.trim ?
  218. str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
  219. /**
  220. * Iterate over an Array or an Object invoking a function for each item.
  221. *
  222. * If `obj` is an Array callback will be called passing
  223. * the value, index, and complete array for each item.
  224. *
  225. * If 'obj' is an Object callback will be called passing
  226. * the value, key, and complete object for each property.
  227. *
  228. * @param {Object|Array} obj The object to iterate
  229. * @param {Function} fn The callback to invoke for each item
  230. *
  231. * @param {Boolean} [allOwnKeys = false]
  232. * @returns {any}
  233. */
  234. function forEach(obj, fn, {allOwnKeys = false} = {}) {
  235. // Don't bother if no value provided
  236. if (obj === null || typeof obj === 'undefined') {
  237. return;
  238. }
  239. let i;
  240. let l;
  241. // Force an array if not already something iterable
  242. if (typeof obj !== 'object') {
  243. /*eslint no-param-reassign:0*/
  244. obj = [obj];
  245. }
  246. if (isArray(obj)) {
  247. // Iterate over array values
  248. for (i = 0, l = obj.length; i < l; i++) {
  249. fn.call(null, obj[i], i, obj);
  250. }
  251. } else {
  252. // Iterate over object keys
  253. const keys = allOwnKeys ? Object.getOwnPropertyNames(obj) : Object.keys(obj);
  254. const len = keys.length;
  255. let key;
  256. for (i = 0; i < len; i++) {
  257. key = keys[i];
  258. fn.call(null, obj[key], key, obj);
  259. }
  260. }
  261. }
  262. function findKey(obj, key) {
  263. key = key.toLowerCase();
  264. const keys = Object.keys(obj);
  265. let i = keys.length;
  266. let _key;
  267. while (i-- > 0) {
  268. _key = keys[i];
  269. if (key === _key.toLowerCase()) {
  270. return _key;
  271. }
  272. }
  273. return null;
  274. }
  275. const _global = (() => {
  276. /*eslint no-undef:0*/
  277. if (typeof globalThis !== "undefined") return globalThis;
  278. return typeof self !== "undefined" ? self : (typeof window !== 'undefined' ? window : global)
  279. })();
  280. const isContextDefined = (context) => !isUndefined(context) && context !== _global;
  281. /**
  282. * Accepts varargs expecting each argument to be an object, then
  283. * immutably merges the properties of each object and returns result.
  284. *
  285. * When multiple objects contain the same key the later object in
  286. * the arguments list will take precedence.
  287. *
  288. * Example:
  289. *
  290. * ```js
  291. * var result = merge({foo: 123}, {foo: 456});
  292. * console.log(result.foo); // outputs 456
  293. * ```
  294. *
  295. * @param {Object} obj1 Object to merge
  296. *
  297. * @returns {Object} Result of all merge properties
  298. */
  299. function merge(/* obj1, obj2, obj3, ... */) {
  300. const {caseless} = isContextDefined(this) && this || {};
  301. const result = {};
  302. const assignValue = (val, key) => {
  303. const targetKey = caseless && findKey(result, key) || key;
  304. if (isPlainObject(result[targetKey]) && isPlainObject(val)) {
  305. result[targetKey] = merge(result[targetKey], val);
  306. } else if (isPlainObject(val)) {
  307. result[targetKey] = merge({}, val);
  308. } else if (isArray(val)) {
  309. result[targetKey] = val.slice();
  310. } else {
  311. result[targetKey] = val;
  312. }
  313. };
  314. for (let i = 0, l = arguments.length; i < l; i++) {
  315. arguments[i] && forEach(arguments[i], assignValue);
  316. }
  317. return result;
  318. }
  319. /**
  320. * Extends object a by mutably adding to it the properties of object b.
  321. *
  322. * @param {Object} a The object to be extended
  323. * @param {Object} b The object to copy properties from
  324. * @param {Object} thisArg The object to bind function to
  325. *
  326. * @param {Boolean} [allOwnKeys]
  327. * @returns {Object} The resulting value of object a
  328. */
  329. const extend = (a, b, thisArg, {allOwnKeys}= {}) => {
  330. forEach(b, (val, key) => {
  331. if (thisArg && isFunction(val)) {
  332. a[key] = bind(val, thisArg);
  333. } else {
  334. a[key] = val;
  335. }
  336. }, {allOwnKeys});
  337. return a;
  338. };
  339. /**
  340. * Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)
  341. *
  342. * @param {string} content with BOM
  343. *
  344. * @returns {string} content value without BOM
  345. */
  346. const stripBOM = (content) => {
  347. if (content.charCodeAt(0) === 0xFEFF) {
  348. content = content.slice(1);
  349. }
  350. return content;
  351. };
  352. /**
  353. * Inherit the prototype methods from one constructor into another
  354. * @param {function} constructor
  355. * @param {function} superConstructor
  356. * @param {object} [props]
  357. * @param {object} [descriptors]
  358. *
  359. * @returns {void}
  360. */
  361. const inherits = (constructor, superConstructor, props, descriptors) => {
  362. constructor.prototype = Object.create(superConstructor.prototype, descriptors);
  363. constructor.prototype.constructor = constructor;
  364. Object.defineProperty(constructor, 'super', {
  365. value: superConstructor.prototype
  366. });
  367. props && Object.assign(constructor.prototype, props);
  368. };
  369. /**
  370. * Resolve object with deep prototype chain to a flat object
  371. * @param {Object} sourceObj source object
  372. * @param {Object} [destObj]
  373. * @param {Function|Boolean} [filter]
  374. * @param {Function} [propFilter]
  375. *
  376. * @returns {Object}
  377. */
  378. const toFlatObject = (sourceObj, destObj, filter, propFilter) => {
  379. let props;
  380. let i;
  381. let prop;
  382. const merged = {};
  383. destObj = destObj || {};
  384. // eslint-disable-next-line no-eq-null,eqeqeq
  385. if (sourceObj == null) return destObj;
  386. do {
  387. props = Object.getOwnPropertyNames(sourceObj);
  388. i = props.length;
  389. while (i-- > 0) {
  390. prop = props[i];
  391. if ((!propFilter || propFilter(prop, sourceObj, destObj)) && !merged[prop]) {
  392. destObj[prop] = sourceObj[prop];
  393. merged[prop] = true;
  394. }
  395. }
  396. sourceObj = filter !== false && getPrototypeOf(sourceObj);
  397. } while (sourceObj && (!filter || filter(sourceObj, destObj)) && sourceObj !== Object.prototype);
  398. return destObj;
  399. };
  400. /**
  401. * Determines whether a string ends with the characters of a specified string
  402. *
  403. * @param {String} str
  404. * @param {String} searchString
  405. * @param {Number} [position= 0]
  406. *
  407. * @returns {boolean}
  408. */
  409. const endsWith = (str, searchString, position) => {
  410. str = String(str);
  411. if (position === undefined || position > str.length) {
  412. position = str.length;
  413. }
  414. position -= searchString.length;
  415. const lastIndex = str.indexOf(searchString, position);
  416. return lastIndex !== -1 && lastIndex === position;
  417. };
  418. /**
  419. * Returns new array from array like object or null if failed
  420. *
  421. * @param {*} [thing]
  422. *
  423. * @returns {?Array}
  424. */
  425. const toArray = (thing) => {
  426. if (!thing) return null;
  427. if (isArray(thing)) return thing;
  428. let i = thing.length;
  429. if (!isNumber(i)) return null;
  430. const arr = new Array(i);
  431. while (i-- > 0) {
  432. arr[i] = thing[i];
  433. }
  434. return arr;
  435. };
  436. /**
  437. * Checking if the Uint8Array exists and if it does, it returns a function that checks if the
  438. * thing passed in is an instance of Uint8Array
  439. *
  440. * @param {TypedArray}
  441. *
  442. * @returns {Array}
  443. */
  444. // eslint-disable-next-line func-names
  445. const isTypedArray = (TypedArray => {
  446. // eslint-disable-next-line func-names
  447. return thing => {
  448. return TypedArray && thing instanceof TypedArray;
  449. };
  450. })(typeof Uint8Array !== 'undefined' && getPrototypeOf(Uint8Array));
  451. /**
  452. * For each entry in the object, call the function with the key and value.
  453. *
  454. * @param {Object<any, any>} obj - The object to iterate over.
  455. * @param {Function} fn - The function to call for each entry.
  456. *
  457. * @returns {void}
  458. */
  459. const forEachEntry = (obj, fn) => {
  460. const generator = obj && obj[Symbol.iterator];
  461. const iterator = generator.call(obj);
  462. let result;
  463. while ((result = iterator.next()) && !result.done) {
  464. const pair = result.value;
  465. fn.call(obj, pair[0], pair[1]);
  466. }
  467. };
  468. /**
  469. * It takes a regular expression and a string, and returns an array of all the matches
  470. *
  471. * @param {string} regExp - The regular expression to match against.
  472. * @param {string} str - The string to search.
  473. *
  474. * @returns {Array<boolean>}
  475. */
  476. const matchAll = (regExp, str) => {
  477. let matches;
  478. const arr = [];
  479. while ((matches = regExp.exec(str)) !== null) {
  480. arr.push(matches);
  481. }
  482. return arr;
  483. };
  484. /* Checking if the kindOfTest function returns true when passed an HTMLFormElement. */
  485. const isHTMLForm = kindOfTest('HTMLFormElement');
  486. const toCamelCase = str => {
  487. return str.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,
  488. function replacer(m, p1, p2) {
  489. return p1.toUpperCase() + p2;
  490. }
  491. );
  492. };
  493. /* Creating a function that will check if an object has a property. */
  494. const hasOwnProperty = (({hasOwnProperty}) => (obj, prop) => hasOwnProperty.call(obj, prop))(Object.prototype);
  495. /**
  496. * Determine if a value is a RegExp object
  497. *
  498. * @param {*} val The value to test
  499. *
  500. * @returns {boolean} True if value is a RegExp object, otherwise false
  501. */
  502. const isRegExp = kindOfTest('RegExp');
  503. const reduceDescriptors = (obj, reducer) => {
  504. const descriptors = Object.getOwnPropertyDescriptors(obj);
  505. const reducedDescriptors = {};
  506. forEach(descriptors, (descriptor, name) => {
  507. let ret;
  508. if ((ret = reducer(descriptor, name, obj)) !== false) {
  509. reducedDescriptors[name] = ret || descriptor;
  510. }
  511. });
  512. Object.defineProperties(obj, reducedDescriptors);
  513. };
  514. /**
  515. * Makes all methods read-only
  516. * @param {Object} obj
  517. */
  518. const freezeMethods = (obj) => {
  519. reduceDescriptors(obj, (descriptor, name) => {
  520. // skip restricted props in strict mode
  521. if (isFunction(obj) && ['arguments', 'caller', 'callee'].indexOf(name) !== -1) {
  522. return false;
  523. }
  524. const value = obj[name];
  525. if (!isFunction(value)) return;
  526. descriptor.enumerable = false;
  527. if ('writable' in descriptor) {
  528. descriptor.writable = false;
  529. return;
  530. }
  531. if (!descriptor.set) {
  532. descriptor.set = () => {
  533. throw Error('Can not rewrite read-only method \'' + name + '\'');
  534. };
  535. }
  536. });
  537. };
  538. const toObjectSet = (arrayOrString, delimiter) => {
  539. const obj = {};
  540. const define = (arr) => {
  541. arr.forEach(value => {
  542. obj[value] = true;
  543. });
  544. };
  545. isArray(arrayOrString) ? define(arrayOrString) : define(String(arrayOrString).split(delimiter));
  546. return obj;
  547. };
  548. const noop = () => {};
  549. const toFiniteNumber = (value, defaultValue) => {
  550. value = +value;
  551. return Number.isFinite(value) ? value : defaultValue;
  552. };
  553. const ALPHA = 'abcdefghijklmnopqrstuvwxyz';
  554. const DIGIT = '0123456789';
  555. const ALPHABET = {
  556. DIGIT,
  557. ALPHA,
  558. ALPHA_DIGIT: ALPHA + ALPHA.toUpperCase() + DIGIT
  559. };
  560. const generateString = (size = 16, alphabet = ALPHABET.ALPHA_DIGIT) => {
  561. let str = '';
  562. const {length} = alphabet;
  563. while (size--) {
  564. str += alphabet[Math.random() * length|0];
  565. }
  566. return str;
  567. };
  568. /**
  569. * If the thing is a FormData object, return true, otherwise return false.
  570. *
  571. * @param {unknown} thing - The thing to check.
  572. *
  573. * @returns {boolean}
  574. */
  575. function isSpecCompliantForm(thing) {
  576. return !!(thing && isFunction(thing.append) && thing[Symbol.toStringTag] === 'FormData' && thing[Symbol.iterator]);
  577. }
  578. const toJSONObject = (obj) => {
  579. const stack = new Array(10);
  580. const visit = (source, i) => {
  581. if (isObject(source)) {
  582. if (stack.indexOf(source) >= 0) {
  583. return;
  584. }
  585. if(!('toJSON' in source)) {
  586. stack[i] = source;
  587. const target = isArray(source) ? [] : {};
  588. forEach(source, (value, key) => {
  589. const reducedValue = visit(value, i + 1);
  590. !isUndefined(reducedValue) && (target[key] = reducedValue);
  591. });
  592. stack[i] = undefined;
  593. return target;
  594. }
  595. }
  596. return source;
  597. };
  598. return visit(obj, 0);
  599. };
  600. const isAsyncFn = kindOfTest('AsyncFunction');
  601. const isThenable = (thing) =>
  602. thing && (isObject(thing) || isFunction(thing)) && isFunction(thing.then) && isFunction(thing.catch);
  603. const utils$1 = {
  604. isArray,
  605. isArrayBuffer,
  606. isBuffer,
  607. isFormData,
  608. isArrayBufferView,
  609. isString,
  610. isNumber,
  611. isBoolean,
  612. isObject,
  613. isPlainObject,
  614. isUndefined,
  615. isDate,
  616. isFile,
  617. isBlob,
  618. isRegExp,
  619. isFunction,
  620. isStream,
  621. isURLSearchParams,
  622. isTypedArray,
  623. isFileList,
  624. forEach,
  625. merge,
  626. extend,
  627. trim,
  628. stripBOM,
  629. inherits,
  630. toFlatObject,
  631. kindOf,
  632. kindOfTest,
  633. endsWith,
  634. toArray,
  635. forEachEntry,
  636. matchAll,
  637. isHTMLForm,
  638. hasOwnProperty,
  639. hasOwnProp: hasOwnProperty, // an alias to avoid ESLint no-prototype-builtins detection
  640. reduceDescriptors,
  641. freezeMethods,
  642. toObjectSet,
  643. toCamelCase,
  644. noop,
  645. toFiniteNumber,
  646. findKey,
  647. global: _global,
  648. isContextDefined,
  649. ALPHABET,
  650. generateString,
  651. isSpecCompliantForm,
  652. toJSONObject,
  653. isAsyncFn,
  654. isThenable
  655. };
  656. /**
  657. * Create an Error with the specified message, config, error code, request and response.
  658. *
  659. * @param {string} message The error message.
  660. * @param {string} [code] The error code (for example, 'ECONNABORTED').
  661. * @param {Object} [config] The config.
  662. * @param {Object} [request] The request.
  663. * @param {Object} [response] The response.
  664. *
  665. * @returns {Error} The created error.
  666. */
  667. function AxiosError(message, code, config, request, response) {
  668. Error.call(this);
  669. if (Error.captureStackTrace) {
  670. Error.captureStackTrace(this, this.constructor);
  671. } else {
  672. this.stack = (new Error()).stack;
  673. }
  674. this.message = message;
  675. this.name = 'AxiosError';
  676. code && (this.code = code);
  677. config && (this.config = config);
  678. request && (this.request = request);
  679. response && (this.response = response);
  680. }
  681. utils$1.inherits(AxiosError, Error, {
  682. toJSON: function toJSON() {
  683. return {
  684. // Standard
  685. message: this.message,
  686. name: this.name,
  687. // Microsoft
  688. description: this.description,
  689. number: this.number,
  690. // Mozilla
  691. fileName: this.fileName,
  692. lineNumber: this.lineNumber,
  693. columnNumber: this.columnNumber,
  694. stack: this.stack,
  695. // Axios
  696. config: utils$1.toJSONObject(this.config),
  697. code: this.code,
  698. status: this.response && this.response.status ? this.response.status : null
  699. };
  700. }
  701. });
  702. const prototype$1 = AxiosError.prototype;
  703. const descriptors = {};
  704. [
  705. 'ERR_BAD_OPTION_VALUE',
  706. 'ERR_BAD_OPTION',
  707. 'ECONNABORTED',
  708. 'ETIMEDOUT',
  709. 'ERR_NETWORK',
  710. 'ERR_FR_TOO_MANY_REDIRECTS',
  711. 'ERR_DEPRECATED',
  712. 'ERR_BAD_RESPONSE',
  713. 'ERR_BAD_REQUEST',
  714. 'ERR_CANCELED',
  715. 'ERR_NOT_SUPPORT',
  716. 'ERR_INVALID_URL'
  717. // eslint-disable-next-line func-names
  718. ].forEach(code => {
  719. descriptors[code] = {value: code};
  720. });
  721. Object.defineProperties(AxiosError, descriptors);
  722. Object.defineProperty(prototype$1, 'isAxiosError', {value: true});
  723. // eslint-disable-next-line func-names
  724. AxiosError.from = (error, code, config, request, response, customProps) => {
  725. const axiosError = Object.create(prototype$1);
  726. utils$1.toFlatObject(error, axiosError, function filter(obj) {
  727. return obj !== Error.prototype;
  728. }, prop => {
  729. return prop !== 'isAxiosError';
  730. });
  731. AxiosError.call(axiosError, error.message, code, config, request, response);
  732. axiosError.cause = error;
  733. axiosError.name = error.name;
  734. customProps && Object.assign(axiosError, customProps);
  735. return axiosError;
  736. };
  737. /**
  738. * Determines if the given thing is a array or js object.
  739. *
  740. * @param {string} thing - The object or array to be visited.
  741. *
  742. * @returns {boolean}
  743. */
  744. function isVisitable(thing) {
  745. return utils$1.isPlainObject(thing) || utils$1.isArray(thing);
  746. }
  747. /**
  748. * It removes the brackets from the end of a string
  749. *
  750. * @param {string} key - The key of the parameter.
  751. *
  752. * @returns {string} the key without the brackets.
  753. */
  754. function removeBrackets(key) {
  755. return utils$1.endsWith(key, '[]') ? key.slice(0, -2) : key;
  756. }
  757. /**
  758. * It takes a path, a key, and a boolean, and returns a string
  759. *
  760. * @param {string} path - The path to the current key.
  761. * @param {string} key - The key of the current object being iterated over.
  762. * @param {string} dots - If true, the key will be rendered with dots instead of brackets.
  763. *
  764. * @returns {string} The path to the current key.
  765. */
  766. function renderKey(path, key, dots) {
  767. if (!path) return key;
  768. return path.concat(key).map(function each(token, i) {
  769. // eslint-disable-next-line no-param-reassign
  770. token = removeBrackets(token);
  771. return !dots && i ? '[' + token + ']' : token;
  772. }).join(dots ? '.' : '');
  773. }
  774. /**
  775. * If the array is an array and none of its elements are visitable, then it's a flat array.
  776. *
  777. * @param {Array<any>} arr - The array to check
  778. *
  779. * @returns {boolean}
  780. */
  781. function isFlatArray(arr) {
  782. return utils$1.isArray(arr) && !arr.some(isVisitable);
  783. }
  784. const predicates = utils$1.toFlatObject(utils$1, {}, null, function filter(prop) {
  785. return /^is[A-Z]/.test(prop);
  786. });
  787. /**
  788. * Convert a data object to FormData
  789. *
  790. * @param {Object} obj
  791. * @param {?Object} [formData]
  792. * @param {?Object} [options]
  793. * @param {Function} [options.visitor]
  794. * @param {Boolean} [options.metaTokens = true]
  795. * @param {Boolean} [options.dots = false]
  796. * @param {?Boolean} [options.indexes = false]
  797. *
  798. * @returns {Object}
  799. **/
  800. /**
  801. * It converts an object into a FormData object
  802. *
  803. * @param {Object<any, any>} obj - The object to convert to form data.
  804. * @param {string} formData - The FormData object to append to.
  805. * @param {Object<string, any>} options
  806. *
  807. * @returns
  808. */
  809. function toFormData(obj, formData, options) {
  810. if (!utils$1.isObject(obj)) {
  811. throw new TypeError('target must be an object');
  812. }
  813. // eslint-disable-next-line no-param-reassign
  814. formData = formData || new (FormData__default["default"] || FormData)();
  815. // eslint-disable-next-line no-param-reassign
  816. options = utils$1.toFlatObject(options, {
  817. metaTokens: true,
  818. dots: false,
  819. indexes: false
  820. }, false, function defined(option, source) {
  821. // eslint-disable-next-line no-eq-null,eqeqeq
  822. return !utils$1.isUndefined(source[option]);
  823. });
  824. const metaTokens = options.metaTokens;
  825. // eslint-disable-next-line no-use-before-define
  826. const visitor = options.visitor || defaultVisitor;
  827. const dots = options.dots;
  828. const indexes = options.indexes;
  829. const _Blob = options.Blob || typeof Blob !== 'undefined' && Blob;
  830. const useBlob = _Blob && utils$1.isSpecCompliantForm(formData);
  831. if (!utils$1.isFunction(visitor)) {
  832. throw new TypeError('visitor must be a function');
  833. }
  834. function convertValue(value) {
  835. if (value === null) return '';
  836. if (utils$1.isDate(value)) {
  837. return value.toISOString();
  838. }
  839. if (!useBlob && utils$1.isBlob(value)) {
  840. throw new AxiosError('Blob is not supported. Use a Buffer instead.');
  841. }
  842. if (utils$1.isArrayBuffer(value) || utils$1.isTypedArray(value)) {
  843. return useBlob && typeof Blob === 'function' ? new Blob([value]) : Buffer.from(value);
  844. }
  845. return value;
  846. }
  847. /**
  848. * Default visitor.
  849. *
  850. * @param {*} value
  851. * @param {String|Number} key
  852. * @param {Array<String|Number>} path
  853. * @this {FormData}
  854. *
  855. * @returns {boolean} return true to visit the each prop of the value recursively
  856. */
  857. function defaultVisitor(value, key, path) {
  858. let arr = value;
  859. if (value && !path && typeof value === 'object') {
  860. if (utils$1.endsWith(key, '{}')) {
  861. // eslint-disable-next-line no-param-reassign
  862. key = metaTokens ? key : key.slice(0, -2);
  863. // eslint-disable-next-line no-param-reassign
  864. value = JSON.stringify(value);
  865. } else if (
  866. (utils$1.isArray(value) && isFlatArray(value)) ||
  867. ((utils$1.isFileList(value) || utils$1.endsWith(key, '[]')) && (arr = utils$1.toArray(value))
  868. )) {
  869. // eslint-disable-next-line no-param-reassign
  870. key = removeBrackets(key);
  871. arr.forEach(function each(el, index) {
  872. !(utils$1.isUndefined(el) || el === null) && formData.append(
  873. // eslint-disable-next-line no-nested-ternary
  874. indexes === true ? renderKey([key], index, dots) : (indexes === null ? key : key + '[]'),
  875. convertValue(el)
  876. );
  877. });
  878. return false;
  879. }
  880. }
  881. if (isVisitable(value)) {
  882. return true;
  883. }
  884. formData.append(renderKey(path, key, dots), convertValue(value));
  885. return false;
  886. }
  887. const stack = [];
  888. const exposedHelpers = Object.assign(predicates, {
  889. defaultVisitor,
  890. convertValue,
  891. isVisitable
  892. });
  893. function build(value, path) {
  894. if (utils$1.isUndefined(value)) return;
  895. if (stack.indexOf(value) !== -1) {
  896. throw Error('Circular reference detected in ' + path.join('.'));
  897. }
  898. stack.push(value);
  899. utils$1.forEach(value, function each(el, key) {
  900. const result = !(utils$1.isUndefined(el) || el === null) && visitor.call(
  901. formData, el, utils$1.isString(key) ? key.trim() : key, path, exposedHelpers
  902. );
  903. if (result === true) {
  904. build(el, path ? path.concat(key) : [key]);
  905. }
  906. });
  907. stack.pop();
  908. }
  909. if (!utils$1.isObject(obj)) {
  910. throw new TypeError('data must be an object');
  911. }
  912. build(obj);
  913. return formData;
  914. }
  915. /**
  916. * It encodes a string by replacing all characters that are not in the unreserved set with
  917. * their percent-encoded equivalents
  918. *
  919. * @param {string} str - The string to encode.
  920. *
  921. * @returns {string} The encoded string.
  922. */
  923. function encode$1(str) {
  924. const charMap = {
  925. '!': '%21',
  926. "'": '%27',
  927. '(': '%28',
  928. ')': '%29',
  929. '~': '%7E',
  930. '%20': '+',
  931. '%00': '\x00'
  932. };
  933. return encodeURIComponent(str).replace(/[!'()~]|%20|%00/g, function replacer(match) {
  934. return charMap[match];
  935. });
  936. }
  937. /**
  938. * It takes a params object and converts it to a FormData object
  939. *
  940. * @param {Object<string, any>} params - The parameters to be converted to a FormData object.
  941. * @param {Object<string, any>} options - The options object passed to the Axios constructor.
  942. *
  943. * @returns {void}
  944. */
  945. function AxiosURLSearchParams(params, options) {
  946. this._pairs = [];
  947. params && toFormData(params, this, options);
  948. }
  949. const prototype = AxiosURLSearchParams.prototype;
  950. prototype.append = function append(name, value) {
  951. this._pairs.push([name, value]);
  952. };
  953. prototype.toString = function toString(encoder) {
  954. const _encode = encoder ? function(value) {
  955. return encoder.call(this, value, encode$1);
  956. } : encode$1;
  957. return this._pairs.map(function each(pair) {
  958. return _encode(pair[0]) + '=' + _encode(pair[1]);
  959. }, '').join('&');
  960. };
  961. /**
  962. * It replaces all instances of the characters `:`, `$`, `,`, `+`, `[`, and `]` with their
  963. * URI encoded counterparts
  964. *
  965. * @param {string} val The value to be encoded.
  966. *
  967. * @returns {string} The encoded value.
  968. */
  969. function encode(val) {
  970. return encodeURIComponent(val).
  971. replace(/%3A/gi, ':').
  972. replace(/%24/g, '$').
  973. replace(/%2C/gi, ',').
  974. replace(/%20/g, '+').
  975. replace(/%5B/gi, '[').
  976. replace(/%5D/gi, ']');
  977. }
  978. /**
  979. * Build a URL by appending params to the end
  980. *
  981. * @param {string} url The base of the url (e.g., http://www.google.com)
  982. * @param {object} [params] The params to be appended
  983. * @param {?object} options
  984. *
  985. * @returns {string} The formatted url
  986. */
  987. function buildURL(url, params, options) {
  988. /*eslint no-param-reassign:0*/
  989. if (!params) {
  990. return url;
  991. }
  992. const _encode = options && options.encode || encode;
  993. const serializeFn = options && options.serialize;
  994. let serializedParams;
  995. if (serializeFn) {
  996. serializedParams = serializeFn(params, options);
  997. } else {
  998. serializedParams = utils$1.isURLSearchParams(params) ?
  999. params.toString() :
  1000. new AxiosURLSearchParams(params, options).toString(_encode);
  1001. }
  1002. if (serializedParams) {
  1003. const hashmarkIndex = url.indexOf("#");
  1004. if (hashmarkIndex !== -1) {
  1005. url = url.slice(0, hashmarkIndex);
  1006. }
  1007. url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
  1008. }
  1009. return url;
  1010. }
  1011. class InterceptorManager {
  1012. constructor() {
  1013. this.handlers = [];
  1014. }
  1015. /**
  1016. * Add a new interceptor to the stack
  1017. *
  1018. * @param {Function} fulfilled The function to handle `then` for a `Promise`
  1019. * @param {Function} rejected The function to handle `reject` for a `Promise`
  1020. *
  1021. * @return {Number} An ID used to remove interceptor later
  1022. */
  1023. use(fulfilled, rejected, options) {
  1024. this.handlers.push({
  1025. fulfilled,
  1026. rejected,
  1027. synchronous: options ? options.synchronous : false,
  1028. runWhen: options ? options.runWhen : null
  1029. });
  1030. return this.handlers.length - 1;
  1031. }
  1032. /**
  1033. * Remove an interceptor from the stack
  1034. *
  1035. * @param {Number} id The ID that was returned by `use`
  1036. *
  1037. * @returns {Boolean} `true` if the interceptor was removed, `false` otherwise
  1038. */
  1039. eject(id) {
  1040. if (this.handlers[id]) {
  1041. this.handlers[id] = null;
  1042. }
  1043. }
  1044. /**
  1045. * Clear all interceptors from the stack
  1046. *
  1047. * @returns {void}
  1048. */
  1049. clear() {
  1050. if (this.handlers) {
  1051. this.handlers = [];
  1052. }
  1053. }
  1054. /**
  1055. * Iterate over all the registered interceptors
  1056. *
  1057. * This method is particularly useful for skipping over any
  1058. * interceptors that may have become `null` calling `eject`.
  1059. *
  1060. * @param {Function} fn The function to call for each interceptor
  1061. *
  1062. * @returns {void}
  1063. */
  1064. forEach(fn) {
  1065. utils$1.forEach(this.handlers, function forEachHandler(h) {
  1066. if (h !== null) {
  1067. fn(h);
  1068. }
  1069. });
  1070. }
  1071. }
  1072. const InterceptorManager$1 = InterceptorManager;
  1073. const transitionalDefaults = {
  1074. silentJSONParsing: true,
  1075. forcedJSONParsing: true,
  1076. clarifyTimeoutError: false
  1077. };
  1078. const URLSearchParams = url__default["default"].URLSearchParams;
  1079. const platform$1 = {
  1080. isNode: true,
  1081. classes: {
  1082. URLSearchParams,
  1083. FormData: FormData__default["default"],
  1084. Blob: typeof Blob !== 'undefined' && Blob || null
  1085. },
  1086. protocols: [ 'http', 'https', 'file', 'data' ]
  1087. };
  1088. const hasBrowserEnv = typeof window !== 'undefined' && typeof document !== 'undefined';
  1089. /**
  1090. * Determine if we're running in a standard browser environment
  1091. *
  1092. * This allows axios to run in a web worker, and react-native.
  1093. * Both environments support XMLHttpRequest, but not fully standard globals.
  1094. *
  1095. * web workers:
  1096. * typeof window -> undefined
  1097. * typeof document -> undefined
  1098. *
  1099. * react-native:
  1100. * navigator.product -> 'ReactNative'
  1101. * nativescript
  1102. * navigator.product -> 'NativeScript' or 'NS'
  1103. *
  1104. * @returns {boolean}
  1105. */
  1106. const hasStandardBrowserEnv = (
  1107. (product) => {
  1108. return hasBrowserEnv && ['ReactNative', 'NativeScript', 'NS'].indexOf(product) < 0
  1109. })(typeof navigator !== 'undefined' && navigator.product);
  1110. /**
  1111. * Determine if we're running in a standard browser webWorker environment
  1112. *
  1113. * Although the `isStandardBrowserEnv` method indicates that
  1114. * `allows axios to run in a web worker`, the WebWorker will still be
  1115. * filtered out due to its judgment standard
  1116. * `typeof window !== 'undefined' && typeof document !== 'undefined'`.
  1117. * This leads to a problem when axios post `FormData` in webWorker
  1118. */
  1119. const hasStandardBrowserWebWorkerEnv = (() => {
  1120. return (
  1121. typeof WorkerGlobalScope !== 'undefined' &&
  1122. // eslint-disable-next-line no-undef
  1123. self instanceof WorkerGlobalScope &&
  1124. typeof self.importScripts === 'function'
  1125. );
  1126. })();
  1127. const utils = /*#__PURE__*/Object.freeze({
  1128. __proto__: null,
  1129. hasBrowserEnv: hasBrowserEnv,
  1130. hasStandardBrowserWebWorkerEnv: hasStandardBrowserWebWorkerEnv,
  1131. hasStandardBrowserEnv: hasStandardBrowserEnv
  1132. });
  1133. const platform = {
  1134. ...utils,
  1135. ...platform$1
  1136. };
  1137. function toURLEncodedForm(data, options) {
  1138. return toFormData(data, new platform.classes.URLSearchParams(), Object.assign({
  1139. visitor: function(value, key, path, helpers) {
  1140. if (platform.isNode && utils$1.isBuffer(value)) {
  1141. this.append(key, value.toString('base64'));
  1142. return false;
  1143. }
  1144. return helpers.defaultVisitor.apply(this, arguments);
  1145. }
  1146. }, options));
  1147. }
  1148. /**
  1149. * It takes a string like `foo[x][y][z]` and returns an array like `['foo', 'x', 'y', 'z']
  1150. *
  1151. * @param {string} name - The name of the property to get.
  1152. *
  1153. * @returns An array of strings.
  1154. */
  1155. function parsePropPath(name) {
  1156. // foo[x][y][z]
  1157. // foo.x.y.z
  1158. // foo-x-y-z
  1159. // foo x y z
  1160. return utils$1.matchAll(/\w+|\[(\w*)]/g, name).map(match => {
  1161. return match[0] === '[]' ? '' : match[1] || match[0];
  1162. });
  1163. }
  1164. /**
  1165. * Convert an array to an object.
  1166. *
  1167. * @param {Array<any>} arr - The array to convert to an object.
  1168. *
  1169. * @returns An object with the same keys and values as the array.
  1170. */
  1171. function arrayToObject(arr) {
  1172. const obj = {};
  1173. const keys = Object.keys(arr);
  1174. let i;
  1175. const len = keys.length;
  1176. let key;
  1177. for (i = 0; i < len; i++) {
  1178. key = keys[i];
  1179. obj[key] = arr[key];
  1180. }
  1181. return obj;
  1182. }
  1183. /**
  1184. * It takes a FormData object and returns a JavaScript object
  1185. *
  1186. * @param {string} formData The FormData object to convert to JSON.
  1187. *
  1188. * @returns {Object<string, any> | null} The converted object.
  1189. */
  1190. function formDataToJSON(formData) {
  1191. function buildPath(path, value, target, index) {
  1192. let name = path[index++];
  1193. const isNumericKey = Number.isFinite(+name);
  1194. const isLast = index >= path.length;
  1195. name = !name && utils$1.isArray(target) ? target.length : name;
  1196. if (isLast) {
  1197. if (utils$1.hasOwnProp(target, name)) {
  1198. target[name] = [target[name], value];
  1199. } else {
  1200. target[name] = value;
  1201. }
  1202. return !isNumericKey;
  1203. }
  1204. if (!target[name] || !utils$1.isObject(target[name])) {
  1205. target[name] = [];
  1206. }
  1207. const result = buildPath(path, value, target[name], index);
  1208. if (result && utils$1.isArray(target[name])) {
  1209. target[name] = arrayToObject(target[name]);
  1210. }
  1211. return !isNumericKey;
  1212. }
  1213. if (utils$1.isFormData(formData) && utils$1.isFunction(formData.entries)) {
  1214. const obj = {};
  1215. utils$1.forEachEntry(formData, (name, value) => {
  1216. buildPath(parsePropPath(name), value, obj, 0);
  1217. });
  1218. return obj;
  1219. }
  1220. return null;
  1221. }
  1222. /**
  1223. * It takes a string, tries to parse it, and if it fails, it returns the stringified version
  1224. * of the input
  1225. *
  1226. * @param {any} rawValue - The value to be stringified.
  1227. * @param {Function} parser - A function that parses a string into a JavaScript object.
  1228. * @param {Function} encoder - A function that takes a value and returns a string.
  1229. *
  1230. * @returns {string} A stringified version of the rawValue.
  1231. */
  1232. function stringifySafely(rawValue, parser, encoder) {
  1233. if (utils$1.isString(rawValue)) {
  1234. try {
  1235. (parser || JSON.parse)(rawValue);
  1236. return utils$1.trim(rawValue);
  1237. } catch (e) {
  1238. if (e.name !== 'SyntaxError') {
  1239. throw e;
  1240. }
  1241. }
  1242. }
  1243. return (encoder || JSON.stringify)(rawValue);
  1244. }
  1245. const defaults = {
  1246. transitional: transitionalDefaults,
  1247. adapter: ['xhr', 'http'],
  1248. transformRequest: [function transformRequest(data, headers) {
  1249. const contentType = headers.getContentType() || '';
  1250. const hasJSONContentType = contentType.indexOf('application/json') > -1;
  1251. const isObjectPayload = utils$1.isObject(data);
  1252. if (isObjectPayload && utils$1.isHTMLForm(data)) {
  1253. data = new FormData(data);
  1254. }
  1255. const isFormData = utils$1.isFormData(data);
  1256. if (isFormData) {
  1257. if (!hasJSONContentType) {
  1258. return data;
  1259. }
  1260. return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
  1261. }
  1262. if (utils$1.isArrayBuffer(data) ||
  1263. utils$1.isBuffer(data) ||
  1264. utils$1.isStream(data) ||
  1265. utils$1.isFile(data) ||
  1266. utils$1.isBlob(data)
  1267. ) {
  1268. return data;
  1269. }
  1270. if (utils$1.isArrayBufferView(data)) {
  1271. return data.buffer;
  1272. }
  1273. if (utils$1.isURLSearchParams(data)) {
  1274. headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
  1275. return data.toString();
  1276. }
  1277. let isFileList;
  1278. if (isObjectPayload) {
  1279. if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
  1280. return toURLEncodedForm(data, this.formSerializer).toString();
  1281. }
  1282. if ((isFileList = utils$1.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
  1283. const _FormData = this.env && this.env.FormData;
  1284. return toFormData(
  1285. isFileList ? {'files[]': data} : data,
  1286. _FormData && new _FormData(),
  1287. this.formSerializer
  1288. );
  1289. }
  1290. }
  1291. if (isObjectPayload || hasJSONContentType ) {
  1292. headers.setContentType('application/json', false);
  1293. return stringifySafely(data);
  1294. }
  1295. return data;
  1296. }],
  1297. transformResponse: [function transformResponse(data) {
  1298. const transitional = this.transitional || defaults.transitional;
  1299. const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
  1300. const JSONRequested = this.responseType === 'json';
  1301. if (data && utils$1.isString(data) && ((forcedJSONParsing && !this.responseType) || JSONRequested)) {
  1302. const silentJSONParsing = transitional && transitional.silentJSONParsing;
  1303. const strictJSONParsing = !silentJSONParsing && JSONRequested;
  1304. try {
  1305. return JSON.parse(data);
  1306. } catch (e) {
  1307. if (strictJSONParsing) {
  1308. if (e.name === 'SyntaxError') {
  1309. throw AxiosError.from(e, AxiosError.ERR_BAD_RESPONSE, this, null, this.response);
  1310. }
  1311. throw e;
  1312. }
  1313. }
  1314. }
  1315. return data;
  1316. }],
  1317. /**
  1318. * A timeout in milliseconds to abort a request. If set to 0 (default) a
  1319. * timeout is not created.
  1320. */
  1321. timeout: 0,
  1322. xsrfCookieName: 'XSRF-TOKEN',
  1323. xsrfHeaderName: 'X-XSRF-TOKEN',
  1324. maxContentLength: -1,
  1325. maxBodyLength: -1,
  1326. env: {
  1327. FormData: platform.classes.FormData,
  1328. Blob: platform.classes.Blob
  1329. },
  1330. validateStatus: function validateStatus(status) {
  1331. return status >= 200 && status < 300;
  1332. },
  1333. headers: {
  1334. common: {
  1335. 'Accept': 'application/json, text/plain, */*',
  1336. 'Content-Type': undefined
  1337. }
  1338. }
  1339. };
  1340. utils$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch'], (method) => {
  1341. defaults.headers[method] = {};
  1342. });
  1343. const defaults$1 = defaults;
  1344. // RawAxiosHeaders whose duplicates are ignored by node
  1345. // c.f. https://nodejs.org/api/http.html#http_message_headers
  1346. const ignoreDuplicateOf = utils$1.toObjectSet([
  1347. 'age', 'authorization', 'content-length', 'content-type', 'etag',
  1348. 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
  1349. 'last-modified', 'location', 'max-forwards', 'proxy-authorization',
  1350. 'referer', 'retry-after', 'user-agent'
  1351. ]);
  1352. /**
  1353. * Parse headers into an object
  1354. *
  1355. * ```
  1356. * Date: Wed, 27 Aug 2014 08:58:49 GMT
  1357. * Content-Type: application/json
  1358. * Connection: keep-alive
  1359. * Transfer-Encoding: chunked
  1360. * ```
  1361. *
  1362. * @param {String} rawHeaders Headers needing to be parsed
  1363. *
  1364. * @returns {Object} Headers parsed into an object
  1365. */
  1366. const parseHeaders = rawHeaders => {
  1367. const parsed = {};
  1368. let key;
  1369. let val;
  1370. let i;
  1371. rawHeaders && rawHeaders.split('\n').forEach(function parser(line) {
  1372. i = line.indexOf(':');
  1373. key = line.substring(0, i).trim().toLowerCase();
  1374. val = line.substring(i + 1).trim();
  1375. if (!key || (parsed[key] && ignoreDuplicateOf[key])) {
  1376. return;
  1377. }
  1378. if (key === 'set-cookie') {
  1379. if (parsed[key]) {
  1380. parsed[key].push(val);
  1381. } else {
  1382. parsed[key] = [val];
  1383. }
  1384. } else {
  1385. parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
  1386. }
  1387. });
  1388. return parsed;
  1389. };
  1390. const $internals = Symbol('internals');
  1391. function normalizeHeader(header) {
  1392. return header && String(header).trim().toLowerCase();
  1393. }
  1394. function normalizeValue(value) {
  1395. if (value === false || value == null) {
  1396. return value;
  1397. }
  1398. return utils$1.isArray(value) ? value.map(normalizeValue) : String(value);
  1399. }
  1400. function parseTokens(str) {
  1401. const tokens = Object.create(null);
  1402. const tokensRE = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;
  1403. let match;
  1404. while ((match = tokensRE.exec(str))) {
  1405. tokens[match[1]] = match[2];
  1406. }
  1407. return tokens;
  1408. }
  1409. const isValidHeaderName = (str) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
  1410. function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
  1411. if (utils$1.isFunction(filter)) {
  1412. return filter.call(this, value, header);
  1413. }
  1414. if (isHeaderNameFilter) {
  1415. value = header;
  1416. }
  1417. if (!utils$1.isString(value)) return;
  1418. if (utils$1.isString(filter)) {
  1419. return value.indexOf(filter) !== -1;
  1420. }
  1421. if (utils$1.isRegExp(filter)) {
  1422. return filter.test(value);
  1423. }
  1424. }
  1425. function formatHeader(header) {
  1426. return header.trim()
  1427. .toLowerCase().replace(/([a-z\d])(\w*)/g, (w, char, str) => {
  1428. return char.toUpperCase() + str;
  1429. });
  1430. }
  1431. function buildAccessors(obj, header) {
  1432. const accessorName = utils$1.toCamelCase(' ' + header);
  1433. ['get', 'set', 'has'].forEach(methodName => {
  1434. Object.defineProperty(obj, methodName + accessorName, {
  1435. value: function(arg1, arg2, arg3) {
  1436. return this[methodName].call(this, header, arg1, arg2, arg3);
  1437. },
  1438. configurable: true
  1439. });
  1440. });
  1441. }
  1442. class AxiosHeaders {
  1443. constructor(headers) {
  1444. headers && this.set(headers);
  1445. }
  1446. set(header, valueOrRewrite, rewrite) {
  1447. const self = this;
  1448. function setHeader(_value, _header, _rewrite) {
  1449. const lHeader = normalizeHeader(_header);
  1450. if (!lHeader) {
  1451. throw new Error('header name must be a non-empty string');
  1452. }
  1453. const key = utils$1.findKey(self, lHeader);
  1454. if(!key || self[key] === undefined || _rewrite === true || (_rewrite === undefined && self[key] !== false)) {
  1455. self[key || _header] = normalizeValue(_value);
  1456. }
  1457. }
  1458. const setHeaders = (headers, _rewrite) =>
  1459. utils$1.forEach(headers, (_value, _header) => setHeader(_value, _header, _rewrite));
  1460. if (utils$1.isPlainObject(header) || header instanceof this.constructor) {
  1461. setHeaders(header, valueOrRewrite);
  1462. } else if(utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
  1463. setHeaders(parseHeaders(header), valueOrRewrite);
  1464. } else {
  1465. header != null && setHeader(valueOrRewrite, header, rewrite);
  1466. }
  1467. return this;
  1468. }
  1469. get(header, parser) {
  1470. header = normalizeHeader(header);
  1471. if (header) {
  1472. const key = utils$1.findKey(this, header);
  1473. if (key) {
  1474. const value = this[key];
  1475. if (!parser) {
  1476. return value;
  1477. }
  1478. if (parser === true) {
  1479. return parseTokens(value);
  1480. }
  1481. if (utils$1.isFunction(parser)) {
  1482. return parser.call(this, value, key);
  1483. }
  1484. if (utils$1.isRegExp(parser)) {
  1485. return parser.exec(value);
  1486. }
  1487. throw new TypeError('parser must be boolean|regexp|function');
  1488. }
  1489. }
  1490. }
  1491. has(header, matcher) {
  1492. header = normalizeHeader(header);
  1493. if (header) {
  1494. const key = utils$1.findKey(this, header);
  1495. return !!(key && this[key] !== undefined && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
  1496. }
  1497. return false;
  1498. }
  1499. delete(header, matcher) {
  1500. const self = this;
  1501. let deleted = false;
  1502. function deleteHeader(_header) {
  1503. _header = normalizeHeader(_header);
  1504. if (_header) {
  1505. const key = utils$1.findKey(self, _header);
  1506. if (key && (!matcher || matchHeaderValue(self, self[key], key, matcher))) {
  1507. delete self[key];
  1508. deleted = true;
  1509. }
  1510. }
  1511. }
  1512. if (utils$1.isArray(header)) {
  1513. header.forEach(deleteHeader);
  1514. } else {
  1515. deleteHeader(header);
  1516. }
  1517. return deleted;
  1518. }
  1519. clear(matcher) {
  1520. const keys = Object.keys(this);
  1521. let i = keys.length;
  1522. let deleted = false;
  1523. while (i--) {
  1524. const key = keys[i];
  1525. if(!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
  1526. delete this[key];
  1527. deleted = true;
  1528. }
  1529. }
  1530. return deleted;
  1531. }
  1532. normalize(format) {
  1533. const self = this;
  1534. const headers = {};
  1535. utils$1.forEach(this, (value, header) => {
  1536. const key = utils$1.findKey(headers, header);
  1537. if (key) {
  1538. self[key] = normalizeValue(value);
  1539. delete self[header];
  1540. return;
  1541. }
  1542. const normalized = format ? formatHeader(header) : String(header).trim();
  1543. if (normalized !== header) {
  1544. delete self[header];
  1545. }
  1546. self[normalized] = normalizeValue(value);
  1547. headers[normalized] = true;
  1548. });
  1549. return this;
  1550. }
  1551. concat(...targets) {
  1552. return this.constructor.concat(this, ...targets);
  1553. }
  1554. toJSON(asStrings) {
  1555. const obj = Object.create(null);
  1556. utils$1.forEach(this, (value, header) => {
  1557. value != null && value !== false && (obj[header] = asStrings && utils$1.isArray(value) ? value.join(', ') : value);
  1558. });
  1559. return obj;
  1560. }
  1561. [Symbol.iterator]() {
  1562. return Object.entries(this.toJSON())[Symbol.iterator]();
  1563. }
  1564. toString() {
  1565. return Object.entries(this.toJSON()).map(([header, value]) => header + ': ' + value).join('\n');
  1566. }
  1567. get [Symbol.toStringTag]() {
  1568. return 'AxiosHeaders';
  1569. }
  1570. static from(thing) {
  1571. return thing instanceof this ? thing : new this(thing);
  1572. }
  1573. static concat(first, ...targets) {
  1574. const computed = new this(first);
  1575. targets.forEach((target) => computed.set(target));
  1576. return computed;
  1577. }
  1578. static accessor(header) {
  1579. const internals = this[$internals] = (this[$internals] = {
  1580. accessors: {}
  1581. });
  1582. const accessors = internals.accessors;
  1583. const prototype = this.prototype;
  1584. function defineAccessor(_header) {
  1585. const lHeader = normalizeHeader(_header);
  1586. if (!accessors[lHeader]) {
  1587. buildAccessors(prototype, _header);
  1588. accessors[lHeader] = true;
  1589. }
  1590. }
  1591. utils$1.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
  1592. return this;
  1593. }
  1594. }
  1595. AxiosHeaders.accessor(['Content-Type', 'Content-Length', 'Accept', 'Accept-Encoding', 'User-Agent', 'Authorization']);
  1596. // reserved names hotfix
  1597. utils$1.reduceDescriptors(AxiosHeaders.prototype, ({value}, key) => {
  1598. let mapped = key[0].toUpperCase() + key.slice(1); // map `set` => `Set`
  1599. return {
  1600. get: () => value,
  1601. set(headerValue) {
  1602. this[mapped] = headerValue;
  1603. }
  1604. }
  1605. });
  1606. utils$1.freezeMethods(AxiosHeaders);
  1607. const AxiosHeaders$1 = AxiosHeaders;
  1608. /**
  1609. * Transform the data for a request or a response
  1610. *
  1611. * @param {Array|Function} fns A single function or Array of functions
  1612. * @param {?Object} response The response object
  1613. *
  1614. * @returns {*} The resulting transformed data
  1615. */
  1616. function transformData(fns, response) {
  1617. const config = this || defaults$1;
  1618. const context = response || config;
  1619. const headers = AxiosHeaders$1.from(context.headers);
  1620. let data = context.data;
  1621. utils$1.forEach(fns, function transform(fn) {
  1622. data = fn.call(config, data, headers.normalize(), response ? response.status : undefined);
  1623. });
  1624. headers.normalize();
  1625. return data;
  1626. }
  1627. function isCancel(value) {
  1628. return !!(value && value.__CANCEL__);
  1629. }
  1630. /**
  1631. * A `CanceledError` is an object that is thrown when an operation is canceled.
  1632. *
  1633. * @param {string=} message The message.
  1634. * @param {Object=} config The config.
  1635. * @param {Object=} request The request.
  1636. *
  1637. * @returns {CanceledError} The created error.
  1638. */
  1639. function CanceledError(message, config, request) {
  1640. // eslint-disable-next-line no-eq-null,eqeqeq
  1641. AxiosError.call(this, message == null ? 'canceled' : message, AxiosError.ERR_CANCELED, config, request);
  1642. this.name = 'CanceledError';
  1643. }
  1644. utils$1.inherits(CanceledError, AxiosError, {
  1645. __CANCEL__: true
  1646. });
  1647. /**
  1648. * Resolve or reject a Promise based on response status.
  1649. *
  1650. * @param {Function} resolve A function that resolves the promise.
  1651. * @param {Function} reject A function that rejects the promise.
  1652. * @param {object} response The response.
  1653. *
  1654. * @returns {object} The response.
  1655. */
  1656. function settle(resolve, reject, response) {
  1657. const validateStatus = response.config.validateStatus;
  1658. if (!response.status || !validateStatus || validateStatus(response.status)) {
  1659. resolve(response);
  1660. } else {
  1661. reject(new AxiosError(
  1662. 'Request failed with status code ' + response.status,
  1663. [AxiosError.ERR_BAD_REQUEST, AxiosError.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
  1664. response.config,
  1665. response.request,
  1666. response
  1667. ));
  1668. }
  1669. }
  1670. /**
  1671. * Determines whether the specified URL is absolute
  1672. *
  1673. * @param {string} url The URL to test
  1674. *
  1675. * @returns {boolean} True if the specified URL is absolute, otherwise false
  1676. */
  1677. function isAbsoluteURL(url) {
  1678. // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
  1679. // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
  1680. // by any combination of letters, digits, plus, period, or hyphen.
  1681. return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
  1682. }
  1683. /**
  1684. * Creates a new URL by combining the specified URLs
  1685. *
  1686. * @param {string} baseURL The base URL
  1687. * @param {string} relativeURL The relative URL
  1688. *
  1689. * @returns {string} The combined URL
  1690. */
  1691. function combineURLs(baseURL, relativeURL) {
  1692. return relativeURL
  1693. ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
  1694. : baseURL;
  1695. }
  1696. /**
  1697. * Creates a new URL by combining the baseURL with the requestedURL,
  1698. * only when the requestedURL is not already an absolute URL.
  1699. * If the requestURL is absolute, this function returns the requestedURL untouched.
  1700. *
  1701. * @param {string} baseURL The base URL
  1702. * @param {string} requestedURL Absolute or relative URL to combine
  1703. *
  1704. * @returns {string} The combined full path
  1705. */
  1706. function buildFullPath(baseURL, requestedURL) {
  1707. if (baseURL && !isAbsoluteURL(requestedURL)) {
  1708. return combineURLs(baseURL, requestedURL);
  1709. }
  1710. return requestedURL;
  1711. }
  1712. const VERSION = "1.6.2";
  1713. function parseProtocol(url) {
  1714. const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
  1715. return match && match[1] || '';
  1716. }
  1717. const DATA_URL_PATTERN = /^(?:([^;]+);)?(?:[^;]+;)?(base64|),([\s\S]*)$/;
  1718. /**
  1719. * Parse data uri to a Buffer or Blob
  1720. *
  1721. * @param {String} uri
  1722. * @param {?Boolean} asBlob
  1723. * @param {?Object} options
  1724. * @param {?Function} options.Blob
  1725. *
  1726. * @returns {Buffer|Blob}
  1727. */
  1728. function fromDataURI(uri, asBlob, options) {
  1729. const _Blob = options && options.Blob || platform.classes.Blob;
  1730. const protocol = parseProtocol(uri);
  1731. if (asBlob === undefined && _Blob) {
  1732. asBlob = true;
  1733. }
  1734. if (protocol === 'data') {
  1735. uri = protocol.length ? uri.slice(protocol.length + 1) : uri;
  1736. const match = DATA_URL_PATTERN.exec(uri);
  1737. if (!match) {
  1738. throw new AxiosError('Invalid URL', AxiosError.ERR_INVALID_URL);
  1739. }
  1740. const mime = match[1];
  1741. const isBase64 = match[2];
  1742. const body = match[3];
  1743. const buffer = Buffer.from(decodeURIComponent(body), isBase64 ? 'base64' : 'utf8');
  1744. if (asBlob) {
  1745. if (!_Blob) {
  1746. throw new AxiosError('Blob is not supported', AxiosError.ERR_NOT_SUPPORT);
  1747. }
  1748. return new _Blob([buffer], {type: mime});
  1749. }
  1750. return buffer;
  1751. }
  1752. throw new AxiosError('Unsupported protocol ' + protocol, AxiosError.ERR_NOT_SUPPORT);
  1753. }
  1754. /**
  1755. * Throttle decorator
  1756. * @param {Function} fn
  1757. * @param {Number} freq
  1758. * @return {Function}
  1759. */
  1760. function throttle(fn, freq) {
  1761. let timestamp = 0;
  1762. const threshold = 1000 / freq;
  1763. let timer = null;
  1764. return function throttled(force, args) {
  1765. const now = Date.now();
  1766. if (force || now - timestamp > threshold) {
  1767. if (timer) {
  1768. clearTimeout(timer);
  1769. timer = null;
  1770. }
  1771. timestamp = now;
  1772. return fn.apply(null, args);
  1773. }
  1774. if (!timer) {
  1775. timer = setTimeout(() => {
  1776. timer = null;
  1777. timestamp = Date.now();
  1778. return fn.apply(null, args);
  1779. }, threshold - (now - timestamp));
  1780. }
  1781. };
  1782. }
  1783. /**
  1784. * Calculate data maxRate
  1785. * @param {Number} [samplesCount= 10]
  1786. * @param {Number} [min= 1000]
  1787. * @returns {Function}
  1788. */
  1789. function speedometer(samplesCount, min) {
  1790. samplesCount = samplesCount || 10;
  1791. const bytes = new Array(samplesCount);
  1792. const timestamps = new Array(samplesCount);
  1793. let head = 0;
  1794. let tail = 0;
  1795. let firstSampleTS;
  1796. min = min !== undefined ? min : 1000;
  1797. return function push(chunkLength) {
  1798. const now = Date.now();
  1799. const startedAt = timestamps[tail];
  1800. if (!firstSampleTS) {
  1801. firstSampleTS = now;
  1802. }
  1803. bytes[head] = chunkLength;
  1804. timestamps[head] = now;
  1805. let i = tail;
  1806. let bytesCount = 0;
  1807. while (i !== head) {
  1808. bytesCount += bytes[i++];
  1809. i = i % samplesCount;
  1810. }
  1811. head = (head + 1) % samplesCount;
  1812. if (head === tail) {
  1813. tail = (tail + 1) % samplesCount;
  1814. }
  1815. if (now - firstSampleTS < min) {
  1816. return;
  1817. }
  1818. const passed = startedAt && now - startedAt;
  1819. return passed ? Math.round(bytesCount * 1000 / passed) : undefined;
  1820. };
  1821. }
  1822. const kInternals = Symbol('internals');
  1823. class AxiosTransformStream extends stream__default["default"].Transform{
  1824. constructor(options) {
  1825. options = utils$1.toFlatObject(options, {
  1826. maxRate: 0,
  1827. chunkSize: 64 * 1024,
  1828. minChunkSize: 100,
  1829. timeWindow: 500,
  1830. ticksRate: 2,
  1831. samplesCount: 15
  1832. }, null, (prop, source) => {
  1833. return !utils$1.isUndefined(source[prop]);
  1834. });
  1835. super({
  1836. readableHighWaterMark: options.chunkSize
  1837. });
  1838. const self = this;
  1839. const internals = this[kInternals] = {
  1840. length: options.length,
  1841. timeWindow: options.timeWindow,
  1842. ticksRate: options.ticksRate,
  1843. chunkSize: options.chunkSize,
  1844. maxRate: options.maxRate,
  1845. minChunkSize: options.minChunkSize,
  1846. bytesSeen: 0,
  1847. isCaptured: false,
  1848. notifiedBytesLoaded: 0,
  1849. ts: Date.now(),
  1850. bytes: 0,
  1851. onReadCallback: null
  1852. };
  1853. const _speedometer = speedometer(internals.ticksRate * options.samplesCount, internals.timeWindow);
  1854. this.on('newListener', event => {
  1855. if (event === 'progress') {
  1856. if (!internals.isCaptured) {
  1857. internals.isCaptured = true;
  1858. }
  1859. }
  1860. });
  1861. let bytesNotified = 0;
  1862. internals.updateProgress = throttle(function throttledHandler() {
  1863. const totalBytes = internals.length;
  1864. const bytesTransferred = internals.bytesSeen;
  1865. const progressBytes = bytesTransferred - bytesNotified;
  1866. if (!progressBytes || self.destroyed) return;
  1867. const rate = _speedometer(progressBytes);
  1868. bytesNotified = bytesTransferred;
  1869. process.nextTick(() => {
  1870. self.emit('progress', {
  1871. 'loaded': bytesTransferred,
  1872. 'total': totalBytes,
  1873. 'progress': totalBytes ? (bytesTransferred / totalBytes) : undefined,
  1874. 'bytes': progressBytes,
  1875. 'rate': rate ? rate : undefined,
  1876. 'estimated': rate && totalBytes && bytesTransferred <= totalBytes ?
  1877. (totalBytes - bytesTransferred) / rate : undefined
  1878. });
  1879. });
  1880. }, internals.ticksRate);
  1881. const onFinish = () => {
  1882. internals.updateProgress(true);
  1883. };
  1884. this.once('end', onFinish);
  1885. this.once('error', onFinish);
  1886. }
  1887. _read(size) {
  1888. const internals = this[kInternals];
  1889. if (internals.onReadCallback) {
  1890. internals.onReadCallback();
  1891. }
  1892. return super._read(size);
  1893. }
  1894. _transform(chunk, encoding, callback) {
  1895. const self = this;
  1896. const internals = this[kInternals];
  1897. const maxRate = internals.maxRate;
  1898. const readableHighWaterMark = this.readableHighWaterMark;
  1899. const timeWindow = internals.timeWindow;
  1900. const divider = 1000 / timeWindow;
  1901. const bytesThreshold = (maxRate / divider);
  1902. const minChunkSize = internals.minChunkSize !== false ? Math.max(internals.minChunkSize, bytesThreshold * 0.01) : 0;
  1903. function pushChunk(_chunk, _callback) {
  1904. const bytes = Buffer.byteLength(_chunk);
  1905. internals.bytesSeen += bytes;
  1906. internals.bytes += bytes;
  1907. if (internals.isCaptured) {
  1908. internals.updateProgress();
  1909. }
  1910. if (self.push(_chunk)) {
  1911. process.nextTick(_callback);
  1912. } else {
  1913. internals.onReadCallback = () => {
  1914. internals.onReadCallback = null;
  1915. process.nextTick(_callback);
  1916. };
  1917. }
  1918. }
  1919. const transformChunk = (_chunk, _callback) => {
  1920. const chunkSize = Buffer.byteLength(_chunk);
  1921. let chunkRemainder = null;
  1922. let maxChunkSize = readableHighWaterMark;
  1923. let bytesLeft;
  1924. let passed = 0;
  1925. if (maxRate) {
  1926. const now = Date.now();
  1927. if (!internals.ts || (passed = (now - internals.ts)) >= timeWindow) {
  1928. internals.ts = now;
  1929. bytesLeft = bytesThreshold - internals.bytes;
  1930. internals.bytes = bytesLeft < 0 ? -bytesLeft : 0;
  1931. passed = 0;
  1932. }
  1933. bytesLeft = bytesThreshold - internals.bytes;
  1934. }
  1935. if (maxRate) {
  1936. if (bytesLeft <= 0) {
  1937. // next time window
  1938. return setTimeout(() => {
  1939. _callback(null, _chunk);
  1940. }, timeWindow - passed);
  1941. }
  1942. if (bytesLeft < maxChunkSize) {
  1943. maxChunkSize = bytesLeft;
  1944. }
  1945. }
  1946. if (maxChunkSize && chunkSize > maxChunkSize && (chunkSize - maxChunkSize) > minChunkSize) {
  1947. chunkRemainder = _chunk.subarray(maxChunkSize);
  1948. _chunk = _chunk.subarray(0, maxChunkSize);
  1949. }
  1950. pushChunk(_chunk, chunkRemainder ? () => {
  1951. process.nextTick(_callback, null, chunkRemainder);
  1952. } : _callback);
  1953. };
  1954. transformChunk(chunk, function transformNextChunk(err, _chunk) {
  1955. if (err) {
  1956. return callback(err);
  1957. }
  1958. if (_chunk) {
  1959. transformChunk(_chunk, transformNextChunk);
  1960. } else {
  1961. callback(null);
  1962. }
  1963. });
  1964. }
  1965. setLength(length) {
  1966. this[kInternals].length = +length;
  1967. return this;
  1968. }
  1969. }
  1970. const AxiosTransformStream$1 = AxiosTransformStream;
  1971. const {asyncIterator} = Symbol;
  1972. const readBlob = async function* (blob) {
  1973. if (blob.stream) {
  1974. yield* blob.stream();
  1975. } else if (blob.arrayBuffer) {
  1976. yield await blob.arrayBuffer();
  1977. } else if (blob[asyncIterator]) {
  1978. yield* blob[asyncIterator]();
  1979. } else {
  1980. yield blob;
  1981. }
  1982. };
  1983. const readBlob$1 = readBlob;
  1984. const BOUNDARY_ALPHABET = utils$1.ALPHABET.ALPHA_DIGIT + '-_';
  1985. const textEncoder = new util.TextEncoder();
  1986. const CRLF = '\r\n';
  1987. const CRLF_BYTES = textEncoder.encode(CRLF);
  1988. const CRLF_BYTES_COUNT = 2;
  1989. class FormDataPart {
  1990. constructor(name, value) {
  1991. const {escapeName} = this.constructor;
  1992. const isStringValue = utils$1.isString(value);
  1993. let headers = `Content-Disposition: form-data; name="${escapeName(name)}"${
  1994. !isStringValue && value.name ? `; filename="${escapeName(value.name)}"` : ''
  1995. }${CRLF}`;
  1996. if (isStringValue) {
  1997. value = textEncoder.encode(String(value).replace(/\r?\n|\r\n?/g, CRLF));
  1998. } else {
  1999. headers += `Content-Type: ${value.type || "application/octet-stream"}${CRLF}`;
  2000. }
  2001. this.headers = textEncoder.encode(headers + CRLF);
  2002. this.contentLength = isStringValue ? value.byteLength : value.size;
  2003. this.size = this.headers.byteLength + this.contentLength + CRLF_BYTES_COUNT;
  2004. this.name = name;
  2005. this.value = value;
  2006. }
  2007. async *encode(){
  2008. yield this.headers;
  2009. const {value} = this;
  2010. if(utils$1.isTypedArray(value)) {
  2011. yield value;
  2012. } else {
  2013. yield* readBlob$1(value);
  2014. }
  2015. yield CRLF_BYTES;
  2016. }
  2017. static escapeName(name) {
  2018. return String(name).replace(/[\r\n"]/g, (match) => ({
  2019. '\r' : '%0D',
  2020. '\n' : '%0A',
  2021. '"' : '%22',
  2022. }[match]));
  2023. }
  2024. }
  2025. const formDataToStream = (form, headersHandler, options) => {
  2026. const {
  2027. tag = 'form-data-boundary',
  2028. size = 25,
  2029. boundary = tag + '-' + utils$1.generateString(size, BOUNDARY_ALPHABET)
  2030. } = options || {};
  2031. if(!utils$1.isFormData(form)) {
  2032. throw TypeError('FormData instance required');
  2033. }
  2034. if (boundary.length < 1 || boundary.length > 70) {
  2035. throw Error('boundary must be 10-70 characters long')
  2036. }
  2037. const boundaryBytes = textEncoder.encode('--' + boundary + CRLF);
  2038. const footerBytes = textEncoder.encode('--' + boundary + '--' + CRLF + CRLF);
  2039. let contentLength = footerBytes.byteLength;
  2040. const parts = Array.from(form.entries()).map(([name, value]) => {
  2041. const part = new FormDataPart(name, value);
  2042. contentLength += part.size;
  2043. return part;
  2044. });
  2045. contentLength += boundaryBytes.byteLength * parts.length;
  2046. contentLength = utils$1.toFiniteNumber(contentLength);
  2047. const computedHeaders = {
  2048. 'Content-Type': `multipart/form-data; boundary=${boundary}`
  2049. };
  2050. if (Number.isFinite(contentLength)) {
  2051. computedHeaders['Content-Length'] = contentLength;
  2052. }
  2053. headersHandler && headersHandler(computedHeaders);
  2054. return stream.Readable.from((async function *() {
  2055. for(const part of parts) {
  2056. yield boundaryBytes;
  2057. yield* part.encode();
  2058. }
  2059. yield footerBytes;
  2060. })());
  2061. };
  2062. const formDataToStream$1 = formDataToStream;
  2063. class ZlibHeaderTransformStream extends stream__default["default"].Transform {
  2064. __transform(chunk, encoding, callback) {
  2065. this.push(chunk);
  2066. callback();
  2067. }
  2068. _transform(chunk, encoding, callback) {
  2069. if (chunk.length !== 0) {
  2070. this._transform = this.__transform;
  2071. // Add Default Compression headers if no zlib headers are present
  2072. if (chunk[0] !== 120) { // Hex: 78
  2073. const header = Buffer.alloc(2);
  2074. header[0] = 120; // Hex: 78
  2075. header[1] = 156; // Hex: 9C
  2076. this.push(header, encoding);
  2077. }
  2078. }
  2079. this.__transform(chunk, encoding, callback);
  2080. }
  2081. }
  2082. const ZlibHeaderTransformStream$1 = ZlibHeaderTransformStream;
  2083. const callbackify = (fn, reducer) => {
  2084. return utils$1.isAsyncFn(fn) ? function (...args) {
  2085. const cb = args.pop();
  2086. fn.apply(this, args).then((value) => {
  2087. try {
  2088. reducer ? cb(null, ...reducer(value)) : cb(null, value);
  2089. } catch (err) {
  2090. cb(err);
  2091. }
  2092. }, cb);
  2093. } : fn;
  2094. };
  2095. const callbackify$1 = callbackify;
  2096. const zlibOptions = {
  2097. flush: zlib__default["default"].constants.Z_SYNC_FLUSH,
  2098. finishFlush: zlib__default["default"].constants.Z_SYNC_FLUSH
  2099. };
  2100. const brotliOptions = {
  2101. flush: zlib__default["default"].constants.BROTLI_OPERATION_FLUSH,
  2102. finishFlush: zlib__default["default"].constants.BROTLI_OPERATION_FLUSH
  2103. };
  2104. const isBrotliSupported = utils$1.isFunction(zlib__default["default"].createBrotliDecompress);
  2105. const {http: httpFollow, https: httpsFollow} = followRedirects__default["default"];
  2106. const isHttps = /https:?/;
  2107. const supportedProtocols = platform.protocols.map(protocol => {
  2108. return protocol + ':';
  2109. });
  2110. /**
  2111. * If the proxy or config beforeRedirects functions are defined, call them with the options
  2112. * object.
  2113. *
  2114. * @param {Object<string, any>} options - The options object that was passed to the request.
  2115. *
  2116. * @returns {Object<string, any>}
  2117. */
  2118. function dispatchBeforeRedirect(options) {
  2119. if (options.beforeRedirects.proxy) {
  2120. options.beforeRedirects.proxy(options);
  2121. }
  2122. if (options.beforeRedirects.config) {
  2123. options.beforeRedirects.config(options);
  2124. }
  2125. }
  2126. /**
  2127. * If the proxy or config afterRedirects functions are defined, call them with the options
  2128. *
  2129. * @param {http.ClientRequestArgs} options
  2130. * @param {AxiosProxyConfig} configProxy configuration from Axios options object
  2131. * @param {string} location
  2132. *
  2133. * @returns {http.ClientRequestArgs}
  2134. */
  2135. function setProxy(options, configProxy, location) {
  2136. let proxy = configProxy;
  2137. if (!proxy && proxy !== false) {
  2138. const proxyUrl = proxyFromEnv.getProxyForUrl(location);
  2139. if (proxyUrl) {
  2140. proxy = new URL(proxyUrl);
  2141. }
  2142. }
  2143. if (proxy) {
  2144. // Basic proxy authorization
  2145. if (proxy.username) {
  2146. proxy.auth = (proxy.username || '') + ':' + (proxy.password || '');
  2147. }
  2148. if (proxy.auth) {
  2149. // Support proxy auth object form
  2150. if (proxy.auth.username || proxy.auth.password) {
  2151. proxy.auth = (proxy.auth.username || '') + ':' + (proxy.auth.password || '');
  2152. }
  2153. const base64 = Buffer
  2154. .from(proxy.auth, 'utf8')
  2155. .toString('base64');
  2156. options.headers['Proxy-Authorization'] = 'Basic ' + base64;
  2157. }
  2158. options.headers.host = options.hostname + (options.port ? ':' + options.port : '');
  2159. const proxyHost = proxy.hostname || proxy.host;
  2160. options.hostname = proxyHost;
  2161. // Replace 'host' since options is not a URL object
  2162. options.host = proxyHost;
  2163. options.port = proxy.port;
  2164. options.path = location;
  2165. if (proxy.protocol) {
  2166. options.protocol = proxy.protocol.includes(':') ? proxy.protocol : `${proxy.protocol}:`;
  2167. }
  2168. }
  2169. options.beforeRedirects.proxy = function beforeRedirect(redirectOptions) {
  2170. // Configure proxy for redirected request, passing the original config proxy to apply
  2171. // the exact same logic as if the redirected request was performed by axios directly.
  2172. setProxy(redirectOptions, configProxy, redirectOptions.href);
  2173. };
  2174. }
  2175. const isHttpAdapterSupported = typeof process !== 'undefined' && utils$1.kindOf(process) === 'process';
  2176. // temporary hotfix
  2177. const wrapAsync = (asyncExecutor) => {
  2178. return new Promise((resolve, reject) => {
  2179. let onDone;
  2180. let isDone;
  2181. const done = (value, isRejected) => {
  2182. if (isDone) return;
  2183. isDone = true;
  2184. onDone && onDone(value, isRejected);
  2185. };
  2186. const _resolve = (value) => {
  2187. done(value);
  2188. resolve(value);
  2189. };
  2190. const _reject = (reason) => {
  2191. done(reason, true);
  2192. reject(reason);
  2193. };
  2194. asyncExecutor(_resolve, _reject, (onDoneHandler) => (onDone = onDoneHandler)).catch(_reject);
  2195. })
  2196. };
  2197. const resolveFamily = ({address, family}) => {
  2198. if (!utils$1.isString(address)) {
  2199. throw TypeError('address must be a string');
  2200. }
  2201. return ({
  2202. address,
  2203. family: family || (address.indexOf('.') < 0 ? 6 : 4)
  2204. });
  2205. };
  2206. const buildAddressEntry = (address, family) => resolveFamily(utils$1.isObject(address) ? address : {address, family});
  2207. /*eslint consistent-return:0*/
  2208. const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
  2209. return wrapAsync(async function dispatchHttpRequest(resolve, reject, onDone) {
  2210. let {data, lookup, family} = config;
  2211. const {responseType, responseEncoding} = config;
  2212. const method = config.method.toUpperCase();
  2213. let isDone;
  2214. let rejected = false;
  2215. let req;
  2216. if (lookup) {
  2217. const _lookup = callbackify$1(lookup, (value) => utils$1.isArray(value) ? value : [value]);
  2218. // hotfix to support opt.all option which is required for node 20.x
  2219. lookup = (hostname, opt, cb) => {
  2220. _lookup(hostname, opt, (err, arg0, arg1) => {
  2221. const addresses = utils$1.isArray(arg0) ? arg0.map(addr => buildAddressEntry(addr)) : [buildAddressEntry(arg0, arg1)];
  2222. opt.all ? cb(err, addresses) : cb(err, addresses[0].address, addresses[0].family);
  2223. });
  2224. };
  2225. }
  2226. // temporary internal emitter until the AxiosRequest class will be implemented
  2227. const emitter = new EventEmitter__default["default"]();
  2228. const onFinished = () => {
  2229. if (config.cancelToken) {
  2230. config.cancelToken.unsubscribe(abort);
  2231. }
  2232. if (config.signal) {
  2233. config.signal.removeEventListener('abort', abort);
  2234. }
  2235. emitter.removeAllListeners();
  2236. };
  2237. onDone((value, isRejected) => {
  2238. isDone = true;
  2239. if (isRejected) {
  2240. rejected = true;
  2241. onFinished();
  2242. }
  2243. });
  2244. function abort(reason) {
  2245. emitter.emit('abort', !reason || reason.type ? new CanceledError(null, config, req) : reason);
  2246. }
  2247. emitter.once('abort', reject);
  2248. if (config.cancelToken || config.signal) {
  2249. config.cancelToken && config.cancelToken.subscribe(abort);
  2250. if (config.signal) {
  2251. config.signal.aborted ? abort() : config.signal.addEventListener('abort', abort);
  2252. }
  2253. }
  2254. // Parse url
  2255. const fullPath = buildFullPath(config.baseURL, config.url);
  2256. const parsed = new URL(fullPath, 'http://localhost');
  2257. const protocol = parsed.protocol || supportedProtocols[0];
  2258. if (protocol === 'data:') {
  2259. let convertedData;
  2260. if (method !== 'GET') {
  2261. return settle(resolve, reject, {
  2262. status: 405,
  2263. statusText: 'method not allowed',
  2264. headers: {},
  2265. config
  2266. });
  2267. }
  2268. try {
  2269. convertedData = fromDataURI(config.url, responseType === 'blob', {
  2270. Blob: config.env && config.env.Blob
  2271. });
  2272. } catch (err) {
  2273. throw AxiosError.from(err, AxiosError.ERR_BAD_REQUEST, config);
  2274. }
  2275. if (responseType === 'text') {
  2276. convertedData = convertedData.toString(responseEncoding);
  2277. if (!responseEncoding || responseEncoding === 'utf8') {
  2278. convertedData = utils$1.stripBOM(convertedData);
  2279. }
  2280. } else if (responseType === 'stream') {
  2281. convertedData = stream__default["default"].Readable.from(convertedData);
  2282. }
  2283. return settle(resolve, reject, {
  2284. data: convertedData,
  2285. status: 200,
  2286. statusText: 'OK',
  2287. headers: new AxiosHeaders$1(),
  2288. config
  2289. });
  2290. }
  2291. if (supportedProtocols.indexOf(protocol) === -1) {
  2292. return reject(new AxiosError(
  2293. 'Unsupported protocol ' + protocol,
  2294. AxiosError.ERR_BAD_REQUEST,
  2295. config
  2296. ));
  2297. }
  2298. const headers = AxiosHeaders$1.from(config.headers).normalize();
  2299. // Set User-Agent (required by some servers)
  2300. // See https://github.com/axios/axios/issues/69
  2301. // User-Agent is specified; handle case where no UA header is desired
  2302. // Only set header if it hasn't been set in config
  2303. headers.set('User-Agent', 'axios/' + VERSION, false);
  2304. const onDownloadProgress = config.onDownloadProgress;
  2305. const onUploadProgress = config.onUploadProgress;
  2306. const maxRate = config.maxRate;
  2307. let maxUploadRate = undefined;
  2308. let maxDownloadRate = undefined;
  2309. // support for spec compliant FormData objects
  2310. if (utils$1.isSpecCompliantForm(data)) {
  2311. const userBoundary = headers.getContentType(/boundary=([-_\w\d]{10,70})/i);
  2312. data = formDataToStream$1(data, (formHeaders) => {
  2313. headers.set(formHeaders);
  2314. }, {
  2315. tag: `axios-${VERSION}-boundary`,
  2316. boundary: userBoundary && userBoundary[1] || undefined
  2317. });
  2318. // support for https://www.npmjs.com/package/form-data api
  2319. } else if (utils$1.isFormData(data) && utils$1.isFunction(data.getHeaders)) {
  2320. headers.set(data.getHeaders());
  2321. if (!headers.hasContentLength()) {
  2322. try {
  2323. const knownLength = await util__default["default"].promisify(data.getLength).call(data);
  2324. Number.isFinite(knownLength) && knownLength >= 0 && headers.setContentLength(knownLength);
  2325. /*eslint no-empty:0*/
  2326. } catch (e) {
  2327. }
  2328. }
  2329. } else if (utils$1.isBlob(data)) {
  2330. data.size && headers.setContentType(data.type || 'application/octet-stream');
  2331. headers.setContentLength(data.size || 0);
  2332. data = stream__default["default"].Readable.from(readBlob$1(data));
  2333. } else if (data && !utils$1.isStream(data)) {
  2334. if (Buffer.isBuffer(data)) ; else if (utils$1.isArrayBuffer(data)) {
  2335. data = Buffer.from(new Uint8Array(data));
  2336. } else if (utils$1.isString(data)) {
  2337. data = Buffer.from(data, 'utf-8');
  2338. } else {
  2339. return reject(new AxiosError(
  2340. 'Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream',
  2341. AxiosError.ERR_BAD_REQUEST,
  2342. config
  2343. ));
  2344. }
  2345. // Add Content-Length header if data exists
  2346. headers.setContentLength(data.length, false);
  2347. if (config.maxBodyLength > -1 && data.length > config.maxBodyLength) {
  2348. return reject(new AxiosError(
  2349. 'Request body larger than maxBodyLength limit',
  2350. AxiosError.ERR_BAD_REQUEST,
  2351. config
  2352. ));
  2353. }
  2354. }
  2355. const contentLength = utils$1.toFiniteNumber(headers.getContentLength());
  2356. if (utils$1.isArray(maxRate)) {
  2357. maxUploadRate = maxRate[0];
  2358. maxDownloadRate = maxRate[1];
  2359. } else {
  2360. maxUploadRate = maxDownloadRate = maxRate;
  2361. }
  2362. if (data && (onUploadProgress || maxUploadRate)) {
  2363. if (!utils$1.isStream(data)) {
  2364. data = stream__default["default"].Readable.from(data, {objectMode: false});
  2365. }
  2366. data = stream__default["default"].pipeline([data, new AxiosTransformStream$1({
  2367. length: contentLength,
  2368. maxRate: utils$1.toFiniteNumber(maxUploadRate)
  2369. })], utils$1.noop);
  2370. onUploadProgress && data.on('progress', progress => {
  2371. onUploadProgress(Object.assign(progress, {
  2372. upload: true
  2373. }));
  2374. });
  2375. }
  2376. // HTTP basic authentication
  2377. let auth = undefined;
  2378. if (config.auth) {
  2379. const username = config.auth.username || '';
  2380. const password = config.auth.password || '';
  2381. auth = username + ':' + password;
  2382. }
  2383. if (!auth && parsed.username) {
  2384. const urlUsername = parsed.username;
  2385. const urlPassword = parsed.password;
  2386. auth = urlUsername + ':' + urlPassword;
  2387. }
  2388. auth && headers.delete('authorization');
  2389. let path;
  2390. try {
  2391. path = buildURL(
  2392. parsed.pathname + parsed.search,
  2393. config.params,
  2394. config.paramsSerializer
  2395. ).replace(/^\?/, '');
  2396. } catch (err) {
  2397. const customErr = new Error(err.message);
  2398. customErr.config = config;
  2399. customErr.url = config.url;
  2400. customErr.exists = true;
  2401. return reject(customErr);
  2402. }
  2403. headers.set(
  2404. 'Accept-Encoding',
  2405. 'gzip, compress, deflate' + (isBrotliSupported ? ', br' : ''), false
  2406. );
  2407. const options = {
  2408. path,
  2409. method: method,
  2410. headers: headers.toJSON(),
  2411. agents: { http: config.httpAgent, https: config.httpsAgent },
  2412. auth,
  2413. protocol,
  2414. family,
  2415. beforeRedirect: dispatchBeforeRedirect,
  2416. beforeRedirects: {}
  2417. };
  2418. // cacheable-lookup integration hotfix
  2419. !utils$1.isUndefined(lookup) && (options.lookup = lookup);
  2420. if (config.socketPath) {
  2421. options.socketPath = config.socketPath;
  2422. } else {
  2423. options.hostname = parsed.hostname;
  2424. options.port = parsed.port;
  2425. setProxy(options, config.proxy, protocol + '//' + parsed.hostname + (parsed.port ? ':' + parsed.port : '') + options.path);
  2426. }
  2427. let transport;
  2428. const isHttpsRequest = isHttps.test(options.protocol);
  2429. options.agent = isHttpsRequest ? config.httpsAgent : config.httpAgent;
  2430. if (config.transport) {
  2431. transport = config.transport;
  2432. } else if (config.maxRedirects === 0) {
  2433. transport = isHttpsRequest ? https__default["default"] : http__default["default"];
  2434. } else {
  2435. if (config.maxRedirects) {
  2436. options.maxRedirects = config.maxRedirects;
  2437. }
  2438. if (config.beforeRedirect) {
  2439. options.beforeRedirects.config = config.beforeRedirect;
  2440. }
  2441. transport = isHttpsRequest ? httpsFollow : httpFollow;
  2442. }
  2443. if (config.maxBodyLength > -1) {
  2444. options.maxBodyLength = config.maxBodyLength;
  2445. } else {
  2446. // follow-redirects does not skip comparison, so it should always succeed for axios -1 unlimited
  2447. options.maxBodyLength = Infinity;
  2448. }
  2449. if (config.insecureHTTPParser) {
  2450. options.insecureHTTPParser = config.insecureHTTPParser;
  2451. }
  2452. // Create the request
  2453. req = transport.request(options, function handleResponse(res) {
  2454. if (req.destroyed) return;
  2455. const streams = [res];
  2456. const responseLength = +res.headers['content-length'];
  2457. if (onDownloadProgress) {
  2458. const transformStream = new AxiosTransformStream$1({
  2459. length: utils$1.toFiniteNumber(responseLength),
  2460. maxRate: utils$1.toFiniteNumber(maxDownloadRate)
  2461. });
  2462. onDownloadProgress && transformStream.on('progress', progress => {
  2463. onDownloadProgress(Object.assign(progress, {
  2464. download: true
  2465. }));
  2466. });
  2467. streams.push(transformStream);
  2468. }
  2469. // decompress the response body transparently if required
  2470. let responseStream = res;
  2471. // return the last request in case of redirects
  2472. const lastRequest = res.req || req;
  2473. // if decompress disabled we should not decompress
  2474. if (config.decompress !== false && res.headers['content-encoding']) {
  2475. // if no content, but headers still say that it is encoded,
  2476. // remove the header not confuse downstream operations
  2477. if (method === 'HEAD' || res.statusCode === 204) {
  2478. delete res.headers['content-encoding'];
  2479. }
  2480. switch ((res.headers['content-encoding'] || '').toLowerCase()) {
  2481. /*eslint default-case:0*/
  2482. case 'gzip':
  2483. case 'x-gzip':
  2484. case 'compress':
  2485. case 'x-compress':
  2486. // add the unzipper to the body stream processing pipeline
  2487. streams.push(zlib__default["default"].createUnzip(zlibOptions));
  2488. // remove the content-encoding in order to not confuse downstream operations
  2489. delete res.headers['content-encoding'];
  2490. break;
  2491. case 'deflate':
  2492. streams.push(new ZlibHeaderTransformStream$1());
  2493. // add the unzipper to the body stream processing pipeline
  2494. streams.push(zlib__default["default"].createUnzip(zlibOptions));
  2495. // remove the content-encoding in order to not confuse downstream operations
  2496. delete res.headers['content-encoding'];
  2497. break;
  2498. case 'br':
  2499. if (isBrotliSupported) {
  2500. streams.push(zlib__default["default"].createBrotliDecompress(brotliOptions));
  2501. delete res.headers['content-encoding'];
  2502. }
  2503. }
  2504. }
  2505. responseStream = streams.length > 1 ? stream__default["default"].pipeline(streams, utils$1.noop) : streams[0];
  2506. const offListeners = stream__default["default"].finished(responseStream, () => {
  2507. offListeners();
  2508. onFinished();
  2509. });
  2510. const response = {
  2511. status: res.statusCode,
  2512. statusText: res.statusMessage,
  2513. headers: new AxiosHeaders$1(res.headers),
  2514. config,
  2515. request: lastRequest
  2516. };
  2517. if (responseType === 'stream') {
  2518. response.data = responseStream;
  2519. settle(resolve, reject, response);
  2520. } else {
  2521. const responseBuffer = [];
  2522. let totalResponseBytes = 0;
  2523. responseStream.on('data', function handleStreamData(chunk) {
  2524. responseBuffer.push(chunk);
  2525. totalResponseBytes += chunk.length;
  2526. // make sure the content length is not over the maxContentLength if specified
  2527. if (config.maxContentLength > -1 && totalResponseBytes > config.maxContentLength) {
  2528. // stream.destroy() emit aborted event before calling reject() on Node.js v16
  2529. rejected = true;
  2530. responseStream.destroy();
  2531. reject(new AxiosError('maxContentLength size of ' + config.maxContentLength + ' exceeded',
  2532. AxiosError.ERR_BAD_RESPONSE, config, lastRequest));
  2533. }
  2534. });
  2535. responseStream.on('aborted', function handlerStreamAborted() {
  2536. if (rejected) {
  2537. return;
  2538. }
  2539. const err = new AxiosError(
  2540. 'maxContentLength size of ' + config.maxContentLength + ' exceeded',
  2541. AxiosError.ERR_BAD_RESPONSE,
  2542. config,
  2543. lastRequest
  2544. );
  2545. responseStream.destroy(err);
  2546. reject(err);
  2547. });
  2548. responseStream.on('error', function handleStreamError(err) {
  2549. if (req.destroyed) return;
  2550. reject(AxiosError.from(err, null, config, lastRequest));
  2551. });
  2552. responseStream.on('end', function handleStreamEnd() {
  2553. try {
  2554. let responseData = responseBuffer.length === 1 ? responseBuffer[0] : Buffer.concat(responseBuffer);
  2555. if (responseType !== 'arraybuffer') {
  2556. responseData = responseData.toString(responseEncoding);
  2557. if (!responseEncoding || responseEncoding === 'utf8') {
  2558. responseData = utils$1.stripBOM(responseData);
  2559. }
  2560. }
  2561. response.data = responseData;
  2562. } catch (err) {
  2563. return reject(AxiosError.from(err, null, config, response.request, response));
  2564. }
  2565. settle(resolve, reject, response);
  2566. });
  2567. }
  2568. emitter.once('abort', err => {
  2569. if (!responseStream.destroyed) {
  2570. responseStream.emit('error', err);
  2571. responseStream.destroy();
  2572. }
  2573. });
  2574. });
  2575. emitter.once('abort', err => {
  2576. reject(err);
  2577. req.destroy(err);
  2578. });
  2579. // Handle errors
  2580. req.on('error', function handleRequestError(err) {
  2581. // @todo remove
  2582. // if (req.aborted && err.code !== AxiosError.ERR_FR_TOO_MANY_REDIRECTS) return;
  2583. reject(AxiosError.from(err, null, config, req));
  2584. });
  2585. // set tcp keep alive to prevent drop connection by peer
  2586. req.on('socket', function handleRequestSocket(socket) {
  2587. // default interval of sending ack packet is 1 minute
  2588. socket.setKeepAlive(true, 1000 * 60);
  2589. });
  2590. // Handle request timeout
  2591. if (config.timeout) {
  2592. // This is forcing a int timeout to avoid problems if the `req` interface doesn't handle other types.
  2593. const timeout = parseInt(config.timeout, 10);
  2594. if (Number.isNaN(timeout)) {
  2595. reject(new AxiosError(
  2596. 'error trying to parse `config.timeout` to int',
  2597. AxiosError.ERR_BAD_OPTION_VALUE,
  2598. config,
  2599. req
  2600. ));
  2601. return;
  2602. }
  2603. // Sometime, the response will be very slow, and does not respond, the connect event will be block by event loop system.
  2604. // And timer callback will be fired, and abort() will be invoked before connection, then get "socket hang up" and code ECONNRESET.
  2605. // At this time, if we have a large number of request, nodejs will hang up some socket on background. and the number will up and up.
  2606. // And then these socket which be hang up will devouring CPU little by little.
  2607. // ClientRequest.setTimeout will be fired on the specify milliseconds, and can make sure that abort() will be fired after connect.
  2608. req.setTimeout(timeout, function handleRequestTimeout() {
  2609. if (isDone) return;
  2610. let timeoutErrorMessage = config.timeout ? 'timeout of ' + config.timeout + 'ms exceeded' : 'timeout exceeded';
  2611. const transitional = config.transitional || transitionalDefaults;
  2612. if (config.timeoutErrorMessage) {
  2613. timeoutErrorMessage = config.timeoutErrorMessage;
  2614. }
  2615. reject(new AxiosError(
  2616. timeoutErrorMessage,
  2617. transitional.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED,
  2618. config,
  2619. req
  2620. ));
  2621. abort();
  2622. });
  2623. }
  2624. // Send the request
  2625. if (utils$1.isStream(data)) {
  2626. let ended = false;
  2627. let errored = false;
  2628. data.on('end', () => {
  2629. ended = true;
  2630. });
  2631. data.once('error', err => {
  2632. errored = true;
  2633. req.destroy(err);
  2634. });
  2635. data.on('close', () => {
  2636. if (!ended && !errored) {
  2637. abort(new CanceledError('Request stream has been aborted', config, req));
  2638. }
  2639. });
  2640. data.pipe(req);
  2641. } else {
  2642. req.end(data);
  2643. }
  2644. });
  2645. };
  2646. const cookies = platform.hasStandardBrowserEnv ?
  2647. // Standard browser envs support document.cookie
  2648. {
  2649. write(name, value, expires, path, domain, secure) {
  2650. const cookie = [name + '=' + encodeURIComponent(value)];
  2651. utils$1.isNumber(expires) && cookie.push('expires=' + new Date(expires).toGMTString());
  2652. utils$1.isString(path) && cookie.push('path=' + path);
  2653. utils$1.isString(domain) && cookie.push('domain=' + domain);
  2654. secure === true && cookie.push('secure');
  2655. document.cookie = cookie.join('; ');
  2656. },
  2657. read(name) {
  2658. const match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
  2659. return (match ? decodeURIComponent(match[3]) : null);
  2660. },
  2661. remove(name) {
  2662. this.write(name, '', Date.now() - 86400000);
  2663. }
  2664. }
  2665. :
  2666. // Non-standard browser env (web workers, react-native) lack needed support.
  2667. {
  2668. write() {},
  2669. read() {
  2670. return null;
  2671. },
  2672. remove() {}
  2673. };
  2674. const isURLSameOrigin = platform.hasStandardBrowserEnv ?
  2675. // Standard browser envs have full support of the APIs needed to test
  2676. // whether the request URL is of the same origin as current location.
  2677. (function standardBrowserEnv() {
  2678. const msie = /(msie|trident)/i.test(navigator.userAgent);
  2679. const urlParsingNode = document.createElement('a');
  2680. let originURL;
  2681. /**
  2682. * Parse a URL to discover its components
  2683. *
  2684. * @param {String} url The URL to be parsed
  2685. * @returns {Object}
  2686. */
  2687. function resolveURL(url) {
  2688. let href = url;
  2689. if (msie) {
  2690. // IE needs attribute set twice to normalize properties
  2691. urlParsingNode.setAttribute('href', href);
  2692. href = urlParsingNode.href;
  2693. }
  2694. urlParsingNode.setAttribute('href', href);
  2695. // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
  2696. return {
  2697. href: urlParsingNode.href,
  2698. protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
  2699. host: urlParsingNode.host,
  2700. search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
  2701. hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
  2702. hostname: urlParsingNode.hostname,
  2703. port: urlParsingNode.port,
  2704. pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
  2705. urlParsingNode.pathname :
  2706. '/' + urlParsingNode.pathname
  2707. };
  2708. }
  2709. originURL = resolveURL(window.location.href);
  2710. /**
  2711. * Determine if a URL shares the same origin as the current location
  2712. *
  2713. * @param {String} requestURL The URL to test
  2714. * @returns {boolean} True if URL shares the same origin, otherwise false
  2715. */
  2716. return function isURLSameOrigin(requestURL) {
  2717. const parsed = (utils$1.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
  2718. return (parsed.protocol === originURL.protocol &&
  2719. parsed.host === originURL.host);
  2720. };
  2721. })() :
  2722. // Non standard browser envs (web workers, react-native) lack needed support.
  2723. (function nonStandardBrowserEnv() {
  2724. return function isURLSameOrigin() {
  2725. return true;
  2726. };
  2727. })();
  2728. function progressEventReducer(listener, isDownloadStream) {
  2729. let bytesNotified = 0;
  2730. const _speedometer = speedometer(50, 250);
  2731. return e => {
  2732. const loaded = e.loaded;
  2733. const total = e.lengthComputable ? e.total : undefined;
  2734. const progressBytes = loaded - bytesNotified;
  2735. const rate = _speedometer(progressBytes);
  2736. const inRange = loaded <= total;
  2737. bytesNotified = loaded;
  2738. const data = {
  2739. loaded,
  2740. total,
  2741. progress: total ? (loaded / total) : undefined,
  2742. bytes: progressBytes,
  2743. rate: rate ? rate : undefined,
  2744. estimated: rate && total && inRange ? (total - loaded) / rate : undefined,
  2745. event: e
  2746. };
  2747. data[isDownloadStream ? 'download' : 'upload'] = true;
  2748. listener(data);
  2749. };
  2750. }
  2751. const isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
  2752. const xhrAdapter = isXHRAdapterSupported && function (config) {
  2753. return new Promise(function dispatchXhrRequest(resolve, reject) {
  2754. let requestData = config.data;
  2755. const requestHeaders = AxiosHeaders$1.from(config.headers).normalize();
  2756. let {responseType, withXSRFToken} = config;
  2757. let onCanceled;
  2758. function done() {
  2759. if (config.cancelToken) {
  2760. config.cancelToken.unsubscribe(onCanceled);
  2761. }
  2762. if (config.signal) {
  2763. config.signal.removeEventListener('abort', onCanceled);
  2764. }
  2765. }
  2766. let contentType;
  2767. if (utils$1.isFormData(requestData)) {
  2768. if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv) {
  2769. requestHeaders.setContentType(false); // Let the browser set it
  2770. } else if ((contentType = requestHeaders.getContentType()) !== false) {
  2771. // fix semicolon duplication issue for ReactNative FormData implementation
  2772. const [type, ...tokens] = contentType ? contentType.split(';').map(token => token.trim()).filter(Boolean) : [];
  2773. requestHeaders.setContentType([type || 'multipart/form-data', ...tokens].join('; '));
  2774. }
  2775. }
  2776. let request = new XMLHttpRequest();
  2777. // HTTP basic authentication
  2778. if (config.auth) {
  2779. const username = config.auth.username || '';
  2780. const password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : '';
  2781. requestHeaders.set('Authorization', 'Basic ' + btoa(username + ':' + password));
  2782. }
  2783. const fullPath = buildFullPath(config.baseURL, config.url);
  2784. request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);
  2785. // Set the request timeout in MS
  2786. request.timeout = config.timeout;
  2787. function onloadend() {
  2788. if (!request) {
  2789. return;
  2790. }
  2791. // Prepare the response
  2792. const responseHeaders = AxiosHeaders$1.from(
  2793. 'getAllResponseHeaders' in request && request.getAllResponseHeaders()
  2794. );
  2795. const responseData = !responseType || responseType === 'text' || responseType === 'json' ?
  2796. request.responseText : request.response;
  2797. const response = {
  2798. data: responseData,
  2799. status: request.status,
  2800. statusText: request.statusText,
  2801. headers: responseHeaders,
  2802. config,
  2803. request
  2804. };
  2805. settle(function _resolve(value) {
  2806. resolve(value);
  2807. done();
  2808. }, function _reject(err) {
  2809. reject(err);
  2810. done();
  2811. }, response);
  2812. // Clean up request
  2813. request = null;
  2814. }
  2815. if ('onloadend' in request) {
  2816. // Use onloadend if available
  2817. request.onloadend = onloadend;
  2818. } else {
  2819. // Listen for ready state to emulate onloadend
  2820. request.onreadystatechange = function handleLoad() {
  2821. if (!request || request.readyState !== 4) {
  2822. return;
  2823. }
  2824. // The request errored out and we didn't get a response, this will be
  2825. // handled by onerror instead
  2826. // With one exception: request that using file: protocol, most browsers
  2827. // will return status as 0 even though it's a successful request
  2828. if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
  2829. return;
  2830. }
  2831. // readystate handler is calling before onerror or ontimeout handlers,
  2832. // so we should call onloadend on the next 'tick'
  2833. setTimeout(onloadend);
  2834. };
  2835. }
  2836. // Handle browser request cancellation (as opposed to a manual cancellation)
  2837. request.onabort = function handleAbort() {
  2838. if (!request) {
  2839. return;
  2840. }
  2841. reject(new AxiosError('Request aborted', AxiosError.ECONNABORTED, config, request));
  2842. // Clean up request
  2843. request = null;
  2844. };
  2845. // Handle low level network errors
  2846. request.onerror = function handleError() {
  2847. // Real errors are hidden from us by the browser
  2848. // onerror should only fire if it's a network error
  2849. reject(new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request));
  2850. // Clean up request
  2851. request = null;
  2852. };
  2853. // Handle timeout
  2854. request.ontimeout = function handleTimeout() {
  2855. let timeoutErrorMessage = config.timeout ? 'timeout of ' + config.timeout + 'ms exceeded' : 'timeout exceeded';
  2856. const transitional = config.transitional || transitionalDefaults;
  2857. if (config.timeoutErrorMessage) {
  2858. timeoutErrorMessage = config.timeoutErrorMessage;
  2859. }
  2860. reject(new AxiosError(
  2861. timeoutErrorMessage,
  2862. transitional.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED,
  2863. config,
  2864. request));
  2865. // Clean up request
  2866. request = null;
  2867. };
  2868. // Add xsrf header
  2869. // This is only done if running in a standard browser environment.
  2870. // Specifically not if we're in a web worker, or react-native.
  2871. if(platform.hasStandardBrowserEnv) {
  2872. withXSRFToken && utils$1.isFunction(withXSRFToken) && (withXSRFToken = withXSRFToken(config));
  2873. if (withXSRFToken || (withXSRFToken !== false && isURLSameOrigin(fullPath))) {
  2874. // Add xsrf header
  2875. const xsrfValue = config.xsrfHeaderName && config.xsrfCookieName && cookies.read(config.xsrfCookieName);
  2876. if (xsrfValue) {
  2877. requestHeaders.set(config.xsrfHeaderName, xsrfValue);
  2878. }
  2879. }
  2880. }
  2881. // Remove Content-Type if data is undefined
  2882. requestData === undefined && requestHeaders.setContentType(null);
  2883. // Add headers to the request
  2884. if ('setRequestHeader' in request) {
  2885. utils$1.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) {
  2886. request.setRequestHeader(key, val);
  2887. });
  2888. }
  2889. // Add withCredentials to request if needed
  2890. if (!utils$1.isUndefined(config.withCredentials)) {
  2891. request.withCredentials = !!config.withCredentials;
  2892. }
  2893. // Add responseType to request if needed
  2894. if (responseType && responseType !== 'json') {
  2895. request.responseType = config.responseType;
  2896. }
  2897. // Handle progress if needed
  2898. if (typeof config.onDownloadProgress === 'function') {
  2899. request.addEventListener('progress', progressEventReducer(config.onDownloadProgress, true));
  2900. }
  2901. // Not all browsers support upload events
  2902. if (typeof config.onUploadProgress === 'function' && request.upload) {
  2903. request.upload.addEventListener('progress', progressEventReducer(config.onUploadProgress));
  2904. }
  2905. if (config.cancelToken || config.signal) {
  2906. // Handle cancellation
  2907. // eslint-disable-next-line func-names
  2908. onCanceled = cancel => {
  2909. if (!request) {
  2910. return;
  2911. }
  2912. reject(!cancel || cancel.type ? new CanceledError(null, config, request) : cancel);
  2913. request.abort();
  2914. request = null;
  2915. };
  2916. config.cancelToken && config.cancelToken.subscribe(onCanceled);
  2917. if (config.signal) {
  2918. config.signal.aborted ? onCanceled() : config.signal.addEventListener('abort', onCanceled);
  2919. }
  2920. }
  2921. const protocol = parseProtocol(fullPath);
  2922. if (protocol && platform.protocols.indexOf(protocol) === -1) {
  2923. reject(new AxiosError('Unsupported protocol ' + protocol + ':', AxiosError.ERR_BAD_REQUEST, config));
  2924. return;
  2925. }
  2926. // Send the request
  2927. request.send(requestData || null);
  2928. });
  2929. };
  2930. const knownAdapters = {
  2931. http: httpAdapter,
  2932. xhr: xhrAdapter
  2933. };
  2934. utils$1.forEach(knownAdapters, (fn, value) => {
  2935. if (fn) {
  2936. try {
  2937. Object.defineProperty(fn, 'name', {value});
  2938. } catch (e) {
  2939. // eslint-disable-next-line no-empty
  2940. }
  2941. Object.defineProperty(fn, 'adapterName', {value});
  2942. }
  2943. });
  2944. const renderReason = (reason) => `- ${reason}`;
  2945. const isResolvedHandle = (adapter) => utils$1.isFunction(adapter) || adapter === null || adapter === false;
  2946. const adapters = {
  2947. getAdapter: (adapters) => {
  2948. adapters = utils$1.isArray(adapters) ? adapters : [adapters];
  2949. const {length} = adapters;
  2950. let nameOrAdapter;
  2951. let adapter;
  2952. const rejectedReasons = {};
  2953. for (let i = 0; i < length; i++) {
  2954. nameOrAdapter = adapters[i];
  2955. let id;
  2956. adapter = nameOrAdapter;
  2957. if (!isResolvedHandle(nameOrAdapter)) {
  2958. adapter = knownAdapters[(id = String(nameOrAdapter)).toLowerCase()];
  2959. if (adapter === undefined) {
  2960. throw new AxiosError(`Unknown adapter '${id}'`);
  2961. }
  2962. }
  2963. if (adapter) {
  2964. break;
  2965. }
  2966. rejectedReasons[id || '#' + i] = adapter;
  2967. }
  2968. if (!adapter) {
  2969. const reasons = Object.entries(rejectedReasons)
  2970. .map(([id, state]) => `adapter ${id} ` +
  2971. (state === false ? 'is not supported by the environment' : 'is not available in the build')
  2972. );
  2973. let s = length ?
  2974. (reasons.length > 1 ? 'since :\n' + reasons.map(renderReason).join('\n') : ' ' + renderReason(reasons[0])) :
  2975. 'as no adapter specified';
  2976. throw new AxiosError(
  2977. `There is no suitable adapter to dispatch the request ` + s,
  2978. 'ERR_NOT_SUPPORT'
  2979. );
  2980. }
  2981. return adapter;
  2982. },
  2983. adapters: knownAdapters
  2984. };
  2985. /**
  2986. * Throws a `CanceledError` if cancellation has been requested.
  2987. *
  2988. * @param {Object} config The config that is to be used for the request
  2989. *
  2990. * @returns {void}
  2991. */
  2992. function throwIfCancellationRequested(config) {
  2993. if (config.cancelToken) {
  2994. config.cancelToken.throwIfRequested();
  2995. }
  2996. if (config.signal && config.signal.aborted) {
  2997. throw new CanceledError(null, config);
  2998. }
  2999. }
  3000. /**
  3001. * Dispatch a request to the server using the configured adapter.
  3002. *
  3003. * @param {object} config The config that is to be used for the request
  3004. *
  3005. * @returns {Promise} The Promise to be fulfilled
  3006. */
  3007. function dispatchRequest(config) {
  3008. throwIfCancellationRequested(config);
  3009. config.headers = AxiosHeaders$1.from(config.headers);
  3010. // Transform request data
  3011. config.data = transformData.call(
  3012. config,
  3013. config.transformRequest
  3014. );
  3015. if (['post', 'put', 'patch'].indexOf(config.method) !== -1) {
  3016. config.headers.setContentType('application/x-www-form-urlencoded', false);
  3017. }
  3018. const adapter = adapters.getAdapter(config.adapter || defaults$1.adapter);
  3019. return adapter(config).then(function onAdapterResolution(response) {
  3020. throwIfCancellationRequested(config);
  3021. // Transform response data
  3022. response.data = transformData.call(
  3023. config,
  3024. config.transformResponse,
  3025. response
  3026. );
  3027. response.headers = AxiosHeaders$1.from(response.headers);
  3028. return response;
  3029. }, function onAdapterRejection(reason) {
  3030. if (!isCancel(reason)) {
  3031. throwIfCancellationRequested(config);
  3032. // Transform response data
  3033. if (reason && reason.response) {
  3034. reason.response.data = transformData.call(
  3035. config,
  3036. config.transformResponse,
  3037. reason.response
  3038. );
  3039. reason.response.headers = AxiosHeaders$1.from(reason.response.headers);
  3040. }
  3041. }
  3042. return Promise.reject(reason);
  3043. });
  3044. }
  3045. const headersToObject = (thing) => thing instanceof AxiosHeaders$1 ? thing.toJSON() : thing;
  3046. /**
  3047. * Config-specific merge-function which creates a new config-object
  3048. * by merging two configuration objects together.
  3049. *
  3050. * @param {Object} config1
  3051. * @param {Object} config2
  3052. *
  3053. * @returns {Object} New object resulting from merging config2 to config1
  3054. */
  3055. function mergeConfig(config1, config2) {
  3056. // eslint-disable-next-line no-param-reassign
  3057. config2 = config2 || {};
  3058. const config = {};
  3059. function getMergedValue(target, source, caseless) {
  3060. if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
  3061. return utils$1.merge.call({caseless}, target, source);
  3062. } else if (utils$1.isPlainObject(source)) {
  3063. return utils$1.merge({}, source);
  3064. } else if (utils$1.isArray(source)) {
  3065. return source.slice();
  3066. }
  3067. return source;
  3068. }
  3069. // eslint-disable-next-line consistent-return
  3070. function mergeDeepProperties(a, b, caseless) {
  3071. if (!utils$1.isUndefined(b)) {
  3072. return getMergedValue(a, b, caseless);
  3073. } else if (!utils$1.isUndefined(a)) {
  3074. return getMergedValue(undefined, a, caseless);
  3075. }
  3076. }
  3077. // eslint-disable-next-line consistent-return
  3078. function valueFromConfig2(a, b) {
  3079. if (!utils$1.isUndefined(b)) {
  3080. return getMergedValue(undefined, b);
  3081. }
  3082. }
  3083. // eslint-disable-next-line consistent-return
  3084. function defaultToConfig2(a, b) {
  3085. if (!utils$1.isUndefined(b)) {
  3086. return getMergedValue(undefined, b);
  3087. } else if (!utils$1.isUndefined(a)) {
  3088. return getMergedValue(undefined, a);
  3089. }
  3090. }
  3091. // eslint-disable-next-line consistent-return
  3092. function mergeDirectKeys(a, b, prop) {
  3093. if (prop in config2) {
  3094. return getMergedValue(a, b);
  3095. } else if (prop in config1) {
  3096. return getMergedValue(undefined, a);
  3097. }
  3098. }
  3099. const mergeMap = {
  3100. url: valueFromConfig2,
  3101. method: valueFromConfig2,
  3102. data: valueFromConfig2,
  3103. baseURL: defaultToConfig2,
  3104. transformRequest: defaultToConfig2,
  3105. transformResponse: defaultToConfig2,
  3106. paramsSerializer: defaultToConfig2,
  3107. timeout: defaultToConfig2,
  3108. timeoutMessage: defaultToConfig2,
  3109. withCredentials: defaultToConfig2,
  3110. withXSRFToken: defaultToConfig2,
  3111. adapter: defaultToConfig2,
  3112. responseType: defaultToConfig2,
  3113. xsrfCookieName: defaultToConfig2,
  3114. xsrfHeaderName: defaultToConfig2,
  3115. onUploadProgress: defaultToConfig2,
  3116. onDownloadProgress: defaultToConfig2,
  3117. decompress: defaultToConfig2,
  3118. maxContentLength: defaultToConfig2,
  3119. maxBodyLength: defaultToConfig2,
  3120. beforeRedirect: defaultToConfig2,
  3121. transport: defaultToConfig2,
  3122. httpAgent: defaultToConfig2,
  3123. httpsAgent: defaultToConfig2,
  3124. cancelToken: defaultToConfig2,
  3125. socketPath: defaultToConfig2,
  3126. responseEncoding: defaultToConfig2,
  3127. validateStatus: mergeDirectKeys,
  3128. headers: (a, b) => mergeDeepProperties(headersToObject(a), headersToObject(b), true)
  3129. };
  3130. utils$1.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
  3131. const merge = mergeMap[prop] || mergeDeepProperties;
  3132. const configValue = merge(config1[prop], config2[prop], prop);
  3133. (utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
  3134. });
  3135. return config;
  3136. }
  3137. const validators$1 = {};
  3138. // eslint-disable-next-line func-names
  3139. ['object', 'boolean', 'number', 'function', 'string', 'symbol'].forEach((type, i) => {
  3140. validators$1[type] = function validator(thing) {
  3141. return typeof thing === type || 'a' + (i < 1 ? 'n ' : ' ') + type;
  3142. };
  3143. });
  3144. const deprecatedWarnings = {};
  3145. /**
  3146. * Transitional option validator
  3147. *
  3148. * @param {function|boolean?} validator - set to false if the transitional option has been removed
  3149. * @param {string?} version - deprecated version / removed since version
  3150. * @param {string?} message - some message with additional info
  3151. *
  3152. * @returns {function}
  3153. */
  3154. validators$1.transitional = function transitional(validator, version, message) {
  3155. function formatMessage(opt, desc) {
  3156. return '[Axios v' + VERSION + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : '');
  3157. }
  3158. // eslint-disable-next-line func-names
  3159. return (value, opt, opts) => {
  3160. if (validator === false) {
  3161. throw new AxiosError(
  3162. formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')),
  3163. AxiosError.ERR_DEPRECATED
  3164. );
  3165. }
  3166. if (version && !deprecatedWarnings[opt]) {
  3167. deprecatedWarnings[opt] = true;
  3168. // eslint-disable-next-line no-console
  3169. console.warn(
  3170. formatMessage(
  3171. opt,
  3172. ' has been deprecated since v' + version + ' and will be removed in the near future'
  3173. )
  3174. );
  3175. }
  3176. return validator ? validator(value, opt, opts) : true;
  3177. };
  3178. };
  3179. /**
  3180. * Assert object's properties type
  3181. *
  3182. * @param {object} options
  3183. * @param {object} schema
  3184. * @param {boolean?} allowUnknown
  3185. *
  3186. * @returns {object}
  3187. */
  3188. function assertOptions(options, schema, allowUnknown) {
  3189. if (typeof options !== 'object') {
  3190. throw new AxiosError('options must be an object', AxiosError.ERR_BAD_OPTION_VALUE);
  3191. }
  3192. const keys = Object.keys(options);
  3193. let i = keys.length;
  3194. while (i-- > 0) {
  3195. const opt = keys[i];
  3196. const validator = schema[opt];
  3197. if (validator) {
  3198. const value = options[opt];
  3199. const result = value === undefined || validator(value, opt, options);
  3200. if (result !== true) {
  3201. throw new AxiosError('option ' + opt + ' must be ' + result, AxiosError.ERR_BAD_OPTION_VALUE);
  3202. }
  3203. continue;
  3204. }
  3205. if (allowUnknown !== true) {
  3206. throw new AxiosError('Unknown option ' + opt, AxiosError.ERR_BAD_OPTION);
  3207. }
  3208. }
  3209. }
  3210. const validator = {
  3211. assertOptions,
  3212. validators: validators$1
  3213. };
  3214. const validators = validator.validators;
  3215. /**
  3216. * Create a new instance of Axios
  3217. *
  3218. * @param {Object} instanceConfig The default config for the instance
  3219. *
  3220. * @return {Axios} A new instance of Axios
  3221. */
  3222. class Axios {
  3223. constructor(instanceConfig) {
  3224. this.defaults = instanceConfig;
  3225. this.interceptors = {
  3226. request: new InterceptorManager$1(),
  3227. response: new InterceptorManager$1()
  3228. };
  3229. }
  3230. /**
  3231. * Dispatch a request
  3232. *
  3233. * @param {String|Object} configOrUrl The config specific for this request (merged with this.defaults)
  3234. * @param {?Object} config
  3235. *
  3236. * @returns {Promise} The Promise to be fulfilled
  3237. */
  3238. request(configOrUrl, config) {
  3239. /*eslint no-param-reassign:0*/
  3240. // Allow for axios('example/url'[, config]) a la fetch API
  3241. if (typeof configOrUrl === 'string') {
  3242. config = config || {};
  3243. config.url = configOrUrl;
  3244. } else {
  3245. config = configOrUrl || {};
  3246. }
  3247. config = mergeConfig(this.defaults, config);
  3248. const {transitional, paramsSerializer, headers} = config;
  3249. if (transitional !== undefined) {
  3250. validator.assertOptions(transitional, {
  3251. silentJSONParsing: validators.transitional(validators.boolean),
  3252. forcedJSONParsing: validators.transitional(validators.boolean),
  3253. clarifyTimeoutError: validators.transitional(validators.boolean)
  3254. }, false);
  3255. }
  3256. if (paramsSerializer != null) {
  3257. if (utils$1.isFunction(paramsSerializer)) {
  3258. config.paramsSerializer = {
  3259. serialize: paramsSerializer
  3260. };
  3261. } else {
  3262. validator.assertOptions(paramsSerializer, {
  3263. encode: validators.function,
  3264. serialize: validators.function
  3265. }, true);
  3266. }
  3267. }
  3268. // Set config.method
  3269. config.method = (config.method || this.defaults.method || 'get').toLowerCase();
  3270. // Flatten headers
  3271. let contextHeaders = headers && utils$1.merge(
  3272. headers.common,
  3273. headers[config.method]
  3274. );
  3275. headers && utils$1.forEach(
  3276. ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
  3277. (method) => {
  3278. delete headers[method];
  3279. }
  3280. );
  3281. config.headers = AxiosHeaders$1.concat(contextHeaders, headers);
  3282. // filter out skipped interceptors
  3283. const requestInterceptorChain = [];
  3284. let synchronousRequestInterceptors = true;
  3285. this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
  3286. if (typeof interceptor.runWhen === 'function' && interceptor.runWhen(config) === false) {
  3287. return;
  3288. }
  3289. synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
  3290. requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
  3291. });
  3292. const responseInterceptorChain = [];
  3293. this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
  3294. responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
  3295. });
  3296. let promise;
  3297. let i = 0;
  3298. let len;
  3299. if (!synchronousRequestInterceptors) {
  3300. const chain = [dispatchRequest.bind(this), undefined];
  3301. chain.unshift.apply(chain, requestInterceptorChain);
  3302. chain.push.apply(chain, responseInterceptorChain);
  3303. len = chain.length;
  3304. promise = Promise.resolve(config);
  3305. while (i < len) {
  3306. promise = promise.then(chain[i++], chain[i++]);
  3307. }
  3308. return promise;
  3309. }
  3310. len = requestInterceptorChain.length;
  3311. let newConfig = config;
  3312. i = 0;
  3313. while (i < len) {
  3314. const onFulfilled = requestInterceptorChain[i++];
  3315. const onRejected = requestInterceptorChain[i++];
  3316. try {
  3317. newConfig = onFulfilled(newConfig);
  3318. } catch (error) {
  3319. onRejected.call(this, error);
  3320. break;
  3321. }
  3322. }
  3323. try {
  3324. promise = dispatchRequest.call(this, newConfig);
  3325. } catch (error) {
  3326. return Promise.reject(error);
  3327. }
  3328. i = 0;
  3329. len = responseInterceptorChain.length;
  3330. while (i < len) {
  3331. promise = promise.then(responseInterceptorChain[i++], responseInterceptorChain[i++]);
  3332. }
  3333. return promise;
  3334. }
  3335. getUri(config) {
  3336. config = mergeConfig(this.defaults, config);
  3337. const fullPath = buildFullPath(config.baseURL, config.url);
  3338. return buildURL(fullPath, config.params, config.paramsSerializer);
  3339. }
  3340. }
  3341. // Provide aliases for supported request methods
  3342. utils$1.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
  3343. /*eslint func-names:0*/
  3344. Axios.prototype[method] = function(url, config) {
  3345. return this.request(mergeConfig(config || {}, {
  3346. method,
  3347. url,
  3348. data: (config || {}).data
  3349. }));
  3350. };
  3351. });
  3352. utils$1.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
  3353. /*eslint func-names:0*/
  3354. function generateHTTPMethod(isForm) {
  3355. return function httpMethod(url, data, config) {
  3356. return this.request(mergeConfig(config || {}, {
  3357. method,
  3358. headers: isForm ? {
  3359. 'Content-Type': 'multipart/form-data'
  3360. } : {},
  3361. url,
  3362. data
  3363. }));
  3364. };
  3365. }
  3366. Axios.prototype[method] = generateHTTPMethod();
  3367. Axios.prototype[method + 'Form'] = generateHTTPMethod(true);
  3368. });
  3369. const Axios$1 = Axios;
  3370. /**
  3371. * A `CancelToken` is an object that can be used to request cancellation of an operation.
  3372. *
  3373. * @param {Function} executor The executor function.
  3374. *
  3375. * @returns {CancelToken}
  3376. */
  3377. class CancelToken {
  3378. constructor(executor) {
  3379. if (typeof executor !== 'function') {
  3380. throw new TypeError('executor must be a function.');
  3381. }
  3382. let resolvePromise;
  3383. this.promise = new Promise(function promiseExecutor(resolve) {
  3384. resolvePromise = resolve;
  3385. });
  3386. const token = this;
  3387. // eslint-disable-next-line func-names
  3388. this.promise.then(cancel => {
  3389. if (!token._listeners) return;
  3390. let i = token._listeners.length;
  3391. while (i-- > 0) {
  3392. token._listeners[i](cancel);
  3393. }
  3394. token._listeners = null;
  3395. });
  3396. // eslint-disable-next-line func-names
  3397. this.promise.then = onfulfilled => {
  3398. let _resolve;
  3399. // eslint-disable-next-line func-names
  3400. const promise = new Promise(resolve => {
  3401. token.subscribe(resolve);
  3402. _resolve = resolve;
  3403. }).then(onfulfilled);
  3404. promise.cancel = function reject() {
  3405. token.unsubscribe(_resolve);
  3406. };
  3407. return promise;
  3408. };
  3409. executor(function cancel(message, config, request) {
  3410. if (token.reason) {
  3411. // Cancellation has already been requested
  3412. return;
  3413. }
  3414. token.reason = new CanceledError(message, config, request);
  3415. resolvePromise(token.reason);
  3416. });
  3417. }
  3418. /**
  3419. * Throws a `CanceledError` if cancellation has been requested.
  3420. */
  3421. throwIfRequested() {
  3422. if (this.reason) {
  3423. throw this.reason;
  3424. }
  3425. }
  3426. /**
  3427. * Subscribe to the cancel signal
  3428. */
  3429. subscribe(listener) {
  3430. if (this.reason) {
  3431. listener(this.reason);
  3432. return;
  3433. }
  3434. if (this._listeners) {
  3435. this._listeners.push(listener);
  3436. } else {
  3437. this._listeners = [listener];
  3438. }
  3439. }
  3440. /**
  3441. * Unsubscribe from the cancel signal
  3442. */
  3443. unsubscribe(listener) {
  3444. if (!this._listeners) {
  3445. return;
  3446. }
  3447. const index = this._listeners.indexOf(listener);
  3448. if (index !== -1) {
  3449. this._listeners.splice(index, 1);
  3450. }
  3451. }
  3452. /**
  3453. * Returns an object that contains a new `CancelToken` and a function that, when called,
  3454. * cancels the `CancelToken`.
  3455. */
  3456. static source() {
  3457. let cancel;
  3458. const token = new CancelToken(function executor(c) {
  3459. cancel = c;
  3460. });
  3461. return {
  3462. token,
  3463. cancel
  3464. };
  3465. }
  3466. }
  3467. const CancelToken$1 = CancelToken;
  3468. /**
  3469. * Syntactic sugar for invoking a function and expanding an array for arguments.
  3470. *
  3471. * Common use case would be to use `Function.prototype.apply`.
  3472. *
  3473. * ```js
  3474. * function f(x, y, z) {}
  3475. * var args = [1, 2, 3];
  3476. * f.apply(null, args);
  3477. * ```
  3478. *
  3479. * With `spread` this example can be re-written.
  3480. *
  3481. * ```js
  3482. * spread(function(x, y, z) {})([1, 2, 3]);
  3483. * ```
  3484. *
  3485. * @param {Function} callback
  3486. *
  3487. * @returns {Function}
  3488. */
  3489. function spread(callback) {
  3490. return function wrap(arr) {
  3491. return callback.apply(null, arr);
  3492. };
  3493. }
  3494. /**
  3495. * Determines whether the payload is an error thrown by Axios
  3496. *
  3497. * @param {*} payload The value to test
  3498. *
  3499. * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
  3500. */
  3501. function isAxiosError(payload) {
  3502. return utils$1.isObject(payload) && (payload.isAxiosError === true);
  3503. }
  3504. const HttpStatusCode = {
  3505. Continue: 100,
  3506. SwitchingProtocols: 101,
  3507. Processing: 102,
  3508. EarlyHints: 103,
  3509. Ok: 200,
  3510. Created: 201,
  3511. Accepted: 202,
  3512. NonAuthoritativeInformation: 203,
  3513. NoContent: 204,
  3514. ResetContent: 205,
  3515. PartialContent: 206,
  3516. MultiStatus: 207,
  3517. AlreadyReported: 208,
  3518. ImUsed: 226,
  3519. MultipleChoices: 300,
  3520. MovedPermanently: 301,
  3521. Found: 302,
  3522. SeeOther: 303,
  3523. NotModified: 304,
  3524. UseProxy: 305,
  3525. Unused: 306,
  3526. TemporaryRedirect: 307,
  3527. PermanentRedirect: 308,
  3528. BadRequest: 400,
  3529. Unauthorized: 401,
  3530. PaymentRequired: 402,
  3531. Forbidden: 403,
  3532. NotFound: 404,
  3533. MethodNotAllowed: 405,
  3534. NotAcceptable: 406,
  3535. ProxyAuthenticationRequired: 407,
  3536. RequestTimeout: 408,
  3537. Conflict: 409,
  3538. Gone: 410,
  3539. LengthRequired: 411,
  3540. PreconditionFailed: 412,
  3541. PayloadTooLarge: 413,
  3542. UriTooLong: 414,
  3543. UnsupportedMediaType: 415,
  3544. RangeNotSatisfiable: 416,
  3545. ExpectationFailed: 417,
  3546. ImATeapot: 418,
  3547. MisdirectedRequest: 421,
  3548. UnprocessableEntity: 422,
  3549. Locked: 423,
  3550. FailedDependency: 424,
  3551. TooEarly: 425,
  3552. UpgradeRequired: 426,
  3553. PreconditionRequired: 428,
  3554. TooManyRequests: 429,
  3555. RequestHeaderFieldsTooLarge: 431,
  3556. UnavailableForLegalReasons: 451,
  3557. InternalServerError: 500,
  3558. NotImplemented: 501,
  3559. BadGateway: 502,
  3560. ServiceUnavailable: 503,
  3561. GatewayTimeout: 504,
  3562. HttpVersionNotSupported: 505,
  3563. VariantAlsoNegotiates: 506,
  3564. InsufficientStorage: 507,
  3565. LoopDetected: 508,
  3566. NotExtended: 510,
  3567. NetworkAuthenticationRequired: 511,
  3568. };
  3569. Object.entries(HttpStatusCode).forEach(([key, value]) => {
  3570. HttpStatusCode[value] = key;
  3571. });
  3572. const HttpStatusCode$1 = HttpStatusCode;
  3573. /**
  3574. * Create an instance of Axios
  3575. *
  3576. * @param {Object} defaultConfig The default config for the instance
  3577. *
  3578. * @returns {Axios} A new instance of Axios
  3579. */
  3580. function createInstance(defaultConfig) {
  3581. const context = new Axios$1(defaultConfig);
  3582. const instance = bind(Axios$1.prototype.request, context);
  3583. // Copy axios.prototype to instance
  3584. utils$1.extend(instance, Axios$1.prototype, context, {allOwnKeys: true});
  3585. // Copy context to instance
  3586. utils$1.extend(instance, context, null, {allOwnKeys: true});
  3587. // Factory for creating new instances
  3588. instance.create = function create(instanceConfig) {
  3589. return createInstance(mergeConfig(defaultConfig, instanceConfig));
  3590. };
  3591. return instance;
  3592. }
  3593. // Create the default instance to be exported
  3594. const axios = createInstance(defaults$1);
  3595. // Expose Axios class to allow class inheritance
  3596. axios.Axios = Axios$1;
  3597. // Expose Cancel & CancelToken
  3598. axios.CanceledError = CanceledError;
  3599. axios.CancelToken = CancelToken$1;
  3600. axios.isCancel = isCancel;
  3601. axios.VERSION = VERSION;
  3602. axios.toFormData = toFormData;
  3603. // Expose AxiosError class
  3604. axios.AxiosError = AxiosError;
  3605. // alias for CanceledError for backward compatibility
  3606. axios.Cancel = axios.CanceledError;
  3607. // Expose all/spread
  3608. axios.all = function all(promises) {
  3609. return Promise.all(promises);
  3610. };
  3611. axios.spread = spread;
  3612. // Expose isAxiosError
  3613. axios.isAxiosError = isAxiosError;
  3614. // Expose mergeConfig
  3615. axios.mergeConfig = mergeConfig;
  3616. axios.AxiosHeaders = AxiosHeaders$1;
  3617. axios.formToJSON = thing => formDataToJSON(utils$1.isHTMLForm(thing) ? new FormData(thing) : thing);
  3618. axios.getAdapter = adapters.getAdapter;
  3619. axios.HttpStatusCode = HttpStatusCode$1;
  3620. axios.default = axios;
  3621. module.exports = axios;
  3622. //# sourceMappingURL=axios.cjs.map