···55class AtUri:
66 @classmethod
77 def record_uri(cls, uri: str) -> tuple[str, str, str]:
88+ if not uri.startswith(URI):
99+ raise ValueError(f"Ivalid record uri {uri}!")
1010+811 did, collection, rid = uri[URI_LEN:].split("/")
912 if not (did and collection and rid):
1013 raise ValueError(f"Ivalid record uri {uri}!")
1414+1115 return did, collection, rid
+6-7
bluesky/info.py
···11from abc import ABC, abstractmethod
22from typing import Any
3344-from atproto.identity import did_resolver, handle_resolver
44+from atproto.auth import resolve_identity
55from cross.service import Service
66from util.util import normalize_service_url
77···3737 if not handle:
3838 raise KeyError("No did: or atproto handle provided!")
3939 self.log.info("Resolving ATP identity for %s...", handle)
4040- self.did = handle_resolver.resolve_handle(handle)
4040+ identity = resolve_identity(handle)
4141+ self.did = identity.did
41424243 if not pds:
4343- self.log.info("Resolving PDS from %s DID document...", self.did)
4444- atp_pds = did_resolver.resolve_did(self.did).get_atproto_pds()
4545- if not atp_pds:
4646- raise Exception("Failed to resolve atproto pds for %s")
4747- self.pds = atp_pds
4444+ self.log.info("Resolving PDS for %s...", self.did)
4545+ identity = resolve_identity(self.did)
4646+ self.pds = identity.pds
48474948 @abstractmethod
5049 def get_identity_options(self) -> tuple[str | None, str | None, str | None]:
···11111212MIGRATIONS_DIR = Path(os.environ.get("MIGRATIONS_DIR") or "./migrations")
13131414-PLC_HOST = os.environ.get("PLC_HOST") or "https://plc.directory"
1414+SLINGSHOT_URL = os.environ.get("SLINGSHOT_URL") or "https://slingshot.microcosm.blue"
···11+import sqlite3
22+33+44+def migrate(conn: sqlite3.Connection):
55+ _ = conn.execute("""
66+ CREATE TABLE IF NOT EXISTS atproto_sessions (
77+ did TEXT PRIMARY KEY,
88+ pds TEXT NOT NULL,
99+ handle TEXT NOT NULL,
1010+ access_jwt TEXT NOT NULL,
1111+ refresh_jwt TEXT NOT NULL,
1212+ email TEXT,
1313+ email_confirmed INTEGER DEFAULT 0,
1414+ email_auth_factor INTEGER DEFAULT 0,
1515+ active INTEGER DEFAULT 1,
1616+ status TEXT,
1717+ created_at REAL NOT NULL
1818+ )
1919+ """)
2020+ _ = conn.execute("""
2121+ CREATE TABLE IF NOT EXISTS atproto_identities (
2222+ identifier TEXT PRIMARY KEY,
2323+ did TEXT NOT NULL,
2424+ handle TEXT NOT NULL,
2525+ pds TEXT NOT NULL,
2626+ signing_key TEXT NOT NULL,
2727+ created_at REAL NOT NULL
2828+ )
2929+ """)
3030+ _ = conn.execute("""
3131+ CREATE INDEX IF NOT EXISTS idx_sessions_pds ON atproto_sessions(pds)
3232+ """)
3333+ _ = conn.execute("""
3434+ CREATE INDEX IF NOT EXISTS idx_sessions_handle ON atproto_sessions(handle)
3535+ """)
3636+ _ = conn.execute("""
3737+ CREATE INDEX IF NOT EXISTS idx_identities_did ON atproto_identities(did)
3838+ """)
3939+ _ = conn.execute("""
4040+ CREATE INDEX IF NOT EXISTS idx_identities_handle ON atproto_identities(handle)
4141+ """)