JwtParser.create constructor

JwtParser.create(
  1. String token, {
  2. DateTime? currentTime,
})

Implementation

factory JwtParser.create(String token, {DateTime? currentTime}) {
  Pointer<Int64> epochSecs = nullptr;
  if (currentTime != null) {
    epochSecs = calloc<Int64>();
    epochSecs.value =
        (currentTime.toUtc().millisecondsSinceEpoch / 1000).round();
  }

  final nativeToken = token.toNativeUtf8();
  try {
    final parser = DartApi.native.jwtParser
        .create(nativeToken, epochSecs)
        .extract((res) => res.asPointer<Void>());
    return JwtParser(parser, true);
  } finally {
    calloc.free(nativeToken);
  }
}