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

signUserToken performance #43

Open
isaachinman opened this issue Dec 18, 2023 · 0 comments
Open

signUserToken performance #43

isaachinman opened this issue Dec 18, 2023 · 0 comments

Comments

@isaachinman
Copy link

Hi there, just getting set up with "enhanced security mode".

I've implemented token signing as per the docs:

const before = performance.now()

const knockToken = Knock.signUserToken(
  userId,
  { expiresInSeconds: 60 * 60 * 24 * 7 },
)

const after = performance.now()
console.log(`Knock.signUserToken took ${after - before}ms`)

The original idea was to put this token directly in our pre-existing GET user endpoint, so that frontend applications could consume it without any new endpoints to fetch.

However, I am seeing signUserToken take 20-30ms consistently.

I see that your implementation is a pretty basic jsonwebtoken flow. I was able to reduce the computation time to sign a JWT to by 50%+ with fast-jwt.

I'd recommend you implement the same, as it should be trivial to do so.

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

1 participant