@tgsnake/skema 1.13.0 → 2.0.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.
Files changed (147) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +124 -15
  3. package/dist/mod.d.ts +10 -0
  4. package/dist/mod.js +10 -0
  5. package/dist/src/Logger.d.ts +20 -0
  6. package/dist/src/Logger.js +23 -0
  7. package/dist/src/deps.d.ts +28 -0
  8. package/dist/src/deps.js +34 -0
  9. package/dist/src/errors/Base.d.ts +53 -0
  10. package/dist/src/errors/Base.js +114 -0
  11. package/dist/src/errors/Client.d.ts +69 -0
  12. package/dist/src/errors/Client.js +69 -0
  13. package/dist/src/errors/File.d.ts +89 -0
  14. package/dist/src/errors/File.js +99 -0
  15. package/dist/src/errors/RpcError.d.ts +115 -0
  16. package/dist/src/errors/RpcError.js +226 -0
  17. package/dist/src/errors/SecretChat.d.ts +78 -0
  18. package/dist/src/errors/SecretChat.js +88 -0
  19. package/dist/src/errors/WebSocket.d.ts +70 -0
  20. package/dist/src/errors/WebSocket.js +80 -0
  21. package/dist/{errors → src/errors}/exceptions/All.d.ts +14 -0
  22. package/dist/{errors → src/errors}/exceptions/All.js +15 -5
  23. package/dist/{errors → src/errors}/exceptions/BadRequest400.d.ts +15 -1
  24. package/dist/src/errors/exceptions/BadRequest400.js +2683 -0
  25. package/dist/{errors → src/errors}/exceptions/Flood420.d.ts +15 -1
  26. package/dist/{errors → src/errors}/exceptions/Flood420.js +25 -24
  27. package/dist/{errors → src/errors}/exceptions/Forbidden403.d.ts +15 -1
  28. package/dist/src/errors/exceptions/Forbidden403.js +243 -0
  29. package/dist/{errors → src/errors}/exceptions/InternalServerError500.d.ts +15 -1
  30. package/dist/src/errors/exceptions/InternalServerError500.js +255 -0
  31. package/dist/{errors → src/errors}/exceptions/NotAcceptable406.d.ts +15 -1
  32. package/dist/{errors → src/errors}/exceptions/NotAcceptable406.js +51 -76
  33. package/dist/src/errors/exceptions/NotFound404.d.ts +27 -0
  34. package/dist/src/errors/exceptions/NotFound404.js +27 -0
  35. package/dist/src/errors/exceptions/SeeOther303.d.ts +39 -0
  36. package/dist/src/errors/exceptions/SeeOther303.js +39 -0
  37. package/dist/src/errors/exceptions/ServiceUnavailable503.d.ts +31 -0
  38. package/dist/src/errors/exceptions/ServiceUnavailable503.js +31 -0
  39. package/dist/{errors → src/errors}/exceptions/Unauthorized401.d.ts +15 -1
  40. package/dist/src/errors/exceptions/Unauthorized401.js +55 -0
  41. package/dist/src/errors/exceptions/index.d.ts +24 -0
  42. package/dist/src/errors/exceptions/index.js +24 -0
  43. package/dist/src/errors/index.d.ts +142 -0
  44. package/dist/src/errors/index.js +178 -0
  45. package/dist/src/helpers.d.ts +102 -0
  46. package/dist/src/helpers.js +176 -0
  47. package/dist/src/index.d.ts +12 -0
  48. package/dist/src/index.js +12 -0
  49. package/dist/{raw → src/raw}/All.d.ts +14 -0
  50. package/dist/{raw → src/raw}/All.js +15 -4
  51. package/dist/{raw → src/raw}/Raw.d.ts +17205 -3
  52. package/dist/{raw → src/raw}/Raw.js +44035 -21917
  53. package/dist/src/raw/UpdateSecretChat.d.ts +186 -0
  54. package/dist/src/raw/UpdateSecretChat.js +215 -0
  55. package/dist/src/raw/core/GzipPacked.d.ts +63 -0
  56. package/dist/src/raw/core/GzipPacked.js +76 -0
  57. package/dist/src/raw/core/Message.d.ts +68 -0
  58. package/dist/src/raw/core/Message.js +105 -0
  59. package/dist/src/raw/core/MsgContainer.d.ts +56 -0
  60. package/dist/src/raw/core/MsgContainer.js +77 -0
  61. package/dist/src/raw/core/TLObject.d.ts +108 -0
  62. package/dist/src/raw/core/TLObject.js +209 -0
  63. package/dist/src/raw/core/index.d.ts +19 -0
  64. package/dist/src/raw/core/index.js +19 -0
  65. package/dist/src/raw/core/primitive/Bool.d.ts +104 -0
  66. package/dist/src/raw/core/primitive/Bool.js +120 -0
  67. package/dist/src/raw/core/primitive/Bytes.d.ts +45 -0
  68. package/dist/src/raw/core/primitive/Bytes.js +76 -0
  69. package/dist/src/raw/core/primitive/Double.d.ts +37 -0
  70. package/dist/src/raw/core/primitive/Double.js +51 -0
  71. package/dist/src/raw/core/primitive/Float.d.ts +37 -0
  72. package/dist/src/raw/core/primitive/Float.js +51 -0
  73. package/dist/src/raw/core/primitive/Int.d.ts +144 -0
  74. package/dist/src/raw/core/primitive/Int.js +237 -0
  75. package/dist/src/raw/core/primitive/String.d.ts +37 -0
  76. package/dist/src/raw/core/primitive/String.js +42 -0
  77. package/dist/src/raw/core/primitive/Vector.d.ts +56 -0
  78. package/dist/src/raw/core/primitive/Vector.js +93 -0
  79. package/dist/src/raw/core/primitive/index.d.ts +20 -0
  80. package/dist/src/raw/core/primitive/index.js +20 -0
  81. package/dist/src/raw/index.d.ts +17 -0
  82. package/dist/src/raw/index.js +17 -0
  83. package/package.json +13 -11
  84. package/dist/Logger.d.ts +0 -3
  85. package/dist/Logger.js +0 -9
  86. package/dist/deps.d.ts +0 -8
  87. package/dist/deps.js +0 -19
  88. package/dist/errors/Base.d.ts +0 -9
  89. package/dist/errors/Base.js +0 -50
  90. package/dist/errors/Client.d.ts +0 -21
  91. package/dist/errors/Client.js +0 -29
  92. package/dist/errors/File.d.ts +0 -13
  93. package/dist/errors/File.js +0 -30
  94. package/dist/errors/RpcError.d.ts +0 -22
  95. package/dist/errors/RpcError.js +0 -120
  96. package/dist/errors/SecretChat.d.ts +0 -13
  97. package/dist/errors/SecretChat.js +0 -30
  98. package/dist/errors/WebSocket.d.ts +0 -13
  99. package/dist/errors/WebSocket.js +0 -30
  100. package/dist/errors/exceptions/BadRequest400.js +0 -3352
  101. package/dist/errors/exceptions/Forbidden403.js +0 -290
  102. package/dist/errors/exceptions/InternalServerError500.js +0 -305
  103. package/dist/errors/exceptions/NotFound404.d.ts +0 -13
  104. package/dist/errors/exceptions/NotFound404.js +0 -19
  105. package/dist/errors/exceptions/SeeOther303.d.ts +0 -25
  106. package/dist/errors/exceptions/SeeOther303.js +0 -34
  107. package/dist/errors/exceptions/ServiceUnavailable503.d.ts +0 -17
  108. package/dist/errors/exceptions/ServiceUnavailable503.js +0 -24
  109. package/dist/errors/exceptions/Unauthorized401.js +0 -54
  110. package/dist/errors/exceptions/index.d.ts +0 -10
  111. package/dist/errors/exceptions/index.js +0 -48
  112. package/dist/errors/index.d.ts +0 -31
  113. package/dist/errors/index.js +0 -111
  114. package/dist/helpers.d.ts +0 -6
  115. package/dist/helpers.js +0 -85
  116. package/dist/index.d.ts +0 -3
  117. package/dist/index.js +0 -34
  118. package/dist/raw/UpdateSecretChat.d.ts +0 -43
  119. package/dist/raw/UpdateSecretChat.js +0 -91
  120. package/dist/raw/core/GzipPacked.d.ts +0 -9
  121. package/dist/raw/core/GzipPacked.js +0 -59
  122. package/dist/raw/core/Message.d.ts +0 -12
  123. package/dist/raw/core/Message.js +0 -80
  124. package/dist/raw/core/MsgContainer.d.ts +0 -10
  125. package/dist/raw/core/MsgContainer.js +0 -68
  126. package/dist/raw/core/TLObject.d.ts +0 -18
  127. package/dist/raw/core/TLObject.js +0 -108
  128. package/dist/raw/core/index.d.ts +0 -6
  129. package/dist/raw/core/index.js +0 -46
  130. package/dist/raw/core/primitive/Bool.d.ts +0 -19
  131. package/dist/raw/core/primitive/Bool.js +0 -41
  132. package/dist/raw/core/primitive/Bytes.d.ts +0 -6
  133. package/dist/raw/core/primitive/Bytes.js +0 -41
  134. package/dist/raw/core/primitive/Double.d.ts +0 -6
  135. package/dist/raw/core/primitive/Double.js +0 -24
  136. package/dist/raw/core/primitive/Float.d.ts +0 -6
  137. package/dist/raw/core/primitive/Float.js +0 -24
  138. package/dist/raw/core/primitive/Int.d.ts +0 -22
  139. package/dist/raw/core/primitive/Int.js +0 -122
  140. package/dist/raw/core/primitive/String.d.ts +0 -6
  141. package/dist/raw/core/primitive/String.js +0 -15
  142. package/dist/raw/core/primitive/Vector.d.ts +0 -8
  143. package/dist/raw/core/primitive/Vector.js +0 -49
  144. package/dist/raw/core/primitive/index.d.ts +0 -7
  145. package/dist/raw/core/primitive/index.js +0 -22
  146. package/dist/raw/index.d.ts +0 -4
  147. package/dist/raw/index.js +0 -17
