Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

get-it

Package Overview
Dependencies
Maintainers
0
Versions
161
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

get-it - npm Package Compare versions

Comparing version 8.6.5 to 8.6.6-canary.0

2

dist/_chunks-es/createRequester.js

@@ -1,1 +0,1 @@

import{p as e,v as t}from"./defaultOptionsValidator.js";const r=["request","response","progress","error","abort"],o=["processOptions","validateOptions","interceptRequest","finalizeOptions","onRequest","onResponse","onError","onReturn","onHeaders"];function n(s,i){const u=[],a=o.reduce(((e,t)=>(e[t]=e[t]||[],e)),{processOptions:[e],validateOptions:[t]});function c(e){const t=r.reduce(((e,t)=>(e[t]=function(){const e=Object.create(null);let t=0;return{publish:function(t){for(const r in e)e[r](t)},subscribe:function(r){const o=t++;return e[o]=r,function(){delete e[o]}}}}(),e)),{}),o=(e=>function(t,r,...o){const n="onError"===t;let s=r;for(let r=0;r<e[t].length&&(s=(0,e[t][r])(s,...o),!n||s);r++);return s})(a),n=o("processOptions",e);o("validateOptions",n);const s={options:n,channels:t,applyMiddleware:o};let u;const c=t.request.subscribe((e=>{u=i(e,((r,n)=>((e,r,n)=>{let s=e,i=r;if(!s)try{i=o("onResponse",r,n)}catch(e){i=null,s=e}s=s&&o("onError",s,n),s?t.error.publish(s):i&&t.response.publish(i)})(r,n,e)))}));t.abort.subscribe((()=>{c(),u&&u.abort()}));const l=o("onReturn",t,s);return l===t&&t.request.publish(s),l}return c.use=function(e){if(!e)throw new Error("Tried to add middleware that resolved to falsey value");if("function"==typeof e)throw new Error("Tried to add middleware that was a function. It probably expects you to pass options to it.");if(e.onReturn&&a.onReturn.length>0)throw new Error("Tried to add new middleware with `onReturn` handler, but another handler has already been registered for this event");return o.forEach((t=>{e[t]&&a[t].push(e[t])})),u.push(e),c},c.clone=()=>n(u,i),s.forEach(c.use),c}export{n as c};//# sourceMappingURL=createRequester.js.map
import{p as e,v as t}from"./defaultOptionsValidator.js";const r=["request","response","progress","error","abort"],o=["processOptions","validateOptions","interceptRequest","finalizeOptions","onRequest","onResponse","onError","onReturn","onHeaders"];function n(s,i){const u=[],a=o.reduce(((e,t)=>(e[t]=e[t]||[],e)),{processOptions:[e],validateOptions:[t]});function c(e){const t=r.reduce(((e,t)=>(e[t]=function(){const e=/* @__PURE__ */Object.create(null);let t=0;return{publish:function(t){for(const r in e)e[r](t)},subscribe:function(r){const o=t++;return e[o]=r,function(){delete e[o]}}}}(),e)),{}),o=(e=>function(t,r,...o){const n="onError"===t;let s=r;for(let r=0;r<e[t].length&&(s=(0,e[t][r])(s,...o),!n||s);r++);return s})(a),n=o("processOptions",e);o("validateOptions",n);const s={options:n,channels:t,applyMiddleware:o};let u;const c=t.request.subscribe((e=>{u=i(e,((r,n)=>((e,r,n)=>{let s=e,i=r;if(!s)try{i=o("onResponse",r,n)}catch(e){i=null,s=e}s=s&&o("onError",s,n),s?t.error.publish(s):i&&t.response.publish(i)})(r,n,e)))}));t.abort.subscribe((()=>{c(),u&&u.abort()}));const l=o("onReturn",t,s);return l===t&&t.request.publish(s),l}return c.use=function(e){if(!e)throw new Error("Tried to add middleware that resolved to falsey value");if("function"==typeof e)throw new Error("Tried to add middleware that was a function. It probably expects you to pass options to it.");if(e.onReturn&&a.onReturn.length>0)throw new Error("Tried to add new middleware with `onReturn` handler, but another handler has already been registered for this event");return o.forEach((t=>{e[t]&&a[t].push(e[t])})),u.push(e),c},c.clone=()=>n(u,i),s.forEach(c.use),c}export{n as c};//# sourceMappingURL=createRequester.js.map

@@ -1,1 +0,1 @@

import t from"decompress-response";import e from"follow-redirects";import o from"http";import r from"https";import n from"progress-stream";import s from"querystring";import{Readable as c}from"stream";import a from"url";import*as p from"tunnel-agent";function i(t){return Object.keys(t||{}).reduce(((e,o)=>(e[o.toLowerCase()]=t[o],e)),{})}function u(t){return t.replace(/^\.*/,".").toLowerCase()}function d(t){const e=t.trim().toLowerCase(),o=e.split(":",2);return{hostname:u(o[0]),port:o[1],hasPort:e.indexOf(":")>-1}}function h(t){const e=process.env.NO_PROXY||process.env.no_proxy||"";return"*"===e||""!==e&&function(t,e){const o=t.port||("https:"===t.protocol?"443":"80"),r=u(t.hostname);return e.split(",").map(d).some((t=>{const e=r.indexOf(t.hostname),n=e>-1&&e===r.length-t.hostname.length;return t.hasPort?o===t.port&&n:n}))}(t,e)?null:"http:"===t.protocol?process.env.HTTP_PROXY||process.env.http_proxy||null:"https:"===t.protocol&&(process.env.HTTPS_PROXY||process.env.https_proxy||process.env.HTTP_PROXY||process.env.http_proxy)||null}const l=["protocol","slashes","auth","host","port","hostname","hash","search","query","pathname","path","href"],m=["accept","accept-charset","accept-encoding","accept-language","accept-ranges","cache-control","content-encoding","content-language","content-location","content-md5","content-range","content-type","connection","date","expect","max-forwards","pragma","referer","te","user-agent","via"],f=["proxy-authorization"];function y(t={},e){const o=Object.assign({},t),r=m.concat(o.proxyHeaderWhiteList||[]).map((t=>t.toLowerCase())),n=f.concat(o.proxyHeaderExclusiveList||[]).map((t=>t.toLowerCase())),s=(c=o.headers,a=r,Object.keys(c).filter((t=>-1!==a.indexOf(t.toLowerCase()))).reduce(((t,e)=>(t[e]=c[e],t)),{}));var c,a;s.host=function(t){const e=t.port,o=t.protocol;let r=`${t.hostname}:`;return r+=e||("https:"===o?"443":"80"),r}(o),o.headers=Object.keys(o.headers||{}).reduce(((t,e)=>(-1===n.indexOf(e.toLowerCase())&&(t[e]=o.headers[e]),t)),{});const i=function(t,e){const o=function(t){return l.reduce(((e,o)=>(e[o]=t[o],e)),{})}(t),r=function(t,e){const o="https:"===t.protocol?"https":"http",r="https:"===e.protocol?"Https":"Http";return`${o}Over${r}`}(o,e);return p[r]}(o,e),u=function(t,e,o){return{proxy:{host:e.hostname,port:+e.port,proxyAuth:e.auth,headers:o},headers:t.headers,ca:t.ca,cert:t.cert,key:t.key,passphrase:t.passphrase,pfx:t.pfx,ciphers:t.ciphers,rejectUnauthorized:t.rejectUnauthorized,secureOptions:t.secureOptions,secureProtocol:t.secureProtocol}}(o,e,s);return o.agent=i(u),o}const b=t=>null!==t&&"object"==typeof t&&"function"==typeof t.pipe,g="node";class x extends Error{request;code;constructor(t,e){super(t.message),this.request=e,this.code=t.code}}const w=(t,e,o,r)=>({body:r,url:e,method:o,headers:t.headers,statusCode:t.statusCode,statusMessage:t.statusMessage}),O=(p,u)=>{const{options:d}=p,l=Object.assign({},a.parse(d.url));if("function"==typeof fetch&&d.fetch){const t=new AbortController,e=p.applyMiddleware("finalizeOptions",{...l,method:d.method,headers:{..."object"==typeof d.fetch&&d.fetch.headers?i(d.fetch.headers):{},...i(d.headers)},maxRedirects:d.maxRedirects}),o={credentials:d.withCredentials?"include":"omit",..."object"==typeof d.fetch?d.fetch:{},method:e.method,headers:e.headers,body:d.body,signal:t.signal},r=p.applyMiddleware("interceptRequest",void 0,{adapter:g,context:p});if(r){const t=setTimeout(u,0,null,r);return{abort:()=>clearTimeout(t)}}const n=fetch(d.url,o);return p.applyMiddleware("onRequest",{options:d,adapter:g,request:n,context:p}),n.then((async t=>{const e=d.rawBody?t.body:await t.text(),o={};t.headers.forEach(((t,e)=>{o[e]=t})),u(null,{body:e,url:t.url,method:d.method,headers:o,statusCode:t.status,statusMessage:t.statusText})})).catch((t=>{"AbortError"!=t.name&&u(t)})),{abort:()=>t.abort()}}const m=b(d.body)?"stream":typeof d.body;if("undefined"!==m&&"stream"!==m&&"string"!==m&&!Buffer.isBuffer(d.body))throw new Error(`Request body must be a string, buffer or stream, got ${m}`);const f={};d.bodySize?f["content-length"]=d.bodySize:d.body&&"stream"!==m&&(f["content-length"]=Buffer.byteLength(d.body));let O=!1;const T=(t,e)=>!O&&u(t,e);p.channels.abort.subscribe((()=>{O=!0}));let v=Object.assign({},l,{method:d.method,headers:Object.assign({},i(d.headers),f),maxRedirects:d.maxRedirects});const R=function(t){let e;e=t.hasOwnProperty("proxy")?t.proxy:h(a.parse(t.url));return"string"==typeof e?a.parse(e):e}(d),j=R&&function(t){return typeof t.tunnel<"u"?!!t.tunnel:"https:"===a.parse(t.url).protocol}(d),q=p.applyMiddleware("interceptRequest",void 0,{adapter:g,context:p});if(q){const t=setImmediate(T,null,q);return{abort:()=>clearImmediate(t)}}if(0!==d.maxRedirects&&(v.maxRedirects=d.maxRedirects||5),R&&j?v=y(v,R):R&&!j&&(v=function(t,e,o){const r=t.headers||{},n=Object.assign({},t,{headers:r});return r.host=r.host||function(t){const e=t.port||("https:"===t.protocol?"443":"80");return`${t.hostname}:${e}`}(e),n.protocol=o.protocol||n.protocol,n.hostname=o.host.replace(/:\d+/,""),n.port=o.port,n.host=function(t){let e=t.host;return t.port&&("80"===t.port&&"http:"===t.protocol||"443"===t.port&&"https:"===t.protocol)&&(e=t.hostname),e}(Object.assign({},e,o)),n.href=`${n.protocol}//${n.host}${n.path}`,n.path=a.format(e),n}(v,l,R)),!j&&R&&R.auth&&!v.headers["proxy-authorization"]){const[t,e]=R.auth.username?[R.auth.username,R.auth.password]:R.auth.split(":").map((t=>s.unescape(t))),o=Buffer.from(`${t}:${e}`,"utf8").toString("base64");v.headers["proxy-authorization"]=`Basic ${o}`}const C=function(t,n,s){const c="https:"===t.protocol,a=0===t.maxRedirects?{http:o,https:r}:{http:e.http,https:e.https};if(!n||s)return c?a.https:a.http;let p=443===n.port;return n.protocol&&(p=/^https:?/.test(n.protocol)),p?a.https:a.http}(v,R,j);"function"==typeof d.debug&&R&&d.debug("Proxying using %s",v.agent?"tunnel agent":`${v.host}:${v.port}`);const $="HEAD"!==v.method;let E;$&&!v.headers["accept-encoding"]&&!1!==d.compress&&(v.headers["accept-encoding"]=typeof Bun<"u"?"gzip, deflate":"br, gzip, deflate");const L=p.applyMiddleware("finalizeOptions",v),P=C.request(L,(e=>{const o=$?t(e):e;E=o;const r=p.applyMiddleware("onHeaders",o,{headers:e.headers,adapter:g,context:p}),n="responseUrl"in e?e.responseUrl:d.url;d.stream?T(null,w(o,n,v.method,r)):function(t,e){const o=[];t.on("data",(function(t){o.push(t)})),t.once("end",(function(){e&&e(null,Buffer.concat(o)),e=null})),t.once("error",(function(t){e&&e(t),e=null}))}(r,((t,e)=>{if(t)return T(t);const r=d.rawBody?e:e.toString(),s=w(o,n,v.method,r);return T(null,s)}))}));function z(t){E&&E.destroy(t),P.destroy(t)}P.once("socket",(t=>{t.once("error",z),P.once("response",(e=>{e.once("end",(()=>{t.removeListener("error",z)}))}))})),P.once("error",(t=>{E||T(new x(t,P))})),d.timeout&&function(t,e){if(t.timeoutTimer)return t;const o=isNaN(e)?e:{socket:e,connect:e},r=t.getHeader("host"),n=r?" to "+r:"";function s(){t.timeoutTimer&&(clearTimeout(t.timeoutTimer),t.timeoutTimer=null)}function c(e){if(s(),void 0!==o.socket){const r=()=>{const t=new Error("Socket timed out on request"+n);t.code="ESOCKETTIMEDOUT",e.destroy(t)};e.setTimeout(o.socket,r),t.once("response",(t=>{t.once("end",(()=>{e.removeListener("timeout",r)}))}))}}void 0!==o.connect&&(t.timeoutTimer=setTimeout((function(){const e=new Error("Connection timed out on request"+n);e.code="ETIMEDOUT",t.destroy(e)}),o.connect)),t.on("socket",(function(t){t.connecting?t.once("connect",(()=>c(t))):c(t)})),t.on("error",s)}(P,d.timeout);const{bodyStream:M,progress:k}=function(t){if(!t.body)return{};const e=b(t.body),o=t.bodySize||(e?null:Buffer.byteLength(t.body));if(!o)return e?{bodyStream:t.body}:{};const r=n({time:16,length:o});return{bodyStream:(e?t.body:c.from(t.body)).pipe(r),progress:r}}(d);return p.applyMiddleware("onRequest",{options:d,adapter:g,request:P,context:p,progress:k}),M?M.pipe(P):P.end(d.body),{abort:()=>P.abort()}};export{x as N,g as a,O as h};//# sourceMappingURL=node-request.js.map
import t from"decompress-response";import e from"follow-redirects";import o from"http";import r from"https";import n from"progress-stream";import s from"querystring";import{Readable as c}from"stream";import a from"url";import*as p from"tunnel-agent";function i(t){return Object.keys(t||{}).reduce(((e,o)=>(e[o.toLowerCase()]=t[o],e)),{})}function u(t){return t.replace(/^\.*/,".").toLowerCase()}function d(t){const e=t.trim().toLowerCase(),o=e.split(":",2);return{hostname:u(o[0]),port:o[1],hasPort:e.indexOf(":")>-1}}const h=["protocol","slashes","auth","host","port","hostname","hash","search","query","pathname","path","href"],l=["accept","accept-charset","accept-encoding","accept-language","accept-ranges","cache-control","content-encoding","content-language","content-location","content-md5","content-range","content-type","connection","date","expect","max-forwards","pragma","referer","te","user-agent","via"],m=["proxy-authorization"],f=t=>null!==t&&"object"==typeof t&&"function"==typeof t.pipe,y="node";class b extends Error{request;code;constructor(t,e){super(t.message),this.request=e,this.code=t.code}}const g=(t,e,o,r)=>({body:r,url:e,method:o,headers:t.headers,statusCode:t.statusCode,statusMessage:t.statusMessage}),x=(x,w)=>{const{options:O}=x,T=Object.assign({},a.parse(O.url));if("function"==typeof fetch&&O.fetch){const t=new AbortController,e=x.applyMiddleware("finalizeOptions",{...T,method:O.method,headers:{..."object"==typeof O.fetch&&O.fetch.headers?i(O.fetch.headers):{},...i(O.headers)},maxRedirects:O.maxRedirects}),o={credentials:O.withCredentials?"include":"omit",..."object"==typeof O.fetch?O.fetch:{},method:e.method,headers:e.headers,body:O.body,signal:t.signal},r=x.applyMiddleware("interceptRequest",void 0,{adapter:y,context:x});if(r){const t=setTimeout(w,0,null,r);return{abort:()=>clearTimeout(t)}}const n=fetch(O.url,o);return x.applyMiddleware("onRequest",{options:O,adapter:y,request:n,context:x}),n.then((async t=>{const e=O.rawBody?t.body:await t.text(),o={};t.headers.forEach(((t,e)=>{o[e]=t})),w(null,{body:e,url:t.url,method:O.method,headers:o,statusCode:t.status,statusMessage:t.statusText})})).catch((t=>{"AbortError"!=t.name&&w(t)})),{abort:()=>t.abort()}}const v=f(O.body)?"stream":typeof O.body;if("undefined"!==v&&"stream"!==v&&"string"!==v&&!Buffer.isBuffer(O.body))throw new Error(`Request body must be a string, buffer or stream, got ${v}`);const R={};O.bodySize?R["content-length"]=O.bodySize:O.body&&"stream"!==v&&(R["content-length"]=Buffer.byteLength(O.body));let j=!1;const q=(t,e)=>!j&&w(t,e);x.channels.abort.subscribe((()=>{j=!0}));let C=Object.assign({},T,{method:O.method,headers:Object.assign({},i(O.headers),R),maxRedirects:O.maxRedirects});const $=function(t){let e;return e=t.hasOwnProperty("proxy")?t.proxy:function(t){const e=process.env.NO_PROXY||process.env.no_proxy||"";return"*"===e||""!==e&&function(t,e){const o=t.port||("https:"===t.protocol?"443":"80"),r=u(t.hostname);return e.split(",").map(d).some((t=>{const e=r.indexOf(t.hostname),n=e>-1&&e===r.length-t.hostname.length;return t.hasPort?o===t.port&&n:n}))}(t,e)?null:"http:"===t.protocol?process.env.HTTP_PROXY||process.env.http_proxy||null:"https:"===t.protocol&&(process.env.HTTPS_PROXY||process.env.https_proxy||process.env.HTTP_PROXY||process.env.http_proxy)||null}(a.parse(t.url)),"string"==typeof e?a.parse(e):e}(O),E=$&&function(t){return typeof t.tunnel<"u"?!!t.tunnel:"https:"===a.parse(t.url).protocol}(O),L=x.applyMiddleware("interceptRequest",void 0,{adapter:y,context:x});if(L){const t=setImmediate(q,null,L);return{abort:()=>clearImmediate(t)}}if(0!==O.maxRedirects&&(C.maxRedirects=O.maxRedirects||5),$&&E?C=function(t={},e){const o=Object.assign({},t),r=l.concat(o.proxyHeaderWhiteList||[]).map((t=>t.toLowerCase())),n=m.concat(o.proxyHeaderExclusiveList||[]).map((t=>t.toLowerCase())),s=(c=o.headers,a=r,Object.keys(c).filter((t=>-1!==a.indexOf(t.toLowerCase()))).reduce(((t,e)=>(t[e]=c[e],t)),{}));var c,a;s.host=function(t){const e=t.port,o=t.protocol;let r=`${t.hostname}:`;return r+=e||("https:"===o?"443":"80"),r}(o),o.headers=Object.keys(o.headers||{}).reduce(((t,e)=>(-1===n.indexOf(e.toLowerCase())&&(t[e]=o.headers[e]),t)),{});const i=function(t,e){const o=function(t){return h.reduce(((e,o)=>(e[o]=t[o],e)),{})}(t),r=function(t,e){return`${"https:"===t.protocol?"https":"http"}Over${"https:"===e.protocol?"Https":"Http"}`}(o,e);return p[r]}(o,e),u=function(t,e,o){return{proxy:{host:e.hostname,port:+e.port,proxyAuth:e.auth,headers:o},headers:t.headers,ca:t.ca,cert:t.cert,key:t.key,passphrase:t.passphrase,pfx:t.pfx,ciphers:t.ciphers,rejectUnauthorized:t.rejectUnauthorized,secureOptions:t.secureOptions,secureProtocol:t.secureProtocol}}(o,e,s);return o.agent=i(u),o}(C,$):$&&!E&&(C=function(t,e,o){const r=t.headers||{},n=Object.assign({},t,{headers:r});return r.host=r.host||function(t){const e=t.port||("https:"===t.protocol?"443":"80");return`${t.hostname}:${e}`}(e),n.protocol=o.protocol||n.protocol,n.hostname=o.host.replace(/:\d+/,""),n.port=o.port,n.host=function(t){let e=t.host;return t.port&&("80"===t.port&&"http:"===t.protocol||"443"===t.port&&"https:"===t.protocol)&&(e=t.hostname),e}(Object.assign({},e,o)),n.href=`${n.protocol}//${n.host}${n.path}`,n.path=a.format(e),n}(C,T,$)),!E&&$&&$.auth&&!C.headers["proxy-authorization"]){const[t,e]=$.auth.username?[$.auth.username,$.auth.password]:$.auth.split(":").map((t=>s.unescape(t))),o=Buffer.from(`${t}:${e}`,"utf8").toString("base64");C.headers["proxy-authorization"]=`Basic ${o}`}const P=function(t,n,s){const c="https:"===t.protocol,a=0===t.maxRedirects?{http:o,https:r}:{http:e.http,https:e.https};if(!n||s)return c?a.https:a.http;let p=443===n.port;return n.protocol&&(p=/^https:?/.test(n.protocol)),p?a.https:a.http}(C,$,E);"function"==typeof O.debug&&$&&O.debug("Proxying using %s",C.agent?"tunnel agent":`${C.host}:${C.port}`);const z="HEAD"!==C.method;let M;z&&!C.headers["accept-encoding"]&&!1!==O.compress&&(C.headers["accept-encoding"]=typeof Bun<"u"?"gzip, deflate":"br, gzip, deflate");const k=x.applyMiddleware("finalizeOptions",C),S=P.request(k,(e=>{const o=z?t(e):e;M=o;const r=x.applyMiddleware("onHeaders",o,{headers:e.headers,adapter:y,context:x}),n="responseUrl"in e?e.responseUrl:O.url;O.stream?q(null,g(o,n,C.method,r)):function(t,e){const o=[];t.on("data",(function(t){o.push(t)})),t.once("end",(function(){e&&e(null,Buffer.concat(o)),e=null})),t.once("error",(function(t){e&&e(t),e=null}))}(r,((t,e)=>{if(t)return q(t);const r=O.rawBody?e:e.toString(),s=g(o,n,C.method,r);return q(null,s)}))}));function B(t){M&&M.destroy(t),S.destroy(t)}S.once("socket",(t=>{t.once("error",B),S.once("response",(e=>{e.once("end",(()=>{t.removeListener("error",B)}))}))})),S.once("error",(t=>{M||q(new b(t,S))})),O.timeout&&function(t,e){if(t.timeoutTimer)return t;const o=isNaN(e)?e:{socket:e,connect:e},r=t.getHeader("host"),n=r?" to "+r:"";function s(){t.timeoutTimer&&(clearTimeout(t.timeoutTimer),t.timeoutTimer=null)}function c(e){if(s(),void 0!==o.socket){const r=()=>{const t=new Error("Socket timed out on request"+n);t.code="ESOCKETTIMEDOUT",e.destroy(t)};e.setTimeout(o.socket,r),t.once("response",(t=>{t.once("end",(()=>{e.removeListener("timeout",r)}))}))}}void 0!==o.connect&&(t.timeoutTimer=setTimeout((function(){const e=new Error("Connection timed out on request"+n);e.code="ETIMEDOUT",t.destroy(e)}),o.connect)),t.on("socket",(function(t){t.connecting?t.once("connect",(()=>c(t))):c(t)})),t.on("error",s)}(S,O.timeout);const{bodyStream:H,progress:_}=function(t){if(!t.body)return{};const e=f(t.body),o=t.bodySize||(e?null:Buffer.byteLength(t.body));if(!o)return e?{bodyStream:t.body}:{};const r=n({time:16,length:o});return{bodyStream:(e?t.body:c.from(t.body)).pipe(r),progress:r}}(O);return x.applyMiddleware("onRequest",{options:O,adapter:y,request:S,context:x,progress:_}),H?H.pipe(S):S.end(O.body),{abort:()=>S.abort()}};export{b as N,y as a,x as h};//# sourceMappingURL=node-request.js.map

