Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 this issue Mar 13, 2024 · 4 comments

Comments

@orached
Copy link

orached commented Mar 13, 2024

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
Copy link

Glazzix commented Aug 30, 2024

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
Copy link

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

@jackweyhrich
Copy link

Seeing the same issue when attempting to require pino for some custom logging. Whitelisting did not resolve the issue.

@hendstephen
Copy link

+1 to this. Getting the same error with node:os even after whitelisting.

Error: Error invoking remote method 'send-http-request': VMError: Cannot find module 'node:os'

image

const { AzureCliCredential } = require("@azure/identity");
if (res.status === 401) {
  const creds = new AzureCliCredential();
  const token = await creds.getToken(bru.getEnvVar("ResourceId"));
  bru.setEnvVar("BearerToken", token.token);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants