sst / sst

Build modern full-stack applications on AWS

Home Page:https://sst.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

jsadoski-rockhall opened this issue · comments

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 🙂.

commented

Would appreciate a PR!