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

@burstjs/http

Package Overview
Dependencies
Maintainers
2
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@burstjs/http - npm Package Compare versions

Comparing version 0.5.1 to 0.6.0-alpha.1

out/__tests__/e2e/http.spec.e2e.d.ts

6

CHANGELOG.md
# Change Log
All notable changes to this project will be documented in this file.
# 0.6.0
- Exporting HttpImpl as HttpClient
# 0.5.1
- Better message handling in case of errors
# 0.4.3

@@ -5,0 +11,0 @@ - Http clients with AxiosConfig

3

dist/burstjs.http.js

@@ -1715,2 +1715,5 @@ var b$http = (function (exports) {

var HttpClient = HttpImpl;
exports.HttpClient = HttpClient;
exports.HttpError = HttpError;

@@ -1717,0 +1720,0 @@ exports.HttpImpl = HttpImpl;

2

dist/burstjs.http.min.js

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

var b$http=function(e){"use strict";function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function r(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),e}var o=function e(n,r){t(this,e),this.status=n,this.response=r},i=function e(n,r,o,i){t(this,e),this.requestUrl=n,this.status=r,this.message=o,this.data=i,this.timestamp=Date.now()},s=function(){function e(){t(this,e),this._replyFunctions=e.initialReplyFunctions(),this.reset()}return r(e,[{key:"createReplyFn",value:function(e,t){return function(){return Promise.resolve(new o(e,t))}}},{key:"createErrorFn",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;return function(){throw new i(e,t,n,r)}}},{key:"reset",value:function(){this._replyFunctions=e.initialReplyFunctions()}},{key:"registerResponse",value:function(e,t,n,r){this._replyFunctions[e][t]=this.createReplyFn(n,r)}},{key:"registerError",value:function(e,t,n,r,o){this._replyFunctions[e][t]=this.createErrorFn(t,n,r,o)}},{key:"get",value:function(e){return this.request("get",e)}},{key:"delete",value:function(e){return this.request("delete",e)}},{key:"post",value:function(e,t){return this.request("post",e)}},{key:"put",value:function(e,t){return this.request("put",e)}},{key:"request",value:function(t,n){var r=this._replyFunctions[t][n]||this._replyFunctions[t][e.ForAll];if(!r)throw new Error("Could not find any mocked function for method ".concat(t.toUpperCase()," url ").concat(n));return r()}}],[{key:"initialReplyFunctions",value:function(){return{get:{},post:{},put:{},delete:{}}}}]),e}();s.ForAll="__all";var a=function(){function e(){t(this,e),this._httpMock=new s}return r(e,[{key:"onReply",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:s.ForAll;return this._httpMock.registerResponse(e,r,t,n),this}},{key:"onThrowError",value:function(e,t,n,r){var o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:s.ForAll;return this._httpMock.registerError(e,o,t,n,r),this}},{key:"onGetReply",value:function(e,t,n){return this.onReply("get",e,t,n)}},{key:"onGetThrowError",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:s.ForAll;return this.onThrowError("get",e,t,n,r)}},{key:"onPostReply",value:function(e,t,n){return this.onReply("post",e,t,n)}},{key:"onPostThrowError",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:s.ForAll;return this.onThrowError("post",e,t,n,r)}},{key:"onPutReply",value:function(e,t,n){return this.onReply("put",e,t,n)}},{key:"onPutThrowError",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:s.ForAll;return this.onThrowError("put",e,t,n,r)}},{key:"onDeleteReply",value:function(e,t,n){return this.onReply("delete",e,t,n)}},{key:"onDeleteThrowError",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:s.ForAll;return this.onThrowError("delete",e,t,n,r)}},{key:"build",value:function(){return this._httpMock}}],[{key:"create",value:function(){return new e}}]),e}();function u(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{u(r.next(e))}catch(e){i(e)}}function a(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){e.done?o(e.value):new n(function(t){t(e.value)}).then(s,a)}u((r=r.apply(e,t||[])).next())})}var c=function(e,t){return function(){for(var n=new Array(arguments.length),r=0;r<n.length;r++)n[r]=arguments[r];return e.apply(t,n)}},f=Object.prototype.toString;function l(e){return"[object Array]"===f.call(e)}function p(e){return null!==e&&"object"==typeof e}function h(e){return"[object Function]"===f.call(e)}function d(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),l(e))for(var n=0,r=e.length;n<r;n++)t.call(null,e[n],n,e);else for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.call(null,e[o],o,e)}var y={isArray:l,isArrayBuffer:function(e){return"[object ArrayBuffer]"===f.call(e)},isBuffer:function(e){return null!=e&&null!=e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)},isFormData:function(e){return"undefined"!=typeof FormData&&e instanceof FormData},isArrayBufferView:function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&e.buffer instanceof ArrayBuffer},isString:function(e){return"string"==typeof e},isNumber:function(e){return"number"==typeof e},isObject:p,isUndefined:function(e){return void 0===e},isDate:function(e){return"[object Date]"===f.call(e)},isFile:function(e){return"[object File]"===f.call(e)},isBlob:function(e){return"[object Blob]"===f.call(e)},isFunction:h,isStream:function(e){return p(e)&&h(e.pipe)},isURLSearchParams:function(e){return"undefined"!=typeof URLSearchParams&&e instanceof URLSearchParams},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&"undefined"!=typeof window&&"undefined"!=typeof document},forEach:d,merge:function e(){var t={};function n(n,r){"object"==typeof t[r]&&"object"==typeof n?t[r]=e(t[r],n):t[r]=n}for(var r=0,o=arguments.length;r<o;r++)d(arguments[r],n);return t},deepMerge:function e(){var t={};function n(n,r){"object"==typeof t[r]&&"object"==typeof n?t[r]=e(t[r],n):t[r]="object"==typeof n?e({},n):n}for(var r=0,o=arguments.length;r<o;r++)d(arguments[r],n);return t},extend:function(e,t,n){return d(t,function(t,r){e[r]=n&&"function"==typeof t?c(t,n):t}),e},trim:function(e){return e.replace(/^\s*/,"").replace(/\s*$/,"")}};function m(e){return encodeURIComponent(e).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var v=function(e,t,n){if(!t)return e;var r;if(n)r=n(t);else if(y.isURLSearchParams(t))r=t.toString();else{var o=[];y.forEach(t,function(e,t){null!=e&&(y.isArray(e)?t+="[]":e=[e],y.forEach(e,function(e){y.isDate(e)?e=e.toISOString():y.isObject(e)&&(e=JSON.stringify(e)),o.push(m(t)+"="+m(e))}))}),r=o.join("&")}if(r){var i=e.indexOf("#");-1!==i&&(e=e.slice(0,i)),e+=(-1===e.indexOf("?")?"?":"&")+r}return e};function g(){this.handlers=[]}g.prototype.use=function(e,t){return this.handlers.push({fulfilled:e,rejected:t}),this.handlers.length-1},g.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},g.prototype.forEach=function(e){y.forEach(this.handlers,function(t){null!==t&&e(t)})};var w=g,E=function(e,t,n){return y.forEach(n,function(n){e=n(e,t)}),e},b=function(e){return!(!e||!e.__CANCEL__)},R=function(e,t){y.forEach(e,function(n,r){r!==t&&r.toUpperCase()===t.toUpperCase()&&(e[t]=n,delete e[r])})},k=function(e,t,n,r,o){return function(e,t,n,r,o){return e.config=t,n&&(e.code=n),e.request=r,e.response=o,e.isAxiosError=!0,e.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code}},e}(new Error(e),t,n,r,o)},A=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"],C=y.isStandardBrowserEnv()?function(){var e,t=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");function r(e){var r=e;return t&&(n.setAttribute("href",r),r=n.href),n.setAttribute("href",r),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:"/"===n.pathname.charAt(0)?n.pathname:"/"+n.pathname}}return e=r(window.location.href),function(t){var n=y.isString(t)?r(t):t;return n.protocol===e.protocol&&n.host===e.host}}():function(){return!0},x=y.isStandardBrowserEnv()?{write:function(e,t,n,r,o,i){var s=[];s.push(e+"="+encodeURIComponent(t)),y.isNumber(n)&&s.push("expires="+new Date(n).toGMTString()),y.isString(r)&&s.push("path="+r),y.isString(o)&&s.push("domain="+o),!0===i&&s.push("secure"),document.cookie=s.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}},S=function(e){return new Promise(function(t,n){var r=e.data,o=e.headers;y.isFormData(r)&&delete o["Content-Type"];var i=new XMLHttpRequest;if(e.auth){var s=e.auth.username||"",a=e.auth.password||"";o.Authorization="Basic "+btoa(s+":"+a)}if(i.open(e.method.toUpperCase(),v(e.url,e.params,e.paramsSerializer),!0),i.timeout=e.timeout,i.onreadystatechange=function(){if(i&&4===i.readyState&&(0!==i.status||i.responseURL&&0===i.responseURL.indexOf("file:"))){var r,o,s,a,u,c="getAllResponseHeaders"in i?(r=i.getAllResponseHeaders(),u={},r?(y.forEach(r.split("\n"),function(e){if(a=e.indexOf(":"),o=y.trim(e.substr(0,a)).toLowerCase(),s=y.trim(e.substr(a+1)),o){if(u[o]&&A.indexOf(o)>=0)return;u[o]="set-cookie"===o?(u[o]?u[o]:[]).concat([s]):u[o]?u[o]+", "+s:s}}),u):u):null,f={data:e.responseType&&"text"!==e.responseType?i.response:i.responseText,status:i.status,statusText:i.statusText,headers:c,config:e,request:i};!function(e,t,n){var r=n.config.validateStatus;!r||r(n.status)?e(n):t(k("Request failed with status code "+n.status,n.config,null,n.request,n))}(t,n,f),i=null}},i.onabort=function(){i&&(n(k("Request aborted",e,"ECONNABORTED",i)),i=null)},i.onerror=function(){n(k("Network Error",e,null,i)),i=null},i.ontimeout=function(){n(k("timeout of "+e.timeout+"ms exceeded",e,"ECONNABORTED",i)),i=null},y.isStandardBrowserEnv()){var u=x,c=(e.withCredentials||C(e.url))&&e.xsrfCookieName?u.read(e.xsrfCookieName):void 0;c&&(o[e.xsrfHeaderName]=c)}if("setRequestHeader"in i&&y.forEach(o,function(e,t){void 0===r&&"content-type"===t.toLowerCase()?delete o[t]:i.setRequestHeader(t,e)}),e.withCredentials&&(i.withCredentials=!0),e.responseType)try{i.responseType=e.responseType}catch(t){if("json"!==e.responseType)throw t}"function"==typeof e.onDownloadProgress&&i.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&i.upload&&i.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then(function(e){i&&(i.abort(),n(e),i=null)}),void 0===r&&(r=null),i.send(r)})},T={"Content-Type":"application/x-www-form-urlencoded"};function j(e,t){!y.isUndefined(e)&&y.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var F,N={adapter:("undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process)?F=S:"undefined"!=typeof XMLHttpRequest&&(F=S),F),transformRequest:[function(e,t){return R(t,"Accept"),R(t,"Content-Type"),y.isFormData(e)||y.isArrayBuffer(e)||y.isBuffer(e)||y.isStream(e)||y.isFile(e)||y.isBlob(e)?e:y.isArrayBufferView(e)?e.buffer:y.isURLSearchParams(e)?(j(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):y.isObject(e)?(j(t,"application/json;charset=utf-8"),JSON.stringify(e)):e}],transformResponse:[function(e){if("string"==typeof e)try{e=JSON.parse(e)}catch(e){}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,validateStatus:function(e){return e>=200&&e<300}};N.headers={common:{Accept:"application/json, text/plain, */*"}},y.forEach(["delete","get","head"],function(e){N.headers[e]={}}),y.forEach(["post","put","patch"],function(e){N.headers[e]=y.merge(T)});var q=N;function O(e){e.cancelToken&&e.cancelToken.throwIfRequested()}var U=function(e){var t,n,r;return O(e),e.baseURL&&(r=e.url,!/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(r))&&(e.url=(t=e.baseURL,(n=e.url)?t.replace(/\/+$/,"")+"/"+n.replace(/^\/+/,""):t)),e.headers=e.headers||{},e.data=E(e.data,e.headers,e.transformRequest),e.headers=y.merge(e.headers.common||{},e.headers[e.method]||{},e.headers||{}),y.forEach(["delete","get","head","post","put","patch","common"],function(t){delete e.headers[t]}),(e.adapter||q.adapter)(e).then(function(t){return O(e),t.data=E(t.data,t.headers,e.transformResponse),t},function(t){return b(t)||(O(e),t&&t.response&&(t.response.data=E(t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)})},B=function(e,t){t=t||{};var n={};return y.forEach(["url","method","params","data"],function(e){void 0!==t[e]&&(n[e]=t[e])}),y.forEach(["headers","auth","proxy"],function(r){y.isObject(t[r])?n[r]=y.deepMerge(e[r],t[r]):void 0!==t[r]?n[r]=t[r]:y.isObject(e[r])?n[r]=y.deepMerge(e[r]):void 0!==e[r]&&(n[r]=e[r])}),y.forEach(["baseURL","transformRequest","transformResponse","paramsSerializer","timeout","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","maxContentLength","validateStatus","maxRedirects","httpAgent","httpsAgent","cancelToken","socketPath"],function(r){void 0!==t[r]?n[r]=t[r]:void 0!==e[r]&&(n[r]=e[r])}),n};function P(e){this.defaults=e,this.interceptors={request:new w,response:new w}}P.prototype.request=function(e){"string"==typeof e?(e=arguments[1]||{}).url=arguments[0]:e=e||{},(e=B(this.defaults,e)).method=e.method?e.method.toLowerCase():"get";var t=[U,void 0],n=Promise.resolve(e);for(this.interceptors.request.forEach(function(e){t.unshift(e.fulfilled,e.rejected)}),this.interceptors.response.forEach(function(e){t.push(e.fulfilled,e.rejected)});t.length;)n=n.then(t.shift(),t.shift());return n},P.prototype.getUri=function(e){return e=B(this.defaults,e),v(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")},y.forEach(["delete","get","head","options"],function(e){P.prototype[e]=function(t,n){return this.request(y.merge(n||{},{method:e,url:t}))}}),y.forEach(["post","put","patch"],function(e){P.prototype[e]=function(t,n,r){return this.request(y.merge(r||{},{method:e,url:t,data:n}))}});var _=P;function L(e){this.message=e}L.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},L.prototype.__CANCEL__=!0;var D=L;function H(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise(function(e){t=e});var n=this;e(function(e){n.reason||(n.reason=new D(e),t(n.reason))})}H.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},H.source=function(){var e;return{token:new H(function(t){e=t}),cancel:e}};var I=H;function M(e){var t=new _(e),n=c(_.prototype.request,t);return y.extend(n,_.prototype,t),y.extend(n,t),n}var z=M(q);z.Axios=_,z.create=function(e){return M(B(z.defaults,e))},z.Cancel=D,z.CancelToken=I,z.isCancel=b,z.all=function(e){return Promise.all(e)},z.spread=function(e){return function(t){return e.apply(null,t)}};var X=z,$=z;X.default=$;var J=X,V={},G=function(){function e(n){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:V;t(this,e),this._clientImpl=J.create(Object.assign({baseURL:n},r))}return r(e,[{key:"get",value:function(t,n){return u(this,void 0,void 0,function*(){try{var r=yield this._clientImpl.get(t,n),i=r.status,s=r.data;return new o(i,s)}catch(n){throw e.mountError(t,n)}})}},{key:"post",value:function(t,n,r){return u(this,void 0,void 0,function*(){try{var i=yield this._clientImpl.post(t,n,r),s=i.status,a=i.data;return new o(s,a)}catch(n){throw e.mountError(t,n)}})}},{key:"put",value:function(t,n,r){return u(this,void 0,void 0,function*(){try{var i=yield this._clientImpl.put(t,n,r),s=i.status,a=i.data;return new o(s,a)}catch(n){throw e.mountError(t,n)}})}},{key:"delete",value:function(t,n){return u(this,void 0,void 0,function*(){try{var r=yield this._clientImpl.delete(t,n),i=r.status,s=r.data;return new o(i,s)}catch(n){throw e.mountError(t,n)}})}}],[{key:"mountError",value:function(e,t){return t.response?new i(e,t.response.status,t.response.statusText,t.response.data):t.message?new i(e,0,"Request failed",t.message):t.request?new i(e,0,"Request failed",t.request):new i(e,-1,"Http Configuration error",null)}}]),e}();return e.HttpError=i,e.HttpImpl=G,e.HttpMockBuilder=a,e.HttpResponse=o,e}({});
var b$http=function(e){"use strict";function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function r(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),e}var o=function e(n,r){t(this,e),this.status=n,this.response=r},i=function e(n,r,o,i){t(this,e),this.requestUrl=n,this.status=r,this.message=o,this.data=i,this.timestamp=Date.now()},s=function(){function e(){t(this,e),this._replyFunctions=e.initialReplyFunctions(),this.reset()}return r(e,[{key:"createReplyFn",value:function(e,t){return function(){return Promise.resolve(new o(e,t))}}},{key:"createErrorFn",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;return function(){throw new i(e,t,n,r)}}},{key:"reset",value:function(){this._replyFunctions=e.initialReplyFunctions()}},{key:"registerResponse",value:function(e,t,n,r){this._replyFunctions[e][t]=this.createReplyFn(n,r)}},{key:"registerError",value:function(e,t,n,r,o){this._replyFunctions[e][t]=this.createErrorFn(t,n,r,o)}},{key:"get",value:function(e){return this.request("get",e)}},{key:"delete",value:function(e){return this.request("delete",e)}},{key:"post",value:function(e,t){return this.request("post",e)}},{key:"put",value:function(e,t){return this.request("put",e)}},{key:"request",value:function(t,n){var r=this._replyFunctions[t][n]||this._replyFunctions[t][e.ForAll];if(!r)throw new Error("Could not find any mocked function for method ".concat(t.toUpperCase()," url ").concat(n));return r()}}],[{key:"initialReplyFunctions",value:function(){return{get:{},post:{},put:{},delete:{}}}}]),e}();s.ForAll="__all";var a=function(){function e(){t(this,e),this._httpMock=new s}return r(e,[{key:"onReply",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:s.ForAll;return this._httpMock.registerResponse(e,r,t,n),this}},{key:"onThrowError",value:function(e,t,n,r){var o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:s.ForAll;return this._httpMock.registerError(e,o,t,n,r),this}},{key:"onGetReply",value:function(e,t,n){return this.onReply("get",e,t,n)}},{key:"onGetThrowError",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:s.ForAll;return this.onThrowError("get",e,t,n,r)}},{key:"onPostReply",value:function(e,t,n){return this.onReply("post",e,t,n)}},{key:"onPostThrowError",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:s.ForAll;return this.onThrowError("post",e,t,n,r)}},{key:"onPutReply",value:function(e,t,n){return this.onReply("put",e,t,n)}},{key:"onPutThrowError",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:s.ForAll;return this.onThrowError("put",e,t,n,r)}},{key:"onDeleteReply",value:function(e,t,n){return this.onReply("delete",e,t,n)}},{key:"onDeleteThrowError",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:s.ForAll;return this.onThrowError("delete",e,t,n,r)}},{key:"build",value:function(){return this._httpMock}}],[{key:"create",value:function(){return new e}}]),e}();function u(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{u(r.next(e))}catch(e){i(e)}}function a(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){e.done?o(e.value):new n(function(t){t(e.value)}).then(s,a)}u((r=r.apply(e,t||[])).next())})}var c=function(e,t){return function(){for(var n=new Array(arguments.length),r=0;r<n.length;r++)n[r]=arguments[r];return e.apply(t,n)}},f=Object.prototype.toString;function l(e){return"[object Array]"===f.call(e)}function p(e){return null!==e&&"object"==typeof e}function h(e){return"[object Function]"===f.call(e)}function d(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),l(e))for(var n=0,r=e.length;n<r;n++)t.call(null,e[n],n,e);else for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.call(null,e[o],o,e)}var y={isArray:l,isArrayBuffer:function(e){return"[object ArrayBuffer]"===f.call(e)},isBuffer:function(e){return null!=e&&null!=e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)},isFormData:function(e){return"undefined"!=typeof FormData&&e instanceof FormData},isArrayBufferView:function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&e.buffer instanceof ArrayBuffer},isString:function(e){return"string"==typeof e},isNumber:function(e){return"number"==typeof e},isObject:p,isUndefined:function(e){return void 0===e},isDate:function(e){return"[object Date]"===f.call(e)},isFile:function(e){return"[object File]"===f.call(e)},isBlob:function(e){return"[object Blob]"===f.call(e)},isFunction:h,isStream:function(e){return p(e)&&h(e.pipe)},isURLSearchParams:function(e){return"undefined"!=typeof URLSearchParams&&e instanceof URLSearchParams},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&"undefined"!=typeof window&&"undefined"!=typeof document},forEach:d,merge:function e(){var t={};function n(n,r){"object"==typeof t[r]&&"object"==typeof n?t[r]=e(t[r],n):t[r]=n}for(var r=0,o=arguments.length;r<o;r++)d(arguments[r],n);return t},deepMerge:function e(){var t={};function n(n,r){"object"==typeof t[r]&&"object"==typeof n?t[r]=e(t[r],n):t[r]="object"==typeof n?e({},n):n}for(var r=0,o=arguments.length;r<o;r++)d(arguments[r],n);return t},extend:function(e,t,n){return d(t,function(t,r){e[r]=n&&"function"==typeof t?c(t,n):t}),e},trim:function(e){return e.replace(/^\s*/,"").replace(/\s*$/,"")}};function m(e){return encodeURIComponent(e).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var v=function(e,t,n){if(!t)return e;var r;if(n)r=n(t);else if(y.isURLSearchParams(t))r=t.toString();else{var o=[];y.forEach(t,function(e,t){null!=e&&(y.isArray(e)?t+="[]":e=[e],y.forEach(e,function(e){y.isDate(e)?e=e.toISOString():y.isObject(e)&&(e=JSON.stringify(e)),o.push(m(t)+"="+m(e))}))}),r=o.join("&")}if(r){var i=e.indexOf("#");-1!==i&&(e=e.slice(0,i)),e+=(-1===e.indexOf("?")?"?":"&")+r}return e};function g(){this.handlers=[]}g.prototype.use=function(e,t){return this.handlers.push({fulfilled:e,rejected:t}),this.handlers.length-1},g.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},g.prototype.forEach=function(e){y.forEach(this.handlers,function(t){null!==t&&e(t)})};var w=g,E=function(e,t,n){return y.forEach(n,function(n){e=n(e,t)}),e},b=function(e){return!(!e||!e.__CANCEL__)},R=function(e,t){y.forEach(e,function(n,r){r!==t&&r.toUpperCase()===t.toUpperCase()&&(e[t]=n,delete e[r])})},k=function(e,t,n,r,o){return function(e,t,n,r,o){return e.config=t,n&&(e.code=n),e.request=r,e.response=o,e.isAxiosError=!0,e.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code}},e}(new Error(e),t,n,r,o)},C=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"],A=y.isStandardBrowserEnv()?function(){var e,t=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");function r(e){var r=e;return t&&(n.setAttribute("href",r),r=n.href),n.setAttribute("href",r),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:"/"===n.pathname.charAt(0)?n.pathname:"/"+n.pathname}}return e=r(window.location.href),function(t){var n=y.isString(t)?r(t):t;return n.protocol===e.protocol&&n.host===e.host}}():function(){return!0},x=y.isStandardBrowserEnv()?{write:function(e,t,n,r,o,i){var s=[];s.push(e+"="+encodeURIComponent(t)),y.isNumber(n)&&s.push("expires="+new Date(n).toGMTString()),y.isString(r)&&s.push("path="+r),y.isString(o)&&s.push("domain="+o),!0===i&&s.push("secure"),document.cookie=s.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}},S=function(e){return new Promise(function(t,n){var r=e.data,o=e.headers;y.isFormData(r)&&delete o["Content-Type"];var i=new XMLHttpRequest;if(e.auth){var s=e.auth.username||"",a=e.auth.password||"";o.Authorization="Basic "+btoa(s+":"+a)}if(i.open(e.method.toUpperCase(),v(e.url,e.params,e.paramsSerializer),!0),i.timeout=e.timeout,i.onreadystatechange=function(){if(i&&4===i.readyState&&(0!==i.status||i.responseURL&&0===i.responseURL.indexOf("file:"))){var r,o,s,a,u,c="getAllResponseHeaders"in i?(r=i.getAllResponseHeaders(),u={},r?(y.forEach(r.split("\n"),function(e){if(a=e.indexOf(":"),o=y.trim(e.substr(0,a)).toLowerCase(),s=y.trim(e.substr(a+1)),o){if(u[o]&&C.indexOf(o)>=0)return;u[o]="set-cookie"===o?(u[o]?u[o]:[]).concat([s]):u[o]?u[o]+", "+s:s}}),u):u):null,f={data:e.responseType&&"text"!==e.responseType?i.response:i.responseText,status:i.status,statusText:i.statusText,headers:c,config:e,request:i};!function(e,t,n){var r=n.config.validateStatus;!r||r(n.status)?e(n):t(k("Request failed with status code "+n.status,n.config,null,n.request,n))}(t,n,f),i=null}},i.onabort=function(){i&&(n(k("Request aborted",e,"ECONNABORTED",i)),i=null)},i.onerror=function(){n(k("Network Error",e,null,i)),i=null},i.ontimeout=function(){n(k("timeout of "+e.timeout+"ms exceeded",e,"ECONNABORTED",i)),i=null},y.isStandardBrowserEnv()){var u=x,c=(e.withCredentials||A(e.url))&&e.xsrfCookieName?u.read(e.xsrfCookieName):void 0;c&&(o[e.xsrfHeaderName]=c)}if("setRequestHeader"in i&&y.forEach(o,function(e,t){void 0===r&&"content-type"===t.toLowerCase()?delete o[t]:i.setRequestHeader(t,e)}),e.withCredentials&&(i.withCredentials=!0),e.responseType)try{i.responseType=e.responseType}catch(t){if("json"!==e.responseType)throw t}"function"==typeof e.onDownloadProgress&&i.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&i.upload&&i.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then(function(e){i&&(i.abort(),n(e),i=null)}),void 0===r&&(r=null),i.send(r)})},T={"Content-Type":"application/x-www-form-urlencoded"};function j(e,t){!y.isUndefined(e)&&y.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var F,N={adapter:("undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process)?F=S:"undefined"!=typeof XMLHttpRequest&&(F=S),F),transformRequest:[function(e,t){return R(t,"Accept"),R(t,"Content-Type"),y.isFormData(e)||y.isArrayBuffer(e)||y.isBuffer(e)||y.isStream(e)||y.isFile(e)||y.isBlob(e)?e:y.isArrayBufferView(e)?e.buffer:y.isURLSearchParams(e)?(j(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):y.isObject(e)?(j(t,"application/json;charset=utf-8"),JSON.stringify(e)):e}],transformResponse:[function(e){if("string"==typeof e)try{e=JSON.parse(e)}catch(e){}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,validateStatus:function(e){return e>=200&&e<300}};N.headers={common:{Accept:"application/json, text/plain, */*"}},y.forEach(["delete","get","head"],function(e){N.headers[e]={}}),y.forEach(["post","put","patch"],function(e){N.headers[e]=y.merge(T)});var q=N;function O(e){e.cancelToken&&e.cancelToken.throwIfRequested()}var U=function(e){var t,n,r;return O(e),e.baseURL&&(r=e.url,!/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(r))&&(e.url=(t=e.baseURL,(n=e.url)?t.replace(/\/+$/,"")+"/"+n.replace(/^\/+/,""):t)),e.headers=e.headers||{},e.data=E(e.data,e.headers,e.transformRequest),e.headers=y.merge(e.headers.common||{},e.headers[e.method]||{},e.headers||{}),y.forEach(["delete","get","head","post","put","patch","common"],function(t){delete e.headers[t]}),(e.adapter||q.adapter)(e).then(function(t){return O(e),t.data=E(t.data,t.headers,e.transformResponse),t},function(t){return b(t)||(O(e),t&&t.response&&(t.response.data=E(t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)})},B=function(e,t){t=t||{};var n={};return y.forEach(["url","method","params","data"],function(e){void 0!==t[e]&&(n[e]=t[e])}),y.forEach(["headers","auth","proxy"],function(r){y.isObject(t[r])?n[r]=y.deepMerge(e[r],t[r]):void 0!==t[r]?n[r]=t[r]:y.isObject(e[r])?n[r]=y.deepMerge(e[r]):void 0!==e[r]&&(n[r]=e[r])}),y.forEach(["baseURL","transformRequest","transformResponse","paramsSerializer","timeout","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","maxContentLength","validateStatus","maxRedirects","httpAgent","httpsAgent","cancelToken","socketPath"],function(r){void 0!==t[r]?n[r]=t[r]:void 0!==e[r]&&(n[r]=e[r])}),n};function P(e){this.defaults=e,this.interceptors={request:new w,response:new w}}P.prototype.request=function(e){"string"==typeof e?(e=arguments[1]||{}).url=arguments[0]:e=e||{},(e=B(this.defaults,e)).method=e.method?e.method.toLowerCase():"get";var t=[U,void 0],n=Promise.resolve(e);for(this.interceptors.request.forEach(function(e){t.unshift(e.fulfilled,e.rejected)}),this.interceptors.response.forEach(function(e){t.push(e.fulfilled,e.rejected)});t.length;)n=n.then(t.shift(),t.shift());return n},P.prototype.getUri=function(e){return e=B(this.defaults,e),v(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")},y.forEach(["delete","get","head","options"],function(e){P.prototype[e]=function(t,n){return this.request(y.merge(n||{},{method:e,url:t}))}}),y.forEach(["post","put","patch"],function(e){P.prototype[e]=function(t,n,r){return this.request(y.merge(r||{},{method:e,url:t,data:n}))}});var _=P;function L(e){this.message=e}L.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},L.prototype.__CANCEL__=!0;var D=L;function H(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise(function(e){t=e});var n=this;e(function(e){n.reason||(n.reason=new D(e),t(n.reason))})}H.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},H.source=function(){var e;return{token:new H(function(t){e=t}),cancel:e}};var I=H;function M(e){var t=new _(e),n=c(_.prototype.request,t);return y.extend(n,_.prototype,t),y.extend(n,t),n}var z=M(q);z.Axios=_,z.create=function(e){return M(B(z.defaults,e))},z.Cancel=D,z.CancelToken=I,z.isCancel=b,z.all=function(e){return Promise.all(e)},z.spread=function(e){return function(t){return e.apply(null,t)}};var X=z,$=z;X.default=$;var J=X,V={},G=function(){function e(n){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:V;t(this,e),this._clientImpl=J.create(Object.assign({baseURL:n},r))}return r(e,[{key:"get",value:function(t,n){return u(this,void 0,void 0,function*(){try{var r=yield this._clientImpl.get(t,n),i=r.status,s=r.data;return new o(i,s)}catch(n){throw e.mountError(t,n)}})}},{key:"post",value:function(t,n,r){return u(this,void 0,void 0,function*(){try{var i=yield this._clientImpl.post(t,n,r),s=i.status,a=i.data;return new o(s,a)}catch(n){throw e.mountError(t,n)}})}},{key:"put",value:function(t,n,r){return u(this,void 0,void 0,function*(){try{var i=yield this._clientImpl.put(t,n,r),s=i.status,a=i.data;return new o(s,a)}catch(n){throw e.mountError(t,n)}})}},{key:"delete",value:function(t,n){return u(this,void 0,void 0,function*(){try{var r=yield this._clientImpl.delete(t,n),i=r.status,s=r.data;return new o(i,s)}catch(n){throw e.mountError(t,n)}})}}],[{key:"mountError",value:function(e,t){return t.response?new i(e,t.response.status,t.response.statusText,t.response.data):t.message?new i(e,0,"Request failed",t.message):t.request?new i(e,0,"Request failed",t.request):new i(e,-1,"Http Configuration error",null)}}]),e}(),K=G;return e.HttpClient=K,e.HttpError=i,e.HttpImpl=G,e.HttpMockBuilder=a,e.HttpResponse=o,e}({});
//# sourceMappingURL=burstjs.http.min.js.map

@@ -6,3 +6,3 @@ import HttpResponse from './httpResponse';

put(url: string, payload: any, options?: any): Promise<HttpResponse>;
delete(url: string, options: any): Promise<HttpResponse>;
delete(url: string, options?: any): Promise<HttpResponse>;
}

@@ -6,2 +6,3 @@ import Http from './http';

import HttpImpl from './httpImpl';
export { Http, HttpImpl, HttpResponse, HttpMockBuilder, HttpError };
declare const HttpClient: typeof HttpImpl;
export { Http, HttpClient, HttpImpl, HttpResponse, HttpMockBuilder, HttpError };

@@ -6,3 +6,3 @@ import HttpResponse from './httpResponse';

put(url: string, payload: any, options?: any): Promise<HttpResponse>;
delete(url: string, options: any): Promise<HttpResponse>;
delete(url: string, options?: any): Promise<HttpResponse>;
}

@@ -6,2 +6,3 @@ import Http from './http';

import HttpImpl from './httpImpl';
export { Http, HttpImpl, HttpResponse, HttpMockBuilder, HttpError };
declare const HttpClient: typeof HttpImpl;
export { Http, HttpClient, HttpImpl, HttpResponse, HttpMockBuilder, HttpError };
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.HttpError = exports.HttpMockBuilder = exports.HttpResponse = exports.HttpImpl = exports.HttpClient = void 0;
const httpResponse_1 = require("./httpResponse");

@@ -11,2 +12,4 @@ exports.HttpResponse = httpResponse_1.default;

exports.HttpImpl = httpImpl_1.default;
const HttpClient = httpImpl_1.default;
exports.HttpClient = HttpClient;
//# sourceMappingURL=index.js.map
{
"name": "@burstjs/http",
"version": "0.5.1",
"version": "0.6.0-alpha.1",
"description": "Send commands to BURST over HTTP",

@@ -54,3 +54,3 @@ "contributors": [

},
"gitHead": "27a7a2409c626bdb996f0085497cc4e8707144a1",
"gitHead": "505c2211b2089675129915bdd4e909f5bdc33fab",
"publishConfig": {

@@ -57,0 +57,0 @@ "access": "public"

@@ -42,4 +42,4 @@ import HttpResponse from './httpResponse';

*/
delete(url: string, options: any): Promise<HttpResponse>;
delete(url: string, options?: any): Promise<HttpResponse>;
}

@@ -10,2 +10,5 @@ import axios, {AxiosInstance, AxiosRequestConfig} from 'axios';

* Http Implementation of [[Http]] using https://github.com/axios/axios
*
* You can use [[HttpClient]] as alias
*
* @module http

@@ -12,0 +15,0 @@ */

@@ -14,4 +14,12 @@ /**

/**
* Alias for HttpImpl
*
* @module http
*/
const HttpClient = HttpImpl;
export {
Http,
HttpClient,
HttpImpl,

@@ -18,0 +26,0 @@ HttpResponse,

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