From 5e88752fc0fb8e85c8d6bacae2b402ae255b550c Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Mon, 3 Aug 2026 18:00:21 +0300 Subject: [PATCH] migrate pds detection handle resolution to the public appview client Co-Authored-By: Claude Fable 5 --- src/state/queries/pds-detection.ts | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/state/queries/pds-detection.ts b/src/state/queries/pds-detection.ts index 697963aa93..1f2b413d6d 100644 --- a/src/state/queries/pds-detection.ts +++ b/src/state/queries/pds-detection.ts @@ -1,13 +1,15 @@ import {useState} from 'react' import {type DidDocument, getPdsEndpoint} from '@atproto/common-web' +import {type HandleString} from '@atproto/syntax' import {useQuery, useQueryClient} from '@tanstack/react-query' -import {DEFAULT_SERVICE, PUBLIC_BSKY_SERVICE} from '#/lib/constants' +import {DEFAULT_SERVICE} from '#/lib/constants' import {useDebouncedValue} from '#/lib/hooks/useDebouncedValue' import {isNetworkError} from '#/lib/strings/errors' import {logger} from '#/logger' import {STALE} from '#/state/queries' -import {Agent} from '#/state/session/agent' +import {getPublicAppviewClient} from '#/state/session/clients' +import {com} from '#/lexicons' const RQKEY_ROOT = 'pds-detection' export const RQKEY = (identifier: string) => [RQKEY_ROOT, identifier] @@ -147,16 +149,25 @@ export async function resolvePdsForIdentifier( identifier: string, ): Promise<{did: string; pdsUrl: string | null} | null> { const norm = normalizeIdentifier(identifier) - const agent = new Agent(null, {service: PUBLIC_BSKY_SERVICE}) + /* + * Resolution runs without a session, so this uses the public appview client + * rather than a session-scoped one. It matches the unauthenticated, + * unproxied public agent this previously constructed by hand. + */ + const client = getPublicAppviewClient() try { let did: string if (norm.startsWith('did:')) { did = norm } else { - const res = await withResolveTimeout(signal => - agent.resolveHandle({handle: norm}, {signal}), + const data = await withResolveTimeout(signal => + client.call( + com.atproto.identity.resolveHandle, + {handle: norm as HandleString}, + {signal}, + ), ) - did = res.data.did + did = data.did } logger.debug('pds-detection: resolved identifier to DID', { identifier: norm,