Skip to main content

pdsx._internal.resolution

PDS and URI resolution utilities.

Functions

normalize_service_url

coerce a bare host into an https base URL. ‘pds.zat.dev’ -> ‘https://pds.zat.dev’; an explicit scheme is left as-is.

reject_private_host

raise ValueError if base_url targets a non-public address. Best-effort SSRF guard for read queries against arbitrary hosts: resolves the host and refuses loopback, private, link-local, or otherwise non-global addresses (e.g. cloud metadata at 169.254.169.254). This does not defend against DNS rebinding, so callers must not follow redirects.

discover_pds

discover PDS URL from handle or DID. Args:
  • repo: handle (e.g., ‘zzstoatzz.io’) or DID (e.g., ‘did:plc:…’)
Returns: Raises:
  • ValueError: if handle cannot be resolved or PDS not found

Classes

URIParts

parsed components of an AT-URI. Methods:

from_uri

parse an AT-URI into its components. Args:
  • uri: either full AT-URI (at://did/collection/rkey) or shorthand (collection/rkey)
  • client_did: authenticated user’s DID (required for shorthand format)
Returns:
  • URIParts with repo, collection, and rkey
Raises:
  • ValueError: if URI format is invalid or shorthand used without authentication