-
Notifications
You must be signed in to change notification settings - Fork 336
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
How to use it in node typescript applicaiton #52
Comments
I use it as such: |
I'm working in TypeScript, and the return of jwt_decode is {} this is causing the following code to fail: import jwt_decode from 'jwt-decode'; function getTokenExpirationDate(encodedToken: any) {
} Specifically the token.exp field. I'm curious what type the return should be, and how I can force the typing in my application. |
@ignatzami This is happening to me as well. Curious if this library is:
I would assume Auth0 would maintain this, but 🤷♂️ |
@DevanB Were you able to figure this out? |
this works for me import JwtDecode from 'jwt-decode';
export function checkExpired() {
const token = 'INSERT YOUR TOKEN HERE';
interface TokenDto {
foo: string;
exp: number;
iat: number;
}
interface TokenHeaderDto {
typ: string;
alg: string;
}
const decodedTokenPayloadOld = JwtDecode(token);
const decodedTokenPayload = JwtDecode<TokenDto>(token);
const decodedTokenHeaderOld = JwtDecode(token, { header: true });
const decodedTokenHeader = JwtDecode<TokenHeaderDto>(token, { header: true });
console.log('decodedTokenPayloadOld :', decodedTokenPayloadOld);
console.log('decodedTokenPayload :', decodedTokenPayload);
console.log('decodedTokenHeader :', decodedTokenHeader);
console.log('decodedTokenHeaderOld :', decodedTokenHeaderOld);
} |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you have not received a response for our team (apologies for the delay) and this is still a blocker, please reply with additional information or just a ping. Thank you for your contribution! 🙇♂️ |
Hi everyone i have problem when using jwt-decode package |
what should I do after the following
var jwtDecode = require('jwt-decode');
I am very new to typescript and node
The text was updated successfully, but these errors were encountered: