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

Feature Request: Pass TokenError's to onError() of LinkAdapter #3690

Open
jsadoski-rockhall opened this issue Mar 1, 2024 · 1 comment
Open

Comments

@jsadoski-rockhall
Copy link

fast-jwt has a Token Error object with discreet error codes: fast-jwt/src
/error.js

It would be great if Token Errors were passed to onError(), along with the TOKEN_ERROR_CODES, so we can respond differently when the token is expired:

const adapter = LinkAdapter({
  onLink: ...;
  onSuccess: ...;
  onError: async (error) => {
    if (error.code === LinkAdapter.TOKEN_ERROR_CODES.expired) {
      return {
        // Invalid Token
        statusCode: 498,
      }
    }

    return {
      statusCode: 400,
    }
  }
})

This would allow devs to handle different scenarios in the client. It should be easy to implement and shouldn't break current developer code, since the argument could be ignored.

I would be happy to open a pull request, when I have time in a few weeks from now 🙂.

@jayair
Copy link
Contributor

jayair commented Mar 2, 2024

Would appreciate a PR!

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