@harnessio/ff-nodejs-server-sdk
Advanced tools
Comparing version 1.3.6 to 1.3.7-rc.1
@@ -1,2 +0,2 @@ | ||
"use strict";var Ht=Object.create;var ie=Object.defineProperty;var Wt=Object.getOwnPropertyDescriptor;var Yt=Object.getOwnPropertyNames;var Qt=Object.getPrototypeOf,Jt=Object.prototype.hasOwnProperty;var Q=(s,e)=>()=>(e||s((e={exports:{}}).exports,e),e.exports),Ne=(s,e)=>{for(var t in e)ie(s,t,{get:e[t],enumerable:!0})},Ue=(s,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Yt(e))!Jt.call(s,r)&&r!==t&&ie(s,r,{get:()=>e[r],enumerable:!(i=Wt(e,r))||i.enumerable});return s};var P=(s,e,t)=>(t=s!=null?Ht(Qt(s)):{},Ue(e||!s||!s.__esModule?ie(t,"default",{value:s,enumerable:!0}):t,s)),Xt=s=>Ue(ie({},"__esModule",{value:!0}),s);var qe=Q((_i,ze)=>{"use strict";function ve(s){this.message=s}ve.prototype=new Error,ve.prototype.name="InvalidCharacterError";var Ve=typeof window<"u"&&window.atob&&window.atob.bind(window)||function(s){var e=String(s).replace(/=+$/,"");if(e.length%4==1)throw new ve("'atob' failed: The string to be decoded is not correctly encoded.");for(var t,i,r=0,n=0,o="";i=e.charAt(n++);~i&&(t=r%4?64*t+i:i,r++%4)?o+=String.fromCharCode(255&t>>(-2*r&6)):0)i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(i);return o};function Zt(s){var e=s.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent(Ve(t).replace(/(.)/g,function(i,r){var n=r.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n}))}(e)}catch{return Ve(e)}}function J(s){this.message=s}function Be(s,e){if(typeof s!="string")throw new J("Invalid token specified");var t=(e=e||{}).header===!0?0:1;try{return JSON.parse(Zt(s.split(".")[t]))}catch(i){throw new J("Invalid token specified: "+i.message)}}J.prototype=new Error,J.prototype.name="InvalidTokenError";var me=Be;me.default=Be,me.InvalidTokenError=J,ze.exports=me});var Ge=Q((Ci,Ke)=>{"use strict";var ei=["ETIMEDOUT","ECONNRESET","EADDRINUSE","ESOCKETTIMEDOUT","ECONNREFUSED","EPIPE","EHOSTUNREACH","EAI_AGAIN"],ti=["ENOTFOUND","ENETUNREACH","UNABLE_TO_GET_ISSUER_CERT","UNABLE_TO_GET_CRL","UNABLE_TO_DECRYPT_CERT_SIGNATURE","UNABLE_TO_DECRYPT_CRL_SIGNATURE","UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY","CERT_SIGNATURE_FAILURE","CRL_SIGNATURE_FAILURE","CERT_NOT_YET_VALID","CERT_HAS_EXPIRED","CRL_NOT_YET_VALID","CRL_HAS_EXPIRED","ERROR_IN_CERT_NOT_BEFORE_FIELD","ERROR_IN_CERT_NOT_AFTER_FIELD","ERROR_IN_CRL_LAST_UPDATE_FIELD","ERROR_IN_CRL_NEXT_UPDATE_FIELD","OUT_OF_MEM","DEPTH_ZERO_SELF_SIGNED_CERT","SELF_SIGNED_CERT_IN_CHAIN","UNABLE_TO_GET_ISSUER_CERT_LOCALLY","UNABLE_TO_VERIFY_LEAF_SIGNATURE","CERT_CHAIN_TOO_LONG","CERT_REVOKED","INVALID_CA","PATH_LENGTH_EXCEEDED","INVALID_PURPOSE","CERT_UNTRUSTED","CERT_REJECTED"];Ke.exports=function(s){return!s||!s.code||ei.indexOf(s.code)!==-1?!0:ti.indexOf(s.code)===-1}});var Ye=Q(L=>{"use strict";Object.defineProperty(L,"__esModule",{value:!0});var ii=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s};L.isNetworkError=Ee;L.isRetryableError=re;L.isSafeRequestError=He;L.isIdempotentRequestError=Se;L.isNetworkOrIdempotentRequestError=Te;L.exponentialDelay=We;L.default=q;var ri=Ge(),si=ni(ri);function ni(s){return s&&s.__esModule?s:{default:s}}var ye="axios-retry";function Ee(s){return!s.response&&!!s.code&&s.code!=="ECONNABORTED"&&(0,si.default)(s)}var $e=["get","head","options"],oi=$e.concat(["put","delete"]);function re(s){return s.code!=="ECONNABORTED"&&(!s.response||s.response.status>=500&&s.response.status<=599)}function He(s){return s.config?re(s)&&$e.indexOf(s.config.method)!==-1:!1}function Se(s){return s.config?re(s)&&oi.indexOf(s.config.method)!==-1:!1}function Te(s){return Ee(s)||Se(s)}function ai(){return 0}function We(){var s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,e=Math.pow(2,s)*100,t=e*.2*Math.random();return e+t}function je(s){var e=s[ye]||{};return e.retryCount=e.retryCount||0,s[ye]=e,e}function li(s,e){return Object.assign({},e,s[ye])}function ci(s,e){s.defaults.agent===e.agent&&delete e.agent,s.defaults.httpAgent===e.httpAgent&&delete e.httpAgent,s.defaults.httpsAgent===e.httpsAgent&&delete e.httpsAgent}async function hi(s,e,t,i){var r=t.retryCount<s&&e(i);if((typeof r>"u"?"undefined":ii(r))==="object")try{return await r,!0}catch{return!1}return r}function q(s,e){s.interceptors.request.use(function(t){var i=je(t);return i.lastRequestTime=Date.now(),t}),s.interceptors.response.use(null,async function(t){var i=t.config;if(!i)return Promise.reject(t);var r=li(i,e),n=r.retries,o=n===void 0?3:n,l=r.retryCondition,h=l===void 0?Te:l,c=r.retryDelay,a=c===void 0?ai:c,f=r.shouldResetTimeout,g=f===void 0?!1:f,p=je(i);if(await hi(o,h,p,t)){p.retryCount+=1;var v=a(p.retryCount,t);if(ci(s,i),!g&&i.timeout&&p.lastRequestTime){var T=Date.now()-p.lastRequestTime;i.timeout=Math.max(i.timeout-T-v,1)}return i.transformRequest=[function(u){return u}],new Promise(function(u){return setTimeout(function(){return u(s(i))},v)})}return Promise.reject(t)})}q.isNetworkError=Ee;q.isSafeRequestError=He;q.isIdempotentRequestError=Se;q.isNetworkOrIdempotentRequestError=Te;q.exponentialDelay=We;q.isRetryableError=re});var Je=Q((Oi,Qe)=>{"use strict";Qe.exports=Ye().default});var zt=Q((Er,Fe)=>{"use strict";(function(){var s=this;let e=o=>new TextEncoder().encode(o);function t(o,l){typeof o=="string"&&(o=e(o));for(var h=o.length,c=l^h,a=0,f;h>=4;)f=o[a]&255|(o[++a]&255)<<8|(o[++a]&255)<<16|(o[++a]&255)<<24,f=(f&65535)*1540483477+(((f>>>16)*1540483477&65535)<<16),f^=f>>>24,f=(f&65535)*1540483477+(((f>>>16)*1540483477&65535)<<16),c=(c&65535)*1540483477+(((c>>>16)*1540483477&65535)<<16)^f,h-=4,++a;switch(h){case 3:c^=(o[a+2]&255)<<16;case 2:c^=(o[a+1]&255)<<8;case 1:c^=o[a]&255,c=(c&65535)*1540483477+(((c>>>16)*1540483477&65535)<<16)}return c^=c>>>13,c=(c&65535)*1540483477+(((c>>>16)*1540483477&65535)<<16),c^=c>>>15,c>>>0}function i(o,l){typeof o=="string"&&(o=e(o));var h,c,a,f,g,p,v,T,u,d;for(h=o.length&3,c=o.length-h,a=l,g=3432918353,v=461845907,d=0;d<c;)u=o[d]&255|(o[++d]&255)<<8|(o[++d]&255)<<16|(o[++d]&255)<<24,++d,u=(u&65535)*g+(((u>>>16)*g&65535)<<16)&4294967295,u=u<<15|u>>>17,u=(u&65535)*v+(((u>>>16)*v&65535)<<16)&4294967295,a^=u,a=a<<13|a>>>19,f=(a&65535)*5+(((a>>>16)*5&65535)<<16)&4294967295,a=(f&65535)+27492+(((f>>>16)+58964&65535)<<16);switch(u=0,h){case 3:u^=(o[d+2]&255)<<16;case 2:u^=(o[d+1]&255)<<8;case 1:u^=o[d]&255,u=(u&65535)*g+(((u>>>16)*g&65535)<<16)&4294967295,u=u<<15|u>>>17,u=(u&65535)*v+(((u>>>16)*v&65535)<<16)&4294967295,a^=u}return a^=o.length,a^=a>>>16,a=(a&65535)*2246822507+(((a>>>16)*2246822507&65535)<<16)&4294967295,a^=a>>>13,a=(a&65535)*3266489909+(((a>>>16)*3266489909&65535)<<16)&4294967295,a^=a>>>16,a>>>0}var r=i;if(r.v2=t,r.v3=i,typeof Fe<"u")Fe.exports=r;else{var n=s.murmur;r.noConflict=function(){return s.murmur=n,r},s.murmur=r}})()});var xi={};Ne(xi,{Client:()=>W,Event:()=>pe,FileStore:()=>H,LRU:()=>Oe,default:()=>wi});module.exports=Xt(xi);var Gt=P(require("events")),jt=P(qe()),ke=P(require("axios")),Le=P(Je());var F=P(require("axios"));var Xe=P(require("axios")),x="http://localhost/api/1.0".replace(/\/+$/,"");var X=class{constructor(e,t=x,i=Xe.default){this.basePath=t;this.axios=i;e&&(this.configuration=e,this.basePath=e.basePath||this.basePath)}},se=class extends Error{constructor(t,i){super(i);this.field=t;this.name="RequiredError"}};var _="https://example.com",R=function(s,e,t){if(t==null)throw new se(e,`Required parameter ${e} was null or undefined when calling ${s}.`)};var k=async function(s,e){if(e&&e.accessToken){let t=typeof e.accessToken=="function"?await e.accessToken():await e.accessToken;s.Authorization="Bearer "+t}};var C=function(s,...e){let t=new URLSearchParams(s.search);for(let i of e)for(let r in i)if(Array.isArray(i[r])){t.delete(r);for(let n of i[r])t.append(r,n)}else t.set(r,i[r]);s.search=t.toString()},Ae=function(s,e,t){let i=typeof s!="string";return(i&&t&&t.isJsonMime?t.isJsonMime(e.headers["Content-Type"]):i)?JSON.stringify(s!==void 0?s:{}):s||""},I=function(s){return s.pathname+s.search+s.hash},O=function(s,e,t,i){return(r=e,n=t)=>{let o={...s.options,url:((i==null?void 0:i.basePath)||n)+s.url};return r.request(o)}};var ui=function(s){return{authenticate:async(e,t={})=>{let i="/client/auth",r=new URL(i,_),n;s&&(n=s.baseOptions);let o={method:"POST",...n,...t},l={},h={};l["Content-Type"]="application/json",C(r,h,t.query);let c=n&&n.headers?n.headers:{};return o.headers={...l,...c,...t.headers},o.data=Ae(e,o,s),{url:I(r),options:o}},getAllSegments:async(e,t,i={})=>{R("getAllSegments","environmentUUID",e);let r="/client/env/{environmentUUID}/target-segments".replace("{environmentUUID}",encodeURIComponent(String(e))),n=new URL(r,_),o;s&&(o=s.baseOptions);let l={method:"GET",...o,...i},h={},c={};await k(h,s),t!==void 0&&(c.cluster=t),C(n,c,i.query);let a=o&&o.headers?o.headers:{};return l.headers={...h,...a,...i.headers},{url:I(n),options:l}},getEvaluationByIdentifier:async(e,t,i,r,n={})=>{R("getEvaluationByIdentifier","environmentUUID",e),R("getEvaluationByIdentifier","feature",t),R("getEvaluationByIdentifier","target",i);let o="/client/env/{environmentUUID}/target/{target}/evaluations/{feature}".replace("{environmentUUID}",encodeURIComponent(String(e))).replace("{feature}",encodeURIComponent(String(t))).replace("{target}",encodeURIComponent(String(i))),l=new URL(o,_),h;s&&(h=s.baseOptions);let c={method:"GET",...h,...n},a={},f={};await k(a,s),r!==void 0&&(f.cluster=r),C(l,f,n.query);let g=h&&h.headers?h.headers:{};return c.headers={...a,...g,...n.headers},{url:I(l),options:c}},getEvaluations:async(e,t,i,r={})=>{R("getEvaluations","environmentUUID",e),R("getEvaluations","target",t);let n="/client/env/{environmentUUID}/target/{target}/evaluations".replace("{environmentUUID}",encodeURIComponent(String(e))).replace("{target}",encodeURIComponent(String(t))),o=new URL(n,_),l;s&&(l=s.baseOptions);let h={method:"GET",...l,...r},c={},a={};await k(c,s),i!==void 0&&(a.cluster=i),C(o,a,r.query);let f=l&&l.headers?l.headers:{};return h.headers={...c,...f,...r.headers},{url:I(o),options:h}},getFeatureConfig:async(e,t,i={})=>{R("getFeatureConfig","environmentUUID",e);let r="/client/env/{environmentUUID}/feature-configs".replace("{environmentUUID}",encodeURIComponent(String(e))),n=new URL(r,_),o;s&&(o=s.baseOptions);let l={method:"GET",...o,...i},h={},c={};await k(h,s),t!==void 0&&(c.cluster=t),C(n,c,i.query);let a=o&&o.headers?o.headers:{};return l.headers={...h,...a,...i.headers},{url:I(n),options:l}},getFeatureConfigByIdentifier:async(e,t,i,r={})=>{R("getFeatureConfigByIdentifier","identifier",e),R("getFeatureConfigByIdentifier","environmentUUID",t);let n="/client/env/{environmentUUID}/feature-configs/{identifier}".replace("{identifier}",encodeURIComponent(String(e))).replace("{environmentUUID}",encodeURIComponent(String(t))),o=new URL(n,_),l;s&&(l=s.baseOptions);let h={method:"GET",...l,...r},c={},a={};await k(c,s),i!==void 0&&(a.cluster=i),C(o,a,r.query);let f=l&&l.headers?l.headers:{};return h.headers={...c,...f,...r.headers},{url:I(o),options:h}},getSegmentByIdentifier:async(e,t,i,r={})=>{R("getSegmentByIdentifier","identifier",e),R("getSegmentByIdentifier","environmentUUID",t);let n="/client/env/{environmentUUID}/target-segments/{identifier}".replace("{identifier}",encodeURIComponent(String(e))).replace("{environmentUUID}",encodeURIComponent(String(t))),o=new URL(n,_),l;s&&(l=s.baseOptions);let h={method:"GET",...l,...r},c={},a={};await k(c,s),i!==void 0&&(a.cluster=i),C(o,a,r.query);let f=l&&l.headers?l.headers:{};return h.headers={...c,...f,...r.headers},{url:I(o),options:h}},stream:async(e,t,i={})=>{R("stream","aPIKey",e);let r="/stream",n=new URL(r,_),o;s&&(o=s.baseOptions);let l={method:"GET",...o,...i},h={},c={};await k(h,s),t!==void 0&&(c.cluster=t),e!=null&&(h["API-Key"]=String(e)),C(n,c,i.query);let a=o&&o.headers?o.headers:{};return l.headers={...h,...a,...i.headers},{url:I(n),options:l}}}},N=function(s){let e=ui(s);return{async authenticate(t,i){let r=await e.authenticate(t,i);return O(r,F.default,x,s)},async getAllSegments(t,i,r){let n=await e.getAllSegments(t,i,r);return O(n,F.default,x,s)},async getEvaluationByIdentifier(t,i,r,n,o){let l=await e.getEvaluationByIdentifier(t,i,r,n,o);return O(l,F.default,x,s)},async getEvaluations(t,i,r,n){let o=await e.getEvaluations(t,i,r,n);return O(o,F.default,x,s)},async getFeatureConfig(t,i,r){let n=await e.getFeatureConfig(t,i,r);return O(n,F.default,x,s)},async getFeatureConfigByIdentifier(t,i,r,n){let o=await e.getFeatureConfigByIdentifier(t,i,r,n);return O(o,F.default,x,s)},async getSegmentByIdentifier(t,i,r,n){let o=await e.getSegmentByIdentifier(t,i,r,n);return O(o,F.default,x,s)},async stream(t,i,r){let n=await e.stream(t,i,r);return O(n,F.default,x,s)}}};var ne=class extends X{authenticate(e,t){return N(this.configuration).authenticate(e,t).then(i=>i(this.axios,this.basePath))}getAllSegments(e,t,i){return N(this.configuration).getAllSegments(e,t,i).then(r=>r(this.axios,this.basePath))}getEvaluationByIdentifier(e,t,i,r,n){return N(this.configuration).getEvaluationByIdentifier(e,t,i,r,n).then(o=>o(this.axios,this.basePath))}getEvaluations(e,t,i,r){return N(this.configuration).getEvaluations(e,t,i,r).then(n=>n(this.axios,this.basePath))}getFeatureConfig(e,t,i){return N(this.configuration).getFeatureConfig(e,t,i).then(r=>r(this.axios,this.basePath))}getFeatureConfigByIdentifier(e,t,i,r){return N(this.configuration).getFeatureConfigByIdentifier(e,t,i,r).then(n=>n(this.axios,this.basePath))}getSegmentByIdentifier(e,t,i,r){return N(this.configuration).getSegmentByIdentifier(e,t,i,r).then(n=>n(this.axios,this.basePath))}stream(e,t,i){return N(this.configuration).stream(e,t,i).then(r=>r(this.axios,this.basePath))}},fi=function(s){return{postMetrics:async(e,t,i,r={})=>{R("postMetrics","environment",e);let n="/metrics/{environment}".replace("{environment}",encodeURIComponent(String(e))),o=new URL(n,_),l;s&&(l=s.baseOptions);let h={method:"POST",...l,...r},c={},a={};await k(c,s),t!==void 0&&(a.cluster=t),c["Content-Type"]="application/json",C(o,a,r.query);let f=l&&l.headers?l.headers:{};return h.headers={...c,...f,...r.headers},h.data=Ae(i,h,s),{url:I(o),options:h}}}},gi=function(s){let e=fi(s);return{async postMetrics(t,i,r,n){let o=await e.postMetrics(t,i,r,n);return O(o,F.default,x,s)}}};var oe=class extends X{postMetrics(e,t,i,r){return gi(this.configuration).postMetrics(e,t,i,r).then(n=>n(this.axios,this.basePath))}};var G=class{constructor(e={}){this.apiKey=e.apiKey,this.username=e.username,this.password=e.password,this.accessToken=e.accessToken,this.basePath=e.basePath,this.baseOptions=e.baseOptions,this.formDataCtor=e.formDataCtor}isJsonMime(e){let t=new RegExp("^(application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(;.*)?$","i");return e!==null&&(t.test(e)||e.toLowerCase()==="application/json-patch+json")}};var ae="1.3.6";var Ze={1e3:"The SDK has successfully initialized",1001:"The SDK has failed to initialize due to an authentication error - defaults will be served",1002:"The SDK has failed to initialize due to a missing or empty API key - defaults will be served",2e3:"Authentication was successful",2001:"Authentication failed with a non-recoverable error",2002:"Authentication attempt failed:",2003:"Authentication failed and max retries have been exceeded",3e3:"Closing SDK",3001:"SDK Closed successfully",4e3:"Polling started, interval:",4001:"Polling stopped",5e3:"SSE stream successfully connected",5001:"SSE stream disconnected, reason:",5002:"SSE event received",5003:"SSE retrying to connect in",5004:"SSE stopped",6e3:"Evaluation successful: ",6001:"Evaluation Failed, returning default variation: ",7e3:"Metrics thread started with request interval:",7001:"Metrics stopped",7002:"Posting metrics failed, reason:",7003:"Metrics posted successfully"};function di(s){return s in Ze?Ze[s]:"Unknown SDK code"}function S(s,e=""){return`SDKCODE:${s}: ${di(s)} ${e}`}function et(s){s.warn(S(1002))}function tt(s,e){e.info(S(4e3,s/1e3+" seconds"))}function be(s){s.info(S(1e3))}function it(s){s.info(S(3e3))}function rt(s){s.info(S(3001))}function Re(s){s.info(S(4001))}function st(s){s.info(S(5e3))}function nt(s){s.debug(S(5002))}function ot(s){s.info(S(5004))}function at(s,e){e.info(S(7e3,s/1e3+" seconds"))}function lt(s){s.info(S(7003))}function ct(s){s.info(S(7001))}function Z(s,e,t,i){i.debug(S(6e3,`result=${s}, flag identifier=${e}, target=${JSON.stringify(t)}`))}function ht(s){s.warn(S(2001))}function ut(s){s.warn(S(1001))}function ft(s,e){e.warn(S(5001,s))}function gt(s,e){e.warn(S(5003,`${s}`))}function dt(s,e){e.warn(S(7002,s))}function D(s,e,t,i){i.warn(S(6001,`default variation used=${t}, flag=${s}, target=${JSON.stringify(e)}`))}var le=class{constructor(e,t,i,r,n,o){this.stopped=!0;this.initialized=!1;this.lastPollTime=0;this.api=i,this.options=r,this.environment=e,this.cluster=t,this.repository=o,this.eventBus=n,this.log=r.logger}poll(){if(this.stopped){this.log.info("PollingProcessor stopped"),Re(this.log);return}let e=new Date().getTime(),t=()=>{let i=new Date().getTime()-e,r=Math.max(this.options.pollInterval-i,0);this.timeout=setTimeout(()=>this.poll(),r)};if(this.lastPollTime>Date.now()-this.options.pollInterval){this.log.info(`Last poll was ${Math.round((Date.now()-this.lastPollTime)/1e3)} seconds ago, skipping flag refresh`),t();return}this.lastPollTime=Date.now(),Promise.all([this.retrieveFlags(),this.retrieveSegments()]).then(()=>{this.initialized||setTimeout(()=>{this.initialized=!0,this.eventBus.emit("poller_ready")},0)}).catch(i=>{this.eventBus.emit("poller_error",{error:i})}).finally(()=>{if(this.stopped){this.log.info("PollingProcessor stopped"),Re(this.log);return}t()})}async retrieveFlags(){try{this.log.debug("Fetching flags started");let e=await this.api.getFeatureConfig(this.environment,this.cluster);this.log.debug("Fetching flags finished"),e.data.forEach(t=>this.repository.setFlag(t.feature,t))}catch(e){throw this.log.error("Error loading flags",e),e}}async retrieveSegments(){try{this.log.debug("Fetching segments started");let e=await this.api.getAllSegments(this.environment,this.cluster);this.log.debug("Fetching segments finished"),e.data.forEach(t=>this.repository.setSegment(t.identifier,t))}catch(e){throw this.log.error("Error loading segments",e),e}}start(){if(!this.stopped){this.log.info("PollingProcessor already started");return}this.log.info("Starting PollingProcessor with request interval: ",this.options.pollInterval),this.stopped=!1,this.poll()}stop(){this.log.info("Stopping PollingProcessor"),this.stopped=!0}close(){this.log.info("Closing PollingProcessor"),this.stop(),clearTimeout(this.timeout),this.log.info("PollingProcessor closed")}};var pt=P(require("https")),mt=P(require("http"));var b=class b{constructor(e,t,i,r,n,o,l,h){this.retryAttempt=0;this.api=e,this.apiKey=t,this.environment=i,this.jwtToken=r,this.options=n,this.cluster=o,this.eventBus=l,this.repository=h,this.log=this.options.logger;let c=5e3,a=1e4;this.retryDelayMs=Math.floor(Math.random()*(a-c)+c)}start(){this.log.info("Starting new StreamProcessor");let e=`${this.options.baseUrl}/stream?cluster=${this.cluster}`,t={headers:{"Cache-Control":"no-cache",Accept:"text/event-stream",Authorization:`Bearer ${this.jwtToken}`,"API-Key":this.apiKey}},i=()=>{this.log.info(`SSE stream connected OK: ${e}`),this.retryAttempt=0,this.readyState=b.CONNECTED,this.eventBus.emit("stream_connected")},r=n=>{if(this.readyState!==b.CLOSED){this.retryAttempt+=1;let o=this.getRandomRetryDelayMs();ft(n,this.log),gt(o,this.log),this.readyState=b.RETRYING,this.eventBus.emit("stream_retrying"),setTimeout(()=>{this.log.info("SSE retrying to connect"),this.connect(e,t,i,r)},o)}};this.connect(e,t,i,r),this.eventBus.emit("stream_ready")}getRandomRetryDelayMs(){let e=this.retryDelayMs*this.retryAttempt;return Math.min(e,6e4)}connect(e,t,i,r){if(this.readyState===b.CONNECTED){this.log.debug("SSE already connected, skip retry");return}let n=e.startsWith("https:");this.log.debug("SSE HTTP start request",e),this.request=(n?pt.default:mt.default).request(e,t,o=>{if(this.log.debug("SSE got HTTP response code",o.statusCode),o.statusCode>=400&&o.statusCode<=599){r(`HTTP code ${o.statusCode}`);return}i(),o.on("data",l=>{nt(this.log),this.processData(l)}).on("close",()=>{r("SSE stream closed")})}).on("error",o=>{r("SSE request failed "+o.message)}).on("timeout",()=>{r("SSE request timed out after "+b.SSE_TIMEOUT_MS+"ms")}).setTimeout(b.SSE_TIMEOUT_MS),this.request.end()}processData(e){e.toString().split(/\r?\n/).forEach(i=>this.processLine(i))}processLine(e){if(e.startsWith("data:")){this.log.debug("SSE GOT:",e.substring(5));let t=JSON.parse(e.substring(5));t.domain==="flag"?this.msgProcessor(t,this.api.getFeatureConfigByIdentifier.bind(this.api),this.repository.setFlag.bind(this.repository),this.repository.deleteFlag.bind(this.repository)):t.domain==="target-segment"&&this.msgProcessor(t,this.api.getSegmentByIdentifier.bind(this.api),this.repository.setSegment.bind(this.repository),this.repository.deleteSegment.bind(this.repository))}}async msgProcessor(e,t,i,r){this.log.info("Processing message",e);try{if(e.event==="create"||e.event==="patch"){let{data:n}=await t(e.identifier,this.environment,this.cluster);i(e.identifier,n)}else e.event==="delete"&&r(e.identifier)}catch(n){throw this.log.error("Error while fetching data with identifier:",e.identifier,n),n}this.log.info("Processing message finished",e)}connected(){return this.readyState===b.CONNECTED}close(){if(this.readyState===b.CLOSED){this.log.info("SteamProcessor already closed");return}this.readyState=b.CLOSED,this.log.info("Closing StreamProcessor"),this.request.destroy(),this.request=void 0,this.eventBus.emit("stream_disconnected"),this.log.info("StreamProcessor closed"),ot(this.log)}};b.CONNECTED=1,b.RETRYING=2,b.CLOSED=3,b.SSE_TIMEOUT_MS=3e4;var ce=b;var Oe={};Ne(Oe,{default:()=>Ie});var ee=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,mi=typeof AbortController=="function",he=mi?AbortController:class{constructor(){this.signal=new vt}abort(e=new Error("This operation was aborted")){this.signal.reason=this.signal.reason||e,this.signal.aborted=!0,this.signal.dispatchEvent({type:"abort",target:this.signal})}},vi=typeof AbortSignal=="function",yi=typeof he.AbortSignal=="function",vt=vi?AbortSignal:yi?he.AbortController:class{constructor(){this.reason=void 0,this.aborted=!1,this._listeners=[]}dispatchEvent(e){e.type==="abort"&&(this.aborted=!0,this.onabort(e),this._listeners.forEach(t=>t(e),this))}onabort(){}addEventListener(e,t){e==="abort"&&this._listeners.push(t)}removeEventListener(e,t){e==="abort"&&(this._listeners=this._listeners.filter(i=>i!==t))}},_e=new Set,we=(s,e)=>{let t=`LRU_CACHE_OPTION_${s}`;ue(t)&&Ce(t,`${s} option`,`options.${e}`,$)},xe=(s,e)=>{let t=`LRU_CACHE_METHOD_${s}`;if(ue(t)){let{prototype:i}=$,{get:r}=Object.getOwnPropertyDescriptor(i,s);Ce(t,`${s} method`,`cache.${e}()`,r)}},Ei=(s,e)=>{let t=`LRU_CACHE_PROPERTY_${s}`;if(ue(t)){let{prototype:i}=$,{get:r}=Object.getOwnPropertyDescriptor(i,s);Ce(t,`${s} property`,`cache.${e}`,r)}},yt=(...s)=>{typeof process=="object"&&process&&typeof process.emitWarning=="function"?process.emitWarning(...s):console.error(...s)},ue=s=>!_e.has(s),Ce=(s,e,t,i)=>{_e.add(s);let r=`The ${e} is deprecated. Please use ${t} instead.`;yt(r,"DeprecationWarning",s,i)},U=s=>s&&s===Math.floor(s)&&s>0&&isFinite(s),Et=s=>U(s)?s<=Math.pow(2,8)?Uint8Array:s<=Math.pow(2,16)?Uint16Array:s<=Math.pow(2,32)?Uint32Array:s<=Number.MAX_SAFE_INTEGER?j:null:null,j=class extends Array{constructor(e){super(e),this.fill(0)}},Pe=class{constructor(e){if(e===0)return[];let t=Et(e);this.heap=new t(e),this.length=0}push(e){this.heap[this.length++]=e}pop(){return this.heap[--this.length]}},$=class s{constructor(e={}){let{max:t=0,ttl:i,ttlResolution:r=1,ttlAutopurge:n,updateAgeOnGet:o,updateAgeOnHas:l,allowStale:h,dispose:c,disposeAfter:a,noDisposeOnSet:f,noUpdateTTL:g,maxSize:p=0,maxEntrySize:v=0,sizeCalculation:T,fetchMethod:u,fetchContext:d,noDeleteOnFetchRejection:E,noDeleteOnStaleGet:A,allowStaleOnFetchRejection:y,allowStaleOnFetchAbort:w,ignoreFetchAbort:m}=e,{length:B,maxAge:z,stale:M}=e instanceof s?{}:e;if(t!==0&&!U(t))throw new TypeError("max option must be a nonnegative integer");let K=t?Et(t):Array;if(!K)throw new Error("invalid max value: "+t);if(this.max=t,this.maxSize=p,this.maxEntrySize=v||this.maxSize,this.sizeCalculation=T||B,this.sizeCalculation){if(!this.maxSize&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(this.fetchMethod=u||null,this.fetchMethod&&typeof this.fetchMethod!="function")throw new TypeError("fetchMethod must be a function if specified");if(this.fetchContext=d,!this.fetchMethod&&d!==void 0)throw new TypeError("cannot set fetchContext without fetchMethod");if(this.keyMap=new Map,this.keyList=new Array(t).fill(null),this.valList=new Array(t).fill(null),this.next=new K(t),this.prev=new K(t),this.head=0,this.tail=0,this.free=new Pe(t),this.initialFill=1,this.size=0,typeof c=="function"&&(this.dispose=c),typeof a=="function"?(this.disposeAfter=a,this.disposed=[]):(this.disposeAfter=null,this.disposed=null),this.noDisposeOnSet=!!f,this.noUpdateTTL=!!g,this.noDeleteOnFetchRejection=!!E,this.allowStaleOnFetchRejection=!!y,this.allowStaleOnFetchAbort=!!w,this.ignoreFetchAbort=!!m,this.maxEntrySize!==0){if(this.maxSize!==0&&!U(this.maxSize))throw new TypeError("maxSize must be a positive integer if specified");if(!U(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.initializeSizeTracking()}if(this.allowStale=!!h||!!M,this.noDeleteOnStaleGet=!!A,this.updateAgeOnGet=!!o,this.updateAgeOnHas=!!l,this.ttlResolution=U(r)||r===0?r:1,this.ttlAutopurge=!!n,this.ttl=i||z||0,this.ttl){if(!U(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.initializeTTLTracking()}if(this.max===0&&this.ttl===0&&this.maxSize===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.max&&!this.maxSize){let Y="LRU_CACHE_UNBOUNDED";ue(Y)&&(_e.add(Y),yt("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",Y,s))}M&&we("stale","allowStale"),z&&we("maxAge","ttl"),B&&we("length","sizeCalculation")}getRemainingTTL(e){return this.has(e,{updateAgeOnHas:!1})?1/0:0}initializeTTLTracking(){this.ttls=new j(this.max),this.starts=new j(this.max),this.setItemTTL=(i,r,n=ee.now())=>{if(this.starts[i]=r!==0?n:0,this.ttls[i]=r,r!==0&&this.ttlAutopurge){let o=setTimeout(()=>{this.isStale(i)&&this.delete(this.keyList[i])},r+1);o.unref&&o.unref()}},this.updateItemAge=i=>{this.starts[i]=this.ttls[i]!==0?ee.now():0},this.statusTTL=(i,r)=>{i&&(i.ttl=this.ttls[r],i.start=this.starts[r],i.now=e||t(),i.remainingTTL=i.now+i.ttl-i.start)};let e=0,t=()=>{let i=ee.now();if(this.ttlResolution>0){e=i;let r=setTimeout(()=>e=0,this.ttlResolution);r.unref&&r.unref()}return i};this.getRemainingTTL=i=>{let r=this.keyMap.get(i);return r===void 0?0:this.ttls[r]===0||this.starts[r]===0?1/0:this.starts[r]+this.ttls[r]-(e||t())},this.isStale=i=>this.ttls[i]!==0&&this.starts[i]!==0&&(e||t())-this.starts[i]>this.ttls[i]}updateItemAge(e){}statusTTL(e,t){}setItemTTL(e,t,i){}isStale(e){return!1}initializeSizeTracking(){this.calculatedSize=0,this.sizes=new j(this.max),this.removeItemSize=e=>{this.calculatedSize-=this.sizes[e],this.sizes[e]=0},this.requireSize=(e,t,i,r)=>{if(this.isBackgroundFetch(t))return 0;if(!U(i))if(r){if(typeof r!="function")throw new TypeError("sizeCalculation must be a function");if(i=r(t,e),!U(i))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return i},this.addItemSize=(e,t,i)=>{if(this.sizes[e]=t,this.maxSize){let r=this.maxSize-this.sizes[e];for(;this.calculatedSize>r;)this.evict(!0)}this.calculatedSize+=this.sizes[e],i&&(i.entrySize=t,i.totalCalculatedSize=this.calculatedSize)}}removeItemSize(e){}addItemSize(e,t){}requireSize(e,t,i,r){if(i||r)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache")}*indexes({allowStale:e=this.allowStale}={}){if(this.size)for(let t=this.tail;!(!this.isValidIndex(t)||((e||!this.isStale(t))&&(yield t),t===this.head));)t=this.prev[t]}*rindexes({allowStale:e=this.allowStale}={}){if(this.size)for(let t=this.head;!(!this.isValidIndex(t)||((e||!this.isStale(t))&&(yield t),t===this.tail));)t=this.next[t]}isValidIndex(e){return e!==void 0&&this.keyMap.get(this.keyList[e])===e}*entries(){for(let e of this.indexes())this.valList[e]!==void 0&&this.keyList[e]!==void 0&&!this.isBackgroundFetch(this.valList[e])&&(yield[this.keyList[e],this.valList[e]])}*rentries(){for(let e of this.rindexes())this.valList[e]!==void 0&&this.keyList[e]!==void 0&&!this.isBackgroundFetch(this.valList[e])&&(yield[this.keyList[e],this.valList[e]])}*keys(){for(let e of this.indexes())this.keyList[e]!==void 0&&!this.isBackgroundFetch(this.valList[e])&&(yield this.keyList[e])}*rkeys(){for(let e of this.rindexes())this.keyList[e]!==void 0&&!this.isBackgroundFetch(this.valList[e])&&(yield this.keyList[e])}*values(){for(let e of this.indexes())this.valList[e]!==void 0&&!this.isBackgroundFetch(this.valList[e])&&(yield this.valList[e])}*rvalues(){for(let e of this.rindexes())this.valList[e]!==void 0&&!this.isBackgroundFetch(this.valList[e])&&(yield this.valList[e])}[Symbol.iterator](){return this.entries()}find(e,t){for(let i of this.indexes()){let r=this.valList[i],n=this.isBackgroundFetch(r)?r.__staleWhileFetching:r;if(n!==void 0&&e(n,this.keyList[i],this))return this.get(this.keyList[i],t)}}forEach(e,t=this){for(let i of this.indexes()){let r=this.valList[i],n=this.isBackgroundFetch(r)?r.__staleWhileFetching:r;n!==void 0&&e.call(t,n,this.keyList[i],this)}}rforEach(e,t=this){for(let i of this.rindexes()){let r=this.valList[i],n=this.isBackgroundFetch(r)?r.__staleWhileFetching:r;n!==void 0&&e.call(t,n,this.keyList[i],this)}}get prune(){return xe("prune","purgeStale"),this.purgeStale}purgeStale(){let e=!1;for(let t of this.rindexes({allowStale:!0}))this.isStale(t)&&(this.delete(this.keyList[t]),e=!0);return e}dump(){let e=[];for(let t of this.indexes({allowStale:!0})){let i=this.keyList[t],r=this.valList[t],n=this.isBackgroundFetch(r)?r.__staleWhileFetching:r;if(n===void 0)continue;let o={value:n};if(this.ttls){o.ttl=this.ttls[t];let l=ee.now()-this.starts[t];o.start=Math.floor(Date.now()-l)}this.sizes&&(o.size=this.sizes[t]),e.unshift([i,o])}return e}load(e){this.clear();for(let[t,i]of e){if(i.start){let r=Date.now()-i.start;i.start=ee.now()-r}this.set(t,i.value,i)}}dispose(e,t,i){}set(e,t,{ttl:i=this.ttl,start:r,noDisposeOnSet:n=this.noDisposeOnSet,size:o=0,sizeCalculation:l=this.sizeCalculation,noUpdateTTL:h=this.noUpdateTTL,status:c}={}){if(o=this.requireSize(e,t,o,l),this.maxEntrySize&&o>this.maxEntrySize)return c&&(c.set="miss",c.maxEntrySizeExceeded=!0),this.delete(e),this;let a=this.size===0?void 0:this.keyMap.get(e);if(a===void 0)a=this.newIndex(),this.keyList[a]=e,this.valList[a]=t,this.keyMap.set(e,a),this.next[this.tail]=a,this.prev[a]=this.tail,this.tail=a,this.size++,this.addItemSize(a,o,c),c&&(c.set="add"),h=!1;else{this.moveToTail(a);let f=this.valList[a];if(t!==f){if(this.isBackgroundFetch(f)?f.__abortController.abort(new Error("replaced")):n||(this.dispose(f,e,"set"),this.disposeAfter&&this.disposed.push([f,e,"set"])),this.removeItemSize(a),this.valList[a]=t,this.addItemSize(a,o,c),c){c.set="replace";let g=f&&this.isBackgroundFetch(f)?f.__staleWhileFetching:f;g!==void 0&&(c.oldValue=g)}}else c&&(c.set="update")}if(i!==0&&this.ttl===0&&!this.ttls&&this.initializeTTLTracking(),h||this.setItemTTL(a,i,r),this.statusTTL(c,a),this.disposeAfter)for(;this.disposed.length;)this.disposeAfter(...this.disposed.shift());return this}newIndex(){return this.size===0?this.tail:this.size===this.max&&this.max!==0?this.evict(!1):this.free.length!==0?this.free.pop():this.initialFill++}pop(){if(this.size){let e=this.valList[this.head];return this.evict(!0),e}}evict(e){let t=this.head,i=this.keyList[t],r=this.valList[t];return this.isBackgroundFetch(r)?r.__abortController.abort(new Error("evicted")):(this.dispose(r,i,"evict"),this.disposeAfter&&this.disposed.push([r,i,"evict"])),this.removeItemSize(t),e&&(this.keyList[t]=null,this.valList[t]=null,this.free.push(t)),this.head=this.next[t],this.keyMap.delete(i),this.size--,t}has(e,{updateAgeOnHas:t=this.updateAgeOnHas,status:i}={}){let r=this.keyMap.get(e);if(r!==void 0)if(this.isStale(r))i&&(i.has="stale",this.statusTTL(i,r));else return t&&this.updateItemAge(r),i&&(i.has="hit"),this.statusTTL(i,r),!0;else i&&(i.has="miss");return!1}peek(e,{allowStale:t=this.allowStale}={}){let i=this.keyMap.get(e);if(i!==void 0&&(t||!this.isStale(i))){let r=this.valList[i];return this.isBackgroundFetch(r)?r.__staleWhileFetching:r}}backgroundFetch(e,t,i,r){let n=t===void 0?void 0:this.valList[t];if(this.isBackgroundFetch(n))return n;let o=new he;i.signal&&i.signal.addEventListener("abort",()=>o.abort(i.signal.reason));let l={signal:o.signal,options:i,context:r},h=(p,v=!1)=>{let{aborted:T}=o.signal,u=i.ignoreFetchAbort&&p!==void 0;return i.status&&(T&&!v?(i.status.fetchAborted=!0,i.status.fetchError=o.signal.reason,u&&(i.status.fetchAbortIgnored=!0)):i.status.fetchResolved=!0),T&&!u&&!v?a(o.signal.reason):(this.valList[t]===g&&(p===void 0?g.__staleWhileFetching?this.valList[t]=g.__staleWhileFetching:this.delete(e):(i.status&&(i.status.fetchUpdated=!0),this.set(e,p,l.options))),p)},c=p=>(i.status&&(i.status.fetchRejected=!0,i.status.fetchError=p),a(p)),a=p=>{let{aborted:v}=o.signal,T=v&&i.allowStaleOnFetchAbort,u=T||i.allowStaleOnFetchRejection,d=u||i.noDeleteOnFetchRejection;if(this.valList[t]===g&&(!d||g.__staleWhileFetching===void 0?this.delete(e):T||(this.valList[t]=g.__staleWhileFetching)),u)return i.status&&g.__staleWhileFetching!==void 0&&(i.status.returnedStale=!0),g.__staleWhileFetching;if(g.__returned===g)throw p},f=(p,v)=>{this.fetchMethod(e,n,l).then(T=>p(T),v),o.signal.addEventListener("abort",()=>{(!i.ignoreFetchAbort||i.allowStaleOnFetchAbort)&&(p(),i.allowStaleOnFetchAbort&&(p=T=>h(T,!0)))})};i.status&&(i.status.fetchDispatched=!0);let g=new Promise(f).then(h,c);return g.__abortController=o,g.__staleWhileFetching=n,g.__returned=null,t===void 0?(this.set(e,g,{...l.options,status:void 0}),t=this.keyMap.get(e)):this.valList[t]=g,g}isBackgroundFetch(e){return e&&typeof e=="object"&&typeof e.then=="function"&&Object.prototype.hasOwnProperty.call(e,"__staleWhileFetching")&&Object.prototype.hasOwnProperty.call(e,"__returned")&&(e.__returned===e||e.__returned===null)}async fetch(e,{allowStale:t=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:r=this.noDeleteOnStaleGet,ttl:n=this.ttl,noDisposeOnSet:o=this.noDisposeOnSet,size:l=0,sizeCalculation:h=this.sizeCalculation,noUpdateTTL:c=this.noUpdateTTL,noDeleteOnFetchRejection:a=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:f=this.allowStaleOnFetchRejection,ignoreFetchAbort:g=this.ignoreFetchAbort,allowStaleOnFetchAbort:p=this.allowStaleOnFetchAbort,fetchContext:v=this.fetchContext,forceRefresh:T=!1,status:u,signal:d}={}){if(!this.fetchMethod)return u&&(u.fetch="get"),this.get(e,{allowStale:t,updateAgeOnGet:i,noDeleteOnStaleGet:r,status:u});let E={allowStale:t,updateAgeOnGet:i,noDeleteOnStaleGet:r,ttl:n,noDisposeOnSet:o,size:l,sizeCalculation:h,noUpdateTTL:c,noDeleteOnFetchRejection:a,allowStaleOnFetchRejection:f,allowStaleOnFetchAbort:p,ignoreFetchAbort:g,status:u,signal:d},A=this.keyMap.get(e);if(A===void 0){u&&(u.fetch="miss");let y=this.backgroundFetch(e,A,E,v);return y.__returned=y}else{let y=this.valList[A];if(this.isBackgroundFetch(y)){let M=t&&y.__staleWhileFetching!==void 0;return u&&(u.fetch="inflight",M&&(u.returnedStale=!0)),M?y.__staleWhileFetching:y.__returned=y}let w=this.isStale(A);if(!T&&!w)return u&&(u.fetch="hit"),this.moveToTail(A),i&&this.updateItemAge(A),this.statusTTL(u,A),y;let m=this.backgroundFetch(e,A,E,v),B=m.__staleWhileFetching!==void 0,z=B&&t;return u&&(u.fetch=B&&w?"stale":"refresh",z&&w&&(u.returnedStale=!0)),z?m.__staleWhileFetching:m.__returned=m}}get(e,{allowStale:t=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:r=this.noDeleteOnStaleGet,status:n}={}){let o=this.keyMap.get(e);if(o!==void 0){let l=this.valList[o],h=this.isBackgroundFetch(l);return this.statusTTL(n,o),this.isStale(o)?(n&&(n.get="stale"),h?(n&&(n.returnedStale=t&&l.__staleWhileFetching!==void 0),t?l.__staleWhileFetching:void 0):(r||this.delete(e),n&&(n.returnedStale=t),t?l:void 0)):(n&&(n.get="hit"),h?l.__staleWhileFetching:(this.moveToTail(o),i&&this.updateItemAge(o),l))}else n&&(n.get="miss")}connect(e,t){this.prev[t]=e,this.next[e]=t}moveToTail(e){e!==this.tail&&(e===this.head?this.head=this.next[e]:this.connect(this.prev[e],this.next[e]),this.connect(this.tail,e),this.tail=e)}get del(){return xe("del","delete"),this.delete}delete(e){let t=!1;if(this.size!==0){let i=this.keyMap.get(e);if(i!==void 0)if(t=!0,this.size===1)this.clear();else{this.removeItemSize(i);let r=this.valList[i];this.isBackgroundFetch(r)?r.__abortController.abort(new Error("deleted")):(this.dispose(r,e,"delete"),this.disposeAfter&&this.disposed.push([r,e,"delete"])),this.keyMap.delete(e),this.keyList[i]=null,this.valList[i]=null,i===this.tail?this.tail=this.prev[i]:i===this.head?this.head=this.next[i]:(this.next[this.prev[i]]=this.next[i],this.prev[this.next[i]]=this.prev[i]),this.size--,this.free.push(i)}}if(this.disposed)for(;this.disposed.length;)this.disposeAfter(...this.disposed.shift());return t}clear(){for(let e of this.rindexes({allowStale:!0})){let t=this.valList[e];if(this.isBackgroundFetch(t))t.__abortController.abort(new Error("deleted"));else{let i=this.keyList[e];this.dispose(t,i,"delete"),this.disposeAfter&&this.disposed.push([t,i,"delete"])}}if(this.keyMap.clear(),this.valList.fill(null),this.keyList.fill(null),this.ttls&&(this.ttls.fill(0),this.starts.fill(0)),this.sizes&&this.sizes.fill(0),this.head=0,this.tail=0,this.initialFill=1,this.free.length=0,this.calculatedSize=0,this.size=0,this.disposed)for(;this.disposed.length;)this.disposeAfter(...this.disposed.shift())}get reset(){return xe("reset","clear"),this.clear}get length(){return Ei("length","size"),this.size}static get AbortController(){return he}static get AbortSignal(){return vt}},Ie=$;var fe=class{trace(e,...t){console.trace(e,...t)}debug(e,...t){console.debug(e,...t)}info(e,...t){console.info(e,...t)}warn(e,...t){console.warn(e,...t)}error(e,...t){console.error(e,...t)}};var St=P(require("keyv")),Tt=require("keyv-file"),H=class{constructor(e={}){this.keyvFile=new Tt.KeyvFile(e),this.keyv=new St.default({store:this.keyvFile})}set(e,t){return this.keyv.set(e,t)}get(e){return this.keyv.get(e)}del(e){return this.keyv.delete(e)}keys(){return Promise.resolve(function*(e){for(let t of e)yield t}(this.keyvFile.keys()))}};var At=100;var bt="featureIdentifier",Rt="featureName",wt="variationIdentifier";var xt="target",Pt="SDK_VERSION",_t="SDK_TYPE",Ct="server",It="SDK_LANGUAGE",Ot="javascript",Ft="global",te="segmentMatch",Dt="in",Lt="equal",kt="gt",Mt="starts_with",Nt="ends_with",Ut="contains",Vt="equal_sensitive",Si="https://config.ff.harness.io/api/1.0",Ti="https://events.ff.harness.io/api/1.0",Ai=1e3,Bt=60*Ai,bi=1*Bt,Ri=1*Bt,V={baseUrl:Si,eventsUrl:Ti,pollInterval:bi,eventsSyncInterval:Ri,enableStream:!0,enableAnalytics:!0,cache:new Ie({max:100}),store:new H,logger:new fe};var qt=P(zt());var ge=class{constructor(e,t){this.query=e,this.log=t}getAttrValue(e,t){var i;return e[t]||((i=e.attributes)==null?void 0:i[t])}findVariation(e,t){return e.find(i=>i.identifier===t)}getNormalizedNumberWithNormalizer(e,t,i){let r=[t,e].join(":");return parseInt((0,qt.default)(r).toString())%i+1}getNormalizedNumber(e,t){return this.getNormalizedNumberWithNormalizer(e,t,At)}isEnabled(e,t,i){let r=this.getAttrValue(e,t);if(!r)return!1;let n=this.getNormalizedNumber(r,t);return i>0&&n<=i}evaluateDistribution(e,t){if(!e)return;let i="",r=0;for(let n of e.variations)if(i=n.variation,r+=n.weight,this.isEnabled(t,e.bucketBy,r))return n.variation;return i}async isTargetIncludedOrExcludedInSegment(e,t){var i,r;for(let n of e){let o=await this.query.getSegment(n);if(o){if((i=o.excluded)!=null&&i.find(l=>l.identifier===t.identifier))return this.log.debug(`Target %s excluded from segment %s via exclude list | ||
"use strict";var Ht=Object.create;var ie=Object.defineProperty;var Wt=Object.getOwnPropertyDescriptor;var Yt=Object.getOwnPropertyNames;var Qt=Object.getPrototypeOf,Jt=Object.prototype.hasOwnProperty;var Q=(s,e)=>()=>(e||s((e={exports:{}}).exports,e),e.exports),Ne=(s,e)=>{for(var t in e)ie(s,t,{get:e[t],enumerable:!0})},Ue=(s,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Yt(e))!Jt.call(s,r)&&r!==t&&ie(s,r,{get:()=>e[r],enumerable:!(i=Wt(e,r))||i.enumerable});return s};var P=(s,e,t)=>(t=s!=null?Ht(Qt(s)):{},Ue(e||!s||!s.__esModule?ie(t,"default",{value:s,enumerable:!0}):t,s)),Xt=s=>Ue(ie({},"__esModule",{value:!0}),s);var qe=Q((_i,ze)=>{"use strict";function ve(s){this.message=s}ve.prototype=new Error,ve.prototype.name="InvalidCharacterError";var Ve=typeof window<"u"&&window.atob&&window.atob.bind(window)||function(s){var e=String(s).replace(/=+$/,"");if(e.length%4==1)throw new ve("'atob' failed: The string to be decoded is not correctly encoded.");for(var t,i,r=0,n=0,o="";i=e.charAt(n++);~i&&(t=r%4?64*t+i:i,r++%4)?o+=String.fromCharCode(255&t>>(-2*r&6)):0)i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(i);return o};function Zt(s){var e=s.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent(Ve(t).replace(/(.)/g,function(i,r){var n=r.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n}))}(e)}catch{return Ve(e)}}function J(s){this.message=s}function Be(s,e){if(typeof s!="string")throw new J("Invalid token specified");var t=(e=e||{}).header===!0?0:1;try{return JSON.parse(Zt(s.split(".")[t]))}catch(i){throw new J("Invalid token specified: "+i.message)}}J.prototype=new Error,J.prototype.name="InvalidTokenError";var me=Be;me.default=Be,me.InvalidTokenError=J,ze.exports=me});var Ge=Q((Ci,Ke)=>{"use strict";var ei=["ETIMEDOUT","ECONNRESET","EADDRINUSE","ESOCKETTIMEDOUT","ECONNREFUSED","EPIPE","EHOSTUNREACH","EAI_AGAIN"],ti=["ENOTFOUND","ENETUNREACH","UNABLE_TO_GET_ISSUER_CERT","UNABLE_TO_GET_CRL","UNABLE_TO_DECRYPT_CERT_SIGNATURE","UNABLE_TO_DECRYPT_CRL_SIGNATURE","UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY","CERT_SIGNATURE_FAILURE","CRL_SIGNATURE_FAILURE","CERT_NOT_YET_VALID","CERT_HAS_EXPIRED","CRL_NOT_YET_VALID","CRL_HAS_EXPIRED","ERROR_IN_CERT_NOT_BEFORE_FIELD","ERROR_IN_CERT_NOT_AFTER_FIELD","ERROR_IN_CRL_LAST_UPDATE_FIELD","ERROR_IN_CRL_NEXT_UPDATE_FIELD","OUT_OF_MEM","DEPTH_ZERO_SELF_SIGNED_CERT","SELF_SIGNED_CERT_IN_CHAIN","UNABLE_TO_GET_ISSUER_CERT_LOCALLY","UNABLE_TO_VERIFY_LEAF_SIGNATURE","CERT_CHAIN_TOO_LONG","CERT_REVOKED","INVALID_CA","PATH_LENGTH_EXCEEDED","INVALID_PURPOSE","CERT_UNTRUSTED","CERT_REJECTED"];Ke.exports=function(s){return!s||!s.code||ei.indexOf(s.code)!==-1?!0:ti.indexOf(s.code)===-1}});var Ye=Q(L=>{"use strict";Object.defineProperty(L,"__esModule",{value:!0});var ii=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s};L.isNetworkError=Ee;L.isRetryableError=re;L.isSafeRequestError=He;L.isIdempotentRequestError=Se;L.isNetworkOrIdempotentRequestError=Te;L.exponentialDelay=We;L.default=q;var ri=Ge(),si=ni(ri);function ni(s){return s&&s.__esModule?s:{default:s}}var ye="axios-retry";function Ee(s){return!s.response&&!!s.code&&s.code!=="ECONNABORTED"&&(0,si.default)(s)}var $e=["get","head","options"],oi=$e.concat(["put","delete"]);function re(s){return s.code!=="ECONNABORTED"&&(!s.response||s.response.status>=500&&s.response.status<=599)}function He(s){return s.config?re(s)&&$e.indexOf(s.config.method)!==-1:!1}function Se(s){return s.config?re(s)&&oi.indexOf(s.config.method)!==-1:!1}function Te(s){return Ee(s)||Se(s)}function ai(){return 0}function We(){var s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,e=Math.pow(2,s)*100,t=e*.2*Math.random();return e+t}function je(s){var e=s[ye]||{};return e.retryCount=e.retryCount||0,s[ye]=e,e}function li(s,e){return Object.assign({},e,s[ye])}function ci(s,e){s.defaults.agent===e.agent&&delete e.agent,s.defaults.httpAgent===e.httpAgent&&delete e.httpAgent,s.defaults.httpsAgent===e.httpsAgent&&delete e.httpsAgent}async function hi(s,e,t,i){var r=t.retryCount<s&&e(i);if((typeof r>"u"?"undefined":ii(r))==="object")try{return await r,!0}catch{return!1}return r}function q(s,e){s.interceptors.request.use(function(t){var i=je(t);return i.lastRequestTime=Date.now(),t}),s.interceptors.response.use(null,async function(t){var i=t.config;if(!i)return Promise.reject(t);var r=li(i,e),n=r.retries,o=n===void 0?3:n,l=r.retryCondition,h=l===void 0?Te:l,c=r.retryDelay,a=c===void 0?ai:c,f=r.shouldResetTimeout,g=f===void 0?!1:f,p=je(i);if(await hi(o,h,p,t)){p.retryCount+=1;var v=a(p.retryCount,t);if(ci(s,i),!g&&i.timeout&&p.lastRequestTime){var T=Date.now()-p.lastRequestTime;i.timeout=Math.max(i.timeout-T-v,1)}return i.transformRequest=[function(u){return u}],new Promise(function(u){return setTimeout(function(){return u(s(i))},v)})}return Promise.reject(t)})}q.isNetworkError=Ee;q.isSafeRequestError=He;q.isIdempotentRequestError=Se;q.isNetworkOrIdempotentRequestError=Te;q.exponentialDelay=We;q.isRetryableError=re});var Je=Q((Oi,Qe)=>{"use strict";Qe.exports=Ye().default});var zt=Q((Er,Fe)=>{"use strict";(function(){var s=this;let e=o=>new TextEncoder().encode(o);function t(o,l){typeof o=="string"&&(o=e(o));for(var h=o.length,c=l^h,a=0,f;h>=4;)f=o[a]&255|(o[++a]&255)<<8|(o[++a]&255)<<16|(o[++a]&255)<<24,f=(f&65535)*1540483477+(((f>>>16)*1540483477&65535)<<16),f^=f>>>24,f=(f&65535)*1540483477+(((f>>>16)*1540483477&65535)<<16),c=(c&65535)*1540483477+(((c>>>16)*1540483477&65535)<<16)^f,h-=4,++a;switch(h){case 3:c^=(o[a+2]&255)<<16;case 2:c^=(o[a+1]&255)<<8;case 1:c^=o[a]&255,c=(c&65535)*1540483477+(((c>>>16)*1540483477&65535)<<16)}return c^=c>>>13,c=(c&65535)*1540483477+(((c>>>16)*1540483477&65535)<<16),c^=c>>>15,c>>>0}function i(o,l){typeof o=="string"&&(o=e(o));var h,c,a,f,g,p,v,T,u,d;for(h=o.length&3,c=o.length-h,a=l,g=3432918353,v=461845907,d=0;d<c;)u=o[d]&255|(o[++d]&255)<<8|(o[++d]&255)<<16|(o[++d]&255)<<24,++d,u=(u&65535)*g+(((u>>>16)*g&65535)<<16)&4294967295,u=u<<15|u>>>17,u=(u&65535)*v+(((u>>>16)*v&65535)<<16)&4294967295,a^=u,a=a<<13|a>>>19,f=(a&65535)*5+(((a>>>16)*5&65535)<<16)&4294967295,a=(f&65535)+27492+(((f>>>16)+58964&65535)<<16);switch(u=0,h){case 3:u^=(o[d+2]&255)<<16;case 2:u^=(o[d+1]&255)<<8;case 1:u^=o[d]&255,u=(u&65535)*g+(((u>>>16)*g&65535)<<16)&4294967295,u=u<<15|u>>>17,u=(u&65535)*v+(((u>>>16)*v&65535)<<16)&4294967295,a^=u}return a^=o.length,a^=a>>>16,a=(a&65535)*2246822507+(((a>>>16)*2246822507&65535)<<16)&4294967295,a^=a>>>13,a=(a&65535)*3266489909+(((a>>>16)*3266489909&65535)<<16)&4294967295,a^=a>>>16,a>>>0}var r=i;if(r.v2=t,r.v3=i,typeof Fe<"u")Fe.exports=r;else{var n=s.murmur;r.noConflict=function(){return s.murmur=n,r},s.murmur=r}})()});var xi={};Ne(xi,{Client:()=>W,Event:()=>pe,FileStore:()=>H,LRU:()=>Oe,default:()=>wi});module.exports=Xt(xi);var Gt=P(require("events")),jt=P(qe()),ke=P(require("axios")),Le=P(Je());var F=P(require("axios"));var Xe=P(require("axios")),x="http://localhost/api/1.0".replace(/\/+$/,"");var X=class{constructor(e,t=x,i=Xe.default){this.basePath=t;this.axios=i;e&&(this.configuration=e,this.basePath=e.basePath||this.basePath)}},se=class extends Error{constructor(t,i){super(i);this.field=t;this.name="RequiredError"}};var _="https://example.com",R=function(s,e,t){if(t==null)throw new se(e,`Required parameter ${e} was null or undefined when calling ${s}.`)};var k=async function(s,e){if(e&&e.accessToken){let t=typeof e.accessToken=="function"?await e.accessToken():await e.accessToken;s.Authorization="Bearer "+t}};var C=function(s,...e){let t=new URLSearchParams(s.search);for(let i of e)for(let r in i)if(Array.isArray(i[r])){t.delete(r);for(let n of i[r])t.append(r,n)}else t.set(r,i[r]);s.search=t.toString()},Ae=function(s,e,t){let i=typeof s!="string";return(i&&t&&t.isJsonMime?t.isJsonMime(e.headers["Content-Type"]):i)?JSON.stringify(s!==void 0?s:{}):s||""},I=function(s){return s.pathname+s.search+s.hash},O=function(s,e,t,i){return(r=e,n=t)=>{let o={...s.options,url:((i==null?void 0:i.basePath)||n)+s.url};return r.request(o)}};var ui=function(s){return{authenticate:async(e,t={})=>{let i="/client/auth",r=new URL(i,_),n;s&&(n=s.baseOptions);let o={method:"POST",...n,...t},l={},h={};l["Content-Type"]="application/json",C(r,h,t.query);let c=n&&n.headers?n.headers:{};return o.headers={...l,...c,...t.headers},o.data=Ae(e,o,s),{url:I(r),options:o}},getAllSegments:async(e,t,i={})=>{R("getAllSegments","environmentUUID",e);let r="/client/env/{environmentUUID}/target-segments".replace("{environmentUUID}",encodeURIComponent(String(e))),n=new URL(r,_),o;s&&(o=s.baseOptions);let l={method:"GET",...o,...i},h={},c={};await k(h,s),t!==void 0&&(c.cluster=t),C(n,c,i.query);let a=o&&o.headers?o.headers:{};return l.headers={...h,...a,...i.headers},{url:I(n),options:l}},getEvaluationByIdentifier:async(e,t,i,r,n={})=>{R("getEvaluationByIdentifier","environmentUUID",e),R("getEvaluationByIdentifier","feature",t),R("getEvaluationByIdentifier","target",i);let o="/client/env/{environmentUUID}/target/{target}/evaluations/{feature}".replace("{environmentUUID}",encodeURIComponent(String(e))).replace("{feature}",encodeURIComponent(String(t))).replace("{target}",encodeURIComponent(String(i))),l=new URL(o,_),h;s&&(h=s.baseOptions);let c={method:"GET",...h,...n},a={},f={};await k(a,s),r!==void 0&&(f.cluster=r),C(l,f,n.query);let g=h&&h.headers?h.headers:{};return c.headers={...a,...g,...n.headers},{url:I(l),options:c}},getEvaluations:async(e,t,i,r={})=>{R("getEvaluations","environmentUUID",e),R("getEvaluations","target",t);let n="/client/env/{environmentUUID}/target/{target}/evaluations".replace("{environmentUUID}",encodeURIComponent(String(e))).replace("{target}",encodeURIComponent(String(t))),o=new URL(n,_),l;s&&(l=s.baseOptions);let h={method:"GET",...l,...r},c={},a={};await k(c,s),i!==void 0&&(a.cluster=i),C(o,a,r.query);let f=l&&l.headers?l.headers:{};return h.headers={...c,...f,...r.headers},{url:I(o),options:h}},getFeatureConfig:async(e,t,i={})=>{R("getFeatureConfig","environmentUUID",e);let r="/client/env/{environmentUUID}/feature-configs".replace("{environmentUUID}",encodeURIComponent(String(e))),n=new URL(r,_),o;s&&(o=s.baseOptions);let l={method:"GET",...o,...i},h={},c={};await k(h,s),t!==void 0&&(c.cluster=t),C(n,c,i.query);let a=o&&o.headers?o.headers:{};return l.headers={...h,...a,...i.headers},{url:I(n),options:l}},getFeatureConfigByIdentifier:async(e,t,i,r={})=>{R("getFeatureConfigByIdentifier","identifier",e),R("getFeatureConfigByIdentifier","environmentUUID",t);let n="/client/env/{environmentUUID}/feature-configs/{identifier}".replace("{identifier}",encodeURIComponent(String(e))).replace("{environmentUUID}",encodeURIComponent(String(t))),o=new URL(n,_),l;s&&(l=s.baseOptions);let h={method:"GET",...l,...r},c={},a={};await k(c,s),i!==void 0&&(a.cluster=i),C(o,a,r.query);let f=l&&l.headers?l.headers:{};return h.headers={...c,...f,...r.headers},{url:I(o),options:h}},getSegmentByIdentifier:async(e,t,i,r={})=>{R("getSegmentByIdentifier","identifier",e),R("getSegmentByIdentifier","environmentUUID",t);let n="/client/env/{environmentUUID}/target-segments/{identifier}".replace("{identifier}",encodeURIComponent(String(e))).replace("{environmentUUID}",encodeURIComponent(String(t))),o=new URL(n,_),l;s&&(l=s.baseOptions);let h={method:"GET",...l,...r},c={},a={};await k(c,s),i!==void 0&&(a.cluster=i),C(o,a,r.query);let f=l&&l.headers?l.headers:{};return h.headers={...c,...f,...r.headers},{url:I(o),options:h}},stream:async(e,t,i={})=>{R("stream","aPIKey",e);let r="/stream",n=new URL(r,_),o;s&&(o=s.baseOptions);let l={method:"GET",...o,...i},h={},c={};await k(h,s),t!==void 0&&(c.cluster=t),e!=null&&(h["API-Key"]=String(e)),C(n,c,i.query);let a=o&&o.headers?o.headers:{};return l.headers={...h,...a,...i.headers},{url:I(n),options:l}}}},N=function(s){let e=ui(s);return{async authenticate(t,i){let r=await e.authenticate(t,i);return O(r,F.default,x,s)},async getAllSegments(t,i,r){let n=await e.getAllSegments(t,i,r);return O(n,F.default,x,s)},async getEvaluationByIdentifier(t,i,r,n,o){let l=await e.getEvaluationByIdentifier(t,i,r,n,o);return O(l,F.default,x,s)},async getEvaluations(t,i,r,n){let o=await e.getEvaluations(t,i,r,n);return O(o,F.default,x,s)},async getFeatureConfig(t,i,r){let n=await e.getFeatureConfig(t,i,r);return O(n,F.default,x,s)},async getFeatureConfigByIdentifier(t,i,r,n){let o=await e.getFeatureConfigByIdentifier(t,i,r,n);return O(o,F.default,x,s)},async getSegmentByIdentifier(t,i,r,n){let o=await e.getSegmentByIdentifier(t,i,r,n);return O(o,F.default,x,s)},async stream(t,i,r){let n=await e.stream(t,i,r);return O(n,F.default,x,s)}}};var ne=class extends X{authenticate(e,t){return N(this.configuration).authenticate(e,t).then(i=>i(this.axios,this.basePath))}getAllSegments(e,t,i){return N(this.configuration).getAllSegments(e,t,i).then(r=>r(this.axios,this.basePath))}getEvaluationByIdentifier(e,t,i,r,n){return N(this.configuration).getEvaluationByIdentifier(e,t,i,r,n).then(o=>o(this.axios,this.basePath))}getEvaluations(e,t,i,r){return N(this.configuration).getEvaluations(e,t,i,r).then(n=>n(this.axios,this.basePath))}getFeatureConfig(e,t,i){return N(this.configuration).getFeatureConfig(e,t,i).then(r=>r(this.axios,this.basePath))}getFeatureConfigByIdentifier(e,t,i,r){return N(this.configuration).getFeatureConfigByIdentifier(e,t,i,r).then(n=>n(this.axios,this.basePath))}getSegmentByIdentifier(e,t,i,r){return N(this.configuration).getSegmentByIdentifier(e,t,i,r).then(n=>n(this.axios,this.basePath))}stream(e,t,i){return N(this.configuration).stream(e,t,i).then(r=>r(this.axios,this.basePath))}},fi=function(s){return{postMetrics:async(e,t,i,r={})=>{R("postMetrics","environment",e);let n="/metrics/{environment}".replace("{environment}",encodeURIComponent(String(e))),o=new URL(n,_),l;s&&(l=s.baseOptions);let h={method:"POST",...l,...r},c={},a={};await k(c,s),t!==void 0&&(a.cluster=t),c["Content-Type"]="application/json",C(o,a,r.query);let f=l&&l.headers?l.headers:{};return h.headers={...c,...f,...r.headers},h.data=Ae(i,h,s),{url:I(o),options:h}}}},gi=function(s){let e=fi(s);return{async postMetrics(t,i,r,n){let o=await e.postMetrics(t,i,r,n);return O(o,F.default,x,s)}}};var oe=class extends X{postMetrics(e,t,i,r){return gi(this.configuration).postMetrics(e,t,i,r).then(n=>n(this.axios,this.basePath))}};var G=class{constructor(e={}){this.apiKey=e.apiKey,this.username=e.username,this.password=e.password,this.accessToken=e.accessToken,this.basePath=e.basePath,this.baseOptions=e.baseOptions,this.formDataCtor=e.formDataCtor}isJsonMime(e){let t=new RegExp("^(application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(;.*)?$","i");return e!==null&&(t.test(e)||e.toLowerCase()==="application/json-patch+json")}};var ae="1.3.7-rc.1";var Ze={1e3:"The SDK has successfully initialized",1001:"The SDK has failed to initialize due to an authentication error - defaults will be served",1002:"The SDK has failed to initialize due to a missing or empty API key - defaults will be served",2e3:"Authentication was successful",2001:"Authentication failed with a non-recoverable error",2002:"Authentication attempt failed:",2003:"Authentication failed and max retries have been exceeded",3e3:"Closing SDK",3001:"SDK Closed successfully",4e3:"Polling started, interval:",4001:"Polling stopped",5e3:"SSE stream successfully connected",5001:"SSE stream disconnected, reason:",5002:"SSE event received",5003:"SSE retrying to connect in",5004:"SSE stopped",6e3:"Evaluation successful: ",6001:"Evaluation Failed, returning default variation: ",7e3:"Metrics thread started with request interval:",7001:"Metrics stopped",7002:"Posting metrics failed, reason:",7003:"Metrics posted successfully"};function di(s){return s in Ze?Ze[s]:"Unknown SDK code"}function S(s,e=""){return`SDKCODE:${s}: ${di(s)} ${e}`}function et(s){s.warn(S(1002))}function tt(s,e){e.info(S(4e3,s/1e3+" seconds"))}function be(s){s.info(S(1e3))}function it(s){s.info(S(3e3))}function rt(s){s.info(S(3001))}function Re(s){s.info(S(4001))}function st(s){s.info(S(5e3))}function nt(s){s.debug(S(5002))}function ot(s){s.info(S(5004))}function at(s,e){e.info(S(7e3,s/1e3+" seconds"))}function lt(s){s.info(S(7003))}function ct(s){s.info(S(7001))}function Z(s,e,t,i){i.debug(S(6e3,`result=${s}, flag identifier=${e}, target=${JSON.stringify(t)}`))}function ht(s){s.warn(S(2001))}function ut(s){s.warn(S(1001))}function ft(s,e){e.warn(S(5001,s))}function gt(s,e){e.warn(S(5003,`${s}`))}function dt(s,e){e.warn(S(7002,s))}function D(s,e,t,i){i.warn(S(6001,`default variation used=${t}, flag=${s}, target=${JSON.stringify(e)}`))}var le=class{constructor(e,t,i,r,n,o){this.stopped=!0;this.initialized=!1;this.lastPollTime=0;this.api=i,this.options=r,this.environment=e,this.cluster=t,this.repository=o,this.eventBus=n,this.log=r.logger}poll(){if(this.stopped){this.log.info("PollingProcessor stopped"),Re(this.log);return}let e=new Date().getTime(),t=()=>{let i=new Date().getTime()-e,r=Math.max(this.options.pollInterval-i,0);this.timeout=setTimeout(()=>this.poll(),r)};if(this.lastPollTime>Date.now()-this.options.pollInterval){this.log.info(`Last poll was ${Math.round((Date.now()-this.lastPollTime)/1e3)} seconds ago, skipping flag refresh`),t();return}this.lastPollTime=Date.now(),Promise.all([this.retrieveFlags(),this.retrieveSegments()]).then(()=>{this.initialized||setTimeout(()=>{this.initialized=!0,this.eventBus.emit("poller_ready")},0)}).catch(i=>{this.eventBus.emit("poller_error",{error:i})}).finally(()=>{if(this.stopped){this.log.info("PollingProcessor stopped"),Re(this.log);return}t()})}async retrieveFlags(){try{this.log.debug("Fetching flags started");let e=await this.api.getFeatureConfig(this.environment,this.cluster);this.log.debug("Fetching flags finished"),e.data.forEach(t=>this.repository.setFlag(t.feature,t))}catch(e){throw this.log.error("Error loading flags",e),e}}async retrieveSegments(){try{this.log.debug("Fetching segments started");let e=await this.api.getAllSegments(this.environment,this.cluster);this.log.debug("Fetching segments finished"),e.data.forEach(t=>this.repository.setSegment(t.identifier,t))}catch(e){throw this.log.error("Error loading segments",e),e}}start(){if(!this.stopped){this.log.info("PollingProcessor already started");return}this.log.info("Starting PollingProcessor with request interval: ",this.options.pollInterval),this.stopped=!1,this.poll()}stop(){this.log.info("Stopping PollingProcessor"),this.stopped=!0}close(){this.log.info("Closing PollingProcessor"),this.stop(),clearTimeout(this.timeout),this.log.info("PollingProcessor closed")}};var pt=P(require("https")),mt=P(require("http"));var b=class b{constructor(e,t,i,r,n,o,l,h){this.retryAttempt=0;this.api=e,this.apiKey=t,this.environment=i,this.jwtToken=r,this.options=n,this.cluster=o,this.eventBus=l,this.repository=h,this.log=this.options.logger;let c=5e3,a=1e4;this.retryDelayMs=Math.floor(Math.random()*(a-c)+c)}start(){this.log.info("Starting new StreamProcessor");let e=`${this.options.baseUrl}/stream?cluster=${this.cluster}`,t={headers:{"Cache-Control":"no-cache",Accept:"text/event-stream",Authorization:`Bearer ${this.jwtToken}`,"API-Key":this.apiKey}},i=()=>{this.log.info(`SSE stream connected OK: ${e}`),this.retryAttempt=0,this.readyState=b.CONNECTED,this.eventBus.emit("stream_connected")},r=n=>{if(this.readyState!==b.CLOSED){this.retryAttempt+=1;let o=this.getRandomRetryDelayMs();ft(n,this.log),gt(o,this.log),this.readyState=b.RETRYING,this.eventBus.emit("stream_retrying"),setTimeout(()=>{this.log.info("SSE retrying to connect"),this.connect(e,t,i,r)},o)}};this.connect(e,t,i,r),this.eventBus.emit("stream_ready")}getRandomRetryDelayMs(){let e=this.retryDelayMs*this.retryAttempt;return Math.min(e,6e4)}connect(e,t,i,r){if(this.readyState===b.CONNECTED){this.log.debug("SSE already connected, skip retry");return}let n=e.startsWith("https:");this.log.debug("SSE HTTP start request",e),this.request=(n?pt.default:mt.default).request(e,t,o=>{if(this.log.debug("SSE got HTTP response code",o.statusCode),o.statusCode>=400&&o.statusCode<=599){r(`HTTP code ${o.statusCode}`);return}i(),o.on("data",l=>{nt(this.log),this.processData(l)}).on("close",()=>{r("SSE stream closed")})}).on("error",o=>{r("SSE request failed "+o.message)}).on("timeout",()=>{r("SSE request timed out after "+b.SSE_TIMEOUT_MS+"ms")}).setTimeout(b.SSE_TIMEOUT_MS),this.request.end()}processData(e){e.toString().split(/\r?\n/).forEach(i=>this.processLine(i))}processLine(e){if(e.startsWith("data:")){this.log.debug("SSE GOT:",e.substring(5));let t=JSON.parse(e.substring(5));t.domain==="flag"?this.msgProcessor(t,this.api.getFeatureConfigByIdentifier.bind(this.api),this.repository.setFlag.bind(this.repository),this.repository.deleteFlag.bind(this.repository)):t.domain==="target-segment"&&this.msgProcessor(t,this.api.getSegmentByIdentifier.bind(this.api),this.repository.setSegment.bind(this.repository),this.repository.deleteSegment.bind(this.repository))}}async msgProcessor(e,t,i,r){this.log.info("Processing message",e);try{if(e.event==="create"||e.event==="patch"){let{data:n}=await t(e.identifier,this.environment,this.cluster);i(e.identifier,n)}else e.event==="delete"&&r(e.identifier)}catch(n){throw this.log.error("Error while fetching data with identifier:",e.identifier,n),n}this.log.info("Processing message finished",e)}connected(){return this.readyState===b.CONNECTED}close(){if(this.readyState===b.CLOSED){this.log.info("SteamProcessor already closed");return}this.readyState=b.CLOSED,this.log.info("Closing StreamProcessor"),this.request.destroy(),this.request=void 0,this.eventBus.emit("stream_disconnected"),this.log.info("StreamProcessor closed"),ot(this.log)}};b.CONNECTED=1,b.RETRYING=2,b.CLOSED=3,b.SSE_TIMEOUT_MS=3e4;var ce=b;var Oe={};Ne(Oe,{default:()=>Ie});var ee=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,mi=typeof AbortController=="function",he=mi?AbortController:class{constructor(){this.signal=new vt}abort(e=new Error("This operation was aborted")){this.signal.reason=this.signal.reason||e,this.signal.aborted=!0,this.signal.dispatchEvent({type:"abort",target:this.signal})}},vi=typeof AbortSignal=="function",yi=typeof he.AbortSignal=="function",vt=vi?AbortSignal:yi?he.AbortController:class{constructor(){this.reason=void 0,this.aborted=!1,this._listeners=[]}dispatchEvent(e){e.type==="abort"&&(this.aborted=!0,this.onabort(e),this._listeners.forEach(t=>t(e),this))}onabort(){}addEventListener(e,t){e==="abort"&&this._listeners.push(t)}removeEventListener(e,t){e==="abort"&&(this._listeners=this._listeners.filter(i=>i!==t))}},_e=new Set,we=(s,e)=>{let t=`LRU_CACHE_OPTION_${s}`;ue(t)&&Ce(t,`${s} option`,`options.${e}`,$)},xe=(s,e)=>{let t=`LRU_CACHE_METHOD_${s}`;if(ue(t)){let{prototype:i}=$,{get:r}=Object.getOwnPropertyDescriptor(i,s);Ce(t,`${s} method`,`cache.${e}()`,r)}},Ei=(s,e)=>{let t=`LRU_CACHE_PROPERTY_${s}`;if(ue(t)){let{prototype:i}=$,{get:r}=Object.getOwnPropertyDescriptor(i,s);Ce(t,`${s} property`,`cache.${e}`,r)}},yt=(...s)=>{typeof process=="object"&&process&&typeof process.emitWarning=="function"?process.emitWarning(...s):console.error(...s)},ue=s=>!_e.has(s),Ce=(s,e,t,i)=>{_e.add(s);let r=`The ${e} is deprecated. Please use ${t} instead.`;yt(r,"DeprecationWarning",s,i)},U=s=>s&&s===Math.floor(s)&&s>0&&isFinite(s),Et=s=>U(s)?s<=Math.pow(2,8)?Uint8Array:s<=Math.pow(2,16)?Uint16Array:s<=Math.pow(2,32)?Uint32Array:s<=Number.MAX_SAFE_INTEGER?j:null:null,j=class extends Array{constructor(e){super(e),this.fill(0)}},Pe=class{constructor(e){if(e===0)return[];let t=Et(e);this.heap=new t(e),this.length=0}push(e){this.heap[this.length++]=e}pop(){return this.heap[--this.length]}},$=class s{constructor(e={}){let{max:t=0,ttl:i,ttlResolution:r=1,ttlAutopurge:n,updateAgeOnGet:o,updateAgeOnHas:l,allowStale:h,dispose:c,disposeAfter:a,noDisposeOnSet:f,noUpdateTTL:g,maxSize:p=0,maxEntrySize:v=0,sizeCalculation:T,fetchMethod:u,fetchContext:d,noDeleteOnFetchRejection:E,noDeleteOnStaleGet:A,allowStaleOnFetchRejection:y,allowStaleOnFetchAbort:w,ignoreFetchAbort:m}=e,{length:B,maxAge:z,stale:M}=e instanceof s?{}:e;if(t!==0&&!U(t))throw new TypeError("max option must be a nonnegative integer");let K=t?Et(t):Array;if(!K)throw new Error("invalid max value: "+t);if(this.max=t,this.maxSize=p,this.maxEntrySize=v||this.maxSize,this.sizeCalculation=T||B,this.sizeCalculation){if(!this.maxSize&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(this.fetchMethod=u||null,this.fetchMethod&&typeof this.fetchMethod!="function")throw new TypeError("fetchMethod must be a function if specified");if(this.fetchContext=d,!this.fetchMethod&&d!==void 0)throw new TypeError("cannot set fetchContext without fetchMethod");if(this.keyMap=new Map,this.keyList=new Array(t).fill(null),this.valList=new Array(t).fill(null),this.next=new K(t),this.prev=new K(t),this.head=0,this.tail=0,this.free=new Pe(t),this.initialFill=1,this.size=0,typeof c=="function"&&(this.dispose=c),typeof a=="function"?(this.disposeAfter=a,this.disposed=[]):(this.disposeAfter=null,this.disposed=null),this.noDisposeOnSet=!!f,this.noUpdateTTL=!!g,this.noDeleteOnFetchRejection=!!E,this.allowStaleOnFetchRejection=!!y,this.allowStaleOnFetchAbort=!!w,this.ignoreFetchAbort=!!m,this.maxEntrySize!==0){if(this.maxSize!==0&&!U(this.maxSize))throw new TypeError("maxSize must be a positive integer if specified");if(!U(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.initializeSizeTracking()}if(this.allowStale=!!h||!!M,this.noDeleteOnStaleGet=!!A,this.updateAgeOnGet=!!o,this.updateAgeOnHas=!!l,this.ttlResolution=U(r)||r===0?r:1,this.ttlAutopurge=!!n,this.ttl=i||z||0,this.ttl){if(!U(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.initializeTTLTracking()}if(this.max===0&&this.ttl===0&&this.maxSize===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.max&&!this.maxSize){let Y="LRU_CACHE_UNBOUNDED";ue(Y)&&(_e.add(Y),yt("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",Y,s))}M&&we("stale","allowStale"),z&&we("maxAge","ttl"),B&&we("length","sizeCalculation")}getRemainingTTL(e){return this.has(e,{updateAgeOnHas:!1})?1/0:0}initializeTTLTracking(){this.ttls=new j(this.max),this.starts=new j(this.max),this.setItemTTL=(i,r,n=ee.now())=>{if(this.starts[i]=r!==0?n:0,this.ttls[i]=r,r!==0&&this.ttlAutopurge){let o=setTimeout(()=>{this.isStale(i)&&this.delete(this.keyList[i])},r+1);o.unref&&o.unref()}},this.updateItemAge=i=>{this.starts[i]=this.ttls[i]!==0?ee.now():0},this.statusTTL=(i,r)=>{i&&(i.ttl=this.ttls[r],i.start=this.starts[r],i.now=e||t(),i.remainingTTL=i.now+i.ttl-i.start)};let e=0,t=()=>{let i=ee.now();if(this.ttlResolution>0){e=i;let r=setTimeout(()=>e=0,this.ttlResolution);r.unref&&r.unref()}return i};this.getRemainingTTL=i=>{let r=this.keyMap.get(i);return r===void 0?0:this.ttls[r]===0||this.starts[r]===0?1/0:this.starts[r]+this.ttls[r]-(e||t())},this.isStale=i=>this.ttls[i]!==0&&this.starts[i]!==0&&(e||t())-this.starts[i]>this.ttls[i]}updateItemAge(e){}statusTTL(e,t){}setItemTTL(e,t,i){}isStale(e){return!1}initializeSizeTracking(){this.calculatedSize=0,this.sizes=new j(this.max),this.removeItemSize=e=>{this.calculatedSize-=this.sizes[e],this.sizes[e]=0},this.requireSize=(e,t,i,r)=>{if(this.isBackgroundFetch(t))return 0;if(!U(i))if(r){if(typeof r!="function")throw new TypeError("sizeCalculation must be a function");if(i=r(t,e),!U(i))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return i},this.addItemSize=(e,t,i)=>{if(this.sizes[e]=t,this.maxSize){let r=this.maxSize-this.sizes[e];for(;this.calculatedSize>r;)this.evict(!0)}this.calculatedSize+=this.sizes[e],i&&(i.entrySize=t,i.totalCalculatedSize=this.calculatedSize)}}removeItemSize(e){}addItemSize(e,t){}requireSize(e,t,i,r){if(i||r)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache")}*indexes({allowStale:e=this.allowStale}={}){if(this.size)for(let t=this.tail;!(!this.isValidIndex(t)||((e||!this.isStale(t))&&(yield t),t===this.head));)t=this.prev[t]}*rindexes({allowStale:e=this.allowStale}={}){if(this.size)for(let t=this.head;!(!this.isValidIndex(t)||((e||!this.isStale(t))&&(yield t),t===this.tail));)t=this.next[t]}isValidIndex(e){return e!==void 0&&this.keyMap.get(this.keyList[e])===e}*entries(){for(let e of this.indexes())this.valList[e]!==void 0&&this.keyList[e]!==void 0&&!this.isBackgroundFetch(this.valList[e])&&(yield[this.keyList[e],this.valList[e]])}*rentries(){for(let e of this.rindexes())this.valList[e]!==void 0&&this.keyList[e]!==void 0&&!this.isBackgroundFetch(this.valList[e])&&(yield[this.keyList[e],this.valList[e]])}*keys(){for(let e of this.indexes())this.keyList[e]!==void 0&&!this.isBackgroundFetch(this.valList[e])&&(yield this.keyList[e])}*rkeys(){for(let e of this.rindexes())this.keyList[e]!==void 0&&!this.isBackgroundFetch(this.valList[e])&&(yield this.keyList[e])}*values(){for(let e of this.indexes())this.valList[e]!==void 0&&!this.isBackgroundFetch(this.valList[e])&&(yield this.valList[e])}*rvalues(){for(let e of this.rindexes())this.valList[e]!==void 0&&!this.isBackgroundFetch(this.valList[e])&&(yield this.valList[e])}[Symbol.iterator](){return this.entries()}find(e,t){for(let i of this.indexes()){let r=this.valList[i],n=this.isBackgroundFetch(r)?r.__staleWhileFetching:r;if(n!==void 0&&e(n,this.keyList[i],this))return this.get(this.keyList[i],t)}}forEach(e,t=this){for(let i of this.indexes()){let r=this.valList[i],n=this.isBackgroundFetch(r)?r.__staleWhileFetching:r;n!==void 0&&e.call(t,n,this.keyList[i],this)}}rforEach(e,t=this){for(let i of this.rindexes()){let r=this.valList[i],n=this.isBackgroundFetch(r)?r.__staleWhileFetching:r;n!==void 0&&e.call(t,n,this.keyList[i],this)}}get prune(){return xe("prune","purgeStale"),this.purgeStale}purgeStale(){let e=!1;for(let t of this.rindexes({allowStale:!0}))this.isStale(t)&&(this.delete(this.keyList[t]),e=!0);return e}dump(){let e=[];for(let t of this.indexes({allowStale:!0})){let i=this.keyList[t],r=this.valList[t],n=this.isBackgroundFetch(r)?r.__staleWhileFetching:r;if(n===void 0)continue;let o={value:n};if(this.ttls){o.ttl=this.ttls[t];let l=ee.now()-this.starts[t];o.start=Math.floor(Date.now()-l)}this.sizes&&(o.size=this.sizes[t]),e.unshift([i,o])}return e}load(e){this.clear();for(let[t,i]of e){if(i.start){let r=Date.now()-i.start;i.start=ee.now()-r}this.set(t,i.value,i)}}dispose(e,t,i){}set(e,t,{ttl:i=this.ttl,start:r,noDisposeOnSet:n=this.noDisposeOnSet,size:o=0,sizeCalculation:l=this.sizeCalculation,noUpdateTTL:h=this.noUpdateTTL,status:c}={}){if(o=this.requireSize(e,t,o,l),this.maxEntrySize&&o>this.maxEntrySize)return c&&(c.set="miss",c.maxEntrySizeExceeded=!0),this.delete(e),this;let a=this.size===0?void 0:this.keyMap.get(e);if(a===void 0)a=this.newIndex(),this.keyList[a]=e,this.valList[a]=t,this.keyMap.set(e,a),this.next[this.tail]=a,this.prev[a]=this.tail,this.tail=a,this.size++,this.addItemSize(a,o,c),c&&(c.set="add"),h=!1;else{this.moveToTail(a);let f=this.valList[a];if(t!==f){if(this.isBackgroundFetch(f)?f.__abortController.abort(new Error("replaced")):n||(this.dispose(f,e,"set"),this.disposeAfter&&this.disposed.push([f,e,"set"])),this.removeItemSize(a),this.valList[a]=t,this.addItemSize(a,o,c),c){c.set="replace";let g=f&&this.isBackgroundFetch(f)?f.__staleWhileFetching:f;g!==void 0&&(c.oldValue=g)}}else c&&(c.set="update")}if(i!==0&&this.ttl===0&&!this.ttls&&this.initializeTTLTracking(),h||this.setItemTTL(a,i,r),this.statusTTL(c,a),this.disposeAfter)for(;this.disposed.length;)this.disposeAfter(...this.disposed.shift());return this}newIndex(){return this.size===0?this.tail:this.size===this.max&&this.max!==0?this.evict(!1):this.free.length!==0?this.free.pop():this.initialFill++}pop(){if(this.size){let e=this.valList[this.head];return this.evict(!0),e}}evict(e){let t=this.head,i=this.keyList[t],r=this.valList[t];return this.isBackgroundFetch(r)?r.__abortController.abort(new Error("evicted")):(this.dispose(r,i,"evict"),this.disposeAfter&&this.disposed.push([r,i,"evict"])),this.removeItemSize(t),e&&(this.keyList[t]=null,this.valList[t]=null,this.free.push(t)),this.head=this.next[t],this.keyMap.delete(i),this.size--,t}has(e,{updateAgeOnHas:t=this.updateAgeOnHas,status:i}={}){let r=this.keyMap.get(e);if(r!==void 0)if(this.isStale(r))i&&(i.has="stale",this.statusTTL(i,r));else return t&&this.updateItemAge(r),i&&(i.has="hit"),this.statusTTL(i,r),!0;else i&&(i.has="miss");return!1}peek(e,{allowStale:t=this.allowStale}={}){let i=this.keyMap.get(e);if(i!==void 0&&(t||!this.isStale(i))){let r=this.valList[i];return this.isBackgroundFetch(r)?r.__staleWhileFetching:r}}backgroundFetch(e,t,i,r){let n=t===void 0?void 0:this.valList[t];if(this.isBackgroundFetch(n))return n;let o=new he;i.signal&&i.signal.addEventListener("abort",()=>o.abort(i.signal.reason));let l={signal:o.signal,options:i,context:r},h=(p,v=!1)=>{let{aborted:T}=o.signal,u=i.ignoreFetchAbort&&p!==void 0;return i.status&&(T&&!v?(i.status.fetchAborted=!0,i.status.fetchError=o.signal.reason,u&&(i.status.fetchAbortIgnored=!0)):i.status.fetchResolved=!0),T&&!u&&!v?a(o.signal.reason):(this.valList[t]===g&&(p===void 0?g.__staleWhileFetching?this.valList[t]=g.__staleWhileFetching:this.delete(e):(i.status&&(i.status.fetchUpdated=!0),this.set(e,p,l.options))),p)},c=p=>(i.status&&(i.status.fetchRejected=!0,i.status.fetchError=p),a(p)),a=p=>{let{aborted:v}=o.signal,T=v&&i.allowStaleOnFetchAbort,u=T||i.allowStaleOnFetchRejection,d=u||i.noDeleteOnFetchRejection;if(this.valList[t]===g&&(!d||g.__staleWhileFetching===void 0?this.delete(e):T||(this.valList[t]=g.__staleWhileFetching)),u)return i.status&&g.__staleWhileFetching!==void 0&&(i.status.returnedStale=!0),g.__staleWhileFetching;if(g.__returned===g)throw p},f=(p,v)=>{this.fetchMethod(e,n,l).then(T=>p(T),v),o.signal.addEventListener("abort",()=>{(!i.ignoreFetchAbort||i.allowStaleOnFetchAbort)&&(p(),i.allowStaleOnFetchAbort&&(p=T=>h(T,!0)))})};i.status&&(i.status.fetchDispatched=!0);let g=new Promise(f).then(h,c);return g.__abortController=o,g.__staleWhileFetching=n,g.__returned=null,t===void 0?(this.set(e,g,{...l.options,status:void 0}),t=this.keyMap.get(e)):this.valList[t]=g,g}isBackgroundFetch(e){return e&&typeof e=="object"&&typeof e.then=="function"&&Object.prototype.hasOwnProperty.call(e,"__staleWhileFetching")&&Object.prototype.hasOwnProperty.call(e,"__returned")&&(e.__returned===e||e.__returned===null)}async fetch(e,{allowStale:t=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:r=this.noDeleteOnStaleGet,ttl:n=this.ttl,noDisposeOnSet:o=this.noDisposeOnSet,size:l=0,sizeCalculation:h=this.sizeCalculation,noUpdateTTL:c=this.noUpdateTTL,noDeleteOnFetchRejection:a=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:f=this.allowStaleOnFetchRejection,ignoreFetchAbort:g=this.ignoreFetchAbort,allowStaleOnFetchAbort:p=this.allowStaleOnFetchAbort,fetchContext:v=this.fetchContext,forceRefresh:T=!1,status:u,signal:d}={}){if(!this.fetchMethod)return u&&(u.fetch="get"),this.get(e,{allowStale:t,updateAgeOnGet:i,noDeleteOnStaleGet:r,status:u});let E={allowStale:t,updateAgeOnGet:i,noDeleteOnStaleGet:r,ttl:n,noDisposeOnSet:o,size:l,sizeCalculation:h,noUpdateTTL:c,noDeleteOnFetchRejection:a,allowStaleOnFetchRejection:f,allowStaleOnFetchAbort:p,ignoreFetchAbort:g,status:u,signal:d},A=this.keyMap.get(e);if(A===void 0){u&&(u.fetch="miss");let y=this.backgroundFetch(e,A,E,v);return y.__returned=y}else{let y=this.valList[A];if(this.isBackgroundFetch(y)){let M=t&&y.__staleWhileFetching!==void 0;return u&&(u.fetch="inflight",M&&(u.returnedStale=!0)),M?y.__staleWhileFetching:y.__returned=y}let w=this.isStale(A);if(!T&&!w)return u&&(u.fetch="hit"),this.moveToTail(A),i&&this.updateItemAge(A),this.statusTTL(u,A),y;let m=this.backgroundFetch(e,A,E,v),B=m.__staleWhileFetching!==void 0,z=B&&t;return u&&(u.fetch=B&&w?"stale":"refresh",z&&w&&(u.returnedStale=!0)),z?m.__staleWhileFetching:m.__returned=m}}get(e,{allowStale:t=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:r=this.noDeleteOnStaleGet,status:n}={}){let o=this.keyMap.get(e);if(o!==void 0){let l=this.valList[o],h=this.isBackgroundFetch(l);return this.statusTTL(n,o),this.isStale(o)?(n&&(n.get="stale"),h?(n&&(n.returnedStale=t&&l.__staleWhileFetching!==void 0),t?l.__staleWhileFetching:void 0):(r||this.delete(e),n&&(n.returnedStale=t),t?l:void 0)):(n&&(n.get="hit"),h?l.__staleWhileFetching:(this.moveToTail(o),i&&this.updateItemAge(o),l))}else n&&(n.get="miss")}connect(e,t){this.prev[t]=e,this.next[e]=t}moveToTail(e){e!==this.tail&&(e===this.head?this.head=this.next[e]:this.connect(this.prev[e],this.next[e]),this.connect(this.tail,e),this.tail=e)}get del(){return xe("del","delete"),this.delete}delete(e){let t=!1;if(this.size!==0){let i=this.keyMap.get(e);if(i!==void 0)if(t=!0,this.size===1)this.clear();else{this.removeItemSize(i);let r=this.valList[i];this.isBackgroundFetch(r)?r.__abortController.abort(new Error("deleted")):(this.dispose(r,e,"delete"),this.disposeAfter&&this.disposed.push([r,e,"delete"])),this.keyMap.delete(e),this.keyList[i]=null,this.valList[i]=null,i===this.tail?this.tail=this.prev[i]:i===this.head?this.head=this.next[i]:(this.next[this.prev[i]]=this.next[i],this.prev[this.next[i]]=this.prev[i]),this.size--,this.free.push(i)}}if(this.disposed)for(;this.disposed.length;)this.disposeAfter(...this.disposed.shift());return t}clear(){for(let e of this.rindexes({allowStale:!0})){let t=this.valList[e];if(this.isBackgroundFetch(t))t.__abortController.abort(new Error("deleted"));else{let i=this.keyList[e];this.dispose(t,i,"delete"),this.disposeAfter&&this.disposed.push([t,i,"delete"])}}if(this.keyMap.clear(),this.valList.fill(null),this.keyList.fill(null),this.ttls&&(this.ttls.fill(0),this.starts.fill(0)),this.sizes&&this.sizes.fill(0),this.head=0,this.tail=0,this.initialFill=1,this.free.length=0,this.calculatedSize=0,this.size=0,this.disposed)for(;this.disposed.length;)this.disposeAfter(...this.disposed.shift())}get reset(){return xe("reset","clear"),this.clear}get length(){return Ei("length","size"),this.size}static get AbortController(){return he}static get AbortSignal(){return vt}},Ie=$;var fe=class{trace(e,...t){console.trace(e,...t)}debug(e,...t){console.debug(e,...t)}info(e,...t){console.info(e,...t)}warn(e,...t){console.warn(e,...t)}error(e,...t){console.error(e,...t)}};var St=P(require("keyv")),Tt=require("keyv-file"),H=class{constructor(e={}){this.keyvFile=new Tt.KeyvFile(e),this.keyv=new St.default({store:this.keyvFile})}set(e,t){return this.keyv.set(e,t)}get(e){return this.keyv.get(e)}del(e){return this.keyv.delete(e)}keys(){return Promise.resolve(function*(e){for(let t of e)yield t}(this.keyvFile.keys()))}};var At=100;var bt="featureIdentifier",Rt="featureName",wt="variationIdentifier";var xt="target",Pt="SDK_VERSION",_t="SDK_TYPE",Ct="server",It="SDK_LANGUAGE",Ot="javascript",Ft="global",te="segmentMatch",Dt="in",Lt="equal",kt="gt",Mt="starts_with",Nt="ends_with",Ut="contains",Vt="equal_sensitive",Si="https://config.ff.harness.io/api/1.0",Ti="https://events.ff.harness.io/api/1.0",Ai=1e3,Bt=60*Ai,bi=1*Bt,Ri=1*Bt,V={baseUrl:Si,eventsUrl:Ti,pollInterval:bi,eventsSyncInterval:Ri,enableStream:!0,enableAnalytics:!0,cache:new Ie({max:100}),store:new H,logger:new fe};var qt=P(zt());var ge=class{constructor(e,t){this.query=e,this.log=t}getAttrValue(e,t){var i;return e[t]||((i=e.attributes)==null?void 0:i[t])}findVariation(e,t){return e.find(i=>i.identifier===t)}getNormalizedNumberWithNormalizer(e,t,i){let r=[t,e].join(":");return parseInt((0,qt.default)(r).toString())%i+1}getNormalizedNumber(e,t){return this.getNormalizedNumberWithNormalizer(e,t,At)}isEnabled(e,t,i){let r=this.getAttrValue(e,t);if(!r)return!1;let n=this.getNormalizedNumber(r,t);return i>0&&n<=i}evaluateDistribution(e,t){if(!e)return;let i="",r=0;for(let n of e.variations)if(i=n.variation,r+=n.weight,this.isEnabled(t,e.bucketBy,r))return n.variation;return i}async isTargetIncludedOrExcludedInSegment(e,t){var i,r;for(let n of e){let o=await this.query.getSegment(n);if(o){if((i=o.excluded)!=null&&i.find(l=>l.identifier===t.identifier))return this.log.debug(`Target %s excluded from segment %s via exclude list | ||
`,t.name,o.name),!1;if((r=o.included)!=null&&r.find(l=>l.identifier===t.identifier))return this.log.debug(`Target %s included in segment %s via include list | ||
@@ -3,0 +3,0 @@ `,t.name,o.name),!0;if(o.rules&&await this.evaluateClauses(o.rules,t))return this.log.debug(`Target %s included in segment %s via rules |
@@ -997,3 +997,3 @@ /** | ||
*/ | ||
authenticate(authenticationRequest?: AuthenticationRequest, options?: any): Promise<import("axios").AxiosResponse<AuthenticationResponse>>; | ||
authenticate(authenticationRequest?: AuthenticationRequest, options?: any): Promise<import("axios").AxiosResponse<AuthenticationResponse, any>>; | ||
/** | ||
@@ -1008,3 +1008,3 @@ * Used to retrieve all segments for certain account id. | ||
*/ | ||
getAllSegments(environmentUUID: string, cluster?: string, options?: any): Promise<import("axios").AxiosResponse<Segment[]>>; | ||
getAllSegments(environmentUUID: string, cluster?: string, options?: any): Promise<import("axios").AxiosResponse<Segment[], any>>; | ||
/** | ||
@@ -1021,3 +1021,3 @@ * | ||
*/ | ||
getEvaluationByIdentifier(environmentUUID: string, feature: string, target: string, cluster?: string, options?: any): Promise<import("axios").AxiosResponse<Evaluation>>; | ||
getEvaluationByIdentifier(environmentUUID: string, feature: string, target: string, cluster?: string, options?: any): Promise<import("axios").AxiosResponse<Evaluation, any>>; | ||
/** | ||
@@ -1033,3 +1033,3 @@ * | ||
*/ | ||
getEvaluations(environmentUUID: string, target: string, cluster?: string, options?: any): Promise<import("axios").AxiosResponse<Pagination & object>>; | ||
getEvaluations(environmentUUID: string, target: string, cluster?: string, options?: any): Promise<import("axios").AxiosResponse<Pagination & object, any>>; | ||
/** | ||
@@ -1044,3 +1044,3 @@ * All feature flags with activations in project environment | ||
*/ | ||
getFeatureConfig(environmentUUID: string, cluster?: string, options?: any): Promise<import("axios").AxiosResponse<FeatureConfig[]>>; | ||
getFeatureConfig(environmentUUID: string, cluster?: string, options?: any): Promise<import("axios").AxiosResponse<FeatureConfig[], any>>; | ||
/** | ||
@@ -1056,3 +1056,3 @@ * | ||
*/ | ||
getFeatureConfigByIdentifier(identifier: string, environmentUUID: string, cluster?: string, options?: any): Promise<import("axios").AxiosResponse<FeatureConfig>>; | ||
getFeatureConfigByIdentifier(identifier: string, environmentUUID: string, cluster?: string, options?: any): Promise<import("axios").AxiosResponse<FeatureConfig, any>>; | ||
/** | ||
@@ -1068,3 +1068,3 @@ * Used to retrieve a segment for a certain account id by identifier | ||
*/ | ||
getSegmentByIdentifier(identifier: string, environmentUUID: string, cluster?: string, options?: any): Promise<import("axios").AxiosResponse<Segment>>; | ||
getSegmentByIdentifier(identifier: string, environmentUUID: string, cluster?: string, options?: any): Promise<import("axios").AxiosResponse<Segment, any>>; | ||
/** | ||
@@ -1079,3 +1079,3 @@ * | ||
*/ | ||
stream(aPIKey: string, cluster?: string, options?: any): Promise<import("axios").AxiosResponse<void>>; | ||
stream(aPIKey: string, cluster?: string, options?: any): Promise<import("axios").AxiosResponse<void, any>>; | ||
} | ||
@@ -1147,3 +1147,3 @@ /** | ||
*/ | ||
postMetrics(environment: string, cluster?: string, metrics?: Metrics, options?: any): Promise<import("axios").AxiosResponse<void>>; | ||
postMetrics(environment: string, cluster?: string, metrics?: Metrics, options?: any): Promise<import("axios").AxiosResponse<void, any>>; | ||
} |
@@ -65,2 +65,2 @@ /** | ||
*/ | ||
export declare const createRequestFunction: (axiosArgs: RequestArgs, globalAxios: AxiosInstance, BASE_PATH: string, configuration?: Configuration) => (axios?: AxiosInstance, basePath?: string) => Promise<import("axios").AxiosResponse<never>>; | ||
export declare const createRequestFunction: (axiosArgs: RequestArgs, globalAxios: AxiosInstance, BASE_PATH: string, configuration?: Configuration) => (axios?: AxiosInstance, basePath?: string) => Promise<import("axios").AxiosResponse<any, any>>; |
@@ -1,1 +0,1 @@ | ||
export declare const VERSION = "1.3.6"; | ||
export declare const VERSION = "1.3.7-rc.1"; |
# Changelog | ||
### 0.22.0 (October 01, 2021) | ||
## [1.6.1](https://github.com/axios/axios/compare/v1.6.0...v1.6.1) (2023-11-08) | ||
Fixes and Functionality: | ||
- Caseless header comparing in HTTP adapter ([#2880](https://github.com/axios/axios/pull/2880)) | ||
- Avoid package.json import fixing issues and warnings related to this ([#4041](https://github.com/axios/axios/pull/4041)), ([#4065](https://github.com/axios/axios/pull/4065)) | ||
- Fixed cancelToken leakage and added AbortController support ([#3305](https://github.com/axios/axios/pull/3305)) | ||
- Updating CI to run on release branches | ||
- Bump follow redirects version | ||
- Fixed default transitional config for custom Axios instance; ([#4052](https://github.com/axios/axios/pull/4052)) | ||
Huge thanks to everyone who contributed to this release via code (authors listed below) or via reviews and triaging on GitHub: | ||
### Bug Fixes | ||
- [Jay](mailto:jasonsaayman@gmail.com) | ||
- [Matt R. Wilson](https://github.com/mastermatt) | ||
- [Xianming Zhong](https://github.com/chinesedfan) | ||
- [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS) | ||
* **formdata:** fixed content-type header normalization for non-standard browser environments; ([#6056](https://github.com/axios/axios/issues/6056)) ([dd465ab](https://github.com/axios/axios/commit/dd465ab22bbfa262c6567be6574bf46a057d5288)) | ||
* **platform:** fixed emulated browser detection in node.js environment; ([#6055](https://github.com/axios/axios/issues/6055)) ([3dc8369](https://github.com/axios/axios/commit/3dc8369e505e32a4e12c22f154c55fd63ac67fbb)) | ||
### 0.21.4 (September 6, 2021) | ||
### Contributors to this release | ||
Fixes and Functionality: | ||
- Fixing JSON transform when data is stringified. Providing backward compatability and complying to the JSON RFC standard ([#4020](https://github.com/axios/axios/pull/4020)) | ||
- <img src="https://avatars.githubusercontent.com/u/12586868?v=4&s=18" alt="avatar" width="18"/> [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+432/-65 (#6059 #6056 #6055 )") | ||
- <img src="https://avatars.githubusercontent.com/u/3982806?v=4&s=18" alt="avatar" width="18"/> [Fabian Meyer](https://github.com/meyfa "+5/-2 (#5835 )") | ||
Huge thanks to everyone who contributed to this release via code (authors listed below) or via reviews and triaging on GitHub: | ||
# [1.6.0](https://github.com/axios/axios/compare/v1.5.1...v1.6.0) (2023-10-26) | ||
- [Jay](mailto:jasonsaayman@gmail.com) | ||
- [Guillaume Fortaine](https://github.com/gfortaine) | ||
- [Yusuke Kawasaki](https://github.com/kawanet) | ||
- [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS) | ||
### 0.21.3 (September 4, 2021) | ||
### Bug Fixes | ||
Fixes and Functionality: | ||
- Fixing response interceptor not being called when request interceptor is attached ([#4013](https://github.com/axios/axios/pull/4013)) | ||
* **CSRF:** fixed CSRF vulnerability CVE-2023-45857 ([#6028](https://github.com/axios/axios/issues/6028)) ([96ee232](https://github.com/axios/axios/commit/96ee232bd3ee4de2e657333d4d2191cd389e14d0)) | ||
* **dns:** fixed lookup function decorator to work properly in node v20; ([#6011](https://github.com/axios/axios/issues/6011)) ([5aaff53](https://github.com/axios/axios/commit/5aaff532a6b820bb9ab6a8cd0f77131b47e2adb8)) | ||
* **types:** fix AxiosHeaders types; ([#5931](https://github.com/axios/axios/issues/5931)) ([a1c8ad0](https://github.com/axios/axios/commit/a1c8ad008b3c13d53e135bbd0862587fb9d3fc09)) | ||
Huge thanks to everyone who contributed to this release via code (authors listed below) or via reviews and triaging on GitHub: | ||
### PRs | ||
- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) ) | ||
``` | ||
- [Jay](mailto:jasonsaayman@gmail.com) | ||
- [Julian Hollmann](https://github.com/nerdbeere) | ||
⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459 | ||
``` | ||
### 0.21.2 (September 4, 2021) | ||
### Contributors to this release | ||
Fixes and Functionality: | ||
- <img src="https://avatars.githubusercontent.com/u/12586868?v=4&s=18" alt="avatar" width="18"/> [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+449/-114 (#6032 #6021 #6011 #5932 #5931 )") | ||
- <img src="https://avatars.githubusercontent.com/u/63700910?v=4&s=18" alt="avatar" width="18"/> [Valentin Panov](https://github.com/valentin-panov "+4/-4 (#6028 )") | ||
- <img src="https://avatars.githubusercontent.com/u/76877078?v=4&s=18" alt="avatar" width="18"/> [Rinku Chaudhari](https://github.com/therealrinku "+1/-1 (#5889 )") | ||
- Updating axios requests to be delayed by pre-emptive promise creation ([#2702](https://github.com/axios/axios/pull/2702)) | ||
- Adding "synchronous" and "runWhen" options to interceptors api ([#2702](https://github.com/axios/axios/pull/2702)) | ||
- Updating of transformResponse ([#3377](https://github.com/axios/axios/pull/3377)) | ||
- Adding ability to omit User-Agent header ([#3703](https://github.com/axios/axios/pull/3703)) | ||
- Adding multiple JSON improvements ([#3688](https://github.com/axios/axios/pull/3688), [#3763](https://github.com/axios/axios/pull/3763)) | ||
- Fixing quadratic runtime and extra memory usage when setting a maxContentLength ([#3738](https://github.com/axios/axios/pull/3738)) | ||
- Adding parseInt to config.timeout ([#3781](https://github.com/axios/axios/pull/3781)) | ||
- Adding custom return type support to interceptor ([#3783](https://github.com/axios/axios/pull/3783)) | ||
- Adding security fix for ReDoS vulnerability ([#3980](https://github.com/axios/axios/pull/3980)) | ||
## [1.5.1](https://github.com/axios/axios/compare/v1.5.0...v1.5.1) (2023-09-26) | ||
Internal and Tests: | ||
- Updating build dev dependancies ([#3401](https://github.com/axios/axios/pull/3401)) | ||
- Fixing builds running on Travis CI ([#3538](https://github.com/axios/axios/pull/3538)) | ||
- Updating follow rediect version ([#3694](https://github.com/axios/axios/pull/3694), [#3771](https://github.com/axios/axios/pull/3771)) | ||
- Updating karma sauce launcher to fix failing sauce tests ([#3712](https://github.com/axios/axios/pull/3712), [#3717](https://github.com/axios/axios/pull/3717)) | ||
- Updating content-type header for application/json to not contain charset field, according do RFC 8259 ([#2154](https://github.com/axios/axios/pull/2154)) | ||
- Fixing tests by bumping karma-sauce-launcher version ([#3813](https://github.com/axios/axios/pull/3813)) | ||
- Changing testing process from Travis CI to GitHub Actions ([#3938](https://github.com/axios/axios/pull/3938)) | ||
### Bug Fixes | ||
Documentation: | ||
* **adapters:** improved adapters loading logic to have clear error messages; ([#5919](https://github.com/axios/axios/issues/5919)) ([e410779](https://github.com/axios/axios/commit/e4107797a7a1376f6209fbecfbbce73d3faa7859)) | ||
* **formdata:** fixed automatic addition of the `Content-Type` header for FormData in non-browser environments; ([#5917](https://github.com/axios/axios/issues/5917)) ([bc9af51](https://github.com/axios/axios/commit/bc9af51b1886d1b3529617702f2a21a6c0ed5d92)) | ||
* **headers:** allow `content-encoding` header to handle case-insensitive values ([#5890](https://github.com/axios/axios/issues/5890)) ([#5892](https://github.com/axios/axios/issues/5892)) ([4c89f25](https://github.com/axios/axios/commit/4c89f25196525e90a6e75eda9cb31ae0a2e18acd)) | ||
* **types:** removed duplicated code ([9e62056](https://github.com/axios/axios/commit/9e6205630e1c9cf863adf141c0edb9e6d8d4b149)) | ||
- Updating documentation around the use of `AUTH_TOKEN` with multiple domain endpoints ([#3539](https://github.com/axios/axios/pull/3539)) | ||
- Remove duplication of item in changelog ([#3523](https://github.com/axios/axios/pull/3523)) | ||
- Fixing gramatical errors ([#2642](https://github.com/axios/axios/pull/2642)) | ||
- Fixing spelling error ([#3567](https://github.com/axios/axios/pull/3567)) | ||
- Moving gitpod metion ([#2637](https://github.com/axios/axios/pull/2637)) | ||
- Adding new axios documentation website link ([#3681](https://github.com/axios/axios/pull/3681), [#3707](https://github.com/axios/axios/pull/3707)) | ||
- Updating documentation around dispatching requests ([#3772](https://github.com/axios/axios/pull/3772)) | ||
- Adding documentation for the type guard isAxiosError ([#3767](https://github.com/axios/axios/pull/3767)) | ||
- Adding explanation of cancel token ([#3803](https://github.com/axios/axios/pull/3803)) | ||
- Updating CI status badge ([#3953](https://github.com/axios/axios/pull/3953)) | ||
- Fixing errors with JSON documentation ([#3936](https://github.com/axios/axios/pull/3936)) | ||
- Fixing README typo under Request Config ([#3825](https://github.com/axios/axios/pull/3825)) | ||
- Adding axios-multi-api to the ecosystem file ([#3817](https://github.com/axios/axios/pull/3817)) | ||
- Adding SECURITY.md to properly disclose security vulnerabilities ([#3981](https://github.com/axios/axios/pull/3981)) | ||
### Contributors to this release | ||
Huge thanks to everyone who contributed to this release via code (authors listed below) or via reviews and triaging on GitHub: | ||
- <img src="https://avatars.githubusercontent.com/u/12586868?v=4&s=18" alt="avatar" width="18"/> [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+89/-18 (#5919 #5917 )") | ||
- <img src="https://avatars.githubusercontent.com/u/110460234?v=4&s=18" alt="avatar" width="18"/> [David Dallas](https://github.com/DavidJDallas "+11/-5 ()") | ||
- <img src="https://avatars.githubusercontent.com/u/71556073?v=4&s=18" alt="avatar" width="18"/> [Sean Sattler](https://github.com/fb-sean "+2/-8 ()") | ||
- <img src="https://avatars.githubusercontent.com/u/4294069?v=4&s=18" alt="avatar" width="18"/> [Mustafa Ateş Uzun](https://github.com/0o001 "+4/-4 ()") | ||
- <img src="https://avatars.githubusercontent.com/u/132928043?v=4&s=18" alt="avatar" width="18"/> [Przemyslaw Motacki](https://github.com/sfc-gh-pmotacki "+2/-1 (#5892 )") | ||
- <img src="https://avatars.githubusercontent.com/u/5492927?v=4&s=18" alt="avatar" width="18"/> [Michael Di Prisco](https://github.com/Cadienvan "+1/-1 ()") | ||
- [Jay](mailto:jasonsaayman@gmail.com) | ||
- [Sasha Korotkov](https://github.com/SashaKoro) | ||
- [Daniel Lopretto](https://github.com/timemachine3030) | ||
- [Mike Bishop](https://github.com/MikeBishop) | ||
- [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS) | ||
- [Mark](https://github.com/bimbiltu) | ||
- [Philipe Gouveia Paixão](https://github.com/piiih) | ||
- [hippo](https://github.com/hippo2cat) | ||
- [ready-research](https://github.com/ready-research) | ||
- [Xianming Zhong](https://github.com/chinesedfan) | ||
- [Christopher Chrapka](https://github.com/OJezu) | ||
- [Brian Anglin](https://github.com/anglinb) | ||
- [Kohta Ito](https://github.com/koh110) | ||
- [Ali Clark](https://github.com/aliclark) | ||
- [caikan](https://github.com/caikan) | ||
- [Elina Gorshkova](https://github.com/elinagorshkova) | ||
- [Ryota Ikezawa](https://github.com/paveg) | ||
- [Nisar Hassan Naqvi](https://github.com/nisarhassan12) | ||
- [Jake](https://github.com/codemaster138) | ||
- [TagawaHirotaka](https://github.com/wafuwafu13) | ||
- [Johannes Jarbratt](https://github.com/johachi) | ||
- [Mo Sattler](https://github.com/MoSattler) | ||
- [Sam Carlton](https://github.com/ThatGuySam) | ||
- [Matt Czapliński](https://github.com/MattCCC) | ||
- [Ziding Zhang](https://github.com/zidingz) | ||
### PRs | ||
- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) ) | ||
``` | ||
### 0.21.1 (December 21, 2020) | ||
⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459 | ||
``` | ||
Fixes and Functionality: | ||
# [1.5.0](https://github.com/axios/axios/compare/v1.4.0...v1.5.0) (2023-08-26) | ||
- Hotfix: Prevent SSRF ([#3410](https://github.com/axios/axios/pull/3410)) | ||
- Protocol not parsed when setting proxy config from env vars ([#3070](https://github.com/axios/axios/pull/3070)) | ||
- Updating axios in types to be lower case ([#2797](https://github.com/axios/axios/pull/2797)) | ||
- Adding a type guard for `AxiosError` ([#2949](https://github.com/axios/axios/pull/2949)) | ||
Internal and Tests: | ||
### Bug Fixes | ||
- Remove the skipping of the `socket` http test ([#3364](https://github.com/axios/axios/pull/3364)) | ||
- Use different socket for Win32 test ([#3375](https://github.com/axios/axios/pull/3375)) | ||
* **adapter:** make adapter loading error more clear by using platform-specific adapters explicitly ([#5837](https://github.com/axios/axios/issues/5837)) ([9a414bb](https://github.com/axios/axios/commit/9a414bb6c81796a95c6c7fe668637825458e8b6d)) | ||
* **dns:** fixed `cacheable-lookup` integration; ([#5836](https://github.com/axios/axios/issues/5836)) ([b3e327d](https://github.com/axios/axios/commit/b3e327dcc9277bdce34c7ef57beedf644b00d628)) | ||
* **headers:** added support for setting header names that overlap with class methods; ([#5831](https://github.com/axios/axios/issues/5831)) ([d8b4ca0](https://github.com/axios/axios/commit/d8b4ca0ea5f2f05efa4edfe1e7684593f9f68273)) | ||
* **headers:** fixed common Content-Type header merging; ([#5832](https://github.com/axios/axios/issues/5832)) ([8fda276](https://github.com/axios/axios/commit/8fda2766b1e6bcb72c3fabc146223083ef13ce17)) | ||
Huge thanks to everyone who contributed to this release via code (authors listed below) or via reviews and triaging on GitHub: | ||
- Daniel Lopretto <timemachine3030@users.noreply.github.com> | ||
- Jason Kwok <JasonHK@users.noreply.github.com> | ||
- Jay <jasonsaayman@gmail.com> | ||
- Jonathan Foster <jonathan@jonathanfoster.io> | ||
- Remco Haszing <remcohaszing@gmail.com> | ||
- Xianming Zhong <chinesedfan@qq.com> | ||
### Features | ||
### 0.21.0 (October 23, 2020) | ||
* export getAdapter function ([#5324](https://github.com/axios/axios/issues/5324)) ([ca73eb8](https://github.com/axios/axios/commit/ca73eb878df0ae2dace81fe3a7f1fb5986231bf1)) | ||
* **export:** export adapters without `unsafe` prefix ([#5839](https://github.com/axios/axios/issues/5839)) ([1601f4a](https://github.com/axios/axios/commit/1601f4a27a81ab47fea228f1e244b2c4e3ce28bf)) | ||
Fixes and Functionality: | ||
### Contributors to this release | ||
- Fixing requestHeaders.Authorization ([#3287](https://github.com/axios/axios/pull/3287)) | ||
- Fixing node types ([#3237](https://github.com/axios/axios/pull/3237)) | ||
- Fixing axios.delete ignores config.data ([#3282](https://github.com/axios/axios/pull/3282)) | ||
- Revert "Fixing overwrite Blob/File type as Content-Type in browser. (#1773)" ([#3289](https://github.com/axios/axios/pull/3289)) | ||
- Fixing an issue that type 'null' and 'undefined' is not assignable to validateStatus when typescript strict option is enabled ([#3200](https://github.com/axios/axios/pull/3200)) | ||
- <img src="https://avatars.githubusercontent.com/u/12586868?v=4&s=18" alt="avatar" width="18"/> [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+66/-29 (#5839 #5837 #5836 #5832 #5831 )") | ||
- <img src="https://avatars.githubusercontent.com/u/102841186?v=4&s=18" alt="avatar" width="18"/> [夜葬](https://github.com/geekact "+42/-0 (#5324 )") | ||
- <img src="https://avatars.githubusercontent.com/u/65978976?v=4&s=18" alt="avatar" width="18"/> [Jonathan Budiman](https://github.com/JBudiman00 "+30/-0 (#5788 )") | ||
- <img src="https://avatars.githubusercontent.com/u/5492927?v=4&s=18" alt="avatar" width="18"/> [Michael Di Prisco](https://github.com/Cadienvan "+3/-5 (#5791 )") | ||
Internal and Tests: | ||
### PRs | ||
- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) ) | ||
``` | ||
- Lock travis to not use node v15 ([#3361](https://github.com/axios/axios/pull/3361)) | ||
⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459 | ||
``` | ||
Documentation: | ||
# [1.4.0](https://github.com/axios/axios/compare/v1.3.6...v1.4.0) (2023-04-27) | ||
- Fixing simple typo, existant -> existent ([#3252](https://github.com/axios/axios/pull/3252)) | ||
- Fixing typos ([#3309](https://github.com/axios/axios/pull/3309)) | ||
Huge thanks to everyone who contributed to this release via code (authors listed below) or via reviews and triaging on GitHub: | ||
### Bug Fixes | ||
- Allan Cruz <57270969+Allanbcruz@users.noreply.github.com> | ||
- George Cheng <Gerhut@GMail.com> | ||
- Jay <jasonsaayman@gmail.com> | ||
- Kevin Kirsche <Kev.Kirsche+GitHub@gmail.com> | ||
- Remco Haszing <remcohaszing@gmail.com> | ||
- Taemin Shin <cprayer13@gmail.com> | ||
- Tim Gates <tim.gates@iress.com> | ||
- Xianming Zhong <chinesedfan@qq.com> | ||
* **formdata:** add `multipart/form-data` content type for FormData payload on custom client environments; ([#5678](https://github.com/axios/axios/issues/5678)) ([bbb61e7](https://github.com/axios/axios/commit/bbb61e70cb1185adfb1cbbb86eaf6652c48d89d1)) | ||
* **package:** export package internals with unsafe path prefix; ([#5677](https://github.com/axios/axios/issues/5677)) ([df38c94](https://github.com/axios/axios/commit/df38c949f26414d88ba29ec1e353c4d4f97eaf09)) | ||
### 0.20.0 (August 20, 2020) | ||
Release of 0.20.0-pre as a full release with no other changes. | ||
### Features | ||
### 0.20.0-pre (July 15, 2020) | ||
* **dns:** added support for a custom lookup function; ([#5339](https://github.com/axios/axios/issues/5339)) ([2701911](https://github.com/axios/axios/commit/2701911260a1faa5cc5e1afe437121b330a3b7bb)) | ||
* **types:** export `AxiosHeaderValue` type. ([#5525](https://github.com/axios/axios/issues/5525)) ([726f1c8](https://github.com/axios/axios/commit/726f1c8e00cffa0461a8813a9bdcb8f8b9d762cf)) | ||
Fixes and Functionality: | ||
- Fixing response with utf-8 BOM can not parse to json ([#2419](https://github.com/axios/axios/pull/2419)) | ||
- fix: remove byte order marker (UTF-8 BOM) when transform response | ||
- fix: remove BOM only utf-8 | ||
- test: utf-8 BOM | ||
- fix: incorrect param name | ||
- Refactor mergeConfig without utils.deepMerge ([#2844](https://github.com/axios/axios/pull/2844)) | ||
- Adding failing test | ||
- Fixing #2587 default custom config persisting | ||
- Adding Concat keys and filter duplicates | ||
- Fixed value from CPE | ||
- update for review feedbacks | ||
- no deepMerge | ||
- only merge between plain objects | ||
- fix rename | ||
- always merge config by mergeConfig | ||
- extract function mergeDeepProperties | ||
- refactor mergeConfig with all keys, and add special logic for validateStatus | ||
- add test for resetting headers | ||
- add lots of tests and fix a bug | ||
- should not inherit `data` | ||
- use simple toString | ||
- Fixing overwrite Blob/File type as Content-Type in browser. ([#1773](https://github.com/axios/axios/pull/1773)) | ||
- Fixing an issue that type 'null' is not assignable to validateStatus ([#2773](https://github.com/axios/axios/pull/2773)) | ||
- Fixing special char encoding ([#1671](https://github.com/axios/axios/pull/1671)) | ||
- removing @ character from replacement list since it is a reserved character | ||
- Updating buildURL test to not include the @ character | ||
- Removing console logs | ||
- Fixing password encoding with special characters in basic authentication ([#1492](https://github.com/axios/axios/pull/1492)) | ||
- Fixing password encoding with special characters in basic authentication | ||
- Adding test to check if password with non-Latin1 characters pass | ||
- Fixing 'Network Error' in react native android ([#1487](https://github.com/axios/axios/pull/1487)) | ||
There is a bug in react native Android platform when using get method. It will trigger a 'Network Error' when passing the requestData which is an empty string to request.send function. So if the requestData is an empty string we can set it to null as well to fix the bug. | ||
- Fixing Cookie Helper with Async Components ([#1105](https://github.com/axios/axios/pull/1105)) ([#1107](https://github.com/axios/axios/pull/1107)) | ||
- Fixing 'progressEvent' type ([#2851](https://github.com/axios/axios/pull/2851)) | ||
- Fix 'progressEvent' type | ||
- Update axios.ts | ||
- Fixing getting local files (file://) failed ([#2470](https://github.com/axios/axios/pull/2470)) | ||
- fix issue #2416, #2396 | ||
- fix Eslint warn | ||
- Modify judgment conditions | ||
- add unit test | ||
- update unit test | ||
- update unit test | ||
- Allow PURGE method in typings ([#2191](https://github.com/axios/axios/pull/2191)) | ||
- Adding option to disable automatic decompression ([#2661](https://github.com/axios/axios/pull/2661)) | ||
- Adding ability to disable auto decompression | ||
- Updating decompress documentation in README | ||
- Fixing test\unit\adapters\http.js lint errors | ||
- Adding test for disabling auto decompression | ||
- Removing changes that fixed lint errors in tests | ||
- Removing formatting change to unit test | ||
- Add independent `maxBodyLength` option ([#2781](https://github.com/axios/axios/pull/2781)) | ||
- Add independent option to set the maximum size of the request body | ||
- Remove maxBodyLength check | ||
- Update README | ||
- Assert for error code and message | ||
- Adding responseEncoding to mergeConfig ([#1745](https://github.com/axios/axios/pull/1745)) | ||
- Compatible with follow-redirect aborts the request ([#2689](https://github.com/axios/axios/pull/2689)) | ||
- Compatible with follow-redirect aborts the request | ||
- Use the error code | ||
- Fix merging of params ([#2656](https://github.com/axios/axios/pull/2656)) | ||
- Name function to avoid ESLint func-names warning | ||
- Switch params config to merge list and update tests | ||
- Restore testing of both false and null | ||
- Restore test cases for keys without defaults | ||
- Include test for non-object values that aren't false-y. | ||
- Revert `finally` as `then` ([#2683](https://github.com/axios/axios/pull/2683)) | ||
### Performance Improvements | ||
Internal and Tests: | ||
* **merge-config:** optimize mergeConfig performance by avoiding duplicate key visits; ([#5679](https://github.com/axios/axios/issues/5679)) ([e6f7053](https://github.com/axios/axios/commit/e6f7053bf1a3e87cf1f9da8677e12e3fe829d68e)) | ||
- Fix stale bot config ([#3049](https://github.com/axios/axios/pull/3049)) | ||
- fix stale bot config | ||
- fix multiple lines | ||
- Add days and change name to work ([#3035](https://github.com/axios/axios/pull/3035)) | ||
- Update close-issues.yml ([#3031](https://github.com/axios/axios/pull/3031)) | ||
- Update close-issues.yml | ||
Update close message to read better 😄 | ||
- Fix use of quotations | ||
Use single quotes as per other .yml files | ||
- Remove user name form message | ||
- Add GitHub actions to close stale issues/prs ([#3029](https://github.com/axios/axios/pull/3029)) | ||
- prepare stale actions | ||
- update messages | ||
- Add exempt labels and lighten up comments | ||
- Add GitHub actions to close invalid issues ([#3022](https://github.com/axios/axios/pull/3022)) | ||
- add close actions | ||
- fix with checkout | ||
- update issue templates | ||
- add reminder | ||
- update close message | ||
- Add test with Node.js 12 ([#2860](https://github.com/axios/axios/pull/2860)) | ||
- test with Node.js 12 | ||
- test with latest | ||
- Adding console log on sandbox server startup ([#2210](https://github.com/axios/axios/pull/2210)) | ||
- Adding console log on sandbox server startup | ||
- Update server.js | ||
Add server error handling | ||
- Update server.js | ||
Better error message, remove retry. | ||
- Adding tests for method `options` type definitions ([#1996](https://github.com/axios/axios/pull/1996)) | ||
Update tests. | ||
- Add test for redirecting with too large response ([#2695](https://github.com/axios/axios/pull/2695)) | ||
- Fixing unit test failure in Windows OS ([#2601](https://github.com/axios/axios/pull/2601)) | ||
- Fixing issue for HEAD method and gzipped response ([#2666](https://github.com/axios/axios/pull/2666)) | ||
- Fix tests in browsers ([#2748](https://github.com/axios/axios/pull/2748)) | ||
- chore: add `jsdelivr` and `unpkg` support ([#2443](https://github.com/axios/axios/pull/2443)) | ||
### Contributors to this release | ||
Documentation: | ||
- <img src="https://avatars.githubusercontent.com/u/12586868?v=4&s=18" alt="avatar" width="18"/> [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+151/-16 (#5684 #5339 #5679 #5678 #5677 )") | ||
- <img src="https://avatars.githubusercontent.com/u/47537704?v=4&s=18" alt="avatar" width="18"/> [Arthur Fiorette](https://github.com/arthurfiorette "+19/-19 (#5525 )") | ||
- <img src="https://avatars.githubusercontent.com/u/43876655?v=4&s=18" alt="avatar" width="18"/> [PIYUSH NEGI](https://github.com/npiyush97 "+2/-18 (#5670 )") | ||
- Adding support for URLSearchParams in node ([#1900](https://github.com/axios/axios/pull/1900)) | ||
- Adding support for URLSearchParams in node | ||
- Remove un-needed code | ||
- Update utils.js | ||
- Make changes as suggested | ||
- Adding table of content (preview) ([#3050](https://github.com/axios/axios/pull/3050)) | ||
- add toc (preview) | ||
- remove toc in toc | ||
Signed-off-by: Moni <usmoni@gmail.com> | ||
- fix sublinks | ||
- fix indentation | ||
- remove redundant table links | ||
- update caps and indent | ||
- remove axios | ||
- Replace 'blacklist' with 'blocklist' ([#3006](https://github.com/axios/axios/pull/3006)) | ||
- docs(): Detailed config options environment. ([#2088](https://github.com/axios/axios/pull/2088)) | ||
- docs(): Detailed config options environment. | ||
- Update README.md | ||
- Include axios-data-unpacker in ECOSYSTEM.md ([#2080](https://github.com/axios/axios/pull/2080)) | ||
- Allow opening examples in Gitpod ([#1958](https://github.com/axios/axios/pull/1958)) | ||
- Remove axios.all() and axios.spread() from Readme.md ([#2727](https://github.com/axios/axios/pull/2727)) | ||
- remove axios.all(), axios.spread() | ||
- replace example | ||
- axios.all() -> Promise.all() | ||
- axios.spread(function (acct, perms)) -> function (acct, perms) | ||
- add deprecated mark | ||
- Update README.md ([#2887](https://github.com/axios/axios/pull/2887)) | ||
Small change to the data attribute doc of the config. A request body can also be set for DELETE methods but this wasn't mentioned in the documentation (it only mentioned POST, PUT and PATCH). Took my some 10-20 minutes until I realized that I don't need to manipulate the request body with transformRequest in the case of DELETE. | ||
- Include swagger-taxos-codegen in ECOSYSTEM.md ([#2162](https://github.com/axios/axios/pull/2162)) | ||
- Add CDNJS version badge in README.md ([#878](https://github.com/axios/axios/pull/878)) | ||
This badge will show the version on CDNJS! | ||
- Documentation update to clear up ambiguity in code examples ([#2928](https://github.com/axios/axios/pull/2928)) | ||
- Made an adjustment to the documentation to clear up any ambiguity around the use of "fs". This should help clear up that the code examples with "fs" cannot be used on the client side. | ||
- Update README.md about validateStatus ([#2912](https://github.com/axios/axios/pull/2912)) | ||
Rewrote the comment from "Reject only if the status code is greater than or equal to 500" to "Resolve only if the status code is less than 500" | ||
- Updating documentation for usage form-data ([#2805](https://github.com/axios/axios/pull/2805)) | ||
Closes #2049 | ||
- Fixing CHANGELOG.md issue link ([#2784](https://github.com/axios/axios/pull/2784)) | ||
- Include axios-hooks in ECOSYSTEM.md ([#2003](https://github.com/axios/axios/pull/2003)) | ||
- Added Response header access instructions ([#1901](https://github.com/axios/axios/pull/1901)) | ||
- Added Response header access instructions | ||
- Added note about using bracket notation | ||
- Add `onUploadProgress` and `onDownloadProgress` are browser only ([#2763](https://github.com/axios/axios/pull/2763)) | ||
Saw in #928 and #1966 that `onUploadProgress` and `onDownloadProgress` only work in the browser and was missing that from the README. | ||
- Update ' sign to ` in proxy spec ([#2778](https://github.com/axios/axios/pull/2778)) | ||
- Adding jsDelivr link in README ([#1110](https://github.com/axios/axios/pull/1110)) | ||
- Adding jsDelivr link | ||
- Add SRI | ||
- Remove SRI | ||
### PRs | ||
- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) ) | ||
``` | ||
Huge thanks to everyone who contributed to this release via code (authors listed | ||
below) or via reviews and triaging on GitHub: | ||
⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459 | ||
``` | ||
- Alan Wang <wp_scut@163.com> | ||
- Alexandru Ungureanu <khakcarot@gmail.com> | ||
- Anubhav Srivastava <anubhav.srivastava00@gmail.com> | ||
- Benny Neugebauer <bn@bennyn.de> | ||
- Cr <631807682@qq.com> | ||
- David <cygnidavid@gmail.com> | ||
- David Ko <david.ko@pvtmethod.com> | ||
- David Tanner <david.tanner@lifeomic.com> | ||
- Emily Morehouse <emilyemorehouse@gmail.com> | ||
- Felipe Martins <felipewmartins@gmail.com> | ||
- Fonger <5862369+Fonger@users.noreply.github.com> | ||
- Frostack <soulburn007@gmail.com> | ||
- George Cheng <Gerhut@GMail.com> | ||
- grumblerchester <grumblerchester@users.noreply.github.com> | ||
- Gustavo López <gualopezb@gmail.com> | ||
- hexaez <45806662+hexaez@users.noreply.github.com> | ||
- huangzuizui <huangzuizui@gmail.com> | ||
- Ian Wijma <ian@wij.ma> | ||
- Jay <jasonsaayman@gmail.com> | ||
- jeffjing <zgayjjf@qq.com> | ||
- jennynju <46782518+jennynju@users.noreply.github.com> | ||
- Jimmy Liao <52391190+jimmy-liao-gogoro@users.noreply.github.com> | ||
- Jonathan Sharpe <j.r.sharpe@gmail.com> | ||
- JounQin <admin@1stg.me> | ||
- Justin Beckwith <justin.beckwith@gmail.com> | ||
- Kamil Posiadała <3dcreator.pl@gmail.com> | ||
- Lukas Drgon <lukas.drgon@gmail.com> | ||
- marcinx <mail@marcinx.com> | ||
- Martti Laine <martti@codeclown.net> | ||
- Michał Zarach <michal.m.zarach@gmail.com> | ||
- Moni <usmoni@gmail.com> | ||
- Motonori Iwata <121048+iwata@users.noreply.github.com> | ||
- Nikita Galkin <nikita@galk.in> | ||
- Petr Mares <petr@mares.tw> | ||
- Philippe Recto <precto1285@gmal.com> | ||
- Remco Haszing <remcohaszing@gmail.com> | ||
- rockcs1992 <chengshi1219@gmail.com> | ||
- Ryan Bown <rbown@niftee.com.au> | ||
- Samina Fu <sufuf3@gmail.com> | ||
- Simone Busoli <simone.busoli@gmail.com> | ||
- Spencer von der Ohe <s.vonderohe40@gmail.com> | ||
- Sven Efftinge <sven.efftinge@typefox.io> | ||
- Taegyeoung Oh <otk1090@naver.com> | ||
- Taemin Shin <cprayer13@gmail.com> | ||
- Thibault Ehrhart <1208424+ehrhart@users.noreply.github.com> | ||
- Xianming Zhong <chinesedfan@qq.com> | ||
- Yasu Flores <carlosyasu91@gmail.com> | ||
- Zac Delventhal <delventhalz@gmail.com> | ||
## [1.3.6](https://github.com/axios/axios/compare/v1.3.5...v1.3.6) (2023-04-19) | ||
### 0.19.2 (Jan 20, 2020) | ||
- Remove unnecessary XSS check ([#2679](https://github.com/axios/axios/pull/2679)) (see ([#2646](https://github.com/axios/axios/issues/2646)) for discussion) | ||
### Bug Fixes | ||
### 0.19.1 (Jan 7, 2020) | ||
* **types:** added transport to RawAxiosRequestConfig ([#5445](https://github.com/axios/axios/issues/5445)) ([6f360a2](https://github.com/axios/axios/commit/6f360a2531d8d70363fd9becef6a45a323f170e2)) | ||
* **utils:** make isFormData detection logic stricter to avoid unnecessary calling of the `toString` method on the target; ([#5661](https://github.com/axios/axios/issues/5661)) ([aa372f7](https://github.com/axios/axios/commit/aa372f7306295dfd1100c1c2c77ce95c95808e76)) | ||
Fixes and Functionality: | ||
### Contributors to this release | ||
- Fixing invalid agent issue ([#1904](https://github.com/axios/axios/pull/1904)) | ||
- Fix ignore set withCredentials false ([#2582](https://github.com/axios/axios/pull/2582)) | ||
- Delete useless default to hash ([#2458](https://github.com/axios/axios/pull/2458)) | ||
- Fix HTTP/HTTPs agents passing to follow-redirect ([#1904](https://github.com/axios/axios/pull/1904)) | ||
- Fix ignore set withCredentials false ([#2582](https://github.com/axios/axios/pull/2582)) | ||
- Fix CI build failure ([#2570](https://github.com/axios/axios/pull/2570)) | ||
- Remove dependency on is-buffer from package.json ([#1816](https://github.com/axios/axios/pull/1816)) | ||
- Adding options typings ([#2341](https://github.com/axios/axios/pull/2341)) | ||
- Adding Typescript HTTP method definition for LINK and UNLINK. ([#2444](https://github.com/axios/axios/pull/2444)) | ||
- Update dist with newest changes, fixes Custom Attributes issue | ||
- Change syntax to see if build passes ([#2488](https://github.com/axios/axios/pull/2488)) | ||
- Update Webpack + deps, remove now unnecessary polyfills ([#2410](https://github.com/axios/axios/pull/2410)) | ||
- Fix to prevent XSS, throw an error when the URL contains a JS script ([#2464](https://github.com/axios/axios/pull/2464)) | ||
- Add custom timeout error copy in config ([#2275](https://github.com/axios/axios/pull/2275)) | ||
- Add error toJSON example ([#2466](https://github.com/axios/axios/pull/2466)) | ||
- Fixing Vulnerability A Fortify Scan finds a critical Cross-Site Scrip… ([#2451](https://github.com/axios/axios/pull/2451)) | ||
- Fixing subdomain handling on no_proxy ([#2442](https://github.com/axios/axios/pull/2442)) | ||
- Make redirection from HTTP to HTTPS work ([#2426](https://github.com/axios/axios/pull/2426)) and ([#2547](https://github.com/axios/axios/pull/2547)) | ||
- Add toJSON property to AxiosError type ([#2427](https://github.com/axios/axios/pull/2427)) | ||
- Fixing socket hang up error on node side for slow response. ([#1752](https://github.com/axios/axios/pull/1752)) | ||
- Alternative syntax to send data into the body ([#2317](https://github.com/axios/axios/pull/2317)) | ||
- Fixing custom config options ([#2207](https://github.com/axios/axios/pull/2207)) | ||
- Fixing set `config.method` after mergeConfig for Axios.prototype.request ([#2383](https://github.com/axios/axios/pull/2383)) | ||
- Axios create url bug ([#2290](https://github.com/axios/axios/pull/2290)) | ||
- Do not modify config.url when using a relative baseURL (resolves [#1628](https://github.com/axios/axios/issues/1098)) ([#2391](https://github.com/axios/axios/pull/2391)) | ||
- <img src="https://avatars.githubusercontent.com/u/12586868?v=4&s=18" alt="avatar" width="18"/> [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+48/-10 (#5665 #5661 #5663 )") | ||
- <img src="https://avatars.githubusercontent.com/u/5492927?v=4&s=18" alt="avatar" width="18"/> [Michael Di Prisco](https://github.com/Cadienvan "+2/-0 (#5445 )") | ||
Internal: | ||
### PRs | ||
- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) ) | ||
``` | ||
- Revert "Update Webpack + deps, remove now unnecessary polyfills" ([#2479](https://github.com/axios/axios/pull/2479)) | ||
- Order of if/else blocks is causing unit tests mocking XHR. ([#2201](https://github.com/axios/axios/pull/2201)) | ||
- Add license badge ([#2446](https://github.com/axios/axios/pull/2446)) | ||
- Fix travis CI build [#2386](https://github.com/axios/axios/pull/2386) | ||
- Fix cancellation error on build master. #2290 #2207 ([#2407](https://github.com/axios/axios/pull/2407)) | ||
⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459 | ||
``` | ||
Documentation: | ||
## [1.3.5](https://github.com/axios/axios/compare/v1.3.4...v1.3.5) (2023-04-05) | ||
- Fixing typo in CHANGELOG.md: s/Functionallity/Functionality ([#2639](https://github.com/axios/axios/pull/2639)) | ||
- Fix badge, use master branch ([#2538](https://github.com/axios/axios/pull/2538)) | ||
- Fix typo in changelog [#2193](https://github.com/axios/axios/pull/2193) | ||
- Document fix ([#2514](https://github.com/axios/axios/pull/2514)) | ||
- Update docs with no_proxy change, issue #2484 ([#2513](https://github.com/axios/axios/pull/2513)) | ||
- Fixing missing words in docs template ([#2259](https://github.com/axios/axios/pull/2259)) | ||
- 🐛Fix request finally documentation in README ([#2189](https://github.com/axios/axios/pull/2189)) | ||
- updating spelling and adding link to docs ([#2212](https://github.com/axios/axios/pull/2212)) | ||
- docs: minor tweak ([#2404](https://github.com/axios/axios/pull/2404)) | ||
- Update response interceptor docs ([#2399](https://github.com/axios/axios/pull/2399)) | ||
- Update README.md ([#2504](https://github.com/axios/axios/pull/2504)) | ||
- Fix word 'sintaxe' to 'syntax' in README.md ([#2432](https://github.com/axios/axios/pull/2432)) | ||
- updating README: notes on CommonJS autocomplete ([#2256](https://github.com/axios/axios/pull/2256)) | ||
- Fix grammar in README.md ([#2271](https://github.com/axios/axios/pull/2271)) | ||
- Doc fixes, minor examples cleanup ([#2198](https://github.com/axios/axios/pull/2198)) | ||
### 0.19.0 (May 30, 2019) | ||
### Bug Fixes | ||
Fixes and Functionality: | ||
* **headers:** fixed isValidHeaderName to support full list of allowed characters; ([#5584](https://github.com/axios/axios/issues/5584)) ([e7decef](https://github.com/axios/axios/commit/e7decef6a99f4627e27ed9ea5b00ce8e201c3841)) | ||
* **params:** re-added the ability to set the function as `paramsSerializer` config; ([#5633](https://github.com/axios/axios/issues/5633)) ([a56c866](https://github.com/axios/axios/commit/a56c8661209d5ce5a645a05f294a0e08a6c1f6b3)) | ||
- Added support for no_proxy env variable ([#1693](https://github.com/axios/axios/pull/1693/files)) - Chance Dickson | ||
- Unzip response body only for statuses != 204 ([#1129](https://github.com/axios/axios/pull/1129)) - drawski | ||
- Destroy stream on exceeding maxContentLength (fixes [#1098](https://github.com/axios/axios/issues/1098)) ([#1485](https://github.com/axios/axios/pull/1485)) - Gadzhi Gadzhiev | ||
- Makes Axios error generic to use AxiosResponse ([#1738](https://github.com/axios/axios/pull/1738)) - Suman Lama | ||
- Fixing Mocha tests by locking follow-redirects version to 1.5.10 ([#1993](https://github.com/axios/axios/pull/1993)) - grumblerchester | ||
- Allow uppercase methods in typings. ([#1781](https://github.com/axios/axios/pull/1781)) - Ken Powers | ||
- Fixing building url with hash mark ([#1771](https://github.com/axios/axios/pull/1771)) - Anatoly Ryabov | ||
- This commit fix building url with hash map (fragment identifier) when parameters are present: they must not be added after `#`, because client cut everything after `#` | ||
- Preserve HTTP method when following redirect ([#1758](https://github.com/axios/axios/pull/1758)) - Rikki Gibson | ||
- Add `getUri` signature to TypeScript definition. ([#1736](https://github.com/axios/axios/pull/1736)) - Alexander Trauzzi | ||
- Adding isAxiosError flag to errors thrown by axios ([#1419](https://github.com/axios/axios/pull/1419)) - Ayush Gupta | ||
### Contributors to this release | ||
Internal: | ||
- <img src="https://avatars.githubusercontent.com/u/12586868?v=4&s=18" alt="avatar" width="18"/> [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+28/-10 (#5633 #5584 )") | ||
- Fixing .eslintrc without extension ([#1789](https://github.com/axios/axios/pull/1789)) - Manoel | ||
- Fix failing SauceLabs tests by updating configuration - Emily Morehouse | ||
- Add issue templates - Emily Morehouse | ||
### PRs | ||
- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) ) | ||
``` | ||
Documentation: | ||
⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459 | ||
``` | ||
- Consistent coding style in README ([#1787](https://github.com/axios/axios/pull/1787)) - Ali Servet Donmez | ||
- Add information about auth parameter to README ([#2166](https://github.com/axios/axios/pull/2166)) - xlaguna | ||
- Add DELETE to list of methods that allow data as a config option ([#2169](https://github.com/axios/axios/pull/2169)) - Daniela Borges Matos de Carvalho | ||
- Update ECOSYSTEM.md - Add Axios Endpoints ([#2176](https://github.com/axios/axios/pull/2176)) - Renan | ||
- Add r2curl in ECOSYSTEM ([#2141](https://github.com/axios/axios/pull/2141)) - 유용우 / CX | ||
- Update README.md - Add instructions for installing with yarn ([#2036](https://github.com/axios/axios/pull/2036)) - Victor Hermes | ||
- Fixing spacing for README.md ([#2066](https://github.com/axios/axios/pull/2066)) - Josh McCarty | ||
- Update README.md. - Change `.then` to `.finally` in example code ([#2090](https://github.com/axios/axios/pull/2090)) - Omar Cai | ||
- Clarify what values responseType can have in Node ([#2121](https://github.com/axios/axios/pull/2121)) - Tyler Breisacher | ||
- docs(ECOSYSTEM): add axios-api-versioning ([#2020](https://github.com/axios/axios/pull/2020)) - Weffe | ||
- It seems that `responseType: 'blob'` doesn't actually work in Node (when I tried using it, response.data was a string, not a Blob, since Node doesn't have Blobs), so this clarifies that this option should only be used in the browser | ||
- Update README.md. - Add Querystring library note ([#1896](https://github.com/axios/axios/pull/1896)) - Dmitriy Eroshenko | ||
- Add react-hooks-axios to Libraries section of ECOSYSTEM.md ([#1925](https://github.com/axios/axios/pull/1925)) - Cody Chan | ||
- Clarify in README that default timeout is 0 (no timeout) ([#1750](https://github.com/axios/axios/pull/1750)) - Ben Standefer | ||
## [1.3.4](https://github.com/axios/axios/compare/v1.3.3...v1.3.4) (2023-02-22) | ||
### 0.19.0-beta.1 (Aug 9, 2018) | ||
**NOTE:** This is a beta version of this release. There may be functionality that is broken in | ||
certain browsers, though we suspect that builds are hanging and not erroring. See | ||
https://saucelabs.com/u/axios for the most up-to-date information. | ||
### Bug Fixes | ||
New Functionality: | ||
* **blob:** added a check to make sure the Blob class is available in the browser's global scope; ([#5548](https://github.com/axios/axios/issues/5548)) ([3772c8f](https://github.com/axios/axios/commit/3772c8fe74112a56e3e9551f894d899bc3a9443a)) | ||
* **http:** fixed regression bug when handling synchronous errors inside the adapter; ([#5564](https://github.com/axios/axios/issues/5564)) ([a3b246c](https://github.com/axios/axios/commit/a3b246c9de5c3bc4b5a742e15add55b375479451)) | ||
- Add getUri method ([#1712](https://github.com/axios/axios/issues/1712)) | ||
- Add support for no_proxy env variable ([#1693](https://github.com/axios/axios/issues/1693)) | ||
- Add toJSON to decorated Axios errors to facilitate serialization ([#1625](https://github.com/axios/axios/issues/1625)) | ||
- Add second then on axios call ([#1623](https://github.com/axios/axios/issues/1623)) | ||
- Typings: allow custom return types | ||
- Add option to specify character set in responses (with http adapter) | ||
### Contributors to this release | ||
Fixes: | ||
- <img src="https://avatars.githubusercontent.com/u/12586868?v=4&s=18" alt="avatar" width="18"/> [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+38/-26 (#5564 )") | ||
- <img src="https://avatars.githubusercontent.com/u/19550000?v=4&s=18" alt="avatar" width="18"/> [lcysgsg](https://github.com/lcysgsg "+4/-0 (#5548 )") | ||
- <img src="https://avatars.githubusercontent.com/u/5492927?v=4&s=18" alt="avatar" width="18"/> [Michael Di Prisco](https://github.com/Cadienvan "+3/-0 (#5444 )") | ||
- Fix Keep defaults local to instance ([#385](https://github.com/axios/axios/issues/385)) | ||
- Correctly catch exception in http test ([#1475](https://github.com/axios/axios/issues/1475)) | ||
- Fix accept header normalization ([#1698](https://github.com/axios/axios/issues/1698)) | ||
- Fix http adapter to allow HTTPS connections via HTTP ([#959](https://github.com/axios/axios/issues/959)) | ||
- Fix Removes usage of deprecated Buffer constructor. ([#1555](https://github.com/axios/axios/issues/1555), [#1622](https://github.com/axios/axios/issues/1622)) | ||
- Fix defaults to use httpAdapter if available ([#1285](https://github.com/axios/axios/issues/1285)) | ||
- Fixing defaults to use httpAdapter if available | ||
- Use a safer, cross-platform method to detect the Node environment | ||
- Fix Reject promise if request is cancelled by the browser ([#537](https://github.com/axios/axios/issues/537)) | ||
- [Typescript] Fix missing type parameters on delete/head methods | ||
- [NS]: Send `false` flag isStandardBrowserEnv for Nativescript | ||
- Fix missing type parameters on delete/head | ||
- Fix Default method for an instance always overwritten by get | ||
- Fix type error when socketPath option in AxiosRequestConfig | ||
- Capture errors on request data streams | ||
- Decorate resolve and reject to clear timeout in all cases | ||
### PRs | ||
- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) ) | ||
``` | ||
Huge thanks to everyone who contributed to this release via code (authors listed | ||
below) or via reviews and triaging on GitHub: | ||
⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459 | ||
``` | ||
- Andrew Scott <ascott18@gmail.com> | ||
- Anthony Gauthier <antho325@hotmail.com> | ||
- arpit <arpit2438735@gmail.com> | ||
- ascott18 | ||
- Benedikt Rötsch <axe312ger@users.noreply.github.com> | ||
- Chance Dickson <me@chancedickson.com> | ||
- Dave Stewart <info@davestewart.co.uk> | ||
- Deric Cain <deric.cain@gmail.com> | ||
- Guillaume Briday <guillaumebriday@gmail.com> | ||
- Jacob Wejendorp <jacob@wejendorp.dk> | ||
- Jim Lynch <mrdotjim@gmail.com> | ||
- johntron | ||
- Justin Beckwith <beckwith@google.com> | ||
- Justin Beckwith <justin.beckwith@gmail.com> | ||
- Khaled Garbaya <khaledgarbaya@gmail.com> | ||
- Lim Jing Rong <jjingrong@users.noreply.github.com> | ||
- Mark van den Broek <mvdnbrk@gmail.com> | ||
- Martti Laine <martti@codeclown.net> | ||
- mattridley | ||
- mattridley <matt.r@joinblink.com> | ||
- Nicolas Del Valle <nicolas.delvalle@gmail.com> | ||
- Nilegfx | ||
- pbarbiero | ||
- Rikki Gibson <rikkigibson@gmail.com> | ||
- Sako Hartounian <sakohartounian@yahoo.com> | ||
- Shane Fitzpatrick <fitzpasd@gmail.com> | ||
- Stephan Schneider <stephanschndr@gmail.com> | ||
- Steven <steven@ceriously.com> | ||
- Tim Garthwaite <tim.garthwaite@jibo.com> | ||
- Tim Johns <timjohns@yahoo.com> | ||
- Yutaro Miyazaki <yutaro@studio-rubbish.com> | ||
## [1.3.3](https://github.com/axios/axios/compare/v1.3.2...v1.3.3) (2023-02-13) | ||
### 0.18.0 (Feb 19, 2018) | ||
- Adding support for UNIX Sockets when running with Node.js ([#1070](https://github.com/axios/axios/pull/1070)) | ||
- Fixing typings ([#1177](https://github.com/axios/axios/pull/1177)): | ||
- AxiosRequestConfig.proxy: allows type false | ||
- AxiosProxyConfig: added auth field | ||
- Adding function signature in AxiosInstance interface so AxiosInstance can be invoked ([#1192](https://github.com/axios/axios/pull/1192), [#1254](https://github.com/axios/axios/pull/1254)) | ||
- Allowing maxContentLength to pass through to redirected calls as maxBodyLength in follow-redirects config ([#1287](https://github.com/axios/axios/pull/1287)) | ||
- Fixing configuration when using an instance - method can now be set ([#1342](https://github.com/axios/axios/pull/1342)) | ||
### Bug Fixes | ||
### 0.17.1 (Nov 11, 2017) | ||
* **formdata:** added a check to make sure the FormData class is available in the browser's global scope; ([#5545](https://github.com/axios/axios/issues/5545)) ([a6dfa72](https://github.com/axios/axios/commit/a6dfa72010db5ad52db8bd13c0f98e537e8fd05d)) | ||
* **formdata:** fixed setting NaN as Content-Length for form payload in some cases; ([#5535](https://github.com/axios/axios/issues/5535)) ([c19f7bf](https://github.com/axios/axios/commit/c19f7bf770f90ae8307f4ea3104f227056912da1)) | ||
* **headers:** fixed the filtering logic of the clear method; ([#5542](https://github.com/axios/axios/issues/5542)) ([ea87ebf](https://github.com/axios/axios/commit/ea87ebfe6d1699af072b9e7cd40faf8f14b0ab93)) | ||
- Fixing issue with web workers ([#1160](https://github.com/axios/axios/pull/1160)) | ||
- Allowing overriding transport ([#1080](https://github.com/axios/axios/pull/1080)) | ||
- Updating TypeScript typings ([#1165](https://github.com/axios/axios/pull/1165), [#1125](https://github.com/axios/axios/pull/1125), [#1131](https://github.com/axios/axios/pull/1131)) | ||
### Contributors to this release | ||
### 0.17.0 (Oct 21, 2017) | ||
- <img src="https://avatars.githubusercontent.com/u/12586868?v=4&s=18" alt="avatar" width="18"/> [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+11/-7 (#5545 #5535 #5542 )") | ||
- <img src="https://avatars.githubusercontent.com/u/19842213?v=4&s=18" alt="avatar" width="18"/> [陈若枫](https://github.com/ruofee "+2/-2 (#5467 )") | ||
- **BREAKING** Fixing issue with `baseURL` and interceptors ([#950](https://github.com/axios/axios/pull/950)) | ||
- **BREAKING** Improving handing of duplicate headers ([#874](https://github.com/axios/axios/pull/874)) | ||
- Adding support for disabling proxies ([#691](https://github.com/axios/axios/pull/691)) | ||
- Updating TypeScript typings with generic type parameters ([#1061](https://github.com/axios/axios/pull/1061)) | ||
### PRs | ||
- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) ) | ||
``` | ||
### 0.16.2 (Jun 3, 2017) | ||
⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459 | ||
``` | ||
- Fixing issue with including `buffer` in bundle ([#887](https://github.com/axios/axios/pull/887)) | ||
- Including underlying request in errors ([#830](https://github.com/axios/axios/pull/830)) | ||
- Convert `method` to lowercase ([#930](https://github.com/axios/axios/pull/930)) | ||
## [1.3.2](https://github.com/axios/axios/compare/v1.3.1...v1.3.2) (2023-02-03) | ||
### 0.16.1 (Apr 8, 2017) | ||
- Improving HTTP adapter to return last request in case of redirects ([#828](https://github.com/axios/axios/pull/828)) | ||
- Updating `follow-redirects` dependency ([#829](https://github.com/axios/axios/pull/829)) | ||
- Adding support for passing `Buffer` in node ([#773](https://github.com/axios/axios/pull/773)) | ||
### Bug Fixes | ||
### 0.16.0 (Mar 31, 2017) | ||
* **http:** treat http://localhost as base URL for relative paths to avoid `ERR_INVALID_URL` error; ([#5528](https://github.com/axios/axios/issues/5528)) ([128d56f](https://github.com/axios/axios/commit/128d56f4a0fb8f5f2ed6e0dd80bc9225fee9538c)) | ||
* **http:** use explicit import instead of TextEncoder global; ([#5530](https://github.com/axios/axios/issues/5530)) ([6b3c305](https://github.com/axios/axios/commit/6b3c305fc40c56428e0afabedc6f4d29c2830f6f)) | ||
- **BREAKING** Removing `Promise` from axios typings in favor of built-in type declarations ([#480](https://github.com/axios/axios/issues/480)) | ||
- Adding `options` shortcut method ([#461](https://github.com/axios/axios/pull/461)) | ||
- Fixing issue with using `responseType: 'json'` in browsers incompatible with XHR Level 2 ([#654](https://github.com/axios/axios/pull/654)) | ||
- Improving React Native detection ([#731](https://github.com/axios/axios/pull/731)) | ||
- Fixing `combineURLs` to support empty `relativeURL` ([#581](https://github.com/axios/axios/pull/581)) | ||
- Removing `PROTECTION_PREFIX` support ([#561](https://github.com/axios/axios/pull/561)) | ||
### Contributors to this release | ||
### 0.15.3 (Nov 27, 2016) | ||
- <img src="https://avatars.githubusercontent.com/u/12586868?v=4&s=18" alt="avatar" width="18"/> [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+2/-1 (#5530 #5528 )") | ||
- Fixing issue with custom instances and global defaults ([#443](https://github.com/axios/axios/issues/443)) | ||
- Renaming `axios.d.ts` to `index.d.ts` ([#519](https://github.com/axios/axios/issues/519)) | ||
- Adding `get`, `head`, and `delete` to `defaults.headers` ([#509](https://github.com/axios/axios/issues/509)) | ||
- Fixing issue with `btoa` and IE ([#507](https://github.com/axios/axios/issues/507)) | ||
- Adding support for proxy authentication ([#483](https://github.com/axios/axios/pull/483)) | ||
- Improving HTTP adapter to use `http` protocol by default ([#493](https://github.com/axios/axios/pull/493)) | ||
- Fixing proxy issues ([#491](https://github.com/axios/axios/pull/491)) | ||
### PRs | ||
- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) ) | ||
``` | ||
### 0.15.2 (Oct 17, 2016) | ||
⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459 | ||
``` | ||
- Fixing issue with calling `cancel` after response has been received ([#482](https://github.com/axios/axios/issues/482)) | ||
## [1.3.1](https://github.com/axios/axios/compare/v1.3.0...v1.3.1) (2023-02-01) | ||
### 0.15.1 (Oct 14, 2016) | ||
- Fixing issue with UMD ([#485](https://github.com/axios/axios/issues/485)) | ||
### Bug Fixes | ||
### 0.15.0 (Oct 10, 2016) | ||
* **formdata:** add hotfix to use the asynchronous API to compute the content-length header value; ([#5521](https://github.com/axios/axios/issues/5521)) ([96d336f](https://github.com/axios/axios/commit/96d336f527619f21da012fe1f117eeb53e5a2120)) | ||
* **serializer:** fixed serialization of array-like objects; ([#5518](https://github.com/axios/axios/issues/5518)) ([08104c0](https://github.com/axios/axios/commit/08104c028c0f9353897b1b6691d74c440fd0c32d)) | ||
- Adding cancellation support ([#452](https://github.com/axios/axios/pull/452)) | ||
- Moving default adapter to global defaults ([#437](https://github.com/axios/axios/pull/437)) | ||
- Fixing issue with `file` URI scheme ([#440](https://github.com/axios/axios/pull/440)) | ||
- Fixing issue with `params` objects that have no prototype ([#445](https://github.com/axios/axios/pull/445)) | ||
### Contributors to this release | ||
### 0.14.0 (Aug 27, 2016) | ||
- <img src="https://avatars.githubusercontent.com/u/12586868?v=4&s=18" alt="avatar" width="18"/> [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+27/-8 (#5521 #5518 )") | ||
- **BREAKING** Updating TypeScript definitions ([#419](https://github.com/axios/axios/pull/419)) | ||
- **BREAKING** Replacing `agent` option with `httpAgent` and `httpsAgent` ([#387](https://github.com/axios/axios/pull/387)) | ||
- **BREAKING** Splitting `progress` event handlers into `onUploadProgress` and `onDownloadProgress` ([#423](https://github.com/axios/axios/pull/423)) | ||
- Adding support for `http_proxy` and `https_proxy` environment variables ([#366](https://github.com/axios/axios/pull/366)) | ||
- Fixing issue with `auth` config option and `Authorization` header ([#397](https://github.com/axios/axios/pull/397)) | ||
- Don't set XSRF header if `xsrfCookieName` is `null` ([#406](https://github.com/axios/axios/pull/406)) | ||
### PRs | ||
- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) ) | ||
``` | ||
### 0.13.1 (Jul 16, 2016) | ||
⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459 | ||
``` | ||
- Fixing issue with response data not being transformed on error ([#378](https://github.com/axios/axios/issues/378)) | ||
# [1.3.0](https://github.com/axios/axios/compare/v1.2.6...v1.3.0) (2023-01-31) | ||
### 0.13.0 (Jul 13, 2016) | ||
- **BREAKING** Improved error handling ([#345](https://github.com/axios/axios/pull/345)) | ||
- **BREAKING** Response transformer now invoked in dispatcher not adapter ([10eb238](https://github.com/axios/axios/commit/10eb23865101f9347570552c04e9d6211376e25e)) | ||
- **BREAKING** Request adapters now return a `Promise` ([157efd5](https://github.com/axios/axios/commit/157efd5615890301824e3121cc6c9d2f9b21f94a)) | ||
- Fixing issue with `withCredentials` not being overwritten ([#343](https://github.com/axios/axios/issues/343)) | ||
- Fixing regression with request transformer being called before request interceptor ([#352](https://github.com/axios/axios/issues/352)) | ||
- Fixing custom instance defaults ([#341](https://github.com/axios/axios/issues/341)) | ||
- Fixing instances created from `axios.create` to have same API as default axios ([#217](https://github.com/axios/axios/issues/217)) | ||
### Bug Fixes | ||
### 0.12.0 (May 31, 2016) | ||
* **headers:** fixed & optimized clear method; ([#5507](https://github.com/axios/axios/issues/5507)) ([9915635](https://github.com/axios/axios/commit/9915635c69d0ab70daca5738488421f67ca60959)) | ||
* **http:** add zlib headers if missing ([#5497](https://github.com/axios/axios/issues/5497)) ([65e8d1e](https://github.com/axios/axios/commit/65e8d1e28ce829f47a837e45129730e541950d3c)) | ||
- Adding support for `URLSearchParams` ([#317](https://github.com/axios/axios/pull/317)) | ||
- Adding `maxRedirects` option ([#307](https://github.com/axios/axios/pull/307)) | ||
### 0.11.1 (May 17, 2016) | ||
### Features | ||
- Fixing IE CORS support ([#313](https://github.com/axios/axios/pull/313)) | ||
- Fixing detection of `FormData` ([#325](https://github.com/axios/axios/pull/325)) | ||
- Adding `Axios` class to exports ([#321](https://github.com/axios/axios/pull/321)) | ||
* **fomdata:** added support for spec-compliant FormData & Blob types; ([#5316](https://github.com/axios/axios/issues/5316)) ([6ac574e](https://github.com/axios/axios/commit/6ac574e00a06731288347acea1e8246091196953)) | ||
### 0.11.0 (Apr 26, 2016) | ||
### Contributors to this release | ||
- Adding support for Stream with HTTP adapter ([#296](https://github.com/axios/axios/pull/296)) | ||
- Adding support for custom HTTP status code error ranges ([#308](https://github.com/axios/axios/pull/308)) | ||
- Fixing issue with ArrayBuffer ([#299](https://github.com/axios/axios/pull/299)) | ||
- <img src="https://avatars.githubusercontent.com/u/12586868?v=4&s=18" alt="avatar" width="18"/> [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+352/-67 (#5514 #5512 #5510 #5509 #5508 #5316 #5507 )") | ||
- <img src="https://avatars.githubusercontent.com/u/35015993?v=4&s=18" alt="avatar" width="18"/> [ItsNotGoodName](https://github.com/ItsNotGoodName "+43/-2 (#5497 )") | ||
### 0.10.0 (Apr 20, 2016) | ||
### PRs | ||
- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) ) | ||
``` | ||
- Fixing issue with some requests sending `undefined` instead of `null` ([#250](https://github.com/axios/axios/pull/250)) | ||
- Fixing basic auth for HTTP adapter ([#252](https://github.com/axios/axios/pull/252)) | ||
- Fixing request timeout for XHR adapter ([#227](https://github.com/axios/axios/pull/227)) | ||
- Fixing IE8 support by using `onreadystatechange` instead of `onload` ([#249](https://github.com/axios/axios/pull/249)) | ||
- Fixing IE9 cross domain requests ([#251](https://github.com/axios/axios/pull/251)) | ||
- Adding `maxContentLength` option ([#275](https://github.com/axios/axios/pull/275)) | ||
- Fixing XHR support for WebWorker environment ([#279](https://github.com/axios/axios/pull/279)) | ||
- Adding request instance to response ([#200](https://github.com/axios/axios/pull/200)) | ||
⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459 | ||
``` | ||
### 0.9.1 (Jan 24, 2016) | ||
## [1.2.6](https://github.com/axios/axios/compare/v1.2.5...v1.2.6) (2023-01-28) | ||
- Improving handling of request timeout in node ([#124](https://github.com/axios/axios/issues/124)) | ||
- Fixing network errors not rejecting ([#205](https://github.com/axios/axios/pull/205)) | ||
- Fixing issue with IE rejecting on HTTP 204 ([#201](https://github.com/axios/axios/issues/201)) | ||
- Fixing host/port when following redirects ([#198](https://github.com/axios/axios/pull/198)) | ||
### 0.9.0 (Jan 18, 2016) | ||
### Bug Fixes | ||
- Adding support for custom adapters | ||
- Fixing Content-Type header being removed when data is false ([#195](https://github.com/axios/axios/pull/195)) | ||
- Improving XDomainRequest implementation ([#185](https://github.com/axios/axios/pull/185)) | ||
- Improving config merging and order of precedence ([#183](https://github.com/axios/axios/pull/183)) | ||
- Fixing XDomainRequest support for only <= IE9 ([#182](https://github.com/axios/axios/pull/182)) | ||
* **headers:** added missed Authorization accessor; ([#5502](https://github.com/axios/axios/issues/5502)) ([342c0ba](https://github.com/axios/axios/commit/342c0ba9a16ea50f5ed7d2366c5c1a2c877e3f26)) | ||
* **types:** fixed `CommonRequestHeadersList` & `CommonResponseHeadersList` types to be private in commonJS; ([#5503](https://github.com/axios/axios/issues/5503)) ([5a3d0a3](https://github.com/axios/axios/commit/5a3d0a3234d77361a1bc7cedee2da1e11df08e2c)) | ||
### 0.8.1 (Dec 14, 2015) | ||
### Contributors to this release | ||
- Adding support for passing XSRF token for cross domain requests when using `withCredentials` ([#168](https://github.com/axios/axios/pull/168)) | ||
- Fixing error with format of basic auth header ([#178](https://github.com/axios/axios/pull/173)) | ||
- Fixing error with JSON payloads throwing `InvalidStateError` in some cases ([#174](https://github.com/axios/axios/pull/174)) | ||
- ![avatar](https://avatars.githubusercontent.com/u/12586868?v=4&s=16) [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+24/-9 (#5503 #5502 )") | ||
### 0.8.0 (Dec 11, 2015) | ||
### PRs | ||
- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) ) | ||
``` | ||
- Adding support for creating instances of axios ([#123](https://github.com/axios/axios/pull/123)) | ||
- Fixing http adapter to use `Buffer` instead of `String` in case of `responseType === 'arraybuffer'` ([#128](https://github.com/axios/axios/pull/128)) | ||
- Adding support for using custom parameter serializer with `paramsSerializer` option ([#121](https://github.com/axios/axios/pull/121)) | ||
- Fixing issue in IE8 caused by `forEach` on `arguments` ([#127](https://github.com/axios/axios/pull/127)) | ||
- Adding support for following redirects in node ([#146](https://github.com/axios/axios/pull/146)) | ||
- Adding support for transparent decompression if `content-encoding` is set ([#149](https://github.com/axios/axios/pull/149)) | ||
- Adding support for transparent XDomainRequest to handle cross domain requests in IE9 ([#140](https://github.com/axios/axios/pull/140)) | ||
- Adding support for HTTP basic auth via Authorization header ([#167](https://github.com/axios/axios/pull/167)) | ||
- Adding support for baseURL option ([#160](https://github.com/axios/axios/pull/160)) | ||
⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459 | ||
``` | ||
### 0.7.0 (Sep 29, 2015) | ||
## [1.2.5](https://github.com/axios/axios/compare/v1.2.4...v1.2.5) (2023-01-26) | ||
- Fixing issue with minified bundle in IE8 ([#87](https://github.com/axios/axios/pull/87)) | ||
- Adding support for passing agent in node ([#102](https://github.com/axios/axios/pull/102)) | ||
- Adding support for returning result from `axios.spread` for chaining ([#106](https://github.com/axios/axios/pull/106)) | ||
- Fixing typescript definition ([#105](https://github.com/axios/axios/pull/105)) | ||
- Fixing default timeout config for node ([#112](https://github.com/axios/axios/pull/112)) | ||
- Adding support for use in web workers, and react-native ([#70](https://github.com/axios/axios/issue/70)), ([#98](https://github.com/axios/axios/pull/98)) | ||
- Adding support for fetch like API `axios(url[, config])` ([#116](https://github.com/axios/axios/issues/116)) | ||
### 0.6.0 (Sep 21, 2015) | ||
### Bug Fixes | ||
- Removing deprecated success/error aliases | ||
- Fixing issue with array params not being properly encoded ([#49](https://github.com/axios/axios/pull/49)) | ||
- Fixing issue with User-Agent getting overridden ([#69](https://github.com/axios/axios/issues/69)) | ||
- Adding support for timeout config ([#56](https://github.com/axios/axios/issues/56)) | ||
- Removing es6-promise dependency | ||
- Fixing issue preventing `length` to be used as a parameter ([#91](https://github.com/axios/axios/pull/91)) | ||
- Fixing issue with IE8 ([#85](https://github.com/axios/axios/pull/85)) | ||
- Converting build to UMD | ||
* **types:** fixed AxiosHeaders to handle spread syntax by making all methods non-enumerable; ([#5499](https://github.com/axios/axios/issues/5499)) ([580f1e8](https://github.com/axios/axios/commit/580f1e8033a61baa38149d59fd16019de3932c22)) | ||
### 0.5.4 (Apr 08, 2015) | ||
### Contributors to this release | ||
- Fixing issue with FormData not being sent ([#53](https://github.com/axios/axios/issues/53)) | ||
- ![avatar](https://avatars.githubusercontent.com/u/12586868?v=4&s=16) [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+82/-54 (#5499 )") | ||
- ![avatar](https://avatars.githubusercontent.com/u/20516159?v=4&s=16) [Elliot Ford](https://github.com/EFord36 "+1/-1 (#5462 )") | ||
### 0.5.3 (Apr 07, 2015) | ||
### PRs | ||
- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) ) | ||
``` | ||
- Using JSON.parse unconditionally when transforming response string ([#55](https://github.com/axios/axios/issues/55)) | ||
⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459 | ||
``` | ||
### 0.5.2 (Mar 13, 2015) | ||
## [1.2.4](https://github.com/axios/axios/compare/v1.2.3...v1.2.4) (2023-01-22) | ||
- Adding support for `statusText` in response ([#46](https://github.com/axios/axios/issues/46)) | ||
### 0.5.1 (Mar 10, 2015) | ||
### Bug Fixes | ||
- Fixing issue using strict mode ([#45](https://github.com/axios/axios/issues/45)) | ||
- Fixing issue with standalone build ([#47](https://github.com/axios/axios/issues/47)) | ||
* **types:** renamed `RawAxiosRequestConfig` back to `AxiosRequestConfig`; ([#5486](https://github.com/axios/axios/issues/5486)) ([2a71f49](https://github.com/axios/axios/commit/2a71f49bc6c68495fa419003a3107ed8bd703ad0)) | ||
* **types:** fix `AxiosRequestConfig` generic; ([#5478](https://github.com/axios/axios/issues/5478)) ([9bce81b](https://github.com/axios/axios/commit/186ea062da8b7d578ae78b1a5c220986b9bce81b)) | ||
### 0.5.0 (Jan 23, 2015) | ||
### Contributors to this release | ||
- Adding support for intercepetors ([#14](https://github.com/axios/axios/issues/14)) | ||
- Updating es6-promise dependency | ||
- ![avatar](https://avatars.githubusercontent.com/u/12586868?v=4&s=16) [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+242/-108 (#5486 #5482 )") | ||
- ![avatar](https://avatars.githubusercontent.com/u/9430821?v=4&s=16) [Daniel Hillmann](https://github.com/hilleer "+1/-1 (#5478 )") | ||
### 0.4.2 (Dec 10, 2014) | ||
### PRs | ||
- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) ) | ||
``` | ||
- Fixing issue with `Content-Type` when using `FormData` ([#22](https://github.com/axios/axios/issues/22)) | ||
- Adding support for TypeScript ([#25](https://github.com/axios/axios/issues/25)) | ||
- Fixing issue with standalone build ([#29](https://github.com/axios/axios/issues/29)) | ||
- Fixing issue with verbs needing to be capitalized in some browsers ([#30](https://github.com/axios/axios/issues/30)) | ||
⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459 | ||
``` | ||
### 0.4.1 (Oct 15, 2014) | ||
## [1.2.3](https://github.com/axios/axios/compare/1.2.2...1.2.3) (2023-01-10) | ||
- Adding error handling to request for node.js ([#18](https://github.com/axios/axios/issues/18)) | ||
### 0.4.0 (Oct 03, 2014) | ||
### Bug Fixes | ||
- Adding support for `ArrayBuffer` and `ArrayBufferView` ([#10](https://github.com/axios/axios/issues/10)) | ||
- Adding support for utf-8 for node.js ([#13](https://github.com/axios/axios/issues/13)) | ||
- Adding support for SSL for node.js ([#12](https://github.com/axios/axios/issues/12)) | ||
- Fixing incorrect `Content-Type` header ([#9](https://github.com/axios/axios/issues/9)) | ||
- Adding standalone build without bundled es6-promise ([#11](https://github.com/axios/axios/issues/11)) | ||
- Deprecating `success`/`error` in favor of `then`/`catch` | ||
* **types:** fixed AxiosRequestConfig header interface by refactoring it to RawAxiosRequestConfig; ([#5420](https://github.com/axios/axios/issues/5420)) ([0811963](https://github.com/axios/axios/commit/08119634a22f1d5b19f5c9ea0adccb6d3eebc3bc)) | ||
### 0.3.1 (Sep 16, 2014) | ||
### Contributors to this release | ||
- Fixing missing post body when using node.js ([#3](https://github.com/axios/axios/issues/3)) | ||
- ![avatar](https://avatars.githubusercontent.com/u/12586868?v=4&s=16) [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+938/-442 (#5456 #5455 #5453 #5451 #5449 #5447 #5446 #5443 #5442 #5439 #5420 )") | ||
### 0.3.0 (Sep 16, 2014) | ||
### PRs | ||
- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) ) | ||
``` | ||
- Fixing `success` and `error` to properly receive response data as individual arguments ([#8](https://github.com/axios/axios/issues/8)) | ||
- Updating `then` and `catch` to receive response data as a single object ([#6](https://github.com/axios/axios/issues/6)) | ||
- Fixing issue with `all` not working ([#7](https://github.com/axios/axios/issues/7)) | ||
⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459 | ||
``` | ||
### 0.2.2 (Sep 14, 2014) | ||
## [1.2.2] - 2022-12-29 | ||
- Fixing bundling with browserify ([#4](https://github.com/axios/axios/issues/4)) | ||
### Fixed | ||
- fix(ci): fix release script inputs [#5392](https://github.com/axios/axios/pull/5392) | ||
- fix(ci): prerelease scipts [#5377](https://github.com/axios/axios/pull/5377) | ||
- fix(ci): release scripts [#5376](https://github.com/axios/axios/pull/5376) | ||
- fix(ci): typescript tests [#5375](https://github.com/axios/axios/pull/5375) | ||
- fix: Brotli decompression [#5353](https://github.com/axios/axios/pull/5353) | ||
- fix: add missing HttpStatusCode [#5345](https://github.com/axios/axios/pull/5345) | ||
### 0.2.1 (Sep 12, 2014) | ||
### Chores | ||
- chore(ci): set conventional-changelog header config [#5406](https://github.com/axios/axios/pull/5406) | ||
- chore(ci): fix automatic contributors resolving [#5403](https://github.com/axios/axios/pull/5403) | ||
- chore(ci): improved logging for the contributors list generator [#5398](https://github.com/axios/axios/pull/5398) | ||
- chore(ci): fix release action [#5397](https://github.com/axios/axios/pull/5397) | ||
- chore(ci): fix version bump script by adding bump argument for target version [#5393](https://github.com/axios/axios/pull/5393) | ||
- chore(deps): bump decode-uri-component from 0.2.0 to 0.2.2 [#5342](https://github.com/axios/axios/pull/5342) | ||
- chore(ci): GitHub Actions Release script [#5384](https://github.com/axios/axios/pull/5384) | ||
- chore(ci): release scripts [#5364](https://github.com/axios/axios/pull/5364) | ||
- Fixing build problem causing ridiculous file sizes | ||
### Contributors to this release | ||
- ![avatar](https://avatars.githubusercontent.com/u/12586868?v=4&s=16) [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS) | ||
- ![avatar](https://avatars.githubusercontent.com/u/1652293?v=4&s=16) [Winnie](https://github.com/winniehell) | ||
### 0.2.0 (Sep 12, 2014) | ||
## [1.2.1] - 2022-12-05 | ||
- Adding support for `all` and `spread` | ||
- Adding support for node.js ([#1](https://github.com/axios/axios/issues/1)) | ||
### Changed | ||
- feat(exports): export mergeConfig [#5151](https://github.com/axios/axios/pull/5151) | ||
### 0.1.0 (Aug 29, 2014) | ||
### Fixed | ||
- fix(CancelledError): include config [#4922](https://github.com/axios/axios/pull/4922) | ||
- fix(general): removing multiple/trailing/leading whitespace [#5022](https://github.com/axios/axios/pull/5022) | ||
- fix(headers): decompression for responses without Content-Length header [#5306](https://github.com/axios/axios/pull/5306) | ||
- fix(webWorker): exception to sending form data in web worker [#5139](https://github.com/axios/axios/pull/5139) | ||
- Initial release | ||
### Refactors | ||
- refactor(types): AxiosProgressEvent.event type to any [#5308](https://github.com/axios/axios/pull/5308) | ||
- refactor(types): add missing types for static AxiosError.from method [#4956](https://github.com/axios/axios/pull/4956) | ||
### Chores | ||
- chore(docs): remove README link to non-existent upgrade guide [#5307](https://github.com/axios/axios/pull/5307) | ||
- chore(docs): typo in issue template name [#5159](https://github.com/axios/axios/pull/5159) | ||
### Contributors to this release | ||
- [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS) | ||
- [Zachary Lysobey](https://github.com/zachlysobey) | ||
- [Kevin Ennis](https://github.com/kevincennis) | ||
- [Philipp Loose](https://github.com/phloose) | ||
- [secondl1ght](https://github.com/secondl1ght) | ||
- [wenzheng](https://github.com/0x30) | ||
- [Ivan Barsukov](https://github.com/ovarn) | ||
- [Arthur Fiorette](https://github.com/arthurfiorette) | ||
### PRs | ||
- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) ) | ||
``` | ||
⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459 | ||
``` | ||
## [1.2.0] - 2022-11-10 | ||
### Changed | ||
- changed: refactored module exports [#5162](https://github.com/axios/axios/pull/5162) | ||
- change: re-added support for loading Axios with require('axios').default [#5225](https://github.com/axios/axios/pull/5225) | ||
### Fixed | ||
- fix: improve AxiosHeaders class [#5224](https://github.com/axios/axios/pull/5224) | ||
- fix: TypeScript type definitions for commonjs [#5196](https://github.com/axios/axios/pull/5196) | ||
- fix: type definition of use method on AxiosInterceptorManager to match the the README [#5071](https://github.com/axios/axios/pull/5071) | ||
- fix: __dirname is not defined in the sandbox [#5269](https://github.com/axios/axios/pull/5269) | ||
- fix: AxiosError.toJSON method to avoid circular references [#5247](https://github.com/axios/axios/pull/5247) | ||
- fix: Z_BUF_ERROR when content-encoding is set but the response body is empty [#5250](https://github.com/axios/axios/pull/5250) | ||
### Refactors | ||
- refactor: allowing adapters to be loaded by name [#5277](https://github.com/axios/axios/pull/5277) | ||
### Chores | ||
- chore: force CI restart [#5243](https://github.com/axios/axios/pull/5243) | ||
- chore: update ECOSYSTEM.md [#5077](https://github.com/axios/axios/pull/5077) | ||
- chore: update get/index.html [#5116](https://github.com/axios/axios/pull/5116) | ||
- chore: update Sandbox UI/UX [#5205](https://github.com/axios/axios/pull/5205) | ||
- chore:(actions): remove git credentials after checkout [#5235](https://github.com/axios/axios/pull/5235) | ||
- chore(actions): bump actions/dependency-review-action from 2 to 3 [#5266](https://github.com/axios/axios/pull/5266) | ||
- chore(packages): bump loader-utils from 1.4.1 to 1.4.2 [#5295](https://github.com/axios/axios/pull/5295) | ||
- chore(packages): bump engine.io from 6.2.0 to 6.2.1 [#5294](https://github.com/axios/axios/pull/5294) | ||
- chore(packages): bump socket.io-parser from 4.0.4 to 4.0.5 [#5241](https://github.com/axios/axios/pull/5241) | ||
- chore(packages): bump loader-utils from 1.4.0 to 1.4.1 [#5245](https://github.com/axios/axios/pull/5245) | ||
- chore(docs): update Resources links in README [#5119](https://github.com/axios/axios/pull/5119) | ||
- chore(docs): update the link for JSON url [#5265](https://github.com/axios/axios/pull/5265) | ||
- chore(docs): fix broken links [#5218](https://github.com/axios/axios/pull/5218) | ||
- chore(docs): update and rename UPGRADE_GUIDE.md to MIGRATION_GUIDE.md [#5170](https://github.com/axios/axios/pull/5170) | ||
- chore(docs): typo fix line #856 and #920 [#5194](https://github.com/axios/axios/pull/5194) | ||
- chore(docs): typo fix #800 [#5193](https://github.com/axios/axios/pull/5193) | ||
- chore(docs): fix typos [#5184](https://github.com/axios/axios/pull/5184) | ||
- chore(docs): fix punctuation in README.md [#5197](https://github.com/axios/axios/pull/5197) | ||
- chore(docs): update readme in the Handling Errors section - issue reference #5260 [#5261](https://github.com/axios/axios/pull/5261) | ||
- chore: remove \b from filename [#5207](https://github.com/axios/axios/pull/5207) | ||
- chore(docs): update CHANGELOG.md [#5137](https://github.com/axios/axios/pull/5137) | ||
- chore: add sideEffects false to package.json [#5025](https://github.com/axios/axios/pull/5025) | ||
### Contributors to this release | ||
- [Maddy Miller](https://github.com/me4502) | ||
- [Amit Saini](https://github.com/amitsainii) | ||
- [ecyrbe](https://github.com/ecyrbe) | ||
- [Ikko Ashimine](https://github.com/eltociear) | ||
- [Geeth Gunnampalli](https://github.com/thetechie7) | ||
- [Shreem Asati](https://github.com/shreem-123) | ||
- [Frieder Bluemle](https://github.com/friederbluemle) | ||
- [윤세영](https://github.com/yunseyeong) | ||
- [Claudio Busatto](https://github.com/cjcbusatto) | ||
- [Remco Haszing](https://github.com/remcohaszing) | ||
- [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS) | ||
- [Csaba Maulis](https://github.com/om4csaba) | ||
- [MoPaMo](https://github.com/MoPaMo) | ||
- [Daniel Fjeldstad](https://github.com/w3bdesign) | ||
- [Adrien Brunet](https://github.com/adrien-may) | ||
- [Frazer Smith](https://github.com/Fdawgs) | ||
- [HaiTao](https://github.com/836334258) | ||
- [AZM](https://github.com/aziyatali) | ||
- [relbns](https://github.com/relbns) | ||
### PRs | ||
- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) ) | ||
``` | ||
⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459 | ||
``` | ||
## [1.1.3] - 2022-10-15 | ||
### Added | ||
- Added custom params serializer support [#5113](https://github.com/axios/axios/pull/5113) | ||
### Fixed | ||
- Fixed top-level export to keep them in-line with static properties [#5109](https://github.com/axios/axios/pull/5109) | ||
- Stopped including null values to query string. [#5108](https://github.com/axios/axios/pull/5108) | ||
- Restored proxy config backwards compatibility with 0.x [#5097](https://github.com/axios/axios/pull/5097) | ||
- Added back AxiosHeaders in AxiosHeaderValue [#5103](https://github.com/axios/axios/pull/5103) | ||
- Pin CDN install instructions to a specific version [#5060](https://github.com/axios/axios/pull/5060) | ||
- Handling of array values fixed for AxiosHeaders [#5085](https://github.com/axios/axios/pull/5085) | ||
### Chores | ||
- docs: match badge style, add link to them [#5046](https://github.com/axios/axios/pull/5046) | ||
- chore: fixing comments typo [#5054](https://github.com/axios/axios/pull/5054) | ||
- chore: update issue template [#5061](https://github.com/axios/axios/pull/5061) | ||
- chore: added progress capturing section to the docs; [#5084](https://github.com/axios/axios/pull/5084) | ||
### Contributors to this release | ||
- [Jason Saayman](https://github.com/jasonsaayman) | ||
- [scarf](https://github.com/scarf005) | ||
- [Lenz Weber-Tronic](https://github.com/phryneas) | ||
- [Arvindh](https://github.com/itsarvindh) | ||
- [Félix Legrelle](https://github.com/FelixLgr) | ||
- [Patrick Petrovic](https://github.com/ppati000) | ||
- [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS) | ||
- [littledian](https://github.com/littledian) | ||
- [ChronosMasterOfAllTime](https://github.com/ChronosMasterOfAllTime) | ||
### PRs | ||
- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) ) | ||
``` | ||
⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459 | ||
``` | ||
## [1.1.2] - 2022-10-07 | ||
### Fixed | ||
- Fixed broken exports for UMD builds. | ||
### Contributors to this release | ||
- [Jason Saayman](https://github.com/jasonsaayman) | ||
### PRs | ||
- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) ) | ||
``` | ||
⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459 | ||
``` | ||
## [1.1.1] - 2022-10-07 | ||
### Fixed | ||
- Fixed broken exports for common js. This fix breaks a prior fix, I will fix both issues ASAP but the commonJS use is more impactful. | ||
### Contributors to this release | ||
- [Jason Saayman](https://github.com/jasonsaayman) | ||
### PRs | ||
- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) ) | ||
``` | ||
⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459 | ||
``` | ||
## [1.1.0] - 2022-10-06 | ||
### Fixed | ||
- Fixed missing exports in type definition index.d.ts [#5003](https://github.com/axios/axios/pull/5003) | ||
- Fixed query params composing [#5018](https://github.com/axios/axios/pull/5018) | ||
- Fixed GenericAbortSignal interface by making it more generic [#5021](https://github.com/axios/axios/pull/5021) | ||
- Fixed adding "clear" to AxiosInterceptorManager [#5010](https://github.com/axios/axios/pull/5010) | ||
- Fixed commonjs & umd exports [#5030](https://github.com/axios/axios/pull/5030) | ||
- Fixed inability to access response headers when using axios 1.x with Jest [#5036](https://github.com/axios/axios/pull/5036) | ||
### Contributors to this release | ||
- [Trim21](https://github.com/trim21) | ||
- [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS) | ||
- [shingo.sasaki](https://github.com/s-sasaki-0529) | ||
- [Ivan Pepelko](https://github.com/ivanpepelko) | ||
- [Richard Kořínek](https://github.com/risa) | ||
### PRs | ||
- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) ) | ||
``` | ||
⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459 | ||
``` | ||
## [1.0.0] - 2022-10-04 | ||
### Added | ||
- Added stack trace to AxiosError [#4624](https://github.com/axios/axios/pull/4624) | ||
- Add AxiosError to AxiosStatic [#4654](https://github.com/axios/axios/pull/4654) | ||
- Replaced Rollup as our build runner [#4596](https://github.com/axios/axios/pull/4596) | ||
- Added generic TS types for the exposed toFormData helper [#4668](https://github.com/axios/axios/pull/4668) | ||
- Added listen callback function [#4096](https://github.com/axios/axios/pull/4096) | ||
- Added instructions for installing using PNPM [#4207](https://github.com/axios/axios/pull/4207) | ||
- Added generic AxiosAbortSignal TS interface to avoid importing AbortController polyfill [#4229](https://github.com/axios/axios/pull/4229) | ||
- Added axios-url-template in ECOSYSTEM.md [#4238](https://github.com/axios/axios/pull/4238) | ||
- Added a clear() function to the request and response interceptors object so a user can ensure that all interceptors have been removed from an axios instance [#4248](https://github.com/axios/axios/pull/4248) | ||
- Added react hook plugin [#4319](https://github.com/axios/axios/pull/4319) | ||
- Adding HTTP status code for transformResponse [#4580](https://github.com/axios/axios/pull/4580) | ||
- Added blob to the list of protocols supported by the browser [#4678](https://github.com/axios/axios/pull/4678) | ||
- Resolving proxy from env on redirect [#4436](https://github.com/axios/axios/pull/4436) | ||
- Added enhanced toFormData implementation with additional options [4704](https://github.com/axios/axios/pull/4704) | ||
- Adding Canceler parameters config and request [#4711](https://github.com/axios/axios/pull/4711) | ||
- Added automatic payload serialization to application/x-www-form-urlencoded [#4714](https://github.com/axios/axios/pull/4714) | ||
- Added the ability for webpack users to overwrite built-ins [#4715](https://github.com/axios/axios/pull/4715) | ||
- Added string[] to AxiosRequestHeaders type [#4322](https://github.com/axios/axios/pull/4322) | ||
- Added the ability for the url-encoded-form serializer to respect the formSerializer config [#4721](https://github.com/axios/axios/pull/4721) | ||
- Added isCancel type assert [#4293](https://github.com/axios/axios/pull/4293) | ||
- Added data URL support for node.js [#4725](https://github.com/axios/axios/pull/4725) | ||
- Adding types for progress event callbacks [#4675](https://github.com/axios/axios/pull/4675) | ||
- URL params serializer [#4734](https://github.com/axios/axios/pull/4734) | ||
- Added axios.formToJSON method [#4735](https://github.com/axios/axios/pull/4735) | ||
- Bower platform add data protocol [#4804](https://github.com/axios/axios/pull/4804) | ||
- Use WHATWG URL API instead of url.parse() [#4852](https://github.com/axios/axios/pull/4852) | ||
- Add ENUM containing Http Status Codes to typings [#4903](https://github.com/axios/axios/pull/4903) | ||
- Improve typing of timeout in index.d.ts [#4934](https://github.com/axios/axios/pull/4934) | ||
### Changed | ||
- Updated AxiosError.config to be optional in the type definition [#4665](https://github.com/axios/axios/pull/4665) | ||
- Updated README emphasizing the URLSearchParam built-in interface over other solutions [#4590](https://github.com/axios/axios/pull/4590) | ||
- Include request and config when creating a CanceledError instance [#4659](https://github.com/axios/axios/pull/4659) | ||
- Changed func-names eslint rule to as-needed [#4492](https://github.com/axios/axios/pull/4492) | ||
- Replacing deprecated substr() with slice() as substr() is deprecated [#4468](https://github.com/axios/axios/pull/4468) | ||
- Updating HTTP links in README.md to use HTTPS [#4387](https://github.com/axios/axios/pull/4387) | ||
- Updated to a better trim() polyfill [#4072](https://github.com/axios/axios/pull/4072) | ||
- Updated types to allow specifying partial default headers on instance create [#4185](https://github.com/axios/axios/pull/4185) | ||
- Expanded isAxiosError types [#4344](https://github.com/axios/axios/pull/4344) | ||
- Updated type definition for axios instance methods [#4224](https://github.com/axios/axios/pull/4224) | ||
- Updated eslint config [#4722](https://github.com/axios/axios/pull/4722) | ||
- Updated Docs [#4742](https://github.com/axios/axios/pull/4742) | ||
- Refactored Axios to use ES2017 [#4787](https://github.com/axios/axios/pull/4787) | ||
### Deprecated | ||
- There are multiple deprecations, refactors and fixes provided in this release. Please read through the full release notes to see how this may impact your project and use case. | ||
### Removed | ||
- Removed incorrect argument for NetworkError constructor [#4656](https://github.com/axios/axios/pull/4656) | ||
- Removed Webpack [#4596](https://github.com/axios/axios/pull/4596) | ||
- Removed function that transform arguments to array [#4544](https://github.com/axios/axios/pull/4544) | ||
### Fixed | ||
- Fixed grammar in README [#4649](https://github.com/axios/axios/pull/4649) | ||
- Fixed code error in README [#4599](https://github.com/axios/axios/pull/4599) | ||
- Optimized the code that checks cancellation [#4587](https://github.com/axios/axios/pull/4587) | ||
- Fix url pointing to defaults.js in README [#4532](https://github.com/axios/axios/pull/4532) | ||
- Use type alias instead of interface for AxiosPromise [#4505](https://github.com/axios/axios/pull/4505) | ||
- Fix some word spelling and lint style in code comments [#4500](https://github.com/axios/axios/pull/4500) | ||
- Edited readme with 3 updated browser icons of Chrome, FireFox and Safari [#4414](https://github.com/axios/axios/pull/4414) | ||
- Bump follow-redirects from 1.14.9 to 1.15.0 [#4673](https://github.com/axios/axios/pull/4673) | ||
- Fixing http tests to avoid hanging when assertions fail [#4435](https://github.com/axios/axios/pull/4435) | ||
- Fix TS definition for AxiosRequestTransformer [#4201](https://github.com/axios/axios/pull/4201) | ||
- Fix grammatical issues in README [#4232](https://github.com/axios/axios/pull/4232) | ||
- Fixing instance.defaults.headers type [#4557](https://github.com/axios/axios/pull/4557) | ||
- Fixed race condition on immediate requests cancellation [#4261](https://github.com/axios/axios/pull/4261) | ||
- Fixing Z_BUF_ERROR when no content [#4701](https://github.com/axios/axios/pull/4701) | ||
- Fixing proxy beforeRedirect regression [#4708](https://github.com/axios/axios/pull/4708) | ||
- Fixed AxiosError status code type [#4717](https://github.com/axios/axios/pull/4717) | ||
- Fixed AxiosError stack capturing [#4718](https://github.com/axios/axios/pull/4718) | ||
- Fixing AxiosRequestHeaders typings [#4334](https://github.com/axios/axios/pull/4334) | ||
- Fixed max body length defaults [#4731](https://github.com/axios/axios/pull/4731) | ||
- Fixed toFormData Blob issue on node>v17 [#4728](https://github.com/axios/axios/pull/4728) | ||
- Bump grunt from 1.5.2 to 1.5.3 [#4743](https://github.com/axios/axios/pull/4743) | ||
- Fixing content-type header repeated [#4745](https://github.com/axios/axios/pull/4745) | ||
- Fixed timeout error message for http [4738](https://github.com/axios/axios/pull/4738) | ||
- Request ignores false, 0 and empty string as body values [#4785](https://github.com/axios/axios/pull/4785) | ||
- Added back missing minified builds [#4805](https://github.com/axios/axios/pull/4805) | ||
- Fixed a type error [#4815](https://github.com/axios/axios/pull/4815) | ||
- Fixed a regression bug with unsubscribing from cancel token; [#4819](https://github.com/axios/axios/pull/4819) | ||
- Remove repeated compression algorithm [#4820](https://github.com/axios/axios/pull/4820) | ||
- The error of calling extend to pass parameters [#4857](https://github.com/axios/axios/pull/4857) | ||
- SerializerOptions.indexes allows boolean | null | undefined [#4862](https://github.com/axios/axios/pull/4862) | ||
- Require interceptors to return values [#4874](https://github.com/axios/axios/pull/4874) | ||
- Removed unused imports [#4949](https://github.com/axios/axios/pull/4949) | ||
- Allow null indexes on formSerializer and paramsSerializer [#4960](https://github.com/axios/axios/pull/4960) | ||
### Chores | ||
- Set permissions for GitHub actions [#4765](https://github.com/axios/axios/pull/4765) | ||
- Included githubactions in the dependabot config [#4770](https://github.com/axios/axios/pull/4770) | ||
- Included dependency review [#4771](https://github.com/axios/axios/pull/4771) | ||
- Update security.md [#4784](https://github.com/axios/axios/pull/4784) | ||
- Remove unnecessary spaces [#4854](https://github.com/axios/axios/pull/4854) | ||
- Simplify the import path of AxiosError [#4875](https://github.com/axios/axios/pull/4875) | ||
- Fix Gitpod dead link [#4941](https://github.com/axios/axios/pull/4941) | ||
- Enable syntax highlighting for a code block [#4970](https://github.com/axios/axios/pull/4970) | ||
- Using Logo Axios in Readme.md [#4993](https://github.com/axios/axios/pull/4993) | ||
- Fix markup for note in README [#4825](https://github.com/axios/axios/pull/4825) | ||
- Fix typo and formatting, add colons [#4853](https://github.com/axios/axios/pull/4853) | ||
- Fix typo in readme [#4942](https://github.com/axios/axios/pull/4942) | ||
### Security | ||
- Update SECURITY.md [#4687](https://github.com/axios/axios/pull/4687) | ||
### Contributors to this release | ||
- [Bertrand Marron](https://github.com/tusbar) | ||
- [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS) | ||
- [Dan Mooney](https://github.com/danmooney) | ||
- [Michael Li](https://github.com/xiaoyu-tamu) | ||
- [aong](https://github.com/yxwzaxns) | ||
- [Des Preston](https://github.com/despreston) | ||
- [Ted Robertson](https://github.com/tredondo) | ||
- [zhoulixiang](https://github.com/zh-lx) | ||
- [Arthur Fiorette](https://github.com/arthurfiorette) | ||
- [Kumar Shanu](https://github.com/Kr-Shanu) | ||
- [JALAL](https://github.com/JLL32) | ||
- [Jingyi Lin](https://github.com/MageeLin) | ||
- [Philipp Loose](https://github.com/phloose) | ||
- [Alexander Shchukin](https://github.com/sashsvamir) | ||
- [Dave Cardwell](https://github.com/davecardwell) | ||
- [Cat Scarlet](https://github.com/catscarlet) | ||
- [Luca Pizzini](https://github.com/lpizzinidev) | ||
- [Kai](https://github.com/Schweinepriester) | ||
- [Maxime Bargiel](https://github.com/mbargiel) | ||
- [Brian Helba](https://github.com/brianhelba) | ||
- [reslear](https://github.com/reslear) | ||
- [Jamie Slome](https://github.com/JamieSlome) | ||
- [Landro3](https://github.com/Landro3) | ||
- [rafw87](https://github.com/rafw87) | ||
- [Afzal Sayed](https://github.com/afzalsayed96) | ||
- [Koki Oyatsu](https://github.com/kaishuu0123) | ||
- [Dave](https://github.com/wangcch) | ||
- [暴走老七](https://github.com/baozouai) | ||
- [Spencer](https://github.com/spalger) | ||
- [Adrian Wieprzkowicz](https://github.com/Argeento) | ||
- [Jamie Telin](https://github.com/lejahmie) | ||
- [毛呆](https://github.com/aweikalee) | ||
- [Kirill Shakirov](https://github.com/turisap) | ||
- [Rraji Abdelbari](https://github.com/estarossa0) | ||
- [Jelle Schutter](https://github.com/jelleschutter) | ||
- [Tom Ceuppens](https://github.com/KyorCode) | ||
- [Johann Cooper](https://github.com/JohannCooper) | ||
- [Dimitris Halatsis](https://github.com/mitsos1os) | ||
- [chenjigeng](https://github.com/chenjigeng) | ||
- [João Gabriel Quaresma](https://github.com/joaoGabriel55) | ||
- [Victor Augusto](https://github.com/VictorAugDB) | ||
- [neilnaveen](https://github.com/neilnaveen) | ||
- [Pavlos](https://github.com/psmoros) | ||
- [Kiryl Valkovich](https://github.com/visortelle) | ||
- [Naveen](https://github.com/naveensrinivasan) | ||
- [wenzheng](https://github.com/0x30) | ||
- [hcwhan](https://github.com/hcwhan) | ||
- [Bassel Rachid](https://github.com/basselworkforce) | ||
- [Grégoire Pineau](https://github.com/lyrixx) | ||
- [felipedamin](https://github.com/felipedamin) | ||
- [Karl Horky](https://github.com/karlhorky) | ||
- [Yue JIN](https://github.com/kingyue737) | ||
- [Usman Ali Siddiqui](https://github.com/usman250994) | ||
- [WD](https://github.com/techbirds) | ||
- [Günther Foidl](https://github.com/gfoidl) | ||
- [Stephen Jennings](https://github.com/jennings) | ||
- [C.T.Lin](https://github.com/chentsulin) | ||
- [mia-z](https://github.com/mia-z) | ||
- [Parth Banathia](https://github.com/Parth0105) | ||
- [parth0105pluang](https://github.com/parth0105pluang) | ||
- [Marco Weber](https://github.com/mrcwbr) | ||
- [Luca Pizzini](https://github.com/lpizzinidev) | ||
- [Willian Agostini](https://github.com/WillianAgostini) | ||
- [Huyen Nguyen](https://github.com/huyenltnguyen) |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.axios=t():e.axios=t()}(window,(function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=11)}([function(e,t,n){"use strict";var r=n(3),o=Object.prototype.toString;function i(e){return"[object Array]"===o.call(e)}function s(e){return void 0===e}function a(e){return null!==e&&"object"==typeof e}function u(e){if("[object Object]"!==o.call(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function c(e){return"[object Function]"===o.call(e)}function f(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),i(e))for(var n=0,r=e.length;n<r;n++)t.call(null,e[n],n,e);else for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.call(null,e[o],o,e)}e.exports={isArray:i,isArrayBuffer:function(e){return"[object ArrayBuffer]"===o.call(e)},isBuffer:function(e){return null!==e&&!s(e)&&null!==e.constructor&&!s(e.constructor)&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)},isFormData:function(e){return"undefined"!=typeof FormData&&e instanceof FormData},isArrayBufferView:function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&e.buffer instanceof ArrayBuffer},isString:function(e){return"string"==typeof e},isNumber:function(e){return"number"==typeof e},isObject:a,isPlainObject:u,isUndefined:s,isDate:function(e){return"[object Date]"===o.call(e)},isFile:function(e){return"[object File]"===o.call(e)},isBlob:function(e){return"[object Blob]"===o.call(e)},isFunction:c,isStream:function(e){return a(e)&&c(e.pipe)},isURLSearchParams:function(e){return"undefined"!=typeof URLSearchParams&&e instanceof URLSearchParams},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)},forEach:f,merge:function e(){var t={};function n(n,r){u(t[r])&&u(n)?t[r]=e(t[r],n):u(n)?t[r]=e({},n):i(n)?t[r]=n.slice():t[r]=n}for(var r=0,o=arguments.length;r<o;r++)f(arguments[r],n);return t},extend:function(e,t,n){return f(t,(function(t,o){e[o]=n&&"function"==typeof t?r(t,n):t})),e},trim:function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")},stripBOM:function(e){return 65279===e.charCodeAt(0)&&(e=e.slice(1)),e}}},function(e,t,n){"use strict";var r=n(0),o=n(17),i=n(5),s={"Content-Type":"application/x-www-form-urlencoded"};function a(e,t){!r.isUndefined(e)&&r.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var u,c={transitional:{silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},adapter:(("undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process))&&(u=n(6)),u),transformRequest:[function(e,t){return o(t,"Accept"),o(t,"Content-Type"),r.isFormData(e)||r.isArrayBuffer(e)||r.isBuffer(e)||r.isStream(e)||r.isFile(e)||r.isBlob(e)?e:r.isArrayBufferView(e)?e.buffer:r.isURLSearchParams(e)?(a(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):r.isObject(e)||t&&"application/json"===t["Content-Type"]?(a(t,"application/json"),function(e,t,n){if(r.isString(e))try{return(t||JSON.parse)(e),r.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(n||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){var t=this.transitional||c.transitional,n=t&&t.silentJSONParsing,o=t&&t.forcedJSONParsing,s=!n&&"json"===this.responseType;if(s||o&&r.isString(e)&&e.length)try{return JSON.parse(e)}catch(e){if(s){if("SyntaxError"===e.name)throw i(e,this,"E_JSON_PARSE");throw e}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};r.forEach(["delete","get","head"],(function(e){c.headers[e]={}})),r.forEach(["post","put","patch"],(function(e){c.headers[e]=r.merge(s)})),e.exports=c},function(e,t,n){"use strict";function r(e){this.message=e}r.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},r.prototype.__CANCEL__=!0,e.exports=r},function(e,t,n){"use strict";e.exports=function(e,t){return function(){for(var n=new Array(arguments.length),r=0;r<n.length;r++)n[r]=arguments[r];return e.apply(t,n)}}},function(e,t,n){"use strict";var r=n(0);function o(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}e.exports=function(e,t,n){if(!t)return e;var i;if(n)i=n(t);else if(r.isURLSearchParams(t))i=t.toString();else{var s=[];r.forEach(t,(function(e,t){null!=e&&(r.isArray(e)?t+="[]":e=[e],r.forEach(e,(function(e){r.isDate(e)?e=e.toISOString():r.isObject(e)&&(e=JSON.stringify(e)),s.push(o(t)+"="+o(e))})))})),i=s.join("&")}if(i){var a=e.indexOf("#");-1!==a&&(e=e.slice(0,a)),e+=(-1===e.indexOf("?")?"?":"&")+i}return e}},function(e,t,n){"use strict";e.exports=function(e,t,n,r,o){return e.config=t,n&&(e.code=n),e.request=r,e.response=o,e.isAxiosError=!0,e.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code,status:this.response&&this.response.status?this.response.status:null}},e}},function(e,t,n){"use strict";var r=n(0),o=n(18),i=n(19),s=n(4),a=n(20),u=n(23),c=n(24),f=n(7),l=n(1),p=n(2);e.exports=function(e){return new Promise((function(t,n){var d,h=e.data,m=e.headers,v=e.responseType;function y(){e.cancelToken&&e.cancelToken.unsubscribe(d),e.signal&&e.signal.removeEventListener("abort",d)}r.isFormData(h)&&delete m["Content-Type"];var g=new XMLHttpRequest;if(e.auth){var b=e.auth.username||"",x=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";m.Authorization="Basic "+btoa(b+":"+x)}var w=a(e.baseURL,e.url);function E(){if(g){var r="getAllResponseHeaders"in g?u(g.getAllResponseHeaders()):null,i={data:v&&"text"!==v&&"json"!==v?g.response:g.responseText,status:g.status,statusText:g.statusText,headers:r,config:e,request:g};o((function(e){t(e),y()}),(function(e){n(e),y()}),i),g=null}}if(g.open(e.method.toUpperCase(),s(w,e.params,e.paramsSerializer),!0),g.timeout=e.timeout,"onloadend"in g?g.onloadend=E:g.onreadystatechange=function(){g&&4===g.readyState&&(0!==g.status||g.responseURL&&0===g.responseURL.indexOf("file:"))&&setTimeout(E)},g.onabort=function(){g&&(n(f("Request aborted",e,"ECONNABORTED",g)),g=null)},g.onerror=function(){n(f("Network Error",e,null,g)),g=null},g.ontimeout=function(){var t="timeout of "+e.timeout+"ms exceeded",r=e.transitional||l.transitional;e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),n(f(t,e,r.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",g)),g=null},r.isStandardBrowserEnv()){var S=(e.withCredentials||c(w))&&e.xsrfCookieName?i.read(e.xsrfCookieName):void 0;S&&(m[e.xsrfHeaderName]=S)}"setRequestHeader"in g&&r.forEach(m,(function(e,t){void 0===h&&"content-type"===t.toLowerCase()?delete m[t]:g.setRequestHeader(t,e)})),r.isUndefined(e.withCredentials)||(g.withCredentials=!!e.withCredentials),v&&"json"!==v&&(g.responseType=e.responseType),"function"==typeof e.onDownloadProgress&&g.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&g.upload&&g.upload.addEventListener("progress",e.onUploadProgress),(e.cancelToken||e.signal)&&(d=function(e){g&&(n(!e||e&&e.type?new p("canceled"):e),g.abort(),g=null)},e.cancelToken&&e.cancelToken.subscribe(d),e.signal&&(e.signal.aborted?d():e.signal.addEventListener("abort",d))),h||(h=null),g.send(h)}))}},function(e,t,n){"use strict";var r=n(5);e.exports=function(e,t,n,o,i){var s=new Error(e);return r(s,t,n,o,i)}},function(e,t,n){"use strict";e.exports=function(e){return!(!e||!e.__CANCEL__)}},function(e,t,n){"use strict";var r=n(0);e.exports=function(e,t){t=t||{};var n={};function o(e,t){return r.isPlainObject(e)&&r.isPlainObject(t)?r.merge(e,t):r.isPlainObject(t)?r.merge({},t):r.isArray(t)?t.slice():t}function i(n){return r.isUndefined(t[n])?r.isUndefined(e[n])?void 0:o(void 0,e[n]):o(e[n],t[n])}function s(e){if(!r.isUndefined(t[e]))return o(void 0,t[e])}function a(n){return r.isUndefined(t[n])?r.isUndefined(e[n])?void 0:o(void 0,e[n]):o(void 0,t[n])}function u(n){return n in t?o(e[n],t[n]):n in e?o(void 0,e[n]):void 0}var c={url:s,method:s,data:s,baseURL:a,transformRequest:a,transformResponse:a,paramsSerializer:a,timeout:a,timeoutMessage:a,withCredentials:a,adapter:a,responseType:a,xsrfCookieName:a,xsrfHeaderName:a,onUploadProgress:a,onDownloadProgress:a,decompress:a,maxContentLength:a,maxBodyLength:a,transport:a,httpAgent:a,httpsAgent:a,cancelToken:a,socketPath:a,responseEncoding:a,validateStatus:u};return r.forEach(Object.keys(e).concat(Object.keys(t)),(function(e){var t=c[e]||i,o=t(e);r.isUndefined(o)&&t!==u||(n[e]=o)})),n}},function(e,t){e.exports={version:"0.22.0"}},function(e,t,n){e.exports=n(12)},function(e,t,n){"use strict";var r=n(0),o=n(3),i=n(13),s=n(9);var a=function e(t){var n=new i(t),a=o(i.prototype.request,n);return r.extend(a,i.prototype,n),r.extend(a,n),a.create=function(n){return e(s(t,n))},a}(n(1));a.Axios=i,a.Cancel=n(2),a.CancelToken=n(26),a.isCancel=n(8),a.VERSION=n(10).version,a.all=function(e){return Promise.all(e)},a.spread=n(27),a.isAxiosError=n(28),e.exports=a,e.exports.default=a},function(e,t,n){"use strict";var r=n(0),o=n(4),i=n(14),s=n(15),a=n(9),u=n(25),c=u.validators;function f(e){this.defaults=e,this.interceptors={request:new i,response:new i}}f.prototype.request=function(e){"string"==typeof e?(e=arguments[1]||{}).url=arguments[0]:e=e||{},(e=a(this.defaults,e)).method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var t=e.transitional;void 0!==t&&u.assertOptions(t,{silentJSONParsing:c.transitional(c.boolean),forcedJSONParsing:c.transitional(c.boolean),clarifyTimeoutError:c.transitional(c.boolean)},!1);var n=[],r=!0;this.interceptors.request.forEach((function(t){"function"==typeof t.runWhen&&!1===t.runWhen(e)||(r=r&&t.synchronous,n.unshift(t.fulfilled,t.rejected))}));var o,i=[];if(this.interceptors.response.forEach((function(e){i.push(e.fulfilled,e.rejected)})),!r){var f=[s,void 0];for(Array.prototype.unshift.apply(f,n),f=f.concat(i),o=Promise.resolve(e);f.length;)o=o.then(f.shift(),f.shift());return o}for(var l=e;n.length;){var p=n.shift(),d=n.shift();try{l=p(l)}catch(e){d(e);break}}try{o=s(l)}catch(e){return Promise.reject(e)}for(;i.length;)o=o.then(i.shift(),i.shift());return o},f.prototype.getUri=function(e){return e=a(this.defaults,e),o(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")},r.forEach(["delete","get","head","options"],(function(e){f.prototype[e]=function(t,n){return this.request(a(n||{},{method:e,url:t,data:(n||{}).data}))}})),r.forEach(["post","put","patch"],(function(e){f.prototype[e]=function(t,n,r){return this.request(a(r||{},{method:e,url:t,data:n}))}})),e.exports=f},function(e,t,n){"use strict";var r=n(0);function o(){this.handlers=[]}o.prototype.use=function(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!n&&n.synchronous,runWhen:n?n.runWhen:null}),this.handlers.length-1},o.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},o.prototype.forEach=function(e){r.forEach(this.handlers,(function(t){null!==t&&e(t)}))},e.exports=o},function(e,t,n){"use strict";var r=n(0),o=n(16),i=n(8),s=n(1),a=n(2);function u(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new a("canceled")}e.exports=function(e){return u(e),e.headers=e.headers||{},e.data=o.call(e,e.data,e.headers,e.transformRequest),e.headers=r.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),r.forEach(["delete","get","head","post","put","patch","common"],(function(t){delete e.headers[t]})),(e.adapter||s.adapter)(e).then((function(t){return u(e),t.data=o.call(e,t.data,t.headers,e.transformResponse),t}),(function(t){return i(t)||(u(e),t&&t.response&&(t.response.data=o.call(e,t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)}))}},function(e,t,n){"use strict";var r=n(0),o=n(1);e.exports=function(e,t,n){var i=this||o;return r.forEach(n,(function(n){e=n.call(i,e,t)})),e}},function(e,t,n){"use strict";var r=n(0);e.exports=function(e,t){r.forEach(e,(function(n,r){r!==t&&r.toUpperCase()===t.toUpperCase()&&(e[t]=n,delete e[r])}))}},function(e,t,n){"use strict";var r=n(7);e.exports=function(e,t,n){var o=n.config.validateStatus;n.status&&o&&!o(n.status)?t(r("Request failed with status code "+n.status,n.config,null,n.request,n)):e(n)}},function(e,t,n){"use strict";var r=n(0);e.exports=r.isStandardBrowserEnv()?{write:function(e,t,n,o,i,s){var a=[];a.push(e+"="+encodeURIComponent(t)),r.isNumber(n)&&a.push("expires="+new Date(n).toGMTString()),r.isString(o)&&a.push("path="+o),r.isString(i)&&a.push("domain="+i),!0===s&&a.push("secure"),document.cookie=a.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}}},function(e,t,n){"use strict";var r=n(21),o=n(22);e.exports=function(e,t){return e&&!r(t)?o(e,t):t}},function(e,t,n){"use strict";e.exports=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)}},function(e,t,n){"use strict";e.exports=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}},function(e,t,n){"use strict";var r=n(0),o=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];e.exports=function(e){var t,n,i,s={};return e?(r.forEach(e.split("\n"),(function(e){if(i=e.indexOf(":"),t=r.trim(e.substr(0,i)).toLowerCase(),n=r.trim(e.substr(i+1)),t){if(s[t]&&o.indexOf(t)>=0)return;s[t]="set-cookie"===t?(s[t]?s[t]:[]).concat([n]):s[t]?s[t]+", "+n:n}})),s):s}},function(e,t,n){"use strict";var r=n(0);e.exports=r.isStandardBrowserEnv()?function(){var e,t=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");function o(e){var r=e;return t&&(n.setAttribute("href",r),r=n.href),n.setAttribute("href",r),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:"/"===n.pathname.charAt(0)?n.pathname:"/"+n.pathname}}return e=o(window.location.href),function(t){var n=r.isString(t)?o(t):t;return n.protocol===e.protocol&&n.host===e.host}}():function(){return!0}},function(e,t,n){"use strict";var r=n(10).version,o={};["object","boolean","number","function","string","symbol"].forEach((function(e,t){o[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}}));var i={};o.transitional=function(e,t,n){function o(e,t){return"[Axios v"+r+"] Transitional option '"+e+"'"+t+(n?". "+n:"")}return function(n,r,s){if(!1===e)throw new Error(o(r," has been removed"+(t?" in "+t:"")));return t&&!i[r]&&(i[r]=!0,console.warn(o(r," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(n,r,s)}},e.exports={assertOptions:function(e,t,n){if("object"!=typeof e)throw new TypeError("options must be an object");for(var r=Object.keys(e),o=r.length;o-- >0;){var i=r[o],s=t[i];if(s){var a=e[i],u=void 0===a||s(a,i,e);if(!0!==u)throw new TypeError("option "+i+" must be "+u)}else if(!0!==n)throw Error("Unknown option "+i)}},validators:o}},function(e,t,n){"use strict";var r=n(2);function o(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise((function(e){t=e}));var n=this;this.promise.then((function(e){if(n._listeners){var t,r=n._listeners.length;for(t=0;t<r;t++)n._listeners[t](e);n._listeners=null}})),this.promise.then=function(e){var t,r=new Promise((function(e){n.subscribe(e),t=e})).then(e);return r.cancel=function(){n.unsubscribe(t)},r},e((function(e){n.reason||(n.reason=new r(e),t(n.reason))}))}o.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},o.prototype.subscribe=function(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]},o.prototype.unsubscribe=function(e){if(this._listeners){var t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}},o.source=function(){var e;return{token:new o((function(t){e=t})),cancel:e}},e.exports=o},function(e,t,n){"use strict";e.exports=function(e){return function(t){return e.apply(null,t)}}},function(e,t,n){"use strict";e.exports=function(e){return"object"==typeof e&&!0===e.isAxiosError}}])})); | ||
//# sourceMappingURL=axios.min.map | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).axios=t()}(this,(function(){"use strict";function e(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function t(t){for(var n=1;n<arguments.length;n++){var r=null!=arguments[n]?arguments[n]:{};n%2?e(Object(r),!0).forEach((function(e){a(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):e(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function i(e,t,n){return t&&o(e.prototype,t),n&&o(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function a(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function s(e,t){return c(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==n)return;var r,o,i=[],a=!0,s=!1;try{for(n=n.call(e);!(a=(r=n.next()).done)&&(i.push(r.value),!t||i.length!==t);a=!0);}catch(e){s=!0,o=e}finally{try{a||null==n.return||n.return()}finally{if(s)throw o}}return i}(e,t)||l(e,t)||p()}function u(e){return function(e){if(Array.isArray(e))return d(e)}(e)||f(e)||l(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function c(e){if(Array.isArray(e))return e}function f(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function l(e,t){if(e){if("string"==typeof e)return d(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?d(e,t):void 0}}function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function p(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function h(e,t){return function(){return e.apply(t,arguments)}}var m,y=Object.prototype.toString,v=Object.getPrototypeOf,b=(m=Object.create(null),function(e){var t=y.call(e);return m[t]||(m[t]=t.slice(8,-1).toLowerCase())}),g=function(e){return e=e.toLowerCase(),function(t){return b(t)===e}},w=function(e){return function(t){return n(t)===e}},O=Array.isArray,E=w("undefined");var S=g("ArrayBuffer");var R=w("string"),A=w("function"),j=w("number"),T=function(e){return null!==e&&"object"===n(e)},P=function(e){if("object"!==b(e))return!1;var t=v(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||Symbol.toStringTag in e||Symbol.iterator in e)},N=g("Date"),C=g("File"),x=g("Blob"),k=g("FileList"),_=g("URLSearchParams");function U(e,t){var r,o,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=i.allOwnKeys,s=void 0!==a&&a;if(null!=e)if("object"!==n(e)&&(e=[e]),O(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{var u,c=s?Object.getOwnPropertyNames(e):Object.keys(e),f=c.length;for(r=0;r<f;r++)u=c[r],t.call(null,e[u],u,e)}}function D(e,t){t=t.toLowerCase();for(var n,r=Object.keys(e),o=r.length;o-- >0;)if(t===(n=r[o]).toLowerCase())return n;return null}var F="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,B=function(e){return!E(e)&&e!==F};var L,I=(L="undefined"!=typeof Uint8Array&&v(Uint8Array),function(e){return L&&e instanceof L}),q=g("HTMLFormElement"),z=function(e){var t=Object.prototype.hasOwnProperty;return function(e,n){return t.call(e,n)}}(),M=g("RegExp"),H=function(e,t){var n=Object.getOwnPropertyDescriptors(e),r={};U(n,(function(n,o){var i;!1!==(i=t(n,o,e))&&(r[o]=i||n)})),Object.defineProperties(e,r)},J="abcdefghijklmnopqrstuvwxyz",W="0123456789",K={DIGIT:W,ALPHA:J,ALPHA_DIGIT:J+J.toUpperCase()+W};var V=g("AsyncFunction"),G={isArray:O,isArrayBuffer:S,isBuffer:function(e){return null!==e&&!E(e)&&null!==e.constructor&&!E(e.constructor)&&A(e.constructor.isBuffer)&&e.constructor.isBuffer(e)},isFormData:function(e){var t;return e&&("function"==typeof FormData&&e instanceof FormData||A(e.append)&&("formdata"===(t=b(e))||"object"===t&&A(e.toString)&&"[object FormData]"===e.toString()))},isArrayBufferView:function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&S(e.buffer)},isString:R,isNumber:j,isBoolean:function(e){return!0===e||!1===e},isObject:T,isPlainObject:P,isUndefined:E,isDate:N,isFile:C,isBlob:x,isRegExp:M,isFunction:A,isStream:function(e){return T(e)&&A(e.pipe)},isURLSearchParams:_,isTypedArray:I,isFileList:k,forEach:U,merge:function e(){for(var t=B(this)&&this||{},n=t.caseless,r={},o=function(t,o){var i=n&&D(r,o)||o;P(r[i])&&P(t)?r[i]=e(r[i],t):P(t)?r[i]=e({},t):O(t)?r[i]=t.slice():r[i]=t},i=0,a=arguments.length;i<a;i++)arguments[i]&&U(arguments[i],o);return r},extend:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o=r.allOwnKeys;return U(t,(function(t,r){n&&A(t)?e[r]=h(t,n):e[r]=t}),{allOwnKeys:o}),e},trim:function(e){return e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")},stripBOM:function(e){return 65279===e.charCodeAt(0)&&(e=e.slice(1)),e},inherits:function(e,t,n,r){e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},toFlatObject:function(e,t,n,r){var o,i,a,s={};if(t=t||{},null==e)return t;do{for(i=(o=Object.getOwnPropertyNames(e)).length;i-- >0;)a=o[i],r&&!r(a,e,t)||s[a]||(t[a]=e[a],s[a]=!0);e=!1!==n&&v(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},kindOf:b,kindOfTest:g,endsWith:function(e,t,n){e=String(e),(void 0===n||n>e.length)&&(n=e.length),n-=t.length;var r=e.indexOf(t,n);return-1!==r&&r===n},toArray:function(e){if(!e)return null;if(O(e))return e;var t=e.length;if(!j(t))return null;for(var n=new Array(t);t-- >0;)n[t]=e[t];return n},forEachEntry:function(e,t){for(var n,r=(e&&e[Symbol.iterator]).call(e);(n=r.next())&&!n.done;){var o=n.value;t.call(e,o[0],o[1])}},matchAll:function(e,t){for(var n,r=[];null!==(n=e.exec(t));)r.push(n);return r},isHTMLForm:q,hasOwnProperty:z,hasOwnProp:z,reduceDescriptors:H,freezeMethods:function(e){H(e,(function(t,n){if(A(e)&&-1!==["arguments","caller","callee"].indexOf(n))return!1;var r=e[n];A(r)&&(t.enumerable=!1,"writable"in t?t.writable=!1:t.set||(t.set=function(){throw Error("Can not rewrite read-only method '"+n+"'")}))}))},toObjectSet:function(e,t){var n={},r=function(e){e.forEach((function(e){n[e]=!0}))};return O(e)?r(e):r(String(e).split(t)),n},toCamelCase:function(e){return e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,(function(e,t,n){return t.toUpperCase()+n}))},noop:function(){},toFiniteNumber:function(e,t){return e=+e,Number.isFinite(e)?e:t},findKey:D,global:F,isContextDefined:B,ALPHABET:K,generateString:function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:16,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:K.ALPHA_DIGIT,n="",r=t.length;e--;)n+=t[Math.random()*r|0];return n},isSpecCompliantForm:function(e){return!!(e&&A(e.append)&&"FormData"===e[Symbol.toStringTag]&&e[Symbol.iterator])},toJSONObject:function(e){var t=new Array(10);return function e(n,r){if(T(n)){if(t.indexOf(n)>=0)return;if(!("toJSON"in n)){t[r]=n;var o=O(n)?[]:{};return U(n,(function(t,n){var i=e(t,r+1);!E(i)&&(o[n]=i)})),t[r]=void 0,o}}return n}(e,0)},isAsyncFn:V,isThenable:function(e){return e&&(T(e)||A(e))&&A(e.then)&&A(e.catch)}};function $(e,t,n,r,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),o&&(this.response=o)}G.inherits($,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:G.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});var X=$.prototype,Q={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach((function(e){Q[e]={value:e}})),Object.defineProperties($,Q),Object.defineProperty(X,"isAxiosError",{value:!0}),$.from=function(e,t,n,r,o,i){var a=Object.create(X);return G.toFlatObject(e,a,(function(e){return e!==Error.prototype}),(function(e){return"isAxiosError"!==e})),$.call(a,e.message,t,n,r,o),a.cause=e,a.name=e.name,i&&Object.assign(a,i),a};function Z(e){return G.isPlainObject(e)||G.isArray(e)}function Y(e){return G.endsWith(e,"[]")?e.slice(0,-2):e}function ee(e,t,n){return e?e.concat(t).map((function(e,t){return e=Y(e),!n&&t?"["+e+"]":e})).join(n?".":""):t}var te=G.toFlatObject(G,{},null,(function(e){return/^is[A-Z]/.test(e)}));function ne(e,t,r){if(!G.isObject(e))throw new TypeError("target must be an object");t=t||new FormData;var o=(r=G.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,(function(e,t){return!G.isUndefined(t[e])}))).metaTokens,i=r.visitor||f,a=r.dots,s=r.indexes,u=(r.Blob||"undefined"!=typeof Blob&&Blob)&&G.isSpecCompliantForm(t);if(!G.isFunction(i))throw new TypeError("visitor must be a function");function c(e){if(null===e)return"";if(G.isDate(e))return e.toISOString();if(!u&&G.isBlob(e))throw new $("Blob is not supported. Use a Buffer instead.");return G.isArrayBuffer(e)||G.isTypedArray(e)?u&&"function"==typeof Blob?new Blob([e]):Buffer.from(e):e}function f(e,r,i){var u=e;if(e&&!i&&"object"===n(e))if(G.endsWith(r,"{}"))r=o?r:r.slice(0,-2),e=JSON.stringify(e);else if(G.isArray(e)&&function(e){return G.isArray(e)&&!e.some(Z)}(e)||(G.isFileList(e)||G.endsWith(r,"[]"))&&(u=G.toArray(e)))return r=Y(r),u.forEach((function(e,n){!G.isUndefined(e)&&null!==e&&t.append(!0===s?ee([r],n,a):null===s?r:r+"[]",c(e))})),!1;return!!Z(e)||(t.append(ee(i,r,a),c(e)),!1)}var l=[],d=Object.assign(te,{defaultVisitor:f,convertValue:c,isVisitable:Z});if(!G.isObject(e))throw new TypeError("data must be an object");return function e(n,r){if(!G.isUndefined(n)){if(-1!==l.indexOf(n))throw Error("Circular reference detected in "+r.join("."));l.push(n),G.forEach(n,(function(n,o){!0===(!(G.isUndefined(n)||null===n)&&i.call(t,n,G.isString(o)?o.trim():o,r,d))&&e(n,r?r.concat(o):[o])})),l.pop()}}(e),t}function re(e){var t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,(function(e){return t[e]}))}function oe(e,t){this._pairs=[],e&&ne(e,this,t)}var ie=oe.prototype;function ae(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function se(e,t,n){if(!t)return e;var r,o=n&&n.encode||ae,i=n&&n.serialize;if(r=i?i(t,n):G.isURLSearchParams(t)?t.toString():new oe(t,n).toString(o)){var a=e.indexOf("#");-1!==a&&(e=e.slice(0,a)),e+=(-1===e.indexOf("?")?"?":"&")+r}return e}ie.append=function(e,t){this._pairs.push([e,t])},ie.toString=function(e){var t=e?function(t){return e.call(this,t,re)}:re;return this._pairs.map((function(e){return t(e[0])+"="+t(e[1])}),"").join("&")};var ue,ce=function(){function e(){r(this,e),this.handlers=[]}return i(e,[{key:"use",value:function(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!n&&n.synchronous,runWhen:n?n.runWhen:null}),this.handlers.length-1}},{key:"eject",value:function(e){this.handlers[e]&&(this.handlers[e]=null)}},{key:"clear",value:function(){this.handlers&&(this.handlers=[])}},{key:"forEach",value:function(e){G.forEach(this.handlers,(function(t){null!==t&&e(t)}))}}]),e}(),fe={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},le={isBrowser:!0,classes:{URLSearchParams:"undefined"!=typeof URLSearchParams?URLSearchParams:oe,FormData:"undefined"!=typeof FormData?FormData:null,Blob:"undefined"!=typeof Blob?Blob:null},protocols:["http","https","file","blob","url","data"]},de="undefined"!=typeof window&&"undefined"!=typeof document,pe=(ue="undefined"!=typeof navigator&&navigator.product,de&&["ReactNative","NativeScript","NS"].indexOf(ue)<0),he="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,me=t(t({},Object.freeze({__proto__:null,hasBrowserEnv:de,hasStandardBrowserWebWorkerEnv:he,hasStandardBrowserEnv:pe})),le);function ye(e){function t(e,n,r,o){var i=e[o++],a=Number.isFinite(+i),s=o>=e.length;return i=!i&&G.isArray(r)?r.length:i,s?(G.hasOwnProp(r,i)?r[i]=[r[i],n]:r[i]=n,!a):(r[i]&&G.isObject(r[i])||(r[i]=[]),t(e,n,r[i],o)&&G.isArray(r[i])&&(r[i]=function(e){var t,n,r={},o=Object.keys(e),i=o.length;for(t=0;t<i;t++)r[n=o[t]]=e[n];return r}(r[i])),!a)}if(G.isFormData(e)&&G.isFunction(e.entries)){var n={};return G.forEachEntry(e,(function(e,r){t(function(e){return G.matchAll(/\w+|\[(\w*)]/g,e).map((function(e){return"[]"===e[0]?"":e[1]||e[0]}))}(e),r,n,0)})),n}return null}var ve={transitional:fe,adapter:["xhr","http"],transformRequest:[function(e,t){var n,r=t.getContentType()||"",o=r.indexOf("application/json")>-1,i=G.isObject(e);if(i&&G.isHTMLForm(e)&&(e=new FormData(e)),G.isFormData(e))return o&&o?JSON.stringify(ye(e)):e;if(G.isArrayBuffer(e)||G.isBuffer(e)||G.isStream(e)||G.isFile(e)||G.isBlob(e))return e;if(G.isArrayBufferView(e))return e.buffer;if(G.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();if(i){if(r.indexOf("application/x-www-form-urlencoded")>-1)return function(e,t){return ne(e,new me.classes.URLSearchParams,Object.assign({visitor:function(e,t,n,r){return me.isNode&&G.isBuffer(e)?(this.append(t,e.toString("base64")),!1):r.defaultVisitor.apply(this,arguments)}},t))}(e,this.formSerializer).toString();if((n=G.isFileList(e))||r.indexOf("multipart/form-data")>-1){var a=this.env&&this.env.FormData;return ne(n?{"files[]":e}:e,a&&new a,this.formSerializer)}}return i||o?(t.setContentType("application/json",!1),function(e,t,n){if(G.isString(e))try{return(t||JSON.parse)(e),G.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(n||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){var t=this.transitional||ve.transitional,n=t&&t.forcedJSONParsing,r="json"===this.responseType;if(e&&G.isString(e)&&(n&&!this.responseType||r)){var o=!(t&&t.silentJSONParsing)&&r;try{return JSON.parse(e)}catch(e){if(o){if("SyntaxError"===e.name)throw $.from(e,$.ERR_BAD_RESPONSE,this,null,this.response);throw e}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:me.classes.FormData,Blob:me.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};G.forEach(["delete","get","head","post","put","patch"],(function(e){ve.headers[e]={}}));var be=ve,ge=G.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),we=Symbol("internals");function Oe(e){return e&&String(e).trim().toLowerCase()}function Ee(e){return!1===e||null==e?e:G.isArray(e)?e.map(Ee):String(e)}function Se(e,t,n,r,o){return G.isFunction(r)?r.call(this,t,n):(o&&(t=n),G.isString(t)?G.isString(r)?-1!==t.indexOf(r):G.isRegExp(r)?r.test(t):void 0:void 0)}var Re=function(e,t){function n(e){r(this,n),e&&this.set(e)}return i(n,[{key:"set",value:function(e,t,n){var r=this;function o(e,t,n){var o=Oe(t);if(!o)throw new Error("header name must be a non-empty string");var i=G.findKey(r,o);(!i||void 0===r[i]||!0===n||void 0===n&&!1!==r[i])&&(r[i||t]=Ee(e))}var i,a,s,u,c,f=function(e,t){return G.forEach(e,(function(e,n){return o(e,n,t)}))};return G.isPlainObject(e)||e instanceof this.constructor?f(e,t):G.isString(e)&&(e=e.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim())?f((c={},(i=e)&&i.split("\n").forEach((function(e){u=e.indexOf(":"),a=e.substring(0,u).trim().toLowerCase(),s=e.substring(u+1).trim(),!a||c[a]&&ge[a]||("set-cookie"===a?c[a]?c[a].push(s):c[a]=[s]:c[a]=c[a]?c[a]+", "+s:s)})),c),t):null!=e&&o(t,e,n),this}},{key:"get",value:function(e,t){if(e=Oe(e)){var n=G.findKey(this,e);if(n){var r=this[n];if(!t)return r;if(!0===t)return function(e){for(var t,n=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;t=r.exec(e);)n[t[1]]=t[2];return n}(r);if(G.isFunction(t))return t.call(this,r,n);if(G.isRegExp(t))return t.exec(r);throw new TypeError("parser must be boolean|regexp|function")}}}},{key:"has",value:function(e,t){if(e=Oe(e)){var n=G.findKey(this,e);return!(!n||void 0===this[n]||t&&!Se(0,this[n],n,t))}return!1}},{key:"delete",value:function(e,t){var n=this,r=!1;function o(e){if(e=Oe(e)){var o=G.findKey(n,e);!o||t&&!Se(0,n[o],o,t)||(delete n[o],r=!0)}}return G.isArray(e)?e.forEach(o):o(e),r}},{key:"clear",value:function(e){for(var t=Object.keys(this),n=t.length,r=!1;n--;){var o=t[n];e&&!Se(0,this[o],o,e,!0)||(delete this[o],r=!0)}return r}},{key:"normalize",value:function(e){var t=this,n={};return G.forEach(this,(function(r,o){var i=G.findKey(n,o);if(i)return t[i]=Ee(r),void delete t[o];var a=e?function(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(function(e,t,n){return t.toUpperCase()+n}))}(o):String(o).trim();a!==o&&delete t[o],t[a]=Ee(r),n[a]=!0})),this}},{key:"concat",value:function(){for(var e,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(e=this.constructor).concat.apply(e,[this].concat(n))}},{key:"toJSON",value:function(e){var t=Object.create(null);return G.forEach(this,(function(n,r){null!=n&&!1!==n&&(t[r]=e&&G.isArray(n)?n.join(", "):n)})),t}},{key:Symbol.iterator,value:function(){return Object.entries(this.toJSON())[Symbol.iterator]()}},{key:"toString",value:function(){return Object.entries(this.toJSON()).map((function(e){var t=s(e,2);return t[0]+": "+t[1]})).join("\n")}},{key:Symbol.toStringTag,get:function(){return"AxiosHeaders"}}],[{key:"from",value:function(e){return e instanceof this?e:new this(e)}},{key:"concat",value:function(e){for(var t=new this(e),n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return r.forEach((function(e){return t.set(e)})),t}},{key:"accessor",value:function(e){var t=(this[we]=this[we]={accessors:{}}).accessors,n=this.prototype;function r(e){var r=Oe(e);t[r]||(!function(e,t){var n=G.toCamelCase(" "+t);["get","set","has"].forEach((function(r){Object.defineProperty(e,r+n,{value:function(e,n,o){return this[r].call(this,t,e,n,o)},configurable:!0})}))}(n,e),t[r]=!0)}return G.isArray(e)?e.forEach(r):r(e),this}}]),n}();Re.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),G.reduceDescriptors(Re.prototype,(function(e,t){var n=e.value,r=t[0].toUpperCase()+t.slice(1);return{get:function(){return n},set:function(e){this[r]=e}}})),G.freezeMethods(Re);var Ae=Re;function je(e,t){var n=this||be,r=t||n,o=Ae.from(r.headers),i=r.data;return G.forEach(e,(function(e){i=e.call(n,i,o.normalize(),t?t.status:void 0)})),o.normalize(),i}function Te(e){return!(!e||!e.__CANCEL__)}function Pe(e,t,n){$.call(this,null==e?"canceled":e,$.ERR_CANCELED,t,n),this.name="CanceledError"}G.inherits(Pe,$,{__CANCEL__:!0});var Ne=me.hasStandardBrowserEnv?{write:function(e,t,n,r,o,i){var a=[];a.push(e+"="+encodeURIComponent(t)),G.isNumber(n)&&a.push("expires="+new Date(n).toGMTString()),G.isString(r)&&a.push("path="+r),G.isString(o)&&a.push("domain="+o),!0===i&&a.push("secure"),document.cookie=a.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}};function Ce(e,t){return e&&!/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)?function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}(e,t):t}var xe=me.hasStandardBrowserEnv?function(){var e,t=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");function r(e){var r=e;return t&&(n.setAttribute("href",r),r=n.href),n.setAttribute("href",r),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:"/"===n.pathname.charAt(0)?n.pathname:"/"+n.pathname}}return e=r(window.location.href),function(t){var n=G.isString(t)?r(t):t;return n.protocol===e.protocol&&n.host===e.host}}():function(){return!0};function ke(e,t){var n=0,r=function(e,t){e=e||10;var n,r=new Array(e),o=new Array(e),i=0,a=0;return t=void 0!==t?t:1e3,function(s){var u=Date.now(),c=o[a];n||(n=u),r[i]=s,o[i]=u;for(var f=a,l=0;f!==i;)l+=r[f++],f%=e;if((i=(i+1)%e)===a&&(a=(a+1)%e),!(u-n<t)){var d=c&&u-c;return d?Math.round(1e3*l/d):void 0}}}(50,250);return function(o){var i=o.loaded,a=o.lengthComputable?o.total:void 0,s=i-n,u=r(s);n=i;var c={loaded:i,total:a,progress:a?i/a:void 0,bytes:s,rate:u||void 0,estimated:u&&a&&i<=a?(a-i)/u:void 0,event:o};c[t?"download":"upload"]=!0,e(c)}}var _e={http:null,xhr:"undefined"!=typeof XMLHttpRequest&&function(e){return new Promise((function(t,n){var r,o,i,a=e.data,s=Ae.from(e.headers).normalize(),d=e.responseType;function h(){e.cancelToken&&e.cancelToken.unsubscribe(r),e.signal&&e.signal.removeEventListener("abort",r)}if(G.isFormData(a))if(me.hasStandardBrowserEnv||me.hasStandardBrowserWebWorkerEnv)s.setContentType(!1);else if(!1!==(o=s.getContentType())){var m=o?o.split(";").map((function(e){return e.trim()})).filter(Boolean):[],y=c(i=m)||f(i)||l(i)||p(),v=y[0],b=y.slice(1);s.setContentType([v||"multipart/form-data"].concat(u(b)).join("; "))}var g=new XMLHttpRequest;if(e.auth){var w=e.auth.username||"",O=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";s.set("Authorization","Basic "+btoa(w+":"+O))}var E=Ce(e.baseURL,e.url);function S(){if(g){var r=Ae.from("getAllResponseHeaders"in g&&g.getAllResponseHeaders());!function(e,t,n){var r=n.config.validateStatus;n.status&&r&&!r(n.status)?t(new $("Request failed with status code "+n.status,[$.ERR_BAD_REQUEST,$.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n)):e(n)}((function(e){t(e),h()}),(function(e){n(e),h()}),{data:d&&"text"!==d&&"json"!==d?g.response:g.responseText,status:g.status,statusText:g.statusText,headers:r,config:e,request:g}),g=null}}if(g.open(e.method.toUpperCase(),se(E,e.params,e.paramsSerializer),!0),g.timeout=e.timeout,"onloadend"in g?g.onloadend=S:g.onreadystatechange=function(){g&&4===g.readyState&&(0!==g.status||g.responseURL&&0===g.responseURL.indexOf("file:"))&&setTimeout(S)},g.onabort=function(){g&&(n(new $("Request aborted",$.ECONNABORTED,e,g)),g=null)},g.onerror=function(){n(new $("Network Error",$.ERR_NETWORK,e,g)),g=null},g.ontimeout=function(){var t=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded",r=e.transitional||fe;e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),n(new $(t,r.clarifyTimeoutError?$.ETIMEDOUT:$.ECONNABORTED,e,g)),g=null},me.hasStandardBrowserEnv){var R=xe(E)&&e.xsrfCookieName&&Ne.read(e.xsrfCookieName);R&&s.set(e.xsrfHeaderName,R)}void 0===a&&s.setContentType(null),"setRequestHeader"in g&&G.forEach(s.toJSON(),(function(e,t){g.setRequestHeader(t,e)})),G.isUndefined(e.withCredentials)||(g.withCredentials=!!e.withCredentials),d&&"json"!==d&&(g.responseType=e.responseType),"function"==typeof e.onDownloadProgress&&g.addEventListener("progress",ke(e.onDownloadProgress,!0)),"function"==typeof e.onUploadProgress&&g.upload&&g.upload.addEventListener("progress",ke(e.onUploadProgress)),(e.cancelToken||e.signal)&&(r=function(t){g&&(n(!t||t.type?new Pe(null,e,g):t),g.abort(),g=null)},e.cancelToken&&e.cancelToken.subscribe(r),e.signal&&(e.signal.aborted?r():e.signal.addEventListener("abort",r)));var A,j=(A=/^([-+\w]{1,25})(:?\/\/|:)/.exec(E))&&A[1]||"";j&&-1===me.protocols.indexOf(j)?n(new $("Unsupported protocol "+j+":",$.ERR_BAD_REQUEST,e)):g.send(a||null)}))}};G.forEach(_e,(function(e,t){if(e){try{Object.defineProperty(e,"name",{value:t})}catch(e){}Object.defineProperty(e,"adapterName",{value:t})}}));var Ue=function(e){return"- ".concat(e)},De=function(e){return G.isFunction(e)||null===e||!1===e},Fe=function(e){for(var t,n,r=(e=G.isArray(e)?e:[e]).length,o={},i=0;i<r;i++){var a=void 0;if(n=t=e[i],!De(t)&&void 0===(n=_e[(a=String(t)).toLowerCase()]))throw new $("Unknown adapter '".concat(a,"'"));if(n)break;o[a||"#"+i]=n}if(!n){var u=Object.entries(o).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"adapter ".concat(n," ")+(!1===r?"is not supported by the environment":"is not available in the build")}));throw new $("There is no suitable adapter to dispatch the request "+(r?u.length>1?"since :\n"+u.map(Ue).join("\n"):" "+Ue(u[0]):"as no adapter specified"),"ERR_NOT_SUPPORT")}return n};function Be(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new Pe(null,e)}function Le(e){return Be(e),e.headers=Ae.from(e.headers),e.data=je.call(e,e.transformRequest),-1!==["post","put","patch"].indexOf(e.method)&&e.headers.setContentType("application/x-www-form-urlencoded",!1),Fe(e.adapter||be.adapter)(e).then((function(t){return Be(e),t.data=je.call(e,e.transformResponse,t),t.headers=Ae.from(t.headers),t}),(function(t){return Te(t)||(Be(e),t&&t.response&&(t.response.data=je.call(e,e.transformResponse,t.response),t.response.headers=Ae.from(t.response.headers))),Promise.reject(t)}))}var Ie=function(e){return e instanceof Ae?e.toJSON():e};function qe(e,t){t=t||{};var n={};function r(e,t,n){return G.isPlainObject(e)&&G.isPlainObject(t)?G.merge.call({caseless:n},e,t):G.isPlainObject(t)?G.merge({},t):G.isArray(t)?t.slice():t}function o(e,t,n){return G.isUndefined(t)?G.isUndefined(e)?void 0:r(void 0,e,n):r(e,t,n)}function i(e,t){if(!G.isUndefined(t))return r(void 0,t)}function a(e,t){return G.isUndefined(t)?G.isUndefined(e)?void 0:r(void 0,e):r(void 0,t)}function s(n,o,i){return i in t?r(n,o):i in e?r(void 0,n):void 0}var u={url:i,method:i,data:i,baseURL:a,transformRequest:a,transformResponse:a,paramsSerializer:a,timeout:a,timeoutMessage:a,withCredentials:a,adapter:a,responseType:a,xsrfCookieName:a,xsrfHeaderName:a,onUploadProgress:a,onDownloadProgress:a,decompress:a,maxContentLength:a,maxBodyLength:a,beforeRedirect:a,transport:a,httpAgent:a,httpsAgent:a,cancelToken:a,socketPath:a,responseEncoding:a,validateStatus:s,headers:function(e,t){return o(Ie(e),Ie(t),!0)}};return G.forEach(Object.keys(Object.assign({},e,t)),(function(r){var i=u[r]||o,a=i(e[r],t[r],r);G.isUndefined(a)&&i!==s||(n[r]=a)})),n}var ze="1.6.1",Me={};["object","boolean","number","function","string","symbol"].forEach((function(e,t){Me[e]=function(r){return n(r)===e||"a"+(t<1?"n ":" ")+e}}));var He={};Me.transitional=function(e,t,n){function r(e,t){return"[Axios v1.6.1] Transitional option '"+e+"'"+t+(n?". "+n:"")}return function(n,o,i){if(!1===e)throw new $(r(o," has been removed"+(t?" in "+t:"")),$.ERR_DEPRECATED);return t&&!He[o]&&(He[o]=!0,console.warn(r(o," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(n,o,i)}};var Je={assertOptions:function(e,t,r){if("object"!==n(e))throw new $("options must be an object",$.ERR_BAD_OPTION_VALUE);for(var o=Object.keys(e),i=o.length;i-- >0;){var a=o[i],s=t[a];if(s){var u=e[a],c=void 0===u||s(u,a,e);if(!0!==c)throw new $("option "+a+" must be "+c,$.ERR_BAD_OPTION_VALUE)}else if(!0!==r)throw new $("Unknown option "+a,$.ERR_BAD_OPTION)}},validators:Me},We=Je.validators,Ke=function(){function e(t){r(this,e),this.defaults=t,this.interceptors={request:new ce,response:new ce}}return i(e,[{key:"request",value:function(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{};var n=t=qe(this.defaults,t),r=n.transitional,o=n.paramsSerializer,i=n.headers;void 0!==r&&Je.assertOptions(r,{silentJSONParsing:We.transitional(We.boolean),forcedJSONParsing:We.transitional(We.boolean),clarifyTimeoutError:We.transitional(We.boolean)},!1),null!=o&&(G.isFunction(o)?t.paramsSerializer={serialize:o}:Je.assertOptions(o,{encode:We.function,serialize:We.function},!0)),t.method=(t.method||this.defaults.method||"get").toLowerCase();var a=i&&G.merge(i.common,i[t.method]);i&&G.forEach(["delete","get","head","post","put","patch","common"],(function(e){delete i[e]})),t.headers=Ae.concat(a,i);var s=[],u=!0;this.interceptors.request.forEach((function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(u=u&&e.synchronous,s.unshift(e.fulfilled,e.rejected))}));var c,f=[];this.interceptors.response.forEach((function(e){f.push(e.fulfilled,e.rejected)}));var l,d=0;if(!u){var p=[Le.bind(this),void 0];for(p.unshift.apply(p,s),p.push.apply(p,f),l=p.length,c=Promise.resolve(t);d<l;)c=c.then(p[d++],p[d++]);return c}l=s.length;var h=t;for(d=0;d<l;){var m=s[d++],y=s[d++];try{h=m(h)}catch(e){y.call(this,e);break}}try{c=Le.call(this,h)}catch(e){return Promise.reject(e)}for(d=0,l=f.length;d<l;)c=c.then(f[d++],f[d++]);return c}},{key:"getUri",value:function(e){return se(Ce((e=qe(this.defaults,e)).baseURL,e.url),e.params,e.paramsSerializer)}}]),e}();G.forEach(["delete","get","head","options"],(function(e){Ke.prototype[e]=function(t,n){return this.request(qe(n||{},{method:e,url:t,data:(n||{}).data}))}})),G.forEach(["post","put","patch"],(function(e){function t(t){return function(n,r,o){return this.request(qe(o||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:n,data:r}))}}Ke.prototype[e]=t(),Ke.prototype[e+"Form"]=t(!0)}));var Ve=Ke,Ge=function(){function e(t){if(r(this,e),"function"!=typeof t)throw new TypeError("executor must be a function.");var n;this.promise=new Promise((function(e){n=e}));var o=this;this.promise.then((function(e){if(o._listeners){for(var t=o._listeners.length;t-- >0;)o._listeners[t](e);o._listeners=null}})),this.promise.then=function(e){var t,n=new Promise((function(e){o.subscribe(e),t=e})).then(e);return n.cancel=function(){o.unsubscribe(t)},n},t((function(e,t,r){o.reason||(o.reason=new Pe(e,t,r),n(o.reason))}))}return i(e,[{key:"throwIfRequested",value:function(){if(this.reason)throw this.reason}},{key:"subscribe",value:function(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]}},{key:"unsubscribe",value:function(e){if(this._listeners){var t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}}}],[{key:"source",value:function(){var t;return{token:new e((function(e){t=e})),cancel:t}}}]),e}();var $e={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries($e).forEach((function(e){var t=s(e,2),n=t[0],r=t[1];$e[r]=n}));var Xe=$e;var Qe=function e(t){var n=new Ve(t),r=h(Ve.prototype.request,n);return G.extend(r,Ve.prototype,n,{allOwnKeys:!0}),G.extend(r,n,null,{allOwnKeys:!0}),r.create=function(n){return e(qe(t,n))},r}(be);return Qe.Axios=Ve,Qe.CanceledError=Pe,Qe.CancelToken=Ge,Qe.isCancel=Te,Qe.VERSION=ze,Qe.toFormData=ne,Qe.AxiosError=$,Qe.Cancel=Qe.CanceledError,Qe.all=function(e){return Promise.all(e)},Qe.spread=function(e){return function(t){return e.apply(null,t)}},Qe.isAxiosError=function(e){return G.isObject(e)&&!0===e.isAxiosError},Qe.mergeConfig=qe,Qe.AxiosHeaders=Ae,Qe.formToJSON=function(e){return ye(G.isHTMLForm(e)?new FormData(e):e)},Qe.getAdapter=Fe,Qe.HttpStatusCode=Xe,Qe.default=Qe,Qe})); | ||
//# sourceMappingURL=axios.min.js.map |
@@ -1,7 +0,114 @@ | ||
export interface AxiosTransformer { | ||
(data: any, headers?: Record<string, string>): any; | ||
// TypeScript Version: 4.7 | ||
export type AxiosHeaderValue = AxiosHeaders | string | string[] | number | boolean | null; | ||
interface RawAxiosHeaders { | ||
[key: string]: AxiosHeaderValue; | ||
} | ||
type MethodsHeaders = Partial<{ | ||
[Key in Method as Lowercase<Key>]: AxiosHeaders; | ||
} & {common: AxiosHeaders}>; | ||
type AxiosHeaderMatcher = string | RegExp | ((this: AxiosHeaders, value: string, name: string) => boolean); | ||
type AxiosHeaderParser = (this: AxiosHeaders, value: AxiosHeaderValue, header: string) => any; | ||
export class AxiosHeaders { | ||
constructor( | ||
headers?: RawAxiosHeaders | AxiosHeaders | string | ||
); | ||
[key: string]: any; | ||
set(headerName?: string, value?: AxiosHeaderValue, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders; | ||
set(headers?: RawAxiosHeaders | AxiosHeaders | string, rewrite?: boolean): AxiosHeaders; | ||
get(headerName: string, parser: RegExp): RegExpExecArray | null; | ||
get(headerName: string, matcher?: true | AxiosHeaderParser): AxiosHeaderValue; | ||
has(header: string, matcher?: AxiosHeaderMatcher): boolean; | ||
delete(header: string | string[], matcher?: AxiosHeaderMatcher): boolean; | ||
clear(matcher?: AxiosHeaderMatcher): boolean; | ||
normalize(format: boolean): AxiosHeaders; | ||
concat(...targets: Array<AxiosHeaders | RawAxiosHeaders | string | undefined | null>): AxiosHeaders; | ||
toJSON(asStrings?: boolean): RawAxiosHeaders; | ||
static from(thing?: AxiosHeaders | RawAxiosHeaders | string): AxiosHeaders; | ||
static accessor(header: string | string[]): AxiosHeaders; | ||
static concat(...targets: Array<AxiosHeaders | RawAxiosHeaders | string | undefined | null>): AxiosHeaders; | ||
setContentType(value: ContentType, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders; | ||
getContentType(parser?: RegExp): RegExpExecArray | null; | ||
getContentType(matcher?: AxiosHeaderMatcher): AxiosHeaderValue; | ||
hasContentType(matcher?: AxiosHeaderMatcher): boolean; | ||
setContentLength(value: AxiosHeaderValue, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders; | ||
getContentLength(parser?: RegExp): RegExpExecArray | null; | ||
getContentLength(matcher?: AxiosHeaderMatcher): AxiosHeaderValue; | ||
hasContentLength(matcher?: AxiosHeaderMatcher): boolean; | ||
setAccept(value: AxiosHeaderValue, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders; | ||
getAccept(parser?: RegExp): RegExpExecArray | null; | ||
getAccept(matcher?: AxiosHeaderMatcher): AxiosHeaderValue; | ||
hasAccept(matcher?: AxiosHeaderMatcher): boolean; | ||
setUserAgent(value: AxiosHeaderValue, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders; | ||
getUserAgent(parser?: RegExp): RegExpExecArray | null; | ||
getUserAgent(matcher?: AxiosHeaderMatcher): AxiosHeaderValue; | ||
hasUserAgent(matcher?: AxiosHeaderMatcher): boolean; | ||
setContentEncoding(value: AxiosHeaderValue, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders; | ||
getContentEncoding(parser?: RegExp): RegExpExecArray | null; | ||
getContentEncoding(matcher?: AxiosHeaderMatcher): AxiosHeaderValue; | ||
hasContentEncoding(matcher?: AxiosHeaderMatcher): boolean; | ||
setAuthorization(value: AxiosHeaderValue, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders; | ||
getAuthorization(parser?: RegExp): RegExpExecArray | null; | ||
getAuthorization(matcher?: AxiosHeaderMatcher): AxiosHeaderValue; | ||
hasAuthorization(matcher?: AxiosHeaderMatcher): boolean; | ||
[Symbol.iterator](): IterableIterator<[string, AxiosHeaderValue]>; | ||
} | ||
type CommonRequestHeadersList = 'Accept' | 'Content-Length' | 'User-Agent' | 'Content-Encoding' | 'Authorization'; | ||
type ContentType = AxiosHeaderValue | 'text/html' | 'text/plain' | 'multipart/form-data' | 'application/json' | 'application/x-www-form-urlencoded' | 'application/octet-stream'; | ||
export type RawAxiosRequestHeaders = Partial<RawAxiosHeaders & { | ||
[Key in CommonRequestHeadersList]: AxiosHeaderValue; | ||
} & { | ||
'Content-Type': ContentType | ||
}>; | ||
export type AxiosRequestHeaders = RawAxiosRequestHeaders & AxiosHeaders; | ||
type CommonResponseHeadersList = 'Server' | 'Content-Type' | 'Content-Length' | 'Cache-Control'| 'Content-Encoding'; | ||
type RawCommonResponseHeaders = { | ||
[Key in CommonResponseHeadersList]: AxiosHeaderValue; | ||
} & { | ||
"set-cookie": string[]; | ||
}; | ||
export type RawAxiosResponseHeaders = Partial<RawAxiosHeaders & RawCommonResponseHeaders>; | ||
export type AxiosResponseHeaders = RawAxiosResponseHeaders & AxiosHeaders; | ||
export interface AxiosRequestTransformer { | ||
(this: InternalAxiosRequestConfig, data: any, headers: AxiosRequestHeaders): any; | ||
} | ||
export interface AxiosResponseTransformer { | ||
(this: InternalAxiosRequestConfig, data: any, headers: AxiosResponseHeaders, status?: number): any; | ||
} | ||
export interface AxiosAdapter { | ||
(config: AxiosRequestConfig): AxiosPromise<any>; | ||
(config: InternalAxiosRequestConfig): AxiosPromise; | ||
} | ||
@@ -17,55 +124,213 @@ | ||
port: number; | ||
auth?: { | ||
username: string; | ||
password:string; | ||
}; | ||
auth?: AxiosBasicCredentials; | ||
protocol?: string; | ||
} | ||
export enum HttpStatusCode { | ||
Continue = 100, | ||
SwitchingProtocols = 101, | ||
Processing = 102, | ||
EarlyHints = 103, | ||
Ok = 200, | ||
Created = 201, | ||
Accepted = 202, | ||
NonAuthoritativeInformation = 203, | ||
NoContent = 204, | ||
ResetContent = 205, | ||
PartialContent = 206, | ||
MultiStatus = 207, | ||
AlreadyReported = 208, | ||
ImUsed = 226, | ||
MultipleChoices = 300, | ||
MovedPermanently = 301, | ||
Found = 302, | ||
SeeOther = 303, | ||
NotModified = 304, | ||
UseProxy = 305, | ||
Unused = 306, | ||
TemporaryRedirect = 307, | ||
PermanentRedirect = 308, | ||
BadRequest = 400, | ||
Unauthorized = 401, | ||
PaymentRequired = 402, | ||
Forbidden = 403, | ||
NotFound = 404, | ||
MethodNotAllowed = 405, | ||
NotAcceptable = 406, | ||
ProxyAuthenticationRequired = 407, | ||
RequestTimeout = 408, | ||
Conflict = 409, | ||
Gone = 410, | ||
LengthRequired = 411, | ||
PreconditionFailed = 412, | ||
PayloadTooLarge = 413, | ||
UriTooLong = 414, | ||
UnsupportedMediaType = 415, | ||
RangeNotSatisfiable = 416, | ||
ExpectationFailed = 417, | ||
ImATeapot = 418, | ||
MisdirectedRequest = 421, | ||
UnprocessableEntity = 422, | ||
Locked = 423, | ||
FailedDependency = 424, | ||
TooEarly = 425, | ||
UpgradeRequired = 426, | ||
PreconditionRequired = 428, | ||
TooManyRequests = 429, | ||
RequestHeaderFieldsTooLarge = 431, | ||
UnavailableForLegalReasons = 451, | ||
InternalServerError = 500, | ||
NotImplemented = 501, | ||
BadGateway = 502, | ||
ServiceUnavailable = 503, | ||
GatewayTimeout = 504, | ||
HttpVersionNotSupported = 505, | ||
VariantAlsoNegotiates = 506, | ||
InsufficientStorage = 507, | ||
LoopDetected = 508, | ||
NotExtended = 510, | ||
NetworkAuthenticationRequired = 511, | ||
} | ||
export type Method = | ||
| 'get' | 'GET' | ||
| 'delete' | 'DELETE' | ||
| 'head' | 'HEAD' | ||
| 'options' | 'OPTIONS' | ||
| 'post' | 'POST' | ||
| 'put' | 'PUT' | ||
| 'patch' | 'PATCH' | ||
| 'purge' | 'PURGE' | ||
| 'link' | 'LINK' | ||
| 'unlink' | 'UNLINK' | ||
| 'get' | 'GET' | ||
| 'delete' | 'DELETE' | ||
| 'head' | 'HEAD' | ||
| 'options' | 'OPTIONS' | ||
| 'post' | 'POST' | ||
| 'put' | 'PUT' | ||
| 'patch' | 'PATCH' | ||
| 'purge' | 'PURGE' | ||
| 'link' | 'LINK' | ||
| 'unlink' | 'UNLINK'; | ||
export type ResponseType = | ||
| 'arraybuffer' | ||
| 'blob' | ||
| 'document' | ||
| 'json' | ||
| 'text' | ||
| 'stream' | ||
| 'arraybuffer' | ||
| 'blob' | ||
| 'document' | ||
| 'json' | ||
| 'text' | ||
| 'stream'; | ||
export interface TransitionalOptions{ | ||
silentJSONParsing: boolean; | ||
forcedJSONParsing: boolean; | ||
clarifyTimeoutError: boolean; | ||
export type responseEncoding = | ||
| 'ascii' | 'ASCII' | ||
| 'ansi' | 'ANSI' | ||
| 'binary' | 'BINARY' | ||
| 'base64' | 'BASE64' | ||
| 'base64url' | 'BASE64URL' | ||
| 'hex' | 'HEX' | ||
| 'latin1' | 'LATIN1' | ||
| 'ucs-2' | 'UCS-2' | ||
| 'ucs2' | 'UCS2' | ||
| 'utf-8' | 'UTF-8' | ||
| 'utf8' | 'UTF8' | ||
| 'utf16le' | 'UTF16LE'; | ||
export interface TransitionalOptions { | ||
silentJSONParsing?: boolean; | ||
forcedJSONParsing?: boolean; | ||
clarifyTimeoutError?: boolean; | ||
} | ||
export interface AxiosRequestConfig<T = any> { | ||
export interface GenericAbortSignal { | ||
readonly aborted: boolean; | ||
onabort?: ((...args: any) => any) | null; | ||
addEventListener?: (...args: any) => any; | ||
removeEventListener?: (...args: any) => any; | ||
} | ||
export interface FormDataVisitorHelpers { | ||
defaultVisitor: SerializerVisitor; | ||
convertValue: (value: any) => any; | ||
isVisitable: (value: any) => boolean; | ||
} | ||
export interface SerializerVisitor { | ||
( | ||
this: GenericFormData, | ||
value: any, | ||
key: string | number, | ||
path: null | Array<string | number>, | ||
helpers: FormDataVisitorHelpers | ||
): boolean; | ||
} | ||
export interface SerializerOptions { | ||
visitor?: SerializerVisitor; | ||
dots?: boolean; | ||
metaTokens?: boolean; | ||
indexes?: boolean | null; | ||
} | ||
// tslint:disable-next-line | ||
export interface FormSerializerOptions extends SerializerOptions { | ||
} | ||
export interface ParamEncoder { | ||
(value: any, defaultEncoder: (value: any) => any): any; | ||
} | ||
export interface CustomParamsSerializer { | ||
(params: Record<string, any>, options?: ParamsSerializerOptions): string; | ||
} | ||
export interface ParamsSerializerOptions extends SerializerOptions { | ||
encode?: ParamEncoder; | ||
serialize?: CustomParamsSerializer; | ||
} | ||
type MaxUploadRate = number; | ||
type MaxDownloadRate = number; | ||
type BrowserProgressEvent = any; | ||
export interface AxiosProgressEvent { | ||
loaded: number; | ||
total?: number; | ||
progress?: number; | ||
bytes: number; | ||
rate?: number; | ||
estimated?: number; | ||
upload?: boolean; | ||
download?: boolean; | ||
event?: BrowserProgressEvent; | ||
} | ||
type Milliseconds = number; | ||
type AxiosAdapterName = 'xhr' | 'http' | string; | ||
type AxiosAdapterConfig = AxiosAdapter | AxiosAdapterName; | ||
export type AddressFamily = 4 | 6 | undefined; | ||
export interface LookupAddressEntry { | ||
address: string; | ||
family?: AddressFamily; | ||
} | ||
export type LookupAddress = string | LookupAddressEntry; | ||
export interface AxiosRequestConfig<D = any> { | ||
url?: string; | ||
method?: Method; | ||
method?: Method | string; | ||
baseURL?: string; | ||
transformRequest?: AxiosTransformer | AxiosTransformer[]; | ||
transformResponse?: AxiosTransformer | AxiosTransformer[]; | ||
headers?: Record<string, string>; | ||
transformRequest?: AxiosRequestTransformer | AxiosRequestTransformer[]; | ||
transformResponse?: AxiosResponseTransformer | AxiosResponseTransformer[]; | ||
headers?: (RawAxiosRequestHeaders & MethodsHeaders) | AxiosHeaders; | ||
params?: any; | ||
paramsSerializer?: (params: any) => string; | ||
data?: T; | ||
timeout?: number; | ||
paramsSerializer?: ParamsSerializerOptions | CustomParamsSerializer; | ||
data?: D; | ||
timeout?: Milliseconds; | ||
timeoutErrorMessage?: string; | ||
withCredentials?: boolean; | ||
adapter?: AxiosAdapter; | ||
adapter?: AxiosAdapterConfig | AxiosAdapterConfig[]; | ||
auth?: AxiosBasicCredentials; | ||
responseType?: ResponseType; | ||
responseEncoding?: responseEncoding | string; | ||
xsrfCookieName?: string; | ||
xsrfHeaderName?: string; | ||
onUploadProgress?: (progressEvent: any) => void; | ||
onDownloadProgress?: (progressEvent: any) => void; | ||
onUploadProgress?: (progressEvent: AxiosProgressEvent) => void; | ||
onDownloadProgress?: (progressEvent: AxiosProgressEvent) => void; | ||
maxContentLength?: number; | ||
@@ -75,3 +340,6 @@ validateStatus?: ((status: number) => boolean) | null; | ||
maxRedirects?: number; | ||
maxRate?: number | [MaxUploadRate, MaxDownloadRate]; | ||
beforeRedirect?: (options: Record<string, any>, responseDetails: { headers: Record<string, string> }) => void; | ||
socketPath?: string | null; | ||
transport?: any; | ||
httpAgent?: any; | ||
@@ -82,27 +350,96 @@ httpsAgent?: any; | ||
decompress?: boolean; | ||
transitional?: TransitionalOptions | ||
signal?: AbortSignal; | ||
transitional?: TransitionalOptions; | ||
signal?: GenericAbortSignal; | ||
insecureHTTPParser?: boolean; | ||
env?: { | ||
FormData?: new (...args: any[]) => object; | ||
}; | ||
formSerializer?: FormSerializerOptions; | ||
family?: AddressFamily; | ||
lookup?: ((hostname: string, options: object, cb: (err: Error | null, address: LookupAddress | LookupAddress[], family?: AddressFamily) => void) => void) | | ||
((hostname: string, options: object) => Promise<[address: LookupAddressEntry | LookupAddressEntry[], family?: AddressFamily] | LookupAddress>); | ||
} | ||
export interface AxiosResponse<T = never> { | ||
// Alias | ||
export type RawAxiosRequestConfig<D = any> = AxiosRequestConfig<D>; | ||
export interface InternalAxiosRequestConfig<D = any> extends AxiosRequestConfig<D> { | ||
headers: AxiosRequestHeaders; | ||
} | ||
export interface HeadersDefaults { | ||
common: RawAxiosRequestHeaders; | ||
delete: RawAxiosRequestHeaders; | ||
get: RawAxiosRequestHeaders; | ||
head: RawAxiosRequestHeaders; | ||
post: RawAxiosRequestHeaders; | ||
put: RawAxiosRequestHeaders; | ||
patch: RawAxiosRequestHeaders; | ||
options?: RawAxiosRequestHeaders; | ||
purge?: RawAxiosRequestHeaders; | ||
link?: RawAxiosRequestHeaders; | ||
unlink?: RawAxiosRequestHeaders; | ||
} | ||
export interface AxiosDefaults<D = any> extends Omit<AxiosRequestConfig<D>, 'headers'> { | ||
headers: HeadersDefaults; | ||
} | ||
export interface CreateAxiosDefaults<D = any> extends Omit<AxiosRequestConfig<D>, 'headers'> { | ||
headers?: RawAxiosRequestHeaders | AxiosHeaders | Partial<HeadersDefaults>; | ||
} | ||
export interface AxiosResponse<T = any, D = any> { | ||
data: T; | ||
status: number; | ||
statusText: string; | ||
headers: Record<string, string>; | ||
config: AxiosRequestConfig<T>; | ||
headers: RawAxiosResponseHeaders | AxiosResponseHeaders; | ||
config: InternalAxiosRequestConfig<D>; | ||
request?: any; | ||
} | ||
export interface AxiosError<T = never> extends Error { | ||
config: AxiosRequestConfig; | ||
export class AxiosError<T = unknown, D = any> extends Error { | ||
constructor( | ||
message?: string, | ||
code?: string, | ||
config?: InternalAxiosRequestConfig<D>, | ||
request?: any, | ||
response?: AxiosResponse<T, D> | ||
); | ||
config?: InternalAxiosRequestConfig<D>; | ||
code?: string; | ||
request?: any; | ||
response?: AxiosResponse<T>; | ||
response?: AxiosResponse<T, D>; | ||
isAxiosError: boolean; | ||
status?: number; | ||
toJSON: () => object; | ||
cause?: Error; | ||
static from<T = unknown, D = any>( | ||
error: Error | unknown, | ||
code?: string, | ||
config?: InternalAxiosRequestConfig<D>, | ||
request?: any, | ||
response?: AxiosResponse<T, D>, | ||
customProps?: object, | ||
): AxiosError<T, D>; | ||
static readonly ERR_FR_TOO_MANY_REDIRECTS = "ERR_FR_TOO_MANY_REDIRECTS"; | ||
static readonly ERR_BAD_OPTION_VALUE = "ERR_BAD_OPTION_VALUE"; | ||
static readonly ERR_BAD_OPTION = "ERR_BAD_OPTION"; | ||
static readonly ERR_NETWORK = "ERR_NETWORK"; | ||
static readonly ERR_DEPRECATED = "ERR_DEPRECATED"; | ||
static readonly ERR_BAD_RESPONSE = "ERR_BAD_RESPONSE"; | ||
static readonly ERR_BAD_REQUEST = "ERR_BAD_REQUEST"; | ||
static readonly ERR_NOT_SUPPORT = "ERR_NOT_SUPPORT"; | ||
static readonly ERR_INVALID_URL = "ERR_INVALID_URL"; | ||
static readonly ERR_CANCELED = "ERR_CANCELED"; | ||
static readonly ECONNABORTED = "ECONNABORTED"; | ||
static readonly ETIMEDOUT = "ETIMEDOUT"; | ||
} | ||
export interface AxiosPromise<T = never> extends Promise<AxiosResponse<T>> { | ||
export class CanceledError<T> extends AxiosError<T> { | ||
} | ||
export type AxiosPromise<T = any> = Promise<AxiosResponse<T>>; | ||
export interface CancelStatic { | ||
@@ -113,7 +450,7 @@ new (message?: string): Cancel; | ||
export interface Cancel { | ||
message: string; | ||
message: string | undefined; | ||
} | ||
export interface Canceler { | ||
(message?: string): void; | ||
(message?: string, config?: AxiosRequestConfig, request?: any): void; | ||
} | ||
@@ -137,5 +474,11 @@ | ||
export interface AxiosInterceptorOptions { | ||
synchronous?: boolean; | ||
runWhen?: (config: InternalAxiosRequestConfig) => boolean; | ||
} | ||
export interface AxiosInterceptorManager<V> { | ||
use<T = V>(onFulfilled?: (value: V) => T | Promise<T>, onRejected?: (error: any) => any): number; | ||
use(onFulfilled?: ((value: V) => V | Promise<V>) | null, onRejected?: ((error: any) => any) | null, options?: AxiosInterceptorOptions): number; | ||
eject(id: number): void; | ||
clear(): void; | ||
} | ||
@@ -145,33 +488,73 @@ | ||
constructor(config?: AxiosRequestConfig); | ||
defaults: AxiosRequestConfig; | ||
defaults: AxiosDefaults; | ||
interceptors: { | ||
request: AxiosInterceptorManager<AxiosRequestConfig>; | ||
request: AxiosInterceptorManager<InternalAxiosRequestConfig>; | ||
response: AxiosInterceptorManager<AxiosResponse>; | ||
}; | ||
getUri(config?: AxiosRequestConfig): string; | ||
request<T = never, R = AxiosResponse<T>> (config: AxiosRequestConfig<T>): Promise<R>; | ||
get<T = never, R = AxiosResponse<T>>(url: string, config?: AxiosRequestConfig<T>): Promise<R>; | ||
delete<T = never, R = AxiosResponse<T>>(url: string, config?: AxiosRequestConfig<T>): Promise<R>; | ||
head<T = never, R = AxiosResponse<T>>(url: string, config?: AxiosRequestConfig<T>): Promise<R>; | ||
options<T = never, R = AxiosResponse<T>>(url: string, config?: AxiosRequestConfig<T>): Promise<R>; | ||
post<T = never, R = AxiosResponse<T>>(url: string, data?: T, config?: AxiosRequestConfig<T>): Promise<R>; | ||
put<T = never, R = AxiosResponse<T>>(url: string, data?: T, config?: AxiosRequestConfig<T>): Promise<R>; | ||
patch<T = never, R = AxiosResponse<T>>(url: string, data?: T, config?: AxiosRequestConfig<T>): Promise<R>; | ||
request<T = any, R = AxiosResponse<T>, D = any>(config: AxiosRequestConfig<D>): Promise<R>; | ||
get<T = any, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R>; | ||
delete<T = any, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R>; | ||
head<T = any, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R>; | ||
options<T = any, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R>; | ||
post<T = any, R = AxiosResponse<T>, D = any>(url: string, data?: D, config?: AxiosRequestConfig<D>): Promise<R>; | ||
put<T = any, R = AxiosResponse<T>, D = any>(url: string, data?: D, config?: AxiosRequestConfig<D>): Promise<R>; | ||
patch<T = any, R = AxiosResponse<T>, D = any>(url: string, data?: D, config?: AxiosRequestConfig<D>): Promise<R>; | ||
postForm<T = any, R = AxiosResponse<T>, D = any>(url: string, data?: D, config?: AxiosRequestConfig<D>): Promise<R>; | ||
putForm<T = any, R = AxiosResponse<T>, D = any>(url: string, data?: D, config?: AxiosRequestConfig<D>): Promise<R>; | ||
patchForm<T = any, R = AxiosResponse<T>, D = any>(url: string, data?: D, config?: AxiosRequestConfig<D>): Promise<R>; | ||
} | ||
export interface AxiosInstance extends Axios { | ||
(config: AxiosRequestConfig): AxiosPromise; | ||
(url: string, config?: AxiosRequestConfig): AxiosPromise; | ||
<T = any, R = AxiosResponse<T>, D = any>(config: AxiosRequestConfig<D>): Promise<R>; | ||
<T = any, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R>; | ||
defaults: Omit<AxiosDefaults, 'headers'> & { | ||
headers: HeadersDefaults & { | ||
[key: string]: AxiosHeaderValue | ||
} | ||
}; | ||
} | ||
export interface GenericFormData { | ||
append(name: string, value: any, options?: any): any; | ||
} | ||
export interface GenericHTMLFormElement { | ||
name: string; | ||
method: string; | ||
submit(): void; | ||
} | ||
export function getAdapter(adapters: AxiosAdapterConfig | AxiosAdapterConfig[] | undefined): AxiosAdapter; | ||
export function toFormData(sourceObj: object, targetFormData?: GenericFormData, options?: FormSerializerOptions): GenericFormData; | ||
export function formToJSON(form: GenericFormData|GenericHTMLFormElement): object; | ||
export function isAxiosError<T = any, D = any>(payload: any): payload is AxiosError<T, D>; | ||
export function spread<T, R>(callback: (...args: T[]) => R): (array: T[]) => R; | ||
export function isCancel(value: any): value is Cancel; | ||
export function all<T>(values: Array<T | Promise<T>>): Promise<T[]>; | ||
export interface AxiosStatic extends AxiosInstance { | ||
create(config?: AxiosRequestConfig): AxiosInstance; | ||
create(config?: CreateAxiosDefaults): AxiosInstance; | ||
Cancel: CancelStatic; | ||
CancelToken: CancelTokenStatic; | ||
Axios: typeof Axios; | ||
AxiosError: typeof AxiosError; | ||
HttpStatusCode: typeof HttpStatusCode; | ||
readonly VERSION: string; | ||
isCancel(value: any): boolean; | ||
all<T>(values: (T | Promise<T>)[]): Promise<T[]>; | ||
spread<T, R>(callback: (...args: T[]) => R): (array: T[]) => R; | ||
isAxiosError(payload: any): payload is AxiosError; | ||
isCancel: typeof isCancel; | ||
all: typeof all; | ||
spread: typeof spread; | ||
isAxiosError: typeof isAxiosError; | ||
toFormData: typeof toFormData; | ||
formToJSON: typeof formToJSON; | ||
getAdapter: typeof getAdapter; | ||
CanceledError: typeof CanceledError; | ||
AxiosHeaders: typeof AxiosHeaders; | ||
} | ||
@@ -178,0 +561,0 @@ |
@@ -1,1 +0,43 @@ | ||
module.exports = require('./lib/axios'); | ||
import axios from './lib/axios.js'; | ||
// This module is intended to unwrap Axios default export as named. | ||
// Keep top-level export same with static properties | ||
// so that it can keep same with es module or cjs | ||
const { | ||
Axios, | ||
AxiosError, | ||
CanceledError, | ||
isCancel, | ||
CancelToken, | ||
VERSION, | ||
all, | ||
Cancel, | ||
isAxiosError, | ||
spread, | ||
toFormData, | ||
AxiosHeaders, | ||
HttpStatusCode, | ||
formToJSON, | ||
getAdapter, | ||
mergeConfig | ||
} = axios; | ||
export { | ||
axios as default, | ||
Axios, | ||
AxiosError, | ||
CanceledError, | ||
isCancel, | ||
CancelToken, | ||
VERSION, | ||
all, | ||
Cancel, | ||
isAxiosError, | ||
spread, | ||
toFormData, | ||
AxiosHeaders, | ||
HttpStatusCode, | ||
formToJSON, | ||
getAdapter, | ||
mergeConfig | ||
} |
'use strict'; | ||
var utils = require('./../utils'); | ||
var settle = require('./../core/settle'); | ||
var buildFullPath = require('../core/buildFullPath'); | ||
var buildURL = require('./../helpers/buildURL'); | ||
var http = require('http'); | ||
var https = require('https'); | ||
var httpFollow = require('follow-redirects').http; | ||
var httpsFollow = require('follow-redirects').https; | ||
var url = require('url'); | ||
var zlib = require('zlib'); | ||
var VERSION = require('./../env/data').version; | ||
var createError = require('../core/createError'); | ||
var enhanceError = require('../core/enhanceError'); | ||
var defaults = require('../defaults'); | ||
var Cancel = require('../cancel/Cancel'); | ||
import utils from './../utils.js'; | ||
import settle from './../core/settle.js'; | ||
import buildFullPath from '../core/buildFullPath.js'; | ||
import buildURL from './../helpers/buildURL.js'; | ||
import {getProxyForUrl} from 'proxy-from-env'; | ||
import http from 'http'; | ||
import https from 'https'; | ||
import util from 'util'; | ||
import followRedirects from 'follow-redirects'; | ||
import zlib from 'zlib'; | ||
import {VERSION} from '../env/data.js'; | ||
import transitionalDefaults from '../defaults/transitional.js'; | ||
import AxiosError from '../core/AxiosError.js'; | ||
import CanceledError from '../cancel/CanceledError.js'; | ||
import platform from '../platform/index.js'; | ||
import fromDataURI from '../helpers/fromDataURI.js'; | ||
import stream from 'stream'; | ||
import AxiosHeaders from '../core/AxiosHeaders.js'; | ||
import AxiosTransformStream from '../helpers/AxiosTransformStream.js'; | ||
import EventEmitter from 'events'; | ||
import formDataToStream from "../helpers/formDataToStream.js"; | ||
import readBlob from "../helpers/readBlob.js"; | ||
import ZlibHeaderTransformStream from '../helpers/ZlibHeaderTransformStream.js'; | ||
import callbackify from "../helpers/callbackify.js"; | ||
var isHttps = /https:?/; | ||
const zlibOptions = { | ||
flush: zlib.constants.Z_SYNC_FLUSH, | ||
finishFlush: zlib.constants.Z_SYNC_FLUSH | ||
}; | ||
const brotliOptions = { | ||
flush: zlib.constants.BROTLI_OPERATION_FLUSH, | ||
finishFlush: zlib.constants.BROTLI_OPERATION_FLUSH | ||
} | ||
const isBrotliSupported = utils.isFunction(zlib.createBrotliDecompress); | ||
const {http: httpFollow, https: httpsFollow} = followRedirects; | ||
const isHttps = /https:?/; | ||
const supportedProtocols = platform.protocols.map(protocol => { | ||
return protocol + ':'; | ||
}); | ||
/** | ||
* If the proxy or config beforeRedirects functions are defined, call them with the options | ||
* object. | ||
* | ||
* @param {Object<string, any>} options - The options object that was passed to the request. | ||
* | ||
* @returns {Object<string, any>} | ||
*/ | ||
function dispatchBeforeRedirect(options) { | ||
if (options.beforeRedirects.proxy) { | ||
options.beforeRedirects.proxy(options); | ||
} | ||
if (options.beforeRedirects.config) { | ||
options.beforeRedirects.config(options); | ||
} | ||
} | ||
/** | ||
* If the proxy or config afterRedirects functions are defined, call them with the options | ||
* | ||
* @param {http.ClientRequestArgs} options | ||
* @param {AxiosProxyConfig} proxy | ||
* @param {AxiosProxyConfig} configProxy configuration from Axios options object | ||
* @param {string} location | ||
* | ||
* @returns {http.ClientRequestArgs} | ||
*/ | ||
function setProxy(options, proxy, location) { | ||
options.hostname = proxy.host; | ||
options.host = proxy.host; | ||
options.port = proxy.port; | ||
options.path = location; | ||
function setProxy(options, configProxy, location) { | ||
let proxy = configProxy; | ||
if (!proxy && proxy !== false) { | ||
const proxyUrl = getProxyForUrl(location); | ||
if (proxyUrl) { | ||
proxy = new URL(proxyUrl); | ||
} | ||
} | ||
if (proxy) { | ||
// Basic proxy authorization | ||
if (proxy.username) { | ||
proxy.auth = (proxy.username || '') + ':' + (proxy.password || ''); | ||
} | ||
// Basic proxy authorization | ||
if (proxy.auth) { | ||
var base64 = Buffer.from(proxy.auth.username + ':' + proxy.auth.password, 'utf8').toString('base64'); | ||
options.headers['Proxy-Authorization'] = 'Basic ' + base64; | ||
if (proxy.auth) { | ||
// Support proxy auth object form | ||
if (proxy.auth.username || proxy.auth.password) { | ||
proxy.auth = (proxy.auth.username || '') + ':' + (proxy.auth.password || ''); | ||
} | ||
const base64 = Buffer | ||
.from(proxy.auth, 'utf8') | ||
.toString('base64'); | ||
options.headers['Proxy-Authorization'] = 'Basic ' + base64; | ||
} | ||
options.headers.host = options.hostname + (options.port ? ':' + options.port : ''); | ||
const proxyHost = proxy.hostname || proxy.host; | ||
options.hostname = proxyHost; | ||
// Replace 'host' since options is not a URL object | ||
options.host = proxyHost; | ||
options.port = proxy.port; | ||
options.path = location; | ||
if (proxy.protocol) { | ||
options.protocol = proxy.protocol.includes(':') ? proxy.protocol : `${proxy.protocol}:`; | ||
} | ||
} | ||
// If a proxy is used, any redirects must also pass through the proxy | ||
options.beforeRedirect = function beforeRedirect(redirection) { | ||
redirection.headers.host = redirection.host; | ||
setProxy(redirection, proxy, redirection.href); | ||
options.beforeRedirects.proxy = function beforeRedirect(redirectOptions) { | ||
// Configure proxy for redirected request, passing the original config proxy to apply | ||
// the exact same logic as if the redirected request was performed by axios directly. | ||
setProxy(redirectOptions, configProxy, redirectOptions.href); | ||
}; | ||
} | ||
const isHttpAdapterSupported = typeof process !== 'undefined' && utils.kindOf(process) === 'process'; | ||
// temporary hotfix | ||
const wrapAsync = (asyncExecutor) => { | ||
return new Promise((resolve, reject) => { | ||
let onDone; | ||
let isDone; | ||
const done = (value, isRejected) => { | ||
if (isDone) return; | ||
isDone = true; | ||
onDone && onDone(value, isRejected); | ||
} | ||
const _resolve = (value) => { | ||
done(value); | ||
resolve(value); | ||
}; | ||
const _reject = (reason) => { | ||
done(reason, true); | ||
reject(reason); | ||
} | ||
asyncExecutor(_resolve, _reject, (onDoneHandler) => (onDone = onDoneHandler)).catch(_reject); | ||
}) | ||
}; | ||
const resolveFamily = ({address, family}) => { | ||
if (!utils.isString(address)) { | ||
throw TypeError('address must be a string'); | ||
} | ||
return ({ | ||
address, | ||
family: family || (address.indexOf('.') < 0 ? 6 : 4) | ||
}); | ||
} | ||
const buildAddressEntry = (address, family) => resolveFamily(utils.isObject(address) ? address : {address, family}); | ||
/*eslint consistent-return:0*/ | ||
module.exports = function httpAdapter(config) { | ||
return new Promise(function dispatchHttpRequest(resolvePromise, rejectPromise) { | ||
var onCanceled; | ||
function done() { | ||
export default isHttpAdapterSupported && function httpAdapter(config) { | ||
return wrapAsync(async function dispatchHttpRequest(resolve, reject, onDone) { | ||
let {data, lookup, family} = config; | ||
const {responseType, responseEncoding} = config; | ||
const method = config.method.toUpperCase(); | ||
let isDone; | ||
let rejected = false; | ||
let req; | ||
if (lookup) { | ||
const _lookup = callbackify(lookup, (value) => utils.isArray(value) ? value : [value]); | ||
// hotfix to support opt.all option which is required for node 20.x | ||
lookup = (hostname, opt, cb) => { | ||
_lookup(hostname, opt, (err, arg0, arg1) => { | ||
const addresses = utils.isArray(arg0) ? arg0.map(addr => buildAddressEntry(addr)) : [buildAddressEntry(arg0, arg1)]; | ||
opt.all ? cb(err, addresses) : cb(err, addresses[0].address, addresses[0].family); | ||
}); | ||
} | ||
} | ||
// temporary internal emitter until the AxiosRequest class will be implemented | ||
const emitter = new EventEmitter(); | ||
const onFinished = () => { | ||
if (config.cancelToken) { | ||
config.cancelToken.unsubscribe(onCanceled); | ||
config.cancelToken.unsubscribe(abort); | ||
} | ||
if (config.signal) { | ||
config.signal.removeEventListener('abort', onCanceled); | ||
config.signal.removeEventListener('abort', abort); | ||
} | ||
emitter.removeAllListeners(); | ||
} | ||
var resolve = function resolve(value) { | ||
done(); | ||
resolvePromise(value); | ||
}; | ||
var reject = function reject(value) { | ||
done(); | ||
rejectPromise(value); | ||
}; | ||
var data = config.data; | ||
var headers = config.headers; | ||
var headerNames = {}; | ||
Object.keys(headers).forEach(function storeLowerName(name) { | ||
headerNames[name.toLowerCase()] = name; | ||
onDone((value, isRejected) => { | ||
isDone = true; | ||
if (isRejected) { | ||
rejected = true; | ||
onFinished(); | ||
} | ||
}); | ||
function abort(reason) { | ||
emitter.emit('abort', !reason || reason.type ? new CanceledError(null, config, req) : reason); | ||
} | ||
emitter.once('abort', reject); | ||
if (config.cancelToken || config.signal) { | ||
config.cancelToken && config.cancelToken.subscribe(abort); | ||
if (config.signal) { | ||
config.signal.aborted ? abort() : config.signal.addEventListener('abort', abort); | ||
} | ||
} | ||
// Parse url | ||
const fullPath = buildFullPath(config.baseURL, config.url); | ||
const parsed = new URL(fullPath, 'http://localhost'); | ||
const protocol = parsed.protocol || supportedProtocols[0]; | ||
if (protocol === 'data:') { | ||
let convertedData; | ||
if (method !== 'GET') { | ||
return settle(resolve, reject, { | ||
status: 405, | ||
statusText: 'method not allowed', | ||
headers: {}, | ||
config | ||
}); | ||
} | ||
try { | ||
convertedData = fromDataURI(config.url, responseType === 'blob', { | ||
Blob: config.env && config.env.Blob | ||
}); | ||
} catch (err) { | ||
throw AxiosError.from(err, AxiosError.ERR_BAD_REQUEST, config); | ||
} | ||
if (responseType === 'text') { | ||
convertedData = convertedData.toString(responseEncoding); | ||
if (!responseEncoding || responseEncoding === 'utf8') { | ||
convertedData = utils.stripBOM(convertedData); | ||
} | ||
} else if (responseType === 'stream') { | ||
convertedData = stream.Readable.from(convertedData); | ||
} | ||
return settle(resolve, reject, { | ||
data: convertedData, | ||
status: 200, | ||
statusText: 'OK', | ||
headers: new AxiosHeaders(), | ||
config | ||
}); | ||
} | ||
if (supportedProtocols.indexOf(protocol) === -1) { | ||
return reject(new AxiosError( | ||
'Unsupported protocol ' + protocol, | ||
AxiosError.ERR_BAD_REQUEST, | ||
config | ||
)); | ||
} | ||
const headers = AxiosHeaders.from(config.headers).normalize(); | ||
// Set User-Agent (required by some servers) | ||
// See https://github.com/axios/axios/issues/69 | ||
if ('user-agent' in headerNames) { | ||
// User-Agent is specified; handle case where no UA header is desired | ||
if (!headers[headerNames['user-agent']]) { | ||
delete headers[headerNames['user-agent']]; | ||
// User-Agent is specified; handle case where no UA header is desired | ||
// Only set header if it hasn't been set in config | ||
headers.set('User-Agent', 'axios/' + VERSION, false); | ||
const onDownloadProgress = config.onDownloadProgress; | ||
const onUploadProgress = config.onUploadProgress; | ||
const maxRate = config.maxRate; | ||
let maxUploadRate = undefined; | ||
let maxDownloadRate = undefined; | ||
// support for spec compliant FormData objects | ||
if (utils.isSpecCompliantForm(data)) { | ||
const userBoundary = headers.getContentType(/boundary=([-_\w\d]{10,70})/i); | ||
data = formDataToStream(data, (formHeaders) => { | ||
headers.set(formHeaders); | ||
}, { | ||
tag: `axios-${VERSION}-boundary`, | ||
boundary: userBoundary && userBoundary[1] || undefined | ||
}); | ||
// support for https://www.npmjs.com/package/form-data api | ||
} else if (utils.isFormData(data) && utils.isFunction(data.getHeaders)) { | ||
headers.set(data.getHeaders()); | ||
if (!headers.hasContentLength()) { | ||
try { | ||
const knownLength = await util.promisify(data.getLength).call(data); | ||
Number.isFinite(knownLength) && knownLength >= 0 && headers.setContentLength(knownLength); | ||
/*eslint no-empty:0*/ | ||
} catch (e) { | ||
} | ||
} | ||
// Otherwise, use specified value | ||
} else { | ||
// Only set header if it hasn't been set in config | ||
headers['User-Agent'] = 'axios/' + VERSION; | ||
} | ||
if (data && !utils.isStream(data)) { | ||
} else if (utils.isBlob(data)) { | ||
data.size && headers.setContentType(data.type || 'application/octet-stream'); | ||
headers.setContentLength(data.size || 0); | ||
data = stream.Readable.from(readBlob(data)); | ||
} else if (data && !utils.isStream(data)) { | ||
if (Buffer.isBuffer(data)) { | ||
@@ -96,4 +317,5 @@ // Nothing to do... | ||
} else { | ||
return reject(createError( | ||
return reject(new AxiosError( | ||
'Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream', | ||
AxiosError.ERR_BAD_REQUEST, | ||
config | ||
@@ -104,43 +326,91 @@ )); | ||
// Add Content-Length header if data exists | ||
if (!headerNames['content-length']) { | ||
headers['Content-Length'] = data.length; | ||
headers.setContentLength(data.length, false); | ||
if (config.maxBodyLength > -1 && data.length > config.maxBodyLength) { | ||
return reject(new AxiosError( | ||
'Request body larger than maxBodyLength limit', | ||
AxiosError.ERR_BAD_REQUEST, | ||
config | ||
)); | ||
} | ||
} | ||
const contentLength = utils.toFiniteNumber(headers.getContentLength()); | ||
if (utils.isArray(maxRate)) { | ||
maxUploadRate = maxRate[0]; | ||
maxDownloadRate = maxRate[1]; | ||
} else { | ||
maxUploadRate = maxDownloadRate = maxRate; | ||
} | ||
if (data && (onUploadProgress || maxUploadRate)) { | ||
if (!utils.isStream(data)) { | ||
data = stream.Readable.from(data, {objectMode: false}); | ||
} | ||
data = stream.pipeline([data, new AxiosTransformStream({ | ||
length: contentLength, | ||
maxRate: utils.toFiniteNumber(maxUploadRate) | ||
})], utils.noop); | ||
onUploadProgress && data.on('progress', progress => { | ||
onUploadProgress(Object.assign(progress, { | ||
upload: true | ||
})); | ||
}); | ||
} | ||
// HTTP basic authentication | ||
var auth = undefined; | ||
let auth = undefined; | ||
if (config.auth) { | ||
var username = config.auth.username || ''; | ||
var password = config.auth.password || ''; | ||
const username = config.auth.username || ''; | ||
const password = config.auth.password || ''; | ||
auth = username + ':' + password; | ||
} | ||
// Parse url | ||
var fullPath = buildFullPath(config.baseURL, config.url); | ||
var parsed = url.parse(fullPath); | ||
var protocol = parsed.protocol || 'http:'; | ||
if (!auth && parsed.auth) { | ||
var urlAuth = parsed.auth.split(':'); | ||
var urlUsername = urlAuth[0] || ''; | ||
var urlPassword = urlAuth[1] || ''; | ||
if (!auth && parsed.username) { | ||
const urlUsername = parsed.username; | ||
const urlPassword = parsed.password; | ||
auth = urlUsername + ':' + urlPassword; | ||
} | ||
if (auth && headerNames.authorization) { | ||
delete headers[headerNames.authorization]; | ||
auth && headers.delete('authorization'); | ||
let path; | ||
try { | ||
path = buildURL( | ||
parsed.pathname + parsed.search, | ||
config.params, | ||
config.paramsSerializer | ||
).replace(/^\?/, ''); | ||
} catch (err) { | ||
const customErr = new Error(err.message); | ||
customErr.config = config; | ||
customErr.url = config.url; | ||
customErr.exists = true; | ||
return reject(customErr); | ||
} | ||
var isHttpsRequest = isHttps.test(protocol); | ||
var agent = isHttpsRequest ? config.httpsAgent : config.httpAgent; | ||
headers.set( | ||
'Accept-Encoding', | ||
'gzip, compress, deflate' + (isBrotliSupported ? ', br' : ''), false | ||
); | ||
var options = { | ||
path: buildURL(parsed.path, config.params, config.paramsSerializer).replace(/^\?/, ''), | ||
method: config.method.toUpperCase(), | ||
headers: headers, | ||
agent: agent, | ||
const options = { | ||
path, | ||
method: method, | ||
headers: headers.toJSON(), | ||
agents: { http: config.httpAgent, https: config.httpsAgent }, | ||
auth: auth | ||
auth, | ||
protocol, | ||
family, | ||
beforeRedirect: dispatchBeforeRedirect, | ||
beforeRedirects: {} | ||
}; | ||
// cacheable-lookup integration hotfix | ||
!utils.isUndefined(lookup) && (options.lookup = lookup); | ||
if (config.socketPath) { | ||
@@ -151,63 +421,12 @@ options.socketPath = config.socketPath; | ||
options.port = parsed.port; | ||
setProxy(options, config.proxy, protocol + '//' + parsed.hostname + (parsed.port ? ':' + parsed.port : '') + options.path); | ||
} | ||
var proxy = config.proxy; | ||
if (!proxy && proxy !== false) { | ||
var proxyEnv = protocol.slice(0, -1) + '_proxy'; | ||
var proxyUrl = process.env[proxyEnv] || process.env[proxyEnv.toUpperCase()]; | ||
if (proxyUrl) { | ||
var parsedProxyUrl = url.parse(proxyUrl); | ||
var noProxyEnv = process.env.no_proxy || process.env.NO_PROXY; | ||
var shouldProxy = true; | ||
if (noProxyEnv) { | ||
var noProxy = noProxyEnv.split(',').map(function trim(s) { | ||
return s.trim(); | ||
}); | ||
shouldProxy = !noProxy.some(function proxyMatch(proxyElement) { | ||
if (!proxyElement) { | ||
return false; | ||
} | ||
if (proxyElement === '*') { | ||
return true; | ||
} | ||
if (proxyElement[0] === '.' && | ||
parsed.hostname.substr(parsed.hostname.length - proxyElement.length) === proxyElement) { | ||
return true; | ||
} | ||
return parsed.hostname === proxyElement; | ||
}); | ||
} | ||
if (shouldProxy) { | ||
proxy = { | ||
host: parsedProxyUrl.hostname, | ||
port: parsedProxyUrl.port, | ||
protocol: parsedProxyUrl.protocol | ||
}; | ||
if (parsedProxyUrl.auth) { | ||
var proxyUrlAuth = parsedProxyUrl.auth.split(':'); | ||
proxy.auth = { | ||
username: proxyUrlAuth[0], | ||
password: proxyUrlAuth[1] | ||
}; | ||
} | ||
} | ||
} | ||
} | ||
if (proxy) { | ||
options.headers.host = parsed.hostname + (parsed.port ? ':' + parsed.port : ''); | ||
setProxy(options, proxy, protocol + '//' + parsed.hostname + (parsed.port ? ':' + parsed.port : '') + options.path); | ||
} | ||
var transport; | ||
var isHttpsProxy = isHttpsRequest && (proxy ? isHttps.test(proxy.protocol) : true); | ||
let transport; | ||
const isHttpsRequest = isHttps.test(options.protocol); | ||
options.agent = isHttpsRequest ? config.httpsAgent : config.httpAgent; | ||
if (config.transport) { | ||
transport = config.transport; | ||
} else if (config.maxRedirects === 0) { | ||
transport = isHttpsProxy ? https : http; | ||
transport = isHttpsRequest ? https : http; | ||
} else { | ||
@@ -217,3 +436,6 @@ if (config.maxRedirects) { | ||
} | ||
transport = isHttpsProxy ? httpsFollow : httpFollow; | ||
if (config.beforeRedirect) { | ||
options.beforeRedirects.config = config.beforeRedirect; | ||
} | ||
transport = isHttpsRequest ? httpsFollow : httpFollow; | ||
} | ||
@@ -223,2 +445,5 @@ | ||
options.maxBodyLength = config.maxBodyLength; | ||
} else { | ||
// follow-redirects does not skip comparison, so it should always succeed for axios -1 unlimited | ||
options.maxBodyLength = Infinity; | ||
} | ||
@@ -231,43 +456,90 @@ | ||
// Create the request | ||
var req = transport.request(options, function handleResponse(res) { | ||
if (req.aborted) return; | ||
req = transport.request(options, function handleResponse(res) { | ||
if (req.destroyed) return; | ||
// uncompress the response body transparently if required | ||
var stream = res; | ||
const streams = [res]; | ||
const responseLength = +res.headers['content-length']; | ||
if (onDownloadProgress) { | ||
const transformStream = new AxiosTransformStream({ | ||
length: utils.toFiniteNumber(responseLength), | ||
maxRate: utils.toFiniteNumber(maxDownloadRate) | ||
}); | ||
onDownloadProgress && transformStream.on('progress', progress => { | ||
onDownloadProgress(Object.assign(progress, { | ||
download: true | ||
})); | ||
}); | ||
streams.push(transformStream); | ||
} | ||
// decompress the response body transparently if required | ||
let responseStream = res; | ||
// return the last request in case of redirects | ||
var lastRequest = res.req || req; | ||
const lastRequest = res.req || req; | ||
// if decompress disabled we should not decompress | ||
if (config.decompress !== false && res.headers['content-encoding']) { | ||
// if no content, but headers still say that it is encoded, | ||
// remove the header not confuse downstream operations | ||
if (method === 'HEAD' || res.statusCode === 204) { | ||
delete res.headers['content-encoding']; | ||
} | ||
// if no content, is HEAD request or decompress disabled we should not decompress | ||
if (res.statusCode !== 204 && lastRequest.method !== 'HEAD' && config.decompress !== false) { | ||
switch (res.headers['content-encoding']) { | ||
switch ((res.headers['content-encoding'] || '').toLowerCase()) { | ||
/*eslint default-case:0*/ | ||
case 'gzip': | ||
case 'x-gzip': | ||
case 'compress': | ||
case 'x-compress': | ||
// add the unzipper to the body stream processing pipeline | ||
streams.push(zlib.createUnzip(zlibOptions)); | ||
// remove the content-encoding in order to not confuse downstream operations | ||
delete res.headers['content-encoding']; | ||
break; | ||
case 'deflate': | ||
// add the unzipper to the body stream processing pipeline | ||
stream = stream.pipe(zlib.createUnzip()); | ||
streams.push(new ZlibHeaderTransformStream()); | ||
// add the unzipper to the body stream processing pipeline | ||
streams.push(zlib.createUnzip(zlibOptions)); | ||
// remove the content-encoding in order to not confuse downstream operations | ||
delete res.headers['content-encoding']; | ||
break; | ||
case 'br': | ||
if (isBrotliSupported) { | ||
streams.push(zlib.createBrotliDecompress(brotliOptions)); | ||
delete res.headers['content-encoding']; | ||
} | ||
} | ||
} | ||
var response = { | ||
responseStream = streams.length > 1 ? stream.pipeline(streams, utils.noop) : streams[0]; | ||
const offListeners = stream.finished(responseStream, () => { | ||
offListeners(); | ||
onFinished(); | ||
}); | ||
const response = { | ||
status: res.statusCode, | ||
statusText: res.statusMessage, | ||
headers: res.headers, | ||
config: config, | ||
headers: new AxiosHeaders(res.headers), | ||
config, | ||
request: lastRequest | ||
}; | ||
if (config.responseType === 'stream') { | ||
response.data = stream; | ||
if (responseType === 'stream') { | ||
response.data = responseStream; | ||
settle(resolve, reject, response); | ||
} else { | ||
var responseBuffer = []; | ||
var totalResponseBytes = 0; | ||
stream.on('data', function handleStreamData(chunk) { | ||
const responseBuffer = []; | ||
let totalResponseBytes = 0; | ||
responseStream.on('data', function handleStreamData(chunk) { | ||
responseBuffer.push(chunk); | ||
@@ -278,44 +550,83 @@ totalResponseBytes += chunk.length; | ||
if (config.maxContentLength > -1 && totalResponseBytes > config.maxContentLength) { | ||
stream.destroy(); | ||
reject(createError('maxContentLength size of ' + config.maxContentLength + ' exceeded', | ||
config, null, lastRequest)); | ||
// stream.destroy() emit aborted event before calling reject() on Node.js v16 | ||
rejected = true; | ||
responseStream.destroy(); | ||
reject(new AxiosError('maxContentLength size of ' + config.maxContentLength + ' exceeded', | ||
AxiosError.ERR_BAD_RESPONSE, config, lastRequest)); | ||
} | ||
}); | ||
stream.on('error', function handleStreamError(err) { | ||
if (req.aborted) return; | ||
reject(enhanceError(err, config, null, lastRequest)); | ||
responseStream.on('aborted', function handlerStreamAborted() { | ||
if (rejected) { | ||
return; | ||
} | ||
const err = new AxiosError( | ||
'maxContentLength size of ' + config.maxContentLength + ' exceeded', | ||
AxiosError.ERR_BAD_RESPONSE, | ||
config, | ||
lastRequest | ||
); | ||
responseStream.destroy(err); | ||
reject(err); | ||
}); | ||
stream.on('end', function handleStreamEnd() { | ||
var responseData = Buffer.concat(responseBuffer); | ||
if (config.responseType !== 'arraybuffer') { | ||
responseData = responseData.toString(config.responseEncoding); | ||
if (!config.responseEncoding || config.responseEncoding === 'utf8') { | ||
responseData = utils.stripBOM(responseData); | ||
responseStream.on('error', function handleStreamError(err) { | ||
if (req.destroyed) return; | ||
reject(AxiosError.from(err, null, config, lastRequest)); | ||
}); | ||
responseStream.on('end', function handleStreamEnd() { | ||
try { | ||
let responseData = responseBuffer.length === 1 ? responseBuffer[0] : Buffer.concat(responseBuffer); | ||
if (responseType !== 'arraybuffer') { | ||
responseData = responseData.toString(responseEncoding); | ||
if (!responseEncoding || responseEncoding === 'utf8') { | ||
responseData = utils.stripBOM(responseData); | ||
} | ||
} | ||
response.data = responseData; | ||
} catch (err) { | ||
return reject(AxiosError.from(err, null, config, response.request, response)); | ||
} | ||
response.data = responseData; | ||
settle(resolve, reject, response); | ||
}); | ||
} | ||
emitter.once('abort', err => { | ||
if (!responseStream.destroyed) { | ||
responseStream.emit('error', err); | ||
responseStream.destroy(); | ||
} | ||
}); | ||
}); | ||
emitter.once('abort', err => { | ||
reject(err); | ||
req.destroy(err); | ||
}); | ||
// Handle errors | ||
req.on('error', function handleRequestError(err) { | ||
if (req.aborted && err.code !== 'ERR_FR_TOO_MANY_REDIRECTS') return; | ||
reject(enhanceError(err, config, null, req)); | ||
// @todo remove | ||
// if (req.aborted && err.code !== AxiosError.ERR_FR_TOO_MANY_REDIRECTS) return; | ||
reject(AxiosError.from(err, null, config, req)); | ||
}); | ||
// set tcp keep alive to prevent drop connection by peer | ||
req.on('socket', function handleRequestSocket(socket) { | ||
// default interval of sending ack packet is 1 minute | ||
socket.setKeepAlive(true, 1000 * 60); | ||
}); | ||
// Handle request timeout | ||
if (config.timeout) { | ||
// This is forcing a int timeout to avoid problems if the `req` interface doesn't handle other types. | ||
var timeout = parseInt(config.timeout, 10); | ||
const timeout = parseInt(config.timeout, 10); | ||
if (isNaN(timeout)) { | ||
reject(createError( | ||
if (Number.isNaN(timeout)) { | ||
reject(new AxiosError( | ||
'error trying to parse `config.timeout` to int', | ||
AxiosError.ERR_BAD_OPTION_VALUE, | ||
config, | ||
'ERR_PARSE_TIMEOUT', | ||
req | ||
@@ -330,38 +641,43 @@ )); | ||
// 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. | ||
// And then these socket which be hang up will devoring CPU little by little. | ||
// And then these socket which be hang up will devouring CPU little by little. | ||
// ClientRequest.setTimeout will be fired on the specify milliseconds, and can make sure that abort() will be fired after connect. | ||
req.setTimeout(timeout, function handleRequestTimeout() { | ||
req.abort(); | ||
var transitional = config.transitional || defaults.transitional; | ||
reject(createError( | ||
'timeout of ' + timeout + 'ms exceeded', | ||
if (isDone) return; | ||
let timeoutErrorMessage = config.timeout ? 'timeout of ' + config.timeout + 'ms exceeded' : 'timeout exceeded'; | ||
const transitional = config.transitional || transitionalDefaults; | ||
if (config.timeoutErrorMessage) { | ||
timeoutErrorMessage = config.timeoutErrorMessage; | ||
} | ||
reject(new AxiosError( | ||
timeoutErrorMessage, | ||
transitional.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED, | ||
config, | ||
transitional.clarifyTimeoutError ? 'ETIMEDOUT' : 'ECONNABORTED', | ||
req | ||
)); | ||
abort(); | ||
}); | ||
} | ||
if (config.cancelToken || config.signal) { | ||
// Handle cancellation | ||
// eslint-disable-next-line func-names | ||
onCanceled = function(cancel) { | ||
if (req.aborted) return; | ||
req.abort(); | ||
reject(!cancel || (cancel && cancel.type) ? new Cancel('canceled') : cancel); | ||
}; | ||
// Send the request | ||
if (utils.isStream(data)) { | ||
let ended = false; | ||
let errored = false; | ||
config.cancelToken && config.cancelToken.subscribe(onCanceled); | ||
if (config.signal) { | ||
config.signal.aborted ? onCanceled() : config.signal.addEventListener('abort', onCanceled); | ||
} | ||
} | ||
data.on('end', () => { | ||
ended = true; | ||
}); | ||
data.once('error', err => { | ||
errored = true; | ||
req.destroy(err); | ||
}); | ||
// Send the request | ||
if (utils.isStream(data)) { | ||
data.on('error', function handleStreamError(err) { | ||
reject(enhanceError(err, config, null, req)); | ||
}).pipe(req); | ||
data.on('close', () => { | ||
if (!ended && !errored) { | ||
abort(new CanceledError('Request stream has been aborted', config, req)); | ||
} | ||
}); | ||
data.pipe(req); | ||
} else { | ||
@@ -371,2 +687,4 @@ req.end(data); | ||
}); | ||
}; | ||
} | ||
export const __setProxy = setProxy; |
'use strict'; | ||
var utils = require('./../utils'); | ||
var settle = require('./../core/settle'); | ||
var cookies = require('./../helpers/cookies'); | ||
var buildURL = require('./../helpers/buildURL'); | ||
var buildFullPath = require('../core/buildFullPath'); | ||
var parseHeaders = require('./../helpers/parseHeaders'); | ||
var isURLSameOrigin = require('./../helpers/isURLSameOrigin'); | ||
var createError = require('../core/createError'); | ||
var defaults = require('../defaults'); | ||
var Cancel = require('../cancel/Cancel'); | ||
import utils from './../utils.js'; | ||
import settle from './../core/settle.js'; | ||
import cookies from './../helpers/cookies.js'; | ||
import buildURL from './../helpers/buildURL.js'; | ||
import buildFullPath from '../core/buildFullPath.js'; | ||
import isURLSameOrigin from './../helpers/isURLSameOrigin.js'; | ||
import transitionalDefaults from '../defaults/transitional.js'; | ||
import AxiosError from '../core/AxiosError.js'; | ||
import CanceledError from '../cancel/CanceledError.js'; | ||
import parseProtocol from '../helpers/parseProtocol.js'; | ||
import platform from '../platform/index.js'; | ||
import AxiosHeaders from '../core/AxiosHeaders.js'; | ||
import speedometer from '../helpers/speedometer.js'; | ||
module.exports = function xhrAdapter(config) { | ||
function progressEventReducer(listener, isDownloadStream) { | ||
let bytesNotified = 0; | ||
const _speedometer = speedometer(50, 250); | ||
return e => { | ||
const loaded = e.loaded; | ||
const total = e.lengthComputable ? e.total : undefined; | ||
const progressBytes = loaded - bytesNotified; | ||
const rate = _speedometer(progressBytes); | ||
const inRange = loaded <= total; | ||
bytesNotified = loaded; | ||
const data = { | ||
loaded, | ||
total, | ||
progress: total ? (loaded / total) : undefined, | ||
bytes: progressBytes, | ||
rate: rate ? rate : undefined, | ||
estimated: rate && total && inRange ? (total - loaded) / rate : undefined, | ||
event: e | ||
}; | ||
data[isDownloadStream ? 'download' : 'upload'] = true; | ||
listener(data); | ||
}; | ||
} | ||
const isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined'; | ||
export default isXHRAdapterSupported && function (config) { | ||
return new Promise(function dispatchXhrRequest(resolve, reject) { | ||
var requestData = config.data; | ||
var requestHeaders = config.headers; | ||
var responseType = config.responseType; | ||
var onCanceled; | ||
let requestData = config.data; | ||
const requestHeaders = AxiosHeaders.from(config.headers).normalize(); | ||
const responseType = config.responseType; | ||
let onCanceled; | ||
function done() { | ||
@@ -30,16 +64,25 @@ if (config.cancelToken) { | ||
let contentType; | ||
if (utils.isFormData(requestData)) { | ||
delete requestHeaders['Content-Type']; // Let the browser set it | ||
if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv) { | ||
requestHeaders.setContentType(false); // Let the browser set it | ||
} else if ((contentType = requestHeaders.getContentType()) !== false) { | ||
// fix semicolon duplication issue for ReactNative FormData implementation | ||
const [type, ...tokens] = contentType ? contentType.split(';').map(token => token.trim()).filter(Boolean) : []; | ||
requestHeaders.setContentType([type || 'multipart/form-data', ...tokens].join('; ')); | ||
} | ||
} | ||
var request = new XMLHttpRequest(); | ||
let request = new XMLHttpRequest(); | ||
// HTTP basic authentication | ||
if (config.auth) { | ||
var username = config.auth.username || ''; | ||
var password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : ''; | ||
requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password); | ||
const username = config.auth.username || ''; | ||
const password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : ''; | ||
requestHeaders.set('Authorization', 'Basic ' + btoa(username + ':' + password)); | ||
} | ||
var fullPath = buildFullPath(config.baseURL, config.url); | ||
const fullPath = buildFullPath(config.baseURL, config.url); | ||
request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true); | ||
@@ -55,6 +98,8 @@ | ||
// Prepare the response | ||
var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null; | ||
var responseData = !responseType || responseType === 'text' || responseType === 'json' ? | ||
const responseHeaders = AxiosHeaders.from( | ||
'getAllResponseHeaders' in request && request.getAllResponseHeaders() | ||
); | ||
const responseData = !responseType || responseType === 'text' || responseType === 'json' ? | ||
request.responseText : request.response; | ||
var response = { | ||
const response = { | ||
data: responseData, | ||
@@ -64,4 +109,4 @@ status: request.status, | ||
headers: responseHeaders, | ||
config: config, | ||
request: request | ||
config, | ||
request | ||
}; | ||
@@ -110,3 +155,3 @@ | ||
reject(createError('Request aborted', config, 'ECONNABORTED', request)); | ||
reject(new AxiosError('Request aborted', AxiosError.ECONNABORTED, config, request)); | ||
@@ -121,3 +166,3 @@ // Clean up request | ||
// onerror should only fire if it's a network error | ||
reject(createError('Network Error', config, null, request)); | ||
reject(new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request)); | ||
@@ -130,11 +175,11 @@ // Clean up request | ||
request.ontimeout = function handleTimeout() { | ||
var timeoutErrorMessage = 'timeout of ' + config.timeout + 'ms exceeded'; | ||
var transitional = config.transitional || defaults.transitional; | ||
let timeoutErrorMessage = config.timeout ? 'timeout of ' + config.timeout + 'ms exceeded' : 'timeout exceeded'; | ||
const transitional = config.transitional || transitionalDefaults; | ||
if (config.timeoutErrorMessage) { | ||
timeoutErrorMessage = config.timeoutErrorMessage; | ||
} | ||
reject(createError( | ||
reject(new AxiosError( | ||
timeoutErrorMessage, | ||
transitional.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED, | ||
config, | ||
transitional.clarifyTimeoutError ? 'ETIMEDOUT' : 'ECONNABORTED', | ||
request)); | ||
@@ -149,23 +194,19 @@ | ||
// Specifically not if we're in a web worker, or react-native. | ||
if (utils.isStandardBrowserEnv()) { | ||
if (platform.hasStandardBrowserEnv) { | ||
// Add xsrf header | ||
var xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName ? | ||
cookies.read(config.xsrfCookieName) : | ||
undefined; | ||
// regarding CVE-2023-45857 config.withCredentials condition was removed temporarily | ||
const xsrfValue = isURLSameOrigin(fullPath) && config.xsrfCookieName && cookies.read(config.xsrfCookieName); | ||
if (xsrfValue) { | ||
requestHeaders[config.xsrfHeaderName] = xsrfValue; | ||
requestHeaders.set(config.xsrfHeaderName, xsrfValue); | ||
} | ||
} | ||
// Remove Content-Type if data is undefined | ||
requestData === undefined && requestHeaders.setContentType(null); | ||
// Add headers to the request | ||
if ('setRequestHeader' in request) { | ||
utils.forEach(requestHeaders, function setRequestHeader(val, key) { | ||
if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') { | ||
// Remove Content-Type if data is undefined | ||
delete requestHeaders[key]; | ||
} else { | ||
// Otherwise add header to the request | ||
request.setRequestHeader(key, val); | ||
} | ||
utils.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) { | ||
request.setRequestHeader(key, val); | ||
}); | ||
@@ -186,3 +227,3 @@ } | ||
if (typeof config.onDownloadProgress === 'function') { | ||
request.addEventListener('progress', config.onDownloadProgress); | ||
request.addEventListener('progress', progressEventReducer(config.onDownloadProgress, true)); | ||
} | ||
@@ -192,3 +233,3 @@ | ||
if (typeof config.onUploadProgress === 'function' && request.upload) { | ||
request.upload.addEventListener('progress', config.onUploadProgress); | ||
request.upload.addEventListener('progress', progressEventReducer(config.onUploadProgress)); | ||
} | ||
@@ -199,7 +240,7 @@ | ||
// eslint-disable-next-line func-names | ||
onCanceled = function(cancel) { | ||
onCanceled = cancel => { | ||
if (!request) { | ||
return; | ||
} | ||
reject(!cancel || (cancel && cancel.type) ? new Cancel('canceled') : cancel); | ||
reject(!cancel || cancel.type ? new CanceledError(null, config, request) : cancel); | ||
request.abort(); | ||
@@ -215,9 +256,13 @@ request = null; | ||
if (!requestData) { | ||
requestData = null; | ||
const protocol = parseProtocol(fullPath); | ||
if (protocol && platform.protocols.indexOf(protocol) === -1) { | ||
reject(new AxiosError('Unsupported protocol ' + protocol + ':', AxiosError.ERR_BAD_REQUEST, config)); | ||
return; | ||
} | ||
// Send the request | ||
request.send(requestData); | ||
request.send(requestData || null); | ||
}); | ||
}; | ||
} |
'use strict'; | ||
var utils = require('./utils'); | ||
var bind = require('./helpers/bind'); | ||
var Axios = require('./core/Axios'); | ||
var mergeConfig = require('./core/mergeConfig'); | ||
var defaults = require('./defaults'); | ||
import utils from './utils.js'; | ||
import bind from './helpers/bind.js'; | ||
import Axios from './core/Axios.js'; | ||
import mergeConfig from './core/mergeConfig.js'; | ||
import defaults from './defaults/index.js'; | ||
import formDataToJSON from './helpers/formDataToJSON.js'; | ||
import CanceledError from './cancel/CanceledError.js'; | ||
import CancelToken from './cancel/CancelToken.js'; | ||
import isCancel from './cancel/isCancel.js'; | ||
import {VERSION} from './env/data.js'; | ||
import toFormData from './helpers/toFormData.js'; | ||
import AxiosError from './core/AxiosError.js'; | ||
import spread from './helpers/spread.js'; | ||
import isAxiosError from './helpers/isAxiosError.js'; | ||
import AxiosHeaders from "./core/AxiosHeaders.js"; | ||
import adapters from './adapters/adapters.js'; | ||
import HttpStatusCode from './helpers/HttpStatusCode.js'; | ||
@@ -13,13 +25,14 @@ /** | ||
* @param {Object} defaultConfig The default config for the instance | ||
* @return {Axios} A new instance of Axios | ||
* | ||
* @returns {Axios} A new instance of Axios | ||
*/ | ||
function createInstance(defaultConfig) { | ||
var context = new Axios(defaultConfig); | ||
var instance = bind(Axios.prototype.request, context); | ||
const context = new Axios(defaultConfig); | ||
const instance = bind(Axios.prototype.request, context); | ||
// Copy axios.prototype to instance | ||
utils.extend(instance, Axios.prototype, context); | ||
utils.extend(instance, Axios.prototype, context, {allOwnKeys: true}); | ||
// Copy context to instance | ||
utils.extend(instance, context); | ||
utils.extend(instance, context, null, {allOwnKeys: true}); | ||
@@ -35,3 +48,3 @@ // Factory for creating new instances | ||
// Create the default instance to be exported | ||
var axios = createInstance(defaults); | ||
const axios = createInstance(defaults); | ||
@@ -42,7 +55,14 @@ // Expose Axios class to allow class inheritance | ||
// Expose Cancel & CancelToken | ||
axios.Cancel = require('./cancel/Cancel'); | ||
axios.CancelToken = require('./cancel/CancelToken'); | ||
axios.isCancel = require('./cancel/isCancel'); | ||
axios.VERSION = require('./env/data').version; | ||
axios.CanceledError = CanceledError; | ||
axios.CancelToken = CancelToken; | ||
axios.isCancel = isCancel; | ||
axios.VERSION = VERSION; | ||
axios.toFormData = toFormData; | ||
// Expose AxiosError class | ||
axios.AxiosError = AxiosError; | ||
// alias for CanceledError for backward compatibility | ||
axios.Cancel = axios.CanceledError; | ||
// Expose all/spread | ||
@@ -52,10 +72,22 @@ axios.all = function all(promises) { | ||
}; | ||
axios.spread = require('./helpers/spread'); | ||
axios.spread = spread; | ||
// Expose isAxiosError | ||
axios.isAxiosError = require('./helpers/isAxiosError'); | ||
axios.isAxiosError = isAxiosError; | ||
module.exports = axios; | ||
// Expose mergeConfig | ||
axios.mergeConfig = mergeConfig; | ||
// Allow use of default import syntax in TypeScript | ||
module.exports.default = axios; | ||
axios.AxiosHeaders = AxiosHeaders; | ||
axios.formToJSON = thing => formDataToJSON(utils.isHTMLForm(thing) ? new FormData(thing) : thing); | ||
axios.getAdapter = adapters.getAdapter; | ||
axios.HttpStatusCode = HttpStatusCode; | ||
axios.default = axios; | ||
// this module should only have a default export | ||
export default axios |
'use strict'; | ||
var Cancel = require('./Cancel'); | ||
import CanceledError from './CanceledError.js'; | ||
@@ -8,113 +8,115 @@ /** | ||
* | ||
* @class | ||
* @param {Function} executor The executor function. | ||
* | ||
* @returns {CancelToken} | ||
*/ | ||
function CancelToken(executor) { | ||
if (typeof executor !== 'function') { | ||
throw new TypeError('executor must be a function.'); | ||
} | ||
class CancelToken { | ||
constructor(executor) { | ||
if (typeof executor !== 'function') { | ||
throw new TypeError('executor must be a function.'); | ||
} | ||
var resolvePromise; | ||
let resolvePromise; | ||
this.promise = new Promise(function promiseExecutor(resolve) { | ||
resolvePromise = resolve; | ||
}); | ||
this.promise = new Promise(function promiseExecutor(resolve) { | ||
resolvePromise = resolve; | ||
}); | ||
var token = this; | ||
const token = this; | ||
// eslint-disable-next-line func-names | ||
this.promise.then(function(cancel) { | ||
if (!token._listeners) return; | ||
// eslint-disable-next-line func-names | ||
this.promise.then(cancel => { | ||
if (!token._listeners) return; | ||
var i; | ||
var l = token._listeners.length; | ||
let i = token._listeners.length; | ||
for (i = 0; i < l; i++) { | ||
token._listeners[i](cancel); | ||
} | ||
token._listeners = null; | ||
}); | ||
while (i-- > 0) { | ||
token._listeners[i](cancel); | ||
} | ||
token._listeners = null; | ||
}); | ||
// eslint-disable-next-line func-names | ||
this.promise.then = function(onfulfilled) { | ||
var _resolve; | ||
// eslint-disable-next-line func-names | ||
var promise = new Promise(function(resolve) { | ||
token.subscribe(resolve); | ||
_resolve = resolve; | ||
}).then(onfulfilled); | ||
this.promise.then = onfulfilled => { | ||
let _resolve; | ||
// eslint-disable-next-line func-names | ||
const promise = new Promise(resolve => { | ||
token.subscribe(resolve); | ||
_resolve = resolve; | ||
}).then(onfulfilled); | ||
promise.cancel = function reject() { | ||
token.unsubscribe(_resolve); | ||
promise.cancel = function reject() { | ||
token.unsubscribe(_resolve); | ||
}; | ||
return promise; | ||
}; | ||
return promise; | ||
}; | ||
executor(function cancel(message, config, request) { | ||
if (token.reason) { | ||
// Cancellation has already been requested | ||
return; | ||
} | ||
executor(function cancel(message) { | ||
if (token.reason) { | ||
// Cancellation has already been requested | ||
return; | ||
token.reason = new CanceledError(message, config, request); | ||
resolvePromise(token.reason); | ||
}); | ||
} | ||
/** | ||
* Throws a `CanceledError` if cancellation has been requested. | ||
*/ | ||
throwIfRequested() { | ||
if (this.reason) { | ||
throw this.reason; | ||
} | ||
token.reason = new Cancel(message); | ||
resolvePromise(token.reason); | ||
}); | ||
} | ||
/** | ||
* Throws a `Cancel` if cancellation has been requested. | ||
*/ | ||
CancelToken.prototype.throwIfRequested = function throwIfRequested() { | ||
if (this.reason) { | ||
throw this.reason; | ||
} | ||
}; | ||
/** | ||
* Subscribe to the cancel signal | ||
*/ | ||
/** | ||
* Subscribe to the cancel signal | ||
*/ | ||
CancelToken.prototype.subscribe = function subscribe(listener) { | ||
if (this.reason) { | ||
listener(this.reason); | ||
return; | ||
} | ||
subscribe(listener) { | ||
if (this.reason) { | ||
listener(this.reason); | ||
return; | ||
} | ||
if (this._listeners) { | ||
this._listeners.push(listener); | ||
} else { | ||
this._listeners = [listener]; | ||
if (this._listeners) { | ||
this._listeners.push(listener); | ||
} else { | ||
this._listeners = [listener]; | ||
} | ||
} | ||
}; | ||
/** | ||
* Unsubscribe from the cancel signal | ||
*/ | ||
/** | ||
* Unsubscribe from the cancel signal | ||
*/ | ||
CancelToken.prototype.unsubscribe = function unsubscribe(listener) { | ||
if (!this._listeners) { | ||
return; | ||
unsubscribe(listener) { | ||
if (!this._listeners) { | ||
return; | ||
} | ||
const index = this._listeners.indexOf(listener); | ||
if (index !== -1) { | ||
this._listeners.splice(index, 1); | ||
} | ||
} | ||
var index = this._listeners.indexOf(listener); | ||
if (index !== -1) { | ||
this._listeners.splice(index, 1); | ||
/** | ||
* Returns an object that contains a new `CancelToken` and a function that, when called, | ||
* cancels the `CancelToken`. | ||
*/ | ||
static source() { | ||
let cancel; | ||
const token = new CancelToken(function executor(c) { | ||
cancel = c; | ||
}); | ||
return { | ||
token, | ||
cancel | ||
}; | ||
} | ||
}; | ||
} | ||
/** | ||
* Returns an object that contains a new `CancelToken` and a function that, when called, | ||
* cancels the `CancelToken`. | ||
*/ | ||
CancelToken.source = function source() { | ||
var cancel; | ||
var token = new CancelToken(function executor(c) { | ||
cancel = c; | ||
}); | ||
return { | ||
token: token, | ||
cancel: cancel | ||
}; | ||
}; | ||
module.exports = CancelToken; | ||
export default CancelToken; |
'use strict'; | ||
module.exports = function isCancel(value) { | ||
export default function isCancel(value) { | ||
return !!(value && value.__CANCEL__); | ||
}; | ||
} |
'use strict'; | ||
var utils = require('./../utils'); | ||
var buildURL = require('../helpers/buildURL'); | ||
var InterceptorManager = require('./InterceptorManager'); | ||
var dispatchRequest = require('./dispatchRequest'); | ||
var mergeConfig = require('./mergeConfig'); | ||
var validator = require('../helpers/validator'); | ||
import utils from './../utils.js'; | ||
import buildURL from '../helpers/buildURL.js'; | ||
import InterceptorManager from './InterceptorManager.js'; | ||
import dispatchRequest from './dispatchRequest.js'; | ||
import mergeConfig from './mergeConfig.js'; | ||
import buildFullPath from './buildFullPath.js'; | ||
import validator from '../helpers/validator.js'; | ||
import AxiosHeaders from './AxiosHeaders.js'; | ||
var validators = validator.validators; | ||
const validators = validator.validators; | ||
/** | ||
@@ -15,112 +18,152 @@ * Create a new instance of Axios | ||
* @param {Object} instanceConfig The default config for the instance | ||
*/ | ||
function Axios(instanceConfig) { | ||
this.defaults = instanceConfig; | ||
this.interceptors = { | ||
request: new InterceptorManager(), | ||
response: new InterceptorManager() | ||
}; | ||
} | ||
/** | ||
* Dispatch a request | ||
* | ||
* @param {Object} config The config specific for this request (merged with this.defaults) | ||
* @return {Axios} A new instance of Axios | ||
*/ | ||
Axios.prototype.request = function request(config) { | ||
/*eslint no-param-reassign:0*/ | ||
// Allow for axios('example/url'[, config]) a la fetch API | ||
if (typeof config === 'string') { | ||
config = arguments[1] || {}; | ||
config.url = arguments[0]; | ||
} else { | ||
config = config || {}; | ||
class Axios { | ||
constructor(instanceConfig) { | ||
this.defaults = instanceConfig; | ||
this.interceptors = { | ||
request: new InterceptorManager(), | ||
response: new InterceptorManager() | ||
}; | ||
} | ||
config = mergeConfig(this.defaults, config); | ||
/** | ||
* Dispatch a request | ||
* | ||
* @param {String|Object} configOrUrl The config specific for this request (merged with this.defaults) | ||
* @param {?Object} config | ||
* | ||
* @returns {Promise} The Promise to be fulfilled | ||
*/ | ||
request(configOrUrl, config) { | ||
/*eslint no-param-reassign:0*/ | ||
// Allow for axios('example/url'[, config]) a la fetch API | ||
if (typeof configOrUrl === 'string') { | ||
config = config || {}; | ||
config.url = configOrUrl; | ||
} else { | ||
config = configOrUrl || {}; | ||
} | ||
// Set config.method | ||
if (config.method) { | ||
config.method = config.method.toLowerCase(); | ||
} else if (this.defaults.method) { | ||
config.method = this.defaults.method.toLowerCase(); | ||
} else { | ||
config.method = 'get'; | ||
} | ||
config = mergeConfig(this.defaults, config); | ||
var transitional = config.transitional; | ||
const {transitional, paramsSerializer, headers} = config; | ||
if (transitional !== undefined) { | ||
validator.assertOptions(transitional, { | ||
silentJSONParsing: validators.transitional(validators.boolean), | ||
forcedJSONParsing: validators.transitional(validators.boolean), | ||
clarifyTimeoutError: validators.transitional(validators.boolean) | ||
}, false); | ||
} | ||
if (transitional !== undefined) { | ||
validator.assertOptions(transitional, { | ||
silentJSONParsing: validators.transitional(validators.boolean), | ||
forcedJSONParsing: validators.transitional(validators.boolean), | ||
clarifyTimeoutError: validators.transitional(validators.boolean) | ||
}, false); | ||
} | ||
// filter out skipped interceptors | ||
var requestInterceptorChain = []; | ||
var synchronousRequestInterceptors = true; | ||
this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) { | ||
if (typeof interceptor.runWhen === 'function' && interceptor.runWhen(config) === false) { | ||
return; | ||
if (paramsSerializer != null) { | ||
if (utils.isFunction(paramsSerializer)) { | ||
config.paramsSerializer = { | ||
serialize: paramsSerializer | ||
} | ||
} else { | ||
validator.assertOptions(paramsSerializer, { | ||
encode: validators.function, | ||
serialize: validators.function | ||
}, true); | ||
} | ||
} | ||
synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous; | ||
// Set config.method | ||
config.method = (config.method || this.defaults.method || 'get').toLowerCase(); | ||
requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected); | ||
}); | ||
// Flatten headers | ||
let contextHeaders = headers && utils.merge( | ||
headers.common, | ||
headers[config.method] | ||
); | ||
var responseInterceptorChain = []; | ||
this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) { | ||
responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected); | ||
}); | ||
headers && utils.forEach( | ||
['delete', 'get', 'head', 'post', 'put', 'patch', 'common'], | ||
(method) => { | ||
delete headers[method]; | ||
} | ||
); | ||
var promise; | ||
config.headers = AxiosHeaders.concat(contextHeaders, headers); | ||
if (!synchronousRequestInterceptors) { | ||
var chain = [dispatchRequest, undefined]; | ||
// filter out skipped interceptors | ||
const requestInterceptorChain = []; | ||
let synchronousRequestInterceptors = true; | ||
this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) { | ||
if (typeof interceptor.runWhen === 'function' && interceptor.runWhen(config) === false) { | ||
return; | ||
} | ||
Array.prototype.unshift.apply(chain, requestInterceptorChain); | ||
chain = chain.concat(responseInterceptorChain); | ||
synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous; | ||
promise = Promise.resolve(config); | ||
while (chain.length) { | ||
promise = promise.then(chain.shift(), chain.shift()); | ||
requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected); | ||
}); | ||
const responseInterceptorChain = []; | ||
this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) { | ||
responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected); | ||
}); | ||
let promise; | ||
let i = 0; | ||
let len; | ||
if (!synchronousRequestInterceptors) { | ||
const chain = [dispatchRequest.bind(this), undefined]; | ||
chain.unshift.apply(chain, requestInterceptorChain); | ||
chain.push.apply(chain, responseInterceptorChain); | ||
len = chain.length; | ||
promise = Promise.resolve(config); | ||
while (i < len) { | ||
promise = promise.then(chain[i++], chain[i++]); | ||
} | ||
return promise; | ||
} | ||
return promise; | ||
} | ||
len = requestInterceptorChain.length; | ||
let newConfig = config; | ||
var newConfig = config; | ||
while (requestInterceptorChain.length) { | ||
var onFulfilled = requestInterceptorChain.shift(); | ||
var onRejected = requestInterceptorChain.shift(); | ||
i = 0; | ||
while (i < len) { | ||
const onFulfilled = requestInterceptorChain[i++]; | ||
const onRejected = requestInterceptorChain[i++]; | ||
try { | ||
newConfig = onFulfilled(newConfig); | ||
} catch (error) { | ||
onRejected.call(this, error); | ||
break; | ||
} | ||
} | ||
try { | ||
newConfig = onFulfilled(newConfig); | ||
promise = dispatchRequest.call(this, newConfig); | ||
} catch (error) { | ||
onRejected(error); | ||
break; | ||
return Promise.reject(error); | ||
} | ||
} | ||
try { | ||
promise = dispatchRequest(newConfig); | ||
} catch (error) { | ||
return Promise.reject(error); | ||
i = 0; | ||
len = responseInterceptorChain.length; | ||
while (i < len) { | ||
promise = promise.then(responseInterceptorChain[i++], responseInterceptorChain[i++]); | ||
} | ||
return promise; | ||
} | ||
while (responseInterceptorChain.length) { | ||
promise = promise.then(responseInterceptorChain.shift(), responseInterceptorChain.shift()); | ||
getUri(config) { | ||
config = mergeConfig(this.defaults, config); | ||
const fullPath = buildFullPath(config.baseURL, config.url); | ||
return buildURL(fullPath, config.params, config.paramsSerializer); | ||
} | ||
} | ||
return promise; | ||
}; | ||
Axios.prototype.getUri = function getUri(config) { | ||
config = mergeConfig(this.defaults, config); | ||
return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\?/, ''); | ||
}; | ||
// Provide aliases for supported request methods | ||
@@ -131,4 +174,4 @@ utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) { | ||
return this.request(mergeConfig(config || {}, { | ||
method: method, | ||
url: url, | ||
method, | ||
url, | ||
data: (config || {}).data | ||
@@ -141,11 +184,21 @@ })); | ||
/*eslint func-names:0*/ | ||
Axios.prototype[method] = function(url, data, config) { | ||
return this.request(mergeConfig(config || {}, { | ||
method: method, | ||
url: url, | ||
data: data | ||
})); | ||
}; | ||
function generateHTTPMethod(isForm) { | ||
return function httpMethod(url, data, config) { | ||
return this.request(mergeConfig(config || {}, { | ||
method, | ||
headers: isForm ? { | ||
'Content-Type': 'multipart/form-data' | ||
} : {}, | ||
url, | ||
data | ||
})); | ||
}; | ||
} | ||
Axios.prototype[method] = generateHTTPMethod(); | ||
Axios.prototype[method + 'Form'] = generateHTTPMethod(true); | ||
}); | ||
module.exports = Axios; | ||
export default Axios; |
'use strict'; | ||
var isAbsoluteURL = require('../helpers/isAbsoluteURL'); | ||
var combineURLs = require('../helpers/combineURLs'); | ||
import isAbsoluteURL from '../helpers/isAbsoluteURL.js'; | ||
import combineURLs from '../helpers/combineURLs.js'; | ||
@@ -13,5 +13,6 @@ /** | ||
* @param {string} requestedURL Absolute or relative URL to combine | ||
* | ||
* @returns {string} The combined full path | ||
*/ | ||
module.exports = function buildFullPath(baseURL, requestedURL) { | ||
export default function buildFullPath(baseURL, requestedURL) { | ||
if (baseURL && !isAbsoluteURL(requestedURL)) { | ||
@@ -21,2 +22,2 @@ return combineURLs(baseURL, requestedURL); | ||
return requestedURL; | ||
}; | ||
} |
'use strict'; | ||
var utils = require('./../utils'); | ||
var transformData = require('./transformData'); | ||
var isCancel = require('../cancel/isCancel'); | ||
var defaults = require('../defaults'); | ||
var Cancel = require('../cancel/Cancel'); | ||
import transformData from './transformData.js'; | ||
import isCancel from '../cancel/isCancel.js'; | ||
import defaults from '../defaults/index.js'; | ||
import CanceledError from '../cancel/CanceledError.js'; | ||
import AxiosHeaders from '../core/AxiosHeaders.js'; | ||
import adapters from "../adapters/adapters.js"; | ||
/** | ||
* Throws a `Cancel` if cancellation has been requested. | ||
* Throws a `CanceledError` if cancellation has been requested. | ||
* | ||
* @param {Object} config The config that is to be used for the request | ||
* | ||
* @returns {void} | ||
*/ | ||
@@ -18,3 +23,3 @@ function throwIfCancellationRequested(config) { | ||
if (config.signal && config.signal.aborted) { | ||
throw new Cancel('canceled'); | ||
throw new CanceledError(null, config); | ||
} | ||
@@ -27,9 +32,9 @@ } | ||
* @param {object} config The config that is to be used for the request | ||
* | ||
* @returns {Promise} The Promise to be fulfilled | ||
*/ | ||
module.exports = function dispatchRequest(config) { | ||
export default function dispatchRequest(config) { | ||
throwIfCancellationRequested(config); | ||
// Ensure headers exist | ||
config.headers = config.headers || {}; | ||
config.headers = AxiosHeaders.from(config.headers); | ||
@@ -39,23 +44,11 @@ // Transform request data | ||
config, | ||
config.data, | ||
config.headers, | ||
config.transformRequest | ||
); | ||
// Flatten headers | ||
config.headers = utils.merge( | ||
config.headers.common || {}, | ||
config.headers[config.method] || {}, | ||
config.headers | ||
); | ||
if (['post', 'put', 'patch'].indexOf(config.method) !== -1) { | ||
config.headers.setContentType('application/x-www-form-urlencoded', false); | ||
} | ||
utils.forEach( | ||
['delete', 'get', 'head', 'post', 'put', 'patch', 'common'], | ||
function cleanHeaderConfig(method) { | ||
delete config.headers[method]; | ||
} | ||
); | ||
const adapter = adapters.getAdapter(config.adapter || defaults.adapter); | ||
var adapter = config.adapter || defaults.adapter; | ||
return adapter(config).then(function onAdapterResolution(response) { | ||
@@ -67,7 +60,8 @@ throwIfCancellationRequested(config); | ||
config, | ||
response.data, | ||
response.headers, | ||
config.transformResponse | ||
config.transformResponse, | ||
response | ||
); | ||
response.headers = AxiosHeaders.from(response.headers); | ||
return response; | ||
@@ -82,6 +76,6 @@ }, function onAdapterRejection(reason) { | ||
config, | ||
reason.response.data, | ||
reason.response.headers, | ||
config.transformResponse | ||
config.transformResponse, | ||
reason.response | ||
); | ||
reason.response.headers = AxiosHeaders.from(reason.response.headers); | ||
} | ||
@@ -92,2 +86,2 @@ } | ||
}); | ||
}; | ||
} |
'use strict'; | ||
var utils = require('./../utils'); | ||
import utils from './../utils.js'; | ||
function InterceptorManager() { | ||
this.handlers = []; | ||
} | ||
class InterceptorManager { | ||
constructor() { | ||
this.handlers = []; | ||
} | ||
/** | ||
* Add a new interceptor to the stack | ||
* | ||
* @param {Function} fulfilled The function to handle `then` for a `Promise` | ||
* @param {Function} rejected The function to handle `reject` for a `Promise` | ||
* | ||
* @return {Number} An ID used to remove interceptor later | ||
*/ | ||
InterceptorManager.prototype.use = function use(fulfilled, rejected, options) { | ||
this.handlers.push({ | ||
fulfilled: fulfilled, | ||
rejected: rejected, | ||
synchronous: options ? options.synchronous : false, | ||
runWhen: options ? options.runWhen : null | ||
}); | ||
return this.handlers.length - 1; | ||
}; | ||
/** | ||
* Add a new interceptor to the stack | ||
* | ||
* @param {Function} fulfilled The function to handle `then` for a `Promise` | ||
* @param {Function} rejected The function to handle `reject` for a `Promise` | ||
* | ||
* @return {Number} An ID used to remove interceptor later | ||
*/ | ||
use(fulfilled, rejected, options) { | ||
this.handlers.push({ | ||
fulfilled, | ||
rejected, | ||
synchronous: options ? options.synchronous : false, | ||
runWhen: options ? options.runWhen : null | ||
}); | ||
return this.handlers.length - 1; | ||
} | ||
/** | ||
* Remove an interceptor from the stack | ||
* | ||
* @param {Number} id The ID that was returned by `use` | ||
*/ | ||
InterceptorManager.prototype.eject = function eject(id) { | ||
if (this.handlers[id]) { | ||
this.handlers[id] = null; | ||
/** | ||
* Remove an interceptor from the stack | ||
* | ||
* @param {Number} id The ID that was returned by `use` | ||
* | ||
* @returns {Boolean} `true` if the interceptor was removed, `false` otherwise | ||
*/ | ||
eject(id) { | ||
if (this.handlers[id]) { | ||
this.handlers[id] = null; | ||
} | ||
} | ||
}; | ||
/** | ||
* Iterate over all the registered interceptors | ||
* | ||
* This method is particularly useful for skipping over any | ||
* interceptors that may have become `null` calling `eject`. | ||
* | ||
* @param {Function} fn The function to call for each interceptor | ||
*/ | ||
InterceptorManager.prototype.forEach = function forEach(fn) { | ||
utils.forEach(this.handlers, function forEachHandler(h) { | ||
if (h !== null) { | ||
fn(h); | ||
/** | ||
* Clear all interceptors from the stack | ||
* | ||
* @returns {void} | ||
*/ | ||
clear() { | ||
if (this.handlers) { | ||
this.handlers = []; | ||
} | ||
}); | ||
}; | ||
} | ||
module.exports = InterceptorManager; | ||
/** | ||
* Iterate over all the registered interceptors | ||
* | ||
* This method is particularly useful for skipping over any | ||
* interceptors that may have become `null` calling `eject`. | ||
* | ||
* @param {Function} fn The function to call for each interceptor | ||
* | ||
* @returns {void} | ||
*/ | ||
forEach(fn) { | ||
utils.forEach(this.handlers, function forEachHandler(h) { | ||
if (h !== null) { | ||
fn(h); | ||
} | ||
}); | ||
} | ||
} | ||
export default InterceptorManager; |
'use strict'; | ||
var utils = require('../utils'); | ||
import utils from '../utils.js'; | ||
import AxiosHeaders from "./AxiosHeaders.js"; | ||
const headersToObject = (thing) => thing instanceof AxiosHeaders ? thing.toJSON() : thing; | ||
/** | ||
@@ -11,12 +14,13 @@ * Config-specific merge-function which creates a new config-object | ||
* @param {Object} config2 | ||
* | ||
* @returns {Object} New object resulting from merging config2 to config1 | ||
*/ | ||
module.exports = function mergeConfig(config1, config2) { | ||
export default function mergeConfig(config1, config2) { | ||
// eslint-disable-next-line no-param-reassign | ||
config2 = config2 || {}; | ||
var config = {}; | ||
const config = {}; | ||
function getMergedValue(target, source) { | ||
function getMergedValue(target, source, caseless) { | ||
if (utils.isPlainObject(target) && utils.isPlainObject(source)) { | ||
return utils.merge(target, source); | ||
return utils.merge.call({caseless}, target, source); | ||
} else if (utils.isPlainObject(source)) { | ||
@@ -31,7 +35,7 @@ return utils.merge({}, source); | ||
// eslint-disable-next-line consistent-return | ||
function mergeDeepProperties(prop) { | ||
if (!utils.isUndefined(config2[prop])) { | ||
return getMergedValue(config1[prop], config2[prop]); | ||
} else if (!utils.isUndefined(config1[prop])) { | ||
return getMergedValue(undefined, config1[prop]); | ||
function mergeDeepProperties(a, b, caseless) { | ||
if (!utils.isUndefined(b)) { | ||
return getMergedValue(a, b, caseless); | ||
} else if (!utils.isUndefined(a)) { | ||
return getMergedValue(undefined, a, caseless); | ||
} | ||
@@ -41,5 +45,5 @@ } | ||
// eslint-disable-next-line consistent-return | ||
function valueFromConfig2(prop) { | ||
if (!utils.isUndefined(config2[prop])) { | ||
return getMergedValue(undefined, config2[prop]); | ||
function valueFromConfig2(a, b) { | ||
if (!utils.isUndefined(b)) { | ||
return getMergedValue(undefined, b); | ||
} | ||
@@ -49,7 +53,7 @@ } | ||
// eslint-disable-next-line consistent-return | ||
function defaultToConfig2(prop) { | ||
if (!utils.isUndefined(config2[prop])) { | ||
return getMergedValue(undefined, config2[prop]); | ||
} else if (!utils.isUndefined(config1[prop])) { | ||
return getMergedValue(undefined, config1[prop]); | ||
function defaultToConfig2(a, b) { | ||
if (!utils.isUndefined(b)) { | ||
return getMergedValue(undefined, b); | ||
} else if (!utils.isUndefined(a)) { | ||
return getMergedValue(undefined, a); | ||
} | ||
@@ -59,42 +63,44 @@ } | ||
// eslint-disable-next-line consistent-return | ||
function mergeDirectKeys(prop) { | ||
function mergeDirectKeys(a, b, prop) { | ||
if (prop in config2) { | ||
return getMergedValue(config1[prop], config2[prop]); | ||
return getMergedValue(a, b); | ||
} else if (prop in config1) { | ||
return getMergedValue(undefined, config1[prop]); | ||
return getMergedValue(undefined, a); | ||
} | ||
} | ||
var mergeMap = { | ||
'url': valueFromConfig2, | ||
'method': valueFromConfig2, | ||
'data': valueFromConfig2, | ||
'baseURL': defaultToConfig2, | ||
'transformRequest': defaultToConfig2, | ||
'transformResponse': defaultToConfig2, | ||
'paramsSerializer': defaultToConfig2, | ||
'timeout': defaultToConfig2, | ||
'timeoutMessage': defaultToConfig2, | ||
'withCredentials': defaultToConfig2, | ||
'adapter': defaultToConfig2, | ||
'responseType': defaultToConfig2, | ||
'xsrfCookieName': defaultToConfig2, | ||
'xsrfHeaderName': defaultToConfig2, | ||
'onUploadProgress': defaultToConfig2, | ||
'onDownloadProgress': defaultToConfig2, | ||
'decompress': defaultToConfig2, | ||
'maxContentLength': defaultToConfig2, | ||
'maxBodyLength': defaultToConfig2, | ||
'transport': defaultToConfig2, | ||
'httpAgent': defaultToConfig2, | ||
'httpsAgent': defaultToConfig2, | ||
'cancelToken': defaultToConfig2, | ||
'socketPath': defaultToConfig2, | ||
'responseEncoding': defaultToConfig2, | ||
'validateStatus': mergeDirectKeys | ||
const mergeMap = { | ||
url: valueFromConfig2, | ||
method: valueFromConfig2, | ||
data: valueFromConfig2, | ||
baseURL: defaultToConfig2, | ||
transformRequest: defaultToConfig2, | ||
transformResponse: defaultToConfig2, | ||
paramsSerializer: defaultToConfig2, | ||
timeout: defaultToConfig2, | ||
timeoutMessage: defaultToConfig2, | ||
withCredentials: defaultToConfig2, | ||
adapter: defaultToConfig2, | ||
responseType: defaultToConfig2, | ||
xsrfCookieName: defaultToConfig2, | ||
xsrfHeaderName: defaultToConfig2, | ||
onUploadProgress: defaultToConfig2, | ||
onDownloadProgress: defaultToConfig2, | ||
decompress: defaultToConfig2, | ||
maxContentLength: defaultToConfig2, | ||
maxBodyLength: defaultToConfig2, | ||
beforeRedirect: defaultToConfig2, | ||
transport: defaultToConfig2, | ||
httpAgent: defaultToConfig2, | ||
httpsAgent: defaultToConfig2, | ||
cancelToken: defaultToConfig2, | ||
socketPath: defaultToConfig2, | ||
responseEncoding: defaultToConfig2, | ||
validateStatus: mergeDirectKeys, | ||
headers: (a, b) => mergeDeepProperties(headersToObject(a), headersToObject(b), true) | ||
}; | ||
utils.forEach(Object.keys(config1).concat(Object.keys(config2)), function computeConfigValue(prop) { | ||
var merge = mergeMap[prop] || mergeDeepProperties; | ||
var configValue = merge(prop); | ||
utils.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) { | ||
const merge = mergeMap[prop] || mergeDeepProperties; | ||
const configValue = merge(config1[prop], config2[prop], prop); | ||
(utils.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue); | ||
@@ -104,2 +110,2 @@ }); | ||
return config; | ||
}; | ||
} |
'use strict'; | ||
var createError = require('./createError'); | ||
import AxiosError from './AxiosError.js'; | ||
@@ -11,12 +11,14 @@ /** | ||
* @param {object} response The response. | ||
* | ||
* @returns {object} The response. | ||
*/ | ||
module.exports = function settle(resolve, reject, response) { | ||
var validateStatus = response.config.validateStatus; | ||
export default function settle(resolve, reject, response) { | ||
const validateStatus = response.config.validateStatus; | ||
if (!response.status || !validateStatus || validateStatus(response.status)) { | ||
resolve(response); | ||
} else { | ||
reject(createError( | ||
reject(new AxiosError( | ||
'Request failed with status code ' + response.status, | ||
[AxiosError.ERR_BAD_REQUEST, AxiosError.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4], | ||
response.config, | ||
null, | ||
response.request, | ||
@@ -26,2 +28,2 @@ response | ||
} | ||
}; | ||
} |
'use strict'; | ||
var utils = require('./../utils'); | ||
var defaults = require('./../defaults'); | ||
import utils from './../utils.js'; | ||
import defaults from '../defaults/index.js'; | ||
import AxiosHeaders from '../core/AxiosHeaders.js'; | ||
@@ -9,15 +10,20 @@ /** | ||
* | ||
* @param {Object|String} data The data to be transformed | ||
* @param {Array} headers The headers for the request or response | ||
* @param {Array|Function} fns A single function or Array of functions | ||
* @param {?Object} response The response object | ||
* | ||
* @returns {*} The resulting transformed data | ||
*/ | ||
module.exports = function transformData(data, headers, fns) { | ||
var context = this || defaults; | ||
/*eslint no-param-reassign:0*/ | ||
export default function transformData(fns, response) { | ||
const config = this || defaults; | ||
const context = response || config; | ||
const headers = AxiosHeaders.from(context.headers); | ||
let data = context.data; | ||
utils.forEach(fns, function transform(fn) { | ||
data = fn.call(context, data, headers); | ||
data = fn.call(config, data, headers.normalize(), response ? response.status : undefined); | ||
}); | ||
headers.normalize(); | ||
return data; | ||
}; | ||
} |
@@ -1,3 +0,1 @@ | ||
module.exports = { | ||
"version": "0.22.0" | ||
}; | ||
export const VERSION = "1.6.1"; |
'use strict'; | ||
module.exports = function bind(fn, thisArg) { | ||
export default function bind(fn, thisArg) { | ||
return function wrap() { | ||
var args = new Array(arguments.length); | ||
for (var i = 0; i < args.length; i++) { | ||
args[i] = arguments[i]; | ||
} | ||
return fn.apply(thisArg, args); | ||
return fn.apply(thisArg, arguments); | ||
}; | ||
}; | ||
} |
'use strict'; | ||
var utils = require('./../utils'); | ||
import utils from '../utils.js'; | ||
import AxiosURLSearchParams from '../helpers/AxiosURLSearchParams.js'; | ||
/** | ||
* It replaces all instances of the characters `:`, `$`, `,`, `+`, `[`, and `]` with their | ||
* URI encoded counterparts | ||
* | ||
* @param {string} val The value to be encoded. | ||
* | ||
* @returns {string} The encoded value. | ||
*/ | ||
function encode(val) { | ||
@@ -20,5 +29,7 @@ return encodeURIComponent(val). | ||
* @param {object} [params] The params to be appended | ||
* @param {?object} options | ||
* | ||
* @returns {string} The formatted url | ||
*/ | ||
module.exports = function buildURL(url, params, paramsSerializer) { | ||
export default function buildURL(url, params, options) { | ||
/*eslint no-param-reassign:0*/ | ||
@@ -28,41 +39,23 @@ if (!params) { | ||
} | ||
const _encode = options && options.encode || encode; | ||
var serializedParams; | ||
if (paramsSerializer) { | ||
serializedParams = paramsSerializer(params); | ||
} else if (utils.isURLSearchParams(params)) { | ||
serializedParams = params.toString(); | ||
} else { | ||
var parts = []; | ||
const serializeFn = options && options.serialize; | ||
utils.forEach(params, function serialize(val, key) { | ||
if (val === null || typeof val === 'undefined') { | ||
return; | ||
} | ||
let serializedParams; | ||
if (utils.isArray(val)) { | ||
key = key + '[]'; | ||
} else { | ||
val = [val]; | ||
} | ||
utils.forEach(val, function parseValue(v) { | ||
if (utils.isDate(v)) { | ||
v = v.toISOString(); | ||
} else if (utils.isObject(v)) { | ||
v = JSON.stringify(v); | ||
} | ||
parts.push(encode(key) + '=' + encode(v)); | ||
}); | ||
}); | ||
serializedParams = parts.join('&'); | ||
if (serializeFn) { | ||
serializedParams = serializeFn(params, options); | ||
} else { | ||
serializedParams = utils.isURLSearchParams(params) ? | ||
params.toString() : | ||
new AxiosURLSearchParams(params, options).toString(_encode); | ||
} | ||
if (serializedParams) { | ||
var hashmarkIndex = url.indexOf('#'); | ||
const hashmarkIndex = url.indexOf("#"); | ||
if (hashmarkIndex !== -1) { | ||
url = url.slice(0, hashmarkIndex); | ||
} | ||
url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams; | ||
@@ -72,2 +65,2 @@ } | ||
return url; | ||
}; | ||
} |
@@ -8,8 +8,9 @@ 'use strict'; | ||
* @param {string} relativeURL The relative URL | ||
* | ||
* @returns {string} The combined URL | ||
*/ | ||
module.exports = function combineURLs(baseURL, relativeURL) { | ||
export default function combineURLs(baseURL, relativeURL) { | ||
return relativeURL | ||
? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '') | ||
: baseURL; | ||
}; | ||
} |
'use strict'; | ||
var utils = require('./../utils'); | ||
import utils from './../utils.js'; | ||
import platform from '../platform/index.js'; | ||
module.exports = ( | ||
utils.isStandardBrowserEnv() ? | ||
export default platform.hasStandardBrowserEnv ? | ||
// Standard browser envs support document.cookie | ||
(function standardBrowserEnv() { | ||
return { | ||
write: function write(name, value, expires, path, domain, secure) { | ||
var cookie = []; | ||
cookie.push(name + '=' + encodeURIComponent(value)); | ||
// Standard browser envs support document.cookie | ||
(function standardBrowserEnv() { | ||
return { | ||
write: function write(name, value, expires, path, domain, secure) { | ||
const cookie = []; | ||
cookie.push(name + '=' + encodeURIComponent(value)); | ||
if (utils.isNumber(expires)) { | ||
cookie.push('expires=' + new Date(expires).toGMTString()); | ||
} | ||
if (utils.isNumber(expires)) { | ||
cookie.push('expires=' + new Date(expires).toGMTString()); | ||
} | ||
if (utils.isString(path)) { | ||
cookie.push('path=' + path); | ||
} | ||
if (utils.isString(path)) { | ||
cookie.push('path=' + path); | ||
} | ||
if (utils.isString(domain)) { | ||
cookie.push('domain=' + domain); | ||
} | ||
if (utils.isString(domain)) { | ||
cookie.push('domain=' + domain); | ||
} | ||
if (secure === true) { | ||
cookie.push('secure'); | ||
} | ||
if (secure === true) { | ||
cookie.push('secure'); | ||
} | ||
document.cookie = cookie.join('; '); | ||
}, | ||
document.cookie = cookie.join('; '); | ||
}, | ||
read: function read(name) { | ||
var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)')); | ||
return (match ? decodeURIComponent(match[3]) : null); | ||
}, | ||
read: function read(name) { | ||
const match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)')); | ||
return (match ? decodeURIComponent(match[3]) : null); | ||
}, | ||
remove: function remove(name) { | ||
this.write(name, '', Date.now() - 86400000); | ||
} | ||
}; | ||
})() : | ||
remove: function remove(name) { | ||
this.write(name, '', Date.now() - 86400000); | ||
} | ||
}; | ||
})() : | ||
// Non standard browser env (web workers, react-native) lack needed support. | ||
(function nonStandardBrowserEnv() { | ||
return { | ||
write: function write() {}, | ||
read: function read() { return null; }, | ||
remove: function remove() {} | ||
}; | ||
})() | ||
); | ||
// Non standard browser env (web workers, react-native) lack needed support. | ||
(function nonStandardBrowserEnv() { | ||
return { | ||
write: function write() {}, | ||
read: function read() { return null; }, | ||
remove: function remove() {} | ||
}; | ||
})(); |
@@ -12,4 +12,6 @@ 'use strict'; | ||
* @param {string} [docs] The documentation URL to get further details | ||
* | ||
* @returns {void} | ||
*/ | ||
module.exports = function deprecatedMethod(method, instead, docs) { | ||
export default function deprecatedMethod(method, instead, docs) { | ||
try { | ||
@@ -25,2 +27,2 @@ console.warn( | ||
} catch (e) { /* Ignore */ } | ||
}; | ||
} |
@@ -7,9 +7,10 @@ 'use strict'; | ||
* @param {string} url The URL to test | ||
* | ||
* @returns {boolean} True if the specified URL is absolute, otherwise false | ||
*/ | ||
module.exports = function isAbsoluteURL(url) { | ||
export default function isAbsoluteURL(url) { | ||
// A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL). | ||
// RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed | ||
// by any combination of letters, digits, plus, period, or hyphen. | ||
return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url); | ||
}; | ||
return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url); | ||
} |
'use strict'; | ||
import utils from './../utils.js'; | ||
/** | ||
@@ -7,6 +9,7 @@ * Determines whether the payload is an error thrown by Axios | ||
* @param {*} payload The value to test | ||
* | ||
* @returns {boolean} True if the payload is an error thrown by Axios, otherwise false | ||
*/ | ||
module.exports = function isAxiosError(payload) { | ||
return (typeof payload === 'object') && (payload.isAxiosError === true); | ||
}; | ||
export default function isAxiosError(payload) { | ||
return utils.isObject(payload) && (payload.isAxiosError === true); | ||
} |
'use strict'; | ||
var utils = require('./../utils'); | ||
import utils from './../utils.js'; | ||
import platform from '../platform/index.js'; | ||
module.exports = ( | ||
utils.isStandardBrowserEnv() ? | ||
export default platform.hasStandardBrowserEnv ? | ||
// Standard browser envs have full support of the APIs needed to test | ||
// whether the request URL is of the same origin as current location. | ||
(function standardBrowserEnv() { | ||
var msie = /(msie|trident)/i.test(navigator.userAgent); | ||
var urlParsingNode = document.createElement('a'); | ||
var originURL; | ||
// Standard browser envs have full support of the APIs needed to test | ||
// whether the request URL is of the same origin as current location. | ||
(function standardBrowserEnv() { | ||
const msie = /(msie|trident)/i.test(navigator.userAgent); | ||
const urlParsingNode = document.createElement('a'); | ||
let originURL; | ||
/** | ||
/** | ||
* Parse a URL to discover it's components | ||
@@ -21,31 +21,31 @@ * | ||
*/ | ||
function resolveURL(url) { | ||
var href = url; | ||
function resolveURL(url) { | ||
let href = url; | ||
if (msie) { | ||
if (msie) { | ||
// IE needs attribute set twice to normalize properties | ||
urlParsingNode.setAttribute('href', href); | ||
href = urlParsingNode.href; | ||
} | ||
urlParsingNode.setAttribute('href', href); | ||
// urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils | ||
return { | ||
href: urlParsingNode.href, | ||
protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '', | ||
host: urlParsingNode.host, | ||
search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '', | ||
hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '', | ||
hostname: urlParsingNode.hostname, | ||
port: urlParsingNode.port, | ||
pathname: (urlParsingNode.pathname.charAt(0) === '/') ? | ||
urlParsingNode.pathname : | ||
'/' + urlParsingNode.pathname | ||
}; | ||
href = urlParsingNode.href; | ||
} | ||
originURL = resolveURL(window.location.href); | ||
urlParsingNode.setAttribute('href', href); | ||
/** | ||
// urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils | ||
return { | ||
href: urlParsingNode.href, | ||
protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '', | ||
host: urlParsingNode.host, | ||
search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '', | ||
hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '', | ||
hostname: urlParsingNode.hostname, | ||
port: urlParsingNode.port, | ||
pathname: (urlParsingNode.pathname.charAt(0) === '/') ? | ||
urlParsingNode.pathname : | ||
'/' + urlParsingNode.pathname | ||
}; | ||
} | ||
originURL = resolveURL(window.location.href); | ||
/** | ||
* Determine if a URL shares the same origin as the current location | ||
@@ -56,15 +56,14 @@ * | ||
*/ | ||
return function isURLSameOrigin(requestURL) { | ||
var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL; | ||
return (parsed.protocol === originURL.protocol && | ||
parsed.host === originURL.host); | ||
}; | ||
})() : | ||
return function isURLSameOrigin(requestURL) { | ||
const parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL; | ||
return (parsed.protocol === originURL.protocol && | ||
parsed.host === originURL.host); | ||
}; | ||
})() : | ||
// Non standard browser envs (web workers, react-native) lack needed support. | ||
(function nonStandardBrowserEnv() { | ||
return function isURLSameOrigin() { | ||
return true; | ||
}; | ||
})() | ||
); | ||
(function nonStandardBrowserEnv() { | ||
return function isURLSameOrigin() { | ||
return true; | ||
}; | ||
})(); |
'use strict'; | ||
var utils = require('./../utils'); | ||
import utils from './../utils.js'; | ||
// Headers whose duplicates are ignored by node | ||
// RawAxiosHeaders whose duplicates are ignored by node | ||
// c.f. https://nodejs.org/api/http.html#http_message_headers | ||
var ignoreDuplicateOf = [ | ||
const ignoreDuplicateOf = utils.toObjectSet([ | ||
'age', 'authorization', 'content-length', 'content-type', 'etag', | ||
@@ -12,3 +12,3 @@ 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since', | ||
'referer', 'retry-after', 'user-agent' | ||
]; | ||
]); | ||
@@ -25,27 +25,29 @@ /** | ||
* | ||
* @param {String} headers Headers needing to be parsed | ||
* @param {String} rawHeaders Headers needing to be parsed | ||
* | ||
* @returns {Object} Headers parsed into an object | ||
*/ | ||
module.exports = function parseHeaders(headers) { | ||
var parsed = {}; | ||
var key; | ||
var val; | ||
var i; | ||
export default rawHeaders => { | ||
const parsed = {}; | ||
let key; | ||
let val; | ||
let i; | ||
if (!headers) { return parsed; } | ||
utils.forEach(headers.split('\n'), function parser(line) { | ||
rawHeaders && rawHeaders.split('\n').forEach(function parser(line) { | ||
i = line.indexOf(':'); | ||
key = utils.trim(line.substr(0, i)).toLowerCase(); | ||
val = utils.trim(line.substr(i + 1)); | ||
key = line.substring(0, i).trim().toLowerCase(); | ||
val = line.substring(i + 1).trim(); | ||
if (key) { | ||
if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) { | ||
return; | ||
} | ||
if (key === 'set-cookie') { | ||
parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]); | ||
if (!key || (parsed[key] && ignoreDuplicateOf[key])) { | ||
return; | ||
} | ||
if (key === 'set-cookie') { | ||
if (parsed[key]) { | ||
parsed[key].push(val); | ||
} else { | ||
parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val; | ||
parsed[key] = [val]; | ||
} | ||
} else { | ||
parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val; | ||
} | ||
@@ -52,0 +54,0 @@ }); |
@@ -21,8 +21,9 @@ 'use strict'; | ||
* @param {Function} callback | ||
* | ||
* @returns {Function} | ||
*/ | ||
module.exports = function spread(callback) { | ||
export default function spread(callback) { | ||
return function wrap(arr) { | ||
return callback.apply(null, arr); | ||
}; | ||
}; | ||
} |
'use strict'; | ||
var VERSION = require('../env/data').version; | ||
import {VERSION} from '../env/data.js'; | ||
import AxiosError from '../core/AxiosError.js'; | ||
var validators = {}; | ||
const validators = {}; | ||
// eslint-disable-next-line func-names | ||
['object', 'boolean', 'number', 'function', 'string', 'symbol'].forEach(function(type, i) { | ||
['object', 'boolean', 'number', 'function', 'string', 'symbol'].forEach((type, i) => { | ||
validators[type] = function validator(thing) { | ||
@@ -14,9 +15,11 @@ return typeof thing === type || 'a' + (i < 1 ? 'n ' : ' ') + type; | ||
var deprecatedWarnings = {}; | ||
const deprecatedWarnings = {}; | ||
/** | ||
* Transitional option validator | ||
* | ||
* @param {function|boolean?} validator - set to false if the transitional option has been removed | ||
* @param {string?} version - deprecated version / removed since version | ||
* @param {string?} message - some message with additional info | ||
* | ||
* @returns {function} | ||
@@ -30,5 +33,8 @@ */ | ||
// eslint-disable-next-line func-names | ||
return function(value, opt, opts) { | ||
return (value, opt, opts) => { | ||
if (validator === false) { | ||
throw new Error(formatMessage(opt, ' has been removed' + (version ? ' in ' + version : ''))); | ||
throw new AxiosError( | ||
formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')), | ||
AxiosError.ERR_DEPRECATED | ||
); | ||
} | ||
@@ -53,5 +59,8 @@ | ||
* Assert object's properties type | ||
* | ||
* @param {object} options | ||
* @param {object} schema | ||
* @param {boolean?} allowUnknown | ||
* | ||
* @returns {object} | ||
*/ | ||
@@ -61,14 +70,14 @@ | ||
if (typeof options !== 'object') { | ||
throw new TypeError('options must be an object'); | ||
throw new AxiosError('options must be an object', AxiosError.ERR_BAD_OPTION_VALUE); | ||
} | ||
var keys = Object.keys(options); | ||
var i = keys.length; | ||
const keys = Object.keys(options); | ||
let i = keys.length; | ||
while (i-- > 0) { | ||
var opt = keys[i]; | ||
var validator = schema[opt]; | ||
const opt = keys[i]; | ||
const validator = schema[opt]; | ||
if (validator) { | ||
var value = options[opt]; | ||
var result = value === undefined || validator(value, opt, options); | ||
const value = options[opt]; | ||
const result = value === undefined || validator(value, opt, options); | ||
if (result !== true) { | ||
throw new TypeError('option ' + opt + ' must be ' + result); | ||
throw new AxiosError('option ' + opt + ' must be ' + result, AxiosError.ERR_BAD_OPTION_VALUE); | ||
} | ||
@@ -78,3 +87,3 @@ continue; | ||
if (allowUnknown !== true) { | ||
throw Error('Unknown option ' + opt); | ||
throw new AxiosError('Unknown option ' + opt, AxiosError.ERR_BAD_OPTION); | ||
} | ||
@@ -84,5 +93,5 @@ } | ||
module.exports = { | ||
assertOptions: assertOptions, | ||
validators: validators | ||
export default { | ||
assertOptions, | ||
validators | ||
}; |
'use strict'; | ||
var bind = require('./helpers/bind'); | ||
import bind from './helpers/bind.js'; | ||
// utils is a library of generic helper functions non-specific to axios | ||
var toString = Object.prototype.toString; | ||
const {toString} = Object.prototype; | ||
const {getPrototypeOf} = Object; | ||
const kindOf = (cache => thing => { | ||
const str = toString.call(thing); | ||
return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase()); | ||
})(Object.create(null)); | ||
const kindOfTest = (type) => { | ||
type = type.toLowerCase(); | ||
return (thing) => kindOf(thing) === type | ||
} | ||
const typeOfTest = type => thing => typeof thing === type; | ||
/** | ||
@@ -13,7 +26,6 @@ * Determine if a value is an Array | ||
* @param {Object} val The value to test | ||
* | ||
* @returns {boolean} True if value is an Array, otherwise false | ||
*/ | ||
function isArray(val) { | ||
return toString.call(val) === '[object Array]'; | ||
} | ||
const {isArray} = Array; | ||
@@ -23,8 +35,7 @@ /** | ||
* | ||
* @param {Object} val The value to test | ||
* @param {*} val The value to test | ||
* | ||
* @returns {boolean} True if the value is undefined, otherwise false | ||
*/ | ||
function isUndefined(val) { | ||
return typeof val === 'undefined'; | ||
} | ||
const isUndefined = typeOfTest('undefined'); | ||
@@ -34,3 +45,4 @@ /** | ||
* | ||
* @param {Object} val The value to test | ||
* @param {*} val The value to test | ||
* | ||
* @returns {boolean} True if value is a Buffer, otherwise false | ||
@@ -40,3 +52,3 @@ */ | ||
return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor) | ||
&& typeof val.constructor.isBuffer === 'function' && val.constructor.isBuffer(val); | ||
&& isFunction(val.constructor.isBuffer) && val.constructor.isBuffer(val); | ||
} | ||
@@ -47,18 +59,8 @@ | ||
* | ||
* @param {Object} val The value to test | ||
* @param {*} val The value to test | ||
* | ||
* @returns {boolean} True if value is an ArrayBuffer, otherwise false | ||
*/ | ||
function isArrayBuffer(val) { | ||
return toString.call(val) === '[object ArrayBuffer]'; | ||
} | ||
const isArrayBuffer = kindOfTest('ArrayBuffer'); | ||
/** | ||
* Determine if a value is a FormData | ||
* | ||
* @param {Object} val The value to test | ||
* @returns {boolean} True if value is an FormData, otherwise false | ||
*/ | ||
function isFormData(val) { | ||
return (typeof FormData !== 'undefined') && (val instanceof FormData); | ||
} | ||
@@ -68,11 +70,12 @@ /** | ||
* | ||
* @param {Object} val The value to test | ||
* @param {*} val The value to test | ||
* | ||
* @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false | ||
*/ | ||
function isArrayBufferView(val) { | ||
var result; | ||
let result; | ||
if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) { | ||
result = ArrayBuffer.isView(val); | ||
} else { | ||
result = (val) && (val.buffer) && (val.buffer instanceof ArrayBuffer); | ||
result = (val) && (val.buffer) && (isArrayBuffer(val.buffer)); | ||
} | ||
@@ -85,18 +88,24 @@ return result; | ||
* | ||
* @param {Object} val The value to test | ||
* @param {*} val The value to test | ||
* | ||
* @returns {boolean} True if value is a String, otherwise false | ||
*/ | ||
function isString(val) { | ||
return typeof val === 'string'; | ||
} | ||
const isString = typeOfTest('string'); | ||
/** | ||
* Determine if a value is a Function | ||
* | ||
* @param {*} val The value to test | ||
* @returns {boolean} True if value is a Function, otherwise false | ||
*/ | ||
const isFunction = typeOfTest('function'); | ||
/** | ||
* Determine if a value is a Number | ||
* | ||
* @param {Object} val The value to test | ||
* @param {*} val The value to test | ||
* | ||
* @returns {boolean} True if value is a Number, otherwise false | ||
*/ | ||
function isNumber(val) { | ||
return typeof val === 'number'; | ||
} | ||
const isNumber = typeOfTest('number'); | ||
@@ -106,22 +115,30 @@ /** | ||
* | ||
* @param {Object} val The value to test | ||
* @param {*} thing The value to test | ||
* | ||
* @returns {boolean} True if value is an Object, otherwise false | ||
*/ | ||
function isObject(val) { | ||
return val !== null && typeof val === 'object'; | ||
} | ||
const isObject = (thing) => thing !== null && typeof thing === 'object'; | ||
/** | ||
* Determine if a value is a Boolean | ||
* | ||
* @param {*} thing The value to test | ||
* @returns {boolean} True if value is a Boolean, otherwise false | ||
*/ | ||
const isBoolean = thing => thing === true || thing === false; | ||
/** | ||
* Determine if a value is a plain Object | ||
* | ||
* @param {Object} val The value to test | ||
* @return {boolean} True if value is a plain Object, otherwise false | ||
* @param {*} val The value to test | ||
* | ||
* @returns {boolean} True if value is a plain Object, otherwise false | ||
*/ | ||
function isPlainObject(val) { | ||
if (toString.call(val) !== '[object Object]') { | ||
const isPlainObject = (val) => { | ||
if (kindOf(val) !== 'object') { | ||
return false; | ||
} | ||
var prototype = Object.getPrototypeOf(val); | ||
return prototype === null || prototype === Object.prototype; | ||
const prototype = getPrototypeOf(val); | ||
return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in val) && !(Symbol.iterator in val); | ||
} | ||
@@ -132,8 +149,7 @@ | ||
* | ||
* @param {Object} val The value to test | ||
* @param {*} val The value to test | ||
* | ||
* @returns {boolean} True if value is a Date, otherwise false | ||
*/ | ||
function isDate(val) { | ||
return toString.call(val) === '[object Date]'; | ||
} | ||
const isDate = kindOfTest('Date'); | ||
@@ -143,8 +159,7 @@ /** | ||
* | ||
* @param {Object} val The value to test | ||
* @param {*} val The value to test | ||
* | ||
* @returns {boolean} True if value is a File, otherwise false | ||
*/ | ||
function isFile(val) { | ||
return toString.call(val) === '[object File]'; | ||
} | ||
const isFile = kindOfTest('File'); | ||
@@ -154,18 +169,16 @@ /** | ||
* | ||
* @param {Object} val The value to test | ||
* @param {*} val The value to test | ||
* | ||
* @returns {boolean} True if value is a Blob, otherwise false | ||
*/ | ||
function isBlob(val) { | ||
return toString.call(val) === '[object Blob]'; | ||
} | ||
const isBlob = kindOfTest('Blob'); | ||
/** | ||
* Determine if a value is a Function | ||
* Determine if a value is a FileList | ||
* | ||
* @param {Object} val The value to test | ||
* @returns {boolean} True if value is a Function, otherwise false | ||
* @param {*} val The value to test | ||
* | ||
* @returns {boolean} True if value is a File, otherwise false | ||
*/ | ||
function isFunction(val) { | ||
return toString.call(val) === '[object Function]'; | ||
} | ||
const isFileList = kindOfTest('FileList'); | ||
@@ -175,7 +188,26 @@ /** | ||
* | ||
* @param {Object} val The value to test | ||
* @param {*} val The value to test | ||
* | ||
* @returns {boolean} True if value is a Stream, otherwise false | ||
*/ | ||
function isStream(val) { | ||
return isObject(val) && isFunction(val.pipe); | ||
const isStream = (val) => isObject(val) && isFunction(val.pipe); | ||
/** | ||
* Determine if a value is a FormData | ||
* | ||
* @param {*} thing The value to test | ||
* | ||
* @returns {boolean} True if value is an FormData, otherwise false | ||
*/ | ||
const isFormData = (thing) => { | ||
let kind; | ||
return thing && ( | ||
(typeof FormData === 'function' && thing instanceof FormData) || ( | ||
isFunction(thing.append) && ( | ||
(kind = kindOf(thing)) === 'formdata' || | ||
// detect form-data instance | ||
(kind === 'object' && isFunction(thing.toString) && thing.toString() === '[object FormData]') | ||
) | ||
) | ||
) | ||
} | ||
@@ -186,8 +218,7 @@ | ||
* | ||
* @param {Object} val The value to test | ||
* @param {*} val The value to test | ||
* | ||
* @returns {boolean} True if value is a URLSearchParams object, otherwise false | ||
*/ | ||
function isURLSearchParams(val) { | ||
return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams; | ||
} | ||
const isURLSearchParams = kindOfTest('URLSearchParams'); | ||
@@ -198,36 +229,9 @@ /** | ||
* @param {String} str The String to trim | ||
* | ||
* @returns {String} The String freed of excess whitespace | ||
*/ | ||
function trim(str) { | ||
return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g, ''); | ||
} | ||
const trim = (str) => str.trim ? | ||
str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, ''); | ||
/** | ||
* Determine if we're running in a standard browser environment | ||
* | ||
* This allows axios to run in a web worker, and react-native. | ||
* Both environments support XMLHttpRequest, but not fully standard globals. | ||
* | ||
* web workers: | ||
* typeof window -> undefined | ||
* typeof document -> undefined | ||
* | ||
* react-native: | ||
* navigator.product -> 'ReactNative' | ||
* nativescript | ||
* navigator.product -> 'NativeScript' or 'NS' | ||
*/ | ||
function isStandardBrowserEnv() { | ||
if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' || | ||
navigator.product === 'NativeScript' || | ||
navigator.product === 'NS')) { | ||
return false; | ||
} | ||
return ( | ||
typeof window !== 'undefined' && | ||
typeof document !== 'undefined' | ||
); | ||
} | ||
/** | ||
* Iterate over an Array or an Object invoking a function for each item. | ||
@@ -243,4 +247,7 @@ * | ||
* @param {Function} fn The callback to invoke for each item | ||
* | ||
* @param {Boolean} [allOwnKeys = false] | ||
* @returns {any} | ||
*/ | ||
function forEach(obj, fn) { | ||
function forEach(obj, fn, {allOwnKeys = false} = {}) { | ||
// Don't bother if no value provided | ||
@@ -251,2 +258,5 @@ if (obj === null || typeof obj === 'undefined') { | ||
let i; | ||
let l; | ||
// Force an array if not already something iterable | ||
@@ -260,3 +270,3 @@ if (typeof obj !== 'object') { | ||
// Iterate over array values | ||
for (var i = 0, l = obj.length; i < l; i++) { | ||
for (i = 0, l = obj.length; i < l; i++) { | ||
fn.call(null, obj[i], i, obj); | ||
@@ -266,6 +276,9 @@ } | ||
// Iterate over object keys | ||
for (var key in obj) { | ||
if (Object.prototype.hasOwnProperty.call(obj, key)) { | ||
fn.call(null, obj[key], key, obj); | ||
} | ||
const keys = allOwnKeys ? Object.getOwnPropertyNames(obj) : Object.keys(obj); | ||
const len = keys.length; | ||
let key; | ||
for (i = 0; i < len; i++) { | ||
key = keys[i]; | ||
fn.call(null, obj[key], key, obj); | ||
} | ||
@@ -275,2 +288,24 @@ } | ||
function findKey(obj, key) { | ||
key = key.toLowerCase(); | ||
const keys = Object.keys(obj); | ||
let i = keys.length; | ||
let _key; | ||
while (i-- > 0) { | ||
_key = keys[i]; | ||
if (key === _key.toLowerCase()) { | ||
return _key; | ||
} | ||
} | ||
return null; | ||
} | ||
const _global = (() => { | ||
/*eslint no-undef:0*/ | ||
if (typeof globalThis !== "undefined") return globalThis; | ||
return typeof self !== "undefined" ? self : (typeof window !== 'undefined' ? window : global) | ||
})(); | ||
const isContextDefined = (context) => !isUndefined(context) && context !== _global; | ||
/** | ||
@@ -291,20 +326,23 @@ * Accepts varargs expecting each argument to be an object, then | ||
* @param {Object} obj1 Object to merge | ||
* | ||
* @returns {Object} Result of all merge properties | ||
*/ | ||
function merge(/* obj1, obj2, obj3, ... */) { | ||
var result = {}; | ||
function assignValue(val, key) { | ||
if (isPlainObject(result[key]) && isPlainObject(val)) { | ||
result[key] = merge(result[key], val); | ||
const {caseless} = isContextDefined(this) && this || {}; | ||
const result = {}; | ||
const assignValue = (val, key) => { | ||
const targetKey = caseless && findKey(result, key) || key; | ||
if (isPlainObject(result[targetKey]) && isPlainObject(val)) { | ||
result[targetKey] = merge(result[targetKey], val); | ||
} else if (isPlainObject(val)) { | ||
result[key] = merge({}, val); | ||
result[targetKey] = merge({}, val); | ||
} else if (isArray(val)) { | ||
result[key] = val.slice(); | ||
result[targetKey] = val.slice(); | ||
} else { | ||
result[key] = val; | ||
result[targetKey] = val; | ||
} | ||
} | ||
for (var i = 0, l = arguments.length; i < l; i++) { | ||
forEach(arguments[i], assignValue); | ||
for (let i = 0, l = arguments.length; i < l; i++) { | ||
arguments[i] && forEach(arguments[i], assignValue); | ||
} | ||
@@ -320,7 +358,9 @@ return result; | ||
* @param {Object} thisArg The object to bind function to | ||
* @return {Object} The resulting value of object a | ||
* | ||
* @param {Boolean} [allOwnKeys] | ||
* @returns {Object} The resulting value of object a | ||
*/ | ||
function extend(a, b, thisArg) { | ||
forEach(b, function assignValue(val, key) { | ||
if (thisArg && typeof val === 'function') { | ||
const extend = (a, b, thisArg, {allOwnKeys}= {}) => { | ||
forEach(b, (val, key) => { | ||
if (thisArg && isFunction(val)) { | ||
a[key] = bind(val, thisArg); | ||
@@ -330,3 +370,3 @@ } else { | ||
} | ||
}); | ||
}, {allOwnKeys}); | ||
return a; | ||
@@ -339,5 +379,6 @@ } | ||
* @param {string} content with BOM | ||
* @return {string} content value without BOM | ||
* | ||
* @returns {string} content value without BOM | ||
*/ | ||
function stripBOM(content) { | ||
const stripBOM = (content) => { | ||
if (content.charCodeAt(0) === 0xFEFF) { | ||
@@ -349,25 +390,358 @@ content = content.slice(1); | ||
module.exports = { | ||
isArray: isArray, | ||
isArrayBuffer: isArrayBuffer, | ||
isBuffer: isBuffer, | ||
isFormData: isFormData, | ||
isArrayBufferView: isArrayBufferView, | ||
isString: isString, | ||
isNumber: isNumber, | ||
isObject: isObject, | ||
isPlainObject: isPlainObject, | ||
isUndefined: isUndefined, | ||
isDate: isDate, | ||
isFile: isFile, | ||
isBlob: isBlob, | ||
isFunction: isFunction, | ||
isStream: isStream, | ||
isURLSearchParams: isURLSearchParams, | ||
isStandardBrowserEnv: isStandardBrowserEnv, | ||
forEach: forEach, | ||
merge: merge, | ||
extend: extend, | ||
trim: trim, | ||
stripBOM: stripBOM | ||
/** | ||
* Inherit the prototype methods from one constructor into another | ||
* @param {function} constructor | ||
* @param {function} superConstructor | ||
* @param {object} [props] | ||
* @param {object} [descriptors] | ||
* | ||
* @returns {void} | ||
*/ | ||
const inherits = (constructor, superConstructor, props, descriptors) => { | ||
constructor.prototype = Object.create(superConstructor.prototype, descriptors); | ||
constructor.prototype.constructor = constructor; | ||
Object.defineProperty(constructor, 'super', { | ||
value: superConstructor.prototype | ||
}); | ||
props && Object.assign(constructor.prototype, props); | ||
} | ||
/** | ||
* Resolve object with deep prototype chain to a flat object | ||
* @param {Object} sourceObj source object | ||
* @param {Object} [destObj] | ||
* @param {Function|Boolean} [filter] | ||
* @param {Function} [propFilter] | ||
* | ||
* @returns {Object} | ||
*/ | ||
const toFlatObject = (sourceObj, destObj, filter, propFilter) => { | ||
let props; | ||
let i; | ||
let prop; | ||
const merged = {}; | ||
destObj = destObj || {}; | ||
// eslint-disable-next-line no-eq-null,eqeqeq | ||
if (sourceObj == null) return destObj; | ||
do { | ||
props = Object.getOwnPropertyNames(sourceObj); | ||
i = props.length; | ||
while (i-- > 0) { | ||
prop = props[i]; | ||
if ((!propFilter || propFilter(prop, sourceObj, destObj)) && !merged[prop]) { | ||
destObj[prop] = sourceObj[prop]; | ||
merged[prop] = true; | ||
} | ||
} | ||
sourceObj = filter !== false && getPrototypeOf(sourceObj); | ||
} while (sourceObj && (!filter || filter(sourceObj, destObj)) && sourceObj !== Object.prototype); | ||
return destObj; | ||
} | ||
/** | ||
* Determines whether a string ends with the characters of a specified string | ||
* | ||
* @param {String} str | ||
* @param {String} searchString | ||
* @param {Number} [position= 0] | ||
* | ||
* @returns {boolean} | ||
*/ | ||
const endsWith = (str, searchString, position) => { | ||
str = String(str); | ||
if (position === undefined || position > str.length) { | ||
position = str.length; | ||
} | ||
position -= searchString.length; | ||
const lastIndex = str.indexOf(searchString, position); | ||
return lastIndex !== -1 && lastIndex === position; | ||
} | ||
/** | ||
* Returns new array from array like object or null if failed | ||
* | ||
* @param {*} [thing] | ||
* | ||
* @returns {?Array} | ||
*/ | ||
const toArray = (thing) => { | ||
if (!thing) return null; | ||
if (isArray(thing)) return thing; | ||
let i = thing.length; | ||
if (!isNumber(i)) return null; | ||
const arr = new Array(i); | ||
while (i-- > 0) { | ||
arr[i] = thing[i]; | ||
} | ||
return arr; | ||
} | ||
/** | ||
* Checking if the Uint8Array exists and if it does, it returns a function that checks if the | ||
* thing passed in is an instance of Uint8Array | ||
* | ||
* @param {TypedArray} | ||
* | ||
* @returns {Array} | ||
*/ | ||
// eslint-disable-next-line func-names | ||
const isTypedArray = (TypedArray => { | ||
// eslint-disable-next-line func-names | ||
return thing => { | ||
return TypedArray && thing instanceof TypedArray; | ||
}; | ||
})(typeof Uint8Array !== 'undefined' && getPrototypeOf(Uint8Array)); | ||
/** | ||
* For each entry in the object, call the function with the key and value. | ||
* | ||
* @param {Object<any, any>} obj - The object to iterate over. | ||
* @param {Function} fn - The function to call for each entry. | ||
* | ||
* @returns {void} | ||
*/ | ||
const forEachEntry = (obj, fn) => { | ||
const generator = obj && obj[Symbol.iterator]; | ||
const iterator = generator.call(obj); | ||
let result; | ||
while ((result = iterator.next()) && !result.done) { | ||
const pair = result.value; | ||
fn.call(obj, pair[0], pair[1]); | ||
} | ||
} | ||
/** | ||
* It takes a regular expression and a string, and returns an array of all the matches | ||
* | ||
* @param {string} regExp - The regular expression to match against. | ||
* @param {string} str - The string to search. | ||
* | ||
* @returns {Array<boolean>} | ||
*/ | ||
const matchAll = (regExp, str) => { | ||
let matches; | ||
const arr = []; | ||
while ((matches = regExp.exec(str)) !== null) { | ||
arr.push(matches); | ||
} | ||
return arr; | ||
} | ||
/* Checking if the kindOfTest function returns true when passed an HTMLFormElement. */ | ||
const isHTMLForm = kindOfTest('HTMLFormElement'); | ||
const toCamelCase = str => { | ||
return str.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g, | ||
function replacer(m, p1, p2) { | ||
return p1.toUpperCase() + p2; | ||
} | ||
); | ||
}; | ||
/* Creating a function that will check if an object has a property. */ | ||
const hasOwnProperty = (({hasOwnProperty}) => (obj, prop) => hasOwnProperty.call(obj, prop))(Object.prototype); | ||
/** | ||
* Determine if a value is a RegExp object | ||
* | ||
* @param {*} val The value to test | ||
* | ||
* @returns {boolean} True if value is a RegExp object, otherwise false | ||
*/ | ||
const isRegExp = kindOfTest('RegExp'); | ||
const reduceDescriptors = (obj, reducer) => { | ||
const descriptors = Object.getOwnPropertyDescriptors(obj); | ||
const reducedDescriptors = {}; | ||
forEach(descriptors, (descriptor, name) => { | ||
let ret; | ||
if ((ret = reducer(descriptor, name, obj)) !== false) { | ||
reducedDescriptors[name] = ret || descriptor; | ||
} | ||
}); | ||
Object.defineProperties(obj, reducedDescriptors); | ||
} | ||
/** | ||
* Makes all methods read-only | ||
* @param {Object} obj | ||
*/ | ||
const freezeMethods = (obj) => { | ||
reduceDescriptors(obj, (descriptor, name) => { | ||
// skip restricted props in strict mode | ||
if (isFunction(obj) && ['arguments', 'caller', 'callee'].indexOf(name) !== -1) { | ||
return false; | ||
} | ||
const value = obj[name]; | ||
if (!isFunction(value)) return; | ||
descriptor.enumerable = false; | ||
if ('writable' in descriptor) { | ||
descriptor.writable = false; | ||
return; | ||
} | ||
if (!descriptor.set) { | ||
descriptor.set = () => { | ||
throw Error('Can not rewrite read-only method \'' + name + '\''); | ||
}; | ||
} | ||
}); | ||
} | ||
const toObjectSet = (arrayOrString, delimiter) => { | ||
const obj = {}; | ||
const define = (arr) => { | ||
arr.forEach(value => { | ||
obj[value] = true; | ||
}); | ||
} | ||
isArray(arrayOrString) ? define(arrayOrString) : define(String(arrayOrString).split(delimiter)); | ||
return obj; | ||
} | ||
const noop = () => {} | ||
const toFiniteNumber = (value, defaultValue) => { | ||
value = +value; | ||
return Number.isFinite(value) ? value : defaultValue; | ||
} | ||
const ALPHA = 'abcdefghijklmnopqrstuvwxyz' | ||
const DIGIT = '0123456789'; | ||
const ALPHABET = { | ||
DIGIT, | ||
ALPHA, | ||
ALPHA_DIGIT: ALPHA + ALPHA.toUpperCase() + DIGIT | ||
} | ||
const generateString = (size = 16, alphabet = ALPHABET.ALPHA_DIGIT) => { | ||
let str = ''; | ||
const {length} = alphabet; | ||
while (size--) { | ||
str += alphabet[Math.random() * length|0] | ||
} | ||
return str; | ||
} | ||
/** | ||
* If the thing is a FormData object, return true, otherwise return false. | ||
* | ||
* @param {unknown} thing - The thing to check. | ||
* | ||
* @returns {boolean} | ||
*/ | ||
function isSpecCompliantForm(thing) { | ||
return !!(thing && isFunction(thing.append) && thing[Symbol.toStringTag] === 'FormData' && thing[Symbol.iterator]); | ||
} | ||
const toJSONObject = (obj) => { | ||
const stack = new Array(10); | ||
const visit = (source, i) => { | ||
if (isObject(source)) { | ||
if (stack.indexOf(source) >= 0) { | ||
return; | ||
} | ||
if(!('toJSON' in source)) { | ||
stack[i] = source; | ||
const target = isArray(source) ? [] : {}; | ||
forEach(source, (value, key) => { | ||
const reducedValue = visit(value, i + 1); | ||
!isUndefined(reducedValue) && (target[key] = reducedValue); | ||
}); | ||
stack[i] = undefined; | ||
return target; | ||
} | ||
} | ||
return source; | ||
} | ||
return visit(obj, 0); | ||
} | ||
const isAsyncFn = kindOfTest('AsyncFunction'); | ||
const isThenable = (thing) => | ||
thing && (isObject(thing) || isFunction(thing)) && isFunction(thing.then) && isFunction(thing.catch); | ||
export default { | ||
isArray, | ||
isArrayBuffer, | ||
isBuffer, | ||
isFormData, | ||
isArrayBufferView, | ||
isString, | ||
isNumber, | ||
isBoolean, | ||
isObject, | ||
isPlainObject, | ||
isUndefined, | ||
isDate, | ||
isFile, | ||
isBlob, | ||
isRegExp, | ||
isFunction, | ||
isStream, | ||
isURLSearchParams, | ||
isTypedArray, | ||
isFileList, | ||
forEach, | ||
merge, | ||
extend, | ||
trim, | ||
stripBOM, | ||
inherits, | ||
toFlatObject, | ||
kindOf, | ||
kindOfTest, | ||
endsWith, | ||
toArray, | ||
forEachEntry, | ||
matchAll, | ||
isHTMLForm, | ||
hasOwnProperty, | ||
hasOwnProp: hasOwnProperty, // an alias to avoid ESLint no-prototype-builtins detection | ||
reduceDescriptors, | ||
freezeMethods, | ||
toObjectSet, | ||
toCamelCase, | ||
noop, | ||
toFiniteNumber, | ||
findKey, | ||
global: _global, | ||
isContextDefined, | ||
ALPHABET, | ||
generateString, | ||
isSpecCompliantForm, | ||
toJSONObject, | ||
isAsyncFn, | ||
isThenable | ||
}; |
{ | ||
"_from": "axios@0.22.0", | ||
"_id": "axios@0.22.0", | ||
"_from": "axios@^1.6.1", | ||
"_id": "axios@1.6.1", | ||
"_inBundle": false, | ||
"_integrity": "sha512-Z0U3uhqQeg1oNcihswf4ZD57O3NrR1+ZXhxaROaWpDmsDTx7T2HNBV2ulBtie2hwJptu8UvgnJoK+BIqdzh/1w==", | ||
"_integrity": "sha512-vfBmhDpKafglh0EldBEbVuoe7DyAavGSLWhuSm5ZSEKQnHhBf0xAAwybbNH1IkrJNGnS/VG4I5yxig1pCEXE4g==", | ||
"_location": "/axios", | ||
"_phantomChildren": {}, | ||
"_requested": { | ||
"type": "version", | ||
"type": "range", | ||
"registry": true, | ||
"raw": "axios@0.22.0", | ||
"raw": "axios@^1.6.1", | ||
"name": "axios", | ||
"escapedName": "axios", | ||
"rawSpec": "0.22.0", | ||
"rawSpec": "^1.6.1", | ||
"saveSpec": null, | ||
"fetchSpec": "0.22.0" | ||
"fetchSpec": "^1.6.1" | ||
}, | ||
@@ -21,6 +21,6 @@ "_requiredBy": [ | ||
], | ||
"_resolved": "https://registry.npmjs.org/axios/-/axios-0.22.0.tgz", | ||
"_shasum": "bf702c41fb50fbca4539589d839a077117b79b25", | ||
"_spec": "axios@0.22.0", | ||
"_where": "/harness", | ||
"_resolved": "https://registry.npmjs.org/axios/-/axios-1.6.1.tgz", | ||
"_shasum": "76550d644bf0a2d469a01f9244db6753208397d7", | ||
"_spec": "axios@^1.6.1", | ||
"_where": "/Users/erowlands/git/ff-nodejs-server-sdk", | ||
"author": { | ||
@@ -30,3 +30,5 @@ "name": "Matt Zabriskie" | ||
"browser": { | ||
"./lib/adapters/http.js": "./lib/adapters/xhr.js" | ||
"./lib/adapters/http.js": "./lib/helpers/null.js", | ||
"./lib/platform/node/index.js": "./lib/platform/browser/index.js", | ||
"./lib/platform/node/classes/FormData.js": "./lib/helpers/null.js" | ||
}, | ||
@@ -43,4 +45,72 @@ "bugs": { | ||
], | ||
"commitlint": { | ||
"rules": { | ||
"header-max-length": [ | ||
2, | ||
"always", | ||
130 | ||
] | ||
}, | ||
"extends": [ | ||
"@commitlint/config-conventional" | ||
] | ||
}, | ||
"contributors": [ | ||
{ | ||
"name": "Matt Zabriskie", | ||
"url": "https://github.com/mzabriskie" | ||
}, | ||
{ | ||
"name": "Nick Uraltsev", | ||
"url": "https://github.com/nickuraltsev" | ||
}, | ||
{ | ||
"name": "Jay", | ||
"url": "https://github.com/jasonsaayman" | ||
}, | ||
{ | ||
"name": "Dmitriy Mozgovoy", | ||
"url": "https://github.com/DigitalBrainJS" | ||
}, | ||
{ | ||
"name": "Emily Morehouse", | ||
"url": "https://github.com/emilyemorehouse" | ||
}, | ||
{ | ||
"name": "Rubén Norte", | ||
"url": "https://github.com/rubennorte" | ||
}, | ||
{ | ||
"name": "Justin Beckwith", | ||
"url": "https://github.com/JustinBeckwith" | ||
}, | ||
{ | ||
"name": "Martti Laine", | ||
"url": "https://github.com/codeclown" | ||
}, | ||
{ | ||
"name": "Xianming Zhong", | ||
"url": "https://github.com/chinesedfan" | ||
}, | ||
{ | ||
"name": "Rikki Gibson", | ||
"url": "https://github.com/RikkiGibson" | ||
}, | ||
{ | ||
"name": "Remco Haszing", | ||
"url": "https://github.com/remcohaszing" | ||
}, | ||
{ | ||
"name": "Yasu Flores", | ||
"url": "https://github.com/yasuf" | ||
}, | ||
{ | ||
"name": "Ben Carp", | ||
"url": "https://github.com/carpben" | ||
} | ||
], | ||
"dependencies": { | ||
"follow-redirects": "^1.14.4" | ||
"follow-redirects": "^1.15.0", | ||
"form-data": "^4.0.0", | ||
"proxy-from-env": "^1.1.0" | ||
}, | ||
@@ -50,22 +120,39 @@ "deprecated": false, | ||
"devDependencies": { | ||
"abortcontroller-polyfill": "^1.5.0", | ||
"coveralls": "^3.0.0", | ||
"es6-promise": "^4.2.4", | ||
"grunt": "^1.3.0", | ||
"grunt-banner": "^0.6.0", | ||
"grunt-cli": "^1.2.0", | ||
"grunt-contrib-clean": "^1.1.0", | ||
"grunt-contrib-watch": "^1.0.0", | ||
"grunt-eslint": "^23.0.0", | ||
"grunt-karma": "^4.0.0", | ||
"grunt-mocha-test": "^0.13.3", | ||
"grunt-ts": "^6.0.0-beta.19", | ||
"grunt-webpack": "^4.0.2", | ||
"istanbul-instrumenter-loader": "^1.0.0", | ||
"@babel/core": "^7.18.2", | ||
"@babel/preset-env": "^7.18.2", | ||
"@commitlint/cli": "^17.3.0", | ||
"@commitlint/config-conventional": "^17.3.0", | ||
"@release-it/conventional-changelog": "^5.1.1", | ||
"@rollup/plugin-babel": "^5.3.1", | ||
"@rollup/plugin-commonjs": "^15.1.0", | ||
"@rollup/plugin-json": "^4.1.0", | ||
"@rollup/plugin-multi-entry": "^4.0.0", | ||
"@rollup/plugin-node-resolve": "^9.0.0", | ||
"abortcontroller-polyfill": "^1.7.3", | ||
"auto-changelog": "^2.4.0", | ||
"body-parser": "^1.20.0", | ||
"chalk": "^5.2.0", | ||
"coveralls": "^3.1.1", | ||
"cross-env": "^7.0.3", | ||
"dev-null": "^0.1.1", | ||
"dtslint": "^4.2.1", | ||
"es6-promise": "^4.2.8", | ||
"eslint": "^8.17.0", | ||
"express": "^4.18.1", | ||
"formdata-node": "^5.0.0", | ||
"formidable": "^2.0.1", | ||
"fs-extra": "^10.1.0", | ||
"get-stream": "^3.0.0", | ||
"gulp": "^4.0.2", | ||
"gzip-size": "^7.0.0", | ||
"handlebars": "^4.7.7", | ||
"husky": "^8.0.2", | ||
"istanbul-instrumenter-loader": "^3.0.1", | ||
"jasmine-core": "^2.4.1", | ||
"karma": "^6.3.2", | ||
"karma-chrome-launcher": "^3.1.0", | ||
"karma-firefox-launcher": "^2.1.0", | ||
"karma": "^6.3.17", | ||
"karma-chrome-launcher": "^3.1.1", | ||
"karma-firefox-launcher": "^2.1.2", | ||
"karma-jasmine": "^1.1.1", | ||
"karma-jasmine-ajax": "^0.1.13", | ||
"karma-rollup-preprocessor": "^7.0.8", | ||
"karma-safari-launcher": "^1.0.0", | ||
@@ -75,13 +162,46 @@ "karma-sauce-launcher": "^4.3.6", | ||
"karma-sourcemap-loader": "^0.3.8", | ||
"karma-webpack": "^4.0.2", | ||
"load-grunt-tasks": "^3.5.2", | ||
"minimist": "^1.2.0", | ||
"mocha": "^8.2.1", | ||
"memoizee": "^0.4.15", | ||
"minimist": "^1.2.7", | ||
"mocha": "^10.0.0", | ||
"multer": "^1.4.4", | ||
"pretty-bytes": "^6.0.0", | ||
"release-it": "^15.5.1", | ||
"rollup": "^2.67.0", | ||
"rollup-plugin-auto-external": "^2.0.0", | ||
"rollup-plugin-bundle-size": "^1.0.3", | ||
"rollup-plugin-terser": "^7.0.2", | ||
"sinon": "^4.5.0", | ||
"stream-throttle": "^0.1.3", | ||
"string-replace-async": "^3.0.2", | ||
"terser-webpack-plugin": "^4.2.3", | ||
"typescript": "^4.0.5", | ||
"url-search-params": "^0.10.0", | ||
"webpack": "^4.44.2", | ||
"webpack-dev-server": "^3.11.0" | ||
"typescript": "^4.8.4" | ||
}, | ||
"exports": { | ||
".": { | ||
"types": { | ||
"require": "./index.d.cts", | ||
"default": "./index.d.ts" | ||
}, | ||
"browser": { | ||
"require": "./dist/browser/axios.cjs", | ||
"default": "./index.js" | ||
}, | ||
"default": { | ||
"require": "./dist/node/axios.cjs", | ||
"default": "./index.js" | ||
} | ||
}, | ||
"./lib/adapters/http.js": "./lib/adapters/http.js", | ||
"./lib/adapters/xhr.js": "./lib/adapters/xhr.js", | ||
"./unsafe/*": "./lib/*", | ||
"./unsafe/core/settle.js": "./lib/core/settle.js", | ||
"./unsafe/core/buildFullPath.js": "./lib/core/buildFullPath.js", | ||
"./unsafe/helpers/isAbsoluteURL.js": "./lib/helpers/isAbsoluteURL.js", | ||
"./unsafe/helpers/buildURL.js": "./lib/helpers/buildURL.js", | ||
"./unsafe/helpers/combineURLs.js": "./lib/helpers/combineURLs.js", | ||
"./unsafe/adapters/http.js": "./lib/adapters/http.js", | ||
"./unsafe/adapters/xhr.js": "./lib/adapters/xhr.js", | ||
"./unsafe/utils.js": "./lib/utils.js", | ||
"./package.json": "./package.json" | ||
}, | ||
"homepage": "https://axios-http.com", | ||
@@ -99,2 +219,33 @@ "jsdelivr": "dist/axios.min.js", | ||
"name": "axios", | ||
"release-it": { | ||
"git": { | ||
"commitMessage": "chore(release): v${version}", | ||
"push": true, | ||
"commit": true, | ||
"tag": true, | ||
"requireCommits": false, | ||
"requireCleanWorkingDir": false | ||
}, | ||
"github": { | ||
"release": true, | ||
"draft": true | ||
}, | ||
"npm": { | ||
"publish": false, | ||
"ignoreVersion": false | ||
}, | ||
"plugins": { | ||
"@release-it/conventional-changelog": { | ||
"preset": "angular", | ||
"infile": "CHANGELOG.md", | ||
"header": "# Changelog" | ||
} | ||
}, | ||
"hooks": { | ||
"before:init": "npm test", | ||
"after:bump": "gulp version --bump ${version} && npm run build && npm run test:build:version && git add ./dist && git add ./package-lock.json", | ||
"before:release": "npm run release:changelog:fix", | ||
"after:release": "echo Successfully released ${name} v${version} to ${repo.repository}." | ||
} | ||
}, | ||
"repository": { | ||
@@ -105,16 +256,36 @@ "type": "git", | ||
"scripts": { | ||
"build": "NODE_ENV=production grunt build", | ||
"build": "gulp clear && cross-env NODE_ENV=production rollup -c -m", | ||
"coveralls": "cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js", | ||
"examples": "node ./examples/server.js", | ||
"fix": "eslint --fix lib/**/*.js", | ||
"postversion": "git push && git push --tags", | ||
"preversion": "grunt version && npm test", | ||
"postpublish": "git push && git push --tags", | ||
"prepare": "husky install && npm run prepare:hooks", | ||
"prepare:hooks": "npx husky set .husky/commit-msg \"npx commitlint --edit $1\"", | ||
"prepublishOnly": "npm run test:build:version", | ||
"preversion": "gulp version", | ||
"release": "release-it", | ||
"release:beta": "release-it --preRelease=beta", | ||
"release:beta:no-npm": "release-it --preRelease=beta --no-npm", | ||
"release:changelog:fix": "node ./bin/injectContributorsList.js && git add CHANGELOG.md", | ||
"release:dry": "release-it --dry-run --no-npm", | ||
"release:info": "release-it --release-version", | ||
"release:no-npm": "release-it --no-npm", | ||
"start": "node ./sandbox/server.js", | ||
"test": "grunt test", | ||
"version": "npm run build && git add -A dist && git add CHANGELOG.md bower.json package.json" | ||
"test": "npm run test:eslint && npm run test:mocha && npm run test:karma && npm run test:dtslint && npm run test:exports", | ||
"test:build:version": "node ./bin/check-build-version.js", | ||
"test:dtslint": "dtslint --localTs node_modules/typescript/lib", | ||
"test:eslint": "node bin/ssl_hotfix.js eslint lib/**/*.js", | ||
"test:exports": "node bin/ssl_hotfix.js mocha test/module/test.js --timeout 30000 --exit", | ||
"test:karma": "node bin/ssl_hotfix.js cross-env LISTEN_ADDR=:: karma start karma.conf.cjs --single-run", | ||
"test:karma:firefox": "node bin/ssl_hotfix.js cross-env LISTEN_ADDR=:: Browsers=Firefox karma start karma.conf.cjs --single-run", | ||
"test:karma:server": "node bin/ssl_hotfix.js cross-env karma start karma.conf.cjs", | ||
"test:mocha": "node bin/ssl_hotfix.js mocha test/unit/**/*.js --timeout 30000 --exit", | ||
"version": "npm run build && git add dist && git add package.json" | ||
}, | ||
"sideEffects": false, | ||
"type": "module", | ||
"types": "index.d.ts", | ||
"typings": "./index.d.ts", | ||
"unpkg": "dist/axios.min.js", | ||
"version": "0.22.0" | ||
"version": "1.6.1" | ||
} |
@@ -1,17 +0,33 @@ | ||
# axios | ||
<h1 align="center"> | ||
<b> | ||
<a href="https://axios-http.com"><img src="https://axios-http.com/assets/logo.svg" /></a><br> | ||
</b> | ||
</h1> | ||
<p align="center">Promise based HTTP client for the browser and node.js</p> | ||
<p align="center"> | ||
<a href="https://axios-http.com/"><b>Website</b></a> • | ||
<a href="https://axios-http.com/docs/intro"><b>Documentation</b></a> | ||
</p> | ||
<div align="center"> | ||
[![npm version](https://img.shields.io/npm/v/axios.svg?style=flat-square)](https://www.npmjs.org/package/axios) | ||
[![CDNJS](https://img.shields.io/cdnjs/v/axios.svg?style=flat-square)](https://cdnjs.com/libraries/axios) | ||
![Build status](https://github.com/axios/axios/actions/workflows/ci.yml/badge.svg) | ||
[![Gitpod Ready-to-Code](https://img.shields.io/badge/Gitpod-Ready--to--Code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/axios/axios) | ||
[![Build status](https://img.shields.io/github/actions/workflow/status/axios/axios/ci.yml?branch=v1.x&label=CI&logo=github&style=flat-square)](https://github.com/axios/axios/actions/workflows/ci.yml) | ||
[![Gitpod Ready-to-Code](https://img.shields.io/badge/Gitpod-Ready--to--Code-blue?logo=gitpod&style=flat-square)](https://gitpod.io/#https://github.com/axios/axios) | ||
[![code coverage](https://img.shields.io/coveralls/mzabriskie/axios.svg?style=flat-square)](https://coveralls.io/r/mzabriskie/axios) | ||
[![install size](https://packagephobia.now.sh/badge?p=axios)](https://packagephobia.now.sh/result?p=axios) | ||
[![npm downloads](https://img.shields.io/npm/dm/axios.svg?style=flat-square)](http://npm-stat.com/charts.html?package=axios) | ||
[![install size](https://img.shields.io/badge/dynamic/json?url=https://packagephobia.com/v2/api.json?p=axios&query=$.install.pretty&label=install%20size&style=flat-square)](https://packagephobia.now.sh/result?p=axios) | ||
[![npm bundle size](https://img.shields.io/bundlephobia/minzip/axios?style=flat-square)](https://bundlephobia.com/package/axios@latest) | ||
[![npm downloads](https://img.shields.io/npm/dm/axios.svg?style=flat-square)](https://npm-stat.com/charts.html?package=axios) | ||
[![gitter chat](https://img.shields.io/gitter/room/mzabriskie/axios.svg?style=flat-square)](https://gitter.im/mzabriskie/axios) | ||
[![code helpers](https://www.codetriage.com/axios/axios/badges/users.svg)](https://www.codetriage.com/axios/axios) | ||
[![Known Vulnerabilities](https://snyk.io/test/npm/axios/badge.svg)](https://snyk.io/test/npm/axios) | ||
Promise based HTTP client for the browser and node.js | ||
> New axios docs website: [click here](https://axios-http.com/) | ||
</div> | ||
## Table of Contents | ||
@@ -22,6 +38,8 @@ | ||
- [Installing](#installing) | ||
- [Package manager](#package-manager) | ||
- [CDN](#cdn) | ||
- [Example](#example) | ||
- [Axios API](#axios-api) | ||
- [Request method aliases](#request-method-aliases) | ||
- [Concurrency (Deprecated)](#concurrency-deprecated) | ||
- [Concurrency 👎](#concurrency-deprecated) | ||
- [Creating an instance](#creating-an-instance) | ||
@@ -36,9 +54,19 @@ - [Instance methods](#instance-methods) | ||
- [Interceptors](#interceptors) | ||
- [Multiple Interceptors](#multiple-interceptors) | ||
- [Handling Errors](#handling-errors) | ||
- [Cancellation](#cancellation) | ||
- [AbortController](#abortcontroller) | ||
- [CancelToken 👎](#canceltoken-deprecated) | ||
- [Using application/x-www-form-urlencoded format](#using-applicationx-www-form-urlencoded-format) | ||
- [Browser](#browser) | ||
- [Node.js](#nodejs) | ||
- [Query string](#query-string) | ||
- [Form data](#form-data) | ||
- [URLSearchParams](#urlsearchparams) | ||
- [Query string](#query-string-older-browsers) | ||
- [🆕 Automatic serialization](#-automatic-serialization-to-urlsearchparams) | ||
- [Using multipart/form-data format](#using-multipartform-data-format) | ||
- [FormData](#formdata) | ||
- [🆕 Automatic serialization](#-automatic-serialization-to-formdata) | ||
- [Files Posting](#files-posting) | ||
- [HTML Form Posting](#-html-form-posting-browser) | ||
- [🆕 Progress capturing](#-progress-capturing) | ||
- [🆕 Rate limiting](#-progress-capturing) | ||
- [🆕 AxiosHeaders](#-axiosheaders) | ||
- [Semver](#semver) | ||
@@ -54,3 +82,3 @@ - [Promises](#promises) | ||
- Make [XMLHttpRequests](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest) from the browser | ||
- Make [http](http://nodejs.org/api/http.html) requests from node.js | ||
- Make [http](https://nodejs.org/api/http.html) requests from node.js | ||
- Supports the [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) API | ||
@@ -60,8 +88,9 @@ - Intercept request and response | ||
- Cancel requests | ||
- Automatic transforms for JSON data | ||
- Client side support for protecting against [XSRF](http://en.wikipedia.org/wiki/Cross-site_request_forgery) | ||
- Automatic transforms for [JSON](https://www.json.org/json-en.html) data | ||
- 🆕 Automatic data object serialization to `multipart/form-data` and `x-www-form-urlencoded` body encodings | ||
- Client side support for protecting against [XSRF](https://en.wikipedia.org/wiki/Cross-site_request_forgery) | ||
## Browser Support | ||
![Chrome](https://raw.github.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png) | ![Firefox](https://raw.github.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png) | ![Safari](https://raw.github.com/alrra/browser-logos/master/src/safari/safari_48x48.png) | ![Opera](https://raw.github.com/alrra/browser-logos/master/src/opera/opera_48x48.png) | ![Edge](https://raw.github.com/alrra/browser-logos/master/src/edge/edge_48x48.png) | ![IE](https://raw.github.com/alrra/browser-logos/master/src/archive/internet-explorer_9-11/internet-explorer_9-11_48x48.png) | | ||
![Chrome](https://raw.githubusercontent.com/alrra/browser-logos/main/src/chrome/chrome_48x48.png) | ![Firefox](https://raw.githubusercontent.com/alrra/browser-logos/main/src/firefox/firefox_48x48.png) | ![Safari](https://raw.githubusercontent.com/alrra/browser-logos/main/src/safari/safari_48x48.png) | ![Opera](https://raw.githubusercontent.com/alrra/browser-logos/main/src/opera/opera_48x48.png) | ![Edge](https://raw.githubusercontent.com/alrra/browser-logos/main/src/edge/edge_48x48.png) | ![IE](https://raw.githubusercontent.com/alrra/browser-logos/master/src/archive/internet-explorer_9-11/internet-explorer_9-11_48x48.png) | | ||
--- | --- | --- | --- | --- | --- | | ||
@@ -74,2 +103,4 @@ Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | 11 ✔ | | ||
### Package manager | ||
Using npm: | ||
@@ -93,30 +124,61 @@ | ||
Using jsDelivr CDN: | ||
Using pnpm: | ||
```html | ||
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script> | ||
```bash | ||
$ pnpm add axios | ||
``` | ||
Using unpkg CDN: | ||
Once the package is installed, you can import the library using `import` or `require` approach: | ||
```html | ||
<script src="https://unpkg.com/axios/dist/axios.min.js"></script> | ||
```js | ||
import axios, {isCancel, AxiosError} from 'axios'; | ||
``` | ||
## Example | ||
You can also use the default export, since the named export is just a re-export from the Axios factory: | ||
### note: CommonJS usage | ||
In order to gain the TypeScript typings (for intellisense / autocomplete) while using CommonJS imports with `require()` use the following approach: | ||
```js | ||
import axios from 'axios'; | ||
console.log(axios.isCancel('something')); | ||
```` | ||
If you use `require` for importing, **only default export is available**: | ||
```js | ||
const axios = require('axios').default; | ||
const axios = require('axios'); | ||
// axios.<method> will now provide autocomplete and parameter typings | ||
console.log(axios.isCancel('something')); | ||
``` | ||
Performing a `GET` request | ||
For cases where something went wrong when trying to import a module into a custom or legacy environment, | ||
you can try importing the module package directly: | ||
```js | ||
const axios = require('axios'); | ||
const axios = require('axios/dist/browser/axios.cjs'); // browser commonJS bundle (ES2017) | ||
// const axios = require('axios/dist/node/axios.cjs'); // node commonJS bundle (ES2017) | ||
``` | ||
### CDN | ||
Using jsDelivr CDN (ES5 UMD browser module): | ||
```html | ||
<script src="https://cdn.jsdelivr.net/npm/axios@1.1.2/dist/axios.min.js"></script> | ||
``` | ||
Using unpkg CDN: | ||
```html | ||
<script src="https://unpkg.com/axios@1.1.2/dist/axios.min.js"></script> | ||
``` | ||
## Example | ||
> **Note**: CommonJS usage | ||
> In order to gain the TypeScript typings (for intellisense / autocomplete) while using CommonJS imports with `require()`, use the following approach: | ||
```js | ||
import axios from 'axios'; | ||
//const axios = require('axios'); // legacy way | ||
// Make a request for a user with a given ID | ||
@@ -132,3 +194,3 @@ axios.get('/user?ID=12345') | ||
}) | ||
.then(function () { | ||
.finally(function () { | ||
// always executed | ||
@@ -149,5 +211,5 @@ }); | ||
}) | ||
.then(function () { | ||
.finally(function () { | ||
// always executed | ||
}); | ||
}); | ||
@@ -165,3 +227,3 @@ // Want to use async/await? Add the `async` keyword to your outer function/method. | ||
> **NOTE:** `async/await` is part of ECMAScript 2017 and is not supported in Internet | ||
> **Note**: `async/await` is part of ECMAScript 2017 and is not supported in Internet | ||
> Explorer and older browsers, so use with caution. | ||
@@ -224,3 +286,3 @@ | ||
method: 'get', | ||
url: 'http://bit.ly/2mTM3nY', | ||
url: 'https://bit.ly/2mTM3nY', | ||
responseType: 'stream' | ||
@@ -242,3 +304,3 @@ }) | ||
For convenience aliases have been provided for all supported request methods. | ||
For convenience, aliases have been provided for all common request methods. | ||
@@ -337,7 +399,14 @@ ##### axios.request(config) | ||
}, | ||
// `paramsSerializer` is an optional config that allows you to customize serializing `params`. | ||
paramsSerializer: { | ||
// `paramsSerializer` is an optional function in charge of serializing `params` | ||
// (e.g. https://www.npmjs.com/package/qs, http://api.jquery.com/jquery.param/) | ||
paramsSerializer: function (params) { | ||
return Qs.stringify(params, {arrayFormat: 'brackets'}) | ||
//Custom encoder function which sends key/value pairs in an iterative fashion. | ||
encode?: (param: string): string => { /* Do custom operations here and return transformed string */ }, | ||
// Custom serializer function for the entire parameter. Allows user to mimic pre 1.x behaviour. | ||
serialize?: (params: Record<string, any>, options?: ParamsSerializerOptions ), | ||
//Configuration for formatting array indexes in the params. | ||
indexes: false // Three available options: (1) indexes: null (leads to no brackets), (2) (default) indexes: false (leads to empty brackets), (3) indexes: true (leads to brackets with indexes). | ||
}, | ||
@@ -350,7 +419,7 @@ | ||
// - Browser only: FormData, File, Blob | ||
// - Node only: Stream, Buffer | ||
// - Node only: Stream, Buffer, FormData (form-data package) | ||
data: { | ||
firstName: 'Fred' | ||
}, | ||
// syntax alternative to send data into the body | ||
@@ -401,11 +470,11 @@ // method post | ||
// `onUploadProgress` allows handling of progress events for uploads | ||
// browser only | ||
onUploadProgress: function (progressEvent) { | ||
// Do whatever you want with the native progress event | ||
// browser & node.js | ||
onUploadProgress: function ({loaded, total, progress, bytes, estimated, rate, upload = true}) { | ||
// Do whatever you want with the Axios progress event | ||
}, | ||
// `onDownloadProgress` allows handling of progress events for downloads | ||
// browser only | ||
onDownloadProgress: function (progressEvent) { | ||
// Do whatever you want with the native progress event | ||
// browser & node.js | ||
onDownloadProgress: function ({loaded, total, progress, bytes, estimated, rate, download = true}) { | ||
// Do whatever you want with the Axios progress event | ||
}, | ||
@@ -429,4 +498,15 @@ | ||
// If set to 0, no redirects will be followed. | ||
maxRedirects: 5, // default | ||
maxRedirects: 21, // default | ||
// `beforeRedirect` defines a function that will be called before redirect. | ||
// Use this to adjust the request options upon redirecting, | ||
// to inspect the latest response headers, | ||
// or to cancel the request by throwing an error | ||
// If maxRedirects is set to 0, `beforeRedirect` is not used. | ||
beforeRedirect: (options, { headers }) => { | ||
if (options.hostname === "example.com") { | ||
options.auth = "user:password"; | ||
} | ||
}, | ||
// `socketPath` defines a UNIX Socket to be used in node.js. | ||
@@ -437,2 +517,5 @@ // e.g. '/var/run/docker.sock' to send requests to the docker daemon. | ||
socketPath: null, // default | ||
// `transport` determines the transport method that will be used to make the request. If defined, it will be used. Otherwise, if `maxRedirects` is 0, the default `http` or `https` library will be used, depending on the protocol specified in `protocol`. Otherwise, the `httpFollow` or `httpsFollow` library will be used, again depending on the protocol, which can handle redirects. | ||
transport: undefined, // default | ||
@@ -455,6 +538,7 @@ // `httpAgent` and `httpsAgent` define a custom agent to be used when performing http | ||
// `Proxy-Authorization` custom headers you have set using `headers`. | ||
// If the proxy server uses HTTPS, then you must set the protocol to `https`. | ||
// If the proxy server uses HTTPS, then you must set the protocol to `https`. | ||
proxy: { | ||
protocol: 'https', | ||
host: '127.0.0.1', | ||
// hostname: '127.0.0.1' // Takes precedence over 'host' if both are defined | ||
port: 9000, | ||
@@ -475,4 +559,4 @@ auth: { | ||
// `decompress` indicates whether or not the response body should be decompressed | ||
// automatically. If set to `true` will also remove the 'content-encoding' header | ||
// `decompress` indicates whether or not the response body should be decompressed | ||
// automatically. If set to `true` will also remove the 'content-encoding' header | ||
// from the responses objects of all decompressed responses | ||
@@ -499,6 +583,24 @@ // - Node only (XHR cannot turn off decompression) | ||
forcedJSONParsing: true, | ||
// throw ETIMEDOUT error instead of generic ECONNABORTED on request timeouts | ||
clarifyTimeoutError: false, | ||
} | ||
}, | ||
env: { | ||
// The FormData class to be used to automatically serialize the payload into a FormData object | ||
FormData: window?.FormData || global?.FormData | ||
}, | ||
formSerializer: { | ||
visitor: (value, key, path, helpers) => {}; // custom visitor function to serialize form values | ||
dots: boolean; // use dots instead of brackets format | ||
metaTokens: boolean; // keep special endings like {} in parameter key | ||
indexes: boolean; // array indexes format null - no brackets, false - empty brackets, true - brackets with indexes | ||
}, | ||
// http adapter only (node.js) | ||
maxRate: [ | ||
100 * 1024, // 100KB/s upload limit, | ||
100 * 1024 // 100KB/s download limit | ||
] | ||
} | ||
@@ -523,3 +625,3 @@ ``` | ||
// `headers` the HTTP headers that the server responded with | ||
// All header names are lower cased and can be accessed using the bracket notation. | ||
// All header names are lowercase and can be accessed using the bracket notation. | ||
// Example: `response.headers['content-type']` | ||
@@ -583,3 +685,3 @@ headers: {}, | ||
Config will be merged with an order of precedence. The order is library defaults found in [lib/defaults.js](https://github.com/axios/axios/blob/master/lib/defaults.js#L28), then `defaults` property of the instance, and finally `config` argument for the request. The latter will take precedence over the former. Here's an example. | ||
Config will be merged with an order of precedence. The order is library defaults found in [lib/defaults.js](https://github.com/axios/axios/blob/master/lib/defaults/index.js#L28), then `defaults` property of the instance, and finally `config` argument for the request. The latter will take precedence over the former. Here's an example. | ||
@@ -634,2 +736,11 @@ ```js | ||
You can also clear all interceptors for requests or responses. | ||
```js | ||
const instance = axios.create(); | ||
instance.interceptors.request.use(function () {/*...*/}); | ||
instance.interceptors.request.clear(); // Removes interceptors from requests | ||
instance.interceptors.response.use(function () {/*...*/}); | ||
instance.interceptors.response.clear(); // Removes interceptors from responses | ||
``` | ||
You can add interceptors to a custom instance of axios. | ||
@@ -643,3 +754,3 @@ | ||
When you add request interceptors, they are presumed to be asynchronous by default. This can cause a delay | ||
in the execution of your axios request when the main thread is blocked (a promise is created under the hood for | ||
in the execution of your axios request when the main thread is blocked (a promise is created under the hood for | ||
the interceptor and your request gets put on the bottom of the call stack). If your request interceptors are synchronous you can add a flag | ||
@@ -655,3 +766,3 @@ to the options object that will tell axios to run the code synchronously and avoid any delays in request execution. | ||
If you want to execute a particular interceptor based on a runtime check, | ||
If you want to execute a particular interceptor based on a runtime check, | ||
you can add a `runWhen` function to the options object. The interceptor will not be executed **if and only if** the return | ||
@@ -672,4 +783,51 @@ of `runWhen` is `false`. The function will be called with the config | ||
### Multiple Interceptors | ||
Given you add multiple response interceptors | ||
and when the response was fulfilled | ||
- then each interceptor is executed | ||
- then they are executed in the order they were added | ||
- then only the last interceptor's result is returned | ||
- then every interceptor receives the result of its predecessor | ||
- and when the fulfillment-interceptor throws | ||
- then the following fulfillment-interceptor is not called | ||
- then the following rejection-interceptor is called | ||
- once caught, another following fulfill-interceptor is called again (just like in a promise chain). | ||
Read [the interceptor tests](./test/specs/interceptors.spec.js) for seeing all this in code. | ||
## Error Types | ||
There are many different axios error messages that can appear that can provide basic information about the specifics of the error and where opportunities may lie in debugging. | ||
The general structure of axios errors is as follows: | ||
| Property | Definition | | ||
| -------- | ---------- | | ||
| message | A quick summary of the error message and the status it failed with. | | ||
| name | This defines where the error originated from. For axios, it will always be an 'AxiosError'. | | ||
| stack | Provides the stack trace of the error. | | ||
| config | An axios config object with specific instance configurations defined by the user from when the request was made | | ||
| code | Represents an axios identified error. The table below lists out specific definitions for internal axios error. | | ||
| status | HTTP response status code. See [here](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes) for common HTTP response status code meanings. | ||
Below is a list of potential axios identified error | ||
| Code | Definition | | ||
| -------- | ---------- | | ||
| ERR_BAD_OPTION_VALUE | Invalid or unsupported value provided in axios configuration. | | ||
| ERR_BAD_OPTION | Invalid option provided in axios configuration. | | ||
| ECONNABORTED | Request timed out due to exceeding timeout specified in axios configuration. | | ||
| ETIMEDOUT | Request timed out due to exceeding default axios timelimit. | | ||
| ERR_NETWORK | Network-related issue. | ||
| ERR_FR_TOO_MANY_REDIRECTS | Request is redirected too many times; exceeds max redirects specified in axios configuration. | ||
| ERR_DEPRECATED | Deprecated feature or method used in axios. | ||
| ERR_BAD_RESPONSE | Response cannot be parsed properly or is in an unexpected format. | ||
| ERR_BAD_REQUEST | Requested has unexpected format or missing required parameters. | | ||
| ERR_CANCELED | Feature or method is canceled explicitly by the user. | ||
| ERR_NOT_SUPPORT | Feature or method not supported in the current axios environment. | ||
| ERR_INVALID_URL | Invalid URL provided for axios request. | ||
## Handling Errors | ||
the default behavior is to reject every response that returns with a status code that falls out of the range of 2xx and treat it as an error. | ||
```js | ||
@@ -697,3 +855,3 @@ axios.get('/user/12345') | ||
Using the `validateStatus` config option, you can define HTTP code(s) that should throw an error. | ||
Using the `validateStatus` config option, you can override the default condition (status >= 200 && status < 300) and define HTTP code(s) that should throw an error. | ||
@@ -719,6 +877,26 @@ ```js | ||
You can cancel a request using a *cancel token*. | ||
### AbortController | ||
> The axios cancel token API is based on the withdrawn [cancelable promises proposal](https://github.com/tc39/proposal-cancelable-promises). | ||
Starting from `v0.22.0` Axios supports AbortController to cancel requests in fetch API way: | ||
```js | ||
const controller = new AbortController(); | ||
axios.get('/foo/bar', { | ||
signal: controller.signal | ||
}).then(function(response) { | ||
//... | ||
}); | ||
// cancel the request | ||
controller.abort() | ||
``` | ||
### CancelToken `👎deprecated` | ||
You can also cancel a request using a *CancelToken*. | ||
> The axios cancel token API is based on the withdrawn [cancellable promises proposal](https://github.com/tc39/proposal-cancelable-promises). | ||
> This API is deprecated since v0.22.0 and shouldn't be used in new projects | ||
You can create a cancel token using the `CancelToken.source` factory as shown below: | ||
@@ -767,35 +945,23 @@ | ||
Axios supports AbortController to abort requests in [`fetch API`](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API#aborting_a_fetch) way: | ||
```js | ||
const controller = new AbortController(); | ||
> **Note:** you can cancel several requests with the same cancel token/abort controller. | ||
> If a cancellation token is already cancelled at the moment of starting an Axios request, then the request is cancelled immediately, without any attempts to make a real request. | ||
axios.get('/foo/bar', { | ||
signal: controller.signal | ||
}).then(function(response) { | ||
//... | ||
}); | ||
// cancel the request | ||
controller.abort() | ||
``` | ||
> During the transition period, you can use both cancellation APIs, even for the same request: | ||
> Note: you can cancel several requests with the same cancel token/abort controller. | ||
> If a cancellation token is already cancelled at the moment of starting an Axios request, then the request is cancelled immediately, without any attempts to make real request. | ||
## Using `application/x-www-form-urlencoded` format | ||
## Using application/x-www-form-urlencoded format | ||
### URLSearchParams | ||
By default, axios serializes JavaScript objects to `JSON`. To send data in the `application/x-www-form-urlencoded` format instead, you can use one of the following options. | ||
By default, axios serializes JavaScript objects to `JSON`. To send data in the [`application/x-www-form-urlencoded` format](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST) instead, you can use the [`URLSearchParams`](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams) API, which is [supported](http://www.caniuse.com/#feat=urlsearchparams) in the vast majority of browsers,and [ Node](https://nodejs.org/api/url.html#url_class_urlsearchparams) starting with v10 (released in 2018). | ||
### Browser | ||
In a browser, you can use the [`URLSearchParams`](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams) API as follows: | ||
```js | ||
const params = new URLSearchParams(); | ||
params.append('param1', 'value1'); | ||
params.append('param2', 'value2'); | ||
const params = new URLSearchParams({ foo: 'bar' }); | ||
params.append('extraparam', 'value'); | ||
axios.post('/foo', params); | ||
``` | ||
> Note that `URLSearchParams` is not supported by all browsers (see [caniuse.com](http://www.caniuse.com/#feat=urlsearchparams)), but there is a [polyfill](https://github.com/WebReflection/url-search-params) available (make sure to polyfill the global environment). | ||
### Query string (Older browsers) | ||
For compatibility with very old browsers, there is a [polyfill](https://github.com/WebReflection/url-search-params) available (make sure to polyfill the global environment). | ||
Alternatively, you can encode data using the [`qs`](https://github.com/ljharb/qs) library: | ||
@@ -822,28 +988,78 @@ | ||
### Node.js | ||
### Older Node.js versions | ||
#### Query string | ||
For older Node.js engines, you can use the [`querystring`](https://nodejs.org/api/querystring.html) module as follows: | ||
In node.js, you can use the [`querystring`](https://nodejs.org/api/querystring.html) module as follows: | ||
```js | ||
const querystring = require('querystring'); | ||
axios.post('http://something.com/', querystring.stringify({ foo: 'bar' })); | ||
axios.post('https://something.com/', querystring.stringify({ foo: 'bar' })); | ||
``` | ||
or ['URLSearchParams'](https://nodejs.org/api/url.html#url_class_urlsearchparams) from ['url module'](https://nodejs.org/api/url.html) as follows: | ||
You can also use the [`qs`](https://github.com/ljharb/qs) library. | ||
> **Note**: The `qs` library is preferable if you need to stringify nested objects, as the `querystring` method has [known issues](https://github.com/nodejs/node-v0.x-archive/issues/1665) with that use case. | ||
### 🆕 Automatic serialization to URLSearchParams | ||
Axios will automatically serialize the data object to urlencoded format if the content-type header is set to "application/x-www-form-urlencoded". | ||
```js | ||
const url = require('url'); | ||
const params = new url.URLSearchParams({ foo: 'bar' }); | ||
axios.post('http://something.com/', params.toString()); | ||
const data = { | ||
x: 1, | ||
arr: [1, 2, 3], | ||
arr2: [1, [2], 3], | ||
users: [{name: 'Peter', surname: 'Griffin'}, {name: 'Thomas', surname: 'Anderson'}], | ||
}; | ||
await axios.postForm('https://postman-echo.com/post', data, | ||
{headers: {'content-type': 'application/x-www-form-urlencoded'}} | ||
); | ||
``` | ||
You can also use the [`qs`](https://github.com/ljharb/qs) library. | ||
The server will handle it as: | ||
###### NOTE | ||
The `qs` library is preferable if you need to stringify nested objects, as the `querystring` method has known issues with that use case (https://github.com/nodejs/node-v0.x-archive/issues/1665). | ||
```js | ||
{ | ||
x: '1', | ||
'arr[]': [ '1', '2', '3' ], | ||
'arr2[0]': '1', | ||
'arr2[1][0]': '2', | ||
'arr2[2]': '3', | ||
'arr3[]': [ '1', '2', '3' ], | ||
'users[0][name]': 'Peter', | ||
'users[0][surname]': 'griffin', | ||
'users[1][name]': 'Thomas', | ||
'users[1][surname]': 'Anderson' | ||
} | ||
```` | ||
#### Form data | ||
If your backend body-parser (like `body-parser` of `express.js`) supports nested objects decoding, you will get the same object on the server-side automatically | ||
```js | ||
var app = express(); | ||
app.use(bodyParser.urlencoded({ extended: true })); // support encoded bodies | ||
app.post('/', function (req, res, next) { | ||
// echo body as JSON | ||
res.send(JSON.stringify(req.body)); | ||
}); | ||
server = app.listen(3000); | ||
``` | ||
## Using `multipart/form-data` format | ||
### FormData | ||
To send the data as a `multipart/formdata` you need to pass a formData instance as a payload. | ||
Setting the `Content-Type` header is not required as Axios guesses it based on the payload type. | ||
```js | ||
const formData = new FormData(); | ||
formData.append('foo', 'bar'); | ||
axios.post('https://httpbin.org/post', formData); | ||
``` | ||
In node.js, you can use the [`form-data`](https://github.com/form-data/form-data) library as follows: | ||
@@ -853,3 +1069,3 @@ | ||
const FormData = require('form-data'); | ||
const form = new FormData(); | ||
@@ -860,16 +1076,505 @@ form.append('my_field', 'my value'); | ||
axios.post('https://example.com', form, { headers: form.getHeaders() }) | ||
axios.post('https://example.com', form) | ||
``` | ||
Alternatively, use an interceptor: | ||
### 🆕 Automatic serialization to FormData | ||
Starting from `v0.27.0`, Axios supports automatic object serialization to a FormData object if the request `Content-Type` | ||
header is set to `multipart/form-data`. | ||
The following request will submit the data in a FormData format (Browser & Node.js): | ||
```js | ||
axios.interceptors.request.use(config => { | ||
if (config.data instanceof FormData) { | ||
Object.assign(config.headers, config.data.getHeaders()); | ||
import axios from 'axios'; | ||
axios.post('https://httpbin.org/post', {x: 1}, { | ||
headers: { | ||
'Content-Type': 'multipart/form-data' | ||
} | ||
return config; | ||
}).then(({data}) => console.log(data)); | ||
``` | ||
In the `node.js` build, the ([`form-data`](https://github.com/form-data/form-data)) polyfill is used by default. | ||
You can overload the FormData class by setting the `env.FormData` config variable, | ||
but you probably won't need it in most cases: | ||
```js | ||
const axios = require('axios'); | ||
var FormData = require('form-data'); | ||
axios.post('https://httpbin.org/post', {x: 1, buf: new Buffer(10)}, { | ||
headers: { | ||
'Content-Type': 'multipart/form-data' | ||
} | ||
}).then(({data}) => console.log(data)); | ||
``` | ||
Axios FormData serializer supports some special endings to perform the following operations: | ||
- `{}` - serialize the value with JSON.stringify | ||
- `[]` - unwrap the array-like object as separate fields with the same key | ||
> **Note**: unwrap/expand operation will be used by default on arrays and FileList objects | ||
FormData serializer supports additional options via `config.formSerializer: object` property to handle rare cases: | ||
- `visitor: Function` - user-defined visitor function that will be called recursively to serialize the data object | ||
to a `FormData` object by following custom rules. | ||
- `dots: boolean = false` - use dot notation instead of brackets to serialize arrays and objects; | ||
- `metaTokens: boolean = true` - add the special ending (e.g `user{}: '{"name": "John"}'`) in the FormData key. | ||
The back-end body-parser could potentially use this meta-information to automatically parse the value as JSON. | ||
- `indexes: null|false|true = false` - controls how indexes will be added to unwrapped keys of `flat` array-like objects | ||
- `null` - don't add brackets (`arr: 1`, `arr: 2`, `arr: 3`) | ||
- `false`(default) - add empty brackets (`arr[]: 1`, `arr[]: 2`, `arr[]: 3`) | ||
- `true` - add brackets with indexes (`arr[0]: 1`, `arr[1]: 2`, `arr[2]: 3`) | ||
Let's say we have an object like this one: | ||
```js | ||
const obj = { | ||
x: 1, | ||
arr: [1, 2, 3], | ||
arr2: [1, [2], 3], | ||
users: [{name: 'Peter', surname: 'Griffin'}, {name: 'Thomas', surname: 'Anderson'}], | ||
'obj2{}': [{x:1}] | ||
}; | ||
``` | ||
The following steps will be executed by the Axios serializer internally: | ||
```js | ||
const formData = new FormData(); | ||
formData.append('x', '1'); | ||
formData.append('arr[]', '1'); | ||
formData.append('arr[]', '2'); | ||
formData.append('arr[]', '3'); | ||
formData.append('arr2[0]', '1'); | ||
formData.append('arr2[1][0]', '2'); | ||
formData.append('arr2[2]', '3'); | ||
formData.append('users[0][name]', 'Peter'); | ||
formData.append('users[0][surname]', 'Griffin'); | ||
formData.append('users[1][name]', 'Thomas'); | ||
formData.append('users[1][surname]', 'Anderson'); | ||
formData.append('obj2{}', '[{"x":1}]'); | ||
``` | ||
Axios supports the following shortcut methods: `postForm`, `putForm`, `patchForm` | ||
which are just the corresponding http methods with the `Content-Type` header preset to `multipart/form-data`. | ||
## Files Posting | ||
You can easily submit a single file: | ||
```js | ||
await axios.postForm('https://httpbin.org/post', { | ||
'myVar' : 'foo', | ||
'file': document.querySelector('#fileInput').files[0] | ||
}); | ||
``` | ||
or multiple files as `multipart/form-data`: | ||
```js | ||
await axios.postForm('https://httpbin.org/post', { | ||
'files[]': document.querySelector('#fileInput').files | ||
}); | ||
``` | ||
`FileList` object can be passed directly: | ||
```js | ||
await axios.postForm('https://httpbin.org/post', document.querySelector('#fileInput').files) | ||
``` | ||
All files will be sent with the same field names: `files[]`. | ||
## 🆕 HTML Form Posting (browser) | ||
Pass HTML Form element as a payload to submit it as `multipart/form-data` content. | ||
```js | ||
await axios.postForm('https://httpbin.org/post', document.querySelector('#htmlForm')); | ||
``` | ||
`FormData` and `HTMLForm` objects can also be posted as `JSON` by explicitly setting the `Content-Type` header to `application/json`: | ||
```js | ||
await axios.post('https://httpbin.org/post', document.querySelector('#htmlForm'), { | ||
headers: { | ||
'Content-Type': 'application/json' | ||
} | ||
}) | ||
``` | ||
For example, the Form | ||
```html | ||
<form id="form"> | ||
<input type="text" name="foo" value="1"> | ||
<input type="text" name="deep.prop" value="2"> | ||
<input type="text" name="deep prop spaced" value="3"> | ||
<input type="text" name="baz" value="4"> | ||
<input type="text" name="baz" value="5"> | ||
<select name="user.age"> | ||
<option value="value1">Value 1</option> | ||
<option value="value2" selected>Value 2</option> | ||
<option value="value3">Value 3</option> | ||
</select> | ||
<input type="submit" value="Save"> | ||
</form> | ||
``` | ||
will be submitted as the following JSON object: | ||
```js | ||
{ | ||
"foo": "1", | ||
"deep": { | ||
"prop": { | ||
"spaced": "3" | ||
} | ||
}, | ||
"baz": [ | ||
"4", | ||
"5" | ||
], | ||
"user": { | ||
"age": "value2" | ||
} | ||
} | ||
```` | ||
Sending `Blobs`/`Files` as JSON (`base64`) is not currently supported. | ||
## 🆕 Progress capturing | ||
Axios supports both browser and node environments to capture request upload/download progress. | ||
```js | ||
await axios.post(url, data, { | ||
onUploadProgress: function (axiosProgressEvent) { | ||
/*{ | ||
loaded: number; | ||
total?: number; | ||
progress?: number; // in range [0..1] | ||
bytes: number; // how many bytes have been transferred since the last trigger (delta) | ||
estimated?: number; // estimated time in seconds | ||
rate?: number; // upload speed in bytes | ||
upload: true; // upload sign | ||
}*/ | ||
}, | ||
onDownloadProgress: function (axiosProgressEvent) { | ||
/*{ | ||
loaded: number; | ||
total?: number; | ||
progress?: number; | ||
bytes: number; | ||
estimated?: number; | ||
rate?: number; // download speed in bytes | ||
download: true; // download sign | ||
}*/ | ||
} | ||
}); | ||
``` | ||
You can also track stream upload/download progress in node.js: | ||
```js | ||
const {data} = await axios.post(SERVER_URL, readableStream, { | ||
onUploadProgress: ({progress}) => { | ||
console.log((progress * 100).toFixed(2)); | ||
}, | ||
headers: { | ||
'Content-Length': contentLength | ||
}, | ||
maxRedirects: 0 // avoid buffering the entire stream | ||
}); | ||
```` | ||
> **Note:** | ||
> Capturing FormData upload progress is not currently supported in node.js environments. | ||
> **⚠️ Warning** | ||
> It is recommended to disable redirects by setting maxRedirects: 0 to upload the stream in the **node.js** environment, | ||
> as follow-redirects package will buffer the entire stream in RAM without following the "backpressure" algorithm. | ||
## 🆕 Rate limiting | ||
Download and upload rate limits can only be set for the http adapter (node.js): | ||
```js | ||
const {data} = await axios.post(LOCAL_SERVER_URL, myBuffer, { | ||
onUploadProgress: ({progress, rate}) => { | ||
console.log(`Upload [${(progress*100).toFixed(2)}%]: ${(rate / 1024).toFixed(2)}KB/s`) | ||
}, | ||
maxRate: [100 * 1024], // 100KB/s limit | ||
}); | ||
``` | ||
## 🆕 AxiosHeaders | ||
Axios has its own `AxiosHeaders` class to manipulate headers using a Map-like API that guarantees caseless work. | ||
Although HTTP is case-insensitive in headers, Axios will retain the case of the original header for stylistic reasons | ||
and for a workaround when servers mistakenly consider the header's case. | ||
The old approach of directly manipulating headers object is still available, but deprecated and not recommended for future usage. | ||
### Working with headers | ||
An AxiosHeaders object instance can contain different types of internal values. that control setting and merging logic. | ||
The final headers object with string values is obtained by Axios by calling the `toJSON` method. | ||
> Note: By JSON here we mean an object consisting only of string values intended to be sent over the network. | ||
The header value can be one of the following types: | ||
- `string` - normal string value that will be sent to the server | ||
- `null` - skip header when rendering to JSON | ||
- `false` - skip header when rendering to JSON, additionally indicates that `set` method must be called with `rewrite` option set to `true` | ||
to overwrite this value (Axios uses this internally to allow users to opt out of installing certain headers like `User-Agent` or `Content-Type`) | ||
- `undefined` - value is not set | ||
> Note: The header value is considered set if it is not equal to undefined. | ||
The headers object is always initialized inside interceptors and transformers: | ||
```ts | ||
axios.interceptors.request.use((request: InternalAxiosRequestConfig) => { | ||
request.headers.set('My-header', 'value'); | ||
request.headers.set({ | ||
"My-set-header1": "my-set-value1", | ||
"My-set-header2": "my-set-value2" | ||
}); | ||
request.headers.set('User-Agent', false); // disable subsequent setting the header by Axios | ||
request.headers.setContentType('text/plain'); | ||
request.headers['My-set-header2'] = 'newValue' // direct access is deprecated | ||
return request; | ||
} | ||
); | ||
```` | ||
You can iterate over an `AxiosHeaders` instance using a `for...of` statement: | ||
````js | ||
const headers = new AxiosHeaders({ | ||
foo: '1', | ||
bar: '2', | ||
baz: '3' | ||
}); | ||
for(const [header, value] of headers) { | ||
console.log(header, value); | ||
} | ||
// foo 1 | ||
// bar 2 | ||
// baz 3 | ||
```` | ||
### new AxiosHeaders(headers?) | ||
Constructs a new `AxiosHeaders` instance. | ||
``` | ||
constructor(headers?: RawAxiosHeaders | AxiosHeaders | string); | ||
``` | ||
If the headers object is a string, it will be parsed as RAW HTTP headers. | ||
````js | ||
const headers = new AxiosHeaders(` | ||
Host: www.bing.com | ||
User-Agent: curl/7.54.0 | ||
Accept: */*`); | ||
console.log(headers); | ||
// Object [AxiosHeaders] { | ||
// host: 'www.bing.com', | ||
// 'user-agent': 'curl/7.54.0', | ||
// accept: '*/*' | ||
// } | ||
```` | ||
### AxiosHeaders#set | ||
```ts | ||
set(headerName, value: Axios, rewrite?: boolean); | ||
set(headerName, value, rewrite?: (this: AxiosHeaders, value: string, name: string, headers: RawAxiosHeaders) => boolean); | ||
set(headers?: RawAxiosHeaders | AxiosHeaders | string, rewrite?: boolean); | ||
``` | ||
The `rewrite` argument controls the overwriting behavior: | ||
- `false` - do not overwrite if header's value is set (is not `undefined`) | ||
- `undefined` (default) - overwrite the header unless its value is set to `false` | ||
- `true` - rewrite anyway | ||
The option can also accept a user-defined function that determines whether the value should be overwritten or not. | ||
Returns `this`. | ||
### AxiosHeaders#get(header) | ||
``` | ||
get(headerName: string, matcher?: true | AxiosHeaderMatcher): AxiosHeaderValue; | ||
get(headerName: string, parser: RegExp): RegExpExecArray | null; | ||
```` | ||
Returns the internal value of the header. It can take an extra argument to parse the header's value with `RegExp.exec`, | ||
matcher function or internal key-value parser. | ||
```ts | ||
const headers = new AxiosHeaders({ | ||
'Content-Type': 'multipart/form-data; boundary=Asrf456BGe4h' | ||
}); | ||
console.log(headers.get('Content-Type')); | ||
// multipart/form-data; boundary=Asrf456BGe4h | ||
console.log(headers.get('Content-Type', true)); // parse key-value pairs from a string separated with \s,;= delimiters: | ||
// [Object: null prototype] { | ||
// 'multipart/form-data': undefined, | ||
// boundary: 'Asrf456BGe4h' | ||
// } | ||
console.log(headers.get('Content-Type', (value, name, headers) => { | ||
return String(value).replace(/a/g, 'ZZZ'); | ||
})); | ||
// multipZZZrt/form-dZZZtZZZ; boundZZZry=Asrf456BGe4h | ||
console.log(headers.get('Content-Type', /boundary=(\w+)/)?.[0]); | ||
// boundary=Asrf456BGe4h | ||
``` | ||
Returns the value of the header. | ||
### AxiosHeaders#has(header, matcher?) | ||
``` | ||
has(header: string, matcher?: AxiosHeaderMatcher): boolean; | ||
``` | ||
Returns `true` if the header is set (has no `undefined` value). | ||
### AxiosHeaders#delete(header, matcher?) | ||
``` | ||
delete(header: string | string[], matcher?: AxiosHeaderMatcher): boolean; | ||
``` | ||
Returns `true` if at least one header has been removed. | ||
### AxiosHeaders#clear(matcher?) | ||
``` | ||
clear(matcher?: AxiosHeaderMatcher): boolean; | ||
``` | ||
Removes all headers. | ||
Unlike the `delete` method matcher, this optional matcher will be used to match against the header name rather than the value. | ||
```ts | ||
const headers = new AxiosHeaders({ | ||
'foo': '1', | ||
'x-foo': '2', | ||
'x-bar': '3', | ||
}); | ||
console.log(headers.clear(/^x-/)); // true | ||
console.log(headers.toJSON()); // [Object: null prototype] { foo: '1' } | ||
``` | ||
Returns `true` if at least one header has been cleared. | ||
### AxiosHeaders#normalize(format); | ||
If the headers object was changed directly, it can have duplicates with the same name but in different cases. | ||
This method normalizes the headers object by combining duplicate keys into one. | ||
Axios uses this method internally after calling each interceptor. | ||
Set `format` to true for converting headers name to lowercase and capitalize the initial letters (`cOntEnt-type` => `Content-Type`) | ||
```js | ||
const headers = new AxiosHeaders({ | ||
'foo': '1', | ||
}); | ||
headers.Foo = '2'; | ||
headers.FOO = '3'; | ||
console.log(headers.toJSON()); // [Object: null prototype] { foo: '1', Foo: '2', FOO: '3' } | ||
console.log(headers.normalize().toJSON()); // [Object: null prototype] { foo: '3' } | ||
console.log(headers.normalize(true).toJSON()); // [Object: null prototype] { Foo: '3' } | ||
``` | ||
Returns `this`. | ||
### AxiosHeaders#concat(...targets) | ||
``` | ||
concat(...targets: Array<AxiosHeaders | RawAxiosHeaders | string | undefined | null>): AxiosHeaders; | ||
``` | ||
Merges the instance with targets into a new `AxiosHeaders` instance. If the target is a string, it will be parsed as RAW HTTP headers. | ||
Returns a new `AxiosHeaders` instance. | ||
### AxiosHeaders#toJSON(asStrings?) | ||
```` | ||
toJSON(asStrings?: boolean): RawAxiosHeaders; | ||
```` | ||
Resolve all internal headers values into a new null prototype object. | ||
Set `asStrings` to true to resolve arrays as a string containing all elements, separated by commas. | ||
### AxiosHeaders.from(thing?) | ||
```` | ||
from(thing?: AxiosHeaders | RawAxiosHeaders | string): AxiosHeaders; | ||
```` | ||
Returns a new `AxiosHeaders` instance created from the raw headers passed in, | ||
or simply returns the given headers object if it's an `AxiosHeaders` instance. | ||
### AxiosHeaders.concat(...targets) | ||
```` | ||
concat(...targets: Array<AxiosHeaders | RawAxiosHeaders | string | undefined | null>): AxiosHeaders; | ||
```` | ||
Returns a new `AxiosHeaders` instance created by merging the target objects. | ||
### Shortcuts | ||
The following shortcuts are available: | ||
- `setContentType`, `getContentType`, `hasContentType` | ||
- `setContentLength`, `getContentLength`, `hasContentLength` | ||
- `setAccept`, `getAccept`, `hasAccept` | ||
- `setUserAgent`, `getUserAgent`, `hasUserAgent` | ||
- `setContentEncoding`, `getContentEncoding`, `hasContentEncoding` | ||
## Semver | ||
@@ -881,3 +1586,3 @@ | ||
axios depends on a native ES6 Promise implementation to be [supported](http://caniuse.com/promises). | ||
axios depends on a native ES6 Promise implementation to be [supported](https://caniuse.com/promises). | ||
If your environment doesn't support ES6 Promises, you can [polyfill](https://github.com/jakearchibald/es6-promise). | ||
@@ -887,3 +1592,3 @@ | ||
axios includes [TypeScript](http://typescriptlang.org) definitions and a type guard for axios errors. | ||
axios includes [TypeScript](https://typescriptlang.org) definitions and a type guard for axios errors. | ||
@@ -904,7 +1609,13 @@ ```typescript | ||
Because axios dual publishes with an ESM default export and a CJS `module.exports`, there are some caveats. | ||
The recommended setting is to use `"moduleResolution": "node16"` (this is implied by `"module": "node16"`). Note that this requires TypeScript 4.7 or greater. | ||
If use ESM, your settings should be fine. | ||
If you compile TypeScript to CJS and you can’t use `"moduleResolution": "node 16"`, you have to enable `esModuleInterop`. | ||
If you use TypeScript to type check CJS JavaScript code, your only option is to use `"moduleResolution": "node16"`. | ||
## Online one-click setup | ||
You can use Gitpod an online IDE(which is free for Open Source) for contributing or running the examples online. | ||
You can use Gitpod, an online IDE(which is free for Open Source) for contributing or running the examples online. | ||
[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/axios/axios/blob/master/examples/server.js) | ||
[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/axios/axios/blob/main/examples/server.js) | ||
@@ -914,11 +1625,10 @@ | ||
* [Changelog](https://github.com/axios/axios/blob/master/CHANGELOG.md) | ||
* [Upgrade Guide](https://github.com/axios/axios/blob/master/UPGRADE_GUIDE.md) | ||
* [Ecosystem](https://github.com/axios/axios/blob/master/ECOSYSTEM.md) | ||
* [Contributing Guide](https://github.com/axios/axios/blob/master/CONTRIBUTING.md) | ||
* [Code of Conduct](https://github.com/axios/axios/blob/master/CODE_OF_CONDUCT.md) | ||
* [Changelog](https://github.com/axios/axios/blob/v1.x/CHANGELOG.md) | ||
* [Ecosystem](https://github.com/axios/axios/blob/v1.x/ECOSYSTEM.md) | ||
* [Contributing Guide](https://github.com/axios/axios/blob/v1.x/CONTRIBUTING.md) | ||
* [Code of Conduct](https://github.com/axios/axios/blob/v1.x/CODE_OF_CONDUCT.md) | ||
## Credits | ||
axios is heavily inspired by the [$http service](https://docs.angularjs.org/api/ng/service/$http) provided in [Angular](https://angularjs.org/). Ultimately axios is an effort to provide a standalone `$http`-like service for use outside of Angular. | ||
axios is heavily inspired by the [$http service](https://docs.angularjs.org/api/ng/service/$http) provided in [AngularJS](https://angularjs.org/). Ultimately axios is an effort to provide a standalone `$http`-like service for use outside of AngularJS. | ||
@@ -925,0 +1635,0 @@ ## License |
@@ -1,5 +0,6 @@ | ||
# Security Policy | ||
# Reporting a Vulnerability | ||
## Reporting a Vulnerability | ||
If you discover a security vulnerability in axios please disclose it via [our huntr page](https://huntr.dev/repos/axios/axios/). Bounty eligibility, CVE assignment, response times and past reports are all there. | ||
Please report security issues to jasonsaayman@gmail.com | ||
Thank you for improving the security of axios. |
{ | ||
"_from": "debug@4.3.4", | ||
"_from": "debug@^4.1.1", | ||
"_id": "debug@4.3.4", | ||
@@ -9,10 +9,10 @@ "_inBundle": false, | ||
"_requested": { | ||
"type": "version", | ||
"type": "range", | ||
"registry": true, | ||
"raw": "debug@4.3.4", | ||
"raw": "debug@^4.1.1", | ||
"name": "debug", | ||
"escapedName": "debug", | ||
"rawSpec": "4.3.4", | ||
"rawSpec": "^4.1.1", | ||
"saveSpec": null, | ||
"fetchSpec": "4.3.4" | ||
"fetchSpec": "^4.1.1" | ||
}, | ||
@@ -36,4 +36,4 @@ "_requiredBy": [ | ||
"_shasum": "1319f6579357f2338d3337d2cdd4914bb5dcc865", | ||
"_spec": "debug@4.3.4", | ||
"_where": "/harness", | ||
"_spec": "debug@^4.1.1", | ||
"_where": "/Users/erowlands/git/ff-nodejs-server-sdk/node_modules/keyv-file", | ||
"author": { | ||
@@ -40,0 +40,0 @@ "name": "Josh Junon", |
{ | ||
"_from": "graceful-fs@4.2.6", | ||
"_id": "graceful-fs@4.2.6", | ||
"_inBundle": false, | ||
"_integrity": "sha512-nTnJ528pbqxYanhpDYsi4Rd8MAeaBA67+RZ10CM1m3bTAVFEDcd5AuA4a6W5YkGZ1iNXHzZz8T6TBKLeBuNriQ==", | ||
"_location": "/graceful-fs", | ||
"_phantomChildren": {}, | ||
"_requested": { | ||
"type": "version", | ||
"registry": true, | ||
"raw": "graceful-fs@4.2.6", | ||
"name": "graceful-fs", | ||
"escapedName": "graceful-fs", | ||
"rawSpec": "4.2.6", | ||
"saveSpec": null, | ||
"fetchSpec": "4.2.6" | ||
}, | ||
"_requiredBy": [ | ||
"/@jest/core", | ||
"/@jest/reporters", | ||
"/@jest/source-map", | ||
"/@jest/test-sequencer", | ||
"/@jest/transform", | ||
"/babel-jest", | ||
"/fs-extra", | ||
"/jest-config", | ||
"/jest-haste-map", | ||
"/jest-message-util", | ||
"/jest-resolve", | ||
"/jest-runner", | ||
"/jest-runtime", | ||
"/jest-serializer", | ||
"/jest-snapshot", | ||
"/jest-util", | ||
"/jest/jest-cli", | ||
"/jsonfile", | ||
"/keyv-file/fs-extra", | ||
"/keyv-file/jsonfile" | ||
], | ||
"_resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.6.tgz", | ||
"_shasum": "ff040b2b0853b23c3d31027523706f1885d76bee", | ||
"_spec": "graceful-fs@4.2.6", | ||
"_where": "/harness", | ||
"bugs": { | ||
"url": "https://github.com/isaacs/node-graceful-fs/issues" | ||
}, | ||
"bundleDependencies": false, | ||
"deprecated": false, | ||
"name": "graceful-fs", | ||
"description": "A drop-in replacement for fs, making various improvements.", | ||
"devDependencies": { | ||
"import-fresh": "^2.0.0", | ||
"mkdirp": "^0.5.0", | ||
"rimraf": "^2.2.8", | ||
"tap": "^12.7.0" | ||
"version": "4.2.6", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/isaacs/node-graceful-fs" | ||
}, | ||
"main": "graceful-fs.js", | ||
"directories": { | ||
"test": "test" | ||
}, | ||
"files": [ | ||
"fs.js", | ||
"graceful-fs.js", | ||
"legacy-streams.js", | ||
"polyfills.js", | ||
"clone.js" | ||
], | ||
"homepage": "https://github.com/isaacs/node-graceful-fs#readme", | ||
"scripts": { | ||
"preversion": "npm test", | ||
"postversion": "npm publish", | ||
"postpublish": "git push origin --follow-tags", | ||
"test": "nyc --silent node test.js | tap -c -", | ||
"posttest": "nyc report" | ||
}, | ||
"keywords": [ | ||
@@ -84,16 +37,15 @@ "fs", | ||
"license": "ISC", | ||
"main": "graceful-fs.js", | ||
"name": "graceful-fs", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/isaacs/node-graceful-fs.git" | ||
"devDependencies": { | ||
"import-fresh": "^2.0.0", | ||
"mkdirp": "^0.5.0", | ||
"rimraf": "^2.2.8", | ||
"tap": "^12.7.0" | ||
}, | ||
"scripts": { | ||
"postpublish": "git push origin --follow-tags", | ||
"posttest": "nyc report", | ||
"postversion": "npm publish", | ||
"preversion": "npm test", | ||
"test": "nyc --silent node test.js | tap -c -" | ||
}, | ||
"version": "4.2.6" | ||
"files": [ | ||
"fs.js", | ||
"graceful-fs.js", | ||
"legacy-streams.js", | ||
"polyfills.js", | ||
"clone.js" | ||
] | ||
} |
@@ -24,3 +24,3 @@ { | ||
"_spec": "json-buffer@3.0.1", | ||
"_where": "/harness", | ||
"_where": "/Users/erowlands/git/ff-nodejs-server-sdk/node_modules/keyv", | ||
"author": { | ||
@@ -27,0 +27,0 @@ "name": "Dominic Tarr", |
{ | ||
"_from": "fs-extra@4.0.3", | ||
"_id": "fs-extra@4.0.3", | ||
"_inBundle": false, | ||
"_integrity": "sha512-q6rbdDd1o2mAnQreO7YADIxf/Whx4AHBiRf6d+/cVT8h44ss+lHgxf1FemcqDnQt9X3ct4McHr+JMGlYSsK7Cg==", | ||
"_location": "/keyv-file/fs-extra", | ||
"_phantomChildren": {}, | ||
"_requested": { | ||
"type": "version", | ||
"registry": true, | ||
"raw": "fs-extra@4.0.3", | ||
"name": "fs-extra", | ||
"escapedName": "fs-extra", | ||
"rawSpec": "4.0.3", | ||
"saveSpec": null, | ||
"fetchSpec": "4.0.3" | ||
}, | ||
"_requiredBy": [ | ||
"/keyv-file" | ||
], | ||
"_resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-4.0.3.tgz", | ||
"_shasum": "0d852122e5bc5beb453fb028e9c0c9bf36340c94", | ||
"_spec": "fs-extra@4.0.3", | ||
"_where": "/harness", | ||
"author": { | ||
"name": "JP Richardson", | ||
"email": "jprichardson@gmail.com" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/jprichardson/node-fs-extra/issues" | ||
}, | ||
"bundleDependencies": false, | ||
"dependencies": { | ||
"graceful-fs": "^4.1.2", | ||
"jsonfile": "^4.0.0", | ||
"universalify": "^0.1.0" | ||
}, | ||
"deprecated": false, | ||
"name": "fs-extra", | ||
"version": "4.0.3", | ||
"description": "fs-extra contains methods that aren't included in the vanilla Node.js fs package. Such as mkdir -p, cp -r, and rm -rf.", | ||
"devDependencies": { | ||
"coveralls": "^2.11.2", | ||
"istanbul": "^0.4.5", | ||
"klaw": "^1.0.0", | ||
"klaw-sync": "^1.1.2", | ||
"minimist": "^1.1.1", | ||
"mocha": "^3.1.2", | ||
"proxyquire": "^1.7.10", | ||
"read-dir-files": "^0.1.1", | ||
"rimraf": "^2.2.8", | ||
"secure-random": "^1.1.1", | ||
"semver": "^5.3.0", | ||
"standard": "^10.0.2", | ||
"standard-markdown": "^4.0.1" | ||
"homepage": "https://github.com/jprichardson/node-fs-extra", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/jprichardson/node-fs-extra" | ||
}, | ||
"homepage": "https://github.com/jprichardson/node-fs-extra", | ||
"keywords": [ | ||
@@ -79,9 +33,25 @@ "fs", | ||
], | ||
"author": "JP Richardson <jprichardson@gmail.com>", | ||
"license": "MIT", | ||
"dependencies": { | ||
"graceful-fs": "^4.1.2", | ||
"jsonfile": "^4.0.0", | ||
"universalify": "^0.1.0" | ||
}, | ||
"devDependencies": { | ||
"coveralls": "^2.11.2", | ||
"istanbul": "^0.4.5", | ||
"klaw": "^1.0.0", | ||
"klaw-sync": "^1.1.2", | ||
"minimist": "^1.1.1", | ||
"mocha": "^3.1.2", | ||
"proxyquire": "^1.7.10", | ||
"read-dir-files": "^0.1.1", | ||
"rimraf": "^2.2.8", | ||
"secure-random": "^1.1.1", | ||
"semver": "^5.3.0", | ||
"standard": "^10.0.2", | ||
"standard-markdown": "^4.0.1" | ||
}, | ||
"main": "./lib/index.js", | ||
"name": "fs-extra", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/jprichardson/node-fs-extra.git" | ||
}, | ||
"scripts": { | ||
@@ -91,7 +61,6 @@ "coverage": "istanbul cover -i 'lib/**' -x '**/__tests__/**' test.js", | ||
"lint": "standard && standard-markdown", | ||
"test-find": "find ./lib/**/__tests__ -name *.test.js | xargs mocha", | ||
"test": "npm run lint && npm run unit", | ||
"test-find": "find ./lib/**/__tests__ -name *.test.js | xargs mocha", | ||
"unit": "node test.js" | ||
}, | ||
"version": "4.0.3" | ||
} | ||
} |
{ | ||
"_from": "jsonfile@4.0.0", | ||
"_id": "jsonfile@4.0.0", | ||
"_inBundle": false, | ||
"_integrity": "sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg==", | ||
"_location": "/keyv-file/jsonfile", | ||
"_phantomChildren": {}, | ||
"_requested": { | ||
"type": "version", | ||
"registry": true, | ||
"raw": "jsonfile@4.0.0", | ||
"name": "jsonfile", | ||
"escapedName": "jsonfile", | ||
"rawSpec": "4.0.0", | ||
"saveSpec": null, | ||
"fetchSpec": "4.0.0" | ||
}, | ||
"_requiredBy": [ | ||
"/keyv-file/fs-extra" | ||
], | ||
"_resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", | ||
"_shasum": "8771aae0799b64076b76640fca058f9c10e33ecb", | ||
"_spec": "jsonfile@4.0.0", | ||
"_where": "/harness", | ||
"author": { | ||
"name": "JP Richardson", | ||
"email": "jprichardson@gmail.com" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/jprichardson/node-jsonfile/issues" | ||
}, | ||
"bundleDependencies": false, | ||
"dependencies": { | ||
"graceful-fs": "^4.1.6" | ||
}, | ||
"deprecated": false, | ||
"name": "jsonfile", | ||
"version": "4.0.0", | ||
"description": "Easily read/write JSON files.", | ||
"devDependencies": { | ||
"mocha": "2.x", | ||
"rimraf": "^2.4.0", | ||
"standard": "^10.0.3" | ||
"repository": { | ||
"type": "git", | ||
"url": "git@github.com:jprichardson/node-jsonfile.git" | ||
}, | ||
"files": [ | ||
"index.js" | ||
], | ||
"homepage": "https://github.com/jprichardson/node-jsonfile#readme", | ||
"keywords": [ | ||
@@ -55,12 +17,17 @@ "read", | ||
], | ||
"author": "JP Richardson <jprichardson@gmail.com>", | ||
"license": "MIT", | ||
"main": "index.js", | ||
"name": "jsonfile", | ||
"dependencies": {}, | ||
"optionalDependencies": { | ||
"graceful-fs": "^4.1.6" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+ssh://git@github.com/jprichardson/node-jsonfile.git" | ||
"devDependencies": { | ||
"mocha": "2.x", | ||
"rimraf": "^2.4.0", | ||
"standard": "^10.0.3" | ||
}, | ||
"main": "index.js", | ||
"files": [ | ||
"index.js" | ||
], | ||
"scripts": { | ||
@@ -70,4 +37,3 @@ "lint": "standard", | ||
"unit": "mocha" | ||
}, | ||
"version": "4.0.0" | ||
} | ||
} |
{ | ||
"_from": "tslib@1.14.1", | ||
"_from": "tslib@^1.9.3", | ||
"_id": "tslib@1.14.1", | ||
@@ -9,10 +9,10 @@ "_inBundle": false, | ||
"_requested": { | ||
"type": "version", | ||
"type": "range", | ||
"registry": true, | ||
"raw": "tslib@1.14.1", | ||
"raw": "tslib@^1.9.3", | ||
"name": "tslib", | ||
"escapedName": "tslib", | ||
"rawSpec": "1.14.1", | ||
"rawSpec": "^1.9.3", | ||
"saveSpec": null, | ||
"fetchSpec": "1.14.1" | ||
"fetchSpec": "^1.9.3" | ||
}, | ||
@@ -24,4 +24,4 @@ "_requiredBy": [ | ||
"_shasum": "cf2d38bdc34a134bcaf1091c41f6619e2f672d00", | ||
"_spec": "tslib@1.14.1", | ||
"_where": "/harness", | ||
"_spec": "tslib@^1.9.3", | ||
"_where": "/Users/erowlands/git/ff-nodejs-server-sdk/node_modules/keyv-file", | ||
"author": { | ||
@@ -28,0 +28,0 @@ "name": "Microsoft Corp." |
{ | ||
"_from": "keyv-file@0.2.0", | ||
"_from": "keyv-file@^0.2.0", | ||
"_id": "keyv-file@0.2.0", | ||
@@ -7,15 +7,12 @@ "_inBundle": false, | ||
"_location": "/keyv-file", | ||
"_phantomChildren": { | ||
"graceful-fs": "4.2.6", | ||
"universalify": "0.1.2" | ||
}, | ||
"_phantomChildren": {}, | ||
"_requested": { | ||
"type": "version", | ||
"type": "range", | ||
"registry": true, | ||
"raw": "keyv-file@0.2.0", | ||
"raw": "keyv-file@^0.2.0", | ||
"name": "keyv-file", | ||
"escapedName": "keyv-file", | ||
"rawSpec": "0.2.0", | ||
"rawSpec": "^0.2.0", | ||
"saveSpec": null, | ||
"fetchSpec": "0.2.0" | ||
"fetchSpec": "^0.2.0" | ||
}, | ||
@@ -27,4 +24,4 @@ "_requiredBy": [ | ||
"_shasum": "3442b07a00c1d7bd0242f4a91bcf498afbd6ea6a", | ||
"_spec": "keyv-file@0.2.0", | ||
"_where": "/harness", | ||
"_spec": "keyv-file@^0.2.0", | ||
"_where": "/Users/erowlands/git/ff-nodejs-server-sdk", | ||
"author": { | ||
@@ -31,0 +28,0 @@ "name": "zaaack" |
{ | ||
"_from": "keyv@4.0.3", | ||
"_id": "keyv@4.0.3", | ||
"_inBundle": false, | ||
"_integrity": "sha512-zdGa2TOpSZPq5mU6iowDARnMBZgtCqJ11dJROFi6tg6kTn4nuUdU09lFyLFSaHrWqpIJ+EBq4E8/Dc0Vx5vLdA==", | ||
"_location": "/keyv", | ||
"_phantomChildren": {}, | ||
"_requested": { | ||
"type": "version", | ||
"registry": true, | ||
"raw": "keyv@4.0.3", | ||
"name": "keyv", | ||
"escapedName": "keyv", | ||
"rawSpec": "4.0.3", | ||
"saveSpec": null, | ||
"fetchSpec": "4.0.3" | ||
"name": "keyv", | ||
"version": "4.0.3", | ||
"description": "Simple key-value storage with support for multiple backends", | ||
"main": "src/index.js", | ||
"scripts": { | ||
"test": "xo && nyc ava test/keyv.js", | ||
"test:full": "xo && nyc ava --serial", | ||
"coverage": "nyc report --reporter=text-lcov | coveralls" | ||
}, | ||
"_requiredBy": [ | ||
"/" | ||
"xo": { | ||
"extends": "xo-lukechilds" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/lukechilds/keyv.git" | ||
}, | ||
"keywords": [ | ||
"key", | ||
"value", | ||
"store", | ||
"cache", | ||
"ttl" | ||
], | ||
"_resolved": "https://registry.npmjs.org/keyv/-/keyv-4.0.3.tgz", | ||
"_shasum": "4f3aa98de254803cafcd2896734108daa35e4254", | ||
"_spec": "keyv@4.0.3", | ||
"_where": "/harness", | ||
"author": { | ||
"name": "Luke Childs", | ||
"email": "lukechilds123@gmail.com", | ||
"url": "http://lukechilds.co.uk" | ||
}, | ||
"author": "Luke Childs <lukechilds123@gmail.com> (http://lukechilds.co.uk)", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/lukechilds/keyv/issues" | ||
}, | ||
"bundleDependencies": false, | ||
"homepage": "https://github.com/lukechilds/keyv", | ||
"dependencies": { | ||
"json-buffer": "3.0.1" | ||
}, | ||
"deprecated": false, | ||
"description": "Simple key-value storage with support for multiple backends", | ||
"devDependencies": { | ||
"ava": "^2.2.0", | ||
"coveralls": "^3.0.0", | ||
"eslint-config-xo-lukechilds": "^1.0.0", | ||
"@keyv/mongo": "*", | ||
@@ -46,5 +44,2 @@ "@keyv/mysql": "*", | ||
"@keyv/test-suite": "*", | ||
"ava": "^2.2.0", | ||
"coveralls": "^3.0.0", | ||
"eslint-config-xo-lukechilds": "^1.0.0", | ||
"nyc": "^14.1.1", | ||
@@ -54,27 +49,3 @@ "this": "^1.0.2", | ||
"xo": "^0.25.3" | ||
}, | ||
"homepage": "https://github.com/lukechilds/keyv", | ||
"keywords": [ | ||
"key", | ||
"value", | ||
"store", | ||
"cache", | ||
"ttl" | ||
], | ||
"license": "MIT", | ||
"main": "src/index.js", | ||
"name": "keyv", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/lukechilds/keyv.git" | ||
}, | ||
"scripts": { | ||
"coverage": "nyc report --reporter=text-lcov | coveralls", | ||
"test": "xo && nyc ava test/keyv.js", | ||
"test:full": "xo && nyc ava --serial" | ||
}, | ||
"version": "4.0.3", | ||
"xo": { | ||
"extends": "xo-lukechilds" | ||
} | ||
} |
@@ -24,3 +24,3 @@ { | ||
"_spec": "ms@2.1.2", | ||
"_where": "/harness", | ||
"_where": "/Users/erowlands/git/ff-nodejs-server-sdk/node_modules/debug", | ||
"bugs": { | ||
@@ -27,0 +27,0 @@ "url": "https://github.com/zeit/ms/issues" |
{ | ||
"_from": "universalify@0.1.2", | ||
"_from": "universalify@^0.1.0", | ||
"_id": "universalify@0.1.2", | ||
@@ -9,19 +9,18 @@ "_inBundle": false, | ||
"_requested": { | ||
"type": "version", | ||
"type": "range", | ||
"registry": true, | ||
"raw": "universalify@0.1.2", | ||
"raw": "universalify@^0.1.0", | ||
"name": "universalify", | ||
"escapedName": "universalify", | ||
"rawSpec": "0.1.2", | ||
"rawSpec": "^0.1.0", | ||
"saveSpec": null, | ||
"fetchSpec": "0.1.2" | ||
"fetchSpec": "^0.1.0" | ||
}, | ||
"_requiredBy": [ | ||
"/keyv-file/fs-extra", | ||
"/tough-cookie" | ||
"/fs-extra" | ||
], | ||
"_resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", | ||
"_shasum": "b646f69be3942dabcecc9d6639c80dc105efaa66", | ||
"_spec": "universalify@0.1.2", | ||
"_where": "/harness", | ||
"_spec": "universalify@^0.1.0", | ||
"_where": "/Users/erowlands/git/ff-nodejs-server-sdk/node_modules/fs-extra", | ||
"author": { | ||
@@ -28,0 +27,0 @@ "name": "Ryan Zimmerman", |
{ | ||
"name": "@harnessio/ff-nodejs-server-sdk", | ||
"version": "1.3.6", | ||
"version": "1.3.7-rc.1", | ||
"description": "Feature flags SDK for NodeJS environments", | ||
@@ -64,3 +64,3 @@ "main": "dist/cjs/index.js", | ||
"dependencies": { | ||
"axios": "^0.22.0", | ||
"axios": "^1.6.1", | ||
"axios-retry": "^3.2.0", | ||
@@ -67,0 +67,0 @@ "jwt-decode": "^3.1.2", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 4 instances in 1 package
3156517
287
34040
2
22
13
Updatedaxios@^1.6.1