Zaubrik / djwt

Create and verify JSON Web Tokens (JWT) with Deno or the browser.
MIT License
228 stars 23 forks source link

Verify Web Token Crypto from a different file (middleware) #59

Closed BayoKwendo closed 3 years ago

BayoKwendo commented 3 years ago

Deno 1.13.2 i can successfully generate token using web crypto api but token verification is always wrong. How can i store crypto key somewhere for verification purposes

await verify(jwt, KEY) .then(() => { console.log('valid'); }) .catch((e) => { console.log(e); });

BayoKwendo commented 3 years ago

I have figure out on how to go about this. Define your key globally

export const  key = await crypto.subtle.generateKey({ name: 'HMAC', hash: 'SHA-512' }, true, [ 'verify', 'sign'    ###])