Verifying with HS256
jwt-authn
hs256Verify(jwt, passphrase, passphraseEncoding)
- jwt: the signed JWT (JSON Web Token) that you’re trying to verify.
- passphrase: the passphrase used when signing with HMAC (HS256).
- passphraseEncoding: (optional) if specified and available, the encoding is used to read the passphrase. Otherwise, base64url encoding is assumed.
import { hs256Verify } from "jwt-authn";
const passphrase = "AyM1SysPpbyDfgZld3umj1qzKObwVMkoqQ-EstJQLr_T-1qS0gZH75aKtMN3Yj0iPS4hcgUuTwjAzZr1Z9CAow";
const encoded = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJqb2UiLCJleHAiOjEzMDA4MTkzODAsImh0dHA6Ly9leGFtcGxlLmNvbS9pc19yb290Ijp0cnVlfQ.lliDzOlRAdGUCfCHCPx_uisb6ZfZ1LRQa0OJLeYTTpY";
hs256Verify(encoded, passphrase)
// expected output: true