ZZZ Digital Lab

Back to HushBrief

scripts/preflight.mjs

import { checkLocal } from './configure.mjs';
import { readFile } from 'node:fs/promises';
import { resolve } from 'node:path';
import { root } from './configure.mjs';

const args = new Set(process.argv.slice(2));
const publicOnly = args.has('--public-only');
console.log('HushBrief pre-flight · no network calls, credentials or field values in this report');
if (publicOnly) console.log('UNVERIFIED: private configuration intentionally not read (--public-only).');
else {
  const config = await checkLocal({ release: args.has('--release') });
  console.log(config.ok ? 'PASS: Firebase web configuration and Enterprise site-key formats.' : 'BLOCKED: client configuration:');
  for (const issue of config.issues) console.log('  MISSING / FIX: ' + issue);
  if (config.debug) console.log('LOCAL DEBUG: owner must privately register this fresh browser’s generated App Check debug token. A fresh profile generates a new token.');
  if (!config.ok) process.exitCode = 1;
}
const hosting = JSON.parse(await readFile(resolve(root, 'firebase.json'), 'utf8'));
if (hosting.hosting?.public === 'dist') console.log('PASS: Firebase Hosting targets dist; no project identifier stored.');
else { console.log('MISSING: firebase.json hosting.public must be dist.'); process.exitCode = 1; }
console.log(`UNVERIFIED console-only pieces (local format checks cannot inspect your project):
  1. Firebase Web app registration matches this configuration.
  2. Firebase AI Logic API is enabled with Gemini Developer API backend.
  3. Gemini / Generative Language API and selected model access are enabled.
  4. App Check app registration uses the reCAPTCHA Enterprise provider and matching site key.
  5. Production hosted domain is allowed by that site key; localhost uses a privately registered debug token instead.
  6. App Check enforcement for Firebase AI Logic is ON.
UNVERIFIED runtime: genuine Gemini cloud response accepted through App Check; real Nano SDK response.
NEXT: npm run dev:live → Firebase workspace → fictional example → consent → Create handoff.
Expected cloud result: “Gemini · cloud”. A local-rules result is recovery, not successful Firebase validation.
If App Check fails: check pieces 4–6 and the fresh-profile debug-token registration.
If access is rejected: check pieces 1–3 and App Check acceptance. If quota fails: review project quota.
RELEASE GATE: this report cannot certify console settings. Validate the live response and hosted domain personally before deployment or filming.`);
// Unknown service state must never produce a green release gate.
if (args.has('--release')) process.exitCode = 1;