// STEP 1 proof: favela's atcute Client backed by GENUINE P2P (atproto-did-peer module) — the keystone
// spike's HTTP SWAP POINT is gone; this reads wj62 over the real swarm through favela's own handler.
import { Client, ok } from '@atcute/client'
import { mkdtempSync } from 'node:fs'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { P2PSource } from '../lib/p2p-handler.js'
const WJ62 = 'did:plc:wj62ebbusln6gxo5azo6ogzo'
const src = new P2PSource({ storage: mkdtempSync(join(tmpdir(), 'favela-p2p-')) })
const client = new Client({ handler: src.handler() })
console.log('favela atcute Client -> P2PSource handler -> atproto-did-peer -> real swarm...\n')
const desc = await ok(client.get('com.atproto.repo.describeRepo', { params: { repo: WJ62 } }))
console.log('describeRepo ->', desc.collections)
const rec = await ok(client.get('com.atproto.repo.getRecord', {
params: { repo: WJ62, collection: 'app.bsky.feed.post', rkey: '3mqkrr6bnh222' }
}))
console.log('getRecord ->', JSON.stringify(rec.value?.text || rec).slice(0, 66))
const list = await ok(client.get('com.atproto.repo.listRecords', {
params: { repo: WJ62, collection: 'app.bsky.feed.post' }
}))
console.log('listRecords ->', list.records.length, 'posts')
console.log('\nSTEP 1 OK: favela atcute client reads wj62 over REAL P2P (no HTTP). SWAP POINT eliminated.')
await src.close()