tharak#3
jwt generation and verification
Here is the sample code of how i was generating and verifying JWT
import { generateSecret } from 'https://deno.land/x/jose@v4.14.4/key/generate_secret.ts';
import { SignJWT } from 'https://deno.land/x/jose@v4.14.4/jwt/sign.ts';
import { jwtVerify } from 'https://deno.land/x/jose@v4.14.4/jwt/verify.ts';
let payload = { name: 'tharak' }
let secretKey = await generateSecret('HS512')
let JWT_TOKEN = await new SignJWT(payload)
.setProtectedHeader({ alg: 'HS512', typ: "JWT" })
.setIssuer('Deno')
.setAudience('Angular')
.setExpirationTime('2h')
.sign(secretKey)
let verified_JWT = await jwtVerify(JWT_TOKEN , secretKey)
This throws me some error, but when i have given the b64 param set to true, .setProtectedHeader({ b64: true, alg: 'HS512', typ: "JWT" })
i was able to get the verified token details but why do i need to set b64 ?
i should be able to verify the token without setting the b64 as well.
it would be great if anyone could helpme of what exactly happening at the SignJWT2 replies