jose.createJWSHeader()

Creates a JWSHeader object.

Syntax

jose.createJWSHeader(key[,algorithm])

Parameters

key
The shared secret key or private key that is used by the algorithm to sign text. For key requirements, see RFC 7518 - JSON Web Algorithms (JWA).
The key must be.
  • A String object that refers to a configured object that also supports prefix usage in XSLT.
  • A Buffer or Buffers object that contains the base64 encoded data of the key.
  • An Object.
  • An RSA private key in JWK form or symmetric key in JWK form. For JWK requirements or limitations, see jwk.isJWK().
  • A JWK set. The 'kid' and 'alg' JOSE headers are used to find a proper JWK inside the JWK set. The 'kid' header is a string that the verifier can use to find the correct key to verify the signature.
For more information, see Key object usage.

The key can also be assigned by using JWSHeader.setKey().

algorithm
The name of the algorithm to use. The following values are supported.
  • HS256
  • HS384
  • HS512
  • RS256
  • RS384
  • RS512
  • ES256
  • ES384
  • ES512
  • PS256
  • PS384
  • PS512

Guidelines

When the algorithm parameter is not specified in the jose.createJWSHeader() API, a header parameter value for the algorithm must be added to the JWSHeader object when you call the jose.createJWSSigner() API.