-
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
v9: decode
does not work with import *
in TypeScript
#875
Comments
Any solution for this so far ? @bluepichu |
import { decode } from 'jsonwebtoken';
console.log(
decode(
'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJPbmxpbmUgSldUIEJ1aWxkZXIiLCJpYXQiOjE2NzMyNzcwNTMsImV4cCI6MTcwNDgxMzA1MywiYXVkIjoid3d3LmV4YW1wbGUuY29tIiwic3ViIjoianJvY2tldEBleGFtcGxlLmNvbSIsIkdpdmVuTmFtZSI6IkpvaG5ueSIsIlN1cm5hbWUiOiJSb2NrZXQiLCJFbWFpbCI6Impyb2NrZXRAZXhhbXBsZS5jb20iLCJSb2xlIjpbIk1hbmFnZXIiLCJQcm9qZWN0IEFkbWluaXN0cmF0b3IiXX0.cN6HdDt31tosRDffE6UIgDGy3lgjFW9j9uO-VCd8S7U'
)
); |
See auth0/node-jsonwebtoken#875 Signed-off-by: Antonio Gamez Diaz <[email protected]>
I am having an issue that I think is related. Long story short, I am getting: I require jwt like this: I posted the issue on OS with some more detail: |
@rpuls I think your issue is the same as #870 (which has a temporary workaround and an open fix) |
Version 9.0.0 on Node 16.19.0 and node 18.x with TS 4.x |
Description
If you
import * as jwt from "jsonwebtoken"
, then you can't calljwt.decode
. It works fine if you use a default import though (import jwt from "jsonwebtoken"
).Related to #866, and probably also #870.
The root cause of this is that
import *
in TS gets translated in such a way that only enumerable properties are copied from the module. Sincedecode
is non-enumerable it is not properly copied.Reproduction
Environment
Version 9.0.0 on Node 16.19.0 with TS 4.6.2
The text was updated successfully, but these errors were encountered: