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

@toruslabs/http-helpers

Package Overview
Dependencies
Maintainers
5
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@toruslabs/http-helpers - npm Package Compare versions

Comparing version 2.1.3 to 2.1.4

55

dist/httpHelpers.cjs.js

@@ -205,10 +205,4 @@ module.exports =

}
}; // for multipart request browser/client will add multipart content type
// along with multipart boundary , so for multipart request send
// content-type: undefined or send with multipart boundary if already known
};
if (options_.headers["Content-Type"] === undefined) {
delete defaultOptions.headers["Content-Type"];
}
if (customOptions.useAPIKey) {

@@ -223,3 +217,13 @@ defaultOptions.headers = _objectSpread(_objectSpread({}, defaultOptions.headers), getApiKeyHeaders());

options.body = customOptions.isUrlEncodedData ? data : JSON.stringify(data);
if (customOptions.isUrlEncodedData) {
// for multipart request browser/client will add multipart content type
// along with multipart boundary , so for multipart request send
// content-type: undefined or send with multipart boundary if already known
options.body = data; // If url encoded data, this must not be the content type
if (options.headers["Content-Type"] === "application/json; charset=utf-8") delete options.headers["Content-Type"];
} else {
options.body = JSON.stringify(data);
}
return promiseTimeout(customOptions.timeout || 60000, fetch(url, options).then(response => {

@@ -246,6 +250,2 @@ if (response.ok) {

if (options_.headers["Content-Type"] === undefined) {
delete defaultOptions.headers["Content-Type"];
}
if (customOptions.useAPIKey) {

@@ -260,3 +260,13 @@ defaultOptions.headers = _objectSpread(_objectSpread({}, defaultOptions.headers), getApiKeyHeaders());

options.body = customOptions.isUrlEncodedData ? data : JSON.stringify(data);
if (customOptions.isUrlEncodedData) {
// for multipart request browser/client will add multipart content type
// along with multipart boundary , so for multipart request send
// content-type: undefined or send with multipart boundary if already known
options.body = data; // If url encoded data, this must not be the content type
if (options.headers["Content-Type"] === "application/json; charset=utf-8") delete options.headers["Content-Type"];
} else {
options.body = JSON.stringify(data);
}
const response = await fetch(url, options);

@@ -271,4 +281,3 @@

const remove = async function (url) {
let _data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
let options_ = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};

@@ -285,6 +294,2 @@ let customOptions = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};

if (options_.headers["Content-Type"] === undefined) {
delete defaultOptions.headers["Content-Type"];
}
if (customOptions.useAPIKey) {

@@ -297,2 +302,14 @@ defaultOptions.headers = _objectSpread(_objectSpread({}, defaultOptions.headers), getApiKeyHeaders());

});
if (customOptions.isUrlEncodedData) {
// for multipart request browser/client will add multipart content type
// along with multipart boundary , so for multipart request send
// content-type: undefined or send with multipart boundary if already known
options.body = data; // If url encoded data, this must not be the content type
if (options.headers["Content-Type"] === "application/json; charset=utf-8") delete options.headers["Content-Type"];
} else {
options.body = JSON.stringify(data);
}
const response = await fetch(url, options);

@@ -299,0 +316,0 @@

@@ -91,8 +91,2 @@ import merge from 'lodash.merge';

};
// for multipart request browser/client will add multipart content type
// along with multipart boundary , so for multipart request send
// content-type: undefined or send with multipart boundary if already known
if (options_.headers["Content-Type"] === undefined) {
delete defaultOptions.headers["Content-Type"];
}
if (customOptions.useAPIKey) {

@@ -104,3 +98,14 @@ defaultOptions.headers = Object.assign(Object.assign({}, defaultOptions.headers), getApiKeyHeaders());

// so we should not deepmerge body data
options.body = customOptions.isUrlEncodedData ? data : JSON.stringify(data);
if (customOptions.isUrlEncodedData) {
// for multipart request browser/client will add multipart content type
// along with multipart boundary , so for multipart request send
// content-type: undefined or send with multipart boundary if already known
options.body = data;
// If url encoded data, this must not be the content type
if (options.headers["Content-Type"] === "application/json; charset=utf-8")
delete options.headers["Content-Type"];
}
else {
options.body = JSON.stringify(data);
}
return promiseTimeout(customOptions.timeout || 60000, fetch(url, options).then((response) => {

@@ -123,5 +128,2 @@ if (response.ok) {

// content-type: undefined or send with multipart boundary if already known
if (options_.headers["Content-Type"] === undefined) {
delete defaultOptions.headers["Content-Type"];
}
if (customOptions.useAPIKey) {

@@ -133,3 +135,14 @@ defaultOptions.headers = Object.assign(Object.assign({}, defaultOptions.headers), getApiKeyHeaders());

// so we should not deepmerge body data
options.body = customOptions.isUrlEncodedData ? data : JSON.stringify(data);
if (customOptions.isUrlEncodedData) {
// for multipart request browser/client will add multipart content type
// along with multipart boundary , so for multipart request send
// content-type: undefined or send with multipart boundary if already known
options.body = data;
// If url encoded data, this must not be the content type
if (options.headers["Content-Type"] === "application/json; charset=utf-8")
delete options.headers["Content-Type"];
}
else {
options.body = JSON.stringify(data);
}
const response = yield fetch(url, options);

@@ -141,3 +154,3 @@ if (response.ok) {

});
const remove = (url, _data = {}, options_ = {}, customOptions = {}) => __awaiter(void 0, void 0, void 0, function* () {
const remove = (url, data = {}, options_ = {}, customOptions = {}) => __awaiter(void 0, void 0, void 0, function* () {
const defaultOptions = {

@@ -152,5 +165,2 @@ mode: "cors",

// content-type: undefined or send with multipart boundary if already known
if (options_.headers["Content-Type"] === undefined) {
delete defaultOptions.headers["Content-Type"];
}
if (customOptions.useAPIKey) {

@@ -160,2 +170,14 @@ defaultOptions.headers = Object.assign(Object.assign({}, defaultOptions.headers), getApiKeyHeaders());

const options = merge(defaultOptions, options_, { method: "DELETE" });
if (customOptions.isUrlEncodedData) {
// for multipart request browser/client will add multipart content type
// along with multipart boundary , so for multipart request send
// content-type: undefined or send with multipart boundary if already known
options.body = data;
// If url encoded data, this must not be the content type
if (options.headers["Content-Type"] === "application/json; charset=utf-8")
delete options.headers["Content-Type"];
}
else {
options.body = JSON.stringify(data);
}
const response = yield fetch(url, options);

@@ -162,0 +184,0 @@ if (response.ok) {

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

!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.HttpHelpers=e():t.HttpHelpers=e()}(window,(function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=2)}([function(t,e,n){(function(t,n){var r=/^\[object .+?Constructor\]$/,o=/^(?:0|[1-9]\d*)$/,i={};i["[object Float32Array]"]=i["[object Float64Array]"]=i["[object Int8Array]"]=i["[object Int16Array]"]=i["[object Int32Array]"]=i["[object Uint8Array]"]=i["[object Uint8ClampedArray]"]=i["[object Uint16Array]"]=i["[object Uint32Array]"]=!0,i["[object Arguments]"]=i["[object Array]"]=i["[object ArrayBuffer]"]=i["[object Boolean]"]=i["[object DataView]"]=i["[object Date]"]=i["[object Error]"]=i["[object Function]"]=i["[object Map]"]=i["[object Number]"]=i["[object Object]"]=i["[object RegExp]"]=i["[object Set]"]=i["[object String]"]=i["[object WeakMap]"]=!1;var u="object"==typeof t&&t&&t.Object===Object&&t,c="object"==typeof self&&self&&self.Object===Object&&self,a=u||c||Function("return this")(),f=e&&!e.nodeType&&e,s=f&&"object"==typeof n&&n&&!n.nodeType&&n,l=s&&s.exports===f,d=l&&u.process,p=function(){try{var t=s&&s.require&&s.require("util").types;return t||d&&d.binding&&d.binding("util")}catch(t){}}(),h=p&&p.isTypedArray;function y(t,e,n){switch(n.length){case 0:return t.call(e);case 1:return t.call(e,n[0]);case 2:return t.call(e,n[0],n[1]);case 3:return t.call(e,n[0],n[1],n[2])}return t.apply(e,n)}var v,b,_,j=Array.prototype,g=Function.prototype,m=Object.prototype,O=a["__core-js_shared__"],w=g.toString,P=m.hasOwnProperty,A=(v=/[^.]+$/.exec(O&&O.keys&&O.keys.IE_PROTO||""))?"Symbol(src)_1."+v:"",T=m.toString,x=w.call(Object),z=RegExp("^"+w.call(P).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),E=l?a.Buffer:void 0,S=a.Symbol,C=a.Uint8Array,k=E?E.allocUnsafe:void 0,I=(b=Object.getPrototypeOf,_=Object,function(t){return b(_(t))}),H=Object.create,D=m.propertyIsEnumerable,F=j.splice,M=S?S.toStringTag:void 0,U=function(){try{var t=ft(Object,"defineProperty");return t({},"",{}),t}catch(t){}}(),K=E?E.isBuffer:void 0,$=Math.max,R=Date.now,B=ft(a,"Map"),N=ft(Object,"create"),J=function(){function t(){}return function(e){if(!mt(e))return{};if(H)return H(e);t.prototype=e;var n=new t;return t.prototype=void 0,n}}();function L(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function q(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function G(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function V(t){var e=this.__data__=new q(t);this.size=e.size}function W(t,e){var n=vt(t),r=!n&&yt(t),o=!n&&!r&&_t(t),i=!n&&!r&&!o&&wt(t),u=n||r||o||i,c=u?function(t,e){for(var n=-1,r=Array(t);++n<t;)r[n]=e(n);return r}(t.length,String):[],a=c.length;for(var f in t)!e&&!P.call(t,f)||u&&("length"==f||o&&("offset"==f||"parent"==f)||i&&("buffer"==f||"byteLength"==f||"byteOffset"==f)||st(f,a))||c.push(f);return c}function Q(t,e,n){(void 0!==n&&!ht(t[e],n)||void 0===n&&!(e in t))&&Z(t,e,n)}function X(t,e,n){var r=t[e];P.call(t,e)&&ht(r,n)&&(void 0!==n||e in t)||Z(t,e,n)}function Y(t,e){for(var n=t.length;n--;)if(ht(t[n][0],e))return n;return-1}function Z(t,e,n){"__proto__"==e&&U?U(t,e,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[e]=n}L.prototype.clear=function(){this.__data__=N?N(null):{},this.size=0},L.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},L.prototype.get=function(t){var e=this.__data__;if(N){var n=e[t];return"__lodash_hash_undefined__"===n?void 0:n}return P.call(e,t)?e[t]:void 0},L.prototype.has=function(t){var e=this.__data__;return N?void 0!==e[t]:P.call(e,t)},L.prototype.set=function(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=N&&void 0===e?"__lodash_hash_undefined__":e,this},q.prototype.clear=function(){this.__data__=[],this.size=0},q.prototype.delete=function(t){var e=this.__data__,n=Y(e,t);return!(n<0)&&(n==e.length-1?e.pop():F.call(e,n,1),--this.size,!0)},q.prototype.get=function(t){var e=this.__data__,n=Y(e,t);return n<0?void 0:e[n][1]},q.prototype.has=function(t){return Y(this.__data__,t)>-1},q.prototype.set=function(t,e){var n=this.__data__,r=Y(n,t);return r<0?(++this.size,n.push([t,e])):n[r][1]=e,this},G.prototype.clear=function(){this.size=0,this.__data__={hash:new L,map:new(B||q),string:new L}},G.prototype.delete=function(t){var e=at(this,t).delete(t);return this.size-=e?1:0,e},G.prototype.get=function(t){return at(this,t).get(t)},G.prototype.has=function(t){return at(this,t).has(t)},G.prototype.set=function(t,e){var n=at(this,t),r=n.size;return n.set(t,e),this.size+=n.size==r?0:1,this},V.prototype.clear=function(){this.__data__=new q,this.size=0},V.prototype.delete=function(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n},V.prototype.get=function(t){return this.__data__.get(t)},V.prototype.has=function(t){return this.__data__.has(t)},V.prototype.set=function(t,e){var n=this.__data__;if(n instanceof q){var r=n.__data__;if(!B||r.length<199)return r.push([t,e]),this.size=++n.size,this;n=this.__data__=new G(r)}return n.set(t,e),this.size=n.size,this};var tt,et=function(t,e,n){for(var r=-1,o=Object(t),i=n(t),u=i.length;u--;){var c=i[tt?u:++r];if(!1===e(o[c],c,o))break}return t};function nt(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":M&&M in Object(t)?function(t){var e=P.call(t,M),n=t[M];try{t[M]=void 0;var r=!0}catch(t){}var o=T.call(t);r&&(e?t[M]=n:delete t[M]);return o}(t):function(t){return T.call(t)}(t)}function rt(t){return Ot(t)&&"[object Arguments]"==nt(t)}function ot(t){return!(!mt(t)||function(t){return!!A&&A in t}(t))&&(jt(t)?z:r).test(function(t){if(null!=t){try{return w.call(t)}catch(t){}try{return t+""}catch(t){}}return""}(t))}function it(t){if(!mt(t))return function(t){var e=[];if(null!=t)for(var n in Object(t))e.push(n);return e}(t);var e=lt(t),n=[];for(var r in t)("constructor"!=r||!e&&P.call(t,r))&&n.push(r);return n}function ut(t,e,n,r,o){t!==e&&et(e,(function(i,u){if(o||(o=new V),mt(i))!function(t,e,n,r,o,i,u){var c=dt(t,n),a=dt(e,n),f=u.get(a);if(f)return void Q(t,n,f);var s=i?i(c,a,n+"",t,e,u):void 0,l=void 0===s;if(l){var d=vt(a),p=!d&&_t(a),h=!d&&!p&&wt(a);s=a,d||p||h?vt(c)?s=c:Ot(j=c)&&bt(j)?s=function(t,e){var n=-1,r=t.length;e||(e=Array(r));for(;++n<r;)e[n]=t[n];return e}(c):p?(l=!1,s=function(t,e){if(e)return t.slice();var n=t.length,r=k?k(n):new t.constructor(n);return t.copy(r),r}(a,!0)):h?(l=!1,y=a,v=!0?(b=y.buffer,_=new b.constructor(b.byteLength),new C(_).set(new C(b)),_):y.buffer,s=new y.constructor(v,y.byteOffset,y.length)):s=[]:function(t){if(!Ot(t)||"[object Object]"!=nt(t))return!1;var e=I(t);if(null===e)return!0;var n=P.call(e,"constructor")&&e.constructor;return"function"==typeof n&&n instanceof n&&w.call(n)==x}(a)||yt(a)?(s=c,yt(c)?s=function(t){return function(t,e,n,r){var o=!n;n||(n={});var i=-1,u=e.length;for(;++i<u;){var c=e[i],a=r?r(n[c],t[c],c,n,t):void 0;void 0===a&&(a=t[c]),o?Z(n,c,a):X(n,c,a)}return n}(t,Pt(t))}(c):mt(c)&&!jt(c)||(s=function(t){return"function"!=typeof t.constructor||lt(t)?{}:J(I(t))}(a))):l=!1}var y,v,b,_;var j;l&&(u.set(a,s),o(s,a,r,i,u),u.delete(a));Q(t,n,s)}(t,e,u,n,ut,r,o);else{var c=r?r(dt(t,u),i,u+"",t,e,o):void 0;void 0===c&&(c=i),Q(t,u,c)}}),Pt)}function ct(t,e){return pt(function(t,e,n){return e=$(void 0===e?t.length-1:e,0),function(){for(var r=arguments,o=-1,i=$(r.length-e,0),u=Array(i);++o<i;)u[o]=r[e+o];o=-1;for(var c=Array(e+1);++o<e;)c[o]=r[o];return c[e]=n(u),y(t,this,c)}}(t,e,xt),t+"")}function at(t,e){var n,r,o=t.__data__;return("string"==(r=typeof(n=e))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?o["string"==typeof e?"string":"hash"]:o.map}function ft(t,e){var n=function(t,e){return null==t?void 0:t[e]}(t,e);return ot(n)?n:void 0}function st(t,e){var n=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==n||"symbol"!=n&&o.test(t))&&t>-1&&t%1==0&&t<e}function lt(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||m)}function dt(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}var pt=function(t){var e=0,n=0;return function(){var r=R(),o=16-(r-n);if(n=r,o>0){if(++e>=800)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(U?function(t,e){return U(t,"toString",{configurable:!0,enumerable:!1,value:(n=e,function(){return n}),writable:!0});var n}:xt);function ht(t,e){return t===e||t!=t&&e!=e}var yt=rt(function(){return arguments}())?rt:function(t){return Ot(t)&&P.call(t,"callee")&&!D.call(t,"callee")},vt=Array.isArray;function bt(t){return null!=t&&gt(t.length)&&!jt(t)}var _t=K||function(){return!1};function jt(t){if(!mt(t))return!1;var e=nt(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e}function gt(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}function mt(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function Ot(t){return null!=t&&"object"==typeof t}var wt=h?function(t){return function(e){return t(e)}}(h):function(t){return Ot(t)&&gt(t.length)&&!!i[nt(t)]};function Pt(t){return bt(t)?W(t,!0):it(t)}var At,Tt=(At=function(t,e,n){ut(t,e,n)},ct((function(t,e){var n=-1,r=e.length,o=r>1?e[r-1]:void 0,i=r>2?e[2]:void 0;for(o=At.length>3&&"function"==typeof o?(r--,o):void 0,i&&function(t,e,n){if(!mt(n))return!1;var r=typeof e;return!!("number"==r?bt(n)&&st(e,n.length):"string"==r&&e in n)&&ht(n[e],t)}(e[0],e[1],i)&&(o=r<3?void 0:o,r=1),t=Object(t);++n<r;){var u=e[n];u&&At(t,u,n,o)}return t})));function xt(t){return t}n.exports=Tt}).call(this,n(3),n(4)(t))},function(t,e){t.exports=function(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t},t.exports.default=t.exports,t.exports.__esModule=!0},function(t,e,n){"use strict";n.r(e),n.d(e,"gatewayAuthHeader",(function(){return l})),n.d(e,"gatewayEmbedHostHeader",(function(){return d})),n.d(e,"setEmbedHost",(function(){return p})),n.d(e,"clearEmbedHost",(function(){return h})),n.d(e,"getEmbedHost",(function(){return y})),n.d(e,"setAPIKey",(function(){return v})),n.d(e,"clearAPIKey",(function(){return b})),n.d(e,"getAPIKey",(function(){return _})),n.d(e,"promiseTimeout",(function(){return g})),n.d(e,"get",(function(){return m})),n.d(e,"post",(function(){return O})),n.d(e,"patch",(function(){return w})),n.d(e,"remove",(function(){return P})),n.d(e,"generateJsonRPCObject",(function(){return A})),n.d(e,"promiseRace",(function(){return T}));var r=n(1),o=n.n(r),i=n(0),u=n.n(i);function c(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function a(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?c(Object(n),!0).forEach((function(e){o()(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):c(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}let f="torus-default",s="";const l="x-api-key",d="x-embed-host";function p(t){s=t}function h(){s=""}function y(){return s}function v(t){f=t}function b(){f="torus-default"}function _(){return f}function j(){const t={};return f&&(t[l]=f),s&&(t[d]=s),t}const g=(t,e)=>{const n=new Promise((e,n)=>{const r=setTimeout(()=>{clearTimeout(r),n(new Error("Timed out in ".concat(t,"ms")))},t)});return Promise.race([e,n])},m=async function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const r={mode:"cors",headers:{}};n.useAPIKey&&(r.headers=a(a({},r.headers),j()));const o=u()(r,e,{method:"GET"}),i=await fetch(t,o);if(i.ok)return i.json();throw i},O=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};const o={mode:"cors",headers:{"Content-Type":"application/json; charset=utf-8"}};void 0===n.headers["Content-Type"]&&delete o.headers["Content-Type"],r.useAPIKey&&(o.headers=a(a({},o.headers),j()));const i=u()(o,n,{method:"POST"});return i.body=r.isUrlEncodedData?e:JSON.stringify(e),g(r.timeout||6e4,fetch(t,i).then(t=>{if(t.ok)return t.json();throw t}))},w=async function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};const o={mode:"cors",headers:{"Content-Type":"application/json; charset=utf-8"}};void 0===n.headers["Content-Type"]&&delete o.headers["Content-Type"],r.useAPIKey&&(o.headers=a(a({},o.headers),j()));const i=u()(o,n,{method:"PATCH"});i.body=r.isUrlEncodedData?e:JSON.stringify(e);const c=await fetch(t,i);if(c.ok)return c.json();throw c},P=async function(t){let e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};const r={mode:"cors",headers:{"Content-Type":"application/json; charset=utf-8"}};void 0===e.headers["Content-Type"]&&delete r.headers["Content-Type"],n.useAPIKey&&(r.headers=a(a({},r.headers),j()));const o=u()(r,e,{method:"DELETE"}),i=await fetch(t,o);if(i.ok)return i.json();throw i},A=(t,e)=>({jsonrpc:"2.0",method:t,id:10,params:e}),T=function(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:6e4;return Promise.race([m(t,e),new Promise((t,e)=>{setTimeout(()=>{e(new Error("timed out"))},n)})])}},function(t,e){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(t){"object"==typeof window&&(n=window)}t.exports=n},function(t,e){t.exports=function(t){return t.webpackPolyfill||(t.deprecate=function(){},t.paths=[],t.children||(t.children=[]),Object.defineProperty(t,"loaded",{enumerable:!0,get:function(){return t.l}}),Object.defineProperty(t,"id",{enumerable:!0,get:function(){return t.i}}),t.webpackPolyfill=1),t}}])}));
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.HttpHelpers=e():t.HttpHelpers=e()}(window,(function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=2)}([function(t,e,n){(function(t,n){var r=/^\[object .+?Constructor\]$/,o=/^(?:0|[1-9]\d*)$/,i={};i["[object Float32Array]"]=i["[object Float64Array]"]=i["[object Int8Array]"]=i["[object Int16Array]"]=i["[object Int32Array]"]=i["[object Uint8Array]"]=i["[object Uint8ClampedArray]"]=i["[object Uint16Array]"]=i["[object Uint32Array]"]=!0,i["[object Arguments]"]=i["[object Array]"]=i["[object ArrayBuffer]"]=i["[object Boolean]"]=i["[object DataView]"]=i["[object Date]"]=i["[object Error]"]=i["[object Function]"]=i["[object Map]"]=i["[object Number]"]=i["[object Object]"]=i["[object RegExp]"]=i["[object Set]"]=i["[object String]"]=i["[object WeakMap]"]=!1;var u="object"==typeof t&&t&&t.Object===Object&&t,c="object"==typeof self&&self&&self.Object===Object&&self,a=u||c||Function("return this")(),f=e&&!e.nodeType&&e,s=f&&"object"==typeof n&&n&&!n.nodeType&&n,l=s&&s.exports===f,d=l&&u.process,p=function(){try{var t=s&&s.require&&s.require("util").types;return t||d&&d.binding&&d.binding("util")}catch(t){}}(),h=p&&p.isTypedArray;function y(t,e,n){switch(n.length){case 0:return t.call(e);case 1:return t.call(e,n[0]);case 2:return t.call(e,n[0],n[1]);case 3:return t.call(e,n[0],n[1],n[2])}return t.apply(e,n)}var b,v,_,j=Array.prototype,g=Function.prototype,m=Object.prototype,O=a["__core-js_shared__"],w=g.toString,P=m.hasOwnProperty,A=(b=/[^.]+$/.exec(O&&O.keys&&O.keys.IE_PROTO||""))?"Symbol(src)_1."+b:"",T=m.toString,x=w.call(Object),z=RegExp("^"+w.call(P).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),E=l?a.Buffer:void 0,S=a.Symbol,C=a.Uint8Array,k=E?E.allocUnsafe:void 0,I=(v=Object.getPrototypeOf,_=Object,function(t){return v(_(t))}),D=Object.create,H=m.propertyIsEnumerable,U=j.splice,F=S?S.toStringTag:void 0,M=function(){try{var t=ft(Object,"defineProperty");return t({},"",{}),t}catch(t){}}(),K=E?E.isBuffer:void 0,$=Math.max,N=Date.now,R=ft(a,"Map"),B=ft(Object,"create"),J=function(){function t(){}return function(e){if(!mt(e))return{};if(D)return D(e);t.prototype=e;var n=new t;return t.prototype=void 0,n}}();function L(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function q(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function G(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function V(t){var e=this.__data__=new q(t);this.size=e.size}function W(t,e){var n=bt(t),r=!n&&yt(t),o=!n&&!r&&_t(t),i=!n&&!r&&!o&&wt(t),u=n||r||o||i,c=u?function(t,e){for(var n=-1,r=Array(t);++n<t;)r[n]=e(n);return r}(t.length,String):[],a=c.length;for(var f in t)!e&&!P.call(t,f)||u&&("length"==f||o&&("offset"==f||"parent"==f)||i&&("buffer"==f||"byteLength"==f||"byteOffset"==f)||st(f,a))||c.push(f);return c}function Q(t,e,n){(void 0!==n&&!ht(t[e],n)||void 0===n&&!(e in t))&&Z(t,e,n)}function X(t,e,n){var r=t[e];P.call(t,e)&&ht(r,n)&&(void 0!==n||e in t)||Z(t,e,n)}function Y(t,e){for(var n=t.length;n--;)if(ht(t[n][0],e))return n;return-1}function Z(t,e,n){"__proto__"==e&&M?M(t,e,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[e]=n}L.prototype.clear=function(){this.__data__=B?B(null):{},this.size=0},L.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},L.prototype.get=function(t){var e=this.__data__;if(B){var n=e[t];return"__lodash_hash_undefined__"===n?void 0:n}return P.call(e,t)?e[t]:void 0},L.prototype.has=function(t){var e=this.__data__;return B?void 0!==e[t]:P.call(e,t)},L.prototype.set=function(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=B&&void 0===e?"__lodash_hash_undefined__":e,this},q.prototype.clear=function(){this.__data__=[],this.size=0},q.prototype.delete=function(t){var e=this.__data__,n=Y(e,t);return!(n<0)&&(n==e.length-1?e.pop():U.call(e,n,1),--this.size,!0)},q.prototype.get=function(t){var e=this.__data__,n=Y(e,t);return n<0?void 0:e[n][1]},q.prototype.has=function(t){return Y(this.__data__,t)>-1},q.prototype.set=function(t,e){var n=this.__data__,r=Y(n,t);return r<0?(++this.size,n.push([t,e])):n[r][1]=e,this},G.prototype.clear=function(){this.size=0,this.__data__={hash:new L,map:new(R||q),string:new L}},G.prototype.delete=function(t){var e=at(this,t).delete(t);return this.size-=e?1:0,e},G.prototype.get=function(t){return at(this,t).get(t)},G.prototype.has=function(t){return at(this,t).has(t)},G.prototype.set=function(t,e){var n=at(this,t),r=n.size;return n.set(t,e),this.size+=n.size==r?0:1,this},V.prototype.clear=function(){this.__data__=new q,this.size=0},V.prototype.delete=function(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n},V.prototype.get=function(t){return this.__data__.get(t)},V.prototype.has=function(t){return this.__data__.has(t)},V.prototype.set=function(t,e){var n=this.__data__;if(n instanceof q){var r=n.__data__;if(!R||r.length<199)return r.push([t,e]),this.size=++n.size,this;n=this.__data__=new G(r)}return n.set(t,e),this.size=n.size,this};var tt,et=function(t,e,n){for(var r=-1,o=Object(t),i=n(t),u=i.length;u--;){var c=i[tt?u:++r];if(!1===e(o[c],c,o))break}return t};function nt(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":F&&F in Object(t)?function(t){var e=P.call(t,F),n=t[F];try{t[F]=void 0;var r=!0}catch(t){}var o=T.call(t);r&&(e?t[F]=n:delete t[F]);return o}(t):function(t){return T.call(t)}(t)}function rt(t){return Ot(t)&&"[object Arguments]"==nt(t)}function ot(t){return!(!mt(t)||function(t){return!!A&&A in t}(t))&&(jt(t)?z:r).test(function(t){if(null!=t){try{return w.call(t)}catch(t){}try{return t+""}catch(t){}}return""}(t))}function it(t){if(!mt(t))return function(t){var e=[];if(null!=t)for(var n in Object(t))e.push(n);return e}(t);var e=lt(t),n=[];for(var r in t)("constructor"!=r||!e&&P.call(t,r))&&n.push(r);return n}function ut(t,e,n,r,o){t!==e&&et(e,(function(i,u){if(o||(o=new V),mt(i))!function(t,e,n,r,o,i,u){var c=dt(t,n),a=dt(e,n),f=u.get(a);if(f)return void Q(t,n,f);var s=i?i(c,a,n+"",t,e,u):void 0,l=void 0===s;if(l){var d=bt(a),p=!d&&_t(a),h=!d&&!p&&wt(a);s=a,d||p||h?bt(c)?s=c:Ot(j=c)&&vt(j)?s=function(t,e){var n=-1,r=t.length;e||(e=Array(r));for(;++n<r;)e[n]=t[n];return e}(c):p?(l=!1,s=function(t,e){if(e)return t.slice();var n=t.length,r=k?k(n):new t.constructor(n);return t.copy(r),r}(a,!0)):h?(l=!1,y=a,b=!0?(v=y.buffer,_=new v.constructor(v.byteLength),new C(_).set(new C(v)),_):y.buffer,s=new y.constructor(b,y.byteOffset,y.length)):s=[]:function(t){if(!Ot(t)||"[object Object]"!=nt(t))return!1;var e=I(t);if(null===e)return!0;var n=P.call(e,"constructor")&&e.constructor;return"function"==typeof n&&n instanceof n&&w.call(n)==x}(a)||yt(a)?(s=c,yt(c)?s=function(t){return function(t,e,n,r){var o=!n;n||(n={});var i=-1,u=e.length;for(;++i<u;){var c=e[i],a=r?r(n[c],t[c],c,n,t):void 0;void 0===a&&(a=t[c]),o?Z(n,c,a):X(n,c,a)}return n}(t,Pt(t))}(c):mt(c)&&!jt(c)||(s=function(t){return"function"!=typeof t.constructor||lt(t)?{}:J(I(t))}(a))):l=!1}var y,b,v,_;var j;l&&(u.set(a,s),o(s,a,r,i,u),u.delete(a));Q(t,n,s)}(t,e,u,n,ut,r,o);else{var c=r?r(dt(t,u),i,u+"",t,e,o):void 0;void 0===c&&(c=i),Q(t,u,c)}}),Pt)}function ct(t,e){return pt(function(t,e,n){return e=$(void 0===e?t.length-1:e,0),function(){for(var r=arguments,o=-1,i=$(r.length-e,0),u=Array(i);++o<i;)u[o]=r[e+o];o=-1;for(var c=Array(e+1);++o<e;)c[o]=r[o];return c[e]=n(u),y(t,this,c)}}(t,e,xt),t+"")}function at(t,e){var n,r,o=t.__data__;return("string"==(r=typeof(n=e))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?o["string"==typeof e?"string":"hash"]:o.map}function ft(t,e){var n=function(t,e){return null==t?void 0:t[e]}(t,e);return ot(n)?n:void 0}function st(t,e){var n=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==n||"symbol"!=n&&o.test(t))&&t>-1&&t%1==0&&t<e}function lt(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||m)}function dt(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}var pt=function(t){var e=0,n=0;return function(){var r=N(),o=16-(r-n);if(n=r,o>0){if(++e>=800)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(M?function(t,e){return M(t,"toString",{configurable:!0,enumerable:!1,value:(n=e,function(){return n}),writable:!0});var n}:xt);function ht(t,e){return t===e||t!=t&&e!=e}var yt=rt(function(){return arguments}())?rt:function(t){return Ot(t)&&P.call(t,"callee")&&!H.call(t,"callee")},bt=Array.isArray;function vt(t){return null!=t&&gt(t.length)&&!jt(t)}var _t=K||function(){return!1};function jt(t){if(!mt(t))return!1;var e=nt(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e}function gt(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}function mt(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function Ot(t){return null!=t&&"object"==typeof t}var wt=h?function(t){return function(e){return t(e)}}(h):function(t){return Ot(t)&&gt(t.length)&&!!i[nt(t)]};function Pt(t){return vt(t)?W(t,!0):it(t)}var At,Tt=(At=function(t,e,n){ut(t,e,n)},ct((function(t,e){var n=-1,r=e.length,o=r>1?e[r-1]:void 0,i=r>2?e[2]:void 0;for(o=At.length>3&&"function"==typeof o?(r--,o):void 0,i&&function(t,e,n){if(!mt(n))return!1;var r=typeof e;return!!("number"==r?vt(n)&&st(e,n.length):"string"==r&&e in n)&&ht(n[e],t)}(e[0],e[1],i)&&(o=r<3?void 0:o,r=1),t=Object(t);++n<r;){var u=e[n];u&&At(t,u,n,o)}return t})));function xt(t){return t}n.exports=Tt}).call(this,n(3),n(4)(t))},function(t,e){t.exports=function(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t},t.exports.default=t.exports,t.exports.__esModule=!0},function(t,e,n){"use strict";n.r(e),n.d(e,"gatewayAuthHeader",(function(){return l})),n.d(e,"gatewayEmbedHostHeader",(function(){return d})),n.d(e,"setEmbedHost",(function(){return p})),n.d(e,"clearEmbedHost",(function(){return h})),n.d(e,"getEmbedHost",(function(){return y})),n.d(e,"setAPIKey",(function(){return b})),n.d(e,"clearAPIKey",(function(){return v})),n.d(e,"getAPIKey",(function(){return _})),n.d(e,"promiseTimeout",(function(){return g})),n.d(e,"get",(function(){return m})),n.d(e,"post",(function(){return O})),n.d(e,"patch",(function(){return w})),n.d(e,"remove",(function(){return P})),n.d(e,"generateJsonRPCObject",(function(){return A})),n.d(e,"promiseRace",(function(){return T}));var r=n(1),o=n.n(r),i=n(0),u=n.n(i);function c(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function a(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?c(Object(n),!0).forEach((function(e){o()(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):c(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}let f="torus-default",s="";const l="x-api-key",d="x-embed-host";function p(t){s=t}function h(){s=""}function y(){return s}function b(t){f=t}function v(){f="torus-default"}function _(){return f}function j(){const t={};return f&&(t[l]=f),s&&(t[d]=s),t}const g=(t,e)=>{const n=new Promise((e,n)=>{const r=setTimeout(()=>{clearTimeout(r),n(new Error("Timed out in ".concat(t,"ms")))},t)});return Promise.race([e,n])},m=async function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const r={mode:"cors",headers:{}};n.useAPIKey&&(r.headers=a(a({},r.headers),j()));const o=u()(r,e,{method:"GET"}),i=await fetch(t,o);if(i.ok)return i.json();throw i},O=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};const o={mode:"cors",headers:{"Content-Type":"application/json; charset=utf-8"}};r.useAPIKey&&(o.headers=a(a({},o.headers),j()));const i=u()(o,n,{method:"POST"});return r.isUrlEncodedData?(i.body=e,"application/json; charset=utf-8"===i.headers["Content-Type"]&&delete i.headers["Content-Type"]):i.body=JSON.stringify(e),g(r.timeout||6e4,fetch(t,i).then(t=>{if(t.ok)return t.json();throw t}))},w=async function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};const o={mode:"cors",headers:{"Content-Type":"application/json; charset=utf-8"}};r.useAPIKey&&(o.headers=a(a({},o.headers),j()));const i=u()(o,n,{method:"PATCH"});r.isUrlEncodedData?(i.body=e,"application/json; charset=utf-8"===i.headers["Content-Type"]&&delete i.headers["Content-Type"]):i.body=JSON.stringify(e);const c=await fetch(t,i);if(c.ok)return c.json();throw c},P=async function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};const o={mode:"cors",headers:{"Content-Type":"application/json; charset=utf-8"}};r.useAPIKey&&(o.headers=a(a({},o.headers),j()));const i=u()(o,n,{method:"DELETE"});r.isUrlEncodedData?(i.body=e,"application/json; charset=utf-8"===i.headers["Content-Type"]&&delete i.headers["Content-Type"]):i.body=JSON.stringify(e);const c=await fetch(t,i);if(c.ok)return c.json();throw c},A=(t,e)=>({jsonrpc:"2.0",method:t,id:10,params:e}),T=function(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:6e4;return Promise.race([m(t,e),new Promise((t,e)=>{setTimeout(()=>{e(new Error("timed out"))},n)})])}},function(t,e){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(t){"object"==typeof window&&(n=window)}t.exports=n},function(t,e){t.exports=function(t){return t.webpackPolyfill||(t.deprecate=function(){},t.paths=[],t.children||(t.children=[]),Object.defineProperty(t,"loaded",{enumerable:!0,get:function(){return t.l}}),Object.defineProperty(t,"id",{enumerable:!0,get:function(){return t.i}}),t.webpackPolyfill=1),t}}])}));
//# sourceMappingURL=httpHelpers.umd.min.js.map

@@ -21,3 +21,3 @@ export interface CustomOptions {

export declare const patch: <T>(url: string, data?: Data, options_?: RequestInit, customOptions?: CustomOptions) => Promise<T>;
export declare const remove: <T>(url: string, _data?: Data, options_?: RequestInit, customOptions?: CustomOptions) => Promise<T>;
export declare const remove: <T>(url: string, data?: Data, options_?: RequestInit, customOptions?: CustomOptions) => Promise<T>;
export declare const generateJsonRPCObject: (method: string, parameters: unknown) => {

@@ -24,0 +24,0 @@ jsonrpc: string;

{
"name": "@toruslabs/http-helpers",
"version": "2.1.3",
"version": "2.1.4",
"description": "http helpers",

@@ -5,0 +5,0 @@ "main": "dist/httpHelpers.cjs.js",

Sorry, the diff of this file is too big to display

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