- scripts/verify-pax8-auth.ts loads .env.local, calls getPax8Client().listCompanies(0,1), logs only counts/status (never token/secret) - CLAUDE.md External integrations table gains a PAX8 row (PAX8_* prefix) - INTEGRATIONS.md does not exist at repo root; edit skipped per plan instructions (noted in SUMMARY)
39 lines
1.4 KiB
TypeScript
39 lines
1.4 KiB
TypeScript
/**
|
|
* verify-pax8-auth.ts
|
|
*
|
|
* Live auth-proof for the PAX8 integration (Phase 10 Success Criterion #2).
|
|
* Runs a real OAuth2 client-credentials token exchange against
|
|
* api.pax8.com/v1/token, then a read-only GET /companies call, through the
|
|
* Plan 01 client (lib/services/pax8-client.ts via lib/services/pax8-factory.ts).
|
|
*
|
|
* Requires PAX8_CLIENT_ID and PAX8_CLIENT_SECRET in .env.local (gitignored —
|
|
* `.env*` is covered by .gitignore; never commit real credentials).
|
|
*
|
|
* Run with: npx tsx scripts/verify-pax8-auth.ts
|
|
*
|
|
* Security: this script prints ONLY a success summary (company count /
|
|
* page.totalElements). It never logs the access token or the client secret.
|
|
*/
|
|
|
|
import { config } from 'dotenv';
|
|
import { resolve } from 'path';
|
|
|
|
config({ path: resolve(__dirname, '../.env.local') });
|
|
|
|
import { getPax8Client } from '../lib/services/pax8-factory';
|
|
|
|
async function main(): Promise<void> {
|
|
console.log('[verify-pax8-auth] Requesting live PAX8 token + /companies read...');
|
|
|
|
const client = getPax8Client();
|
|
const result = await client.listCompanies(0, 1);
|
|
|
|
console.log('[verify-pax8-auth] SUCCESS');
|
|
console.log(`[verify-pax8-auth] companies returned this page: ${result.content.length}`);
|
|
console.log(`[verify-pax8-auth] total companies (page.totalElements): ${result.page.totalElements}`);
|
|
}
|
|
|
|
main().catch((err) => {
|
|
console.error('[verify-pax8-auth] FAILED:', err instanceof Error ? err.message : err);
|
|
process.exit(1);
|
|
});
|