/** Read-only: list Privy users (DID) + their embedded EOA, to seed user_wallets.
* Usage: node node-executor/privy-whoami.mjs (reads ./.env.privy) */
import fs from 'node:fs';
import { PrivyClient } from '@privy-io/server-auth';
const env = {};
for (const l of fs.readFileSync(new URL('../.env.privy', import.meta.url), 'utf8').split('\n')) {
const t = l.trim(); if (!t || t.startsWith('#')) continue;
const i = t.indexOf('='); if (i > 0) env[t.slice(0, i).trim()] = t.slice(i + 1).trim();
}
const privy = new PrivyClient(env.PRIVY_APP_ID, env.PRIVY_APP_SECRET, { walletApi: { authorizationPrivateKey: env.PRIVY_AUTHORIZATION_KEY } });
const users = await privy.getUsers();
for (const u of users) {
const wallets = (u.linkedAccounts || []).filter((a) => a.type === 'wallet' && a.walletClientType === 'privy').map((a) => a.address);
const email = (u.linkedAccounts || []).find((a) => a.type === 'email')?.address || '';
console.log(JSON.stringify({ did: u.id, email, embeddedEoa: wallets }));
}