teleproto 1.225.4 → 1.227.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Version.d.ts +1 -1
- package/Version.js +1 -1
- package/client/TelegramClient.d.ts +1 -1
- package/client/auth.d.ts +1 -1
- package/client/auth.js +16 -1
- package/errors/RPCBaseErrors.d.ts +0 -9
- package/errors/RPCBaseErrors.js +1 -14
- package/errors/RPCErrorList.d.ts +2871 -26
- package/errors/RPCErrorList.js +7874 -89
- package/errors/aliases.d.ts +18 -0
- package/errors/aliases.js +15 -0
- package/errors/index.d.ts +3 -1
- package/errors/index.js +23 -6
- package/package.json +1 -1
- package/tl/generated/api-definitions.js +1 -1
- package/tl/generated/api.d.ts +771 -38
- package/tl/runtime/registry.d.ts +1 -1
- package/tl/runtime/registry.js +1 -1
package/Version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "1.
|
|
1
|
+
export declare const version = "1.227.0";
|
package/Version.js
CHANGED
|
@@ -70,7 +70,7 @@ export declare class TelegramClient extends TelegramBaseClient {
|
|
|
70
70
|
*
|
|
71
71
|
* You can now use the client instance to call other api requests.
|
|
72
72
|
*/
|
|
73
|
-
start(authParams
|
|
73
|
+
start(authParams?: authMethods.UserAuthParams | authMethods.BotAuthParams): Promise<void>;
|
|
74
74
|
/**
|
|
75
75
|
* Checks whether the current client is authorized or not. (logged in as a user)
|
|
76
76
|
* @example
|
package/client/auth.d.ts
CHANGED
|
@@ -114,7 +114,7 @@ export interface ApiCredentials {
|
|
|
114
114
|
apiHash: string;
|
|
115
115
|
}
|
|
116
116
|
/** @hidden */
|
|
117
|
-
export declare function start(client: TelegramClient, authParams
|
|
117
|
+
export declare function start(client: TelegramClient, authParams?: UserAuthParams | BotAuthParams): Promise<void>;
|
|
118
118
|
/** @hidden */
|
|
119
119
|
export declare function checkAuthorization(client: TelegramClient): Promise<boolean>;
|
|
120
120
|
/** @hidden */
|
package/client/auth.js
CHANGED
|
@@ -49,6 +49,7 @@ const tl_1 = require("../tl");
|
|
|
49
49
|
const utils = __importStar(require("../Utils"));
|
|
50
50
|
const Helpers_1 = require("../Helpers");
|
|
51
51
|
const Password_1 = require("../Password");
|
|
52
|
+
const errors_1 = require("../errors");
|
|
52
53
|
const QR_CODE_TIMEOUT = 30000;
|
|
53
54
|
// region public methods
|
|
54
55
|
/** @hidden */
|
|
@@ -56,9 +57,23 @@ async function start(client, authParams) {
|
|
|
56
57
|
if (!client.connected) {
|
|
57
58
|
await client.connect();
|
|
58
59
|
}
|
|
59
|
-
|
|
60
|
+
// Probe authorization inline (instead of checkAuthorization) so we can keep
|
|
61
|
+
// the actual error the server returned — e.g. AuthKeyUnregisteredError or
|
|
62
|
+
// SessionRevokedError on a revoked session — rather than discarding it.
|
|
63
|
+
let authError;
|
|
64
|
+
try {
|
|
65
|
+
await client.invoke(new tl_1.Api.updates.GetState());
|
|
60
66
|
return;
|
|
61
67
|
}
|
|
68
|
+
catch (e) {
|
|
69
|
+
authError = e;
|
|
70
|
+
}
|
|
71
|
+
// Not authorized and no way to (re)login: surface the real reason instead
|
|
72
|
+
// of crashing on `"phoneNumber" in undefined` further down in _authFlow.
|
|
73
|
+
if (!authParams ||
|
|
74
|
+
(!("phoneNumber" in authParams) && !("botAuthToken" in authParams))) {
|
|
75
|
+
throw (authError !== null && authError !== void 0 ? authError : new errors_1.UnauthorizedError("Not authorized and no auth parameters were provided to log in.", undefined));
|
|
76
|
+
}
|
|
62
77
|
const apiCredentials = {
|
|
63
78
|
apiId: client.apiId,
|
|
64
79
|
apiHash: client.apiHash,
|
|
@@ -65,15 +65,6 @@ export declare class FloodError extends RPCError {
|
|
|
65
65
|
code: number;
|
|
66
66
|
errorMessage: string;
|
|
67
67
|
}
|
|
68
|
-
/**
|
|
69
|
-
* The account is frozen and cannot use this method.
|
|
70
|
-
* Clients should call help.getAppConfig to get freeze_since_date,
|
|
71
|
-
* freeze_until_date, and freeze_appeal_url.
|
|
72
|
-
*/
|
|
73
|
-
export declare class FrozenError extends RPCError {
|
|
74
|
-
code: number;
|
|
75
|
-
errorMessage: string;
|
|
76
|
-
}
|
|
77
68
|
/**
|
|
78
69
|
* An internal server error occurred while a request was being processed
|
|
79
70
|
* for example, there was a disruption while accessing a database or file
|
package/errors/RPCBaseErrors.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TimedOutError = exports.ServerError = exports.
|
|
3
|
+
exports.TimedOutError = exports.ServerError = exports.FloodError = exports.AuthKeyError = exports.NotFoundError = exports.ForbiddenError = exports.UnauthorizedError = exports.BadRequestError = exports.InvalidDCError = exports.RPCError = void 0;
|
|
4
4
|
const ts_custom_error_1 = require("ts-custom-error");
|
|
5
5
|
class RPCError extends ts_custom_error_1.CustomError {
|
|
6
6
|
constructor(message, request, code) {
|
|
@@ -107,19 +107,6 @@ class FloodError extends RPCError {
|
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
109
|
exports.FloodError = FloodError;
|
|
110
|
-
/**
|
|
111
|
-
* The account is frozen and cannot use this method.
|
|
112
|
-
* Clients should call help.getAppConfig to get freeze_since_date,
|
|
113
|
-
* freeze_until_date, and freeze_appeal_url.
|
|
114
|
-
*/
|
|
115
|
-
class FrozenError extends RPCError {
|
|
116
|
-
constructor() {
|
|
117
|
-
super(...arguments);
|
|
118
|
-
this.code = 420;
|
|
119
|
-
this.errorMessage = "FROZEN";
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
exports.FrozenError = FrozenError;
|
|
123
110
|
/**
|
|
124
111
|
* An internal server error occurred while a request was being processed
|
|
125
112
|
* for example, there was a disruption while accessing a database or file
|