State of the crypto package in the new forge runtime?

Doing some preliminary testing with forge apps and I’m attempting to use the github octokit library to make some calls out to github, but I’m getting an error during authentication:

ReferenceError: crypto is not defined
at getToken (webpack://compass-data-provider/node_modules/universal-github-app-jwt/dist-web/index.js:48:1)
at githubAppJwt (webpack://compass-data-provider/node_modules/universal-github-app-jwt/dist-web/index.js:68:1

I’ve seen some discussions around the crypto package being incomplete in the forge environment. Is this still the case with the new nodejs18.x runtime?

Any guidance would be appreciated, thanks.

@amackinnon,

I confirm your impression. The “original” Forge Runtime was a custom Node.js implementation with many libraries that were intentionally implemented for security. Crypto wasn’t necessarily intentional but it was incomplete/incompatible for many libraries. That is why the “Native Node.js runtime” exists, to use a real implementation of Node.js and push the security concerns out of the runtime and into the infrastructure configuration. I would recommend that option for your scenario.

1 Like

Thanks for the quick reply, I didn’t word my initial question too well. I actually am using the new runtime (at least I think I am, I have app.runtime.name = nodejs18.x in my manifest and I’m using the latest forge packages.) Should I not see this error in the new runtime?

1 Like