Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/just-cameron/tangled-cli. Automation-first CLI for Tangled.org
Something went wrong. Try again.
618 B · 22 lines
TypeScript
1234567891011121314151617181920212223import type { TangledApiClient } from '../lib/api-client.js';
/** * Validate that the client is authenticated and has an active session * @throws Error if not authenticated or no session found * @returns The current session with did and handle */export async function requireAuth(client: TangledApiClient): Promise<{ did: string; handle: string;}> { if (!(await client.isAuthenticated())) { throw new Error('Must be authenticated. Run "tangled auth login" first.'); }
const session = client.getSession(); if (!session) { throw new Error('No active session found'); }
return session;}