22 * DID:nostr Resolution
33 *
44 * Resolves did:nostr:<pubkey> to a Solid WebID by:
5- * 1. Trying the in-process local well-known index first (the pod is
6- * its own authoritative resolver for its accounts — no HTTP)
7- * 2. Falling back to the configured external resolver:
8- * a. Fetching the DID document
9- * b. Extracting alsoKnownAs WebID
10- * c. Verifying bidirectional link (WebID links back to did:nostr)
5+ * 1. Fetching DID document from nostr.social
6+ * 2. Extracting alsoKnownAs WebID
7+ * 3. Verifying bidirectional link (WebID links back to did:nostr)
118 */
129
1310import { validateExternalUrl } from '../utils/ssrf.js' ;
@@ -171,21 +168,12 @@ export async function fetchWithRedirectGuard(initialUrl, {
171168}
172169
173170/**
174- * Resolve did:nostr pubkey to WebID.
171+ * Resolve did:nostr pubkey to WebID via DID document .
175172 *
176- * Tries the in-process local well-known index first (the pod is its
177- * own authoritative resolver for its accounts — no HTTP fetch, no
178- * external dependency, no SSRF surface). Falls back to the configured
179- * external resolver (`nostr.social` by default) only for cross-pod
180- * pubkeys that no local account claims.
181- *
182- * This local-first ordering is also enforced in the `verifyNostrAuth`
183- * resolver chain (src/auth/nostr.js). Duplicating it inside the
184- * resolver itself is defense-in-depth: callers from other code paths
185- * (and any future caller that forgets to consult the local index)
186- * still get the cheap, reliable answer for the dominant SSO case
187- * — user signing in to their own pod — even when the external
188- * resolver is unavailable (network down, SSL cert expired, etc.).
173+ * Local users are resolved by `resolveDidNostrLocally` in the auth
174+ * caller (well-known-did-nostr.js exports an in-process function) —
175+ * this resolver is the cross-pod fallback that fetches an external
176+ * DID doc, so all fetches run through the SSRF guard.
189177 *
190178 * @param {string } pubkey - 64-char hex Nostr pubkey
191179 * @param {string } [resolverUrl] - DID resolver base URL (without the
@@ -205,24 +193,6 @@ export async function resolveDidNostrToWebId(pubkey, resolverUrl = DEFAULT_DID_R
205193 }
206194 pubkey = pubkey . toLowerCase ( ) ;
207195
208- // Local-first: consult the in-process well-known index before any
209- // HTTP fetch. The index is built from local WebID profiles whose
210- // `verificationMethod` declares this Nostr pubkey AND is referenced
211- // from `authentication` (see src/idp/well-known-did-nostr.js) — so
212- // the binding is already verified by construction and we skip the
213- // backlink round-trip required for external answers.
214- //
215- // Dynamic import keeps the IdP module optional: pods built/run
216- // without the IdP layer don't pull it in. Any import or lookup
217- // error falls through to the external resolver.
218- try {
219- const { resolveDidNostrLocally } = await import ( '../idp/well-known-did-nostr.js' ) ;
220- const localWebId = await resolveDidNostrLocally ( pubkey ) ;
221- if ( localWebId ) return localWebId ;
222- } catch {
223- // IdP module unavailable or local lookup threw — fall through.
224- }
225-
226196 // Cache key includes the resolver URL because different resolvers
227197 // can legitimately disagree about the same pubkey (one might have
228198 // a DID doc, another not; alsoKnownAs values can differ across
0 commit comments