27 lines
753 B
TypeScript
27 lines
753 B
TypeScript
import { SentCode } from '../../types'
|
|
import { TelegramClient } from '../../client'
|
|
import { normalizePhoneNumber } from '../../utils/misc-utils'
|
|
|
|
/**
|
|
* Send the confirmation code to the given phone number
|
|
*
|
|
* @param phone Phone number in international format.
|
|
* @returns An object containing information about the sent confirmation code
|
|
* @internal
|
|
*/
|
|
export async function sendCode(
|
|
this: TelegramClient,
|
|
phone: string
|
|
): Promise<SentCode> {
|
|
phone = normalizePhoneNumber(phone)
|
|
|
|
const res = await this.call({
|
|
_: 'auth.sendCode',
|
|
phoneNumber: phone,
|
|
apiId: this._initConnectionParams.apiId,
|
|
apiHash: this._apiHash,
|
|
settings: { _: 'codeSettings' },
|
|
})
|
|
|
|
return new SentCode(res)
|
|
}
|