@mtkruto/node 0.1.124 → 0.1.125
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/esm/0_deps.d.ts +1 -0
- package/esm/0_deps.js +1 -0
- package/esm/1_utilities.d.ts +1 -1
- package/esm/1_utilities.js +1 -1
- package/esm/4_constants.d.ts +1 -1
- package/esm/4_constants.js +1 -1
- package/esm/client/1_client_abstract.d.ts +1 -1
- package/esm/client/3_types.d.ts +56 -0
- package/esm/client/5_client.d.ts +17 -1
- package/esm/client/5_client.js +152 -49
- package/esm/connection/0_connection.d.ts +4 -0
- package/esm/connection/0_connection.js +6 -0
- package/esm/deps/deno.land/std@0.208.0/media_types/_db.d.ts +5 -0
- package/esm/deps/deno.land/std@0.208.0/media_types/_db.js +33 -0
- package/esm/deps/deno.land/std@0.208.0/media_types/_util.d.ts +21 -0
- package/esm/deps/deno.land/std@0.208.0/media_types/_util.js +122 -0
- package/esm/deps/deno.land/std@0.208.0/media_types/content_type.d.ts +38 -0
- package/esm/deps/deno.land/std@0.208.0/media_types/content_type.js +60 -0
- package/esm/deps/deno.land/std@0.208.0/media_types/format_media_type.d.ts +16 -0
- package/esm/deps/deno.land/std@0.208.0/media_types/format_media_type.js +61 -0
- package/esm/deps/deno.land/std@0.208.0/media_types/get_charset.d.ts +15 -0
- package/esm/deps/deno.land/std@0.208.0/media_types/get_charset.js +37 -0
- package/esm/deps/deno.land/std@0.208.0/media_types/parse_media_type.d.ts +37 -0
- package/esm/deps/deno.land/std@0.208.0/media_types/parse_media_type.js +122 -0
- package/esm/deps/deno.land/std@0.208.0/media_types/vendor/mime-db.v1.52.0.d.ts +8518 -0
- package/esm/deps/deno.land/std@0.208.0/media_types/vendor/mime-db.v1.52.0.js +8555 -0
- package/esm/storage/0_storage.d.ts +1 -0
- package/esm/storage/1_storage_indexed_db.d.ts +4 -3
- package/esm/storage/1_storage_indexed_db.js +17 -8
- package/esm/storage/1_storage_local_storage.d.ts +2 -2
- package/esm/storage/1_storage_local_storage.js +3 -0
- package/esm/storage/1_storage_memory.d.ts +1 -0
- package/esm/storage/1_storage_memory.js +3 -0
- package/esm/storage/1_storage_session_storage.d.ts +1 -0
- package/esm/storage/1_storage_session_storage.js +3 -0
- package/esm/transport/0_transport.d.ts +1 -1
- package/esm/transport/0_transport.js +0 -6
- package/esm/transport/1_transport_abridged.d.ts +1 -0
- package/esm/transport/1_transport_abridged.js +9 -5
- package/esm/transport/1_transport_intermediate.d.ts +1 -0
- package/esm/transport/1_transport_intermediate.js +8 -4
- package/esm/types/1_chat.d.ts +2 -15
- package/esm/types/1_chat.js +3 -14
- package/esm/types/1_user.js +4 -2
- package/esm/types/3_message.d.ts +2 -2
- package/esm/types/3_message.js +6 -6
- package/esm/utilities/{0_base64.js → 1_base64.js} +2 -1
- package/package.json +1 -1
- package/script/0_deps.d.ts +1 -0
- package/script/0_deps.js +3 -1
- package/script/1_utilities.d.ts +1 -1
- package/script/1_utilities.js +1 -1
- package/script/4_constants.d.ts +1 -1
- package/script/4_constants.js +1 -1
- package/script/client/1_client_abstract.d.ts +1 -1
- package/script/client/3_types.d.ts +56 -0
- package/script/client/5_client.d.ts +17 -1
- package/script/client/5_client.js +151 -48
- package/script/connection/0_connection.d.ts +4 -0
- package/script/connection/0_connection.js +6 -0
- package/script/deps/deno.land/std@0.208.0/media_types/_db.d.ts +5 -0
- package/script/deps/deno.land/std@0.208.0/media_types/_db.js +39 -0
- package/script/deps/deno.land/std@0.208.0/media_types/_util.d.ts +21 -0
- package/script/deps/deno.land/std@0.208.0/media_types/_util.js +132 -0
- package/script/deps/deno.land/std@0.208.0/media_types/content_type.d.ts +38 -0
- package/script/deps/deno.land/std@0.208.0/media_types/content_type.js +64 -0
- package/script/deps/deno.land/std@0.208.0/media_types/format_media_type.d.ts +16 -0
- package/script/deps/deno.land/std@0.208.0/media_types/format_media_type.js +65 -0
- package/script/deps/deno.land/std@0.208.0/media_types/get_charset.d.ts +15 -0
- package/script/deps/deno.land/std@0.208.0/media_types/get_charset.js +41 -0
- package/script/deps/deno.land/std@0.208.0/media_types/parse_media_type.d.ts +37 -0
- package/script/deps/deno.land/std@0.208.0/media_types/parse_media_type.js +126 -0
- package/script/deps/deno.land/std@0.208.0/media_types/vendor/mime-db.v1.52.0.d.ts +8518 -0
- package/script/deps/deno.land/std@0.208.0/media_types/vendor/mime-db.v1.52.0.js +8557 -0
- package/script/storage/0_storage.d.ts +1 -0
- package/script/storage/1_storage_indexed_db.d.ts +4 -3
- package/script/storage/1_storage_indexed_db.js +17 -8
- package/script/storage/1_storage_local_storage.d.ts +2 -2
- package/script/storage/1_storage_local_storage.js +3 -0
- package/script/storage/1_storage_memory.d.ts +1 -0
- package/script/storage/1_storage_memory.js +3 -0
- package/script/storage/1_storage_session_storage.d.ts +1 -0
- package/script/storage/1_storage_session_storage.js +3 -0
- package/script/transport/0_transport.d.ts +1 -1
- package/script/transport/0_transport.js +0 -6
- package/script/transport/1_transport_abridged.d.ts +1 -0
- package/script/transport/1_transport_abridged.js +9 -5
- package/script/transport/1_transport_intermediate.d.ts +1 -0
- package/script/transport/1_transport_intermediate.js +8 -4
- package/script/types/1_chat.d.ts +2 -15
- package/script/types/1_chat.js +3 -14
- package/script/types/1_user.js +4 -2
- package/script/types/3_message.d.ts +2 -2
- package/script/types/3_message.js +6 -6
- package/script/utilities/{0_base64.js → 1_base64.js} +2 -1
- /package/esm/utilities/{0_base64.d.ts → 1_base64.d.ts} +0 -0
- /package/script/utilities/{0_base64.d.ts → 1_base64.d.ts} +0 -0
|
@@ -6,6 +6,7 @@ export declare abstract class Storage {
|
|
|
6
6
|
#private;
|
|
7
7
|
abstract init(): MaybePromise<void>;
|
|
8
8
|
abstract set(key: readonly StorageKeyPart[], value: unknown): MaybePromise<void>;
|
|
9
|
+
abstract incr(key: readonly StorageKeyPart[], by: number): MaybePromise<void>;
|
|
9
10
|
abstract get<T>(key: readonly StorageKeyPart[]): MaybePromise<T | null>;
|
|
10
11
|
abstract getMany<T>(prefix: readonly StorageKeyPart[]): MaybePromise<Generator<[readonly StorageKeyPart[], T]> | AsyncGenerator<[readonly StorageKeyPart[], T]>>;
|
|
11
12
|
setDc(dc: DC | null): MaybePromise<void>;
|
|
@@ -4,7 +4,8 @@ export declare class StorageIndexedDB extends Storage {
|
|
|
4
4
|
database: IDBDatabase | null;
|
|
5
5
|
constructor(name: string);
|
|
6
6
|
init(): Promise<void>;
|
|
7
|
-
set(k: StorageKeyPart[], v: unknown): Promise<void>;
|
|
8
|
-
get<T>(k: readonly StorageKeyPart[]): Promise<T | null>;
|
|
9
|
-
getMany<T>(prefix: readonly StorageKeyPart[]): AsyncGenerator<[readonly StorageKeyPart[], T], void, unknown>;
|
|
7
|
+
set(k: readonly StorageKeyPart[], v: unknown, tx_?: IDBTransaction): Promise<void>;
|
|
8
|
+
get<T>(k: readonly StorageKeyPart[], tx_?: IDBTransaction): Promise<T | null>;
|
|
9
|
+
getMany<T>(prefix: readonly StorageKeyPart[], tx_?: IDBTransaction): AsyncGenerator<[readonly StorageKeyPart[], T], void, unknown>;
|
|
10
|
+
incr(key: readonly StorageKeyPart[], by: number): Promise<void>;
|
|
10
11
|
}
|
|
@@ -35,12 +35,12 @@ export class StorageIndexedDB extends Storage {
|
|
|
35
35
|
};
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
|
-
set(k, v) {
|
|
38
|
+
set(k, v, tx_) {
|
|
39
39
|
if (!this.database) {
|
|
40
40
|
throw new Error("Not initialized");
|
|
41
41
|
}
|
|
42
|
-
const store = this.database
|
|
43
|
-
.transaction(KV_OBJECT_STORE, "readwrite")
|
|
42
|
+
const store = (tx_ ?? this.database
|
|
43
|
+
.transaction(KV_OBJECT_STORE, "readwrite"))
|
|
44
44
|
.objectStore(KV_OBJECT_STORE);
|
|
45
45
|
// deno-lint-ignore no-explicit-any
|
|
46
46
|
let tx;
|
|
@@ -57,12 +57,12 @@ export class StorageIndexedDB extends Storage {
|
|
|
57
57
|
};
|
|
58
58
|
});
|
|
59
59
|
}
|
|
60
|
-
get(k) {
|
|
60
|
+
get(k, tx_) {
|
|
61
61
|
if (!this.database) {
|
|
62
62
|
throw new Error("Not initialized");
|
|
63
63
|
}
|
|
64
|
-
const tx = this.database
|
|
65
|
-
.transaction(KV_OBJECT_STORE, "readonly")
|
|
64
|
+
const tx = (tx_ ?? this.database
|
|
65
|
+
.transaction(KV_OBJECT_STORE, "readonly"))
|
|
66
66
|
.objectStore(KV_OBJECT_STORE)
|
|
67
67
|
.get(fixKey(k));
|
|
68
68
|
return new Promise((res, rej) => {
|
|
@@ -72,12 +72,12 @@ export class StorageIndexedDB extends Storage {
|
|
|
72
72
|
};
|
|
73
73
|
});
|
|
74
74
|
}
|
|
75
|
-
async *getMany(prefix) {
|
|
75
|
+
async *getMany(prefix, tx_) {
|
|
76
76
|
if (!this.database) {
|
|
77
77
|
throw new Error("Not initialized");
|
|
78
78
|
}
|
|
79
79
|
const keys = await new Promise((res, rej) => {
|
|
80
|
-
const tx = this.database.transaction(KV_OBJECT_STORE, "readonly")
|
|
80
|
+
const tx = (tx_ ?? this.database.transaction(KV_OBJECT_STORE, "readonly"))
|
|
81
81
|
.objectStore(KV_OBJECT_STORE)
|
|
82
82
|
.getAllKeys(getPrefixKeyRange(prefix));
|
|
83
83
|
tx.onerror = rej;
|
|
@@ -89,4 +89,13 @@ export class StorageIndexedDB extends Storage {
|
|
|
89
89
|
yield [key, await this.get(key)];
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
|
+
async incr(key, by) {
|
|
93
|
+
if (!this.database) {
|
|
94
|
+
throw new Error("Not initialized");
|
|
95
|
+
}
|
|
96
|
+
const tx = this.database
|
|
97
|
+
.transaction(KV_OBJECT_STORE, "readwrite");
|
|
98
|
+
const currentValue = await this.get(key, tx);
|
|
99
|
+
await this.set(key, (currentValue || 0) + by, tx);
|
|
100
|
+
}
|
|
92
101
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { MaybePromise } from "../1_utilities.js";
|
|
2
1
|
import { Storage, StorageKeyPart } from "./0_storage.js";
|
|
3
2
|
export declare class StorageLocalStorage extends Storage implements Storage {
|
|
4
3
|
private readonly prefix;
|
|
@@ -6,5 +5,6 @@ export declare class StorageLocalStorage extends Storage implements Storage {
|
|
|
6
5
|
init(): void;
|
|
7
6
|
get<T>(key_: readonly StorageKeyPart[]): T | null;
|
|
8
7
|
getMany<T>(prefix: readonly StorageKeyPart[]): Generator<[readonly StorageKeyPart[], T], void, unknown>;
|
|
9
|
-
set(key_: readonly StorageKeyPart[], value: unknown):
|
|
8
|
+
set(key_: readonly StorageKeyPart[], value: unknown): void;
|
|
9
|
+
incr(key: readonly StorageKeyPart[], by: number): void;
|
|
10
10
|
}
|
|
@@ -6,4 +6,5 @@ export declare class StorageMemory extends Storage implements Storage {
|
|
|
6
6
|
get<T>(key: readonly StorageKeyPart[]): NonNullable<T> | null;
|
|
7
7
|
getMany<T>(prefix: readonly StorageKeyPart[]): Generator<[readonly StorageKeyPart[], T], void, unknown>;
|
|
8
8
|
set(key_: readonly StorageKeyPart[], value: unknown): MaybePromise<void>;
|
|
9
|
+
incr(key: readonly StorageKeyPart[], by: number): void;
|
|
9
10
|
}
|
|
@@ -7,4 +7,5 @@ export declare class StorageSessionStorage extends Storage implements Storage {
|
|
|
7
7
|
get<T>(key_: readonly StorageKeyPart[]): T | null;
|
|
8
8
|
getMany<T>(prefix: readonly StorageKeyPart[]): Generator<[readonly StorageKeyPart[], T], void, unknown>;
|
|
9
9
|
set(key_: readonly StorageKeyPart[], value: unknown): MaybePromise<void>;
|
|
10
|
+
incr(key: readonly StorageKeyPart[], by: number): void;
|
|
10
11
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { CTR, MaybePromise } from "../1_utilities.js";
|
|
2
2
|
export declare abstract class Transport {
|
|
3
|
-
protected initialized: boolean;
|
|
4
3
|
protected obfuscationParameters: {
|
|
5
4
|
encryptionCTR: CTR;
|
|
6
5
|
decryptionCTR: CTR;
|
|
7
6
|
} | null;
|
|
8
7
|
protected encrypt(buffer: Uint8Array): void;
|
|
9
8
|
protected decrypt(buffer: Uint8Array): void;
|
|
9
|
+
abstract get initialized(): boolean;
|
|
10
10
|
abstract initialize(): MaybePromise<void>;
|
|
11
11
|
abstract receive(): MaybePromise<Uint8Array>;
|
|
12
12
|
abstract send(buffer: Uint8Array): MaybePromise<void>;
|
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
export class Transport {
|
|
2
2
|
constructor() {
|
|
3
|
-
Object.defineProperty(this, "initialized", {
|
|
4
|
-
enumerable: true,
|
|
5
|
-
configurable: true,
|
|
6
|
-
writable: true,
|
|
7
|
-
value: false
|
|
8
|
-
});
|
|
9
3
|
Object.defineProperty(this, "obfuscationParameters", {
|
|
10
4
|
enumerable: true,
|
|
11
5
|
configurable: true,
|
|
@@ -9,27 +9,28 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
9
9
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
10
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
11
|
};
|
|
12
|
-
var _TransportAbridged_connection, _TransportAbridged_obfuscated;
|
|
12
|
+
var _TransportAbridged_initialized, _TransportAbridged_connection, _TransportAbridged_obfuscated;
|
|
13
13
|
import { bufferFromBigInt, concat } from "../1_utilities.js";
|
|
14
14
|
import { getObfuscationParameters } from "./0_obfuscation.js";
|
|
15
15
|
import { Transport } from "./0_transport.js";
|
|
16
16
|
export class TransportAbridged extends Transport {
|
|
17
17
|
constructor(connection, obfuscated = false) {
|
|
18
18
|
super();
|
|
19
|
+
_TransportAbridged_initialized.set(this, false);
|
|
19
20
|
_TransportAbridged_connection.set(this, void 0);
|
|
20
21
|
_TransportAbridged_obfuscated.set(this, void 0);
|
|
21
22
|
__classPrivateFieldSet(this, _TransportAbridged_connection, connection, "f");
|
|
22
23
|
__classPrivateFieldSet(this, _TransportAbridged_obfuscated, obfuscated, "f");
|
|
23
24
|
}
|
|
24
25
|
async initialize() {
|
|
25
|
-
if (!this
|
|
26
|
+
if (!__classPrivateFieldGet(this, _TransportAbridged_initialized, "f")) {
|
|
26
27
|
if (__classPrivateFieldGet(this, _TransportAbridged_obfuscated, "f")) {
|
|
27
28
|
this.obfuscationParameters = await getObfuscationParameters(0xEFEFEFEF, __classPrivateFieldGet(this, _TransportAbridged_connection, "f"));
|
|
28
29
|
}
|
|
29
30
|
else {
|
|
30
31
|
await __classPrivateFieldGet(this, _TransportAbridged_connection, "f").write(new Uint8Array([0xEF]));
|
|
31
32
|
}
|
|
32
|
-
this
|
|
33
|
+
__classPrivateFieldSet(this, _TransportAbridged_initialized, true, "f");
|
|
33
34
|
}
|
|
34
35
|
else {
|
|
35
36
|
throw new Error("Transport already initialized");
|
|
@@ -70,7 +71,10 @@ export class TransportAbridged extends Transport {
|
|
|
70
71
|
await __classPrivateFieldGet(this, _TransportAbridged_connection, "f").write(data);
|
|
71
72
|
}
|
|
72
73
|
deinitialize() {
|
|
73
|
-
this
|
|
74
|
+
__classPrivateFieldSet(this, _TransportAbridged_initialized, false, "f");
|
|
75
|
+
}
|
|
76
|
+
get initialized() {
|
|
77
|
+
return __classPrivateFieldGet(this, _TransportAbridged_initialized, "f");
|
|
74
78
|
}
|
|
75
79
|
}
|
|
76
|
-
_TransportAbridged_connection = new WeakMap(), _TransportAbridged_obfuscated = new WeakMap();
|
|
80
|
+
_TransportAbridged_initialized = new WeakMap(), _TransportAbridged_connection = new WeakMap(), _TransportAbridged_obfuscated = new WeakMap();
|
|
@@ -9,7 +9,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
9
9
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
10
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
11
|
};
|
|
12
|
-
var _TransportIntermediate_connection, _TransportIntermediate_obfuscated;
|
|
12
|
+
var _TransportIntermediate_connection, _TransportIntermediate_initialized, _TransportIntermediate_obfuscated;
|
|
13
13
|
import { bufferFromBigInt, concat } from "../1_utilities.js";
|
|
14
14
|
import { getObfuscationParameters } from "./0_obfuscation.js";
|
|
15
15
|
import { Transport } from "./0_transport.js";
|
|
@@ -17,6 +17,7 @@ export class TransportIntermediate extends Transport {
|
|
|
17
17
|
constructor(connection, obfuscated = false) {
|
|
18
18
|
super();
|
|
19
19
|
_TransportIntermediate_connection.set(this, void 0);
|
|
20
|
+
_TransportIntermediate_initialized.set(this, false);
|
|
20
21
|
_TransportIntermediate_obfuscated.set(this, void 0);
|
|
21
22
|
__classPrivateFieldSet(this, _TransportIntermediate_connection, connection, "f");
|
|
22
23
|
__classPrivateFieldSet(this, _TransportIntermediate_obfuscated, obfuscated, "f");
|
|
@@ -29,7 +30,7 @@ export class TransportIntermediate extends Transport {
|
|
|
29
30
|
else {
|
|
30
31
|
await __classPrivateFieldGet(this, _TransportIntermediate_connection, "f").write(new Uint8Array([0xEE, 0xEE, 0xEE, 0xEE]));
|
|
31
32
|
}
|
|
32
|
-
this
|
|
33
|
+
__classPrivateFieldSet(this, _TransportIntermediate_initialized, true, "f");
|
|
33
34
|
}
|
|
34
35
|
else {
|
|
35
36
|
throw new Error("Transport already initialized");
|
|
@@ -59,7 +60,10 @@ export class TransportIntermediate extends Transport {
|
|
|
59
60
|
await __classPrivateFieldGet(this, _TransportIntermediate_connection, "f").write(data);
|
|
60
61
|
}
|
|
61
62
|
deinitialize() {
|
|
62
|
-
this
|
|
63
|
+
__classPrivateFieldSet(this, _TransportIntermediate_initialized, false, "f");
|
|
64
|
+
}
|
|
65
|
+
get initialized() {
|
|
66
|
+
return __classPrivateFieldGet(this, _TransportIntermediate_initialized, "f");
|
|
63
67
|
}
|
|
64
68
|
}
|
|
65
|
-
_TransportIntermediate_connection = new WeakMap(), _TransportIntermediate_obfuscated = new WeakMap();
|
|
69
|
+
_TransportIntermediate_connection = new WeakMap(), _TransportIntermediate_initialized = new WeakMap(), _TransportIntermediate_obfuscated = new WeakMap();
|
package/esm/types/1_chat.d.ts
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
import { types } from "../2_tl.js";
|
|
2
|
-
import { ChatPhoto } from "./0_chat_photo.js";
|
|
3
2
|
import { RestrictionReason } from "./0_restriction_reason.js";
|
|
4
3
|
export type ChatType = "private" | "group" | "supergroup" | "channel";
|
|
5
4
|
export declare namespace Chat {
|
|
6
5
|
interface Base {
|
|
7
|
-
/** The type of the chat. */
|
|
8
|
-
type: ChatType;
|
|
9
6
|
/** The identifier of the chat. */
|
|
10
7
|
id: number;
|
|
8
|
+
/** The type of the chat. */
|
|
9
|
+
type: ChatType;
|
|
11
10
|
/** Identifier of a color that can be displayed instead of the chat's photo. */
|
|
12
11
|
color: number;
|
|
13
|
-
/** The chat's photo. */
|
|
14
|
-
photo?: ChatPhoto;
|
|
15
12
|
}
|
|
16
13
|
interface Private extends Base {
|
|
17
14
|
type: "private";
|
|
@@ -23,10 +20,6 @@ export declare namespace Chat {
|
|
|
23
20
|
lastName?: string;
|
|
24
21
|
/** The user's main username. */
|
|
25
22
|
username?: string;
|
|
26
|
-
/** The user's other usernames. */
|
|
27
|
-
also?: string[];
|
|
28
|
-
/** The user's profile photo. */
|
|
29
|
-
photo?: ChatPhoto.User;
|
|
30
23
|
/** Whether the user has been identified as scam. */
|
|
31
24
|
isScam: boolean;
|
|
32
25
|
/** Whether the user has been identified as an impersonator. */
|
|
@@ -44,8 +37,6 @@ export declare namespace Chat {
|
|
|
44
37
|
type: "group";
|
|
45
38
|
/** The title of the chat. */
|
|
46
39
|
title: string;
|
|
47
|
-
/** The chat's photo. */
|
|
48
|
-
photo?: ChatPhoto.Chat;
|
|
49
40
|
/** Whether the current user is the owner of the chat. */
|
|
50
41
|
isCreator: boolean;
|
|
51
42
|
}
|
|
@@ -54,10 +45,6 @@ export declare namespace Chat {
|
|
|
54
45
|
title: string;
|
|
55
46
|
/** The main username of the chat or channel. */
|
|
56
47
|
username?: string;
|
|
57
|
-
/** The other usernames of the chat or channel. */
|
|
58
|
-
also?: string[];
|
|
59
|
-
/** The chat or channel's photo. */
|
|
60
|
-
photo?: ChatPhoto.Chat;
|
|
61
48
|
/** Whether the chat or channel has been identified as scam. */
|
|
62
49
|
isScam: boolean;
|
|
63
50
|
/** Whether the chat or channel has been identified as an impersonator. */
|
package/esm/types/1_chat.js
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { cleanObject, getColorFromPeerId, UNREACHABLE, ZERO_CHANNEL_ID } from "../1_utilities.js";
|
|
2
2
|
import { types } from "../2_tl.js";
|
|
3
|
-
import { constructChatPhoto } from "./0_chat_photo.js";
|
|
4
3
|
import { constructRestrictionReason } from "./0_restriction_reason.js";
|
|
5
4
|
export function constructChat(chat) {
|
|
6
5
|
if (chat instanceof types.User) {
|
|
7
6
|
const id = Number(chat.id);
|
|
8
7
|
const chat_ = {
|
|
8
|
+
id,
|
|
9
9
|
type: "private",
|
|
10
10
|
isBot: chat.bot || false,
|
|
11
|
-
id,
|
|
12
11
|
color: chat.color?.color !== undefined ? chat.color.color : getColorFromPeerId(id),
|
|
13
12
|
firstName: chat.first_name || "",
|
|
14
13
|
lastName: chat.last_name,
|
|
@@ -21,23 +20,17 @@ export function constructChat(chat) {
|
|
|
21
20
|
chat_.isRestricted = chat.restricted || false;
|
|
22
21
|
chat_.restrictionReason = chat.restriction_reason;
|
|
23
22
|
}
|
|
24
|
-
if (chat.photo instanceof types.UserProfilePhoto) {
|
|
25
|
-
chat_.photo = constructChatPhoto(chat.photo, chat_.id, chat.access_hash ?? 0n);
|
|
26
|
-
}
|
|
27
23
|
return cleanObject(chat_);
|
|
28
24
|
}
|
|
29
25
|
else if (chat instanceof types.Chat) {
|
|
30
26
|
const id = Number(-chat.id);
|
|
31
27
|
const chat_ = {
|
|
32
|
-
type: "group",
|
|
33
28
|
id,
|
|
29
|
+
type: "group",
|
|
34
30
|
color: getColorFromPeerId(id),
|
|
35
31
|
title: chat.title,
|
|
36
32
|
isCreator: chat.creator || false,
|
|
37
33
|
};
|
|
38
|
-
if (chat.photo instanceof types.ChatPhoto) {
|
|
39
|
-
chat_.photo = constructChatPhoto(chat.photo, chat_.id, 0n);
|
|
40
|
-
}
|
|
41
34
|
return cleanObject(chat_);
|
|
42
35
|
}
|
|
43
36
|
else if (chat instanceof types.Channel) {
|
|
@@ -70,14 +63,10 @@ export function constructChat(chat) {
|
|
|
70
63
|
isRestricted,
|
|
71
64
|
};
|
|
72
65
|
}
|
|
73
|
-
chat_.username = chat.username;
|
|
74
|
-
chat_.also = chat.usernames?.map((v) => v.username);
|
|
66
|
+
chat_.username = chat.username ?? chat.usernames?.[0].username;
|
|
75
67
|
if (chat_.isRestricted) {
|
|
76
68
|
chat_.restrictionReason = (chat.restriction_reason ?? []).map(constructRestrictionReason);
|
|
77
69
|
}
|
|
78
|
-
if (chat.photo instanceof types.ChatPhoto) {
|
|
79
|
-
chat_.photo = constructChatPhoto(chat.photo, chat_.id, chat.access_hash ?? 0n);
|
|
80
|
-
}
|
|
81
70
|
return cleanObject(chat_);
|
|
82
71
|
}
|
|
83
72
|
else {
|
package/esm/types/1_user.js
CHANGED
|
@@ -3,14 +3,16 @@ import { types } from "../2_tl.js";
|
|
|
3
3
|
import { constructChatPhoto } from "./0_chat_photo.js";
|
|
4
4
|
export function constructUser(user_) {
|
|
5
5
|
const id = Number(user_.id);
|
|
6
|
+
const usernames = user_.usernames?.map((v) => v.username);
|
|
7
|
+
const username = user_.username ?? usernames?.shift();
|
|
6
8
|
const user = {
|
|
7
9
|
id,
|
|
8
10
|
color: user_.color?.color !== undefined ? user_.color.color : getColorFromPeerId(id),
|
|
9
11
|
isBot: user_.bot || false,
|
|
10
12
|
firstName: user_.first_name || "",
|
|
11
13
|
lastName: user_.last_name,
|
|
12
|
-
username:
|
|
13
|
-
also:
|
|
14
|
+
username: username,
|
|
15
|
+
also: usernames?.filter((v) => v != username),
|
|
14
16
|
languageCode: user_.lang_code,
|
|
15
17
|
isScam: user_.scam || false,
|
|
16
18
|
isFake: user_.fake || false,
|
package/esm/types/3_message.d.ts
CHANGED
|
@@ -57,7 +57,7 @@ export interface Message {
|
|
|
57
57
|
/** True, if the message is a channel post that was automatically forwarded to the connected discussion group */
|
|
58
58
|
isAutomaticForward?: boolean;
|
|
59
59
|
/** For replies, the original message. Note that the Message object in this field will not contain further reply_to_message fields even if it itself is a reply. */
|
|
60
|
-
replyToMessage?: Omit<Message, "
|
|
60
|
+
replyToMessage?: Omit<Message, "replyToMessage">;
|
|
61
61
|
/** Bot through which the message was sent */
|
|
62
62
|
viaBot?: User;
|
|
63
63
|
/** Date the message was last edited in Unix time */
|
|
@@ -172,7 +172,7 @@ export interface Message {
|
|
|
172
172
|
};
|
|
173
173
|
}
|
|
174
174
|
export interface MessageGetter<O extends keyof Message | null = null> {
|
|
175
|
-
(chatId: number, messageId: number): MaybePromise<(O extends null ? Message : Omit<Message, "
|
|
175
|
+
(chatId: number, messageId: number): MaybePromise<(O extends null ? Message : Omit<Message, "replyToMessage">) | null>;
|
|
176
176
|
}
|
|
177
177
|
type Message_MessageGetter = MessageGetter<"replyToMessage"> | null;
|
|
178
178
|
export declare function constructMessage(message_: enums.Message, getEntity: EntityGetter, getMessage: Message_MessageGetter, getStickerSetName: StickerSetNameGetter): Promise<Message>;
|
package/esm/types/3_message.js
CHANGED
|
@@ -50,15 +50,15 @@ async function getReply(message_, chat, getMessage) {
|
|
|
50
50
|
if (message_.reply_to.forum_topic) {
|
|
51
51
|
isTopicMessage = true;
|
|
52
52
|
}
|
|
53
|
-
const
|
|
54
|
-
if (
|
|
55
|
-
return {
|
|
53
|
+
const replyToMessage = await getMessage(chat.id, message_.reply_to.reply_to_msg_id);
|
|
54
|
+
if (replyToMessage) {
|
|
55
|
+
return { replyToMessage, threadId: message_.reply_to.reply_to_top_id, isTopicMessage };
|
|
56
56
|
}
|
|
57
57
|
else {
|
|
58
58
|
d("couldn't get replied message");
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
-
return {
|
|
61
|
+
return { replyToMessage: undefined, threadId: undefined, isTopicMessage: undefined };
|
|
62
62
|
}
|
|
63
63
|
async function constructServiceMessage(message_, chat, getEntity, getMessage) {
|
|
64
64
|
const message = {
|
|
@@ -133,8 +133,8 @@ async function constructServiceMessage(message_, chat, getEntity, getMessage) {
|
|
|
133
133
|
message.chatMigratedFrom = Number(-message_.action.chat_id);
|
|
134
134
|
}
|
|
135
135
|
else if (message_.action instanceof types.MessageActionPinMessage) {
|
|
136
|
-
const {
|
|
137
|
-
message.pinnedMessage =
|
|
136
|
+
const { replyToMessage } = await getReply(message_, chat, getMessage);
|
|
137
|
+
message.pinnedMessage = replyToMessage;
|
|
138
138
|
}
|
|
139
139
|
else if (message_.action instanceof types.MessageActionRequestedPeer) {
|
|
140
140
|
const user = message_.action.peer[as](types.PeerUser);
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { decodeBase64, encodeBase64 } from "../0_deps.js";
|
|
2
|
+
import { mod } from "./0_bigint.js";
|
|
2
3
|
export function base64EncodeUrlSafe(data) {
|
|
3
4
|
return encodeBase64(data).replace(/=*$/, "").replaceAll("+", "-").replaceAll("/", "_");
|
|
4
5
|
}
|
|
5
6
|
export function base64DecodeUrlSafe(data) {
|
|
6
7
|
data = data.replaceAll("_", "/").replaceAll("-", "+");
|
|
7
8
|
if (data.length != 4) {
|
|
8
|
-
data += "=".repeat(
|
|
9
|
+
data += "=".repeat(mod(-data.length, 4));
|
|
9
10
|
}
|
|
10
11
|
return decodeBase64(data);
|
|
11
12
|
}
|
package/package.json
CHANGED
package/script/0_deps.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from "./deps/deno.land/std@0.208.0/assert/mod.js";
|
|
2
2
|
export * as path from "./deps/deno.land/std@0.208.0/path/mod.js";
|
|
3
3
|
export { decodeBase64, encodeBase64 } from "./deps/deno.land/std@0.208.0/encoding/base64.js";
|
|
4
|
+
export { contentType } from "./deps/deno.land/std@0.208.0/media_types/content_type.js";
|
|
4
5
|
export { ctr256, factorize, ige256Decrypt, ige256Encrypt, init as initTgCrypto } from "./deps/deno.land/x/tgcrypto@0.3.3/mod.js";
|
|
5
6
|
export { gunzip, gzip } from "./deps/raw.githubusercontent.com/MTKruto/compress/main/gzip/gzip.js";
|
|
6
7
|
export { Mutex, type MutexInterface } from "async-mutex";
|
package/script/0_deps.js
CHANGED
|
@@ -26,12 +26,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
26
26
|
return result;
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.debug = exports.Parser = exports.Mutex = exports.gzip = exports.gunzip = exports.initTgCrypto = exports.ige256Encrypt = exports.ige256Decrypt = exports.factorize = exports.ctr256 = exports.encodeBase64 = exports.decodeBase64 = exports.path = void 0;
|
|
29
|
+
exports.debug = exports.Parser = exports.Mutex = exports.gzip = exports.gunzip = exports.initTgCrypto = exports.ige256Encrypt = exports.ige256Decrypt = exports.factorize = exports.ctr256 = exports.contentType = exports.encodeBase64 = exports.decodeBase64 = exports.path = void 0;
|
|
30
30
|
__exportStar(require("./deps/deno.land/std@0.208.0/assert/mod.js"), exports);
|
|
31
31
|
exports.path = __importStar(require("./deps/deno.land/std@0.208.0/path/mod.js"));
|
|
32
32
|
var base64_js_1 = require("./deps/deno.land/std@0.208.0/encoding/base64.js");
|
|
33
33
|
Object.defineProperty(exports, "decodeBase64", { enumerable: true, get: function () { return base64_js_1.decodeBase64; } });
|
|
34
34
|
Object.defineProperty(exports, "encodeBase64", { enumerable: true, get: function () { return base64_js_1.encodeBase64; } });
|
|
35
|
+
var content_type_js_1 = require("./deps/deno.land/std@0.208.0/media_types/content_type.js");
|
|
36
|
+
Object.defineProperty(exports, "contentType", { enumerable: true, get: function () { return content_type_js_1.contentType; } });
|
|
35
37
|
var mod_js_1 = require("./deps/deno.land/x/tgcrypto@0.3.3/mod.js");
|
|
36
38
|
Object.defineProperty(exports, "ctr256", { enumerable: true, get: function () { return mod_js_1.ctr256; } });
|
|
37
39
|
Object.defineProperty(exports, "factorize", { enumerable: true, get: function () { return mod_js_1.factorize; } });
|
package/script/1_utilities.d.ts
CHANGED
package/script/1_utilities.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./utilities/
|
|
17
|
+
__exportStar(require("./utilities/1_base64.js"), exports);
|
|
18
18
|
__exportStar(require("./utilities/0_bigint.js"), exports);
|
|
19
19
|
__exportStar(require("./utilities/0_buffer.js"), exports);
|
|
20
20
|
__exportStar(require("./utilities/0_color.js"), exports);
|
package/script/4_constants.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export type PublicKeys = readonly [bigint, [bigint, bigint]][];
|
|
|
4
4
|
export declare const PUBLIC_KEYS: PublicKeys;
|
|
5
5
|
export declare const INITIAL_DC: DC;
|
|
6
6
|
export declare const LAYER = 167;
|
|
7
|
-
export declare const APP_VERSION = "MTKruto 0.1.
|
|
7
|
+
export declare const APP_VERSION = "MTKruto 0.1.125";
|
|
8
8
|
export declare const DEVICE_MODEL: string;
|
|
9
9
|
export declare const LANG_CODE: string;
|
|
10
10
|
export declare const LANG_PACK = "";
|
package/script/4_constants.js
CHANGED
|
@@ -79,7 +79,7 @@ exports.PUBLIC_KEYS = Object.freeze([
|
|
|
79
79
|
]);
|
|
80
80
|
exports.INITIAL_DC = "2";
|
|
81
81
|
exports.LAYER = 167;
|
|
82
|
-
exports.APP_VERSION = "MTKruto 0.1.
|
|
82
|
+
exports.APP_VERSION = "MTKruto 0.1.125";
|
|
83
83
|
// @ts-ignore: lib
|
|
84
84
|
exports.DEVICE_MODEL = typeof dntShim.Deno === "undefined" ? typeof navigator === "undefined" ? typeof process === "undefined" ? "Unknown" : process.platform + "-" + process.arch : navigator.userAgent.split(" ")[0] : dntShim.Deno.build.os + "-" + dntShim.Deno.build.arch;
|
|
85
85
|
exports.LANG_CODE = typeof navigator === "undefined" ? "en" : navigator.language.split("-")[0];
|
|
@@ -17,7 +17,7 @@ export interface ClientAbstractParams {
|
|
|
17
17
|
export declare abstract class ClientAbstract {
|
|
18
18
|
#private;
|
|
19
19
|
protected readonly initialDc: DC;
|
|
20
|
-
protected
|
|
20
|
+
protected transportProvider: TransportProvider;
|
|
21
21
|
protected readonly cdn: boolean;
|
|
22
22
|
protected transport?: ReturnType<TransportProvider>;
|
|
23
23
|
constructor(params?: ClientAbstractParams);
|
|
@@ -287,6 +287,54 @@ export interface SendPhotoParams {
|
|
|
287
287
|
*/
|
|
288
288
|
replyMarkup?: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply;
|
|
289
289
|
}
|
|
290
|
+
export interface SendDocumentParams {
|
|
291
|
+
/** The file name to assign. */
|
|
292
|
+
fileName?: string;
|
|
293
|
+
/** The mime type to assign. */
|
|
294
|
+
mimeType?: string;
|
|
295
|
+
/** Size of each upload chunk in bytes. */
|
|
296
|
+
chunkSize?: number;
|
|
297
|
+
/** Upload abort signal. */
|
|
298
|
+
signal?: AbortSignal | null;
|
|
299
|
+
/** The caption of the document. */
|
|
300
|
+
caption?: string;
|
|
301
|
+
/**
|
|
302
|
+
* The caption's entities.
|
|
303
|
+
*/
|
|
304
|
+
captionEntities?: MessageEntity[];
|
|
305
|
+
/**
|
|
306
|
+
* The parse mode to use for the caption. If not provided, the default parse mode will be used.
|
|
307
|
+
*/
|
|
308
|
+
parseMode?: ParseMode;
|
|
309
|
+
/**
|
|
310
|
+
* Whether to mark the document as a spoiler.
|
|
311
|
+
*/
|
|
312
|
+
hasSpoiler?: boolean;
|
|
313
|
+
/**
|
|
314
|
+
* Whether to send the message in a silent way without making a sound on the recipients' clients.
|
|
315
|
+
*/
|
|
316
|
+
disableNotification?: boolean;
|
|
317
|
+
/**
|
|
318
|
+
* Whether to protect the contents of the message from copying and forwarding.
|
|
319
|
+
*/
|
|
320
|
+
protectContent?: boolean;
|
|
321
|
+
/**
|
|
322
|
+
* The identifier of a message to reply to.
|
|
323
|
+
*/
|
|
324
|
+
replyToMessageId?: number;
|
|
325
|
+
/**
|
|
326
|
+
* The identifier of a thread to send the message to.
|
|
327
|
+
*/
|
|
328
|
+
messageThreadId?: number;
|
|
329
|
+
/**
|
|
330
|
+
* The identifier of the chat to send the message on behalf of. User-only.
|
|
331
|
+
*/
|
|
332
|
+
sendAs?: ChatID;
|
|
333
|
+
/**
|
|
334
|
+
* The reply markup of the message. Bot-only.
|
|
335
|
+
*/
|
|
336
|
+
replyMarkup?: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply;
|
|
337
|
+
}
|
|
290
338
|
export type ConnectionState = "notConnected" | "updating" | "ready";
|
|
291
339
|
export type AuthorizationState = {
|
|
292
340
|
authorized: boolean;
|
|
@@ -324,4 +372,12 @@ export type FilterUpdate<Update extends Update_, Type extends keyof Update_, Fie
|
|
|
324
372
|
[Field_ in Field]-?: Field extends keyof TypeType ? NonNullable<TypeType[Field]> : never;
|
|
325
373
|
};
|
|
326
374
|
};
|
|
375
|
+
export interface NetworkStatisticsEntry {
|
|
376
|
+
sent: number;
|
|
377
|
+
received: number;
|
|
378
|
+
}
|
|
379
|
+
export interface NetworkStatistics {
|
|
380
|
+
messages: NetworkStatisticsEntry;
|
|
381
|
+
cdn: NetworkStatisticsEntry;
|
|
382
|
+
}
|
|
327
383
|
export {};
|