I have a nodejs module i have created using neon rust, that uses JsBox, and queue async feature. I also have an electron react app, my current mainjs looks like this:
function createWindow() {
const mainWindow = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
nodeIntegration: true,
contextIsolation: true,
webSecurity: false,
preload: path.join(__dirname, 'preload.js')
}
})
mainWindow.loadURL(
isDev ? "http://localhost:3000" : `file://${path.join(__dirname, "../build/index.html")}`
)
// Open the DevTools.
// mainWindow.webContents.openDevTools()
}
In preloadjs i have mapped the module to a class like this:
const shinny_spoon_service = require('../../shiny-spoon-service/lib/index')
class Cracker {
constructor(hash, threads, callback) {
this._cracker = shinny_spoon_service.cracker_new(hash, threads, callback)
}
get_counter() {
return shinny_spoon_service.get_counter(this._cracker)
}
cracker_crack_using_password_file(algorithm,file_path,buff_size){
return shinny_spoon_service.cracker_crack_using_password_file(this._cracker,algorithm,file_path,buff_size)
}
}
when i pass the class to the renderer process using the context bridge
contextBridge.exposeInMainWorld(
"api",
{
shiny_spoon: shinny_spoon_service,
nativeImage: nativeImage,
Cracker: Cracker,
send: (channel, data) => {
// whitelist channels
let validChannels = ["getFile", "open-error-dialog"];
if (validChannels.includes(channel)) {
ipcRenderer.send(channel, data);
}
},
receive: (channel, func) => {
let validChannels = ["result-get-file", 'opened-error-dialog'];
if (validChannels.includes(channel)) {
// Deliberately strip event as it includes `sender`
ipcRenderer.on(channel, (event, args) => func(event, args));
}
},
sendSync: (channel, data) => {
// whitelist channels
let validChannels = ["getFile", "saveFile", "chooseFile"];
if (validChannels.includes(channel)) {
let result = ipcRenderer.sendSync(channel, data);
return result
}
},
}
)
I get the Error as shown in this image I would like to interact with the Class from the renderer process, but i don't know how to go about this