@mtkruto/node 0.0.6
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 +165 -0
- package/README.md +1 -0
- package/esm/_dnt.shims.js +68 -0
- package/esm/client/client.js +169 -0
- package/esm/client/client_abstract.js +51 -0
- package/esm/client/client_plain.js +112 -0
- package/esm/connection/connection.js +2 -0
- package/esm/connection/connection_web_socket.js +90 -0
- package/esm/constants.js +60 -0
- package/esm/deps/deno.land/std@0.186.0/fmt/colors.js +474 -0
- package/esm/deps/deno.land/std@0.186.0/testing/_diff.js +311 -0
- package/esm/deps/deno.land/std@0.186.0/testing/_format.js +23 -0
- package/esm/deps/deno.land/std@0.186.0/testing/asserts.js +633 -0
- package/esm/deps/deno.land/x/crc32@v0.2.0/mod.js +105 -0
- package/esm/deps/deno.land/x/tgcrypto@0.1.1/mod.js +68 -0
- package/esm/deps/deno.land/x/tgcrypto@0.1.1/tgcrypto.js +1127 -0
- package/esm/deps/raw.githubusercontent.com/MTKruto/compress/master/gzip/gzip.js +239 -0
- package/esm/deps/raw.githubusercontent.com/MTKruto/compress/master/utils/uint8.js +10 -0
- package/esm/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/deflate.js +139 -0
- package/esm/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/inflate.js +176 -0
- package/esm/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/mod.js +2 -0
- package/esm/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/adler32.js +19 -0
- package/esm/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/crc32.js +25 -0
- package/esm/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/deflate.js +1941 -0
- package/esm/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/gzheader.js +85 -0
- package/esm/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/inffast.js +321 -0
- package/esm/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/inflate.js +1658 -0
- package/esm/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/inftrees.js +355 -0
- package/esm/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/messages.js +11 -0
- package/esm/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/status.js +42 -0
- package/esm/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/trees.js +1107 -0
- package/esm/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/zstream.js +86 -0
- package/esm/deps.js +4 -0
- package/esm/mod.js +4 -0
- package/esm/package.json +3 -0
- package/esm/tl/0_tl_raw_reader.js +62 -0
- package/esm/tl/0_tl_raw_writer.js +60 -0
- package/esm/tl/1_tl_object.js +149 -0
- package/esm/tl/2_types.js +48220 -0
- package/esm/tl/3_functions.js +19856 -0
- package/esm/tl/3_tl_object_deserializer.js +72 -0
- package/esm/tl/3_tl_reader.js +16 -0
- package/esm/tl/3_tl_writer.js +7 -0
- package/esm/tl/4_rpc_result.js +27 -0
- package/esm/tl/5_message.js +54 -0
- package/esm/tl/6_message_container.js +35 -0
- package/esm/transport/transport.js +32 -0
- package/esm/transport/transport_intermediate.js +56 -0
- package/esm/transport/transport_provider.js +23 -0
- package/esm/types.js +1 -0
- package/esm/utilities/0_bigint.js +37 -0
- package/esm/utilities/0_buffer.js +33 -0
- package/esm/utilities/0_crypto.js +35 -0
- package/esm/utilities/0_hash.js +7 -0
- package/esm/utilities/1_auth.js +29 -0
- package/esm/utilities/1_message.js +94 -0
- package/esm/utilities/1_obfuscation.js +33 -0
- package/package.json +40 -0
- package/script/_dnt.shims.js +77 -0
- package/script/client/client.js +173 -0
- package/script/client/client_abstract.js +55 -0
- package/script/client/client_plain.js +116 -0
- package/script/connection/connection.js +6 -0
- package/script/connection/connection_web_socket.js +117 -0
- package/script/constants.js +63 -0
- package/script/deps/deno.land/std@0.186.0/fmt/colors.js +548 -0
- package/script/deps/deno.land/std@0.186.0/testing/_diff.js +317 -0
- package/script/deps/deno.land/std@0.186.0/testing/_format.js +50 -0
- package/script/deps/deno.land/std@0.186.0/testing/asserts.js +659 -0
- package/script/deps/deno.land/x/crc32@v0.2.0/mod.js +113 -0
- package/script/deps/deno.land/x/tgcrypto@0.1.1/mod.js +82 -0
- package/script/deps/deno.land/x/tgcrypto@0.1.1/tgcrypto.js +1152 -0
- package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/gzip/gzip.js +271 -0
- package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/utils/uint8.js +14 -0
- package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/deflate.js +172 -0
- package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/inflate.js +208 -0
- package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/mod.js +18 -0
- package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/adler32.js +22 -0
- package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/crc32.js +30 -0
- package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/deflate.js +1976 -0
- package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/gzheader.js +88 -0
- package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/inffast.js +324 -0
- package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/inflate.js +1674 -0
- package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/inftrees.js +358 -0
- package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/messages.js +14 -0
- package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/status.js +44 -0
- package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/trees.js +1115 -0
- package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/zstream.js +89 -0
- package/script/deps.js +30 -0
- package/script/mod.js +32 -0
- package/script/package.json +3 -0
- package/script/tl/0_tl_raw_reader.js +66 -0
- package/script/tl/0_tl_raw_writer.js +64 -0
- package/script/tl/1_tl_object.js +156 -0
- package/script/tl/2_types.js +49824 -0
- package/script/tl/3_functions.js +20413 -0
- package/script/tl/3_tl_object_deserializer.js +76 -0
- package/script/tl/3_tl_reader.js +20 -0
- package/script/tl/3_tl_writer.js +11 -0
- package/script/tl/4_rpc_result.js +31 -0
- package/script/tl/5_message.js +58 -0
- package/script/tl/6_message_container.js +39 -0
- package/script/transport/transport.js +36 -0
- package/script/transport/transport_intermediate.js +60 -0
- package/script/transport/transport_provider.js +27 -0
- package/script/types.js +2 -0
- package/script/utilities/0_bigint.js +67 -0
- package/script/utilities/0_buffer.js +38 -0
- package/script/utilities/0_crypto.js +39 -0
- package/script/utilities/0_hash.js +35 -0
- package/script/utilities/1_auth.js +56 -0
- package/script/utilities/1_message.js +102 -0
- package/script/utilities/1_obfuscation.js +60 -0
- package/types/_dnt.shims.d.ts +10 -0
- package/types/client/client.d.ts +19 -0
- package/types/client/client_abstract.d.ts +20 -0
- package/types/client/client_plain.d.ts +10 -0
- package/types/connection/connection.d.ts +7 -0
- package/types/connection/connection_web_socket.d.ts +13 -0
- package/types/constants.d.ts +2 -0
- package/types/deps/deno.land/std@0.186.0/fmt/colors.d.ts +270 -0
- package/types/deps/deno.land/std@0.186.0/testing/_diff.d.ts +26 -0
- package/types/deps/deno.land/std@0.186.0/testing/_format.d.ts +1 -0
- package/types/deps/deno.land/std@0.186.0/testing/asserts.d.ts +284 -0
- package/types/deps/deno.land/x/crc32@v0.2.0/mod.d.ts +15 -0
- package/types/deps/deno.land/x/tgcrypto@0.1.1/mod.d.ts +47 -0
- package/types/deps/deno.land/x/tgcrypto@0.1.1/tgcrypto.d.ts +2 -0
- package/types/deps/raw.githubusercontent.com/MTKruto/compress/master/gzip/gzip.d.ts +16 -0
- package/types/deps/raw.githubusercontent.com/MTKruto/compress/master/utils/uint8.d.ts +1 -0
- package/types/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/deflate.d.ts +29 -0
- package/types/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/inflate.d.ts +23 -0
- package/types/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/mod.d.ts +2 -0
- package/types/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/adler32.d.ts +1 -0
- package/types/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/crc32.d.ts +2 -0
- package/types/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/deflate.d.ts +78 -0
- package/types/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/gzheader.d.ts +12 -0
- package/types/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/inffast.d.ts +1 -0
- package/types/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/inflate.d.ts +47 -0
- package/types/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/inftrees.d.ts +1 -0
- package/types/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/messages.d.ts +12 -0
- package/types/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/status.d.ts +30 -0
- package/types/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/trees.d.ts +5 -0
- package/types/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/zstream.d.ts +14 -0
- package/types/deps.d.ts +4 -0
- package/types/mod.d.ts +4 -0
- package/types/tl/0_tl_raw_reader.d.ts +13 -0
- package/types/tl/0_tl_raw_writer.d.ts +13 -0
- package/types/tl/1_tl_object.d.ts +36 -0
- package/types/tl/2_types.d.ts +14815 -0
- package/types/tl/3_functions.d.ts +6122 -0
- package/types/tl/3_tl_object_deserializer.d.ts +3 -0
- package/types/tl/3_tl_reader.d.ts +4 -0
- package/types/tl/3_tl_writer.d.ts +5 -0
- package/types/tl/4_rpc_result.d.ts +8 -0
- package/types/tl/5_message.d.ts +11 -0
- package/types/tl/6_message_container.d.ts +9 -0
- package/types/transport/transport.d.ts +15 -0
- package/types/transport/transport_intermediate.d.ts +11 -0
- package/types/transport/transport_provider.d.ts +12 -0
- package/types/types.d.ts +1 -0
- package/types/utilities/0_bigint.d.ts +4 -0
- package/types/utilities/0_buffer.d.ts +2 -0
- package/types/utilities/0_crypto.d.ts +8 -0
- package/types/utilities/0_hash.d.ts +2 -0
- package/types/utilities/1_auth.d.ts +1 -0
- package/types/utilities/1_message.d.ts +10 -0
- package/types/utilities/1_obfuscation.d.ts +6 -0
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { TLRawReader } from "./0_tl_raw_reader.js";
|
|
2
|
+
import { ParamDesc, TLObjectConstructor } from "./1_tl_object.js";
|
|
3
|
+
export declare function deserialize<T extends TLObjectConstructor<InstanceType<T>>>(reader: TLRawReader, paramDesc: ParamDesc, constructor: T): InstanceType<T>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { id, TLObject } from "./1_tl_object.js";
|
|
2
|
+
export declare class RPCResult {
|
|
3
|
+
readonly messageId: bigint;
|
|
4
|
+
readonly result: TLObject;
|
|
5
|
+
static get [id](): number;
|
|
6
|
+
constructor(messageId: bigint, result: TLObject);
|
|
7
|
+
static deserialize(buffer: Uint8Array): RPCResult;
|
|
8
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { TLObject } from "./1_tl_object.js";
|
|
2
|
+
import { TLReader } from "./3_tl_reader.js";
|
|
3
|
+
import { RPCResult } from "./4_rpc_result.js";
|
|
4
|
+
export declare class Message {
|
|
5
|
+
readonly id: bigint;
|
|
6
|
+
readonly seqNo: number;
|
|
7
|
+
readonly body: TLObject | RPCResult;
|
|
8
|
+
constructor(id: bigint, seqNo: number, body: TLObject | RPCResult);
|
|
9
|
+
serialize(): Uint8Array;
|
|
10
|
+
static deserialize(reader: TLReader): Message;
|
|
11
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { id } from "./1_tl_object.js";
|
|
2
|
+
import { Message } from "./5_message.js";
|
|
3
|
+
export declare class MessageContainer {
|
|
4
|
+
messages: Message[];
|
|
5
|
+
static get [id](): number;
|
|
6
|
+
constructor(messages: Message[]);
|
|
7
|
+
serialize(): Uint8Array;
|
|
8
|
+
static deserialize(buffer: Uint8Array): MessageContainer;
|
|
9
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { MaybePromise } from "../types.js";
|
|
2
|
+
import { CTR } from "../utilities/0_crypto.js";
|
|
3
|
+
export declare abstract class Transport {
|
|
4
|
+
protected initialized: boolean;
|
|
5
|
+
protected obfuscationParameters: {
|
|
6
|
+
encryptionCTR: CTR;
|
|
7
|
+
decryptionCTR: CTR;
|
|
8
|
+
} | null;
|
|
9
|
+
protected encrypt(buffer: Uint8Array): Uint8Array;
|
|
10
|
+
protected decrypt(buffer: Uint8Array): Uint8Array;
|
|
11
|
+
abstract initialize(): MaybePromise<void>;
|
|
12
|
+
abstract receive(): MaybePromise<Uint8Array>;
|
|
13
|
+
abstract send(buffer: Uint8Array): MaybePromise<void>;
|
|
14
|
+
abstract deinitialize(): MaybePromise<void>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Connection } from "../connection/connection.js";
|
|
2
|
+
import { Transport } from "./transport.js";
|
|
3
|
+
export declare class TransportIntermediate extends Transport implements Transport {
|
|
4
|
+
private readonly connection;
|
|
5
|
+
private readonly obfuscated;
|
|
6
|
+
constructor(connection: Connection, obfuscated?: boolean);
|
|
7
|
+
initialize(): Promise<void>;
|
|
8
|
+
receive(): Promise<Uint8Array>;
|
|
9
|
+
send(buffer: Uint8Array): Promise<void>;
|
|
10
|
+
deinitialize(): void;
|
|
11
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Connection } from "../connection/connection.js";
|
|
2
|
+
import { Transport } from "./transport.js";
|
|
3
|
+
export interface TransportProviderParams {
|
|
4
|
+
dc: "1" | "2" | "3" | "4" | "5" | "1-test" | "2-test" | "3-test";
|
|
5
|
+
}
|
|
6
|
+
export type TransportProvider = (params?: TransportProviderParams) => (cdn: boolean) => {
|
|
7
|
+
connection: Connection;
|
|
8
|
+
transport: Transport;
|
|
9
|
+
dcId: number;
|
|
10
|
+
};
|
|
11
|
+
export declare const defaultDc: TransportProviderParams["dc"];
|
|
12
|
+
export declare const defaultTransportProvider: TransportProvider;
|
package/types/types.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type MaybePromise<T> = T | Promise<T>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare function modExp(a: bigint, b: bigint, n: bigint): bigint;
|
|
2
|
+
export declare function mod(n: bigint, m: bigint): bigint;
|
|
3
|
+
export declare function bigIntFromBuffer(buffer: Uint8Array, little?: boolean, signed?: boolean): bigint;
|
|
4
|
+
export declare function getRandomBigInt(byteLength: number, little?: boolean, signed?: boolean): bigint;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function rsaPad(data: Uint8Array, [serverKey, exponent]: [bigint, bigint]): Promise<Uint8Array>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Message } from "../tl/5_message.js";
|
|
2
|
+
import { MessageContainer } from "../tl/6_message_container.js";
|
|
3
|
+
export declare function getMessageId(): bigint;
|
|
4
|
+
export declare function packUnencryptedMessage(data: Uint8Array): Uint8Array;
|
|
5
|
+
export declare function unpackUnencryptedMessage(buffer: Uint8Array): {
|
|
6
|
+
messageId: bigint;
|
|
7
|
+
message: Uint8Array;
|
|
8
|
+
};
|
|
9
|
+
export declare function encryptMessage(message: Message, authKey: Uint8Array, authKeyId: bigint, salt: bigint, sessionId: bigint): Promise<Uint8Array>;
|
|
10
|
+
export declare function decryptMessage(buffer: Uint8Array, authKey: Uint8Array, authKeyId: bigint, _sessionId: bigint): Promise<Message | MessageContainer>;
|