var e=require("buffer");Object.defineProperty(module.exports,"__esModule",{value:!0,configurable:!0}),Object.defineProperty(module.exports,"default",{get:()=>a,set:void 0,enumerable:!0,configurable:!0});var r=e.Buffer,a=async({url:e,body:a,headers:t={},auth:s,jwt:o,signature:n,dev:p=!1},d)=>{let i=new Headers;if(Object.keys(t).forEach(e=>{i.append(e,t[e])}),i.has("Accept")||i.append("Accept","application/json"),i.has("Content-Type")||i.append("Content-Type","application/json"),n&&i.append("Signature",JSON.stringify(n)),o&&i.append("Authorization","Bearer "+o),s&&s.user&&s.pass){let e="Basic "+r.from(s.user+":"+s.pass).toString("base64");i.set("Authorization",e)}let u={jsonrpc:"2.0",method:a.method};return(a.id&&(u.id=a.id),a.params&&"object"!=typeof a.params)?{jsonrpc:"2.0",error:{code:-32602,message:"Invalid params"},id:null}:(a.params&&(u.params=a.params),fetch(e,{body:JSON.stringify(u),headers:i,method:"POST",signal:AbortSignal.timeout(3e4)}).then(e=>{if(e.status>=400)throw Error(e.statusText);return e.json()}).then(e=>"InternalServerError"===e.name?{jsonrpc:"2.0",error:{code:e.code,message:e.message},id:null}:e).catch(({message:e})=>"Not Found"===e?{jsonrpc:"2.0",error:{code:-32603,message:e},id:null}:{jsonrpc:"2.0",error:{code:-32099,message:e},id:null}))}; //# sourceMappingURL=index.cjs.map