#!/usr/bin/env tsx /** * Boots a local AT Protocol network (PDS + PLC) using @atproto/dev-env * and creates test accounts for alice and bob. * * The PDS includes a built-in OAuth Authorization Server, so the full * browser-based OAuth flow works against it. * * Usage: * pnpm run dev:network */ import { TestNetworkNoAppView } from "@atproto/dev-env"; const APP_URL = process.env.APP_URL || "http://[::1]:3000"; const ACCOUNTS = [ { shortName: "alice", handle: "alice.test", email: "alice@test.com", password: "alice-pass-123", displayName: "Alice Test", }, { shortName: "bob", handle: "bob.test", email: "bob@test.com", password: "bob-pass-123", displayName: "Bob Test", }, ]; async function main() { console.log("Starting local AT Protocol network...\n"); const network = await TestNetworkNoAppView.create({ plc: { port: 2583 }, pds: { port: 2584 }, }); const pdsUrl = network.pds.url; const plcUrl = network.plc.url; console.log(`PDS running at: ${pdsUrl}`); console.log(`PLC running at: ${plcUrl}\n`); const sc = network.getSeedClient(); for (const account of ACCOUNTS) { const { shortName, handle, email, password, displayName } = account; await sc.createAccount(shortName, { handle, email, password }); const did = sc.dids[shortName]; await sc.createProfile(did, displayName, `Hi, I'm ${displayName}`); console.log(`Account created: ${handle} (DID: ${did})`); } await network.processAll(); const bar = "═".repeat(60); console.log(`\n${bar}`); console.log(` Open the app at: ${APP_URL}`); console.log(`${bar}`); console.log( " IMPORTANT: use exactly this URL (IPv6 loopback). Opening\n" + " http://localhost:3000 or http://127.0.0.1:3000 will break the\n" + " OAuth flow — the PDS rejects same-site authorize requests.\n", ); console.log("--- Test accounts ---\n"); for (const account of ACCOUNTS) { const did = sc.dids[account.shortName]; console.log(` ${account.handle}`); console.log(` DID: ${did}`); console.log(` Email: ${account.email}`); console.log(` Password: ${account.password}`); console.log(""); } console.log("Network is running. Press Ctrl+C to stop.\n"); await new Promise(() => {}); } main().catch((err) => { console.error("Fatal error:", err); process.exit(1); });