···
328
328
const initialStatuses = {};
329
329
TRUSTED_VERIFIERS.forEach(id => { initialStatuses[id] = 'checking'; });
330
330
setOfficialVerifiersStatus(initialStatuses);
331
331
-
const publicAgent = new Agent({ service: 'https://public.api.bsky.app' });
331
331
+
// No need for publicAgent instance here
332
332
+
// const publicAgent = new Agent({ service: 'https://public.api.bsky.app' });
332
333
333
334
await Promise.all(TRUSTED_VERIFIERS.map(async (verifierIdentifier) => {
334
335
let verifierDid = null;
335
336
let verifierHandle = verifierIdentifier;
336
337
let currentStatus = 'checking';
337
338
try {
339
339
+
// Resolve handle using direct fetch if necessary
338
340
if (!verifierIdentifier.startsWith('did:')) {
339
339
-
const resolveResult = await publicAgent.api.com.atproto.identity.resolveHandle({ handle: verifierIdentifier });
340
340
-
verifierDid = resolveResult.data.did;
341
341
+
const resolveUrl = `https://public.api.bsky.app/xrpc/com.atproto.identity.resolveHandle?handle=${encodeURIComponent(verifierIdentifier)}`;
342
342
+
const resolveResponse = await fetch(resolveUrl);
343
343
+
if (!resolveResponse.ok) throw new Error(`Resolve handle failed: ${resolveResponse.status}`);
344
344
+
const resolveData = await resolveResponse.json();
345
345
+
verifierDid = resolveData.did;
341
346
} else {
342
347
verifierDid = verifierIdentifier;
348
348
+
// Optionally fetch profile handle for display using direct fetch
343
349
try {
344
344
-
const profileRes = await publicAgent.api.app.bsky.actor.getProfile({ actor: verifierDid });
345
345
-
verifierHandle = profileRes.data.handle;
350
350
+
const profileUrl = `https://public.api.bsky.app/xrpc/app.bsky.actor.getProfile?actor=${encodeURIComponent(verifierDid)}`;
351
351
+
const profileResponse = await fetch(profileUrl);
352
352
+
if (profileResponse.ok) {
353
353
+
const profileData = await profileResponse.json();
354
354
+
verifierHandle = profileData.handle;
355
355
+
}
346
356
} catch { /* ignore */ }
347
357
}
358
358
+
348
359
if (!verifierDid) throw new Error('Could not resolve identifier');
349
360
const pdsEndpoint = await getPdsEndpoint(verifierDid);
350
361
if (!pdsEndpoint) throw new Error('Could not find PDS');
351
362
352
363
let listRecordsCursor = undefined;
353
364
let foundMatch = false;
354
354
-
const tempPublicAgent = new Agent({ service: pdsEndpoint });
355
355
-
365
365
+
// No agent needed here, use fetch
356
366
do {
357
367
try {
358
358
-
const response = await tempPublicAgent.api.com.atproto.repo.listRecords({
359
359
-
repo: verifierDid,
360
360
-
collection: 'app.bsky.graph.verification',
361
361
-
limit: 100,
362
362
-
cursor: listRecordsCursor
363
363
-
});
364
364
-
const records = response.data.records || [];
368
368
+
const listParams = new URLSearchParams({ repo: verifierDid, collection: 'app.bsky.graph.verification', limit: '100' });
369
369
+
if (listRecordsCursor) listParams.set('cursor', listRecordsCursor);
370
370
+
// *** Use direct fetch for listRecords ***
371
371
+
const listRecordsUrl = `${pdsEndpoint}/xrpc/com.atproto.repo.listRecords?${listParams.toString()}`;
372
372
+
const listResponse = await fetch(listRecordsUrl);
373
373
+
374
374
+
if (!listResponse.ok) {
375
375
+
if (listResponse.status !== 400) {
376
376
+
console.warn(`Failed fetch for ${verifierHandle}: ${listResponse.status}`);
377
377
+
throw new Error(`Fetch failed with status ${listResponse.status}`);
378
378
+
}
379
379
+
break; // Stop on 400 or other errors
380
380
+
}
381
381
+
382
382
+
const listData = await listResponse.json();
383
383
+
const records = listData.records || [];
365
384
const matchingRecord = records.find(record => record.value?.subject === session.did);
366
385
if (matchingRecord) {
367
386
currentStatus = 'verified';
368
387
foundMatch = true;
369
388
break;
370
389
}
371
371
-
listRecordsCursor = response.data.cursor;
390
390
+
listRecordsCursor = listData.cursor;
372
391
} catch (err) {
373
392
console.warn(`Could not listRecords for ${verifierDid} on ${pdsEndpoint}:`, err.message);
374
393
listRecordsCursor = undefined;
···
400
419
}
401
420
setIsFetchingSuggestions(true);
402
421
try {
403
403
-
const publicAgent = new Agent({ service: 'https://public.api.bsky.app' });
404
404
-
const response = await publicAgent.api.app.bsky.actor.searchActorsTypeahead({
405
405
-
q: query,
406
406
-
limit: 5
407
407
-
});
408
408
-
setSuggestions(response.data.actors || []);
422
422
+
// *** Use direct fetch ***
423
423
+
const url = new URL('https://public.api.bsky.app/xrpc/app.bsky.actor.searchActorsTypeahead');
424
424
+
url.searchParams.append('q', query);
425
425
+
url.searchParams.append('limit', '5');
426
426
+
const response = await fetch(url.toString());
427
427
+
if (!response.ok) throw new Error(`Suggestions fetch failed: ${response.status}`);
428
428
+
const data = await response.json();
429
429
+
setSuggestions(data.actors || []);
409
430
} catch (error) {
410
431
console.error('Failed to fetch suggestions:', error);
411
432
setSuggestions([]);