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

46 views Asked by At

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".

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.

0

There are 0 answers