Creates a JSON Web Token, signs it, then returns it to the caller.

The JWT returned by this function:

  1. includes the payload provided by the caller;
  2. is signed using the private Key ID (kid) found in the JWKS provided;
  3. includes, in the protected header, information related to the JWK used to sign the JWT.
  • Parameters

    Returns Promise<
        | { error: Error; value?: undefined }
        | { error?: undefined; value: string },
    >