diff --git a/package-lock.json b/package-lock.json
index e225ab3b9a..3b57e938ac 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -23949,14 +23949,6 @@
"mini-svg-data-uri": "^1.2.3"
}
},
- "@tailwindcss/forms": {
- "version": "0.5.7",
- "resolved": "https://registry.npmjs.org/@tailwindcss/forms/-/forms-0.5.7.tgz",
- "integrity": "sha512-QE7X69iQI+ZXwldE+rzasvbJiyV/ju1FGHH0Qn2W3FKbuYtqp8LKcy6iSw79fVUT5/Vvf+0XgLCeYVG+UV6hOw==",
- "requires": {
- "mini-svg-data-uri": "^1.2.3"
- }
- },
"@tippyjs/react": {
"version": "4.2.6",
"requires": {
diff --git a/packages/bruno-app/src/components/ResponsePane/QueryResult/index.js b/packages/bruno-app/src/components/ResponsePane/QueryResult/index.js
index ee956f1b12..8f7d4835a8 100644
--- a/packages/bruno-app/src/components/ResponsePane/QueryResult/index.js
+++ b/packages/bruno-app/src/components/ResponsePane/QueryResult/index.js
@@ -114,7 +114,7 @@ const QueryResult = ({ item, collection, data, dataBuffer, width, disableRunEven
{error ? (
-
{error}
+
{error}
{error && typeof error === 'string' && error.toLowerCase().includes('self signed certificate') ? (
diff --git a/packages/bruno-cli/src/runner/run-single-request.js b/packages/bruno-cli/src/runner/run-single-request.js
index 5cdca9beb3..017292fd74 100644
--- a/packages/bruno-cli/src/runner/run-single-request.js
+++ b/packages/bruno-cli/src/runner/run-single-request.js
@@ -72,18 +72,16 @@ const runSingleRequest = async function (
get(collectionRoot, 'request.script.req'),
get(bruJson, 'request.script.req')
]).join(os.EOL);
- // TODO: Add feature Flag
- if (false) {
- const variables = {
- envVariables,
- collectionVariables,
- processEnvVars
- };
+ if (scriptingConfig?.runtime === 'node') {
const result = await runScript(
decomment(requestScriptFile),
request,
null,
- variables,
+ {
+ envVariables,
+ collectionVariables,
+ processEnvVars
+ },
false,
collectionPath,
scriptingConfig,
@@ -298,18 +296,16 @@ const runSingleRequest = async function (
get(collectionRoot, 'request.script.res'),
get(bruJson, 'request.script.res')
]).join(os.EOL);
- // TODO: Add feature flag
- if (false) {
- const variables = {
- envVariables,
- collectionVariables,
- processEnvVars
- };
+ if (scriptingConfig?.runtime === 'node') {
const result = await runScript(
decomment(responseScriptFile),
request,
response,
- variables,
+ {
+ envVariables,
+ collectionVariables,
+ processEnvVars
+ },
false,
collectionPath,
scriptingConfig,
@@ -366,11 +362,11 @@ const runSingleRequest = async function (
let testResults = [];
const testFile = compact([get(collectionRoot, 'request.tests'), get(bruJson, 'request.tests')]).join(os.EOL);
- if (false) {
+ if (scriptingConfig?.runtime === 'node') {
const result = await runScript(
decomment(testFile),
request,
- null,
+ response,
{
envVariables,
collectionVariables,
diff --git a/packages/bruno-electron/src/ipc/network/index.js b/packages/bruno-electron/src/ipc/network/index.js
index fb9c628b30..d72e98f2f7 100644
--- a/packages/bruno-electron/src/ipc/network/index.js
+++ b/packages/bruno-electron/src/ipc/network/index.js
@@ -11,7 +11,7 @@ const contentDispositionParser = require('content-disposition');
const mime = require('mime-types');
const { ipcMain } = require('electron');
const { isUndefined, isNull, each, get, compact, cloneDeep } = require('lodash');
-const { VarsRuntime, AssertRuntime, ScriptRuntime, TestRuntime } = require('@usebruno/js');
+const { VarsRuntime, AssertRuntime, ScriptRuntime, TestRuntime, runScript } = require('@usebruno/js');
const prepareRequest = require('./prepare-request');
const prepareCollectionRequest = require('./prepare-collection-request');
const prepareGqlIntrospectionRequest = require('./prepare-gql-introspection-request');
@@ -320,10 +320,9 @@ const registerNetworkIpc = (mainWindow) => {
}
// run pre-request script
- let scriptResult, nextRequestName;
+ let scriptResult;
const requestScript = compact([get(collectionRoot, 'request.script.req'), get(request, 'script.req')]).join(os.EOL);
- // TODO: Add feature flags
- if (false) {
+ if (scriptingConfig?.runtime === 'node') {
scriptResult = await runScript(
decomment(requestScript),
request,
@@ -415,17 +414,16 @@ const registerNetworkIpc = (mainWindow) => {
}
// run post-response script
- let scriptResult, nextRequestName;
+ let scriptResult;
const responseScript = compact([get(collectionRoot, 'request.script.res'), get(request, 'script.res')]).join(
os.EOL
);
- // TODO: Add feature flag
- if (false) {
+ if (scriptingConfig?.runtime === 'node') {
scriptResult = await runScript(
decomment(responseScript),
request,
- null,
+ response,
{
envVariables: envVars,
collectionVariables,
@@ -436,10 +434,6 @@ const registerNetworkIpc = (mainWindow) => {
scriptingConfig,
onConsoleLog
);
- if (scriptResult?.nextRequestName !== undefined) {
- nextRequestName = scriptResult.nextRequestName;
- }
-
mainWindow.webContents.send('main:script-environment-update', {
envVariables: scriptResult.envVariables,
collectionVariables: scriptResult.collectionVariables,
@@ -460,9 +454,12 @@ const registerNetworkIpc = (mainWindow) => {
processEnvVars,
scriptingConfig
);
- if (scriptResult?.nextRequestName !== undefined) {
- nextRequestName = scriptResult.nextRequestName;
- }
+ mainWindow.webContents.send('main:script-environment-update', {
+ envVariables: scriptResult.envVariables,
+ collectionVariables: scriptResult.collectionVariables,
+ requestUid,
+ collectionUid
+ });
}
}
return scriptResult;
@@ -631,12 +628,11 @@ const registerNetworkIpc = (mainWindow) => {
]).join(os.EOL);
if (typeof testFile === 'string') {
let testResults;
- // TODO: Add feature flag
- if (false) {
+ if (scriptingConfig?.runtime === 'node') {
testResults = await runScript(
decomment(testFile),
request,
- null,
+ response,
{
envVariables: envVars,
collectionVariables,
@@ -645,7 +641,7 @@ const registerNetworkIpc = (mainWindow) => {
true,
collectionPath,
scriptingConfig,
- null
+ onConsoleLog
);
} else {
const testRuntime = new TestRuntime();
@@ -1088,12 +1084,11 @@ const registerNetworkIpc = (mainWindow) => {
]).join(os.EOL);
if (typeof testFile === 'string') {
let testResults;
- // TODO: Add feature flag
- if (false) {
+ if (scriptingConfig?.runtime === 'node') {
testResults = await runScript(
decomment(testFile),
request,
- null,
+ response,
{
envVariables: envVars,
collectionVariables,
@@ -1102,7 +1097,7 @@ const registerNetworkIpc = (mainWindow) => {
true,
collectionPath,
scriptingConfig,
- null
+ onConsoleLog
);
} else {
const testRuntime = new TestRuntime();
diff --git a/packages/bruno-js/src/runtime/vm-helper.js b/packages/bruno-js/src/runtime/vm-helper.js
index 1e42026899..522a5d9fb0 100644
--- a/packages/bruno-js/src/runtime/vm-helper.js
+++ b/packages/bruno-js/src/runtime/vm-helper.js
@@ -139,7 +139,8 @@ const defaultModuleWhiteList = [
'axios',
'chai',
'crypto-js',
- 'node-vault'
+ 'node-vault',
+ 'node-fetch'
];
/**
@@ -155,7 +156,6 @@ function createCustomRequire(scriptingConfig, collectionPath) {
const allowScriptFilesystemAccess = get(scriptingConfig, 'filesystemAccess.allow', false);
if (allowScriptFilesystemAccess) {
- // TODO: Allow other modules like os, child_process etc too?
whitelistedModules.push('fs');
}
@@ -167,7 +167,7 @@ function createCustomRequire(scriptingConfig, collectionPath) {
additionalContextRootsAbsolute.push(collectionPath);
return (moduleName) => {
- // First check If we want to require a native node module or
+ // First check If we want to require a native node module or an internal node module
// Remove the "node:" prefix, to make sure "node:fs" and "fs" can be required, and we only need to whitelist one
if (whitelistedModules.includes(moduleName.replace(/^node:/, ''))) {
try {
@@ -195,12 +195,12 @@ function createCustomRequire(scriptingConfig, collectionPath) {
const fullScriptPath = path.join(contextRoot, moduleName);
try {
return require(fullScriptPath);
- } catch (error) {
- triedPaths.push({ fullScriptPath, error });
+ } catch {
+ triedPaths.push({ fullScriptPath });
}
}
- const triedPathsFormatted = triedPaths.map((i) => `- "${i.fullScriptPath}": ${i.error}\n`);
+ const triedPathsFormatted = triedPaths.map((i) => `- ${i.fullScriptPath}\n`);
throw new Error(`Failed to require "${moduleName}"!
If you tried to require a internal node module / external package, make sure its whitelisted in the "bruno.json" under "scriptConfig".
@@ -218,7 +218,7 @@ ${triedPathsFormatted}`);
function createCustomConsole(onConsoleLog) {
const customLogger = (type) => {
return (...args) => {
- onConsoleLog(type, cleanJson(args));
+ onConsoleLog && onConsoleLog(type, cleanJson(args));
};
};
return {