🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@qevm/web

Package Overview
Dependencies
Maintainers
3
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@qevm/web - npm Package Compare versions

Comparing version
5.7.2
to
5.7.3
+1
-1
lib/_version.d.ts

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

export declare const version = "web/5.7.1";
export declare const version = "web/5.7.3";
//# sourceMappingURL=_version.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.version = void 0;
exports.version = "web/5.7.1";
exports.version = "web/5.7.3";
//# sourceMappingURL=_version.js.map

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

{"version":3,"file":"browser-geturl.d.ts","sourceRoot":"","sources":["../src.ts/browser-geturl.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAEvD,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,CAAC;AAEnC,wBAAsB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,cAAc,CAAC,CA8CrF"}
{"version":3,"file":"browser-geturl.d.ts","sourceRoot":"","sources":["../src.ts/browser-geturl.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAEvD,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,CAAC;AAEnC,wBAAsB,MAAM,CACxB,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,OAAO,GAClB,OAAO,CAAC,cAAc,CAAC,CA0DzB"}
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
Object.defineProperty(exports, "__esModule", { value: true });
exports.getUrl = getUrl;
const bytes_1 = require("@qevm/bytes");
async function getUrl(href, options) {
if (options == null) {
options = {};
}
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getUrl = void 0;
var bytes_1 = require("@qevm/bytes");
function getUrl(href, options) {
return __awaiter(this, void 0, void 0, function () {
var request, opts, response, body, headers;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (options == null) {
options = {};
}
request = {
method: (options.method || "GET"),
headers: (options.headers || {}),
body: (options.body || undefined),
};
if (options.skipFetchSetup !== true) {
request.mode = "cors"; // no-cors, cors, *same-origin
request.cache = "no-cache"; // *default, no-cache, reload, force-cache, only-if-cached
request.credentials = "same-origin"; // include, *same-origin, omit
request.redirect = "follow"; // manual, *follow, error
request.referrer = "client"; // no-referrer, *client
}
;
if (options.fetchOptions != null) {
opts = options.fetchOptions;
if (opts.mode) {
request.mode = (opts.mode);
}
if (opts.cache) {
request.cache = (opts.cache);
}
if (opts.credentials) {
request.credentials = (opts.credentials);
}
if (opts.redirect) {
request.redirect = (opts.redirect);
}
if (opts.referrer) {
request.referrer = opts.referrer;
}
}
return [4 /*yield*/, fetch(href, request)];
case 1:
response = _a.sent();
return [4 /*yield*/, response.arrayBuffer()];
case 2:
body = _a.sent();
headers = {};
if (response.headers.forEach) {
response.headers.forEach(function (value, key) {
headers[key.toLowerCase()] = value;
});
}
else {
((response.headers).keys)().forEach(function (key) {
headers[key.toLowerCase()] = response.headers.get(key);
});
}
return [2 /*return*/, {
headers: headers,
statusCode: response.status,
statusMessage: response.statusText,
body: (0, bytes_1.arrayify)(new Uint8Array(body)),
}];
}
const request = {
method: options.method || "GET",
headers: options.headers || {},
body: options.body || undefined,
};
if (options.skipFetchSetup !== true) {
request.mode = "cors"; // no-cors, cors, *same-origin
request.cache = "no-cache"; // *default, no-cache, reload, force-cache, only-if-cached
request.credentials = "same-origin"; // include, *same-origin, omit
request.redirect = "follow"; // manual, *follow, error
request.referrer = "client"; // no-referrer, *client
}
if (options.fetchOptions != null) {
const opts = options.fetchOptions;
if (opts.mode) {
request.mode = opts.mode;
}
if (opts.cache) {
request.cache = opts.cache;
}
if (opts.credentials) {
request.credentials = opts.credentials;
}
if (opts.redirect) {
request.redirect = opts.redirect;
}
if (opts.referrer) {
request.referrer = opts.referrer;
}
}
const response = await fetch(href, request);
const body = await response.arrayBuffer();
const headers = {};
if (response.headers.forEach) {
response.headers.forEach((value, key) => {
headers[key.toLowerCase()] = value;
});
});
}
else {
response.headers.keys().forEach((key) => {
headers[key.toLowerCase()] = response.headers.get(key);
});
}
return {
headers: headers,
statusCode: response.status,
statusMessage: response.statusText,
body: (0, bytes_1.arrayify)(new Uint8Array(body)),
};
}
exports.getUrl = getUrl;
//# sourceMappingURL=browser-geturl.js.map

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

{"version":3,"file":"browser-geturl.js","sourceRoot":"","sources":["../src.ts/browser-geturl.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEb,qCAAuC;AAMvC,SAAsB,MAAM,CAAC,IAAY,EAAE,OAAiB;;;;;;oBACxD,IAAI,OAAO,IAAI,IAAI,EAAE;wBAAE,OAAO,GAAG,EAAG,CAAC;qBAAE;oBAEjC,OAAO,GAAgB;wBACzB,MAAM,EAAE,CAAC,OAAO,CAAC,MAAM,IAAI,KAAK,CAAC;wBACjC,OAAO,EAAE,CAAC,OAAO,CAAC,OAAO,IAAI,EAAG,CAAC;wBACjC,IAAI,EAAE,CAAC,OAAO,CAAC,IAAI,IAAI,SAAS,CAAC;qBACpC,CAAC;oBAEF,IAAI,OAAO,CAAC,cAAc,KAAK,IAAI,EAAE;wBACjC,OAAO,CAAC,IAAI,GAAgB,MAAM,CAAC,CAAc,8BAA8B;wBAC/E,OAAO,CAAC,KAAK,GAAiB,UAAU,CAAC,CAAQ,0DAA0D;wBAC3G,OAAO,CAAC,WAAW,GAAuB,aAAa,CAAC,CAAE,8BAA8B;wBACxF,OAAO,CAAC,QAAQ,GAAoB,QAAQ,CAAC,CAAI,yBAAyB;wBAC1E,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAC,CAAqB,uBAAuB;qBAC3E;oBAAA,CAAC;oBAEF,IAAI,OAAO,CAAC,YAAY,IAAI,IAAI,EAAE;wBACxB,IAAI,GAAG,OA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,QAAQ,CAAC,UAAU;QAClC,IAAI,EAAE,IAAA,gBAAQ,EAAC,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC;KACvC,CAAC;AACN,CAAC"}

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

{"version":3,"file":"geturl.d.ts","sourceRoot":"","sources":["../src.ts/geturl.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAMvD,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,CAAC;AAmDnC,wBAAsB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,cAAc,CAAC,CA6CrF"}
{"version":3,"file":"geturl.d.ts","sourceRoot":"","sources":["../src.ts/geturl.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAMvD,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,CAAC;AA4DnC,wBAAsB,MAAM,CACxB,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,OAAO,GAClB,OAAO,CAAC,cAAc,CAAC,CAmDzB"}
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -42,20 +6,20 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

Object.defineProperty(exports, "__esModule", { value: true });
exports.getUrl = void 0;
var http_1 = __importDefault(require("http"));
var https_1 = __importDefault(require("https"));
var zlib_1 = require("zlib");
var url_1 = require("url");
var bytes_1 = require("@qevm/bytes");
var properties_1 = require("@ethersproject/properties");
var logger_1 = require("@ethersproject/logger");
var _version_1 = require("./_version");
var logger = new logger_1.Logger(_version_1.version);
exports.getUrl = getUrl;
const http_1 = __importDefault(require("http"));
const https_1 = __importDefault(require("https"));
const zlib_1 = require("zlib");
const url_1 = require("url");
const bytes_1 = require("@qevm/bytes");
const properties_1 = require("@qevm/properties");
const logger_1 = require("@qevm/logger");
const _version_1 = require("./_version");
const logger = new logger_1.Logger(_version_1.version);
function getResponse(request) {
return new Promise(function (resolve, reject) {
request.once("response", function (resp) {
var response = {
return new Promise((resolve, reject) => {
request.once("response", (resp) => {
const response = {
statusCode: resp.statusCode,
statusMessage: resp.statusMessage,
headers: Object.keys(resp.headers).reduce(function (accum, name) {
var value = resp.headers[name];
headers: Object.keys(resp.headers).reduce((accum, name) => {
let value = resp.headers[name];
if (Array.isArray(value)) {

@@ -67,6 +31,6 @@ value = value.join(", ");

}, {}),
body: null
body: null,
};
//resp.setEncoding("utf8");
resp.on("data", function (chunk) {
resp.on("data", (chunk) => {
if (response.body == null) {

@@ -77,3 +41,3 @@ response.body = new Uint8Array(0);

});
resp.on("end", function () {
resp.on("end", () => {
if (response.headers["content-encoding"] === "gzip") {

@@ -86,3 +50,3 @@ //const size = response.body.length;

});
resp.on("error", function (error) {
resp.on("error", (error) => {
/* istanbul ignore next */

@@ -93,3 +57,5 @@ error.response = response;

});
request.on("error", function (error) { reject(error); });
request.on("error", (error) => {
reject(error);
});
});

@@ -104,51 +70,43 @@ }

}
function getUrl(href, options) {
return __awaiter(this, void 0, void 0, function () {
var url, request, req, response;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (options == null) {
options = {};
}
url = (0, url_1.parse)(href);
request = {
protocol: nonnull(url.protocol),
hostname: nonnull(url.hostname),
port: nonnull(url.port),
path: (nonnull(url.pathname) + nonnull(url.search)),
method: (options.method || "GET"),
headers: (0, properties_1.shallowCopy)(options.headers || {}),
};
if (options.allowGzip) {
request.headers["accept-encoding"] = "gzip";
}
req = null;
switch (nonnull(url.protocol)) {
case "http:":
req = http_1.default.request(request);
break;
case "https:":
req = https_1.default.request(request);
break;
default:
/* istanbul ignore next */
logger.throwError("unsupported protocol " + url.protocol, logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
protocol: url.protocol,
operation: "request"
});
}
if (options.body) {
req.write(Buffer.from(options.body));
}
req.end();
return [4 /*yield*/, getResponse(req)];
case 1:
response = _a.sent();
return [2 /*return*/, response];
}
});
});
async function getUrl(href, options) {
if (options == null) {
options = {};
}
// @TODO: Once we drop support for node 8, we can pass the href
// directly into request and skip adding the components
// to this request object
const url = (0, url_1.parse)(href);
const request = {
protocol: nonnull(url.protocol),
hostname: nonnull(url.hostname),
port: nonnull(url.port),
path: nonnull(url.pathname) + nonnull(url.search),
method: options.method || "GET",
headers: (0, properties_1.shallowCopy)(options.headers || {}),
};
if (options.allowGzip) {
request.headers["accept-encoding"] = "gzip";
}
let req = null;
switch (nonnull(url.protocol)) {
case "http:":
req = http_1.default.request(request);
break;
case "https:":
req = https_1.default.request(request);
break;
default:
/* istanbul ignore next */
logger.throwError(`unsupported protocol ${url.protocol}`, logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
protocol: url.protocol,
operation: "request",
});
}
if (options.body) {
req.write(Buffer.from(options.body));
}
req.end();
const response = await getResponse(req);
return response;
}
exports.getUrl = getUrl;
//# sourceMappingURL=geturl.js.map

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

{"version":3,"file":"geturl.js","sourceRoot":"","sources":["../src.ts/geturl.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEb,8CAAwB;AACxB,gDAA0B;AAC1B,6BAAkC;AAClC,2BAA2B;AAE3B,qCAA+C;AAC/C,wDAAwD;AAIxD,gDAA+C;AAC/C,uCAAqC;AACrC,IAAM,MAAM,GAAG,IAAI,eAAM,CAAC,kBAAO,CAAC,CAAC;AAInC,SAAS,WAAW,CAAC,OAA2B;IAC5C,OAAO,IAAI,OAAO,CAAC,UAAC,OAAO,EAAE,MAAM;QAC/B,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,UAAC,IAA0B;YAChD,IAAM,QAAQ,GAAmB;gBAC7B,UAAU,EAAE,IAAI,CAAC,UAAU;gBAC3B,aAAa,EAAE,IAAI,CAAC,aAAa;gBACjC,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,CA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,CAAC,EAAE,CAAC;QAC5B,KAAK,OAAO;YACR,GAAG,GAAG,cAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;YAC5B,MAAM;QACV,KAAK,QAAQ;YACT,GAAG,GAAG,eAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;YAC7B,MAAM;QACV;YACI,0BAA0B;YAC1B,MAAM,CAAC,UAAU,CACb,wBAAwB,GAAG,CAAC,QAAQ,EAAE,EACtC,eAAM,CAAC,MAAM,CAAC,qBAAqB,EACnC;gBACI,QAAQ,EAAE,GAAG,CAAC,QAAQ;gBACtB,SAAS,EAAE,SAAS;aACvB,CACJ,CAAC;IACV,CAAC;IAED,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;QACf,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;IACzC,CAAC;IACD,GAAG,CAAC,GAAG,EAAE,CAAC;IAEV,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,GAAG,CAAC,CAAC;IACxC,OAAO,QAAQ,CAAC;AACpB,CAAC"}

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

export declare type ConnectionInfo = {
export type ConnectionInfo = {
url: string;

@@ -24,3 +24,3 @@ headers?: {

}
export declare type PollOptions = {
export type PollOptions = {
timeout?: number;

@@ -34,3 +34,3 @@ floor?: number;

};
export declare type FetchJsonResponse = {
export type FetchJsonResponse = {
statusCode: number;

@@ -37,0 +37,0 @@ headers: {

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

{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src.ts/index.ts"],"names":[],"mappings":"AAqCA,oBAAY,cAAc,GAAG;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAA;KAAE,CAAA;IAE5C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC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AC,EAAE,WAAW,GACtB,OAAO,CAAC,CAAC,CAAC,CA2FZ"}
+201
-229
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.poll = exports.fetchJson = exports._fetchData = void 0;
var base64_1 = require("@qevm/base64");
var bytes_1 = require("@qevm/bytes");
var properties_1 = require("@ethersproject/properties");
var strings_1 = require("@qevm/strings");
var logger_1 = require("@ethersproject/logger");
var _version_1 = require("./_version");
var logger = new logger_1.Logger(_version_1.version);
var geturl_1 = require("./geturl");
exports._fetchData = _fetchData;
exports.fetchJson = fetchJson;
exports.poll = poll;
const base64_1 = require("@qevm/base64");
const bytes_1 = require("@qevm/bytes");
const properties_1 = require("@qevm/properties");
const strings_1 = require("@qevm/strings");
const logger_1 = require("@qevm/logger");
const _version_1 = require("./_version");
const logger = new logger_1.Logger(_version_1.version);
const geturl_1 = require("./geturl");
function staller(duration) {
return new Promise(function (resolve) {
return new Promise((resolve) => {
setTimeout(resolve, duration);

@@ -57,7 +23,9 @@ });

}
if (typeof (value) === "string") {
if (typeof value === "string") {
return value;
}
if ((0, bytes_1.isBytesLike)(value)) {
if (type && (type.split("/")[0] === "text" || type.split(";")[0].trim() === "application/json")) {
if (type &&
(type.split("/")[0] === "text" ||
type.split(";")[0].trim() === "application/json")) {
try {

@@ -67,3 +35,2 @@ return (0, strings_1.toUtf8String)(value);

catch (error) { }
;
}

@@ -75,3 +42,3 @@ return (0, bytes_1.hexlify)(value);

function unpercent(value) {
return (0, strings_1.toUtf8Bytes)(value.replace(/%([0-9a-f][0-9a-f])/gi, function (all, code) {
return (0, strings_1.toUtf8Bytes)(value.replace(/%([0-9a-f][0-9a-f])/gi, (all, code) => {
return String.fromCharCode(parseInt(code, 16));

@@ -88,20 +55,25 @@ }));

// How many times to retry in the event of a throttle
var attemptLimit = (typeof (connection) === "object" && connection.throttleLimit != null) ? connection.throttleLimit : 12;
logger.assertArgument((attemptLimit > 0 && (attemptLimit % 1) === 0), "invalid connection throttle limit", "connection.throttleLimit", attemptLimit);
var throttleCallback = ((typeof (connection) === "object") ? connection.throttleCallback : null);
var throttleSlotInterval = ((typeof (connection) === "object" && typeof (connection.throttleSlotInterval) === "number") ? connection.throttleSlotInterval : 100);
logger.assertArgument((throttleSlotInterval > 0 && (throttleSlotInterval % 1) === 0), "invalid connection throttle slot interval", "connection.throttleSlotInterval", throttleSlotInterval);
var errorPassThrough = ((typeof (connection) === "object") ? !!(connection.errorPassThrough) : false);
var headers = {};
var url = null;
const attemptLimit = typeof connection === "object" && connection.throttleLimit != null
? connection.throttleLimit
: 12;
logger.assertArgument(attemptLimit > 0 && attemptLimit % 1 === 0, "invalid connection throttle limit", "connection.throttleLimit", attemptLimit);
const throttleCallback = typeof connection === "object" ? connection.throttleCallback : null;
const throttleSlotInterval = typeof connection === "object" &&
typeof connection.throttleSlotInterval === "number"
? connection.throttleSlotInterval
: 100;
logger.assertArgument(throttleSlotInterval > 0 && throttleSlotInterval % 1 === 0, "invalid connection throttle slot interval", "connection.throttleSlotInterval", throttleSlotInterval);
const errorPassThrough = typeof connection === "object" ? !!connection.errorPassThrough : false;
const headers = {};
let url = null;
// @TODO: Allow ConnectionInfo to override some of these values
var options = {
const options = {
method: "GET",
};
var allow304 = false;
var timeout = 2 * 60 * 1000;
if (typeof (connection) === "string") {
let allow304 = false;
let timeout = 2 * 60 * 1000;
if (typeof connection === "string") {
url = connection;
}
else if (typeof (connection) === "object") {
else if (typeof connection === "object") {
if (connection == null || connection.url == null) {

@@ -111,8 +83,11 @@ logger.throwArgumentError("missing URL", "connection.url", connection);

url = connection.url;
if (typeof (connection.timeout) === "number" && connection.timeout > 0) {
if (typeof connection.timeout === "number" && connection.timeout > 0) {
timeout = connection.timeout;
}
if (connection.headers) {
for (var key in connection.headers) {
headers[key.toLowerCase()] = { key: key, value: String(connection.headers[key]) };
for (const key in connection.headers) {
headers[key.toLowerCase()] = {
key: key,
value: String(connection.headers[key]),
};
if (["if-none-match", "if-modified-since"].indexOf(key.toLowerCase()) >= 0) {

@@ -125,9 +100,15 @@ allow304 = true;

if (connection.user != null && connection.password != null) {
if (url.substring(0, 6) !== "https:" && connection.allowInsecureAuthentication !== true) {
logger.throwError("basic authentication requires a secure https url", logger_1.Logger.errors.INVALID_ARGUMENT, { argument: "url", url: url, user: connection.user, password: "[REDACTED]" });
if (url.substring(0, 6) !== "https:" &&
connection.allowInsecureAuthentication !== true) {
logger.throwError("basic authentication requires a secure https url", logger_1.Logger.errors.INVALID_ARGUMENT, {
argument: "url",
url: url,
user: connection.user,
password: "[REDACTED]",
});
}
var authorization = connection.user + ":" + connection.password;
const authorization = connection.user + ":" + connection.password;
headers["authorization"] = {
key: "Authorization",
value: "Basic " + (0, base64_1.encode)((0, strings_1.toUtf8Bytes)(authorization))
value: "Basic " + (0, base64_1.encode)((0, strings_1.toUtf8Bytes)(authorization)),
};

@@ -142,13 +123,15 @@ }

}
var reData = new RegExp("^data:([^;:]*)?(;base64)?,(.*)$", "i");
var dataMatch = ((url) ? url.match(reData) : null);
const reData = new RegExp("^data:([^;:]*)?(;base64)?,(.*)$", "i");
const dataMatch = url ? url.match(reData) : null;
if (dataMatch) {
try {
var response = {
const response = {
statusCode: 200,
statusMessage: "OK",
headers: { "content-type": (dataMatch[1] || "text/plain") },
body: (dataMatch[2] ? (0, base64_1.decode)(dataMatch[3]) : unpercent(dataMatch[3]))
headers: { "content-type": dataMatch[1] || "text/plain" },
body: dataMatch[2]
? (0, base64_1.decode)(dataMatch[3])
: unpercent(dataMatch[3]),
};
var result = response.body;
let result = response.body;
if (processFunc) {

@@ -165,3 +148,3 @@ result = processFunc(response.body, response);

requestMethod: "GET",
url: url
url: url,
});

@@ -174,19 +157,25 @@ }

if (headers["content-type"] == null) {
headers["content-type"] = { key: "Content-Type", value: "application/octet-stream" };
headers["content-type"] = {
key: "Content-Type",
value: "application/octet-stream",
};
}
if (headers["content-length"] == null) {
headers["content-length"] = { key: "Content-Length", value: String(body.length) };
headers["content-length"] = {
key: "Content-Length",
value: String(body.length),
};
}
}
var flatHeaders = {};
Object.keys(headers).forEach(function (key) {
var header = headers[key];
const flatHeaders = {};
Object.keys(headers).forEach((key) => {
const header = headers[key];
flatHeaders[header.key] = header.value;
});
options.headers = flatHeaders;
var runningTimeout = (function () {
var timer = null;
var promise = new Promise(function (resolve, reject) {
const runningTimeout = (function () {
let timer = null;
const promise = new Promise(function (resolve, reject) {
if (timeout) {
timer = setTimeout(function () {
timer = setTimeout(() => {
if (timer == null) {

@@ -200,3 +189,3 @@ return;

timeout: timeout,
url: url
url: url,
}));

@@ -206,3 +195,3 @@ }, timeout);

});
var cancel = function () {
const cancel = function () {
if (timer == null) {

@@ -214,135 +203,118 @@ return;

};
return { promise: promise, cancel: cancel };
return { promise, cancel };
})();
var runningFetch = (function () {
return __awaiter(this, void 0, void 0, function () {
var attempt, response, location_1, tryAgain, stall, retryAfter, error_1, body_1, result, error_2, tryAgain, timeout_1;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
attempt = 0;
_a.label = 1;
case 1:
if (!(attempt < attemptLimit)) return [3 /*break*/, 20];
response = null;
_a.label = 2;
case 2:
_a.trys.push([2, 9, , 10]);
return [4 /*yield*/, (0, geturl_1.getUrl)(url, options)];
case 3:
response = _a.sent();
if (!(attempt < attemptLimit)) return [3 /*break*/, 8];
if (!(response.statusCode === 301 || response.statusCode === 302)) return [3 /*break*/, 4];
location_1 = response.headers.location || "";
if (options.method === "GET" && location_1.match(/^https:/)) {
const runningFetch = (async function () {
for (let attempt = 0; attempt < attemptLimit; attempt++) {
let response = null;
try {
response = await (0, geturl_1.getUrl)(url, options);
if (attempt < attemptLimit) {
if (response.statusCode === 301 ||
response.statusCode === 302) {
// Redirection; for now we only support absolute locataions
const location = response.headers.location || "";
if (options.method === "GET" &&
location.match(/^https:/)) {
url = response.headers.location;
return [3 /*break*/, 19];
continue;
}
return [3 /*break*/, 8];
case 4:
if (!(response.statusCode === 429)) return [3 /*break*/, 8];
tryAgain = true;
if (!throttleCallback) return [3 /*break*/, 6];
return [4 /*yield*/, throttleCallback(attempt, url)];
case 5:
tryAgain = _a.sent();
_a.label = 6;
case 6:
if (!tryAgain) return [3 /*break*/, 8];
stall = 0;
retryAfter = response.headers["retry-after"];
if (typeof (retryAfter) === "string" && retryAfter.match(/^[1-9][0-9]*$/)) {
stall = parseInt(retryAfter) * 1000;
}
else if (response.statusCode === 429) {
// Exponential back-off throttling
let tryAgain = true;
if (throttleCallback) {
tryAgain = await throttleCallback(attempt, url);
}
else {
stall = throttleSlotInterval * parseInt(String(Math.random() * Math.pow(2, attempt)));
if (tryAgain) {
let stall = 0;
const retryAfter = response.headers["retry-after"];
if (typeof retryAfter === "string" &&
retryAfter.match(/^[1-9][0-9]*$/)) {
stall = parseInt(retryAfter) * 1000;
}
else {
stall =
throttleSlotInterval *
parseInt(String(Math.random() *
Math.pow(2, attempt)));
}
//console.log("Stalling 429");
await staller(stall);
continue;
}
//console.log("Stalling 429");
return [4 /*yield*/, staller(stall)];
case 7:
//console.log("Stalling 429");
_a.sent();
return [3 /*break*/, 19];
case 8: return [3 /*break*/, 10];
case 9:
error_1 = _a.sent();
response = error_1.response;
if (response == null) {
runningTimeout.cancel();
logger.throwError("missing response", logger_1.Logger.errors.SERVER_ERROR, {
requestBody: bodyify(options.body, flatHeaders["content-type"]),
requestMethod: options.method,
serverError: error_1,
url: url
});
}
}
}
catch (error) {
response = error.response;
if (response == null) {
runningTimeout.cancel();
logger.throwError("missing response", logger_1.Logger.errors.SERVER_ERROR, {
requestBody: bodyify(options.body, flatHeaders["content-type"]),
requestMethod: options.method,
serverError: error,
url: url,
});
}
}
let body = response.body;
if (allow304 && response.statusCode === 304) {
body = null;
}
else if (!errorPassThrough &&
(response.statusCode < 200 || response.statusCode >= 300)) {
runningTimeout.cancel();
logger.throwError("bad response", logger_1.Logger.errors.SERVER_ERROR, {
status: response.statusCode,
headers: response.headers,
body: bodyify(body, response.headers
? response.headers["content-type"]
: null),
requestBody: bodyify(options.body, flatHeaders["content-type"]),
requestMethod: options.method,
url: url,
});
}
if (processFunc) {
try {
const result = await processFunc(body, response);
runningTimeout.cancel();
return result;
}
catch (error) {
// Allow the processFunc to trigger a throttle
if (error.throttleRetry && attempt < attemptLimit) {
let tryAgain = true;
if (throttleCallback) {
tryAgain = await throttleCallback(attempt, url);
}
return [3 /*break*/, 10];
case 10:
body_1 = response.body;
if (allow304 && response.statusCode === 304) {
body_1 = null;
if (tryAgain) {
const timeout = throttleSlotInterval *
parseInt(String(Math.random() * Math.pow(2, attempt)));
//console.log("Stalling callback");
await staller(timeout);
continue;
}
else if (!errorPassThrough && (response.statusCode < 200 || response.statusCode >= 300)) {
runningTimeout.cancel();
logger.throwError("bad response", logger_1.Logger.errors.SERVER_ERROR, {
status: response.statusCode,
headers: response.headers,
body: bodyify(body_1, ((response.headers) ? response.headers["content-type"] : null)),
requestBody: bodyify(options.body, flatHeaders["content-type"]),
requestMethod: options.method,
url: url
});
}
if (!processFunc) return [3 /*break*/, 18];
_a.label = 11;
case 11:
_a.trys.push([11, 13, , 18]);
return [4 /*yield*/, processFunc(body_1, response)];
case 12:
result = _a.sent();
runningTimeout.cancel();
return [2 /*return*/, result];
case 13:
error_2 = _a.sent();
if (!(error_2.throttleRetry && attempt < attemptLimit)) return [3 /*break*/, 17];
tryAgain = true;
if (!throttleCallback) return [3 /*break*/, 15];
return [4 /*yield*/, throttleCallback(attempt, url)];
case 14:
tryAgain = _a.sent();
_a.label = 15;
case 15:
if (!tryAgain) return [3 /*break*/, 17];
timeout_1 = throttleSlotInterval * parseInt(String(Math.random() * Math.pow(2, attempt)));
//console.log("Stalling callback");
return [4 /*yield*/, staller(timeout_1)];
case 16:
//console.log("Stalling callback");
_a.sent();
return [3 /*break*/, 19];
case 17:
runningTimeout.cancel();
logger.throwError("processing response error", logger_1.Logger.errors.SERVER_ERROR, {
body: bodyify(body_1, ((response.headers) ? response.headers["content-type"] : null)),
error: error_2,
requestBody: bodyify(options.body, flatHeaders["content-type"]),
requestMethod: options.method,
url: url
});
return [3 /*break*/, 18];
case 18:
runningTimeout.cancel();
// If we had a processFunc, it either returned a T or threw above.
// The "body" is now a Uint8Array.
return [2 /*return*/, body_1];
case 19:
attempt++;
return [3 /*break*/, 1];
case 20: return [2 /*return*/, logger.throwError("failed response", logger_1.Logger.errors.SERVER_ERROR, {
requestBody: bodyify(options.body, flatHeaders["content-type"]),
requestMethod: options.method,
url: url
})];
}
runningTimeout.cancel();
logger.throwError("processing response error", logger_1.Logger.errors.SERVER_ERROR, {
body: bodyify(body, response.headers
? response.headers["content-type"]
: null),
error: error,
requestBody: bodyify(options.body, flatHeaders["content-type"]),
requestMethod: options.method,
url: url,
});
}
});
}
runningTimeout.cancel();
// If we had a processFunc, it either returned a T or threw above.
// The "body" is now a Uint8Array.
return body;
}
return logger.throwError("failed response", logger_1.Logger.errors.SERVER_ERROR, {
requestBody: bodyify(options.body, flatHeaders["content-type"]),
requestMethod: options.method,
url: url,
});

@@ -352,6 +324,5 @@ })();

}
exports._fetchData = _fetchData;
function fetchJson(connection, json, processFunc) {
var processJsonFunc = function (value, response) {
var result = null;
let processJsonFunc = (value, response) => {
let result = null;
if (value != null) {

@@ -364,3 +335,3 @@ try {

body: value,
error: error
error: error,
});

@@ -377,9 +348,11 @@ }

// - convert the json to bytes
var body = null;
let body = null;
if (json != null) {
body = (0, strings_1.toUtf8Bytes)(json);
// Create a connection with the content-type set for JSON
var updated = (typeof (connection) === "string") ? ({ url: connection }) : (0, properties_1.shallowCopy)(connection);
const updated = typeof connection === "string"
? { url: connection }
: (0, properties_1.shallowCopy)(connection);
if (updated.headers) {
var hasContentType = (Object.keys(updated.headers).filter(function (k) { return (k.toLowerCase() === "content-type"); }).length) !== 0;
const hasContentType = Object.keys(updated.headers).filter((k) => k.toLowerCase() === "content-type").length !== 0;
if (!hasContentType) {

@@ -397,3 +370,2 @@ updated.headers = (0, properties_1.shallowCopy)(updated.headers);

}
exports.fetchJson = fetchJson;
function poll(func, options) {

@@ -414,6 +386,6 @@ if (!options) {

return new Promise(function (resolve, reject) {
var timer = null;
var done = false;
let timer = null;
let done = false;
// Returns true if cancel was successful. Unsuccessful cancel means we're already done.
var cancel = function () {
const cancel = () => {
if (done) {

@@ -429,3 +401,3 @@ return false;

if (options.timeout) {
timer = setTimeout(function () {
timer = setTimeout(() => {
if (cancel()) {

@@ -436,4 +408,4 @@ reject(new Error("timeout"));

}
var retryLimit = options.retryLimit;
var attempt = 0;
const retryLimit = options.retryLimit;
let attempt = 0;
function check() {

@@ -462,3 +434,4 @@ return func().then(function (result) {

}
var timeout = options.interval * parseInt(String(Math.random() * Math.pow(2, attempt)));
let timeout = options.interval *
parseInt(String(Math.random() * Math.pow(2, attempt)));
if (timeout < options.floor) {

@@ -482,3 +455,2 @@ timeout = options.floor;

}
exports.poll = poll;
//# sourceMappingURL=index.js.map

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

{"version":3,"file":"index.js","sourceRoot":"","sources":["../src.ts/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEb,uCAA8E;AAC9E,qCAAmD;AACnD,wDAAwD;AACxD,yCAA0D;AAE1D,gDAA+C;AAC/C,uCAAqC;AACrC,IAAM,MAAM,GAAG,IAAI,eAAM,CAAC,kBAAO,CAAC,CAAC;AAEnC,mCAA2D;AAE3D,SAAS,OAAO,CAAC,QAAgB;IAC7B,OAAO,IAAI,OAAO,CAAC,UAAC,OAAO;QACvB,UAAU,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAClC,CAAC,CAAC,CAAC;AACP,CAAC;AAED,SAAS,OAAO,CAAC,KAAU,EAAE,IAAY;IACrC,IAAI,KAAK,IAAI,IAAI,EAAE;QAAE,OAAO,IAAI,CAAC;KAAE;IAEnC,IAAI,OAAM,CAAC,KAAK,CAAC,KAAK,QAAQ,EAAE;QAAE,OAAO,KAAK,CAAC;KAAE;IAEjD,IAAI,IAAA,mBAAW,EAAC,KAAK,CAAC,EAAE;QACpB,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,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AC;oBACV,IAAI,OAAO,GAAG,UAAU,EAAE,CAAC;wBACvB,IAAI,MAAM,EAAE,EAAE,CAAC;4BACX,MAAM,CAAC,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC,CAAC;wBAC7C,CAAC;wBACD,OAAO;oBACX,CAAC;oBAED,IAAI,OAAO,GACP,OAAO,CAAC,QAAQ;wBAChB,QAAQ,CACJ,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAC/C,CAAC;oBACN,IAAI,OAAO,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;wBAC1B,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC;oBAC5B,CAAC;oBACD,IAAI,OAAO,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;wBAC5B,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;oBAC9B,CAAC;oBAED,UAAU,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;gBAC/B,CAAC;gBAED,OAAO,IAAI,CAAC;YAChB,CAAC,EACD,UAAU,KAAK;gBACX,IAAI,MAAM,EAAE,EAAE,CAAC;oBACX,MAAM,CAAC,KAAK,CAAC,CAAC;gBAClB,CAAC;YACL,CAAC,CACJ,CAAC;QACN,CAAC;QACD,KAAK,EAAE,CAAC;IACZ,CAAC,CAAC,CAAC;AACP,CAAC"}

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

export declare type GetUrlResponse = {
export type GetUrlResponse = {
statusCode: number;

@@ -9,3 +9,3 @@ statusMessage: string;

};
export declare type Options = {
export type Options = {
method?: string;

@@ -12,0 +12,0 @@ allowGzip?: boolean;

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

{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src.ts/types.ts"],"names":[],"mappings":"AAEA,oBAAY,cAAc,GAAG;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE;QAAE,CAAE,GAAG,EAAE,MAAM,GAAI,MAAM,CAAA;KAAE,CAAC;IACrC,IAAI,EAAE,UAAU,CAAC;CACpB,CAAC;AAEF,oBAAY,OAAO,GAAG;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,OAAO,CAAC,EAAE;QAAE,CAAE,GAAG,EAAE,MAAM,GAAI,MAAM,CAAA;KAAE,CAAC;IACtC,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACzC,CAAC"}
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src.ts/types.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,cAAc,GAAG;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IACnC,IAAI,EAAE,UAAU,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,OAAO,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IACpC,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACzC,CAAC"}
{
"_ethers.alias": {
"geturl.js": "browser-geturl.js"
},
"author": "Eugene Kuleshov",
"browser": {
"./lib/geturl": "./lib/browser-geturl.js"
},
"dependencies": {
"@ethersproject/logger": "^5.7.0",
"@ethersproject/properties": "^5.7.0",
"@qevm/base64": "^5.7.0",
"@qevm/bytes": "5.7.1",
"@qevm/strings": "^5.7.0"
},
"description": "Utility fucntions for managing web requests for ethers.",
"keywords": [
"Ethereum",
"qethers"
],
"license": "MIT",
"main": "./lib/index.js",
"module": "./lib.esm/index.js",
"name": "@qevm/web",
"publishConfig": {
"access": "public"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"sideEffects": false,
"tarballHash": "0x37945bd0bcbf905a641db7e631bb538570042dbe6513e1e4cdd088f25b4ec274",
"types": "./lib/index.d.ts",
"version": "5.7.2",
"devDependencies": {
"@types/node": "^22.15.30"
}
"_ethers.alias": {
"geturl.js": "browser-geturl.js"
},
"contributors": [
"Eugene Kuleshov <kulevgen32@gmail.com>",
"Richard Moore <me@ricmoo.com>"
],
"browser": {
"./lib/geturl": "./lib/browser-geturl.js"
},
"dependencies": {
"@qevm/logger": "^5.7.1",
"@qevm/properties": "^5.7.1",
"@qevm/base64": "^5.7.1",
"@qevm/bytes": "^5.7.2",
"@qevm/strings": "^5.7.2"
},
"description": "Utility fucntions for managing web requests for qethers.",
"keywords": [
"QuantumEVM",
"QEVM",
"qethers"
],
"license": "MIT",
"main": "./lib/index.js",
"module": "./lib.esm/index.js",
"name": "@qevm/web",
"publishConfig": {
"access": "public"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"sideEffects": false,
"tarballHash": "0x37945bd0bcbf905a641db7e631bb538570042dbe6513e1e4cdd088f25b4ec274",
"types": "./lib/index.d.ts",
"version": "5.7.3",
"devDependencies": {
"@types/node": "^22.15.30"
}
}
Web Utilities
=============
This sub-module is part of the [ethers project](https://github.com/ethers-io/ethers.js).
This sub-module is part of the qethers, a fork of [ethers project](https://github.com/ethers-io/ethers.js).

@@ -9,3 +9,2 @@ It contains functions to abstract safely and responsibly connecting to the web,

For more information, see the [documentation](https://docs.ethers.io/v5/api/utils/web/).

@@ -15,3 +14,3 @@ Importing

Most users will prefer to use the [umbrella package](https://www.npmjs.com/package/ethers),
Most users will prefer to use the [umbrella package](https://www.npmjs.com/package/@qevm/qethers),
but for those with more specific needs, individual components can be imported.

@@ -34,3 +33,3 @@

} = require("@ethersproject/web");
} = require("@qevm/web");
```

@@ -37,0 +36,0 @@

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

export const version = "web/5.7.1";
export const version = "web/5.7.3";

@@ -9,26 +9,41 @@ "use strict";

export async function getUrl(href: string, options?: Options): Promise<GetUrlResponse> {
if (options == null) { options = { }; }
export async function getUrl(
href: string,
options?: Options,
): Promise<GetUrlResponse> {
if (options == null) {
options = {};
}
const request: RequestInit = {
method: (options.method || "GET"),
headers: (options.headers || { }),
body: (options.body || undefined),
method: options.method || "GET",
headers: options.headers || {},
body: options.body || undefined,
};
if (options.skipFetchSetup !== true) {
request.mode = <RequestMode>"cors"; // no-cors, cors, *same-origin
request.cache = <RequestCache>"no-cache"; // *default, no-cache, reload, force-cache, only-if-cached
request.credentials = <RequestCredentials>"same-origin"; // include, *same-origin, omit
request.redirect = <RequestRedirect>"follow"; // manual, *follow, error
request.referrer = "client"; // no-referrer, *client
};
request.mode = <RequestMode>"cors"; // no-cors, cors, *same-origin
request.cache = <RequestCache>"no-cache"; // *default, no-cache, reload, force-cache, only-if-cached
request.credentials = <RequestCredentials>"same-origin"; // include, *same-origin, omit
request.redirect = <RequestRedirect>"follow"; // manual, *follow, error
request.referrer = "client"; // no-referrer, *client
}
if (options.fetchOptions != null) {
const opts = options.fetchOptions;
if (opts.mode) { request.mode = <RequestMode>(opts.mode); }
if (opts.cache) { request.cache = <RequestCache>(opts.cache); }
if (opts.credentials) { request.credentials = <RequestCredentials>(opts.credentials); }
if (opts.redirect) { request.redirect = <RequestRedirect>(opts.redirect); }
if (opts.referrer) { request.referrer = opts.referrer; }
if (opts.mode) {
request.mode = <RequestMode>opts.mode;
}
if (opts.cache) {
request.cache = <RequestCache>opts.cache;
}
if (opts.credentials) {
request.credentials = <RequestCredentials>opts.credentials;
}
if (opts.redirect) {
request.redirect = <RequestRedirect>opts.redirect;
}
if (opts.referrer) {
request.referrer = opts.referrer;
}
}

@@ -39,3 +54,3 @@

const headers: { [ name: string ]: string } = { };
const headers: { [name: string]: string } = {};
if (response.headers.forEach) {

@@ -46,3 +61,3 @@ response.headers.forEach((value, key) => {

} else {
(<() => Array<string>>((<any>(response.headers)).keys))().forEach((key) => {
(<() => Array<string>>(<any>response.headers).keys)().forEach((key) => {
headers[key.toLowerCase()] = response.headers.get(key);

@@ -57,3 +72,3 @@ });

body: arrayify(new Uint8Array(body)),
}
};
}

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

import { gunzipSync } from "zlib";
import { parse } from "url"
import { parse } from "url";
import { arrayify, concat } from "@qevm/bytes";
import { shallowCopy } from "@ethersproject/properties";
import { shallowCopy } from "@qevm/properties";
import type { GetUrlResponse, Options } from "./types";
import { Logger } from "@ethersproject/logger";
import { Logger } from "@qevm/logger";
import { version } from "./_version";

@@ -26,11 +26,14 @@ const logger = new Logger(version);

statusMessage: resp.statusMessage,
headers: Object.keys(resp.headers).reduce((accum, name) => {
let value = resp.headers[name];
if (Array.isArray(value)) {
value = value.join(", ");
}
accum[name] = value;
return accum;
}, <{ [ name: string ]: string }>{ }),
body: null
headers: Object.keys(resp.headers).reduce(
(accum, name) => {
let value = resp.headers[name];
if (Array.isArray(value)) {
value = value.join(", ");
}
accum[name] = value;
return accum;
},
<{ [name: string]: string }>{},
),
body: null,
};

@@ -40,4 +43,6 @@ //resp.setEncoding("utf8");

resp.on("data", (chunk: Uint8Array) => {
if (response.body == null) { response.body = new Uint8Array(0); }
response.body = concat([ response.body, chunk ]);
if (response.body == null) {
response.body = new Uint8Array(0);
}
response.body = concat([response.body, chunk]);
});

@@ -61,3 +66,5 @@

request.on("error", (error) => { reject(error); });
request.on("error", (error) => {
reject(error);
});
});

@@ -68,8 +75,15 @@ }

function nonnull(value: string): string {
if (value == null) { return ""; }
if (value == null) {
return "";
}
return value;
}
export async function getUrl(href: string, options?: Options): Promise<GetUrlResponse> {
if (options == null) { options = { }; }
export async function getUrl(
href: string,
options?: Options,
): Promise<GetUrlResponse> {
if (options == null) {
options = {};
}

@@ -85,6 +99,6 @@ // @TODO: Once we drop support for node 8, we can pass the href

port: nonnull(url.port),
path: (nonnull(url.pathname) + nonnull(url.search)),
path: nonnull(url.pathname) + nonnull(url.search),
method: (options.method || "GET"),
headers: shallowCopy(options.headers || { }),
method: options.method || "GET",
headers: shallowCopy(options.headers || {}),
};

@@ -106,6 +120,10 @@

/* istanbul ignore next */
logger.throwError(`unsupported protocol ${ url.protocol }`, Logger.errors.UNSUPPORTED_OPERATION, {
protocol: url.protocol,
operation: "request"
});
logger.throwError(
`unsupported protocol ${url.protocol}`,
Logger.errors.UNSUPPORTED_OPERATION,
{
protocol: url.protocol,
operation: "request",
},
);
}

@@ -121,2 +139,1 @@

}

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

import { hexlify, isBytesLike } from "@qevm/bytes";
import { shallowCopy } from "@ethersproject/properties";
import { shallowCopy } from "@qevm/properties";
import { toUtf8Bytes, toUtf8String } from "@qevm/strings";
import { Logger } from "@ethersproject/logger";
import { Logger } from "@qevm/logger";
import { version } from "./_version";

@@ -22,11 +22,19 @@ const logger = new Logger(version);

function bodyify(value: any, type: string): string {
if (value == null) { return null; }
if (value == null) {
return null;
}
if (typeof(value) === "string") { return value; }
if (typeof value === "string") {
return value;
}
if (isBytesLike(value)) {
if (type && (type.split("/")[0] === "text" || type.split(";")[0].trim() === "application/json")) {
if (
type &&
(type.split("/")[0] === "text" ||
type.split(";")[0].trim() === "application/json")
) {
try {
return toUtf8String(value);
} catch (error) { };
} catch (error) {}
}

@@ -41,14 +49,14 @@ return hexlify(value);

export type ConnectionInfo = {
url: string,
headers?: { [key: string]: string | number }
url: string;
headers?: { [key: string]: string | number };
user?: string,
password?: string,
user?: string;
password?: string;
allowInsecureAuthentication?: boolean,
allowGzip?: boolean,
allowInsecureAuthentication?: boolean;
allowGzip?: boolean;
throttleLimit?: number,
throttleLimit?: number;
throttleSlotInterval?: number;
throttleCallback?: (attempt: number, url: string) => Promise<boolean>,
throttleCallback?: (attempt: number, url: string) => Promise<boolean>;

@@ -59,3 +67,3 @@ skipFetchSetup?: boolean;

timeout?: number,
timeout?: number;
};

@@ -72,9 +80,9 @@

export type PollOptions = {
timeout?: number,
floor?: number,
ceiling?: number,
interval?: number,
retryLimit?: number,
onceBlock?: OnceBlockable
oncePoll?: OncePollable
timeout?: number;
floor?: number;
ceiling?: number;
interval?: number;
retryLimit?: number;
onceBlock?: OnceBlockable;
oncePoll?: OncePollable;
};

@@ -84,12 +92,13 @@

statusCode: number;
headers: { [ header: string ]: string };
headers: { [header: string]: string };
};
type Header = { key: string; value: string };
type Header = { key: string, value: string };
function unpercent(value: string): Uint8Array {
return toUtf8Bytes(value.replace(/%([0-9a-f][0-9a-f])/gi, (all, code) => {
return String.fromCharCode(parseInt(code, 16));
}));
return toUtf8Bytes(
value.replace(/%([0-9a-f][0-9a-f])/gi, (all, code) => {
return String.fromCharCode(parseInt(code, 16));
}),
);
}

@@ -103,17 +112,37 @@

// For this reason, it should be considered internal until the API is finalized
export function _fetchData<T = Uint8Array>(connection: string | ConnectionInfo, body?: Uint8Array, processFunc?: (value: Uint8Array, response: FetchJsonResponse) => T): Promise<T> {
export function _fetchData<T = Uint8Array>(
connection: string | ConnectionInfo,
body?: Uint8Array,
processFunc?: (value: Uint8Array, response: FetchJsonResponse) => T,
): Promise<T> {
// How many times to retry in the event of a throttle
const attemptLimit = (typeof(connection) === "object" && connection.throttleLimit != null) ? connection.throttleLimit: 12;
logger.assertArgument((attemptLimit > 0 && (attemptLimit % 1) === 0),
"invalid connection throttle limit", "connection.throttleLimit", attemptLimit);
const attemptLimit =
typeof connection === "object" && connection.throttleLimit != null
? connection.throttleLimit
: 12;
logger.assertArgument(
attemptLimit > 0 && attemptLimit % 1 === 0,
"invalid connection throttle limit",
"connection.throttleLimit",
attemptLimit,
);
const throttleCallback = ((typeof(connection) === "object") ? connection.throttleCallback: null);
const throttleSlotInterval = ((typeof(connection) === "object" && typeof(connection.throttleSlotInterval) === "number") ? connection.throttleSlotInterval: 100);
logger.assertArgument((throttleSlotInterval > 0 && (throttleSlotInterval % 1) === 0),
"invalid connection throttle slot interval", "connection.throttleSlotInterval", throttleSlotInterval);
const throttleCallback =
typeof connection === "object" ? connection.throttleCallback : null;
const throttleSlotInterval =
typeof connection === "object" &&
typeof connection.throttleSlotInterval === "number"
? connection.throttleSlotInterval
: 100;
logger.assertArgument(
throttleSlotInterval > 0 && throttleSlotInterval % 1 === 0,
"invalid connection throttle slot interval",
"connection.throttleSlotInterval",
throttleSlotInterval,
);
const errorPassThrough = ((typeof(connection) === "object") ? !!(connection.errorPassThrough): false);
const errorPassThrough =
typeof connection === "object" ? !!connection.errorPassThrough : false;
const headers: { [key: string]: Header } = { };
const headers: { [key: string]: Header } = {};

@@ -131,8 +160,11 @@ let url: string = null;

if (typeof(connection) === "string") {
if (typeof connection === "string") {
url = connection;
} else if (typeof(connection) === "object") {
} else if (typeof connection === "object") {
if (connection == null || connection.url == null) {
logger.throwArgumentError("missing URL", "connection.url", connection);
logger.throwArgumentError(
"missing URL",
"connection.url",
connection,
);
}

@@ -142,3 +174,3 @@

if (typeof(connection.timeout) === "number" && connection.timeout > 0) {
if (typeof connection.timeout === "number" && connection.timeout > 0) {
timeout = connection.timeout;

@@ -149,4 +181,11 @@ }

for (const key in connection.headers) {
headers[key.toLowerCase()] = { key: key, value: String(connection.headers[key]) };
if (["if-none-match", "if-modified-since"].indexOf(key.toLowerCase()) >= 0) {
headers[key.toLowerCase()] = {
key: key,
value: String(connection.headers[key]),
};
if (
["if-none-match", "if-modified-since"].indexOf(
key.toLowerCase(),
) >= 0
) {
allow304 = true;

@@ -160,7 +199,15 @@ }

if (connection.user != null && connection.password != null) {
if (url.substring(0, 6) !== "https:" && connection.allowInsecureAuthentication !== true) {
if (
url.substring(0, 6) !== "https:" &&
connection.allowInsecureAuthentication !== true
) {
logger.throwError(
"basic authentication requires a secure https url",
Logger.errors.INVALID_ARGUMENT,
{ argument: "url", url: url, user: connection.user, password: "[REDACTED]" }
{
argument: "url",
url: url,
user: connection.user,
password: "[REDACTED]",
},
);

@@ -172,3 +219,3 @@ }

key: "Authorization",
value: "Basic " + base64Encode(toUtf8Bytes(authorization))
value: "Basic " + base64Encode(toUtf8Bytes(authorization)),
};

@@ -187,3 +234,3 @@ }

const reData = new RegExp("^data:([^;:]*)?(;base64)?,(.*)$", "i");
const dataMatch = ((url) ? url.match(reData): null);
const dataMatch = url ? url.match(reData) : null;
if (dataMatch) {

@@ -194,20 +241,25 @@ try {

statusMessage: "OK",
headers: { "content-type": (dataMatch[1] || "text/plain")},
body: (dataMatch[2] ? base64Decode(dataMatch[3]): unpercent(dataMatch[3]))
headers: { "content-type": dataMatch[1] || "text/plain" },
body: dataMatch[2]
? base64Decode(dataMatch[3])
: unpercent(dataMatch[3]),
};
let result: T = <T><unknown>response.body;
let result: T = <T>(<unknown>response.body);
if (processFunc) {
result = processFunc(response.body, response);
}
return Promise.resolve(<T><unknown>result);
return Promise.resolve(<T>(<unknown>result));
} catch (error) {
logger.throwError("processing response error", Logger.errors.SERVER_ERROR, {
body: bodyify(dataMatch[1], dataMatch[2]),
error: error,
requestBody: null,
requestMethod: "GET",
url: url
});
logger.throwError(
"processing response error",
Logger.errors.SERVER_ERROR,
{
body: bodyify(dataMatch[1], dataMatch[2]),
error: error,
requestBody: null,
requestMethod: "GET",
url: url,
},
);
}

@@ -220,10 +272,16 @@ }

if (headers["content-type"] == null) {
headers["content-type"] = { key: "Content-Type", value: "application/octet-stream" };
headers["content-type"] = {
key: "Content-Type",
value: "application/octet-stream",
};
}
if (headers["content-length"] == null) {
headers["content-length"] = { key: "Content-Length", value: String(body.length) };
headers["content-length"] = {
key: "Content-Length",
value: String(body.length),
};
}
}
const flatHeaders: { [ key: string ]: string } = { };
const flatHeaders: { [key: string]: string } = {};
Object.keys(headers).forEach((key) => {

@@ -235,16 +293,23 @@ const header = headers[key];

const runningTimeout = (function() {
const runningTimeout = (function () {
let timer: NodeJS.Timeout = null;
const promise: Promise<never> = new Promise(function(resolve, reject) {
const promise: Promise<never> = new Promise(function (resolve, reject) {
if (timeout) {
timer = setTimeout(() => {
if (timer == null) { return; }
if (timer == null) {
return;
}
timer = null;
reject(logger.makeError("timeout", Logger.errors.TIMEOUT, {
requestBody: bodyify(options.body, flatHeaders["content-type"]),
requestMethod: options.method,
timeout: timeout,
url: url
}));
reject(
logger.makeError("timeout", Logger.errors.TIMEOUT, {
requestBody: bodyify(
options.body,
flatHeaders["content-type"],
),
requestMethod: options.method,
timeout: timeout,
url: url,
}),
);
}, timeout);

@@ -254,7 +319,9 @@ }

const cancel = function() {
if (timer == null) { return; }
const cancel = function () {
if (timer == null) {
return;
}
clearTimeout(timer);
timer = null;
}
};

@@ -264,4 +331,3 @@ return { promise, cancel };

const runningFetch = (async function() {
const runningFetch = (async function () {
for (let attempt = 0; attempt < attemptLimit; attempt++) {

@@ -274,10 +340,15 @@ let response: GetUrlResponse = null;

if (attempt < attemptLimit) {
if (response.statusCode === 301 || response.statusCode === 302) {
if (
response.statusCode === 301 ||
response.statusCode === 302
) {
// Redirection; for now we only support absolute locataions
const location = response.headers.location || "";
if (options.method === "GET" && location.match(/^https:/)) {
if (
options.method === "GET" &&
location.match(/^https:/)
) {
url = response.headers.location;
continue;
}
} else if (response.statusCode === 429) {

@@ -294,6 +365,16 @@ // Exponential back-off throttling

const retryAfter = response.headers["retry-after"];
if (typeof(retryAfter) === "string" && retryAfter.match(/^[1-9][0-9]*$/)) {
if (
typeof retryAfter === "string" &&
retryAfter.match(/^[1-9][0-9]*$/)
) {
stall = parseInt(retryAfter) * 1000;
} else {
stall = throttleSlotInterval * parseInt(String(Math.random() * Math.pow(2, attempt)));
stall =
throttleSlotInterval *
parseInt(
String(
Math.random() *
Math.pow(2, attempt),
),
);
}

@@ -307,3 +388,2 @@

}
} catch (error) {

@@ -313,12 +393,18 @@ response = (<any>error).response;

runningTimeout.cancel();
logger.throwError("missing response", Logger.errors.SERVER_ERROR, {
requestBody: bodyify(options.body, flatHeaders["content-type"]),
requestMethod: options.method,
serverError: error,
url: url
});
logger.throwError(
"missing response",
Logger.errors.SERVER_ERROR,
{
requestBody: bodyify(
options.body,
flatHeaders["content-type"],
),
requestMethod: options.method,
serverError: error,
url: url,
},
);
}
}
let body = response.body;

@@ -328,3 +414,6 @@

body = null;
} else if (!errorPassThrough && (response.statusCode < 200 || response.statusCode >= 300)) {
} else if (
!errorPassThrough &&
(response.statusCode < 200 || response.statusCode >= 300)
) {
runningTimeout.cancel();

@@ -334,6 +423,14 @@ logger.throwError("bad response", Logger.errors.SERVER_ERROR, {

headers: response.headers,
body: bodyify(body, ((response.headers) ? response.headers["content-type"]: null)),
requestBody: bodyify(options.body, flatHeaders["content-type"]),
body: bodyify(
body,
response.headers
? response.headers["content-type"]
: null,
),
requestBody: bodyify(
options.body,
flatHeaders["content-type"],
),
requestMethod: options.method,
url: url
url: url,
});

@@ -347,3 +444,2 @@ }

return result;
} catch (error) {

@@ -358,3 +454,9 @@ // Allow the processFunc to trigger a throttle

if (tryAgain) {
const timeout = throttleSlotInterval * parseInt(String(Math.random() * Math.pow(2, attempt)));
const timeout =
throttleSlotInterval *
parseInt(
String(
Math.random() * Math.pow(2, attempt),
),
);
//console.log("Stalling callback");

@@ -367,9 +469,21 @@ await staller(timeout);

runningTimeout.cancel();
logger.throwError("processing response error", Logger.errors.SERVER_ERROR, {
body: bodyify(body, ((response.headers) ? response.headers["content-type"]: null)),
error: error,
requestBody: bodyify(options.body, flatHeaders["content-type"]),
requestMethod: options.method,
url: url
});
logger.throwError(
"processing response error",
Logger.errors.SERVER_ERROR,
{
body: bodyify(
body,
response.headers
? response.headers["content-type"]
: null,
),
error: error,
requestBody: bodyify(
options.body,
flatHeaders["content-type"],
),
requestMethod: options.method,
url: url,
},
);
}

@@ -385,13 +499,21 @@ }

return logger.throwError("failed response", Logger.errors.SERVER_ERROR, {
requestBody: bodyify(options.body, flatHeaders["content-type"]),
requestMethod: options.method,
url: url
});
return logger.throwError(
"failed response",
Logger.errors.SERVER_ERROR,
{
requestBody: bodyify(options.body, flatHeaders["content-type"]),
requestMethod: options.method,
url: url,
},
);
})();
return Promise.race([ runningTimeout.promise, runningFetch ]);
return Promise.race([runningTimeout.promise, runningFetch]);
}
export function fetchJson(connection: string | ConnectionInfo, json?: string, processFunc?: (value: any, response: FetchJsonResponse) => any): Promise<any> {
export function fetchJson(
connection: string | ConnectionInfo,
json?: string,
processFunc?: (value: any, response: FetchJsonResponse) => any,
): Promise<any> {
let processJsonFunc = (value: Uint8Array, response: FetchJsonResponse) => {

@@ -405,3 +527,3 @@ let result: any = null;

body: value,
error: error
error: error,
});

@@ -416,3 +538,3 @@ }

return result;
}
};

@@ -427,5 +549,11 @@ // If we have json to send, we must

// Create a connection with the content-type set for JSON
const updated: ConnectionInfo = (typeof(connection) === "string") ? ({ url: connection }): shallowCopy(connection);
const updated: ConnectionInfo =
typeof connection === "string"
? { url: connection }
: shallowCopy(connection);
if (updated.headers) {
const hasContentType = (Object.keys(updated.headers).filter((k) => (k.toLowerCase() === "content-type")).length) !== 0;
const hasContentType =
Object.keys(updated.headers).filter(
(k) => k.toLowerCase() === "content-type",
).length !== 0;
if (!hasContentType) {

@@ -444,11 +572,21 @@ updated.headers = shallowCopy(updated.headers);

export function poll<T>(func: () => Promise<T>, options?: PollOptions): Promise<T> {
if (!options) { options = {}; }
export function poll<T>(
func: () => Promise<T>,
options?: PollOptions,
): Promise<T> {
if (!options) {
options = {};
}
options = shallowCopy(options);
if (options.floor == null) { options.floor = 0; }
if (options.ceiling == null) { options.ceiling = 10000; }
if (options.interval == null) { options.interval = 250; }
if (options.floor == null) {
options.floor = 0;
}
if (options.ceiling == null) {
options.ceiling = 10000;
}
if (options.interval == null) {
options.interval = 250;
}
return new Promise(function(resolve, reject) {
return new Promise(function (resolve, reject) {
let timer: NodeJS.Timeout = null;

@@ -459,5 +597,9 @@ let done: boolean = false;

const cancel = (): boolean => {
if (done) { return false; }
if (done) {
return false;
}
done = true;
if (timer) { clearTimeout(timer); }
if (timer) {
clearTimeout(timer);
}
return true;

@@ -468,4 +610,6 @@ };

timer = setTimeout(() => {
if (cancel()) { reject(new Error("timeout")); }
}, options.timeout)
if (cancel()) {
reject(new Error("timeout"));
}
}, options.timeout);
}

@@ -477,33 +621,47 @@

function check() {
return func().then(function(result: any): any {
return func().then(
function (result: any): any {
// If we have a result, or are allowed null then we're done
if (result !== undefined) {
if (cancel()) {
resolve(result);
}
} else if (options.oncePoll) {
options.oncePoll.once("poll", check);
} else if (options.onceBlock) {
options.onceBlock.once("block", check);
// If we have a result, or are allowed null then we're done
if (result !== undefined) {
if (cancel()) { resolve(result); }
// Otherwise, exponential back-off (up to 10s) our next request
} else if (!done) {
attempt++;
if (attempt > retryLimit) {
if (cancel()) {
reject(new Error("retry limit reached"));
}
return;
}
} else if (options.oncePoll) {
options.oncePoll.once("poll", check);
let timeout =
options.interval *
parseInt(
String(Math.random() * Math.pow(2, attempt)),
);
if (timeout < options.floor) {
timeout = options.floor;
}
if (timeout > options.ceiling) {
timeout = options.ceiling;
}
} else if (options.onceBlock) {
options.onceBlock.once("block", check);
setTimeout(check, timeout);
}
// Otherwise, exponential back-off (up to 10s) our next request
} else if (!done) {
attempt++;
if (attempt > retryLimit) {
if (cancel()) { reject(new Error("retry limit reached")); }
return;
return null;
},
function (error) {
if (cancel()) {
reject(error);
}
let timeout = options.interval * parseInt(String(Math.random() * Math.pow(2, attempt)));
if (timeout < options.floor) { timeout = options.floor; }
if (timeout > options.ceiling) { timeout = options.ceiling; }
setTimeout(check, timeout);
}
return null;
}, function(error) {
if (cancel()) { reject(error); }
});
},
);
}

@@ -513,2 +671,1 @@ check();

}

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

statusMessage: string;
headers: { [ key: string] : string };
headers: { [key: string]: string };
body: Uint8Array;

@@ -15,6 +15,5 @@ };

body?: Uint8Array;
headers?: { [ key: string] : string };
headers?: { [key: string]: string };
skipFetchSetup?: boolean;
fetchOptions?: Record<string, string>;
};