elysiajs / elysia-jwt

Plugin for Elysia for using JWT Authentication
MIT License
38 stars 16 forks source link

CryptoKey instances for asymmetric algorithm verifying must be of type "public" #21

Open LIMPIX31 opened 7 months ago

LIMPIX31 commented 7 months ago

I am using the following jwt setup

export const jwt = jwtPlugin({
  name: 'jwt',
  alg: 'EdDSA',
  exp: '30m',
  schema: user,
  secret: await importJWK(
    {
      crv: 'Ed25519',
      d: 'N3cOzsFZwiIbtNiBYQP9bcbcTIdkITC8a4iRslrbW7Q',
      x: 'RjnTe-mqZcVls6SQ5CgW0X__jRaa-Quj5HBDREzVLhc',
      kty: 'OKP',
    },
    'EdDSA',
  ),
})

This works for signing, but not for verification

TypeError: CryptoKey instances for asymmetric algorithm verifying must be of type "public"

It's worth noting that @elysia/jwt is using version 4 of jose. It might be a good idea to consider upgrading to version 5.