diff --git a/package-lock.json b/package-lock.json index 900aacf45..ec70c1a2a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3928,39 +3928,6 @@ "node": ">=12" } }, - "node_modules/@n8n/vm2": { - "version": "3.9.23", - "resolved": "https://registry.npmjs.org/@n8n/vm2/-/vm2-3.9.23.tgz", - "integrity": "sha512-yu+It+L89uljQsCJ2e9cQaXzoXJe9bU69QQIoWUOcUw0u5Zon37DuB7bdNNsjKS1ZdFD+fBWCQpq/FkqHsSjXQ==", - "dependencies": { - "acorn": "^8.7.0", - "acorn-walk": "^8.2.0" - }, - "bin": { - "vm2": "bin/vm2" - }, - "engines": { - "node": ">=18.10", - "pnpm": ">=8.6.12" - } - }, - "node_modules/@n8n/vm2/node_modules/acorn": { - "version": "8.11.3", - "license": "MIT", - "bin": { - "acorn": "bin/acorn" - }, - "engines": { - "node": ">=0.4.0" - } - }, - "node_modules/@n8n/vm2/node_modules/acorn-walk": { - "version": "8.3.2", - "license": "MIT", - "engines": { - "node": ">=0.4.0" - } - }, "node_modules/@next/env": { "version": "12.3.3", "license": "MIT" @@ -17256,6 +17223,41 @@ "license": "MIT", "optional": true }, + "node_modules/vm2": { + "version": "3.9.19", + "resolved": "https://registry.npmjs.org/vm2/-/vm2-3.9.19.tgz", + "integrity": "sha512-J637XF0DHDMV57R6JyVsTak7nIL8gy5KH4r1HiwWLf/4GBbb5MKL5y7LpmF4A8E2nR6XmzpmMFQ7V7ppPTmUQg==", + "deprecated": "The library contains critical security issues and should not be used for production! The maintenance of the project has been discontinued. Consider migrating your code to isolated-vm.", + "dependencies": { + "acorn": "^8.7.0", + "acorn-walk": "^8.2.0" + }, + "bin": { + "vm2": "bin/vm2" + }, + "engines": { + "node": ">=6.0" + } + }, + "node_modules/vm2/node_modules/acorn": { + "version": "8.11.3", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.3.tgz", + "integrity": "sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg==", + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/vm2/node_modules/acorn-walk": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.2.tgz", + "integrity": "sha512-cjkyv4OtNCIeqhHrfS81QWXoCBPExR/J62oyEqepVw8WaQeSqpW2uhuLPh1m9eWhDuOo/jUXVTlifvesOWp/4A==", + "engines": { + "node": ">=0.4.0" + } + }, "node_modules/vscode-languageserver-types": { "version": "3.17.2", "license": "MIT" @@ -17950,7 +17952,6 @@ "version": "1.4.0", "license": "MIT", "dependencies": { - "@n8n/vm2": "^3.9.23", "@usebruno/common": "0.1.0", "@usebruno/js": "0.10.0", "@usebruno/lang": "0.9.0", @@ -17967,6 +17968,7 @@ "mustache": "^4.2.0", "qs": "^6.11.0", "socks-proxy-agent": "^8.0.2", + "vm2": "^3.9.13", "xmlbuilder": "^15.1.1", "yargs": "^17.6.2" }, @@ -18058,7 +18060,6 @@ "version": "v1.7.0", "dependencies": { "@aws-sdk/credential-providers": "^3.425.0", - "@n8n/vm2": "^3.9.23", "@usebruno/common": "0.1.0", "@usebruno/js": "0.10.0", "@usebruno/lang": "0.9.0", @@ -18091,6 +18092,7 @@ "socks-proxy-agent": "^8.0.2", "tough-cookie": "^4.1.3", "uuid": "^9.0.0", + "vm2": "^3.9.13", "yup": "^0.32.11" }, "devDependencies": { @@ -21134,23 +21136,6 @@ "@n1ru4l/push-pull-async-iterable-iterator": { "version": "3.2.0" }, - "@n8n/vm2": { - "version": "3.9.23", - "resolved": "https://registry.npmjs.org/@n8n/vm2/-/vm2-3.9.23.tgz", - "integrity": "sha512-yu+It+L89uljQsCJ2e9cQaXzoXJe9bU69QQIoWUOcUw0u5Zon37DuB7bdNNsjKS1ZdFD+fBWCQpq/FkqHsSjXQ==", - "requires": { - "acorn": "^8.7.0", - "acorn-walk": "^8.2.0" - }, - "dependencies": { - "acorn": { - "version": "8.11.3" - }, - "acorn-walk": { - "version": "8.3.2" - } - } - }, "@next/env": { "version": "12.3.3" }, @@ -22289,7 +22274,6 @@ "@usebruno/cli": { "version": "file:packages/bruno-cli", "requires": { - "@n8n/vm2": "^3.9.23", "@usebruno/common": "0.1.0", "@usebruno/js": "0.10.0", "@usebruno/lang": "0.9.0", @@ -22306,6 +22290,7 @@ "mustache": "^4.2.0", "qs": "^6.11.0", "socks-proxy-agent": "^8.0.2", + "vm2": "^3.9.13", "xmlbuilder": "^15.1.1", "yargs": "^17.6.2" }, @@ -23283,7 +23268,6 @@ "version": "file:packages/bruno-electron", "requires": { "@aws-sdk/credential-providers": "^3.425.0", - "@n8n/vm2": "^3.9.23", "@usebruno/common": "0.1.0", "@usebruno/js": "0.10.0", "@usebruno/lang": "0.9.0", @@ -23320,6 +23304,7 @@ "socks-proxy-agent": "^8.0.2", "tough-cookie": "^4.1.3", "uuid": "^9.0.0", + "vm2": "^3.9.13", "yup": "^0.32.11" }, "dependencies": { @@ -30204,6 +30189,27 @@ } } }, + "vm2": { + "version": "3.9.19", + "resolved": "https://registry.npmjs.org/vm2/-/vm2-3.9.19.tgz", + "integrity": "sha512-J637XF0DHDMV57R6JyVsTak7nIL8gy5KH4r1HiwWLf/4GBbb5MKL5y7LpmF4A8E2nR6XmzpmMFQ7V7ppPTmUQg==", + "requires": { + "acorn": "^8.7.0", + "acorn-walk": "^8.2.0" + }, + "dependencies": { + "acorn": { + "version": "8.11.3", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.3.tgz", + "integrity": "sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg==" + }, + "acorn-walk": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.2.tgz", + "integrity": "sha512-cjkyv4OtNCIeqhHrfS81QWXoCBPExR/J62oyEqepVw8WaQeSqpW2uhuLPh1m9eWhDuOo/jUXVTlifvesOWp/4A==" + } + } + }, "vscode-languageserver-types": { "version": "3.17.2" }, diff --git a/packages/bruno-cli/package.json b/packages/bruno-cli/package.json index b24b0758d..312627d2a 100644 --- a/packages/bruno-cli/package.json +++ b/packages/bruno-cli/package.json @@ -24,7 +24,6 @@ "package.json" ], "dependencies": { - "@n8n/vm2": "^3.9.23", "@usebruno/common": "0.1.0", "@usebruno/js": "0.10.0", "@usebruno/lang": "0.9.0", @@ -41,6 +40,7 @@ "mustache": "^4.2.0", "qs": "^6.11.0", "socks-proxy-agent": "^8.0.2", + "vm2": "^3.9.13", "xmlbuilder": "^15.1.1", "yargs": "^17.6.2" } diff --git a/packages/bruno-electron/package.json b/packages/bruno-electron/package.json index afa511254..c36cf24fb 100644 --- a/packages/bruno-electron/package.json +++ b/packages/bruno-electron/package.json @@ -52,7 +52,7 @@ "socks-proxy-agent": "^8.0.2", "tough-cookie": "^4.1.3", "uuid": "^9.0.0", - "@n8n/vm2": "^3.9.23", + "vm2": "^3.9.13", "yup": "^0.32.11" }, "optionalDependencies": { diff --git a/packages/bruno-js/src/runtime/script-runtime.js b/packages/bruno-js/src/runtime/script-runtime.js index 23ff530e9..8df51d793 100644 --- a/packages/bruno-js/src/runtime/script-runtime.js +++ b/packages/bruno-js/src/runtime/script-runtime.js @@ -1,4 +1,4 @@ -const { NodeVM } = require('@n8n/vm2'); +const { NodeVM } = require('vm2'); const path = require('path'); const http = require('http'); const https = require('https'); diff --git a/packages/bruno-js/src/runtime/test-runtime.js b/packages/bruno-js/src/runtime/test-runtime.js index d8d686975..cc46fd14c 100644 --- a/packages/bruno-js/src/runtime/test-runtime.js +++ b/packages/bruno-js/src/runtime/test-runtime.js @@ -1,4 +1,4 @@ -const { NodeVM } = require('@n8n/vm2'); +const { NodeVM } = require('vm2'); const chai = require('chai'); const path = require('path'); const http = require('http'); diff --git a/packages/bruno-tests/collection/.nvmrc b/packages/bruno-tests/collection/.nvmrc new file mode 100644 index 000000000..0828ab794 --- /dev/null +++ b/packages/bruno-tests/collection/.nvmrc @@ -0,0 +1 @@ +v18 \ No newline at end of file diff --git a/packages/bruno-tests/collection/package-lock.json b/packages/bruno-tests/collection/package-lock.json new file mode 100644 index 000000000..717181ec3 --- /dev/null +++ b/packages/bruno-tests/collection/package-lock.json @@ -0,0 +1,30 @@ +{ + "name": "@usebruno/test-collection", + "version": "0.0.1", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "@usebruno/test-collection", + "version": "0.0.1", + "dependencies": { + "@faker-js/faker": "^8.4.0" + } + }, + "node_modules/@faker-js/faker": { + "version": "8.4.0", + "resolved": "https://registry.npmjs.org/@faker-js/faker/-/faker-8.4.0.tgz", + "integrity": "sha512-htW87352wzUCdX1jyUQocUcmAaFqcR/w082EC8iP/gtkF0K+aKcBp0hR5Arb7dzR8tQ1TrhE9DNa5EbJELm84w==", + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/fakerjs" + } + ], + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0", + "npm": ">=6.14.13" + } + } + } +} diff --git a/packages/bruno-tests/collection/package.json b/packages/bruno-tests/collection/package.json new file mode 100644 index 000000000..23621129b --- /dev/null +++ b/packages/bruno-tests/collection/package.json @@ -0,0 +1,7 @@ +{ + "name": "@usebruno/test-collection", + "version": "0.0.1", + "dependencies": { + "@faker-js/faker": "^8.4.0" + } +} diff --git a/packages/bruno-tests/collection/scripting/npm modules/fakerjs.bru b/packages/bruno-tests/collection/scripting/npm modules/fakerjs.bru new file mode 100644 index 000000000..f621ce546 --- /dev/null +++ b/packages/bruno-tests/collection/scripting/npm modules/fakerjs.bru @@ -0,0 +1,45 @@ +meta { + name: fakerjs + type: http + seq: 1 +} + +post { + url: {{host}}/api/echo/json + body: json + auth: none +} + +body:json { + { + "hello": "bruno" + } +} + +assert { + res.status: eq 200 +} + +script:pre-request { + const { faker } = require('@faker-js/faker'); + const uuid = faker.string.uuid(); + + const data = req.getBody(); + data.uuid = uuid; + + req.setBody(data); +} + +tests { + test("should return json", function() { + const data = res.getBody(); + const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i; + const isUUID = (inputString) => { + return uuidRegex.test(inputString); + }; + + expect(data.hello).to.equal("bruno"); + expect(isUUID(data.uuid)).to.be.true; + }); + +}