diff --git a/packages/core/src/highlevel/client.ts b/packages/core/src/highlevel/client.ts index bd70098b..ceddd3c2 100644 --- a/packages/core/src/highlevel/client.ts +++ b/packages/core/src/highlevel/client.ts @@ -729,6 +729,12 @@ export interface TelegramClient extends ITelegramClient { */ onUrlUpdated: (url: string, expires: Date) => void + /** + * Function that will be called when the user has scanned the QR code + * (i.e. when `updateLoginToken` is received), and the library is finalizing the auth + */ + onQrScanned?: () => void + /** Password for 2FA */ password?: MaybeDynamic diff --git a/packages/core/src/highlevel/methods/auth/sign-in-qr.ts b/packages/core/src/highlevel/methods/auth/sign-in-qr.ts index 07ef3498..0b9a1637 100644 --- a/packages/core/src/highlevel/methods/auth/sign-in-qr.ts +++ b/packages/core/src/highlevel/methods/auth/sign-in-qr.ts @@ -27,6 +27,12 @@ export async function signInQr( */ onUrlUpdated: (url: string, expires: Date) => void + /** + * Function that will be called when the user has scanned the QR code + * (i.e. when `updateLoginToken` is received), and the library is finalizing the auth + */ + onQrScanned?: () => void + /** Password for 2FA */ password?: MaybeDynamic @@ -42,7 +48,7 @@ export async function signInQr( abortSignal?: AbortSignal }, ): Promise { - const { onUrlUpdated, abortSignal } = params + const { onUrlUpdated, abortSignal, onQrScanned } = params let waiter: ControllablePromise | undefined @@ -56,6 +62,7 @@ export async function signInQr( const onUpdate: ServerUpdateHandler = (upd) => { if (upd._ === 'updateShort' && upd.update._ === 'updateLoginToken') { + onQrScanned?.() waiter?.resolve() client.onServerUpdate(originalHandler) }