Open omniwuyi opened 6 years ago
Easiest solution is to generate randomness separately and pass it in directly. See for example: https://github.com/openpgpjs/openpgpjs/blob/c9d837cf8a316d2b4041c209e7fd815edbd38890/src/crypto/public_key/elliptic/curves.js#L196-L207 ps: it's not the best idea that the randomness length is hardcoded in there. I'll fix it soon.
any update on the fix?
+1
It happens because the testing framework you are using assumes you are running the test in the browser, but you are running the code in the node environment. Go to package.json and if you are running the tests with jest for example type
"jest" : { "testEnvironment : "node" }
Replace it according to the test framework you are using.
Copy-pasta ready
{
"name": ...,
"scripts": {
...
},
"dependencies": {
...
},
"devDependencies": {
...
},
"jest": {
"testEnvironment": "node"
}
}
(package.json)
It happens because the testing framework you are using assumes you are running the test in the browser, but you are running the code in the node environment. Go to package.json and if you are running the tests with jest for example type
"jest" : { "testEnvironment : "node" }
Replace it according to the test framework you are using.
Unfortunately getting the same error event after trying your solution. Using node version 12.14.0
I am having the same issue developing an app in electron using Vue My package.json file includes this:
"jest": {
"setupFiles": [
"<rootDir>/jest.init.ts"
],
"preset": "@vue/cli-plugin-unit-jest/presets/typescript-and-babel",
"testEnvironment": "node"
}
and the jest.init.ts
is
import Vuetify from "vuetify";
import Vue from "vue";
import development from "./src/config/development";
import { EnvironmentConfig } from "./src/types/EnvironmentConfigInterface";
import axios, { AxiosInstance } from "axios";
import endpoints from "./src/shared/endpoints";
import Endpoints from "./src/types/EndpointsInterface";
import VueApexCharts from "vue-apexcharts";
Vue.prototype.$axios = axios;
Vue.prototype.$endpoints = endpoints;
Vue.prototype.$config = Object.freeze(development);
import store from "./src/store";
Vue.prototype.$store = store;
declare module "vue/types/vue" {
interface Vue {
$config: EnvironmentConfig;
$axios: AxiosInstance;
$endpoints: Endpoints;
}
}
Vue.component("apexchart", VueApexCharts);
Vue.use(Vuetify);
Vue.config.productionTip = false;
If I remove the ""setupFiles"
key in the package.json, then the error disappears
I hope this may be of help to debug and fix the issue
Hi there
I'm new here, hope this is the right place to raise an issue.
I am using this lib for a node.js backend project (no browser involved), but when calling the genKeyPair() function, it throws the error below. Looking into the brorand index.js, it throws an error if it is safari. I have been searching for a solution, but couldn't find one. Hope you guys can shed some light. Thanks!
my env:
--------------Error for invoking genKeyPair -------------------------------------- Not implemented yet
-------------- The brorand code throws the above error ------
// Safari's WebWorkers do not have
crypto
} else if (typeof window === 'object') { // Old junk Rand.prototype._rand = function() { throw new Error('Not implemented yet'); }; }