teleproto 1.216.1 → 1.218.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/LICENSE.txt CHANGED
@@ -1,25 +1,25 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 sanyok12345. All rights reserved.
4
-
5
- This project, teleproto, is an independent work originally derived from GramJS.
6
- GramJS is an open source project licensed under the MIT License.
7
- Portions of teleproto are adapted from GramJS and remain subject to the MIT terms.
8
-
9
- Permission is hereby granted, free of charge, to any person obtaining a copy
10
- of this software and associated documentation files (the "Software"), to deal
11
- in the Software without restriction, including without limitation the rights
12
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
- copies of the Software, and to permit persons to whom the Software is
14
- furnished to do so, subject to the following conditions:
15
-
16
- The above copyright notice and this permission notice shall be included in all
17
- copies or substantial portions of the Software.
18
-
19
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1
+ MIT License
2
+
3
+ Copyright (c) 2025 sanyok12345. All rights reserved.
4
+
5
+ This project, teleproto, is an independent work originally derived from GramJS.
6
+ GramJS is an open source project licensed under the MIT License.
7
+ Portions of teleproto are adapted from GramJS and remain subject to the MIT terms.
8
+
9
+ Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ of this software and associated documentation files (the "Software"), to deal
11
+ in the Software without restriction, including without limitation the rights
12
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ copies of the Software, and to permit persons to whom the Software is
14
+ furnished to do so, subject to the following conditions:
15
+
16
+ The above copyright notice and this permission notice shall be included in all
17
+ copies or substantial portions of the Software.
18
+
19
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
25
  SOFTWARE.
