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.3.0 to 0.4.0

4

package.json
{
"name": "@usebruno/js",
"version": "0.3.0",
"version": "0.4.0",
"main": "src/index.js",

@@ -19,2 +19,3 @@ "files": [

"atob": "^2.1.2",
"axios": "^0.26.0",
"btoa": "^1.2.1",

@@ -26,4 +27,5 @@ "crypto-js": "^4.1.1",

"nanoid": "3.3.4",
"node-fetch": "2.*",
"uuid": "^9.0.0"
}
}

@@ -8,2 +8,6 @@

getProcessEnv(key) {
return process.env[key];
}
getEnvVar(key) {

@@ -20,3 +24,3 @@ return this._envVariables[key];

if(!this._envVariables.hasOwnProperty(key)) {
return;
return;
}

@@ -40,2 +44,2 @@

module.exports = Bru;
module.exports = Bru;
class BrunoResponse {
constructor(res) {
this.res = res;
this.status = res.status;
this.statusText = res.statusText;
this.headers = res.headers;
this.body = res.data;
this.status = res ? res.status : null;
this.statusText = res ? res.statusText : null;
this.headers = res ? res.headers : null;
this.body = res ? res.data : null;
}
getStatus() {
return this.res.status;
return this.res ? this.res.status : null;
}
getHeader(name) {
return this.res.header[name];
return (this.res && this.res.headers) ? this.res.headers[name] : null;
}
getHeaders() {
return this.res.headers;
return this.res ? this.res.headers : null;
}
getBody() {
return this.res.data;
return this.res ? this.res.data : null;
}

@@ -25,0 +25,0 @@ }

const { NodeVM } = require('vm2');
const path = require('path');
const http = require('http');
const https = require('https');
const stream = require('stream');
const util = require('util');
const zlib = require('zlib');
const url = require('url');
const punycode = require('punycode');
const Bru = require('../bru');

@@ -14,2 +21,4 @@ const BrunoRequest = require('../bruno-request');

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

@@ -21,6 +30,5 @@

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

@@ -37,2 +45,12 @@ bru,

mock: {
// node libs
path,
stream,
util,
url,
http,
https,
punycode,
zlib,
// 3rd party libs
atob,

@@ -44,2 +62,4 @@ btoa,

nanoid,
axios,
'node-fetch': fetch,
'crypto-js': CryptoJS

@@ -49,5 +69,4 @@ }

});
vm.run(script, path.join(collectionPath, 'vm.js'));
const asyncVM = vm.run(`module.exports = async () => { ${script} }`, path.join(collectionPath, 'vm.js'));
await asyncVM();
return {

@@ -60,3 +79,3 @@ request,

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

@@ -84,2 +103,4 @@ const req = new BrunoRequest(request);

nanoid,
axios,
'node-fetch': fetch,
'crypto-js': CryptoJS

@@ -90,3 +111,4 @@ }

vm.run(script, path.join(collectionPath, 'vm.js'));
const asyncVM = vm.run(`module.exports = async () => { ${script} }`, path.join(collectionPath, 'vm.js'));
await asyncVM();

@@ -93,0 +115,0 @@ return {

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