atprotoPdsEndpoint property

String? get atprotoPdsEndpoint

Returns PDS endpoint like porcini.us-east.host.bsky.network dynamically based on this Session.

Implementation

String? get atprotoPdsEndpoint {
  if (didDoc == null) return null;

  try {
    final services = didDoc?['service'] ?? const <Map<String, dynamic>>[];
    for (final service in services) {
      if (service['serviceEndpoint'] != null &&
          service['id'] == '#atproto_pds' &&
          service['type'] == 'AtprotoPersonalDataServer') {
        return Uri.parse(service['serviceEndpoint']).host;
      }
    }
  } catch (_) {
    return null;
  }

  return null;
}