@taquito/http-utils 11.0.2 → 11.2.0-beta-RC.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/taquito-http-utils.js +37 -47
- package/dist/lib/taquito-http-utils.js.map +1 -1
- package/dist/lib/version.js +2 -4
- package/dist/lib/version.js.map +1 -1
- package/dist/{taquito-http-utils.es5.js → taquito-http-utils.es6.js} +42 -54
- package/dist/{taquito-http-utils.es5.js.map → taquito-http-utils.es6.js.map} +1 -1
- package/dist/taquito-http-utils.umd.js +41 -53
- package/dist/taquito-http-utils.umd.js.map +1 -1
- package/dist/types/taquito-http-utils.d.ts +3 -4
- package/package.json +20 -20
|
@@ -15,16 +15,15 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.HttpBackend = exports.HttpRequestFailed = exports.HttpResponseError = exports.VERSION = void 0;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
// tslint:enable: strict-type-predicates
|
|
21
|
-
var XMLHttpRequestCTOR = isNode ? require('xhr2-cookies').XMLHttpRequest : XMLHttpRequest;
|
|
18
|
+
const isNode = typeof process !== 'undefined' && process.versions != null && process.versions.node != null;
|
|
19
|
+
const XMLHttpRequestCTOR = isNode ? require('xhr2-cookies').XMLHttpRequest : XMLHttpRequest;
|
|
22
20
|
__exportStar(require("./status_code"), exports);
|
|
23
21
|
var version_1 = require("./version");
|
|
24
22
|
Object.defineProperty(exports, "VERSION", { enumerable: true, get: function () { return version_1.VERSION; } });
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
const defaultTimeout = 30000;
|
|
24
|
+
class HttpResponseError extends Error {
|
|
25
|
+
constructor(message, status, statusText, body, url) {
|
|
26
|
+
super(message);
|
|
28
27
|
this.message = message;
|
|
29
28
|
this.status = status;
|
|
30
29
|
this.statusText = statusText;
|
|
@@ -32,78 +31,70 @@ var HttpResponseError = /** @class */ (function () {
|
|
|
32
31
|
this.url = url;
|
|
33
32
|
this.name = 'HttpResponse';
|
|
34
33
|
}
|
|
35
|
-
|
|
36
|
-
}());
|
|
34
|
+
}
|
|
37
35
|
exports.HttpResponseError = HttpResponseError;
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
class HttpRequestFailed extends Error {
|
|
37
|
+
constructor(url, innerEvent) {
|
|
38
|
+
super(`Request to ${url} failed`);
|
|
40
39
|
this.url = url;
|
|
41
40
|
this.innerEvent = innerEvent;
|
|
42
41
|
this.name = 'HttpRequestFailed';
|
|
43
|
-
this.message = "Request to " + url + " failed";
|
|
44
42
|
}
|
|
45
|
-
|
|
46
|
-
}());
|
|
43
|
+
}
|
|
47
44
|
exports.HttpRequestFailed = HttpRequestFailed;
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
HttpBackend.prototype.serialize = function (obj) {
|
|
45
|
+
class HttpBackend {
|
|
46
|
+
serialize(obj) {
|
|
52
47
|
if (!obj) {
|
|
53
48
|
return '';
|
|
54
49
|
}
|
|
55
|
-
|
|
56
|
-
|
|
50
|
+
const str = [];
|
|
51
|
+
for (const p in obj) {
|
|
52
|
+
// eslint-disable-next-line no-prototype-builtins
|
|
57
53
|
if (obj.hasOwnProperty(p) && typeof obj[p] !== 'undefined') {
|
|
58
|
-
|
|
54
|
+
const prop = typeof obj[p].toJSON === 'function' ? obj[p].toJSON() : obj[p];
|
|
59
55
|
// query arguments can have no value so we need some way of handling that
|
|
60
56
|
// example https://domain.com/query?all
|
|
61
57
|
if (prop === null) {
|
|
62
58
|
str.push(encodeURIComponent(p));
|
|
63
|
-
|
|
59
|
+
continue;
|
|
64
60
|
}
|
|
65
61
|
// another use case is multiple arguments with the same name
|
|
66
62
|
// they are passed as array
|
|
67
63
|
if (Array.isArray(prop)) {
|
|
68
|
-
prop.forEach(
|
|
64
|
+
prop.forEach((item) => {
|
|
69
65
|
str.push(encodeURIComponent(p) + '=' + encodeURIComponent(item));
|
|
70
66
|
});
|
|
71
|
-
|
|
67
|
+
continue;
|
|
72
68
|
}
|
|
73
69
|
str.push(encodeURIComponent(p) + '=' + encodeURIComponent(prop));
|
|
74
70
|
}
|
|
75
|
-
};
|
|
76
|
-
for (var p in obj) {
|
|
77
|
-
_loop_1(p);
|
|
78
71
|
}
|
|
79
|
-
|
|
72
|
+
const serialized = str.join('&');
|
|
80
73
|
if (serialized) {
|
|
81
|
-
return
|
|
74
|
+
return `?${serialized}`;
|
|
82
75
|
}
|
|
83
76
|
else {
|
|
84
77
|
return '';
|
|
85
78
|
}
|
|
86
|
-
}
|
|
87
|
-
|
|
79
|
+
}
|
|
80
|
+
createXHR() {
|
|
88
81
|
return new XMLHttpRequestCTOR();
|
|
89
|
-
}
|
|
82
|
+
}
|
|
90
83
|
/**
|
|
91
84
|
*
|
|
92
85
|
* @param options contains options to be passed for the HTTP request (url, method and timeout)
|
|
93
86
|
*/
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
var request = _this.createXHR();
|
|
99
|
-
request.open(method || 'GET', "" + url + _this.serialize(query));
|
|
87
|
+
createRequest({ url, method, timeout, query, headers = {}, json = true, mimeType = undefined, }, data) {
|
|
88
|
+
return new Promise((resolve, reject) => {
|
|
89
|
+
const request = this.createXHR();
|
|
90
|
+
request.open(method || 'GET', `${url}${this.serialize(query)}`);
|
|
100
91
|
if (!headers['Content-Type']) {
|
|
101
92
|
request.setRequestHeader('Content-Type', 'application/json');
|
|
102
93
|
}
|
|
103
94
|
if (mimeType) {
|
|
104
|
-
request.overrideMimeType(
|
|
95
|
+
request.overrideMimeType(`${mimeType}`);
|
|
105
96
|
}
|
|
106
|
-
for (
|
|
97
|
+
for (const k in headers) {
|
|
107
98
|
request.setRequestHeader(k, headers[k]);
|
|
108
99
|
}
|
|
109
100
|
request.timeout = timeout || defaultTimeout;
|
|
@@ -114,7 +105,7 @@ var HttpBackend = /** @class */ (function () {
|
|
|
114
105
|
resolve(JSON.parse(request.response));
|
|
115
106
|
}
|
|
116
107
|
catch (ex) {
|
|
117
|
-
reject(new Error(
|
|
108
|
+
reject(new Error(`Unable to parse response: ${request.response}`));
|
|
118
109
|
}
|
|
119
110
|
}
|
|
120
111
|
else {
|
|
@@ -122,25 +113,24 @@ var HttpBackend = /** @class */ (function () {
|
|
|
122
113
|
}
|
|
123
114
|
}
|
|
124
115
|
else {
|
|
125
|
-
reject(new HttpResponseError(
|
|
116
|
+
reject(new HttpResponseError(`Http error response: (${this.status}) ${request.response}`, this.status, request.statusText, request.response, url));
|
|
126
117
|
}
|
|
127
118
|
};
|
|
128
119
|
request.ontimeout = function () {
|
|
129
|
-
reject(new Error(
|
|
120
|
+
reject(new Error(`Request timed out after: ${request.timeout}ms`));
|
|
130
121
|
};
|
|
131
122
|
request.onerror = function (err) {
|
|
132
123
|
reject(new HttpRequestFailed(url, err));
|
|
133
124
|
};
|
|
134
125
|
if (data) {
|
|
135
|
-
|
|
126
|
+
const dataStr = JSON.stringify(data);
|
|
136
127
|
request.send(dataStr);
|
|
137
128
|
}
|
|
138
129
|
else {
|
|
139
130
|
request.send();
|
|
140
131
|
}
|
|
141
132
|
});
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
}());
|
|
133
|
+
}
|
|
134
|
+
}
|
|
145
135
|
exports.HttpBackend = HttpBackend;
|
|
146
136
|
//# sourceMappingURL=taquito-http-utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"taquito-http-utils.js","sourceRoot":"","sources":["../../src/taquito-http-utils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;AAIH,
|
|
1
|
+
{"version":3,"file":"taquito-http-utils.js","sourceRoot":"","sources":["../../src/taquito-http-utils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;AAIH,MAAM,MAAM,GACV,OAAO,OAAO,KAAK,WAAW,IAAI,OAAO,CAAC,QAAQ,I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AAC,IAAI,KAAK,CAAC,4BAA4B,OAAO,CAAC,OAAO,IAAI,CAAC,CAAC,CAAC;YACrE,CAAC,CAAC;YAEF,OAAO,CAAC,OAAO,GAAG,UAAU,GAAG;gBAC7B,MAAM,CAAC,IAAI,iBAAiB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;YAC1C,CAAC,CAAC;YAEF,IAAI,IAAI,EAAE;gBACR,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;gBACrC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;aACvB;iBAAM;gBACL,OAAO,CAAC,IAAI,EAAE,CAAC;aAChB;QACH,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AA7GD,kCA6GC"}
|
package/dist/lib/version.js
CHANGED
|
@@ -2,10 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.VERSION = void 0;
|
|
4
4
|
// IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
|
|
5
|
-
/* tslint:disable */
|
|
6
5
|
exports.VERSION = {
|
|
7
|
-
"commitHash": "
|
|
8
|
-
"version": "11.0.
|
|
6
|
+
"commitHash": "e03d983c780c7f96d8291ddd1251ea82f4581858",
|
|
7
|
+
"version": "11.2.0-beta-RC.0"
|
|
9
8
|
};
|
|
10
|
-
/* tslint:enable */
|
|
11
9
|
//# sourceMappingURL=version.js.map
|
package/dist/lib/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";;;AACA,2EAA2E;
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";;;AACA,2EAA2E;AAC9D,QAAA,OAAO,GAAG;IACnB,YAAY,EAAE,0CAA0C;IACxD,SAAS,EAAE,kBAAkB;CAChC,CAAC"}
|
|
@@ -319,24 +319,21 @@ var STATUS_CODE;
|
|
|
319
319
|
})(STATUS_CODE || (STATUS_CODE = {}));
|
|
320
320
|
|
|
321
321
|
// IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
"
|
|
325
|
-
|
|
326
|
-
};
|
|
327
|
-
/* tslint:enable */
|
|
322
|
+
const VERSION = {
|
|
323
|
+
"commitHash": "e03d983c780c7f96d8291ddd1251ea82f4581858",
|
|
324
|
+
"version": "11.2.0-beta-RC.0"
|
|
325
|
+
};
|
|
328
326
|
|
|
329
327
|
/**
|
|
330
328
|
* @packageDocumentation
|
|
331
329
|
* @module @taquito/http-utils
|
|
332
330
|
*/
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
function HttpResponseError(message, status, statusText, body, url) {
|
|
331
|
+
const isNode = typeof process !== 'undefined' && process.versions != null && process.versions.node != null;
|
|
332
|
+
const XMLHttpRequestCTOR = isNode ? require('xhr2-cookies').XMLHttpRequest : XMLHttpRequest;
|
|
333
|
+
const defaultTimeout = 30000;
|
|
334
|
+
class HttpResponseError extends Error {
|
|
335
|
+
constructor(message, status, statusText, body, url) {
|
|
336
|
+
super(message);
|
|
340
337
|
this.message = message;
|
|
341
338
|
this.status = status;
|
|
342
339
|
this.statusText = statusText;
|
|
@@ -344,76 +341,68 @@ var HttpResponseError = /** @class */ (function () {
|
|
|
344
341
|
this.url = url;
|
|
345
342
|
this.name = 'HttpResponse';
|
|
346
343
|
}
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
344
|
+
}
|
|
345
|
+
class HttpRequestFailed extends Error {
|
|
346
|
+
constructor(url, innerEvent) {
|
|
347
|
+
super(`Request to ${url} failed`);
|
|
351
348
|
this.url = url;
|
|
352
349
|
this.innerEvent = innerEvent;
|
|
353
350
|
this.name = 'HttpRequestFailed';
|
|
354
|
-
this.message = "Request to " + url + " failed";
|
|
355
351
|
}
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
function HttpBackend() {
|
|
360
|
-
}
|
|
361
|
-
HttpBackend.prototype.serialize = function (obj) {
|
|
352
|
+
}
|
|
353
|
+
class HttpBackend {
|
|
354
|
+
serialize(obj) {
|
|
362
355
|
if (!obj) {
|
|
363
356
|
return '';
|
|
364
357
|
}
|
|
365
|
-
|
|
366
|
-
|
|
358
|
+
const str = [];
|
|
359
|
+
for (const p in obj) {
|
|
360
|
+
// eslint-disable-next-line no-prototype-builtins
|
|
367
361
|
if (obj.hasOwnProperty(p) && typeof obj[p] !== 'undefined') {
|
|
368
|
-
|
|
362
|
+
const prop = typeof obj[p].toJSON === 'function' ? obj[p].toJSON() : obj[p];
|
|
369
363
|
// query arguments can have no value so we need some way of handling that
|
|
370
364
|
// example https://domain.com/query?all
|
|
371
365
|
if (prop === null) {
|
|
372
366
|
str.push(encodeURIComponent(p));
|
|
373
|
-
|
|
367
|
+
continue;
|
|
374
368
|
}
|
|
375
369
|
// another use case is multiple arguments with the same name
|
|
376
370
|
// they are passed as array
|
|
377
371
|
if (Array.isArray(prop)) {
|
|
378
|
-
prop.forEach(
|
|
372
|
+
prop.forEach((item) => {
|
|
379
373
|
str.push(encodeURIComponent(p) + '=' + encodeURIComponent(item));
|
|
380
374
|
});
|
|
381
|
-
|
|
375
|
+
continue;
|
|
382
376
|
}
|
|
383
377
|
str.push(encodeURIComponent(p) + '=' + encodeURIComponent(prop));
|
|
384
378
|
}
|
|
385
|
-
};
|
|
386
|
-
for (var p in obj) {
|
|
387
|
-
_loop_1(p);
|
|
388
379
|
}
|
|
389
|
-
|
|
380
|
+
const serialized = str.join('&');
|
|
390
381
|
if (serialized) {
|
|
391
|
-
return
|
|
382
|
+
return `?${serialized}`;
|
|
392
383
|
}
|
|
393
384
|
else {
|
|
394
385
|
return '';
|
|
395
386
|
}
|
|
396
|
-
}
|
|
397
|
-
|
|
387
|
+
}
|
|
388
|
+
createXHR() {
|
|
398
389
|
return new XMLHttpRequestCTOR();
|
|
399
|
-
}
|
|
390
|
+
}
|
|
400
391
|
/**
|
|
401
392
|
*
|
|
402
393
|
* @param options contains options to be passed for the HTTP request (url, method and timeout)
|
|
403
394
|
*/
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
var request = _this.createXHR();
|
|
409
|
-
request.open(method || 'GET', "" + url + _this.serialize(query));
|
|
395
|
+
createRequest({ url, method, timeout, query, headers = {}, json = true, mimeType = undefined, }, data) {
|
|
396
|
+
return new Promise((resolve, reject) => {
|
|
397
|
+
const request = this.createXHR();
|
|
398
|
+
request.open(method || 'GET', `${url}${this.serialize(query)}`);
|
|
410
399
|
if (!headers['Content-Type']) {
|
|
411
400
|
request.setRequestHeader('Content-Type', 'application/json');
|
|
412
401
|
}
|
|
413
402
|
if (mimeType) {
|
|
414
|
-
request.overrideMimeType(
|
|
403
|
+
request.overrideMimeType(`${mimeType}`);
|
|
415
404
|
}
|
|
416
|
-
for (
|
|
405
|
+
for (const k in headers) {
|
|
417
406
|
request.setRequestHeader(k, headers[k]);
|
|
418
407
|
}
|
|
419
408
|
request.timeout = timeout || defaultTimeout;
|
|
@@ -424,7 +413,7 @@ var HttpBackend = /** @class */ (function () {
|
|
|
424
413
|
resolve(JSON.parse(request.response));
|
|
425
414
|
}
|
|
426
415
|
catch (ex) {
|
|
427
|
-
reject(new Error(
|
|
416
|
+
reject(new Error(`Unable to parse response: ${request.response}`));
|
|
428
417
|
}
|
|
429
418
|
}
|
|
430
419
|
else {
|
|
@@ -432,26 +421,25 @@ var HttpBackend = /** @class */ (function () {
|
|
|
432
421
|
}
|
|
433
422
|
}
|
|
434
423
|
else {
|
|
435
|
-
reject(new HttpResponseError(
|
|
424
|
+
reject(new HttpResponseError(`Http error response: (${this.status}) ${request.response}`, this.status, request.statusText, request.response, url));
|
|
436
425
|
}
|
|
437
426
|
};
|
|
438
427
|
request.ontimeout = function () {
|
|
439
|
-
reject(new Error(
|
|
428
|
+
reject(new Error(`Request timed out after: ${request.timeout}ms`));
|
|
440
429
|
};
|
|
441
430
|
request.onerror = function (err) {
|
|
442
431
|
reject(new HttpRequestFailed(url, err));
|
|
443
432
|
};
|
|
444
433
|
if (data) {
|
|
445
|
-
|
|
434
|
+
const dataStr = JSON.stringify(data);
|
|
446
435
|
request.send(dataStr);
|
|
447
436
|
}
|
|
448
437
|
else {
|
|
449
438
|
request.send();
|
|
450
439
|
}
|
|
451
440
|
});
|
|
452
|
-
}
|
|
453
|
-
|
|
454
|
-
}());
|
|
441
|
+
}
|
|
442
|
+
}
|
|
455
443
|
|
|
456
444
|
export { HttpBackend, HttpRequestFailed, HttpResponseError, STATUS_CODE, VERSION };
|
|
457
|
-
//# sourceMappingURL=taquito-http-utils.
|
|
445
|
+
//# sourceMappingURL=taquito-http-utils.es6.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"taquito-http-utils.es5.js","sources":["../src/status_code.ts","../src/version.ts","../src/taquito-http-utils.ts"],"sourcesContent":["/**\n * Hypertext Transfer Protocol (HTTP) response status codes.\n * @see {@link https://en.wikipedia.org/wiki/List_of_HTTP_status_codes}\n */\nexport enum STATUS_CODE {\n /**\n * The server has received the request headers and the client should proceed to send the request body\n * (in the case of a request for which a body needs to be sent; for example, a POST request).\n * Sending a large request body to a server after a request has been rejected for inappropriate headers would be inefficient.\n * To have a server check the request's headers, a client must send Expect: 100-continue as a header in its initial request\n * and receive a 100 Continue status code in response before sending the body. The response 417 Expectation Failed indicates the request should not be continued.\n */\n CONTINUE = 100,\n\n /**\n * The requester has asked the server to switch protocols and the server has agreed to do so.\n */\n SWITCHING_PROTOCOLS = 101,\n\n /**\n * A WebDAV request may contain many sub-requests involving file operations, requiring a long time to complete the request.\n * This code indicates that the server has received and is processing the request, but no response is available yet.\n * This prevents the client from timing out and assuming the request was lost.\n */\n PROCESSING = 102,\n\n /**\n * Standard response for successful HTTP requests.\n * The actual response will depend on the request method used.\n * In a GET request, the response will contain an entity corresponding to the requested resource.\n * In a POST request, the response will contain an entity describing or containing the result of the action.\n */\n OK = 200,\n\n /**\n * The request has been fulfilled, resulting in the creation of a new resource.\n */\n CREATED = 201,\n\n /**\n * The request has been accepted for processing, but the processing has not been completed.\n * The request might or might not be eventually acted upon, and may be disallowed when processing occurs.\n */\n ACCEPTED = 202,\n\n /**\n * SINCE HTTP/1.1\n * The server is a transforming proxy that received a 200 OK from its origin,\n * but is returning a modified version of the origin's response.\n */\n NON_AUTHORITATIVE_INFORMATION = 203,\n\n /**\n * The server successfully processed the request and is not returning any content.\n */\n NO_CONTENT = 204,\n\n /**\n * The server successfully processed the request, but is not returning any content.\n * Unlike a 204 response, this response requires that the requester reset the document view.\n */\n RESET_CONTENT = 205,\n\n /**\n * The server is delivering only part of the resource (byte serving) due to a range header sent by the client.\n * The range header is used by HTTP clients to enable resuming of interrupted downloads,\n * or split a download into multiple simultaneous streams.\n */\n PARTIAL_CONTENT = 206,\n\n /**\n * The message body that follows is an XML message and can contain a number of separate response codes,\n * depending on how many sub-requests were made.\n */\n MULTI_STATUS = 207,\n\n /**\n * The members of a DAV binding have already been enumerated in a preceding part of the (multistatus) response,\n * and are not being included again.\n */\n ALREADY_REPORTED = 208,\n\n /**\n * The server has fulfilled a request for the resource,\n * and the response is a representation of the result of one or more instance-manipulations applied to the current instance.\n */\n IM_USED = 226,\n\n /**\n * Indicates multiple options for the resource from which the client may choose (via agent-driven content negotiation).\n * For example, this code could be used to present multiple video format options,\n * to list files with different filename extensions, or to suggest word-sense disambiguation.\n */\n MULTIPLE_CHOICES = 300,\n\n /**\n * This and all future requests should be directed to the given URI.\n */\n MOVED_PERMANENTLY = 301,\n\n /**\n * This is an example of industry practice contradicting the standard.\n * The HTTP/1.0 specification (RFC 1945) required the client to perform a temporary redirect\n * (the original describing phrase was \"Moved Temporarily\"), but popular browsers implemented 302\n * with the functionality of a 303 See Other. Therefore, HTTP/1.1 added status codes 303 and 307\n * to distinguish between the two behaviours. However, some Web applications and frameworks\n * use the 302 status code as if it were the 303.\n */\n FOUND = 302,\n\n /**\n * SINCE HTTP/1.1\n * The response to the request can be found under another URI using a GET method.\n * When received in response to a POST (or PUT/DELETE), the client should presume that\n * the server has received the data and should issue a redirect with a separate GET message.\n */\n SEE_OTHER = 303,\n\n /**\n * Indicates that the resource has not been modified since the version specified by the request headers If-Modified-Since or If-None-Match.\n * In such case, there is no need to retransmit the resource since the client still has a previously-downloaded copy.\n */\n NOT_MODIFIED = 304,\n\n /**\n * SINCE HTTP/1.1\n * The requested resource is available only through a proxy, the address for which is provided in the response.\n * Many HTTP clients (such as Mozilla and Internet Explorer) do not correctly handle responses with this status code, primarily for security reasons.\n */\n USE_PROXY = 305,\n\n /**\n * No longer used. Originally meant \"Subsequent requests should use the specified proxy.\"\n */\n SWITCH_PROXY = 306,\n\n /**\n * SINCE HTTP/1.1\n * In this case, the request should be repeated with another URI; however, future requests should still use the original URI.\n * In contrast to how 302 was historically implemented, the request method is not allowed to be changed when reissuing the original request.\n * For example, a POST request should be repeated using another POST request.\n */\n TEMPORARY_REDIRECT = 307,\n\n /**\n * The request and all future requests should be repeated using another URI.\n * 307 and 308 parallel the behaviors of 302 and 301, but do not allow the HTTP method to change.\n * So, for example, submitting a form to a permanently redirected resource may continue smoothly.\n */\n PERMANENT_REDIRECT = 308,\n\n /**\n * The server cannot or will not process the request due to an apparent client error\n * (e.g., malformed request syntax, too large size, invalid request message framing, or deceptive request routing).\n */\n BAD_REQUEST = 400,\n\n /**\n * Similar to 403 Forbidden, but specifically for use when authentication is required and has failed or has not yet\n * been provided. The response must include a WWW-Authenticate header field containing a challenge applicable to the\n * requested resource. See Basic access authentication and Digest access authentication. 401 semantically means\n * \"unauthenticated\",i.e. the user does not have the necessary credentials.\n */\n UNAUTHORIZED = 401,\n\n /**\n * Reserved for future use. The original intention was that this code might be used as part of some form of digital\n * cash or micro payment scheme, but that has not happened, and this code is not usually used.\n * Google Developers API uses this status if a particular developer has exceeded the daily limit on requests.\n */\n PAYMENT_REQUIRED = 402,\n\n /**\n * The request was valid, but the server is refusing action.\n * The user might not have the necessary permissions for a resource.\n */\n FORBIDDEN = 403,\n\n /**\n * The requested resource could not be found but may be available in the future.\n * Subsequent requests by the client are permissible.\n */\n NOT_FOUND = 404,\n\n /**\n * A request method is not supported for the requested resource;\n * for example, a GET request on a form that requires data to be presented via POST, or a PUT request on a read-only resource.\n */\n METHOD_NOT_ALLOWED = 405,\n\n /**\n * The requested resource is capable of generating only content not acceptable according to the Accept headers sent in the request.\n */\n NOT_ACCEPTABLE = 406,\n\n /**\n * The client must first authenticate itself with the proxy.\n */\n PROXY_AUTHENTICATION_REQUIRED = 407,\n\n /**\n * The server timed out waiting for the request.\n * According to HTTP specifications:\n * \"The client did not produce a request within the time that the server was prepared to wait. The client MAY repeat the request without modifications at any later time.\"\n */\n REQUEST_TIMEOUT = 408,\n\n /**\n * Indicates that the request could not be processed because of conflict in the request,\n * such as an edit conflict between multiple simultaneous updates.\n */\n CONFLICT = 409,\n\n /**\n * Indicates that the resource requested is no longer available and will not be available again.\n * This should be used when a resource has been intentionally removed and the resource should be purged.\n * Upon receiving a 410 status code, the client should not request the resource in the future.\n * Clients such as search engines should remove the resource from their indices.\n * Most use cases do not require clients and search engines to purge the resource, and a \"404 Not Found\" may be used instead.\n */\n GONE = 410,\n\n /**\n * The request did not specify the length of its content, which is required by the requested resource.\n */\n LENGTH_REQUIRED = 411,\n\n /**\n * The server does not meet one of the preconditions that the requester put on the request.\n */\n PRECONDITION_FAILED = 412,\n\n /**\n * The request is larger than the server is willing or able to process. Previously called \"Request Entity Too Large\".\n */\n PAYLOAD_TOO_LARGE = 413,\n\n /**\n * The URI provided was too long for the server to process. Often the result of too much data being encoded as a query-string of a GET request,\n * in which case it should be converted to a POST request.\n * Called \"Request-URI Too Long\" previously.\n */\n URI_TOO_LONG = 414,\n\n /**\n * The request entity has a media type which the server or resource does not support.\n * For example, the client uploads an image as image/svg+xml, but the server requires that images use a different format.\n */\n UNSUPPORTED_MEDIA_TYPE = 415,\n\n /**\n * The client has asked for a portion of the file (byte serving), but the server cannot supply that portion.\n * For example, if the client asked for a part of the file that lies beyond the end of the file.\n * Called \"Requested Range Not Satisfiable\" previously.\n */\n RANGE_NOT_SATISFIABLE = 416,\n\n /**\n * The server cannot meet the requirements of the Expect request-header field.\n */\n EXPECTATION_FAILED = 417,\n\n /**\n * This code was defined in 1998 as one of the traditional IETF April Fools' jokes, in RFC 2324, Hyper Text Coffee Pot Control Protocol,\n * and is not expected to be implemented by actual HTTP servers. The RFC specifies this code should be returned by\n * teapots requested to brew coffee. This HTTP status is used as an Easter egg in some websites, including Google.com.\n */\n I_AM_A_TEAPOT = 418,\n\n /**\n * The request was directed at a server that is not able to produce a response (for example because a connection reuse).\n */\n MISDIRECTED_REQUEST = 421,\n\n /**\n * The request was well-formed but was unable to be followed due to semantic errors.\n */\n UNPROCESSABLE_ENTITY = 422,\n\n /**\n * The resource that is being accessed is locked.\n */\n LOCKED = 423,\n\n /**\n * The request failed due to failure of a previous request (e.g., a PROPPATCH).\n */\n FAILED_DEPENDENCY = 424,\n\n /**\n * The client should switch to a different protocol such as TLS/1.0, given in the Upgrade header field.\n */\n UPGRADE_REQUIRED = 426,\n\n /**\n * The origin server requires the request to be conditional.\n * Intended to prevent \"the 'lost update' problem, where a client\n * GETs a resource's state, modifies it, and PUTs it back to the server,\n * when meanwhile a third party has modified the state on the server, leading to a conflict.\"\n */\n PRECONDITION_REQUIRED = 428,\n\n /**\n * The user has sent too many requests in a given amount of time. Intended for use with rate-limiting schemes.\n */\n TOO_MANY_REQUESTS = 429,\n\n /**\n * The server is unwilling to process the request because either an individual header field,\n * or all the header fields collectively, are too large.\n */\n REQUEST_HEADER_FIELDS_TOO_LARGE = 431,\n\n /**\n * A server operator has received a legal demand to deny access to a resource or to a set of resources\n * that includes the requested resource. The code 451 was chosen as a reference to the novel Fahrenheit 451.\n */\n UNAVAILABLE_FOR_LEGAL_REASONS = 451,\n\n /**\n * A generic error message, given when an unexpected condition was encountered and no more specific message is suitable.\n */\n INTERNAL_SERVER_ERROR = 500,\n\n /**\n * The server either does not recognize the request method, or it lacks the ability to fulfill the request.\n * Usually this implies future availability (e.g., a new feature of a web-service API).\n */\n NOT_IMPLEMENTED = 501,\n\n /**\n * The server was acting as a gateway or proxy and received an invalid response from the upstream server.\n */\n BAD_GATEWAY = 502,\n\n /**\n * The server is currently unavailable (because it is overloaded or down for maintenance).\n * Generally, this is a temporary state.\n */\n SERVICE_UNAVAILABLE = 503,\n\n /**\n * The server was acting as a gateway or proxy and did not receive a timely response from the upstream server.\n */\n GATEWAY_TIMEOUT = 504,\n\n /**\n * The server does not support the HTTP protocol version used in the request\n */\n HTTP_VERSION_NOT_SUPPORTED = 505,\n\n /**\n * Transparent content negotiation for the request results in a circular reference.\n */\n VARIANT_ALSO_NEGOTIATES = 506,\n\n /**\n * The server is unable to store the representation needed to complete the request.\n */\n INSUFFICIENT_STORAGE = 507,\n\n /**\n * The server detected an infinite loop while processing the request.\n */\n LOOP_DETECTED = 508,\n\n /**\n * Further extensions to the request are required for the server to fulfill it.\n */\n NOT_EXTENDED = 510,\n\n /**\n * The client needs to authenticate to gain network access.\n * Intended for use by intercepting proxies used to control access to the network (e.g., \"captive portals\" used\n * to require agreement to Terms of Service before granting full Internet access via a Wi-Fi hotspot).\n */\n NETWORK_AUTHENTICATION_REQUIRED = 511,\n}\n","\n// IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!\n/* tslint:disable */\nexport const VERSION = {\n \"commitHash\": \"e4fb2f0ab9a459640e474bf65ae4578f4b948c63\",\n \"version\": \"11.0.2\"\n};\n/* tslint:enable */\n","/**\n * @packageDocumentation\n * @module @taquito/http-utils\n */\n\nimport { STATUS_CODE } from './status_code';\n\n// tslint:disable: strict-type-predicates\nconst isNode =\n typeof process !== 'undefined' && process.versions != null && process.versions.node != null;\n// tslint:enable: strict-type-predicates\n\nconst XMLHttpRequestCTOR = isNode ? require('xhr2-cookies').XMLHttpRequest : XMLHttpRequest;\n\nexport * from './status_code';\nexport { VERSION } from './version';\n\nconst defaultTimeout = 30000;\n\nexport interface HttpRequestOptions {\n url: string;\n method?: 'GET' | 'POST';\n timeout?: number;\n json?: boolean;\n query?: { [key: string]: any };\n headers?: { [key: string]: string };\n mimeType?: string;\n}\n\nexport class HttpResponseError implements Error {\n public name = 'HttpResponse';\n\n constructor(\n public message: string,\n public status: STATUS_CODE,\n public statusText: string,\n public body: string,\n public url: string\n ) {}\n}\n\nexport class HttpRequestFailed implements Error {\n public name = 'HttpRequestFailed';\n public message: string;\n\n constructor(public url: string, public innerEvent: any) {\n this.message = `Request to ${url} failed`;\n }\n}\n\nexport class HttpBackend {\n protected serialize(obj?: { [key: string]: any }) {\n if (!obj) {\n return '';\n }\n\n const str = [];\n for (const p in obj) {\n if (obj.hasOwnProperty(p) && typeof obj[p] !== 'undefined') {\n const prop = typeof obj[p].toJSON === 'function' ? obj[p].toJSON() : obj[p];\n // query arguments can have no value so we need some way of handling that\n // example https://domain.com/query?all\n if (prop === null) {\n str.push(encodeURIComponent(p));\n continue;\n }\n // another use case is multiple arguments with the same name\n // they are passed as array\n if (Array.isArray(prop)) {\n prop.forEach((item) => {\n str.push(encodeURIComponent(p) + '=' + encodeURIComponent(item));\n });\n continue;\n }\n str.push(encodeURIComponent(p) + '=' + encodeURIComponent(prop));\n }\n }\n const serialized = str.join('&');\n if (serialized) {\n return `?${serialized}`;\n } else {\n return '';\n }\n }\n\n protected createXHR(): XMLHttpRequest {\n return new XMLHttpRequestCTOR();\n }\n\n /**\n *\n * @param options contains options to be passed for the HTTP request (url, method and timeout)\n */\n createRequest<T>(\n {\n url,\n method,\n timeout,\n query,\n headers = {},\n json = true,\n mimeType = undefined,\n }: HttpRequestOptions,\n data?: {}\n ) {\n return new Promise<T>((resolve, reject) => {\n const request = this.createXHR();\n request.open(method || 'GET', `${url}${this.serialize(query)}`);\n if (!headers['Content-Type']) {\n request.setRequestHeader('Content-Type', 'application/json');\n }\n if (mimeType) {\n request.overrideMimeType(`${mimeType}`);\n }\n for (const k in headers) {\n request.setRequestHeader(k, headers[k]);\n }\n request.timeout = timeout || defaultTimeout;\n request.onload = function () {\n if (this.status >= 200 && this.status < 300) {\n if (json) {\n try {\n resolve(JSON.parse(request.response));\n } catch (ex) {\n reject(new Error(`Unable to parse response: ${request.response}`));\n }\n } else {\n resolve(request.response);\n }\n } else {\n reject(\n new HttpResponseError(\n `Http error response: (${this.status}) ${request.response}`,\n this.status as STATUS_CODE,\n request.statusText,\n request.response,\n url\n )\n );\n }\n };\n\n request.ontimeout = function () {\n reject(new Error(`Request timed out after: ${request.timeout}ms`));\n };\n\n request.onerror = function (err) {\n reject(new HttpRequestFailed(url, err));\n };\n\n if (data) {\n const dataStr = JSON.stringify(data);\n request.send(dataStr);\n } else {\n request.send();\n }\n });\n }\n}\n"],"names":[],"mappings":"AAAA;;;;IAIY;AAAZ,WAAY,WAAW;;;;;;;;IAQrB,uDAAc,CAAA;;;;IAKd,6EAAyB,CAAA;;;;;;IAOzB,2DAAgB,CAAA;;;;;;;IAQhB,2CAAQ,CAAA;;;;IAKR,qDAAa,CAAA;;;;;IAMb,uDAAc,CAAA;;;;;;IAOd,iGAAmC,CAAA;;;;IAKnC,2DAAgB,CAAA;;;;;IAMhB,iEAAmB,CAAA;;;;;;IAOnB,qEAAqB,CAAA;;;;;IAMrB,+DAAkB,CAAA;;;;;IAMlB,uEAAsB,CAAA;;;;;IAMtB,qDAAa,CAAA;;;;;;IAOb,uEAAsB,CAAA;;;;IAKtB,yEAAuB,CAAA;;;;;;;;;IAUvB,iDAAW,CAAA;;;;;;;IAQX,yDAAe,CAAA;;;;;IAMf,+DAAkB,CAAA;;;;;;IAOlB,yDAAe,CAAA;;;;IAKf,+DAAkB,CAAA;;;;;;;IAQlB,2EAAwB,CAAA;;;;;;IAOxB,2EAAwB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C;aACzC,CAAC;YAEF,IAAI,IAAI,EAAE;gBACR,IAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;gBACrC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;aACvB;iBAAM;gBACL,OAAO,CAAC,IAAI,EAAE,CAAC;aAChB;SACF,CAAC,CAAC;KACJ;IACH,kBAAC;AAAD,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"taquito-http-utils.es6.js","sources":["../src/status_code.ts","../src/version.ts","../src/taquito-http-utils.ts"],"sourcesContent":["/**\n * Hypertext Transfer Protocol (HTTP) response status codes.\n * @see {@link https://en.wikipedia.org/wiki/List_of_HTTP_status_codes}\n */\nexport enum STATUS_CODE {\n /**\n * The server has received the request headers and the client should proceed to send the request body\n * (in the case of a request for which a body needs to be sent; for example, a POST request).\n * Sending a large request body to a server after a request has been rejected for inappropriate headers would be inefficient.\n * To have a server check the request's headers, a client must send Expect: 100-continue as a header in its initial request\n * and receive a 100 Continue status code in response before sending the body. The response 417 Expectation Failed indicates the request should not be continued.\n */\n CONTINUE = 100,\n\n /**\n * The requester has asked the server to switch protocols and the server has agreed to do so.\n */\n SWITCHING_PROTOCOLS = 101,\n\n /**\n * A WebDAV request may contain many sub-requests involving file operations, requiring a long time to complete the request.\n * This code indicates that the server has received and is processing the request, but no response is available yet.\n * This prevents the client from timing out and assuming the request was lost.\n */\n PROCESSING = 102,\n\n /**\n * Standard response for successful HTTP requests.\n * The actual response will depend on the request method used.\n * In a GET request, the response will contain an entity corresponding to the requested resource.\n * In a POST request, the response will contain an entity describing or containing the result of the action.\n */\n OK = 200,\n\n /**\n * The request has been fulfilled, resulting in the creation of a new resource.\n */\n CREATED = 201,\n\n /**\n * The request has been accepted for processing, but the processing has not been completed.\n * The request might or might not be eventually acted upon, and may be disallowed when processing occurs.\n */\n ACCEPTED = 202,\n\n /**\n * SINCE HTTP/1.1\n * The server is a transforming proxy that received a 200 OK from its origin,\n * but is returning a modified version of the origin's response.\n */\n NON_AUTHORITATIVE_INFORMATION = 203,\n\n /**\n * The server successfully processed the request and is not returning any content.\n */\n NO_CONTENT = 204,\n\n /**\n * The server successfully processed the request, but is not returning any content.\n * Unlike a 204 response, this response requires that the requester reset the document view.\n */\n RESET_CONTENT = 205,\n\n /**\n * The server is delivering only part of the resource (byte serving) due to a range header sent by the client.\n * The range header is used by HTTP clients to enable resuming of interrupted downloads,\n * or split a download into multiple simultaneous streams.\n */\n PARTIAL_CONTENT = 206,\n\n /**\n * The message body that follows is an XML message and can contain a number of separate response codes,\n * depending on how many sub-requests were made.\n */\n MULTI_STATUS = 207,\n\n /**\n * The members of a DAV binding have already been enumerated in a preceding part of the (multistatus) response,\n * and are not being included again.\n */\n ALREADY_REPORTED = 208,\n\n /**\n * The server has fulfilled a request for the resource,\n * and the response is a representation of the result of one or more instance-manipulations applied to the current instance.\n */\n IM_USED = 226,\n\n /**\n * Indicates multiple options for the resource from which the client may choose (via agent-driven content negotiation).\n * For example, this code could be used to present multiple video format options,\n * to list files with different filename extensions, or to suggest word-sense disambiguation.\n */\n MULTIPLE_CHOICES = 300,\n\n /**\n * This and all future requests should be directed to the given URI.\n */\n MOVED_PERMANENTLY = 301,\n\n /**\n * This is an example of industry practice contradicting the standard.\n * The HTTP/1.0 specification (RFC 1945) required the client to perform a temporary redirect\n * (the original describing phrase was \"Moved Temporarily\"), but popular browsers implemented 302\n * with the functionality of a 303 See Other. Therefore, HTTP/1.1 added status codes 303 and 307\n * to distinguish between the two behaviours. However, some Web applications and frameworks\n * use the 302 status code as if it were the 303.\n */\n FOUND = 302,\n\n /**\n * SINCE HTTP/1.1\n * The response to the request can be found under another URI using a GET method.\n * When received in response to a POST (or PUT/DELETE), the client should presume that\n * the server has received the data and should issue a redirect with a separate GET message.\n */\n SEE_OTHER = 303,\n\n /**\n * Indicates that the resource has not been modified since the version specified by the request headers If-Modified-Since or If-None-Match.\n * In such case, there is no need to retransmit the resource since the client still has a previously-downloaded copy.\n */\n NOT_MODIFIED = 304,\n\n /**\n * SINCE HTTP/1.1\n * The requested resource is available only through a proxy, the address for which is provided in the response.\n * Many HTTP clients (such as Mozilla and Internet Explorer) do not correctly handle responses with this status code, primarily for security reasons.\n */\n USE_PROXY = 305,\n\n /**\n * No longer used. Originally meant \"Subsequent requests should use the specified proxy.\"\n */\n SWITCH_PROXY = 306,\n\n /**\n * SINCE HTTP/1.1\n * In this case, the request should be repeated with another URI; however, future requests should still use the original URI.\n * In contrast to how 302 was historically implemented, the request method is not allowed to be changed when reissuing the original request.\n * For example, a POST request should be repeated using another POST request.\n */\n TEMPORARY_REDIRECT = 307,\n\n /**\n * The request and all future requests should be repeated using another URI.\n * 307 and 308 parallel the behaviors of 302 and 301, but do not allow the HTTP method to change.\n * So, for example, submitting a form to a permanently redirected resource may continue smoothly.\n */\n PERMANENT_REDIRECT = 308,\n\n /**\n * The server cannot or will not process the request due to an apparent client error\n * (e.g., malformed request syntax, too large size, invalid request message framing, or deceptive request routing).\n */\n BAD_REQUEST = 400,\n\n /**\n * Similar to 403 Forbidden, but specifically for use when authentication is required and has failed or has not yet\n * been provided. The response must include a WWW-Authenticate header field containing a challenge applicable to the\n * requested resource. See Basic access authentication and Digest access authentication. 401 semantically means\n * \"unauthenticated\",i.e. the user does not have the necessary credentials.\n */\n UNAUTHORIZED = 401,\n\n /**\n * Reserved for future use. The original intention was that this code might be used as part of some form of digital\n * cash or micro payment scheme, but that has not happened, and this code is not usually used.\n * Google Developers API uses this status if a particular developer has exceeded the daily limit on requests.\n */\n PAYMENT_REQUIRED = 402,\n\n /**\n * The request was valid, but the server is refusing action.\n * The user might not have the necessary permissions for a resource.\n */\n FORBIDDEN = 403,\n\n /**\n * The requested resource could not be found but may be available in the future.\n * Subsequent requests by the client are permissible.\n */\n NOT_FOUND = 404,\n\n /**\n * A request method is not supported for the requested resource;\n * for example, a GET request on a form that requires data to be presented via POST, or a PUT request on a read-only resource.\n */\n METHOD_NOT_ALLOWED = 405,\n\n /**\n * The requested resource is capable of generating only content not acceptable according to the Accept headers sent in the request.\n */\n NOT_ACCEPTABLE = 406,\n\n /**\n * The client must first authenticate itself with the proxy.\n */\n PROXY_AUTHENTICATION_REQUIRED = 407,\n\n /**\n * The server timed out waiting for the request.\n * According to HTTP specifications:\n * \"The client did not produce a request within the time that the server was prepared to wait. The client MAY repeat the request without modifications at any later time.\"\n */\n REQUEST_TIMEOUT = 408,\n\n /**\n * Indicates that the request could not be processed because of conflict in the request,\n * such as an edit conflict between multiple simultaneous updates.\n */\n CONFLICT = 409,\n\n /**\n * Indicates that the resource requested is no longer available and will not be available again.\n * This should be used when a resource has been intentionally removed and the resource should be purged.\n * Upon receiving a 410 status code, the client should not request the resource in the future.\n * Clients such as search engines should remove the resource from their indices.\n * Most use cases do not require clients and search engines to purge the resource, and a \"404 Not Found\" may be used instead.\n */\n GONE = 410,\n\n /**\n * The request did not specify the length of its content, which is required by the requested resource.\n */\n LENGTH_REQUIRED = 411,\n\n /**\n * The server does not meet one of the preconditions that the requester put on the request.\n */\n PRECONDITION_FAILED = 412,\n\n /**\n * The request is larger than the server is willing or able to process. Previously called \"Request Entity Too Large\".\n */\n PAYLOAD_TOO_LARGE = 413,\n\n /**\n * The URI provided was too long for the server to process. Often the result of too much data being encoded as a query-string of a GET request,\n * in which case it should be converted to a POST request.\n * Called \"Request-URI Too Long\" previously.\n */\n URI_TOO_LONG = 414,\n\n /**\n * The request entity has a media type which the server or resource does not support.\n * For example, the client uploads an image as image/svg+xml, but the server requires that images use a different format.\n */\n UNSUPPORTED_MEDIA_TYPE = 415,\n\n /**\n * The client has asked for a portion of the file (byte serving), but the server cannot supply that portion.\n * For example, if the client asked for a part of the file that lies beyond the end of the file.\n * Called \"Requested Range Not Satisfiable\" previously.\n */\n RANGE_NOT_SATISFIABLE = 416,\n\n /**\n * The server cannot meet the requirements of the Expect request-header field.\n */\n EXPECTATION_FAILED = 417,\n\n /**\n * This code was defined in 1998 as one of the traditional IETF April Fools' jokes, in RFC 2324, Hyper Text Coffee Pot Control Protocol,\n * and is not expected to be implemented by actual HTTP servers. The RFC specifies this code should be returned by\n * teapots requested to brew coffee. This HTTP status is used as an Easter egg in some websites, including Google.com.\n */\n I_AM_A_TEAPOT = 418,\n\n /**\n * The request was directed at a server that is not able to produce a response (for example because a connection reuse).\n */\n MISDIRECTED_REQUEST = 421,\n\n /**\n * The request was well-formed but was unable to be followed due to semantic errors.\n */\n UNPROCESSABLE_ENTITY = 422,\n\n /**\n * The resource that is being accessed is locked.\n */\n LOCKED = 423,\n\n /**\n * The request failed due to failure of a previous request (e.g., a PROPPATCH).\n */\n FAILED_DEPENDENCY = 424,\n\n /**\n * The client should switch to a different protocol such as TLS/1.0, given in the Upgrade header field.\n */\n UPGRADE_REQUIRED = 426,\n\n /**\n * The origin server requires the request to be conditional.\n * Intended to prevent \"the 'lost update' problem, where a client\n * GETs a resource's state, modifies it, and PUTs it back to the server,\n * when meanwhile a third party has modified the state on the server, leading to a conflict.\"\n */\n PRECONDITION_REQUIRED = 428,\n\n /**\n * The user has sent too many requests in a given amount of time. Intended for use with rate-limiting schemes.\n */\n TOO_MANY_REQUESTS = 429,\n\n /**\n * The server is unwilling to process the request because either an individual header field,\n * or all the header fields collectively, are too large.\n */\n REQUEST_HEADER_FIELDS_TOO_LARGE = 431,\n\n /**\n * A server operator has received a legal demand to deny access to a resource or to a set of resources\n * that includes the requested resource. The code 451 was chosen as a reference to the novel Fahrenheit 451.\n */\n UNAVAILABLE_FOR_LEGAL_REASONS = 451,\n\n /**\n * A generic error message, given when an unexpected condition was encountered and no more specific message is suitable.\n */\n INTERNAL_SERVER_ERROR = 500,\n\n /**\n * The server either does not recognize the request method, or it lacks the ability to fulfill the request.\n * Usually this implies future availability (e.g., a new feature of a web-service API).\n */\n NOT_IMPLEMENTED = 501,\n\n /**\n * The server was acting as a gateway or proxy and received an invalid response from the upstream server.\n */\n BAD_GATEWAY = 502,\n\n /**\n * The server is currently unavailable (because it is overloaded or down for maintenance).\n * Generally, this is a temporary state.\n */\n SERVICE_UNAVAILABLE = 503,\n\n /**\n * The server was acting as a gateway or proxy and did not receive a timely response from the upstream server.\n */\n GATEWAY_TIMEOUT = 504,\n\n /**\n * The server does not support the HTTP protocol version used in the request\n */\n HTTP_VERSION_NOT_SUPPORTED = 505,\n\n /**\n * Transparent content negotiation for the request results in a circular reference.\n */\n VARIANT_ALSO_NEGOTIATES = 506,\n\n /**\n * The server is unable to store the representation needed to complete the request.\n */\n INSUFFICIENT_STORAGE = 507,\n\n /**\n * The server detected an infinite loop while processing the request.\n */\n LOOP_DETECTED = 508,\n\n /**\n * Further extensions to the request are required for the server to fulfill it.\n */\n NOT_EXTENDED = 510,\n\n /**\n * The client needs to authenticate to gain network access.\n * Intended for use by intercepting proxies used to control access to the network (e.g., \"captive portals\" used\n * to require agreement to Terms of Service before granting full Internet access via a Wi-Fi hotspot).\n */\n NETWORK_AUTHENTICATION_REQUIRED = 511,\n}\n","\n// IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!\nexport const VERSION = {\n \"commitHash\": \"e03d983c780c7f96d8291ddd1251ea82f4581858\",\n \"version\": \"11.2.0-beta-RC.0\"\n};\n","/**\n * @packageDocumentation\n * @module @taquito/http-utils\n */\n\nimport { STATUS_CODE } from './status_code';\n\nconst isNode =\n typeof process !== 'undefined' && process.versions != null && process.versions.node != null;\n\nconst XMLHttpRequestCTOR = isNode ? require('xhr2-cookies').XMLHttpRequest : XMLHttpRequest;\n\nexport * from './status_code';\nexport { VERSION } from './version';\n\nconst defaultTimeout = 30000;\n\nexport interface HttpRequestOptions {\n url: string;\n method?: 'GET' | 'POST';\n timeout?: number;\n json?: boolean;\n query?: { [key: string]: any };\n headers?: { [key: string]: string };\n mimeType?: string;\n}\n\nexport class HttpResponseError extends Error {\n public name = 'HttpResponse';\n\n constructor(\n public message: string,\n public status: STATUS_CODE,\n public statusText: string,\n public body: string,\n public url: string\n ) {\n super(message);\n }\n}\n\nexport class HttpRequestFailed extends Error {\n public name = 'HttpRequestFailed';\n\n constructor(public url: string, public innerEvent: any) {\n super(`Request to ${url} failed`);\n }\n}\n\nexport class HttpBackend {\n protected serialize(obj?: { [key: string]: any }) {\n if (!obj) {\n return '';\n }\n\n const str = [];\n for (const p in obj) {\n // eslint-disable-next-line no-prototype-builtins\n if (obj.hasOwnProperty(p) && typeof obj[p] !== 'undefined') {\n const prop = typeof obj[p].toJSON === 'function' ? obj[p].toJSON() : obj[p];\n // query arguments can have no value so we need some way of handling that\n // example https://domain.com/query?all\n if (prop === null) {\n str.push(encodeURIComponent(p));\n continue;\n }\n // another use case is multiple arguments with the same name\n // they are passed as array\n if (Array.isArray(prop)) {\n prop.forEach((item) => {\n str.push(encodeURIComponent(p) + '=' + encodeURIComponent(item));\n });\n continue;\n }\n str.push(encodeURIComponent(p) + '=' + encodeURIComponent(prop));\n }\n }\n const serialized = str.join('&');\n if (serialized) {\n return `?${serialized}`;\n } else {\n return '';\n }\n }\n\n protected createXHR(): XMLHttpRequest {\n return new XMLHttpRequestCTOR();\n }\n\n /**\n *\n * @param options contains options to be passed for the HTTP request (url, method and timeout)\n */\n createRequest<T>(\n {\n url,\n method,\n timeout,\n query,\n headers = {},\n json = true,\n mimeType = undefined,\n }: HttpRequestOptions,\n data?: object | string\n ) {\n return new Promise<T>((resolve, reject) => {\n const request = this.createXHR();\n request.open(method || 'GET', `${url}${this.serialize(query)}`);\n if (!headers['Content-Type']) {\n request.setRequestHeader('Content-Type', 'application/json');\n }\n if (mimeType) {\n request.overrideMimeType(`${mimeType}`);\n }\n for (const k in headers) {\n request.setRequestHeader(k, headers[k]);\n }\n request.timeout = timeout || defaultTimeout;\n request.onload = function () {\n if (this.status >= 200 && this.status < 300) {\n if (json) {\n try {\n resolve(JSON.parse(request.response));\n } catch (ex) {\n reject(new Error(`Unable to parse response: ${request.response}`));\n }\n } else {\n resolve(request.response);\n }\n } else {\n reject(\n new HttpResponseError(\n `Http error response: (${this.status}) ${request.response}`,\n this.status as STATUS_CODE,\n request.statusText,\n request.response,\n url\n )\n );\n }\n };\n\n request.ontimeout = function () {\n reject(new Error(`Request timed out after: ${request.timeout}ms`));\n };\n\n request.onerror = function (err) {\n reject(new HttpRequestFailed(url, err));\n };\n\n if (data) {\n const dataStr = JSON.stringify(data);\n request.send(dataStr);\n } else {\n request.send();\n }\n });\n }\n}\n"],"names":[],"mappings":"AAAA;;;;IAIY;AAAZ,WAAY,WAAW;;;;;;;;IAQrB,uDAAc,CAAA;;;;IAKd,6EAAyB,CAAA;;;;;;IAOzB,2DAAgB,CAAA;;;;;;;IAQhB,2CAAQ,CAAA;;;;IAKR,qDAAa,CAAA;;;;;IAMb,uDAAc,CAAA;;;;;;IAOd,iGAAmC,CAAA;;;;IAKnC,2DAAgB,CAAA;;;;;IAMhB,iEAAmB,CAAA;;;;;;IAOnB,qEAAqB,CAAA;;;;;IAMrB,+DAAkB,CAAA;;;;;IAMlB,uEAAsB,CAAA;;;;;IAMtB,qDAAa,CAAA;;;;;;IAOb,uEAAsB,CAAA;;;;IAKtB,yEAAuB,CAAA;;;;;;;;;IAUvB,iDAAW,CAAA;;;;;;;IAQX,yDAAe,CAAA;;;;;IAMf,+DAAkB,CAAA;;;;;;IAOlB,yDAAe,CAAA;;;;IAKf,+DAAkB,CAAA;;;;;;;IAQlB,2EAAwB,CAAA;;;;;;IAOxB,2EAAwB,CAAA;;;;;IAMxB,6DAAiB,CAAA;;;;;;;IAQjB,+DAAkB,CAAA;;;;;;IAOlB,uEAAsB,CAAA;;;;;IAMtB,yDAAe,CAAA;;;;;IAMf,yDAAe,CAAA;;;;;IAMf,2EAAwB,CAAA;;;;IAKxB,mEAAoB,CAAA;;;;IAKpB,iGAAmC,CAAA;;;;;;IAOnC,qEAAqB,CAAA;;;;;IAMrB,uDAAc,CAAA;;;;;;;;IASd,+CAAU,CAAA;;;;IAKV,qEAAqB,CAAA;;;;IAKrB,6EAAyB,CAAA;;;;IAKzB,yEAAuB,CAAA;;;;;;IA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333
|
-
/* tslint:enable */
|
|
328
|
+
const VERSION = {
|
|
329
|
+
"commitHash": "e03d983c780c7f96d8291ddd1251ea82f4581858",
|
|
330
|
+
"version": "11.2.0-beta-RC.0"
|
|
331
|
+
};
|
|
334
332
|
|
|
335
333
|
/**
|
|
336
334
|
* @packageDocumentation
|
|
337
335
|
* @module @taquito/http-utils
|
|
338
336
|
*/
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
function HttpResponseError(message, status, statusText, body, url) {
|
|
337
|
+
const isNode = typeof process !== 'undefined' && process.versions != null && process.versions.node != null;
|
|
338
|
+
const XMLHttpRequestCTOR = isNode ? require('xhr2-cookies').XMLHttpRequest : XMLHttpRequest;
|
|
339
|
+
const defaultTimeout = 30000;
|
|
340
|
+
class HttpResponseError extends Error {
|
|
341
|
+
constructor(message, status, statusText, body, url) {
|
|
342
|
+
super(message);
|
|
346
343
|
this.message = message;
|
|
347
344
|
this.status = status;
|
|
348
345
|
this.statusText = statusText;
|
|
@@ -350,76 +347,68 @@
|
|
|
350
347
|
this.url = url;
|
|
351
348
|
this.name = 'HttpResponse';
|
|
352
349
|
}
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
350
|
+
}
|
|
351
|
+
class HttpRequestFailed extends Error {
|
|
352
|
+
constructor(url, innerEvent) {
|
|
353
|
+
super(`Request to ${url} failed`);
|
|
357
354
|
this.url = url;
|
|
358
355
|
this.innerEvent = innerEvent;
|
|
359
356
|
this.name = 'HttpRequestFailed';
|
|
360
|
-
this.message = "Request to " + url + " failed";
|
|
361
357
|
}
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
function HttpBackend() {
|
|
366
|
-
}
|
|
367
|
-
HttpBackend.prototype.serialize = function (obj) {
|
|
358
|
+
}
|
|
359
|
+
class HttpBackend {
|
|
360
|
+
serialize(obj) {
|
|
368
361
|
if (!obj) {
|
|
369
362
|
return '';
|
|
370
363
|
}
|
|
371
|
-
|
|
372
|
-
|
|
364
|
+
const str = [];
|
|
365
|
+
for (const p in obj) {
|
|
366
|
+
// eslint-disable-next-line no-prototype-builtins
|
|
373
367
|
if (obj.hasOwnProperty(p) && typeof obj[p] !== 'undefined') {
|
|
374
|
-
|
|
368
|
+
const prop = typeof obj[p].toJSON === 'function' ? obj[p].toJSON() : obj[p];
|
|
375
369
|
// query arguments can have no value so we need some way of handling that
|
|
376
370
|
// example https://domain.com/query?all
|
|
377
371
|
if (prop === null) {
|
|
378
372
|
str.push(encodeURIComponent(p));
|
|
379
|
-
|
|
373
|
+
continue;
|
|
380
374
|
}
|
|
381
375
|
// another use case is multiple arguments with the same name
|
|
382
376
|
// they are passed as array
|
|
383
377
|
if (Array.isArray(prop)) {
|
|
384
|
-
prop.forEach(
|
|
378
|
+
prop.forEach((item) => {
|
|
385
379
|
str.push(encodeURIComponent(p) + '=' + encodeURIComponent(item));
|
|
386
380
|
});
|
|
387
|
-
|
|
381
|
+
continue;
|
|
388
382
|
}
|
|
389
383
|
str.push(encodeURIComponent(p) + '=' + encodeURIComponent(prop));
|
|
390
384
|
}
|
|
391
|
-
};
|
|
392
|
-
for (var p in obj) {
|
|
393
|
-
_loop_1(p);
|
|
394
385
|
}
|
|
395
|
-
|
|
386
|
+
const serialized = str.join('&');
|
|
396
387
|
if (serialized) {
|
|
397
|
-
return
|
|
388
|
+
return `?${serialized}`;
|
|
398
389
|
}
|
|
399
390
|
else {
|
|
400
391
|
return '';
|
|
401
392
|
}
|
|
402
|
-
}
|
|
403
|
-
|
|
393
|
+
}
|
|
394
|
+
createXHR() {
|
|
404
395
|
return new XMLHttpRequestCTOR();
|
|
405
|
-
}
|
|
396
|
+
}
|
|
406
397
|
/**
|
|
407
398
|
*
|
|
408
399
|
* @param options contains options to be passed for the HTTP request (url, method and timeout)
|
|
409
400
|
*/
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
var request = _this.createXHR();
|
|
415
|
-
request.open(method || 'GET', "" + url + _this.serialize(query));
|
|
401
|
+
createRequest({ url, method, timeout, query, headers = {}, json = true, mimeType = undefined, }, data) {
|
|
402
|
+
return new Promise((resolve, reject) => {
|
|
403
|
+
const request = this.createXHR();
|
|
404
|
+
request.open(method || 'GET', `${url}${this.serialize(query)}`);
|
|
416
405
|
if (!headers['Content-Type']) {
|
|
417
406
|
request.setRequestHeader('Content-Type', 'application/json');
|
|
418
407
|
}
|
|
419
408
|
if (mimeType) {
|
|
420
|
-
request.overrideMimeType(
|
|
409
|
+
request.overrideMimeType(`${mimeType}`);
|
|
421
410
|
}
|
|
422
|
-
for (
|
|
411
|
+
for (const k in headers) {
|
|
423
412
|
request.setRequestHeader(k, headers[k]);
|
|
424
413
|
}
|
|
425
414
|
request.timeout = timeout || defaultTimeout;
|
|
@@ -430,7 +419,7 @@
|
|
|
430
419
|
resolve(JSON.parse(request.response));
|
|
431
420
|
}
|
|
432
421
|
catch (ex) {
|
|
433
|
-
reject(new Error(
|
|
422
|
+
reject(new Error(`Unable to parse response: ${request.response}`));
|
|
434
423
|
}
|
|
435
424
|
}
|
|
436
425
|
else {
|
|
@@ -438,26 +427,25 @@
|
|
|
438
427
|
}
|
|
439
428
|
}
|
|
440
429
|
else {
|
|
441
|
-
reject(new HttpResponseError(
|
|
430
|
+
reject(new HttpResponseError(`Http error response: (${this.status}) ${request.response}`, this.status, request.statusText, request.response, url));
|
|
442
431
|
}
|
|
443
432
|
};
|
|
444
433
|
request.ontimeout = function () {
|
|
445
|
-
reject(new Error(
|
|
434
|
+
reject(new Error(`Request timed out after: ${request.timeout}ms`));
|
|
446
435
|
};
|
|
447
436
|
request.onerror = function (err) {
|
|
448
437
|
reject(new HttpRequestFailed(url, err));
|
|
449
438
|
};
|
|
450
439
|
if (data) {
|
|
451
|
-
|
|
440
|
+
const dataStr = JSON.stringify(data);
|
|
452
441
|
request.send(dataStr);
|
|
453
442
|
}
|
|
454
443
|
else {
|
|
455
444
|
request.send();
|
|
456
445
|
}
|
|
457
446
|
});
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
}());
|
|
447
|
+
}
|
|
448
|
+
}
|
|
461
449
|
|
|
462
450
|
exports.HttpBackend = HttpBackend;
|
|
463
451
|
exports.HttpRequestFailed = HttpRequestFailed;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"taquito-http-utils.umd.js","sources":["../src/status_code.ts","../src/version.ts","../src/taquito-http-utils.ts"],"sourcesContent":["/**\n * Hypertext Transfer Protocol (HTTP) response status codes.\n * @see {@link https://en.wikipedia.org/wiki/List_of_HTTP_status_codes}\n */\nexport enum STATUS_CODE {\n /**\n * The server has received the request headers and the client should proceed to send the request body\n * (in the case of a request for which a body needs to be sent; for example, a POST request).\n * Sending a large request body to a server after a request has been rejected for inappropriate headers would be inefficient.\n * To have a server check the request's headers, a client must send Expect: 100-continue as a header in its initial request\n * and receive a 100 Continue status code in response before sending the body. The response 417 Expectation Failed indicates the request should not be continued.\n */\n CONTINUE = 100,\n\n /**\n * The requester has asked the server to switch protocols and the server has agreed to do so.\n */\n SWITCHING_PROTOCOLS = 101,\n\n /**\n * A WebDAV request may contain many sub-requests involving file operations, requiring a long time to complete the request.\n * This code indicates that the server has received and is processing the request, but no response is available yet.\n * This prevents the client from timing out and assuming the request was lost.\n */\n PROCESSING = 102,\n\n /**\n * Standard response for successful HTTP requests.\n * The actual response will depend on the request method used.\n * In a GET request, the response will contain an entity corresponding to the requested resource.\n * In a POST request, the response will contain an entity describing or containing the result of the action.\n */\n OK = 200,\n\n /**\n * The request has been fulfilled, resulting in the creation of a new resource.\n */\n CREATED = 201,\n\n /**\n * The request has been accepted for processing, but the processing has not been completed.\n * The request might or might not be eventually acted upon, and may be disallowed when processing occurs.\n */\n ACCEPTED = 202,\n\n /**\n * SINCE HTTP/1.1\n * The server is a transforming proxy that received a 200 OK from its origin,\n * but is returning a modified version of the origin's response.\n */\n NON_AUTHORITATIVE_INFORMATION = 203,\n\n /**\n * The server successfully processed the request and is not returning any content.\n */\n NO_CONTENT = 204,\n\n /**\n * The server successfully processed the request, but is not returning any content.\n * Unlike a 204 response, this response requires that the requester reset the document view.\n */\n RESET_CONTENT = 205,\n\n /**\n * The server is delivering only part of the resource (byte serving) due to a range header sent by the client.\n * The range header is used by HTTP clients to enable resuming of interrupted downloads,\n * or split a download into multiple simultaneous streams.\n */\n PARTIAL_CONTENT = 206,\n\n /**\n * The message body that follows is an XML message and can contain a number of separate response codes,\n * depending on how many sub-requests were made.\n */\n MULTI_STATUS = 207,\n\n /**\n * The members of a DAV binding have already been enumerated in a preceding part of the (multistatus) response,\n * and are not being included again.\n */\n ALREADY_REPORTED = 208,\n\n /**\n * The server has fulfilled a request for the resource,\n * and the response is a representation of the result of one or more instance-manipulations applied to the current instance.\n */\n IM_USED = 226,\n\n /**\n * Indicates multiple options for the resource from which the client may choose (via agent-driven content negotiation).\n * For example, this code could be used to present multiple video format options,\n * to list files with different filename extensions, or to suggest word-sense disambiguation.\n */\n MULTIPLE_CHOICES = 300,\n\n /**\n * This and all future requests should be directed to the given URI.\n */\n MOVED_PERMANENTLY = 301,\n\n /**\n * This is an example of industry practice contradicting the standard.\n * The HTTP/1.0 specification (RFC 1945) required the client to perform a temporary redirect\n * (the original describing phrase was \"Moved Temporarily\"), but popular browsers implemented 302\n * with the functionality of a 303 See Other. Therefore, HTTP/1.1 added status codes 303 and 307\n * to distinguish between the two behaviours. However, some Web applications and frameworks\n * use the 302 status code as if it were the 303.\n */\n FOUND = 302,\n\n /**\n * SINCE HTTP/1.1\n * The response to the request can be found under another URI using a GET method.\n * When received in response to a POST (or PUT/DELETE), the client should presume that\n * the server has received the data and should issue a redirect with a separate GET message.\n */\n SEE_OTHER = 303,\n\n /**\n * Indicates that the resource has not been modified since the version specified by the request headers If-Modified-Since or If-None-Match.\n * In such case, there is no need to retransmit the resource since the client still has a previously-downloaded copy.\n */\n NOT_MODIFIED = 304,\n\n /**\n * SINCE HTTP/1.1\n * The requested resource is available only through a proxy, the address for which is provided in the response.\n * Many HTTP clients (such as Mozilla and Internet Explorer) do not correctly handle responses with this status code, primarily for security reasons.\n */\n USE_PROXY = 305,\n\n /**\n * No longer used. Originally meant \"Subsequent requests should use the specified proxy.\"\n */\n SWITCH_PROXY = 306,\n\n /**\n * SINCE HTTP/1.1\n * In this case, the request should be repeated with another URI; however, future requests should still use the original URI.\n * In contrast to how 302 was historically implemented, the request method is not allowed to be changed when reissuing the original request.\n * For example, a POST request should be repeated using another POST request.\n */\n TEMPORARY_REDIRECT = 307,\n\n /**\n * The request and all future requests should be repeated using another URI.\n * 307 and 308 parallel the behaviors of 302 and 301, but do not allow the HTTP method to change.\n * So, for example, submitting a form to a permanently redirected resource may continue smoothly.\n */\n PERMANENT_REDIRECT = 308,\n\n /**\n * The server cannot or will not process the request due to an apparent client error\n * (e.g., malformed request syntax, too large size, invalid request message framing, or deceptive request routing).\n */\n BAD_REQUEST = 400,\n\n /**\n * Similar to 403 Forbidden, but specifically for use when authentication is required and has failed or has not yet\n * been provided. The response must include a WWW-Authenticate header field containing a challenge applicable to the\n * requested resource. See Basic access authentication and Digest access authentication. 401 semantically means\n * \"unauthenticated\",i.e. the user does not have the necessary credentials.\n */\n UNAUTHORIZED = 401,\n\n /**\n * Reserved for future use. The original intention was that this code might be used as part of some form of digital\n * cash or micro payment scheme, but that has not happened, and this code is not usually used.\n * Google Developers API uses this status if a particular developer has exceeded the daily limit on requests.\n */\n PAYMENT_REQUIRED = 402,\n\n /**\n * The request was valid, but the server is refusing action.\n * The user might not have the necessary permissions for a resource.\n */\n FORBIDDEN = 403,\n\n /**\n * The requested resource could not be found but may be available in the future.\n * Subsequent requests by the client are permissible.\n */\n NOT_FOUND = 404,\n\n /**\n * A request method is not supported for the requested resource;\n * for example, a GET request on a form that requires data to be presented via POST, or a PUT request on a read-only resource.\n */\n METHOD_NOT_ALLOWED = 405,\n\n /**\n * The requested resource is capable of generating only content not acceptable according to the Accept headers sent in the request.\n */\n NOT_ACCEPTABLE = 406,\n\n /**\n * The client must first authenticate itself with the proxy.\n */\n PROXY_AUTHENTICATION_REQUIRED = 407,\n\n /**\n * The server timed out waiting for the request.\n * According to HTTP specifications:\n * \"The client did not produce a request within the time that the server was prepared to wait. The client MAY repeat the request without modifications at any later time.\"\n */\n REQUEST_TIMEOUT = 408,\n\n /**\n * Indicates that the request could not be processed because of conflict in the request,\n * such as an edit conflict between multiple simultaneous updates.\n */\n CONFLICT = 409,\n\n /**\n * Indicates that the resource requested is no longer available and will not be available again.\n * This should be used when a resource has been intentionally removed and the resource should be purged.\n * Upon receiving a 410 status code, the client should not request the resource in the future.\n * Clients such as search engines should remove the resource from their indices.\n * Most use cases do not require clients and search engines to purge the resource, and a \"404 Not Found\" may be used instead.\n */\n GONE = 410,\n\n /**\n * The request did not specify the length of its content, which is required by the requested resource.\n */\n LENGTH_REQUIRED = 411,\n\n /**\n * The server does not meet one of the preconditions that the requester put on the request.\n */\n PRECONDITION_FAILED = 412,\n\n /**\n * The request is larger than the server is willing or able to process. Previously called \"Request Entity Too Large\".\n */\n PAYLOAD_TOO_LARGE = 413,\n\n /**\n * The URI provided was too long for the server to process. Often the result of too much data being encoded as a query-string of a GET request,\n * in which case it should be converted to a POST request.\n * Called \"Request-URI Too Long\" previously.\n */\n URI_TOO_LONG = 414,\n\n /**\n * The request entity has a media type which the server or resource does not support.\n * For example, the client uploads an image as image/svg+xml, but the server requires that images use a different format.\n */\n UNSUPPORTED_MEDIA_TYPE = 415,\n\n /**\n * The client has asked for a portion of the file (byte serving), but the server cannot supply that portion.\n * For example, if the client asked for a part of the file that lies beyond the end of the file.\n * Called \"Requested Range Not Satisfiable\" previously.\n */\n RANGE_NOT_SATISFIABLE = 416,\n\n /**\n * The server cannot meet the requirements of the Expect request-header field.\n */\n EXPECTATION_FAILED = 417,\n\n /**\n * This code was defined in 1998 as one of the traditional IETF April Fools' jokes, in RFC 2324, Hyper Text Coffee Pot Control Protocol,\n * and is not expected to be implemented by actual HTTP servers. The RFC specifies this code should be returned by\n * teapots requested to brew coffee. This HTTP status is used as an Easter egg in some websites, including Google.com.\n */\n I_AM_A_TEAPOT = 418,\n\n /**\n * The request was directed at a server that is not able to produce a response (for example because a connection reuse).\n */\n MISDIRECTED_REQUEST = 421,\n\n /**\n * The request was well-formed but was unable to be followed due to semantic errors.\n */\n UNPROCESSABLE_ENTITY = 422,\n\n /**\n * The resource that is being accessed is locked.\n */\n LOCKED = 423,\n\n /**\n * The request failed due to failure of a previous request (e.g., a PROPPATCH).\n */\n FAILED_DEPENDENCY = 424,\n\n /**\n * The client should switch to a different protocol such as TLS/1.0, given in the Upgrade header field.\n */\n UPGRADE_REQUIRED = 426,\n\n /**\n * The origin server requires the request to be conditional.\n * Intended to prevent \"the 'lost update' problem, where a client\n * GETs a resource's state, modifies it, and PUTs it back to the server,\n * when meanwhile a third party has modified the state on the server, leading to a conflict.\"\n */\n PRECONDITION_REQUIRED = 428,\n\n /**\n * The user has sent too many requests in a given amount of time. Intended for use with rate-limiting schemes.\n */\n TOO_MANY_REQUESTS = 429,\n\n /**\n * The server is unwilling to process the request because either an individual header field,\n * or all the header fields collectively, are too large.\n */\n REQUEST_HEADER_FIELDS_TOO_LARGE = 431,\n\n /**\n * A server operator has received a legal demand to deny access to a resource or to a set of resources\n * that includes the requested resource. The code 451 was chosen as a reference to the novel Fahrenheit 451.\n */\n UNAVAILABLE_FOR_LEGAL_REASONS = 451,\n\n /**\n * A generic error message, given when an unexpected condition was encountered and no more specific message is suitable.\n */\n INTERNAL_SERVER_ERROR = 500,\n\n /**\n * The server either does not recognize the request method, or it lacks the ability to fulfill the request.\n * Usually this implies future availability (e.g., a new feature of a web-service API).\n */\n NOT_IMPLEMENTED = 501,\n\n /**\n * The server was acting as a gateway or proxy and received an invalid response from the upstream server.\n */\n BAD_GATEWAY = 502,\n\n /**\n * The server is currently unavailable (because it is overloaded or down for maintenance).\n * Generally, this is a temporary state.\n */\n SERVICE_UNAVAILABLE = 503,\n\n /**\n * The server was acting as a gateway or proxy and did not receive a timely response from the upstream server.\n */\n GATEWAY_TIMEOUT = 504,\n\n /**\n * The server does not support the HTTP protocol version used in the request\n */\n HTTP_VERSION_NOT_SUPPORTED = 505,\n\n /**\n * Transparent content negotiation for the request results in a circular reference.\n */\n VARIANT_ALSO_NEGOTIATES = 506,\n\n /**\n * The server is unable to store the representation needed to complete the request.\n */\n INSUFFICIENT_STORAGE = 507,\n\n /**\n * The server detected an infinite loop while processing the request.\n */\n LOOP_DETECTED = 508,\n\n /**\n * Further extensions to the request are required for the server to fulfill it.\n */\n NOT_EXTENDED = 510,\n\n /**\n * The client needs to authenticate to gain network access.\n * Intended for use by intercepting proxies used to control access to the network (e.g., \"captive portals\" used\n * to require agreement to Terms of Service before granting full Internet access via a Wi-Fi hotspot).\n */\n NETWORK_AUTHENTICATION_REQUIRED = 511,\n}\n","\n// IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!\n/* tslint:disable */\nexport const VERSION = {\n \"commitHash\": \"e4fb2f0ab9a459640e474bf65ae4578f4b948c63\",\n \"version\": \"11.0.2\"\n};\n/* tslint:enable */\n","/**\n * @packageDocumentation\n * @module @taquito/http-utils\n */\n\nimport { STATUS_CODE } from './status_code';\n\n// tslint:disable: strict-type-predicates\nconst isNode =\n typeof process !== 'undefined' && process.versions != null && process.versions.node != null;\n// tslint:enable: strict-type-predicates\n\nconst XMLHttpRequestCTOR = isNode ? require('xhr2-cookies').XMLHttpRequest : XMLHttpRequest;\n\nexport * from './status_code';\nexport { VERSION } from './version';\n\nconst defaultTimeout = 30000;\n\nexport interface HttpRequestOptions {\n url: string;\n method?: 'GET' | 'POST';\n timeout?: number;\n json?: boolean;\n query?: { [key: string]: any };\n headers?: { [key: string]: string };\n mimeType?: string;\n}\n\nexport class HttpResponseError implements Error {\n public name = 'HttpResponse';\n\n constructor(\n public message: string,\n public status: STATUS_CODE,\n public statusText: string,\n public body: string,\n public url: string\n ) {}\n}\n\nexport class HttpRequestFailed implements Error {\n public name = 'HttpRequestFailed';\n public message: string;\n\n constructor(public url: string, public innerEvent: any) {\n this.message = `Request to ${url} failed`;\n }\n}\n\nexport class HttpBackend {\n protected serialize(obj?: { [key: string]: any }) {\n if (!obj) {\n return '';\n }\n\n const str = [];\n for (const p in obj) {\n if (obj.hasOwnProperty(p) && typeof obj[p] !== 'undefined') {\n const prop = typeof obj[p].toJSON === 'function' ? obj[p].toJSON() : obj[p];\n // query arguments can have no value so we need some way of handling that\n // example https://domain.com/query?all\n if (prop === null) {\n str.push(encodeURIComponent(p));\n continue;\n }\n // another use case is multiple arguments with the same name\n // they are passed as array\n if (Array.isArray(prop)) {\n prop.forEach((item) => {\n str.push(encodeURIComponent(p) + '=' + encodeURIComponent(item));\n });\n continue;\n }\n str.push(encodeURIComponent(p) + '=' + encodeURIComponent(prop));\n }\n }\n const serialized = str.join('&');\n if (serialized) {\n return `?${serialized}`;\n } else {\n return '';\n }\n }\n\n protected createXHR(): XMLHttpRequest {\n return new XMLHttpRequestCTOR();\n }\n\n /**\n *\n * @param options contains options to be passed for the HTTP request (url, method and timeout)\n */\n createRequest<T>(\n {\n url,\n method,\n timeout,\n query,\n headers = {},\n json = true,\n mimeType = undefined,\n }: HttpRequestOptions,\n data?: {}\n ) {\n return new Promise<T>((resolve, reject) => {\n const request = this.createXHR();\n request.open(method || 'GET', `${url}${this.serialize(query)}`);\n if (!headers['Content-Type']) {\n request.setRequestHeader('Content-Type', 'application/json');\n }\n if (mimeType) {\n request.overrideMimeType(`${mimeType}`);\n }\n for (const k in headers) {\n request.setRequestHeader(k, headers[k]);\n }\n request.timeout = timeout || defaultTimeout;\n request.onload = function () {\n if (this.status >= 200 && this.status < 300) {\n if (json) {\n try {\n resolve(JSON.parse(request.response));\n } catch (ex) {\n reject(new Error(`Unable to parse response: ${request.response}`));\n }\n } else {\n resolve(request.response);\n }\n } else {\n reject(\n new HttpResponseError(\n `Http error response: (${this.status}) ${request.response}`,\n this.status as STATUS_CODE,\n request.statusText,\n request.response,\n url\n )\n );\n }\n };\n\n request.ontimeout = function () {\n reject(new Error(`Request timed out after: ${request.timeout}ms`));\n };\n\n request.onerror = function (err) {\n reject(new HttpRequestFailed(url, err));\n };\n\n if (data) {\n const dataStr = JSON.stringify(data);\n request.send(dataStr);\n } else {\n request.send();\n }\n });\n }\n}\n"],"names":["STATUS_CODE"],"mappings":";;;;;;EAAA;;;;AAIYA;EAAZ,WAAY,WAAW;;;;;;;;MAQrB,uDAAc,CAAA;;;;MAKd,6EAAyB,CAAA;;;;;;MAOzB,2DAAgB,CAAA;;;;;;;MAQhB,2CAAQ,CAAA;;;;MAKR,qDAAa,CAAA;;;;;MAMb,uDAAc,CAAA;;;;;;MAOd,iGAAmC,CAAA;;;;MAKnC,2DAAgB,CAAA;;;;;MAMhB,iEAAmB,CAAA;;;;;;MAOnB,qEAAqB,CAAA;;;;;MAMrB,+DAAkB,CAAA;;;;;MAMlB,uEAAsB,CAAA;;;;;MAMtB,qDAAa,CAAA;;;;;;MAOb,uEAAsB,CAAA;;;;MAKtB,yEAAuB,CAAA;;;;;;;;;MAUvB,iDAAW,CAAA;;;;;;;MAQX,yDAAe,CAAA;;;;;MAMf,+DAAkB,CAAA;;;;;;MAOlB,yDAAe,CAAA;;;;MAKf,+DAAkB,CAAA;;;;;;;MAQlB,2EAAwB,CAAA;;;;;;MAOxB,2EAAwB,CAAA;;;;;MAMxB,6DAAiB,CAAA;;;;;;;MAQjB,+DAAkB,CAAA;;;;;;MAOlB,uEAAsB,CAAA;;;;;MAMtB,yDAAe,CAAA;;;;;MAMf,yDAAe,CAAA;;;;;MAMf,2EAAwB,CAAA;;;;MAKxB,mEAAoB,CAAA;;;;MAKpB,iGAAmC,CAAA;;;;;;MAOnC,qEAAqB,CAAA;;;;;MAMrB,uDAAc,CAAA;;;;;;;;MASd,+CAAU,CAAA;;;;MAKV,qEAAqB,CAAA;;;;MAKrB,6EAAyB,CAAA;;;;MAKzB,yEAAuB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ts"],"sourcesContent":["/**\n * Hypertext Transfer Protocol (HTTP) response status codes.\n * @see {@link https://en.wikipedia.org/wiki/List_of_HTTP_status_codes}\n */\nexport enum STATUS_CODE {\n /**\n * The server has received the request headers and the client should proceed to send the request body\n * (in the case of a request for which a body needs to be sent; for example, a POST request).\n * Sending a large request body to a server after a request has been rejected for inappropriate headers would be inefficient.\n * To have a server check the request's headers, a client must send Expect: 100-continue as a header in its initial request\n * and receive a 100 Continue status code in response before sending the body. The response 417 Expectation Failed indicates the request should not be continued.\n */\n CONTINUE = 100,\n\n /**\n * The requester has asked the server to switch protocols and the server has agreed to do so.\n */\n SWITCHING_PROTOCOLS = 101,\n\n /**\n * A WebDAV request may contain many sub-requests involving file operations, requiring a long time to complete the request.\n * This code indicates that the server has received and is processing the request, but no response is available yet.\n * This prevents the client from timing out and assuming the request was lost.\n */\n PROCESSING = 102,\n\n /**\n * Standard response for successful HTTP requests.\n * The actual response will depend on the request method used.\n * In a GET request, the response will contain an entity corresponding to the requested resource.\n * In a POST request, the response will contain an entity describing or containing the result of the action.\n */\n OK = 200,\n\n /**\n * The request has been fulfilled, resulting in the creation of a new resource.\n */\n CREATED = 201,\n\n /**\n * The request has been accepted for processing, but the processing has not been completed.\n * The request might or might not be eventually acted upon, and may be disallowed when processing occurs.\n */\n ACCEPTED = 202,\n\n /**\n * SINCE HTTP/1.1\n * The server is a transforming proxy that received a 200 OK from its origin,\n * but is returning a modified version of the origin's response.\n */\n NON_AUTHORITATIVE_INFORMATION = 203,\n\n /**\n * The server successfully processed the request and is not returning any content.\n */\n NO_CONTENT = 204,\n\n /**\n * The server successfully processed the request, but is not returning any content.\n * Unlike a 204 response, this response requires that the requester reset the document view.\n */\n RESET_CONTENT = 205,\n\n /**\n * The server is delivering only part of the resource (byte serving) due to a range header sent by the client.\n * The range header is used by HTTP clients to enable resuming of interrupted downloads,\n * or split a download into multiple simultaneous streams.\n */\n PARTIAL_CONTENT = 206,\n\n /**\n * The message body that follows is an XML message and can contain a number of separate response codes,\n * depending on how many sub-requests were made.\n */\n MULTI_STATUS = 207,\n\n /**\n * The members of a DAV binding have already been enumerated in a preceding part of the (multistatus) response,\n * and are not being included again.\n */\n ALREADY_REPORTED = 208,\n\n /**\n * The server has fulfilled a request for the resource,\n * and the response is a representation of the result of one or more instance-manipulations applied to the current instance.\n */\n IM_USED = 226,\n\n /**\n * Indicates multiple options for the resource from which the client may choose (via agent-driven content negotiation).\n * For example, this code could be used to present multiple video format options,\n * to list files with different filename extensions, or to suggest word-sense disambiguation.\n */\n MULTIPLE_CHOICES = 300,\n\n /**\n * This and all future requests should be directed to the given URI.\n */\n MOVED_PERMANENTLY = 301,\n\n /**\n * This is an example of industry practice contradicting the standard.\n * The HTTP/1.0 specification (RFC 1945) required the client to perform a temporary redirect\n * (the original describing phrase was \"Moved Temporarily\"), but popular browsers implemented 302\n * with the functionality of a 303 See Other. Therefore, HTTP/1.1 added status codes 303 and 307\n * to distinguish between the two behaviours. However, some Web applications and frameworks\n * use the 302 status code as if it were the 303.\n */\n FOUND = 302,\n\n /**\n * SINCE HTTP/1.1\n * The response to the request can be found under another URI using a GET method.\n * When received in response to a POST (or PUT/DELETE), the client should presume that\n * the server has received the data and should issue a redirect with a separate GET message.\n */\n SEE_OTHER = 303,\n\n /**\n * Indicates that the resource has not been modified since the version specified by the request headers If-Modified-Since or If-None-Match.\n * In such case, there is no need to retransmit the resource since the client still has a previously-downloaded copy.\n */\n NOT_MODIFIED = 304,\n\n /**\n * SINCE HTTP/1.1\n * The requested resource is available only through a proxy, the address for which is provided in the response.\n * Many HTTP clients (such as Mozilla and Internet Explorer) do not correctly handle responses with this status code, primarily for security reasons.\n */\n USE_PROXY = 305,\n\n /**\n * No longer used. Originally meant \"Subsequent requests should use the specified proxy.\"\n */\n SWITCH_PROXY = 306,\n\n /**\n * SINCE HTTP/1.1\n * In this case, the request should be repeated with another URI; however, future requests should still use the original URI.\n * In contrast to how 302 was historically implemented, the request method is not allowed to be changed when reissuing the original request.\n * For example, a POST request should be repeated using another POST request.\n */\n TEMPORARY_REDIRECT = 307,\n\n /**\n * The request and all future requests should be repeated using another URI.\n * 307 and 308 parallel the behaviors of 302 and 301, but do not allow the HTTP method to change.\n * So, for example, submitting a form to a permanently redirected resource may continue smoothly.\n */\n PERMANENT_REDIRECT = 308,\n\n /**\n * The server cannot or will not process the request due to an apparent client error\n * (e.g., malformed request syntax, too large size, invalid request message framing, or deceptive request routing).\n */\n BAD_REQUEST = 400,\n\n /**\n * Similar to 403 Forbidden, but specifically for use when authentication is required and has failed or has not yet\n * been provided. The response must include a WWW-Authenticate header field containing a challenge applicable to the\n * requested resource. See Basic access authentication and Digest access authentication. 401 semantically means\n * \"unauthenticated\",i.e. the user does not have the necessary credentials.\n */\n UNAUTHORIZED = 401,\n\n /**\n * Reserved for future use. The original intention was that this code might be used as part of some form of digital\n * cash or micro payment scheme, but that has not happened, and this code is not usually used.\n * Google Developers API uses this status if a particular developer has exceeded the daily limit on requests.\n */\n PAYMENT_REQUIRED = 402,\n\n /**\n * The request was valid, but the server is refusing action.\n * The user might not have the necessary permissions for a resource.\n */\n FORBIDDEN = 403,\n\n /**\n * The requested resource could not be found but may be available in the future.\n * Subsequent requests by the client are permissible.\n */\n NOT_FOUND = 404,\n\n /**\n * A request method is not supported for the requested resource;\n * for example, a GET request on a form that requires data to be presented via POST, or a PUT request on a read-only resource.\n */\n METHOD_NOT_ALLOWED = 405,\n\n /**\n * The requested resource is capable of generating only content not acceptable according to the Accept headers sent in the request.\n */\n NOT_ACCEPTABLE = 406,\n\n /**\n * The client must first authenticate itself with the proxy.\n */\n PROXY_AUTHENTICATION_REQUIRED = 407,\n\n /**\n * The server timed out waiting for the request.\n * According to HTTP specifications:\n * \"The client did not produce a request within the time that the server was prepared to wait. The client MAY repeat the request without modifications at any later time.\"\n */\n REQUEST_TIMEOUT = 408,\n\n /**\n * Indicates that the request could not be processed because of conflict in the request,\n * such as an edit conflict between multiple simultaneous updates.\n */\n CONFLICT = 409,\n\n /**\n * Indicates that the resource requested is no longer available and will not be available again.\n * This should be used when a resource has been intentionally removed and the resource should be purged.\n * Upon receiving a 410 status code, the client should not request the resource in the future.\n * Clients such as search engines should remove the resource from their indices.\n * Most use cases do not require clients and search engines to purge the resource, and a \"404 Not Found\" may be used instead.\n */\n GONE = 410,\n\n /**\n * The request did not specify the length of its content, which is required by the requested resource.\n */\n LENGTH_REQUIRED = 411,\n\n /**\n * The server does not meet one of the preconditions that the requester put on the request.\n */\n PRECONDITION_FAILED = 412,\n\n /**\n * The request is larger than the server is willing or able to process. Previously called \"Request Entity Too Large\".\n */\n PAYLOAD_TOO_LARGE = 413,\n\n /**\n * The URI provided was too long for the server to process. Often the result of too much data being encoded as a query-string of a GET request,\n * in which case it should be converted to a POST request.\n * Called \"Request-URI Too Long\" previously.\n */\n URI_TOO_LONG = 414,\n\n /**\n * The request entity has a media type which the server or resource does not support.\n * For example, the client uploads an image as image/svg+xml, but the server requires that images use a different format.\n */\n UNSUPPORTED_MEDIA_TYPE = 415,\n\n /**\n * The client has asked for a portion of the file (byte serving), but the server cannot supply that portion.\n * For example, if the client asked for a part of the file that lies beyond the end of the file.\n * Called \"Requested Range Not Satisfiable\" previously.\n */\n RANGE_NOT_SATISFIABLE = 416,\n\n /**\n * The server cannot meet the requirements of the Expect request-header field.\n */\n EXPECTATION_FAILED = 417,\n\n /**\n * This code was defined in 1998 as one of the traditional IETF April Fools' jokes, in RFC 2324, Hyper Text Coffee Pot Control Protocol,\n * and is not expected to be implemented by actual HTTP servers. The RFC specifies this code should be returned by\n * teapots requested to brew coffee. This HTTP status is used as an Easter egg in some websites, including Google.com.\n */\n I_AM_A_TEAPOT = 418,\n\n /**\n * The request was directed at a server that is not able to produce a response (for example because a connection reuse).\n */\n MISDIRECTED_REQUEST = 421,\n\n /**\n * The request was well-formed but was unable to be followed due to semantic errors.\n */\n UNPROCESSABLE_ENTITY = 422,\n\n /**\n * The resource that is being accessed is locked.\n */\n LOCKED = 423,\n\n /**\n * The request failed due to failure of a previous request (e.g., a PROPPATCH).\n */\n FAILED_DEPENDENCY = 424,\n\n /**\n * The client should switch to a different protocol such as TLS/1.0, given in the Upgrade header field.\n */\n UPGRADE_REQUIRED = 426,\n\n /**\n * The origin server requires the request to be conditional.\n * Intended to prevent \"the 'lost update' problem, where a client\n * GETs a resource's state, modifies it, and PUTs it back to the server,\n * when meanwhile a third party has modified the state on the server, leading to a conflict.\"\n */\n PRECONDITION_REQUIRED = 428,\n\n /**\n * The user has sent too many requests in a given amount of time. Intended for use with rate-limiting schemes.\n */\n TOO_MANY_REQUESTS = 429,\n\n /**\n * The server is unwilling to process the request because either an individual header field,\n * or all the header fields collectively, are too large.\n */\n REQUEST_HEADER_FIELDS_TOO_LARGE = 431,\n\n /**\n * A server operator has received a legal demand to deny access to a resource or to a set of resources\n * that includes the requested resource. The code 451 was chosen as a reference to the novel Fahrenheit 451.\n */\n UNAVAILABLE_FOR_LEGAL_REASONS = 451,\n\n /**\n * A generic error message, given when an unexpected condition was encountered and no more specific message is suitable.\n */\n INTERNAL_SERVER_ERROR = 500,\n\n /**\n * The server either does not recognize the request method, or it lacks the ability to fulfill the request.\n * Usually this implies future availability (e.g., a new feature of a web-service API).\n */\n NOT_IMPLEMENTED = 501,\n\n /**\n * The server was acting as a gateway or proxy and received an invalid response from the upstream server.\n */\n BAD_GATEWAY = 502,\n\n /**\n * The server is currently unavailable (because it is overloaded or down for maintenance).\n * Generally, this is a temporary state.\n */\n SERVICE_UNAVAILABLE = 503,\n\n /**\n * The server was acting as a gateway or proxy and did not receive a timely response from the upstream server.\n */\n GATEWAY_TIMEOUT = 504,\n\n /**\n * The server does not support the HTTP protocol version used in the request\n */\n HTTP_VERSION_NOT_SUPPORTED = 505,\n\n /**\n * Transparent content negotiation for the request results in a circular reference.\n */\n VARIANT_ALSO_NEGOTIATES = 506,\n\n /**\n * The server is unable to store the representation needed to complete the request.\n */\n INSUFFICIENT_STORAGE = 507,\n\n /**\n * The server detected an infinite loop while processing the request.\n */\n LOOP_DETECTED = 508,\n\n /**\n * Further extensions to the request are required for the server to fulfill it.\n */\n NOT_EXTENDED = 510,\n\n /**\n * The client needs to authenticate to gain network access.\n * Intended for use by intercepting proxies used to control access to the network (e.g., \"captive portals\" used\n * to require agreement to Terms of Service before granting full Internet access via a Wi-Fi hotspot).\n */\n NETWORK_AUTHENTICATION_REQUIRED = 511,\n}\n","\n// IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!\nexport const VERSION = {\n \"commitHash\": \"e03d983c780c7f96d8291ddd1251ea82f4581858\",\n \"version\": \"11.2.0-beta-RC.0\"\n};\n","/**\n * @packageDocumentation\n * @module @taquito/http-utils\n */\n\nimport { STATUS_CODE } from './status_code';\n\nconst isNode =\n typeof process !== 'undefined' && process.versions != null && process.versions.node != null;\n\nconst XMLHttpRequestCTOR = isNode ? require('xhr2-cookies').XMLHttpRequest : XMLHttpRequest;\n\nexport * from './status_code';\nexport { VERSION } from './version';\n\nconst defaultTimeout = 30000;\n\nexport interface HttpRequestOptions {\n url: string;\n method?: 'GET' | 'POST';\n timeout?: number;\n json?: boolean;\n query?: { [key: string]: any };\n headers?: { [key: string]: string };\n mimeType?: string;\n}\n\nexport class HttpResponseError extends Error {\n public name = 'HttpResponse';\n\n constructor(\n public message: string,\n public status: STATUS_CODE,\n public statusText: string,\n public body: string,\n public url: string\n ) {\n super(message);\n }\n}\n\nexport class HttpRequestFailed extends Error {\n public name = 'HttpRequestFailed';\n\n constructor(public url: string, public innerEvent: any) {\n super(`Request to ${url} failed`);\n }\n}\n\nexport class HttpBackend {\n protected serialize(obj?: { [key: string]: any }) {\n if (!obj) {\n return '';\n }\n\n const str = [];\n for (const p in obj) {\n // eslint-disable-next-line no-prototype-builtins\n if (obj.hasOwnProperty(p) && typeof obj[p] !== 'undefined') {\n const prop = typeof obj[p].toJSON === 'function' ? obj[p].toJSON() : obj[p];\n // query arguments can have no value so we need some way of handling that\n // example https://domain.com/query?all\n if (prop === null) {\n str.push(encodeURIComponent(p));\n continue;\n }\n // another use case is multiple arguments with the same name\n // they are passed as array\n if (Array.isArray(prop)) {\n prop.forEach((item) => {\n str.push(encodeURIComponent(p) + '=' + encodeURIComponent(item));\n });\n continue;\n }\n str.push(encodeURIComponent(p) + '=' + encodeURIComponent(prop));\n }\n }\n const serialized = str.join('&');\n if (serialized) {\n return `?${serialized}`;\n } else {\n return '';\n }\n }\n\n protected createXHR(): XMLHttpRequest {\n return new XMLHttpRequestCTOR();\n }\n\n /**\n *\n * @param options contains options to be passed for the HTTP request (url, method and timeout)\n */\n createRequest<T>(\n {\n url,\n method,\n timeout,\n query,\n headers = {},\n json = true,\n mimeType = undefined,\n }: HttpRequestOptions,\n data?: object | string\n ) {\n return new Promise<T>((resolve, reject) => {\n const request = this.createXHR();\n request.open(method || 'GET', `${url}${this.serialize(query)}`);\n if (!headers['Content-Type']) {\n request.setRequestHeader('Content-Type', 'application/json');\n }\n if (mimeType) {\n request.overrideMimeType(`${mimeType}`);\n }\n for (const k in headers) {\n request.setRequestHeader(k, headers[k]);\n }\n request.timeout = timeout || defaultTimeout;\n request.onload = function () {\n if (this.status >= 200 && this.status < 300) {\n if (json) {\n try {\n resolve(JSON.parse(request.response));\n } catch (ex) {\n reject(new Error(`Unable to parse response: ${request.response}`));\n }\n } else {\n resolve(request.response);\n }\n } else {\n reject(\n new HttpResponseError(\n `Http error response: (${this.status}) ${request.response}`,\n this.status as STATUS_CODE,\n request.statusText,\n request.response,\n url\n )\n );\n }\n };\n\n request.ontimeout = function () {\n reject(new Error(`Request timed out after: ${request.timeout}ms`));\n };\n\n request.onerror = function (err) {\n reject(new HttpRequestFailed(url, err));\n };\n\n if (data) {\n const dataStr = JSON.stringify(data);\n request.send(dataStr);\n } else {\n request.send();\n }\n });\n }\n}\n"],"names":["STATUS_CODE"],"mappings":";;;;;;EAAA;;;;AAIYA;EAAZ,WAAY,WAAW;;;;;;;;MAQrB,uDAAc,CAAA;;;;MAKd,6EAAyB,C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B,CACnB,yBAAyB,IAAI,CAAC,MAAM,KAAK,OAAO,CAAC,QAAQ,EAAE,EAC3D,IAAI,CAAC,MAAqB,EAC1B,OAAO,CAAC,UAAU,EAClB,OAAO,CAAC,QAAQ,EAChB,GAAG,CACJ,CACF,CAAC;mBACH;eACF,CAAC;cAEF,OAAO,CAAC,SAAS,GAAG;kBAClB,MAAM,CAAC,IAAI,KAAK,CAAC,4BAA4B,OAAO,CAAC,OAAO,IAAI,CAAC,CAAC,CAAC;eACpE,CAAC;cAEF,OAAO,CAAC,OAAO,GAAG,UAAU,GAAG;kBAC7B,MAAM,CAAC,IAAI,iBAAiB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;eACzC,CAAC;cAEF,IAAI,IAAI,EAAE;kBACR,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;kBACrC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;eACvB;mBAAM;kBACL,OAAO,CAAC,IAAI,EAAE,CAAC;eAChB;WACF,CAAC,CAAC;OACJ;;;;;;;;;;;;;;"}
|
|
@@ -18,7 +18,7 @@ export interface HttpRequestOptions {
|
|
|
18
18
|
};
|
|
19
19
|
mimeType?: string;
|
|
20
20
|
}
|
|
21
|
-
export declare class HttpResponseError
|
|
21
|
+
export declare class HttpResponseError extends Error {
|
|
22
22
|
message: string;
|
|
23
23
|
status: STATUS_CODE;
|
|
24
24
|
statusText: string;
|
|
@@ -27,11 +27,10 @@ export declare class HttpResponseError implements Error {
|
|
|
27
27
|
name: string;
|
|
28
28
|
constructor(message: string, status: STATUS_CODE, statusText: string, body: string, url: string);
|
|
29
29
|
}
|
|
30
|
-
export declare class HttpRequestFailed
|
|
30
|
+
export declare class HttpRequestFailed extends Error {
|
|
31
31
|
url: string;
|
|
32
32
|
innerEvent: any;
|
|
33
33
|
name: string;
|
|
34
|
-
message: string;
|
|
35
34
|
constructor(url: string, innerEvent: any);
|
|
36
35
|
}
|
|
37
36
|
export declare class HttpBackend {
|
|
@@ -43,5 +42,5 @@ export declare class HttpBackend {
|
|
|
43
42
|
*
|
|
44
43
|
* @param options contains options to be passed for the HTTP request (url, method and timeout)
|
|
45
44
|
*/
|
|
46
|
-
createRequest<T>({ url, method, timeout, query, headers, json, mimeType, }: HttpRequestOptions, data?:
|
|
45
|
+
createRequest<T>({ url, method, timeout, query, headers, json, mimeType, }: HttpRequestOptions, data?: object | string): Promise<T>;
|
|
47
46
|
}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@taquito/http-utils",
|
|
3
|
-
"version": "11.0.
|
|
3
|
+
"version": "11.2.0-beta-RC.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"tezos"
|
|
7
7
|
],
|
|
8
8
|
"main": "dist/taquito-http-utils.umd.js",
|
|
9
|
-
"module": "dist/taquito-http-utils.
|
|
9
|
+
"module": "dist/taquito-http-utils.es6.js",
|
|
10
10
|
"typings": "dist/types/taquito-http-utils.d.ts",
|
|
11
11
|
"files": [
|
|
12
12
|
"signature.json",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"precommit": "lint-staged",
|
|
30
30
|
"prebuild": "rimraf dist",
|
|
31
31
|
"version-stamp": "node ../taquito/version-stamping.js",
|
|
32
|
-
"build": "
|
|
33
|
-
"start": "
|
|
32
|
+
"build": "tsc --project ./tsconfig.prod.json --module commonjs && rollup -c rollup.config.ts ",
|
|
33
|
+
"start": "rollup -c rollup.config.ts -w"
|
|
34
34
|
},
|
|
35
35
|
"lint-staged": {
|
|
36
36
|
"{src,test}/**/*.ts": [
|
|
@@ -62,33 +62,33 @@
|
|
|
62
62
|
"xhr2-cookies": "^1.1.0"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
|
+
"@types/bluebird": "^3.5.36",
|
|
65
66
|
"@types/jest": "^26.0.23",
|
|
66
|
-
"@types/node": "^
|
|
67
|
-
"@types/superagent": "^4.1.
|
|
68
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
69
|
-
"@typescript-eslint/parser": "^
|
|
67
|
+
"@types/node": "^17.0.0",
|
|
68
|
+
"@types/superagent": "^4.1.13",
|
|
69
|
+
"@typescript-eslint/eslint-plugin": "^5.7.0",
|
|
70
|
+
"@typescript-eslint/parser": "^5.7.0",
|
|
70
71
|
"colors": "^1.4.0",
|
|
71
|
-
"coveralls": "^3.1.
|
|
72
|
+
"coveralls": "^3.1.1",
|
|
72
73
|
"cross-env": "^7.0.3",
|
|
73
|
-
"eslint": "^
|
|
74
|
+
"eslint": "^8.5.0",
|
|
74
75
|
"jest": "^26.6.3",
|
|
75
76
|
"jest-config": "^26.6.3",
|
|
76
|
-
"lint-staged": "^
|
|
77
|
+
"lint-staged": "^12.1.2",
|
|
77
78
|
"lodash.camelcase": "^4.3.0",
|
|
78
|
-
"prettier": "^2.
|
|
79
|
-
"prompt": "^1.
|
|
80
|
-
"replace-in-file": "^6.2
|
|
79
|
+
"prettier": "^2.5.1",
|
|
80
|
+
"prompt": "^1.2.0",
|
|
81
|
+
"replace-in-file": "^6.3.2",
|
|
81
82
|
"rimraf": "^3.0.2",
|
|
82
|
-
"rollup": "^2.
|
|
83
|
+
"rollup": "^2.61.1",
|
|
83
84
|
"rollup-plugin-json": "^4.0.0",
|
|
84
85
|
"rollup-plugin-sourcemaps": "^0.6.3",
|
|
85
|
-
"rollup-plugin-typescript2": "^0.
|
|
86
|
+
"rollup-plugin-typescript2": "^0.31.1",
|
|
86
87
|
"shelljs": "^0.8.4",
|
|
87
88
|
"ts-jest": "^26.4.4",
|
|
88
|
-
"ts-node": "^10.
|
|
89
|
-
"
|
|
90
|
-
"tslint-config-standard": "^9.0.0",
|
|
89
|
+
"ts-node": "^10.4.0",
|
|
90
|
+
"ts-toolbelt": "^9.6.0",
|
|
91
91
|
"typescript": "~4.1.5"
|
|
92
92
|
},
|
|
93
|
-
"gitHead": "
|
|
93
|
+
"gitHead": "7cc9152cdad01bacca4a1b682c7cb0a33a24f544"
|
|
94
94
|
}
|