less than 1 minute read

npm npm bundle size codesize npm NPM GitHub Sponsors GitHub Repo stars GitHub forks GitHub watchers Rate on Openbase link to npm

jwt-authn

hs256Verify(jwt, passphrase, passphraseEncoding)

Full Documentation

  • 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