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

Setting complete to true in verifier does not return the input #521

Closed
timjam opened this issue Dec 11, 2024 · 8 comments · Fixed by #522 or #524
Closed

Setting complete to true in verifier does not return the input #521

timjam opened this issue Dec 11, 2024 · 8 comments · Fixed by #522 or #524
Labels
bug Something isn't working

Comments

@timjam
Copy link

timjam commented Dec 11, 2024

Hi!

First of all thanks for creating a great JWT library.

I wanted to create a new Passport JWT strategy using your JWT library, because the current most used strategy library does not support EdDSA algorithms. When playing around with it, it looks like in contrary what the docs say setting the complete: true in verifier settings does not return the original input token. Instead it seems to only return the header, payload and signature

Also in case you want to check it out, here's the package
https://www.npmjs.com/package/passport-fast-jwt

@simoneb
Copy link
Member

simoneb commented Dec 11, 2024

Thanks for reporting! Weird, because according to our tests it seems that setting complete to true does indeed return what is documented. See here.

Thoughts?

@timjam
Copy link
Author

timjam commented Dec 11, 2024

Hmm I have to recheck this and make sure I am using the latest version of the package. I'll come back in a short moment

@timjam
Copy link
Author

timjam commented Dec 11, 2024

To me it looks like the decoder returns the input, but the verifier does not. Should it be like that?

I was able to verify that your verifier at least does not return the input

const sign = createSigner({
    key: async () => "secret",
  })

const token = sign({ sub: "123" })

const verify = createVerifier({
  key: async () => "secret"
  complete: true,
})

const sections = verify(token)

// Here the sections does not contain the input property

@simoneb simoneb added the bug Something isn't working label Dec 11, 2024
@simoneb simoneb changed the title BUG: Setting complete to true does not return the input Setting complete to true does not return the input Dec 11, 2024
@simoneb simoneb changed the title Setting complete to true does not return the input Setting complete to true in verifier does not return the input Dec 11, 2024
@simoneb
Copy link
Member

simoneb commented Dec 11, 2024

So it seems, so you're right that the doc is misleading.

@timjam
Copy link
Author

timjam commented Dec 11, 2024

Great. Thanks for a very very fast reaction and good to have the docs fixed

Copy link
Contributor

🎉 This issue has been resolved in version 5.0.1 🎉

The release is available on:

Your optic bot 📦🚀

@timjam
Copy link
Author

timjam commented Dec 11, 2024

You may want to add the input also into the types.

type DecodedJwt = {
  header: Record<string, any>
  payload: any
  signature: string
  // input is missing here
}

Copy link
Contributor

🎉 This issue has been resolved in version 5.0.2 🎉

The release is available on:

Your optic bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants