fix: makes node version undefined when process.version is undefined
Changes
Makes node version undefined when process.version is undefined. process.version can be undefined on some edge runtimes like cloudflare workers.
References
- Cloudflare Documentation
- https://github.com/auth0/node-auth0/issues/996
Testing
- Create a Node.js worker
- Instantiate an Auth0 client and perform a request with this client
Expected: No error should be thrown.
Checklist
- [x] I have read the Auth0 general contribution guidelines
- [x] I have read the Auth0 Code of Conduct
- [x] All existing and new tests complete without errors
Would also be nice to bump the jose dep too because of this line in v4: https://github.com/panva/jose/blob/051a18e13c9df98d0cfb7d9a7cca7f3746f23526/src/runtime/node/flags.ts#L1
My reading of the jose changelog suggests that v5 still supports Node.js 18, so I think it should be fine for a patch release of this library.
Btw, you can define these variables if you're using Cloudflare Workers.
Add this (or similar) to your wrangler.jsonc:
"define": {
"process.version": "\"v22.14.0\"",
"process.versions": "{ \"node\": \"22.14.0\" }"
},
And then these values will get injected at build time
Would also be nice to bump the
josedep too because of this line in v4: https://github.com/panva/jose/blob/051a18e13c9df98d0cfb7d9a7cca7f3746f23526/src/runtime/node/flags.ts#L1My reading of the
josechangelog suggests that v5 still supports Node.js 18, so I think it should be fine for a patch release of this library.
Yes, a JOSE update would be nice too. Perhaps in a separate PR? This PR has been open for 9 months now, so I’d prefer to get it merged first to address this issue quickly.
@tusharpandey13 @tanya732 Could someone review this?