@privy-io/server-auth
Version:
Server-side client for the Privy API
2 lines (1 loc) • 954 B
JavaScript
;var t=require("redaxios"),r=require("./constants.js"),e=require("./errors.js"),a=require("./utils-D9BZ7JAH.js");function s(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}require("node-fetch-native"),require("ts-case-convert");var i=/*#__PURE__*/s(t);exports.Http=class{async get(t,r){try{return await this.instance.get(t,r)}catch(t){throw e.wrapApiError(t)}}async post(t,r,a){try{return await this.instance.post(t,r,a)}catch(t){throw e.wrapApiError(t)}}async patch(t,r,a){try{return await this.instance.patch(t,r,a)}catch(t){throw e.wrapApiError(t)}}async delete(t,r,a){try{return await this.instance.delete(t,{...a,data:r})}catch(t){throw e.wrapApiError(t)}}constructor(t,e,{baseURL:s,timeout:c}){this.sdkVersion=r.VERSION,this.instance=i.default.create({baseURL:s,fetch:a.fetchWithTimeout(c),auth:`Basic ${a.base64(`${t}:${e}`)}`,headers:{"privy-app-id":t,"privy-client":`server-auth:${this.sdkVersion}`}}),this.baseURL=s}};