diff --git a/client/viewer.tsx b/client/viewer.tsx index ac87e20..9bc03ec 100644 --- a/client/viewer.tsx +++ b/client/viewer.tsx @@ -21,7 +21,7 @@ const fetchVideoRecord = async ( const xrpc = new XRPC(pds); const record = await xrpc.get("com.atproto.repo.getRecord", { - parameters: { + params: { collection: "blue.cerulea.video.video", repo: did, rkey, diff --git a/common/identity.ts b/common/identity.ts index 8c2ba63..b975c07 100644 --- a/common/identity.ts +++ b/common/identity.ts @@ -1,26 +1,32 @@ import type { DidDocument } from "@atcute/identity"; -import { - CompositeDidDocumentResolver, - PlcDidDocumentResolver, - WebDidDocumentResolver, - XrpcHandleResolver, -} from "@atcute/identity-resolver"; +import type { WebDidDocumentResolver } from "@atcute/identity-resolver"; +import type { ATProtoUniverse } from "@char/lexicon.ts/atproto"; +import { XRPC } from "@char/lexicon.ts/rpc"; -const handleResolver = new XrpcHandleResolver({ - serviceUrl: "https://public.api.bsky.app", -}); +const bskyPublic = new XRPC("https://public.api.bsky.app"); -const didResolver = new CompositeDidDocumentResolver({ - methods: { - plc: new PlcDidDocumentResolver(), - web: new WebDidDocumentResolver(), - }, -}); - -export function resolveHandle(handle: string): Promise<`did:${string}`> { - return handleResolver.resolve(handle as `${string}.${string}`); +export async function resolveHandle(handle: string): Promise<`did:${string}`> { + const { did } = await bskyPublic.get("com.atproto.identity.resolveHandle", { + params: { handle }, + }); + return did; } -export function resolveDid(did: string): Promise { - return didResolver.resolve(did as `did:${"plc" | "web"}:${string}`); +export async function resolveDid(did: string): Promise { + if (did.startsWith("did:plc:")) { + const doc = await fetch("https://plc.directory/" + did).then((r) => + r.json() + ); + return doc; + } else if (did.startsWith("did:web:")) { + // TODO: write our own did:web resolver (maybe use a CORS proxy on clientside) + const resolver: WebDidDocumentResolver = await import( + "@atcute/identity-resolver" + ) + .then((m) => m.WebDidDocumentResolver) + .then((r) => new r()); + return resolver.resolve(did as `did:web:${string}`); + } + + throw new Error("unsupported did type: " + did); } diff --git a/vendor/lexicon.ts b/vendor/lexicon.ts index 1edb68e..4b3c485 160000 --- a/vendor/lexicon.ts +++ b/vendor/lexicon.ts @@ -1 +1 @@ -Subproject commit 1edb68e5eac3ddfabdd77674ed8193ef9af05649 +Subproject commit 4b3c48591c21d976ab94d0ae6cf2160a2115471c