@mosaic/mosaic is now the single package providing both: - 'mosaic' binary (CLI: yolo, coord, prdy, tui, gateway, etc.) - 'mosaic-wizard' binary (installation wizard) Changes: - Move packages/cli/src/* into packages/mosaic/src/ - Convert dynamic @mosaic/mosaic imports to static relative imports - Add CLI deps (ink, react, socket.io-client, @mosaic/config) to mosaic - Add jsx: react-jsx to mosaic's tsconfig - Exclude packages/cli from workspace (pnpm-workspace.yaml) - Update install.sh to install @mosaic/mosaic instead of @mosaic/cli - Bump version to 0.0.17 This eliminates the circular dependency between @mosaic/cli and @mosaic/mosaic that was blocking the build graph.
30 lines
782 B
TypeScript
30 lines
782 B
TypeScript
import type { AuthResult } from '../auth.js';
|
|
|
|
export interface AuthContext {
|
|
gateway: string;
|
|
session: AuthResult;
|
|
cookie: string;
|
|
}
|
|
|
|
/**
|
|
* Load and validate the user's auth session.
|
|
* Exits with an error message if not signed in or session expired.
|
|
*/
|
|
export async function withAuth(gateway: string): Promise<AuthContext> {
|
|
const { loadSession, validateSession } = await import('../auth.js');
|
|
|
|
const session = loadSession(gateway);
|
|
if (!session) {
|
|
console.error('Not signed in. Run `mosaic login` first.');
|
|
process.exit(1);
|
|
}
|
|
|
|
const valid = await validateSession(gateway, session.cookie);
|
|
if (!valid) {
|
|
console.error('Session expired. Run `mosaic login` again.');
|
|
process.exit(1);
|
|
}
|
|
|
|
return { gateway, session, cookie: session.cookie };
|
|
}
|