Skip to content
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

jwt.isExpired() throws "TypeError: Cannot read property 'exp' of undefined" #251

Open
nebosite opened this issue Jun 9, 2021 · 0 comments

Comments

@nebosite
Copy link

nebosite commented Jun 9, 2021

I'm hitting a weird problem trying to call the isExpired function on a Jwt.

Setup: Single-page web app is sending access token to a server. Server is verifying the token.

Packages:
"@okta/jwt-verifier": "^2.1.0",
"@okta/oidc-middleware": "^4.1.0",

Server code:

    import OktaJwtVerifier from '@okta/jwt-verifier';
    const oktaJwtVerifier:OktaJwtVerifier = new OktaJwtVerifier(oktaConfig);
...
    const jwt = await oktaJwtVerifier.verifyAccessToken(token, audience) 
    console.log(`JWT:  ${JSON.stringify(jwt)}`)
    console.log(`IsExpired:  ${jwt.isExpired()}`)

Output:

JWT:  {"header":{"typ":"JWT","alg":"RS256","kid":"[...]"},"claims":{"ver":1,"jti":"[...]","iss":"[internal uri]","aud":"api://default","iat":1623249209,"exp":1623252809,"cid":"0oa1j3h0l6b5DdVTm1d8","uid":"00u1g2d7eprtOZQrC1d8","scp":["email","profile","openid"],"sub":"me","mail":"[email protected]"}}
ERROR:  TypeError: Cannot read property 'exp' of undefined {}

Expected: instead of an error, should see "isExpired: false"

Side question: What happens when I try to verify an expired token? Will verifyAccessToken throw? Do I even need to check the expiration?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant