Socket
Socket
Sign inDemoInstall

@taquito/http-utils

Package Overview
Dependencies
Maintainers
4
Versions
200
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@taquito/http-utils - npm Package Compare versions

Comparing version 16.2.0 to 17.0.0-beta-RC.0

dist/lib/errors.js

42

dist/lib/taquito-http-utils.js

@@ -27,5 +27,6 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.HttpBackend = exports.HttpRequestFailed = exports.HttpResponseError = exports.VERSION = void 0;
exports.HttpBackend = exports.HttpResponseError = exports.HttpRequestFailed = exports.VERSION = void 0;
const fetch_adapter_1 = require("./fetch-adapter");
const axios_1 = require("axios");
const errors_1 = require("./errors");
const isNode = typeof process !== 'undefined' && !!((_a = process === null || process === void 0 ? void 0 : process.versions) === null || _a === void 0 ? void 0 : _a.node);

@@ -36,2 +37,5 @@ const adapter = isNode ? undefined : fetch_adapter_1.default;

Object.defineProperty(exports, "VERSION", { enumerable: true, get: function () { return version_1.VERSION; } });
var errors_2 = require("./errors");
Object.defineProperty(exports, "HttpRequestFailed", { enumerable: true, get: function () { return errors_2.HttpRequestFailed; } });
Object.defineProperty(exports, "HttpResponseError", { enumerable: true, get: function () { return errors_2.HttpResponseError; } });
var ResponseType;

