twilio / twilio-node

Node.js helper library
MIT License
1.37k stars 495 forks source link

Right-hand side of 'instanceof' is not an object for token.toJwt() (next.js) #1015

Closed MarkovskiyKonstantin closed 1 month ago

MarkovskiyKonstantin commented 3 months ago

Issue Summary

When I create an access token and add it to jwt I get a error Right-hand side of 'instanceof' is not an object for next.js app

image

Steps to Reproduce

  1. This is the first step
  2. This is the second step
  3. Further steps, etc.

Code Snippet

    const AccessToken = Twilio.jwt.AccessToken;

    const VoiceGrant = AccessToken.VoiceGrant;

    const token = new AccessToken(accountSid, apiKey, apiKeySecret, {identity});

    const voiceGrant = new VoiceGrant({
      incomingAllow: true, // Optional: add to allow incoming calls
      outgoingApplicationSid: accountSid,
    });

   token.addGrant(voiceGrant);

    console.log('### token', token.toJwt());

Technical details:

"twilio": "4.23.0", node version: v20.9.0 "next": "13.3.2",

tiwarishubham635 commented 1 month ago

I think this is an open issue with jsonwebtoken v9, see here. A quick fix can be that we can revert the version from 9.0.0 to 8.5.1 but the permanent fix will be done by this library only. So it is more of an issue for that repository.

tiwarishubham635 commented 1 month ago

Closing this issue as not an issue from twilio