tsndr / cloudflare-worker-jwt

A lightweight JWT implementation with ZERO dependencies for Cloudflare Workers.
MIT License
649 stars 51 forks source link

Verifying Clerk JWT #36

Closed timothymiller closed 1 year ago

timothymiller commented 1 year ago

Hello, thank you for building this library for Cloudflare Workers.

Description

I'm trying to use this library to verify the authenticity of a session token with the public key. I am using Clerk for the sessionToken and JWT, which uses RS256.

const splitPem = JWT_VERIFICATION_KEY.match(/.{1,64}/g) as string[]
const publicKey = '-----BEGIN PUBLIC KEY-----\n' + splitPem.join('\n') + '\n-----END PUBLIC KEY-----'
const authorized = await jwt.verify(sessionToken, publicKey, {
   algorithm: 'RS256'
})

jwt.verify always returns false. Any pointers?

timothymiller commented 1 year ago

Was using the wrong JWT_VERIFICATION_KEY

Library works as expected!