Socket
Socket
Sign inDemoInstall

debugbear

Package Overview
Dependencies
28
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.16 to 2.0.17

12

callApi.ts

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

import * as request from "request-promise";
import axios from "axios";

@@ -15,3 +15,3 @@ function getApiBaseUrl() {

}: {
method: string;
method: "get" | "post" | "delete";
path: string;

@@ -24,3 +24,3 @@ body?: any;

json: true,
body,
data: body,
url: getApiBaseUrl() + path,

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

try {
return await request(reqDetail);
return (await axios(reqDetail)).data;
} catch (err) {
let msg = err.message;
let msg = err.response?.data?.error || err.message;
if (err.response && err.response.body && err.response.body.error) {
msg = err.response.body.error;
}
throw Error(`Error making request ${method} ${path}: ${msg}`);
throw Error(`Error making request ${method.toUpperCase()} ${path}: ${msg}`);
}
}

@@ -41,2 +41,7 @@ import { callApi } from "./callApi";

const waitInterval = setInterval(() => {
// Keep printing output, because e.g. CircleCI cancels step after 10 mins without output
process.stdout.write(".");
}, 8 * 60 * 1000);
let resp;

@@ -50,3 +55,3 @@ while (!hasFinished) {

resp = await callApi({
method: "GET",
method: "get",
path: "/analysis/" + analysisId,

@@ -56,3 +61,4 @@ explicitApiKeyParam,

({ hasFinished } = resp);
if (timeWaited > 30 * 60 * 1000) {
if (timeWaited > 45 * 60 * 1000) {
clearInterval(waitInterval);
throw Error("Waiting for result timed out");

@@ -62,2 +68,3 @@ }

clearInterval(waitInterval);
return resp as AnalysisResultObject;

@@ -136,3 +143,3 @@ }

const project = await callApi({
method: "GET",
method: "get",
path: "/projects/" + projectId,

@@ -147,3 +154,3 @@ explicitApiKeyParam: this.apiKey,

const res = await callApi({
method: "GET",
method: "get",
path: "/projects",

@@ -159,3 +166,3 @@ explicitApiKeyParam: this.apiKey,

const page = await callApi({
method: "POST",
method: "post",
path: "/projects",

@@ -199,3 +206,3 @@ body: {

return callApi({
method: "POST",
method: "post",
path: `/projects/${projectId}/collaborators`,

@@ -209,3 +216,3 @@ body: { email },

return callApi({
method: "GET",
method: "get",
path: `/projects/${projectId}/collaborators`,

@@ -273,3 +280,3 @@ explicitApiKeyParam: this.apiKey,

const { analysis, resultUrl } = await callApi({
method: "POST",
method: "post",
path: "/page/" + pageId + "/analyze",

@@ -295,3 +302,3 @@ body: options,

return callApi({
method: "POST",
method: "post",
path: `/projects/${projectId}/pages`,

@@ -311,3 +318,3 @@ body: {

return callApi({
method: "DELETE",
method: "delete",
path: "/pages/" + pageId,

@@ -326,3 +333,3 @@ explicitApiKeyParam: this.apiKey,

return callApi({
method: "GET",
method: "get",
path:

@@ -329,0 +336,0 @@ `/page/${pageId}/metrics?` +

export declare function callApi({ method, path, body, explicitApiKeyParam, }: {
method: string;
method: "get" | "post" | "delete";
path: string;

@@ -4,0 +4,0 @@ body?: any;

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

exports.callApi = void 0;
var request = require("request-promise");
var axios_1 = require("axios");
function getApiBaseUrl() {

@@ -46,7 +46,8 @@ return (process.env.DEBUGBEAR_API_BASE_URL || "https://www.debugbear.com/api/v1");

function callApi(_a) {
var _b, _c;
var method = _a.method, path = _a.path, body = _a.body, explicitApiKeyParam = _a.explicitApiKeyParam;
return __awaiter(this, void 0, void 0, function () {
var reqDetail, err_1, msg;
return __generator(this, function (_b) {
switch (_b.label) {
return __generator(this, function (_d) {
switch (_d.label) {
case 0:

@@ -56,3 +57,3 @@ reqDetail = {

json: true,
body: body,
data: body,
url: getApiBaseUrl() + path,

@@ -67,14 +68,14 @@ headers: {

}
_b.label = 1;
_d.label = 1;
case 1:
_b.trys.push([1, 3, , 4]);
return [4 /*yield*/, request(reqDetail)];
case 2: return [2 /*return*/, _b.sent()];
_d.trys.push([1, 3, , 4]);
return [4 /*yield*/, axios_1.default(reqDetail)];
case 2: return [2 /*return*/, (_d.sent()).data];
case 3:
err_1 = _b.sent();
msg = err_1.message;
err_1 = _d.sent();
msg = ((_c = (_b = err_1.response) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.error) || err_1.message;
if (err_1.response && err_1.response.body && err_1.response.body.error) {
msg = err_1.response.body.error;
}
throw Error("Error making request " + method + " " + path + ": " + msg);
throw Error("Error making request " + method.toUpperCase() + " " + path + ": " + msg);
case 4: return [2 /*return*/];

@@ -81,0 +82,0 @@ }

@@ -10,2 +10,4 @@ "use strict";

return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);

@@ -94,3 +96,3 @@ function __() { this.constructor = d; }

return __awaiter(this, void 0, void 0, function () {
var hasFinished, timeWaited, interval, resp;
var hasFinished, timeWaited, interval, waitInterval, resp;
return __generator(this, function (_a) {

@@ -102,2 +104,6 @@ switch (_a.label) {

interval = 10000 * pollIntervalAdjustmentFactor;
waitInterval = setInterval(function () {
// Keep printing output, because e.g. CircleCI cancels step after 10 mins without output
process.stdout.write(".");
}, 8 * 60 * 1000);
_a.label = 1;

@@ -114,3 +120,3 @@ case 1:

return [4 /*yield*/, callApi_1.callApi({
method: "GET",
method: "get",
path: "/analysis/" + analysisId,

@@ -122,7 +128,10 @@ explicitApiKeyParam: explicitApiKeyParam,

(hasFinished = resp.hasFinished);
if (timeWaited > 30 * 60 * 1000) {
if (timeWaited > 45 * 60 * 1000) {
clearInterval(waitInterval);
throw Error("Waiting for result timed out");
}
return [3 /*break*/, 1];
case 4: return [2 /*return*/, resp];
case 4:
clearInterval(waitInterval);
return [2 /*return*/, resp];
}

@@ -165,3 +174,3 @@ });

case 0: return [4 /*yield*/, callApi_1.callApi({
method: "GET",
method: "get",
path: "/projects/" + projectId,

@@ -184,3 +193,3 @@ explicitApiKeyParam: this.apiKey,

case 0: return [4 /*yield*/, callApi_1.callApi({
method: "GET",
method: "get",
path: "/projects",

@@ -205,3 +214,3 @@ explicitApiKeyParam: this.apiKey,

case 0: return [4 /*yield*/, callApi_1.callApi({
method: "POST",
method: "post",
path: "/projects",

@@ -255,3 +264,3 @@ body: {

return callApi_1.callApi({
method: "POST",
method: "post",
path: "/projects/" + projectId + "/collaborators",

@@ -264,3 +273,3 @@ body: { email: email },

return callApi_1.callApi({
method: "GET",
method: "get",
path: "/projects/" + projectId + "/collaborators",

@@ -309,3 +318,3 @@ explicitApiKeyParam: this.apiKey,

case 4: return [4 /*yield*/, callApi_1.callApi({
method: "POST",
method: "post",
path: "/page/" + pageId + "/analyze",

@@ -329,3 +338,3 @@ body: options,

return callApi_1.callApi({
method: "POST",
method: "post",
path: "/projects/" + projectId + "/pages",

@@ -344,3 +353,3 @@ body: {

return callApi_1.callApi({
method: "DELETE",
method: "delete",
path: "/pages/" + pageId,

@@ -359,3 +368,3 @@ explicitApiKeyParam: this.apiKey,

return callApi_1.callApi({
method: "GET",
method: "get",
path: "/page/" + pageId + "/metrics?" +

@@ -362,0 +371,0 @@ queryString.stringify({

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

exports.getNgrokTunnelPublicUrl = void 0;
var request = require("request-promise");
var axios_1 = require("axios");
function getNgrokTunnelPublicUrl(ngrokAdminPort) {

@@ -47,9 +47,8 @@ return __awaiter(this, void 0, void 0, function () {

switch (_a.label) {
case 0: return [4 /*yield*/, request({
method: "GET",
json: true,
case 0: return [4 /*yield*/, axios_1.default({
method: "get",
url: "http://localhost:" + ngrokAdminPort + "/api/tunnels",
})];
case 1:
tunnelsResponse = _a.sent();
tunnelsResponse = (_a.sent()).data;
tunnel = tunnelsResponse.tunnels.filter(function (t) { return t.proto === "https"; })[0];

@@ -56,0 +55,0 @@ return [2 /*return*/, tunnel.public_url];

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

return __awaiter(this, void 0, void 0, function () {
var urlValue, program, baseUrl, err_1;
var urlValue, program, options, baseUrl, err_1;
return __generator(this, function (_a) {

@@ -52,3 +52,3 @@ switch (_a.label) {

program = commander
.arguments("<url>")
.arguments("[url]")
.option("--pageId <id>")

@@ -87,6 +87,4 @@ .option("--path <path>")

.parse(process.argv);
if (!program.pageId) {
console.log("--pageId option is required");
process.exit(1);
}
options = program.opts();
console.log({ options: options });
baseUrl = undefined;

@@ -101,5 +99,5 @@ _a.label = 1;

}, {
customHeaders: program.customHeader,
userFlowReplacements: program.userFlowReplacement,
}, lodash_1.pick(program, [
customHeaders: options.customHeader,
userFlowReplacements: options.userFlowReplacement,
}, lodash_1.pick(options, [
"pageId",

@@ -106,0 +104,0 @@ "waitForResult",

@@ -1,11 +0,12 @@

import * as request from "request-promise";
import axios from "axios";
export async function getNgrokTunnelPublicUrl(ngrokAdminPort) {
const tunnelsResponse = await request({
method: "GET",
json: true,
url: "http://localhost:" + ngrokAdminPort + "/api/tunnels",
});
const tunnelsResponse = (
await axios({
method: "get",
url: "http://localhost:" + ngrokAdminPort + "/api/tunnels",
})
).data;
const tunnel = tunnelsResponse.tunnels.filter((t) => t.proto === "https")[0];
return tunnel.public_url;
}
{
"name": "debugbear",
"version": "2.0.16",
"version": "2.0.17",
"description": "Use DebugBear to test web performance as part of your Continuous Integration process.",

@@ -13,12 +13,11 @@ "main": "dist/index.js",

"dependencies": {
"commander": "^2.19.0",
"axios": "^0.21.1",
"commander": "^7.2.0",
"env-ci": "^5.0.2",
"lodash": "^4.17.11",
"query-string": "^6.13.1",
"request": "^2.88.0",
"request-promise": "^4.2.2"
"lodash": "^4.17.21",
"query-string": "^7.0.0"
},
"devDependencies": {
"@types/node": "^10.17.28",
"typescript": "^3.9.7"
"typescript": "^4.2.4"
},

@@ -25,0 +24,0 @@ "bin": {

@@ -10,3 +10,3 @@ import * as commander from "commander";

const program = commander
.arguments("<url>")
.arguments("[url]")
.option("--pageId <id>")

@@ -62,6 +62,4 @@ .option("--path <path>")

if (!program.pageId) {
console.log("--pageId option is required");
process.exit(1);
}
const options = program.opts();
console.log({ options });

@@ -79,6 +77,6 @@ let baseUrl = undefined;

{
customHeaders: program.customHeader,
userFlowReplacements: program.userFlowReplacement,
customHeaders: options.customHeader,
userFlowReplacements: options.userFlowReplacement,
},
pick(program, [
pick(options, [
"pageId",

@@ -85,0 +83,0 @@ "waitForResult",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc