signJWT method
Future<String>
signJWT({
- required String sub,
- required String aud,
- required int ttl,
- required RelayAuthKeyPair keyPair,
- int? iat,
override
Implementation
@override
Future<String> signJWT({
required String sub,
required String aud,
required int ttl,
required RelayAuthKeyPair keyPair,
int? iat,
}) async {
iat ??= DateTime.now().millisecondsSinceEpoch ~/ 1000 - 60;
final JWTHeader header = JWTHeader();
final String iss = encodeIss(keyPair.publicKeyBytes);
final int exp = iat + ttl;
final JWTPayload payload = JWTPayload(
iss,
sub,
aud,
iat,
exp,
);
final Uint8List data = encodeData(
JWTData(
header,
payload,
),
);
Uint8List signature = ed.sign(
ed.PrivateKey(keyPair.privateKeyBytes),
data,
);
// List<int> signature = keyPair.sign(data);
return encodeJWT(JWTSigned(signature, payload));
}