-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Version 9.0.0 - sign
function throws error on frontend (in browser)
#863
Comments
sign
function throws error on frontend (in browser)sign
function throws error on frontend (in browser)
It is better to rely on JWT modules made to be consumed in browser environments. You can discover such modules on jwt.io under "JavaScript" libraries. |
I had the same issue that's because I am using Node.js v8, which doesn't include KeyObject in 'crypto' module. There are two ways to fix this issue: 1) update your node version to above v11; 2) don't use the latest version of jsonwebtoken. |
I'm seeing a similar error after upgrading from I'll report back once I try moving over to a listed one |
**Update Node verson to |
KeyObject is part of node 12 crypto library. The polyfills dont have that Object. |
In addition to this, when using node with version 18, |
So, does that mean if I am using node 18+ version, I cannot use msal-node library and have to look for an alternative? Kindly suggest if that is the case. |
I have edited my comment to avoid confusion.
I have edited my comment to avoid confusion. As far as I see, msal-node is not using jsonwebtoken. |
It is using jsonwebtoken. Pasting the error which has the stack trace to show msal-node calling jsonwebtoken files : TypeError: Right-hand side of 'instanceof' is not an object |
I found this option here and this's helped me! const jwt = require('jsonwebtoken');
// instead of
import jwt from 'jsonwebtoken' |
This help me |
Description
When trying to use
jsonwebtoken
sign
function on the frontend it throws error:it looks like this is this
if
:Reproduction
Just call
sign
function in the browserEnvironment
"jsonwebtoken": "^9.0.0"
Chrome version: Version 108.0.5359.124 (Official Build) (arm64)
The text was updated successfully, but these errors were encountered: