diff --git a/e2e/deno/tests/01.auth.ts b/e2e/deno/tests/01.auth.ts index 1b739983..0f5a6be0 100644 --- a/e2e/deno/tests/01.auth.ts +++ b/e2e/deno/tests/01.auth.ts @@ -1,6 +1,6 @@ import { assertEquals } from 'https://deno.land/std@0.223.0/assert/mod.ts' -import { MtcuteError } from '@mtcute/core' +import { MtcuteError, tl } from '@mtcute/core' import { BaseTelegramClient, TelegramClient } from '@mtcute/core/client.js' import { getApiParams } from '../utils.ts' @@ -29,7 +29,10 @@ Deno.test('1. authorization', { sanitizeResources: false }, async (t) => { code: () => '22222', }) } catch (e) { - if (e instanceof MtcuteError && e.message.match(/Signup is no longer supported|2FA is enabled/)) { + if ( + (e instanceof MtcuteError && e.message.match(/Signup is no longer supported|2FA is enabled/)) || + tl.RpcError.is(e, 'SESSION_PASSWORD_NEEDED') + ) { // retry with another number continue } else { @@ -64,7 +67,10 @@ Deno.test('1. authorization', { sanitizeResources: false }, async (t) => { code: () => '11111', }) } catch (e) { - if (e instanceof MtcuteError && e.message.match(/Signup is no longer supported|2FA is enabled/)) { + if ( + (e instanceof MtcuteError && e.message.match(/Signup is no longer supported|2FA is enabled/)) || + tl.RpcError.is(e, 'SESSION_PASSWORD_NEEDED') + ) { // retry with another number continue } else { diff --git a/e2e/node/ts/tests/01.auth.ts b/e2e/node/ts/tests/01.auth.ts index 1c4b7e6e..e5367888 100644 --- a/e2e/node/ts/tests/01.auth.ts +++ b/e2e/node/ts/tests/01.auth.ts @@ -1,7 +1,7 @@ import { expect } from 'chai' import { describe, it } from 'mocha' -import { MtcuteError } from '@mtcute/core' +import { MtcuteError, tl } from '@mtcute/core' import { BaseTelegramClient, TelegramClient } from '@mtcute/core/client.js' import { getApiParams } from '../utils.js' @@ -32,7 +32,10 @@ describe('1. authorization', function () { code: () => '22222', }) } catch (e) { - if (e instanceof MtcuteError && e.message.match(/Signup is no longer supported|2FA is enabled/)) { + if ( + (e instanceof MtcuteError && e.message.match(/Signup is no longer supported|2FA is enabled/)) || + tl.RpcError.is(e, 'SESSION_PASSWORD_NEEDED') + ) { // retry with another number continue } else { @@ -67,7 +70,10 @@ describe('1. authorization', function () { code: () => '11111', }) } catch (e) { - if (e instanceof MtcuteError && e.message.match(/Signup is no longer supported|2FA is enabled/)) { + if ( + (e instanceof MtcuteError && e.message.match(/Signup is no longer supported|2FA is enabled/)) || + tl.RpcError.is(e, 'SESSION_PASSWORD_NEEDED') + ) { // retry with another number continue } else {