rsa = new RSAServer({bits: 1024})
app.get("/publickey", rsa.publish)
Error:
TypeError: Cannot read properties of undefined (reading 'publicKey')
at publish (/home/username/project/node_modules/rsa-bridge/dist/modules/server.js:20:23)
at Layer.handle [as handle_request] (/home/username/project/node_modules/express/lib/router/layer.js:95:5)
at next (/home/username/project/node_modules/express/lib/router/route.js:149:13)
at Route.dispatch (/home/username/project/node_modules/express/lib/router/route.js:119:3)
at Layer.handle [as handle_request] (/home/username/project/node_modules/express/lib/router/layer.js:95:5)
at /home/username/project/node_modules/express/lib/router/index.js:284:15
at Function.process_params (/home/username/project/node_modules/express/lib/router/index.js:346:12)
at next (/home/username/project/node_modules/express/lib/router/index.js:280:10)
at expressInit (/home/username/project/node_modules/express/lib/middleware/init.js:40:5)
at Layer.handle [as handle_request] (/home/username/project/node_modules/express/lib/router/layer.js:95:5)
Publish function:
/** Returns an http handler responsible for exposing the public key of the RSA service */
publish(_: any, res: any) {
if (typeof res?.contentType === "function") res.contentType("text");
if (typeof res?.status === "function") res.status(200);
return res?.json({
key: this.publicKey("public"),
format: "public",
});
}
Run:
Error:
TypeError: Cannot read properties of undefined (reading 'publicKey') at publish (/home/username/project/node_modules/rsa-bridge/dist/modules/server.js:20:23) at Layer.handle [as handle_request] (/home/username/project/node_modules/express/lib/router/layer.js:95:5) at next (/home/username/project/node_modules/express/lib/router/route.js:149:13) at Route.dispatch (/home/username/project/node_modules/express/lib/router/route.js:119:3) at Layer.handle [as handle_request] (/home/username/project/node_modules/express/lib/router/layer.js:95:5) at /home/username/project/node_modules/express/lib/router/index.js:284:15 at Function.process_params (/home/username/project/node_modules/express/lib/router/index.js:346:12) at next (/home/username/project/node_modules/express/lib/router/index.js:280:10) at expressInit (/home/username/project/node_modules/express/lib/middleware/init.js:40:5) at Layer.handle [as handle_request] (/home/username/project/node_modules/express/lib/router/layer.js:95:5)
Publish function: