|
@@ -93,7 +93,7 @@ export async function start(
|
|
|
|
|
|
const apiCredentials = {
|
|
|
apiId: client.apiId,
|
|
|
- apiHash: client.apiHash
|
|
|
+ apiHash: client.apiHash,
|
|
|
};
|
|
|
|
|
|
await _authFlow(client, apiCredentials, authParams);
|
|
@@ -150,7 +150,7 @@ export async function signInUser(
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
- } catch (err:any) {
|
|
|
+ } catch (err: any) {
|
|
|
if (typeof authParams.phoneNumber !== "function") {
|
|
|
throw err;
|
|
|
}
|
|
@@ -170,7 +170,7 @@ export async function signInUser(
|
|
|
try {
|
|
|
try {
|
|
|
phoneCode = await authParams.phoneCode(isCodeViaApp);
|
|
|
- } catch (err:any) {
|
|
|
+ } catch (err: any) {
|
|
|
// This is the support for changing phone number from the phone code screen.
|
|
|
if (err.errorMessage === "RESTART_AUTH") {
|
|
|
return client.signInUser(apiCredentials, authParams);
|
|
@@ -187,7 +187,7 @@ export async function signInUser(
|
|
|
new Api.auth.SignIn({
|
|
|
phoneNumber,
|
|
|
phoneCodeHash,
|
|
|
- phoneCode
|
|
|
+ phoneCode,
|
|
|
})
|
|
|
);
|
|
|
|
|
@@ -198,7 +198,7 @@ export async function signInUser(
|
|
|
}
|
|
|
|
|
|
return result.user;
|
|
|
- } catch (err:any) {
|
|
|
+ } catch (err: any) {
|
|
|
if (err.errorMessage === "SESSION_PASSWORD_NEEDED") {
|
|
|
return client.signInWithPassword(apiCredentials, authParams);
|
|
|
} else {
|
|
@@ -229,7 +229,7 @@ export async function signInUser(
|
|
|
phoneNumber,
|
|
|
phoneCodeHash,
|
|
|
firstName,
|
|
|
- lastName
|
|
|
+ lastName,
|
|
|
})
|
|
|
)) as Api.auth.Authorization;
|
|
|
|
|
@@ -237,13 +237,13 @@ export async function signInUser(
|
|
|
// This is a violation of Telegram rules: the user should be presented with and accept TOS.
|
|
|
await client.invoke(
|
|
|
new Api.help.AcceptTermsOfService({
|
|
|
- id: termsOfService.id
|
|
|
+ id: termsOfService.id,
|
|
|
})
|
|
|
);
|
|
|
}
|
|
|
|
|
|
return user;
|
|
|
- } catch (err:any) {
|
|
|
+ } catch (err: any) {
|
|
|
const shouldWeStop = await authParams.onError(err);
|
|
|
if (shouldWeStop) {
|
|
|
throw new Error("AUTH_USER_CANCEL");
|
|
@@ -268,7 +268,7 @@ export async function signInUserWithQrCode(
|
|
|
new Api.auth.ExportLoginToken({
|
|
|
apiId: Number(apiCredentials.apiId),
|
|
|
apiHash: apiCredentials.apiHash,
|
|
|
- exceptIds: []
|
|
|
+ exceptIds: [],
|
|
|
})
|
|
|
);
|
|
|
|
|
@@ -280,7 +280,7 @@ export async function signInUserWithQrCode(
|
|
|
if (authParams.qrCode) {
|
|
|
await Promise.race([
|
|
|
authParams.qrCode({ token, expires }),
|
|
|
- sleep(QR_CODE_TIMEOUT)
|
|
|
+ sleep(QR_CODE_TIMEOUT),
|
|
|
]);
|
|
|
}
|
|
|
await sleep(QR_CODE_TIMEOUT);
|
|
@@ -306,7 +306,7 @@ export async function signInUserWithQrCode(
|
|
|
new Api.auth.ExportLoginToken({
|
|
|
apiId: Number(apiCredentials.apiId),
|
|
|
apiHash: apiCredentials.apiHash,
|
|
|
- exceptIds: []
|
|
|
+ exceptIds: [],
|
|
|
})
|
|
|
);
|
|
|
if (
|
|
@@ -318,7 +318,7 @@ export async function signInUserWithQrCode(
|
|
|
await client._switchDC(result2.dcId);
|
|
|
const migratedResult = await client.invoke(
|
|
|
new Api.auth.ImportLoginToken({
|
|
|
- token: result2.token
|
|
|
+ token: result2.token,
|
|
|
})
|
|
|
);
|
|
|
|
|
@@ -329,7 +329,7 @@ export async function signInUserWithQrCode(
|
|
|
return migratedResult.authorization.user;
|
|
|
}
|
|
|
}
|
|
|
- } catch (err:any) {
|
|
|
+ } catch (err: any) {
|
|
|
if (err.errorMessage === "SESSION_PASSWORD_NEEDED") {
|
|
|
return client.signInWithPassword(apiCredentials, authParams);
|
|
|
}
|
|
@@ -356,7 +356,7 @@ export async function sendCode(
|
|
|
phoneNumber,
|
|
|
apiId,
|
|
|
apiHash,
|
|
|
- settings: new Api.CodeSettings({})
|
|
|
+ settings: new Api.CodeSettings({}),
|
|
|
})
|
|
|
);
|
|
|
|
|
@@ -365,22 +365,22 @@ export async function sendCode(
|
|
|
return {
|
|
|
phoneCodeHash: sendResult.phoneCodeHash,
|
|
|
isCodeViaApp:
|
|
|
- sendResult.type instanceof Api.auth.SentCodeTypeApp
|
|
|
+ sendResult.type instanceof Api.auth.SentCodeTypeApp,
|
|
|
};
|
|
|
}
|
|
|
|
|
|
const resendResult = await client.invoke(
|
|
|
new Api.auth.ResendCode({
|
|
|
phoneNumber,
|
|
|
- phoneCodeHash: sendResult.phoneCodeHash
|
|
|
+ phoneCodeHash: sendResult.phoneCodeHash,
|
|
|
})
|
|
|
);
|
|
|
|
|
|
return {
|
|
|
phoneCodeHash: resendResult.phoneCodeHash,
|
|
|
- isCodeViaApp: resendResult.type instanceof Api.auth.SentCodeTypeApp
|
|
|
+ isCodeViaApp: resendResult.type instanceof Api.auth.SentCodeTypeApp,
|
|
|
};
|
|
|
- } catch (err:any) {
|
|
|
+ } catch (err: any) {
|
|
|
if (err.errorMessage === "AUTH_RESTART") {
|
|
|
return client.sendCode(apiCredentials, phoneNumber, forceSMS);
|
|
|
} else {
|
|
@@ -417,12 +417,12 @@ export async function signInWithPassword(
|
|
|
);
|
|
|
const { user } = (await client.invoke(
|
|
|
new Api.auth.CheckPassword({
|
|
|
- password: passwordSrpCheck
|
|
|
+ password: passwordSrpCheck,
|
|
|
})
|
|
|
)) as Api.auth.Authorization;
|
|
|
|
|
|
return user;
|
|
|
- } catch (err:any) {
|
|
|
+ } catch (err: any) {
|
|
|
const shouldWeStop = await authParams.onError(err);
|
|
|
if (shouldWeStop) {
|
|
|
throw new Error("AUTH_USER_CANCEL");
|
|
@@ -461,7 +461,7 @@ export async function signInBot(
|
|
|
new Api.auth.ImportBotAuthorization({
|
|
|
apiId,
|
|
|
apiHash,
|
|
|
- botAuthToken
|
|
|
+ botAuthToken,
|
|
|
})
|
|
|
)) as Api.auth.Authorization;
|
|
|
return user;
|