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

Verify Token Failing #31

Closed
gautammd opened this issue Dec 14, 2022 · 1 comment
Closed

Verify Token Failing #31

gautammd opened this issue Dec 14, 2022 · 1 comment

Comments

@gautammd
Copy link

Hey, below is the function am using for issuing a token and later when I try to verify the token immediately, I get false.

I tried HS256, HS512 algorithms, same issue. surprisingly, verify works if I don't pass nbf and exp whilst issuing.

import jwt from "@tsndr/cloudflare-worker-jwt"

const issueToken = async (payload: any, secret: string) => {
    return await jwt.sign({
        ...payload,
        nbf: Math.floor(Date.now() / 1000) + (60 * 60), // Not before: Now + 1h
        exp: Math.floor(Date.now() / 1000) + (2 * (60 * 60)) // Expires: Now + 2h
    }, secret)
}

Thank you again for this library :)

@tsndr
Copy link
Owner

tsndr commented Dec 14, 2022

Because the token will be valid in an hour from now (see: #30)

@tsndr tsndr closed this as completed Dec 14, 2022
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

2 participants