signJWS function
Signs the provided data using the private key and returns a JSON Web Signature (JWS) token.
The data
parameter represents the data to be signed.
The privateKey
parameter represents the private key used for signing.
The function returns the JWS token as a string.
Implementation
String signJWS(String data, String privateKey) {
final jwt = JWT(data, header: {"typ": "JWM", "alg": "EdDSA"});
// Key must be 64 bytes long
final token = jwt.sign(
EdDSAPrivateKey(hex.decode(privateKey)),
algorithm: JWTAlgorithm.EdDSA,
);
return token;
}