atprotoPdsEndpoint property

String? get atprotoPdsEndpoint

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

Implementation

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

    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;
}