Mass Block [bsky] Reposts [and more]
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat: replace public bsky identity calls with slingshot resolveMiniDoc

Winter 58b265db 604eadb1

+28 -11
+10 -10
index.js
··· 75 75 return value; 76 76 } 77 77 78 - async function resolveHandle(handle) { 78 + async function resolveMiniDoc(identifier) { 79 79 const res = await fetch( 80 - `https://public.api.bsky.app/xrpc/com.atproto.identity.resolveHandle?handle=${encodeURIComponent(handle)}` 80 + `https://slingshot.microcosm.blue/xrpc/blue.microcosm.identity.resolveMiniDoc?identifier=${encodeURIComponent(identifier)}` 81 81 ); 82 - if (!res.ok) throw new Error(`failed to resolve handle ${handle}: ${res.status}`); 83 - return (await res.json()).did; 82 + if (!res.ok) throw new Error(`slingshot identity error for ${identifier}: ${res.status}`); 83 + return res.json(); 84 + } 85 + 86 + async function resolveHandle(handle) { 87 + return (await resolveMiniDoc(handle)).did; 84 88 } 85 89 86 90 function makeBlockRecord(targetDid, createdAt) { ··· 190 194 191 195 // ── social graph ──────────────────────────────────────────────────── 192 196 async function resolvePds(did) { 193 - const res = await fetch( 194 - `https://slingshot.microcosm.blue/xrpc/com.bad-example.identity.resolveMiniDoc?identifier=${encodeURIComponent(did)}` 195 - ); 196 - if (!res.ok) throw new Error(`slingshot error: ${res.status}`); 197 - return (await res.json()).pds; 197 + return (await resolveMiniDoc(did)).pds; 198 198 } 199 199 200 200 async function fetchFollowing(did, pdsUrl) { ··· 875 875 }); 876 876 } 877 877 878 - export { isProfileUrl }; 878 + export { isProfileUrl, resolveMiniDoc };
+18 -1
test.js
··· 1 1 import { test } from "node:test"; 2 2 import assert from "node:assert/strict"; 3 - import { isProfileUrl } from "./index.js"; 3 + import { isProfileUrl, resolveMiniDoc } from "./index.js"; 4 4 5 5 test("isProfileUrl: profile URLs", () => { 6 6 assert.equal(isProfileUrl("https://bsky.app/profile/alice.bsky.social"), true); ··· 17 17 assert.equal(isProfileUrl("https://bsky.app/"), false); 18 18 assert.equal(isProfileUrl("https://bsky.app/search"), false); 19 19 }); 20 + 21 + test("resolveMiniDoc returns did, handle, pds for a known handle", async (t) => { 22 + // bad-example.com is slingshot's own example account -- stable 23 + const result = await resolveMiniDoc("bad-example.com"); 24 + assert.equal(typeof result.did, "string"); 25 + assert.ok(result.did.startsWith("did:")); 26 + assert.equal(typeof result.handle, "string"); 27 + assert.equal(typeof result.pds, "string"); 28 + assert.ok(result.pds.startsWith("https://")); 29 + }); 30 + 31 + test("resolveMiniDoc accepts a DID as identifier", async (t) => { 32 + // did:plc:hdhoaan3xa3jiuq4fg4mefid is bad-example.com per slingshot docs 33 + const result = await resolveMiniDoc("did:plc:hdhoaan3xa3jiuq4fg4mefid"); 34 + assert.equal(typeof result.did, "string"); 35 + assert.equal(typeof result.pds, "string"); 36 + });