From cc295497fe7fd7ea64fb034b2261440883459dae Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Mon, 3 Aug 2026 20:32:23 +0300 Subject: [PATCH] add the arbitrary-service pre-auth client factory Co-Authored-By: Claude Fable 5 --- src/lib/lexClient.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/lib/lexClient.ts b/src/lib/lexClient.ts index 40b0640665..2a865d763c 100644 --- a/src/lib/lexClient.ts +++ b/src/lib/lexClient.ts @@ -24,3 +24,23 @@ export function createLexClient( ): Client { return new Client(agent, {strictResponseProcessing: false, ...options}) } + +/** + * An unauthenticated {@link Client} pointed at an arbitrary service URL, for + * the PRE-AUTH flows that talk to a host the user typed or picked (hosting + * provider description, password reset, handle availability). Those requests + * cannot go through a session-scoped client, because there is no session yet. + * + * Deliberately NOT memoized: `service` is user-supplied and changes as the user + * edits it, so there is no stable key to cache on. Each call builds a fresh + * client, mirroring the ad-hoc agents these call sites constructed inline. That + * keeps client identity per-render, so callers must not put the returned client + * in a React Query key or a dependency array. + * + * Requests use PLAIN `fetch`, not `networkAwareFetch`: the host is untrusted + * input, and a typo'd or dead service must not be reported as the app losing + * network reachability. + */ +export function createServiceClient(service: string): Client { + return createLexClient({service}) +}