tsndr / cloudflare-worker-jwt

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

unable to get .verify() to work #41

Closed 2hmad closed 11 months ago

2hmad commented 1 year ago

I get TypeError: Failed to execute 'importKey' on 'SubtleCrypto': 2nd argument is not instance of ArrayBuffer, Buffer, TypedArray, or DataView. error after upgrade my nodejs version from 18.12 to 18.17

const JWTService = {
  verify: async function verify(
    request: NextRequest,
  ): Promise<boolean> {
    const algorithm: JwtAlgorithm = 'ES384'
    const token = request.cookies.get('token')

    if (!token) return false

    return jwt.verify(token.value, atob(String(process.env.JWT_PUBLIC_KEY)), { algorithm })
  }
}

image

tsndr commented 1 year ago

Are you within a Cloudflare Worker environment?