@@ -0,0 +1,104 @@
1
+ /**
2
+ * tgsnake - Telegram MTProto library for javascript or typescript.
3
+ * Copyright (C) 2026 tgsnake <https://github.com/tgsnake>
4
+ *
5
+ * THIS FILE IS PART OF TGSNAKE
6
+ *
7
+ * tgsnake is a free software: you can redistribute it and/or modify
8
+ * it under the terms of the MIT License as published.
9
+ */
10
+ import { TLObject } from '../TLObject.js';
11
+ import { BytesIO, Buffer } from '../../../deps.js';
12
+ /**
13
+ * Represents the false boolean constructor in the Telegram MTProto schema.
14
+ *
15
+ * @extends TLObject
16
+ */
17
+ export declare class BoolFalse extends TLObject {
18
+ /**
19
+ * Unique Class ID representing `BoolFalse` (0xbc799737).
20
+ */
21
+ static ID: number;
22
+ /**
23
+ * The underlying native boolean value representation.
24
+ */
25
+ static value: boolean;
26
+ /**
27
+ * Serializes the `BoolFalse` class ID into a 4-byte buffer (little-endian).
28
+ *
29
+ * @override
30
+ * @returns A Buffer containing the serialized Class ID.
31
+ */
32
+ static write(): Buffer;
33
+ /**
34
+ * Reads the boolean value from a stream (always resolves to `false`).
35
+ *
36
+ * @param _data - Unused BytesIO stream.
37
+ * @param _arg - Unused arguments.
38
+ * @returns A promise resolving to `false`.
39
+ */
40
+ static read(_data: BytesIO, ..._arg: Array<any>): Promise<boolean>;
41
+ }
42
+ /**
43
+ * Represents the true boolean constructor in the Telegram MTProto schema.
44
+ *
45
+ * @extends BoolFalse
46
+ */
47
+ export declare class BoolTrue extends BoolFalse {
48
+ /**
49
+ * Unique Class ID representing `BoolTrue` (0x997275b5).
50
+ */
51
+ static ID: number;
52
+ /**
53
+ * The underlying native boolean value representation.
54
+ */
55
+ static value: boolean;
56
+ /**
57
+ * Serializes the `BoolTrue` class ID into a 4-byte buffer (little-endian).
58
+ *
59
+ * @override
60
+ * @returns A Buffer containing the serialized Class ID.
61
+ */
62
+ static write(): Buffer;
63
+ /**
64
+ * Reads the boolean value from a stream (always resolves to `true`).
65
+ *
66
+ * @param _data - Unused BytesIO stream.
67
+ * @param _arg - Unused arguments.
68
+ * @returns A promise resolving to `true`.
69
+ */
70
+ static read(_data: BytesIO, ..._arg: Array<any>): Promise<boolean>;
71
+ }
72
+ /**
73
+ * Dynamic dispatcher class representing MTProto abstract boolean values.
74
+ *
75
+ * @remarks
76
+ * In MTProto, boolean values are represented as explicit class instances (`BoolTrue` or `BoolFalse`)
77
+ * rather than raw bits or primitive bytes. This class coordinates dynamic serialization and
78
+ * deserialization between native JavaScript boolean values (`true`/`false`) and the corresponding MTProto constructors.
79
+ *
80
+ * @extends TLObject
81
+ * @example
82
+ * ```typescript
83
+ * const buffer = Bool.write(true); // Serializes `true` to a Buffer using BoolTrue
84
+ * const val = await Bool.read(bytesIO); // Deserializes from stream to native boolean
85
+ * ```
86
+ */
87
+ export declare class Bool extends TLObject {
88
+ className: string;
89
+ /**
90
+ * Serializes a native JS boolean value into a Buffer using the appropriate constructor.
91
+ *
92
+ * @param value - The boolean value to serialize.
93
+ * @returns A Buffer containing the serialized `BoolTrue` or `BoolFalse` representation.
94
+ */
95
+ static write(value: boolean): Buffer;
96
+ /**
97
+ * Reads a 32-bit boolean constructor identifier from the stream and resolves it to a native boolean.
98
+ *
99
+ * @param data - The `BytesIO` stream to read from.
100
+ * @param _arg - Unused arguments.
101
+ * @returns A promise resolving to the decoded boolean value.
102
+ */
103
+ static read(data: BytesIO, ..._arg: Array<any>): Promise<boolean>;
104
+ }
@@ -0,0 +1,120 @@
1
+ /**
2
+ * tgsnake - Telegram MTProto library for javascript or typescript.
3
+ * Copyright (C) 2026 tgsnake <https://github.com/tgsnake>
4
+ *
5
+ * THIS FILE IS PART OF TGSNAKE
6
+ *
7
+ * tgsnake is a free software: you can redistribute it and/or modify
8
+ * it under the terms of the MIT License as published.
9
+ */
10
+ import { TLObject } from '../TLObject.js';
11
+ import { Buffer } from '../../../deps.js';
12
+ /**
13
+ * Represents the false boolean constructor in the Telegram MTProto schema.
14
+ *
15
+ * @extends TLObject
16
+ */
17
+ export class BoolFalse extends TLObject {
18
+ /**
19
+ * Unique Class ID representing `BoolFalse` (0xbc799737).
20
+ */
21
+ static ID = 0xbc799737;
22
+ /**
23
+ * The underlying native boolean value representation.
24
+ */
25
+ static value = false;
26
+ /**
27
+ * Serializes the `BoolFalse` class ID into a 4-byte buffer (little-endian).
28
+ *
29
+ * @override
30
+ * @returns A Buffer containing the serialized Class ID.
31
+ */
32
+ static write() {
33
+ const buff = Buffer.alloc(4);
34
+ buff.writeUInt32LE(BoolFalse.ID);
35
+ return buff;
36
+ }
37
+ /**
38
+ * Reads the boolean value from a stream (always resolves to `false`).
39
+ *
40
+ * @param _data - Unused BytesIO stream.
41
+ * @param _arg - Unused arguments.
42
+ * @returns A promise resolving to `false`.
43
+ */
44
+ static async read(_data, ..._arg) {
45
+ return BoolFalse.value;
46
+ }
47
+ }
48
+ /**
49
+ * Represents the true boolean constructor in the Telegram MTProto schema.
50
+ *
51
+ * @extends BoolFalse
52
+ */
53
+ export class BoolTrue extends BoolFalse {
54
+ /**
55
+ * Unique Class ID representing `BoolTrue` (0x997275b5).
56
+ */
57
+ static ID = 0x997275b5;
58
+ /**
59
+ * The underlying native boolean value representation.
60
+ */
61
+ static value = true;
62
+ /**
63
+ * Serializes the `BoolTrue` class ID into a 4-byte buffer (little-endian).
64
+ *
65
+ * @override
66
+ * @returns A Buffer containing the serialized Class ID.
67
+ */
68
+ static write() {
69
+ const buff = Buffer.alloc(4);
70
+ buff.writeUInt32LE(BoolTrue.ID);
71
+ return buff;
72
+ }
73
+ /**
74
+ * Reads the boolean value from a stream (always resolves to `true`).
75
+ *
76
+ * @param _data - Unused BytesIO stream.
77
+ * @param _arg - Unused arguments.
78
+ * @returns A promise resolving to `true`.
79
+ */
80
+ static async read(_data, ..._arg) {
81
+ return BoolTrue.value;
82
+ }
83
+ }
84
+ /**
85
+ * Dynamic dispatcher class representing MTProto abstract boolean values.
86
+ *
87
+ * @remarks
88
+ * In MTProto, boolean values are represented as explicit class instances (`BoolTrue` or `BoolFalse`)
89
+ * rather than raw bits or primitive bytes. This class coordinates dynamic serialization and
90
+ * deserialization between native JavaScript boolean values (`true`/`false`) and the corresponding MTProto constructors.
91
+ *
92
+ * @extends TLObject
93
+ * @example
94
+ * ```typescript
95
+ * const buffer = Bool.write(true); // Serializes `true` to a Buffer using BoolTrue
96
+ * const val = await Bool.read(bytesIO); // Deserializes from stream to native boolean
97
+ * ```
98
+ */
99
+ export class Bool extends TLObject {
100
+ className = 'Bool';
101
+ /**
102
+ * Serializes a native JS boolean value into a Buffer using the appropriate constructor.
103
+ *
104
+ * @param value - The boolean value to serialize.
105
+ * @returns A Buffer containing the serialized `BoolTrue` or `BoolFalse` representation.
106
+ */
107
+ static write(value) {
108
+ return value ? BoolTrue.write() : BoolFalse.write();
109
+ }
110
+ /**
111
+ * Reads a 32-bit boolean constructor identifier from the stream and resolves it to a native boolean.
112
+ *
113
+ * @param data - The `BytesIO` stream to read from.
114
+ * @param _arg - Unused arguments.
115
+ * @returns A promise resolving to the decoded boolean value.
116
+ */
117
+ static async read(data, ..._arg) {
118
+ return data.readUInt32LE(4) === BoolTrue.ID;
119
+ }
120
+ }
@@ -0,0 +1,45 @@
1
+ /**
2
+ * tgsnake - Telegram MTProto library for javascript or typescript.
3
+ * Copyright (C) 2026 tgsnake <https://github.com/tgsnake>
4
+ *
5
+ * THIS FILE IS PART OF TGSNAKE
6
+ *
7
+ * tgsnake is a free software: you can redistribute it and/or modify
8
+ * it under the terms of the MIT License as published.
9
+ */
10
+ import { TLObject } from '../TLObject.js';
11
+ import { BytesIO, Buffer } from '../../../deps.js';
12
+ /**
13
+ * Serializer and deserializer for raw, variable-length byte arrays.
14
+ *
15
+ * @remarks
16
+ * In MTProto, raw byte arrays are serialized with a custom length-prefix scheme:
17
+ * - If the array is 253 bytes or shorter:
18
+ * - The first byte contains the exact length.
19
+ * - Followed by the raw payload bytes.
20
+ * - Followed by `0-3` padding bytes to align the entire block to a 4-byte boundary.
21
+ * - If the array is longer than 253 bytes:
22
+ * - The first byte is written as exactly `254` (0xfe).
23
+ * - The next 3 bytes contain the little-endian length.
24
+ * - Followed by the raw payload bytes.
25
+ * - Followed by `0-3` padding bytes to align the entire block to a 4-byte boundary.
26
+ *
27
+ * @extends TLObject
28
+ */
29
+ export declare class Bytes extends TLObject {
30
+ /**
31
+ * Serializes a Node.js Buffer value into a length-prefixed and padded MTProto binary structure.
32
+ *
33
+ * @param value - The input Buffer to serialize.
34
+ * @returns A Buffer containing the formatted prefix, data, and padding bytes.
35
+ */
36
+ static write(value: Buffer): Buffer;
37
+ /**
38
+ * Reads, decodes, and aligns a variable-length byte array from a binary stream.
39
+ *
40
+ * @param data - The `BytesIO` stream to read the byte array from.
41
+ * @param _args - Unused additional parameters.
42
+ * @returns A promise resolving to the decoded Node.js Buffer.
43
+ */
44
+ static read(data: BytesIO, ..._args: Array<any>): Promise<Buffer>;
45
+ }
@@ -0,0 +1,76 @@
1
+ /**
2
+ * tgsnake - Telegram MTProto library for javascript or typescript.
3
+ * Copyright (C) 2026 tgsnake <https://github.com/tgsnake>
4
+ *
5
+ * THIS FILE IS PART OF TGSNAKE
6
+ *
7
+ * tgsnake is a free software: you can redistribute it and/or modify
8
+ * it under the terms of the MIT License as published.
9
+ */
10
+ import { TLObject } from '../TLObject.js';
11
+ import { Buffer } from '../../../deps.js';
12
+ import { bufferToBigint, bigintToBuffer, mod } from '../../../helpers.js';
13
+ /**
14
+ * Serializer and deserializer for raw, variable-length byte arrays.
15
+ *
16
+ * @remarks
17
+ * In MTProto, raw byte arrays are serialized with a custom length-prefix scheme:
18
+ * - If the array is 253 bytes or shorter:
19
+ * - The first byte contains the exact length.
20
+ * - Followed by the raw payload bytes.
21
+ * - Followed by `0-3` padding bytes to align the entire block to a 4-byte boundary.
22
+ * - If the array is longer than 253 bytes:
23
+ * - The first byte is written as exactly `254` (0xfe).
24
+ * - The next 3 bytes contain the little-endian length.
25
+ * - Followed by the raw payload bytes.
26
+ * - Followed by `0-3` padding bytes to align the entire block to a 4-byte boundary.
27
+ *
28
+ * @extends TLObject
29
+ */
30
+ export class Bytes extends TLObject {
31
+ /**
32
+ * Serializes a Node.js Buffer value into a length-prefixed and padded MTProto binary structure.
33
+ *
34
+ * @param value - The input Buffer to serialize.
35
+ * @returns A Buffer containing the formatted prefix, data, and padding bytes.
36
+ */
37
+ static write(value) {
38
+ const length = Buffer.byteLength(value);
39
+ if (length <= 253) {
40
+ return Buffer.concat([
41
+ Buffer.from([length]),
42
+ value,
43
+ Buffer.alloc(mod(-(length + 1), 4)),
44
+ ]);
45
+ }
46
+ else {
47
+ return Buffer.concat([
48
+ Buffer.from([254]),
49
+ bigintToBuffer(BigInt(length), 3),
50
+ value,
51
+ Buffer.alloc(mod(-length, 4)),
52
+ ]);
53
+ }
54
+ }
55
+ /**
56
+ * Reads, decodes, and aligns a variable-length byte array from a binary stream.
57
+ *
58
+ * @param data - The `BytesIO` stream to read the byte array from.
59
+ * @param _args - Unused additional parameters.
60
+ * @returns A promise resolving to the decoded Node.js Buffer.
61
+ */
62
+ static async read(data, ..._args) {
63
+ let length = data.read(1)[0];
64
+ if (length <= 253) {
65
+ const x = data.read(length);
66
+ data.read(mod(-(length + 1), 4));
67
+ return x;
68
+ }
69
+ else {
70
+ length = Number(bufferToBigint(data.read(3)));
71
+ const x = data.read(length);
72
+ data.read(mod(-length, 4));
73
+ return x;
74
+ }
75
+ }
76
+ }
@@ -0,0 +1,37 @@
1
+ /**
2
+ * tgsnake - Telegram MTProto library for javascript or typescript.
3
+ * Copyright (C) 2026 tgsnake <https://github.com/tgsnake>
4
+ *
5
+ * THIS FILE IS PART OF TGSNAKE
6
+ *
7
+ * tgsnake is a free software: you can redistribute it and/or modify
8
+ * it under the terms of the MIT License as published.
9
+ */
10
+ import { TLObject } from '../TLObject.js';
11
+ import { BytesIO, Buffer } from '../../../deps.js';
12
+ /**
13
+ * Serializer and deserializer for double-precision 64-bit floating-point numbers (IEEE 754).
14
+ *
15
+ * @remarks
16
+ * In MTProto, double-precision floats are represented as 8 bytes, typically in little-endian order.
17
+ *
18
+ * @extends TLObject
19
+ */
20
+ export declare class Double extends TLObject {
21
+ /**
22
+ * Serializes a JS `number` into an 8-byte buffer.
23
+ *
24
+ * @param value - The floating-point number to serialize.
25
+ * @param little - Set to `true` to use little-endian byte ordering; set to `false` for big-endian. Defaults to `true`.
26
+ * @returns A Buffer containing the 8-byte representation of the double.
27
+ */
28
+ static write(value: number, little?: boolean): Buffer;
29
+ /**
30
+ * Reads and decodes a double-precision floating-point number from a binary stream.
31
+ *
32
+ * @param data - The `BytesIO` stream to read the double from.
33
+ * @param little - Set to `true` to read in little-endian byte ordering; set to `false` for big-endian. Defaults to `true`.
34
+ * @returns A promise resolving to the decoded number value.
35
+ */
36
+ static read(data: BytesIO, little?: boolean): Promise<number>;
37
+ }
@@ -0,0 +1,51 @@
1
+ /**
2
+ * tgsnake - Telegram MTProto library for javascript or typescript.
3
+ * Copyright (C) 2026 tgsnake <https://github.com/tgsnake>
4
+ *
5
+ * THIS FILE IS PART OF TGSNAKE
6
+ *
7
+ * tgsnake is a free software: you can redistribute it and/or modify
8
+ * it under the terms of the MIT License as published.
9
+ */
10
+ import { TLObject } from '../TLObject.js';
11
+ import { Buffer } from '../../../deps.js';
12
+ /**
13
+ * Serializer and deserializer for double-precision 64-bit floating-point numbers (IEEE 754).
14
+ *
15
+ * @remarks
16
+ * In MTProto, double-precision floats are represented as 8 bytes, typically in little-endian order.
17
+ *
18
+ * @extends TLObject
19
+ */
20
+ export class Double extends TLObject {
21
+ /**
22
+ * Serializes a JS `number` into an 8-byte buffer.
23
+ *
24
+ * @param value - The floating-point number to serialize.
25
+ * @param little - Set to `true` to use little-endian byte ordering; set to `false` for big-endian. Defaults to `true`.
26
+ * @returns A Buffer containing the 8-byte representation of the double.
27
+ */
28
+ static write(value, little = true) {
29
+ const buffer = Buffer.alloc(8);
30
+ if (little) {
31
+ buffer.writeDoubleLE(value);
32
+ }
33
+ else {
34
+ buffer.writeDoubleBE(value);
35
+ }
36
+ return buffer;
37
+ }
38
+ /**
39
+ * Reads and decodes a double-precision floating-point number from a binary stream.
40
+ *
41
+ * @param data - The `BytesIO` stream to read the double from.
42
+ * @param little - Set to `true` to read in little-endian byte ordering; set to `false` for big-endian. Defaults to `true`.
43
+ * @returns A promise resolving to the decoded number value.
44
+ */
45
+ static async read(data, little = true) {
46
+ if (little) {
47
+ return data.readDoubleLE();
48
+ }
49
+ return data.readDoubleBE();
50
+ }
51
+ }
@@ -0,0 +1,37 @@
1
+ /**
2
+ * tgsnake - Telegram MTProto library for javascript or typescript.
3
+ * Copyright (C) 2026 tgsnake <https://github.com/tgsnake>
4
+ *
5
+ * THIS FILE IS PART OF TGSNAKE
6
+ *
7
+ * tgsnake is a free software: you can redistribute it and/or modify
8
+ * it under the terms of the MIT License as published.
9
+ */
10
+ import { TLObject } from '../TLObject.js';
11
+ import { BytesIO, Buffer } from '../../../deps.js';
12
+ /**
13
+ * Serializer and deserializer for single-precision 32-bit floating-point numbers (IEEE 754).
14
+ *
15
+ * @remarks
16
+ * In MTProto, single-precision floats are represented as 4 bytes, typically in little-endian order.
17
+ *
18
+ * @extends TLObject
19
+ */
20
+ export declare class Float extends TLObject {
21
+ /**
22
+ * Serializes a JS `number` into a 4-byte buffer.
23
+ *
24
+ * @param value - The floating-point number to serialize.
25
+ * @param little - Set to `true` to use little-endian byte ordering; set to `false` for big-endian. Defaults to `true`.
26
+ * @returns A Buffer containing the 4-byte representation of the float.
27
+ */
28
+ static write(value: number, little?: boolean): Buffer;
29
+ /**
30
+ * Reads and decodes a single-precision floating-point number from a binary stream.
31
+ *
32
+ * @param data - The `BytesIO` stream to read the float from.
33
+ * @param little - Set to `true` to read in little-endian byte ordering; set to `false` for big-endian. Defaults to `true`.
34
+ * @returns A promise resolving to the decoded number value.
35
+ */
36
+ static read(data: BytesIO, little?: boolean): Promise<number>;
37
+ }
@@ -0,0 +1,51 @@
1
+ /**
2
+ * tgsnake - Telegram MTProto library for javascript or typescript.
3
+ * Copyright (C) 2026 tgsnake <https://github.com/tgsnake>
4
+ *
5
+ * THIS FILE IS PART OF TGSNAKE
6
+ *
7
+ * tgsnake is a free software: you can redistribute it and/or modify
8
+ * it under the terms of the MIT License as published.
9
+ */
10
+ import { TLObject } from '../TLObject.js';
11
+ import { Buffer } from '../../../deps.js';
12
+ /**
13
+ * Serializer and deserializer for single-precision 32-bit floating-point numbers (IEEE 754).
14
+ *
15
+ * @remarks
16
+ * In MTProto, single-precision floats are represented as 4 bytes, typically in little-endian order.
17
+ *
18
+ * @extends TLObject
19
+ */
20
+ export class Float extends TLObject {
21
+ /**
22
+ * Serializes a JS `number` into a 4-byte buffer.
23
+ *
24
+ * @param value - The floating-point number to serialize.
25
+ * @param little - Set to `true` to use little-endian byte ordering; set to `false` for big-endian. Defaults to `true`.
26
+ * @returns A Buffer containing the 4-byte representation of the float.
27
+ */
28
+ static write(value, little = true) {
29
+ const buffer = Buffer.alloc(4);
30
+ if (little) {
31
+ buffer.writeFloatLE(value);
32
+ }
33
+ else {
34
+ buffer.writeFloatBE(value);
35
+ }
36
+ return buffer;
37
+ }
38
+ /**
39
+ * Reads and decodes a single-precision floating-point number from a binary stream.
40
+ *
41
+ * @param data - The `BytesIO` stream to read the float from.
42
+ * @param little - Set to `true` to read in little-endian byte ordering; set to `false` for big-endian. Defaults to `true`.
43
+ * @returns A promise resolving to the decoded number value.
44
+ */
45
+ static async read(data, little = true) {
46
+ if (little) {
47
+ return data.readFloatLE();
48
+ }
49
+ return data.readFloatBE();
50
+ }
51
+ }
@@ -0,0 +1,144 @@
1
+ /**
2
+ * tgsnake - Telegram MTProto library for javascript or typescript.
3
+ * Copyright (C) 2026 tgsnake <https://github.com/tgsnake>
4
+ *
5
+ * THIS FILE IS PART OF TGSNAKE
6
+ *
7
+ * tgsnake is a free software: you can redistribute it and/or modify
8
+ * it under the terms of the MIT License as published.
9
+ */
10
+ import { TLObject } from '../TLObject.js';
11
+ import { BytesIO, Buffer } from '../../../deps.js';
12
+ /**
13
+ * Serializer and deserializer for standard 32-bit (4-byte) signed or unsigned integers.
14
+ *
15
+ * @extends TLObject
16
+ */
17
+ export declare class Int extends TLObject {
18
+ /**
19
+ * The byte size of a standard 32-bit integer (4 bytes).
20
+ */
21
+ static SIZE: number;
22
+ /**
23
+ * Serializes a 32-bit integer into a Buffer.
24
+ *
25
+ * @param value - The integer value to write (accepts `number` or `bigint`).
26
+ * @param signed - Set to `true` if the integer is signed; set to `false` if unsigned. Defaults to `true`.
27
+ * @param little - Set to `true` to write in little-endian format; set to `false` for big-endian. Defaults to `true`.
28
+ * @returns A Buffer containing the 4-byte representation of the integer.
29
+ */
30
+ static write(value: number | bigint, signed?: boolean, little?: boolean): Buffer;
31
+ /**
32
+ * Reads and decodes a 32-bit integer from a binary stream.
33
+ *
34
+ * @param data - The `BytesIO` stream to read the integer from.
35
+ * @param signed - Set to `true` to parse as a signed integer; set to `false` for unsigned. Defaults to `true`.
36
+ * @param little - Set to `true` to read in little-endian format; set to `false` for big-endian. Defaults to `true`.
37
+ * @param size - The exact number of bytes to read from the stream. Defaults to `Int.SIZE`.
38
+ * @returns A promise resolving to the decoded number.
39
+ */
40
+ static read(data: BytesIO, signed?: boolean, little?: boolean, size?: number): Promise<number>;
41
+ }
42
+ /**
43
+ * Serializer and deserializer for 64-bit (8-byte) signed or unsigned integers.
44
+ *
45
+ * @remarks
46
+ * In MTProto, 64-bit integers are heavily used for message IDs, session IDs, chat IDs,
47
+ * and salt values. Because standard JS numbers only support safe integers up to 53 bits,
48
+ * this class operates on native JavaScript `bigint` values.
49
+ *
50
+ * @extends TLObject
51
+ */
52
+ export declare class Long extends TLObject {
53
+ /**
54
+ * The byte size of a 64-bit long integer (8 bytes).
55
+ */
56
+ static SIZE: number;
57
+ /**
58
+ * Reads and decodes a 64-bit integer from a binary stream.
59
+ *
60
+ * @param data - The `BytesIO` stream to read the long integer from.
61
+ * @param signed - Set to `true` to parse as a signed integer; set to `false` for unsigned. Defaults to `true`.
62
+ * @param little - Set to `true` to read in little-endian format; set to `false` for big-endian. Defaults to `true`.
63
+ * @param size - The exact number of bytes to read from the stream. Defaults to `Long.SIZE`.
64
+ * @returns A promise resolving to the decoded native `bigint`.
65
+ */
66
+ static read(data: BytesIO, signed?: boolean, little?: boolean, size?: number): Promise<bigint>;
67
+ /**
68
+ * Serializes a 64-bit integer value into a Buffer.
69
+ *
70
+ * @param value - The native `bigint` value to serialize.
71
+ * @param signed - Set to `true` if the integer is signed; set to `false` if unsigned. Defaults to `true`.
72
+ * @param little - Set to `true` to write in little-endian format; set to `false` for big-endian. Defaults to `true`.
73
+ * @returns A Buffer containing the 8-byte representation of the 64-bit integer.
74
+ */
75
+ static write(value: bigint, signed?: boolean, little?: boolean): Buffer;
76
+ }
77
+ /**
78
+ * Serializer and deserializer for 128-bit (16-byte) integers.
79
+ *
80
+ * @remarks
81
+ * Used in MTProto cryptographic handshakes, secure nonces, and session key generation.
82
+ * Operates on native JavaScript `bigint` values.
83
+ *
84
+ * @extends Long
85
+ */
86
+ export declare class Int128 extends Long {
87
+ /**
88
+ * The byte size of a 128-bit integer (16 bytes).
89
+ */
90
+ static SIZE: number;
91
+ /**
92
+ * Reads and decodes a 128-bit integer from a binary stream.
93
+ *
94
+ * @param data - The `BytesIO` stream to read the integer from.
95
+ * @param signed - Set to `true` to parse as signed; set to `false` for unsigned. Defaults to `true`.
96
+ * @param little - Set to `true` to read in little-endian format; set to `false` for big-endian. Defaults to `true`.
97
+ * @param size - The exact number of bytes to read from the stream. Defaults to `Int128.SIZE`.
98
+ * @returns A promise resolving to the decoded native `bigint`.
99
+ */
100
+ static read(data: BytesIO, signed?: boolean, little?: boolean, size?: number): Promise<bigint>;
101
+ /**
102
+ * Serializes a 128-bit integer into a Buffer.
103
+ *
104
+ * @param value - The native `bigint` to serialize.
105
+ * @param _signed - Unused parameter.
106
+ * @param _little - Unused parameter.
107
+ * @returns A Buffer containing the 16-byte representation of the 128-bit integer.
108
+ */
109
+ static write(value: bigint, _signed?: boolean, _little?: boolean): Buffer;
110
+ }
111
+ /**
112
+ * Serializer and deserializer for 256-bit (32-byte) integers.
113
+ *
114
+ * @remarks
115
+ * Extensively used in cryptographic tasks, DH (Diffie-Hellman) parameters, and authorization key hashing.
116
+ * Operates on native JavaScript `bigint` values.
117
+ *
118
+ * @extends Long
119
+ */
120
+ export declare class Int256 extends Long {
121
+ /**
122
+ * The byte size of a 256-bit integer (32 bytes).
123
+ */
124
+ static SIZE: number;
125
+ /**
126
+ * Reads and decodes a 256-bit integer from a binary stream.
127
+ *
128
+ * @param data - The `BytesIO` stream to read the integer from.
129
+ * @param signed - Set to `true` to parse as signed; set to `false` for unsigned. Defaults to `true`.
130
+ * @param little - Set to `true` to read in little-endian format; set to `false` for big-endian. Defaults to `true`.
131
+ * @param size - The exact number of bytes to read from the stream. Defaults to `Int256.SIZE`.
132
+ * @returns A promise resolving to the decoded native `bigint`.
133
+ */
134
+ static read(data: BytesIO, signed?: boolean, little?: boolean, size?: number): Promise<bigint>;
135
+ /**
136
+ * Serializes a 256-bit integer into a Buffer.
137
+ *
138
+ * @param value - The native `bigint` to serialize.
139
+ * @param _signed - Unused parameter.
140
+ * @param _little - Unused parameter.
141
+ * @returns A Buffer containing the 32-byte representation of the 256-bit integer.
142
+ */
143
+ static write(value: bigint, _signed?: boolean, _little?: boolean): Buffer;
144
+ }