/** * The partner API from your server (Node 18+): lessons, participants' links, minutes, webhooks. * The API key stays on the server — never in the browser. * * const wb = new WhiteboardPartner({ apiKey: process.env.WB_API_KEY! }) * const lesson = await wb.createLesson({ title: 'Дроби, 5 класс', externalId: 'course-7/lesson-3' }) * const { url } = await wb.createLink(lesson.id, { id: user.id, name: user.name, role: 'student' }) * * // a webhook (express: app.post('/wb', express.raw({ type: 'application/json' }), …)) * if (!verifyWebhook({ secret, header: req.get('X-Whiteboard-Signature'), body: req.body })) return res.sendStatus(400) */ export declare const DEFAULT_BASE_URL = "https://api.rismik.ru"; export type LessonMode = 'full' | 'board_only'; export type ParticipantRole = 'teacher' | 'student'; export type Lesson = { id: string; external_id: string | null; title: string; mode: LessonMode; created_at: string; started_at: string | null; ended_at: string | null; billed_seconds: number; archived: boolean; }; export type Link = { url: string; token: string; expires_at: string; }; /** Shared links of a lesson: whoever opens one enters a name (pupils' / teacher's); the iframe for a site. */ export type JoinLinks = { pupil_url: string; host_url: string; embed_code: string; }; export type Balance = { balance_seconds: number; balance_minutes: number; }; export type Usage = { total_seconds: number; items: { lesson_id: string; external_id: string | null; day: string; seconds: number; }[]; }; export type WebhookEvent = { id: number; type: 'lesson.started' | 'lesson.ended'; created_at: string; data: LessonEventData; } | { id: number; type: 'participant.joined'; created_at: string; data: ParticipantData; } | { id: number; type: 'balance.low' | 'balance.exhausted'; created_at: string; data: Balance; } | { id: number; type: 'webhook.test'; created_at: string; data: { message: string; }; }; export type LessonEventData = { lesson_id: string; external_id: string | null; started_at: string | null; ended_at: string | null; minutes: number; }; export type ParticipantData = { lesson_id: string; external_id: string | null; role: ParticipantRole; name: string | null; }; export declare class WhiteboardApiError extends Error { status: number; code: string | undefined; detail: unknown; constructor(message: string, status: number, code: string | undefined, detail: unknown); } export type PartnerOptions = { apiKey: string; /** The API host (default: production). */ baseUrl?: string; fetch?: typeof fetch; timeoutMs?: number; }; export declare class WhiteboardPartner { private readonly apiKey; private readonly baseUrl; private readonly fetchImpl; private readonly timeoutMs; constructor(options: PartnerOptions); private request; createLesson(input: { title: string; externalId?: string; mode?: LessonMode; subjectMode?: string; }): Promise; getLesson(id: string): Promise; /** Your own id of a lesson → the lesson (or null). */ findLesson(externalId: string): Promise; archiveLesson(id: string): Promise; /** A personal link to the lesson; give it to that person only (it is their identity). */ createLink(lessonId: string, user: { id: string; name: string; role: ParticipantRole; }, options?: { ttlMinutes?: number; }): Promise; /** Shared links (no personal ones): the pupils' link and code for a site, the teacher's link. renew: new ones, the old stop opening. */ joinLinks(lessonId: string, options?: { renew?: boolean; }): Promise; /** The board's content as JSON (elements and pages), to keep on your side. */ snapshot(lessonId: string): Promise>; /** The latest thumbnail of the board (PNG). */ preview(lessonId: string): Promise; balance(): Promise; usage(range?: { from?: string; to?: string; }): Promise; /** A new webhook address; the signing secret is returned once — keep it. */ setWebhook(url: string): Promise<{ url: string; secret: string; }>; deleteWebhook(): Promise; testWebhook(): Promise<{ queued: boolean; }>; } /** * Is this webhook ours and fresh? `body` is the raw request body (bytes or string) exactly as * received — parse JSON only after the check. */ export declare function verifyWebhook(input: { secret: string; header: string | null | undefined; body: string | Uint8Array; toleranceSeconds?: number; now?: number; }): boolean; /** verifyWebhook + JSON: the event, or null for a request that is not ours. */ export declare function parseWebhook(input: Parameters[0]): WebhookEvent | null;