Giter Site home page Giter Site logo

JWT invalid? about djwt HOT 3 CLOSED

richcorbs avatar richcorbs commented on August 24, 2024
JWT invalid?

from djwt.

Comments (3)

richcorbs avatar richcorbs commented on August 24, 2024 1
const jwtSecretKey = 'my-secret-secret'
const header = { alg: "HS256", typ: "JWT" }
const payload = { iss: "richard", exp: (await setExpiration(new Date().getTime() + 60000)) }

from djwt.

timonson avatar timonson commented on August 24, 2024

Hi @richcorbs , would you be so kind to post the exact input data? Meaning the makeJwt arguments. Thanks a lot!

from djwt.

timonson avatar timonson commented on August 24, 2024

@richcorbs I could not replicate this error but I have some ideas what might have caused it in your case.

  1. Execute the file with deno run --reload file.ts at least once.
  2. Don't forget that the function setExpiration (which doesn't return a promise by the way) never returns the same result twice if you use it the way you did.

I checked the following code with jwt.io and I got equal results:

const key = "my-secret-secret"
const header = { alg: "HS256" as const, typ: "JWT" }
const payload = {
  iss: "richard",
  exp: 1690616799118,
}

const jwt = await makeJwt({ header, payload, key })
const isJwtValid = await validateJwt(jwt, key, { isThrowing: false })
console.log(jwt)
/* eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJyaWNoYXJkIiwiZXhwIjoxNjkwNjE2Nzk5MTE4fQ.I6scoOdIyEaKefD_tH5bqi8Glm5Y7up7UYnUZsJfMcA */
console.log(isJwtValid)
/* {
  header: { alg: "HS256", typ: "JWT" },
  payload: { iss: "richard", exp: 1690616799118 },
  signature: "23ab1ca0e748c8468a79f0ffb47e5baa2f06966e58eeea7b5189d466c25f31c0"
} */

jwt comparison

Please let me know if this resolves this issue or if the error persists. Thank you!

from djwt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.