Add the concept of authentication methods that authenticate an account where using the telegram login widget is one such method. If a login is done with an authentication method that's not associated with any account the session ends up with the data from the authentication method in order to allow registering a new account with the authentication method. This has to be stored on the session as otherwise it wouldn't be possible to implement authentication methods such as OAuth2 that takes the user to a third-party site and then redirects the browser back.
20 lines
611 B
TypeScript
20 lines
611 B
TypeScript
/*
|
|
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>;
|