tokenExpired method

bool tokenExpired(
  1. String token
)

Whether the exp of a token issued by the fake lies in the past.

Implementation

bool tokenExpired(String token) {
  final parts = token.split('.');
  if (parts.length != 3) return true;
  try {
    final payload = jsonDecode(
      utf8.decode(base64Url.decode(base64Url.normalize(parts[1]))),
    ) as JsonMap;
    final exp = payload['exp']! as int;
    return world.now().millisecondsSinceEpoch ~/ 1000 >= exp;
  } on Object {
    return true;
  }
}