@merqva/telegram-passport
Version:
Decrypt/Parse incoming Telegram Passport data
114 lines (113 loc) • 3.25 kB
TypeScript
import { EncryptedPassportElementType } from './types';
export interface BillLike {
files: Array<PassportFile & FileCredentials>;
translation?: Array<PassportFile & FileCredentials>;
}
export interface Credentials {
secure_data: SecureData;
nonce: string;
}
export interface DataCredentials {
data_hash: string;
secret: string;
}
export interface Data<T extends IdDocumentData | PersonalDetails | ResidentialAddress> {
data: T;
}
export interface EncryptedCredentials {
data: string;
hash: string;
secret: string;
}
export interface EncryptedPassportElement {
type: EncryptedPassportElementType;
data?: string;
phone_number?: string;
email?: string;
files?: Array<PassportFile>;
front_side?: PassportFile;
reverse_side?: PassportFile;
selfie?: PassportFile;
translation?: Array<PassportFile>;
hash: string;
}
export interface FileCredentials {
file_hash: string;
secret: string;
}
export interface IdDocumentData {
document_no: string;
expiry_date?: string;
}
export interface IdDocument extends Data<IdDocumentData> {
front_side: PassportFile & FileCredentials;
reverse_side: PassportFile & FileCredentials;
selfie?: PassportFile & FileCredentials;
translation?: Array<PassportFile & FileCredentials>;
}
export interface PassportData {
data: Array<EncryptedPassportElement>;
credentials: EncryptedCredentials;
}
export interface PassportFile {
file_id: string;
file_unique_id: string;
file_size: number;
file_date: number;
}
export interface PersonalDetails {
first_name: string;
last_name: string;
middle_name?: string;
birth_date: string;
gender: 'male' | 'female';
country_code: string;
residence_country_code: string;
first_name_native?: string;
last_name_native?: string;
middle_name_native?: string;
}
export interface RequestedFields extends Omit<Credentials, 'secure_data'> {
personal_details?: Data<PersonalDetails>;
passport?: Omit<IdDocument, 'reverse_side'>;
internal_passport?: IdDocument;
driver_license?: IdDocument;
identity_card?: IdDocument;
address?: Data<ResidentialAddress>;
utility_bill?: BillLike;
bank_statement?: BillLike;
rental_agreement?: BillLike;
passport_registration?: BillLike;
temporary_registration?: BillLike;
phone_number?: string;
email?: string;
}
export interface ResidentialAddress {
street_line1: string;
street_line2?: string;
city: string;
state?: string;
country_code: string;
post_code: string;
}
export interface SecureData {
personal_details?: SecureValue;
passport?: SecureValue;
internal_passport?: SecureValue;
driver_license?: SecureValue;
identity_card?: SecureValue;
address?: SecureValue;
utility_bill?: SecureValue;
bank_statement?: SecureValue;
rental_agreement?: SecureValue;
passport_registration?: SecureValue;
temporary_registration?: SecureValue;
}
export interface SecureValue {
data?: DataCredentials;
front_side?: FileCredentials;
reverse_side?: FileCredentials;
selfie?: FileCredentials;
translation?: Array<FileCredentials>;
files?: Array<FileCredentials>;
}