usebruno / bruno

Opensource IDE For Exploring and Testing Api's (lightweight alternative to postman/insomnia)
https://www.usebruno.com/
MIT License
27.24k stars 1.25k forks source link

Couldn't import external library 'cose-js': Error invoking remote method 'send-http-request': VMError: Operation not allowed on contextified object. #1784

Open orached opened 8 months ago

orached commented 8 months ago

Hello,

I have been working on Bruno couple of weeks now and I really like it.

Currently I'm facing a problem for importing a specific external library 'cose-js'. I managed to import and use others like "@peculiar/webcrypto' or 'jose" by following this discussion.

But for the "cose-js" I have the following error: Error invoking remote method 'send-http-request': VMError: Operation not allowed on contextified object.

My script looks like this:

`const { TextDecoder, TextEncoder } = require('node:util'); global.TextEncoder = TextEncoder; global.TextDecoder = TextDecoder;

// Library to base64 encoding const btoa = require('btoa');

// External lib for COSE signature const { Cose } = require('cose-js'); const cose = new Cose();

const { Crypto } = require("@peculiar/webcrypto"); const crypto = new Crypto();

const keys = await crypto.subtle.generateKey( { name: "ECDSA", namedCurve: "P-256", // P-256, P-384, or P-521 }, false, ["sign", "verify"], );

//... rest of the pre-script ...`

and the bruno.json: { "version": "1", "name": "myCollection", "type": "collection", "scripts": { "moduleWhitelist": [ "cose-js", "crypto", "process", "buffer" ], "filesystemAccess": { "allow": true } }, "ignore": [ "node_modules", ".git" ] }

The error occurs right when I try to import the library const { Cose } = require('cose-js');

I went through this discussion, but couldn't find a solution for my problem.

Glazzix commented 2 months ago

Hello, I'm just beginning to use Bruno and I run into the same issue, with 2 other libraries. I whitelisted it but nothing seems to work. Did you find any solution ?

Streamlinesx commented 1 month ago

Also running into this issue when trying to work with IMAP libraries to fetch emails