expressSign function

String expressSign(
  1. String id,
  2. String secretKey, {
  3. String? issuer,
  4. List<String>? audience,
  5. Map<String, dynamic>? otherClaims,
  6. Duration? maxAge,
})

Issues a HMAC SHA-256 signed JWT.

Creates a JWT using the claimSet for the payload and signing it using the hmacKey with the HMAC SHA-256 algorithm.

Throws a JsonUnsupportedObjectError if any of the Claim Values are not suitable for a JWT.

id is the user id you are trying to encrypt

secretKey is your personal encryption key. Should be kept save.

Implementation

String expressSign(String id, String secretKey,
    {String? issuer,
    List<String>? audience,
    Map<String, dynamic>? otherClaims,
    Duration? maxAge}) {
  final claimSet = JwtExpress(
      subject: id,
      issuer: issuer ?? null,
      audience: audience ?? null,
      otherClaims: otherClaims ?? null,
      maxAge: maxAge ?? null);

  String token = issueExpressToken(claimSet, secretKey);

  return token;
}