Encrypted, ephemeral, private memos on atproto

feat(shared): implement slingshot identity resolver

graham.systems ad3f47cc 270231c9

verified
Changed files
+40
packages
+9
packages/shared/deno.jsonc
··· 1 + { 2 + "name": "@cistern/shared", 3 + "exports": { 4 + ".": "./mod.ts" 5 + }, 6 + "imports": { 7 + "@atcute/lexicons": "npm:@atcute/lexicons@^1.2.2" 8 + } 9 + }
+1
packages/shared/mod.ts
··· 1 + export * from "./resolve-did.ts";
+30
packages/shared/resolve-did.ts
··· 1 + import type { Did, Handle } from "@atcute/lexicons"; 2 + 3 + export interface MiniDoc { 4 + did: Did; 5 + handle: Handle; 6 + pds: string; 7 + signing_key: string; 8 + } 9 + 10 + export async function resolveMiniDoc( 11 + handle: string, 12 + slingshotUrl?: string, 13 + ): Promise<MiniDoc> { 14 + const url = new URL( 15 + "/xrpc/com.bad-example.identity.resolveMiniDoc", 16 + slingshotUrl ?? "https://slingshot.microcosm.blue", 17 + ); 18 + 19 + url.searchParams.set("handle", handle); 20 + 21 + const result = await fetch(url.toString()); 22 + 23 + if (!result.ok) { 24 + throw new Error( 25 + `failed to fetch identity mini doc: Error ${result.status} ${result.statusText}`, 26 + ); 27 + } 28 + 29 + return await result.json(); 30 + }