terminalGrantOf method

String? terminalGrantOf(
  1. String userId,
  2. String hostId
)

The ID of the valid grant terminal of userId on hostId, or null.

Implementation

String? terminalGrantOf(String userId, String hostId) => grants.values
    .where(
      (g) =>
          g['revoked_at'] == null &&
          g['target_kind'] == 'host' &&
          g['target_id'] == hostId &&
          g['subject_id'] == userId,
    )
    .map((g) => g['id']! as String)
    .firstOrNull;