• Start the client in an interactive and declarative manner, by providing callbacks for authorization details.

    This method handles both login and sign up, and also handles 2FV

    All parameters are MaybeDynamic<T>, meaning you can either supply T, or a function that returns MaybePromise<T>

    This method is intended for simple and fast use in automated scripts and bots. If you are developing a custom client, you'll probably need to use other auth methods.

    Parameters

    • client: ITelegramClient
    • params: {
          abortSignal?: AbortSignal;
          botToken?: MaybeDynamic<string>;
          code?: MaybeDynamic<string>;
          codeSentCallback?: ((code: SentCode) => MaybePromise<void>);
          codeSettings?: Omit<RawCodeSettings, "_" | "logoutTokens">;
          forceSms?: boolean;
          futureAuthTokens?: Uint8Array[];
          invalidCodeCallback?: ((type: "code" | "password") => MaybePromise<void>);
          password?: MaybeDynamic<string>;
          phone?: MaybeDynamic<string>;
          qrCodeHandler?: ((url: string, expires: Date) => void);
          session?: string | StringSessionData;
          sessionForce?: boolean;
      }
      • OptionalabortSignal?: AbortSignal

        Abort signal

      • OptionalbotToken?: MaybeDynamic<string>

        Bot token to use. Ignored if phone is supplied.

      • Optionalcode?: MaybeDynamic<string>

        Code sent to the phone (either sms, call, flash call or other). Ignored if botToken is supplied, must be present if phone is supplied.

      • OptionalcodeSentCallback?: ((code: SentCode) => MaybePromise<void>)

        Custom method that is called when a code is sent. Can be used to show a GUI alert of some kind.

        This method is called before start.params.code.

        console.log.

      • OptionalcodeSettings?: Omit<RawCodeSettings, "_" | "logoutTokens">

        Additional code settings to pass to the server

      • OptionalforceSms?: boolean

        Whether to force code delivery through SMS

      • OptionalfutureAuthTokens?: Uint8Array[]

        Saved future auth tokens, if any

      • OptionalinvalidCodeCallback?: ((type: "code" | "password") => MaybePromise<void>)

        If passed, this function will be called if provided code or 2FA password was invalid. New code/password will be requested later.

        If provided code/password is a constant string, providing an invalid one will interrupt authorization flow.

      • Optionalpassword?: MaybeDynamic<string>

        2FA password. Ignored if botToken is supplied

      • Optionalphone?: MaybeDynamic<string>

        Phone number of the account. If account does not exist, it will be created

      • OptionalqrCodeHandler?: ((url: string, expires: Date) => void)

        When passed, QR login flow will be used instead of the regular login flow.

        This function will be called whenever the login URL is changed, and the app is expected to display it as a QR code to the user.

          • (url, expires): void
          • Parameters

            • url: string
            • expires: Date

            Returns void

      • Optionalsession?: string | StringSessionData

        String session exported using TelegramClient.exportSession.

        This simply calls TelegramClient.importSession before anything else.

        Note that passed session will be ignored in case storage already contains authorization.

      • OptionalsessionForce?: boolean

        Whether to overwrite existing session.

    Returns Promise<User>