package/README.md CHANGED
@@ -1,98 +1,98 @@
1
- # teleproto
2
-
3
- A modern Telegram client library written in TypeScript for Node.js, forked from [GramJS](https://github.com/gram-js/gramjs) with performance and size improvements.
4
-
5
- ## Quick Start
6
-
7
- Here's how to get started with teleproto:
8
-
9
- ### Installation
10
-
11
- ```bash
12
- $ npm i teleproto
13
- ```
14
-
15
- ### Authentication Setup
16
-
17
- 1. Login to your [Telegram account](https://my.telegram.org/)
18
- 2. Click "API development tools" and create an application
19
- 3. Save your API ID and hash (never share these with anyone)
20
-
21
- ### Basic Usage
22
-
23
- ```javascript
24
- import { TelegramClient } from "teleproto";
25
- import { StringSession } from "teleproto/sessions";
26
- import readline from "readline";
27
-
28
- const apiId = 123456; // Replace with your API ID
29
- const apiHash = "123456abcdefg"; // Replace with your API Hash
30
- const stringSession = new StringSession(""); // Save the string session for later use
31
-
32
- const rl = readline.createInterface({
33
- input: process.stdin,
34
- output: process.stdout,
35
- });
36
-
37
- async function main() {
38
- console.log("Starting teleproto client...");
39
- const client = new TelegramClient(stringSession, apiId, apiHash, {
40
- connectionRetries: 5,
41
- });
42
-
43
- await client.start({
44
- phoneNumber: async () =>
45
- await new Promise(resolve => rl.question("Phone number: ", resolve)),
46
- password: async () =>
47
- await new Promise(resolve => rl.question("Password: ", resolve)),
48
- phoneCode: async () =>
49
- await new Promise(resolve => rl.question("Verification code: ", resolve)),
50
- onError: (err) => console.error(err),
51
- });
52
-
53
- console.log("Connected successfully!");
54
- console.log("Session string:", client.session.save()); // Save this to avoid login next time
55
-
56
- // Send a message to yourself
57
- await client.sendMessage("me", { message: "Hello from teleproto!" });
58
-
59
- // Disconnect when done
60
- await client.disconnect();
61
- rl.close();
62
- }
63
-
64
- main();
65
- ```
66
-
67
- You can also use `StoreSession` to save auth data to a folder instead of a string:
68
-
69
- ```javascript
70
- import { StoreSession } from "teleproto/sessions";
71
- const storeSession = new StoreSession("session_folder");
72
- const client = new TelegramClient(storeSession, apiId, apiHash, {});
73
- ```
74
-
75
- ## API Usage
76
-
77
- ### Calling Raw API Methods
78
-
79
- ```javascript
80
- await client.invoke(new Api.RequestClass({ param1: "value1" }));
81
- ```
82
-
83
- ### Event Handling
84
-
85
- ```javascript
86
- import { NewMessage } from "teleproto/events";
87
-
88
- client.addEventHandler(async (event) => {
89
- console.log("New message received:", event.message.text);
90
-
91
- if (event.message.text === "Hello") {
92
- await event.message.reply("Hi there!");
93
- }
94
- }, new NewMessage({}));
95
- ```
96
-
97
- # Ask a question
1
+ # teleproto
2
+
3
+ A modern Telegram client library written in TypeScript for Node.js, forked from [GramJS](https://github.com/gram-js/gramjs) with performance and size improvements.
4
+
5
+ ## Quick Start
6
+
7
+ Here's how to get started with teleproto:
8
+
9
+ ### Installation
10
+
11
+ ```bash
12
+ $ npm i teleproto
13
+ ```
14
+
15
+ ### Authentication Setup
16
+
17
+ 1. Login to your [Telegram account](https://my.telegram.org/)
18
+ 2. Click "API development tools" and create an application
19
+ 3. Save your API ID and hash (never share these with anyone)
20
+
21
+ ### Basic Usage
22
+
23
+ ```javascript
24
+ import { TelegramClient } from "teleproto";
25
+ import { StringSession } from "teleproto/sessions";
26
+ import readline from "readline";
27
+
28
+ const apiId = 123456; // Replace with your API ID
29
+ const apiHash = "123456abcdefg"; // Replace with your API Hash
30
+ const stringSession = new StringSession(""); // Save the string session for later use
31
+
32
+ const rl = readline.createInterface({
33
+ input: process.stdin,
34
+ output: process.stdout,
35
+ });
36
+
37
+ async function main() {
38
+ console.log("Starting teleproto client...");
39
+ const client = new TelegramClient(stringSession, apiId, apiHash, {
40
+ connectionRetries: 5,
41
+ });
42
+
43
+ await client.start({
44
+ phoneNumber: async () =>
45
+ await new Promise(resolve => rl.question("Phone number: ", resolve)),
46
+ password: async () =>
47
+ await new Promise(resolve => rl.question("Password: ", resolve)),
48
+ phoneCode: async () =>
49
+ await new Promise(resolve => rl.question("Verification code: ", resolve)),
50
+ onError: (err) => console.error(err),
51
+ });
52
+
53
+ console.log("Connected successfully!");
54
+ console.log("Session string:", client.session.save()); // Save this to avoid login next time
55
+
56
+ // Send a message to yourself
57
+ await client.sendMessage("me", { message: "Hello from teleproto!" });
58
+
59
+ // Disconnect when done
60
+ await client.disconnect();
61
+ rl.close();
62
+ }
63
+
64
+ main();
65
+ ```
66
+
67
+ You can also use `StoreSession` to save auth data to a folder instead of a string:
68
+
69
+ ```javascript
70
+ import { StoreSession } from "teleproto/sessions";
71
+ const storeSession = new StoreSession("session_folder");
72
+ const client = new TelegramClient(storeSession, apiId, apiHash, {});
73
+ ```
74
+
75
+ ## API Usage
76
+
77
+ ### Calling Raw API Methods
78
+
79
+ ```javascript
80
+ await client.invoke(new Api.RequestClass({ param1: "value1" }));
81
+ ```
82
+
83
+ ### Event Handling
84
+
85
+ ```javascript
86
+ import { NewMessage } from "teleproto/events";
87
+
88
+ client.addEventHandler(async (event) => {
89
+ console.log("New message received:", event.message.text);
90
+
91
+ if (event.message.text === "Hello") {
92
+ await event.message.reply("Hi there!");
93
+ }
94
+ }, new NewMessage({}));
95
+ ```
96
+
97
+ # Ask a question
98
98
  If you have any questions or need help, feel free to join our [Telegram group](https://t.me/TeleprotoChat) or open an issue on GitHub
package/client/users.js CHANGED
@@ -334,7 +334,7 @@ async function getInputEntity(client, peer) {
334
334
  }
335
335
  }
336
336
  }
337
- throw new Error(`Could not find the input entity for ${JSON.stringify(peer)}.
337
+ throw new Error(`Could not find the input entity for ${JSON.stringify(peer)}.
338
338
  Please read https://` +
339
339
  "docs.telethon.dev/en/stable/concepts/entities.html to" +
340
340
  " find out more details.");
@@ -8,12 +8,12 @@ export declare class CTR {
8
8
  }
9
9
  export declare function createDecipher(algorithm: string, key: Buffer, iv: Buffer): CTR;
10
10
  export declare function createCipher(algorithm: string, key: Buffer, iv: Buffer): CTR;
11
- export declare function randomBytes(count: number): Buffer<ArrayBufferLike>;
11
+ export declare function randomBytes(count: number): NonSharedBuffer;
12
12
  export declare class Hash {
13
13
  private readonly hash;
14
14
  constructor(algorithm: string);
15
15
  update(data: Buffer): void;
16
16
  digest(): any;
17
17
  }
18
- export declare function pbkdf2Sync(password: any, salt: any, iterations: any, keylen: any, digest: any): Buffer<ArrayBufferLike>;
18
+ export declare function pbkdf2Sync(password: any, salt: any, iterations: any, keylen: any, digest: any): NonSharedBuffer;
19
19
  export declare function createHash(algorithm: string): Hash;
package/crypto/words.d.ts CHANGED
@@ -2,5 +2,5 @@ export declare function s2i(str: string, pos: number): number;
2
2
  /**
3
3
  * Helper function for transforming string key to Uint32Array
4
4
  */
5
- export declare function getWords(key: string | Uint8Array | Uint32Array): Uint32Array<ArrayBuffer>;
5
+ export declare function getWords(key: string | Uint8Array | Uint32Array): Uint32Array<ArrayBufferLike>;
6
6
  export declare function xor(left: Uint32Array, right: Uint32Array, to?: Uint32Array<ArrayBufferLike>): void;
package/define.d.ts CHANGED
@@ -1,77 +1,77 @@
1
- import type { Button } from "./tl/custom/button";
2
- import { Api } from "./tl";
3
- import type { CustomFile } from "./client/uploads";
4
- import TypeUser = Api.TypeUser;
5
- import TypeChat = Api.TypeChat;
6
- import TypeInputUser = Api.TypeInputUser;
7
- import TypeInputChannel = Api.TypeInputChannel;
8
- import bigInt from "big-integer";
9
- import { WriteStream } from "fs";
10
-
11
- type ValueOf<T> = T[keyof T];
12
- type Phone = string;
13
- type Username = string;
14
- type PeerID = number;
15
- type Entity = Api.User | Api.Chat | Api.Channel | TypeUser | TypeChat;
16
- type FullEntity =
17
- | Api.UserFull
18
- | Api.messages.ChatFull
19
- | Api.ChatFull
20
- | Api.ChannelFull;
21
- type PeerLike = Api.TypePeer | Api.TypeInputPeer | Entity | FullEntity;
22
- type EntityLike =
23
- | bigInt.BigInteger
24
- | Phone
25
- | Username
26
- | PeerID
27
- | Api.TypePeer
28
- | Api.TypeInputPeer
29
- | Entity
30
- | FullEntity
31
- | TypeUser
32
- | TypeChat
33
- | TypeInputChannel
34
- | TypeInputUser;
35
-
36
- type EntitiesLike = EntityLike[];
37
- type MessageIDLike =
38
- | number
39
- | Api.Message
40
- | Api.MessageService
41
- | Api.TypeInputMessage;
42
- type MessageLike = string | Api.Message;
43
-
44
- type LocalPath = string;
45
- type ExternalUrl = string;
46
- type BotFileID = string;
47
-
48
- type FileLike =
49
- | LocalPath
50
- | ExternalUrl
51
- | BotFileID
52
- | Buffer
53
- | Api.TypeMessageMedia
54
- | Api.TypeInputMedia
55
- | Api.TypeInputFile
56
- | Api.TypeInputFileLocation
57
- | File
58
- | Api.TypePhoto
59
- | Api.TypeDocument
60
- | CustomFile;
61
- type OutFile =
62
- | string
63
- | Buffer
64
- | WriteStream
65
- | { write: Function; close?: Function };
66
- type ProgressCallback = (
67
- downloaded: bigInt.BigInteger,
68
- total: bigInt.BigInteger
69
- ) => void;
70
- type ButtonLike = Api.TypeKeyboardButton | Button;
71
-
72
- type MarkupLike =
73
- | Api.TypeReplyMarkup
74
- | ButtonLike
75
- | ButtonLike[]
76
- | ButtonLike[][];
77
- type DateLike = number;
1
+ import type { Button } from "./tl/custom/button";
2
+ import { Api } from "./tl";
3
+ import type { CustomFile } from "./client/uploads";
4
+ import TypeUser = Api.TypeUser;
5
+ import TypeChat = Api.TypeChat;
6
+ import TypeInputUser = Api.TypeInputUser;
7
+ import TypeInputChannel = Api.TypeInputChannel;
8
+ import bigInt from "big-integer";
9
+ import { WriteStream } from "fs";
10
+
11
+ type ValueOf<T> = T[keyof T];
12
+ type Phone = string;
13
+ type Username = string;
14
+ type PeerID = number;
15
+ type Entity = Api.User | Api.Chat | Api.Channel | TypeUser | TypeChat;
16
+ type FullEntity =
17
+ | Api.UserFull
18
+ | Api.messages.ChatFull
19
+ | Api.ChatFull
20
+ | Api.ChannelFull;
21
+ type PeerLike = Api.TypePeer | Api.TypeInputPeer | Entity | FullEntity;
22
+ type EntityLike =
23
+ | bigInt.BigInteger
24
+ | Phone
25
+ | Username
26
+ | PeerID
27
+ | Api.TypePeer
28
+ | Api.TypeInputPeer
29
+ | Entity
30
+ | FullEntity
31
+ | TypeUser
32
+ | TypeChat
33
+ | TypeInputChannel
34
+ | TypeInputUser;
35
+
36
+ type EntitiesLike = EntityLike[];
37
+ type MessageIDLike =
38
+ | number
39
+ | Api.Message
40
+ | Api.MessageService
41
+ | Api.TypeInputMessage;
42
+ type MessageLike = string | Api.Message;
43
+
44
+ type LocalPath = string;
45
+ type ExternalUrl = string;
46
+ type BotFileID = string;
47
+
48
+ type FileLike =
49
+ | LocalPath
50
+ | ExternalUrl
51
+ | BotFileID
52
+ | Buffer
53
+ | Api.TypeMessageMedia
54
+ | Api.TypeInputMedia
55
+ | Api.TypeInputFile
56
+ | Api.TypeInputFileLocation
57
+ | File
58
+ | Api.TypePhoto
59
+ | Api.TypeDocument
60
+ | CustomFile;
61
+ type OutFile =
62
+ | string
63
+ | Buffer
64
+ | WriteStream
65
+ | { write: Function; close?: Function };
66
+ type ProgressCallback = (
67
+ downloaded: bigInt.BigInteger,
68
+ total: bigInt.BigInteger
69
+ ) => void;
70
+ type ButtonLike = Api.TypeKeyboardButton | Button;
71
+
72
+ type MarkupLike =
73
+ | Api.TypeReplyMarkup
74
+ | ButtonLike
75
+ | ButtonLike[]
76
+ | ButtonLike[][];
77
+ type DateLike = number;
package/errors/Common.js CHANGED
@@ -19,8 +19,8 @@ exports.ReadCancelledError = ReadCancelledError;
19
19
  */
20
20
  class TypeNotFoundError extends Error {
21
21
  constructor(invalidConstructorId, remaining) {
22
- super(`Could not find a matching Constructor ID for the TLObject that was supposed to be
23
- read with ID ${invalidConstructorId}. Most likely, a TLObject was trying to be read when
22
+ super(`Could not find a matching Constructor ID for the TLObject that was supposed to be
23
+ read with ID ${invalidConstructorId}. Most likely, a TLObject was trying to be read when
24
24
  it should not be read. Remaining bytes: ${remaining.length}`);
25
25
  if (typeof alert !== "undefined") {
26
26
  alert(`Missing MTProto Entity: Please, make sure to add TL definition for ID ${invalidConstructorId}`);
package/package.json CHANGED
@@ -1,50 +1,50 @@
1
- {
2
- "name": "teleproto",
3
- "version": "1.216.1",
4
- "description": "NodeJS MTProto API Telegram client library,",
5
- "main": "index.js",
6
- "types": "index.d.ts",
7
- "repository": {
8
- "type": "git",
9
- "url": "git+https://github.com/sanyok12345/teleproto.git"
10
- },
11
- "scripts": {
12
- "docs": "typedoc"
13
- },
14
- "license": "MIT",
15
- "bugs": {
16
- "url": "https://github.com/sanyok12345/teleproto/issues"
17
- },
18
- "keywords": [
19
- "telegram",
20
- "mtproto",
21
- "teleproto",
22
- "client",
23
- "nodejs",
24
- "typescript",
25
- "api"
26
- ],
27
- "homepage": "https://github.com/sanyok12345/teleproto#readme",
28
- "devDependencies": {
29
- "@types/mime": "^2.0.3",
30
- "@types/node": "^22.15.18",
31
- "@types/node-localstorage": "^1.3.0",
32
- "@types/pako": "^1.0.1",
33
- "@types/websocket": "^1.0.4",
34
- "ts-node": "^9.1.1",
35
- "typedoc": "^0.28.7",
36
- "typescript": "^5.8.3",
37
- "util": "^0.12.4"
38
- },
39
- "dependencies": {
40
- "async-mutex": "^0.3.0",
41
- "big-integer": "^1.6.48",
42
- "mime": "^3.0.0",
43
- "node-localstorage": "^2.2.1",
44
- "pako": "^2.0.3",
45
- "socks": "^2.6.2",
46
- "store2": "^2.13.0",
47
- "ts-custom-error": "^3.2.0",
48
- "websocket": "^1.0.34"
49
- }
50
- }
1
+ {
2
+ "name": "teleproto",
3
+ "version": "1.218.0",
4
+ "description": "NodeJS MTProto API Telegram client library,",
5
+ "main": "index.js",
6
+ "types": "index.d.ts",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/sanyok12345/teleproto.git"
10
+ },
11
+ "scripts": {
12
+ "docs": "typedoc"
13
+ },
14
+ "license": "MIT",
15
+ "bugs": {
16
+ "url": "https://github.com/sanyok12345/teleproto/issues"
17
+ },
18
+ "keywords": [
19
+ "telegram",
20
+ "mtproto",
21
+ "teleproto",
22
+ "client",
23
+ "nodejs",
24
+ "typescript",
25
+ "api"
26
+ ],
27
+ "homepage": "https://github.com/sanyok12345/teleproto#readme",
28
+ "devDependencies": {
29
+ "@types/mime": "^2.0.3",
30
+ "@types/node": "^22.15.18",
31
+ "@types/node-localstorage": "^1.3.0",
32
+ "@types/pako": "^1.0.1",
33
+ "@types/websocket": "^1.0.4",
34
+ "ts-node": "^9.1.1",
35
+ "typedoc": "^0.28.7",
36
+ "typescript": "^5.8.3",
37
+ "util": "^0.12.4"
38
+ },
39
+ "dependencies": {
40
+ "async-mutex": "^0.3.0",
41
+ "big-integer": "^1.6.48",
42
+ "mime": "^3.0.0",
43
+ "node-localstorage": "^2.2.1",
44
+ "pako": "^2.0.3",
45
+ "socks": "^2.6.2",
46
+ "store2": "^2.13.0",
47
+ "ts-custom-error": "^3.2.0",
48
+ "websocket": "^1.0.34"
49
+ }
50
+ }
@@ -1,3 +1,3 @@
1
- export declare const LAYER = 216;
1
+ export declare const LAYER = 218;
2
2
  declare const tlobjects: any;
3
3
  export { tlobjects };
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.tlobjects = exports.LAYER = void 0;
4
- exports.LAYER = 216;
4
+ exports.LAYER = 218;
5
5
  const _1 = require(".");
6
6
  const tlobjects = {};
7
7
  exports.tlobjects = tlobjects;