← back to Nineoh Guide
scripts/check-approval.mjs
26 lines
#!/usr/bin/env node
// Read-only: report the App Store review state of Unofficial 90210 Guide.
// When it reaches READY_FOR_SALE / PENDING_DEVELOPER_RELEASE / APPROVED, it's
// time to link the AdMob app (id 3798456380) to the App Store listing.
// Usage: node scripts/check-approval.mjs (run from anywhere; keypath is absolute)
import { readFileSync } from 'node:fs';
import { createSign } from 'node:crypto';
const KEY = '/Users/macstudio3/Projects/tesla/apps/mobile/credentials/AuthKey_72Y2TZT54R.p8';
const key = readFileSync(KEY, 'utf8');
const b64u = (o) => Buffer.from(typeof o === 'string' ? o : JSON.stringify(o)).toString('base64url');
const now = Math.floor(Date.now() / 1000);
const jwt = `${b64u({ alg: 'ES256', kid: '72Y2TZT54R', typ: 'JWT' })}.${b64u({ iss: 'cfbd63ed-301b-465c-aad7-49e94420ad70', iat: now, exp: now + 600, aud: 'appstoreconnect-v1' })}`;
const sg = createSign('SHA256'); sg.update(jwt); sg.end();
const token = `${jwt}.${sg.sign({ key, dsaEncoding: 'ieee-p1363' }).toString('base64url')}`;
const r = await fetch('https://api.appstoreconnect.apple.com/v1/apps/6798381949/appStoreVersions?fields[appStoreVersions]=appStoreState,versionString&limit=1', { headers: { Authorization: `Bearer ${token}` } });
const j = await r.json();
const v = j.data?.[0]?.attributes;
const state = v?.appStoreState;
const LIVE = ['READY_FOR_SALE', 'PENDING_DEVELOPER_RELEASE', 'PENDING_APPLE_RELEASE', 'APPROVED'];
console.log(`Unofficial 90210 Guide v${v?.versionString} → ${state}`);
if (LIVE.includes(state)) {
console.log('APPROVED ✅ — time to link the AdMob app (3798456380) to the App Store listing.');
process.exit(10);
}
process.exit(0);