- cli/serve.ts: session.hello with a per-session secret, typed methods per tool, project.inspect, portfolio.status over many project folders, progress notifications, cancellation - cli/lib/confirm-token.ts: single-use HMAC tokens bound to method + canonical params + expiry; writes are dry runs without one; no submit / release / publish method exists - cli/lib/runner.ts: shared child runner for mcp and serve, works from a compiled binary - --json on check, testflight / ppo status, next-build, next-version-code, analytics compare, prices import; inspect command; confirm() always answers no under serve - tools/build-sidecars.ts: bun build --compile for five targets, ad-hoc re-sign on macOS, path leak check - tests/serve.test.ts: methods, token binding / expiry / replay, shared vector, stdio and compiled smoke
36 lines
1.6 KiB
TypeScript
36 lines
1.6 KiB
TypeScript
import type { Args } from './args';
|
|
import type { Language, Loaded } from './config';
|
|
import { playCodes } from './config';
|
|
|
|
export interface Ctx { loaded: Loaded; args: Args }
|
|
|
|
export function need<T>(v: T | undefined, what: string): T {
|
|
if (v === undefined || v === null) throw new Error(`storebound.config.ts: ${what} is not set`);
|
|
return v;
|
|
}
|
|
|
|
/** Play language code -> language entry. */
|
|
export function byPlayCode(langs: Language[]): Map<string, Language> {
|
|
const m = new Map<string, Language>();
|
|
for (const l of langs) for (const c of playCodes(l)) m.set(c, l);
|
|
return m;
|
|
}
|
|
|
|
/** App Store locale -> language entry. */
|
|
export function byAppleLocale(langs: Language[]): Map<string, Language> {
|
|
return new Map(langs.filter(l => l.apple).map(l => [l.apple!, l] as const));
|
|
}
|
|
|
|
/**
|
|
* Asks on the terminal unless --yes. Store actions that are public or irreversible go through this.
|
|
* Under `storebound serve` (the desktop sidecar) nothing can answer and nothing may skip the question, not even --yes:
|
|
* those actions stay terminal-only, so the answer is always no.
|
|
*/
|
|
export async function confirm(ctx: Ctx, question: string): Promise<boolean> {
|
|
if (process.env.STOREBOUND_SERVE === '1') { console.error(`confirm-required: ${question}\n terminal only: run it in a terminal`); return false; }
|
|
if (ctx.args.has('yes')) return true;
|
|
if (!process.stdin.isTTY) { console.log(`${question}\n not a terminal: re-run with --yes to confirm`); return false; }
|
|
process.stdout.write(`${question} [y/N] `);
|
|
for await (const line of console) return /^y(es)?$/i.test(line.trim());
|
|
return false;
|
|
}
|