@@ -42,30 +46,2 @@ (function (ResponseType) {

})(ResponseType || (ResponseType = {}));
/**
* @category Error
* @description This error will be thrown when the endpoint returns an HTTP error to the client
*/
class HttpResponseError extends Error {
constructor(message, status, statusText, body, url) {
super(message);
this.message = message;
this.status = status;
this.statusText = statusText;
this.body = body;
this.url = url;
this.name = 'HttpResponse';
}
}
exports.HttpResponseError = HttpResponseError;
/**
* @category Error
* @description Error that indicates a general failure in making the HTTP request
*/
class HttpRequestFailed extends Error {
constructor(message) {
super(message);
this.message = message;
this.name = 'HttpRequestFailed';
}
}
exports.HttpRequestFailed = HttpRequestFailed;
class HttpBackend {

@@ -112,5 +88,7 @@ constructor(timeout = 30000) {

* @param options contains options to be passed for the HTTP request (url, method and timeout)
* @throws {@link HttpRequestFailed} | {@link HttpResponseError}
*/
createRequest({ url, method, timeout = this.timeout, query, headers = {}, json = true }, data) {
return __awaiter(this, void 0, void 0, function* () {
const urlWithQuery = url + this.serialize(query);
let resType;

@@ -130,3 +108,3 @@ let transformResponse = undefined;

const response = yield axios_1.default.request({
url: url + this.serialize(query),
url: urlWithQuery,
method: method !== null && method !== void 0 ? method : 'GET',

@@ -151,6 +129,6 @@ headers: headers,

}
throw new HttpResponseError(`Http error response: (${err.response.status}) ${errorData}`, err.response.status, err.response.statusText, errorData, url + this.serialize(query));
throw new errors_1.HttpResponseError(`Http error response: (${err.response.status}) ${errorData}`, err.response.status, err.response.statusText, errorData, urlWithQuery);
}
else {
throw new HttpRequestFailed(`${method} ${url + this.serialize(query)} ${String(err)}`);
throw new errors_1.HttpRequestFailed(String(method), urlWithQuery, err);
}

@@ -157,0 +135,0 @@ }

@@ -6,5 +6,5 @@ "use strict";

exports.VERSION = {
"commitHash": "adc0f8c31492e8eb2f03b06ac36ba053e8ba6224",
"version": "16.2.0"
"commitHash": "1169170fdbf4efd03283dc902bc03b9df5bb2fb1",
"version": "17.0.0-beta-RC.0"
};
//# sourceMappingURL=version.js.map
import axios from 'axios';
import { NetworkError } from '@taquito/core';

@@ -245,2 +246,32 @@ /******************************************************************************

/**
* @category Error
* @description Error indicates a general failure in making the HTTP request
*/
class HttpRequestFailed extends NetworkError {
constructor(method, url, cause) {
super();
this.method = method;
this.url = url;
this.cause = cause;
this.name = 'HttpRequestFailed';
this.message = `${method} ${url} ${String(cause)}`;
}
}
/**
* @category Error
* @description Error thrown when the endpoint returns an HTTP error to the client
*/
class HttpResponseError extends NetworkError {
constructor(message, status, statusText, body, url) {
super(message);
this.message = message;
this.status = status;
this.statusText = statusText;
this.body = body;
this.url = url;
this.name = 'HttpResponse';
}
}
/**
* Hypertext Transfer Protocol (HTTP) response status codes.

@@ -567,4 +598,4 @@ * @see {@link https://en.wikipedia.org/wiki/List_of_HTTP_status_codes}

const VERSION = {
"commitHash": "adc0f8c31492e8eb2f03b06ac36ba053e8ba6224",
"version": "16.2.0"
"commitHash": "1169170fdbf4efd03283dc902bc03b9df5bb2fb1",
"version": "17.0.0-beta-RC.0"
};

@@ -584,28 +615,2 @@

})(ResponseType || (ResponseType = {}));
/**
* @category Error
* @description This error will be thrown when the endpoint returns an HTTP error to the client
*/
class HttpResponseError extends Error {
constructor(message, status, statusText, body, url) {
super(message);
this.message = message;
this.status = status;
this.statusText = statusText;
this.body = body;
this.url = url;
this.name = 'HttpResponse';
}
}
/**
* @category Error
* @description Error that indicates a general failure in making the HTTP request
*/
class HttpRequestFailed extends Error {
constructor(message) {
super(message);
this.message = message;
this.name = 'HttpRequestFailed';
}
}
class HttpBackend {

@@ -652,5 +657,7 @@ constructor(timeout = 30000) {

* @param options contains options to be passed for the HTTP request (url, method and timeout)
* @throws {@link HttpRequestFailed} | {@link HttpResponseError}
*/
createRequest({ url, method, timeout = this.timeout, query, headers = {}, json = true }, data) {
return __awaiter(this, void 0, void 0, function* () {
const urlWithQuery = url + this.serialize(query);
let resType;

@@ -670,3 +677,3 @@ let transformResponse = undefined;

const response = yield axios.request({
url: url + this.serialize(query),
url: urlWithQuery,
method: method !== null && method !== void 0 ? method : 'GET',

@@ -691,6 +698,6 @@ headers: headers,

}
throw new HttpResponseError(`Http error response: (${err.response.status}) ${errorData}`, err.response.status, err.response.statusText, errorData, url + this.serialize(query));
throw new HttpResponseError(`Http error response: (${err.response.status}) ${errorData}`, err.response.status, err.response.statusText, errorData, urlWithQuery);
}
else {
throw new HttpRequestFailed(`${method} ${url + this.serialize(query)} ${String(err)}`);
throw new HttpRequestFailed(String(method), urlWithQuery, err);
}

@@ -697,0 +704,0 @@ }

(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('axios')) :
typeof define === 'function' && define.amd ? define(['exports', 'axios'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.taquitoHttpUtils = {}, global.axios));
})(this, (function (exports, axios) { 'use strict';
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('axios'), require('@taquito/core')) :
typeof define === 'function' && define.amd ? define(['exports', 'axios', '@taquito/core'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.taquitoHttpUtils = {}, global.axios, global.core));
})(this, (function (exports, axios, core) { 'use strict';

@@ -253,2 +253,32 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

/**
* @category Error
* @description Error indicates a general failure in making the HTTP request
*/
class HttpRequestFailed extends core.NetworkError {
constructor(method, url, cause) {
super();
this.method = method;
this.url = url;
this.cause = cause;
this.name = 'HttpRequestFailed';
this.message = `${method} ${url} ${String(cause)}`;
}
}
/**
* @category Error
* @description Error thrown when the endpoint returns an HTTP error to the client
*/
class HttpResponseError extends core.NetworkError {
constructor(message, status, statusText, body, url) {
super(message);
this.message = message;
this.status = status;
this.statusText = statusText;
this.body = body;
this.url = url;
this.name = 'HttpResponse';
}
}
/**
* Hypertext Transfer Protocol (HTTP) response status codes.

@@ -575,4 +605,4 @@ * @see {@link https://en.wikipedia.org/wiki/List_of_HTTP_status_codes}

const VERSION = {
"commitHash": "adc0f8c31492e8eb2f03b06ac36ba053e8ba6224",
"version": "16.2.0"
"commitHash": "1169170fdbf4efd03283dc902bc03b9df5bb2fb1",
"version": "17.0.0-beta-RC.0"
};

@@ -592,28 +622,2 @@

})(ResponseType || (ResponseType = {}));
/**
* @category Error
* @description This error will be thrown when the endpoint returns an HTTP error to the client
*/
class HttpResponseError extends Error {
constructor(message, status, statusText, body, url) {
super(message);
this.message = message;
this.status = status;
this.statusText = statusText;
this.body = body;
this.url = url;
this.name = 'HttpResponse';
}
}
/**
* @category Error
* @description Error that indicates a general failure in making the HTTP request
*/
class HttpRequestFailed extends Error {
constructor(message) {
super(message);
this.message = message;
this.name = 'HttpRequestFailed';
}
}
class HttpBackend {

@@ -660,5 +664,7 @@ constructor(timeout = 30000) {

* @param options contains options to be passed for the HTTP request (url, method and timeout)
* @throws {@link HttpRequestFailed} | {@link HttpResponseError}
*/
createRequest({ url, method, timeout = this.timeout, query, headers = {}, json = true }, data) {
return __awaiter(this, void 0, void 0, function* () {
const urlWithQuery = url + this.serialize(query);
let resType;

@@ -678,3 +684,3 @@ let transformResponse = undefined;

const response = yield axios__default["default"].request({
url: url + this.serialize(query),
url: urlWithQuery,
method: method !== null && method !== void 0 ? method : 'GET',

@@ -699,6 +705,6 @@ headers: headers,

}
throw new HttpResponseError(`Http error response: (${err.response.status}) ${errorData}`, err.response.status, err.response.statusText, errorData, url + this.serialize(query));
throw new HttpResponseError(`Http error response: (${err.response.status}) ${errorData}`, err.response.status, err.response.statusText, errorData, urlWithQuery);
}
else {
throw new HttpRequestFailed(`${method} ${url + this.serialize(query)} ${String(err)}`);
throw new HttpRequestFailed(String(method), urlWithQuery, err);
}

@@ -705,0 +711,0 @@ }

@@ -5,5 +5,5 @@ /**

*/
import { STATUS_CODE } from './status_code';
export * from './status_code';
export { VERSION } from './version';
export { HttpRequestFailed, HttpResponseError } from './errors';
declare type ObjectType = Record<string, any>;

@@ -21,24 +21,2 @@ export interface HttpRequestOptions {

}
/**
* @category Error
* @description This error will be thrown when the endpoint returns an HTTP error to the client
*/
export declare class HttpResponseError extends Error {
message: string;
status: STATUS_CODE;
statusText: string;
body: string;
url: string;
name: string;
constructor(message: string, status: STATUS_CODE, statusText: string, body: string, url: string);
}
/**
* @category Error
* @description Error that indicates a general failure in making the HTTP request
*/
export declare class HttpRequestFailed extends Error {
message: string;
name: string;
constructor(message: string);
}
export declare class HttpBackend {

@@ -51,4 +29,5 @@ private timeout;

* @param options contains options to be passed for the HTTP request (url, method and timeout)
* @throws {@link HttpRequestFailed} | {@link HttpResponseError}
*/
createRequest<T>({ url, method, timeout, query, headers, json }: HttpRequestOptions, data?: object | string): Promise<T>;
}
{
"name": "@taquito/http-utils",
"version": "16.2.0",
"version": "17.0.0-beta-RC.0",
"description": "",

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

"dependencies": {
"@taquito/core": "^17.0.0-beta-RC.0",
"axios": "^0.26.0"

@@ -94,3 +95,3 @@ },

},
"gitHead": "148b11675d2c3d3a10ce20c02dcece388ef59414"
"gitHead": "8acebfdf7b4361533d963eed87f03f8983dc679b"
}

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