Library API
    Preparing search index...

    Function verifyJWS

    • Verifies a JSON Web Signature (JWS) against a provided key or secret. Enforces a mandatory caller-supplied expectedAlg for algorithm dispatch to prevent algorithm confusion attacks. Supports:

      • Asymmetric RS256: via CryptoKey or PEM public key string
      • Symmetric HS256, HS384, HS512: via shared secret string or Uint8Array

      Parameters

      • token: string

        The JWS string to verify

      • keyOrSecret: string | CryptoKey

        The public CryptoKey, PEM public key string, or HMAC shared secret

      • expectedAlg: "RS256"

        Mandatory expected algorithm to enforce (e.g. 'RS256', 'HS256', 'HS384', 'HS512')

      Returns Promise<boolean>

      A promise resolving to true if the signature is valid

    • Verifies a JSON Web Signature (JWS) against a provided key or secret. Enforces a mandatory caller-supplied expectedAlg for algorithm dispatch to prevent algorithm confusion attacks. Supports:

      • Asymmetric RS256: via CryptoKey or PEM public key string
      • Symmetric HS256, HS384, HS512: via shared secret string or Uint8Array

      Parameters

      • token: string

        The JWS string to verify

      • keyOrSecret: string | Uint8Array<ArrayBufferLike>

        The public CryptoKey, PEM public key string, or HMAC shared secret

      • expectedAlg: HMACAlgorithm

        Mandatory expected algorithm to enforce (e.g. 'RS256', 'HS256', 'HS384', 'HS512')

      Returns Promise<boolean>

      A promise resolving to true if the signature is valid

    • Verifies a JSON Web Signature (JWS) against a provided key or secret. Enforces a mandatory caller-supplied expectedAlg for algorithm dispatch to prevent algorithm confusion attacks. Supports:

      • Asymmetric RS256: via CryptoKey or PEM public key string
      • Symmetric HS256, HS384, HS512: via shared secret string or Uint8Array

      Parameters

      • token: string

        The JWS string to verify

      • keyOrSecret: string | Uint8Array<ArrayBufferLike> | CryptoKey

        The public CryptoKey, PEM public key string, or HMAC shared secret

      • expectedAlg: string

        Mandatory expected algorithm to enforce (e.g. 'RS256', 'HS256', 'HS384', 'HS512')

      Returns Promise<boolean>

      A promise resolving to true if the signature is valid