read method

  1. @override
Future<String?> read()
override

Implementation

@override
Future<String?> read() async {
  final String? sealed = await sink.read();
  if (sealed == null) return null;
  final DVAppKeyCipher? cipher = await _cipher();
  if (cipher == null) return null;
  final String? token = cipher.decrypt(sealed);
  if (token == null || !token.startsWith(DVSessions.tokenPrefix)) {
    // Unreadable -- a rotated key, a reset keyring, or something that was
    // never sealed. Discarded rather than sent anywhere.
    await sink.write(null);
    return null;
  }
  return token;
}