Function signJWS

  • sign JWS (JSON Web Signature)

    Parameters

    • alg: JWSAlgorithmName

      JWS signature algorithm

    • keyobjOrString: string | CryptoKey

      key for verification. CryptoKey object, PKCS#8 PEM private key or HMAC hexadecimal key string

    • header: string

      JWS header

    • payload: string

      JWS payload

    Returns Promise<string>

    JWS signature string

    See

    https://www.rfc-editor.org/rfc/rfc7515.html

    Example

    await signJWS("RS256", prvkey, "eyJOe..", "eyJpc...") -> "eyJOe..."
    await signJWS("PS256", "-----BEGIN PRIVATE...", "eyJOe..", "eyJpc...") -> "eyJOe..."
    await signJWS("ES256", "-----BEGIN PRIVATE...", "eyJOe..", "eyJpc...") -> "eyJOe..."
    await signJWS("HS256", "12ab34...", "eyJOe..", "eyJpc...") -> "eyJOe..."