@@ -1,1 +0,1 @@

import{p as e,v as t,g as r}from"./_chunks-es/_commonjsHelpers.js";const o=["request","response","progress","error","abort"],s=["processOptions","validateOptions","interceptRequest","finalizeOptions","onRequest","onResponse","onError","onReturn","onHeaders"];function n(r,a){const i=[],u=s.reduce(((e,t)=>(e[t]=e[t]||[],e)),{processOptions:[e],validateOptions:[t]});function l(e){const t=o.reduce(((e,t)=>(e[t]=function(){const e=Object.create(null);let t=0;return{publish:function(t){for(const r in e)e[r](t)},subscribe:function(r){const o=t++;return e[o]=r,function(){delete e[o]}}}}(),e)),{}),r=(e=>function(t,r,...o){const s="onError"===t;let n=r;for(let r=0;r<e[t].length&&(n=(0,e[t][r])(n,...o),!s||n);r++);return n})(u),s=r("processOptions",e);r("validateOptions",s);const n={options:s,channels:t,applyMiddleware:r};let i;const l=t.request.subscribe((e=>{i=a(e,((o,s)=>((e,o,s)=>{let n=e,a=o;if(!n)try{a=r("onResponse",o,s)}catch(e){a=null,n=e}n=n&&r("onError",n,s),n?t.error.publish(n):a&&t.response.publish(a)})(o,s,e)))}));t.abort.subscribe((()=>{l(),i&&i.abort()}));const c=r("onReturn",t,n);return c===t&&t.request.publish(n),c}return l.use=function(e){if(!e)throw new Error("Tried to add middleware that resolved to falsey value");if("function"==typeof e)throw new Error("Tried to add middleware that was a function. It probably expects you to pass options to it.");if(e.onReturn&&u.onReturn.length>0)throw new Error("Tried to add new middleware with `onReturn` handler, but another handler has already been registered for this event");return s.forEach((t=>{e[t]&&u[t].push(e[t])})),i.push(e),l},l.clone=()=>n(i,a),r.forEach(l.use),l}var a=function(e){return e.replace(/^\s+|\s+$/g,"")},i=r((function(e){if(!e)return{};for(var t={},r=a(e).split("\n"),o=0;o<r.length;o++){var s=r[o],n=s.indexOf(":"),i=a(s.slice(0,n)).toLowerCase(),u=a(s.slice(n+1));typeof t[i]>"u"?t[i]=u:(l=t[i],"[object Array]"===Object.prototype.toString.call(l)?t[i].push(u):t[i]=[t[i],u])}var l;return t}));class u{onabort;onerror;onreadystatechange;ontimeout;readyState=0;response;responseText="";responseType="";status;statusText;withCredentials;#e;#t;#r;#o={};#s;#n={};#a;open(e,t,r){this.#e=e,this.#t=t,this.#r="",this.readyState=1,this.onreadystatechange?.(),this.#s=void 0}abort(){this.#s&&this.#s.abort()}getAllResponseHeaders(){return this.#r}setRequestHeader(e,t){this.#o[e]=t}setInit(e,t=!0){this.#n=e,this.#a=t}send(e){const t="arraybuffer"!==this.responseType,r={...this.#n,method:this.#e,headers:this.#o,body:e};"function"==typeof AbortController&&this.#a&&(this.#s=new AbortController,typeof EventTarget<"u"&&this.#s.signal instanceof EventTarget&&(r.signal=this.#s.signal)),typeof document<"u"&&(r.credentials=this.withCredentials?"include":"omit"),fetch(this.#t,r).then((e=>(e.headers.forEach(((e,t)=>{this.#r+=`${t}: ${e}\r\n`})),this.status=e.status,this.statusText=e.statusText,this.readyState=3,this.onreadystatechange?.(),t?e.text():e.arrayBuffer()))).then((e=>{"string"==typeof e?this.responseText=e:this.response=e,this.readyState=4,this.onreadystatechange?.()})).catch((e=>{"AbortError"!==e.name?this.onerror?.(e):this.onabort?.()}))}}const l="function"==typeof XMLHttpRequest?"xhr":"fetch",c="xhr"===l?XMLHttpRequest:u,h=(e,t)=>{const r=e.options,o=e.applyMiddleware("finalizeOptions",r),s={},n=e.applyMiddleware("interceptRequest",void 0,{adapter:l,context:e});if(n){const e=setTimeout(t,0,null,n);return{abort:()=>clearTimeout(e)}}let a=new c;a instanceof u&&"object"==typeof o.fetch&&a.setInit(o.fetch,o.useAbortSignal??!0);const h=o.headers,d=o.timeout;let p=!1,f=!1,b=!1;if(a.onerror=e=>{m(a instanceof u?e instanceof Error?e:new Error(`Request error while attempting to reach is ${o.url}`,{cause:e}):new Error(`Request error while attempting to reach is ${o.url}${e.lengthComputable?`(${e.loaded} of ${e.total} bytes transferred)`:""}`))},a.ontimeout=e=>{m(new Error(`Request timeout while attempting to reach ${o.url}${e.lengthComputable?`(${e.loaded} of ${e.total} bytes transferred)`:""}`))},a.onabort=()=>{w(!0),p=!0},a.onreadystatechange=()=>{d&&(w(),s.socket=setTimeout((()=>y("ESOCKETTIMEDOUT")),d.socket)),!p&&4===a.readyState&&0!==a.status&&function(){if(!(p||f||b)){if(0===a.status)return void m(new Error("Unknown XHR error"));w(),f=!0,t(null,{body:a.response||(""===a.responseType||"text"===a.responseType?a.responseText:""),url:o.url,method:o.method,headers:i(a.getAllResponseHeaders()),statusCode:a.status,statusMessage:a.statusText})}}()},a.open(o.method,o.url,!0),a.withCredentials=!!o.withCredentials,h&&a.setRequestHeader)for(const e in h)h.hasOwnProperty(e)&&a.setRequestHeader(e,h[e]);return o.rawBody&&(a.responseType="arraybuffer"),e.applyMiddleware("onRequest",{options:o,adapter:l,request:a,context:e}),a.send(o.body||null),d&&(s.connect=setTimeout((()=>y("ETIMEDOUT")),d.connect)),{abort:function(){p=!0,a&&a.abort()}};function y(t){b=!0,a.abort();const r=new Error("ESOCKETTIMEDOUT"===t?`Socket timed out on request to ${o.url}`:`Connection timed out on request to ${o.url}`);r.code=t,e.channels.error.publish(r)}function w(e){(e||p||a.readyState>=2&&s.connect)&&clearTimeout(s.connect),s.socket&&clearTimeout(s.socket)}function m(e){if(f)return;w(!0),f=!0,a=null;const r=e||new Error(`Network error while attempting to reach ${o.url}`);r.isNetworkError=!0,r.request=o,t(r)}},d=(e=[],t=h)=>n(e,t),p="browser";export{l as adapter,p as environment,d as getIt};//# sourceMappingURL=index.browser.js.map
import{p as e,v as t,g as r}from"./_chunks-es/_commonjsHelpers.js";const o=["request","response","progress","error","abort"],s=["processOptions","validateOptions","interceptRequest","finalizeOptions","onRequest","onResponse","onError","onReturn","onHeaders"];function n(r,a){const i=[],u=s.reduce(((e,t)=>(e[t]=e[t]||[],e)),{processOptions:[e],validateOptions:[t]});function l(e){const t=o.reduce(((e,t)=>(e[t]=function(){const e=/* @__PURE__ */Object.create(null);let t=0;return{publish:function(t){for(const r in e)e[r](t)},subscribe:function(r){const o=t++;return e[o]=r,function(){delete e[o]}}}}(),e)),{}),r=(e=>function(t,r,...o){const s="onError"===t;let n=r;for(let r=0;r<e[t].length&&(n=(0,e[t][r])(n,...o),!s||n);r++);return n})(u),s=r("processOptions",e);r("validateOptions",s);const n={options:s,channels:t,applyMiddleware:r};let i;const l=t.request.subscribe((e=>{i=a(e,((o,s)=>((e,o,s)=>{let n=e,a=o;if(!n)try{a=r("onResponse",o,s)}catch(e){a=null,n=e}n=n&&r("onError",n,s),n?t.error.publish(n):a&&t.response.publish(a)})(o,s,e)))}));t.abort.subscribe((()=>{l(),i&&i.abort()}));const c=r("onReturn",t,n);return c===t&&t.request.publish(n),c}return l.use=function(e){if(!e)throw new Error("Tried to add middleware that resolved to falsey value");if("function"==typeof e)throw new Error("Tried to add middleware that was a function. It probably expects you to pass options to it.");if(e.onReturn&&u.onReturn.length>0)throw new Error("Tried to add new middleware with `onReturn` handler, but another handler has already been registered for this event");return s.forEach((t=>{e[t]&&u[t].push(e[t])})),i.push(e),l},l.clone=()=>n(i,a),r.forEach(l.use),l}var a,i,u=/* @__PURE__ */r(function(){if(i)return a;i=1;var e=function(e){return e.replace(/^\s+|\s+$/g,"")};return a=function(t){if(!t)return{};for(var r={},o=e(t).split("\n"),s=0;s<o.length;s++){var n=o[s],a=n.indexOf(":"),i=e(n.slice(0,a)).toLowerCase(),u=e(n.slice(a+1));typeof r[i]>"u"?r[i]=u:(l=r[i],"[object Array]"===Object.prototype.toString.call(l)?r[i].push(u):r[i]=[r[i],u])}var l;return r}}());class l{onabort;onerror;onreadystatechange;ontimeout;readyState=0;response;responseText="";responseType="";status;statusText;withCredentials;#e;#t;#r;#o={};#s;#n={};#a;open(e,t,r){this.#e=e,this.#t=t,this.#r="",this.readyState=1,this.onreadystatechange?.(),this.#s=void 0}abort(){this.#s&&this.#s.abort()}getAllResponseHeaders(){return this.#r}setRequestHeader(e,t){this.#o[e]=t}setInit(e,t=!0){this.#n=e,this.#a=t}send(e){const t="arraybuffer"!==this.responseType,r={...this.#n,method:this.#e,headers:this.#o,body:e};"function"==typeof AbortController&&this.#a&&(this.#s=new AbortController,typeof EventTarget<"u"&&this.#s.signal instanceof EventTarget&&(r.signal=this.#s.signal)),typeof document<"u"&&(r.credentials=this.withCredentials?"include":"omit"),fetch(this.#t,r).then((e=>(e.headers.forEach(((e,t)=>{this.#r+=`${t}: ${e}\r\n`})),this.status=e.status,this.statusText=e.statusText,this.readyState=3,this.onreadystatechange?.(),t?e.text():e.arrayBuffer()))).then((e=>{"string"==typeof e?this.responseText=e:this.response=e,this.readyState=4,this.onreadystatechange?.()})).catch((e=>{"AbortError"!==e.name?this.onerror?.(e):this.onabort?.()}))}}const c="function"==typeof XMLHttpRequest?"xhr":"fetch",h="xhr"===c?XMLHttpRequest:l,d=(e,t)=>{const r=e.options,o=e.applyMiddleware("finalizeOptions",r),s={},n=e.applyMiddleware("interceptRequest",void 0,{adapter:c,context:e});if(n){const e=setTimeout(t,0,null,n);return{abort:()=>clearTimeout(e)}}let a=new h;a instanceof l&&"object"==typeof o.fetch&&a.setInit(o.fetch,o.useAbortSignal??!0);const i=o.headers,d=o.timeout;let p=!1,f=!1,b=!1;if(a.onerror=e=>{m(a instanceof l?e instanceof Error?e:new Error(`Request error while attempting to reach is ${o.url}`,{cause:e}):new Error(`Request error while attempting to reach is ${o.url}${e.lengthComputable?`(${e.loaded} of ${e.total} bytes transferred)`:""}`))},a.ontimeout=e=>{m(new Error(`Request timeout while attempting to reach ${o.url}${e.lengthComputable?`(${e.loaded} of ${e.total} bytes transferred)`:""}`))},a.onabort=()=>{w(!0),p=!0},a.onreadystatechange=()=>{d&&(w(),s.socket=setTimeout((()=>y("ESOCKETTIMEDOUT")),d.socket)),!p&&4===a.readyState&&0!==a.status&&function(){if(!(p||f||b)){if(0===a.status)return void m(new Error("Unknown XHR error"));w(),f=!0,t(null,{body:a.response||(""===a.responseType||"text"===a.responseType?a.responseText:""),url:o.url,method:o.method,headers:u(a.getAllResponseHeaders()),statusCode:a.status,statusMessage:a.statusText})}}()},a.open(o.method,o.url,!0),a.withCredentials=!!o.withCredentials,i&&a.setRequestHeader)for(const e in i)i.hasOwnProperty(e)&&a.setRequestHeader(e,i[e]);return o.rawBody&&(a.responseType="arraybuffer"),e.applyMiddleware("onRequest",{options:o,adapter:c,request:a,context:e}),a.send(o.body||null),d&&(s.connect=setTimeout((()=>y("ETIMEDOUT")),d.connect)),{abort:function(){p=!0,a&&a.abort()}};function y(t){b=!0,a.abort();const r=new Error("ESOCKETTIMEDOUT"===t?`Socket timed out on request to ${o.url}`:`Connection timed out on request to ${o.url}`);r.code=t,e.channels.error.publish(r)}function w(e){(e||p||a.readyState>=2&&s.connect)&&clearTimeout(s.connect),s.socket&&clearTimeout(s.socket)}function m(e){if(f)return;w(!0),f=!0,a=null;const r=e||new Error(`Network error while attempting to reach ${o.url}`);r.isNetworkError=!0,r.request=o,t(r)}},p=(e=[],t=d)=>n(e,t),f="browser";export{c as adapter,f as environment,p as getIt};//# sourceMappingURL=index.browser.js.map

@@ -1,1 +0,1 @@

import{c as e}from"./_chunks-es/createRequester.js";import{g as t}from"./_chunks-es/_commonjsHelpers.js";var r=function(e){return e.replace(/^\s+|\s+$/g,"")},s=t((function(e){if(!e)return{};for(var t={},s=r(e).split("\n"),o=0;o<s.length;o++){var n=s[o],a=n.indexOf(":"),i=r(n.slice(0,a)).toLowerCase(),u=r(n.slice(a+1));typeof t[i]>"u"?t[i]=u:(l=t[i],"[object Array]"===Object.prototype.toString.call(l)?t[i].push(u):t[i]=[t[i],u])}var l;return t}));class o{onabort;onerror;onreadystatechange;ontimeout;readyState=0;response;responseText="";responseType="";status;statusText;withCredentials;#e;#t;#r;#s={};#o;#n={};#a;open(e,t,r){this.#e=e,this.#t=t,this.#r="",this.readyState=1,this.onreadystatechange?.(),this.#o=void 0}abort(){this.#o&&this.#o.abort()}getAllResponseHeaders(){return this.#r}setRequestHeader(e,t){this.#s[e]=t}setInit(e,t=!0){this.#n=e,this.#a=t}send(e){const t="arraybuffer"!==this.responseType,r={...this.#n,method:this.#e,headers:this.#s,body:e};"function"==typeof AbortController&&this.#a&&(this.#o=new AbortController,typeof EventTarget<"u"&&this.#o.signal instanceof EventTarget&&(r.signal=this.#o.signal)),typeof document<"u"&&(r.credentials=this.withCredentials?"include":"omit"),fetch(this.#t,r).then((e=>(e.headers.forEach(((e,t)=>{this.#r+=`${t}: ${e}\r\n`})),this.status=e.status,this.statusText=e.statusText,this.readyState=3,this.onreadystatechange?.(),t?e.text():e.arrayBuffer()))).then((e=>{"string"==typeof e?this.responseText=e:this.response=e,this.readyState=4,this.onreadystatechange?.()})).catch((e=>{"AbortError"!==e.name?this.onerror?.(e):this.onabort?.()}))}}const n="function"==typeof XMLHttpRequest?"xhr":"fetch",a="xhr"===n?XMLHttpRequest:o,i=(e,t)=>{const r=e.options,i=e.applyMiddleware("finalizeOptions",r),u={},l=e.applyMiddleware("interceptRequest",void 0,{adapter:n,context:e});if(l){const e=setTimeout(t,0,null,l);return{abort:()=>clearTimeout(e)}}let c=new a;c instanceof o&&"object"==typeof i.fetch&&c.setInit(i.fetch,i.useAbortSignal??!0);const h=i.headers,d=i.timeout;let p=!1,f=!1,y=!1;if(c.onerror=e=>{g(c instanceof o?e instanceof Error?e:new Error(`Request error while attempting to reach is ${i.url}`,{cause:e}):new Error(`Request error while attempting to reach is ${i.url}${e.lengthComputable?`(${e.loaded} of ${e.total} bytes transferred)`:""}`))},c.ontimeout=e=>{g(new Error(`Request timeout while attempting to reach ${i.url}${e.lengthComputable?`(${e.loaded} of ${e.total} bytes transferred)`:""}`))},c.onabort=()=>{b(!0),p=!0},c.onreadystatechange=()=>{d&&(b(),u.socket=setTimeout((()=>m("ESOCKETTIMEDOUT")),d.socket)),!p&&4===c.readyState&&0!==c.status&&function(){if(!(p||f||y)){if(0===c.status)return void g(new Error("Unknown XHR error"));b(),f=!0,t(null,{body:c.response||(""===c.responseType||"text"===c.responseType?c.responseText:""),url:i.url,method:i.method,headers:s(c.getAllResponseHeaders()),statusCode:c.status,statusMessage:c.statusText})}}()},c.open(i.method,i.url,!0),c.withCredentials=!!i.withCredentials,h&&c.setRequestHeader)for(const e in h)h.hasOwnProperty(e)&&c.setRequestHeader(e,h[e]);return i.rawBody&&(c.responseType="arraybuffer"),e.applyMiddleware("onRequest",{options:i,adapter:n,request:c,context:e}),c.send(i.body||null),d&&(u.connect=setTimeout((()=>m("ETIMEDOUT")),d.connect)),{abort:function(){p=!0,c&&c.abort()}};function m(t){y=!0,c.abort();const r=new Error("ESOCKETTIMEDOUT"===t?`Socket timed out on request to ${i.url}`:`Connection timed out on request to ${i.url}`);r.code=t,e.channels.error.publish(r)}function b(e){(e||p||c.readyState>=2&&u.connect)&&clearTimeout(u.connect),u.socket&&clearTimeout(u.socket)}function g(e){if(f)return;b(!0),f=!0,c=null;const r=e||new Error(`Network error while attempting to reach ${i.url}`);r.isNetworkError=!0,r.request=i,t(r)}},u=(t=[],r=i)=>e(t,r),l="react-server";export{n as adapter,l as environment,u as getIt};//# sourceMappingURL=index.react-server.js.map
import{c as e}from"./_chunks-es/createRequester.js";import{g as t}from"./_chunks-es/_commonjsHelpers.js";var r,s,o=/* @__PURE__ */t(function(){if(s)return r;s=1;var e=function(e){return e.replace(/^\s+|\s+$/g,"")};return r=function(t){if(!t)return{};for(var r={},s=e(t).split("\n"),o=0;o<s.length;o++){var n=s[o],a=n.indexOf(":"),i=e(n.slice(0,a)).toLowerCase(),u=e(n.slice(a+1));typeof r[i]>"u"?r[i]=u:(l=r[i],"[object Array]"===Object.prototype.toString.call(l)?r[i].push(u):r[i]=[r[i],u])}var l;return r}}());class n{onabort;onerror;onreadystatechange;ontimeout;readyState=0;response;responseText="";responseType="";status;statusText;withCredentials;#e;#t;#r;#s={};#o;#n={};#a;open(e,t,r){this.#e=e,this.#t=t,this.#r="",this.readyState=1,this.onreadystatechange?.(),this.#o=void 0}abort(){this.#o&&this.#o.abort()}getAllResponseHeaders(){return this.#r}setRequestHeader(e,t){this.#s[e]=t}setInit(e,t=!0){this.#n=e,this.#a=t}send(e){const t="arraybuffer"!==this.responseType,r={...this.#n,method:this.#e,headers:this.#s,body:e};"function"==typeof AbortController&&this.#a&&(this.#o=new AbortController,typeof EventTarget<"u"&&this.#o.signal instanceof EventTarget&&(r.signal=this.#o.signal)),typeof document<"u"&&(r.credentials=this.withCredentials?"include":"omit"),fetch(this.#t,r).then((e=>(e.headers.forEach(((e,t)=>{this.#r+=`${t}: ${e}\r\n`})),this.status=e.status,this.statusText=e.statusText,this.readyState=3,this.onreadystatechange?.(),t?e.text():e.arrayBuffer()))).then((e=>{"string"==typeof e?this.responseText=e:this.response=e,this.readyState=4,this.onreadystatechange?.()})).catch((e=>{"AbortError"!==e.name?this.onerror?.(e):this.onabort?.()}))}}const a="function"==typeof XMLHttpRequest?"xhr":"fetch",i="xhr"===a?XMLHttpRequest:n,u=(e,t)=>{const r=e.options,s=e.applyMiddleware("finalizeOptions",r),u={},l=e.applyMiddleware("interceptRequest",void 0,{adapter:a,context:e});if(l){const e=setTimeout(t,0,null,l);return{abort:()=>clearTimeout(e)}}let c=new i;c instanceof n&&"object"==typeof s.fetch&&c.setInit(s.fetch,s.useAbortSignal??!0);const h=s.headers,d=s.timeout;let p=!1,f=!1,y=!1;if(c.onerror=e=>{g(c instanceof n?e instanceof Error?e:new Error(`Request error while attempting to reach is ${s.url}`,{cause:e}):new Error(`Request error while attempting to reach is ${s.url}${e.lengthComputable?`(${e.loaded} of ${e.total} bytes transferred)`:""}`))},c.ontimeout=e=>{g(new Error(`Request timeout while attempting to reach ${s.url}${e.lengthComputable?`(${e.loaded} of ${e.total} bytes transferred)`:""}`))},c.onabort=()=>{b(!0),p=!0},c.onreadystatechange=()=>{d&&(b(),u.socket=setTimeout((()=>m("ESOCKETTIMEDOUT")),d.socket)),!p&&4===c.readyState&&0!==c.status&&function(){if(!(p||f||y)){if(0===c.status)return void g(new Error("Unknown XHR error"));b(),f=!0,t(null,{body:c.response||(""===c.responseType||"text"===c.responseType?c.responseText:""),url:s.url,method:s.method,headers:o(c.getAllResponseHeaders()),statusCode:c.status,statusMessage:c.statusText})}}()},c.open(s.method,s.url,!0),c.withCredentials=!!s.withCredentials,h&&c.setRequestHeader)for(const e in h)h.hasOwnProperty(e)&&c.setRequestHeader(e,h[e]);return s.rawBody&&(c.responseType="arraybuffer"),e.applyMiddleware("onRequest",{options:s,adapter:a,request:c,context:e}),c.send(s.body||null),d&&(u.connect=setTimeout((()=>m("ETIMEDOUT")),d.connect)),{abort:function(){p=!0,c&&c.abort()}};function m(t){y=!0,c.abort();const r=new Error("ESOCKETTIMEDOUT"===t?`Socket timed out on request to ${s.url}`:`Connection timed out on request to ${s.url}`);r.code=t,e.channels.error.publish(r)}function b(e){(e||p||c.readyState>=2&&u.connect)&&clearTimeout(u.connect),u.socket&&clearTimeout(u.socket)}function g(e){if(f)return;b(!0),f=!0,c=null;const r=e||new Error(`Network error while attempting to reach ${s.url}`);r.isNetworkError=!0,r.request=s,t(r)}},l=(t=[],r=u)=>e(t,r),c="react-server";export{a as adapter,c as environment,l as getIt};//# sourceMappingURL=index.react-server.js.map

@@ -1,10 +0,12 @@

import {FinalizeNodeOptionsPayload} from 'get-it'
import {FinalizeNodeOptionsPayload as FinalizeNodeOptionsPayload_2} from 'get-it'
import {HookOnRequestEvent} from 'get-it'
import {HttpContext} from 'get-it'
import {MiddlewareChannels} from 'get-it'
import type {MiddlewareHooks} from 'get-it'
import type {IncomingHttpHeaders} from 'http'
import type {IncomingMessage} from 'http'
import {MiddlewareChannels as MiddlewareChannels_2} from 'get-it'
import {MiddlewareResponse} from 'get-it'
import {RequestAdapter} from 'get-it'
import type {ProgressStream} from 'progress-stream'
import {RequestAdapter as RequestAdapter_2} from 'get-it'
import {RequestOptions} from 'get-it'
import type {RetryOptions} from 'get-it'
import type {UrlWithStringQuery} from 'url'

@@ -18,2 +20,9 @@ /**

/** @public */
declare type ApplyMiddleware = <T extends keyof MiddlewareHooks>(
hook: T,
value: MiddlewareHooks[T] extends (defaultValue: infer V, ...rest: any[]) => any ? V : never,
...args: MiddlewareHooks[T] extends (defaultValue: any, ...rest: infer P) => any ? P : never
) => ReturnType<MiddlewareHooks[T]>
/** @public */
export declare function base(baseUrl: string): {

@@ -57,2 +66,13 @@ processOptions: (options: RequestOptions) => RequestOptions

/** @public */
declare interface FinalizeNodeOptionsPayload extends UrlWithStringQuery {
method: RequestOptions_2['method']
headers: RequestOptions_2['headers']
maxRedirects: RequestOptions_2['maxRedirects']
agent?: any
cert?: any
key?: any
ca?: any
}
/** @public */
export declare function headers(

@@ -66,2 +86,31 @@ _headers: any,

/** @public */
declare type HookOnRequestEvent_2 = HookOnRequestEventNode | HookOnRequestEventBrowser
/** @public */
declare interface HookOnRequestEventBase {
options: RequestOptions_2
context: HttpContext_2
request: any
}
/** @public */
declare interface HookOnRequestEventBrowser extends HookOnRequestEventBase {
adapter: Omit<RequestAdapter, 'node'>
progress?: undefined
}
/** @public */
declare interface HookOnRequestEventNode extends HookOnRequestEventBase {
adapter: 'node'
progress: any
}
/** @public */
declare interface HttpContext_2 {
options: RequestOptions_2
channels: MiddlewareChannels
applyMiddleware: ApplyMiddleware
}
/** @public */
export declare function httpErrors(): {

@@ -76,11 +125,11 @@ onResponse: (res: MiddlewareResponse, ctx: HttpContext) => MiddlewareResponse

prevValue: Parameters<MiddlewareHooks['interceptRequest']>[0],
) => Partial<MiddlewareResponse | undefined | void>
) => Partial<MiddlewareResponse_2 | undefined | void>
}): {
interceptRequest: (
prevValue: MiddlewareResponse | undefined,
prevValue: MiddlewareResponse_2 | undefined,
event: {
adapter: RequestAdapter
adapter: RequestAdapter_2
context: HttpContext
},
) => MiddlewareResponse | undefined
) => MiddlewareResponse_2 | undefined
}

@@ -109,6 +158,53 @@

/** @public */
declare interface MiddlewareChannels {
request: PubSub<HttpContext_2>
response: PubSub<unknown>
progress: PubSub<unknown>
error: PubSub<unknown>
abort: PubSub<void>
}
/** @public */
declare interface MiddlewareHooks {
processOptions: (options: RequestOptions_2) => RequestOptions_2
validateOptions: (options: RequestOptions_2) => void | undefined
interceptRequest: (
prevValue: MiddlewareResponse_2 | undefined,
event: {
adapter: RequestAdapter
context: HttpContext_2
},
) => MiddlewareResponse_2 | undefined | void
finalizeOptions: (
options: FinalizeNodeOptionsPayload | RequestOptions_2,
) => FinalizeNodeOptionsPayload | RequestOptions_2
onRequest: (evt: HookOnRequestEvent_2) => void
onResponse: (response: MiddlewareResponse_2, context: HttpContext_2) => MiddlewareResponse_2
onError: (err: Error | null, context: HttpContext_2) => any
onReturn: (channels: MiddlewareChannels, context: HttpContext_2) => any
onHeaders: (
response: IncomingMessage,
evt: {
headers: IncomingHttpHeaders
adapter: RequestAdapter
context: HttpContext_2
},
) => ProgressStream
}
/** @public */
declare interface MiddlewareResponse_2 {
body: any
url: string
method: string
headers: any
statusCode: number
statusMessage: string
}
/** @public */
export declare function mtls(config?: any): {
finalizeOptions: (options: RequestOptions | FinalizeNodeOptionsPayload) =>
finalizeOptions: (options: RequestOptions | FinalizeNodeOptionsPayload_2) =>
| RequestOptions
| (FinalizeNodeOptionsPayload & {
| (FinalizeNodeOptionsPayload_2 & {
cert: any

@@ -122,7 +218,7 @@ key: any

export declare function observable(opts?: {implementation?: any}): {
onReturn: (channels: MiddlewareChannels, context: HttpContext) => any
onReturn: (channels: MiddlewareChannels_2, context: HttpContext) => any
}
/** @public */
export declare const processOptions: (opts: RequestOptions) => {
export declare const processOptions: (opts: RequestOptions_2) => {
url: string

@@ -161,3 +257,3 @@ body?: any

(options?: {onlyBody?: boolean; implementation?: PromiseConstructor}): {
onReturn: (channels: MiddlewareChannels, context: HttpContext) => Promise<unknown>
onReturn: (channels: MiddlewareChannels_2, context: HttpContext) => Promise<unknown>
}

@@ -177,2 +273,49 @@ Cancel: typeof Cancel

/** @public */
declare interface PubSub<Message> {
publish: (message: Message) => void
subscribe: (subscriber: Subscriber<Message>) => () => void
}
/**
* Reports the request adapter in use. `node` is only available if `ExportEnv` is also `node`.
* When `ExportEnv` is `browser` then the adapter can be either `xhr` or `fetch`.
* In the future `fetch` will be available in `node` as well.
* @public
*/
declare type RequestAdapter = 'node' | 'xhr' | 'fetch'
/** @public */
declare interface RequestOptions_2 {
url: string
body?: any
bodySize?: number
cancelToken?: any
compress?: boolean
headers?: any
maxRedirects?: number
maxRetries?: number
retryDelay?: (attemptNumber: number) => number
method?: string
proxy?: any
query?: any
rawBody?: boolean
shouldRetry?: any
stream?: boolean
timeout?: any
tunnel?: boolean
debug?: any
requestId?: number
attemptNumber?: number
withCredentials?: boolean
/**
* Enables using the native `fetch` API instead of the default `http` module, and allows setting its options like `cache`
*/
fetch?: boolean | Omit<RequestInit, 'method'>
/**
* Some frameworks have special behavior for `fetch` when an `AbortSignal` is used, and may want to disable it unless userland specifically opts-in.
*/
useAbortSignal?: boolean
}
/** @public */
export declare const retry: {

@@ -186,2 +329,14 @@ (opts?: Partial<RetryOptions>): {

/** @public */
declare interface RetryOptions {
shouldRetry: (err: any, num: number, options: any) => boolean
maxRetries?: number
retryDelay?: (attemptNumber: number) => number
}
/** @public */
declare interface Subscriber<Event> {
(event: Event): void
}
/** @public */
export declare function urlEncoded(): {

@@ -188,0 +343,0 @@ processOptions: (options: RequestOptions) => RequestOptions

@@ -1,1 +0,1 @@

import{g as e}from"./_chunks-es/_commonjsHelpers.js";import{p as t,v as s}from"./_chunks-es/_commonjsHelpers.js";function n(e){return{}}const r=/^\//,o=/\/$/;function i(e){const t=e.replace(o,"");return{processOptions:e=>{if(/^https?:\/\//i.test(e.url))return e;const s=[t,e.url.replace(r,"")].join("/");return Object.assign({},e,{url:s})}}}var a,c,u={exports:{}};function l(){if(c)return a;c=1;var e=1e3,t=60*e,s=60*t,n=24*s,r=7*n,o=365.25*n;function i(e,t,s,n){var r=t>=1.5*s;return Math.round(e/s)+" "+n+(r?"s":"")}return a=function(a,c){c=c||{};var u,l,p=typeof a;if("string"===p&&a.length>0)return function(i){if(!((i=String(i)).length>100)){var a=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(i);if(a){var c=parseFloat(a[1]);switch((a[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return c*o;case"weeks":case"week":case"w":return c*r;case"days":case"day":case"d":return c*n;case"hours":case"hour":case"hrs":case"hr":case"h":return c*s;case"minutes":case"minute":case"mins":case"min":case"m":return c*t;case"seconds":case"second":case"secs":case"sec":case"s":return c*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return c;default:return}}}}(a);if("number"===p&&isFinite(a))return c.long?(u=a,(l=Math.abs(u))>=n?i(u,l,n,"day"):l>=s?i(u,l,s,"hour"):l>=t?i(u,l,t,"minute"):l>=e?i(u,l,e,"second"):u+" ms"):function(r){var o=Math.abs(r);return o>=n?Math.round(r/n)+"d":o>=s?Math.round(r/s)+"h":o>=t?Math.round(r/t)+"m":o>=e?Math.round(r/e)+"s":r+"ms"}(a);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(a))}}var p=function(e){function t(e){let n,r,o,i=null;function a(...e){if(!a.enabled)return;const s=a,r=Number(new Date),o=r-(n||r);s.diff=o,s.prev=n,s.curr=r,n=r,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let i=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((n,r)=>{if("%%"===n)return"%";i++;const o=t.formatters[r];if("function"==typeof o){const t=e[i];n=o.call(s,t),e.splice(i,1),i--}return n})),t.formatArgs.call(s,e),(s.log||t.log).apply(s,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=s,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==i?i:(r!==t.namespaces&&(r=t.namespaces,o=t.enabled(e)),o),set:e=>{i=e}}),"function"==typeof t.init&&t.init(a),a}function s(e,s){const n=t(this.namespace+(typeof s>"u"?":":s)+e);return n.log=this.log,n}function n(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){const e=[...t.names.map(n),...t.skips.map(n).map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){let s;t.save(e),t.namespaces=e,t.names=[],t.skips=[];const n=("string"==typeof e?e:"").split(/[\s,]+/),r=n.length;for(s=0;s<r;s++)n[s]&&("-"===(e=n[s].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.slice(1)+"$")):t.names.push(new RegExp("^"+e+"$")))},t.enabled=function(e){if("*"===e[e.length-1])return!0;let s,n;for(s=0,n=t.skips.length;s<n;s++)if(t.skips[s].test(e))return!1;for(s=0,n=t.names.length;s<n;s++)if(t.names[s].test(e))return!0;return!1},t.humanize=l(),t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach((s=>{t[s]=e[s]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let s=0;for(let t=0;t<e.length;t++)s=(s<<5)-s+e.charCodeAt(t),s|=0;return t.colors[Math.abs(s)%t.colors.length]},t.enable(t.load()),t};!function(e,t){t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const s="color: "+this.color;t.splice(1,0,s,"color: inherit");let n=0,r=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(n++,"%c"===e&&(r=n))})),t.splice(r,0,s)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch{}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch{}return!e&&typeof process<"u"&&"env"in process&&(e=process.env.DEBUG),e},t.useColors=function(){return!(!(typeof window<"u"&&window.process)||"renderer"!==window.process.type&&!window.process.__nwjs)||!(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&(typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},t.storage=function(){try{return localStorage}catch{}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=p(t);const{formatters:s}=e.exports;s.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(u,u.exports);var d=e(u.exports);const f=["cookie","authorization"],m=Object.prototype.hasOwnProperty;function C(e={}){const t=e.verbose,s=e.namespace||"get-it",n=d(s),r=e.log||n,o=r===n&&!d.enabled(s);let i=0;return{processOptions:e=>(e.debug=r,e.requestId=e.requestId||++i,e),onRequest:s=>{if(o||!s)return s;const n=s.options;if(r("[%s] HTTP %s %s",n.requestId,n.method,n.url),t&&n.body&&"string"==typeof n.body&&r("[%s] Request body: %s",n.requestId,n.body),t&&n.headers){const t=!1===e.redactSensitiveHeaders?n.headers:((e,t)=>{const s={};for(const n in e)m.call(e,n)&&(s[n]=t.indexOf(n.toLowerCase())>-1?"<redacted>":e[n]);return s})(n.headers,f);r("[%s] Request headers: %s",n.requestId,JSON.stringify(t,null,2))}return s},onResponse:(e,s)=>{if(o||!e)return e;const n=s.options.requestId;return r("[%s] Response code: %s %s",n,e.statusCode,e.statusMessage),t&&e.body&&r("[%s] Response body: %s",n,function(e){return-1!==(e.headers["content-type"]||"").toLowerCase().indexOf("application/json")?function(e){try{const t="string"==typeof e?JSON.parse(e):e;return JSON.stringify(t,null,2)}catch{return e}}(e.body):e.body}(e)),e},onError:(e,t)=>{const s=t.options.requestId;return e?(r("[%s] ERROR: %s",s,e.message),e):(r("[%s] Error encountered, but handled by an earlier middleware",s),e)}}}function h(e,t={}){return{processOptions:s=>{const n=s.headers||{};return s.headers=t.override?Object.assign({},n,e):Object.assign({},e,n),s}}}class g extends Error{response;request;constructor(e,t){super();const s=e.url.length>400?`${e.url.slice(0,399)}…`:e.url;let n=`${e.method}-request to ${s} resulted in `;n+=`HTTP ${e.statusCode} ${e.statusMessage}`,this.message=n.trim(),this.response=e,this.request=t.options}}function b(){return{onResponse:(e,t)=>{if(!(e.statusCode>=400))return e;throw new g(e,t)}}}function y(e={}){if("function"!=typeof e.inject)throw new Error("`injectResponse` middleware requires a `inject` function");return{interceptRequest:function(t,s){const n=e.inject(s,t);if(!n)return t;const r=s.context.options;return{body:"",url:r.url,method:r.method,headers:{},statusCode:200,statusMessage:"OK",...n}}}}const w=typeof Buffer>"u"?()=>!1:e=>Buffer.isBuffer(e);function F(e){return"[object Object]"===Object.prototype.toString.call(e)}function O(e){if(!1===F(e))return!1;const t=e.constructor;if(void 0===t)return!0;const s=t.prototype;return!(!1===F(s)||!1===s.hasOwnProperty("isPrototypeOf"))}const j=["boolean","string","number"];function v(){return{processOptions:e=>{const t=e.body;return!t||"function"==typeof t.pipe||w(t)||-1===j.indexOf(typeof t)&&!Array.isArray(t)&&!O(t)?e:Object.assign({},e,{body:JSON.stringify(e.body),headers:Object.assign({},e.headers,{"Content-Type":"application/json"})})}}}function x(e){return{onResponse:s=>{const n=s.headers["content-type"]||"",r=e&&e.force||-1!==n.indexOf("application/json");return s.body&&n&&r?Object.assign({},s,{body:t(s.body)}):s},processOptions:e=>Object.assign({},e,{headers:Object.assign({Accept:"application/json"},e.headers)})};function t(e){try{return JSON.parse(e)}catch(e){throw e.message=`Failed to parsed response body as JSON: ${e.message}`,e}}}function E(e={}){if(!e.ca)throw new Error('Required mtls option "ca" is missing');if(!e.cert)throw new Error('Required mtls option "cert" is missing');if(!e.key)throw new Error('Required mtls option "key" is missing');return{finalizeOptions:t=>{if(function(e){return"object"==typeof e&&null!==e&&!("protocol"in e)}(t))return t;const s={cert:e.cert,key:e.key,ca:e.ca};return Object.assign({},t,s)}}}let R={};typeof globalThis<"u"?R=globalThis:typeof window<"u"?R=window:typeof global<"u"?R=global:typeof self<"u"&&(R=self);var k=R;function q(e={}){const t=e.implementation||k.Observable;if(!t)throw new Error("`Observable` is not available in global scope, and no implementation was passed");return{onReturn:(e,s)=>new t((t=>(e.error.subscribe((e=>t.error(e))),e.progress.subscribe((e=>t.next(Object.assign({type:"progress"},e)))),e.response.subscribe((e=>{t.next(Object.assign({type:"response"},e)),t.complete()})),e.request.publish(s),()=>e.abort.publish())))}}function A(){return{onRequest:e=>{if("xhr"!==e.adapter)return;const t=e.request,s=e.context;function n(e){return t=>{const n=t.lengthComputable?t.loaded/t.total*100:-1;s.channels.progress.publish({stage:e,percent:n,total:t.total,loaded:t.loaded,lengthComputable:t.lengthComputable})}}"upload"in t&&"onprogress"in t.upload&&(t.upload.onprogress=n("upload")),"onprogress"in t&&(t.onprogress=n("download"))}}}const S=(e={})=>{const t=e.implementation||Promise;if(!t)throw new Error("`Promise` is not available in global scope, and no implementation was passed");return{onReturn:(s,n)=>new t(((t,r)=>{const o=n.options.cancelToken;o&&o.promise.then((e=>{s.abort.publish(e),r(e)})),s.error.subscribe(r),s.response.subscribe((s=>{t(e.onlyBody?s.body:s)})),setTimeout((()=>{try{s.request.publish(n)}catch(e){r(e)}}),0)}))}};class N{__CANCEL__=!0;message;constructor(e){this.message=e}toString(){return"Cancel"+(this.message?`: ${this.message}`:"")}}class ${promise;reason;constructor(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");let t=null;this.promise=new Promise((e=>{t=e})),e((e=>{this.reason||(this.reason=new N(e),t(this.reason))}))}static source=()=>{let e;return{token:new $((t=>{e=t})),cancel:e}}}function T(e){if(!(!1===e||e&&e.host))throw new Error("Proxy middleware takes an object of host, port and auth properties");return{processOptions:t=>Object.assign({proxy:e},t)}}S.Cancel=N,S.CancelToken=$,S.isCancel=e=>!(!e||!e?.__CANCEL__);var I=(e,t,s)=>("GET"===s.method||"HEAD"===s.method)&&(e.isNetworkError||!1);function M(e){return 100*Math.pow(2,e)+100*Math.random()}const _=(e={})=>(e=>{const t=e.maxRetries||5,s=e.retryDelay||M,n=e.shouldRetry;return{onError:(e,r)=>{const o=r.options,i=o.maxRetries||t,a=o.retryDelay||s,c=o.shouldRetry||n,u=o.attemptNumber||0;if(null!==(l=o.body)&&"object"==typeof l&&"function"==typeof l.pipe||!c(e,u,o)||u>=i)return e;var l;const p=Object.assign({},r,{options:Object.assign({},o,{attemptNumber:u+1})});return setTimeout((()=>r.channels.request.publish(p)),a(u)),null}}})({shouldRetry:I,...e});function P(e){const t=new URLSearchParams,s=(e,n)=>{const r=n instanceof Set?Array.from(n):n;if(Array.isArray(r))if(r.length)for(const t in r)s(`${e}[${t}]`,r[t]);else t.append(`${e}[]`,"");else if("object"==typeof r&&null!==r)for(const[t,n]of Object.entries(r))s(`${e}[${t}]`,n);else t.append(e,r)};for(const[t,n]of Object.entries(e))s(t,n);return t.toString()}function J(){return{processOptions:e=>{const t=e.body;return t&&"function"!=typeof t.pipe&&!w(t)&&O(t)?{...e,body:P(e.body),headers:{...e.headers,"Content-Type":"application/x-www-form-urlencoded"}}:e}}}_.shouldRetry=I;class L extends Error{request;code;constructor(e,t){super(e.message),this.request=t,this.code=e.code}}const z=(H=n,function(e={}){const{maxRetries:t=3,ms:s=1e3,maxFree:n=256}=e,{finalizeOptions:r}=H({keepAlive:!0,keepAliveMsecs:s,maxFreeSockets:n});return{finalizeOptions:r,onError:(e,s)=>{if(("GET"===s.options.method||"POST"===s.options.method)&&e instanceof L&&"ECONNRESET"===e.code&&e.request.reusedSocket){const e=s.options.attemptNumber||0;if(e<t){const t=Object.assign({},s,{options:Object.assign({},s.options,{attemptNumber:e+1})});return setImmediate((()=>s.channels.request.publish(t))),null}}return e}}});var H;export{N as Cancel,$ as CancelToken,n as agent,i as base,C as debug,h as headers,b as httpErrors,y as injectResponse,v as jsonRequest,x as jsonResponse,z as keepAlive,E as mtls,q as observable,t as processOptions,A as progress,S as promise,T as proxy,_ as retry,J as urlEncoded,s as validateOptions};//# sourceMappingURL=middleware.browser.js.map
import{g as e}from"./_chunks-es/_commonjsHelpers.js";import{p as t,v as s}from"./_chunks-es/_commonjsHelpers.js";function n(e){return{}}const r=/^\//,o=/\/$/;function i(e){const t=e.replace(o,"");return{processOptions:e=>{if(/^https?:\/\//i.test(e.url))return e;const s=[t,e.url.replace(r,"")].join("/");return Object.assign({},e,{url:s})}}}var a,c,u,l,p,d={exports:{}},f=/* @__PURE__ */e((p||(p=1,function(e,t){t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const s="color: "+this.color;t.splice(1,0,s,"color: inherit");let n=0,r=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(n++,"%c"===e&&(r=n))})),t.splice(r,0,s)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch{}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch{}return!e&&typeof process<"u"&&"env"in process&&(e=process.env.DEBUG),e},t.useColors=function(){return!(!(typeof window<"u"&&window.process)||"renderer"!==window.process.type&&!window.process.__nwjs)||!(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&(typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},t.storage=function(){try{return localStorage}catch{}}(),t.destroy=/* @__PURE__ */(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=(l?u:(l=1,u=function(e){function t(e){let n,r,o,i=null;function a(...e){if(!a.enabled)return;const s=a,r=Number(/* @__PURE__ */new Date),o=r-(n||r);s.diff=o,s.prev=n,s.curr=r,n=r,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let i=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((n,r)=>{if("%%"===n)return"%";i++;const o=t.formatters[r];if("function"==typeof o){const t=e[i];n=o.call(s,t),e.splice(i,1),i--}return n})),t.formatArgs.call(s,e),(s.log||t.log).apply(s,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=s,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==i?i:(r!==t.namespaces&&(r=t.namespaces,o=t.enabled(e)),o),set:e=>{i=e}}),"function"==typeof t.init&&t.init(a),a}function s(e,s){const n=t(this.namespace+(typeof s>"u"?":":s)+e);return n.log=this.log,n}function n(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){const e=[...t.names.map(n),...t.skips.map(n).map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){let s;t.save(e),t.namespaces=e,t.names=[],t.skips=[];const n=("string"==typeof e?e:"").split(/[\s,]+/),r=n.length;for(s=0;s<r;s++)n[s]&&("-"===(e=n[s].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.slice(1)+"$")):t.names.push(new RegExp("^"+e+"$")))},t.enabled=function(e){if("*"===e[e.length-1])return!0;let s,n;for(s=0,n=t.skips.length;s<n;s++)if(t.skips[s].test(e))return!1;for(s=0,n=t.names.length;s<n;s++)if(t.names[s].test(e))return!0;return!1},t.humanize=function(){if(c)return a;c=1;var e=1e3,t=60*e,s=60*t,n=24*s,r=7*n;function o(e,t,s,n){var r=t>=1.5*s;return Math.round(e/s)+" "+n+(r?"s":"")}return a=function(i,a){a=a||{};var c,u,l=typeof i;if("string"===l&&i.length>0)return function(o){if(!((o=String(o)).length>100)){var i=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(o);if(i){var a=parseFloat(i[1]);switch((i[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*a;case"weeks":case"week":case"w":return a*r;case"days":case"day":case"d":return a*n;case"hours":case"hour":case"hrs":case"hr":case"h":return a*s;case"minutes":case"minute":case"mins":case"min":case"m":return a*t;case"seconds":case"second":case"secs":case"sec":case"s":return a*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return a;default:return}}}}(i);if("number"===l&&isFinite(i))return a.long?(c=i,(u=Math.abs(c))>=n?o(c,u,n,"day"):u>=s?o(c,u,s,"hour"):u>=t?o(c,u,t,"minute"):u>=e?o(c,u,e,"second"):c+" ms"):function(r){var o=Math.abs(r);return o>=n?Math.round(r/n)+"d":o>=s?Math.round(r/s)+"h":o>=t?Math.round(r/t)+"m":o>=e?Math.round(r/e)+"s":r+"ms"}(i);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(i))}}(),t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach((s=>{t[s]=e[s]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let s=0;for(let t=0;t<e.length;t++)s=(s<<5)-s+e.charCodeAt(t),s|=0;return t.colors[Math.abs(s)%t.colors.length]},t.enable(t.load()),t}))(t);const{formatters:s}=e.exports;s.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(d,d.exports)),d.exports));const m=["cookie","authorization"],C=Object.prototype.hasOwnProperty;function h(e={}){const t=e.verbose,s=e.namespace||"get-it",n=f(s),r=e.log||n,o=r===n&&!f.enabled(s);let i=0;return{processOptions:e=>(e.debug=r,e.requestId=e.requestId||++i,e),onRequest:s=>{if(o||!s)return s;const n=s.options;if(r("[%s] HTTP %s %s",n.requestId,n.method,n.url),t&&n.body&&"string"==typeof n.body&&r("[%s] Request body: %s",n.requestId,n.body),t&&n.headers){const t=!1===e.redactSensitiveHeaders?n.headers:((e,t)=>{const s={};for(const n in e)C.call(e,n)&&(s[n]=t.indexOf(n.toLowerCase())>-1?"<redacted>":e[n]);return s})(n.headers,m);r("[%s] Request headers: %s",n.requestId,JSON.stringify(t,null,2))}return s},onResponse:(e,s)=>{if(o||!e)return e;const n=s.options.requestId;return r("[%s] Response code: %s %s",n,e.statusCode,e.statusMessage),t&&e.body&&r("[%s] Response body: %s",n,function(e){return-1!==(e.headers["content-type"]||"").toLowerCase().indexOf("application/json")?function(e){try{const t="string"==typeof e?JSON.parse(e):e;return JSON.stringify(t,null,2)}catch{return e}}(e.body):e.body}(e)),e},onError:(e,t)=>{const s=t.options.requestId;return e?(r("[%s] ERROR: %s",s,e.message),e):(r("[%s] Error encountered, but handled by an earlier middleware",s),e)}}}function g(e,t={}){return{processOptions:s=>{const n=s.headers||{};return s.headers=t.override?Object.assign({},n,e):Object.assign({},e,n),s}}}class b extends Error{response;request;constructor(e,t){super();const s=e.url.length>400?`${e.url.slice(0,399)}…`:e.url;let n=`${e.method}-request to ${s} resulted in `;n+=`HTTP ${e.statusCode} ${e.statusMessage}`,this.message=n.trim(),this.response=e,this.request=t.options}}function y(){return{onResponse:(e,t)=>{if(!(e.statusCode>=400))return e;throw new b(e,t)}}}function w(e={}){if("function"!=typeof e.inject)throw new Error("`injectResponse` middleware requires a `inject` function");return{interceptRequest:function(t,s){const n=e.inject(s,t);if(!n)return t;const r=s.context.options;return{body:"",url:r.url,method:r.method,headers:{},statusCode:200,statusMessage:"OK",...n}}}}const F=typeof Buffer>"u"?()=>!1:e=>Buffer.isBuffer(e);function O(e){return"[object Object]"===Object.prototype.toString.call(e)}function j(e){if(!1===O(e))return!1;const t=e.constructor;if(void 0===t)return!0;const s=t.prototype;return!(!1===O(s)||!1===s.hasOwnProperty("isPrototypeOf"))}const v=["boolean","string","number"];function x(){return{processOptions:e=>{const t=e.body;return!t||"function"==typeof t.pipe||F(t)||-1===v.indexOf(typeof t)&&!Array.isArray(t)&&!j(t)?e:Object.assign({},e,{body:JSON.stringify(e.body),headers:Object.assign({},e.headers,{"Content-Type":"application/json"})})}}}function E(e){return{onResponse:s=>{const n=s.headers["content-type"]||"",r=e&&e.force||-1!==n.indexOf("application/json");return s.body&&n&&r?Object.assign({},s,{body:t(s.body)}):s},processOptions:e=>Object.assign({},e,{headers:Object.assign({Accept:"application/json"},e.headers)})};function t(e){try{return JSON.parse(e)}catch(e){throw e.message=`Failed to parsed response body as JSON: ${e.message}`,e}}}function R(e={}){if(!e.ca)throw new Error('Required mtls option "ca" is missing');if(!e.cert)throw new Error('Required mtls option "cert" is missing');if(!e.key)throw new Error('Required mtls option "key" is missing');return{finalizeOptions:t=>{if(function(e){return"object"==typeof e&&null!==e&&!("protocol"in e)}(t))return t;const s={cert:e.cert,key:e.key,ca:e.ca};return Object.assign({},t,s)}}}let k={};typeof globalThis<"u"?k=globalThis:typeof window<"u"?k=window:typeof global<"u"?k=global:typeof self<"u"&&(k=self);var q=k;function A(e={}){const t=e.implementation||q.Observable;if(!t)throw new Error("`Observable` is not available in global scope, and no implementation was passed");return{onReturn:(e,s)=>new t((t=>(e.error.subscribe((e=>t.error(e))),e.progress.subscribe((e=>t.next(Object.assign({type:"progress"},e)))),e.response.subscribe((e=>{t.next(Object.assign({type:"response"},e)),t.complete()})),e.request.publish(s),()=>e.abort.publish())))}}function S(){return{onRequest:e=>{if("xhr"!==e.adapter)return;const t=e.request,s=e.context;function n(e){return t=>{const n=t.lengthComputable?t.loaded/t.total*100:-1;s.channels.progress.publish({stage:e,percent:n,total:t.total,loaded:t.loaded,lengthComputable:t.lengthComputable})}}"upload"in t&&"onprogress"in t.upload&&(t.upload.onprogress=n("upload")),"onprogress"in t&&(t.onprogress=n("download"))}}}const N=(e={})=>{const t=e.implementation||Promise;if(!t)throw new Error("`Promise` is not available in global scope, and no implementation was passed");return{onReturn:(s,n)=>new t(((t,r)=>{const o=n.options.cancelToken;o&&o.promise.then((e=>{s.abort.publish(e),r(e)})),s.error.subscribe(r),s.response.subscribe((s=>{t(e.onlyBody?s.body:s)})),setTimeout((()=>{try{s.request.publish(n)}catch(e){r(e)}}),0)}))}};class ${__CANCEL__=!0;message;constructor(e){this.message=e}toString(){return"Cancel"+(this.message?`: ${this.message}`:"")}}class T{promise;reason;constructor(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");let t=null;this.promise=new Promise((e=>{t=e})),e((e=>{this.reason||(this.reason=new $(e),t(this.reason))}))}static source=()=>{let e;return{token:new T((t=>{e=t})),cancel:e}}}function I(e){if(!(!1===e||e&&e.host))throw new Error("Proxy middleware takes an object of host, port and auth properties");return{processOptions:t=>Object.assign({proxy:e},t)}}N.Cancel=$,N.CancelToken=T,N.isCancel=e=>!(!e||!e?.__CANCEL__);var M=(e,t,s)=>("GET"===s.method||"HEAD"===s.method)&&(e.isNetworkError||!1);function _(e){return 100*Math.pow(2,e)+100*Math.random()}const P=(e={})=>(e=>{const t=e.maxRetries||5,s=e.retryDelay||_,n=e.shouldRetry;return{onError:(e,r)=>{const o=r.options,i=o.maxRetries||t,a=o.retryDelay||s,c=o.shouldRetry||n,u=o.attemptNumber||0;if(null!==(l=o.body)&&"object"==typeof l&&"function"==typeof l.pipe||!c(e,u,o)||u>=i)return e;var l;const p=Object.assign({},r,{options:Object.assign({},o,{attemptNumber:u+1})});return setTimeout((()=>r.channels.request.publish(p)),a(u)),null}}})({shouldRetry:M,...e});function J(e){const t=new URLSearchParams,s=(e,n)=>{const r=n instanceof Set?Array.from(n):n;if(Array.isArray(r))if(r.length)for(const t in r)s(`${e}[${t}]`,r[t]);else t.append(`${e}[]`,"");else if("object"==typeof r&&null!==r)for(const[t,n]of Object.entries(r))s(`${e}[${t}]`,n);else t.append(e,r)};for(const[t,n]of Object.entries(e))s(t,n);return t.toString()}function L(){return{processOptions:e=>{const t=e.body;return t&&"function"!=typeof t.pipe&&!F(t)&&j(t)?{...e,body:J(e.body),headers:{...e.headers,"Content-Type":"application/x-www-form-urlencoded"}}:e}}}P.shouldRetry=M;class z extends Error{request;code;constructor(e,t){super(e.message),this.request=t,this.code=e.code}}const H=(B=n,function(e={}){const{maxRetries:t=3,ms:s=1e3,maxFree:n=256}=e,{finalizeOptions:r}=B({keepAlive:!0,keepAliveMsecs:s,maxFreeSockets:n});return{finalizeOptions:r,onError:(e,s)=>{if(("GET"===s.options.method||"POST"===s.options.method)&&e instanceof z&&"ECONNRESET"===e.code&&e.request.reusedSocket){const e=s.options.attemptNumber||0;if(e<t){const t=Object.assign({},s,{options:Object.assign({},s.options,{attemptNumber:e+1})});return setImmediate((()=>s.channels.request.publish(t))),null}}return e}}});var B;export{$ as Cancel,T as CancelToken,n as agent,i as base,h as debug,g as headers,y as httpErrors,w as injectResponse,x as jsonRequest,E as jsonResponse,H as keepAlive,R as mtls,A as observable,t as processOptions,S as progress,N as promise,I as proxy,P as retry,L as urlEncoded,s as validateOptions};//# sourceMappingURL=middleware.browser.js.map
import {AgentOptions} from 'http'
import {FinalizeNodeOptionsPayload} from 'get-it'
import {FinalizeNodeOptionsPayload as FinalizeNodeOptionsPayload_2} from 'get-it'
import {HookOnRequestEvent} from 'get-it'

@@ -7,9 +7,9 @@ import {HttpContext} from 'get-it'

import {IncomingMessage} from 'http'
import {MiddlewareChannels} from 'get-it'
import type {MiddlewareHooks} from 'get-it'
import {MiddlewareChannels as MiddlewareChannels_2} from 'get-it'
import {MiddlewareResponse} from 'get-it'
import type {ProgressStream} from 'progress-stream'
import progressStream from 'progress-stream'
import {RequestAdapter} from 'get-it'
import {RequestAdapter as RequestAdapter_2} from 'get-it'
import {RequestOptions} from 'get-it'
import type {RetryOptions} from 'get-it'
import type {UrlWithStringQuery} from 'url'

@@ -26,2 +26,9 @@ /**

/** @public */
declare type ApplyMiddleware = <T extends keyof MiddlewareHooks>(
hook: T,
value: MiddlewareHooks[T] extends (defaultValue: infer V, ...rest: any[]) => any ? V : never,
...args: MiddlewareHooks[T] extends (defaultValue: any, ...rest: infer P) => any ? P : never
) => ReturnType<MiddlewareHooks[T]>
/** @public */
export declare function base(baseUrl: string): {

@@ -65,2 +72,13 @@ processOptions: (options: RequestOptions) => RequestOptions

/** @public */
declare interface FinalizeNodeOptionsPayload extends UrlWithStringQuery {
method: RequestOptions_2['method']
headers: RequestOptions_2['headers']
maxRedirects: RequestOptions_2['maxRedirects']
agent?: any
cert?: any
key?: any
ca?: any
}
/** @public */
export declare function headers(

@@ -74,2 +92,31 @@ _headers: any,

/** @public */
declare type HookOnRequestEvent_2 = HookOnRequestEventNode | HookOnRequestEventBrowser
/** @public */
declare interface HookOnRequestEventBase {
options: RequestOptions_2
context: HttpContext_2
request: any
}
/** @public */
declare interface HookOnRequestEventBrowser extends HookOnRequestEventBase {
adapter: Omit<RequestAdapter, 'node'>
progress?: undefined
}
/** @public */
declare interface HookOnRequestEventNode extends HookOnRequestEventBase {
adapter: 'node'
progress: any
}
/** @public */
declare interface HttpContext_2 {
options: RequestOptions_2
channels: MiddlewareChannels
applyMiddleware: ApplyMiddleware
}
/** @public */
export declare function httpErrors(): {

@@ -84,11 +131,11 @@ onResponse: (res: MiddlewareResponse, ctx: HttpContext) => MiddlewareResponse

prevValue: Parameters<MiddlewareHooks['interceptRequest']>[0],
) => Partial<MiddlewareResponse | undefined | void>
) => Partial<MiddlewareResponse_2 | undefined | void>
}): {
interceptRequest: (
prevValue: MiddlewareResponse | undefined,
prevValue: MiddlewareResponse_2 | undefined,
event: {
adapter: RequestAdapter
adapter: RequestAdapter_2
context: HttpContext
},
) => MiddlewareResponse | undefined
) => MiddlewareResponse_2 | undefined
}

@@ -117,6 +164,53 @@

/** @public */
declare interface MiddlewareChannels {
request: PubSub<HttpContext_2>
response: PubSub<unknown>
progress: PubSub<unknown>
error: PubSub<unknown>
abort: PubSub<void>
}
/** @public */
declare interface MiddlewareHooks {
processOptions: (options: RequestOptions_2) => RequestOptions_2
validateOptions: (options: RequestOptions_2) => void | undefined
interceptRequest: (
prevValue: MiddlewareResponse_2 | undefined,
event: {
adapter: RequestAdapter
context: HttpContext_2
},
) => MiddlewareResponse_2 | undefined | void
finalizeOptions: (
options: FinalizeNodeOptionsPayload | RequestOptions_2,
) => FinalizeNodeOptionsPayload | RequestOptions_2
onRequest: (evt: HookOnRequestEvent_2) => void
onResponse: (response: MiddlewareResponse_2, context: HttpContext_2) => MiddlewareResponse_2
onError: (err: Error | null, context: HttpContext_2) => any
onReturn: (channels: MiddlewareChannels, context: HttpContext_2) => any
onHeaders: (
response: IncomingMessage,
evt: {
headers: IncomingHttpHeaders
adapter: RequestAdapter
context: HttpContext_2
},
) => ProgressStream
}
/** @public */
declare interface MiddlewareResponse_2 {
body: any
url: string
method: string
headers: any
statusCode: number
statusMessage: string
}
/** @public */
export declare function mtls(config?: any): {
finalizeOptions: (options: RequestOptions | FinalizeNodeOptionsPayload) =>
finalizeOptions: (options: RequestOptions | FinalizeNodeOptionsPayload_2) =>
| RequestOptions
| (FinalizeNodeOptionsPayload & {
| (FinalizeNodeOptionsPayload_2 & {
cert: any

@@ -130,7 +224,7 @@ key: any

export declare function observable(opts?: {implementation?: any}): {
onReturn: (channels: MiddlewareChannels, context: HttpContext) => any
onReturn: (channels: MiddlewareChannels_2, context: HttpContext) => any
}
/** @public */
export declare const processOptions: (opts: RequestOptions) => {
export declare const processOptions: (opts: RequestOptions_2) => {
url: string

@@ -167,3 +261,3 @@ body?: any

headers: IncomingHttpHeaders
adapter: RequestAdapter
adapter: RequestAdapter_2
context: HttpContext

@@ -178,3 +272,3 @@ },

(options?: {onlyBody?: boolean; implementation?: PromiseConstructor}): {
onReturn: (channels: MiddlewareChannels, context: HttpContext) => Promise<unknown>
onReturn: (channels: MiddlewareChannels_2, context: HttpContext) => Promise<unknown>
}

@@ -194,2 +288,49 @@ Cancel: typeof Cancel

/** @public */
declare interface PubSub<Message> {
publish: (message: Message) => void
subscribe: (subscriber: Subscriber<Message>) => () => void
}
/**
* Reports the request adapter in use. `node` is only available if `ExportEnv` is also `node`.
* When `ExportEnv` is `browser` then the adapter can be either `xhr` or `fetch`.
* In the future `fetch` will be available in `node` as well.
* @public
*/
declare type RequestAdapter = 'node' | 'xhr' | 'fetch'
/** @public */
declare interface RequestOptions_2 {
url: string
body?: any
bodySize?: number
cancelToken?: any
compress?: boolean
headers?: any
maxRedirects?: number
maxRetries?: number
retryDelay?: (attemptNumber: number) => number
method?: string
proxy?: any
query?: any
rawBody?: boolean
shouldRetry?: any
stream?: boolean
timeout?: any
tunnel?: boolean
debug?: any
requestId?: number
attemptNumber?: number
withCredentials?: boolean
/**
* Enables using the native `fetch` API instead of the default `http` module, and allows setting its options like `cache`
*/
fetch?: boolean | Omit<RequestInit, 'method'>
/**
* Some frameworks have special behavior for `fetch` when an `AbortSignal` is used, and may want to disable it unless userland specifically opts-in.
*/
useAbortSignal?: boolean
}
/** @public */
export declare const retry: {

@@ -203,2 +344,14 @@ (opts?: Partial<RetryOptions>): {

/** @public */
declare interface RetryOptions {
shouldRetry: (err: any, num: number, options: any) => boolean
maxRetries?: number
retryDelay?: (attemptNumber: number) => number
}
/** @public */
declare interface Subscriber<Event> {
(event: Event): void
}
/** @public */
export declare function urlEncoded(): {

@@ -205,0 +358,0 @@ processOptions: (options: RequestOptions) => RequestOptions

@@ -1,1 +0,1 @@

import{Agent as e}from"http";import{Agent as t}from"https";import{g as s}from"./_chunks-es/_commonjsHelpers.js";import r from"tty";import n from"util";import{p as o,v as i}from"./_chunks-es/defaultOptionsValidator.js";import c from"progress-stream";import a from"is-retry-allowed";import{N as u}from"./_chunks-es/node-request.js";const p=/^https:/i;function l(s){const r=new e(s),n=new t(s),o={http:r,https:n};return{finalizeOptions:e=>{if(e.agent)return e;if(e.maxRedirects>0)return{...e,agents:o};const t=p.test(e.href||e.protocol);return{...e,agent:t?n:r}}}}const d=/^\//,f=/\/$/;function m(e){const t=e.replace(f,"");return{processOptions:e=>{if(/^https?:\/\//i.test(e.url))return e;const s=[t,e.url.replace(d,"")].join("/");return Object.assign({},e,{url:s})}}}var h,g,C,b,y,w={exports:{}},F={exports:{}};function O(){if(g)return h;g=1;var e=1e3,t=60*e,s=60*t,r=24*s,n=7*r,o=365.25*r;function i(e,t,s,r){var n=t>=1.5*s;return Math.round(e/s)+" "+r+(n?"s":"")}return h=function(c,a){a=a||{};var u,p,l=typeof c;if("string"===l&&c.length>0)return function(i){if(!((i=String(i)).length>100)){var c=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(i);if(c){var a=parseFloat(c[1]);switch((c[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return a*o;case"weeks":case"week":case"w":return a*n;case"days":case"day":case"d":return a*r;case"hours":case"hour":case"hrs":case"hr":case"h":return a*s;case"minutes":case"minute":case"mins":case"min":case"m":return a*t;case"seconds":case"second":case"secs":case"sec":case"s":return a*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return a;default:return}}}}(c);if("number"===l&&isFinite(c))return a.long?(u=c,(p=Math.abs(u))>=r?i(u,p,r,"day"):p>=s?i(u,p,s,"hour"):p>=t?i(u,p,t,"minute"):p>=e?i(u,p,e,"second"):u+" ms"):function(n){var o=Math.abs(n);return o>=r?Math.round(n/r)+"d":o>=s?Math.round(n/s)+"h":o>=t?Math.round(n/t)+"m":o>=e?Math.round(n/e)+"s":n+"ms"}(c);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(c))}}function v(){if(b)return C;return b=1,C=function(e){function t(e){let r,n,o,i=null;function c(...e){if(!c.enabled)return;const s=c,n=Number(new Date),o=n-(r||n);s.diff=o,s.prev=r,s.curr=n,r=n,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let i=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((r,n)=>{if("%%"===r)return"%";i++;const o=t.formatters[n];if("function"==typeof o){const t=e[i];r=o.call(s,t),e.splice(i,1),i--}return r})),t.formatArgs.call(s,e),(s.log||t.log).apply(s,e)}return c.namespace=e,c.useColors=t.useColors(),c.color=t.selectColor(e),c.extend=s,c.destroy=t.destroy,Object.defineProperty(c,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==i?i:(n!==t.namespaces&&(n=t.namespaces,o=t.enabled(e)),o),set:e=>{i=e}}),"function"==typeof t.init&&t.init(c),c}function s(e,s){const r=t(this.namespace+(typeof s>"u"?":":s)+e);return r.log=this.log,r}function r(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){const e=[...t.names.map(r),...t.skips.map(r).map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){let s;t.save(e),t.namespaces=e,t.names=[],t.skips=[];const r=("string"==typeof e?e:"").split(/[\s,]+/),n=r.length;for(s=0;s<n;s++)r[s]&&("-"===(e=r[s].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.slice(1)+"$")):t.names.push(new RegExp("^"+e+"$")))},t.enabled=function(e){if("*"===e[e.length-1])return!0;let s,r;for(s=0,r=t.skips.length;s<r;s++)if(t.skips[s].test(e))return!1;for(s=0,r=t.names.length;s<r;s++)if(t.names[s].test(e))return!0;return!1},t.humanize=O(),t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach((s=>{t[s]=e[s]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let s=0;for(let t=0;t<e.length;t++)s=(s<<5)-s+e.charCodeAt(t),s|=0;return t.colors[Math.abs(s)%t.colors.length]},t.enable(t.load()),t}}var j,x,E,R={exports:{}};typeof process>"u"||"renderer"===process.type||!0===process.browser||process.__nwjs?w.exports=(y||(y=1,function(e,t){t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const s="color: "+this.color;t.splice(1,0,s,"color: inherit");let r=0,n=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(r++,"%c"===e&&(n=r))})),t.splice(n,0,s)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch{}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch{}return!e&&typeof process<"u"&&"env"in process&&(e=process.env.DEBUG),e},t.useColors=function(){return!(!(typeof window<"u"&&window.process)||"renderer"!==window.process.type&&!window.process.__nwjs)||!(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&(typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},t.storage=function(){try{return localStorage}catch{}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=v()(t);const{formatters:s}=e.exports;s.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(F,F.exports)),F.exports):w.exports=(E||(E=1,function(e,t){const s=r,o=n;t.init=function(e){e.inspectOpts={};const s=Object.keys(t.inspectOpts);for(let r=0;r<s.length;r++)e.inspectOpts[s[r]]=t.inspectOpts[s[r]]},t.log=function(...e){return process.stderr.write(o.format(...e)+"\n")},t.formatArgs=function(s){const{namespace:r,useColors:n}=this;if(n){const t=this.color,n="[3"+(t<8?t:"8;5;"+t),o=` ${n};1m${r} `;s[0]=o+s[0].split("\n").join("\n"+o),s.push(n+"m+"+e.exports.humanize(this.diff)+"")}else s[0]=(t.inspectOpts.hideDate?"":(new Date).toISOString()+" ")+r+" "+s[0]},t.save=function(e){e?process.env.DEBUG=e:delete process.env.DEBUG},t.load=function(){return process.env.DEBUG},t.useColors=function(){return"colors"in t.inspectOpts?!!t.inspectOpts.colors:s.isatty(process.stderr.fd)},t.destroy=o.deprecate((()=>{}),"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."),t.colors=[6,2,3,4,5,1];try{const e=function(){if(x)return j;x=1;const e=function(){const e=/(Chrome|Chromium)\/(?<chromeVersion>\d+)\./.exec(navigator.userAgent);if(e)return Number.parseInt(e.groups.chromeVersion,10)}()>=69&&{level:1,hasBasic:!0,has256:!1,has16m:!1};return j={stdout:e,stderr:e}}();e&&(e.stderr||e).level>=2&&(t.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch{}t.inspectOpts=Object.keys(process.env).filter((e=>/^debug_/i.test(e))).reduce(((e,t)=>{const s=t.substring(6).toLowerCase().replace(/_([a-z])/g,((e,t)=>t.toUpperCase()));let r=process.env[t];return r=!!/^(yes|on|true|enabled)$/i.test(r)||!/^(no|off|false|disabled)$/i.test(r)&&("null"===r?null:Number(r)),e[s]=r,e}),{}),e.exports=v()(t);const{formatters:i}=e.exports;i.o=function(e){return this.inspectOpts.colors=this.useColors,o.inspect(e,this.inspectOpts).split("\n").map((e=>e.trim())).join(" ")},i.O=function(e){return this.inspectOpts.colors=this.useColors,o.inspect(e,this.inspectOpts)}}(R,R.exports)),R.exports);var k=s(w.exports);const A=["cookie","authorization"],q=Object.prototype.hasOwnProperty;function S(e={}){const t=e.verbose,s=e.namespace||"get-it",r=k(s),n=e.log||r,o=n===r&&!k.enabled(s);let i=0;return{processOptions:e=>(e.debug=n,e.requestId=e.requestId||++i,e),onRequest:s=>{if(o||!s)return s;const r=s.options;if(n("[%s] HTTP %s %s",r.requestId,r.method,r.url),t&&r.body&&"string"==typeof r.body&&n("[%s] Request body: %s",r.requestId,r.body),t&&r.headers){const t=!1===e.redactSensitiveHeaders?r.headers:((e,t)=>{const s={};for(const r in e)q.call(e,r)&&(s[r]=t.indexOf(r.toLowerCase())>-1?"<redacted>":e[r]);return s})(r.headers,A);n("[%s] Request headers: %s",r.requestId,JSON.stringify(t,null,2))}return s},onResponse:(e,s)=>{if(o||!e)return e;const r=s.options.requestId;return n("[%s] Response code: %s %s",r,e.statusCode,e.statusMessage),t&&e.body&&n("[%s] Response body: %s",r,function(e){return-1!==(e.headers["content-type"]||"").toLowerCase().indexOf("application/json")?function(e){try{const t="string"==typeof e?JSON.parse(e):e;return JSON.stringify(t,null,2)}catch{return e}}(e.body):e.body}(e)),e},onError:(e,t)=>{const s=t.options.requestId;return e?(n("[%s] ERROR: %s",s,e.message),e):(n("[%s] Error encountered, but handled by an earlier middleware",s),e)}}}function N(e,t={}){return{processOptions:s=>{const r=s.headers||{};return s.headers=t.override?Object.assign({},r,e):Object.assign({},e,r),s}}}class $ extends Error{response;request;constructor(e,t){super();const s=e.url.length>400?`${e.url.slice(0,399)}…`:e.url;let r=`${e.method}-request to ${s} resulted in `;r+=`HTTP ${e.statusCode} ${e.statusMessage}`,this.message=r.trim(),this.response=e,this.request=t.options}}function I(){return{onResponse:(e,t)=>{if(!(e.statusCode>=400))return e;throw new $(e,t)}}}function _(e={}){if("function"!=typeof e.inject)throw new Error("`injectResponse` middleware requires a `inject` function");return{interceptRequest:function(t,s){const r=e.inject(s,t);if(!r)return t;const n=s.context.options;return{body:"",url:n.url,method:n.method,headers:{},statusCode:200,statusMessage:"OK",...r}}}}const T=typeof Buffer>"u"?()=>!1:e=>Buffer.isBuffer(e);function M(e){return"[object Object]"===Object.prototype.toString.call(e)}function P(e){if(!1===M(e))return!1;const t=e.constructor;if(void 0===t)return!0;const s=t.prototype;return!(!1===M(s)||!1===s.hasOwnProperty("isPrototypeOf"))}const z=["boolean","string","number"];function L(){return{processOptions:e=>{const t=e.body;return!t||"function"==typeof t.pipe||T(t)||-1===z.indexOf(typeof t)&&!Array.isArray(t)&&!P(t)?e:Object.assign({},e,{body:JSON.stringify(e.body),headers:Object.assign({},e.headers,{"Content-Type":"application/json"})})}}}function D(e){return{onResponse:s=>{const r=s.headers["content-type"]||"",n=e&&e.force||-1!==r.indexOf("application/json");return s.body&&r&&n?Object.assign({},s,{body:t(s.body)}):s},processOptions:e=>Object.assign({},e,{headers:Object.assign({Accept:"application/json"},e.headers)})};function t(e){try{return JSON.parse(e)}catch(e){throw e.message=`Failed to parsed response body as JSON: ${e.message}`,e}}}function B(e={}){if(!e.ca)throw new Error('Required mtls option "ca" is missing');if(!e.cert)throw new Error('Required mtls option "cert" is missing');if(!e.key)throw new Error('Required mtls option "key" is missing');return{finalizeOptions:t=>{if(function(e){return"object"==typeof e&&null!==e&&!("protocol"in e)}(t))return t;const s={cert:e.cert,key:e.key,ca:e.ca};return Object.assign({},t,s)}}}let J={};typeof globalThis<"u"?J=globalThis:typeof window<"u"?J=window:typeof global<"u"?J=global:typeof self<"u"&&(J=self);var U=J;function G(e={}){const t=e.implementation||U.Observable;if(!t)throw new Error("`Observable` is not available in global scope, and no implementation was passed");return{onReturn:(e,s)=>new t((t=>(e.error.subscribe((e=>t.error(e))),e.progress.subscribe((e=>t.next(Object.assign({type:"progress"},e)))),e.response.subscribe((e=>{t.next(Object.assign({type:"response"},e)),t.complete()})),e.request.publish(s),()=>e.abort.publish())))}}function H(e){return t=>({stage:e,percent:t.percentage,total:t.length,loaded:t.transferred,lengthComputable:!(0===t.length&&0===t.percentage)})}function V(){return{onHeaders:(e,t)=>{const s=c({time:16}),r=H("download"),n=e.headers["content-length"],o=n?Number(n):0;return!isNaN(o)&&o>0&&s.setLength(o),s.on("progress",(e=>t.context.channels.progress.publish(r(e)))),e.pipe(s)},onRequest:e=>{if(!e.progress)return;const t=H("upload");e.progress.on("progress",(s=>e.context.channels.progress.publish(t(s))))}}}const Z=(e={})=>{const t=e.implementation||Promise;if(!t)throw new Error("`Promise` is not available in global scope, and no implementation was passed");return{onReturn:(s,r)=>new t(((t,n)=>{const o=r.options.cancelToken;o&&o.promise.then((e=>{s.abort.publish(e),n(e)})),s.error.subscribe(n),s.response.subscribe((s=>{t(e.onlyBody?s.body:s)})),setTimeout((()=>{try{s.request.publish(r)}catch(e){n(e)}}),0)}))}};class K{__CANCEL__=!0;message;constructor(e){this.message=e}toString(){return"Cancel"+(this.message?`: ${this.message}`:"")}}class W{promise;reason;constructor(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");let t=null;this.promise=new Promise((e=>{t=e})),e((e=>{this.reason||(this.reason=new K(e),t(this.reason))}))}static source=()=>{let e;return{token:new W((t=>{e=t})),cancel:e}}}function Q(e){if(!(!1===e||e&&e.host))throw new Error("Proxy middleware takes an object of host, port and auth properties");return{processOptions:t=>Object.assign({proxy:e},t)}}Z.Cancel=K,Z.CancelToken=W,Z.isCancel=e=>!(!e||!e?.__CANCEL__);var X=(e,t,s)=>!("GET"!==s.method&&"HEAD"!==s.method||e.response&&e.response.statusCode)&&a(e);function Y(e){return 100*Math.pow(2,e)+100*Math.random()}const ee=(e={})=>(e=>{const t=e.maxRetries||5,s=e.retryDelay||Y,r=e.shouldRetry;return{onError:(e,n)=>{const o=n.options,i=o.maxRetries||t,c=o.retryDelay||s,a=o.shouldRetry||r,u=o.attemptNumber||0;if(null!==(p=o.body)&&"object"==typeof p&&"function"==typeof p.pipe||!a(e,u,o)||u>=i)return e;var p;const l=Object.assign({},n,{options:Object.assign({},o,{attemptNumber:u+1})});return setTimeout((()=>n.channels.request.publish(l)),c(u)),null}}})({shouldRetry:X,...e});function te(e){const t=new URLSearchParams,s=(e,r)=>{const n=r instanceof Set?Array.from(r):r;if(Array.isArray(n))if(n.length)for(const t in n)s(`${e}[${t}]`,n[t]);else t.append(`${e}[]`,"");else if("object"==typeof n&&null!==n)for(const[t,r]of Object.entries(n))s(`${e}[${t}]`,r);else t.append(e,n)};for(const[t,r]of Object.entries(e))s(t,r);return t.toString()}function se(){return{processOptions:e=>{const t=e.body;return t&&"function"!=typeof t.pipe&&!T(t)&&P(t)?{...e,body:te(e.body),headers:{...e.headers,"Content-Type":"application/x-www-form-urlencoded"}}:e}}}ee.shouldRetry=X;const re=(ne=l,function(e={}){const{maxRetries:t=3,ms:s=1e3,maxFree:r=256}=e,{finalizeOptions:n}=ne({keepAlive:!0,keepAliveMsecs:s,maxFreeSockets:r});return{finalizeOptions:n,onError:(e,s)=>{if(("GET"===s.options.method||"POST"===s.options.method)&&e instanceof u&&"ECONNRESET"===e.code&&e.request.reusedSocket){const e=s.options.attemptNumber||0;if(e<t){const t=Object.assign({},s,{options:Object.assign({},s.options,{attemptNumber:e+1})});return setImmediate((()=>s.channels.request.publish(t))),null}}return e}}});var ne;export{K as Cancel,W as CancelToken,l as agent,m as base,S as debug,N as headers,I as httpErrors,_ as injectResponse,L as jsonRequest,D as jsonResponse,re as keepAlive,B as mtls,G as observable,o as processOptions,V as progress,Z as promise,Q as proxy,ee as retry,se as urlEncoded,i as validateOptions};//# sourceMappingURL=middleware.js.map
import{Agent as e}from"http";import{Agent as t}from"https";import{g as s}from"./_chunks-es/_commonjsHelpers.js";import n from"tty";import r from"util";import{p as o,v as i}from"./_chunks-es/defaultOptionsValidator.js";import c from"progress-stream";import a from"is-retry-allowed";import{N as u}from"./_chunks-es/node-request.js";const p=/^https:/i;function l(s){const n=new e(s),r=new t(s),o={http:n,https:r};return{finalizeOptions:e=>{if(e.agent)return e;if(e.maxRedirects>0)return{...e,agents:o};const t=p.test(e.href||e.protocol);return{...e,agent:t?r:n}}}}const d=/^\//,f=/\/$/;function m(e){const t=e.replace(f,"");return{processOptions:e=>{if(/^https?:\/\//i.test(e.url))return e;const s=[t,e.url.replace(d,"")].join("/");return Object.assign({},e,{url:s})}}}var h,g,C,b,y,w={exports:{}},F={exports:{}};function O(){return b?C:(b=1,C=function(e){function t(e){let n,r,o,i=null;function c(...e){if(!c.enabled)return;const s=c,r=Number(/* @__PURE__ */new Date),o=r-(n||r);s.diff=o,s.prev=n,s.curr=r,n=r,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let i=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((n,r)=>{if("%%"===n)return"%";i++;const o=t.formatters[r];if("function"==typeof o){const t=e[i];n=o.call(s,t),e.splice(i,1),i--}return n})),t.formatArgs.call(s,e),(s.log||t.log).apply(s,e)}return c.namespace=e,c.useColors=t.useColors(),c.color=t.selectColor(e),c.extend=s,c.destroy=t.destroy,Object.defineProperty(c,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==i?i:(r!==t.namespaces&&(r=t.namespaces,o=t.enabled(e)),o),set:e=>{i=e}}),"function"==typeof t.init&&t.init(c),c}function s(e,s){const n=t(this.namespace+(typeof s>"u"?":":s)+e);return n.log=this.log,n}function n(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){const e=[...t.names.map(n),...t.skips.map(n).map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){let s;t.save(e),t.namespaces=e,t.names=[],t.skips=[];const n=("string"==typeof e?e:"").split(/[\s,]+/),r=n.length;for(s=0;s<r;s++)n[s]&&("-"===(e=n[s].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.slice(1)+"$")):t.names.push(new RegExp("^"+e+"$")))},t.enabled=function(e){if("*"===e[e.length-1])return!0;let s,n;for(s=0,n=t.skips.length;s<n;s++)if(t.skips[s].test(e))return!1;for(s=0,n=t.names.length;s<n;s++)if(t.names[s].test(e))return!0;return!1},t.humanize=function(){if(g)return h;g=1;var e=1e3,t=60*e,s=60*t,n=24*s,r=7*n;function o(e,t,s,n){var r=t>=1.5*s;return Math.round(e/s)+" "+n+(r?"s":"")}return h=function(i,c){c=c||{};var a,u,p=typeof i;if("string"===p&&i.length>0)return function(o){if(!((o=String(o)).length>100)){var i=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(o);if(i){var c=parseFloat(i[1]);switch((i[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*c;case"weeks":case"week":case"w":return c*r;case"days":case"day":case"d":return c*n;case"hours":case"hour":case"hrs":case"hr":case"h":return c*s;case"minutes":case"minute":case"mins":case"min":case"m":return c*t;case"seconds":case"second":case"secs":case"sec":case"s":return c*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return c;default:return}}}}(i);if("number"===p&&isFinite(i))return c.long?(a=i,(u=Math.abs(a))>=n?o(a,u,n,"day"):u>=s?o(a,u,s,"hour"):u>=t?o(a,u,t,"minute"):u>=e?o(a,u,e,"second"):a+" ms"):function(r){var o=Math.abs(r);return o>=n?Math.round(r/n)+"d":o>=s?Math.round(r/s)+"h":o>=t?Math.round(r/t)+"m":o>=e?Math.round(r/e)+"s":r+"ms"}(i);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(i))}}(),t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach((s=>{t[s]=e[s]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let s=0;for(let t=0;t<e.length;t++)s=(s<<5)-s+e.charCodeAt(t),s|=0;return t.colors[Math.abs(s)%t.colors.length]},t.enable(t.load()),t})}var v,j,x,E,R={exports:{}},k=/* @__PURE__ */s((E||(E=1,typeof process>"u"||"renderer"===process.type||!0===process.browser||process.__nwjs?w.exports=(y||(y=1,function(e,t){t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const s="color: "+this.color;t.splice(1,0,s,"color: inherit");let n=0,r=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(n++,"%c"===e&&(r=n))})),t.splice(r,0,s)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch{}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch{}return!e&&typeof process<"u"&&"env"in process&&(e=process.env.DEBUG),e},t.useColors=function(){return!(!(typeof window<"u"&&window.process)||"renderer"!==window.process.type&&!window.process.__nwjs)||!(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&(typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},t.storage=function(){try{return localStorage}catch{}}(),t.destroy=/* @__PURE__ */(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=O()(t);const{formatters:s}=e.exports;s.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(F,F.exports)),F.exports):w.exports=(x||(x=1,function(e,t){const s=n,o=r;t.init=function(e){e.inspectOpts={};const s=Object.keys(t.inspectOpts);for(let n=0;n<s.length;n++)e.inspectOpts[s[n]]=t.inspectOpts[s[n]]},t.log=function(...e){return process.stderr.write(o.format(...e)+"\n")},t.formatArgs=function(s){const{namespace:n,useColors:r}=this;if(r){const t=this.color,r="[3"+(t<8?t:"8;5;"+t),o=` ${r};1m${n} `;s[0]=o+s[0].split("\n").join("\n"+o),s.push(r+"m+"+e.exports.humanize(this.diff)+"")}else s[0]=(t.inspectOpts.hideDate?"":/* @__PURE__ */(new Date).toISOString()+" ")+n+" "+s[0]},t.save=function(e){e?process.env.DEBUG=e:delete process.env.DEBUG},t.load=function(){return process.env.DEBUG},t.useColors=function(){return"colors"in t.inspectOpts?!!t.inspectOpts.colors:s.isatty(process.stderr.fd)},t.destroy=o.deprecate((()=>{}),"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."),t.colors=[6,2,3,4,5,1];try{const e=function(){if(j)return v;j=1;const e=function(){const e=/(Chrome|Chromium)\/(?<chromeVersion>\d+)\./.exec(navigator.userAgent);if(e)return Number.parseInt(e.groups.chromeVersion,10)}()>=69&&{level:1,hasBasic:!0,has256:!1,has16m:!1};return v={stdout:e,stderr:e}}();e&&(e.stderr||e).level>=2&&(t.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch{}t.inspectOpts=Object.keys(process.env).filter((e=>/^debug_/i.test(e))).reduce(((e,t)=>{const s=t.substring(6).toLowerCase().replace(/_([a-z])/g,((e,t)=>t.toUpperCase()));let n=process.env[t];return n=!!/^(yes|on|true|enabled)$/i.test(n)||!/^(no|off|false|disabled)$/i.test(n)&&("null"===n?null:Number(n)),e[s]=n,e}),{}),e.exports=O()(t);const{formatters:i}=e.exports;i.o=function(e){return this.inspectOpts.colors=this.useColors,o.inspect(e,this.inspectOpts).split("\n").map((e=>e.trim())).join(" ")},i.O=function(e){return this.inspectOpts.colors=this.useColors,o.inspect(e,this.inspectOpts)}}(R,R.exports)),R.exports)),w.exports));const A=["cookie","authorization"],q=Object.prototype.hasOwnProperty;function S(e={}){const t=e.verbose,s=e.namespace||"get-it",n=k(s),r=e.log||n,o=r===n&&!k.enabled(s);let i=0;return{processOptions:e=>(e.debug=r,e.requestId=e.requestId||++i,e),onRequest:s=>{if(o||!s)return s;const n=s.options;if(r("[%s] HTTP %s %s",n.requestId,n.method,n.url),t&&n.body&&"string"==typeof n.body&&r("[%s] Request body: %s",n.requestId,n.body),t&&n.headers){const t=!1===e.redactSensitiveHeaders?n.headers:((e,t)=>{const s={};for(const n in e)q.call(e,n)&&(s[n]=t.indexOf(n.toLowerCase())>-1?"<redacted>":e[n]);return s})(n.headers,A);r("[%s] Request headers: %s",n.requestId,JSON.stringify(t,null,2))}return s},onResponse:(e,s)=>{if(o||!e)return e;const n=s.options.requestId;return r("[%s] Response code: %s %s",n,e.statusCode,e.statusMessage),t&&e.body&&r("[%s] Response body: %s",n,function(e){return-1!==(e.headers["content-type"]||"").toLowerCase().indexOf("application/json")?function(e){try{const t="string"==typeof e?JSON.parse(e):e;return JSON.stringify(t,null,2)}catch{return e}}(e.body):e.body}(e)),e},onError:(e,t)=>{const s=t.options.requestId;return e?(r("[%s] ERROR: %s",s,e.message),e):(r("[%s] Error encountered, but handled by an earlier middleware",s),e)}}}function N(e,t={}){return{processOptions:s=>{const n=s.headers||{};return s.headers=t.override?Object.assign({},n,e):Object.assign({},e,n),s}}}class $ extends Error{response;request;constructor(e,t){super();const s=e.url.length>400?`${e.url.slice(0,399)}…`:e.url;let n=`${e.method}-request to ${s} resulted in `;n+=`HTTP ${e.statusCode} ${e.statusMessage}`,this.message=n.trim(),this.response=e,this.request=t.options}}function I(){return{onResponse:(e,t)=>{if(!(e.statusCode>=400))return e;throw new $(e,t)}}}function _(e={}){if("function"!=typeof e.inject)throw new Error("`injectResponse` middleware requires a `inject` function");return{interceptRequest:function(t,s){const n=e.inject(s,t);if(!n)return t;const r=s.context.options;return{body:"",url:r.url,method:r.method,headers:{},statusCode:200,statusMessage:"OK",...n}}}}const T=typeof Buffer>"u"?()=>!1:e=>Buffer.isBuffer(e);function M(e){return"[object Object]"===Object.prototype.toString.call(e)}function P(e){if(!1===M(e))return!1;const t=e.constructor;if(void 0===t)return!0;const s=t.prototype;return!(!1===M(s)||!1===s.hasOwnProperty("isPrototypeOf"))}const z=["boolean","string","number"];function L(){return{processOptions:e=>{const t=e.body;return!t||"function"==typeof t.pipe||T(t)||-1===z.indexOf(typeof t)&&!Array.isArray(t)&&!P(t)?e:Object.assign({},e,{body:JSON.stringify(e.body),headers:Object.assign({},e.headers,{"Content-Type":"application/json"})})}}}function D(e){return{onResponse:s=>{const n=s.headers["content-type"]||"",r=e&&e.force||-1!==n.indexOf("application/json");return s.body&&n&&r?Object.assign({},s,{body:t(s.body)}):s},processOptions:e=>Object.assign({},e,{headers:Object.assign({Accept:"application/json"},e.headers)})};function t(e){try{return JSON.parse(e)}catch(e){throw e.message=`Failed to parsed response body as JSON: ${e.message}`,e}}}function B(e={}){if(!e.ca)throw new Error('Required mtls option "ca" is missing');if(!e.cert)throw new Error('Required mtls option "cert" is missing');if(!e.key)throw new Error('Required mtls option "key" is missing');return{finalizeOptions:t=>{if(function(e){return"object"==typeof e&&null!==e&&!("protocol"in e)}(t))return t;const s={cert:e.cert,key:e.key,ca:e.ca};return Object.assign({},t,s)}}}let J={};typeof globalThis<"u"?J=globalThis:typeof window<"u"?J=window:typeof global<"u"?J=global:typeof self<"u"&&(J=self);var U=J;function G(e={}){const t=e.implementation||U.Observable;if(!t)throw new Error("`Observable` is not available in global scope, and no implementation was passed");return{onReturn:(e,s)=>new t((t=>(e.error.subscribe((e=>t.error(e))),e.progress.subscribe((e=>t.next(Object.assign({type:"progress"},e)))),e.response.subscribe((e=>{t.next(Object.assign({type:"response"},e)),t.complete()})),e.request.publish(s),()=>e.abort.publish())))}}function H(e){return t=>({stage:e,percent:t.percentage,total:t.length,loaded:t.transferred,lengthComputable:!(0===t.length&&0===t.percentage)})}function V(){return{onHeaders:(e,t)=>{const s=c({time:16}),n=H("download"),r=e.headers["content-length"],o=r?Number(r):0;return!isNaN(o)&&o>0&&s.setLength(o),s.on("progress",(e=>t.context.channels.progress.publish(n(e)))),e.pipe(s)},onRequest:e=>{if(!e.progress)return;const t=H("upload");e.progress.on("progress",(s=>e.context.channels.progress.publish(t(s))))}}}const Z=(e={})=>{const t=e.implementation||Promise;if(!t)throw new Error("`Promise` is not available in global scope, and no implementation was passed");return{onReturn:(s,n)=>new t(((t,r)=>{const o=n.options.cancelToken;o&&o.promise.then((e=>{s.abort.publish(e),r(e)})),s.error.subscribe(r),s.response.subscribe((s=>{t(e.onlyBody?s.body:s)})),setTimeout((()=>{try{s.request.publish(n)}catch(e){r(e)}}),0)}))}};class K{__CANCEL__=!0;message;constructor(e){this.message=e}toString(){return"Cancel"+(this.message?`: ${this.message}`:"")}}class W{promise;reason;constructor(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");let t=null;this.promise=new Promise((e=>{t=e})),e((e=>{this.reason||(this.reason=new K(e),t(this.reason))}))}static source=()=>{let e;return{token:new W((t=>{e=t})),cancel:e}}}function Q(e){if(!(!1===e||e&&e.host))throw new Error("Proxy middleware takes an object of host, port and auth properties");return{processOptions:t=>Object.assign({proxy:e},t)}}Z.Cancel=K,Z.CancelToken=W,Z.isCancel=e=>!(!e||!e?.__CANCEL__);var X=(e,t,s)=>!("GET"!==s.method&&"HEAD"!==s.method||e.response&&e.response.statusCode)&&a(e);function Y(e){return 100*Math.pow(2,e)+100*Math.random()}const ee=(e={})=>(e=>{const t=e.maxRetries||5,s=e.retryDelay||Y,n=e.shouldRetry;return{onError:(e,r)=>{const o=r.options,i=o.maxRetries||t,c=o.retryDelay||s,a=o.shouldRetry||n,u=o.attemptNumber||0;if(null!==(p=o.body)&&"object"==typeof p&&"function"==typeof p.pipe||!a(e,u,o)||u>=i)return e;var p;const l=Object.assign({},r,{options:Object.assign({},o,{attemptNumber:u+1})});return setTimeout((()=>r.channels.request.publish(l)),c(u)),null}}})({shouldRetry:X,...e});function te(e){const t=new URLSearchParams,s=(e,n)=>{const r=n instanceof Set?Array.from(n):n;if(Array.isArray(r))if(r.length)for(const t in r)s(`${e}[${t}]`,r[t]);else t.append(`${e}[]`,"");else if("object"==typeof r&&null!==r)for(const[t,n]of Object.entries(r))s(`${e}[${t}]`,n);else t.append(e,r)};for(const[t,n]of Object.entries(e))s(t,n);return t.toString()}function se(){return{processOptions:e=>{const t=e.body;return t&&"function"!=typeof t.pipe&&!T(t)&&P(t)?{...e,body:te(e.body),headers:{...e.headers,"Content-Type":"application/x-www-form-urlencoded"}}:e}}}ee.shouldRetry=X;const ne=(re=l,function(e={}){const{maxRetries:t=3,ms:s=1e3,maxFree:n=256}=e,{finalizeOptions:r}=re({keepAlive:!0,keepAliveMsecs:s,maxFreeSockets:n});return{finalizeOptions:r,onError:(e,s)=>{if(("GET"===s.options.method||"POST"===s.options.method)&&e instanceof u&&"ECONNRESET"===e.code&&e.request.reusedSocket){const e=s.options.attemptNumber||0;if(e<t){const t=Object.assign({},s,{options:Object.assign({},s.options,{attemptNumber:e+1})});return setImmediate((()=>s.channels.request.publish(t))),null}}return e}}});var re;export{K as Cancel,W as CancelToken,l as agent,m as base,S as debug,N as headers,I as httpErrors,_ as injectResponse,L as jsonRequest,D as jsonResponse,ne as keepAlive,B as mtls,G as observable,o as processOptions,V as progress,Z as promise,Q as proxy,ee as retry,se as urlEncoded,i as validateOptions};//# sourceMappingURL=middleware.js.map
// Necessary for `get-it/middleware` imports to work with setups not setup to be ESM native, like older `jest` configs.
module.exports = require('./dist/middleware.cjs')
module.exports = require('./dist/middleware.cjs') // eslint-disable-line @typescript-eslint/no-require-imports
{
"name": "get-it",
"version": "8.6.5",
"version": "8.6.6-canary.0",
"description": "Generic HTTP request library for node, browsers and workers",

@@ -101,2 +101,3 @@ "keywords": [

"browserslist": "extends @sanity/browserslist-config",
"prettier": "@sanity/prettier-config",
"dependencies": {

@@ -106,3 +107,3 @@ "@types/follow-redirects": "^1.14.4",

"decompress-response": "^7.0.0",
"follow-redirects": "^1.15.6",
"follow-redirects": "^1.15.9",
"is-retry-allowed": "^2.2.0",

@@ -113,14 +114,15 @@ "progress-stream": "^2.0.0",

"devDependencies": {
"@edge-runtime/vm": "^4.0.1",
"@sanity/pkg-utils": "^6.10.9",
"@edge-runtime/vm": "^5.0.0",
"@sanity/pkg-utils": "^7.0.0",
"@sanity/prettier-config": "^1.0.3",
"@sanity/semantic-release-preset": "^5.0.0",
"@types/bun": "^1.1.6",
"@types/debug": "^4.1.10",
"@types/bun": "^1.1.15",
"@types/debug": "^4.1.12",
"@types/node": "^20.8.8",
"@types/zen-observable": "^0.8.7",
"@typescript-eslint/eslint-plugin": "^7.18.0",
"@typescript-eslint/parser": "^7.18.0",
"@vitest/coverage-v8": "^2.0.5",
"@typescript-eslint/eslint-plugin": "^8.19.1",
"@typescript-eslint/parser": "^8.19.1",
"@vitest/coverage-v8": "^2.1.8",
"debug": "4.3.4",
"eslint": "^8.57.0",
"eslint": "^8.57.1",
"eslint-config-prettier": "^9.1.0",

@@ -130,3 +132,3 @@ "eslint-plugin-prettier": "^5.2.1",

"faucet": "^0.0.4",
"get-uri": "^6.0.2",
"get-uri": "^6.0.4",
"happy-dom": "12.10.3",

@@ -136,11 +138,10 @@ "ls-engines": "^0.9.3",

"parse-headers": "2.0.5",
"prettier": "^3.3.3",
"prettier-plugin-packagejson": "^2.5.1",
"prettier": "^3.4.2",
"semantic-release": "^24.0.0",
"typescript": "5.5.3",
"vite": "5.3.5",
"vitest": "^2.0.5",
"vitest-github-actions-reporter": "^0.11.1",
"typescript": "5.7.3",
"vite": "^5.4.11",
"vitest": "^2.1.8",
"zen-observable": "^0.10.0"
},
"packageManager": "npm@10.8.2",
"engines": {

@@ -147,0 +148,0 @@ "node": ">=14.0.0"

@@ -100,5 +100,5 @@ import debugIt from 'debug'

return JSON.stringify(parsed, null, 2)
} catch (err) {
} catch {
return body
}
}

@@ -151,3 +151,3 @@ import type {IncomingHttpHeaders, IncomingMessage} from 'http'

/** @public */
export interface MiddlewareRequest {}
export interface MiddlewareRequest {} // eslint-disable-line @typescript-eslint/no-empty-object-type

@@ -154,0 +154,0 @@ /** @public */

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 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 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 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 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 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 not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc