owltide/shared/types/telegram.ts

21 lines
611 B
TypeScript
Raw Normal View History

/*
SPDX-FileCopyrightText: © 2025 Hornwitser <code@hornwitser.no>
SPDX-License-Identifier: AGPL-3.0-or-later
*/
import { z } from "zod/v4-mini";
export const telegramAuthDataSchema = z.catchall(
z.object({
// These fields are pure speculation as the actual API is undocumented.
auth_date: z.number(),
first_name: z.optional(z.string()),
hash: z.string(),
id: z.number(),
last_name: z.optional(z.string()),
photo_url: z.optional(z.string()),
username: z.optional(z.string()),
}),
z.union([z.string(), z.number()]),
);
export type TelegramAuthData = z.infer<typeof telegramAuthDataSchema>;