debugbear
Advanced tools
Comparing version 2.0.2 to 2.0.3
const debugbear = require("./makeApiClient").makeApiClient; | ||
export async function analyzePage(options) { | ||
const dbbClient = debugbear(options.explicitApiKeyParam); | ||
if (!process.env.DEBUGBEAR_API_KEY) { | ||
throw Error( | ||
"Need to provide API key via DEBUGBEAR_API_KEY environment variable" | ||
); | ||
} | ||
const dbbClient = debugbear(process.env.DEBUGBEAR_API_KEY); | ||
if (!options) { | ||
@@ -6,0 +11,0 @@ console.log( |
@@ -17,3 +17,3 @@ import { analyzePage } from "./analyzePage"; | ||
async function waitForAnalysisResult(analysisId) { | ||
async function waitForAnalysisResult(analysisId, explicitApiKeyParam) { | ||
let hasFinished = false; | ||
@@ -28,3 +28,4 @@ let timeWaited = 0; | ||
method: "GET", | ||
path: "/analysis/" + analysisId | ||
path: "/analysis/" + analysisId, | ||
explicitApiKeyParam | ||
})); | ||
@@ -118,4 +119,4 @@ if (timeWaited > 10 * 60 * 1000) { | ||
url: resultUrl, | ||
waitForResult: async function() { | ||
waitForAnalysisResult(analysis.id); | ||
waitForResult: async () => { | ||
return waitForAnalysisResult(analysis.id, this.apiKey); | ||
} | ||
@@ -122,0 +123,0 @@ }; |
import * as request from "request-promise"; | ||
function getApiKey(explicitApiKeyParam) { | ||
if (explicitApiKeyParam) { | ||
return explicitApiKeyParam; | ||
} | ||
return process.env.DEBUGBEAR_API_KEY; | ||
} | ||
function getApiBaseUrl() { | ||
@@ -15,12 +9,2 @@ return ( | ||
function verifyHasApiKey(explicitApiKeyParam) { | ||
const apiKey = getApiKey(explicitApiKeyParam); | ||
if (!apiKey) { | ||
console.log( | ||
"You need to set the DEBUGBEAR_API_KEY environment variable. You can generate an API token on your project page on debugbear.com" | ||
); | ||
process.exit(1); | ||
} | ||
} | ||
export async function callApi({ | ||
@@ -37,4 +21,2 @@ method, | ||
}): Promise<any> { | ||
verifyHasApiKey(explicitApiKeyParam); | ||
const reqDetail = { | ||
@@ -46,3 +28,3 @@ method, | ||
headers: { | ||
"X-Api-Key": getApiKey(explicitApiKeyParam), | ||
"X-Api-Key": explicitApiKeyParam, | ||
"Cli-Version": require("../package.json").version | ||
@@ -57,3 +39,3 @@ } | ||
let msg = err.message; | ||
if (err.response.body.error) { | ||
if (err.response && err.response.body && err.response.body.error) { | ||
msg = err.response.body.error; | ||
@@ -60,0 +42,0 @@ } |
@@ -45,3 +45,6 @@ "use strict"; | ||
case 0: | ||
dbbClient = debugbear(options.explicitApiKeyParam); | ||
if (!process.env.DEBUGBEAR_API_KEY) { | ||
throw Error("Need to provide API key via DEBUGBEAR_API_KEY environment variable"); | ||
} | ||
dbbClient = debugbear(process.env.DEBUGBEAR_API_KEY); | ||
if (!options) { | ||
@@ -48,0 +51,0 @@ console.log("The pageId option is required. You can find the page ID in the top right corner on the results page."); |
@@ -50,3 +50,3 @@ "use strict"; | ||
exports.ApiClient = ApiClient; | ||
function waitForAnalysisResult(analysisId) { | ||
function waitForAnalysisResult(analysisId, explicitApiKeyParam) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
@@ -69,3 +69,4 @@ var hasFinished, timeWaited, interval; | ||
method: "GET", | ||
path: "/analysis/" + analysisId | ||
path: "/analysis/" + analysisId, | ||
explicitApiKeyParam: explicitApiKeyParam | ||
})]; | ||
@@ -157,2 +158,3 @@ case 3: | ||
var inferredBuildInfo, _a, _b, analysis, resultUrl; | ||
var _this = this; | ||
return __generator(this, function (_c) { | ||
@@ -195,10 +197,7 @@ switch (_c.label) { | ||
url: resultUrl, | ||
waitForResult: function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
waitForAnalysisResult(analysis.id); | ||
return [2 /*return*/]; | ||
}); | ||
waitForResult: function () { return __awaiter(_this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, waitForAnalysisResult(analysis.id, this.apiKey)]; | ||
}); | ||
} | ||
}); } | ||
}]; | ||
@@ -205,0 +204,0 @@ } |
@@ -39,18 +39,5 @@ "use strict"; | ||
var request = require("request-promise"); | ||
function getApiKey(explicitApiKeyParam) { | ||
if (explicitApiKeyParam) { | ||
return explicitApiKeyParam; | ||
} | ||
return process.env.DEBUGBEAR_API_KEY; | ||
} | ||
function getApiBaseUrl() { | ||
return (process.env.DEBUGBEAR_API_BASE_URL || "https://www.debugbear.com/api/v1"); | ||
} | ||
function verifyHasApiKey(explicitApiKeyParam) { | ||
var apiKey = getApiKey(explicitApiKeyParam); | ||
if (!apiKey) { | ||
console.log("You need to set the DEBUGBEAR_API_KEY environment variable. You can generate an API token on your project page on debugbear.com"); | ||
process.exit(1); | ||
} | ||
} | ||
function callApi(_a) { | ||
@@ -63,3 +50,2 @@ var method = _a.method, path = _a.path, body = _a.body, explicitApiKeyParam = _a.explicitApiKeyParam; | ||
case 0: | ||
verifyHasApiKey(explicitApiKeyParam); | ||
reqDetail = { | ||
@@ -71,3 +57,3 @@ method: method, | ||
headers: { | ||
"X-Api-Key": getApiKey(explicitApiKeyParam), | ||
"X-Api-Key": explicitApiKeyParam, | ||
"Cli-Version": require("../package.json").version | ||
@@ -84,3 +70,3 @@ } | ||
msg = err_1.message; | ||
if (err_1.response.body.error) { | ||
if (err_1.response && err_1.response.body && err_1.response.body.error) { | ||
msg = err_1.response.body.error; | ||
@@ -87,0 +73,0 @@ } |
{ | ||
"name": "debugbear", | ||
"version": "2.0.2", | ||
"version": "2.0.3", | ||
"description": "API/CLI for DebugBearAnalyze pages with DebugBear. Analyze pages on demand on demand or as part of your Continuous Integration process.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
4
42389
1000