Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@usebruno/js

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@usebruno/js - npm Package Compare versions

Comparing version 0.5.0 to 0.6.0

license.md

5

package.json
{
"name": "@usebruno/js",
"version": "0.5.0",
"version": "0.6.0",
"license": "MIT",
"main": "src/index.js",

@@ -21,3 +22,5 @@ "files": [

"btoa": "^1.2.1",
"chai": "^4.3.7",
"crypto-js": "^4.1.1",
"handlebars": "^4.7.8",
"json-query": "^2.2.2",

@@ -24,0 +27,0 @@ "lodash": "^4.17.21",

26

src/bru.js

@@ -0,7 +1,27 @@

const Handlebars = require('handlebars');
const { cloneDeep } = require('lodash');
class Bru {
constructor(envVariables, collectionVariables) {
constructor(envVariables, collectionVariables, processEnvVars) {
this.envVariables = envVariables;
this.collectionVariables = collectionVariables;
this.processEnvVars = cloneDeep(processEnvVars || {});
}
_interpolateEnvVar = (str) => {
if (!str || !str.length || typeof str !== 'string') {
return str;
}
const template = Handlebars.compile(str, { noEscape: true });
return template({
process: {
env: {
...this.processEnvVars
}
}
});
};
getEnvName() {

@@ -12,7 +32,7 @@ return this.envVariables.__name__;

getProcessEnv(key) {
return process.env[key];
return this.processEnvVars[key];
}
getEnvVar(key) {
return this.envVariables[key];
return this._interpolateEnvVar(this.envVariables[key]);
}

@@ -19,0 +39,0 @@

@@ -24,2 +24,3 @@ const { NodeVM } = require('vm2');

const fetch = require('node-fetch');
const chai = require('chai');
const CryptoJS = require('crypto-js');

@@ -30,4 +31,12 @@

async runRequestScript(script, request, envVariables, collectionVariables, collectionPath, onConsoleLog) {
const bru = new Bru(envVariables, collectionVariables);
async runRequestScript(
script,
request,
envVariables,
collectionVariables,
collectionPath,
onConsoleLog,
processEnvVars
) {
const bru = new Bru(envVariables, collectionVariables, processEnvVars);
const req = new BrunoRequest(request);

@@ -78,2 +87,3 @@

axios,
chai,
'node-fetch': fetch,

@@ -93,4 +103,13 @@ 'crypto-js': CryptoJS

async runResponseScript(script, request, response, envVariables, collectionVariables, collectionPath, onConsoleLog) {
const bru = new Bru(envVariables, collectionVariables);
async runResponseScript(
script,
request,
response,
envVariables,
collectionVariables,
collectionPath,
onConsoleLog,
processEnvVars
) {
const bru = new Bru(envVariables, collectionVariables, processEnvVars);
const req = new BrunoRequest(request);

@@ -97,0 +116,0 @@ const res = new BrunoResponse(response);

@@ -23,4 +23,13 @@ const { NodeVM } = require('vm2');

runTests(testsFile, request, response, envVariables, collectionVariables, collectionPath, onConsoleLog) {
const bru = new Bru(envVariables, collectionVariables);
runTests(
testsFile,
request,
response,
envVariables,
collectionVariables,
collectionPath,
onConsoleLog,
processEnvVars
) {
const bru = new Bru(envVariables, collectionVariables, processEnvVars);
const req = new BrunoRequest(request);

@@ -78,2 +87,3 @@ const res = new BrunoResponse(response);

nanoid,
chai,
'crypto-js': CryptoJS

@@ -80,0 +90,0 @@ }

@@ -7,3 +7,3 @@ const _ = require('lodash');

class VarsRuntime {
runPreRequestVars(vars, request, envVariables, collectionVariables, collectionPath) {
runPreRequestVars(vars, request, envVariables, collectionVariables, collectionPath, processEnvVars) {
const enabledVars = _.filter(vars, (v) => v.enabled);

@@ -14,3 +14,3 @@ if (!enabledVars.length) {

const bru = new Bru(envVariables, collectionVariables);
const bru = new Bru(envVariables, collectionVariables, processEnvVars);
const req = new BrunoRequest(request);

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

runPostResponseVars(vars, request, response, envVariables, collectionVariables, collectionPath) {
runPostResponseVars(vars, request, response, envVariables, collectionVariables, collectionPath, processEnvVars) {
const enabledVars = _.filter(vars, (v) => v.enabled);

@@ -46,3 +46,3 @@ if (!enabledVars.length) {

const bru = new Bru(envVariables, collectionVariables);
const bru = new Bru(envVariables, collectionVariables, processEnvVars);
const req = new BrunoRequest(request);

@@ -49,0 +49,0 @@ const res = createResponseParser(response);

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc