diff --git a/.claude/settings.local.json b/.claude/settings.local.json index 6703ebd..9261172 100644 --- a/.claude/settings.local.json +++ b/.claude/settings.local.json @@ -7,7 +7,8 @@ "mcp__plugin_svelte_svelte__svelte-autofixer", "mcp__plugin_svelte_svelte__get-documentation", "Bash(pnpm check:*)", - "Bash(pnpm env:generate-secret:*)" + "Bash(pnpm env:generate-secret:*)", + "Bash(pnpm build:agent-setup:*)" ] } } diff --git a/AGENT_SETUP.md b/AGENT_SETUP.md index b62930b..a84dfe6 100644 --- a/AGENT_SETUP.md +++ b/AGENT_SETUP.md @@ -182,6 +182,7 @@ export async function logout() { ```ts import { parseResourceUri, type Did, type Handle } from '@atcute/lexicons'; +import { isDid } from '@atcute/lexicons/syntax'; import { user } from './auth.svelte'; import { DOH_RESOLVER, type AllowedCollection } from './settings'; import { @@ -222,6 +223,14 @@ export async function resolveHandle({ handle }: { handle: Handle }) { return data; } +/** + * Returns a DID given a handle or DID string. + */ +export async function actorToDid(actor: string): Promise { + if (isDid(actor)) return actor; + return await resolveHandle({ handle: actor as Handle }); +} + const didResolver = new CompositeDidDocumentResolver({ methods: { plc: new PlcDidDocumentResolver(), @@ -511,6 +520,7 @@ export { user, login, signup, logout } from './auth.svelte'; export { parseUri, resolveHandle, + actorToDid, getPDS, getDetailedProfile, getClient, diff --git a/src/lib/atproto/index.ts b/src/lib/atproto/index.ts index 43b9e59..8d3232a 100644 --- a/src/lib/atproto/index.ts +++ b/src/lib/atproto/index.ts @@ -3,6 +3,7 @@ export { user, login, signup, logout } from './auth.svelte'; export { parseUri, resolveHandle, + actorToDid, getPDS, getDetailedProfile, getClient, diff --git a/src/lib/atproto/methods.ts b/src/lib/atproto/methods.ts index acf9470..ade4f1a 100644 --- a/src/lib/atproto/methods.ts +++ b/src/lib/atproto/methods.ts @@ -1,4 +1,5 @@ import { parseResourceUri, type Did, type Handle } from '@atcute/lexicons'; +import { isDid } from '@atcute/lexicons/syntax'; import { user } from './auth.svelte'; import { DOH_RESOLVER, type AllowedCollection } from './settings'; import { @@ -39,6 +40,14 @@ export async function resolveHandle({ handle }: { handle: Handle }) { return data; } +/** + * Returns a DID given a handle or DID string. + */ +export async function actorToDid(actor: string): Promise { + if (isDid(actor)) return actor; + return await resolveHandle({ handle: actor as Handle }); +} + const didResolver = new CompositeDidDocumentResolver({ methods: { plc: new PlcDidDocumentResolver(),