mtcute/packages/client/src/methods/auth/send-code.ts

28 lines
753 B
TypeScript
Raw Normal View History

2021-04-08 12:19:38 +03:00
import { TelegramClient } from '../../client'
import { SentCode } from '../../types'
2021-04-08 12:19:38 +03:00
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)
}